Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Using Randomness for Generative Art | Animation and Time-Based Art
Generative Art with JavaScript and P5.js

bookUsing Randomness for Generative Art

index.html

index.html

copy

Randomness is a key ingredient in generative art, allowing you to create visuals that are unpredictable and unique each time your sketch runs. In P5.js, randomness can be introduced using the random() function, which generates floating-point numbers within a specified range. This can be used to control positions, sizes, colors, and many other parameters, resulting in compositions that feel organic and surprising.

The opposite of randomness is determinism, where outcomes are fully predictable given the same starting conditions. In generative art, deterministic processes will always produce the same result, while random processes introduce variety and chance. However, sometimes you may want your generative piece to be repeatable for sharing or debugging. P5.js provides the randomSeed() function for this purpose. By setting a specific seed value with randomSeed(), you ensure that the sequence of random numbers—and thus the artwork—remains identical every time you run the sketch with that seed. This gives you control over when your art is unpredictable and when it is reproducible.

question mark

Which function in P5.js generates a random floating-point number within a specified range?

Select the correct answer

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 2

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

bookUsing Randomness for Generative Art

Deslize para mostrar o menu

index.html

index.html

copy

Randomness is a key ingredient in generative art, allowing you to create visuals that are unpredictable and unique each time your sketch runs. In P5.js, randomness can be introduced using the random() function, which generates floating-point numbers within a specified range. This can be used to control positions, sizes, colors, and many other parameters, resulting in compositions that feel organic and surprising.

The opposite of randomness is determinism, where outcomes are fully predictable given the same starting conditions. In generative art, deterministic processes will always produce the same result, while random processes introduce variety and chance. However, sometimes you may want your generative piece to be repeatable for sharing or debugging. P5.js provides the randomSeed() function for this purpose. By setting a specific seed value with randomSeed(), you ensure that the sequence of random numbers—and thus the artwork—remains identical every time you run the sketch with that seed. This gives you control over when your art is unpredictable and when it is reproducible.

question mark

Which function in P5.js generates a random floating-point number within a specified range?

Select the correct answer

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 2
some-alt