/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://bard117s14.sketchpad.cc/sp/pad/view/ro.3acasFDytg1/rev.327
*
* authors:
* Anna Wheeler
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
/* Anna Wheeler
4.8.2014
Interactive Systems
COMMENT: Although I was able to execute the minutes and seconds passing, I was at first unable to debug the hours passing, so the purple hour marker was a bit of a maverick/lone ranger about where it was located. It seemed to be working, except the placement was off to an hour ahead, even though the time displayed was not. Then I realized it was because I had the range in my map set from 0 to 60, as opposed to the range of hours, which is 0 to 12. Solved! */
void setup(){
size(400, 400);
smooth();
textSize(24);
fill(196);
stroke(196);
frameRate(24);
}
float s = 80;
float m = 150;
float h = 115;
void secondPass() {
float g= map(second(), 0, 60, 0, TWO_PI) - HALF_PI;
float x = 200 + s*cos(g);
float y = 200 + s*sin(g);
fill(108, 154, 160);
ellipse(x, y, 10, 10);
}
void minutePass(){
float f = map(minute(), 0, 60, 0, TWO_PI) - HALF_PI;
float x = 200 + m*cos(f);
float y = 200 + m*sin(f);
fill(247, 72, 72);
ellipse(x, y, 15, 15);
}
void hourPass(){
float r= map(hour(), 0, 12, 0, TWO_PI) - HALF_PI;
float x = 200 + h*cos(r);
float y = 200 + h*sin(r);
fill(150, 118, 185);
ellipse(x, y, 25, 25);
}
void draw(){
background(24);
fill (255);
float s_angle = 0;
while (s_angle < 360){
float x = 200 + s*cos(radians(s_angle));
float y = 200 + s*sin(radians(s_angle));
ellipse(x, y, 5, 5);
s_angle = s_angle + 360/60.0;
}
float m_angle = 0;
while (m_angle < 360){
float x = 200 + m*cos(radians(m_angle));
float y = 200 + m*sin(radians(m_angle));
ellipse(x, y, 10, 10);
m_angle = m_angle + 360/60.0;
}
float h_angle = 0;
while (h_angle < 360){
float x = 200 + h*cos(radians(h_angle));
float y = 200 + h*sin(radians(h_angle));
ellipse(x, y, 20, 20);
h_angle = h_angle + 360/12.0;
}
secondPass();
minutePass();
hourPass();
fill(255);
textMode(CENTER);
textSize(20);
text(hour(), (width/2 -40), height/2);
text(minute(), (width/2 - 10), height/2);
text(second(), (width/2 + 20), height/2);
}