Nina Yoo- Project 02- Variable- Face Section E

sketch

/*Nina Yoo
Section E
nyoo@andrew.cmu.edu
Project-02
*/ 

var eyeSizeW = 44;
var eyeSizeH = 27;
var colorEye = 0;
var faceWidth = 192;
var faceHeight = 192;
var eyeBruiseWidth = 76;
var eyeBruiseHeight = 63;
var earH = 54;
var earW = 23;


function setup() {
    createCanvas(480, 650);
    noStroke();
    
    
}

function draw() {
	background(167,217,201);

	//head
	fill(229,222,167);
	ellipse(240, 350, faceWidth, faceHeight);
	fill(229,222,167);
	ellipse(143, 350, earW, earH);
	fill(229,222,167);
	ellipse(336,350, earW, earH);

	//hair
	fill(0);
	triangle(215,228, 211, 257,239,261);
	triangle(239,261,222,221,278,163);

	//left eye
	fill(255);
	arc(195,346, 44, 44, 0, PI);
	fill(colorEye);
	arc(195,346,24,15,0,PI);


	//bruise
	fill(175,127,183);
	ellipse(286,350, eyeBruiseWidth,eyeBruiseHeight);

	//right eye
	fill(255);
	ellipse(286,351,eyeSizeW,eyeSizeH);
	fill(colorEye);
	ellipse(286,350,24,15);

}

function mousePressed(){
	faceWidth = random(192, 240);
	faceHeight = random(192, 250);
	colorEye = random (0, 200);
	eyeSizeW = random (44, 85);
	eyeSizeH = random (27, 50);
	earW = random (23, 76);
	earH = random (54, 100);
	eyeBruiseWidth = random (76, 100);
	eyeBruiseHeight = random (63, 90);


}



	





















The assignment required a lot of going back and forth with the variables because there were values I wanted to change, but having the variables also helped in the case that I didn’t have to go through the whole code and change every number. Another important factor I realized was that I needed to close the function draw in order for the function mousePressed to work. The mousePressed function was surprisingly easier than expected and having the variables also as a little cheat sheet for measurements was helpful.

Leave a Reply