Learn creative coding writing simple programs

39. The candy-space. Understanding noise() with 1 parameter

When we use noise() with one parameter Processing assumes the missing two parameters are 0. We present noise as a function that picks up candies from inside a box. To locate each candy we need to give noise() three parameters: x, y and z. We are used to x and y now from working with the screen. The z represents the depth, so we no longer are limited to the display surface, but we can imagine objects behind the display and objects in front of the display.
This imaginary candy space is full of candies of different colors. Each time our program starts, Processing fills the candy space with candies. But the space has a unique property: candies next to each other are similar in color. You will not find a blue candy next to a green candy. That's the reason why, if you want to get slowly changing colors out of noise(), you should choose candies that are close to each other. That means changing the noise() parameters slowly, in steps smaller than 0.03. With larger increments you probably get very different values out of noise().


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); } ```