🔬 These two lines decide when the pie turns orange and then red. What happens if you lower the 18 and 21 thresholds to, say, 6 and 9 (as in 6am and 9am)? What if you swap the colors so it starts red and becomes calmer later?
if (h >= 21) remainingCol = color(255, 80, 80);
else if (h >= 18) remainingCol = color(255, 160, 60);
🔬 The first arc draws a full circle, and the second arc draws only up to the elapsed angle on top of it. What happens if you swap which arc uses 'ang' and which uses 'TWO_PI' - does the meaning of dark vs light flip?
fill(remainingCol); arc(cx, cy, d, d, start, start + TWO_PI, PIE);
fill(40); arc(cx, cy, d, d, start, start + ang, PIE);
function draw() {
background(245);
let h = hour(), m = minute(), s = second();
let total = h * 3600 + m * 60 + s;
let frac = total / 86400;
let start = -HALF_PI, ang = frac * TWO_PI;
let d = min(width, height) * 0.6;
let cx = width / 2, cy = height / 2;
let remainingCol = color(235);
if (h >= 21) remainingCol = color(255, 80, 80);
else if (h >= 18) remainingCol = color(255, 160, 60);
noStroke();
fill(remainingCol); arc(cx, cy, d, d, start, start + TWO_PI, PIE);
fill(40); arc(cx, cy, d, d, start, start + ang, PIE);
fill(20);
textSize(d * 0.12);
let hh = nf(h, 2), mm = nf(m, 2), ss = nf(s, 2);
text(hh + ":" + mm + ":" + ss, cx, cy);
textSize(d * 0.06);
let hrsLeft = 24 - (h + m / 60 + s / 3600);
hrsLeft = max(0, hrsLeft);
text("Only " + hrsLeft.toFixed(1) + " hours until midnight", cx, cy + d * 0.35);
}