xxxxxxxxxx
31
function setup() {
createCanvas(windowWidth, windowHeight);
background(255);
}
function draw() {
if (mouseIsPressed) {
drawFlower(mouseX, mouseY);
}
}
function drawFlower(x, y) {
let petals = int(random(5, 10));
let petalSize = random(10, 30);
let flowerColor = color(random(255), random(255), random(255));
let centerColor = color(random(100, 255), random(100, 255), 0);
push();
translate(x, y);
noStroke();
fill(flowerColor);``
for (let i = 0; i < petals; i++) {
ellipse(0, petalSize / 2, petalSize, petalSize * 2);
rotate(TWO_PI / petals);
}
fill(centerColor);
ellipse(0, 0, petalSize, petalSize);
pop();
}