Shariq Shah – Project 02 – Variable Faces

shariqs_VariableFaces-02

// Shariq M. Shah
// Section C
// shariqs@andrew.cmu.edu
// Assignment_01

//setting up variables

var eyeWidth = 20
var eyeHeight = 20
var eyePosL = 240
var eyePosR = 340
var mouthC = 80
var backColor = 200
var earPos = 280
var nosePos = 320
var faceWidth = 220

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

function draw() {
  background(230, backColor, 211);
  noStroke()

  fill(250, 200, 0)
  ellipse(300,600,600,300)

  strokeWeight(2)
  rect(220, 400, 150, 150, 15)

  //Face
  fill(200, 162, 132)
  rect(170, 180, 250, 250, 30, 100, 150, 150)

  fill(0,0,0)

  ellipse(300,180, faceWidth, 150)
  rect(150, 180, 300, 80,30)

  //Left Spec
  noFill()
  stroke(300)
  ellipse(240, 290, 60, 60)
  ellipse(240, 290, 55, 55)


  //Left Eye
  stroke(300)
  fill(300)
  ellipse(240, 290, eyeWidth, eyeHeight)
  fill(0)
  ellipse(eyePosL, 290, 15, 20)
  ellipse(eyePosL, 285, 2, 2)


  //Right Eye
  stroke(300)
  fill(300)
  ellipse(340, 290, eyeWidth, eyeHeight)
  fill(0)
  ellipse(eyePosR, 290, 15, 20)
  ellipse(eyePosR, 285, 2, 2)

  line(175, 180, 425, 180)

  //Right Spec
  noFill()
  stroke(300)
  ellipse(340, 290, 60, 60)
  ellipse(340, 290, 55, 55)

  line(310,290, 270, 290)
  line(310,285, 270, 285)

  line(210,285, 170, 280)
  line(210,290, 170, 280)


  line(370,285, 420, 280)
  line(370,290, 420, 280)

  //Nose
  noStroke()
  fill(240, 171, 142)
  triangle(290, 300, 290, nosePos, 310, 360)
  fill(214, 171, 139)
  triangle(290, 300, 290, nosePos, 270, 360)

//Mouth
	fill (300);

	ellipse (290, 382, mouthC, 42);
	fill (200, 162, 132);

	rect (220, 360, 120, 21);

  //Ears
  ellipse(425,earPos, 20, 80)
  ellipse(165,earPos, 20, 80)


  fill(300-backColor)



  //Logo
  bezier(105, 20, 10, 10, 90, 90, 15, 80)

  //Collar
  bezier(220, 460, 300, 650, 150, 650, 370, 460)
}



function mousePressed() {

    eyeWidth = random(15, 50);
    eyeHeight = random(20, 35);
    eyePosL = random(240, 250);
    eyePosR = random(340, 350);
    mouthC = random(30, 90);
    backColor = random(100, 200);
    earPos = random(300,310)
    nosePos = random(320, 360)
    faceWidth = random(220, 250)


}

In this exercise, I explored multiple ways to vary the way different shapes and colors that change as a result of the mousePressed() function. The result is a strange, expressive, and colorful face that alters itself randomly, with constraints, as a result of pressing on the image.

Leave a Reply