Learn creative coding writing simple programs

37. Make a rectangle dance using noise()

Our second experiment using the noise() function. In this case we make a rectangle move, rotate and resize using several calls to the noise() function. The noise() function takes one parameter. If you call noise() several times and the parameter is identical, you get back the same random number.
In our animation we call noise() five times with different parameters and we also try what happens when the parameters are equal. In that case it feels like the rectangle properties are linked. For example, moving to the right equals to a larger rectangle, or moving to the right means more clockwise rotation.
Try animating also the background color, the fill color, the stroke, and maybe change the different numbers in the program trying to predict which effect your change will produce. Can you make the rectangle move only on the left half of the display?

Tags: noise, random, animation

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