void setup() {
size(200, 200);
colorMode(HSB, 360, 100, 100, 100);
background(0, 0, 0);
smooth();
frameRate(15);
}
void draw() {
//①背景を黒色に塗りつぶし、座標を画面の中央へ移動する。
background(0, 0, 0);
translate(width / 2, height / 2);
//②時計の白い裏板を描く。
noStroke();
fill(0, 0, 100);
ellipse(0, 0, 170, 170);
//③時刻を表す黒丸をそれぞれ描く。
fill(0, 0, 0);
for(int i = 0; i < 12; i++) {
pushMatrix();
rotate(radians(i * 30));
ellipse(0, -75, 10, 10);
popMatrix();
}
//④時計の針を3本描く。
int[][] hand = {{hour() * 30 + int(minute() / 2), 5, -55}, {minute() * 6, 3, -75}, {second() * 6, 1, -75}};
stroke(0, 0, 0);
fill(0, 0, 100);
for(int i = 0; i < 3; i++) {
pushMatrix();
rotate(radians(hand[i][0]));
strokeWeight(hand[i][1]);
line(0, 0, 0, hand[i][2]);
popMatrix();
}
//⑤時計の針の留めピンを描く。
fill(0, 0, 0);
ellipse(0, 0, 7, 7);
}