Skip to content

Instantly share code, notes, and snippets.

@mimetaur
Created July 31, 2018 12:13
Show Gist options
  • Save mimetaur/ee9d3a3316f2241d9143310b7680aeaf to your computer and use it in GitHub Desktop.
Save mimetaur/ee9d3a3316f2241d9143310b7680aeaf to your computer and use it in GitHub Desktop.
Filling variables with random values
// Example 4-7: Filling variables with random values
float r;
float g;
float b;
float a;
float diam;
float x;
float y;
void setup() {
size(720, 480);
background(255);
}
void draw() {
// Each time through draw(), new random
// numbers are picked for a new ellipse.
r = random(255);
g = random(255);
b = random(255);
a = random(255);
diam = random(20);
x = random(width);
y = random(height);
// Use values to draw an ellipse
noStroke();
fill(r, g, b, a);
ellipse(x, y, diam, diam);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment