All checks were successful
docs / build-and-deploy (push) Successful in 2s
A Noise.* namespace for procedural generation, implemented entirely in Q16.16 fixed point over an integer permutation hash so a seed reproduces the exact same field on every platform and run (native/headless/wasm) — the determinism edge over float noise that drifts across CPUs. - value2 / perlin2 / simplex2 — value, gradient, and simplex noise -> [-1,1] - fbm2(x,y,seed,octaves) — fractal Brownian motion (octaves of simplex) - cellular2 / cellular2_id — Worley F1 distance + nearest-cell id - unit(n) — remap [-1,1] -> [0,1] Covers issue phases 1–2 fully plus cellular from phase 3; domain warp, ridged/ billow, and sample1/sample3 remain as follow-ups. Pure integer IR, C-free; cellular/fbm reuse the math prelude's fx_sqrt. - examples/library/noise.ludic: asserts the invariants a fixed-point generator must hold (Perlin == 0 at lattice points, every sampler within [-1,1], reproducibility, seed sensitivity, non-negative cellular distance). Wired into `x test` (now 52 passed). - docs: a new Noise section + per-symbol pages; inventory and coverage pass. - seed regenerated; `x bootstrap-cfree` fixpoint holds. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1.3 KiB
1.3 KiB
| id | name | category | kind | tokens | sig | tip | order | ns | member |
|---|---|---|---|---|---|---|---|---|---|
| noise-perlin2 | Noise.perlin2 | noise | namespace-method | Noise.perlin2 | Noise.perlin2(x, y, seed) -> fixed | 2D Perlin gradient noise, deterministic, in [-1, 1]. | 2 | Noise | perlin2 |
Samples 2D Perlin gradient noise at (x, y) for the given seed and returns a fixed in [-1, 1]. Instead of a random value per lattice point, Perlin places a random gradient at each corner and interpolates their dot products with the offset vectors — which gives smoother, more natural gradients than value noise, the familiar look of classic terrain and cloud fields. By construction the value is exactly 0 at every integer lattice point.
Deterministic in fixed point across platforms and runs. Scale the coordinates to set feature size, and stack octaves with Noise.fbm2 for richer detail.
Parameters:
x,y— the sample coordinates (fixed)seed— the field selector
program Perlin {
entry {
let seed = 1337
if Noise.perlin2(fixed(0), fixed(0), seed) == 0 { print(1) } # zero at the lattice
let n = Noise.perlin2(fixed(10) / fixed(3), fixed(7) / fixed(3), seed)
print(Math.floor(n * fixed(1000)))
}
}