xxxxxxxxxx
var numObjects = 10;
var centerX;
var centerY;
var distance = 100;
var a = 0;
function setup() {
createCanvas(windowWidth, windowHeight);
centerX = width / 2;
centerY = height / 2;
//noStroke();
stroke(13, 97, 133,60)
ellipseMode(CENTER);
}
function draw() {
background(0);
var angleObject = 360 / numObjects;
var expansion = map(mouseX, 0, width, 0, 2);
for (var i = 0; i < numObjects; i++) {
push();
translate(centerX, centerY);
rotate(radians(i * angleObject));
//or you can draw at 0,0 and translate again
//translate(distance,0);
a += expansion;
var ySin = sin(radians(a)) * 50;
//adding the sine to y starting from the center position
ellipse(50, 50 + ySin, 30, 30);
pop();
}
}