# Miranda Luong-Project-06-Abstract-Clock

``````/* Miranda Luong
Section E
mluong@andrew.cmu.edu
Project-06
*/

var prevSec;
var millisRolloverTime;

function setup() {
createCanvas(300, 300);
}

function draw() {
background(154,191,219);

// Fetch the current time
var H = hour();
var M = minute();
var S = second();

// Reckon the current millisecond,
// particularly if the second has rolled over.
// Note that this is more correct than using millis()%1000;

if (prevSec != S) {
millisRolloverTime = millis();
}
prevSec = S;
var mils = floor(millis() - millisRolloverTime);

// print current time next to corresponding colors
noStroke();
fill(0);
text("Hour: "   + H, 30, 22);
text("Minute: " + M, 30, 42);
text("Second: " + S, 30, 62);
text("Millis: " + mils, 30, 82);

fill(0);
ellipse(15,18,12,12);
fill(255/3);
ellipse(15,38,12,12);
fill(255*(2/3));
ellipse(15,58,12,12);
fill(255);
ellipse(15,78,12,12);

//Hours
var hStart = 0 - HALF_PI //first arc always starts at 0
//loop creates individual wedges, the number of wedges corresponding to current hour
for (var a = 0; a < H; a ++){
stroke(255);
fill(0);
//creates arc from point of 'start' to 'start' plus the 'i'th wedge
arc(50 + width / 2, 10 + height / 2, hRadius, hRadius, hStart, hStart + (TWO_PI/24), PIE);
hStart += (TWO_PI/24)
}

//Minutes
var mStart = 0 - HALF_PI
//loop creates individual wedges, the number of wedges corresponding to current minute
for (var a = 0; a < M; a ++){
fill(255/3);
stroke(255);
//creates arc from point of 'start' to 'start' plus the 'i'th wedge
arc(50 + width / 2, 10 + height / 2, mRadius, mRadius, mStart, mStart + (TWO_PI/60), PIE);
mStart += (TWO_PI/60)
//reassigns radius of next wedge to
}

var sStart = 0 - HALF_PI
//loop creates individual wedges, the number of wedges corresponding to number of values in array
for (var a = 0; a < S; a ++){
//loop generates shades of grey, value increasing in accordance to number of values in array
fill(255*(2/3));
stroke(255);
//creates arc from point of 'start' to 'start' plus the 'i'th wedge
arc(50 + width / 2, 10 + height / 2, sRadius, sRadius, sStart, sStart + (TWO_PI/60), PIE);
sStart += (TWO_PI/60)
}

var msStart = 0 - HALF_PI
//loop creates individual wedges, the number of wedges corresponding to number of values in array
for (var a = 0; a < mils; a ++){
//loop generates shades of grey, value increasing in accordance to number of values in array
fill(255);
//creates arc from point of 'start' to 'start' plus the 'i'th wedge
arc(50 + width / 2, 10 + height / 2, msRadius, msRadius, msStart, msStart + (TWO_PI/1000), PIE);