int s; float r; void setup() { s = 300; r = s / 2; size(s, s); smooth(); frameRate(15); } void draw() { strokeWeight(1.5); translate(s / 2, s / 2); rotate(radians(270)); stroke(#000000); fill(#FFFFFF); ellipse(0, 0, s, s); float u = radians(360 / 12); for(int h = 0; h < 12; h++) { pushMatrix(); float x = (r * 0.9) * cos(h * u); float y = (r * 0.9) * sin(h * u); translate(x, y); rotate(radians(90)); fill(#000000); textAlign(CENTER, CENTER); text(h, 0, 0); popMatrix(); } float ts = radians(second() * (360 / 60)); stroke(#FF0000); line(0, 0, (r * 0.9) * cos(ts), (r * 0.9) * sin(ts)); float tm = radians(minute() * (360 / 60)); stroke(#00FF00); line(0, 0, (r * 0.8) * cos(tm), (r * 0.8) * sin(tm)); float th = radians(hour() * (360 / 12)); stroke(#0000FF); line(0, 0, (r * 0.7) * cos(th), (r * 0.7) * sin(th)); }
|