Learn creative coding writing simple programs

53. Create a pattern by drawing 150000 pixels

Instead of drawing some shapes in the screen, this time we are going to draw every single pixel in our display. We draw first all the pixels in the first column, then the second column and so on until we cover the whole screen. If we always use the same color the result is the same as using background(). But if we change the color of each pixel we can create interesting patterns. We quickly try using random(), noise() and sin(). Finally we add a line that saves the picture to the hard drive. But it's not nice to save it always with the same name, because the previous image gets replaced. To solve this we generate a random name for our picture. Each time the program runs, it saves an image with a random file name.

Tags: pattern, texture, while, loop, sin, noise, random

Code editor

You can make changes to the code below. Then

Questions and comments

Try to stay close to the topic of this episode. Use the Processing forums for help with unrelated Processing projects (or hire me for help ;-)

To indicate that a word in your comment is code, use the `backtick`. Example
Do `float` and `int` smell similar?
To highlight code blocks, surround it with ``` code-fences ``` like this:
``` void setup() { size(600, 600); } ```