rgroves – project02 – Variable Face

sketch

//Rebecca Groves
//Section B
//rgroves@andrew.cmu.edu
//Week 02 Variable Face

//color of fur
var reds = [60, 110, 184, 220]; 
var r = 60;
var b = 60;
var g = 60;
//color of chin
var chinvariables = [1, 2, 3, 4, 5];
var v = 1;
//color of eyes
var eyereds = [210, 194, 253, 147, 152];
var eyer = 210;
var eyeb = 203;
var eyeg = 91;
//size of eyes
var eyeseperation = 230;
var eyewidth = 60;
var eyeheight = 45;
var pupilwidth = 10;
var eyecurve = 30
//size of nose
var nosemultiplier = 1;
var jowelwidth = 90;
var jowelheight = 75;
//right mustache
var rtop = 365;
var rbottom = 400;
var rlength = 70;
//left mustache
var ltop = 340;
var lbottom = 370;
var llength = 50;


function setup() {
    createCanvas(600, 600);
    background(222,226,222);
}

function draw() {
	//headshape
	noStroke();
	fill(r, b, g);
	if (r == 60){
		b = 60;	
		g = 60;
	} else // blue grey
	if (r == 110){
		b = 124;
		g = 138;
	} else // orange
	if (r == 184){
		b = 115;
		g = 55;
	} else 
	if (r == 220){
		b = 220;
		g = 220;
	}
	beginShape();
	vertex(150, 600);
	vertex(150, 90);
	vertex(220, 180);
	vertex(600 - 220, 180);
	vertex(600 - 150, 90);
	vertex(600 - 150, 600);
	endShape();

	//eyes
	ellipseMode(CENTER);
	fill(eyer, eyeb, eyeg);
	if (eyer == 210){ // yellow green
		eyeb = 203;	
		eyeg = 91;
	} else // turquoise
	if (eyer == 194){ 
		eyeb = 248;
		eyeg = 182;
	} else // yellow
	if (eyer == 253){ 
		eyeb = 212;
		eyeg = 37;
	} else // brown
	if (eyer == 147){
		eyeb = 66;
		eyeg = 38;
	} else // blue
	if (eyer == 152){
		eyeb = 186;
		eyeg = 205;
	}
	rectMode(CENTER);
	rect(eyeseperation, 290, eyewidth, eyeheight, 0, eyecurve, 0, eyecurve);
	rect(600- eyeseperation, 290, eyewidth, eyeheight, eyecurve, 0, eyecurve, 0);
	//pupils
	fill(60);
	ellipse(eyeseperation, 290, pupilwidth, eyeheight);
	ellipse(600 - eyeseperation, 290, pupilwidth, eyeheight);
	//eye highlight
	fill(220);
	ellipse(eyeseperation + 10, 290 - (eyeheight * .15), 20, 15);
	ellipse(600 - eyeseperation + 10, 290 - (eyeheight * .15), 20, 15)

    //ears
    noStroke();
    fill(r - 50, b - 70, g - 50);
    triangle(150, 90 + 20, 220 - 20, 180, 150, 180);
    triangle(600 - 150, 90 + 20, 600 - (220 - 20), 180, 600 - 150, 180);

    //chin
    if (v == 4) { //make chin occasionally white
    	fill(230);
    	ellipse(300, 370 + (jowelheight * .4), 55, 55); 
    } else {
    	fill(r - 50, b - 70, g - 50);
    	ellipse(300, 370 + (jowelheight * .4), 55, 55);
    }
    

    //jowels
    if (v == 4) { //make jowels occasionally solid
    	fill(r, b, g);
    	ellipse(300 - 35, 370, jowelwidth, jowelheight);
    	ellipse(300 + 35, 370, jowelwidth, jowelheight);
    } else {
    	fill(230);
    	ellipse(300 - 35, 370, jowelwidth, jowelheight);
    	ellipse(300 + 35, 370, jowelwidth, jowelheight);
    }
    //left mustache
	noStroke();
	fill(r, b, g);
	ellipseMode(CORNERS);
	ellipse(300, ltop, 300 - llength, lbottom);
	//right mustache
	ellipse(300, rtop, 300 + rlength, rbottom);

    //nose
	fill(211, 177, 160);
	rect(300, 325, 50 * nosemultiplier, 15 * nosemultiplier, 5);
	triangle(300 - (20 * nosemultiplier), 320, 300 + (20 * nosemultiplier), 320, 300, 300 + (50 * nosemultiplier));
	strokeWeight(3);
	stroke(156, 102, 81);
	line(300, 300 + (50 * nosemultiplier), 300, 335)
}

function mousePressed(){
	reds = [60, 110, 184, 220];
	r = random(reds);
    eyereds = [210, 194, 253, 147, 152];
    eyer = random(eyereds);
    chinvariables = [1, 2, 3, 4, 5];
    v = random(chinvariables);
    eyeseperation = random(210, 260);
    eyewidth = random(45, 70);
    eyeheight = random(20, 50);
    pupilwidth = random(5, 20);
    eyecurve = random(20, 50);
    nosemultiplier = random(.75, 1.25);
    jowelwidth = random(70, 140);
    jowelheight = random(65, 110);
    rtop = random(370, 370 - (jowelheight * .5));
    ltop = random(370, 370 - (jowelheight * .5));
    rbottom = rtop + random(20, 70);
    while (rbottom > (370 + (jowelheight * .5))){
    	rbottom = rtop + random(20, 70);
    }
    lbottom = ltop + random(20, 70);
    while (lbottom > (370 + (jowelheight * .5))){
    	lbottom = ltop + random(20, 70);
    }
    rlength = (30, jowelwidth - 40);
    llength = (30, jowelwidth - 40);
}

For this project I was inspired by my childhood cats. They were both tuxedo cats, and most people could only tell them apart by the markings around their mouths – one had a little black mustache and one had a white chin. Here are pictures of them:

1/5 of the time it generates a cat with a solid color face and a white chin and 4/5 of the time it generates a cat with a uniquely shaped mustache. The fur color, eye color and shape, and nose size also change.

Leave a Reply