Project 02: Variable Faces

sketchDownload
var pot = 3;
var plant = 1;
var eyebrows = 3;
var eyes = 3;
var mouth = 3;

function setup() {
    createCanvas(400, 400);
}
 
function draw() {
    background(251, 166, 156);
    noStroke();
    fill(255,202,196);
    rect(0,300,400,100);
    if(plant<=1) { //spiky
        noStroke();
        fill(43, 92, 48);
        triangle(140,200,110,120,190,200); //1
        fill(50, 136, 58);
        triangle(155,200,120,70,200,200); //2
        fill(65, 167, 75 );
        triangle(200,200,290,70,260,200); //5
        fill(77, 144, 84 );
        triangle(190,200,220,35,250,200); //4
        fill(57, 116, 62);
        triangle(175,200,160,30,220,200); //3
    }
    else if(plant<=2) { //flower
        noFill();
        stroke(143, 167, 65);
        strokeWeight(6)
        bezier(155,110,185,130,210,200,188,200); //leftstem
        stroke(143, 167, 65);
        strokeWeight(6)
        bezier(250,53,180,130,200,200,200,200); //rightstem
        noStroke();
        fill(178, 123, 210); //lightpurple
        ellipse(140,95,20);
        fill(178,123,210);
        ellipse(155,100,20);
        fill(178,123,210);
        ellipse(150,115,20);
        fill(178,123,210);
        ellipse(135,110,20); //end of flower left
        fill(178, 123, 210);
        ellipse(245,45,20);
        fill(178,123,210);
        ellipse(260,50,20);
        fill(178,123,210);
        ellipse(255,65,20);
        fill(178,123,210);
        ellipse(240,60,20); //endof flower right
        noStroke();
        fill(223, 186, 244);
        ellipse(249,55,10) //topflowermiddle
        fill(223, 186, 244);
        ellipse(145,105,10); //bottomflowermiddle
        noStroke();
        fill(143,167,65);
        arc(197,150, 80, 80, 0, PI/2, OPEN); //rightleafright
        fill(143,167,65);
        arc(237,190, 80, 80, PI,-PI/2, OPEN); //rightleafleft
        noStroke();
        fill(143,167,65);
        arc(154,190, 80, 80, -PI/2, 0,OPEN); //leftleafright
        fill(143,167,65);
        arc(194,150, 80, 80, PI/2, PI, OPEN); //leftleafleft
    }
    else if(plant<=3) { //cactus
        noStroke();
        fill(34, 72, 13);
        ellipse(200,85,90);
        noStroke();
        fill(34, 72, 13);
        rect(155,85,90,110);
        noFill();
        strokeWeight(30);
        stroke(34,72,14);
        bezier(130,80,130,100,120,120,160,120); //rightarm
        noFill();
        strokeWeight(30);
        stroke(34,72,14);
        bezier(275,100,275,120,280,150,240,145); //leftarm
    }


    if(pot<=1) {
        noStroke();
        fill(209,164,96);
        quad(100,200,300,200,250,360,150,360); //pot1
        fill(194, 140, 55);
        rect(90,190,220,35); //pottop1
        fill(160, 118, 53 );
        triangle(144,340,148,352,155,321); //crack
        triangle(153,329,155,321,142,310);
        triangle(141,310,144,313,143,292);
    }
    else if(pot<=2) {
        noStroke();
        fill(178, 123, 210);
        ellipse(200,280,180);
        fill(152, 104, 180);
        rect(105,190,190,35); //pottop1
        fill(132, 83, 161);
        triangle(220,368,233,364,240,330);
        triangle(240,330,237,340,270,317);
        triangle(270,317,263,320,275,300);
    }
    else if(pot<=3) {
        noStroke();
        fill(104, 180, 153);
        ellipse(200,270,180,180);
        fill(104, 180, 153);
        quad(110,180,290,180,230,350,170,350);
        fill(73, 146, 120);
        triangle(260,180,270,180,245,215);
        triangle(245,215,250,204,269,238);
        triangle(269,238,265,232,260,267);
    }

    if(eyes<=1) { //opencircleeyes
        fill(65, 49, 21);
        ellipse(175,280,5,8);
        ellipse(225,280,5,8); //righteye
    }
    else if(eyes<=2) { //closed
        noFill();
        strokeWeight(3);
        stroke(65, 49, 21);
        bezier(220,280,220,290,235,290,235,280);
        stroke(65, 49, 21);
        bezier(180,280,180,290,165,290,165,280);
    }
    else if(eyes<=3) { //squint
        noFill();
        strokeWeight(3);
        stroke(65, 49, 21);
        line(180,280,168,275)
        line(180,280,168,285)
        line(220,280,232,275)
        line(220,280,232,285);
    }

    if(mouth<=1) { //openmouth
        noStroke();
        fill(108, 32, 55);
        ellipse(200,312,18,20);
    }
    else if (mouth<=2) { //smile
        noFill();
        strokeWeight(3);
        stroke(65, 49, 21);
        bezier(190,310,190,325,210,325,210,310);
    }
    else if (mouth<=3) { //sidemouth
        noFill();
        strokeWeight(3);
        stroke(65, 49, 21);
        bezier(200,320,210,325,218,320,225,310);
    }

    if(eyebrows<=1) {
        noFill();
        strokeWeight(3);
        stroke(65, 49, 21);
        bezier(225,253,230,265,238,265,240,265);
        bezier(175,253,170,265,162,265,160,265);
    }
    else if(eyebrows<=2) {
        noFill();
        strokeWeight(3);
        stroke(65, 49, 21);
        bezier(225,253,230,250,238,260,240,265);
        bezier(175,253,170,250,162,260,160,265);
    }
    else if(eyebrows<=3) {
        noFill();
        strokeWeight(3);
        stroke(65, 49, 21);
        line(220,260,230,255);
        line(180,260,170,255);
    }
    strokeWeight(3); //cheeks
    stroke(255, 158, 147);
    line(238,295,245,290);
    line(246,295,253,290);
    line(162,295,155,290);
    line(154,295,147,290);

fill(255);
    noStroke();
    textSize(12);
    textAlign(CENTER);
    text("2 CORINTHIANS 4:7",333,390);
}

 
function mousePressed() {
    pot = random(0, 3);
    plant = random(0, 3);
    eyebrows = random(0,3);
    eyes = random(0,3);
    mouth = random(0,3);
}

Leave a Reply