var nPoints=300;
function setup() {
createCanvas(500,500);
}
function draw() {
background(157,129,137);
drawLeaf();
drawPeach();
drawPedal();
}
function drawPeach(){
var xa;
var ya;
var v;
fill(255,202,212);
noStroke();
push();
translate(width/2, height/2-40);
beginShape();
var a;
var b=map(mouseY, 0,height, 250,255);
for (var i=0; i<nPoints; i++){
var t=map(i,0, nPoints, 0, TWO_PI);
xa=a*((v-1)*cos(t)+cos((v-1)*t))/v;
ya=a*((v-1)*sin(t)+sin((v-1)*t))/v;
a=constrain(b,250,255);
v=3;
vertex(ya,xa);
}
endShape();
pop();
}
function drawPedal(){
var xp;
var yp;
noFill();
stroke(255,229,217);
strokeWeight(5);
push();
translate(width/2, height/2+30);
var m=map(mouseX, 0, height, 0, 5);
var n=constrain(m,0,5);
beginShape();
for (var i=0; i<nPoints; i++){
var t=map(i,0, nPoints, 0, TWO_PI);
xp=10*(n+2)*(cos(t)-cos((n+1)*t));
yp=10*(n+2)*(sin(t)-sin((n+1)*t));
vertex(xp,yp);
}
endShape();
pop();
}
function drawLeaf(){
var c=map(mouseY, 0, height, 0, 5);
fill(215,226,220);
noStroke();
push();
translate(width/2, height/2);
rotate(radians(50));
ellipse(-100,-140, 50+c, 145+c);
pop();
}
I used two different pedal curves in this project. One of them I managed to use MouseX to control the n number of the pedals, while the other one I set the n number to 3 to create the two-pedal peach shape. Moving the mouse from left to right will increase the number of pedals from 0 to 5. MouseY controls the size of the peach.