Project 02: Variable Faces

variable faces

var eyeSize = 100;   //Max Stockdale, section D
var faceWidth = 350;
var faceHeight = 250;
var mouth = 50;
var tooth=40;
var nose=60;
var eyeHighlight=20;
var body=400
var arms=100

function setup() {
    createCanvas(640, 480);
    background(220);
    text("p5.js vers 0.9.0 test.", 10, 15);
}

 
function draw() {
    background(91,161,191);  //blue
    strokeWeight(0);
    fill(47,213,102);
    circle(width/2, height/1.2, body); //body shape
    fill(255,255,255);
    strokeWeight(0);
    ellipse(width / 2, height / 2, faceWidth,  faceHeight); //face
    var eyeLX = width / 2 - faceWidth * 0.5;
    var eyeRX = width / 2 + faceWidth * 0.5;
    strokeWeight(1);
    fill(0,0,0);
    ellipse(eyeLX, height / 2, eyeSize, eyeSize);  //left eye
    ellipse(eyeRX, height / 2, eyeSize, eyeSize);  //right eye
    fill(255,255,255);
    circle(eyeLX + 5, height / 2, eyeHighlight);  //eye highlight
    circle(eyeRX + 5, height / 2, eyeHighlight);  //eye highlight
    fill(48,56,65); 
    rect(width/2, height/2, mouth, mouth);  //mouth
    fill(255,255,255);
    triangle(320,240, 330,250, 340,240);  //tooth
    fill(72,3,31);
    ellipse(width/2, height/2.25, nose, 20); //noser
    strokeWeight(0);
    fill(153,155,250);
    circle(width/4.75, height/1.3, arms);  //left arm
    circle(width/1.25, height/1.3, arms);  //right arm
    fill(255,255,255);

    




}
 
function mousePressed() {
    faceWidth = random(50, 600);
    faceHeight = random(150, 300);
    eyeSize = random(20, 60);
    mouth = random(10, 40);
    ears = random(5,15);
    nose = random(15,45);
    body =random(400,500);
    arms = random(80,120);
}

Leave a Reply