# Truck and Push (横移推近)

A sentence wider than the frame: the camera trucks across it while pushing in slightly, one ease for both, and stops on the final key word.

- Ref: `video/motion-camera-truck-push` (code video · motion · any · any · 4.5s at 30fps)
- Page: https://uifino.com/en/videos/motion-camera-truck-push
- Markdown: https://uifino.com/md/videos/motion-camera-truck-push.md
- Preview image: https://uifino.com/videos/motion-camera-truck-push/poster.jpg

## Install

- ZIP: https://uifino.com/videos/motion-camera-truck-push/source.zip

A sentence wider than the frame: the camera trucks across it while pushing in slightly, one ease for both, and stops on the final key word.

Rendered video: https://uifino.com/videos/motion-camera-truck-push/preview.mp4

## Beats

- 0-3.2s The camera sweeps the sentence and stops on the key word: Text layer trucks 1158.4 px and pushes 1.0 to 1.15, background trucks 60% of that, one power2.inOut, 3.2 s Camera: truck-push. On-screen text: "From one idea to a film you can ship".
- 3.2-4.5s The key word sits dead center: Fully still, no tween Camera: static.

## Parameters

- `pushScale` Push end scale: default 1.15, range 1.05 to 1.25
- `bgPanRatio` Background pan as a share of the text pan: default 0.6, range 0.3 to 0.9
- `moveDuration` Move duration: default 3.2s, range 2.4 to 3.6s
- `moveEase` Shared ease: default power2.inOut
- `fontSize` Font size: default 120px, range 96 to 144px

## Good for

- One claim wider than the frame that should land on its last key word
- A restrained, slightly cinematic camera move
- Works for Chinese and English, one long line

## Not for

- Multi-line or multi-block text
- Scenes where the title needs its own entrance

## Source files (plain text)

- https://uifino.com/videos/motion-camera-truck-push/source/SPEC.md
- https://uifino.com/videos/motion-camera-truck-push/source/PROMPT.md
- https://uifino.com/videos/motion-camera-truck-push/source/NOTICE.md
- https://uifino.com/videos/motion-camera-truck-push/source/project/assets/fonts/OFL.txt
- https://uifino.com/videos/motion-camera-truck-push/source/project/compositions/truck.html
- https://uifino.com/videos/motion-camera-truck-push/source/project/hyperframes.json
- https://uifino.com/videos/motion-camera-truck-push/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 | 6.9 KB |

### PROMPT.md

```md
# PROMPT：motion-camera-truck-push

## 照抄复刻
> 给用户的 AI：用 `/hyperframes` 按下面的数字复刻，不要自己加动作。

做一个 1920×1080、30 fps、4.5 秒的 HyperFrames 动效：深绿底上一句比画面还宽的单行长句，镜头一边从左往右横移、一边轻轻推近，停在句尾的关键词上，关键词落在画面正中。

- 底色 `#0F1712`，字色 `#ECF2EE`，强调色 `#7FD99A`（只染最后的关键词），背景线 `#1F2B24`。
- 句子：中文「从一个想法，到一支能发出去的片子」，关键词「片子」；英文「From one idea to a film you can ship」，关键词「ship」。一行，不换行，字号 120px，字重 600，字距 0.02em，起点 x = 160，垂直居中 y = 540。中文用 Noto Serif SC，西文用 Instrument Sans，本地 `@font-face`。
- 背景：一个铺满画布的 div，用 CSS 渐变画细线网格，线宽 2px，格子 120px，起点 `background-position: 0 0`。没有粒子，没有光斑，没有暗角，没有辉光。
- 镜头：两条 tween，都从 0 秒开始、3.2 秒结束，缓动都是 `power2.inOut`，中途不停、不回弹：
  - 文字层：`x` 从 0 到「把关键词中心带到 x = 960」所需的距离（中文版 -1158.4px），同时 `scale` 1 → 1.15，缩放中心放在关键词中心；`force3D: false`。
  - 背景层：横移文字层距离的 60%（中文版 695.04px），格子 120 → 126px（缩放中心为画面中心，终点 background-position 取整为 -743px -27px，停住时线都在整数像素上），做法是改 `background-size` 和 `background-position`，不要用比画布大的缩放层。
- 3.2–4.5 秒完全静止，不晃动，画面上除了这句话没有任何文字。
- 先横移再推近分成两段、背景粒子、停住后再晃动，都不要。

