hyperframes 0.2.2 → 0.2.3-alpha.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/dist/cli.js +7926 -7426
- package/dist/skills/gsap/SKILL.md +222 -0
- package/dist/skills/gsap/references/effects.md +304 -0
- package/dist/skills/gsap/references/frameworks.md +56 -0
- package/dist/skills/gsap/references/plugins.md +194 -0
- package/dist/skills/gsap/references/react.md +80 -0
- package/dist/skills/gsap/references/scrolltrigger.md +147 -0
- package/dist/skills/gsap/references/utils.md +91 -0
- package/dist/skills/gsap/scripts/extract-audio-data.py +188 -0
- package/dist/skills/{hyperframes-compose → hyperframes}/SKILL.md +43 -43
- package/dist/skills/hyperframes/references/audio-reactive.md +76 -0
- package/dist/skills/hyperframes/references/captions.md +132 -0
- package/dist/skills/hyperframes/references/css-patterns.md +371 -0
- package/dist/skills/hyperframes/references/examples.md +146 -0
- package/dist/skills/hyperframes/references/marker-highlight.md +158 -0
- package/dist/skills/hyperframes/references/transitions/catalog.md +132 -0
- package/dist/skills/hyperframes/references/transitions/css-3d.md +12 -0
- package/dist/skills/hyperframes/references/transitions/css-blur.md +51 -0
- package/dist/skills/hyperframes/references/transitions/css-cover.md +43 -0
- package/dist/skills/hyperframes/references/transitions/css-destruction.md +95 -0
- package/dist/skills/hyperframes/references/transitions/css-dissolve.md +66 -0
- package/dist/skills/hyperframes/references/transitions/css-distortion.md +45 -0
- package/dist/skills/hyperframes/references/transitions/css-grid.md +10 -0
- package/dist/skills/hyperframes/references/transitions/css-light.md +49 -0
- package/dist/skills/hyperframes/references/transitions/css-mechanical.md +30 -0
- package/dist/skills/hyperframes/references/transitions/css-other.md +36 -0
- package/dist/skills/hyperframes/references/transitions/css-push.md +41 -0
- package/dist/skills/hyperframes/references/transitions/css-radial.md +37 -0
- package/dist/skills/hyperframes/references/transitions/css-scale.md +24 -0
- package/dist/skills/hyperframes/references/transitions/shader-setup.md +463 -0
- package/dist/skills/hyperframes/references/transitions/shader-transitions.md +329 -0
- package/dist/skills/hyperframes/references/transitions.md +96 -0
- package/dist/skills/hyperframes/references/tts.md +56 -0
- package/dist/skills/hyperframes-cli/SKILL.md +114 -0
- package/dist/templates/_shared/CLAUDE.md +5 -7
- package/dist/templates/blank/index.html +8 -10
- package/package.json +2 -4
- package/dist/skills/hyperframes-captions/SKILL.md +0 -212
- package/dist/skills/hyperframes-tts/SKILL.md +0 -79
- package/dist/templates/blank/compositions/captions.html +0 -95
- /package/dist/skills/{hyperframes-compose → hyperframes}/data-in-motion.md +0 -0
- /package/dist/skills/{hyperframes-compose → hyperframes}/house-style.md +0 -0
- /package/dist/skills/{hyperframes-compose → hyperframes}/palettes/bold-energetic.md +0 -0
- /package/dist/skills/{hyperframes-compose → hyperframes}/palettes/clean-corporate.md +0 -0
- /package/dist/skills/{hyperframes-compose → hyperframes}/palettes/dark-premium.md +0 -0
- /package/dist/skills/{hyperframes-compose → hyperframes}/palettes/jewel-rich.md +0 -0
- /package/dist/skills/{hyperframes-compose → hyperframes}/palettes/monochrome.md +0 -0
- /package/dist/skills/{hyperframes-compose → hyperframes}/palettes/nature-earth.md +0 -0
- /package/dist/skills/{hyperframes-compose → hyperframes}/palettes/neon-electric.md +0 -0
- /package/dist/skills/{hyperframes-compose → hyperframes}/palettes/pastel-soft.md +0 -0
- /package/dist/skills/{hyperframes-compose → hyperframes}/palettes/warm-editorial.md +0 -0
- /package/dist/skills/{hyperframes-compose → hyperframes}/patterns.md +0 -0
- /package/dist/skills/{hyperframes-captions → hyperframes/references}/dynamic-techniques.md +0 -0
- /package/dist/skills/{hyperframes-captions → hyperframes/references}/transcript-guide.md +0 -0
|
@@ -1,22 +1,11 @@
|
|
|
1
1
|
---
|
|
2
|
-
name: hyperframes
|
|
3
|
-
description: Create video compositions, animations, title cards,
|
|
2
|
+
name: hyperframes
|
|
3
|
+
description: Create video compositions, animations, title cards, overlays, captions, voiceovers, audio-reactive visuals, and scene transitions in HyperFrames HTML. Use when asked to build any HTML-based video content, add captions or subtitles synced to audio, generate text-to-speech narration, create audio-reactive animation (beat sync, glow, pulse driven by music), add animated text highlighting (marker sweeps, hand-drawn circles, burst lines, scribble, sketchout), or add transitions between scenes (crossfades, wipes, reveals, shader transitions). Covers composition authoring, timing, media, and the full video production workflow. For CLI commands (init, lint, preview, render, transcribe, tts) see the hyperframes-cli skill.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# HyperFrames
|
|
7
7
|
|
|
8
|
-
HTML is the source of truth for video. A composition is an HTML file with `data-*` attributes for timing, a GSAP timeline for animation, and CSS for appearance.
|
|
9
|
-
|
|
10
|
-
## Approach
|
|
11
|
-
|
|
12
|
-
Before writing HTML, think at a high level:
|
|
13
|
-
|
|
14
|
-
1. **What** — what should the viewer experience? Identify the narrative arc, key moments, and emotional beats.
|
|
15
|
-
2. **Structure** — how many compositions, which are sub-compositions vs inline, what tracks carry what (video, audio, overlays, captions).
|
|
16
|
-
3. **Timing** — which clips drive the duration, where do transitions land, what's the pacing.
|
|
17
|
-
4. **Execute** — then implement using the rules below.
|
|
18
|
-
|
|
19
|
-
For small edits (fix a color, adjust timing, add one element), skip straight to the rules.
|
|
8
|
+
HTML is the source of truth for video. A composition is an HTML file with `data-*` attributes for timing, a GSAP timeline for animation, and CSS for appearance.
|
|
20
9
|
|
|
21
10
|
When no `visual-style.md` or animation direction is provided, follow [house-style.md](./house-style.md) for motion defaults, sizing, and color palettes.
|
|
22
11
|
|
|
@@ -29,7 +18,7 @@ When no `visual-style.md` or animation direction is provided, follow [house-styl
|
|
|
29
18
|
| `id` | Yes | Unique identifier |
|
|
30
19
|
| `data-start` | Yes | Seconds or clip ID reference (`"el-1"`, `"intro + 2"`) |
|
|
31
20
|
| `data-duration` | Required for img/div/compositions | Seconds. Video/audio defaults to media duration. |
|
|
32
|
-
| `data-track-index` | Yes | Integer. Same-track clips
|
|
21
|
+
| `data-track-index` | Yes | Integer. Same-track clips cannot overlap. |
|
|
33
22
|
| `data-media-start` | No | Trim offset into source (seconds) |
|
|
34
23
|
| `data-volume` | No | 0-1 (default 1) |
|
|
35
24
|
|
|
@@ -46,7 +35,7 @@ When no `visual-style.md` or animation direction is provided, follow [house-styl
|
|
|
46
35
|
|
|
47
36
|
## Composition Structure
|
|
48
37
|
|
|
49
|
-
Every composition is a `<template>` wrapping a `<div>` with `data-composition-id
|
|
38
|
+
Every composition is a `<template>` wrapping a `<div>` with `data-composition-id`:
|
|
50
39
|
|
|
51
40
|
```html
|
|
52
41
|
<template id="my-comp-template">
|
|
@@ -100,15 +89,14 @@ Video must be `muted playsinline`. Audio is always a separate `<audio>` element:
|
|
|
100
89
|
- Register every timeline: `window.__timelines["<composition-id>"] = tl`
|
|
101
90
|
- Framework auto-nests sub-timelines — do NOT manually add them
|
|
102
91
|
- Duration comes from `data-duration`, not from GSAP timeline length
|
|
103
|
-
- Never create empty tweens to set duration
|
|
104
92
|
|
|
105
93
|
## Rules (Non-Negotiable)
|
|
106
94
|
|
|
107
|
-
**Deterministic:** No `Math.random()`, `Date.now()`, or time-based logic.
|
|
95
|
+
**Deterministic:** No `Math.random()`, `Date.now()`, or time-based logic.
|
|
108
96
|
|
|
109
97
|
**GSAP:** Only animate visual properties (`opacity`, `x`, `y`, `scale`, `rotation`, `color`, `backgroundColor`, `borderRadius`, transforms). Do NOT animate `visibility`, `display`, or call `video.play()`/`audio.play()`.
|
|
110
98
|
|
|
111
|
-
**Animation conflicts:** Never animate the same property on the same element from multiple timelines simultaneously
|
|
99
|
+
**Animation conflicts:** Never animate the same property on the same element from multiple timelines simultaneously.
|
|
112
100
|
|
|
113
101
|
**Never do:**
|
|
114
102
|
|
|
@@ -120,36 +108,48 @@ Video must be `muted playsinline`. Audio is always a separate `<audio>` element:
|
|
|
120
108
|
6. Call play/pause/seek on media — framework owns playback
|
|
121
109
|
7. Create a top-level container without `data-composition-id`
|
|
122
110
|
|
|
123
|
-
## Editing Existing Compositions
|
|
124
|
-
|
|
125
|
-
- Read the full composition first — match existing fonts, colors, animation patterns
|
|
126
|
-
- Only change what was requested — don't rewrite untouched sections
|
|
127
|
-
- Don't rewrite entire files for small changes
|
|
128
|
-
- Preserve timing of unrelated clips
|
|
129
|
-
|
|
130
111
|
## Typography and Assets
|
|
131
112
|
|
|
132
|
-
- Every composition loads its own fonts (`@import` or `@font-face`
|
|
133
|
-
- Use `font-display: block` for local fonts
|
|
134
|
-
- Add `crossorigin="anonymous"` to
|
|
113
|
+
- Every composition loads its own fonts (`@import` or `@font-face`)
|
|
114
|
+
- Use `font-display: block` for local fonts
|
|
115
|
+
- Add `crossorigin="anonymous"` to external media
|
|
135
116
|
- Minimum readable text: 20px landscape, 18px portrait
|
|
136
|
-
- For dynamic text
|
|
137
|
-
- All files
|
|
138
|
-
- From sub-compositions, use `../` to reference root files
|
|
117
|
+
- For dynamic text overflow, use `window.__hyperframes.fitTextFontSize(text, { maxWidth, fontFamily, fontWeight })` — returns `{ fontSize, fits }`
|
|
118
|
+
- All files live at the project root alongside `index.html`; sub-compositions use `../`
|
|
139
119
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
120
|
+
## Editing Existing Compositions
|
|
121
|
+
|
|
122
|
+
- Read the full composition first — match existing fonts, colors, animation patterns
|
|
123
|
+
- Only change what was requested
|
|
124
|
+
- Preserve timing of unrelated clips
|
|
144
125
|
|
|
145
126
|
## Output Checklist
|
|
146
127
|
|
|
147
|
-
- [ ] Every top-level container has `data-composition-id`
|
|
148
|
-
- [ ] Every composition has `data-width`, `data-height`, `data-duration`
|
|
128
|
+
- [ ] Every top-level container has `data-composition-id`, `data-width`, `data-height`, `data-duration`
|
|
149
129
|
- [ ] Compositions in own HTML files, loaded via `data-composition-src`
|
|
150
130
|
- [ ] `<template>` wrapper on sub-compositions
|
|
151
131
|
- [ ] `window.__timelines` registered for every composition
|
|
152
|
-
- [ ] 100% deterministic
|
|
153
|
-
- [ ] Each composition includes GSAP
|
|
154
|
-
- [ ] `npx hyperframes lint`
|
|
155
|
-
|
|
132
|
+
- [ ] 100% deterministic
|
|
133
|
+
- [ ] Each composition includes GSAP script tag
|
|
134
|
+
- [ ] `npx hyperframes lint` and `npx hyperframes validate` both pass
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## References (loaded on demand)
|
|
139
|
+
|
|
140
|
+
- **[references/captions.md](references/captions.md)** — Captions, subtitles, lyrics, karaoke synced to audio. Tone-adaptive style detection, per-word styling, text overflow prevention, caption exit guarantees, word grouping. Read when adding any text synced to audio timing.
|
|
141
|
+
- **[references/tts.md](references/tts.md)** — Text-to-speech with Kokoro-82M. Voice selection, speed tuning, TTS+captions workflow. Read when generating narration or voiceover.
|
|
142
|
+
- **[references/audio-reactive.md](references/audio-reactive.md)** — Audio-reactive animation: map frequency bands and amplitude to GSAP properties. Read when visuals should respond to music, voice, or sound.
|
|
143
|
+
- **[references/marker-highlight.md](references/marker-highlight.md)** — Animated text highlighting via canvas overlays: marker pen, circle, burst, scribble, sketchout. Read when adding visual emphasis to text.
|
|
144
|
+
- **[house-style.md](house-style.md)** — Default motion, sizing, and color palettes when no style is specified.
|
|
145
|
+
- **[patterns.md](patterns.md)** — PiP, title cards, slide show patterns.
|
|
146
|
+
- **[data-in-motion.md](data-in-motion.md)** — Data, stats, and infographic patterns.
|
|
147
|
+
- **[references/transcript-guide.md](references/transcript-guide.md)** — Transcription commands, whisper models, external APIs, troubleshooting.
|
|
148
|
+
- **[references/dynamic-techniques.md](references/dynamic-techniques.md)** — Dynamic caption animation techniques (karaoke, clip-path, slam, scatter, elastic, 3D).
|
|
149
|
+
|
|
150
|
+
- **[references/transitions.md](references/transitions.md)** — Scene transitions: crossfades, wipes, reveals, shader transitions. Energy/mood selection, narrative position, CSS vs WebGL guidance. Read when a composition has multiple scenes that need visual handoffs.
|
|
151
|
+
- [transitions/catalog.md](references/transitions/catalog.md) — Hard rules, scene template, and routing to per-type implementation code.
|
|
152
|
+
- [transitions/shader-setup.md](references/transitions/shader-setup.md) — WebGL boilerplate for shader transitions.
|
|
153
|
+
- [transitions/shader-transitions.md](references/transitions/shader-transitions.md) — 14 fragment shaders.
|
|
154
|
+
|
|
155
|
+
GSAP patterns and effects are in the `/gsap` skill.
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Audio-Reactive Animation
|
|
2
|
+
|
|
3
|
+
Drive visuals from music, voice, or sound. Any GSAP-animatable property can respond to pre-extracted audio data.
|
|
4
|
+
|
|
5
|
+
## Audio Data Format
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
var AUDIO_DATA = {
|
|
9
|
+
fps: 30,
|
|
10
|
+
totalFrames: 900,
|
|
11
|
+
frames: [{ bands: [0.82, 0.45, 0.31, ...] }, ...]
|
|
12
|
+
};
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
- `frames[i].bands[]` — frequency band amplitudes, 0-1. Index 0 = bass, higher = treble.
|
|
16
|
+
- Each band normalized independently across the full track.
|
|
17
|
+
|
|
18
|
+
## Mapping Audio to Visuals
|
|
19
|
+
|
|
20
|
+
| Audio signal | Visual property | Effect |
|
|
21
|
+
| ---------------------- | --------------------------------- | -------------------------- |
|
|
22
|
+
| Bass (bands[0]) | `scale` | Pulse on beat |
|
|
23
|
+
| Treble (bands[12-14]) | `textShadow`, `boxShadow` | Glow intensity |
|
|
24
|
+
| Overall amplitude | `opacity`, `y`, `backgroundColor` | Breathe, lift, color shift |
|
|
25
|
+
| Mid-range (bands[4-8]) | `borderRadius`, `width` | Shape morphing |
|
|
26
|
+
|
|
27
|
+
Any GSAP-tweenable property works — `clipPath`, `filter`, SVG attributes, CSS custom properties.
|
|
28
|
+
|
|
29
|
+
## Content, Not Medium
|
|
30
|
+
|
|
31
|
+
Audio provides **timing and intensity**. The visual vocabulary comes from the narrative.
|
|
32
|
+
|
|
33
|
+
**Never add:** equalizer bars, spectrum analyzers, waveform displays, musical notes clip art, generic particle systems, rainbow color cycling, strobing white on beats, abstract pulsing orbs.
|
|
34
|
+
|
|
35
|
+
**Instead:** Let content guide the visual and audio drive its behavior. Bass makes warmth _swell_. Treble sharpens _contrast_. The visual choice comes from "what does this piece feel like?"
|
|
36
|
+
|
|
37
|
+
## Sampling Pattern
|
|
38
|
+
|
|
39
|
+
Audio reactivity requires per-frame sampling via a `for` loop with `tl.call()`, not a single tween:
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
// ✅ Correct — sample every frame
|
|
43
|
+
for (var f = 0; f < AUDIO_DATA.totalFrames; f++) {
|
|
44
|
+
tl.call(
|
|
45
|
+
(function (frame) {
|
|
46
|
+
return function () {
|
|
47
|
+
draw(frame);
|
|
48
|
+
};
|
|
49
|
+
})(AUDIO_DATA.frames[f]),
|
|
50
|
+
[],
|
|
51
|
+
f / AUDIO_DATA.fps,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// ❌ Wrong — single tween, doesn't react to audio
|
|
56
|
+
gsap.to(".el", { scale: 1.2, duration: totalDuration });
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Without per-frame sampling, the composition doesn't actually react to audio.
|
|
60
|
+
|
|
61
|
+
## textShadow Gotcha
|
|
62
|
+
|
|
63
|
+
`textShadow` on a parent container with semi-transparent children (e.g., inactive caption words at `rgba(255,255,255,0.3)`) renders a visible glow rectangle behind all children. Fix: apply `scale` to the container for beat pulse, but apply `textShadow` to individual active words only.
|
|
64
|
+
|
|
65
|
+
## Guidelines
|
|
66
|
+
|
|
67
|
+
- **Subtlety for text** — 3-6% scale variation, soft glow. Heavy pulsing makes text unreadable.
|
|
68
|
+
- **Go bigger on non-text** — backgrounds and shapes can handle 10-30% swings.
|
|
69
|
+
- **Match the energy** — corporate = subtle; music video = dramatic.
|
|
70
|
+
- **Deterministic** — pre-extracted data, no Web Audio API, no runtime analysis.
|
|
71
|
+
|
|
72
|
+
## Constraints
|
|
73
|
+
|
|
74
|
+
- All audio data must be pre-extracted (use `extract-audio-data.py` from the gsap skill's scripts/)
|
|
75
|
+
- No `Math.random()` or `Date.now()`
|
|
76
|
+
- Audio reactivity runs on the same GSAP timeline as everything else
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Captions
|
|
2
|
+
|
|
3
|
+
## Language Rule (Non-Negotiable)
|
|
4
|
+
|
|
5
|
+
**Never use `.en` models unless the user explicitly states the audio is English.** `.en` models TRANSLATE non-English audio into English instead of transcribing it.
|
|
6
|
+
|
|
7
|
+
1. User says the language → `--model small --language <code>` (no `.en`)
|
|
8
|
+
2. User says English → `--model small.en`
|
|
9
|
+
3. Language unknown → `--model small` (no `.en`, no `--language`) — auto-detects
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
Analyze spoken content to determine caption style. If user specifies a style, use that. Otherwise, detect tone from the transcript.
|
|
14
|
+
|
|
15
|
+
## Transcript Source
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
[
|
|
19
|
+
{ "text": "Hello", "start": 0.0, "end": 0.5 },
|
|
20
|
+
{ "text": "world.", "start": 0.6, "end": 1.2 }
|
|
21
|
+
]
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
For transcription commands, whisper models, external APIs, see [transcript-guide.md](transcript-guide.md).
|
|
25
|
+
|
|
26
|
+
## Style Detection (When No Style Specified)
|
|
27
|
+
|
|
28
|
+
Read the full transcript before choosing. Four dimensions:
|
|
29
|
+
|
|
30
|
+
**1. Visual feel** — corporate→clean; energetic→bold; storytelling→elegant; technical→precise; social→playful.
|
|
31
|
+
|
|
32
|
+
**2. Color palette** — dark+bright for energy; muted for professional; high contrast for clarity; one accent color.
|
|
33
|
+
|
|
34
|
+
**3. Font mood** — heavy/condensed for impact; clean sans for modern; rounded for friendly; serif for elegance.
|
|
35
|
+
|
|
36
|
+
**4. Animation character** — scale-pop for punchy; gentle fade for calm; word-by-word for emphasis; typewriter for technical.
|
|
37
|
+
|
|
38
|
+
## Per-Word Styling
|
|
39
|
+
|
|
40
|
+
Scan for words deserving distinct treatment:
|
|
41
|
+
|
|
42
|
+
- **Brand/product names** — larger size, unique color
|
|
43
|
+
- **ALL CAPS** — scale boost, flash, accent color
|
|
44
|
+
- **Numbers/statistics** — bold weight, accent color
|
|
45
|
+
- **Emotional keywords** — exaggerated animation (overshoot, bounce)
|
|
46
|
+
- **Call-to-action** — highlight, underline, color pop
|
|
47
|
+
- **Marker highlight** — for beyond-color emphasis, see [marker-highlight.md](marker-highlight.md)
|
|
48
|
+
|
|
49
|
+
## Script-to-Style Mapping
|
|
50
|
+
|
|
51
|
+
| Tone | Font mood | Animation | Color | Size |
|
|
52
|
+
| ------------ | ------------------------ | ---------------------------------- | --------------------------- | ------- |
|
|
53
|
+
| Hype/launch | Heavy condensed, 800-900 | Scale-pop, back.out(1.7), 0.1-0.2s | Bright on dark | 72-96px |
|
|
54
|
+
| Corporate | Clean sans, 600-700 | Fade+slide, power3.out, 0.3s | White/neutral, muted accent | 56-72px |
|
|
55
|
+
| Tutorial | Mono/clean sans, 500-600 | Typewriter/fade, 0.4-0.5s | High contrast, minimal | 48-64px |
|
|
56
|
+
| Storytelling | Serif/elegant, 400-500 | Slow fade, power2.out, 0.5-0.6s | Warm muted tones | 44-56px |
|
|
57
|
+
| Social | Rounded sans, 700-800 | Bounce, elastic.out, word-by-word | Playful, colored pills | 56-80px |
|
|
58
|
+
|
|
59
|
+
## Word Grouping
|
|
60
|
+
|
|
61
|
+
- **High energy:** 2-3 words. Quick turnover.
|
|
62
|
+
- **Conversational:** 3-5 words. Natural phrases.
|
|
63
|
+
- **Measured/calm:** 4-6 words. Longer groups.
|
|
64
|
+
|
|
65
|
+
Break on sentence boundaries, 150ms+ pauses, or max word count.
|
|
66
|
+
|
|
67
|
+
## Positioning
|
|
68
|
+
|
|
69
|
+
- **Landscape (1920x1080):** Bottom 80-120px, centered
|
|
70
|
+
- **Portrait (1080x1920):** Lower middle ~600-700px from bottom, centered
|
|
71
|
+
- Never cover the subject's face
|
|
72
|
+
- `position: absolute` — never relative
|
|
73
|
+
- One caption group visible at a time
|
|
74
|
+
|
|
75
|
+
## Text Overflow Prevention
|
|
76
|
+
|
|
77
|
+
Use `window.__hyperframes.fitTextFontSize()`:
|
|
78
|
+
|
|
79
|
+
```js
|
|
80
|
+
var result = window.__hyperframes.fitTextFontSize(group.text.toUpperCase(), {
|
|
81
|
+
fontFamily: "Outfit",
|
|
82
|
+
fontWeight: 900,
|
|
83
|
+
maxWidth: 1600,
|
|
84
|
+
});
|
|
85
|
+
el.style.fontSize = result.fontSize + "px";
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Options: `maxWidth` (1600 landscape, 900 portrait), `baseFontSize` (78), `minFontSize` (42), `fontWeight`, `fontFamily`, `step` (2).
|
|
89
|
+
|
|
90
|
+
CSS safety nets: `max-width` on container, `overflow: visible` (**not** `hidden` — hidden clips scaled emphasis words and glow effects), `position: absolute`, explicit `height`. When per-word styling uses `scale > 1.0`, compute `maxWidth = safeWidth / maxScale` to leave headroom.
|
|
91
|
+
|
|
92
|
+
**Container pattern:** Full-width absolute container, centered. Do **not** use `left: 50%; transform: translateX(-50%)` — causes clipping at composition edges.
|
|
93
|
+
|
|
94
|
+
## Caption Exit Guarantee
|
|
95
|
+
|
|
96
|
+
Every group **must** have a hard kill after exit animation:
|
|
97
|
+
|
|
98
|
+
```js
|
|
99
|
+
tl.to(groupEl, { opacity: 0, scale: 0.95, duration: 0.12, ease: "power2.in" }, group.end - 0.12);
|
|
100
|
+
tl.set(groupEl, { opacity: 0, visibility: "hidden" }, group.end); // deterministic kill
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Self-lint after building timeline — place **before** `window.__timelines[id] = tl` so it runs at composition init:
|
|
104
|
+
|
|
105
|
+
```js
|
|
106
|
+
GROUPS.forEach(function (group, gi) {
|
|
107
|
+
var el = document.getElementById("cg-" + gi);
|
|
108
|
+
if (!el) return;
|
|
109
|
+
tl.seek(group.end + 0.01);
|
|
110
|
+
var computed = window.getComputedStyle(el);
|
|
111
|
+
if (computed.opacity !== "0" && computed.visibility !== "hidden") {
|
|
112
|
+
console.warn(
|
|
113
|
+
"[caption-lint] group " + gi + " still visible at t=" + (group.end + 0.01).toFixed(2) + "s",
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
tl.seek(0);
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Further References
|
|
121
|
+
|
|
122
|
+
- [dynamic-techniques.md](dynamic-techniques.md) — karaoke, clip-path reveals, slam words, scatter exits, elastic, 3D rotation
|
|
123
|
+
- [transcript-guide.md](transcript-guide.md) — transcription commands, whisper models, external APIs
|
|
124
|
+
- [marker-highlight.md](marker-highlight.md) — animated text emphasis paired with per-word styling
|
|
125
|
+
|
|
126
|
+
## Constraints
|
|
127
|
+
|
|
128
|
+
- Deterministic. No `Math.random()`, no `Date.now()`.
|
|
129
|
+
- Sync to transcript timestamps.
|
|
130
|
+
- One group visible at a time.
|
|
131
|
+
- Every group must have a hard `tl.set` kill at `group.end`.
|
|
132
|
+
- Check project root for font files before defaulting to Google Fonts.
|