xxxxxxxxxx
57
let hRad = 70;
let mRad = 100;
let sRad = 140;
function setup() {
createCanvas(400, 400);
angleMode(DEGREES);
}
function draw() {
background(20);
translate(200, 200);
let h = hour();
let m = minute();
let s = second();
if (h > 12) h = h - 12;
let hAngle = map(h, 0, 12, 0, 360) - 90;
let mAngle = map(m, 0, 60, 0, 360) - 90;
let sAngle = map(s, 0, 60, 0, 360) - 90;
let hPoint = {
x: hRad * cos(hAngle),
y: hRad * sin(hAngle)
};
let mPoint = {
x: mRad * cos(mAngle),
y: mRad * sin(mAngle)
};
let sPoint = {
x: sRad * cos(sAngle),
y: sRad * sin(sAngle)
};
noFill();
stroke(255);
strokeWeight(12);
line(0, 0, hPoint.x, hPoint.y);
strokeWeight(8);
line(0, 0, mPoint.x, mPoint.y);
strokeWeight(3);
line(0, 0, sPoint.x, sPoint.y);
for(let i = 0; i < 360; i = i + 6) {
let p = {
x: sRad * cos(i),
y: sRad * sin(i),
}
point(p.x, p.y);
}
}