Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Random numbers are often used in programming, everywhere from encrypting data to generative design. Processing offers simple function to get a random number:

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


Code Block
void setup()
{
  size(300,300);
  background(0);
  noLoop();
}
 
void draw()
{
  stroke(random(100,200));
  fill(random(50,100),random(50,100),random(150,255));
  strokeWeight(random(1,5));
  ellipse(random(0,width),random(0,height),random(10,100),random(10,100));
}
 
void mousePressed()
{
  redraw();
}