Sydney Salamy: Project-02-Variable-Face

I wanted my project to react and change as the mouse of the viewer moved, so I played around with if statements, which was an interesting challenge. I wanted my project to have a cute aspect to it. Originally, there was supposed to be a fruit with a face reacting, but then it turned into a baby who didn’t want others touching its candy.

sketchsydney

//Dont Touch The Lolipop!

var pi = 3.14159;
var mainX = 320;
var headY = 220;
var bodyY = 360;
var iEyeBrowY = 212;

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

function draw() {
    background(163, 210, 267);//baby blue
    noStroke();
    //baby base
    fill(233, 185, 122);//darker tan
    ellipse(mainX,bodyY, 170,170);//baby body
    fill(237, 189, 126);//tan
    ellipse(mainX,headY, 150,150);//baby head
    //arcs
    fill(255);
    arc(mainX,bodyY, 172, 172, 0, pi, CHORD);//baby diaper
    fill(255, 163, 195);
    arc(mainX,headY, 152, 152, pi, 0, CHORD);//baby hat
    //limbs
    fill(229,181,118);//darker tan 2
    ellipse(440,307, 150,40);//right arm
    ellipse(200,307, 150,40);//left arm 
    ellipse(355,475, 45,145);//right leg
    ellipse(285,475, 45,145);//left leg
    //lolipop
    fill(245);
    rect(490,245, 6, 100);//stick
    frameRate(.7);
    fill(random(230),random(200),random(220));//candy color
    ellipse(493,220, 106,100);//candy part   
    //facial features
    frameRate(10);
    fill(0);
    ellipse(343,225, 8,8);//right eye
    ellipse(297,225, 8,8);//left eye
    strokeWeight(4);
    stroke(0);
    line(336,iEyeBrowY, 355,218);//right eyebrow
    line(285,218, 304,iEyeBrowY);//left eyebrow
    //movement
    if(mouseX > 365){
        iEyeBrowY = 218;//stern
        line(315,256, 325,256);//flat mouth
        fill(128, 17, 17);
        ellipse(343,225, 8,8);//right eye
        ellipse(297,225, 8,8);//left eye
    }
    if(mouseX > 440){
        iEyeBrowY = 223;//angry
        arc(mainX,256, 20, 20, pi, 0, CHORD);//sad mouth
        fill("red");
        ellipse(343,225, 8,8);//right eye
        ellipse(297,225, 8,8);//left eye
    }
    if(mouseX > 545){
        iEyeBrowY = 218;//stern
        line(315,256, 325,256);//flat mouth
        fill(128, 17, 17);
        ellipse(343,225, 8,8);//right eye
        ellipse(297,225, 8,8);//left eye
    }
    if(mouseX < 365){
        iEyeBrowY = 212;//happy
        arc(mainX,256, 20, 20, 0, pi, CHORD);//happy mouth
        fill(0);
        ellipse(343,225, 8,8);//right eye
        ellipse(297,225, 8,8);//left eye
    }
    if(mouseX > 621){
        iEyeBrowY = 212;//happy
        arc(mainX,256, 20, 20, 0, pi, CHORD);//happy mouth
        fill(0);
        ellipse(343,225, 8,8);//right eye
        ellipse(297,225, 8,8);//left eye
    }
}

Leave a Reply