Hi there! I have a loop with 5 quads on random positions and I want to assign a specific color to every quad. How could I control that? Thanks!
void setup() {
size(1000, 1000);
background(255);
for(int j=0; j<5;j++){
if (j>0.2) {
fill(0,0,128,130);
}
else if (j>0.2){
fill(64,224,208,130);
}
else if (j>0.2){
fill(255,20,147, 130);
}
else if (j>0.2){
fill(128,0,128,130);
}
else{
fill(255,255,224,130);
}
noStroke();
drawQuad(random(width), random(height),600);
}
}
void drawQuad(float cx, float cy, float av_r) {
PVector[] pts = new PVector[4];
for (int i = 0; i < 4; i++) {
float angle = random(i * HALF_PI, (i + 1) * HALF_PI);
float r = random(0.5 * av_r, 1.5 * av_r);
float x = cx + r * cos(angle);
float y = cy + r * sin(angle);
pts[i] = new PVector(x, y);
}
quad(pts[0].x, pts[0].y, pts[1].x, pts[1].y, pts[2].x, pts[2].y,pts[3].x, pts[3].y);
}