aranders-project-02

aranders-project-02

//Anna Anderson
//Section D
//aranders@andrew.cmu.edu
//project-02

var mouth = 15;
var nose = 10;
var eyes = 25;
var brows = 10;
var faceHeight = 230;
var faceWidth = 200;

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

function draw() {
  background(130, 211, 168);

  //face
  fill(249, 231, 126);
  ellipse(320, 240, faceWidth, faceHeight);

  //mouth
  fill(240, 125, 140);
  ellipse(320, 315, mouth * 2, mouth)
  noFill();
  beginShape();
  curveVertex(280, 290);
  curveVertex(300, 309);
  curveVertex(320, 316);
  curveVertex(340, 309);
  curveVertex(360, 290);
  endShape();

  //nose
  fill(250);
  triangle(315 - nose, 270, 320, 250 + nose, 325 + nose, 270);

  //eyes
  fill(0);
  ellipse(275, 230, eyes, eyes * 1.5);
  fill(0);
  ellipse(365, 230, eyes, eyes * 1.5);

  //brows
  line(260 - brows, 180 + brows, 290, 180);
  line(350, 180, 400 - brows, 180 + brows);
}

function mousePressed() {

  mouth = random(5, 20);
  nose = random(5, 20);
  eyes = random(15, 35);
  brows = random(5, 20);
  faceHeight = random(220, 300);
  faceWidth = random(190, 250);
}

I really enjoyed creating this interactive face! I made many dumb errors in the course of creating it, but eventually it came together.

Leave a Reply