Published
Edited
May 3, 2020
3 forks
3 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
seed = Date.now()
Insert cell
Insert cell
strokeWeight = 20
Insert cell
trailLength = 220
Insert cell
stepLength = 3
Insert cell
Insert cell
svg`<svg width="${w}" height="${h}">
<rect width="${w}" height="${h}" stroke="blue" fill="none" />

${layer('red')}
${layer('black')}
</svg>`
Insert cell
layer = (color) => `<g>
${array(n).map(() => {
const v = PVector.random(PVector(0, 0), PVector(w, h))
const pts = [v.clone()]

for(let i = 0; i < trailLength; i++){
const angle = simplex.noise3D(v.x/noiseScale, v.y/noiseScale, seed) * TAU/2
const dir = PVector.fromAngle(angle)
v.add(dir.setMag(stepLength))
if(!(v.x > 0 && v.x < w && v.y > 0 && v.y < h)) break
pts.push(v.clone())
}

return pts.map((pt, i, arr) => `<circle
cx="${pt.x}"
cy="${pt.y}"
r="${(1 - i/arr.length) * strokeWeight * arr.length / trailLength}"
stroke="${color}"
fill="none"
opacity="0.2"
/>`).join('\n')
}).join('\n')}
</g>`
Insert cell
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