Learn creative coding writing simple programs

36. Organic random animation using noise()

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!

Tags: random, noise

Code editor

You can make changes to the code below. Then
Below you can ask and answer questions related to this video. If your question is unrelated to the video, please post it at the Processing Forum as I'm unable to help with all of your programs and still have enough free time to eat and sleep :)
comments powered by Disqus