@intentius/behold 0.29.41 → 0.29.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +32 -0
- package/dist/cli.js +111 -20
- package/package.json +1 -1
- package/web/app.js +12 -8
- package/web/carve-narration.js +32 -6
- package/web/carve-narration.test.js +31 -1
- package/web/dots-cards.js +362 -0
- package/web/dots-cards.test.js +303 -0
- package/web/dots.js +363 -74
- package/web/embed.js +16 -0
- package/web/embed.test.js +19 -1
- package/web/event-help-modal.js +1 -1
- package/web/index.html +192 -127
- package/web/kiosk-carve.js +26 -20
- package/web/kiosk-event-help-ui.js +1 -1
- package/web/kiosk-link.js +68 -0
- package/web/kiosk-link.test.js +69 -0
- package/web/kiosk-metrics.js +2 -2
- package/web/kiosk-trace.js +1 -1
- package/web/kiosk.html +186 -135
- package/web/kiosk.js +44 -1
- package/web/motion.js +42 -0
- package/web/motion.test.js +64 -0
- package/web/terralith.html +2 -2
- package/web/theme.js +99 -26
- package/web/theme.test.js +70 -6
- package/web/tooltip.js +212 -0
- package/web/tooltip.test.js +193 -0
- package/web/trunk-lane.js +160 -8
- package/web/trunk-lane.test.js +108 -1
package/web/dots.js
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
import { readCarve, carveShow, walkthroughShow, phaseAt } from "./dots-recording.js";
|
|
24
24
|
import { parentsOf } from "./dots-layout.js";
|
|
25
25
|
import { buildScene, takeoffsBy, firstLandings, flightPoint, easeInOut, replayClock, BOX } from "./dots-scene.js";
|
|
26
|
-
import { cardMorph, discMorph, discRadius, levelOf, caption, railMarks, railPos, lerp } from "./dots-lod.js";
|
|
26
|
+
import { cardMorph, discMorph, discRadius, levelOf, caption, railMarks, railPos, lerp, LOD } from "./dots-lod.js";
|
|
27
27
|
import { perimeter, pointAt, nearestS, segment } from "./dots-border.js";
|
|
28
28
|
import { getTokens, onThemeChange, contrast, hexToOklch, oklchToHex } from "./theme.js";
|
|
29
29
|
import { LOOP, carveStory, beatAt, tipsBetween, directorFocus, shortName as shortOf, liveBeat, liveTipsBetween, liveEndTip, LIVE_HOLD_MS } from "./dots-kiosk.js";
|
|
@@ -31,6 +31,7 @@ import { liveShow, stampArrivals, showKey, currentMigration, boxName, playedCoun
|
|
|
31
31
|
import { provenanceText, migrationTool, stepMsFor } from "./tour-player.js";
|
|
32
32
|
import { tourNow, tourFocus, tourFx, fxKey, tourMessage } from "./dots-tour.js";
|
|
33
33
|
import { wallTicks, recordedLabel, recordedMarks, speedWords, skippedWords, clockWords, RECORDED_SPEEDS } from "./dots-timeline.js";
|
|
34
|
+
import { cardLabel, cardShape, cardText, cardTextAlpha, pickMark, cardsMark, cardsFrame, cardsEstate, middleCard, gridScale, gridSlots, cardSize, cardNeed, rosterLod, unitKeyOf, minViewWidth, tipSpot, CARD_TEXT } from "./dots-cards.js";
|
|
34
35
|
|
|
35
36
|
/** #715: how often the live layer asks for the carve. The route shares one read for 1.5 s while a migration runs. */
|
|
36
37
|
export const LIVE_POLL_MS = 2_000;
|
|
@@ -46,6 +47,8 @@ const RIPPLE_MS = 650;
|
|
|
46
47
|
const PULSE_MS = 520;
|
|
47
48
|
const DRAW_MS = 650;
|
|
48
49
|
const LINGER_MS = 2600;
|
|
50
|
+
/** A viewer's hand on the camera (a wheel, a pinch, a drag, a rail mark) holds the director and the tour off until this long after their last input. */
|
|
51
|
+
export const VIEWER_HOLD_MS = 8_000;
|
|
49
52
|
|
|
50
53
|
export function dotsActive() {
|
|
51
54
|
return !!S;
|
|
@@ -56,6 +59,15 @@ export function dotsZoomOutFactor() {
|
|
|
56
59
|
return S ? S.zoomOut : null;
|
|
57
60
|
}
|
|
58
61
|
|
|
62
|
+
/**
|
|
63
|
+
* How far in the zoom may go, as the narrowest viewBox width: a little past where the roster's cards are fully drawn,
|
|
64
|
+
* while the canvas draws them; null otherwise (the app's own limit holds).
|
|
65
|
+
*/
|
|
66
|
+
export function dotsMinViewWidth() {
|
|
67
|
+
if (!S || !S.own) return null;
|
|
68
|
+
return minViewWidth(paneRect().width, S.rc.w, S.need);
|
|
69
|
+
}
|
|
70
|
+
|
|
59
71
|
/** #715: whether the live carve's director holds the camera (a migration is running in the kiosk's frame). */
|
|
60
72
|
export function dotsCarving() {
|
|
61
73
|
return !!(S && S.live && S.carving);
|
|
@@ -86,6 +98,8 @@ function addStyle() {
|
|
|
86
98
|
const st = document.createElement("style");
|
|
87
99
|
st.textContent = `
|
|
88
100
|
.dots-on > svg { position: relative; z-index: 1; background: transparent; }
|
|
101
|
+
/* Once the cards are out of the paint a touch lands on the host: a pinch there is the camera's, never the page's zoom. */
|
|
102
|
+
.dots-on { touch-action: none; }
|
|
89
103
|
.dots-on > svg > rect[fill^="url(#pin-"] { display: none; }
|
|
90
104
|
.dots-on > svg [data-node-id], .dots-on > svg rect[data-group-id], .dots-on > svg text { opacity: var(--dots-card-a, 1); }
|
|
91
105
|
#dots-canvas { position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none; }
|
|
@@ -97,16 +111,18 @@ function addStyle() {
|
|
|
97
111
|
.dots-rail-mark { position: absolute; right: 0; transform: translateY(-50%); display: flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--fg); cursor: pointer; padding: 3px 0; text-align: right; font: inherit; }
|
|
98
112
|
.dots-rail-mark span { display: block; }
|
|
99
113
|
.dots-rail-mark b { display: block; font-weight: 600; }
|
|
100
|
-
.dots-rail-mark small { display: block; color: var(--muted); font-size:
|
|
114
|
+
.dots-rail-mark small { display: block; color: var(--muted); font-size: 11.5px; }
|
|
101
115
|
.dots-rail-mark i { width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--muted); background: var(--bg); flex: none; margin-right: 4px; }
|
|
102
116
|
.dots-rail-mark:hover i, .dots-rail-mark:focus-visible i { border-color: var(--focus); }
|
|
117
|
+
.dots-rail-mark:disabled { cursor: default; color: var(--muted); }
|
|
118
|
+
.dots-rail-mark:disabled:hover i { border-color: var(--muted); }
|
|
103
119
|
.dots-bottom { position: absolute; left: 50%; transform: translateX(-50%); bottom: 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; max-width: calc(100% - 24px); pointer-events: none; }
|
|
104
120
|
.dots-bottom > * { pointer-events: auto; }
|
|
105
|
-
.dots-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; max-width: calc(100% - 24px); background: color-mix(in srgb, var(--panel) 92%, transparent); border: 1px solid var(--line); border-radius: 8px; padding: 6px
|
|
121
|
+
.dots-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; max-width: calc(100% - 24px); background: color-mix(in srgb, var(--panel) 92%, transparent); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; box-sizing: border-box; }
|
|
106
122
|
.dots-bar button, .dots-bar select { background: var(--well); color: var(--fg); border: 1px solid var(--line); border-radius: 5px; padding: 3px 8px; font: inherit; cursor: pointer; }
|
|
107
123
|
.dots-bar input[type=range] { width: min(320px, 40vw); accent-color: var(--focus); }
|
|
108
124
|
.dots-time { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 12em; }
|
|
109
|
-
.dots-caption { padding: 3px
|
|
125
|
+
.dots-caption { padding: 3px 8px; border-radius: 6px; background: color-mix(in srgb, var(--bg) 80%, transparent); color: var(--fg); white-space: nowrap; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; box-sizing: border-box; }
|
|
110
126
|
.dots-kiosk .dots-caption { display: none; }
|
|
111
127
|
/* #715: a live carve has no playback head: it plays as it is written. */
|
|
112
128
|
.dots-live .dots-bar { display: none; }
|
|
@@ -119,20 +135,20 @@ function addStyle() {
|
|
|
119
135
|
.dots-keep-bar .dots-bar:hover, .dots-keep-bar .dots-bar:focus-within { opacity: 1; }
|
|
120
136
|
/* In Watch the director holds the camera; the rail is Inspect's. */
|
|
121
137
|
.dots-kiosk.dots-watch:not(.dots-keep-bar) .dots-rail { display: none; }
|
|
122
|
-
.dots-tip { position: absolute; pointer-events: none; padding: 3px
|
|
123
|
-
.dots-tip .dots-prov { white-space: normal; color: var(--muted); font: 11.5px/1.35 var(--font-mono, monospace); margin-top: 2px; }
|
|
138
|
+
.dots-tip { position: absolute; pointer-events: none; padding: 3px 6px; border-radius: 5px; background: var(--panel); border: 1px solid var(--line); white-space: nowrap; display: none; font-size: 12px; max-width: min(560px, calc(100% - 16px)); }
|
|
139
|
+
.dots-tip .dots-prov { white-space: normal; color: var(--ink2, var(--muted)); font: 11.5px/1.35 var(--font-mono, monospace); margin-top: 2px; }
|
|
124
140
|
/* A recording's timeline (#711): the label on the timeline itself, wall-clock ticks, the marks the records give, the breaks it skips. */
|
|
125
141
|
.dots-bar-rec { flex-direction: column; align-items: stretch; gap: 4px; width: min(860px, calc(100vw - 48px)); }
|
|
126
142
|
.dots-tl-label { font: 600 12px var(--font-ui, system-ui); color: var(--fg); }
|
|
127
143
|
.dots-tl-short { display: none; }
|
|
128
144
|
.dots-tl-row { display: flex; align-items: flex-end; gap: 16px; }
|
|
129
145
|
/* Break labels sit in their own row above the track; tick labels sit in the track, so the two never meet. */
|
|
130
|
-
.dots-tl-track { position: relative; flex: 1; height: 30px; margin-top:
|
|
146
|
+
.dots-tl-track { position: relative; flex: 1; height: 30px; margin-top: 16px; border-bottom: 1px solid var(--line); }
|
|
131
147
|
.dots-bar input.dots-tl-range { position: absolute; left: 0; right: 0; bottom: -8px; width: 100%; margin: 0; accent-color: var(--focus); background: transparent; }
|
|
132
|
-
.dots-tl-tick { position: absolute; bottom: 10px; transform: translateX(-50%); font:
|
|
148
|
+
.dots-tl-tick { position: absolute; bottom: 10px; transform: translateX(-50%); font: 11.5px var(--font-mono, monospace); color: var(--muted); white-space: nowrap; pointer-events: none; }
|
|
133
149
|
.dots-tl-tick::after { content: ""; position: absolute; left: 50%; top: 100%; width: 1px; height: 4px; background: var(--line); }
|
|
134
150
|
.dots-tl-break { position: absolute; top: 0; bottom: 0; width: 8px; transform: translateX(-50%); background: repeating-linear-gradient(135deg, var(--muted) 0 1.5px, transparent 1.5px 4px); opacity: 0.8; cursor: help; z-index: 1; }
|
|
135
|
-
.dots-tl-break small { position: absolute; bottom: calc(100% + 2px); left: 50%; transform: translateX(-50%); font:
|
|
151
|
+
.dots-tl-break small { position: absolute; bottom: calc(100% + 2px); left: 50%; transform: translateX(-50%); font: 11.5px var(--font-mono, monospace); color: var(--muted); white-space: nowrap; }
|
|
136
152
|
.dots-tl-break-end small { left: auto; right: 0; transform: none; }
|
|
137
153
|
.dots-bar .dots-tl-mark { position: absolute; top: 2px; width: 9px; height: 9px; padding: 0; margin-left: -4.5px; transform: rotate(45deg); border: 1.5px solid var(--focus); background: var(--focus); border-radius: 2px; cursor: pointer; z-index: 2; }
|
|
138
154
|
.dots-bar .dots-tl-keyframe { border-color: var(--muted); background: var(--muted); }
|
|
@@ -141,7 +157,7 @@ function addStyle() {
|
|
|
141
157
|
.dots-bar .dots-tl-first, .dots-bar .dots-tl-last { border-color: var(--bar-managed, var(--focus)); }
|
|
142
158
|
.dots-speed { white-space: nowrap; font-variant-numeric: tabular-nums; }
|
|
143
159
|
.dots-tip.dots-tip-go { pointer-events: auto; cursor: pointer; border-color: var(--focus); }
|
|
144
|
-
.dots-prov-go { font:
|
|
160
|
+
.dots-prov-go { font: 11.5px var(--font-ui, system-ui); color: var(--focus); margin-top: 2px; }
|
|
145
161
|
@media (max-width: 640px) { .dots-tl-long { display: none; } .dots-tl-short { display: inline; } .dots-tl-break small { display: none; } .dots-bar-rec { width: calc(100vw - 24px); } .dots-tl-row { flex-wrap: wrap; } .dots-tl-track { order: -1; flex: 1 1 100%; } }
|
|
146
162
|
.dots-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
147
163
|
.dots-keys { position: absolute; left: 8px; top: 8px; opacity: 0; pointer-events: none; font: 12px var(--font-ui, system-ui); background: var(--panel); color: var(--fg); border: 1px solid var(--focus); border-radius: 6px; padding: 3px 8px; }
|
|
@@ -153,7 +169,7 @@ function addStyle() {
|
|
|
153
169
|
.dots-rail-mark { font-size: 11px; }
|
|
154
170
|
.dots-rail-mark small { display: none; }
|
|
155
171
|
.dots-bottom { bottom: 6px; }
|
|
156
|
-
.dots-bar { gap: 6px; padding:
|
|
172
|
+
.dots-bar { gap: 6px; padding: 4px 8px; }
|
|
157
173
|
.dots-bar input[type=range] { width: 100%; order: 9; }
|
|
158
174
|
.dots-time { min-width: 0; }
|
|
159
175
|
.dots-caption { font-size: 12px; white-space: normal; text-align: center; }
|
|
@@ -261,10 +277,13 @@ export async function mountDots({ host, svg, meta, getVB, setVB, vbInit, source
|
|
|
261
277
|
// carve's cards are the served roots' (`<member>/<address>`), joined by address.
|
|
262
278
|
const cards = new Map();
|
|
263
279
|
const widths = [];
|
|
280
|
+
// The cards the SVG draws of its own: what the card level shows when none of them is a resource's.
|
|
281
|
+
let svgCards = 0;
|
|
264
282
|
for (const g of svg.querySelectorAll("[data-node-id]")) {
|
|
265
283
|
const id = g.getAttribute("data-node-id");
|
|
266
284
|
const r = g.querySelector("rect");
|
|
267
285
|
if (!r) continue;
|
|
286
|
+
svgCards++;
|
|
268
287
|
const slash = id.indexOf("/");
|
|
269
288
|
if (live ? slash < 0 : !id.startsWith(prefix)) continue;
|
|
270
289
|
const addr = live ? id.slice(slash + 1) : id.slice(prefix.length);
|
|
@@ -315,6 +334,20 @@ export async function mountDots({ host, svg, meta, getVB, setVB, vbInit, source
|
|
|
315
334
|
cards,
|
|
316
335
|
cardW,
|
|
317
336
|
pitch,
|
|
337
|
+
// No SVG card is a resource's (a live carve at the Components zoom draws one per root): the canvas draws the roster's.
|
|
338
|
+
seedless: cards.size === 0,
|
|
339
|
+
svgCards,
|
|
340
|
+
// The roster's cards (fitRosterCards): their size in viewBox units, the width in px their card level starts at.
|
|
341
|
+
rc: { w: 1, h: 1 },
|
|
342
|
+
need: LOD.cardPx,
|
|
343
|
+
lodR: LOD,
|
|
344
|
+
gridK: 0,
|
|
345
|
+
grids: new WeakMap(),
|
|
346
|
+
gdisp: new Map(),
|
|
347
|
+
ownA: 0,
|
|
348
|
+
own: false,
|
|
349
|
+
labels: new Map(),
|
|
350
|
+
fits: new Map(),
|
|
318
351
|
origin,
|
|
319
352
|
mbox,
|
|
320
353
|
live: !!live,
|
|
@@ -343,6 +376,8 @@ export async function mountDots({ host, svg, meta, getVB, setVB, vbInit, source
|
|
|
343
376
|
px: new Float32Array(n),
|
|
344
377
|
py: new Float32Array(n),
|
|
345
378
|
pvis: new Uint8Array(n),
|
|
379
|
+
pw: new Float32Array(n),
|
|
380
|
+
ph: new Float32Array(n),
|
|
346
381
|
stats: { draw: [], frame: [] },
|
|
347
382
|
snap: true,
|
|
348
383
|
fly: null,
|
|
@@ -353,6 +388,7 @@ export async function mountDots({ host, svg, meta, getVB, setVB, vbInit, source
|
|
|
353
388
|
S.col = readColours();
|
|
354
389
|
// The page's own UI face; a canvas cannot read var() in its font.
|
|
355
390
|
S.font = (cssVar("--font-ui") || "system-ui, sans-serif").replace(/;$/, "");
|
|
391
|
+
fitRosterCards();
|
|
356
392
|
S.off.push(onThemeChange(() => {
|
|
357
393
|
if (!S) return;
|
|
358
394
|
S.col = readColours();
|
|
@@ -439,7 +475,7 @@ export async function mountDots({ host, svg, meta, getVB, setVB, vbInit, source
|
|
|
439
475
|
const setInsets = (ins) => {
|
|
440
476
|
if (S) S.insets = { top: Number(ins.top) || 0, bottom: Number(ins.bottom) || 0 };
|
|
441
477
|
};
|
|
442
|
-
window.__dots = { select: (id) => selectDot(id), landed: () => S && landedIds(), seek, play, step, zoomTo, zoomCardPx, setInsets, pause: () => play(false), fly, setSpeed, stats: () => S && S.stats, length: () => S && S.clock.length, marks: () => S && currentMarks(), state: () => S && { t: S.t, level: S.level, reduced: S.reduced, cardPx: S.cardPx, pitchPx: S.pitchPx }, debug: () => S && { band: (({ left, right, w }) => ({ left, right, w }))(band()), svg: S.svg.getBoundingClientRect().toJSON(), rail: S.ui.querySelector('.dots-rail').getBoundingClientRect().toJSON(), vb: S.getVB(), dir: S.dir, directing: S.directing, focusBox: S.dir && focusBox(S.dir.focus), want: S.dir && frameBox(focusBox(S.dir.focus)), pitch: S.pitch, origin: S.origin }, story: () => S && S.story && { start: S.story.start, end: S.story.end, firstRefusal: S.story.firstRefusal ? S.story.firstRefusal.end : null } };
|
|
478
|
+
window.__dots = { select: (id) => selectDot(id), landed: () => S && landedIds(), seek, play, step, zoomTo, zoomCardPx, setInsets, pause: () => play(false), fly, setSpeed, stats: () => S && S.stats, length: () => S && S.clock.length, marks: () => S && currentMarks(), state: () => S && { t: S.t, level: S.level, reduced: S.reduced, cardPx: S.cardPx, pitchPx: S.pitchPx, rosterCards: S.own, rosterCardPx: S.rosterCardPx, directing: !!S.directing }, debug: () => S && { band: (({ left, right, w }) => ({ left, right, w }))(band()), svg: S.svg.getBoundingClientRect().toJSON(), rail: S.ui.querySelector('.dots-rail').getBoundingClientRect().toJSON(), vb: S.getVB(), dir: S.dir, directing: S.directing, focusBox: S.dir && focusBox(S.dir.focus), want: S.dir && frameBox(focusBox(S.dir.focus)), pitch: S.pitch, origin: S.origin }, story: () => S && S.story && { start: S.story.start, end: S.story.end, firstRefusal: S.story.firstRefusal ? S.story.firstRefusal.end : null } };
|
|
443
479
|
const loop = (wall) => {
|
|
444
480
|
if (!S) return;
|
|
445
481
|
S.raf = requestAnimationFrame(loop);
|
|
@@ -570,7 +606,8 @@ function currentMarks() {
|
|
|
570
606
|
const sorted = [...sizes].sort((a, b) => a - b);
|
|
571
607
|
const typical = sorted.length ? sorted[sorted.length >> 1] : 0;
|
|
572
608
|
const P = S.pitch;
|
|
573
|
-
|
|
609
|
+
// The card level is where the cards that draw are legible: the roster's own when the canvas draws them.
|
|
610
|
+
return railMarks({ paneW: bw, paneH: r.height || 1, cardW: S.own ? S.rc.w : S.cardW, ...(S.own ? { lod: S.lodR, cardAt: S.need * 1.1 } : {}), sceneW: S.scene.extent.w * P, sceneH: S.scene.extent.h * P, smallestBox: Number.isFinite(small) ? small * P : 0, largestBox: big * P, typicalBox: typical * P });
|
|
574
611
|
}
|
|
575
612
|
|
|
576
613
|
/** Fly the camera to a rail mark, centred on the scene (or the cards for Cards). */
|
|
@@ -582,6 +619,25 @@ function fly(mark) {
|
|
|
582
619
|
const vb = S.getVB();
|
|
583
620
|
const ext = S.scene.extent;
|
|
584
621
|
const P = S.pitch;
|
|
622
|
+
if (mark === "cards" && S.own) {
|
|
623
|
+
// The roster's cards: the one nearest the middle of the director's estate's cards, else the source estate's, else
|
|
624
|
+
// the fullest estate's, at the width where a card is just fully drawn.
|
|
625
|
+
const sc = S.scene;
|
|
626
|
+
const L = sc.layoutAt(takeoffsBy(sc, S.t));
|
|
627
|
+
const grid = gridOf(L);
|
|
628
|
+
const counts = new Map();
|
|
629
|
+
for (const a of grid.keys()) counts.set(L.owners.get(a), (counts.get(L.owners.get(a)) ?? 0) + 1);
|
|
630
|
+
const f = S.dir && S.dir.focus;
|
|
631
|
+
const e = cardsEstate(f && f.kind === "estate" ? f.estate : null, sc.source, counts);
|
|
632
|
+
const at = e === null ? null : middleCard([...grid].filter(([a]) => L.owners.get(a) === e).map(([, p]) => p));
|
|
633
|
+
if (!at) return;
|
|
634
|
+
const { r, left, right } = band();
|
|
635
|
+
const to = cardsFrame({ x: S.origin.x + at.x * P, y: S.origin.y + at.y * P }, w, vb[3] / vb[2]);
|
|
636
|
+
to[0] -= (((left - right) / 2) * w) / Math.max(1, r.width);
|
|
637
|
+
if (S.reduced) S.setVB(to);
|
|
638
|
+
else S.fly = { from: vb.slice(), to, start: performance.now(), dur: 900 };
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
585
641
|
const cx = mark === "cards" ? Math.max(S.origin.x + w / 2, Math.min(vb[0] + vb[2] / 2, S.origin.x + S.scene.sourceBox.w * P - w / 2)) : S.origin.x + (ext.w * P) / 2;
|
|
586
642
|
const cy = mark === "cards" ? Math.max(S.origin.y + (w * vb[3]) / vb[2] / 2, Math.min(vb[1] + vb[3] / 2, S.origin.y + S.scene.sourceBox.h * P)) : S.origin.y + (ext.h * P) / 2;
|
|
587
643
|
// Centre in the part of the pane the floating panel leaves uncovered.
|
|
@@ -644,6 +700,8 @@ function buildUi() {
|
|
|
644
700
|
b.title = `Fly to ${label.toLowerCase()}`;
|
|
645
701
|
b.addEventListener("click", (e) => {
|
|
646
702
|
e.stopPropagation();
|
|
703
|
+
// A mark is a viewer's hand on the camera: the director waits while it flies and reads.
|
|
704
|
+
viewerHold();
|
|
647
705
|
fly(k);
|
|
648
706
|
});
|
|
649
707
|
b.addEventListener("mousedown", (e) => e.stopPropagation());
|
|
@@ -813,7 +871,13 @@ function updateUiFrame(counts, level) {
|
|
|
813
871
|
const marks = currentMarks();
|
|
814
872
|
// The zoom goes out a little past the estates mark and no further.
|
|
815
873
|
S.zoomOut = Math.max(3, (marks.estates * 1.4) / Math.max(1, S.vbInit[2]));
|
|
816
|
-
|
|
874
|
+
// The Cards mark counts the cards that can draw at its zoom, never more.
|
|
875
|
+
const cm = cardsMark({ resources: S.show.roster.length, seeded: S.cards.size, svgCards: S.svgCards, own: S.own });
|
|
876
|
+
if (S.railMarks.cards.disabled === cm.enabled) {
|
|
877
|
+
S.railMarks.cards.disabled = !cm.enabled;
|
|
878
|
+
S.railMarks.cards.title = cm.enabled ? "Fly to cards" : "No cards draw here";
|
|
879
|
+
}
|
|
880
|
+
const sub = { cards: cm.words, resources: `${fmt(S.show.roster.length)} resources`, estates: `${estatesNow} estate${estatesNow === 1 ? "" : "s"}` };
|
|
817
881
|
for (const k of Object.keys(S.railMarks)) {
|
|
818
882
|
const sm = S.railMarks[k].querySelector("small");
|
|
819
883
|
if (sm.textContent !== sub[k]) sm.textContent = sub[k];
|
|
@@ -834,21 +898,13 @@ function hoverAt(e) {
|
|
|
834
898
|
S.tip.style.display = "none";
|
|
835
899
|
return;
|
|
836
900
|
}
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
for (let i = 0; i < S.addrs.length; i++) {
|
|
840
|
-
if (!S.pvis[i]) continue;
|
|
841
|
-
const d = (S.px[i] - x) ** 2 + (S.py[i] - y) ** 2;
|
|
842
|
-
if (d < bd) {
|
|
843
|
-
bd = d;
|
|
844
|
-
best = i;
|
|
845
|
-
}
|
|
846
|
-
}
|
|
901
|
+
// A roster card is hit anywhere on it; a dot within 10 px of its centre.
|
|
902
|
+
const best = pickMark(x, y, S, { within: 10 });
|
|
847
903
|
if (best < 0) {
|
|
848
904
|
S.tip.style.display = "none";
|
|
849
905
|
return;
|
|
850
906
|
}
|
|
851
|
-
showTip(S.addrs[best], x, y);
|
|
907
|
+
showTip(S.addrs[best], x, S.ph[best] > 0 ? S.py[best] + S.ph[best] : y, S.ph[best] > 0 ? S.py[best] - S.ph[best] : y);
|
|
852
908
|
}
|
|
853
909
|
|
|
854
910
|
/** A landed dot's provenance: what its newest write was, from its progress line and the migration's run; null for a dot no line names. */
|
|
@@ -878,7 +934,7 @@ function recordedProvenance(id) {
|
|
|
878
934
|
return { text: `${text} · ${file}${best.line ? ` line ${best.line}` : ""}`, url: null, seek: best.t };
|
|
879
935
|
}
|
|
880
936
|
|
|
881
|
-
function showTip(a, x, y) {
|
|
937
|
+
function showTip(a, x, y, top = y) {
|
|
882
938
|
const prov = provenanceOf(a);
|
|
883
939
|
S.tip.replaceChildren(el("div", "", `${a} · ${shortName(S.ownersNow.get(a) ?? S.scene.source)}`));
|
|
884
940
|
if (prov) {
|
|
@@ -890,8 +946,10 @@ function showTip(a, x, y) {
|
|
|
890
946
|
S.tip.classList.toggle("dots-tip-go", !!(prov && prov.seek !== undefined && S.selected === a));
|
|
891
947
|
S.tipSeek = prov && prov.seek !== undefined ? prov.seek : null;
|
|
892
948
|
S.tip.style.display = "block";
|
|
893
|
-
|
|
894
|
-
S.tip.
|
|
949
|
+
// Clear of the rail on the right, and over the mark when the pane's foot leaves no room under it.
|
|
950
|
+
const spot = tipSpot(x, y, { tipW: S.tip.offsetWidth, tipH: S.tip.offsetHeight, paneW: S.host.clientWidth, paneH: S.host.clientHeight, rightInset: band().right, above: top });
|
|
951
|
+
S.tip.style.left = `${spot.left}px`;
|
|
952
|
+
S.tip.style.top = `${spot.top}px`;
|
|
895
953
|
}
|
|
896
954
|
|
|
897
955
|
/** The dots that a write of this cycle landed, in the order they were written: what the keys step through. */
|
|
@@ -922,7 +980,7 @@ function selectDot(id) {
|
|
|
922
980
|
S.provLink.hidden = !(prov && prov.url);
|
|
923
981
|
if (prov && prov.url) S.provLink.href = prov.url;
|
|
924
982
|
}
|
|
925
|
-
if (i !== undefined && S.pvis[i]) showTip(id, S.px[i], S.py[i]);
|
|
983
|
+
if (i !== undefined && S.pvis[i]) showTip(id, S.px[i], S.py[i] + S.ph[i], S.py[i] - S.ph[i]);
|
|
926
984
|
S.dirty = true;
|
|
927
985
|
}
|
|
928
986
|
|
|
@@ -930,17 +988,8 @@ function nearestDot(e, within = 100) {
|
|
|
930
988
|
const hr = S.host.getBoundingClientRect();
|
|
931
989
|
const x = e.clientX - hr.left + S.host.scrollLeft;
|
|
932
990
|
const y = e.clientY - hr.top + S.host.scrollTop;
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
for (let i = 0; i < S.addrs.length; i++) {
|
|
936
|
-
if (!S.pvis[i]) continue;
|
|
937
|
-
const d = (S.px[i] - x) ** 2 + (S.py[i] - y) ** 2;
|
|
938
|
-
if (d < bd) {
|
|
939
|
-
bd = d;
|
|
940
|
-
best = i;
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
return best;
|
|
991
|
+
// `within` is a squared distance, as it always was here.
|
|
992
|
+
return pickMark(x, y, S, { within: Math.sqrt(within) });
|
|
944
993
|
}
|
|
945
994
|
|
|
946
995
|
// --- drawing -----------------------------------------------------------------
|
|
@@ -968,6 +1017,183 @@ function roundRect(ctx, x, y, w, h, r) {
|
|
|
968
1017
|
else ctx.rect(x, y, w, h);
|
|
969
1018
|
}
|
|
970
1019
|
|
|
1020
|
+
/**
|
|
1021
|
+
* The roster's cards for the scene now: one cell size every estate's grid fits at across the show (sampled at its
|
|
1022
|
+
* start, its end and 39 moments between), the card size and the width in px at which a card is fully drawn: wide
|
|
1023
|
+
* enough for the longest name and type. Only a scene with no SVG card for any resource draws them.
|
|
1024
|
+
*/
|
|
1025
|
+
function fitRosterCards() {
|
|
1026
|
+
S.grids = new WeakMap();
|
|
1027
|
+
S.gdisp = new Map();
|
|
1028
|
+
S.labels.clear();
|
|
1029
|
+
S.fits.clear();
|
|
1030
|
+
if (!S.seedless) return;
|
|
1031
|
+
const sc = S.scene;
|
|
1032
|
+
S.unitKey = unitKeyOf(sc.rosterBy);
|
|
1033
|
+
const n = sc.landing.length;
|
|
1034
|
+
const ks = new Set([0, n]);
|
|
1035
|
+
for (let j = 1; j < 40; j++) ks.add(Math.round((n * j) / 40));
|
|
1036
|
+
S.gridK = gridScale([...ks].map((k) => sc.layoutAt(k)), S.unitKey);
|
|
1037
|
+
const c = cardSize(S.gridK);
|
|
1038
|
+
S.rc = { w: c.w * S.pitch, h: c.h * S.pitch };
|
|
1039
|
+
const ctx = S.ctx;
|
|
1040
|
+
S.need = cardNeed(
|
|
1041
|
+
S.show.roster.map((r) => labelOf(r.address)),
|
|
1042
|
+
(txt, px, weight) => {
|
|
1043
|
+
ctx.font = `${weight} ${px}px ${S.font}`;
|
|
1044
|
+
return ctx.measureText(txt).width;
|
|
1045
|
+
},
|
|
1046
|
+
);
|
|
1047
|
+
S.lodR = rosterLod(S.need);
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
/** Each roster card's cell in a layout, in pitches (web/dots-cards.js gridSlots), kept per layout. */
|
|
1051
|
+
function gridOf(layout) {
|
|
1052
|
+
let g = S.grids.get(layout);
|
|
1053
|
+
if (!g) {
|
|
1054
|
+
g = gridSlots(layout, S.gridK, S.unitKey);
|
|
1055
|
+
S.grids.set(layout, g);
|
|
1056
|
+
}
|
|
1057
|
+
return g;
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
/**
|
|
1061
|
+
* Where a resource's card is now, in pitches: flying from its cell in the box it leaves to its cell in the box it
|
|
1062
|
+
* lands in, or at rest in its cell, sliding when a box re-packs as its dots do.
|
|
1063
|
+
*/
|
|
1064
|
+
function cellOf(a, f, L, t, ease) {
|
|
1065
|
+
if (f && f.ok) {
|
|
1066
|
+
const from = gridOf(S.scene.layoutAt(f.k - 1)).get(a);
|
|
1067
|
+
const to = gridOf(S.scene.layoutAt(f.k)).get(a) ?? from;
|
|
1068
|
+
if (!from) return to ?? null;
|
|
1069
|
+
const uf = (t - f.start) / (f.end - f.start);
|
|
1070
|
+
if (S.reduced) return uf < 0.5 ? from : to;
|
|
1071
|
+
S.cellMoving = true;
|
|
1072
|
+
return flightPoint(from, to, uf);
|
|
1073
|
+
}
|
|
1074
|
+
const target = gridOf(L).get(a);
|
|
1075
|
+
if (!target) return null;
|
|
1076
|
+
const prev = S.gdisp.get(a);
|
|
1077
|
+
const out = prev && !S.snap && ease < 1 ? { x: lerp(prev.x, target.x, ease), y: lerp(prev.y, target.y, ease) } : target;
|
|
1078
|
+
if (Math.abs(out.x - target.x) + Math.abs(out.y - target.y) > 0.01) S.cellMoving = true;
|
|
1079
|
+
S.gdisp.set(a, out);
|
|
1080
|
+
return out;
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
/** A roster row's card words, from its address and type alone (web/dots-cards.js). */
|
|
1084
|
+
function labelOf(a) {
|
|
1085
|
+
let l = S.labels.get(a);
|
|
1086
|
+
if (!l) {
|
|
1087
|
+
l = cardLabel(S.scene.rosterBy.get(a) || { address: a });
|
|
1088
|
+
S.labels.set(a, l);
|
|
1089
|
+
}
|
|
1090
|
+
return l;
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
/** A card's lines at its size now, kept by size: fitting a name measures it several times. */
|
|
1094
|
+
function linesOf(ctx, a, sh) {
|
|
1095
|
+
const key = `${a}|${Math.round(sh.w)}|${Math.round(sh.h)}`;
|
|
1096
|
+
let lines = S.fits.get(key);
|
|
1097
|
+
if (!lines) {
|
|
1098
|
+
lines = cardText(labelOf(a), { w: sh.w, h: sh.h, need: S.need }, (txt, px, weight) => {
|
|
1099
|
+
ctx.font = `${weight} ${px}px ${S.font}`;
|
|
1100
|
+
return ctx.measureText(txt).width;
|
|
1101
|
+
});
|
|
1102
|
+
if (S.fits.size > 4000) S.fits.clear();
|
|
1103
|
+
S.fits.set(key, lines);
|
|
1104
|
+
}
|
|
1105
|
+
return lines;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
/**
|
|
1109
|
+
* A resource's roster card, `u` of the way from its dot (0) to its card (1): the dot's disc grows into a rounded
|
|
1110
|
+
* rect in its estate's colour, which pales to a tint on the page's surface as the name and the type fade in. The
|
|
1111
|
+
* marks a dot wears (a tour's light, the adoption's ring, the selection, a takeoff) go round the card.
|
|
1112
|
+
*/
|
|
1113
|
+
function drawRosterCard(ctx, a, sh, u, { vis, colour, glow, ring, selected, takeoff }) {
|
|
1114
|
+
const col = S.col;
|
|
1115
|
+
const round = (o) => roundRect(ctx, sh.x - o, sh.y - o, sh.w + 2 * o, sh.h + 2 * o, sh.r + o);
|
|
1116
|
+
if (glow) {
|
|
1117
|
+
ctx.globalAlpha = vis * glow.a * 0.7;
|
|
1118
|
+
ctx.strokeStyle = glow.colour;
|
|
1119
|
+
ctx.lineWidth = 3;
|
|
1120
|
+
round(3);
|
|
1121
|
+
ctx.stroke();
|
|
1122
|
+
}
|
|
1123
|
+
round(0);
|
|
1124
|
+
ctx.globalAlpha = vis * Math.min(1, u * 2);
|
|
1125
|
+
ctx.fillStyle = col.surface || col.bg;
|
|
1126
|
+
ctx.fill();
|
|
1127
|
+
ctx.globalAlpha = vis * lerp(1, 0.12, u);
|
|
1128
|
+
ctx.fillStyle = colour;
|
|
1129
|
+
ctx.fill();
|
|
1130
|
+
ctx.globalAlpha = vis * Math.min(1, u * 1.5);
|
|
1131
|
+
ctx.strokeStyle = colour;
|
|
1132
|
+
ctx.lineWidth = 1.2;
|
|
1133
|
+
ctx.stroke();
|
|
1134
|
+
const ta = cardTextAlpha(u);
|
|
1135
|
+
if (u > 0.5) {
|
|
1136
|
+
ctx.save();
|
|
1137
|
+
round(0);
|
|
1138
|
+
ctx.clip();
|
|
1139
|
+
ctx.globalAlpha = vis;
|
|
1140
|
+
ctx.fillStyle = colour;
|
|
1141
|
+
ctx.fillRect(sh.x, sh.y, CARD_TEXT.bar, sh.h);
|
|
1142
|
+
const lines = ta > 0 ? linesOf(ctx, a, sh) : [];
|
|
1143
|
+
if (lines.length) {
|
|
1144
|
+
const total = lines.reduce((n, l) => n + l.size * 1.25, 0);
|
|
1145
|
+
let y = sh.y + (sh.h - total) / 2;
|
|
1146
|
+
ctx.textAlign = "left";
|
|
1147
|
+
ctx.textBaseline = "middle";
|
|
1148
|
+
ctx.globalAlpha = vis * ta;
|
|
1149
|
+
for (const l of lines) {
|
|
1150
|
+
ctx.font = `${l.weight} ${l.size}px ${S.font}`;
|
|
1151
|
+
ctx.fillStyle = l.ink === "muted" ? col.muted : col.fg;
|
|
1152
|
+
ctx.fillText(l.text, sh.x + CARD_TEXT.bar + CARD_TEXT.pad, y + l.size * 0.625);
|
|
1153
|
+
y += l.size * 1.25;
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
ctx.restore();
|
|
1157
|
+
}
|
|
1158
|
+
if (ring) {
|
|
1159
|
+
// It wears its estate's tags now: a ring round the dot, a tag on the card's corner.
|
|
1160
|
+
ctx.globalAlpha = vis;
|
|
1161
|
+
if (u < 0.5) {
|
|
1162
|
+
ctx.strokeStyle = col.managed;
|
|
1163
|
+
ctx.lineWidth = 1.2;
|
|
1164
|
+
round(2);
|
|
1165
|
+
ctx.stroke();
|
|
1166
|
+
} else {
|
|
1167
|
+
ctx.fillStyle = col.managed;
|
|
1168
|
+
ctx.beginPath();
|
|
1169
|
+
ctx.arc(sh.x + sh.w - 6, sh.y + 6, Math.max(2, Math.min(3.5, sh.h * 0.08)), 0, Math.PI * 2);
|
|
1170
|
+
ctx.fill();
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
if (glow && glow.ring) {
|
|
1174
|
+
ctx.globalAlpha = vis;
|
|
1175
|
+
ctx.strokeStyle = glow.colour;
|
|
1176
|
+
ctx.lineWidth = 2;
|
|
1177
|
+
round(5);
|
|
1178
|
+
ctx.stroke();
|
|
1179
|
+
}
|
|
1180
|
+
if (selected) {
|
|
1181
|
+
ctx.globalAlpha = 1;
|
|
1182
|
+
ctx.strokeStyle = col.fg;
|
|
1183
|
+
ctx.lineWidth = 1.6;
|
|
1184
|
+
round(4);
|
|
1185
|
+
ctx.stroke();
|
|
1186
|
+
}
|
|
1187
|
+
if (takeoff < 0.2) {
|
|
1188
|
+
ctx.globalAlpha = vis * (1 - takeoff / 0.2);
|
|
1189
|
+
ctx.strokeStyle = col.pending;
|
|
1190
|
+
ctx.lineWidth = 1.4;
|
|
1191
|
+
round(2 + takeoff * 20);
|
|
1192
|
+
ctx.stroke();
|
|
1193
|
+
}
|
|
1194
|
+
ctx.globalAlpha = 1;
|
|
1195
|
+
}
|
|
1196
|
+
|
|
971
1197
|
function polyline(ctx, pts) {
|
|
972
1198
|
if (pts.length < 2) return;
|
|
973
1199
|
ctx.beginPath();
|
|
@@ -1005,11 +1231,25 @@ function draw(dt) {
|
|
|
1005
1231
|
const tc = cardMorph(S.cardW * s, { reduced });
|
|
1006
1232
|
S.cardPx = S.cardW * s;
|
|
1007
1233
|
S.pitchPx = P * s;
|
|
1008
|
-
|
|
1234
|
+
// With no SVG card for any resource, the canvas draws the roster's cards: while the carve holds the stage (a live
|
|
1235
|
+
// carve's director or tour), or always for a recording. The SVG's own cards (a live carve's roots) stay out of the
|
|
1236
|
+
// paint then, and come back, eased, when the stage is theirs again.
|
|
1237
|
+
const ownWant = S.seedless && (!S.live || S.carving) ? 1 : 0;
|
|
1238
|
+
S.ownA = S.snap || reduced ? ownWant : lerp(S.ownA, ownWant, 1 - Math.exp(-dt / 300));
|
|
1239
|
+
if (Math.abs(S.ownA - ownWant) < 0.01) S.ownA = ownWant;
|
|
1240
|
+
const ownA = S.ownA;
|
|
1241
|
+
S.own = ownA >= 0.5;
|
|
1242
|
+
// The roster's cards grow from the dots in their slots: their own size on screen picks their form, as a card's does.
|
|
1243
|
+
const rcW = S.rc.w * s;
|
|
1244
|
+
const rcH = S.rc.h * s;
|
|
1245
|
+
S.rosterCardPx = rcW;
|
|
1246
|
+
const tr = cardMorph(rcW, { reduced, lod: S.lodR });
|
|
1247
|
+
const layerA = lerp(tc, 1, ownA);
|
|
1248
|
+
S.cardA = 1 - layerA;
|
|
1009
1249
|
// Cards fade faster than the dots grow, so the dots under them read by the middle of the morph.
|
|
1010
|
-
const cardA = Math.pow(1 - tc, 2).toFixed(3);
|
|
1250
|
+
const cardA = (Math.pow(1 - tc, 2) * (1 - ownA)).toFixed(3);
|
|
1011
1251
|
if (S.host.style.getPropertyValue("--dots-card-a") !== cardA) S.host.style.setProperty("--dots-card-a", cardA);
|
|
1012
|
-
const hide = tc >= 1;
|
|
1252
|
+
const hide = tc >= 1 || ownA >= 1;
|
|
1013
1253
|
if (hide !== S.svgHidden) {
|
|
1014
1254
|
// The export owns its camera and measures the host, so it takes the SVG out of
|
|
1015
1255
|
// layout altogether; the app's own wheel handler measures the SVG, so there it stays in layout.
|
|
@@ -1053,11 +1293,14 @@ function draw(dt) {
|
|
|
1053
1293
|
const size = Math.max(b.w, b.h, fin ? Math.max(fin.w, fin.h) : 0);
|
|
1054
1294
|
td.set(e, discMorph(size * P * s, { reduced }));
|
|
1055
1295
|
}
|
|
1056
|
-
const level = levelOf(tc, td.values());
|
|
1296
|
+
const level = levelOf(S.own ? tr : tc, td.values());
|
|
1057
1297
|
// Reaching the estate level by hand fits the estates, so they are not a speck in a corner.
|
|
1058
1298
|
if (level === "discs" && S.level && S.level !== "discs" && !S.fly && !S.directing) queueMicrotask(() => fly("estates"));
|
|
1059
1299
|
S.level = level;
|
|
1060
|
-
const dotLayerA =
|
|
1300
|
+
const dotLayerA = layerA;
|
|
1301
|
+
// How far a resource with no SVG card has grown into its roster card: 0 its dot, 1 its card.
|
|
1302
|
+
const rosterU = ownA * (1 - tr);
|
|
1303
|
+
if (ownA !== ownWant) moving = true;
|
|
1061
1304
|
|
|
1062
1305
|
// Activity per estate: dots in the air toward it (or leaving it), for the running light.
|
|
1063
1306
|
const act = new Map();
|
|
@@ -1150,7 +1393,7 @@ function draw(dt) {
|
|
|
1150
1393
|
// and the box have room, else just above the outline (it may run past a
|
|
1151
1394
|
// narrow box's edge), so a label never sits on the dots.
|
|
1152
1395
|
const fs = 11.5;
|
|
1153
|
-
if (
|
|
1396
|
+
if (dotLayerA > 0.6 && (td.get(e) ?? 0) < 0.5) {
|
|
1154
1397
|
ctx.font = `700 ${fs}px ${S.font}`;
|
|
1155
1398
|
ctx.textBaseline = "middle";
|
|
1156
1399
|
ctx.textAlign = "left";
|
|
@@ -1265,6 +1508,7 @@ function draw(dt) {
|
|
|
1265
1508
|
}
|
|
1266
1509
|
ctx.globalAlpha = 1;
|
|
1267
1510
|
const refusedLit = [];
|
|
1511
|
+
S.cellMoving = false;
|
|
1268
1512
|
for (let i = 0; i < addrs.length; i++) {
|
|
1269
1513
|
const a = addrs[i];
|
|
1270
1514
|
const f = inAir.get(a);
|
|
@@ -1295,7 +1539,8 @@ function draw(dt) {
|
|
|
1295
1539
|
colour = u < 0.5 ? col.estate.get(f.from) || col.neutral : col.estate.get(f.to) || col.neutral;
|
|
1296
1540
|
est = u < 0.5 ? f.from : f.to;
|
|
1297
1541
|
// The trail: where it was a moment ago, fading, in the destination's colour.
|
|
1298
|
-
|
|
1542
|
+
// At the card level the cards fly cell to cell, not along the slots' path: no trail then.
|
|
1543
|
+
if (dotLayerA > 0.05 && !f.parent && rosterU < 0.5) {
|
|
1299
1544
|
ctx.strokeStyle = col.estate.get(f.to) || col.neutral;
|
|
1300
1545
|
ctx.lineCap = "round";
|
|
1301
1546
|
let prev = p;
|
|
@@ -1340,6 +1585,13 @@ function draw(dt) {
|
|
|
1340
1585
|
const tdE = td.get(est) ?? 0;
|
|
1341
1586
|
// Card centre -> slot -> disc, by the zoom.
|
|
1342
1587
|
const card = S.cards.get(a);
|
|
1588
|
+
// A resource the SVG has no card for grows into its roster card as it slides from its slot to its cell in its
|
|
1589
|
+
// estate's grid of cards (web/dots-cards.js).
|
|
1590
|
+
const u = card ? 0 : rosterU * (1 - tdE);
|
|
1591
|
+
if (u > 0.001) {
|
|
1592
|
+
const cell = cellOf(a, f, L, t, ease);
|
|
1593
|
+
if (cell) p = { x: lerp(p.x, cell.x, u), y: lerp(p.y, cell.y, u) };
|
|
1594
|
+
}
|
|
1343
1595
|
const d = discAt(est);
|
|
1344
1596
|
const slotPx = { x: sx(p.x), y: sy(p.y) };
|
|
1345
1597
|
const cardPx = card ? { x: vx(card.x), y: vy(card.y) } : slotPx;
|
|
@@ -1352,10 +1604,19 @@ function draw(dt) {
|
|
|
1352
1604
|
S.px[i] = q.x;
|
|
1353
1605
|
S.py[i] = q.y;
|
|
1354
1606
|
S.pvis[i] = vis > 0.2 ? 1 : 0;
|
|
1355
|
-
|
|
1607
|
+
const flying = f && f.ok && !reduced;
|
|
1608
|
+
const shape = u > 0.01 ? cardShape(q.x, q.y, u, { dotR: flying ? rDot * 1.6 : rDot, cardW: rcW, cardH: rcH }) : null;
|
|
1609
|
+
S.pw[i] = shape ? shape.w / 2 : 0;
|
|
1610
|
+
S.ph[i] = shape ? shape.h / 2 : 0;
|
|
1611
|
+
const margin = shape ? 20 + shape.w / 2 : 20;
|
|
1612
|
+
if (q.x < -margin || q.y < -margin || q.x > W + margin || q.y > H + margin) continue;
|
|
1356
1613
|
const g = glow.get(a);
|
|
1357
1614
|
if (f || g) markLit(est);
|
|
1358
1615
|
if (vis <= 0.01) continue;
|
|
1616
|
+
if (shape) {
|
|
1617
|
+
drawRosterCard(ctx, a, shape, u, { vis, colour, glow: g, ring: rings.has(a), selected: a === S.selected, takeoff: flying ? (t - f.start) / (f.end - f.start) : 1 });
|
|
1618
|
+
continue;
|
|
1619
|
+
}
|
|
1359
1620
|
if (g) {
|
|
1360
1621
|
ctx.globalAlpha = vis * g.a * 0.6;
|
|
1361
1622
|
ctx.fillStyle = g.colour;
|
|
@@ -1363,7 +1624,6 @@ function draw(dt) {
|
|
|
1363
1624
|
ctx.arc(q.x, q.y, rDot * 2.6, 0, Math.PI * 2);
|
|
1364
1625
|
ctx.fill();
|
|
1365
1626
|
}
|
|
1366
|
-
const flying = f && f.ok && !reduced;
|
|
1367
1627
|
if (flying) {
|
|
1368
1628
|
// A dot in the air is lifted: larger, with a soft halo in the colour it is turning.
|
|
1369
1629
|
ctx.globalAlpha = vis * 0.25;
|
|
@@ -1414,6 +1674,7 @@ function draw(dt) {
|
|
|
1414
1674
|
}
|
|
1415
1675
|
}
|
|
1416
1676
|
}
|
|
1677
|
+
if (S.cellMoving) moving = true;
|
|
1417
1678
|
// Landings: a small pulse at the dot and a ripple along the nearest border.
|
|
1418
1679
|
for (const f of near) {
|
|
1419
1680
|
if (t < f.end || t > f.end + RIPPLE_MS) continue;
|
|
@@ -1429,8 +1690,14 @@ function draw(dt) {
|
|
|
1429
1690
|
ctx.strokeStyle = col.estate.get(f.to) || col.neutral;
|
|
1430
1691
|
ctx.globalAlpha = a * (1 - u);
|
|
1431
1692
|
ctx.lineWidth = 1.5;
|
|
1432
|
-
|
|
1433
|
-
|
|
1693
|
+
if (S.pw[i] > 0) {
|
|
1694
|
+
// A card's landing: its outline swells and fades.
|
|
1695
|
+
const grow = 2 + u * 10;
|
|
1696
|
+
roundRect(ctx, qx - S.pw[i] - grow, qy - S.ph[i] - grow, 2 * (S.pw[i] + grow), 2 * (S.ph[i] + grow), 6 + grow / 2);
|
|
1697
|
+
} else {
|
|
1698
|
+
ctx.beginPath();
|
|
1699
|
+
ctx.arc(qx, qy, rDot * (1.2 + u * 5), 0, Math.PI * 2);
|
|
1700
|
+
}
|
|
1434
1701
|
ctx.stroke();
|
|
1435
1702
|
}
|
|
1436
1703
|
const b = boxes.get(f.to);
|
|
@@ -1456,15 +1723,25 @@ function draw(dt) {
|
|
|
1456
1723
|
const qx = S.px[i];
|
|
1457
1724
|
const qy = S.py[i];
|
|
1458
1725
|
const u = Math.min(1, (t - f.end) / PULSE_MS);
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1726
|
+
if (S.pw[i] > 0) {
|
|
1727
|
+
// A refused card: its outline in the failure colour, so its words stay readable.
|
|
1728
|
+
const out = 2 + 3 * (1 - u);
|
|
1729
|
+
ctx.globalAlpha = dotLayerA * (0.6 + 0.4 * (1 - u));
|
|
1730
|
+
ctx.strokeStyle = col.degraded;
|
|
1731
|
+
ctx.lineWidth = 2.2;
|
|
1732
|
+
roundRect(ctx, qx - S.pw[i] - out, qy - S.ph[i] - out, 2 * (S.pw[i] + out), 2 * (S.ph[i] + out), 7);
|
|
1733
|
+
ctx.stroke();
|
|
1734
|
+
} else {
|
|
1735
|
+
ctx.globalAlpha = dotLayerA * (0.35 + 0.4 * (1 - u));
|
|
1736
|
+
ctx.fillStyle = col.degraded;
|
|
1737
|
+
ctx.beginPath();
|
|
1738
|
+
ctx.arc(qx, qy, rDot * (2.2 + 1.5 * (1 - u)), 0, Math.PI * 2);
|
|
1739
|
+
ctx.fill();
|
|
1740
|
+
ctx.globalAlpha = dotLayerA;
|
|
1741
|
+
ctx.beginPath();
|
|
1742
|
+
ctx.arc(qx, qy, rDot, 0, Math.PI * 2);
|
|
1743
|
+
ctx.fill();
|
|
1744
|
+
}
|
|
1468
1745
|
const b = boxes.get(owners.get(f.address) ?? scene.source);
|
|
1469
1746
|
if (b) {
|
|
1470
1747
|
const bp = boxPx(b);
|
|
@@ -1618,18 +1895,32 @@ function startKiosk() {
|
|
|
1618
1895
|
window.addEventListener("message", onMsg);
|
|
1619
1896
|
S.off.push(() => window.removeEventListener("message", onMsg));
|
|
1620
1897
|
// The director never moves while a person has the graph in hand.
|
|
1621
|
-
|
|
1622
|
-
if (S) S.userUntil = performance.now() + 8_000;
|
|
1623
|
-
};
|
|
1624
|
-
for (const ev of ["wheel", "mousedown", "touchstart"]) {
|
|
1625
|
-
S.host.addEventListener(ev, touched, { passive: true });
|
|
1626
|
-
S.off.push(() => S && S.host.removeEventListener(ev, touched));
|
|
1627
|
-
}
|
|
1898
|
+
watchViewer();
|
|
1628
1899
|
S.camAt = null;
|
|
1629
1900
|
play(true);
|
|
1630
1901
|
toParent({ type: "behold:dots-ready", source: S.name });
|
|
1631
1902
|
}
|
|
1632
1903
|
|
|
1904
|
+
/** A viewer has the camera: the director and the tour's framing wait until VIEWER_HOLD_MS after their last input, then ease back. */
|
|
1905
|
+
function viewerHold() {
|
|
1906
|
+
if (S) S.userUntil = performance.now() + VIEWER_HOLD_MS;
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1909
|
+
/**
|
|
1910
|
+
* The director never moves while a person has the graph in hand: every input that moves the camera holds it, a wheel
|
|
1911
|
+
* or a trackpad pinch (a wheel with ctrlKey), a touch and each move of a pinch, a press and each move of a drag.
|
|
1912
|
+
*/
|
|
1913
|
+
function watchViewer() {
|
|
1914
|
+
const host = S.host;
|
|
1915
|
+
const dragging = (e) => {
|
|
1916
|
+
if (e.buttons) viewerHold();
|
|
1917
|
+
};
|
|
1918
|
+
for (const [ev, f] of [["wheel", viewerHold], ["pointerdown", viewerHold], ["mousedown", viewerHold], ["touchstart", viewerHold], ["touchmove", viewerHold], ["pointermove", dragging]]) {
|
|
1919
|
+
host.addEventListener(ev, f, { passive: true });
|
|
1920
|
+
S.off.push(() => host.removeEventListener(ev, f));
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1633
1924
|
/** A box in scene pitches, as the viewBox that frames it clear of the rail and the parent's caption. */
|
|
1634
1925
|
function frameBox(b) {
|
|
1635
1926
|
const { r, left, right } = band();
|
|
@@ -1780,13 +2071,7 @@ function startLive(kiosk) {
|
|
|
1780
2071
|
window.addEventListener("message", onMsg);
|
|
1781
2072
|
S.off.push(() => window.removeEventListener("message", onMsg));
|
|
1782
2073
|
// The director never moves while a person has the graph in hand.
|
|
1783
|
-
|
|
1784
|
-
if (S) S.userUntil = performance.now() + 8_000;
|
|
1785
|
-
};
|
|
1786
|
-
for (const ev of ["wheel", "mousedown", "touchstart"]) {
|
|
1787
|
-
S.host.addEventListener(ev, touched, { passive: true });
|
|
1788
|
-
S.off.push(() => S && S.host.removeEventListener(ev, touched));
|
|
1789
|
-
}
|
|
2074
|
+
watchViewer();
|
|
1790
2075
|
toParent({ type: "behold:dots-ready", source: S.name, live: true });
|
|
1791
2076
|
}
|
|
1792
2077
|
}
|
|
@@ -1841,6 +2126,10 @@ function takeLive(answer) {
|
|
|
1841
2126
|
S.px = new Float32Array(n);
|
|
1842
2127
|
S.py = new Float32Array(n);
|
|
1843
2128
|
S.pvis = new Uint8Array(n);
|
|
2129
|
+
S.pw = new Float32Array(n);
|
|
2130
|
+
S.ph = new Float32Array(n);
|
|
2131
|
+
// A later read may name a type the first did not, and the boxes the cards fill are the new scene's.
|
|
2132
|
+
fitRosterCards();
|
|
1844
2133
|
S.col = readColours();
|
|
1845
2134
|
busy();
|
|
1846
2135
|
S.dirty = true;
|