/
p5.js Random Numbers

p5.js Random Numbers

Random numbers are often used in programming and can be found everywhere from encrypting data to generative design. In p5js there's a simple function to get a random number:

random( [lower limit], [upper limit] )  

function setup() { createCanvas(500,500); background(255); fill(255); stroke(0); } function draw() { fill(random(100,150), random(0,100), random(150,255)); //random color var size = random(10, 100); // random size ellipse(random(0, width), random(0, height), size, size); //random eclipse size and position }



Related content

p5.js Loops
p5.js Loops
Read with this
p5.js Variables
p5.js Variables
Read with this
p5.js Introduction
p5.js Introduction
Read with this
p5.js Particle System
p5.js Particle System
Read with this
P5js Bitmap or SVG Permutations
P5js Bitmap or SVG Permutations
Read with this
p5.js WebGL
p5.js WebGL
Read with this