Created
July 31, 2018 12:13
-
-
Save mimetaur/ee9d3a3316f2241d9143310b7680aeaf to your computer and use it in GitHub Desktop.
Filling variables with random values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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