Published
Edited
Nov 26, 2020
4 stars
Insert cell
Insert cell
w = 540
Insert cell
svg`<svg width="${w}" height="${w}">
<rect x="0" y="0" width="${w}" height="${w}" fill="black" />
<g>
${(() => {
const prng = new PRNG(seed)
return array(230).map((d, i, arr) => {
const N = arr.length
const y = map(i, 0, N, 50, w-50)
const r = (Math.sin(i/N*PI) * Math.sin(i/N*PI*24)) * w * 0.75
// const r = Math.sin(i/N*PI) * w * 0.65
return `<rect
transform="translate(${w/2}, ${y}) scale(1, .2) rotate(${(now/30 + i*1) % 360})"
x="-${r/2}"
y="-${r/2}"
width="${r}"
height="${r}"
rx="${(Math.cos(now/700) + 1) * 200 | 0}"
fill="rgba(0, 0, 0, 0.08)"
stroke="${palette[prng.rand(0, palette.length)]}"
stroke-width="5"
stroke-width="${5 + prng.rand(0, 10)}"
stroke-dasharray="${dashes[i]}"
/>`
}).join('\n')
})()}
</g>
</svg>`
Insert cell
seed = Date.now()
Insert cell
dashes = array(550).map(() => array(30).map(i => i===0 ? randInt(2) * randInt(80) : randInt(40)))
Insert cell
palette = getRandomPalette()
Insert cell
Insert cell
Insert cell
import { getRandomPalette, displayPalettes } from '@makio135/give-me-colors'
Insert cell
import { PI, array, map, PRNG, randInt } from '@makio135/utilities'
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