Last active
October 18, 2015 23:19
-
-
Save takawo/7b1b11368e73004c3e7d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float startAngle = - PI/2; | |
float hour, minute, second; | |
void setup() { | |
size(600, 600); | |
textAlign(CENTER,CENTER); | |
textSize(25); | |
strokeCap(ROUND); | |
} | |
void draw() { | |
hour = hour(); | |
minute = minute(); | |
second = second(); | |
minute += second/60; | |
hour += minute/60; | |
background(0); | |
fill(255); | |
noStroke(); | |
//frameの描画 | |
ellipse(width/2, height/2, width*0.8, height*0.8); | |
//中心に移動 | |
translate(width/2, height/2); | |
for (int i = 0; i < 360; i+= 360/60) { | |
float x = cos(radians(i) + startAngle)*250; | |
float y = sin(radians(i) + startAngle)*250; | |
float x2 = cos(radians(i) + startAngle)*252; | |
float y2 = sin(radians(i) + startAngle)*252; | |
float x3 = cos(radians(i) + startAngle)*280; | |
float y3 = sin(radians(i) + startAngle)*280; | |
stroke(20); | |
strokeWeight(4); | |
fill(255); | |
if (i%5 == 0) { | |
ellipse(x, y, 12, 12); | |
if (i == 0) { | |
text(12, x3, y3); | |
} else { | |
text(i/(360/12), x3, y3); | |
} | |
}else{ | |
ellipse(x, y, 7, 7); | |
} | |
} | |
pushMatrix(); | |
strokeWeight(10); | |
rotate(radians(hour%12*360.0/12.0)); | |
line(0, 0, 0, -130); | |
fill(0); | |
triangle(-10, -130, 10, -130, 0, -150); | |
popMatrix(); | |
pushMatrix(); | |
strokeWeight(7); | |
rotate(radians(minute*360.0/60)); | |
line(0, 0, 0, -180); | |
triangle(-5, -180, 5, -180, 0, -195); | |
popMatrix(); | |
pushMatrix(); | |
strokeWeight(3); | |
rotate(radians(second*360.0/60)); | |
line(0, 0, 0, -220); | |
popMatrix(); | |
ellipse(0, 0, 25, 25); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment