Spaces:
Running
Running
spacebeam: layer guide and panel, from lightfastai/beam-entry 4f6a1d6
Browse filesFiles changed (4)
- README.md+1-1
- app.js+47-2
- index.html+8
- style.css+8
23 unmodified lines2425262728293023 unmodified lines- **Rings.** One ring per layer, layer 3 innermost. Each token has its own spoke, at its place in the passage, so the passage sweeps round like a clock hand and fills the disc.- **Loom.** The layers are wedges round a circle in star order: each next layer is placed 20 wedges further round. The star shape comes from that layout, not from Beam. Only the points inside each wedge, and where each token's line passes through them, come from Beam.The controls are kept small: the passage, the speed, how many tokens' trails stay on screen, pause, and save the current picture as a PNG. Hover a point to see the expert's most frequent tokens and which tokens on screen picked it.## The five passages23 unmodified lines2425262728293023 unmodified lines- **Rings.** One ring per layer, layer 3 innermost. Each token has its own spoke, at its place in the passage, so the passage sweeps round like a clock hand and fills the disc.- **Loom.** The layers are wedges round a circle in star order: each next layer is placed 20 wedges further round. The star shape comes from that layout, not from Beam. Only the points inside each wedge, and where each token's line passes through them, come from Beam.The controls are kept small: the passage, the speed, how many tokens' trails stay on screen, pause, and save the current picture as a PNG. Hover a point to see the expert's most frequent tokens and which tokens on screen picked it. Point at a layer and a guide line crosses every layer (a circle in Orbit and Loom, a spoke in Rings); the panel on the right then shows that layer for the token now travelling: its public picks by router weight, with each expert's most frequent tokens, and how many of its 8 picks went to withheld experts.## The five passages
146 unmodified lines147148149150151152153182 unmodified lines33633733833934034134247 unmodified lines39039139239339439539 unmodified lines435436437438439440441442443444445146 unmodified linesspeedFromSlider();function pickView(i) {S.view = i;[...$("views").children].forEach((b, k) => b.classList.toggle("on", k === i));layout();caption();182 unmodified linesctx.strokeStyle = "rgba(255,255,255,0.85)"; ctx.lineWidth = 1;ctx.beginPath(); ctx.arc(px, py, 5 * u + 2, 0, 2 * Math.PI); ctx.stroke();}ctx.restore();// the word now travelling: in the empty centre of Orbit, in the corner elsewhereconst word = show(e.tokens[k].t), small = `${Math.max(9, 10 * u)}px ui-monospace, Menlo, monospace`;47 unmodified lines}return best && { ...best, x: mx, y: my };}function segDist2(x, y, [ax, ay], [bx, by]) {const dx = bx - ax, dy = by - ay, l = dx * dx + dy * dy, t = l ? Math.max(0, Math.min(1, ((x - ax) * dx + (y - ay) * dy) / l)) : 0;return (ax + t * dx - x) ** 2 + (ay + t * dy - y) ** 2;39 unmodified lines}canvas.addEventListener("mousemove", ev => {S.hover = hit(ev);canvas.style.cursor = S.hover ? "crosshair" : "default";if (!S.hover) $("tip").style.display = "none";});canvas.addEventListener("mouseleave", () => { S.hover = null; $("tip").style.display = "none"; });canvas.addEventListener("click", ev => { if (!hit(ev)) togglePause(); });function savePNG() {146 unmodified lines147148149150151152153182 unmodified lines33633733833934034134234334447 unmodified lines39239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743839 unmodified lines478479480481482483484485486487488489490146 unmodified linesspeedFromSlider();function pickView(i) {S.view = i; S.guide = null; S.detailKey = null;[...$("views").children].forEach((b, k) => b.classList.toggle("on", k === i));layout();caption();182 unmodified linesctx.strokeStyle = "rgba(255,255,255,0.85)"; ctx.lineWidth = 1;ctx.beginPath(); ctx.arc(px, py, 5 * u + 2, 0, 2 * Math.PI); ctx.stroke();}drawGuide();ctx.restore();detail(k, upto);// the word now travelling: in the empty centre of Orbit, in the corner elsewhereconst word = show(e.tokens[k].t), small = `${Math.max(9, 10 * u)}px ui-monospace, Menlo, monospace`;47 unmodified lines}return best && { ...best, x: mx, y: my };}// the layer under the mouse, and the guide line across every layer: in Orbit and Loom a circle at the// mouse's radius through all 49 wedges, in Rings a spoke at the mouse's angle through all 49 ringsconst LOOM_LAYER = (() => { const m = []; for (let i = 0; i < L; i++) m[(i * STAR) % L] = i; return m; })();function layerAt(mx, my) {const g = S.g, V = view(), dx = mx - g.c, dy = my - g.c, r = Math.hypot(dx, dy);const th = Math.atan2(dy, dx), turn = ((th + Math.PI / 2) % (2 * Math.PI) + 2 * Math.PI) % (2 * Math.PI);if (V.perWord) {if (r < g.Q0 || r > g.Q1) return null;return { i: Math.min(L - 1, Math.floor((r - g.Q0) / g.bw)), th };}if (r < g.R0 * 0.85 || r > g.Rr * 1.06) return null;const slot = Math.floor(turn / A) % L;return { i: V.slot ? LOOM_LAYER[slot] : slot, r: Math.max(g.R0, Math.min(g.R1, r)) };}function drawGuide() {const m = S.guide; if (!m) return;const g = S.g, V = view(), u = g.u;ctx.globalCompositeOperation = "source-over";ctx.strokeStyle = "rgba(232,232,227,0.28)"; ctx.lineWidth = 0.8 * u; ctx.setLineDash([2 * u, 4 * u]);ctx.beginPath();if (V.perWord) { ctx.moveTo(...polar(m.th, g.Q0)); ctx.lineTo(...polar(m.th, g.Q1)); }else ctx.arc(g.c, g.c, m.r, 0, 2 * Math.PI);ctx.stroke(); ctx.setLineDash([]);ctx.strokeStyle = "rgba(255,255,255,0.75)"; ctx.lineWidth = (V.thin ? 1.6 : 3) * u; strokePts(ctx, S.markPts[m.i]);}// the second panel: the layer under the mouse (or the layer the word is at), for the word now travellingfunction detail(k, upto) {const i = S.guide ? S.guide.i : upto, key = `${S.ex}:${k}:${i}:${S.view}`;if (S.detailKey === key) return; S.detailKey = key;const e = S.routes.excerpts[S.ex], tok = e.tokens[k], l = tok.L[i], n = S.routes.meta.layers[i];const picks = l.p.slice().sort((a, b) => b[1] - a[1]).map(([cell, w]) => {const id = S.cards.cells[n][cell], card = id && S.cards.cards[id];return `<li><span class="k">${esc(id || "")}</span> <span class="m">${w.toFixed(3)}</span><br>${card ? card.top_tokens.slice(0, 5).map(t => `<code>${esc(show(t))}</code>`).join("") : ""}</li>`;}).join("");$("dlayer").textContent = `Layer ${n}`;$("dword").innerHTML = `word ${k + 1} of ${e.n}: <code>${esc(show(tok.t))}</code>` + (S.guide ? "" : ` <span class="m">(follows the word; point at a layer to hold one)</span>`);$("dpicks").innerHTML = picks || `<li class="m">no public pick at this layer</li>`;$("dhid").textContent = `${l.h} of its 8 picks went to withheld experts: counted, never named or placed.` + (i > upto ? " The word has not reached this layer yet on screen." : "");}function segDist2(x, y, [ax, ay], [bx, by]) {const dx = bx - ax, dy = by - ay, l = dx * dx + dy * dy, t = l ? Math.max(0, Math.min(1, ((x - ax) * dx + (y - ay) * dy) / l)) : 0;return (ax + t * dx - x) ** 2 + (ay + t * dy - y) ** 2;39 unmodified lines}canvas.addEventListener("mousemove", ev => {const cr = canvas.getBoundingClientRect();S.guide = S.g ? layerAt(ev.clientX - cr.left, ev.clientY - cr.top) : null;S.hover = hit(ev);canvas.style.cursor = S.hover ? "crosshair" : "default";if (!S.hover) $("tip").style.display = "none";});canvas.addEventListener("mouseleave", () => { S.hover = null; S.guide = null; $("tip").style.display = "none"; });canvas.addEventListener("click", ev => { if (!hit(ev)) togglePause(); });function savePNG() {
30 unmodified lines31323334353630 unmodified lines<canvas id="orbit"></canvas><div id="tip" class="tip"></div></main></div><footer id="caption"></footer><script src="app.js"></script>30 unmodified lines313233343536373839404142434430 unmodified lines<canvas id="orbit"></canvas><div id="tip" class="tip"></div></main><aside id="detail"><div class="plabel">This layer, this token</div><div id="dlayer" class="ptitle"></div><div id="dword" class="psrc"></div><div class="plabel">Public picks, by router weight</div><ul id="dpicks"></ul><div id="dhid" class="psrc"></div></aside></div><footer id="caption"></footer><script src="app.js"></script>
42 unmodified lines43444542 unmodified lines#legend { margin: 0; padding-left: 16px; color: #a9a9a3; font-size: 12px; line-height: 1.45; flex: none; max-height: 40%; overflow: auto; }#legend li { margin-bottom: 4px; }#legend b { color: var(--ink); font-weight: 500; }42 unmodified lines434445464748495051525342 unmodified lines#legend { margin: 0; padding-left: 16px; color: #a9a9a3; font-size: 12px; line-height: 1.45; flex: none; max-height: 40%; overflow: auto; }#legend li { margin-bottom: 4px; }#legend b { color: var(--ink); font-weight: 500; }#detail { width: 260px; flex: none; display: flex; flex-direction: column; gap: 6px; padding: 4px 16px 12px 14px;border-left: 1px solid var(--line); min-height: 0; overflow: auto; }#detail code, #dword code { font: 11px ui-monospace, Menlo, monospace; background: #232321; padding: 0 3px; border-radius: 2px; margin-right: 2px; white-space: pre; }#dpicks { list-style: none; margin: 0; padding: 0; font-size: 12px; }#dpicks li { padding: 5px 0; border-bottom: 1px solid var(--line); line-height: 1.6; }#dpicks .k { font: 600 12px ui-monospace, Menlo, monospace; }.m { color: var(--dim); }@media (max-width: 760px) { #detail { width: auto; border-left: 0; border-top: 1px solid var(--line); max-height: 30vh; } }
README.md+1-1
app.js+47-2
index.html+8
style.css+8