Using Randomness for Generative Art
index.html
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.
Thanks for your feedback!
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Can you give an example of using random() in P5.js?
How do I use randomSeed() to make my sketch repeatable?
What are some creative ways to use randomness in generative art?
Awesome!
Completion rate improved to 6.67
Using Randomness for Generative Art
Swipe to show menu
index.html
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.
Thanks for your feedback!