xxxxxxxxxx
40
const n = 800
const radius = 1
const maxDist = 40
const dim = 400
const particles = []
function setup() {
createCanvas(dim, dim)
const r = 70
const cx = dim / 2
const cy = dim / 2
for (let i = 0; i < n; ++i) {
const rad = TWO_PI / n * i
particles[i] = {
x: cx + cos(rad) * r,
y: cy + sin(rad) * r,
vx: 0,
vy: 0,
}
}
}
function draw() {
noFill()
stroke(0, 10)
for (let i = 0; i < n; ++i) {
const p = particles[i]
p.x += p.vx
p.y += p.vy
p.vx += 0.2 * (Math.random() - 0.5)
p.vy += 0.2 * (Math.random() - 0.5)
circle(p.x, p.y, radius)
}
}