Project-02-Variable-Face- sehenry

While I was making this project, I became very interested in the way that the random function works. A simple but complex concept that I will try to use in a majority of my projects. I didn’t sketch any drafts for this one like the Family Composition. I also tried to randomize a triangle nose within my sketch but it became very difficult and I was forced to switch to an ellipse nose.

sketch

//Seth Henry

//Section B (Tuesdays 10:30)

//sehenry@andrew.cmu.edu

//Assignment-Variable Faces

var eyeSize = 50
var pupilSize = 20
var headHeight = 200
var headWidth = 170
var noseHeight = 30
var noseWidth = 20
var mouthHeight = 30
var mouthWidth = 100
var browHeight = 10
var browWidth = 40
var earHeight = 50
var earWidth = 40




function setup() {
    createCanvas(640, 480);
    
    text("p5.js vers 0.5.2 test.", 10, 15);
}

function draw() {
	background(102, 102, 202);
	noStroke(0);
	fill(255);

	//hair: Becomes randomized when headwidth is randomized
	rectMode(CENTER);
	fill(0);
	rect(width / 2, 150, headWidth, 150);

	//nose: Center of Face (Triangle Nose Test. THIS WAS ONLY A TEST)
	var leftpointW = width / 2 - 10
	var leftpointH = height / 2 + 40
	var rightpointW = width / 2 + 10
	var rightpointH = height / 2 + 40
	fill(0);
	triangle(width / 2, height / 2, leftpointW, leftpointH, rightpointW, rightpointH);


	//ear
	var leftEarW = width / 2 - headWidth / 2
	var rightEarW = width / 2 + headWidth / 2
	fill(163, 121, 7);
	ellipse(leftEarW, height / 2, earWidth, earHeight);
	ellipse(rightEarW, height / 2, earWidth, earHeight);


	//head: Middle of Canvas
	fill(163, 121, 7);
	ellipse(width / 2, height / 2, headWidth, headHeight);

	//eyes 
	fill(255);
	var leftEye = width / 2 - headWidth/3.25
	var rightEye = width / 2 + headWidth/3.25
	ellipse(leftEye, height / 2, eyeSize, eyeSize);
	ellipse(rightEye, height / 2, eyeSize, eyeSize);

	//pupils: center of eyes
	fill(random(10, 200), 20, 120);
	ellipse(leftEye, height / 2, pupilSize, pupilSize);
	ellipse(rightEye, height / 2, pupilSize, pupilSize);

	//nose: Center 
	fill(0);
	ellipse(width / 2, height / 2 + 20, noseWidth, noseHeight);
	
	//mouth
	fill(235, 70, 177);
	ellipse(width / 2, height / 2 + 70, mouthWidth, mouthHeight);

	//brow: centered over eyes
	rectMode(CENTER);
	fill(0);
	rect(leftEye, height / 2 - 50, browWidth, browHeight);
	rect(rightEye, height / 2 - 50, browWidth, browHeight);


}

	function mousePressed(){ //11 Random Aspects
		headWidth = random(150, 200);
		headHeight = random(180, 220);
		mouthHeight = random(20, 50);
		mouthWidth = random(40, 150);
		eyeSize = random(30, 70);
		pupilSize = random(10, 40);
		browWidth = random(20, 70);
		earHeight = random(30, 80);
		earWidth = random(20, 60);
		rightpointW = random(height / 2 + 30, height / 2 + 50); //A PART OF THE TRIANGLE NOSE TEST
		noseheight = random(10, 200);
		noseWidth = random(10, 40);



	}


	




Leave a Reply