需要替换的地方：
- 整句：`headline`；镜头停住的关键词：`keyWord`（必须是句子的最后一段）
- 配色：`bg`、`ink`、`accentColor`、`lineColor`
- 字号：`fontSize`（默认 120）
- 推近力度：`pushScale`（默认 1.15）；背景横移比例：`bgPanRatio`（默认 0.6）
- 时长和缓动：`moveDuration`（默认 3.2 秒）、`moveEase`（默认 `power2.inOut`）

这些都是 `compositions/truck.html` 根元素上的变量，在 `index.html` 的 `#truck` 上用 `data-variable-values` 覆盖。背景格子推近倍率 `BG_END = 1.05`（格距 126px） 写在该文件的脚本常量里。

## 只学手法
横移和推近是同一个镜头动作：同一条 `power2.inOut`、同一刻开始同一刻结束（3.2 秒），推近只有 1.0 到 1.15；缩放中心放在最终要停住的那个词上，它自己就不会漂；背景层只横移文字层的 60%，错开的那 40% 就是纵深。
```

### SPEC.md

```md
# SPEC：motion-camera-truck-push

一句话：一句比画面还宽的长句，镜头一边从左往右横移、一边轻轻推近，用同一条缓动、同一刻开始同一刻结束，停在句尾的「片子」上，「片子」落在画面正中。背景细线网格只横移文字层的 60%，两层错开出纵深。

## LOOK
- 色值：底 `#0F1712`，字 `#ECF2EE`，背景线 `#1F2B24`，强调色 `#7FD99A`（只染「片子」两个字，面积远小于 10%）。中性色 3 个。BRIEF 给的次要字 `#8FA096` 画面上没有位置，没有放进代码。
- 字体：Noto Serif SC（汉字）+ Instrument Sans（西文），字重 600，本地 `assets/fonts/noto-serif-sc.woff2`、`assets/fonts/instrument-sans.woff2`。同一条 `font-family: "Instrument Sans", "Noto Serif SC", serif`，西文字母走 Instrument Sans，汉字和中文标点落到 Noto Serif SC。
- 字号：只有一档 120px，字距 0.02em，行高 1.3，不换行（`white-space: nowrap`）。推近后字面是 138px（120 × 1.15）。
- 文字行：中文 17 个字符，每个字符 122.4px 宽（120 + 0.02em 字距），共 2080.8px。左边起点 x = 160，所以句尾落在 x = 2240.8，比 1920 的画面宽出 320.8px。垂直居中在 y = 540。
- 圆角、阴影、渐变：无。
- 背景：一个铺满画布的 div（`inset: 0`，1920×1080），用 CSS 渐变画细线网格：竖线、横线各 2px，颜色 `#1F2B24`，格子 120px，起始 `background-position: 0 0`，所以开始时竖线占 x = 120n 到 120n + 2，横线占 y = 120n 到 120n + 2。没有粒子，没有光斑，没有暗角，没有辉光。

## MOTION
- 只有一个镜头动作，由两条 tween 一起完成，都从 0 秒开始、3.2 秒结束，缓动都是 `power2.inOut`，中途不停、不回弹。3.2 到 4.5 秒完全静止，没有任何 tween。
- 文字层（一条 tween）：
  - 横移 `x`：0 → -1158.4px（把「片子」的中心从句子里的 x = 2118.4 带到画面中心 x = 960：160 + 1958.4 − 1158.4 − 960 = 0）。
  - 推近 `scale`：1 → 1.15，缩放中心是「片子」两个字的中心（行内 x = 1958.4，y = 540），所以推近时「片子」自己不会漂。
  - `force3D: false`，不写 `will-change`，保证放大后每一帧字都重新按新大小画，边缘锐利。
- 背景层（一条 tween）：
  - 横移：文字层横移距离的 60%，即 0.6 × 1158.4 = 695.04px 向左。
  - 推近：格子从 120px 变到 126px（120 × 1.05，终点是整数像素），缩放中心是画面中心 (960, 540)。网格的起点跟着变：从 (0, 0) 到 (-743px, -27px)，其中 -743 = round(960 × (1 − 1.05) − 695.04)，-27 = 540 × (1 − 1.05)。起点取整，停住时所有线都落在整数像素上，粗细和亮度一致。线宽始终 2px。
  - 不用比画布大的缩放层，直接改 `background-size` 和 `background-position`，网格一直铺到四边。
