xxxxxxxxxx
41
let petalCount = 10;
let maxPetalSize = 200;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(255);
let bloomSize = map(mouseX, 0, width, 0, maxPetalSize);
drawFlower(width/2, height/2, bloomSize);
}
function drawFlower(x, y, size) {
push();
translate(x, y);
for (let i = 0; i < petalCount; i++) {
let angle = TWO_PI / petalCount * i;
push();
rotate(angle);
let colorFactor = map(size, 0, maxPetalSize, 255, 100);
fill(255, colorFactor, colorFactor);
drawPetal(size);
pop();
}
fill(255,200,0);
ellipse(0, 0, size);
pop();
}
function drawPetal(size) {
ellipse(size / 2, 0, size, size * 3);
}