rnayyar Project 02 variable faces

sketch

// Rhea Nayyar
// rnayyar@andrew.cmu.edu
// Section C
// Variable Face (02-C)



// W -> Width
// H -> Height
// Vert -> Vertical/Height
// Acr -> Across/Width

var headVert = 200;
var headAcr = 165;
var noseW = 28;
var noseH = 55;
var eyesW = 40;
var eyesH = 25;
var toplipW = 25;
var bottomlipW = 40;
var toplipH = 15;
var bottomlipH = 20;
var pupil = 6;
var iris = 20;
var eyebrowH = 8;
var eyebrowW = 45;


function setup() {
    createCanvas(500, 500);


}
//original face
function draw() {
  background(0, 178, 191);
  noStroke(0);
  fill( 116, 89, 71); //face color
  ellipse( 225, 250, headAcr, headVert); //head
  fill(145, 110, 89);
  rect(210,230,noseW,noseH); //nose
  fill(225);
  ellipse(180,220,eyesW,eyesH); //eye
  ellipse(265,220,eyesW,eyesH); //eye
  fill(74,61,92);
  ellipse(182,220,iris,iris);
  ellipse(263,220,iris,iris);
  fill(0);
  ellipse(182,220,pupil,pupil);
  ellipse(263,220,pupil,pupil);
  rect(160,190,eyebrowW,eyebrowH); //eyebrow
  rect(245,190,eyebrowW,eyebrowH); //eyebrow
  fill(182,74,117);
  ellipse(225,316,bottomlipW,bottomlipH); //bottom lip
  fill(121, 74, 94);
  ellipse(215,310,toplipW,toplipH); //top lip
  ellipse(235,310,toplipW,toplipH); //top lip

}
//randomized faces
function mousePressed() {
  headAcr = random(120, 230);
  headVert = random(180,265);
  noseH = random(45,67);
  noseW = random(25,35);
  eyesW = random(25,52);
  pupil = random(6,20);
  eyebrowH = random(5,20);
  toplipW = random(20,40);
  toplipH = random(12,20);
  bottomlipH = random(15,23);
  bottomlipW = random(33,45);
  iris = random(20,26);
}

A lot of experimenting with features had to go into this. Despite having previous knowledge from the self-portrait assignment on how to make a simple face with p5, I had to tweak things a lot for the ‘randomize’ process. Nevertheless, I’m starting to get the hang of correlating coordinates on the text editor to where the object I’m making would appear when I run the code. The faces look a little foolish but I like them 🙂

Leave a Reply