float seconds = 0; // this ensures floating-point divisions void setup() { size(400,400); frameRate(60); textAlign(CENTER,CENTER); textSize(24); } void drawNumbers() { pushStyle(); fill(0); // black lettering for (int h=1; h <= 12; h++) { pushMatrix(); float theta = h*TWO_PI/12; rotate(theta); // orient the y-axis from the current center translate(0,-130); // now move origin along the y-axis rotate(-theta); // and now "unrotate" so that text is properly aligned text(nf(h),0,0); popMatrix(); } popStyle(); } void draw() { seconds++; background(204); ellipse(200,200,300,300); // white clock face translate(200,200); drawNumbers(); // second hand pushMatrix(); rotate(TWO_PI*seconds/60); // 60 seconds around the clock line(0,0,0,-130); popMatrix(); // minute hand pushMatrix(); rotate(TWO_PI*seconds/3600); // 60 minutes = 3600 seconds line(0,0,0,-100); popMatrix(); // hour hand pushMatrix(); rotate(TWO_PI*seconds/43200); // 12 hours = 43200 seconds line(0,0,0,-80); popMatrix(); }