How do i make all circles flicker
You need to draw all the circles in a loop with a different color in each frame:
void draw() {
background(255);
fill(random(256), random(256), random(256));
for (int i = 0; i< numPointsX; ++i) {
circle(xPos[i], yPos[i], DIAM);
}
}
Complete example:
float colour = random(256);
final int DIAM = 20;
final int MAX_NUM = 1000;
int numPointsX = 0;
int numPointsY = 0;
int [] xPos = new int[MAX_NUM];
int [] yPos = new int [MAX_NUM];
boolean start = false;
void setup() {
size (500, 500);
}
void draw() {
background(255);
fill(random(256), random(256), random(256));
for (int i = 0; i< numPointsX; ++i) {
circle(xPos[i], yPos[i], DIAM);
}
}
void mouseClicked() {
insertXandY();
}
void insertXandY() {
int x = mouseX;
int y = mouseY;
xPos[numPointsX] = x;
yPos[numPointsY] = y;
numPointsX += 1;
numPointsY += 1;
start = true;
}