void setup() {
size(300, 300);
stroke(255);
smooth();
}
void draw(){
background(#FFFFFF);
draw_clock(150, 150);
}
void draw_clock(int posX, int posY){
float s;
float m;
float h;
// Angles for sin() and cos() start at 3 o'clock;
// subtract HALF_PI to make them start at the top
s = (PI*2*second()/60)-HALF_PI;
m = (PI*2*minute()/60)-HALF_PI;
h = (PI*2*(hour()%12)/12)-HALF_PI;
//clock body
ellipse(posX, posY, 200, 200);
stroke(#000000);
//second hand
strokeWeight(1);
line(posX, posY, posX+(72*cos(s)), posY+(72*sin(s)));
//minute hand
strokeWeight(3);
line(posX, posY, posX+(60*cos(m)), posY+(60*sin(m)));
//hour hand
strokeWeight(6);
line(posX, posY, posX+(50*cos(h)), posY+(50*sin(h)));
}
No comments:
Post a Comment