Published
Edited
Jun 3, 2020
3 stars
Insert cell
Insert cell
Insert cell
Insert cell
n = 30
Insert cell
brushLength = 10
Insert cell
palette = ['cyan', 'magenta', 'yellow']
Insert cell
Insert cell
svg`<svg width="${w}" height="${h}">
<rect width="${w}" height="${h}" fill="none" stroke="blue" />
${array(n).map(i => Polygon.intersection(zone, new Polygon(...polygonPath(PVector.random(PVector(w, h)), randInt(12), randInt(50, (n-i) * 10), random(TAU))))[0])
.filter(d => d)
.map(p => {
const c = palette[randInt(palette.length)]
const hatches = p.getHatches(random(TAU), randInt(3, 8), 3, true)
return `<path
stroke="${c}"
fill="none"
d="${pathFromHatches(hatches)}"
/>
<path
stroke="${c}"
fill="none"
d="${pathFromPolygon(p)}"
/>`
}).join('\n')}
</svg>`
Insert cell
Insert cell
polygonPath = (center, n, rad, startAngle = 0) => array(n).map(i => PVector.fromAngle(startAngle + TAU/n * i).mult(rad).add(center))

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