Kai Zhang-Project-02-Variable-Face

kaiz1_Project02

//Kai Zhang
//Section B
//kaiz1@andrew.cmu.edu
//Project-02

//eyes
var eyeLW = 40;
var eyeLH = 20;
var eyeRW = 40;
var eyeRH = 20;
var eyeR = 10; //eye rotation
var eyeX = -50;

//eye background
var eyeBW = 70;
var eyeBH = 60;

//face
var faceW = 240;
var faceH = 220;

//knife
var knifeX = 0;
var knifeY = 0;
var knifeR = 0;

//overall Rotation
var rotateA = 0;


function setup() {
    createCanvas(480, 640);
    background(80);
    angleMode(DEGREES);
}


function draw() {
	background(80);
	strokeWeight(5);
	fill(255, 0, 0);
	translate(240, 320);

	rotate(rotateA);

	//knife
	push();
		fill(255);
		translate(knifeX, knifeY);
		rotate(knifeR);
		//knife edge
		beginShape();
			vertex(0, 0);
			vertex(0, 45);
			vertex(12, 45);
			vertex(12, 13);
		endShape(CLOSE);
		//knife handle
		fill(0);
		beginShape();
			vertex(-5, 45);
			vertex(17,45);
			vertex(17, 47);
			vertex(11, 47);
			vertex(11, 65);
			vertex(1, 65);
			vertex(1, 47);
			vertex(-5, 47);
		endShape(CLOSE);

	pop();

	//face
	ellipse(0, 0, faceW, faceH);
	line(0, -faceH/2, 0, faceH/2);

	//eye background
	push();
		fill(0);
		ellipse(eyeX - 3, -20, eyeBW, eyeBH);
		ellipse(-eyeX + 3, -20, eyeBW, eyeBH);
	pop();

	//eyes
	push();
		fill(255);
		translate(eyeX, -20);
		rotate(eyeR);
		ellipse(0, 0, eyeLW, eyeLH);
	pop();
	push();
		fill(255)
		translate(-eyeX, -20);
		rotate(-eyeR);
		ellipse(0, 0, eyeRW, eyeRH);
	pop();
}



function mousePressed() {
	eyeX = (-faceW/5);
	eyeLW = random(37, 45);
	eyeLH = random(10, 40);
	eyeRW = random(37, 45);
	eyeRH = random(10, 40);
	eyeR = random(-13, 13);
	eyeBH = random(55, 80);
	eyeBW = random(65, 80);

	faceW = random(210, 280);
	faceH = random(150, 280);

	knifeX = random(-180, 180);
	knifeY = random(-280, 280);
	knifeR = random(-180, 180);

	rotateA = random(-30, 30);
}

Deadpool is one of my favorite Marvel characters. He made possible two amazing featured films and hundreds of comic stories. The reason I chose him as the protagonist of my project 2 is he makes perfect leap from and to 3D and 2D world. The kartoon version of him comes with countless different proportions of facial features and expressions (especially the eyes), easily fits into the gridlines of the project. In the code of this project, I’ve set up to 14 different variables, composing the different eye shapes, eye shade shapes, face shapes, orientations, etc. I’ve also added an “eastern egg”, a small knife that floats across the canvas that occasionally hits the little deadpool’s haed. Luckily, because of his super power, he would be easily recovered from that. 🙂

Leave a Reply