Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
Confluence
/
p5.js Random Numbers
Updated Sep 01, 2021

p5.js Random Numbers

Analytics

Loading data...

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
Luke Franzke
p5.js Variables
p5.js Variables
Luke Franzke
p5.js Introduction
p5.js Introduction
Luke Franzke
p5.js Particle System
p5.js Particle System
paulina.zybinska
P5js Bitmap or SVG Permutations
P5js Bitmap or SVG Permutations
Luke Franzke
p5.js WebGL
p5.js WebGL
paulina.zybinska
For you

Programming
Results will update as you type.
  • Tiling and Repetition
  • Reactors
  • Programming Basics: Parametric and Generative Graphic Design 2016
  • Archive
  • High Scores
  • Artificial Neural Network
  • Alternatives to the Processing IDE
  • p5.js Programming
    • p5.js Introduction
    • p5.js Variables
    • p5.js Random Numbers
      • P5js Random numbers (de)
    • p5.js SVG + Images
    • p5.js WebGL
    • p5.js Classes and Objects
    • p5.js Events and Functions
    • p5.js Loops
    • p5.js Coordinates
    • P5js Nested Loops
    • p5.js Animation Exercise 1
    • p5.js Animation Exercise 2
    • p5.js Conditionals
    • p5.js Arrays and Lists
    • p5.js Simple Collision Detection
    • p5.js Reactors
    • p5.js Tiling and Repetition
    • p5.js Vectors
    • p5.js Animation Solution with Objects
    • p5.js Easing
    • p5.js Perlin Noise
    • p5.js Particle System
    • p5.js Sound
    • p5j.s Typography
    • P5js Archive
  • Programming in Processing (java)

{"serverDuration": 47, "requestCorrelationId": "392e9594bda3415da8f40631fce03ad9"}