xxxxxxxxxx
72
// Connie Hu - N12157740
// Assignment 4 - FROG with FUNCTIONS
// I intend to create the same frog from assignment 1, BUT with cleaner code.
function setup() {
createCanvas(500, 500);
}
//function to draw the Frog's head
function drawHead() {
stroke(0, 230, 0);
noStroke();
fill(152, 255, 140);
ellipse(250, 310, 400, 300);
}
//function to draw the frog's eyes
function drawEyes() {
//eye parts (green)
stroke(0, 230, 0);
strokeWeight(20);
fill(152, 255, 140);
noStroke();
ellipse(140, 160, 160, 160);
ellipse(340, 160, 160, 160);
//eye (whites)
noStroke();
fill(255);
ellipse(140, 150, 110, 110);
ellipse(340, 150, 110, 110);
//eyes (black)
stroke(0);
fill(0);
ellipse(140, 150, 40, 40);
ellipse(350, 150, 40, 40);
// inner eye whites
fill(255);
noStroke();
ellipse(130, 165, 25, 25);
ellipse(360, 135, 25, 25);
}
//function to draw the frog's mouth/tongue area
function drawMouth() {
stroke(1);
strokeWeight(20);
line(100, 340, 400, 340);
//cover up
fill(152, 255, 140);
noStroke();
rect(210, 250, 130, 80);
fill(255, 92, 92);
arc(290, 350, 100, 150, 0, PI, CHORD);
}
//functions are called in draw. This creates cleaner and easier to manage code!
function draw() {
background(220);
drawHead();
drawEyes();
drawMouth();
}