xxxxxxxxxx
51
let petals = [];
let mouse;
let angle = 360;
let step = 45,
size = 50;
let amount = angle / step; // formula to the amount of circles
let note = ["C4", "D4", "E4", "F4", "G4", "A4", "B4", "C5"];
let count = 0;
let synth;
function setup() {
createCanvas(400, 400);
angleMode(DEGREES);
textAlign(CENTER);
for (let i = 0; i < angle; i += step) {
let r = 100;
let x = r * cos(i);
let y = r * sin(i);
let petal = new Petal(x + width / 2, y + height / 2, size, note[count]);
if (count < amount) {
count += 1;
}
petals.push(petal);
}
synth = new p5.MonoSynth();
}
function draw() {
background(220);
mouse = {
x: mouseX,
y: mouseY,
};
noStroke();
for (let p of petals) {
p.display();
p.hover(mouse);
}
}