Raymond Pai-Project-02-Variable-Face

sketch

var r = (200);
var g = (120);
var b = (120);
var mouthx = 50
var mouthy = 20
var eyew = 40
var eyeh = 40
var brow1y1 = 100
var brow1y2 = 100
var brow2y1 = 100
var brow2y2 = 100

function setup() {
    createCanvas(640, 480);
}

function draw() {
    background(240);
    // Draw head
    strokeWeight(5);
    fill(r, g, b, 127);
    ellipse(320, 240, 400, 400);
    //Draw mouth
    fill(0);
    stroke(255, 200, 200);
    rect(320, 300, mouthx, mouthy)
    //Draw eye1
    strokeWeight(20);
    stroke(255);
    fill(0);
    ellipse(420, 200, eyew, eyeh);
    //Draw eye2
    strokeWeight(20);
    stroke(255);
    fill(0);
    ellipse(330, 200, eyew, eyeh);
    //Draw brow1
    strokeWeight(18);
    stroke(0);
    line(270, brow1y1, 350, brow1y2)
    //Draw brow2
    strokeWeight(18);
    stroke(0);
    line(380, brow2y1, 430, brow2y2)
    //ear
    strokeWeight(5);
    fill(r, g, b, 127)

    arc(220, 250, 80, 80, 0, 5 + QUARTER_PI, OPEN);
}
function mousePressed() {
  // Check if mouse is inside the circle
  let d = dist(mouseX, mouseY, 360, 200);
  if (d < 700) {
  //randomize
    r = random(120, 200);
    g = random(100, 120);
    b = random(100, 120);
    mouthx = random(50, 95);
    mouthy = random(30, 105);
    eyew = random (20, 90);
    eyeh = random (20, 145);
    brow1y1 = random (60, 100);
    brow1y2 = random (60, 100);
    brow2y1 = random (60, 100);
    brow2y2 = random (60, 100);
  }
}

Changes in color, mouth, eyes, and eyebrows. It is an expressive fish.

Leave a Reply