Lrospigl-Project02-VariableFaces

sketch

  var eyeSize = 20;
  var faceWidth = 170;
  var faceHeight = 170;
  var eyeColor = 150;
  var shirtColor = 150;
  
function setup() {
  createCanvas(400, 400);
}

function draw() {

  background(127, 155, 245);

  //hair
  strokeWeight(0);
  fill (138,109,90);
  rect (width/2 - (faceWidth/2) - 10, 
  height/2 - (faceHeight / 2) - 10, 
  faceWidth + 20, 
  faceHeight + 40, 30);
  
  //hairShadow
  strokeWeight(0);
  fill (121,96,79);
  rect (width/2 - (faceWidth/2), height/2 - (faceHeight / 2) - 10, 
  faceWidth, faceHeight + 40, 15);
  
  //neck
  strokeWeight(0);
  fill(239, 205, 182);
  rect (width/2 - 10, 200, 20, 200, 10);

  //neckshadow
  strokeWeight(0);
  fill(211, 179, 158);
  rect (width/2 - 10, 150 + (faceHeight / 3), 20, 100, 10);
  
  //head
  strokeWeight(0);
  fill(239, 205, 182);
  rect (width/2 - (faceWidth/2), height/2 - (faceHeight / 2), 
  faceWidth, faceHeight, 30);
  
  var eyeXpos = (width / 2 - faceWidth * 0.25);
  var eyeYpos = (width / 2 + faceWidth * 0.25);

  //eyes
  strokeWeight(1);
  arc(eyeXpos, height / 2, eyeSize, eyeSize, 0, 2*HALF_PI);
  arc(eyeYpos, height / 2, eyeSize, eyeSize, 0, 2*HALF_PI);

  //shirt
  strokeWeight(0);
  fill(76, shirtColor, 91);
  rect (width/2 - (faceWidth*1.2 / 2), 340,
  (faceWidth * 1.2), 80, 10);
  
  //smile
  
  fill (246,180,211); 
  arc(200, 200 + (faceHeight / 4), 
  (faceWidth/3), faceHeight/4, 0, 2*HALF_PI);
  
  //teeth
  fill (255,255,255);
  arc(200, 200 + (faceHeight / 4), 
  (faceWidth/3), faceHeight/10, 0, 2*HALF_PI);
  
  //eyebrows
  noFill ();
  strokeWeight(0.2);
  bezier(eyeXpos - 17, height / 2 - 10, 
  eyeXpos + 10, height / 2 - 20,
  eyeXpos + 10, height / 2 - 12,
  eyeXpos + 15, height / 2 - 10);
  
  bezier(eyeYpos - 17, height / 2 - 10, 
  eyeYpos + 10, height / 2 - 20,
  eyeYpos + 10, height / 2 - 12,
  eyeYpos + 15, height / 2 - 10);
  
  //bangs
  strokeWeight(0);
  fill (138,109,90)
  rect (width/2 - (faceWidth/2) + 2, 
  height/2 - (faceHeight / 2) - 10,
  faceWidth - 4, 
  faceHeight - (faceHeight/1.6), 10);
  
}

function mousePressed() {
  faceWidth = random(100, 200);
  faceHeight = random(100, 250);
  eyeSize = random(15, 30);
  shirtColor = random(0,150);
}

Leave a Reply