Skip to content

Commit

Permalink
Updated clock CodingTrain#5 with exact measurements
Browse files Browse the repository at this point in the history
Got the exact size measurements, relative to the screen size for scaling, from the original version. I also noticed the minutes' and seconds' angles are relative to that of the hours, but reversed.
  • Loading branch information
Merijn-DH authored Sep 25, 2017
1 parent eae7e2f commit 30625c3
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions clocks/clock-05.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// This is the overlapping rotated numbers clock
// font sizes can be tweaked at the three occurences of: size = ..;

var clock05 = function(sketch) {
sketch.setup = function() {
Expand All @@ -14,12 +13,13 @@ var clock05 = function(sketch) {
sketch.background(150);
sketch.translate(sketch.width/2,sketch.height/2);

// -- draw hours --
let size = 10;
// --- draw hours ---
let size = sketch.height/14;
sketch.fill(0);

// rotate the hours, not in push()-pop() because minutes and seconds are relative to the hours
sketch.rotate(2*sketch.PI*h/12);
sketch.push();
sketch.rotate(2*sketch.PI*h/12);
if (h >= 10) {
sketch.translate(-3*size, 0);
drawCharacter(sketch.floor(h/10), size);
Expand All @@ -30,8 +30,11 @@ var clock05 = function(sketch) {
}
sketch.pop();

// -- draw minutes --
size = 9.5;
// the minutes and seconds are an additional 180 degrees rotated (look at original)
sketch.rotate(sketch.PI);

// --- draw minutes ---
size = size * 0.75;
sketch.fill(255);

sketch.push();
Expand All @@ -46,8 +49,8 @@ var clock05 = function(sketch) {
}
sketch.pop();

// -- draw minutes --
size = 6;
// --- draw minutes ---
size = size / 0.75 * 0.5;
sketch.fill(231,0,0);

sketch.push();
Expand Down

0 comments on commit 30625c3

Please sign in to comment.