Dani Delgado Variable Face

sketch

/*Dani Delgado
ddelgad1@andrew.cmu.edu
Section E
Project-02
*/

// eye variables
var eyeType = 1;
//face variables 
var faceWidth = 160;
var faceHeight = 220;
var faceColorR = 240;
var faceColorG = 230;
var faceColorB = 179;
//hair variables
var hairType = 1;
var hairColorR = 95;
var hairColorG = 23;
var hairColorB = 23;
//facial feature variables 
var noseN = 1;
var mouthNum = 1;
var detailNum = 1;


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

}

function draw() {
    background(202, 255, 221);

    	//draw the hair
	var hair = int(hairType);
	if (hair == 1){
		//long hair
		noStroke();
		fill(hairColorR, hairColorG, hairColorB);
		rect(width/2, height/2+25, 230, 350, 95, 95, 10, 10);

	} if (hair == 2){
		//medium hair
		noStroke();
		fill(hairColorR, hairColorG, hairColorB);
		rect(width/2, height/2-20, 225, 250, 95, 95, 10, 10);

	} if (hair == 3){
		//bun
		noStroke();
		fill(hairColorR, hairColorG, hairColorB);
		ellipse(width/2, height/2-40, 225, 230);
		ellipse(width/2, height/3-70, 100, 100);
	}

    //draw the general face
	noStroke();
	fill(faceColorR, 220, faceColorB);
	rectMode(CENTER);
	rect (width/2, height/2, faceWidth, faceHeight, 90);

	//draw the eyes
	var eye = int(eyeType);
	if (eye == 1){
		fill(70, 40, 38);
		ellipse(width/2+40, height/2-20, 29, 29);
		ellipse(width/2-40, height/2-20, 29, 29);
		//pupils
		noStroke();
		fill(250, 250, 250)
		ellipse(width/2+36, height/2-24, 10, 10);
		ellipse(width/2-44, height/2-24, 10, 10);

	} if (eye == 2){
		fill(70, 40, 38);
		arc(width/2+40, height/2-15, 40, 25, 3.14, 0, PI, OPEN);
		arc(width/2-40, height/2-15, 40, 25, 3.14, 0, PI, OPEN);
	}

	//draw the eyebrows
	noFill();
	stroke(90, 60, 50);
	strokeWeight(6);
	arc(width/2+40, height/2-50, 40, 12, 3.24, 6, PI, OPEN);
	arc(width/2-40, height/2-50, 40, 12, 3.24, 6, PI, OPEN);

	//draw the bangs
	noStroke();
	fill(hairColorR, hairColorG, hairColorB);
	rect(width/2+50, height/3-23, 50, 50, 10, 90, 0, 0);
	rect(width/2.2, height/3-23, 100, 50, 90, 10, 0, 0);

	//draw the nose
	var nose = int(noseN);
	if (nose == 1){
		noStroke();
		fill(255, 160, 140);
		rect(width/2, height/1.85, 15, 40, 90, 90, 5, 5);

	} else if (nose == 2){
		noStroke();
		fill(255, 160, 140);
		ellipse(width/2, height/1.75, 25, 15);

	} else if (nose == 3){
		noStroke();
		fill(255, 160, 140);
		triangle(width/2, height/2+20, width/2-15, height/2+35, width/2+15, height/2+35);
	}

	//draw the mouth
	var mouth = int(mouthNum);
	if (mouth == 1){
		noStroke();
		fill(70, 40, 38);
		arc(width/2, height/1.6, 55, 50, 6.28, 3.14, PI, OPEN);
		fill(249,249,249);
		rect(width/2, height/1.6, 55, 8, 0, 0, 35, 35);

	} else if (mouth == 2){
		noFill();
		strokeWeight(8);
		stroke(60, 30, 30);
		arc(width/2, height/1.6, 50, 40, 6.28, 3.14, PI, OPEN);
	}
	
	//draw the details
	var detail = int(detailNum);
	if (detail == 1){
		//freckles
		noStroke();
		fill(163, 112, 10);
		ellipse(width/2.2, height/1.8, 7, 7);
		ellipse(width/2.34, height/1.8, 7, 7);
		ellipse(width/2.48, height/1.8, 7, 7);
		ellipse(width/2.27, height/1.9, 7, 7);
		ellipse(width/2.41, height/1.9, 7, 7);

		ellipse(width/1.84, height/1.8, 7, 7);
		ellipse(width/1.76, height/1.8, 7, 7);
		ellipse(width/1.68, height/1.8, 7, 7);
		ellipse(width/1.80, height/1.9, 7, 7);
		ellipse(width/1.72, height/1.9, 7, 7);

	} if (detail == 2){
		//blush
		noStroke();
		fill(255, 153, 153);
		ellipse(width/2.5, height/2+10, 30, 15);
		ellipse(width/1.67, height/2+10, 30, 15);

	} if (detail == 3){
		//peircings 
		noStroke();
		fill(100,100,100);
		ellipse(width/2+50, height/2-47, 7, 7);
		ellipse(width/2+54, height/2-62, 7, 7);
	}
}

function mousePressed() {
    //hair randomizing
    hairType = random(1, 4);
    hair = random(1,3);
    hairColorR = random(245, 255);
    hairColorG = random(153, 221);
    hairColorB = random(151, 153);

    // face randomizing
    faceWidth = random(155, 200);
    faceHeight = random(220, 250);
    eyeSize = random(10, 30);

    //facecolor randomizing
    faceColorR = random(235, 255);
    faceColorG = random(190, 240);
    faceColorB = random(180, 210);

    //mouth randomizing
    mouthNum = random(1, 3);
    mouth = random(1, 2);

    //nose randomizing
    noseN = random(1, 4);
    nose = random(1, 3);

    //eye randoming
    eyeType = random(1,3);
    eye = random(1,2);

    //detail randoming
    detailNum = random(1,4);
    detail = random(1,3);

}

This project was a great learning experience for me; at the beginning I struggled to wrap my mind around how to apply variables and what to name them. But, as I continued to push through, I found the assignment to become more and more enjoyable as the concepts we learned solidified in my head.
In my drawings, I wanted to keep all of the features within a specific, warm-toned color palette so that the background had a nice contrast. I also wanted to make all of the changing facial features fairly distinct and fun to look at.

Leave a Reply