/* Alexandra Kaplan
Section C
aekaplan@andrew.cmu.edu
Project-02*/
var headW = 250;
var headH = 300;
var eyeSizeW = 40;
var eyeSizeH = 60;
var eyeY = headH/1.3;
var pupilSize = eyeSizeW - 10;
var pupilY = eyeY;
var pupilR =0;
var pupilG =0;
var pupilB =0;
var noseW = 20;
var noseH = 25;
var mouthH = 1;
var mouthW = 1;
var hatH = headH/2.5;
var hatW = 320;
var hatR = 100
var hatG = 50
var hatB = 60
function setup() {
createCanvas(640, 480);
}
function draw() {
background(200, 200, 230);
strokeWeight(0);
//draw head
fill(220, 190, 160);
ellipse(width/2, height/2, headW, headH);
//draw eyes
fill(255);
var eyeXL = width/2 - headW/4;
var eyeXR = width/2 + headW/4;
ellipse(eyeXL, eyeY, eyeSizeW, eyeSizeH);
ellipse(eyeXR, eyeY, eyeSizeW, eyeSizeH);
//draw pupils
fill(pupilR, pupilG, pupilB);
ellipse(eyeXL, pupilY, pupilSize, pupilSize);
ellipse(eyeXR, pupilY, pupilSize, pupilSize);
//draw nose
fill(200, 170, 140);
ellipse(eyeXL/2 + eyeXR/2 , height/2 + headH/6 , noseW, noseH);
//draw mouth
fill(200,100,100);
arc(eyeXL/2 + eyeXR/2, height/2 + headH/3, 30 * mouthW, 20 * mouthH, 0, PI + QUARTER_PI, OPEN);
//draw hat
fill(hatR, hatG, hatB);
rectMode(CENTER);
rect(hatW, hatH, headW + 20, headH/2, 100, 100, 10, 10);
}
function mousePressed() {
//head size
headW = random(200, 500);
headH = random(200, 350);
//pupil color
pupilR = random(100, 255);
pupilG = random(100, 255);
pupilB = random(100, 255);
//pupil location
pupilY = random(220, 250);
//nose size
noseW = random(10, 50);
noseH = random(10, 50);
//mouth size
mouthW = random(0.5, 3);
mouthH = (0.5, 3);
//hat color
hatR = random(0, 255);
hatG = random(0, 255);
hatB = random(0, 255);
}
I found this project to be pretty difficult to wrap my head around at first, though as I continued on with the project it started to make more sense. As I got into the random manipulation, I started to enjoy myself more than when I was figuring out the arithmetic. I definitely want to use more variables in future projects so I can continue to get more comfortable with them.