Project-02-Variable-Face

In addition to the faces, I tried making each variation bigger after each click, as if the image is approaching you. After a certain size, the image would revert back to the starting size but the variables are still different, giving a new look each time.

var eyesize = 30
var headwidth = 200
var headheight = 270
var headcolor = 255
var red = 0
var green = 0
var blue = 0
var hair = 230
var hairheight = 200
var hairR = 410
var hairheightR = 200
var hairsize = 50
var hairdifference = 10
var lefteyex = 270
var righteyex = 370
var eyeheight = 240
var mouthheight = 50
var tonguelength = 30
var bodysize = 500
var browstartleft = 240
var browstartright = 340
var browheight = 180
var browlength = 50


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

}

function draw() {
    background(red,green,blue);
  //body
    fill(random(90),random(90),random(90))
    ellipse(320,520,bodysize,400);
  //head
    fill(219, 181, 88);
    noStroke();
    ellipse(320,240,headwidth,headheight);
  //parameters
    if(headheight>400) {headheight=270,headwidth=200,
                        hair=230,hairheight=200,
                        hairR=410,hairheightR=200
                        hairsize=50,hairdifference=10
                        lefteyex=270,righteyex=370
                        eyeheight=230,mouthheight=50
                        tonguelength=30,bodysize=500
                        browstartright=340,browstartleft=240
                        browheight=180,browlength=50}
  //hair
    noFill();
    stroke(0,50);
    strokeWeight(5,);
    arc(hair,hairheight,hairsize,30,PI,0);
    arc(hair,hairheight-hairdifference,hairsize,30,PI,0);
    arc(hairR,hairheightR,hairsize,30,PI,0);
    arc(hairR,hairheightR-hairdifference,hairsize,30,PI,0);
  //eyes
    noStroke();
    fill(random(200,255),random(200,255),random(200,255))
    circle(lefteyex,eyeheight,eyesize);
    circle(righteyex,eyeheight,eyesize);
  //mouth
    fill(0);
    rect(250,300,140,mouthheight,50);
  //tongue
    stroke(241, 76, 88);
    arc(320,330,30,tonguelength,0,PI);
  //eyebrows
    noStroke();
    rect(browstartleft,browheight,browlength,10,30);
    rect(browstartright,browheight,browlength,10,30);

}

function mousePressed() {
  red = random(255);
  green = random(255);
  blue = random(255);
  headwidth += 25
  headheight += 30
  hair -= 10
  hairheight -= 5
  hairR += 10
  hairheightR -= 5
  hairsize += 7
  hairdifference += 2
  eyesize = random(50, 70);
  lefteyex -= 7
  righteyex += 7
  eyeheight -= 3
  mouthheight +=10
  tonguelength += 10
  bodysize += 30
  browstartleft -= 7
  browstartright +=7
  browheight = random(150,200);
  browlength += 7
}

Leave a Reply