I’m in the process currently of trying to make a program that runs a type of clock. I am using images in my program, but for the purposes of my question, I have substituted ellipses. I understand how to use a nested loop to draw 60 circles, which represent the minutes, but I can’t figure out how to make them appear as the minutes go up.
For example, if it was 11:36 pm on your computer, I would want the program 36 ellipses. It would then draw a new one to add to the minute count each time the minute changed: 11:36 pm > 36 ellipses, 11:37pm > 37 ellipses.
I want the ellipses to stay in the same layout as my 60 ellipses nested for loop, but only having as many visible as the minutes.
The solution is in two parts, first use background(…) to clear the display at the start of every frame otherwise you will not see any changes once all 60 pictures are shown. Use a counter to control the number of pictures visible like this
void setup() {
size(1000, 600);
}
void draw() {
background(230);
int m = minute();
for (int xPosition = 0; xPosition < 1000; xPosition = xPosition + 100) {
for (int yPosition = 0; yPosition < 600; yPosition = yPosition + 100) {
ellipseMode(CORNER);
ellipse(xPosition, yPosition, 100, 100);
m--;
if (m == 0) break; // breakout of inner loop
}
if (m == 0) break; // breakout of outer loop
}
}```