In this section
- Iterations — 26 Apps Layers Substrate Page render · galaxies-wafers / iterations/26-apps-layers-substrate/index.html lines 1–59
- Queue ingest · galaxies-wafers / iterations/26-apps-layers-substrate/queue.mjs lines 1–56
- Iterations — 26 Apps Layers Substrate Style Sheet render · galaxies-wafers / iterations/26-apps-layers-substrate/style.css lines 1–147
- Hazards render · galaxies-wafers / iterations/27-earth-radii-and-argument-order/hazards.css lines 1–56
- Hazards geodesy · galaxies-wafers / iterations/27-earth-radii-and-argument-order/hazards.mjs lines 1–382
Iterations — 26 Apps Layers Substrate Page
A web page in Galaxies Wafers that reads inputs for depth. Published at https://ventusltd.github.io/galaxies-wafers/iterations/26-apps-layers-substrate/.
rendergalaxies-wafers / iterations/26-apps-layers-substrate/index.html · lines 1–59 of 59 · Entry point
- What it does
- It draws its content. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- README: "The page (`index.html`, `app.mjs`, `lib.mjs`) is inherited unchanged from testcode/202609151339."
- Inputs & outputs
- In: form fields (user input). Out: web page.
- Downstream impact
- It is itself an entry point, published at https://ventusltd.github.io/galaxies-wafers/iterations/26-apps-layers-substrate/.
- What it achieves
- Apps, Layers, Substrate — the estate's apps as tabs over its numbered lines.
- Why it matters
- No other file in the estate was found to import it; it is an entry point.
- Application
- galaxies-wafers · iterations/26-apps-layers-substrate · page
- Uses
- Iterations — 26 Apps Layers Substrate Style Sheet (stylesheet), Galaxies Wafers — Proof Page (link), Iterations — 26 Apps Layers Substrate (script src), Layers Panel (script src), Apps (script src)
- Used by
- none found
- Produces
- none declared
- Defines here
- none
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- galaxies-wafers@5814793812add74605660fa821e6a39b8de80588 iterations/26-apps-layers-substrate/index.html:1-59 · blob 5c74115092928d3125e76af8470b823726e7be41 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: unknown · users: none · canonical: unknown
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover, maximum-scale=5">
<meta name="color-scheme" content="dark">
<title>Apps, Layers, Substrate — the estate's apps as tabs over its numbered lines</title>
<link rel="icon" href="data:,">
<link rel="stylesheet" href="style.css">
</head>
<body>
<canvas id="stage" aria-label="Every permanently numbered line of code in the estate, placed by its own number."></canvas>
<header id="bar">
<span id="wordmark">APPS · LAYERS · SUBSTRATE</span>
<span id="count" class="dim">loading the numbered database…</span>
</header>
<nav id="apps" role="tablist" aria-label="apps of the estate, derived from the block register"></nav>
<section id="appcard" aria-live="polite">
<div id="apphead">
<button id="appfold" type="button" aria-label="fold the app card" aria-expanded="true">▾</button>
<h1 id="appname"></h1>
<label class="dim" id="depthlabel">group by
<select id="depth"><option value="1">top folder</option><option value="2">two folders</option></select>
</label>
</div>
<div id="appsrc"></div>
<div id="appbody"></div>
<div id="appmem" class="dim"></div>
</section>
<form id="beam" autocomplete="off">
<input id="a" inputmode="numeric" pattern="[0-9]*" placeholder="line number" aria-label="line number to fly to">
<input id="b" inputmode="numeric" pattern="[0-9]*" placeholder="connect to…" aria-label="second line number to connect to">
<button id="go" type="submit">FLY</button>
</form>
<section id="panel" hidden>
<button id="close" type="button" aria-label="close">✕</button>
<div id="panelbody"></div>
</section>
<footer id="foot">
<span id="prov" class="dim">provenance loading</span>
<span id="wake" class="dim">tick a layer to wake its lines</span>
<span id="hint" class="dim">drag to steer · pinch or scroll to focus the beam · tap a line</span>
<a id="proofs" href="../../proof/">check every claim on this page</a>
</footer>
<noscript><p class="dim" style="padding:1rem">This surface is drawn from the numbered database at run time, so it needs JavaScript. Nothing here is typed into the page.</p></noscript>
<script type="module" src="app.mjs"></script>
<script type="module" src="layers-panel.mjs"></script>
<script type="module" src="apps.mjs"></script>
</body>
</html>Queue
A JavaScript module in the iterations folder of Galaxies Wafers. Served with the page at https://ventusltd.github.io/galaxies-wafers/iterations/26-apps-layers-substrate/.
ingestgalaxies-wafers / iterations/26-apps-layers-substrate/queue.mjs · lines 1–56 of 56 · pattern fetchJSON (shared by 9 files)
- What it does
- It fetches data. Defines Unwanted, run, fetchJSON, forget, queueDepth. Side effects: makes network requests.
- Downstream impact
- Used directly by 2 files: Layers Panel (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/26-apps-layers-substrate/); Apps (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/26-apps-layers-substrate/). Reached from 1 other entry point, including Iterations — 26 Apps Layers Substrate Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/26-apps-layers-substrate/).
- What it achieves
- It fetches JSON (`fetchJSON`) and is built from the unwanted class (`Unwanted`) and the run step (`run`). One FetchQueue for every request this page makes after the substrate: layer files, the block register and page titles.
- Why it matters
- Imported by Layers Panel and Apps.
- Application
- galaxies-wafers · iterations/26-apps-layers-substrate · JavaScript module
- Uses
- none found
- Used by
- imported by Layers Panel (import), imported by Apps (import)
- Produces
- CONCURRENCY, TIMEOUT_MS, Unwanted, run, fetchJSON, forget, queueDepth
- Defines here
- Unwanted, run, fetchJSON, forget, queueDepth
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- galaxies-wafers@5814793812add74605660fa821e6a39b8de80588 iterations/26-apps-layers-substrate/queue.mjs:1-56 · blob 817d1cd9e754a2aa95fe7af40df4c4782d1d1bd2 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: ingest · effects: network · domain stage: unknown · users: none · canonical: unknown
/* queue.mjs — one FetchQueue for every request this page makes after the
* substrate: layer files, the block register and page titles. Learned from Grid
* Atlas (repd_grid_atlasv8 ventus-corev8engine.js, its FetchQueue and urlCache):
*
* CONCURRENCY 4. Never more than four requests in flight.
* TIMEOUT 15 s. Every request carries an AbortController; one that takes longer
* fails with that reason instead of holding a slot for ever.
* ONE PROMISE PER URL. Two layers backed by the same file, or a tap repeated
* while the file is on its way, share one request. A failed request is
* removed from the cache so a retry is possible; an evicted layer's file is
* removed too (forget), so eviction really frees the memory.
* WANTED AT THE DOOR. A job that waited carries a wanted() test asked when its
* slot opens: if the reader has moved to another app by then, it is dropped
* without touching the network.
*/
export const CONCURRENCY = 4;
export const TIMEOUT_MS = 15000;
let inFlight = 0;
const waiting = [];
const urlCache = new Map(); /* url -> Promise of parsed JSON */
export class Unwanted extends Error { constructor() { super('no longer wanted'); this.unwanted = true; } }
export async function run(job, wanted = () => true) {
if (inFlight >= CONCURRENCY) await new Promise(res => waiting.push(res));
inFlight++;
const ctl = new AbortController();
const timer = setTimeout(() => ctl.abort(), TIMEOUT_MS);
try {
if (!wanted()) throw new Unwanted();
return await job(ctl.signal);
} catch (e) {
if (ctl.signal.aborted && !e.unwanted) throw new Error(`no answer within ${TIMEOUT_MS / 1000} s`);
throw e;
} finally {
clearTimeout(timer);
inFlight--;
waiting.shift()?.();
}
}
/* JSON through the queue and the cache. failPrefix names an HTTP failure. */
export function fetchJSON(url, failPrefix = 'HTTP ', wanted = () => true) {
if (urlCache.has(url)) return urlCache.get(url);
const p = run(async signal => {
const r = await fetch(url, { cache: 'default', signal });
if (!r.ok) throw new Error(failPrefix + r.status);
return r.json();
}, wanted);
urlCache.set(url, p);
p.catch(() => { if (urlCache.get(url) === p) urlCache.delete(url); });
return p;
}
export const forget = url => urlCache.delete(url);
export const queueDepth = () => ({ inFlight, waiting: waiting.length, cached: urlCache.size });Iterations — 26 Apps Layers Substrate Style Sheet
A style sheet in Galaxies Wafers. Served with the page at https://ventusltd.github.io/galaxies-wafers/iterations/26-apps-layers-substrate/.
rendergalaxies-wafers / iterations/26-apps-layers-substrate/style.css · lines 1–147 of 147 · Entry point
- What it does
- Side effects: changes the web page (DOM).
- Downstream impact
- Used directly by 1 file: Iterations — 26 Apps Layers Substrate Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/26-apps-layers-substrate/). It is itself an entry point, published at https://ventusltd.github.io/galaxies-wafers/iterations/26-apps-layers-substrate/.
- What it achieves
- The Line Wafer. Designed at 430 px first; the desktop is the same layout with more room.
- Why it matters
- Loaded by the 26 Apps Layers Substrate page at https://ventusltd.github.io/galaxies-wafers/iterations/26-apps-layers-substrate/.
- Application
- galaxies-wafers · iterations/26-apps-layers-substrate · style sheet
- Uses
- none found
- Used by
- loaded by Iterations — 26 Apps Layers Substrate Page (stylesheet)
- Produces
- none declared
- Defines here
- none
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- galaxies-wafers@5814793812add74605660fa821e6a39b8de80588 iterations/26-apps-layers-substrate/style.css:1-147 · blob 033dd620ec62541eaeeafdb7f7caed99a00dbf24 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: unknown · users: none · canonical: unknown
/* The Line Wafer. Designed at 430 px first; the desktop is the same layout with
more room. One canvas, three chrome strips, nothing that scrolls the page. */
:root{
--ink:#d8dee9; --dim:#8b93a7; --ground:#0b0d12; --edge:#1b2030;
--lit:#ffd54a; --beam:#5ec8f2;
--top:env(safe-area-inset-top,0px); --bot:env(safe-area-inset-bottom,0px);
}
*{box-sizing:border-box}
html,body{height:100%}
body{
margin:0; background:var(--ground); color:var(--ink);
font:13px/1.45 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
overflow:hidden; overscroll-behavior:none; -webkit-text-size-adjust:100%;
}
#stage{position:fixed; inset:0; width:100%; height:100%; display:block; touch-action:none}
#bar{
position:fixed; left:0; right:0; top:0; z-index:2;
display:flex; gap:.75rem; align-items:baseline; flex-wrap:wrap;
padding:calc(var(--top) + .5rem) .75rem .5rem;
background:linear-gradient(#0b0d12ee,#0b0d1200); pointer-events:none;
}
#wordmark{letter-spacing:.14em; font-size:11px}
.dim{color:var(--dim)}
#beam{
position:fixed; z-index:3; left:.5rem; right:.5rem;
bottom:calc(var(--bot) + 3.4rem);
display:flex; gap:.4rem;
}
#beam input{
flex:1 1 0; min-width:0; padding:.6rem .55rem;
background:#11151f; color:var(--ink); border:1px solid var(--edge); border-radius:6px;
font:inherit; font-size:16px; /* 16px stops iOS zooming the page on focus */
}
#beam input:focus{outline:none; border-color:var(--beam)}
#beam button{
flex:0 0 auto; padding:.6rem .9rem; border-radius:6px; cursor:pointer;
background:#11151f; color:var(--beam); border:1px solid var(--beam);
font:inherit; font-size:13px; letter-spacing:.1em;
}
#beam button:active{background:#16202c}
#panel{
position:fixed; z-index:4; left:.5rem; right:.5rem;
bottom:calc(var(--bot) + 6.6rem);
max-height:52vh; overflow:auto; -webkit-overflow-scrolling:touch;
background:#0e121bf2; border:1px solid var(--edge); border-radius:8px;
padding:.75rem .8rem 1rem;
}
#panel[hidden]{display:none!important}
#close{
position:absolute; top:.35rem; right:.4rem; width:2rem; height:2rem;
background:none; border:0; color:var(--dim); font:inherit; font-size:15px; cursor:pointer;
}
#panel h2{margin:0 .5rem .5rem 0; font-size:15px; font-weight:600; letter-spacing:.02em}
#panel h2 .n{color:var(--lit)}
#panel dl{display:grid; grid-template-columns:auto 1fr; gap:.15rem .6rem; margin:.5rem 0}
#panel dt{color:var(--dim)}
#panel dd{margin:0; overflow-wrap:anywhere}
#panel p{margin:.5rem 0 0}
#panel ul{margin:.35rem 0 0; padding-left:1.1rem}
#panel li{margin:.15rem 0}
.fam{color:var(--beam)}
.refuse{color:var(--lit)}
#foot{
position:fixed; z-index:2; left:0; right:0; bottom:0;
display:flex; gap:.15rem; flex-direction:column;
padding:.35rem .75rem calc(var(--bot) + .35rem);
background:linear-gradient(#0b0d1200,#0b0d12ee); pointer-events:none;
font-size:10.5px;
}
#hint{text-align:left}
#foot a{color:var(--beam); pointer-events:auto; text-decoration:underline}
@media (min-width:760px){
#beam{left:auto; right:1rem; width:26rem; bottom:calc(var(--bot) + 2.9rem)}
#foot{flex-direction:row; gap:.6rem; justify-content:space-between}
#hint{text-align:right}
#panel{left:1rem; right:auto; width:26rem; bottom:calc(var(--bot) + 2.5rem); max-height:66vh}
#foot{font-size:11px}
}
/* Dark Pixels: the wake line reads a little brighter than the other footer text */
#wake{color:var(--ink)}
/* the footer carries a third line here, so on a phone the form and panel sit one line higher */
@media (max-width:759px){
#beam{bottom:calc(var(--bot) + 5.4rem)}
#panel{bottom:calc(var(--bot) + 8.6rem); max-height:44vh}
}
/* ── Apps, Layers, Substrate (iteration 26) ───────────────────────────────
Tabs after the chip rows of the Quantum Twin Star page; the LAYERS button
moves up into the bar, to the right, as Grid Atlas keeps its layer control
apart from its content. */
#bar{flex-wrap:nowrap; padding-right:6.2rem; white-space:nowrap; overflow:hidden}
#count{overflow:hidden; text-overflow:ellipsis; min-width:0}
#layers{top:calc(env(safe-area-inset-top,0px) + .3rem) !important}
#apps{
position:fixed; z-index:3; left:0; right:0; top:calc(var(--top) + 2.2rem);
display:flex; gap:.35rem; overflow-x:auto; overflow-y:hidden; -webkit-overflow-scrolling:touch;
padding:.25rem .75rem .35rem; scrollbar-width:thin; scroll-snap-type:x proximity;
}
.tab{
flex:0 0 auto; max-width:16rem; scroll-snap-align:start;
display:flex; align-items:baseline; gap:.1rem;
background:#0e121b; color:var(--ink); border:1px solid var(--edge); border-radius:999px;
padding:.4rem .75rem; font:inherit; font-size:12px; cursor:pointer;
}
.tab .tname{overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.tab .tcount{color:var(--dim); font-size:10.5px}
.tab[aria-selected="true"]{border-color:var(--beam); color:var(--beam); background:#0f1c26}
#appcard{
position:fixed; z-index:3; left:.5rem; right:.5rem; top:calc(var(--top) + 4.75rem);
max-height:36vh; overflow:auto; -webkit-overflow-scrolling:touch;
background:#0e121bee; border:1px solid var(--edge); border-radius:8px; padding:.45rem .6rem .5rem;
font-size:11.5px;
}
#apphead{display:flex; gap:.4rem; align-items:baseline}
#appfold{background:none; border:0; color:var(--dim); font:inherit; font-size:13px; cursor:pointer; padding:0 .2rem}
#appname{flex:1; margin:0; font-size:13.5px; font-weight:600; color:var(--ink); overflow-wrap:anywhere}
#depthlabel{font-size:10.5px; white-space:nowrap}
#depth{background:#11151f; color:var(--ink); border:1px solid var(--edge); border-radius:4px; font:inherit; font-size:10.5px}
#appsrc{margin:.15rem 0 .2rem; overflow-wrap:anywhere}
.alink{color:var(--beam)}
.acounts{color:var(--ink); margin:.15rem 0 .3rem}
#appbody[hidden]{display:none!important}
#appbody details{border-top:1px solid var(--edge); padding-top:.25rem; margin-top:.25rem}
#appbody summary{cursor:pointer; color:var(--dim); letter-spacing:.08em; font-size:10.5px; text-transform:uppercase}
.arow{margin:.2rem 0}
.asym{color:var(--lit); font-weight:700}
.atitle{color:var(--ink)}
.arow .ltag{margin-left:.35rem; font-size:10.5px}
.awhy{color:var(--dim); font-size:10.5px; margin-left:1rem; overflow-wrap:anywhere}
.ltag.WAIT{color:#8b93a7}.ltag.LOAD{color:#ffd54a}.ltag.OK{color:#7fd6a2}
.ltag.EMPTY{color:#b39ddb}.ltag.FAIL{color:#ff8a80}
.qa{margin:.3rem 0}
.qq{color:var(--beam)}
.qans{color:var(--ink); overflow-wrap:anywhere}
.qa.machine{font-size:10.5px}
.qa.machine .qq{color:var(--lit)}
@media (min-width:760px){
#appcard{right:auto; width:30rem; max-height:calc(100vh - 12rem)}
}
#appmem{font-size:10px;margin-top:.2rem}Hazards
A style sheet in the iterations folder of Galaxies Wafers. Served with the page at https://ventusltd.github.io/galaxies-wafers/iterations/27-earth-radii-and-argument-order/.
rendergalaxies-wafers / iterations/27-earth-radii-and-argument-order/hazards.css · lines 1–56 of 56 · Entry point
- What it does
- Side effects: changes the web page (DOM).
- Downstream impact
- Used directly by 1 file: Iterations — 27 Earth Radii and Argument Order Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/27-earth-radii-and-argument-order/). It is itself an entry point, published at https://ventusltd.github.io/galaxies-wafers/iterations/27-earth-radii-and-argument-order/.
- What it achieves
- No statement of purpose was found in the file, a README line naming it, or its name.
- Why it matters
- Loaded by the 27 Earth Radii and Argument Order page at https://ventusltd.github.io/galaxies-wafers/iterations/27-earth-radii-and-argument-order/.
- Application
- galaxies-wafers · iterations/27-earth-radii-and-argument-order · style sheet
- Uses
- none found
- Used by
- loaded by Iterations — 27 Earth Radii and Argument Order Page (stylesheet)
- Produces
- none declared
- Defines here
- none
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- galaxies-wafers@5814793812add74605660fa821e6a39b8de80588 iterations/27-earth-radii-and-argument-order/hazards.css:1-56 · blob 150fec85a8141cff097d983e9999ce5f9ff7e213 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: dom · domain stage: unknown · users: none · canonical: unknown
:root{--ink:#d8dee9;--dim:#8b93a7;--ground:#0b0d12;--edge:#1b2030;--lit:#ffd54a;--beam:#5ec8f2;--swap:#ff9f40;--mean:#b48cff}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{margin:0;background:var(--ground);color:var(--ink);font:13px/1.45 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
padding:calc(env(safe-area-inset-top,0px) + .8rem) 1rem calc(env(safe-area-inset-bottom,0px) + 2rem)}
main{max-width:72rem;margin:0 auto}
h1{font-size:13px;letter-spacing:.16em;font-weight:600;margin:0 0 .3rem}
h2{font-size:11px;letter-spacing:.14em;font-weight:400;color:var(--dim);margin:1.1rem 0 .4rem}
.dim{color:var(--dim)} .small{font-size:11.5px}
a{color:var(--beam)}
.mods{margin:.5rem 0 0;display:flex;flex-wrap:wrap;gap:.3rem .8rem;font-size:11.5px}
.mods span b{font-weight:600}
.boundary{border:1px solid var(--edge);border-left:3px solid #ffffff;background:#10131b;padding:.5rem .6rem;margin:.6rem 0;font-size:11.5px}
canvas{display:block;width:100%;background:#07080c;border:1px solid var(--edge);border-radius:.4rem;touch-action:pan-y;margin:.4rem 0}
#map{cursor:crosshair}
#radii{height:250px} #gap{height:210px}
.seg{display:flex;flex-wrap:wrap;gap:.35rem;margin-top:.35rem}
.seg button{font:inherit;color:var(--ink);background:#07080c;border:1px solid var(--edge);border-radius:.35rem;padding:.45rem .6rem;min-height:40px;min-width:3.2rem}
.seg button[aria-pressed=true]{border-color:#fff;box-shadow:inset 0 0 0 1px #fff}
.presets button{font-size:11.5px;text-align:left}
.key{display:flex;flex-wrap:wrap;gap:.2rem .9rem;color:var(--dim)}
.key i{display:inline-block;width:1.4rem;height:0;border-top:2px solid;vertical-align:middle;margin-right:.3rem}
.key i.dash{border-top-style:dashed}
.coords{display:grid;grid-template-columns:auto 1fr;gap:.1rem .6rem;margin:.3rem 0}
.coords b{font-weight:600}
.in{border:1px solid var(--edge);border-radius:.4rem;padding:.45rem .6rem;background:#10131b}
.in .row{display:flex;justify-content:space-between;gap:.5rem;align-items:baseline}
.in .tag{font-size:10px;letter-spacing:.1em;color:var(--dim)}
.in output{color:var(--lit);font-weight:600}
.in input[type=range]{width:100%;height:36px;margin:.1rem 0 0;accent-color:#ffffff}
.results{list-style:none;margin:0;padding:0;display:grid;gap:.4rem}
.results li{border:1px solid var(--edge);border-left:3px solid var(--c,var(--edge));border-radius:.4rem;padding:.45rem .6rem;background:#10131b}
.results .k{display:flex;justify-content:space-between;gap:.5rem;flex-wrap:wrap}
.results .v{color:var(--lit);font-weight:600;text-align:right;overflow-wrap:anywhere}
.results .fn{font-size:10.5px;color:var(--beam);overflow-wrap:anywhere}
.results .basis{font-size:11px;color:var(--dim);margin-top:.2rem}
.results li.empty{border-style:dashed}
.results li.empty .v{color:var(--ink);font-weight:400}
.pair{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:.5rem}
.pair blockquote{margin:0;border:1px solid var(--edge);border-radius:.4rem;padding:.45rem .55rem;background:#10131b;font-size:11px}
.pair p{margin:.25rem 0 .5rem}
.pair .who{color:var(--beam);font-size:10.5px;overflow-wrap:anywhere}
footer{margin-top:1.4rem}
@media (min-width:900px){
.cols{display:grid;grid-template-columns:minmax(0,1.2fr) minmax(0,1fr);gap:1.4rem;align-items:start}
.mapcol{position:sticky;top:.8rem}
#radii{height:280px}
}
.questions{border:1px solid var(--edge);border-radius:.4rem;background:#10131b;margin:1.1rem 0 .5rem;padding:0 .6rem}
.questions summary{cursor:pointer;min-height:40px;display:flex;align-items:center;color:var(--beam);letter-spacing:.1em}
.qa{margin:0 0 .6rem;padding-left:1.1rem}
.qa li{margin:.45rem 0}
.qa b{color:var(--ink)}
.qa .live{color:var(--lit)}
.machine{border-top:1px solid var(--edge);padding-top:.4rem;color:var(--dim);overflow-wrap:anywhere}
.machine b{color:var(--ink);font-weight:600}Hazards
A JavaScript module in Galaxies Wafers that paints mods and controls, wraps lon, calculates great-circle distances and draws on a canvas. Served with the page at https://ventusltd.github.io/galaxies-wafers/iterations/27-earth-radii-and-argument-order/.
geodesygalaxies-wafers / iterations/27-earth-radii-and-argument-order/hazards.mjs · lines 1–382 of 483 · Entry point · pattern paintResults (shared by 2 files)
- What it does
- It draws cables. Defines 38 functions or classes, including $, el, nf, fmtLen, fmtLat. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain terms in the code: cables.
- Inputs & outputs
- Out: canvas drawing.
- Downstream impact
- Used directly by 1 file: Iterations — 27 Earth Radii and Argument Order Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/27-earth-radii-and-argument-order/). It is itself an entry point, published at https://ventusltd.github.io/galaxies-wafers/iterations/27-earth-radii-and-argument-order/.
- What it achieves
- It paints mods (`paintMods`), paints controls (`paintControls`) and maps projection (`mapProjection`). Two Hazards on One Map — Earth radii and argument order, charted from the engine's own geodesy. It responds to click, input and resize events.
- Why it matters
- Loaded by the 27 Earth Radii and Argument Order page at https://ventusltd.github.io/galaxies-wafers/iterations/27-earth-radii-and-argument-order/.
- Application
- galaxies-wafers · iterations/27-earth-radii-and-argument-order · JavaScript module
- Uses
- none found
- Used by
- loaded by Iterations — 27 Earth Radii and Argument Order Page (script src)
- Produces
- $, el, nf, fmtLen, fmtLat, fmtLon, fmtPt, paintMods, dFromT, seg, paintControls, fit
- Defines here
- $, el, nf, fmtLen, fmtLat, fmtLon, fmtPt, paintMods, dFromT, seg, paintControls, fit, textHalo, emptyCanvas, mapProjection, wrapLon, gcPath, drawPoly, strokePath, marker, drawMap, out, k, rnd, compute, drawRadii, yOf, drawGap, X, Y
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- galaxies-wafers@5814793812add74605660fa821e6a39b8de80588 iterations/27-earth-radii-and-argument-order/hazards.mjs:1-382 · blob cf91f31e5bfd0eda3b8141da655f2497dbcda735 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: unknown · users: none · canonical: unknown
/* Two Hazards on One Map — Earth radii and argument order, charted from the
engine's own geodesy. No distance formula is written in this file: every
distance, bearing, arc point and corridor length is returned by
ventus-grid-engine at the pinned commit. The page projects (plain
equirectangular) and draws. */
const COMMIT = 'd9cd18b0e2034325814924e6e4a0e958014f2748';
const ENGINE = `https://cdn.jsdelivr.net/gh/Ventusltd/ventus-grid-engine@${COMMIT}/engine/`;
const MODULES = ['geo-core.js', 'v9-geodesy.js', 'corridor-estimate.js'];
const COL = { correct: '#5ec8f2', swapped: '#ff9f40', leg: '#ffffff', R_MEAN: '#b48cff', R_ATLAS: '#ffffff', R_UK: '#5ec8f2', EARTH_RADIUS_KM: '#ffffff' };
const $ = id => document.getElementById(id);
const el = (tag, cls, text) => { const e = document.createElement(tag); if (cls) e.className = cls; if (text != null) e.textContent = text; return e; };
const nf = (v, sig = 4) => Number(v).toLocaleString('en-GB', { maximumSignificantDigits: sig });
/* ── lengths: one formatter, SI steps ───────────────────────────────────── */
function fmtLen(km, sig = 6) {
if (km == null) return String(km);
if (!Number.isFinite(km)) return String(km);
const m = Number((Math.abs(km) * 1000).toPrecision(Math.min(sig + 2, 17))), s = km < 0 ? '−' : ''; // round before choosing the unit
if (m === 0) return '0 m';
if (m >= 1000) return s + nf(m / 1000, sig) + ' km';
if (m >= 1) return s + nf(m, sig) + ' m';
if (m >= 1e-3) return s + nf(m * 1e3, sig) + ' mm';
return s + nf(m * 1e6, sig) + ' µm';
}
const fmtLat = v => `${nf(Math.abs(v), 6)}°${v < 0 ? 'S' : 'N'}`;
const fmtLon = v => `${nf(Math.abs(v), 6)}°${v < 0 ? 'W' : v > 0 ? 'E' : ''}`;
const fmtPt = p => `${fmtLat(p.lat)} ${fmtLon(p.lon)}`;
/* ── modules, Grid Atlas grammar; three files at once, the queue cap ─────── */
const mod = {};
const modState = Object.fromEntries(MODULES.map(m => [m, 'WAIT']));
function paintMods() {
const box = $('mods'); box.textContent = '';
for (const m of MODULES) {
const st = modState[m], sp = st.indexOf(' ');
const s = el('span'); const b = el('b', null, sp < 0 ? st : st.slice(0, sp));
s.append(b, ` engine/${m}` + (sp < 0 ? '' : ' — ' + st.slice(sp + 1)));
box.append(s);
}
for (const p of document.querySelectorAll('.pin')) p.textContent = COMMIT.slice(0, 12);
}
paintMods();
/* ── state ───────────────────────────────────────────────────────────────── */
const logD = { lo: 1e-3, hi: 1e3 }; // km: the scenario range, 1 m to 1,000 km
const dFromT = t => logD.lo * Math.pow(logD.hi / logD.lo, t / 1000);
const PRESETS = [
[{ lat: 56.05, lon: -2.35 }, { lat: 51.5, lon: -0.1 }],
[{ lat: 60, lon: 0 }, { lat: 60, lon: 1 }],
[{ lat: 0, lon: 0 }, { lat: 1, lon: 0 }],
[{ lat: 58.5, lon: -3.1 }, { lat: 50.1, lon: -5.5 }],
[{ lat: 40.7, lon: -74 }, { lat: 51.5, lon: -0.1 }],
[{ lat: 51.5, lon: -0.1 }, { lat: 35.7, lon: 139.7 }]
];
const VIEWS = {
world: { label: 'WORLD', lon: [-180, 180], lat: [-90, 90], major: 30, minor: 10, snap: 0.1 },
gb: { label: 'GB BOX', lon: [-12, 5], lat: [49, 60.5], major: 5, minor: 1, snap: 0.01 }
};
const S = { t: +$('in-d').value, A: { ...PRESETS[0][0] }, B: { ...PRESETS[0][1] }, next: 'A', view: 'world', preset: 0 };
/* ── controls ────────────────────────────────────────────────────────────── */
function seg(box, items, isOn, onTap) {
if (box.childElementCount !== items.length) {
box.textContent = '';
for (const it of items) {
const b = el('button', null, it.label); b.type = 'button'; b.dataset.v = it.v;
b.addEventListener('click', () => onTap(it.v));
box.append(b);
}
}
for (const b of box.children) b.setAttribute('aria-pressed', String(isOn(b.dataset.v)));
}
function paintControls() {
seg($('views'), Object.entries(VIEWS).map(([v, o]) => ({ v, label: o.label })), v => S.view === v, v => { S.view = v; update(); });
seg($('nexts'), [{ v: 'A', label: 'NEXT TAP SETS A' }, { v: 'B', label: 'NEXT TAP SETS B' }], v => S.next === v, v => { S.next = v; paintControls(); });
seg($('presets'), PRESETS.map((p, i) => ({ v: String(i), label: `${fmtPt(p[0])} → ${fmtPt(p[1])}` })),
v => S.preset === +v, v => { const p = PRESETS[+v]; S.A = { ...p[0] }; S.B = { ...p[1] }; S.preset = +v; update(); });
}
$('in-d').addEventListener('input', e => { S.t = +e.target.value; update(); });
/* ── canvas helpers ──────────────────────────────────────────────────────── */
function fit(cv, cssH) {
const dpr = Math.min(window.devicePixelRatio || 1, 3);
if (cssH != null) cv.style.height = cssH + 'px';
const w = cv.clientWidth, h = cv.clientHeight;
if (cv.width !== Math.round(w * dpr) || cv.height !== Math.round(h * dpr)) { cv.width = Math.round(w * dpr); cv.height = Math.round(h * dpr); }
const g = cv.getContext('2d'); g.setTransform(dpr, 0, 0, dpr, 0, 0); g.clearRect(0, 0, w, h);
return { g, w, h };
}
function textHalo(g, s, x, y, color, align = 'left') {
g.textAlign = align; g.lineWidth = 3; g.strokeStyle = '#07080c'; g.strokeText(s, x, y); g.fillStyle = color; g.fillText(s, x, y);
}
function emptyCanvas(g, text) {
g.fillStyle = '#8b93a7'; g.font = '12px ui-monospace,Menlo,Consolas,monospace'; g.textAlign = 'left';
g.fillText('EMPTY', 10, 22); g.fillText(text.slice(0, 52), 10, 40);
}
/* ── the map ─────────────────────────────────────────────────────────────── */
let proj = null;
function mapProjection(w) {
const v = VIEWS[S.view];
const midLat = (v.lat[0] + v.lat[1]) / 2;
const k = S.view === 'world' ? 1 : Math.cos(midLat * Math.PI / 180); // stated in the key
const lonSpan = v.lon[1] - v.lon[0], latSpan = v.lat[1] - v.lat[0];
const h = Math.max(160, Math.min(Math.round(w * latSpan / (lonSpan * k)), Math.round(window.innerHeight * 0.7)));
const ppd = Math.min(w / (lonSpan * k), h / latSpan); // px per degree of latitude
const cLon = (v.lon[0] + v.lon[1]) / 2;
return {
v, k, h, w,
x: lon => w / 2 + (lon - cLon) * ppd * k,
y: lat => h / 2 - (lat - midLat) * ppd,
lonAt: px => cLon + (px - w / 2) / (ppd * k),
latAt: py => midLat - (py - h / 2) / ppd
};
}
const wrapLon = l => ((l + 540) % 360 + 360) % 360 - 180;
/* Great-circle points from the module: bearing from initialBearingDeg, points
from destinationPoint, total length from distanceKm. */
function gcPath(a, b, n = 96) {
const g = mod['v9-geodesy.js'];
const D = g.distanceKm(a.lon, a.lat, b.lon, b.lat);
if (!Number.isFinite(D)) return null;
const brg = g.initialBearingDeg(a.lon, a.lat, b.lon, b.lat);
const pts = [];
for (let i = 0; i <= n; i++) {
const p = i === 0 ? [a.lon, a.lat] : g.destinationPoint(a.lon, a.lat, D * i / n, brg);
pts.push([wrapLon(p[0]), p[1]]);
}
return pts;
}
function drawPoly(g, P, pts) {
g.beginPath();
let prev = null;
for (const [lon, lat] of pts) {
const X = P.x(lon), Y = P.y(lat);
if (prev == null || Math.abs(lon - prev) > 180) g.moveTo(X, Y); else g.lineTo(X, Y);
prev = lon;
}
}
function strokePath(g, P, pts, color, dash) {
g.save(); g.setLineDash(dash || []);
g.lineWidth = 5; g.strokeStyle = 'rgba(0,0,0,0.6)'; drawPoly(g, P, pts); g.stroke();
g.lineWidth = 2; g.strokeStyle = color; drawPoly(g, P, pts); g.stroke(); g.restore();
}
function marker(g, P, p, label, color, hollow) {
const X = P.x(p.lon), Y = P.y(p.lat);
g.beginPath(); g.arc(X, Y, 5, 0, 7); g.lineWidth = 3; g.strokeStyle = '#07080c'; g.stroke();
g.lineWidth = 1.6; g.strokeStyle = color; g.stroke();
if (!hollow) { g.fillStyle = color; g.fill(); }
g.font = '600 11px ui-monospace,Menlo,Consolas,monospace';
textHalo(g, label, X + 8, Y - 7, color);
}
function drawMap(model) {
const cv = $('map');
const w = cv.clientWidth;
const P = proj = mapProjection(w);
const { g, h } = fit(cv, P.h);
const lon0 = P.lonAt(0), lon1 = P.lonAt(w), lat0 = P.latAt(h), lat1 = P.latAt(0);
const L0 = Math.max(lon0, -180), L1 = Math.min(lon1, 180), B0 = Math.max(lat0, -90), B1 = Math.min(lat1, 90);
g.lineWidth = 1;
for (const step of [P.v.minor, P.v.major]) {
g.strokeStyle = step === P.v.major ? '#2a3146' : '#151a26';
for (let lon = Math.ceil(L0 / step) * step; lon <= L1; lon += step) { g.beginPath(); g.moveTo(P.x(lon), P.y(B1)); g.lineTo(P.x(lon), P.y(B0)); g.stroke(); }
for (let lat = Math.ceil(B0 / step) * step; lat <= B1; lat += step) { g.beginPath(); g.moveTo(P.x(L0), P.y(lat)); g.lineTo(P.x(L1), P.y(lat)); g.stroke(); }
}
g.strokeStyle = '#3a4360';
if (B0 <= 0 && B1 >= 0) { g.beginPath(); g.moveTo(P.x(L0), P.y(0)); g.lineTo(P.x(L1), P.y(0)); g.stroke(); }
if (L0 <= 0 && L1 >= 0) { g.beginPath(); g.moveTo(P.x(0), P.y(B1)); g.lineTo(P.x(0), P.y(B0)); g.stroke(); }
g.font = '10px ui-monospace,Menlo,Consolas,monospace'; g.fillStyle = '#5c6580';
g.textAlign = 'center';
for (let lon = Math.ceil(L0 / P.v.major) * P.v.major; lon <= L1; lon += P.v.major) if (lon > L0 && lon < L1) g.fillText(fmtLon(lon), P.x(lon), h - 4);
g.textAlign = 'left';
for (let lat = Math.ceil(B0 / P.v.major) * P.v.major; lat <= B1; lat += P.v.major) if (lat > B0 && lat < B1) g.fillText(fmtLat(lat), 3, P.y(lat) - 3);
const notes = [];
if (model.ok) {
const o = model.order;
if (o.swapPts) strokePath(g, P, o.swapPts, COL.swapped, [6, 4]);
if (o.pts) strokePath(g, P, o.pts, COL.correct);
if (model.radii.legPts) strokePath(g, P, model.radii.legPts, COL.leg);
if (o.swapDrawable) { marker(g, P, o.Aswap, 'A′', COL.swapped, true); marker(g, P, o.Bswap, 'B′', COL.swapped, true); }
const out = p => p.lon < lon0 || p.lon > lon1 || p.lat < lat0 || p.lat > lat1;
const offView = o.swapDrawable ? [o.Aswap, o.Bswap].filter(out).length : 0;
if (offView) notes.push(`${offView} of the swapped points A′, B′ lie outside this view; WORLD shows them.`);
if (!o.swapDrawable) notes.push('Swapped arc EMPTY: a longitude beyond ±90° read as a latitude is not a point on the globe.');
} else {
notes.push('Arcs EMPTY: ' + emptyReason());
}
marker(g, P, S.A, 'A', '#ffffff'); marker(g, P, S.B, 'B', '#ffffff');
const key = $('mapkey'); key.textContent = '';
const k = (c, dash, t) => { const s = el('span'); const i = el('i', dash ? 'dash' : ''); i.style.borderColor = c; s.append(i, t); key.append(s); };
k(COL.correct, false, 'documented call (lon, lat), A to B');
k(COL.swapped, true, 'swapped call (lat, lon): the arc it measures, A′ to B′');
k(COL.leg, false, 'radii scenario leg from A');
key.append(el('span', null, S.view === 'world'
? 'equirectangular: 1° of longitude drawn as wide as 1° of latitude'
: `equirectangular: longitude compressed by cos(${nf((P.v.lat[0] + P.v.lat[1]) / 2, 4)}°) = ${nf(P.k, 4)}`));
for (const n of notes) key.append(el('span', null, n));
$('coords').textContent = '';
for (const [n, p] of [['A', S.A], ['B', S.B]]) { $('coords').append(el('b', null, n), el('span', null, `${fmtPt(p)} · lon ${p.lon}, lat ${p.lat}`)); }
}
$('map').addEventListener('click', e => {
if (!proj) return;
const r = e.currentTarget.getBoundingClientRect();
const snap = proj.v.snap;
const rnd = v => Math.round(v / snap) * snap;
const lon = Math.max(-180, Math.min(180, rnd(proj.lonAt(e.clientX - r.left))));
const lat = Math.max(-90, Math.min(90, rnd(proj.latAt(e.clientY - r.top))));
S[S.next] = { lat: +lat.toFixed(4), lon: +lon.toFixed(4) };
S.next = S.next === 'A' ? 'B' : 'A';
S.preset = -1;
update();
});
/* ── compute: every number below is a module call ────────────────────────── */
function compute() {
const gc = mod['geo-core.js'], v9 = mod['v9-geodesy.js'], ce = mod['corridor-estimate.js'];
if (!gc || !v9) return { ok: false };
const d = dFromT(S.t);
const { A, B } = S;
const same = A.lat === B.lat && A.lon === B.lon;
const brg = same ? 0 : v9.initialBearingDeg(A.lon, A.lat, B.lon, B.lat);
const E = v9.destinationPoint(A.lon, A.lat, d, brg);
const end = { lon: E[0], lat: E[1] };
/* The radius constants, as the modules name them. */
const named = [
{ name: 'R_MEAN', file: 'geo-core.js', R: gc.R_MEAN },
{ name: 'R_ATLAS', file: 'geo-core.js', R: gc.R_ATLAS },
{ name: 'R_UK', file: 'geo-core.js', R: gc.R_UK },
{ name: 'EARTH_RADIUS_KM', file: 'geo-core.js', R: gc.EARTH_RADIUS_KM },
{ name: 'EARTH_RADIUS_KM', file: 'v9-geodesy.js', R: v9.EARTH_RADIUS_KM }
];
const ref = gc.haversine(A.lon, A.lat, end.lon, end.lat); // haversine's default radius
const rows = [
{ key: 'R_MEAN', label: 'R_MEAN · geo-core.js', fn: 'haversine(A, E, R_MEAN)', R: gc.R_MEAN, km: gc.haversine(A.lon, A.lat, end.lon, end.lat, gc.R_MEAN) },
{ key: 'R_ATLAS', label: 'R_ATLAS · geo-core.js · the default', fn: 'haversine(A, E)', R: gc.R_ATLAS, km: ref },
{ key: 'EARTH_RADIUS_KM', label: 'EARTH_RADIUS_KM · v9-geodesy.js', fn: 'distanceKm(A, E)', R: v9.EARTH_RADIUS_KM, km: v9.distanceKm(A.lon, A.lat, end.lon, end.lat) },
{ key: 'R_UK', label: 'R_UK · geo-core.js', fn: 'haversineUK(A, E)', R: gc.R_UK, km: gc.haversineUK(A.lon, A.lat, end.lon, end.lat) }
].map(r => ({ ...r, diffKm: r.km - ref, ppm: ref > 0 ? (r.km / ref - 1) * 1e6 : NaN }));
const distinct = [...new Set(named.map(n => n.R))].sort((a, b) => a - b);
/* Difference against leg length, sampled with the same module calls. */
const probe = { lon: 0, lat: 54 };
const curve = [];
for (let i = 0; i <= 60; i++) {
const dk = dFromT(i * 1000 / 60);
const q = v9.destinationPoint(probe.lon, probe.lat, dk, 90);
const base = gc.haversine(probe.lon, probe.lat, q[0], q[1]);
curve.push({ d: dk, mean: gc.haversine(probe.lon, probe.lat, q[0], q[1], gc.R_MEAN) - base, uk: gc.haversineUK(probe.lon, probe.lat, q[0], q[1]) - base });
}
/* Argument order. */
const correct = gc.haversine(A.lon, A.lat, B.lon, B.lat);
const swapped = gc.haversine(A.lat, A.lon, B.lat, B.lon);
const correct9 = v9.distanceKm(A.lon, A.lat, B.lon, B.lat);
const swapped9 = v9.distanceKm(A.lat, A.lon, B.lat, B.lon);
const Aswap = { lon: A.lat, lat: A.lon }, Bswap = { lon: B.lat, lat: B.lon };
const swapDrawable = Math.abs(A.lon) <= 90 && Math.abs(B.lon) <= 90;
const order = {
correct, swapped, correct9, swapped9, Aswap, Bswap, swapDrawable,
ratio: correct > 0 && Number.isFinite(swapped) ? swapped / correct : null,
pts: same ? null : gcPath(A, B),
swapPts: swapDrawable && !(Aswap.lat === Bswap.lat && Aswap.lon === Bswap.lon) ? gcPath(Aswap, Bswap) : null
};
/* Where a straight-line km goes next: the cable corridor estimate. */
const corridor = ce ? {
documented: ce.forCable(correct), swapped: ce.forCable(swapped),
legAtlas: ce.forCable(ref), legUK: ce.forCable(rows[3].km), legMean: ce.forCable(rows[0].km)
} : null;
return {
ok: true, d,
radii: { A, bearing: brg, end, rows, named, distinct, curve, probe, legPts: gcPath(A, end, 48), same },
order, corridor
};
}
/* ── hazard 1 drawing ────────────────────────────────────────────────────── */
function drawRadii(m) {
const cv = $('radii'); const { g, w, h } = fit(cv);
const key = $('radiikey');
if (w < 120 || h < 120) return; // not laid out yet; the next frame draws it
if (!m.ok) { emptyCanvas(g, emptyReason()); key.textContent = ''; return; }
const vals = m.radii.distinct;
const rmin = vals[0], rmax = vals[vals.length - 1], span = rmax - rmin || 1;
const lo = rmin - span * 0.45, hi = rmax + span * 0.3;
const top = 26, bottom = h - 18, band = bottom - top;
const yOf = r => bottom - (r - lo) / (hi - lo) * band;
const Rpx = w * 2.2; // drawn curvature radius of the reference arc, px
const ref = mod['geo-core.js'].R_ATLAS;
const cx = w / 2, cy = yOf(ref) + Rpx;
const half = Math.asin(Math.min(1, (w / 2 + 10) / Rpx));
const wedge = 0.1; // drawn half-angle of the wedge, radians
const mag = (band / (hi - lo)) / (Rpx / ref);
g.fillStyle = 'rgba(94,200,242,0.07)';
g.beginPath(); g.moveTo(cx, cy); g.arc(cx, cy, cy - top + 4, -Math.PI / 2 - wedge, -Math.PI / 2 + wedge); g.closePath(); g.fill();
g.font = '10.5px ui-monospace,Menlo,Consolas,monospace';
const byR = new Map();
for (const r of m.radii.rows) { if (!byR.has(r.R)) byR.set(r.R, []); byR.get(r.R).push(r); }
for (const [R, rs] of byR) {
const rad = cy - yOf(R), color = COL[rs[0].key];
g.strokeStyle = color; g.lineWidth = 1.2; g.globalAlpha = 0.55;
g.beginPath(); g.arc(cx, cy, rad, -Math.PI / 2 - half, -Math.PI / 2 + half); g.stroke();
g.globalAlpha = 1; g.lineWidth = 4;
g.beginPath(); g.arc(cx, cy, rad, -Math.PI / 2 - wedge, -Math.PI / 2 + wedge); g.stroke();
const yl = cy - rad;
textHalo(g, rs.map(r => r.key).join(' = ') + ' ' + nf(R, 8) + ' km', 6, yl - 6, color);
textHalo(g, fmtLen(rs[0].km, 8), w - 6, yl + 15, color, 'right');
}
g.strokeStyle = '#8b93a7'; g.lineWidth = 1;
for (const s of [-1, 1]) {
const a = -Math.PI / 2 + s * wedge;
g.beginPath(); g.moveTo(cx + Math.cos(a) * (cy - bottom), cy + Math.sin(a) * (cy - bottom)); g.lineTo(cx + Math.cos(a) * (cy - top), cy + Math.sin(a) * (cy - top)); g.stroke();
}
textHalo(g, `scenario leg ${fmtLen(m.d, 4)} · angle ${nf(m.d / ref, 4)} rad`, cx, 15, '#d8dee9', 'center');
key.textContent = `Radial axis runs from ${nf(lo, 7)} km at the bottom to ${nf(hi, 7)} km at the top; the centre of the Earth is far below the frame. Gaps between arcs are magnified ${nf(mag, 3)} times against the drawn curvature. The wedge is drawn at a fixed width; the angle it stands for is printed at its top, and the length on each arc is printed at the right. ${m.radii.named.length} named r … [line shortened here: 485 characters; full line on GitHub]
}
function drawGap(m) {
const cv = $('gap'); const { g, w, h } = fit(cv);
const key = $('gapkey');
if (w < 120 || h < 80) return;
if (!m.ok) { emptyCanvas(g, emptyReason()); key.textContent = ''; return; }
const c = m.radii.curve;
const allM = c.flatMap(p => [Math.abs(p.mean), Math.abs(p.uk)]).filter(v => v > 0).map(v => v * 1000);
const y0 = Math.floor(Math.log10(Math.min(...allM))), y1 = Math.ceil(Math.log10(Math.max(...allM)));
const L = 48, R = w - 10, T = 10, B = h - 22;
const X = dk => L + (Math.log10(dk) - Math.log10(logD.lo)) / (Math.log10(logD.hi) - Math.log10(logD.lo)) * (R - L);
const Y = mtr => B - (Math.log10(mtr) - y0) / (y1 - y0) * (B - T);
g.font = '10px ui-monospace,Menlo,Consolas,monospace'; g.lineWidth = 1;
for (let e = y0; e <= y1; e++) {
g.strokeStyle = '#1b2030'; g.beginPath(); g.moveTo(L, Y(10 ** e)); g.lineTo(R, Y(10 ** e)); g.stroke();
g.fillStyle = '#5c6580'; g.textAlign = 'right'; g.fillText(fmtLen(10 ** e / 1000, 3), L - 4, Y(10 ** e) + 3);
}
for (let e = Math.round(Math.log10(logD.lo)); e <= Math.round(Math.log10(logD.hi)); e++) {
g.strokeStyle = '#1b2030'; g.beginPath(); g.moveTo(X(10 ** e), T); g.lineTo(X(10 ** e), B); g.stroke();
g.fillStyle = '#5c6580'; g.textAlign = e === Math.round(Math.log10(logD.hi)) ? 'right' : 'center'; g.fillText(fmtLen(10 ** e, 3), X(10 ** e), h - 7);
}
for (const [k, col] of [['mean', COL.R_MEAN], ['uk', COL.R_UK]]) {
g.strokeStyle = col; g.lineWidth = 2; g.beginPath();
c.forEach((p, i) => { const v = Math.abs(p[k]) * 1000; if (i) g.lineTo(X(p.d), Y(v)); else g.moveTo(X(p.d), Y(v)); });
g.stroke();
}
const rows = m.radii.rows;
for (const r of rows) {
if (r.diffKm === 0 || !Number.isFinite(r.diffKm)) continue;
const v = Math.max(10 ** y0, Math.min(10 ** y1, Math.abs(r.diffKm) * 1000));
g.beginPath(); g.arc(X(m.d), Y(v), 4.5, 0, 7); g.fillStyle = COL[r.key]; g.fill(); g.strokeStyle = '#07080c'; g.lineWidth = 1.5; g.stroke();
}
const zeroRows = rows.filter(r => r.diffKm === 0).map(r => r.label.split(' · ').slice(0, 2).join(' in '));
key.textContent = `Absolute difference from R_ATLAS against leg length, both axes log; ${c.length} legs sampled by calling the modules from ${fmtPt(m.radii.probe)} due east. R_MEAN (violet) returns the shorter distance, R_UK (blue) the longer. Zero difference cannot sit on a log axis, so ${zeroRows.join(' and ')} ${zeroRows.length === 1 ? 'is' : 'are'} not drawn. Dots mark the scenario leg.`;
}
/* ── result lists: rows built once, only their text is updated ───────────── */
const rowCache = new Map();
function row(list, id, color) {
if (rowCache.has(id)) return rowCache.get(id);
const li = el('li'); li.style.setProperty('--c', color || '#1b2030');
const k = el('div', 'k'), lab = el('span'), v = el('span', 'v');
const fn = el('div', 'fn'), basis = el('div', 'basis');
k.append(lab, v); li.append(k, fn, basis); list.append(li);
const r = { li, lab, v, fn, basis };
rowCache.set(id, r); return r;
}
const setT = (node, t) => { if (node.textContent !== t) node.textContent = t; };
function fill(r, lab, v, fn, basis, empty) { setT(r.lab, lab); setT(r.v, v); setT(r.fn, fn); setT(r.basis, basis); r.li.classList.toggle('empty', !!empty); }
let loadError = '';
const emptyReason = () => loadError || 'the engine modules have not loaded yet';
function paintResults(m) {
$('out-d').textContent = fmtLen(dFromT(S.t), 4);
const rl = $('radiires'), ol = $('orderres');