# Camera Follows the Caret (镜头跟着光标打字)

One sentence types out at 360 px while the camera frames only the last four or five characters and follows the caret to the right; after a 0.4 s stop it pulls back over 1 s to settle the whole sentence in the middle of the frame, the caret blinks twice and retracts.

- Ref: `video/motion-camera-follow-caret` (code video · motion · launch, feature, brand · any · 6s at 30fps)
- Page: https://uifino.com/en/videos/motion-camera-follow-caret
- Markdown: https://uifino.com/md/videos/motion-camera-follow-caret.md
- Preview image: https://uifino.com/videos/motion-camera-follow-caret/poster.jpg

## Install

- ZIP: https://uifino.com/videos/motion-camera-follow-caret/source.zip

One sentence types out at 360 px while the camera frames only the last four or five characters and follows the caret to the right; after a 0.4 s stop it pulls back over 1 s to settle the whole sentence in the middle of the frame, the caret blinks twice and retracts.

Rendered video: https://uifino.com/videos/motion-camera-follow-caret/preview.mp4

## Beats

- 0-0.6s Show the caret first so the viewer knows something will be written: Paper ground, one caret resting at x = 1440 px, blinking off and on once Camera: static.
- 0.6-2.338s The camera stays on the caret and follows it character by character: One character every 0.15 to 0.25 s (fixed seed); each character gets one power2.out move that pulls the caret back to 1440 px; 4 to 5 characters are in frame, with a horizontal smear that settles after each landing Camera: follow. On-screen text: "Make the opening shorter today".
- 2.338-2.738s A short stop so the viewer feels the sentence is done: Camera and caret fully still for 0.4 s Camera: static.
- 2.738-3.738s Pull back and hand the whole sentence to the viewer: One second of power3.inOut, move and scale in the same tween; the sentence lands centered at an effective 96 px without reflowing Camera: pull-back. On-screen text: "Make the opening shorter today".
- 3.738-5.038s Two blinks and a retract close the line: From 0.1 s after the pull: off 0.25 s, on 0.25 s, twice, then a 0.2 s collapse to its center Camera: static.
- 5.038-6s Let the sentence be read: The sentence stays fully still, no caret Camera: static. On-screen text: "Make the opening shorter today".

## Parameters

- `text` Sentence to type: default 今天把开场改短一点
- `fontSize` Font size while typing: default 360px, range 240 to 420px
- `startAt` First unit time: default 0.6s, range 0.3 to 1.5s
- `seed` Random seed: default 7, range 1 to 999
- `gap` Average gap: default 0.2s, range 0.12 to 0.4s
- `jitter` Gap spread: default 0.05s, range 0 to 0.1s
- `caretX` Screen x of the resting caret: default 1440px, range 1280 to 1600px
- `hold` Stop after the last unit: default 0.4s, range 0.2 to 1s
- `pullDuration` Pull back duration: default 1s, range 0.6 to 1.6s
- `endSize` Equivalent font size after the pull: default 96px, range 64 to 140px
- `blinkHalf` Half period of the blinks: default 0.25s, range 0.15 to 0.4s
- `ink` Text and caret color: default #121212
- `bg` Background: default #F6F5F2

## Good for

- The moment a feature is typing in a launch or feature film
- One short sentence (about 10 Chinese characters or 5 English words)
- Making the viewer watch the caret first and read the whole sentence last

## Not for

- Multi-line or multi-paragraph copy
- Whole-sentence fades or typo-and-backspace demos
- Showing the whole sentence during typing (only the last four or five characters are visible)

## Source files (plain text)

- https://uifino.com/videos/motion-camera-follow-caret/source/SPEC.md
- https://uifino.com/videos/motion-camera-follow-caret/source/PROMPT.md
- https://uifino.com/videos/motion-camera-follow-caret/source/NOTICE.md
- https://uifino.com/videos/motion-camera-follow-caret/source/project/assets/fonts/OFL.txt
- https://uifino.com/videos/motion-camera-follow-caret/source/project/compositions/follow.html
- https://uifino.com/videos/motion-camera-follow-caret/source/project/hyperframes.json
- https://uifino.com/videos/motion-camera-follow-caret/source/project/index.html

## How to use

- Copy the beats and parameters; replace only the copy, the accent color and the product screenshots.
- `PROMPT.md` has two prompts: one to reproduce this video exactly, one to learn only the technique.
- Build with HyperFrames (`/hyperframes`); the project in the ZIP is a ready starting point.