- 为什么两层同一条缓动：横移和推近是同一个镜头动作，只是被拆成两个数。同缓动、同起止，所以看起来是一只手在推一台滑轨车，不是先后两步。
- 最快速度出现在 1.6 秒：文字层约每帧 24px，背景约每帧 14.5px。快，但是一整句字在扫过，视觉上是连续的横移。运动模糊没有用（见已知取舍）。
- 停住后不晃、不呼吸。

## 逐拍节拍表
| 拍 | 起止秒 | 画面 | 镜头 | 转场 | 屏幕文案原文 |
| --- | --- | --- | --- | --- | --- |
| move | 0.00 - 3.20 | 一开始只看见句子的前 15 个字，「片」只露出左边一小条在右缘；背景网格铺满 | 文字层 x 0 → -1158.4px，scale 1 → 1.15；背景层向左 695.04px（终点起点取整为 -743px），格子 120 → 126px；全部 `power2.inOut` | 无 | 从一个想法，到一支能发出去的片子 |
| hold | 3.20 - 4.50 | 「片子」停在画面正中（中心 x = 960，y = 540），整句的前半句已经移出画面左缘 | 静止 | 无 | 同上 |

英文版：「From one idea to a film you can ship」，`keyWord` 用「ship」。代码用测量得到的字符位置算横移和缩放中心，所以英文宽度不一样也能让「ship」停在正中（已临时换成英文跑门禁，在 3.2 秒截帧确认「ship」落在画面正中，之后改回）。西文单词之间的空格靠 `white-space: pre` 保留。

## 参数接线
所有参数都是 `project/compositions/truck.html` 根元素上 `data-composition-variables` 声明的变量，用户的 AI 在 `index.html` 的 `#truck` 上用 `data-variable-values` 覆盖。

| 变量 | 默认值 | 说明 |
| --- | --- | --- |
| headline | 从一个想法，到一支能发出去的片子 | 整句原文，单行，要比画面宽 |
| keyWord | 片子 | 必须是 headline 的最后一段原文，镜头停在它上面，它被染成强调色；不是结尾就不染色，镜头停在整句中心 |
| accentColor | #7FD99A | 强调色 |
| bg | #0F1712 | 底色 |
| ink | #ECF2EE | 字色 |
| lineColor | #1F2B24 | 背景线颜色 |
| fontSize | 120 | 字号（px） |
| pushScale | 1.15 | 文字层推近终点倍率 |
| bgPanRatio | 0.6 | 背景横移距离占文字层的比例 |
| moveDuration | 3.2 | 横移加推近的时长（秒） |
| moveEase | power2.inOut | 两条 tween 共用的缓动 |

没有做成变量的两个常量，在 `project/compositions/truck.html` 的脚本里：`BG_END = 1.05`（背景格子推近终点倍率，格距 126px）、`LEFT = 160`（句子起点 x）。总时长 4.5 秒由 `index.html` 根和 `#truck` 的 `data-duration` 决定。

## 禁用项
先横移再推近分成两段；背景粒子或光斑；停住后再晃动；暗角和光晕；渐变；画面上任何标签、说明、进度文字；标题入场动画（淡入、上滑、逐字）；呼吸或漂浮循环；横移和推近用不同缓动或错开起止。

## 已知取舍
- 开场没有入场动作：这条只演示横移加推近这一个手法，第一帧就是完整画面。
- 运动模糊：试过在根上写 `data-motion-blur="on"`，快门 120 和 360 都试了，成片 1.5 秒（最快处）的帧上字边缘完全一样，没有任何效果，所以没有写进代码。最快约每帧 24px，实际看是连续的。
- 本条的缩放中心和横移都靠 `offsetLeft` 和 `offsetWidth` 测量，字体加载完后会再测一次并 `invalidate()`；成片和浏览器截图一致（0、1.6、3.6、4.4 秒帧已对过）。
- 网格是纯色细线，没有渐变，不会出色带。
- 最快处没有拖影，是已验证的限制（见上一条）。想更顺滑，把 `moveDuration` 调到 3.6 秒，每帧位移会降下来，上限是参数范围的最大值。
- 停住后右半边只有空底、左缘「支」被切掉一半：这是「关键词落正中」的必然结果。缩放后每个字 140.76px 宽，「片子」中心定在 960，左缘必然落在字中间；不为凑齐字边去移动关键词，那样就不在正中了。
- 句子右端在开场时被画面裁掉，这是故意的（`data-layout-allow-overflow`）：「比画面还宽」就是这条的前提。
```
