hqq – secE – project06 – abstract-clock

hamza

//hamza qureshi
//hqq@andrew.cmu.edu
//section e
//project 6

function setup(){
    createCanvas(480,480);
    ellipseMode(CENTER);
}

function draw(){
    background(210,230,220);
    noStroke();

    //body of oscar the walrus
    fill(170);
    var bodw = 0.75*width;
    var bodh = 0.75*height;
    ellipse(bodw,bodh,width,bodh);

    //mouth
    bodw = width/2;  //redefines variables to allow to draw from center
    bodh = height/2;
    var h = hour(); //calls hour function
    if (h == 12){ //resets the hourly measure to convert to 12-hr clock
        h = 0;
    }
    var xH = map(h,0,11,0,40); //remaps range of hours to translation unit
    fill(180);
    ellipse(bodw,bodh+xH,130,250); // lowers mouth as hour increases
    fill(160,100,100);
    ellipse(bodw,bodh+xH,110,230); //"______________________________"

    //head
    fill(190);
    ellipse(bodw,bodh-70,260,250);

    //eyes
    //black
    fill(0);
    ellipse(bodw-50,bodh-100,30,30);
    ellipse(bodw+50,bodh-100,30,30);
    //white
    fill(255);
    ellipse(bodw-55,bodh-105,15,15);
    ellipse(bodw+45,bodh-105,15,15);

    //blink every other second
    var s = second(); //calls second function
    if (s % 2 == 1){ //modulus to determine odd-count second
        fill(170);
        ellipse(bodw-50,bodh-100,31,31); //draws "blink" over original eye
        ellipse(bodw+50,bodh-100,31,31);
        fill(130);
        ellipse(bodw-50,bodh-100,32,10);
        ellipse(bodw+50,bodh-100,32,10);
        push();
        strokeWeight(2);
        stroke(120);
        line(bodw-68,bodh-100,bodw-32,bodh-100);
        line(bodw+68,bodh-100,bodw+32,bodh-100);
        pop();
    }

    //tusks
    fill(252,246,232); //ivory color
    var m = minute(); //calls minute function
    var xM = map(m,0,59,130,240); //remaps minute range to reflect length of tusk
    beginShape();
    curveVertex(bodw-80,bodh);
    curveVertex(bodw-85,bodh+120);
    curveVertex(bodw-80,bodw+xM); //lowers left tusk according to minute
    curveVertex(bodw-65,bodh+120);
    curveVertex(bodw-60,bodh);
    endShape(CLOSE);
    beginShape();
    curveVertex(bodw+80,bodh);
    curveVertex(bodw+85,bodh+120);
    curveVertex(bodw+80,bodw+xM); //lowers right tusk according to minute
    curveVertex(bodw+65,bodh+120);
    curveVertex(bodw+60,bodh);
    endShape(CLOSE);

    //cheeks
    fill(190);
    ellipse(bodw-70,bodh+40,165,140);
    ellipse(bodw+70,bodh+40,165,140);
        //freckles
        fill(90);
        ellipse(bodw-80,bodh+30,7,7);
        ellipse(bodw-100,bodh+60,7,7);
        ellipse(bodw-60,bodh+50,7,7);
        ellipse(bodw+80,bodh+30,7,7);
        ellipse(bodw+100,bodh+60,7,7);
        ellipse(bodw+60,bodh+50,7,7);

    //nose
    fill(0);
    triangle(bodw,bodh-20,bodw+30,bodh-35,bodw-30,bodh-35);

    //whiskers
    strokeWeight(1);
    stroke(0);
    noFill();
    bezier(bodw-140,bodh+30,bodw-160,bodh+25,bodw-180,bodh+30,bodw-200,bodh+40);
    bezier(bodw+140,bodh+30,bodw+160,bodh+25,bodw+180,bodh+30,bodw+200,bodh+40);
    bezier(bodw-130,bodh+50,bodw-150,bodh+45,bodw-170,bodh+40,bodw-190,bodh+60);
    bezier(bodw+130,bodh+50,bodw+150,bodh+45,bodw+170,bodh+40,bodw+190,bodh+60);
    bezier(bodw-120,bodh+70,bodw-140,bodh+65,bodw-160,bodh+50,bodw-180,bodh+70);
    bezier(bodw+120,bodh+70,bodw+140,bodh+65,bodw+160,bodh+50,bodw+180,bodh+70);
}

For my abstract clock, I wanted to create an image that was fun and playful, and would not immediately read as a clock unless it was meticulously watched for awhile. I thought of walruses as a fun way to create an image that tells time and used subtle aspects of the walrus’ anatomy to show changes in time. In the script, the eyes blink to correspond to the second, the tusks grow longer as each minute passes, and the mouth drops to correspond with the hour. Much like me, the walrus appears to get happier the later in the morning or evening it becomes, much like I do. However, unlike me, the walrus seems to be pretty good at keeping time.

Leave a Reply