Project 2 – Variable Faces

sketch

var facewidth = 200;
var faceheight = 200;
var lefteary = 149; //y coordinate of the left ear
var righteary = 149; //y coordinate of the right ear
var eyebrowx1 = 295; //x coordinate of the left eyebrow
var eyebrowy1 = 230; //y coordinate of the left eyebrow
var eyebrowx2 = 345; //x coordinate of the right eyebrow
var eyebrowy2 = 230; //y coordinate of the right eyebrow
var eyewidth = 15;
var eyeheight = 15;
var mouthwidth = 15;
var mouthheight = 11;
var cheekwidth = 65;
var cheekheight = 65;

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

function draw() {
  background(255,243,169);
  noStroke();
  fill(255,197,197);
  ellipse(266,lefteary,70,172); //left ear
  ellipse(373,righteary,70,172); //right ear
  ellipse(320,267,facewidth,faceheight); //face
  fill(255,171,195);
  ellipse(250,291,cheekwidth,cheekheight);//left cheek
  ellipse(389,291,cheekwidth,cheekheight); //right cheek
  fill(107,43,43);
  ellipse(286,251,eyewidth,eyeheight);//left eye
  ellipse(353,251,eyewidth,eyeheight); //right eye
  rect(313,268,mouthwidth,mouthheight); //mouth
  strokeWeight(5);
  stroke(107,43,43);
  line(277,230,eyebrowx1,eyebrowy1); //eyebrow left
  line(eyebrowx2,eyebrowy2,362,230); //eyebrow right
  
  
}

function mousePressed(){
  eyebrowy1 = random(225,235);
  eyebrowy2 = random(225,235);
  eyewidth = random(5,30);
  eyeheight = random(5,30);
  mouthwidth = random(5,30);
  mouthheight = random(5,30);
  cheekwidth = random(40,70);
  cheekheight = random(20,70);
  lefteary = random(120,170);
  righteary = random(120,170);
  
}

Leave a Reply