use-scroll-animate 9.2.0 → 9.4.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.
- package/CHANGELOG.md +24 -0
- package/dist/components/fx-genart.cjs +137 -0
- package/dist/components/fx-genart.cjs.map +1 -0
- package/dist/components/fx-genart.d.cts +69 -0
- package/dist/components/fx-genart.d.ts +69 -0
- package/dist/components/fx-genart.js +131 -0
- package/dist/components/fx-genart.js.map +1 -0
- package/dist/components/fx-video.cjs +111 -0
- package/dist/components/fx-video.cjs.map +1 -0
- package/dist/components/fx-video.d.cts +80 -0
- package/dist/components/fx-video.d.ts +80 -0
- package/dist/components/fx-video.js +105 -0
- package/dist/components/fx-video.js.map +1 -0
- package/dist/components/fx2.cjs +16 -0
- package/dist/components/fx2.cjs.map +1 -1
- package/dist/components/fx2.d.cts +61 -1
- package/dist/components/fx2.d.ts +61 -1
- package/dist/components/fx2.js +9 -1
- package/dist/components/fx2.js.map +1 -1
- package/dist/components/marketplace.cjs +2 -0
- package/dist/components/marketplace.cjs.map +1 -1
- package/dist/components/marketplace.js +2 -0
- package/dist/components/marketplace.js.map +1 -1
- package/dist/components/widgets.cjs +619 -177
- package/dist/components/widgets.cjs.map +1 -1
- package/dist/components/widgets.d.cts +69 -2
- package/dist/components/widgets.d.ts +69 -2
- package/dist/components/widgets.js +615 -178
- package/dist/components/widgets.js.map +1 -1
- package/dist/widgets.umd.js +1 -1
- package/dist/widgets.umd.js.map +1 -1
- package/docs/ROADMAP.md +2 -2
- package/docs/components.md +34 -0
- package/package.json +41 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [9.4.0] - 2026-10-09
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- **Video motion — `motionary/fx/video`** (= `motionary/components/fx-video`, `registerVideoPack()`, also in `registerEffectPacks()` and the marketplace): `scrubVideo(video, trigger?)` (scroll-driven video, eased `currentTime`), `frameSequence(canvas, { count, src | draw }, trigger?)` (Apple-style image sequences scrubbed by scroll, preloaded), `scrollProgress(el)`. Effects `film-burn` (enter) and `jump-cut` (attention).
|
|
14
|
+
- **2 new components (9.4)** in `motionary/components/widgets`:
|
|
15
|
+
- `<usa-video-card>` — hover / focus plays a muted preview with a progress line, play badge and duration chip (`duration` or read from the video); poster Ken Burns drift when there is no playable video; click / Enter → `usa:open` { src }; `previewing`.
|
|
16
|
+
- `<usa-hero-video>` — full-bleed hero: poster (`poster`, `<img>` or gradient) cross-fades to the background video when it can play, scrim, always-present pause / play button, `scrub` for a scroll-driven video, poster drift when no video; `paused`, `toggle()`; `usa:play` / `usa:pause`.
|
|
17
|
+
- Showcase: 3 new gallery cards with copyable code, live demos and live Store thumbnails.
|
|
18
|
+
|
|
19
|
+
### Accessibility
|
|
20
|
+
- The hero always offers a labelled pause / play button for moving video (WCAG 2.2.2) and is a labelled `region`; background videos are muted and `aria-hidden`. The video card is a focusable button labelled "Play <title>". Reduced motion: no autoplay or preview (poster only), scrubbing shows the first frame, `film-burn` fades, `jump-cut` does nothing.
|
|
21
|
+
|
|
22
|
+
## [9.3.0] - 2026-10-09
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
- **2 new components (9.3)** in `motionary/components/widgets`:
|
|
26
|
+
- `<usa-gen-art>` — seeded generative artwork on a canvas: `art` = `flow` (flow field) · `circles` (circle packing) · `truchet` (quarter-arc tiles) · `waves` (layered ridges), `seed`, `palette`, `label`; draws itself in on screen; click / Enter re-seeds; `generate(seed?)`, `toDataURL()`, `seed`; `usa:generate` { seed }.
|
|
27
|
+
- `<usa-bg-generator>` — background generator: palette + style (`mesh`, `grain`, `stripes`, `dots`) + shuffle, live preview with a cross-fade, copy the CSS; `css`, `shuffle()`, `copy()`; `usa:change` { css, seed }; `backgroundCss()`.
|
|
28
|
+
- **Generative art 2.0 pack — `motionary/fx/genart`** (= `motionary/components/fx-genart`, `registerGenArtPack()`, also in `registerEffectPacks()` and the marketplace): `halftone-in` (enter), `mesh-drift` (loop), `kaleido` (loop), `grain-flicker` (loop). `PALETTES`, `seededRandom()`, `meshGradient()`.
|
|
29
|
+
- Showcase: 4 new gallery cards with copyable code, live demos and live Store thumbnails.
|
|
30
|
+
|
|
31
|
+
### Accessibility
|
|
32
|
+
- `<usa-gen-art>` is a focusable `img` whose label names the art style and seed (updated on re-seed). `<usa-bg-generator>` is a labelled `group` of real `<select>`s and buttons; the preview is `aria-hidden` and the CSS is shown as text. Reduced motion: artwork is drawn at once, no cross-fade, `halftone-in` fades, the loops are skipped.
|
|
33
|
+
|
|
10
34
|
## [9.2.0] - 2026-10-09
|
|
11
35
|
|
|
12
36
|
### Added
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var registry = require('../chunks/registry-BVklOepd.cjs');
|
|
4
|
+
require('../chunks/base-DoRUZBy-.cjs');
|
|
5
|
+
|
|
6
|
+
const PALETTES = {
|
|
7
|
+
sunset: ['#ff6b6b', '#feca57', '#ff9ff3', '#5f27cd', '#1dd1a1'],
|
|
8
|
+
ocean: ['#0abde3', '#48dbfb', '#c8d6e5', '#10ac84', '#222f3e'],
|
|
9
|
+
forest: ['#2d6a4f', '#52b788', '#95d5b2', '#d8f3dc', '#081c15'],
|
|
10
|
+
candy: ['#f72585', '#b5179e', '#7209b7', '#4361ee', '#4cc9f0'],
|
|
11
|
+
mono: ['#111827', '#374151', '#6b7280', '#d1d5db', '#f9fafb'],
|
|
12
|
+
};
|
|
13
|
+
/** Deterministic PRNG in [0, 1) (mulberry32) (9.3). */
|
|
14
|
+
function seededRandom(seed) {
|
|
15
|
+
let a = (Math.floor(Math.abs(seed) * 1e3) >>> 0) || 1;
|
|
16
|
+
return () => {
|
|
17
|
+
a = (a + 0x6d2b79f5) >>> 0;
|
|
18
|
+
let t = a;
|
|
19
|
+
t = Math.imul(t ^ (t >>> 15), t | 1);
|
|
20
|
+
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
|
21
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** A seeded mesh-gradient CSS background (4 radial blobs over a base colour) (9.3). */
|
|
25
|
+
function meshGradient(seed = 1, palette = 'sunset') {
|
|
26
|
+
const pal = Array.isArray(palette) ? palette : PALETTES[palette] || PALETTES.sunset;
|
|
27
|
+
const r = seededRandom(seed);
|
|
28
|
+
const blobs = [0, 1, 2, 3].map((i) => `radial-gradient(at ${Math.round(r() * 100)}% ${Math.round(r() * 100)}%, ${pal[(i + 1) % pal.length]} 0px, transparent ${45 + Math.round(r() * 20)}%)`);
|
|
29
|
+
return `${blobs.join(', ')}, ${pal[0]}`;
|
|
30
|
+
}
|
|
31
|
+
const overlay = (el, ctx) => {
|
|
32
|
+
if (getComputedStyle(el).position === 'static') {
|
|
33
|
+
const prev = el.style.position;
|
|
34
|
+
el.style.position = 'relative';
|
|
35
|
+
ctx.onCleanup(() => (el.style.position = prev));
|
|
36
|
+
}
|
|
37
|
+
const o = document.createElement('span');
|
|
38
|
+
o.setAttribute('aria-hidden', 'true');
|
|
39
|
+
Object.assign(o.style, { position: 'absolute', inset: '0', pointerEvents: 'none', borderRadius: 'inherit', overflow: 'hidden' });
|
|
40
|
+
el.appendChild(o);
|
|
41
|
+
ctx.onCleanup(() => o.remove());
|
|
42
|
+
return o;
|
|
43
|
+
};
|
|
44
|
+
const GRAIN = "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E\")";
|
|
45
|
+
const GENART_FX = [
|
|
46
|
+
{
|
|
47
|
+
name: 'halftone-in',
|
|
48
|
+
kind: 'enter',
|
|
49
|
+
description: 'The element prints in through a growing halftone dot screen (`dot` px).',
|
|
50
|
+
defaults: { dot: 10, duration: 1100 },
|
|
51
|
+
run: (el, o, ctx) => {
|
|
52
|
+
if (ctx.reduced)
|
|
53
|
+
return ctx.animate(el, [{ opacity: 0 }, { opacity: 1 }], { duration: 300 })?.finished.catch(() => undefined);
|
|
54
|
+
const d = Math.max(4, Math.min(40, Number(o.dot) || 10));
|
|
55
|
+
const m = (r) => `radial-gradient(circle, #000 ${r}px, transparent ${r + 0.5}px) 0 0 / ${d}px ${d}px`;
|
|
56
|
+
const prev = [el.style.maskImage, el.style.webkitMaskImage];
|
|
57
|
+
ctx.onCleanup(() => {
|
|
58
|
+
el.style.maskImage = prev[0];
|
|
59
|
+
el.style.webkitMaskImage = prev[1];
|
|
60
|
+
});
|
|
61
|
+
const a = ctx.animate(el, [0, 0.15, 0.3, 0.45, 0.6, 0.75].map((f, i, all) => ({ mask: m(f * d), WebkitMask: m(f * d), offset: i / all.length })).concat([{ mask: m(d), WebkitMask: m(d), offset: 1 }]), { duration: o.duration, delay: o.delay, easing: 'steps(6, end)', fill: 'backwards' });
|
|
62
|
+
return a?.finished.catch(() => undefined);
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'mesh-drift',
|
|
67
|
+
kind: 'loop',
|
|
68
|
+
description: 'A seeded mesh-gradient background that slowly drifts (`seed`, `palette`).',
|
|
69
|
+
defaults: { seed: 3, palette: 'sunset', duration: 14000 },
|
|
70
|
+
run: (el, o, ctx) => {
|
|
71
|
+
if (ctx.reduced)
|
|
72
|
+
return;
|
|
73
|
+
const ov = overlay(el, ctx);
|
|
74
|
+
ov.style.zIndex = '-1';
|
|
75
|
+
ov.style.background = meshGradient(Number(o.seed) || 3, o.palette);
|
|
76
|
+
ov.style.backgroundSize = '200% 200%';
|
|
77
|
+
if (getComputedStyle(el).isolation !== 'isolate') {
|
|
78
|
+
const prev = el.style.isolation;
|
|
79
|
+
el.style.isolation = 'isolate';
|
|
80
|
+
ctx.onCleanup(() => (el.style.isolation = prev));
|
|
81
|
+
}
|
|
82
|
+
const a = ctx.animate(ov, [{ backgroundPosition: '0% 0%', filter: 'hue-rotate(0deg)' }, { backgroundPosition: '100% 60%', filter: 'hue-rotate(25deg)' }, { backgroundPosition: '0% 0%', filter: 'hue-rotate(0deg)' }], { duration: o.duration, iterations: Infinity, easing: 'ease-in-out' });
|
|
83
|
+
return () => {
|
|
84
|
+
a?.cancel();
|
|
85
|
+
ov.remove();
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: 'kaleido',
|
|
91
|
+
kind: 'loop',
|
|
92
|
+
description: 'A kaleidoscopic conic overlay that turns slowly (`color`, `segments`).',
|
|
93
|
+
defaults: { color: 'rgba(255,255,255,.35)', segments: 12, duration: 12000 },
|
|
94
|
+
run: (el, o, ctx) => {
|
|
95
|
+
if (ctx.reduced)
|
|
96
|
+
return;
|
|
97
|
+
const ov = overlay(el, ctx);
|
|
98
|
+
const n = Math.max(4, Math.min(36, Math.round(Number(o.segments) || 12)));
|
|
99
|
+
const inner = document.createElement('i');
|
|
100
|
+
Object.assign(inner.style, { position: 'absolute', left: '-50%', top: '-50%', width: '200%', height: '200%', background: `repeating-conic-gradient(${o.color} 0 ${180 / n}deg, transparent ${180 / n}deg ${360 / n}deg)`, mixBlendMode: 'overlay' });
|
|
101
|
+
ov.appendChild(inner);
|
|
102
|
+
const a = ctx.animate(inner, [{ transform: 'rotate(0)' }, { transform: 'rotate(360deg)' }], { duration: o.duration, iterations: Infinity, easing: 'linear' });
|
|
103
|
+
return () => {
|
|
104
|
+
a?.cancel();
|
|
105
|
+
ov.remove();
|
|
106
|
+
};
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: 'grain-flicker',
|
|
111
|
+
kind: 'loop',
|
|
112
|
+
description: 'Animated film grain over the element (`opacity`).',
|
|
113
|
+
defaults: { opacity: 0.25 },
|
|
114
|
+
run: (el, o, ctx) => {
|
|
115
|
+
if (ctx.reduced)
|
|
116
|
+
return;
|
|
117
|
+
const ov = overlay(el, ctx);
|
|
118
|
+
Object.assign(ov.style, { backgroundImage: GRAIN, opacity: String(o.opacity), mixBlendMode: 'overlay' });
|
|
119
|
+
const a = ctx.animate(ov, [0, 1, 2, 3, 4, 5].map((i) => ({ backgroundPosition: `${(i * 37) % 160}px ${(i * 71) % 160}px` })), { duration: 600, iterations: Infinity, easing: 'steps(6, end)' });
|
|
120
|
+
return () => {
|
|
121
|
+
a?.cancel();
|
|
122
|
+
ov.remove();
|
|
123
|
+
};
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
];
|
|
127
|
+
/** Register halftone-in, mesh-drift, kaleido and grain-flicker (9.3). */
|
|
128
|
+
function registerGenArtPack() {
|
|
129
|
+
registry.registerEffects(GENART_FX);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
exports.GENART_FX = GENART_FX;
|
|
133
|
+
exports.PALETTES = PALETTES;
|
|
134
|
+
exports.meshGradient = meshGradient;
|
|
135
|
+
exports.registerGenArtPack = registerGenArtPack;
|
|
136
|
+
exports.seededRandom = seededRandom;
|
|
137
|
+
//# sourceMappingURL=fx-genart.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fx-genart.cjs","sources":["../../src/components/fx2/genart.ts"],"sourcesContent":["/**\n * 9.3 — Generative art 2.0 pack (`motionary/fx/genart`, also `motionary/components/fx-genart`):\n *\n * - `halftone-in` (enter) — the element prints in through a growing\n * halftone dot screen, like a comic-book plate (`dot`).\n * - `mesh-drift` (loop) — a seeded mesh-gradient background that slowly\n * drifts (`seed`, `palette`).\n * - `kaleido` (loop) — a kaleidoscopic conic overlay that turns slowly\n * (`color`, `segments`).\n * - `grain-flicker` (loop) — animated film grain over the element.\n *\n * `PALETTES`, `seededRandom(seed)`, `meshGradient(seed, palette)` (a CSS\n * background string) are shared with `<usa-bg-generator>` and\n * `<usa-gen-art>`. Reduced motion: halftone-in fades, loops are skipped.\n */\nimport type { EffectContext, EffectDefinition } from '../fx/registry';\nimport { registerEffects } from '../fx/registry';\n\nexport const PALETTES: Record<string, string[]> = {\n sunset: ['#ff6b6b', '#feca57', '#ff9ff3', '#5f27cd', '#1dd1a1'],\n ocean: ['#0abde3', '#48dbfb', '#c8d6e5', '#10ac84', '#222f3e'],\n forest: ['#2d6a4f', '#52b788', '#95d5b2', '#d8f3dc', '#081c15'],\n candy: ['#f72585', '#b5179e', '#7209b7', '#4361ee', '#4cc9f0'],\n mono: ['#111827', '#374151', '#6b7280', '#d1d5db', '#f9fafb'],\n};\n\n/** Deterministic PRNG in [0, 1) (mulberry32) (9.3). */\nexport function seededRandom(seed: number): () => number {\n let a = (Math.floor(Math.abs(seed) * 1e3) >>> 0) || 1;\n return () => {\n a = (a + 0x6d2b79f5) >>> 0;\n let t = a;\n t = Math.imul(t ^ (t >>> 15), t | 1);\n t ^= t + Math.imul(t ^ (t >>> 7), t | 61);\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n };\n}\n\n/** A seeded mesh-gradient CSS background (4 radial blobs over a base colour) (9.3). */\nexport function meshGradient(seed = 1, palette: string | string[] = 'sunset'): string {\n const pal = Array.isArray(palette) ? palette : PALETTES[palette] || PALETTES.sunset;\n const r = seededRandom(seed);\n const blobs = [0, 1, 2, 3].map((i) => `radial-gradient(at ${Math.round(r() * 100)}% ${Math.round(r() * 100)}%, ${pal[(i + 1) % pal.length]} 0px, transparent ${45 + Math.round(r() * 20)}%)`);\n return `${blobs.join(', ')}, ${pal[0]}`;\n}\n\nconst overlay = (el: HTMLElement, ctx: EffectContext) => {\n if (getComputedStyle(el).position === 'static') {\n const prev = el.style.position;\n el.style.position = 'relative';\n ctx.onCleanup(() => (el.style.position = prev));\n }\n const o = document.createElement('span');\n o.setAttribute('aria-hidden', 'true');\n Object.assign(o.style, { position: 'absolute', inset: '0', pointerEvents: 'none', borderRadius: 'inherit', overflow: 'hidden' });\n el.appendChild(o);\n ctx.onCleanup(() => o.remove());\n return o;\n};\nconst GRAIN = \"url(\\\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E\\\")\";\n\nexport const GENART_FX: EffectDefinition[] = [\n {\n name: 'halftone-in',\n kind: 'enter',\n description: 'The element prints in through a growing halftone dot screen (`dot` px).',\n defaults: { dot: 10, duration: 1100 },\n run: (el: HTMLElement, o: any, ctx: EffectContext) => {\n if (ctx.reduced) return ctx.animate(el, [{ opacity: 0 }, { opacity: 1 }], { duration: 300 })?.finished.catch(() => undefined);\n const d = Math.max(4, Math.min(40, Number(o.dot) || 10));\n const m = (r: number) => `radial-gradient(circle, #000 ${r}px, transparent ${r + 0.5}px) 0 0 / ${d}px ${d}px`;\n const prev = [el.style.maskImage, (el.style as any).webkitMaskImage];\n ctx.onCleanup(() => {\n el.style.maskImage = prev[0];\n (el.style as any).webkitMaskImage = prev[1];\n });\n const a = ctx.animate(el, [0, 0.15, 0.3, 0.45, 0.6, 0.75].map((f, i, all) => ({ mask: m(f * d), WebkitMask: m(f * d), offset: i / all.length })).concat([{ mask: m(d), WebkitMask: m(d), offset: 1 } as any]) as Keyframe[], { duration: o.duration, delay: o.delay, easing: 'steps(6, end)', fill: 'backwards' });\n return a?.finished.catch(() => undefined);\n },\n },\n {\n name: 'mesh-drift',\n kind: 'loop',\n description: 'A seeded mesh-gradient background that slowly drifts (`seed`, `palette`).',\n defaults: { seed: 3, palette: 'sunset', duration: 14000 },\n run: (el: HTMLElement, o: any, ctx: EffectContext) => {\n if (ctx.reduced) return;\n const ov = overlay(el, ctx);\n ov.style.zIndex = '-1';\n ov.style.background = meshGradient(Number(o.seed) || 3, o.palette);\n ov.style.backgroundSize = '200% 200%';\n if (getComputedStyle(el).isolation !== 'isolate') {\n const prev = el.style.isolation;\n el.style.isolation = 'isolate';\n ctx.onCleanup(() => (el.style.isolation = prev));\n }\n const a = ctx.animate(ov, [{ backgroundPosition: '0% 0%', filter: 'hue-rotate(0deg)' }, { backgroundPosition: '100% 60%', filter: 'hue-rotate(25deg)' }, { backgroundPosition: '0% 0%', filter: 'hue-rotate(0deg)' }], { duration: o.duration, iterations: Infinity, easing: 'ease-in-out' });\n return () => {\n a?.cancel();\n ov.remove();\n };\n },\n },\n {\n name: 'kaleido',\n kind: 'loop',\n description: 'A kaleidoscopic conic overlay that turns slowly (`color`, `segments`).',\n defaults: { color: 'rgba(255,255,255,.35)', segments: 12, duration: 12000 },\n run: (el: HTMLElement, o: any, ctx: EffectContext) => {\n if (ctx.reduced) return;\n const ov = overlay(el, ctx);\n const n = Math.max(4, Math.min(36, Math.round(Number(o.segments) || 12)));\n const inner = document.createElement('i');\n Object.assign(inner.style, { position: 'absolute', left: '-50%', top: '-50%', width: '200%', height: '200%', background: `repeating-conic-gradient(${o.color} 0 ${180 / n}deg, transparent ${180 / n}deg ${360 / n}deg)`, mixBlendMode: 'overlay' });\n ov.appendChild(inner);\n const a = ctx.animate(inner, [{ transform: 'rotate(0)' }, { transform: 'rotate(360deg)' }], { duration: o.duration, iterations: Infinity, easing: 'linear' });\n return () => {\n a?.cancel();\n ov.remove();\n };\n },\n },\n {\n name: 'grain-flicker',\n kind: 'loop',\n description: 'Animated film grain over the element (`opacity`).',\n defaults: { opacity: 0.25 },\n run: (el: HTMLElement, o: any, ctx: EffectContext) => {\n if (ctx.reduced) return;\n const ov = overlay(el, ctx);\n Object.assign(ov.style, { backgroundImage: GRAIN, opacity: String(o.opacity), mixBlendMode: 'overlay' });\n const a = ctx.animate(ov, [0, 1, 2, 3, 4, 5].map((i) => ({ backgroundPosition: `${(i * 37) % 160}px ${(i * 71) % 160}px` })), { duration: 600, iterations: Infinity, easing: 'steps(6, end)' });\n return () => {\n a?.cancel();\n ov.remove();\n };\n },\n },\n];\n\n/** Register halftone-in, mesh-drift, kaleido and grain-flicker (9.3). */\nexport function registerGenArtPack(): void {\n registerEffects(GENART_FX);\n}\n"],"names":["registerEffects"],"mappings":";;;;;AAkBO,MAAM,QAAQ,GAA6B;IAChD,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC;IAC/D,KAAK,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC;IAC9D,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC;IAC/D,KAAK,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC;IAC9D,IAAI,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC;;AAG/D;AACM,SAAU,YAAY,CAAC,IAAY,EAAA;IACvC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC;AACrD,IAAA,OAAO,MAAK;QACV,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU,MAAM,CAAC;QAC1B,IAAI,CAAC,GAAG,CAAC;AACT,QAAA,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;AACpC,QAAA,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC;AACzC,QAAA,OAAO,CAAC,CAAC,CAAC,IAAI,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MAAM,EAAE,eAAe,EAAE,CAAC;AAC/L,YAAA,OAAO,MAAK;gBACV,CAAC,EAAE,MAAM,EAAE;gBACX,EAAE,CAAC,MAAM,EAAE;AACb,YAAA,CAAC;QACH,CAAC;AACF,KAAA;;AAGH;SACgB,kBAAkB,GAAA;IAChCA,wBAAe,CAAC,SAAS,CAAC;AAC5B;;;;;;;;"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
type MotionSensitivity = 'full' | 'gentle' | 'minimal' | 'static';
|
|
2
|
+
type Cleanup = () => void;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 5.0 — unified plugin-style effect registration. Every effect (built-in or
|
|
6
|
+
* yours) is a plain object registered once and played the same way:
|
|
7
|
+
* `playEffect(el, name)`, `bindEffect(el, name, { trigger })` or
|
|
8
|
+
* `<usa-fx effect="name" trigger="click">`. Effects get a context that
|
|
9
|
+
* already applies reduced motion, motion sensitivity, intensity and the
|
|
10
|
+
* animation budget.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
declare const EFFECT_KINDS: readonly ["enter", "exit", "attention", "click", "hover", "card", "loop", "page", "background", "text", "cursor", "scroll"];
|
|
14
|
+
type EffectKind = (typeof EFFECT_KINDS)[number];
|
|
15
|
+
interface EffectContext {
|
|
16
|
+
/** Reduced motion applies (OS setting, `minimal` / `static` sensitivity). */
|
|
17
|
+
readonly reduced: boolean;
|
|
18
|
+
readonly sensitivity: MotionSensitivity;
|
|
19
|
+
/** The triggering event (pointer position for click effects), if any. */
|
|
20
|
+
readonly event?: Event;
|
|
21
|
+
/** `el.animate()` with the library's motion rules (may return `null`). */
|
|
22
|
+
animate(el: Element, keyframes: Keyframe[], options: KeyframeAnimationOptions): Animation | null;
|
|
23
|
+
/** Register teardown for long-running effects (loops, listeners). */
|
|
24
|
+
onCleanup(fn: Cleanup): void;
|
|
25
|
+
}
|
|
26
|
+
interface EffectDefinition<O extends Record<string, unknown> = Record<string, any>> {
|
|
27
|
+
/** Unique, kebab-case. */
|
|
28
|
+
name: string;
|
|
29
|
+
kind: EffectKind;
|
|
30
|
+
/** One line for docs and the gallery. */
|
|
31
|
+
description?: string;
|
|
32
|
+
/** Option defaults (merged under the caller's options). */
|
|
33
|
+
defaults?: Partial<O>;
|
|
34
|
+
/**
|
|
35
|
+
* Under reduced motion: `'skip'` (do nothing — default for loop, background
|
|
36
|
+
* and cursor effects) or `'run'` (run with `ctx.reduced === true`, the
|
|
37
|
+
* effect degrades itself — default for everything else).
|
|
38
|
+
*/
|
|
39
|
+
reduced?: 'skip' | 'run';
|
|
40
|
+
/** Play the effect. Return an Animation / Promise to be awaited, or a cleanup. */
|
|
41
|
+
run(el: HTMLElement, options: O, ctx: EffectContext): void | Cleanup | Animation | null | Promise<unknown>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 9.3 — Generative art 2.0 pack (`motionary/fx/genart`, also `motionary/components/fx-genart`):
|
|
46
|
+
*
|
|
47
|
+
* - `halftone-in` (enter) — the element prints in through a growing
|
|
48
|
+
* halftone dot screen, like a comic-book plate (`dot`).
|
|
49
|
+
* - `mesh-drift` (loop) — a seeded mesh-gradient background that slowly
|
|
50
|
+
* drifts (`seed`, `palette`).
|
|
51
|
+
* - `kaleido` (loop) — a kaleidoscopic conic overlay that turns slowly
|
|
52
|
+
* (`color`, `segments`).
|
|
53
|
+
* - `grain-flicker` (loop) — animated film grain over the element.
|
|
54
|
+
*
|
|
55
|
+
* `PALETTES`, `seededRandom(seed)`, `meshGradient(seed, palette)` (a CSS
|
|
56
|
+
* background string) are shared with `<usa-bg-generator>` and
|
|
57
|
+
* `<usa-gen-art>`. Reduced motion: halftone-in fades, loops are skipped.
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
declare const PALETTES: Record<string, string[]>;
|
|
61
|
+
/** Deterministic PRNG in [0, 1) (mulberry32) (9.3). */
|
|
62
|
+
declare function seededRandom(seed: number): () => number;
|
|
63
|
+
/** A seeded mesh-gradient CSS background (4 radial blobs over a base colour) (9.3). */
|
|
64
|
+
declare function meshGradient(seed?: number, palette?: string | string[]): string;
|
|
65
|
+
declare const GENART_FX: EffectDefinition[];
|
|
66
|
+
/** Register halftone-in, mesh-drift, kaleido and grain-flicker (9.3). */
|
|
67
|
+
declare function registerGenArtPack(): void;
|
|
68
|
+
|
|
69
|
+
export { GENART_FX, PALETTES, meshGradient, registerGenArtPack, seededRandom };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
type MotionSensitivity = 'full' | 'gentle' | 'minimal' | 'static';
|
|
2
|
+
type Cleanup = () => void;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 5.0 — unified plugin-style effect registration. Every effect (built-in or
|
|
6
|
+
* yours) is a plain object registered once and played the same way:
|
|
7
|
+
* `playEffect(el, name)`, `bindEffect(el, name, { trigger })` or
|
|
8
|
+
* `<usa-fx effect="name" trigger="click">`. Effects get a context that
|
|
9
|
+
* already applies reduced motion, motion sensitivity, intensity and the
|
|
10
|
+
* animation budget.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
declare const EFFECT_KINDS: readonly ["enter", "exit", "attention", "click", "hover", "card", "loop", "page", "background", "text", "cursor", "scroll"];
|
|
14
|
+
type EffectKind = (typeof EFFECT_KINDS)[number];
|
|
15
|
+
interface EffectContext {
|
|
16
|
+
/** Reduced motion applies (OS setting, `minimal` / `static` sensitivity). */
|
|
17
|
+
readonly reduced: boolean;
|
|
18
|
+
readonly sensitivity: MotionSensitivity;
|
|
19
|
+
/** The triggering event (pointer position for click effects), if any. */
|
|
20
|
+
readonly event?: Event;
|
|
21
|
+
/** `el.animate()` with the library's motion rules (may return `null`). */
|
|
22
|
+
animate(el: Element, keyframes: Keyframe[], options: KeyframeAnimationOptions): Animation | null;
|
|
23
|
+
/** Register teardown for long-running effects (loops, listeners). */
|
|
24
|
+
onCleanup(fn: Cleanup): void;
|
|
25
|
+
}
|
|
26
|
+
interface EffectDefinition<O extends Record<string, unknown> = Record<string, any>> {
|
|
27
|
+
/** Unique, kebab-case. */
|
|
28
|
+
name: string;
|
|
29
|
+
kind: EffectKind;
|
|
30
|
+
/** One line for docs and the gallery. */
|
|
31
|
+
description?: string;
|
|
32
|
+
/** Option defaults (merged under the caller's options). */
|
|
33
|
+
defaults?: Partial<O>;
|
|
34
|
+
/**
|
|
35
|
+
* Under reduced motion: `'skip'` (do nothing — default for loop, background
|
|
36
|
+
* and cursor effects) or `'run'` (run with `ctx.reduced === true`, the
|
|
37
|
+
* effect degrades itself — default for everything else).
|
|
38
|
+
*/
|
|
39
|
+
reduced?: 'skip' | 'run';
|
|
40
|
+
/** Play the effect. Return an Animation / Promise to be awaited, or a cleanup. */
|
|
41
|
+
run(el: HTMLElement, options: O, ctx: EffectContext): void | Cleanup | Animation | null | Promise<unknown>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 9.3 — Generative art 2.0 pack (`motionary/fx/genart`, also `motionary/components/fx-genart`):
|
|
46
|
+
*
|
|
47
|
+
* - `halftone-in` (enter) — the element prints in through a growing
|
|
48
|
+
* halftone dot screen, like a comic-book plate (`dot`).
|
|
49
|
+
* - `mesh-drift` (loop) — a seeded mesh-gradient background that slowly
|
|
50
|
+
* drifts (`seed`, `palette`).
|
|
51
|
+
* - `kaleido` (loop) — a kaleidoscopic conic overlay that turns slowly
|
|
52
|
+
* (`color`, `segments`).
|
|
53
|
+
* - `grain-flicker` (loop) — animated film grain over the element.
|
|
54
|
+
*
|
|
55
|
+
* `PALETTES`, `seededRandom(seed)`, `meshGradient(seed, palette)` (a CSS
|
|
56
|
+
* background string) are shared with `<usa-bg-generator>` and
|
|
57
|
+
* `<usa-gen-art>`. Reduced motion: halftone-in fades, loops are skipped.
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
declare const PALETTES: Record<string, string[]>;
|
|
61
|
+
/** Deterministic PRNG in [0, 1) (mulberry32) (9.3). */
|
|
62
|
+
declare function seededRandom(seed: number): () => number;
|
|
63
|
+
/** A seeded mesh-gradient CSS background (4 radial blobs over a base colour) (9.3). */
|
|
64
|
+
declare function meshGradient(seed?: number, palette?: string | string[]): string;
|
|
65
|
+
declare const GENART_FX: EffectDefinition[];
|
|
66
|
+
/** Register halftone-in, mesh-drift, kaleido and grain-flicker (9.3). */
|
|
67
|
+
declare function registerGenArtPack(): void;
|
|
68
|
+
|
|
69
|
+
export { GENART_FX, PALETTES, meshGradient, registerGenArtPack, seededRandom };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { registerEffects } from '../chunks/registry-CnO7ZVPK.js';
|
|
2
|
+
import '../chunks/base-CLuqlLfG.js';
|
|
3
|
+
|
|
4
|
+
const PALETTES = {
|
|
5
|
+
sunset: ['#ff6b6b', '#feca57', '#ff9ff3', '#5f27cd', '#1dd1a1'],
|
|
6
|
+
ocean: ['#0abde3', '#48dbfb', '#c8d6e5', '#10ac84', '#222f3e'],
|
|
7
|
+
forest: ['#2d6a4f', '#52b788', '#95d5b2', '#d8f3dc', '#081c15'],
|
|
8
|
+
candy: ['#f72585', '#b5179e', '#7209b7', '#4361ee', '#4cc9f0'],
|
|
9
|
+
mono: ['#111827', '#374151', '#6b7280', '#d1d5db', '#f9fafb'],
|
|
10
|
+
};
|
|
11
|
+
/** Deterministic PRNG in [0, 1) (mulberry32) (9.3). */
|
|
12
|
+
function seededRandom(seed) {
|
|
13
|
+
let a = (Math.floor(Math.abs(seed) * 1e3) >>> 0) || 1;
|
|
14
|
+
return () => {
|
|
15
|
+
a = (a + 0x6d2b79f5) >>> 0;
|
|
16
|
+
let t = a;
|
|
17
|
+
t = Math.imul(t ^ (t >>> 15), t | 1);
|
|
18
|
+
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
|
19
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/** A seeded mesh-gradient CSS background (4 radial blobs over a base colour) (9.3). */
|
|
23
|
+
function meshGradient(seed = 1, palette = 'sunset') {
|
|
24
|
+
const pal = Array.isArray(palette) ? palette : PALETTES[palette] || PALETTES.sunset;
|
|
25
|
+
const r = seededRandom(seed);
|
|
26
|
+
const blobs = [0, 1, 2, 3].map((i) => `radial-gradient(at ${Math.round(r() * 100)}% ${Math.round(r() * 100)}%, ${pal[(i + 1) % pal.length]} 0px, transparent ${45 + Math.round(r() * 20)}%)`);
|
|
27
|
+
return `${blobs.join(', ')}, ${pal[0]}`;
|
|
28
|
+
}
|
|
29
|
+
const overlay = (el, ctx) => {
|
|
30
|
+
if (getComputedStyle(el).position === 'static') {
|
|
31
|
+
const prev = el.style.position;
|
|
32
|
+
el.style.position = 'relative';
|
|
33
|
+
ctx.onCleanup(() => (el.style.position = prev));
|
|
34
|
+
}
|
|
35
|
+
const o = document.createElement('span');
|
|
36
|
+
o.setAttribute('aria-hidden', 'true');
|
|
37
|
+
Object.assign(o.style, { position: 'absolute', inset: '0', pointerEvents: 'none', borderRadius: 'inherit', overflow: 'hidden' });
|
|
38
|
+
el.appendChild(o);
|
|
39
|
+
ctx.onCleanup(() => o.remove());
|
|
40
|
+
return o;
|
|
41
|
+
};
|
|
42
|
+
const GRAIN = "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E\")";
|
|
43
|
+
const GENART_FX = [
|
|
44
|
+
{
|
|
45
|
+
name: 'halftone-in',
|
|
46
|
+
kind: 'enter',
|
|
47
|
+
description: 'The element prints in through a growing halftone dot screen (`dot` px).',
|
|
48
|
+
defaults: { dot: 10, duration: 1100 },
|
|
49
|
+
run: (el, o, ctx) => {
|
|
50
|
+
if (ctx.reduced)
|
|
51
|
+
return ctx.animate(el, [{ opacity: 0 }, { opacity: 1 }], { duration: 300 })?.finished.catch(() => undefined);
|
|
52
|
+
const d = Math.max(4, Math.min(40, Number(o.dot) || 10));
|
|
53
|
+
const m = (r) => `radial-gradient(circle, #000 ${r}px, transparent ${r + 0.5}px) 0 0 / ${d}px ${d}px`;
|
|
54
|
+
const prev = [el.style.maskImage, el.style.webkitMaskImage];
|
|
55
|
+
ctx.onCleanup(() => {
|
|
56
|
+
el.style.maskImage = prev[0];
|
|
57
|
+
el.style.webkitMaskImage = prev[1];
|
|
58
|
+
});
|
|
59
|
+
const a = ctx.animate(el, [0, 0.15, 0.3, 0.45, 0.6, 0.75].map((f, i, all) => ({ mask: m(f * d), WebkitMask: m(f * d), offset: i / all.length })).concat([{ mask: m(d), WebkitMask: m(d), offset: 1 }]), { duration: o.duration, delay: o.delay, easing: 'steps(6, end)', fill: 'backwards' });
|
|
60
|
+
return a?.finished.catch(() => undefined);
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'mesh-drift',
|
|
65
|
+
kind: 'loop',
|
|
66
|
+
description: 'A seeded mesh-gradient background that slowly drifts (`seed`, `palette`).',
|
|
67
|
+
defaults: { seed: 3, palette: 'sunset', duration: 14000 },
|
|
68
|
+
run: (el, o, ctx) => {
|
|
69
|
+
if (ctx.reduced)
|
|
70
|
+
return;
|
|
71
|
+
const ov = overlay(el, ctx);
|
|
72
|
+
ov.style.zIndex = '-1';
|
|
73
|
+
ov.style.background = meshGradient(Number(o.seed) || 3, o.palette);
|
|
74
|
+
ov.style.backgroundSize = '200% 200%';
|
|
75
|
+
if (getComputedStyle(el).isolation !== 'isolate') {
|
|
76
|
+
const prev = el.style.isolation;
|
|
77
|
+
el.style.isolation = 'isolate';
|
|
78
|
+
ctx.onCleanup(() => (el.style.isolation = prev));
|
|
79
|
+
}
|
|
80
|
+
const a = ctx.animate(ov, [{ backgroundPosition: '0% 0%', filter: 'hue-rotate(0deg)' }, { backgroundPosition: '100% 60%', filter: 'hue-rotate(25deg)' }, { backgroundPosition: '0% 0%', filter: 'hue-rotate(0deg)' }], { duration: o.duration, iterations: Infinity, easing: 'ease-in-out' });
|
|
81
|
+
return () => {
|
|
82
|
+
a?.cancel();
|
|
83
|
+
ov.remove();
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: 'kaleido',
|
|
89
|
+
kind: 'loop',
|
|
90
|
+
description: 'A kaleidoscopic conic overlay that turns slowly (`color`, `segments`).',
|
|
91
|
+
defaults: { color: 'rgba(255,255,255,.35)', segments: 12, duration: 12000 },
|
|
92
|
+
run: (el, o, ctx) => {
|
|
93
|
+
if (ctx.reduced)
|
|
94
|
+
return;
|
|
95
|
+
const ov = overlay(el, ctx);
|
|
96
|
+
const n = Math.max(4, Math.min(36, Math.round(Number(o.segments) || 12)));
|
|
97
|
+
const inner = document.createElement('i');
|
|
98
|
+
Object.assign(inner.style, { position: 'absolute', left: '-50%', top: '-50%', width: '200%', height: '200%', background: `repeating-conic-gradient(${o.color} 0 ${180 / n}deg, transparent ${180 / n}deg ${360 / n}deg)`, mixBlendMode: 'overlay' });
|
|
99
|
+
ov.appendChild(inner);
|
|
100
|
+
const a = ctx.animate(inner, [{ transform: 'rotate(0)' }, { transform: 'rotate(360deg)' }], { duration: o.duration, iterations: Infinity, easing: 'linear' });
|
|
101
|
+
return () => {
|
|
102
|
+
a?.cancel();
|
|
103
|
+
ov.remove();
|
|
104
|
+
};
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: 'grain-flicker',
|
|
109
|
+
kind: 'loop',
|
|
110
|
+
description: 'Animated film grain over the element (`opacity`).',
|
|
111
|
+
defaults: { opacity: 0.25 },
|
|
112
|
+
run: (el, o, ctx) => {
|
|
113
|
+
if (ctx.reduced)
|
|
114
|
+
return;
|
|
115
|
+
const ov = overlay(el, ctx);
|
|
116
|
+
Object.assign(ov.style, { backgroundImage: GRAIN, opacity: String(o.opacity), mixBlendMode: 'overlay' });
|
|
117
|
+
const a = ctx.animate(ov, [0, 1, 2, 3, 4, 5].map((i) => ({ backgroundPosition: `${(i * 37) % 160}px ${(i * 71) % 160}px` })), { duration: 600, iterations: Infinity, easing: 'steps(6, end)' });
|
|
118
|
+
return () => {
|
|
119
|
+
a?.cancel();
|
|
120
|
+
ov.remove();
|
|
121
|
+
};
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
];
|
|
125
|
+
/** Register halftone-in, mesh-drift, kaleido and grain-flicker (9.3). */
|
|
126
|
+
function registerGenArtPack() {
|
|
127
|
+
registerEffects(GENART_FX);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export { GENART_FX, PALETTES, meshGradient, registerGenArtPack, seededRandom };
|
|
131
|
+
//# sourceMappingURL=fx-genart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fx-genart.js","sources":["../../src/components/fx2/genart.ts"],"sourcesContent":["/**\n * 9.3 — Generative art 2.0 pack (`motionary/fx/genart`, also `motionary/components/fx-genart`):\n *\n * - `halftone-in` (enter) — the element prints in through a growing\n * halftone dot screen, like a comic-book plate (`dot`).\n * - `mesh-drift` (loop) — a seeded mesh-gradient background that slowly\n * drifts (`seed`, `palette`).\n * - `kaleido` (loop) — a kaleidoscopic conic overlay that turns slowly\n * (`color`, `segments`).\n * - `grain-flicker` (loop) — animated film grain over the element.\n *\n * `PALETTES`, `seededRandom(seed)`, `meshGradient(seed, palette)` (a CSS\n * background string) are shared with `<usa-bg-generator>` and\n * `<usa-gen-art>`. Reduced motion: halftone-in fades, loops are skipped.\n */\nimport type { EffectContext, EffectDefinition } from '../fx/registry';\nimport { registerEffects } from '../fx/registry';\n\nexport const PALETTES: Record<string, string[]> = {\n sunset: ['#ff6b6b', '#feca57', '#ff9ff3', '#5f27cd', '#1dd1a1'],\n ocean: ['#0abde3', '#48dbfb', '#c8d6e5', '#10ac84', '#222f3e'],\n forest: ['#2d6a4f', '#52b788', '#95d5b2', '#d8f3dc', '#081c15'],\n candy: ['#f72585', '#b5179e', '#7209b7', '#4361ee', '#4cc9f0'],\n mono: ['#111827', '#374151', '#6b7280', '#d1d5db', '#f9fafb'],\n};\n\n/** Deterministic PRNG in [0, 1) (mulberry32) (9.3). */\nexport function seededRandom(seed: number): () => number {\n let a = (Math.floor(Math.abs(seed) * 1e3) >>> 0) || 1;\n return () => {\n a = (a + 0x6d2b79f5) >>> 0;\n let t = a;\n t = Math.imul(t ^ (t >>> 15), t | 1);\n t ^= t + Math.imul(t ^ (t >>> 7), t | 61);\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n };\n}\n\n/** A seeded mesh-gradient CSS background (4 radial blobs over a base colour) (9.3). */\nexport function meshGradient(seed = 1, palette: string | string[] = 'sunset'): string {\n const pal = Array.isArray(palette) ? palette : PALETTES[palette] || PALETTES.sunset;\n const r = seededRandom(seed);\n const blobs = [0, 1, 2, 3].map((i) => `radial-gradient(at ${Math.round(r() * 100)}% ${Math.round(r() * 100)}%, ${pal[(i + 1) % pal.length]} 0px, transparent ${45 + Math.round(r() * 20)}%)`);\n return `${blobs.join(', ')}, ${pal[0]}`;\n}\n\nconst overlay = (el: HTMLElement, ctx: EffectContext) => {\n if (getComputedStyle(el).position === 'static') {\n const prev = el.style.position;\n el.style.position = 'relative';\n ctx.onCleanup(() => (el.style.position = prev));\n }\n const o = document.createElement('span');\n o.setAttribute('aria-hidden', 'true');\n Object.assign(o.style, { position: 'absolute', inset: '0', pointerEvents: 'none', borderRadius: 'inherit', overflow: 'hidden' });\n el.appendChild(o);\n ctx.onCleanup(() => o.remove());\n return o;\n};\nconst GRAIN = \"url(\\\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E\\\")\";\n\nexport const GENART_FX: EffectDefinition[] = [\n {\n name: 'halftone-in',\n kind: 'enter',\n description: 'The element prints in through a growing halftone dot screen (`dot` px).',\n defaults: { dot: 10, duration: 1100 },\n run: (el: HTMLElement, o: any, ctx: EffectContext) => {\n if (ctx.reduced) return ctx.animate(el, [{ opacity: 0 }, { opacity: 1 }], { duration: 300 })?.finished.catch(() => undefined);\n const d = Math.max(4, Math.min(40, Number(o.dot) || 10));\n const m = (r: number) => `radial-gradient(circle, #000 ${r}px, transparent ${r + 0.5}px) 0 0 / ${d}px ${d}px`;\n const prev = [el.style.maskImage, (el.style as any).webkitMaskImage];\n ctx.onCleanup(() => {\n el.style.maskImage = prev[0];\n (el.style as any).webkitMaskImage = prev[1];\n });\n const a = ctx.animate(el, [0, 0.15, 0.3, 0.45, 0.6, 0.75].map((f, i, all) => ({ mask: m(f * d), WebkitMask: m(f * d), offset: i / all.length })).concat([{ mask: m(d), WebkitMask: m(d), offset: 1 } as any]) as Keyframe[], { duration: o.duration, delay: o.delay, easing: 'steps(6, end)', fill: 'backwards' });\n return a?.finished.catch(() => undefined);\n },\n },\n {\n name: 'mesh-drift',\n kind: 'loop',\n description: 'A seeded mesh-gradient background that slowly drifts (`seed`, `palette`).',\n defaults: { seed: 3, palette: 'sunset', duration: 14000 },\n run: (el: HTMLElement, o: any, ctx: EffectContext) => {\n if (ctx.reduced) return;\n const ov = overlay(el, ctx);\n ov.style.zIndex = '-1';\n ov.style.background = meshGradient(Number(o.seed) || 3, o.palette);\n ov.style.backgroundSize = '200% 200%';\n if (getComputedStyle(el).isolation !== 'isolate') {\n const prev = el.style.isolation;\n el.style.isolation = 'isolate';\n ctx.onCleanup(() => (el.style.isolation = prev));\n }\n const a = ctx.animate(ov, [{ backgroundPosition: '0% 0%', filter: 'hue-rotate(0deg)' }, { backgroundPosition: '100% 60%', filter: 'hue-rotate(25deg)' }, { backgroundPosition: '0% 0%', filter: 'hue-rotate(0deg)' }], { duration: o.duration, iterations: Infinity, easing: 'ease-in-out' });\n return () => {\n a?.cancel();\n ov.remove();\n };\n },\n },\n {\n name: 'kaleido',\n kind: 'loop',\n description: 'A kaleidoscopic conic overlay that turns slowly (`color`, `segments`).',\n defaults: { color: 'rgba(255,255,255,.35)', segments: 12, duration: 12000 },\n run: (el: HTMLElement, o: any, ctx: EffectContext) => {\n if (ctx.reduced) return;\n const ov = overlay(el, ctx);\n const n = Math.max(4, Math.min(36, Math.round(Number(o.segments) || 12)));\n const inner = document.createElement('i');\n Object.assign(inner.style, { position: 'absolute', left: '-50%', top: '-50%', width: '200%', height: '200%', background: `repeating-conic-gradient(${o.color} 0 ${180 / n}deg, transparent ${180 / n}deg ${360 / n}deg)`, mixBlendMode: 'overlay' });\n ov.appendChild(inner);\n const a = ctx.animate(inner, [{ transform: 'rotate(0)' }, { transform: 'rotate(360deg)' }], { duration: o.duration, iterations: Infinity, easing: 'linear' });\n return () => {\n a?.cancel();\n ov.remove();\n };\n },\n },\n {\n name: 'grain-flicker',\n kind: 'loop',\n description: 'Animated film grain over the element (`opacity`).',\n defaults: { opacity: 0.25 },\n run: (el: HTMLElement, o: any, ctx: EffectContext) => {\n if (ctx.reduced) return;\n const ov = overlay(el, ctx);\n Object.assign(ov.style, { backgroundImage: GRAIN, opacity: String(o.opacity), mixBlendMode: 'overlay' });\n const a = ctx.animate(ov, [0, 1, 2, 3, 4, 5].map((i) => ({ backgroundPosition: `${(i * 37) % 160}px ${(i * 71) % 160}px` })), { duration: 600, iterations: Infinity, easing: 'steps(6, end)' });\n return () => {\n a?.cancel();\n ov.remove();\n };\n },\n },\n];\n\n/** Register halftone-in, mesh-drift, kaleido and grain-flicker (9.3). */\nexport function registerGenArtPack(): void {\n registerEffects(GENART_FX);\n}\n"],"names":[],"mappings":";;;AAkBO,MAAM,QAAQ,GAA6B;IAChD,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC;IAC/D,KAAK,EAAE,CAAC,SAAS,EAAE,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-.cjs');
|
|
5
|
+
|
|
6
|
+
/** Scroll progress of `el` through the viewport: 0 entering at the bottom → 1 leaving at the top (9.4). */
|
|
7
|
+
function scrollProgress(el) {
|
|
8
|
+
const r = el.getBoundingClientRect();
|
|
9
|
+
const vh = (typeof innerHeight === 'number' && innerHeight) || 1;
|
|
10
|
+
return Math.min(1, Math.max(0, (vh - r.top) / (vh + r.height || 1)));
|
|
11
|
+
}
|
|
12
|
+
/** Scroll-driven video: `video.currentTime` follows the scroll progress of `trigger` (9.4). */
|
|
13
|
+
function scrubVideo(video, trigger = video, opts = {}) {
|
|
14
|
+
video.pause();
|
|
15
|
+
if (base.prefersReducedMotion())
|
|
16
|
+
return () => undefined;
|
|
17
|
+
const k = Math.min(1, Math.max(0.02, opts.ease ?? 0.15));
|
|
18
|
+
let cur = 0;
|
|
19
|
+
return base.onFrame(() => {
|
|
20
|
+
const d = video.duration;
|
|
21
|
+
if (!d || !Number.isFinite(d))
|
|
22
|
+
return;
|
|
23
|
+
const target = scrollProgress(trigger) * d;
|
|
24
|
+
cur += (target - cur) * k;
|
|
25
|
+
if (Math.abs(video.currentTime - cur) > 1 / 60)
|
|
26
|
+
video.currentTime = cur;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/** Image-sequence scrubbing on a canvas (preloads `src(i)`, or paints with `draw`) (9.4). */
|
|
30
|
+
function frameSequence(canvas, seq, trigger = canvas) {
|
|
31
|
+
const ctx = canvas.getContext?.('2d');
|
|
32
|
+
const n = Math.max(1, Math.floor(seq.count));
|
|
33
|
+
const imgs = [];
|
|
34
|
+
if (seq.src && typeof Image !== 'undefined')
|
|
35
|
+
for (let i = 0; i < n; i++) {
|
|
36
|
+
const im = new Image();
|
|
37
|
+
im.decoding = 'async';
|
|
38
|
+
im.src = seq.src(i);
|
|
39
|
+
imgs.push(im);
|
|
40
|
+
}
|
|
41
|
+
let last = -1;
|
|
42
|
+
const paint = (i) => {
|
|
43
|
+
if (!ctx || i === last)
|
|
44
|
+
return;
|
|
45
|
+
const w = canvas.width;
|
|
46
|
+
const h = canvas.height;
|
|
47
|
+
if (seq.draw) {
|
|
48
|
+
ctx.clearRect(0, 0, w, h);
|
|
49
|
+
seq.draw(ctx, i, w, h);
|
|
50
|
+
last = i;
|
|
51
|
+
}
|
|
52
|
+
else if (imgs[i]?.complete && imgs[i].naturalWidth) {
|
|
53
|
+
const im = imgs[i];
|
|
54
|
+
const s = Math.max(w / im.naturalWidth, h / im.naturalHeight);
|
|
55
|
+
ctx.drawImage(im, (w - im.naturalWidth * s) / 2, (h - im.naturalHeight * s) / 2, im.naturalWidth * s, im.naturalHeight * s);
|
|
56
|
+
last = i;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
paint(0);
|
|
60
|
+
if (base.prefersReducedMotion())
|
|
61
|
+
return () => undefined;
|
|
62
|
+
return base.onFrame(() => paint(Math.min(n - 1, Math.floor(scrollProgress(trigger) * n))));
|
|
63
|
+
}
|
|
64
|
+
const VIDEO_FX = [
|
|
65
|
+
{
|
|
66
|
+
name: 'film-burn',
|
|
67
|
+
kind: 'enter',
|
|
68
|
+
description: 'A warm light leak burns across as the element appears (`color`).',
|
|
69
|
+
defaults: { color: 'rgba(255,140,40,.85)', duration: 1300 },
|
|
70
|
+
run: (el, o, ctx) => {
|
|
71
|
+
if (ctx.reduced)
|
|
72
|
+
return ctx.animate(el, [{ opacity: 0 }, { opacity: 1 }], { duration: 300 })?.finished.catch(() => undefined);
|
|
73
|
+
if (getComputedStyle(el).position === 'static') {
|
|
74
|
+
const prev = el.style.position;
|
|
75
|
+
el.style.position = 'relative';
|
|
76
|
+
ctx.onCleanup(() => (el.style.position = prev));
|
|
77
|
+
}
|
|
78
|
+
const leak = document.createElement('span');
|
|
79
|
+
leak.setAttribute('aria-hidden', 'true');
|
|
80
|
+
Object.assign(leak.style, { position: 'absolute', inset: '0', pointerEvents: 'none', borderRadius: 'inherit', background: `radial-gradient(ellipse at 20% 50%, ${o.color}, transparent 60%)`, mixBlendMode: 'screen', backgroundSize: '200% 100%' });
|
|
81
|
+
el.appendChild(leak);
|
|
82
|
+
ctx.onCleanup(() => leak.remove());
|
|
83
|
+
const a = ctx.animate(el, [{ opacity: 0, filter: 'brightness(2.2) sepia(.5)' }, { opacity: 1, filter: 'brightness(1.4) sepia(.2)', offset: 0.4 }, { opacity: 1, filter: 'none' }], { duration: o.duration, delay: o.delay, easing: 'ease-out', fill: 'backwards' });
|
|
84
|
+
const b = ctx.animate(leak, [{ backgroundPosition: '100% 0', opacity: 1 }, { backgroundPosition: '-60% 0', opacity: 0 }], { duration: o.duration, delay: o.delay, easing: 'ease-in-out', fill: 'backwards' });
|
|
85
|
+
const end = () => leak.remove();
|
|
86
|
+
return Promise.all([a?.finished.catch(() => undefined), b?.finished.catch(() => undefined)]).then(end, end);
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: 'jump-cut',
|
|
91
|
+
kind: 'attention',
|
|
92
|
+
description: 'Two hard cuts (zoom, reframe) and back, like an edit.',
|
|
93
|
+
defaults: { duration: 700 },
|
|
94
|
+
run: (el, o, ctx) => {
|
|
95
|
+
if (ctx.reduced)
|
|
96
|
+
return;
|
|
97
|
+
return ctx.animate(el, [{ transform: 'none' }, { transform: 'scale(1.18) translate(3%, -2%)', offset: 0.3 }, { transform: 'scale(1.06) translate(-4%, 2%)', offset: 0.6 }, { transform: 'none', offset: 0.9 }, { transform: 'none' }], { duration: o.duration, easing: 'steps(1, end)' })?.finished.catch(() => undefined);
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
];
|
|
101
|
+
/** Register film-burn and jump-cut (9.4). */
|
|
102
|
+
function registerVideoPack() {
|
|
103
|
+
registry.registerEffects(VIDEO_FX);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
exports.VIDEO_FX = VIDEO_FX;
|
|
107
|
+
exports.frameSequence = frameSequence;
|
|
108
|
+
exports.registerVideoPack = registerVideoPack;
|
|
109
|
+
exports.scrollProgress = scrollProgress;
|
|
110
|
+
exports.scrubVideo = scrubVideo;
|
|
111
|
+
//# sourceMappingURL=fx-video.cjs.map
|