// Yinjie Tian
// yinjiet@andrew.cmu.edu
// Section D
// Project 02
var earSize = 20
var hairColor = 0
var glassSize = 45
var pocketPosition = 450
var rgb1 = 250
var rgb2 = 250
var rgb3 = 250
var mouthSize = 30
function setup() {
createCanvas(600, 600);
background(180);
}
function draw() {
//Background
stroke(0);
fill(rgb1, rgb2, rgb3);
rect(80, 50, 80, 550);
fill(rgb2, rgb1, rgb3);
rect(110, 80, 140, 520);
fill(rgb3, rgb1, rgb2);
rect(300, 100, 200, 500);
fill(rgb1, rgb3, rgb2);
rect(160, 170, 300, 430);
fill(rgb2, rgb3, rgb1);
rect(400, 200, 200, 400);
//Neck
noStroke();
fill(230,214,169);
quad(240, 310, 235, 370, 320, 370, 315, 310);
//Ears
stroke(240,224,179);
fill(240,224,179);
rect(195, 240, earSize, 40, 10);
rect(340, 240, earSize, 40, 10);
//Face
stroke(255,244,189);
fill(255,244,189);
strokeWeight(3);
beginShape();
vertex(210, 270);
vertex(210, 310);
vertex(250, 335);
vertex(310, 335);
vertex(340, 310);
vertex(340, 225);
vertex(215, 225);
endShape();
//Hair
stroke(0);
fill(hairColor);
strokeWeight(4);
beginShape();
vertex(190, 220);
vertex(205, 150);
vertex(270, 125);
vertex(338, 150);
vertex(360, 218);
vertex(342, 235);
vertex(330, 235);
vertex(290, 225);
vertex(250, 235);
vertex(217, 230);
vertex(210, 230);
endShape();
//Glasses
stroke(225, 215, 0);
strokeWeight(3);
fill(255);
rect(220, 240, glassSize, glassSize, 15);
rect(288, 240, glassSize, glassSize, 15);
line(265, 250, 288, 250);
//Nose
stroke(0);
strokeWeight(2);
line(275, 280, 270, 300);
line(270, 300, 275, 300);
//Mouth
noStroke();
fill(290,214,159);
ellipse(290, 320, mouthSize, 10);
//Jacket
stroke(0, 0, 0);
fill(0, 0, 0);
strokeWeight(4);
beginShape();
vertex(150, 365);
vertex(90, 480);
vertex(90, 600);
vertex(430, 600);
vertex(490, 480);
vertex(410, 365);
endShape();
//Pocket
stroke(255,165,0);
rect(190, pocketPosition, 50, 60);
}
function mousePressed() {
earSize = random(15, 30);
hairColor = random(0, 220);
glassSize = random(35, 55);
pocketPosition = random(425, 475);
rgb1 = random(0, 250);
rgb2 = random(0, 250);
rgb3 = random(0, 250);
mouthSize = random(20, 50)
}
I used my portrait for project 1 as the base file. The three factors for variations I looked into were size, position and color. Based on the three factors, I created variables that can change the sizes of my nose, glasses, and mouth; alter the color of my hair and the background; reposition the pocket on my sweatshirt.