The main problem is that seconds() has a resolution of 1 second so can't be used to do what you want. The following changes will do the trick.
Add three new variables above your setup()
- long baseTime;
- float currSecs, lastSecs;
Add the folowing lines as the last lines in setup()
- // Calculate the number of millis for the last whole minute
- // ie when second() would have returned 0
- int baseTime = millis() - second() *1000;
- // Initialise these so they work in draw()
- lastSecs = currSecs = ((millis() - baseTime)`000)/1000.0;
In setup remove the frameRate command as you will no longer need it.
The rest of the changes are in draw()
Add this line after the 2 text statements and before the commands to calculate the arcs
- // Calculate the current number of seconds as a float
- currSecs = ((millis() - baseTime)`000)/1000.0;
Also in draw change the secondAngle calculation to
- float secondAngle = map(currSecs, 0, 60, 0, TWO_PI) - HALF_PI;
Finally at the end of draw where you test for seconds() == 0 change this to
- if(currSecs < lastSecs) {
- stroke(255);
- ellipse(arc_x, arc_y, secondDiameter, secondDiameter);
- }
- lastSecs = currSecs;
This will change the arc when the second roll over from 59.999 > 0.0 otherwise the second hand gets stuck for 1 second between 0>1 second. Finally remember the number of seconds in lastSecs so this test will work next time.
I tried it out and it works smoothly.
Nice sketch by the way.