Jonathan Perez Project 6

sketch

//Jonathan Perez
//Section B
//jdperez@andrew.cmu.edu
//Project-6



function setup() {
    createCanvas(480, 480);
    background(255);
}

function draw() {
    var y1 =-50
    var y2 = -200
    var dy1 = random(-1, 1);
    var dy2 = random(-1, 1);
    var irisColor = 0 //lower bound on random greyscale for second hand
    var irisColor2 = 10 //upper bound on random greyscale for second hand
    var irisFill; // iris coloring
    var brightCap; // max greyscale value iris color can be

    //iris darkness caps
    if(hour() >= 0 & hour() < 7) { //almost black at night-time
        brightCap = 100
    } else if(hour() >= 7 && hour() < 8) { //light grey during sunrise
        brightCap = 200
    } else if(hour() >= 8 && hour() < 19) { //light grey to white during the day
        brightCap = 300
    } else if (hour() >= 19 && hour() < 20) { //same as sunrise
        brightCap = 200
    } else { //same as night-time
        brightCap = 100
    }

    push();
    translate(width/2, height/2);


    push();
    rotate(minute() * TWO_PI/60);
    stroke(0);
    strokeWeight(1);
    line(0, 0, 0, -height); //minute hands
    pop();

    //pupil detail
    push();
    if(hour() <= 12) {
        rotate(hour() * TWO_PI/12);
    } else {
        rotate(hour() * TWO_PI/12 + TWO_PI/24); //offsets to continue creating more vertices
    } 
    stroke(0);
    fill(0);
    rect(-30, -30, 60, 60); //stacked squares to create a star-pupil shape
    pop();


    //iris detail
    push();
    rotate(millis() * TWO_PI/60000);
    for(i = 0; i < 80; i++) {
    if(irisColor2 < brightCap) { 
        irisColor += 3.5
        irisColor2 += 3.5
    }
    irisFill = random(irisColor, irisColor2);
    strokeWeight(2);
    fill(irisFill);
    point(0, y1); //inner detail
    point(0, y2); //outer detail
    if(y1 + dy1 < -120) {
        dy1 = random(1.5); //max range is 120
    } else if(y1 + dy1 > 0) {
        dy1 = random(-1.5);
    }
    if(y2 + dy2 < -200) { //max range is 200
        dy2 = random(1.5);
    } else if(y2 + dy2 > -100) {
        dy2 = random(-1.5);
    }
    y2 += dy2;
    y1 += dy1


    }

    pop();
}

For this project, I wanted to mimic the circular shape of the traditional clock in something organic. Incidentally, while playing around with some random behavior, I stumbled across the human eye as inspiration.

This project feels pretty incomplete, and I would like to implement some changes relating color to time. For instance, perhaps the color of the iris could mimic the color of the sunset or something.

Leave a Reply