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) { pushMatrix(); rotate(radians(i*30)); pushMatrix(); translate(0,-width*.39); rotate(-radians(i*30)); text(i==0? 12 : i, 0, 0); popMatrix(); popMatrix(); }
Tags: animation, circles, clock, intermediate, time
Hi!
how would you make it so that you can draw 60 tickmarks on the clock?
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 = ??