Project 06- Abstract Clock

sketchDownload


//Shruti Prasanth
//Section C
//Project 6 - Abstract Clock

function setup() {
    createCanvas(480, 480);
}
   
  
function draw() {

    
    push(); 
    background(175, 298, 173); //mint green
    translate(width / 2, height / 2); //origin now center canvas
    pop(); 

    var s = second(); 
    var m = minute(); 
    var h = hour();

    let sAngle = map(s, 0, 60, 0, 360); 
    let mAngle = map(m, 0, 60, 0, 360);
    let hAngle = map(h, 0, 24, 0, 360); 

    translate(width / 2, height / 2); 
    
    //drawing the second hand ring 
    fill(255);
    noStroke(); 
    push(); 
    for (var i = 0; i < s; i ++){
        rotate(radians(sAngle)); //creates a pattern based on current second 
        ellipse(0, -200, 20, 20); 
    }
    pop(); 

    //drawing the minute hand ring 
    push();
    fill(207, 187, 208); //purple
    for (var j = 0; j < m; j ++){
        rotate(radians(mAngle)); // pattern based on what minute it is 
        ellipse(0, -130, 30, 30); 
    }
    pop(); 

    //the hour hand ring
    push();
    fill(43, 97, 109);
    for (var k = 0; k < h; k ++){ 
        rotate(radians(hAngle)); // pattern based on hour 
        ellipse(0, -50, 40, 40); 

    }
    pop();

// drawing the middle clover
    circle(0,0,20);
    circle(0,15,20);
    circle(0,-15,20);
    circle(15,0,20);
    circle(-15,0,20);
     
}

Leave a Reply