xxxxxxxxxx
function setup() {
createCanvas(windowWidth, windowHeight);
rectMode(CENTER);
}
function draw() {
let x = windowWidth/2
let y = windowHeight/2
background('white');
//clock:
let h = hour();
let m = minute();
let s = second();
let h0 = "";
let m0 ="";
let s0 ="";
let angle_s;
let angle_m;
let angle_h;
if (h<10){
h0 = "0";
}
if (s<10){
s0 = "0";
}
if (m<10){
m0 = "0";
}
textSize(25)
fill('black');
text(h0 + h+":", windowWidth/2 - 600, windowHeight/2);
text(m0 + m+":", windowWidth/2 -550, windowHeight/2);
text( s0 + s, windowWidth/2 -500 , windowHeight/2);
// angle management:
angle_s = (s*360)/60
angle_m = (m*360)/60
angle_h = (h*360)/12
push();
translate(x,y);
rotate(angle_h);
fill('black');
rect(0,0,500,500);
pop();
push();
translate(x,y);
rotate(angle_m);
fill('grey');
rect(0,0,300,300);
pop();
push();
fill('white');
translate(x,y);
rotate(angle_s);
rect(0,0,150,150);
pop();
}