## Files

| Path | Role | Size |
| :--- | :--- | ---: |
| PROMPT.md | doc | 2.7 KB |
| SPEC.md | doc | 8.2 KB |

### PROMPT.md

```md
# PROMPT：motion-camera-follow-caret

## 照抄复刻
用 `/hyperframes` 复刻一条 6 秒、1920×1080、30 fps 的镜头跟拍打字片。纸色底 `#F6F5F2`，字和光标都是 `#121212`，画面上只有一句话和一根光标，没有别的东西。

- 做一个「世界层」（宽 = 整句宽，`transform-origin: 0 0`），里面放整行字（Noto Serif SC，字重 500，360px，行高 468px，行中线在 y = 540px）和一根光标（宽 16px，高 378px，纯色，圆角 0）。镜头就是这个世界层的 `x`、`y`、`scale`。
- 每个字在自己的时间点瞬间出现，光标瞬移到它右边 11px。第一个字在 0.6 秒，之后每字间隔 0.2 秒上下浮动 0.05 秒，用固定种子的随机数（种子 7），每次渲染一样。
- 每出一个字，世界层 `x` 做一段补间，让光标落回屏幕 x = 1440px，`power2.out`，最长 0.2 秒（间隔不足 0.2 秒时缩到间隔长度）。镜头位置只能是时间线上的补间，不能在回调里跟随计算。光标停靠时画面里 4 个字，新字出现的一瞬间是 5 个字。
- 最后一个字出现后，等跟拍走完，再静止 0.4 秒。
- 然后 1.0 秒、`power3.inOut`，在同一段补间里把 `x`、`y`、`scale` 一起变到：scale = 96 / 360 = 0.2667（等效字号 96px），整句落在画面正中，不重新排版。
- 拉远结束 0.1 秒后光标灭 0.25 秒、亮 0.25 秒，共两次，然后 0.2 秒 `power3.in` 从中心向内收没。整句静止到结束。
- 快速移动加水平运动模糊：每个字的跟拍从 σ 10 线性降到 0（只占跟拍补间的前半段），拉远时 σ 0 升到 16 再降回 0。用 SVG `feGaussianBlur` 配合补间做，不要依赖 `data-motion-blur`。
- 字体用本地 `@font-face`（assets/fonts/noto-serif-sc.woff2，英文用 instrument-sans.woff2）；时间线要等 `document.fonts.load` 完成、量完字宽后再注册。

需要替换的地方：
- 句子（默认「今天把开场改短一点」；没有空格按字拆，有空格按词拆，英文如 Make the opening shorter today）
- 字号 360px、光标停靠位置 1440px、打字起点 0.6 秒、字间隔 0.2 秒、浮动 0.05 秒、随机种子 7
- 打完后的停顿 0.4 秒、拉远时长 1.0 秒、拉远后的等效字号 96px、光标闪烁半周期 0.25 秒
- 字和光标颜色 `#121212`、底色 `#F6F5F2`

## 只学手法
把整句排成一行放进可缩放的世界层，打字时镜头用每字一段 0.2 秒 `power2.out` 的补间把光标拉回右侧 1440px，画面始终只框住最近的 4 到 5 个字；打完停 0.4 秒，再用 1.0 秒 `power3.inOut` 同时缩放加平移拉远，整句收进画面正中，光标闪两下后收起。
```

### SPEC.md

```md
# SPEC：motion-camera-follow-caret

## LOOK
- 色值：底 `#F6F5F2`，字和光标 `#121212`。次要字 `#6B6966`、线 `#E2DFD8`、强调色 `#D4412A` 这条片不用：画面只有一句话和一根光标，多一种颜色就是装饰。中性色 2 个，强调色 0 个。
- 字体：中文 Noto Serif SC（字重 500），西文 Instrument Sans（字重 500），本地 `@font-face`，`assets/fonts/noto-serif-sc.woff2`、`assets/fonts/instrument-sans.woff2`。两个族都声明，默认中文文案只会用到 Noto Serif SC，换成英文文案才用 Instrument Sans。
- 字号：只有 1 档，360px（打字时的真实字号，行高 468px = round(360 × 1.3)，字距 0）。拉远后靠整体缩放变小，没有第二个字号：缩放倍率 = min(96 / 360, 1536 / 整句宽 3240) = 0.2667，等效字号 96px，整句宽 864px（9 个字 × 96px）。
- 光标：宽 16px（round(360 × 0.045)），高 378px（round(360 × 1.05)），纯色 `#121212`，圆角 0，没有阴影和发光。光标放在刚出现的字右边缘外 11px（round(360 × 0.03)）。光标在世界层里，随镜头一起缩放：拉远后宽约 4px、高约 101px。
- 版式：整句单行，打字前就按完整句子排好，世界层宽 3240px（9 个汉字 × 360px），行中线固定在世界坐标 y = 540px。出字不推动版面。
- 圆角：无。阴影：无。渐变：无。背景纯色。

