Project 06

l

sketch
//Keng Pu (Paul) Li
//section A 

var minuteX = [];
var minuteY = [];
var minuteColor = [];
var sec;
var mnth;
var hr;

function setup() {
    createCanvas(300,400);
    rectMode(CENTER);
    //assigns array for minute fn

}

function draw() {
    background(40,10,10);
    sec = second()+1;

    //allows minute circles to produce jittering effect
     for(var i = 0; i<=minute(); i++){
        minuteX[i] = min(56+i*random(2.5,3),245);
        minuteY[i] = max(340-i*random(3,5),100);
        minuteColor[i] = minute()*4;
    }

    timeMonth();
    timeHours();
    timeMinutes();
    frameRate(sec); //higher the second faster the frame-> quickker jitters
}

function timeMonth(){
    mnth = month();
    noStroke();
    //changes color depending to season, fall = orange, winter =  blue, spring =  pink, summer = green, code in that order
    //also places circle on diff corner of that color depending on the season
    if(mnth>=9 & mnth<12){
        fill(255,160,70);
        circle(20,20,30);
    } else if(mnth>=12 & mnth<3){
        fill(18,130,210);
        circle(width-20,20,30);
    } else if(mnth>=3 & mnth<6){
        fill(255,100,220);
        circle(width-20,height-20,30);
    }else{
        fill(30,230,70);
        circle(20,height-20,30);
    }
    rect(width/2,height/2,200,300);
}


// draws a strike every hour and resets every 12 hr on top of the orange cube,, resets to 0 strikes each 24 hr

function timeHours(){
    hr = hour();
    var strikeW = (200/24) - 13;
    var strikeH = 30;
    fill(255,40,40);
    stroke(0.5);
    if(hr<24){
        for (var i = 0; i<hr; i++){
            rect((55+strikeW/2)-i*(strikeW-200/48),50-strikeH/2,strikeW,strikeH);
        }
    }else{
        var i = 0;
        for (var i = 0; i<hr; i++){
            rect((55+strikeW/2)-i*(strikeW-200/48),50-strikeH/2,strikeW,strikeH);
        }
    }
}

//for every minute, a ball is added into the orange box, and as time goes on the color of the balls get lighter, the spread also goes further ddepending on time

function timeMinutes(){
    noStroke();
    fill(0,0,0,0);
   for(var i = 0; i<=minute(); i++){
        circle(minuteX[i],minuteY[i],10);
        fill(minuteColor[i]);
    }
   

}

Leave a Reply