paths = {
noise.seed(seed)
const TAU = Math.PI * 2
const PERIOD = 1/frequency
const STEP = step
const particles = []
const NUM=num
const ITER=iter
const ROTMULT = rotmul
for (let i = 0; i < NUM; i++) {
particles.push({
x: (i/NUM * W - W/2) * 0.8,
y: 0,
})
}
const paths = particles.map(initial => {
let pa = []
let p = {x:initial.x, y:initial.y}
for (let i = 0; i < ITER; i++) {
const n = noise.perlin2(p.x * PERIOD, p.y * PERIOD) * ROTMULT
p.x += Math.sin(n) * STEP
p.y += Math.cos(n) * STEP
pa.push([p.x, p.y])
}
p.x = initial.x; p.y = initial.y
for (let i = 0; i < ITER; i++) {
const n = noise.perlin2(p.x * PERIOD, p.y * PERIOD) * ROTMULT
p.x -= Math.sin(n) * STEP
p.y -= Math.cos(n) * STEP
pa.unshift([p.x, p.y])
}
return pa
})
return paths
}