@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.
- package/CHANGELOG.md +46 -0
- package/LICENSE +21 -0
- package/README.md +56 -2
- package/package.json +85 -4
- package/src/index.d.ts +16 -0
- package/src/index.js +16 -0
- package/src/live.d.ts +105 -0
- package/src/live.js +146 -0
- package/src/looks/bloom.d.ts +40 -0
- package/src/looks/bloom.js +134 -0
- package/src/looks/club.d.ts +39 -0
- package/src/looks/club.js +140 -0
- package/src/looks/index.d.ts +186 -0
- package/src/looks/index.js +1070 -0
- package/src/looks/kit.d.ts +72 -0
- package/src/looks/kit.js +54 -0
- package/src/looks/modern.d.ts +90 -0
- package/src/looks/modern.js +457 -0
- package/src/looks/street.d.ts +100 -0
- package/src/looks/street.js +425 -0
- package/src/looks/studio.d.ts +52 -0
- package/src/looks/studio.js +269 -0
- package/src/marks.d.ts +57 -0
- package/src/marks.js +101 -0
- package/src/promo.d.ts +37 -0
- package/src/promo.js +48 -0
- package/src/styles/wall-looks.css +4900 -0
- package/src/styles/wall.css +1957 -0
- package/src/wall.d.ts +135 -0
- package/src/wall.js +441 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @logomarks/lookbook/looks/studio
|
|
3
|
+
*
|
|
4
|
+
* The Lookbook's studio set (2026-11-12; the owner: "a few new ones … that are modern and look good"): frost, spectral,
|
|
5
|
+
* editorial, brandsheet and overprint. Quiet, current brand design: soft colour behind glass, a grainy spectrum in the
|
|
6
|
+
* mark, big type with a small mark, a brand sheet, a two-ink print. Same rules as ./index.js (pure HTML
|
|
7
|
+
* strings from the card's seeded random, per-card values as custom properties in `style`, ids under the card's uid,
|
|
8
|
+
* motion in CSS only and only while `is-live`, the still styles the final frame); each look's styles are a block at the
|
|
9
|
+
* end of wall-looks.css.
|
|
10
|
+
*
|
|
11
|
+
* - The two that move (frost, spectral) move by `transform` alone, on layers drawn once: the compositor does the work,
|
|
12
|
+
* so neither is heavy.
|
|
13
|
+
* - editorial and brandsheet are flat boxes, hairlines, the mark and words, so they also download as plain SVG.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { escapeHtml } from '@arraypress/text';
|
|
17
|
+
import { art, around, def, markUrl, meta, mk, nameB, pad2, pickOf, use } from './kit.js';
|
|
18
|
+
|
|
19
|
+
/** The mark's one copy, in an empty `<svg>`, for the looks whose mark isn't in a drawn artwork. */
|
|
20
|
+
const defs = (c) => `<svg class="wx-def" aria-hidden="true"><defs>${def(c)}</defs></svg>`;
|
|
21
|
+
/** A small copy of the mark (a box that grows with the optical size, like a lockup's). */
|
|
22
|
+
const small = (c, cls) =>
|
|
23
|
+
`<svg class="${cls}" viewBox="0 0 512 512" fill="currentColor" aria-hidden="true"><use href="#${c.uid}-m" /></svg>`;
|
|
24
|
+
/** The made-up brand's web address. */
|
|
25
|
+
const host = (c) => `www.${c.name.toLowerCase().replace(/[^a-z0-9]/g, '')}${c.tld}`;
|
|
26
|
+
|
|
27
|
+
/** Instrument Sans 700's advance widths, in hundredths of an em (measured), for `sansEms`. */
|
|
28
|
+
const SANS = {
|
|
29
|
+
A: 74,
|
|
30
|
+
B: 65,
|
|
31
|
+
C: 75,
|
|
32
|
+
D: 76,
|
|
33
|
+
E: 63,
|
|
34
|
+
F: 59,
|
|
35
|
+
G: 76,
|
|
36
|
+
H: 72,
|
|
37
|
+
I: 25,
|
|
38
|
+
J: 41,
|
|
39
|
+
K: 72,
|
|
40
|
+
L: 59,
|
|
41
|
+
M: 89,
|
|
42
|
+
N: 72,
|
|
43
|
+
O: 80,
|
|
44
|
+
P: 67,
|
|
45
|
+
Q: 82,
|
|
46
|
+
R: 67,
|
|
47
|
+
S: 65,
|
|
48
|
+
T: 67,
|
|
49
|
+
U: 70,
|
|
50
|
+
V: 74,
|
|
51
|
+
W: 109,
|
|
52
|
+
X: 72,
|
|
53
|
+
Y: 71,
|
|
54
|
+
Z: 64,
|
|
55
|
+
a: 57,
|
|
56
|
+
b: 63,
|
|
57
|
+
c: 56,
|
|
58
|
+
d: 63,
|
|
59
|
+
e: 57,
|
|
60
|
+
f: 38,
|
|
61
|
+
g: 63,
|
|
62
|
+
h: 62,
|
|
63
|
+
i: 27,
|
|
64
|
+
j: 27,
|
|
65
|
+
k: 57,
|
|
66
|
+
l: 27,
|
|
67
|
+
m: 95,
|
|
68
|
+
n: 62,
|
|
69
|
+
o: 60,
|
|
70
|
+
p: 63,
|
|
71
|
+
q: 63,
|
|
72
|
+
r: 40,
|
|
73
|
+
s: 50,
|
|
74
|
+
t: 42,
|
|
75
|
+
u: 61,
|
|
76
|
+
v: 54,
|
|
77
|
+
w: 82,
|
|
78
|
+
x: 61,
|
|
79
|
+
y: 54,
|
|
80
|
+
z: 52,
|
|
81
|
+
' ': 19,
|
|
82
|
+
'&': 77,
|
|
83
|
+
'-': 49,
|
|
84
|
+
'.': 29,
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* A name's width in ems, set in Instrument Sans 700 tracked −0.05 em (the editorial's name is sized to its measure
|
|
89
|
+
* from this). The Lookbook's script calls it again for a name typed in the toolbar (`data-fit="sans"`).
|
|
90
|
+
*
|
|
91
|
+
* @param name The name.
|
|
92
|
+
*/
|
|
93
|
+
export function sansEms(name) {
|
|
94
|
+
let w = 0;
|
|
95
|
+
for (const ch of name) w += (SANS[ch] ?? 62) / 100 - 0.05;
|
|
96
|
+
return Math.max(2.2, +w.toFixed(2));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/* ---------- frost: the mark on a pane of frosted glass, soft colour drifting behind it ---------- */
|
|
100
|
+
|
|
101
|
+
/** Frost's grounds: the base, three soft lights behind the glass, and the ink. */
|
|
102
|
+
const frosts = (accent) => [
|
|
103
|
+
['#141021', '#ff5e8a', '#7a5cff', '#ffb347', '#ffffff'],
|
|
104
|
+
['#0b1520', '#3ad6c5', '#3b6cff', '#b7ff5a', '#ffffff'],
|
|
105
|
+
['#190f13', '#ff7a45', '#ff3d81', '#ffd166', '#ffffff'],
|
|
106
|
+
['#0d1324', '#5cc8ff', '#8a6bff', '#ff8fd0', '#ffffff'],
|
|
107
|
+
['#0e150f', accent, '#0f8b8d', '#3ad66f', '#ffffff'],
|
|
108
|
+
['#e8e5f0', '#ff9db8', '#9db4ff', '#ffd58a', '#15131c'],
|
|
109
|
+
];
|
|
110
|
+
|
|
111
|
+
/** frost: three soft lights drift slowly behind a pane of frosted glass (a pale tint, a bright rim, fine grain), the
|
|
112
|
+
* mark on the pane in one ink, the name under it. The lights are plain radial fades moved by `transform`. */
|
|
113
|
+
function frost(c) {
|
|
114
|
+
const pick = pickOf(c);
|
|
115
|
+
const [bg, a, b, d, fg] = pick(frosts(c.accent));
|
|
116
|
+
const orbs = [a, b, d].map((col, k) => `<i class="is-k${k}" style="--c:${col}"></i>`).join('');
|
|
117
|
+
return {
|
|
118
|
+
style: `;--bg:${bg};--fg:${fg}`,
|
|
119
|
+
attrs: '',
|
|
120
|
+
inner:
|
|
121
|
+
`<span class="wx-frorbs" aria-hidden="true">${orbs}</span>` +
|
|
122
|
+
`<span class="wx-frpane">${art(around(64), `<defs>${def(c)}</defs>${mk(use(c, 'wx-frmark'))}`)}</span>` +
|
|
123
|
+
meta('tl', escapeHtml(c.line)) +
|
|
124
|
+
meta('tr', `Glass · ${pad2(1 + Math.floor(c.r() * 24))}`) +
|
|
125
|
+
`<span class="wx-foot is-centre">${nameB(c)}</span>`,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/* ---------- spectral: a grainy spectrum inside the mark ---------- */
|
|
130
|
+
|
|
131
|
+
/** Spectral's gradients, each ending where it starts (it tiles, so it can slide for ever). */
|
|
132
|
+
const spectra = (accent) => [
|
|
133
|
+
'#ff4d6d, #ff9e4a, #ffe66d, #6ee7b7, #5cc8ff, #8a6bff, #ff4d6d',
|
|
134
|
+
'#ff2e88, #ff7a45, #ffd23f, #ff7a45, #ff2e88',
|
|
135
|
+
'#22d3ee, #3b6cff, #8a6bff, #ff8fd0, #22d3ee',
|
|
136
|
+
`${accent}, #3ad6c5, #0f8b8d, #3ad6c5, ${accent}`,
|
|
137
|
+
'#f4f3ef, #9db4ff, #ff9db8, #ffd58a, #f4f3ef',
|
|
138
|
+
];
|
|
139
|
+
|
|
140
|
+
/** spectral: the mark filled with a spectrum that slides slowly through it under film grain, on near-black or paper;
|
|
141
|
+
* nothing else on the card but its name and two small words. The mark is a mask (the glass look's `markUrl`); the
|
|
142
|
+
* spectrum is one wide strip moved by `transform`. */
|
|
143
|
+
function spectral(c) {
|
|
144
|
+
const pick = pickOf(c);
|
|
145
|
+
const light = c.r() < 0.25;
|
|
146
|
+
const all = spectra(c.accent);
|
|
147
|
+
const stops = pick(light ? all.slice(0, 4) : all);
|
|
148
|
+
return {
|
|
149
|
+
style: `;--bg:${light ? '#efede7' : '#0b0b0d'};--fg:${light ? '#131313' : '#f1f1f4'};--m:${markUrl(c.paths, '#fff')};--sp:linear-gradient(90deg, ${stops});--so:${Math.round(c.r() * 100)}`,
|
|
150
|
+
attrs: '',
|
|
151
|
+
inner:
|
|
152
|
+
defs(c) +
|
|
153
|
+
`<span class="wx-spfill" data-ink="#fff" aria-hidden="true"><i class="wx-spgrad"></i><i class="wx-spgrain"></i></span>` +
|
|
154
|
+
meta('tl', escapeHtml(c.line)) +
|
|
155
|
+
meta('tr', `No. ${pad2(1 + Math.floor(c.r() * 40))}`) +
|
|
156
|
+
`<span class="wx-foot">${nameB(c)}</span>`,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/* ---------- editorial: big type, a small mark ---------- */
|
|
161
|
+
|
|
162
|
+
/** Editorial's grounds: ground, ink, and the mark's colour. */
|
|
163
|
+
const editorials = (accent) => [
|
|
164
|
+
['#f1efe9', '#111111', '#ff4d1f'],
|
|
165
|
+
['#f1efe9', '#111111', '#2b4bff'],
|
|
166
|
+
['#0c0c0d', '#f1efe9', accent],
|
|
167
|
+
['#0c0c0d', '#f1efe9', '#f1efe9'],
|
|
168
|
+
['#2b4bff', '#ffffff', '#ffffff'],
|
|
169
|
+
[accent, '#0b0b0b', '#0b0b0b'],
|
|
170
|
+
['#ff4d1f', '#0b0b0b', '#0b0b0b'],
|
|
171
|
+
];
|
|
172
|
+
|
|
173
|
+
/** editorial: a magazine cover: the mark small in the top corner beside an issue number, a hairline, the tagline in a
|
|
174
|
+
* light weight, and the name huge and tight in a bold grotesque the full measure (sized from its width, `sansEms`), a
|
|
175
|
+
* hairline and two small words at the foot. Flat colour, hairlines and words only. */
|
|
176
|
+
function editorial(c) {
|
|
177
|
+
const pick = pickOf(c);
|
|
178
|
+
const [bg, fg, ink] = pick(editorials(c.accent));
|
|
179
|
+
return {
|
|
180
|
+
style: `;--bg:${bg};--fg:${fg};--ink:${ink}`,
|
|
181
|
+
attrs: '',
|
|
182
|
+
inner:
|
|
183
|
+
defs(c) +
|
|
184
|
+
`<span class="wx-edtop">${small(c, 'wx-edmark')}<span class="wx-edmeta"><i>Issue ${pad2(1 + Math.floor(c.r() * 24))}</i><i>2026</i></span></span>` +
|
|
185
|
+
`<span class="wx-edlead"><i>${escapeHtml(c.tagline)}</i></span>` +
|
|
186
|
+
`<span class="wx-edname"><b class="wc-name" data-fit="sans" style="--chars:${sansEms(c.name)}">${escapeHtml(c.name)}</b></span>` +
|
|
187
|
+
`<span class="wx-edfoot"><i>${escapeHtml(c.line)}</i><i>${escapeHtml(host(c))}</i></span>`,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/* ---------- brandsheet: one page of a brand's guidelines ---------- */
|
|
192
|
+
|
|
193
|
+
/** A typeface's name from the card's `type` style (`font-family:'Sora Variable', sans-serif;…` → Sora). */
|
|
194
|
+
const faceName = (type) => (type.match(/font-family:\s*'([^']+)'/)?.[1] ?? 'Grotesk').replace(/ Variable$/, '');
|
|
195
|
+
|
|
196
|
+
/** brandsheet: a page from a brand's guidelines on a hairline grid: the name and a version in the header, the mark big
|
|
197
|
+
* in its own cell, then three cells: its minimum sizes, its colours as chips with the accent's hex, and its typeface
|
|
198
|
+
* ("Aa" in the card's face, named). Flat boxes, hairlines and words only. */
|
|
199
|
+
function brandsheet(c) {
|
|
200
|
+
const pick = pickOf(c);
|
|
201
|
+
const dark = c.r() < 0.35;
|
|
202
|
+
// an accent that reads on the sheet's ground
|
|
203
|
+
const accents = dark
|
|
204
|
+
? [c.accent, '#5CECFF', '#FF5C64', '#FFD43B', '#FF3EA5']
|
|
205
|
+
: ['#2E4BFF', '#FF5C64', '#0E8C7E', '#FF6A00', '#7B3FF2', '#1E6B3A'];
|
|
206
|
+
const ink = pick(accents);
|
|
207
|
+
const [bg, fg] = dark ? ['#0e0e0f', '#f1efe9'] : ['#f4f3ef', '#0b0b0b'];
|
|
208
|
+
const sizes = [3, 2, 1].map((k) => small(c, `wx-bssz is-s${k}`)).join('');
|
|
209
|
+
const chips = `<em class="is-ink"></em><em class="is-fg"></em><em class="is-bg"></em>`;
|
|
210
|
+
return {
|
|
211
|
+
style: `;--bg:${bg};--fg:${fg};--ink:${ink}`,
|
|
212
|
+
attrs: '',
|
|
213
|
+
inner:
|
|
214
|
+
`<span class="wx-bshead">${nameB(c, '', false)}<i>Brand sheet · v1.${Math.floor(c.r() * 9)}</i></span>` +
|
|
215
|
+
`<span class="wx-bsmain">${art(around(70), `<defs>${def(c)}</defs>${mk(use(c, 'wx-bsmark'))}`)}</span>` +
|
|
216
|
+
`<span class="wx-bsrow">` +
|
|
217
|
+
`<span class="wx-bscell"><i>Minimum size</i><span class="wx-bssizes">${sizes}</span></span>` +
|
|
218
|
+
`<span class="wx-bscell"><i>Colour</i><span class="wx-bschips">${chips}</span><i class="wx-bshex">${ink.toUpperCase()}</i></span>` +
|
|
219
|
+
`<span class="wx-bscell"><i>Type</i><span class="wx-bsaa" style="${c.type}">Aa</span><i>${escapeHtml(faceName(c.type))}</i></span>` +
|
|
220
|
+
`</span>` +
|
|
221
|
+
`<span class="wx-bsfoot"><i>${escapeHtml(c.line)}</i><i>${escapeHtml(host(c))}</i></span>`,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/* ---------- overprint: two spot inks, a little off register ---------- */
|
|
226
|
+
|
|
227
|
+
/** Overprint's ink pairs (the first under, the second over it), bright spot colours that make a third where they cross. */
|
|
228
|
+
const SPOTS = [
|
|
229
|
+
['#ff48b0', '#0078bf'],
|
|
230
|
+
['#ff6c2f', '#00838a'],
|
|
231
|
+
['#ffe800', '#ff48b0'],
|
|
232
|
+
['#f15060', '#3255a4'],
|
|
233
|
+
['#ffe800', '#0078bf'],
|
|
234
|
+
];
|
|
235
|
+
|
|
236
|
+
/** overprint: the mark printed twice on uncoated paper in two spot inks: the first solid, the second through a 45°
|
|
237
|
+
* halftone screen and off register, multiplied over the first so a third colour shows in the dots where they cross;
|
|
238
|
+
* paper grain, two registration marks, the inks as swatches. A print-room proof, where the riso look is a photo. */
|
|
239
|
+
function overprint(c) {
|
|
240
|
+
const pick = pickOf(c);
|
|
241
|
+
const [a, b] = pick(SPOTS);
|
|
242
|
+
const paper = pick(['#f3efe4', '#f1ece2', '#eef0ea']);
|
|
243
|
+
// the second pass's slip: 14–22 units, down and to the right or left
|
|
244
|
+
const dx = (c.r() < 0.5 ? -1 : 1) * Math.round(14 + c.r() * 8),
|
|
245
|
+
dy = Math.round(12 + c.r() * 8);
|
|
246
|
+
// the second ink's screen: round dots on a 45° grid, as a mask
|
|
247
|
+
const screen =
|
|
248
|
+
`<pattern id="${c.uid}-hd" width="11" height="11" patternUnits="userSpaceOnUse" patternTransform="rotate(45)"><circle cx="5.5" cy="5.5" r="3.3" fill="#fff" /></pattern>` +
|
|
249
|
+
`<mask id="${c.uid}-hm" maskUnits="userSpaceOnUse" x="-100" y="-100" width="712" height="712"><rect x="-100" y="-100" width="712" height="712" fill="url(#${c.uid}-hd)" /></mask>`;
|
|
250
|
+
const reg = (pos) =>
|
|
251
|
+
`<svg class="wx-opreg is-${pos}" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="6.5" /><path d="M12 0V24M0 12H24" /></svg>`;
|
|
252
|
+
return {
|
|
253
|
+
style: `;--bg:${paper};--fg:#1c1b19;--a:${a};--b:${b};--dx:${dx}px;--dy:${dy}px`,
|
|
254
|
+
attrs: '',
|
|
255
|
+
inner:
|
|
256
|
+
art(
|
|
257
|
+
around(100),
|
|
258
|
+
`<defs>${def(c)}${screen}</defs>${mk(`${use(c, 'wx-opa')}<g class="wx-opb" mask="url(#${c.uid}-hm)">${use(c, '')}</g>`)}`,
|
|
259
|
+
) +
|
|
260
|
+
reg('l') +
|
|
261
|
+
reg('r') +
|
|
262
|
+
meta('tl', `Proof ${pad2(1 + Math.floor(c.r() * 12))} · 2 inks`) +
|
|
263
|
+
`<span class="wx-opinks" aria-hidden="true"><i class="is-a"></i><i class="is-b"></i></span>` +
|
|
264
|
+
`<span class="wx-foot">${nameB(c)}<i>${escapeHtml(c.line)}</i></span>`,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/** The set's looks, by kind. */
|
|
269
|
+
export const STUDIO = { frost, spectral, editorial, brandsheet, overprint };
|
package/src/marks.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @logomarks/lookbook/marks
|
|
3
|
+
*
|
|
4
|
+
* What the Lookbook's looks need to know about a mark's shape: its real box, its optical size (how much bigger a wide,
|
|
5
|
+
* slim or light mark is drawn), and the mark as square cells (the pixel and LED looks). Browser-safe, so the wall's
|
|
6
|
+
* script can make the same cards as the page.
|
|
7
|
+
*
|
|
8
|
+
* The measures are `@logomarks/core`'s (since 0.2.1), re-exported here: `markBox`, `inkShare`, `opticalScale` and
|
|
9
|
+
* `OPTICAL` from `/analyse`, `cellsAcross` and `markCells` from `/edit`. What stays here is the Lookbook's own:
|
|
10
|
+
* `opticalVars` and `opticalStyle` (the cards' CSS) and `heatField` (the thermal look's filter).
|
|
11
|
+
*/
|
|
12
|
+
import { type PixelGrid } from '@logomarks/core/edit';
|
|
13
|
+
import { type Bounds } from '@logomarks/core/svg';
|
|
14
|
+
export { markBox, inkShare, opticalScale, OPTICAL } from '@logomarks/core/analyse';
|
|
15
|
+
export { cellsAcross, markCells, type MarkCells } from '@logomarks/core/edit';
|
|
16
|
+
/** A box on the 512 canvas (core's `Bounds`). */
|
|
17
|
+
export type Box = Bounds;
|
|
18
|
+
/**
|
|
19
|
+
* A card's optical size as CSS custom properties for its `style`: `--mk-k` (the scale), `--mk-w` and `--mk-h` (the box,
|
|
20
|
+
* on the 512 canvas), from which wall.css works out `--mk-scale` within each look's room.
|
|
21
|
+
*
|
|
22
|
+
* @param paths The mark's paths' markup.
|
|
23
|
+
* @returns The three properties, as strings.
|
|
24
|
+
*/
|
|
25
|
+
export declare function opticalVars(paths: string): Record<'--mk-k' | '--mk-w' | '--mk-h', string>;
|
|
26
|
+
/**
|
|
27
|
+
* `opticalVars` as a `style` fragment (`;--mk-k:…`).
|
|
28
|
+
*
|
|
29
|
+
* @param paths The mark's paths' markup.
|
|
30
|
+
* @returns The fragment, to append to a card's `style`.
|
|
31
|
+
*/
|
|
32
|
+
export declare const opticalStyle: (paths: string) => string;
|
|
33
|
+
/** A mark's heat: what the thermal look's infrared filter shows (./looks/index.js), worked out on a grid so the seeker
|
|
34
|
+
* knows where the mark is hottest. */
|
|
35
|
+
export type HeatField = {
|
|
36
|
+
/** The grid (8 units a cell, round the 512 canvas with a 40-unit margin). */
|
|
37
|
+
grid: PixelGrid;
|
|
38
|
+
/** Heat per cell, row by row: 0 to about 1.1 (the filter shows it clipped at 1; the seeker reads it whole, so it
|
|
39
|
+
* finds the middle of a solid mark's white). */
|
|
40
|
+
heat: Float32Array;
|
|
41
|
+
/** Ink coverage 0–1 per cell, row by row. */
|
|
42
|
+
ink: Float32Array;
|
|
43
|
+
/** The hottest cell's centre, on the 512 canvas, and its heat. */
|
|
44
|
+
peak: {
|
|
45
|
+
x: number;
|
|
46
|
+
y: number;
|
|
47
|
+
v: number;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* The mark's heat as the thermal look draws it: its coverage blurred at two radii (8 and 30 units) and mixed 0.6 : 0.5,
|
|
52
|
+
* like the look's SVG filter, on an 8-unit grid; and the hottest point.
|
|
53
|
+
*
|
|
54
|
+
* @param paths The mark's paths' markup.
|
|
55
|
+
* @returns The grid, the heat and ink per cell, and the hottest cell.
|
|
56
|
+
*/
|
|
57
|
+
export declare function heatField(paths: string): HeatField;
|
package/src/marks.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @logomarks/lookbook/marks
|
|
3
|
+
*
|
|
4
|
+
* What the Lookbook's looks need to know about a mark's shape: its real box, its optical size (how much bigger a wide,
|
|
5
|
+
* slim or light mark is drawn), and the mark as square cells (the pixel and LED looks). Browser-safe, so the wall's
|
|
6
|
+
* script can make the same cards as the page.
|
|
7
|
+
*
|
|
8
|
+
* The measures are `@logomarks/core`'s (since 0.2.1), re-exported here: `markBox`, `inkShare`, `opticalScale` and
|
|
9
|
+
* `OPTICAL` from `/analyse`, `cellsAcross` and `markCells` from `/edit`. What stays here is the Lookbook's own:
|
|
10
|
+
* `opticalVars` and `opticalStyle` (the cards' CSS) and `heatField` (the thermal look's filter).
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { shapes, rings } from '@logomarks/core/svg';
|
|
14
|
+
import { pixelCoverage } from '@logomarks/core/edit';
|
|
15
|
+
import { markBox, inkShare, opticalScale } from '@logomarks/core/analyse';
|
|
16
|
+
|
|
17
|
+
export { markBox, inkShare, opticalScale, OPTICAL } from '@logomarks/core/analyse';
|
|
18
|
+
export { cellsAcross, markCells } from '@logomarks/core/edit';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A card's optical size as CSS custom properties for its `style`: `--mk-k` (the scale), `--mk-w` and `--mk-h` (the box,
|
|
22
|
+
* on the 512 canvas), from which wall.css works out `--mk-scale` within each look's room.
|
|
23
|
+
*
|
|
24
|
+
* @param paths The mark's paths' markup.
|
|
25
|
+
* @returns The three properties, as strings.
|
|
26
|
+
*/
|
|
27
|
+
export function opticalVars(paths) {
|
|
28
|
+
const box = markBox(paths);
|
|
29
|
+
return {
|
|
30
|
+
'--mk-k': opticalScale(box, inkShare(paths)).toFixed(3),
|
|
31
|
+
'--mk-w': String(Math.round(box.w)),
|
|
32
|
+
'--mk-h': String(Math.round(box.h)),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* `opticalVars` as a `style` fragment (`;--mk-k:…`).
|
|
38
|
+
*
|
|
39
|
+
* @param paths The mark's paths' markup.
|
|
40
|
+
* @returns The fragment, to append to a card's `style`.
|
|
41
|
+
*/
|
|
42
|
+
export const opticalStyle = (paths) =>
|
|
43
|
+
Object.entries(opticalVars(paths))
|
|
44
|
+
.map(([k, v]) => `;${k}:${v}`)
|
|
45
|
+
.join('');
|
|
46
|
+
|
|
47
|
+
/** A separable Gaussian blur of a grid, `sigma` in cells. */
|
|
48
|
+
function blur(src, cols, rows, sigma) {
|
|
49
|
+
const rad = Math.ceil(sigma * 3);
|
|
50
|
+
const k = Array.from({ length: 2 * rad + 1 }, (_, i) => Math.exp(-((i - rad) ** 2) / (2 * sigma * sigma)));
|
|
51
|
+
const sum = k.reduce((s, v) => s + v, 0);
|
|
52
|
+
const tmp = new Float32Array(src.length),
|
|
53
|
+
out = new Float32Array(src.length);
|
|
54
|
+
for (let j = 0; j < rows; j++)
|
|
55
|
+
for (let i = 0; i < cols; i++) {
|
|
56
|
+
let v = 0;
|
|
57
|
+
for (let t = -rad; t <= rad; t++) {
|
|
58
|
+
const x = i + t;
|
|
59
|
+
if (x >= 0 && x < cols) v += src[j * cols + x] * k[t + rad];
|
|
60
|
+
}
|
|
61
|
+
tmp[j * cols + i] = v / sum;
|
|
62
|
+
}
|
|
63
|
+
for (let j = 0; j < rows; j++)
|
|
64
|
+
for (let i = 0; i < cols; i++) {
|
|
65
|
+
let v = 0;
|
|
66
|
+
for (let t = -rad; t <= rad; t++) {
|
|
67
|
+
const y = j + t;
|
|
68
|
+
if (y >= 0 && y < rows) v += tmp[y * cols + i] * k[t + rad];
|
|
69
|
+
}
|
|
70
|
+
out[j * cols + i] = v / sum;
|
|
71
|
+
}
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The mark's heat as the thermal look draws it: its coverage blurred at two radii (8 and 30 units) and mixed 0.6 : 0.5,
|
|
77
|
+
* like the look's SVG filter, on an 8-unit grid; and the hottest point.
|
|
78
|
+
*
|
|
79
|
+
* @param paths The mark's paths' markup.
|
|
80
|
+
* @returns The grid, the heat and ink per cell, and the hottest cell.
|
|
81
|
+
*/
|
|
82
|
+
export function heatField(paths) {
|
|
83
|
+
const list = shapes(paths);
|
|
84
|
+
const grid = { cols: 74, rows: 74, cell: 8, x0: -40, y0: -40 };
|
|
85
|
+
const ink = list.length
|
|
86
|
+
? pixelCoverage(
|
|
87
|
+
list.map((s) => ({ rings: rings(s.segs), evenodd: s.evenodd })),
|
|
88
|
+
grid,
|
|
89
|
+
)
|
|
90
|
+
: new Float32Array(grid.cols * grid.rows);
|
|
91
|
+
const a = blur(ink, grid.cols, grid.rows, 1),
|
|
92
|
+
b = blur(ink, grid.cols, grid.rows, 3.75);
|
|
93
|
+
const heat = new Float32Array(ink.length);
|
|
94
|
+
let best = 0;
|
|
95
|
+
for (let i = 0; i < heat.length; i++) {
|
|
96
|
+
heat[i] = 0.6 * a[i] + 0.5 * b[i];
|
|
97
|
+
if (heat[i] > heat[best]) best = i;
|
|
98
|
+
}
|
|
99
|
+
const at = (i) => ({ x: grid.x0 + ((i % grid.cols) + 0.5) * grid.cell, y: grid.y0 + (Math.floor(i / grid.cols) + 0.5) * grid.cell });
|
|
100
|
+
return { grid, heat, ink, peak: { ...at(best), v: heat[best] || 1 } };
|
|
101
|
+
}
|
package/src/promo.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @logomarks/lookbook/promo
|
|
3
|
+
*
|
|
4
|
+
* The cards between the marks (`feed`'s `promo`): a headline card that glitches now and then, a sponsor's card, and an
|
|
5
|
+
* open sponsor slot, each with smoke behind its words (`data-smoke`, started by `liveCards`). The words and links are
|
|
6
|
+
* the site's; the markup and its styles (wall.css) are these.
|
|
7
|
+
*/
|
|
8
|
+
import type { Card } from './wall.js';
|
|
9
|
+
/**
|
|
10
|
+
* A headline card (4:5): a small tag, a headline whose two tinted copies slice and shift for a moment now and then
|
|
11
|
+
* (while live), and a line to act on.
|
|
12
|
+
*
|
|
13
|
+
* @param k Its place among the promo cards (1, 2 …): its glitch's moment.
|
|
14
|
+
* @param o `href`; `tag` (text); `head`, the headline (HTML, the site's own: an `<em>` for its second half); `cta` (text).
|
|
15
|
+
*/
|
|
16
|
+
export declare function headlineCard(
|
|
17
|
+
k: number,
|
|
18
|
+
o: {
|
|
19
|
+
href: string;
|
|
20
|
+
tag: string;
|
|
21
|
+
head: string;
|
|
22
|
+
cta: string;
|
|
23
|
+
},
|
|
24
|
+
): Card;
|
|
25
|
+
/**
|
|
26
|
+
* A sponsor's card (1:1): its logo, name and tagline over smoke; it opens the sponsor's site in a new tab.
|
|
27
|
+
*
|
|
28
|
+
* @param o `href`, the sponsor's address; `tag` (text); `logo`, an image address; `name` and `tagline` (text).
|
|
29
|
+
*/
|
|
30
|
+
export declare function sponsorCard(o: { href: string; tag: string; logo: string; name: string; tagline: string }): Card;
|
|
31
|
+
/**
|
|
32
|
+
* An open sponsor slot (1:1): an empty logo with light scanning across it, a title, a line, and a line to book it that
|
|
33
|
+
* rises on hover.
|
|
34
|
+
*
|
|
35
|
+
* @param o `href`, where it's booked; `tag`, `title`, `line` and `go` (text).
|
|
36
|
+
*/
|
|
37
|
+
export declare function openSlotCard(o: { href: string; tag: string; title: string; line: string; go: string }): Card;
|
package/src/promo.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @logomarks/lookbook/promo
|
|
3
|
+
*
|
|
4
|
+
* The cards between the marks (`feed`'s `promo`): a headline card that glitches now and then, a sponsor's card, and an
|
|
5
|
+
* open sponsor slot, each with smoke behind its words (`data-smoke`, started by `liveCards`). The words and links are
|
|
6
|
+
* the site's; the markup and its styles (wall.css) are these.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { escapeHtml } from '@arraypress/text';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A headline card (4:5): a small tag, a headline whose two tinted copies slice and shift for a moment now and then
|
|
13
|
+
* (while live), and a line to act on.
|
|
14
|
+
*
|
|
15
|
+
* @param k Its place among the promo cards (1, 2 …): its glitch's moment.
|
|
16
|
+
* @param o `href`; `tag` (text); `head`, the headline (HTML, the site's own: an `<em>` for its second half); `cta` (text).
|
|
17
|
+
*/
|
|
18
|
+
export function headlineCard(k, o) {
|
|
19
|
+
return {
|
|
20
|
+
html: `<a class="wc wc-promo wc-custom" href="${escapeHtml(o.href)}" data-anim style="aspect-ratio:4 / 5;--glitch-delay:${-((k * 1.7) % 5).toFixed(2)}s"><span class="wc-promo-tag">${escapeHtml(o.tag)}</span><span class="wc-glitch"><b>${o.head}</b><b class="wc-glitch-a" aria-hidden="true">${o.head}</b><b class="wc-glitch-b" aria-hidden="true">${o.head}</b></span><span class="wc-promo-cta">${escapeHtml(o.cta)}</span></a>`,
|
|
21
|
+
h: 5 / 4,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A sponsor's card (1:1): its logo, name and tagline over smoke; it opens the sponsor's site in a new tab.
|
|
27
|
+
*
|
|
28
|
+
* @param o `href`, the sponsor's address; `tag` (text); `logo`, an image address; `name` and `tagline` (text).
|
|
29
|
+
*/
|
|
30
|
+
export function sponsorCard(o) {
|
|
31
|
+
return {
|
|
32
|
+
html: `<a class="wc wc-promo wc-sponsor" href="${escapeHtml(o.href)}" rel="sponsored noopener" target="_blank" data-smoke style="aspect-ratio:1 / 1"><canvas class="wc-smoke" aria-hidden="true"></canvas><span class="wc-promo-tag">${escapeHtml(o.tag)}</span><img class="wc-sponsor-logo" src="${escapeHtml(o.logo)}" alt="" loading="lazy" /><b>${escapeHtml(o.name)}</b><span>${escapeHtml(o.tagline)}</span></a>`,
|
|
33
|
+
h: 1,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* An open sponsor slot (1:1): an empty logo with light scanning across it, a title, a line, and a line to book it that
|
|
39
|
+
* rises on hover.
|
|
40
|
+
*
|
|
41
|
+
* @param o `href`, where it's booked; `tag`, `title`, `line` and `go` (text).
|
|
42
|
+
*/
|
|
43
|
+
export function openSlotCard(o) {
|
|
44
|
+
return {
|
|
45
|
+
html: `<a class="wc wc-promo wc-sponsor is-open" href="${escapeHtml(o.href)}" data-smoke style="aspect-ratio:1 / 1"><canvas class="wc-smoke" aria-hidden="true"></canvas><span class="wc-promo-tag">${escapeHtml(o.tag)}</span><span class="wc-sponsor-logo" aria-hidden="true"></span><b>${escapeHtml(o.title)}</b><span>${escapeHtml(o.line)}</span><span class="wc-sponsor-go">${escapeHtml(o.go)}</span></a>`,
|
|
46
|
+
h: 1,
|
|
47
|
+
};
|
|
48
|
+
}
|