// sketch.js var ms; var xoff = 0.0; var n0 = 100; var n; var m0 = 150; var m = 0.5; var i = 0; function setup() { var cnv = createCanvas(640, 400); cnv.position(24, 140); background(127); ms = millis(); } //setup function draw() { xoff = xoff + .01; if (millis() > ms + 1000) { ms = millis(); i = 1 - i; } if (i==0) { updatePupils(); } else if (i==1) { updateSmile(); } drawFace(); drawEyes(); drawPupils(); drawRings(); drawSmile(); } //draw function drawFace() { noStroke(); fill(255, 225, 0); ellipse(width/2, height/2, 400, 400); } //drawFace function updatePupils() { n = noise(xoff) * n0; } //updatePupils function updateSmile() { m = noise(xoff) * m0; } //updateSmile function drawEyes() { noStroke(); fill(255); ellipse(width/2 - 80, height/2 - 60, 100, 100); // left ellipse(width/2 + 80, height/2 - 60, 100, 100); // right } //drawEyes function drawPupils() { noStroke(); fill(0); ellipse(width/2 - 80 +n-n0/2, height/2 - 60, 40, 50); // left ellipse(width/2 + 80 +n-n0/2, height/2 - 60, 40, 50); // right } //drawPupils function drawRings() { noFill(); stroke(255, 225, 0) strokeWeight(40); ellipse(width/2 - 80, height/2 - 60, 130, 130); // left ellipse(width/2 + 80, height/2 - 60, 130, 130); // right } //drawRings function drawSmile() { stroke(0); strokeWeight(8); noFill(); arc(width/2, height/2, m0+m, m0+m, 0.25, PI-0.25); } //drawSmile