Evenly spaced circles
in
Programming Questions
•
22 days ago
Hi,
I am pretty new to processing and I am trying to create circles evenly spaced over an entire square surface that randomly change color. I've achieved everything but the evenly spaced part. We need to keep the code relatively simple as per the requirements of our assignment in class. I've tried to use what I know (like using boolean statements and state machines) but I am failing. Here's a look at my code, could you help me out?
float r;
float g;
float b;
float a;
float diam;
float x;
float y;
int endCircle;
int len;
int spacing;
void setup() {
size(200,200);
background(255);
smooth();
}
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 = 20;
x = random(10,190);
y = random(10,190);
// Use values to draw an ellipse
noStroke();
fill(r,g,b,a);
ellipse(x,y,diam,diam);
x = x + 20;
y = y + 20;
}
Thanks!
I am pretty new to processing and I am trying to create circles evenly spaced over an entire square surface that randomly change color. I've achieved everything but the evenly spaced part. We need to keep the code relatively simple as per the requirements of our assignment in class. I've tried to use what I know (like using boolean statements and state machines) but I am failing. Here's a look at my code, could you help me out?
float r;
float g;
float b;
float a;
float diam;
float x;
float y;
int endCircle;
int len;
int spacing;
void setup() {
size(200,200);
background(255);
smooth();
}
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 = 20;
x = random(10,190);
y = random(10,190);
// Use values to draw an ellipse
noStroke();
fill(r,g,b,a);
ellipse(x,y,diam,diam);
x = x + 20;
y = y + 20;
}
Thanks!
1