## MOTION
- 世界层：`#fc-world` 装整行字和光标，宽 3240px，`transform-origin: 0 0`。镜头就是这一层的 `x`、`y`、`scale`，屏幕位置 = x + scale × 世界坐标。全部是时间线上的补间，没有回调。
- 出字：每个字在自己的时间点瞬间出现（opacity 0 到 1，0.001 秒），光标同一时刻瞬移到它右边。
- 字间隔：固定种子 7（mulberry32），间隔 = 0.2 + (随机数 × 2 − 1) × 0.05 秒，范围 0.15 到 0.25 秒。第一个字在 0.6 秒。
- 跟拍：每个字一段补间，世界层 `x` 从上一个字的位置移到「光标落在屏幕 x = 1440px」的位置，`power2.out`，时长 min(0.2 秒, 到下一个字的间隔)。间隔小于 0.2 秒时补间缩短，避免两段补间重叠抢同一个属性；间隔大于 0.2 秒时补间走完后镜头静止一小会儿。光标落点 1440px 在右三分之一线（1280px）之内，每个字出现的一瞬间光标比 1440px 靠右 360px（最右到 1800px，仍在画面内），随后被镜头拉回。
- 运动模糊：不用 `data-motion-blur`（实测它会把几千像素宽的世界层裁掉，字消失）。改用 SVG 滤镜 `#fc-mb`（`feGaussianBlur`，只在水平方向模糊），模糊量按镜头速度补间：每个字的跟拍从 σ 10 线性降到 0.01（`ease: none`），只占跟拍补间的前半段（时长 = 补间时长 ÷ 2，约 0.075–0.1 秒），后半段画面清晰，每个字落定后有一小段清楚的停留；拉远前半段 σ 0.01 升到 16（`power2.in`），后半段降回 0.01（`power2.out`）。σ 单位是世界坐标。
- 打完停：最后一个字（2.138 秒）出现后，跟拍补间 0.2 秒走完，再静止 `hold` 0.4 秒。
- 拉远：1.0 秒，`power3.inOut`，同一段补间里 `x`、`y`、`scale` 一起变。终点 scale = 0.2667，x = 960 − scale × 3240 / 2 = 528px，y = 540 × (1 − scale) = 396px，整句落在画面正中。三个量用同一条缓动，所以每个字走的是直线，字不会重新排版或换行。
- 光标闪：拉远结束后 0.1 秒开始，灭 0.25 秒、亮 0.25 秒，共两次；之后亮着的光标 `scaleY` 1 到 0，0.2 秒，`power3.in`，从中心向内收没。开场 0.2–0.4 秒灭一次。
- 缓动只用：瞬时（出字、光标跳位、闪烁）、`power2.out`（跟拍）、`power3.inOut`（拉远）、`power3.in`（光标收起）、模糊用 `none`、`power2.in`、`power2.out`。

## 逐拍节拍表
默认中文文案，9 个字。字出现时间（秒），按种子 7 算出：

0.600 今 / 0.751 天 / 0.907 把 / 1.155 开 / 1.375 场 / 1.577 改 / 1.768 短 / 1.964 一 / 2.138 点

