Sarah Yae – Project 02 – Variable Face

sketch

//Sarah Yae
//Section B
//smyae@andrew.cmu.edu
//Project-02

var faceX = 240
var faceY = 320
var facecolor = 255

var earX = 180
var earY = 200
var earlength = 60
var earwidth = 60

var eyeX = 200
var eyeY = 300
var eyecolor = 120

var noseX = 240
var noseY = 340
var nosewidth = 10

var mouth = 80
var mouthx1 = 200
var mouthx2 = 280

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

function draw() {
	background (255,229,204);

//draws the face in first frame
	noStroke();
	fill(facecolor);
	ellipse (faceX, faceY,230,230);

//draws the left ear in first frame
	noStroke();
	fill(facecolor);
	ellipse (earX, earY, earwidth, earlength);

//draws the right ear in first frame
    noStroke();
    fill(facecolor);
    ellipse (earX + 120, earY, earwidth, earlength);

//draws the left eye in first frame
    noStroke();
    fill (eyecolor);
    ellipse (eyeX, eyeY, 40, 40);

//draws the right eye in first frame
    noStroke();
    fill(eyecolor);
    ellipse (eyeX + 80, eyeY,40,40);

//draws the nose in first frame 
    noStroke();
    fill (204,204,255);
    ellipse (noseX, noseY, nosewidth, 30);

//draws the mouth in first frame 
    noStroke();
    fill (255,204,204);
    triangle (mouthx1,370,mouthx2,370,240,400);

}

function mousePressed() {

//face changes color
    faceX = 240;
    faceY = 320;
    facecolor = random(140,255);

//ears changes size (lengths and widths)
    earX = 180;
    earY = 200;
    earlength = random(50,130);
    earwidth = random(50,100);

//eyes changes color 
    eyeX = 200;
    eyeY = 300;
    eyecolor = random (10,120);

//nose changes size (width)
    noseX = 240;
    noseY = 340;
    nosewidth = random(10,40);

//mouth changes size (width)
    mouth = 80;
    mouthx1 = random (180,220);
    mouthx2 = random (260,300);

}

I wanted to create a cute, fantasy creature. By pressing the mouse, you can see my animal switch up from a mouse, a bunny, a bear, etc… you name it!

Leave a Reply