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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more