> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://bard117f12.sketchpad.cc/sp/pad/view/ro.t8wyzjkdovS/rev.24
 * 
 * authors: 
 *   Robbie von Kampen

 * license (unless otherwise specified): 
 *   creative commons attribution-share alike 3.0 license.
 *   https://creativecommons.org/licenses/by-sa/3.0/ 
 */ 



//Robbie von Kampen
//[email protected]
//10-23-12
//I referenced this article on the Processing website: http://processing.org/learning/basics/clock.html

float second_radius;
float minute_radius;
float hour_radius;

void setup(){
  size(400, 400);
  smooth();
}

void draw(){
  background(47, 79, 47);
  fill(107, 66, 38);
  stroke(0);
  ellipse(width/2, height/2, 300, 300);
  
  int radius = 150;
  second_radius = radius * .85;
  minute_radius = radius * .75;
  hour_radius = radius * .65;
  
  //movement of the hands
  float seconds = map(second(), 0, 60, 0, 2*PI)- 1/2*PI;
  float minutes = map(minute() + norm(second(), 0, 60), 0, 60, 0, 2*PI) - 1/2*PI;
  float hours = map(hour() + norm(minute(), 0, 60), 0, 24, 0, 2*PI) -1/2*PI;
  //hands of the clock
  stroke(255);
  
  //secondhand 
  strokeWeight(1);
  stroke(255, 0, 0);
  line(width/2, height/2, width/2 + cos(seconds) * second_radius, height/2 + sin(seconds) * second_radius);
  
  //minutehand
  strokeWeight(2);
  stroke(255);
  line(width/2, height/2, width/2 + cos(minutes) * minute_radius, height/2 + sin(minutes) * minute_radius);
  
  //hourhand
  strokeWeight(4);
  line(width/2, height/2, width/2 + cos(hours) * hour_radius, height/2 + sin(hours) *hour_radius);
}