Project 02-Variable-Face

sketchDownload
//Sofia Rolla
//Section D

var eyeSize = 20;
var pupilSize= 5;
var faceWidth = 150;
var faceHeight = 200;
var noseWidth = 20;
var noseHeight = 30;
var mouthSize = 40;

var faceR = 199
var faceG = 177
var faceB = 140

var pupilR = 112
var pupilG = 166
var pupilB = 233
  
var noseR = 200
var noseG = 190
var noseB = 170

var mouthR = 0
var mouthG = 0
var mouthB = 0





function setup() {
    createCanvas(640, 480);
}
 
function draw() {
    background(170,10,90);
    //head
    fill(faceR, faceG, faceB)
    ellipse(width / 2, height / 2, faceWidth,  faceHeight);
    //eyes
    fill(255)
    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);
    //pupils
    fill(pupilR, pupilG, pupilB)
    ellipse(eyeLX, height / 2, pupilSize, pupilSize);
    ellipse(eyeRX, height / 2, pupilSize, pupilSize);
    //nose
    var noseY = height / 2 + faceHeight* 0.15;
    fill(noseR, noseG, noseB)
    ellipse(width/2, noseY, noseWidth, noseHeight); 
    //mouth
    fill(mouthR, mouthG, mouthB)
    ellipse(width / 2, height / 2 + .4 * faceHeight, mouthSize, faceHeight/10)
    //hair
    arc(width / 2, height / 2-35, faceWidth+10,  faceHeight-10, PI,2*PI, PI);
   
 
}
 
function mousePressed() {
    faceWidth = random(75, 150);
    faceHeight = random(100, 200);
    eyeSize = random(20, 40);
    pupilSize = random(5,15);
    noseWidth = random(5,20)
    noseHeight= random (10,30);
    mouthX = random (20, 50);
    faceR = random (170,230)
    faceG = random (50,200)
    faceB = random (50,200)
    mouthR = random (50,200)
    mouthB = random (50,200)
    mouthG = random (50,200)
    pupilR = random (50,200)
    pupilG = random (50,200)
    pupilB = random (50,200)
    noseR = random (50,200)
    noseG = random (50,200)
    noseB = random (50,200)
    
}

This was a difficult process for me. I struggled with finding the right variables and with setting proper variables for positions of certain facial features. I hope that this process will get easier as I keep learning.

Leave a Reply