os_noise_seed()#

Sets the seed value for os_noise().

Examples#

1def setup():
2    py5.os_noise_seed(42)
3    py5.stroke(0, 10)
4
5
6def draw():
7    n = py5.remap(py5.os_noise(0.2, py5.frame_count / 100), -1, 1, 0, py5.width)
8    py5.line(n, 0, n, py5.height)
 1def setup():
 2    global xpos, ypos
 3    py5.rect_mode(py5.CENTER)
 4    py5.os_noise_seed(42)
 5    xpos = py5.width / 2
 6    ypos = py5.height / 2
 7
 8
 9def draw():
10    global xpos, ypos
11    py5.background(128)
12    xpos = (xpos + py5.os_noise(xpos, py5.frame_count / 250)) % py5.width
13    ypos = (ypos + py5.os_noise(ypos, py5.frame_count / 250)) % py5.height
14    py5.square(xpos, ypos, 25)

Description#

Sets the seed value for os_noise(). By default, os_noise() produces different results each time the program is run. Set the seed parameter to a constant to return the same pseudo-random numbers each time the Sketch is run.

Syntax#

os_noise_seed(seed: int, /) -> None

Parameters#

  • seed: int - seed value

Updated on March 22, 2022 21:53:01pm UTC