# Project-04-Clock

In this assignment I tried to integrate a transitioning gradient with my moving clock. It was hard to find a range of color that transitioned relatively smooth.

``````/* Emma Brennan
15205 Section D
etbrenna@andrew.cmu.edu
Project 04-B*/

//coordinates
var snd;  //seconds
var mn;   //minutes
var hr;   //hour
var sX;   //sec
var sY;
var mX;   //min
var mY;
var hX;   //hour
var hY;

//color range
var fR = 0;
var fG = 102;
var fB = 102;

function setup() {
createCanvas(400,400);
background(255);
}

function draw() {

snd = second();
mn = minute();
hr = hour();

//analog time

//second hand
sX = 150 + cos(radians(-90+snd*6))* 90;
sY = 150 + sin(radians(-90+snd*6))* 90;

push();
translate(50,50);
noStroke();
fill(fR*(snd/20), 0, fB*snd/20);
rect(sX/2,sY/2,sX,sY);
pop();

//minute hand
mX = 200 + cos(radians(-90+mn*6))* 90;
mY = 200 + sin(radians(-90+mn*6))* 90;

stroke(200);
strokeWeight(2);
line(200,200,mX,mY);

//hour hand
hX = 200 + cos(radians(-90+hr*12))* 40;
hY = 200 + sin(radians(-90+hr*12))* 40;

stroke(200);
strokeWeight(7);
line(200,200,hX,hY);
}

``````