Learn creative coding writing simple programs

38. Animate the ocean surface using noise()

Imagine the noise() function is like looking through a hole in a paper. The noise function gives you back a random number depending on the parameters you send. In the case of our paper with a hole, it would return the color we see through the hole, and the parameters actually mean in which direction we are looking through the hole. If we point a little bit up, or a little bit right, the color changes. The same way, if we change the parameters in our noise() function a little bit, the number we get also changes a little bit.
In this episode we use the noise() function with two parameters instead of one. In our example, the first parameter is our current horizontal position and the second parameter is the time. As we slowly change time, the random numbers we get also change, creating something that looks like the surface of the sea.

Tags: animation, 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, use ```processing and ``` like this:
  void setup() {
    size(600, 600);