xxxxxxxxxx
50
const dim = 400
const radius = 20
const spacing = radius * 1.2
const speed = Math.PI / 50
const particles = []
function setup() {
createCanvas(400, 400);
for (let x = 0; x < dim + spacing; x += spacing) {
for (let y = 0; y < dim + spacing; y += spacing) {
particles.push({
x,
y,
rad: sin((x + y) / spacing / 10) * TWO_PI
})
}
}
}
function draw() {
background(255);
// move particles
particles.forEach(particle => {
particle.rad += speed
})
// tracks, uncomment these lines to see
// noFill()
// stroke(200)
// particles.forEach(({
// x,
// y,
// rad
// }) => {
// circle(x, y, radius * 2)
// })
// particles
fill(100)
stroke(100)
particles.forEach(({
x,
y,
rad
}) => {
circle(x - cos(rad) * radius, y + sin(rad) * radius,3)
})
}