Alex Clock
For this prompt, I decided to crake an hour glass looking structure that counts the seconds in red, the minutes in yellow and the hours (0-12) in blue. I used smooth progressive rectangle code in the example and multiplied it and flipped it vertically in my version. For some reason I lost the function of the rectangles resting when I transferred it into my hourglass structure. I originally wanted to crate a particle falling hourglass that gads small particles of sand fall through a hole and once the sand reached a certain number would combine and turn into a larger different color sand particle for the minute and then when 60 min sand particles combined, they would turn into a larger particle for the hour.
int prevSec;
int millisRolloverTime;
//--------------------------
void setup() {
size(400,400);
background(80);
millisRolloverTime = 0;
}
//--------------------------
void draw() {
strokeWeight(25);
stroke(100,70,20);
line(100,50, 300,50);
line(100,350, 300,350);
strokeWeight(3);
line(120,50,120,350);
line(280,50,280,350);
int H = hour();
int M = minute();
int S = second();
if (prevSec != S) {
millisRolloverTime = millis();
}
prevSec = S;
int mils = millis() - millisRolloverTime
float secondsWithFraction = S + mils/1000.0;
float minuetesWithFraction = M;
float hourWithFraction = H;
float rectHeightSec = map(secondsWithFraction, 0,60, 0,277);
float rectHeightMin = map(minuetesWithFraction, 0,60, 0,277);
float rectHeightHr = map(hourWithFraction, 0,12, 0,100);
noStroke();
fill(150,0,0);
rect(140,62, 20, rectHeightSec);
fill(150,120,0);
rect(170,62, 35, rectHeightMin);
fill(0,0,150);
rect(220,62, 50, rectHeightHr);
}