Project-02-Varying faces

sketch

//Sihan Dong
//sihand@andrew.cmu.edu
//Section B
//this program generates different faces of yound women


//setting up the variables and the default image (no mouse pressed)
var headpar = 150;
var mouthpar = 20;
var neckl = 50;
var bodwidth = 130;
var bodheight = 600;
var bulbstroke = 0;
var browarch = 40;
var eyestroke = 7;
var eyeht = 250;
var vertexX = 350;
var vertexY = 100;
var noi = 5;

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

function draw() {
  background(245,231,146);//creating the notebook effect
  var noteline1 = color(212,201,140);
  stroke(noteline1);
  line(0,40,480,40);
  line(0,80,480,80);
  line(0,120,480,120);
  line(0,160,480,160);
  line(0,200,480,200);
  line(0,240,480,240);
  line(0,280,480,280);
  line(0,320,480,320);
  line(0,360,480,360);
  line(0,400,480,400);
  line(0,440,480,440);
  line(0,480,480,480);
  line(0,520,480,520);
  line(0,560,480,560);
  line(0,600,480,600);
  var noteline2 = color(195,159,105);
  stroke(noteline2);
  line(80,0,80,640);
  line(85,0,85,640);

  var ballpt = color(52,57,136);//created the doodle face
  noFill();
  stroke(ballpt);
  strokeWeight(5);
  ellipse(290,250,headpar,1.25*headpar);//headshape
  ellipse(290-headpar/2+70,280,mouthpar,mouthpar);//mouthshape

  line(290,250+1.25*headpar/2,290, 250+1.25*headpar/2+neckl);//neckline_1
  line(290+noi,250+1.25*headpar/2,290+noi, 250+1.25*headpar/2+neckl);//neckline_2

  ellipse(290,250+1.25*headpar/2+neckl+bodheight/2,bodwidth,bodheight);//body
  ellipse(290,250+noi+1.25*headpar/2+neckl+bodheight/2,bodwidth-noi,bodheight-noi);

  arc(250,230,browarch,browarch,PI+QUARTER_PI, TWO_PI-QUARTER_PI);//left brow
  arc(320,230,browarch,browarch,PI+QUARTER_PI, TWO_PI-QUARTER_PI);//right brow

  strokeWeight(eyestroke);//eyes
  line (235,eyeht,255,eyeht);
  line (315,eyeht,335,eyeht);

  //a bulb will appear when the person gasps, so will the eyes open up
  // have fun clicking! :D
    if (mouthpar>35) {
      bulbstroke = 3;
      eyestroke = 25;
      strokeWeight(2);
      textSize(20);
      text("Eureka!",vertexX-150,vertexY-20);
      noFill();
      stroke(ballpt);//the bulb will not appear if the mouth is not open wide enough
      strokeWeight(bulbstroke);
      beginShape();
      vertex(vertexX,vertexY);
      vertex(vertexX+15,vertexY);
      vertex(vertexX+15,vertexY+20);
      vertex(vertexX, vertexY+20);
      endShape(CLOSE);
      line(vertexX,vertexY+10,vertexX+15,vertexY+10);
      ellipse(vertexX+15/2, vertexY-25,50,50);//the outer ellipse
      ellipse(vertexX+15/2, vertexY-15,15,30);//the inner ellipse
    }
    if (mouthpar<35) {
      bulbstroke = 0
      eyestroke = 7;
    }
}

//generating doodles
function mousePressed() {
  headpar = random(130,180);
  mouthpar = random(10,40);
  neckl = random (40,60);
  bodwidth = random (100,200);
  browarch = random (35,45);
  noi = random (-15,15);
  eyeht = random(245,255);
  //the light bulb shows up around the figure's head
  vertexY = random (80,120);
  vertexX = random (150,400);

}

This project was inspired by the ballpoint doodles I used to draw on my notes. I recreated the notebook background and the stroke color according to an online picture. A user can play with the doodle by clicking until the light bulb appears, signifying the “eureka” moment.

Leave a Reply