Now you know how to write code using functions, variables, and if statements. So far your code has worked by executing each line one after the other: if you want to draw three circles, you’d have to write three separate calls to the circle function.
I used nested for loop and stroke() and rect() for giving a random color to each pixel on the canvas. random colored pixels
A canvas with larger no of pixels(around 1e5) was having trouble with higher frameRates. It also made the Preview and the editor laggy.
Is there a better and more efficient ways to do this?
A great explanation by The Coding Train RELATED to second method ( i.e. the pixels array one), in case if someone else need help too. However, he uses pixelDensity(1) in the video, which makes things a bit simpler but it is a deprecated method.