Need help making all circles flicker

i am trying to make all the circles i draw flicker in my code. i am currently able to make the latest circle that was drawn to flicker but the goal is to make all the circles on the canvas flicker.
here is my code;

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() {
if (start) {
if (xPos[numPointsX-1] > 0 || (yPos[numPointsY-1]>0)) {
fill(random(256), random(256), random(256));
circle(xPos[numPointsX-1], yPos[numPointsY-1], DIAM);


void mouseClicked() {

void insertXandY() {
int x = mouseX;
int y = mouseY;

xPos[numPointsX] = x;
yPos[numPointsY] = y;

numPointsX += 1;
numPointsY += 1;
start = true;



A quick tip: Format your code with Ctrl + T. It makes it far more readable.

This is the code you used to make the last circle change colors. It works fine, but it only applies to the last circle in the array.

So what you need, is a way to go through all circles and change their colors. I would also suggest you reset the background every frame (at the start of draw(), using background( color ) ).

So in coding, we call them loops. Their job is to run the code within them any number of times.
I would suggest you check out these two pages:

With this, it should be easy to find the solution.

1 Like