DA1: TIPS: Random VS. Noise

You have already used the random() function in your code, but there is another way to make something move or get drawn in an unpredictable way that is not quite as jumpy as the random.

Random

If you pick 100 random values one after the other, there will be no relation to to the values before and after each number. They are random.

Random values used as the fill() color of rectangles. The result looks (and is) like white noise.

If you use random values as the x and y coordinates for drawing something, the result is very… well… random.

• With random(), you set the minimum and maximum values as the parameters when calling the function
• The function returns a random value between the min and max

Noise

• The noise() function in Processing is based on Perlin noise
• When you call the noise() function, it returns a value between 0.0-1.0 (so in most cases you need to scale the value somehow)
• You can think of the parameter/parameters for noise as coordinates for moving in a cloud of noise values.
• Each values is only slightly different from the value next to it, which creates a smooth transition between the values

Examples

Particles moving based on noise. A line is draw between points that are closer to each other than a set threshold.

This one is based on the example above with some adjustments (hiding the ellipses, more particles etc.)