Published
Edited
Jul 18, 2018
Fork of Inner swirl
3 forks
9 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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,//Math.random() * W,
y: 0,// + Math.random() * 50,
})
}

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
}
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more