sketch
//Audrey Zheng
//Section A
//audreyz@andrew.cmu.edu
//Assignment-06-C
function setup() {
createCanvas(300, 300);
}
function draw() {
background(220);
var h = hour();
var m = minute();
var s = second();
text(h + ":" + m + ":" + s, 125, 20);
ellipseMode(CENTER);
ellipse(width/2,height/2,200,200)
translate(width/2,height/2);
rotate(3 * PI /2);
for (var i = 0; i < 60; i++) {
push();
rotate(TWO_PI * i /60);
stroke(170);
if (i == 0) {
stroke(255,0,0);
line(80,0,100,0);
}
else if (i %5 == 0) {
line(80,0,100,0);
}
else {
line(90,0,100,0);
}
pop();
}
//second
var x = 100 *cos(TWO_PI * s /60) ;
var y = 100 *sin(TWO_PI * s /60) ;
line(0,0,x,y);
//hour
strokeWeight(5);
var x = 50 *cos(TWO_PI * h /12) ;
var y = 50 *sin(TWO_PI * h /12) ;
line(0,0,x ,y);
//minute
strokeWeight(3);
var x = 80 *cos(TWO_PI * m /60) ;
var y = 80 *sin(TWO_PI * m /60) ;
line(0,0,x ,y );
}