xxxxxxxxxx
let circleWaves = [];
function setup() {
createCanvas(windowWidth, windowHeight);
let r = 0;
for(let i = 0; i < 720; i++) {
r += 0.5;
circleWave = new CircleWave({
p: createVector(r * cos(i) + width / 2, r * sin(i) + height / 2),
// v: createVector(cos(i) + sin(i), cos(i) + sin(i)),
a: createVector(0, 0),
r: 10,
color: color(255, 255, 255),
color2: color(0, 0, 255),
})
circleWaves.push(circleWave);
}
background(0);
}
function draw() {
circleWaves.forEach(circle => {
circle.update();
circle.draw();
})
if (mouseIsPressed) {
let r = 0;
for(let i = 0; i < 45; i++) {
r += 0.5;
circleWave = new CircleWave({
p: createVector(r * cos(i) + mouseX, r * sin(i) + mouseY),
v: createVector(2, 0).rotate(1 - (PI * 2 * random())),
a: createVector(0, 0),
color: color(0, random(50, 255), random(0, 255)),
color2: color(0, random(0, 255), random(0, 10), 200),
r: 1,
})
circleWaves.push(circleWave);
}
}
circleWaves = circleWaves.filter(
circle =>
circle.p.x <= windowWidth &&
circle.p.y <= windowHeight
);
}