/* Charmaine Qiu
Section E
charmaiq@andrew.cmu.edu
Project-02-Variable_Face */
var faceWidth = 200;
var faceHeight = 200;
var eyeSize = 20;
var eyebrow1 = 300;
var eyebrow2 = 300;
var mouthLeft = 230;
var mouthRight = 260;
var star = 5
var star2 = 7
function setup() {
createCanvas(480, 640);
}
function draw() {
background(28, 42, 87);
//stars
fill(255);
ellipse(100, 100, star, star);
ellipse(400, 400, star, star);
ellipse(300, 200, star2, star2);
ellipse(60, 500, star2, star2);
ellipse(120, 450, 6, 6);
ellipse(200, 550, 3, 3);
ellipse(350, 160, 3, 3);
ellipse(80, 260, 3, 3);
ellipse(420, 70, 5, 5);
ellipse(300, 40, 4, 4);
ellipse(420, 580, star, star);
//body
noStroke();
fill(141, 230, 73);
beginShape();
vertex(230, 370);
vertex(225, 450);
vertex(235, 440);
vertex(250, 500);
vertex(255, 490);
vertex(320, 480);
vertex(330, 485);
vertex(320, 430);
vertex(335, 435);
vertex(300, 370);
endShape(CLOSE);
//head
ellipse(width / 2, height / 2, faceWidth, faceHeight);
triangle(220, 230, 230, 200, 240, 230);
//eyes
noStroke();
fill(0);
var eyeLX = width / 2 - faceWidth * 0.25;
var eyeRX = width / 2 + faceWidth * 0.25;
ellipse(eyeLX, height / 2, eyeSize, eyeSize);
ellipse(eyeRX, height / 2, eyeSize, eyeSize);
fill(222, 45, 13);
ellipse(eyeLX, height / 2, eyeSize / 2, eyeSize / 2);
ellipse(eyeRX, height / 2, eyeSize / 2, eyeSize / 2);
//eyebrows
triangle(150, 295, 160, 290, 190, eyebrow1);
triangle(290, eyebrow1, 320, 290, 330, 295);
//nose
ellipse(width / 2, height/ 2, 7, 10);
//mouth
triangle(mouthLeft, 400, 240, 390, mouthRight, 400);
// strokeWeight()
// line(200, 320, width / 2 - faceWidth * 0.25, 320);
// line(width / 2 - faceWidth * 0.25, 320, 260, 320);
}
function mousePressed() {
// when the user clicks, these variables are reassigned
// to random values within specified ranges. For example,
// 'faceWidth' gets a random value between 75 and 150.
faceWidth = random(150, 300);
eyeSize = random(20, 50);
eyebrow1 = random(290, 302);
eyebrow2 = random(290, 302);
mouthLeft = random(220,240);
mouthRight = random(240,260);
star = random(2, 15);
star2 = random(2, 15);
}
MousePressed was really fun to work with!