> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://bard117f12.sketchpad.cc/sp/pad/view/ro.iVEcbwD-Y5$/rev.2
 * 
 * authors: 
 *   Joe Curry-Stodder

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



// Assignment 3: Clock
// Joe Curry-Stodder, [email protected]
// Submited 10/18/12

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

void draw() {
  // define center of clock variables
  int x = width/2;
  int y = height/2;
  
  // define second and minute hand variables
  float secondAngle = radians(6*second())-radians(90); // by defult in degrees
  float minuteAngle =  radians(6*minute())-radians(90);
  
  // make time non-military time
  int hourTime;
  if(hour() < 12) {
    hourTime = hour();
  } else {
    hourTime = hour()-12;
  }
  
  // define hour hand variable
  float hourAngle = radians(30*hourTime)-radians(90); // EDIT THIS FOR CORRECTNESS
  
  // draw background and clock
  background(225, 0, 0);
  fill(255);
  ellipse(x, y, 500, 500);
  fill(0);
  
  // draw clock numbers
  textSize(50);
  text("12", width/2-31, 100);
  text("6", width/2-16, 535);
  text("9", 66, height/2+19);
  text("3", 500, height/2+19);
  
  // draw month/day boxes
  strokeWeight(1);
  fill(255);
  rect(475, height/2-19, 50, 40);
  rect(400, height/2-19, 75, 40);
  
  // draw day
  fill(0);
  textSize(30);
  text(day(), 480, height/2+12);
  
  //draw month, multiple if statements b/c words need positioning
  if(month() == 1) {
    text("JAN", 412.5, height/2+12);
  } else if(month() == 2){
    text("FEB", 412.5, height/2+12);
  } else if(month() == 3) {
    text("MAR", 405, height/2+12);
  } else if(month() == 4) {
    text("APR", 410, height/2+12);
  } else if(month() == 5) {
    text("MAY", 405, height/2+12);
  } else if(month() == 6) {
    text("JUN", 412.5, height/2+12);
  } else if(month() == 7) {
    text("JUL", 415, height/2+12);
  } else if(month() == 8) {
    text("AUG", 405, height/2+12);
  } else if(month() == 9) {
    text("SEP", 412.5, height/2+12);
  } else if(month() == 10) {
    text("OCT", 405, height/2+12);
  } else if(month() == 11) {
    text("NOV", 405, height/2+12);
  } else {
    text("DEC", 405, height/2+12);
  }
  
  // draw second hand
  float xSecond = width/2 + 230*cos(secondAngle);
  float ySecond = height/2 + 230*sin(secondAngle);
  strokeWeight(1);
  line(x, y, xSecond, ySecond);
  
  // draw minute hand
  float xMinute = width/2 + (208+1/3)*cos(minuteAngle);
  float yMinute = height/2 + (208+1/3)*sin(minuteAngle);
  strokeWeight(3);
  line(x, y, xMinute, yMinute);
  
  // draw hour hand
  float xHour = width/2 + (166+2/3)*cos(hourAngle);
  float yHour = height/2 + (166+2/3)*sin(hourAngle);
  strokeWeight(5);
  line(x, y, xHour, yHour);
}