Platform
Solutions
Resources
Pricing
Sign in
Sign up
UnluckyNinja
Workspace
Fork
Public
Procedural Content Generation
By
UnluckyNinja
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.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
scale
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
offsetX
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
offsetY
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
reroll
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
distributionType
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
delaunay
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
rawPoints
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
spawnPoints
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
delaunayCentroids
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
triangleHeights
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
samplePointsOnRectEdge
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
mergeSegments
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
voronoi
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
noiseGenerator
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
simplex
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML