noise_detail()#

Adjusts the character and level of detail of Processing’s noise algorithm, produced by the noise() function.

Examples#

example picture for noise_detail()
 1import numpy as np
 2
 3def setup():
 4    py5.noise_seed(42)
 5    draw_noise_line(1, 0.25 * py5.height)
 6    draw_noise_line(2, 0.50 * py5.height)
 7    draw_noise_line(4, 0.75 * py5.height)
 8
 9
10def draw_noise_line(octaves, y):
11    py5.noise_detail(octaves)
12    # use the noise method in a loop for clarity
13    for i in range(py5.width):
14        py5.point(i, y + 25 * py5.noise(i / 20))
15
16    # use the noise method with numpy arrays for efficiency
17    # xvals = np.arange(0, py5.width)
18    # yvals = y + 25 * py5.noise(xvals / 20)
19    # py5.points(np.stack([xvals, yvals]).T)
example picture for noise_detail()
1import numpy as np
2
3
4def setup():
5    py5.noise_seed(42)
6    py5.noise_detail(4, 0.5)
7    x, y = np.meshgrid(np.linspace(0, 5, py5.width), np.linspace(0, 5, py5.height))
8    new_pixels = py5.remap(py5.noise(x, y), 0, 1, 0, 255).astype(np.uint8)
9    py5.set_np_pixels(new_pixels, bands='L')

Description#

Adjusts the character and level of detail of Processing’s noise algorithm, produced by the noise() function. Similar to harmonics in physics, Processing noise is computed over several octaves. Lower octaves contribute more to the output signal and as such define the overall intensity of the noise, whereas higher octaves create finer-grained details in the noise sequence.

By default, noise is computed over 4 octaves with each octave contributing exactly half than its predecessor, starting at 50% strength for the first octave. This falloff amount can be changed by adding an additional function parameter. For example, a falloff factor of 0.75 means each octave will now have 75% impact (25% less) of the previous lower octave. While any number between 0.0 and 1.0 is valid, note that values greater than 0.5 may result in noise() returning values greater than 1.0 or less than 0.0.

By changing these parameters, the signal created by the noise() function can be adapted to fit very specific needs and characteristics.

Underlying Processing method: noiseDetail

Syntax#

noise_detail(lod: int, /) -> None
noise_detail(lod: int, falloff: float, /) -> None

Parameters#

  • falloff: float - falloff factor for each octave

  • lod: int - number of octaves to be used by the noise

Updated on November 12, 2021 11:30:58am UTC