Project 06: abstract clock



function setup() {
    wd = 600
    ht = 600
    createCanvas(wd, ht);
    background(60,80,140);
}

function draw() {
    background(60,80,140)
    s = second();
    m = minute();
    h = hour();
   
    
    noStroke();
    
    xPos = 10*s
    yPos = 10*s
    
    
    //the minute bar
    fill(238,229,169)
    rect(0, 29, wd, 79);
    rect(0, ht-109, wd, 79);
    fill(105,160,225)
    rect(0, 49, wd*(m/60), 60)
    rect(0, ht-100, wd*(m/60), 60)
        
    //Hour Circle
    fill(255);
    circle(wd/2, ht/2, 199)
    fill(255,81,13)
    arc(wd/2, ht/2, 199, 199, -PI/2, -PI/2+h*(2*PI/12));
    
    //Seconds cirlcles
    fill(230,120,12)
    
    if (s <= 30) {
        circle(xPos, ht/2, 60);
    } else {
        circle(wd/2, yPos, 60);
    }
    
    if (s <= 30) {
        circle(wd-xPos, ht/2, 60);
    } else {
        circle(wd/2, ht-yPos, 60);
    }
        
}

Leave a Reply