xxxxxxxxxx
40
let centerSize = 20;
let petalSize = 20;
let petalNum = 6;
function setup() {
createCanvas(500, 200);
angleMode(DEGREES);
}
function draw() {
background('pink');
//a list of flower
for (let i = 0; i < 30; i++) {
flower('red', 'silver', 'yellow', 20 * i, height / 2, 0.3);
}
}
function flower(c1, stroColor, c2, xPos, yPos, scaleNum) {
push();
translate(xPos, yPos);
scale(scaleNum);
noStroke();
fill(c1);
circle(0, 0, centerSize);
//flower petals
for (let i = 0; i < petalNum; i++) {
angle = 60;
rotate(angle);
stroke(stroColor);
fill(c2);
circle(20, 0, petalSize);
}
pop();
}