Analog Clock

21 Nov

The world really doesn’t need another analog clock program, but I thought I’d make one, to illustrate why pushMatrix and popMatrix are cool. Here I’m using them to rotate each hand into the correct position.

Want some numbers instead of the minimal notches shown here? Replace the loop that draws the hour markers with this (it looks good with a 48 point font).

    // draw hour markers
    textAlign(CENTER, CENTER);
    for (int i = 0; i < 12; ++i) {
        text(i==0? 12 : i, 0, 0);

Tags: , , , ,

2 Responses to “Analog Clock”

  1. felix March 13, 2014 at 9:45 pm #


    how would you make it so that you can draw 60 tickmarks on the clock?

    • jbum March 14, 2014 at 1:33 pm #

      It’s basically a modification of the code that draws the hour markers. The first step is understanding that code thoroughly. Look at it closely.
      The two numbers that need to be changed are 12 (which represents the number of marks) and 30 (which represents the angle from mark to mark).

      360 / 12 = 30
      360 / 60 = ??

Leave a Reply

Your email address will not be published. Required fields are marked *