Exercise 31
by Haig. Average Reading Time: less than a minute.
Let’s start simple. The following listing creates a script that draws a handful of randomly placed circles every time the mouse is clicked.
int _num = 10;
void setup() {
size(500, 300);
background(255);
smooth();
strokeWeight(1);
fill(150, 50);
drawCircles();
}
void draw() {
}
void mouseReleased() {
drawCircles();
}
void drawCircles() {
for (int i=0; i<_num; i++) {
float x = random(width);
float y = random(height);
float radius = random(100) + 10;
noStroke();
ellipse(x, y, radius*2, radius*2);
stroke(0, 150);
ellipse(x, y, 10, 10);
}
}
No comments on ‘Exercise 31’
Leave a Reply