/*
Daniel Noh
Section D
dnoh@andrew.cmu.edu
Project-02
*/
var yolkSize = 230;
var eggX = 0;
var eggY = 0;
var eggA = 0;
var eggB = 0;
var rEye = 20;
var lEye = 20;
var r = -15;
var g = -15;
var b = 15;
var bubbleSize = 30;
function setup() {
createCanvas(640, 480);
background(255);
}
function draw() {
//fryingpanback
stroke(0);
strokeWeight(7);
fill(40);
ellipse(320, 480, 1000, 1000);
noStroke();
fill(60);
ellipse(320, 480, 850, 850)
//egg white shape
fill(240+b, 240+b, 240+b);
stroke(0);
strokeWeight(7);
beginShape();
curveVertex(100+eggX, 540+eggY);
curveVertex(100+eggX, 540+eggY);
curveVertex(80+eggX, 400+eggY);
curveVertex(110+eggA, 300+eggB);
curveVertex(200+eggB, 250+eggX);
curveVertex(320+eggX, 150+eggA);
curveVertex(440+eggB, 250+eggY);
curveVertex(530+eggY, 300+eggB);
curveVertex(560+eggX, 400+eggA);
curveVertex(540+eggA, 540+eggB);
curveVertex(540+eggA, 540+eggB);
endShape();
//yolk face
fill(255+r, 255+g, 0+b);
stroke(0);
strokeWeight(7);
ellipse(320, 450, yolkSize, yolkSize);
//eyes
fill(0);
noStroke();
//uppereye
ellipse(270+r, 460+r, bubbleSize+r+10, bubbleSize+r+10);
//lowereye
ellipse(320+g, 400+r, bubbleSize, bubbleSize);
//mouth
stroke(0);
ellipse(340, 480, bubbleSize+20+eggA, bubbleSize+40+b);
}
function mousePressed() {
eggX = random(-25, 25);
eggY = random(-25, 25);
eggA = random(-25, 25);
eggB = random(-25, 25);
r = random(-15, 0);
g = random(-25, 0);
b = random(0, 25);
yolkSize = random(200, 230);
bubbleSize = random(20, 25);
clear();
}
I honestly went directly to coding only knowing that I wanted to create a dynamic egg face, so at first I was slightly confused. I plotted points down relative to the overall canvas and went from there. I reused several randomized variables for different things, which made my code a bit unorganized. However, I am content with my final product.