28. Oktober 2011
Aufgabe zur Lektion 7 Mache eine eigene Variante der Uhr, eine grafische Darstellung der Zeit. Uhrzeit des Bildbeispiels : 15:03:05 Download/* ---------------------------------------------------------------------------- * BlockClock * ---------------------------------------------------------------------------- * Typo / Time * ---------------------------------------------------------------------------- * prog: daniel.mischler@zhdk.ch * ---------------------------------------------------------------------------- */ PShape balken; PShape rahmen; PShape uhrName; void setup() { size(1000, 1000); balken = loadShape("balkenPink.svg"); // lade die svg file rahmen = loadShape("rahmenPink.svg"); // lade die svg file uhrName = loadShape("uhrName.svg"); // lade die svg file smooth(); } void draw() { background(#C1AD79); pushMatrix(); translate(width *.5 - 289,height *.5 - 94); for(int x = 0; x <= 420; x+=210) { pushMatrix(); translate(x,0); rahmenPink(); zehner(x); ziffer(x); popMatrix(); } uhrName(); popMatrix(); } void uhrName() { pushMatrix(); scale(1.3); shape(uhrName,375,160); //zeichne svg File popMatrix(); } void rahmenPink() { int anzahl = 1; int x = 0; for(int i = 0; i < anzahl;i++) { shape(rahmen,x,0); //zeichne svg File x = x-210; } } void zehner(int wert) { int anzahl = 0; int y = 179; int spaceWert = 0; if (wert==0) { anzahl = hour()/10; } if (wert==210) { anzahl = minute()/10; } if (wert==420) { anzahl = second()/10; } for(int i = 0; i < anzahl;i++) { y = y-15; shape(balken,14,y); //zeichne svg File spaceWert = spaceWert + 1; if (spaceWert == 3) { y = y-15; spaceWert = 0; } } } void ziffer(int wert) { int anzahl = 0; int y = 179; int spaceWert = 0; if (wert==0) { anzahl = hour()%10; } if (wert==210) { anzahl = minute()%10; } if (wert==420) { anzahl = second()%10; } for(int i = 0; i < anzahl;i++) { y = y-15; shape(balken,84,y); //zeichne svg File spaceWert = spaceWert + 1; if (spaceWert == 3) { y = y-15; spaceWert = 0; } } }