Mihika Bansal-Project 02-Variable Face

sketch

/*
Mihika Bansal 
Section E 
mbansal@andrew.cmu.edu
Project-01
*/

var faceWidth=120; 
var faceHeight=150; 
var faceColorR=234; 
var faceColorG=213; 
var faceColorB=200; 
var hairLength=200; 
var neckLength=100; 
var neckWidth= 75; 
var noseY= 220;
var eyeWidth=15; 
var mouthX=20; 
var mouthY=10; 
var earWidth= 15; 
var earHeight= 17; 
var colorR= 230; 
var colorG=211; 
var colorB=152; 

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

function draw() {
    background(231, 231, 253); 
  
    //neck
    fill(faceColorR, faceColorG, faceColorB); 
    rectMode(CENTER); 
    rect(width/2, (height / 2 - 50)+(0.5*faceHeight)+0.2*neckLength, neckWidth, neckLength);
    
    //hair 
    fill("black");
    arc(width/2+0.68*(0.5*faceWidth), height/2-20, 100, hairLength, 3*PI/2, PI/2);
    arc(width/2-0.68*(0.5*faceWidth), height/2-20, 100, hairLength, PI/2, 3*PI/2);
    
     //face +ears 
    fill(faceColorR, faceColorG, faceColorB);
    ellipse(width / 2, height / 2 - 50, faceWidth,  faceHeight);
    arc(width/2+(0.5*faceWidth), height/2-0.20*faceHeight, earWidth, earHeight, 3*PI/2, PI/2);
    arc(width/2-(0.5*faceWidth), height/2-0.20*faceHeight, earWidth, earHeight, PI/2, 3*PI/2);
    //hair 
    fill("black");
    arc(width/2, height/2-65, faceWidth*1.3, faceHeight, PI-0.40, QUARTER_PI-0.45 , PIE);
    //nose 
    fill(faceColorR, faceColorG, faceColorB);
    triangle(width/2, noseY, width/2-5, noseY*0.97, width/2+5, noseY*0.97);

    //eyes 
    fill("white"); 
    ellipse(width/2-20, height/2-40, eyeWidth, eyeWidth*0.65);
    ellipse(width/2+20, height/2-40, eyeWidth, eyeWidth*0.65);
    fill("black"); 
    ellipse(width/2-18, height/2-42, eyeWidth*0.45, eyeWidth*0.45);
    ellipse(width/2+22, height/2-42, eyeWidth*0.45, eyeWidth*0.45);

    //mouth
    fill(123, 30, 30); 
    arc(width/2, height/2+faceHeight*0.04, mouthX, mouthY, 0, PI,OPEN);

    //earrings 
    fill(colorR, colorG, colorB); 
    ellipse(width/2+(0.52*faceWidth), height/2-0.18*faceHeight, 5, 5);
    ellipse(width/2-(0.52*faceWidth), height/2-0.18*faceHeight, 5, 5);
    fill(colorR*1.2, colorB*1.2, colorG*1.2);
    rect(width/2+(0.52*faceWidth), height/2+0.04*faceHeight, 5, hairLength*0.2);
    rect(width/2-(0.52*faceWidth), height/2+0.04*faceHeight, 5, hairLength*0.2);
     
}

function mousePressed() {
    faceWidth = random(100, 150);
    faceHeight = random(140, 180);
    eyeWidth = random(10, 25);
    faceColorR= random(150, 250);
    faceColorG= random(102, 245);
    faceColorB= random(55, 236);
    hairLength= random(100, 250);
    neckLength= random(85, 150); 
    neckWidth= random(50, 120);
    noseY=random(215, 230);
    mouthY=random(5,20); 
    mouthX=random(15, 30);
    earWidth=random(10, 25);
    earHeight=random(13, 30);
    colorR=random(0,255); 
    colorG=random(0,255);
    colorB=random(0,255);

}

For this project, I worked with the same style of my self portrait to create faces that changed multiple facets. I changed the eye size, skin color, face width and height, neck size and length, hair length, earring size and color, etc, to create unique faces with a distinct style. It was interesting to see faces that were made that I typically would not have made, but still worked visually.

Leave a Reply