Project-02:Variable Face

cody.variable.face
function setup() {
    createCanvas(640, 480);
    background(220);
    text("p5.js vers 0.9.0 test.", 10, 15);
}
var faceWidth=400
var faceHeight=470
var noseCenter=300
var mouthAngle=0

function draw() {
    background(176, 196, 222);
    ellipse((width/2),(height/2), 400,470);  
    arc((width/2),(height/2+40),410,550,3.14,0) //hair
    arc((width/2),(height/2+40),400,540,3.14,0)
    arc((width/2),(height/2+40),390,530,3.14,0)
    arc((width/2),(height/2+40),390,520,3.14,0)   
    arc((width/2),(height/2+40),390,510,3.14,0)
    arc((width/2),(height/2+40),390,500,3.14,0)
    arc((width/2),(height/2+40),390,490,3.14,0)
    arc((width/2),(height/2+40),390,480,3.14,0)
    arc((width/2),(height/2+40),390,470,3.14,0)
    arc((width/2),(height/2+40),390,460,3.14,0)
    arc((width/2),(height/2+40),390,450,3.14,0)
    arc((width/2),(height/2+40),390,440,3.14,0) //hair line
    ellipse(225,220,80,45) //orbit left
    fill(0)
    ellipse((faceWidth/2+15),220,37,37) //eyeball left
    fill(255)
    ellipse(375,220,80,45) //orbit right
    fill(0)
    ellipse((faceWidth/2+170),220,37,37) //eyeball right
    fill(255,182,193)
    arc((width/2-10),380, 150, 100, (mouthAngle-0.5), (2.5+mouthAngle)) //mouth
    fill(255,192,203)
    triangle(300, 280, (noseCenter), 350, 320, (noseCenter+60)) //nose
    fill(255)
    stroke(72,209,204)
    strokeWeight(6)
    arc(225, 185, 80, 40, 3.2, -0.04) //eyebrow left
    arc(375,185, 80, 40, 3.2, -0.04) //eyebrow right
    arc(130, 280, 50, 60, 1.5, 4.75) //ear left
    arc(500, 280, 50, 60, 4.75, 1.65) //ear left
    
}

function mousePressed(){
    faceWidth=random(360,440)
    noseCenter=random (250,300)
    mouthAngle = random(0,1)
}
noLoop();

The part I like the most is how the eyeballs change randomly.

Leave a Reply