random once not every frame
in
Programming Questions
•
7 months ago
hi, now while circles touch, background is randomly changed with every frame
but instead i want it to choose just one random colour every time circles touch
how?
but instead i want it to choose just one random colour every time circles touch
how?
- float diam = 100;
void setup() {
size(500, 400);
background(0);
noFill();
}
void draw() {
background(0);
float x = width/2;
float y = height/2;
float d = dist(x, y, mouseX, mouseY);
if(d > diam) {
background(255);
} else {
background(random(255));
}
stroke(255, 255, 0);
ellipse(x, y, diam, diam);
stroke(0, 255, 0);
ellipse(mouseX, mouseY, diam, diam);
}
1