/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://bard117s14.sketchpad.cc/sp/pad/view/ro.Gh2i3LgutFB/rev.3427
*
* authors:
* Zoe Azulay
* keith mackie
* Daniel
* Stefanie Walker
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
/* Stefanie Walker
* Clock Buddy
* April 4, 2014
* [email protected]
* Not only does this clock tell time, but its eyes follow you (and can be located in three different locations on the screen! Left, center, and right). */
void setup() {
size(600,600);
smooth();
background(95);
frameRate(1);
}
float sr = 185;
float mr = 190;
float hr = 150;
void draw() {
clockBody();
secondTicker();
minuteTicker();
hourTicker();
}
void secondTicker() {
float s = map(second(), 0, 60, 0, TWO_PI) - HALF_PI;
float x = (width/2) + sr*cos(s);
float y = (height/2) + sr*sin(s);
stroke(79);
strokeWeight(3);
line((width/2), (height/2), x, y);
}
void minuteTicker(){
float m = map(minute() + norm(second(), 0, 60), 0, 60, 0, TWO_PI) -
HALF_PI;
float x = (width/2) + mr*cos(m);
float y = (height/2) + mr*sin(m);
stroke(200,33,0);
fill(200,33,0);
strokeWeight(6);
line((width/2), (height/2), x, y );
}
void hourTicker(){
float h = map(hour() + norm(minute(), 0, 60), 0, 24, 0, TWO_PI * 2)
- HALF_PI;
float x = (width/2) + hr*cos(h);
float y = (height/2) + hr*sin(h);
stroke(200,33,0);
strokeWeight(8);
line((width/2), (height/2), x, y );
noFill();
stroke(200,33,0);
ellipse(width/2, height/2, 10, 10);
}
void clockBody() {
//main body
fill(80, 101, 222);
stroke(4);
strokeWeight(26);
ellipse(width/2, height/2, 480,480);
noStroke();
//arms and legs
fill(4);
rectMode(CENTER);
rect(577, (height/2)-20, 90, 40);
rect(23, (height/2)-20, 90, 40);
rect((width/2)-80, 577, 40, 90);
rect((width/2)+80, 577, 40, 90);
//tick marks
fill(255, 227, 13);
rect(width/2, 98, 20, 50);
rect(502, height/2, 50, 20);
rect(width/2, 502, 20, 50);
rect(98, height/2, 50, 20);
//eyes
float e1 = (width/3)+35;
float e2 = (2*width/3)-5;
float ey = 210;
fill(255);
ellipse((width/3)+20, 210, 60,60);
ellipse((2*width/3)-20, 210, 60,60);
fill(0);
if (mouseX > 400){
ellipse(e1, ey, 20,20);
ellipse(e2, ey, 20, 20);}
if (mouseX > 200 && mouseX < 400){
ellipse(e1-15, ey, 20,20);
ellipse(e2-15, ey, 20, 20); }
if (mouseX < 200){
ellipse(e1-30, ey, 20,20);
ellipse(e2-30, ey, 20, 20); }
//mouth
stroke(74,50,45);
strokeWeight(7);
line (250, 400, 350, 400);
//eyebrows
stroke(12);
noFill();
strokeWeight(4);
arc((width/3)+20, 176, 70, 50, -PI+(2/3), -2/3);
arc((2*width/3)-20, 176, 70, 50, -PI+(2/3), -2/3);
}