jooheek-Project02-Variable-Face

sketch

//Joo Hee Kim
//Section E
//jooheek@andrew.cmu.edu
//Project-02

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

var faceSize = 200;
var cheekSize = 230;
var earsSize = 50;
var eyeHeight = 50;
var eyeWidth = 30;
var hippoR = 149;
var hippoG = 186;
var hippoB = 198;
var backgroundR = 0;
var backgroundG = 77;
var backgroundB = 104;

function draw() {
	background(backgroundR, backgroundG, backgroundB);

	noStroke();
	//hippo ears
	var earsRX = width/2 - faceSize*0.25;
	var earsLX = width/2 + faceSize*0.25;
	var earsY = height/2 - faceSize*0.25;

	fill(hippoR, hippoG, hippoB);
	ellipse(earsRX, earsY, earsSize, earsSize);//outer ear right

	fill(hippoR, hippoG, hippoB);
	ellipse(earsLX, earsY, earsSize, earsSize);//outer ear left

	fill(hippoR-20, hippoG-20, hippoB-20);
	ellipse(earsRX, earsY, earsSize*0.8, earsSize*0.8);//inner ear right

	fill(hippoR-20, hippoG-20, hippoB-20);
	ellipse(earsLX, earsY, earsSize*0.8, earsSize*0.8);//inner ear left


	//hippo face
	fill(hippoR, hippoG, hippoB);
	ellipse(width/2, height/2, faceSize, faceSize*0.75);

	//hippo Eye
	var eyeRX = width/2 + faceSize*0.25;
	var eyeLX = width/2 - faceSize*0.25;
	
	fill(255, 255, 255);
	ellipse(eyeLX, height/2, eyeWidth, eyeHeight);//left eye white

	fill(255, 255, 255);
	ellipse(eyeRX, height/2, eyeWidth, eyeHeight);//right eye white

	fill(0, 0, 0);
	ellipse(eyeLX, height/2, eyeWidth/2, eyeHeight/2);//left eye black

	fill(0, 0, 0);
	ellipse(eyeRX, height/2, eyeWidth/2, eyeHeight/2);//right eye black
	
	//hippo cheek
	fill(hippoR+20, hippoG+20, hippoB+20);
	ellipse(width/2, 325, cheekSize, cheekSize*0.75);

	//hippo nose
	var noseRX = width/2 - cheekSize*0.25;
	var noseLX = width/2 + cheekSize*0.25;
	var noseY = height/2 + cheekSize*0.25;
	
	fill(hippoR+40, hippoG+40, hippoB+40);
	ellipse(noseRX, noseY, earsSize, earsSize);//hippo noseright light

	fill(hippoR+40, hippoG+40, hippoB+40);
	ellipse(noseLX, noseY, earsSize, earsSize);//hippo noseleft light

	fill(hippoR-10, hippoG-10, hippoB-10);
	ellipse(noseRX, noseY, earsSize*0.6, earsSize*0.6);//hippo noseright dark

	fill(hippoR-10, hippoG-10, hippoB-10);
	ellipse(noseLX, noseY, earsSize*0.6, earsSize*0.6);//hippo noseleft dark

}

function mousePressed() {
	faceSize = random(70, 270);
	cheekSize = random(100, 300);
	earsSize = random(50, 100);
	eyeHeight = random(50, 150);
	eyeWidth = random(30, 130);
	hippoR = random(0, 255);
	hippoG = random(0, 255);
	hippoB = random(0, 255);
	backgroundR = random(0, 255);
	backgroundG = random(0, 255);
	backgroundB = random(0, 255);
	clear();

}

For this project, I wanted to do something simple yet fun to do, which is why I chose to do an animal, specifically a hippo. I think this assignment really let me understand how and why variables are used.

Leave a Reply