Published
Edited
Apr 25, 2022
Importers
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
/**
* Generate a points in a 2D using Poission Disc Sampling
*
* @param {number} width The width
* @param {number} height The height
* @param {object} [opts={}] The options for PoissonDiskSampling, except `shape`
* @return {Array<[number,number]>} The points
*/
function poissonSampling2d(width, height, opts = {}) {
const options = Object.assign(
{
minDistance: Math.min(width, height) / 20
},
opts
);

const pds = new PoissonDiskSampling({
...options,
shape: [width, height]
});

return pds.fill();
}
Insert cell
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