1 |
/*Xindi Lyu
Section A
xindil@andrew.cmu.edu
Project-02-Face Variables */
//face
var faceWidth = 100;
var faceHeight =95;
var skinR = 250;
var skinG = 180;
var skinB = 150;
//eyes
var color1 = 0;
var color2 = 0;
var color3 = 0;
//hair
var hairR = 200;
var hairG = 40;
var hairB = 210;
function setup() {
createCanvas(640, 480);
background(200);
text("p5.js vers 0.5.12 test.", 10, 15);
}
function draw(){
createCanvas(640, 480);
noStroke();
background(skinR*(1/5),skinG*(1/5), skinB);
//hair
fill(hairR, hairG, hairB);
rect(320-faceWidth/2-20, 240-faceHeight/2-30, faceWidth+40, faceHeight+60, 150,150,10,10);
//face
fill(skinR,skinG,skinB);
rect(320-faceWidth/2, 240-faceHeight*7/24, faceWidth, faceHeight, 10,10, 70,70);
//eyes
fill(color1, color2, color3);
rect(320-faceWidth/2+15, 240-faceHeight/2+50, 10, faceHeight*1/4);
rect(320+faceWidth/2-25, 240-faceHeight/2+50, 10, faceHeight*1/4);
//mouth
noFill();
stroke(skinR*1/2, skinG*1/2, skinB*1/2);
arc(320,240-faceHeight/2+80,12,6,0,PI);
}
function mousePressed() {
faceWidth = random(95,110);
faceHeight = random(90, 140);
skinR = random(220,280);
skinG = random(150,210);
skinB = random(120,170);
color1 = random(0,255);
color2 = random(0,255);
color3 = random(0,255);
hairR = random(150,250);
hairG = random(0,90);
hairB = random(160,270);
}
For this project I played with color variations and light changes of face length and width.