Skip to content

Instantly share code, notes, and snippets.

@exnihilodub
Created March 24, 2016 19:35
Show Gist options
  • Select an option

  • Save exnihilodub/831c5ee8db98989499a2 to your computer and use it in GitHub Desktop.

Select an option

Save exnihilodub/831c5ee8db98989499a2 to your computer and use it in GitHub Desktop.
My own take on the "timer" that's been shown in DBC class.
//author:Baran Elitez
int millisoff;
//PImage bg;
color step1 = color(0,0,0);
color step2 = color(112,219,255);
color step3 = color(255,157,0);
color step4 = color(112,219,255);
void setup() {
size(380, 90);
frameRate(60);
// bg = loadImage("background.jpg");
int s = second();
while(s == second());
millisoff = millis();
}
void draw() {
background(18,58,66);
//filter(BLUR, 8);
stroke(255);
float s = (second() + ((millis()- millisoff) % 1000) / 1000.0) / 60.0, m = (minute() + s) / 60.0, h = (hour() + m) / 24.0;
float mapsec = map(s, 0, 1, 0, 350);
float mapmin = map(m, 0, 1, 0, 350);
float maphour = map(h, 0, 1, 0, 350);
//println(mapsec);
//println(mapmin);
// println(h);
fill(255);
rect(10, 10, mapsec, 5);
rect(10, 20, mapmin, 5);
rect(10, 30, maphour, 5);
for (float i = 0; i < 24+1; ++i) {
float divider = 14.583;
line(i*divider+10, 50, i*divider+10, 60);
}
for (float i = 0; i < 60+1; ++i) {
float divider = 5.83;
line(i*divider+10, 60, i*divider+10, 55);
}
for (float i = 0; i < 150+1; ++i) {
float divider = 2.33;
if (i<25) {
float imap = map(i, 0, 25, 0, 1);
color steppedcolor = color(0,0,0);
stroke(steppedcolor);
}
else if (i<60) {
float imap = map(i, 25, 60, 0, 1);
color steppedcolor = lerpColor(step1, step2, imap);
stroke(steppedcolor);
}
else if (i<120) {
float imap = map(i, 60, 120, 0, 1);
color steppedcolor = lerpColor(step2, step3, imap);
stroke(steppedcolor);
}
else if (i<130) {
float imap = map(i, 120, 130, 0, 1);
color steppedcolor = lerpColor(step3, step1, imap);
stroke(steppedcolor);
}
else if (i<150) {
float imap = map(i, 130, 150, 0, 1);
color steppedcolor = lerpColor(step1, step1, imap);
stroke(steppedcolor);
}
line(i*divider+10, 70, i*divider+10, 60);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment