@arraypress/effects-astro 0.12.0 → 0.13.0

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,331 @@
1
+ /**
2
+ * @module @arraypress/effects-astro/glass-drop
3
+ *
4
+ * A logo arriving as liquid glass: a drop forms, lands with rings running
5
+ * out across the ground, and spreads into a glass tile with the logo rising
6
+ * under it (or, with `form: 'mark'`, into the logo's own shape, the logo
7
+ * itself made of tinted glass). The glass bends what is under it, hardest
8
+ * at its rim, splits colour there, mirrors a small studio along its bevels
9
+ * and focuses light at its edge. It holds, then melts away, and the logo is
10
+ * left flat on the ground at its resting size. It plays once, or loops.
11
+ *
12
+ * Our own construction after the idea of a logo intro in liquid glass (see
13
+ * docs/credits.md): the glass is a height field over a signed distance —
14
+ * a circle, a rounded square or the logo's own field, mixed as the drop
15
+ * spreads — lit by the shared studio (./glass-optics.js).
16
+ *
17
+ * Opaque: it paints its `background` everywhere. Without WebGL the canvas
18
+ * goes and the element's background shows. With reduced motion it is one
19
+ * still frame: the final state (the logo at rest, or the glass held).
20
+ */
21
+
22
+ import { createStage } from './stage.js';
23
+ import { drawShape, distanceField, blurField } from './shape.js';
24
+ import { parseColor } from './color.js';
25
+ import { GLSL_STUDIO, lightVector } from './glass-optics.js';
26
+ import { DROP_SIZE, dropAt, dropLayout } from './glass-drop-plan.js';
27
+
28
+ /**
29
+ * @typedef {import('./glass-drop.js').GlassDropConfig} GlassDropConfig
30
+ */
31
+
32
+ const FRAG = `
33
+ precision highp float;
34
+ uniform vec2 uRes;
35
+ uniform sampler2D uMask;
36
+ uniform sampler2D uSdf;
37
+ uniform float uSpread;
38
+ uniform vec2 uCentre;
39
+ uniform float uEdge;
40
+ uniform float uMarkBox;
41
+ uniform float uScale;
42
+ uniform float uForm;
43
+ uniform float uRadius;
44
+ uniform float uDrop;
45
+ uniform float uMorph;
46
+ uniform float uWobble;
47
+ uniform float uTime;
48
+ uniform float uRipple;
49
+ uniform float uMarkIn;
50
+ uniform float uGlass;
51
+ uniform vec3 uGround;
52
+ uniform vec3 uInk;
53
+ uniform vec3 uPlate;
54
+ uniform vec3 uLight;
55
+ uniform float uDepth;
56
+ uniform float uDispersion;
57
+ uniform float uBevel;
58
+ uniform float uHighlights;
59
+ uniform float uCaustics;
60
+ uniform float uBloom;
61
+ uniform float uRipples;
62
+ uniform float uTint;
63
+ uniform vec2 uLightDir;
64
+ ${GLSL_STUDIO}
65
+
66
+ // The logo's coverage at p (heights from the glass's middle), its box 'box' high.
67
+ float markCover(vec2 p, float box) {
68
+ vec2 uv = p / box + 0.5;
69
+ if (uv.x < 0.0 || uv.y < 0.0 || uv.x > 1.0 || uv.y > 1.0) return 0.0;
70
+ return texture2D(uMask, vec2(uv.x, 1.0 - uv.y)).r;
71
+ }
72
+
73
+ // The logo's signed distance, in heights, positive inside.
74
+ float markField(vec2 p) {
75
+ vec2 uv = p / uMarkBox + 0.5;
76
+ vec2 c = clamp(uv, 0.0, 1.0);
77
+ float d = (texture2D(uSdf, vec2(c.x, 1.0 - c.y)).r - 0.5) * 2.0 * uSpread * uMarkBox;
78
+ return d - length(uv - c) * uMarkBox;
79
+ }
80
+
81
+ // A rounded square's signed distance, positive inside.
82
+ float roundBox(vec2 p, float hw, float r) {
83
+ vec2 q = abs(p) - vec2(hw - r);
84
+ return -(length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - r);
85
+ }
86
+
87
+ // The glass's signed distance now: the drop, becoming the tile or the logo, its edge still rippling.
88
+ float glassField(vec2 p) {
89
+ float drop = uDrop - length(p);
90
+ float target = uForm < 0.5 ? roundBox(p, uEdge * 0.5, uEdge * uRadius) : markField(p);
91
+ float a = atan(p.y, p.x);
92
+ float wave = sin(a * 3.0 + uTime * 5.0) * 0.6 + sin(a * 5.0 - uTime * 7.3) * 0.4;
93
+ return mix(drop, target, uMorph) + wave * uWobble * (uDrop * 0.1 + uEdge * 0.012 * clamp(uMorph, 0.0, 1.0));
94
+ }
95
+
96
+ // The bevel's reach now: the whole drop while it is a drop, the set bevel once it has spread.
97
+ float bevelNow() {
98
+ float shape = uForm < 0.5 ? uEdge : uMarkBox;
99
+ return max(mix(uDrop, uBevel * shape, clamp(uMorph, 0.0, 1.0)), 1e-4);
100
+ }
101
+
102
+ // The glass's height, 0 at its edge rising to 1 past the bevel: a quarter round, so the rim is steep.
103
+ float heightAt(float g, float b) {
104
+ float s = clamp(g / b, 0.0, 1.0);
105
+ return sqrt(s * (2.0 - s));
106
+ }
107
+
108
+ // The ground: its colour, a faint pool of light about the middle, and the rings the drop sent out.
109
+ vec3 ground(vec2 p) {
110
+ vec3 col = uGround + (uLight - uGround) * 0.03 * uGlass * exp(-dot(p, p) * 5.0);
111
+ if (uRipple > 0.0) {
112
+ float r = length(p);
113
+ for (int k = 0; k < 3; k++) {
114
+ float age = uRipple - float(k) * 0.32;
115
+ if (age <= 0.0) continue;
116
+ float at = uDrop * 1.1 + age * 0.42;
117
+ float w = 0.004 + age * 0.006;
118
+ float ring = exp(-pow((r - at) / w, 2.0));
119
+ col += mix(uLight, uInk, 0.35) * ring * exp(-age * 1.6) * 0.28 * uRipples / (1.0 + float(k));
120
+ }
121
+ }
122
+ return col;
123
+ }
124
+
125
+ // What lies under the glass (and, once it melts, what is left): the ground, the tile's plate, the logo.
126
+ vec3 scene(vec2 p, float plateCover) {
127
+ vec3 col = ground(p);
128
+ col = mix(col, uPlate, plateCover * uGlass);
129
+ return mix(col, uInk, markCover(p, uMarkBox * uScale) * uMarkIn);
130
+ }
131
+
132
+ void main() {
133
+ vec2 p = gl_FragCoord.xy / uRes.y - uCentre;
134
+ float px = 1.0 / uRes.y;
135
+ float b = bevelNow();
136
+ float g = glassField(p);
137
+
138
+ // The slope of the glass, from its height either side.
139
+ vec2 e = vec2(px * 1.5, 0.0);
140
+ float hx = heightAt(glassField(p + e.xy), b) - heightAt(glassField(p - e.xy), b);
141
+ float hy = heightAt(glassField(p + e.yx), b) - heightAt(glassField(p - e.yx), b);
142
+ vec2 slope = vec2(hx, hy) / (2.0 * e.x) * b;
143
+ float h = heightAt(g, b);
144
+ vec3 n = normalize(vec3(-slope * uDepth * 0.55 * uGlass, 1.0));
145
+ vec2 outward = length(slope) > 1e-5 ? -normalize(slope) : vec2(0.0);
146
+
147
+ float cover = clamp(g / (px * 1.2) + 0.5, 0.0, 1.0);
148
+ float plate = uForm < 0.5 ? cover : 0.0;
149
+
150
+ // Through the glass: magnified a little, bent at the rim, the colours parting there.
151
+ vec2 rim = n.xy * uDepth * 0.06;
152
+ vec2 lens = p * (1.0 - h * uDepth * 0.05 * uGlass);
153
+ float split = uDispersion * 0.3;
154
+ vec3 through = vec3(
155
+ scene(lens - rim * (1.0 + split), plate).r,
156
+ scene(lens - rim, plate).g,
157
+ scene(lens - rim * (1.0 - split), plate).b
158
+ );
159
+ if (uForm > 0.5) {
160
+ // The logo made of glass: the ground through it, tinted the logo's colour, deepest where it is thickest.
161
+ float tint = mix(1.0, uTint * (0.75 + 0.25 * h), uGlass);
162
+ through = mix(through, uInk * (0.82 + 0.18 * h + 0.12 * (1.0 - uGlass)), tint);
163
+ }
164
+
165
+ // What the glass mirrors: the studio, along the bevels as they turn toward it.
166
+ vec3 view = vec3(0.0, 0.0, -1.0);
167
+ vec3 mirrored = studio(reflect(view, n), uLightDir, uLight);
168
+ float fres = schlick(n.z, 0.04);
169
+ vec3 col = through * (1.0 - fres * 0.6) + mirrored * (0.25 + fres * 1.6) * uHighlights * uGlass;
170
+
171
+ // The lip: a hairline brightest facing the light; light gathered just inside the rim on the far side.
172
+ float facing = dot(outward, uLightDir);
173
+ float lip = exp(-pow(g / (px * 1.3), 2.0));
174
+ col += uLight * lip * (0.25 + 0.55 * max(facing, 0.0)) * uHighlights * uGlass;
175
+ float inner = smoothstep(b * 0.9, 0.0, g) * smoothstep(0.0, px * 3.0, g);
176
+ col += mix(uLight, uInk, 0.5) * inner * max(-facing, 0.0) * 0.32 * uCaustics * uGlass;
177
+
178
+ // Outside: the ground, the light the glass focuses onto it on the side away from the light, and a soft bloom.
179
+ vec3 outside = scene(p, 0.0);
180
+ // (the logo's own field stops a little way out, so its glow stays closer)
181
+ float reach = uForm < 0.5 ? uEdge : uMarkBox * 0.4;
182
+ float near = exp(min(g, 0.0) / (reach * 0.05 + 1e-4));
183
+ outside += mix(uLight, uInk, 0.6) * near * max(-facing, 0.0) * 0.14 * uCaustics * uGlass;
184
+ outside += mix(uLight, uInk, 0.5) * exp(min(g, 0.0) / (reach * 0.09 + 1e-4)) * 0.12 * uBloom * uGlass;
185
+
186
+ gl_FragColor = vec4(mix(outside, col, cover), 1.0);
187
+ }
188
+ `;
189
+
190
+ /** The defaults: a white logo under dark navy glass on black, lit from the top left. */
191
+ const DEFAULTS = Object.freeze({
192
+ background: '#000000',
193
+ color: '#ffffff',
194
+ plate: '#0a1020',
195
+ light: '#ffffff',
196
+ radius: 0.24,
197
+ depth: 1,
198
+ dispersion: 1,
199
+ bevel: 0.1,
200
+ highlights: 1,
201
+ caustics: 1,
202
+ bloom: 0.5,
203
+ ripples: 1,
204
+ tint: 0.88,
205
+ lightAngle: 125,
206
+ });
207
+
208
+ /** The finest the logo's mask and field are drawn, in pixels across. */
209
+ const MASK_MAX = 1024;
210
+ const FIELD_MAX = 360;
211
+
212
+ /**
213
+ * Uploads a one-byte-a-pixel picture to a texture unit.
214
+ *
215
+ * @param {WebGLRenderingContext | WebGL2RenderingContext} gl The context.
216
+ * @param {number} unit The texture unit.
217
+ * @param {WebGLTexture | null} texture The texture.
218
+ * @param {number} size Its edge, in pixels (square).
219
+ * @param {Uint8Array | Uint8ClampedArray} data Its bytes, rows from the top.
220
+ */
221
+ function upload(gl, unit, texture, size, data) {
222
+ gl.activeTexture(gl.TEXTURE0 + unit);
223
+ gl.bindTexture(gl.TEXTURE_2D, texture);
224
+ gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
225
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, size, size, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, data instanceof Uint8Array ? data : new Uint8Array(data.buffer));
226
+ }
227
+
228
+ /**
229
+ * Makes an empty, smoothly filtered, edge-clamped texture on a unit.
230
+ *
231
+ * @param {WebGLRenderingContext | WebGL2RenderingContext} gl The context.
232
+ * @param {number} unit The texture unit.
233
+ * @returns {WebGLTexture | null} The texture.
234
+ */
235
+ function texture(gl, unit) {
236
+ const t = gl.createTexture();
237
+ gl.activeTexture(gl.TEXTURE0 + unit);
238
+ gl.bindTexture(gl.TEXTURE_2D, t);
239
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
240
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
241
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
242
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
243
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, 1, 1, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, new Uint8Array([0]));
244
+ return t;
245
+ }
246
+
247
+ /**
248
+ * Starts the glass drop on an element: an opaque canvas inside it, filling it.
249
+ *
250
+ * @param {HTMLElement} el The element (its first canvas is drawn into).
251
+ * @param {GlassDropConfig} config The settings.
252
+ * @returns {() => void} Stops it.
253
+ */
254
+ export function glassDrop(el, config) {
255
+ const c = { ...DEFAULTS, ...config };
256
+ const form = c.form === 'mark' ? 1 : 0;
257
+ const start = performance.now();
258
+ let generation = 0;
259
+ /** The tile's edge in heights, from the last resize. */
260
+ let tile = 0;
261
+ /** The shape's textures, made in setup. */
262
+ let mask = /** @type {WebGLTexture | null} */ (null);
263
+ let sdf = /** @type {WebGLTexture | null} */ (null);
264
+
265
+ const { stage, stop } = createStage(el, {
266
+ fragment: FRAG,
267
+ alpha: false,
268
+ setup({ gl, uniform }) {
269
+ mask = texture(gl, 0);
270
+ sdf = texture(gl, 1);
271
+ gl.uniform1i(uniform('uMask'), 0);
272
+ gl.uniform1i(uniform('uSdf'), 1);
273
+ gl.uniform1f(uniform('uForm'), form);
274
+ gl.uniform1f(uniform('uRadius'), Math.min(0.5, Math.max(0, c.radius)));
275
+ gl.uniform1f(uniform('uDepth'), c.depth);
276
+ gl.uniform1f(uniform('uDispersion'), c.dispersion);
277
+ gl.uniform1f(uniform('uBevel'), c.bevel);
278
+ gl.uniform1f(uniform('uHighlights'), c.highlights);
279
+ gl.uniform1f(uniform('uCaustics'), c.caustics);
280
+ gl.uniform1f(uniform('uBloom'), c.bloom);
281
+ gl.uniform1f(uniform('uRipples'), c.ripples);
282
+ gl.uniform1f(uniform('uTint'), c.tint);
283
+ gl.uniform2fv(uniform('uLightDir'), lightVector(c.lightAngle));
284
+ gl.uniform3fv(uniform('uGround'), parseColor(c.background));
285
+ gl.uniform3fv(uniform('uInk'), parseColor(c.color));
286
+ gl.uniform3fv(uniform('uPlate'), parseColor(c.plate));
287
+ gl.uniform3fv(uniform('uLight'), parseColor(c.light));
288
+ },
289
+ resize({ gl, uniform, canvas }) {
290
+ const aspect = canvas.width / canvas.height;
291
+ const layout = dropLayout(c, aspect);
292
+ gl.uniform2f(uniform('uCentre'), layout.centre.x * aspect, 1 - layout.centre.y);
293
+ tile = layout.tile;
294
+ gl.uniform1f(uniform('uEdge'), tile);
295
+ gl.uniform1f(uniform('uMarkBox'), layout.mark);
296
+ // The mask at the larger of the logo's two sizes, so it is never magnified.
297
+ const big = Math.max(layout.mark, layout.rest) * canvas.height;
298
+ const size = Math.max(64, Math.min(MASK_MAX, Math.round(big)));
299
+ const mine = ++generation;
300
+ const source = { text: c.text, font: c.font, src: c.src, padding: 0 };
301
+ const shapes = [drawShape(source, size, size)];
302
+ if (form) shapes.push(drawShape(source, FIELD_MAX, FIELD_MAX));
303
+ Promise.all(shapes)
304
+ .then(([full, small]) => {
305
+ if (mine !== generation) return;
306
+ upload(gl, 0, mask, size, full.alpha);
307
+ if (small) {
308
+ const spread = Math.round(FIELD_MAX / 9);
309
+ upload(gl, 1, sdf, FIELD_MAX, blurField(distanceField(small, spread), FIELD_MAX, FIELD_MAX, FIELD_MAX / 160));
310
+ gl.useProgram(stage?.program ?? null);
311
+ gl.uniform1f(uniform('uSpread'), spread / FIELD_MAX);
312
+ }
313
+ if (stage?.still) stage.redraw();
314
+ })
315
+ .catch((error) => console.warn('[effects-astro]', error));
316
+ },
317
+ uniforms({ gl, uniform, still }, now) {
318
+ const seconds = (now - start) / 1000;
319
+ const s = dropAt(still ? Infinity : seconds, c);
320
+ gl.uniform1f(uniform('uTime'), seconds);
321
+ gl.uniform1f(uniform('uDrop'), s.drop * DROP_SIZE * tile);
322
+ gl.uniform1f(uniform('uMorph'), s.morph);
323
+ gl.uniform1f(uniform('uWobble'), s.wobble);
324
+ gl.uniform1f(uniform('uRipple'), s.ripple);
325
+ gl.uniform1f(uniform('uMarkIn'), s.markIn);
326
+ gl.uniform1f(uniform('uGlass'), s.glass);
327
+ gl.uniform1f(uniform('uScale'), s.scale);
328
+ },
329
+ });
330
+ return stop;
331
+ }
@@ -0,0 +1,5 @@
1
+ /** GLSL: `studio(dir, lightDir, light)`, the light a mirror facing `dir` sees in a dark studio (a softbox on the light's side, a strip light opposite, a dim fill), and `schlick(cosine, f0)`, Schlick's fresnel. */
2
+ export declare const GLSL_STUDIO: string;
3
+
4
+ /** A light angle (degrees, 0 right, 90 top) as a unit vector on the screen, y up. */
5
+ export declare function lightVector(degrees: number): [number, number];
@@ -0,0 +1,49 @@
1
+ /**
2
+ * @module @arraypress/effects-astro/glass-optics
3
+ *
4
+ * The optics the glass logos share (GlassDrop, GlassStack): a small studio
5
+ * for glass to mirror, and how much a surface mirrors at an angle. Glass
6
+ * looks real when it reflects a room, not when it carries highlight spots,
7
+ * so the bevels pick up a softbox and a strip light as they turn toward
8
+ * them, and a flat face facing the viewer picks up almost nothing.
9
+ */
10
+
11
+ /**
12
+ * GLSL: `vec3 studio(vec3 dir, vec2 lightDir, vec3 light)`, the light a
13
+ * mirror facing `dir` sees in a dark studio (`dir` points out of the
14
+ * surface; +z is toward the viewer): a broad softbox up toward `lightDir`
15
+ * (a unit vector on the screen, the side the light comes from), a thin
16
+ * strip light opposite it, and a dim fill everywhere. And
17
+ * `float schlick(float cosine, float f0)`, Schlick's fresnel: how much of
18
+ * the light a surface mirrors when seen at that angle (`f0` head on).
19
+ */
20
+ export const GLSL_STUDIO = `
21
+ vec3 studio(vec3 dir, vec2 lightDir, vec3 light) {
22
+ vec3 d = normalize(dir);
23
+ // The softbox: large, high on the light's side, so a face looking straight back sees only its edge.
24
+ vec3 key = normalize(vec3(lightDir * 0.78, 0.62));
25
+ float box = smoothstep(0.78, 0.93, dot(d, key));
26
+ // The strip: a long, thin light low on the other side, for a rim on the shadowed bevels.
27
+ vec3 across = normalize(vec3(-lightDir.y, lightDir.x, 0.0));
28
+ vec3 back = normalize(vec3(-lightDir * 0.9, 0.42));
29
+ float strip = smoothstep(0.86, 0.97, dot(d, back)) * smoothstep(0.55, 0.2, abs(dot(d, across)));
30
+ // The room: a little light everywhere, more from above the horizon of the light's side.
31
+ float fill = 0.035 + 0.05 * clamp(dot(d.xy, lightDir) * 0.5 + 0.5, 0.0, 1.0);
32
+ return light * (box + strip * 0.45 + fill);
33
+ }
34
+ float schlick(float cosine, float f0) {
35
+ float m = clamp(1.0 - cosine, 0.0, 1.0);
36
+ return f0 + (1.0 - f0) * m * m * m * m * m;
37
+ }
38
+ `;
39
+
40
+ /**
41
+ * A light angle as the shaders take it: a unit vector on the screen, y up.
42
+ *
43
+ * @param {number} degrees Where the light comes from, 0 right, 90 top.
44
+ * @returns {[number, number]} Its direction.
45
+ */
46
+ export function lightVector(degrees) {
47
+ const a = (degrees * Math.PI) / 180;
48
+ return [Math.cos(a), Math.sin(a)];
49
+ }
@@ -0,0 +1,65 @@
1
+ export interface GlassStackConfig {
2
+ /** An image (an SVG logo) to make the stack of. */
3
+ src?: string;
4
+ /** A character or word instead of an image. */
5
+ text?: string;
6
+ /** Its CSS font, without the size. Default: the page's, bold. */
7
+ font?: string;
8
+ /** Where the stack sits, each 0–1 from the top left. Default all of the element. */
9
+ area?: { x: number; y: number; width: number; height: number };
10
+ /** The logo's size, a share of the area's shorter side, 0.2–1. Default 0.73. */
11
+ logoScale?: number;
12
+ /** The glass's tints from the top slice to the bottom, 2–6 colours. Default aqua to deep blue. */
13
+ colors?: string[];
14
+ /** The ground. Default `#ffffff`. */
15
+ background?: string;
16
+ /** The lit card behind the stack, and the studio the glass mirrors. Default `#ffffff`. */
17
+ light?: string;
18
+ /** How many slices the logo is cut into, 4–64. Default 22. */
19
+ slabs?: number;
20
+ /** Where in its slice each disc samples the logo, 0 the top to 1 the bottom. Default 0.5. */
21
+ phase?: number;
22
+ /** How much of its slice each disc samples, 0 a line to 1 all of it; more keeps small parts. Default 0.35. */
23
+ band?: number;
24
+ /** How open each disc is from below (the camera's height), a share of the slice, 0.05–1.4. Default 0.55. */
25
+ depth?: number;
26
+ /** How much of each disc's front edge shows, a share of the slice, 0–1. Default 0.35. */
27
+ thickness?: number;
28
+ /** The glass's refractive index: how hard its rims bend the card, 1–2. Default 1.45. */
29
+ ior?: number;
30
+ /** How strongly the glass mirrors the studio, 0–1. Default 0.3. */
31
+ reflectivity?: number;
32
+ /** How deeply the glass is tinted, 0–3. Default 0.9. */
33
+ density?: number;
34
+ /** How much the discs hide the discs behind them, 0–1. Default 0.92. */
35
+ opacity?: number;
36
+ /** The card's brightness, 0–2. Default 1.1. */
37
+ exposure?: number;
38
+ /** How far the card's light spills onto the ground, 0–1. Default 0.05. */
39
+ ambient?: number;
40
+ /** The card's size, times the logo's box, 0 for none to 3. Default 1.15. */
41
+ cardSize?: number;
42
+ /** Where the light comes from, degrees, 0–360 (0 right, 90 top). Default 115. */
43
+ lightAngle?: number;
44
+ /** How far the stack leans toward the pointer, 0–2; 0 for not at all. Default 1. */
45
+ tilt?: number;
46
+ /** How far it leans on its own, slowly, 0–2; 0 holds it still. Default 0.5. */
47
+ sway?: number;
48
+ /** Grow the discs from the bottom up when it first shows. Default true. */
49
+ intro?: boolean;
50
+ /** Seconds until the top disc has grown, 0.2–6. Default 1.6. */
51
+ introDuration?: number;
52
+ /** Seconds before the intro starts, 0–10. Default 0. */
53
+ delay?: number;
54
+ /** How fast the intro plays, 0.25–3. Default 1. */
55
+ speed?: number;
56
+ }
57
+
58
+ /** The tint of each slice: the colours as a gradient from the top slice to the bottom one, blended in Oklab (RGB 0–1). */
59
+ export declare function sliceTints(colors: string[], slices: number): Array<[number, number, number]>;
60
+
61
+ /** Where the stack sits in an element (`aspect`, its width over its height): its middle (0–1 from the top left) and its square box's edge, a share of the height. */
62
+ export declare function stackLayout(config: Pick<GlassStackConfig, 'area' | 'logoScale'>, aspect: number): { centre: { x: number; y: number }; edge: number };
63
+
64
+ /** Starts the glass stack on an element (its first canvas). Returns a function that stops it. */
65
+ export declare function glassStack(el: HTMLElement, config: GlassStackConfig): () => void;