Public
Edited
Jan 23, 2023
1 star
Insert cell
Insert cell
Insert cell
Insert cell
svg`<svg width="${w}" height="${h}">
<defs>
${polygons.map((p, i) => {
const index = randInt(p.pts.length)
let a = p.pts[index]
let b = p.pts[(index + p.pts.length / 2 | 0) % p.pts.length]
const colorA = getColor(a)
const colorB = getColor(b)
a = PVector.sub(a, p.center).setMag(0.7).add(0.5)
b = PVector.sub(b, p.center).setMag(0.7).add(0.5)
return `<linearGradient id="gradient${i}" x1="${a.x}" y1="${a.y}" x2="${b.x}" y2="${b.y}">
<stop offset="0%" stop-color="${colorA}"/>
<stop offset="100%" stop-color="${colorB}"/>
</linearGradient>`
}).join('\n')}
</defs>

<rect x="0" y="0" width="${w}" height="${h}" stroke="none" fill="white"></rect>

<g transform="translate(${w/2}, ${h/2}) scale(1) translate(${-w/2}, ${-h/2})">
${polygons.map((p, i) => `<polygon
transform="translate(${p.center.x}, ${p.center.y}) scale(1.05) translate(${-p.center.x}, ${-p.center.y})"
fill="url(#gradient${i})"
stroke="none"
points="${p.pts.map(pt => `${pt.x} ${pt.y}`).join(' ')}"
/>`).join('\n')}
</g>
</svg>`
Insert cell
imageData = readPixels(`https://source.unsplash.com/featured?portrait,close,${Date.now()}`, { w, h , format: 'hsl', fit: true })
Insert cell
Insert cell
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