karinac-Project-02-Variable-Face

project-02

//Karina Chiu
//karinac@andrew.cmu.edu
//Section C
//Project-02

var faceWidth = 360
var faceHeight = 320
var leftX = 200   //left-eye-pupil
var leftY = 290   //left-eye-pupil
var rightX = 300  //right-eye-pupil
var rightY = 290  //right-eye-pupil
var beakX = 220   //position of beak
var beakY = 360	  //position of beak
var comb = 110    //height of comb

function setup() {
	createCanvas(500,500);
}

function draw() {
	background(192,183,227);

	//head
	stroke(0);
	strokeWeight(5);
	fill(245,202,52);
	ellipse(250,300,faceWidth,faceHeight);

	//left-outer-eye
	strokeWeight(3);
	fill(250);
	ellipse(190,290,110,110);

	//right-outer-eye
	fill(250);
	ellipse(310,285,140,140);

	//left-pupil
	fill(0);
	ellipse(leftX,leftY,10,10);

	//right-pupil
	fill(0);
	ellipse(rightX,rightY,10,10);

	//beak
	fill(235,143,31);
	triangle(beakX,beakY,250,440,500-beakX,beakY);

	//chicken-comb
	fill(250,0,0);
	triangle(180,comb,240,220,300,comb);
}


function mousePressed() {
	
	//when mouse is clicked, random values are
	//assigned to the variables

	faceWidth = random(300,450);
	faceHeight = random(290,370);
	leftX = random(150,220);
	leftY = random(255,330);
	rightX = random(270,350);
	rightY = random(245,340);
	beakX = random(200,220);
	beakY = random(360,370);
	comb = random(80,110);

}

In my childhood, I loved drawing cartoon animals with exaggerated eyeballs, so I decided to try drawing them in this project. It took me a few times to write the ‘random’ code lines, but I eventually grasped the concept.

Leave a Reply