Project 2: Variable Faces



//shape variables 
var faceWidth = random(250, 450);
var faceHeight = random(320, 450);
var eyeSize = random(20, 40);
var noseWidth = random(20, 40);
var noseHeight = random(30, 50); 
var eyebrowShape = random(20, 30);
var mouth = 1 

//color variables 
var faceRed = random(0, 255);
var faceGreen = random(0, 255);
var faceBlue = random(0, 255); 
var noseRed = random(0, 255);
var noseGreen = random(0, 255);
var noseBlue = random(0, 255);
var eyebrowRed = random(0, 255);
var eyebrowGreen = random(0, 255);
var eyebrowBlue = random (0, 255); 

function setup() {
  createCanvas(640, 480);
  background(220);

}

function draw() {
  noStroke();
  background(220);
  fill(red,green,blue);

  // face and eyes 
  ellipse(width / 2, height / 2, faceWidth,  faceHeight);
  fill(0, 0, 0);
  var eyeLX = width / 2 - faceWidth * 0.25;
  var eyeRX = width / 2 + faceWidth * 0.25;
  ellipse(eyeLX, height / 2, eyeSize, eyeSize);
  ellipse(eyeRX, height / 2, eyeSize, eyeSize);

  //nose 
  fill(noseRed, noseGreen, noseBlue);
  rect(310, 230, 20, 40);
  
  //mouth 
  if (mouth <= 1) { 
    stroke(1);
    noFill();
    line(275,325,325,325);
  } else if (mouth < 2 ) {
    stroke(1); 
    noFill();
    arc(320,230,230,230,.31,2.83);
  } else if (mouth < 3) {
    stroke(1); 
    noFill();
    arc(320,370,140,170,3.46,5.97);
    
  }

  // eyebrows 
  noStroke();
  fill(eyebrowRed, eyebrowGreen, eyebrowBlue);
  rect(eyeLX - 20, height / 2 - 50, 50, eyebrowShape);
  rect(eyeRX - 20, height / 2 - 50, 50, eyebrowShape);
}
  

function mousePressed() {
  red = random(0, 255);
  green = random(0, 255);
  blue = random(0, 255); 

  noseRed = random(0, 255);
  noseGreen = random(0, 255);
  noseBlue = random(0, 255);

  faceWidth = random(250, 450);
  faceHeight = random(320, 450);
  eyeSize = random(20, 40);

  noseWidth = random(20, 40);
  noseHeight = random(30, 50);

  eyebrowShape = random(20, 30); 

  eyebrowRed = random(0, 255);
  eyebrowGreen = random(0, 255);
  eyebrowBlue = random (0, 255); 

  mouth = random(1,3); 



  

 




}

Leave a Reply