Random numbers are often used in programming , and can be found everywhere from encrypting data to generative design. Processing offers In p5js there's a simple function to get a random number:
random( [lower Limitlimit], [upper Limitlimit] )
Code Block | ||
---|---|---|
| ||
function setup() { sizecreateCanvas(500,500); background(255); fill(255); stroke(0); } voidfunction draw() { //fill(random(100,150), random(0,100), random(150,255)); //random color float var size = random(10, 100); // random size ellipse(random(0, width), random(0, height), size, size); //random eclipse size and position } |