ludic/noise-cellular2_id.html
2026-09-17 22:10:03 +00:00

35 lines
No EOL
2.4 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Noise.cellular2_id — Ludic</title>
<meta name="description" content="The id of the nearest Worley cell — stable per cell.">
<link rel="stylesheet" href="base.css">
<link rel="stylesheet" href="docs.css">
</head>
<body>
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
<main class="wrap item">
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-noise.html">Noise</a> <span>›</span> <span class="here">Noise.cellular2_id</span></div>
<div class="item-head">
<span class="kind-badge kind-method">method</span>
<h1 id="top">Noise.cellular2_id</h1>
</div>
<code class="sig">Noise.cellular2_id(x, y, seed) -&gt; int</code>
<div class="desc"><p>Returns the integer **id of the nearest cell** in the same Worley diagram that <a href="noise-cellular2"><code>Noise.cellular2</code></a> measures distance in — a stable hash that is identical for every sample point inside a given cell. Use it to assign something discrete per region: the biome or material of a cell, the variant of a scattered prop, a per-region colour. Combine it with the F1 distance to shade toward cell edges.</p><p>The id is a hash, so treat it as an opaque label (mod it into your table of choices); it is deterministic across platforms and runs.</p></div>
<div class="params"><h2>Parameters</h2><div class="param" id="param-seed"><code class="pname">seed</code><span class="pdesc">the field selector (must match the <code>cellular2</code> call it pairs with)</span></div></div>
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program CellId {
entry {
let seed = 7
let id = Noise.cellular2_id(fixed(5) / fixed(4), fixed(3) / fixed(4), seed)
let biome = Math.posmod(id, 4) # one of 4 biomes for this cell
print(biome)
}
}</pre></div>
<a class="back" href="api.html">← All symbols</a>
</main>
<script src="ludic-highlight.js"></script>
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
</body></html>