Fun programming with Processing, episode 36. We have used random() in many of our episodes. We could say random() has one problem: it's too random. Things in real life do not jump from place to place, but move in small increments. The noise() function allows us to get that kind of random numbers.
There are some differences between random() and noise(). random() returns a number between a minimum and a maximum value. noise() returns a value between 0 and 1. The parameters used when calling random set the minimum and maximum values. The only parameter used in noise() is used to get random numbers that do not change too much.
So if I call noise(3.00) and then noise(3.01), they will return a random number, but in both cases the number will not be very different. This is great for animating positions, sizes, rotation or colors.
Normally we will be interested in ranges of numbers greater than the default 0 ... 1 range. We solve this by multiplying whatever number comes out of noise(). For example if we multiply noise() by 100, we will get a number between 0 and 100.
Try to use noise() in any of the programs we created in past episodes!
www.funprogramming.org
Link to this comment:
All Comments (0)