回到我的視頻時鐘。我需要一些指導。我正在嘗試製作一個「時鐘」圖表,用於記錄時間(以小時爲單位),直到用戶輸入的事件發生時爲止,例如直到他們吃晚飯,睡覺等等。在我的素描中,「現在」是深灰色線條左邊,我想建立一個系統,倒計時這些輸入時間,實時。白色蜱象徵着一天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();
你有沒有想過這個想法? –