Published
Edited
Apr 28, 2020
2 forks
9 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
layer = color => array(30).map(() => {
const nbRects = randInt(5, 25)
const rad = randInt(2, 8) * 60
const rw = randInt(4, 15)
const rh = randInt(5, 100)
const startAngle = random(720)
const stepAngle = randInt(Math.max(1, rw - rad / 60), rw/2)
const nbHashes = random(0.05, 0.4) * rh | 0

return array(nbRects).map(i => {
return `<g transform="translate(${w/2}, ${h/2}) rotate(${startAngle + i * stepAngle}) translate(0, ${rad - rh/2})">
<rect
x="${-rw/2}" y="0"
width="${rw}"
height="${rh}"
stroke="${color}"
fill="none"
/>

${array(nbHashes).map(j => {
const y = map(j, -1, nbHashes, 0, rh)
return `<line
x1="-${rw / 2}"
y1="${y}"
x2="${rw / 2}"
y2="${y}"
stroke="${color}"
/>`
}).join('\n')}
</g>`
}).join('\n')
}).join('\n')
Insert cell
import { array, random, randInt, expRand, map, TAU } from '@makio135/utilities'
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