Code

void setup(){
  size(500,300);
  background(140,40,60);
  smooth();
  noStroke();
  drawRandomFace();
}
void draw(){
  // leave this alone
}
void mousePressed(){
  drawRandomFace();
}
void drawRandomFace(){
  int hueR=(int)random(10,80);
  int hueG=(int)random(100,200);
  int hueB=(int)random(140,255);
  background(140,40,60);
  strokeWeight(3);
  stroke(255);
  fill(hueR,hueG,hueB);
  beginShape();
  curveVertex(140,201);
  curveVertex(94,161);
  curveVertex(180,121);
  curveVertex(250,128);
  curveVertex(324,161);
  curveVertex(365,126);
  curveVertex(338,113);
  curveVertex(330,85);
  curveVertex(372,84);
  curveVertex(380,94);  //dip
  curveVertex(392,87);
  curveVertex(425,86);
  curveVertex(412,122);
  curveVertex(382,128);
  curveVertex(360,180); //
  curveVertex(260,240);
  curveVertex(160,242);
  curveVertex(94,161);
  curveVertex(200,-40);
  endShape();

  int randArm=(int)random(2);
  if (randArm==1){
    fill(250,240,140);
    stroke(255);
    beginShape();
    curveVertex(268,230);
    curveVertex(268,230);
    curveVertex(287,187);
    curveVertex(335,188);
    curveVertex(374,214);
    curveVertex(424,197);
    curveVertex(429,178);
    curveVertex(412,170);//
    curveVertex(388,160);
    curveVertex(390,156);
    curveVertex(406,158);
    curveVertex(404,147);
    curveVertex(407,134);
    curveVertex(416,134);
    curveVertex(422,130);
    curveVertex(432,134);
    curveVertex(440,130);
    curveVertex(448,134);
    curveVertex(454,128);
    curveVertex(460,134);
    curveVertex(458,177);
    curveVertex(410,240);
    curveVertex(358,272);
    curveVertex(307,277);
    curveVertex(268,230);
    curveVertex(320,180);
    endShape();
    noFill();
    stroke(0);
    strokeWeight(2);
    ellipse(308,228, 4,4);
    line(306,240, 322,229);
    line(310,230, 330,250);
    line(320,250, 330,250);
    line(330,240, 330,250);
  }

  stroke(255);
  curve(0,300, 95,162, 260,200, 300,240);

  noStroke();
  fill(140,40,60);
  int eyeSizeL = (int)random(4,10);
  int eyeSizeR = (int)random(8,20);
  ellipse (130,146,eyeSizeL,eyeSizeL);
  ellipse (260,180,eyeSizeR,eyeSizeR);


}

0308 - Random Faces: More about the random() function

Statement:The objective of this exercise is for you to have some fun learning how to control the random() function. Below is a simple code template that draws the beginnings of a random face whenever the user clicks. Fill out the drawRandomFace() function with interesting stuff. For example, you could give consideration to creating random skin colors, interocular distance (eye separation), facial expression, etcetera. Some random properties could be represented by continuous variables (nose size), while others could be represented by booleans (the presence or absence of glasses, freckles, a mustache, etc.). In my code template below, the use of an ellipse for the head is only a suggestion.

void setup(){
  size(300,300);
  drawRandomFace();
}
void draw(){
  // leave this alone
}
void mousePressed(){
  drawRandomFace();
}
void drawRandomFace(){
  // this is only a suggestion
  background(220);
  float rw = random(100,200);
  float rh = random(100,200);
  ellipse(width/2,height/2, rw,rh);
}

hide statement