xxxxxxxxxx
66
let y = 200;
function setup() {
createCanvas(740, 400);
}
function draw() {
background(255,10);
textAlign(CENTER);
fill(0);
// noStroke();
let time = hour();
let offset = width/26;
for(let i = 1; i<=12; i++){
fill(0);
text("+"+i,width/2+(offset*i),height-20);
let t = time + i
text(t,width/2+(offset*i),20);
if(t < 6 || t > 18){
fill(0);
}else{
fill(255);
}
let pos = map(t,1,12,50,height-50);
if(t > 12){
pos = map(t,13,24,50,height-50);
}
ellipse(width/2+(offset*i),pos,10);
}
for(let i = 12; i>=1; i--){
let num = map(i,12,1,1,12);
fill(0);
text("-"+num,offset*i,height-20);
let t = time + -num;
if(t < 1){
t = map(t,0,-24,24,0);
}
text(t,offset*i,20);
if(t < 6 || t > 18){
fill(0);
}else{
fill(255);
}
let pos = map(t,1,12,50,height-50);
if(t > 12){
pos = map(t,13,24,50,height-50);
}
ellipse(offset*i,pos,10);
}
text("EST",width/2,height-20);
text(time,width/2,20);
if(time < 6 || time > 18){
fill(0);
}else{
fill(255);
}
let pos = map(time,1,12,50,height-50);
if(time > 12){
pos = map(t,13,24,50,height-50);
}
ellipse(width/2,pos,10);
}