10. November 2010
Ladies and Gents, may I present you my watch:int stunden; int minuten; int sekunden; boolean h = false; boolean m = false; boolean s = false; void setup() { size(790, 360); PFont font; font = loadFont("DINOT-Regular-40.vlw"); textFont(font, 48); smooth(); } void draw() { background(51); // berechnen der stellen der zeit stunden = hour(); minuten = minute(); sekunden = second(); //variablen / alles was grad ist ergibt 0 int y_offset = sekunden%2; int x_offset = (sekunden-1)/2; // darstellung/zeichnen der werte bzw. zeit // darstellung sekunden int local_sec = 1; pushMatrix(); translate(20, 160); for (int x = 0; x < 30; x ++){ pushMatrix(); for (int y = 0; y < 2; y++){ if(sekunden == local_sec) rect(0, 0, 20, 20); else rect(0, 0, 5, 5); translate (0, 25); local_sec ++; } popMatrix(); translate(25, 0); } popMatrix(); // darstellung/zeichnen der werte bzw. zeit // darstellung minuten int local_min = 1; pushMatrix(); translate(20, 220); for (int x = 0; x < 30; x ++){ pushMatrix(); for (int y = 0; y < 2; y++){ if(minuten == local_min) rect(0, 0, 20, 20); else rect(0, 0, 5, 5); translate (0, 25); local_min ++; } popMatrix(); translate(25, 0); } popMatrix(); // darstellung/zeichnen der werte bzw. zeit // darstellung stunden int local_hour = 1; pushMatrix(); translate(20, 280); for (int x = 0; x < 12; x ++){ pushMatrix(); for (int y = 0; y < 2; y++){ if(stunden == local_hour) rect(0, 0, 20, 20); else rect(0, 0, 5, 5); translate (0, 25); local_hour ++; } popMatrix(); translate(25, 0); } popMatrix(); /* pushMatrix(); translate(20, 260); for (int i = 0; i < stunden*0.5; i = i+1) { rect(0, 0, 40, 40); translate(45, 0); // zweite zeile (oben) pushMatrix(); translate(-45, -45); for (int c = 0; c < stunden*0.5; c = c+1) { rect(0, 0, 40, 40); } popMatrix(); } popMatrix(); // darstellung minuten pushMatrix(); translate(20, 185); for (int i = 0; i < minuten*0.5; i = i+1) { rect(0, 0, 20, 20); translate(25, 0); // zweite zeile (oben) pushMatrix(); translate(-25, -25); for (int c = 0; c < minuten*0.5; c = c+1) { rect(0, 0, 20, 20); } popMatrix(); } popMatrix(); // darstellung uhr in zahlen //String clockStr = str(hour()) + ":" + str(minute()) + ":" + str(second()); //text(clockStr,20,70); } */ //darstellung uhr in zahlen, mit zahlen 1-9 auffüllen mit 0 if(hour() < 10){ h = true; }else{ h = false; } if(minute() < 10){ m = true; }else{ m = false; } if(second() < 10){ s = true; }else{ s = false; } String clockStr = ""; if(h == true){ clockStr = clockStr + "0"; } clockStr = clockStr + str(hour()) + ":"; if(m == true){ clockStr = clockStr + "0"; } clockStr = clockStr + str(minute()) + ":"; if(s == true){ clockStr = clockStr + "0"; } clockStr = clockStr + str(second()); text(clockStr,20,70); }