npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@anomnomnomaly/sample

v0.1.0

Published

Spatial distributions: Poisson disk, Delaunay, Voronoi, Halton/Sobol

Downloads

193

Readme

@anomnomnomaly/sample

Spatial distribution and computational geometry for the @anomnomnomaly suite — Poisson disk sampling, Delaunay triangulation, Voronoi tessellation, and low-discrepancy sequences. All randomised functions accept a RandomFn so the caller controls reproducibility.

Functions

poissonDisk — minimum-distance point distribution

Bridson's algorithm. Generates points with a guaranteed minimum distance between any two, producing natural-looking scatter without clustering. O(n).

import { poissonDisk } from '@anomnomnomaly/sample';
import { xoshiro256 } from '@anomnomnomaly/prng';

const rng = xoshiro256({ seed: 42 });
const points = poissonDisk(
  { width: 800, height: 600, minDistance: 40 },
  rng,
);
// [{ x, y }, ...] — every pair is at least 40 units apart

| Option | Default | Description | |---|---|---| | width | — | Sampling region width | | height | — | Sampling region height | | minDistance | — | Minimum distance between any two points | | maxAttempts | 30 | Candidates per active point before giving up — higher = denser |

delaunayTriangulate — Delaunay triangulation

Bowyer-Watson incremental algorithm. Returns index-triples into the input array. Satisfies the empty circumcircle property: no point lies inside the circumcircle of any triangle.

import { delaunayTriangulate, delaunayEdges } from '@anomnomnomaly/sample';

const pts = [{ x: 0, y: 0 }, { x: 100, y: 0 }, { x: 50, y: 100 }, ...];
const tris = delaunayTriangulate(pts);
// [[0, 1, 2], [1, 3, 2], ...] — indices into pts

// Extract unique edges (optionally filtered by max length)
const edges = delaunayEdges(pts, tris, /* maxLength */ 200);
// [[0, 1], [1, 2], ...] — useful for cosmic web filaments, road networks

minimumSpanningTree — connect everything, no loops

Kruskal's algorithm with a union–find. Given points and candidate edges, keeps the subset with the smallest total length that still connects every point. With Delaunay edges as candidates this is the standard dungeon corridor graph; add a few of the discarded edges back for loops.

import { delaunayTriangulate, delaunayEdges, minimumSpanningTree } from '@anomnomnomaly/sample';

const edges = delaunayEdges(roomCentres, delaunayTriangulate(roomCentres));
const tree  = minimumSpanningTree(roomCentres, edges);
// tree.length === roomCentres.length - 1

voronoiCells — Voronoi tessellation

Derived as the dual of the Delaunay triangulation — no additional expensive computation. Returns the circumcentre vertices of surrounding triangles for each site, sorted angularly to form a convex polygon.

import { delaunayTriangulate, voronoiCells } from '@anomnomnomaly/sample';

const tris  = delaunayTriangulate(sites);
const cells = voronoiCells(sites, tris);

for (const { siteIndex, vertices } of cells) {
  // vertices = polygon corners for this Voronoi cell
  // cells at the convex hull are open — clip to your viewport as needed
}

A common pipeline for map region generation:

const sites  = poissonDisk({ width, height, minDistance: 60 }, rng);
const tris   = delaunayTriangulate(sites);
const cells  = voronoiCells(sites, tris);
const edges  = delaunayEdges(sites, tris, 300); // filament connections

halton / halton2D / vanDerCorput — low-discrepancy sequences

Quasi-random sequences that cover the unit square more evenly than pseudo-random sampling — useful for Monte Carlo integration, stratified sampling, and anti-aliased jitter. No RNG dependency; entirely deterministic.

import { halton, halton2D, vanDerCorput } from '@anomnomnomaly/sample';

// Individual Halton values (base-2 for x, base-3 for y is the standard pairing)
halton(0, 2); // 0
halton(1, 2); // 0.5
halton(2, 2); // 0.25
halton(3, 2); // 0.75

// 64 well-distributed 2D points in [0, 1)²
const pts = halton2D(64);

// Van der Corput — base-2 Halton via bit-reversal (faster for large n)
vanDerCorput(n);

Unlike Poisson disk, there is no minimum-distance guarantee, but the low-discrepancy property ensures no large uncovered gaps — and unlike pure PRNG sampling, it converges faster in Monte Carlo contexts.