Published
Edited
Nov 22, 2020
7 forks
21 stars
Insert cell
Insert cell
Insert cell
Insert cell
seed = Date.now()
Insert cell
step = 10
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
noiseScale = 1200
Insert cell
svg`<svg width="${w}" height="${h}">
<rect x="0" y="0" width="${w}" height="${h}" stroke="none" fill="black"></rect>
<g transform="translate(${marginX}, ${marginY})">
${(() => {
return array(ny).map(i => {
const y = i * step
return array(nx).map(j => {
let x = j * step
let v = PVector(x, y)

return `<path
stroke="rgba(${x/w * 255}, ${y/h * 255}, 127, 0.2)"
fill="none"
d="M${x} ${y} ${array(trailLength).map(() => {
const isInside = v.x >= 0 && v.x <= w && v.y >= 0 && v.y <= h
if(!isInside) return

const angle = simplex.noise3D(v.x/noiseScale, v.y/noiseScale, seed) * TAU
v.add(PVector.fromAngle(angle).setMag(stepLength))
return `L${v.x} ${v.y}`
}).filter(d => d).join(' ')}"
/>`
}).join('\n')
}).join('\n')
})()}
</g>
</svg>`
Insert cell
Insert cell
Insert cell
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