xxxxxxxxxx
57
let ugao = 0;
function setup() {
createCanvas(300, 300);
angleMode(DEGREES);
}
function draw() {
ugao += 1;
translate(150, 150);
rotate(-90);
let s = second();
let m = minute();
let h = hour();
// RGB
background(0);
// sati
let rH = 60;
let ugaoH = map(h, 0, 12, 0, 360);
let xH = rH * cos(ugaoH);
let yH = rH * sin(ugaoH);
stroke(255, 0, 0);
strokeWeight(30);
line(0, 0, xH, yH);
// minuti
let rM = 80;
let ugaoM = map(m, 0, 60, 0, 360);
// ugaoM = m * 6;
let xM = rM * cos(ugaoM);
let yM = rM * sin(ugaoM);
stroke(0, 255, 0);
strokeWeight(20);
line(0, 0, xM, yM);
// sekunde
let rS = 120;
let ugaoS = map(s, 0, 60, 0, 360);
let xS = rS * cos(ugaoS);
let yS = rS * sin(ugaoS);
noFill();
stroke(0, 0, 255);
strokeWeight(10);
line(0, 0, xS, yS);
}