28. Oktober 2011
A 3D Clock, based on the OpenGL library./* TOWERCLOCK by Joachim Hummel 28.10.2011 */ import processing.opengl.*; float rotation = 1; PFont font; void setup() { size (500,500,OPENGL); camera(0, -40, 150.0, 0, -50, 0.0, 0.0, 1.0, 0.0); font = loadFont("Bauhaus.vlw"); textFont(font,12); } void draw() { rotation=rotation+0.3; background(255); lights(); smooth(); fill(255,255,0); noStroke(); rotateY(radians((float)rotation)); println(rotation); fill(0); pushMatrix(); rotateX(radians(90)); ellipse(0,0,200,200); popMatrix(); //Seconds fill(0,159,227); pushMatrix(); translate (0,(float)-second()/2-minute()-hour()-2,0); box(10,second()+1, 10); //TEXT if (rotation >=90 & rotation= 360) rotation = 0; text(second(),0,0); popMatrix(); //Minutes fill(230,0,126); pushMatrix(); translate (0,(float)-minute()/2-hour()-1,0); box(20,minute()+1, 20); //TEXT if (rotation >=90 & rotation= 360) rotation = 0; text(minute(),20,0); //Hours fill(255,237,0); popMatrix(); pushMatrix(); translate (0,(float)-hour()/2,0); box(30,hour()+1, 30); //TEXT if (rotation >=90 & rotation= 360) rotation = 0; text(hour(),20,0); popMatrix(); }