Public
Edited
Oct 2, 2024
[PCG] Procedual map generation random stuff
[PCG] Maze
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

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