Published
Edited
Apr 25, 2020
5 forks
18 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
seed = Date.now()
Insert cell
Insert cell
strokeWeight = 20
Insert cell
trailLength = 150
Insert cell
stepLength = 5
Insert cell
Insert cell
p = getRandomPalette()
Insert cell
palette = shuffle(p)
// palette = ["#fefcbf", "#122c91", "#81e9e6", "#48d6d2", "#2a6fdb"]
// palette = ["#034c8c", "#f2d49b", "#f2e205", "#69a7bf", "#f2cb05"]
Insert cell
Insert cell
svg`<svg width="${w}" height="${h}">
<rect x="0" y="0" width="${w}" height="${h}" stroke="none" fill="${palette[0]}"></rect>

<g>
${(() => {
return array(n).map(() => {
let v = PVector.random(PVector(-w/4, -h/4), PVector(w*5/4, h*5/4))
const pts = [v.clone()]
let sideA = []
let sideB = []
array(trailLength).forEach(i => {
const angle = simplex.noise3D(v.x/noiseScale, v.y/noiseScale, seed) * TAU/2
const dir = PVector.fromAngle(angle)
v.add(dir.clone().setMag(stepLength))
pts.push(v.clone())
sideA.push(v.clone().add(dir.clone().rotateBy(Math.PI/2).setMag((i/trailLength) * strokeWeight)))
sideB.push(v.clone().add(dir.clone().rotateBy(-Math.PI/2).setMag((i/trailLength) * strokeWeight)))
})
sideA.push(v.clone())
sideB.push(v.clone())
sideB.reverse()
const c = palette[1 + (palette.length - 1) * Math.random() | 0]
return `<g opacity="0.9">
<polygon
points="${[...sideA, ...sideB].map(d => `${d.x},${d.y}`).join(' ')}"
stroke="none"
fill="${c}"
/>
<circle cx="${v.x}" cy="${v.y}" r="${strokeWeight - .5}"
stroke="none"
fill="${c}"
/>
</g>`
}).join('\n')
})()}
</g>
</svg>`
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