@logomarks/lookbook 0.0.0-stage → 0.1.2

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.
@@ -0,0 +1,1070 @@
1
+ /**
2
+ * @module @logomarks/lookbook/looks
3
+ *
4
+ * The Lookbook's drawn looks: cards whose artwork is the mark itself redrawn (traced, constructed, refracted, pixelated,
5
+ * screened, lit, flipped, contoured, debossed, heat-mapped, shadowed), not a mark laid on a picture. `card()`
6
+ * (../wall.js) picks the kind and calls `look()`; each kind's styles are a block in wall-looks.css.
7
+ *
8
+ * - Pure: HTML strings from the card's seeded random, so the page and its script make identical cards.
9
+ * - CSP: per-card values go in `style` attributes as custom properties (allowed); no `<style>`, no script. SVG filters,
10
+ * masks and patterns are inline elements with ids unique to the card (`wlk-…`; the expanded view renames its copy).
11
+ * - Motion is CSS only, on cards marked `data-anim`: the page adds `is-live` while one is near the screen (and the
12
+ * preview page always), and the animations run only then. Under reduced motion, in Plain mode and before a card is
13
+ * live, each card shows its final frame.
14
+ * - The mark is drawn once per card, in `<defs>` (`[data-m]`), and reused with `<use>`; `retarget()` swaps it for
15
+ * another mark in the expanded view.
16
+ */
17
+
18
+ import { escapeHtml } from '@arraypress/text';
19
+ import { hash, rng } from '@arraypress/og-image/palette';
20
+ import { markBox, markCells, heatField } from '../marks.js';
21
+ import { f1, pad2, withLength, def, use, mk, meta, nameB, art, around, framed, pickOf, markUrl } from './kit.js';
22
+ import { MODERN, retargetModern } from './modern.js';
23
+ import { BLOOM } from './bloom.js';
24
+ import { STREET, retargetStreet } from './street.js';
25
+ import { CLUB } from './club.js';
26
+ import { STUDIO, sansEms } from './studio.js';
27
+
28
+ /** The mark as a CSS background image (./kit.js). */
29
+ export { markUrl };
30
+ /** The bloom looks, dealt only to abstract, round marks (./bloom.js). */
31
+ export { BLOOM_KINDS, bloomFits } from './bloom.js';
32
+ /** The club looks, dealt only to marks for a club night, on the club photos (./club.js). */
33
+ export { CLUB_KINDS, CLUB_PHOTOS, clubFits } from './club.js';
34
+
35
+ /** The drawn looks' kinds. */
36
+ export const LOOK_KINDS = [
37
+ 'draw',
38
+ 'construct',
39
+ 'glassdrift',
40
+ 'pixelassemble',
41
+ 'breathe',
42
+ 'neon',
43
+ 'splitflap',
44
+ 'contour',
45
+ 'blueprint',
46
+ 'letterpress',
47
+ 'dotmatrix',
48
+ 'topo',
49
+ 'thermal',
50
+ 'longshadow',
51
+ 'acidmap',
52
+ 'megacrop',
53
+ 'outlinewall',
54
+ 'terminal',
55
+ 'pixelframe',
56
+ // the 2027 set (./modern.js), and the grid fill
57
+ 'diffusion',
58
+ 'chrome',
59
+ 'puff',
60
+ 'datamosh',
61
+ 'holo',
62
+ 'eink',
63
+ 'cloud',
64
+ 'gridfill',
65
+ // the bloom set, on the flower backgrounds (./bloom.js)
66
+ 'bloomposter',
67
+ 'bloomglow',
68
+ 'bloomband',
69
+ // the street set: festival, street and craft (./street.js)
70
+ 'laser',
71
+ 'orbittext',
72
+ 'sunshadow',
73
+ 'patch',
74
+ 'slitscan',
75
+ 'ascii',
76
+ 'stencil',
77
+ 'acrylic',
78
+ // the club set, on the nightclub photos (./club.js)
79
+ 'clubwash',
80
+ 'clubposter',
81
+ 'clubpulse',
82
+ // the studio set: quiet, current brand design (./studio.js)
83
+ 'frost',
84
+ 'spectral',
85
+ 'editorial',
86
+ 'brandsheet',
87
+ 'overprint',
88
+ ];
89
+
90
+ /** The animated ones (marked `data-anim`, started on screen). */
91
+ const ANIMATED = new Set([
92
+ 'draw',
93
+ 'construct',
94
+ 'glassdrift',
95
+ 'pixelassemble',
96
+ 'breathe',
97
+ 'neon',
98
+ 'splitflap',
99
+ 'contour',
100
+ 'terminal',
101
+ 'pixelframe',
102
+ 'dotmatrix',
103
+ 'thermal',
104
+ 'diffusion',
105
+ 'chrome',
106
+ 'puff',
107
+ 'datamosh',
108
+ 'holo',
109
+ 'eink',
110
+ 'cloud',
111
+ 'gridfill',
112
+ 'bloomglow',
113
+ 'laser',
114
+ 'orbittext',
115
+ 'sunshadow',
116
+ 'slitscan',
117
+ 'ascii',
118
+ 'clubpulse',
119
+ 'frost',
120
+ 'spectral',
121
+ ]);
122
+
123
+ /**
124
+ * Each animated look's loop, for its video download: one whole cycle of its CSS motion
125
+ * (`cycle`, seconds, the longest animation's period in wall-looks.css), played `speed` times faster, so every
126
+ * clip runs 3–6 s and loops without a seam. Keep in step with the CSS durations.
127
+ */
128
+ export const LOOK_LOOP = {
129
+ draw: { cycle: 11, speed: 2 }, // trace, fill, hold: 5.5 s
130
+ construct: { cycle: 14, speed: 2.5 }, // 5.6 s
131
+ glassdrift: { cycle: 36, speed: 6 }, // 18 s across and 18 s back (alternate): 6 s
132
+ pixelassemble: { cycle: 10, speed: 2 }, // 5 s
133
+ breathe: { cycle: 9, speed: 1.5 }, // 6 s
134
+ neon: { cycle: 7.7, speed: 1.4 }, // 5.5 s
135
+ splitflap: { cycle: 11, speed: 2 }, // 5.5 s
136
+ contour: { cycle: 4.4, speed: 1 }, // one ripple out: 4.4 s
137
+ terminal: { cycle: 6, speed: 1 }, // the log types in (done by 4.3 s), the cursor blinks: 6 s
138
+ pixelframe: { cycle: 5, speed: 1 }, // the blinking blocks' period: 5 s
139
+ dotmatrix: { cycle: 7, speed: 1 }, // power on row by row, the name scrolls in, hold, blink off: 7 s
140
+ thermal: { cycle: 7, speed: 1 }, // hunt, lock, hold, let go (the scan band twice): 7 s
141
+ diffusion: { cycle: 6, speed: 1 }, // noise, five denoising steps, hold, back to noise: 6 s
142
+ chrome: { cycle: 6, speed: 1 }, // still, the ripple runs down, sags, snaps back: 6 s
143
+ puff: { cycle: 6, speed: 1 }, // inflate, wobble, hold, deflate: 6 s
144
+ datamosh: { cycle: 6, speed: 1 }, // clean, the frame breaks and drags, a keyframe, an aftershock: 6 s
145
+ holo: { cycle: 6, speed: 1 }, // the foil there and back, one sheen, the seal a turn: 6 s
146
+ eink: { cycle: 6, speed: 1 }, // hold, the refresh flashes, the mark paints in: 6 s
147
+ cloud: { cycle: 6, speed: 1 }, // swarm in, breathe, scatter: 6 s
148
+ gridfill: { cycle: 6, speed: 1 }, // fill, hold, clear: 6 s
149
+ bloomglow: { cycle: 8, speed: 1.4 }, // the outline draws, glows, holds, fades: 5.7 s
150
+ laser: { cycle: 6, speed: 1 }, // the beams sweep in, trace the mark, pulse, sweep off: 6 s
151
+ orbittext: { cycle: 24, speed: 4 }, // one full turn of the ring: 6 s
152
+ sunshadow: { cycle: 10, speed: 2 }, // the leaves sway there and back: 5 s
153
+ slitscan: { cycle: 6, speed: 1 }, // smeared, snaps in strip by strip, holds, smears off: 6 s
154
+ ascii: { cycle: 6, speed: 1 }, // one full turn, 36 frames: 6 s
155
+ clubpulse: { cycle: 8, speed: 1.4 }, // the mark fades up, four light pulses, it fades: 5.7 s
156
+ frost: { cycle: 12, speed: 2 }, // the three lights drift out and back: 6 s
157
+ spectral: { cycle: 10, speed: 2 }, // the spectrum slides one whole tile: 5 s
158
+ };
159
+
160
+ /** How often each look is dealt, against the older looks' weights (`WEIGHTS`: photo 3, gradient 3, mono 2 … crop 1, 23
161
+ * in all): about 8.5 in 31.5 by weight, nearer 3 in 10 on a wall (neighbours avoid each other's looks, which favours the
162
+ * many light ones), so a wall is still mostly photos, colour and gradients. */
163
+ export const LOOK_WEIGHTS = {
164
+ draw: 0.55,
165
+ construct: 0.45,
166
+ glassdrift: 0.45,
167
+ pixelassemble: 0.45,
168
+ breathe: 0.4,
169
+ neon: 0.45,
170
+ splitflap: 0.45,
171
+ contour: 0.45,
172
+ blueprint: 0.45,
173
+ letterpress: 0.45,
174
+ dotmatrix: 0.45,
175
+ topo: 0.4,
176
+ thermal: 0.4,
177
+ longshadow: 0.55,
178
+ acidmap: 0.45,
179
+ megacrop: 0.45,
180
+ outlinewall: 0.4,
181
+ terminal: 0.45,
182
+ pixelframe: 0.45,
183
+ diffusion: 0.35,
184
+ chrome: 0.35,
185
+ puff: 0.35,
186
+ datamosh: 0.35,
187
+ holo: 0.35,
188
+ eink: 0.35,
189
+ cloud: 0.35,
190
+ gridfill: 0.4,
191
+ bloomposter: 0.4,
192
+ bloomglow: 0.4,
193
+ bloomband: 0.4,
194
+ laser: 0.35,
195
+ orbittext: 0.35,
196
+ sunshadow: 0.35,
197
+ patch: 0.35,
198
+ slitscan: 0.35,
199
+ ascii: 0.35,
200
+ stencil: 0.35,
201
+ acrylic: 0.35,
202
+ clubwash: 0.4,
203
+ clubposter: 0.4,
204
+ clubpulse: 0.4,
205
+ frost: 0.4,
206
+ spectral: 0.4,
207
+ editorial: 0.4,
208
+ brandsheet: 0.4,
209
+ overprint: 0.4,
210
+ };
211
+
212
+ /** Each look's card shape (width / height). */
213
+ export const LOOK_RATIO = {
214
+ draw: '4 / 5',
215
+ construct: '1 / 1',
216
+ glassdrift: '4 / 5',
217
+ pixelassemble: '1 / 1',
218
+ breathe: '4 / 5',
219
+ neon: '4 / 5',
220
+ splitflap: '4 / 5',
221
+ contour: '4 / 5',
222
+ blueprint: '4 / 5',
223
+ letterpress: '4 / 5',
224
+ dotmatrix: '5 / 4',
225
+ topo: '4 / 5',
226
+ thermal: '4 / 5',
227
+ longshadow: '1 / 1',
228
+ acidmap: '4 / 5',
229
+ megacrop: '4 / 5',
230
+ outlinewall: '1 / 1',
231
+ terminal: '4 / 5',
232
+ pixelframe: '4 / 5',
233
+ diffusion: '4 / 5',
234
+ chrome: '4 / 5',
235
+ puff: '1 / 1',
236
+ datamosh: '4 / 5',
237
+ holo: '4 / 5',
238
+ eink: '4 / 5',
239
+ cloud: '4 / 5',
240
+ gridfill: '4 / 5',
241
+ bloomposter: '3 / 2',
242
+ bloomglow: '4 / 5',
243
+ bloomband: '4 / 5',
244
+ laser: '4 / 5',
245
+ orbittext: '1 / 1',
246
+ sunshadow: '4 / 5',
247
+ patch: '1 / 1',
248
+ slitscan: '4 / 5',
249
+ ascii: '4 / 5',
250
+ stencil: '4 / 5',
251
+ acrylic: '4 / 5',
252
+ clubwash: '1 / 1',
253
+ clubposter: '4 / 5',
254
+ clubpulse: '4 / 5',
255
+ frost: '4 / 5',
256
+ spectral: '4 / 5',
257
+ editorial: '4 / 5',
258
+ brandsheet: '4 / 5',
259
+ overprint: '1 / 1',
260
+ };
261
+
262
+ /** Names for the expanded view's background label. */
263
+ export const LOOK_LABEL = {
264
+ draw: 'Draw',
265
+ construct: 'Construction',
266
+ glassdrift: 'Reeded glass',
267
+ pixelassemble: 'Pixel mosaic',
268
+ breathe: 'Halftone',
269
+ neon: 'Neon',
270
+ splitflap: 'Split-flap',
271
+ contour: 'Contour',
272
+ blueprint: 'Blueprint',
273
+ letterpress: 'Letterpress',
274
+ dotmatrix: 'Dot matrix',
275
+ topo: 'Topographic',
276
+ thermal: 'Thermal',
277
+ longshadow: 'Long shadow',
278
+ acidmap: 'Acid map',
279
+ megacrop: 'Mega crop',
280
+ outlinewall: 'Outline wall',
281
+ terminal: 'Terminal',
282
+ pixelframe: 'Pixel frame',
283
+ diffusion: 'Diffusion',
284
+ chrome: 'Liquid chrome',
285
+ puff: 'Puff',
286
+ datamosh: 'Datamosh',
287
+ holo: 'Holo foil',
288
+ eink: 'E-ink',
289
+ cloud: 'Point cloud',
290
+ gridfill: 'Grid fill',
291
+ bloomposter: 'Bloom poster',
292
+ bloomglow: 'Bloom glow',
293
+ bloomband: 'Bloom band',
294
+ laser: 'Laser show',
295
+ orbittext: 'Orbit text',
296
+ sunshadow: 'Sun shadow',
297
+ patch: 'Embroidered patch',
298
+ slitscan: 'Slit-scan',
299
+ ascii: 'ASCII',
300
+ stencil: 'Spray stencil',
301
+ acrylic: 'Backlit acrylic',
302
+ clubwash: 'Club wash',
303
+ clubposter: 'Club poster',
304
+ clubpulse: 'Club pulse',
305
+ frost: 'Frosted glass',
306
+ spectral: 'Spectral',
307
+ editorial: 'Editorial',
308
+ brandsheet: 'Brand sheet',
309
+ overprint: 'Overprint',
310
+ };
311
+
312
+ /* ---------- the looks ---------- */
313
+
314
+ /** draw: the outline traces itself, then fills solid; a long hold, then again. One ink on near-black. */
315
+ function draw(c) {
316
+ const pick = pickOf(c);
317
+ const ink = pick(c.inks);
318
+ const fig = pad2(1 + Math.floor(c.r() * 24));
319
+ return {
320
+ style: `;--ink:${ink}`,
321
+ attrs: '',
322
+ inner:
323
+ // the line is drawn inline, not with <use>: Chrome ignores pathLength on a path reached through <use>
324
+ art(around(40), `<defs>${def(c)}</defs>${mk(`${use(c, 'wx-dfill')}<g class="wx-dline" data-m="len">${withLength(c.paths)}</g>`)}`) +
325
+ meta('tl', escapeHtml(c.line)) +
326
+ meta('tr', `Fig. ${fig}`) +
327
+ `<span class="wx-foot">${nameB(c)}</span>`,
328
+ };
329
+ }
330
+
331
+ /** The construction drawn round a mark: an 8 × 8 grid on its square, its box, centre lines, diagonals, and its
332
+ * inscribed and circumscribed circles (dashed, each shown through a solid ring that draws round: a dash can't also
333
+ * draw itself). Also the radii, for the card's corner. */
334
+ export function constructGuides(paths, uid) {
335
+ const b = markBox(paths);
336
+ const cx = b.x + b.w / 2,
337
+ cy = b.y + b.h / 2,
338
+ s = Math.max(b.w, b.h),
339
+ gx = cx - s / 2,
340
+ gy = cy - s / 2;
341
+ const rIn = Math.min(b.w, b.h) / 2,
342
+ rOut = Math.hypot(b.w, b.h) / 2;
343
+ let grid = '';
344
+ for (let i = 0; i <= 8; i++) {
345
+ const t = (s * i) / 8;
346
+ grid += `M${f1(gx + t)} ${f1(gy)}V${f1(gy + s)}M${f1(gx)} ${f1(gy + t)}H${f1(gx + s)}`;
347
+ }
348
+ const ext = 40;
349
+ const lines = [
350
+ `M${f1(b.x)} ${f1(b.y)}H${f1(b.x + b.w)}V${f1(b.y + b.h)}H${f1(b.x)}Z`,
351
+ `M${f1(cx)} ${f1(gy - ext)}V${f1(gy + s + ext)}`,
352
+ `M${f1(gx - ext)} ${f1(cy)}H${f1(gx + s + ext)}`,
353
+ `M${f1(gx)} ${f1(gy)}L${f1(gx + s)} ${f1(gy + s)}M${f1(gx + s)} ${f1(gy)}L${f1(gx)} ${f1(gy + s)}`,
354
+ ];
355
+ const circle = (r, k) => {
356
+ const id = `${uid}-c${k}`;
357
+ return `<mask id="${id}" maskUnits="userSpaceOnUse" x="-200" y="-200" width="912" height="912"><circle class="wx-crev" style="--k:${k}" cx="${f1(cx)}" cy="${f1(cy)}" r="${f1(r)}" transform="rotate(-90 ${f1(cx)} ${f1(cy)})" pathLength="1" /></mask><circle class="wx-ccirc" cx="${f1(cx)}" cy="${f1(cy)}" r="${f1(r)}" mask="url(#${id})" />`;
358
+ };
359
+ const svg = `<path class="wx-cgrid" d="${grid}" />${lines.map((d, k) => `<path class="wx-cline" style="--k:${k}" d="${d}" pathLength="1" />`).join('')}${circle(rIn, 0)}${circle(rOut, 1)}<circle class="wx-cdot" cx="${f1(cx)}" cy="${f1(cy)}" r="4" />`;
360
+ return { svg, rIn, rOut };
361
+ }
362
+ const radii = (g) => `R ${Math.round(g.rIn)} · ${Math.round(g.rOut)}`;
363
+
364
+ /** construct: the mark's construction drawn in thin blue, then the mark over it. */
365
+ function construct(c) {
366
+ const g = constructGuides(c.paths, c.uid);
367
+ // room for the widest circumscribed circle (a 448 square's), whatever the mark, so another mark fits the same frame
368
+ const body = `<defs>${def(c)}</defs>${mk(`<g data-guides="construct">${g.svg}</g>${use(c, 'wx-cmark')}`)}`;
369
+ return {
370
+ style: '',
371
+ attrs: '',
372
+ inner:
373
+ art(around(85), body) +
374
+ meta('tl', 'Construction · v1.0') +
375
+ meta('tr', 'Grid 8 × 8') +
376
+ `<span class="wx-foot">${nameB(c)}</span>` +
377
+ `<span class="wx-meta is-br" data-radii>${radii(g)}</span>`,
378
+ };
379
+ }
380
+
381
+ /** glassdrift: the mark sliding slowly behind reeded glass. Each flute shows the scene squeezed about its own centre (a
382
+ * cylinder lens), so the mark repeats and bends across them; soft shading, no hard lines. */
383
+ // (2026-11-12: the scene used to be each flute's background, moved by an animated custom property, which restyled and
384
+ // repainted 14–18 flutes a card every frame: five cards took a whole core. Now each flute's scene is a layer.)
385
+ function glassdrift(c) {
386
+ const pick = pickOf(c);
387
+ const [bg, fg] = pick(c.palettes);
388
+ const n = pick([14, 16, 18]);
389
+ // each flute holds its own copy of the scene (<b>), slid by `transform`: the compositor moves it, nothing repaints
390
+ const flutes = Array.from({ length: n }, (_, i) => `<i style="--i:${i}"><b></b></i>`).join('');
391
+ return {
392
+ style: `;--bg:${bg};--fg:${fg};--m:${markUrl(c.paths, fg)};--n:${n};--gd:-${(c.r() * 18).toFixed(2)}s`,
393
+ attrs: '',
394
+ inner:
395
+ `<svg class="wx-def" aria-hidden="true"><defs>${def(c)}</defs></svg>` +
396
+ `<span class="wx-glass" data-ink="${fg}">${flutes}</span>` +
397
+ meta('tl', `Reeded · ${n}`) +
398
+ meta('tr', escapeHtml(c.line)) +
399
+ `<span class="wx-foot">${nameB(c)}</span>`,
400
+ };
401
+ }
402
+
403
+ /** The pixel mosaic's cells: square tiles, `n` across, each popping in at its own moment (seeded order). */
404
+ export function mosaicArt(paths, uid, grey, r) {
405
+ const { grid, on } = markCells(paths, 12);
406
+ const { cols, rows, cell, x0, y0 } = grid;
407
+ const idx = [];
408
+ on.forEach((v, i) => v && idx.push(i));
409
+ // a seeded order to pop in
410
+ for (let i = idx.length - 1; i > 0; i--) {
411
+ const j = Math.floor(r() * (i + 1));
412
+ [idx[i], idx[j]] = [idx[j], idx[i]];
413
+ }
414
+ const gap = cell * 0.1,
415
+ span = 3.2;
416
+ const greys = ['#ffffff', '#d6d6d6', '#a8a8a8', '#7a7a7a', '#ececec'];
417
+ const tiles = idx
418
+ .map((i, k) => {
419
+ const q = i % cols,
420
+ j = Math.floor(i / cols);
421
+ const tone = grey ? `;--g:${greys[Math.floor(r() * greys.length)]}` : '';
422
+ return `<rect x="${f1(x0 + q * cell + gap / 2)}" y="${f1(y0 + j * cell + gap / 2)}" width="${f1(cell - gap)}" height="${f1(cell - gap)}" style="--d:${((k / Math.max(1, idx.length)) * span).toFixed(2)}s${tone}" />`;
423
+ })
424
+ .join('');
425
+ const pat = `<pattern id="${uid}-g" patternUnits="userSpaceOnUse" x="${f1(x0)}" y="${f1(y0)}" width="${f1(cell)}" height="${f1(cell)}"><rect x="${f1(gap / 2)}" y="${f1(gap / 2)}" width="${f1(cell - gap)}" height="${f1(cell - gap)}" /></pattern>`;
426
+ return {
427
+ svg: `<defs>${pat}</defs><rect class="wx-pxbed" x="${f1(x0)}" y="${f1(y0)}" width="${f1(cols * cell)}" height="${f1(rows * cell)}" fill="url(#${uid}-g)" /><g class="wx-pxcells">${tiles}</g>`,
428
+ cols,
429
+ rows,
430
+ count: idx.length,
431
+ };
432
+ }
433
+
434
+ /** pixelassemble: the mark as a neon mosaic of square cells (lime, or greys) popping in one by one; a hold; it clears. */
435
+ function pixelassemble(c) {
436
+ const grey = c.r() < 0.4;
437
+ const px = mosaicArt(c.paths, c.uid, grey, rng(hash(c.slug) + 17));
438
+ return {
439
+ style: grey ? ';--px:#ffffff' : `;--px:${c.accent}`,
440
+ attrs: '',
441
+ inner:
442
+ `<svg class="wx-def" aria-hidden="true"><defs>${def(c)}</defs></svg>` +
443
+ art(around(40), px.svg, grey ? 'is-grey' : '', ` data-px="mosaic${grey ? '-grey' : ''}"`) +
444
+ `<span class="wx-meta is-tl" data-pxsize>Mosaic ${px.cols} × ${px.rows}</span>` +
445
+ `<span class="wx-meta is-tr" data-pxcount>${px.count} px</span>` +
446
+ `<span class="wx-foot">${nameB(c)}</span>`,
447
+ };
448
+ }
449
+
450
+ /** breathe: the mark in ink on a flat colour, under a halftone screen in the ground's colour whose dots swell and shrink,
451
+ * so the mark melts away from the bottom up and comes back. Rows of round-capped dashes: light. */
452
+ function breathe(c) {
453
+ const pick = pickOf(c);
454
+ const [bg, fg] = pick(c.palettes);
455
+ // rows over the whole 448 frame (dots in the ground's colour only show over the mark), so any mark fits under them
456
+ const b = { x: 32, y: 32, w: 448, h: 448 };
457
+ const g = 16;
458
+ const y0 = b.y - g / 2,
459
+ y1 = b.y + b.h + g;
460
+ const rows = [];
461
+ const total = Math.ceil((y1 - y0) / g);
462
+ for (let k = 0; k < total; k++) {
463
+ const y = y1 - k * g; // k counts up from the bottom
464
+ rows.push(
465
+ `<line x1="${f1(b.x - g)}" x2="${f1(b.x + b.w + g)}" y1="${f1(y)}" y2="${f1(y)}" style="--k:${k}"${k % 2 ? ' class="is-odd"' : ''} />`,
466
+ );
467
+ }
468
+ return {
469
+ style: `;--bg:${bg};--fg:${fg};--rows:${total}`,
470
+ attrs: '',
471
+ inner:
472
+ art(around(56), `<defs>${def(c)}</defs>${mk(`${use(c, 'wx-bmark')}<g class="wx-bdots">${rows.join('')}</g>`)}`) +
473
+ meta('tl', escapeHtml(c.line)) +
474
+ meta('tr', 'Halftone · 45°') +
475
+ `<span class="wx-foot">${nameB(c)}</span>`,
476
+ };
477
+ }
478
+
479
+ /** neon: the mark as a glowing tube on a dark wall, in one ink, with a rare flicker. */
480
+ function neon(c) {
481
+ const pick = pickOf(c);
482
+ const ink = pick(c.inks);
483
+ return {
484
+ style: `;--ink:${ink};--nd:-${(c.r() * 8).toFixed(2)}s`,
485
+ attrs: '',
486
+ inner:
487
+ art(around(72), `<defs>${def(c)}</defs>${mk(use(c, 'wx-nglow') + use(c, 'wx-ncore'))}`) +
488
+ meta('tl', 'Open late') +
489
+ meta('tr', escapeHtml(c.line)) +
490
+ `<span class="wx-foot">${nameB(c, 'wx-nname')}</span>`,
491
+ };
492
+ }
493
+
494
+ /** splitflap: the mark above its name on a departure board, each letter flipping through a few characters before it
495
+ * lands, one after another. */
496
+ function splitflap(c) {
497
+ const pick = pickOf(c);
498
+ const ink = pick(['#f4f3ef', '#ffd23f', '#f4f3ef']);
499
+ const POOL = 'ABCDEFGHJKLMNOPRSTUVWXYZ0123456789';
500
+ const letters = [...c.name.toUpperCase()]
501
+ .map((ch, i) => {
502
+ const roll = [0, 1, 2, 3].map(() => POOL[Math.floor(c.r() * POOL.length)]);
503
+ return `<span class="wx-flap" style="--i:${i}"><span class="wx-roll" aria-hidden="true">${roll.map((x) => `<i>${x}</i>`).join('')}<i>${escapeHtml(ch)}</i></span></span>`;
504
+ })
505
+ .join('');
506
+ const hh = pad2(5 + Math.floor(c.r() * 18)),
507
+ mm = pad2(Math.floor(c.r() * 12) * 5),
508
+ gate = 1 + Math.floor(c.r() * 24);
509
+ return {
510
+ style: `;--ink:${ink}`,
511
+ attrs: '',
512
+ inner:
513
+ art(around(24), `<defs>${def(c)}</defs>${mk(use(c, 'wx-fmark'))}`) +
514
+ meta('tl', 'Departures') +
515
+ meta('tr', `${hh}:${mm}`) +
516
+ // the name's own text is kept (data-own), so a name typed in the toolbar and cleared again comes back plain
517
+ `<span class="wx-board"><b class="wc-name wx-flaps" data-own="${escapeHtml(c.name)}" aria-label="${escapeHtml(c.name)}">${letters}</b></span>` +
518
+ meta('bl', `Gate ${pad2(gate)} · ${escapeHtml(c.line)}`) +
519
+ meta('br', 'On time'),
520
+ };
521
+ }
522
+
523
+ /** contour: the mark in ink on a soft flat colour, its outline offset as rings that travel slowly outward and fade;
524
+ * a two-line title top left, a number bottom left. Each ring is a wide stroke in ink under a slightly narrower one in
525
+ * the ground's colour, which leaves a thin line at a true round offset. */
526
+ function contour(c) {
527
+ const pick = pickOf(c);
528
+ const bg = pick(['#e7e2d6', '#dfe6ea', '#ecdcd2', '#dfe8da', '#e6e0ef', '#eee8cf']);
529
+ const ink = pick(['#141414', '#141414', c.inks[0], c.inks[1]]);
530
+ const n = 5;
531
+ let rings = '';
532
+ for (let k = n - 1; k >= 0; k--) rings += use(c, 'wx-ri', ` style="--k:${k}"`) + use(c, 'wx-rg', ` style="--k:${k}"`);
533
+ return {
534
+ style: `;--bg:${bg};--ink:${ink};--n:${n}`,
535
+ attrs: '',
536
+ inner:
537
+ art(around(140), `<defs>${def(c)}</defs>${mk(rings + use(c, 'wx-rmark'))}`) +
538
+ `<span class="wx-title">${nameB(c, '', false)}<i>${escapeHtml(c.line)}</i></span>` +
539
+ `<span class="wx-num">${pad2(1 + Math.floor(c.r() * 12))}</span>` +
540
+ meta('br', `Offset × ${n}`),
541
+ };
542
+ }
543
+
544
+ /** A drawing's centre lines and dimensions round a mark: extension lines, dimension lines with ticks, the measures. */
545
+ export function blueprintDims(paths) {
546
+ const b = markBox(paths);
547
+ const cx = b.x + b.w / 2,
548
+ cy = b.y + b.h / 2;
549
+ const dy = b.y + b.h + 34,
550
+ dx = b.x + b.w + 34;
551
+ const t = 7;
552
+ return (
553
+ `<path class="wx-pcl" d="M${f1(cx)} ${f1(b.y - 24)}V${f1(b.y + b.h + 24)}M${f1(b.x - 24)} ${f1(cy)}H${f1(b.x + b.w + 24)}" />` +
554
+ `<path class="wx-pthin" d="M${f1(b.x)} ${f1(b.y + b.h + 8)}V${f1(dy + 10)}M${f1(b.x + b.w)} ${f1(b.y + b.h + 8)}V${f1(dy + 10)}M${f1(b.x + b.w + 8)} ${f1(b.y)}H${f1(dx + 10)}M${f1(b.x + b.w + 8)} ${f1(b.y + b.h)}H${f1(dx + 10)}" />` +
555
+ `<path class="wx-pdim" d="M${f1(b.x)} ${f1(dy)}H${f1(b.x + b.w)}M${f1(b.x - t / 2)} ${f1(dy + t / 2)}l${t} ${-t}M${f1(b.x + b.w - t / 2)} ${f1(dy + t / 2)}l${t} ${-t}M${f1(dx)} ${f1(b.y)}V${f1(b.y + b.h)}M${f1(dx - t / 2)} ${f1(b.y + t / 2)}l${t} ${-t}M${f1(dx - t / 2)} ${f1(b.y + b.h + t / 2)}l${t} ${-t}" />` +
556
+ `<text class="wx-ptext" x="${f1(cx)}" y="${f1(dy - 7)}" text-anchor="middle">${Math.round(b.w)}</text>` +
557
+ `<text class="wx-ptext" x="${f1(dx - 7)}" y="${f1(cy)}" text-anchor="middle" transform="rotate(-90 ${f1(dx - 7)} ${f1(cy)})">${Math.round(b.h)}</text>`
558
+ );
559
+ }
560
+
561
+ /** blueprint: white line work of the mark on blueprint blue, a fine grid, centre lines, dimensions and a title block. */
562
+ function blueprint(c) {
563
+ const no = String(1 + Math.floor(c.r() * 999)).padStart(3, '0');
564
+ return {
565
+ style: '',
566
+ attrs: '',
567
+ inner:
568
+ art(
569
+ '-70 -50 652 652',
570
+ `<defs>${def(c)}</defs>${mk(`${use(c, 'wx-pmark')}<g data-guides="blueprint">${blueprintDims(c.paths)}</g>`)}`,
571
+ ) +
572
+ meta('tl', 'Sheet 1 / 1') +
573
+ meta('tr', 'Rev. A') +
574
+ `<span class="wx-tblock">${nameB(c)}<i>DWG LM-${no}</i><i>Scale 1:1</i><i>${escapeHtml(c.line)}</i></span>`,
575
+ };
576
+ }
577
+
578
+ /** letterpress: the mark debossed into thick cotton paper (a shadow inside its top edges, light inside the lower ones,
579
+ * a bright lip under it), blind or pressed in one ink. */
580
+ function letterpress(c) {
581
+ const pick = pickOf(c);
582
+ const paper = pick(['#f1ece2', '#efebe3', '#f3efe6', '#ece6da']);
583
+ const inked = c.r() < 0.5;
584
+ const ink = inked ? pick([c.inks[0], c.inks[1], c.inks[3], c.inks[5], '#1c1c1c']) : '';
585
+ const id = `${c.uid}-lp`;
586
+ const filter = `<filter id="${id}" x="-10%" y="-10%" width="120%" height="120%" color-interpolation-filters="sRGB"><feOffset in="SourceAlpha" dx="2.5" dy="3.5" /><feGaussianBlur stdDeviation="2.6" result="b1" /><feComposite in="SourceAlpha" in2="b1" operator="out" result="in1" /><feFlood flood-color="#000" flood-opacity="0.42" /><feComposite in2="in1" operator="in" result="sh" /><feOffset in="SourceAlpha" dx="-2" dy="-2.5" /><feGaussianBlur stdDeviation="2" result="b2" /><feComposite in="SourceAlpha" in2="b2" operator="out" result="in2" /><feFlood flood-color="#fff" flood-opacity="0.55" /><feComposite in2="in2" operator="in" result="hi" /><feOffset in="SourceAlpha" dx="0" dy="1.8" result="o3" /><feComposite in="o3" in2="SourceAlpha" operator="out" result="rim" /><feFlood flood-color="#fff" flood-opacity="0.8" /><feComposite in2="rim" operator="in" result="lip" /><feMerge><feMergeNode in="lip" /><feMergeNode in="SourceGraphic" /><feMergeNode in="sh" /><feMergeNode in="hi" /></feMerge></filter>`;
587
+ return {
588
+ style: `;--bg:${paper}${inked ? `;--ink:${ink}` : ''}`,
589
+ attrs: '',
590
+ inner:
591
+ art(around(116), `<defs>${def(c)}${filter}</defs>${mk(use(c, `wx-lmark${inked ? ' is-inked' : ''}`, ` filter="url(#${id})"`))}`) +
592
+ meta('tl', 'Cotton · 600 gsm') +
593
+ meta('tr', inked ? 'One ink' : 'Blind') +
594
+ `<span class="wx-foot is-centre">${nameB(c)}</span>`,
595
+ };
596
+ }
597
+
598
+ /** The dot matrix's layers: every LED (dim, one pattern), and the lit ones (the mark's cells), `n` across. The lit LEDs
599
+ * are drawn row by row (a path of round dots a row and brightness: zero-length lines with round caps), so the panel can
600
+ * power on a row at a time with a few dozen elements, not hundreds; each LED is one of three brightnesses (seeded), and
601
+ * one is a tired LED, dimmer than the rest. */
602
+ export function ledArt(paths, uid, n, viewBox, seed) {
603
+ const { grid, on } = markCells(paths, n);
604
+ const { cols, rows, cell, x0, y0 } = grid;
605
+ const r = rng(seed);
606
+ const dot = (id) =>
607
+ `<pattern id="${id}" patternUnits="userSpaceOnUse" x="${f1(x0)}" y="${f1(y0)}" width="${f1(cell)}" height="${f1(cell)}"><circle cx="${f1(cell / 2)}" cy="${f1(cell / 2)}" r="${f1(cell * 0.36)}" /></pattern>`;
608
+ const [vx, vy, vw, vh] = viewBox.split(' ').map(Number);
609
+ const lit = [];
610
+ on.forEach((v, i) => v && lit.push(i));
611
+ const tired = lit.length > 12 ? lit[Math.floor(r() * lit.length)] : -1;
612
+ let rowsSvg = '';
613
+ for (let j = 0; j < rows; j++) {
614
+ const d = ['', '', '', ''];
615
+ for (let q = 0; q < cols; q++) {
616
+ const i = j * cols + q;
617
+ if (!on[i]) continue;
618
+ const x = r();
619
+ const b = i === tired ? 3 : x < 0.62 ? 0 : x < 0.9 ? 1 : 2;
620
+ d[b] += `M${f1(x0 + (q + 0.5) * cell)} ${f1(y0 + (j + 0.5) * cell)}h0`;
621
+ }
622
+ d.forEach((p, b) => p && (rowsSvg += `<path class="wx-lr${b ? ` is-b${b}` : ''}" style="--r:${j}" d="${p}" />`));
623
+ }
624
+ return {
625
+ dim: `<defs>${dot(`${uid}-off`)}</defs><rect x="${vx}" y="${vy}" width="${vw}" height="${vh}" fill="url(#${uid}-off)" />`,
626
+ lit: `<g class="wx-lrows" style="--cell:${f1(cell)}">${rowsSvg}</g>`,
627
+ cols,
628
+ rows,
629
+ };
630
+ }
631
+
632
+ /** dotmatrix: the mark lit on an LED panel, round dots on near-black, amber or one ink; the name in a dot face. Live, the
633
+ * panel powers on row by row (each LED warming from a deep red-orange to its colour with a little flash), the name
634
+ * scrolls in like a departure board, a camera's refresh band rolls down, and it blinks off and on again. */
635
+ function dotmatrix(c) {
636
+ const pick = pickOf(c);
637
+ const ink = c.r() < 0.5 ? '#ffb000' : pick([c.inks[2], c.inks[6], c.inks[1], c.inks[4]]);
638
+ const n = 24;
639
+ const vb = framed(5 / 4, 0.62);
640
+ const led = ledArt(c.paths, c.uid, n, vb, Math.floor(c.r() * 1e9));
641
+ return {
642
+ style: `;--ink:${ink}`,
643
+ attrs: '',
644
+ inner:
645
+ `<svg class="wx-def" aria-hidden="true"><defs>${def(c)}</defs></svg>` +
646
+ art(vb, led.dim, 'wx-ledoff', ` preserveAspectRatio="xMidYMid slice" data-px="led"`) +
647
+ art(vb, led.lit, 'wx-ledon', ' preserveAspectRatio="xMidYMid slice"') +
648
+ `<span class="wx-ledscan" aria-hidden="true"></span>` +
649
+ `<span class="wx-meta is-tl" data-pxsize>LED ${led.cols} × ${led.rows}</span>` +
650
+ meta('tr', escapeHtml(c.line)) +
651
+ `<span class="wx-foot wx-ledfoot">${nameB(c, 'wx-dotface', false)}</span>`,
652
+ };
653
+ }
654
+
655
+ /** topo: the mark as a hill on a map: nested contour lines inside it (inward offsets, an index line every fourth, each
656
+ * band a shade higher), a few faint ones round it, a graticule, a scale bar and an elevation. */
657
+ function topo(c) {
658
+ const pick = pickOf(c);
659
+ const bg = pick(['#ecebe4', '#e9eee7', '#eef0f2', '#f1ece4']);
660
+ const ink = pick(['#7a4b2a', '#7a4b2a', c.inks[0], '#1a1a1a', '#0e7c6e']);
661
+ const n = 14;
662
+ let inner = '';
663
+ for (let k = n; k >= 1; k--)
664
+ inner += use(c, `wx-tl${k % 4 === 0 ? ' is-idx' : ''}`, ` style="--k:${k}"`) + use(c, 'wx-tg', ` style="--k:${k}"`);
665
+ let outer = '';
666
+ for (let k = 3; k >= 1; k--) outer += use(c, 'wx-to', ` style="--k:${k}"`) + use(c, 'wx-tog', ` style="--k:${k}"`);
667
+ const clip = `<clipPath id="${c.uid}-k" data-m>${c.paths}</clipPath>`;
668
+ const elev = (600 + Math.floor(c.r() * 30) * 50).toLocaleString('en-GB');
669
+ const lat = 50 + Math.floor(c.r() * 8),
670
+ lon = 1 + Math.floor(c.r() * 6);
671
+ return {
672
+ style: `;--bg:${bg};--ink:${ink};--n:${n}`,
673
+ attrs: '',
674
+ inner:
675
+ art(
676
+ around(64),
677
+ `<defs>${def(c)}${clip}<mask id="${c.uid}-o" maskUnits="userSpaceOnUse" x="-200" y="-200" width="912" height="912">${outer}</mask></defs>${mk(`<rect class="wx-tout" x="-200" y="-200" width="912" height="912" mask="url(#${c.uid}-o)" /><g clip-path="url(#${c.uid}-k)">${use(c, 'wx-tfill', ` style="--k:${n + 1}"`)}${inner}</g>${use(c, 'wx-tedge')}`)}`,
678
+ ) +
679
+ meta('tl', `Sheet ${pad2(1 + Math.floor(c.r() * 99))} · 1:25 000`) +
680
+ meta('tr', `${lat}°N ${lon}°W`) +
681
+ `<span class="wx-foot">${nameB(c)}<i>Summit ${elev} m · CI 10 m</i></span>` +
682
+ `<span class="wx-scalebar" aria-hidden="true"><i></i><i></i><i></i><i></i><em>1 km</em></span>`,
683
+ };
684
+ }
685
+
686
+ /** The seeker's crosshair: four ticks round a gap. */
687
+ const CROSS = 'M-38 0H-12M12 0H38M0 -38V-12M0 12V38';
688
+
689
+ /** The thermal look's heat seeker: a reticle that hunts across the mark in short, overshooting jumps (four points, each
690
+ * warmer and nearer), homes onto the hottest spot, locks (its brackets snap in and pulse, LOCK shows), holds, and lets go
691
+ * back to where it started. The readout beside it ticks up as it closes in. Everything is drawn round the mark's own heat
692
+ * (`heatField`), so the lock lands where the picture is whitest; the timings are the CSS's (wall-looks.css, thermal). */
693
+ export function seekerArt(paths, uid, seed, lo, hi) {
694
+ const r = rng(seed);
695
+ const f = heatField(paths);
696
+ const { grid, heat, ink, peak } = f;
697
+ const T = { x: peak.x, y: peak.y };
698
+ const dist = (a, b) => Math.hypot(a.x - b.x, a.y - b.y);
699
+ const at = (i) => ({
700
+ x: grid.x0 + ((i % grid.cols) + 0.5) * grid.cell,
701
+ y: grid.y0 + (Math.floor(i / grid.cols) + 0.5) * grid.cell,
702
+ v: heat[i],
703
+ });
704
+ // the cells on the mark, coolest first
705
+ const cand = [];
706
+ for (let i = 0; i < heat.length; i++) if (ink[i] > 0.5) cand.push(at(i));
707
+ cand.sort((a, b) => a.v - b.v);
708
+ const pts = [];
709
+ const Q = [0.1, 0.35, 0.6, 0.82];
710
+ for (let k = 0; k < 4; k++) {
711
+ const prev = pts[k - 1];
712
+ const band = (w) => cand.slice(Math.floor(cand.length * Math.max(0, Q[k] - w)), Math.ceil(cand.length * Math.min(1, Q[k] + w)));
713
+ const ok = (p, strict) =>
714
+ dist(p, T) > 28 &&
715
+ (!prev || (dist(p, prev) > (strict ? 70 : 36) && dist(p, T) < dist(prev, T) * (strict ? 0.92 : 1.05))) &&
716
+ (prev || dist(p, T) > (strict ? 120 : 60));
717
+ let pool = band(0.12).filter((p) => ok(p, true));
718
+ if (!pool.length) pool = band(0.3).filter((p) => ok(p, false));
719
+ if (pool.length) pts.push(pool[Math.floor(r() * pool.length)]);
720
+ else {
721
+ // a mark too small or thin to hunt across: points on a closing spiral round the peak
722
+ const a = r() * Math.PI * 2,
723
+ d = [150, 105, 70, 40][k];
724
+ pts.push({
725
+ x: Math.min(500, Math.max(12, T.x + Math.cos(a) * d)),
726
+ y: Math.min(500, Math.max(12, T.y + Math.sin(a) * d)),
727
+ v: peak.v * (0.4 + k * 0.12),
728
+ });
729
+ }
730
+ }
731
+ // readings: each stop warmer than the last, the approach closing on the peak's
732
+ const temp = (v) => lo + (hi - lo) * Math.min(1, Math.max(0, v / peak.v)) ** 1.6;
733
+ // (never past the scale's top: the last stop at least 2.4° under the peak, each 0.6° or more over the one before)
734
+ const rd = pts.map((p, k) => Math.min(temp(p.v), hi - 2.4 - (3 - k) * 0.6));
735
+ for (let k = 1; k < 4; k++) rd[k] = Math.max(rd[k], rd[k - 1] + 0.6);
736
+ const top = hi;
737
+ const read = [
738
+ rd[0],
739
+ rd[1],
740
+ rd[1] + 0.1 + r() * 0.2,
741
+ rd[2],
742
+ rd[2] - 0.1 - r() * 0.2,
743
+ rd[3],
744
+ rd[3] + 0.1 + r() * 0.2,
745
+ top - 1.3 - r() * 0.6,
746
+ top - 0.4 - r() * 0.2,
747
+ top - 0.1,
748
+ top,
749
+ top - 0.1,
750
+ ];
751
+ const roll = read.map((t, k) => `<text x="64" y="${-42 + k * 60}">${t.toFixed(1)}°</text>`).join('');
752
+ const xy = (k, p) => `;--x${k}:${f1(p.x)};--y${k}:${f1(p.y)}`;
753
+ const vars = pts.map((p, k) => xy(String(k), p)).join('') + xy('t', T);
754
+ const svg =
755
+ `<defs><clipPath id="${uid}-rd"><rect x="60" y="-78" width="220" height="48" /></clipPath></defs>` +
756
+ `<g class="wx-sk" style="${vars.slice(1)}"><g class="wx-skc">` +
757
+ `<path class="wx-skxo" d="${CROSS}" /><path class="wx-skx" d="${CROSS}" /><circle class="wx-skdot" r="3" />` +
758
+ `<path class="wx-skb" d="M-52 -34V-52H-34M34 -52H52V-34M52 34V52H34M-34 52H-52V34" />` +
759
+ `<g clip-path="url(#${uid}-rd)"><g class="wx-skroll">${roll}</g></g>` +
760
+ `<text class="wx-sktag is-srch" x="64" y="-8">SRCH</text><text class="wx-sktag is-lock" x="64" y="-8">LOCK</text>` +
761
+ `</g></g>`;
762
+ return { svg, vars };
763
+ }
764
+
765
+ /** thermal: the mark as a warm body through an infrared camera: its coverage blurred at two radii and mapped through a
766
+ * heat ramp (deep blue, magenta, orange, yellow, white) on black, with a temperature scale; live, a heat seeker hunts
767
+ * across it and locks onto the hottest spot (`seekerArt`), under a camera's rolling scan band. The heat map is its own
768
+ * SVG and never moves, so its blurs are drawn once; only the seeker's small layer repaints. */
769
+ function thermal(c) {
770
+ const hi = 34 + c.r() * 5,
771
+ lo = 18 + c.r() * 5;
772
+ const id = `${c.uid}-ir`;
773
+ const filter = `<filter id="${id}" x="-35%" y="-35%" width="170%" height="170%" color-interpolation-filters="sRGB"><feGaussianBlur in="SourceAlpha" stdDeviation="8" result="a" /><feGaussianBlur in="SourceAlpha" stdDeviation="30" result="b" /><feComposite in="a" in2="b" operator="arithmetic" k2="0.6" k3="0.5" /><feColorMatrix type="matrix" values="0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1" /><feComponentTransfer><feFuncR type="table" tableValues="0 0.07 0.5 0.9 1 1 1" /><feFuncG type="table" tableValues="0 0.02 0.04 0.22 0.6 0.88 1" /><feFuncB type="table" tableValues="0 0.36 0.56 0.22 0.04 0.3 1" /></feComponentTransfer></filter>`;
774
+ const sk = seekerArt(c.paths, c.uid, Math.floor(c.r() * 1e9), lo, hi);
775
+ return {
776
+ style: '',
777
+ attrs: '',
778
+ inner:
779
+ art(around(90), `<defs>${def(c)}${filter}</defs>${mk(`<g filter="url(#${id})">${use(c, 'wx-hmark')}</g>`)}`) +
780
+ art(around(90), mk(sk.svg), 'wx-skart', ` data-seek="${f1(lo)},${f1(hi)}"`) +
781
+ `<span class="wx-scan" aria-hidden="true"></span>` +
782
+ meta('tl', 'IR · ε 0.95') +
783
+ meta('tr', '<em>●</em> REC') +
784
+ `<span class="wx-heat" aria-hidden="true"><i>${hi.toFixed(1)}°</i><i>${lo.toFixed(1)}°</i></span>` +
785
+ `<span class="wx-foot">${nameB(c)}</span>`,
786
+ };
787
+ }
788
+
789
+ /** longshadow: a flat mark in ink on a flat colour, a long 45° shadow in a darker shade of the ground running off the
790
+ * card (the mark's alpha swept by doubling offsets: 1, 2, 4 … 256). */
791
+ function longshadow(c) {
792
+ const pick = pickOf(c);
793
+ const [bg, fg] = pick(c.palettes.filter(([g]) => g !== '#F4F3EF'));
794
+ const id = `${c.uid}-ls`;
795
+ const m = 180,
796
+ vb = around(m);
797
+ let steps = '',
798
+ prev = 'SourceAlpha';
799
+ for (let i = 0, d = 1.5; d < 900; i++, d *= 2) {
800
+ steps += `<feOffset in="${prev}" dx="${d}" dy="${d}" result="o${i}" /><feMerge result="s${i}"><feMergeNode in="${prev}" /><feMergeNode in="o${i}" /></feMerge>`;
801
+ prev = `s${i}`;
802
+ }
803
+ const filter = `<filter id="${id}" filterUnits="userSpaceOnUse" x="${-m}" y="${-m}" width="${512 + 2 * m}" height="${512 + 2 * m}">${steps}<feFlood class="wx-lsc" /><feComposite in2="${prev}" operator="in" result="sh" /><feMerge><feMergeNode in="sh" /><feMergeNode in="SourceGraphic" /></feMerge></filter>`;
804
+ return {
805
+ style: `;--bg:${bg};--fg:${fg}`,
806
+ attrs: '',
807
+ inner:
808
+ art(vb, `<defs>${def(c)}${filter}</defs>${mk(use(c, 'wx-smark', ` filter="url(#${id})"`))}`) +
809
+ meta('tl', '45°') +
810
+ meta('tr', escapeHtml(c.line)) +
811
+ `<span class="wx-foot">${nameB(c)}</span>`,
812
+ };
813
+ }
814
+
815
+ /* ---------- the acid set: a tech brand board in acid lime, teal and near-black ---------- */
816
+
817
+ /** The acid set's colours: lime, teal, near-black. */
818
+ export const ACID = { lime: '#c6f432', teal: '#0f8b8d', black: '#0b0f0c' };
819
+ /** Portraits among the wall's photos (the rest are figures at a distance and helmets). */
820
+ const PORTRAITS = /\/(modern|y2k|red-bob|teal-shades|violet-shades|pink-holo|blue-braids)-?\d*\.webp$/;
821
+
822
+ /** acidmap: a portrait, black and white, gradient-mapped near-black → teal → lime (an SVG filter on the photo); the mark
823
+ * big in white or lime, the name small in wide-tracked capitals, one line of tight copy. */
824
+ function acidmap(c) {
825
+ const pick = pickOf(c);
826
+ const id = `${c.uid}-am`;
827
+ // grey, a little more contrast, then the three-colour map (table values: near-black, teal, lime)
828
+ const ramp = `<feComponentTransfer><feFuncR type="table" tableValues="0.035 0.045 0.06 0.42 0.78" /><feFuncG type="table" tableValues="0.05 0.24 0.55 0.82 0.96" /><feFuncB type="table" tableValues="0.04 0.26 0.55 0.38 0.2" /></feComponentTransfer>`;
829
+ const filter = `<filter id="${id}" x="0" y="0" width="100%" height="100%" color-interpolation-filters="sRGB"><feColorMatrix type="saturate" values="0" /><feComponentTransfer><feFuncR type="linear" slope="1.25" intercept="-0.08" /><feFuncG type="linear" slope="1.25" intercept="-0.08" /><feFuncB type="linear" slope="1.25" intercept="-0.08" /></feComponentTransfer>${ramp}</filter>`;
830
+ const ink = pick(['#ffffff', ACID.lime]);
831
+ return {
832
+ style: `;--bg:${ACID.black};--mk:${ink}`,
833
+ attrs: '',
834
+ inner:
835
+ `<svg class="wx-def" aria-hidden="true"><defs>${def(c)}${filter}</defs></svg>` +
836
+ `<img src="${c.photo(PORTRAITS)}" alt="" loading="lazy" decoding="async" style="filter:url(#${id})" />` +
837
+ `<svg class="wx-art wx-ammark" viewBox="0 0 512 512" aria-hidden="true">${mk(`<use href="#${c.uid}-m" />`)}</svg>` +
838
+ `<span class="wx-amword"><b class="wc-name">${escapeHtml(c.name)}</b><i>${escapeHtml(c.tagline)}</i></span>` +
839
+ meta('tr', escapeHtml(c.line)),
840
+ };
841
+ }
842
+
843
+ /** megacrop: the mark so big it runs off two or three edges, a tone off the ground; a small lockup centred on it in a
844
+ * strong ink, a tiny tracked line under. Two tones, where the crop look is one. */
845
+ function megacrop(c) {
846
+ const pick = pickOf(c);
847
+ const sets = [
848
+ { bg: ACID.lime, big: '#a9d12a', ink: ACID.black },
849
+ { bg: ACID.lime, big: '#93b81f', ink: ACID.black },
850
+ { bg: ACID.black, big: '#1a2614', ink: ACID.lime },
851
+ { bg: ACID.teal, big: '#0c7476', ink: ACID.lime },
852
+ ];
853
+ const own = c.r() < 0.6 ? pick(sets) : (([bg, fg]) => ({ bg, big: `color-mix(in srgb, ${fg} 13%, ${bg})`, ink: fg }))(pick(c.palettes));
854
+ const bs = Math.round(150 + c.r() * 60),
855
+ bx = Math.round((c.r() - 0.5) * 44),
856
+ by = Math.round((c.r() - 0.5) * 40);
857
+ return {
858
+ style: `;--bg:${own.bg};--fg:${own.ink};--big:${own.big};--bs:${bs};--bx:${bx};--by:${by}`,
859
+ attrs: '',
860
+ inner:
861
+ `<svg class="wx-def" aria-hidden="true"><defs>${def(c)}</defs></svg>` +
862
+ `<svg class="wx-art wx-mbig" viewBox="0 0 512 512" aria-hidden="true"><use href="#${c.uid}-m" /></svg>` +
863
+ `<span class="wc-lockup is-stack wx-mlock"><svg viewBox="0 0 512 512" fill="currentColor" aria-hidden="true"><use href="#${c.uid}-m" /></svg>${nameB(c)}<i>${escapeHtml(c.line)}</i></span>`,
864
+ };
865
+ }
866
+
867
+ /** outlinewall: near-black, a soft teal-to-lime glow, the mark solid lime in the middle, a huge faint outline of it
868
+ * cropped along the bottom, a fine 8 × 8 lime grid with a cell or two filled, and the corner words. */
869
+ function outlinewall(c) {
870
+ const cells = Array.from({ length: c.r() < 0.5 ? 1 : 2 }, () => {
871
+ const col = Math.floor(c.r() * 8),
872
+ row = [1, 2, 5, 6][Math.floor(c.r() * 4)]; // (never the top or bottom row: the corner words sit there)
873
+ return `<i style="--c:${col};--r:${row}"></i>`;
874
+ }).join('');
875
+ const ox = Math.round((c.r() - 0.5) * 30);
876
+ return {
877
+ style: `;--bg:${ACID.black};--ink:${ACID.lime};--ox:${ox}`,
878
+ attrs: '',
879
+ inner:
880
+ `<span class="wx-ogrid" aria-hidden="true">${cells}</span>` +
881
+ art(around(40), `<defs>${def(c)}</defs>${mk(use(c, 'wx-ofill'))}`, 'wx-omark') +
882
+ `<svg class="wx-art wx-oline" viewBox="0 0 512 512" aria-hidden="true"><use href="#${c.uid}-m" class="wx-ostroke" /></svg>` +
883
+ `<span class="wx-oname">${nameB(c, '', false)}</span>` +
884
+ meta('tl', `@${escapeHtml(c.name.toLowerCase())}`) +
885
+ meta('tr', '©2026') +
886
+ meta('bl', 'Discovery') +
887
+ meta('br', escapeHtml(c.line)),
888
+ };
889
+ }
890
+
891
+ /* ---------- the terminal set: a crypto / HUD board in the accent (acid lime) on black ---------- */
892
+
893
+ /** Michroma's capitals, in ems (measured): most are about 1, M and W far wider, I a sliver. */
894
+ const WIDE = { M: 1.37, W: 1.63, N: 1.13, I: 0.28, ' ': 0.28, E: 0.88, F: 0.84, J: 0.84, L: 0.81, T: 0.94, '&': 1.19, '-': 0.5 };
895
+
896
+ /**
897
+ * A name's width in ems, set in Michroma capitals (the terminal's name is sized to its measure from this; a count of
898
+ * letters cut MANSARD off at the card's edge).
899
+ *
900
+ * @param name The name.
901
+ */
902
+ export function wideEms(name) {
903
+ let w = 0;
904
+ for (const ch of name.toUpperCase()) w += WIDE[ch] ?? 1.04;
905
+ return Math.max(4, +w.toFixed(2));
906
+ }
907
+
908
+ /**
909
+ * Refits a name that's sized from its width (`data-fit`: the terminal's and the editorial's) after its text changes: a
910
+ * name typed in the Lookbook's toolbar.
911
+ *
912
+ * @param el The name's element.
913
+ */
914
+ export function refit(el) {
915
+ const fit = el.dataset.fit;
916
+ if (fit) el.style.setProperty('--chars', String((fit === 'wide' ? wideEms : sansEms)(el.textContent ?? '')));
917
+ }
918
+
919
+ /** terminal: a HUD on black: status lines typing in one by one in lime mono, a lime panel with chamfered corners,
920
+ * notches and tabs holding the mark in black, a row of HUD glyphs, and the name huge in a wide techno face. */
921
+ function terminal(c) {
922
+ const d = (n) => Math.floor(c.r() * n);
923
+ const code = `${100 + d(900)}-${'ABCDEFHKMNPRSTX'[d(15)]}<${1 + d(9)}.${10 + d(90)}.${1 + d(9)}.${100 + d(156)}>`;
924
+ const lines = ['PUBLIC ACCESS TERMINAL', code, 'CORE REVIEW [START]', `CORE 1 ........OK`, `CORE 2 ........OK`, 'CORES STABLE'];
925
+ const line = (t, i) => `<span class="wx-hl" style="--n:${t.length};--l:${i}">${escapeHtml(t)}</span>`;
926
+ const hud = lines.slice(0, -1).map(line).join('') + `<span class="wx-hrow">${line(lines[5], 5)}<i class="wx-cur">_</i></span>`;
927
+ const n2 = () => pad2(d(100));
928
+ const glyphs = `<i class="wx-bar"></i><i>+</i><i>${n2()}</i><i>×</i><i class="wx-tgt"></i><i>${n2()}</i><i>+</i>`;
929
+ return {
930
+ style: `;--bg:#000;--ink:${c.accent}`,
931
+ attrs: '',
932
+ inner:
933
+ `<span class="wx-hud" aria-hidden="true">${hud}</span>` +
934
+ `<span class="wx-pwrap"><span class="wx-panel"><i class="wx-ptag">${pad2(1 + d(40))}-${'ABCD'[d(4)]}</i>${art(around(36), `<defs>${def(c)}</defs>${mk(use(c, 'wx-pm'))}`)}</span><i class="wx-tab is-l"></i><i class="wx-tab is-r"></i></span>` +
935
+ `<span class="wx-glyphs" aria-hidden="true">${glyphs}</span>` +
936
+ `<span class="wx-hname"><b class="wc-name" data-fit="wide" style="--chars:${wideEms(c.name)}">${escapeHtml(c.name)}</b></span>`,
937
+ };
938
+ }
939
+
940
+ /** The pixel frame's blocks: chunky cells on a 16 × 20 grid, thick at the edges, thicker at the corners, none in the
941
+ * middle; a few kept apart to blink. */
942
+ function frameBlocks(r) {
943
+ const cols = 16,
944
+ rows = 20;
945
+ const taken = new Uint8Array(cols * rows);
946
+ let solid = '',
947
+ blink = '';
948
+ for (let j = 0; j < rows; j++)
949
+ for (let q = 0; q < cols; q++) {
950
+ if (taken[j * cols + q]) continue;
951
+ const edge = Math.min(q, j, cols - 1 - q, rows - 1 - j);
952
+ const corner = Math.min(q, cols - 1 - q) < 4 && Math.min(j, rows - 1 - j) < 4;
953
+ const p = [0.42, 0.14, 0.03, 0][Math.min(edge, 3)] + (corner && edge < 2 ? 0.16 : 0);
954
+ if (r() >= p) continue;
955
+ // at the corners, sometimes a bigger block (2 × 2) where it fits
956
+ const big = corner && r() < 0.35 && q + 1 < cols && j + 1 < rows && !taken[j * cols + q + 1];
957
+ const w = big ? 2 : 1,
958
+ h = big ? 2 : 1;
959
+ for (let y = j; y < j + h; y++) for (let x = q; x < q + w; x++) taken[y * cols + x] = 1;
960
+ if (r() < 0.05)
961
+ blink += `<rect class="is-blink" x="${q}" y="${j}" width="${w}" height="${h}" style="--d:-${(r() * 5).toFixed(2)}s" />`;
962
+ else solid += `M${q} ${j}h${w}v${h}h${-w}z`;
963
+ }
964
+ return { solid, blink };
965
+ }
966
+
967
+ /** pixelframe: a flat acid lime (now and then another ink), chunky black pixel blocks round the edges like a glitch
968
+ * frame, the mark rastered in black in the middle, the name in a techno face, a tagline and an address under it. */
969
+ function pixelframe(c) {
970
+ const pick = pickOf(c);
971
+ const bg = c.r() < 0.7 ? c.accent : pick([c.inks[3], c.inks[4], c.inks[6], '#f4f3ef']);
972
+ const { solid, blink } = frameBlocks(c.r);
973
+ const cells = markCells(c.paths, 14);
974
+ const host = c.name.toLowerCase().replace(/[^a-z0-9]/g, '');
975
+ return {
976
+ style: `;--bg:${bg};--fg:#0b0b0b`,
977
+ attrs: '',
978
+ inner:
979
+ `<svg class="wx-def" aria-hidden="true"><defs>${def(c)}</defs></svg>` +
980
+ `<svg class="wx-pfblocks" viewBox="0 0 16 20" preserveAspectRatio="none" aria-hidden="true"><path d="${solid}" />${blink}</svg>` +
981
+ `<svg class="wx-art wx-pfmark" viewBox="0 0 512 512" data-px="frame" aria-hidden="true">${mk(`<path d="${cells.d}" />`)}</svg>` +
982
+ `<span class="wx-pfname"><b class="wc-name">${escapeHtml(c.name)}</b><i>${escapeHtml(c.tagline)}</i><i>www.${host}${escapeHtml(c.tld)}</i></span>`,
983
+ };
984
+ }
985
+
986
+ const LOOKS = {
987
+ draw,
988
+ construct,
989
+ glassdrift,
990
+ pixelassemble,
991
+ breathe,
992
+ neon,
993
+ splitflap,
994
+ contour,
995
+ blueprint,
996
+ letterpress,
997
+ dotmatrix,
998
+ topo,
999
+ thermal,
1000
+ longshadow,
1001
+ acidmap,
1002
+ megacrop,
1003
+ outlinewall,
1004
+ terminal,
1005
+ pixelframe,
1006
+ ...MODERN,
1007
+ ...BLOOM,
1008
+ ...STREET,
1009
+ ...CLUB,
1010
+ ...STUDIO,
1011
+ };
1012
+
1013
+ /** Whether a kind is one of the drawn looks. */
1014
+ export const isLook = (k) => LOOK_KINDS.includes(k);
1015
+
1016
+ /** A drawn look's card: what goes inside it, on its style and as its attributes (`data-anim` on the animated ones). */
1017
+ export function look(c) {
1018
+ const out = LOOKS[c.kind](c);
1019
+ return { ...out, attrs: out.attrs + (ANIMATED.has(c.kind) && !out.attrs.includes('data-anim') ? ' data-anim' : '') };
1020
+ }
1021
+
1022
+ /**
1023
+ * Another mark on a drawn card (the expanded view's "try another"): the mark's `<defs>` copy (and the topo clip and the
1024
+ * traced line), the reeded glass's image, the construction and the blueprint's dimensions, and the pixel and LED cells
1025
+ * are redrawn for it; everything else on the card stays.
1026
+ *
1027
+ * @param el The card.
1028
+ * @param paths The new mark's paths' markup.
1029
+ */
1030
+ export function retarget(el, paths) {
1031
+ for (const g of el.querySelectorAll('[data-m]')) g.innerHTML = g.dataset.m === 'len' ? withLength(paths) : paths;
1032
+ const glass = el.querySelector('.wx-glass, .wx-holo, .wx-spfill');
1033
+ if (glass?.dataset.ink) el.style.setProperty('--m', markUrl(paths, glass.dataset.ink));
1034
+ retargetModern(el, paths);
1035
+ retargetStreet(el, paths);
1036
+ const uid = (el.querySelector('[data-m]')?.id ?? 'wlv-x-m').replace(/-m$/, '');
1037
+ const guides = el.querySelector('[data-guides]');
1038
+ if (guides?.dataset.guides === 'construct') {
1039
+ const g = constructGuides(paths, uid);
1040
+ guides.innerHTML = g.svg;
1041
+ const r = el.querySelector('[data-radii]');
1042
+ if (r) r.textContent = radii(g);
1043
+ } else if (guides?.dataset.guides === 'blueprint') guides.innerHTML = blueprintDims(paths);
1044
+ const seek = el.querySelector('[data-seek]');
1045
+ if (seek) {
1046
+ const [lo, hi] = (seek.dataset.seek ?? '20,36').split(',').map(Number);
1047
+ const mkg = seek.querySelector('.wx-mk');
1048
+ if (mkg) mkg.innerHTML = seekerArt(paths, uid, hash(paths.slice(0, 64)) + 31, lo, hi).svg;
1049
+ }
1050
+ const px = el.querySelector('[data-px]');
1051
+ if (!px) return;
1052
+ const text = (sel, t) => {
1053
+ const e = el.querySelector(sel);
1054
+ if (e) e.textContent = t;
1055
+ };
1056
+ if (px.dataset.px?.startsWith('mosaic')) {
1057
+ const m = mosaicArt(paths, uid, px.dataset.px === 'mosaic-grey', rng(hash(paths.slice(0, 64)) + 17));
1058
+ px.innerHTML = m.svg;
1059
+ text('[data-pxsize]', `Mosaic ${m.cols} × ${m.rows}`);
1060
+ text('[data-pxcount]', `${m.count} px`);
1061
+ } else if (px.dataset.px === 'frame') {
1062
+ px.innerHTML = mk(`<path d="${markCells(paths, 14).d}" />`);
1063
+ } else if (px.dataset.px === 'led') {
1064
+ const led = ledArt(paths, uid, 24, px.getAttribute('viewBox') ?? '0 0 512 512', hash(paths.slice(0, 64)) + 29);
1065
+ px.innerHTML = led.dim;
1066
+ const lit = el.querySelector('.wx-ledon');
1067
+ if (lit) lit.innerHTML = led.lit;
1068
+ text('[data-pxsize]', `LED ${led.cols} × ${led.rows}`);
1069
+ }
1070
+ }