For this project, I was inspired by a cute sketch of a tomato (reference at bottom) that I found, and wanted to replicate the same idea onto an apple/tomato that looks more like one or the other depending on the random regeneration after clicking.
sketch
Download
// Susie Kim
// Section A
var BodyHeight = 265;
var BodyWidth = 175;
var leafLength = 30;
var leafWidth = 60;
var pupilSize = 35;
var mouthLength = 20;
var stemLength = 150;
var stemThickness = 15;
var nose = 10;
var eyebrowHeight = 300
function setup() {
createCanvas(480,640);
}
function draw() {
background(255,218,185);
// draw stem
stroke(0, 139, 0);
strokeWeight(stemThickness);
line(230, 320, 230, stemLength);
// cheeks
noStroke();
fill(255,8,0);
// draw left cheek
ellipse(180, 320, BodyWidth, BodyHeight);
// draw right cheek
ellipse(270, 320, BodyWidth, BodyHeight);
// leaves
fill(0,139,0);
ellipse(200,170, leafWidth, leafLength);
ellipse(260,160, leafWidth, leafLength);
// eyes, outer
fill(255);
ellipse(170,330,55);
ellipse(280,330,55);
// eyes, pupil
fill (0);
ellipse(170,335, pupilSize);
ellipse(280,335, pupilSize);
// nose:
fill (230,230,250)
ellipse(225,365,nose)
// mouth:
strokeWeight(3);
stroke(0);
line(215, 390, 235, 390);
// eyebrows
line(160,eyebrowHeight, 180, eyebrowHeight);
line(270,eyebrowHeight, 290, eyebrowHeight);
}
function mousePressed() {
// when the user clicks, the following variables are reassigned
// randomly depending on the assigned paramenets.
BodyHeight = random(265, 305);
BodyWidth = random(175, 225);
pupilSize = random(25, 45);
stemLength = random(90, 140);
stemThickness = random(8, 21);
leafLength = random(25, 50);
leafWidth = random(70, 80);
nose = random(9,20);
eyebrowHeight = random(250,300)
}