Variable Face

I decided to give this flower a face. I made each eye shape to randomize differently. In addition, the flower occasionally blushes.

VariableFace
/*
 *  Hayoon Choi
 *  hayoonc@andrew.cmu.edu
 *  Section C
 *
 *  Random Face
 */
var reyeWidth = 23;
var reyeHeight = 7;
var leyeWidth = 23;
var leyeHeight = 7;
var headWidth = 160;
var headHeight = 262;
var petalHeight = 150;
var petalR = 237;
var petalG = 227;
var petalB = 98;
var nosePoint = 253.5;
var noseePoint = 243.5;
var blush = 0;

function setup() {
    createCanvas(480, 640);
    frameRate = 10;
}
 
function draw() {
    background(166, 213, 221);
    //clouds
    fill(255);
    circle(100, 50, 70);
    circle(140, 90, 60);
    circle(70, 90, 90);
    circle(150, 60, 50);
    circle(300, 180, 50);
    circle(350, 170, 80);
    circle(375, 120, 85);
    circle(430, 150, 100);
    circle(400, 200, 45);
    //petals
    noStroke();
    fill(petalR, petalG, petalB);
    ellipse(207, 168, 61, petalHeight);
    push();
    translate(290,210);
    rotate(PI / 3.0);
    ellipse(0, 0, 61, petalHeight);
    pop();
    push();
    translate(320,275);
    rotate(HALF_PI);
    ellipse(0, 0, 61, petalHeight);
    pop();
    push();
    translate(310,345);
    rotate(PI / 1.5);
    ellipse(0, 0, 61, petalHeight);
    pop();
    push();
    translate(270,390);
    rotate(PI / 1.25);
    ellipse(0, 0, 61, petalHeight);
    pop();
    push();
    translate(120,210);
    rotate(-PI / 3.0);
    ellipse(0, 0, 61, petalHeight);
    pop();
    push();
    translate(100,275);
    rotate(-HALF_PI);
    ellipse(0, 0, 61, petalHeight);
    pop();
    push();
    translate(100,345);
    rotate(-PI / 1.5);
    ellipse(0, 0, 61, petalHeight);
    pop();
    push();
    translate(114,390);
    rotate(-PI / 1.25);
    ellipse(0, 0, 61, petalHeight);
    pop();
    //shirt
    noStroke();
    fill(112, 163, 72);
    rect(80, 400, 250, 300, 80);
    //leaves
    ellipse(390, 530, 180, 70);
    ellipse(50, 580, 180, 70);
    strokeWeight(2);
    stroke(49, 73, 29);
    line(330, 530, width, 530);
    line(0, 580, 80, 580);
    //v neck
    point(135, 400);
    point(160, 470);
    point(200, 530);
    point(240, 470);
    point(280, 400);
    noStroke();
    fill(201, 170, 109);
    beginShape();
    curveVertex(135, 400);
    curveVertex(135, 400);
    curveVertex(160, 470);
    curveVertex(200, 530);
    curveVertex(240, 470);
    curveVertex(280, 400);
    curveVertex(280, 400);
    endShape();
    //head
    fill(216, 187, 115);
    ellipse(207, 347, headWidth, headHeight);
    noFill();
    strokeWeight(3);
    stroke(153, 128, 80);
    arc(230, 450, 30, 15, 0, PI);
    //eyes
    strokeWeight(1);
    stroke(0);
    fill(255);
    ellipse(189, 312, leyeWidth, leyeHeight);
    ellipse(258, 312, reyeWidth, reyeHeight);
    fill(0);
    noStroke();
    var x = constrain(mouseX, 189 - leyeWidth + 20, 189 + (leyeWidth - 20));
    ellipse(x, 312, 9, 7);
    var xTwo = constrain(mouseX, 257 - reyeWidth + 20, 257 + (reyeWidth - 20));
    ellipse(xTwo, 312, 9, 7);
    //mouth
    fill(214, 116, 146);
    ellipse(245, 368, 20.5, 16.5);
    stroke(0);
    line(236, 368, 256, 368);
    //blush
    if (blush > 1.5) {
        fill(245, 223, 223);
        noStroke();
        ellipse (170, 347, headWidth / 5, headHeight /12);
        ellipse (280, 347, headWidth / 7, headHeight /14);
    }
    //nose
    point(233.5, 307.5);
    point(noseePoint, 320.5);
    point(nosePoint, 350.5);
    point(241.5, 355.5);
    fill(216, 187, 115);
    stroke(0);
    beginShape();
    curveVertex(233.5, 307.5);
    curveVertex(233.5, 307.5);
    curveVertex(noseePoint, 320.5);
    curveVertex(nosePoint, 350.5);
    curveVertex(241.5, 355.5);
    curveVertex(241.5, 355.5);
    endShape();
    noFill();
    arc(236.5, 354.5, 4, 4, PI , TWO_PI);
    //shine
    fill(255);
    noStroke();
    push()
    translate(170 , 250);
    rotate(-PI / 3.75);
    ellipse(0, 0, 40, 10);
    pop();
    ellipse(195, 227, 10, 10);
}

function mousePressed() {
    reyeWidth = random(20, 35);
    reyeHeight = random(7, 25);
    leyeWidth = random(20, 35);
    leyeHeight = random(7, 25);
    headWidth = random(145, 230);
    headHeight = random(260, 350);
    petalHeight = random(100, 250);
    petalR = random(150, 250);
    petalG = random(30, 250);
    petalB = random(40, 220);
    nosePoint = random(245, 350);
    noseePoint = random(240, 280);
    blush = random(0,2);
}

Leave a Reply