Project-06-Abstract-Clock

Clock

sketch
//Brody Ploeger
//Section C
//jploeger@andrew.cmu.edu
//Assignment-06



function setup() {
    createCanvas(450, 450);
    background(220);
    //text("p5.js vers 0.9.0 test.", 10, 15);
}

function draw() {
var s = second()
var m = minute()
var h = hour()
background(0)

//hours
for(var n = 0; n<h*height/24; n+=height/24){
    noStroke();
    fill('orange');
    rect(0,0,width,n+20);
}

//hours
for(var n = 0; n<h*height/24; n+=height/24){
    noStroke();
    fill('red');
    circle(width-20,0+n+10,20);
}

//minute counter
for(var j = 0; j<m*7.5; j+=7.5){
    strokeWeight(2)
    stroke(255)
    line(0+j,0,0+j,height)
}

//move origin for second counter
push();
translate(width/2,height/2)
//secondcounter
for(var i = 0; i<s; i++){
    rotate(radians(6));
    secondcounter(0,0)
}
secondcounter(0,0)
pop();
}

//seconds function
function secondcounter(x,y){
stroke('green');
strokeWeight(10);
noFill();
arc(x,y,width/2,width/2,0,radians(6))
}

Leave a Reply