Public
Edited
Oct 2, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// adapt this code for your application
viewof distributionType = Inputs.select([
"poisson",
"pseudoblue",
"hex",
"grid",
"random",
"normal"
])
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
delaunay = d3.Delaunay.from([...rawPoints, ...samplePointsOnRectEdge(Math.min(width, 500)+12, Math.min(width, 500)+12, 20,-6,-6)])
Insert cell
rawPoints = {
reroll
return spawnPoints({
type: distributionType,
rect: {x:0, y:0, width: Math.min(width, 500), height: Math.min(width, 500)},
n: 2000,
})
}
Insert cell
function spawnPoints(options = {}){
const {type, rect, n} = {
type: 'poisson',
rect: {x:0,y:0,width:1,height:1},
n: 100,
...options,
}
// may change to seedable in the future.
return [...pick2d(rect.width, rect.height, n, type)].map(it=>[it[0]+rect.x,it[1]+rect.y])
}
Insert cell
spawnPoints({type: 'poisson'})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
voronoi = delaunay.voronoi([-6, -6, Math.min(width, 500)+6, Math.min(width, 500)+6])
Insert cell
Insert cell
noiseGenerator = simplex.createNoise2D()
Insert cell
simplex = import('https://unpkg.com/simplex-noise@4.0.1/dist/esm/simplex-noise.js?module')
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