Open In App

p5.js noise() Function

The noise() function is used to return a number generated by Perlin noise at the given coordinates. This value is semi-random, which means that the value would be fixed for a coordinate for the lifespan of the program.

The Perlin noise value is different from the value returned by the random() function as this noise has a more natural and harmonic succession compared to the standard one.



Syntax:

noise(x, [y], [z])

Parameter: This function accept three parameters as mentioned above and described below:



Return Value: It returns the Perlin noise value between 0 and 1.

Below examples illustrates the noise() function in p5.js:

Example 1: Plotting the noise values of the y-coordinate of the moving point.

Example 2: This example demonstrates the semi-random property of a function.

Example 3: This example uses two parameters for defining a point in the noise space.

Online editor: https://editor.p5js.org/
Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/amp/

Reference: https://p5js.org/reference/#/p5/noise


Article Tags :