@logomarks/lookbook 0.5.0 → 0.6.1
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 +152 -0
- package/README.md +3 -3
- package/package.json +2 -2
- package/src/fields.d.ts +14 -2
- package/src/fields.js +325 -6
- package/src/fit.js +118 -0
- package/src/glass.d.ts +1 -1
- package/src/glass.js +229 -63
- package/src/live.d.ts +25 -3
- package/src/live.js +61 -12
- package/src/looks/blur.d.ts +16 -0
- package/src/looks/blur.js +71 -0
- package/src/looks/exposure.js +139 -0
- package/src/looks/index.d.ts +15 -2
- package/src/looks/index.js +105 -20
- package/src/looks/kit.d.ts +8 -0
- package/src/looks/kit.js +16 -0
- package/src/looks/stark.d.ts +19 -0
- package/src/looks/stark.js +106 -0
- package/src/looks/tone.d.ts +20 -0
- package/src/looks/tone.js +132 -0
- package/src/styles/wall-looks.css +1046 -0
- package/src/styles/wall.css +13 -0
- package/src/wall.js +8 -5
package/src/fit.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @logomarks/lookbook/fit
|
|
3
|
+
*
|
|
4
|
+
* Every card's name fits its card, in the browser. A look sets its name's size for a name of usual length; a long name
|
|
5
|
+
* in a wide face (ROSEMARY in Unbounded, KALEIDOSCOPE in Michroma) ran off the card's edge. `fitName` measures the name
|
|
6
|
+
* against its card and, where it would cross the card's edge (less a small margin), sets it smaller until it clears:
|
|
7
|
+
* never clipped, never wrapped, never larger than its look made it. The size it had is kept (`data-fs`), so a name fitted
|
|
8
|
+
* on a small card and shown again in a large one (the expanded view's copy) starts from its look's size each time.
|
|
9
|
+
*
|
|
10
|
+
* `fitNames` fits every name under an element, `fitWatch` keeps them fitted as cards come, change size, or the web fonts
|
|
11
|
+
* load (`liveCards` runs it on the wall it watches). A width-sized name (the terminal's, the editorial's: `data-fit`,
|
|
12
|
+
* sized in CSS from `--chars`) is fitted too, in case its face measures wider than the estimate.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** The names a card can show. */
|
|
16
|
+
const NAMES = '.wc-name';
|
|
17
|
+
|
|
18
|
+
/** The card a name is on. */
|
|
19
|
+
const cardOf = (el) => el.closest('.wc, .lv-card');
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The room a name may take: its card's box less a margin each side (5% of the card's width, at least 6 px), so a fitted
|
|
23
|
+
* name never touches the edge.
|
|
24
|
+
*
|
|
25
|
+
* @param card The card.
|
|
26
|
+
*/
|
|
27
|
+
function room(card) {
|
|
28
|
+
const r = card.getBoundingClientRect();
|
|
29
|
+
const m = Math.max(6, r.width * 0.05);
|
|
30
|
+
return { left: r.left + m, right: r.right - m };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Fits one name to its card: back to its look's size first, then, if it would cross the card's edge, smaller by what
|
|
35
|
+
* it crosses (a centred lockup clears by the same measure as a left-aligned one), up to four passes for a face whose
|
|
36
|
+
* width doesn't scale exactly with its size.
|
|
37
|
+
*
|
|
38
|
+
* @param el The name (`.wc-name`).
|
|
39
|
+
* @returns The scale it was set at (1: as its look made it).
|
|
40
|
+
*/
|
|
41
|
+
export function fitName(el) {
|
|
42
|
+
const card = cardOf(el);
|
|
43
|
+
if (!card) return 1;
|
|
44
|
+
// back to its look's size: what it had in its style before any fitting
|
|
45
|
+
if (el.dataset.fs === undefined) el.dataset.fs = el.style.fontSize || '';
|
|
46
|
+
el.style.fontSize = el.dataset.fs;
|
|
47
|
+
const r0 = el.getBoundingClientRect();
|
|
48
|
+
if (!r0.width || !r0.height) return 1; // hidden (a Plain card's name while the look shows, or the reverse)
|
|
49
|
+
const base = parseFloat(getComputedStyle(el).fontSize);
|
|
50
|
+
if (!base) return 1;
|
|
51
|
+
let k = 1;
|
|
52
|
+
for (let pass = 0; pass < 4; pass++) {
|
|
53
|
+
const { left, right } = room(card);
|
|
54
|
+
const r = el.getBoundingClientRect();
|
|
55
|
+
const over = Math.max(0, left - r.left) + Math.max(0, r.right - right);
|
|
56
|
+
if (over < 0.5) break;
|
|
57
|
+
k *= Math.max(0.2, (r.width - over) / r.width);
|
|
58
|
+
el.style.fontSize = `${(base * k).toFixed(2)}px`;
|
|
59
|
+
}
|
|
60
|
+
return k;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Fits every name under `scope`.
|
|
65
|
+
*
|
|
66
|
+
* @param scope Where to look (the document, a wall, a card).
|
|
67
|
+
*/
|
|
68
|
+
export function fitNames(scope = document) {
|
|
69
|
+
const own = scope instanceof Element && scope.matches(NAMES) ? [scope] : [];
|
|
70
|
+
for (const el of [...own, ...scope.querySelectorAll(NAMES)]) fitName(el);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Keeps the names under `scope` fitted: now, when the web fonts finish loading, when a card changes size, and when
|
|
75
|
+
* cards are added under the `observe` elements.
|
|
76
|
+
*
|
|
77
|
+
* @param scope Where the cards are.
|
|
78
|
+
* @param options `observe`: elements whose new cards are fitted as they come (the wall, the expanded view).
|
|
79
|
+
* @returns Stops watching.
|
|
80
|
+
*/
|
|
81
|
+
export function fitWatch(scope = document, options = {}) {
|
|
82
|
+
const sizes = new WeakMap();
|
|
83
|
+
const ro =
|
|
84
|
+
typeof ResizeObserver === 'function'
|
|
85
|
+
? new ResizeObserver((entries) => {
|
|
86
|
+
for (const e of entries) {
|
|
87
|
+
const w = Math.round(e.contentRect.width);
|
|
88
|
+
if (sizes.get(e.target) === w) continue;
|
|
89
|
+
sizes.set(e.target, w);
|
|
90
|
+
fitNames(e.target);
|
|
91
|
+
}
|
|
92
|
+
})
|
|
93
|
+
: null;
|
|
94
|
+
const seen = new WeakSet();
|
|
95
|
+
const add = (root) => {
|
|
96
|
+
for (const card of root.querySelectorAll('.wc, .lv-card')) {
|
|
97
|
+
if (seen.has(card)) continue;
|
|
98
|
+
seen.add(card);
|
|
99
|
+
ro?.observe(card);
|
|
100
|
+
fitNames(card);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
add(scope);
|
|
104
|
+
const fonts = typeof document !== 'undefined' ? document.fonts : undefined;
|
|
105
|
+
const again = () => fitNames(scope);
|
|
106
|
+
fonts?.ready.then(again).catch(() => {});
|
|
107
|
+
fonts?.addEventListener?.('loadingdone', again);
|
|
108
|
+
const mos = (options.observe ?? []).map((el) => {
|
|
109
|
+
const mo = new MutationObserver(() => add(el));
|
|
110
|
+
mo.observe(el, { childList: true, subtree: true });
|
|
111
|
+
return mo;
|
|
112
|
+
});
|
|
113
|
+
return () => {
|
|
114
|
+
ro?.disconnect();
|
|
115
|
+
for (const mo of mos) mo.disconnect();
|
|
116
|
+
fonts?.removeEventListener?.('loadingdone', again);
|
|
117
|
+
};
|
|
118
|
+
}
|
package/src/glass.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
/** The glass cards' kinds. */
|
|
9
|
-
export type GlassKind = 'glassdrop' | 'glassstack';
|
|
9
|
+
export type GlassKind = 'glassdrop' | 'glassstack' | 'paintdrip';
|
|
10
10
|
|
|
11
11
|
/** What a glass card is dealt from: the card's seeded pick and random, the accent, the mark's paths and the card's id. */
|
|
12
12
|
export type GlassDeal = {
|
package/src/glass.js
CHANGED
|
@@ -8,8 +8,11 @@
|
|
|
8
8
|
* lit card, growing from the bottom up, then leaning gently. Both are our own effects after reactdrops.dev's Liquid
|
|
9
9
|
* Glass Logo and Glass Slab Logo (the idea, not their code: their licence forbids reuse in a component library).
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* Both refract a photo from the glass set (`GLASS_PHOTOS`) behind them (2026-11-28, the owner: "proper refraction …
|
|
12
|
+
* look like actual glass"): liquid glass is the mark's own shape in clear, lightly tinted glass that holds, its top
|
|
13
|
+
* swelling slowly, the light drifting; glass slabs are tinted discs, each a thick lens. Each card's still is the photo
|
|
14
|
+
* (a CSS background) and markup under the canvas, laid exactly where the effect draws the mark: the photo through the
|
|
15
|
+
* mark, magnified and tinted, with its rim and lip (liquid glass), or through tinted bands (glass slabs). The
|
|
13
16
|
* runner reads the mark from the still (`data-m`) and hands it to the effect, so the paths are in the page once.
|
|
14
17
|
*
|
|
15
18
|
* Pure: everything comes from the card's seeded random, so the page and its script deal identical cards.
|
|
@@ -18,6 +21,9 @@
|
|
|
18
21
|
import { escapeHtml } from '@arraypress/text';
|
|
19
22
|
import { dropLayout } from '@arraypress/effects-astro/runtime/glass-drop-plan';
|
|
20
23
|
import { sliceTints, stackLayout } from '@arraypress/effects-astro/runtime/glass-stack';
|
|
24
|
+
import { dripAnchors, dripPlan, dripsAtRest } from '@arraypress/effects-astro/runtime/paint-drip';
|
|
25
|
+
import { shapes, rings } from '@logomarks/core/svg';
|
|
26
|
+
import { pixelCoverage } from '@logomarks/core/edit';
|
|
21
27
|
import { markBox, inkShare, opticalScale } from './marks.js';
|
|
22
28
|
|
|
23
29
|
/** A glass card's shape, width over height (4:5, like the field cards). */
|
|
@@ -56,85 +62,244 @@ function still(centre, edge, body, extra = '') {
|
|
|
56
62
|
|
|
57
63
|
/* ---------- Liquid glass (effects-astro's glassDrop) ---------- */
|
|
58
64
|
|
|
59
|
-
/**
|
|
60
|
-
*
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
/** What the glass cards refract: the glass set's colourful abstracts (fluid colour, foil, holo, ribbons, waves, sunsets,
|
|
66
|
+
* spheres), where bending and magnifying shows; never a flat ground (the owner, 2026-11-28: "proper refraction … look
|
|
67
|
+
* like actual glass"). */
|
|
68
|
+
export const GLASS_PHOTOS = /\/(fluid|liquid|ribbon|bluewaves|sunset|dusk|spheres|swirl)-\d+\.webp$/;
|
|
69
|
+
|
|
70
|
+
/** How bright the photo shows round the glass (the glass reads over it, the name under it). */
|
|
71
|
+
const DIM = 0.8;
|
|
72
|
+
|
|
73
|
+
/** A card's still background: the photo, dimmed as the effect dims it, covering the card. */
|
|
74
|
+
const photoStill = (src, dim) => `linear-gradient(rgba(0,0,0,${f2(1 - dim)}),rgba(0,0,0,${f2(1 - dim)})),center / cover no-repeat url('${src}')`;
|
|
75
|
+
|
|
76
|
+
/** How soft the photo is round the glass (the effect's `soften`, a mip bias): the glass, a lens, shows it sharp. */
|
|
77
|
+
const SOFT = 2.2;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The card's photo, soft and dimmed, laid over the card in a still's box units (the card's own CSS background stays
|
|
81
|
+
* under it, for the moment before the still's SVG paints).
|
|
82
|
+
*
|
|
83
|
+
* @param href The photo.
|
|
84
|
+
* @param card The card's rect in the box's units.
|
|
85
|
+
* @param dim How bright it shows.
|
|
86
|
+
* @param id The blur filter's id.
|
|
87
|
+
*/
|
|
88
|
+
function softPhoto(href, card, dim, id) {
|
|
89
|
+
const img = `<image href="${href}" x="${f2(card.x)}" y="${f2(card.y)}" width="${f2(card.w)}" height="${f2(card.h)}" preserveAspectRatio="xMidYMid slice" />`;
|
|
90
|
+
const sd = Math.round(card.h / 160);
|
|
91
|
+
return `<filter id="${id}" x="-5%" y="-5%" width="110%" height="110%"><feGaussianBlur stdDeviation="${sd}"/></filter><g filter="url(#${id})">${img}</g><rect x="${f2(card.x)}" y="${f2(card.y)}" width="${f2(card.w)}" height="${f2(card.h)}" fill="#000" opacity="${f2(1 - dim)}"/>`;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The glass mark as a still, over the card's photo: inside the mark the photo again, magnified about the mark's middle
|
|
96
|
+
* (the lens the glass is), tinted, with a dark band inside the rim, a lit lip on the light's side, a highlight swept
|
|
97
|
+
* across the top, and the glass's shadow cast away from the light. All in the 512 box the effect draws the mark in.
|
|
98
|
+
*
|
|
99
|
+
* @param o `uid`, the mark's `paths`, the photo `src`, the box (`centre`, `edge`, shares of the card's height), the
|
|
100
|
+
* `tint`, the light's angle `light` (degrees, 0 right, 90 top), and how much it magnifies (`k`).
|
|
101
|
+
*/
|
|
102
|
+
function glassStill({ uid, paths, src, centre, edge, tint, light, k, dim }) {
|
|
103
|
+
// the card in the box's units: the box's top left in card units, scaled to 512 an edge
|
|
104
|
+
const x0 = centre.x * CARD - edge / 2;
|
|
105
|
+
const y0 = centre.y - edge / 2;
|
|
106
|
+
const u = 512 / edge;
|
|
107
|
+
const card = { x: -x0 * u, y: -y0 * u, w: CARD * u, h: u };
|
|
108
|
+
const photo = `<image href="${src}" x="${f2(card.x)}" y="${f2(card.y)}" width="${f2(card.w)}" height="${f2(card.h)}" preserveAspectRatio="xMidYMid slice" />`;
|
|
109
|
+
const a = (light * Math.PI) / 180;
|
|
110
|
+
const lx = Math.cos(a);
|
|
111
|
+
const ly = -Math.sin(a); // screen y is down
|
|
112
|
+
const d = 12; // the shadow's reach, box units
|
|
113
|
+
const id = (x) => `${uid}-${x}`;
|
|
114
|
+
return [
|
|
115
|
+
// behind: the photo soft and dimmed, as the effect shows it round the glass
|
|
116
|
+
softPhoto(src, card, dim, id('gb')),
|
|
117
|
+
'<defs>',
|
|
118
|
+
// the mark's shape, as a mask that keeps its even-odd holes
|
|
119
|
+
`<mask id="${id('gk')}" maskUnits="userSpaceOnUse" x="-64" y="-64" width="640" height="640"><g data-m fill="#fff">${paths}</g></mask>`,
|
|
120
|
+
// the rim: a dark band just inside the edge, a white hairline at the very edge, and the bevel's highlight
|
|
121
|
+
`<filter id="${id('gr')}" x="-10%" y="-10%" width="120%" height="120%"><feGaussianBlur in="SourceAlpha" stdDeviation="8" result="b"/>`,
|
|
122
|
+
`<feComposite in="SourceAlpha" in2="b" operator="arithmetic" k2="1" k3="-1" result="rim"/>`,
|
|
123
|
+
`<feColorMatrix in="rim" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.1 0" result="band"/>`,
|
|
124
|
+
`<feMorphology in="SourceAlpha" operator="erode" radius="2.2" result="in"/>`,
|
|
125
|
+
`<feComposite in="SourceAlpha" in2="in" operator="out" result="edge"/>`,
|
|
126
|
+
`<feColorMatrix in="edge" type="matrix" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.75 0" result="hair"/>`,
|
|
127
|
+
`<feSpecularLighting in="b" surfaceScale="11" specularConstant="1.3" specularExponent="26" lighting-color="#fff" result="spec"><feDistantLight azimuth="${Math.round(-light)}" elevation="36"/></feSpecularLighting>`,
|
|
128
|
+
`<feComposite in="spec" in2="SourceAlpha" operator="in" result="lit"/>`,
|
|
129
|
+
`<feMerge><feMergeNode in="band"/><feMergeNode in="hair"/><feMergeNode in="lit"/></feMerge></filter>`,
|
|
130
|
+
`<filter id="${id('gs')}" x="-20%" y="-20%" width="140%" height="140%"><feGaussianBlur stdDeviation="10"/></filter>`,
|
|
131
|
+
'</defs>',
|
|
132
|
+
// the shadow, cast away from the light
|
|
133
|
+
`<g filter="url(#${id('gs')})" opacity="0.4" transform="translate(${f2(-lx * d)} ${f2(-ly * d)})"><g fill="#000">${paths}</g></g>`,
|
|
134
|
+
// the photo through the glass: sharp, magnified about the box's middle, tinted, a touch brighter than the ground
|
|
135
|
+
`<g mask="url(#${id('gk')})"><g transform="translate(256 256) scale(${f2(k)}) translate(-256 -256)">${photo}</g>`,
|
|
136
|
+
`<rect x="-64" y="-64" width="640" height="640" fill="${tint}" opacity="0.22" style="mix-blend-mode:multiply"/>`,
|
|
137
|
+
`<rect x="-64" y="-64" width="640" height="640" fill="#fff" opacity="0.06"/></g>`,
|
|
138
|
+
// the rim
|
|
139
|
+
`<g filter="url(#${id('gr')})"><g fill="#fff">${paths}</g></g>`,
|
|
140
|
+
].join('');
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Liquid glass cards' tints (the glass takes the colour as light through tinted glass does) and the name's ink. */
|
|
144
|
+
const dropTintsOf = (accent) => ['#FFFFFF', '#FFFFFF', '#DFF4FF', accent, '#FFD9C7', '#E9E2FF'];
|
|
69
145
|
|
|
70
|
-
/** glassdrop: a drop of liquid glass
|
|
71
|
-
|
|
72
|
-
|
|
146
|
+
/** glassdrop: a drop of liquid glass lands and spreads into the mark's own shape in clear glass over a photo, which it
|
|
147
|
+
* bends and magnifies; the glass holds, its top swelling slowly like liquid, the light drifting over it. */
|
|
148
|
+
function glassdrop({ pick, r, accent, paths, uid, glass }) {
|
|
149
|
+
const src = glass(GLASS_PHOTOS);
|
|
150
|
+
const tint = pick(dropTintsOf(accent));
|
|
73
151
|
const k = growOf(paths);
|
|
74
|
-
const
|
|
152
|
+
const light = Math.round(between(r, 105, 150));
|
|
75
153
|
const cfg = {
|
|
76
|
-
form,
|
|
154
|
+
form: 'mark',
|
|
155
|
+
rest: 'glass',
|
|
156
|
+
loop: false,
|
|
77
157
|
area: AREA,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
158
|
+
size: 0.8,
|
|
159
|
+
markScale: Math.min(0.92, 0.78 * k),
|
|
160
|
+
restScale: 1,
|
|
161
|
+
background: '#050505',
|
|
162
|
+
color: tint,
|
|
163
|
+
light: '#FFFFFF',
|
|
164
|
+
backdrop: src,
|
|
165
|
+
dim: DIM,
|
|
166
|
+
tint: between(r, 0.35, 0.6),
|
|
167
|
+
depth: between(r, 1.1, 1.4),
|
|
168
|
+
bevel: between(r, 0.12, 0.16),
|
|
169
|
+
magnify: between(r, 0.1, 0.14),
|
|
170
|
+
dispersion: between(r, 0.9, 1.3),
|
|
171
|
+
highlights: 1.1,
|
|
172
|
+
caustics: 1,
|
|
173
|
+
bloom: 0.2,
|
|
174
|
+
ripples: 0.8,
|
|
175
|
+
shadow: 0.7,
|
|
176
|
+
soften: SOFT,
|
|
177
|
+
flow: between(r, 0.6, 1),
|
|
178
|
+
lightAngle: light,
|
|
179
|
+
lightDrift: 26,
|
|
180
|
+
delay: between(r, 0.2, 0.7),
|
|
89
181
|
};
|
|
90
182
|
const at = dropLayout(cfg, CARD);
|
|
91
|
-
const under = still(at.centre, at.
|
|
92
|
-
return { cfg, ground, ink, under };
|
|
183
|
+
const under = still(at.centre, at.mark, glassStill({ uid, paths, src, centre: at.centre, edge: at.mark, tint, light, k: 1.12 + cfg.magnify, dim: DIM }), ' overflow="visible"');
|
|
184
|
+
return { cfg, ground: '#050505', ink: '#F4F3EF', under, still: photoStill(src, DIM) };
|
|
93
185
|
}
|
|
94
186
|
|
|
95
187
|
/* ---------- Glass slabs (effects-astro's glassStack) ---------- */
|
|
96
188
|
|
|
97
|
-
/** Glass slab cards'
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
{ colors: ['#
|
|
101
|
-
{ colors: ['#
|
|
102
|
-
{ colors: ['#
|
|
103
|
-
{ colors: ['#
|
|
104
|
-
{ colors: ['#
|
|
189
|
+
/** Glass slab cards' plates, back to front, and the colour their thickness shows (real glass is green-blue through
|
|
190
|
+
* its edge; tinted glass takes its own colour there). */
|
|
191
|
+
const plateInksOf = (accent) => [
|
|
192
|
+
{ colors: ['#EEF8FF', '#DDF0FA', '#CBE6F4'], edge: '#5FD6B8' }, // clear
|
|
193
|
+
{ colors: ['#F4FFE0', '#E6FFB8', accent], edge: '#9BE36A' }, // acid
|
|
194
|
+
{ colors: ['#E8F2FF', '#BFD8FF', '#8FB6FF'], edge: '#4F8BFF' }, // blue
|
|
195
|
+
{ colors: ['#FFF1E6', '#FFD7BA', '#FFB98C'], edge: '#E8925A' }, // amber
|
|
196
|
+
{ colors: ['#F6EEFF', '#E2D2FF', '#C9B0FF'], edge: '#9A7BEA' }, // violet
|
|
105
197
|
];
|
|
106
198
|
|
|
107
|
-
/** glassstack: the mark
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const
|
|
199
|
+
/** glassstack: the mark cut from sheets of thick glass laid one over another, each down and across from the one behind,
|
|
200
|
+
* over a photo it bends and magnifies; the plates slide apart, then drift slowly so the refraction shifts. */
|
|
201
|
+
function glassstack({ pick, r, accent, paths, uid, glass }) {
|
|
202
|
+
const { colors, edge } = pick(plateInksOf(accent));
|
|
203
|
+
const src = glass(GLASS_PHOTOS);
|
|
204
|
+
const plates = pick([2, 3, 3]);
|
|
205
|
+
const k = growOf(paths);
|
|
112
206
|
const cfg = {
|
|
207
|
+
form: 'plates',
|
|
113
208
|
colors,
|
|
209
|
+
edge,
|
|
210
|
+
plates,
|
|
114
211
|
area: AREA,
|
|
115
|
-
logoScale: Math.min(0.
|
|
116
|
-
background:
|
|
117
|
-
light,
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
212
|
+
logoScale: Math.min(0.78, 0.64 * k),
|
|
213
|
+
background: '#050505',
|
|
214
|
+
light: '#FFFFFF',
|
|
215
|
+
backdrop: src,
|
|
216
|
+
dim: 0.74,
|
|
217
|
+
soften: SOFT,
|
|
218
|
+
spread: plates === 2 ? 0.09 : 0.07,
|
|
219
|
+
thickness: between(r, 0.04, 0.055),
|
|
220
|
+
bevel: 0.035,
|
|
221
|
+
density: between(r, 0.5, 0.7),
|
|
222
|
+
bend: between(r, 0.02, 0.028),
|
|
223
|
+
dispersion: between(r, 0.3, 0.5),
|
|
224
|
+
lightAngle: Math.round(between(r, 105, 140)),
|
|
124
225
|
delay: between(r, 0.1, 0.5),
|
|
125
226
|
};
|
|
126
227
|
const at = stackLayout(cfg, CARD);
|
|
127
|
-
// the still: the
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
const
|
|
136
|
-
const
|
|
137
|
-
|
|
228
|
+
// the still: the plates as the effect leaves them, back to front, in the box's units: each plate's edge (the mark in
|
|
229
|
+
// the edge colour, down and across from its face), then its face (the photo through it, sharp and magnified, tinted,
|
|
230
|
+
// with a lit lip and a dark band at the rim)
|
|
231
|
+
const x0 = at.centre.x * CARD - at.edge / 2;
|
|
232
|
+
const y0 = at.centre.y - at.edge / 2;
|
|
233
|
+
const u = 512 / at.edge;
|
|
234
|
+
const card = { x: -x0 * u, y: -y0 * u, w: CARD * u, h: u };
|
|
235
|
+
const photo = `<image href="${src}" x="${f2(card.x)}" y="${f2(card.y)}" width="${f2(card.w)}" height="${f2(card.h)}" preserveAspectRatio="xMidYMid slice" />`;
|
|
236
|
+
const step = cfg.spread * 512;
|
|
237
|
+
const side = { x: cfg.thickness * 512 * 0.55, y: cfg.thickness * 512 };
|
|
238
|
+
const tints = sliceTints(colors, plates);
|
|
239
|
+
const rim = `<filter id="${uid}-pr" x="-10%" y="-10%" width="120%" height="120%"><feGaussianBlur in="SourceAlpha" stdDeviation="6" result="b"/><feComposite in="SourceAlpha" in2="b" operator="arithmetic" k2="1" k3="-1" result="rim"/><feColorMatrix in="rim" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.8 0" result="band"/><feMorphology in="SourceAlpha" operator="erode" radius="1.8" result="in"/><feComposite in="SourceAlpha" in2="in" operator="out" result="edge"/><feColorMatrix in="edge" type="matrix" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.8 0" result="hair"/><feMerge><feMergeNode in="band"/><feMergeNode in="hair"/></feMerge></filter>`;
|
|
240
|
+
const layers = Array.from({ length: plates }, (_, i) => {
|
|
241
|
+
const t = i - (plates - 1) / 2;
|
|
242
|
+
const dx = t * step;
|
|
243
|
+
const dy = t * step;
|
|
244
|
+
const move = `translate(${f2(dx)} ${f2(dy)})`;
|
|
245
|
+
const edgeLayers = [0.5, 1].map((f) => `<g transform="translate(${f2(dx + side.x * f)} ${f2(dy + side.y * f)})" fill="${edge}" opacity="0.85">${paths}</g>`).join('');
|
|
246
|
+
return `${edgeLayers}<mask id="${uid}-p${i}" maskUnits="userSpaceOnUse" x="-128" y="-128" width="768" height="768"><g transform="${move}"${i === plates - 1 ? ' data-m' : ''} fill="#fff">${paths}</g></mask><g mask="url(#${uid}-p${i})"><g transform="translate(256 256) scale(1.12) translate(-256 -256)">${photo}</g><rect x="-128" y="-128" width="768" height="768" fill="${hex(tints[i])}" opacity="0.5" style="mix-blend-mode:multiply"/><rect x="-128" y="-128" width="768" height="768" fill="#fff" opacity="0.07"/></g><g transform="${move}" filter="url(#${uid}-pr)"><g fill="#fff">${paths}</g></g>`;
|
|
247
|
+
}).join('');
|
|
248
|
+
const body = `${softPhoto(src, card, 0.74, `${uid}-gb`)}<defs>${rim}</defs>${layers}`;
|
|
249
|
+
return { cfg, ground: '#050505', ink: '#F4F3EF', under: still(at.centre, at.edge, body, ' overflow="visible"'), still: photoStill(src, 0.74) };
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/* ---------- Paint drip (effects-astro's paintDrip, after the owner's spray-stencil reference, 2026-11-28) ---------- */
|
|
253
|
+
|
|
254
|
+
/** The grid the drips' anchors are read on, cells across the mark's 512 canvas. */
|
|
255
|
+
const DRIP_GRID = 96;
|
|
256
|
+
|
|
257
|
+
/** Paint cards' colours: ground, the paint (the name takes it too). */
|
|
258
|
+
const paintInksOf = (accent) => [
|
|
259
|
+
{ ground: '#85857F', paint: accent }, // acid on concrete
|
|
260
|
+
{ ground: '#141414', paint: '#FF4A1C' }, // signal on black
|
|
261
|
+
{ ground: '#B9B6AE', paint: '#FF2E88' }, // pink on pale concrete
|
|
262
|
+
{ ground: '#1438E0', paint: '#F4F3EF' }, // white on cobalt
|
|
263
|
+
{ ground: '#2A2B2E', paint: '#4FE3FF' }, // cyan on charcoal
|
|
264
|
+
{ ground: accent, paint: '#111111' }, // black on acid
|
|
265
|
+
];
|
|
266
|
+
|
|
267
|
+
/** paintdrip: the mark sprayed in paint, wet paint pooling on its lower edges and running down in drips that slow, stop
|
|
268
|
+
* and dry, then fade and run again. */
|
|
269
|
+
function paintdrip({ pick, r, accent, paths }) {
|
|
270
|
+
const { ground, paint } = pick(paintInksOf(accent));
|
|
271
|
+
// the mark high, so the drips have room above the name
|
|
272
|
+
const centre = { x: 0.5, y: 0.35 };
|
|
273
|
+
const edge = Math.min(0.46, 0.4 * growOf(paths));
|
|
274
|
+
const cfg = {
|
|
275
|
+
color: paint,
|
|
276
|
+
background: ground,
|
|
277
|
+
box: { x: centre.x, y: centre.y, size: edge },
|
|
278
|
+
drips: pick([2, 3, 3, 4]),
|
|
279
|
+
volume: between(r, 0.85, 1.15),
|
|
280
|
+
floor: 0.73,
|
|
281
|
+
glow: between(r, 0.4, 0.7),
|
|
282
|
+
spray: between(r, 0.45, 0.75),
|
|
283
|
+
hold: between(r, 2.2, 3),
|
|
284
|
+
seed: Math.round(r() * 1000) / 100,
|
|
285
|
+
};
|
|
286
|
+
// where the drips hang, read off the mark's outer lower silhouette here (its coverage on a grid of the 512 canvas),
|
|
287
|
+
// handed to the effect so the canvas runs the same drips the still shows at full length
|
|
288
|
+
const n = DRIP_GRID;
|
|
289
|
+
const list = shapes(paths);
|
|
290
|
+
const cover = list.length
|
|
291
|
+
? pixelCoverage(
|
|
292
|
+
list.map((sh) => ({ rings: rings(sh.segs), evenodd: sh.evenodd })),
|
|
293
|
+
{ cols: n, rows: n, cell: 512 / n, x0: 0, y0: 0 },
|
|
294
|
+
)
|
|
295
|
+
: new Float32Array(n * n);
|
|
296
|
+
const round4 = (v) => Math.round(v * 1e4) / 1e4;
|
|
297
|
+
const anchors = dripAnchors(cover, n, n, cfg.drips, cfg.seed).map((a) => ({ x: round4(a.x), y: round4(a.y), room: round4(a.room), open: a.open }));
|
|
298
|
+
const at = { left: centre.x * CARD - edge / 2, top: centre.y - edge / 2, size: edge };
|
|
299
|
+
const rest = anchors.length ? dripsAtRest(dripPlan(anchors, at, cfg)) : '';
|
|
300
|
+
// the still: the mark, and the drips at full length (the loop's resting frame), in the 512 box's units
|
|
301
|
+
const drips = rest ? `<path fill="${paint}" transform="scale(${f2(512 / edge)}) translate(${-at.left} ${-at.top})" d="${rest}" />` : '';
|
|
302
|
+
return { cfg: { ...cfg, anchors }, ground, ink: paint, under: still(centre, edge, `${drips}<g data-m fill="${paint}">${paths}</g>`, ' overflow="visible"') };
|
|
138
303
|
}
|
|
139
304
|
|
|
140
305
|
/* ---------- the table ---------- */
|
|
@@ -144,6 +309,7 @@ function glassstack({ pick, r, accent, paths, uid }) {
|
|
|
144
309
|
export const GLASS = {
|
|
145
310
|
glassdrop: { effect: 'glass-drop', label: 'Liquid glass', deal: glassdrop },
|
|
146
311
|
glassstack: { effect: 'glass-stack', label: 'Glass slabs', deal: glassstack },
|
|
312
|
+
paintdrip: { effect: 'paint-drip', label: 'Paint drip', deal: paintdrip },
|
|
147
313
|
};
|
|
148
314
|
|
|
149
315
|
/** Whether a kind is a glass card. */
|
package/src/live.d.ts
CHANGED
|
@@ -67,6 +67,8 @@ export declare function markSource(card: Element): string | null;
|
|
|
67
67
|
* @returns Starts a card; what it returns stops it (or gives up its place in the queue).
|
|
68
68
|
*/
|
|
69
69
|
export declare function shaders(cap?: number): (card: HTMLElement) => Stop;
|
|
70
|
+
/** How many costly looks run at once: 1 on a phone or a 4-core machine, 4 on a mid one, 10 with 8 cores or more. */
|
|
71
|
+
export declare function heavyCap(): number;
|
|
70
72
|
/** What `liveCards` watches and how. */
|
|
71
73
|
export type LiveOptions = {
|
|
72
74
|
/** Where the cards are found (the document). */
|
|
@@ -77,18 +79,20 @@ export type LiveOptions = {
|
|
|
77
79
|
plain?: () => boolean;
|
|
78
80
|
/** Starts a `[data-smoke]` card (a sponsor's); `smoke(card)` by default. */
|
|
79
81
|
smoke?: (card: HTMLElement) => Stop;
|
|
80
|
-
/** How many costly looks (`data-anim="heavy"`) move at once
|
|
82
|
+
/** How many costly looks (`data-anim="heavy"`) move at once (`heavyCap()`: 1 on a phone, 4 on a mid machine, 10 with 8+ cores). */
|
|
81
83
|
heavy?: number;
|
|
82
|
-
/** How many shader and
|
|
84
|
+
/** How many shader, gradient and field cards run at once (all: they share one WebGL context). */
|
|
83
85
|
gl?: number;
|
|
84
86
|
/** How near the screen a card starts (`150px`). */
|
|
85
87
|
margin?: string;
|
|
86
88
|
/** Cards whose motion never waits its turn (the expanded view's, `.lv-card`). */
|
|
87
89
|
always?: (card: HTMLElement) => boolean;
|
|
90
|
+
/** Keep every card's name fitted to its card (`fitWatch`; true). */
|
|
91
|
+
fit?: boolean;
|
|
88
92
|
};
|
|
89
93
|
/** The watcher `liveCards` returns. */
|
|
90
94
|
export type LiveCards = {
|
|
91
|
-
/** Watches cards not yet watched; lets go of any that left the page (or that Plain hid). */
|
|
95
|
+
/** Watches cards not yet watched; lets go of any that left the page (or that Plain hid); fits the names again. */
|
|
92
96
|
watch: () => void;
|
|
93
97
|
/** Starts the matching cards again (the smoke, when the theme changes). */
|
|
94
98
|
restart: (match: (card: HTMLElement) => boolean) => void;
|
|
@@ -107,3 +111,21 @@ export declare function liveCards(options?: LiveOptions): LiveCards;
|
|
|
107
111
|
* @returns Stops listening.
|
|
108
112
|
*/
|
|
109
113
|
export declare function holoPointer(target?: Window | HTMLElement): Stop;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Fits one card name (`.wc-name`) to its card: back to its look's size, then smaller where it would cross the card's
|
|
117
|
+
* edge less a 5% margin; never clipped, never wrapped, never larger than its look made it.
|
|
118
|
+
*
|
|
119
|
+
* @param el The name.
|
|
120
|
+
* @returns The scale it was set at (1: as its look made it).
|
|
121
|
+
*/
|
|
122
|
+
export declare function fitName(el: HTMLElement): number;
|
|
123
|
+
/** Fits every card name under `scope` (the document). */
|
|
124
|
+
export declare function fitNames(scope?: ParentNode): void;
|
|
125
|
+
/**
|
|
126
|
+
* Keeps every card name under `scope` fitted: now, when the web fonts load, when a card changes size, and when cards
|
|
127
|
+
* are added under `observe`.
|
|
128
|
+
*
|
|
129
|
+
* @returns Stops watching.
|
|
130
|
+
*/
|
|
131
|
+
export declare function fitWatch(scope?: ParentNode, options?: { observe?: Element[] }): Stop;
|