带着我的视觉时钟再次回来。我需要一点指导。我正在尝试制作一个“时钟”图表,该图表倒计时(以小时为单位)直到用户输入的事件时间,例如直到他们吃晚饭,睡觉等。在我的草图中,“现在”是深灰色的线左边,我想创建一个系统,对这些输入时间进行倒计时,与实时相关。白色刻度表示一天 24 小时。我还希望渐变相对于“现在”发生变化,具体取决于外部的亮度。有人建议映射,但我什至不知道从哪里开始。这是我的草图和代码:感谢您的任何帮助!
PFont din;
PFont din2;
color blue = color(0, 80, 200);
color orange = color(255, 150, 50);
int hr = hour();
float w, h, angle;
void setup () {
size (1100, 600, P2D);
din = loadFont("DIN-Medium-30.vlw");
din2 = loadFont("DIN-Medium-15.vlw");
}
void draw() {
background(255);
gradientRect(90, 470, 850, 50, blue, orange);
fill(0, 102, 153);
textFont(din);
if (hr > 12) {
hr=hour()-12;
text("pm", 220, 55);
} else {
text ("am", 220, 55);
}
text(nf(hr, 2)+":", 86, 55);
text(nf(minute(), 2)+":", 126, 55);
text(nf(second(), 2), 166, 55);
textFont(din2);
text("SLEEP", 25, 350);
stroke(255);
textFont(din2);
text("TEST", 25, 250);
textFont(din2);
text("DINNER", 25, 150);
//GREY RECT
strokeWeight(0);
fill(209);
rect(90, 70, 850, 400);
//DINNER
strokeWeight(2);
stroke(255);
noFill();
rect(90, 130, 850, 30);
//TEST
strokeWeight(2);
stroke(255);
noFill();
rect(90, 230, 850, 30);
//SLEEP
strokeWeight(2);
stroke(255);
noFill();
rect(90, 330, 850, 30);
//NOW
stroke(150);
strokeWeight(5);
line(90, 470, 90, 75);
//24 HRS
stroke(255);
strokeWeight(2);
translate(90, 230);
// TIME
angle = millis();
w = hr=hour()-12;
h = 30;
fill(255);
rect(0, 0, w, 100);
strokeWeight(0);
}
//Gradiant
void gradientRect(int x, int y, int w, int h, color c1, color c2) {
beginShape();
fill(c1);
vertex(x, y);
vertex(x, y+h);
fill(c2);
vertex(x+w, y+h);
vertex(x+w, y);
endShape();
}
//input, output - calculations, get second();
//map();