Project 2 – Variable Faces

alienface
// Yoo Jin Kim
// 15104 - section D
// yoojink1@andrew.cmu.edu
// Project-02

var faceWidth = 300;
var faceHeight = 160;
var eyeSize = 65; 
var eyeWidth = 70;
var eyeHeight = 100;
var eyeTwinkleX = 23;
var eyeTwinkleY = 18;
var tongueSize = 36;
var B = 100;
var crownTipY = 140;


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

function draw() {
	//background color
	background(color(B));

	//alien head shape
	strokeWeight(0);
	fill(171,190,188);
	beginShape();
	curveVertex(width/2 - faceWidth/2, height/2);
	curveVertex(width/2 - faceWidth/2, height/2);
	curveVertex(width/4, height/2 - (faceHeight - 40));
	curveVertex(width/2, height/2 - faceHeight); 
	curveVertex(width * (3/4), height/2 - (faceHeight - 40));
	curveVertex(width/2 + faceWidth/2, height/2);
	curveVertex(width/2, 441);
	endShape(CLOSE);

	strokeWeight(0);
	beginShape();
	curveVertex(width/2 + faceWidth/2, height/2);
	curveVertex(width/2 + faceWidth/2, height/2);
	curveVertex((width/4) * 3, height/2 - (faceHeight - 40));
	curveVertex(width/2, height/2 - faceHeight); 
	curveVertex(width/4, height/2 - (faceHeight - 40));
	curveVertex(width/2 - faceWidth/2, height/2);
	curveVertex(width/2, 441);
	endShape(CLOSE);

	//crown
	strokeWeight(0);
	fill(214,178,69);
	triangle(376,crownTipY,350,200,318,184);
	triangle(343,185,343,crownTipY - 20,305,181);
	triangle(307,crownTipY - 25,295,178,325,186);

	strokeWeight(0);
	fill(171,190,188);
	quad(353,197,295,171,276,190,342,230);


	//mouth - stagnant
	fill(0);
	stroke(0);
	ellipse(240,395,43,10);

	//tongue
	fill(0,135,53);
	quad(251,396,228,396,230,401,248,404);
	beginShape();
	curveVertex(230,401);
	curveVertex(248,401);
	curveVertex(width/1.98, height/2 + 2.6 * tongueSize);
	curveVertex(width/2, height/2 + 2.6 * tongueSize);
	endShape(CLOSE);

	//right eye
	translate(width/1, height/90);
	rotate(PI/3.0);
	fill(37,44,46);
	ellipse(186,295,eyeWidth,eyeHeight);

	//left eye
	translate(width/4.8,height/2.95);
	rotate(PI/3.0);
	fill(37,44,46);
	ellipse(186,95,eyeWidth,eyeHeight);

	//left eye twinkle
	fill(255);
	ellipse(191,127,eyeTwinkleX,eyeTwinkleY);

	//right eye twinkle
	fill(255);
	ellipse(119,height/14 - 57.5,eyeTwinkleX,eyeTwinkleY);
}

function mousePressed() {
	//random assignment of drawing with mouse clicks
	clear(); //reshaping of head instead of adding onto the original shape
	background(0);
	faceWidth = random(200,350);
	faceHeight = random(160,200);
	eyeWidth = random(50,100);
	eyeHeight = random(100,120);
	tongueSize = random(34,42);
	B = random(0,170);
	crownTipY = random(70,160);
	eyeTwinkleX = random(15,23);
	eyeTwinkleY = random(10,18);
}

I was inspired by the alien emoji to create these variable faces. I love aliens 🙂

Leave a Reply