| 拍 | 起止秒 | 画面 | 镜头 | 转场 | 屏幕文案原文 |
| --- | --- | --- | --- | --- | --- |
| wait | 0.00 – 0.60 | 纸色底，一根光标停在 x = 1440px，0.2 秒灭到 0.4 秒再亮 | 固定 | 无 | |
| type | 0.60 – 2.338 | 逐字打出，每字一段 0.15–0.25 秒的跟拍，光标停靠时画面里 4 个字，新字出现的一瞬间是 5 个字 | 跟着光标往右走 | 无 | 今天把开场改短一点（逐字） |
| hold | 2.338 – 2.738 | 整句已打完，镜头静止，光标常亮 | 固定 | 无 | 今天把开场改短一点 |
| pull | 2.738 – 3.738 | 镜头拉远，整句收进画面正中，带水平拖影 | 拉远 1.0 秒 | 无 | 同上 |
| blink | 3.738 – 5.038 | 光标灭亮两次（3.838–4.838），4.838 起 0.2 秒收起 | 固定 | 无 | 同上 |
| rest | 5.038 – 6.00 | 整句完全静止，没有光标 | 固定 | 无 | 同上 |

拉远结束后整句静止（含光标闪）从 3.738 秒到 6.0 秒，共 2.262 秒，其中光标消失后的纯静止 0.962 秒。

## 参数接线
全部是 `project/compositions/follow.html` 根元素 `data-composition-variables` 里的变量。用户的 AI 在 `project/index.html` 里 `id="follow"` 的挂载元素上写 `data-variable-values='{"text":"Make the opening shorter today"}'` 覆盖。
- text（今天把开场改短一点）：要打的句子。没有空格的按字拆，有空格的按词拆（每个词带前导空格，一个词一段跟拍）。英文「Make the opening shorter today」5 个词，只有 1 到 2 个词同时出现在画面里，这是 360px 下的必然结果。换了新汉字要重跑门禁生成字体子集。
- fontSize（360）：打字时的字号。
- startAt（0.6）：第一个字出现的秒。
- seed（7）：字间隔的随机种子。
- gap（0.2）、jitter（0.05）：平均间隔和上下浮动，秒。
- caretX（1440）：打字时光标停在屏幕 x 多少像素。
- hold（0.4）：最后一个字的跟拍走完后到开始拉远的静止时间，秒。
- pullDuration（1.0）：拉远时长，秒。
- endSize（96）：拉远后的等效字号，px。整句宽超过 1536px 时自动缩到 1536px。
- blinkHalf（0.25）：拉远后光标闪烁的半个周期，秒。
- ink（#121212）、bg（#F6F5F2）：字和光标色、底色。`index.html` 里的 `#F6F5F2` 是兜底底色，换底色时一起改。
没做成变量、要改代码常量的：跟拍补间最长 0.2 秒（`stepDur`）、跟拍模糊 σ 10（及其占补间一半时长）、拉远模糊 σ 16，都在 `follow.html` 的 `build` 函数里。总时长 6 秒写在 `index.html` 和 `follow.html` 的 `data-duration`，要改就一起改（总时长不够长时，打字或拉远会被截断）。

## 禁用项
镜头晃动或模拟手持、拉远时重排版或换行、彩色或发光的光标、光标滑动、整句淡入、字位移或缩放入场、下划线和装饰线、第二行文字、标签、产品截图。

## 已知取舍
- first_frame_empty 警告保留：第 0 帧只有一根光标（大块内容检查不认），这条本来就是先光标、后打字的入场。poster 取 5.5 秒（整句静止、光标已收）。
- 没有用 HyperFrames 自带的 `data-motion-blur`：它在这条片上会把宽 3240px 的世界层裁掉，字在跟拍和拉远时整行消失。换成 SVG 水平模糊，成片里确认有拖影。
- 间隔小于 0.2 秒的字，跟拍补间缩短到间隔长度，不是整 0.2 秒：否则相邻两段补间重叠。
- 光标不在严格的 1280px 线上，而是 1440px：360px 的字宽下，1280px 只能看到 3.5 个字，1440px 刚好 4 个字，新字出现的一瞬间画面里有 5 个字，对上 BRIEF 的「4～5 个字」。caretX 不再往上提：1600px 时新字出现瞬间光标到 1960px，出画。
- 英文版已实测：把 `follow.html` 里 text 声明的 default 临时改成 Make the opening shorter today 跑 `--no-render --at=`（1.0、1.6、2.3、2.6、3.6、5.5 秒），按词拆分正确，打字阶段画面里 1 到 2 个词，拉远后整句居中，测完已改回中文。覆盖在宿主 `data-variable-values` 上的写法没有单独跑过。
- 时间线要等字体加载完才注册（先量字宽、排版），代码里用了 document.fonts.load 的 Promise。
```
