hyperframes 0.2.2 → 0.2.3-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +8651 -7892
- package/dist/docker/Dockerfile.render +33 -0
- package/dist/hyperframe-runtime.js +5 -5
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +5 -5
- 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/SKILL.md +175 -0
- 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/studio/assets/{index-DA_l-VKo.js → index-B0VCLOXQ.js} +15 -15
- package/dist/studio/index.html +1 -1
- 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-compose/SKILL.md +0 -155
- 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
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
---
|
|
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
|
+
---
|
|
5
|
+
|
|
6
|
+
# HyperFrames
|
|
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
|
+
When no `visual-style.md` or animation direction is provided, follow [house-style.md](./house-style.md) for motion defaults, sizing, and color palettes.
|
|
11
|
+
|
|
12
|
+
## Data Attributes
|
|
13
|
+
|
|
14
|
+
### All Clips
|
|
15
|
+
|
|
16
|
+
| Attribute | Required | Values |
|
|
17
|
+
| ------------------ | --------------------------------- | ------------------------------------------------------ |
|
|
18
|
+
| `id` | Yes | Unique identifier |
|
|
19
|
+
| `data-start` | Yes | Seconds or clip ID reference (`"el-1"`, `"intro + 2"`) |
|
|
20
|
+
| `data-duration` | Required for img/div/compositions | Seconds. Video/audio defaults to media duration. |
|
|
21
|
+
| `data-track-index` | Yes | Integer. Same-track clips cannot overlap. |
|
|
22
|
+
| `data-media-start` | No | Trim offset into source (seconds) |
|
|
23
|
+
| `data-volume` | No | 0-1 (default 1) |
|
|
24
|
+
|
|
25
|
+
`data-track-index` does **not** affect visual layering — use CSS `z-index`.
|
|
26
|
+
|
|
27
|
+
### Composition Clips
|
|
28
|
+
|
|
29
|
+
| Attribute | Required | Values |
|
|
30
|
+
| ---------------------------- | -------- | -------------------------------------------- |
|
|
31
|
+
| `data-composition-id` | Yes | Unique composition ID |
|
|
32
|
+
| `data-duration` | Yes | Takes precedence over GSAP timeline duration |
|
|
33
|
+
| `data-width` / `data-height` | Yes | Pixel dimensions (1920x1080 or 1080x1920) |
|
|
34
|
+
| `data-composition-src` | No | Path to external HTML file |
|
|
35
|
+
|
|
36
|
+
## Composition Structure
|
|
37
|
+
|
|
38
|
+
Every composition is a `<template>` wrapping a `<div>` with `data-composition-id`:
|
|
39
|
+
|
|
40
|
+
```html
|
|
41
|
+
<template id="my-comp-template">
|
|
42
|
+
<div data-composition-id="my-comp" data-width="1920" data-height="1080">
|
|
43
|
+
<!-- content -->
|
|
44
|
+
<style>
|
|
45
|
+
[data-composition-id="my-comp"] {
|
|
46
|
+
/* scoped styles */
|
|
47
|
+
}
|
|
48
|
+
</style>
|
|
49
|
+
<script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script>
|
|
50
|
+
<script>
|
|
51
|
+
window.__timelines = window.__timelines || {};
|
|
52
|
+
const tl = gsap.timeline({ paused: true });
|
|
53
|
+
// tweens...
|
|
54
|
+
window.__timelines["my-comp"] = tl;
|
|
55
|
+
</script>
|
|
56
|
+
</div>
|
|
57
|
+
</template>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Load in root: `<div id="el-1" data-composition-id="my-comp" data-composition-src="compositions/my-comp.html" data-start="0" data-duration="10" data-track-index="1"></div>`
|
|
61
|
+
|
|
62
|
+
## Video and Audio
|
|
63
|
+
|
|
64
|
+
Video must be `muted playsinline`. Audio is always a separate `<audio>` element:
|
|
65
|
+
|
|
66
|
+
```html
|
|
67
|
+
<video
|
|
68
|
+
id="el-v"
|
|
69
|
+
data-start="0"
|
|
70
|
+
data-duration="30"
|
|
71
|
+
data-track-index="0"
|
|
72
|
+
src="video.mp4"
|
|
73
|
+
muted
|
|
74
|
+
playsinline
|
|
75
|
+
></video>
|
|
76
|
+
<audio
|
|
77
|
+
id="el-a"
|
|
78
|
+
data-start="0"
|
|
79
|
+
data-duration="30"
|
|
80
|
+
data-track-index="2"
|
|
81
|
+
src="video.mp4"
|
|
82
|
+
data-volume="1"
|
|
83
|
+
></audio>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Timeline Contract
|
|
87
|
+
|
|
88
|
+
- All timelines start `{ paused: true }` — the player controls playback
|
|
89
|
+
- Register every timeline: `window.__timelines["<composition-id>"] = tl`
|
|
90
|
+
- Framework auto-nests sub-timelines — do NOT manually add them
|
|
91
|
+
- Duration comes from `data-duration`, not from GSAP timeline length
|
|
92
|
+
|
|
93
|
+
## Rules (Non-Negotiable)
|
|
94
|
+
|
|
95
|
+
**Deterministic:** No `Math.random()`, `Date.now()`, or time-based logic. Use a seeded PRNG if you need pseudo-random values (e.g. mulberry32).
|
|
96
|
+
|
|
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()`.
|
|
98
|
+
|
|
99
|
+
**Animation conflicts:** Never animate the same property on the same element from multiple timelines simultaneously.
|
|
100
|
+
|
|
101
|
+
**No `repeat: -1`:** Infinite-repeat timelines break the capture engine. Calculate the exact repeat count from composition duration: `repeat: Math.ceil(duration / cycleDuration) - 1`.
|
|
102
|
+
|
|
103
|
+
**Synchronous timeline construction:** Never build timelines inside `async`/`await`, `setTimeout`, or Promises. The capture engine reads `window.__timelines` synchronously after page load. If you need fonts loaded first, use a synchronous `document.fonts.load()` call or rely on `font-display: block` — the engine waits for the page `load` event.
|
|
104
|
+
|
|
105
|
+
**Never do:**
|
|
106
|
+
|
|
107
|
+
1. Forget `window.__timelines` registration
|
|
108
|
+
2. Use video for audio — always muted video + separate `<audio>`
|
|
109
|
+
3. Nest video inside a timed div — use a non-timed wrapper
|
|
110
|
+
4. Use `data-layer` (use `data-track-index`) or `data-end` (use `data-duration`)
|
|
111
|
+
5. Animate video element dimensions — animate a wrapper div
|
|
112
|
+
6. Call play/pause/seek on media — framework owns playback
|
|
113
|
+
7. Create a top-level container without `data-composition-id`
|
|
114
|
+
8. Use `repeat: -1` on any timeline or tween — always finite repeats
|
|
115
|
+
9. Build timelines asynchronously (inside `async`, `setTimeout`, `Promise`)
|
|
116
|
+
|
|
117
|
+
## Typography and Assets
|
|
118
|
+
|
|
119
|
+
- Load fonts via `<link>` tags with `display=block` in `<head>`, NOT via CSS `@import` — `@import` is async and may not complete before the first frame capture
|
|
120
|
+
- Use `font-display: block` for `@font-face` declarations
|
|
121
|
+
- Add `crossorigin="anonymous"` to external media
|
|
122
|
+
- **Minimum font sizes for rendered video (1080p at DPR 1):**
|
|
123
|
+
- Body/label text: 20px minimum (landscape), 18px minimum (portrait)
|
|
124
|
+
- Data labels, axis labels, footnotes: 16px minimum — anything smaller becomes illegible after encoding
|
|
125
|
+
- Headlines: 36px+ recommended
|
|
126
|
+
- Avoid sub-14px text entirely — it will be unreadable in the final MP4
|
|
127
|
+
- For dynamic text overflow, use `window.__hyperframes.fitTextFontSize(text, { maxWidth, fontFamily, fontWeight })` — returns `{ fontSize, fits }`
|
|
128
|
+
- All files live at the project root alongside `index.html`; sub-compositions use `../`
|
|
129
|
+
|
|
130
|
+
### Backgrounds and Color
|
|
131
|
+
|
|
132
|
+
- **Avoid full-screen linear gradients on dark backgrounds** — H.264 encoding creates visible color banding. Prefer: solid colors, radial gradients with limited range, or subtle noise/texture overlays to break up banding.
|
|
133
|
+
- For dark themes, use solid `#000` or `#0A0A0A` with localized radial glows rather than a linear gradient spanning the full viewport.
|
|
134
|
+
|
|
135
|
+
## Editing Existing Compositions
|
|
136
|
+
|
|
137
|
+
- Read the full composition first — match existing fonts, colors, animation patterns
|
|
138
|
+
- Only change what was requested
|
|
139
|
+
- Preserve timing of unrelated clips
|
|
140
|
+
|
|
141
|
+
## Output Checklist
|
|
142
|
+
|
|
143
|
+
- [ ] Every top-level container has `data-composition-id`, `data-width`, `data-height`, `data-duration`
|
|
144
|
+
- [ ] Compositions in own HTML files, loaded via `data-composition-src`
|
|
145
|
+
- [ ] `<template>` wrapper on sub-compositions
|
|
146
|
+
- [ ] `window.__timelines` registered for every composition
|
|
147
|
+
- [ ] Timeline construction is synchronous (no async/await wrapping timeline code)
|
|
148
|
+
- [ ] No `repeat: -1` on any tween or nested timeline
|
|
149
|
+
- [ ] No text below 16px (data labels, footnotes) or 20px (body text)
|
|
150
|
+
- [ ] No full-screen linear dark gradients (use radial or solid + localized glow)
|
|
151
|
+
- [ ] Fonts loaded via `<link>` with `display=block`, not CSS `@import`
|
|
152
|
+
- [ ] 100% deterministic
|
|
153
|
+
- [ ] Each composition includes GSAP script tag
|
|
154
|
+
- [ ] `npx hyperframes lint` and `npx hyperframes validate` both pass
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## References (loaded on demand)
|
|
159
|
+
|
|
160
|
+
- **[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.
|
|
161
|
+
- **[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.
|
|
162
|
+
- **[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.
|
|
163
|
+
- **[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.
|
|
164
|
+
- **[house-style.md](house-style.md)** — Default motion, sizing, and color palettes when no style is specified.
|
|
165
|
+
- **[patterns.md](patterns.md)** — PiP, title cards, slide show patterns.
|
|
166
|
+
- **[data-in-motion.md](data-in-motion.md)** — Data, stats, and infographic patterns.
|
|
167
|
+
- **[references/transcript-guide.md](references/transcript-guide.md)** — Transcription commands, whisper models, external APIs, troubleshooting.
|
|
168
|
+
- **[references/dynamic-techniques.md](references/dynamic-techniques.md)** — Dynamic caption animation techniques (karaoke, clip-path, slam, scatter, elastic, 3D).
|
|
169
|
+
|
|
170
|
+
- **[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.
|
|
171
|
+
- [transitions/catalog.md](references/transitions/catalog.md) — Hard rules, scene template, and routing to per-type implementation code.
|
|
172
|
+
- [transitions/shader-setup.md](references/transitions/shader-setup.md) — WebGL boilerplate for shader transitions.
|
|
173
|
+
- [transitions/shader-transitions.md](references/transitions/shader-transitions.md) — 14 fragment shaders.
|
|
174
|
+
|
|
175
|
+
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.
|