Skip to content

艺术动画skill:35种艺术风格、9种解说语法,用代码让画动起来。

Initial public release

alchaincyf445c0752a7d9
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a9473e2
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,25 @@
+# macOS
+.DS_Store
+**/.DS_Store
+
+# Python
+__pycache__/
+
+# 渲染与合成产物(可重新生成)
+*.mp4
+*.mov
+*.wav
+
+# Local credentials and private working files
+.env
+.env.*
+!.env.example
+*.pem
+*.key
+*.p12
+*.pfx
+*.log
+.venv/
+node_modules/
+_archive/
+_private/
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..d1ccb61
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,22 @@
+# 发布包更新 · 2026-10-06
+
+- 同步35种当前艺术风格目录和第9种讲解员语法;8种语法仍提供参数化片段。
+- 加入口播整片代码快照、文字框景QA和浅底字幕区检查;说明需自备素材的范围。
+- 私人反馈、角色源提示词、未公开依赖与开发Git历史不随包发布。
+- 保留公开副本的思源黑体、原创示例配乐和角色使用边界;补齐第三方笔顺数据许可。
+
+# CHANGELOG
+
+- 2026-10-04 v0.1 · 从「艺术史速通」复刻沉淀:拆解法(01)、五层机制(02)、一帧先行四路线(03)、纯代码绘制(04)、节奏与配乐(05)、口播驱动草案(06);16 张风格配方卡;完整引擎+16 个场景;breakdown.py 拆解脚本(网格拟合取「80% 内点下最大步长」);key_green.py 保坐标抠图;音轨合成模板。
+- 2026-10-04 v0.3 · 迁移测试 A–D 回流进库:lib 拆出 brush.js(毛笔飞白/墨晕/流线长笔/水彩/厚涂/剪刀折线)、render.js(照片网点/点彩/赛璐珞/Kirby 阴影/体积/长影子/双版本光影/光照图/皮影/手剪位移/霓虹)、post.js(VHS/胶片/泛光/光晕/纹理叠角色/褪色);RIG.limb 端帽修正、猫身与白胸平滑、drawGirl/drawCat 分层钩子、非等比拉长、刚体枢轴;角标可插拔且转场中点硬切;转场按 eras 自动加载、缓存可按段;霞鹜文楷子集+font_subset.py+U.assertGlyphs(查 cmap);20 段新风格进 scenes/,全风格样片 eras_gallery.js(36 段,?film=gallery);qa 加转场冒烟、--film。
+- 2026-10-04 v0.4 · YouTube 解说动画语法 8 种(Kurzgesagt / Vox / 白板 / storytime / 动态文字 / 3b1b / 发布会 / 财经图表)收进 skill:
+ lib 新增 motion(MO)、camera(CAM)、diagram(DG)、typo(TY)、chart(CH)、ui(UI)、collage(CL)、toon(TOON)八个库;transitions.js 新增 13 个解说转场(same / lensReveal / matchCut / whip / smash / fillZoom / bands / push / zoomThrough / blurPush / expandRect / slidePush / fadeShift);
+ 引擎支持 window.BPM、段写 dur(秒)、transition.punch / window.PUNCH、SCENE_LIBS / SCENE_DIR、?film=demos/<语法>;8 支示范片进 demos/(与实验原片逐像素一致);
+ 参数化片段 clip.html+clips/<语法>.js+render.py --spec(时长精确、竖屏、--alpha 出 ProRes 4444),给口播管线当动画段,8 份样例在 engine/examples/;
+ 字体:普惠体四字重与霞鹜文楷扩到 GB2312 全部汉字(font_subset.py --gb2312),CMU / Inter / Roboto Condensed / 思源子集;
+ 文档 references/09-视频动画语法.md(总览、选语法决策表、跨语法通用规律、库速查、片段契约),语法卡 8 张进 references/动画语法/、总览图进 assets/动画语法/。
+
+- 2026-10-05 00:34:23 +0800:一支口播片实战回流:按解释任务混用Vox与3b1b、固定音轨字幕后重构画面,证据与边界见07号新条目。
+
+- 2026-10-05 v0.5 · 开源整理:去掉本机路径与合作项目信息;中文黑体换成思源黑体 Noto Sans SC(family 名沿用 PuHui-*),补字体许可清单;全风格样片移到 Release;加 README / LICENSE。
+- 2026-10-05 v0.6 · 开源第二轮:Vox 示范片的人物改用卡通帧,写实人像不再随仓库;配乐脚本换成原创示例乐谱,音轨文档改成「方法+原创示例」;洞穴段标题换成原创文字;收进长卷穿越片示范 demos/long_scroll(骨架+埃及、莫奈、8-bit 三段)与 11 号文档。
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..ed67368
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2026 alchaincyf (花叔 · 花生)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..0dd3b7a
--- /dev/null
+++ b/README.md
@@ -0,0 +1,169 @@
+<div align="center">
+
+<img src="assets/showcase/hero.png" alt="huashu-art-motion电影画廊:35种艺术风格,9种解说语法" width="100%" />
+
+# huashu-art-motion · 艺术动画
+
+让你的coding agent,把艺术风格写成会动的画。
+
+35种艺术风格 · 9种解说语法 · 8种参数化片段 · 口播整片参考代码
+
+```sh
+npx skills add alchaincyf/huashu-art-motion
+```
+
+[看动画](#动画样片) · [看风格](#看效果) · [开始使用](#里面有什么) · [下载完整样片](https://github.com/alchaincyf/huashu-art-motion/releases/latest)
+
+</div>
+
+## 动画样片
+
+画里真的会动。下面三段来自同一支穿越短片,场景用代码画,角色用生成帧合成。
+
+<img src="assets/showcase/monet.gif" alt="莫奈日本桥:打水漂,水面泛起涟漪" width="100%" />
+
+日本桥上的一次水漂。
+
+<table><tr>
+<td width="50%"><img src="assets/showcase/egypt.gif" alt="古埃及:与圣甲虫互动" width="100%" /><br/>古埃及 · 圣甲虫</td>
+<td width="50%"><img src="assets/showcase/pixel.gif" alt="8-bit:顶方块出金币" width="100%" /><br/>8-bit · 顶出金币</td>
+</tr></table>
+
+## 看效果
+
+<img src="assets/全风格总览.jpg" alt="35种艺术风格真实样片总览" width="100%" />
+
+35段样片各取一帧:同一位少女、同一只橘白猫、同一张桌子,从公元前 40000 年的岩洞一路穿到 2026 年。每一段都在动:梵高的星空在转,马赛克的颜色从石块上流过去,水墨晕染把画面带进下一个时代。
+
+👉 [下载全风格样片(MP4)](https://github.com/alchaincyf/huashu-art-motion/releases/latest)
+
+长卷穿越片:一个人从左走到右,跨过边界的那一刻,世界和他自己的画风一起换(下图是收进仓库的 3 段示范:埃及壁画 → 莫奈《日本桥》→ 8-bit):
+
+<img src="assets/长卷穿越_总览.jpg" alt="长卷穿越片示范:埃及壁画、莫奈日本桥、8-bit 像素" width="100%" />
+
+8种解说语法各有一支可运行示范片(下图每镜取一帧)。此外还有第9种「讲解员式财经科普」,提供语法卡和需自备角色的整片代码快照。白板适合跟着口播画关系,Vox适合图形与信息拼贴:
+
+| | |
+|---|---|
+| <img src="assets/动画语法/y1_kurzgesagt_总览.jpg" alt="Kurzgesagt 风格" /> Kurzgesagt:扁平无描边、尺度穿行 | <img src="assets/动画语法/y2_vox_总览.jpg" alt="Vox 风格" /> Vox:剪报、红线、荧光笔 |
+| <img src="assets/动画语法/y3_whiteboard_总览.jpg" alt="白板风格" /> 白板:笔尖揭开线稿 | <img src="assets/动画语法/t1_3b1b_总览.jpg" alt="3Blue1Brown 风格" /> 3Blue1Brown:一个对象形变成下一个 |
+| <img src="assets/动画语法/y4_storytime_总览.jpg" alt="storytime 风格" /> Storytime:反应特写、笑点停顿 | <img src="assets/动画语法/y5_kinetic_type_总览.jpg" alt="动态文字" /> 动态文字:主词砸进来 |
+| <img src="assets/动画语法/t2_keynote_ui_总览.jpg" alt="发布会风格" /> 发布会:光斑底、毛玻璃卡、大数字 | <img src="assets/动画语法/t3_finance_chart_总览.jpg" alt="财经图表" /> 财经图表:先轴、后数据、只标一件事 |
+
+---
+
+## 能做什么
+
+| 你说 | 它做 |
+|---|---|
+| 「复刻这个动画」「拆一下这段」 | 先跑拆解脚本量出转场、节拍网格、每段运动热图,再按机制用代码复刻 |
+| 「做个梵高/莫奈/包豪斯那种的动画」 | 先设计一帧,再让它动起来;35张风格配方卡当起点 |
+| 「用我的口播做一段艺术动画」 | 镜头表 → 定风格 → 世界画布加镜头 → 输出一条画面轨 |
+| 「做一个人穿过一幅幅名画的片子」 | 长卷骨架:每个世界一个段文件,主角一路往右走,跨边界换画风,镜头只进不退 |
+| 「做解说视频的动画段」 | 按口播选语法,喂一份 JSON,出一段时长精确到帧的片段(横竖屏、可透明底) |
+| 「画面里要有人」 | 人交给生图模型出帧,代码负责合成、换帧和材质 |
+| 「配个乐、卡节奏」 | BPM 网格、动机换乐器、结尾音效序列,纯代码合成 |
+
+交付前有一道数字验收:`qa.py` 量稳定、效率、动感、流畅及文字框景线索,再派一个没参与制作的 agent 只看成片挑问题。
+
+---
+
+## 里面有什么
+
+| | 数量 |
+|---|---|
+| 艺术风格配方卡(参数、母题动作、签名转场、当前短板) | 35张,`references/风格配方/` |
+| 对应的场景代码 | 35个,`scripts/engine/scenes/` |
+| 解说动画语法卡 | 9份;其中8种附示范片、参数化片段与示例spec |
+| 口播整片参考代码 | 混合风格、白板、Vox、讲解员;需自备部分素材,详见目录README |
+| 长卷穿越片示范(骨架+3 段+角色帧库) | 1 支,`scripts/engine/demos/long_scroll/` |
+| 转场 | 艺术风格签名转场与解说转场,包含淡入、硬切和纸面转场 |
+| 绘画与动画库(笔刷、渲染器、后期、骨架、镜头、图表、排版……) | 17 个,`scripts/engine/lib/` |
+| 方法文档(拆解、机制、一帧先行、纯代码绘制、节奏配乐、角色、长卷……) | 12篇,`references/01`–`12` |
+
+```
+huashu-art-motion/
+├── SKILL.md # 先判断任务,再按表读对应文档
+├── references/ # 01–12方法文档、35张风格配方卡、9张语法卡、正面经验
+├── assets/ # 总览图(README 用)
+└── scripts/
+ ├── engine/ # 可整个复制走的动画工程:引擎、转场、库、场景、示范片、片段
+ ├── analyze/breakdown.py # 把参考动画拆成「能写代码的地图」
+ ├── qa.py # 一键验收
+ ├── audio/ # 纯代码合成配乐的模板
+ └── font_subset.py ... # 字体子集、绿幕抠图
+```
+
+依赖:[uv](https://docs.astral.sh/uv/)、ffmpeg、Playwright Chromium(第一次跑 `uv run --with playwright playwright install chromium`)。试一下:
+
+```sh
+cd huashu-art-motion
+uv run --with playwright python scripts/engine/render.py --solo 09_postimp --stills 0.3 --out 试渲 # 梵高那一段的一帧
+uv run --with playwright python scripts/engine/render.py --spec scripts/engine/examples/t3_finance_chart.json --out 财经图表.mp4
+```
+
+---
+
+## 背后的故事
+
+2026 年 10 月初,我在 X 上看到 Tak([@cherry_mx_reds](https://x.com/cherry_mx_reds/status/2106095190285144331))的一支 15 秒动画:一位少女和一只猫穿过 40000 年艺术史,每个时代只有一秒左右,但画里的东西都在动。
+
+我让 Claude 复刻它。第一版是「一张张画之间做转场」,被我否了:原片每个时代可能就一秒,但画里的元素完全是流动的。于是改成先拆解(量转场、拟合节拍网格、看每段哪里在动),再用代码一层层把画画出来、让它动起来。
+
+做的过程中我跟它说:「我们不只是为了复刻,我需要你积累经验。」所以这个 skill 里记的不只是代码,还有哪些做法被证明有效(`references/07-正面经验.md`)、每种风格的坑和短板。之后又派了 4 组只读 skill 的 agent 去做它没见过的 20 种风格,把它们各自造的轮子收成统一的库;再加上 8 种 YouTube 解说动画语法,接进了我自己的口播视频管线。最后用同一套东西做了《花叔穿越名画》:23种画风、2分08秒,我从洞穴一路走到 2026,骨架和其中 3 段也收进来了。
+
+---
+
+## 致谢
+
+- **Tak([@cherry_mx_reds](https://x.com/cherry_mx_reds))** 的《Art History Speedrun》是这个 skill 的起点。16 个艺术时代的场景构图和「少女+猫穿越」的设定沿用了原片的思路,画面全部用代码重新画,配乐脚本里是原创示例乐谱(只保留拆解方法,不保留对原曲的转录);仓库里不含原片的帧、截图或音频文件。想看原作请去他的 X。
+- 解说语法卡里拆解过的频道和资料(Kurzgesagt、Vox、3Blue1Brown、RSA Animate、TheOdd1sOut 等)都在各张卡的「一手参考」里给了链接,仓库只记测量出来的参数,不含他们的画面。
+- 字体都是 SIL OFL 1.1 开源字体,清单和版权见 `scripts/engine/lib/fonts/LICENSES.md`。
+
+---
+
+## 关于作者
+
+| | |
+|:---|:---|
+| 🌐 官网 | [bookai.top](https://bookai.top) · [huasheng.ai](https://www.huasheng.ai) |
+| 𝕏 Twitter | [@AlchainHust](https://x.com/AlchainHust) |
+| 📺 B站 | [花叔v](https://space.bilibili.com/14097567) |
+| ▶️ YouTube | [@Alchain](https://www.youtube.com/@Alchain) |
+| 📕 小红书 | [花叔](https://www.xiaohongshu.com/user/profile/5abc6f17e8ac2b109179dfdf) |
+| 💬 公众号 | 微信搜「花叔」 |
+
+## 许可证
+
+代码和文档:MIT。随便用,随便改,随便造。
+
+例外:笔顺衍生数据`reference_films/spacex/spacex_wb/assets/strokes.js`沿用Arphic Public License(原文随文件附带);`scripts/engine/lib/fonts/` 里的字体沿用各自的 OFL 许可;花叔的卡通形象与角色帧(`scripts/engine/demos/_shared/hero/`、`scripts/engine/demos/long_scroll/frames/`、`assets/角色/`)以及总览图、示范视频中包含的同一形象,只用于本 skill 的示范,不随 MIT 授权用于其他用途。
+
+---
+
+<div align="center">
+
+**[女娲](https://github.com/alchaincyf/nuwa-skill)** 造 Skill。**[达尔文](https://github.com/alchaincyf/darwin-skill)** 让 Skill 进化。**艺术动画** 让画动起来。
+
+MIT License © [花叔 Huashu](https://github.com/alchaincyf)
+
+</div>
+
+---
+
+<div align="center">
+<sub>作者的其他项目 · also by 花叔</sub>
+
+[![FanBox · Coding Agent 的驾驶舱](https://raw.githubusercontent.com/alchaincyf/fanbox/master/assets/promo-banner.jpg)](https://github.com/alchaincyf/fanbox)
+
+</div>
+
+---
+
+## English
+
+**huashu-art-motion** is an agent skill for making animation with code, where the paintings actually move. It ships 35 art-style recipes (cave painting, Egyptian murals, Van Gogh, Klimt, Bauhaus, Kirby comics, 8-bit, vaporwave, Shinkai and more), each with a working Canvas scene, a style "renderer" and a signature transition; 8 explainer-video grammars (Kurzgesagt, Vox, whiteboard, storytime, kinetic type, 3Blue1Brown, keynote UI, finance charts) with demo films and parameterized clips you drive with a JSON spec, frame-accurate and in landscape, portrait or alpha; a long-scroll skeleton where a character walks left to right through one painting after another (3 sample worlds included); plus a breakdown script that maps a reference animation into cuts, beat grid and motion heatmaps, and a QA script that measures stability, cost per frame, motion and smoothness.
+
+It started as a code-only recreation of Tak's ([@cherry_mx_reds](https://x.com/cherry_mx_reds/status/2106095190285144331)) 15-second *Art History Speedrun*. The scene layouts and the girl-and-cat premise follow his original; every frame here is redrawn in code, and no frames, screenshots or audio from the original are included.
+
+Install: `npx skills add alchaincyf/huashu-art-motion`. Requires uv, ffmpeg and Playwright Chromium. The skill content is in Chinese. The ninth grammar, presenter-led explainers, ships as a reference implementation and requires your own character assets. Full-narration examples are code snapshots, not ready-to-render projects. Code and docs are MIT; the bundled stroke medians retain the Arphic Public License; bundled fonts keep their SIL OFL licenses; the Huashu character artwork, including its appearance in overview images and demo videos, is for demo use only.
diff --git a/SKILL.md b/SKILL.md
new file mode 100644
index 0000000..d08c50a
--- /dev/null
+++ b/SKILL.md
@@ -0,0 +1,67 @@
+---
+name: huashu-art-motion
+description: "艺术与视频动画:拆解复刻动画;代码画35种艺术风格并让画活;9种解说动画语法,8种可按口播参数渲片段;含口播整片参考代码及框景检查;人用AI生帧。"
+---
+
+# 艺术动画
+
+## 你是谁
+
+你同时是这支片子的导演、分镜师、原画师、动画师和剪辑师,而且你画画用的是代码。你对成片只有一个标准:观众一眼认得出这是哪位艺术家/哪个时代的画,而且画是活的,不是图片在切换。
+
+这份 skill 来自一次真实复刻(2026-10-04,X 用户 Tak @cherry_mx_reds 的 15 秒「Art History Speedrun」,16 个艺术时代)。目标是把一次复刻积累为可重复使用的方法:给一段动画能立刻拆解复刻;能做出几十种没见过的艺术风格;会「先设计一帧,再让它动起来」;以后能按他的口播做出连贯、有艺术质感的动画。
+
+## 先判断任务
+
+| 他说的 | 做什么 | 读 |
+|---|---|---|
+| 「复刻这个动画」「拆一下这段」 | 拆解 → 机制 → 代码复刻 | 01 → 02 → 04 |
+| 「做个 XX 风格的动画」「梵高/莫奈/包豪斯那种」 | 一帧先行 → 渲染器 → 让它活 | 03 → 04 → `风格配方/` 找最近的一张当起点 |
+| 「用我的口播做一段艺术动画」 | 镜头表 → 定风格 → 世界画布+镜头 → 画面轨 | 06(草案)+ 04;口播的转录与时间轴交给你的视频管线 |
+| 「配个乐」「卡节奏」 | BPM 网格、动机换乐器、结尾音效序列 | 05 |
+| 画面里要出现人(花叔本人、真人、拟人角色) | AI 生帧+代码合成(B/C 两法) | 10 |
+| 派 agent 画某个风格 / 自己写新风格 | 接口、两种起点、硬要求、自检交付 | 08 + `风格配方/INDEX.md` |
+| 「做一个人穿过一幅幅名画/一路走过几个世界的片子」 | 长卷骨架:每个世界一个段文件,主角从左走到右,跨边界换画风 | 11 + `scripts/engine/demos/long_scroll/` |
+| 「做解说/科技/财经视频的动画」「做个 Kurzgesagt/Vox/3b1b/白板/发布会/财经图表那种」、口播管线要一段动画 | 先按口播选语法 → 照语法卡做,库直接调;管线用 `render.py --spec` 出时长精确的片段 | 09 + `动画语法/<语法>.md` |
+
+口播整片先读`references/12-口播整片与经验回流.md`;讲解员风格再读`references/动画语法/y6_presenter_explainer.md`。
+
+## 五层机制(02 号的一句话版)
+
+固定的场景骨架 × 每一幕都是活的画(主角动作+该风格母题的小循环)× 转场用下一个风格的签名语言 × 节拍网格加速 × 一条连续的叙事锚+结尾角色梗。换题材照样成立。
+
+## 窄桥:照字面做
+
+- **画面必须动。** 每一幕至少一个主动作+2个母题循环,自检要量帧差(避开转场后0.35s的镜头冲击)。
+- **场景与风格用代码画;人用AI生帧,代码负责合成。** 场景、风格、运镜、转场、物件用Canvas程序化绘制。真人、本人和拟人角色采用已有角色帧,或按画风生成sprite帧再抠图合成;代码控制位置、大小、换帧时机和材质。几何角色可以用代码画。见`references/10-角色.md`。
+- **复刻是学机制,不是逐像素。** 提取场景、运动与转场规律,再用于新题材。
+- **三方向硬门**:新的角色诠释或风格方向,先在同一帧上出三个给他挑,指定了风格也不豁免。
+- **确定性**:所有随机用种子,同一时刻渲两次逐像素一致。
+- **独立审片**:成片交付前派一个没参与制作的 agent 只看成片挑问题。
+- 角色涉及未成年人(如 17 岁)时,服装一律端庄长款;给生图模型写「短裙」会被审核整张拒绝。
+
+## 开阔地:当起点,不当配额
+
+`风格配方/` 里 35 张卡(总表 `风格配方/INDEX.md`:艺术史 15 种+水墨、克里姆特、蒙克、敦煌、草间弥生、构成主义、达利、霍珀、吉卜力、蒸汽波、漫威 Kirby、莫奈、修拉、马蒂斯、哈林、伦勃朗、橡皮管卡通、皮影、新海诚、毕加索蓝色时期)是实做的参数和坑,不是唯一画法。表里标了每种的当前质量和短板——下一次做到它时先超越短板。你有更好的渲染器就去写,做出来和原作/参考并排给人看。新风格做完,把配方卡补进来。
+
+## 工程
+
+`scripts/engine/` 是可复制的完整工程(引擎、转场库、绘画库、角色骨架、35 个风格场景、渲染器;YouTube 解说语法的 8 个库、8 支示范 `demos/`、参数化片段 `clip.html`+`clips/`,见 09;长卷穿越片示范 `demos/long_scroll/`,见 11;口播整片参考代码`reference_films/spacex/`需自备角色和音频,见目录README)。开新片:复制到项目的 `代码工程/`,改 `eras.js` 段落表,写 `scenes/<id>.js`。
+
+```sh
+E=<项目>/代码工程
+uv run --with playwright python $E/render.py --solo <id> --stills 0,0.3,0.6 --out 渲染/<id> # 单段静帧
+uv run --with playwright python $E/render.py --out 成片.mp4 --audio 配乐.wav # 整片
+python3 $E/compare.py --a 参考.mp4 --b 成片.mp4 --times 1.5,2.0 --out 对比.jpg # 并排
+uv run scripts/analyze/breakdown.py --video 参考.mp4 --out 拆解/ # 拆解地图
+```
+
+字体在 `scripts/engine/lib/fonts/`(woff,各字体许可见同目录 `LICENSES.md`)。依赖:[uv](https://docs.astral.sh/uv/)、ffmpeg(出片与拆解)、Playwright Chromium(首次要 `uv run --with playwright playwright install chromium`)。
+
+## 验收
+
+交付前必跑 `uv run scripts/qa.py --project <工程>`(稳定/效率/动感/流畅及文字框景线索)+派独立 agent 只看成片审片。浅底无字幕成片再用`uv run --with numpy python scripts/subzone_gate.py 成片.mp4`检查图形进入字幕区;纹理底不适用。两样都做完才算完成。经验先看 `07-正面经验.md`。
+
+## 回流
+
+每做完一支:新风格写进 `风格配方/` 并更新 INDEX,**做对了的事写进 `07-正面经验.md`(做法+证据+为什么+何时用)**,新坑写进对应 reference 的「踩过的坑」,`CHANGELOG.md` 记一行。实际与这里不符时以实际为准,然后把这里改对。
diff --git a/assets/showcase/egypt.gif b/assets/showcase/egypt.gif
new file mode 100644
index 0000000..fac4f54
Binary files /dev/null and b/assets/showcase/egypt.gif differ
diff --git a/assets/showcase/hero.png b/assets/showcase/hero.png
new file mode 100644
index 0000000..1caac91
Binary files /dev/null and b/assets/showcase/hero.png differ
diff --git a/assets/showcase/monet.gif b/assets/showcase/monet.gif
new file mode 100644
index 0000000..9a70a6f
Binary files /dev/null and b/assets/showcase/monet.gif differ
diff --git a/assets/showcase/pixel.gif b/assets/showcase/pixel.gif
new file mode 100644
index 0000000..1e6568d
Binary files /dev/null and b/assets/showcase/pixel.gif differ
diff --git "a/assets/\345\205\250\351\243\216\346\240\274\346\200\273\350\247\210.jpg" "b/assets/\345\205\250\351\243\216\346\240\274\346\200\273\350\247\210.jpg"
new file mode 100644
index 0000000..9f834ab
Binary files /dev/null and "b/assets/\345\205\250\351\243\216\346\240\274\346\200\273\350\247\210.jpg" differ
diff --git "a/assets/\345\212\250\347\224\273\350\257\255\346\263\225/t1_3b1b_\346\200\273\350\247\210.jpg" "b/assets/\345\212\250\347\224\273\350\257\255\346\263\225/t1_3b1b_\346\200\273\350\247\210.jpg"
new file mode 100644
index 0000000..822f07d
Binary files /dev/null and "b/assets/\345\212\250\347\224\273\350\257\255\346\263\225/t1_3b1b_\346\200\273\350\247\210.jpg" differ
diff --git "a/assets/\345\212\250\347\224\273\350\257\255\346\263\225/t2_keynote_ui_\346\200\273\350\247\210.jpg" "b/assets/\345\212\250\347\224\273\350\257\255\346\263\225/t2_keynote_ui_\346\200\273\350\247\210.jpg"
new file mode 100644
index 0000000..2db9602
Binary files /dev/null and "b/assets/\345\212\250\347\224\273\350\257\255\346\263\225/t2_keynote_ui_\346\200\273\350\247\210.jpg" differ
diff --git "a/assets/\345\212\250\347\224\273\350\257\255\346\263\225/t3_finance_chart_\346\200\273\350\247\210.jpg" "b/assets/\345\212\250\347\224\273\350\257\255\346\263\225/t3_finance_chart_\346\200\273\350\247\210.jpg"
new file mode 100644
index 0000000..8ae77d0
Binary files /dev/null and "b/assets/\345\212\250\347\224\273\350\257\255\346\263\225/t3_finance_chart_\346\200\273\350\247\210.jpg" differ
diff --git "a/assets/\345\212\250\347\224\273\350\257\255\346\263\225/y1_kurzgesagt_\346\200\273\350\247\210.jpg" "b/assets/\345\212\250\347\224\273\350\257\255\346\263\225/y1_kurzgesagt_\346\200\273\350\247\210.jpg"
new file mode 100644
index 0000000..df0f5de
Binary files /dev/null and "b/assets/\345\212\250\347\224\273\350\257\255\346\263\225/y1_kurzgesagt_\346\200\273\350\247\210.jpg" differ
diff --git "a/assets/\345\212\250\347\224\273\350\257\255\346\263\225/y2_vox_\346\200\273\350\247\210.jpg" "b/assets/\345\212\250\347\224\273\350\257\255\346\263\225/y2_vox_\346\200\273\350\247\210.jpg"
new file mode 100644
index 0000000..92f6230
Binary files /dev/null and "b/assets/\345\212\250\347\224\273\350\257\255\346\263\225/y2_vox_\346\200\273\350\247\210.jpg" differ
diff --git "a/assets/\345\212\250\347\224\273\350\257\255\346\263\225/y3_whiteboard_\346\200\273\350\247\210.jpg" "b/assets/\345\212\250\347\224\273\350\257\255\346\263\225/y3_whiteboard_\346\200\273\350\247\210.jpg"
new file mode 100644
index 0000000..0e19c2c
Binary files /dev/null and "b/assets/\345\212\250\347\224\273\350\257\255\346\263\225/y3_whiteboard_\346\200\273\350\247\210.jpg" differ
diff --git "a/assets/\345\212\250\347\224\273\350\257\255\346\263\225/y4_storytime_\346\200\273\350\247\210.jpg" "b/assets/\345\212\250\347\224\273\350\257\255\346\263\225/y4_storytime_\346\200\273\350\247\210.jpg"
new file mode 100644
index 0000000..b2d9ded
Binary files /dev/null and "b/assets/\345\212\250\347\224\273\350\257\255\346\263\225/y4_storytime_\346\200\273\350\247\210.jpg" differ
diff --git "a/assets/\345\212\250\347\224\273\350\257\255\346\263\225/y5_kinetic_type_\346\200\273\350\247\210.jpg" "b/assets/\345\212\250\347\224\273\350\257\255\346\263\225/y5_kinetic_type_\346\200\273\350\247\210.jpg"
new file mode 100644
index 0000000..b1a547c
Binary files /dev/null and "b/assets/\345\212\250\347\224\273\350\257\255\346\263\225/y5_kinetic_type_\346\200\273\350\247\210.jpg" differ
diff --git "a/assets/\350\247\222\350\211\262/\350\212\261\345\217\224\345\275\242\350\261\241_\345\257\271\346\257\224.jpg" "b/assets/\350\247\222\350\211\262/\350\212\261\345\217\224\345\275\242\350\261\241_\345\257\271\346\257\224.jpg"
new file mode 100644
index 0000000..5460db2
Binary files /dev/null and "b/assets/\350\247\222\350\211\262/\350\212\261\345\217\224\345\275\242\350\261\241_\345\257\271\346\257\224.jpg" differ
diff --git "a/assets/\351\225\277\345\215\267\347\251\277\350\266\212_\346\200\273\350\247\210.jpg" "b/assets/\351\225\277\345\215\267\347\251\277\350\266\212_\346\200\273\350\247\210.jpg"
new file mode 100644
index 0000000..26c8373
Binary files /dev/null and "b/assets/\351\225\277\345\215\267\347\251\277\350\266\212_\346\200\273\350\247\210.jpg" differ
diff --git "a/references/01-\346\213\206\350\247\243.md" "b/references/01-\346\213\206\350\247\243.md"
new file mode 100644
index 0000000..0133872
--- /dev/null
+++ "b/references/01-\346\213\206\350\247\243.md"
@@ -0,0 +1,55 @@
+# 01 · 拆解:拿到一段动画,一小时内拆到能写成代码
+
+目标不是写观后感,是产出**能直接照着编程的规格**:每段的起止帧、转场机制和参数、镜内动作清单、计数器/字幕的数值曲线、构图坐标、音轨的网格与配器。文字是索引,数字和接触表才是正文。
+
+第一次实战:2026-10-04 拆 X 上的 15 秒「Art History Speedrun」(16 个艺术时代、15 个转场),全流程约 1.5 小时(分镜 agent 79 分钟、音轨 agent 22 分钟,并行)。
+
+## 一、先摸物理参数(5 分钟)
+
+```sh
+ffprobe -v error -show_entries format=duration:stream=codec_type,width,height,r_frame_rate,sample_rate -of default=nw=1 src.mp4
+```
+X 的视频从 syndication 接口拿最高档(`video_info.variants` 里挑最高码率),不要录屏。原片 60fps 就按 60fps 拆,帧号是之后所有规格的公共语言(秒 = 帧/60)。
+
+## 二、全貌三张图(10 分钟)
+
+1. **接触表**:4fps × 480 宽,30 帧一张,标时间戳。看一眼知道有几段、每段是什么。
+2. **关键帧总览**:每段挑一张最干净的整帧拼成 4×5。后面所有工作的地图。
+3. **频谱图**:`ffmpeg -lavfi showspectrumpic=s=1600x400:legend=1`。一眼看出音乐是否按段换配器、有没有坠落滑音、碎裂瞬态、拍点。谐波干净、16kHz 一刀切 = 代码合成+AAC。
+
+## 三、量出转场与节奏(15 分钟)
+
+**逐帧灰度差**:缩到 192×108 灰度,相邻帧平均绝对差。静止段 <2,转场段 10–37。阈值 5 + 去抖 12 帧,一次找全转场起点。存成 `diff.npy` 给所有 agent 共用。
+
+找到起点后**拟合网格**:起点间隔如果是常数的整数倍,就有 BPM 网格(本片:起点 = 84 + 14.06·n 帧,残差 < 0.45 帧,= 128 BPM 八分音符)。网格一旦确认,画面和音乐的所有时间都写成「第几个八分音符」。
+
+**每个转场一张 60fps 接触表**:从起点前 2 帧开始,每 2 帧取一张,取 0.5 秒,15 格。机制只能从这里看出来——「8 条竖条依次落下回弹」「20px 方块绕竖轴翻转、从猫的位置向外扩散」这种描述,粗看 4fps 图只会写成「方块转场」。
+
+**参考帧取「转场开始前最后一帧」**,不是你觉得好看的那一帧。取早了会把上一段转场的余波(碎石块)当成画面内容(埃及第一版踩到)。
+
+## 四、镜内运动:每段里到底什么在动(15 分钟)
+
+运动热图:每段静止区间内逐像素取最大帧差,红色叠在灰度底图上,标出「运动面积占比」。
+
+本片的结论推翻了第一印象:以为「每段就是一张画」,实际每段都有 2.5%–34% 的面积在动——岩画动物两张姿态交替奔跑、圣甲虫推太阳球、回纹带滚动、维苏威冒烟、金箔高光扫过、扑翼机飞过、四宫格换色……**没做这一步就开工,做出来就是「图片之间的转场」,会丢掉场景内部的连续运动。**
+
+热图告诉你「哪里动」,再到 60fps 帧里看「怎么动」(周期、幅度、是两帧交替还是连续)。
+
+## 五、分工给 agent 时的写法
+
+- 分镜 agent 和音轨 agent 并行,各给一份完整说明:素材路径、已知事实(帧率、时长、粗看的段落表)、要的产物(分镜表.md / spec.json / 接触表目录 / 音轨拆解.md / 合成脚本)、方法要求(用数据证实,不凭想象)、回复格式(摘要+最不确定的 3 处)。
+- 让它们**先修正你的清单**。本片我把「1993→2026 的光圈转场」认成了一个「孟菲斯时代」,分镜 agent 第一条就纠正了。
+- 全模态模型「听」音轨只当候选:乐器判断可信,BPM(报 120,实为 128)、动机音数、「每段一记嗖声」都是错的,必须用起音检测回校。
+
+## 六、产物清单(拆完应该有)
+
+| 产物 | 用途 |
+|---|---|
+| `分镜表.md` + `spec.json` | 每段起止帧、转场机制参数、镜内动作、计数器曲线、构图坐标 |
+| `转场/T*.jpg`(60fps 接触表) | 写转场代码时逐帧对照 |
+| `镜内运动/运动热图.jpg` | 每段动什么、动多大 |
+| `结尾动作/`(如有角色表演) | 逐帧质心、轨迹、物理参数(重力 px/帧²) |
+| `音轨拆解.md` + `synth.py`(模板:`scripts/audio/synth_艺术史速通.py`) | BPM 网格、每段八分音符数、动机、配器、音效序列 |
+| `关键帧总览.jpg` + `生图/ref/*.png` | 构图地图、每段参考帧 |
+
+脚本:`scripts/analyze/`(接触表、灰度差、转场接触表、运动热图),命令见各脚本 docstring。
diff --git "a/references/02-\346\234\272\345\210\266.md" "b/references/02-\346\234\272\345\210\266.md"
new file mode 100644
index 0000000..8fd1fde
--- /dev/null
+++ "b/references/02-\346\234\272\345\210\266.md"
@@ -0,0 +1,41 @@
+# 02 · 机制:「艺术史速通」为什么好看
+
+这一页整理可复用的场景与运动机制。换任何题材(科技史、城市变迁、一个人的十八岁到八十岁)都能照这五层搭。
+
+## 五层机制
+
+**1. 一个固定的场景骨架。** 16 个时代,窗、桌、猫、人、年份牌的位置几乎不动(±40px)。观众的眼睛有锚点,才看得清「变的是风格」。也因为位置固定,转场可以用画内物体当原点(马赛克从猫的位置扩散、光圈从杯子展开)。
+→ 做法:先定标准构图坐标,所有时代对齐到它。代码里是一份常量,不是每段各画各的。
+
+**2. 每个时代是一幅活的画。** 停留 0.25–1.4 秒,但画里一直在动:主角一个连续动作(端杯喝茶)+ 2–4 个**取自那个时代自己视觉母题**的小循环——岩画动物用「两张姿态交替」跑(这就是岩画多腿表示奔跑的动画化)、埃及圣甲虫推太阳、希腊回纹带滚动、罗马火山冒烟、哥特金箔高光、文艺复兴扑翼机、浮世绘巨浪、梵高星空旋转、包豪斯指针、波普四宫格换色。
+→ 做法:每段列「这个时代最有辨识度的 3 个形式元素」,让它们动起来。动作要在停留窗口里看得出来(短段节奏要快)。
+
+**3. 转场 = 下一个时代的签名语言。** 进埃及是石块/挂毯落下、进希腊是陶瓶滚筒转面、进罗马是马赛克砖翻面、进哥特是羊皮纸翻页、进文艺复兴是神光、进浮世绘是神奈川巨浪横扫、进印象派是笔触色点铺满、进梵高是星空漩涡、进新艺术是金边有机形生长、进立体主义是几何碎片、进包豪斯是红黄蓝几何旋转放大、进波普是闪电+网点、进 8-bit 是像素化、进光追是绿色线框→逐行渲染、进 2026 是三色同心环光圈。
+→ 做法:转场不从转场库里挑通用的,从「新风格最有辨识度的形式元素」里长出来。每个转场第一帧加镜头冲击(场景层放大到 1.03,约 20 帧回到 1.0,年份牌不缩放)——拍点上的那一下顿挫感来自它。
+
+**4. 节拍网格加速。** 128 BPM 不变,每段占的八分音符数递减:6 → 4×5 → 3×4 → 2×3 → 1×3 → 结尾放长到 9+。速度没变,听感和看感越来越急;最后一段放长给笑点留位置。转场时长跟着缩(0.4s → 0.13s),年份滚动也跟着缩(0.55s → 0.07s)。
+→ 做法:先列每段想要的时长,四舍五入到八分音符,再整体微调成规律的递减。所有剪点、音乐起音、音效都落在网格上。
+
+**5. 一个连续的叙事锚+结尾角色梗。** 年份计数器是全片唯一连续的东西:数值只由全局时间决定,转场时新旧两层显示同一个滚动中的数字,各用各的字体(40,000 BC 的岩画手写 → 1350 BC 的芦苇笔 → … → 2026 的几何无衬线)。结尾给角色一个梗(猫三次拍杯把杯子推下桌,少女惊呼,签名写出),用预备、挤压拉伸、跟随、二次动作把它演足——前面 11 秒是「看」,这 4 秒是「笑」,笑点让人转发。
+
+## 补充(2026-10-04 迁移测试 A–D)
+
+- **主角动作跨段连续**:叙事锚不只是计数器,主角的动作也要按全片时间走;每段重做一遍动作,观众看到的是「举杯五次」而不是「同一瞬间换了五种画风」。
+- **计数器用年份时段落必须按年代排**;不能重排就把角标换成序号或风格名(引擎角标可插拔)。转场中点硬切新旧角标,避免叠字。
+- **第一段没有转场可借时,让画「自己画出来」**(笔触写出、套色一版版落、像素一行行点亮)。
+- **签名转场越复杂,时长越长**:原片形状简单所以 0.4s 够;金箔、色带、飘带这类要 0.48–0.5s。
+
+## 换题材时怎么用
+
+| 层 | 本片 | 换成「一座城市的 100 年」可以是 |
+|---|---|---|
+| 骨架 | 窗/桌/猫/人 | 同一个街角:路灯、店招、行人、天际线 |
+| 活的画 | 时代母题小循环 | 每个年代的交通工具驶过、招牌字体闪烁、天上的东西(风筝→飞机→无人机) |
+| 转场 | 下一时代的签名语言 | 下一年代的媒介:胶片烧边、电视雪花、像素、扫描线 |
+| 节拍 | 128 BPM 递减 | 同 |
+| 锚+梗 | 年份计数器+猫拍杯 | 年份计数器+同一只鸽子每个年代都在偷吃东西 |
+
+## 不要学歪的地方
+
+- 不要把「16 个时代」当配额。机制是「风格在变、骨架不变」,3 个时代也成立。
+- 不要逐像素复刻原片。复刻是学机制的手段,交付物是你理解后的版本(花叔选了金发少女+橘白猫,就是在原片骨架上换角色)。
diff --git "a/references/03-\344\270\200\345\270\247\345\205\210\350\241\214\345\233\233\346\235\241\350\267\257\347\272\277.md" "b/references/03-\344\270\200\345\270\247\345\205\210\350\241\214\345\233\233\346\235\241\350\267\257\347\272\277.md"
new file mode 100644
index 0000000..58ffcc6
--- /dev/null
+++ "b/references/03-\344\270\200\345\270\247\345\205\210\350\241\214\345\233\233\346\235\241\350\267\257\347\272\277.md"
@@ -0,0 +1,37 @@
+# 03 · 一帧先行,再让它动:四条路线
+
+花叔要的方法:先设计一帧有艺术感的画面,再按要求让这帧动起来。2026-10-04 一个项目里四条路都实跑过,各有适用场景。
+
+| 路线 | 画面谁画 | 动作谁做 | 实测 | 什么时候选 |
+|---|---|---|---|---|
+| **A 纯代码** | Canvas 程序化绘制+风格渲染器 | 代码(编舞曲线、IK、粒子、沸腾线) | 艺术史复刻主线(花叔选定) | 要证明「模型直接用代码产出艺术动画」;要精确控制每个元素的运动;要换几十种风格(换渲染器就换风格);要和口播逐帧对齐 |
+| **B AI 分层素材+代码动** | 生图模型按图层画(绿幕、保留原画面坐标) | 代码(位移、弧线、挤压、物理、特效) | 2026 结尾段 11 张素材一次合成到位 | 画质要最高、角色要复杂表演;画风是写实/插画、代码画不出来时 |
+| **C 视频模型首尾帧** | 生图模型画一帧 | Seedance 首尾帧(首尾同一张) | Lovart Seedance 2.0 梵高试片:少女放杯再端起、星空转、猫甩尾,构图全程守住 | 要「整幅画都在流动」的有机感,又不要精确控制;示例/氛围镜头 |
+| **D 混合** | 背景用 B/C,角色用 A,或反过来 | 代码统一编排时间轴 | — | 大片:背景要质感、角色要可控 |
+
+## 共同的第一步:一帧设定稿
+
+不管走哪条路,先有一帧「对的画面」:
+- **有参考片**:把参考片该段「转场开始前最后一帧」当参考图喂给 gpt-image,prompt 写「完全保持参考图的构图、镜头、每件物品的位置和大小、配色和笔触,只改两处:……」。实测与原片 50% 叠加几乎逐像素重合,构图锁定靠参考图,不靠文字写坐标。
+- **没有参考片**:先定场景骨架(标准构图坐标),用骨架白模截图当参考图。
+- **三方向硬门**:角色诠释(本片:时代女装 / 同一人穿越 / 原装换头)在同一帧上出三张给人挑。选原片是男性角色的那一帧,差别最拉得开。
+
+设定稿的坑(都踩过):
+- 写未成年角色(17 岁)+任何「短裙」字样会被审核判 sexual 整张拒绝。服装一律写长款,加「服装端庄」。
+- 毛色写到部位:「橘白猫(头顶、背部和尾巴橘色虎斑,口鼻、胸口、肚子、四爪白色)」。只写「橘猫」会画成全身橘。
+- 描述里写动作(「端杯喝茶」)会压过参考图的姿势。要保持原姿势就只写「保持参考图里的手势」。
+- 要动的文字(年份、标题)让模型「去掉,留成干净背景」,交给代码画;画内装饰文字逐字写进 prompt。
+- 批量生图串行跑;验真看生图工具的输出目录新增文件数 = 出图数,且 PNG info 里没有 ImageMagick 的 date:create(有就说明是被拼出来的,不是模型生成的)。
+
+## 路线 B 的关键:绿幕素材保留原画面坐标
+
+用设定帧当参考图,prompt:「只画参考图里的 XX……其余全部是纯平涂 #00FF00,没有阴影地面文字。位置、大小、朝向与参考图完全一致。」生成出来的角色已经站在原画面坐标上。抠图时**不要裁到主体边框就丢坐标**——`scripts/key_green.py` 裁边同时把左上角写进 sprites.json,合成时按原坐标贴回,一次对齐。
+
+## 路线 C 的关键:首尾同帧
+
+Seedance 2.5/2.0 支持 frames2video。首帧和尾帧给同一张设定稿 → 画里的东西动起来又回到原构图,片段首尾能无缝接转场。prompt 结构:①镜头完全固定(不推拉摇变焦晃)②全程保持构图/画风/配色,不写实化、不增删物体、不出新文字 ③逐条列「画里什么动、怎么动」(来自拆解的运动清单)。生成 5 秒取最好的 1 秒左右、按节奏变速。
+通道:任何支持首尾帧(frames2video)的 Seedance 接入都行,要点在 prompt 本身;视频生成按次计费,先用短时长试一条。
+
+## 路线 A 的关键
+
+见 `04-纯代码绘制.md`。一句话:同一场景骨架 × 共享编舞 × 每个风格一个渲染器 × 角色单独一层后画 × 最后补线。
diff --git "a/references/04-\347\272\257\344\273\243\347\240\201\347\273\230\345\210\266.md" "b/references/04-\347\272\257\344\273\243\347\240\201\347\273\230\345\210\266.md"
new file mode 100644
index 0000000..ecb16a7
--- /dev/null
+++ "b/references/04-\347\272\257\344\273\243\347\240\201\347\273\230\345\210\266.md"
@@ -0,0 +1,92 @@
+# 04 · 纯代码绘制:用 Canvas 把一幅有艺术感的画画出来并让它活
+
+本页以纯代码绘制为主线:场景、几何角色和物件通过程序与风格渲染器实现;拟人角色的生成帧方案见10号。本页是第一次做完 16 种风格后的方法总结;每种风格的具体参数在 `风格配方/<id>.md`。
+
+## 一、工程骨架(`scripts/engine/`,复制一份就能开新片)
+
+```
+index.html 加载顺序:lib/fonts → lib/util → lib/paint → lib/rig → eras → transitions → scenes/index → engine
+eras.js 段落表:id、占几个八分音符(eighths)、转场{type,dur,delay,cx,cy}、年份牌样式
+scenes/<id>.js 每段一个文件:SCENES['<id>'] = { draw(c, lt, t) } ← 主要工作量在这里
+transitions.js 转场库:(c, A旧, B新, p, o) → 画一帧
+engine.js 节拍网格→各段 t0/t1;转场时新旧两段各画进离屏再交给转场;拍点镜头冲击;年份计数器(值只由全局 t 决定)
+lib/paint.js 噪声、纹理、手绘沸腾线、风格渲染器、区域色板 swatch、共享编舞 choreo、热气、粒子
+lib/rig.js 角色骨架:RIG.girl / RIG.cat → 各部位 Path2D + 锚点;drawGirl/drawCat(mode: fill/line);ik2、smooth、taper
+render.py 无头 Chromium 逐帧调 renderFrame(t) → PNG 管道 → ffmpeg 60fps,可混音轨;--solo <id> 单段预览、--stills 出静帧
+compare.py 原片|复刻 同时刻并排拼图
+```
+
+渲染速度:15 秒 60fps 整片约 90 秒(M 系列 Mac)。单段每帧大多 5–40ms,最重的梵高 110ms。
+
+## 二、一个风格怎么画(五层,标杆 `scenes/09_postimp.js`)
+
+> 五层是油画/版画类的默认顺序,不是万能的:**水墨**倒过来(纸是底,墨只往上加,大面积留白,不先铺满);**图案类**(草间、包豪斯)是「平涂上撒图案」,图案本身就是渲染器;**明暗法**是「先画亮版再乘光照图」。
+
+1. **平涂底稿**:大面积(墙、地、天、窗外)先用纯色/渐变画对位置和明暗。这一层决定构图,风格还没出来。
+2. **风格渲染器重画**:用底稿当取色源,按该风格的笔法整幅重画——梵高流场长笔触、印象派短点、马赛克石块、浮世绘套色错位+纹样、立体主义切面、波普网点、8-bit 低分辨率逐像素、光追逐像素反射……渲染器决定「这是谁的画」。
+3. **小物件单独一层**:桌椅、花瓶、画框这类小东西如果混在大面积里一起过渲染器,会被打碎成一团。单独画、单独用更细的参数,`source-atop` 只画在自身上。
+4. **角色**:同一副骨架(RIG)、同一套编舞,换画法——平涂后叠该风格的细肌理,最后补清晰的轮廓和五官。角色是观众视线的落点,必须读得出是谁。
+5. **会动的高光**:时代母题的小循环(见 02 号)。连续运动用连续时间;手绘线条用 8–12fps 换种子「沸腾」,给手工感。
+
+## 三、风格渲染器速查(都在 `lib/paint.js` 或各 scene 里自写)
+
+| 渲染器 | 适合 | 关键 |
+|---|---|---|
+| `strokes` 流场笔触 | 梵高、表现主义、油画 | 方向场按区域写(墙竖、地板沿透视、星空沿漩涡);**区域色板**比颜色抖动重要;每笔带深色描边才厚 |
+| `dabs` 色点 | 印象派 | 冷暖偏移的椭圆短笔;**不是点彩**(没有纯色板、点不等大,画出来是印象派) |
+| 视觉混色点彩(29_seurat) | 修拉、新印象派 | 纯色板按比例并置、点等大、补色点、明暗交界光渗 |
+| 镶嵌(04_roman 自写) | 马赛克、彩色玻璃 | 布局只算一次、颜色每帧流过石块;石块沿轮廓排(距离场等值线);石块比半间距大 8–28% 让平分线切出缝 |
+| 套色+纹样(07_ukiyoe) | 浮世绘、木刻、丝网 | 填色相对墨线错位 (3,2)px;纹样做 CanvasPattern;横向刷痕晕染 |
+| `facets` 切面 | 立体主义、低多边形 | 半透明渐变面叠出空间;三角不裁剪让轮廓变直边 |
+| `halftone` 网点 | 波普、旧印刷 | 小 tile `createPattern` 比逐点画快 10 倍;45° 网格 |
+| 低分辨率逐像素(14_8bit) | 像素、复古游戏 | 240×135 画完最近邻放大;限 14 色板;每部件描 1px 黑边 |
+| 逐像素着色(15_raytrace) | 早期 CGI、塑料、金属 | 统一塑料着色(底色+径向暗边+环境反光+硬高光);地面倒影镜像 |
+| 金箔(05_gothic) | 泥金、圣像、装饰 | 逐像素打磨纹+压花暗线错 1px 亮线;高光只落在「金色度」遮罩上 |
+| 晕涂(06_renaissance) | 古典油画 | 整层轻模糊+半透明清晰层;龟裂纹+画布纹+暗角+黄釉 |
+| 可变线宽路径(10_nouveau) | 新艺术、书法线、版画 | 沿点列两侧按宽度偏移成多边形;剪影染深色错位垫底=外粗内细 |
+| 颗粒点彩(16_2026) | 当代扁平插画 | 形状内撒点,密度是位置函数;静态全进缓存 |
+| 毛笔飞白+墨晕(17_ink) | 水墨、书法、东方写意 | 笔锋起收、沿弧长等距采样做飞白;`filter='blur()'` 洇开(Chromium 下确定);纸是底、墨只往上加 |
+| 长弯流线笔+按行 warp(19_munch) | 表现主义、流动感 | 沿流场走 20–30 步的长笔;整幅按行正弦位移(margin ≥ 最大位移防露缝) |
+| 水彩洗染(25_ghibli) | 吉卜力背景、水彩 | 透明叠色+水痕边;水痕描边 α 随扩张淡出 |
+| 灰度照片网点(22_constructivism) | 构成主义、旧报纸、照片拼贴 | 按亮度定点径、45° 网格、批成一条 path 一次 fill |
+| 双版本光影裁切+剪切长影子(24_hopper、23_dali) | 霍珀、超现实、强光场景 | 亮版暗版各画一遍,按光块 clip;影子用剪切仿射 |
+| VHS 通道分离后期(26_vaporwave) | 蒸汽波、复古视频 | RGB 错位、扫描线、跟踪噪声带,作为后期叠层 |
+| 光照图整幅相乘(32_rembrandt) | 明暗法、夜景、烛光 | 先画亮版,再乘一张光照图(窗光+烛光径向) |
+| 赛璐珞硬阴影带(35_shinkai) | 日本动画、新海诚 | 部件减去平移后的自己 = 硬阴影带;受光亮边 |
+| 步进帧率 `stepTime(t,fps)`(33_rubberhose、34_shadowpuppet) | 老动画、皮影、定格 | 12fps/10fps 一顿一顿是风格的一半,不是卡顿 |
+
+## 四、角色:同一副骨架,十几种画法
+
+- 骨架坐标别拍脑袋写:拿一张 AI 设定稿(或任何参考图)叠 20px 网格,逐部位读关键点,Catmull-Rom 平滑成 Path2D(`RIG.smooth`)。第一版手写坐标的少女像男孩,量点之后一轮就读得出 17 岁金发少女。
+- 坐姿把腿藏进长裙最自然;端杯用两骨 IK(上臂 165 / 前臂 122),肘向固定朝下。
+- 锚点 `G.A`(头顶、额、颈、胸、腰、膝、手…)给各风格加服饰:埃及宽领、哥特光环、浮世绘岛田髻、包豪斯关节盘、波普大波浪。
+- 各风格可以对骨架做程式化变形(埃及侧脸正面眼、黑绘剪影、立体主义半边蓝脸、像素化),但站位、动作节奏要和骨架一致——这是「同一对角色在穿越」的来源。
+- 结尾表演这种大幅度动作(跳、趴、伸爪、惊呼)不必硬塞进通用骨架:16_2026 自建姿势库(每个姿势一组局部关键点,逐数值插值),挤压拉伸以脚底为轴,压到最扁那一帧翻面。
+
+## 五、让画「活」:动作清单与量法
+
+- 每段至少:主角一个连续动作(choreo.cup 端杯)+ 2–4 个母题小循环。短段(<0.5s)节奏要快到 15–30fps 步进。
+- 自检运动量:渲两帧(**避开转场后 0.35s 的镜头冲击**,否则全屏都算在动)做帧差。第一次做下来的数(缩放结束后 0.45↔0.9s):洞穴 2.8%、埃及 3.4%、罗马 6.4%、希腊 9.9%;原片同段热图 6.9%、6.2%、17.3%、11.6%。偏静就加母题动作。
+- 动的东西要在视线焦点上:人、猫、窗里。
+
+## 六、踩过的坑
+
+- **合成模式**:逐个纹样 `source-in` 会互相清空(克里姆特金袍整件消失)——先把纹样画满一张 scratch,再按剪影 source-in 一次;在段画布上 `destination-out` 会挖出透明洞,进视频是黑的——在离屏里挖好再贴;往角色上叠纸纹/颗粒不能用 `source-atop`(纸色盖上去人物发白)——纹理层 `destination-in` 剪影后 `multiply` 叠回。
+- 自画字形:同一条 path 里两条反向绕行的笔画按 nonzero 规则会抵消出洞,每个部件单独 fill。
+- 「融化」类转场:让新画面带圆头液滴从上往下流(剖面 `(1-u²)^0.3`),旧画往下拖出来的是尖刺,不像液滴。
+- 转场时长按「看得见的部分」定:inOut 缓动两头几乎看不出变化,复杂的签名转场 0.34s 只读得到 0.2s,会被读成普通擦除,给到 0.48–0.5s。
+- 皮影/剪纸这类半透明叠片,重叠处相乘会发黑,叠片顺序和透明度要按材料调。
+
+- `putImageData` 直接写到目标 canvas 会绕过引擎的镜头冲击缩放和转场裁剪——先写进离屏再 `drawImage`。
+- 读像素的离屏 context 用 `{willReadFrequently:true}`;每帧用 `g.reset()`,不然上一帧的 lineJoin/状态会残留,第一帧和之后不一致。
+- `drawGirl(mode:'line')` 叠在最上层会把被遮住的部件轮廓画穿(远侧袖子穿过躯干、帽檐后半圈穿过头发)。用 `RIG.visibleLines(key, (g, lineColor) => 完整画一遍, 真线色, box)`:同一画法画两遍、线色换成白色当哨兵,两遍不同的像素就是没被遮住的线(含五官线)。按「填色→风格肌理→visibleLines 补线」走。
+- **镜头冲击要作用在新旧两层**:只冲新层时,转场刚开始新层还没露出来,拍点那一帧画面不动,听感上「声音先到画面后到」(v1 审片量到拖拍 0.1–0.17s)。
+- **整屏笔触按 8fps 换种子 = 闪,不是活**:审片量到整屏跳变帧差 18–20,比转场还大。笔触位置固定,让方向场随时间连续变化(火苗般摇曳),沸腾只留给线稿。
+- 动态区不要单独换参数(石块尺寸、笔触密度)——静止时就是一块补丁。
+- 马赛克/像素这类粗颗粒风格里,字要用等宽粗笔画(每笔 ≥2 个颗粒宽),细字体会断。
+- 小东西做得比你觉得的大:浮世绘浪爪 22–50px 读不出来,44–74px 才是「神奈川冲浪里」。
+- 确定性:所有随机用种子;同一个 t 渲两次必须逐像素一致,否则渲染时会闪。
+
+## 七、分工(多 agent 并行画)
+
+先写好 `时代作者规范.md`(接口、可用库、标杆、硬要求、参考文件、自检命令、交付 notes),再按 4 个时代一组派 agent。规范里写清「不改 lib/ 和别人的文件」。每组 30–35 分钟交回,notes 直接沉淀成 `风格配方/`。第一次 16 段全部一次通过,主要靠规范+标杆实现。
diff --git "a/references/05-\350\212\202\345\245\217\344\270\216\351\205\215\344\271\220.md" "b/references/05-\350\212\202\345\245\217\344\270\216\351\205\215\344\271\220.md"
new file mode 100644
index 0000000..27b893f
--- /dev/null
+++ "b/references/05-\350\212\202\345\245\217\344\270\216\351\205\215\344\271\220.md"
@@ -0,0 +1,19 @@
+# 05 · 节奏与配乐
+
+拆解方法与可复用规律:`风格配方/_音轨_艺术史速通.md`(第 5 节「可复用规律」可以直接照抄);合成脚本模板(原创示例乐谱):`scripts/audio/synth_艺术史速通.py`。
+
+## 要点
+
+1. **先定 BPM 网格,画面和音乐都落在网格上。** 128 BPM、八分音符 0.234s 适合速通/蒙太奇。`eras.js` 的 `eighths` 就是每段占几个八分。
+2. **加速靠每段变短,不靠提速。** 6 → 4×5 → 3×4 → 2×3 → 1×3 → 结尾放长。
+3. **一个三音动机,每段换该风格的代表乐器、随和弦移调。** 和声一个四和弦循环就够。
+4. **段间硬起音,不交叉淡化,不加嗖声。**
+5. **结尾音效:停—悬—砸—反应—收**(叮 → 滑哨坠落 → 碎裂 → 猫叫 → 低音拨弦),时间点对齐画面事件帧。
+6. **响度**:对齐参考片的积分 LUFS 与真峰;逐段比相对差值。
+7. 全模态模型听音只当候选:乐器可信,BPM、动机音数、音效时间都要用起音检测回校。
+
+## 和画面的对位
+
+- 转场起点 = 网格点;镜头冲击(场景层 1.03 → 1.0,20 帧)落在同一点,听感上的「咔」和视觉上的顿挫是同一下。
+- 结尾表演的动作帧(拍杯 3、杯子落地)对齐音频 onset,误差 3 帧以内。
+- 没有参考片时:先写段落表(每段多少八分),再同时生成画面时间轴和配乐;之后改节奏只改 `eighths` 一处。
diff --git "a/references/06-\345\217\243\346\222\255\351\251\261\345\212\250\347\232\204\350\211\272\346\234\257\347\237\255\347\211\207.md" "b/references/06-\345\217\243\346\222\255\351\251\261\345\212\250\347\232\204\350\211\272\346\234\257\347\237\255\347\211\207.md"
new file mode 100644
index 0000000..d575b98
--- /dev/null
+++ "b/references/06-\345\217\243\346\222\255\351\251\261\345\212\250\347\232\204\350\211\272\346\234\257\347\237\255\347\211\207.md"
@@ -0,0 +1,31 @@
+# 06 · 口播驱动的艺术短片(方法草案,待第一支实片验证)
+
+目标:根据口播表达,使用选定的时代或艺术家画风,制作镜头与画面连贯的动画。最新整片方法见`12-口播整片与经验回流.md`。
+
+> ⚠️ 本页是从艺术史速通的引擎推出来的方案,**还没在真实口播上跑过**。第一支做完把这行删掉,把实测写回来。
+
+## 和速通片的区别
+
+| | 速通片 | 口播短片 |
+|---|---|---|
+| 时间轴 | BPM 网格 | 口播词级时间戳(来自你的转录工具,如 Whisper 一类的词级时间戳) |
+| 风格 | 每段换风格 | **一个风格贯穿**(一位艺术家/一个时代) |
+| 镜头 | 固定机位 | 要有镜头语言:推拉、摇移、切景别、跟随 |
+| 叙事 | 骨架不变、风格变 | 风格不变、内容随口播变 |
+
+## 流程
+
+1. **口播 → 镜头表**:按句切,每句定「这句话画面上是什么」(具象物/隐喻/人物动作/文字),标镜头类型(全景/近景/特写/推/摇)和时长(来自词级时间戳)。先给花叔看 5–10 行镜头表再动手。
+2. **定风格=定渲染器+色板+线条**:从 `风格配方/` 选最接近的一张卡做起点;没有的风格按 04 号第三节新写一个渲染器。先出一帧(三方向硬门:同一句口播的同一帧,三种风格诠释给花叔挑)。
+3. **世界而不是画面**:口播片要切镜头,所以把场景建成一个比画面大的「世界画布」(如 5760×3240),各元素有世界坐标;镜头 = 视口(中心、缩放、旋转)。渲染器作用在视口画出来的那一帧上,笔触大小按屏幕像素定,推镜头时笔触不会变粗——这是「画在动」而不是「图片在放大」的关键。
+4. **镜头间的流动**:
+ - 同场景内:视口插值(推拉摇),配缓入缓出。
+ - 换场景:用该风格自己的语言做转场(梵高就是笔触漩涡卷走、浮世绘就是浪、水墨就是晕开)——02 号第 3 层机制。
+ - 匹配剪辑:上一镜的形状对下一镜的形状(杯口 → 月亮)。
+5. **字与口播**:关键词可以用该风格的字体/笔法写进画里(马赛克字、书法、霓虹),不做通用字幕条;字幕交给剪辑工程另轨。
+6. **音乐**:05 号的网格法照用,只是网格让位于口播节奏(句间留白处放转场与音乐重音)。
+7. **验收**:和口播并排看,每句话画面是否在讲同一件事;每镜是否在动;风格是否一眼可辨。
+
+## 与视频管线的分工
+
+口播的转录、时间轴、混音、交付走你的视频管线;本 skill 只负责「艺术动画画面」这一轨,产出一条无声 MP4 或 ProRes,给剪辑工程当画面轨。
diff --git "a/references/07-\346\255\243\351\235\242\347\273\217\351\252\214.md" "b/references/07-\346\255\243\351\235\242\347\273\217\351\252\214.md"
new file mode 100644
index 0000000..dc45c83
--- /dev/null
+++ "b/references/07-\346\255\243\351\235\242\347\273\217\351\252\214.md"
@@ -0,0 +1,195 @@
+# 07 · 正面经验:哪些做法被证明有效
+
+这里记录实践中可复用的做法、证据及适用条件。
+
+这一页只记**做对了的事**:做法、证据(量到什么/谁在什么情况下复用成功了)、为什么有效、什么时候用。坑在各 reference 的「踩过的坑」里。每条带来源,后来者复用成功就在证据里加一笔,复用失败就写清边界。
+
+---
+
+## 一、导演与机制
+
+**1. 转场 = 下一个风格的签名语言。**
+- 证据:艺术史速通 15 个转场全部这样设计;迁移测试 A、B 两个独立 agent 都把它评为「整份 skill 里最值钱、可迁移性最强的一句」,9 个新转场(金箔螺旋铺开、呐喊色带下压、飞天飘带剥落旧画、波点长出、融化液滴、硬边阳光、湿纸晕开、VHS 撕裂……)几乎是从这句话直接推出来的,没走弯路。
+- 为什么:转场同时完成两件事——告别旧风格、预告新风格。观众在 0.3 秒里就知道「下一个是谁」。
+- 怎么用:列新风格最有辨识度的形式元素(材料、笔法、母题、媒介故障),选一个能「从无到满」的,做成从画内某个物体(猫、杯、头)长出来的过程。
+
+**2. 一副骨架、一套编舞、N 种画法 = 「同一对角色在穿越」免费得到。**
+- 证据:RIG.girl/RIG.cat 返回 Path2D+锚点,36 种风格全部复用;A、B 都说「换风格时人和猫都站在原位,站位和动作自动一致,这个效果是免费得到的」。
+- 怎么用:先定角色骨架和动作曲线,再写风格;风格只改「怎么画」,不改「在哪、怎么动」。
+
+**3. 主角的动作要跨段连续,按全片时间走。**
+- 证据:迁移测试 A 第一版每段按局部时间重喝一次,审片原话「观众看到的是她举杯五次,而不是同一个瞬间换了五种画风」;改成全片时间(`PAINT.cupCycle(t)`)后转场两侧姿势一致,「两个头」的穿帮也消失。
+- 怎么用:速通/穿越类片子,角色动作一律用全片时间 t;只有「某段专属的表演」用局部 lt。
+
+**4. 节拍网格+拍点冲击作用在新旧两层。**
+- 证据:v1 只冲新层,审片量到 15 个转场里前 6 个拖拍 0.1–0.17s;改成两层同时冲后,15 个转场首个画面变化全部落在拍点上(±2 帧),拍点帧差 7–33。
+- 怎么用:任何卡点剪辑,拍点那一帧必须有整屏可见的变化。
+
+**5. 开场让第一幅画「自己画出来」。**
+- 证据:迁移测试 A 的水墨段前 0.45 秒笔触按 reveal 写出、墨晕洇开,审片认可,第 0 帧不再是白纸。
+- 怎么用:片子第一段没有转场可借时,用该风格的「作画过程」开场(笔触写出、版画套色一版版落、像素一行行点亮)。
+
+## 二、画面美感
+
+**6. 区域色板比颜色抖动重要。**
+- 证据:梵高第一版只做颜色抖动,是「同一个蓝的噪点」;每个区域给 7–8 色的色组(`P.swatch`)后才出梵高。A 的蒙克(天空/峡湾/山/墙/地各一组)直接照搬成功。
+- 怎么用:任何笔触/色点类风格,先按区域定色组,每一笔从组里抽色,再混 30–45% 底稿色保留明暗。
+
+**7. 大面积交给渲染器,小物件与角色单独一层,最后补线。**
+- 证据:向日葵、桌腿被大笔触打碎成一团,拆层后清楚;B 的霍珀「双版本光影裁切」是这条的推广。
+- 边界:水墨、版画、图案类管线顺序不同(纸是底、墨只往上加;图案本身就是渲染器),见 04 号。
+
+**8. 角色也要过同一个渲染器,否则像贴上去的剪贴画。**
+- 证据:36 种风格里,角色也走了渲染器的(梵高细笔触、马赛克石块、8-bit 像素、立体切面、黑绘剪影、皮影镂空)最融;只用矢量骨架平涂的(水墨人物 6/10、吉卜力人物「像扁平矢量」、达利「偏矢量插画」)是各段最弱处。
+- 怎么用:角色平涂之后,至少做一样「该风格的材料处理」——笔触、颗粒、纸纹 multiply、墨晕边、网点、色版错位。
+
+**9. 风格里的字用路径画,比用字体更有风格。**
+- 证据:B 的西里尔方块字(5×7 模块)、霓虹灯管假名;罗马的马赛克字(等宽粗笔画,每笔 ≥2 颗石头宽)。字体子集缺字会静默回退到系统字体,换台机器就变样。
+- 怎么用:标题、招牌、题签优先用路径画成该风格的材料;必须用字体时先验证字形在。
+
+**10. 材料的物理过程就是渲染器。**
+- 证据:浮世绘「填色相对墨线错位 (3,2)px+暈し横刷痕」=套色木版;马赛克「布局一次算、颜色每帧流过石块」=真马赛克的动画方式;金箔「横向拉丝噪声 y 频率是 x 的 20 倍」一次就出金属感,被 A 的克里姆特直接复用。
+- 怎么用:写新渲染器前先问「这种画在现实里是怎么做出来的」,把那个过程写成代码。
+
+**11. 小东西要做得比直觉大。**
+- 证据:浮世绘浪爪 22–50px 读不出,44–74px 才是神奈川冲浪里;A 把齐白石虾放大 1.45 倍、飞天 1.35 倍才读得出。
+
+## 三、运动
+
+**12. 每幕 = 主动作 + 2–4 个取自该风格母题的小循环。**
+- 证据:单纯切图无法表现画内运动;按这条做的 16 段,qa 运动面积 1.6–14%,全部无跳变。
+- 怎么用:母题动作清单从拆解的运动热图来;没有参考片就自己列该风格最有辨识度的 3 个形式元素,每个配一个能动的方式。
+
+**13. 让方向场随时间连续变化,而不是按 8fps 换种子重洗。**
+- 证据:整屏 8fps 重洗的帧差 18–20(比转场还大),审片读成「画在闪」;改成笔触位置固定、方向场连续摇曳后,跳变 0、运动面积 9%。沸腾只留给线稿。
+
+**14. 滚动纹样的取模周期等于图案真实周期。**
+- 证据:A 的波点裙按间距取模,回绕那一帧整片跳(帧差 2.7 倍),按六角网格两行周期取模后消失。
+
+## 四、稳定与效率
+
+**15. 规范+标杆实现+分组并行 agent,一次通过。**
+- 证据:16 个时代 4 组并行,每组 30–35 分钟,全部一次交付可用;之后 4 组迁移测试(20 种新风格)同样一次交付。规范写清接口、可用库、硬要求、自检、交付 notes;标杆实现让「五层结构」可以照抄。
+
+**16. 交付前必派独立审片 agent,只看成片。**
+- 证据:复刻 v1 审片抓到拖拍、整屏闪、偏静、跳戏猫 4 类问题;迁移 A 审片抓到「举杯五次」「两个头」「透明手臂」;B 审片抓到「ЧАЙ 读成 ЧАИ」「粉衣像没穿衣服」——制作者自己看了 3 轮都没发现。
+
+**17. 用数字验收:qa.py。**
+- 证据:运动面积、静止帧对、跳变、真实耗时(强制 GPU flush)、确定性,一次 40 秒验完 16 段。只看首尾差会漏卡顿(A:克里姆特 33% 变化但 14/48 帧对静止);只量 JS 时间会报出假的 1ms(B)。
+
+**18. 一切随机用种子,同一时刻渲两次逐像素一致。**
+- 证据:36 种风格全部通过冷/热渲比对;渲染不闪、可以分段重渲再拼。
+
+**19. 静态部分全缓存,每帧只画会动的。**
+- 证据:包豪斯 2.5ms、波普 5ms、8-bit 3ms;B 5 段里 4 段底版整张缓存。最重的梵高(全幅三遍笔触)117ms,整片 60fps 仍在 2 分钟内渲完。
+
+## 五、拆解与参考
+
+**20. 参考帧当生图参考图锁构图;AI 设定稿叠网格读关键点。**
+- 证据:gpt-image 用原片帧当参考,与原片 50% 叠加几乎逐像素重合;少女骨架第一版手写坐标像男孩,叠 20px 网格读点后一轮就读得出 17 岁金发少女。
+
+**21. 运动热图在开工前就告诉你「画是活的」。**
+- 证据:没看热图之前我以为每段是一张画;热图显示每段 2.5–34% 面积在动,直接决定了整条路线。
+
+**22. 网格拟合用「80% 内点下的最大步长」。**
+- 证据:最小残差法会挑一个很小的步长硬凑所有点;改后从 16 个检测点里拟出 14.1 帧(128 BPM 八分),3 个误检点被标成离群。
+
+## 六、规模化(2026-10-04 晚,36 种风格整合)
+
+**23. 先让独立 agent 各自造轮子,再统一收库。**
+- 证据:4 组迁移测试各自写了笔刷/渲染器/后期,整合时归并成 brush.js(7 个)、render.js(14 个)、post.js(6 个);20 段移植到统一库后,16 段在角色框外与原工程逐像素一致——库的 API 足够承载真实用法。
+- 为什么:先统一库会设计出没人用的抽象;让真实风格先长出来,重复出现两次以上的才进库(「三行重复好过过早抽象」的反面也成立:重复三次就该收)。
+
+**24. 迁移测试本身就是最好的需求文档。**
+- 证据:「只读 skill、做 skill 没有的风格、写反馈」的任务书让 4 个 agent 一共交回 60 多条具体问题(静默降级、片长写死、计时不 flush、骨架 bug、dabs 标错),每条都带复现场景;这些在作者自己用时一条都没暴露。
+- 怎么用:skill 每加一块大能力,派 2 个只读 skill 的 agent 做没见过的题目,要求交回「帮上了什么 / 哪里卡住」。
+
+**25. 验收工具也要被验收。**
+- 证据:qa.py 曾经全绿,但整合时发现它根本不执行转场代码,一个转场引用了不存在的函数、整帧崩溃也没报;加「转场冒烟」后才抓到。字形检查用 measureText 对比在 Mac 上漏报,改读字体文件字符表。
+- 怎么用:每个检查项故意制造一次失败(删一个场景、写错一个转场、用一个缺字),确认它真的会红。
+
+## 七、视频动画语法(2026-10-04 晚,YouTube 5 种+科技财经 3 种)
+
+**26. 先实测样片再定语法。**
+- 证据:G1 第一版 Vox 用了撕纸转场,回头逐帧数 5 支 Vox 样片一次都没出现;白板第一版推进思考泡泡,RSA 样片里也没有。G2 实测 TheOdd1sOut 一支:平均镜头 2.4 秒、七成相邻帧完全不动——和「动画就该一直动」的直觉相反。
+- 怎么用:做一种语法前,拿 2–5 支代表作跑 `breakdown.py` 量镜头时长、静止比例、转场种类,再写卡片。印象里的「风格特征」常常是别人的。
+
+**27. 相机只由全片时间决定,转场函数只负责合成两镜。**
+- 证据:Kurzgesagt 缩放 60 倍的尺度穿行全程矢量重画、不糊;Vox 桌面与白板的「转场」就是相机运动本身,qa 跳变 0。G3:推镜转场让旧镜头自己继续推相机,而不是把截图放大——要穿过一个圆形物体时放大倍数 ≥ 1100/半径,否则最后一帧会跳。
+- 怎么用:世界画布+视口;不要对渲染好的位图做缩放转场。
+
+**28. 「揭开」那一帧才是重音。**
+- 证据:G2 动态文字把段起点设为「小节线 − 揭开点 × 转场时长」,所有视觉事件都和底鼓同帧。和第 4 条(拍点冲击两层)是同一个原理的两种情况。
+
+**29. 静止不等于卡:语法决定运动密度。**
+- 证据:storytime 七成帧不动是风格(笑点在「切到反应特写并闭嘴」那一下);kinetic 字落定后不再动、动感交给镜头和背景;qa 的「静止帧对 >40% 读作卡」对这两种不适用。
+- 怎么用:qa 数字按语法读:艺术风格速通要「一直活」,故事/文字类要「动在节点上、静在笑点上」。
+
+**30. 审片要查逻辑和数字口径,不只查画面。**
+- 证据:G3 审片抓到「输出神经元连的是隐藏层不是像素」「『涨了 9 倍』应为『涨到原来的 9 倍』」「月线终点 ¥268 和日 K 终点 ¥286.40 对不上」——三条都是画面完美、内容错。财经图表的硬规矩:坐标轴不截断误导(截断要明写「纵轴未从 0 开始」)、单位、来源、示意数据角标。
+
+**31. 一屏一个焦点;先结构、后数据、再只标一件事。**
+- 证据:kinetic「主词砸进来,其余从遮罩升起」;finance「先出坐标轴、再出数据、最后只标一件事」;3b1b「一个颜色代表一个概念,形变让上一个概念直接变成下一个,几乎不切镜头」——三种语法独立得出同一结论。
+
+## 八、角色
+
+**32. 人交给生图模型,代码只做合成——分工按「谁擅长」划,不按「路线纯不纯」。**
+- 证据:同一帧三方向对比,代码画的 Q 版被判「烂爆了」,G2 帧库和按画风重画的 AI 帧都「效果很好」;36 种风格里最普遍的短板也是角色。代码擅长的是规则性(笔触场、几何、运镜、时间、物理、确定性),模型擅长的是人脸与人形的「对」。
+- 怎么用:见 10 号。先问每一层「谁画得最好」,再决定用什么画。
+
+## 九、接进口播管线(2026-10-04 夜,端到端实测)
+
+**33. 片段按成片帧数渲,窗口从成片时间轴取——跨剪口、跨倍速都不用管。**
+- 证据:要换的两条 beat 之间夹着一段被粗剪剪掉的 3.65 秒停顿,粗剪还整体加了速;把它们当一段连续的成片时间(119 帧)渲出来换进去,编译后该镜 `rate` = 1.0,渲出 119 帧 = 镜头 119 帧,只重渲 1 章(30–57 秒),其余 7 章不动。章节逐帧对片段,画面在动的帧 28/29、127/137 投出偏移 0(其余是编码噪声,正负对称)。
+- 为什么:管线的导演层用原片秒、成片用成片秒,动画只活在成片里。从成片时间轴取窗口,就绕开了倍速、剪口、「beat 终点=下一条起点」三处换算。
+- 怎么用:口播管线里写一个小脚本包住「draft(从成片时间轴取窗口、出 spec 草稿)→ render → verify(逐帧核同步)」三步,见 09 号「片段契约」。
+
+**34. cue 写「哪个词」,不写「第几秒」,渲染前再换成帧。**
+- 证据:5 个 cue(柱子长出、标注弹出、剪报露出、两次荧光笔)露出帧与词起点的误差 −0.48 ~ +0.09 帧,全部来自按帧取整;口播改了、窗口帧数变了,render 直接拒收而不是悄悄错位。
+- 为什么:秒数是从词表抄的二手数,抄一次错一次;词是导演真正的意图(某个数字念到时标注弹出),换算交给脚本。
+- 怎么用:`{"word": "7.8", "kind": "highlight"}`;同词多次加 `nth`,要提前写 `offset`。
+
+**35. 竖屏贴真实截图:按口播念到的半句拆成两次荧光笔,每次对一个关键词。**
+- 证据:整段框(宽 0.93)时红圈放不下,镜头推不进去,正文字高约 20px,手机上读不出;按口播拆成两个半句的框、各对一个关键词,推近 2.4 倍,字高约 50px;第二个框在画外时镜头先移过去再揭开。
+- 为什么:竖屏的瓶颈是画宽,一个焦点只能是半句话;Vox 本来就是「看这一句」的语法,跟着口播一句句圈正好。
+- 怎么用:截图用原样帧裁切(存一份 `_来源帧`),rect 先 `--stills` 渲一张核,目测常偏 20–30%。
+
+**36. 带字的语法让开字幕带,而不是让字幕让开动画。**
+- 证据:t3 竖屏原排版的标注正落在 y≈1460,和烧录字幕(1400–1520)重叠;加 `safe` 后图表排在 300–1430,和片里其它 contain 素材同一块安全区,抽帧零遮挡。第一轮独立审片说「满屏纯白夹在深色截图之间,亮度跳得最明显」,再加 `safe.fill`=片子底色,上下两条变成和相邻截图一样的深色底,图表成了同位置的一张卡。
+- 为什么:字幕是导出时统一烧的,按段挪字幕要动导出链;动画是参数化的,挪自己最便宜。
+- 怎么用:spec 写 `safe`(管线的 draft 会从 ASS 和 contain_box 算好)。
+
+## 九、从示范片到可复用片段
+
+**33. 示范片做得好 ≠ 参数化之后还好;参数化要单独审。**
+- 证据:8 种语法的示范片都过了独立审片,抽成 spec 驱动的片段后再审,只有 3 种能直接用:真实数据一换就暴露刻度取整错、类目标签被抽掉、大数字压线头;字幕让位参数 6/8 被忽略;文字卡没打完相机就走;白板末帧笔盖住「不」字把意思读反。示范片的输入是作者挑过的,片段的输入是管线给的。
+- 怎么用:参数化片段的审片要换输入——负数、小数、长标题、竖屏、无截图、透明背景、文字超长——每种至少喂一份「不友好」的 spec;验收用的样例素材本身也要干净(不能拿目录页截图当示例)。
+
+## 十、接进口播视频
+
+**34. 动画段按「成片时长+词级时间」渲,关键帧落在关键词上。**
+- 证据:一支竖屏口播片的副本里,一章中两段换成动画(t3 财经图表讲一组数字对比、y2 Vox 推官方原文截图),帧数与镜头严丝合缝,7 个关键词误差 −0.48~+0.09 帧。
+- 为什么:动画只在录屏讲不清的地方出现(一个数字对比、一句官方原话),前后仍是真人和录屏;画面事件跟着他说到那个词才揭开,像是他在指着讲。
+- 怎么用:给 beat → 取成片时长与词级时间 → 生成 spec → 渲染 → 冻结回填(接口见 09 号「片段契约」)。数字只来自出处表,来源写在图上。
+
+**35. 不要替他加没要的叙事梗。**
+- 经验:角色身上持续累加装饰会抢走场景的注意力,叙事梗应先在样片中确认。
+- 怎么用:审片指出的「缺什么」是给他判断的信息,不是我直接加东西的授权;要加结构性的梗,先在样片或方向说明里给他看、等他点头。
+
+## 2026-10-05 00:34:23 +0800 · 同一口播按解释任务分配语法
+
+做法:真实原帖/样稿用Vox资料桌面追线和高亮,规则/控制变量/声画关系用3b1b连续对象变换;固定声音、字幕与时间轴后再替换画面。证据:一支口播片的 467.8 秒旁白和 270 条字幕在整套画风重构后复用,最终两版MP4的AAC原始包哈希与锁定混音一致;尚无发布后留存数据。为什么:画面承担对应段落的解释动作,材质服务可读性;语法允许读图或推导后的静止,不用背景装饰微动凑运动量。适用:真实材料与机制解释交替的口播片。
+
+## 十一、长卷穿越片(花叔穿越名画,2026-10-05)
+
+**36. 一个骨架文件+按段并行,24 个世界 4 组 agent 一次拼上。**
+- 证据(骨架和其中 3 段收进了 `scripts/engine/demos/long_scroll/`,做法见 11 号):`lib/world.js` 只定义段接口(宽、地面线、走路帧、互动 at/dur/frame、back/front/seam)、主角行进、按边界裁开的主角、角标;四组各写 6 段,按年代排序后一次拼成 123.7 秒、qa 确定性 ✓、跳变 0;审片核对 23 条边界的地面高度与主角连续性全部通过。关键是全片统一常量(地面线 760、身高 300、步速)写死在骨架里。
+- 怎么用:长片先写骨架和接口,再派组;接口里**所有事件相对「互动开始」定时**(`WORLD.actT`、`item.atAct`),不写「进段后第几秒」——全片步速后来从 330 提到 560,没有一段需要改时间。
+
+**37. 每段速度微调让音乐边界落在小节第一拍。**
+- 证据:24 条边界时刻固定,单一 BPM 最好也差 112ms;每段放整数拍、速度在 86–104 BPM 之间逐段微调后,24 条边界全落小节第一拍,最大误差 11.7ms、平均 3ms。
+- 怎么用:画面先定、音乐后配时,不强求统一 BPM;人耳听不出 ±8% 的逐段速度差,但听得出换乐器没踩在重拍上。
+
+**38. 镜头只进不退。**
+- 证据:v1 互动时镜头往前让出空间、结尾收回,17/24 段出现 68–256px 的「倒带」,qa 测不到、审片一眼看出。改成「目标位置取历史最大值+高斯平滑」后全片 0 次后退,停与起都不顿。
+- 怎么用:跟拍主角的横向长卷,相机位置函数做单调化;qa 加一条「相机后退次数」更好。
diff --git "a/references/08-\351\243\216\346\240\274\344\275\234\350\200\205\350\247\204\350\214\203.md" "b/references/08-\351\243\216\346\240\274\344\275\234\350\200\205\350\247\204\350\214\203.md"
new file mode 100644
index 0000000..af3e811
--- /dev/null
+++ "b/references/08-\351\243\216\346\240\274\344\275\234\350\200\205\350\247\204\350\214\203.md"
@@ -0,0 +1,60 @@
+# 08 · 风格作者规范(通用版,给写 scene 的人和派出去的 agent)
+
+> 替代早期绑死在复刻项目上的 `时代作者规范.md`。派 agent 画风格时,把本页路径给它,再加上「本项目」那一节的具体信息。
+
+## 接口
+
+一个风格段 = `scenes/<id>.js`:
+
+```js
+SCENES['<id>'] = { draw(c, lt, t) { /* 画满 1920×1080 */ }, init(IMG) { /* 可选:一次性预计算 */ } };
+```
+
+- `c` 目标 2D context;`lt` 本段局部时间(秒,从该段转场开始算);`t` 全片时间。
+- 段落表 `eras.js`:`{ id, eighths 或 dur, transition: { type, dur }, counter: {...} }`。片长由段落表自动算。
+- 转场 `transitions.js`:`TRANSITIONS.<name> = (c, A旧, B新, p, o) => {}`。
+- 场景缺文件、语法错、没注册 → 引擎拒绝启动,render/qa 直接报错。不要靠「看起来渲出来了」判断成功。
+
+## 先读(按顺序)
+
+1. `references/02-机制.md`(五层机制)、`04-纯代码绘制.md`(管线、渲染器速查、坑)、`07-正面经验.md`。
+2. `references/风格配方/INDEX.md`:找最接近的风格当起点,读那张卡。
+3. 标杆实现 `scripts/engine/scenes/09_postimp.js`;最接近风格的 scene 源码。
+4. `lib/`:`paint.js`(噪声/纹理/渲染器/色板/编舞)、`rig.js`(角色骨架、visibleLines)、`kit.js` 等工具库。**先找库里有没有,再自己写。**
+
+## 两种起点
+
+**有参考片**:先跑 `scripts/analyze/breakdown.py` 拿到参考帧(`ref/segNN.png`)、运动热图、转场接触表,按 01 号拆。参考帧决定构图、母题、配色,热图决定「画里什么在动」。
+
+**没有参考片**(更常见):
+1. 写下该风格最有辨识度的 3–5 个形式元素(材料、笔法、配色、母题、媒介痕迹)。查一手资料(原作图像、美术史描述),不凭印象。
+2. 给每个元素配一个「能动的方式」——它在那幅画的世界里本来会怎么动(水会颤、纸会飘、金会闪、版会错位、胶片会抖)。
+3. 想清楚这种画在现实里是怎么做出来的(刷、刻、印、贴、镶、喷、渲),把那个物理过程写成渲染器。
+4. 先出一帧:静帧拼图对照原作看,一眼认得出再让它动。
+
+## 硬要求
+
+1. **场景骨架**:按本项目给定的构图坐标摆(各段一致,转场和「同一角色在穿越」都依赖它)。
+2. **角色**:用 `RIG` 骨架与共享编舞,换画法不换站位动作。**角色也要过该风格的材料处理**(笔触、颗粒、纸纹 multiply、墨晕边、网点、色版错位……),否则像贴上去的剪贴画——这是 36 种风格里最普遍的短板。需要线稿时用 `drawGirl/drawCat` 的 `mode:'line'`(内部已走 visibleLines,不会画穿)。
+3. **画要活**:主动作+2–4 个母题小循环,在停留窗口里看得出。速通/穿越片里角色动作用全片时间(`PAINT.cupCycle(t)` 这类),换段不重置。
+4. **流畅**:不要整屏按低帧率换种子重洗(会读成闪);沸腾只给线稿或母题区域。有意的「步进帧率」(橡皮管 12fps、皮影 10fps)用 `stepTime`,那是风格不是卡顿。滚动纹样的取模周期等于图案真实周期。
+5. **确定性**:所有随机用种子;同一个 t 两次渲染逐像素一致。
+6. **性能**:静态部分 `PAINT.cached`;读像素的离屏用 `willReadFrequently`、每帧 `g.reset()`;目标每帧 ≤150ms(qa 量的是带 GPU flush 的真实时间)。
+7. **字**:风格里的字优先用路径画成该风格的材料;用字体时先 `U.assertGlyphs` 验证字形存在(缺字会静默回退系统字体)。
+8. **做旧不上身**:剥落、污渍、划痕只在背景;角色区域设保护区(敦煌剥落斑落在背上读成「衣服破洞」)。
+
+## 自检与交付
+
+```sh
+uv run --with playwright python <工程>/render.py --solo <id> --stills 0.4,0.6,0.8,1.0 --out <渲染>/<id> # 静帧
+uv run <skill>/scripts/qa.py --project <工程> --ids <id> # 数字
+```
+
+每段至少 3 轮:静帧对照原作/参考拼图看 → qa 看运动/静止帧对/跳变/耗时/确定性 → 改。四问:①一眼认得出是哪个风格?②角色对、和背景融吗?③停留窗口里看得出画在动、而且不闪不卡?④有没有穿帮(遮挡、断线、错位、空白、叠字)?
+
+交付:`scenes/<id>.js`+配方卡(照 `风格配方/` 格式:管线、关键参数与色值、母题动画怎么做、签名转场、性能、坑、仍可改进),写具体、写数字。**多段的片子交付前派一个没参与制作的 agent 只看成片审片。**
+
+## 三方向硬门在无人值守时
+
+有花叔在场:新风格方向、角色诠释先在同一帧出三个给他挑。
+没人可问(自动测试、夜间批量):执行任务书写明的方向,同时在交付说明里列出「本可以给的另外两个方向」各一句,等他回来再挑。
diff --git "a/references/09-\350\247\206\351\242\221\345\212\250\347\224\273\350\257\255\346\263\225.md" "b/references/09-\350\247\206\351\242\221\345\212\250\347\224\273\350\257\255\346\263\225.md"
new file mode 100644
index 0000000..8d7f423
--- /dev/null
+++ "b/references/09-\350\247\206\351\242\221\345\212\250\347\224\273\350\257\255\346\263\225.md"
@@ -0,0 +1,369 @@
+# 09 · 视频动画语法:YouTube 解说 / 科技 / AI / 财经片的 8 种画法
+
+做口播解说片的「动画段」时读这份。它是 8 张语法卡(`references/动画语法/`)的总目录、选型表、跨语法规律、库速查,以及给口播管线用的片段契约。
+
+8 种语法都有可直接渲的示范片(`scripts/engine/demos/<语法>/`,收进来时和实验原片逐像素一致;2026-10-05 修了 `TY.charsIn` 透明度后,y1 示范片标题按原意 0.55s 淡出,那 0.55s 的帧和原片不同)和参数化片段(`scripts/engine/clips/<语法>.js`,喂一份 JSON 就出一段时长精确的视频)。
+
+---
+
+## 一、总览
+
+| 语法 | 适用场景 | 一句话核心语法 | 典型镜头时长 | 主缓动 | 主转场 | 卡片 | 示范 |
+|---|---|---|---|---|---|---|---|
+| **y1 Kurzgesagt 扁平科普** | 讲尺度、讲「里面是什么」、讲机制系统;娓娓道来的科普腔 | 把抽象概念放进能无限缩放的发光世界,相机在尺度之间穿行,画面永远在轻轻动 | 硬切镜头 7–9s,视觉单元每 4.6–6.7s 换一次 | `MO.k75`=bezier(.75,0,.25,1);循环 `MO.easyEase` | 钻进镜头 `lensReveal`、填满再拉出 `matchCut`(相机对数推拉) | `动画语法/y1_kurzgesagt.md` | `--film demos/y1_kurzgesagt` |
+| **y2 Vox 拼贴** | 有真实档案、新闻、截图、人物的论证;「看这一句」「注意这个数字」 | 论证摆在一张有真实材料的桌面上,相机像调查记者的眼睛在桌上移动,线和笔一顿一顿画上去 | 慢档中位 3.3s(一张卡 3–7s);快档 1.4–1.8s | 相机 `MO.sineInOut` / 长尾 `MO.longTail`;元素 12fps 步进 | 硬切、沿红线平移 `same`、推满照片→硬切 `cut` | `动画语法/y2_vox.md` | `--film demos/y2_vox` |
+| **y3 白板手绘(RSA)** | 推理链、步骤、「为什么」;边讲边推导 | 说一句写一句,相机跟着论证在一张大白板上移动,最后拉远看全图 | 每块停留中位 6.6s | 板上平移 `MO.sineInOut` 1.2–2.4s;远跳 0.8s 甩镜+运动模糊 | 同一块板 `same`(相机运动就是转场),收尾拉远 | `动画语法/y3_whiteboard.md` | `--film demos/y3_whiteboard` |
+| **y4 故事型简笔角色** | 第一人称讲经历、翻车、笑点;观众要的是「这个人」 | 口播是主角,画面是给口播配的表情包:姿势 0.1s 快切后定住,笑点靠切到反应特写并在那一下闭嘴 | ASL 2.43s(中位 1.87s) | 换姿势 `MO.expoOut` 0.1s+`MO.settle` 挤压回弹;角色 24fps | 硬切 `cut`、砸镜 `smash`、甩镜 `whip`、跳近 | `动画语法/y4_storytime.md` | `--film demos/y4_storytime` |
+| **y5 动态文字** | 清单、「X 个阶段」、金句、数字开场、章节卡 | 字就是演员:关键词踩重音砸进来,主词大到一眼读完,画面永远只有一个焦点 | 一小节一个镜头(120BPM 约 2s) | `MO.expoOut` 入场、`MO.springHz` 砸入、退场 `MO.expoIn` 更快 | 冲进色块 `fillZoom`、色带 `bands`、推页 `push` | `动画语法/y5_kinetic_type.md` | `--film demos/y5_kinetic_type` |
+| **t1 3Blue1Brown** | 讲一个机制怎么一步步变成另一个东西:网络、矩阵、梯度、概率 | 黑底上只放正在讲的那一个东西,用 Transform 把上一个概念直接变成下一个,颜色=概念名,几乎不切 | 单个动画 1–3s+停 1s;一个概念 8–20s | `MO.smooth`(6t⁵−15t⁴+10t³),几乎全用它 | Transform 接续(不切)、镜头穿越 `zoomThrough`、`fadeShift` | `动画语法/t1_3b1b.md` | `--film demos/t1_3b1b` |
+| **t2 发布会界面** | 产品/功能发布、版本更新、教程步骤、参数公布 | 深色光斑底一屏一件事,字从模糊里浮出,界面装进玻璃卡用轻回弹弹簧落位,转场靠同一块玻璃展开 | 演讲一屏 5–8s;产品快剪 1.5–3s | `MO.spring` bounce 0–0.15、`MO.appleOut` | 模糊推进 `blurPush`、卡片展开 `expandRect` | `动画语法/t2_keynote_ui.md` | `--film demos/t2_keynote_ui` |
+| **t3 财经图表** | 营收、股价、份额、拐点;观众会截图较真的数字 | 先搭坐标系,再让数据长出来,最后只标一件事;数值永远诚实,动画只决定怎么出现 | 一张图 2.5–6s | `MO.quintOut`、折线 `MO.smooth` | 面板横推 `slidePush`、推进局部 `zoomThrough`(live+bScale0)、硬切版式不动 | `动画语法/t3_finance_chart.md` | `--film demos/t3_finance_chart` |
+
+总览图:`assets/动画语法/<语法>_总览.jpg`(每镜一帧)。
+
+示范命令(在 `scripts/` 下):
+
+```sh
+uv run --with playwright python engine/render.py --film demos/y1_kurzgesagt --out y1.mp4 # 渲示范片
+uv run scripts/qa.py --project scripts/engine --film demos/y1_kurzgesagt --out <目录> # 验收(在 skill 根目录跑)
+# 预览:起一个本地服务打开 scripts/engine/index.html?film=demos/y1_kurzgesagt 拖时间轴
+```
+
+示范片的时长都压到 8 秒左右,是真片节奏的 2.5–3 倍密度,只为在演示里看全语法。真用时按上表的镜头时长放慢。
+
+---
+
+## 二、怎么为一段口播选语法
+
+先看这段口播在干什么,再选画法。一支片子可以分段换语法,但同一段里不混。
+
+| 这段口播在…… | 选 | 别选 | 为什么 |
+|---|---|---|---|
+| 讲一个概念、一个机制(「神经网络是怎么……」) | **t1 3b1b**(要推导、有公式)或 **y1 Kurzgesagt**(要尺度、要可爱) | y2(没有真实材料可贴,会变成假档案) | 机制靠形变和尺度讲得清 |
+| 讲新闻、事件、历史,有截图和原话 | **y2 Vox** | y1(扁平卡通冲淡可信度) | 观众要亲眼看到出处 |
+| 讲自己的经历、翻车、笑点 | **y4 storytime** | t2(自带好消息的情绪) | 笑点在反应镜头的停顿里 |
+| 讲清单、几个要点、几个阶段、一句金句 | **y5 动态文字** | t1(没有能变形的对象) | 信息是结构,不是画面 |
+| 讲产品、教程步骤、功能、参数 | **t2 发布会界面**(截图放进玻璃卡) | t1(玻璃和光斑不承载逻辑,反过来也一样) | 一屏一件事、名词和数字当主角 |
+| 讲数字、增长、走势、对比 | **t3 财经图表** | t2 的大数字(只有一个数时才用它) | 要坐标系和单位,要能被较真 |
+| 边讲边推导、一步一步论证 | **y3 白板** | 一次整屏切换 | 说一句写一句,最后拉远是落点 |
+
+两条兜底:
+- 有真实截图要放 → t2(教程,干净)或 y2(论证,证据感)。截图一律等比放,不裁关键 UI。
+- 一段里只有一个数 → 不画图表,用 t2/y5 的大数字计数,在口播说出数值那一刻落定。
+
+---
+
+## 三、跨语法通用规律
+
+从 8 张卡里提炼的、换语法也成立的规矩。每条后面是出处。
+
+1. **相机只由时间决定,场景按相机矢量重画。** 推拉、平移、穿越都是同一个世界画布在不同相机下重画,所以放大 60 倍也不糊,转场里上一镜继续按时间推相机(`zoomThrough` 的 `live:true`)。(y1 ⑥「关键架构」;y3 ⑥;t1 ④-2)
+2. **缩放用对数插值,穿过圆形开口要够倍数。** `CAM.zlerp` 让每帧放大同样的倍数,线性插值会前慢后猛;穿进半径 r 的开口,倍数 ≥ 开口中心到最远屏幕角的距离 / r(居中时约 1100/r,`CAM.coverZoom`)。(y1 ⑧-2;t1 ④-2)
+3. **揭开那一帧对齐拍点或口播词。** 转场从新段起点开始算,要让新画面露出来的那一帧落在小节线上:段起点 = 小节线 − 揭开点 × 转场时长(`MO.onBeat`)。数字要在口播说出数值时落定:计数起点 = 说数字的时刻 − 计数时长。白板开写比对应短语晚约 0.5s。(y5 ④「对位技巧」;t2 ⑤;t3 ⑤;y3 ⑤)
+4. **先结构、后数据、最后标注。** 坐标系先出、数据后长、标注最后,一镜只标一件事;3b1b 是先 Write 问题再演示;发布会是眉题→产品名→副标题。(t3 ③;t1 ⑤;t2 ③)
+5. **一屏一个焦点。** 同一时刻只让一个东西入场,其余静止;主词和辅句至少 3:1;背景的饱和度、对比、线宽都比主角低一档。(y5 ⑧-1;t2 ⑤;y4 ⑧-2)
+6. **入场慢、退场快,落定后要停。** 入场 0.3–0.4s、退场约 0.18s;数字落定后至少停 0.5s,包袱后定住 ≥0.9s,3b1b 每个动画后 wait 约 1s。(y5 ⑤;t3 ⑧-3;y4 ⑤;t1 ⑤)
+7. **「一直在动」还是「快切后定住」,按语法选,别混。** Kurzgesagt 里 0.5s 内完全不动的时段只占 0.3%;storytime 七成帧完全静止,生命在快切+定住。(y1 ⑧-1;y4 ⑧-1)
+8. **两层帧率:相机平滑,元素步进。** Vox 相机平滑、纸片/荧光笔/打字按 12fps 一拍二;storytime 角色 24fps、镜头 60fps。全部丝滑像企业宣传片,全部步进会晃。(y2 ③、⑧-1;y4 ③)
+9. **颜色=概念,强调色少。** 一个颜色讲一个概念(公式里的 W 和连线同是蓝),超过 3–4 种语义色就记不住;Vox 是黑、纸白、一种红,白板是黑加一个橙。(t1 ⑧-3;t3 ⑧-2;y2 ⑧-3;y3 ⑧-3)
+10. **转场放在换气和换话题处,不放在句子中间。** 甩镜切在两句之间,反应镜头放在沉默里;白板的平移卡新论点;Vox 硬切卡句读。(y4 ⑤;y3 ⑤;y2 ④)
+11. **审片要查逻辑和数字口径,不只看好不好看。** 实测抓到过的:「涨了 8.7 倍」应为「涨到原来的 8.7 倍」;展开成全屏后又从 0 重数;讲隐藏层却连到了像素;倍数要能从图上的数算出来。(t3 修订表;t2 修订表;t1 ⑥)
+12. **真实素材保持原样。** 截图等比放、不裁关键 UI;数据只改「怎么出现」不改「是多少」;柱一律从 0 起,轴不从 0 起要写明;虚构数据每一镜标「示意数据」,真实数据不许出现这个角标。(t3 ②、⑧-1;片段契约)
+
+---
+
+## 四、库速查(`scripts/engine/lib/`,index.html 和 clip.html 都已加载)
+
+| 文件 | 命名空间 | 有什么 |
+|---|---|---|
+| `motion.js` | `MO` | `seg/at/anim/step`(12fps 步进)、manim `smooth/thereAndBack/rushInto/rushFrom/doubleSmooth/wiggle/lagged`、`sineInOut/cubic*/quart/quint/expo*/backOut/elasticOut`、`bezier` 与 `appleOut/emphasized/k75/easyEase/longTail`、SwiftUI `spring/smoothSpring/snappy/bouncy`、`springHz/settle`、`float`、`invert`(缓动反查)、`beat/onBeat`(拍号对齐);`U.setStage/onStage`(画布尺寸) |
+| `camera.js` | `CAM` | `apply/with`、`toScreen/toWorld`、`zlerp`(对数缩放)、`coverZoom`、`anchor`、`pushTo`(推进某点、该点平滑移到中心或原地放大)、`at`(关键帧,沿路径平移)、`layer`(视差)、`velocity/motionBlur`(甩镜模糊)、`drift`(手持微漂) |
+| `diagram.js` | `DG` | 点列 `cum/len/pointAt/drawPartial`(逐笔描出)/`xform/arcPts/ellipsePts/hand`(手绘抖动)/`revealMask/zigzag`(Reveal 揭开)、Transform `rectPts/circlePts/morph/shape`、颜色 `mix/mixA/rgba`、3b1b 色板 `MANIM`(已 ×1.5 饱和)/`saturate`、`math/write`(manim Write,先描边后填色)、`neuron/edgeEnds/edge/flash`、`indicate/circumscribe/brace`、白板 `board`(笔画时间线+笔间滑移)、`pen`(马克笔) |
+| `typo.js` | `TY` | `text/width/font`、`wrap/fit`(折行;`fit` 缩字号到真放得下:行数 ≤ maxLines 且量过每行宽,单个长英文词也不出框;`soft:true` 放不下返回 `ok:false` 让你换方案,`balance:true` 多行折成等长)、`charsIn`(逐字上浮)、`rise`(遮罩升起)、`pop`、`blurIn`(从模糊浮出)、`typed/typedCount`(打字)、`marker/underline`、`slam`(主词砸入)、`keyword/keywordMarker`(关键词强调)、`fmt/count/tabular`(数字滚动与等宽数字) |
+| `chart.js` | `CH` | `lin/ticks`、`grid/xLabels`(坐标系先出)、`bars`(从 0 长出+同步计数+高亮变灰)、`line/yAt`、`candles`、`callout`(点→引线→文字)、`tag/demoBadge/frame`(经济学人版式) |
+| `ui.js` | `UI` | `mesh`(光斑底)、`grainTex`、`backdrop`、`shadow`、`glass`(毛玻璃卡)、`sheen`(光扫过)、`persp`(伪 3D)、`icon`、`rr/rrPath/scratch` |
+| `collage.js` | `CL` | `paperTile/fillPaper`(纸纹)、`tornEdge/tornRect`(撕边)、`halftone/photo`(网点照片)、`placed/shadowed/slideIn`(倾斜滑入放平)、`tape/pin`、`stringPts/string`(红线)、`highlight`(毛边荧光笔)、`stickerEdge`(剪纸白边) |
+| `toon.js` | `TOON` | `flat`(双色分面)、`glow/vgrad/circle/ellipse`、`bean`(豆子花叔)与 `POSES`、`poseAt`(pose-to-pose+回弹)、`blinkAt`、`alive`、`env/mouth`(口型读包络)、`sweat/mark` |
+
+转场在 `transitions.js` 末尾「YouTube 解说语法的转场」一节:`same / lensReveal / matchCut / whip / smash / fillZoom / bands / push / zoomThrough / blurPush / expandRect / slidePush / fadeShift`,每个都写了一句说明和参数。硬切用原有的 `cut`。
+
+引擎相关的小改动:段可写 `dur`(秒)代替 `eighths`;`window.BPM` 改节拍;解说片写 `window.PUNCH = 0` 关掉拍点冲击(或单个转场写 `punch`);`window.SCENE_LIBS / SCENE_DIR` 让一支片子把代码放在自己的目录里(demos 就是这么组织的)。
+
+**实验时的旧名 → 现在的名字**(读实验归档代码时对照):`YT.camAt→CAM.at`、`YT.camForAnchor→CAM.anchor`、`YT.apply/camera→CAM.apply/with`(相机字段 `zoom/rot` 改成 `z/r`)、`YT.ease.*→MO.*`、`YT.spring(t,f,d)→MO.springHz`、`YT.textIn→TY.charsIn`、`YT.type→TY.typed`、`YT.partial→DG.drawPartial`、`YT.at→DG.pointAt`、`YT.circlePts→DG.ellipsePts`、`YT.paperTile/halftone/tornEdge→CL.*`、`YT.bean/POSES/mouth→TOON.*`、`MN.*→DG.*`(`lerpPts→morph`、`C→MANIM`、`FONT_RM→FONT.rm`)、`GL.*→UI.*`、`MO.textIn→TY.blurIn`、`MO.count/fmt/tabular→TY.*`、`easeOutQuint/easeOutExpo→quintOut/expoOut`、转场 `k_lens→lensReveal`、`k_fill→matchCut`、`hardcut→cut`、y5 的 `zoomThrough→fillZoom`(和 3b1b 的镜头穿越撞名)。
+
+字体:中文黑体统一用 `PuHui-Medium/Bold/Heavy/Black`(开源版实际是思源黑体 Noto Sans SC 500/700/800/900,family 名沿用;见 `lib/fonts.js`),白板用 `LXGWWenKai-500`,两者都是 GB2312 全部 6763 个汉字的子集,换题目一般不用补字。公式 `CMU-rm/it`,发布会 `Inter`,财经数字 `RobotoCondensed`。思源黑/宋 `NotoSansSC/NotoSerifSC` 只含三支示范片用到的字,新内容别用。
+
+---
+
+## 五、片段契约(给口播管线的「动画段」)
+
+口播视频管线(无论你用哪套)在合适的段落调用这 8 种语法做动画段,由管线当导演选语法、从口播词级时间戳算 cue。这一节是双方的约定。
+
+### 入口
+
+**口播管线里建议包一层脚本,不要手敲下面这些**:draft 从成片时间轴定时长、出词表和 spec 草稿 → render 解析 word、调本节的 render.py、数帧、换进剪辑工程、冻结 → verify 对章节逐帧核同步。作者自己的管线就是这样接的(那部分未随本仓库开源)。下面是引擎本身的接口。
+
+```sh
+cd <skill>/scripts
+uv run --with playwright python engine/render.py --spec clip.json --out 片段.mp4 # 无声 H.264 yuv420p
+uv run --with playwright python engine/render.py --spec clip.json --alpha --out 片段.mov # ProRes 4444 带透明(不画背景,给管线叠层)
+uv run --with playwright python engine/render.py --spec clip.json --stills 0.5,2,4 --out 静帧/ # 抽帧检查
+# 预览:本地服务打开 scripts/engine/clip.html?spec=examples/t3_finance_chart.json 拖时间轴
+```
+
+- 时长严格等于 `duration`:帧数 = round(duration × fps),第 i 帧的时间是 i / fps。H.264 每秒一个关键帧(GOP = fps),管线的渲染器按秒 seek 不冻帧。
+- 宽高和 fps 从 spec 读,默认 1920×1080@30;竖屏写 `width: 1080, height: 1920`,每种语法都有竖屏排版。
+- spec 里的图片路径相对 spec 文件(也可以写绝对路径);render.py 只服务 spec 里点名的文件。
+- 量这一段:`uv run qa.py --spec <clip.json>`(在 `scripts/` 下;整段当一段量确定性、运动、静止帧对、孤立跳变、耗时,竖屏按画幅缩)。
+- 页面报错(语法文件出错、图片不存在)→ 非零退出,不出片。spec 里有字库没有的汉字只告警(会回退系统字体,换台机器会变样),常用字都在子集里。
+
+### spec
+
+```json
+{
+ "grammar": "t3_finance_chart", // 8 选 1:t1_3b1b | t2_keynote_ui | t3_finance_chart | y1_kurzgesagt | y2_vox | y3_whiteboard | y4_storytime | y5_kinetic_type
+ "duration": 7, "fps": 30, "width": 1920, "height": 1080,
+ "safe": { "top": 0, "bottom": 520 }, // 可选:让开的边(px),见下
+ "alpha": false, // 可选:true = 不画背景(render.py --alpha 会自动设上)
+ "data": { ... }, // 语法级参数,各语法认的字段见下面每节的「data」行;不认的字段直接忽略
+ "cues": [ { "at": 1.2, "kind": "bar", "text": "...", "sub": "...", "data": { ... }, "image": "截图.png", "dur": 1.0 } ]
+}
+```
+
+**cue 的公共字段**(每种语法认哪些见下面各节):
+
+| 字段 | 含义 |
+|---|---|
+| `at` | 秒,必填。「揭开那一帧」:元素在 t = at 这一帧第一次可见(动画内部从 at 前一帧起算)。例外:`number` 的 at 是数字**落定**的时刻。cue 不必按时间排序,clip.js 会排;at 超过 duration 的 cue 告警后丢掉(看不到,也不占版面)。 |
+| `kind` | 必填。**写了这个语法不认的 kind 不报错、什么都不画**——对着下面的表写。 |
+| `text` | 主文字:标题、要点、标签、气泡原文、插入镜头的大字。 |
+| `sub` | 辅文字:t2 卡片说明、y5 辅句、y4 气泡里实际显示的短句、y4 插入镜头里他打的那一行。 |
+| `image` | 图片路径,相对 spec 文件(也可写绝对路径、`data:`、`http(s):`)。文件不存在 → 拒绝渲染。 |
+| `data` | 这个 cue 自己的参数(`index`、`rect`、`icon`……),见各节。 |
+| `dur` | 只有少数 kind 读:t1 的 title/point/equation/line,t3 的 bar/line/candle,y1 的 enter,y4 的 react/insert。其它 kind 写了也不读。 |
+
+**`safe`**:`{top, bottom, left, right, fill?}`(px,默认 0)。clip.js 把它和让开后的内容框 `ctx.box = {x, y, w, h}` 传给语法;`fill` 是可选颜色,渲完把让开的边涂成它(竖屏片里让图表成为和相邻 contain 截图同一位置、同一种底的「卡」;`--alpha` 时不涂)。**8 种语法都已接 `top` / `bottom`**(语法对象里都写了 `safe: true`,内容只排在 top..H−bottom 之间:t3 的坐标系与来源行、y2 的相机缩放与画面中心、t1/t2/y1/y3/y5 的版面、y4 的气泡与插入镜头大字);**`left` / `right` 目前没有语法按它排版**,写了只会被 `fill` 涂色、内容照样排到边上。竖屏 1080×1920 的口播片字幕带约在 1400–1520,`bottom` 取 490–570;横屏一般 `bottom` 160–220。新语法要接 safe,照 t3:版式的纵向基准加 `safe.top`、底部元素减 `safe.bottom`,或者直接按 `ctx.box` 排,再在语法对象里写 `safe: true`(没写而 spec 给了 safe 时 clip.js 会 console.warn)。
+
+**`number`(大数字)的口径**——只有 t2、t3、y5 认,其它 5 种写了不显示:
+
+| 项 | 规定 |
+|---|---|
+| 数值 | `data.value`(数,可负;不写当 0)。从 0 滚到 value(expoOut,先快后慢),负数用真减号「−」,整数部分自动加千分位。 |
+| 格式 | `data.prefix`(如 `"¥"`)、`data.suffix`(如 `"%"`、`" 倍"`,要空格自己写)、`data.decimals`(默认 **0**;t3 的 `spec.data.decimals` 只管柱子标签,**number 不继承**,要小数就在 cue 里再写一遍)。 |
+| 说明 | 写 `text`、`sub`、`data.text` 任一个都行,clip.js 把三者统一。 |
+| 小标签 | `data.label`:t2 画在数字上方,y5 画在页左上;t3 不画。 |
+| 时间 | `at` = 数字落定的时刻。t2、t3 在 at−0.9s 开始滚;y5 在 at−0.7s 换页并开始滚。所以 number 的 at 至少写 0.9(y5 0.7),否则第 0 帧就已经滚了一大半。 |
+| 位置 | t2:单独一屏,上一屏在 at−0.9s 开始退场,不叠在卡上;t3:图区上方专留的一条,右对齐,说明在数字左边;y5:单独一页。 |
+
+### 各语法认的 cue
+
+下面每节第一行是 spec 级 `data`,表里是 cue。「最小 spec」是能渲出一段像样画面的最少写法,复制改字就能用。
+
+#### t1_3b1b(3b1b / manim 讲解:公式、曲线、要点)
+
+spec 级 data:无。
+
+| kind | 字段 | 说明 | 示例 |
+|---|---|---|---|
+| `title` | `text`,`data.color`,`dur` | at 起 Write;再来一个 title 时旧标题上移淡出;太长先缩字号、再折两行 | `{"at":0,"kind":"title","text":"注意力就是加权平均"}` |
+| `equation` | `data.tokens` 或 `text`,`dur`(首个 1.2s,之后 1.5s) | token:`{s, it?, col?, gap?, sub?, sup?, size?}`,`col` 写 manim 色名(`BLUE_C` `YELLOW` `GREEN_C` `TEAL_C` `RED_C`…)或 #hex。只给 text 时自动拆:单个字母斜体、连续字母(softmax)正体。第二个起从上一个 Transform 过来 | `{"at":1,"kind":"equation","text":"softmax(QK)V"}` |
+| `point` | `text`,`dur` | 一句一行 Write,新的出来时旧的变灰。放不下时先让曲线让位(竖屏 50%→30%)、再缩字号(≥0.6 倍),还不够就新要点出来时整块上卷、最早的淡出(会告警) | `{"at":3,"kind":"point","text":"先算相似度"}` |
+| `line` | `data.values`(等距 y)或 `data.points`(`[[x,y],…]`),`text`=曲线标签,`data.color`,`dur` | 坐标系先 Create 再画曲线;第二条起从上一条形变过来。有 line 时横屏左文右图、竖屏上图下文 | `{"at":2,"kind":"line","text":"损失","data":{"values":[9,5,3,2,1.5]}}` |
+| `highlight` | `data.index`(第几个 point,从 0 起,默认最新)或 `data.target:"equation"` | Indicate+黄框留住 | `{"at":5,"kind":"highlight","data":{"index":0}}` |
+
+最小 spec:
+```json
+{"grammar":"t1_3b1b","duration":6,"cues":[
+ {"at":0,"kind":"title","text":"注意力就是加权平均"},
+ {"at":1.2,"kind":"equation","text":"softmax(QK)V"},
+ {"at":3,"kind":"point","text":"先算每个词和我有多像"},
+ {"at":4.2,"kind":"point","text":"再按像的程度把信息加起来"}]}
+```
+
+#### t2_keynote_ui(发布会界面:功能卡、截图卡、大数字)
+
+spec 级 data:`eyebrow`(标题上方小字)、`title`、`subtitle`、`accent`(强调色,默认 `#3d6bff`)。
+
+| kind | 字段 | 说明 | 示例 |
+|---|---|---|---|
+| `title` | `text`/`sub` 覆盖 data.title/subtitle | at 起从模糊里浮出 | `{"at":0,"kind":"title"}` |
+| `card` / `step` / `image`(同义) | `text` 卡标题,`sub` 说明,`image` 截图;`data.step` 指定编号;无图卡可加 `data.icon`(`wave memory agent clock phone layers chart code check play bolt lock`)、`data.value/prefix/suffix/decimals/label`(卡上计数) | 有图:一屏一张,截图等比 contain;无图:连着的最多 3 张并排一屏 | `{"at":2,"kind":"card","text":"一句话出图","sub":"不用写提示词","data":{"icon":"bolt"}}` |
+| `highlight` | `data.rect=[x,y,w,h]`(相对截图 0..1),`text` 可选标签 | 框出当前截图卡的一块并压暗其余 | `{"at":5,"kind":"highlight","data":{"rect":[0.6,0.2,0.2,0.1]}}` |
+| `number` | 见上方 number 口径 | 单独一屏 | `{"at":4,"kind":"number","text":"每月活跃用户","data":{"value":1.2,"decimals":1,"suffix":" 亿"}}` |
+
+最小 spec:
+```json
+{"grammar":"t2_keynote_ui","duration":6,"data":{"title":"三个新功能"},"cues":[
+ {"at":0,"kind":"title"},
+ {"at":1.8,"kind":"card","text":"语音输入","sub":"说完就转成文字","data":{"icon":"wave"}},
+ {"at":2.6,"kind":"card","text":"长期记忆","sub":"记得你上次说过什么","data":{"icon":"memory"}},
+ {"at":3.4,"kind":"card","text":"自动执行","sub":"替你点完剩下的按钮","data":{"icon":"agent"}}]}
+```
+
+#### t3_finance_chart(经济学人式数据图)
+
+spec 级 data:`title`、`unit`(副标题:指标与单位;放不下先缩再折两行)、`source`(左下来源;同上,并让开右下角标)、`badge?`(只有写了才画右下角标,如「示意数据」;真实数据别写)、`chart: "bar"|"line"|"candle"`、`series: [{label, value, color?}]` 或 K 线 `[{label, o, h, l, c}]`、`decimals`(柱/点标签,默认 1)、`prefix`、`suffix`、`highlight: {index, text, sub}`、`colors: {main, accent, dim}`、`upDown: "cn"`(红涨绿跌,默认)`|"us"`、`xAxis: "category"|"time"`(柱默认按类目每根写名字,折线/K 线默认按时间抽稀)。
+
+| kind | 字段 | 说明 | 示例 |
+|---|---|---|---|
+| `title` | — | 版式先出(标题、副标题、来源) | `{"at":0,"kind":"title"}` |
+| `bar` / `line` / `candle` | `dur`(默认按根数);柱状图可写多个 bar,各带 `data.index`(数或数组)=这几根在这一刻才长 | 坐标系→数据长出。柱一律从 0 起;折线/K 线纵轴不从 0 时副标题自动加「纵轴未从 0 开始」;负数柱的数值写在柱底下方、标注往下走;类目名放不下先缩字再错成两行,被标注的那根永远有名字;刻度按步长取小数位 | `{"at":1.2,"kind":"bar"}` |
+| `highlight` | `text`/`sub` 覆盖 data.highlight,`data.index` 第几根 | at 这一帧标注圆点弹出,引线+文字;斜向放会压到别的柱子或数值时改放这根正上方,顶上不够就自动加一档刻度 | `{"at":4,"kind":"highlight","data":{"index":2},"text":"最高"}` |
+| `number` | 见上方 number 口径 | 图区上方专留一条,不压折线线头 | `{"at":5,"kind":"number","text":"最新收盘","data":{"value":259.97,"prefix":"¥","decimals":2}}` |
+
+最小 spec:
+```json
+{"grammar":"t3_finance_chart","duration":6,"data":{"title":"三家公司的研发投入","unit":"2024 年,亿元","source":"来源:示意数据","badge":"示意数据","chart":"bar",
+ "series":[{"label":"甲","value":120},{"label":"乙","value":86},{"label":"丙","value":43}]},"cues":[
+ {"at":0,"kind":"title"},{"at":1,"kind":"bar"},{"at":3.5,"kind":"highlight","data":{"index":0},"text":"最多"}]}
+```
+
+#### y1_kurzgesagt(扁平科普:星球+卫星节点+尺度穿行)
+
+spec 级 data:`center`(第一层中心星球的名字)、`flow: true`(节点串成一条链、信号依次流过、带序号,讲「先后」时用)。
+
+| kind | 字段 | 说明 | 示例 |
+|---|---|---|---|
+| `title` | `text` | 顶部标题逐字上浮;第一个 highlight 或 enter 的 at 起 0.5s 淡出 | `{"at":0,"kind":"title","text":"一次搜索经历了什么"}` |
+| `point` | `text`,`data.color` | 当前这一层的一个卫星节点+标签胶囊。≤3 个排上半圈,≥4 个绕一整圈。标签按当前镜头夹在画内,长标签先缩字 | `{"at":1.4,"kind":"point","text":"分词"}` |
+| `highlight` | `data.index`(只数当前层的 point,从 0 起,默认最新) | 相机推近那个节点,其余变暗,1.2s 推完 | `{"at":5,"kind":"highlight","data":{"index":1}}` |
+| `enter` | `data.index`(钻进哪个节点,默认最新),`text`(新中心的名字,默认用节点名),`dur`(默认 1.6) | 尺度穿行:at 这一帧开始推进,约 at+0.55×dur 满屏同色、切到新一层,at+dur 新中心星球拉出完毕;之后的 point 都属于新一层(第一个新 point 的 at 写在 at+dur 之后) | `{"at":4,"kind":"enter","data":{"index":0},"text":"分词器"}` |
+
+最小 spec:
+```json
+{"grammar":"y1_kurzgesagt","duration":6,"data":{"center":"搜索引擎","flow":true},"cues":[
+ {"at":0,"kind":"title","text":"一次搜索经历了什么"},
+ {"at":1.2,"kind":"point","text":"抓取"},{"at":2,"kind":"point","text":"索引"},{"at":2.8,"kind":"point","text":"排序"},
+ {"at":4.2,"kind":"highlight","data":{"index":2}}]}
+```
+
+#### y2_vox(拼贴桌面:截图、剪报、红线、荧光笔)
+
+spec 级 data:无。
+
+| kind | 字段 | 说明 | 示例 |
+|---|---|---|---|
+| `image` / `clip`(同义) | `image`,`text`=下方黑底标签,`data.halftone: true` 转灰度网点 | at 起滑入桌面;等比放、不裁,加纸白边和胶带。横屏左→右排、竖屏上→下排,红线连起来 | `{"at":1,"kind":"image","image":"截图.png","text":"官网首页"}` |
+| `title` | `text`(空的或纯空格会告警并跳过) | 黑底白字标签条,打字 13 字/秒 | `{"at":0,"kind":"title","text":"这件事有三条线索"}` |
+| `point` | `text` | 横线索引卡,打字(间隔短会提速到最多 40 字/秒) | `{"at":4,"kind":"point","text":"发布时间比公告早一天"}` |
+| `highlight` | `data.rect=[x,y,w,h]`(相对**当前这张图** 0..1) | 荧光笔扫过→红圈→相机推近。rect 目测常偏 20–30%,先 `--stills` 核 | `{"at":2.5,"kind":"highlight","data":{"rect":[0.1,0.2,0.3,0.1]}}` |
+
+最小 spec(不需要截图也能用:标题+索引卡):
+```json
+{"grammar":"y2_vox","duration":6,"cues":[
+ {"at":0,"kind":"title","text":"这次涨价的三条线索"},
+ {"at":1.6,"kind":"point","text":"供应商先发了通知"},
+ {"at":3.4,"kind":"point","text":"两周后官网改了价格"}]}
+```
+
+#### y3_whiteboard(白板手绘:说一句写一句、画图标、圈重点)
+
+spec 级 data:无。
+
+| kind | 字段 | 说明 | 示例 |
+|---|---|---|---|
+| `title` | `text` | 7.5 字/秒起,赶不上下一个 cue 自动提速 | `{"at":0,"kind":"title","text":"为什么要写测试"}` |
+| `point` | `text` | 先画小圈当项目符号再写,16 字/秒起 | `{"at":1.5,"kind":"point","text":"改代码时有人替你盯着"}` |
+| `draw` | `data.icon`(`person cat network doc chat bulb check cross screen stack gear target clock chart`;写错会告警、只写说明字),`text`=图标下的说明(放不下先缩字号),`data.arrow: false` 不画箭头 | 和刚写的那条字并排;连续的 draw 用橙箭头连起来 | `{"at":2.5,"kind":"draw","text":"自动检查","data":{"icon":"check"}}` |
+| `image` | `image` | 之字形揭开+手绘框,等比不裁 | `{"at":4,"kind":"image","image":"草图.png"}` |
+| `highlight` | `data.index`(第几个,从 0 起),`data.target`: `"title"` / `"draw"` / `"image"`(默认数 point),`data.style: "underline"` | 橙圈圈住或划线;不写 index = 最新写出的那一条 | `{"at":5,"kind":"highlight","data":{"index":0,"style":"underline"}}` |
+
+最小 spec:
+```json
+{"grammar":"y3_whiteboard","duration":6,"cues":[
+ {"at":0,"kind":"title","text":"为什么要写测试"},
+ {"at":1.5,"kind":"point","text":"改代码时有人替你盯着"},
+ {"at":2.7,"kind":"draw","text":"自动检查","data":{"icon":"check"}},
+ {"at":4.4,"kind":"highlight","data":{"index":0}}]}
+```
+
+#### y4_storytime(豆子花叔讲故事:气泡、反应特写、插入镜头)
+
+spec 级 data:无(有 `window.VO_ENV` 就按口播包络对口型,没有就按字数合成)。safe 只让字(气泡、插入镜头的大字);角色、桌子、反应特写的脸是图形,竖屏下会伸进字幕带——字幕压在身体上读得清,但别指望它们让开。
+
+| kind | 字段 | 说明 | 示例 |
+|---|---|---|---|
+| `point` / `title`(同义) | `text`=口播原文(定张嘴时长,≈6.5 字/秒),`sub`=气泡里实际显示的短句(≤12 字最好;不写才显示 text),`data.pose`: `talk` / `point` / `shrug` / `type` | at 这一帧气泡弹出、开始张嘴 | `{"at":0.1,"kind":"point","text":"我让它帮我改个错别字,","sub":"就改一个字"}` |
+| `highlight` | `data.mark`(默认「?」) | 「?」「!」弹出+摊手担心 | `{"at":4,"kind":"highlight","data":{"mark":"!"}}` |
+| `react` | `dur`(从 at 起算,默认到下一个 cue) | 跳到反应大特写:死鱼眼+汗滴,一言不发 | `{"at":3,"kind":"react"}` |
+| `insert` | `sub`=他在电脑上打的那一行(长了折行,最多 3 行),`text`=砸出来的大字,`data.hit`(**绝对秒**,默认 at+1.3,没有 sub 时 at+0.4),`data.count`+`data.unit`(右上计数器在砸出时停在这个数),`data.app`(窗口标题,默认「AI助手」),`dur`(从 at 起算,默认到下一个 cue) | 切到桌上电脑的屏幕特写:打字→回复像代码墙越滚越快→大字砸出 | `{"at":2,"kind":"insert","sub":"改个错别字","text":"改了 40 个文件","data":{"hit":3.4}}` |
+
+最小 spec:
+```json
+{"grammar":"y4_storytime","duration":6,"cues":[
+ {"at":0.1,"kind":"point","text":"我让它帮我改一个错别字,","sub":"就改一个字"},
+ {"at":2,"kind":"insert","sub":"把「的」改成「得」","text":"改了 40 个文件","data":{"hit":3.4}},
+ {"at":4.4,"kind":"react"}]}
+```
+
+#### y5_kinetic_type(动态文字:一个 cue 一页)
+
+spec 级 data:`palette: [[底色, 字色], …]`(按页轮换)。
+
+| kind | 字段 | 说明 | 示例 |
+|---|---|---|---|
+| `title` / `point` | `text` 主词(太长自动缩字号、最多两行),`sub` 辅句,`data.label`(左上小标签),`data.key`(辅句里要着色的那个词),`data.num`(背景巨型序号) | 主词在 at 这一帧砸进来,换页是色带擦除(at 前 0.3s 开始)。两个以上 point = 清单:画进度轨+背景巨型序号 | `{"at":1.8,"kind":"point","text":"慢","sub":"每次只改一处","data":{"label":"01","key":"一处"}}` |
+| `number` | 见上方 number 口径 | 一页大数字 | `{"at":4,"kind":"number","sub":"一次跑通的比例","data":{"value":87.5,"decimals":1,"suffix":"%"}}` |
+| `highlight` | `data.word`(主词里的词;不给就刷整个主词) | 荧光笔+放大一下;荧光笔和字同色(深蓝底黄字页)时笔下的字反白成底色。word 不在主词里会告警、什么都不做(辅句里的词用 `data.key`) | `{"at":3,"kind":"highlight","data":{"word":"慢"}}` |
+
+最小 spec:
+```json
+{"grammar":"y5_kinetic_type","duration":5,"cues":[
+ {"at":0,"kind":"title","text":"慢就是快"},
+ {"at":1.8,"kind":"point","text":"慢","sub":"每次只改一处","data":{"key":"一处"}},
+ {"at":3.3,"kind":"point","text":"快","sub":"一次就跑通","data":{"key":"跑通"}}]}
+```
+
+### 样例(`scripts/engine/examples/`)
+
+```sh
+cd <skill>/scripts
+uv run --with playwright python engine/render.py --spec engine/examples/t3_finance_chart.json --out t3.mp4 # 英伟达五个财年营收(10-K 真实数据,无示意角标)
+uv run --with playwright python engine/render.py --spec engine/examples/t2_keynote_ui.json --out t2.mp4 # 教程:两张截图进玻璃卡+框出时间轴
+uv run --with playwright python engine/render.py --spec engine/examples/t1_3b1b.json --out t1.mp4 # 梯度下降:公式+损失曲线+三个要点
+uv run --with playwright python engine/render.py --spec engine/examples/y2_vox.json --out y2.mp4 # 横图+竖图贴桌面、荧光笔+红圈+推近到落定的收盘价
+uv run --with playwright python engine/render.py --spec engine/examples/y3_whiteboard.json --out y3.mp4 # 白板:标题+三条要点+圈重点+揭开截图
+# 另有 y1_kurzgesagt / y4_storytime / y5_kinetic_type.json;样例素材在 examples/assets/,都是 t3 自己渲出的终帧(数字已落定、无播放条、无路径)
+```
+
+### 给管线导演的提醒
+
+- 一段动画别塞太多 cue:按第一节的镜头时长,3–8 秒的片段放 2–5 个 cue 最舒服;cue 太密,写字会被迫提速、相机来不及到位。
+- 画面里有字的语法(t1/t3/y3/y5)会和管线的烧录字幕抢视线,叠层时把字幕挪开或这段不烧。
+- 透明模式(`--alpha`)只去掉背景层,元素本身的阴影还在;y2 的纸片、t2 的玻璃卡在透明底上读作「浮在画面上的卡片」。t3 是白纸黑字,透明底下字带一圈白色光晕,叠深色画面也读得清;t1 的白字带深色光晕。
+- **竖屏里贴截图,要框口播正在念的那半句。** 竖屏桌面上一张截图约 900px 宽,网页里 16px 的正文要推近 2–2.5 倍才看得清;框住整段宽字(框宽接近画宽)时红圈放不下,镜头就推不进去。一句话跨两行就拆成两个 highlight,各对一个关键词(2026-10-04 实测:拆开后推近 2.4 倍,字高约 50px)。rect 目测常偏 20–30%,先 `--stills` 渲一张核。
+- **语法文件里的步进动画要从 at 起算。** 「一拍二」之类的步进如果按绝对时间网格取整(`MO.step(t, 12)`),元素会比 at 早最多一格露出(30fps 下早 2 帧)。写成 `MO.step(t − at, 12)`,at 这一帧才是第一帧。y4 的角色帧仍按绝对 24fps 取,cue 落点可能差 1 帧,用前先核。
+
+---
+
+## 六、回归(2026-10-04 收进 skill 时)
+
+| 对象 | 结果 |
+|---|---|
+| 16 段原片(`eras.js`)、36 段全风格样片(`--film gallery`) | 改前改后同一时刻 61 帧逐像素一致;qa 全部无报错、确定性 ✓,运动/跳变数字不变,耗时背靠背 21.5 → 22.3 ms/帧(噪声内) |
+| 8 支示范片 vs 实验原片 | 每片 16 个时刻(含转场窗口)逐像素一致;qa 25 段全部无报错、确定性 ✓;运动、跳变、耗时和原工程一致(各片首段起点从 8/16s 变成 0,qa 采样窗口不同,所以首段数字略有出入) |
+| 2026-10-05 终审修复后 | 8 份样例+16 原段+36 样片+8 支示范片共 87 段 qa 全部确定性 ✓、无页面报错;样例静帧只有预期的变化(t2 差 1 色阶=修确定性、y5 深蓝页关键词改橙、y1 标题真的淡出);独立终审 36 份 spec(横屏样例、竖屏、压力、边界、alpha)无 🔴 |
+| 已知的跳变 | y1_s3(42 倍→1 倍拉出中段)、y2_s2/s3(快摇与推满照片)、t1_s3(穿进神经元)、y5 拍点重音——都是设计内的相机推拉或节拍闪,原片里就有 |
+
+---
+
+## 七、踩过的坑
+
+- **(2026-10-04 接入口播管线实测)y2 推近后下一处框在画外,荧光笔在画外开扫。** 观众晚 7 帧才看到。已改:框的起点不在当前镜头里时,镜头先移过去、at 前一帧到位,再揭开;推近的倍数同时受「红圈留在画里」约束(红圈比框宽 1.24 倍、高 1.5 倍)。
+- **(2026-10-04 参数化片段审片)t3 刻度撒谎、类目没名字、大数字压线头。** `fmtTick` 只在步长 <1 时留小数,步长 2.5 时 −2.5/2.5/7.5 被印成 −3/3/8;10 根类目柱竖屏按 `ceil(n/6)` 抽稀,被标注的「第一」恰好没名字;number 固定在图区右上角,上涨的折线线头正好在那。三处都改了(见第五节 t3 一行)。
+- **(同上)y2 文字卡没打完相机就走。** 相机离开只看下一件的 at−0.95。现在按「打完+停 0.5s」才起跑(最晚 at−0.4),间隔短就把打字从 13 字/秒提到最多 40 字/秒。
+- **(同上)普惠体 Medium/Bold 的全角空格字宽是 0。** 源字体(阿里巴巴普惠体 3.0 的 65/85 两个字重)本身就是 0,「美元 纵轴未从 0 开始」粘成一串。`font_subset.py` 抽子集时自动设成和「一」同宽;已有文件用 `--fix-widths` 修过。
+- **(同上)t3 竖屏的标注正好落在烧录字幕带上。** 竖屏图表底部在 y≈1660,标注在 y≈1460,和 1080×1920 片子的字幕(1400–1520)重叠。加了 `safe`。
+
+- **(2026-10-05 参数化片段终审)照样例写都对,换成竖屏和真实长度就出画。** 独立终审 33 份 spec(横屏样例、自写竖屏、压力、边界、alpha)查出 12 条 🔴:y2 空 text 让渲染器死循环卡住;y5 深蓝页荧光笔和黄字同色把主词涂没、竖屏长数字出画;t1 竖屏 7 条要点压进字幕带;t3 竖屏副标题与来源行出画、标注压邻柱、透明底叠深色看不见;y1 竖屏标签被切;y3 竖屏说明出画;y4 竖屏打字溢出气泡;t2 同一时刻先后渲差 1 色阶(复用的缓冲带上一帧残留)。另自测出 `TY.charsIn` 不乘外层透明度(y1 标题说好的淡出是一帧消失)、t3 最低负数柱的数值压类目名、`TY.fit` 只数行数不量行宽。规律:**凡是「放不下」的地方都要有退路——先缩、再折、再让位,最后才告警**;只在样例长度上调好的版式,一碰真实口播就破。
+
+- **两组实验各写了一个 `window.YT`,API 完全不同。** 合并时按功能拆成 8 个命名空间,并给同名不同义的东西改名:G2 的 `zoomThrough`(冲进色块)→ `fillZoom`,G2 的 `spring(t, freq, decay)` → `MO.springHz`,G1 的 `circlePts`(开口椭圆)→ `DG.ellipsePts`。
+- **woff2 字体过不了字形检查。** 引擎的 `U.loadCmaps` 只会解 WOFF1/TTF,G3 的 woff2 一加载就 console.error,qa 判失败。收进来时统一转成 woff。
+- **全片时间读出来的背景会因为片子在时间轴上的位置不同而换相位。** 发布会示范的光斑原来排在 8–16s,单独成片后构图全变了,用 `T2.PHASE = 8` 保住定稿画面。参数化片段里光斑只读片段时间,不受这个影响。
+- **刻度要把数据整个包住。** `CH.ticks` 只给区间内的整刻度,最大值 130 时最高刻度可能是 100,柱子顶出坐标系;片段里补齐了上下各一档。
+- **系统字体不在 skill 里。** Vox 示范的宋体(Songti SC)、动态文字示范的代码字体(Menlo)用的是 macOS 系统字体,换台机器会变样;参数化片段已全部换成 skill 自带的字体。
+
+
+## 口播整片与第9种语法
+
+以上8种已提供参数化片段。另有[讲解员式财经科普](动画语法/y6_presenter_explainer.md),提供语法和整片参考代码,尚无参数化片段。完整口播制作、框景检查和经验回流见[口播整片与经验回流](12-口播整片与经验回流.md)。
diff --git "a/references/10-\350\247\222\350\211\262.md" "b/references/10-\350\247\222\350\211\262.md"
new file mode 100644
index 0000000..a4405d5
--- /dev/null
+++ "b/references/10-\350\247\222\350\211\262.md"
@@ -0,0 +1,32 @@
+# 10 · 角色:人用 AI 生帧,代码负责合成
+
+## 角色实现的选择
+
+同一角色可用三种方式实现(A、B的并排图见`assets/角色/花叔形象_对比.jpg`;C的效果见Kurzgesagt与白板示范片):
+- **A 代码画**:几何角色与运动白模适用,复杂人脸的表现有限。
+- **B 已定帧库直接贴**:容易保持角色一致,但需要协调帧库与场景的画风。
+- **C 按该片画风生成动作帧再合成**:用参考图保持身份,绿幕抠图后交给代码控制动作与材质。
+
+真人和拟人角色优先采用B或C,几何角色可以继续用代码画。风格卡里保留了各类角色的已知短板。
+
+## B:贴已定帧库
+
+- 帧库:你自己已经定稿的角色帧(如挥手、拖拽等,每动作 8 帧透明 PNG;通用动作帧需自行准备;长卷示范附带的三段角色帧见`scripts/engine/demos/long_scroll/frames/`)。
+- 引擎启动时作为图片资源加载;渲染按 `floor(t*9)%8` 换帧——有限动画,不做补间。
+- 以脚底中心为锚点放置;`face=-1` 水平翻转。
+- 给帧加所在片的材质(Vox 加白色剪纸边和投影;笔触类风格可在帧上再过一层细笔触 source-atop)。
+
+## C:按画风生一版
+
+1. **生图**:用 gpt-image 一类支持参考图的生图模型(prompt 写法可参考 [huashu-gpt-image](https://github.com/alchaincyf/huashu-gpt-image)),批量时串行跑。ref = 角色三视图设定稿或已定帧库的母版;prompt 写清:
+ - 该画风的**造型语法**(不是只写「XX 风格」):Kurzgesagt 纯色块不描边、同色相深一档做阴影;Vox 黑白网点剪报照片+白色剪纸边;白板黑色马克笔线稿+橙色排线;莫奈短笔触光斑……
+ - **姿势与镜头调度对齐**(「侧身朝右伸手指向右边」);要动就一张出多帧 sprite(4×2 八帧,帧数写在开头、「同一角色」锁一致性、只给关键姿势让模型补中间、「每帧站在单元格底部居中、大小一致」)。
+ - 绿幕 `#00B140`(白帽白 T 不能用白底)。
+ - 定规(以花叔形象为例):**纯白**渔夫帽(模型爱画成浅灰,要写死)、圆框黑眼镜、白 T、卡其短裤、白洞洞鞋、左手腕黑手表、大头小身体。
+2. **验真**:生图工具的输出目录文件数确实增加,且 PNG `.info` 为空(ImageMagick 拼的会有 date:create)。
+3. **抠图切帧**:`scripts/key_split.py`(去绿溢、按列切姿势;白板线稿用 `--white` 只裁不抠、贴进画面用 multiply);需要保留原画面坐标时用 `scripts/key_green.py`。
+4. **合成**:代码只决定位置、大小、朝向、换帧时机、材质;石子、涟漪、道具等互动物件仍用代码画并对齐到手的位置。
+
+## 什么时候还用代码画
+
+几何角色(方块、终端、机器人、小鸟、猫)、剪影、极简符号人(哈林小人、白板火柴人)可以代码画。`lib/rig.js` 的少女/猫骨架与 `rig_huashu.js` 保留:用于运动参考(手在哪、脚在哪,给 AI 帧定锚点)、白模预演、几何风格。
diff --git "a/references/11-\351\225\277\345\215\267\347\251\277\350\266\212\347\211\207.md" "b/references/11-\351\225\277\345\215\267\347\251\277\350\266\212\347\211\207.md"
new file mode 100644
index 0000000..f1c22d0
--- /dev/null
+++ "b/references/11-\351\225\277\345\215\267\347\251\277\350\266\212\347\211\207.md"
@@ -0,0 +1,43 @@
+# 11 · 长卷穿越片:一个人从左走到右,穿过一幅幅名画
+
+《花叔穿越名画》(2026-10-05,123.7 秒,24 个世界)用的做法。和艺术史速通(同一个房间换画风)不同,这里是**一条横向长画卷**:每个世界是一段横向延展的画,首尾相接;主角一直往右走,跨过边界那一刻,他的画风和世界一起换。
+
+示范:`scripts/engine/demos/long_scroll/`,收了 3 段(埃及壁画 → 莫奈《日本桥》→ 8-bit 像素),约 15.6 秒。
+
+```sh
+uv run --with playwright python scripts/engine/render.py --film demos/long_scroll --stills 1,5,9 --out 试渲 # 三张静帧
+uv run --with playwright python scripts/engine/render.py --film demos/long_scroll --out long_scroll.mp4 # 整段
+```
+
+浏览器预览:在 `scripts/engine/` 起一个静态服务,打开 `index.html?film=demos/long_scroll`;`&only=28_monet,14_8bit` 只排这几段,`&v=330` 试别的步速。
+
+## 文件
+
+| 文件 | 管什么 |
+|---|---|
+| `eras.js` | 片子入口:加载库、`FILM_ORDER`(段的顺序)、登记帧库、生成一个 `dur = WORLD.total` 的段 |
+| `lib/world.js` | 骨架 `WORLD`:时间轴(走→停下互动→走)、主角行进、相机、按边界裁开的主角、边界、角标。**先读它的头部注释** |
+| `lib/crossing.js` | `XING`:读帧库、画角色帧(`XING.actor`)、笔触材质、莫奈世界 |
+| `lib/acts.js` | `ACT`:小剧本工具(打水漂的石子轨迹等) |
+| `lib/xing2_*.js` | 几段共用的小工具,由段文件开头按需加载 |
+| `segments/<id>.js` | 一个世界一个文件,调用 `WORLD.add({...})` |
+| `frames/<key>/` | 角色帧库:8 张透明 PNG+`meta.json`(每帧脚底锚点 `ax/ay`、尺寸、是否离地 `air`;`ref_h` 是站立身高的像素数) |
+
+## 加一段
+
+1. 在 `segments/` 新建 `<id>.js`,调用 `WORLD.add({ id, year, name, w, hero, acts, back, front, seam })`,接口见 `lib/world.js` 头部注释。世界本身用代码画,优先把 `scenes/<id>.js` 里现成的风格场景改造成横向延展的版本(段宽 2000–2800)。
+2. 生角色帧:每个世界一张「走路 8 帧」,有互动的再加一张「互动 8 帧」,按该画风让生图模型重画、绿幕、切帧(`scripts/key_split.py`,做法见 10 号),放进 `frames/<key>/`,写好 `meta.json`。
+3. 把 `<id>` 加进 `eras.js` 的 `FILM_ORDER`。
+4. 渲静帧核边界两侧,再跑 `qa.py --project scripts/engine --film demos/long_scroll`,确定性必须 ✓。
+
+## 关键约定(全片统一,写死在骨架里)
+
+- **地面线 `WORLD.GROUND = 760`,主角站立身高 300,主角在画面 720px 处。** 段两端(x=0 和 x=w 附近 ±150px)地面必须回到 760,地平线尽量落在 480–560,跨边界时两边才接得上。中间可以有桥、台阶(`ground: lx => y`)。
+- **所有事件相对「互动开始」定时。** 用 `WORLD.actT(段)` 拿到互动开始的全片时刻,`r = S.t - WORLD.actT(ME)`;不要写「进段后第几秒」。全片步速后来从 330 提到 560,按这条写的段一处都不用改。
+- **镜头只进不退。** 相机目标 = 主角 x − 720 + 互动时向前让出的 `lead`,取历史最大值再做高斯平滑,所以全程单调、停与起都不顿。互动想让镜头别动,就写 `lead: 0`。
+- **每段的边界用该段的签名语言画**(`seam`:纸边、像素棋盘、彩块分栏线……),这是速通片「转场 = 下一个风格的签名语言」在长卷里的版本。
+- **主角走路帧率随步速同比例**(`hero.fps`),8 帧一个步态循环;需要再过一层该画风的材质时,在段里写 `hero.draw(c, key, i, o, S)` 自己合成,不改共用库。
+- **配乐**:画面先定,音乐后配。每段放整数拍,逐段把速度在 86–104 BPM 之间微调,让每条边界都落在小节第一拍(实测 24 条边界最大误差 11.7ms);人耳听不出 ±8% 的逐段速度差。
+- **不要替主角加没要的梗。** 骨架里有「帽子上摞纪念品」的功能(`FILM_HAT_ITEMS`),容易与场景争夺视觉注意力,默认关闭。
+
+更多证据和数字见 `07-正面经验.md` 第 36–38 条。
diff --git "a/references/12-\345\217\243\346\222\255\346\225\264\347\211\207\344\270\216\347\273\217\351\252\214\345\233\236\346\265\201.md" "b/references/12-\345\217\243\346\222\255\346\225\264\347\211\207\344\270\216\347\273\217\351\252\214\345\233\236\346\265\201.md"
new file mode 100644
index 0000000..0ad71ec
--- /dev/null
+++ "b/references/12-\345\217\243\346\222\255\346\225\264\347\211\207\344\270\216\347\273\217\351\252\214\345\233\236\346\265\201.md"
@@ -0,0 +1,25 @@
+# 口播整片与经验回流
+
+本页收录口播整片制作中的通用方法;不包含作者的私人反馈档案。片段接口仍见09号,角色见10号,长卷示范见11号。
+
+## 从口播到画面
+
+先确认脚本、口播和逐字时间,再做风格表与高光清单。动作挂关键词(如参考代码的`TM.cue`),不要把每一处时间写死。镜头跟着内容外框移动;字幕区是相机空间的约束,推近时也必须让开。
+
+白板在同一大画布上累计,块首第一笔与相机到位同步;块内再按语速写。用`const B = DG.board(...)`建立画板后,矩形调用`B.line(points, {smooth:false})`避免平滑样条鼓成椭圆。完整清单的阅读时间从最后一项呈现完成开始计算,不能把绘制时间算成可读停留。
+
+Vox拼贴先建立物件、关系和相机,再加纸纹与装饰。讲解员片先安排不同版式和景别,后期只挪人物位置补不回单调分镜。
+
+## 验收与冻结
+
+`qa.py`提供确定性、效率、动感、流畅及文字框景线索。框景可检测文字裁切、叠字、字幕区及近空白;装饰大字等可能误报,要看对应帧。浅底成片用`subzone_gate.py`补查图形进入字幕带;纹理底不适用这项深色像素阈值。
+
+交付前由没有参与制作的agent独立审片,长片至少两位。问题记录时间码、根因、改动和复验;旧问题回归与新问题发现分开。根据具体问题验收,不追逐总分。连续三轮同类问题仍在且两种修法均无效,回到素材或引擎能力;上游脚本问题回脚本处理。
+
+用户选定后同时冻结代码、时间轴、混音和字幕。候选成片与冻结版保存在项目内,未经确认不覆盖。
+
+## 经验如何回到skill
+
+每轮记录现象→根因→改法→验证→归宿。风格特有问题写对应语法卡,跨风格方法写09号,角色方法写10号,机器可量的写QA。反复出现的坑提炼为开工检查,做成引擎能力后减少文字规则。修改后让独立agent核验,写入CHANGELOG。
+
+项目的私人反馈、个人形象提示词和未公开素材留在项目内;公开skill只收可复用的方法与必要证据。
diff --git "a/references/\345\212\250\347\224\273\350\257\255\346\263\225/t1_3b1b.md" "b/references/\345\212\250\347\224\273\350\257\255\346\263\225/t1_3b1b.md"
new file mode 100644
index 0000000..ae006bb
--- /dev/null
+++ "b/references/\345\212\250\347\224\273\350\257\255\346\263\225/t1_3b1b.md"
@@ -0,0 +1,114 @@
+# t1_3b1b · 3Blue1Brown 式数学/概念可视化
+
+> 一句话语法:**黑底上只放「正在讲的那一个东西」,用平滑形变(Transform)把上一个概念直接变成下一个,颜色=概念的名字,全片几乎不切。**
+>
+> 示范片:`scripts/engine/demos/t1_3b1b/`(渲染 `render.py --film demos/t1_3b1b`)(8s,3 镜头)· 总览 `assets/动画语法/t1_3b1b_总览.jpg` · 代码 `scripts/engine/demos/t1_3b1b/`
+
+## ① 适用场景
+
+- **用**:讲一个机制「怎么一步步变成另一个东西」——神经网络前向传播、注意力、矩阵变换、梯度下降、概率分布、算法流程。口播是「我们把这张图压平成一列」「每个像素乘上一个权重」这种**动作型句子**时最合适:每句话对应一次 Transform。
+- **用**:观众需要「看见数学」——公式里的符号与画面里的物体一一对应(公式的 W 是蓝色,连线也是蓝色)。
+- **别用**:产品发布、情绪/品牌片(黑底白线太冷、太慢);数据真实走势(那是 t3 的活);口播是观点、故事、金句时(没有可以「变形」的对象,硬上只剩装饰)。8 秒以内的快剪也不合适——3b1b 的原生节奏是一个动画 1–3 秒+停 1 秒(见⑤),压到 8 秒 3 个镜头已经是上限。
+
+## ② 画面构成
+
+| 项 | 取值 | 依据 |
+|---|---|---|
+| 背景 | **纯黑 #000000** | Grant 自己的 `custom_config.yml`。网上流传的「深海军蓝 #0E1525」是营销博客的说法,不是原作 |
+| 饱和度 | 色值照 manim 常量,再整体 **×1.5 饱和**(`DG.saturate`) | Grant 导出时 ffmpeg `saturation=1.5`;照原值用会发灰 |
+| 主色(原值→×1.5 后) | BLUE_C `#58C4DD` · RED_C `#FC6255` · YELLOW `#FFFF00`(3b1b 版是纯黄,不是 CE 的奶黄 `#F7D96F`)· TEAL_C `#5CD0B3` · GREEN_C `#83C167` · GREY_A–E `#DDD/#BBB/#888/#444/#222` | 3b1b/manim `default_config.yml` |
+| 颜色编码 | 一个颜色只代表一个概念,全片不换:本片 **黄=激活/信号,蓝=正权重,红=负权重**,公式里的 `a` 是黄、`W`/`w` 是蓝 | 3b1b nn 第二集 part2.py:正权重 BLUE、负权重 RED |
+| 线宽 | 默认描边 4(1080p 约 4px);坐标/网络连线 2;网格主线 2、细分线 1 且不透明度 0.25 | manimlib `coordinate_systems.py` |
+| 单位 | 画面高 = 8 个 manim 单位 → **1 单位 = 135px**(`DG.U`) | manim 默认 frame_height=8 |
+| 神经元 | 白描边 2px;**填充不透明度 = 激活值**;半径 0.15 单位(≈20px),同层间距 0.25 单位;每层最多画 16 个,其余用 ⋮+大括号 | `_2017/nn/part1.py` |
+| 连线 | 从圆周到圆周;线宽 `3·(|w|/max)³`(本片 `0.6+3.2·|w|³` px),正蓝负红 | part2.py |
+| 字体 | 公式 **Computer Modern**(CMU Serif,本工程 `CMU-rm/CMU-it`);中文配思源宋体(与 CM 同为衬线、笔画对比接近) | custom_config:Text 字体 "CMU Serif" |
+| 构图 | 一屏一个主体,居中或左右对称;标题/公式固定在上方 1/8(y≈110–150),不随相机动 | — |
+| 形状语言 | 圆、方格、直线、大括号、箭头;**几乎不用发光**——「发光感」来自纯黑底上的高饱和细线,不是 bloom | 原作观察;需要强调时用 Indicate 染黄,不加光晕 |
+
+## ③ 运动轨迹
+
+- **缓动**:默认 `smooth = 6t⁵−15t⁴+10t³`(3b1b 版,两端速度和加速度都为 0;CE 版是 sigmoid,`MO.smoothCE`)。**几乎所有动画都用它**;linear 只给 Write、匀速旋转、ShowPassingFlash 的推进。`there_and_back` 给 Indicate,`rush_into/rush_from` 给「冲进/冲出」。
+- **默认时长**:Animation run_time=1s,wait=1s。2023–24 年源码统计:显式 run_time 最常见 2s(481 次)>3s(333)>1s(187)>4s(145)。
+- **LaggedStart**:默认 lag_ratio 0.05;源码里最常用 0.1。实现:`MO.lagged(i, n, p, r)`(第 i 个占 `[i·r, i·r+1]`,总长 `1+(n−1)r`)。本片 100 个像素→神经元用 0.01(1.1s 走完),160 条连线用 0.006。
+- **Write**:linear;<15 个子物件 1s,否则 2s;子物件间 lag = `min(4/(n+1), 0.2)`;每个字「先描轮廓、后填色」(`DG.math`/`DG.write`:lineDash 推进描边 → 后 60% 填色淡入、描边淡出)。
+- **Transform**:两个形状重采样成同样点数、**起点对齐**(都从左上方向起、顺时针),逐点直线插值(path_arc=0)+颜色插值。`DG.rectPts/circlePts/morph`。本片:方格→圆(像素→神经元),权重格→飞向一个神经元(加权求和)。
+- **入场/出场**:FadeIn/FadeOut 带 shift(本片 24–40px,「从下往上」或「往上淡走」);新层神经元从右侧 24px 淡入;被替换的东西缩成点并入「⋮」。
+- **信号**:ShowPassingFlash(time_width 2)——把连线复制一份染黄、线宽 ×1.5,可见段 `[max(0,u−2), min(1,u)]`,u 从 0 到 3(`DG.flash`),按输入行 lag 0.04 错开。
+- **相机**:MovingCameraScene 的 frame 动画——本片镜头 1 绕网格 1→1.025 慢推、镜头 2 1→1.08 推向输出层;3D 场景环绕 0.5–3°/s(3b1b 默认 1°/s)。
+- **持续微动**:原作在 wait 里通常是**静止的**——这是 3b1b 与发布会片最大的不同。本片为满足「持续运动」只加了极慢相机推(≤3%/镜),不加呼吸、漂浮。
+
+## ④ 转场(常用 4 种)
+
+1. **Transform 接续(不切)**:上一镜末帧=下一镜首帧,靠形变把旧对象变成新对象。本片镜头 1→2:100 个像素方格变成一列输入神经元,镜头 2 首帧与镜头 1 末帧逐像素相同。这是 3b1b 的头号转场,占绝大多数。
+2. **镜头穿越(zoom through)**:相机绕一个物体指数推近(`zoom = Z^e`,感知速度恒定),物体圆周变成开口,里面是新画面。`TRANSITIONS.zoomThrough`,参数 `live:true`(旧镜头自己在 lt>时长时继续推相机,矢量重画不糊)、`r0`(物体半径)、`zoom ≥ 1100/r0`(否则开口盖不满屏、最后一帧跳)、`focus`(新画面主体先待在开口正中,e>0.55 才归位)。本片镜头 2→3:先把激活 0.95 的那个隐藏神经元描边染黄(「我们来看这一个」),再推进它 48 倍,0.75s。
+3. **FadeOut(shift=UP) + FadeIn(shift=UP)**:换话题时全部往上淡走、新内容从下淡入(`TRANSITIONS.fadeShift`)。
+4. **ReplacementTransform 标题/公式**:旧公式的符号移动到新公式里同名符号的位置(TransformMatchingTex,3b1b 版默认 2s);对不上的符号淡出淡入。
+
+## ⑤ 节奏与文字
+
+- **镜头时长**:原作是连续场景,单个动画 1–3s、后面 wait 1s;一个「镜头」(一个概念)常 8–20s。本片 8 秒 3 个镜头(2.6/2.8/2.6s)是**压缩版**,真用在口播里应拉长 2–3 倍。
+- **与口播对位**:Grant 的流程是**先排动画、后录口播**("I start by laying out all of the animations… then once I record the voiceover, the actual editing is like a day")。所以对位规则是「一句话=一个动画」:句子说出动作动词时动画开始,句末落定后 wait 约 1s 给观众看。
+- **文字**:标题/提问在动作之前 Write 出来(先问后演);公式与画面同时出现、同色;数值(0.95)跟着填充计数,不先于画面出现。中文一屏不超过一行标题+一行注释。
+- **FAQ 原则**:"Every movement on the screen should be deliberate, with an identifiable purpose"——没有讲解目的的动作要删。
+
+## ⑥ 代码实现要点
+
+> 收进 skill 后(2026-10-04 v0.4):本卡「新写」里的通用函数已统一进 `scripts/engine/lib/`(名字已换成统一后的 MO / CAM / DG / TY / CH / UI / CL / TOON),示范片自己的代码在 `scripts/engine/demos/t1_3b1b/`。库速查和「怎么为一段口播选语法」见 `references/09-视频动画语法.md`。
+
+- 复用 skill:`engine.js`(时间轴、转场框架、`renderSolo`)、`render.py`、`PAINT.hex/cached`、`U.clamp/lerp/hash`。
+- 改了引擎副本两处:段落可写 `dur`(秒);转场可 `punch:0` 关掉拍点镜头冲击(讲解片不要那一下)。
+- 新写、现已统一进库 `lib/diagram.js`(`window.DG`;`lerpPts` 改名 `morph`,相机归 `CAM`):色板+`saturate(×1.5)`、`camera/toScreen`、`rectPts/circlePts/lerpPts/shape`(Transform)、`neuron/edgeEnds/edge`、`flash`(ShowPassingFlash)、`indicate`、`circumscribe`、`layout/math/write`(公式排版+Write)、`brace`。
+- 新写 `lib/motion.js`(`window.MO`,三种风格共用):`smooth/smoothCE/thereAndBack/rushInto/rushFrom/doubleSmooth`、`lagged`(`count/fmt/tabular` 收进库后在 `TY`)。
+- 新写转场(已进 `transitions.js`):`zoomThrough`、`fadeShift`。
+- 关键参数:神经元 r=17/22/32px;镜头 3 讲的是**隐藏层**神经元(它的 100 个权重才能画成 10×10 图;输出神经元连的是隐藏层,不是像素——审片抓到的逻辑错);连线 alpha 0.7–0.85;信号黄线 3–4.5px;Write 字号 58(标题)/64(公式)。
+- 字体:`scripts/font_subset.py` 按片中用字子集化思源宋(全量 25MB → 300KB);CMU 从 jsDelivr `bitmaks/cm-web-fonts@master/font/Serif/` 取 woff(注意是 `font/` 不是 `fonts/`)。
+
+## ⑦ 代表作品与一手参考
+
+- 代表作:3Blue1Brown《But what is a neural network?》(2017)、《Essence of linear algebra》、2024《Transformers》系列。
+- https://github.com/3b1b/videos/blob/master/custom_config.yml (背景 #000、CMU Serif、saturation 1.5)
+- https://github.com/3b1b/manim/blob/master/manimlib/default_config.yml (色值)
+- https://github.com/3b1b/manim/blob/master/manimlib/utils/rate_functions.py (smooth 等)
+- https://github.com/3b1b/manim/blob/master/manimlib/animation/creation.py (Write/ShowCreation 参数)
+- https://github.com/3b1b/videos/blob/master/_2017/nn/part1.py 、part2.py (神经元与权重画法)
+- https://github.com/ManimCommunity/manim/blob/main/manim/utils/rate_functions.py (CE 版对照)
+- https://www.3blue1brown.com/faq ("Avoid pointless animations")
+- https://www.dwarkesh.com/p/grant-sanderson (先排动画后录口播)
+
+## ⑧ 最容易做错的 3 件事
+
+1. **把「发光」当成 3b1b 的标志去加 bloom、加深蓝渐变底。** 原作是纯黑底+高饱和细线+×1.5 饱和,几乎没有光晕。加了光晕就成了「科技感 PPT」。
+2. **全用 linear 或普通 ease,动画又快又多。** 默认必须是 smooth(五次多项式),一个动画 1–3s 后停 1s;每个动作要对应口播里的一个动词。
+3. **颜色编码中途变卦/颜色太多。** 一个颜色=一个概念,公式里的符号和画面里的物体同色;超过 3–4 种语义色观众就记不住。
+
+## qa 数字(skill `scripts/qa.py`,2026-10-04,审片前)
+
+| 镜头 | 运动% | 静止帧对% | 跳变 | 均/峰 ms | 确定性 |
+|---|---|---|---|---|---|
+| t1_s1 | 1.83 | 17.7 | 0 | 1.5/2.4 | ✓ |
+| t1_s2 | 7.1 | 0.0 | 0 | 2.2/3.1 | ✓ |
+| t1_s3 | 3.26 | 0.0 | 0 | 1.0/2.2 | ✓ |
+
+## 修订(独立审片 → 改一轮,2026-10-04)
+
+审片 agent 只看成片,t1 提了 2 条 🔴、2 条 🟡:
+
+| 审片意见 | 改法 |
+|---|---|
+| 🔴 逻辑错:镜头 3 把输出神经元「猫」的权重画成 10×10 像素模板,但输出层连的是隐藏层 | 改成推进**激活 0.95 的隐藏层神经元**(3b1b 原片讲隐藏层就是这样把权重画成图),结论「像猫脸 0.95」与镜头 2 里它的亮度一致;公式 a⁽¹⁾ 本来就指隐藏层,不用改 |
+| 🔴 结论没有停留,0.92 在最后 0.1s 才数到;图例提前淡出 | 镜头 3 时间轴整体前移:1.65–2.0s 数到 0.95,Indicate 到 2.3s,**停 0.6s**;图例留到片尾 |
+| 🟡 推镜前停留太短、新标题出来时挂着粗连线残影 | 推镜前先描黄目标神经元 0.3s;开口外旧画面改为 p 0.45–0.8 退完;新标题 0.75s 才开始写 |
+| 🟡 8 秒塞 5 个概念 | 保持 8 秒(任务要求),卡片⑤写明真用时拉长 2–3 倍 |
+
+另:镜头 1 落定后的神经元改用真圆画(原来是 48 边形),镜头 1 末帧与镜头 2 首帧**逐像素相同**(实测差值 0)。
+
+修订后 qa:
+
+| 镜头 | 运动% | 静止帧对% | 跳变 | 均/峰 ms | 确定性 |
+|---|---|---|---|---|---|
+| t1_s1 | 1.9 | 15.8 | 0 | 1.6/2.7 | ✓ |
+| t1_s2 | 8.41 | 4.2 | 0 | 2.1/2.8 | ✓ |
+| t1_s3 | 2.66 | 15.1 | 8 | 0.9/2.0 | ✓ |
+
+t1_s3 的 8 个「跳变」在 lt 1.06–1.23s(像素图整体滑到权重图上)和 1.51–1.54s(100 格收拢)——看过逐帧,是有意的大位移,不是穿帮;15% 静止帧对来自结尾 0.6s 的停留(3b1b 的 wait,有意为之)。
diff --git "a/references/\345\212\250\347\224\273\350\257\255\346\263\225/t2_keynote_ui.md" "b/references/\345\212\250\347\224\273\350\257\255\346\263\225/t2_keynote_ui.md"
new file mode 100644
index 0000000..37ccc51
--- /dev/null
+++ "b/references/\345\212\250\347\224\273\350\257\255\346\263\225/t2_keynote_ui.md"
@@ -0,0 +1,109 @@
+# t2_keynote_ui · 发布会式界面与渐变动效
+
+> 一句话语法:**深色底上缓慢漂移的彩色光斑,一屏一件事;字收紧、从模糊里浮出来;界面做成玻璃卡片在 3D 里用无回弹/轻回弹弹簧落位,数字计数、光扫过,转场靠「同一块玻璃」展开。**
+>
+> 示范片:`scripts/engine/demos/t2_keynote_ui/`(渲染 `render.py --film demos/t2_keynote_ui`)(8s,3 镜头)· 总览 `assets/动画语法/t2_keynote_ui_总览.jpg` · 代码 `scripts/engine/demos/t2_keynote_ui/`
+
+## ① 适用场景
+
+- **用**:产品/功能发布、版本更新、「三个新功能」、价格与参数公布、开场品牌片、视频里的「这个产品是什么」段落。口播是**名词+数字**(「Plover 2」「延迟 320 毫秒」「100 万 tokens」)时最合适:一句一屏,名词出现时字浮出,数字说到时落定。
+- **用**:需要把「界面截图」讲得高级——把 UI 放进玻璃卡、放到 3D 里转正。
+- **别用**:讲机制原理(玻璃和光斑不承载逻辑,用 t1);讲数据走势(用 t3);严肃事故/财报坏消息(这套语言自带「好消息」的情绪);内容本身没有一个能放大的「主角」时(只剩空镜光斑)。
+
+## ② 画面构成
+
+| 项 | 取值 | 依据 |
+|---|---|---|
+| 底色 | 近黑:本片 `#050508`;Apple `#000/#161617/#1d1d1f`;Linear `#08090a`(上一级 `#0f1011/#141516`,正文 `#f7f8f8`,描边 `#ffffff14`) | 两家官网 CSS 实测 |
+| 光斑 | 4 团径向渐变 screen 叠加 → 1/4 尺寸上模糊 90px → 放大铺满 → 叠 3.5% 静态颗粒防色带。色相走 Stripe 一系:紫 `(150,90,238)`、蓝 `(56,104,255)`、青 `(120,214,255)`、一点暖红 `(255,96,84)`;中心再压一层 38% 黑径向渐变给白字让对比 | Stripe 2021 渐变 `#a960ee #ff333d #90e0ff #ffcb57` |
+| 光斑运动 | 每团漂移振幅 90–260px、周期 9.5–13s,**避开 5s 周期**(HIG:避免 ~0.2Hz 持续摆动) | Apple HIG Motion |
+| 玻璃卡 | 背景取样模糊 40px(Apple 导航 `saturate(180%) blur(20px)`,NN/g 说越大越好)+白 7.5% 填充+顶部 14% 白渐变受光带+1.5px 渐变描边(左上亮、右下暗)+大阴影(blur 70–80,y+30–40,α0.5) | apple.com globalheader.css;NN/g Glassmorphism |
+| 圆角 | 卡片 36px;**同心圆角**:内部图标底圆角 = 36 − 内边距 14 = 22 | WWDC25「子圆角 = 父圆角 − padding」 |
+| 字体 | Inter(SF Pro 最接近的开源字,Linear 用 Inter);中文思源黑。标题 600 字重、**大字号字距收紧 −0.02 ~ −0.03em**(`T2.track`) | Apple 96px −0.015em、Linear 64px −0.022em、OpenAI 64px −0.03em |
+| 文字层级 | 白 `#f5f5f7` 主、`rgba(235,235,245,.6)` 次、`#a7a7b4` 眉题(字距 +6px);产品名用白→淡紫→淡青横向渐变 | Apple 官网层级惯例 |
+| 构图 | 一屏一个焦点,居中对称;三卡等宽 480、间距 52;大数字占画面宽 55% 以上 | — |
+| 形状语言 | 圆角矩形、胶囊、细线图标(圆头等线宽,SF Symbols 气质,`UI.icon`) | — |
+
+## ③ 运动轨迹
+
+- **弹簧(主力)**:SwiftUI duration+bounce 参数化,`MO.spring(t,{duration,bounce})`:mass=1、stiffness=(2π/d)²、damping=4π(1−bounce)/d → 阻尼比 ζ=1−bounce。**默认 bounce 0**(最通用);0.15 利落几乎不弹(本片卡片入场 d=0.75、气泡 d=0.5);0.3 明显弹;>0.4 对 UI 夸张。`.smooth/.snappy/.bouncy` 都是 d=0.5。
+- **曲线(非弹簧)**:apple.com 导航 `.32s cubic-bezier(.4,0,.6,1)`;本片字的浮现用 CSS `ease`=`(.25,.1,.25,1)`(`MO.appleOut`);Linear 主力 ease-out-quad `(.25,.46,.45,.94)` .16s;Stripe 建议 <500ms、`(.2,1,.2,1)`。`MO.bezier(x1,y1,x2,y2)` 通吃。
+- **字的入场**:模糊 18–26px → 0、上移 16–40px → 0、透明 → 1,0.7–1.0s(`TY.blurIn`)。眉题 → 产品名 → 副标题依次错开 0.2–0.4s。
+- **卡片入场**:从下方 170px、绕 Y 轴 ±0.55rad(≈31°,两侧卡朝外)、缩放 0.9 → 弹簧落位;三张错开 0.1s。3D 用 `UI.persp`(竖条切片透视,persp 1800px;Stripe 用 600、Linear 用 1000)。
+- **持续微动**:卡片漂浮 7px、周期 3.4/3.85/4.3s(两频叠加,`MO.float`)+ry 轻摆 ±0.06rad;光斑漂移;相机匀速慢推 1→1.045(**线性**,减速到停会让画面「死」)。
+- **计数**:卡片落定后 0.25s 起 0.9s(同一个数只数一次——展开成全屏后沿用「100万」,不再从 0 重数);`easeOutExpo`(CountUp.js 默认缓动)——最后一位慢慢落定;数字**等宽排布**(`TY.tabular`,Canvas 不能开 tnum,不排会抖)。
+- **光扫过**:斜 −20°、宽 110–140px 的亮带 0.8–0.9s 扫过;在文字离屏上用 `source-atop`(只亮在字上),在卡片上用 `lighter`;三张卡按各自屏幕位置算进度 = 同一道光。
+
+## ④ 转场(常用 5 种)
+
+1. **模糊推进(blurPush)**:旧画面缩到 0.92+模糊 24px+淡出,新画面从 1.06 带模糊落到 1.0 清晰,0.55s,`ease`。**底下先垫一层放大 1.08 的重模糊旧画面**,缩小的画面四周才不露黑边。本片镜头 1→2。
+2. **共享元素展开(expandRect)**:(新画面第一帧就**不透明**装进卡片——卡片是半透明的,任何溶接都会看到新旧两层字叠在一起)被选中的卡片(先放大到 1.06、两侧卡后退变暗到 45%)从自己的屏幕矩形展开成全屏,圆角 38→0,弹簧 d=0.55 bounce 0;新画面一开始就按卡片大小缩放装在卡里。**选中卡在展开前停止漂浮**,转场才从一个稳定矩形起跳。本片镜头 2→3。
+3. **匹配剪辑**:前后两镜同一物体同一位置(产品名 → 卡片标题位置)。
+4. **遮罩擦除/光扫切**:一道光扫过时在光带后面换画面。
+5. **折射代替淡入淡出**(Liquid Glass):元素出场时逐渐改变折射/模糊强度,而不是直接降透明度(本片字的模糊浮现即此思路)。
+
+## ⑤ 节奏与文字
+
+- **镜头时长**:发布会演讲一屏常 5–8s(Jobs 2007 iPhone 70 秒 9 屏≈7.8s/屏);产品片快剪 1.5–3s。本片 2.6/3.0/2.4s。
+- **一屏一件事**:一个名词、一个数字、一张卡。密集段落后放一屏空的给观众喘气(Presentation Zen 说的 counterweight)。
+- **与口播对位**:名词说出前 0.2–0.3s 字开始浮现(浮现本身要 0.7s,说到时正好清晰);数字在口播说出数值时**落定**——计数起点 = 说数字时刻 − 计数时长;三卡依次入场对应「第一、第二、第三」。
+- **文字**:标题 ≤6 个字或一个产品名;副标题一句话 ≤16 字;卡片:标题 4 字+一行说明+一个大数字+单位(小一号、灰一级)。
+
+## ⑥ 代码实现要点
+
+> 收进 skill 后(2026-10-04 v0.4):本卡「新写」里的通用函数已统一进 `scripts/engine/lib/`(名字已换成统一后的 MO / CAM / DG / TY / CH / UI / CL / TOON),示范片自己的代码在 `scripts/engine/demos/t2_keynote_ui/`。库速查和「怎么为一段口播选语法」见 `references/09-视频动画语法.md`。
+
+- 复用 skill:`engine.js`、`render.py`、`PAINT.cached/hex`、`U.rng`。
+- 新写、现已统一进库 `lib/ui.js`(`window.UI`):`mesh`(光斑底)、`grainTex`、`backdrop`(模糊副本,毛玻璃取样)、`shadow`(只画影子)、`glass`(毛玻璃卡)、`sheen`(光扫过,`comp` 可选)、`persp`(绕 Y/X 轴伪 3D)、`icon`、`rr/rrPath`、`scratch`。
+- `lib/motion.js`:`spring/smoothSpring/snappy/bouncy`、`bezier/appleOut/emphasized`、`float`;数字与文字在 `lib/typo.js`:`TY.count/tabular`、`TY.blurIn`(实验时叫 MO.textIn)。
+- 转场(实验时在 `transitions_info.js`,现已进 `transitions.js`):`blurPush`、`expandRect`。
+- 性能:每帧画一次光斑(1/4 尺寸)+一次背景模糊副本,均 40–60ms/帧(qa 带 GPU flush);8 秒 60fps 渲完约 1 分钟。
+- 坑(已修进库里):①**blur 会从画布外拉进透明像素**,画进不清空的离屏会逐帧累积,qa 报确定性 ✗——先垫一层不模糊原图;②透视切片相邻重叠 0.75px 在半透明纹理上出一条条纹——切片边界取整像素首尾相接,并先画进离屏再整体按 alpha 贴回;③`UI.sheen` 内部设了合成模式,会盖掉外面设的 `source-atop`,所以做成参数。
+
+## ⑦ 代表作品与一手参考
+
+- 代表作:Apple iPhone/Apple Intelligence 发布片与 apple.com 产品页;OpenAI GPT-4o / o 系列发布视频;Linear 官网与 Linear Release 视频;Stripe 2020–21 官网渐变。
+- https://developer.apple.com/videos/play/wwdc2023/10158/ (Animate with springs:duration/bounce)
+- https://developer.apple.com/videos/play/wwdc2018/803/ (Designing Fluid Interfaces:从 100% 阻尼起步)
+- https://developer.apple.com/videos/play/wwdc2025/219/ (Meet Liquid Glass)
+- https://developer.apple.com/design/human-interface-guidelines/materials 、/motion 、/typography
+- https://www.nngroup.com/articles/glassmorphism/
+- https://web.archive.org/web/20211015000000/https://stripe.com/ (渐变色值)
+- https://stripe.com/blog/connect-front-end-experience (<500ms、曲线)
+- https://linear.app/now/how-we-redesigned-the-linear-ui (LCH 色彩、Inter)
+
+## ⑧ 最容易做错的 3 件事
+
+1. **玻璃后面没东西。** 毛玻璃只模糊它后面的内容;深色纯底上的「玻璃」就是一块灰矩形。先画有色彩、有起伏的光斑,再按卡片屏幕位置取样模糊。
+2. **弹簧太弹、动作太多。** bounce 默认 0,入场最多 0.15–0.3;>0.4 立刻廉价。一次只动一组东西。
+3. **大字没收紧字距、光斑颜色发脏。** 64px 以上 −0.015~−0.03em;光斑每团颜色各占一块(screen 叠加+大模糊),别把多色线性平均成灰紫泥。
+
+## qa 数字(skill `scripts/qa.py`,2026-10-04,审片前)
+
+| 镜头 | 运动% | 静止帧对% | 跳变 | 均/峰 ms | 确定性 |
+|---|---|---|---|---|---|
+| t2_s1 | 0.58 | 35.4 | 0 | 39.8/51.4 | ✓ |
+| t2_s2 | 2.62 | 8.5 | 0 | 60.2/65.0 | ✓ |
+| t2_s3 | 1.84 | 9.6 | 0 | 44.3/51.0 | ✓ |
+
+说明:t2_s1 的「静止帧对 35%」不是卡——光斑漂移和 4.5% 的慢推每帧变化低于 qa 的像素阈值(>12 级),隔 1 秒取两帧(成片 1.6s vs 2.6s)有 26.8% 的像素变化超过 12 级、78% 超过 4 级;这类「慢呼吸」画面要另用间隔帧差判断。
+
+## 修订(独立审片 → 改一轮,2026-10-04)
+
+| 审片意见 | 改法 |
+|---|---|
+| 🔴 2.55–2.75s、5.6–5.85s 转场四周露黑边 | blurPush / expandRect 底下垫一层放大 1.08、模糊 30px 的旧画面 |
+| 🔴 卡片展开时「长期记忆」「100万」两层叠影;展开后又从 0 重数 | 新画面第一帧不透明装进卡片;全屏页沿用「100万 tokens」同一口径,不重数 |
+| 🔴 6.95s 计数一帧从 999,023 跳到 1,000,000,「tokens」被挤 | 随上条删掉重复计数;单位按三段实测宽度排版,不再贴字 |
+| 🟡 落版只出现 0.4s、y≈1020 出安全区 | 落版 1.2–1.8s 浮现、停 0.6s,y=972;对话面板整体上移 65px |
+| ⚪ 卡片「100万」与全屏「1,000,000」口径不一 | 统一为「100万」 |
+
+修订后 qa:
+
+| 镜头 | 运动% | 静止帧对% | 跳变 | 均/峰 ms | 确定性 |
+|---|---|---|---|---|---|
+| t2_s1 | 0.58 | 35.4 | 0 | 39.5/51.6 | ✓ |
+| t2_s2 | 2.62 | 8.5 | 0 | 57.2/59.9 | ✓ |
+| t2_s3 | 0.97 | 15.4 | 0 | 43.0/48.7 | ✓ |
+
+(转场冒烟:blurPush 最慢约 137ms/帧,含两次全屏模糊。)
diff --git "a/references/\345\212\250\347\224\273\350\257\255\346\263\225/t3_finance_chart.md" "b/references/\345\212\250\347\224\273\350\257\255\346\263\225/t3_finance_chart.md"
new file mode 100644
index 0000000..7451538
--- /dev/null
+++ "b/references/\345\212\250\347\224\273\350\257\255\346\263\225/t3_finance_chart.md"
@@ -0,0 +1,107 @@
+# t3_finance_chart · 财经数据图表动画
+
+> 一句话语法:**先搭坐标系、再让数据「长」出来、最后只标一件事;一个颜色讲主角、其余变灰;数值永远诚实(柱从 0 起、单位和来源写在图上),动画只决定「怎么出现」,不改变「是多少」。**
+>
+> 示范片:`scripts/engine/demos/t3_finance_chart/`(渲染 `render.py --film demos/t3_finance_chart`)(8s,3 镜头,数据全部虚构,每镜右下角「示意数据」)· 总览 `assets/动画语法/t3_finance_chart_总览.jpg` · 代码 `scripts/engine/demos/t3_finance_chart/`
+
+## ① 适用场景
+
+- **用**:营收/利润/用户数的增长、股价走势、市场份额排名变化(bar chart race)、地区对比(地图着色)、某个事件前后的拐点。口播里出现**具体数字、时间、比较**(「五年涨了 8.7 倍」「2023 年 3 月之后」)时。
+- **用**:需要「可信」的段落——观众会截图转发、会较真。
+- **别用**:只有一个数(直接大字报,用 t2 的计数);数据本身不可靠或你不愿标来源时(宁可不做图);讲原理(用 t1)。
+
+## ② 画面构成
+
+| 项 | 取值 | 依据 |
+|---|---|---|
+| 底 | 白 `#FFFFFF`(经济学人网页图);或 FT 三文鱼粉 `#FFF1E5` | Economist 2017 图表风格指南;FT o-colors 源码 |
+| 版式 | **顶部细红线(8px)+左上红色小旗(96×22)+粗体标题(一句结论)+副标题(指标、单位)+左下来源** | Economist 风格指南版面示例 |
+| 主色板 | ECON RED `#E3120B`、蓝 `#006BA2`、青 `#3EBCD2`、绿 `#379A8B`、黄 `#EBB434`、灰 `#758D99`、黑 `#0C0C0C` | Economist 图表色板 |
+| 强调法 | **一个颜色讲主角,其余变浅灰**(本片:最后一根柱保持蓝,其余过渡到 `#C6D2D8`) | Datawrapper「用灰压住次要数据」 |
+| 网格 | 只有水平网格,细灰(本片 α0.13、1.5px);**只有零基线是黑实线**(3px);y 轴刻度值放右侧网格线上方 | Economist 风格指南 |
+| 字体 | 经济学人用 Econ Sans(Cnd);本片用 Roboto Condensed(数字)+思源黑(中文)。标题 700、副标题/轴 400;轴字最小、来源最小最浅(75% 黑) | 同上 |
+| 涨跌色 | **中国大陆 A 股:红涨绿跌**(本片);香港与欧美:绿涨红跌。面向中文观众必须在图上写明「红涨绿跌」;色盲友好替代:蓝/橙+▲▼符号 | Jiang 等 2014(JBDM);Bloomberg 终端色盲模式 |
+| 线宽 | 主数据线 5px(本片)、均线 4px;标注引线 2px | — |
+| 形状语言 | 矩形柱、折线+末端圆点、K 线实体+影线、小圆点+引线标注 | — |
+
+## ③ 运动轨迹
+
+- **顺序(staging)**:版式 0–0.5s → 网格从左往右逐条画出(lag 0.12,easeOutQuint)→ x 轴标签依次淡入上移 → 数据 → 强调色变化 → 标注。每阶段约 0.5–1.3s。Heer & Robertson 2007:复杂变化要分阶段、一律缓入缓出、单步「需要多长就多长」约 1s;先坐标轴后数据是行业惯例(无实证研究,但它让观众先知道「尺子」再看「量」)。
+- **柱**:从 0 基线长出,easeOutQuint,依次错开(lag 0.22,共 1.3s);数值标签跟着柱顶走、同步计数(`CH.bars`)。
+- **折线**:按 **x(时间)** 推进画出,不按弧长——时间匀速流过,陡峭段自然画得快,读得出「暴涨」;头部 9px 圆点+价格标签跟随(等宽数字);面积渐变 α0.14→0。本片 1.5s,smooth(最后一个价格「落」在点上)。D3 官方示例是 5000ms linear,适合独立图表,视频里压到 1.5–2s。
+- **标注**:在线头**经过**事件点的那一刻触发(`tHit` 由缓动反函数算出)——圆点弹出(spring d0.45 bounce0.25)+一圈脉冲 → 0.12s 后引线画出 → 0.3s 后文字淡入。**一镜只标一件事**。
+- **K 线**:逐根出现(lag 0.06,0.2–1.3s),实体从开盘价长到收盘价、影线随后展开;成交量柱同步;右上价格跟着「最新出现的那根」滚动,颜色按相对区间起点的涨跌。
+- **数字**:count-up 用 easeOutExpo(CountUp.js 默认 2s;视频里 0.9–1.3s);所有滚动数字等宽排布防抖。
+- **相机/持续运动**:图表镜头匀速慢推 1→1.03(每镜),不晃不摇;推近转场期间相机继续矢量推近(不放大位图)。
+- **排名赛跑(本片未用)**:D3 官方 bar chart race 每关键帧 250ms、帧间线性插 10 帧、显示 12 根;换位约 0.5s;名次变化要错开,避免所有柱同时上下乱跳。
+
+## ④ 转场(常用 5 种)
+
+1. **面板横推(slidePush)**:新面板从右推入、旧面板向左推出,中间一道品牌红竖条领路,0.5s,`cubic-bezier(.7,0,.2,1)`。本片镜头 1→2。新面板在推入过程中就开始搭版式(红线生长、标题浮现)。
+2. **推进到局部(zoomThrough,live+bScale0)**:相机绕最新数据点推近 6 倍(旧镜头自己矢量重画),新画面(最近 20 日 K 线)从 0.6 倍溶进来,主体(最新一根 K 线)对准推进点。本片镜头 2→3。没有圆形开口时一定要设 `bScale0`,否则新画面会像一张浮在中间的小卡片。
+3. **图表间形变(morph)**:同一数据换图形(柱→点→线),先移动到位、再变形(Heer & Robertson:散点→柱先横移再变形;堆叠→分组先改宽再落下)。**不同指标之间不要 morph**(营收柱变成股价线会暗示二者同量纲)。
+4. **坐标轴重标**:数据范围变了先变刻度(旧刻度淡出、新刻度淡入),再动数据。
+5. **硬切+版式不动**:同一版式换一张图,红线/标题位置不变,只换内容——经济学人视频最常用。
+
+## ⑤ 节奏与文字
+
+- **镜头时长**:一张图 2.5–6s;本片 2.8/2.7/2.5s 是压缩版(真用时一张图配一到两句口播)。叙事结构:铺垫(Establisher)→ 引发 → 高潮(Peak)→ 收束(Amini 等 2015,50 支专业数据视频)。
+- **与口播对位**:数字**说出时正好落定**——柱长完、标签停在 107.9 的那一刻对上「一百零七点九亿」;标注在线头经过事件时弹出,对上「2023 年 3 月发布大模型之后」。所以先定口播时间点,再倒推动画起点。
+- **文字**:标题写结论(「营收五年涨到原来的近 9 倍」——**「涨到」不是「涨了」**:8.7 倍是涨到原来的 8.7 倍=涨了 7.7 倍,审片抓到过),副标题写指标与单位(「年营收,亿元」);倍数要能从图上数字算出来(107.9÷12.4=8.70);轴不从 0 时写在副标题(「纵轴未从 0 开始」);来源一行左下;虚构数据右下「示意数据」角标每镜都在。
+
+## ⑥ 代码实现要点
+
+> 收进 skill 后(2026-10-04 v0.4):本卡「新写」里的通用函数已统一进 `scripts/engine/lib/`(名字已换成统一后的 MO / CAM / DG / TY / CH / UI / CL / TOON),示范片自己的代码在 `scripts/engine/demos/t3_finance_chart/`。库速查和「怎么为一段口播选语法」见 `references/09-视频动画语法.md`。
+
+- 复用 skill:`engine.js`、`render.py`、`U.rng`(虚构数据全部种子生成,可复现)、`PAINT.hex`。
+- 新写 `lib/chart.js`(`window.CH`):`lin`(比例尺,带 `inv`)、`ticks`(1/2/2.5/5×10ᵏ 刻度)、`grid`(网格逐条画出、零线加粗、刻度值右置)、`xLabels`、`bars`(从 0 长出+同步计数+高亮/变灰)、`line`(按 x 推进、头部点、面积)、`yAt`、`candles`(逐根 K 线,涨跌色可配)、`callout`(点→引线→文字)、`tag`(红色小旗)、`demoBadge`(示意数据角标)、`mixHex`。
+- `lib/motion.js`:`lagged`、`quintOut/expoOut`(实验时叫 easeOutQuint/easeOutExpo)、`spring`(标注圆点);`TY.count/tabular/fmt`。
+- 转场(已进 `transitions.js`):`slidePush`、`zoomThrough`(live、bScale0、focus)。
+- 事件触发时刻:`tHit = 起点 + 时长 × smooth⁻¹(事件x占比)`(二分求反函数),标注永远和线头同步,改了线的时长不用手调。
+
+## ⑦ 代表作品与一手参考
+
+- 代表作:The Economist 网页图表与视频;FT 图表;Bloomberg Originals / Quicktake 的数据段;Flourish 的 bar chart race。
+- Economist 图表风格指南 2017(镜像):https://sa.ipaa.org.au/wp-content/uploads/2026/02/Economist-CHARTstyleguide_20170505.pdf
+- FT 色板源码:https://unpkg.com/@financial-times/o-colors/src/scss/_palette.scss
+- Heer & Robertson 2007, Animated Transitions in Statistical Data Graphics:https://idl.cs.washington.edu/files/2007-AnimatedTransitions-InfoVis.pdf
+- D3 bar chart race:https://observablehq.com/@d3/bar-chart-race-explained
+- Correll 等 2020(截断坐标轴的夸大效应,断轴标记也救不回来):https://arxiv.org/abs/1907.02035
+- Datawrapper:柱从零 https://www.datawrapper.de/academy/why-our-column-and-bar-charts-start-at-zero ;双轴 https://www.datawrapper.de/blog/dualaxis ;色盲 https://www.datawrapper.de/blog/colorblindness-part2
+- 红涨绿跌的文化差异:https://onlinelibrary.wiley.com/doi/10.1002/bdm.1800
+- CountUp.js(easeOutExpo、2s):https://github.com/inorganik/countUp.js
+
+## ⑧ 最容易做错的 3 件事
+
+1. **截断坐标轴。** 柱状图一律从 0;折线和 K 线可以不从 0,但要在图上写明。Tufte 的 Lie Factor(图上效应÷数据效应)超出 0.95–1.05 就算失真。
+2. **颜色太多、全部都是主角。** 一个颜色讲故事,其余变灰;红绿含义面向谁要写清(A 股红涨,欧美红跌)。
+3. **动画太花读不出数。** 不要弹跳柱、3D 柱、旋转饼图;分阶段、缓入缓出、一步约 1s;数字落定后至少停 0.5s 让人读。
+
+## qa 数字(skill `scripts/qa.py`,2026-10-04,审片前)
+
+| 镜头 | 运动% | 静止帧对% | 跳变 | 均/峰 ms | 确定性 |
+|---|---|---|---|---|---|
+| t3_s1 | 1.39 | 0.0 | 3 | 1.3/1.9 | ✓ |
+| t3_s2 | 2.37 | 4.7 | 0 | 1.9/2.8 | ✓ |
+| t3_s3 | 0.96 | 0.0 | 0 | 1.6/2.3 | ✓ |
+
+说明:t3_s1 的 3 个「跳变」在 lt 2.10/2.20/2.27s,正是四根柱同时由蓝变灰(高亮主角)和标注弹出的那几帧——有意的大面积变化,不是穿帮。
+
+## 修订(独立审片 → 改一轮,2026-10-04)
+
+| 审片意见 | 改法 |
+|---|---|
+| 🔴 标题「涨了近 9 倍」与标注 8.7 倍口径错(应为「涨到」) | 改为「营收五年涨到原来的近 9 倍」;股价页同口径「涨到原来的 7.5 倍」 |
+| 🔴 月线终点 ¥268 与日 K 286.40 对不上(推镜推的就是这个点) | 月线末点 = 最新价 286.4,倒数第二个月收盘 = 日 K 起点 242;**两镜之间的数字必须能互相推出来** |
+| 🟡 5.6s「¥268」和计数中的价格两个大红数叠影 | 股价头部标签在推进转场开始 0.2s 内收掉 |
+| 🟡 「成交量」压 K 线、量柱顶到 240 网格线 | 标签移到右下空处;量柱按最大量归一,留 6px 间隙 |
+| 🟡 日 K 页 2 秒读不完 | 删 5 日均线;K 线 1.3s 出完、括注 1.75s 落定、停 0.75s |
+| ⚪ 红涨绿跌与品牌红撞色 | 保留(面向 A 股观众),副标题写「红涨绿跌(A 股惯例)」;做海外版换绿涨或蓝/橙 |
+
+修订后 qa:
+
+| 镜头 | 运动% | 静止帧对% | 跳变 | 均/峰 ms | 确定性 |
+|---|---|---|---|---|---|
+| t3_s1 | 1.44 | 0.0 | 3 | 1.3/1.7 | ✓ |
+| t3_s2 | 2.45 | 4.7 | 0 | 1.9/2.6 | ✓ |
+| t3_s3 | 0.91 | 0.0 | 0 | 1.7/2.9 | ✓ |
diff --git "a/references/\345\212\250\347\224\273\350\257\255\346\263\225/y1_kurzgesagt.md" "b/references/\345\212\250\347\224\273\350\257\255\346\263\225/y1_kurzgesagt.md"
new file mode 100644
index 0000000..d851b5d
--- /dev/null
+++ "b/references/\345\212\250\347\224\273\350\257\255\346\263\225/y1_kurzgesagt.md"
@@ -0,0 +1,183 @@
+# Y1 · Kurzgesagt 扁平科普:视频动画语法卡
+
+一句话:把一个抽象概念放进一个能无限缩放的发光世界里,相机在尺度之间穿行,画面里的东西永远不停地轻轻动。
+
+示范片:`scripts/engine/demos/y1_kurzgesagt/`(渲染 `render.py --film demos/y1_kurzgesagt`)(8s,3 镜 2 转场),总览:`assets/动画语法/y1_kurzgesagt_总览.jpg`
+依据:本风格的调研(调研原文与逐帧数据留在实验归档、没收进 skill,用到的数字已摘进本卡)(2025 两支正片+2014《免疫系统》实测,官方 Skillshare 课逐字稿)。标【实测】【一手】的数字出自那里,标【本片】的是示范片里实际用的参数。
+
+---
+
+## ① 适用场景
+
+**用它:**
+- 讲尺度、讲「里面是什么」的内容:从细胞到星系、从一个像素到一个模型,或者「放大看会发现……」。尺度转场是这个风格的标配。
+- 讲机制、讲系统:神经网络、免疫系统、能量流。最适合把看不见的过程画成发光的粒子和连线。
+- 口播是平稳、娓娓道来的科普腔。Kurzgesagt 约 168 词/分,一个硬切镜头大约配 2 句话【实测】。
+- 需要「严肃但可爱」的语气,可以用一个吉祥物或鸟群出来讲笑点。
+
+**别用它:**
+- 讲真实人物、真实事件、档案证据:扁平卡通会把可信度冲淡,这种内容用 Y2 拼贴。
+- 讲步骤、讲推理链:一步一步写出来更好懂,用 Y3 白板。
+- 制作预算很小的时候。这个风格的质量全靠「每一帧都有东西在动」,官方单片要 1200 小时以上【一手】。偷工减料的 Kurzgesagt 看起来就是廉价 PPT。
+
+## ② 画面构成
+
+- **先选年代**。2025 年是深色系:暗像素占 61–68%,饱和度中位 0.84–0.89。2014 年是浅灰白底、低饱和。两者不能混【实测】。示范片前两镜用 2025 深色系,第三镜白天用明亮系,模仿他们「换段落就换一整套色温」的做法。
+- **色板**(2025 深色系,实测取色):
+ - 底:`#05020F` / `#0E0631` / `#25155E`
+ - 次底:`#191670`、`#3826A3`、`#5F58DB`
+ - 强调青:`#32BAEE`、`#7DD3DC`
+ - 强调橙黄(发光体):`#F48301`、`#E07919`、`#FACC12`,辉光芯 `#F9EF93`
+ - 品红:`#BE3A95`、`#C83C7F`
+ - 高光与白字:`#E7DFE1`、`#F9FCFB`
+ - 规律:一个深底配 2–3 个高饱和强调色,强调色互为对比(橙黄对靛紫、青对品红)【实测+归纳】
+- **形状语言**:
+ - 不描边。阴影用同色相深一档的色块,高光是白色椭圆或一条弧线【归纳】。
+ - 圆角无处不在。生物是团状有机形,角色头是圆的,四肢是圆头管。
+ - 发光体必带径向辉光。暗底存在的意义就是让辉光成立。
+- **【本片】双色分面**:`flat(c, path, 本色, 阴影色, 高光色, v, w)`。在形状内部做两次平移:右下留一条阴影带,左上留一条细高光边。v≈(10,12)px,w≈(4,5)px。花叔的每个部件也走这一道,所以他和场景是同一种画法,不像贴上去的。
+- **构图**:主体放在画面中部偏下的三分线上,上方留天空给标题和星星。场景分 5–6 层视差:星空 d=0.05、月亮 0.12、远山 0.3、近坡 0.65、主体 1.0、前景叶片 1.5(近景虚、暗)。官方没公开层数,实测是 2–5 层【归纳】。
+- **角色**:
+ - Kurzgesagt 鸟:蛋形身体,大白眼,小黑瞳偏前,橙色三角喙。翅膀是比身体深一档的叶形,每只鸟换一个颜色【一手+归纳】。
+ - 【本片】猫是水滴身体加圆头,三角耳带品红内耳,大白眼;机器人是圆角壳加深色屏幕脸,一只发光镜头眼;花叔用 `HUASHU.build` 的 point 姿势,每个部件都过双色分面。
+
+## ③ 运动轨迹
+
+- **官方缓动**【一手,Skillshare】:
+ - 常规动作 50 帧(60fps 下 0.83s)。想利落用 30/20/10 帧,弹出用 5–10 帧。
+ - 循环动作用 Easy Ease 33.3%,约等于 `cubic-bezier(.333,0,.667,1)`。
+ - 其他动作用 75% influence,约等于 `cubic-bezier(.75,0,.25,1)`:起步很软,中段快,收尾很软。
+- **弹出**【实测】:卡片在 0.25s 内长到 90%,第 20 帧过冲到 108%(探测器卡是 114%),约 0.5s 回到 100%。
+ - 【本片】识别标签用 `backOut(q, 1.1)`,时长 0.5s。
+- **错开**:同类元素错开 10–20 帧,肢体之间错开 3–4 帧,动作之间停 20 帧【一手】。
+ - 【本片】标题逐字错开 45ms、单字 0.5s cubicOut。像素猫 144 块按到中心的距离错开 35ms/格,每块 0.5s backOut(1.4) 从四周飞入。神经网络逐层点亮,间隔 0.32s,节点弹一下 0.35s。
+- **持续微动(最重要)**:2025 片里 0.5s 内完全不动的时段只占 0.3%【实测】。
+ - 待机循环:50 帧 ping-pong 的浮动、星星闪、辉光呼吸、粒子漂。
+ - 眨眼 5 帧闭、10 帧开,间隔不规则,**眼睛不缩到 0**【一手】。
+ - 【本片】星星 170 颗,各自相位闪烁 1–3.5 rad/s。前景叶片 `blur(7px)` 虚焦,做景深。机器人上下浮 ±12px,喷射光用 23/37Hz 双正弦抖。猫尾两段贝塞尔摆。草叶 2.1 rad/s 摆。萤火粒子在 0.8–1.3 层漂。信号脉冲沿连线持续循环。
+- **相机**【实测】:
+ - 2025 片里约 1/3 的时间在缩放,平移约 10%,旋转约 5%,拉远多于推进。
+ - 待机慢推中位 3–4.5%/s。
+ - 【本片】镜 1 在 2.6s 里从 1.00 推到 1.10(sineInOut),约 3.8%/s,落在实测区间。
+
+## ④ 转场(常用 6 种)
+
+1. **推进穿越 → 物体颜色铺满 → 新场景**(尺度转场的标准写法)。
+ - 实测:免疫 1:48,约 1.4s,先加速后减速,峰值在中段。
+ - 【本片】转场 B:
+ - 相机对数插值推进点亮的输出节点(0.45s,cubicIn),直到满屏黄。
+ - 在中点 ±3 帧溶到机器人发黄光的眼睛。两边的高光点都在左上,剪点看不出来。
+ - 再用 cubicInOut 1.45s 拉远(42→1),落进白天的新色板。
+ - 不要用 expoOut:它起步斜率太大,第一帧就跳掉一大半尺度。
+2. **钻进物体,物体里是下一个世界**(穿越的变体)。
+ - 【本片】转场 A,1.0s:相机按 `bezier(.75,0,.25,1)` 对数推进机器人镜头(1.1→60)。下一镜只露在「镜头圆」里,圆随推进长大到盖满屏幕,圆边有一圈青色光环。下一镜同时从 0.42 倍 expoOut 浮出。
+3. **快速拉远揭示**:0.2–2s,起步快、长尾收(实测每 0.2s 缩放 1.074→1.040→…→1.0006)。用来连接微观和宏观。
+4. **光或闪光铺满画面**:用画面里的光源做白场,约 0.5s。
+5. **扫掠擦除**:物体或光带斜扫过画面,带速度线,约 0.4s。
+6. **复制增殖到铺满**:用于「数量多到……」,3–6s。
+
+另外两点【实测】:
+- 硬切比例很低,每分钟约 5 个,跟着旁白句首走,比句首早 0–0.2s。
+- 其余换画面多数是 0.3–0.6s 的设计转场,每 4.6–6.7s 一次。
+
+## ⑤ 节奏与文字
+
+- **镜头时长**【实测】:
+ - 硬切镜头中位 7–9s,均值约 11.5s。
+ - 但「视觉单元」每 4.6–6.7s 就换一次,靠设计转场换。
+ - 每句旁白里至少有一次状态变化:弹标签、换标注、形变或转场。
+- **和口播对齐**:以旁白句子的时间戳为骨架,硬切放在新句首前 0–0.2s【实测】。配乐是成片后再作曲的(Epic Mountain)【一手】。
+- **文字**:
+ - 标注是先画一条细白引线,再逐字打出文字,约 40 字符/秒;一句旁白对一个标注,停约 3s 后逐字擦掉【实测】。
+ - 章节标题卡每 2–3 分钟一张,全屏,逐词出现,背景虚化。
+ - 标签胶囊是大圆角,填饱和纯色,里面是粗体无衬线字。
+- **【本片】**:
+ - 8s 里放 3 镜,是正常节奏的约 3 倍密度,只为在演示里看全语法。真片请按 7–9s 一镜。
+ - 标题用 PuHui-Heavy 76px,逐字上浮。
+ - 层标签用 PuHui-Medium 40px,配下划线伸出。
+
+## ⑥ 代码实现要点
+
+> 收进 skill 后(2026-10-04 v0.4):本卡「新写」里的通用函数已统一进 `scripts/engine/lib/`(名字已换成统一后的 MO / CAM / DG / TY / CH / UI / CL / TOON),示范片自己的代码在 `scripts/engine/demos/y1_kurzgesagt/`。库速查和「怎么为一段口播选语法」见 `references/09-视频动画语法.md`。
+
+- 复用 skill:
+ - `PAINT.cached`、`U.rng`:确定性
+ - `RIG.smooth`:把点列平滑成 Path2D,画猫、山、叶片
+ - `HUASHU.build/pose/details`:花叔
+ - `PAINT.noise`
+ - 引擎的段落表、转场接口、离屏 A/B 缓冲
+- 新写、现已统一进库(`lib/camera.js` / `motion.js` / `typo.js`):
+ - `CAM.at(keys, t)`:关键帧相机,缩放用对数插值。`CAM.zlerp` 让每帧放大同样的倍数,尺度转场才是匀速穿越。
+ - `CAM.anchor`:缩放时让目标点平滑移到画面中心。
+ - `MO.bezier(x1,y1,x2,y2)`:把 AE/CSS 的贝塞尔缓动搬进代码,牛顿法求解。
+ - `MO.*`:sine、quint、expo、back、elastic 等。
+ - `TY.charsIn`:逐字入场。
+- 示范片自己的(`demos/y1_kurzgesagt/kurzgesagt.js`;`flat` 已进库为 `TOON.flat`,`layer` 为 `CAM.layer`):
+ - `flat()`:双色分面。
+ - `layer(c, cam, d, fn)`:视差层。位移按 d 线性,缩放按 `z^d`,深推时远景几乎不动。
+ - `Y1.cat`、`Y1.bot`、`Y1.bird`:三个角色。
+ - `Y1.lensAt(t)`:给转场 A 用的镜头圆屏幕坐标。
+- **关键架构**:
+ - 相机只由全片时间决定。转场窗口里,引擎照常把上一镜继续画进 A 缓冲,上一镜自己算「钻进去」的相机。
+ - 所以缩放转场永远是矢量重画,不会把 1920 的位图放大 60 倍糊掉。
+ - 转场函数(`transitions.js` 的 `lensReveal`、`matchCut`)只负责「A、B 怎么合」。
+- 引擎改动(只改本实验的副本):
+ - `eras.js` 的任意段可以写 `dur`(秒)。
+ - 拍点镜头冲击改成默认关,`transition.punch:true` 才开。解说片不该有卡点顿挫。
+
+## ⑦ 代表作品与一手参考
+
+- 样片:
+ - How Are Memories Stored Inside Your Brain?(2025)https://www.youtube.com/watch?v=PqtggjVAi8M
+ - Why Humanity Will Never Leave The Solar System(2025)https://www.youtube.com/watch?v=Cyl3X88KEgg
+ - The Immune System Explained I(2014)https://www.youtube.com/watch?v=zQGOcOUBi6s
+- 官方课(缓动、循环、鸟、角色动法逐字稿):
+ - Skillshare《Motion Graphics with Kurzgesagt》Part 1 https://www.skillshare.com/en/classes/motion-graphics-with-kurzgesagt-part-1/631970755
+ - Part 3 https://www.skillshare.com/en/classes/motion-graphics-with-kurzgesagt-part-3/140140401
+- 官方幕后:
+ - 1200 小时一支片:https://www.youtube.com/watch?v=uFk0mgljtns
+ - 官方自述:https://kurzgesagt.org/what-we-do?visit=videos
+- 配乐:Epic Mountain https://www.epic-mountain.com
+
+## ⑧ 最容易做错的 3 件事
+
+1. **画面停住**。做完入场就静止,立刻变成 PPT。每个元素入场后都要接一个待机循环:浮动、闪、呼吸、漂。实测 2025 片里不动的时段只占 0.3%。
+2. **缩放用线性插值,或者放大位图**。
+ - 线性插值的 z 前慢后猛,穿越感会断。要用对数插值。
+ - 把上一镜的截图放大 20 倍会糊成马赛克。必须让场景自己在更大的 z 下重画。
+3. **配色亮而杂,或者给东西加描边**。
+ - 2025 的 Kurzgesagt 是「深底+2–3 个发光强调色」,靠辉光撑画面。
+ - 加黑描边或者用中等亮度的底,就会滑向儿童绘本或企业扁平插画。
+ - 阴影用同色相深一档,不要用灰。
+
+---
+
+## 审片与修订(独立 agent 只看成片,7/10)
+
+审片意见和这一轮的处理:
+- 「猫、草、山丘带描边,像儿童插画」:草叶从线条改成填色细三角;山丘顶部的亮边压到和本色只差一档。
+- 「左下角黑块像脏东西」:前景叶片加 `blur(7px)` 做景深,颜色从近黑提到 `#0E0631`。
+- 「标题一帧消失」:改成 0.55s sineInOut 淡出。
+- 「镜 3 猫从橙变黑没交代」:橙猫留在花叔脚边当「认识的那只」;黑猫上方先出引线和小字「没见过的猫」,再弹识别标签。
+- 「7.8s 鸟穿插机器人」:鸟的高度移到 175/225px。
+- 「结尾 7.1–8.0 几乎静止」:落定后加 4%/s 慢推。
+- 「3.03–3.10s 像素猫被镜头圆裁掉一半」:没改。这是「钻进镜头」揭开过程的正常状态。
+
+## QA(skill `scripts/qa.py`,2026-10-04,修订后终版)
+
+| 镜 | 量的窗口(镜内秒) | 运动面积% 均/峰 | 静止帧对% | 跳变帧 | 每帧耗时 均/峰 ms | 确定性 |
+|---|---|---|---|---|---|---|
+| y1_s1 | 0.0–2.58 | 1.57 / 2.58 | 0.0 | 0 | 32.9 / 34.6 | ✓ 逐像素一致 |
+| y1_s2 | 1–2.68 | 3.36 / 4.42 | 0.0 | 0 | 6.1 / 7.2 | ✓ 逐像素一致 |
+| y1_s3 | 0.9–2.68 | 17.94 / 91.88 | 0.0 | 8(1.04–1.28s 连续) | 11.2 / 16.0 | ✓ 逐像素一致 |
+
+转场冒烟(每个转场渲一遍,最慢一帧):y1_s2(k_lens)48.3ms;y1_s3(k_fill)36ms
+
+读法:
+- **镜 3 的 8 个跳变帧**落在 1.04–1.28s,是连续一段,正好是「从机器人眼睛里拉出」42 倍→1 倍的中段,整屏都在缩放,所以运动面积峰值 92%。这是设计内的尺度转场,不是单帧穿帮。
+ - 第一版用 expoOut,起步斜率太大,第一帧就从 42 倍跳到 15 倍,审片和 qa 都报了。
+ - 改成 cubicInOut,峰值落在中段,和实测 Kurzgesagt「穿越式推进」的形状一致。
+- **镜 1 每帧 33ms**:前景叶片加了 `filter: blur(7px)` 做景深,比没虚化前的 9ms 慢,仍远低于 150ms 的上限。
+- 运动面积 1.6–3.4% 看起来低,因为 Kurzgesagt 的微动是「很多小东西各自动」:星、粒子、尾巴、浮动、脉冲。实测 2025 片里完全不动的时段只占 0.3%,这里三镜的静止帧对都是 0%,对上了。
+
+复跑:`uv run scripts/qa.py --project scripts/engine --film demos/y1_kurzgesagt --out <目录>`(上表是实验时的数字;收进 skill 后的复跑见 09 号的回归表)。
diff --git "a/references/\345\212\250\347\224\273\350\257\255\346\263\225/y2_vox.md" "b/references/\345\212\250\347\224\273\350\257\255\346\263\225/y2_vox.md"
new file mode 100644
index 0000000..3e04040
--- /dev/null
+++ "b/references/\345\212\250\347\224\273\350\257\255\346\263\225/y2_vox.md"
@@ -0,0 +1,185 @@
+# Y2 · Vox 式拼贴解说:视频动画语法卡
+
+一句话:把论证摆在一张有真实材料的桌面上——剪报、照片、文件,相机像调查记者的眼睛在桌上移动;线和笔一顿一顿地画上去,证据感来自「这些东西是真的被放在这里的」。
+
+示范片:`scripts/engine/demos/y2_vox/`(渲染 `render.py --film demos/y2_vox`)(8s,3 镜 2 转场),总览:`assets/动画语法/y2_vox_总览.jpg`
+依据:本风格的调研(调研原文与逐帧数据留在实验归档、没收进 skill,用到的数字已摘进本卡)。样本 5 支:Missing Chapter(2022)、迷幻海报(2019)、Vox Borders(2018)、Johnny Harris(2026),另有 Vox 2026 实拍片作对照。13 段相机运动拟合了缓动,取了色。
+
+---
+
+## ① 适用场景
+
+**用它:**
+- 有真实档案、新闻、历史、地图、人物的内容:「这件事是怎么发生的」「谁在什么时候说了什么」。
+- 口播是记者式的论证:引用、证据、因果。旁白里有「看这一句」「注意这个数字」,画面就去高亮那一句。
+- 引一句原话、一组数字、一个年份,需要观众「亲眼看到出处」的时刻。
+- 示范片用 2012 年 Google「认猫」论文的真实数字:1000 台机器、1.6 万个 CPU 核、1000 万张 YouTube 截图、不打标签。出处是 arXiv:1112.6209 与 Google 官方博客。
+
+**别用它:**
+- 纯机制、纯概念、没有任何真实材料可贴的内容。硬做会变成「假档案」,用 Y1。
+- 推导和步骤:用 Y3。
+- 需要大量角色表演的内容:剪纸角色只能一顿一顿地动。
+
+## ② 画面构成
+
+- **三色体系**(Missing Chapter 实测):
+ - 近黑底 `#171716`
+ - 纸白 `#E0DCDA`–`#EEEDED`
+ - 一种红分两档:亮红 `#B65255` 画线,暗红 `#93403C` 填面
+ - 荧光黄 `#DACF08`(比 Vox logo 的 `#FFF200` 更暗、更偏橄榄。logo 黄在片中很少大面积用)
+ - 旧地图纸 `#E4DCCF`,羊皮纸 `#CFB195`
+ - 没有纯白,没有纯黑。
+- **【本片】**:
+ - 桌面 `#e4ddcf`,平铺纸纹,有纤维和低频明暗。
+ - 线索红用 `#b8433f`,比实测略亮,因为 1080p 下要读得清。
+ - 荧光 `rgba(218,207,8,.9)`,叠加方式是 multiply。
+ - 镜 3 是桌上的一张大黑卡纸 `#1b1b1a`,四边露出桌面。
+- **材料**:
+ - 照片一律灰度网点(45°),带白边,贴两条半透明胶带。
+ - 剪报是撕边、泛黄,宋体标题。
+ - 标签是 Borders 式的黑底白字粗体条(「2012 · 谷歌」)。
+ - 索引卡是横线纸。
+ - 纸纹是**静态**的。实测停留段帧差是 0.0–0.1,没有逐帧颗粒,那是 Johnny Harris 2026 的底片风,不是 Vox。
+- **投影很弱**。黑底卡片在 360p 下几乎看不到投影【实测】。【本片】统一 blur 10、偏移 (3,6)、α 0.28。
+- **故意不完美**:Vox 美术总监的原话是「You don't want it to look perfect because that might make it look more like an ad than an editorial piece」【一手】。
+- **角色**:真人照片剪下来做贴纸,加白边和阴影。【本片】花叔用 `HUASHU.draw`,把剪影向 16 个方向偏移 12px,垫一层纸白当贴纸边。
+
+## ③ 运动轨迹
+
+- **两层帧率(核心)**【实测】:
+ - 相机层是 24fps 平滑运动。
+ - 元素层(地图色块生长、红线描路、打字、手绘圈、弹入)按 12fps「一拍二」步进。迷幻海报片里 52% 的运动帧有「动-停-动」交替的指纹。
+ - 【本片】相机按 60fps 连续算;所有元素都用 `MO.step(t, 12)` 量化后再算进度。qa 量到镜 1 有 16.9% 的静止帧对,就是一拍二的停帧,不是卡顿。
+- **相机缓动**【实测 13 段】:
+ - 时长中位 1.29s,范围 0.71–1.96s,**没有一段是线性**。
+ - 7 段是对称的 easeInOutSine,相当于 AE 默认 Easy Ease,用于长距离「找下一张卡」。
+ - 6 段是起步快、长尾落定,贴近 `cubic-bezier(.33,0,.2,1)`,用于「拉出揭示」和「沿线索追过去」。
+- **【本片】相机**:
+ - 镜 1:荧光笔扫完后,用 1.5s sineInOut 推向那一行(1.14→1.28)。BD 实测扫完常接一次推进。
+ - 转场 A:1.1s 长尾 bezier。
+ - 转场 B:推进 0.6s sineInOut。
+ - 镜 1 开场:0.9s 慢推 1.14→1.165。
+ - 镜 3:拉出 0.85s 长尾 bezier,之后 1%/s 慢推。
+- **入场**【实测】:
+ - 档案照片和剪报**随切点直接出现**,不弹、不落。
+ - 只有沿时间线追踪时,下一张卡会从画外滑入,带 5–15° 倾斜,到位放平,约 0.8s。
+ - 【本片】小照片和花叔贴纸用 `slideIn`:0.55s quartOut,从 12° 倾斜放平,12fps 步进。
+- **线与笔**【实测】:
+ - 红色下划线 0.5–1s 画完。
+ - 红色椭圆圈约 1s,一笔,首尾不闭合、略交叉。
+ - 荧光条一行 1.5–3s,跟着旁白念词扫。
+ - 打字约 13 字/秒,一拍二。
+ - 【本片】红圈 0.65s,荧光 0.9s(演示压缩),打字 13 字/秒,红线每根 0.5s、错开 0.15s,计数器 1.4s cubicOut 滚到 10,000,000。
+- **停留时慢漂**:可有可无。卡片内部有动画时相机不动;纯静态图停 3s 以上才加 0.5–1%/s 的慢漂【实测+归纳】。
+
+## ④ 转场(常用 6 种)
+
+1. **硬切**:占绝大多数,切点卡在旁白句读上【实测】。
+2. **沿红线平移(时间线追踪)**:相机沿一条红线水平移动,1.3–1.8s,用长尾缓动;下一张卡从右侧斜着滑入放平。
+ - 【本片】转场 A:红线从剪报高亮那行连到调查墙的计数标签,相机 1.1s 追过去,带沿速度方向的短运动模糊(7 次叠加,系数 0.6)。
+3. **推进进纸或照片 → 直接切成同一张图的高清扫描**:1.0–1.4s,S 型缓动。
+ - 【本片】转场 B:推满墙上那张小照片(对数插值到 z≈9.6);硬切成同一张图的大幅扫描(网点从细变粗,读作「换了一张更清楚的」);再接 3。
+4. **从单张照片拉出 → 露出整面拼贴**:约 1.0s,起步快、长尾(实测 MC 2:30)。
+5. **地图色块生长、路线描线**:2.5–3.5s,一拍二,线头带实心红点。
+6. **真手翻页、抽纸**(Missing Chapter 的标志):代码里可以近似成「纸沿弧线滑入,带阴影变化」。
+
+**注意**:「撕纸转场」在 5 支样片里一次都没出现。它是模板网站的常见做法,不是 Vox 语法。本片第一版用了撕纸,看过调研后换掉了。
+
+## ⑤ 节奏与文字
+
+- **镜头时长**【实测,拼贴段】:
+ - 分两档:慢档(Missing Chapter)中位 3.3s,约 12 切/分,一张卡停 3–7s,靠卡内的描线和高亮撑场。
+ - 快档(迷幻海报 1.8s、Johnny Harris 1.4s)约 25–33 切/分,图几乎不动,靠切换出节奏。
+- **和口播对齐**:
+ - 荧光条、打字、描线的速度锁在念词速度上,不锁音乐拍点。
+ - Johnny Harris 的说法是「Each word must correspond to a movement or action within the animation」,他的脚本分两栏写【一手】。
+ - Joss Fong 约每 20s 换一段音乐【一手】。
+- **文字**:
+ - 人名、地点用衬线小字,白字放在照片下方。
+ - 黑底时间线标题逐字打出,13 字/秒,配一条横贯画面的红线。
+ - 引文用手写体「墨水洇开」式浮现,约 2s,然后红条逐行跟读【实测】。
+ - 【本片】剪报和卡片用 Songti SC,大标签用 PuHui-Heavy,数字用 Anton。
+
+## ⑥ 代码实现要点
+
+> 收进 skill 后(2026-10-04 v0.4):本卡「新写」里的通用函数已统一进 `scripts/engine/lib/`(名字已换成统一后的 MO / CAM / DG / TY / CH / UI / CL / TOON),示范片自己的代码在 `scripts/engine/demos/y2_vox/`。库速查和「怎么为一段口播选语法」见 `references/09-视频动画语法.md`。
+
+- 复用 skill:
+ - `PAINT.cached`、`PAINT.scratch`:所有纸片、照片、剪报都一次画成精灵图
+ - `PAINT.grain`:静态颗粒
+ - `PAINT.noise/fbm`
+ - `KIT.densify/resample`:手画圈
+ - `HUASHU.build/pose/draw`
+ - 引擎转场接口
+- 新写、现已统一进库(`lib/collage.js` / `camera.js` / `diagram.js` / `motion.js`):
+ - `MO.step(t,12)`:一拍二。
+ - `CL.paperTile`:可平铺纸纹,在环面上取样所以无缝,带纤维。
+ - `CL.halftone`:灰度转 45° 网点,批成一条 path 一次 fill。
+ - `CL.tornEdge`:撕边。
+ - `DG.hand / DG.drawPartial / DG.cum`:手画线,按长度描出。
+ - `CAM.motionBlur`:沿速度方向叠帧。
+ - `MO.bezier`:长尾缓动 `(.33,0,.2,1)`。
+- 示范片自己的(`demos/y2_vox/vox.js`;`slideIn / highlight / stringPts` 已进库为 `CL.slideIn / CL.highlight / CL.stringPts`):
+ - `slideIn`:倾斜滑入放平。
+ - `highlight`:荧光毛边带,multiply。
+ - `stringPts`:带下垂的红线。
+ - `deskCam`:桌面相机关键帧,加末段推进。
+- **关键架构**:
+ - 镜 1、镜 2 是同一张桌面世界、同一台相机。转场 A 用 `same`(A、B 本来就是同一幅画),平移完全由相机完成。
+ - 镜 3 是桌上的大黑卡纸。转场 B 用 `cut`,在推满的那一帧切。
+- **性能**:镜 3 每帧 73/89ms(均/峰),花叔贴纸每帧要做 16 次偏移垫边。可以把贴纸边缓存起来,只在 12fps 换姿势时重算。
+
+## ⑦ 代表作品与一手参考
+
+- 样片:
+ - Missing Chapter《The case to rename this famous Christmas plant》https://www.youtube.com/watch?v=lLSUjl4WatY
+ - 《Where the 1960s "psychedelic" look came from》https://www.youtube.com/watch?v=9vuqI2v2IRs
+ - Vox Borders《China is erasing its border with Hong Kong》https://www.youtube.com/watch?v=MQyxG4vTyZ8
+ - Johnny Harris《The Internet Didn't Fail. It Was Taken.》https://www.youtube.com/watch?v=0rKDo3hKbVk
+- 一手:
+ - Vox 美术总监 Joey Sendaydiego 访谈 https://www.storybench.org/how-vox-uses-animation-to-make-complicated-topics-digestible-for-everyone/
+ - Joss Fong 访谈 https://www.theopennotebook.com/2020/01/07/videogram-how-a-vox-video-explains-the-science-behind-the-first-photo-of-a-black-hole/
+ - Johnny Harris《How I Make My Maps》https://www.youtube.com/watch?v=GsojLuJpe_0
+- 二手:PremiumBeat《Replicating Vox motion graphic》https://www.premiumbeat.com/blog/replicating-vox-motion-graphic/
+- 示范片事实:
+ - Le et al., ICML 2012, arXiv:1112.6209 https://arxiv.org/abs/1112.6209
+ - Google 官方博客 2012-06-26 https://blog.google/innovation-and-ai/products/using-large-scale-brain-simulations-for/
+
+## ⑧ 最容易做错的 3 件事
+
+1. **所有东西一起 60fps 丝滑地动**。拼贴的手工感一半来自「相机滑、元素顿」的两层帧率。全部丝滑会像企业宣传片,全部 12fps 又会让相机发晕。
+2. **用模板语法冒充 Vox**:撕纸、每张图都弹入落下、纸纹逐帧抖。实测里这些都没出现,Vox 的照片随切点直接在、纸纹是死的、转场多是硬切和推进。花哨的入场越多,越不像「编辑部作品」。
+3. **用 Vox logo 黄当大面积底色、颜色铺太多**。片子里的黄是 `#DACF08` 一档的荧光笔,只用来划重点。主体是「黑、纸白、一种红」三色,另加一种强调色就够了。
+
+---
+
+## 审片与修订(独立 agent 只看成片,8/10)
+
+审片意见和这一轮的处理:
+- 「镜 3 变纯黑,一张大桌面断了」:改成一张大黑卡纸铺在同一张桌上,四边露出桌面纸纹。仍是 Missing Chapter 的黑底卡片语法,但桌面不断。
+- 「0–0.9s 完全静止」:加开场慢推(1.14→1.165)。
+- 「半调糊图铺满全屏太久」:推镜从 0.7s 缩到 0.6s,拉出从 1.0s 缩到 0.85s。拉出起点 z=3.68,让照片在硬切两侧的屏幕宽度一致,并给大图补上同位置的胶带,硬切读作「换成高清扫描」。
+- 「空白纸条先出现」:纸条改成倾斜滑入,打字提前到 0.4s。
+- 「主角从右边一帧切进来半身」:起点移到屏外 1100px,12fps 的第一步仍在画外。
+- 「荧光笔没划完片子就结束」:打字、红圈、荧光整体前移,荧光在 1.8s 划完,之后停 0.3s。
+- 「它脑中的『猫』字太小」:提到 40px。
+- 「相机全程平滑,一拍二不够」:没改。调研实测 Vox 就是「相机 24fps 平滑、元素 12fps 步进」;把相机也改成步进,会背离实测。
+
+## QA(skill `scripts/qa.py`,修订后终版)
+
+| 镜 | 量的窗口(镜内秒) | 运动面积% 均/峰 | 静止帧对% | 跳变帧 | 每帧耗时 均/峰 ms | 确定性 |
+|---|---|---|---|---|---|---|
+| y2_s1 | 0.35–2.58 | 11.02 / 16.71 | 3.1 | 0 | 17.4 / 20.3 | ✓ 逐像素一致 |
+| y2_s2 | 1.1–3.28 | 16.09 / 76.76 | 3.1 | 16(2.77–3.28s 连续) | 23.4 / 52.2 | ✓ 逐像素一致 |
+| y2_s3 | 0.35–2.08 | 7.77 / 37.41 | 0.0 | 14(0.39–0.83s 连续) | 73.3 / 88.5 | ✓ 逐像素一致 |
+
+转场冒烟(每个转场渲一遍,最慢一帧):y2_s2(same)55.2ms;y2_s3(hardcut)43.8ms
+
+读法:
+- **镜 2 的跳变**在 2.77–3.28s 连续,是「推进墙上小照片」的 0.6s 推镜,推到 9.6 倍。
+- **镜 3 的跳变**在 0.39–0.83s 连续,是硬切后「拉出揭示」的 0.85s 拉镜。
+- 两段都是整屏缩放,属于设计内的相机运动。硬切本身落在镜 3 第 0 帧,不在量的窗口里。
+- **静止帧对 3.1%**:来自元素层的一拍二(12fps 停帧)。第一版开场相机不动,这个数是 16.9%;审片指出「0–0.9s 完全静止」后加了开场慢推,降到 3.1%。
+- **镜 3 每帧 73/89ms** 是三片里最重的:花叔贴纸每帧做 16 次偏移垫白边,还要画黑卡纸纹。要提速,可以只在 12fps 换姿势时重算贴纸、其余帧复用。
+
+复跑:`uv run scripts/qa.py --project scripts/engine --film demos/y2_vox --out <目录>`(上表是实验时的数字;收进 skill 后的复跑见 09 号的回归表)。
diff --git "a/references/\345\212\250\347\224\273\350\257\255\346\263\225/y3_whiteboard.md" "b/references/\345\212\250\347\224\273\350\257\255\346\263\225/y3_whiteboard.md"
new file mode 100644
index 0000000..52722eb
--- /dev/null
+++ "b/references/\345\212\250\347\224\273\350\257\255\346\263\225/y3_whiteboard.md"
@@ -0,0 +1,182 @@
+# Y3 · 白板手绘解说(RSA Animate 型):视频动画语法卡
+
+一句话:讲者说一句,手就在一张大白板上写一句、画一个图;相机跟着论证在板上移动,最后拉远,观众看到整场论证是一张图。
+
+示范片:`scripts/engine/demos/y3_whiteboard/`(渲染 `render.py --film demos/y3_whiteboard`)(8s,3 镜,转场 2 种+收尾拉远),总览:`assets/动画语法/y3_whiteboard_总览.jpg`
+依据:本风格的调研(调研原文与逐帧数据留在实验归档、没收进 skill,用到的数字已摘进本卡)。实测了 RSA Animate《Changing Education Paradigms》和 Minute Physics《Why is it Dark at Night?》,还查了 VideoScribe、Doodly 的官方文档和 Andrew Park、Henry Reich 的一手说法。
+
+**先选一种语法,不能混**:
+- RSA 型:一整块大白板,相机在板上移动,每分钟 5.3 次。
+- Minute Physics 型:一页一张纸,硬切换纸,每分钟 8.1 次,相机不动。
+- 本卡和示范片走 RSA 型。Minute Physics 型的要点写在 ④ 和 ⑧ 里。
+
+---
+
+## ① 适用场景
+
+**用它:**
+- 论证型内容:演讲、观点、因果链、历史脉络。概念之间有关系、能画成一张地图的内容最合适。Andrew Park 的原话是「把信息摆在空间里,让人看见事物之间的关系」【一手】。
+- 一条推理链的短科普,走 Minute Physics 型。
+- 口播语速平稳,关键词清楚。RSA 的写字速度大约等于语速,像「字幕被手写出来」【实测】。
+
+**别用它:**
+- 需要精确数据图表的内容,手绘误差大。
+- 动作和空间关系复杂的内容,白板没有景深。
+- 需要情绪强度的内容,单色线稿表达弱。
+- 想靠它「提升理解」:Türkay 2016 的实验没发现白板动画比其他形式学得更好。它的价值在吸引注意和陪伴感【二手】。
+
+## ② 画面构成
+
+- **配色**(RSA 实测):
+ - 底:纯白 `#FBFBFB`
+ - 线:黑 `#0A0503`
+ - 唯一强调色:橙,文字 `#EB701F`,填色 `#F3742D`;斜线排出的浅橙面约 `#E9A67C`
+ - 橙色约占全部笔迹像素的 22%,只用在关键词和斜线填色上。
+ - Minute Physics 则是偏粉的米白纸 `#E7DBE1`,加彩铅浅黄 `#EDE6A2` 和浅蓝 `#B5CBE8`。
+- **【本片】**:底 `#FBFBFB`,线 `#0A0503`,强调 `#EF7226`。猫身用 22% 透明度的橙色铺一层。
+- **线宽**:RSA 笔画约为画高的 0.6–0.7%,1080p 下约 6–7px;阴影斜线约 0.3%;标题字高约为画高的 5.5%。Minute Physics 的线更粗,约 0.8%【实测】。【本片】线宽 6.5px。
+- **构图**:
+ - RSA 是「先规划好最终全图,再倒着画」【一手】。
+ - 每块画面里有 3–6 个图文组块,画满再移走。
+ - 平滑移动一次只移 0.23 个画宽,所以新旧两块大面积重叠,观众始终看得到上一块的边【实测】。
+ - 收尾露出的全图是一条很长的横向长卷。
+- **字**:RSA 是全大写的手写印刷体(漫画对白体)。【本片】中文用霞鹜文楷(LXGW WenKai),子集化成 woff。
+- **手**:
+ - 真人右手握黑马克笔,从**右下方**入画,前臂斜向右下,遮住 15–25% 的画面。
+ - 不画的时候整只手出画。手在画面里的时间:RSA 49%,Minute Physics 40%【实测】。
+ - 【本片】代码画的手:裸前臂带暗面和汗毛,食指压黑马克笔,缩放 0.82,按 7 rad/s 轻轻晃。
+
+## ③ 运动轨迹
+
+- **写字速度**【实测,9 例】:
+ - 正文中位约 16 字符/秒。
+ - 片头标题慢一半,约 7.5 字符/秒,用来「立题」。
+ - 口播约 13 字符/秒,所以写字速度大致等于语速。
+ - 【本片】正文 16 字/秒;「猫?」按标题 7.5 字/秒写。
+- **画图速度**【实测+归纳】:
+ - 小图标 0.5–1s,人物头像约 2s。
+ - RSA 新增墨迹的面积中位是每秒 0.25% 画面。
+ - 复杂插画不当着镜头画:要么预先画好,相机移过去时露出来;要么整张硬切进来,手只补色。
+- **【本片】**:
+ - 线条笔速 2600 世界像素/秒,约为 RSA 实拍的 2 倍。8 秒演示片必须压缩,真片请放慢。
+ - 笔画时长按长度除以笔速算,每笔至少 0.04s,抬笔间隔 0.02s。
+ - 每笔内部用 sineInOut,起笔、收笔慢。
+ - 花叔用 0.7s「Reveal」揭开:笔尖在他的关节包围盒里走 8 行之字形,`DG.revealMask` 把走过的地方变成 clip,线稿只在 clip 里露出。
+ - 第一版是按部件 `setLineDash` 同时描、笔尖沿关节走,审片判「笔不领线」,所以换了。
+ - 汉字没有笔顺数据,每个字用 3 行之字形揭开,笔尖跟着来回,看起来就是在写。
+- **加速倍率**:Henry Reich 每秒拍 1 张照片,画画时每张停 2 帧,等效约 12 倍速。RSA 推断 5–8 倍【一手+推断】。
+- **「不带手」的弹出**:RSA 有一部分橙色关键词是后期整词弹出的,没有手画(ANAESTHETIC、CREATIVITY)【实测】。【本片】「×1000万张」「是猫!」用 0.3s backOut(2.2) 弹出,手不过去。
+- **笔尖路径**:
+ - 两笔之间间隔 <0.25s 时,笔尖从上一笔终点沿弧线滑到下一笔起点(sineInOut,抬高 30px)。
+ - 间隔更长时,抬手出画:0.35s cubicIn 退到右下屏外。
+ - 下一笔开始前 0.3s,从右下 cubicOut 进来。
+- **持续运动**:白板片的「活」来自手一直在画。RSA 的画线活动量和说话词密度之间几乎不相关(|r|<0.07):说话停顿时,手也不停【实测】。
+
+## ④ 转场(常用 5 种)
+
+1. **板上平滑移动或推拉**(RSA 主力,41 次)。
+ - 1.2–2.4s,**easeInOutSine**:实测速度峰值/均值 1.49,理论 sine 是 1.57。
+ - 一次平移约 0.23 画宽,与上一块重叠约 75%。
+ - 【本片】转场 B:0.9s sineInOut(4.7→5.6s),斜移约 0.5 画宽,同时推到 1.12 倍。移动开始时手正在画一支橙色连线引向新区域,手领着相机走。
+2. **甩镜**:快速摇加运动模糊,约 0.8s,一次移 0.5–1.2 画宽,用来跳到板上很远的区域(RSA 15 次)。
+ - 【本片】转场 A:0.8s cubicInOut 横移约一整屏。只在这 0.8s 里沿速度方向叠 9 次做模糊;平滑移动和拉远都保持清楚。
+3. **拉远揭示全图**(收尾)。
+ - RSA 片尾:灰色铺满 → 0.6s 快速拉远 → 约 9s 横摇扫过长卷 → 再拉远看全图。
+ - VideoScribe 默认就勾着「Zoom at end?」【一手】。
+ - 【本片】6.85→7.5s sineInOut 拉到 0.45 倍,停 0.5s,同时整板在 0.5s 里铺一层很浅的灰 `#EEEEEC`。
+4. **云团或爆炸擦除**:卡通烟团铺满再散开,约 1s(RSA 1 次)。
+5. **硬切**:硬切到预先画好的图(RSA 少量);Minute Physics 型的换纸硬切(主力,每分钟 8.1 次);Minute Physics 讲黑夜时整帧反相。
+
+**注意**:「推进到画框或泡泡里」「翻页」在样片里都没出现。本片第一版做了「推进思考泡泡」,看过调研后换成甩镜加平滑移动。
+
+## ⑤ 节奏与文字
+
+- **每块停留**:RSA 两次相机移动之间中位 6.6s(四分位 4.0–13.8s);Minute Physics 每个镜头中位 7.1s【实测】。示范片 8s 放了 3 块,约为真片密度的 2.5 倍。
+- **和口播对齐(核心)**【实测】:
+ - 开写比对应短语开说晚 0.2–0.8s,中位 +0.5s。
+ - 短语说完后 1s 内写完:边说边写,稍微落后,**不抢先**。
+ - 例外是视觉铺垫(药瓶、箭头)会提前几秒画好,等台词说到。
+ - Minute Physics 是名词一说出来图就落下,中位 +0.3s。
+- **转场卡话题,不卡停顿**:新的一块板对应一个新论点【实测+归纳】。
+- **音乐**:RSA 在讲话下面**没有音乐**。Minute Physics 全程有音乐垫底,约比人声低 9dB【实测】。
+- **工具默认值**:
+ - VideoScribe 画完停留默认 0.5s【一手】,相机移动默认 1s【二手】。
+ - Doodly 每个素材默认画 3s【一手】。
+
+## ⑥ 代码实现要点
+
+> 收进 skill 后(2026-10-04 v0.4):本卡「新写」里的通用函数已统一进 `scripts/engine/lib/`(名字已换成统一后的 MO / CAM / DG / TY / CH / UI / CL / TOON),示范片自己的代码在 `scripts/engine/demos/y3_whiteboard/`。库速查和「怎么为一段口播选语法」见 `references/09-视频动画语法.md`。
+
+- 复用 skill:
+ - `KIT.densify / KIT.resample`:Catmull-Rom 加密后按弧长等距重采样,`DG.hand` 在这之上加低频噪声
+ - `PAINT.noise`、`PAINT.cached`
+ - `HUASHU.build/pose/details`:花叔线稿
+ - 引擎转场接口
+- 新写、现已统一进库(`lib/diagram.js` / `camera.js`):
+ - `DG.cum / DG.pointAt / DG.drawPartial`:折线按长度描出,返回笔尖位置。
+ - `CAM.at`:关键帧相机。
+ - `CAM.motionBlur`:运动模糊。
+ - `DG.revealMask / DG.zigzag`:之字形揭开遮罩(审片后新加)。
+- 示范片自己的(`demos/y3_whiteboard/whiteboard.js`;笔画时间线、笔间滑移、马克笔已进库为 `DG.board` / `B.penAt` / `DG.pen`):
+ - **笔画时间线**:`addLine / addText / addPop / addFill` 按顺序排,时长由长度和速度自动算,交付时打印 `Y3.timeline` 核对每块的结束时间。第一版第二块排到了 7.9s,比相机移动晚了 2.5s,靠这个数才发现。
+ - `drawStroke`:线、字、弹出、填色、角色五种。字和角色都用之字形遮罩揭开,笔尖坐标直接取遮罩的前沿。
+ - `penAt`:笔尖与手的路径,包括笔间滑移、抬手出画、入画。
+ - `drawHand`:手和马克笔。
+ - 擦痕纹理放在屏幕空间,只跟相机平移、不跟缩放,否则推近 5 倍时会变成大灰斑。
+- **关键架构**:三镜画的是同一块白板、同一台相机,转场全是 `same`。「转场」本身就是相机运动,所以白板上的东西在转场里绝不会跳。
+
+## ⑦ 代表作品与一手参考
+
+- 样片:
+ - RSA ANIMATE: Changing Education Paradigms https://www.youtube.com/watch?v=zDZFcDGpL4U
+ - MinutePhysics: Why is it Dark at Night? https://www.youtube.com/watch?v=gxJ4M7tyLRE
+- Andrew Park 访谈(Sketchnote Army 2025)https://sketchnotearmy.com/blog/2025/11/18/andrew-park
+- Cognitive Media「毛手」https://www.hairyhand.co/about
+- VideoScribe 官方文档:
+ - 相机与 Zoom at end https://help.videoscribe.co/knowledge/use-zoom-and-set-the-camera
+ - Draw 入场 https://help.videoscribe.co/knowledge/draw
+ - 入场动画 https://help.videoscribe.co/knowledge/entrance-animations
+- Doodly 默认值 https://support.voomly.com/en/articles/12735753-doodly-how-do-i-customize-video-settings
+- 学习效果研究(转引)https://en.wikipedia.org/wiki/Whiteboard_animation
+
+## ⑧ 最容易做错的 3 件事
+
+1. **一块画满才说话,或者说完才画**。白板片的魔力是「说一句写一句」:写字速度等于语速,比口播晚约 0.5s。先画后说会让观众等,先说后画会让画变成多余的复述。复杂插画不要现场画,预先画好,相机移过去露出来。
+2. **每次都整屏切到下一块空白**。RSA 的平滑移动只移 0.23 画宽,新旧区域大面积重叠,观众一直知道自己在一张大图的哪里。只在跳到远处时才用 0.8s 甩镜加模糊。收尾一定要拉远看全图,这是这个类型的落点。
+3. **颜色多、线太细或太均匀、手一直挂在画面上**。只用黑加一个强调色,线宽约为画高的 0.65%。手只在画的时候入画,画完就从右下退出;强调词可以不带手直接弹出。另外别把 RSA 和 Minute Physics 混用:要么一张大白板加相机移动,要么一页一张纸加硬切。
+
+---
+
+## 审片与修订(独立 agent 只看成片,6/10,三片里最低)
+
+审片意见和这一轮的处理:
+- 「笔尖不领着线走,花叔好几笔同时冒出来;字是遮罩擦出来的」:
+ - 花叔改成 VideoScribe 的 Reveal 画法:完整线稿藏在下面,笔尖走 8 行之字形,笔过之处揭开,笔尖永远在前沿上。
+ - 字改成逐字写:每个字一段时间,笔尖在字框里 3 行之字形来回,遮罩跟着揭开。
+ - 新写 `DG.revealMask`(同向绕行的方条并集,nonzero 下重叠不抵消)和 `DG.zigzag`。
+- 「甩镜后 0.4s 死区」:第二块提前到 3.12s 开画,手在甩镜收尾时就入画。
+- 「截图框线穿过猫头」:每个框先填一层白板色再描边,前框盖住后框的线。
+- 「『自己找规律』被上缘切一半」:第三块整体下移 60px。
+- 「拉远后灰底和擦痕像脏墙」:灰底减淡到 `#EEEEEC`,擦痕透明度减半。
+- 「全景只停 0.15s、三组画没连起来」:
+ - 第一块结尾加一支橙箭头指向右边,甩镜有了方向。
+ - 第二块结尾画一支橙色连线引向第三块,手领着相机走。
+ - 拉远提前到 6.85–7.5s,全景停 0.5s。
+- 「手是蓝袖子卡通手」:改成裸前臂,带暗面和汗毛,更接近 RSA 的真人手。仍是代码画的。
+
+## QA(skill `scripts/qa.py`,修订后终版)
+
+| 镜 | 量的窗口(镜内秒) | 运动面积% 均/峰 | 静止帧对% | 跳变帧 | 每帧耗时 均/峰 ms | 确定性 |
+|---|---|---|---|---|---|---|
+| y3_s1 | 0.35–2.48 | 3.1 / 5.31 | 0.0 | 0 | 6.5 / 6.9 | ✓ 逐像素一致 |
+| y3_s2 | 0.8–2.23 | 4.65 / 9.57 | 0.0 | 0 | 6.5 / 7.3 | ✓ 逐像素一致 |
+| y3_s3 | 0.85–3.23 | 4.45 / 10.94 | 0.0 | 0 | 8.3 / 9.0 | ✓ 逐像素一致 |
+
+转场冒烟(每个转场渲一遍,最慢一帧):y3_s2(same)46.9ms;y3_s3(same)14ms
+
+读法:
+- 白板片三镜都没有跳变:所有「转场」都是同一块板上的相机运动,板上的东西不会跳。
+- 运动面积 3–4.7% 主要来自手和正在画的线,相机移动时会更高。
+- 每帧不到 10ms,因为全是矢量线条,没有像素级处理。
+
+复跑:`uv run scripts/qa.py --project scripts/engine --film demos/y3_whiteboard --out <目录>`(上表是实验时的数字;收进 skill 后的复跑见 09 号的回归表)。
diff --git "a/references/\345\212\250\347\224\273\350\257\255\346\263\225/y4_storytime.md" "b/references/\345\212\250\347\224\273\350\257\255\346\263\225/y4_storytime.md"
new file mode 100644
index 0000000..04f9550
--- /dev/null
+++ "b/references/\345\212\250\347\224\273\350\257\255\346\263\225/y4_storytime.md"
@@ -0,0 +1,166 @@
+# y4 · 故事型简笔角色动画(YouTube storytime animation)
+
+> 一句话语法:**口播是主角,画面是给口播配的「表情包」——角色在几个姿势之间快切(0.1 秒)然后定住,笑点靠切到反应大特写、并在那一下里闭嘴。**
+
+代表:TheOdd1sOut(James Rallison)、Jaiden Animations、Domics。工具:据 Jaiden 的 FAQ 和二手资料,三人早期都用 Flash / Adobe Animate(这条没拿到一手原文,只作背景)。
+
+---
+
+## ① 适用场景
+
+**用它:**
+- 第一人称讲经历、讲翻车、讲「我第一次……」:口播有起承转合、有一个能停顿的笑点。
+- 观众要的是「这个人」:创作者的卡通化身每期出现,认的是人设不是画工(Pappis 的类型研究:化身之间「往往只靠发型就能区分」)。
+- 预算有限、要稳定周更:一个角色、五六个姿势、三张嘴就能撑满一期。
+
+**别用:**
+- 信息密度高的教程、数据讲解 → 用 y5 动态文字或信息图。观众会盯着角色等笑点,记不住数字。
+- 没有「我」的内容(行业新闻、产品对比)→ 角色没有立场可表演,就只剩一个会张嘴的贴图。
+- 口播本身不好笑、没停顿 → 这个风格把口播放大,不会替口播救场。
+
+## ② 画面构成
+
+**构图**
+- 中景(腰以上,头占画高 25–35%)是默认机位,角色居中偏一侧,另一侧留给「他在说的东西」(电脑、对方、物件)。
+- 背景只交代「在哪」:一面墙、一张桌、一扇窗,3–5 个大色块。白底或纯色底也完全成立(Pappis:「白底或者一个粗糙的场景草图」)。
+- 反应镜头把环境拿掉:脸占满画面(头半径 ≈ 画高 1/3),背景换纯色+暗角。
+- 笑点镜头经常反着来:切到**大全景**,人变得很小(「渺小无助」本身就是笑点)。
+
+**配色(示范片实际色值)**
+
+| 部位 | 色值 | 说明 |
+|---|---|---|
+| 皮肤 | `#FFE2CC` | 浅、近白——TheOdd1sOut 的「棉花糖人」是纯白,Jaiden 偏暖白 |
+| 帽子 / 白 T | `#FFFFFF`,帽带 `#E4E4E8` | 白色物件靠黑轮廓立住 |
+| 短裤 | `#CDBB97` | |
+| 角色线 | `#1B1B1F` | 全片最黑 |
+| 墙 / 桌 / 地 | `#DCE9EC` / `#E2C29B` / `#E8DCC8` | 低饱和、高明度:背景永远比角色「轻」 |
+| 背景线 | `#5B6470` 3px | 比角色线浅、细一半以上 |
+| 反应镜头虚空 | `#3D405B`+径向暗角 | 冷、暗,把注意力全压到脸上 |
+| 嘴 / 舌 / 腮红 | `#6E2430` / `#F07B7B` / `rgba(255,140,120,.35)` | 嘴里唯一的饱和色,口型一张一合很显眼 |
+
+**线宽**:角色线 = 头半径 × 0.05(最低 4px)——中景 R=165 → 8px,大特写 R=360 → 12px,全景 R=95 → 6px。线随镜头缩放变粗变细(Flash 默认行为),背景线固定 3px。**角色线 ≥ 背景线 × 2** 是这个风格「人永远跳出来」的根源。
+
+**形状语言**:全圆、全钝。头是略扁的圆(宽 1.0R × 高 0.93R),身体是豆子(宽 1.0R × 高 1.2R),全身 3.2R——**头占身高约 58%**。手臂是一根两端圆头的管子,没有肘、没有手指,手是一个圆。没有直角,除了道具。
+
+**角色画法(花叔 storytime 版)**
+- 保留两个标志:**纯白渔夫帽**(帽冠圆角梯形+往下斜的宽帽檐+浅灰帽带)、**圆框黑眼镜**(镜框线是轮廓线的 1.5 倍——眼镜就是这张脸的「眼睛」)。其余从原形象里只留白 T、卡其短裤、黑手表(近侧手腕一小块黑)。
+- 眼睛是镜片里的黑点(0.075R),带一个白高光;「死鱼眼」把黑点缩到 0.035R、去高光。
+- 表情主要靠**眉毛**(帽檐和镜框之间那条短粗线):抬高=惊、内端抬高=委屈、放平=无语。嘴只有:微笑弧、一字、波浪(担心)、半张、全张五种。
+- 鬓角露一点黑发,告诉观众帽子底下是头发不是光头。
+
+## ③ 运动轨迹
+
+**原片实测(本次抓取、480p 转载版、去掉片头片尾各 10 秒;方法:160×90 灰度逐帧差)**
+
+| | TheOdd1sOut「老妈的惩罚」(30fps,475s) | Jaiden Animations「Being Not Straight」(24fps,902s) |
+|---|---|---|
+| 平均镜头长 ASL | **2.43s**(中位 1.87s,四分位 1.03–3.07s) | **5.73s**(中位 3.21s,四分位 1.67–6.67s) |
+| 完全静止的相邻帧 | **70.7%** | 51.2% |
+| 静止段时长 | 中位 **0.40s**,p75 0.70s | 中位 0.08s(=一拍二的停顿) |
+| 运动段时长 | 中位 **100ms**(3 帧) | 中位 42ms(1 帧) |
+
+读法:TheOdd1sOut 是**快切(0.1s)→ 定住(0.4–0.7s)→ 再快切**,七成时间画面完全不动;Jaiden 是**一拍二持续在动**(12 张/秒),镜头更长。Toon Boom 访谈里 Netflix《Oddballs》的动画监督 Hallis Blaney 说得最准:「TheOdd1sOut 是 pose-to-pose,动画极少……基本是在图片之间切换」,改成剧集时最难的是保住那种 snappiness,避免「太软、太慢」。示范片取两者中间:姿势快切照 TheOdd1sOut,呼吸和口型照 Jaiden。
+
+**示范片参数**
+
+| 运动 | 怎么做 | 数字 |
+|---|---|---|
+| 角色帧率 | 角色所有运动按 24fps 步进(`MO.step(t,24)`),镜头按 60fps 平滑 | Flash 默认 24 |
+| 姿势切换 | 手臂目标点 `expoOut` 插值 | **0.10s**(24fps 下 2–3 帧) |
+| 换姿势回弹 | 切换瞬间身体竖向压 7%,Ebberts 弹簧回弹(体积守恒,横向反向) | `settle(dt, -0.07, freq 3.5, decay 9)`,≈0.35s 停稳 |
+| 口型 | 读口播 RMS 包络,**每 1/12 秒才允许换一次形**(一拍二);三张嘴 | 包络 <0.06 闭、<0.22 半张、其余全张 |
+| 说话点头 | 嘴张开时头下沉 | 0.015R × 口型级数 |
+| 呼吸 | 身体竖向缩放 | ±1.2%,周期 1.6s |
+| 眨眼 | 固定时刻表,间隔 2.4–3.6s | 闭眼 2 帧@24fps(83ms);「无语」慢眨 3 帧 |
+| 眼神 | 指向某物时黑点往那边移 | 0.09R |
+| 镜头 | 中景慢推、反应镜头慢推、全景慢拉、近景慢推 | 中景 +3.5%/2.0s;特写 +6%/1.2s;全景 0.53→0.50(quintOut);近景 1.90→1.98 |
+| 开场 | 镜头 1.04→1.01 落定(0.5s expoOut),代替「第一帧静止」 | |
+| 汗滴 | 太阳穴处沿脸侧滑落 | 0.9s,expoOut 混线性 |
+| 镜片反光 | 白色斜带扫过两片镜片 | 0.3s |
+| 「?」 | 头顶弹出,backOut 过冲 30%,之后 ±3° 晃 | 0.26s |
+
+入场/出场:storytime 几乎没有「入场动画」——角色在镜头切进来的第一帧就已经在位、已经在说话。道具和符号(?!、汗滴、数字)才用弹入(`backOut`,过冲 15–30%)。
+
+## ④ 转场(常用 5 种)
+
+1. **硬切(cut)**——占绝大多数。一句口播一个镜头,口播换句就切。示范片 S3→S4(特写 → 同一房间的大全景)就是硬切,靠景别反差制造笑点。
+2. **砸镜 / smash cut 到反应特写**——新画面第一帧就出现,从 1.22 倍以弹簧(freq 3, decay 11)缩回 1,前 2 帧压一层 55% 白闪,配一个低音「噔」。用在「说完一句离谱的话 → 看他的脸」。`TRANSITIONS.smash`。
+3. **甩镜 / whip pan**——镜头往「他在看的东西」方向甩,`expoInOut` 0.26s,中段 16 张偏移叠加做横向运动模糊、配 whoosh。用在「我打开电脑 →(屏幕)」这种视线转移。`TRANSITIONS.whip`。
+4. **推近 / 跳近(jump-in)**——同一机位直接切到约 2 倍的更近景,不换背景。用在「他重复了一遍」「他意识到了」「包袱那一句」。示范片 S4→S5:全景里说「这些……」,在「贴哪儿」前的换气处硬切到 1.9 倍近景,笑点那张脸才看得清。前提是全景和近景是**同一张世界画布、只换镜头**(`world.js`),否则一跳就穿帮。
+5. **过肩 / 主观镜头**——切到他看见的东西(屏幕、手机、对方),前景放一块他的后脑勺。示范片 S2:花叔的背影——白帽+帽带、耳朵、挂在耳朵上的眼镜腿、短黑发、后颈、白 T 领口,屏幕那侧一圈冷色轮廓光(第一版画成纯黑剪影,审片读成「另一个影子人」);前景不跟镜头推,只随呼吸起伏,和屏幕之间有视差,画面立刻「有空间」。
+
+## ⑤ 节奏与文字
+
+- **镜头跟口播句子走,不跟音乐拍子走**:一句 ≈ 一镜。示范片 5 镜平均 1.75s(2.0 / 2.4 / 1.2 / 1.65 / 1.5),落在 TheOdd1sOut 实测的四分位 1.03–3.07s 之内。
+- **转场放在两句之间的换气里,字幕和切点同一帧换**:第一版甩镜切在「它一口气」的前两个字上,审片指出「切点落在句子中间」;改成 L1 结束(1.87s)→ 2.0s 甩 → 2.26s 落定 → 2.30s 才开口。
+- **反应镜头放在两句之间的沉默里**:示范片 S3 整整 1.3s 没有一句话,只有蟋蟀叫——这一下停顿就是笑点。剪辑上:说完离谱的那句(「三千行」)后**不要马上接下一句**,留 0.8–1.5s 给脸。
+- **包袱后定住 ≥0.9s**:「?」7.80s 弹出,片子 8.75s 才结束,音效尾巴自然收完(第一版只留 0.4s,审片:「笑的那一拍被剪掉了」)。
+- **字**:YouTube 原生 storytime 不烧字幕(靠 CC),只在画面里写「需要被看见」的字——屏幕上的字、关键数字(示范片「3000 行」用普惠体 Black 230px、`#FFCB6B`、过冲 23% 砸出来)。中文平台需要烧录字幕:白字 50px、黑描边 10px、整句切入切出、不做动画(字幕动起来会和角色抢视线)。
+- 画内数字和口播**同一个字**对齐:「三千」那个音节(3.70s)= 3000 砸出 = 低频 thump = 屏幕震(9Hz、0.3s 衰减完)。
+
+## ⑥ 代码实现要点
+
+> 收进 skill 后(2026-10-04 v0.4):本卡「新写」里的通用函数已统一进 `scripts/engine/lib/`(名字已换成统一后的 MO / CAM / DG / TY / CH / UI / CL / TOON),示范片自己的代码在 `scripts/engine/demos/y4_storytime/`。库速查和「怎么为一段口播选语法」见 `references/09-视频动画语法.md`。
+
+- **复用 skill**:引擎(段落表、转场时新旧两段离屏合成、`GLOBAL_OVERLAY`)、`render.py`、`PAINT.cached`(房间背景整张缓存)、`U.rng` 种子随机(代码瀑布的色块布局)。
+- **engine 两处改动(已并进 skill 引擎)**:段落表任何段都可以直接写 `dur`(秒),不必凑八分音符——storytime 按口播切,不按节拍;转场可以写 `punch: 0`(或片级 `window.PUNCH = 0`)关掉引擎默认的拍点冲击(storytime 没有拍点)。
+- **新写、现已统一进库**(`lib/toon.js` / `typo.js` / `camera.js` / `motion.js`,转场进 `transitions.js`):
+ - `TOON.bean(c, {x, y, s, pose, expr, mouth, blink, look, squash, bob, tilt, lw})`:正面豆子花叔,全部 Path2D 程序化,返回双手和头的坐标(给道具、符号定位)。
+ - `TOON.POSES`:rest / talk / point / type / shrug / stiff,每个姿势只是两只手相对肩的目标点(单位:头半径)。
+ - `TOON.mouth(t)`:读 `window.VO_ENV`(音频脚本导出的 60fps RMS 包络),一拍二量化成 0/1/2。
+ - `MO.springHz / settle / backOut / expoOut / step`,`CAM.with`、`CAM.drift`,`TOON.sweat`、`TOON.mark`。
+ - 转场 `whip`、`smash`(y5 用的冲进色块转场收进库后改名 `fillZoom`,另有 `bands / push`)。
+- **本片 `y4_storytime/story.js`**:`STORY.poseAt(keys, t)`(姿势时间线+换姿势回弹),`blinkAt`、`alive`(点头+呼吸),字幕 overlay。
+- **音频(实验归档里的 `build_y4.py`,没收进 skill)**:摆口播、合成音效(whoosh、键盘、bloop、thump、「噔」、蟋蟀、pip、boing),同时导出 `vo_env.js`。口播是 macOS `say` 的 Eddy 占位——**正式片换成真人口播后重新导出包络,口型自动跟上**。
+- **同一个房间三种景别**:`y4_storytime/world.js` 把房间画成一张世界画布(x −1000..2900、y −700..1700,静态部分整张缓存),S1(zoom 1.01–1.045)、S4(0.53→0.50)、S5(1.90→1.98)只换 `CAM.with`。全景才看得到的书架、绿植、吊灯本来就在世界里。世界要比最远的镜头大一圈,否则镜头漂移会露黑边(第一版三处黑边全是这个原因)。
+- 关键参数:角色 24fps、口型 12 次/秒、换姿势 0.1s+7% 回弹、角色线 0.05R。
+
+## ⑦ 代表作品与一手参考
+
+- TheOdd1sOut 频道:https://www.youtube.com/@theodd1sout ;本次实测的转载「老妈的惩罚」:https://www.bilibili.com/video/BV14s411M7x4
+- Jaiden Animations 频道:https://www.youtube.com/@JaidenAnimations ;本次实测「Being Not Straight」转载:https://www.bilibili.com/video/BV1xu411r734
+- Domics 频道:https://www.youtube.com/@Domics
+- Toon Boom × Atomic Cartoons,《Oddballs》从 YouTube 到剧集(「pose-to-pose,动画极少」「他在 YouTube 上从没做过口型」「太软、太慢」):https://www.toonboom.com/atomic-cartoons-on-bringing-oddballs-from-youtube-to-series
+- Konstantinos Pappis, *The Odd Ones Out: The Rise of YouTube Storytime Animation*(Animation Studies,类型史与视觉语法:圆脸化身、白底、无逐帧、更像动态分镜):https://journal.animationstudies.org/article/id/135/
+- TheOdd1sOut 维基(「棉花糖人」的说法):https://en.wikipedia.org/wiki/TheOdd1sOut
+- Dan Ebberts 惯性回弹表达式(freq 3、decay 5 的出处):http://www.motionscript.com/articles/bounce-and-overshoot.html
+- 制作者经验帖「换姿势时加一点 bounce」:https://forum.wickeditor.com/t/whoever-wants-to-make-a-storytime-animation/5940
+
+## ⑧ 最容易做错的 3 件事
+
+1. **把它当「全动画」做,什么都在动。** 这个风格的生命在「快切+定住」:TheOdd1sOut 七成帧完全静止。所有东西都在慢慢飘,反而软、反而没节奏(Oddballs 团队最怕的「too soft, too slow」)。姿势切换要快到 0.1s,然后**真的停住**;持续微动只给呼吸、眨眼、背景小物,幅度 ≤ 1–2%。
+2. **背景画得和角色一样精彩。** 背景饱和度、对比、线宽都要比角色低一档(本片背景线 3px 灰 vs 角色 8px 黑)。背景一花,观众的眼睛就离开脸,口播的笑点就丢了。
+3. **反应镜头不给沉默。** 说完离谱那句马上接下一句,等于把笑点讲掉了。反应镜头要放在口播的空白里,至少 0.8s,镜头只做极慢推近和一两个小细节(汗滴、慢眨、眉毛一垮)。
+
+---
+
+## 示范片
+
+- 成片:`scripts/engine/demos/y4_storytime/`(渲染 `render.py --film demos/y4_storytime`)(8.75s,60fps,含临时口播+音效);每镜一帧总览:`assets/动画语法/y4_storytime_总览.jpg`
+- 工程:`scripts/engine/demos/y4_storytime/`(`eras.js` 段落表、`story.js`、`world.js` 世界画布、`s1_desk.js / s2_screen.js / s3_react.js / s4_wide.js / s5_close.js`),通用部分在 `scripts/engine/lib/`
+- 镜头表:S1 中景对镜头讲(0–2.0s)→ 甩镜 → S2 过肩看屏幕,代码瀑布+「3000行」(2.0–4.4s)→ 砸镜 → S3 反应大特写,沉默(4.4–5.6s)→ 硬切 → S4 同一房间大全景「我问它:这些……」,瞟电脑、指电脑(5.6–7.25s)→ 跳近 → S5 近景摊手「贴哪儿?」+「?」,定住(7.25–8.75s)
+
+## 审片返修(独立 agent 只看成片)
+
+第一版审片「必须改」5 条,全部处理:
+1. 三处黑边穿帮(S1 左/上、砸镜回弹缩到 1 以下、S4 镜头下漂)→ 世界画布铺大+`smash` 缩放夹在 ≥1。返修后逐帧扫描四条边:0 帧露黑。
+2. 包袱没留气口 → 拆出 S5 跳近镜头,「?」后定住 0.95s。
+3. S1 和 S4 不是同一个房间 → 改成同一张世界画布换镜头。
+4. 过肩剪影像另一个人 → 画出背面识别点+轮廓光。
+5. 甩镜切在句中、第二句字幕晚 → 甩镜挪进换气,字幕跟切点同帧。
+「可以更好」处理了 2 条:S3 第二声蟋蟀后 0.15s 眉毛一垮(原来音效在 5.23s、表情在 5.38s 对不上);S4 两段停顿里加「瞟电脑→回看镜头」和说「这些」时指电脑。字幕去掉中英文之间的空格(「让AI帮我」「3000行」)。
+没改的:线条是均匀等粗的矢量线、没有手绘抖线——这是 TheOdd1sOut/Jaiden 的 Flash 矢量线本来的样子,保留。
+
+## qa.py 数字(返修后,`uv run scripts/qa.py --project scripts/engine --film demos/y4_storytime`)
+
+| 段 | 运动% | 静止帧对% | 跳变 | 均/峰 ms | 确定性 |
+|---|---|---|---|---|---|
+| s1_desk | 1.47 | 8.6 | 0 | 9.9/10.4 | ✓ |
+| s2_screen | 6.0 | 0.0 | 0 | 1.7/3.8 | ✓ |
+| s3_react | 1.73 | 0.0 | 0 | 5.6/6.1 | ✓ |
+| s4_wide | 0.77 | 16.2 | 0 | 9.6/9.9 | ✓ |
+| s5_close | 3.27 | 3.1 | 0 | 10.9/11.4 | ✓ |
+
+转场冒烟(整帧峰值):whip 47.9ms、smash 10.1ms、cut 15.7 / 20.5ms。第一版 s1、s2、s4 各报 1 个跳变(开场落定、3000 砸出、全景开头的快速拉远),返修后为 0。
+读这张表要注意:qa 的经验阈值「静止帧对 >40% 读作卡」**不适用于 storytime**——TheOdd1sOut 原片 70.7% 的相邻帧完全静止,那是风格不是卡顿。本片静止帧对 0–16%,比原片「活」得多,是有意取 Jaiden 式的持续呼吸;想更像 TheOdd1sOut,就把呼吸、点头、背景小循环关掉,只留口型和姿势快切(静止帧对会大幅上升,本次没实测)。
diff --git "a/references/\345\212\250\347\224\273\350\257\255\346\263\225/y5_kinetic_type.md" "b/references/\345\212\250\347\224\273\350\257\255\346\263\225/y5_kinetic_type.md"
new file mode 100644
index 0000000..f64d628
--- /dev/null
+++ "b/references/\345\212\250\347\224\273\350\257\255\346\263\225/y5_kinetic_type.md"
@@ -0,0 +1,150 @@
+# y5 · 动态文字排版 / 信息图动效(kinetic typography)
+
+> 一句话语法:**字就是演员——每个关键词踩一个重音砸进来,主词大到一眼读完,其余的字从「槽」里升起给耳朵对位;画面里永远只有一个焦点,镜头和底纹一直在动,字落定后不动。**
+
+血统:Saul Bass《North by Northwest》(1959)片头被普遍认作第一次在长片里大规模用动态文字;2008 年后 YouTube 上的歌词/台词 kinetic type(After Effects 一代)把它变成解说视频、清单、语录、数据开场的标准语法。
+
+---
+
+## ① 适用场景
+
+**用它:**
+- 解说/清单/「X 个阶段」「3 个理由」类的开场与章节卡:信息是**结构**(几个、哪一个、从什么到什么),不是画面。
+- 语录、金句、一句话结论:让观众「看着读」比「听着记」更牢。
+- 数字讲解:一个数字一个镜头,数字本身做主角。
+- 口播里有明确的重音词(「不是写代码,是**说需求**」)。
+
+**别用:**
+- 讲故事、讲情绪起伏 → 没有人脸,观众很难共情(用 y4 角色)。
+- 长段解释性口播配满屏字 → 观众只会读不会听,读也跟不上。整片超过 30–60 秒全是动态字会累,用它做开场、章节卡、结论卡就好。
+- 字很多的列表(>5 条)→ 改成静态信息图慢慢讲。
+
+## ② 画面构成
+
+**构图**:一屏一个主词。主词左对齐压在画面左侧 1/3–1/2(或镜像到右侧),辅句紧贴主词下方,另一侧放一个「证据物」(代码卡、聊天气泡、清单)。上角放小标签(「阶段 01」)和进度轨。四周至少留 130px 边距。
+
+**字号阶梯(示范片)**:主词 340px(普惠体 115 Black):辅句 96px(105 Heavy):标签 40px(85 Bold,字距 6px)≈ **3.4 : 1 : 0.4**。主词要在 0.3 秒里被读完,所以主词只给 2 个字。
+
+**配色**:每个章节一个整屏底色,换章节=换底色(色彩本身就是章节号)。
+
+| 镜头 | 底色 | 主词 | 强调 |
+|---|---|---|---|
+| 标题 | 黄 `#FFD23F` | 墨 `#111111` | 珊瑚圆 `#FF5A36` 里的白「3」 |
+| 01 补全 | 珊瑚 `#FF5A36` | 白 | 黄荧光笔 `#FFD23F` |
+| 02 对话 | 藏青 `#14213D` | 黄 | 黄荧光笔、蓝气泡 `#3A86FF` |
+| 03 代理 | 米白 `#F4EFE6` | 墨 | 珊瑚下划线、绿勾 `#2BB673` |
+
+全片 4 个底色 + 墨 + 白,强调色永远只有一个。
+
+**形状语言**:字是最大的形;辅助形状只用圆角矩形(卡片 r=26、气泡 r=30、键帽 r=22)、正圆(数字底)、斜切色块(荧光笔,斜率 0.18)。背景是 64px 间距的点阵(不透明度 6–10%)。不用描边字、不用投影字(唯一的投影是卡片下 8–18% 的偏移阴影)。
+
+## ③ 运动轨迹
+
+**入场(按「重要性」选方式)**
+
+| 元素 | 方式 | 曲线与时长 |
+|---|---|---|
+| 主词 | **砸**:从 1.7 倍缩到 1,前 0.06s 不透明度 0→1 | 欠阻尼弹簧 `1−e^(−10t)·cos(2π·2.2t)`,过冲约 8%,≈0.35s 停稳 |
+| 标题首词 | 砸+旋转回正 −8°→0 | 同上 |
+| 辅句、标签 | **槽里升起**:字在基线下的遮罩里从 +1.2 倍字高推到 0 | `expoOut`,0.30–0.35s |
+| 数字/图标/气泡/键帽 | **弹入**:0→1 缩放 | `backOut`,s=2.6–3.0(过冲 17–20%),0.30–0.42s |
+| 卡片 | **滑入**:从 +700px 或下方 +260px,带 3.4° 旋转回正 | `expoOut` 0.40s |
+| 打字 | 按字符截断 | 0.5s 打完 13 个字符(26 字/秒),光标 2Hz 闪 |
+| 代码补全 | 灰字**0 帧**闪现(补全本来就是瞬间出现的)→ 按 Tab 变实色 | 键帽按下压 14%,e^(−18t) 回弹 |
+| 荧光笔 / 下划线 | 从左往右刷出 | `expoOut` 0.30s,在字出现后 1–3 个八分音符再刷 |
+| 关键词放大 | 到强调拍放大到 1.35 倍并钉住,荧光笔跟着放大 | 弹簧 freq 2.5 / decay 9,和配合的动作(按 Tab、打勾)同一拍 |
+| 巨型阶段数字 | 900px、透明度 5–13%、压在画右下、从 1.35 倍落到 1 后斜向慢漂 14/10 px/s | 弹簧 freq 2 / decay 8 |
+| 打勾 | 勾的笔画按弧长画出,框同时 1→1.25→1 | 0.22s;删除线晚 0.08s 再划 |
+
+**出场**:比入场快、用加速曲线(`expoIn`),时长 0.18s,元素之间错开 0.03s,同时缩到 0.6、下落 60px、变透明。**退场比入场快**——观众的注意力在退场开始前就已经走了。示范片标题段最后一拍:除「3」以外全部退场,只剩下一个要冲进去的形。
+
+**错开(stagger)**:同一行的词错开一个八分音符(120 BPM 下 0.25s);同一组小元素(三个勾)也是一个八分一个。
+
+**持续运动(字落定后不动,动的是别的)**
+- 镜头微漂:两路正弦,振幅 5px,周期约 7s / 2.7s;极慢旋转 ±0.5°。
+- 拍点微冲:每个四分拍整屏放大 1.2%,`e^(−25t)` 衰减(≈0.12s)——画面跟着鼓「呼吸」。
+- 背景点阵斜向平移 36px/s。
+- 结尾一拍:镜头拉远 6%(`expoOut` 0.5s),所有东西缩小一点=「收束」。
+
+**原片对照(本次抓取的两支 YouTube 歌词 kinetic type 转载,30fps)**:相邻帧完全静止只占 10.3%(DISCORD)/ 21.2%(Charlie Puth),七八成时间画面在动——和 storytime 的 71% 静止正好相反;大的视觉事件(整屏变化 >1.5% 的峰)平均 0.66s / 0.83s 一个,接近**一拍一个**(两支曲速约 105 / 99 BPM,一拍 0.57 / 0.60s)。示范片的大事件密度是一个八分一个(0.25s),比歌词片密一倍——解说开场可以这么密,长片要放到一拍一个。
+
+## ④ 转场(示范片 3 种+常用 2 种)
+
+1. **穿越放大(zoom through)**:镜头冲进上一屏的某个形(「3」的珊瑚圆),形的颜色=下一屏的底色,冲满屏后下一屏从 1.25 倍落回 1。前 55% 时间 `expoIn` 放大到 30 倍,后 45% `expoOut` 落定。`TRANSITIONS.fillZoom`(实验时叫 zoomThrough,收进库后改名,免得和 3b1b 的镜头穿越撞名),参数 `cx, cy, k, maxZoom, fill`。
+2. **色带擦除(bands)**:三条斜切色带(黄→白→藏青)接力从左扫到右,错开 12%,最后一条是新画面的底色,色带后面露出新画面。0.5s `expoInOut`。`TRANSITIONS.bands`。
+3. **推(push)**:新旧一起平移,像在一张长画布上滑到下一块。0.35s `expoInOut`。`TRANSITIONS.push`。
+4. **遮罩擦出(mask wipe)**:一个形(圆、矩形条、字本身)当遮罩从小长大露出新画面。可用 `skill` 原有的 `iris`。
+5. **字变形 / 字当转场**:上一屏的某个字放大成整屏的色块,或者一个字甩出画面带走旧画面。
+
+**对位技巧(本次最值钱的一条)**:引擎里转场从新段的 `t0` 开始,所以要让「新画面露出来」的那一帧正好落在小节线,段的起点 = **小节线 − 转场的揭开点 × 转场时长**。示范片:fillZoom 揭开点 p=0.55、时长 0.45 → 起点 1.75(揭开在 2.00);bands 揭开点 ≈0.6、0.5s → 起点 3.70;push 用 expoInOut,肉眼的「到位」是位移 90% 那一刻(p≈0.58)而不是 p=1 → 起点 5.80(第一版按 p=1 算起点 5.65,审片量到「推完比重拍早 8 帧」)。所有镜头内的落点也写成拍号 `KT.b(n)`,不写秒。
+
+## ⑤ 节奏与文字
+
+- **120 BPM,4 小节+1 拍收尾(8.5s),每小节一个镜头**(标题 / 阶段一 / 阶段二 / 阶段三),每个镜头里:第 1 拍主词砸(+背景巨型阶段数字)、第 1.5 拍证据物、第 2 拍辅句、第 3 拍证据物动作、第 3.5 拍关键词放大+高亮、第 4 拍留白或退场;最后第 16 拍(8.0s)收尾重拍,再静住 0.5s。四个镜头同一套拍位,只换左右和内容——观众第二个镜头起就「知道下一下在哪」,这正是节奏感的来源。
+- **主词落在强拍(每小节第一拍)**,配低频冲击;小元素落在八分音符上,配 pop;转场前 0.3s 一段上扬噪声把耳朵带到下一小节。
+- 每个画面落点都有一个声音,每个重音都有一个画面——示范片音效表在实验归档的 `build_y5.py`(没收进 skill),和 `scenes/*.js` 的拍号一一对应。
+- **停留时间够读**:英文视频文字指南给的下限是 13 字符/秒(SSW);中文没找到一手标准,按字幕行业的经验上限 7–9 字/秒算(未核实,当经验值用)。主词 2 字至少停 0.5s,辅句 7–8 字至少停 1.0s。
+- 和口播对位时:主词=口播里的重音词,**画面宁早勿晚、最多早 1 帧**——人对「声音比画面早」比「声音比画面晚」敏感得多(广播声画同步容差 EBU R37 是声音领先 ≤40ms、落后 ≤60ms)。
+
+## ⑥ 代码实现要点
+
+> 收进 skill 后(2026-10-04 v0.4):本卡「新写」里的通用函数已统一进 `scripts/engine/lib/`(名字已换成统一后的 MO / CAM / DG / TY / CH / UI / CL / TOON),示范片自己的代码在 `scripts/engine/demos/y5_kinetic_type/`。库速查和「怎么为一段口播选语法」见 `references/09-视频动画语法.md`。
+
+- **复用 skill**:引擎(段落表、转场新旧两层、`renderFrame`)、`render.py`、`U.clamp / lerp / rng`、`PAINT` 不需要(这风格不用纹理)。
+- **engine 改动(已并进 skill 引擎)**:`window.BPM` 可配(默认 128,本片 120);任何段可写 `dur` 秒;转场 `punch:0` 可关(本片用自己的拍点微冲,冲在拍上,不冲在转场起点上)。
+- **新写、现已统一进库**(`lib/motion.js` / `typo.js` / `camera.js`,转场进 `transitions.js`):
+ - 缓动:`expoOut / expoIn / expoInOut / quintOut / backOut(p, s) / spring(t, freq, decay) / settle(t, amp, freq, decay)`。
+ - 字:`TY.text`(缩放旋转以任意点为轴、描边、字距)、`TY.width`、`TY.rise`(遮罩升起)、`TY.pop`(弹入)、`TY.typed`(打字)、`TY.marker`(荧光笔斜切块)、`TY.underline`。
+ - 镜头:`CAM.with(c, {x, y, z, r}, fn)`、`CAM.drift`。
+ - 转场:`fillZoom`、`bands`、`push`。
+- **本片 `y5_kinetic_type/kinetic.js`**:`KT.b(n)` 拍号、`KT.SZ` 字号阶梯、`KT.bump` 拍点微冲、`KT.slam` 主词砸入、`KT.dots` 点阵、进度轨(画在 `GLOBAL_OVERLAY` 固定层,值只由全片时间决定——skill 02 号「连续叙事锚」的用法;第一版画在各段里,推页时跟着页面跳)、`KT.key / keyMarker`(关键词先升起、到强调拍放大并钉住)、`KT.bigNum`(背景巨型阶段数字)、`KT.cam`。
+- **中文字体**:示范片用阿里巴巴普惠体 3.0 四个字重(Black/Heavy/Bold/Medium)做;开源版因字体许可换成思源黑体 Noto Sans SC 900/800/700/500,family 名沿用 `PuHui-*`,GB2312 全量子集(`scripts/font_subset.py --gb2312`),换题目一般不用重做。
+- **音乐(实验归档里的 `build_y5.py`,没收进 skill)**:numpy 合成鼓(kick 每拍、clap 2/4 拍、hat 反拍)+贝斯(每小节一个根音的八分音符)+事件音效(主词=boom、小元素=pop、打字=click、打勾=升调 pop、转场前=riser)。
+
+## ⑦ 代表作品与一手参考
+
+- Saul Bass 片头档案(Art of the Title):https://www.artofthetitle.com/designer/saul-bass/
+- 维基「Kinetic typography」(motion typography / fluid typography 两类、Bass 是长片先驱):https://en.wikipedia.org/wiki/Kinetic_typography
+- School of Motion《Kinetic Typography in After Effects》Part 2(帧数:小词滑入 4 帧、主词甩入 6 帧+2 帧过冲回正、镜头推 6 帧+2 帧回拉;「镜头要晚一点动,像是被声音推着走」):https://www.schoolofmotion.com/blog/kinetic-typography-after-effects-part-2
+- School of Motion Part 3(下落要加速不要缓停、撞击时整个合成放大再回 100%):https://schoolofmotion.com/blog/kinetic-typography-after-effects-part-3
+- Dan Ebberts 惯性回弹表达式(`amp·sin(2πft)/e^(decay·t)`,默认 freq 3 / decay 5):http://www.motionscript.com/articles/bounce-and-overshoot.html
+- Lee, Forlizzi, Hudson,《The Kinetic Typography Engine》(UIST 2002,动态字表达情绪与语气):https://dl.acm.org/doi/10.1145/571985.571997
+- 视频文字停留时间:https://www.ssw.com.au/rules/post-production-do-you-give-enough-time-to-read-texts-in-your-videos
+- 本次实测的两支转载:DISCORD [Kinetic Typography] https://www.bilibili.com/video/BV1ts411S7Xa ;Charlie Puth – We Don't Talk Anymore (Kinetic Typography) https://www.bilibili.com/video/BV1by4y1r74Y
+
+## ⑧ 最容易做错的 3 件事
+
+1. **所有字一样大、一起动。** 没有层级就没有焦点,观众不知道先读哪个。主词与辅句至少 3:1,同一时刻只让一个东西在「入场」,其余全部静止。
+2. **字一直在漂。** 字在读的时候不能动(会读不进去)。持续运动交给镜头微漂、拍点微冲、背景点阵;字砸进来 0.35s 后就钉住。
+3. **动画不踩拍,或者踩在转场起点上。** 转场的第一帧不是重音,「新画面露出来」那一帧才是。把段起点往前挪「揭开点 × 时长」,再把镜头里每个落点写成拍号;节拍网格以外的落点每多一个,整片就散一分。
+
+---
+
+## 示范片
+
+- 成片:`scripts/engine/demos/y5_kinetic_type/`(渲染 `render.py --film demos/y5_kinetic_type`)(8.5s,60fps,合成配乐 120 BPM);每镜一帧总览:`assets/动画语法/y5_kinetic_type_总览.jpg`
+- 工程:`scripts/engine/demos/y5_kinetic_type/`(`eras.js`、`kinetic.js`、`k1_title.js / k2_complete.js / k3_chat.js / k4_agent.js`),通用部分在 `scripts/engine/lib/`
+- 镜头表:K1 标题「AI 写代码 的 ③ 个阶段」→ 穿越放大 → K2「补全」(代码卡+灰字补全+Tab)→ 色带擦除 → K3「对话」(你一句、它一整段)→ 推 → K4「代理」(TODO 三条自己打勾)+进度轨满格
+
+## 审片返修(独立 agent 只看成片)
+
+审片结论:「开头 0–2s 是标准的 kinetic type,『3』的圆冲进镜头变成下一段底色是全片最好的设计」「声画对位几乎完美,所有视觉事件都落在 120BPM 网格上、和底鼓同一帧」。「必须改」5 条,处理如下:
+1. **辅句停留太短**(0.6–0.9s)→ 辅句提前一拍出、压到 6–7 个字(「它补完下一行」「一句话换一整段」「你只说要什么」),可读时间 1.0–1.5s(阶段 2 仍偏紧,正式片配口播就够);全片加 0.5s。
+2. **阶段 2 辅句快撞上 AI 面板**(14px)→ 辅句变短、右对齐,间距 >180px。
+3. **推页早了 8 帧、进度轨跟着跳** → 段起点按 90% 位移重算(5.80);进度轨移到 `GLOBAL_OVERLAY` 固定层,颜色在揭开那一帧换。
+4. **阶段段落不够 kinetic**(编号太小、关键词只高亮不放大)→ 加背景巨型阶段数字 1/2/3;关键词到强调拍放大 1.35 倍。
+5. **结尾没有收尾的一击、打完勾全变灰** → 加第 16 拍收尾重拍(镜头拉远 6%+3.5% 冲击+低频+高音铃),勾完的字变绿不变灰,内容整体下移 70px 填掉底部空白。
+另外:代码卡改用等宽字体(Menlo)。
+没采纳的:「把每段延长到 2.5–3s、全片 10–11s」——示范片要求约 8 秒,用压字数代替延时长。
+
+## qa.py 数字(返修后,`uv run scripts/qa.py --project scripts/engine --film demos/y5_kinetic_type`)
+
+| 段 | 运动% | 静止帧对% | 跳变 | 均/峰 ms | 确定性 |
+|---|---|---|---|---|---|
+| k1_title | 2.37 | 0.0 | 1(t=1.63,标题退场) | 1.0/1.6 | ✓ |
+| k2_complete | 2.39 | 0.0 | 0 | 1.5/3.2 | ✓ |
+| k3_chat | 2.59 | 0.0 | 1(t=4.54,AI 气泡长出) | 1.6/2.2 | ✓ |
+| k4_agent | 2.88 | 0.0 | 3(t=6.29 Agent+任务卡;t=8.00/8.04 收尾重拍) | 1.6/2.0 | ✓ |
+
+转场冒烟(整帧峰值):fillZoom 6.8ms、bands 4.8ms、push 3.8ms。5 个跳变逐个看过帧,全是有意的拍点重音(qa 文档:「有意的节拍闪不算错」)。kinetic 的跳变就该落在拍上——可以拿跳变时刻去对节拍网格,对不上的才是 bug。
+返修后逐帧扫描四条边:0 帧露黑。
diff --git "a/references/\345\212\250\347\224\273\350\257\255\346\263\225/y6_presenter_explainer.md" "b/references/\345\212\250\347\224\273\350\257\255\346\263\225/y6_presenter_explainer.md"
new file mode 100644
index 0000000..94a88fc
--- /dev/null
+++ "b/references/\345\212\250\347\224\273\350\257\255\346\263\225/y6_presenter_explainer.md"
@@ -0,0 +1,24 @@
+# Y6 · 讲解员式财经科普
+
+一个卡通讲解员在纸面、图表和关键词之间串联信息。适合商业史、产品机制和带情绪反应的知识讲解。参考代码在`scripts/engine/reference_films/spacex/spacex_lin/`;这是第9种语法卡,目前没有独立参数化片段,也不附角色sprite。
+
+## 起手必查
+
+- 分镜先分配版式:侧身讲解、满屏数字、左右对比、角色进入图里、反应特写。不要全片固定人左图右。
+- 生帧至少备全身和胸像两档景别;坐姿和倚靠需要真实的对应帧。
+- 每段第一个`cast`关键帧显式给出`x`和`s`,防止跨段继承造成回归。
+- 嵌套绘制的透明度用`*=`,保留外层淡出。
+- 顶栏年份、字幕和段标题读同一个时间源。
+- 第一版即跑`qa.py`文字框景;浅底无字幕成片再跑`subzone_gate.py`。
+
+## 帧与动作
+
+角色采用AI生成帧,代码控制脚底锚点、位置、大小和换帧。姿势硬切配轻微弹出,避免不同轮廓溶解形成双影。说话和闭嘴随口播时间切换;停顿时停止口型,走路使用完整步态帧。姿势的身高按中位数校齐;反应特写用胸像素材,不把整帧截图硬放大。
+
+数字在口播念到时落定。计数过程中不要提前带「超过」「+」等断言;强调圈在数字落定后出现。高光后的停顿要在脚本和口播阶段留出来。
+
+## 参考实现
+
+`common.js`提供`presenterFrame`、`drawFigure`、`hud`、`yearAt`、`popK`和`L.cast`。`prep_presenter.py`演示切帧及脚底锚点。转场`transitions/lin_page.js`只翻页面,讲解员和顶栏可跨页连续。
+
+已知限制:人物遮字、角色被推镜裁掉仍需肉眼审片;参考代码中的整帧位图推近容易裁切,新片应优先使用场景相机。素材和口播需自行提供,不能直接把本卡当作完整成片模板。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/01_cave.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/01_cave.md"
new file mode 100644
index 0000000..281849a
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/01_cave.md"
@@ -0,0 +1,46 @@
+# 01_cave · 40,000 BC 洞穴岩画(纯代码)
+
+文件:`scenes/01_cave.js`(约 330 行)。最终性能:warm max 22ms / mean 21.1ms,cold(建缓存)在引擎 boot 时完成;确定性通过;0.2↔0.7s 运动差分 3.9% 像素。
+
+## 管线
+1. **岩壁(全部缓存,`cave_relief`/`cave_bg`)**
+ - 半分辨率 960×540 算高度场:`fbm(x·0.0022,4oct)·1.0 + fbm(x·0.011,3oct)·0.16 + noise(x·0.05)·0.03`(坐标用全分辨率像素)。
+ - 有限差分×52 得法线,光源 L=(-0.55,-0.62,0.56)(左上),`shade = clamp(0.5+(dot-0.56)·0.9)`;底色在 `#ce925a`(亮赭)/`#6e4426`(暗)/`#b6643a`(红斑) 之间用两层低频 fbm 混,再 ×(0.72+shade·0.55)。放大到全屏用平滑插值 → 起伏柔和。
+ - 叠两层 `P.grain`(暗 0.22 密度 α0.32、亮 0.10 α0.28)出颗粒;10 条随机游走裂缝(每步转角 ±0.45rad、步长 14–40px、12% 概率分叉),深线下面垫一条 +1.6px 偏移的亮线 → 刻痕感。
+ - 暗角:径向渐变 r 260→1180,外圈 α0.8;中心静态暖光用 lighter(α0.36)只照亮岩壁。
+ - **踩坑:relief 的中频项系数一大(0.35、×60 法线)整面墙就成了迷彩/沙丘,人物叠上贴图后像迷彩服**。中频降到 0.16、法线 ×52 后才像岩面。
+2. **「颜料吃进岩石」**
+ - 所有图形统一画法 `shape()`:先用 **fuzz 图案**(稀疏炭点,宽 2lw+7)描一遍 → 再用 **ink 图案**(炭黑、7% 随机孔洞 + 噪声 >0.58 处大孔,宽 2lw)描 → 最后平涂填色盖住内半圈。效果 = 实心炭线 + 喷点毛边,且 painter 顺序天然处理遮挡(手臂盖住外衣的线)。
+ - 炭笔「沸腾」:两张 256 图案每 1/9 s 用 `pattern.setTransform` 随机平移一次,几何不动、颗粒在跳,比抖动路径省且不变形。
+ - 整个颜料层画完后 `source-atop` 叠一张 `cave_figtex`:岩面阴影→黑 α(0.5-v)·150、亮处→暖白 α(v-0.5)·50、暗/亮颗粒、低频干湿斑 α≤70。**颜料层只有一次全屏合成**,所以 19ms。
+ - 填色都是不透明平涂,颜色靠贴图「脏」掉;不要用 multiply 叠颜料——白垩(猫的白)会消失。
+3. **负形手印/爪印**:320² 临时画布高斯喷点(σ46·s 3200 点 α0.15–0.6 + σ28 1400 点),再 `destination-out` 一张实心手形蒙版,最后蒙版 α0.3 填 `#f6e2bc`。**手形必须逐块 fill 到蒙版**:把手掌椭圆和手指胶囊 addPath 进一个 Path2D 一次 fill,子路径绕向相反处 nonzero 抵消,出现缺口(r4 踩到)。
+4. **火光**:每帧一层径向渐变,中心 (1000+40·noise(t·3.1), 540+26·noise(t·2.3)),强度 `0.13+0.09·noise(t·8.5)+0.04·sin(21t)`,**用 overlay 合成**(α=强度×2.6)。外圈再叠一层随火光反向呼吸的暗角。踩坑:一开始用 lighter,少女的金发和兽皮被洗成粉白、失去赭石饱和度,改 overlay 后颜色回来了。
+5. **余烬**:`P.particles` 三组(左 0–360 ×11、右 1540–1920 ×12、中间 ×5),y 从 1110 漂到 120,life 5.5s;亮核 r 2.2–4.6 + 3.2 倍光晕,`|sin(6t+1.9i)|` 闪烁,`sin(q·π)` 首尾淡入淡出,lighter 合成。
+
+## 母题动画
+- **野牛/马两张姿态**:`ph = floor(t·60/7)%2`(每 7 帧换),腿的终点两套坐标(伸展/收拢)、头绕颈点 ±0.07rad、整体 y 交替 -3/+1px;马与野牛反相。腿只用炭线(原片也是),身体是填色剪影 + 背脊一道 22px 深色晕染(拉斯科式明暗)。
+- **端杯**:没用 RIG 的杯子轨迹(桌面→嘴,桌面点在少女胸前,不像原片「伸臂端在半空」)。自定:`hold=(1084,506)` → `mouth=HP(1224,380)`,进度 `k = choreo(max(0,lt-0.95)).cup`(choreo 曲线整体平移 0.95s,对上原片 58 帧起举杯),手臂用 `RIG.ik2(G.A.shoulder, cup+(34,10), 170,128,-1)`;`RIG.girl({cup:k})` 仍负责头部后仰与喝的微仰。k 在 lt≈1.85(T01 转场末)到 1。
+- **热气**:三条炭线 `x0 + sin(13q − 11t + 1.3j)·6`,高 58px,跟杯走。
+- **猫**:RIG.cat 的 head/eyes/nose/earInner/stripes/tailPts 锚点 + 自画梨形身体、白胸、白前腿、大腿弧线;尾巴 = fuzz/ink/橙三层描边 + 每 4 个采样点一道横纹;眨眼来自 choreo.blink。
+- **猫的尺寸(复核返修)**:RIG.cat 原尺寸耳尖在 y≈535,顶进壁画框底边(550)。整只猫用画布变换以脚底 (540,905) 为锚缩 0.86(translate→scale→translate,RIG.cat 本身仍 s=1),耳尖落到 y≈582,与框底留出约 30px,脚底不动。线宽随之 ×0.86,看不出差别。
+- **标题**:`Kalam-700` 78px letterSpacing 7,水平缩放到 930px 宽,`#9b2a18`,画进颜料层(同样吃岩面贴图)。α = t<0.933 ? 1 : 1-(t-0.933)/0.2。
+
+## 运动量返修(复核口径:静止段帧 21–84,480×270 逐帧平均帧差)
+复刻 0.62 vs 原片 0.86,偏静。只加局部动作,不靠全屏闪烁:
+- 火光:强度 `0.14+0.11·noise(9.5t)+0.04·sin23t+0.03·sin37t`,中心游移 ±60/±36px(原 ±40/±26)。试过更大(±0.16、±90px)会冲到 1.22,画面发晃,回调。
+- 余烬 28→49 颗(左 20、右 20、中 9),亮核 r 2.6–5.4,光晕 α0.32、3.6 倍,闪烁 `0.3+0.7|sin|`。
+- 手印忽明忽暗:每个手印叠一块 r=105 的暖色径向渐变(lighter),α=0.2·clamp(0.5+0.9·noise(7t+3.7k)),各自独立相位。
+- 野牛/马颠簸 ±3→上下 9px、左右 ±3px,头部摆 ±0.12rad。
+- 猫头小动作(对原片 65–81 帧):lt 1.08–1.35 用 `sin(πq)` 包络,绕颈点 (596,680) 抬头转 −0.16rad,RIG.cat look 推 1.5,耳朵 60Hz 微抖 ±0.06rad。
+- 结果:**0.62 → 1.06**(原片 0.86);每帧 max 22ms。
+
+## 少女的时代化
+红赭石 `#9c3520` 剪影(脸/颈/手臂/小腿),侧脸只留一只杏仁眼(米白眼白+黑瞳+一根睫毛,眨眼变弧线)——这一笔是「少女感」的关键;金发用黄赭 `#cf8f2c` 填 + 6 条 `#6e3c0e` 波浪发丝(振幅随长度增大),轮廓也是波浪;发丝下半段逐渐不跟头部旋转(HB 函数),避免喝水仰头时整片头发甩动。及膝兽皮外衣 = G.torso + 自画下摆(每 15px 一个 ±16px 锯齿毛边),`#b06a2c` + 26 个「圆斑+7 个小点」豹纹斑 + 18 道短毛线,接缝靠「先描两块的边再一起填」盖掉。
+
+## 色板
+墙 `#ce925a/#6e4426/#b6643a`;炭 `#21150d`;红赭 `#9c3520`/暗 `#74261a`;黄赭(猫)`#c9772f`;金发 `#cf8f2c`/`#6e3c0e`;兽皮 `#b06a2c`/斑 `#4e2610`;白垩 `#f0dfbf`;野牛 `#8c3d22`/头 `#76301a`;马 `#cf8236`;石 `#c98c50`/`#c08048`;桌面 `#d49a5a`;手印 `#8e2a1a`;余烬 `#ffe082`。
+
+## 仍可改进
+- 少女身体是 RIG 的写实曲线,比真正岩画人形「太顺」;更原始的做法是把轮廓点降采样到 12–16 个再加大手绘抖动。
+- 岩壁浮雕是静态的,火光只改亮度不改阴影方向;真要「火光跳动下岩面起伏在动」需要两张不同光向的 shade 图按火光插值(+1 次全屏合成)。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/02_egypt.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/02_egypt.md"
new file mode 100644
index 0000000..0816d71
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/02_egypt.md"
@@ -0,0 +1,64 @@
+# 02_egypt · 公元前1350年埃及墓室壁画(纯代码)
+
+文件:`scenes/02_egypt.js`(约 460 行)。性能:warm max 20.7ms / mean 10.5ms(1920×1080),boot 时 `init()` 预热缓存,第一帧不再卡 170ms。确定性检查通过。
+
+## 管线
+1. **静态层 `eg_static`(缓存一次)**:灰泥墙 → 象形文字栏 → 窗(檐口/彩块框/白底/阿顿日盘/圣蛇) → 陶罐×3 → 供桌与供品 → 金椅 → 蓝碗 → 地线与底部多层饰带 → 深蓝带 → 顶/左右彩块边框。
+2. **会动的母题(每帧画,便宜)**:水纹象形字流动、阿顿光线+末端小手开合、两条长光线伸到猫面前托安卡、圣甲虫推日球。
+3. **角色**:埃及程式重画,不走 RIG.drawGirl/drawCat,只取锚点与编舞。
+4. **壁画表面**:`eg_surface` 斑驳图层 `multiply` 全画面+`P.grain` 颗粒+6 条随机游走发丝裂纹(裂纹画在表面层里,所以会跨过人物,像真墙面老化)。
+
+埃及壁画是「无透视、平涂、轮廓线」,这里**不用任何笔触渲染器**,线条也不沸腾(干净的 2.2–2.8px 深棕线 `#2a1810` 才像),时代感全靠程式(侧脸正面眼、正面双肩)+色板+纹样密度。
+
+## 色板
+墙 `#eadcb8`→斑驳暗部 `#d8c597`;四色边框 红 `#b8322a` 蓝 `#2a58a8` 黄 `#e2b13a` 绿 `#2e8a55`,块间米白 `#f2ead6`、黑缝 `#231a14`;金 `#e0ab38`/暗金 `#a8741c`/亮金 `#f3d27a`;深蓝带 `#1c2236`;分栏红线 `#9a2b22`;阿顿日盘 `#c8372b`、光线 `#c23a2a`、小手 `#b4452c`;肤色 `#e6b282`(埃及女性的浅黄赭);猫 橘 `#e08a3c` 条纹 `#b45a1c` 白 `#f6efe0`;圣甲虫 青金 `#2c56b0`+绿松石 `#3fa6a0`。
+
+## 象形文字(最出时代感的部分)
+- 写了 **24 个字形函数**(安卡、日轮、面包、芦苇、猫头鹰、隼、鹭、角蝰、荷鲁斯之眼、王名圈、圣甲虫、坐人、腿、手臂、篮、房、三竖、羽、杰德柱、申环、罐、莲花、nfr、嘴、水纹),每个在 ~50px 框内用 10–20 笔画出,自带候选颜色。线宽 3.1(缩放后约 3px),`round` 端点。
+- 栏位照原片量:左 3 栏 x=78..306/y=66..566、中上 4 栏 x=852..1172/y=66..452、右 4 栏 x=1560..1866/y=252..882、猫左 1 栏 x=298..366/y=614..886。
+- 排布:`U.rng(1350)` 种子,逐栏往下塞,字形缩放 = 栏宽/78×(1.0–1.14),间距 6–11px;**同栏不相邻重复、同栏同字形 ≤3 次、圣甲虫/水纹降权 60%**(第一版没限制,满屏都是圣甲虫,像贴纸)。
+- 排布在模块初始化时算好、存位置——这样水纹字可以不进缓存,单独每帧画。保底至少 6 个水纹字。
+
+## 母题动画(全部只靠 lt/t,确定性)
+| 母题 | 做法 | 数字 |
+|---|---|---|
+| 圣甲虫推日球 | x(lt)=800+642·(lt−0.394),原片 10.7px/帧量出来的;取模 2160 循环;球滚动角 = 球心x/半径;腿两套姿态 `floor(lt*15)%2`(60fps 每 4 帧换) | 整体 ×1.22,球 r=23×1.22 |
+| 阿顿小手开合 | open=0.5+0.5·sin(2π·lt/0.4+k·0.9),手指张角 (0.1+0.24·open) | 周期 0.4s,13 只窗内+2 只窗外 |
+| 光线微颤 | 末端 x+=3·sin(7t+1.3k),y+=2·cos(6t+k) | ±3px |
+| 水纹字流动 | zigzag 相位 = floor(lt·12)·0.5,12fps 步进、4 步一循环 | 0.33s/循环,像逐张手绘 |
+| 端杯 | `cup = lerp(0.8,1,choreo.cup)`:原片「一直端在嘴边喝」,只走最后 20% 的举杯+choreo.sip 仰头 | — |
+| 猫 | choreo.tail 甩尾(RIG.cat.tailPts)、blink(t≈2.18–2.30,正好落在本段 lt≈0.77–0.89)、breathe 上身 | — |
+
+运动量:lt 0.45↔0.9(避开拍点冲击缩放)动像素 3.5%,集中在光线小手、猫尾、少女头臂、圣甲虫——量不大但都是视线焦点。
+
+## 角色:埃及程式
+**少女**(`RIG.girl({dy:-25})`,dy 让脚落在 y=900 地线上):
+- 侧脸取 `G.face`;**正面眼**自己画:杏仁形白眼+黑瞳 r4.2 贴上眼睑、上眼线 3.2px 往后拖 18px(kohl 拖尾)、长眉。
+- **正面双肩**:躯干不用 G.torso,自己画宽梯形 x 1270–1452(两个肩都看得见,上宽下窄)。
+- 白亚麻:先填肤色,再 `alpha .9` 罩白 → 透出一点肤色=亚麻半透明感;裙身 27 条贝塞尔细褶从腰扇形散到下摆(clip 在裙里,`rgba(120,96,70,.5)` 1.3px),胸前竖褶间距 9px。
+- 宽领项圈:5 条同心半椭圆(蓝/红/绿/金/蓝,rx 50→88、ry 24→55),外圈 18 颗红蓝交替水滴坠。
+- **金色发辫**:假发轮廓 clip 后画 15 束竖辫,每束 = 11.5px 深金底线+8.5px 金色线+每 8px 一道左右交替的斜分节(人字纹),末端长短错落。第一版用小圆珠铺满,像「金色鱼子酱」,换成长条+斜节才读成编发。
+- 金发箍(贝塞尔 15px 黑底/11px 金/3px 亮金)+后垂带、大金耳环、金臂环(金 8px+蓝 2.5px 横条)。
+- **端杯手臂**:RIG 默认的手在杯侧、肩在躯干中间,肘会甩到很远。改成「手托在杯身下(杯脚)」,肩挪到前肩 (1282,476),`RIG.ik2(sh, hand, 140, 160, -1)` 让肘下垂到胸前。
+- 蓝色莲花杯:花瓣形杯身+三道浅蓝瓣线+杯脚,跟 G.cup 的位置/倾角走。
+
+**猫=巴斯特坐姿**(`RIG.cat({dy:-5})` 取 headC、tailPts、blink、breathe,身体自己画):
+- 剪影:挺直的胸+圆臀,**前腿包在剪影里**,胸口到前爪一整片白,再用两条线分出两条前腿+趾线。第一版把前腿画成两根独立白柱,像保龄球瓶。
+- 侧头+高尖耳+正面杏仁眼(黄 `#e8cf4a`、竖瞳、黑眼线拖尾)、白口鼻、胡须、金耳环。
+- 项圈 clip 在「身体∪头」里(`Path2D.addPath` 合并),不然圆头描边会戳出脖子;荷鲁斯之眼金坠子。
+- 橘色虎斑:背上 9 道、大腿 4 道、头顶 5 道深橘弧线,尾巴每 3 个采样点一道横纹,尾尖白。
+
+## 踩到的坑
+- selfcheck 的 0.2↔0.7 差分在本段会「全画面都在动」——那是引擎的拍点冲击缩放(lt<0.36s),不是场景在动。看真实运动要比 lt≥0.4 的两帧。
+- `P.texture` 首次生成约 170ms;在 `init()` 里预热(引擎 boot 时调用),否则会卡在 T01 转场第一帧。
+- 原片 ref 里的碎石块是转场残留,不是画面内容,别照抄(设定稿里也没有)。
+- 年份牌区域 1500–1890×40–210 只留墙面;右侧象形栏从 y=252 开始正好避开。
+- 复核返修:猫原尺寸时耳尖 y≈530,压到窗框底部彩块(y 530–560)上,像猫头插进窗框。改为以脚底 (540,898) 为锚、画布变换整体缩到 0.85(RIG.cat 仍是 s=1),耳尖落到 y≈585;两条长光线末端用同一变换 `catPt()` 换算,小手仍落在猫头/口鼻处;背线和臀部前移 12–20px,让巴斯特坐姿更修长。**教训:猫/人和窗框各自对齐标准构图框还不够,两个框在 y≈540–600 贴得很近,加高耳朵这类超出骨架框的部件要单独查和邻近物体的间隙。**
+
+## 返修 v2:埃及偏静(审片报告第 3 条)
+口径:整片 renderFrame,静止段帧 112–140,480×270 逐帧平均绝对差(屏蔽计数器)。**改前 0.32 → 改后 0.84(原片 0.90)**,性能 warm max 21.7ms。
+- **端杯循环**:lt<0.35 照 choreo 举到嘴边;之后每 0.6s 一个循环 `cup = 1 − 0.46·(1−cos 2πu)/2`(杯离嘴下放到 0.54 再举回);杯在嘴边时加仰头 `sip += 0.3·clamp((cup−0.78)/0.22)·(0.65+0.35·sin 13lt)`,头部倾角到 ~0.2rad。这一项贡献最大。
+- **铭文被写出来**:每 0.12s 从打乱的字表(种子 77,跨所有栏)取 6 个字:先用墙面纹理 `drawImage` 子矩形擦掉,再用 `setLineDash([p·95, 999])` 按笔画描出(每个子路径的 dash 会各自从头开始,正好像逐笔书写),填色部分 p>0.55 才出现;笔迹颜色从亮金 `#f6c846` 落回原色,带 10px 金色 shadowBlur 余辉,0.36s 写完。同时约 18 个字在写。
+- **阿顿脉动**:周期 0.45s;光线长度沿扇形依次 ±9%(相位 −0.55k,像一道波扫过),线宽 2.2→3.8,小手整体缩放 0.9–1.2、手指张角 0.03–0.45;日盘外金色光晕+亮环脉动,日盘重画在光晕之上保持红色。小手坐标 clamp 在窗内(x 428–752,y≤512),否则伸长时会被窗框裁掉半只。
+- **猫**:尾巴幅度 `tail·2.1 + 0.25·sin 9.5t`;两耳错相快速一抖(每 ~0.38s 一次 0.1s,绕耳根中点转 0.32–0.38rad)。
+- 教训:阿顿光线、水纹字这类细线母题在 480×270 的帧差里几乎不计分,**测「看得出在动」要靠面积够大的局部动作**(手臂+头、整字擦写),细线摆动只能当点缀。第一版日盘脉动用半透明橙色盖在日盘上,峰值时把红日盘冲成橙色,改成盘外光晕+亮环。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/03_greek.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/03_greek.md"
new file mode 100644
index 0000000..a4b3e6c
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/03_greek.md"
@@ -0,0 +1,50 @@
+# 03_greek · 公元前530 阿提卡黑绘陶器 —— 代码画法笔记
+
+文件:`scenes/03_greek.js`(纯 Canvas 2D,无图片)。最终自检:warm max 15.9ms / mean 7.6ms / cold 80ms,确定性通过,0.2↔0.7s 运动差分 22% 像素在动。
+
+## 一句话诀窍
+黑绘 = **黑釉剪影 + 刻线 + 附加色**三件套,缺一不可:
+- 剪影:所有人/物填 `#1b120d`(近黑带暖),不描边,靠剪影和陶土底对比成形。
+- 刻线:在黑剪影上「刻穿」,用陶土亮橙 `#e8904c` 画 1.5–2px 细线(衣褶、五官、肢体重叠处的分界)。
+- 附加色:紫红 `#8a2a37` 色带(发带、袖口、下摆、项圈、坐垫)+白色小点(`#f6ead6`,r≈2,间距 11–17px)。
+做到这三样,不需要任何纹理就一眼是希腊陶瓶。
+
+## 色板
+陶土 `#dc6a2f`、亮陶土(瓶面板)`#e8803f`、黑釉 `#1b120d`、紫红 `#8a2a37`、白 `#f6ead6`、刻线 `#e8904c`、金发 `#f2bd48`、陶土留白(猫白区)`#f3cfa4`、猫橘 `#f2913f`、猫鼻 `#e7897a`。
+
+## 管线与参数
+1. **陶土底(缓存 `gr_bg`)**:480×270 低分辨率逐像素算 fbm(×0.016, 4 octave) 斑驳 ±30 + `noise(x*0.006, y*0.85)` 的**水平条带噪声**(拉坯纹)±9,放大到 1920×1080(低频本来就糊,省 16 倍计算);再画 560 条随机水平细线(长 150–1050,alpha 0.03–0.08,深/浅两种)当拉坯细纹;420 个深色小点 + 120 个浅点;两层 `P.grain`;5 条裂纹(每 9px 一段、±2px 抖动,下沿再画一条 1px 偏移的淡亮边,裂缝立刻有厚度)。中心叠一层暖色径向提亮 0.16。冷启动整帧 ~80ms。
+2. **暗角(缓存 `gr_vig`)**:径向 380→1180,外沿 rgba(30,6,0,.62),最后一层盖全画面(含纹带)。
+3. **静态黑绘层(缓存 `gr_static`)**:画框(黑边 18px+白点串 11.6px 间距+内细线)、葡萄藤(正弦茎+三角葡萄串 3-2-1 圆点)、桌(腿带兽爪脚)、车旋椅腿(宽度表 [y,w] 折线对称成形)、天鹅颈椅背(13px 粗描边曲线+椭圆头+三角喙)、双耳瓶(24 点对称轮廓→`RIG.smooth`,瓶面板留陶土+小黑猫、瓶底射线纹、一条竖向 0.09 的光泽渐变)、两段希腊铭文。
+4. **希腊铭文**:字体库没有希腊字形 → 自写**笔画表**(每个字母 1–3 段折线,单位格 0..1)。字高 30、笔宽 3.4、每字高度 ×(0.9–1.06) 随机、基线 ±6% 抖动、顶点 ±0.7px 抖动;Ο 画成小圆(字高 0.25,原片就是小 o),Ι 宽 2px。手写陶画铭文味道主要来自「字母不等高 + 小 o」。
+5. **滚动纹带**:顶部回纹(周期 60px,7px 黑线,单元折线 `[[4,46],[4,0],[50,0],[50,34],[18,34],[18,14],[36,14],[36,22]]` +通长底线)与底部莲苞链+射线纹(周期 76px=两个 38px 单元,奇数苞填紫红,所以真实周期是 76)各预渲成宽 W+2P 的条带,每帧 `drawImage(strip, -(off mod P))`。偏移曲线:
+ - 顶:`off = 22·lt + 60·easeInOut((lt−0.49)/0.35)`,向左;
+ - 底:`off = −(18·lt + 76·easeInOut((lt−0.477)/0.367))`,向右。
+ 原片只在 169–191 帧做一次 easeInOut 周期跳;我额外加了 18–22px/s 匀速漂移,让本段前 0.47s 也能看出在走。
+6. **画框内母题**(每帧画,clip 进画框):6 条海豚(自写贝塞尔剪影:喙、背鳍、腹鳍、尾叉+腹部刻线+白眼点)沿自身朝向 ±9px 来回游、角度 ±0.12rad,周期 0.85s,彼此相位差 1.3;船整体绕 (560,420) 起伏 ±4px、摇 ±0.025rad,周期 0.9s。白帆+紫红缝线、新月船身+蝎尾形船尾、紫红船舱、斜倚人形。
+7. **里拉琴**:以钉子 (1050,150) 为轴 `0.09·sin(2π·lt/0.8+0.5)` 摆(±5°,音箱处位移 ±17px,1 秒内明显)。龟壳音箱=黑圆+刻线圈+5 个刻线小圆。
+8. **玫瑰花饰**:8 瓣黑椭圆+刻线分瓣+紫红心,`lt·1.6` rad/s 正反交替旋转。
+9. **橘白猫**(自画,不用 RIG 默认多边形;尾巴用 `RIG.cat` 的 tailPts 跟 choreo.tail 摆):整体以 (548,903) 缩 0.9 落进标准框;橘剪影+黑描边 3.4px;白胸/白爪/口鼻用「陶土留白」奶油色;**背部虎斑沿背轮廓按弧长等距取 12 点,朝身体中心 (575,800) 画锥形斑**(长 30–48,根宽 10)——比手摆斑纹自然得多;大腿弧、前腿竖斑;古风大圆眼(白眼+黑瞳+高光+上方一道眉弧),眨眼时换成弧线;紫红项圈白点。
+10. **少女**:`RIG.girl({cup,sip,breathe,s:0.97,dy:-14,hair:'long'})`——缩放下移让脚落在地线 903。
+ - 身体直接填 RIG 的 Path2D(farSleeve/skirt/torso/neck),远侧手换成小椭圆(RIG 的 farHand 在黑剪影里像一片刀片)。
+ - **头部自画**:在 RIG 静止坐标系里写希腊侧脸(直鼻梁连额、细下巴)+发型轮廓,用 canvas 变换复刻 RIG 的头部运动:`translate(neck)·rotate(G.tilt)·translate(−neck)·T`。同一个矩阵用 `DOMMatrix` 再算一份,`Path2D.addPath(faceSil, M)` 拿来做刻线裁剪区。
+ - **金发**(认出「金发少女」的关键):发区 clip 内画 11 条头顶波浪发丝(二次贝塞尔+法向 2.6px·sin(7πu) 波动)、8 绺背后长卷发(正弦 4.5 个半波+末端小螺旋)、发髻双螺旋、额前 4 个小卷、鬓角两条螺旋卷(黑底 6px 垫一道再画金 2.2px,跨出剪影也看得清)。金线 2.5px 在 1080p 下才够「量」,2px 时缩略图里就看不出是金发。
+ - 刻线:衣褶 16 条(clip 在身体内)、杏仁眼(浅色眼白+黑瞳,正面眼画在侧脸上)、眉、鼻翼、唇、下巴。**近侧手臂与身体/头重叠处的分界**:clip(身体∪头) 后描手臂轮廓的刻线——黑叠黑只能靠这个分开,手举到嘴边时脸才不会糊成一团。
+ - 附加色:下摆 15px 紫红带+白点、袖口带(clip 在上臂内,沿上臂法向画 15px 宽色带+上下刻线)、手镯、白点四瓣小花 8 朵、发带。
+ - 基里克斯杯(宽浅双耳,半宽 32)跟 `G.cup`(含 tilt),杯口紫红线;热气是三道「≀」黑细线,相位 `t·9`。
+
+## 动的东西(0–0.94s 内都可见)
+端杯(choreo.cup 0.9s 举到嘴边+头微仰)、猫尾/眨眼/呼吸、顶底纹带滚动(漂移+拍点周期跳)、里拉琴摆、船起伏、海豚游、玫瑰转、热气扭。
+
+## 踩到的坑
+- RIG 头发轮廓直接放大后后脑太宽(第一版后脑伸到 x=1450,头像头盔);按设定稿收到 1424,长发只垂到 y≈558。
+- 杯子在嘴边时黑手黑杯黑脸糊成一块:①手臂对头部做刻线分界 ②杯子缩小(半宽 44→32)③杯口留一条紫红线。
+- RIG 猫的头顶到 y=535,标准框猫顶是 610;不缩会压到画框下沿。
+- 底带奇偶苞交替时真实周期是 2 个单元(76px),预渲条带的 wrap 周期必须用 76,否则每 38px 跳色。
+- `P.grain` 的种子 = key 长度,两层 grain 的 key 必须不同长度,否则图案相同。
+- **端杯终点要时代化(复核返修)**:RIG 的 cup→mouth 终点在鼻尖附近、杯倾 −0.45rad,换成宽浅的基里克斯杯后像一根鸟嘴/烟斗插在脸上,手还捂住嘴和下巴。改成自己做 IK:唇点 rest(1243,391) 用头部 DOMMatrix 变换到屏幕,杯沿中心 = 唇点 −(30,−1)(杯沿右端刚碰嘴唇),倾角 −0.08·cup(≤5°),手的 IK 目标 = 杯沿 +(lerp(32,6,cup), 30),即托在杯脚下;`RIG.ik2(S, 手目标, 165s, 122s, −1)`+`RIG.taper` 自己出上臂/前臂。前臂竖在胸前,鼻、唇、下巴的侧脸轮廓完整露出。热气跟随杯沿。
+
+## v1 审片返修(猫改黑绘 + 顶带滚动加量)
+- **猫必须和人同一套画法**:亮橘大圆眼卡通猫在黑绘里一眼跳戏。改成黑釉剪影,「橘白」只靠附加色和刻线分区:背部沿轮廓画一条 26px 紫红鞍带、头顶一块紫红(椭圆 46×22 clip 在头内)、尾巴黑底+7px 紫红芯;虎斑全部是陶土橙 `#f2913f` 3px **刻线**(沿背轮廓弧长等距 14 条朝身体中心的弯线+大腿 3 条+前腿 3 条+尾巴每隔 2 点一道环);白胸/口鼻/爪用白彩 `#efe1c8`,爪上黑刻趾;眼睛改古风刻线杏仁眼(白彩眼白+竖椭圆黑瞳+眼尾小刻线),眨眼是一道下弯刻线;鼻子紫红,须左侧用刻线(落在黑脸上)、右侧用黑线(落在陶土上)。
+- **周期图案滚整数个周期 = 首尾两帧一样**:顶带 60px 周期跳一次后画面和跳之前完全相同,看静帧对比或抽帧很容易判成「没动」。匀速漂移从 22→48px/s(底带 18→30px/s),保证任意两帧间都有相位差。
+- 整片静止段运动量(480×270 帧差均值):03_greek 1.87 → 2.02,原片 2.06。warm max 17ms。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/04_roman.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/04_roman.md"
new file mode 100644
index 0000000..7131869
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/04_roman.md"
@@ -0,0 +1,99 @@
+# 04_roman · 公元79年 庞贝马赛克 —— 手法笔记
+
+文件:`scenes/04_roman.js`(约 330 行)。最终自检:warm max 17ms / mean 13ms(1920×1080),init 206ms(boot 时一次),17,871 块石头,其中 13,067 块在动态区每帧重新取色。确定性通过。
+
+## 核心思路:布局只算一次,颜色每帧流过石块
+
+马赛克的动画应当长成这样:石块本身固定在墙上,动的是颜色从一块流到另一块。所以渲染器拆成两半。
+
+1. **init(`build()`,206ms)**:先算出每一块石头在哪、多大、朝哪、哪些像素属于它、斜面明暗如何,存成 `ID`(Int32,每像素对应的石块号,-1 表示灰浆)和 `SH`(Uint8,每像素明暗,128=1.0)。
+2. **每帧**:重画平涂底稿,`getImageData` 一次,然后在动态石块的中心点取色(加上每块石头固定的颜色抖动),再在动态矩形里逐像素填 `色×明暗>>7`,最后 `putImageData` 到自己的离屏画布,用 `drawImage` 贴到 `c` 上。
+ - 坑:**不能直接对 `c` 做 `putImageData`**,因为它会无视引擎的镜头冲击缩放(punch zoom)和转场裁剪。必须先写进离屏画布再 `drawImage`。
+ - 每帧逐像素只处理约 100 万像素(4 条边框带、画框内、少女、猫),用 JS 循环大约 5ms。所有离屏 context 都用 `{willReadFrequently:true}`,`getImageData` 才快。
+
+## 石块布局(andamento:沿轮廓排)
+
+按 Hausner 2001「Simulating Decorative Mosaics」的思路简化而来。
+
+- **结构图**:静态底稿加上第 0 帧的猫和少女(不画会动的近侧手臂),降采样到 960×540。相邻像素的 RGB 差之和大于 34 就记为边缘,再把类别图里边框带的边界也算作边缘。
+- **距离场**:用 Felzenszwalb–Huttenlocher 精确欧氏距离变换(两遍一维下包络),半分辨率下约 20ms。
+- **沿轮廓走线放石块**:候选像素满足 |d−(k+½)s|<1.5、k<该类的圈数,也就是距离场的等值线带。从未访问的候选点出发,沿 8 邻域优先走「和上一步方向最一致」的候选(方向做 0.6/0.4 平滑),离上一块的距离 ≥s 时放一块。石块的朝向取距离场梯度的切向。空间哈希保证任意两块的间距 ≥0.8×平均尺寸。
+- **规则成行补洞**:每个类别铺一张砖缝错开半块的网格(行抖动 ±5%、列抖动 ±9%)。最小间距检查用 0.86,能放下就放。这一步同时填掉轮廓行之间和中轴线上的洞。
+ - 坑:起初只让「距离 ≥K×s」的地方放网格,结果窄形状(猫尾巴,26px 宽)里一块石头都没有,整条尾巴露出灰浆。改成只靠最小间距之后就解决了。
+- **边框带单独排**:每条边在自己的局部坐标里排 11 行,石块 7.6px,沿边方向宽度在 0.86–1.14 之间随机;四角是 11×11 的方格。
+
+| 类别 | 石块边长 px | 沿轮廓圈数 | 颜色抖动 |
+|---|---|---|---|
+| 墙 | 12 | 1,之后规则成行 | ±8%,7% 的石块额外压暗 12% |
+| 晕圈(人/猫/物件外侧白边) | 11 | 9(整条晕圈都沿轮廓) | ±5% |
+| 少女身体 / 物件 | 10 | 全部沿轮廓 | ±5% |
+| 少女脸、猫头 | 6 | 全部 | ±4% |
+| 头发 | 8 | 全部 | ±5% |
+| 火山画内 | 9 | 2 | ±6% |
+| 外框带 | 7.6 | 沿边成行 | ±5% |
+| 文字 | 7 | 全部 | ±5% |
+| 地面带 | 13 | 1 | ±6.5% |
+
+除了表里的抖动,每块石头还会加一个 ±7 的加性灰度抖动。9% 的石块偏暖(+12,+4,−8),7% 偏冷(−6,0,+9)。
+
+## 石块形状与灰浆:加权 L∞ Voronoi
+
+- 每块石头是一个旋转方块。四条半边长各自独立取 `s/2×(1.08–1.28)`,旋转角再抖动 ±0.06rad。像素到石块 k 的距离定义为 `D=max(|u|/h±, |v|/h±)`,其中 (u,v) 是像素在该石块局部坐标里的位置。
+- 光栅化时对每个像素记录最小的 D1、次小的 D2 和对应石块号,开销是每块石头的包围盒 1.5h。
+- **灰浆**:满足 `D1>1`,或 `(D2−D1)·h/2 < g`(g = clamp(0.1s, 0.75, 1.25)px)的像素算灰浆,也就是落在两块石头的平分线附近。所以缝宽约 1.5–2.5px,石头被邻居「切」出不规则边,像真的錾过。
+ - 坑:半边长最初只取 `s/2×(0.9–1.1)`,石块小于间距,结果灰浆占了约 40% 的面积,看起来很稀。把石块做得比半间距大 8–28%,交给平分线去切,石块就密实了。这一处是质感的关键。
+- **斜面明暗**:离边 2.2px 以内,按外法线与光向 (−0.6,−0.8) 的点积 ±16% 变亮或变暗(左上亮、右下暗)。再加穹顶项 `−5%·D1²` 和 ±3% 的像素颗粒。
+- 灰浆色:`rgb(112,103,92)` ±8 噪声。
+
+## 平涂底稿与配色
+
+- 墙 `#e4ddcd`,晕圈 `#f5f1e8`(每个人和物件外面都描一圈 44–50px 的晕圈,石块会沿它排出白边),描边 `#46322a`,描边 8px(脸部 8px,以便成排)。
+- 画框:红 `#a8322a`,往里依次是深红 `#7c221d` 线、金 `#d0a23c` 线、深色线。
+- 火山:三个面分别是亮 `#7c84b8`、中 `#4e5796`、暗 `#2f3672`;天空 `#9ec0d8`→`#d3e3e4`;山坡 `#6f9341`/`#92b254`;地面 `#cba344`;柏树 `#2b5a2f`;熔岩 `#d64a22`/`#f2952c`。
+- 少女:斯托拉 `#efe7d5`,下摆两道红条 `#a8322a`;红披肩分三块(背后斜披、膝上一条、前襟垂下),褶线 `#7c221d`,配金色胸针;短袖口是在上臂里裁一个以肩为圆心、半径 62 的圆,加红边;金发 `#dcaa42`,分层线 `#9c6c1c`,脑后螺旋发髻;红发带用三次贝塞尔并跟随头部 tilt 旋转。眼睛画成 10×6 的白加半径 5.5 的深色,这样恰好落成「一白一深」两块 6px 石头。
+- 猫:橘 `#dc8530`,背部压暗 `#c06a24`,条纹 `#9c4818`,白 `#f7f2e8`,大黄眼 `#e9c22c`(半径为 eyeR×1.65),红项圈 `#b02a22` 带金坠。身体用 `RIG.smooth(K.bodyPts)` 平滑出梨形,替代原来的多边形。尾巴的环纹用虚线 `setLineDash([9,13])` 画。
+- 「CAVE CATTVM」:**自己写的等宽粗笔画字母**(C 用椭圆弧,A、V、E、T、M 用折线),笔画 14px、字高 60px、字距 16,横向缩放到 600px 宽。
+ - 坑:用 Cinzel-700 直接 fillText,细横笔在 7–9px 石块下会断(E 变 F、A 丢横),字距紧时还会粘成一团。三轮迭代下来,结论是「马赛克字 = 等宽粗笔画、每笔约 2 块石头宽」。
+
+## 母题动画(本段 lt 0–0.94s,T04 转场期间画到 1.29s)
+
+- **四边波浪纹顺时针流动**:每条边用 `setTransform` 切到局部坐标(u 沿顺时针方向,v 从外往里),画同一个维特鲁威卷涡:从内侧黑带起笔,螺旋 r 从 24 收到 5、转 2.25 圈,线宽 13,周期 81px。相位为 `42·lt + 81·easeInOut((lt−0.485)/0.365)`,即全程匀速漂移,再在原片的 226–248 帧多走一个周期。石块位置不动,所以黑白在石块间流动,正是马赛克动起来的样子。0.4→0.9s 之间边框带有 20% 的像素在变。
+- **维苏威冒烟**:火山口离画框顶只有 70px,烟往上飘很快就被裁掉,看不见(第一版就踩了这个坑)。改为让整条灰云带以 55px/s 向右漂(周期 380px),再加 9 团烟(深 `#3f3c3a`→浅 `#a29c94`)贴着天空往右压低飘,加 12 颗火星(10px 方块,抛物线轨迹)和火山口熔岩脉动。画框内有 4.4% 的像素在变。
+- **端杯**:节奏用 `choreo.cup/sip`,杯子是金色双耳杯 kantharos,杯口有白石热气,透明度为 1−0.85·cup。路线是自写的 `armPose`(见文末「复核返修」)。
+ - 坑:墙石 15px 时,手和杯子在大石块里糊成一团。一度给手臂扫过区单独换成 8.5px 石块,结果静止时成了发白的补丁,最后改成全墙统一 12px。
+- **猫**:尾巴用 `choreo.tail×1.6`(9px 石块下原幅度太小,看不出摆),眨眼时眼睛变成橘色石块加一条深线。
+
+## 性能与动态矩形
+
+- 动态矩形在 init 时由采样姿态的包围盒算出(cup 从 0 到 1 每 0.05 一档,sip 取 0/0.15;猫尾 tail 在 ±0.75 范围内),外扩 58px,包住晕圈和热气。矩形外是第 0 帧的静态马赛克。
+ - 坑:矩形要包得足够大,否则跨边界的石块会出现一半新色、一半旧色。
+- 全片时间轴里罗马段(包括前后两次转场、新旧两层同画)的帧,除了首次进入转场时其他时代的冷缓存外,都在 40ms 以下。
+
+## 自检里要知道的
+
+- `selfcheck` 的「运动差分 0.2↔0.7」会被引擎的拍点镜头冲击污染。lt<0.37 时整幅画面在缩放,结果报 68%,那不是画在动。改用 0.4↔0.9(冲击已结束)测:全画面 6.2%,其中边框带 20.4%、少女 8.4%、画框 4.4%、猫 0.8%。
+
+## 还能更好的地方
+
+- 少女举杯到嘴边时,手、杯和脸挤在一起,在 6–8.5px 的石块尺度下略糊。
+
+## 复核返修(第二轮)
+
+- **猫**:以脚底 (540,905) 为锚,用画布变换缩到 0.85(类别图、动态矩形同步缩放),耳尖从 y≈540 降到约 590,晕圈不再碰画框。头改画成正脸庞贝猫:两只 R17 的大黄圆眼、黑竖瞳、7px 深色眼眶,头部 11px 深色描边,类别图里也描进 6px 小石块,所以轮廓能成排。
+- **举杯糊脸**:不再走骨架原来的举杯路线,改用自写的 `armPose`。杯子沿「桌面→前上方 (1150,470)→唇前」的二次贝塞尔移动,终点是杯沿右端贴在 `G.lips[0]`,倾角 0.15rad(8.6°)。手托在杯脚下(偏移从 (28,34) 插值到 (3,44)),IK 用同一副臂长 165/122 和肘向。前臂竖在下巴前方,鼻、唇、下巴和眼都露出来了。面部描边加粗到 10px。
+- **补墙感**:去掉了「手臂扫过区 8.5px」这个类别。墙石统一改为 12px(也更接近原片墙石的尺度),动态区的墙和周围共用同一套布局,只是每帧重新取色,看不出边界。
+ - 教训:动态区千万别为了细节单独换石块尺寸,静止时它就是一块补丁。
+- 返修后:warm max 17.1ms,mean 13.0ms,确定性通过。
+
+## 审片返修(第三轮,v1 审片报告第 3、4 条)
+
+- **边框看不出在滚**:整片时间轴(renderFrame)里其实在动,但「石块不动、只换色」的做法下,卷涡每帧只移 1–3px,被 7.6px 的石块量化之后,在运动热力图里几乎不亮。
+ - 改法:边框改成「传送带」。在 init 里预烘一条长 2106px(26 个周期)的石块带。图案周期是 81px,石块布局也按 81px 循环:每行 11 块,宽度各自随机,但归一化到正好 81px,抖动也按周期复用。所以整条带平移任意相位都能无缝接上。
+ - 每帧对四条边各做一次 `c.transform(边的局部坐标)`,再裁剪、`drawImage(strip, BW−2·81+相位, 0)`,石块跟着图案一起顺时针走。四角方块保持静态。
+ - 相位改为 `15·lt + 81·easeInOut((lt−0.485)/0.365)`,匀速漂移从 42 降到 15px/s,主运动留给原片 226–248 帧那一个周期。
+ - 静止段运动量(motion.py,480×270 平均帧差,帧 222–253):复刻从 1.98 升到 4.62,原片 2.90。漂移是 42px/s 时为 5.5。
+ - 规律:慢速图案位移小于石块尺寸时,「只换色」会被量化吃掉,要么让石块跟着走,要么位移必须远大于石块。
+- **杯子读不出**:杯子从底稿里拿掉,改成 4.4px 小石块的拼片 `cupSprite`。内容是放大 1.3 倍的双耳杯:深色描边石块、金色杯身(右侧压暗)、亮杯口加深色杯内、两只耳、杯脚。每帧按 `armPose` 的位置和倾角整块叠在马赛克上。热气也改成两列沿正弦上行的白色方石(`steamTiles`),带灰浆边。底稿里只留杯子的白晕。
+ - 规律:小于 3 块石头宽的道具在固定布局里读不出来,应当做成随手移动的「嵌片」(emblema 式拼片)。
+- **脸读不出五官**:脸部石块从 6px 改为 5px。眼睛白色 13×7,深色 8×7,约 3 块深石加白;嘴唇改成红 `#a8282a`、8.5×6 的椭圆,约 2 块;眉毛 6px 深棕。1080p 缩到一半看,能读出眼睛和嘴。
+- 返修后:warm max 20.9ms,p90 17.4ms,mean 13.9ms,确定性通过。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/05_gothic.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/05_gothic.md"
new file mode 100644
index 0000000..0ed79e2
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/05_gothic.md"
@@ -0,0 +1,32 @@
+# 05_gothic · 1290 哥特泥金手抄本
+
+每帧 11–22ms(中位 12ms)。静态层+金箔掩膜在 `init()` 里一次性建好。
+
+## 管线
+1. 静态层 `goth_static`(缓存):羊皮纸 → 金箔 → 菱格压花 → 山墙、小尖塔、侧柱 → 尖拱窗和彩玻璃 → 桌子、宝座 → 拉丁文栏 → 页边小骑士。
+2. 金箔掩膜 `goth_mask`:对静态层逐像素算「金色度」 `clamp((r-b-70)/50)·clamp((g-b-30)/40)·clamp((r-140)/40)`,结果当 alpha。羊皮纸 (236,223,194) 的 r−b 只有 42,被排除;粉色带 b 值高,也被排除。**不用再画一遍金色形状来做遮罩**,凡是金色的地方都会自动被高光扫到:背景、首字母、金球、山墙顶饰。
+3. 每帧依次画:彩玻璃闪烁 → 斜向高光 → 高光经过处出现四角星 → 藤蔓花饰 → 蜗牛 → 跑过的老鼠 → 猫 → 少女 → 颗粒。
+
+## 金箔质感(规范要求的「细纹理+高光」)
+- 逐像素着色:`f = 0.52 + fbm(x·.0035)·0.42 + 横向打磨纹 noise(x·.004, y·.09)·0.5 + 左上受光 + 颗粒±0.05`,再在 goldLo #9c6a1a / gold #d9a63a / goldHi #f8de86 三个色之间插值。打磨纹的 y 频率是 x 的 20 倍以上,所以看起来是横向的金属拉丝。
+- 菱格:间距 46px,两族斜线(x+y、x−y 各为常数)。每条线画两遍:一遍暗线,一遍错开 1.2px 的亮线,看起来就是刻进金里的。菱心压 4 个点,左上亮、右下暗。
+- 每隔 118×125px 画一条极淡的方块接缝,模仿一片片贴上去的金箔。
+- 斜向高光:先在一张 920px 宽的 scratch 上画线性渐变带,斜率 K=0.45(“/” 方向)。用 `destination-in` 乘掩膜,再以 `lighter`、α0.62 叠回画面。**按匀速移动** `x = lerp(150,1650,(lt-0.08)/1.15)`。最初用 inOut 缓动,结果 0.9s 时高光已经扫出金区,少女身上看不到;改成匀速后,0.3s 扫到窗边,0.9s 正好扫过少女。光环、11 个固定点按 `|u − sweepX| < 70` 判定,在高光经过时出四角星闪光。
+
+## 母题动画(0.25–1.4s 窗口内都看得出)
+- 藤蔓:两条茎各约 120 个点,每个点加 `sin(t·2.1+i·.09)·2.5` 的摆动。每 3–5 个点挂一片三瓣常春藤叶(蓝/红/金轮换)或一颗带 3 根须的金球。叶片绕挂点按 `sin(t·3.1+k·1.7)·0.28` 摆。叶片缩放第一版用 0.85,太小太稀,改为 1.05–1.45 后,密度才接近原片。
+- 彩玻璃:26 个随机点,`sin(t·5+h·40) > 0.6` 时点亮一团白色径向光。
+- 猫抬起一只前爪,拎着老鼠尾巴,老鼠像钟摆一样摆 `0.32·sin(t·5.5)`,小腿乱蹬。蜗牛以 62px/s 向左爬,触角晃动;文字栏下的老鼠在 0.12–1.17s 内跑过 360px,腿每秒摆 40 弧度。
+- 少女按共享编舞端起金杯,杯沿有一颗四角星闪烁,杯上热气用细墨线。
+
+## 角色
+- 少女直接拿 `RIG.girl` 的 Path2D 自己按顺序画,**不调 `RIG.drawGirl`**,原因有两个:drawGirl 一定会画成带把手的马克杯;斗篷和光环要插在中间某几层之间。画的顺序:光环(以 headC 为中心偏 (16,−22),r=114,红圈加 36 颗压印点)→ 波浪长金发 → 红袍(金细竖条每 20px 一条,袍摆一道金边)→ 蓝斗篷(锚在 nape/back 上,带金边)→ 头 → 金圣杯。
+- 猫做成手抄本里「人脸猫」:脸部是一块奶油色椭圆,杏眼瞳孔挤在右侧斜睨少女,上眼皮加粗,眉毛挑起,嘴角下撇,两颊红晕。只用 `legs[0]`,另一条前腿用 `RIG.limb` 自己画成抬起的姿势。
+- 拉丁文正文用 UnifrakturMaguntia 44px。50px 会把 “cum poculo suo” 挤出画面右边。句首的 Cattus/Nemo/Mus 用朱红,这是中世纪的朱批做法。
+
+## 坑
+- scratchpad 和其它时代作者共用,`check.py` 被别人覆盖过一次。自检脚本要放进自己的子目录。
+- 运动差分图如果拿 lt=0 当基准,会被引擎前 20 帧的镜头冲击(1.03 缩放)污染。基准要取 lt≥0.35。
+
+## v2 微调
+藤蔓摆幅 ×2、叶摆 0.42;彩窗闪点 40 个;金箔高光 α0.85、高光带加宽。静止段帧差 1.10 → 1.32(原片 1.64)。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/06_renaissance.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/06_renaissance.md"
new file mode 100644
index 0000000..8405bcd
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/06_renaissance.md"
@@ -0,0 +1,41 @@
+# 06_renaissance · 1503 文艺复兴盛期(达芬奇式)
+
+每帧 16–37ms(中位 16ms)。
+
+## 管线
+1. 静态层 `ren_static`:先在原始 canvas 上画完房间,再整层用 `filter: blur(1.3px)` 画进缓存,相当于全画面做一遍 sfumato。房间内容如下:
+ - 墙:P.texture #43321f→#22180e,加窗光晕的径向渐变,顶部压暗。
+ - 窗:半圆拱窗,石框左侧受光,窗洞里是远景。
+ - 地砖:透视棋盘。按真投影算:`y = 420 + f·h/Z`,`x = 960 + f·X/Z`,f=1029、h=5.75,Z 从 16 往前每块砖 1.4。第一行落在 y=790,往下依次 825/868/922/989,和原片的行距对得上。地砖色是 #a88c64 和 #5c2418,再叠一层 soft-light 光池和一层四周压暗的径向渐变(以 760,960 为中心)。
+ - 方桌白布、梯背椅。
+2. 远景(空气透视):画三层山,越远越蓝越淡(#9fb4b8 → #7d9294),轮廓用 fbm 生成。之后是湖、河谷(由灰绿过渡到暖赭)、蜿蜒的银白河(宽度随远近从 3 增到 16px)、柏树和圆树、石桥。
+3. 每帧依次画:河面碎光(24 个光点顺流移动、闪烁)→ 飞鸟 → 扑翼机(三者都裁剪在窗洞内)→ 角色层 → 光柱和浮尘 → 罩层。
+4. 罩层 `ren_over`(缓存后一次 drawImage):
+ - 暗角:0.55 处 α0.3,边缘 α0.8。
+ - 黄釉:α0.07。
+ - 画布经纬:每 3px 一条线。
+ - 油彩笔触肌理:9000 笔,α0.022/0.028,线宽 5–10,方向随机。
+ - 龟裂纹:P.craquelure 取 α0.32;再用 `brightness(0) invert(1)` 把它变成白线,错开 1px、α0.16、`lighter` 叠一遍,模拟漆皮翘起的亮边。
+
+## 晕涂(sfumato)
+角色先画进离屏层 `renChars`,只处理 (320,180,1200,780) 这块区域。画回主画面分两遍:先 `blur(2.6px)` 全不透明,再叠一张 α0.38 的清晰层。这样边缘是软的,五官还认得出。角色不描线,全部靠渐变出体积:
+- 裙褶:亮褶 rgba(200,70,60,.3),暗褶 rgba(40,0,0,.45)。
+- 天鹅绒袖子:沿骨骼方向画一条 rgba(170,200,140,.45) 的光带。
+- 脸:左侧受光渐变,加眼窝阴影。
+
+## 母题动画
+- 扑翼机:0–1.35s 从 x=470 飞到 740,同时上下浮动、略有俯仰。两张蝙蝠翼的扇动按 `up = 0.5+0.5·sin(t·12+相位)`,翼尖在 −118 到 +24px 之间。远翼缩到 0.78 倍、颜色压暗、相位错开 0.5。翼的画法:前缘梁+6 根放射肋+扇贝形后缘膜,尾舵也在摆。第一版是平面「纸飞机」,认不出是达芬奇的扑翼机,重画成现在的肋骨扇形翼后才认得出。
+- 光柱:楔形一次性画进缓存并做 `blur(28px)`,每帧 screen 叠加。第一版每帧直接填多边形,两条硬边很假。浮尘是 46 颗粒子,沿光柱缓慢上浮并闪烁。
+- 少女按编舞用银杯啜饮,cup>0.7 时闭眼。猫一直眯眼微笑,尾巴在摆。
+
+## 坑
+- 第一版油彩肌理用 26000 笔、α0.05、方向跟着 noise 走,结果整面墙像梵高的漩涡(后印象派)。降到 9000 笔、α0.025、方向随机后才回到古典油画的感觉。
+- 猫身体的轮廓内侧压暗用了 26px、α0.45,奶白色身体看起来像个玻璃罩。改成 14px、α0.22,白色的胸部改用径向渐变把橘色毛「晕」进来,不留硬边界。
+- 地砖第一版太亮、对比太强,像矢量插画。必须压暗四周,只留下窗光照到的那块光池。
+
+## v2 返修(审片:偏静 0.20 vs 0.46;主角被模糊、窗外反而清晰,景深倒置)
+- 晕涂改为:模糊层 1.6px(原 2.6),清晰层 α0.82(原 0.38)。软边保留,五官和轮廓清楚了。
+- 扑翼机放大 1.6 倍,航程 440→790,俯仰幅度 ±0.07;飞鸟增加到 14 只、放大 1–1.8 倍。
+- 猫:头绕脖子歪蹭 ±0.16rad,眯眼松紧交替,尾巴 ×2.2,呼吸 ×3,look 左右转头。少女:发梢摆 ±11px,sip ×1.6。
+- 窗外云影掠过河谷;光柱亮度随「云过日」以 0.75±0.35 变化;浮尘 70 颗。
+- 静止段帧差:0.20(审片口径)/0.30(我量)→ 0.37。原片 0.43。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/08_impressionism.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/08_impressionism.md"
new file mode 100644
index 0000000..a2593e5
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/08_impressionism.md"
@@ -0,0 +1,34 @@
+# 08_impressionism · 1874 印象派(莫奈)
+
+每帧 65–76ms(中位 69ms)。主要开销是两遍全屏 P.strokes 加一遍角色笔触。
+
+## 管线(照 09_postimp 标杆)
+1. 平涂底稿 `impBase`,每帧重画,因为罂粟、云、花束、盆栽、窗帘都在动:
+ - 粉紫墙(#d8bede→#f0c8cc→#f2c4d4),右上叠一个 r=900 的暖黄阳光径向渐变。
+ - 窗外花园:天、树林、红顶屋、草地,70 朵罂粟(茎底不动,花头横摆 `sin(t·3.2+ph+x·.02)·(6+r·.6)`),撑阳伞的女子加孩子(向《罂粟田》致敬),花丛。
+ - 白窗框、淡紫窗帘、墙上的《日出·印象》、圆桌白紫桌布、花瓶、茶壶、右侧盆栽(整团叶子随 `sin(t·1.9)·8` 摆)。
+2. 笔触重画,**两遍**:
+ - 主画面:cell 11、len 20、width 7、outline 0、jitterCol 26,用 mask 排除窗景和墙上的小画。
+ - 窗景和《日出》:cell 6、len 11、width 4.5,只画 mask 范围内。
+ - 第一版只有一遍粗笔,窗外的房子、撑伞女人全被糊掉,《日出》也被斜笔刷成一片。分开两遍、《日出》改成横向水波笔后就都认得出了。
+ - 画布先铺 #f2e6ee,笔触缝隙里露出浅色底。
+3. 方向场:墙向右上斜(阳光区 −0.95 弧度,其余 −0.55,再加 ±0.55 噪声);地面接近水平;窗帘和桌布竖向;盆栽从盆口往外放射;窗里的天空横向。
+4. 区域色板 `P.swatch`(mixBase 0.3–0.45):墙 9 色粉紫黄;阳光墙 7 色奶黄;地面 7 色玫瑰橙紫;天空、草绿、窗帘淡紫、桌布蓝紫各一组。白窗框用 `col > (240,236,225)` 判定,混回白色,否则会被刷成墙色、窗框消失。罂粟的红返回 null,保留底稿原色。
+5. 角色:先用 `RIG.drawCat` / `RIG.drawGirl` 的 fill 模式平涂,再在角色层上用 `source-atop` 跑一遍 P.strokes(cell 7、len 13),只在角色内部出笔。白裙用白、淡紫、奶黄四色抽色。之后只补五官,用淡紫细线,印象派不勾轮廓。
+ - 草帽、蓝丝带、腰带飘带都在飘。
+ - `pal.line` 一定要设成发色金:drawGirl 的 locks、lid 这些部位即使 lw=0 也会用 pal.line 描线,默认的深蓝会在脸旁边留下黑道。猫同理,要设 `line`/`whisker`。
+
+## 母题动画
+- **阳光斑闪烁跳动**:26 个斑块(6 块在桌面,20 块在地面)。每块的强度是 `0.5+0.5·sin(t·sp+ph)·sin(t·sp·0.53+2ph)`,再用 clamp 截断,所以亮灭的节奏不规则。斑块缓慢横漂 ±10px。每块是 40 笔亮黄白短笔,按 8fps 换种子沸腾。第一版用 screen 叠加、α0.75,在粉底上几乎看不见,改成 source-over、α0.95 才够亮。
+- 墙上阳光区有 60 根斜向亮笔,按 6fps 换种子闪烁。
+- 猫毛闪光:60 个候选点,用 `isPointInPath` 限定在猫身和猫头的左半边(受光侧),按 `sin(t·7+h·30)` 明灭。
+- 全画 8fps 沸腾,热气白色。
+
+## 性能
+两遍全屏笔触加一遍角色笔触,约 69ms。转场时引擎要同时画前后两个时代,08→09 合计约 69+110ms,会超过 150ms,但只发生在转场的那十几帧里。
+
+## v2 返修(审片:整屏每 7–8 帧笔触重洗,帧差 18)
+- 笔触位置全部固定:`boil: 0`。**光固定种子不够**:P.strokes 的随机数是一条顺序流,palette 返回 null 时 jitter 会多吃 3 个数;而返回不返回 null 取决于底稿颜色,罂粟一摇、盆栽一摆,后面所有格子的笔就整体重洗。`stable(palette)` 包装成每格只吃 1 个数、永不返回 null。
+- 角色笔触不用 alphaMask(端杯一动跳过的格子就变,整层重洗),改成自写循环:每格随机数用 `U.hash(i,j)`。顺带每帧从 115ms 降回 72ms。
+- 「活」改由局部运动承担:光斑漂移 ±44px、明灭频率 5–11;罂粟摆幅加到 10+;云横走 45px/s;窗帘和盆栽摆动;窗外花草的笔按风向 ±0.22rad 转角;猫甩尾(×2.2)、扭头(look)。
+- 静止段帧差(480×270,屏蔽计数器,去掉段尾转场帧):v1 均值 4.14、峰值 20.5,是频闪;v2 均值 0.57、峰值 1.9。原片 0.77。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/09_postimp.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/09_postimp.md"
new file mode 100644
index 0000000..50d7c8d
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/09_postimp.md"
@@ -0,0 +1,17 @@
+# 09_postimp · 1889 梵高(标杆实现)
+
+文件:`scripts/engine/scenes/09_postimp.js`,每帧约 110ms(全幅三遍笔触)。其他时代照它的结构写。
+
+## 管线
+平涂底稿(墙/地/窗/床大面积)→ 流场笔触重画(区域色板)→ 道具层(桌椅花瓶画框吊灯,单独小笔触 source-atop)→ 环境线稿(深蓝 4.5px,8fps 沸腾)→ 角色(平涂 → 细笔触 source-atop → 补线与五官)→ 会动的高光(灯晕虚线环外扩、星星闪、热气)。
+
+## 关键参数
+- 方向场:墙竖向 −π/2 ± 0.22·noise;地板沿透视线指向消失点 (960,330);星空沿最近漩涡切线+0.3t 旋转;灯晕沿圆周;床头竖、床单近水平。
+- 三遍笔触:非墙非地 cell10 len22 w6.5;墙 cell14 len64 w8;地 cell12 len46 w8。描边 outline 0.8–0.9、混 40–45% 深蓝。8fps 换种子。
+- 区域色板(P.swatch,mixBase 0.3–0.45):墙 `#7f9be6 #5f7fd8 #a7bbf2 #6c6fd2 #8ad0e6 #c3cbf6 #4f6cc8 #9a8fe0`;星空 `#22339a #2f4fb8 #5c86dc #8fb6ee #1b2a78 #3c6bd0`;地板 `#c0573c #a8453a #d7774a #8e3b30 #5f8f6a #c96a52 #e08a5c`。
+- 猫身上 7 圈橘/浅橘螺旋纹(clip 到身体,0.6rad/s 转)——原片的「漩涡猫」。
+
+## 坑
+- 同一参数跑全图会糊成地毯:墙、地、其余必须分三遍。
+- 小物件被大笔触打碎:一律拆成道具层。
+- 只靠颜色抖动出来的是「同一个蓝的噪点」,梵高的感觉来自区域色板里十几种色相。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/10_nouveau.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/10_nouveau.md"
new file mode 100644
index 0000000..71ac0d6
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/10_nouveau.md"
@@ -0,0 +1,31 @@
+# 10_nouveau · 1896 新艺术运动(慕夏海报)
+
+文件:`scenes/10_nouveau.js`(约 300 行)。性能:warm 平均 29ms、最大 37ms,首帧(建缓存)≈80ms;确定性通过(同一 lt 两次逐像素相同);lt 0.35→0.65 运动差分 13.1% 像素。片中停留 0.70s(T09 有机波浪转场 0.24s,从 (1330,320) = 少女光环长出来)。
+
+## 管线
+1. **底版全缓存 `nv_bg`**:灰绿→米绿→桃色三段竖渐变(`#b9cba0`→`#cfd3a6`→`#ecc9a2`,只铺内框 34..1886×32..907);圆点花纹 = 环 r10 + 心点 r2.6,行距 54、列距 62,奇数行错 31(菱形交错),色 `rgba(120,140,100,.38)`;240×135 的 fbm 小图放大 α0.5 叠石版斑驳(比全屏算噪声快几百倍);马赛克地砖带 20×24 一格、9 色循环 `(k*7+(k>>2))%9` 打散;绿横幅 `#8fac80`;标题 `Marcellus-400` 76px、letterSpacing 12、先 7px 深棕描边再填奶白;金框 = 外 6px 金 `#c9a24a` + 内外两条 2px 深棕。
+2. **可变线宽路径 `ribbon(pts, w(q))`**:点列先 Catmull-Rom 加密(每段 4–10 点),每点沿法线两侧各偏 w/2,拼成闭合多边形 fill。所有「鞭线」都是它:茎、叶、铁艺桌腿、横幅卷草、头发、热气。`swellW(wmax)` = 两头尖中间粗(sin 包络),这就是慕夏线条的粗细呼吸。螺旋收尾 `spiral(cx,cy,r0,a0,turns,dir)`:半径线性收到 15%。
+3. **慕夏式「外轮廓粗、内线细」——整体剪影错位法**:角色(猫+少女+头发+披帛)全部画进离屏层 L(RIG 的 both 模式,lw 2 → 内线按部件顺序遮挡正确);再复制 L 用 `source-in` 染成深棕 `#4e3320`,在主画布按 (-1.5,-1.5)、(3.5,4.5)、(2,2.5) 三个偏移垫在 L 下面。结果:剪影外缘一圈 1.5px,右下侧 4–5px 厚边;内部线保持 2px。只多 3 次全屏 drawImage。
+4. 颗粒 `P.grain('nv', .05, 暖棕, .14)` 盖最上层,像石版印刷。
+
+## 母题动画(0.7s 内都要看得见)
+- **太阳升起**:按原片测量(509 帧 (583,400) → 530 帧 (576,299),≈-5px/帧)写成 `sy = 400 - (lt-0.267)·288`、`sx = 583 - (lt-0.267)·20`,lt=0 时在 477(藏在山后),lt=0.7 到 275。山丘色带画在太阳之后 = 天然遮挡「从山后升起」。
+- **铅条光芒转动**:14 根放射铅条从日心 r92→r420,角度 `+lt·0.9·0.25` 慢转并带 ±0.04 摆动;铅条随太阳移动,所以整窗玻璃分割都在变——这是窗里最显眼的动。
+- **彩色玻璃边带**:沿拱形内缘(直边+椭圆弧 rx219 ry130)每 17px 放一块 14×14 色片,按切线旋转,6 色循环。
+- **罂粟/百合摇摆**:花头水平位移 `sin(7.5t+φ)·13 + sin(3.1t+2φ)·5`,茎是 ribbon 的三控制点曲线只推上段;左右两丛相位相反;叶片 0.3 倍幅度。
+- **光环转动**:少女光环 R172,18 颗圆钉 `+0.9t` 转,内圈 32 片玫瑰窗花瓣 `-0.63t` 反转;猫光环 R106 八瓣橙花 `-1.1t` + 金色虚线环 lineDashOffset 走。
+- **头发**:先一大块发团(16 点 smooth,外缘按 `sin(6t+y·0.035)·9` 波动),再 7 绺背后卷发 + 2 绺肩前卷发:每绺 12 点 S 曲线 `sin(7.4q+φ-7t)·(6+20q)`(行波往下传)、末端接 1.2 圈螺旋、宽 14–18 → 2.5 递减,奶黄高光芯 + 深金细线。头顶外缘 6 个小卷做体积。所有点跟随 `G.A.headC` 的偏移(喝水仰头时一起动,越往下跟得越少)。
+- **S 形装饰热气**:3 条奶白 ribbon(宽 26/20/14)+ 1.8px 棕描边 + 中线,`sin(4q+φ-6t)·(18+70q)` 行波,横向间距随高度 ×(1+2.6q) 散开,末端 34px 螺旋;整体 `lean = -90 - 160·cup` 往左倒——**踩坑**:choreo 把杯子举到嘴边,热气如果竖直升会横穿少女的脸,必须随 cup 往窗那边倒。
+- choreo:端杯、仰头、眨眼、甩尾、呼吸全用 RIG;碟子留在桌上(杯子被端走后桌面不空)。
+
+## 色板
+线 `#4e3320`;金 `#c9a24a`/`#9c7a2e`;奶白 `#f6eedb`;皮肤 `#f6dcc4`;金发 `#e8bf55`/高光 `#f6dc8a`/暗 `#b9862a`;裙 `#f4ecda`;粉披帛 `#e6aaa5`/褶 `#d48e8c`;罂粟 `#d9706a`/`#b4504b`、花心 `#3f6a4a`+金点;百合 `#f7f2e6`;铁艺 `#3d7763`;猫 `#e39a4c`/`#fbf3e3`/纹 `#c0672c`、眼 `#e6c040`;光环粉 `#ebb8b2`、青环 `#5f9a8a`、猫光环红 `#b8473a`。
+
+## 踩坑
+- **`drawGirl(mode:'line')` 叠在最上层会把被遮住的部件轮廓(远侧袖子)画穿躯干**(09 标杆也有)。改成在离屏层里用 both 模式按部件顺序画线,再整体做粗外轮廓。
+- 头发最初是 7 条 34px 宽的长带,像香肠/面条;慕夏头发 = 一块发团打底 + 细绺 S 卷 + 螺旋收尾,宽度 ≤18。
+- 自检差分别拿 lt<0.33 的帧:引擎在转场开始后 20 帧内有 1.03 倍「拍点冲击」缩放,差分会全屏发红。
+
+## 仍可改进
+- 猫仍是 RIG 的坐姿(白色直腿),设定稿是趴卧的毛茸茸橘猫;慕夏味主要靠光环和粗细线撑。
+- 标题用 Marcellus,设定稿是更圆的手绘新艺术字形;可以手写一套字母路径。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/11_cubism.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/11_cubism.md"
new file mode 100644
index 0000000..40a647b
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/11_cubism.md"
@@ -0,0 +1,30 @@
+# 11_cubism · 1912 分析立体主义(毕加索/布拉克)
+
+文件:`scenes/11_cubism.js`(约 280 行)。性能:warm 平均 13ms、最大 19ms,首帧(建缓存)≈100ms;确定性通过;lt 0.34→0.46 运动差分 6.9% 像素。片中停留 0.47s(T10 碎片转场 0.24s)。
+
+## 管线
+1. **底版全缓存 `cb_bg`——「透明叠面」**:核心函数 `plane(g, pts, col, alpha, r)`:每块面一条线性渐变,起点取第 0 顶点、终点随机取另一顶点,三个色标 = 混 25% 米白 → 原色 → 混 40% 深棕,alpha 0.18–0.7。叠法:18 块手排大面(照原片构图位置)+ 桌下 9 片放射扇面(自 (1000,1090) 发出,亮暗交替 α0.3)+ 70 片随机 3/4 边形(避开右上年份区)。多层半透明渐变叠起来就出现分析立体主义那种「透明、互相穿插、每面一亮一暗」的空间。
+ - 肌理面:4 块点画(9px 菱形格 r1.6)、4 块排线(7px 间距斜线)、左缘一页横线纸。
+ - 布拉克短划砂纹:9000 个 3–8×1.5px 小划,55% 米白 α0.28 / 45% 深棕 α0.16——原片那种「砖纹」质感就靠它。
+ - 46 条贯穿细直线(1.3px α0.55)= passage。
+ - 仿木纹 `wood()`:沿长边画 S/6 条波浪线,过节疤位置加高斯鼓包 `14·exp(-(u-k)²/0.01)`,节疤 4 圈椭圆。用于桌面和右侧木板(布拉克的梳纹假木)。藤编椅背 = 10px 菱形孔点 + 双向斜线。
+2. **窗格碎面滑动**:窗景单独缓存成 560×540 大图(55 片蓝灰切面 + 3 条斜光束 + 埃菲尔铁塔 + 海鸥弧),四格各自 clip 后以不同偏移取景 `dx = sin(9lt+1.7i)·18 + 10fps 抖动 ±3`、`dy = cos(7lt+i)·8`——同一窗景在四格里错位 = 多视角拼合;每格另有一片半透明三角以 260px/s 横向滑过。
+3. **CAFÉ 模版字跳动换位**:`AlfaSlabOne-400` 104px 画进离屏小层,12fps 卡点(`st=floor(lt·12)`),顺序表 `CAFÉ/ACFÉ/CAÉF/CFAÉ` 轮换,每步每字 y ±13、旋转 ±0.11rad(hash 取);然后 `destination-out` 切出横竖断口 = 模版字(断口透出底下的叠面,比画纸色条真实)。
+4. **报纸 JOU**:缓存 300×190 小图(LibreBaskerville-700 84px「JOU」+ 12px 标题「LA BATAILLE / S'EST ENGAGÉ UN CHAT」+ 三栏灰色假字),每帧以 8fps 微颤(旋转 ±0.0125rad、x ±1.5px),右上折角按 `sin(20lt)` 翻。
+5. **角色 = 自写切面器 `facetize`**:RIG 平涂(fill 模式,无线)进离屏层 → 读回该包围盒像素 → 抖动三角网(每格随机选对角线)→ 每个三角在质心取色,`×(0.8+0.38·rand)` 明暗、再做一条从顶点 0 到顶点 2 的亮→暗渐变 → **三角不裁剪**直接画回去(质心 alpha<120 的跳过)。不裁剪是关键:剪影边缘被切成锯齿直边,有的三角还伸出轮廓外——就是立体派「平面溢出轮廓」的感觉。
+ - 少女 cell 58(大面),发区再用 cell 26 细切一遍、只切「像金发的颜色」(`only: R>150 && B<130 && R-B>60`),猫 cell 26。
+ - 顶点每 8fps 抖 ±8% cell、16–35% 的三角明暗跳 ±12%(boil)→ 角色在「微动」,原片 548–562 帧猫区域就是这样。
+6. **切完再补毕加索式的结构**:脸重铺两块肤色明暗面(切面会把金发色带进脸)+ 前半张脸蓝灰面 α0.82 + 正面杏眼(侧脸上画正面眼)+ 螺旋耳 + 红唇;白领两块明暗三角 + 三颗扣;裙摆从腰部 8 条放射切线 + 亮暗交替楔面;外轮廓用直线段 `segs()`,每段两端各外伸 10–16px(线画出界)。猫:六边形直线头轮廓、`bodyPts` 直线身轮廓、黄色菱形眼 + 竖瞳、侧面三角鼻。
+7. 最上层 5 片 α0.2 的叠面压在人和猫身上并以 `sin(6lt)·8` 错动——把角色「嵌」进空间,不像贴在背景上。
+
+## 色板
+纸 `#d6c8ac`、米白 `#ece3cf`、赭 `#b8975f`、棕 `#6e5538`、深棕 `#3a2c1e`、灰 `#a8a395`、蓝灰 `#8e9eab`、暗灰 `#5a5852`;窗景 `#c9d3da/#8fa3b3/#e4e6e2/#6f8597/#b4c1cb/#5f7385`;裙 `#6a7a8b`、袖 `#3c4857`(必须比裙深,否则端杯的手臂整个融进裙子切面里)、皮肤 `#e2cfae`、金发 `#c9a256`;猫 `#c8773a`/`#e8dfc9`。
+
+## 踩坑(重要)
+- **不确定性:第一帧和之后不一样。** 两个原因叠加,都只在第一帧出现:① 要 `getImageData` 的离屏层第一次画时走 GPU,读回后 Chrome 把它转成 CPU 光栅,抗锯齿不同 → 质心取色不同 → 三角颜色不同;② 更主要的:离屏层的 context 状态(facetize 里设的 `lineJoin='round'`、segs 的 `lineCap='round'`)会残留到下一帧,第一帧用的是默认 miter/butt。修法:自建层 `getContext('2d',{willReadFrequently:true})`,**每帧开头用 `g.reset()`(清像素 + 清状态)而不是 `clearRect`**。用 hash 对比「同一 lt 连渲三次」才查出来。
+- 切面 cell 34 时满身小三角,像 low-poly 3D 模型而不是立体派;58 才有「大块明暗面」。
+- 第二遍发区细切一开始用圆形 clip,把半张脸也切成了金色——加了按颜色过滤的 `only`。
+
+## 仍可改进
+- 少女整体轮廓仍是 RIG 的写实曲线,切面只改了边缘;更彻底的做法是把肩、肘、膝都换成折线骨架再切。
+- 原片色调更暗、明暗对比更强(大块深褐面更多),我这版偏亮。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/12_bauhaus.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/12_bauhaus.md"
new file mode 100644
index 0000000..cbc2298
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/12_bauhaus.md"
@@ -0,0 +1,30 @@
+# 12_bauhaus · 1923 包豪斯海报
+
+文件:`scenes/12_bauhaus.js`(约 210 行)。性能:warm 平均 5ms、最大 9.5ms,首帧≈85ms;确定性通过;lt 0.34→0.46 运动差分 4.9% 像素(黑杆、格窗、同心弧、猫、球、人偶都在动)。片中停留 0.47s(T11 蓝方块/红圆/黄三角/圆孔转场 0.20s,原点 (1330,590) ≈ 红圆圆心)。
+
+## 管线
+1. **底版全缓存 `bh_bg`**:米白旧纸 `#ebe3cf` + 320×180 fbm 小图放大 α0.5(做旧斑驳)+ 贯穿细斜线 (40,170)→(1900,840)(压在窗后)+ 左上黑横条 (60,61,256,13)、红竖条 (292,105,24,468) + 竖排 bauhaus(`Poppins-800` 210px,`rotate(-π/2)` 后水平缩放到正好 820px 长,原点 (262,1000) 自下而上读)+ 灰小方块 + 地线 (345,898)-(1860,915) + 黄直角三角 + katze(Poppins-800 150px,红 `#d3262b`)+ 右下两行 Poppins-600 31px + 黑面桌/镀铬管腿(三色线性渐变)+ 布劳耶悬臂椅(同一路径描 15px 深灰 / 10px 镀铬 / 3px 高光偏移 2px)+ 两层颗粒(暗点 0.02 密度 α0.35,旧印刷黑斑)。
+2. 红圆单独缓存 520²:底色 + `source-atop` 叠 fbm 浅色斑 α0.55,模仿丝网/石版的不匀墨。
+3. 角色、构成全是几何体:没有任何曲线描边,只有圆、方、三角、粗杆。
+
+## 母题动画
+- **斜长黑杆像指针转**:按原片逐帧量的角度(575–579 帧 28°,581 帧 33°,583 帧 37°,585 帧 42°,587 帧 46°,591 帧 49.5°)写成 `deg = 28 + 21.5·easeOut(clamp((lt-0.26)/0.22))`。转轴 = 毂心 (1125,195)(原片对比 576/590 帧确认:毂不动、下端扫下来),杆 27px 从 -432 到 +150,细平行线偏 30px,红短杆偏 -30px,毂内弧跟着转。
+- **蒙德里安格窗轮换**:4×4 格(内框 366..794 × 126..561,格 100×101、缝 9.5),6 个格子参与轮换,13fps 卡点 `step=floor(lt·13)`,每格相位不同、`(step+2·sw)%9 < 6` 才换(不是每拍都换,节奏不机械);轮换色只用红黄蓝米浅蓝灰。图样格(9px 方格纸)、四分之一圆格保留。
+- **同心弧**:红圆右侧 6 条弧,起点相位 `sin(9lt-0.7i)·0.05` 波动、半径 `±3` 呼吸、弧长在 0.4s 内从 55% 扫到 100%——像声波往外推。
+- **杯上热气**:一根 2.2px 正弦细线(26 个周期/170px、`-18t` 行波),线性渐变淡出。
+- **猫拨球滚一下**:右前爪 `tap = sin(clamp((lt-0.05)/0.16)·π)` 往前伸 36px 再收;蓝球 r31 在 `lt 0.13→0.47` 以 easeOut 从 x712 滚到 816,**转角 = 位移/半径**(白直径线+白点看得出在滚),滚动中身后两条速度线。尾巴 = 26px 粗橙弧 + 同宽虚线深橙条纹,角度跟 `choreo.tail·0.5`。
+
+## 角色的几何化(锚点全来自 RIG)
+- **施莱默人偶**:头 = 圆 r70(`G.A.headC + (14,-18)`),金色几何发片 = 后半个头的扇形(-1.95→1.15rad)+ 额前三角 + 发髻圆 r34 + 背后半圆发片(`G.A.back`);脸 = 黑竖条眼(眨眼变横条)、红方腮、短黑口。头部整组绕 `G.A.neck` 按 `G.tilt` 转(喝时仰头)。躯干 = 蓝梯形 + 后半黑梯形(随 breathe 起伏);裙 = 黑扇面 r178 + 蓝梯形;四肢 = 粗黑圆头杆,关节 = 米白圆盘 + 5px 黑圈 + 黑心点。近侧手臂直接用 `G.A.shoulder/elbow/hand`(RIG 的 IK 端杯),远侧手臂平放桌上(复现原片那只伸向桌面的手)。
+- **猫**:身体圆 r100(`K.box` 推算的 (536,805),随 breathe 缩放)+ 左侧 4 条深橙横条(clip 在圆里)+ 右下米白扇面(橙白块面);头 = 104 方块(`K.headC + (14,48)`,随尾巴相位微转 ±0.08rad)+ 黄三角耳 + 米白下半脸 + 深橙额带;眼 = 白圆 + 黑竖条瞳。
+
+## 色板
+纸 `#ebe3cf`;黑 `#161514`;红 `#d3262b`;蓝 `#2a58b4`;黄 `#efc12f`;浅蓝 `#b9cee0`/`#a6c0da`;灰 `#c6c3bb`;米 `#f2ecdf`;橙 `#ee8a2a`/`#c25a14`;镀铬 `#c9c9c6`。
+
+## 踩坑
+- 第一版格子按 107px 算,右侧溢出黑框 16px——格窗尺寸要从「内框宽 - 3 缝」反推。
+- 轮换色里放了黑色,换到黑格时整窗突然变重、像坏格子,删掉。
+- 人偶嘴原本照原片画成伸出头外的长黑杠,放在少女脸上像叼烟,改成头内短横。
+
+## 仍可改进
+- 猫头/身体的位置相对 RIG 骨架做了下移(为了方头压在圆身上),转场时与前后时代的猫头位置差约 50px。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/13_pop.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/13_pop.md"
new file mode 100644
index 0000000..a940e85
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/13_pop.md"
@@ -0,0 +1,29 @@
+# 13_pop · 1962 波普(利希滕斯坦漫画格+沃霍尔四宫格)
+
+文件:`scenes/13_pop.js`(约 230 行)。性能:warm 平均 6ms、最大 9ms,首帧≈45ms;确定性通过;lt 0.34→0.46 运动差分 11.6% 像素。片中停留 0.47s(T12 黄闪电网点化转场 0.16s)。
+
+## 管线
+1. **本戴点 = `createPattern`,零成本**:一个 pitch×pitch 的小 tile 画 4 角 + 中心 5 个圆 = 45° 网格(对角间距 pitch/√2)。墙:pitch 24、r5.6、蓝 `#2f5cc8` 底白(对角 17px,与原片 FFT 量的 17px 周期一致);皮肤:pitch 13、r3.3、红 `#e2483c` 底肤色 `#fae0cc`;黄地:pitch 14 r2.2 α0.18 隐约印刷点。皮肤用 `fillStyle = pattern; fill(path)`,比 `PAINT.halftone`(逐点 getImageData)快两个数量级,而且图案对齐屏幕坐标、不会随角色移动「游泳」。
+2. **底版全缓存 `pop_bg`**:漫画格外框 6px 黑;白踢脚线 754–792(上下 6px 黑线);黄地 796→990/1003(地平线略斜);红带;MEANWHILE...(`Bangers-400` 46px,黄底黑框 5px);沃霍尔白画框+窗台蓝线;蓝椅;纸面颗粒。
+3. **所有角色都是「粗黑描边 5px + 平涂」**,`ink(c, path, fill, lw)` 一个函数到底;高光用白色粗短线;阴影用 `hatch()`:椭圆 clip 内画 10px 间距、3.5px 宽的黑斜线。
+
+## 母题动画
+- **沃霍尔四格换配色**:4 套配色(底/脸/下半脸/眼影/口红),`step = floor(lt·11)`(≈每 5.5 帧换一次,原片 601、605/606、612 帧换),格 i 用第 `(i+step)%4` 套。猫脸 = RIG.smooth 的 9 点头型 + 下半脸椭圆 + 右侧黑块(丝网错版的黑影)+ 眼影/口红/鼻/胡须;右上格两道白色玻璃反光。
+- **思考泡泡三点依次闪**:原片「点1 612–615、点2 614–617、点3 616–618 帧」→ 每 12 帧一循环,点 k 在 `((f-2k) mod 12) < 4` 时亮(r20、上跳 6px),否则 r12。泡泡 = 10 个圆先统一描 11px 黑再统一填白(并集轮廓的最省写法)。
+- **WIGGLE WIGGLE 爆炸框抖**:30fps 卡点 hash 抖动 ±8px/±6px/±0.03rad;外层白爆炸(14 尖,半径 128/178 带随机)+ 内层黄爆炸 + 两行 `Bangers-400` 82px 红字(12px 黑描边 + 4px 黑投影);外围 10 根黑三角动作线长度 `0.85+0.25·sin(40lt+2i)` 脉动。
+- **猫扭屁股准备扑**:用 RIG.cat 的锚点做时代化变形——趴低:身体用 10 点自定轮廓(以 `K.box` 为原点),头 `K.headC + (22,104)` 压低贴身,前爪白椭圆往前伸;扭:`wig = sin(lt·2π·6)·16`(6Hz,0.47s 里 ~3 次),点的权重 `clamp((560-x)/140)` → 越靠屁股位移越大,并同时上翘 `|wig|·0.6`;条纹、尾巴跟同一变形走;屁股旁三道弧形动作线跟着 wig 移动。
+- **少女端杯**:RIG IK 端杯;杯 = 白杯 + 蓝斜条纹 + 咖啡;热气两条 14Hz 抖动的黑波浪线。
+
+## 少女(利希滕斯坦)
+- 金色大波浪:发团(19 点 smooth,后缘 `sin(2.1i+4t)·14` 鼓包)+ 7 个卷团圆(r30–48,沿后缘排),**先全部描 10px 黑、再全部填黄 = 并集轮廓**;每个卷团里一道 4.5px 黑 C 形弧 + 一道深金 `#d9a514` 弧 = 利希滕斯坦那种雕塑感卷发;5 条黑色 S 发丝、2 道白高光。
+- 皮肤(脸、颈、手、腿)全部红本戴点;红裙(截到膝,裙摆 clip 用曲线不是矩形)+ 白高光条;两条点点腿 + 红高跟(7 点多边形);大眼(白眼 12×8.5、蓝虹膜 r7、高光点)+ 3 根粗睫毛 + 眉毛上移 5px;红唇放大。
+
+## 色板
+黑 `#141414`;纸 `#f3eedb`;蓝 `#2f5cc8`;黄 `#f7d52c`;红 `#d8232a`/`#a8161c`;白 `#fbf8ee`;皮 `#fae0cc` + 点 `#e2483c`;金发 `#f8d62c`/`#d9a514`;猫 `#f39a2c`/`#c4561a`;沃霍尔底色 `#9ccf3a/#e0359a/#2fc0b0/#f08a2a`。
+
+## 踩坑
+- 猫头按 RIG 原位置画会悬在趴低的身体上方(空一截),趴姿下头要下移 ~100px 压进身体。
+- 头发第一版只是一整片带轻微波浪的黄色,远看像披了块布;利希滕斯坦的金发辨识度来自「卷团 + 黑色 C 弧」。
+
+## 仍可改进
+- 原片少女有泪珠和白领子(经典利希滕斯坦哭泣女孩),设定稿去掉了,我也没加;想更「漫画」可以加一个对白框。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/14_8bit.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/14_8bit.md"
new file mode 100644
index 0000000..042c111
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/14_8bit.md"
@@ -0,0 +1,27 @@
+# 14_8bit · 1985 8-bit 像素游戏
+
+## 管线
+1. **整幅在 240×135 低分辨率画布上画**(1 低像素 = 8 屏幕像素,原片实测像素块就是 8px),最后 `imageSmoothingEnabled=false` 一次性 `drawImage` 放大 8 倍。
+2. **背景逐像素 `fillRect`**(缓存 `8b_bg`):十字点纹墙=6px 网格、隔行错 3px 的 3×3 十字;木地板条 y=106–113,每 24px 一道黑缝;砖块 16×6+1px 缝,隔行错 8,上沿和左沿一行米色高光(`#fbe2a6`)。窗里天空用 3 档蓝(`#0856ef / #47c4f8 / #aae9fb`),交界 ±0.05 的带子做 `(x+y)%2` 棋盘抖动——这是 NES 做渐变的唯一办法。
+3. **角色=RIG 路径缩到低分辨率填色 → spriteize**:每个部件单独一层(远侧手臂 / 身体腿 / 头发 / 脸 / 刘海 / 近侧手臂;猫身 / 猫头),每层:
+ - `getImageData` → alpha < 110 直接透明(去抗锯齿)→ 其余量化到 14 色角色调色板(最近色);
+ - 外轮廓描 1px 黑边(透明像素的 4 邻域里有不透明像素就涂黑)。
+ **分层描边是关键**:只描一次整体外轮廓时,头发/脸/手臂糊成一块;每个部件单独描边才有 NES 精灵那种内轮廓。
+4. **五官全部逐像素点**(眼 1×2 黑+眉,猫眼 2×2 黑+左上 1 白高光,粉鼻 1px,腮红 2×1),用 RIG 锚点 `/8` 取整定位。
+5. **马克杯不用 RIG.drawCup**:AA 路径缩到 6px 宽会糊,直接在低分辨率上画 6×5 白杯+两道红条+3px 把手,跟着 `G.cup` 走。
+6. **HUD 在全分辨率画**:`PressStart2P` 48px(字体 1 像素 = 6 屏幕像素,64px 太宽会让 WORLD 1-1 撞上苹果图标),8px 黑投影;猫头/心/苹果图标是字符串位图,每格 8×8。
+
+## 牛仔裤
+RIG.girl 是长裙,8-bit 版用两段 `RIG.taper`(髋 `G.hipSeat`→膝 (1222,724)→踝 (1214,872),宽 92/76/56)画蓝裤,远侧腿深一档 `#0838a8` 错后 26px;白球鞋+一道红条。
+
+## 小循环(片中只停约 0.23s ≈ 11 可见帧,全部做成步进动画)
+- 猫尾:15fps 四姿态循环 `[-0.55, 0, 0.55, 0]`(RIG.cat 的 tail 参数),像素动画的「几张图交替」。
+- HUD 心闪:lt 0.16–0.23(≈ 630 帧)每 2 帧一换:满心变白、空心变满红。
+- 盆栽抖:同一窗口里叶子整像素 `[0,1,0,-1]` 偏移。
+- 问号块顶出金币:lt 0.06–0.22 半正弦上 9px 再落回。
+- 窗外云 2 帧左移 1px;像素热气三列 1×2 点、30fps 每帧上移 1px、6px 循环。
+
+## 踩到的坑
+- RIG 猫头顶到 y≈535,会压住窗台(窗到 y=590)。这是共用骨架的位置,没挪;8-bit 黑描边让重叠更显眼,但转场依赖标准构图,保留。
+- `spriteize` 读的是非预乘 RGBA,别再除 alpha。
+- 性能:热帧 2.5–6ms,冷启动 11ms。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/15_raytrace.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/15_raytrace.md"
new file mode 100644
index 0000000..2a1638c
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/15_raytrace.md"
@@ -0,0 +1,32 @@
+# 15_raytrace · 1993 早期光线追踪 CGI
+
+不用 3D 引擎,靠 2D Canvas 的「着色约定」假装是渲染器出图。
+
+## 塑料着色(每个部件都过一遍)
+`plastic(c, path, base, hx, hy, R)`:
+1. 底色填充;
+2. 以高光点 (hx,hy) 为心、半径 R 的径向渐变:0→白 .55,0.28→白 .06,0.62→透明,1→深紫 `rgba(10,0,30,.42)`(边缘压暗=体积);
+3. 环境反光:`lighter` 叠一圈 `rgba(70,150,150,.28)` 的描边,宽 0.18R,向左偏 0.04R——墙是青绿色,反光就是青绿色;
+4. 一颗硬边白色椭圆镜面高光(0.16R × 0.09R,透明度 .85)。这一笔最像 90 年代 Phong。
+
+肢体用 `cyl()`:渐变横跨肢体法线方向(暗 .25 → 白 .5 窄带在 22% 处 → 暗 .45),再沿 20%–75% 画一道白色细高光线。
+少女用 RIG.girl 的 Path2D(长发),裙子换成蓝色塑料圆柱腿+膝盖球关节,肩膀加球关节——就是「玩具人偶」的关节感。
+RIG 的猫身是折线,塑料感会露出棱角:先 `RIG.smooth(K.bodyPts)` 再着色。虎斑用 `filter: blur(2px)` 画成「印在塑料下面」的软条纹。
+
+## 场景
+- 墙:径向渐变 `#7dbcb9 → #64a6a6 → #3f8285`,光源在窗的位置;窗的投影 `blur(10px)` 偏右下。
+- 窗外:粉紫渐变天(`#a24cc4 → #df62ae → #f5a08a → #f8c070`),两层山,山体上叠 28×26 的粉色线框网格(早期 CG 的 wireframe 地形),雪顶是锯齿三角。
+- **地面**:逐像素透视棋盘,消失点 (960,480),`X=(x-960)/dy, Z=1/dy`,格子 TX=0.27、TZ=0.00029,2×2 超采样抗锯齿,近墙 140px 内加 35% 雾。缓存,冷启动整场 53ms。
+- **反射**:物体层(椅/桌/少女/猫)画在离屏层,`translate(0, 2*906); scale(1,-1)` 镜像、`globalAlpha .34` 画进地面裁剪区;道具各按自己的接地线镜像(锥 780、紫环 846、铬球 800),并**先画到独立层再整体半透明**——否则紫环的 140 颗小球各自 .34 叠加会变成不透明。
+- 玻璃桌:半透明绿椭圆+厚边+白描边,一条斜向反光每秒滑 260px。
+
+## 小循环(0.23s 内要看得见)
+- 紫环:140 颗球沿圆环排布,绕竖轴以 7 rad/s 自转、倾斜 0.35,按深度排序画(先一层暗紫底让球连成管,再逐颗径向高光)。0.23s 转 1.6 rad,从正面转到侧面,非常明显。
+- 铬球:每帧逐像素环境映射(反射向量向下→棋盘,向上→粉紫天+一条窗光),棋盘 u 坐标随 `t*4.5` 平移=在转;菲涅尔边缘提亮。直径 104px,每帧 <2ms。
+- 镜头光晕(`lighter`):日芯辉光 170px 以 23 rad/s 脉动 ±8%;12 道星芒以 1.6 rad/s 旋转;水平长条光 960px;5 个鬼影(圆+六边形)沿「太阳→画面中心」直线排布、随 `sin(t*5)*0.03` 滑动。
+- 猫眼绿光:`lighter` 径向渐变半径 46px,以 18 rad/s 脉动 ±25%。
+- 端杯(choreo.cup)、甩尾、眨眼、热气照常。
+
+## 坑
+- 转场 wireframe 用新画面第一次出现时的帧算边缘并缓存(`once('edges')`),所以 lt≈0 那一帧要完整——别在 lt=0 留空白或淡入。
+- 性能:热帧 23ms,冷启动 53ms。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/16_2026.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/16_2026.md"
new file mode 100644
index 0000000..e092f56
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/16_2026.md"
@@ -0,0 +1,55 @@
+# 16_2026 · 2026 扁平矢量插画 + 全片笑点收尾
+
+所有表演用**全片帧号 `F = t*60`** 写,关键数字逐条照抄 `../拆解/分镜表.md` §4,方便和原片逐帧对表。
+对照接触表(左原片|右复刻):`../渲染/16_2026/cmp_E1…E4_*.jpg`,片段 `clip_2026.mp4`(10.8–15.06s)。
+
+## 画风(Dribbble 扁平+颗粒)
+- 纯色块、无描边;体块只靠「同色系深一档的色块」分(毛衣亮面斜块 `#f08b7d`、猫大腿 `#f3ad4c`+一道深色弧边)。
+- **颗粒点彩 `stipple()`**:在形状里撒 2px 方点,密度是位置函数——粉圆 `0.12 + 0.75·clamp((y-cy+120)/420)`(越往下越密),淡紫块往右下密,太阳往右下密。静态部分全进缓存 `fl_bg`。
+- 角色层画完后用一张静态颗粒纹理 `source-atop` 叠上(5% 暗点 α70、3.5% 亮点 α90),颗粒只落在角色身上。
+- 光锥:26000 个点、宽度随 y 线性 56→150、透明度随 y 衰减、靠中心更密,缓存成 340×420 贴图,跟吊灯一起绕 (1010,0) 摆。
+
+## 少女(RIG 基础上自写姿势)
+- 躯干/颈锚点:`RIG.girl({s:1.12})`;头部再调一次 `RIG.girl({s:1.344, dy:43.7})`——相当于头部围绕颈点放大 1.2 倍,扁平插画的大头比例。脸、刘海、后发、丸子、眼/唇/耳锚点都取自它。
+- 手臂:`RIG.ik2(肩, 目标, 150, 140, -1)`,三套目标点按进度混合:打字(两手在键盘上以 22 rad/s 交替起落 7px)→ 摸猫(688–704,近手在猫背上画小圆)→ 惊呼(791–798,`ease.outBack` 举到下巴前,手指张开)。
+- 表情:闭眼弧+上扬嘴(<686)→ 圆点眼+高光、小 o 嘴(686 起,o 用 outBack 弹出)→ 大眼+大张嘴+舌头(791 起)→ 838 帧后改成挤眼「<」(原片终帧也是闭眼)。
+- 紧张线:3 道,从头顶前上方放射,长度 outBack 弹出;颜色 793 淡粉 → 796 全红(RGB 插值);830–888 每 2 帧随机抖 ±2.5px,头部同步抖 ±2px。
+- 裤腿/袜/鞋自画(RIG 是长裙)。
+
+## 猫(姿势库 + 插值)
+每个姿势是一组局部关键点(朝右、原点=质心):身体 10 点、白胸 6 点、大腿椭圆、背纹 3 段、头、两前腿、后腿、尾巴 4 个贝塞尔点、gy(脚底到质心)。
+姿势:`SIT_F`(地上坐,从原片 10.95s 量)、`SIT_T`(桌上坐,原片朝左实测后镜像成朝右存)、`LEAP`(水平拉长)、`LAND`(前爪向下)。`mixPose` 逐数值 lerp。
+变换:`translate(质心) → [绕脚底 或 绕质心] rotate → scale(dir·sx, sy)`,挤压拉伸都绕脚底,所以蹲下时脚不离地。
+
+| 帧 | 表演 | 做法 |
+|---|---|---|
+| 657–661 | 预备下蹲 | sy 1→0.86、sx 1→1.07,头低 8px |
+| 661–664 | 蹬地 | 切到「绕质心」、rot→-0.75、sy→1.12(拉长),姿势混 45% LEAP |
+| 662–684 | 弧线 | 质心用分镜表 12 个实测点 Catmull-Rom;rot = 切线角×0.8,679 起逐渐放平;670–676 sx→1.12 / sy→0.9 |
+| 664–672 | 起跳烟尘 | 4 团米色圆往外扩、变淡 |
+| 684–690 | 落桌挤压 | 混 LAND,sy 0.86→0.70,sx→1.18,脚底钉在 y=628(笔记本面) |
+| 690 | 翻面 | 压到最扁的那一帧 dir 从 +1 跳 -1(限帧动画的 snap,比 2–3 帧的「纸片翻转」干净) |
+| 690–698 | 坐起 | 混到 SIT_T;sy 0.96→1.07(694 过冲)→1.0 |
+| 685–689 | 笔记本盖被压上 | 屏幕绕铰链转 -1.91→0.02 rad;「•••」输入气泡缩没 |
+| 724–812 | 盯杯子 | 身体绕脚底前倾 0.08 rad,瞳孔左移 4px |
+| 744/766/786 | 三次拍杯 | 每次:预备 7 帧(爪抬到胸前)→ 击出 4 帧 → 停 4 帧 → 收 8 帧;前倾量 = 0.1+0.28·clamp(肩到杯沿距离),越远越趴 |
+| 835– | 得意 | 闭眼弧+大腮红;856–875、886–892 换 ∩∩ 开心眼 |
+
+**拍杯对准的关键**:先按世界距离算前倾、施加前倾变换,再用 `c.getTransform().invertSelf().transformPoint(杯沿)` 把杯子右沿换回局部坐标当爪子目标。直接按未前倾的坐标算,前倾 0.38 rad 后爪子会往下偏 60px 戳进桌面。
+
+## 杯子与碎裂
+- 杯子 x:分镜表 16 个实测点线性插值(744:981 … 796:801);790–796 开始外倾 -0.12。
+- 坠落 796–815:9 个实测中心点 Catmull-Rom(实测重力≈1.75px/帧²),旋转 `-0.12 - 2.3·q^1.3`;身后 6 颗咖啡滴取杯子过去 1.3 帧间隔的位置、越早越小。
+- 815 落地:7 道冲击放射线 8 帧淡出;两块大碎片用分镜表三点(818/824/834)拉格朗日抛物线,834 落地后停住;9 颗小碎屑抛物线、各自落地高度 893–911 停住;咖啡渍宽 818:140 → 822:220 → 826:235(ease.out);两圈灰涟漪扩到 560/460 宽、838 前淡出;把手半圆+茶包标签留在地上。
+- 拍杯动线:杯子右侧 3 道短线,击中后 12 帧外扩淡出。
+
+## 环境二次动作
+- 吊灯:`damped(F, 686, 0.055rad, 周期26帧, 衰减22帧) + damped(F, 830, 0.045, 22, 20)`,光锥一起摆。
+- 植物:`damped(F, 697, 0.035, 22, 18)`(晃)+ `damped(F, 821, 0.05, 9, 26)`(抖,周期短);龟背竹每片叶再加一点相位不同的自摆。
+- 云 15px/s 左移(0.25px/帧);小飞机 177px/s 拖虚线尾迹(12.0s 在 x≈440、13.75s 在 x≈750,对上原片);太阳光芒 0.35 rad/s 转;17 个装饰符号 4fps 沸腾(±1.5px、±0.09rad)。
+
+## 签名
+`window.SIGNATURE || 'Opus 5.5'`,Caveat-600 64px 缩放到宽 236px,起点 (1614,1032) 微倾 -0.03;书写前沿 x 用分镜表 842:1606 → 870:1868 逐帧插值,`clip` 揭示;下划线 24 段、线宽 3.4→1.4 渐细,同一个前沿一起画出。
+
+## 性能
+热帧 5–12ms,转场首帧(含缓存构建)31–64ms。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/17_ink.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/17_ink.md"
new file mode 100644
index 0000000..6a8e4c4
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/17_ink.md"
@@ -0,0 +1,50 @@
+# 17_ink · 中国水墨写意(八大山人/齐白石)
+
+> 来源:迁移测试 A(只读 skill 的独立 agent 实做,2026-10-04)。场景代码由整合后移植到 `scripts/engine/scenes/17_ink.js`。
+
+实验时的文件名 `scenes/01_ink.js`(313 行)。帧差 0.45↔0.9s 为 3.3%(阈值 24),相邻帧中位 0.62%,没有静止帧对。
+
+**管线**(和 09 标杆相反:纸是底,墨只加不铺)。开场 `lt += 0.12`,第 0 帧已经落下前几笔,不是一张白纸(审片指出白纸首帧不能当封面)。
+宣纸(缓存)→ 晕染层:淡墨远山、朱日 → 雾带(纸色模糊椭圆横移)→ 掠过的小鸟 → 静态笔触:窗、案、地线,写完缓存 → 竹枝(个字叶)→ 挂轴里的齐白石虾 → 猫:赭石晕染+焦墨 → 少女:花青晕染+白描+衣纹 → 热气游丝 → 钤印。
+
+**宣纸**
+`P.texture('#efe6d0', scale .0025, amt 9, grain 7)`。上面叠 2600 根纸纤维短弧:一半褐色 α.05–.13,一半亮色 α.12–.27。再加径向暗角,到边缘 α.22。
+
+**毛笔 `brush(c, pts, {w, tone, dry, reveal, bristles, head, tail})`**
+- 点列先 Catmull-Rom 加密,再按 4px 等弧长重采样(`KIT.resample`)。不重采样的话,飞白噪声的频率会随笔画长短变化。
+- 笔压:`prof(q) = smoothstep(0,head,q) · (1−0.7·smoothstep(1−tail,1,q)) · (0.85+0.15·noise)`。
+- 湿笔芯:整笔都用 ribbon 填,宽度 `w·prof·(1−0.85·dry·q^0.8)`,α 为 tone×0.72。越往后越细,表示墨在用完。
+- 笔毛:每根一条**连续**折线,横向偏移 ±0.475w·prof。噪声 `noise(k·1.9, i·0.09)` 低于 `dry·q^1.2·0.95+0.05` 时断开,露出的纸就是飞白。
+- 坑:第一版按「每一小段单独 stroke+round cap」画笔毛,接头处叠出一节节深点,看起来像竹节或麻绳。必须改成每根笔毛一条连续 path、butt cap。
+- 参数:窗框 w14–18、dry .45–.6;案面 w22;衣纹 w4–6、dry .3–.4、tone .78;地线 w5、dry .85、tone .35。
+
+**晕染层 `washLayer`**
+- 形状先画在 scratch 上,再用 multiply 合到纸上,分两遍。
+- 外晕:`blur(halo·(0.4+grow))`,α 为 haloA·grow。
+- 本体:`blur(blur·(1.6−0.6grow))`。
+- grow 按 lt 从 0 走到 1:开场是从无到有洇开,之后外晕继续慢慢变宽,这就是「墨在纸上晕开」。
+- 少女 halo 12、α.6;猫 halo 9、α.78;远山 halo 14。
+
+**留白**
+- 猫的白色部分(口鼻、胸、爪)用 `destination-out` 从赭石层里挖掉,露出纸色。这比画白色更有水墨味。
+- 少女的交领内衫也这样挖掉。
+- 面部用纸色填,再用 1.8px 焦墨白描勾。
+
+**色**
+- 墨 `[16,14,12]`,用 tone 分出五色(焦 .9/浓 .8/重 .6/淡 .35/清 .15)。
+- 赭石(猫)`#c47a3c`;花青(衣)`#6f8aa0`、广袖 `#7d97ab`;藤黄(金发)`rgba(226,170,52,.75)` multiply。
+- 胭脂红只点三处:腰带、发簪珠、点唇,用 `[190,40,40]`。另有朱日 `#d8553f`、钤印 `#c4281e`。
+
+**母题动画**
+- **开场写出**:lt 0→0.45,每笔 `reveal = ss(d, d+l, lt/0.45)`,按窗、案、竹、猫、人的顺序依次写出。
+- 竹:分节淡墨主枝,绕 (835,70) 摆 `sin(2.9t)·0.11`,越往枝梢越大。5 组个字叶各 3 片(L110、w15),翻动 `sin(7t+g)·0.2`。
+- 雾带:4 条纸色椭圆,blur 14、α.72,以 150–270px/s 横移,远山时隐时现。
+- 八大式小鸟:从窗右侧以 420px/s 掠过,翅膀两笔,每秒约扇 8 次(`sin(52·lt)`)。
+- 齐白石虾(挂轴里两只,1.45 倍):6 节淡墨节+头胸甲中间一笔焦墨,两长两短须做行波,三节长钳,身体弯曲 `sin(7t)·0.12`,沿曲线游动。
+- 八大白眼:猫的瞳点顶到眼眶上方,「白眼向天」。
+- 钤印:lt 0.3–0.4 从 1.5 倍压到 1 倍,multiply 盖上;白文「白石」。
+
+**坑**
+- 静态笔触在写出期间实时画,写完一次性缓存成 `ink_static`,否则每帧要画几千根笔毛。
+- 小鸟第一版的路径穿过竹叶丛,看不见,改到雾带上方 y≈470 才读得出来。
+- 晕染用的是 multiply,透明,所以窗台墨线会透过猫的耳朵,桌腿会透过裙子,审片读成「层级错了」。修法是在猫和衣裙的剪影里先补一层纸色(clip 后 drawImage 纸),再上晕染。这等于在纸上「先留出这块地方」。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/18_klimt.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/18_klimt.md"
new file mode 100644
index 0000000..29178ca
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/18_klimt.md"
@@ -0,0 +1,37 @@
+# 18_klimt · 克里姆特金色时期(1907)
+
+> 来源:迁移测试 A(只读 skill 的独立 agent 实做,2026-10-04)。场景代码由整合后移植到 `scripts/engine/scenes/18_klimt.js`。
+
+实验时的文件名 `scenes/02_klimt.js`(223 行)。0.45↔0.9s 为 32.9%(主要来自流光),相邻帧中位 0.40%,但 48 对里有 14 对几乎静止(见 ②-2)。
+
+**管线**
+金箔墙(缓存)→ 金粉四角星闪烁(lighter)→ 窗《白桦林》点彩 → 黑白方格金框 → 花毯地 → 霍夫曼黑白方格桌 → 斜向流光(在角色之前画,角色自然挡住)→ 猫 → 少女金袍(纹样层按剪影 source-in)→ 写实的脸与手 → 花冠 → 金袖、金杯 → 金色热气。
+
+**金箔**
+- 逐像素:`f = 0.5 + fbm(x·.004)·0.55 + noise(x·.003, y·.08)·0.5 ± 0.05`,在 `[120,78,18]→[196,148,52]→[246,216,128]` 之间插值。
+- 每 96px 画一条极淡的方块接缝,表示一片片贴上去的金箔。
+- 墙:金箔 × 480×270 小 fbm 图放大后 multiply(褐金斑驳,像《吻》的底),再撒 9000 颗金粉、暗粉。
+
+**纹样(金袍)**
+- 150 个随机点,分四类:
+ - 同心圆三色(30%):红白蓝、蓝金红、紫白金;
+ - 深褐底金螺旋(32%),每个按 ±3rad/s 转;
+ - 荷鲁斯式眼形纹(22%),轮流眨:`sin(2.2t+φ)>0.86` 时闭上;
+ - 白点簇+红心(16%)。
+- 下摆另有 60 块黑白竖长方块,金描边,这是《吻》里男子长袍的语言。
+- **平面装饰对写实脸**:脸、手用径向渐变表现体积(高光 `#fbe8da` → `#f0cfb8` → `#d8a88c` → 边缘 `#b88068`),模糊的腮红和眼窝阴影,只有 1.2px 淡轮廓。金袍有 3px 深色描边。这个对比就是克里姆特。
+
+**其它**
+- 窗《白桦林》:2600 个秋叶色椭圆点,6 根白桦树干带黑斑;落叶 14 片翻面下落。
+- 花毯:260 朵同心圆花,越近越大(6→20px),点头 `sin(4.2t+φ)·0.18r`。
+- 流光:520px 宽、α.24 的亮带,`transform(1,0,−0.45,1)` 斜切,lighter,在 1.15 秒内**匀速**从 −200 扫到 2300。
+- 金粉:420 颗,`sin(t·sp+φ)>0.55` 时出四角星。第一版星太大,像圣诞装饰,后来半径从 `s·(1+2.2a)` 改为 `s·(0.6+1.1a)`。
+
+**坑**
+- 逐个纹样 `source-in` 会把彼此清掉,见 ②-7。
+- 流光 α 到 .38 时像镜头眩光,压到 .24。
+- 第一版相邻帧有静止段:眨眼是间歇的,流光是软渐变。加了三样之后,静止帧对从 20/36 降到 0/36:
+ - 34 片金箔碎片翻面飘落(150px/s,方片和圆片,金色渐变);
+ - 金粉以 26px/s 上浮;
+ - 花点头幅度从 0.18 加到 0.35。
+- 猫身上的金螺旋第一版连脸上也有,审片说「像起了疹子」,改成只在身体上、数量减到 46 个。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/19_munch.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/19_munch.md"
new file mode 100644
index 0000000..0911128
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/19_munch.md"
@@ -0,0 +1,42 @@
+# 19_munch · 蒙克《呐喊》式表现主义(1893)
+
+> 来源:迁移测试 A(只读 skill 的独立 agent 实做,2026-10-04)。场景代码由整合后移植到 `scripts/engine/scenes/19_munch.js`。
+
+实验时的文件名 `scenes/03_munch.js`(约 160 行)。终版相邻帧中位 2.27%,单帧 JS 侧大约 90–140ms。
+
+**流线渲染器 `flowLines`(新)**
+- 种子:24px 抖动网格,约 3600 个。每个种子判定区域(天、峡湾、山、墙、地板)。
+- 沿「随时间扭动的方向场」积分,每区参数 [steps, step, width, α]:
+ - 终版:天 [32,7,10,.78]、峡湾 [26,6,9,.78]、墙 [42,7,13,.5]、地 [32,8,12,.55],每根另加 0–8 步随机。
+ - 一根笔走 200–300px。
+ - 历程:第二版是 [26,6,7,.85],独立审片仍判「第一眼是梵高」,只好再拉长、加宽、减透明度。
+- 越出本区就停,所以区域边界是干净的。
+- **不描边、半透明叠色**:蒙克是薄涂长笔。第一版照搬梵高的「深色描边」,墙面成了一节节毛毛虫短笔,一眼就是梵高。去掉描边、步数从 10 加到 26 以后才对。
+- 底下先铺同色系平涂(墙从 `#a8401e` 渐变到 `#5a1a14`),笔缝里露出来的是同色,不是黑。
+
+**方向场**
+- 天:`0.55·sin(x·.011 + y·.018 − 2.4t)`;
+- 峡湾:绕 (620,470) 的切线;
+- 墙:竖向 ±0.5 正弦扭;
+- 地:指向消失点 (1000,640)。
+
+**血色天空**
+- 种子按「波浪化的 y」决定色带:`yy = y + 22·sin(x·.014 − 2.2t)`,带宽 28px。
+- 7 色循环:`#e2541c #f08a24 #f4c03a #c8301e #e8743a #f6a63a #b82a1e`。
+- 色带本身也在扭,这就是「天空在流」。
+
+**整个世界在流动**
+最后把整幅画按行位移 `9·sin(y·.012 + 4.2t) + 4·sin(y·.031 − 6t)`,再按列位移 `6·sin(x·.009 − 3.6t)`,带宽 4px,用 `KIT.warpRows / warpCols`。人、猫、桌都会一起晃,比单独画摇晃的线便宜得多。
+
+**母题**
+- 窗里:桥面斜纹、栏杆三条(随世界扭)、两个戴帽远人。
+- 尖叫者:骷髅脸、双手捂颊、嘴张合 `7+2sin(9t)`,身体摆 `sin(3.2t)·0.12`。
+- 桌、椅腿是抖动的波浪线。
+- 少女:1890 年代挪威深色长裙+白领,黄绿脸影(blur 8 的 `rgba(120,150,70,.4)`),9 绺长金发做行波 `sin(9q − 7t)`。
+- 猫嘴微张,像被画外的尖叫传染了。
+
+**角标**:文字画进离屏,再按行正弦扭。字体不要用 Kalam 这类漫画手写体(审片说出戏),改用 IMFellEnglish。
+
+**坑**
+- 整幅行列位移以后,左右边缘会露出暗色缺口。`KIT.warpRows/warpCols` 加了 margin 参数:每行多拉伸 2×margin 像素,margin 要大于等于最大位移。
+- 线稿模式下举杯的手臂会被躯干线穿过,用 `KIT.nearArm` 重盖(见 ②-16)。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/20_dunhuang.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/20_dunhuang.md"
new file mode 100644
index 0000000..cd301f2
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/20_dunhuang.md"
@@ -0,0 +1,49 @@
+# 20_dunhuang · 敦煌壁画(莫高窟·盛唐)
+
+> 来源:迁移测试 A(只读 skill 的独立 agent 实做,2026-10-04)。场景代码由整合后移植到 `scripts/engine/scenes/20_dunhuang.js`。
+
+实验时的文件名 `scenes/04_dunhuang.js`(215 行)。0.45↔0.9s 为 6.6%,相邻帧中位 1.98%。
+
+**管线**
+土红地仗(缓存):`P.texture #a5452f`、dark `#7a3020`,加稀疏褪色团花,顶部卷草边+三角垂幔(青绿白红交替+金珠)→ 窗=石青天:祥云、飞天 → 卷草纹窗框 → 莲花砖地(缓存)→ 壸门低案、油灯 → 猫 → 少女(唐代供养人)→ 热气卷云 → 天花 → 罩层。
+
+**线与色**
+- 铁线描:等宽 2.6px,色 `#5a2414`。脸用更红的 `#8a3a24`。
+- 矿物色:土红 `#a5452f`、石绿 `#3f8f6e / #6ab08e`、石青 `#2f5f8f / #5a86b0`、白 `#ecdfc4`、金 `#d8b05a`。
+
+**唐装**
+- 间色裙:红底,斜梯形绿条,每 44px 一条,向下随 x 发散。
+- 石青短襦、白交领、高腰红带。
+- 高髻:在 headTop 上方叠两个椭圆,加金钗和三朵簪花。
+- 面妆:花钿(额头四瓣红花)、斜红(太阳穴一道红弧)、点唇、蛾眉。
+- 茶盏是越窑青瓷。
+
+**披帛 `shawl(pts,w)`**
+- 行波点列 → ribbon,加白色虚线描花和红点。
+- 背后一段:`x = back + 230q + 64q·sin(4.2q − 5.5t)`,末端 30% 向上扬。
+- 前段绕臂垂下。
+- 坑:第一版横向摆幅只有 18–34px,又几乎竖直,看起来像椅子的竖杆。横向位移要到 200px 以上,加上末端上扬,才读得出是飘起来的帛。
+
+**飞天**
+- 横卧朝左,1.35 倍,以 300px/s 飞过窗。
+- 三条飘带做行波,其中一条从肩起弧过头顶再甩到身后,这条大弧是飞天最有辨识度的形。
+- 头光、发髻、托花盘。
+- 祥云是圆团+渐细云尾,以 40–76px/s 漂。
+
+**罩层(做旧)**
+- 整体 `saturation` 混合 α.3 褪色,再 multiply 一层浅土纹理 α.5。
+- 逐像素剥落:`fbm(x·.0032)+0.12·noise(x·.03) > 0.3` 处露出白灰地仗 `#d8c6a2`,0.28–0.3 是剥落边缘的暗线。
+- 两张脸附近设为保护区,不剥落。
+- 500 条龟裂随机游走,顶部 380px 烟熏渐变。
+- 坑:
+ - 剥落噪声频率用 .006 时,出来的是满屏芝麻斑,像污渍。降到 .0032 并提高阈值后,才是一块块的剥落。
+ - 终版把猫 (380–720, 530–920) 和少女 (1070–1530, 240–950) 都设成保护区,只剥背景。
+ - 斜红 α 降到 .32,否则像伤疤。
+ - 飞天的头光第一版是实心绿圆,读成「游泳圈」,改成 α.28 半透明加细线。
+ - 猫用 `#c8843a` 时,叠上褪色就成了褐黄色,改成 `#e08a3a`;再加 `look: sin(2.6t)` 转头,呼吸加大 2.5 倍,不然整段只有尾巴在动。
+
+**母题动画**
+- 天花:30 片四瓣花,旋转并翻面下落。
+- 油灯:火苗 `1+0.12sin(17t)+0.08sin(29t)` 跳动,加光晕。
+- 颜料片:10 片从剥落边缘脱开,翻转、抛物线下落。
+- 猫的项圈小铃摆动。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/21_kusama.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/21_kusama.md"
new file mode 100644
index 0000000..b95a193
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/21_kusama.md"
@@ -0,0 +1,32 @@
+# 21_kusama · 草间弥生无限波点
+
+> 来源:迁移测试 A(只读 skill 的独立 agent 实做,2026-10-04)。场景代码由整合后移植到 `scripts/engine/scenes/21_kusama.js`。
+
+实验时的文件名 `scenes/05_kusama.js`(124 行)。0.45↔0.9s 为 17.3%,相邻帧中位 2.98%,JS 侧 4–28ms。
+
+**蠕动的点**
+- 所有点的半径乘同一个「从猫出发的行波」:`wave = 0.82 + 0.28·sin(dist·0.012 − 6t)`。
+- 整个房间的点从猫的位置一圈圈胀缩,像在呼吸。这一个函数就让全屏都活了。
+
+**点的布置**
+- 墙:大点(30px,间距 104)+小点(10px,错位)两套六角网格,各带 ±25–50% 抖动。每个点是轻微椭圆加随机转角,像手画的。
+- 地板:9 行,越近越大(6→28px)、越疏,压成 0.42 的椭圆做透视。
+- 红裙白点 13px、间距 52,按 46px/s **顺着裙子往下爬**(clip 到裙子剪影,y 偏移取模)。
+- 猫:橘色区白点、白色区红点,各自往下爬。
+- 脸颊上也画了一个红点(草间的身体彩绘),头上是红底白点蝴蝶结。
+
+**无限镜屋(窗)**
+- 3D 格子灯:13×7×3,6 色。z 以 0.3/s 循环飞向镜头,透视投影 F150。
+- 每颗灯是实心小核加 3.2 倍光晕,lighter 叠加。
+- 坑:第一版灯随机散布、光晕很大,糊成了散景。规则格子+小实心核才有镜面无限重复的感觉。
+
+**黄南瓜**
+- 5 瓣椭圆,绘制顺序是外 → 内。
+- 每瓣按行排黑点:中列最大(9.5px),向两边、上下都缩小,点的大小也跟着行波变。
+- 整体呼吸:缩放 `1 ± 0.025·sin(5t)`,以底部为轴。
+
+**结尾「自我消融」**
+- lt 1.0–1.26:红色覆盖层渐显,全屏 120px 六角点阵从猫的位置一圈圈胀到 0.47 倍间距。之后约 0.15s 只剩点阵在轻轻呼吸,给结尾一个落点(审片指出第一版没有停留帧)。
+- 最后一帧停在红底白点的点阵上。
+- 坑:第一版让点无限胀大,结果是白屏。半径必须封顶,最后停在点阵,不能停在纯色。
+- 坑:裙子和墙都是红底白点,少女在画面里会溶解掉。终版把少女轮廓线加到 4.5px,猫白色区域的红点去掉,保住橘白分界。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/22_constructivism.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/22_constructivism.md"
new file mode 100644
index 0000000..ea5e95d
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/22_constructivism.md"
@@ -0,0 +1,35 @@
+# 22_constructivism · 1924 俄罗斯构成主义海报(罗德琴科 / 李西茨基)
+
+> 来源:迁移测试 B(只读 skill 的独立 agent 实做,2026-10-04)。场景代码由整合后移植到 `scripts/engine/scenes/22_constructivism.js`。
+
+实验时的文件名:`scenes/c1_constructivism.js`(约 175 行)。每帧中位 5ms;帧差 3.6%。
+
+**管线**
+1. 底版全缓存 `cs_bg`:米白旧纸(`P.texture` `#e9dfc4`,dark `#d9c9a4`)→ 左侧斜黑条(rotate −0.5)、红方块(rotate 0.26)、5 行「正文」黑条 → 右侧细斜线、红圆点、黑竖条里竖排几何字「ЧАЙ」→ 人物头后大黑圆(中心 (1330,395),r 215)→ 斜红地面 (0,905)→(1920,856),上沿一道 12px 黑线 → 窗 → 黑桌(红边、斜撑)→ 黑块凳。
+2. **窗=照片拼贴**:先在离屏画灰度「照片」(天空渐变 `#5e5e5e→#e8e8e8`、径向白云、暗色厂房剪影、烟囱),再用 `halftone()` 网点化(cell 7,gain 0.8);舒霍夫塔用清晰黑线画在网点上面(五节双曲面,每节两组各 18 条直母线,相位差 ±1.1rad,背面 sin<−0.2 的省掉),这正是「照片+手绘」拼贴。
+3. **皮肤=网点照片**:脸、颈、手先画灰度渐变(前亮后暗,`#fafafa→#9c9c9c`)到离屏,再网点化(cell 4.6、gain 0.74、45°)。网点下垫米白,外圈先描 7px `#fbf7ea`,这一圈就是照片剪下来的白边。五官用清晰黑笔补,嘴唇手工上红。衣服全是剪纸平涂+3px 黑线;阴影用 `shadeDots()`,在路径内按函数落网点。
+
+**关键函数**
+- `halftone(c, src, bx,by,bw,bh, cell, col, gain, ang=π/4)`:在旋转网格上采样 src 灰度,点径 = cell·gain·√(1−L),只落在 alpha>128 处。**所有点并成一条 path、只 fill 一次**。脸部约 3000 点,耗时 <2ms。
+- 几何西里尔字:5×7 模块,每个字母是若干矩形或多边形(Й 的斜笔是四边形,短音符是上方一个小矩形)。**每个部件单独 fill**。
+
+**母题动画**
+- 李西茨基红楔刺入黑圆:顶点沿 0.34rad 轴线往返,`70·(0.5−0.5cos(2π·1.6·lt))`。
+- 黑圆外的红虚线环:dash [46,22],`lineDashOffset = −260·lt`。
+- 塔顶无线电波:4 道红弧,`r = 18 + ((1.4lt + k/4) mod 1)·230`,α 和线宽随相位衰减。
+- 地面标语「ПЕЙТЕ ЧАЙ!」:逐字盖章(第 k 个字在 0.045k 秒起跳,0.12s 内从 1.5 倍缩回 1),之后整排波浪跳 `−10·max(0, sin(11lt − 0.8k))`;每第 4 个字是黑字。
+- 头巾两条尾巴 `sin(9lt)·6` 轻摆;杯上热气是三条黑折线上行。
+
+**角色**:共青团少女——红头巾(头部局部 13 点,前沿后移到能露出金色刘海,颈后打结两条三角尾)、白衬衫+红领巾三角+红袖口、深灰长裙(网点阴影)。猫用剪纸橙 `#e2741c`+米白,10px 黑条纹,尾巴用虚线描边做虎斑,眼睛是方瞳竖条。
+
+**色板**:纸 `#e9dfc4`;红 `#c8231c`/`#8f1711`;黑 `#151311`;米白 `#f4ecd6`;金发 `#e3b03e`/`#a87a1c`;猫橙 `#e2741c`。
+
+**坑**
+- 「Й」的短音符第一版画在字格上方(y=−1.7u):竖排时被上一个字母盖住,地面标语里被裙摆盖住,审片读成「ЧАИ」。改成整个字画在 7 格内(И 部分下移 1.7 格),标语也改到角色之上画(海报字压人物)。
+- 「А」第一版用两条反向斜腿+横杠拼在一个 path 里,重叠处被 nonzero 抵消,竖排时读成「В」。改成逐部件 fill。
+- 地面标语第一版基线压在 y=1060,字的下半截出画。按 `translate(x, 990)` 以字中心定位。
+- 颧下阴影第一版太重,网点化之后像一片胡子。灰度源里的阴影 α 要比平涂时低一半。
+
+**仍可改进**:罗德琴科更典型的是「人物照片+喇叭形文字锥」。可以把热气换成从杯口放射出的红黑楔形字锥。
+
+---
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/23_dali.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/23_dali.md"
new file mode 100644
index 0000000..4b4a54a
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/23_dali.md"
@@ -0,0 +1,29 @@
+# 23_dali · 1931 达利超现实主义(《记忆的永恒》)
+
+> 来源:迁移测试 B(只读 skill 的独立 agent 实做,2026-10-04)。场景代码由整合后移植到 `scripts/engine/scenes/23_dali.js`。
+
+实验时的文件名:`scenes/c2_dali.js`(约 235 行)。每帧中位 47ms(首帧 84ms);帧差 4.6%。
+
+**管线**
+1. 底版拆成三张缓存,因为影子必须夹在中间:`dali_bg`(天、海、岩、地)→ 每帧画影子 → `dali_wall`(开窗的断墙残片+枯枝)→ `dali_block`(石块桌+凳)→ 软钟 → 角色。
+2. **体积填色 `vol(c, path, x0,y0,x1,y1, a, b, occl, blur)`**:线性渐变填充,再在 clip 里用 shadowBlur 描一圈暗边做内阴影。全片无勾线,学院派的圆润感全靠这个。
+3. **长影子**:把每个物体的剪影用剪切仿射投到地面,`setTransform(1, 0, −kx, ky, kx·yg, yg·(1−ky))`,yg 是该物体的着地线(墙 700、桌/猫 905、人 930)。所有剪影先画进一张离屏(纯黑),再整体以 α 0.55、blur 1.5px 叠上去,避免影子重叠处加深。用 clip 只留地面部分(y > 594)。`kx = 0.85 + 0.6·easeInOut(lt/1.2)`,影子在 1.2s 里明显变长。
+4. **软钟 `softMap(o, sag)`**:圆盘局部坐标 (u,v) → 屏幕。v ≤ fold 的部分躺在台面上(y 压缩到 0.28–0.32);v > fold 的部分垂下:`X = cx + u·(1 − flare·q)`,`Y = … + d·(0.62 + 0.3·sag) + 中央下垂高斯 + sin 波纹`。外框、表盘、12 个刻度、两根指针(沿映射采样成软线)、折线高光**都走同一个映射**。
+
+**关键参数**:`flare = −0.12`,负值让垂下部分像软布一样往外摊开,下缘是圆的;正值会收成冰淇淋筒。drip 0.18–0.4。sag 在 1.2s 内从 0.1 → 1.4:第一版 0.35→1.0,审片说「钟没有明显在淌」。三只钟:窗台 R72、桌沿 R88、枯枝 R64(fold −34,大部分垂下)。指针转速 4.5–6.5 rad/s。
+
+**母题动画**:三只软钟持续下垂、指针以不同速度转;地平线上的高跷象(四条细腿相位差 π/2 交替迈步,膝关节 0.52 高度处微弯,身体 14Hz 微颠,背驮方尖碑)每秒左移 70px;9 只蚂蚁绕橙色怀表做椭圆爬行;长影子变长;猫尾巴软化下垂(尾尖 y + q²·34)。
+
+**角色**:西班牙少女,浅蓝长裙+白翻领,金发髻,无勾线,体积靠渐变+内阴影,五官是暗褐细线。猫用渐变橙,条纹用 blur 2px 的半透明笔(柔),眼睛用径向渐变;白胸改用平滑椭圆 (606,768) 40×92,不用 `K.white`。
+
+**色板**:天 `#22407c → #5f88bd → #e9dcae`;海 `#8aa6b8 → #4f6f86`;岩 `#e8c27a / #9a6a34`;地 `#d2ad70 → #7a5129`;墙 `#f4ead2 → #cdbf9f`;钟金 `#f0d27c / #9a7426`,表盘 `#f6efd6`。
+
+**坑**
+- 影子第一版往观众方向投(ky>0 向下),全被画框底边吃掉。太阳要放在左前方低空,影子往右后方躺(y′ = yg − ky·(yg − y))。
+- 影子是投在地上的,必须画在墙和桌子下面,所以底版要拆层,不能一张缓存到底。
+- 软钟 flare>0 加大 drip,就是冰淇淋筒。
+- 这个计数器底色是深蓝天,原来设的深褐色字看不见,改成米白字+深色投影。
+
+**仍可改进**:人物还是偏矢量插画,可以加更细的高光和暗部反光;《记忆的永恒》里那个侧卧的软体「自画像」生物可以作为第四个母题。
+
+---
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/24_hopper.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/24_hopper.md"
new file mode 100644
index 0000000..b48b743
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/24_hopper.md"
@@ -0,0 +1,30 @@
+# 24_hopper · 1942 霍珀美国现实主义(硬光块面)
+
+> 来源:迁移测试 B(只读 skill 的独立 agent 实做,2026-10-04)。场景代码由整合后移植到 `scripts/engine/scenes/24_hopper.js`。
+
+实验时的文件名:`scenes/c3_hopper.js`(约 150 行)。每帧中位 13ms(首帧 54ms);帧差 6.0%。
+
+**核心手法「双版本裁切」**:同一个 `room(g, K)` 函数按两套色画两张缓存——背光版 `SH`(冷绿墙 `#5d8679`、暗地板 `#5b3d2b`)和受光版 `LT`(暖黄墙 `#efcf8f`、亮地板 `#c98b52`)。每帧先画背光版,再用会移动的光斑多边形 clip 进受光版,光影边缘天然是硬的,还能整体平移。人物和家具同理:`girl(c, K, G)` 用背光色画一遍,再 clip 进斜光带用受光色画一遍。
+
+**光斑几何**(dx = 30 − 95·easeInOut(lt/1.25),1.2s 里左移约 95px)
+- 墙上光斑 WP:(1420+dx, 250) → (1920, 470) → (1920, 730) → (1420+dx, 730)
+- 地上光斑 FP:接在墙光斑下面,往右下方展开
+- 人物光带 OP:左缘从 (1345+dx, 0) 到 (1185+dx, 1080)。光边在这一段里扫过少女的脸,从半脸背光到全脸受光
+- 窗棂影:竖条 24px + 一条平行于光斑上沿的斜条
+- **人在墙上的投影** = 人物剪影平移 (+150, +18) 后画进离屏,`source-in` 填进背光底版,再画回光斑区域。效果就是光斑里透出背光墙,和人物姿态同步。
+
+**母题动画**:光斑缓慢移动(核心);窗外对街红砖楼(致敬《星期天的清晨》)的理发店旋转柱,红蓝斜纹以 60px/s 上行;卷帘拉绳 `sin(4.2lt)·0.07rad` 轻摆;光带里 26 颗浮尘(只在光边右侧显示);热气。
+
+**质感**:油画拖笔用竖向拉长的 fbm(x·0.06, y·0.006)为主、斜向为辅,1/4 分辨率生成后放大,`soft-light` α 0.2。窗外每个窗洞右侧画 10px 硬影,卷帘拉到不同高度(0.25–0.7),这是霍珀的细节。
+
+**色板**:背光墙 `#5d8679`、护墙 `#4b6d63`、地 `#5b3d2b`;受光墙 `#efcf8f`、护墙 `#d8ad68`、地 `#c98b52`;裙 背光 `#7a2c2a` / 受光 `#cc4a3c`;金发 背光 `#a8893f` / 受光 `#f3d67e`;砖 `#b4553a`。
+
+**坑**
+- 刷痕第一版用横向 fbm、α 0.35,墙面像水纹大理石。霍珀的墙是平的,刷痕只能若有若无。
+- 改代码时把注释插进一行中间,把同一行后半截代码注释掉了(Python 批量替换时注意)。
+
+**角色**:第一版是盘发+红长裙,审片说「像成年女性,读不出 17 岁」。改成披肩长发(`hair:'long'`)+一条蓝发带,就年轻了。猫的白胸用平滑椭圆,背光白 `#dcd6c8`(第一版 `#c4bdac` 读成灰白猫)。
+
+**仍可改进**:猫全程在阴影里,偏暗(这是孤独感的取舍)。也可以给猫一小块从后窗进来的光。
+
+---
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/25_ghibli.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/25_ghibli.md"
new file mode 100644
index 0000000..faff25a
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/25_ghibli.md"
@@ -0,0 +1,31 @@
+# 25_ghibli · 1988 吉卜力式手绘水彩背景美术
+
+> 来源:迁移测试 B(只读 skill 的独立 agent 实做,2026-10-04)。场景代码由整合后移植到 `scripts/engine/scenes/25_ghibli.js`。
+
+实验时的文件名:`scenes/c4_ghibli.js`(约 270 行)。每帧中位 17ms,**首帧 619ms**(水彩底版缓存);帧差 5.1%。
+
+**水彩渲染器**
+- `deform(pts, depth, amp, r)`:中点位移。每轮在每条边中点沿法向推一个近似高斯量(3 个均匀数相加),幅度和边长成比例(min(1, len/80)),每轮 amp×0.6。
+- `wash(g, pts, color, {layers, alpha, amp, seed, edge, blend, fill})`:先 deform 3 轮得到基形;每层再 deform 2 轮,用 `multiply` 低 α 填充(透明颜料叠色),并以 α=edge 描一圈 1.6px 同色边。描边逐层叠加,就是颜料在边缘沉积的**水痕边**。fill 可以传渐变(天空、墙)。
+- 常用参数:大面积墙 layers 5、α 0.4、amp 12;色晕 layers 3、α 0.045、amp 40(大幅变形);木板 layers 3、α 0.5、amp 3、edge 0.14;不透明的白(窗框、桌布、云)用 `blend:'source-over'`、α 0.9–0.95。
+- 墙 = 径向渐变洗染(窗边亮 `#fbf3e0` → 角落 `#dcc49a`)+ 28 块大幅变形的透明色晕(暖黄、粉、蓝灰、浅绿交替)+ 两角暗晕。护墙板和地板**逐块**换色调洗染。最后 `multiply` α 0.3 叠一层高频纸纹颗粒。
+- 云:白色不透明圆团(16 个 puff,用 wash 画边)+ `source-atop` 叠底部蓝灰渐变,缓存成精灵。大樟树也是精灵,绕树根转 ±0.025rad。
+
+**赛璐璐角色 `cel(c, p, base, shade, dx, dy)`**:先整块填阴影色,再在 clip(p) 里把自身朝光平移 (−dx, −dy) 后填基色,只剩背光侧一道月牙阴影。最后描 2.4px 暖褐线 `#4a3428`。一个函数就是吉卜力式的两色赛璐璐。
+
+**母题动画**
+- 白纱窗帘:两幅,下摆鼓起 `q²·(90 + 70·gust)`,gust = 0.55 + 0.45·sin(3.2lt + 相位),再叠 `sin(7lt + 6q)` 小波纹;3 层半透明 wash,固定种子,所以边缘不沸腾。
+- 窗外 360 根草叶:风是一阵一阵的,`wind = 0.5 + 0.5·sin(3.1t − 0.018x)`,相位沿 x 推进,看得出一道风浪扫过草坡。
+- 云飘 22–30px/s;树冠轻摇;墙上 34 个 komorebi 光斑(`screen` 暖黄径向渐变,位置用 noise 漂,亮度 `sin(5t + 1.7i)` 闪);桌上雏菊点头;少女长发被风吹向右后(7 点 smooth,wind 推动);红蝴蝶结飘带抖动;桌布垂边摆动。
+
+**角色**:长金发+大红蝴蝶结(致敬魔女宅急便,不复制角色)、青色长裙+白围裙+白袖口;猫是暖橙+米白赛璐璐。背景里靠墙的扫帚是彩蛋。
+**角色的水彩填色**:审片说「背景像,人物不像(扁平矢量)」。把角色先画进离屏 L,另起纹理层 M(纸纹颗粒 α 0.8 + 40 块透明色晕 `charBloom`,α 0.1、amp 16),M 用 `destination-in` 按 L 的剪影裁掉,再以 `multiply` 叠回画面。线色从 `#4a3428` 调软到 `#6a4a38`。
+**窗帘**:审片说不飘。gust 频率 3.2 → 5.4,鼓起 `q²·(60 + 150·gust)`。
+
+**坑**
+- 色晕 α 0.07×4 层、颗粒 multiply 0.5 时,墙面像发霉的旧羊皮纸。吉卜力的房间是亮的:色晕 α 降到 0.045×3 层,渐变整体提亮一档。
+- 第一版用两个矩形 wash 拼墙(右侧更暗),x≈1100 出现硬接缝。暗部要用大幅变形的多边形(amp 60),不能用矩形。
+
+**仍可改进**:人物还是平面,可以加吉卜力式的发丝高光块;地上的光斑里可以加窗帘影子的流动。
+
+---
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/26_vaporwave.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/26_vaporwave.md"
new file mode 100644
index 0000000..1087ae6
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/26_vaporwave.md"
@@ -0,0 +1,27 @@
+# 26_vaporwave · 2011 蒸汽波 / 赛博霓虹
+
+> 来源:迁移测试 B(只读 skill 的独立 agent 实做,2026-10-04)。场景代码由整合后移植到 `scripts/engine/scenes/26_vaporwave.js`。
+
+实验时的文件名:`scenes/c5_vaporwave.js`(约 210 行)。审片红灯:上衣第一版是粉色,和粉调肤色混成一片,读起来像没穿衣服。改成薰衣草紫风衣 `#8f7cf6`+白三角领+青色拉链线。每帧中位 49ms;帧差 25%(VHS 后期让全屏都在动)。
+
+**管线**:整幅先画进离屏 S,再做 VHS 后期输出到 c(计数器由引擎画在最上层,不受色差影响)。
+1. 墙:深紫纵向渐变 `#0d0322 → #4a0f6a` + 窗口处洋红径向光、招牌处青色径向光。墙脚一条青色灯带。
+2. **`glowLine(c, col, w, blur)`**:同一路径先用 shadowBlur 描粗的辉光,再描 2–3px 近白芯线,就是霓虹灯管。
+3. 窗里落日:太阳是黄 → 橙 → 洋红竖向渐变,用 `destination-out` 切 7 条横缝,缝宽随深度变大(2 + q²·16),整体以 0.9/s 上移。地平线是线框山(洋红辉光),下面是青色透视网格往观众方向滚,左右棕榈剪影摇。
+4. 地面:洋红透视网格,消失点 (960,600),横线 `y = 600 + 520/d`、d = k + 1 − phase(phase = 1.3t mod 1),线宽随近处加粗。
+5. **霓虹招牌「カフェ」用折线自己画灯管**(不依赖字体):每个假名 1–3 笔,(u,v) 单位坐标。逐字按帧哈希闪:`hash(floor(30t), k) < 0.07` 灭;「フ」额外在 `f mod 17 < 5` 时 22% 概率灭,灭时画暗紫灯管。
+6. Win95 对话框 TEA.EXE:灰体、海军蓝渐变标题栏、进度块 `3 + 14lt` 格、百分比 `18 + 70lt`。桌上大理石胸像(侧脸剪影 22 点、紫灰渐变+静脉线+粉色轮廓光+墨镜梗)。
+7. 角色:粉毛衣、青色百褶长裙、金发+粉发圈。辉光轮廓「朝窗一侧粉、背面青」:同一组路径描两次,分别 clip 在左右半屏。
+
+**VHS 后期 `vhs(c, S, t, lt)`**
+- RGB 分离:对每个通道,把 S 画进临时画布、`multiply` 纯色 `#ff0000/#00ff00/#0000ff` 取出单通道,再以 `lighter` 错位合成到黑底。错位量 3 + 1.5sin(7t),偶发(hash<0.12)+6。
+- 跟踪噪声带:70px 高,`(520lt + 200) mod (H+160)` 下滚。带内每 6px 一条横向错位 `±30·sin(πy/bh)`,叠 90 条白灰噪线。
+- 扫描线:4×4 tile pattern(第 0 行 α 0.28、第 2 行 α 0.12)。OSD:PressStart2P「PLAY」+手画 ▶(字体里没有这个字形),16 帧一闪;左下日期、时间码按 lt 走。
+
+**色板**:洋红 `#ff4fd8`、热粉 `#ff2f8f`、青 `#3ff6ff`、深紫 `#12052a / #2a0b4a`、日黄 `#ffd84a`、橙 `#ff8a3a`。
+
+**坑**
+- 全角「VAPORWAVE」、▶、日文在 `lib/fonts` 里都没有,会静默回退系统字体。标签改用半角+字距 7,▶ 和假名都自己画。
+- 人物描边用的是部件路径,腰线、手臂和躯干的交界也会发光。霓虹线稿能接受,但想要纯外轮廓,得先把剪影画进离屏,再描离屏的边缘。
+
+---
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/27_kirby.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/27_kirby.md"
new file mode 100644
index 0000000..d213d6e
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/27_kirby.md"
@@ -0,0 +1,30 @@
+# 27_kirby · 1966 漫威银河时代(Jack Kirby + 四色胶印)
+
+> 来源:迁移测试 C(只读 skill 的独立 agent 实做,2026-10-04)。场景代码由整合后移植到 `scripts/engine/scenes/27_kirby.js`。
+
+实验时的文件名:`scenes/k1_kirby.js`(255 行)。每帧约 20ms,帧差 7.5%。
+
+**管线:同一份几何画两遍**
+1. **色版层**:纸 `#f4ecd6` + 平涂 + 本戴网点。墙浅蓝底上铺 C 网点(pitch 9、r 2.7、15°),地板深蓝底上铺紫网点(pitch 9、r 3.2、75°),皮肤是红点(pitch 7、r 1.5、75°)。**整层 `drawImage(color, 4, 3)`=套色不准**。
+2. **墨线层**:白底,每个部件「白填 → 阴影 → 黑描边 6px」。合成时 `multiply` 叠在色版上,白色=透明。逐部件填白会盖掉前面部件的线,所以只剩看得见的线,不需要 visibleLines。
+3. **Kirby 的黑块阴影+羽化排线(spotted blacks+feathering)**:光从窗来(LIGHT=(-0.86,-0.5))。
+ - 黑月牙:`path ∩ ¬translate(path, LIGHT·d1)`,d1=14。做法是先 `clip(path)`,再用「全屏矩形+平移后的 path」做 `clip(…,'evenodd')`,最后 fillRect 黑。
+ - 羽化带:同样的取法,用 d2=30 得到一条带,带里画沿光方向的平行线(间距 9px、线宽 2.6)。
+ - 参数(d1/d2):裙 16/34、躯干 14/30、袖 10/22、头发 12/26、猫身 16/34、桌面 10/18。
+ - 一个函数就能给任意 Path2D 打 Kirby 式阴影。
+
+**母题动画**
+- **Kirby krackle**:一簇 16–26 个黑圆。距离按 `R·rnd^0.7` 分布,越靠中心越大(`R·(0.05+0.2·(1-d/R))`),12fps 换种子,半径按 `sin(18t+i)` 脉动。6 簇沿窗外 S 形能量流移动(`(k/6+0.42t)%1`),能量流是橙边黄芯带+锯齿墨边。热气也用 krackle(4 簇小的往上飘)。
+- **速度线**:端杯速度 `|sin(min(1,lt/0.9)π)|`,在杯底往下拖 9 根黑线,长 70–180·v,12fps 抖;肘后两道动作弧。
+- **拟声大字 SLURRP!**:lt 0.52 起 `outBack` 弹出,用 `Bangers-400` 132px(×0.82);黑色挤出 7 层(每层偏移 (0.8d,d))做出 Kirby 的立体积木字;红字上面 46px 带 clip 成黄(双色字);底是 26 尖黄爆炸框;12fps ±3px 抖。
+- **分格**:主格 24..1534,右侧一格是猫脸特写,瞳孔随 `cup` 上移(`lerp(14,-18,cup)`)、往左看。背景是品红底+黄网点+44 根聚焦黑三角(12fps 换)+头周围 6 簇 krackle。底部旁白框「BUT THE CAT IS WATCHING!」,左上旁白框「MEANWHILE, AT TEA TIME...」。计数器做成黄底黑框、带黑色错位投影的旁白框,放在右上格缝里。
+
+**角色**:60 年代红色 A 字长裙、白色彼得潘领(两个椭圆)、前襟三颗黑纽扣、黑发箍(头部旋转坐标系里的椭圆弧,线宽 11)、外翻发尾(在 `skirt` 钩子里画,位于躯干后面)。椅子是 Saarinen 郁金香椅。
+
+**坑**
+- 拟声字一开始放在 (1000,300) 满尺寸,压住了窗和少女的脸。挪到 (990,318) 并缩到 0.82。
+- 猫特写右侧的大黑椭圆让猫像玳瑁猫,改成贴边的窄月牙。
+- 行星环要拆成后半弧(先画)和前半弧(后画),不然环会穿过星球。
+- **仍可改进**:画面偏「干净的波普漫画」,还缺 Kirby 那种方块化的手指、更夸张的透视和肌肉张力。
+
+---
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/28_monet.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/28_monet.md"
new file mode 100644
index 0000000..cef93af
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/28_monet.md"
@@ -0,0 +1,39 @@
+# 28_monet · 1899 莫奈《睡莲》+《日本桥》
+
+> 来源:迁移测试 C(只读 skill 的独立 agent 实做,2026-10-04)。场景代码由整合后移植到 `scripts/engine/scenes/28_monet.js`。
+
+实验时的文件名:`scenes/k2_monet.js`(176 行)。每帧约 105ms,帧差 30%(主要是水面沸腾)。
+
+**构图**:墙=橘园式睡莲壁画(整面水面),窗=绿色日本桥(拱桥+紫藤+池水),窗两侧是吉维尼的绿百叶,少女坐在壁画前。
+
+**管线(09 标杆结构)**
+1. 底稿 `moBase`,每帧重画,因为睡莲在漂、柳影在晃。
+ - 水面:竖向渐变 `#b9c7e6→#8fa6d6→#6c84bf→#5a72a8`,加 4 片浅粉黄的天光倒影。
+ - 柳影:5 条竖带,边缘 `sin(0.03y−3.2t+k)·14` 横向波动。
+ - 睡莲:10 丛、共约 100 片缺口椭圆(rx 38–78、ry 12–21),40% 带粉/白花。
+2. 笔触 4 遍:
+ - 水面:cell 9、len 34、w 6.5,**横向** angle≈0±0.06,boil 6。
+ - 窗景:cell 6、len 13、w 4.5,上半斜笔、下半横笔,boil 6。
+ - 地板:cell 12、len 34、w 8,**boil 0**。
+ - 窗框/百叶:cell 6、竖横各一,boil 0。
+ - 所有遍 outline 0(印象派不勾边)。
+3. **桥单独成层**:底稿里先在桥后面铺一块深色树荫衬底 `#24452a`;桥本身用 `#3f8a62` 粗线(20px)衬底、`#8fdcae` 亮线描出。笔触用 cell 5、浅蓝绿 5 色板。不这样做的话,桥会被树叶色板吞掉,完全看不见。
+4. 区域色板:
+ - 水 `#5b6fb5 #7d8fd0 #9db5e0 #6aa0a8 #b7a6d8 #d9c8e8 #8fb8a8 #a6c4e8 #c8b0d8`(mix .45)
+ - 叶 `#5f8f4a #7fae5a #3f6f4a #9cc070 #6f9a7a #b4cc78`
+ - 粉 `#f0a0b8 #f7d0dc #fff2f4 #e88aa0`
+ - 地板 `#c69a6a #b07a5a #d8b08a #9a6a7a #8a7aa8 #e0bc90`
+5. 角色:fill 模式平涂 → source-atop 细笔触(cell 6、len 12,白裙从 `#fbf8f2 #e4e0f6 #cfd2ee #f8ecd0 #d8e8f2` 里抽色)→ **色彩阴影**:受光侧叠暖黄 α.22、背光侧叠紫 α.32 的线性渐变(source-atop)→ 只补五官,用 `#5a4f8a` 细线。
+
+**母题动画**
+- **水面光斑颤动**:160 根亮色横短笔(`#fffbe8 #fdf0d0 #f8e0ec #e8f4ff`)。亮度 `clamp(sin(t·(5..11)+φ)·sin(2.3t+i))`,10fps 横向跳 ±5px。
+- 睡莲漂 `x+sin(1.3t+φ)·7+6t`,柳影波动,3 处涟漪(虚线椭圆 ry=rx·0.22,外扩并淡出)。
+- 紫藤:12 串垂花,每串 9 个由大到小的淡紫色点,按 `sin(2.4t+0.9i)·8` 摆。草帽蓝丝带飘。
+
+**角色**:1899 白色夏裙,高领、泡泡袖(肩部椭圆)、浅蓝腰带,RIG 草帽涂成 `#ecd28a`。
+**坑**
+- 全屏 6fps 沸腾时帧差 47%,满屏都是噪声。
+- 紫藤第一版用粗线条,画出来像光滑的药丸,改成点列。
+- 计数器放在笔触底上看不清,要加 blur 18 的奶白光晕。
+
+---
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/29_seurat.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/29_seurat.md"
new file mode 100644
index 0000000..5b5cf94
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/29_seurat.md"
@@ -0,0 +1,31 @@
+# 29_seurat · 1884 修拉《大碗岛的星期天下午》(点彩:视觉混色渲染器)
+
+> 来源:迁移测试 C(只读 skill 的独立 agent 实做,2026-10-04)。场景代码由整合后移植到 `scripts/engine/scenes/29_seurat.js`。
+
+实验时的文件名:`scenes/k3_seurat.js`(136 行)。每帧约 100ms,帧差 7.4%(静穆,相邻帧均差 0.45)。
+
+**渲染器(重点,可抽进 paint.js)**
+1. 整幅平涂底稿,角色也包含在内(每帧 ~3ms)。底层铺一遍 `blur(4px) saturate(.85) brightness(1.06)` 的底稿,当打底色,点与点之间的缝会露出它。
+2. **固定六角网格,点等大**:pitch 10、行距 8.66、r 4.5,每个点有 ±1.2px 的静态抖动。约 2.4 万个点。按颜色把点攒进 21 个 Path2D,每种颜色只 fill 一次。
+3. **视觉混色取色**:21 色纯色板。
+ - 14 个饱和色:`#1a2058 #2a3a9a #3f6fd0 #6aaee6 #1f6a52 #2f9a5a #a8c83a #f2cf3a #f08a2a #e0432a #c0306a #7a4aa8 #f8f4e8 #e8b48a`
+ - 7 个淡色(修拉的「和白混过的色」):`#f6e49a #f6c48a #cfe08a #b0cff0 #f2b8c8 #c99a4a #9a7ac8`
+ - 对每一对 (i,j),把目标色**投影**到线段 Pj→Pi 上,得到连续比例 w,clamp 到 [.2,.8]。距离再加上 `0.004·|Pi−Pj|²`,惩罚相差太远的配对,免得用黑白点混出灰。取距离最小的一对;每个点按 `hash(i,j) < w` 决定用 Pi 还是 Pj。
+ - 结果按 15bit 量化色缓存进 Map。
+4. **取色前给目标色加 ±20 的哈希抖动**(R+dj、G+0.8dj、B−0.6dj)。配对色的切换边界因此变成交错的点,不会出现竖向色带。
+5. **补色点**:8% 的点换成对比色(蓝↔橙、绿↔红紫、黄↔紫……共 21 条映射)。**光渗**:和右下方 14px 处比较,亮度差 >45 时,45% 的概率在亮侧放白点、暗侧放深蓝点。
+6. **修拉自己画的边框**:四周 28px 深蓝带,也过点彩渲染,所以带里会出现橙色补色点。
+
+**母题动画**:
+- 窗内塞纳河:帆船漂(40px/s)、汽船冒烟、撑伞女士的侧影+小猴。
+- 河面的点 6fps 重掷哈希=波光。
+- 室内一只橙红蝴蝶绕桌上方飞(`sin(2.6t)·120`),扑翅 `|sin(20t)|`。
+- 6fps 让 7% 的点换成配对色,表现光在点之间颤。第一版用 4fps/3%,独立审片判「基本定格」(相邻帧均差 0.1–0.2);改成 6fps/7% 后升到 0.45。
+
+**角色**:1880 年代深蓝紫长裙+腰后裙撑(`back` 钩子里一块弧形)+白高领+橙色纽扣+小圆帽配红羽毛。椅背上靠一把收拢的红阳伞。
+**坑**(两个都是渲染器层面的)
+- 偏好单一纯色(加了惩罚项)会把渐变墙切成几条竖色带。
+- 比例换成连续值以后,配对色在边界整列切换,还是会出带。要靠第 4 步的目标色抖动解决。
+- 第一版色板里没有淡色,亮墙被分解成白+肤色+零散蓝点,看起来像雪花噪声。
+
+---
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/30_matisse.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/30_matisse.md"
new file mode 100644
index 0000000..2f9ada9
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/30_matisse.md"
@@ -0,0 +1,26 @@
+# 30_matisse · 1947 马蒂斯《爵士》剪纸
+
+> 来源:迁移测试 C(只读 skill 的独立 agent 实做,2026-10-04)。场景代码由整合后移植到 `scripts/engine/scenes/30_matisse.js`。
+
+实验时的文件名:`scenes/k4_matisse.js`(167 行)。每帧约 25ms,帧差 9.3%。
+
+**构图**:墙=《波利尼西亚》双蓝棋盘(`#1d4fb8 / #4f95dc`,每格 240×236 剪纸块),窗=《伊卡洛斯》(钴蓝底、黑人形、红心、黄星),地=翠绿 `#1f9a5a` 加黑踢脚条,桌面是黑剪纸,椅子是黄剪纸。
+
+**手法**
+1. **剪刀折线 `cut(pts)`**:沿轮廓每 14–24px 取一个点,加 ±2–2.5px 种子抖动,点与点直线相连。自己生成的形状一律这样处理。
+2. **海藻(关键)**:一根锥形茎,加 2×lobes 根左右交替的**圆头胶囊手指**。手指角度 `±(1.05−0.55u)`,长 `width·(1−0.45u)`,宽 `width·(0.34−0.12u)`。所有子路径 `addPath` 进同一个 Path2D,用 nonzero 一次填充,得到并集,投影也只算一次。**不要用「沿脊线调制宽度」**:第一版这样做,出来的是毛毛虫和 Z 字闪电。
+3. **RIG 角色手剪边**:RIG 不给点列,所以角色层整层做像素位移。静态位移场是 `fbm(0.028x, 0.028y, 2)·9`,dx、dy 各一套,只处理 bbox (330,470)-(1600,980),约 15ms。
+4. **纸的投影**:shadow 偏移 (5,6)、blur 4、`rgba(10,20,40,.3)`,表现钉在墙上的纸。
+5. **水粉刷痕**:缓存 2600 道长条笔痕(60–300px、宽 6–22、黑白各半、α .04–.13、倾斜 −0.25rad),整幅 `overlay`。
+
+**母题动画**:
+- 海藻像纸片一样绕根部摆 `sin(2.8t+φ)·0.13`,卷边用 `scaleX 0.93–1.0` 呼吸。
+- 伊卡洛斯:7 颗不规则黄星,转着闪(scale `.82+.22sin(7t+1.9k)`);黑人形上下漂;红心跳(`1+.18·max(0,sin 9t)`)。
+- 两只白鸟扑翅(scaleY `.55+.45cos 13t`)。
+- 一片粉纸翻飞落下(scaleX=cos 6t)。
+- 热气是两根白色小剪纸。
+
+**角色**:马蒂斯《罗马尼亚衬衫》。白宽袖衫,前襟一条钴蓝刺绣带(红黄交错的小三角),袖上随手臂旋转的红/蓝刺绣横带(clip 在 upperArm 里),红长裙+黑腰带,金发是 5 个剪纸卷团。五官只用剪纸碎片:黑杏仁眼、红唇三角、粉腮圆片。
+**坑**:飘落的纸片第一版轨迹划过少女的脸,改到左墙。计数器底下垫一张白剪纸片,否则黑字压在钴蓝上看不清。
+
+---
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/31_haring.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/31_haring.md"
new file mode 100644
index 0000000..147e696
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/31_haring.md"
@@ -0,0 +1,22 @@
+# 31_haring · 1982 凯斯·哈林
+
+> 来源:迁移测试 C(只读 skill 的独立 agent 实做,2026-10-04)。场景代码由整合后移植到 `scripts/engine/scenes/31_haring.js`。
+
+实验时的文件名:`scenes/k5_haring.js`(109 行)。每帧约 4ms,帧差 11.5%。
+
+**手法**
+- 纯色底:黄墙 `#ffd51c`、绿地 `#16a54a`、14px 黑地平线。
+- 一切都是 13px 圆头黑线+平涂,用 `X.girl / X.cat` 逐部件「填→描」。
+- **跳舞小人**:用修正版 `X.limb` 的胶囊做 7 段肢体+圆头,**先全部描 2×LW 黑,再统一填色**,得到并集轮廓。4 个姿势(局部关键点,原点在脚底)**8fps 硬切、不插值**,这才是哈林的跳法;手旁加动作弧。
+- **放射动作线**:物体外围椭圆上的 n 根短直线(长 22–34、线宽 7–9),8fps 换角度。用在猫、少女头、杯、茶壶、红心、右侧小人上。
+- **一切跟拍**:`bounce=|sin(t·128/60·π)|^0.6`。少女 dy=−12·bb,猫错半拍。桌子以脚底为轴挤压拉伸(sy 1−0.07(1−bb)、sx 1+0.05(1−bb)),桌腿弯;茶壶跳 26px;窗框摇 ±0.025rad;地上的「跳起」横线长度随拍变。
+
+**母题动画**:
+- 窗里的光芒宝宝:白色并集剪影,两帧交替爬;14 根光芒,长短 8fps 交替。
+- 墙上 3 个跳舞小人(红/蓝/粉,相位不同,有一个镜像)。
+- 桌上方的红心,跳动并带放射线。
+
+**角色**:80 年代纽约少女。宽大红毛衣(下摆一道罗纹线)、牛仔蓝长裙、白高帮球鞋。脸上只留一个眼点和一道红唇(哈林的人物本来没有五官,留这一点是为了认人)。耳朵的粗黑圈看起来像随身听耳机,正好合年代。
+**坑**:`RIG.limb` 的反向端帽在粗描边下会在关节处留洞(见②-1)。窗户横档要画在宝宝下面。RIG 的 hairLines 是细线,在哈林里违背「等粗线」,而且喝茶仰头时会穿过脸,所以去掉了。
+
+---
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/32_rembrandt.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/32_rembrandt.md"
new file mode 100644
index 0000000..8079355
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/32_rembrandt.md"
@@ -0,0 +1,29 @@
+# 32_rembrandt · 1642 伦勃朗明暗法
+
+> 来源:迁移测试 D(只读 skill 的独立 agent 实做,2026-10-04)。场景代码由整合后移植到 `scripts/engine/scenes/32_rembrandt.js`。
+
+实验时的文件名:`scenes/r1_rembrandt.js`,每帧约 47ms。
+
+**管线**:亮态底稿(按"全亮"时的颜色画房间、铅条菱格窗、土耳其桌毯)→ 褐色大笔触重画背景,再糊 2.2px 叠 75%(揉开的底子)→ 桌毯单独一层、细笔触 → 角色平涂+体积渐变+细笔触 → 角色"失边"处理 → **光照图 multiply** → 窗玻璃 screen 提亮+云影掠过 → 鬃毛厚涂 → 烛焰、光柱浮尘、热气 → 龟裂、颗粒、暗角缓存层+soft-light 金褐釉。
+
+**关键参数**
+- 光照图:底色 rgb(30,21,13),相当于环境光 0.13。用 lighter 叠:
+ - 光柱:楔形多边形,模糊 40px,缓存,α 0.8–0.95。
+ - 窗本身:r330。
+ - 脸池:r250 α0.95。胸:r230 α0.55。猫:r240 α0.8。桌面:r280 α0.6。
+ - 烛光:r190+40·fc,α 0.6+0.4·fc。
+ - 少女背后墙面的"分离光":r300 α0.35。伦勃朗常在人物暗侧后面把墙打亮,好把人从背景里分出来。
+ - 叠完整幅 multiply。
+- 摇曳:`flick(t) = 0.5·noise(2.2t) + 0.25·noise(6.5t)`;光池中心随 noise(0.9t) 漂移 ±14px;云影 `cloud = 0.5 + 0.5·sin(2.2t − 0.6)` 让窗光 ×(1 − 0.35·cloud),同时一团暗色径向斑以 260px/s 横穿玻璃。
+- 背景笔触:cell18、len54、w16,jitter 6,角度 −0.9 + 1.6·noise(0.003);色板 mixBase 0.7。
+- 失边:角色层先 blur(2.4px) 全不透明画一遍,再叠 α0.62 的清晰层。暗侧会融进背景,五官还认得出。
+- 厚涂(鬃毛笔):一笔 = round(w/1.3) 条平行细鬃,每条亮度 ±17、两端随机缩 0–25%、线宽 1.4–2.6;下侧一条 α0.28 的投影;上侧撒 2+w/3 个亮点。只用在受光处:金发、领口、瓷杯、珍珠、猫白胸、猫头顶。
+- 罩层:龟裂 α0.28×0.28;颗粒 density 0.05 α0.12;暗角 0.75;soft-light rgba(200,140,60,.35)。
+
+**母题动画**:烛焰(noise 驱动左右倾、高度跳)、窗光被云影遮暗再恢复、光柱里 70 颗浮尘(只在光柱内显示,24 帧闪烁)、端杯、热气。运动面积 8.0%(0.45↔1.0s)。
+
+**坑**
+- 厚涂第一版画成"暗影偏移+主笔+亮脊"三条整齐的线,读出来像白色贴纸/创可贴。改成鬃毛笔才像颜料。
+- 拷回原图的局部区域(`drawImage(b, x,y,w,h…)`)会把未刷笔触的背景一起带回来,形成矩形补丁。道具应该单独一层画在笔触之后,不要拷区域。
+- 颗粒 density 0.12 / α0.22 会让脸上全是脏点,0.05 / 0.12 刚好。
+- 手要在杯子之前画,不然手的椭圆把瓷杯盖掉了。drawGirl 里的顺序是"手→杯→拇指",自己重画时要照这个顺序。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/33_rubberhose.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/33_rubberhose.md"
new file mode 100644
index 0000000..a2e4c90
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/33_rubberhose.md"
@@ -0,0 +1,31 @@
+# 33_rubberhose · 1930 橡皮管卡通
+
+> 来源:迁移测试 D(只读 skill 的独立 agent 实做,2026-10-04)。场景代码由整合后移植到 `scripts/engine/scenes/33_rubberhose.js`。
+
+实验时的文件名:`scenes/r2_rubberhose.js`,每帧约 20ms。
+
+**管线**:纸色单色底(墙纸竖条+菱点、地板砖缝、角落水彩压暗,缓存)→ 窗外天空(太阳脸、云、树)→ 窗框和圆点窗帘 → 椅 → 桌(弯腿+跳舞花)→ 少女 → 猫 → `saturation` 灰去色+multiply #f2e8d2 做褪色 → 胶片层。
+
+**关键参数**
+- 节拍弹跳:`bnc(tq, ph) = |sin(π(tq/BEAT + ph))|`,BEAT = 60/128。每个物体绕自己的着地点上弹 amp 像素:落地时压扁 sx=1+0.09k、sy=1−0.09k,腾空时拉长约 5%。各物体相位错开 0.25 拍:桌 0.5、少女 0.25、猫 0.75、太阳 0;蝴蝶结 0.05,比身体晚一点,算作跟随。
+- 步进:所有角色和母题用 `tq = floor(t·12)/12`(一拍二);端杯也按 12fps 步进;胶片层用 floor(t·24)。
+- 角色画法:骨架只取锚点。
+ - 头:围绕 headC 画半径 82 的大圆脸。
+ - 派切眼:白眼眶+黑瞳,黑瞳上用 arc(−1.45..−0.85) 切掉一块楔形;上方 3 根睫毛。
+ - 手臂:橡皮管 = 肩到手的一根二次贝塞尔,粗细恒定,黑边 +10px。
+ - 白手套:4 指、外翻袖口、手背 3 道线。
+ - 波点裙长到脚踝(端庄款)。
+- 猫:身体用 `RIG.smooth(K.bodyPts)`,中灰 #a39a84(=橘),虎斑 #5e574b,白胸白爪 #fbf7ec;尾巴是波浪橡皮管 `sin(7q − 9tq)·26q`。
+- 胶片层:
+ - 抖片 ±1.5/±2px。
+ - 闪烁:每格叠 α0.02–0.09 白,再叠 0–0.06 黑。
+ - 划痕:3 条竖线,按 floor(t·6) 换位置,所以一条划痕能活好几格。
+ - 每格 14 个灰尘点+偶尔一根毛发。
+ - 颗粒层每格随机平移 ±20px。
+ - 圆角片门:roundRect r60,加暗角。
+
+**母题动画**:所有物体随拍弹、太阳脸光芒旋转 1.6rad/s 且脸随拍点头、跳舞的花(茎左右 ±0.35rad,叶子当手挥,花瓣转)、烟圈一拍冒一个、窗帘下摆随拍甩、胶片闪烁和划痕。运动面积 40%,但大部分是胶片噪声(见 ② 第 5 条)。
+
+**坑**
+- 骨架的猫身体是折线,卡通里一眼看出直边,必须 smooth。
+- 整片要压成单色,必须在角色画完之后统一做一次 saturation 去色,不然手套、杯子会残留暖色。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/34_shadowpuppet.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/34_shadowpuppet.md"
new file mode 100644
index 0000000..2fe6328
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/34_shadowpuppet.md"
@@ -0,0 +1,40 @@
+# 34_shadowpuppet · 中国皮影戏
+
+> 来源:迁移测试 D(只读 skill 的独立 agent 实做,2026-10-04)。场景代码由整合后移植到 `scripts/engine/scenes/34_shadowpuppet.js`。
+
+实验时的文件名:`scenes/r3_piying.js`,每帧约 121ms(每块皮件单独离屏,multiply 次数多)。
+
+**管线**:影窗(油灯在幕后的径向暖光+screen 灯芯热点+3px 布纹,布纹缓存)→ 道具层(窗棂、桌、瓶花、方背椅,缓存)→ 蝴蝶 → 猫 → 少女,每组一张离屏层 → 每层先印一层偏移软影,再 multiply 本体 → 铆钉 → 操纵杆 → 木框。
+
+**关键参数**
+- 皮件函数 `piece(g, path, col, carve)`:
+ - 填色。
+ - 在 clip 内用 destination-out 刻纹。
+ - 在 clip 内描 2×edge 宽的同色"皮边",保证刻纹不会刻穿外轮廓。
+ - 描 2.6px 深褐边 #3a160a。
+- 刻纹库:
+ - 鱼子纹 dots:s14–22,r3–3.5。
+ - 团花 flowers:5 瓣椭圆,s36–46。
+ - 云纹 clouds:阿基米德小螺旋,线宽 3.4,s24–40。
+ - 方格 lattice:s26–32。
+ - 刻线 lines:线宽 3–7。
+- 印到幕布:`stamp(layer)` 先 multiply α0.28、blur 6px、偏移 (7,5),表示皮件没完全贴紧幕布时的虚影;再 multiply 本体。透光 = 幕布色×皮色,重叠的皮件自然变深。
+- 颜色:红 #c0352a、绿 #2f7d4c、琥珀 #d99a2e(金发=琥珀色皮)、黄 #e2bd4a、蓝 #2c5a8a、橘 #d9782a(猫)。
+- 幕布:径向 #fff6d6 → #f2d7a0 → #cf9a58 → #7a4a20;灯焰扰动 `fl = 0.5·noise(3ts) + 0.3·noise(9ts)`,ts 按 15fps 步进。光心漂移 ±26/±18px,热点半径 260+40·fl。
+- 旦角"空脸":头发画完后 destination-out 掉整张脸,只描脸部轮廓,再补凤眼(上挑长线+下眼线+点睛)、柳叶眉、点唇。
+- 橘白猫的映射:橘色 = 橘皮;白胸、白口鼻、白腿白爪 = **整块镂空只留皮边**;虎斑 = 刻线。这条对所有"剪影/镂空类"风格都适用:白色部位直接镂空。
+- 动作:
+ - 少女整体绕 (1260,930) 摆 ±0.012rad;头绕颈部铆钉转 ±0.06。
+ - 端杯按 10fps 步进。
+ - 手腕松:dangle = 0.35·sin(11·ls)·(1 − 0.6·cup),杯子跟着手一起甩。
+ - 猫头绕颈点头 0.1·sin(6ts) + 0.05。
+ - 尾巴 4 节铰链,每节相对上一节转 0.3·sin(7ts − 0.9i) + 0.38,鞭梢一节节滞后。
+ - 步摇珠串甩动。
+- 杆子:5px 深褐线,blur 1.2px multiply,从颈、腕、猫背、猫头、蝴蝶通到画面底边。
+
+**母题动画**:灯焰让整块幕布的光斑跳、蝴蝶(翅膀按 12fps 用 scaleX 翻面,带杆子)、手腕甩、猫点头和尾巴鞭梢、步摇。运动面积 6.8%。
+
+**坑**
+- 桌腿压在裙子上:multiply 后红×绿接近黑,变成一块黑梯形。皮影里重叠变深是对的,但别把重叠放在视觉焦点上,把桌腿挪开就好。
+- 猫前腿第一版是一整块橘色矩形,盖住了白胸。改成两条几乎全镂空的白腿才读得出"橘白"。
+- 杆子横穿主体会很乱:杆子从皮件往下、往外走,不要跨过别的角色。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/35_shinkai.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/35_shinkai.md"
new file mode 100644
index 0000000..584b6c6
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/35_shinkai.md"
@@ -0,0 +1,34 @@
+# 35_shinkai · 2016 新海诚光影
+
+> 来源:迁移测试 D(只读 skill 的独立 agent 实做,2026-10-04)。场景代码由整合后移植到 `scripts/engine/scenes/35_shinkai.js`。
+
+实验时的文件名:`scenes/r4_shinkai.js`,每帧约 71ms。
+
+**管线**:写实室内(墙面冷暖渐变、木地板透视缝、铝框窗、挂历、书桌,缓存)→ 天空+积雨云+电线杆电线+远处屋顶+飞机拉线+鸟 → 玻璃水珠 → 白纱窗帘 → 地板和墙面的窗形光斑(墙面光斑里有窗帘的影子在摆)→ 盆栽 → 猫、少女(赛璐珞)→ 热气 → 丁达尔光柱+光尘 → 镜头光晕 → 泛光 → soft-light 冷暖分离。
+
+**关键参数**
+- 赛璐珞函数 `cel(c, p, base, shade, rim, {sd, rw, lx, ly})`:
+ - 阴影 = clip(p) ∩ ¬(p 平移 (lx·sd, ly·sd))。用 evenodd 实现:一个大矩形 + 平移后的 p,作为 clip。
+ - 亮边 = clip(p) ∩ ¬(p 反向平移 rw)。
+ - 光从窗来,lx=−1、ly=−0.55,所以阴影落在右下侧。sd:大部件 22–30,脸 10,小件 8;rw 3–9。
+ - 线色 #6a4632,线宽 2.2。按部件顺序"填 → 影 → 亮边 → 描线",遮挡自然正确,不需要 visibleLines。
+- 猫在窗下是逆光:lx=0.5、ly=1,暗部在下侧,头顶和背上再加一圈 lighter 的暖色亮边 rgba(255,220,160,.55)。
+- 颜色:肤 #ffe8dc/#f2b6a8;金发 #f8d681/#d8a050;白校服 #fbfbfe/#b9c3dc;藏青 #2c3a66/#1b2446。天使环:后脑一道 9px 亮弧 rgba(255,250,226,.85)。
+- 动画眼:白 8×12、虹膜纵向渐变 #1f3f7a → #3f7fd0 → #9fd4ff、两颗高光、上眼睑 3.4px 加一根眼角睫毛。
+- 积雨云:70+12 团。①所有团块画蓝灰剪影(线性渐变 #b7c6e6 → #8297c6)②每团在偏向太阳 (+0.22r, −0.3r) 处画一个 0.82r 的白色径向亮球 ③整层 blur 3px,再叠 55% 清晰层。每团半径以 0.05·sin(1.3t) 呼吸,整体以 10px/s 漂移。
+- 光晕:
+ - 太阳核:r130。
+ - 10 根星芒:长 90/170,以 0.25rad/s 旋转。
+ - 横丝:840×4。
+ - 5 个六边形光斑:落在太阳 → 画心连线上 0.45/0.75/1.25/1.6/2.0 倍处,α 0.04–0.12。
+- 丁达尔:3 个楔形,模糊 18px 后缓存,screen,α 0.75 + 0.25·sin(3.4t)。光尘 60 颗,径向渐变,闪烁。
+- 泛光:整帧画进 480×270 的小画布 → blur 6px、brightness 1.1 → screen α0.28 放大回叠。
+
+**母题动画**:云团翻涌和漂移、飞机拉线、鸟群扇翅、一颗水珠沿玻璃滑下(带水痕)、白纱窗帘和它投在墙上的影子在摆、盆栽叶子摆、发丝被风吹、星芒旋转、光柱明灭、光尘。运动面积 3.0%。
+
+**坑**
+- 太阳放在窗框角上时,光晕会溢到墙上,像墙上挂了一盏灯。太阳必须放在玻璃里面,光晕半径 ≤130。
+- 云第一版每团一个径向渐变,再描一圈"受光弧线",结果读成一堆肥皂泡。要"剪影 + 偏移亮球 + 糊/清两层"。
+- 全画面横向光丝第一版有 1800px 长,看起来像一条 bug 线。收到太阳附近 840px,α0.35。
+- 水珠画成实心圆像气泡飘在天上。只画下缘弧线、α0.22 的透明体和一个高光点。
+- 变量名冲突(两个 `const cg`)导致整段场景加载失败,且被静默替换成占位画面(见 ② 第 1 条)。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/36_picasso_blue.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/36_picasso_blue.md"
new file mode 100644
index 0000000..fa017a3
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/36_picasso_blue.md"
@@ -0,0 +1,25 @@
+# 36_picasso_blue · 1903 毕加索蓝色时期
+
+> 来源:迁移测试 D(只读 skill 的独立 agent 实做,2026-10-04)。场景代码由整合后移植到 `scripts/engine/scenes/36_picasso_blue.js`。
+
+实验时的文件名:`scenes/r5_bluepicasso.js`,每帧约 24ms。
+
+**管线**:蓝单色平涂底稿(墙、地、窗外夜海和月亮)→ 宽而干的笔触重画,再糊 7px 叠 80% → 极淡的干刷细丝 → 窗框原样拷回,加小笔触 → 桌单独一层 → 环境粗轮廓(不抖)→ 海浪、月光碎影、云 → 角色(整体拉长)→ 角色小笔触+冷光渐变 → visibleLines 粗轮廓 → 披肩褶线 → 慢热气 → 画布纹+冷暗角。
+
+**关键参数**
+- 色板:#132240 / #1d3866 / #2d5a94 / #6b8fb6 / #b6c8d8 / 青灰 #3b6878,严格单色。
+- 橘白猫用明度区分:橘 = 中蓝 #4f719a,虎斑 #273f66,白 = 浅蓝 #b6c8d8。金发 = 最亮的蓝灰 #cbd8e0,肤色 #90a9be,发色要比肤色亮一档才读得出"金"。
+- 墙笔触:cell34、len110、w34,jitter 4,竖向 ±0.5·noise(0.003);色板 mixBase 0.8;之后 blur 7px 叠 α0.8。地面笔触同参,横向。
+- 干刷细丝:900 条,α0.07,长 30–90。
+- 拉长:少女 `DOMMatrix().translate(1240,932).scale(0.84,1.12)`,以脚底为轴;猫 scale(0.82,1.14),以 (540,905) 为轴。同一个矩阵用在三处:Path2D.addPath、离屏 setTransform、visibleLines 回调里的 setTransform。
+- 披肩:从 forehead/headTop 罩下,经 nape、back,落到 waist+70,色 #6b8fb6,褶线 rgba(20,40,80,.6) 4px。长指:3 个细长椭圆 22×4.5 绕杯。
+- 轮廓:普鲁士蓝 #0c1830,5px,不沸腾。蓝色时期的轮廓线是笃定的,不该抖。
+- 慢:呼吸 sin(1.8t)·0.026(幅度约为共享编舞的 2 倍、频率约 0.45 倍);端杯用 1.25s 举起(共享编舞是 0.9s);热气按 0.5 倍时间升。
+
+**母题动画**:窗外海浪横移(越近越快,速度 20 + 0.25·(y − 400))、月光碎影 14 条闪烁、一条苍白长云横过月亮、缓慢呼吸(人和猫)、端杯、热气。运动面积 3.2%。
+
+**坑**
+- 第一版给猫和头发留了一点赭色(想参考《老吉他手》),独立审片判定破坏单色。蓝色时期就该全蓝,用明度区分。
+- cell16、len40、w14 满墙竖刷读成"下雨/毛毯",是印象派,不是蓝色时期。要宽、长、低对比,再糊一层。
+- 宽笔的圆头密排成"人头阵"(见 ② 第 11 条)。用糊 7px 压住了,根治要给 strokes 加 cap 参数。
+- 桌子区域如果用矩形 mask 排除在大笔触之外,地面上会留下一块平涂矩形补丁。桌子要单独成层画在笔触之后,不要在笔触里挖洞。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/INDEX.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/INDEX.md"
new file mode 100644
index 0000000..3537d04
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/INDEX.md"
@@ -0,0 +1,47 @@
+# 风格总索引(35 种,2026-10-05 更新)
+
+选风格先看这张表,再打开对应卡片。「质量」是当前实做水平(★★★ 一眼认得、可直接用;★★ 认得出但有明显短板;★ 要重做),不是风格本身的难度。短板就是下一次做这个风格时该先超越的地方。
+
+| id | 风格 | 核心渲染器 / 手法 | 母题动作(画怎么活) | 签名转场(进入它) | 质量 | 当前短板 |
+|---|---|---|---|---|---|---|
+| 01_cave | 洞穴岩画 | 噪声浮雕岩壁+炭点毛边+赭石吃进岩面 | 动物两姿态交替奔跑、火光摇曳、余烬 | (开场) | ★★★ | 人形太卡通,不够原始 |
+| 02_egypt | 埃及墓室壁画 | 侧脸正面眼程式、平涂细勾线、24 个手写象形字 | 圣甲虫推日、阿顿光线小手开合、象形字逐笔重写 | 挂毯竖条落下回弹 | ★★★ | 端杯肘偏僵 |
+| 03_greek | 阿提卡黑绘 | 黑剪影+陶土色刻线+紫红带白点 | 回纹带反向滚动、船起伏海豚跃、里拉琴摆 | 陶瓶滚筒转面 | ★★★ | 裙摆偏厚 |
+| 04_roman | 庞贝马赛克 | 距离场沿轮廓排石块、加权 L∞ Voronoi 灰浆、布局一次算颜色每帧流过 | 波浪纹边框顺时针流、维苏威冒烟溅火星 | 马赛克砖从猫处翻面扩散 | ★★★ | 小尺度下脸部细节少 |
+| 05_gothic | 哥特泥金手抄本 | 逐像素金箔(拉丝+压花错 1px 亮线)、金色度遮罩高光 | 金箔斜向高光扫过、藤蔓摇、蜗牛爬、老鼠跑 | 羊皮纸翻页 | ★★★ | 金发像兜帽 |
+| 06_renaissance | 文艺复兴晕涂 | 整层轻模糊+高不透明清晰层、龟裂纹/画布纹/黄釉 | 达芬奇扑翼机飞过、河面碎光、浮尘 | 窗口神光 | ★★ | 猫偏卡通;整体偏静 |
+| 08_impressionism | 印象派 | 区域粉彩色板短笔触(位置固定)、窗景细笔 | 光斑漂移明灭、罂粟摇、云走、丝带飘 | 笔触色点铺满 | ★★ | 脸和手被笔触打碎 |
+| 09_postimp | 梵高 | 流场笔触三遍(墙竖长/地透视/其余)+区域色板+描边;道具层;visibleLines 补线 | 星空漩涡、灯晕环外扩、方向场火苗般摇曳、漩涡猫 | 星空漩涡卷入 | ★★★(标杆) | 每帧 120ms 最重 |
+| 10_nouveau | 慕夏新艺术 | 可变线宽路径(外粗内细)、剪影错位垫底 | 太阳升起、光环转、花摇、S 形热气、卷发波 | 金边有机形生长 | ★★★ | 猫姿势僵 |
+| 11_cubism | 分析立体主义 | 半透明渐变面叠空间、切面器(三角不裁剪)、毕加索式双视角脸 | CAFÉ 字母跳换、窗格碎面滑、报纸颤 | 几何碎片错位拼合 | ★★ | 偏亮,深褐大面不够 |
+| 12_bauhaus | 包豪斯 | 纯几何构成、施莱默人偶关节盘 | 指针杆转陡、蒙德里安格换色、猫拨球 | 红黄蓝几何旋转放大 | ★★★ | 猫头偏离骨架位 |
+| 13_pop | 利希滕斯坦波普 | 本戴点 createPattern、粗黑描边 | 沃霍尔四格换色、思考点闪、猫扭臀、拟声框抖 | 闪电+网点化 | ★★★ | — |
+| 14_8bit | 8-bit 像素 | 240×135 逐像素、14 色板、部件 1px 黑边 | 尾巴、HUD 心闪、问号块顶金币(15–30fps 步进) | 像素块放大缩小 | ★★★ | 猫头压窗台 |
+| 15_raytrace | 早期光追 CGI | 统一塑料着色、逐像素棋盘倒影、铬球环境映射 | 紫环旋转、镜头光晕、猫眼绿光 | 绿色线框→扫描线渲染 | ★★ | 猫腿直柱、脸像面具 |
+| 16_2026 | 当代扁平插画 | 颗粒点彩密度函数、无描边色块 | 角色表演(跳/拍杯/碎裂/惊呼/签名)、阻尼二次动作 | 三色同心环光圈 | ★★★ | — |
+| 17_ink | 中国水墨写意 | 毛笔笔锋飞白、墨晕 blur 洇开、留白、钤印 | 开场笔触自己写出、墨晕扩散、虾须动 | (速通里开场) | ★★ | 人物不够写意(审片 6/10) |
+| 18_klimt | 克里姆特金色时期 | 复用哥特金箔、螺旋/眼形纹样、写实脸配平面金袍 | 袍上眼形纹轮流眨、金屑飘 | 金箔从头部螺旋铺开 | ★★★ | 桌上的手没接袖子 |
+| 19_munch | 蒙克表现主义 | 长弯流线笔(沿流场走 20–30 步)、按行正弦 warp 整个世界 | 整幅画扭动、血色天空流 | 呐喊色带从上往下压 | ★★ | 墙面曾被读成梵高 |
+| 20_dunhuang | 敦煌壁画 | 土红底矿物色、剥落斑(只在背景)、saturation 褪色 | 飞天飘带、天花飘、灯焰 | 飘带扫过、旧画剥落下落 | ★★ | 飞天造型粗 |
+| 21_kusama | 草间弥生波点 | 手绘不规则圆、六角网格按真实周期取模 | 波点从猫处一圈圈胀缩、南瓜、无限镜屋 | 波点长出 clip 新画 | ★★★ | 人物与墙同色靠轮廓撑 |
+| 22_constructivism | 俄国构成主义 | 灰度照片网点(可变点径 45°)、红楔黑圆、路径画西里尔方块字 | 标语逐字盖章再波浪跳 | (B 片开场) | ★★★ | 缺喇叭形文字锥 |
+| 23_dali | 达利超现实 | 软钟变形、长影子剪切仿射 | 钟往下流、长腿象走、蚂蚁绕表、影子变长 | 新画带圆头液滴往下流 | ★★ | 人物偏矢量插画 |
+| 24_hopper | 霍珀美国现实主义 | 双版本光影裁切(亮版/暗版按光块 clip)、硬边光斑 | 光斑缓移扫过脸、墙上人影同步喝茶 | 硬边阳光扫过 | ★★★ | 猫全程在阴影里 |
+| 25_ghibli | 吉卜力水彩背景 | 水彩洗染(透明叠色+水痕边)、赛璐璐月牙影 | 纱帘被风鼓起、草叶成片摆、树影光斑 | 湿纸晕开 | ★★ | 人物不如背景 |
+| 26_vaporwave | 蒸汽波/赛博霓虹 | 霓虹双色辉光、透视网格、VHS 通道分离后期、路径画灯管假名 | 落日横条上移、网格前滚、招牌闪、跟踪噪声带 | VHS 撕裂+上滚 | ★★★ | 部件交界也发光 |
+| 27_kirby | 漫威 Kirby 银河时代 | 四色网点、套色错位、黑块阴影羽化排线、krackle 能量点 | 拟声大字、分格猫眼特写、能量点 | (C 片开场) | ★★ | 更像利希滕斯坦,缺 Kirby 透视与方块手 |
+| 28_monet | 莫奈睡莲与日本桥 | 短笔触水面倒影、光在水面颤动 | 睡莲漂、柳影晃、涟漪扩散 | 水波荡开 | ★★ | 墙是池水、地是木头的空间别扭 |
+| 29_seurat | 修拉点彩 | 视觉混色:21 色纯色板按比例并置、补色点、等大点 | 光渗、点在呼吸 | 画面结晶成圆点 | ★★ | 偏静;网格规整 |
+| 30_matisse | 马蒂斯剪纸 | 剪刀边不规则、钉纸投影、饱和平涂 | 纸片飘动、海藻摆 | 钉着剪纸的蓝纸扫过 | ★★★ | 水粉刷痕偏重 |
+| 31_haring | 凯斯·哈林 | 粗黑等宽线、放射动作线 | 小人按 8fps 硬切跳舞、一切跟 BPM 弹跳 | 跳舞小人放大、身体里是新画 | ★★★ | 少女不够哈林 |
+| 32_rembrandt | 伦勃朗明暗 | 光照图整幅相乘、窗光+烛光 | 光柱浮尘、云影让窗光明暗 | 老胶片光圈收放 | ★ | 人物扁平(审片 5/10),最该重做 |
+| 33_rubberhose | 1930 橡皮管卡通 | 派切眼、面条臂、白手套、12fps 步进、胶片划痕闪烁 | 一切按节拍弹跳 | (幕后点灯前的老片) | ★★★ | 运动大半是胶片噪声 |
+| 34_shadowpuppet | 中国皮影 | 半透明牛皮镂空、铆钉关节、10fps 步进、幕后油灯 | 杆子操控僵直关节、手腕甩 | 幕后点灯 | ★★★ | 重叠处相乘发黑;121ms 偏慢 |
+| 35_shinkai | 新海诚光影 | 积雨云、丁达尔光柱、赛璐珞硬阴影带、光晕 | 光粒飘、云移 | 斜向扫光 | ★★ | 室内背景密度不够 |
+| 36_picasso_blue | 毕加索蓝色时期 | 单色蓝调、宽笔触、普鲁士蓝粗轮廓、人体拉长 | 缓慢呼吸 | 颜色抽成蓝再宽笔刷过 | ★★ | 造型不够忧郁 |
+
+## 质量分布与下一步
+
+- ★★★ 20 种、★★ 14 种、★ 1 种。
+- **最普遍的短板是角色**:背景过了风格渲染器就像那个风格,角色只用矢量骨架平涂就像贴上去的(正面经验第 8 条)。下一轮提质先从「角色也过同一个渲染器/按该风格重塑造型」做起:伦勃朗、毕加索蓝、水墨、吉卜力、达利、漫威。
+- 转场合集:`_转场_迁移测试.md`(A–D 新增 19 个)+各卡内说明。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/_\350\275\254\345\234\272_\350\277\201\347\247\273\346\265\213\350\257\225.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/_\350\275\254\345\234\272_\350\277\201\347\247\273\346\265\213\350\257\225.md"
new file mode 100644
index 0000000..4f05627
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/_\350\275\254\345\234\272_\350\277\201\347\247\273\346\265\213\350\257\225.md"
@@ -0,0 +1,53 @@
+# 迁移测试新增转场(A–D)
+
+<!-- 来自迁移测试 A -->
+## 转场(`transitions.js` 末尾的新块)
+
+| 转场 | 进入 | 手法与参数 |
+|---|---|---|
+| `goldLeaf` 0.5s | 克里姆特 | 72px 方块。次序 key=离少女头部 (1300,380) 的距离×0.78+方位角×0.12+随机×0.08,所以金箔是螺旋铺开的。每块 q=(1.32p−key)/0.32:q<0.5 时一片金箔从 1.3 倍带旋转落位,金色渐变高光随 q 移动,压螺旋、眼形或同心圆暗纹;0.5<q<1 时露出 B,金箔淡出。 |
+| `screamWarp` 0.5s | 蒙克 | 旧画按行正弦扭曲,幅度 70e。波浪前沿 `y = lerp(−180, H+220, e) + 80sin(x·.0055 + 7p)` 从上往下推,前沿以上是新画(扭曲幅度 60(1−e) 逐渐平复)。前沿压 4 道 26px 色带:`#b82a1e #e2541c #f08a24 #f4c03a`。 |
+| `apsara` 0.5s | 敦煌 | 前沿 `x = lerp(W+260, −300, e) + 110sin(y·.006 + 5p)` 从右往左扫,右侧是新画。前沿上 3 条飘带(石绿、土红、石青,宽 44/38/32,行波,白虚线描花)。前沿左侧,旧画的碎片(直接取 A 的像素块)翻转、抛物线落下,就是「旧画剥落」。 |
+| `dotBloom` 0.48s | 草间 | 58px 六角网格,从猫 (540,760) 按距离依次长出圆点(outBack,最大到 0.74 倍间距,正好铺满),点里 clip 出新画。未长满的点有白色描边,逐渐淡出。 |
+
+---
+
+<!-- 来自迁移测试 B -->
+## 转场 `transitions_b.js`
+
+| 进入 | 名称 | 手法 | 参数 | 每帧 |
+|---|---|---|---|---|
+| 达利 | `melt` | 旧画面逐 4px 竖列下垂(`sag = 0.22·edge·e`,并拉长 0.3);新画面在液面 edge(x) 以上,edge = 整体下落线(−160 → H+40,easeInOut)+ 26 个圆头液滴(宽 10–32、长 60–280,剖面 `(1−u²)^0.3`,各自起始相位)+ sin 波;液面描暗边(blur 3)+高光 | 0.36s | 86ms |
+| 霍珀 | `sunShaft` | 旧画面 `multiply` 冷绿 `rgba(70,120,110, 0.7·min(1,2p))` 沉进阴影;斜边光块(斜度 260px)右缘扫过全屏,里面是新画面+`screen` 暖光(0.45 → 0 在 p 0.6–1 内退)+一根跟着走的窗棂斜影;前缘一道亮边 | 0.34s | 76ms |
+| 吉卜力 | `bleed` | 5 团色晕按 t0 先后绽开(窗口先开),半径 `q·1400·k`、q=easeInOut(seg(p,t0,t0+0.66)),边界 `R·(1 + 0.28·fbm(角度) + 0.05·sin 9a)`;外侧 70px blur 18 的亮晕(水先到)、内部是新画面、边缘 5px `multiply` 褐色水痕。亮晕和水痕 α 都乘 (1−q) | 0.38s | 127ms |
+| 蒸汽波 | `vhs` | 前半旧、后半新;p 0.38–0.62 段「场同步丢失」整幅上滚+40px 黑条;随机高度 6–54px 的撕裂带从 A/B 取(取 B 的概率 = p),横向错位 ±130·sin(πp);洋红/青两份单通道副本以 `screen` 错位 ±14;160 条雪花线 | 0.30s | 88ms |
+
+共同点:每个转场都是「新风格的物理过程」,不是通用的擦除——融化是液体、霍珀是光、水彩是水、VHS 是磁带。设计时先问一句:「这个风格的画面会以什么物理方式出现?」
+
+---
+
+<!-- 来自迁移测试 C -->
+## 转场(`transitions_c.js`)
+
+| 进入 | 名 | 手法与参数 |
+|---|---|---|
+| 莫奈 | `ripple` | (距离分母 1700、p>.7 开始补淡入,保证 p≈.85 时四角已清)旧画面按 6px 行条横向正弦错位,`dx=sin(0.045y−26p)·46·sin(π·min(1,1.2p))·(0.4+|y−cy|/H)`,像倒影被搅乱。新画面由 3600 个**横向短笔椭圆**(长 40–110、高 9–17)组成的 clip 露出来,按到杯子 (1000,600) 的椭圆距离(y×1.9)一圈圈荡开。前沿 3 圈浅色虚线椭圆,dashOffset 跟 p 走;中段 140 根水光横线闪。p>.85 补一层淡入。 |
+| 修拉 | `pointill` | 网格 pitch 14:点从 0 长到 r=6.4(前 30%),点下的旧画面淡成纸色。每个点的换色时刻 `0.5·(0.6x/W+0.4y/H)+0.25·hash+0.15`,左上先、带随机;换色的瞬间点放大 1.35 倍「跳」一下。p>.6 新画面在点下面显影,p>.7 点收回。每帧要对 A、B 各做一次 getImageData。 |
+| 马蒂斯 | `cutouts` | 一张宽 1100px 的钴蓝纸(左右缘是 sin 不规则剪边)从右往左扫过,投影 (14,10) blur 12。纸上有 260 道水粉刷痕,钉着白/黄海藻(茎+7 指)、黄/粉 6 角星(随 p 转)、红圆片,各带投影。纸右缘之后已经换成新画面。 |
+| 哈林 | `radiant` | V 字跳舞小人,比例 `s=0.15·320^easeInOut(p)`,以杯子为原点放大。先「描 30px 黑+填黑」画出外轮廓,再在离屏里把肢体填白、`source-in` 新画面,得到身体里的新画面;外圈 16 根放射线 8fps 跳;p>.82 开始补淡入。第一版指数太慢(`0.08·40^…`,前 80% 时间只有 300px 高,最后硬切);第二版 `0.15·120^…` 在结尾仍有空隙,只能靠约 1 帧的淡入收尾,被审片判为闪帧;定稿用 `s=0.15·320^easeInOut(p)`。 |
+
+**转场的通用经验**:
+- 需要像素的转场(点彩、水波)每帧对 A/B 做 getImageData,一次约 10ms,可以接受。
+- 「新画面藏在一个形状里」这类转场,形状一旦是多段并集,就不要 `clip(并集 Path2D)`:子路径绕向不一致会抵消成洞。改用离屏填白,再 `source-in`。
+
+<!-- 来自迁移测试 D -->
+## 转场(`transitions.js` 末尾 D 段)
+
+| 转场 | 新风格的签名 | 手法与参数 |
+|---|---|---|
+| `irisFilm` 伦勃朗→橡皮管 | 30 年代卡通的光圈收放+老胶片 | ①p<0.5:旧画逐步加 `sepia(q) grayscale(0.7q) contrast(1+0.3q)`,黑色光圈收到杯口 (1236,420),R = R0·(1 − easeIn(q)),R0 取到最远角的距离 ②p≥0.5:新画按 R0·outBack(q) 弹开 ③圆周 48 段,按 12fps 加 ±1.5% 的手抖 ④全程叠胶片闪烁、划痕、灰尘 |
+| `lampGlow` 橡皮管→皮影 | 幕后点灯 | ①旧画 multiply rgba(70,34,12, min(1, 2.2p)),像灯灭一样压暗 ②新画用 destination-in 径向蒙版(内 0.55R 实、外缘透)露出,R = 1500·inOut(seg(p, .12, 1)),带灯焰抖动 ±7% ③lighter 暖光晕 sin(πp) 加一朵小火苗 |
+| `flareSweep` 皮影→新海诚 | 漏光、扫光 | 斜向(k=0.35)分界线从 −500 扫到 W+700(inOut)。左边是新画,右边是旧画。分界上叠 3 层 lighter 光带:宽 520 α0.55 暖色、160 α0.85 白、60 α0.6 青。另有横丝、40 颗光粒、3 个六边形光斑 |
+| `blueBrush` 新海诚→蓝色时期 | 颜色被抽走+宽干笔 | ①旧画 `color` 混合叠 rgba(45,90,148, min(1, 2.2p)),只剩蓝;再 multiply 压暗 ②6 道宽笔(每道高 H/6+90)交错倾斜 ±18,依次从左刷到右,启动时间错开 0.07。笔头是一段二次曲线,上下边带 6–7px 正弦抖动 ③笔头后 80–280px 内有 26 条深/浅渐变鬃毛线(颜料还没刷匀)|
+
+转场设计的一般步骤(建议写进 02 号第 3 层):找新风格里会"出现、点亮、扫过"的那个物理过程 → 用它先"污染"旧画 → 新画从这个过程的形状里露出来 → 拍点上叠一个短暂的高亮或过冲。
diff --git "a/references/\351\243\216\346\240\274\351\205\215\346\226\271/_\351\237\263\350\275\250_\350\211\272\346\234\257\345\217\262\351\200\237\351\200\232.md" "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/_\351\237\263\350\275\250_\350\211\272\346\234\257\345\217\262\351\200\237\351\200\232.md"
new file mode 100644
index 0000000..070a0fe
--- /dev/null
+++ "b/references/\351\243\216\346\240\274\351\205\215\346\226\271/_\351\237\263\350\275\250_\350\211\272\346\234\257\345\217\262\351\200\237\351\200\232.md"
@@ -0,0 +1,135 @@
+# 音轨方法 · 速通片的代码合成配乐(拆解方法+原创示例)
+
+这一页是从一次拆解里沉淀的方法:参考片是 X 用户 Tak(@cherry_mx_reds)的 15 秒《Art History Speedrun》,它的配乐本身就是代码合成的。这里只保留**怎么拆、怎么写、怎么混**,不保留对原曲的逐音转录。
+
+配套脚本:`scripts/audio/synth_艺术史速通.py`。乐谱是一段**原创示例**(D 小调,和声 Dm–B♭–F–C),段落结构和画面的 `scripts/engine/eras.js` 一致,乐器库和混音链可以直接复用,换成你自己的乐谱即可。
+
+---
+
+## 0. 一句话结论
+
+速通类短片的配乐可以是**一张严格的 BPM 网格上的程序化编曲**:17 个时代按「八分音符个数」排布(6,4,4,4,4,4,3,3,3,3,2,2,2,1,1,1,9),越往后每段越短,靠「段落变短」制造加速感,速度本身不变。每段换一套该时代的代表乐器,一个三音动机随和弦移调贯穿全片。音乐在网格上停住后,接一串卡通音效(叮、滑哨坠落、碎裂、猫叫、收尾拨弦)完成结尾笑点。
+
+---
+
+## 1. 怎么拆一条参考配乐
+
+| 量什么 | 方法 | 精度/可信度 |
+|---|---|---|
+| 拍速与网格 | 对 STFT 做 superflux 式频谱通量(hop 2.5ms),取峰值作起音,再用最小二乘拟合 `t = t0 + n·E`(共 28 个起音) | E = 0.23431s(八分音符)→ **128.04 BPM**,网格零点 t0 = 0.028s。残差全部在 ±4ms 内,人手演奏做不到,可以断定是代码排程 |
+| 时代边界 | 三路互证:①网格位置;②MFCC 新奇度曲线(前后各 0.2s 均值的距离)的峰值;③视频逐帧差分的峰值 | 音频边界(网格)与 MFCC 峰值的偏差 ≤20ms。画面转场比音频晚 0–0.2s(画面用 0.1–0.2s 的擦除/变形转场) |
+| 音高 | ①Spotify basic-pitch 复音转录(ONNX,Python 3.11 临时环境);②在 16 分音符网格上取 85ms FFT 峰值,起音前后增益 >6dB 判为新音;③自写 CQT 半音能量图人工核读 | 旋律主音的可信度高(两种方法一致)。和声内声部、浮世绘和梵高两段的细节可信度中等 |
+| 音色 | 对每个旋律音取起音后 20–220ms 的谐波幅度(H1–H8,±1.5% 窄带),再测窄带包络的起音时间和衰减(+50/100/200ms 相对峰值) | 复音会混进别的声部,谐波比只能当倾向看 |
+| 打击乐 | 逐 16 分音符测 >6kHz(噪声类)和 <150Hz(鼓类)的能量跳变 | 高 |
+| 音效 | 对 13–15s 用 20ms 步长的 FFT 峰值追踪频率轨迹,配合 2.1s 的画面接触表(每 0.1s 一帧)对齐事件 | 高 |
+| 响度 | ffmpeg ebur128;分段用 BS.1770 K 加权、不加门限的均方 | 整体 **-14.3 LUFS,LRA 0.9 LU,真峰 -2.4 dBTP**(常听到的「平均 -16.6dB」是 RMS 均值,口径不同) |
+| 全模态模型「听」 | 用一个全模态模型整片听一遍,按作曲家视角自定义提问 | 只当候选,逐条回校,见第 4 节 |
+
+---
+
+
+另外两条经验:音色判断看「起音后 20–220ms 的谐波幅度+窄带包络衰减」最稳;判断「是不是代码合成」看三件事——时间残差是否在 ±5ms 内、音色是否都是正弦/方波/锯齿/指数衰减这类教科书构件、静处有没有录音底噪。
+
+---
+
+## 2. 原创示例乐谱(脚本里的 `era()` 块)
+
+时间单位是八分音符,起点 = `t0 + n·E`。动机 ♪♪♩ 标为「动机」。
+
+| # | 时代 | 长度 | 配器 | 示例写的音 |
+|---|---|---|---|---|
+| 1 | 洞穴 | 6 | 骨笛+手鼓+弱拍敲击 | 下行扩大版 A4–G4–D4 |
+| 2 | 埃及 | 4 | 竖琴+叉铃 | Dm→B♭ 分解;动机 F5–G5–D5 |
+| 3 | 希腊黑绘 | 4 | 里拉琴+双管 aulos | B♭ 和弦;D5 → F5 |
+| 4 | 罗马 | 4 | 号角+战鼓 | 动机 C5–D5–A4,F→C→Dm |
+| 5 | 哥特 | 4 | 管风琴 | Dm → Gm/D,D2 踏板 |
+| 6 | 文艺复兴 | 4 | 羽管键琴+低音维奥尔 | 动机 B♭5–C6–G5,Gm→F |
+| 7 | 浮世绘 | 3 | 筝+太鼓+拍子木 | D 都节音阶(D–E♭–G–A–B♭)的十六分拨奏 |
+| 8 | 印象派 | 3 | 柔和钢琴 | 动机变体 A5–C6–G5,Fmaj7 → B♭ → Dm9 |
+| 9 | 梵高 | 3 | 明亮拨弦+风声 | D2 低音律动,高处零散 A5/F5/D6/E5 |
+| 10 | 新艺术 | 3 | 钢片琴 | 动机 D5–E5–A4,B♭→C→Dm |
+| 11 | 立体主义 | 2 | 钢琴式击弦 | 刻意不协和:D–G♯–C♯ → E♭–A–B♭–E |
+| 12 | 包豪斯 | 2 | 马林巴式短音+机械滴答 | D 五个八度叠置 → F/A → D |
+| 13 | 波普 | 2 | 鼓机+卡通短音 | 底鼓、反拍拍手、D/F 短音 |
+| 14 | 像素 | 1 | 方波 | F 大三三十二分琶音 |
+| 15 | 光追 | 1 | 超级锯齿 | B♭ 和弦 |
+| 16 | 孟菲斯 | 1 | 超级锯齿持续和弦+底鼓+上滑音(猫跳上桌) | C 大三挂过段尾 |
+| 17 | 2026 | 9 | 128BPM 浩室:四拍底鼓、反拍开镲、锯齿低音、方波系拨奏、pad | 转到 D 大调 add9:F♯5 A5 D6 E6 F♯6 E6 D6 B5 A5 |
+
+写自己的乐谱时:先定和声循环和一个三音动机,再按段落表把每段的「代表乐器+动机移调」填进去;「出格」的段(异国、前卫)只换调式或加三全音,节奏和网格不动。
+
+---
+
+## 3. 结尾音效(按「停—悬—砸—反应—收」)
+
+| 事件 | 合成方法(脚本里的函数) |
+|---|---|
+| 音乐停 | 低音约 150ms 快速衰减,不硬切 |
+| 爪子碰杯「叮」 | 几个 5–7kHz 的非谐波振铃+一点 1.5kHz(`tink`),同时一道高频嗖声(`swipe`) |
+| 杯子坠落 | 纯正弦指数下滑约 1550→325Hz、0.35s(`slide_whistle`) |
+| 落地碎裂 | 80Hz 左右闷击+宽带噪声(质心 5–7kHz、约 0.45s 衰减)+陶瓷非谐泛音+几颗碎片小碰撞(`crash`) |
+| 猫叫 | 线性折线音高(上行再下行)的谐波合成+两个共振峰,整段最响(`meow`) |
+| 签名出现 | 两下 ~90Hz 轻「啵」叠一点亮点(`end_thump`) |
+| 收尾 | 落在主音的低音拨弦 |
+
+时间点全部从画面接触表(每 0.1s 一帧)对齐到画面事件。
+
+---
+
+## 4. 混音做法(脚本后半段,原样可用)
+
+1. 0.5s 小空间混响,12ms 预延迟,湿声 9%
+2. 逐段低频暖底:按段的和弦根音(`BED_ROOT`)铺「三角波+下八度正弦,250Hz 低通」,电平按「地板比段响度」的相对值自动算,已经够的段不加
+3. 逐段 2–6kHz 动态 EQ(`MID_ORIG`)
+4. 逐段补 >6kHz 的空气噪声(`HF_ORIG`)
+5. 逐段 K 加权响度对齐 `target`,迭代 4 次,10ms 平滑增益防拉链声
+6. 可选:15.8kHz 陡峭低通,模拟流媒体 AAC
+7. 整体对齐 LUFS,再做前视峰值限幅
+
+有参考片时,`target / MID_ORIG / HF_ORIG / LOW_FLOOR_ORIG` 填参考片逐段量出来的值(用第 1 节的方法);没有参考片时,示例里的「统一相对值」就够用。
+
+起音软化的经验:拨弦模型 2ms 硬起音听起来太「点」,改成 10ms 线性起音、高次谐波起音更晚(每升一次谐波 ×1.6,上限 35ms)、起音噪声减半并加 7kHz 低通,整体会连贯很多。
+
+示例的产出:48k 立体声,15.06s,-14.0 LUFS,真峰 -1.5 dBTP。
+
+```
+uv run --with numpy --with scipy --with soundfile python scripts/audio/synth_艺术史速通.py
+```
+
+---
+
+## 5. 可复用规律:给任何动画做代码合成配乐
+
+下面这些可以直接照抄。
+
+1. **先定一张 BPM 网格,所有东西都对齐到它上面**。128 BPM(八分音符 0.234s)适合「速通、蒙太奇」这类节奏;剪辑点、音乐起音、音效落点全部取 `t0 + n·E`。好处是画面怎么剪,音乐都不会显得乱。参考片的时间残差只有 ±4ms,这种「机器般的准」本身就是风格的一部分。
+2. **用「每段八分音符数递减」做加速,不要提速**。本片是 6 → 4×5 → 3×4 → 2×3 → 1×3,到最后一段再放长(9)让观众喘口气、给笑点留位置。速度不变,听感却越来越急;而且每段都落在网格上,和画面切点天然同步。做法:先列出画面每段的时长,四舍五入到八分音符,再整体微调,让递减变得规律。
+3. **一个三音动机,换乐器、随和弦移调重复**。选一个短小、节奏鲜明的细胞(示例乐谱是 ♪♪♩「级进上行、再下跳」),每个场景用该时代或风格的代表乐器演奏一遍,音高跟着当段和弦走。和声骨架用一个四和弦循环(示例是 Dm–B♭–F–C)就够;想做「出格感」的段(异国、前卫)只换调式或加三全音,节奏和网格不动。开场可以用动机的倒影或扩大版(示例洞穴段是下行的附点四分)先立住。
+4. **段间不做交叉淡化**。新段在网格上硬起音,上一段的音符保留自己的自然尾音(拨弦 30–300ms,持续音约 150ms 的 release),可以让一个低音持续音跨段延续来「缝」两段。这样每次换场都有清楚的「咔」,又不会断。不需要每段都加转场嗖声(参考片一个都没有)。
+5. **结尾音效按「停—悬—砸—反应—收」设计**:
+ - 停:音乐在网格上停住,用约 150ms 的快速衰减,不要硬切
+ - 悬:一个小「叮」作为引子,接下滑哨(纯正弦指数扫频,约 0.35s、2 个八度多)
+ - 砸:闷击 + 宽带噪声 + 非谐泛音 + 几颗碎片小碰撞,约 0.45s 衰减完
+ - 反应:角色发声,比如线性折线音高的「喵」,放在砸之后约 0.5s,整段最响
+ - 收:一两下轻「啵」配签名,最后一个落在主音或属音上的低音拨弦
+ 全部按事件时间点从画面接触表(每 0.1s 一帧)对齐。
+6. **响度对齐方法**:
+ 1. 先量参考片的整体值(ffmpeg ebur128:积分 LUFS、LRA、真峰)
+ 2. 再按段量 K 加权响度,以及 2–6kHz、>6kHz、40–220Hz 地板相对段响度的差值
+ 3. 合成后依次做:逐段低频暖底 → 逐段中高频动态 EQ → 逐段空气噪声 → 逐段响度迭代对齐(3–4 次,10ms 平滑增益,防止拉链声)
+ 4. 如果参考是 AAC,再加 16kHz 低通
+ 5. 最后整体对齐 LUFS,并做前视峰值限幅
+ 全程用「相对段响度」的差值,不用绝对值,这样换素材、换整体响度都不用重标。
+7. **synth.py 改成通用模板的方式**(结构不动,只换四块数据):
+ - `T0, E`:网格零点与八分音符时长(BPM → `E = 60 / BPM / 2`)
+ - `edges / target / MID_ORIG / HF_ORIG / LOW_FLOOR_ORIG / BED_ROOT`:段落边界和逐段参考值;没有参考片时,`target` 统一填一个值即可(比如 -14),其余三项填「不补」
+ - `era(n0, items)` 的乐谱块:每段一行列表,元素是 `(相对八分位置, 乐器函数, 增益, 声像)`。乐器函数库(`pluck` 拨弦族、`additive` 持续音族、`kick / clap / hat / taiko` 鼓族、`chip / supersaw` 合成器族)可以直接复用,新风格一般只要调 `pluck` 的谐波表和衰减参数
+ - 音效块:按事件时间调用 `tink / slide_whistle / crash / meow / end_thump`,参数(频率、时长)从参考片测得,或按第 5 条的模板自己定
+ 后半段混音链(暖底 → EQ → 空气 → 响度迭代 → 低通 → 限幅)原样保留。
+8. **分析流程的顺序**:
+ 1. 起音通量拟合网格,先拿到 BPM 和 t0
+ 2. 在 16 分音符网格上逐格做 FFT 新音检测,再用 basic-pitch 复音转录交叉验证
+ 3. 用窄带谐波比和包络判断音色
+ 4. 用高频、低频能量跳变判断打击乐
+ 5. 全模态模型只当候选,逐条回校。实测它在乐器判断上可靠,在拍速(说 120,实测 128)、动机音数、「转场嗖声」、音效时间上都错了
+
diff --git a/scripts/analyze/breakdown.py b/scripts/analyze/breakdown.py
new file mode 100644
index 0000000..ed52b8e
--- /dev/null
+++ b/scripts/analyze/breakdown.py
@@ -0,0 +1,101 @@
+#!/usr/bin/env python3
+# /// script
+# dependencies = ["numpy", "pillow"]
+# ///
+"""一条命令把参考动画拆成「能写代码的地图」:接触表、逐帧差、转场起点+节拍网格拟合、每个转场的 60fps 接触表、每段运动热图、关键帧总览。
+
+ uv run breakdown.py --video 原片.mp4 --out 拆解/ [--thresh 5] [--debounce 12]
+
+产物(都在 --out 下):
+ sheet_*.jpg 4fps 接触表(每张 30 帧,标秒)
+ diff.npy 逐帧平均灰度差(192x108),长度 N-1
+ cuts.json 转场起点帧号、节拍网格拟合(起点≈t0+k·step,报残差与 BPM 候选)
+ 转场/T??.jpg 每个转场起点前 2 帧起、每 2 帧一格、15 格的原分辨率缩略接触表
+ 镜内运动/运动热图.jpg 每段静止区间的逐像素最大帧差(红)叠在灰度底图上,标运动面积占比
+ 关键帧总览.jpg 每段最后一帧(下个转场前 3 帧)拼图 = 每段的「参考帧」
+ ref/seg??.png 同上,原分辨率,喂给生图模型当构图参考
+判断阈值:静止段帧差 <2,转场段 10–40;默认阈值 5、去抖 12 帧,按片子调。
+"""
+import argparse, json, subprocess
+from pathlib import Path
+import numpy as np
+from PIL import Image, ImageDraw
+
+ap = argparse.ArgumentParser(description=__doc__.splitlines()[0])
+ap.add_argument('--video', required=True); ap.add_argument('--out', required=True)
+ap.add_argument('--thresh', type=float, default=5); ap.add_argument('--debounce', type=int, default=12)
+a = ap.parse_args()
+out = Path(a.out); out.mkdir(parents=True, exist_ok=True)
+
+def probe():
+ r = subprocess.run(['ffprobe', '-v', 'error', '-select_streams', 'v:0', '-show_entries', 'stream=width,height,r_frame_rate', '-of', 'json', a.video], capture_output=True, text=True)
+ s = json.loads(r.stdout)['streams'][0]; n, d = s['r_frame_rate'].split('/'); return s['width'], s['height'], float(n) / float(d)
+W, H, FPS = probe()
+
+def frames(w, h, fmt='rgb24'):
+ raw = subprocess.run(['ffmpeg', '-v', 'error', '-i', a.video, '-vf', f'scale={w}:{h}', '-f', 'rawvideo', '-pix_fmt', fmt, '-'], capture_output=True).stdout
+ c = 3 if fmt == 'rgb24' else 1
+ return np.frombuffer(raw, np.uint8).reshape(-1, h, w, c) if c == 3 else np.frombuffer(raw, np.uint8).reshape(-1, h, w)
+
+# 1) 逐帧差
+g = frames(192, 108, 'gray').astype(np.float32)
+d = np.abs(np.diff(g, axis=0)).mean(axis=(1, 2)); np.save(out / 'diff.npy', d)
+starts = []
+for i in range(1, len(d)):
+ if d[i] > a.thresh and d[i - 1] <= a.thresh and (not starts or i - starts[-1] > a.debounce): starts.append(i)
+# 网格拟合:找「大部分起点都落在 t0+k·step 上」的最大 step(容差 1.5 帧,允许 20% 离群——镜内大动作会被误检成转场)
+grid = None
+if len(starts) >= 4:
+ S_ = np.array(starts, float); best = None
+ for step in np.arange(4.0, np.diff(S_).max() + 0.01, 0.01):
+ for t0 in S_[:3]:
+ k = np.round((S_ - t0) / step); res = S_ - (t0 + k * step); inl = np.abs(res) <= 1.5
+ if inl.mean() < 0.8: continue
+ t0f = t0 + res[inl].mean(); res = S_ - (t0f + k * step); score = (step, inl.sum()) # 先要最大步长(小步长能硬凑任何点)
+ if best is None or score > best[0]: best = (score, step, t0f, k.astype(int).tolist(), np.abs(res[inl]).max(), (~inl).nonzero()[0].tolist())
+ if best:
+ _, step, t0, k, e, outl = best
+ grid = {'t0_frame': round(float(t0), 2), 'step_frames': round(float(step), 3), 'max_residual_frames': round(float(e), 2), 'units_per_cut': k,
+ 'outlier_cut_index': outl, 'bpm_if_step_is_eighth': round(float(60 * FPS / step / 2), 2), 'bpm_if_step_is_quarter': round(float(60 * FPS / step), 2)}
+json.dump({'fps': FPS, 'size': [W, H], 'cuts_frames': starts, 'cuts_sec': [round(s / FPS, 3) for s in starts], 'grid': grid}, open(out / 'cuts.json', 'w'), indent=1, ensure_ascii=False)
+print('转场起点(秒):', [round(s / FPS, 3) for s in starts]); print('网格:', grid)
+
+# 2) 4fps 接触表
+small = frames(480, 270)
+step4 = max(1, round(FPS / 4)); idx = list(range(0, len(small), step4))
+for p in range(0, len(idx), 30):
+ sub = idx[p:p + 30]; rows = (len(sub) + 5) // 6
+ S = Image.new('RGB', (6 * 480, rows * 288), 'white'); dr = ImageDraw.Draw(S)
+ for i, f in enumerate(sub):
+ x, y = (i % 6) * 480, (i // 6) * 288; S.paste(Image.fromarray(small[f]), (x, y + 18)); dr.text((x + 4, y + 3), f'{f / FPS:.2f}s', fill='black')
+ S.save(out / f'sheet_{p // 30}.jpg', quality=85)
+
+# 3) 每个转场的接触表
+(out / '转场').mkdir(exist_ok=True)
+mid = frames(384, 216)
+for n, s in enumerate(starts):
+ S = Image.new('RGB', (5 * 384, 3 * 230), 'white'); dr = ImageDraw.Draw(S)
+ for i, f in enumerate(range(s - 2, s + 28, 2)):
+ if f >= len(mid): break
+ x, y = (i % 5) * 384, (i // 5) * 230; S.paste(Image.fromarray(mid[f]), (x, y + 14)); dr.text((x + 3, y + 1), f'f{f} {f / FPS:.3f}s', fill='black')
+ S.save(out / '转场' / f'T{n + 1:02d}.jpg', quality=85)
+
+# 4) 运动热图 + 5) 参考帧
+(out / '镜内运动').mkdir(exist_ok=True); (out / 'ref').mkdir(exist_ok=True)
+bounds = [0] + starts + [len(small)]
+heat, keys = [], []
+for i in range(len(bounds) - 1):
+ a0 = bounds[i] + (round(0.35 * FPS) if i else 0); b0 = bounds[i + 1] - 2
+ ref_f = max(bounds[i], bounds[i + 1] - 3)
+ subprocess.run(['ffmpeg', '-v', 'error', '-y', '-i', a.video, '-vf', f'select=eq(n\\,{ref_f})', '-frames:v', '1', str(out / 'ref' / f'seg{i + 1:02d}.png')])
+ keys.append((i + 1, Image.fromarray(small[min(ref_f, len(small) - 1)])))
+ if b0 - a0 < 4: continue
+ seq = small[a0:b0].astype(np.float32); m = np.abs(np.diff(seq, axis=0)).mean(axis=3).max(axis=0); frac = (m > 25).mean()
+ base = Image.fromarray(seq[0].astype(np.uint8)).convert('L').convert('RGB'); hm = np.zeros((270, 480, 3), np.uint8); hm[..., 0] = np.clip(m * 4, 0, 255)
+ im = Image.blend(base, Image.fromarray(hm), 0.6); ImageDraw.Draw(im).text((4, 4), f'段{i + 1} f{a0}-{b0} 运动{frac * 100:.1f}%', fill='yellow'); heat.append(im)
+for name, ims in [('镜内运动/运动热图.jpg', heat), ('关键帧总览.jpg', [k[1] for k in keys])]:
+ if not ims: continue
+ rows = (len(ims) + 3) // 4; S = Image.new('RGB', (4 * 480, rows * 270))
+ for i, im in enumerate(ims): S.paste(im, ((i % 4) * 480, (i // 4) * 270))
+ S.save(out / name, quality=85)
+print('done ->', out)
diff --git "a/scripts/audio/synth_\350\211\272\346\234\257\345\217\262\351\200\237\351\200\232.py" "b/scripts/audio/synth_\350\211\272\346\234\257\345\217\262\351\200\237\351\200\232.py"
new file mode 100644
index 0000000..4a987fa
--- /dev/null
+++ "b/scripts/audio/synth_\350\211\272\346\234\257\345\217\262\351\200\237\351\200\232.py"
@@ -0,0 +1,633 @@
+#!/usr/bin/env python3
+"""速通片 15 秒配乐模板 —— 纯代码合成,不用任何采样。乐谱是一段原创示例(D 小调),换成你自己的即可。
+
+运行:
+ uv run --with numpy --with scipy --with soundfile python scripts/audio/synth_艺术史速通.py
+输出:脚本同目录 示例配乐.wav(48k / 立体声 / 15.06s)
+
+方法见 references/风格配方/_音轨_艺术史速通.md:128 BPM 严格网格(八分音符 0.23431s,网格零点 0.028s),
+17 个时代按八分音符数 6,4,4,4,4,4,3,3,3,3,2,2,2,1,1,1,9 依次排布(这是独立配乐示例,换片子时按实际段落表重排),
+每个时代换一套配器,一个三音动机换乐器、随和弦移调;13.155s 音乐停,接音效(拍杯叮、滑哨坠落、碎裂、猫叫、收尾拨弦)。
+响度:逐段 K 加权响度对齐到 target 表,再整体对齐 -14 LUFS / 真峰 -1.5 dBFS。
+"""
+import numpy as np
+import scipy.signal as ss
+import soundfile as sf
+from pathlib import Path
+
+SR = 48000
+N = 722944 # 独立示例总长15.0613s
+T0, E = 0.028, 0.23431 # 网格零点、八分音符时长(实测 128.04 BPM)
+rng = np.random.default_rng(7)
+OUT = Path(__file__).with_name("示例配乐.wav")
+
+L = np.zeros(N); R = np.zeros(N)
+
+
+def tt(n): # 第 n 个八分音符的绝对时间
+ return T0 + n * E
+
+
+NOTE = {"C": 0, "D": 2, "E": 4, "F": 5, "G": 7, "A": 9, "B": 11}
+
+
+def hz(name):
+ s = NOTE[name[0]]; i = 1
+ while name[i] in "#b":
+ s += 1 if name[i] == "#" else -1; i += 1
+ midi = 12 * (int(name[i:]) + 1) + s
+ return 440.0 * 2 ** ((midi - 69) / 12)
+
+
+def add(sig, t, gain=1.0, pan=0.0):
+ """等功率声像放进总线。pan -1..1"""
+ s = int(round(t * SR))
+ if s >= N or len(sig) == 0:
+ return
+ sig = sig[: N - s] * gain
+ a = (pan + 1) * np.pi / 4
+ L[s:s + len(sig)] += sig * np.cos(a)
+ R[s:s + len(sig)] += sig * np.sin(a)
+
+
+# ---------------------------------------------------------------- 基础构件
+def tvec(dur):
+ return np.arange(int(dur * SR)) / SR
+
+
+def adsr(dur, a=0.01, d=0.05, s=0.8, r=0.1):
+ """dur 为按住时长,返回长度 dur+r 的包络"""
+ t = tvec(dur + r)
+ e = np.where(t < a, t / max(a, 1e-4), 0)
+ m = (t >= a) & (t < a + d); e[m] = 1 - (1 - s) * (t[m] - a) / max(d, 1e-4)
+ m = (t >= a + d) & (t < dur); e[m] = s
+ lvl = s if dur > a + d else max(e[t < dur][-1] if (t < dur).any() else 0, 0)
+ m = t >= dur; e[m] = lvl * np.exp(-(t[m] - dur) / max(r / 4, 1e-4))
+ return e
+
+
+def additive(f, amps, dur, phase_jitter=True):
+ """f 可以是常数或逐样本频率数组;amps[k] 是第 k+1 次谐波幅度。带限到 18k。"""
+ n = int(dur * SR) if np.isscalar(f) else len(f)
+ fa = np.full(n, f) if np.isscalar(f) else f
+ ph = 2 * np.pi * np.cumsum(fa) / SR
+ out = np.zeros(n); fmax = fa.max()
+ for k, a in enumerate(amps, 1):
+ if a == 0 or k * fmax > 18000:
+ continue
+ p0 = rng.uniform(0, 2 * np.pi) if phase_jitter else 0
+ out += a * np.sin(k * ph + p0)
+ return out
+
+
+def saw_amps(n=40):
+ return [1 / k for k in range(1, n + 1)]
+
+
+def square_amps(n=40):
+ return [1 / k if k % 2 else 0 for k in range(1, n + 1)]
+
+
+ATT = 0.010 # 起音软化:2ms 硬起音听起来太「点」,10ms 更连贯
+
+
+def pluck(f, dur, amps, d0=3.0, slope=0.6, B=0.0, noise=0.02, bend=0.0, att=None):
+ """拨弦/击弦:各次谐波独立指数衰减,高次衰减更快;B 为弦的非谐性;bend 为起音音高回落(半音)。
+ v2:基音 att 秒线性起音,高次谐波起音更慢(模拟滤波包络从闭到开),起音噪声减半。"""
+ att = ATT if att is None else att
+ t = tvec(dur); out = np.zeros_like(t)
+ fb = f * 2 ** (bend * np.exp(-t / 0.03) / 12) if bend else np.full_like(t, f)
+ ph = 2 * np.pi * np.cumsum(fb) / SR
+ for k, a in enumerate(amps, 1):
+ fk = f * k * np.sqrt(1 + B * k * k)
+ if fk > 18000 or a == 0:
+ continue
+ ak = min(att * (1 + 0.6 * (k - 1)), 0.035) # 高次谐波晚开
+ out += a * np.exp(-t * d0 * (1 + slope * (k - 1))) * np.minimum(1, t / ak) * np.sin(ph * fk / f + rng.uniform(0, 6.28))
+ if noise:
+ nb = rng.standard_normal(len(t)) * np.exp(-t / 0.006) * noise * 0.5
+ out += lp(hp(nb, 2000), 7000)
+ return out
+
+
+def bp(x, lo, hi, order=2):
+ return ss.sosfilt(ss.butter(order, [lo, hi], "band", fs=SR, output="sos"), x)
+
+
+def hp(x, fc, order=2):
+ return ss.sosfilt(ss.butter(order, fc, "high", fs=SR, output="sos"), x)
+
+
+def lp(x, fc, order=2):
+ return ss.sosfilt(ss.butter(order, fc, "low", fs=SR, output="sos"), x)
+
+
+def noise(dur):
+ return rng.standard_normal(int(dur * SR))
+
+
+def expdec(dur, tau):
+ return np.exp(-tvec(dur) / tau)
+
+
+# ---------------------------------------------------------------- 乐器
+def bone_flute(n, dur): # 洞穴:近纯正弦 + 气声,慢起音
+ f = hz(n); held = dur
+ t = tvec(held + 0.3)
+ vib = 1 + 0.004 * np.sin(2 * np.pi * 5.2 * t) * np.minimum(1, t / 0.2)
+ tone = additive(f * vib, [1, 0.018, 0.022, 0.012], held + 0.3)
+ breath = bp(noise(held + 0.3), f * 0.8, f * 3.5) * 0.05
+ return (tone + breath) * adsr(held, a=0.07, d=0.1, s=0.9, r=0.3)[: len(t)]
+
+
+def frame_drum(): # 洞穴:低沉手鼓,98→87Hz
+ t = tvec(0.5); f = 87 + 14 * np.exp(-t / 0.04)
+ body = np.sin(2 * np.pi * np.cumsum(f) / SR) * np.exp(-t / 0.16)
+ skin = lp(noise(0.5), 900) * np.exp(-t / 0.02) * 0.3
+ return body + skin
+
+
+def stick_click(level=1.0): # 敲击/摇奏的高频颗粒
+ t = tvec(0.04)
+ return bp(noise(0.04), 4000, 11000) * np.exp(-t / 0.006) * level
+
+
+def harp(n, dur=0.6, bright=1.0): # 埃及竖琴:H2≈-11dB,0.2s 衰减约 15dB
+ return pluck(hz(n), dur, [1, 0.3 * bright, 0.07, 0.12, 0.015, 0.015, 0.02], d0=6.0, slope=0.5, noise=0.03)
+
+
+def sistrum(): # 埃及叉铃:带金属泛音的短噪声
+ t = tvec(0.12)
+ jing = sum(np.sin(2 * np.pi * f * t + rng.uniform(0, 6)) for f in (5120, 6890, 8230)) * 0.15
+ return (bp(noise(0.12), 6000, 12000) + jing) * np.exp(-t / 0.025)
+
+
+def lyre(n, dur=0.8): # 希腊里拉琴:较闷的拨弦
+ return pluck(hz(n), dur, [1, 0.45, 0.3, 0.12, 0.05, 0.03], d0=3.5, slope=0.7, noise=0.02)
+
+
+def aulos(n, dur): # 希腊双管:明亮簧音,H2/H3 强,持续
+ f = hz(n); t = tvec(dur + 0.06)
+ vib = 1 + 0.006 * np.sin(2 * np.pi * 6 * t) * np.minimum(1, t / 0.15)
+ tone = additive(f * vib, [1, 0.4, 0.6, 0.35, 0.06, 0.035, 0.11, 0.06], dur + 0.06)
+ tone += bp(noise(dur + 0.06), f, f * 4) * 0.03
+ return tone * adsr(dur, a=0.05, d=0.05, s=0.9, r=0.06)
+
+
+def tambourine():
+ t = tvec(0.35)
+ return bp(noise(0.35), 7000, 14000) * np.exp(-t / 0.09) * (1 + 0.5 * np.sin(2 * np.pi * 28 * t))
+
+
+def brass(n, dur): # 罗马号角:锯齿 + 随包络变亮的低通
+ f = hz(n); tot = dur + 0.08
+ raw = additive(f, saw_amps(30), tot)
+ env = adsr(dur, a=0.03, d=0.12, s=0.6, r=0.08)
+ t = tvec(tot)
+ # 分两段低通近似"开口变亮再收"
+ bright = lp(raw, min(f * 10, 12000)); dull = lp(raw, min(f * 4, 7000))
+ w = np.exp(-t / 0.12)
+ return (bright * w + dull * (1 - w)) * env
+
+
+def war_drum(): # 罗马战鼓 ~87Hz
+ t = tvec(0.45); f = 70 + 30 * np.exp(-t / 0.03)
+ return np.sin(2 * np.pi * np.cumsum(f) / SR) * np.exp(-t / 0.13) + lp(noise(0.45), 1500) * np.exp(-t / 0.015) * 0.5
+
+
+def organ(n, dur): # 哥特管风琴:H1 + 奇次/高次音栓,几乎不衰减
+ f = hz(n); tot = dur + 0.15; t = tvec(tot)
+ trem = 1 + 0.03 * np.sin(2 * np.pi * 5.5 * t)
+ tone = additive(f, [1, 0.03, 0.05, 0.12, 0.18, 0.04, 0.0, 0.06, 0.03, 0.05, 0.02, 0.04, 0, 0.03, 0, 0.03], tot) * trem # 末尾为混合音栓(高频)
+ return tone * adsr(dur, a=0.035, d=0.02, s=1.0, r=0.15)
+
+
+def harpsichord(n, dur=0.5): # 文艺复兴羽管键琴:鼻音(H5 突出),衰减中等
+ return pluck(hz(n), dur, [1, 0.12, 0.045, 0.06, 0.14, 0.02, 0.03, 0.025] + [0.02] * 10, d0=2.2, slope=0.12, noise=0.08)
+
+
+def viol(n, dur): # 低音维奥尔:柔和弓弦
+ f = hz(n); tot = dur + 0.12
+ raw = lp(additive(f, saw_amps(20), tot), 1200)
+ return raw * adsr(dur, a=0.06, d=0.1, s=0.85, r=0.12)
+
+
+def koto(n, dur=0.35): # 浮世绘:筝/三味线,快衰减 + 起音回落
+ return pluck(hz(n), dur, [1, 0.55, 0.12, 0.13, 0.13, 0.06, 0.04], d0=14, slope=0.4, noise=0.06, bend=0.6)
+
+
+def taiko():
+ t = tvec(0.6); f = 58 + 40 * np.exp(-t / 0.05)
+ return np.sin(2 * np.pi * np.cumsum(f) / SR) * np.exp(-t / 0.2) + lp(noise(0.6), 700) * np.exp(-t / 0.03) * 0.4
+
+
+def hyoshigi(): # 拍子木
+ t = tvec(0.06)
+ return (bp(noise(0.06), 1800, 4200, 4) + np.sin(2 * np.pi * 2650 * t) * 0.6) * np.exp(-t / 0.012)
+
+
+def soft_piano(n, dur=0.9): # 印象派:柔和钢琴/钢片琴,接近正弦
+ return pluck(hz(n), dur, [1, 0.16, 0.08, 0.04, 0.025, 0.015, 0.012, 0.01, 0.008], d0=2.6, slope=0.45, B=0.0002, noise=0.03)
+
+
+def pizz(n, dur=0.3): # 梵高:明亮拨弦(H2/H3 很强),快衰减
+ return pluck(hz(n), dur, [1, 0.9, 0.6, 0.22, 0.35, 0.14, 0.09, 0.05], d0=18, slope=0.3, noise=0.04)
+
+
+def swirl(dur): # 梵高:上扬的风声
+ x = noise(dur); n = len(x); out = np.zeros(n); seg = 2400
+ for i in range(0, n, seg):
+ fc = 2500 + 6000 * i / n
+ out[i:i + seg] = bp(x[max(0, i - 400):i + seg], fc * 0.7, fc * 1.3)[-len(out[i:i + seg]):]
+ return out * np.sin(np.pi * np.arange(n) / n)
+
+
+def celesta(n, dur=0.35): # 新艺术:钢片琴/竖琴,快衰减
+ return pluck(hz(n), dur, [1, 0.6, 0.12, 0.1, 0.12, 0.12, 0.2, 0.06], d0=11, slope=0.3, noise=0.02)
+
+
+def blip(n, dur=0.2): # 包豪斯:几何感短音(马林巴式)
+ return pluck(hz(n), dur, [1, 0.75, 0.2, 0.4], d0=22, slope=0.4, noise=0.0)
+
+
+def tick():
+ t = tvec(0.015)
+ return hp(noise(0.015), 6000) * np.exp(-t / 0.003)
+
+
+def kick(f0=150, f1=48, tau=0.18, dur=0.35):
+ t = tvec(dur); f = f1 + (f0 - f1) * np.exp(-t / 0.025)
+ return np.sin(2 * np.pi * np.cumsum(f) / SR) * np.exp(-t / tau) + hp(noise(dur), 3000) * np.exp(-t / 0.003) * 0.15
+
+
+def clap():
+ t = tvec(0.18); env = np.zeros_like(t)
+ for d in (0, 0.009, 0.018):
+ env += (t >= d) * np.exp(-np.maximum(t - d, 0) / (0.006 if d < 0.018 else 0.05))
+ return bp(noise(0.18), 1200, 6000) * env
+
+
+def hat(open_=False):
+ d = 0.09 if open_ else 0.03; t = tvec(d)
+ return hp(noise(d), 7500, 4) * np.exp(-t / (d / 3))
+
+
+def chip(n, dur, duty_sq=True): # 像素:方波(只有奇次谐波)
+ f = hz(n); tot = dur + 0.01
+ return additive(f, square_amps(40), tot, phase_jitter=False) * adsr(dur, a=0.006, d=0.0, s=1.0, r=0.01)
+
+
+def supersaw(n, dur): # 光追:多层失谐锯齿,玻璃感
+ f = hz(n); tot = dur + 0.15; out = 0
+ for det in (-0.012, -0.005, 0, 0.006, 0.013):
+ out = out + additive(f * (1 + det), saw_amps(25), tot)
+ out = lp(out / 5, 7000)
+ return out * adsr(dur, a=0.04, d=0.1, s=0.7, r=0.15)
+
+
+def boing(t0=11.01, t1=11.165, f0=600, f1=985): # 猫跳上桌:上滑音
+ t = tvec(t1 - t0); f = f0 * (f1 / f0) ** (t / t[-1])
+ tone = additive(f, [1, 0.5, 0.35, 0.2, 0.1], len(t) / SR)
+ return tone * np.sin(np.pi * t / t[-1]) ** 0.5
+
+
+def pluck2026(n, dur=0.22): # 2026:方波系合成拨奏(H2 弱、H3 强)+ 包络低通
+ f = hz(n); tot = dur
+ raw = additive(f, [1, 0.1, 0.38, 0.3, 0.22, 0.12, 0.14, 0.1, 0.08], tot)
+ return raw * np.exp(-tvec(tot) / 0.1) * np.minimum(1, tvec(tot) / 0.014)
+
+
+def sub_bass(n, dur): # 2026:锯齿低音 + 下八度正弦
+ f = hz(n); tot = dur + 0.15
+ raw = lp(additive(f, saw_amps(30), tot), 700, 4) + 0.6 * np.sin(2 * np.pi * f / 2 * tvec(tot))
+ return raw * adsr(dur, a=0.01, d=0.05, s=0.9, r=0.15)
+
+
+def pad(n, dur):
+ f = hz(n); tot = dur + 0.1
+ return lp(additive(f, saw_amps(15), tot), 2500) * adsr(dur, a=0.05, d=0.1, s=0.7, r=0.1)
+
+
+# ---------------------------------------------------------------- 音效
+def tink(): # 13.16 猫爪碰杯:陶瓷高频非谐振铃
+ t = tvec(0.35); out = 0
+ for f, a, tau in ((5720, 1, 0.12), (6506, 0.6, 0.09), (6315, 0.25, 0.1), (5490, 0.35, 0.08), (1533, 0.1, 0.05)):
+ out = out + a * np.sin(2 * np.pi * f * t) * np.exp(-t / tau)
+ return out
+
+
+def swipe(): # 爪子划过的嗖声
+ d = 0.2; t = tvec(d)
+ return bp(noise(d), 2500, 9000) * np.sin(np.pi * t / d) ** 2
+
+
+def slide_whistle(t0=13.29, t1=13.635, f0=1550, f1=325): # 杯子坠落:指数下滑正弦
+ t = tvec(t1 - t0); f = f0 * (f1 / f0) ** (t / t[-1])
+ tone = np.sin(2 * np.pi * np.cumsum(f) / SR)
+ env = np.minimum(1, t / 0.015) * np.minimum(1, (t[-1] - t) / 0.01 + 0.0001)
+ return tone * env
+
+
+def crash(): # 13.624 碎裂:83Hz 闷响 + 高频碎屑 + 非谐振残响
+ d = 0.6; t = tvec(d)
+ f = 60 + 40 * np.exp(-t / 0.02)
+ thump = np.sin(2 * np.pi * np.cumsum(f) / SR) * np.exp(-t / 0.07)
+ hiss = hp(noise(d), 2500) * np.exp(-t / 0.13)
+ shards = np.zeros_like(t)
+ for _ in range(14): # 若干碎片的二次小碰撞
+ s = rng.uniform(0.02, 0.4); i = int(s * SR); g = rng.uniform(0.2, 0.7) * np.exp(-s / 0.2)
+ seg = hp(noise(0.03), 4000) * np.exp(-tvec(0.03) / 0.005) * g
+ shards[i:i + len(seg)] += seg[: len(shards) - i]
+ ring = sum(a * np.sin(2 * np.pi * fr * t) * np.exp(-t / tau)
+ for fr, a, tau in ((1669, .25, .15), (2302, .2, .1), (4462, .12, .08), (7320, .3, .12), (7921, .25, .1)))
+ return thump * 1.2 + hiss * 0.6 + shards + ring
+
+
+def meow(t0=14.12, tp=14.28, t1=14.65): # 猫叫:574→797Hz 上行,再降到 486Hz;锯齿 + 共振峰
+ n = int((t1 - t0) * SR); t = np.arange(n) / SR; ip = int((tp - t0) * SR)
+ f = np.empty(n); f[:ip] = np.linspace(574, 797, ip); f[ip:] = np.linspace(797, 486, n - ip)
+ raw = additive(f, saw_amps(24), n / SR)
+ vowel = 0.5 * bp(raw, 1300, 1900) + 1.0 * bp(raw, 2100, 2700) + 0.9 * bp(raw, f.mean() * 0.8, f.mean() * 1.3) + 0.15 * raw
+ env = np.minimum(1, t / 0.04) * np.minimum(1, (t[-1] - t) / 0.12)
+ return vowel * env
+
+
+def end_thump(f=90, sparkle=True): # 签名出现时的轻"啵"
+ d = 0.2; t = tvec(d)
+ out = np.sin(2 * np.pi * f * t) * np.exp(-t / 0.05)
+ if sparkle:
+ out += sum(0.08 * np.sin(2 * np.pi * fr * t) * np.exp(-t / 0.06) for fr in (531, 852, 921, 965, 1058))
+ return out
+
+
+# ---------------------------------------------------------------- 编曲(时间单位:八分音符)
+def era(n0, items):
+ """items: (相对八分位置, 生成函数, 增益, 声像)"""
+ for pos, fn, g, pan in items:
+ add(fn(), tt(n0 + pos), g, pan)
+
+
+B8 = E # 一个八分音符的秒数
+
+# ---- 原创示例乐谱(D 小调 / F 大调,和声骨架 Dm–B♭–F–C)----
+# 贯穿动机:♪♪♩「级进上行、再下跳」,每段换乐器、随当段和弦移调;洞穴段用它的下行扩大版先立住。
+# 1 洞穴(6 个八分):骨笛 A4–G4–D4(下行,附点四分起)+ 手鼓 + 弱拍敲击
+era(0, [(0, lambda: bone_flute("A4", 3 * B8), 1.0, 0), (3, lambda: bone_flute("G4", B8), 1.0, 0),
+ (4, lambda: bone_flute("D4", 2.4 * B8), 1.0, 0),
+ (0, frame_drum, 1.3, -0.1), (3, frame_drum, 1.1, -0.1)]
+ + [(k, lambda: stick_click(0.25), 1.0, 0.25) for k in (1, 2, 4, 5)])
+
+# 2 埃及(4):竖琴 Dm→B♭ 分解 + 动机 F5–G5–D5 + 弱拍叉铃
+era(6, [(0, lambda: harp("D3", 0.9), 0.55, -0.2), (0.06, lambda: harp("F3", 0.6), 0.35, -0.15),
+ (0.5, lambda: harp("A3", 0.6), 0.45, -0.1), (1, lambda: harp("D4", 0.5), 0.4, -0.2),
+ (2, lambda: harp("Bb2", 0.9), 0.5, -0.2), (2.06, lambda: harp("D3", 0.6), 0.35, -0.15), (3, lambda: harp("F3", 0.5), 0.4, -0.2),
+ (0, lambda: harp("F5", 0.5, 1.2), 0.8, 0.1), (1, lambda: harp("G5", 0.5, 1.2), 0.8, 0.1),
+ (2, lambda: harp("D5", 0.6, 1.2), 0.8, 0.1)]
+ + [(k + 0.5, sistrum, 0.22, 0.3) for k in range(4)])
+
+# 3 希腊(4):里拉琴 B♭ 和弦 + 双管 D5(♪)→ F5(附点四分)
+era(10, [(0, lambda: lyre("Bb2"), 0.4, -0.25), (0.04, lambda: lyre("F3"), 0.45, -0.2), (0.08, lambda: lyre("Bb3"), 0.35, -0.15),
+ (2.5, lambda: lyre("D4", 0.5), 0.35, -0.2), (3.5, lambda: lyre("F2", 0.6), 0.5, -0.2),
+ (0, lambda: aulos("D5", B8), 0.55, 0.05), (1, lambda: aulos("F5", 3 * B8), 0.5, 0.05),
+ (1, lambda: aulos("F6", 3 * B8), 0.15, 0.05), (0, tambourine, 0.12, 0.3), (2, tambourine, 0.08, 0.3)])
+
+# 4 罗马(4):号角动机 C5–D5–A4,和弦 F→C→Dm + 战鼓
+era(14, [(0, lambda: brass("C5", B8 * 0.9), 0.45, 0.05), (0, lambda: brass("F3", B8 * 0.9), 0.25, -0.15), (0, lambda: brass("A3", B8 * 0.9), 0.25, 0.15),
+ (1, lambda: brass("D5", B8 * 1.4), 0.4, 0.05), (1, lambda: brass("G3", B8 * 1.4), 0.25, -0.15), (1, lambda: brass("C3", B8 * 1.8), 0.3, 0),
+ (2.5, lambda: brass("A4", B8 * 1.4), 0.4, 0.05), (2.5, lambda: brass("F3", B8 * 1.4), 0.25, -0.15), (3, lambda: brass("D3", B8), 0.3, 0),
+ (0, war_drum, 1.1, -0.05), (1.5, war_drum, 0.9, -0.05), (2, war_drum, 1.1, -0.05)])
+
+# 5 哥特(4):管风琴 Dm → Gm/D,D2 持续踏板
+era(18, [(0, lambda: organ("D3", 2 * B8), 0.3, -0.1), (0, lambda: organ("A3", 2 * B8), 0.25, 0.1), (0, lambda: organ("D4", 2 * B8), 0.25, -0.05),
+ (0, lambda: organ("F4", 2 * B8), 0.3, 0.05), (0.5, lambda: organ("A5", 1.5 * B8), 0.12, 0),
+ (2, lambda: organ("D3", 2 * B8), 0.3, -0.1), (2, lambda: organ("G3", 2 * B8), 0.3, 0.1), (2, lambda: organ("Bb3", 2 * B8), 0.3, -0.05),
+ (2, lambda: organ("D4", 2 * B8), 0.2, 0.05), (2.5, lambda: organ("Bb4", 1.5 * B8), 0.15, 0), (0, lambda: organ("D2", 4 * B8), 0.18, 0)])
+
+# 6 文艺复兴(4):羽管键琴动机 B♭5–C6–G5,伴奏 Gm→F + 低音维奥尔 G2
+era(22, [(0, lambda: harpsichord("Bb5"), 0.6, 0.1), (1, lambda: harpsichord("C6"), 0.6, 0.1), (2, lambda: harpsichord("G5", 0.7), 0.6, 0.1),
+ (0, lambda: harpsichord("G3"), 0.3, -0.2), (0.04, lambda: harpsichord("Bb3"), 0.28, -0.15), (1, lambda: harpsichord("D4"), 0.25, -0.15),
+ (2, lambda: harpsichord("F3"), 0.3, -0.2), (3, lambda: harpsichord("A3"), 0.28, -0.15), (3, lambda: harpsichord("C4"), 0.25, -0.1),
+ (0, lambda: viol("G2", 3.6 * B8), 0.35, -0.05)])
+
+# 7 浮世绘(3):筝走 D 都节音阶(D–E♭–G–A–B♭)+ 太鼓 + 拍子木
+era(26, [(0, taiko, 1.2, -0.05), (1.5, taiko, 1.0, -0.05),
+ (0, lambda: koto("D5"), 0.55, 0.15), (0.5, lambda: koto("A4"), 0.45, 0.15), (0.75, lambda: koto("Bb4"), 0.5, 0.15),
+ (1, lambda: koto("G4"), 0.45, 0.15), (1.5, lambda: koto("A4"), 0.4, 0.15), (2, lambda: koto("Eb5"), 0.5, 0.15),
+ (2.25, lambda: koto("D5"), 0.45, 0.15), (2.5, lambda: koto("A4"), 0.45, 0.15),
+ (0.5, hyoshigi, 0.25, 0.3), (2, hyoshigi, 0.2, 0.3)])
+
+# 8 印象派(3):柔和钢琴 A5–C6–G5,Fmaj7 → B♭ 低音 → Dm9 色彩
+era(29, [(0, lambda: soft_piano("A5"), 0.55, 0.1), (0, lambda: soft_piano("F3"), 0.35, -0.15), (0, lambda: soft_piano("E4"), 0.3, -0.1),
+ (0.5, lambda: soft_piano("C5"), 0.3, 0), (1, lambda: soft_piano("C6"), 0.55, 0.1), (1, lambda: soft_piano("D5"), 0.3, 0),
+ (1, lambda: soft_piano("F4"), 0.3, -0.1), (1, lambda: soft_piano("Bb2", 1.5), 0.55, -0.05),
+ (2, lambda: soft_piano("G5"), 0.55, 0.1), (2, lambda: soft_piano("D3"), 0.3, -0.1), (2.5, lambda: soft_piano("E5"), 0.25, 0.1)])
+
+# 9 梵高(3):D2 低音拨弦律动 + 高处零散亮拨弦 + 上扬风声
+era(32, [(0, lambda: pizz("D2", 0.3), 0.7, -0.05), (0.5, lambda: pizz("A2"), 0.45, -0.1), (1, lambda: pizz("D2"), 0.6, -0.05),
+ (1.75, lambda: pizz("C3"), 0.5, -0.05), (2, lambda: pizz("D2"), 0.6, -0.05), (2.5, lambda: pizz("A2", 0.4), 0.5, -0.05),
+ (0.25, lambda: pizz("A5"), 0.4, 0.15), (1, lambda: pizz("F5"), 0.35, 0.1), (1.75, lambda: pizz("D6"), 0.3, 0.15),
+ (2.5, lambda: pizz("E5"), 0.4, 0.15),
+ (1.5, lambda: swirl(0.4), 0.06, 0.2)])
+
+# 10 新艺术(3):钢片琴动机 D5–E5–A4,低音 B♭→C→Dm
+era(35, [(0, lambda: celesta("D5"), 0.6, 0.1), (0.2, lambda: celesta("D6"), 0.2, 0.15), (1, lambda: celesta("E5"), 0.6, 0.1),
+ (2, lambda: celesta("A4"), 0.6, 0.1),
+ (0, lambda: pizz("Bb2", 0.5), 0.5, -0.05), (1, lambda: pizz("C3", 0.5), 0.45, -0.05), (1, lambda: celesta("E3", 0.5), 0.3, -0.15),
+ (1, lambda: celesta("G3", 0.5), 0.25, -0.1), (2, lambda: pizz("D3", 0.5), 0.45, -0.05), (2, lambda: celesta("D4"), 0.25, -0.1),
+ (2, lambda: celesta("F4"), 0.25, -0.15), (2, lambda: celesta("A4"), 0.2, 0), (0, lambda: tambourine(), 0.06, 0.3)])
+
+# 11 立体主义(2):刻意不协和的碎片和弦 D–G♯–C♯ → E♭–A–B♭–E
+era(38, [(0, lambda: soft_piano("D2", 0.5), 0.5, -0.1), (0, lambda: soft_piano("D3", 0.5), 0.45, -0.1), (0, lambda: soft_piano("G#3", 0.5), 0.4, 0),
+ (0, lambda: soft_piano("C#5", 0.5), 0.45, 0.15),
+ (1, lambda: soft_piano("Eb4", 0.3), 0.4, -0.1), (1, lambda: soft_piano("A4", 0.3), 0.45, 0.1), (1, lambda: soft_piano("Bb4", 0.3), 0.35, 0),
+ (1, lambda: soft_piano("E5", 0.3), 0.5, 0.15)])
+
+# 12 包豪斯(2):D 八度叠置 → F/A → D,十六分机械滴答
+era(40, [(0, lambda x=x: blip(x), 0.3, p) for x, p in (("D2", 0), ("D3", -0.1), ("D4", 0.1), ("D5", -0.05), ("D6", 0.05))]
+ + [(1, lambda: blip("F5"), 0.45, 0.1), (1, lambda: blip("A5"), 0.3, 0.1), (1, lambda: blip("A6"), 0.2, -0.1), (1.5, lambda: blip("D5"), 0.45, 0)]
+ + [(k * 0.5, tick, 0.25, 0.3) for k in range(4)])
+
+# 13 波普(2):底鼓 + 反拍拍手 + 卡通短音
+era(42, [(0, lambda: kick(140, 45), 1.1, 0), (0, lambda: blip("D4", 0.2), 0.25, -0.1), (0, lambda: blip("F4", 0.2), 0.25, 0.1),
+ (1, clap, 0.45, 0.1), (0.5, lambda: chip("D4", 0.09), 0.18, -0.1), (0.5, lambda: chip("F4", 0.09), 0.15, 0.1),
+ (0.5, lambda: chip("C5", 0.09), 0.12, 0), (1.5, lambda: chip("D6", 0.05), 0.15, 0.2)]
+ + [(k * 0.5, hat, 0.3, 0.25) for k in range(4)])
+
+# 14 像素(1):方波 F 大三琶音(三十二分)+ 方波低音
+era(44, [(0, lambda: chip("F3", 0.2), 0.3, 0), (0, lambda: chip("F6", 0.055), 0.18, 0.1), (0.25, lambda: chip("A6", 0.05), 0.15, 0.1),
+ (0.5, lambda: chip("C7", 0.055), 0.12, 0.1), (0.75, lambda: chip("F6", 0.05), 0.15, 0.1), (0, lambda: kick(120, 50, 0.08), 0.6, 0)])
+
+# 15 光追(1):超级锯齿 B♭ 和弦,玻璃感
+era(45, [(0, lambda x=x: supersaw(x, B8 * 1.1), 0.18, p) for x, p in (("Bb3", -0.2), ("D4", 0.2), ("F4", -0.1), ("Bb4", 0.1))]
+ + [(0.5, lambda: supersaw("D5", B8 * 0.6), 0.15, 0.15), (0.5, lambda: supersaw("F3", B8 * 0.8), 0.15, -0.1),
+ (0, lambda: kick(130, 50, 0.1), 0.7, 0)])
+
+# 16 孟菲斯(1):C 大三持续和弦挂过段尾 + C 低音 + 底鼓;猫跳上桌的上滑音
+era(46, [(0, lambda: kick(150, 46), 1.0, 0), (0, lambda: sub_bass("C2", 0.24), 0.35, 0)]
+ + [(0, lambda x=x: supersaw(x, 0.42), g, p) for x, g, p in (("C3", 0.12, -0.15), ("G3", 0.1, 0.15), ("C5", 0.16, -0.05), ("E5", 0.16, 0.1), ("G5", 0.1, 0))])
+add(boing(), 11.01, 0.35, 0.0)
+
+# 17 2026(9):128BPM 浩室——四拍底鼓、反拍开镲、D 锯齿低音、D 大调 add9 拨奏(结尾转到同名大调)
+add(sub_bass("D2", tt(56) - tt(47)), tt(47), 0.4, 0)
+for n in (48, 50, 52, 54):
+ add(kick(150, 46, 0.2), tt(n), 1.0, 0)
+for n in (49, 51, 53, 55):
+ add(hat(True), tt(n), 0.3, 0.2)
+lead = [(48, "F#5"), (49, "A5"), (50, "D6"), (51, "E6"), (52, "F#6"), (53, "E6"), (54, "D6"), (55, "B5"), (55.5, "A5")]
+for n, x in lead:
+ add(pluck2026(x), tt(n), 0.5, 0.1)
+arp = ["A4", "D5", "F#4", "E5", "D4", "A4", "B4", "F#4"]
+for k in range(18):
+ n = 47 + k * 0.5
+ if n >= 56:
+ break
+ add(pluck2026(arp[k % len(arp)], 0.15), tt(n), 0.22, -0.15)
+for x, a, b in (("F#3", 50.5, 53.5), ("A3", 50.5, 53.5), ("E4", 51.5, 53.5), ("D3", 53.5, 54.3), ("F#3", 54.5, 56), ("A3", 54.5, 56), ("B3", 54.5, 56)):
+ add(pad(x, tt(b) - tt(a)), tt(a), 0.07, -0.2 if x < "C" else 0.2)
+
+# 18 音效段
+add(tink(), 13.158, 0.12, 0.1)
+add(swipe(), 13.17, 0.05, 0.2)
+add(slide_whistle(), 13.29, 0.16, 0.0)
+add(crash(), 13.624, 0.55, 0.0)
+add(meow(), 14.12, 0.55, 0.0)
+add(end_thump(88), 14.561, 0.2, 0)
+add(end_thump(90), 14.796, 0.25, 0)
+add(pluck(hz("D2"), 0.3, [1, 0.5, 0.35, 0.15, 0.08], d0=4, slope=0.5, noise=0.03), 14.92, 0.6, 0) # 收在主音
+
+
+# ---------------------------------------------------------------- 混音:小空间混响 → 逐段响度对齐 → 整体 LUFS/峰值
+def reverb(x, seed):
+ r = np.random.default_rng(seed); d = 0.5; t = tvec(d)
+ ir = r.standard_normal(len(t)) * np.exp(-t / 0.09)
+ ir = lp(ir, 6000); ir[: int(0.012 * SR)] = 0 # 12ms 预延迟,起音更软
+ return ss.fftconvolve(x, ir)[: len(x)] / np.sqrt((ir ** 2).sum())
+
+
+wetL, wetR = reverb(L, 1), reverb(R, 2)
+L = L + 0.09 * wetL; R = R + 0.09 * wetR
+
+
+def kweight(x):
+ b1 = [1.53512485958697, -2.69169618940638, 1.19839281085285]; a1 = [1, -1.69065929318241, 0.73248077421585]
+ b2 = [1.0, -2.0, 1.0]; a2 = [1, -1.99004745483398, 0.99007225036621]
+ return ss.lfilter(b2, a2, ss.lfilter(b1, a1, x))
+
+
+def seg_loud(kl, kr, s, e):
+ return -0.691 + 10 * np.log10(np.mean(kl[s:e] ** 2 + kr[s:e] ** 2) + 1e-12)
+
+
+def lufs(l, r): # BS.1770-4 积分响度(400ms 块,绝对+相对门限)
+ kl, kr = kweight(l), kweight(r); blk, hop = int(0.4 * SR), int(0.1 * SR)
+ z = np.array([np.mean(kl[i:i + blk] ** 2 + kr[i:i + blk] ** 2) for i in range(0, len(l) - blk + 1, hop)])
+ lk = -0.691 + 10 * np.log10(z + 1e-12); z = z[lk > -70]
+ rel = -0.691 + 10 * np.log10(z.mean()) - 10
+ z = z[-0.691 + 10 * np.log10(z) > rel]
+ return -0.691 + 10 * np.log10(z.mean())
+
+
+# 逐段目标响度(K 加权、不加门限)。有参考片时填它逐段量出来的值;这里是示例:音乐段统一 -14,音效段略低。
+edges = [0] + [tt(n) for n in (6, 10, 14, 18, 22, 26, 29, 32, 35, 38, 40, 42, 44, 45, 46, 47)] + [13.155, 13.624, 14.1, N / SR]
+target = [-14.0] * 17 + [-18.0, -17.5, -16.0]
+idx = [int(round(x * SR)) for x in edges]
+# 低频暖底:按段的和弦根音铺柔和三角波 + 250Hz 低通,电平按「低频地板比段响度」的相对值自动定(这里示例统一低 18dB)。
+BED_ROOT = ["D2", "D2", "A#1", "F2", "D2", "G2", "D2", "F2", "D2", "A#1", "D2", "D2", "D2", "F2", "A#1", "C2", "D2", None, None, None]
+LOW_FLOOR_ORIG = [t - 18 for t in target[:17]] + [None, None, None]
+_sos_low = ss.butter(4, [40, 220], "band", fs=SR, output="sos")
+
+
+def _floor(x): # 50ms 窗 RMS 的最小值(只看持续部分,不看鼓的击头)
+ w = 2400
+ return min(20 * np.log10(np.sqrt(np.mean(x[k:k + w] ** 2)) + 1e-12) for k in range(0, max(1, len(x) - w), 1200))
+
+
+_kl, _kr = kweight(L), kweight(R)
+_low = ss.sosfilt(_sos_low, (L + R) / 2)
+for i in range(len(target)):
+ if BED_ROOT[i] is None:
+ continue
+ s0, s1 = idx[i], idx[i + 1]
+ want = seg_loud(_kl, _kr, s0, s1) + (LOW_FLOOR_ORIG[i] - target[i])
+ have = _floor(_low[s0 + 1200:s1])
+ if want - have < 1.5:
+ continue
+ n = s1 - s0 + int(0.04 * SR); f = hz(BED_ROOT[i])
+ tri = additive(f, [1, 0, 1 / 9, 0, 1 / 25], n / SR) + 0.35 * np.sin(2 * np.pi * f / 2 * np.arange(n) / SR)
+ tri = lp(tri, 250)
+ env = np.ones(n); fd = int(0.02 * SR); env[:fd] = np.linspace(0, 1, fd); env[-fd:] = np.linspace(1, 0, fd)
+ z = tri * env; zl = ss.sosfilt(_sos_low, z)
+ amp = np.sqrt(max(10 ** (want / 10) - 10 ** (have / 10), 0)) / (np.sqrt(np.mean(zl[fd:-fd] ** 2)) + 1e-12)
+ e = min(N, s0 + n)
+ L[s0:e] += z[: e - s0] * amp * 0.707; R[s0:e] += z[: e - s0] * amp * 0.707
+
+# 中高频(2–6kHz)动态 EQ:把每段 2–6kHz 的相对电平推到目标值(上限 +12dB)。有参考片时填参考值;这里示例统一比段响度低 15dB
+MID_ORIG = [t - 15 for t in target]
+_sos_mid = ss.butter(2, [2000, 6000], "band", fs=SR, output="sos")
+_kl, _kr = kweight(L), kweight(R)
+_midL, _midR = ss.sosfiltfilt(_sos_mid, L), ss.sosfiltfilt(_sos_mid, R)
+_g = np.zeros(N)
+for i in range(len(target)):
+ s0, s1 = idx[i], idx[i + 1]
+ want = seg_loud(_kl, _kr, s0, s1) + (MID_ORIG[i] - target[i])
+ have = 20 * np.log10(np.sqrt(np.mean(((_midL + _midR) / 2)[s0:s1] ** 2)) + 1e-12)
+ _g[s0:s1] = 10 ** (np.clip(want - have, 0, 12) / 20) - 1
+_g = np.convolve(_g, np.ones(960) / 960, mode="same")
+L = L + _g * _midL; R = R + _g * _midR
+
+# >6kHz 的「空气」(高次泛音 + 噪声颗粒):按「高频比段响度」的相对值补一层高通噪声。示例统一低 24dB
+HF_ORIG = [t - 24 for t in target]
+_sos_hf = ss.butter(4, 6000, "high", fs=SR, output="sos")
+_kl, _kr = kweight(L), kweight(R)
+_hf = ss.sosfilt(_sos_hf, (L + R) / 2)
+for i in range(len(target)):
+ s0, s1 = idx[i], idx[i + 1]
+ want = seg_loud(_kl, _kr, s0, s1) + (HF_ORIG[i] - target[i])
+ have = 20 * np.log10(np.sqrt(np.mean(_hf[s0:s1] ** 2)) + 1e-12)
+ if want - have > 2:
+ need = np.sqrt(max(10 ** (want / 10) - 10 ** (have / 10), 0))
+ fade = int(0.01 * SR); n = s1 - s0
+ env = np.ones(n); env[:fade] = np.linspace(0, 1, fade); env[-fade:] = np.linspace(1, 0, fade)
+ for ch, seed in ((L, 11 + i), (R, 41 + i)):
+ z = ss.sosfilt(_sos_hf, np.random.default_rng(seed).standard_normal(n + 2000))[2000:]
+ ch[s0:s1] += z / np.sqrt(np.mean(z ** 2)) * need * env
+
+gain_db = np.zeros(len(target))
+for _ in range(4): # 迭代:尾音跨段会互相影响
+ g = np.zeros(N)
+ for i in range(len(target)):
+ g[idx[i]:idx[i + 1]] = gain_db[i]
+ g = np.convolve(g, np.ones(480) / 480, mode="same") # 10ms 平滑,避免拉链声
+ gl, gr = L * 10 ** (g / 20), R * 10 ** (g / 20)
+ kl, kr = kweight(gl), kweight(gr)
+ for i in range(len(target)):
+ gain_db[i] += target[i] - seg_loud(kl, kr, idx[i], idx[i + 1])
+L, R = gl, gr
+print("逐段增益(dB):", np.round(gain_db, 1))
+
+
+def true_peak(l, r):
+ return 20 * np.log10(max(np.abs(ss.resample_poly(l, 4, 1)).max(), np.abs(ss.resample_poly(r, 4, 1)).max()))
+
+
+def soft_limit(x, ceil): # 只压超过门限的瞬态(前视 1ms 的峰值包络)
+ from scipy.ndimage import maximum_filter1d
+ env = maximum_filter1d(np.abs(x), 96)
+ gr = np.minimum(1, ceil / np.maximum(env, 1e-9))
+ gr = np.convolve(gr, np.ones(96) / 96, mode="same")
+ return x * gr
+
+
+# 模拟流媒体 AAC 的 16kHz 截止(要和参考片质感一致时用,不需要可以删掉)
+_sos16 = ss.butter(10, 15800, "low", fs=SR, output="sos")
+L, R = ss.sosfiltfilt(_sos16, L), ss.sosfiltfilt(_sos16, R)
+
+TARGET_LUFS, TARGET_TP = -14.0, -1.5
+for _ in range(3):
+ cur = lufs(L, R); k = 10 ** ((TARGET_LUFS - cur) / 20); L *= k; R *= k
+ ceil = 10 ** ((TARGET_TP - 0.05) / 20)
+ L, R = soft_limit(L, ceil), soft_limit(R, ceil)
+
+y = np.stack([L, R], 1)
+sf.write(OUT, y, SR, subtype="PCM_24")
+print(f"写出 {OUT.name}: {len(y)} 样本 = {len(y) / SR:.4f}s, 积分响度 {lufs(L, R):.2f} LUFS, 真峰 {true_peak(L, R):.2f} dBTP")
diff --git a/scripts/engine/clip.html b/scripts/engine/clip.html
new file mode 100644
index 0000000..72032e2
--- /dev/null
+++ b/scripts/engine/clip.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<html><head><meta charset="utf-8"><title>参数化动画片段 · clip</title>
+<style>html,body{margin:0;background:#222;overflow:hidden}canvas{display:block;max-width:100vw;max-height:100vh}#ui{position:fixed;left:8px;bottom:8px;color:#ddd;font:12px monospace}body.render #ui{display:none}</style></head>
+<body>
+<canvas id="c" width="1920" height="1080"></canvas>
+<div id="ui"><input id="scrub" type="range" min="0" max="10" step="0.0333" value="0" style="width:600px"> <span id="tt"></span></div>
+<!-- 口播管线用的参数化片段(references/09「片段契约」)。render.py --spec 注入 window.CLIP_SPEC;预览:clip.html?spec=examples/t3_finance_chart.json -->
+<script src="lib/fonts.js"></script>
+<script src="lib/util.js"></script>
+<script src="lib/paint.js"></script>
+<script src="lib/kit.js"></script>
+<script src="lib/motion.js"></script>
+<script src="lib/camera.js"></script>
+<script src="lib/diagram.js"></script>
+<script src="lib/typo.js"></script>
+<script src="lib/chart.js"></script>
+<script src="lib/ui.js"></script>
+<script src="lib/collage.js"></script>
+<script src="lib/toon.js"></script>
+<script src="clip.js"></script>
+</body></html>
diff --git a/scripts/engine/clip.js b/scripts/engine/clip.js
new file mode 100644
index 0000000..af5b946
--- /dev/null
+++ b/scripts/engine/clip.js
@@ -0,0 +1,82 @@
+// 参数化片段运行时:一份 spec(JSON)→ 一段时长严格等于 spec.duration 的动画。给口播视频管线当「动画段」用。
+// 契约见 references/09-视频动画语法.md「片段契约」。和 engine.js 的区别:没有段落表/转场,一个语法一个 draw(c, t, ctx),画布尺寸从 spec 读(竖屏也行)。
+//
+// spec = { grammar, duration, fps=30, width=1920, height=1080, safe?: {top,bottom,left,right(px,留给字幕/平台 UI), fill?(让开的边涂这个色)}, theme?, alpha?, data?, cues: [{at, kind, text?, sub?, data?, image?, dur?}] }
+// 语法文件 clips/<grammar>.js 注册 CLIPS[grammar] = { init?(ctx), draw(c, t, ctx), safe?: true(按 ctx.safe / ctx.box 排版了才写,否则 spec.safe 会告警) }。
+// 对齐约定(CLIP.lt):cue 的「揭开那一帧」= at 所在的那一帧——元素在 t = at 这一帧第一次可见,动画内部时间从 at − 1 帧起算。
+(() => {
+const cv = document.getElementById('c'), c = cv.getContext('2d');
+window.__canvas = cv;
+window.CLIPS = window.CLIPS || {};
+const C = window.CLIP = {};
+const fail = msg => { window.__bootFailed = msg; console.error('CLIP BOOT FAILED\n' + msg); };
+
+// ---------- 给语法文件用的小工具 ----------
+// 片内时间:cue 在 at 这一帧第一次可见
+C.lt = (t, at, fps) => t - at + 1 / fps;
+// 进度:从 at 起 dur 秒走完 0→1(at 这一帧已经 >0)
+C.p = (t, at, dur, fps) => U.clamp(C.lt(t, at, fps) / dur);
+// 等比放进框里(contain,不裁):返回 {x, y, w, h}
+C.fit = (iw, ih, bx, by, bw, bh) => { const s = Math.min(bw / iw, bh / ih); const w = iw * s, h = ih * s; return { x: bx + (bw - w) / 2, y: by + (bh - h) / 2, w, h, s }; };
+// 归一化矩形 [x,y,w,h](0..1,相对图片)→ 画面矩形
+C.sub = (r, box) => ({ x: box.x + r[0] * box.w, y: box.y + r[1] * box.h, w: r[2] * box.w, h: r[3] * box.h });
+C.text = (cue, ...fallback) => (cue && (cue.text ?? cue.data?.text)) ?? fallback.find(v => v != null) ?? '';
+
+async function boot() {
+ let spec = window.CLIP_SPEC;
+ if (!spec) { // 预览:?spec=<相对 engine 的路径>
+ const u = new URLSearchParams(location.search).get('spec');
+ if (!u) return fail('没有 spec:render.py --spec 会注入 window.CLIP_SPEC;预览用 clip.html?spec=examples/<名>.json');
+ spec = await (await fetch(u)).json();
+ const base = u.replace(/[^/]*$/, '');
+ const fix = p => p && !/^(data:|https?:|\/)/.test(p) ? base + p : p;
+ (spec.cues || []).forEach(q => { if (q.image) q.image = fix(q.image); });
+ if (spec.data && spec.data.image) spec.data.image = fix(spec.data.image);
+ }
+ if (location.search.includes('render=1')) document.body.classList.add('render');
+ const W = spec.width || 1920, H = spec.height || 1080, FPS = spec.fps || 30;
+ if (!spec.grammar) return fail('spec 缺 grammar');
+ if (!(spec.duration > 0)) return fail('spec.duration 必须 > 0');
+ cv.width = W; cv.height = H; U.setStage(W, H);
+ // 语法文件(同步 XHR + eval,带 sourceURL,报错能定位)
+ const x = new XMLHttpRequest(); x.open('GET', `clips/${spec.grammar}.js`, false);
+ try { x.send(); } catch (e) { return fail('请求语法文件失败 ' + e); }
+ if (x.status !== 200) return fail(`没有这个语法:clips/${spec.grammar}.js(HTTP ${x.status})`);
+ try { (0, eval)(x.responseText + `\n//# sourceURL=clips/${spec.grammar}.js`); } catch (e) { return fail(`clips/${spec.grammar}.js 执行出错 ${e.stack || e}`); }
+ const G = CLIPS[spec.grammar]; if (!G || typeof G.draw !== 'function') return fail(`clips/${spec.grammar}.js 没注册 CLIPS['${spec.grammar}'] = { draw }`);
+ // 图片
+ const IMG = {}, urls = new Set();
+ (spec.cues || []).forEach(q => q.image && urls.add(q.image)); if (spec.data && spec.data.image) urls.add(spec.data.image);
+ try { await Promise.all([...urls].map(u => new Promise((res, rej) => { const im = new Image(); im.onload = () => { IMG[u] = im; res(); }; im.onerror = () => rej(u); im.src = u; }))); }
+ catch (u) { return fail('图片加载失败:' + u); }
+ // 字体+字形检查(spec 里的字缺字形只警告:回退系统字体照样能渲,但换台机器会变样)
+ for (const f of (window.FONT_FACES || [])) { const ff = new FontFace(f.family, `url(${f.url})`, f.desc || {}); await ff.load(); document.fonts.add(ff); }
+ await document.fonts.ready; await U.loadCmaps();
+ const cues0 = (spec.cues || []).map((q, i) => ({ ...q, i, at: +q.at || 0 })).sort((a, b) => a.at - b.at || a.i - b.i);
+ for (const q of cues0) if (q.at > spec.duration + 1e-9) console.warn(`cue ${q.kind} at=${q.at} 超出片段时长 ${spec.duration}s,看不到,已丢掉(不占版面)`);
+ const cues = cues0.filter(q => q.at <= spec.duration + 1e-9); // 看不到的 cue 不进语法:否则照样占排版位置、进度轨照样数它
+ // number 的说明字段各语法以前各认各的(t2/t3 认 text,y5 认 sub),写错了不报错只是没字。统一:text 与 sub 互为别名,data.text 也算
+ for (const q of cues) if (q.kind === 'number') { const cap = q.text ?? q.sub ?? (q.data && q.data.text); if (cap != null) { q.text = cap; q.sub = cap; } }
+ const safe = { top: 0, bottom: 0, left: 0, right: 0, ...(spec.safe || {}) }; // 让开的边(px):管线烧录字幕、平台 UI 压在这里,带字的语法不往里排
+ const box = { x: safe.left, y: safe.top, w: W - safe.left - safe.right, h: H - safe.top - safe.bottom }; // 让开之后的内容框,语法排版用它(ctx.box)
+ const ctx = { spec, data: spec.data || {}, theme: spec.theme || {}, cues, W, H, FPS, u: Math.min(W, H) / 1080, portrait: H > W, alpha: !!spec.alpha, IMG, dur: spec.duration, safe, box,
+ of: (...kinds) => cues.filter(q => kinds.includes(q.kind)), lt: (t, at) => C.lt(t, at, FPS), p: (t, at, d) => C.p(t, at, d, FPS) };
+ if (G.fonts) { const txt = cues.map(q => [q.text, q.sub, q.data && q.data.text].filter(Boolean).join('')).join('') + JSON.stringify(spec.data || {});
+ for (const fam of G.fonts) { const miss = U.missingGlyphs(fam, [...txt].filter(ch => ch.codePointAt(0) >= 0x2E80).join('')); /* 只查汉字与全角符号:拉丁/希腊/数学符号各语法另有字体 */ if (miss.length) console.warn(`字体「${fam}」缺字:${miss.join('')}(会回退系统字体;常用字已在 GB2312 子集里,生僻字用 scripts/font_subset.py --text 补)`); } }
+ if (spec.safe && (safe.top || safe.bottom || safe.left || safe.right) && !G.safe)
+ console.warn(`语法 ${spec.grammar} 还没接 safe(语法对象里没有 safe: true),spec.safe 被忽略:字幕带可能压在字上`);
+ if (G.init) G.init(ctx);
+ window.CLIP_CTX = ctx;
+ window.__total = spec.duration; window.__fps = FPS; window.__size = [W, H];
+ // safe.fill:让开的边涂成这个颜色(竖屏片把图表做成和相邻 contain 素材同一块「卡片」,外面是片子的底色);透明模式下不涂
+ const band = (safe.fill && !spec.alpha) ? (cc => { cc.fillStyle = safe.fill; const { top: t0, bottom: b0, left: l0, right: r0 } = safe;
+ if (t0) cc.fillRect(0, 0, W, t0); if (b0) cc.fillRect(0, H - b0, W, b0); if (l0) cc.fillRect(0, 0, l0, H); if (r0) cc.fillRect(W - r0, 0, r0, H); }) : null;
+ window.renderFrame = t => { c.setTransform(1, 0, 0, 1, 0, 0); c.clearRect(0, 0, W, H); c.save(); G.draw(c, t, ctx); c.restore(); if (band) band(c); };
+ window.prepare = async () => {};
+ window.__ready = true;
+ window.renderFrame(0);
+ const sc = document.getElementById('scrub'), tt = document.getElementById('tt'); sc.max = spec.duration; sc.step = 1 / FPS;
+ sc.oninput = () => { window.renderFrame(+sc.value); tt.textContent = (+sc.value).toFixed(3); };
+}
+boot().catch(e => fail(String(e && e.stack || e)));
+})();
diff --git a/scripts/engine/clips/t1_3b1b.js b/scripts/engine/clips/t1_3b1b.js
new file mode 100644
index 0000000..5a41358
--- /dev/null
+++ b/scripts/engine/clips/t1_3b1b.js
@@ -0,0 +1,197 @@
+// 片段 · 3b1b / manim 式讲解(t1):纯黑底,一次只放正在讲的那一个东西;字和公式都是 Write(先描边后填色),缓动一律 smooth。
+// 招牌是 Transform:上一个概念直接变成下一个,不切、不淡出重来。
+// cues:title(at 这一帧开始 Write;再来一个 title 时旧标题 FadeOut 上移;太长先缩字号、再折两行)
+// equation(data.tokens = DG.math 的 token 数组,或只给 text;颜色=概念名:col 写 'BLUE_C' 等 manim 色名或 #hex)
+// 第二个起的 equation 不重新 Write,而是从上一个 Transform 过来(TransformMatchingTex:同名符号移到新位置,对不上的淡出/淡入;默认 1.5s)
+// point(要点一句一行,Write;新要点出来时旧的变灰)
+// line(坐标系先 Create,再画曲线:data.values = [y...](等距)或 data.points = [[x,y]...];text = 曲线标签;data.color)
+// 第二个起的 line 是 Transform:上一条曲线逐点(按弧长对齐重采样)形变成这一条,颜色和标签一起换,坐标系不动
+// highlight(Indicate+黄色框住并留住:data.index = 第几个要点(只数 point,从 0 起;默认最新);data.target = 'equation' 时框公式)
+// 布局:有 line 时横屏左文右图、竖屏上图下文;要点块在剩下的高度里竖直居中。safe:内容只排在 top..H−bottom 之间。
+// 公式太宽就整体缩字号(所有公式同一字号,Transform 时不跳),竖屏长公式不出画。
+// 字形:CMU 斜体把 θ 画成 ϑ,θ 改用 EB Garamond 斜体(闭合的 θ);连续两个以上的字母(softmax、ReLU)按正体单词排,单个字母才是斜体变量。
+// alpha:透明底时字外面描一圈深色边,压在亮画面上也看得见。
+CLIPS.t1_3b1b = (() => {
+const { clamp, lerp } = U;
+let M, L;
+const col = v => !v ? null : M[v] || v;
+const isZh = ch => ch.codePointAt(0) >= 0x2E80;
+// 一段字 → token:汉字/全角走普惠体;连续 ≥2 个字母是单词(正体);单个字母斜体;其余(数字、符号、希腊字母)正体
+const toks = text => (String(text).match(/[A-Za-z]{2,}|./gu) || []).flatMap(s => s.length > 1 && !/[a-z]/.test(s) ? [...s] : [s]) // 全大写的一串(QK)是几个变量,拆开
+ .map(s => ({ s, zh: isZh(s), it: /^[a-zA-Z]$/.test(s), gap: 0 }));
+// θ 用 EB Garamond 斜体画(CMU 的 θ 是 ϑ 字形)。只换这一个 token 的字体:逐 token 调 DG.math,期间临时改 DG.FONT
+const THETA = /[θΘ]/;
+const withFont = (tk, fn) => { if (!THETA.test(tk.s)) return fn(tk); const o = { ...DG.FONT }; DG.FONT.it = DG.FONT.rm = 'EBGaramond-400i';
+ try { return fn({ ...tk, zh: false, it: true }); } finally { Object.assign(DG.FONT, o); } };
+const layoutT = (c, tokens, size) => { let x = 0; return tokens.map(tk => { const w = withFont(tk, t2 => DG.layout(c, [{ ...t2, gap: 0 }], size)[0].w), sz = (tk.size || 1) * size;
+ const r = { x, w }; x += w + (tk.gap != null ? tk.gap : sz * 0.06); return r; }); };
+const widthT = (c, tokens, size) => { const l = layoutT(c, tokens, size); return l.length ? l[l.length - 1].x + l[l.length - 1].w : 0; };
+// Write 一串 token(等价于 DG.math 整串调用:token 间按 manim LaggedStart 错开),返回每个 token 的屏幕 {x, w}
+const writeT = (c, tokens, x, y, size, p, { align = 'center', col: cl = '#fff' } = {}) => {
+ const Lt = layoutT(c, tokens, size), tot = Lt.length ? Lt[Lt.length - 1].x + Lt[Lt.length - 1].w : 0, x0 = align === 'center' ? x - tot / 2 : align === 'right' ? x - tot : x;
+ const n = tokens.length, r = Math.min(4 / (n + 1), 0.2);
+ tokens.forEach((tk, i) => { const q = MO.lagged(i, n, clamp(p), r); if (q > 0) withFont(tk, t2 => DG.math(c, [t2], x0 + Lt[i].x, y, size, { p: q, align: 'left', col: cl })); });
+ return Lt.map(l => ({ x: x0 + l.x, w: l.w }));
+};
+// 按弧长等分重采样成 n 个点(Transform 前两条曲线要点数相同、起点对齐)
+const resample = (pts, n) => { const cum = DG.cum(pts), T = cum[cum.length - 1]; return Array.from({ length: n }, (_, i) => DG.pointAt(pts, cum, T * i / (n - 1))); };
+// 折行但各行等长(不让一个字母/单词孤零零挂到下一行)
+const balance = (g, text, maxW, font) => { const n = TY.wrap(g, text, maxW, font).length; if (n < 2) return [text];
+ let lo = maxW * 0.4, hi = maxW; for (let k = 0; k < 14; k++) { const m = (lo + hi) / 2; if (TY.wrap(g, text, m, font).length > n) lo = m; else hi = m; } return TY.wrap(g, text, hi, font); };
+// 标题:先缩字号放一行(最小 0.75),放不下就等长折行(竖屏最多 3 行、横屏 2 行),再缩到每行放得下
+const titleLines = (c, text, maxW, size, maxLines) => {
+ let s = size; while (s > size * 0.75 && widthT(c, toks(text), s) > maxW) s *= 0.95;
+ if (widthT(c, toks(text), s) <= maxW) return { size: s, lines: [text] };
+ s = size * 0.9; let lines = balance(c, text, maxW, `${s}px "PuHui-Medium"`);
+ while (lines.length > maxLines) { s *= 0.94; lines = balance(c, text, maxW, `${s}px "PuHui-Medium"`); }
+ while (s > size * 0.45 && Math.max(...lines.map(l => widthT(c, toks(l), s))) > maxW) s *= 0.95;
+ return { size: s, lines };
+};
+let BUF;
+return {
+ fonts: ['PuHui-Medium'],
+ safe: true,
+ init(ctx) {
+ M = DG.MANIM; DG.FONT.zh = 'PuHui-Medium'; // 任意中文:普惠体(思源宋子集只有示范片用到的字)
+ const { W, H, u, safe } = ctx, g = document.createElement('canvas').getContext('2d');
+ const pad = (ctx.portrait ? 70 : 140) * u, yTop = safe.top, yBot = H - safe.bottom - (ctx.portrait ? 90 : 70) * u;
+ const hasLine = ctx.of('line').length > 0, hasEq = ctx.of('equation').length > 0;
+ // 标题
+ const titles = ctx.of('title').map(q => ({ q, ...titleLines(g, q.text || '', W - 2 * pad, (ctx.portrait ? 72 : 62) * u, ctx.portrait ? 3 : 2) }));
+ const tH = titles.length ? Math.max(...titles.map(z => z.lines.length * z.size * 1.25)) : 0;
+ const titleY = yTop + (ctx.portrait ? 170 : 130) * u;
+ let y = titles.length ? titleY + tH : yTop + 90 * u;
+ let eqSz = (ctx.portrait ? 72 : 66) * u;
+ for (const q of ctx.of('equation')) { const tk = q.data && q.data.tokens ? q.data.tokens : toks(q.text || ''), w = widthT(g, tk, eqSz) + 60 * u; if (w > W - 2 * pad) eqSz *= (W - 2 * pad) / w; }
+ const eqY = y + eqSz * (titles.length ? 1.15 : 0.9);
+ if (hasEq) y = eqY + eqSz * 0.6;
+ y += 30 * u;
+ // 要点:预先折行(每条可能多行)
+ const size0 = (hasLine ? (ctx.portrait ? 56 : 50) : (ctx.portrait ? 62 : 58)) * u;
+ let text, plot = null;
+ if (hasLine && ctx.portrait) { plot = { x: pad + 20 * u, y: y + 20 * u, w: W - 2 * pad - 20 * u, h: (yBot - y) * 0.5 }; text = { x: pad, y0: plot.y + plot.h + 70 * u, y1: yBot, w: W - 2 * pad }; }
+ else if (hasLine) { plot = { x: W * 0.52, y: y + 20 * u, w: W * 0.48 - pad, h: yBot - y - 40 * u }; text = { x: pad, y0: y, y1: yBot, w: W * 0.47 - pad }; }
+ else text = { x: pad, y0: y, y1: yBot, w: W - 2 * pad };
+ // 要点放不下(竖屏有曲线、要点多):先让曲线让位(竖屏 50% → 最少 30%),再缩字号(最小 0.6 倍),不压进 safe.bottom
+ let points, blockH, size = size0; const gapP = 36 * u, room = yBot - y;
+ for (let k = 1; ; k *= 0.94) {
+ size = size0 * k;
+ points = ctx.of('point').map(q => { const lines = balance(g, q.text || '', text.w - 50 * u, `${size}px "PuHui-Medium"`); return { q, lines, h: lines.length * size * 1.35 }; });
+ blockH = points.reduce((s, p) => s + p.h + gapP, 0) - gapP;
+ if (plot && ctx.portrait) { plot.h = Math.max(room * 0.3, Math.min(room * 0.5, room - 110 * u - blockH)); text.y0 = plot.y + plot.h + 70 * u; }
+ if (blockH <= text.y1 - text.y0 || k < 0.6) break;
+ }
+ if (blockH > text.y1 - text.y0 + 1) console.warn(`t1:${points.length} 条要点缩到 0.6 倍字号仍放不下(超出 ${Math.round(blockH - (text.y1 - text.y0))}px):新要点出来时整块上卷、最早的淡出;想全留在屏上就删几条或拆成两段`);
+ let py = text.y0 + Math.max(0, (text.y1 - text.y0 - blockH) / 2) * (hasLine && !ctx.portrait ? 1 : 0.6); // 要点块竖直居中(竖屏略偏上)
+ for (const p of points) { p.y = py + size; py += p.h + gapP; p.need = Math.max(0, py - gapP - text.y1); } // need:这一条出来时整块要上卷多少才不越过 y1
+ // 曲线:坐标统一用所有 line 的数据范围(Transform 时坐标系不动)
+ const lines = ctx.of('line').map(q => { const d = q.data || {}; return { q, d, pts0: d.points || (d.values || []).map((v, i) => [i, v]) }; }).filter(l => l.pts0.length >= 2);
+ if (plot && lines.length) {
+ const all = lines.flatMap(l => l.pts0), xs = all.map(p => p[0]), ys = all.map(p => p[1]);
+ const x0 = Math.min(...xs), x1 = Math.max(...xs), y0 = Math.min(0, ...ys); let y1 = Math.max(...ys); if (y1 === y0) y1 = y0 + 1;
+ plot.X = v => plot.x + (v - x0) / ((x1 - x0) || 1) * plot.w; plot.Y = v => plot.y + plot.h - (v - y0) / (y1 - y0) * plot.h * 0.9;
+ for (const l of lines) { const [lx0, lx1] = [Math.min(...l.pts0.map(p => p[0])), Math.max(...l.pts0.map(p => p[0]))];
+ // 每条曲线横向铺满坐标系(不同 line 的 x 量纲可以不同:损失-参数 → 损失-步数)
+ l.scr = l.pts0.map(([px, py]) => [plot.x + (px - lx0) / ((lx1 - lx0) || 1) * plot.w, plot.Y(py)]); l.rs = resample(l.scr, 160); }
+ }
+ L = { titleY, titles, eqY, eqSz, text, plot, points, size, lines };
+ },
+ draw(c0, t, ctx) {
+ const { W, H, u } = ctx;
+ const c = ctx.alpha ? (BUF = BUF || document.createElement('canvas'), BUF.width = W, BUF.height = H, BUF.getContext('2d')) : c0;
+ if (!ctx.alpha) { c.fillStyle = '#000'; c.fillRect(0, 0, W, H); }
+ // ---- 标题(同一时间只有一个,换标题 = 旧的上移淡出、新的 Write) ----
+ L.titles.forEach((z, i) => {
+ const q = z.q, nx = L.titles[i + 1], out = nx ? MO.smooth(MO.seg(t, nx.q.at - 0.45, nx.q.at)) : 0; if (out >= 1 || ctx.lt(t, q.at) <= 0) return;
+ const n = [...(q.text || '')].length, dur = q.dur || clamp(n / 14, 0.6, 1.6);
+ c.save(); c.globalAlpha = 1 - out; c.translate(0, -50 * u * out);
+ z.lines.forEach((ln, k) => writeT(c, toks(ln), W / 2, L.titleY + k * z.size * 1.25, z.size, ctx.p(t, q.at + k * dur / z.lines.length, dur / z.lines.length), { col: col(q.data && q.data.color) || '#fff' }));
+ c.restore();
+ });
+ // ---- 公式:第一个 Write,之后每个从上一个 TransformMatchingTex 过来 ----
+ let eqBox = null;
+ const eqs = ctx.of('equation').map(q => (q.data && q.data.tokens ? q.data.tokens : toks(q.text || '')).map(k => ({ ...k, col: col(k.col) })));
+ const eqCues = ctx.of('equation'), sz = L.eqSz;
+ let k = -1; eqCues.forEach((q, i) => { if (ctx.lt(t, q.at) > 0) k = i; });
+ if (k >= 0) {
+ const q = eqCues[k], tk = eqs[k], Ln = layoutT(c, tk, sz), tot = Ln.length ? Ln[Ln.length - 1].x + Ln[Ln.length - 1].w : 0, x0 = W / 2 - tot / 2;
+ if (k === 0) writeT(c, tk, W / 2, L.eqY, sz, ctx.p(t, q.at, q.dur || 1.2));
+ else {
+ const p = MO.smooth(ctx.p(t, q.at, q.dur || 1.5)), old = eqs[k - 1], Lo = layoutT(c, old, sz), toto = Lo.length ? Lo[Lo.length - 1].x + Lo[Lo.length - 1].w : 0, xo = W / 2 - toto / 2;
+ const used = new Set(), from = tk.map(nt => { const j = old.findIndex((ot, jj) => !used.has(jj) && ot.s === nt.s && (ot.sub || '') === (nt.sub || '') && (ot.sup || '') === (nt.sup || '')); if (j >= 0) used.add(j); return j; });
+ const one = (tok, x, a, cl) => { if (a <= 0) return; c.save(); c.globalAlpha *= a; withFont(tok, t2 => DG.math(c, [{ ...t2, col: cl }], x, L.eqY, sz, { p: 1, align: 'left' })); c.restore(); };
+ old.forEach((ot, j) => { if (!used.has(j)) { c.save(); c.translate(0, -30 * u * p); one(ot, xo + Lo[j].x, 1 - clamp(p * 1.6), ot.col || '#fff'); c.restore(); } }); // 对不上的旧符号:淡出上移
+ tk.forEach((nt, i) => { const j = from[i];
+ if (j >= 0) one(nt, lerp(xo + Lo[j].x, x0 + Ln[i].x, p), 1, DG.mix(old[j].col || '#ffffff', nt.col || '#ffffff', p)); // 同名符号:移到新位置,颜色插值
+ else { c.save(); c.translate(0, 30 * u * (1 - p)); one(nt, x0 + Ln[i].x, clamp((p - 0.35) / 0.65), nt.col || '#fff'); c.restore(); } }); // 新符号:淡入
+ }
+ if (Ln.length) eqBox = { x: x0 - 20 * u, y: L.eqY - sz * 0.95, w: tot + 40 * u, h: sz * 1.35 };
+ }
+ // ---- 坐标系+曲线:第一条 Create,之后每条从上一条逐点形变过来 ----
+ const P = L.plot;
+ if (P && L.lines.length) {
+ const l0 = L.lines[0];
+ if (ctx.lt(t, l0.q.at) > 0) {
+ const ap = MO.smooth(ctx.p(t, l0.q.at, 0.6)), lw = 3 * u;
+ c.save(); c.strokeStyle = M.GREY_B; c.lineWidth = lw; c.lineCap = 'round';
+ c.beginPath(); c.moveTo(P.x, P.Y(0)); c.lineTo(P.x + P.w * ap, P.Y(0)); c.moveTo(P.x, P.y + P.h); c.lineTo(P.x, P.y + P.h - P.h * ap); c.stroke();
+ c.globalAlpha = ap; for (let kk = 1; kk <= 4; kk++) { const xx = P.x + P.w * kk / 4; c.beginPath(); c.moveTo(xx, P.Y(0) - 8 * u); c.lineTo(xx, P.Y(0) + 8 * u); c.stroke(); }
+ c.restore();
+ let j = 0; L.lines.forEach((l, i) => { if (ctx.lt(t, l.q.at) > 0) j = i; });
+ const l = L.lines[j], lc = col(l.d.color) || M.BLUE_C;
+ c.save(); c.lineWidth = 5 * u; c.lineJoin = 'round'; c.lineCap = 'round';
+ if (j === 0) {
+ const cp = MO.smooth(ctx.p(t, l.q.at + 0.5, l.q.dur || 1.4));
+ if (cp > 0) { const cum = DG.cum(l.scr); c.strokeStyle = lc; const tip = DG.drawPartial(c, l.scr, cum, cum[cum.length - 1] * cp);
+ if (cp < 1) DG.neuron(c, tip[0], tip[1], 10 * u, 1, { fill: lc, stroke: '#fff', lw: 2 * u }); }
+ label(c, l, MO.smooth(MO.seg(cp, 0.8, 1)), lc, u);
+ } else {
+ const pv = L.lines[j - 1], p = MO.smooth(ctx.p(t, l.q.at, l.q.dur || 1.5)), pc = col(pv.d.color) || M.BLUE_C;
+ const pts = DG.morph(pv.rs, l.rs, p); c.strokeStyle = DG.mix(pc, lc, p); c.beginPath(); pts.forEach((q, i) => i ? c.lineTo(q[0], q[1]) : c.moveTo(q[0], q[1])); c.stroke();
+ label(c, pv, 1 - clamp(p * 2), pc, u); label(c, l, clamp(p * 2 - 1), lc, u);
+ }
+ c.restore();
+ }
+ }
+ // ---- 要点 ----
+ const hl = ctx.of('highlight'), size = L.size;
+ const target = h => h.data && h.data.target === 'equation' ? -2 : h.data && h.data.index != null ? h.data.index : L.points.filter(p => p.q.at <= h.at).length - 1;
+ const roll = Math.max(0, ...L.points.map(p => p.need * MO.smooth(ctx.p(t, p.q.at - 0.3, 0.4)))); // 放不下时:新要点出来前 0.3s 整块上卷,越过顶的淡出
+ L.points.forEach((it0, i) => {
+ const q = it0.q; if (ctx.lt(t, q.at) <= 0) return;
+ const it = roll ? { ...it0, y: it0.y - roll } : it0, over = L.text.y0 - (it.y - size);
+ if (over > 0 && clamp(1 - over / (size * 1.2)) <= 0) return;
+ c.save(); if (over > 0) c.globalAlpha *= clamp(1 - over / (size * 1.2));
+ const nx = L.points[i + 1], h = [...hl].reverse().find(z => target(z) === i && t >= z.at - 1e-6) || null, hOther = hl.some(z => t >= z.at && target(z) !== i && z.at > (h ? h.at : -1));
+ const dimN = nx ? MO.smooth(ctx.p(t, nx.q.at, 0.4)) : 0;
+ const n = [...(q.text || '')].length, dur = q.dur || clamp(n / 16, 0.6, 1.8);
+ // Indicate:放大 1.2、染黄、回来;之后这一条保持黄色(被强调的留住),其余变灰
+ const ip = h && !hOther ? ctx.p(t, h.at, 0.8) : 0, ind = DG.indicate(ip), keep = h && !hOther ? MO.smooth(clamp(ip * 2)) : 0;
+ const dim = keep > 0 ? 0 : dimN;
+ const base = DG.mixA(DG.mixA('#ffffff', M.GREY_C, dim), M.YELLOW, Math.max(keep, ind.k)), colr = DG.rgba(base);
+ const bx = L.text.x + 14 * u, by = it.y - size * 0.36;
+ c.save(); c.translate(bx, by); c.scale(ind.s, ind.s); c.translate(-bx, -by);
+ DG.neuron(c, bx, by, 12 * u, 1 - dim * 0.6, { lw: 2 * u, stroke: colr, fill: col(q.data && q.data.color) || M.BLUE_C, sa: MO.smooth(ctx.p(t, q.at, 0.3)) });
+ let wMax = 0;
+ it.lines.forEach((ln, kk) => { const r = writeT(c, toks(ln), L.text.x + 50 * u, it.y + kk * size * 1.35, size, ctx.p(t, q.at + kk * dur / it.lines.length, dur / it.lines.length), { align: 'left', col: colr });
+ if (r.length) wMax = Math.max(wMax, r[r.length - 1].x + r[r.length - 1].w - (L.text.x + 50 * u)); });
+ c.restore();
+ if (h && !hOther) box(c, L.text.x - 16 * u, it.y - size * 1.05, wMax + 90 * u, it.lines.length * size * 1.35 + 18 * u, ctx.lt(t, h.at), u);
+ c.restore();
+ });
+ const he = [...hl].reverse().find(z => target(z) === -2 && t >= z.at);
+ if (he && eqBox && !hl.some(z => t >= z.at && z.at > he.at)) box(c, eqBox.x, eqBox.y, eqBox.w, eqBox.h, ctx.lt(t, he.at), u);
+ if (ctx.alpha) { c0.save(); c0.shadowColor = 'rgba(0,0,0,0.9)'; c0.shadowBlur = 10 * u; c0.drawImage(BUF, 0, 0); c0.shadowBlur = 3 * u; c0.drawImage(BUF, 0, 0); c0.restore(); }
+ },
+};
+// 曲线标签:放在曲线末端上方
+function label(c, l, a, colr, u) { if (!l.q.text || a <= 0) return; const e = l.scr[l.scr.length - 1];
+ c.save(); c.globalAlpha *= a; c.font = `${40 * u}px "PuHui-Medium"`; c.fillStyle = colr; c.textAlign = 'right'; c.fillText(l.q.text, e[0], e[1] - 30 * u); c.restore(); }
+// 强调框:Circumscribe 先绕一圈(1s),同时 SurroundingRectangle 画出来并留住(末帧有焦点)
+function box(c, x, y, w, h, lt, u) {
+ if (lt <= 0) return; DG.circumscribe(c, x - 8 * u, y - 8 * u, w + 16 * u, h + 16 * u, MO.seg(lt, 0, 1.0), { lw: 4 * u });
+ const p = MO.smooth(MO.seg(lt, 0.3, 1.0)); if (p <= 0) return;
+ const pts = DG.rectPts(x + w / 2, y + h / 2, w, h, 120); c.save(); c.strokeStyle = DG.MANIM.YELLOW; c.lineWidth = 3 * u; c.lineJoin = 'round';
+ DG.drawPartial(c, [...pts, pts[0]], DG.cum([...pts, pts[0]]), DG.len([...pts, pts[0]]) * p); c.restore();
+}
+})();
diff --git a/scripts/engine/clips/t2_keynote_ui.js b/scripts/engine/clips/t2_keynote_ui.js
new file mode 100644
index 0000000..429158b
--- /dev/null
+++ b/scripts/engine/clips/t2_keynote_ui.js
@@ -0,0 +1,243 @@
+// 片段 · 发布会式界面(t2),做教程、功能、参数最顺手:深色光斑底,一屏一件事;字从模糊里浮出,卡片是毛玻璃、轻回弹落位。
+// data: { eyebrow?(标题上方小字), title?, subtitle?, accent?:'#3d6bff' }
+// cues:title(at 这一帧标题开始从模糊里浮出;text/sub 覆盖 data)
+// card | step | image(一张卡:text 卡标题,sub 说明,image 截图路径;at 这一帧卡片开始弹入;步骤号按出现顺序 01、02…,data.step 可指定)
+// · 有 image:一屏一张,截图等比放进卡里(contain,不裁)。横图横卡;竖图(手机截图)在横屏里是「左字右图」,图撑满高度
+// · 没有 image:功能卡。连着的几张(最多 3 张)并排站在一屏里,新卡进来时旧卡让位(像示范片的三卡并列);
+// 卡上有图标(data.icon:wave memory agent clock phone layers chart code check play bolt lock,不写就画步骤号)、
+// 大标题、说明,可选一个大数字(data.value / prefix / suffix / decimals + data.label,卡片落定后计数)
+// highlight(框出当前截图卡里的一块:data.rect = [x, y, w, h],相对截图的 0..1;text 可选标签)
+// number(大数字单独一屏:data {value, prefix, suffix, decimals, label?(数字上方小字)};at = 数字落定时刻,提前 0.9s 开始计数,
+// 上一屏这时开始退场,不叠在卡片上;说明写 text 或 sub 都认)
+// 竖屏:第一张卡进来时标题缩成页眉留在顶上(不让上下大片空着);卡片按剩余高度放大。safe:版面只排在 top..H−bottom 之间。
+// alpha:不画光斑底;卡片垫一层深色、字带投影,压在亮画面上也看得清。
+CLIPS.t2_keynote_ui = (() => {
+const { clamp, lerp } = U;
+const SANS = '"Inter", "PuHui-Medium"', SANSB = '"Inter", "PuHui-Bold"', ZH = '"PuHui-Medium"', ZHB = '"PuHui-Bold"';
+let BL, slides, scr = {}, G;
+const track = (c, size, em = -0.02) => { c.letterSpacing = (size * em).toFixed(2) + 'px'; };
+// 本语法自带的几个线性图标(UI.icon 只有 wave/memory/agent):单位框 ±0.5,圆头等线宽
+const ICON = {
+ clock: c => { c.beginPath(); c.arc(0, 0, 0.42, 0, 7); c.stroke(); c.beginPath(); c.moveTo(0, -0.24); c.lineTo(0, 0); c.lineTo(0.18, 0.1); c.stroke(); },
+ phone: c => { c.beginPath(); c.roundRect(-0.25, -0.45, 0.5, 0.9, 0.1); c.stroke(); c.beginPath(); c.moveTo(-0.08, 0.32); c.lineTo(0.08, 0.32); c.stroke(); },
+ layers: c => { for (let k = 0; k < 3; k++) { const y = -0.22 + k * 0.22; c.globalAlpha = k ? 0.6 : 1; c.beginPath(); c.moveTo(-0.45, y); c.lineTo(0, y - 0.18); c.lineTo(0.45, y); c.lineTo(0, y + 0.18); c.closePath(); c.stroke(); } c.globalAlpha = 1; },
+ chart: c => { c.beginPath(); c.moveTo(-0.42, -0.42); c.lineTo(-0.42, 0.4); c.lineTo(0.44, 0.4); c.stroke(); c.beginPath(); c.moveTo(-0.28, 0.18); c.lineTo(-0.06, -0.04); c.lineTo(0.1, 0.06); c.lineTo(0.36, -0.26); c.stroke(); },
+ code: c => { c.beginPath(); c.moveTo(-0.18, -0.28); c.lineTo(-0.42, 0); c.lineTo(-0.18, 0.28); c.moveTo(0.18, -0.28); c.lineTo(0.42, 0); c.lineTo(0.18, 0.28); c.moveTo(0.08, -0.38); c.lineTo(-0.08, 0.38); c.stroke(); },
+ check: c => { c.beginPath(); c.arc(0, 0, 0.42, 0, 7); c.stroke(); c.beginPath(); c.moveTo(-0.2, 0); c.lineTo(-0.05, 0.16); c.lineTo(0.22, -0.16); c.stroke(); },
+ play: c => { c.beginPath(); c.moveTo(-0.22, -0.34); c.lineTo(0.34, 0); c.lineTo(-0.22, 0.34); c.closePath(); c.fill(); },
+ bolt: c => { c.beginPath(); c.moveTo(0.08, -0.46); c.lineTo(-0.28, 0.06); c.lineTo(0, 0.06); c.lineTo(-0.08, 0.46); c.lineTo(0.28, -0.06); c.lineTo(0, -0.06); c.closePath(); c.fill(); },
+ lock: c => { c.beginPath(); c.roundRect(-0.32, -0.04, 0.64, 0.46, 0.08); c.stroke(); c.beginPath(); c.arc(0, -0.04, 0.2, Math.PI, 0); c.stroke(); },
+};
+const icon = (g, kind, x, y, s, col, t) => {
+ if (['wave', 'memory', 'agent'].includes(kind)) return UI.icon(g, kind, x, y, s, col, t);
+ const f = ICON[kind]; if (!f) return false;
+ g.save(); g.translate(x, y); g.scale(s, s); g.strokeStyle = col; g.fillStyle = col; g.lineWidth = 0.075; g.lineCap = 'round'; g.lineJoin = 'round'; f(g); g.restore();
+};
+// 放得下才算:TY.fit 量每行宽度,多行折成等长(说明文字不留一个字挂在下一行)
+const fitB = (g, text, maxW, size, fam, o = {}) => TY.fit(g, text, maxW, size, fam, { ...o, balance: true });
+const fmtNum = (d, k) => (d.prefix || '') + TY.fmt((+d.value || 0) * k, d.decimals ?? 0) + (d.suffix || '');
+return {
+ fonts: ['PuHui-Medium', 'PuHui-Bold'],
+ safe: true,
+ init(ctx) {
+ const { W, H, u, safe } = ctx;
+ BL = [{ x: .22 * W, y: .28 * H, r: .4 * Math.max(W, H), col: [150, 90, 238], a: .75, ax: .11 * W, ay: .11 * H, period: 11, ph: 0 },
+ { x: .79 * W, y: .24 * H, r: .37 * Math.max(W, H), col: [56, 104, 255], a: .7, ax: .1 * W, ay: .15 * H, period: 13, ph: 2.1 },
+ { x: .69 * W, y: .86 * H, r: .3 * Math.max(W, H), col: [120, 214, 255], a: .5, ax: .13 * W, ay: .09 * H, period: 9.5, ph: 4 },
+ { x: .27 * W, y: .89 * H, r: .27 * Math.max(W, H), col: [255, 96, 84], a: .42, ax: .09 * W, ay: .08 * H, period: 12, ph: 1.3 }];
+ const hasTitle = ctx.of('title').length > 0, hdr = ctx.portrait && hasTitle;
+ G = { y0: safe.top + (hdr ? 250 * u : 40 * u), y1: H - safe.bottom - 40 * u, hdrY: safe.top + 150 * u, hdr };
+ G.cy = (G.y0 + G.y1) / 2; G.bh = G.y1 - G.y0;
+ // 分屏:截图卡一张一屏;连着的无图卡最多 3 张一屏;number 单独一屏
+ slides = []; let k = 0;
+ for (const q of ctx.cues) {
+ if (['card', 'step', 'image'].includes(q.kind)) {
+ const n = q.data && q.data.step != null ? q.data.step : ++k, im = q.image && ctx.IMG[q.image], cd = { q, n, im };
+ const last = slides[slides.length - 1];
+ if (!im && last && last.type === 'cards' && last.cards.length < 3) last.cards.push(cd);
+ else slides.push({ type: im ? 'img' : 'cards', cards: [cd], start: q.at });
+ } else if (q.kind === 'number') slides.push({ type: 'num', q, start: q.at - 0.9 });
+ }
+ slides.forEach((s, i) => { s.next = slides[i + 1] ? slides[i + 1].start : 1e9; });
+ // 截图卡的版式:标题行 + 截图区;截图区按截图比例定。竖图在横屏里改成「左字右图」
+ const maxW = W * (ctx.portrait ? 0.9 : 0.8), maxH = G.bh * (ctx.portrait ? 0.92 : 0.86), head = (ctx.portrait ? 230 : 130) * u, pad = 36 * u;
+ for (const s of slides) if (s.type === 'img') {
+ const cd = s.cards[0], ar = cd.im.width / cd.im.height;
+ if (!ctx.portrait && ar < 0.9) { // 横屏放竖图:左字右图,图撑满卡高
+ const ih = maxH - 2 * pad, iw = ih * ar, tw = 560 * u;
+ cd.box = { w: tw + iw + 3 * pad, h: maxH, img: { x: tw + 2 * pad, y: pad, w: iw, h: ih }, side: tw };
+ } else {
+ let iw = maxW - 2 * pad, ih = iw / ar; if (ih > maxH - head - 2 * pad) { ih = maxH - head - 2 * pad; iw = ih * ar; }
+ const cw = Math.max(iw + 2 * pad, Math.min(maxW, 760 * u)), ch = ih + head + 2 * pad;
+ cd.box = { w: cw, h: ch, img: { x: (cw - iw) / 2, y: head + pad, w: iw, h: ih } };
+ }
+ }
+ },
+ draw(c, t, ctx) {
+ const { W, H, u, data: d } = ctx, acc = d.accent || '#3d6bff';
+ // ---- 底:光斑(只依赖片段时间,连续) ----
+ let bd = null;
+ if (!ctx.alpha) {
+ const bgc = UI.scratch('clip_t2bg', W, H), g = bgc.getContext('2d'); g.clearRect(0, 0, W, H); // 先清空:不清的话上一帧的残留会透过半透明边缘,同一时刻先后渲出来差 1 个色阶(qa 确定性 ✗)
+ UI.mesh(g, t, { base: '#050508', blobs: BL, blur: 90, scale: 0.25, grain: 0.035, key: 'clip_t2mesh' });
+ const vg = g.createRadialGradient(W / 2, H / 2, 100 * u, W / 2, H / 2, Math.max(W, H) * 0.55); vg.addColorStop(0, 'rgba(0,0,0,0.38)'); vg.addColorStop(1, 'rgba(0,0,0,0.1)');
+ g.fillStyle = vg; g.fillRect(0, 0, W, H); c.drawImage(bgc, 0, 0); bd = UI.backdrop(bgc, { blur: 40, key: 'clip_t2bd' });
+ }
+ const shadowText = g => { if (ctx.alpha) { g.shadowColor = 'rgba(0,0,0,0.75)'; g.shadowBlur = 18 * u; g.shadowOffsetY = 3 * u; } };
+ // ---- 标题:眉题 → 主标题(模糊→清晰+上移)→ 副标题;第一屏进来时:横屏退到后面,竖屏缩成页眉留在顶上 ----
+ const qt = ctx.of('title')[0], first = slides[0] ? slides[0].start : 1e9;
+ if (qt) {
+ const out = MO.appleOut(MO.seg(t, first - 0.15, first + 0.5));
+ const keep = G.hdr, title = qt.text ?? d.title ?? '', eb = (qt.data && qt.data.eyebrow) ?? d.eyebrow, sub = qt.sub ?? d.subtitle;
+ if (out < 1 || keep) {
+ c.save(); c.textAlign = 'center'; c.textBaseline = 'alphabetic'; shadowText(c);
+ let sz = TY.fit(c, title, W * 0.86, (ctx.portrait ? 150 : 190) * u, 'Inter', { maxLines: 1, min: 0.55, weight: '600 ', soft: true }); // 先缩字号放一行,放不下再折两行
+ if (!sz.ok) sz = fitB(c, title, W * 0.86, (ctx.portrait ? 150 : 190) * u, 'Inter', { maxLines: 2, weight: '600 ' });
+ const cy = G.cy - (sz.lines.length - 1) * sz.size * 0.55;
+ // 竖屏:整块缩到页眉(主标题 → 约 64px),眉题和副标题淡出
+ const hs = keep ? Math.min(1, 68 * u / sz.size) : 1, sc = keep ? lerp(1, hs, out) : lerp(1, 0.92, out), ty = keep ? lerp(0, G.hdrY - cy, out) : 0;
+ c.translate(W / 2, cy + ty); c.scale(sc, sc); c.translate(-W / 2, -cy);
+ const aSide = 1 - out;
+ if (!keep) { c.globalAlpha = 1 - out; if (out > 0) c.filter = `blur(${(20 * out * u).toFixed(1)}px)`; }
+ if (eb && aSide > 0) { c.save(); c.globalAlpha *= keep ? aSide : 1; c.font = `500 ${34 * u}px ${ZH}`; c.fillStyle = '#a7a7b4'; c.letterSpacing = `${6 * u}px`; TY.blurIn(c, eb, W / 2, cy - sz.size * 0.95, MO.appleOut(ctx.p(t, qt.at, 0.7)), { blur: 10 * u, dy: 16 * u }); c.restore(); }
+ c.font = `600 ${sz.size}px ${SANSB}`; track(c, sz.size); c.fillStyle = '#f5f3ff';
+ sz.lines.forEach((ln, i) => TY.blurIn(c, ln, W / 2, cy + i * sz.size * 1.1, MO.appleOut(ctx.p(t, qt.at + 0.15 + i * 0.12, 1.0)), { blur: 26 * u, dy: 40 * u }));
+ if (sub && aSide > 0) { c.save(); c.globalAlpha *= keep ? aSide : 1; c.letterSpacing = '0px'; c.font = `400 ${46 * u}px ${ZH}`; c.fillStyle = '#c9c9d4';
+ TY.wrap(c, sub, W * 0.84).forEach((ln, i) => TY.blurIn(c, ln, W / 2, cy + (sz.lines.length - 1) * sz.size * 1.1 + 110 * u + i * 62 * u, MO.appleOut(ctx.p(t, qt.at + 0.5, 0.9)), { blur: 12 * u, dy: 22 * u })); c.restore(); }
+ c.restore();
+ }
+ }
+ // ---- 每一屏:下一屏开始时往左后方退走(0.65s),不和下一屏的内容叠着 ----
+ slides.forEach((s, si) => {
+ if (t < s.start - 1e-6) return;
+ const nx = slides[si + 1], leave = MO.appleOut(MO.seg(t, s.next - 0.15, s.next + (nx && nx.type === 'num' ? 0.3 : 0.5))); if (leave >= 1) return;
+ if (s.type === 'num') return drawNumber(c, s, t, leave, ctx, shadowText);
+ if (s.type === 'img') return drawCard(c, s.cards[0], 0, t, leave, ctx, bd, cardGeoImg(s.cards[0], ctx), 'i' + si);
+ // 无图卡并排:n 张时的位置;新卡进来时旧卡按弹簧挪到新位置
+ const vis = s.cards.filter(cd => t >= cd.q.at - 1e-6), n = vis.length, last = vis[n - 1]; ctx._stat = s.cards.some(cd => cd.q.data && cd.q.data.value != null);
+ const rf = n > 1 ? MO.spring(t - last.q.at, { duration: 0.7, bounce: 0.12 }) : 1;
+ vis.forEach((cd, j) => { const A = rowGeo(j, n, ctx, s.cards.length), Bp = j < n - 1 ? rowGeo(j, n - 1, ctx, s.cards.length) : A;
+ const geo = { cx: lerp(Bp.cx, A.cx, rf), cy: lerp(Bp.cy, A.cy, rf), w: lerp(Bp.w, A.w, rf), h: lerp(Bp.h, A.h, rf), focus: j === n - 1 ? 1 : 1 - 0.25 * rf };
+ drawCard(c, cd, j, t, leave, ctx, bd, geo, 'c' + si + '_' + j); });
+ });
+ },
+};
+// 截图卡的屏幕几何
+function cardGeoImg(cd, ctx) { return { cx: ctx.W / 2, cy: G.cy, w: cd.box.w, h: cd.box.h, focus: 1 }; }
+// 无图卡:横屏排一行(1 张时宽一点),竖屏叠成一列;total = 这一屏最终有几张(排版按当前张数,但尺寸上限按最终张数,挪位时不忽大忽小)
+function rowGeo(j, n, ctx, total) {
+ const { W, u } = ctx, gap = 44 * u;
+ if (ctx.portrait) { const w = W * 0.86, h = Math.min(400 * u, (G.bh - (total - 1) * gap) / total), y0 = G.cy - (n * h + (n - 1) * gap) / 2; return { cx: W / 2, cy: y0 + j * (h + gap) + h / 2, w, h }; }
+ const w = total === 1 ? 760 * u : Math.min(540 * u, (W * 0.9 - (total - 1) * gap) / total), h = Math.min((ctx._stat ? 660 : 540) * u, G.bh * 0.9), x0 = W / 2 - (n * w + (n - 1) * gap) / 2;
+ return { cx: x0 + j * (w + gap) + w / 2, cy: G.cy, w, h };
+}
+// 一张卡:弹簧从下方升起+绕 Y 轴转正;内容画进离屏纹理(毛玻璃按卡片的屏幕位置取样),再伪 3D 贴回
+function drawCard(c, cd, i, t, leave, ctx, bd, geo, key) {
+ const { u, data: d } = ctx, q = cd.q, lt = ctx.lt(t, q.at); if (lt <= 0) return;
+ const sp = MO.spring(lt, { duration: 0.7, bounce: 0.15 }), acc = d.accent || '#3d6bff';
+ const Bw = geo.w, Bh = geo.h, cx = geo.cx - leave * ctx.W * 0.35, cy = geo.cy + (1 - sp) * 170 * u + MO.float(t, 5 * u, 3.6, i);
+ const sc = (0.9 + 0.1 * sp) * (1 - 0.12 * leave) * lerp(0.97, 1, geo.focus), ry = (1 - sp) * -0.45 + 0.03 * Math.sin(t * 0.9 + i) - 0.35 * leave, a = clamp(lt / 0.2) * (1 - leave) * lerp(0.6, 1, geo.focus);
+ const pad = 60, tex = scr[key] || (scr[key] = document.createElement('canvas')); tex.width = Math.ceil(Bw + 2 * pad); tex.height = Math.ceil(Bh + 2 * pad);
+ const g = tex.getContext('2d'); g.reset();
+ const sw = Bw * sc, sh = Bh * sc;
+ if (ctx.alpha) { g.fillStyle = 'rgba(12,12,22,0.62)'; g.beginPath(); g.roundRect(pad, pad, Bw, Bh, 34 * u); g.fill(); }
+ UI.glass(g, { x: pad, y: pad, w: Bw, h: Bh, r: 34 * u, bd, sample: { x: cx - sw / 2, y: cy - sh / 2, w: sw, h: sh }, tint: ctx.alpha ? 0.08 : 0.075, stroke: 0.22, light: 0.14, shadow: false });
+ g.save(); g.translate(pad, pad);
+ if (cd.im) imgContent(g, cd, Bw, Bh, t, ctx, acc); else featContent(g, cd, Bw, Bh, lt, t, ctx, acc);
+ UI.sheen(g, UI.rrPath(0, 0, Bw, Bh, 34 * u), MO.seg(lt, 0.4, 1.2), { x0: 0, x1: Bw, width: 120 * u, angle: -0.35, alpha: 0.16 }); // 光扫过整张卡(入场后 0.4s)
+ g.restore();
+ c.save(); c.globalAlpha = a;
+ UI.shadow(c, cx - sw / 2 + 10 * u, cy - sh / 2 + 20 * u, sw - 20 * u, sh - 20 * u, 34 * u, { blur: 80 * u, oy: 40 * u, alpha: 0.55 });
+ UI.persp(c, tex, { cx, cy, w: tex.width * sc, h: tex.height * sc, ry, persp: 1800 * u, strip: 3, shade: 0.35 });
+ c.restore();
+}
+// 步骤号徽章
+function badge(g, x, y, s, n, acc, u) { g.fillStyle = acc; g.beginPath(); g.roundRect(x, y, s, s, s * 0.28); g.fill();
+ g.fillStyle = '#fff'; g.font = `700 ${s * 0.5}px ${SANSB}`; g.textAlign = 'center'; g.textBaseline = 'middle'; g.fillText(String(n).padStart(2, '0'), x + s / 2, y + s / 2 + 2 * u); g.textAlign = 'left'; g.textBaseline = 'alphabetic'; }
+// 截图卡的内容:步骤号+标题+说明,截图 contain;highlight 框出一块
+function imgContent(g, cd, Bw, Bh, t, ctx, acc) {
+ const { u } = ctx, q = cd.q, B = cd.box, I = B.img, hp = 40 * u, bs = 70 * u;
+ badge(g, hp, hp, bs, cd.n, acc, u);
+ if (B.side) { // 左字右图:标题、说明在左栏往下排
+ const tw = B.side - hp, tl = fitB(g, q.text || '', tw, 58 * u, 'PuHui-Bold', { maxLines: 3, weight: '600 ' });
+ g.font = `600 ${tl.size}px ${ZHB}`; g.fillStyle = '#f5f5f7'; tl.lines.forEach((ln, k) => g.fillText(ln, hp, hp + bs + 70 * u + k * tl.size * 1.25));
+ if (q.sub) { const sl = fitB(g, q.sub, tw, 34 * u, 'PuHui-Medium', { maxLines: 5 }); g.font = `400 ${sl.size}px ${ZH}`; g.fillStyle = 'rgba(235,235,245,0.66)';
+ sl.lines.forEach((ln, k) => g.fillText(ln, hp, hp + bs + 70 * u + tl.lines.length * tl.size * 1.25 + 30 * u + k * sl.size * 1.4)); }
+ } else {
+ const tx = hp + bs + 26 * u, tw = Bw - tx - hp;
+ if (ctx.portrait) { // 竖屏:卡头高一些,标题、说明字大一号
+ const tl = fitB(g, q.text || '', tw, 56 * u, 'PuHui-Bold', { maxLines: 2, weight: '600 ', min: 0.7 }); g.font = `600 ${tl.size}px ${ZHB}`; g.fillStyle = '#f5f5f7';
+ tl.lines.forEach((ln, k) => g.fillText(ln, tx, hp + tl.size * 0.85 + k * tl.size * 1.2));
+ // 标题占两行时说明只留一行,卡头放得下
+ if (q.sub) { const sl = fitB(g, q.sub, tw, 34 * u, 'PuHui-Medium', { maxLines: tl.lines.length > 1 ? 1 : 2, min: 0.75 }); g.font = `400 ${sl.size}px ${ZH}`; g.fillStyle = 'rgba(235,235,245,0.66)';
+ sl.lines.forEach((ln, k) => g.fillText(ln, tx, hp + tl.size * 0.85 + (tl.lines.length - 1) * tl.size * 1.2 + 24 * u + sl.size + k * sl.size * 1.35)); }
+ } else {
+ const tl = TY.fit(g, q.text || '', tw, 46 * u, 'PuHui-Bold', { maxLines: 1, weight: '600 ' });
+ g.font = `600 ${tl.size}px ${ZHB}`; g.fillStyle = '#f5f5f7'; g.fillText(tl.lines[0] || '', tx, hp + (q.sub ? 32 * u : 48 * u));
+ if (q.sub) { const sl = TY.fit(g, q.sub, tw, 28 * u, 'PuHui-Medium', { maxLines: 1 }); g.font = `400 ${sl.size}px ${ZH}`; g.fillStyle = 'rgba(235,235,245,0.62)'; g.fillText(sl.lines[0] || '', tx, hp + 74 * u); }
+ }
+ }
+ const f = CLIP.fit(cd.im.width, cd.im.height, I.x, I.y, I.w, I.h);
+ g.save(); g.shadowColor = 'rgba(0,0,0,.45)'; g.shadowBlur = 30 * u; g.shadowOffsetY = 12 * u; g.fillStyle = '#000'; g.beginPath(); g.roundRect(f.x, f.y, f.w, f.h, 10 * u); g.fill(); g.restore();
+ g.save(); g.beginPath(); g.roundRect(f.x, f.y, f.w, f.h, 10 * u); g.clip(); g.drawImage(cd.im, f.x, f.y, f.w, f.h); g.restore();
+ g.strokeStyle = 'rgba(255,255,255,0.22)'; g.lineWidth = 1.5; g.beginPath(); g.roundRect(f.x + .75, f.y + .75, f.w - 1.5, f.h - 1.5, 10 * u); g.stroke();
+ // 框出重点:at 这一帧框开始弹出,之后呼吸;一道光扫过框内(只认落在这张卡在屏期间的 highlight)
+ const nxAt = (() => { const i = ctx.cues.indexOf(q); const n = ctx.cues.slice(i + 1).find(z => ['card', 'step', 'image', 'number'].includes(z.kind)); return n ? (n.kind === 'number' ? n.at - 0.9 : n.at) : 1e9; })();
+ for (const qh of ctx.of('highlight')) {
+ if (qh.at < q.at || qh.at >= nxAt || !qh.data || !qh.data.rect) continue;
+ const hl = ctx.lt(t, qh.at); if (hl <= 0) continue;
+ const R = CLIP.sub(qh.data.rect, f), s = MO.spring(hl, { duration: 0.45, bounce: 0.25 }), e = 8 * u * (1 - s);
+ g.save(); g.fillStyle = 'rgba(0,0,0,0.38)'; g.beginPath(); g.rect(f.x, f.y, f.w, f.h); g.roundRect(R.x - e, R.y - e, R.w + 2 * e, R.h + 2 * e, 10 * u); g.globalAlpha = clamp(hl / 0.3); g.fill('evenodd'); g.restore();
+ g.save(); g.strokeStyle = acc; g.lineWidth = 5 * u; g.shadowColor = acc; g.shadowBlur = 18 * u * (0.7 + 0.3 * Math.sin(hl * 5)); g.globalAlpha = clamp(hl / 0.15);
+ g.beginPath(); g.roundRect(R.x - e, R.y - e, R.w + 2 * e, R.h + 2 * e, 10 * u); g.stroke(); g.restore();
+ UI.sheen(g, UI.rrPath(R.x, R.y, R.w, R.h, 10 * u), MO.seg(hl, 0.25, 1.0), { x0: R.x, x1: R.x + R.w, width: Math.max(60 * u, R.w * 0.2), alpha: 0.35 });
+ if (qh.text) { g.font = `600 ${30 * u}px ${ZHB}`; const lw = g.measureText(qh.text).width + 36 * u, ly = R.y + R.h + 16 * u + 48 * u > f.y + f.h ? R.y - 64 * u : R.y + R.h + 16 * u;
+ g.save(); g.globalAlpha = clamp((hl - 0.15) / 0.25); g.fillStyle = acc; g.beginPath(); g.roundRect(clamp(R.x, f.x, f.x + f.w - lw), ly, lw, 48 * u, 24 * u); g.fill(); g.fillStyle = '#fff'; g.textBaseline = 'middle'; g.fillText(qh.text, clamp(R.x, f.x, f.x + f.w - lw) + 18 * u, ly + 25 * u); g.restore(); }
+ }
+}
+// 无图功能卡的内容:图标(或步骤号)→ 大标题 → 说明 →(可选)大数字计数。横屏竖卡上下排,竖屏横卡左右排
+function featContent(g, cd, Bw, Bh, lt, t, ctx, acc) {
+ const { u } = ctx, q = cd.q, dd = q.data || {}, hasNum = dd.value != null, pad = 48 * u, tile = (ctx.portrait ? 110 : 120) * u;
+ const drawTile = (x, y) => { g.fillStyle = 'rgba(255,255,255,0.10)'; g.beginPath(); g.roundRect(x, y, tile, tile, 26 * u); g.fill();
+ if (!dd.icon || icon(g, dd.icon, x + tile / 2, y + tile / 2, tile * 0.6, '#f2f2f7', t) === false) {
+ g.fillStyle = acc; g.beginPath(); g.roundRect(x, y, tile, tile, 26 * u); g.fill(); g.fillStyle = '#fff'; g.font = `700 ${tile * 0.46}px ${SANSB}`; g.textAlign = 'center'; g.textBaseline = 'middle';
+ g.fillText(String(cd.n).padStart(2, '0'), x + tile / 2, y + tile / 2 + 3 * u); g.textAlign = 'left'; g.textBaseline = 'alphabetic'; } };
+ const num = (x, y, size, align) => { const v = MO.expoOut(clamp((lt - 0.35) / 0.9)); g.save(); g.font = `600 ${size}px ${SANSB}`; track(g, size, -0.03); g.fillStyle = '#fff';
+ TY.tabular(g, fmtNum(dd, v), x, y, { align }); g.restore(); if (dd.label) { g.font = `400 ${28 * u}px ${ZH}`; g.fillStyle = 'rgba(235,235,245,0.6)'; g.textAlign = align; g.fillText(dd.label, x, y + 46 * u); g.textAlign = 'left'; } };
+ g.textAlign = 'left'; g.textBaseline = 'alphabetic';
+ if (!ctx.portrait) {
+ drawTile(pad, pad);
+ const tl = fitB(g, q.text || '', Bw - 2 * pad, 64 * u, 'PuHui-Bold', { maxLines: 2, weight: '600 ', min: 0.6 });
+ let y = pad + tile + 40 * u + tl.size; g.font = `600 ${tl.size}px ${ZHB}`; g.fillStyle = '#f5f5f7'; tl.lines.forEach((ln, k) => g.fillText(ln, pad, y + k * tl.size * 1.2)); y += (tl.lines.length - 1) * tl.size * 1.2;
+ if (q.sub) { const sl = fitB(g, q.sub, Bw - 2 * pad, (hasNum ? 32 : 38) * u, 'PuHui-Medium', { maxLines: hasNum ? 2 : 4, min: 0.75 }); g.font = `400 ${sl.size}px ${ZH}`; g.fillStyle = 'rgba(235,235,245,0.66)';
+ sl.lines.forEach((ln, k) => g.fillText(ln, pad, y + 26 * u + sl.size + k * sl.size * 1.45)); }
+ if (hasNum) { g.fillStyle = 'rgba(255,255,255,0.12)'; g.fillRect(pad, Bh - pad - 200 * u, Bw - 2 * pad, 1.5); num(pad, Bh - pad - 66 * u, Math.min(128 * u, (Bw - 2 * pad) / Math.max(3, fmtNum(dd, 1).length) * 1.6), 'left'); }
+ } else {
+ drawTile(pad, (Bh - tile) / 2);
+ const tx = pad + tile + 34 * u, nw = hasNum ? Math.min(340 * u, Bw * 0.36) : 0, tw = Bw - tx - pad - nw;
+ const tl = fitB(g, q.text || '', tw, 62 * u, 'PuHui-Bold', { maxLines: 2, weight: '600 ', min: 0.6 }); // 标题放不下就折两行,不再截掉后半句
+ const sl = q.sub ? fitB(g, q.sub, tw, 38 * u, 'PuHui-Medium', { maxLines: tl.lines.length > 1 ? 1 : 2, min: 0.75 }) : { lines: [], size: 0 };
+ const tH = tl.size + (tl.lines.length - 1) * tl.size * 1.15, blk = tH + (sl.lines.length ? 22 * u + sl.lines.length * sl.size * 1.4 : 0), y0 = (Bh - blk) / 2 + tl.size * 0.85;
+ g.font = `600 ${tl.size}px ${ZHB}`; g.fillStyle = '#f5f5f7'; tl.lines.forEach((ln, k) => g.fillText(ln, tx, y0 + k * tl.size * 1.15));
+ const ys = y0 + (tl.lines.length - 1) * tl.size * 1.15;
+ g.font = `400 ${sl.size}px ${ZH}`; g.fillStyle = 'rgba(235,235,245,0.66)'; sl.lines.forEach((ln, k) => g.fillText(ln, tx, ys + 22 * u + sl.size + k * sl.size * 1.4));
+ if (hasNum) num(Bw - pad, Bh / 2 + 20 * u, Math.min(96 * u, nw / Math.max(3, fmtNum(dd, 1).length) * 1.7), 'right');
+ }
+}
+// 大数字一屏:at 落定(提前 0.9s 开始滚);数字上方可有小字 label,下方说明(text 或 sub)
+function drawNumber(c, s, t, leave, ctx, shadowText) {
+ const { W, u } = ctx, q = s.q, nd = q.data || {}, k = MO.expoOut(clamp((t - s.start) / 0.9)), a = MO.appleOut(clamp((t - s.start - 0.12) / 0.3)) * (1 - leave);
+ const cap = q.text ?? q.sub;
+ c.save(); c.globalAlpha = a; shadowText(c); c.textAlign = 'center'; c.textBaseline = 'alphabetic';
+ if (leave > 0) { c.filter = `blur(${(16 * leave * u).toFixed(1)}px)`; }
+ const str = fmtNum(nd, k), full = fmtNum(nd, 1);
+ c.font = `600 ${220 * u}px ${SANSB}`; track(c, 220 * u, -0.03); let size = 220 * u; const fw = c.measureText(full).width; if (fw > W * 0.88) size *= W * 0.88 / fw;
+ c.font = `600 ${size}px ${SANSB}`; track(c, size, -0.03); c.fillStyle = '#fff';
+ const y = G.cy + size * 0.32 - (cap ? 30 * u : 0);
+ TY.tabular(c, str, W / 2, y, { align: 'center' });
+ c.letterSpacing = '0px';
+ if (nd.label) { c.font = `500 ${34 * u}px ${ZH}`; c.fillStyle = '#a7a7b4'; c.fillText(nd.label, W / 2, y - size * 0.85); }
+ if (cap) { c.font = `400 ${(ctx.portrait ? 46 : 44) * u}px ${ZH}`; c.fillStyle = 'rgba(235,235,245,0.78)'; TY.wrap(c, cap, W * 0.84).forEach((ln, i) => c.fillText(ln, W / 2, y + 100 * u + i * 60 * u)); }
+ c.restore();
+}
+})();
diff --git a/scripts/engine/clips/t3_finance_chart.js b/scripts/engine/clips/t3_finance_chart.js
new file mode 100644
index 0000000..53f98a7
--- /dev/null
+++ b/scripts/engine/clips/t3_finance_chart.js
@@ -0,0 +1,174 @@
+// 片段 · 财经图表(t3):版式先出 → 坐标系 → 数据长出 → 只标一件事。真实数据驱动,单位/来源/角标全从 data 读。
+// data: { title, unit(副标题:指标与单位), source(来源,左下), badge?(只有写了才画右下角标,如 "示意数据"),
+// chart: 'bar'|'line'|'candle', series: [{label, value}] 或 K 线 [{label, o, h, l, c}], decimals=1, prefix='', suffix='',
+// highlight?: {index, text, sub}, colors?: {main, accent, dim}, upDown?: 'cn'(红涨绿跌,默认)|'us' }
+// cues(at 秒):title(版式)· bar|line|candle(数据从 at 开始长出,dur 默认按根数;柱状图可写多个 bar cue,各带 data.index(数或数组)=这几根在这一刻才长,让每根柱子踩自己的那个词)
+// series 每项可写 color(柱子自己的颜色,和片里别处同一个量的配色对上)· highlight(at 这一帧标注圆点弹出;text/sub 覆盖 data.highlight,data.index 指定第几根)
+// number(大数字:data {value, prefix, suffix, decimals},at = 数字落定的时刻,提前 0.9s 开始滚)
+// 规矩:柱一律从 0 起;折线/K 线纵轴不从 0 起时自动在副标题后加「纵轴未从 0 开始」。
+CLIPS.t3_finance_chart = (() => {
+const { clamp, lerp } = U;
+const RED = '#E3120B', INK = '#0C0C0C', SUB = '#4F5B61', GRID = 'rgba(12,12,12,0.13)';
+const CN = '"PuHui-Medium"', CNB = '"PuHui-Bold"', NUM = '"RobotoCondensed", "PuHui-Medium"';
+let L, BUF;
+const fmtv = (d, v) => (d.prefix || '') + TY.fmt(v, d.decimals ?? 1) + (d.suffix || '');
+return {
+ fonts: ['PuHui-Medium', 'PuHui-Bold'],
+ safe: true,
+ init(ctx) {
+ const { W, H, u, data: d } = ctx, m = (ctx.portrait ? 70 : 90) * u, c = document.createElement('canvas').getContext('2d');
+ const kind = (ctx.of('bar', 'line', 'candle')[0] || {}).kind || d.chart || 'bar';
+ const S = d.series || [];
+ const vals = kind === 'candle' ? S.flatMap(r => [r.h, r.l]) : S.map(r => r.value);
+ let lo = Math.min(...vals), hi = Math.max(...vals);
+ let zeroBased = kind === 'bar' || lo <= 0 || (hi - lo) / hi > 0.6;
+ if (zeroBased) lo = Math.min(0, lo);
+ const pad = (hi - lo) * 0.08, ticks = CH.ticks(zeroBased ? lo : lo - pad, hi + pad, ctx.portrait ? 5 : 4);
+ const step = ticks[1] - ticks[0]; // 刻度要把数据整个包住(CH.ticks 只给区间内的整刻度)
+ while (ticks[ticks.length - 1] < hi + pad * 0.5) ticks.push(+(ticks[ticks.length - 1] + step).toFixed(10));
+ while (ticks[0] > (zeroBased ? lo : lo - pad * 0.5)) ticks.unshift(+(ticks[0] - step).toFixed(10));
+ const titleSz = (ctx.portrait ? 64 : 58) * u, t = TY.fit(c, d.title || '', W - 2 * m, titleSz, 'PuHui-Bold', { maxLines: ctx.portrait ? 3 : 2, weight: '700 ' });
+ const sub = (d.unit || '') + (!zeroBased ? (d.unit ? ' ' : '') + '纵轴未从 0 开始' : '');
+ // 副标题、来源行:放不下先缩一点,再折两行(竖屏长口径会出画);来源行要让开右下角标
+ const fsz = ctx.portrait ? 1.2 : 1, subF = TY.fit(c, sub, W - 2 * m, 32 * u * fsz, 'PuHui-Medium', { maxLines: 2, min: 0.8 });
+ c.font = `700 ${28 * u}px "PuHui-Medium"`; const badgeW = d.badge ? c.measureText(d.badge).width + 28 + 30 * u : 0;
+ const srcF = TY.fit(c, d.source || '', W - 2 * m - badgeW, 26 * u * fsz, 'PuHui-Medium', { maxLines: 2, min: 0.8 });
+ const top = ctx.safe.top + 80 * u + t.lines.length * t.size * 1.25 + 60 * u + (subF.lines.length - 1) * subF.size * 1.3;
+ const band = ctx.of('number').length ? 150 * u : 0; // 有 number:给大数字单独留一条,不压在图区里(折线一上涨,右上角正好是线头)
+ const F = { x: m + 20 * u, y: top + 40 * u + band, w: W - 2 * m - 40 * u, h: H - top - 40 * u - band - (ctx.portrait ? 260 : 190) * u - ctx.safe.bottom - (srcF.lines.length - 1) * srcF.size * 1.3 }; // safe.bottom:字幕带整条让出来,来源行落在它上面
+ const n = S.length, slot = (F.w - 80 * u) / n, xs = S.map((_, i) => F.x + slot * (i + 0.5)); // 右边留 80px 给刻度值,别压在最后一根柱上
+ // x 轴:时间序列(折线/K 线,或 data.xAxis:'time')按间隔抽稀;类目(柱状图默认)每根都要有名字,放不下就缩字、再放不下错成两行
+ const category = (d.xAxis || (kind === 'bar' ? 'category' : 'time')) === 'category';
+ const fs0 = ctx.portrait ? 1.2 : 1, xf = 30 * u * fs0;
+ c.font = `400 ${xf}px "RobotoCondensed", "PuHui-Medium"`;
+ const maxW = Math.max(1, ...S.map(r => c.measureText(String(r.label ?? '')).width));
+ const xScale = category ? clamp(slot * 0.94 / maxW, 0.7, 1) : 1, stagger = category && slot * 0.94 < maxW * 0.7;
+ // 刻度标签按步长定小数位:步长 2.5 就要 1 位,不然 −2.5/2.5/7.5 会被四舍五入印成 −3/3/8(刻度撒谎)
+ let tdec = 0; while (tdec < 4 && Math.abs(step * 10 ** tdec - Math.round(step * 10 ** tdec)) > 1e-6) tdec++;
+ if (kind === 'bar' && Math.min(...vals) < 0) { // 负数柱的数值写在柱底下方:最低那根下面留出一行,不然压到类目名
+ const vmin = Math.min(...vals), need = 56 * u * fs0;
+ while ((vmin - ticks[0]) / (ticks[ticks.length - 1] - ticks[0]) * F.h < need) ticks.unshift(+(ticks[0] - step).toFixed(10));
+ }
+ const qh1 = ctx.of('highlight')[0], H1 = d.highlight || {}, hiI = qh1 ? (qh1.data && qh1.data.index != null ? qh1.data.index : (H1.index != null ? H1.index : S.length - 1)) : -1;
+ if (kind === 'bar' && hiI >= 0 && S[hiI] && S[hiI].value >= 0 && S.some((r, j) => j !== hiI && r.value >= S[hiI].value)) { // 标注的不是最高那根:文字块要抬到邻柱之上,顶上留够一块(不够就加一档刻度)
+ const nL = [C(qh1.text, H1.text), C(qh1.sub, H1.sub)].filter(Boolean).length, need = (52 * nL + 44 + 30) * u * fs0, vmax = Math.max(...vals);
+ while ((ticks[ticks.length - 1] - vmax) / (ticks[ticks.length - 1] - ticks[0]) * F.h < need) ticks.push(+(ticks[ticks.length - 1] + step).toFixed(10));
+ }
+ L = { subF, srcF, m, kind, S, zeroBased, ticks, tdec, yS: CH.lin(ticks[0], ticks[ticks.length - 1], F.y + F.h, F.y), F, xs, slot, t, sub, band, category, xFont: xf * xScale, stagger,
+ every: category ? 1 : Math.max(1, Math.ceil(n / (ctx.portrait ? 6 : 10))) };
+ const main = (d.colors && d.colors.main) || (kind === 'bar' ? '#006BA2' : RED);
+ L.col = { main, accent: (d.colors && d.colors.accent) || main, dim: (d.colors && d.colors.dim) || '#C6D2D8' };
+ L.updown = d.upDown === 'us' ? ['#1B9E5A', RED] : [RED, '#1B9E5A'];
+ },
+ draw(c0, t, ctx) {
+ // alpha:图是白纸黑字,叠在深色画面上墨色看不见。先画进缓冲,再带一圈白色光晕合成(和 t1 同一招)
+ const c = ctx.alpha ? (BUF = BUF || document.createElement('canvas'), BUF.width = ctx.W, BUF.height = ctx.H, BUF.getContext('2d')) : c0;
+ const { W, H, u, data: d } = ctx, { m, F, yS, xs, S, kind } = L, fs = ctx.portrait ? 1.2 : 1; // 竖屏在手机上看:小字放大两成
+ const qt = ctx.of('title')[0] || { at: 0 }, lt = ctx.lt(t, qt.at);
+ if (!ctx.alpha) { c.fillStyle = '#FFFFFF'; c.fillRect(0, 0, W, H); }
+ // ---- 版式:顶红线 → 小旗 → 标题 → 副标题(单位/口径)→ 来源 → 角标 ----
+ if (lt > 0) {
+ const p = MO.quintOut(MO.seg(lt, 0, 0.45));
+ c.fillStyle = RED; c.fillRect(0, 0, W * p, 8 * u); CH.tag(c, m, ctx.safe.top + 52 * u, 96 * p * u, 22 * u, RED);
+ c.save(); c.textBaseline = 'alphabetic'; c.textAlign = 'left';
+ const tp = MO.quintOut(MO.seg(lt, 0.05, 0.5)); c.globalAlpha = tp; c.fillStyle = INK; c.font = `700 ${L.t.size}px ${CNB}`;
+ L.t.lines.forEach((ln, i) => c.fillText(ln, m, ctx.safe.top + 80 * u + (i + 1) * L.t.size * 1.2 + (1 - tp) * 18 * u));
+ const sp = MO.quintOut(MO.seg(lt, 0.15, 0.6)), sy = ctx.safe.top + 80 * u + L.t.lines.length * L.t.size * 1.2 + 54 * u;
+ c.globalAlpha = sp; c.font = `400 ${L.subF.size}px ${CN}`; c.fillStyle = SUB; L.subF.lines.forEach((ln, k) => c.fillText(ln, m, sy + k * L.subF.size * 1.3 + (1 - sp) * 14 * u));
+ c.globalAlpha = MO.seg(lt, 0.2, 0.6); c.font = `400 ${L.srcF.size}px ${CN}`; c.fillStyle = '#7c868b';
+ L.srcF.lines.forEach((ln, k, a) => c.fillText(ln, m, H - 40 * u - ctx.safe.bottom - (a.length - 1 - k) * L.srcF.size * 1.3));
+ c.restore();
+ if (d.badge) { c.save(); c.globalAlpha = MO.seg(lt, 0.2, 0.6); CH.demoBadge(c, d.badge, { x: W - m, y: H - 50 * u - ctx.safe.bottom, font: `700 ${28 * u}px ${CN}`, col: RED, box: 'rgba(227,18,11,0.06)' }); c.restore(); }
+ }
+ // ---- 坐标系(版式之后 0.25s) ----
+ const qd = ctx.of('bar', 'line', 'candle')[0] || { at: qt.at + 0.75 }, gStart = Math.min(qt.at + 0.25, qd.at - 0.4);
+ const gp = MO.seg(ctx.lt(t, gStart), 0, 0.6);
+ const fmtTick = v => TY.fmt(v, L.tdec);
+ CH.grid(c, F, L.ticks, yS, gp, { col: GRID, zeroCol: L.zeroBased ? INK : GRID, font: `400 ${28 * u * fs}px ${NUM}`, labelCol: '#5b666b', side: 'right', lw: 1.5 * u, zeroLw: 3 * u, fmt: fmtTick, labelDy: -10 * u });
+ const qh0 = ctx.of('highlight')[0], hi0 = qh0 ? (qh0.data && qh0.data.index != null ? qh0.data.index : (d.highlight && d.highlight.index != null ? d.highlight.index : S.length - 1)) : -1;
+ const keep = i => i % L.every === 0 || i === hi0 || (i === S.length - 1 && (S.length - 1) % L.every >= L.every / 2); // 被标注的那根永远有名字;末尾标签离上一个太近就不硬塞
+ const xp = MO.seg(ctx.lt(t, gStart + 0.15), 0, 0.5), xy = F.y + F.h + 46 * u, xo = { font: `400 ${L.xFont}px ${NUM}`, col: '#3a4246' };
+ if (!L.stagger) CH.xLabels(c, S.map((r, i) => ({ x: xs[i], label: keep(i) ? String(r.label ?? '') : '' })), xy, xp, xo);
+ else { CH.xLabels(c, S.map((r, i) => ({ x: xs[i], label: i % 2 ? '' : String(r.label ?? '') })), xy, xp, xo); CH.xLabels(c, S.map((r, i) => ({ x: xs[i], label: i % 2 ? String(r.label ?? '') : '' })), xy + L.xFont * 1.15, xp, xo); }
+ // ---- 数据 ----
+ const n = S.length, ddur = qd.dur || Math.min(2.2, Math.max(0.9, n * (kind === 'bar' ? 0.22 : 0.06)));
+ const dp = ctx.p(t, qd.at, ddur);
+ const qh = ctx.of('highlight')[0], hi = qh ? (qh.data && qh.data.index != null ? qh.data.index : (d.highlight && d.highlight.index != null ? d.highlight.index : n - 1)) : -1;
+ const hiP = qh ? MO.smooth(ctx.p(t, qh.at, 0.4)) : 0;
+ let anchor = null;
+ if (kind === 'bar') {
+ const bw = Math.min(150 * u, L.slot * 0.62);
+ const on = qh && ctx.lt(t, qh.at) > 0, opt = { col: L.col.main, hiP, hiCol: L.col.accent, dimCol: L.col.dim,
+ fmt: v => fmtv(d, v), font: `600 ${Math.max(24 * u * fs, Math.min(34 * u * fs, L.slot * 0.3))}px ${NUM}`, labelCol: INK, label: n <= 14 };
+ const own = {}; // 带 data.index 的 bar cue:这几根柱子从它的 at 起单独长
+ for (const q of ctx.of('bar')) if (q.data && q.data.index != null) [].concat(q.data.index).forEach(i => { own[i] = q; });
+ let tops;
+ if (!Object.keys(own).length && !S.some(r => r.color)) tops = CH.bars(c, S.map((r, i) => ({ x: xs[i], v: r.value })), yS, bw, dp, { ...opt, lag: Math.min(0.22, 2 / n), hi: on ? hi : -1 });
+ else tops = S.map((r, i) => {
+ const q = own[i], p = q ? ctx.p(t, q.at, q.dur || 0.7) : MO.lagged(i, n, dp, Math.min(0.22, 2 / n));
+ const col = r.color || L.col.main;
+ return CH.bars(c, [{ x: xs[i], v: r.value }], yS, bw, p, { ...opt, lag: 0, col, hiCol: col, hi: on ? (i === hi ? 0 : 1) : -1 })[0];
+ });
+ if (hi >= 0) anchor = [xs[hi], tops[hi][1]];
+ L.neg = hi >= 0 && S[hi].value < 0; L.tops = tops;
+ L.barAbove = hi >= 0 && S[hi].value >= 0 && S.some((r, j) => j !== hi && r.value > S[hi].value * 1.5); // 有更高的柱子挡在旁边:标注放在这根柱子正上方,别压进别的柱子
+ } else if (kind === 'line') {
+ const pts = S.map((r, i) => [xs[i], yS(r.value)]);
+ const lp = MO.smooth(dp);
+ const hp = CH.line(c, pts, lp, { col: L.col.main, lw: 5 * u, headR: 9 * u, area: { top: F.y, base: F.y + F.h, c0: 'rgba(227,18,11,0.12)', c1: 'rgba(227,18,11,0)' } });
+ if (hp && lp < 1) { const v = yS.inv(hp[1]); c.save(); c.font = `700 ${36 * u}px ${NUM}`; c.fillStyle = L.col.main; c.textAlign = 'left'; c.textBaseline = 'middle'; TY.tabular(c, fmtv(d, v), hp[0] + 20 * u, hp[1] - 4 * u); c.restore(); }
+ else if (lp >= 1) { const v = S[n - 1].value; c.save(); c.font = `700 ${36 * u}px ${NUM}`; c.fillStyle = L.col.main; c.textAlign = 'right'; c.textBaseline = 'alphabetic'; TY.tabular(c, fmtv(d, v), pts[n - 1][0], pts[n - 1][1] - 24 * u, { align: 'right' }); c.restore(); }
+ if (hi >= 0) anchor = pts[hi];
+ } else {
+ const cw = Math.min(30 * u, L.slot * 0.6);
+ CH.candles(c, S, xs, yS, cw, dp, { up: L.updown[0], down: L.updown[1], lag: Math.min(0.06, 1.5 / n) });
+ if (hi >= 0) anchor = [xs[hi], yS(S[hi].c)];
+ }
+ // ---- 标注:一镜只标一件事 ----
+ let above = L.barAbove;
+ if (qh && anchor && kind === 'bar' && !above && !L.neg) { // 预演斜向标注的文字框:压到别的柱子或它的数值,就改放这根柱子正上方
+ const H0 = d.highlight || {}, ls = [C(qh.text, H0.text), C(qh.sub, H0.sub)].filter(Boolean);
+ const ax = anchor[0] - Math.min(150 * u, L.slot * 0.62) / 2, right = ax > F.x + F.w * 0.55, tx = right ? ax - 60 * u : ax + 60 * u, ty = Math.max(F.y + 60 * u, anchor[1] - 140 * u);
+ c.save(); c.font = `700 ${50 * u}px ${NUM}`; let tw = c.measureText(ls[0] || '').width; c.font = `400 ${28 * u * fs}px ${CN}`; if (ls[1]) tw = Math.max(tw, c.measureText(ls[1]).width); c.restore();
+ const bx0 = right ? tx - 12 - tw : tx + 12, bx1 = bx0 + tw, by1 = ty + (ls.length > 1 ? 56 : 16) * u;
+ above = L.tops.some(([bx, by], j) => j !== hi && bx + L.slot * 0.45 > bx0 && bx - L.slot * 0.45 < bx1 && by - 44 * u * fs < by1);
+ }
+ if (qh && anchor && kind === 'bar' && above) {
+ const H0 = d.highlight || {}, lines = [C(qh.text, H0.text), C(qh.sub, H0.sub)].filter(Boolean), k = ctx.lt(t, qh.at);
+ if (k > 0) {
+ const s = MO.spring(k, { duration: 0.45, bounce: 0.25 }), lp = MO.quintOut(MO.seg(k, 0.12, 0.45)), fp = MO.quintOut(MO.seg(k, 0.3, 0.7));
+ // 文字块放在这根柱子正上方:先量宽,横向夹在图区里;再抬到它横跨的所有柱子(含数值标签)之上,引线从本柱数值标签上沿连上去
+ const [x, y] = anchor, lh = 52 * u * fs, vlab = 44 * u * fs;
+ c.save(); c.font = `700 ${50 * u * fs}px ${NUM}`; let tw = c.measureText(lines[0]).width; c.font = `400 ${28 * u * fs}px ${CN}`; if (lines[1]) tw = Math.max(tw, c.measureText(lines[1]).width);
+ const cx = clamp(x, F.x + tw / 2, F.x + F.w - 80 * u - tw / 2);
+ const cover = L.tops.filter(([bx]) => bx > cx - tw / 2 - L.slot / 2 && bx < cx + tw / 2 + L.slot / 2).map(([, by]) => by);
+ const bottom = Math.max(F.y + lh * lines.length, Math.min(y, ...cover) - vlab - 18 * u); // 文字块底边
+ c.fillStyle = RED; c.beginPath(); c.arc(x, y - 4 * u, 9 * u * Math.max(0, s), 0, 7); c.fill();
+ const y0 = y - vlab, y1 = bottom + 8 * u;
+ if (y0 - y1 > 6 * u) { c.strokeStyle = INK; c.lineWidth = 2 * u; c.beginPath(); c.moveTo(x, y0); c.lineTo(lerp(x, cx, lp), lerp(y0, y1, lp)); c.stroke(); }
+ c.globalAlpha = fp; c.fillStyle = INK; c.textAlign = 'center'; c.textBaseline = 'alphabetic';
+ lines.forEach((ln, i) => { c.font = i === 0 ? `700 ${50 * u * fs}px ${NUM}` : `400 ${28 * u * fs}px ${CN}`; c.fillText(ln, cx, bottom - (lines.length - 1 - i) * lh * (i === 0 ? 1 : 0.62) + (1 - fp) * 12 * u); });
+ c.restore();
+ }
+ } else if (qh && anchor) {
+ if (kind === 'bar') anchor = [anchor[0] - Math.min(150 * u, L.slot * 0.62) / 2, anchor[1]];
+ const H0 = d.highlight || {}, lines = [C(qh.text, H0.text), C(qh.sub, H0.sub)].filter(Boolean);
+ const right = anchor[0] > F.x + F.w * 0.55, tx = right ? anchor[0] - 60 * u : anchor[0] + 60 * u;
+ const ty = L.neg ? Math.min(F.y + F.h - 90 * u, anchor[1] + 70 * u) : Math.max(F.y + 60 * u, anchor[1] - 140 * u); // 负数柱:标注往下走,别压回零线上方的柱子
+ CH.callout(c, ctx.lt(t, qh.at), 0, { x: anchor[0], y: anchor[1], tx, ty, lines, col: INK, dotCol: RED, font: `700 ${50 * u}px ${NUM}`, font2: `400 ${28 * u * fs}px ${CN}`, align: right ? 'right' : 'left', r: 9 * u });
+ }
+ // ---- 大数字(number cue:at = 落定时刻) ----
+ for (const q of ctx.of('number')) {
+ const nd = q.data || {}, k = MO.expoOut(clamp((t - (q.at - 0.9)) / 0.9)); if (t < q.at - 0.9) continue;
+ c.save(); c.globalAlpha = clamp((t - (q.at - 0.9)) / 0.2); c.font = `700 ${120 * u}px ${NUM}`; c.fillStyle = RED; c.textAlign = 'right'; c.textBaseline = 'alphabetic';
+ const numStr = (nd.prefix || '') + TY.fmt((nd.value || 0) * k, nd.decimals ?? 0) + (nd.suffix || ''), by = F.y - 62 * u; // 落在图区上方专留的那一条(让开顶格刻度值)
+ const nw = c.measureText((nd.prefix || '') + TY.fmt(nd.value || 0, nd.decimals ?? 0) + (nd.suffix || '')).width;
+ TY.tabular(c, numStr, W - m, by, { align: 'right' });
+ const cap = q.text ?? q.sub; if (cap) { c.font = `400 ${30 * u * fs}px ${CN}`; c.fillStyle = SUB; c.textAlign = 'right'; c.fillText(cap, W - m - nw - 24 * u, by - 10 * u); }
+ c.restore();
+ }
+ if (ctx.alpha) { c0.save(); c0.shadowColor = '#FFFFFF'; for (const b of [8, 3, 1.5]) { c0.shadowBlur = b * ctx.u; c0.drawImage(BUF, 0, 0); } c0.restore(); } // 三遍由宽到窄:外圈柔光+贴字的实边
+ },
+};
+function C(...a) { return a.find(v => v != null && v !== ''); }
+})();
diff --git a/scripts/engine/clips/y1_kurzgesagt.js b/scripts/engine/clips/y1_kurzgesagt.js
new file mode 100644
index 0000000..9fab4ad
--- /dev/null
+++ b/scripts/engine/clips/y1_kurzgesagt.js
@@ -0,0 +1,143 @@
+// 片段 · Kurzgesagt 式扁平科普(y1):深靛紫夜空、发光的扁平星球=要讲的那个概念;每个要点是一颗卫星节点,
+// 带标签胶囊弹出(过冲 108%)、信号沿连线流动;画面永远有东西在轻轻动(星闪、浮动、光晕呼吸、相机慢推)。
+// 招牌是尺度穿行:enter 让相机对数推进一颗卫星,推到它的颜色填满整屏,再从同色的新星球里拉出来——「里面是什么」。
+// cues:title(顶部标题逐字上浮;text)· point(当前这一层的一个卫星节点+标签:text;data.color 换强调色)
+// highlight(相机推近第 data.index 个节点(只数当前这一层的 point,从 0 起;默认最新),其余节点和标签变暗;1.2s 推完)
+// enter(钻进第 data.index 个节点(默认最新):推进→满屏同色→从新的中心星球拉出;text = 新中心的名字(默认用那个节点的名字);
+// 之后的 point 都是新这一层的卫星;dur 默认 1.6s,at 这一帧开始推)
+// data.center:第一层中心星球的名字。data.flow:true:节点按顺序串成一条链(中心→1→2→3),信号依次流过,节点带序号——讲「先后」时用。
+// 节点排法横竖屏一致:≤3 个排在上半圈(从左到右),≥4 个绕一整圈(从左边起顺时针)。safe:版面只排在 top..H−bottom 之间。
+CLIPS.y1_kurzgesagt = (() => {
+const { clamp, lerp, rng } = U;
+const P = { sky: ['#05020F', '#0E0631', '#2a1a6e'], star: '#F9FCFB', planet: '#F48301', line: 'rgba(125,211,220,.35)', pulse: '#32BAEE' };
+const ACC = ['#32BAEE', '#FACC12', '#BE3A95', '#5CD0B3', '#FC6255', '#8A6CF0'];
+const dark = (col, k = 0.72) => PAINT.rgb(PAINT.hex(col).map(v => v * k)), light = col => PAINT.rgb(PAINT.hex(col).map(v => v + (255 - v) * 0.4));
+let S, levels, flow;
+return {
+ fonts: ['PuHui-Heavy', 'PuHui-Medium'],
+ safe: true,
+ init(ctx) {
+ const { W, H, u, safe } = ctx, r = rng(11);
+ flow = !!ctx.data.flow;
+ const y0 = safe.top + (ctx.of('title').length ? (ctx.portrait ? 300 : 210) * u : 60 * u), y1 = H - safe.bottom - 40 * u;
+ const R = (ctx.portrait ? 160 : 140) * u, cx = W / 2, cy = (y0 + y1) / 2 + (ctx.portrait ? 0 : 30 * u);
+ S = { cx, cy, R, stars: Array.from({ length: 160 }, () => ({ x: r() * W * 1.4 - W * 0.2, y: r() * H * 1.4 - H * 0.2, r: (0.8 + r() * r() * 3) * u, ph: r() * 6.28, sp: 1 + r() * 2.5 })),
+ motes: Array.from({ length: 24 }, () => ({ x: r() * W, y: r() * H, ph: r() * 6.28, d: 0.8 + r() * 0.5, s: (2 + r() * 3) * u })) };
+ // 分层:enter 把后面的 point 放进新的一层
+ levels = [{ start: 0, center: ctx.data.center || '', col: P.planet, pts: [], hls: [] }];
+ for (const q of ctx.cues) {
+ const L = levels[levels.length - 1];
+ if (q.kind === 'point') L.pts.push(q);
+ else if (q.kind === 'highlight') L.hls.push(q);
+ else if (q.kind === 'enter') { const D = q.dur || 1.6; L.exit = { q, at: q.at, D, sw: q.at + D * 0.55, idx: q.data && q.data.index };
+ levels.push({ start: q.at + D * 0.55, end0: q.at + D, center: '', col: null, pts: [], hls: [], from: L }); }
+ }
+ // 每层的节点位置(横竖屏同一套角度:≤3 上半圈左→右,≥4 从左边起顺时针一整圈)
+ const lab = 46 * u + 70 * u + 45 * u; // 节点半径+标签偏移+半个标签高:最下面的标签也要在 y1 之内
+ const rx = ctx.portrait ? W * 0.34 : Math.min(W * 0.32, 640 * u), ryHalf = Math.min(y1 - y0, H) * (ctx.portrait ? 0.3 : 0.42), ryRing = Math.min((y1 - y0) * (ctx.portrait ? 0.34 : 0.36), y1 - cy - lab, cy - y0 - 60 * u);
+ levels.forEach((L, li) => {
+ const n = L.pts.length, ring = n >= 4;
+ L.nodes = L.pts.map((q, i) => { const ang = ring ? Math.PI + i / n * Math.PI * 2 : Math.PI + (i + 0.5) / n * Math.PI;
+ const ry = ring ? ryRing : ryHalf; return { q, i, x: cx + Math.cos(ang) * rx, y: cy + Math.sin(ang) * ry, col: (q.data && q.data.color) || ACC[(i + li * 2) % ACC.length] }; });
+ if (L.exit) { const nd = L.exit.idx != null ? L.nodes[L.exit.idx] : L.nodes.filter(z => z.q.at <= L.exit.at).pop() || L.nodes[L.nodes.length - 1];
+ L.exit.node = nd; const N = levels[li + 1]; N.col = nd ? nd.col : ACC[0]; N.center = L.exit.q.text || (nd && nd.q.text) || ''; }
+ // 本层的相机关键帧:慢推 ≈2%/s;highlight 推近节点(对数缩放、1.2s、目标点往中心星球偏一点,中心不被裁掉太多)
+ const t0 = L.start, keys = [{ t: t0, x: W / 2, y: H / 2, z: 1 }];
+ for (const h of L.hls) {
+ const nd = h.data && h.data.index != null ? L.nodes[h.data.index] : L.nodes.filter(z => z.q.at <= h.at).pop(); if (!nd) continue;
+ const last = keys[keys.length - 1], z0 = last.z * (1 + 0.02 * Math.max(0, h.at - last.t)), Z = (1 + 0.02 * (h.at - t0)) * (ctx.portrait ? 1.35 : 1.45); // 推近倍数按本层起点算,连续两次 highlight 不叠乘
+ const tx = lerp(nd.x, cx, 0.35), ty = lerp(nd.y, cy, 0.35);
+ keys.push({ t: h.at, x: last.x, y: last.y, z: last.z > 1.2 ? last.z : z0, ease: MO.linear }); keys.push({ t: h.at + 1.2, x: tx, y: ty, z: Z, ease: MO.sineInOut }); h.node = nd;
+ }
+ const last = keys[keys.length - 1], tEnd = L.exit ? L.exit.at : ctx.dur; keys.push({ t: Math.max(last.t + 0.01, tEnd), x: last.x, y: last.y, z: last.z * (1 + 0.02 * Math.max(0, tEnd - last.t)), ease: MO.linear });
+ L.keys = keys;
+ });
+ },
+ draw(c, t, ctx) {
+ const { W, H, u } = ctx;
+ // 当前层:过了切换点就是新的一层;切换点 ±0.05s 两层交叉溶解(两边都是满屏同一种颜色,剪点看不见)
+ let k = 0; levels.forEach((L, i) => { if (i > 0 && t >= L.start) k = i; });
+ drawLevel(c, k, t, ctx);
+ const L = levels[k], ex = L.exit;
+ if (ex && t > ex.sw - 0.05 && t < ex.sw) { const buf = UI.scratch('clip_y1x', W, H), g = buf.getContext('2d'); g.setTransform(1, 0, 0, 1, 0, 0); g.clearRect(0, 0, W, H);
+ drawLevel(g, k + 1, t, ctx); c.save(); c.globalAlpha = (t - (ex.sw - 0.05)) / 0.1; c.drawImage(buf, 0, 0); c.restore(); }
+ // 标题:逐字上浮(屏幕层,不跟相机);第一次 highlight / enter 时淡出
+ const qt = ctx.of('title')[0];
+ if (qt) { const nx = ctx.of('highlight', 'enter')[0], out = nx ? 1 - MO.sineInOut(clamp((t - nx.at) / 0.5)) : 1;
+ if (out > 0) { c.save(); c.globalAlpha = out; const fs = TY.fit(c, qt.text || '', W * 0.88, (ctx.portrait ? 84 : 76) * u, 'PuHui-Heavy', { maxLines: 2, balance: true });
+ fs.lines.forEach((ln, i) => TY.charsIn(c, ln, W / 2, ctx.safe.top + (ctx.portrait ? 200 : 130) * u + i * fs.size * 1.2, ctx.lt(t, qt.at) - i * 0.2, { font: `${fs.size}px "PuHui-Heavy"`, color: '#fff', dur: 0.5, stagger: 0.045, dy: 30 * u, align: 'center', shadow: { color: 'rgba(10,8,40,.6)', y: 6 * u, blur: ctx.alpha ? 14 * u : 0 } }));
+ c.restore(); } }
+ },
+};
+// 相机:本层关键帧;正在钻出去 → 推进那个节点到满屏;刚钻进来 → 从满屏的中心星球拉出
+function camAt(L, t, ctx) {
+ const { W, H } = ctx;
+ if (L.from && t < L.end0) { // 拉出:z 从「中心星球盖满屏」对数降到 1,星球从屏幕中心回到它的位置
+ const e = MO.cubicInOut(clamp((t - L.start) / (L.end0 - L.start))), Z = CAM.coverZoom(S.R) * 1.15;
+ return CAM.anchor(S.cx, S.cy, CAM.zlerp(Z, 1, e), lerp(W / 2, S.cx, e), lerp(H / 2, S.cy, e));
+ }
+ const ex = L.exit;
+ if (ex && t >= ex.at && ex.node) { // 推进:对数缩放,节点平滑移到画面中心,推到它的圆盖满屏
+ const base = CAM.at(L.keys, ex.at), e = MO.cubicIn(clamp((t - ex.at) / (ex.sw - ex.at)) ) * 0.5 + MO.cubicInOut(clamp((t - ex.at) / (ex.sw - ex.at))) * 0.5;
+ return CAM.pushTo(base, ex.node.x, ex.node.y, CAM.coverZoom(46 * ctx.u) * 1.2, e, e);
+ }
+ return CAM.at(L.keys, t);
+}
+function drawLevel(c, k, t, ctx) {
+ const { W, H, u } = ctx, L = levels[k], cam = camAt(L, t, ctx), { cx, cy, R } = S;
+ if (!ctx.alpha) {
+ c.fillStyle = TOON.vgrad(c, 0, H, P.sky); c.fillRect(0, 0, W, H);
+ CAM.layer(c, cam, 0.05, g => { for (const s of S.stars) { g.globalAlpha = 0.45 + 0.55 * (0.5 + 0.5 * Math.sin(t * s.sp + s.ph)); g.fillStyle = P.star; g.beginPath(); g.arc(s.x, s.y, s.r, 0, 7); g.fill(); } g.globalAlpha = 1; });
+ }
+ // highlight 生效时:被推近的节点亮,其余节点和标签暗下去
+ const hNow = [...L.hls].reverse().find(h => t >= h.at && h.node), dimK = hNow ? MO.smooth(clamp((t - hNow.at) / 0.6)) : 0;
+ const col = L.col, fyP = MO.float(t, 6 * u, 4), pull = L.from && t < L.end0 ? MO.smooth(clamp(((t - L.start) / (L.end0 - L.start) - 0.45) / 0.45)) : 1; // 刚钻进来:先是满屏纯色,名字和环在拉出后半段才出来
+ CAM.layer(c, cam, 1, g => {
+ // 连线+信号脉冲(flow:中心→1→2→3 串成链,信号依次流过)
+ L.nodes.forEach((nd, i) => {
+ const l = ctx.lt(t, nd.q.at); if (l <= 0) return;
+ const from = flow && i > 0 ? L.nodes[i - 1] : { x: cx, y: cy }, p = MO.cubicOut(clamp(l / 0.4)), ex = lerp(from.x, nd.x, p), ey = lerp(from.y, nd.y, p);
+ g.save(); g.globalAlpha = 1 - 0.6 * dimK * (hNow && hNow.node === nd ? 0 : 1);
+ g.strokeStyle = P.line; g.lineWidth = 4 * u; g.beginPath(); g.moveTo(from.x, from.y); g.lineTo(ex, ey); g.stroke();
+ if (flow && l > 0.4) { const ax = lerp(from.x, nd.x, 0.55), ay = lerp(from.y, nd.y, 0.55), a = Math.atan2(nd.y - from.y, nd.x - from.x); g.fillStyle = 'rgba(125,211,220,.7)'; g.translate(ax, ay); g.rotate(a); g.beginPath(); g.moveTo(10 * u, 0); g.lineTo(-8 * u, -9 * u); g.lineTo(-8 * u, 9 * u); g.closePath(); g.fill(); }
+ g.restore();
+ for (let kk = 0; kk < 3; kk++) { if (l < 0.4) break; const q = flow ? ((t * 0.7 - i * 0.33 + kk / 3) % 1 + 1) % 1 : ((l * 0.8 + kk / 3) % 1); const x = lerp(from.x, nd.x, q), y = lerp(from.y, nd.y, q); TOON.glow(g, x, y, 20 * u, P.pulse, 0.6 * (1 - 0.7 * dimK)); g.fillStyle = '#e9fdff'; g.beginPath(); g.arc(x, y, 5 * u, 0, 7); g.fill(); }
+ });
+ // 中心星球:双色分面+光晕呼吸+环
+ TOON.glow(g, cx, cy, R * (2.4 + 0.1 * Math.sin(t * 1.6)), light(col), 0.28);
+ TOON.flat(g, TOON.circle(cx, cy + fyP, R), col, dark(col), light(col), [-18 * u, 14 * u], [-6 * u, 5 * u]);
+ g.save(); g.globalAlpha = pull; g.strokeStyle = 'rgba(255,230,190,.55)'; g.lineWidth = 6 * u; g.beginPath(); g.ellipse(cx, cy, R * 1.55, R * 0.35, -0.25, Math.PI * 1.05, Math.PI * 1.95); g.stroke(); g.restore();
+ if (L.center) { const f = TY.fit(g, L.center, R * 1.7, 56 * u, 'PuHui-Heavy', { maxLines: 2, min: 0.5, balance: true }); // 名字放进星球里:先缩字号,再折两行
+ g.save(); g.globalAlpha = pull; g.font = `${f.size}px "PuHui-Heavy"`; g.fillStyle = '#fff'; g.textAlign = 'center'; g.textBaseline = 'middle';
+ f.lines.forEach((ln, i) => g.fillText(ln, cx, cy + fyP + (i - (f.lines.length - 1) / 2) * f.size * 1.1)); g.restore(); }
+ // 节点+标签胶囊(弹出 0.5s,过冲 108%)
+ for (const nd of L.nodes) {
+ const l = ctx.lt(t, nd.q.at); if (l <= 0) continue;
+ const on = hNow && hNow.node === nd, a = 1 - 0.65 * dimK * (on ? 0 : 1);
+ const pop = MO.backOut(clamp(l / 0.5), 1.1), fy = MO.float(t, 8 * u, 3.4 + nd.i * 0.4, nd.i), nr = 46 * u * pop * (on ? 1 + 0.15 * dimK : 1);
+ g.save(); g.globalAlpha = a;
+ TOON.glow(g, nd.x, nd.y + fy, nr * (on ? 4.2 : 2.6), nd.col, on ? 0.7 : 0.45);
+ TOON.flat(g, TOON.circle(nd.x, nd.y + fy, nr), nd.col, dark(nd.col), '#ffffff', [-8 * u, -8 * u], [-3 * u, -3 * u]);
+ if (flow) { g.font = `${30 * u * pop}px "PuHui-Heavy"`; g.fillStyle = '#1f1a3a'; g.textAlign = 'center'; g.textBaseline = 'middle'; g.fillText(String(nd.i + 1), nd.x, nd.y + fy + 2 * u); }
+ const gone = L.exit ? 1 - clamp((t - L.exit.at) / 0.2) : 1; // 钻进去时:推进一开始这一层的标签全收掉(不然被放大成半屏白块,邻居的也会)
+ const lp = MO.backOut(clamp((l - 0.15) / 0.5), 1.1) * gone; if (lp > 0) {
+ const sc = lp * (on ? 1 + 0.18 * dimK : 1);
+ const lf = TY.fit(g, nd.q.text || '', ctx.W * 0.44 - 56 * u, (ctx.portrait ? 44 : 38) * u, 'PuHui-Medium', { maxLines: 1 }); // 长标签先缩字号
+ g.font = `${lf.size}px "PuHui-Medium"`; const tw = g.measureText(nd.q.text || '').width, bw = tw + 56 * u, bh = 70 * u;
+ const ly = nd.y + fy + (nd.y < cy - R * 0.5 && ctx.portrait ? -nr - 70 * u : nr + 70 * u); // 标签放节点下方(竖屏上半圈放上方)
+ const z = cam.z || 1, vx0 = cam.x - ctx.W / 2 / z, vx1 = cam.x + ctx.W / 2 / z, hw = bw * sc / 2 + 20 * u / z; // 当前镜头里看得见的世界范围(慢推会把边上的标签推出画)
+ const lx = nd.x > vx0 && nd.x < vx1 ? (vx1 - vx0 > 2 * hw ? clamp(nd.x, vx0 + hw, vx1 - hw) : cam.x) : nd.x; // 节点在画里,标签就夹回画里
+ g.translate(lx, ly); g.scale(sc, sc);
+ g.fillStyle = 'rgba(20,40,20,.25)'; g.beginPath(); g.roundRect(-bw / 2 + 6 * u, -bh / 2 + 8 * u, bw, bh, bh / 2); g.fill();
+ g.fillStyle = '#ffffff'; g.beginPath(); g.roundRect(-bw / 2, -bh / 2, bw, bh, bh / 2); g.fill();
+ if (on) { g.strokeStyle = nd.col; g.lineWidth = 5 * u * dimK; g.stroke(); }
+ g.fillStyle = '#1f1a3a'; g.textAlign = 'center'; g.textBaseline = 'middle'; g.fillText(nd.q.text || '', 0, 2 * u);
+ }
+ g.restore();
+ }
+ // 萤火微粒
+ for (const m of S.motes) { const x = m.x + Math.sin(t * 0.8 + m.ph) * 30 * u, y = m.y - ((t * 22 * u + m.ph * 40 * u) % (120 * u)); g.globalAlpha = 0.4 + 0.4 * Math.sin(t * 2 + m.ph); g.fillStyle = '#fff6d0'; g.beginPath(); g.arc(x, y, m.s, 0, 7); g.fill(); }
+ g.globalAlpha = 1;
+ });
+}
+})();
diff --git a/scripts/engine/clips/y2_vox.js b/scripts/engine/clips/y2_vox.js
new file mode 100644
index 0000000..350eabd
--- /dev/null
+++ b/scripts/engine/clips/y2_vox.js
@@ -0,0 +1,141 @@
+// 片段 · Vox 式拼贴(y2):一张大桌面=世界,素材按出场顺序摆在桌上、红线连起来;相机 60fps 平滑追过去,
+// 桌上的东西(滑入、荧光笔、红圈、打字)按 12fps「一拍二」步进。
+// cues:image | clip(截图/照片/剪报:image 路径;text 可选=贴在下方的黑底标签;data.halftone:true 转成灰度网点,默认保留原色;at 这一帧开始滑入)
+// title(Borders 式黑底白字标签条,打字 13 字/秒)· point(横线索引卡,打字)
+// highlight(当前这张图上 data.rect=[x,y,w,h](0..1,相对图片):at 起荧光笔扫过 → 红笔圈住 → 相机推近那一块)
+// 截图等比放(不裁),只加纸白边和胶带;横屏素材左→右排、竖屏上→下排,相机沿红线追(长尾缓动+短运动模糊)。
+CLIPS.y2_vox = (() => {
+const { clamp, lerp, rng } = U;
+const C = { desk: '#e4ddcf', ink: '#171716', red: '#b8433f', paper: '#eeedeb', card: '#f6f4ee' };
+const BOLD = '"PuHui-Heavy"', TXT = '"PuHui-Bold"';
+let items, keys, strings;
+// 一拍二的片内时间:at 这一帧就 >0
+const ls = (t, at) => MO.step(t - at + 1e-6, 12) + 1 / 12;
+return {
+ fonts: ['PuHui-Heavy', 'PuHui-Bold'],
+ safe: true,
+ init(ctx) {
+ const { W, H, u, portrait } = ctx, r = rng(7), g = document.createElement('canvas').getContext('2d');
+ items = []; let cur = 0, prev = null;
+ for (const q of ctx.of('image', 'clip', 'title', 'point')) {
+ let w, h, kind = q.kind === 'clip' ? 'image' : q.kind, lines = null, size = 0;
+ if (kind === 'image') {
+ const im = ctx.IMG[q.image]; if (!im) continue;
+ const bw = W * (portrait ? 0.84 : 0.62), bh = H * (portrait ? 0.46 : 0.62), f = CLIP.fit(im.width, im.height, 0, 0, bw, bh);
+ w = f.w + 32 * u; h = f.h + 32 * u + (q.text ? 70 * u : 0);
+ } else {
+ if (!String(q.text ?? '').trim()) { console.warn(`y2 ${q.kind} at=${q.at}:text 是空的,这张卡跳过`); continue; } // 空卡宽度是 −Infinity,撕边点列会死循环
+ size = (kind === 'title' ? 64 : 48) * u;
+ lines = TY.wrap(g, q.text || '', W * (portrait ? 0.74 : 0.5), `${size}px ${kind === 'title' ? BOLD : TXT}`);
+ g.font = `${size}px ${kind === 'title' ? BOLD : TXT}`;
+ w = Math.max(...lines.map(l => g.measureText(l).width)) + (kind === 'title' ? 80 : 110) * u; h = lines.length * size * 1.45 + (kind === 'title' ? 50 : 100) * u;
+ }
+ const gap = 260 * u, jitter = (r() - 0.5) * (portrait ? W * 0.12 : H * 0.12);
+ const x = portrait ? W / 2 + jitter : (prev ? prev.x + prev.w / 2 + gap + w / 2 : W / 2);
+ const y = portrait ? (prev ? prev.y + prev.h / 2 + gap + h / 2 : H / 2) : H / 2 + jitter;
+ const it = { q, kind, x, y, w, h, rot: (r() - 0.5) * 0.07, lines, size, seed: 11 + items.length * 7 };
+ items.push(it); prev = it; cur++;
+ }
+ // 文字卡的打字速度与「读完」时刻:默认 13 字/秒;离下一件太近就提速(最多 40 字/秒),保证相机走之前打完、再停 0.5s 让人读完
+ items.forEach((it, i) => {
+ if (it.kind === 'image') { it.done = it.q.at + 0.6; return; }
+ const nC = [...(it.q.text || '')].length, next = items[i + 1] ? items[i + 1].q.at : ctx.dur;
+ it.cps = clamp(nC / Math.max(0.3, next - it.q.at - 0.95 - 0.5), 13, 40);
+ it.done = it.q.at + nC / it.cps + 0.5;
+ });
+ // 红线:上一件的右缘(竖屏下缘)钉到下一件的左缘(上缘)
+ strings = items.slice(1).map((b, i) => { const a = items[i];
+ const pa = portrait ? [a.x + a.w * 0.2, a.y + a.h / 2 - 20 * u] : [a.x + a.w / 2 - 30 * u, a.y + a.h * 0.25];
+ const pb = portrait ? [b.x - b.w * 0.2, b.y - b.h / 2 + 20 * u] : [b.x - b.w / 2 + 30 * u, b.y - b.h * 0.25];
+ const pts = CL.stringPts(pa, pb, 0.06); return { a: pa, b: pb, pts, cum: DG.cum(pts), at: b.q.at }; });
+ // 相机关键帧:每件到场前 ≈0.9s 起追过去(长尾),在它的 at 之前落定;高亮时推近那一块
+ const Hs = H - ctx.safe.top - ctx.safe.bottom; // 让开字幕带后的可用高度;画面中心同步下移/上移(draw 里平移)
+ const zFor = it => clamp(Math.min(W * 0.82 / it.w, Hs * 0.8 / it.h), 0.5, 1.6);
+ keys = []; let last = null;
+ const hls = ctx.of('highlight');
+ const events = [...items.map(it => ({ at: it.q.at, it })), ...hls.map(h => ({ at: h.at, h }))].sort((a, b) => a.at - b.at);
+ let curItem = null;
+ for (const e of events) {
+ if (e.it) {
+ const tgt = { x: e.it.x, y: e.it.y, z: zFor(e.it) };
+ if (!last) { keys.push({ t: 0, ...tgt }); }
+ else { const t0 = Math.max(last.t + 0.25, e.at - 0.95, Math.min(curItem ? curItem.done : 0, e.at - 0.4)), t1 = Math.max(t0 + 0.35, e.at - 0.05); // 上一张卡没读完相机不走(最晚 at−0.4 起跑)
+ keys.push({ t: t0, x: last.x, y: last.y, z: last.z }); keys.push({ t: t1, ...tgt, ease: MO.longTail }); }
+ last = keys[keys.length - 1]; curItem = e.it;
+ } else if (curItem && curItem.kind === 'image' && e.h.data && e.h.data.rect) {
+ const im = ctx.IMG[curItem.q.image], R = e.h.data.rect, ib = imgBox(curItem, im, u);
+ const cx = curItem.x + (ib.x + (R[0] + R[2] / 2) * ib.w) - curItem.w / 2, cy = curItem.y + (ib.y + (R[1] + R[3] / 2) * ib.h) - curItem.h / 2;
+ const rw = R[2] * ib.w, rh = R[3] * ib.h;
+ let zFit = Math.min(W * 0.8 / (rw * 1.4 + 32 * u), Hs * 0.8 / (rh * 1.44 + 20 * u)); // 红圈(下面 drawItem 的椭圆)推近后整圈留在画里,左右各留一成(审片:0.9 时手抖的圈和运动模糊仍会出画)
+ if (R[2] >= 0.5) zFit = Math.min(zFit, Math.max(last.z, W * 0.96 / curItem.w)); // 框占了半张图以上:推近只会把这张图两侧的字切掉,不推
+ const z = Math.min(clamp(Math.min(W * (ctx.portrait ? 0.78 : 0.55) / rw, Hs * 0.55 / rh), last.z, last.z * 2.6), zFit); // 竖屏宽是瓶颈:框推到约八成画宽
+ // 框的起点(荧光笔从左缘扫起)在当前镜头里看得见:先画、at+0.2 再推近;看不见(上一次推近后它在画外):
+ // 先把镜头移过去、at 前一帧到位,再揭开——否则揭开那一帧在画外,观众晚 0.2s 以上才看到(2026-10 竖屏实测晚 7 帧)
+ const x0 = cx - rw / 2, inView = Math.abs(x0 - last.x) * last.z < W / 2 - 20 * u && Math.abs(cy - last.y) * last.z < Hs / 2 - rh * last.z / 2;
+ const t0 = inView ? Math.max(last.t + 0.1, e.at + 0.2) : Math.max(last.t + 0.1, e.at - 0.8), t1 = inView ? t0 + 1.0 : Math.max(t0 + 0.35, e.at - 1 / ctx.FPS);
+ keys.push({ t: t0, x: last.x, y: last.y, z: last.z }); keys.push({ t: t1, x: cx, y: cy, z, ease: MO.sineInOut });
+ last = keys[keys.length - 1];
+ }
+ }
+ if (!keys.length) keys.push({ t: 0, x: W / 2, y: H / 2, z: 1 });
+ const end = keys[keys.length - 1]; keys.push({ t: Math.max(end.t + 0.01, ctx.dur), x: end.x, y: end.y, z: end.z * (1 + 0.01 * Math.max(0, ctx.dur - end.t)), ease: MO.linear }); // 停住后 1%/s 慢推
+ },
+ draw(c, t, ctx) {
+ const { W, H, u } = ctx, cam = CAM.at(keys, t);
+ const buf = UI.scratch('clip_vox', W, H), g = buf.getContext('2d'); g.reset();
+ g.save(); g.translate(0, (ctx.safe.top - ctx.safe.bottom) / 2); CAM.apply(g, cam);
+ if (!ctx.alpha) { g.fillStyle = g.createPattern(CL.paperTile('clipdesk', C.desk, { amt: 12, fibers: 320, fiberCol: [110, 95, 70] }), 'repeat'); const s = 4 / cam.z; g.fillRect(cam.x - W * s, cam.y - H * s, W * 2 * s, H * 2 * s); }
+ // 红线:跟着下一件的到场描出(12fps)
+ for (const s of strings) { const q = MO.sineInOut(clamp(ls(t, s.at - 0.9) / 0.7)); if (t < s.at - 0.9) continue;
+ CL.string(g, s.pts, s.cum, s.cum[s.cum.length - 1] * q, { col: C.red, lw: 5 * u }); CL.pin(g, s.a[0], s.a[1], C.red); if (q >= 1) CL.pin(g, s.b[0], s.b[1], C.red); }
+ for (const it of items) {
+ const q = it.q; if (t < q.at - 1e-6) continue;
+ // 一拍二从 at 起算(ls),不从绝对 12fps 网格起算:按网格取整会让素材比 cue 早 1–2 帧露出(2026-10 竖屏实测早了 2 帧)
+ CL.slideIn(g, q.at + ls(t, q.at), q.at, it.x, it.y, it.rot, gg => drawItem(gg, it, t, ctx), { from: ctx.portrait ? [120 * u, 360 * u] : [420 * u, -60 * u], tilt: 0.2, dur: 0.55, fps: 1e6 });
+ }
+ g.restore();
+ const [vx, vy] = CAM.velocity(tt => CAM.at(keys, tt), t);
+ if (Math.hypot(vx, vy) >= 1.5) c.drawImage(buf, 0, 0); // 先垫一张不偏移的:motionBlur 第一张就是偏移的,画面四边会留一圈半透明(出片是灰边)
+ CAM.motionBlur(c, buf, vx * 0.6, vy * 0.6, 7);
+ if (!ctx.alpha) { // 暗角+静态颗粒(纸纹是贴死的,不逐帧抖)
+ const v = PAINT.cached('clip_vox_vig' + W + 'x' + H, W, H, gg => { const r = gg.createRadialGradient(W / 2, H / 2, Math.min(W, H) * 0.45, W / 2, H / 2, Math.max(W, H) * 0.62); r.addColorStop(0, 'rgba(40,30,20,0)'); r.addColorStop(1, 'rgba(40,30,20,.34)'); gg.fillStyle = r; gg.fillRect(0, 0, W, H); });
+ c.drawImage(v, 0, 0);
+ }
+ },
+};
+function imgBox(it, im, u) { const f = CLIP.fit(im.width, im.height, 16 * u, 16 * u, it.w - 32 * u, it.h - 32 * u - (it.q.text ? 70 * u : 0)); return f; }
+function drawItem(g, it, t, ctx) {
+ const { u } = ctx, q = it.q, w = it.w, h = it.h;
+ if (it.kind === 'image') {
+ const im = ctx.IMG[q.image], f = imgBox(it, im, u);
+ CL.shadowed(g, () => { g.fillStyle = '#f2f0ea'; g.fillRect(-w / 2, -h / 2, w, h); }, { blur: 12 * u, x: 3 * u, y: 7 * u });
+ if (q.data && q.data.halftone) { const src = PAINT.canvas(Math.round(f.w), Math.round(f.h)); src.getContext('2d').drawImage(im, 0, 0, src.width, src.height); g.drawImage(CL.halftone('clipimg' + it.seed, src, { cell: 5 * u, contrast: 1.25 }), -w / 2 + f.x, -h / 2 + f.y, f.w, f.h); }
+ else g.drawImage(im, -w / 2 + f.x, -h / 2 + f.y, f.w, f.h);
+ g.save(); g.globalCompositeOperation = 'multiply'; g.fillStyle = 'rgba(214,205,185,.18)'; g.fillRect(-w / 2, -h / 2, w, h); g.restore(); // 印在纸上:压一层旧纸色
+ CL.tape(g, -w / 2 + 40 * u, -h / 2 + 8 * u, -0.6, 120 * u); CL.tape(g, w / 2 - 40 * u, -h / 2 + 8 * u, 0.5, 120 * u);
+ if (q.text) { const fs = TY.fit(g, q.text, w - 72 * u, 34 * u, 'PuHui-Bold', { maxLines: 1, min: 0.5 }); g.font = `${fs.size}px ${TXT}`; // 标签条按字宽量,放不下就缩字
+ g.fillStyle = C.ink; g.fillRect(-w / 2 + 16 * u, h / 2 - 72 * u, g.measureText(q.text).width + 40 * u, 56 * u); g.fillStyle = C.paper; g.textBaseline = 'middle'; g.fillText(q.text, -w / 2 + 36 * u, h / 2 - 43 * u); }
+ // 高亮:荧光笔(multiply,一拍二扫过)→ 红笔圈
+ for (const hq of ctx.of('highlight')) {
+ if (!hq.data || !hq.data.rect || hq.at < q.at) continue;
+ const own = ctx.of('image', 'clip').filter(z => z.at <= hq.at).pop(); if (own !== q) continue;
+ const l = t - hq.at; if (l < -1e-6) continue;
+ const R = hq.data.rect, x0 = -w / 2 + f.x + R[0] * f.w, y0 = -h / 2 + f.y + R[1] * f.h, rw = R[2] * f.w, rh = R[3] * f.h;
+ CL.highlight(g, x0 - 6 * u, y0 - 4 * u, rw + 12 * u, rh + 8 * u, MO.sineInOut(clamp(ls(t, hq.at) / 0.6)));
+ const cq = MO.cubicOut(clamp((ls(t, hq.at) - 0.5) / 0.6));
+ const newer = ctx.of('highlight').find(z => z.at > hq.at && z.at <= t + 1e-6 && z.data && z.data.rect && ctx.of('image', 'clip').filter(y => y.at <= z.at).pop() === q);
+ const fa = newer ? 1 - 0.75 * clamp((t - newer.at) / 0.3) : 1; // 同一张图圈了下一处:旧红圈退成淡痕,免得两个圈叠着、旧圈出画
+ if (cq > 0) { const pts = DG.hand(DG.ellipsePts(x0 + rw / 2, y0 + rh / 2, rw * 0.7 + 16 * u, rh * 0.72 + 10 * u, -2.6, 1.08, 44), { amp: 2.2 * u, seed: it.seed }), L = DG.cum(pts);
+ g.save(); g.globalAlpha *= fa; g.strokeStyle = C.red; g.lineWidth = 7 * u; g.lineCap = 'round'; g.lineJoin = 'round'; DG.drawPartial(g, pts, L, L[L.length - 1] * cq); g.restore(); }
+ }
+ } else {
+ const n = Math.ceil(ls(t, q.at) * (it.cps || 13)), title = it.kind === 'title';
+ CL.shadowed(g, () => { g.fillStyle = title ? C.ink : C.card; g.save(); g.translate(-w / 2, -h / 2); CL.tornRect(g, w, h, it.seed, 3 * u); g.fill(); g.restore(); }, { blur: 10 * u, x: 3 * u, y: 6 * u });
+ if (!title) { g.strokeStyle = 'rgba(80,140,200,.3)'; g.lineWidth = 2 * u; for (let y = -h / 2 + 90 * u; y < h / 2; y += it.size * 1.45) { g.beginPath(); g.moveTo(-w / 2, y); g.lineTo(w / 2, y); g.stroke(); }
+ g.strokeStyle = 'rgba(184,67,63,.5)'; g.beginPath(); g.moveTo(-w / 2, -h / 2 + 56 * u); g.lineTo(w / 2, -h / 2 + 56 * u); g.stroke(); }
+ g.fillStyle = title ? C.paper : C.ink; g.font = `${it.size}px ${title ? BOLD : TXT}`; g.textBaseline = 'alphabetic';
+ let k = 0; it.lines.forEach((ln, li) => { let x = -w / 2 + (title ? 40 : 55) * u; const y = -h / 2 + (title ? 25 * u : 70 * u) + (li + 1) * it.size * 1.3;
+ for (const ch of ln) { if (k < n) g.fillText(ch, x, y); x += g.measureText(ch).width; k++; } });
+ }
+}
+})();
diff --git a/scripts/engine/clips/y3_whiteboard.js b/scripts/engine/clips/y3_whiteboard.js
new file mode 100644
index 0000000..cbf832f
--- /dev/null
+++ b/scripts/engine/clips/y3_whiteboard.js
@@ -0,0 +1,206 @@
+// 片段 · 白板手绘(y3,RSA 型):说一句写一句、讲到东西就画出来。一支马克笔在白板上写字、画图标、画箭头、圈重点,相机跟着往下走,最后拉远看全图。
+// cues:title(标题,7.5 字/秒起,赶不上下一个 cue 会自动提速)· point(要点:先画一个小圈当项目符号再写,16 字/秒起)
+// draw(画一个手绘图标:data.icon 见下方 ICONS,text = 图标下的手写说明;和刚写的那条字并排;连续的 draw 用橙箭头连起来,像示范片「一摞图 → 网络」;data.arrow:false 不画箭头)
+// image(截图/草图:笔走之字形把它「揭开」,再描一圈手绘框;等比放,不裁)
+// highlight(橙圈圈住一条:data.index = 第几个要点(只数 point,从 0 起,和 t1/y1 同一口径);
+// data.target = 'title' | 'draw' | 'image' 改圈那一类(配 index 数那一类,默认最新);不写 = 最新写出的那一条;data.style:'underline' 改成划线)
+// 版式:横屏有 draw/image 时左文右图,竖屏有 draw 时图标在右侧窄栏;图标和刚写的那条字并排,连续的图标之间画往下的橙箭头。
+// 横屏纯文字、要点 ≥5 条时分左右两栏。字号随内容多少在 0.72–1.2 倍之间取,尽量一屏放下并撑满;放不下才让相机往下走。
+// 每一笔都在 at 这一帧落下第一点;写字速度=max(基准速度, 字数 / 到下一个 cue 的间隔),说到下一句时这句已写完。
+// 笔:两笔之间空档 <0.6s 沿弧线滑过去;更长就 0.35s 退出右下屏外,下一笔前 0.3s 再进来;最后一笔画完一定退场,不留在字上。
+// safe(spec.safe):内容只排在 top..H−bottom 之间,收尾拉远也只拉进这一带。alpha:墨色外面描一圈白边,叠在深色画面上也看得见。
+CLIPS.y3_whiteboard = (() => {
+const { clamp, lerp } = U;
+const INK = '#0A0503', ORANGE = '#EF7226', WASH = 'rgba(239,114,38,.22)', BOARD = '#FBFBFB';
+const FONT = 'LXGWWenKai-500';
+// ---------- 手绘图标:单位框 [-0.5,0.5]²(y 朝下)里的笔画;o:1 = 橙色强调,seg:1 = 快速直线(网络连线),fill = 铺浅橙 ----------
+const A = (cx, cy, rx, ry, a0, a1, n = 22) => DG.arcPts(cx, cy, rx, ry, a0, a1, n);
+const box = (x0, y0, x1, y1) => [[x0, y0], [x1, y0], [x1, y1], [x0, y1], [x0, y0 + 0.01]];
+const ICONS = {
+ person: () => [{ p: A(0, -0.3, 0.13, 0.13, -Math.PI / 2, Math.PI * 1.55) }, { p: [[0, -0.17], [0, 0.14]] }, { p: [[-0.24, -0.04], [0, -0.1], [0.24, -0.04]] }, { p: [[-0.17, 0.44], [0, 0.14], [0.17, 0.44]] }],
+ cat: () => { const k = 1 / 380, T = pts => pts.map(([x, y]) => [x * k, y * k + 0.44]);
+ return [{ p: T([[-60, -250], [-92, -330], [-30, -300], [30, -300], [92, -330], [60, -250]]) }, { p: T(A(0, -230, 100, 82, -0.55, Math.PI + 0.55, 26).reverse()) },
+ { p: T([[-80, -170], [-120, -60], [-110, 0], [110, 0], [120, -60], [80, -170]]), fill: T([[-80, -170], [-120, -60], [-110, 0], [110, 0], [120, -60], [80, -170], [0, -150]]) },
+ { p: T([[110, -20], [190, -40], [210, -130], [170, -190]]) }, { p: T(A(-38, -240, 12, 16, 0, Math.PI * 2, 14)), w: 0.8 }, { p: T(A(38, -240, 12, 16, 0, Math.PI * 2, 14)), w: 0.8 },
+ { p: T([[-30, -196], [-110, -206]]), w: 0.6 }, { p: T([[30, -196], [110, -206]]), w: 0.6 }]; },
+ network: () => { const C = [[-0.38, [-0.28, 0, 0.28]], [0, [-0.33, -0.11, 0.11, 0.33]], [0.38, [-0.14, 0.14]]], r = 0.06, out = [];
+ for (const [x, ys] of C) for (const y of ys) out.push({ p: A(x, y, r, r, -Math.PI / 2, Math.PI * 1.55, 14), fast: 1 });
+ for (let a = 0; a < 2; a++) for (const y0 of C[a][1]) for (const y1 of C[a + 1][1]) out.push({ seg: [[C[a][0] + r, y0], [C[a + 1][0] - r, y1]] });
+ return out; },
+ doc: () => [{ p: [[0.14, -0.42], [-0.3, -0.42], [-0.3, 0.42], [0.3, 0.42], [0.3, -0.26], [0.14, -0.42], [0.14, -0.26], [0.3, -0.26]] },
+ { p: [[-0.18, -0.12], [0.18, -0.12]], w: 0.7 }, { p: [[-0.18, 0.04], [0.18, 0.04]], w: 0.7 }, { p: [[-0.18, 0.2], [0.06, 0.2]], w: 0.7 }],
+ chat: () => [{ p: [[-0.3, -0.36], [0.3, -0.36], [0.42, -0.24], [0.42, 0.1], [0.3, 0.22], [-0.06, 0.22], [-0.24, 0.4], [-0.2, 0.22], [-0.3, 0.22], [-0.42, 0.1], [-0.42, -0.24], [-0.3, -0.36]] },
+ ...[-0.18, 0, 0.18].map(x => ({ p: A(x, -0.07, 0.035, 0.035, 0, Math.PI * 2, 10), w: 0.9, fast: 1 }))],
+ bulb: () => [{ p: A(0, -0.12, 0.26, 0.26, Math.PI * 0.72, Math.PI * 2.28, 30), fill: A(0, -0.12, 0.26, 0.26, 0, Math.PI * 2, 30) }, { p: [[-0.11, 0.12], [-0.11, 0.27], [0.11, 0.27], [0.11, 0.12]] },
+ { p: [[-0.08, 0.36], [0.08, 0.36]] }, ...[-2.4, -1.57, -0.74].map(a => ({ p: [[Math.cos(a) * 0.34, -0.12 + Math.sin(a) * 0.34], [Math.cos(a) * 0.46, -0.12 + Math.sin(a) * 0.46]], o: 1, fast: 1 }))],
+ check: () => [{ p: [[-0.32, 0.0], [-0.08, 0.26], [0.36, -0.32]], o: 1, w: 1.5 }],
+ cross: () => [{ p: [[-0.28, -0.28], [0.28, 0.28]], o: 1, w: 1.5 }, { p: [[0.28, -0.28], [-0.28, 0.28]], o: 1, w: 1.5 }],
+ screen: () => [{ p: box(-0.44, -0.36, 0.44, 0.2) }, { p: [[0, 0.2], [0, 0.34]] }, { p: [[-0.2, 0.36], [0.2, 0.36]] },
+ { p: [[-0.32, -0.22], [0.06, -0.22]], w: 0.6, fast: 1 }, { p: [[-0.24, -0.1], [0.24, -0.1]], w: 0.6, fast: 1 }, { p: [[-0.24, 0.02], [0.12, 0.02]], w: 0.6, fast: 1 }],
+ stack: () => [2, 1, 0].map(i => ({ p: box(-0.4 + i * 0.09, -0.22 - i * 0.09, 0.2 + i * 0.09, 0.3 - i * 0.09), paper: 1 })).concat([{ p: [[-0.3, 0.2], [-0.14, 0.02], [0, 0.14], [0.1, 0.06], [0.2, 0.2]], w: 0.7 }]),
+ gear: () => { const pts = []; for (let i = 0; i <= 64; i++) { const a = i / 64 * Math.PI * 2, r = (Math.floor(i / 4) % 2) ? 0.3 : 0.4; pts.push([Math.cos(a) * r, Math.sin(a) * r]); }
+ return [{ p: pts }, { p: A(0, 0, 0.12, 0.12, 0, Math.PI * 2.1, 16) }]; },
+ target: () => [{ p: A(0, 0.04, 0.4, 0.4, -Math.PI / 2, Math.PI * 1.55, 32) }, { p: A(0, 0.04, 0.25, 0.25, -Math.PI / 2, Math.PI * 1.55, 24) }, { p: A(0, 0.04, 0.09, 0.09, 0, Math.PI * 2, 12), fill: A(0, 0.04, 0.09, 0.09, 0, Math.PI * 2, 12) },
+ { p: [[0.46, -0.42], [0.02, 0.02]], o: 1 }, { p: [[0.3, -0.42], [0.46, -0.42], [0.46, -0.26]], o: 1 }],
+ clock: () => [{ p: A(0, 0, 0.4, 0.4, -Math.PI / 2, Math.PI * 1.55, 32) }, { p: [[0, -0.26], [0, 0], [0.18, 0.1]] }],
+ chart: () => [{ p: [[-0.42, -0.42], [-0.42, 0.38], [0.44, 0.38]] }, { p: [[-0.32, 0.22], [-0.12, 0.04], [0.06, 0.12], [0.34, -0.26]], o: 1 }, { p: [[0.18, -0.26], [0.34, -0.26], [0.34, -0.1]], o: 1 }],
+};
+let B, keys, items, OFF, lastEnd, band;
+const halo = (c, src, W, H, col, r) => { // 透明底:墨色外描一圈白边(8 个方向各压一次剪影)
+ const s2 = UI.scratch('clip_y3halo', W, H), g = s2.getContext('2d'); g.globalCompositeOperation = 'source-over'; g.clearRect(0, 0, W, H);
+ g.drawImage(src, 0, 0); g.globalCompositeOperation = 'source-in'; g.fillStyle = col; g.fillRect(0, 0, W, H); g.globalCompositeOperation = 'source-over';
+ for (let i = 0; i < 8; i++) { const a = i / 8 * Math.PI * 2; c.drawImage(s2, Math.cos(a) * r, Math.sin(a) * r); }
+ c.drawImage(src, 0, 0);
+};
+// 折行但各行等长:先按栏宽折出 n 行,再找「仍是 n 行」的最窄宽度重折(不留一个字孤零零挂在第二行)
+const balance = (g, text, maxW, font) => { const n = TY.wrap(g, text, maxW, font).length; if (n < 2) return [text];
+ let lo = maxW * 0.4, hi = maxW; for (let k = 0; k < 14; k++) { const m = (lo + hi) / 2; if (TY.wrap(g, text, m, font).length > n) lo = m; else hi = m; } return TY.wrap(g, text, hi, font); };
+// 手绘矩形:先把四条边各加密成多点,再加抖动,角还是角(直接对 4 个角点做 Catmull-Rom 会画成一个圆团)
+const rectPts = (x, y, w, h) => { const P = [[x, y], [x + w, y], [x + w, y + h], [x, y + h], [x, y + 3]], out = [];
+ for (let i = 0; i < 4; i++) for (let k = 0; k < 12; k++) out.push([lerp(P[i][0], P[i + 1][0], k / 12), lerp(P[i][1], P[i + 1][1], k / 12)]); out.push(P[4]); return out; };
+function layout(ctx, f) {
+ const { W, H, u, FPS, safe } = ctx, pad = (ctx.portrait ? 80 : 150) * u, lw = 6.5 * u, g = document.createElement('canvas').getContext('2d');
+ const cues = ctx.cues, next = q => { const i = cues.indexOf(q); const n = cues.slice(i + 1).find(z => z.at > q.at + 1e-6); return n ? n.at : ctx.dur; };
+ const hasDraw = cues.some(q => q.kind === 'draw'), hasImg = cues.some(q => q.kind === 'image' && ctx.IMG[q.image]);
+ // 栏:横屏有图就左文右图;竖屏有 draw 时图标排在右侧窄栏、和它说的那条字并排(截图仍整宽)
+ const S = (ctx.portrait ? 250 : 210) * u * f, gap = 70 * u * f;
+ const two = ctx.portrait ? hasDraw : (hasDraw || hasImg);
+ const colP = !two ? null : ctx.portrait ? { x: W - pad - S, w: S } : { x: W * 0.55, w: W * 0.45 - pad };
+ const nPt = cues.filter(q => q.kind === 'point').length, split = !ctx.portrait && !two && nPt >= 5 ? Math.ceil(nPt / 2) : 0; // 横屏纯文字、要点 ≥5 条:分左右两栏写
+ const colT = { x: pad, w: split ? W / 2 - pad - 40 * u : !two ? W - 2 * pad : ctx.portrait ? colP.x - gap - pad : W * 0.5 - pad };
+ let kPt = 0, col0 = null;
+ // 同一份清单的要点用同一个字号:取「放进一行」要缩到的最小那个(最小 0.72),还放不下的那条再折行
+ const pSize = Math.min(74 * u * f, ...cues.filter(q => q.kind === 'point').map(q => { const r = TY.fit(g, q.text || '', colT.w - 80 * u, 74 * u * f, FONT, { maxLines: 1, min: 0.72, soft: true }); return r.ok ? r.size : 74 * u * f * 0.72; }));
+ const B = DG.board({ ink: INK, lw, speed: 2600 * u, font: `"${FONT}"` }), items = [];
+ const top = (ctx.portrait ? 240 : 130) * u + safe.top;
+ let yT = top, yP = top, lastText = null, lastDraw = null; // 文字流 / 图流的当前 y
+ const start = q => B.at(Math.max(0, q.at - 1 / FPS)); // 第一笔在 at 这一帧可见
+ const capSz = (ctx.portrait ? 52 : 50) * u * Math.max(0.85, Math.min(1.1, f)), capRight = !ctx.portrait; // 横屏说明写在图标右边,竖屏写在下面
+ for (const q of cues) {
+ if (q.kind === 'title' || q.kind === 'point') {
+ const title = q.kind === 'title', indent = title ? 0 : 80 * u, colW = title ? W - 2 * pad : colT.w;
+ const ft = title ? TY.fit(g, q.text || '', colW - indent, 112 * u * f, FONT, { maxLines: 1, min: 0.72, soft: true }) : { size: pSize, lines: TY.wrap(g, q.text || '', colW - indent, `${pSize}px "${FONT}"`) }; // 标题先缩字号放一行,放不下再折行
+ const size = ft.size, lines = ft.lines.length > 1 ? balance(g, q.text || '', colW - indent, `${size}px "${FONT}"`) : ft.lines;
+ const n = [...(q.text || '')].length, room = Math.max(0.35, next(q) - q.at - 0.15 - (title ? 0 : 0.15)), rate = Math.max(title ? 7.5 : 16, n / room);
+ if (title) yT = Math.max(yT, yP);
+ else { if (col0 == null) col0 = yT; if (split && kPt === split) { colT.x = W / 2 + 40 * u; yT = col0; } kPt++; }
+ let y = yT + size * (title ? 1.1 : 1.0);
+ start(q);
+ if (!title) B.line(DG.ellipsePts(colT.x + 26 * u, y - size * 0.32, 15 * u, 15 * u, -1.6, 1.05, 18), { w: lw * 0.9, col: ORANGE, speed: 9000 * u, min: 0.08, gap: 0.02 });
+ const x = (title ? pad : colT.x) + indent, it = { q, kind: q.kind, x, y0: y - size, lines, size };
+ lines.forEach((ln, k) => B.text(ln, x, y + k * size * 1.3, size, { col: INK, rate }));
+ g.font = `${size}px "${FONT}"`; it.w = Math.max(...lines.map(l => g.measureText(l).width)); it.y1 = y + (lines.length - 1) * size * 1.3 + size * 0.25;
+ yT = it.y1 + (title ? 60 : 44) * u * f; items.push(it);
+ if (title) yP = Math.max(yP, yT); else lastText = it;
+ } else if (q.kind === 'draw') {
+ const icon = (q.data && q.data.icon) || '', mk = ICONS[icon];
+ if (!mk && icon) console.warn(`y3 draw:没有图标「${icon}」,可用:${Object.keys(ICONS).join(' ')}(只写说明字)`);
+ // 和刚写的那条字并排(那条字还没配图、且在图流下面);否则接在图流下面
+ const pair = lastText && !lastText.pic && lastText.y0 >= yP - 1;
+ const y0 = two ? (pair ? lastText.y0 + (lastText.y1 - lastText.y0) / 2 - S / 2 : yP) : yT;
+ const x0 = two ? colP.x : pad, cx = x0 + S / 2, cy = Math.max(y0, two ? yP : y0) + S / 2;
+ if (pair) lastText.pic = true;
+ const prev = lastDraw && !(q.data && q.data.arrow === false) ? lastDraw : null;
+ start(q);
+ const room = Math.max(0.5, next(q) - q.at - 0.15), strokes = mk ? mk() : [];
+ const P = pts => pts.map(([x, y]) => [cx + x * S, cy + y * S]);
+ const capN = [...(q.text || '')].length, arrowL = prev ? Math.max(0, cy - S / 2 - prev.y1) : 0;
+ const len = strokes.reduce((s, k) => s + (k.p ? DG.len(P(k.p)) : 0), 0) + arrowL;
+ const budget = clamp(room - (capN ? Math.max(0.3, capN / 16) : 0) - 0.1, 0.4, 1.4), sp = Math.max(2600 * u, len / budget);
+ if (prev && arrowL > 30 * u) { const ax = prev.cx, ay0 = prev.y1 + 8 * u, ay1 = cy - S / 2 - 8 * u; // 箭头:上一个图标 → 这一个(往下)
+ B.line([[ax, ay0], [ax + 6 * u, lerp(ay0, ay1, 0.5)], [ax, ay1]], { col: ORANGE, w: lw, speed: sp });
+ const h = Math.min(20 * u, (ay1 - ay0) * 0.4); B.line([[ax - h, ay1 - h], [ax, ay1], [ax + h, ay1 - h]], { col: ORANGE, w: lw, speed: sp, smooth: false }); }
+ for (const k of strokes) {
+ if (k.seg) { B.segment(P([k.seg[0]])[0], P([k.seg[1]])[0], { w: 2.5 * u, dur: 0.05, gap: 0.008 }); continue; }
+ const pts = P(k.p);
+ if (k.paper) B.fill(U.poly(pts), BOARD, 0.01);
+ B.line(pts, { col: k.o ? ORANGE : INK, w: lw * (k.w || 1), speed: sp * (k.fast ? 2 : 1), gap: 0.015 });
+ if (k.fill) B.fill(U.poly(P(k.fill)), WASH);
+ }
+ B.at(B.cur + 0.02);
+ const capMax = capRight ? W - pad - (x0 + S + 24 * u) : W - 2 * pad, cs = q.text ? TY.fit(g, q.text, capMax, capSz, FONT, { maxLines: 1 }).size : capSz; // 说明字放不下先缩字号
+ g.font = `${cs}px "${FONT}"`; const cw = q.text ? g.measureText(q.text).width : 0, crate = Math.max(16, capN / Math.max(0.3, room - (B.cur - q.at)));
+ const capX = capRight ? x0 + S + 24 * u : clamp(cx, pad + cw / 2, W - pad - cw / 2), capY = capRight ? cy + cs * 0.35 : cy + S / 2 + cs * 1.05; // 竖屏图标在右侧窄栏:居中的说明字夹回画内
+ if (q.text) B.text(q.text, capX, capY, cs, { col: INK, align: capRight ? 'left' : 'center', rate: crate });
+ const it = { q, kind: 'draw', x: x0, w: S, cx, y0: cy - S / 2, y1: cy + S / 2 + (capRight ? 0 : cs * 1.3),
+ hx: capRight ? x0 : Math.min(x0, capX - cw / 2), hw: capRight ? S + 24 * u + cw : Math.max(x0 + S, capX + cw / 2) - Math.min(x0, capX - cw / 2) };
+ items.push(it); lastDraw = it;
+ if (two) { yP = it.y1 + gap; if (!ctx.portrait) yT = Math.max(yT, pair ? it.y1 + gap * 0.5 : yT); else yT = Math.max(yT, it.y1 + gap * 0.6); }
+ else yT = it.y1 + gap;
+ } else if (q.kind === 'image') {
+ const im = ctx.IMG[q.image]; if (!im) continue;
+ // 右栏的图只用剩下的高度,不让相机为右栏往下走、把左栏的字推出画
+ const inCol = two && !ctx.portrait, y = (inCol ? yP : Math.max(yT, yP)) + 30 * u, box = inCol ? colP : { x: pad, w: W - 2 * pad };
+ const f2 = CLIP.fit(im.width, im.height, box.x, y, box.w, inCol ? Math.max(H * 0.2, Math.min(H * 0.5 * Math.max(0.8, f), H - safe.bottom - 80 * u - y)) : H * (ctx.portrait ? 0.32 : 0.45) * Math.max(0.8, f)), it = { q, kind: 'image', x: f2.x, y0: f2.y, w: f2.w, y1: f2.y + f2.h };
+ const zz = DG.zigzag(f2.x - 20 * u, f2.y - 10 * u, f2.w + 40 * u, f2.h + 20 * u, 7), cum = DG.cum(zz), rowH = (f2.h + 20 * u) / 7;
+ start(q);
+ const s = B.push({ kind: 'custom', t0: B.cur, t1: B.cur + Math.min(1.0, Math.max(0.4, next(q) - q.at - 0.5)), col: INK,
+ draw(gg, p) { gg.save(); if (p < 1) gg.clip(DG.revealMask(zz, cum, cum[cum.length - 1] * p, rowH * 2.6)); gg.drawImage(im, f2.x, f2.y, f2.w, f2.h); gg.restore(); return p < 1 ? DG.pointAt(zz, cum, cum[cum.length - 1] * p) : null; },
+ start() { return zz[0]; }, end() { return zz[zz.length - 1]; } });
+ B.at(s.t1 + 0.02);
+ B.line(rectPts(f2.x - 10 * u, f2.y - 10 * u, f2.w + 20 * u, f2.h + 20 * u), { w: lw * 0.8, speed: 9000 * u, amp: 1.0 * u });
+ yP = f2.y + f2.h + 60 * u; if (!inCol) yT = yP; items.push(it); lastDraw = null;
+ } else if (q.kind === 'highlight') {
+ const d = q.data || {}, written = items.filter(z => z.q.at <= q.at), kind = d.target || (d.index != null ? 'point' : null);
+ const pool = kind ? written.filter(z => z.kind === kind) : written, all = kind ? items.filter(z => z.kind === kind) : items;
+ const it = d.index != null ? all[d.index] : pool[pool.length - 1];
+ if (!it) { console.warn(`y3 highlight at=${q.at}:找不到要圈的条目(index=${d.index} target=${d.target || 'point'})`); continue; }
+ start(q);
+ const hx = it.hx ?? it.x, hw = it.hw ?? it.w;
+ if (d.style === 'underline') B.line([[hx - 10 * u, it.y1 + 12 * u], [hx + hw / 2, it.y1 + 18 * u], [hx + hw + 10 * u, it.y1 + 10 * u]], { col: ORANGE, w: lw * 1.3, speed: 3000 * u });
+ else B.line(DG.ellipsePts(hx + hw / 2, (it.y0 + it.y1) / 2, hw * 0.56 + 30 * u, (it.y1 - it.y0) * 0.62 + 24 * u, -2.9, 1.08, 44), { col: ORANGE, w: lw, speed: 3600 * u, amp: 1.6 * u });
+ }
+ }
+ const bottom = Math.max(...items.map(z => z.y1), top);
+ return { B, items, bottom, top, pad };
+}
+return {
+ fonts: [FONT],
+ safe: true,
+ init(ctx) {
+ const { W, H, u, safe } = ctx;
+ band = { y0: safe.top, y1: H - safe.bottom }; band.h = band.y1 - band.y0;
+ // 字号系数 f 从 1.2 往下试:内容少就放大撑满版面,内容多就缩(最小 0.72),还放不下才让相机往下走
+ let L; for (let f = 1.2; f >= 0.7; f -= 0.04) { L = layout(ctx, f); if (L.bottom + 70 * u <= band.y1) break; } // 内容少就放大(最大 1.2)把版面撑满
+ ({ B, items } = L);
+ OFF = [W + 140 * u, H + 280 * u];
+ lastEnd = Math.max(0, ...B.S.map(s => s.t1));
+ // 相机:内容超出可用带就在下一条开写前平移过去(sineInOut);最后有空就拉远看全图(只拉进 safe 带)
+ keys = [{ t: 0, x: W / 2, y: H / 2, z: 1 }]; let cy = H / 2, panned = false;
+ for (const it of items) {
+ const need = it.y1 + 70 * u - (cy + band.y1 - H / 2); if (need <= 0) continue;
+ panned = true; cy += need + band.h * 0.12; const t1 = Math.max(keys[keys.length - 1].t + 0.2, it.q.at), t0 = Math.max(keys[keys.length - 1].t + 0.01, t1 - 0.6);
+ keys.push({ t: t0, x: W / 2, y: keys[keys.length - 1].y, z: 1 }); keys.push({ t: t1, x: W / 2, y: cy, z: 1, ease: MO.sineInOut });
+ }
+ const y0c = Math.min(L.top, ...items.map(z => z.y0)) - 50 * u, y1c = L.bottom + 40 * u, total = y1c - y0c;
+ const zEnd = Math.min(0.94, band.h / total * 0.96);
+ // 收尾拉远:最后一笔后有 ≥0.6s 才拉;相机走过了的话,就算时间紧也在最后 0.8s 拉(不然末帧标题被切在顶上)
+ const tz0 = Math.max(keys[keys.length - 1].t + 0.01, panned ? Math.min(lastEnd + 0.1, ctx.dur - 0.8) : lastEnd + 0.1);
+ if (ctx.dur - tz0 >= 0.6) {
+ const prev = keys[keys.length - 1]; keys.push({ ...prev, t: tz0, ease: undefined });
+ const midW = (y0c + y1c) / 2, ty = midW - ((band.y0 + band.y1) / 2 - H / 2) / zEnd; // 全图中心落在 safe 带中心
+ keys.push({ t: Math.min(ctx.dur - 0.15, tz0 + 0.8), x: W / 2, y: ty, z: zEnd, ease: MO.sineInOut });
+ }
+ },
+ draw(c, t, ctx) {
+ const { W, H, u } = ctx, cam = CAM.at(keys, t);
+ const g = ctx.alpha ? (() => { const b = UI.scratch('clip_y3buf', W, H), x = b.getContext('2d'); x.setTransform(1, 0, 0, 1, 0, 0); x.clearRect(0, 0, W, H); return x; })() : c;
+ if (!ctx.alpha) { c.fillStyle = BOARD; c.fillRect(0, 0, W, H); }
+ g.save(); CAM.apply(g, cam); const { tip, col } = B.draw(g, t); g.restore();
+ const pen = penAt(t, cam, tip, ctx);
+ if (pen) DG.pen(g, pen[0], pen[1], col || B.penColor(t), Math.sin(t * 7) * 0.03);
+ if (ctx.alpha) halo(c, g.canvas, W, H, 'rgba(255,255,255,0.92)', 4 * u);
+ },
+};
+// 笔的位置(屏幕):在画 → 笔尖;空档短 → 沿弧线滑;空档长 → 退出右下再进来;画完最后一笔 → 0.35s 退场(返回 null = 不画)
+function penAt(t, cam, tip, ctx) {
+ if (tip) return CAM.toScreen(cam, tip[0], tip[1]);
+ const hs = B.S.filter(s => s.kind !== 'pop' && s.kind !== 'fill' && (s.kind !== 'custom' || s.handed !== false));
+ let prev = null, next = null; for (const s of hs) { if (s.t1 <= t) prev = s; else if (s.t0 > t && !next) next = s; }
+ if (prev && next && next.t0 - prev.t1 <= 0.6) return B.penAt(t, cam, null);
+ const end = s => B.penAt(s.t1, cam, null); // 上一笔终点(屏幕)
+ if (next && next.t0 - t <= 0.3) { const b = CAM.toScreen(cam, ...(next.kind === 'custom' ? next.start() : next.kind === 'line' ? next.pts[0] : [next.x, next.y - next.size * 0.3])), q = MO.cubicOut(1 - (next.t0 - t) / 0.3); return [lerp(OFF[0], b[0], q), lerp(OFF[1], b[1], q)]; }
+ if (prev && t - prev.t1 < 0.35) { const a = end(prev), q = MO.cubicIn((t - prev.t1) / 0.35); return [lerp(a[0], OFF[0], q), lerp(a[1], OFF[1], q)]; }
+ return null;
+}
+})();
diff --git a/scripts/engine/clips/y4_storytime.js b/scripts/engine/clips/y4_storytime.js
new file mode 100644
index 0000000..4b8765f
--- /dev/null
+++ b/scripts/engine/clips/y4_storytime.js
@@ -0,0 +1,168 @@
+// 片段 · 故事型简笔角色(y4,storytime):豆子花叔在小房间里对镜头讲,姿势快切(0.1s)后定住,笑点靠反应特写和插入镜头。
+// cues:point | title(他说一句:at 这一帧气泡弹出、开始张嘴;嘴按 text 的字数说 ≈6.5 字/秒;data.pose 指定姿势 talk/point/shrug/type)
+// 气泡里写什么:有 sub 就写 sub(≤12 字的短句最好),没有才写 text——口播原文交给管线的字幕,气泡别和字幕重复一遍
+// highlight(「?」「!」弹出+摊手担心:data.mark 默认「?」)
+// react(反应镜头:at 这一帧跳到大特写,死鱼眼+汗滴,一言不发;dur 默认到下一个 cue)
+// insert(插入镜头:at 这一帧切到桌上那台电脑的屏幕特写——sub = 他打的那一行(打字、发送),之后 AI 的回复像代码墙一样越滚越快,
+// text = 砸出来的大字(如「3000行」),在 data.hit(绝对秒,默认 at+1.3,没有 sub 时 at+0.4)砸出、屏幕一震;
+// data.count + data.unit 让右上角计数器在砸出那一刻停在这个数;dur 默认到下一个 cue)
+// 房间里有桌上的电脑(插入镜头切进去的就是它的屏幕)、马克杯、墙上的书架和绿植,右边不再是空墙。
+// 没有口播包络时,口型由字数和时间合成(一拍二,0/1/2 三张嘴);有包络就把 window.VO_ENV 交给管线(TOON.mouth 自动读)。
+// safe:气泡、插入镜头的大字排在 top..H−bottom 之间。alpha:不画房间,角色和气泡照画(气泡本来就是白底黑字);插入镜头只画显示器和后脑勺,四周透明。
+CLIPS.y4_storytime = (() => {
+const { clamp, lerp, rng } = U;
+const C = { wall: '#DCE9EC', wall2: '#CFE0E4', floor: '#E8DCC8', desk: '#E2C29B', deskSide: '#CDA97F', line: '#5B6470', sky: '#BFE3F5', screen: '#20222D' };
+const COLS = ['#C792EA', '#82AAFF', '#C3E88D', '#F78C6C', '#89DDFF', '#FFCB6B', '#676E95'];
+const LINES = (() => { const r = rng(42), out = []; let ind = 0;
+ for (let i = 0; i < 400; i++) { if (r() < 0.18) ind = Math.min(4, ind + 1); else if (r() < 0.2) ind = Math.max(0, ind - 1);
+ const toks = []; let x = ind * 34; const n = 1 + (r() * 4 | 0); for (let k = 0; k < n; k++) { const w = 30 + r() * 150; toks.push([x, w, COLS[(r() * COLS.length) | 0]]); x += w + 14; } out.push(toks); } return out; })();
+let keys, says, L, shots;
+return {
+ fonts: ['PuHui-Bold', 'PuHui-Black'],
+ safe: true,
+ init(ctx) {
+ const { W, H, u } = ctx;
+ L = { cx: ctx.portrait ? W * 0.42 : W * 0.3, fy: ctx.portrait ? H * 0.8 : H * 1.02, R: (ctx.portrait ? 230 : 215) * u };
+ L.dy = L.fy - L.R * 0.55; // 桌面高度
+ L.mon = ctx.portrait ? { x: W * 0.66, w: 330 * u, h: 240 * u } : { x: W * 0.6, w: 520 * u, h: 340 * u }; // 桌上的电脑(屏幕左上角 x、宽高)
+ says = ctx.of('point', 'title').map(q => ({ q, end: q.at + Math.max(0.6, [...(q.text || '')].length / 6.5) }));
+ keys = [[0, 'rest', 'happy']]; let n = 0;
+ for (const q of ctx.cues) {
+ if (q.kind === 'point' || q.kind === 'title') keys.push([q.at, (q.data && q.data.pose) || (n++ % 2 ? 'point' : 'talk'), 'talk']);
+ if (q.kind === 'highlight') keys.push([q.at, 'shrug', 'worry']);
+ if (q.kind === 'react' || q.kind === 'insert') keys.push([q.at, 'stiff', 'blank']);
+ }
+ // 特写镜头(react / insert)占的时间段
+ shots = ctx.of('react', 'insert').map(q => { const nx = ctx.cues.find(z => z.at > q.at + 1e-6); const end = q.dur ? q.at + q.dur : nx ? nx.at : ctx.dur + 1;
+ const hit = q.kind === 'insert' ? (q.data && q.data.hit != null ? +q.data.hit : q.at + (q.sub ? 1.3 : 0.4)) : 0; return { q, end, hit }; });
+ },
+ draw(c, t, ctx) {
+ const { W, H, u } = ctx, ts = MO.step(t, 24); // 角色 24fps,镜头 60fps
+ const shot = shots.find(s => t >= s.q.at - 1e-6 && t < s.end);
+ if (shot && shot.q.kind === 'insert') return insert(c, t, ctx, shot);
+ const inReact = !!shot;
+ // 镜头:中景慢推 3%;反应=同机位跳到 1.9 倍大特写(砸镜:前 0.3s 从 2.2 弹回)
+ let z = 1.0 + 0.03 * MO.quintOut(clamp(t / 3)), cy = L.fy - L.R * 1.6;
+ if (inReact) { const l = t - shot.q.at; z = 1.9 * (1 + 0.15 * Math.max(0, 1 - MO.springHz(l, 3, 11))) * (1 + 0.03 * clamp(l / 1.5)); cy = L.fy - L.R * 2.2; }
+ const [dx, dy] = CAM.drift(t, 3 * u, 1);
+ if (!ctx.alpha) { c.fillStyle = C.wall; c.fillRect(0, 0, W, H); }
+ CAM.with(c, { x: (inReact ? L.cx : W / 2) + dx, y: (inReact ? cy : H / 2) + dy, z }, g => {
+ if (!ctx.alpha) room(g, t, ctx);
+ const st = TOON.poseAt(keys, ts), say = says.find(s => t >= s.q.at - 1e-6 && t < s.end);
+ const mouth = window.VO_ENV ? TOON.mouth(t) : say ? [1, 2, 1, 0, 2, 1][Math.floor(MO.step(t - say.q.at + 1e-6, 12) * 12) % 6] : 0;
+ const blink = TOON.blinkAt(ts, [0.9, 3.4, 6.1, 8.8, 11.5]), br = 1 + 0.012 * Math.sin(2 * Math.PI * t / 1.6);
+ const info = TOON.bean(g, { x: L.cx, y: L.fy, s: L.R, pose: st.pose, expr: inReact ? 'blank' : st.expr, mouth: inReact ? 0 : mouth, blink, squash: st.squash * br, bob: mouth * L.R * 0.015, tilt: st.expr === 'worry' ? -0.06 : 0.02 * Math.sin(t), lw: inReact ? 12 * u : undefined });
+ if (!ctx.alpha) desk(g, t, ctx);
+ if (inReact) { const sw = clamp((t - shot.q.at - 0.3) / 0.9); if (sw > 0) TOON.sweat(g, L.cx + L.R * 0.88, info.head[1] - L.R * 0.1, 30 * u, MO.expoOut(sw) * 0.6 + sw * 0.4); }
+ for (const h of ctx.of('highlight')) { const l = ctx.lt(t, h.at); if (l <= 0) continue;
+ g.save(); g.translate(info.head[0] + L.R * 1.35, info.head[1] - L.R * 0.6); g.rotate(0.14 + 0.05 * Math.sin(t * 6)); TOON.mark(g, (h.data && h.data.mark) || '?', 0, 0, clamp(l / 0.26), 130 * u); g.restore(); }
+ });
+ // 对话气泡(屏幕空间,不跟镜头):at 这一帧弹出,说完 0.6s 后收起;特写切回来后,特写之前的那句不再出现
+ if (!inReact) for (const s of says) {
+ const l = ctx.lt(t, s.q.at), out = clamp((t - s.end - 0.6) / 0.2); if (l <= 0 || out >= 1) continue;
+ const nx = says[says.indexOf(s) + 1]; if (nx && t >= nx.q.at - 1e-6) continue;
+ if (shots.some(sh => sh.q.at > s.q.at && sh.q.at <= t)) continue;
+ const txt = s.q.sub || s.q.text || '';
+ const bw0 = ctx.portrait ? W * 0.84 : W * 0.42, f = TY.fit(c, txt, bw0 - 80 * u, (ctx.portrait ? 64 : 62) * u, 'PuHui-Bold', { maxLines: 2, min: 0.72, balance: true });
+ c.font = `${f.size}px "PuHui-Bold"`; const bw = Math.min(bw0, Math.max(...f.lines.map(x => c.measureText(x).width)) + 80 * u);
+ const bh = f.lines.length * f.size * 1.3 + 56 * u, bx = ctx.portrait ? (W - bw) / 2 : W * 0.5, by = ctx.safe.top + (ctx.portrait ? H * 0.06 : H * 0.09);
+ const sc = MO.backOut(clamp(l / 0.25), 2.2) * (1 - out);
+ c.save(); c.translate(bx + 60 * u, by + bh); c.scale(sc, sc); c.translate(-(bx + 60 * u), -(by + bh));
+ c.fillStyle = '#fff'; c.strokeStyle = '#1B1B1F'; c.lineWidth = 6 * u; c.lineJoin = 'round';
+ c.beginPath(); c.roundRect(bx, by, bw, bh, 40 * u); c.moveTo(bx + 70 * u, by + bh); c.lineTo(bx + (ctx.portrait ? 40 : 10) * u, by + bh + 60 * u); c.lineTo(bx + 130 * u, by + bh); c.fill(); c.stroke();
+ c.fillStyle = '#fff'; c.fillRect(bx + 76 * u, by + bh - 8 * u, 50 * u, 12 * u);
+ c.fillStyle = '#1B1B1F'; c.textBaseline = 'alphabetic';
+ f.lines.forEach((ln, i) => c.fillText(ln, bx + 40 * u, by + 26 * u + (i + 1) * f.size * 1.2));
+ c.restore();
+ }
+ },
+};
+// 房间:墙、地、窗(慢飘的云)、书架、画框。只画一次的东西不缓存——片段短,画得起
+function room(g, t, ctx) {
+ const { W, H, u } = ctx, X0 = -W, Y0 = -H, fy = L.fy;
+ g.fillStyle = C.wall; g.fillRect(X0, Y0, W * 3, H * 3);
+ g.fillStyle = C.floor; g.fillRect(X0, fy + 10 * u, W * 3, H * 2);
+ g.lineWidth = 3 * u; g.strokeStyle = C.line; g.lineJoin = 'round'; g.beginPath(); g.moveTo(X0, fy + 10 * u); g.lineTo(X0 + W * 3, fy + 10 * u); g.stroke();
+ // 窗:天空+慢飘的云
+ const wx = ctx.portrait ? W * 0.08 : W * 0.05, wy = ctx.portrait ? H * 0.2 : H * 0.12, ww = ctx.portrait ? W * 0.3 : W * 0.17, wh = ww * 0.7;
+ g.save(); g.beginPath(); g.roundRect(wx, wy, ww, wh, 12 * u); g.clip(); g.fillStyle = C.sky; g.fillRect(wx, wy, ww, wh);
+ for (const [k, r, sp] of [[0.2, 46, 18], [0.7, 34, 12]]) { const x = wx - 60 * u + ((k * ww + t * sp * u) % (ww + 120 * u)), y = wy + wh * (0.35 + k * 0.3); g.fillStyle = '#fff'; g.beginPath(); g.arc(x, y, r * u, 0, 7); g.arc(x + r * 0.9 * u, y + 6 * u, r * 0.75 * u, 0, 7); g.arc(x - r * 0.9 * u, y + 8 * u, r * 0.65 * u, 0, 7); g.fill(); }
+ g.restore(); g.strokeStyle = C.line; g.beginPath(); g.roundRect(wx, wy, ww, wh, 12 * u); g.moveTo(wx + ww / 2, wy); g.lineTo(wx + ww / 2, wy + wh); g.moveTo(wx, wy + wh / 2); g.lineTo(wx + ww, wy + wh / 2); g.stroke();
+ // 墙上:横屏右边一块书架;竖屏书架在窗下方右侧
+ const r = rng(9), sx = ctx.portrait ? W * 0.62 : W * 0.68, sy = ctx.portrait ? H * 0.3 : H * 0.36, sw = ctx.portrait ? W * 0.3 : W * 0.22;
+ g.fillStyle = '#D9C3A0'; g.fillRect(sx, sy, sw, 16 * u); g.strokeRect(sx, sy, sw, 16 * u);
+ let x = sx + 16 * u; while (x < sx + sw * 0.7) { const w = (22 + r() * 22) * u, h = (70 + r() * 40) * u; g.fillStyle = ['#8FB3C9', '#E7A37B', '#B9C98F', '#C6A0C9'][(r() * 4) | 0]; g.fillRect(x, sy - h, w, h); g.strokeRect(x, sy - h, w, h); x += w + 5 * u; }
+ g.fillStyle = '#E7A37B'; const px = sx + sw * 0.83; g.beginPath(); g.moveTo(px - 30 * u, sy); g.lineTo(px - 38 * u, sy - 56 * u); g.lineTo(px + 38 * u, sy - 56 * u); g.lineTo(px + 30 * u, sy); g.closePath(); g.fill(); g.stroke();
+ g.fillStyle = '#8DBF8B'; for (const [dx, a] of [[-18, -0.5], [0, 0], [18, 0.5]]) { g.beginPath(); g.ellipse(px + dx * u, sy - 100 * u, 16 * u, 46 * u, a, 0, 7); g.fill(); g.stroke(); }
+}
+// 桌子挡在腰前(角色线最黑最粗,背景线细而灰);桌上的电脑、马克杯
+function desk(g, t, ctx) {
+ const { W, H, u } = ctx, X0 = -W, dy = L.dy; g.lineWidth = 3 * u; g.strokeStyle = C.line;
+ // 电脑:屏幕微微发光,上面是滚动的代码色块(插入镜头切进去就是它)
+ const M = L.mon, mx = M.x, my = dy - M.h - 60 * u;
+ g.fillStyle = '#9AA0AC'; g.fillRect(mx + M.w / 2 - 18 * u, dy - 62 * u, 36 * u, 62 * u); g.strokeRect(mx + M.w / 2 - 18 * u, dy - 62 * u, 36 * u, 62 * u);
+ g.beginPath(); g.ellipse(mx + M.w / 2, dy, 90 * u, 10 * u, 0, 0, 7); g.fill(); g.stroke();
+ g.fillStyle = '#2B2D36'; g.beginPath(); g.roundRect(mx, my, M.w, M.h, 16 * u); g.fill(); g.stroke();
+ g.save(); g.beginPath(); g.roundRect(mx + 14 * u, my + 14 * u, M.w - 28 * u, M.h - 28 * u, 6 * u); g.clip(); g.fillStyle = C.screen; g.fillRect(mx, my, M.w, M.h);
+ const lh = 22 * u, off = (t * 30 * u) % lh; for (let i = 0; i < 20; i++) { const y = my + 30 * u + i * lh - off; for (const [x, w, col] of LINES[i % LINES.length]) { g.fillStyle = col; g.globalAlpha = 0.75; g.fillRect(mx + 26 * u + x * 0.3 * u, y, w * 0.3 * u, 8 * u); } }
+ g.restore(); g.globalAlpha = 1;
+ g.fillStyle = C.desk; g.fillRect(X0, dy, W * 3, 40 * u); g.strokeRect(X0, dy, W * 3, 40 * u);
+ g.fillStyle = C.deskSide; g.fillRect(X0, dy + 40 * u, W * 3, H); g.strokeRect(X0, dy + 40 * u, W * 3, H);
+ // 马克杯
+ const cx = ctx.portrait ? W * 0.1 : L.cx - L.R * 1.9; g.fillStyle = '#F26B4F'; g.beginPath(); g.roundRect(cx, dy - 92 * u, 70 * u, 92 * u, 10 * u); g.fill(); g.stroke();
+ g.beginPath(); g.arc(cx + 78 * u, dy - 52 * u, 22 * u, -1.2, 1.2); g.lineWidth = 9 * u; g.stroke(); g.lineWidth = 3 * u;
+}
+// 插入镜头:电脑屏幕特写(过肩),打字→发送→代码墙加速滚→大字砸出+屏幕一震(和示范片 s2_screen 同一套)
+function insert(c, t, ctx, shot) {
+ const { W, H, u, safe } = ctx, q = shot.q, d = q.data || {}, t0 = q.at, msg = q.sub || '', T_SEND = t0 + (msg ? 0.1 + Math.min(0.9, [...msg].length / 14) + 0.1 : 0.05), T_HIT = Math.max(shot.hit, T_SEND + 0.2);
+ const lt = t - t0, slam = t - T_HIT;
+ const scrollAt = tt => { const k = Math.max(0, tt - T_SEND - 0.15), span = Math.max(0.3, T_HIT - T_SEND - 0.15); return 46 * u * (k * 6 + Math.pow(k / span * 1.8, 3) * 6); };
+ const shake = slam > 0 && slam < 0.3 ? MO.settle(slam, 14 * u, 9, 14) : 0;
+ const zoom = 1.06 - 0.06 * MO.expoOut(clamp(lt / 0.25)) + 0.02 * clamp(lt / 2.2) + (slam > 0 ? 0.04 * MO.expoOut(clamp(slam / 0.12)) : 0); // 切进来:1.06 落到 1(像推过去的一下)
+ if (!ctx.alpha) { c.fillStyle = '#15161C'; c.fillRect(0, 0, W, H); } // 透明模式:只留显示器和后脑勺,口播画面从四周透出来
+ const bx = W * 0.06, by = safe.top + H * 0.05, bw = W * 0.88, bh = H - safe.bottom - by - H * (ctx.portrait ? 0.2 : 0.06);
+ CAM.with(c, { x: W / 2 + shake, y: H / 2 - shake * 0.5, z: zoom }, c => {
+ c.fillStyle = '#2B2D36'; c.beginPath(); c.roundRect(bx, by, bw, bh, 34 * u); c.fill();
+ const sx = bx + 40 * u, sy = by + 40 * u, sw = bw - 80 * u, sh = bh - 80 * u;
+ c.save(); c.beginPath(); c.roundRect(sx, sy, sw, sh, 14 * u); c.clip(); c.fillStyle = C.screen; c.fillRect(sx, sy, sw, sh);
+ const scr = scrollAt(t), top = sy + 64 * u;
+ // 我那一行:右侧气泡,打字(光标闪),发送后变蓝
+ if (msg) { const bubY = top + 110 * u - Math.min(scr, 600 * u), p = clamp((t - t0 - 0.1) / Math.max(0.2, T_SEND - t0 - 0.2));
+ const mf = TY.fit(c, msg, sw * 0.7 - 60 * u, (ctx.portrait ? 44 : 40) * u, 'PuHui-Bold', { maxLines: 3, min: 0.75, balance: true }), fs = mf.size, lh = fs * 1.3; // 长句折行(最多 3 行),气泡往下长
+ const bwid = Math.max(...mf.lines.map(l => TY.width(c, l, fs, 'PuHui-Bold'))) + 60 * u, bht = 78 * u + (mf.lines.length - 1) * lh;
+ if (bubY > sy) { c.fillStyle = t >= T_SEND ? '#3B82F6' : '#2F3342'; c.beginPath(); c.roundRect(sx + sw - 30 * u - bwid, bubY - 52 * u, bwid, bht, 24 * u); c.fill();
+ let left = Math.round(p * mf.lines.reduce((a, l) => a + [...l].length, 0)); // 逐行打出来,光标跟在最后打到的那一行
+ const ns = mf.lines.map(ln => { const n = Math.min(left, [...ln].length); left -= n; return n; }), curK = Math.max(0, ns.findLastIndex(n => n > 0)), blink = t < T_SEND && Math.floor(t * 4) % 2;
+ mf.lines.forEach((ln, k) => { if (k > curK) return;
+ TY.text(c, [...ln].slice(0, ns[k]).join('') + (blink && k === curK ? '|' : ''), sx + sw - 30 * u - bwid + 30 * u, bubY + 2 * u + k * lh, { size: fs, fam: 'PuHui-Bold', color: '#fff', align: 'left' }); }); } }
+ // AI 的回复:代码墙,越滚越快
+ if (t > T_SEND + 0.05) { const lh = 46 * u, y0 = top + (msg ? 220 : 40) * u - scr;
+ for (let i = Math.max(0, Math.floor((top - y0) / lh)); ; i++) { const y = y0 + i * lh; if (y > sy + sh) break; if (y < top) continue;
+ const shown = clamp((t - T_SEND - 0.05 - Math.min(i, 12) * 0.03) / 0.05); if (shown <= 0) continue;
+ c.fillStyle = '#4A4F66'; c.fillRect(sx + 30 * u, y - 12 * u, 44 * u, 16 * u);
+ for (const [x, w, col] of LINES[i % LINES.length]) { c.fillStyle = col; c.globalAlpha = 0.9; c.beginPath(); c.roundRect(sx + 110 * u + x * u, y - 14 * u, w * u * shown, 20 * u, 10 * u); c.fill(); } c.globalAlpha = 1; }
+ const v = (scrollAt(t + 1 / 60) - scr) * 60; if (v > 1500 * u) { c.fillStyle = `rgba(32,34,45,${clamp((v - 1500 * u) / (6000 * u)) * 0.5})`; c.fillRect(sx, top, sw, sh); } }
+ // 顶栏:三个圆点、标题、计数器(砸出那一刻停在 data.count)
+ c.fillStyle = '#2A2D3A'; c.fillRect(sx, sy, sw, 64 * u);
+ ['#FF5F57', '#FEBC2E', '#28C840'].forEach((col, i) => { c.fillStyle = col; c.beginPath(); c.arc(sx + 42 * u + i * 34 * u, sy + 32 * u, 10 * u, 0, 7); c.fill(); });
+ TY.text(c, d.app || 'AI助手', sx + sw / 2, sy + 44 * u, { size: 30 * u, fam: 'PuHui-Bold', color: '#9AA3B8' });
+ if (d.count != null && t > T_SEND + 0.1) { const N = +d.count, k = slam >= 0 ? N : Math.min(N - 1, Math.floor(Math.pow(clamp((t - T_SEND - 0.15) / Math.max(0.2, T_HIT - T_SEND - 0.15)), 2.4) * (N - 1)));
+ TY.text(c, `${k}${d.unit || ''}`, sx + sw - 30 * u, sy + 44 * u, { size: 32 * u, fam: 'PuHui-Bold', color: slam >= 0 ? '#FFCB6B' : '#9AA3B8', align: 'right' }); }
+ // 大字砸出(backOut 过冲)+压暗
+ if (slam > 0 && q.text) { c.fillStyle = `rgba(10,10,16,${0.6 * MO.expoOut(clamp(slam / 0.15))})`; c.fillRect(sx, sy, sw, sh);
+ const fs = TY.fit(c, q.text, sw * 0.86, (ctx.portrait ? 200 : 230) * u, 'PuHui-Black', { maxLines: 2, min: 0.4, balance: true });
+ fs.lines.forEach((ln, i) => TY.pop(c, ln, sx + sw / 2, sy + sh / 2 + fs.size * 0.35 + (i - (fs.lines.length - 1) / 2) * fs.size * 1.1, clamp(slam / 0.24), { size: fs.size, fam: 'PuHui-Black', color: '#FFCB6B', over: 3.5, stroke: '#15161C', strokeW: 18 * u })); }
+ c.restore();
+ });
+ // 前景:他的后脑勺(过肩),随呼吸起伏,砸出时往后一缩
+ const hx = W * (ctx.portrait ? 0.2 : 0.17), hy = by + bh - 60 * u + 6 * u * Math.sin(2 * Math.PI * t / 1.6) + (slam > 0 ? -MO.settle(slam, 18 * u, 4, 7) : 0), s = (ctx.portrait ? 0.8 : 0.75) * u;
+ c.save(); c.translate(hx, hy); c.scale(s, s); c.lineWidth = 7; c.strokeStyle = '#1B1B1F'; c.lineJoin = 'round';
+ c.fillStyle = '#FFFFFF'; c.beginPath(); c.ellipse(0, 300, 330, 200, 0, Math.PI, 0); c.fill(); c.stroke();
+ c.fillStyle = '#FFE2CC'; c.beginPath(); c.roundRect(-70, 120, 140, 110, 30); c.fill(); c.stroke();
+ for (const k of [-1, 1]) { c.beginPath(); c.ellipse(k * 196, 40, 34, 52, k * 0.2, 0, 7); c.fill(); c.stroke(); }
+ c.fillStyle = '#1B1B1F'; c.beginPath(); c.ellipse(0, 40, 190, 175, 0, 0, 7); c.fill();
+ c.fillStyle = '#FFFFFF'; c.beginPath(); c.moveTo(-180, -20); c.bezierCurveTo(-180, -290, 180, -290, 180, -20); c.closePath(); c.fill(); c.stroke();
+ c.beginPath(); c.ellipse(0, -12, 280, 64, 0, 0, 7); c.fill(); c.stroke();
+ c.restore();
+}
+})();
diff --git a/scripts/engine/clips/y5_kinetic_type.js b/scripts/engine/clips/y5_kinetic_type.js
new file mode 100644
index 0000000..e18f941
--- /dev/null
+++ b/scripts/engine/clips/y5_kinetic_type.js
@@ -0,0 +1,126 @@
+// 片段 · 动态文字(y5):字就是演员。一个 cue 一页:主词在 at 这一帧砸进来(弹簧过冲 ≈8%),辅句从槽里升起;
+// 换页是色带擦除,新页面露出来的那一帧=at(擦除在 at 之前 0.3s 开始)。
+// cues:title | point(一页:text 主词(太长自动缩字号、最多两行),sub 辅句,data.label 左上小标签如「01」)
+// number(一页大数字:data {value, prefix, suffix, decimals},at = 数字落定的时刻,页面提前 0.7s 出现开始滚)
+// highlight(当前页里 data.word 这个词刷荧光笔+放大一下;不给 word 就刷整个主词)
+// sub 里的关键词:data.key 写辅句里的一个词,那个词用强调色(示范片「下一行」那样)
+// number 的说明写 text 或 sub 都行(clip.js 已统一);data.label 照样有
+// 两个以上的 point 页 = 一份清单:画进度轨(01/02/03,告诉观众第几个、一共几个;横屏右上、竖屏在下方)和背景巨型序号(低对比、斜向慢漂,data.num 可指定)。
+// data.palette = [[底色, 字色], ...] 换配色。alpha 模式不画底,字白色带深色描边。safe:主词块在 top..H−bottom 之间居中,进度轨也在这一带里。
+CLIPS.y5_kinetic_type = (() => {
+const { clamp, lerp } = U;
+const PAL = [['#FFD23F', '#111111'], ['#FF5A36', '#FFFFFF'], ['#14213D', '#FFD23F'], ['#F4EFE6', '#111111']];
+let pages, LIST;
+const accentOf = col => col[0] === '#FFD23F' || col[0] === '#F4EFE6' || col[1] === '#FFD23F' ? '#FF5A36' : '#FFD23F'; // 字本身是黄的(深蓝页)就用橙,不然着色看不出来
+return {
+ fonts: ['PuHui-Black', 'PuHui-Heavy', 'PuHui-Bold'],
+ safe: true,
+ init(ctx) {
+ const { W, u } = ctx, pal = ctx.data.palette || PAL, g = document.createElement('canvas').getContext('2d');
+ pages = ctx.of('title', 'point', 'number').map((q, i) => {
+ const num = q.kind === 'number', nd = q.data || {};
+ const text = num ? (nd.prefix || '') + TY.fmt(nd.value || 0, nd.decimals ?? 0) + (nd.suffix || '') : (q.text || '');
+ const S0 = (ctx.portrait ? 250 : 300) * u;
+ let f = TY.fit(g, text, W * 0.86, S0, 'PuHui-Black', { maxLines: 1, min: 0.55, soft: true }); // 先缩字号放一行,再不行折两行;单个长英文词再缩也要放得下
+ if (!f.ok) f = num ? TY.fit(g, text, W * 0.86, S0, 'PuHui-Black', { maxLines: 1 }) // 数字不折行(滚动时逐字变宽,折开会跳):只缩字号
+ : TY.fit(g, text, W * 0.86, S0, 'PuHui-Black', { maxLines: 2, min: 0.3, balance: true });
+ const sf = q.sub ? TY.fit(g, q.sub, W * 0.86, (ctx.portrait ? 64 : 80) * u, 'PuHui-Heavy', { maxLines: 2, min: 0.6, balance: true }) : null; // 辅句:放不下先缩、再折两行
+ const show = num ? q.at - 0.7 : q.at;
+ return { q, i, num, nd, text, f, sf, show, col: pal[i % pal.length] };
+ });
+ const pts = pages.filter(p => p.q.kind === 'point'); pts.forEach((p, k) => { p.ord = k + 1; });
+ LIST = pts.length >= 2 ? pts : null;
+ // 高亮的词不在页上:只告警(以前什么都不发生)
+ for (const h of ctx.of('highlight')) { const w = h.data && h.data.word; if (!w) continue; const pg = [...pages].reverse().find(p => p.show <= h.at + 1e-6);
+ if (pg && !pg.f.lines.some(l => l.includes(w))) console.warn(`y5 highlight at=${h.at}:主词里没有「${w}」(主词「${pg.text}」;荧光笔只刷主词,辅句里的词用 data.key 着色),这一下什么都不做`); }
+ },
+ draw(c, t, ctx) {
+ const { W, H, u } = ctx;
+ let k = -1; pages.forEach((p, i) => { if (t >= p.show - 1e-6) k = i; });
+ const P = pages[Math.max(0, k)]; if (!P) return;
+ const page = (p, c2) => drawPage(c2, p, t, ctx);
+ // 底+点阵
+ if (!ctx.alpha) { c.fillStyle = P.col[0]; c.fillRect(0, 0, W, H); dots(c, t, P.col[1], 0.07, u, W, H); }
+ if (k >= 0) {
+ // 拍点微冲:每个 cue 落下时整屏放大 1.5%,0.15s 衰减
+ let bump = 1; for (const q of ctx.cues) { const l = t - q.at; if (l >= 0 && l < 0.4) bump += 0.015 * Math.exp(-l * 22); }
+ const [dx, dy] = CAM.drift(t, 5 * u, 2);
+ CAM.with(c, { x: W / 2 + dx, y: H / 2 + dy, z: bump, r: 0.008 * Math.sin(t * 0.8) }, cc => { ghost(cc, P, t, ctx); page(P, cc); });
+ track(c, P, t, ctx);
+ }
+ // 换页:两条色带从左扫到右,最后一条后面露出新页(露出那一帧=新页的 show 时刻)
+ const N = pages[k + 1];
+ if (N && !ctx.alpha) {
+ const p = (t - (N.show - 0.3)) / 0.36; if (p > 0 && p < 1) {
+ const mid = ['#FFD23F', '#FF5A36', '#14213D', '#3A86FF'].find(x => x !== P.col[0] && x !== N.col[0]), cols = [mid, N.col[0]], sk = H * 0.35; // 两条:一条和前后底色都不同的强调色+新底色(以前第一条是字色,白字页前会整屏闪一帧白)
+ const edge = q => lerp(-sk - 40, W + sk + 40, MO.expoInOut(clamp(q)));
+ cols.forEach((col, i) => { const x = edge((p - i * 0.12) / 0.76); c.save(); c.beginPath(); c.moveTo(-sk - 60, 0); c.lineTo(x + sk, 0); c.lineTo(x, H); c.lineTo(-sk - 60, H); c.closePath(); c.clip(); c.fillStyle = col; c.fillRect(0, 0, W, H); c.restore(); });
+ }
+ }
+ },
+};
+function dots(c, t, col, a, u, W, H) { const g = 64 * u, ox = (t * 36 * u) % g, oy = (t * 18 * u) % g; c.save(); c.globalAlpha = a; c.fillStyle = col; for (let y = -g; y < H + g; y += g) for (let x = -g; x < W + g; x += g) { c.beginPath(); c.arc(x + ox, y + oy, 4 * u, 0, Math.PI * 2); c.fill(); } c.restore(); }
+function drawPage(c, P, t, ctx) {
+ const { W, H, u } = ctx, q = P.q, fg = ctx.alpha ? '#FFFFFF' : P.col[1], lt = ctx.lt(t, P.num ? P.show : q.at);
+ const stroke = ctx.alpha ? { stroke: '#111', strokeW: P.f.size * 0.06 } : {};
+ const lines = P.num ? [P.text] : P.f.lines, size = P.f.size, lh = size * 1.08;
+ const sub = q.sub, subSz = P.sf ? P.sf.size : 0, subL = P.sf ? P.sf.lines : [];
+ const by0 = ctx.safe.top, by1 = H - ctx.safe.bottom - (ctx.portrait && LIST ? 220 * u : 0), cyB = ctx.portrait ? by0 + (by1 - by0) * 0.44 : (by0 + by1) / 2;
+ const blockH = lines.length * lh + (sub ? subSz * (0.6 + subL.length * 1.15) : 0), y0 = cyB - blockH / 2 + size * 0.82;
+ // 标签(左上)
+ const label = q.data && q.data.label;
+ if (label) TY.rise(c, label, (ctx.portrait ? 80 : 140) * u, ctx.safe.top + (ctx.portrait ? 260 : 210) * u, MO.at(lt, 0, 0.3), { size: (ctx.portrait ? 56 : 52) * u, fam: 'PuHui-Bold', color: fg, track: 6 * u, ...(ctx.alpha ? { stroke: '#111', strokeW: 6 * u } : {}) });
+ // 高亮(画在字后面)
+ const hq = ctx.of('highlight').filter(h => h.at >= (P.num ? P.show : q.at) - 1e-6).find(h => { const nx = ctx.of('title', 'point', 'number').find(z => z.at > q.at); return !nx || h.at < nx.at; });
+ let hiScale = 1, knock = null;
+ if (hq) {
+ const hl = ctx.lt(t, hq.at), wd = hq.data && hq.data.word, found = !wd || lines.some(l => l.includes(wd));
+ hiScale = hl > 0 && found ? 1 + 0.06 * MO.settle(hl, 1, 2.5, 6) : 1; // 词不在主词里:不刷也不放大(init 里已告警)
+ if (hl > 0) lines.forEach((ln, i) => {
+ const word = wd || ln, at = ln.indexOf(word); if (at < 0) return;
+ const wPre = TY.width(c, ln.slice(0, at), size), wW = TY.width(c, word, size), wl = TY.width(c, ln, size), x = W / 2 - wl / 2 + wPre, y = y0 + i * lh;
+ const mc = ctx.alpha ? '#FF5A36' : (P.col[0] === '#FFD23F' ? '#FF5A36' : '#FFD23F'), mr = [x - 12 * u, y - size * 0.86, wW + 24 * u, size * 1.0, MO.at(hl, 0, 0.3)];
+ TY.marker(c, ...mr, mc);
+ if (mc.toLowerCase() === fg.toLowerCase()) (knock = knock || []).push({ i, mr }); // 荧光笔和字同色(深蓝页黄字):笔下面的字反白成底色,不然整个词被涂没
+ });
+ }
+ // 主词:每行在 at(+0.08s/行)砸进来;数字页从 0 滚到落定
+ lines.forEach((ln, i) => {
+ let s = ln; if (P.num) { const k = MO.expoOut(clamp(lt / 0.7)); s = (P.nd.prefix || '') + TY.fmt((P.nd.value || 0) * k, P.nd.decimals ?? 0) + (P.nd.suffix || ''); }
+ const w = TY.width(c, s, size), x = W / 2 - w / 2, y = y0 + i * lh;
+ TY.slam(c, s, x, y, lt - i * 0.08, { size, color: fg, scale: hiScale, ox: W / 2, oy: y - size * 0.36, ...stroke });
+ for (const k of (knock || []).filter(k => k.i === i)) { // 只在荧光笔那块平行四边形里,用底色再砸一遍同一行(和 TY.marker 同一形状)
+ const [mx, my, mw, mh, mp] = k.mr, ww = mw * MO.expoOut(clamp(mp)), sk = mh * 0.18;
+ c.save(); c.beginPath(); c.moveTo(mx + sk, my); c.lineTo(mx + ww + sk, my); c.lineTo(mx + ww, my + mh); c.lineTo(mx, my + mh); c.closePath(); c.clip();
+ TY.slam(c, s, x, y, lt - i * 0.08, { size, color: P.col[0], scale: hiScale, ox: W / 2, oy: y - size * 0.36 }); c.restore();
+ }
+ });
+ if (sub) subL.forEach((ln, k) => { // 辅句(可两行);data.key 那个词用强调色
+ const sw = TY.width(c, ln, subSz, 'PuHui-Heavy'), sy = y0 + (lines.length - 1) * lh + subSz * (1.7 + k * 1.15), sp = MO.at(lt, 0.35 + k * 0.08, 0.35), so = { size: subSz, fam: 'PuHui-Heavy', color: fg, ...(ctx.alpha ? { stroke: '#111', strokeW: subSz * 0.08 } : {}) };
+ const key = q.data && q.data.key, ki = key ? ln.indexOf(key) : -1, x0 = W / 2 - sw / 2;
+ if (ki < 0) return TY.rise(c, ln, x0, sy, sp, so);
+ const pre = ln.slice(0, ki), post = ln.slice(ki + key.length), wp = TY.width(c, pre, subSz, 'PuHui-Heavy'), wk = TY.width(c, key, subSz, 'PuHui-Heavy');
+ if (pre) TY.rise(c, pre, x0, sy, sp, so); TY.rise(c, key, x0 + wp, sy, sp, { ...so, color: ctx.alpha ? '#FFD23F' : accentOf(P.col) }); if (post) TY.rise(c, post, x0 + wp + wk, sy, sp, so);
+ });
+}
+// 背景巨型序号:清单页右下角(竖屏落在下半屏),低对比、弹簧落位后斜向慢漂;不和主词抢(字色 12% 透明度)
+function ghost(c, P, t, ctx) {
+ if (!LIST || !P.ord || ctx.alpha) return;
+ const { W, H, u } = ctx, lt = t - P.show, k = MO.springHz(lt, 2.0, 8), sc = lerp(1.35, 1, k), s = String((P.q.data && P.q.data.num) ?? P.ord);
+ const size = (ctx.portrait ? 1000 : 900) * u, x = W - (ctx.portrait ? 40 : 60) * u + lt * 14 * u, y = H - ctx.safe.bottom + (ctx.portrait ? -120 : 70) * u - lt * 10 * u;
+ TY.text(c, s, x, y, { size, fam: 'PuHui-Black', align: 'right', color: P.col[1], alpha: 0.12 * clamp(lt / 0.08), scale: sc, ox: x - size * 0.28, oy: y - size * 0.36 });
+}
+// 进度轨:01/02/03 三格(几个 point 页就几格),当前页那一格在换页露出那一帧点亮;画在相机外,不跟页面晃
+function track(c, P, t, ctx) {
+ if (!LIST) return;
+ const { W, H, u } = ctx, n = LIST.length, k = LIST.filter(p => p.show <= t + 1e-6).length; if (k === 0) return;
+ const fg = ctx.alpha ? '#FFFFFF' : P.col[1], gap = 18 * u, seg = Math.min((ctx.portrait ? 150 : 110) * u, ((ctx.portrait ? W * 0.86 : W * 0.4) - (n - 1) * gap) / n), tot = n * seg + (n - 1) * gap; // 要点多时每格变窄,不出画
+ const x0 = ctx.portrait ? (W - tot) / 2 : W - (ctx.portrait ? 80 : 140) * u - tot, y = ctx.portrait ? H - ctx.safe.bottom - 130 * u : ctx.safe.top + 120 * u;
+ const a = MO.expoOut(clamp((t - LIST[0].show) / 0.3));
+ c.save(); c.globalAlpha = a;
+ for (let i = 0; i < n; i++) { const x = x0 + i * (seg + gap), on = i < k, fill = on ? MO.expoOut(clamp((t - LIST[i].show) / 0.3)) : 0;
+ c.fillStyle = fg; c.globalAlpha = a * 0.25; c.fillRect(x, y, seg, 10 * u); c.globalAlpha = a; c.fillRect(x, y, seg * fill, 10 * u);
+ TY.text(c, String(i + 1).padStart(2, '0'), x, y - 20 * u, { size: (ctx.portrait ? 40 : 32) * u, fam: 'PuHui-Bold', color: fg, align: 'left', alpha: on ? 1 : 0.4, track: 2 * u, ...(ctx.alpha ? { stroke: '#111', strokeW: 5 * u } : {}) }); }
+ c.restore();
+}
+})();
diff --git a/scripts/engine/compare.py b/scripts/engine/compare.py
new file mode 100644
index 0000000..13c27ea
--- /dev/null
+++ b/scripts/engine/compare.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python3
+"""原片 vs 复刻 逐帧并排:给一组时刻,各抽一帧,左原片右复刻,拼成一张图。
+python3 compare.py --a 原片.mp4 --b 复刻.mp4 --times 1.5,1.6 --out 对比.jpg [--w 640]"""
+import argparse, subprocess, io
+from PIL import Image, ImageDraw
+ap = argparse.ArgumentParser(); ap.add_argument('--a'); ap.add_argument('--b'); ap.add_argument('--times'); ap.add_argument('--out'); ap.add_argument('--w', type=int, default=640); ap.add_argument('--cols', type=int, default=2)
+a = ap.parse_args()
+def grab(v, t):
+ png = subprocess.run(['ffmpeg', '-v', 'error', '-ss', str(t), '-i', v, '-frames:v', '1', '-f', 'image2pipe', '-c:v', 'png', '-'], capture_output=True).stdout
+ return Image.open(io.BytesIO(png)).convert('RGB').resize((a.w, a.w * 9 // 16))
+ts = [float(x) for x in a.times.split(',')]
+w, h = a.w, a.w * 9 // 16
+cols = a.cols; rows = (len(ts) + cols - 1) // cols
+S = Image.new('RGB', (cols * 2 * w + (cols - 1) * 12, rows * (h + 18)), 'white'); d = ImageDraw.Draw(S)
+for i, t in enumerate(ts):
+ x = (i % cols) * (2 * w + 12); y = (i // cols) * (h + 18)
+ S.paste(grab(a.a, t), (x, y + 18)); S.paste(grab(a.b, t), (x + w, y + 18))
+ d.text((x + 3, y + 3), f'{t:.3f}s 原片 | 复刻', fill='black')
+S.save(a.out, quality=85); print(a.out)
diff --git a/scripts/engine/demos/_shared/hero.js b/scripts/engine/demos/_shared/hero.js
new file mode 100644
index 0000000..80ee192
--- /dev/null
+++ b/scripts/engine/demos/_shared/hero.js
@@ -0,0 +1,96 @@
+// y1/y2/y3 三支示范片里的花叔形象。window.HERO_MODE = 'C'(默认)| 'A' | 'rig'。
+// C 各片原生(示范片采用):每种风格单独用 gpt-image 生一版设定图(Kurzgesagt 扁平无描边 / Vox 复用 Kurzgesagt 那张转灰度当剪报贴纸 /
+// 白板马克笔线稿),放在 demos/_shared/hero/。这是「纯代码绘制」主线的明确例外——角色是贴图,画面其余全是代码。
+// A 极简几何:纯代码画的 Q 版(大圆头+白渔夫帽+圆眼镜),每片按该片画法上色/描线。不想用贴图时切到它。
+// rig 旧骨架:lib/rig_huashu.js 的 FK 角色(各片里的回退分支)。
+// (实验时还有方向 B「G2 绘本帧库」,需要 24 张帧图,没收进 skill。)
+(() => {
+const { clamp, lerp } = U;
+const H = window.HERO = {};
+const MODE = () => window.HERO_MODE || 'C';
+H.mode = MODE;
+const PNG = n => `demos/_shared/hero/${n}.png`;
+window.EXTRA_ASSETS = (window.EXTRA_ASSETS || []).concat(['c1_0', 'c1_1', 'c1_2', 'c3_line'].map(PNG));
+const img = p => window.IMG[p];
+
+// 把一张图按「脚底中心」放到 (x, y),高 h;face=-1 水平翻转
+const place = (c, im, x, y, h, face = 1, anchorY = 0.97) => {
+ const w = im.width * h / im.height; c.save(); c.translate(x, y); if (face < 0) c.scale(-1, 1); c.drawImage(im, -w / 2, -h * anchorY, w, h); c.restore();
+};
+
+// ---------- A:极简几何 Q 版 ----------
+// 原点 = 两脚之间地面;单位高 1 ≈ 全身高;opt.style: 'flat'(无描边,同色深一档做阴影)| 'line'(白底黑线)| 'print'(平涂+细黑线)
+H.geo = (c, x, y, h, { face = 1, t = 0, style = 'flat', point = true, ink = '#1d1b19' } = {}) => {
+ const s = h / 100; c.save(); c.translate(x, y); c.scale(face * s, s);
+ const bob = Math.sin(t * 6.5) * 0.8;
+ const line = style !== 'flat', lw = style === 'line' ? 2.2 : 1.4;
+ const P = { skin: '#ffd8bd', skinSh: '#f2b493', hat: '#ffffff', hatSh: '#dfe3ef', tee: '#ffffff', teeSh: '#e3e6f0', shorts: '#d8c7a6', shortsSh: '#bfa982', shoe: '#ffffff', hair: '#1f1b2e', glass: '#1f1b2e', cheek: 'rgba(255,128,120,.45)' };
+ if (style === 'line') Object.assign(P, { skin: '#fbfbf8', skinSh: '#fbfbf8', hatSh: '#fbfbf8', tee: '#fbfbf8', teeSh: '#fbfbf8', shorts: '#fbfbf8', shortsSh: '#fbfbf8', cheek: 'rgba(239,114,38,.35)' });
+ // 扁平分面:先铺深一档,再把本色往左上挪 2.5 单位盖回去,右下留一条阴影带(和 Y1 的 flat 同一招)
+ const shape = (path, fill, sh) => { if (sh && sh !== fill) { c.save(); c.clip(path); c.fillStyle = sh; c.fill(path); c.translate(-2.5, -2); c.fillStyle = fill; c.fill(path); c.restore(); } else { c.fillStyle = fill; c.fill(path); } if (line) { c.strokeStyle = ink; c.lineWidth = lw; c.stroke(path); } };
+ const rr = (x0, y0, w, hh, r) => { const p = new Path2D(); p.roundRect(x0, y0, w, hh, r); return p; };
+ const el = (cx, cy, rx, ry) => { const p = new Path2D(); p.ellipse(cx, cy, rx, ry, 0, 0, Math.PI * 2); return p; };
+ c.lineJoin = 'round'; c.lineCap = 'round';
+ // 腿+洞洞鞋
+ for (const lx of [-7, 7]) { shape(rr(lx - 3, -14, 6, 12, 3), P.skin, P.skinSh); shape(el(lx + 2.5, -2, 7.5, 4), P.shoe, P.hatSh); }
+ c.fillStyle = ink; for (const lx of [-7, 7]) for (const [dx, dy] of [[-1, -3], [2, -3.5], [5, -2.5]]) { c.beginPath(); c.arc(lx + 2.5 + dx, -2 + dy + 1, 0.8, 0, 7); c.fill(); }
+ c.translate(0, bob);
+ shape(rr(-12, -26, 24, 13, 4), P.shorts, P.shortsSh); // 短裤
+ // 远侧手臂(自然下垂,手表)
+ shape(rr(-15, -42, 6, 16, 3), P.skin, P.skinSh); c.fillStyle = ink; c.fillRect(-15.5, -30, 7, 3);
+ shape(rr(-14, -46, 28, 22, 7), P.tee, P.teeSh); // T 恤
+ // 近侧手臂:指向前方(point)或下垂
+ if (point) { c.save(); c.translate(10, -42); c.rotate(-1.35 + Math.sin(t * 3.4) * 0.06); shape(rr(-3.2, 0, 6.4, 20, 3.2), P.skin, P.skinSh); shape(el(0, 21, 3.6, 3.6), P.skin); c.restore(); }
+ else shape(rr(9, -42, 6, 16, 3), P.skin, P.skinSh);
+ // 头:正面大圆脸(头身比约 1:1.2)。正面比侧面好画、也更好认:帽檐下一圈刘海、两只耳朵、圆眼镜居中
+ c.translate(0, -66); c.rotate(Math.sin(t * 2.1) * 0.03);
+ for (const ex of [-19, 19]) shape(el(ex, 4, 3.6, 4.6), P.skin, P.skinSh); // 耳
+ shape(el(0, 2, 19, 18.5), P.skin, P.skinSh); // 脸
+ const crown = new Path2D(); crown.moveTo(-17, -9); crown.bezierCurveTo(-17, -33, 17, -33, 17, -9); crown.closePath();
+ const brim = new Path2D(); brim.ellipse(0, -9, 29, 7, 0, 0, Math.PI * 2);
+ shape(brim, P.hat, P.hatSh); shape(crown, P.hat, P.hatSh);
+ // 刘海+鬓角:画在帽檐之后,从帽檐下沿露出一排黑发(光头感就是少了这一排)
+ c.fillStyle = P.hair; c.beginPath(); c.moveTo(-19.5, -4); c.lineTo(19.5, -4); c.lineTo(19, 5); c.lineTo(16.5, 1); c.lineTo(13, -0.5); c.lineTo(9, 1.5); c.lineTo(5, -1); c.lineTo(0, 1); c.lineTo(-5, -1.5); c.lineTo(-9, 1); c.lineTo(-13, -1); c.lineTo(-16.5, 1.5); c.lineTo(-19, 5); c.closePath(); c.fill();
+ shape(brim, P.hat, P.hatSh);
+ if (!line) { c.fillStyle = P.hatSh; c.beginPath(); c.ellipse(0, -9.5, 17, 2.2, 0, 0, Math.PI * 2); c.fill(); } // 帽身与帽檐交界的一道暗线(色块,不是描边)
+ // 圆眼镜+眼睛(眨眼 0.12s/3.2s)
+ const blink = (t % 3.2) > 3.08;
+ c.strokeStyle = P.glass; c.lineWidth = 1.8; for (const ex of [-7.5, 7.5]) { c.beginPath(); c.arc(ex, 3, 6, 0, 7); c.stroke(); }
+ c.beginPath(); c.moveTo(-1.5, 3); c.lineTo(1.5, 3); c.stroke();
+ c.fillStyle = P.glass; for (const ex of [-7.5, 7.5]) { if (blink) c.fillRect(ex - 2.2, 3, 4.4, 1.1); else { c.beginPath(); c.ellipse(ex, 3.4, 1.8, 2.3, 0, 0, 7); c.fill(); } }
+ c.fillStyle = P.cheek; for (const ex of [-11, 11]) { c.beginPath(); c.ellipse(ex, 10.5, 3.2, 1.9, 0, 0, 7); c.fill(); }
+ const m = 0.4 + 0.6 * Math.max(0, Math.sin(t * 9)); // 嘴:说话时开合
+ c.fillStyle = '#c4473f'; c.beginPath(); c.ellipse(0, 12.5, 2.8, 0.9 + 1.7 * m, 0, 0, 7); c.fill();
+ c.restore();
+};
+
+// ---------- 每片的接入点 ----------
+// Y1 镜 3:花叔站在草坡左侧指向黑猫(脚底 (470,900),全身约 440px)
+H.y1 = (g, ft, flatFn) => {
+ const m = MODE();
+ if (m === 'A') return H.geo(g, 470, 900, 440, { face: 1, t: ft, style: 'flat' });
+ if (m === 'C') {
+ // 一张设定稿里的三个姿势当三个关键帧:拉出时挥手 → 扫描时指向黑猫 → 标签弹出后举手欢呼。
+ // 换姿势那一下给 0.12s 的挤压回弹(Kurzgesagt 弹出的 108% 过冲),站着时以脚底为轴呼吸。
+ const l = ft - Y1.SHOTS.s3[0], k = l < 1.25 ? 1 : l < 2.3 ? 0 : 2, t0 = [0, 1.25, 2.3][[1, 0, 2].indexOf(k)];
+ const pop = l - t0 < 0.14 && t0 > 0 ? 1 + 0.06 * Math.sin((l - t0) / 0.14 * Math.PI) : 1;
+ const br = 1 + 0.012 * Math.sin(ft * 5.2);
+ g.save(); g.translate(470, 905); g.scale(1 / Math.sqrt(br * pop), br * pop); place(g, img(PNG('c1_' + k)), 0, 0, 450, 1); g.restore(); return;
+ }
+ return false;
+};
+// Y2 镜 3:剪纸贴纸,画进 sp(之后统一垫白边、阴影),脚底 (1500,1040),面朝左
+H.y2 = (g, st) => {
+ const m = MODE();
+ if (m === 'A') return H.geo(g, 1500, 1040, 560, { face: -1, t: st, style: 'print', ink: '#171716' }), true;
+ if (m === 'C') { const k = Math.floor(st * 12); g.save(); g.translate(1500, 1015); g.rotate(((k * 7919) % 13 - 6) * 0.0012); g.filter = 'grayscale(1) contrast(1.25) brightness(1.04)'; place(g, img(PNG('c1_0')), 20, 8, 520, -1); g.restore(); return true; } // 卡通帧转灰度当剪报贴纸:按 12fps 微抖(定格感)
+ return false;
+};
+// Y3 镜 3:被之字形笔触揭开的那张画(世界坐标,脚底 (fx, fy),高 hh)
+H.y3 = (g, fx, fy, hh, ft) => {
+ const m = MODE();
+ if (m === 'A') return H.geo(g, fx, fy, hh, { face: 1, t: ft, style: 'line', ink: '#0A0503' }), true;
+ if (m === 'C') { g.save(); g.globalCompositeOperation = 'multiply'; place(g, img(PNG('c3_line')), fx, fy + 4, hh * 1.08, 1); g.restore(); return true; }
+ return false;
+};
+})();
diff --git a/scripts/engine/demos/_shared/hero/c1_0.png b/scripts/engine/demos/_shared/hero/c1_0.png
new file mode 100644
index 0000000..47c6230
Binary files /dev/null and b/scripts/engine/demos/_shared/hero/c1_0.png differ
diff --git a/scripts/engine/demos/_shared/hero/c1_1.png b/scripts/engine/demos/_shared/hero/c1_1.png
new file mode 100644
index 0000000..86ec86c
Binary files /dev/null and b/scripts/engine/demos/_shared/hero/c1_1.png differ
diff --git a/scripts/engine/demos/_shared/hero/c1_2.png b/scripts/engine/demos/_shared/hero/c1_2.png
new file mode 100644
index 0000000..a576008
Binary files /dev/null and b/scripts/engine/demos/_shared/hero/c1_2.png differ
diff --git a/scripts/engine/demos/_shared/hero/c3_line.png b/scripts/engine/demos/_shared/hero/c3_line.png
new file mode 100644
index 0000000..45ae503
Binary files /dev/null and b/scripts/engine/demos/_shared/hero/c3_line.png differ
diff --git a/scripts/engine/demos/long_scroll/eras.js b/scripts/engine/demos/long_scroll/eras.js
new file mode 100644
index 0000000..6c4b39a
--- /dev/null
+++ b/scripts/engine/demos/long_scroll/eras.js
@@ -0,0 +1,23 @@
+// 示范 · 长卷穿越片:一条横向长画卷,几个「世界段」首尾相接,主角从左走到右,跨过边界时画风跟着换。
+// 这里只收了 3 段(埃及壁画 → 莫奈《日本桥》→ 8-bit 像素),完整片子是 24 段,做法见 references/11-长卷穿越片.md。
+// 预览 index.html?film=demos/long_scroll 渲染 render.py --film demos/long_scroll --out long_scroll.mp4
+// 骨架 lib/world.js 管时间轴、主角行进、只进不退的相机、按边界裁开的主角、角标;每段一个文件 segments/<id>.js,调用 WORLD.add({...})。
+(() => {
+ window.__bootErrors = window.__bootErrors || [];
+ const base = 'demos/long_scroll/';
+ const load = url => { const x = new XMLHttpRequest(); x.open('GET', url, false); x.send(); if (x.status !== 200) { __bootErrors.push(`${url} 不存在 (HTTP ${x.status})`); return; }
+ try { (0, eval)(x.responseText + `\n//# sourceURL=${url}`); } catch (e) { __bootErrors.push(`${url} 执行出错 ${e && e.stack || e}`); } };
+ load(base + 'lib/crossing.js'); // XING:角色帧库、笔触材质、莫奈世界
+ load(base + 'lib/acts.js'); // ACT:打水漂的石子轨迹等小剧本工具
+ load(base + 'lib/world.js'); // WORLD:长卷骨架
+ // 片子顺序:改顺序、加段只改这里(加段 = 往 segments/ 放一个文件,再把 id 写进来)
+ window.FILM_ORDER = ['02_egypt', '28_monet', '14_8bit'];
+ for (const id of window.FILM_ORDER) { const n = WORLD.segs.length; load(`${base}segments/${id}.js`);
+ if (WORLD.segs.length === n || WORLD.segs[WORLD.segs.length - 1].id !== id) __bootErrors.push(`segments/${id}.js 没有 WORLD.add({ id: '${id}', ... })`); }
+ // 每段用到的帧库(hero.walk、acts[].key、sprites)一次性登记成资源,引擎启动前全部加载
+ const sprites = new Set(); WORLD.segs.forEach(s => { if (s.hero && s.hero.walk) sprites.add(s.hero.walk); (s.acts || []).forEach(a => a.key && sprites.add(a.key)); (s.sprites || []).forEach(k => sprites.add(k)); });
+ try { window.EXTRA_ASSETS = (window.EXTRA_ASSETS || []).concat(XING.sprites([...sprites])); } catch (e) { __bootErrors.push('帧库缺失:' + e.message); }
+ WORLD.layout();
+ window.PUNCH = 0;
+ window.ERAS = [{ id: 'film', dur: WORLD.total, draw: (c, lt, t) => WORLD.draw(c, t) }];
+})();
diff --git a/scripts/engine/demos/long_scroll/frames/8bit_act/01.png b/scripts/engine/demos/long_scroll/frames/8bit_act/01.png
new file mode 100644
index 0000000..3ffb186
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/8bit_act/01.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/8bit_act/02.png b/scripts/engine/demos/long_scroll/frames/8bit_act/02.png
new file mode 100644
index 0000000..f4fc4d8
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/8bit_act/02.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/8bit_act/03.png b/scripts/engine/demos/long_scroll/frames/8bit_act/03.png
new file mode 100644
index 0000000..b7e5959
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/8bit_act/03.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/8bit_act/04.png b/scripts/engine/demos/long_scroll/frames/8bit_act/04.png
new file mode 100644
index 0000000..9ff1e99
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/8bit_act/04.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/8bit_act/05.png b/scripts/engine/demos/long_scroll/frames/8bit_act/05.png
new file mode 100644
index 0000000..f12d09d
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/8bit_act/05.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/8bit_act/06.png b/scripts/engine/demos/long_scroll/frames/8bit_act/06.png
new file mode 100644
index 0000000..cb8c307
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/8bit_act/06.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/8bit_act/07.png b/scripts/engine/demos/long_scroll/frames/8bit_act/07.png
new file mode 100644
index 0000000..800875a
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/8bit_act/07.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/8bit_act/08.png b/scripts/engine/demos/long_scroll/frames/8bit_act/08.png
new file mode 100644
index 0000000..b33ac72
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/8bit_act/08.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/8bit_act/meta.json b/scripts/engine/demos/long_scroll/frames/8bit_act/meta.json
new file mode 100644
index 0000000..af6de69
--- /dev/null
+++ b/scripts/engine/demos/long_scroll/frames/8bit_act/meta.json
@@ -0,0 +1,69 @@
+{
+ "frames": [
+ {
+ "file": "01.png",
+ "ax": 120.0,
+ "ay": 374.0,
+ "w": 239,
+ "h": 375,
+ "air": 0
+ },
+ {
+ "file": "02.png",
+ "ax": 118.5,
+ "ay": 323.0,
+ "w": 239,
+ "h": 324,
+ "air": 0
+ },
+ {
+ "file": "03.png",
+ "ax": 116.5,
+ "ay": 396.0,
+ "w": 255,
+ "h": 367,
+ "air": 30
+ },
+ {
+ "file": "04.png",
+ "ax": 127.0,
+ "ay": 420.0,
+ "w": 246,
+ "h": 372,
+ "air": 49
+ },
+ {
+ "file": "05.png",
+ "ax": 136.0,
+ "ay": 395.0,
+ "w": 257,
+ "h": 381,
+ "air": 15
+ },
+ {
+ "file": "06.png",
+ "ax": 125.0,
+ "ay": 316.0,
+ "w": 247,
+ "h": 317,
+ "air": 0
+ },
+ {
+ "file": "07.png",
+ "ax": 106.5,
+ "ay": 369.0,
+ "w": 214,
+ "h": 370,
+ "air": 0
+ },
+ {
+ "file": "08.png",
+ "ax": 128.5,
+ "ay": 397.0,
+ "w": 267,
+ "h": 373,
+ "air": 25
+ }
+ ],
+ "ref_h": 371.0
+}
\ No newline at end of file
diff --git a/scripts/engine/demos/long_scroll/frames/8bit_walk/01.png b/scripts/engine/demos/long_scroll/frames/8bit_walk/01.png
new file mode 100644
index 0000000..82a071c
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/8bit_walk/01.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/8bit_walk/02.png b/scripts/engine/demos/long_scroll/frames/8bit_walk/02.png
new file mode 100644
index 0000000..31a9806
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/8bit_walk/02.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/8bit_walk/03.png b/scripts/engine/demos/long_scroll/frames/8bit_walk/03.png
new file mode 100644
index 0000000..73c02cf
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/8bit_walk/03.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/8bit_walk/04.png b/scripts/engine/demos/long_scroll/frames/8bit_walk/04.png
new file mode 100644
index 0000000..395e407
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/8bit_walk/04.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/8bit_walk/05.png b/scripts/engine/demos/long_scroll/frames/8bit_walk/05.png
new file mode 100644
index 0000000..e60019f
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/8bit_walk/05.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/8bit_walk/06.png b/scripts/engine/demos/long_scroll/frames/8bit_walk/06.png
new file mode 100644
index 0000000..99a872e
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/8bit_walk/06.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/8bit_walk/07.png b/scripts/engine/demos/long_scroll/frames/8bit_walk/07.png
new file mode 100644
index 0000000..e762a2e
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/8bit_walk/07.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/8bit_walk/08.png b/scripts/engine/demos/long_scroll/frames/8bit_walk/08.png
new file mode 100644
index 0000000..28d75bc
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/8bit_walk/08.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/8bit_walk/meta.json b/scripts/engine/demos/long_scroll/frames/8bit_walk/meta.json
new file mode 100644
index 0000000..2181be4
--- /dev/null
+++ b/scripts/engine/demos/long_scroll/frames/8bit_walk/meta.json
@@ -0,0 +1,69 @@
+{
+ "frames": [
+ {
+ "file": "01.png",
+ "ax": 134.0,
+ "ay": 387.0,
+ "w": 246,
+ "h": 388,
+ "air": 0
+ },
+ {
+ "file": "02.png",
+ "ax": 128.5,
+ "ay": 395.0,
+ "w": 245,
+ "h": 396,
+ "air": 0
+ },
+ {
+ "file": "03.png",
+ "ax": 128.5,
+ "ay": 393.0,
+ "w": 244,
+ "h": 394,
+ "air": 0
+ },
+ {
+ "file": "04.png",
+ "ax": 127.5,
+ "ay": 395.0,
+ "w": 242,
+ "h": 396,
+ "air": 0
+ },
+ {
+ "file": "05.png",
+ "ax": 134.0,
+ "ay": 395.0,
+ "w": 246,
+ "h": 396,
+ "air": 0
+ },
+ {
+ "file": "06.png",
+ "ax": 128.5,
+ "ay": 398.0,
+ "w": 245,
+ "h": 399,
+ "air": 0
+ },
+ {
+ "file": "07.png",
+ "ax": 132.5,
+ "ay": 397.0,
+ "w": 244,
+ "h": 398,
+ "air": 0
+ },
+ {
+ "file": "08.png",
+ "ax": 127.5,
+ "ay": 398.0,
+ "w": 242,
+ "h": 399,
+ "air": 0
+ }
+ ],
+ "ref_h": 396.0
+}
\ No newline at end of file
diff --git a/scripts/engine/demos/long_scroll/frames/egypt_dodge/01.png b/scripts/engine/demos/long_scroll/frames/egypt_dodge/01.png
new file mode 100644
index 0000000..3a03ebf
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/egypt_dodge/01.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/egypt_dodge/02.png b/scripts/engine/demos/long_scroll/frames/egypt_dodge/02.png
new file mode 100644
index 0000000..99def09
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/egypt_dodge/02.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/egypt_dodge/03.png b/scripts/engine/demos/long_scroll/frames/egypt_dodge/03.png
new file mode 100644
index 0000000..f1e7f51
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/egypt_dodge/03.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/egypt_dodge/04.png b/scripts/engine/demos/long_scroll/frames/egypt_dodge/04.png
new file mode 100644
index 0000000..d275318
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/egypt_dodge/04.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/egypt_dodge/05.png b/scripts/engine/demos/long_scroll/frames/egypt_dodge/05.png
new file mode 100644
index 0000000..93081fb
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/egypt_dodge/05.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/egypt_dodge/06.png b/scripts/engine/demos/long_scroll/frames/egypt_dodge/06.png
new file mode 100644
index 0000000..7e26cef
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/egypt_dodge/06.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/egypt_dodge/07.png b/scripts/engine/demos/long_scroll/frames/egypt_dodge/07.png
new file mode 100644
index 0000000..11ab597
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/egypt_dodge/07.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/egypt_dodge/08.png b/scripts/engine/demos/long_scroll/frames/egypt_dodge/08.png
new file mode 100644
index 0000000..90f53c0
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/egypt_dodge/08.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/egypt_dodge/meta.json b/scripts/engine/demos/long_scroll/frames/egypt_dodge/meta.json
new file mode 100644
index 0000000..464923c
--- /dev/null
+++ b/scripts/engine/demos/long_scroll/frames/egypt_dodge/meta.json
@@ -0,0 +1,69 @@
+{
+ "frames": [
+ {
+ "file": "01.png",
+ "ax": 111.0,
+ "ay": 424.0,
+ "w": 238,
+ "h": 425,
+ "air": 0
+ },
+ {
+ "file": "02.png",
+ "ax": 118.0,
+ "ay": 425.0,
+ "w": 237,
+ "h": 426,
+ "air": 0
+ },
+ {
+ "file": "03.png",
+ "ax": 157.5,
+ "ay": 378.0,
+ "w": 265,
+ "h": 379,
+ "air": 0
+ },
+ {
+ "file": "04.png",
+ "ax": 179.5,
+ "ay": 434.0,
+ "w": 341,
+ "h": 393,
+ "air": 42
+ },
+ {
+ "file": "05.png",
+ "ax": 176.5,
+ "ay": 435.0,
+ "w": 335,
+ "h": 368,
+ "air": 68
+ },
+ {
+ "file": "06.png",
+ "ax": 110.5,
+ "ay": 426.0,
+ "w": 216,
+ "h": 427,
+ "air": 0
+ },
+ {
+ "file": "07.png",
+ "ax": 106.0,
+ "ay": 413.0,
+ "w": 228,
+ "h": 414,
+ "air": 0
+ },
+ {
+ "file": "08.png",
+ "ax": 100.5,
+ "ay": 412.0,
+ "w": 219,
+ "h": 412,
+ "air": 1
+ }
+ ],
+ "ref_h": 413.0
+}
\ No newline at end of file
diff --git a/scripts/engine/demos/long_scroll/frames/egypt_walk8/01.png b/scripts/engine/demos/long_scroll/frames/egypt_walk8/01.png
new file mode 100644
index 0000000..029228e
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/egypt_walk8/01.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/egypt_walk8/02.png b/scripts/engine/demos/long_scroll/frames/egypt_walk8/02.png
new file mode 100644
index 0000000..9e3460e
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/egypt_walk8/02.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/egypt_walk8/03.png b/scripts/engine/demos/long_scroll/frames/egypt_walk8/03.png
new file mode 100644
index 0000000..06aaf99
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/egypt_walk8/03.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/egypt_walk8/04.png b/scripts/engine/demos/long_scroll/frames/egypt_walk8/04.png
new file mode 100644
index 0000000..008e226
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/egypt_walk8/04.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/egypt_walk8/05.png b/scripts/engine/demos/long_scroll/frames/egypt_walk8/05.png
new file mode 100644
index 0000000..f7cd5d9
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/egypt_walk8/05.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/egypt_walk8/06.png b/scripts/engine/demos/long_scroll/frames/egypt_walk8/06.png
new file mode 100644
index 0000000..5a78c8d
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/egypt_walk8/06.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/egypt_walk8/07.png b/scripts/engine/demos/long_scroll/frames/egypt_walk8/07.png
new file mode 100644
index 0000000..f565793
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/egypt_walk8/07.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/egypt_walk8/08.png b/scripts/engine/demos/long_scroll/frames/egypt_walk8/08.png
new file mode 100644
index 0000000..7924835
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/egypt_walk8/08.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/egypt_walk8/meta.json b/scripts/engine/demos/long_scroll/frames/egypt_walk8/meta.json
new file mode 100644
index 0000000..ec779b4
--- /dev/null
+++ b/scripts/engine/demos/long_scroll/frames/egypt_walk8/meta.json
@@ -0,0 +1,69 @@
+{
+ "frames": [
+ {
+ "file": "01.png",
+ "ax": 137.0,
+ "ay": 451.0,
+ "w": 263,
+ "h": 451,
+ "air": 1
+ },
+ {
+ "file": "02.png",
+ "ax": 112.5,
+ "ay": 442.0,
+ "w": 233,
+ "h": 442,
+ "air": 1
+ },
+ {
+ "file": "03.png",
+ "ax": 110.0,
+ "ay": 454.0,
+ "w": 203,
+ "h": 455,
+ "air": 0
+ },
+ {
+ "file": "04.png",
+ "ax": 134.5,
+ "ay": 449.0,
+ "w": 264,
+ "h": 450,
+ "air": 0
+ },
+ {
+ "file": "05.png",
+ "ax": 137.0,
+ "ay": 442.0,
+ "w": 269,
+ "h": 442,
+ "air": 1
+ },
+ {
+ "file": "06.png",
+ "ax": 129.0,
+ "ay": 442.0,
+ "w": 248,
+ "h": 442,
+ "air": 1
+ },
+ {
+ "file": "07.png",
+ "ax": 110.5,
+ "ay": 445.0,
+ "w": 210,
+ "h": 445,
+ "air": 1
+ },
+ {
+ "file": "08.png",
+ "ax": 133.5,
+ "ay": 442.0,
+ "w": 268,
+ "h": 443,
+ "air": 0
+ }
+ ],
+ "ref_h": 444.0
+}
\ No newline at end of file
diff --git a/scripts/engine/demos/long_scroll/frames/monet_throw/01.png b/scripts/engine/demos/long_scroll/frames/monet_throw/01.png
new file mode 100644
index 0000000..e8daefb
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/monet_throw/01.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/monet_throw/02.png b/scripts/engine/demos/long_scroll/frames/monet_throw/02.png
new file mode 100644
index 0000000..57e6f82
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/monet_throw/02.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/monet_throw/03.png b/scripts/engine/demos/long_scroll/frames/monet_throw/03.png
new file mode 100644
index 0000000..7a6fee6
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/monet_throw/03.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/monet_throw/04.png b/scripts/engine/demos/long_scroll/frames/monet_throw/04.png
new file mode 100644
index 0000000..d2462d6
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/monet_throw/04.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/monet_throw/05.png b/scripts/engine/demos/long_scroll/frames/monet_throw/05.png
new file mode 100644
index 0000000..fd7f6e5
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/monet_throw/05.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/monet_throw/06.png b/scripts/engine/demos/long_scroll/frames/monet_throw/06.png
new file mode 100644
index 0000000..17d345f
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/monet_throw/06.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/monet_throw/07.png b/scripts/engine/demos/long_scroll/frames/monet_throw/07.png
new file mode 100644
index 0000000..8eae301
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/monet_throw/07.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/monet_throw/08.png b/scripts/engine/demos/long_scroll/frames/monet_throw/08.png
new file mode 100644
index 0000000..4ae3344
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/monet_throw/08.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/monet_throw/meta.json b/scripts/engine/demos/long_scroll/frames/monet_throw/meta.json
new file mode 100644
index 0000000..311c664
--- /dev/null
+++ b/scripts/engine/demos/long_scroll/frames/monet_throw/meta.json
@@ -0,0 +1,71 @@
+{
+ "frames": [
+ {
+ "file": "01.png",
+ "ax": 145.0,
+ "ay": 431.0,
+ "w": 273,
+ "h": 432,
+ "air": 0
+ },
+ {
+ "file": "02.png",
+ "ax": 205.0,
+ "ay": 411.0,
+ "w": 338,
+ "h": 411,
+ "air": 1
+ },
+ {
+ "file": "03.png",
+ "ax": 144.5,
+ "ay": 424.0,
+ "w": 267,
+ "h": 424,
+ "air": 1
+ },
+ {
+ "file": "04.png",
+ "ax": 132.5,
+ "ay": 420.0,
+ "w": 347,
+ "h": 420,
+ "air": 1
+ },
+ {
+ "file": "05.png",
+ "ax": 211.5,
+ "ay": 421.0,
+ "w": 330,
+ "h": 413,
+ "air": 9
+ },
+ {
+ "file": "06.png",
+ "ax": 123.0,
+ "ay": 430.0,
+ "w": 258,
+ "h": 428,
+ "air": 3
+ },
+ {
+ "file": "07.png",
+ "ax": 116.5,
+ "ay": 423.0,
+ "w": 280,
+ "h": 419,
+ "air": 5
+ },
+ {
+ "file": "08.png",
+ "ax": 120.0,
+ "ay": 417.0,
+ "w": 285,
+ "h": 418,
+ "air": 0
+ }
+ ],
+ "ref_h": 439.0,
+ "ref_h_raw": 419.5,
+ "hat_w": 233.5
+}
\ No newline at end of file
diff --git a/scripts/engine/demos/long_scroll/frames/monet_walk/01.png b/scripts/engine/demos/long_scroll/frames/monet_walk/01.png
new file mode 100644
index 0000000..b291311
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/monet_walk/01.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/monet_walk/02.png b/scripts/engine/demos/long_scroll/frames/monet_walk/02.png
new file mode 100644
index 0000000..acbe8f6
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/monet_walk/02.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/monet_walk/03.png b/scripts/engine/demos/long_scroll/frames/monet_walk/03.png
new file mode 100644
index 0000000..743ad16
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/monet_walk/03.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/monet_walk/04.png b/scripts/engine/demos/long_scroll/frames/monet_walk/04.png
new file mode 100644
index 0000000..83400e0
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/monet_walk/04.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/monet_walk/05.png b/scripts/engine/demos/long_scroll/frames/monet_walk/05.png
new file mode 100644
index 0000000..cb83696
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/monet_walk/05.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/monet_walk/06.png b/scripts/engine/demos/long_scroll/frames/monet_walk/06.png
new file mode 100644
index 0000000..d570494
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/monet_walk/06.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/monet_walk/07.png b/scripts/engine/demos/long_scroll/frames/monet_walk/07.png
new file mode 100644
index 0000000..99a7aa5
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/monet_walk/07.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/monet_walk/08.png b/scripts/engine/demos/long_scroll/frames/monet_walk/08.png
new file mode 100644
index 0000000..1a119c1
Binary files /dev/null and b/scripts/engine/demos/long_scroll/frames/monet_walk/08.png differ
diff --git a/scripts/engine/demos/long_scroll/frames/monet_walk/meta.json b/scripts/engine/demos/long_scroll/frames/monet_walk/meta.json
new file mode 100644
index 0000000..7f522f7
--- /dev/null
+++ b/scripts/engine/demos/long_scroll/frames/monet_walk/meta.json
@@ -0,0 +1,71 @@
+{
+ "frames": [
+ {
+ "file": "01.png",
+ "ax": 129.0,
+ "ay": 447.0,
+ "w": 249,
+ "h": 448,
+ "air": 0
+ },
+ {
+ "file": "02.png",
+ "ax": 123.0,
+ "ay": 445.0,
+ "w": 241,
+ "h": 445,
+ "air": 1
+ },
+ {
+ "file": "03.png",
+ "ax": 121.0,
+ "ay": 445.0,
+ "w": 240,
+ "h": 446,
+ "air": 0
+ },
+ {
+ "file": "04.png",
+ "ax": 118.0,
+ "ay": 449.0,
+ "w": 236,
+ "h": 448,
+ "air": 2
+ },
+ {
+ "file": "05.png",
+ "ax": 128.5,
+ "ay": 448.0,
+ "w": 248,
+ "h": 448,
+ "air": 1
+ },
+ {
+ "file": "06.png",
+ "ax": 123.0,
+ "ay": 447.0,
+ "w": 241,
+ "h": 447,
+ "air": 1
+ },
+ {
+ "file": "07.png",
+ "ax": 121.5,
+ "ay": 446.0,
+ "w": 240,
+ "h": 447,
+ "air": 0
+ },
+ {
+ "file": "08.png",
+ "ax": 118.5,
+ "ay": 450.0,
+ "w": 236,
+ "h": 449,
+ "air": 2
+ }
+ ],
+ "ref_h": 440.9,
+ "ref_h_raw": 447.5,
+ "hat_w": 234.5
+}
\ No newline at end of file
diff --git a/scripts/engine/demos/long_scroll/lib/acts.js b/scripts/engine/demos/long_scroll/lib/acts.js
new file mode 100644
index 0000000..65e5de2
--- /dev/null
+++ b/scripts/engine/demos/long_scroll/lib/acts.js
@@ -0,0 +1,87 @@
+// 莫奈《日本桥》一幕:固定机位的打水漂小剧。B 方向直接用;C 方向当画框里的「活的画」用。
+// ACT.monet(c, lt, sc) 画一帧并返回主角状态 {x,y,h,key,i,hat};sc = 剧本参数(见 SCRIPTS)。
+(() => {
+const W = 1920, H = 1080, TAU = Math.PI * 2;
+const { clamp, lerp, ss } = U;
+const X = window.XING, P = window.PAINT;
+const ACT = window.ACT = {};
+ACT.monetWorld = () => X.monetWorld({ key: 'fixed', x0: 0, w: 1920, waterTop: 520, bridge: { x0: -160, x1: 2080, yEnd: 690, lift: 210 }, pond: null, groundY: 700 });
+const HERO_H = 330;
+
+// 睡莲花(代码画+莫奈笔触,缓存)
+let LILY = null;
+ACT.lily = (c, x, y, s, rot = 0) => {
+ if (!LILY) { const cc = P.canvas(140, 100), q = cc.getContext('2d'); q.translate(70, 70);
+ q.fillStyle = '#7aa85a'; q.beginPath(); q.ellipse(0, 10, 58, 16, 0, 0.4, TAU - 0.4); q.lineTo(0, 10); q.fill();
+ for (let k = 0; k < 7; k++) { const a = -Math.PI / 2 + (k - 3) * 0.42; q.fillStyle = k % 2 ? '#f2a6bf' : '#f7c4d4'; q.save(); q.rotate(a + Math.PI / 2); q.beginPath(); q.ellipse(0, -22, 10, 24, 0, 0, TAU); q.fill(); q.restore(); }
+ q.fillStyle = '#f6d86a'; q.beginPath(); q.arc(0, -4, 8, 0, TAU); q.fill();
+ const out = P.canvas(140, 100), og = out.getContext('2d'); og.drawImage(cc, 0, 0); og.globalCompositeOperation = 'source-atop';
+ X.strokes(og, cc, { cell: 4, len: 8, width: 3, seed: 91, alphaMask: true, alphaMin: 100, angle: (x, y, r) => Math.atan2(y - 66, x - 70) + Math.PI / 2 + (r() - 0.5) * 0.4, jitterCol: 22 });
+ LILY = out; }
+ c.save(); c.translate(x, y); c.rotate(rot); c.scale(s, s); c.drawImage(LILY, -70, -80); c.restore();
+};
+
+// 打水漂动作分镜(相对出手动作开始 T 的秒数)——monet_throw 8 帧:0看石子 1蓄力 2甩 3出手(帧里画着石子) 4随挥 5搭凉棚看 6欢呼 7抬头惊讶
+const THROW = [[0, 0], [0.22, 1], [0.48, 2], [0.56, 3], [0.66, 4], [0.9, 5]];
+ACT.throwFrame = (u) => { let f = 0; for (const [tt, i] of THROW) if (u >= tt) f = i; return f; };
+ACT.RELEASE = 0.66; // 帧 3 结束、代码石子接手
+// 帧 3 里石子在精灵上的位置(像素,见 slice 时量的 309–346 × 186–210),换算成屏幕坐标
+ACT.stoneFrom = (x, y, h) => { const s = h / 439.0; return [x + (327 - 132.5) * s, y + (198 - 420) * s]; };
+
+// 找最接近某点的一片睡莲
+const nearestPad = (M, x, y, flower) => { let best = null, bd = 1e9; for (const p of M.pads) { if (flower === true && !p.flower) continue; if (flower === false && p.flower) continue; const d = Math.hypot(p.x - x, (p.y - y) * 2); if (d < bd) { bd = d; best = p; } } return best; };
+
+// sc: { entry:'walk'|'drop', tIn, standX, T (出手动作开始), gag:'frog'|'lily', hideAfter, hideBefore, heroH }
+ACT.monet = (c, lt, sc) => {
+ const M = ACT.monetWorld(), h = sc.heroH || HERO_H, T = sc.T;
+ const pad = sc.gag === 'frog' ? nearestPad(M, 1640, 975) : nearestPad(M, 1560, 930, false);
+ const sx = sc.standX, sy = M.deckY(sx);
+ const rel = T + ACT.RELEASE, from = ACT.stoneFrom(sx, sy, h);
+ const hops = [{ x: 1000, y: 700, t: rel + 0.26, s: 0.45 }, { x: 1230, y: 790, t: rel + 0.5, s: 0.6, peak: 120 }, { x: 1410, y: 868, t: rel + 0.68, s: 0.74, peak: 80 }];
+ const last = { x: pad.x, y: pad.y, t: rel + 0.82, s: 0.85, peak: 55 };
+ const plan = { t0: rel, from, s0: 0.4, firstArc: 90, hops: hops.concat([last]) };
+ const ev = { hops: plan.hops.map((p, i) => ({ x: p.x, y: p.y, t: p.t, s: p.s, big: i === 3 })), padBump: { pad, t: last.t } };
+ const hitT = last.t, landT = hitT + 1.0;
+ c.save(); if (sc.zoom) { const z = 1 + 0.16 * ss(hitT + 0.5, landT + 0.2, lt); const zx = sx + 60, zy = sy - h * 0.7; c.translate(zx, zy); c.scale(z, z); c.translate(-zx, -zy); }
+ X.monetBack(c, M, 0, lt, ev);
+ // 青蛙或花:起(一直坐在那片叶子上)→ 被石子砸中弹起 → 落到他帽子上
+ // 主角
+ let hero = null;
+ const hidden = (sc.hideBefore != null && lt < sc.hideBefore) || (sc.hideAfter != null && lt >= sc.hideAfter);
+ if (!hidden) {
+ let key = 'monet_throw', i = 0, x = sx, y = sy, sq = 1;
+ if (sc.entry === 'walk' && lt < sc.tIn) { key = 'monet_walk'; const q = lt / sc.tIn; x = lerp(sc.walkFrom, sx, q); y = M.deckY(x); i = Math.floor((x - sc.walkFrom) / 17) % 8; }
+ else if (sc.entry === 'drop' && lt < sc.tIn) { key = 'monet_jump'; const q = clamp((lt - (sc.hideBefore || 0)) / (sc.tIn - (sc.hideBefore || 0))); x = lerp(sc.dropFrom[0], sx, q); y = lerp(sc.dropFrom[1], sy, q) - Math.sin(q * Math.PI) * 90; i = q < 0.7 ? 3 : 4; }
+ else if (sc.entry === 'drop' && lt < sc.tIn + 0.3) { key = 'monet_jump'; i = lt < sc.tIn + 0.12 ? 5 : 6; }
+ else if (lt < T) i = 0;
+ else { const u = lt - T; i = ACT.throwFrame(u); if (lt >= hitT - 0.1) i = 6; if (lt >= hitT + 0.35) i = 5; if (lt >= landT) i = 7; }
+ if (sc.override) ({ key, i, x, y } = Object.assign({ key, i, x, y }, sc.override(lt, { key, i, x, y })));
+ if (lt >= landT && lt < landT + 0.3) { const a = (lt - landT) / 0.3; y -= Math.sin(a * Math.PI) * 26; x += Math.sin(a * 40) * 4 * (1 - a); } // 落帽那一下:吓得一蹦、抖
+ X.actor(c, key, i, { x, y, h, mat: 'monet', t: lt, wx: x, shadow: 'rgba(60,70,120,.18)' });
+ if (lt >= landT && lt < landT + 0.9) { const a = (lt - landT) / 0.9, [hx0, hy0] = X.hatTop(key, i, { x, y, h }); c.save(); c.lineCap = 'round'; c.globalAlpha = 1 - a * a; // 惊吓线(莫奈色短笔)
+ [-0.9, -0.35, 0.25].forEach((ang, k) => { const r0 = h * 0.42 + a * 30, r1 = r0 + 34; const cx = hx0 + 30, cy = hy0 + h * 0.25; c.strokeStyle = ['#fffbe8', '#f2a6bf', '#9db5e0'][k]; c.lineWidth = 9; c.beginPath(); c.moveTo(cx + Math.cos(ang - 1.2) * r0, cy + Math.sin(ang - 1.2) * r0); c.lineTo(cx + Math.cos(ang - 1.2) * r1, cy + Math.sin(ang - 1.2) * r1); c.stroke(); }); c.restore(); }
+ hero = { key, i, x, y, h, hat: X.hatTop(key, i, { x, y, h }) };
+ }
+ X.monetFront(c, M, 0, lt, [90, 1830]);
+ X.stoneAt(c, lt, plan);
+ // 道具:青蛙 / 睡莲花
+ const hatAt = hero ? hero.hat : (sc.hatFallback || [sx, sy - h]);
+ const padY = pad.y - 4 * pad.s;
+ if (sc.gag === 'frog') {
+ const fs = 0.7 + 0.5 * pad.s;
+ if (lt < hitT) X.frog(c, pad.x, padY + Math.sin(lt * 2) * 1.5, fs, 'sit', 'monet', { croak: lt > 0.3 && lt < 0.7 ? Math.sin((lt - 0.3) / 0.4 * Math.PI) : 0, flip: true });
+ else if (lt < landT) { const q = (lt - hitT) / (landT - hitT), x = lerp(pad.x, hatAt[0], q), y = lerp(padY, hatAt[1] + 4, q) - Math.sin(q * Math.PI) * 360, s = lerp(fs, 0.62, q) + Math.sin(q * Math.PI) * 0.55;
+ X.frog(c, x, y, s, 'leap', 'monet', { rot: -q * TAU * 1.0 - 0.5, flip: true }); }
+ else if (!sc.hideFrogAfter || lt < sc.hideFrogAfter) { const a = lt - landT, sq = 1 - 0.3 * Math.exp(-a * 9) * Math.cos(a * 30);
+ X.frog(c, hatAt[0], hatAt[1] + 8, 0.62, 'sit', 'monet', { sy: sq, croak: a > 0.25 && a < 0.75 ? Math.sin((a - 0.25) / 0.5 * Math.PI) : 0, flip: true }); }
+ } else if (sc.gag === 'lily') {
+ const ls = 0.5 + 0.5 * pad.s;
+ if (lt < hitT) ACT.lily(c, pad.x, padY + 4, ls * 0.8, 0);
+ else if (lt < landT) { const q = (lt - hitT) / (landT - hitT), x = lerp(pad.x, hatAt[0], q), y = lerp(padY, hatAt[1] + 8, q) - Math.sin(q * Math.PI) * 300; ACT.lily(c, x, y, lerp(ls, 0.5, q) + Math.sin(q * Math.PI) * 0.7, q * TAU * 1.5);
+ if (q < 0.25) X.ripple(c, pad.x, pad.y, (lt - hitT), 0.9, true); }
+ else if (lt >= landT && !(sc.hideAfter != null && lt >= sc.hideAfter)) { const a = lt - landT; ACT.lily(c, hatAt[0], hatAt[1] + 10, 0.5 * (1 + 0.15 * Math.exp(-a * 8) * Math.sin(a * 30)), 0); }
+ }
+ c.restore();
+ return { hero, hitT, landT, pad, hatAt };
+};
+})();
diff --git a/scripts/engine/demos/long_scroll/lib/crossing.js b/scripts/engine/demos/long_scroll/lib/crossing.js
new file mode 100644
index 0000000..dbb44eb
--- /dev/null
+++ b/scripts/engine/demos/long_scroll/lib/crossing.js
@@ -0,0 +1,463 @@
+// 长卷穿越片 · 共用库 XING(《花叔穿越名画》用的,随 demos/long_scroll 收进 skill)。
+// 角色=AI 生的画风帧(gpt-image 按画风重画→绿幕抠图→切帧,见 references/10-角色.md),代码只管:在哪、多大、何时换帧、加什么材质。
+// 场景、运镜、石子、涟漪、睡莲、青蛙、转场全部代码画。
+// XING.sprites(keys) 同步读 demos/long_scroll/frames/<key>/meta.json,返回资源列表(给 era.assets)
+// XING.actor(c, key, i, o) 画第 i 帧:o={x,y(脚底),h(站立身高),mat:'monet'|'ukiyoe'|'vangogh'|'none',wx,t,flip,alpha}
+// XING.hatTop(key,i,o) 帽顶在屏幕上的位置(青蛙落点)
+// XING.strokes(g, src, opt) 任意尺寸画布的笔触重画,每格独立种子(位置永不重洗)
+// XING.monetWorld / ukiyoeWorld / vgWorld 三个世界:静态部分一次画好缓存(世界坐标),动态部分每帧画
+// XING.stone(t, plan) 打水漂:石子位置+各次触水时刻
+// XING.frog(c, x, y, s, pose, style, o)
+(() => {
+const W = 1920, H = 1080, TAU = Math.PI * 2;
+const { clamp, lerp, ss, rng } = U;
+const P = window.PAINT;
+const X = window.XING = {};
+const hx = P.hex;
+const cellRng = (i, j, seed) => rng((Math.floor(U.hash(i * 131 + seed * 7919, j * 31 + seed) * 4294967296)) >>> 0);
+const lum = c => c[0] * 0.3 + c[1] * 0.59 + c[2] * 0.11;
+const pick = (arr, r) => arr[(r() * arr.length) | 0];
+
+// ================= 笔触重画(任意尺寸,每格独立种子) =================
+X.strokes = (g, src, { cell = 10, len = 24, width = 6, angle, palette, seed = 1, mask, alphaMask = false, alphaMin = 180, outline = 0, outlineCol = [20, 25, 60], outlineMix = 0.55, jitterCol = 14, skip, cap = 'round', alpha = 1 } = {}) => {
+ const w = src.width, h = src.height;
+ const sd = src.getContext('2d', { willReadFrequently: true }).getImageData(0, 0, w, h).data;
+ g.save(); g.lineCap = cap;
+ for (let j = 0; j * cell < h + cell; j++) for (let i = 0; i * cell < w + cell; i++) {
+ const r = cellRng(i, j, seed);
+ const px = i * cell + (r() - 0.5) * cell, py = j * cell + (r() - 0.5) * cell;
+ const ix = clamp(px | 0, 0, w - 1), iy = clamp(py | 0, 0, h - 1), k = (iy * w + ix) * 4;
+ if (alphaMask && sd[k + 3] < alphaMin) continue;
+ if (mask && !mask(px, py)) continue;
+ let col = [sd[k], sd[k + 1], sd[k + 2]];
+ if (skip && skip(col, px, py, r)) continue;
+ const pc = palette ? palette(px, py, col, r) : null;
+ col = pc || P.jitter(col, r, jitterCol);
+ const a = angle ? angle(px, py, r) : 0, l = len * (0.7 + r() * 0.6);
+ const dx = Math.cos(a) * l / 2, dy = Math.sin(a) * l / 2;
+ if (outline > 0) { g.strokeStyle = P.rgb(P.mix(col, outlineCol, outlineMix), outline * alpha); g.lineWidth = width + 2.5; g.beginPath(); g.moveTo(px - dx, py - dy); g.lineTo(px + dx, py + dy); g.stroke(); }
+ g.strokeStyle = P.rgb(col, alpha); g.lineWidth = width * (0.8 + r() * 0.4);
+ g.beginPath(); g.moveTo(px - dx, py - dy); g.lineTo(px + dx, py + dy); g.stroke();
+ }
+ g.restore();
+};
+
+// ================= 角色帧 =================
+X.SPR = {};
+const syncJSON = url => { const x = new XMLHttpRequest(); x.open('GET', url, false); x.send(); if (x.status !== 200) throw new Error(url + ' ' + x.status); return JSON.parse(x.responseText); };
+X.sprites = keys => {
+ const list = [];
+ for (const k of keys) {
+ if (!X.SPR[k]) { const meta = syncJSON(`demos/long_scroll/frames/${k}/meta.json`); X.SPR[k] = { key: k, meta, imgs: null, mats: {} }; }
+ X.SPR[k].meta.frames.forEach(f => list.push(`demos/long_scroll/frames/${k}/${f.file}`));
+ }
+ return list;
+};
+function ensure(key) {
+ const S = X.SPR[key]; if (S.imgs) return S;
+ S.imgs = S.meta.frames.map(f => window.IMG[`demos/long_scroll/frames/${key}/${f.file}`]);
+ // 帽顶:最上面一行不透明像素的中心
+ S.hat = S.imgs.map(im => { const c = P.canvas(im.width, im.height), g = c.getContext('2d', { willReadFrequently: true }); g.drawImage(im, 0, 0); const d = g.getImageData(0, 0, im.width, im.height).data;
+ for (let y = 0; y < im.height; y++) { let x0 = -1, x1 = -1; for (let x = 0; x < im.width; x++) if (d[(y * im.width + x) * 4 + 3] > 140) { if (x0 < 0) x0 = x; x1 = x; } if (x0 >= 0 && x1 - x0 > 6) return [(x0 + x1) / 2, y]; } return [im.width / 2, 0]; });
+ return S;
+}
+// 材质:把 AI 帧再过一遍该画风的笔触,让他和场景用同一种「笔」(不碰深色=眼镜、眼睛、头发不被糊掉)
+const MAT = {
+ monet: { pad: 8, cell: 6, len: 12, width: 4.2, seed: 11, outline: 0, angle: (x, y, r) => -0.55 + (r() - 0.5) * 0.9,
+ skip: (col, x, y, r) => lum(col) < 95 || r() < 0.35,
+ palette: (x, y, col, r) => { const L = lum(col);
+ if (L > 205) return P.mix(hx(pick(['#fbf6ea', '#efe6f6', '#e0e2f6', '#fff0d4', '#e6eef8', '#f6e4ee'], r)), col, 0.45);
+ if (col[0] > 190 && col[0] > col[2] + 40 && col[1] > 120) return P.mix(hx(pick(['#f6c6a6', '#f0b4a0', '#fad6bc', '#e8a890', '#f8d0b0'], r)), col, 0.45);
+ if (col[0] > 150 && col[1] > 140 && col[2] < col[1]) return P.mix(hx(pick(['#d8c8a0', '#c8b48a', '#e2d4ae', '#b8aaa8', '#d0c0b8'], r)), col, 0.45);
+ return null; } },
+ vangogh: { pad: 8, cell: 7, len: 17, width: 5, seed: 13, outline: 0.45, outlineCol: [20, 26, 80],
+ angle: (x, y, r) => Math.PI / 2 + Math.sin(y * 0.05 + x * 0.02) * 0.7 + (r() - 0.5) * 0.4,
+ skip: (col, x, y, r) => lum(col) < 90 || r() < 0.25,
+ palette: (x, y, col, r) => { const L = lum(col);
+ if (L > 200) return P.mix(hx(pick(['#f8f0b0', '#e8f0f8', '#c8d8f0', '#fff6c8', '#d8e4f4'], r)), col, 0.35);
+ if (col[0] > 190 && col[0] > col[2] + 40) return P.mix(hx(pick(['#f0b060', '#e8a050', '#f8c878', '#e89060'], r)), col, 0.4);
+ return null; } },
+};
+function material(S, i, mat) {
+ const key = mat; S.mats[key] = S.mats[key] || [];
+ if (S.mats[key][i]) return S.mats[key][i];
+ const im = S.imgs[i], M = MAT[mat], pad = M ? M.pad : 0;
+ const out = P.canvas(im.width + 2 * pad, im.height + 2 * pad), g = out.getContext('2d');
+ g.drawImage(im, pad, pad);
+ if (M) { const base = P.canvas(out.width, out.height), bgx = base.getContext('2d', { willReadFrequently: true }); bgx.drawImage(im, pad, pad);
+ // 五官保护:附近 7px 内有深色像素(眼镜、眼睛、嘴、发际)就不下笔,免得把脸糊掉
+ const bw = base.width, bh = base.height, bd = bgx.getImageData(0, 0, bw, bh).data, dk = new Uint8Array(bw * bh);
+ for (let k = 0; k < bw * bh; k++) dk[k] = bd[k * 4 + 3] > 150 && (bd[k * 4] * 0.3 + bd[k * 4 + 1] * 0.59 + bd[k * 4 + 2] * 0.11) < 110 ? 1 : 0;
+ const nearDark = (x, y) => { for (let dy = -7; dy <= 7; dy += 3.5) for (let dx = -7; dx <= 7; dx += 3.5) { const xx = (x + dx) | 0, yy = (y + dy) | 0; if (xx >= 0 && yy >= 0 && xx < bw && yy < bh && dk[yy * bw + xx]) return true; } return false; };
+ X.strokes(g, base, { cell: M.cell, len: M.len, width: M.width, seed: M.seed + i, angle: M.angle, palette: M.palette, skip: (col, x, y, r) => M.skip(col, x, y, r) || nearDark(x, y), alphaMask: true, alphaMin: 170, outline: M.outline, outlineCol: M.outlineCol, jitterCol: 12 }); }
+ if (mat === 'ukiyoe') { // 木纹+纸纤维压进色块(multiply,只在人身上)
+ { const d = g.getImageData(0, 0, out.width, out.height), q = d.data; // 生图把白帽白T画成米黄:低饱和的亮色拉回纸白(帽子定规是纯白)
+ for (let k = 0; k < q.length; k += 4) { const mx = Math.max(q[k], q[k + 1], q[k + 2]), mn = Math.min(q[k], q[k + 1], q[k + 2]); if (q[k + 3] > 0 && mx > 185 && mx - mn < 48) { const f = (mx - 185) / 70; q[k] = lerp(q[k], 251, f); q[k + 1] = lerp(q[k + 1], 249, f); q[k + 2] = lerp(q[k + 2], 242, f); } }
+ g.putImageData(d, 0, 0); }
+ const tex = P.canvas(out.width, out.height), tg = tex.getContext('2d'), r = rng(77 + i);
+ tg.fillStyle = '#fff'; tg.fillRect(0, 0, tex.width, tex.height);
+ for (let k = 0; k < 160; k++) { const y = r() * tex.height; tg.strokeStyle = `rgba(150,110,60,${0.05 + r() * 0.08})`; tg.lineWidth = 1 + r() * 1.5; tg.beginPath(); tg.moveTo(0, y); tg.bezierCurveTo(tex.width * 0.3, y + (r() - 0.5) * 8, tex.width * 0.7, y + (r() - 0.5) * 8, tex.width, y + (r() - 0.5) * 6); tg.stroke(); }
+ tg.globalCompositeOperation = 'destination-in'; tg.drawImage(out, 0, 0);
+ g.globalCompositeOperation = 'multiply'; g.drawImage(tex, 0, 0); g.globalCompositeOperation = 'source-over';
+ }
+ out.pad = pad; S.mats[key][i] = out; return out;
+}
+// 画一帧。x,y = 脚底锚点(屏幕),h = 站立身高(按 meta.ref_h 换算,整套帧同一缩放)
+X.actor = (c, key, i, o) => {
+ const S = ensure(key), f = S.meta.frames[i], mat = o.mat || 'none';
+ const im = material(S, i, mat), pad = im.pad || 0, s = o.h / S.meta.ref_h * (o.scale || 1);
+ const fx = o.flip ? -1 : 1;
+ const dw = im.width * s, dh = im.height * s, x0 = o.x - (f.ax + pad) * s * fx, y0 = o.y - (f.ay + pad) * s;
+ // 光影斑驳(莫奈):暖黄光斑与淡紫阴影按世界坐标落在他身上,他走过时光从身上滑过
+ const S2 = P.scratch('actorTmp'), g = S2.getContext('2d');
+ const bw = Math.ceil(dw) + 4, bh = Math.ceil(dh) + 4;
+ g.setTransform(1, 0, 0, 1, 0, 0); g.clearRect(0, 0, Math.min(W, bw + 4), Math.min(H, bh + 4));
+ g.save(); if (o.flip) { g.translate(bw - 2, 2); g.scale(-1, 1); } else g.translate(2, 2); g.drawImage(im, 0, 0, dw, dh); g.restore();
+ if (mat === 'monet' && o.dapple !== false) {
+ g.save(); g.globalCompositeOperation = 'source-atop';
+ const wx0 = (o.flip ? x0 - dw : x0) + ((o.wx ?? o.x) - o.x), t = o.t || 0; // 精灵左上角的世界 x
+ const cs = 70;
+ for (let j = -1; j * cs < bh + cs; j++) for (let ii = Math.floor(wx0 / cs) - 1; ii * cs < wx0 + bw + cs; ii++) {
+ const hh = U.hash(ii, j + 40), hv = U.hash(ii + 7, j); if (hh < 0.45) continue;
+ const cx = ii * cs + hv * cs + Math.sin(t * 0.9 + ii) * 10 - wx0, cy = j * cs + U.hash(ii, j + 3) * cs + Math.cos(t * 0.7 + j) * 6, rr = 18 + hh * 26;
+ const warm = U.hash(ii + 3, j + 9) > 0.35, rg = g.createRadialGradient(cx, cy, 0, cx, cy, rr);
+ rg.addColorStop(0, warm ? 'rgba(255,238,170,0.42)' : 'rgba(110,96,190,0.26)'); rg.addColorStop(1, warm ? 'rgba(255,238,170,0)' : 'rgba(110,96,190,0)');
+ g.fillStyle = rg; g.fillRect(cx - rr, cy - rr, rr * 2, rr * 2);
+ }
+ const sg = g.createLinearGradient(0, bh * 0.45, 0, bh); sg.addColorStop(0, 'rgba(120,110,200,0)'); sg.addColorStop(1, 'rgba(120,110,200,0.22)'); g.fillStyle = sg; g.fillRect(0, 0, bw, bh);
+ g.restore();
+ }
+ c.save(); if (o.alpha != null) c.globalAlpha *= o.alpha;
+ if (o.shadow) { c.fillStyle = o.shadow; c.beginPath(); c.ellipse(o.x, o.y + 2, o.h * 0.2, o.h * 0.035, 0, 0, TAU); c.fill(); }
+ c.drawImage(S2, 0, 0, bw, bh, (o.flip ? x0 - dw : x0) - 2, y0 - 2, bw, bh);
+ c.restore();
+};
+X.hatTop = (key, i, o) => { const S = ensure(key), f = S.meta.frames[i], s = o.h / S.meta.ref_h * (o.scale || 1), [hxp, hyp] = S.hat[i], fx = o.flip ? -1 : 1;
+ return [o.x + (hxp - f.ax) * s * fx, o.y + (hyp - f.ay) * s]; };
+X.nFrames = key => X.SPR[key].meta.frames.length;
+
+// ================= 莫奈:睡莲池+日本桥 =================
+// o: { key, x0, w, waterTop, bridge:{x0,x1,yEnd,lift}, pond:[px0,px1]|null, groundY, willows:[x...] }
+const SW = {
+ water: P.swatch(['#5b6fb5', '#7d8fd0', '#9db5e0', '#6aa0a8', '#b7a6d8', '#d9c8e8', '#8fb8a8', '#a6c4e8', '#c8b0d8'], 0.45),
+ deep: P.swatch(['#2e5048', '#3f6a58', '#4a5f8a', '#355a4a', '#5a6a9a', '#2a4a5a', '#6a8a5a'], 0.45),
+ fol: P.swatch(['#4f7f3a', '#6f9a40', '#2f5a30', '#9cbf58', '#c0d070', '#3a6a5a', '#7aa86a', '#5a8a9a', '#d8d890', '#4a5a8a'], 0.6),
+ grass: P.swatch(['#5f8f4a', '#7fae5a', '#3f6f4a', '#9cc070', '#b4cc78', '#6a9a8a'], 0.35),
+ path: P.swatch(['#d8b890', '#c89a78', '#e8c8a0', '#b88a8a', '#a89ab8', '#e0c0a8'], 0.35),
+};
+X.monetWorld = (o) => {
+ const key = 'mw_' + o.key; if (X[key]) return X[key];
+ const w = o.w, x0 = o.x0, B = o.bridge, mid = (B.x0 + B.x1) / 2, half = (B.x1 - B.x0) / 2;
+ const deckY = x => { const q = clamp((x - mid) / half, -1, 1); return B.yEnd - B.lift * (1 - q * q); };
+ const inPond = wx => !o.pond || (wx > o.pond[0] && wx < o.pond[1]);
+ const pondEdge = (wx, y) => { if (!o.pond) return true; const sl = (y - o.groundY) * 0.25; return wx > o.pond[0] - sl && wx < o.pond[1] + sl; };
+ const WT = o.waterTop, G = o.groundY;
+ const isWater = (wx, y) => y > WT && (y < G - 10 ? inPond(wx) || true : pondEdge(wx, y)) && !(y < G + 30 && !inPond(wx) && y > G - 40);
+ // ---- 底稿 ----
+ const base = P.canvas(w, H), g = base.getContext('2d');
+ g.fillStyle = '#2f4a36'; g.fillRect(0, 0, w, H);
+ const r = rng(301);
+ // 树荫:低频噪声分出深浅大块(深蓝绿的柳荫 / 中绿 / 黄绿受光),再撒垂柳条
+ for (let i = 0; i < w * 0.12; i++) { const x = r() * w, y = r() * (G + 20), n = P.fbm((x + x0) * 0.0035, y * 0.005);
+ const pal = n < -0.12 ? ['#1f3a2e', '#2a4a4a', '#34507a', '#2e5a40'] : n < 0.12 ? ['#3f6a3a', '#5a8a3e', '#4a7a6a', '#6a8a9a', '#5f8a4a'] : ['#9cc060', '#b8cc68', '#d8d890', '#c0d070', '#e8e0a0'];
+ g.fillStyle = pick(pal, r); g.globalAlpha = 0.85; g.beginPath(); g.ellipse(x, y, 30 + r() * 80, 24 + r() * 50, r() * 3, 0, TAU); g.fill(); }
+ for (let i = 0; i < w * 0.01; i++) { const x = r() * w, y = r() * 200; g.fillStyle = pick(['#cfd8e8', '#e6e0f0', '#d8e8d0', '#f0e8d0'], r); g.globalAlpha = 0.75; g.beginPath(); g.ellipse(x, y, 16 + r() * 34, 12 + r() * 18, 0, 0, TAU); g.fill(); }
+ g.globalAlpha = 1;
+ for (let i = 0; i < w * 0.04; i++) { const x = r() * w, L = 180 + r() * 360, n = P.fbm((x + x0) * 0.0035, 0.5); g.strokeStyle = pick(n < 0 ? ['#3a6a4a', '#4a7a3a', '#2e5a48'] : ['#8ab050', '#a8c868', '#c8d878'], r); g.lineWidth = 5 + r() * 8; g.beginPath(); g.moveTo(x, -10); g.quadraticCurveTo(x + (r() - 0.5) * 30, L / 2, x + (r() - 0.5) * 40, L); g.stroke(); }
+ // 水面
+ const wg = g.createLinearGradient(0, WT, 0, H); wg.addColorStop(0, '#34503f'); wg.addColorStop(0.18, '#456a7a'); wg.addColorStop(0.5, '#7590c0'); wg.addColorStop(1, '#a9b6dc');
+ g.save(); g.beginPath();
+ if (o.pond) { g.moveTo(o.pond[0] - x0, WT); g.lineTo(o.pond[1] - x0, WT); g.lineTo(o.pond[1] + (H - G) * 0.25 - x0, H); g.lineTo(o.pond[0] - (H - G) * 0.25 - x0, H); g.closePath(); }
+ else g.rect(0, WT, w, H - WT);
+ g.fillStyle = wg; g.fill(); g.clip();
+ for (let i = 0; i < w * 0.03; i++) { const x = r() * w, y = WT + r() * 260, L = 60 + r() * 200; g.fillStyle = pick(['#2e5048', '#3f6a58', '#4a6a3a', '#5a7a4a'], r); g.globalAlpha = 0.6; g.fillRect(x, y, 10 + r() * 20, L); }
+ for (let i = 0; i < w * 0.012; i++) { const x = r() * w, y = WT + 250 + r() * (H - WT - 250); g.fillStyle = pick(['#e8d6e8', '#f2e2c4', '#d0dcf0'], r); g.globalAlpha = 0.55; g.beginPath(); g.ellipse(x, y, 60 + r() * 120, 12 + r() * 16, 0, 0, TAU); g.fill(); }
+ g.restore(); g.globalAlpha = 1;
+ // 岸(有池边界时):小路+草+鸢尾
+ if (o.pond) {
+ g.save(); g.beginPath(); g.rect(0, G - 40, w, H); g.moveTo(o.pond[0] - x0, G - 40); g.lineTo(o.pond[1] - x0, G - 40); g.lineTo(o.pond[1] + (H - G + 40) * 0.25 - x0, H); g.lineTo(o.pond[0] - (H - G + 40) * 0.25 - x0, H); g.closePath(); g.clip('evenodd');
+ g.fillStyle = '#5f8f4a'; g.fillRect(0, G - 40, w, H);
+ g.fillStyle = '#d8b890'; g.fillRect(0, G - 8, w, 46);
+ for (let i = 0; i < w * 0.03; i++) { const x = r() * w, y = G + 60 + r() * (H - G - 60); g.strokeStyle = '#4f7f3a'; g.lineWidth = 5; for (let k = 0; k < 5; k++) { g.beginPath(); g.moveTo(x, y); g.lineTo(x + (k - 2) * 9 + (r() - 0.5) * 8, y - 50 - r() * 40); g.stroke(); } g.fillStyle = pick(['#7a5ab8', '#9a7ad0', '#f0e080', '#e890b0'], r); g.beginPath(); g.ellipse(x + (r() - 0.5) * 20, y - 70 - r() * 20, 12, 15, 0, 0, TAU); g.fill(); }
+ g.restore();
+ }
+ // ---- 笔触 ----
+ const bg = P.canvas(w, H), bgc = bg.getContext('2d'); bgc.drawImage(base, 0, 0);
+ const regionOf = (lx, y) => { const wx = lx + x0;
+ if (y > WT) { if (!o.pond) return 'water'; const sl = (y - G + 40) * 0.25; if (y > G - 40 && (wx < o.pond[0] - Math.max(0, sl) || wx > o.pond[1] + Math.max(0, sl))) return (y < G + 38 && y > G - 8) ? 'path' : 'grass'; return 'water'; }
+ if (o.pond && !inPond(wx) && y > G - 40) return (y > G - 8) ? 'path' : 'grass';
+ return 'fol'; };
+ X.strokes(bgc, base, { cell: 9, len: 30, width: 7, seed: 21, jitterCol: 12,
+ angle: (lx, y, rr) => { const reg = regionOf(lx, y); if (reg === 'water') return 0.05 * Math.sin(y * 0.05 + lx * 0.004) + (rr() - 0.5) * 0.08; if (reg === 'path') return (rr() - 0.5) * 0.2; if (reg === 'grass') return -1.35 + (rr() - 0.5) * 0.6; return (y < WT - 120 ? -1.5 + 0.35 * P.noise((lx + x0) * 0.01, y * 0.01) : -0.9 + 0.8 * P.noise((lx + x0) * 0.01, y * 0.01)) + (rr() - 0.5) * 0.4; },
+ palette: (lx, y, col, rr) => { const reg = regionOf(lx, y); if (reg === 'water') return y < WT + 120 + rr() * 200 ? SW.deep(col, rr) : SW.water(col, rr); return SW[reg](col, rr); } });
+ // ---- 桥(远侧栏杆+桥面),近侧栏杆单独一层(画在人前面) ----
+ const mkBridge = (near) => { const c = P.canvas(w, H), q = c.getContext('2d'); q.lineCap = 'round'; q.lineJoin = 'round';
+ const line = (dy, lw, col) => { q.strokeStyle = col; q.lineWidth = lw; q.beginPath(); for (let x = B.x0; x <= B.x1; x += 6) { const y = deckY(x) + dy; x === B.x0 ? q.moveTo(x - x0, y) : q.lineTo(x - x0, y); } q.stroke(); };
+ if (!near) {
+ // 桥身(拱下的厚度)+桥面
+ q.fillStyle = '#2f6a4a'; q.beginPath(); for (let x = B.x0; x <= B.x1; x += 6) q.lineTo(x - x0, deckY(x) - 4); for (let x = B.x1; x >= B.x0; x -= 6) q.lineTo(x - x0, deckY(x) + 30); q.closePath(); q.fill();
+ line(-2, 10, '#8fdcae');
+ line(-16 - 96, 8, '#4f9a72'); line(-16 - 52, 6, '#5fae82');
+ q.strokeStyle = '#4f9a72'; q.lineWidth = 6; for (let x = B.x0 + 20; x < B.x1; x += 58) { q.beginPath(); q.moveTo(x - x0, deckY(x) - 10); q.lineTo(x - x0, deckY(x) - 16 - 96); q.stroke(); }
+ // 桥墩
+ [B.x0 + 30, B.x1 - 30].forEach(x => { q.fillStyle = '#2a5a3e'; q.fillRect(x - x0 - 10, deckY(x) + 20, 20, 120); });
+ } else {
+ line(-80, 9, '#7fcf9a'); line(-38, 6, '#6fbf8a');
+ q.strokeStyle = '#6fbf8a'; q.lineWidth = 6; for (let x = B.x0 + 44; x < B.x1; x += 64) { q.beginPath(); q.moveTo(x - x0, deckY(x) + 22); q.lineTo(x - x0, deckY(x) - 80); q.stroke(); }
+ }
+ const out = P.canvas(w, H), og = out.getContext('2d'); og.drawImage(c, 0, 0);
+ og.globalCompositeOperation = 'source-atop';
+ X.strokes(og, c, { cell: 5, len: 11, width: 4, seed: near ? 31 : 32, alphaMask: true, alphaMin: 120, angle: (x, y, rr) => 0.1 + (rr() - 0.5) * 0.5,
+ palette: (x, y, col, rr) => P.mix(hx(pick(['#8fdcae', '#a8e8c0', '#6fc49a', '#c0f0d0', '#4f9a8a', '#7fb8d8', '#3f7a5a'], rr)), col, 0.35) });
+ return out; };
+ const bridge = mkBridge(false), nearRail = mkBridge(true);
+ // ---- 睡莲(每片预画成小图,每帧按涟漪起伏) ----
+ const pads = [], rp = rng(505);
+ const sc = y => 0.22 + 0.78 * clamp((y - WT) / (H - WT));
+ for (let y = WT + 26; y < H + 20;) {
+ const s = sc(y); let x = x0 + (rp() - 0.5) * 200;
+ while (x < x0 + w + 100) {
+ const clusterN = 2 + ((rp() * 5) | 0);
+ for (let k = 0; k < clusterN; k++) {
+ const wx = x + (rp() - 0.3) * 60 * s, wy = y + (rp() - 0.5) * 14 * s;
+ if (!pondEdge(wx, wy) || (o.pond && wy > G - 30 && !inPond(wx))) continue;
+ const rx = (22 + rp() * 26) * s * 1.7, ry = rx * (0.24 + 0.1 * s), flower = rp() < 0.3 ? (rp() < 0.6 ? 'pink' : 'white') : null;
+ pads.push({ x: wx, y: wy, rx, ry, flower, notch: rp() * TAU, ph: rp() * TAU, img: null, s });
+ x += rx * 1.6;
+ }
+ x += (60 + rp() * 260) * s * 1.6;
+ }
+ y += 18 + 44 * s;
+ }
+ pads.forEach((p, i) => { const pw = Math.ceil(p.rx * 2 + 16), ph = Math.ceil(p.ry * 2 + 34 * p.s + 16); const cc = P.canvas(pw, ph), q = cc.getContext('2d'), cx = pw / 2, cy = ph - p.ry - 8;
+ q.fillStyle = pick(['#5f8f4a', '#7aa85a', '#6a9a4a', '#8ab860'], rng(i + 9)); q.beginPath(); q.ellipse(cx, cy, p.rx, p.ry, 0, p.notch + 0.35, p.notch + TAU - 0.35); q.lineTo(cx, cy); q.closePath(); q.fill();
+ q.fillStyle = 'rgba(40,70,60,0.35)'; q.beginPath(); q.ellipse(cx, cy + p.ry * 0.25, p.rx * 0.95, p.ry * 0.7, 0, 0, Math.PI); q.fill();
+ if (p.flower) { const fr = 11 * p.s * 1.6 + 3; q.fillStyle = p.flower === 'pink' ? '#f2a6bf' : '#fbf4f0'; q.beginPath(); q.ellipse(cx + p.rx * 0.15, cy - fr * 0.5, fr * 1.4, fr * 0.8, 0, 0, TAU); q.fill(); q.fillStyle = p.flower === 'pink' ? '#fff0f2' : '#f6d86a'; q.beginPath(); q.ellipse(cx + p.rx * 0.15, cy - fr * 0.8, fr * 0.6, fr * 0.45, 0, 0, TAU); q.fill(); }
+ const out = P.canvas(pw, ph), og = out.getContext('2d'); og.drawImage(cc, 0, 0); og.globalCompositeOperation = 'source-atop';
+ X.strokes(og, cc, { cell: Math.max(3, 5 * p.s + 1), len: 10 * p.s + 5, width: 3 * p.s + 1.6, seed: 600 + i, alphaMask: true, alphaMin: 100, angle: (x, y, rr) => (rr() - 0.5) * 0.4,
+ palette: (x, y, col, rr) => col[1] > col[0] + 10 ? P.mix(hx(pick(['#5f8f4a', '#7fae5a', '#9cc070', '#b4cc78', '#4a7a5a', '#c8d880'], rr)), col, 0.3) : (lum(col) > 170 ? P.mix(hx(pick(['#fff2f4', '#f7d0dc', '#fbf4e8', '#f0a0b8'], rr)), col, 0.4) : null) });
+ p.img = out; p.ax = cx; p.ay = cy; });
+ // 水面光斑(世界坐标)
+ const glints = []; const rg = rng(909);
+ for (let i = 0; i < w * 0.16; i++) { const wx = x0 + rg() * w, y = WT + 20 + rg() * (H - WT - 20); if (!pondEdge(wx, y)) continue; glints.push({ x: wx, y, f: 5 + rg() * 6, ph: rg() * TAU, l: (14 + rg() * 26) * (0.4 + sc(y)), col: pick(['#fffbe8', '#fdf0d0', '#f8e0ec', '#e8f4ff'], rg), w: (3 + rg() * 3) * (0.5 + sc(y) * 0.7) }); }
+ const M = X[key] = { o, base, bg, bridge, nearRail, pads, glints, deckY, sc, x0, w, WT, G, pondEdge, inPond };
+ return M;
+};
+// 每帧:底 → 睡莲(按涟漪起伏)→ 光斑 → 涟漪 → 桥(远栏杆) ;人画完后再 X.monetFront(近栏杆+前景柳条)
+X.monetBack = (c, M, camX, t, ev = {}) => {
+ c.drawImage(M.bg, M.x0 - camX, 0);
+ const hops = ev.hops || [];
+ // 睡莲
+ for (const p of M.pads) { const sx = p.x - camX; if (sx < -200 || sx > W + 200) continue;
+ let dy = Math.sin(t * 1.1 + p.ph) * 1.5 * p.s, rot = 0;
+ for (const h of hops) { const a = t - h.t; if (a < 0 || a > 2.2) continue; const d = Math.hypot(p.x - h.x, (p.y - h.y) * 3.2), R = 40 + a * 260 * h.s; const near = Math.exp(-Math.pow((d - R) / (60 * h.s + 20), 2)) * Math.exp(-a * 1.6);
+ dy += Math.sin(a * 16) * 7 * h.s * near; rot += Math.sin(a * 13 + 1) * 0.06 * near; }
+ if (ev.padBump && ev.padBump.pad === p) { const a = t - ev.padBump.t; if (a > 0 && a < 1.2) dy += Math.sin(a * 18) * 16 * Math.exp(-a * 3) * p.s + (a < 0.12 ? 10 * p.s : 0); }
+ c.save(); c.translate(sx, p.y + dy); c.rotate(rot); c.drawImage(p.img, -p.ax, -p.ay); c.restore(); }
+ // 光斑颤动(位置固定,亮度不规则明灭,10fps 横向小跳)
+ const st = Math.floor(t * 10); c.save(); c.lineCap = 'round';
+ for (let i = 0; i < M.glints.length; i++) { const gl = M.glints[i], sx = gl.x - camX; if (sx < -60 || sx > W + 60) continue;
+ const a = clamp(Math.sin(t * gl.f + gl.ph) * Math.sin(t * 2.3 + i), 0, 1); if (a < 0.12) continue;
+ const jx = (U.hash(i, st) - 0.5) * 8; c.strokeStyle = gl.col; c.globalAlpha = 0.85 * a; c.lineWidth = gl.w; c.beginPath(); c.moveTo(sx + jx, gl.y); c.lineTo(sx + jx + gl.l, gl.y + 1); c.stroke(); }
+ c.restore();
+ // 涟漪:断续的亮色短笔围成透视椭圆,一圈圈外扩
+ for (const h of hops) X.ripple(c, h.x - camX, h.y, t - h.t, h.s, h.big);
+ c.drawImage(M.bridge, M.x0 - camX, 0);
+};
+X.ripple = (c, x, y, a, s, big) => {
+ if (a < 0 || a > 2.0) return;
+ c.save(); c.lineCap = 'round';
+ for (let k = 0; k < (big ? 4 : 3); k++) { const ak = a - k * 0.16; if (ak <= 0) continue; const R = (22 + ak * (big ? 380 : 300)) * s, al = clamp(1 - ak / 1.6) * (1 - k * 0.15); if (al <= 0) continue;
+ const n = Math.max(10, Math.round(R / 7)); for (let i = 0; i < n; i++) { if (U.hash(i, k * 17 + 3) < 0.3) continue; const th = i / n * TAU + k * 0.4, th2 = th + TAU / n * 0.55;
+ c.strokeStyle = ['#ffffff', '#fffbe8', '#eef0ff'][(i + k) % 3]; c.globalAlpha = al; c.lineWidth = (9 - k * 1.4) * (0.5 + s * 0.6);
+ c.beginPath(); c.ellipse(x, y, R, R * 0.27, 0, th, th2); c.stroke(); } }
+ // 溅起的水花(短竖笔向上甩)
+ if (a < 0.1) { c.globalAlpha = 1 - a / 0.1; c.fillStyle = '#ffffff'; c.beginPath(); c.ellipse(x, y, 40 * s, 12 * s, 0, 0, TAU); c.fill(); }
+ if (a < 0.4) { const r = rng(Math.round(x * 7 + y)); for (let i = 0; i < (big ? 22 : 14); i++) { const ang = -Math.PI / 2 + (r() - 0.5) * 1.6, sp = (90 + r() * 150) * s * (big ? 1.6 : 1), q = a / 0.4;
+ const px = x + Math.cos(ang) * sp * a * 2.2, py = y + Math.sin(ang) * sp * a * 2.2 + 300 * a * a * s; c.globalAlpha = 1 - q; c.strokeStyle = i % 2 ? '#ffffff' : '#dfe8ff'; c.lineWidth = 6 * (0.5 + s * 0.6); c.beginPath(); c.moveTo(px, py); c.lineTo(px - Math.cos(ang) * 8 * s, py - Math.sin(ang) * 8 * s); c.stroke(); } }
+ c.restore();
+};
+X.monetFront = (c, M, camX, t, willows = []) => {
+ c.drawImage(M.nearRail, M.x0 - camX, 0);
+ // 前景柳条:从画面顶部垂下,成片摆动
+ c.save(); c.lineCap = 'round';
+ willows.forEach((wx, k) => { const sx = wx - camX; if (sx < -200 || sx > W + 200) return; const r = rng(80 + k);
+ for (let f = 0; f < 9; f++) { const fx = sx + (r() - 0.5) * 150, L = 260 + r() * 300, ph = r() * TAU;
+ for (let i = 0; i < 26; i++) { const q = i / 25, sw = Math.sin(t * 1.6 + ph + q * 2) * 26 * q * q, px = fx + sw + Math.sin(q * 5 + f) * 6, py = -10 + L * q;
+ c.strokeStyle = pick(['#6f9a40', '#9cbf58', '#4f7f3a', '#c0d070', '#3a6a5a'], r); c.lineWidth = 5; c.globalAlpha = 0.9; c.beginPath(); c.moveTo(px, py); c.lineTo(px + 4 + sw * 0.05, py + 14); c.stroke(); } } });
+ c.restore();
+};
+
+// ================= 打水漂 =================
+// plan: { t0, from:[x,y], hops:[{x,y,t,s}], sinkT, sinkS }
+X.stone = (t, plan) => {
+ if (t < plan.t0) return null;
+ const pts = [{ x: plan.from[0], y: plan.from[1], t: plan.t0, s: plan.s0 || 0.5 }].concat(plan.hops);
+ for (let i = 1; i < pts.length; i++) { const A = pts[i - 1], B = pts[i]; if (t <= B.t) { const q = (t - A.t) / (B.t - A.t);
+ const pk = i === 1 ? (plan.firstArc || 80) : (B.peak ?? 60) * (B.s ?? 1);
+ return { x: lerp(A.x, B.x, q), y: lerp(A.y, B.y, q) - 4 * pk * q * (1 - q), s: lerp(A.s, B.s, q), spin: t * 30 }; } }
+ return null;
+};
+X.drawStone = (c, st, trail) => { if (!st) return; const s = 1.2 + st.s * 1.4;
+ if (trail) { c.save(); c.lineCap = 'round'; for (let k = 1; k <= 6; k++) { const p = trail(k * 0.018); if (!p) break; c.strokeStyle = '#fffbea'; c.globalAlpha = 0.5 * (1 - k / 7); c.lineWidth = 9 * s * (1 - k / 8); c.beginPath(); c.moveTo(p.x, p.y); const q = trail((k - 1) * 0.018) || st; c.lineTo(q.x, q.y); c.stroke(); } c.restore(); }
+ c.save(); c.translate(st.x, st.y);
+ c.fillStyle = 'rgba(40,40,80,.3)'; c.beginPath(); c.ellipse(2, 4, 13 * s, 6 * s, 0, 0, TAU); c.fill();
+ c.fillStyle = '#4a4a6a'; c.beginPath(); c.ellipse(0, 0, 11 * s, 11 * s * Math.abs(Math.cos(st.spin)) * 0.5 + 3 * s, 0, 0, TAU); c.fill();
+ c.fillStyle = '#d8d8f0'; c.beginPath(); c.ellipse(-2 * s, -1.5 * s, 4.5 * s, 2 * s, 0, 0, TAU); c.fill(); c.restore(); };
+// 带拖尾地画石子:x 方向可传相机偏移
+X.stoneAt = (c, lt, plan, camX = 0) => { const sh = p => p ? { ...p, x: p.x - camX } : null; X.drawStone(c, sh(X.stone(lt, plan)), dt => sh(X.stone(lt - dt, plan))); };
+
+// ================= 青蛙(几何小动物,代码画;按画风上材质) =================
+const FROG = {};
+function frogImg(pose, style) {
+ const k = pose + style; if (FROG[k]) return FROG[k];
+ const cw = 200, ch = 160, cc = P.canvas(cw, ch), q = cc.getContext('2d'); q.translate(100, 110); q.lineJoin = 'round';
+ const body = style === 'vangogh' ? '#3f8a3a' : '#6aa84a', dark = style === 'vangogh' ? '#1f4a2a' : '#3f6a3a', belly = '#d8e8a0';
+ if (pose === 'leap') {
+ q.fillStyle = dark; q.beginPath(); q.ellipse(-62, 20, 38, 9, 0.3, 0, TAU); q.fill(); q.beginPath(); q.ellipse(-60, 34, 36, 8, 0.15, 0, TAU); q.fill();
+ q.fillStyle = body; q.beginPath(); q.ellipse(0, 0, 50, 26, -0.15, 0, TAU); q.fill();
+ q.fillStyle = belly; q.beginPath(); q.ellipse(4, 10, 32, 12, -0.15, 0, TAU); q.fill();
+ q.fillStyle = dark; q.beginPath(); q.ellipse(46, 18, 20, 7, 0.6, 0, TAU); q.fill();
+ [[28, -22], [8, -26]].forEach(([x, y]) => { q.fillStyle = body; q.beginPath(); q.arc(x, y, 13, 0, TAU); q.fill(); q.fillStyle = '#fbf6e0'; q.beginPath(); q.arc(x + 2, y - 1, 8, 0, TAU); q.fill(); q.fillStyle = '#1a1a2a'; q.beginPath(); q.arc(x + 4, y - 1, 4.5, 0, TAU); q.fill(); });
+ } else {
+ q.fillStyle = dark; q.beginPath(); q.ellipse(-30, 18, 34, 18, -0.2, 0, TAU); q.fill(); q.beginPath(); q.ellipse(30, 18, 34, 18, 0.2, 0, TAU); q.fill();
+ q.fillStyle = body; q.beginPath(); q.ellipse(0, -2, 46, 34, 0, 0, TAU); q.fill();
+ q.fillStyle = belly; q.beginPath(); q.ellipse(0, 12, 28, 16, 0, 0, TAU); q.fill();
+ q.fillStyle = dark; [[-18, 30], [18, 30]].forEach(([x, y]) => { q.beginPath(); q.ellipse(x, y, 10, 6, 0, 0, TAU); q.fill(); });
+ [[-20, -30], [20, -30]].forEach(([x, y]) => { q.fillStyle = body; q.beginPath(); q.arc(x, y, 15, 0, TAU); q.fill(); q.fillStyle = '#fbf6e0'; q.beginPath(); q.arc(x, y - 2, 9.5, 0, TAU); q.fill(); q.fillStyle = '#1a1a2a'; q.beginPath(); q.arc(x, y - 1, 5, 0, TAU); q.fill(); });
+ q.strokeStyle = '#2a3a2a'; q.lineWidth = 3; q.lineCap = 'round'; q.beginPath(); q.arc(0, -4, 16, 0.25, Math.PI - 0.25); q.stroke();
+ }
+ const out = P.canvas(cw, ch), og = out.getContext('2d'); og.drawImage(cc, 0, 0); og.globalCompositeOperation = 'source-atop';
+ const M = MAT[style] || MAT.monet;
+ X.strokes(og, cc, { cell: 5, len: style === 'vangogh' ? 12 : 9, width: 3.6, seed: 71, alphaMask: true, alphaMin: 120, outline: style === 'vangogh' ? 0.4 : 0, outlineCol: [20, 30, 60],
+ angle: (x, y, r) => (style === 'vangogh' ? Math.atan2(y - 110, x - 100) + Math.PI / 2 : -0.4) + (r() - 0.5) * 0.5, skip: (col) => lum(col) < 60 || lum(col) > 235,
+ palette: (x, y, col, r) => col[1] > col[0] + 20 ? P.mix(hx(pick(style === 'vangogh' ? ['#3f8a3a', '#6aaa40', '#2a6a4a', '#c8d040'] : ['#6aa84a', '#8ac060', '#4f8a4a', '#a8d070', '#5a9a8a'], r)), col, 0.35) : null });
+ out.ax = 100; out.ay = 128; FROG[k] = out; return out;
+}
+// x,y = 脚底;s = 缩放(1 ≈ 100px 宽);o.rot 旋转,o.croak 0..1 鸣囊鼓起
+X.frog = (c, x, y, s, pose, style, o = {}) => {
+ const im = frogImg(pose, style); c.save(); c.translate(x, y); c.rotate(o.rot || 0); c.scale(s * (o.flip ? -1 : 1), s * (o.sy || 1)); c.drawImage(im, -im.ax, -im.ay);
+ if (o.croak > 0) { c.fillStyle = 'rgba(240,236,190,0.92)'; c.beginPath(); c.ellipse(0, -14 + 26, 14 + 22 * o.croak, 8 + 15 * o.croak, 0, 0, TAU); c.fill(); c.strokeStyle = 'rgba(120,130,80,.6)'; c.lineWidth = 2; c.stroke(); }
+ c.restore();
+};
+
+// ================= 浮世绘:海岸、富士、巨浪 =================
+const INK = '#1c1a1e';
+const uF = (g, path, fill, lw = 2.6) => { if (fill) { g.save(); g.translate(3, 2); g.fillStyle = fill; g.fill(path); g.restore(); } if (lw) { g.strokeStyle = INK; g.lineWidth = lw; g.stroke(path); } };
+const poly = pts => { const p = new Path2D(); pts.forEach((q, i) => i ? p.lineTo(q[0], q[1]) : p.moveTo(q[0], q[1])); p.closePath(); return p; };
+X.ukiyoeWorld = (o) => {
+ const key = 'uw_' + o.key; if (X[key]) return X[key];
+ const w = o.w, x0 = o.x0, G = o.groundY, SEA = o.sea || 560;
+ const c = P.canvas(w, H), g = c.getContext('2d');
+ const sg = g.createLinearGradient(0, 0, 0, SEA); sg.addColorStop(0, '#2c4a80'); sg.addColorStop(0.1, '#4a6a98'); sg.addColorStop(0.3, '#e8d8a0'); sg.addColorStop(0.75, '#f2dc96'); sg.addColorStop(1, '#f3c98a');
+ g.fillStyle = sg; g.fillRect(0, 0, w, SEA);
+ const r = rng(41); for (let i = 0; i < w * 0.3; i++) { const y = r() * SEA; g.strokeStyle = y < 90 ? `rgba(30,50,110,${0.06 + r() * 0.1})` : `rgba(140,90,40,${0.03 + r() * 0.05})`; g.lineWidth = 1 + r() * 2; g.beginPath(); g.moveTo(r() * w, y); g.lineTo(r() * w, y + (r() - 0.5) * 3); g.stroke(); }
+ // 富士
+ (o.fuji || []).forEach(fx => { const lx = fx - x0; uF(g, poly([[lx - 230, SEA], [lx - 30, SEA - 230], [lx + 30, SEA - 232], [lx + 240, SEA]]), '#26467e', 2.4);
+ uF(g, poly([[lx - 70, SEA - 190], [lx - 30, SEA - 230], [lx + 30, SEA - 232], [lx + 72, SEA - 192], [lx + 50, SEA - 196], [lx + 34, SEA - 176], [lx + 16, SEA - 196], [lx - 4, SEA - 172], [lx - 24, SEA - 196], [lx - 46, SEA - 180]]), '#fbf8ee', 1.8); });
+ // 远海
+ g.save(); g.translate(3, 2); g.fillStyle = '#18305e'; g.fillRect(0, SEA, w, G - 40 - SEA); g.restore();
+ g.strokeStyle = INK; g.lineWidth = 2.4; g.beginPath(); g.moveTo(0, SEA); g.lineTo(w, SEA); g.stroke();
+ // 岸
+ const shore = new Path2D(); shore.moveTo(0, G - 30); for (let x = 0; x <= w; x += 40) shore.lineTo(x, G - 30 + Math.sin(x * 0.013) * 8); shore.lineTo(w, H); shore.lineTo(0, H); shore.closePath();
+ uF(g, shore, '#e8c890', 3);
+ g.save(); g.clip(shore); for (let i = 0; i < w * 0.05; i++) { const x = r() * w, y = G + r() * (H - G); g.fillStyle = 'rgba(150,100,50,.25)'; g.beginPath(); g.ellipse(x, y, 3 + r() * 6, 1.5 + r() * 2, 0, 0, TAU); g.fill(); }
+ const pg = g.createLinearGradient(0, G + 120, 0, H); pg.addColorStop(0, 'rgba(160,120,70,0)'); pg.addColorStop(1, 'rgba(160,120,70,.35)'); g.fillStyle = pg; g.fillRect(0, G, w, H - G); g.restore();
+ g.strokeStyle = INK; g.lineWidth = 2; for (let x = 20; x < w; x += 140) { g.beginPath(); g.moveTo(x, G + 70 + (x % 3) * 30); g.quadraticCurveTo(x + 40, G + 64 + (x % 3) * 30, x + 80, G + 72 + (x % 3) * 30); g.stroke(); }
+ // 松
+ (o.pines || []).forEach(px => { const lx = px - x0; const trunk = poly([[lx - 14, G - 20], [lx - 30, G - 200], [lx + 10, G - 330], [lx + 60, G - 400], [lx + 40, G - 330], [lx + 12, G - 200], [lx + 14, G - 20]]); uF(g, trunk, '#8a4a2a', 2.6);
+ [[lx - 60, G - 260, 90], [lx + 80, G - 400, 110], [lx - 10, G - 360, 80], [lx + 120, G - 300, 70]].forEach(([x, y, rr]) => { const p = new Path2D(); p.ellipse(x, y, rr, rr * 0.32, -0.08, 0, TAU); uF(g, p, '#2f5a3a', 2.4); g.strokeStyle = 'rgba(20,40,30,.6)'; g.lineWidth = 1.4; for (let k = -rr + 10; k < rr - 10; k += 12) { g.beginPath(); g.moveTo(x + k, y - 6); g.lineTo(x + k + 6, y + 8); g.stroke(); } }); });
+ // 纸纹罩层
+ const ov = P.canvas(w, H), og = ov.getContext('2d'); const ro = rng(5);
+ for (let i = 0; i < w * 0.7; i++) { const y = ro() * H, x = ro() * w, L = 200 + ro() * 700; og.strokeStyle = `rgba(120,80,40,${0.025 + ro() * 0.04})`; og.lineWidth = 1 + ro(); og.beginPath(); og.moveTo(x, y); og.lineTo(x + L, y + (ro() - 0.5) * 6); og.stroke(); }
+ for (let i = 0; i < w * 1.2; i++) { const x = ro() * w, y = ro() * H; og.strokeStyle = ro() < 0.5 ? 'rgba(255,250,235,.12)' : 'rgba(90,60,30,.07)'; og.lineWidth = 1; og.beginPath(); og.arc(x, y, 3 + ro() * 6, ro() * 6, ro() * 6 + 1); og.stroke(); }
+ return X[key] = { o, bg: c, over: ov, x0, w, G, SEA };
+};
+// 巨浪(每帧):浪身+内侧流线(虚线前移)+白沫带+浪爪屈伸+飞沫
+X.greatWave = (c, bx, by, S, t) => {
+ c.save(); c.translate(bx, by); c.scale(S, S); c.lineCap = 'round'; c.lineJoin = 'round';
+ const k = Math.sin(t * 2.4) * 0.5 + 0.5; // 浪唇前卷程度
+ const back = K => KIT.densify(K, 6);
+ const O = back([[-420, 0], [-300, -90], [-190, -220], [-80, -350], [40, -430], [150, -432 + k * 8], [240, -380 + k * 14], [282 + k * 30, -300 + k * 34]]);
+ const tip = O[O.length - 1];
+ const I = back([tip, [220 + k * 12, -290 + k * 20], [150, -300], [100, -250], [96, -160], [130, -70], [220, 0]]);
+ const body = new Path2D(); O.forEach((p, i) => i ? body.lineTo(p[0], p[1]) : body.moveTo(p[0], p[1])); I.forEach(p => body.lineTo(p[0], p[1])); body.closePath();
+ uF(c, body, '#26467e', 3.2);
+ // 浪身流线:沿背面轮廓向内偏移,虚线往浪顶涌
+ c.save(); c.clip(body); c.setLineDash([30, 16]); c.lineDashOffset = -t * 140;
+ for (let m = 1; m < 9; m++) { c.strokeStyle = m % 2 ? 'rgba(150,182,226,.9)' : 'rgba(236,242,250,.8)'; c.lineWidth = 7; c.beginPath();
+ O.forEach((p, i) => { const q = i / (O.length - 1); const x = p[0] + m * 26 * (0.4 + q) , y = p[1] + m * 30 * (1 - q * 0.6); i ? c.lineTo(x, y) : c.moveTo(x, y); }); c.stroke(); }
+ c.restore(); c.setLineDash([]);
+ // 白沫带(沿浪背上段)
+ const top = O.slice(Math.floor(O.length * 0.35));
+ c.strokeStyle = INK; c.lineWidth = 40; c.beginPath(); top.forEach((p, i) => i ? c.lineTo(p[0], p[1]) : c.moveTo(p[0], p[1])); c.stroke();
+ c.strokeStyle = '#fbf7ec'; c.lineWidth = 35; c.stroke();
+ // 浪爪:沿浪唇外缘一簇簇胖手指,指向前下方并向内卷
+ const claw = (x, y, ang, L, kk) => { const lens = [1, 0.66, 0.56, 0.42], offs = [0, -0.6, 0.45, -0.25];
+ for (let f = 0; f < 4; f++) { let a = ang + offs[f], px = x, py = y; const LL = L * lens[f], pts = [[px, py]], cv = 1.1 + Math.sin(t * 5 + kk * 0.9) * 0.6;
+ for (let s2 = 0; s2 < 7; s2++) { a += cv * 0.34 * (0.5 + s2 / 7) / 2.4; px += Math.cos(a) * LL / 7; py += Math.sin(a) * LL / 7; pts.push([px, py]); }
+ [[LL * 0.32 + 4, INK], [LL * 0.32, '#fbf7ec'], [LL * 0.1, '#9ab0c8']].forEach(([lw, col]) => { c.strokeStyle = col; c.lineWidth = lw; c.beginPath(); pts.forEach((p, i) => i ? c.lineTo(p[0], p[1]) : c.moveTo(p[0], p[1])); c.stroke(); }); } };
+ const lipStart = Math.floor(O.length * 0.55);
+ for (let j = lipStart, kk = 0; j < O.length; j += 3, kk++) { const p = O[j], q = O[Math.max(0, j - 1)]; const nx = p[1] - q[1], ny = -(p[0] - q[0]); const a = Math.atan2(ny, nx) * -1; claw(p[0], p[1], Math.atan2(-(p[0] - q[0]), (p[1] - q[1])) + 0.6, 60 + (kk % 3) * 16, kk); }
+ for (let j = 0, kk = 20; j < 4; j++, kk++) { const p = I[1 + j]; claw(p[0], p[1], 1.3, 46, kk); }
+ // 飞沫(北斋的「雪」)
+ const r = rng(13); c.fillStyle = '#fbf7ec'; c.strokeStyle = INK; c.lineWidth = 1.6;
+ for (let i = 0; i < 40; i++) { const ph = (t * 0.7 + r()) % 1, x = tip[0] - 20 + r() * 150 + ph * 90, y = tip[1] - 30 - r() * 90 + ph * ph * 260, rr = 2.5 + r() * 4; c.globalAlpha = 1 - ph * 0.7; c.beginPath(); c.arc(x, y, rr, 0, TAU); c.fill(); c.stroke(); }
+ c.restore();
+};
+// 近海浪纹(每帧平移)
+X.seaLines = (c, x0, y0, w, h, t) => { c.save(); c.beginPath(); c.rect(x0, y0, w, h); c.clip(); c.strokeStyle = 'rgba(230,236,245,.85)'; c.lineWidth = 3; const r = rng(3);
+ for (let k = 0; k < 9; k++) { const y = y0 + 12 + k * (h / 9), off = (t * 40 * (k % 2 ? 1 : -0.6)) % 120; for (let x = x0 - 120 + off + r() * 60; x < x0 + w; x += 120) { c.beginPath(); c.arc(x, y + 10, 22, Math.PI * 1.1, Math.PI * 1.9); c.stroke(); } } c.restore(); };
+
+// ================= 梵高:星月夜 =================
+X.vgWorld = (o) => {
+ const key = 'vg_' + o.key; if (X[key]) return X[key];
+ const w = o.w, x0 = o.x0, G = o.groundY, HOR = o.horizon || 600;
+ const stars = []; const rs = rng(17); for (let x = 120; x < w; x += 200 + rs() * 140) { const sx = x0 + x; if ((o.cypress || []).some(cx => Math.abs(cx - sx) < 160)) continue; stars.push({ x: sx, y: 70 + rs() * 360, r: 16 + rs() * 16 }); }
+ const swirls = (o.swirls || []).map(([x, y, R]) => ({ x, y, R }));
+ const moon = o.moon;
+ const angleSky = (wx, y) => { let a = 0.15 * Math.sin(wx * 0.004 + y * 0.01);
+ for (const s of swirls) { const dx = wx - s.x, dy = (y - s.y) * 1.6, d = Math.hypot(dx, dy); const f = Math.exp(-Math.pow(d / s.R, 2) * 0.8); a = lerp(a, Math.atan2(dy, dx) + Math.PI / 2, f); }
+ for (const s of stars.concat(moon ? [{ x: moon[0], y: moon[1], r: 60 }] : [])) { const dx = wx - s.x, dy = y - s.y, d = Math.hypot(dx, dy); if (d < s.r * 3.2) a = Math.atan2(dy, dx) + Math.PI / 2; }
+ return a; };
+ const base = P.canvas(w, H), g = base.getContext('2d');
+ const sg = g.createLinearGradient(0, 0, 0, HOR); sg.addColorStop(0, '#13246a'); sg.addColorStop(0.5, '#25479e'); sg.addColorStop(1, '#5a7ec0'); g.fillStyle = sg; g.fillRect(0, 0, w, HOR + 40);
+ swirls.forEach(s => { g.strokeStyle = '#9ab8e0'; g.lineWidth = 46; g.beginPath(); for (let a = 0; a < TAU * 1.4; a += 0.1) { const rr = s.R * (0.3 + a / (TAU * 1.4) * 0.7); g.lineTo(s.x - x0 + Math.cos(a) * rr, s.y + Math.sin(a) * rr / 1.6); } g.stroke(); });
+ stars.forEach(s => { const rg = g.createRadialGradient(s.x - x0, s.y, 0, s.x - x0, s.y, s.r * 2.6); rg.addColorStop(0, '#fff8c0'); rg.addColorStop(0.35, '#f0e070'); rg.addColorStop(0.6, '#c8d8a0'); rg.addColorStop(1, 'rgba(90,126,192,0)'); g.fillStyle = rg; g.beginPath(); g.arc(s.x - x0, s.y, s.r * 2.6, 0, TAU); g.fill(); });
+ if (moon) { const rg = g.createRadialGradient(moon[0] - x0, moon[1], 0, moon[0] - x0, moon[1], 150); rg.addColorStop(0, '#fff0a0'); rg.addColorStop(0.4, '#f0c840'); rg.addColorStop(0.7, '#e8d080'); rg.addColorStop(1, 'rgba(90,126,192,0)'); g.fillStyle = rg; g.beginPath(); g.arc(moon[0] - x0, moon[1], 150, 0, TAU); g.fill(); }
+ // 远山、村庄
+ g.fillStyle = '#2a3a78'; g.beginPath(); g.moveTo(0, HOR); for (let x = 0; x <= w; x += 30) g.lineTo(x, HOR - 70 - Math.sin(x * 0.004 + 1) * 50 - Math.sin(x * 0.011) * 20); g.lineTo(w, HOR + 60); g.lineTo(0, HOR + 60); g.fill();
+ const rv = rng(23); for (let x = 30; x < w; x += 46 + rv() * 30) { const hh = 26 + rv() * 30, y = HOR + 10 + rv() * 30; g.fillStyle = pick(['#3a4a6a', '#4a5a8a', '#5a6a5a'], rv); g.fillRect(x, y - hh, 40, hh); g.fillStyle = '#2a3058'; g.beginPath(); g.moveTo(x - 4, y - hh); g.lineTo(x + 20, y - hh - 18); g.lineTo(x + 44, y - hh); g.fill(); if (rv() < 0.6) { g.fillStyle = '#f8d850'; g.fillRect(x + 12, y - hh + 8, 10, 10); } }
+ g.fillStyle = '#3a5a3a'; g.fillRect(0, HOR + 50, w, G - HOR - 50);
+ const pg = g.createLinearGradient(0, G - 30, 0, H); pg.addColorStop(0, '#8a8a3a'); pg.addColorStop(0.3, '#c8a040'); pg.addColorStop(1, '#7a6a3a'); g.fillStyle = pg; g.fillRect(0, G - 30, w, H - G + 30);
+ (o.cypress || []).forEach(cx => { const lx = cx - x0; g.fillStyle = '#1e2e1e'; g.beginPath(); g.moveTo(lx - 70, G + 10); g.bezierCurveTo(lx - 90, G - 300, lx - 30, G - 500, lx + 6, G - 760); g.bezierCurveTo(lx + 40, G - 520, lx + 90, G - 300, lx + 70, G + 10); g.fill(); });
+ const out = P.canvas(w, H), oc = out.getContext('2d'); oc.drawImage(base, 0, 0);
+ const isCyp = (lx, y) => (o.cypress || []).some(cx => Math.abs(lx + x0 - cx) < 80 * (0.2 + (y - (G - 760)) / 760) && y > G - 760 && y < G + 10);
+ X.strokes(oc, base, { cell: 10, len: 28, width: 7, seed: 51, outline: 0.5, outlineCol: [16, 22, 70], jitterCol: 16,
+ angle: (lx, y, r) => isCyp(lx, y) ? -Math.PI / 2 + Math.sin(y * 0.03) * 0.5 : y < HOR + 20 ? angleSky(lx + x0, y) : y < G - 30 ? Math.sin(lx * 0.02) * 0.4 : 0.2 * Math.sin(lx * 0.01 + y * 0.02),
+ palette: (lx, y, col, r) => { const L = lum(col);
+ if (isCyp(lx, y)) return P.mix(hx(pick(['#1e3a24', '#2a4a2a', '#3a5a2a', '#14241a', '#4a6a3a'], r)), col, 0.3);
+ if (y < HOR + 20) { if (L > 180) return P.mix(hx(pick(['#fff8c0', '#f0e070', '#f8d850', '#e8f0d0'], r)), col, 0.4); if (L > 120) return P.mix(hx(pick(['#9ab8e0', '#c8d8f0', '#e8e8c0', '#6a8ad0'], r)), col, 0.4); return P.mix(hx(pick(['#1e3a8a', '#2a52a8', '#3a6ac0', '#5a86d0', '#1a2a6a', '#3a4aa0'], r)), col, 0.4); }
+ if (y > G - 30) return P.mix(hx(pick(['#c8a040', '#e0b850', '#8a7a3a', '#a89a4a', '#6a7a3a'], r)), col, 0.4);
+ return null; } });
+ return X[key] = { o, bg: out, x0, w, G, stars, moon, swirls, angleSky };
+};
+// 星空的动:星晕环旋转、漩涡带上的短笔沿螺线流动
+X.vgSky = (c, V, camX, t) => {
+ c.save(); c.lineCap = 'round';
+ V.stars.forEach((s, k) => { const sx = s.x - camX; if (sx < -150 || sx > W + 150) return; const pul = 1 + 0.12 * Math.sin(t * 3 + k);
+ for (let ring = 0; ring < 2; ring++) { const R = s.r * (1.5 + ring * 0.8) * pul, n = 16 + ring * 6; for (let i = 0; i < n; i++) { const a = i / n * TAU + t * (0.8 - ring * 0.3) * (k % 2 ? 1 : -1);
+ c.strokeStyle = ring ? '#c8d8a0' : '#fff2a0'; c.lineWidth = 5; c.globalAlpha = 0.85; c.beginPath(); c.arc(sx, s.y, R, a, a + 0.22); c.stroke(); } } });
+ V.swirls.forEach((s, k) => { const sx = s.x - camX; if (sx < -s.R * 1.5 || sx > W + s.R * 1.5) return;
+ for (let i = 0; i < 60; i++) { const q = ((i / 60) + t * 0.12) % 1, a = q * TAU * 1.4, rr = s.R * (0.3 + q * 0.7), x = sx + Math.cos(a) * rr, y = s.y + Math.sin(a) * rr / 1.6, ta = a + Math.PI / 2;
+ c.strokeStyle = ['#e8f0ff', '#c8d8f0', '#fff8d0'][i % 3]; c.lineWidth = 6; c.globalAlpha = 0.8 * Math.sin(q * Math.PI); c.beginPath(); c.moveTo(x - Math.cos(ta) * 14, y - Math.sin(ta) * 9); c.lineTo(x + Math.cos(ta) * 14, y + Math.sin(ta) * 9); c.stroke(); } });
+ if (V.moon) { const sx = V.moon[0] - camX; c.globalAlpha = 1; c.fillStyle = '#ffe680'; c.beginPath(); c.arc(sx, V.moon[1], 52, 0, TAU); c.fill(); c.fillStyle = '#e8a830'; c.beginPath(); c.arc(sx + 22, V.moon[1] - 12, 46, 0, TAU); c.fill();
+ for (let i = 0; i < 24; i++) { const a = i / 24 * TAU - t * 0.5, R = 90 + 8 * Math.sin(t * 2 + i); c.strokeStyle = '#f8e070'; c.lineWidth = 6; c.globalAlpha = 0.75; c.beginPath(); c.arc(sx, V.moon[1], R, a, a + 0.18); c.stroke(); } }
+ c.restore();
+};
+
+// ================= 画风颜料迸散(跳进/跳出画框、跨边界时用) =================
+X.burst = (c, x, y, a, R, style, seed = 1) => { if (a < 0 || a > 1) return; const r = rng(seed), cols = style === 'monet' ? ['#f2a6bf', '#9db5e0', '#9cc070', '#fff2d4', '#b7a6d8', '#8fdcae'] : ['#f8d850', '#2a52a8', '#fff8c0', '#5a86d0'];
+ c.save(); c.lineCap = 'round'; for (let i = 0; i < 70; i++) { const ang = r() * TAU, sp = R * (0.4 + r() * 0.8), d = sp * U.ease.out(a), x1 = x + Math.cos(ang) * d, y1 = y + Math.sin(ang) * d * 0.8 + 120 * a * a;
+ c.strokeStyle = cols[i % cols.length]; c.globalAlpha = 1 - a; c.lineWidth = 7 + r() * 6; c.beginPath(); c.moveTo(x1, y1); c.lineTo(x1 + Math.cos(ang) * 16, y1 + Math.sin(ang) * 10); c.stroke(); } c.restore(); };
+})();
diff --git a/scripts/engine/demos/long_scroll/lib/world.js b/scripts/engine/demos/long_scroll/lib/world.js
new file mode 100644
index 0000000..44d28d9
--- /dev/null
+++ b/scripts/engine/demos/long_scroll/lib/world.js
@@ -0,0 +1,143 @@
+// 全片骨架:一条长画卷,N 个世界段首尾相接,花叔从左走到右(横向长卷)。
+// 每个世界段是一个文件 segments/<id>.js,调用 WORLD.add({...});本文件负责:时间轴、主角行进、相机、画风边界、按边界裁开的主角、帽子上的收藏品。
+//
+// 段的接口(坐标都是「段内世界坐标」:x 从 0 到 w,地面线 GROUND=760 是全片统一的,跨边界时脚底在同一高度):
+// WORLD.add({
+// id: '10_monet', year: 1899, name: '莫奈《睡莲》', // 角标:年份+名
+// w: 2400, // 段宽(世界 px),≥ 1900;含走路与互动的空间
+// hero: { walk: 'monet_walk', mat: 'monet', h: 300 }, // 走路帧库(demos/long_scroll/frames/<key>/),材质(XING.actor 的 mat),站立身高
+// acts: [ { at: 1100, dur: 1.6, key: 'monet_throw', frame: u => 帧号, y: lx => 脚底y(可选) } ], // 在段内 x=at 处停下做互动,dur 秒;frame(u) 返回该动作帧库的帧号(u=动作内秒)
+// ground: lx => y, // 可选:地面高度函数(桥面、台阶),两端必须回到 GROUND
+// back(c, s), front(c, s), // 画背景/前景。s = { camX(段内), t(全片秒), lt(进段后秒), hx(主角段内x), hy, act:{i, u}|null, W:1920, H:1080 }
+// // c 已经裁在本段的带里;世界坐标到屏幕 = lx - s.camX
+// seam(c, y, sx, t), // 可选:进入本段的那条边界怎么画(本段的签名语言:纸边、浪花、金箔、像素…),sx = 边界在屏幕上的 x
+// item: { draw(c, x, y, s, t) , gotAt: 段内秒 } // 本段送给帽子的收藏品(用本段画风画),从 gotAt 起出现在帽子上,之后跟着他穿越所有世界
+// });
+// 预览:index.html?film=demos/long_scroll&only=28_monet,14_8bit 只排这几段(世界从 0 开始);?from=秒
+(() => {
+const W = 1920, H = 1080, { clamp, lerp, ss } = U;
+const WD = window.WORLD = { segs: [], GROUND: 760, V: +(new URLSearchParams(location.search).get('v') || 560), HERO_H: 300 }; // 步速:?v=560 可试更快的全片节奏
+WD.add = seg => { WD.segs.push(seg); };
+WD.START_X = 320; // 开场主角从段内 x=320 起步(画面左侧留出世界)
+
+// 布局:按 FILM_ORDER(demos/long_scroll/eras.js 里)排;?only= 过滤
+WD.layout = () => {
+ const q = new URLSearchParams(location.search), only = q.get('only');
+ let segs = (window.FILM_ORDER || WD.segs.map(s => s.id)).map(id => WD.segs.find(s => s.id === id)).filter(Boolean);
+ if (only) { const set = only.split(','); segs = segs.filter(s => set.includes(s.id)); }
+ let x = 0, t = 0; const plan = [];
+ for (const s of segs) {
+ s.x0 = x; s.x1 = x + s.w;
+ // 主角时间表:段内按 acts 切成「走→停做动作→走」
+ const acts = (s.acts || []).slice().sort((a, b) => a.at - b.at); let lx = plan.length ? 0 : Math.min(WD.START_X, (acts[0] ? acts[0].at : s.w) - 60); // 开场主角从画内起步,第 0 帧整个人可见(v1 审片:开头只露半个身子)
+ s.tIn = t;
+ for (const a of acts) { t += (a.at - lx) / (a.v || s.v || WD.V); plan.push({ seg: s, kind: 'walk', t0: t - (a.at - lx) / (a.v || s.v || WD.V), t1: t, x0: x + lx, x1: x + a.at });
+ plan.push({ seg: s, kind: 'act', act: a, t0: t, t1: t + a.dur, x0: x + a.at, x1: x + a.at + (a.dx || 0) }); t += a.dur; lx = a.at + (a.dx || 0); }
+ const tw = (s.w - lx) / (s.v || WD.V); plan.push({ seg: s, kind: 'walk', t0: t, t1: t + tw, x0: x + lx, x1: x + s.w }); t += tw;
+ s.tOut = t; x += s.w;
+ }
+ WD.plan = plan; WD.total = t + (window.FILM_TAIL || 0); WD.active = segs; return WD;
+};
+WD.heroAt = t => {
+ const p = WD.plan.find(q => t >= q.t0 && t < q.t1) || WD.plan[WD.plan.length - 1];
+ const u = clamp((t - p.t0) / Math.max(1e-6, p.t1 - p.t0));
+ const x = lerp(p.x0, p.x1, p.kind === 'walk' ? u : (p.act.move ? p.act.move(u) : u));
+ return { x, p, u: t - p.t0 };
+};
+const segAt = x => WD.active.find(s => x >= s.x0 && x < s.x1) || WD.active[WD.active.length - 1];
+// 边界线:轻微波浪(每条边界相位不同)
+WD.seamX = (s, y) => s.x0 + 22 * Math.sin(y * 0.011 + s.x0 * 0.001) + 8 * Math.sin(y * 0.047 + s.x0 * 0.003);
+const band = (c, a, b, camX) => { c.beginPath();
+ for (let y = -10; y <= H + 10; y += 20) c.lineTo(a ? WD.seamX(a, y) - camX : -60, y);
+ for (let y = H + 10; y >= -10; y -= 20) c.lineTo(b ? WD.seamX(b, y) - camX : W + 60, y);
+ c.closePath(); c.clip(); };
+
+WD.draw = (c, t) => {
+ if (!WD.plan) WD.layout();
+ const hero = WD.heroAt(t), hs = segAt(hero.x);
+ // 相机:主角在画面左 38%,做动作时镜头往前让出空间(act.lead 可调),平滑
+ const camX = WD.camAt(t);
+ const vis = WD.active.filter(s => s.x1 > camX - 80 && s.x0 < camX + W + 80);
+ const ctxFor = s => ({ camX: camX - s.x0, t, lt: t - s.tIn, hx: hero.x - s.x0, act: hero.p.seg === s && hero.p.kind === 'act' ? { a: hero.p.act, u: hero.u } : null, W, H, G: WD.GROUND });
+ // 背景
+ for (const s of vis) { const k = WD.active.indexOf(s), nx = WD.active[k + 1]; c.save(); band(c, k ? s : null, nx, camX); s.back(c, ctxFor(s)); c.restore(); }
+ // 主角:按边界裁开,每段用自己的画风帧
+ for (const s of vis) {
+ if (hero.x < s.x0 - 200 || hero.x > s.x1 + 200) continue;
+ const k = WD.active.indexOf(s), nx = WD.active[k + 1], S = ctxFor(s);
+ c.save(); band(c, k ? s : null, nx, camX);
+ WD.drawHero(c, s, S, hero);
+ c.restore();
+ }
+ // 前景
+ for (const s of vis) { if (!s.front) continue; const k = WD.active.indexOf(s), nx = WD.active[k + 1]; c.save(); band(c, k ? s : null, nx, camX); s.front(c, ctxFor(s)); c.restore(); }
+ // 边界本身(属于进入的那一段)
+ for (const s of vis) { const k = WD.active.indexOf(s); if (!k) continue; c.save(); for (let y = -10; y < H + 10; y += 6) { const sx = WD.seamX(s, y) - camX; if (sx < -120 || sx > W + 120) break; if (s.seam) s.seam(c, y, sx, t); else { c.fillStyle = '#f4ead2'; c.fillRect(sx - 6, y, 8 + U.hash(y, 3) * 6, 7); } } c.restore(); }
+ // 跨边界的颜料迸散
+ for (const s of WD.active) { const k = WD.active.indexOf(s); if (!k) continue; const tc = WD.crossT(s); const a = (t - tc) / 0.5; if (a > 0 && a < 1 && XING.burst) XING.burst(c, s.x0 - camX, WD.GROUND - WD.HERO_H * 0.5, a, 160, s.burst || 'monet', k + 3); }
+ // 角标:年份+名(随所在段切换,切换时淡入)
+ if (window.FILM_LABEL !== false) WD.label(c, hs, t);
+};
+// 相机:只进不退(v1 审片:互动结尾镜头往回收 68–256px,17 段都有,读成「倒带」)。
+// 目标 = 主角 x − 720 + 互动时向前让出的 lead(只升不降);取历史最大值保证单调;再做高斯平滑(单调信号卷积正核仍单调),停与起都不顿。
+WD.camAt = t => {
+ if (!WD._cam) {
+ const R = 120, n = Math.ceil(WD.total * R) + 2, raw = new Float64Array(n), last = WD.active[WD.active.length - 1];
+ let mx = -1e9;
+ for (let k = 0; k < n; k++) { const tt = k / R, h = WD.heroAt(tt);
+ const lead = h.p.kind === 'act' ? (h.p.act.lead ?? 160) * ss(0, 0.6, h.u) : 0;
+ mx = Math.max(mx, h.x - 720 + lead); raw[k] = mx; }
+ const sig = 0.14 * R, K = Math.ceil(sig * 3), ker = []; let ks = 0; for (let j = -K; j <= K; j++) { const w = Math.exp(-j * j / (2 * sig * sig)); ker.push(w); ks += w; }
+ const sm = new Float64Array(n);
+ for (let k = 0; k < n; k++) { let a = 0; for (let j = -K; j <= K; j++) a += ker[j + K] * raw[clamp(k + j, 0, n - 1)]; sm[k] = clamp(a / ks, 0, Math.max(0, last.x1 - W)); }
+ WD._cam = { R, sm };
+ }
+ const { R, sm } = WD._cam, f = clamp(t * R, 0, sm.length - 1), k = Math.floor(f), u = f - k;
+ return sm[k] + (sm[Math.min(k + 1, sm.length - 1)] - sm[k]) * u;
+};
+WD.crossT = s => { const p = WD.plan.find(q => q.seg === s); return p ? p.t0 : 0; };
+// 第 k 个互动开始的全片时刻(段里的事件请用它或 s.act.u 定时,不要写死「进段后第几秒」——全片步速会在合成时统一调整)
+WD.actT = (s, k = 0) => { const ps = WD.plan.filter(q => q.seg === s && q.kind === 'act'); return ps[k] ? ps[k].t0 : s.tIn; };
+// 纪念品落帽时刻:item.atAct = 互动开始后第几秒(推荐);旧写法 item.gotAt = 进段后第几秒(步速变了会错位)
+WD.itemT = g => g.item.atAct != null ? WD.actT(g, g.item.act || 0) + g.item.atAct : g.tIn + (g.item.gotAt ?? (g.tOut - g.tIn) * 0.7);
+
+// 主角:画风帧+帽子上的收藏品
+WD.drawHero = (c, s, S, hero) => {
+ const H0 = s.hero || {}, h = H0.h || WD.HERO_H, lx = hero.x - s.x0;
+ const gy = (hero.p.kind === 'act' && hero.p.act.y) ? hero.p.act.y(lx, hero.u) : (s.ground ? s.ground(lx) : WD.GROUND);
+ let key = H0.walk, i;
+ const walked = WD.plan.filter(q => q.kind === 'walk' && q.t0 <= S.t).reduce((a, q) => a + Math.min(S.t, q.t1) - q.t0, 0);
+ if (hero.p.kind === 'act' && hero.p.seg === s) { key = hero.p.act.key || H0.walk; i = hero.p.act.frame ? hero.p.act.frame(hero.u) : 0; }
+ else { const n = XING.nFrames(key); i = Math.floor(walked * (H0.fps || 8.5) * WD.V / 330) % n; } // 步频随步速同比例 // 步频:8.5 帧/秒,同一相位跨边界
+ const o = { x: hero.x - S.camX - s.x0 + s.x0 - s.x0, y: gy, h, mat: H0.mat || 'none', t: S.t, wx: hero.x, shadow: H0.shadow ?? 'rgba(0,0,0,.14)', flip: H0.flip };
+ o.x = lx - S.camX;
+ if (H0.draw) H0.draw(c, key, i, o, S); else XING.actor(c, key, i, o);
+ // 收藏品:按获得顺序叠在帽顶;每件用它来自的那个世界的画风画(纪念品集合)
+ // 段可以接管:s.hideHatItems(S) 返回 true 时这里不画(帽子被叫飞、摘帽放桌上时由段自己画,用 WD.drawHatStack)
+ if (window.FILM_HAT_ITEMS !== true) return; // 帽上纪念品默认关闭,保持角色轮廓清晰
+ if (s.hideHatItems && s.hideHatItems(S)) return;
+ const [tx, ty] = XING.hatTop(key, i, o); WD.drawHatStack(c, tx, ty + 4, h, S.t);
+};
+// 在 (x, y) 处从下往上画到时刻 t 为止已获得的全部纪念品;返回堆顶 y。段接管帽子时调用它(例如帽子飞起时,传帽子的位置)
+WD.drawHatStack = (c, tx, y, h, t, rot = 0) => {
+ c.save(); c.translate(tx, y); c.rotate(rot); y = 0; tx = 0; const S = { t };
+ for (const g of WD.active) { if (!g.item) continue; const tg = WD.itemT(g); if (S.t < tg) continue;
+ const pop = ss(tg, tg + 0.25, S.t), sc = (g.item.s || 1) * (0.6 + 0.4 * pop) * h / 300;
+ const wob = Math.sin(S.t * 6 + g.x0) * 2 * ss(tg, tg + 0.3, S.t);
+ c.save(); c.translate(tx + wob, y); g.item.draw(c, 0, 0, sc, S.t); c.restore();
+ y -= (g.item.hgt || 26) * sc; }
+ c.restore(); return y;
+};
+
+WD.label = (c, s, t) => {
+ const a = ss(s.tIn, s.tIn + 0.35, t); if (!s.year) return;
+ const yr = typeof s.year === 'number' ? (s.year < 0 ? `${-s.year} BC` : String(s.year)) : s.year;
+ c.save(); c.globalAlpha = a; c.textAlign = 'right'; c.textBaseline = 'alphabetic';
+ c.font = '600 54px "Poppins-700", sans-serif'; const w1 = c.measureText(yr).width;
+ c.font = '30px "LXGWWenKai-500", sans-serif'; const w2 = c.measureText(s.name || '').width;
+ const bw = Math.max(w1, w2) + 48; // 半透明纸片底:跨世界时角标始终可读(审片建议)
+ c.fillStyle = 'rgba(250,246,236,.78)'; c.beginPath(); c.roundRect(1890 - bw, 50, bw, 118, 14); c.fill();
+ c.fillStyle = 'rgba(30,30,40,.88)'; c.font = '600 54px "Poppins-700", sans-serif'; c.fillText(yr, 1866, 108);
+ c.font = '30px "LXGWWenKai-500", sans-serif'; c.fillText(s.name || '', 1866, 152); c.restore();
+};
+})();
diff --git a/scripts/engine/demos/long_scroll/lib/xing2_ding.js b/scripts/engine/demos/long_scroll/lib/xing2_ding.js
new file mode 100644
index 0000000..ae09e16
--- /dev/null
+++ b/scripts/engine/demos/long_scroll/lib/xing2_ding.js
@@ -0,0 +1,42 @@
+// 一组段共用的小工具(完整片子里 27_kirby、13_pop、14_8bit、25_ghibli、26_vaporwave、16_2026 共用;本示范只用到 14_8bit)。不改 world.js / crossing.js。
+// 段文件开头用 D4.need() 同步加载本文件(index.html 不用改)。
+// D4.hero(seg, s) 复刻 world.js drawHero 的取帧逻辑:返回 { key, i, o:{x,y,h}, hat:[x,y], act, u }(屏幕坐标),front 里画道具对准手/帽子用
+// D4.since(seg, s, k) 距本段第 k 个互动开始的秒数(互动前为负)——段内事件一律相对互动定时,步速改了也不错位
+// D4.frameCanvas(key, i, tag, fn) 取第 i 帧的原图,交给 fn(g, im) 加工成新画布并缓存(画风材质:像素化、海报化、霓虹描边…)
+// D4.drawFrame(c, key, i, o, cv) 按 XING.actor 的锚点规则把加工后的帧画到 (o.x, o.y),cv.pad 为加工时四周留的边
+(() => {
+const D4 = window.D4 = {};
+D4.SCALE = {}; // 某些互动帧库(全身+胸像、站+坐混排)的 ref_h 被拉偏:按 key 整套补一个缩放,D4.hero 与 hero.draw 共用
+const { clamp } = U;
+D4.hero = (seg, s) => {
+ const WD = WORLD, hero = WD.heroAt(s.t), H0 = seg.hero || {};
+ let key = H0.walk, i;
+ if (hero.p.kind === 'act' && hero.p.seg === seg) { key = hero.p.act.key || H0.walk; i = hero.p.act.frame ? hero.p.act.frame(hero.u) : 0; }
+ else { const walked = WD.plan.filter(q => q.kind === 'walk' && q.t0 <= s.t).reduce((a, q) => a + Math.min(s.t, q.t1) - q.t0, 0); i = Math.floor(walked * (H0.fps || 8.5) * WD.V / 330) % XING.nFrames(key); } // 与 world.js 同:步频随步速同比例
+ const lx = hero.x - seg.x0;
+ const gy = (hero.p.kind === 'act' && hero.p.seg === seg && hero.p.act.y) ? hero.p.act.y(lx, hero.u) : (seg.ground ? seg.ground(lx) : WD.GROUND);
+ const o = { x: lx - s.camX, y: gy, h: H0.h || WD.HERO_H, scale: D4.SCALE[key] || 1 };
+ return { key, i, o, lx, hat: XING.hatTop(key, i, o), act: hero.p.kind === 'act' && hero.p.seg === seg ? hero.p.act : null, u: hero.u };
+};
+const FC = {};
+D4.img = (key, i) => window.IMG[`demos/long_scroll/frames/${key}/${XING.SPR[key].meta.frames[i].file}`];
+D4.frameCanvas = (key, i, tag, fn) => {
+ const k = key + '|' + i + '|' + tag; if (FC[k]) return FC[k];
+ const im = D4.img(key, i); const cv = fn(im); FC[k] = cv; return cv;
+};
+D4.drawFrame = (c, key, i, o, cv, alpha) => {
+ const f = XING.SPR[key].meta.frames[i], s = o.h / XING.SPR[key].meta.ref_h * (o.scale || 1), pad = cv.pad || 0, k = cv.k || 1;
+ const fx = o.flip ? -1 : 1;
+ c.save(); if (alpha != null) c.globalAlpha *= alpha;
+ if (o.shadow) { c.fillStyle = o.shadow; c.beginPath(); c.ellipse(o.x, o.y + 2, o.h * 0.2, o.h * 0.035, 0, 0, Math.PI * 2); c.fill(); }
+ c.translate(o.x, o.y); c.scale(fx, 1);
+ if (cv.pixel) c.imageSmoothingEnabled = false;
+ c.drawImage(cv, -(f.ax + pad) * s, -(f.ay + pad) * s, cv.width / k * s, cv.height / k * s);
+ c.restore();
+};
+// 一个 im → 留边画布
+D4.padded = (im, pad) => { const cv = PAINT.canvas(im.width + 2 * pad, im.height + 2 * pad); cv.getContext('2d').drawImage(im, pad, pad); cv.pad = pad; return cv; };
+// 抛物线:从 a 到 b(u 0..1),返回 [x,y,u]
+D4.arc = (a, b, u, peak = 200) => { const e = clamp(u); return [a[0] + (b[0] - a[0]) * e, a[1] + (b[1] - a[1]) * e - Math.sin(e * Math.PI) * peak, e]; };
+D4.since = (seg, s, k = 0) => s.t - WORLD.actT(seg, k);
+})();
diff --git a/scripts/engine/demos/long_scroll/lib/xing2_jia.js b/scripts/engine/demos/long_scroll/lib/xing2_jia.js
new file mode 100644
index 0000000..4ad4735
--- /dev/null
+++ b/scripts/engine/demos/long_scroll/lib/xing2_jia.js
@@ -0,0 +1,114 @@
+// 一组段共用的小工具(完整片子里 01_cave 02_egypt 03_greek 20_dunhuang 17_ink 05_gothic 共用;本示范只用到 02_egypt)。各段文件开头用 XJ_LOAD 同步加载,不进 index.html。
+// XJ.actor(c, key, i, o, name, proc) 用本段材质画主角帧:proc(g, w, h, i, img) 在「帧+pad」画布上做该画风的材料处理,结果按 key/帧/name 缓存
+// XJ.texInside(g, w, h, draw, op) 纹理只乘在角色上(纹理层 destination-in 剪影 → multiply 回去),白帽不变灰:纹理请用接近白的底
+// XJ.ta(seg, s) 互动内秒(全片时刻 − WORLD.actT(seg);互动前为负)——段里所有事件都按它定时,步速改了也对得上
+// XJ.hatNow(seg, s) 互动进行中:帽顶在屏幕上的位置
+// XJ.arc(p0, p1, q, lift) 两点间抛物线
+// XJ.actFrame(table) [[秒, 帧], ...] → frame(u) 函数(u = 动作内秒)
+(() => {
+if (window.XJ) return;
+const { clamp, lerp } = U, P = PAINT, TAU = Math.PI * 2;
+const XJ = window.XJ = {};
+const MATS = {};
+XJ.mat = (key, i, name, proc, pad = 6) => {
+ const k = key + '|' + i + '|' + name; if (MATS[k]) return MATS[k];
+ const S = XING.SPR[key], im = S.imgs[i];
+ const out = P.canvas(im.width + 2 * pad, im.height + 2 * pad), g = out.getContext('2d', { willReadFrequently: true });
+ g.drawImage(im, pad, pad);
+ if (proc) proc(g, out.width, out.height, i, im, pad);
+ out.pad = pad; MATS[k] = out; return out;
+};
+XJ.actor = (c, key, i, o, name, proc) => {
+ XING.hatTop(key, i, o); // 触发 crossing.js 里的 ensure(读帧、算帽顶)
+ const S = XING.SPR[key], f = S.meta.frames[i], im = XJ.mat(key, i, name, proc), pad = im.pad, s = o.h / S.meta.ref_h * (o.scale || 1);
+ const x0 = o.x - (f.ax + pad) * s, y0 = o.y - (f.ay + pad) * s;
+ c.save(); if (o.alpha != null) c.globalAlpha *= o.alpha;
+ if (o.shadow) { c.fillStyle = o.shadow; c.beginPath(); c.ellipse(o.x, o.y + 2, o.h * 0.2, o.h * 0.035, 0, 0, TAU); c.fill(); }
+ if (!o.lock) c.drawImage(im, x0, y0, im.width * s, im.height * s);
+ else { // 脚底锁:上半身照常(平滑);膝盖往下用一个连续的错切把下半段平移到 o.lock,鞋(底部 9%)整块平移满——支撑脚贴住地面不打滑
+ const iw = im.width, foot = f.ay + pad, cut = Math.max(0, foot - S.meta.ref_h * 0.4), full = foot - S.meta.ref_h * 0.09;
+ c.drawImage(im, 0, 0, iw, cut, x0, y0, iw * s, cut * s);
+ c.save(); c.beginPath(); c.rect(x0 - 200, y0 + cut * s, iw * s + 400, (full - cut) * s); c.clip();
+ c.translate(0, y0 + cut * s); c.transform(1, 0, o.lock / ((full - cut) * s), 1, 0, 0); c.drawImage(im, x0, -cut * s, iw * s, im.height * s); c.restore();
+ c.drawImage(im, 0, full, iw, im.height - full, x0 + o.lock, y0 + full * s, iw * s, (im.height - full) * s);
+ }
+ c.restore();
+};
+// 走路脚底锁的平移量(屏幕 px)。st = 每帧支撑脚相对锚点的 x(身高 300 时,从走路帧逐帧量出),fps = 该帧库在步速 330 时的帧率(与 hero.fps 一致)。
+// 原理:一个半周期(4 帧)里支撑脚的世界位置不变;平滑行进的身体相对它走了 V·τ,画里的脚相对锚点退了 st0−stj,两者之差就是这一刻该把脚挪回去的量。
+// 段两端 220px 内渐隐到 0(跨边界时两边帧库不同,避免左右半身错位)。
+XJ.walkLock = (seg, S, i, st, fps, h = 300) => {
+ if (S.act) return 0; const t = S.t, P0 = WORLD.plan.find(q => t >= q.t0 && t < q.t1); if (!P0 || P0.kind !== 'walk') return 0;
+ const walked = WORLD.plan.filter(q => q.kind === 'walk' && q.t0 <= t).reduce((a, q) => a + Math.min(t, q.t1) - q.t0, 0);
+ const rate = fps * WORLD.V / 330, ph = walked * rate, h0 = Math.floor(ph / 4) * 4, tau = (ph - h0) / rate;
+ const k0 = h0 % 8, n = st.length; const lock = ((st[k0 % n] - st[i % n]) * h / 300 - WORLD.V * tau);
+ const L = U.ss(0, 220, S.hx) * U.ss(0, 220, seg.w - S.hx);
+ return clamp(lock, -70, 40) * L;
+};
+XJ.texInside = (g, w, h, draw, op = 'multiply', alpha = 1, skipWhite = false) => {
+ const T = P.canvas(w, h), tg = T.getContext('2d');
+ draw(tg, w, h);
+ tg.globalCompositeOperation = 'destination-in'; tg.drawImage(g.canvas, 0, 0);
+ if (skipWhite) { tg.globalCompositeOperation = 'destination-out'; tg.drawImage(XJ.whiteMask(g, w, h), 0, 0); } // 白帽白T不上做旧(角色设定:帽子纯白)
+ g.save(); g.globalCompositeOperation = op; g.globalAlpha = alpha; g.drawImage(T, 0, 0); g.restore();
+};
+// 逐像素改色(白帽护白等):fn(r,g,b,a) → [r,g,b] 或 null
+XJ.remap = (g, w, h, fn) => { const d = g.getImageData(0, 0, w, h), q = d.data;
+ for (let k = 0; k < q.length; k += 4) { if (q[k + 3] < 8) continue; const r = fn(q[k], q[k + 1], q[k + 2], q[k + 3], (k >> 2) % w, (k >> 2) / w | 0); if (r) { q[k] = r[0]; q[k + 1] = r[1]; q[k + 2] = r[2]; if (r.length > 3) q[k + 3] = r[3]; } }
+ g.putImageData(d, 0, 0); };
+// 白色区域蒙版(亮且低饱和),给 texInside 挖掉
+XJ.whiteMask = (g, w, h) => { const d = g.getImageData(0, 0, w, h).data, M = P.canvas(w, h), mg = M.getContext('2d'), o = mg.createImageData(w, h);
+ for (let k = 0; k < w * h; k++) { const r = d[k * 4], gg = d[k * 4 + 1], b = d[k * 4 + 2], mx = Math.max(r, gg, b), mn = Math.min(r, gg, b); o.data[k * 4 + 3] = d[k * 4 + 3] > 100 && mx > 200 && mx - mn < 50 ? 255 : 0; }
+ mg.putImageData(o, 0, 0); return M; };
+// 帽区(上 frac)里的做旧斑点抹白:周围 5×5 有六成以上是白的、自身又不暗的像素=白帽上的斑点 → 换成纯白(帽檐的勾线周围白不足六成,保留)
+XJ.cleanHat = (g, w, h, frac = 0.34, white = [250, 248, 242], R = 2, wmin = 205) => { const D = g.getImageData(0, 0, w, h), d = D.data, Y = Math.floor(h * frac), wt = new Uint8Array(w * Y);
+ for (let y = 0; y < Y; y++) for (let x = 0; x < w; x++) { const k = (y * w + x) * 4, mx = Math.max(d[k], d[k + 1], d[k + 2]), mn = Math.min(d[k], d[k + 1], d[k + 2]); wt[y * w + x] = d[k + 3] > 100 && mx > wmin && mx - mn < 45 ? 1 : 0; }
+ const need = Math.ceil((2 * R + 1) ** 2 * 0.55);
+ for (let y = R; y < Y - R; y++) for (let x = R; x < w - R; x++) { const k = (y * w + x) * 4; if (d[k + 3] < 100 || wt[y * w + x]) continue; const lum = d[k] * 0.3 + d[k + 1] * 0.59 + d[k + 2] * 0.11; if (lum < 95) continue;
+ let n = 0; for (let dy = -R; dy <= R; dy++) for (let dx = -R; dx <= R; dx++) n += wt[(y + dy) * w + x + dx]; if (n >= need) { d[k] = white[0]; d[k + 1] = white[1]; d[k + 2] = white[2]; } }
+ g.putImageData(D, 0, 0); };
+XJ.ta = (seg, s, k = 0) => s.t - WORLD.actT(seg, k);
+XJ.hatNow = (seg, s) => {
+ const a = s.act; if (!a) return null;
+ const key = a.a.key, i = a.a.frame ? a.a.frame(a.u) : 0, h = (seg.hero && seg.hero.h) || WORLD.HERO_H;
+ const x = s.hx - s.camX, y = a.a.y ? a.a.y(s.hx, a.u) : (seg.ground ? seg.ground(s.hx) : WORLD.GROUND);
+ return XING.hatTop(key, i, { x, y, h });
+};
+XJ.arc = (p0, p1, q, lift = 120) => [lerp(p0[0], p1[0], q), lerp(p0[1], p1[1], q) - 4 * lift * q * (1 - q)];
+// 停下/起步不再一帧刹死、一帧满速:互动开头 Tb 秒从步速匀减到 0、末尾 Tb 秒从 0 匀加回步速(镜头跟着他,所以镜头也是缓停缓起)。
+// extra(u) 可叠加互动自己的位移(如被甩飞),extraDx 是它的总位移。返回 { dx, move } 直接展开进 acts 项(并配 lead: 0,免得镜头先冲再倒带)。
+XJ.glide = (dur, Tb = 0.22, extra = null, extraDx = 0) => { const V = WORLD.V, d1 = V * Tb / 2, dx = 2 * d1 + extraDx;
+ const pos = u => (u < Tb ? V * (u - u * u / (2 * Tb)) : d1) + (u > dur - Tb ? V * (u - (dur - Tb)) ** 2 / (2 * Tb) : 0) + (extra ? extra(u) : 0);
+ return { dx, move: f => dx ? pos(f * dur) / dx : 0 }; };
+// 缓停/缓起窗口里不播互动帧,接着播走路帧:步频随速度降到 0 再升回来,与互动前后的走路相位首尾相接
+XJ.walkedAt = t => WORLD.plan.filter(q => q.kind === 'walk' && q.t0 <= t).reduce((a, q) => a + Math.min(t, q.t1) - q.t0, 0);
+XJ.glideWalk = (S, dur, fps, n = 8, Tb = 0.22, head = true, tail = true) => {
+ if (!S.act) return null; const u = S.act.u, V = WORLD.V, rate = fps * V / 330, ph0 = XJ.walkedAt(S.t - u) * rate, d1 = V * Tb / 2;
+ let ph = null;
+ if (head && u < Tb) ph = ph0 + (V * (u - u * u / (2 * Tb))) / V * rate;
+ else if (tail && u > dur - Tb) { const w = u - (dur - Tb); ph = ph0 - (d1 - V * w * w / (2 * Tb)) / V * rate; }
+ return ph == null ? null : ((Math.floor(ph) % n) + n) % n;
+};
+XJ.actFrame = tab => u => { let f = tab[0][1]; for (const [t0, fr] of tab) if (u >= t0) f = fr; return f; };
+// 只在本段可见范围内画:lx 世界坐标 → 屏幕
+XJ.vis = (s, lx, pad = 300) => lx - s.camX > -pad && lx - s.camX < s.W + pad;
+// 跨边界的颜料迸散:crossing.js 只有 monet / vg 两套颜色。这里只给本组的 burst 名('jia_*')换色,其余照旧交回原函数(不改 crossing.js)
+XJ.BURST = {
+ jia_cave: ['#9c3520', '#c9772f', '#21150d', '#d49a5a', '#74261a'],
+ jia_egypt: ['#1f4fa0', '#c0392b', '#2f8a5a', '#e0b030', '#1a1a1a'],
+ jia_greek: ['#1a1410', '#c8602a', '#e8d2b0', '#7a2a1a'],
+ jia_dunhuang: ['#2f5f8f', '#3f8f6e', '#a5452f', '#ecdfc4', '#d8b05a'],
+ jia_ink: ['#1a1a1a', '#3a3a3a', '#6a6a6a', '#9a9a9a', '#b8322a'],
+ jia_gothic: ['#e8c45a', '#1f3f9f', '#b8202a', '#f6e6a8', '#2f7a3a'],
+};
+if (XING.burst && !XING.burst.__jia) {
+ const orig = XING.burst;
+ XING.burst = (c, x, y, a, R, style, seed = 1) => {
+ const cols = XJ.BURST[style]; if (!cols) return orig(c, x, y, a, R, style, seed); if (a < 0 || a > 1) return;
+ const r = U.rng(seed); c.save(); c.lineCap = 'round';
+ for (let i = 0; i < 70; i++) { const ang = r() * TAU, sp = R * (0.55 + r() * 0.8), d = 150 + sp * U.ease.out(a), x1 = x + Math.cos(ang) * d, y1 = y + Math.sin(ang) * d * 0.8 + 120 * a * a; // 从人身外一圈迸开,不压在他身上(审片:彩条留在白T上)
+ c.strokeStyle = cols[i % cols.length]; c.globalAlpha = 1 - a; c.lineWidth = 7 + r() * 6; c.beginPath(); c.moveTo(x1, y1); c.lineTo(x1 + Math.cos(ang) * 16, y1 + Math.sin(ang) * 10); c.stroke(); }
+ c.restore(); };
+ XING.burst.__jia = true;
+}
+})();
diff --git a/scripts/engine/demos/long_scroll/lib/xing2_yi.js b/scripts/engine/demos/long_scroll/lib/xing2_yi.js
new file mode 100644
index 0000000..0364434
--- /dev/null
+++ b/scripts/engine/demos/long_scroll/lib/xing2_yi.js
@@ -0,0 +1,133 @@
+// 一组段共用的小工具(完整片子里 06_renaissance / 32_rembrandt / 07_ukiyoe / 28_monet / 29_seurat / 09_postimp 共用;本示范只用到 28_monet)。
+// 不进 index.html:各段文件开头同步加载(if (!window.YI) …),哪一段先加载都行。
+// YI.S(key) 帧库(确保 XING 已算好 imgs/hat)
+// YI.actor(c, key, i, o, mat) 画第 i 帧,mat = { name, fn(img)->canvas(可带 pad), atop(g, o, box) }:
+// fn 是逐帧缓存的材质(滤镜、点彩重画…);atop 每帧在精灵上 source-atop 叠(烛光、光斑)
+// YI.toScreen(key, i, o, [px,py]) 帧内像素坐标 → 屏幕坐标(手的位置、道具对齐)
+// YI.hand(key, i, o, tbl) tbl[i] = [px,py](帧内像素)→ 屏幕坐标
+// YI.fly(c, from, to, q, draw, o) 纪念品飞上帽子:抛物线+放大+旋转(落帽那一下由 world.js 的 pop 接住)
+(() => {
+const W = 1920, H = 1080, TAU = Math.PI * 2;
+const { clamp, lerp, ss } = U;
+const P = window.PAINT, X = window.XING;
+const Y = window.YI = {};
+
+// 帧库在不在(读目录列表,不发 404 请求——render.py 把 404 记成页面报错)
+let LIST = null;
+Y.has = k => { if (LIST == null) { const x = new XMLHttpRequest(); x.open('GET', 'demos/long_scroll/frames/', false); x.send(); LIST = x.status === 200 ? x.responseText : ''; } return LIST.includes(`"${k}/"`); };
+// 帽顶修正:举过头顶的手会骗过 XING 的「最上一行不透明像素」,用逐帧量出的白帽顶覆盖(帧内像素 [x,y])
+Y.HATFIX = {};
+Y.fixHat = (key, arr) => { Y.HATFIX[key] = arr; };
+Y.S = key => { X.hatTop(key, 0, { x: 0, y: 0, h: 1 }); const S = X.SPR[key]; if (Y.HATFIX[key] && !S._yiFixed) { Y.HATFIX[key].forEach((p, i) => { if (p) S.hat[i] = p; }); S._yiFixed = true; } return S; };
+Y.hatTop = (key, i, o) => { Y.S(key); return X.hatTop(key, i, o); };
+const PROC = {};
+Y.proc = (key, i, mat) => {
+ const k = key + '|' + mat.name + '|' + i; if (PROC[k]) return PROC[k];
+ const S = Y.S(key), im = S.imgs[i]; const out = mat.fn(im); if (out.pad == null) out.pad = 0; return PROC[k] = out;
+};
+Y.geom = (key, i, o) => { const S = Y.S(key), f = S.meta.frames[i], s = o.h / S.meta.ref_h * (o.scale || 1); return { S, f, s }; };
+Y.toScreen = (key, i, o, p) => { const { f, s } = Y.geom(key, i, o), fx = o.flip ? -1 : 1; return [o.x + (p[0] - f.ax) * s * fx, o.y + (p[1] - f.ay) * s]; };
+Y.hand = (key, i, o, tbl) => Y.toScreen(key, i, o, tbl[i] || tbl[0]);
+
+Y.actor = (c, key, i, o, mat) => {
+ const { S, f, s } = Y.geom(key, i, o);
+ const im = mat && mat.fn ? Y.proc(key, i, mat) : S.imgs[i], pad = im.pad || 0, fx = o.flip ? -1 : 1;
+ const dw = im.width * s, dh = im.height * s, x0 = o.x - (f.ax + pad) * s * fx, y0 = o.y - (f.ay + pad) * s;
+ const left = o.flip ? x0 - dw : x0;
+ c.save(); if (o.alpha != null) c.globalAlpha *= o.alpha;
+ if (o.shadow) { c.fillStyle = o.shadow; c.beginPath(); c.ellipse(o.x, o.y + 2, o.h * 0.2, o.h * 0.035, 0, 0, TAU); c.fill(); }
+ if (mat && mat.atop) {
+ const Sc = P.scratch('yiActor'), g = Sc.getContext('2d'); g.setTransform(1, 0, 0, 1, 0, 0);
+ const bw = Math.ceil(dw) + 4, bh = Math.ceil(dh) + 4; g.clearRect(0, 0, bw + 4, bh + 4);
+ g.save(); g.translate(2, 2); if (o.flip) { g.translate(dw, 0); g.scale(-1, 1); } g.drawImage(im, 0, 0, dw, dh); g.restore();
+ g.save(); g.globalCompositeOperation = 'source-atop'; g.translate(2 - left, 2 - y0); mat.atop(g, o, { x: left, y: y0, w: dw, h: dh }); g.restore();
+ c.drawImage(Sc, 0, 0, bw, bh, left - 2, y0 - 2, bw, bh);
+ } else {
+ if (o.flip) { c.translate(left + dw, y0); c.scale(-1, 1); c.drawImage(im, 0, 0, dw, dh); }
+ else c.drawImage(im, left, y0, dw, dh);
+ }
+ c.restore();
+};
+
+// 生图爱把白帽白T画成米黄浅灰:低饱和的亮色拉回白(帽子定规是纯白)。lo = 起拉的亮度
+Y.whiten = (g, w, h, lo = 185, r = 251, gg = 249, b = 242, chroma = 52) => { const d = g.getImageData(0, 0, w, h), q = d.data;
+ for (let k = 0; k < q.length; k += 4) { const mx = Math.max(q[k], q[k + 1], q[k + 2]), mn = Math.min(q[k], q[k + 1], q[k + 2]); if (q[k + 3] > 0 && mx > lo && mx - mn < chroma) { const f = Math.min(1, (mx - lo) / (255 - lo) * 1.15); q[k] = lerp(q[k], r, f); q[k + 1] = lerp(q[k + 1], gg, f); q[k + 2] = lerp(q[k + 2], b, f); } }
+ g.putImageData(d, 0, 0); };
+// 段两端补边:画风边界是波浪线(±30px),会伸出段的 [0,w] 之外——把世界画布最边上 2px 拉宽铺到外面 80px,免得露黑
+Y.edge = (c, cv, camX, w) => { c.drawImage(cv, 0, 0, 2, cv.height, -camX - 80, 0, 82, cv.height); c.drawImage(cv, w - 2, 0, 2, cv.height, w - camX, 0, 80, cv.height); };
+// 纪念品飞上帽子时的落点=当前那摞的顶(不是帽顶):在草稿画布上空画一遍 drawHatStack 拿顶端高度
+Y.stackTop = (key, i, o, t) => { const [hx, hy] = Y.hatTop(key, i, o), g = P.scratch('yiStackProbe').getContext('2d'); g.setTransform(1, 0, 0, 1, 0, 0); g.globalAlpha = 0; const top = WORLD.drawHatStack(g, hx, hy + 4, o.h || 300, t); g.globalAlpha = 1; return [hx, hy + 4 + top]; };
+// 帽子拉回纯白:直接改帧库里的原帧(只改上部帽子那几成高度的低饱和亮色),之后 XING 的材质都从白帽子算起
+Y.whitenHat = (key, { frac = 0.42, lo = 150, chroma = 110 } = {}) => { const S = Y.S(key); if (S._yiWhite) return; S.imgs = S.imgs.map(im => { const cv = P.canvas(im.width, im.height), g = cv.getContext('2d', { willReadFrequently: true }); g.drawImage(im, 0, 0);
+ const hh = Math.round(im.height * frac); const d = g.getImageData(0, 0, im.width, hh), q = d.data;
+ for (let k = 0; k < q.length; k += 4) { const mx = Math.max(q[k], q[k + 1], q[k + 2]), mn = Math.min(q[k], q[k + 1], q[k + 2]); if (q[k + 3] > 0 && mx > lo && mx - mn < chroma && q[k + 2] >= q[k] - 20) { const f = Math.min(1, (mx - lo) / (255 - lo) * 1.3); q[k] = lerp(q[k], 252, f); q[k + 1] = lerp(q[k + 1], 251, f); q[k + 2] = lerp(q[k + 2], 248, f); } }
+ g.putImageData(d, 0, 0); return cv; }); S._yiWhite = true; };
+// 纪念品飞上帽子:from/to 屏幕坐标;q 0..1;draw(c, x, y, scale, rot)
+Y.fly = (c, from, to, q, draw, { arc = 160, grow = 0.8, spin = 0, s0 = 1, s1 = 1 } = {}) => {
+ const e = U.ease ? q : q; const x = lerp(from[0], to[0], e), y = lerp(from[1], to[1], e) - Math.sin(e * Math.PI) * arc;
+ const sc = lerp(s0, s1, e) * (1 + grow * Math.sin(e * Math.PI)); draw(c, x, y, sc, spin * e);
+};
+
+// 简单的抠精灵像素工具:返回精灵的 ImageData(缓存)
+const DATA = {};
+Y.data = (key, i) => { const k = key + i; if (DATA[k]) return DATA[k]; const im = Y.S(key).imgs[i], cv = P.canvas(im.width, im.height), g = cv.getContext('2d', { willReadFrequently: true }); g.drawImage(im, 0, 0); return DATA[k] = { w: im.width, h: im.height, d: g.getImageData(0, 0, im.width, im.height).data }; };
+
+// 烛火(伦勃朗段纪念品与段内道具共用):x,y = 烛芯底;s 缩放;t 时间。只画火苗+内焰+芯
+Y.flame = (c, x, y, s, t, seed = 0) => {
+ const fl = 0.5 * P.noise(t * 2.2 + seed, 3.1) + 0.25 * P.noise(t * 6.5 + seed, 7.7), lean = fl * 0.5, hgt = (30 + 8 * P.noise(t * 5 + seed, 1.3)) * s;
+ c.save(); c.translate(x, y);
+ const outer = new Path2D(); outer.moveTo(-7 * s, 0); outer.bezierCurveTo(-9 * s, -hgt * 0.45, lean * hgt * 0.6 - 2 * s, -hgt * 0.75, lean * hgt, -hgt); outer.bezierCurveTo(lean * hgt * 0.6 + 2 * s, -hgt * 0.75, 9 * s, -hgt * 0.45, 7 * s, 0); outer.closePath();
+ const g1 = c.createRadialGradient(0, -hgt * 0.3, 1, 0, -hgt * 0.3, hgt * 0.9); g1.addColorStop(0, 'rgba(255,250,215,1)'); g1.addColorStop(0.5, 'rgba(255,200,90,.95)'); g1.addColorStop(1, 'rgba(230,110,30,.7)');
+ c.fillStyle = g1; c.fill(outer);
+ c.fillStyle = 'rgba(255,255,240,.95)'; c.beginPath(); c.ellipse(lean * hgt * 0.25, -hgt * 0.3, 2.6 * s, hgt * 0.22, lean * 0.3, 0, TAU); c.fill();
+ c.fillStyle = 'rgba(90,110,200,.55)'; c.beginPath(); c.ellipse(0, -2 * s, 3.5 * s, 3 * s, 0, 0, TAU); c.fill();
+ c.strokeStyle = '#2a1a10'; c.lineWidth = 1.6 * s; c.beginPath(); c.moveTo(0, 2 * s); c.lineTo(lean * 3 * s, -5 * s); c.stroke();
+ c.restore();
+};
+// 烛光晕(lighter)
+Y.glow = (c, x, y, r, a, col = '255,190,100') => { c.save(); c.globalCompositeOperation = 'lighter'; const g = c.createRadialGradient(x, y, 0, x, y, r); g.addColorStop(0, `rgba(${col},${a})`); g.addColorStop(0.4, `rgba(${col},${a * 0.4})`); g.addColorStop(1, `rgba(${col},0)`); c.fillStyle = g; c.fillRect(x - r, y - r, 2 * r, 2 * r); c.restore(); };
+Y.flick = (t, seed = 0) => 0.5 + 0.5 * (0.6 * P.noise(t * 2.2 + seed, 5.5) + 0.4 * P.noise(t * 7 + seed, 9.1));
+
+// ---------- 点彩(修拉):P.pointillism 的「世界坐标版」——网格锚在世界上(相机横移时点不游动),任意尺寸画布,可只点不透明处 ----------
+// src 的 x=0 对应世界 x = gx0;alphaMin>0 时只在 src 不透明处下点(动态物件层);rect=[x0,y0,x1,y1] 限定范围(src 坐标)
+const PICK = new Map();
+Y.dots = (c, src, { pal, comp = {}, pitch = 10, rad = 4.5, posJitter = 2.4, colorJitter = 40, compRate = 0.08, flicker = 0.07, fps = 6, t = 0, shimmer, white = 12, dark = 0, bleed = 45, gx0 = 0, alphaMin = 0, rect, palKey = 'p' } = {}) => {
+ const PAL = pal.map(v => typeof v === 'string' ? P.hex(v) : v);
+ let cache = PICK.get(palKey); if (!cache) { cache = new Map(); PICK.set(palKey, cache); }
+ const pick = (r, g, b) => { const key = (r >> 3) << 10 | (g >> 3) << 5 | (b >> 3); let v = cache.get(key); if (v) return v;
+ let best = 1e18, bi = 0, bj = 0, bw = 1;
+ for (let i = 0; i < PAL.length; i++) for (let j = i + 1; j < PAL.length; j++) { const pi = PAL[i], pj = PAL[j], ex = pi[0] - pj[0], ey = pi[1] - pj[1], ez = pi[2] - pj[2];
+ const w = clamp(((r - pj[0]) * ex + (g - pj[1]) * ey + (b - pj[2]) * ez) / (ex * ex + ey * ey + ez * ez + 1e-6), 0.2, 0.8);
+ const dr = pj[0] + w * ex - r, dg = pj[1] + w * ey - g, db = pj[2] + w * ez - b, d = dr * dr * 0.9 + dg * dg * 1.2 + db * db * 0.8 + (ex * ex + ey * ey + ez * ez) * 0.004;
+ if (d < best) { best = d; bi = i; bj = j; bw = w; } }
+ v = [bi, bj, bw]; cache.set(key, v); return v; };
+ const sw = src.width, sh = src.height, [rx0, ry0, rx1, ry1] = rect || [0, 0, sw, sh];
+ const sd = src.getContext('2d', { willReadFrequently: true }).getImageData(0, 0, sw, sh).data;
+ const at = (x, y) => (clamp(y | 0, 0, sh - 1) * sw + clamp(x | 0, 0, sw - 1)) * 4;
+ const L = (x, y) => { const k = at(x, y); return sd[k] * 0.3 + sd[k + 1] * 0.59 + sd[k + 2] * 0.11; };
+ const paths = PAL.map(() => new Path2D()), st = Math.floor(t * fps), ROWH = pitch * 0.866, hj = posJitter / 2;
+ for (let j = Math.max(0, Math.floor(ry0 / ROWH) - 1), y = j * ROWH; y < ry1 + ROWH; j++, y += ROWH) {
+ const off = (j % 2) * pitch / 2, i0 = Math.floor((gx0 + rx0 - off) / pitch) - 1, i1 = Math.ceil((gx0 + rx1 - off) / pitch) + 1;
+ for (let i = i0; i <= i1; i++) {
+ const jx = (U.hash(i, j * 7 + 1) - 0.5) * 2 * hj, jy = (U.hash(i * 3, j + 5) - 0.5) * 2 * hj, px = i * pitch + off + jx - gx0, py = y + jy;
+ if (px < rx0 - pitch || px > rx1 + pitch) continue;
+ const k = at(px, py); if (alphaMin && sd[k + 3] < alphaMin) continue;
+ const dj = (U.hash(i * 7 + 3, j * 11) - 0.5) * colorJitter;
+ const [a, bb, w] = pick(clamp(sd[k] + dj, 0, 255), clamp(sd[k + 1] + dj * 0.8, 0, 255), clamp(sd[k + 2] - dj * 0.6, 0, 255));
+ const hseed = shimmer && shimmer(px, py) ? U.hash(i + st * 977, j) : U.hash(i, j);
+ let idx = hseed < w ? a : bb; const h2 = U.hash(i * 5 + 2, j * 3 + 9);
+ if (h2 < compRate && comp[idx] != null) idx = comp[idx];
+ else if (U.hash(i * 13 + st * 31, j * 17) < flicker) idx = (U.hash(i, j + st) < w) ? bb : a;
+ else if (!alphaMin) { const dl = L(px, py) - L(px + 14, py + 6); if (Math.abs(dl) > bleed && h2 < 0.45) idx = dl > 0 ? white : dark; }
+ paths[idx].moveTo(px + rad, py); paths[idx].arc(px, py, rad, 0, TAU);
+ } }
+ paths.forEach((p, k) => { c.fillStyle = P.rgb(PAL[k]); c.fill(p); });
+};
+// 精灵 → 点阵(散开/聚回用):按 pitch 采样不透明像素,返回 [{x,y,col,r1,r2,r3}](帧内像素坐标)
+const DOTS = {};
+Y.spriteDots = (key, i, pitch, procCanvas) => { const k = key + i + '|' + pitch; if (DOTS[k]) return DOTS[k];
+ const im = procCanvas || Y.S(key).imgs[i], cv = P.canvas(im.width, im.height), g = cv.getContext('2d', { willReadFrequently: true }); g.drawImage(im, 0, 0); const d = g.getImageData(0, 0, im.width, im.height).data, out = [];
+ for (let y = 0, j = 0; y < im.height; y += pitch * 0.866, j++) for (let x = (j % 2) * pitch / 2; x < im.width; x += pitch) { const q = ((y | 0) * im.width + (x | 0)) * 4; if (d[q + 3] < 140) continue;
+ out.push({ x, y, col: `rgb(${d[q]},${d[q + 1]},${d[q + 2]})`, r1: U.hash(x | 0, y | 0), r2: U.hash(y | 0, (x | 0) + 7), r3: U.hash((x | 0) + 3, (y | 0) * 3) }); }
+ return DOTS[k] = out; };
+})();
diff --git a/scripts/engine/demos/long_scroll/segments/02_egypt.js b/scripts/engine/demos/long_scroll/segments/02_egypt.js
new file mode 100644
index 0000000..aeda459
--- /dev/null
+++ b/scripts/engine/demos/long_scroll/segments/02_egypt.js
@@ -0,0 +1,234 @@
+// 02_egypt · 古埃及墓室壁画(约公元前 1350 年,新王国)—— 横向「分栏壁画」世界
+// 世界=墓室墙上的三层分栏(register):顶上 kheker 饰带+彩块边;上栏是美杜姆群鹅、有翼日盘、纸莎草丛里惊飞的水鸟(内巴蒙猎禽图的母题)和象形文字栏;
+// 540 处一道彩块分栏线(地平线);中栏是他走的这一层(供桌、尖底罐、蓝莲花);760 处彩块地线;下栏是尼罗河之字形水纹、游鱼、蓝莲。
+// 画法沿用 scenes/02_egypt.js:灰泥墙底+平涂色块+深色勾线+四色彩块边框+象形字库+整幅 multiply 壁画表面(斑驳、发丝裂纹、颗粒)。
+// 活:水纹流动、鱼游、水鸟扑翅、群鹅点头啄食、纸莎草摇、日盘脉动。
+// 互动:圣甲虫推着太阳球从前面滚来,他埃及舞者式跳起让开,球和圣甲虫从他脚下滚过去、一路滚出画外;他回头看、得意地叉腰。
+// 圣甲虫推着球走开,帽子保持纯白,不累积纪念品
+if (!window.XJ) { const x = new XMLHttpRequest(); x.open('GET', 'demos/long_scroll/lib/xing2_jia.js', false); x.send(); (0, eval)(x.responseText + '\n//# sourceURL=demos/long_scroll/lib/xing2_jia.js'); }
+(() => {
+const { clamp, lerp, rng, ss } = U, P = PAINT, TAU = Math.PI * 2, H = 1080, W = 1920;
+const w = 2100, OX = 160, WW = w + 2 * OX, G = WORLD.GROUND, REG = 540;
+const WALK = { st: [49.0, 23.6, -1.4, -53.7, 51.4, 27.0, -22.6, -55.4], fps: 12.6 }; // 支撑脚 x(身高300)与步速330时的帧率,从走路帧逐帧量出
+const K = { walk: 'egypt_walk8', act: 'egypt_dodge' };
+const AT = 1000, DUR = 1.6;
+const AX = AT + WORLD.V * 0.11; // 他互动时实际站的位置(XJ.glide 缓停滑过的那一小段之后)
+const T_HIT = 0.6, V_SC = 650; // 互动内秒:球滚到他脚下;圣甲虫速度(px/s,与步速无关)。加快甲虫并拉长腾空时间,让整只甲虫在角色落地前通过
+const C = { wall: [234, 220, 184], wall2: [216, 197, 151], line: '#2a1810', rule: '#9a2b22', red: '#b8322a', blue: '#2a58a8', green: '#2e8a55', yellow: '#e2b13a', black: '#231a14',
+ gold: '#e0ab38', cream: '#f2ead6', white: '#f6f2e8', terra: '#d4936a', lapis: '#2c56b0', turq: '#3fa6a0', water: '#2f5fa8', papy: '#3f8a4a', papyL: '#7ab45a' };
+const BAND = [C.red, C.blue, C.yellow, C.green];
+const poly = (g, pts, close = true) => { g.beginPath(); pts.forEach((p, i) => i ? g.lineTo(p[0], p[1]) : g.moveTo(p[0], p[1])); if (close) g.closePath(); };
+const fs = (g, fill, stroke, lw = 2.5) => { if (fill) { g.fillStyle = fill; g.fill(); } if (stroke) { g.strokeStyle = stroke; g.lineWidth = lw; g.stroke(); } };
+
+// ---------- 象形文字(字形取自 scenes/02_egypt.js) ----------
+const GL = {
+ ankh: { h: 60, cols: [C.blue, C.green, C.black, C.red], d(g) { g.lineWidth = 3.6; g.beginPath(); g.ellipse(0, -17, 8, 11, 0, 0, 7); g.moveTo(-16, -3); g.lineTo(16, -3); g.moveTo(0, -5); g.lineTo(0, 29); g.stroke(); } },
+ sun: { h: 40, cols: [C.black, C.blue, C.red], d(g) { g.lineWidth = 3; g.beginPath(); g.arc(0, 0, 15, 0, 7); g.stroke(); g.beginPath(); g.arc(0, 0, 4, 0, 7); g.fill(); } },
+ bread: { h: 26, cols: [C.red, C.blue, C.green], d(g) { g.beginPath(); g.arc(0, 9, 19, Math.PI, 0); g.closePath(); g.stroke(); g.beginPath(); g.moveTo(-12, 4); g.lineTo(12, 4); g.stroke(); } },
+ reed: { h: 62, cols: [C.black, C.green, C.red], d(g) { g.beginPath(); g.moveTo(-2, 29); g.quadraticCurveTo(-11, 0, 1, -29); g.quadraticCurveTo(7, -2, 4, 29); g.stroke(); g.beginPath(); g.moveTo(1, -29); g.quadraticCurveTo(9, -31, 10, -24); g.stroke(); } },
+ owl: { h: 60, cols: [C.black, C.blue], d(g) { g.beginPath(); g.ellipse(3, 6, 12, 19, 0.1, 0, 7); g.stroke(); g.beginPath(); g.arc(-2, -18, 10, 0, 7); g.stroke(); g.beginPath(); g.arc(-6, -19, 2.4, 0, 7); g.arc(2, -19, 2.4, 0, 7); g.fill(); g.beginPath(); g.moveTo(-2, -14); g.lineTo(-3, -9); g.moveTo(9, 22); g.lineTo(18, 29); g.moveTo(-3, 24); g.lineTo(-5, 30); g.moveTo(4, 24); g.lineTo(3, 30); g.stroke(); } },
+ falcon: { h: 60, cols: [C.black, C.red, C.blue], d(g) { g.beginPath(); g.arc(-6, -20, 7, 0, 7); g.fill(); poly(g, [[-12, -21], [-19, -16], [-11, -15]]); g.fill(); g.beginPath(); g.ellipse(2, 1, 10, 20, -0.35, 0, 7); g.stroke(); poly(g, [[8, 16], [20, 30], [6, 27]]); g.fill(); g.beginPath(); g.moveTo(-3, 19); g.lineTo(-5, 30); g.moveTo(2, 19); g.lineTo(1, 30); g.moveTo(-1, -8); g.quadraticCurveTo(10, 0, 12, 14); g.stroke(); } },
+ eye: { h: 36, cols: [C.green, C.black, C.blue], d(g) { g.beginPath(); g.moveTo(-18, 0); g.quadraticCurveTo(0, -12, 18, 0); g.quadraticCurveTo(0, 9, -18, 0); g.stroke(); g.beginPath(); g.arc(0, -1, 4.5, 0, 7); g.fill(); g.beginPath(); g.moveTo(-18, -12); g.quadraticCurveTo(0, -20, 20, -11); g.moveTo(-4, 6); g.lineTo(-6, 16); g.moveTo(6, 5); g.quadraticCurveTo(14, 18, 4, 16); g.stroke(); } },
+ cartouche: { h: 74, cols: [C.black, C.red], d(g) { g.beginPath(); g.ellipse(0, -2, 15, 31, 0, 0, 7); g.stroke(); g.beginPath(); g.moveTo(-14, 33); g.lineTo(14, 33); g.stroke(); g.lineWidth = 2; g.beginPath(); g.arc(0, -18, 5, 0, 7); g.moveTo(-7, -2); g.lineTo(7, -2); g.moveTo(-6, 8); g.lineTo(-3, 13); g.lineTo(0, 8); g.lineTo(3, 13); g.lineTo(6, 8); g.stroke(); } },
+ snake: { h: 30, cols: [C.green, C.black, C.red], d(g) { g.lineWidth = 3.2; g.beginPath(); g.moveTo(22, 8); g.bezierCurveTo(10, -4, 4, 14, -6, 6); g.bezierCurveTo(-14, 0, -16, -4, -20, -2); g.stroke(); g.beginPath(); g.moveTo(-20, -2); g.lineTo(-23, -9); g.moveTo(-17, -3); g.lineTo(-15, -10); g.stroke(); } },
+ seated: { h: 58, cols: [C.red, C.black, C.blue], d(g) { g.beginPath(); g.arc(-2, -21, 6.5, 0, 7); g.fill(); poly(g, [[-6, -13], [4, -13], [6, 6], [16, 8], [17, 18], [-10, 18], [-10, 2]]); g.fill(); g.beginPath(); g.moveTo(-6, -8); g.lineTo(-17, -16); g.stroke(); g.beginPath(); g.moveTo(-14, 26); g.lineTo(18, 26); g.stroke(); } },
+ djed: { h: 62, cols: [C.blue, C.green], d(g) { g.beginPath(); g.moveTo(-6, 29); g.lineTo(-6, -10); g.moveTo(6, 29); g.lineTo(6, -10); for (let k = 0; k < 4; k++) { g.moveTo(-13, -12 - k * 5); g.lineTo(13, -12 - k * 5); } g.moveTo(-12, 29); g.lineTo(12, 29); g.stroke(); } },
+ jug: { h: 50, cols: [C.red, C.green, C.blue], d(g) { g.beginPath(); g.moveTo(-6, -22); g.lineTo(6, -22); g.lineTo(5, -14); g.quadraticCurveTo(16, -6, 12, 12); g.quadraticCurveTo(8, 22, 0, 22); g.quadraticCurveTo(-8, 22, -12, 12); g.quadraticCurveTo(-16, -6, -5, -14); g.closePath(); g.stroke(); g.beginPath(); g.moveTo(-10, 0); g.lineTo(10, 0); g.stroke(); } },
+ lotus: { h: 56, cols: [C.green, C.blue], d(g) { g.beginPath(); g.moveTo(0, 27); g.lineTo(0, -6); g.stroke(); poly(g, [[0, -6], [-12, -18], [-6, -26], [0, -16], [6, -26], [12, -18]]); g.stroke(); } },
+ nfr: { h: 56, cols: [C.black, C.red], d(g) { g.beginPath(); g.ellipse(0, 12, 10, 14, 0, 0, 7); g.moveTo(0, -2); g.lineTo(0, -26); g.moveTo(-6, -18); g.lineTo(6, -18); g.moveTo(-6, -12); g.lineTo(6, -12); g.stroke(); } },
+ water: { h: 30, cols: [C.blue], d(g) { g.lineWidth = 2.6; for (let r = -1; r <= 1; r++) { g.beginPath(); for (let i = 0; i <= 16; i++) { const x = -21 + i * 2.625, y = r * 9 + (i % 2 < 1 ? -3 : 3); i ? g.lineTo(x, y) : g.moveTo(x, y); } g.stroke(); } } },
+ feather: { h: 60, cols: [C.blue, C.green, C.black], d(g) { g.beginPath(); g.moveTo(-2, 29); g.quadraticCurveTo(-8, -10, 4, -29); g.quadraticCurveTo(12, -18, 6, 0); g.quadraticCurveTo(3, 15, 2, 29); g.stroke(); } },
+};
+const GN = Object.keys(GL);
+const glyphCols = (g, xs, y0, y1, seed) => { const r = rng(seed); g.lineCap = 'round';
+ xs.forEach(x => { g.strokeStyle = C.rule; g.lineWidth = 2.6; g.beginPath(); g.moveTo(x, y0); g.lineTo(x, y1); g.stroke(); });
+ for (let k = 0; k < xs.length - 1; k++) { const cx = (xs[k] + xs[k + 1]) / 2, s = (xs[k + 1] - xs[k]) / 78; let y = y0 + 8, prev = '';
+ while (true) { let n; do { n = GN[(r() * GN.length) | 0]; } while (n === prev); prev = n; const gl = GL[n]; if (y + gl.h * s > y1) break;
+ g.save(); g.translate(cx, y + gl.h * s / 2); g.scale(s, s); const col = gl.cols[(r() * gl.cols.length) | 0]; g.strokeStyle = col; g.fillStyle = col; g.lineWidth = 3.1; g.lineJoin = 'round'; gl.d(g); g.restore(); y += gl.h * s + 7; } } };
+// 彩块边(水平/竖直),块间黑缝
+function blocks(g, x0, y0, x1, y1, len, off = 0) {
+ const hor = (x1 - x0) > (y1 - y0), L = hor ? x1 - x0 : y1 - y0;
+ g.fillStyle = C.cream; g.fillRect(x0, y0, x1 - x0, y1 - y0);
+ for (let s = 0, k = off; s < L; s += len, k++) { g.fillStyle = BAND[k % 4];
+ if (hor) g.fillRect(x0 + s + 3, y0 + 3, Math.min(len - 6, L - s - 3), y1 - y0 - 6); else g.fillRect(x0 + 3, y0 + s + 3, x1 - x0 - 6, Math.min(len - 6, L - s - 3));
+ g.fillStyle = C.black; if (hor) g.fillRect(x0 + s, y0, 2, y1 - y0); else g.fillRect(x0, y0 + s, x1 - x0, 2); }
+ g.strokeStyle = C.black; g.lineWidth = 2; g.strokeRect(x0, y0, x1 - x0, y1 - y0);
+}
+function jar(g, cx, y0, s) {
+ g.save(); g.translate(cx, y0); g.scale(s, s);
+ poly(g, [[-26, 256], [-20, 256], [10, 196], [4, 196]]); fs(g, C.white, C.line, 2); poly(g, [[26, 256], [20, 256], [-10, 196], [-4, 196]]); fs(g, C.white, C.line, 2);
+ g.fillStyle = C.white; g.fillRect(-24, 198, 48, 6); g.strokeStyle = C.line; g.strokeRect(-24, 198, 48, 6);
+ g.beginPath(); g.moveTo(-10, 30); g.bezierCurveTo(-40, 50, -38, 120, -20, 180); g.quadraticCurveTo(-6, 222, 0, 228); g.quadraticCurveTo(6, 222, 20, 180); g.bezierCurveTo(38, 120, 40, 50, 10, 30); g.closePath(); fs(g, C.terra, C.line, 2.5);
+ g.save(); g.clip(); g.fillStyle = C.green; g.fillRect(-40, 52, 80, 6); g.fillStyle = C.blue; g.fillRect(-40, 58, 80, 4);
+ g.fillStyle = '#2f9a8a'; for (let x = -36; x < 36; x += 9) { poly(g, [[x, 62], [x + 9, 62], [x + 4.5, 82]]); g.fill(); } g.restore();
+ g.fillStyle = C.terra; g.fillRect(-9, 18, 18, 14); g.strokeStyle = C.line; g.lineWidth = 2; g.strokeRect(-9, 18, 18, 14);
+ g.beginPath(); g.moveTo(-14, 20); g.quadraticCurveTo(-14, -6, 0, -6); g.quadraticCurveTo(14, -6, 14, 20); g.closePath(); fs(g, '#3a302a', C.line, 2);
+ g.restore();
+}
+// 供桌:苇席桌上摞面包、蓝莲、鸭、葡萄
+function offering(g, x, y) {
+ g.fillStyle = C.yellow; g.fillRect(x - 70, y - 120, 140, 10); g.strokeStyle = C.line; g.lineWidth = 2; g.strokeRect(x - 70, y - 120, 140, 10);
+ g.fillStyle = C.yellow; g.fillRect(x - 8, y - 110, 16, 110); g.strokeRect(x - 8, y - 110, 16, 110); g.fillRect(x - 30, y - 8, 60, 8); g.strokeRect(x - 30, y - 8, 60, 8);
+ [[-52, -136, C.terra], [-20, -140, C.yellow], [14, -138, C.terra], [44, -134, '#c8802a']].forEach(([dx, dy, col]) => { g.beginPath(); g.ellipse(x + dx, y + dy, 18, 12, 0, 0, TAU); fs(g, col, C.line, 2); });
+ g.beginPath(); g.ellipse(x - 4, y - 166, 40, 13, 0, 0, TAU); fs(g, '#e8e0cc', C.line, 2);
+ for (let k = 0; k < 7; k++) { g.beginPath(); g.arc(x + 40 + (k % 3) * 9, y - 176 + Math.floor(k / 3) * 9, 5, 0, TAU); fs(g, '#5a3a7a', C.line, 1.2); }
+ // 蓝莲两朵从桌上垂下
+ [[-60, 1], [60, -1]].forEach(([dx, sg]) => { g.strokeStyle = C.green; g.lineWidth = 3; g.beginPath(); g.moveTo(x + dx * 0.6, y - 120); g.quadraticCurveTo(x + dx * 1.3, y - 80, x + dx * 1.2, y - 30); g.stroke();
+ poly(g, [[x + dx * 1.2, y - 30], [x + dx * 1.2 - 12, y - 4], [x + dx * 1.2, y - 12], [x + dx * 1.2 + 12, y - 4]]); fs(g, C.blue, C.line, 1.6); void sg; });
+}
+
+// ---------- 静态层(世界坐标 +OX,缓存) ----------
+const WALLTEX = () => P.cached('je_walltex', WW, H, g => {
+ const hw = Math.ceil(WW / 2), hh = H / 2, s = P.canvas(hw, hh), sg = s.getContext('2d'), img = sg.createImageData(hw, hh), d = img.data, r = rng(13);
+ for (let y = 0; y < hh; y++) for (let x = 0; x < hw; x++) { const n = P.fbm(x * 0.007 + 3, y * 0.007, 4), m = P.fbm(x * 0.05, y * 0.05 + 9, 2), k = (y * hw + x) * 4;
+ const col = P.mix(C.wall, C.wall2, clamp(0.35 - n * 1.2)); const v = 1 + m * 0.05 + (r() - 0.5) * 0.04; d[k] = col[0] * v; d[k + 1] = col[1] * v; d[k + 2] = col[2] * v; d[k + 3] = 255; }
+ sg.putImageData(img, 0, 0); g.imageSmoothingQuality = 'high'; g.drawImage(s, 0, 0, WW, H);
+});
+const SURF = () => P.cached('je_surface', WW, H, g => { // 壁画表面(multiply):斑驳+发丝裂纹+颗粒
+ const hw = Math.ceil(WW / 2), hh = H / 2, s = P.canvas(hw, hh), sg = s.getContext('2d'), img = sg.createImageData(hw, hh), d = img.data, r = rng(99);
+ for (let y = 0; y < hh; y++) for (let x = 0; x < hw; x++) { const n = P.fbm(x * 0.012 + 40, y * 0.012, 4), m = P.fbm(x * 0.06, y * 0.06 + 9, 2), v = 243 + n * 30 + m * 12 + (r() - 0.5) * 18, k = (y * hw + x) * 4; d[k] = v; d[k + 1] = v - 6; d[k + 2] = v - 16; d[k + 3] = 255; }
+ sg.putImageData(img, 0, 0); g.drawImage(s, 0, 0, WW, H);
+ const rr = rng(5); for (let q = 0; q < 9; q++) { let x = rr() * WW, y = rr() < 0.5 ? 0 : rr() * H, a = rr() * TAU; g.strokeStyle = 'rgba(90,70,50,.5)'; g.lineWidth = 1.1; g.beginPath(); g.moveTo(x, y); for (let k = 0; k < 34; k++) { a += (rr() - 0.5) * 0.7; x += Math.cos(a) * 14; y += Math.sin(a) * 14; g.lineTo(x, y); } g.stroke(); }
+ for (let x = 0; x < WW; x += W) g.drawImage(P.grain('eg_specks', 0.018, [70, 50, 30], 0.4), x, 0);
+});
+const GEESE = [[300, 498, 1], [520, 498, -1], [700, 498, 1]]; // 美杜姆群鹅(世界 x、脚底 y、朝向)
+const PAPY = [1260, 1760]; // 纸莎草丛 x 范围(上栏)
+const DISC = [880, 210];
+const STATIC = () => P.cached('je_static', WW, H, g => {
+ g.drawImage(WALLTEX(), 0, 0); const X = x => x + OX;
+ // 顶:kheker 饰带(束起的芦苇头)+彩块边
+ g.fillStyle = C.cream; g.fillRect(0, 0, WW, 74);
+ for (let x = 0, k = 0; x < WW; x += 34, k++) { g.beginPath(); g.moveTo(x + 6, 74); g.lineTo(x + 6, 26); g.quadraticCurveTo(x + 17, 0, x + 28, 26); g.lineTo(x + 28, 74); g.closePath(); fs(g, [C.red, C.blue, C.green][k % 3], C.black, 2);
+ g.fillStyle = C.cream; g.fillRect(x + 12, 34, 10, 8); g.fillStyle = C.yellow; g.beginPath(); g.arc(x + 17, 22, 5, 0, TAU); g.fill(); }
+ blocks(g, 0, 74, WW, 96, 44, 0);
+ // 上栏:象形字栏(三组)
+ glyphCols(g, [X(-120), X(-44), X(32), X(108)], 112, 500, 1350);
+ glyphCols(g, [X(1060), X(1132), X(1204)], 112, 520, 1351);
+ glyphCols(g, [X(1880), X(1956), X(2032), X(2108), X(2184)], 112, 520, 1352);
+ // 有翼日盘的翅膀(静态部分;日盘本身每帧画以便脉动)
+ const [dx, dy] = [X(DISC[0]), DISC[1]];
+ for (const sg2 of [-1, 1]) { for (let r2 = 0; r2 < 3; r2++) { g.beginPath(); g.moveTo(dx + sg2 * 40, dy - 10 + r2 * 12); g.quadraticCurveTo(dx + sg2 * 150, dy - 34 + r2 * 18, dx + sg2 * (250 - r2 * 40), dy - 4 + r2 * 18); g.lineTo(dx + sg2 * (240 - r2 * 40), dy + 12 + r2 * 18); g.quadraticCurveTo(dx + sg2 * 140, dy - 6 + r2 * 18, dx + sg2 * 40, dy + 6 + r2 * 12); g.closePath(); fs(g, [C.blue, C.green, C.red][r2], C.black, 2); }
+ for (let f = 0; f < 9; f++) { g.strokeStyle = C.black; g.lineWidth = 1.4; g.beginPath(); g.moveTo(dx + sg2 * (60 + f * 22), dy - 18); g.lineTo(dx + sg2 * (60 + f * 22), dy + 40); g.stroke(); } }
+ // 上栏底的水带(纸莎草下的沼泽)
+ g.fillStyle = C.water; g.fillRect(X(1180), 500, 680, 40); g.strokeStyle = C.black; g.lineWidth = 2; g.strokeRect(X(1180), 500, 680, 40);
+ // 540 分栏线、760 地线:彩块带
+ blocks(g, 0, REG - 8, WW, REG + 8, 38, 1);
+ blocks(g, 0, G, WW, G + 16, 38, 2);
+ // 中栏:尖底罐、供桌(他走过时在身后)
+ jar(g, X(250), G - 256 * 0.86, 0.86); jar(g, X(330), G - 256 * 0.8, 0.8);
+ offering(g, X(620), G);
+ jar(g, X(1660), G - 256 * 0.86, 0.86);
+ offering(g, X(1880), G);
+ glyphCols(g, [X(1420), X(1490), X(1560)], 562, 740, 1353);
+ // 下栏:尼罗河(水色带+黑色之字水纹另画动态)+底部护墙裙
+ g.fillStyle = C.water; g.fillRect(0, G + 16, WW, 230);
+ blocks(g, 0, G + 246, WW, G + 262, 38, 3);
+ g.fillStyle = '#7a2a1c'; g.fillRect(0, G + 262, WW, H - G - 262); g.fillStyle = C.black; g.fillRect(0, G + 290, WW, 6); g.fillStyle = C.yellow; g.fillRect(0, G + 296, WW, 3);
+});
+
+// ---------- 动态母题 ----------
+function goose(c, x, y, fx, t, k) { // 美杜姆鹅:侧身、平涂、勾线;点头啄食
+ const peck = Math.max(0, Math.sin(t * 2.2 + k * 2.1)) ** 3;
+ c.save(); c.translate(x, y); c.scale(fx * 1.2, 1.2);
+ c.strokeStyle = C.line; c.lineWidth = 2; c.beginPath(); c.moveTo(-6, -14); c.lineTo(-10, 0); c.moveTo(6, -14); c.lineTo(10, 0); c.stroke();
+ c.fillStyle = C.red; c.fillRect(-16, -2, 12, 3); c.fillRect(6, -2, 12, 3);
+ c.beginPath(); c.moveTo(-60, -48); c.quadraticCurveTo(-30, -78, 20, -66); c.quadraticCurveTo(44, -56, 40, -36); c.quadraticCurveTo(20, -12, -30, -16); c.quadraticCurveTo(-56, -22, -60, -48); c.closePath(); fs(c, '#d8c8a8', C.line, 2);
+ c.save(); c.clip(); c.fillStyle = '#8a6a4a'; c.fillRect(-60, -80, 120, 26); c.strokeStyle = '#4a3a2a'; c.lineWidth = 1.4; for (let i = 0; i < 6; i++) { c.beginPath(); c.moveTo(-50 + i * 14, -64); c.lineTo(-40 + i * 14, -52); c.stroke(); } c.restore();
+ c.save(); c.translate(30, -58); c.rotate(peck * 0.9);
+ c.beginPath(); c.moveTo(-6, 4); c.quadraticCurveTo(0, -40, 10, -56); c.lineTo(20, -54); c.quadraticCurveTo(12, -34, 8, 6); c.closePath(); fs(c, '#a8886a', C.line, 1.8);
+ c.beginPath(); c.ellipse(16, -58, 11, 8, 0, 0, TAU); fs(c, '#6a5a4a', C.line, 1.6); poly(c, [[24, -60], [40, -56], [24, -52]]); fs(c, '#d86a2a', C.line, 1.2);
+ c.fillStyle = '#fff'; c.beginPath(); c.arc(18, -60, 2.4, 0, TAU); c.fill();
+ c.restore(); c.restore();
+}
+function papyrus(c, x0, x1, t, camX) { // 纸莎草丛:茎+伞形花头,成片摇;水鸟从丛中惊飞
+ const r = rng(77);
+ for (let i = 0; i < 26; i++) { const bx = lerp(x0, x1, r()) - camX, top = 170 + r() * 120, sw = Math.sin(t * 1.4 + i * 0.7) * 10 * (0.5 + r() * 0.5);
+ if (bx < -100 || bx > W + 100) { r(); continue; }
+ c.strokeStyle = C.papy; c.lineWidth = 4; c.beginPath(); c.moveTo(bx, 500); c.quadraticCurveTo(bx + sw * 0.3, (500 + top) / 2, bx + sw, top); c.stroke();
+ c.save(); c.translate(bx + sw, top); c.rotate(sw * 0.02); poly(c, [[0, 0], [-34, -46], [34, -46]]); fs(c, i % 3 ? C.papyL : C.papy, C.line, 2);
+ c.strokeStyle = C.line; c.lineWidth = 1.2; for (let k = -2; k <= 2; k++) { c.beginPath(); c.moveTo(0, 0); c.lineTo(k * 15, -46); c.stroke(); } c.fillStyle = C.yellow; c.fillRect(-34, -50, 68, 5); c.restore(); }
+ // 水鸟:在纸莎草上方绕圈扑翅(两套翅膀姿态,10fps 交替)
+ for (let k = 0; k < 6; k++) { const ph = t * 0.9 + k * 1.05, bx = (x0 + x1) / 2 + Math.cos(ph) * 220 + (k - 2.5) * 30 - camX, by = 200 + Math.sin(ph * 1.3) * 60 + k * 8; if (bx < -60 || bx > W + 60) continue;
+ const up = Math.floor(t * 10 + k) % 2, fx = Math.sin(ph) < 0 ? 1 : -1;
+ c.save(); c.translate(bx, by); c.scale(fx, 1); c.beginPath(); c.ellipse(0, 0, 18, 8, 0, 0, TAU); fs(c, k % 2 ? C.white : '#5a8ab0', C.line, 1.6);
+ c.beginPath(); c.arc(18, -4, 6, 0, TAU); fs(c, k % 2 ? C.green : '#2a3a5a', C.line, 1.4); poly(c, [[23, -4], [32, -2], [23, 0]]); fs(c, C.yellow, null);
+ poly(c, up ? [[-6, -2], [-16, -30], [6, -4]] : [[-6, 2], [-18, 22], [6, 4]]); fs(c, k % 2 ? '#c8d8e8' : '#3a6a9a', C.line, 1.4); c.restore(); }
+}
+function nile(c, t, camX) { // 下栏:黑色之字水纹向左流,鱼游,蓝莲点头
+ const y0 = G + 30, y1 = G + 236, step = 26, off = (t * 60) % (step * 2);
+ c.save(); c.strokeStyle = '#13213f'; c.lineWidth = 3; c.lineJoin = 'miter';
+ for (let y = y0; y < y1; y += 30) { c.beginPath(); const sh = ((y / 30) % 2) * step; for (let x = -step * 2 - off + sh - (camX % (step * 2)); x < W + step * 2; x += step) { const yy = y + ((Math.round((x + off - sh + camX) / step)) % 2 ? 9 : -9); x === -step * 2 - off + sh - (camX % (step * 2)) ? c.moveTo(x, yy) : c.lineTo(x, yy); } c.stroke(); }
+ c.restore();
+ const r = rng(19);
+ for (let k = 0; k < 9; k++) { const sp = 30 + r() * 40, dir = r() < 0.5 ? -1 : 1, base = r() * (w + 400) - 200, fy = y0 + 30 + r() * 160;
+ let wx = base + dir * sp * t; wx = ((wx + 300) % (w + 600) + (w + 600)) % (w + 600) - 300; const fx = wx - camX; if (fx < -80 || fx > W + 80) continue;
+ const wig = Math.sin(t * 9 + k) * 0.12;
+ c.save(); c.translate(fx, fy); c.scale(dir, 1); c.rotate(wig * 0.3);
+ c.beginPath(); c.ellipse(0, 0, 30, 14, 0, 0, TAU); fs(c, k % 2 ? '#8aa0b8' : '#c8a060', C.black, 1.8);
+ poly(c, [[-26, 0], [-44, -12 + wig * 30], [-44, 12 + wig * 30]]); fs(c, k % 2 ? '#8aa0b8' : '#c8a060', C.black, 1.6);
+ c.strokeStyle = C.black; c.lineWidth = 1.2; c.beginPath(); c.moveTo(-10, -12); c.quadraticCurveTo(4, -22, 18, -10); c.stroke(); c.fillStyle = '#fff'; c.beginPath(); c.arc(18, -3, 3.2, 0, TAU); c.fill(); c.fillStyle = C.black; c.beginPath(); c.arc(19, -3, 1.6, 0, TAU); c.fill();
+ c.restore(); }
+ for (let k = 0; k < 14; k++) { const lx = k * 170 + 40 - camX; if (lx < -40 || lx > W + 40) continue; const nod = Math.sin(t * 2 + k) * 0.12;
+ c.save(); c.translate(lx, G + 18); c.rotate(nod); c.strokeStyle = C.green; c.lineWidth = 3; c.beginPath(); c.moveTo(0, 30); c.lineTo(0, -10); c.stroke();
+ poly(c, [[0, -8], [-14, -36], [-5, -30], [0, -44], [5, -30], [14, -36]]); fs(c, k % 2 ? C.blue : C.white, C.line, 1.6); c.restore(); }
+}
+// 有翼日盘:红盘+两条圣蛇,光晕脉动
+function disc(c, x, y, t) { const pu = 0.5 + 0.5 * Math.sin(t * TAU / 0.9);
+ const hg = c.createRadialGradient(x, y, 30, x, y, 80 + 20 * pu); hg.addColorStop(0, `rgba(255,180,80,${0.35 * pu + 0.1})`); hg.addColorStop(1, 'rgba(255,170,70,0)'); c.fillStyle = hg; c.fillRect(x - 110, y - 110, 220, 220);
+ c.beginPath(); c.arc(x, y, 34, 0, TAU); fs(c, '#c8372b', '#7a1c14', 3);
+ for (const s of [-1, 1]) { c.beginPath(); c.moveTo(x + s * 30, y + 26); c.quadraticCurveTo(x + s * 44, y + 6, x + s * 38, y - 14); c.lineWidth = 6; c.strokeStyle = C.gold; c.stroke(); c.beginPath(); c.arc(x + s * 38, y - 16, 6, 0, TAU); fs(c, C.gold, C.black, 1.4); } }
+
+// ---------- 圣甲虫(背视:青金石身、绿松石鞘翅),头朝左推着红色太阳球滚 ----------
+function scarab(c, x, y, s, t) {
+ c.save(); c.translate(x, y); c.scale(s, s); c.lineCap = 'round'; c.lineJoin = 'round'; c.rotate(-Math.PI / 2);
+ const pose = Math.floor(t * 15) % 2;
+ c.strokeStyle = '#141a30'; c.lineWidth = 3; // 腿:两套姿态交替
+ const legs = pose ? [[-14, -16, -26], [0, -18, -6], [14, -14, 18]] : [[-14, -14, -32], [0, -19, 2], [14, -18, 24]];
+ legs.forEach(([ly, lx, ex]) => { for (const sg of [-1, 1]) { c.beginPath(); c.moveTo(sg * 10, ly + 14); c.lineTo(sg * 24, ly + 14 + (ex - ly) * 0.3); c.lineTo(sg * 30, ly + 24 + (pose ? 3 : -3) * sg); c.stroke(); } void lx; });
+ c.beginPath(); c.ellipse(0, 8, 17, 23, 0, 0, TAU); fs(c, C.lapis, '#0d1430', 2.2);
+ c.beginPath(); c.moveTo(0, -12); c.lineTo(0, 30); c.stroke();
+ c.fillStyle = C.turq; c.beginPath(); c.ellipse(-7, 6, 4, 13, 0.1, 0, TAU); c.fill(); c.beginPath(); c.ellipse(7, 6, 4, 13, -0.1, 0, TAU); c.fill();
+ c.beginPath(); c.ellipse(0, -18, 12, 8, 0, 0, TAU); fs(c, '#3a68c4', '#0d1430', 2);
+ c.beginPath(); c.moveTo(-10, -24); for (let k = 0; k < 5; k++) c.lineTo(-10 + k * 5, -28 - (k % 2) * 4); c.lineTo(10, -24); fs(c, '#3a68c4', '#0d1430', 1.6);
+ const by = -52, br = 23; // 日球:在头前,随滚动转
+ c.beginPath(); c.arc(0, by, br, 0, TAU); fs(c, '#c8302a', '#3a0c08', 2.2);
+ c.save(); c.clip(); c.fillStyle = '#f2c23a'; for (let k = 0; k < 6; k++) { const a = t * 10 + k * 1.05; c.beginPath(); c.arc(Math.cos(a) * br * 0.55, by + Math.sin(a) * br * 0.55, 3.4, 0, TAU); c.fill(); } c.restore();
+ c.restore();
+}
+// 圣甲虫在世界里的位置(ta = 互动内秒):一直往左滚,从他脚下穿过、滚出画外
+const SC_S = 1.9, scX = ta => AX + 52 * SC_S + V_SC * (T_HIT - ta); // 圣甲虫身体中心;球在它左边 52*SC_S,T_HIT 时球正好滚到他脚下
+function scarabWorld(c, s, seg) {
+ const ta = XJ.ta(seg, s); if (ta < -3 || ta > 6) return;
+ const x = scX(ta) - s.camX; if (x < -200 || x > W + 150) return;
+ scarab(c, x, G - 23 * SC_S - 3, SC_S, s.t);
+}
+// ---------- 主角材质:灰泥墙面斑驳 multiply(只在人身上),白保持白 ----------
+const heroMat = (g, ww, hh, i) => {
+ XJ.texInside(g, ww, hh, (tg, w2, h2) => { const S = SURF(); tg.drawImage(S, -((i * 137) % 600) - 200, -300); });
+};
+
+WORLD.add({
+ id: '02_egypt', year: -1350, name: '古埃及壁画', w, burst: 'jia_egypt', labelColor: 'rgba(42,24,16,.85)',
+ hero: { walk: K.walk, h: 300, fps: WALK.fps, // 一个步态循环 8 帧(4 帧一步);帧率按量出的步幅定,脚底锁见 XJ.walkLock
+ shadow: null, draw(c, key, i, o, S) { if (key === K.act) { const gw = XJ.glideWalk(S, DUR, WALK.fps, 8, 0.22, true); if (gw != null) { key = K.walk; i = gw; } } if (key === K.walk) o.lock = (S.act ? 0 : XJ.walkLock({ w }, S, i, WALK.st, WALK.fps)); XJ.actor(c, key, i, o, 'egypt', heroMat); } },
+ acts: [{ at: AT, dur: DUR, key: K.act, lead: 0, ...XJ.glide(DUR),
+ frame: XJ.actFrame([[0, 1], [0.22, 2], [0.3, 3], [0.42, 4], [1.04, 5], [1.2, 6], [1.4, 7]]),
+ y: (lx, u) => G - 140 * Math.sin(Math.PI * clamp((u - 0.22) / 0.9)) }],
+ back(c, s) {
+ c.drawImage(STATIC(), -OX - s.camX, 0);
+ if (XJ.vis(s, DISC[0], 400)) disc(c, DISC[0] - s.camX, DISC[1], s.t);
+ GEESE.forEach(([x, y, f], k) => { if (XJ.vis(s, x, 120)) goose(c, x - s.camX, y, f, s.t, k); });
+ papyrus(c, PAPY[0], PAPY[1], s.t, s.camX);
+ nile(c, s.t, s.camX);
+ scarabWorld(c, s, this);
+ c.save(); c.globalCompositeOperation = 'multiply'; c.drawImage(SURF(), -OX - s.camX, 0); c.restore();
+ },
+ front(c, s) {
+ // 跳起时脚下扬起的一点金色尘(埃及式:小三角点)
+ const ta = XJ.ta(this, s);
+ if (ta > 1.1 && ta < 1.5) { const q = (ta - 1.1) / 0.4, x = AX - s.camX; c.save(); c.globalAlpha = 1 - q; c.fillStyle = C.gold; for (let k = 0; k < 8; k++) { const a = Math.PI + (k / 7) * Math.PI, d = 30 + q * 60; c.beginPath(); c.arc(x + Math.cos(a) * d, G - 6 + Math.sin(a) * d * 0.3, 4, 0, TAU); c.fill(); } c.restore(); }
+ },
+ // 进入埃及的边界:一条竖向四色彩块边(墓室壁画的边框语言)
+ seam(c, y, sx, t) { const k = Math.floor((y + 1000) / 36), yy = (y + 1000) % 36; c.fillStyle = yy < 3 ? C.black : BAND[k % 4]; c.fillRect(sx - 10, y, 20, 6); c.fillStyle = C.black; c.fillRect(sx - 12, y, 2, 6); c.fillRect(sx + 10, y, 2, 6); },
+});
+})();
diff --git a/scripts/engine/demos/long_scroll/segments/14_8bit.js b/scripts/engine/demos/long_scroll/segments/14_8bit.js
new file mode 100644
index 0000000..f0714ec
--- /dev/null
+++ b/scripts/engine/demos/long_scroll/segments/14_8bit.js
@@ -0,0 +1,118 @@
+// 21 · 1980s 8-bit 像素游戏(通用 8-bit 语法,不指向任何一款游戏:夜晚紫色天空、像素星空和月亮、远山剪影、萤火虫、浮空木平台、星星方块、宝箱)。
+// 互动:跳起来顶星星方块,方块一跳,弹出一枚转着的像素金币,升到顶点闪一下消失,100 飘起、HUD 金币 7→8、分数 +100;他落地仰头再欢呼一跳。所有事件相对互动定时。
+// 画法沿用 skill 场景 14_8bit:整个世界在 1/8 分辨率画布上逐像素画(1 低像素 = 8 屏幕像素),imageSmoothing 关掉放大;天空交界用 (x+y)%2 棋盘抖动(NES 做渐变的唯一办法)。
+// 花叔=AI 生的像素小人帧,代码再按 6px 网格降采样、alpha 二值化(去抗锯齿),保证是真·硬边像素。
+(() => {
+if (!window.D4) { const x = new XMLHttpRequest(); x.open('GET', 'demos/long_scroll/lib/xing2_ding.js', false); x.send(); (0, eval)(x.responseText); }
+const W = 1920, H = 1080, TAU = Math.PI * 2, { clamp, lerp, ss, ease } = U, P = PAINT;
+const SW = 2000, PX = 8, LW = SW / PX, LH = H / PX, G = 760, GR = G / PX, AT = 900, DUR = 1.6;
+const BX = Math.round(AT / PX) - 4, BY = 33; // 星星方块(低分辨率格):x 在他头顶,y 33..41 → 屏幕 264..328
+const PAL = { sky0: '#140c38', sky1: '#2a1660', sky2: '#4a2a8a', sky3: '#7a46a8', white: '#fcfcfc', black: '#000000', star: '#fcf4b8', moon: '#fce8a8', moonD: '#d8b868', mtn: '#1c1448', mtnL: '#3c2c78', pine: '#0c0a24', stone: '#3c4a6c', stoneD: '#24304c', stoneL: '#6a7ca0', moss: '#3cb87c', mossL: '#8cf0a8', wood: '#a8642c', woodD: '#5c3014', woodL: '#e09c54', blk: '#2c5cd8', blkD: '#183898', blkL: '#7cacfc', gold: '#f8d040', coin: '#f8d878', coinD: '#e45c10', chest: '#b4602c', fly: '#d8fc6c' };
+const WALK = '8bit_walk', ACTK = '8bit_act';
+const REAL = ACTK === '8bit_act';
+const tab = (u, T) => { let f = T[0][1]; for (const [a, i] of T) if (u >= a) f = i; return f; };
+// 0 站 1 蹲 2 起跳举拳 3 顶 4 下落 5 落地 6 仰头 7 欢呼
+const HF = REAL ? [[0, 0], [0.08, 1], [0.2, 2], [0.32, 3], [0.46, 4], [0.6, 5], [0.72, 6], [1.1, 7]] : [[0, 0], [0.08, 2], [0.2, 4], [0.32, 5], [0.46, 7], [0.6, 9], [0.72, 0], [1.1, 6]];
+const J0 = 0.2, J1 = 0.6, T_HIT = (J0 + J1) / 2, T_TOP = T_HIT + 0.5, T_SCORE = T_TOP + 0.08; // 跳 0.2→0.6,最高点顶砖;金币升 0.5s 到顶闪没
+
+// ---------- 字符位图 ----------
+const BMP = {
+ star: ['...#....', '...#....', '.#####..', '..###...', '..#.#...', '.#...#..', '........', '........'],
+ moon: ['...####...', '.##....##.', '#.......##', '#........#', '#.....#..#', '#........#', '#.#......#', '.##....##.', '...####...'],
+ chest: ['.########.', '#oooooooo#', '#oooooooo#', '##########', '#ooooYYooo', '#oooYYYYoo', '#oooooooo#', '##########'],
+ cloud: ['....######......', '..##......##.....', '.#..........###..', '#...............#', '.################'],
+};
+const bmp = (g, rows, x, y, col) => { g.fillStyle = col; rows.forEach((r, j) => { for (let i = 0; i < r.length; i++) if (r[i] === '#') g.fillRect(x + i, y + j, 1, 1); }); };
+const dither = (g, x0, x1, y0, y1, a, b) => { for (let y = y0; y < y1; y++) for (let x = x0; x < x1; x++) { g.fillStyle = (x + y) % 2 ? a : b; g.fillRect(x, y, 1, 1); } };
+
+// ---------- 静态世界(低分辨率,缓存) ----------
+let LO = null;
+function build() {
+ if (LO) return LO;
+ const cv = P.canvas(LW, LH), g = cv.getContext('2d'), r = U.rng(85);
+ // 夜空:四档紫,交界棋盘抖动(NES 渐变)
+ [[0, PAL.sky0], [22, PAL.sky1], [44, PAL.sky2], [60, PAL.sky3]].forEach(([y, col], k, A) => { g.fillStyle = col; g.fillRect(0, y, LW, (A[k + 1] ? A[k + 1][0] : GR) - y); if (k) dither(g, 0, LW, y - 2, y, A[k - 1][1], col); });
+ // 静态小星(单像素),大月亮(带坑)
+ for (let k = 0; k < 160; k++) { const x = (r() * LW) | 0, y = (r() * 52) | 0; g.fillStyle = r() < 0.7 ? '#b8a8e8' : PAL.star; g.fillRect(x, y, 1, 1); }
+ { const mx = 176, my = 8; for (let y = 0; y < 14; y++) for (let x = 0; x < 14; x++) { const d = Math.hypot(x - 6.5, y - 6.5); if (d < 7) { g.fillStyle = d > 6 ? PAL.moonD : PAL.moon; g.fillRect(mx + x, my + y, 1, 1); } } g.fillStyle = PAL.moonD; [[4, 4, 2], [9, 8, 2], [5, 10, 1]].forEach(([x, y, w]) => g.fillRect(mx + x, my + y, w, w)); }
+ // 远山剪影(锯齿+亮边),地平线 68 → 屏幕 544
+ for (let x = 0; x < LW; x++) { const top = Math.round(60 - 10 * Math.abs(Math.sin(x * 0.045)) - 6 * Math.abs(Math.sin(x * 0.13 + 1))); g.fillStyle = PAL.mtn; g.fillRect(x, top, 1, 68 - top); g.fillStyle = PAL.mtnL; g.fillRect(x, top, 1, 1); }
+ // 中景:松树剪影带
+ g.fillStyle = PAL.pine; g.fillRect(0, 68, LW, GR - 68);
+ for (let x = 2; x < LW; x += 5 + ((r() * 4) | 0)) { const h = 10 + ((r() * 10) | 0); for (let j = 0; j < h; j++) { const w = Math.max(0, Math.floor((j / h) * 4)); g.fillRect(x - w, 70 - h + j, 2 * w + 1, 1); } }
+ // 地面:苔藓石阶(顶一行亮苔,下面石块错缝)
+ for (let y = GR; y < LH; y += 6) for (let x = (y / 6) % 2 ? 0 : -5; x < LW; x += 10) { g.fillStyle = PAL.stone; g.fillRect(x, y, 10, 6); g.fillStyle = PAL.stoneL; g.fillRect(x, y, 10, 1); g.fillStyle = PAL.stoneD; g.fillRect(x + 9, y, 1, 6); g.fillRect(x, y + 5, 10, 1); }
+ for (let x = 0; x < LW; x++) { g.fillStyle = PAL.moss; g.fillRect(x, GR, 1, 2); if ((x * 7) % 5 === 0) { g.fillStyle = PAL.mossL; g.fillRect(x, GR - 1, 1, 1); } }
+ // 浮空木平台(两端木桩):星星方块两侧、远处两块;一块上放宝箱
+ const plank = (x, y, n) => { for (let k = 0; k < n; k++) { g.fillStyle = PAL.wood; g.fillRect(x + k * 6, y, 6, 4); g.fillStyle = PAL.woodL; g.fillRect(x + k * 6, y, 6, 1); g.fillStyle = PAL.woodD; g.fillRect(x + k * 6 + 5, y, 1, 4); g.fillRect(x + k * 6, y + 3, 6, 1); } g.fillStyle = PAL.black; g.fillRect(x - 1, y, 1, 4); g.fillRect(x + n * 6, y, 1, 4); };
+ plank(BX - 20, BY + 2, 3); plank(BX + 9, BY + 2, 3); plank(20, 48, 4); plank(170, 46, 5);
+ const C2 = { '#': PAL.black, o: PAL.chest, Y: PAL.gold }; BMP.chest.forEach((row, j) => [...row].forEach((ch, i) => { if (C2[ch]) { g.fillStyle = C2[ch]; g.fillRect(182 + i, 38 + j, 1, 1); } }));
+ return (LO = cv);
+}
+
+// ---------- 低分辨率坐标 → 屏幕:全部对齐同一张 8px 网格(随相机整体平移) ----------
+const sx = (lx, camX) => lx * PX - camX;
+function qblock(c, camX, t, bump, used) { // 星星方块:蓝块+黄星,星星呼吸闪;被顶过后变灰
+ const x = sx(BX, camX), y = BY * PX - bump * PX;
+ c.fillStyle = PAL.black; c.fillRect(x, y, 8 * PX, 8 * PX);
+ c.fillStyle = used ? '#5c5c74' : PAL.blk; c.fillRect(x, y, 7 * PX, 7 * PX);
+ c.fillStyle = used ? '#8c8ca4' : PAL.blkL; c.fillRect(x, y, 7 * PX, PX); c.fillRect(x, y, PX, 7 * PX);
+ c.fillStyle = used ? '#3c3c50' : PAL.blkD; c.fillRect(x + 6 * PX, y + PX, PX, 6 * PX); c.fillRect(x + PX, y + 6 * PX, 6 * PX, PX);
+ if (!used) { c.save(); c.translate(x, y + PX); c.scale(PX, PX); bmp(c, BMP.star, 0, 0, Math.floor(t * 6) % 3 ? PAL.gold : '#fcfcd0'); c.restore(); }
+}
+function coin(c, x, y, t, s = 1) { // 像素金币:宽度 8/6/2/6 循环 = 翻转
+ const ph = Math.floor(t * 8) % 4, w = [8, 6, 3, 6][ph], h = 12, u = 4 * s; // 8fps 翻转,最窄也留 3 格(审片:细条一闪看不出是金币) c.fillStyle = PAL.black; c.fillRect(x - w * u / 2 - u, y - h * u - u, w * u + 2 * u, h * u + 2 * u);
+ c.fillStyle = PAL.coinD; c.fillRect(x - w * u / 2, y - h * u, w * u, h * u);
+ if (w > 3) { c.fillStyle = PAL.coin; c.fillRect(x - w * u / 2 + u, y - h * u + u, Math.max(u, w * u - 3 * u), h * u - 3 * u); c.fillStyle = '#fcfcfc'; c.fillRect(x - w * u / 2 + u, y - h * u + 2 * u, u, 4 * u); }
+}
+function hud(c, coins, score) {
+ c.save(); c.font = '36px "PressStart2P-400"'; c.textBaseline = 'top'; c.fillStyle = '#000'; const T = (s, x, y) => { c.fillStyle = '#000'; c.fillText(s, x + 6, y + 6); c.fillStyle = '#fcfcfc'; c.fillText(s, x, y); };
+ T('HUASHU', 60, 40); T(String(score).padStart(6, '0'), 60, 88); T('×' + String(coins).padStart(2, '0'), 470, 88); coin(c, 444, 128, 0, 0.75);
+ c.restore();
+}
+
+// ---------- 花叔像素化:6px 网格降采样+alpha 二值化 ----------
+const pix = (key, i) => D4.frameCanvas(key, i, 'px6', im => {
+ const s = 300 / XING.SPR[key].meta.ref_h, k = s / 6, w = Math.max(1, Math.round(im.width * k)), h = Math.max(1, Math.round(im.height * k));
+ const cv = P.canvas(w, h), g = cv.getContext('2d', { willReadFrequently: true }); g.imageSmoothingEnabled = false; g.drawImage(im, 0, 0, w, h); // 最近邻:像素画源图的色块不被平均成泥
+ const d = g.getImageData(0, 0, w, h), q = d.data; for (let j = 0; j < q.length; j += 4) { if (q[j + 3] < 120) q[j + 3] = 0; else { q[j + 3] = 255; for (let m = 0; m < 3; m++) q[j + m] = Math.round(q[j + m] / 36) * 36; } } g.putImageData(d, 0, 0);
+ cv.k = w / im.width; cv.pixel = true; cv.pad = 0; return cv;
+});
+const apexTop = () => { const f = XING.SPR[ACTK].meta.frames[HF[3][1]], s = 300 / XING.SPR[ACTK].meta.ref_h; return f.ay * s; }; // 顶砖那帧:脚底到拳头顶的高度
+
+WORLD.add({
+ id: '14_8bit', year: '1980s', name: '8-bit 像素游戏', w: SW, burst: 'vg', labelColor: 'rgba(252,252,252,.95)',
+ hero: { walk: WALK, h: 300, shadow: null, draw(c, key, i, o, S) { D4.drawFrame(c, key, i, o, pix(key, i)); } },
+ acts: [{ at: AT, dur: DUR, key: ACTK, lead: 140, frame: u => Math.min(tab(u, HF), XING.nFrames(ACTK) - 1),
+ // 跳:J0→J1 抛物线,最高点拳头正好顶到砖底;欢呼时再小跳一下
+ y: (lx, u) => { const q = clamp((u - J0) / (J1 - J0)); const lift = Math.max(0, (G - (BY + 8) * PX) - apexTop()); return G - Math.sin(q * Math.PI) * lift - (u > 1.1 && u < 1.4 ? Math.sin((u - 1.1) / 0.3 * Math.PI) * 40 : 0); } }],
+ back(c, s) {
+ const lo = build(); c.save(); c.imageSmoothingEnabled = false;
+ const ox = Math.floor(s.camX / PX), fx = s.camX - ox * PX;
+ c.drawImage(lo, ox, 0, LW - ox, LH, -fx, 0, (LW - ox) * PX, H); c.restore();
+ c.imageSmoothingEnabled = false;
+ // 闪烁星:一部分星 6fps 亮灭(整像素)
+ for (let k = 0; k < 40; k++) { const lx = U.hash(k, 11) * LW, ly = U.hash(k, 12) * 50; if (U.hash(k, Math.floor(s.t * 6)) < 0.5) continue; const X = sx(lx | 0, s.camX * 0.3 / 1) , Y = (ly | 0) * PX; c.fillStyle = PAL.star; c.fillRect(Math.round(X / PX) * PX, Y, PX, PX); c.fillRect(Math.round(X / PX) * PX - PX, Y + 0, PX * 3, PX * 0 + 2); }
+ // 夜云:深紫像素云整格左移
+ for (let k = 0; k < 5; k++) { const lx = ((k * 61 + 300 - Math.floor(s.t * 3)) % 320 + 320) % 320 - 20, ly = 14 + (k * 9) % 26; c.save(); c.translate(Math.round(sx(lx, s.camX * 0.6) / PX) * PX, ly * PX); c.scale(PX, PX); c.fillStyle = '#3a2470'; c.fillRect(1, 1, 15, 3); c.fillRect(4, 0, 7, 1); bmp(c, BMP.cloud, 0, 0, '#5a3c98'); c.restore(); }
+ // 流星:每 2.4 秒一颗,斜着划过(拖 5 格尾巴)
+ { const ph = (s.t % 2.4) / 0.5; if (ph < 1) { const hx = 40 + ((Math.floor(s.t / 2.4) * 67) % 160), lx = hx + ph * 30, ly = 6 + ph * 12; for (let k = 0; k < 6; k++) { c.fillStyle = k ? `rgba(252,244,184,${1 - k / 6})` : '#fff'; c.fillRect(Math.round(sx(lx - k * 2, s.camX * 0.3)), Math.round((ly - k * 0.8)) * PX, PX, PX); } } }
+ // 萤火虫:12 只在草丛上方慢飘、按自己的节奏亮灭
+ for (let k = 0; k < 12; k++) { const lx = U.hash(k, 21) * LW + Math.sin(s.t * 0.8 + k) * 4, ly = GR - 4 - U.hash(k, 22) * 14 + Math.sin(s.t * 1.3 + k * 2) * 2, on = Math.sin(s.t * 3 + k * 1.7) > 0.2; if (!on) continue; c.fillStyle = PAL.fly; c.fillRect(Math.round(sx(lx, s.camX) / PX) * PX, Math.round(ly) * PX, PX, PX); c.fillStyle = 'rgba(216,252,108,.3)'; c.fillRect(Math.round(sx(lx, s.camX) / PX) * PX - PX, Math.round(ly) * PX - PX, 3 * PX, 3 * PX); }
+ // 宝箱盖子一开一合,冒一颗金光
+ { const op = Math.floor(s.t * 1.5) % 2, X = sx(182, s.camX), Y = 38 * PX; if (op) { c.fillStyle = PAL.gold; c.fillRect(X + 3 * PX, Y - 2 * PX, 4 * PX, PX); c.fillStyle = '#fff'; c.fillRect(X + 4 * PX, Y - 4 * PX, PX, PX); } }
+ // 星星方块:被顶时上跳 2 格再落回,之后变成用过的灰块
+ const u = D4.since(this, s), bump = u > T_HIT && u < T_HIT + 0.16 ? Math.round(Math.sin((u - T_HIT) / 0.16 * Math.PI) * 2) : 0;
+ qblock(c, s.camX, s.t, bump, u > T_HIT);
+ // 金币:从砖顶弹出、转着上升(减速)→ 顶点闪一下消失(像素十字星)
+ const cx = sx(BX + 4, s.camX), cy0 = BY * PX;
+ if (u > T_HIT && u < T_TOP) { const q = (u - T_HIT) / (T_TOP - T_HIT); coin(c, cx, Math.round((cy0 - ease.out(q) * 130) / 4) * 4, s.t, 1.5); }
+ if (u >= T_TOP && u < T_TOP + 0.24) { const q = (u - T_TOP) / 0.24, r = Math.round((8 + q * 40) / 4) * 4; c.fillStyle = q < 0.5 ? '#fcfcfc' : PAL.coin; [[0, -1], [0, 1], [-1, 0], [1, 0]].forEach(([dx, dy]) => c.fillRect(cx + dx * r - 4, cy0 - 150 + dy * r - 4, 8, 8)); c.fillRect(cx - 4, cy0 - 150 - 4, 8, 8); }
+ if (u > T_SCORE && u < T_SCORE + 0.7) { c.save(); c.font = '30px "PressStart2P-400"'; c.fillStyle = '#fcfcfc'; c.globalAlpha = 1 - clamp((u - T_SCORE - 0.45) / 0.25); c.fillText('100', cx + 50, cy0 - 70 - (u - T_SCORE) * 60); c.restore(); }
+ hud(c, u >= T_SCORE ? 8 : 7, u >= T_SCORE ? 2100 : 2000);
+ c.imageSmoothingEnabled = true;
+ },
+ // 边界:一列一列的像素方块(黑白相间的格子边)
+ seam(c, y, sxp, t) { const q = Math.round(sxp / PX) * PX, row = Math.floor(y / PX); c.fillStyle = row % 2 ? '#000' : '#fcfcfc'; c.fillRect(q - PX, y, PX, 6); c.fillStyle = row % 2 ? '#fcfcfc' : '#000'; c.fillRect(q, y, PX, 6); },
+});
+})();
diff --git a/scripts/engine/demos/long_scroll/segments/28_monet.js b/scripts/engine/demos/long_scroll/segments/28_monet.js
new file mode 100644
index 0000000..71a733f
--- /dev/null
+++ b/scripts/engine/demos/long_scroll/segments/28_monet.js
@@ -0,0 +1,86 @@
+// 1899 莫奈《睡莲池上的日本桥》。世界=吉维尼花园横向展开:柳荫、绿色拱桥、桥顶垂下的紫藤、满池睡莲、水面光斑、蜻蜓。
+// 互动(示范动作):桥顶打水漂,灰白扁石跳 4 下,间隔一次比一次长、弧一次比一次高,涟漪逐个扩散;第 4 下的水花里浮上一朵和池里一样的睡莲,他欢呼。
+// 画法:XING.monetWorld(底稿→区域色板短笔触、桥与近栏杆单独一层、睡莲每片预画);人物用 XING 的 monet 材质(短笔触+光斑按世界坐标滑过)。
+if (!window.YI) { const x = new XMLHttpRequest(); x.open('GET', 'demos/long_scroll/lib/xing2_yi.js', false); x.send(); (0, eval)(x.responseText + '\n//# sourceURL=demos/long_scroll/lib/xing2_yi.js'); }
+(() => {
+const W = 1920, H = 1080, TAU = Math.PI * 2, { clamp, lerp, ss } = U, P = PAINT, G = WORLD.GROUND;
+const SW = 2150, AT = 760;
+const MO = { key: 'yi_m', x0: 0, w: SW, waterTop: 560, bridge: { x0: 320, x1: 1200, yEnd: G, lift: 165 }, pond: [300, 1240], groundY: G };
+const M = () => XING.monetWorld(MO);
+// 事件按「互动开始后的秒数」r 定时(r = S.t - WORLD.actT(ME))。示范节奏:4 跳拉开到 1.36 秒、间隔递增(0.22/0.30/0.38/0.46),弧一次比一次高
+let ME = null; const TA = 0;
+const THROW = [[0, 0], [0.18, 1], [0.36, 2], [0.44, 3], [0.5, 4], [0.66, 5]], REL = 0.5;
+const throwFrame = u => { let f = 0; for (const [tt, i] of THROW) if (u >= tt) f = i; return f; };
+// 石子:出手后跳 4 下(世界坐标、动作内秒),越跳越近越大;第 4 下溅起睡莲
+const HOPS = [{ x: AT + 170, y: 790, t: REL + 0.22, s: 0.5 }, { x: AT + 290, y: 850, t: REL + 0.52, s: 0.62, peak: 110 }, { x: AT + 390, y: 915, t: REL + 0.9, s: 0.74, peak: 150 }, { x: AT + 460, y: 985, t: REL + 1.36, s: 0.86, peak: 190 }];
+const HIT = HOPS[3].t, DUR = HIT + 0.2;
+const frameAt = u => u < 0.66 ? throwFrame(u) : u < HIT ? 5 : 6;
+const plan = () => { const from = ACT.stoneFrom(AT, M().deckY(AT), 300); return { t0: TA + REL, from, s0: 0.4, firstArc: 90, hops: HOPS.map(h => ({ ...h, t: TA + h.t })) }; };
+// 石子:莫奈笔触的灰白扁石(淡紫阴影+奶白高光的短笔),转着飞;拖尾是几笔奶白水沫
+function stone(c, st, trail) { if (!st) return; const sc = 1 + st.s * 1.3, flat = Math.abs(Math.cos(st.spin)) * 0.5 + 0.28;
+ c.save(); c.lineCap = 'round';
+ if (trail) for (let k = 1; k <= 5; k++) { const p = trail(k * 0.02); if (!p) break; c.strokeStyle = '#fffbea'; c.globalAlpha = 0.45 * (1 - k / 6); c.lineWidth = 6 * sc * (1 - k / 7); c.beginPath(); c.moveTo(p.x, p.y); c.lineTo(p.x + 3, p.y); c.stroke(); }
+ c.globalAlpha = 1; c.translate(st.x, st.y);
+ c.fillStyle = 'rgba(70,72,120,.28)'; c.beginPath(); c.ellipse(2, 5, 13 * sc, 4 * sc, 0, 0, TAU); c.fill();
+ [['#8a88a0', 0, 2, 13, 0.0], ['#b8b4c4', -2, 0, 11, -0.2], ['#d8d4e0', 1, -1.5, 8, 0.15], ['#efeaf2', -3, -2.5, 5, -0.1], ['#fffbea', -4, -3.4, 3, 0]].forEach(([col, dx, dy, L, a]) => {
+ c.strokeStyle = col; c.lineWidth = 7 * sc * flat; c.beginPath(); c.moveTo((dx - L / 2) * sc, (dy + a * 10) * sc * flat); c.lineTo((dx + L / 2) * sc, (dy - a * 10) * sc * flat); c.stroke(); });
+ c.restore(); }
+// 冒出的睡莲:和池里每片同一个画法、同一个尺寸(monetWorld 的叶托+花→同参数短笔触重画),缓存
+let BLOOM = null;
+function bloomImg() { if (BLOOM) return BLOOM; const s = 0.22 + 0.78 * clamp((985 - 560) / (H - 560)), rx = 36 * s * 1.7, ry = rx * (0.24 + 0.1 * s), pw = Math.ceil(rx * 2 + 16), ph = Math.ceil(ry * 2 + 34 * s + 16);
+ const cc = P.canvas(pw, ph), q = cc.getContext('2d'), cx = pw / 2, cy = ph - ry - 8, notch = 1.2;
+ q.fillStyle = '#7aa85a'; q.beginPath(); q.ellipse(cx, cy, rx, ry, 0, notch + 0.35, notch + TAU - 0.35); q.lineTo(cx, cy); q.closePath(); q.fill();
+ q.fillStyle = 'rgba(40,70,60,0.35)'; q.beginPath(); q.ellipse(cx, cy + ry * 0.25, rx * 0.95, ry * 0.7, 0, 0, Math.PI); q.fill();
+ const fr = 11 * s * 1.6 + 3; q.fillStyle = '#f2a6bf'; q.beginPath(); q.ellipse(cx + rx * 0.15, cy - fr * 0.5, fr * 1.4, fr * 0.8, 0, 0, TAU); q.fill(); q.fillStyle = '#fff0f2'; q.beginPath(); q.ellipse(cx + rx * 0.15, cy - fr * 0.8, fr * 0.6, fr * 0.45, 0, 0, TAU); q.fill();
+ const out = P.canvas(pw, ph), og = out.getContext('2d'); og.drawImage(cc, 0, 0); og.globalCompositeOperation = 'source-atop';
+ XING.strokes(og, cc, { cell: Math.max(3, 5 * s + 1), len: 10 * s + 5, width: 3 * s + 1.6, seed: 4242, alphaMask: true, alphaMin: 100, angle: (x, y, rr) => (rr() - 0.5) * 0.4,
+ palette: (x, y, col, rr) => { const L = col[0] * 0.3 + col[1] * 0.59 + col[2] * 0.11; return col[1] > col[0] + 10 ? P.mix(P.hex(['#5f8f4a', '#7fae5a', '#9cc070', '#b4cc78', '#4a7a5a', '#c8d880'][(rr() * 6) | 0]), col, 0.3) : (L > 170 ? P.mix(P.hex(['#fff2f4', '#f7d0dc', '#fbf4e8', '#f0a0b8'][(rr() * 4) | 0]), col, 0.4) : null); } });
+ out.ax = cx; out.ay = cy; return BLOOM = out; }
+
+// 紫藤:从桥顶上方的架子垂下的淡紫花串(点列,由大到小,随风摆)
+function wisteria(c, camX, t) {
+ const B = MO.bridge, deck = M().deckY; c.save();
+ // 紫藤架:桥上方一道拱形绿架,缀着叶子
+ c.lineCap = 'round'; c.strokeStyle = '#4f9a72'; c.lineWidth = 8; c.beginPath(); for (let wx = B.x0 + 40; wx <= B.x1 - 40; wx += 10) { const y = deck(wx) - 235; wx === B.x0 + 40 ? c.moveTo(wx - camX, y) : c.lineTo(wx - camX, y); } c.stroke();
+ [B.x0 + 40, B.x1 - 40].forEach(wx => { c.beginPath(); c.moveTo(wx - camX, deck(wx) - 235); c.lineTo(wx - camX, deck(wx) - 10); c.stroke(); });
+ for (let k = 0; k < 40; k++) { const wx = B.x0 + 50 + k * (B.x1 - B.x0 - 100) / 39, x = wx - camX + Math.sin(t * 1.8 + k) * 2; if (x < -40 || x > W + 40) continue; c.fillStyle = ['#6f9a40', '#9cbf58', '#4f7f3a'][k % 3]; c.beginPath(); c.ellipse(x, deck(wx) - 238 + (k % 3) * 5, 16, 7, (k % 5) * 0.6, 0, TAU); c.fill(); }
+ for (let k = 0; k < 18; k++) { const wx = B.x0 + 70 + k * ((B.x1 - B.x0 - 140) / 17), x = wx - camX; if (x < -60 || x > W + 60) continue;
+ const top = deck(wx) - 230, L = 7 + (k * 7) % 6, sw = Math.sin(t * 2.4 + 0.9 * k) * 8;
+ for (let i = 0; i < L; i++) { const q = i / L, r = 9 * (1 - q * 0.7); c.fillStyle = ['#b8a0d8', '#d0bce8', '#9a84c8', '#e4d4f0'][(i + k) % 4]; c.globalAlpha = 0.92; c.beginPath(); c.ellipse(x + sw * q * q + Math.sin(i * 2.1 + k) * 4, top + i * 11, r, r * 0.8, 0, 0, TAU); c.fill(); } }
+ c.restore();
+}
+// 蜻蜓:在水面上方折线飞,翅膀闪
+function dragonflies(c, camX, t) {
+ c.save(); for (let k = 0; k < 3; k++) { const ph = k * 2.3, x = 700 + k * 380 + Math.sin(t * 0.9 + ph) * 160 + Math.sin(t * 3.1 + ph) * 30 - camX, y = 640 + k * 70 + Math.sin(t * 1.7 + ph) * 40;
+ c.strokeStyle = '#3a6a8a'; c.lineWidth = 4; c.lineCap = 'round'; c.beginPath(); c.moveTo(x - 18, y); c.lineTo(x + 14, y); c.stroke();
+ const f = 0.5 + 0.5 * Math.sin(t * 40 + k); c.fillStyle = 'rgba(230,240,255,.75)'; [[-1, -1], [1, -1]].forEach(([a]) => { c.beginPath(); c.ellipse(x + 2 + a * 4, y - 6 * f, 12, 3.5, a * 0.4, 0, TAU); c.fill(); }); }
+ c.restore();
+}
+
+WORLD.add(ME = { id: '28_monet', year: 1899, name: '莫奈《睡莲池上的日本桥》', w: SW, burst: 'monet', labelColor: 'rgba(16,22,40,.92)',
+ hero: { walk: 'monet_walk', mat: 'monet', shadow: 'rgba(60,70,120,.18)', draw(c, key, i, o) { YI.whitenHat(key); XING.actor(c, key, i, o); } },
+ ground: lx => M().deckY(lx),
+ acts: [{ at: AT, dur: DUR, key: 'monet_throw', frame: frameAt, lead: 0 }],
+ back(c, S) {
+ const lt = S.t - WORLD.actT(ME), pl = plan();
+ YI.edge(c, M().bg, S.camX, SW);
+ XING.monetBack(c, M(), S.camX, lt, { hops: pl.hops.map((p, i) => ({ x: p.x, y: p.y, t: p.t, s: p.s, big: i === 3 })) });
+ dragonflies(c, S.camX, lt);
+ wisteria(c, S.camX, lt);
+ // 第 4 下:水花里冒出一朵睡莲——叶托先浮上来,花一瓣瓣弹开,落定后随涟漪轻轻摇
+ if (lt >= HIT + 0.06) { const a = lt - HIT - 0.06, x = HOPS[3].x - S.camX, y = HOPS[3].y, im = bloomImg(), rise = U.ease.out(clamp(a / 0.45)), bob = Math.sin(a * 9) * 3 * Math.exp(-a * 2);
+ if (x > -200 && x < W + 200) { c.save(); c.globalAlpha = clamp(a / 0.15); c.translate(x, y + (1 - rise) * 14 + bob); c.scale(1, 0.3 + 0.7 * rise); c.drawImage(im, -im.ax, -im.ay); c.restore(); } }
+ },
+ front(c, S) {
+ const lt = S.t - WORLD.actT(ME), u = S.act ? S.act.u : -1;
+ XING.monetFront(c, M(), S.camX, lt, [200, 1600, 2000]);
+ { const pl = plan(), sh = p => p ? { ...p, x: p.x - S.camX } : null; stone(c, sh(XING.stone(lt, pl)), dt => sh(XING.stone(lt - dt, pl))); }
+ },
+ // 进入本段的边界:印象派短笔触(粉、蓝、绿、奶白),微微颤
+ seam(c, y, sx, t) {
+ const k = Math.floor(y / 6), cols = ['#f2a6bf', '#9db5e0', '#9cc070', '#fff2d4', '#b7a6d8', '#8fdcae'];
+ c.save(); c.lineCap = 'round'; c.strokeStyle = cols[k % 6]; c.lineWidth = 7; const a = -0.5 + U.hash(k, 3) * 0.6, L = 12 + U.hash(k, 4) * 10, x = sx + (U.hash(k, 6) - 0.5) * 10 + Math.sin(t * 4 + k) * 1.5;
+ c.beginPath(); c.moveTo(x - Math.cos(a) * L / 2, y + 3 - Math.sin(a) * L / 2); c.lineTo(x + Math.cos(a) * L / 2, y + 3 + Math.sin(a) * L / 2); c.stroke(); c.restore();
+ },
+});
+})();
diff --git a/scripts/engine/demos/t1_3b1b/eras.js b/scripts/engine/demos/t1_3b1b/eras.js
new file mode 100644
index 0000000..704a31b
--- /dev/null
+++ b/scripts/engine/demos/t1_3b1b/eras.js
@@ -0,0 +1,11 @@
+// 示范 · 3b1b / manim 式讲解「神经网络一层是怎么把像素变成『猫』的」(8 秒三镜)。语法卡:references/动画语法/t1_3b1b.md
+// 预览 index.html?film=demos/t1_3b1b 渲染 render.py --film demos/t1_3b1b --out t1.mp4
+// 镜头 1→2 无转场:首帧 = 上一镜末帧,Transform 接续(100 个像素变成一列神经元)。镜头 2→3 穿进一个隐藏层神经元看它在找什么。
+window.PUNCH = 0;
+window.SCENE_DIR = 'demos/t1_3b1b';
+window.ERAS = [
+ { id: 't1_s1', dur: 2.6 },
+ { id: 't1_s2', dur: 2.8 },
+ // cx,cy = 目标神经元在镜头 2 末帧的屏幕位置(r = 22×1.1);live:镜头 2 自己在转场里继续推相机(矢量重画)
+ { id: 't1_s3', dur: 2.6, transition: { type: 'zoomThrough', dur: 0.75, cx: 850, cy: 391.5, zoom: 48, r0: 24.2, live: true, focus: [640, 585] } },
+];
diff --git a/scripts/engine/demos/t1_3b1b/t1_s1.js b/scripts/engine/demos/t1_3b1b/t1_s1.js
new file mode 100644
index 0000000..b5d0c35
--- /dev/null
+++ b/scripts/engine/demos/t1_3b1b/t1_s1.js
@@ -0,0 +1,101 @@
+// t1 · 3b1b 式:「神经网络一层是怎么把像素变成『猫』的」
+// 镜头 1(2.6s):一张 10×10 的猫图逐格出现 → 每格写上亮度 → 100 个像素 Transform 成一列输入神经元(16 个可见+⋮)
+// 本文件同时放 t1 三个镜头共用的数据与布局(window.T1),后面的镜头直接用。
+(() => {
+const { clamp, lerp, hash } = U;
+const C = DG.MANIM;
+
+// ---------- 共用数据 ----------
+const CAT = [
+ '0000000000',
+ '0600000060',
+ '0870000780',
+ '0899999980',
+ '0929999290',
+ '0999999990',
+ '0999449990',
+ '0099999900',
+ '0007887000',
+ '0000000000'];
+const PIX = []; for (let r = 0; r < 10; r++) for (let q = 0; q < 10; q++) { const d = +CAT[r][q]; PIX.push(d ? clamp(d / 10 + (hash(r, q) - 0.5) * 0.08, 0, 1) : 0); }
+// 「猫」神经元的权重:猫形处为正(蓝),猫形外一圈为负(红),眼睛处为负(猫的眼睛是暗的)
+const WTS = PIX.map((v, i) => {
+ const r = (i / 10) | 0, q = i % 10;
+ if (+CAT[r][q] === 2) return -0.55;
+ if (v > 0.5) return 0.55 + 0.4 * hash(q, r + 7);
+ let near = false; for (let dr = -1; dr <= 1; dr++) for (let dq = -1; dq <= 1; dq++) { const rr = r + dr, qq = q + dq; if (rr >= 0 && rr < 10 && qq >= 0 && qq < 10 && PIX[rr * 10 + qq] > 0.5) near = true; }
+ return near ? -0.6 - 0.3 * hash(r, q + 3) : -0.12 * hash(q, r);
+});
+
+// ---------- 布局(屏幕 px;1 manim 单位 = 135px) ----------
+const GRID = { cx: 960, cy: 545, cell: 52 };
+const cellXY = i => [GRID.cx + ((i % 10) - 4.5) * GRID.cell, GRID.cy + (((i / 10) | 0) - 4.5) * GRID.cell];
+const IN_X = 330, IN_R = 17;
+const VIS = Array.from({ length: 16 }, (_, k) => Math.round(k * 99 / 15)); // 可见的 16 个输入
+const inY = j => 540 + (j - 7.5) * 44 + (j >= 8 ? 30 : -30);
+const HID_X = 900, HID_R = 22, HID_N = 10, hidY = j => 540 + (j - 4.5) * 70;
+const OUT_X = 1470, OUT_R = 32, OUT = [{ y: 400, name: '猫', a: 0.92 }, { y: 540, name: '狗', a: 0.07 }, { y: 680, name: '鸟', a: 0.03 }];
+const HID_A = [0.82, 0.12, 0.95, 0.3, 0.64, 0.06, 0.71, 0.22, 0.88, 0.41];
+const W1 = (j, k) => Math.sin(j * 12.9898 + k * 78.233) * 0.5 + (hash(j, k + 11) - 0.5) * 1.1; // 输入→隐藏
+const W2 = (k, o) => [[0.9, -0.5, 0.95, -0.2, 0.7, -0.8, 0.85, -0.3, 0.8, 0.1], [-0.6, 0.4, -0.7, 0.5, -0.2, 0.6, -0.5, 0.3, -0.4, 0.2], [-0.3, 0.2, -0.5, 0.6, -0.6, 0.4, -0.2, 0.7, -0.5, 0.3]][o][k];
+
+// 输入列(S1 结束、S2 全程都要画)
+const drawInputs = (c, a = 1) => {
+ VIS.forEach((pi, j) => DG.neuron(c, IN_X, inY(j), IN_R, PIX[pi] * a, { sa: a }));
+ c.save(); c.fillStyle = `rgba(255,255,255,${a})`; for (let d = -1; d <= 1; d++) { c.beginPath(); c.arc(IN_X, 540 + d * 16, 4, 0, Math.PI * 2); c.fill(); } c.restore();
+};
+const drawBrace = (c, p) => {
+ DG.brace(c, IN_X - 34, inY(0) - IN_R, inY(15) + IN_R, { p: MO.smooth(p), lw: 3 });
+ c.save(); c.translate(IN_X - 92, 540); c.rotate(-Math.PI / 2);
+ DG.write(c, '100 个输入', 0, 0, 40, p, { align: 'center' }); c.restore();
+};
+window.T1 = { PIX, WTS, CAT, GRID, cellXY, IN_X, IN_R, VIS, inY, HID_X, HID_R, HID_N, hidY, OUT_X, OUT_R, OUT, HID_A, W1, W2, drawInputs, drawBrace };
+
+// ---------- 镜头 1 ----------
+const DUR = 2.6;
+SCENES['t1_s1'] = {
+ draw(c, lt) {
+ c.fillStyle = '#000'; c.fillRect(0, 0, 1920, 1080);
+ // 相机:前 1.4s 绕网格极慢推近 1→1.025,Transform 开始时 smooth 拉回 1(镜头 2 首帧要逐像素对上)
+ const z = 1 + 0.025 * MO.smooth(MO.seg(lt, 0, 1.4)) * (1 - MO.smooth(MO.seg(lt, 1.4, 2.2)));
+ c.save(); c.translate(960, 545); c.scale(z, z); c.translate(-960, -545);
+ // 标题:Write(linear,<15 个字 1 秒)
+ const out = MO.smooth(MO.seg(lt, 1.4, 1.9)); // FadeOut(shift=UP)
+ c.save(); c.globalAlpha = 1 - out; c.translate(0, -40 * out);
+ DG.write(c, '一张 10×10 的「猫」', 960, 150, 58, MO.seg(lt, 0.1, 1.1));
+ c.restore();
+
+ const morph = MO.seg(lt, 1.45, 2.55); // 100 个子 Transform,LaggedStart 0.01
+ const appear = MO.seg(lt, 0.0, 0.9);
+ const order = i => ((i % 10) + ((i / 10) | 0)); // 按对角线出现,像扫描
+ for (let i = 0; i < 100; i++) {
+ const [x, y] = cellXY(i), v = PIX[i];
+ const qa = MO.smooth(clamp(appear * 1.6 - order(i) / 18 * 0.6));
+ if (qa <= 0) continue;
+ const qm = MO.smooth(MO.lagged(i, 100, morph, 0.01));
+ const j = VIS.indexOf(i), vis = j >= 0;
+ // 不可见的像素:飞向中间的 ⋮ 并缩成点
+ const tx = IN_X, ty = vis ? inY(j) : 540 + (((i * 7) % 3) - 1) * 16, tr = vis ? IN_R : 3;
+ const s = GRID.cell * (0.92 + 0.08 * qa);
+ const A = DG.rectPts(x, y, s, s, 48), B = DG.circlePts(tx, ty, tr, 48);
+ const pts = qm > 0 ? DG.morph(A, B, qm) : A;
+ const fadeHidden = vis ? 1 : 1 - clamp((qm - 0.6) / 0.4);
+ if (qm >= 1) { if (vis) DG.neuron(c, tx, ty, IN_R, v); continue; } // 落定后用真圆画:镜头 2 首帧逐像素接得上(48 边形与 arc 抗锯齿不同)
+ c.save(); c.globalAlpha = qa * fadeHidden;
+ DG.shape(c, pts, { fill: `rgba(255,255,255,${v})`, stroke: `rgba(255,255,255,${lerp(0.22, 1, qm)})`, lw: lerp(1, 2, qm) });
+ c.restore();
+ // 亮度数字(0.7s 起淡入,Transform 开始时淡出)
+ const na = clamp((lt - 0.7) / 0.3) * (1 - clamp((lt - 1.35) / 0.2));
+ if (na > 0) { c.save(); c.globalAlpha = na; c.font = `20px "${DG.FONT.rm}"`; c.textAlign = 'center'; c.fillStyle = v > 0.55 ? '#000' : C.GREY_B; c.fillText(v.toFixed(1), x, y + 7); c.restore(); }
+ }
+ // 底部说明:FadeIn(shift=UP),随标题一起淡出
+ const la = MO.smooth(MO.seg(lt, 0.55, 1.15)) * (1 - out);
+ if (la > 0) { c.save(); c.globalAlpha = la; c.font = `600 38px "${DG.FONT.zh}"`; c.textAlign = 'center'; c.fillStyle = C.GREY_A; c.fillText('每个像素 = 一个 0 到 1 之间的数', 960, 905 + 24 * (1 - la)); c.restore(); }
+ // ⋮ 与大括号
+ const dots = MO.smooth(MO.seg(lt, 2.25, 2.55));
+ if (dots > 0) { c.save(); c.fillStyle = '#fff'; c.globalAlpha = dots; for (let d = -1; d <= 1; d++) { c.beginPath(); c.arc(IN_X, 540 + d * 16, 4, 0, Math.PI * 2); c.fill(); } c.restore(); }
+ T1.drawBrace(c, MO.seg(lt, 1.95, 2.6));
+ c.restore();
+ },
+};
+})();
diff --git a/scripts/engine/demos/t1_3b1b/t1_s2.js b/scripts/engine/demos/t1_3b1b/t1_s2.js
new file mode 100644
index 0000000..ea22ea6
--- /dev/null
+++ b/scripts/engine/demos/t1_3b1b/t1_s2.js
@@ -0,0 +1,74 @@
+// t1 · 镜头 2(2.8s):一层网络。连线按权重着色(蓝正红负、线宽 ∝ |w|³)逐条画出 → 公式 Write →
+// 黄色信号沿连线闪过(ShowPassingFlash)→ 隐藏层按激活值变亮 → 输出层「猫」最亮 → Indicate → 激活 0.95 的隐藏神经元描边染黄,镜头推进它。
+// 开头一帧与镜头 1 的最后一帧逐像素相同(Transform 接续,没有切)。
+(() => {
+const { clamp, lerp } = U;
+const C = DG.MANIM;
+const DUR = 2.8;
+const CAM_END = { x: 1000, y: 500, z: 1.1 };
+const TGT = { k: 2 }; // 要推进去看的隐藏层神经元(激活 0.95 的那个)
+const camAt = lt => {
+ if (lt <= DUR) { const k = MO.smooth(clamp(lt / DUR)); return { x: lerp(960, CAM_END.x, k), y: lerp(540, CAM_END.y, k), z: lerp(1, CAM_END.z, k) }; }
+ // 转场期间(lt>时长):绕目标神经元的屏幕位置继续推相机,矢量重画;与 eras.js 里 zoomThrough 的 dur/zoom 一致
+ const T = window.T1, wx = T.HID_X, wy = T.hidY(TGT.k);
+ const tr = ERAS.find(e => e.id === 't1_s3').transition, e = MO.smooth(clamp((lt - DUR) / tr.dur));
+ return CAM.pushTo(CAM_END, wx, wy, CAM_END.z * tr.zoom, e, 0); // k=0:目标在屏幕上原地不动,只放大
+};
+SCENES['t1_s2'] = {
+ camAt,
+ draw(c, lt) {
+ const T = window.T1;
+ c.fillStyle = '#000'; c.fillRect(0, 0, 1920, 1080);
+ const cam = camAt(lt);
+ CAM.with(c, cam, (c) => {
+ const inE = T.VIS.map((pi, j) => [T.IN_X, T.inY(j)]);
+ const hid = Array.from({ length: T.HID_N }, (_, k) => [T.HID_X, T.hidY(k)]);
+ // ---- 连线:ShowCreation,LaggedStart lag 0.006 ----
+ const e1p = MO.seg(lt, 0.15, 0.95), e2p = MO.seg(lt, 0.55, 1.05);
+ const n1 = inE.length * hid.length;
+ inE.forEach((a, j) => hid.forEach((b, k) => {
+ const i = j * hid.length + k, q = MO.smooth(MO.lagged(i, n1, e1p, 0.006));
+ DG.edge(c, DG.edgeEnds(a[0], a[1], T.IN_R, b[0], b[1], T.HID_R), T.W1(j, k), q, { alpha: 0.7, maxW: 3 });
+ }));
+ hid.forEach((a, k) => T.OUT.forEach((o, m) => {
+ const q = MO.smooth(MO.lagged(k * 3 + m, 30, e2p, 0.02));
+ DG.edge(c, DG.edgeEnds(a[0], a[1], T.HID_R, T.OUT_X, o.y, T.OUT_R), T.W2(k, m), q, { alpha: 0.8, maxW: 3.4 });
+ }));
+ // ---- 信号:连线复制一份染黄、线宽 ×1.5,ShowPassingFlash(time_width 2),按输入行错开 ----
+ const f1 = MO.seg(lt, 0.95, 1.75);
+ if (f1 > 0 && f1 < 1) inE.forEach((a, j) => { if (T.PIX[T.VIS[j]] < 0.3) return; hid.forEach((b, k) => {
+ const q = MO.smooth(MO.lagged(j, 16, f1, 0.04)); const [lo, hi] = DG.flash(q); if (hi <= lo) return;
+ const e = DG.edgeEnds(a[0], a[1], T.IN_R, b[0], b[1], T.HID_R);
+ c.save(); c.strokeStyle = C.YELLOW; c.globalAlpha = 0.85; c.lineWidth = 3; c.beginPath(); c.moveTo(lerp(e[0], e[2], lo), lerp(e[1], e[3], lo)); c.lineTo(lerp(e[0], e[2], hi), lerp(e[1], e[3], hi)); c.stroke(); c.restore();
+ }); });
+ const f2 = MO.seg(lt, 1.6, 2.25);
+ if (f2 > 0 && f2 < 1) hid.forEach((a, k) => { if (T.HID_A[k] < 0.4) return; T.OUT.forEach((o, m) => {
+ const q = MO.smooth(MO.lagged(k, 10, f2, 0.05)); const [lo, hi] = DG.flash(q); if (hi <= lo) return;
+ const e = DG.edgeEnds(a[0], a[1], T.HID_R, T.OUT_X, o.y, T.OUT_R);
+ c.save(); c.strokeStyle = C.YELLOW; c.globalAlpha = 0.9; c.lineWidth = 4.5; c.beginPath(); c.moveTo(lerp(e[0], e[2], lo), lerp(e[1], e[3], lo)); c.lineTo(lerp(e[0], e[2], hi), lerp(e[1], e[3], hi)); c.stroke(); c.restore();
+ }); });
+ // ---- 神经元 ----
+ T.drawInputs(c); T.drawBrace(c, 1);
+ const ha = MO.seg(lt, 0.0, 0.55), hf = MO.seg(lt, 1.3, 1.95);
+ const pick = MO.smooth(MO.seg(lt, 2.3, 2.6)); // 末尾:目标隐藏神经元描边染黄(「我们来看这一个」),相机随后推进去
+ hid.forEach((b, k) => { const q = MO.smooth(MO.lagged(k, 10, ha, 0.05)); if (q <= 0) return;
+ const hk = k === TGT.k ? pick : 0;
+ c.save(); c.globalAlpha = q; DG.neuron(c, b[0] + 24 * (1 - q), b[1], T.HID_R, T.HID_A[k] * MO.smooth(MO.lagged(k, 10, hf, 0.08)), { stroke: DG.mix('#ffffff', C.YELLOW, hk), lw: 2 + 2 * hk }); c.restore(); });
+ const oa = MO.seg(lt, 0.2, 0.7), of = MO.seg(lt, 1.95, 2.4);
+ T.OUT.forEach((o, m) => { const q = MO.smooth(MO.lagged(m, 3, oa, 0.2)); if (q <= 0) return;
+ const fill = o.a * MO.smooth(of);
+ c.save(); c.globalAlpha = q; DG.neuron(c, T.OUT_X + 24 * (1 - q), o.y, T.OUT_R, fill, { lw: 2.5 });
+ // 标签+数值;「猫」Indicate:放大 1.2、染黄、回来
+ const ind = m === 0 ? DG.indicate(MO.seg(lt, 2.0, 2.45)) : { s: 1, k: 0 };
+ c.translate(T.OUT_X + 62, o.y + 15); c.scale(ind.s, ind.s);
+ c.font = `600 46px "${DG.FONT.zh}"`; c.fillStyle = DG.mix('#ffffff', C.YELLOW, ind.k); c.textAlign = 'left'; c.fillText(o.name, 0, 0);
+ if (of > 0) { c.font = `40px "${DG.FONT.rm}"`; c.fillStyle = DG.mix(C.GREY_B, C.YELLOW, ind.k); c.globalAlpha = q * clamp(of * 2); c.fillText(TY.fmt(fill, 2), 62, 0); }
+ c.restore(); });
+ });
+ // 公式(不随相机动:屏幕固定层),颜色编码:黄=激活,蓝=权重
+ const Y = C.YELLOW, B = C.BLUE_C;
+ DG.math(c, [{ s: 'a', it: true, col: Y, sup: '(1)' }, { s: '=', gap: 14 }, { s: 'σ', it: true, gap: 4 }, { s: '(', gap: 6 }, { s: 'W', it: true, col: B, gap: 8 },
+ { s: 'a', it: true, col: Y, sup: '(0)', gap: 14 }, { s: '+', gap: 14 }, { s: 'b', it: true }, { s: ')' }], 960, 112, 64, { p: MO.seg(lt, 0.3, 1.3) });
+ },
+};
+})();
diff --git a/scripts/engine/demos/t1_3b1b/t1_s3.js b/scripts/engine/demos/t1_3b1b/t1_s3.js
new file mode 100644
index 0000000..7dae1a4
--- /dev/null
+++ b/scripts/engine/demos/t1_3b1b/t1_s3.js
@@ -0,0 +1,65 @@
+// t1 · 镜头 3(2.6s,前 0.75s 是「镜头穿进隐藏层神经元」转场):
+// 神经元内部 = 它连向 100 个像素的权重图(蓝正红负,长得像猫脸)→ 像素图滑进来叠上去(逐格相乘)→ 100 格收拢成一个数 →
+// σ 压到 0.95(= 镜头 2 里它的亮度)→ 「像猫脸」;最后 0.6s 停住给观众读。3b1b 原片讲隐藏层也是这样把权重画成图。
+(() => {
+const { clamp, lerp } = U;
+const C = DG.MANIM;
+const WG = { cx: 640, cy: 585, cell: 44 };
+const cxy = (g, i) => [g.cx + ((i % 10) - 4.5) * g.cell, g.cy + (((i / 10) | 0) - 4.5) * g.cell];
+const wcol = (w, a = 1) => DG.rgba(w >= 0 ? C.BLUE_C : C.RED_C, clamp(Math.abs(w)) * a);
+const NEU = { x: 1460, y: 585, r: 78 };
+SCENES['t1_s3'] = {
+ draw(c, lt) {
+ const T = window.T1;
+ c.fillStyle = '#000'; c.fillRect(0, 0, 1920, 1080);
+ DG.write(c, '这个神经元在找什么?', 960, 135, 58, MO.seg(lt, 0.75, 1.5));
+ const appear = MO.seg(lt, 0.0, 0.7), slideIn = MO.seg(lt, 0.7, 0.95), merge = MO.seg(lt, 0.95, 1.3), collapse = MO.seg(lt, 1.35, 1.75);
+ // ---- 权重图 ----
+ for (let i = 0; i < 100; i++) {
+ const [x, y] = cxy(WG, i), w = T.WTS[i], v = T.PIX[i];
+ const qa = MO.smooth(MO.lagged(i, 100, appear, 0.008)); if (qa <= 0) continue;
+ const qm = MO.smooth(merge), qc = MO.smooth(MO.lagged(i, 100, collapse, 0.008));
+ // 相乘后的颜色:w·a(只有猫形处的亮像素还亮着蓝,背景被乘成接近 0)
+ const prod = w * (v > 0 ? v : 0.06);
+ const fill = DG.mix(DG.mixA(w >= 0 ? C.BLUE_C : C.RED_C, '#000000', 1 - clamp(Math.abs(w))), DG.mixA(prod >= 0 ? C.BLUE_C : C.RED_C, '#000000', 1 - clamp(Math.abs(prod) * 1.3)), qm);
+ const s = WG.cell * lerp(0.94, 0.3, qc) * qa;
+ const px = lerp(x, NEU.x, qc), py = lerp(y, NEU.y, qc);
+ if (qc > 0) { const g = 0.28 * MO.smooth(clamp(qc * 1.5)), gs = WG.cell * 0.94; // 收拢后原位留一张淡的权重图(它在找的图案)
+ c.save(); c.globalAlpha = g; c.fillStyle = DG.mix(w >= 0 ? C.BLUE_C : C.RED_C, '#000000', 1 - clamp(Math.abs(w))); c.fillRect(x - gs / 2, y - gs / 2, gs, gs); c.restore(); }
+ c.save(); c.globalAlpha = 1 - clamp((qc - 0.75) / 0.25);
+ c.fillStyle = fill; c.fillRect(px - s / 2, py - s / 2, s, s);
+ c.strokeStyle = 'rgba(255,255,255,.18)'; c.lineWidth = 1; c.strokeRect(px - s / 2, py - s / 2, s, s); c.restore();
+ }
+ // 说明(FadeIn shift=UP),合并时淡出
+ const la = MO.smooth(MO.seg(lt, 0.75, 1.1)); // 图例留到片尾(相乘后还要靠它读颜色)
+ if (la > 0) { c.save(); c.globalAlpha = la; c.font = `600 34px "${DG.FONT.zh}"`; c.textAlign = 'center';
+ c.fillStyle = C.BLUE_C; c.fillText('蓝 = 希望这里亮', WG.cx - 120, 885 + 20 * (1 - la)); c.fillStyle = C.RED_C; c.fillText('红 = 希望这里暗', WG.cx + 150, 885 + 20 * (1 - la)); c.restore(); }
+ // ---- 像素图:从右边 FadeIn,再整体移到权重图上(Transform 位置),叠上后淡出成「相乘」 ----
+ if (slideIn > 0 && merge < 1) {
+ const qs = MO.smooth(slideIn), qm = MO.smooth(merge);
+ const gx = lerp(lerp(1340, 1290, qs), WG.cx, qm);
+ for (let i = 0; i < 100; i++) {
+ const v = T.PIX[i], x = gx + ((i % 10) - 4.5) * WG.cell, y = WG.cy + (((i / 10) | 0) - 4.5) * WG.cell, s = WG.cell * 0.94;
+ c.save(); c.globalAlpha = qs * (1 - qm * 0.9); c.fillStyle = `rgba(255,255,255,${v})`; c.fillRect(x - s / 2, y - s / 2, s, s);
+ c.strokeStyle = 'rgba(255,255,255,.25)'; c.lineWidth = 1; c.strokeRect(x - s / 2, y - s / 2, s, s); c.restore();
+ }
+ c.save(); c.globalAlpha = qs * (1 - qm); c.font = `64px "${DG.FONT.rm}"`; c.fillStyle = '#fff'; c.textAlign = 'center'; c.fillText('×', (WG.cx + 5 * WG.cell + gx - 5 * WG.cell) / 2, WG.cy + 22); c.restore();
+ }
+ // ---- 收拢成一个神经元:加权求和 → σ → 0.92 ----
+ const nq = MO.smooth(MO.seg(lt, 1.3, 1.6));
+ if (nq > 0) {
+ const fillA = 0.95 * MO.smooth(MO.seg(lt, 1.65, 2.0)); // = 镜头 2 里它的激活值 0.95
+ const ind = DG.indicate(MO.seg(lt, 1.9, 2.3));
+ c.save(); c.translate(NEU.x, NEU.y); c.scale(ind.s, ind.s); c.translate(-NEU.x, -NEU.y); c.globalAlpha = nq;
+ DG.neuron(c, NEU.x, NEU.y, NEU.r * (0.6 + 0.4 * nq), fillA, { lw: 3, stroke: DG.mix('#ffffff', C.YELLOW, ind.k) });
+ c.restore();
+ c.save(); c.globalAlpha = nq; c.textAlign = 'center';
+ c.font = `600 52px "${DG.FONT.zh}"`; c.fillStyle = DG.mix('#ffffff', C.YELLOW, ind.k); c.fillText('像猫脸', NEU.x, NEU.y - NEU.r - 34);
+ c.font = `48px "${DG.FONT.rm}"`; c.fillStyle = C.GREY_A; c.fillText(TY.fmt(fillA, 2), NEU.x, NEU.y + NEU.r + 62);
+ c.restore();
+ }
+ DG.math(c, [{ s: 'σ', it: true }, { s: '(', gap: 4 }, { s: 'Σ', gap: 6 }, { s: 'w', it: true, col: C.BLUE_C, sub: 'i', gap: 2 }, { s: 'a', it: true, col: C.YELLOW, sub: 'i', gap: 12 },
+ { s: '+', gap: 12 }, { s: 'b', it: true }, { s: ')', gap: 14 }, { s: '=', gap: 14 }, { s: TY.fmt(0.95 * MO.smooth(MO.seg(lt, 1.65, 2.0)), 2) }], 1180, 965, 54, { p: MO.seg(lt, 1.45, 1.95) });
+ },
+};
+})();
diff --git a/scripts/engine/demos/t2_keynote_ui/eras.js b/scripts/engine/demos/t2_keynote_ui/eras.js
new file mode 100644
index 0000000..212b967
--- /dev/null
+++ b/scripts/engine/demos/t2_keynote_ui/eras.js
@@ -0,0 +1,10 @@
+// 示范 · 发布会式(Apple keynote / 产品发布 UI)「Plover 2 的三个功能」(8 秒三镜,产品与数字虚构)。语法卡:references/动画语法/t2_keynote_ui.md
+// 预览 index.html?film=demos/t2_keynote_ui 渲染 render.py --film demos/t2_keynote_ui --out t2.mp4
+// 光斑底只依赖全片时间 t,三个镜头之间无缝;卡片 → 全屏是共享元素展开(rect = 中间卡在镜头 2 末帧的屏幕矩形)。
+window.PUNCH = 0;
+window.SCENE_DIR = 'demos/t2_keynote_ui';
+window.ERAS = [
+ { id: 't2_s1', dur: 2.6 },
+ { id: 't2_s2', dur: 3.0, transition: { type: 'blurPush', dur: 0.55 } },
+ { id: 't2_s3', dur: 2.4, transition: { type: 'expandRect', dur: 0.6, rect: { x: 705.6, y: 252.6, w: 508.8, h: 614.8 }, r: 38 } },
+];
diff --git a/scripts/engine/demos/t2_keynote_ui/t2_s1.js b/scripts/engine/demos/t2_keynote_ui/t2_s1.js
new file mode 100644
index 0000000..5ffed95
--- /dev/null
+++ b/scripts/engine/demos/t2_keynote_ui/t2_s1.js
@@ -0,0 +1,57 @@
+// t2 · 发布会式:「一个 AI 产品发布:三个功能卡片」
+// 镜头 1(2.6s):深色底上柔和光斑缓慢漂移;眉题 → 产品名(模糊→清晰+上移,渐变字,光扫过)→ 一句话副标题。相机极慢推近。
+// 本文件同时放 t2 共用的东西(window.T2):光斑底、字体、颜色。
+(() => {
+const { clamp, lerp } = U;
+const W = 1920, H = 1080;
+const BASE = '#050508';
+const BLOBS = [ // 色相取 Stripe 渐变一系(紫/蓝/青)+ 一点暖色;周期避开 5s(HIG:避免 ~0.2Hz 持续摆动)
+ { x: 430, y: 300, r: 760, col: [150, 90, 238], a: 0.75, ax: 220, ay: 120, period: 11, ph: 0 },
+ { x: 1520, y: 260, r: 700, col: [56, 104, 255], a: 0.7, ax: 200, ay: 160, period: 13, ph: 2.1 },
+ { x: 1320, y: 930, r: 560, col: [120, 214, 255], a: 0.5, ax: 260, ay: 100, period: 9.5, ph: 4 },
+ { x: 520, y: 960, r: 520, col: [255, 96, 84], a: 0.42, ax: 180, ay: 90, period: 12, ph: 1.3 },
+];
+const SANS = '"Inter", "NotoSansSC"', ZH = '"NotoSansSC"';
+// 光斑底:只依赖全片时间 t,三个镜头之间无缝(换镜头时背景不跳)
+const bg = (c, t, { dim = 0.38 } = {}) => {
+ UI.mesh(c, t, { base: BASE, blobs: BLOBS, blur: 90, scale: 0.25, grain: 0.035, key: 't2mesh' });
+ // 中心压暗一点,给白字留对比
+ const g = c.createRadialGradient(W / 2, H / 2, 100, W / 2, H / 2, 1000); g.addColorStop(0, `rgba(0,0,0,${dim})`); g.addColorStop(1, 'rgba(0,0,0,0.1)');
+ c.fillStyle = g; c.fillRect(0, 0, W, H);
+};
+// 大字:字距收紧 −0.02em(苹果/Linear 官网 64px 以上 −0.015~−0.03em)
+const track = (c, size, em = -0.02) => { c.letterSpacing = (size * em).toFixed(2) + 'px'; };
+// 光斑漂移、卡片漂浮、图标律动都读全片时间 t。PHASE:沿用实验时这支片排在 8–16s 的相位,保持定稿画面的构图(换题目时删掉或随便改)
+const PHASE = 8;
+window.T2 = { bg, SANS, ZH, track, BASE, PHASE };
+
+const DUR = 2.6;
+SCENES['t2_s1'] = {
+ draw(c, lt, t) {
+ t += T2.PHASE;
+ bg(c, t);
+ // 相机匀速慢推:1.0 → 1.045(整镜线性,发布会片的慢推不减速,减速到停会让画面「死」掉)
+ const s = lerp(1, 1.045, lt / (DUR + 0.55));
+ c.save(); c.translate(W / 2, H / 2); c.scale(s, s); c.translate(-W / 2, -H / 2);
+ c.textAlign = 'center'; c.textBaseline = 'alphabetic';
+ // 眉题
+ c.font = `500 34px ${ZH}`; c.fillStyle = '#a7a7b4'; c.letterSpacing = '6px';
+ TY.blurIn(c, '全 新 发 布', W / 2, 372, MO.appleOut(MO.seg(lt, 0.1, 0.8)), { blur: 10, dy: 16 });
+ // 产品名:渐变字画进离屏 → 光扫过(source-atop 只亮在字上)→ 模糊→清晰贴回
+ const p = MO.appleOut(MO.seg(lt, 0.3, 1.3));
+ if (p > 0) {
+ const tx = UI.scratch('t2title', W, 420), g = tx.getContext('2d'); g.reset();
+ g.font = `600 220px ${SANS}`; track(g, 220); g.textAlign = 'center'; g.textBaseline = 'alphabetic';
+ const gr = g.createLinearGradient(600, 0, 1320, 0); gr.addColorStop(0, '#ffffff'); gr.addColorStop(0.55, '#ddd2ff'); gr.addColorStop(1, '#a8dcff');
+ g.fillStyle = gr; g.fillText('Plover 2', W / 2, 300);
+ UI.sheen(g, null, MO.seg(lt, 1.25, 2.15), { x0: 560, x1: 1360, width: 140, angle: -0.38, alpha: 0.85, comp: 'source-atop' });
+ c.save(); c.globalAlpha = clamp(p * 1.5); const b = (1 - p) * 26; if (b > 0.3) c.filter = `blur(${b.toFixed(1)}px)`;
+ c.drawImage(tx, 0, 620 - 300 + (1 - p) * 40); c.restore(); // 纹理基线 y=300 → 屏幕 y=620
+ }
+ // 副标题
+ c.font = `400 50px ${ZH}`; c.fillStyle = '#c9c9d4'; c.letterSpacing = '1px';
+ TY.blurIn(c, '会思考、会记忆、会动手的 AI 助手', W / 2, 740, MO.appleOut(MO.seg(lt, 0.7, 1.6)), { blur: 12, dy: 22 });
+ c.restore();
+ },
+};
+})();
diff --git a/scripts/engine/demos/t2_keynote_ui/t2_s2.js b/scripts/engine/demos/t2_keynote_ui/t2_s2.js
new file mode 100644
index 0000000..8d68008
--- /dev/null
+++ b/scripts/engine/demos/t2_keynote_ui/t2_s2.js
@@ -0,0 +1,70 @@
+// t2 · 镜头 2(3.0s):三张毛玻璃功能卡片在 3D 空间入场(弹簧,bounce 0.15,错开 0.1s),绕 Y 轴转正;
+// 卡上数字计数;整组持续漂浮;光扫过三张卡;最后中间卡「被选中」(放大,其余后退变暗),接共享元素展开。
+(() => {
+const { clamp, lerp } = U;
+const W = 1920, H = 1080;
+const CW = 480, CH_ = 580, GAP = 52, CY = 560, R = 36;
+const CARDS = [
+ { icon: 'wave', title: '实时语音', desc: '像打电话一样自然地打断和追问', num: 320, dec: 0, unit: 'ms', label: '端到端延迟' },
+ { icon: 'memory', title: '长期记忆', desc: '记得你说过的每一个偏好', num: 100, dec: 0, unit: '万', label: 'tokens 上下文' },
+ { icon: 'agent', title: '自主执行', desc: '拆解任务、调用工具、交付结果', num: 87, dec: 0, unit: '%', label: '任务一次完成率' },
+];
+const DUR = 3.0, FOCUS = 2.15; // 2.15s 起中间卡被选中
+// 每张卡在 lt 时刻的状态(屏幕中心、旋转、缩放、透明),转场也要用中间卡的最终矩形
+const state = (i, lt, t) => {
+ const t0 = 0.05 + i * 0.1; // 错开 0.1s
+ const sp = MO.spring(lt - t0, { duration: 0.75, bounce: 0.15 });
+ const f = MO.smooth(MO.seg(lt, FOCUS, FOCUS + 0.6));
+ const floatAmp = lerp(1, i === 1 ? 0 : 0.6, f); // 被选中的卡停止漂浮,好让转场从一个稳定的矩形展开
+ const cx = 960 + (i - 1) * (CW + GAP) + (i - 1) * 40 * f;
+ const cy = CY + (1 - sp) * 170 + MO.float(t, 7, 3.4 + i * 0.45, i * 2) * floatAmp;
+ const ry = (1 - sp) * (i - 1 || 0.001) * -0.55 + 0.06 * Math.sin(t * 0.9 + i) * floatAmp + (i - 1) * 0.12 * f;
+ const sc = (0.9 + 0.1 * sp) * (i === 1 ? lerp(1, 1.06, f) : lerp(1, 0.94, f));
+ const a = clamp((lt - t0) / 0.25) * (i === 1 ? 1 : lerp(1, 0.45, f));
+ return { cx, cy, ry, sc, a, t0 };
+};
+const cardRectAt = (lt, t) => { const s = state(1, lt, t); return { x: s.cx - CW * s.sc / 2, y: s.cy - CH_ * s.sc / 2, w: CW * s.sc, h: CH_ * s.sc }; };
+
+SCENES['t2_s2'] = {
+ cardRectAt, CW, CH: CH_,
+ draw(c, lt, t) {
+ t += T2.PHASE;
+ const bgc = UI.scratch('t2bg', W, H), bgx = bgc.getContext('2d');
+ T2.bg(bgx, t); c.drawImage(bgc, 0, 0);
+ const bd = UI.backdrop(bgc, { blur: 40, key: 't2bd' });
+ // 先画两侧再画中间(中间卡在最上层)
+ [0, 2, 1].forEach(i => {
+ const S = state(i, lt, t); if (S.a <= 0) return;
+ const d = CARDS[i], cw = CW * S.sc, ch = CH_ * S.sc;
+ // 卡片纹理:毛玻璃(按卡片的屏幕位置取样背景)+内容
+ const tex = UI.scratch('t2card' + i, CW + 120, CH_ + 120), g = tex.getContext('2d'); g.reset();
+ const ox = 60, oy = 60;
+ UI.glass(g, { x: ox, y: oy, w: CW, h: CH_, r: R, bd, sample: { x: S.cx - cw / 2, y: S.cy - ch / 2, w: cw, h: ch }, tint: 0.075, stroke: 0.2, light: 0.14, shadow: false });
+ g.save(); g.translate(ox, oy);
+ // 图标底:同心圆角(子圆角 = 父圆角 − 内边距)
+ const pad = 44; g.fillStyle = 'rgba(255,255,255,0.09)'; g.beginPath(); g.roundRect(pad, pad, 96, 96, R - 14); g.fill();
+ UI.icon(g, d.icon, pad + 48, pad + 48, 60, '#f2f2f7', t);
+ g.textBaseline = 'alphabetic'; g.textAlign = 'left';
+ g.font = `600 50px ${T2.ZH}`; g.fillStyle = '#f5f5f7'; g.fillText(d.title, pad, 230);
+ g.font = `400 28px ${T2.ZH}`; g.fillStyle = 'rgba(235,235,245,0.62)'; g.fillText(d.desc, pad, 278);
+ // 分隔线
+ g.fillStyle = 'rgba(255,255,255,0.12)'; g.fillRect(pad, 330, CW - pad * 2, 1.5);
+ // 大数字:卡片落定后 0.25s 起计数 0.9s(easeOutExpo,最后一位慢慢落定),等宽排布不抖
+ const v = TY.count(lt, S.t0 + 0.35, 0.9, 0, d.num);
+ g.font = `600 132px ${T2.SANS}`; T2.track(g, 132, -0.03); g.fillStyle = '#ffffff';
+ const nw = TY.tabular(g, TY.fmt(v, d.dec), pad, 488);
+ g.letterSpacing = '0px'; g.font = `500 52px ${T2.SANS}`; g.fillStyle = 'rgba(235,235,245,0.7)'; g.fillText(d.unit, pad + nw + 10, 488);
+ g.font = `400 28px ${T2.ZH}`; g.fillStyle = 'rgba(235,235,245,0.55)'; g.fillText(d.label, pad, 535);
+ g.restore();
+ // 光扫过:1.2–2.0s 从左到右扫过整组(每张卡按自己的屏幕位置算进度,看起来是同一道光)
+ const sp = MO.seg(lt, 1.15, 2.05), gx = lerp(-200, W + 200, sp), lx = (gx - (S.cx - cw / 2)) / cw;
+ if (sp > 0 && sp < 1) UI.sheen(g, UI.rrPath(ox, oy, CW, CH_, R), clamp((lx + 0.35) / 1.7), { x0: ox, x1: ox + CW, width: 110, angle: -0.35, alpha: 0.22 });
+ // 阴影(按屏幕投影后的尺寸)+透视贴图
+ c.save(); c.globalAlpha = S.a;
+ UI.shadow(c, S.cx - cw / 2 + 10, S.cy - ch / 2 + 20, cw - 20, ch - 20, R, { blur: 80, oy: 40, alpha: 0.55 });
+ UI.persp(c, tex, { cx: S.cx, cy: S.cy, w: (CW + 120) * S.sc, h: (CH_ + 120) * S.sc, ry: S.ry, persp: 1800, strip: 3, shade: 0.4 });
+ c.restore();
+ });
+ },
+};
+})();
diff --git a/scripts/engine/demos/t2_keynote_ui/t2_s3.js b/scripts/engine/demos/t2_keynote_ui/t2_s3.js
new file mode 100644
index 0000000..37086e0
--- /dev/null
+++ b/scripts/engine/demos/t2_keynote_ui/t2_s3.js
@@ -0,0 +1,61 @@
+// t2 · 镜头 3(2.4s,前 0.6s 是中间卡「展开成全屏」的共享元素转场):
+// 我们「进到了长期记忆这张卡里」——底是同一块毛玻璃;超大数字(与卡片同口径,不重数);下方一块向后倾斜的对话面板,气泡依次弹起;最后产品落版。
+(() => {
+const { clamp, lerp } = U;
+const W = 1920, H = 1080;
+const PW = 1180, PH = 360;
+SCENES['t2_s3'] = {
+ draw(c, lt, t) {
+ t += T2.PHASE;
+ const bgc = UI.scratch('t2bg3', W, H), bgx = bgc.getContext('2d');
+ T2.bg(bgx, t, { dim: 0.25 });
+ const bd = UI.backdrop(bgc, { blur: 40, key: 't2bd3' });
+ // 全屏毛玻璃 = 卡片的质地放大到全屏(与转场里展开的卡片同一种材料)
+ c.drawImage(bd, 0, 0, W, H); c.fillStyle = 'rgba(255,255,255,0.075)'; c.fillRect(0, 0, W, H);
+ const tg = c.createLinearGradient(0, 0, 0, H * 0.5); tg.addColorStop(0, 'rgba(255,255,255,0.10)'); tg.addColorStop(1, 'rgba(255,255,255,0)'); c.fillStyle = tg; c.fillRect(0, 0, W, H * 0.5);
+ // 卡片抬头留在左上(展开前它就在卡片的这个位置,观众知道自己在哪)
+ c.fillStyle = 'rgba(255,255,255,0.09)'; c.beginPath(); c.roundRect(120, 96, 84, 84, 20); c.fill();
+ UI.icon(c, 'memory', 162, 138, 52, '#f2f2f7', t);
+ c.font = `600 44px ${T2.ZH}`; c.fillStyle = '#f5f5f7'; c.textBaseline = 'alphabetic'; c.textAlign = 'left'; c.fillText('长期记忆', 232, 154);
+ // 超大数字:和卡片上同一个口径「100万」,不重新计数(卡片刚数过一遍,展开后再从 0 数会让叙事打嗝)——卡片里的数字放大成主角
+ const pin = MO.appleOut(MO.seg(lt, 0.0, 0.5));
+ c.save(); c.textBaseline = 'alphabetic'; c.textAlign = 'left';
+ c.font = `600 230px ${T2.SANS}`; T2.track(c, 230, -0.03); const w1 = c.measureText('100').width;
+ c.letterSpacing = '0px'; c.font = `600 150px ${T2.ZH}`; const w2 = c.measureText('万').width;
+ c.font = `500 56px ${T2.SANS}`; const w3 = c.measureText('tokens').width;
+ const x0 = W / 2 - (w1 + w2 + w3 + 34) / 2, by = 400 - (1 - pin) * 20;
+ c.font = `600 230px ${T2.SANS}`; T2.track(c, 230, -0.03); c.fillStyle = '#ffffff'; c.fillText('100', x0, by);
+ c.letterSpacing = '0px'; c.font = `600 150px ${T2.ZH}`; c.fillText('万', x0 + w1 + 6, by);
+ c.font = `500 56px ${T2.SANS}`; c.fillStyle = 'rgba(235,235,245,0.7)'; c.fillText('tokens', x0 + w1 + w2 + 34, by);
+ c.restore();
+ c.font = `400 34px ${T2.ZH}`; c.fillStyle = 'rgba(235,235,245,0.6)'; c.textAlign = 'center';
+ TY.blurIn(c, '上下文窗口 —— 一年的对话,它都记得', W / 2, 478, MO.appleOut(MO.seg(lt, 0.35, 0.95)), { blur: 8, dy: 14 });
+ // 对话面板(纹理 → 绕 X 轴后倾),气泡按 spring 依次弹起;面板整体缓慢上浮
+ const tex = UI.scratch('t2panel', PW, PH), g = tex.getContext('2d'); g.reset();
+ g.fillStyle = 'rgba(12,12,20,0.55)'; g.beginPath(); g.roundRect(0, 0, PW, PH, 30); g.fill();
+ g.strokeStyle = 'rgba(255,255,255,0.16)'; g.lineWidth = 2; g.stroke();
+ const bubble = (k, text, right, y, t0) => {
+ const s = MO.spring(lt - t0, { duration: 0.5, bounce: 0.15 }); if (lt <= t0) return;
+ g.save(); g.globalAlpha = clamp((lt - t0) / 0.2); g.font = `400 34px ${T2.ZH}`;
+ const tw = g.measureText(text).width, bw = tw + 64, bh = 74, bx = right ? PW - 48 - bw : 48, by = y + (1 - s) * 40;
+ g.translate(bx + (right ? bw : 0), by + bh); g.scale(lerp(0.85, 1, s), lerp(0.85, 1, s)); g.translate(-(bx + (right ? bw : 0)), -(by + bh));
+ g.fillStyle = right ? '#3d6bff' : 'rgba(255,255,255,0.14)'; g.beginPath(); g.roundRect(bx, by, bw, bh, 37); g.fill();
+ g.fillStyle = '#fff'; g.textBaseline = 'middle'; g.fillText(text, bx + 32, by + bh / 2 + 2); g.restore();
+ void k;
+ };
+ bubble(0, '还记得我上个月说的旅行计划吗?', true, 36, 0.45);
+ bubble(1, '记得:五月去京都,预算两万,不坐红眼航班。', false, 134, 0.8);
+ bubble(2, '那帮我订吧。', true, 232, 1.15);
+ // 输入中光标闪(持续小动作)
+ if (lt > 1.35) { g.fillStyle = `rgba(255,255,255,${0.35 + 0.35 * Math.sin(lt * 9)})`; for (let k = 0; k < 3; k++) { g.beginPath(); g.arc(90 + k * 26, 330, 7, 0, Math.PI * 2); g.fill(); } }
+ const pp = MO.spring(lt - 0.3, { duration: 0.8, bounce: 0 });
+ c.save(); c.globalAlpha = clamp((lt - 0.3) / 0.3);
+ UI.persp(c, tex, { cx: W / 2, cy: 725 + (1 - pp) * 120 - 8 * MO.smooth(clamp(lt / 2.4)), w: PW, h: PH, rx: lerp(0.55, 0.32, pp), persp: 1500, strip: 2 });
+ c.restore();
+ // 落版:品牌名 + 上线信息
+ c.textAlign = 'center'; c.font = `600 40px ${T2.SANS}`; T2.track(c, 40, -0.01); c.fillStyle = '#ffffff';
+ TY.blurIn(c, 'Plover 2 · 今天起可用', W / 2, 972, MO.appleOut(MO.seg(lt, 1.2, 1.8)), { blur: 10, dy: 12 }); // 1.8s 落定,停 0.6s;y=972 在字幕安全区内
+ c.letterSpacing = '0px';
+ },
+};
+})();
diff --git a/scripts/engine/demos/t3_finance_chart/eras.js b/scripts/engine/demos/t3_finance_chart/eras.js
new file mode 100644
index 0000000..0bb6853
--- /dev/null
+++ b/scripts/engine/demos/t3_finance_chart/eras.js
@@ -0,0 +1,11 @@
+// 示范 · 财经图表(经济学人 / 财经频道)「深算科技营收与股价」(8 秒三镜,公司与数据全部虚构,每镜标「示意数据」)。语法卡:references/动画语法/t3_finance_chart.md
+// 预览 index.html?film=demos/t3_finance_chart 渲染 render.py --film demos/t3_finance_chart --out t3.mp4
+// 镜头 2→3:相机绕股价线最新点推近(矢量重画、屏幕位置不动),穿进最近 20 日 K 线。
+window.PUNCH = 0;
+window.SCENE_DIR = 'demos/t3_finance_chart';
+window.ERAS = [
+ { id: 't3_s1', dur: 2.8 },
+ { id: 't3_s2', dur: 2.7, transition: { type: 'slidePush', dur: 0.5, bar: '#E3120B' } },
+ { id: 't3_s3', dur: 2.5, transition: { type: 'zoomThrough', dur: 0.6, cx: 1530, cy: 297.65, zoom: 6, live: true, bScale0: 0.6, bg: '#FFFFFF',
+ get focus() { return SCENES.t3_s3.focus; } } }, // focus = 最新一根 K 线
+];
diff --git a/scripts/engine/demos/t3_finance_chart/t3_s1.js b/scripts/engine/demos/t3_finance_chart/t3_s1.js
new file mode 100644
index 0000000..fddcf7f
--- /dev/null
+++ b/scripts/engine/demos/t3_finance_chart/t3_s1.js
@@ -0,0 +1,48 @@
+// t3 · 财经图表:「某虚构 AI 公司 5 年营收增长与股价」(数据全部虚构,每一镜角落标「示意数据」)
+// 镜头 1(2.8s):版式先出(顶红线+红色小旗+标题+单位)→ 网格从左往右画出(零线最深)→ 柱子从 0 依次长出、数值同步计数 →
+// 高亮最后一根(其余变灰)→ 标注「8.7 倍」。本文件同时放 t3 共用的版式与数据(window.T3)。
+(() => {
+const { clamp, lerp, rng } = U;
+const W = 1920, H = 1080;
+// 颜色:经济学人图表色板(2017 图表风格指南)
+const COL = { red: '#E3120B', blue: '#006BA2', blue2: '#3EBCD2', grey: '#758D99', dim: '#C6D2D8', ink: '#0C0C0C', sub: '#4F5B61', grid: 'rgba(12,12,12,0.13)', bg: '#FFFFFF', up: '#E3120B', down: '#1B9E5A', gold: '#EBB434' };
+const CN = '"NotoSansSC"', NUM = '"RobotoCondensed", "NotoSansSC"';
+const F = { x: 170, y: 270, w: 1580, h: 610 }; // 绘图区
+// ---- 虚构数据 ----
+const REV = [{ y: 2021, v: 12.4 }, { y: 2022, v: 19.8 }, { y: 2023, v: 34.6 }, { y: 2024, v: 61.2 }, { y: 2025, v: 107.9 }];
+// 月收盘价 60 个点:带种子的随机游走,2022 回撤、2023-03 跳涨,再整体缩放到 38 → 286.4
+const PRICE = (() => { const r = rng(2025), a = []; let v = 0;
+ for (let m = 0; m < 60; m++) { const drift = m < 12 ? 0.02 : m < 24 ? -0.035 : m === 26 ? 0.35 : 0.045; v += drift + (r() - 0.5) * 0.11; a.push(v); }
+ const e = a.map(Math.exp), k0 = e[0], k1 = e[59], out = e.map(x => 38 + (x - k0) / (k1 - k0) * (286.4 - 38));
+ out[58] = 242; return out; })(); // 末点 = 最新价 286.4,倒数第二个月收盘 = 日 K 起点 242(两镜数字对得上)
+// 最近 20 个交易日 K 线:从 242 走到 286.4(+18.3%),有涨有跌
+const KL = (() => { const r = rng(77), out = []; let c = 242;
+ for (let i = 0; i < 20; i++) { const tgt = 242 + (286.4 - 242) * (i + 1) / 20; const o = c; const cl = i === 19 ? 286.4 : tgt + (r() - 0.5) * 9 + (i % 5 === 3 ? -7 : 0);
+ const hi = Math.max(o, cl) + 1.5 + r() * 4, lo = Math.min(o, cl) - 1.5 - r() * 4; out.push({ o, c: cl, h: hi, l: lo, vol: 0.4 + r() * 0.6 + (Math.abs(cl - o) / 10) }); c = cl; }
+ return out; })();
+
+// ---- 版式(每镜都画):经济学人式整页版式 CH.frame(顶部红线、左上红色小旗、标题、副标题=单位、来源、示意数据角标)----
+const frame = (c, lt, { title, sub, source = '来源:示意数据,公司与数字均为虚构' } = {}) => CH.frame(c, lt, { title, sub, source, font: CN, red: COL.red, ink: COL.ink, subCol: COL.sub });
+window.T3 = { COL, CN, NUM, F, REV, PRICE, KL, frame };
+
+// ---- 镜头 1 ----
+const yS = CH.lin(0, 120, F.y + F.h, F.y);
+const xs = REV.map((d, i) => F.x + 130 + i * ((F.w - 330) / 4));
+SCENES['t3_s1'] = {
+ draw(c, lt) {
+ c.fillStyle = T3.COL.bg; c.fillRect(0, 0, 1920, 1080);
+ const z = 1 + 0.03 * lt / 2.8; // 匀速慢推 1→1.03(财经频道图表镜头的常规呼吸感)
+ c.save(); c.translate(960, 575); c.scale(z, z); c.translate(-960, -575);
+ frame(c, lt, { title: '深算科技:营收五年涨到原来的近 9 倍', sub: '年营收,亿元' });
+ CH.grid(c, F, [0, 30, 60, 90, 120], yS, MO.seg(lt, 0.25, 0.85), { col: COL.grid, zeroCol: COL.ink, font: `400 30px ${NUM}`, labelCol: '#5b666b', side: 'right', lw: 1.5, zeroLw: 3 });
+ CH.xLabels(c, REV.map((d, i) => ({ x: xs[i], label: String(d.y) })), F.y + F.h + 50, MO.seg(lt, 0.45, 1.0), { font: `400 32px ${NUM}`, col: '#3a4246' });
+ const hiP = MO.smooth(MO.seg(lt, 1.95, 2.35));
+ const tops = CH.bars(c, REV.map((d, i) => ({ x: xs[i], v: d.v })), yS, 150, MO.seg(lt, 0.65, 1.95),
+ { lag: 0.22, col: COL.blue, hi: lt > 1.95 ? 4 : -1, hiP, hiCol: COL.blue, dimCol: COL.dim, fmt: v => v.toFixed(1), font: `600 34px ${NUM}`, labelCol: COL.ink });
+ // 标注:最后一根柱旁,点 → 引线 → 两行字(数字先说,比较后说)
+ CH.callout(c, lt, 2.15, { x: xs[4] - 75, y: tops[4][1], tx: xs[4] - 330, ty: yS(96), lines: ['8.7 倍', '2025 年 107.9 亿 ÷ 2021 年 12.4 亿'],
+ col: COL.ink, dotCol: COL.red, font: `700 54px ${NUM}`, font2: `400 28px ${CN}`, align: 'right', r: 9 });
+ c.restore();
+ },
+};
+})();
diff --git a/scripts/engine/demos/t3_finance_chart/t3_s2.js b/scripts/engine/demos/t3_finance_chart/t3_s2.js
new file mode 100644
index 0000000..614bb24
--- /dev/null
+++ b/scripts/engine/demos/t3_finance_chart/t3_s2.js
@@ -0,0 +1,42 @@
+// t3 · 镜头 2(2.7s,开头 0.5s 是面板横推转场):股价折线。网格先出 → 折线按时间从左画到右(头部圆点+价格跟随)→
+// 画过 2023 年 3 月时弹出事件标注(一镜只标一件事) → 相机缓慢推向最新一个点;转场期间继续推近(矢量重画),穿进 K 线镜头。
+(() => {
+const { clamp, lerp } = U;
+const W = 1920, H = 1080;
+const DUR = 2.7;
+SCENES['t3_s2'] = {
+ draw(c, lt) {
+ const { COL, CN, NUM, F, PRICE, frame } = T3;
+ const yS = CH.lin(0, 300, F.y + F.h, F.y), xm = m => F.x + m / 59 * (F.w - 220);
+ const pts = PRICE.map((v, m) => [xm(m), yS(v)]);
+ const P = pts[59];
+ // 相机:镜头内 1 → 1.05,转场期间(lt > DUR)指数推近到 ×6,始终绕最新点(屏幕位置不动)
+ const tr = ERAS.find(e => e.id === 't3_s3').transition;
+ const z = lt <= DUR ? lerp(1, 1.05, MO.smooth(lt / DUR)) : 1.05 * Math.pow(tr.zoom / 1.05, MO.smooth(clamp((lt - DUR) / tr.dur)));
+ c.fillStyle = COL.bg; c.fillRect(0, 0, W, H);
+ c.save(); c.translate(P[0], P[1]); c.scale(z, z); c.translate(-P[0], -P[1]);
+ frame(c, lt, { title: '股价:先跌后涨,五年涨到原来的 7.5 倍', sub: '月收盘价,元' });
+ CH.grid(c, F, [0, 100, 200, 300], yS, MO.seg(lt, 0.2, 0.75), { col: COL.grid, zeroCol: COL.ink, font: `400 30px ${NUM}`, labelCol: '#5b666b', side: 'right', lw: 1.5, zeroLw: 3 });
+ CH.xLabels(c, [2021, 2022, 2023, 2024, 2025].map((y, i) => ({ x: xm(i * 12 + 5.5), label: String(y) })), F.y + F.h + 50, MO.seg(lt, 0.3, 0.8), { font: `400 32px ${NUM}`, col: '#3a4246' });
+ // 年份分隔短刻度
+ c.save(); c.strokeStyle = 'rgba(12,12,12,.35)'; c.lineWidth = 2; c.globalAlpha = MO.seg(lt, 0.3, 0.6);
+ for (let y = 1; y < 5; y++) { const x = xm(y * 12 - 0.5); c.beginPath(); c.moveTo(x, F.y + F.h); c.lineTo(x, F.y + F.h + 14); c.stroke(); } c.restore();
+ // 折线:0.45–1.95s 按时间画出(smooth:起步和落定都慢,最后一个价格「落」在点上)
+ const lp = MO.smooth(MO.seg(lt, 0.45, 1.95));
+ const hp = CH.line(c, pts, lp, { col: COL.red, lw: 5, headR: 9, area: { top: F.y, base: F.y + F.h, c0: 'rgba(227,18,11,0.14)', c1: 'rgba(227,18,11,0)' } });
+ if (hp) { // 价格标签跟着头走(等宽数字,不抖)
+ const v = yS.inv(hp[1]);
+ c.save(); c.globalAlpha = 1 - clamp((lt - DUR) / 0.2); // 推进转场一开始就收掉,免得和下一镜右上的价格叠影
+ c.font = `700 38px ${NUM}`; c.fillStyle = COL.red; c.textAlign = 'left'; c.textBaseline = 'middle';
+ TY.tabular(c, '¥' + v.toFixed(0), hp[0] + 22, hp[1] - 4); c.restore();
+ }
+ // 事件标注:线头经过 2023 年 3 月(第 26 个月)时触发
+ const m26 = xm(26), tHit = 0.45 + 1.5 * invSmooth((m26 - pts[0][0]) / (pts[59][0] - pts[0][0]));
+ CH.callout(c, lt, tHit, { x: m26, y: pts[26][1], tx: m26 - 30, ty: pts[26][1] - 150, lines: ['2023.3', '发布自研大模型'], col: COL.ink, dotCol: COL.ink,
+ font: `700 34px ${NUM}`, font2: `400 30px ${CN}`, align: 'right', r: 8 });
+ c.restore();
+ },
+};
+// smooth 的反函数(二分),用于「线头到达某个 x 的时刻」
+function invSmooth(y) { let a = 0, b = 1; for (let i = 0; i < 30; i++) { const m = (a + b) / 2; if (MO.smooth(m) < y) a = m; else b = m; } return (a + b) / 2; }
+})();
diff --git a/scripts/engine/demos/t3_finance_chart/t3_s3.js b/scripts/engine/demos/t3_finance_chart/t3_s3.js
new file mode 100644
index 0000000..5026099
--- /dev/null
+++ b/scripts/engine/demos/t3_finance_chart/t3_s3.js
@@ -0,0 +1,51 @@
+// t3 · 镜头 3(2.5s,前 0.6s 是从上一镜最新点「推进来」的转场):最近 20 个交易日 K 线。
+// 价格区网格先出 → K 线逐根长出(红涨绿跌,A 股惯例)、成交量同步 → 右上价格跟着最新一根滚动 → 起点参考虚线+区间涨幅标注 → 停 0.75s。
+// (审片后删掉了 5 日均线:2 秒里读不完 K 线+均线+量+括注)
+(() => {
+const { clamp, lerp } = U;
+const W = 1920, H = 1080;
+const L = (() => {
+ const { F, KL } = T3;
+ const lo = Math.min(...KL.map(k => k.l)), hi = Math.max(...KL.map(k => k.h));
+ const ticks = CH.ticks(lo - 4, hi + 4, 4), y0 = ticks[0], y1 = ticks[ticks.length - 1];
+ const PB = F.y + F.h * 0.74; // 价格区底
+ const yS = CH.lin(y0, y1, PB, F.y + 10);
+ const xs = KL.map((_, i) => F.x + 40 + i * ((F.w - 330) / 19));
+ return { ticks, yS, xs, PB, VB: F.y + F.h, VT: F.y + F.h * 0.8 };
+})();
+SCENES['t3_s3'] = {
+ focus: [L.xs[19], L.yS(286.4)],
+ draw(c, lt) {
+ const { COL, CN, NUM, F, KL, frame } = T3;
+ c.fillStyle = COL.bg; c.fillRect(0, 0, 1920, 1080);
+ const z = 1 + 0.03 * lt / 2.5; // 匀速慢推 1→1.03
+ c.save(); c.translate(960, 575); c.scale(z, z); c.translate(-960, -575);
+ frame(c, lt + 0.6, { title: '最近 20 个交易日:涨了 18.3%', sub: '日 K 线,元 红涨绿跌(A 股惯例) 纵轴未从 0 开始' });
+ const PF = { x: F.x, y: F.y, w: F.w, h: L.PB - F.y };
+ CH.grid(c, PF, L.ticks, L.yS, MO.seg(lt, 0.1, 0.6), { col: COL.grid, zeroCol: COL.grid, font: `400 30px ${NUM}`, labelCol: '#5b666b', side: 'right', lw: 1.5 });
+ // 成交量区基线
+ c.fillStyle = COL.ink; c.fillRect(F.x, L.VB - 1, F.w * MO.quintOut(MO.seg(lt, 0.1, 0.6)), 2);
+ c.save(); c.font = `400 26px ${CN}`; c.fillStyle = '#7c868b'; c.textAlign = 'right'; c.globalAlpha = MO.seg(lt, 0.3, 0.6); c.fillText('成交量', F.x + F.w, L.VB - 14); c.restore(); // 放右下角空处,不压 K 线
+ // K 线 + 成交量:逐根(lag 0.06),0.2–1.3s
+ const kp = MO.seg(lt, 0.2, 1.3);
+ CH.candles(c, KL, L.xs, L.yS, 30, kp, { up: COL.up, down: COL.down, lag: 0.06 });
+ const VMAX = Math.max(...KL.map(k => k.vol));
+ KL.forEach((k, i) => { const q = MO.quintOut(MO.lagged(i, 20, kp, 0.06)); if (q <= 0) return;
+ const h = (L.VB - L.VT - 6) * k.vol / VMAX * q; // 按最大量归一,量柱不顶到价格区
+ c.fillStyle = k.c >= k.o ? 'rgba(227,18,11,.35)' : 'rgba(27,158,90,.35)'; c.fillRect(L.xs[i] - 15, L.VB - h, 30, h); });
+ // 右上价格:跟着「最新出现的那根」滚动;涨跌色 = 相对区间起点
+ let n = 0; for (let i = 0; i < 20; i++) if (MO.lagged(i, 20, kp, 0.06) > 0) n = i;
+ const qn = MO.quintOut(MO.lagged(n, 20, kp, 0.06)), v = lt < 0.2 ? 242 : lerp(KL[n].o, KL[n].c, qn), pct = (v / 242 - 1) * 100;
+ c.save(); c.textAlign = 'right'; c.textBaseline = 'alphabetic'; c.font = `700 76px ${NUM}`; c.fillStyle = pct >= 0 ? COL.up : COL.down;
+ TY.tabular(c, '¥' + v.toFixed(2), W - 80, 150, { align: 'right' });
+ c.font = `700 40px ${NUM}`; TY.tabular(c, (pct >= 0 ? '▲ +' : '▼ ') + pct.toFixed(1) + '%', W - 80, 205, { align: 'right' }); c.restore();
+ // 起点参考虚线 + 区间涨幅括注
+ const rp = MO.quintOut(MO.seg(lt, 1.35, 1.75)); // 1.75s 落定,停 0.75s 给人读
+ if (rp > 0) { const y = L.yS(242); c.save(); c.setLineDash([10, 8]); c.strokeStyle = COL.sub; c.lineWidth = 2; c.beginPath(); c.moveTo(L.xs[0], y); c.lineTo(lerp(L.xs[0], L.xs[19] + 60, rp), y); c.stroke(); c.setLineDash([]);
+ const x = L.xs[19] + 60, yt = L.yS(286.4); c.strokeStyle = COL.up; c.lineWidth = 3; c.beginPath(); c.moveTo(x, y); c.lineTo(x, lerp(y, yt, rp)); c.stroke();
+ c.globalAlpha = MO.seg(lt, 1.5, 1.8); c.font = `700 40px ${NUM}`; c.fillStyle = COL.up; c.fillText('+18.3%', x + 14, (y + yt) / 2 + 14);
+ c.font = `400 26px ${CN}`; c.fillStyle = COL.sub; c.textAlign = 'right'; c.fillText('区间起点 ¥242', x - 14, y + 32); c.restore(); }
+ c.restore();
+ },
+};
+})();
diff --git a/scripts/engine/demos/y1_kurzgesagt/eras.js b/scripts/engine/demos/y1_kurzgesagt/eras.js
new file mode 100644
index 0000000..720affa
--- /dev/null
+++ b/scripts/engine/demos/y1_kurzgesagt/eras.js
@@ -0,0 +1,10 @@
+// 示范 · Kurzgesagt 式扁平科普「AI 是怎么学会认猫的」(8 秒三镜)。语法卡:references/动画语法/y1_kurzgesagt.md
+// 预览 index.html?film=demos/y1_kurzgesagt 渲染 render.py --film demos/y1_kurzgesagt --out y1.mp4
+// 镜头按口播切,dur 用秒;解说片不要拍点冲击(PUNCH = 0)。相机运动全在场景里按时间算(CAM),转场只管 A、B 怎么合。
+window.PUNCH = 0;
+window.SCENE_LIBS = ['demos/_shared/hero.js', 'demos/y1_kurzgesagt/kurzgesagt.js'];
+window.ERAS = [
+ { id: 'y1_s1', dur: 2.6 }, // 夜晚山坡:5 层视差慢推,机器人扫描猫
+ { id: 'y1_s2', dur: 2.7, transition: { type: 'lensReveal', dur: 1.0, lens: t => Y1.lensAt(t) } }, // 钻进镜头:相机指数推进眼睛,眼睛里是下一个世界
+ { id: 'y1_s3', dur: 2.7, transition: { type: 'matchCut', dur: 0.9 } }, // 填满再拉出:推满黄色输出节点 → 从黄色的眼睛里拉出
+];
diff --git a/scripts/engine/demos/y1_kurzgesagt/kurzgesagt.js b/scripts/engine/demos/y1_kurzgesagt/kurzgesagt.js
new file mode 100644
index 0000000..c75083c
--- /dev/null
+++ b/scripts/engine/demos/y1_kurzgesagt/kurzgesagt.js
@@ -0,0 +1,347 @@
+// Y1 · Kurzgesagt 式扁平科普:「AI 是怎么学会认猫的」
+// 三镜:①夜晚山坡,机器人扫描一只猫(视差 5 层、慢推) → 转场 A「钻进镜头」:相机指数推进机器人眼睛,眼睛里是下一个世界
+// ②机器人脑中:像素猫 → 神经网络逐层点亮(边缘→形状→猫) → 转场 B「填满再拉出」:推进点亮的输出节点直到满屏黄,切到机器人发黄光的眼睛再指数拉远
+// ③白天草坡:花叔招手,机器人认出一只没见过的黑猫,标签弹出
+// 时间全部用片内时间 ft = t - F0。镜头表在 Y1.SHOTS。
+// 用到的库:CAM(世界相机、视差层、对数缩放、推进锚点)、TOON(双色分面 flat、glow)、TY.charsIn(逐字上浮)、MO(k75 等缓动)。
+(() => {
+const W = 1920, H = 1080;
+const { clamp, lerp, rng } = U;
+const seg = MO.seg;
+const Y1 = window.Y1 = {};
+const F0 = 0; // 本片在时间轴上的起点
+Y1.F0 = F0;
+Y1.SHOTS = { s1: [0, 2.6], s2: [2.6, 5.3], s3: [5.3, 8.0] };
+const T1 = { a: 2.6, d: 1.0 }, T2 = { a: 5.3, d: 0.9 };
+// 调研 §6.2:官方「其他动作用 75% influence」≈ cubic-bezier(.75,0,.25,1);循环用 Easy Ease ≈ (.333,0,.667,1)
+const K75 = MO.k75;
+
+// ---------- 配色(夜 / 机内 / 昼 三套,Kurzgesagt 换场景=换整套色板) ----------
+const C = {
+ // 色值取自调研 §7.1(2025 深色系实测):深靛紫底+青/橙黄/品红三个强调色
+ night: { sky: ['#05020F', '#0E0631', '#2a1a6e'], star: '#F9FCFB', moon: '#FAF3CC', moonSh: '#E2C34E', hillFar: '#1a1260', hillFarHi: '#261c86', hill: '#2b1f86', hillHi: '#3a2c9e', hillSh: '#1f1668', fg: '#0E0631', grass: '#34269a' },
+ mind: { bg: ['#010718', '#130C4B'], grid: 'rgba(125,211,220,.07)', line: 'rgba(95,88,219,.35)', node: '#191670', nodeHi: '#3826A3', pulse: '#32BAEE', hot: '#FACC12', label: '#7DD3DC' },
+ day: { sky: ['#3fb4f5', '#8fd8ff', '#dcf6ff'], sun: '#fff1a8', cloud: '#ffffff', cloudSh: '#d6efff', hillFar: '#9ad66b', hillMid: '#6cc04d', ground: '#4ea83f', groundHi: '#66c24c', tree: '#2f8f3c', treeHi: '#4fb34f', trunk: '#8a5a3c' },
+ cat: { fur: '#F48301', sh: '#BF5E07', hi: '#ffab4a', belly: '#ffe0b5', ear: '#C83C7F', eye: '#ffffff', pupil: '#0E0631' },
+ bot: { shell: '#E7DFE1', sh: '#b3a6d6', hi: '#ffffff', face: '#0E0631', eye: '#32BAEE', eyeHot: '#FACC12', ant: '#BE3A95' },
+};
+
+// ---------- 扁平+双色阴影(Kurzgesagt 的「无描边、靠色块分面」):TOON.flat;视差层:CAM.layer ----------
+const flat = TOON.flat, glow = TOON.glow, circ = TOON.circle, ell = TOON.ellipse, vgrad = TOON.vgrad, layer = CAM.layer;
+Y1.flat = flat;
+const poly = (pts, smooth = true) => smooth ? RIG.smooth(pts, true) : U.poly(pts);
+
+// ---------- 角色:猫 ----------
+// 原点 = 坐姿底部中心;face=-1 朝左
+Y1.cat = (c, x, y, ft, { s = 1, face = -1, pal = C.cat, look = 0 } = {}) => {
+ const P = pal; c.save(); c.translate(x, y); c.scale(face * -s, s); // 本地朝左(-x 为脸)
+ const br = Math.sin(ft * 2.6) * 0.012; // 呼吸
+ c.scale(1 - br, 1 + br);
+ // 尾巴:两段贝塞尔,尖端画 8 字摆
+ const tw = Math.sin(ft * 2.2) * 0.5, tw2 = Math.sin(ft * 2.2 - 0.9) * 0.6;
+ const tail = new Path2D(); const tx = 120 + Math.cos(tw) * 30, ty = -150 + Math.sin(tw) * 40;
+ c.lineCap = 'round'; c.strokeStyle = P.sh; c.lineWidth = 30;
+ c.beginPath(); c.moveTo(70, -20); c.bezierCurveTo(150, -10, 170, -80, tx, ty); c.quadraticCurveTo(tx + 30 * Math.cos(tw2), ty - 40, tx - 10 + 30 * Math.sin(tw2), ty - 70); c.stroke();
+ c.strokeStyle = P.fur; c.lineWidth = 22; c.stroke();
+ // 身体:水滴形坐姿
+ const body = poly([[-70, 0], [-82, -60], [-64, -140], [-20, -190], [36, -186], [74, -140], [92, -60], [86, 0]]);
+ flat(c, body, P.fur, P.sh, P.hi, [-14, 12], [-5, 5]);
+ flat(c, poly([[-58, -4], [-62, -70], [-40, -140], [-6, -150], [10, -100], [10, -4]]), P.belly, '#f3c99a', '#fff3e0', [-8, 8], [-3, 3]);
+ // 前爪
+ flat(c, ell(-38, -6, 26, 14), P.belly, '#efc392', '#fff', [-4, 4], [-2, 2]);
+ flat(c, ell(12, -6, 26, 14), P.hi, P.sh, '#fff', [-4, 4], [-2, 2]);
+ // 头
+ c.save(); c.translate(-16, -210); c.rotate(look * 0.12 + Math.sin(ft * 1.3) * 0.03);
+ const earL = poly([[-70, -30], [-82, -118], [-20, -64]], false), earR = poly([[20, -64], [64, -120], [72, -30]], false);
+ flat(c, earL, P.fur, P.sh, P.hi, [-6, 6], [-2, 2]); flat(c, earR, P.fur, P.sh, P.hi, [-6, 6], [-2, 2]);
+ c.fillStyle = P.ear; c.fill(poly([[-62, -44], [-72, -98], [-32, -62]], false)); c.fill(poly([[30, -62], [58, -100], [62, -44]], false));
+ const head = ell(0, 0, 86, 74);
+ flat(c, head, P.fur, P.sh, P.hi, [-14, 12], [-5, 5]);
+ flat(c, ell(-12, 26, 46, 30), P.belly, '#f3c99a', '#fff', [-6, 6], [-2, 2]);
+ // 眼:大白眼+瞳孔看向 look 方向,眨眼
+ const bl = (ft % 3.1) > 2.98 ? 0.15 : 1;
+ for (const ex of [-44, 16]) {
+ c.save(); c.translate(ex, -8); c.scale(1, bl);
+ c.fillStyle = P.eye; c.beginPath(); c.ellipse(0, 0, 19, 23, 0, 0, Math.PI * 2); c.fill();
+ c.fillStyle = P.pupil; c.beginPath(); c.ellipse(-6 - look * 3, 2, 11, 16, 0, 0, Math.PI * 2); c.fill();
+ c.fillStyle = '#fff'; c.beginPath(); c.arc(-10 - look * 3, -5, 4.5, 0, Math.PI * 2); c.fill();
+ c.restore();
+ }
+ c.fillStyle = '#ff6f8a'; c.beginPath(); c.moveTo(-22, 18); c.lineTo(-6, 18); c.lineTo(-14, 28); c.closePath(); c.fill();
+ // 胡须
+ c.strokeStyle = 'rgba(255,255,255,.75)'; c.lineWidth = 3;
+ for (const k of [-1, 1]) { c.beginPath(); c.moveTo(-40, 26 + k * 6); c.lineTo(-104, 18 + k * 16 + Math.sin(ft * 3) * 2); c.stroke(); }
+ c.restore();
+ c.restore();
+};
+
+// ---------- 角色:机器人(AI) ----------
+// 原点 = 头部中心;返回眼睛中心(世界坐标)
+Y1.bot = (c, x, y, ft, { eye = C.bot.eye, eyeR = 34, look = 0, s = 1 } = {}) => {
+ const P = C.bot; c.save(); c.translate(x, y); c.scale(s, s); c.rotate(Math.sin(ft * 1.7) * 0.04);
+ // 喷射光
+ const jf = 1 + Math.sin(ft * 23) * 0.08 + Math.sin(ft * 37) * 0.05;
+ glow(c, 0, 128, 70 * jf, '#7df9ff', 0.55);
+ c.fillStyle = '#c9fbff'; c.beginPath(); c.moveTo(-22, 96); c.quadraticCurveTo(0, 96 + 70 * jf, 22, 96); c.closePath(); c.fill();
+ flat(c, (() => { const p = new Path2D(); p.roundRect(-46, 70, 92, 34, 14); return p; })(), '#d6d3fb', P.sh, P.hi, [6, 8], [2, 3]);
+ // 天线
+ c.strokeStyle = P.sh; c.lineWidth = 8; c.lineCap = 'round'; c.beginPath(); c.moveTo(0, -84); c.quadraticCurveTo(8, -120, 0 + Math.sin(ft * 3) * 6, -142); c.stroke();
+ const ab = 0.6 + 0.4 * Math.max(0, Math.sin(ft * 5));
+ glow(c, Math.sin(ft * 3) * 6, -148, 34, P.ant, 0.6 * ab); flat(c, circ(Math.sin(ft * 3) * 6, -148, 13), P.ant, '#d84a7b', '#ffc2d6', [3, 3], [1, 1]);
+ // 头壳
+ const shell = new Path2D(); shell.roundRect(-118, -88, 236, 176, 64);
+ flat(c, shell, P.shell, P.sh, P.hi, [16, 18], [6, 7]);
+ // 侧耳
+ for (const k of [-1, 1]) flat(c, (() => { const p = new Path2D(); p.roundRect(k * 118 - 14, -30, 28, 60, 12); return p; })(), '#d6d3fb', P.sh, P.hi, [4, 4], [2, 2]);
+ // 屏幕脸
+ const face = new Path2D(); face.roundRect(-88, -60, 176, 120, 44); c.fillStyle = P.face; c.fill(face);
+ c.save(); c.clip(face); c.fillStyle = 'rgba(255,255,255,.07)'; c.beginPath(); c.ellipse(-40, -50, 90, 30, -0.3, 0, Math.PI * 2); c.fill(); c.restore();
+ // 眼睛(镜头)
+ const ex = look * 14, ey = 0;
+ glow(c, ex, ey, eyeR * 2.6, eye, 0.55);
+ const g = c.createRadialGradient(ex - eyeR * 0.25, ey - eyeR * 0.25, 0, ex, ey, eyeR); g.addColorStop(0, '#ffffff'); g.addColorStop(0.35, eye); g.addColorStop(1, eye);
+ c.fillStyle = g; c.beginPath(); c.arc(ex, ey, eyeR, 0, Math.PI * 2); c.fill();
+ c.strokeStyle = 'rgba(255,255,255,.55)'; c.lineWidth = 3; c.beginPath(); c.arc(ex, ey, eyeR * 0.7, -2.4, -1.2); c.stroke();
+ c.restore();
+ const cs = Math.cos(Math.sin(ft * 1.7) * 0.04), sn = Math.sin(Math.sin(ft * 1.7) * 0.04);
+ return [x + (ex * cs - ey * sn) * s, y + (ex * sn + ey * cs) * s, eyeR * s];
+};
+
+// ---------- 小鸟(Kurzgesagt 的签名角色:圆身、大眼、三角喙) ----------
+Y1.bird = (c, x, y, ft, { s = 1, col = '#ff5d8f', sh = '#d63c70', face = 1, ph = 0 } = {}) => {
+ c.save(); c.translate(x, y); c.scale(face * s, s);
+ const fl = Math.sin((ft + ph) * 2 * Math.PI / 0.36);
+ const wing = poly([[-6, -6], [-30, -6 - 34 * fl], [-44, -2 - 30 * fl], [-14, 8]], false);
+ c.fillStyle = sh; c.fill(wing);
+ flat(c, ell(0, 0, 30, 24), col, sh, '#ffa3c2', [5, 5], [2, 2]);
+ c.fillStyle = '#fff1f5'; c.beginPath(); c.ellipse(6, 8, 18, 12, 0, 0, Math.PI * 2); c.fill();
+ c.fillStyle = '#ffb02e'; c.beginPath(); c.moveTo(26, -4); c.lineTo(44, 2); c.lineTo(26, 8); c.closePath(); c.fill();
+ c.fillStyle = '#fff'; c.beginPath(); c.arc(12, -6, 9, 0, Math.PI * 2); c.fill(); c.fillStyle = '#1d1640'; c.beginPath(); c.arc(15, -5, 5, 0, Math.PI * 2); c.fill();
+ c.fillStyle = col; c.beginPath(); c.moveTo(-26, -4); c.lineTo(-44, -12); c.lineTo(-40, 6); c.closePath(); c.fill();
+ c.restore();
+};
+
+// ---------- 镜 1:夜晚山坡 ----------
+const BOT1 = [700, 470];
+const s1cam = (ft) => {
+ // 慢推:0→2.6s 从 1.00 推到 1.10(sine 进出),中心略偏向机器人
+ const k = MO.sineInOut(seg(ft, 0, 2.6));
+ const cam = { x: lerp(960, 900, k), y: lerp(540, 520, k), z: lerp(1.0, 1.1, k) };
+ if (ft <= T1.a) return cam;
+ // 钻进镜头:0.9s 对数插值推进 1.1 → 60,眼睛中心平滑移到画面中心(缓动用 sineIn 偏 InOut:起步不拖,中段最快)
+ const e = K75(Math.pow(seg(ft, T1.a, T1.a + T1.d), 0.85));
+ const eye = Y1.eyeWorld(ft);
+ const k2 = MO.cubicOut(seg(ft, T1.a, T1.a + T1.d * 0.7)); // 眼睛移到画面中心比推进先完成
+ return { ...CAM.pushTo(cam, eye[0], eye[1], 60, e, k2), e };
+};
+Y1.botPos = (ft) => [BOT1[0] + Math.sin(ft * 1.9) * 6, BOT1[1] + Math.sin(ft * 2.4) * 12];
+Y1.eyeWorld = (ft) => { const [bx, by] = Y1.botPos(ft); const a = Math.sin(ft * 1.7) * 0.04; const ex = 0.6 * 14; return [bx + ex * Math.cos(a), by + ex * Math.sin(a), 34]; };
+// 转场 A 要的「镜头圆」:屏幕上的圆心与半径
+Y1.lensAt = (t) => { const ft = t - F0, cam = s1cam(ft), e = Y1.eyeWorld(ft), s = CAM.toScreen(cam, e[0], e[1]); return { x: s[0], y: s[1], r: e[2] * cam.z, e: cam.e || 0 }; };
+
+const STARS = (() => { const r = rng(11), o = []; for (let i = 0; i < 170; i++) o.push({ x: r() * 2400 - 240, y: r() * 760 - 80, r: 0.8 + r() * r() * 3.2, ph: r() * 6.28, sp: 1 + r() * 2.5 }); return o; })();
+const GRASS = (() => { const r = rng(12), o = []; for (let i = 0; i < 46; i++) o.push({ x: 820 + r() * 900, h: 18 + r() * 26, ph: r() * 6.28 }); return o; })();
+const MOTES = (() => { const r = rng(13), o = []; for (let i = 0; i < 26; i++) o.push({ x: r() * W, y: 300 + r() * 600, ph: r() * 6.28, d: 0.8 + r() * 0.5, s: 2 + r() * 3 }); return o; })();
+
+Y1.shot1 = (c, lt, t) => {
+ const ft = t - F0, P = C.night, cam = s1cam(ft);
+ c.fillStyle = vgrad(c, 0, H, P.sky); c.fillRect(0, 0, W, H);
+ // d=0.05 星空:闪烁
+ layer(c, cam, 0.05, g => { for (const s of STARS) { const a = 0.45 + 0.55 * (0.5 + 0.5 * Math.sin(ft * s.sp + s.ph)); g.globalAlpha = a; g.fillStyle = P.star; g.beginPath(); g.arc(s.x, s.y, s.r, 0, Math.PI * 2); g.fill(); } g.globalAlpha = 1; });
+ // d=0.12 月亮:光晕呼吸
+ layer(c, cam, 0.12, g => { glow(g, 1500, 230, 260 + Math.sin(ft * 1.2) * 12, '#ffd9a0', 0.22); flat(g, circ(1500, 230, 92), P.moon, P.moonSh, '#fff8ea', [-18, 14], [-6, 5]);
+ g.fillStyle = 'rgba(214,180,130,.45)'; for (const [x, y, r] of [[1470, 205, 16], [1528, 262, 11], [1520, 196, 7]]) { g.beginPath(); g.arc(x, y, r, 0, Math.PI * 2); g.fill(); } });
+ // d=0.3 远山
+ layer(c, cam, 0.3, g => { const p = poly([[-300, 760], [-80, 640], [200, 700], [520, 610], [860, 690], [1180, 600], [1520, 680], [1840, 620], [2200, 700], [2200, 1300], [-300, 1300]]); flat(g, p, P.hillFar, P.hillFar, P.hillFarHi, [0, -10], [0, 4]); });
+ // d=0.65 近坡
+ layer(c, cam, 0.65, g => { const p = poly([[-300, 900], [200, 840], [700, 820], [1100, 740], [1500, 760], [1900, 840], [2300, 900], [2300, 1400], [-300, 1400]]); flat(g, p, P.hill, P.hillSh, P.hillHi, [0, -14], [0, 5]); });
+ // d=1 主体:山顶小丘、草、猫、机器人与扫描光
+ layer(c, cam, 1, g => {
+ flat(g, poly([[860, 1200], [960, 860], [1180, 790], [1400, 810], [1620, 900], [1760, 1200]]), P.hill, P.hillSh, P.hillHi, [0, -12], [0, 5]);
+ // 草叶:填色的细三角(不用线条——线条会读成描边)
+ g.fillStyle = P.grass;
+ for (const q of GRASS) { const by = 806 + Math.pow((q.x - 1240) / 420, 2) * 70; const sw = Math.sin(ft * 2.1 + q.ph) * 6; g.beginPath(); g.moveTo(q.x - 5, by + 10); g.quadraticCurveTo(q.x + sw * 0.4, by - q.h * 0.5, q.x + sw, by - q.h); g.quadraticCurveTo(q.x + 2 + sw * 0.3, by - q.h * 0.4, q.x + 5, by + 10); g.closePath(); g.fill(); }
+ // 扫描光束:从眼睛扇形照到猫,扫描线上下扫
+ const [ex, ey] = Y1.eyeWorld(ft), cx = 1240, sy = 640 + Math.sin(ft * 3.2) * 110;
+ const beam = new Path2D(); beam.moveTo(ex, ey); beam.lineTo(cx + 40, 420); beam.lineTo(cx + 60, 830); beam.closePath();
+ const bg = g.createLinearGradient(ex, ey, cx, ey); bg.addColorStop(0, 'rgba(50,186,238,.45)'); bg.addColorStop(1, 'rgba(50,186,238,.06)');
+ g.fillStyle = bg; g.fill(beam);
+ Y1.cat(g, 1240, 810, ft, { s: 1.05, face: -1, look: 0.4 });
+ g.save(); g.clip(beam); g.strokeStyle = 'rgba(150,245,255,.9)'; g.lineWidth = 5; g.beginPath(); g.moveTo(1080, sy); g.lineTo(1420, sy); g.stroke(); glow(g, 1240, sy, 160, '#46e6ff', 0.18); g.restore();
+ const [bx, by] = Y1.botPos(ft); Y1.bot(g, bx, by, ft, { look: 0.6 });
+ });
+ // d=0.9–1.3 萤火微粒
+ for (const m of MOTES) layer(c, cam, m.d, g => { const x = m.x + Math.sin(ft * 0.8 + m.ph) * 30, y = m.y - ((ft * 22 + m.ph * 40) % 120); g.globalAlpha = 0.5 + 0.5 * Math.sin(ft * 2 + m.ph); glow(g, x, y, m.s * 5, '#ffe9a8', 0.5); g.fillStyle = '#fff6d0'; g.beginPath(); g.arc(x, y, m.s, 0, Math.PI * 2); g.fill(); g.globalAlpha = 1; });
+ // d=1.5 前景叶片剪影(近景最快,景深靠它)
+ // 前景叶片:虚焦(景深),实测 2025 片大量用前景虚化
+ layer(c, cam, 1.5, g => { const sw = Math.sin(ft * 1.4) * 0.05; g.filter = 'blur(7px)';
+ const leaf = (x, y, a, L, w) => { g.save(); g.translate(x, y); g.rotate(a); const p = poly([[0, 0], [w, -L * 0.35], [w * 0.7, -L * 0.75], [0, -L], [-w * 0.7, -L * 0.75], [-w, -L * 0.35]]);
+ flat(g, p, P.fg, '#0a0824', '#241e5a', [8, 0], [3, 0]); g.strokeStyle = '#241e5a'; g.lineWidth = 4; g.beginPath(); g.moveTo(0, -10); g.lineTo(0, -L * 0.9); g.stroke(); g.restore(); };
+ leaf(-30, 1130, -0.75 + sw, 380, 90); leaf(60, 1150, -0.25 + sw * 1.3, 300, 70); leaf(1960, 1150, 0.6 - sw, 400, 95); g.filter = 'none'; });
+ // 标题:逐字上浮(0.25s 起,每字错开 45ms,单字 0.5s cubicOut),钻镜头前淡出
+ const out = 1 - MO.sineInOut(seg(ft, 1.95, 2.5)); // 0.55s 淡出,别一帧消失
+ if (out > 0) { c.save(); c.globalAlpha = out;
+ TY.charsIn(c, 'AI 是怎么学会认猫的?', W / 2, 150, ft - 0.25, { font: '76px "PuHui-Heavy"', color: '#ffffff', dur: 0.5, stagger: 0.045, dy: 30, align: 'center', shadow: { color: 'rgba(10,8,40,.45)', y: 6, blur: 0 } });
+ c.restore(); }
+};
+
+// ---------- 镜 2:机器脑内 ----------
+const PIX = [
+ '..O......O..', '.OOO....OOO.', '.OPOOOOOOPO.', '.OOOOOOOOOO.', 'OOWWOOOOWWOO', 'OOWKOOOOWKOO',
+ 'OOOOOOOOOOOO', 'OOOOCPPCOOOO', 'OOOCCCCCCOOO', '.OOOCCCCOOO.', '..OOOOOOOO..', '....OOOO....'];
+const PCOL = { O: '#F48301', P: '#C83C7F', W: '#ffffff', K: '#0E0631', C: '#ffe0b5' };
+const LAYERS = [{ x: 860, n: 4, label: '边缘' }, { x: 1120, n: 5, label: '形状' }, { x: 1370, n: 3, label: '部件' }, { x: 1600, n: 1, label: '猫', out: true }];
+LAYERS.forEach((L, i) => { L.ys = []; for (let k = 0; k < L.n; k++) L.ys.push(L.n === 1 ? 520 : 520 + (k - (L.n - 1) / 2) * (L.n > 4 ? 118 : 140)); L.i = i; });
+const OUT = [1600, 520, 50];
+const pulseT = 1.0; // 信号从像素出发的时刻(镜内时间)
+const layerHit = i => pulseT + 0.32 * (i + 1); // 第 i 层被点亮的时刻
+Y1.outNode = OUT;
+const s2cam = (ft) => {
+ const lt = ft - Y1.SHOTS.s2[0];
+ // 从镜头里浮出:0→0.9s z 0.42→1.0(expoOut),之后极慢漂移推进
+ const k = MO.expoOut(seg(lt, 0, 1.2));
+ let cam = { x: lerp(1020, 1000, k) + lt * 12, y: 540, z: CAM.zlerp(0.42, 1.0, k) * (1 + 0.012 * lt) };
+ if (ft <= T2.a) return cam;
+ // 推进输出节点直到满屏(0.45s,cubicIn)
+ const e = MO.cubicIn(seg(ft, T2.a, T2.a + T2.d * 0.5));
+ return CAM.pushTo(cam, OUT[0], OUT[1], 26, e);
+};
+const DUST = (() => { const r = rng(21), o = []; for (let i = 0; i < 90; i++) o.push({ x: r() * 2600 - 340, y: r() * 1500 - 210, r: 1 + r() * 2.5, d: 0.3 + r() * 0.5, ph: r() * 6.28 }); return o; })();
+const nodeIcon = (g, li, k, x, y, a) => {
+ g.save(); g.globalAlpha = a; g.strokeStyle = '#e8f6ff'; g.fillStyle = '#e8f6ff'; g.lineWidth = 5; g.lineCap = 'round'; g.lineJoin = 'round';
+ if (li === 0) { const ang = [0, Math.PI / 2, Math.PI / 4, -Math.PI / 4][k]; g.beginPath(); g.moveTo(x - Math.cos(ang) * 16, y - Math.sin(ang) * 16); g.lineTo(x + Math.cos(ang) * 16, y + Math.sin(ang) * 16); g.stroke(); }
+ if (li === 1) { g.beginPath(); if (k === 0 || k === 4) { g.moveTo(x - 14, y + 10); g.lineTo(x, y - 14); g.lineTo(x + 14, y + 10); g.closePath(); } else if (k === 1) { g.ellipse(x, y, 10, 14, 0, 0, Math.PI * 2); } else if (k === 2) { g.moveTo(x - 16, y - 6); g.lineTo(x + 16, y - 10); g.moveTo(x - 16, y + 6); g.lineTo(x + 16, y + 8); } else { g.arc(x, y, 13, 0.2, Math.PI - 0.2); } g.stroke(); }
+ if (li === 2) { g.beginPath(); if (k === 0) { g.moveTo(x - 18, y + 8); g.lineTo(x - 10, y - 14); g.lineTo(x - 2, y + 2); g.moveTo(x + 2, y + 2); g.lineTo(x + 10, y - 14); g.lineTo(x + 18, y + 8); } else if (k === 1) { g.ellipse(x - 9, y, 6, 9, 0, 0, Math.PI * 2); g.moveTo(x + 15, y); g.ellipse(x + 9, y, 6, 9, 0, 0, Math.PI * 2); } else { g.moveTo(x - 6, y - 4); g.lineTo(x + 6, y - 4); g.lineTo(x, y + 4); g.closePath(); g.moveTo(x - 20, y + 2); g.lineTo(x - 8, y + 4); g.moveTo(x + 8, y + 4); g.lineTo(x + 20, y + 2); } g.stroke(); }
+ g.restore();
+};
+Y1.shot2 = (c, lt, t) => {
+ const ft = t - F0, P = C.mind, cam = s2cam(ft), l = ft - Y1.SHOTS.s2[0];
+ c.fillStyle = vgrad(c, 0, H, P.bg); c.fillRect(0, 0, W, H);
+ // 远景:点阵网格+漂浮尘埃(视差)
+ layer(c, cam, 0.35, g => { g.fillStyle = P.grid; for (let y = -400; y < 1500; y += 60) for (let x = -600; x < 2600; x += 60) { g.beginPath(); g.arc(x, y, 2.4, 0, Math.PI * 2); g.fill(); } });
+ for (const d of DUST) layer(c, cam, d.d, g => { g.globalAlpha = 0.35 + 0.35 * Math.sin(ft * 1.5 + d.ph); g.fillStyle = '#8fb0ff'; g.beginPath(); g.arc(d.x + Math.sin(ft * 0.6 + d.ph) * 20, d.y + Math.cos(ft * 0.5 + d.ph) * 14, d.r, 0, Math.PI * 2); g.fill(); g.globalAlpha = 1; });
+ layer(c, cam, 1, g => {
+ // 像素猫:144 块从四周飞入就位(每块 0.5s backOut,按到中心的距离错开),之后整体轻微呼吸
+ const cell = 30, gx = 400 - 6 * cell, gy = 520 - 6 * cell, r = rng(31);
+ for (let j = 0; j < 12; j++) for (let i = 0; i < 12; i++) {
+ const ch = PIX[j][i], fx = r() * 2 - 1, fy = r() * 2 - 1; if (ch === '.') continue;
+ const dl = 0.05 + Math.hypot(i - 5.5, j - 5.5) * 0.035, q = clamp((l - dl) / 0.5), e = MO.backOut(q, 1.4);
+ const x = gx + i * cell + (1 - e) * fx * 260, y = gy + j * cell + (1 - e) * fy * 260, s = (cell - 4) * (0.3 + 0.7 * e) * (1 + 0.04 * Math.sin(ft * 3 + i * 0.5 + j * 0.3));
+ g.globalAlpha = clamp(q * 3); g.fillStyle = PCOL[ch]; g.beginPath(); g.roundRect(x + (cell - s) / 2, y + (cell - s) / 2, s, s, 5); g.fill();
+ }
+ g.globalAlpha = 1;
+ // 连线:像素 → 第一层 → … 全连接
+ const cols = [{ x: 600, ys: [380, 470, 570, 660] }, ...LAYERS];
+ g.lineWidth = 2.5;
+ for (let a = 0; a < cols.length - 1; a++) for (const y0 of cols[a].ys) for (const y1 of cols[a + 1].ys) {
+ const lit = clamp((l - layerHit(a) + 0.1) / 0.3);
+ g.strokeStyle = lit > 0 ? `rgba(${lerp(110, 120, lit) | 0},${lerp(140, 230, lit) | 0},255,${0.22 + 0.25 * lit})` : P.line;
+ g.beginPath(); g.moveTo(cols[a].x, y0); g.lineTo(cols[a + 1].x, y1); g.stroke();
+ }
+ // 信号脉冲:沿每条连线跑,0.32s 跑完一层;之后循环流动(持续的「思考」)
+ for (let a = 0; a < cols.length - 1; a++) {
+ const rr = rng(40 + a);
+ for (const y0 of cols[a].ys) for (const y1 of cols[a + 1].ys) {
+ if (rr() < 0.45) continue;
+ const start = pulseT + 0.32 * a, ph = rr() * 0.3;
+ let q = (l - start - ph * 0.3) / 0.32; if (q < 0) continue; if (q > 1) q = ((l - start) * 1.6 + ph) % 1;
+ const x = lerp(cols[a].x, cols[a + 1].x, q), y = lerp(y0, y1, q);
+ glow(g, x, y, 22, P.pulse, 0.6); g.fillStyle = '#e9fdff'; g.beginPath(); g.arc(x, y, 5, 0, Math.PI * 2); g.fill();
+ }
+ }
+ // 节点:被信号点亮时弹一下(backOut 0.35s)+显示该层学到的特征图标
+ for (const L of LAYERS) L.ys.forEach((y, k) => {
+ const hit = layerHit(L.i) + k * 0.04, q = clamp((l - hit) / 0.35), pop = q > 0 ? 1 + 0.25 * Math.sin(Math.PI * clamp(q * 1.2)) : 1;
+ const r = (L.out ? OUT[2] : 34) * pop * (1 + 0.03 * Math.sin(ft * 4 + k));
+ if (L.out) {
+ if (q > 0) glow(g, L.x, y, r * (3.2 + 0.4 * Math.sin(ft * 5)), P.hot, 0.55 * q);
+ const gg = g.createRadialGradient(L.x - r * 0.3, y - r * 0.3, 0, L.x, y, r); gg.addColorStop(0, q > 0 ? '#fff6c8' : P.nodeHi); gg.addColorStop(1, q > 0 ? P.hot : P.node);
+ g.fillStyle = gg; g.beginPath(); g.arc(L.x, y, r, 0, Math.PI * 2); g.fill();
+ } else {
+ if (q > 0) glow(g, L.x, y, r * 2.4, P.pulse, 0.32 * q);
+ flat(g, circ(L.x, y, r), q > 0 ? '#3e6fd8' : P.node, q > 0 ? '#2b4fb0' : '#1c275a', q > 0 ? '#7fb2ff' : P.nodeHi, [-6, -6], [-2, -2]);
+ if (q > 0) nodeIcon(g, L.i, k, L.x, y, q);
+ }
+ });
+ // 层标签:逐个出现(文字是从下往上浮 + 短下划线伸出)
+ const labs = [{ x: 400, s: '像素' }, ...LAYERS.map(L => ({ x: L.x, s: L.label }))];
+ labs.forEach((L, i) => { const t0 = 0.55 + (i ? layerHit(i - 1) - 0.55 + 0.1 : 0); const q = MO.cubicOut(seg(l, t0, t0 + 0.45));
+ if (q <= 0) return; TY.charsIn(g, L.s, L.x, 880, l - t0, { font: '40px "PuHui-Medium"', color: i === 4 ? P.hot : P.label, dur: 0.4, stagger: 0.06, dy: 18, align: 'center' });
+ g.strokeStyle = i === 4 ? P.hot : P.label; g.lineWidth = 4; g.lineCap = 'round'; g.beginPath(); g.moveTo(L.x - 34 * q, 904); g.lineTo(L.x + 34 * q, 904); g.stroke(); });
+ // 箭头:标签之间
+ g.fillStyle = 'rgba(169,188,255,.55)'; for (let i = 0; i < 4; i++) { const xa = [400, ...LAYERS.map(L => L.x)]; const q = seg(l, 0.6 + (i ? layerHit(i - 1) - 0.5 : 0.2), 1.0 + (i ? layerHit(i - 1) - 0.5 : 0.2)); if (q <= 0) continue; const mx = (xa[i] + xa[i + 1]) / 2; g.globalAlpha = q; g.beginPath(); g.moveTo(mx - 10, 868); g.lineTo(mx + 10, 878); g.lineTo(mx - 10, 888); g.closePath(); g.fill(); }
+ g.globalAlpha = 1;
+ });
+};
+
+// ---------- 镜 3:白天草坡 ----------
+const BOT3 = [1010, 400];
+Y1.bot3Pos = (ft) => [BOT3[0] + Math.sin(ft * 1.9) * 6, BOT3[1] + Math.sin(ft * 2.4) * 10];
+const s3cam = (ft) => {
+ const l = ft - Y1.SHOTS.s3[0];
+ const [bx, by] = Y1.bot3Pos(ft); const eye = [bx, by]; // look=0 时眼睛在头中心
+ // 0–0.45s 停在满屏黄色的眼睛里;0.45→1.9s 对数插值拉远 42→1.0。
+ // 用 cubicInOut 而不是 expoOut:expoOut 起步斜率太大,第一帧就从 42 倍跳到 15 倍(qa 量到 9 帧跳变);实测 Kurzgesagt 穿越是先加速后减速、峰值在中段
+ const e = MO.cubicInOut(seg(l, 0.45, 1.9));
+ const z = CAM.zlerp(42, 1.0, e) * (1 + 0.04 * Math.max(0, l - 1.9)); // 落定后 4%/s 慢推(实测待机推 3–4.5%/s)
+ const final = { x: 960, y: 540 };
+ const s0 = [W / 2, H / 2], s1 = CAM.toScreen({ ...final, z: 1 }, eye[0], eye[1]);
+ return CAM.anchor(eye[0], eye[1], z, lerp(s0[0], s1[0], e), lerp(s0[1], s1[1], e));
+};
+const CLOUDS = [[300, 230, 1.0], [880, 150, 0.7], [1480, 260, 1.15], [2100, 180, 0.8]];
+const TREES = [[180, 760, 1], [330, 790, 0.7], [1580, 770, 0.9], [1760, 790, 1.2]];
+const cloud = (g, x, y, s) => { const p = new Path2D(); for (const [dx, dy, r] of [[-70, 10, 50], [-20, -18, 66], [50, -4, 56], [100, 16, 40], [0, 22, 46]]) p.arc(x + dx * s, y + dy * s, r * s, 0, Math.PI * 2); flat(g, p, C.day.cloud, C.day.cloudSh, '#ffffff', [0, -10 * s], [0, 4]); };
+Y1.shot3 = (c, lt, t) => {
+ const ft = t - F0, P = C.day, cam = s3cam(ft), l = ft - Y1.SHOTS.s3[0];
+ c.fillStyle = vgrad(c, 0, H, P.sky); c.fillRect(0, 0, W, H);
+ layer(c, cam, 0.08, g => { glow(g, 1640, 170, 300, '#fff6c0', 0.55); g.fillStyle = P.sun; g.beginPath(); g.arc(1640, 170, 80 + Math.sin(ft * 2) * 3, 0, Math.PI * 2); g.fill(); });
+ layer(c, cam, 0.2, g => { for (const [x, y, s] of CLOUDS) cloud(g, ((x + ft * 26) % 2600) - 340, y, s); });
+ layer(c, cam, 0.35, g => flat(g, poly([[-300, 760], [100, 650], [520, 700], [900, 620], [1300, 690], [1700, 610], [2200, 700], [2200, 1300], [-300, 1300]]), P.hillFar, '#86c45c', '#b4e889', [0, -10], [0, 4]));
+ layer(c, cam, 0.6, g => { flat(g, poly([[-300, 820], [300, 760], [900, 800], [1500, 740], [2200, 820], [2200, 1300], [-300, 1300]]), P.hillMid, '#58a63e', '#8fd468', [0, -12], [0, 4]);
+ for (const [x, y, s] of TREES) { g.fillStyle = P.trunk; g.fillRect(x - 8 * s, y - 60 * s, 16 * s, 70 * s); const sw = Math.sin(ft * 1.6 + x) * 4; flat(g, circ(x + sw, y - 100 * s, 62 * s), P.tree, '#23753a', P.treeHi, [-12 * s, -10 * s], [-4, -4]); } });
+ // 鸟:两只从左飞到右(Kurzgesagt 的签名彩蛋)
+ layer(c, cam, 0.75, g => { Y1.bird(g, -200 + ft * 150, 175 + Math.sin(ft * 3) * 14, ft, { s: 0.9, col: '#ff5d8f', sh: '#d63c70' }); Y1.bird(g, -420 + ft * 165, 225 + Math.sin(ft * 3 + 1) * 12, ft, { s: 0.7, col: '#ffb02e', sh: '#e08a10', ph: 0.15 }); });
+ layer(c, cam, 1, g => {
+ flat(g, poly([[-300, 900], [400, 860], [1000, 880], [1600, 850], [2300, 900], [2300, 1400], [-300, 1400]]), P.ground, '#3d8f33', P.groundHi, [0, -14], [0, 5]);
+ // 花叔:指向黑猫(point 姿势+手臂与头的小幅持续摆动,嘴在说话)
+ if (HERO.y1(g, ft) === false) { // 形象方向见 lib/hero.js
+ const HSb = HUASHU.build({ x: 470, y: 900 + Math.sin(ft * 3.2) * 2, s: 0.66, face: 1, pose: HUASHU.pose('point', 0, { ua1: 1.38 + 0.07 * Math.sin(ft * 3.4), fa1: 0.05 + 0.05 * Math.sin(ft * 3.4 + 1), head: -0.04 + 0.03 * Math.sin(ft * 2.1), mouth: 0.45 + 0.4 * Math.max(0, Math.sin(ft * 9)) }) });
+ const pal = { skin: '#ffd3b4', hair: '#1f1a3a', shirt: '#ffffff', shorts: '#d9c9a8', hat: '#ffffff', hatBand: '#d8d4f2', shoe: '#f4f2ff', watch: '#2a2550' };
+ const shade = { skin: '#f0a98a', hair: '#120f26', shirt: '#cfcbee', shorts: '#b39f7c', hat: '#d3cff0', hatBand: '#b6b0e0', shoe: '#c9c5ea', watch: '#14112b' };
+ for (const p of HSb.parts) flat(g, p.path, pal[p.role] || pal.skin, shade[p.role] || shade.skin, '#ffffff', [-10, -8], [-4, -3]);
+ HUASHU.details(g, HSb, { line: '#1f1a3a', lw: 3.5, glass: '#1f1a3a', cheek: 'rgba(255,120,120,.35)', earLine: 'rgba(200,110,90,.7)', shoeHole: '#8a86b8' });
+ }
+ // 认识的那只橙猫蹲在花叔脚边;镜头要认的是一只「没见过的」黑猫
+ Y1.cat(g, 790, 905, ft + 0.3, { s: 0.55, face: -1, look: 0.5 });
+ Y1.cat(g, 1420, 880, ft + 0.7, { s: 0.85, face: -1, pal: { fur: '#3a3550', sh: '#24203a', hi: '#5a5478', belly: '#4a4566', ear: '#ff8fa3', eye: '#d9ff6b', pupil: '#16132a' }, look: 0.2 });
+ // 扫描光与机器人
+ const [bx, by] = Y1.bot3Pos(ft);
+ const bq = MO.cubicOut(seg(l, 1.5, 1.85));
+ if (bq > 0) { const beam = new Path2D(); beam.moveTo(bx, by); beam.lineTo(1300, 660); beam.lineTo(1540, 660); beam.closePath(); g.save(); g.globalAlpha = bq; const bg = g.createLinearGradient(bx, by, 1420, 760); bg.addColorStop(0, 'rgba(255,210,63,.55)'); bg.addColorStop(1, 'rgba(255,210,63,.08)'); g.fillStyle = bg; g.fill(beam); g.restore(); }
+ Y1.bot(g, bx, by, ft, { eye: C.bot.eyeHot, eyeR: 30, look: 0 });
+ // 小字:一只没见过的猫(引线先画出,再逐字打出,实测标注≈40 字/秒)
+ const cq = seg(l, 1.0, 1.25), cout = 1 - seg(l, 1.65, 1.8);
+ if (cq > 0 && cout > 0) { g.save(); g.globalAlpha = cout; g.strokeStyle = '#ffffff'; g.lineWidth = 3; g.beginPath(); g.moveTo(1500, 700); g.lineTo(1500 + 80 * cq, 640 - 40 * cq); g.lineTo(1500 + 80 * cq + 120 * clamp(cq * 2 - 1), 600); g.stroke();
+ const str = '没见过的猫', n = Math.floor((l - 1.2) * 25); // 中文按 25 字/秒打出
+ g.fillStyle = '#ffffff'; g.font = '34px "PuHui-Medium"'; g.textBaseline = 'alphabetic'; g.fillText([...str].slice(0, Math.min(5, Math.max(0, n))).join(''), 1590, 590); g.restore(); }
+ // 识别标签:从猫头上方弹出,之后轻轻上下浮
+ const q = seg(l, 1.75, 2.25); if (q > 0) {
+ // 实测卡片弹出 ≈0.5s、过冲到 108% 回 100%
+ const e = MO.backOut(q, 1.1), y = 560 + Math.sin(ft * 2.5) * 6;
+ g.save(); g.translate(1420, y); g.scale(e, e);
+ g.fillStyle = 'rgba(20,40,20,.18)'; g.beginPath(); g.roundRect(-122, -40, 252, 92, 46); g.fill();
+ g.fillStyle = '#ffffff'; g.beginPath(); g.roundRect(-130, -50, 252, 92, 46); g.fill();
+ g.beginPath(); g.moveTo(-14, 40); g.lineTo(0, 64); g.lineTo(14, 40); g.fill();
+ g.fillStyle = '#2fbf71'; g.beginPath(); g.arc(-80, -4, 30, 0, Math.PI * 2); g.fill();
+ g.strokeStyle = '#fff'; g.lineWidth = 8; g.lineCap = 'round'; g.lineJoin = 'round'; g.beginPath(); g.moveTo(-94, -4); g.lineTo(-84, 8); g.lineTo(-64, -16); g.stroke();
+ g.fillStyle = '#1f1a3a'; g.font = '52px "PuHui-Heavy"'; g.textBaseline = 'middle'; g.fillText('猫', -36, -2);
+ g.font = '34px "PuHui-Medium"'; g.fillStyle = '#2fbf71'; g.fillText('98%', 26, 0);
+ g.restore();
+ }
+ });
+};
+})();
+
+SCENES['y1_s1'] = { draw: (c, lt, t) => Y1.shot1(c, lt, t) };
+SCENES['y1_s2'] = { draw: (c, lt, t) => Y1.shot2(c, lt, t) };
+SCENES['y1_s3'] = { draw: (c, lt, t) => Y1.shot3(c, lt, t) };
diff --git a/scripts/engine/demos/y2_vox/eras.js b/scripts/engine/demos/y2_vox/eras.js
new file mode 100644
index 0000000..b0d34b5
--- /dev/null
+++ b/scripts/engine/demos/y2_vox/eras.js
@@ -0,0 +1,10 @@
+// 示范 · Vox 式拼贴解说「AI 是怎么学会认猫的」(8 秒三镜)。语法卡:references/动画语法/y2_vox.md
+// 预览 index.html?film=demos/y2_vox 渲染 render.py --film demos/y2_vox --out y2.mp4
+// 一张大桌面=世界;相机 60fps 平滑推移,桌上的纸片/荧光笔/红笔/打字按 12fps 步进。
+window.PUNCH = 0;
+window.SCENE_LIBS = ['demos/_shared/hero.js', 'demos/y2_vox/vox.js'];
+window.ERAS = [
+ { id: 'y2_s1', dur: 2.6 }, // 剪报+网点照片:荧光笔扫行、红笔圈词、相机慢推
+ { id: 'y2_s2', dur: 3.3, transition: { type: 'same', dur: 1.1 } }, // 沿红线平移到调查墙(同一桌面,相机连续走)
+ { id: 'y2_s3', dur: 2.1, transition: { type: 'cut', dur: 1 / 60 } }, // 推满小照片 → 硬切到同一张图的大幅扫描,再拉出揭示黑底拼贴
+];
diff --git a/scripts/engine/demos/y2_vox/vox.js b/scripts/engine/demos/y2_vox/vox.js
new file mode 100644
index 0000000..b7effb1
--- /dev/null
+++ b/scripts/engine/demos/y2_vox/vox.js
@@ -0,0 +1,240 @@
+// Y2 · Vox 式拼贴解说(Missing Chapter / Borders 一路):「AI 是怎么学会认猫的」
+// 一张大桌面(世界坐标),相机 60fps 平滑地推、移;桌上的元素(荧光笔、红笔、打字、红线、贴纸)按 12fps「一拍二」步进。
+// 依据:调研/y2_vox/调研.md(13 段相机运动实测:中位 1.29s,对称 easeInOutSine 或长尾 bezier(.33,0,.2,1),没有线性;元素层 12fps)
+// ①剪报+网点照片已在桌上(随切点直接出现),荧光笔按行扫、红笔圈词、相机慢推向那一行
+// → 转场 A「沿红线平移」:一条红线从剪报连到调查墙,相机沿线 1.1s 追过去(长尾 bezier)
+// ②调查墙:1000 万张截图里的猫被红线连到索引卡,打字机 13 字/秒,计数滚到 10,000,000,一张小照片带倾斜滑入放平
+// → 转场 B「推进照片→硬切」:相机推满那张小照片,硬切成同一张图的大幅扫描,再「拉出揭示」整张黑底拼贴
+// ③黑底:它脑中的「猫」、纸条标题打字+荧光笔、花叔剪纸贴纸滑入、红笔圈住
+// 用到的库:CL(纸纹、撕边、网点照片、胶带、图钉、红线、毛边荧光笔、倾斜滑入、贴纸白边)、CAM(关键帧相机、推进锚点、运动模糊)、
+// DG(手画圈、逐段描出)、TY.typedCount(打字机)、MO(longTail、12fps 步进)。
+(() => {
+const W = 1920, H = 1080;
+const { clamp, lerp, rng } = U;
+const seg = MO.seg, step = MO.step;
+const Y2 = window.Y2 = {};
+const F0 = 0; Y2.F0 = F0;
+Y2.SHOTS = { s1: [0, 2.6], s2: [2.6, 5.9], s3: [5.9, 8.0] };
+const PAN = { a: 2.6, d: 1.1 }, PUSH = { a: 5.3, b: 5.9 };
+const longTail = MO.longTail; // 「沿线追过去」「拉出揭示」用:起步快、长尾落定
+
+// 调研实测色(MC/BD/PSY 取色)
+const C = { desk: '#e4ddcf', news: '#eeedeb', ink: '#171716', red: '#b8433f', hl: '#dacf08', black: '#171716', paper: '#eeedeb', tape: 'rgba(226,220,200,.85)', card: '#f6f4ee' };
+const SERIF = '"Songti SC", "STSong", serif';
+
+// ---------- 素材(一次画好缓存) ----------
+const sprite = (key, w, h, fn) => PAINT.cached('y2_' + key, w, h, fn);
+const tornPoly = CL.tornRect;
+const catPhoto = (g, w, h, { dark = false, pose = 0 } = {}) => {
+ const bg = g.createLinearGradient(0, 0, w, h); bg.addColorStop(0, dark ? '#555' : '#bdbdbd'); bg.addColorStop(1, dark ? '#2a2a2a' : '#8a8a8a'); g.fillStyle = bg; g.fillRect(0, 0, w, h);
+ const cx = w * (0.5 + pose * 0.08), cy = h * 0.56, s = Math.min(w, h) / 300;
+ g.save(); g.translate(cx, cy); g.scale(s, s);
+ g.fillStyle = dark ? '#d9d9d9' : '#3a3a3a';
+ g.beginPath(); g.ellipse(0, 120, 120, 90, 0, 0, Math.PI * 2); g.fill();
+ g.beginPath(); g.ellipse(0, 0, 92, 78, 0, 0, Math.PI * 2); g.fill();
+ g.beginPath(); g.moveTo(-80, -30); g.lineTo(-70, -118); g.lineTo(-20, -66); g.fill(); g.beginPath(); g.moveTo(80, -30); g.lineTo(70, -118); g.lineTo(20, -66); g.fill();
+ const fg = g.createRadialGradient(0, 20, 5, 0, 20, 70); fg.addColorStop(0, dark ? '#fff' : '#9a9a9a'); fg.addColorStop(1, 'rgba(0,0,0,0)'); g.fillStyle = fg; g.beginPath(); g.ellipse(0, 22, 60, 46, 0, 0, Math.PI * 2); g.fill();
+ g.fillStyle = '#f2f2f2'; for (const ex of [-34, 34]) { g.beginPath(); g.ellipse(ex, -6, 17, 13, 0, 0, Math.PI * 2); g.fill(); }
+ g.fillStyle = '#111'; for (const ex of [-34, 34]) { g.beginPath(); g.ellipse(ex, -6, 5, 12, 0, 0, Math.PI * 2); g.fill(); }
+ g.fillStyle = '#222'; g.beginPath(); g.moveTo(-9, 22); g.lineTo(9, 22); g.lineTo(0, 32); g.fill();
+ g.strokeStyle = 'rgba(240,240,240,.7)'; g.lineWidth = 2.5; for (const k of [-1, 1]) for (const d of [-6, 6]) { g.beginPath(); g.moveTo(k * 30, 34 + d); g.lineTo(k * 110, 26 + d * 2.4); g.stroke(); }
+ g.restore();
+};
+const thumbScene = (g, w, h, kind, seed) => {
+ const r = rng(seed); const bg = g.createLinearGradient(0, 0, 0, h); const L = 120 + r() * 80; bg.addColorStop(0, `rgb(${L},${L},${L})`); bg.addColorStop(1, `rgb(${L - 50},${L - 50},${L - 50})`); g.fillStyle = bg; g.fillRect(0, 0, w, h);
+ g.fillStyle = r() < 0.5 ? '#2c2c2c' : '#e8e8e8';
+ if (kind === 'cat') return catPhoto(g, w, h, { dark: r() < 0.4, pose: r() - 0.5 });
+ g.save(); g.translate(w / 2, h * 0.6); const s = h / 90; g.scale(s, s);
+ if (kind === 'dog') { g.beginPath(); g.ellipse(0, 6, 34, 18, 0, 0, Math.PI * 2); g.fill(); g.beginPath(); g.ellipse(-30, -14, 14, 12, 0, 0, Math.PI * 2); g.fill(); g.beginPath(); g.ellipse(-40, -8, 6, 12, 0.3, 0, Math.PI * 2); g.fill(); g.fillRect(-26, 14, 6, 16); g.fillRect(18, 14, 6, 16); }
+ if (kind === 'car') { g.beginPath(); g.roundRect(-44, -4, 88, 22, 6); g.fill(); g.beginPath(); g.roundRect(-24, -22, 46, 22, 8); g.fill(); g.fillStyle = '#111'; g.beginPath(); g.arc(-26, 20, 9, 0, 7); g.arc(26, 20, 9, 0, 7); g.fill(); }
+ if (kind === 'man') { g.beginPath(); g.arc(0, -26, 13, 0, 7); g.fill(); g.beginPath(); g.roundRect(-20, -10, 40, 44, 10); g.fill(); }
+ if (kind === 'tree') { g.fillRect(-5, -4, 10, 34); g.beginPath(); g.arc(0, -20, 26, 0, 7); g.fill(); }
+ if (kind === 'house') { g.fillRect(-28, -8, 56, 36); g.beginPath(); g.moveTo(-36, -8); g.lineTo(0, -38); g.lineTo(36, -8); g.fill(); }
+ if (kind === 'game') { g.beginPath(); g.roundRect(-36, -14, 72, 34, 16); g.fill(); }
+ g.restore();
+ g.fillStyle = 'rgba(0,0,0,.45)'; g.fillRect(0, h - 8, w, 8); g.fillStyle = '#b8433f'; g.fillRect(0, h - 8, w * (0.2 + r() * 0.6), 8); // 播放条(只用形状,不放台标)
+};
+const photoSprite = CL.photo; // 网点照片+纸边(halftone 6px、对比 1.3)
+// 「猫神经元」的最优刺激图(论文 Fig.6 那种模糊猫脸),用大块柔光画,过网点
+const neuronDraw = (g, w, h) => {
+ g.fillStyle = '#7b7b7b'; g.fillRect(0, 0, w, h); const k = w / 560;
+ const blob = (x, y, rx, ry, col) => { g.save(); g.filter = `blur(${26 * k}px)`; g.fillStyle = col; g.beginPath(); g.ellipse(x * w, y * h, rx * k, ry * k, 0, 0, Math.PI * 2); g.fill(); g.restore(); };
+ blob(0.5, 0.56, 190, 160, '#3b3b3b'); blob(0.28, 0.25, 60, 90, '#3a3a3a'); blob(0.72, 0.25, 60, 90, '#3a3a3a');
+ blob(0.5, 0.68, 110, 70, '#c9c9c9'); blob(0.36, 0.5, 34, 26, '#e6e6e6'); blob(0.64, 0.5, 34, 26, '#e6e6e6');
+ blob(0.36, 0.5, 12, 18, '#111'); blob(0.64, 0.5, 12, 18, '#111'); blob(0.5, 0.64, 16, 10, '#222');
+};
+// 剪报(数字出自 Le et al. 2012 论文摘要与 Google 官方博客:1000 台机器、1.6 万个 CPU 核、1000 万张 YouTube 截图、不打标签)
+const NEWS = { w: 860, h: 600, hl: { x: 52, y: 352, w: 590, h: 48 }, circ: { x: 450, y: 226, rx: 96, ry: 50 } };
+const newsSprite = () => sprite('news', NEWS.w, NEWS.h, (g) => {
+ const tile = CL.paperTile('news', C.news, { amt: 9, fibers: 160 });
+ g.save(); tornPoly(g, NEWS.w, NEWS.h, 21, 4); g.clip(); g.fillStyle = g.createPattern(tile, 'repeat'); g.fillRect(0, 0, NEWS.w, NEWS.h);
+ const yel = g.createRadialGradient(NEWS.w * 0.4, NEWS.h * 0.4, 50, NEWS.w * 0.5, NEWS.h * 0.5, NEWS.w * 0.75); yel.addColorStop(0, 'rgba(255,255,255,0)'); yel.addColorStop(1, 'rgba(170,150,110,.2)'); g.fillStyle = yel; g.fillRect(0, 0, NEWS.w, NEWS.h);
+ g.fillStyle = C.ink; g.font = `600 22px ${SERIF}`; g.fillText('科技 · 2012 年 6 月', 52, 64);
+ g.fillRect(52, 80, NEWS.w - 104, 3); g.fillRect(52, 86, NEWS.w - 104, 1);
+ g.font = `900 66px ${SERIF}`; g.fillText('谷歌的电脑', 52, 170); g.fillText('自己学会了认猫', 52, 250);
+ g.font = `400 32px ${SERIF}`; g.fillStyle = '#2a2723';
+ g.fillText('1000 台机器、1.6 万个处理器核心,', 52, 330); g.fillText('看了 1000 万张 YouTube 视频截图,', 52, 386); g.fillText('没有人告诉过它,哪一张是猫。', 52, 442);
+ g.fillStyle = 'rgba(40,36,30,.3)'; for (let i = 0; i < 3; i++) g.fillRect(52, 482 + i * 34, [700, 640, 420][i], 14);
+ g.restore();
+});
+const CARD = { w: 520, h: 330 };
+const cardSprite = () => sprite('card', CARD.w, CARD.h, (g) => {
+ g.fillStyle = C.card; g.fillRect(0, 0, CARD.w, CARD.h);
+ g.strokeStyle = 'rgba(80,140,200,.3)'; g.lineWidth = 2; for (let y = 96; y < CARD.h; y += 52) { g.beginPath(); g.moveTo(0, y); g.lineTo(CARD.w, y); g.stroke(); }
+ g.strokeStyle = 'rgba(184,67,63,.5)'; g.beginPath(); g.moveTo(0, 60); g.lineTo(CARD.w, 60); g.stroke();
+});
+
+// ---------- 桌面世界 ----------
+const R1 = [960, 540], R2 = [3100, 720];
+const NEWSPOS = { x: 620, y: 520, r: -0.035 }, PHOTO = { x: 1440, y: 470, r: 0.06, w: 380, h: 430 };
+const THUMBS = (() => { const r = rng(55), o = [], kinds = ['dog', 'car', 'man', 'tree', 'house', 'game']; const cats = new Set([3, 8, 13, 16, 22]);
+ for (let j = 0; j < 4; j++) for (let i = 0; i < 6; i++) { const k = j * 6 + i; o.push({ x: 2250 + i * 205 + (r() - .5) * 26, y: 420 + j * 150 + (r() - .5) * 20, r: (r() - .5) * 0.09, kind: cats.has(k) ? 'cat' : kinds[(r() * kinds.length) | 0], seed: 100 + k, cat: cats.has(k) }); }
+ return o; })();
+const CARDPOS = { x: 3660, y: 560, r: 0.025 };
+const PRINT = { x: 3640, y: 900, r: -0.04, w: 210, h: 210 }; // 调查墙上那张小照片:推进它、硬切到镜 3
+const deskCam = (ft) => {
+ const base = CAM.at([
+ { t: 0, x: R1[0] + 20, y: R1[1] + 20, z: 1.14 },
+ { t: 0.9, x: R1[0] + 10, y: R1[1] + 30, z: 1.165, ease: MO.sineInOut }, // 开场慢推(停留段 0.5–1%/s 的 Ken Burns 加一点)
+ // 荧光笔扫完后推向那一行(BD 实测约 +11%/s),1.5s easeInOutSine
+ { t: 2.4, x: R1[0] - 60, y: R1[1] + 60, z: 1.28, ease: MO.sineInOut },
+ { t: PAN.a, x: R1[0] - 56, y: R1[1] + 60, z: 1.29, ease: MO.sineInOut },
+ // 沿红线追过去:1.1s 长尾 bezier(.33,0,.2,1)
+ { t: PAN.a + PAN.d, x: R2[0], y: R2[1], z: 1.0, ease: longTail },
+ { t: PUSH.a, x: R2[0] + 30, y: R2[1] + 10, z: 1.04, ease: MO.sineInOut },
+ ], ft);
+ if (ft <= PUSH.a) return base;
+ // 推进照片:0.6s easeInOutSine,对数插值推到照片铺满画面(z≈9.6)
+ return CAM.pushTo(base, PRINT.x, PRINT.y, 9.6, MO.sineInOut(seg(ft, PUSH.a, PUSH.b)));
+};
+Y2.deskCam = deskCam;
+// 投影很弱(MC 实测黑底卡片几乎无投影;桌面上留一点就够);纸片滑入带倾斜、到位放平(12fps 步进)
+const shadowed = CL.shadowed, slideIn = CL.slideIn, placed = CL.placed, tape = CL.tape, stringPts = CL.stringPts, highlight = CL.highlight;
+const pin = (g, x, y, on) => { if (on) CL.pin(g, x, y, C.red); };
+const NEWS_CIRCLE = DG.hand(DG.ellipsePts(0, 0, NEWS.circ.rx, NEWS.circ.ry, -2.6, 1.1, 40), { amp: 2.2, seed: 9 }), NEWS_CIRCLE_L = DG.cum(NEWS_CIRCLE);
+// 线索红线:从剪报高亮那一行的末端,一路连到调查墙的计数标签(相机沿它追)
+const CLUE = (() => { const a = [NEWSPOS.x + 250, NEWSPOS.y + 70], b = [2400, 1100]; return { a, b, pts: stringPts(a, b, 0.05) }; })();
+CLUE.cum = DG.cum(CLUE.pts);
+const drawDesk = (g, cam, ft) => {
+ g.save(); CAM.apply(g, cam);
+ g.fillStyle = g.createPattern(CL.paperTile('desk', C.desk, { amt: 12, fibers: 320, fiberCol: [110, 95, 70] }), 'repeat'); g.fillRect(-1200, -1200, 6800, 3600);
+ const st = step(ft);
+ // —— 区域 1:剪报+照片(随切点直接在桌上) ——
+ placed(g, NEWSPOS.x, NEWSPOS.y, NEWSPOS.r, (g) => {
+ const sp = newsSprite(); shadowed(g, () => g.drawImage(sp, -NEWS.w / 2, -NEWS.h / 2));
+ const b = NEWS.hl; highlight(g, -NEWS.w / 2 + b.x - 8, -NEWS.h / 2 + b.y - 6, b.w + 16, b.h + 12, MO.sineInOut(seg(st, 0.35, 1.25)));
+ const cq = MO.cubicOut(seg(st, 1.35, 2.0)); // 红笔圈:0.65s,首尾不闭合
+ if (cq > 0) { g.save(); g.translate(-NEWS.w / 2 + NEWS.circ.x, -NEWS.h / 2 + NEWS.circ.y); g.strokeStyle = C.red; g.lineWidth = 7; g.lineCap = 'round'; g.lineJoin = 'round'; DG.drawPartial(g, NEWS_CIRCLE, NEWS_CIRCLE_L, NEWS_CIRCLE_L[NEWS_CIRCLE_L.length - 1] * cq); g.restore(); }
+ });
+ placed(g, PHOTO.x, PHOTO.y, PHOTO.r, (g) => {
+ const sp = photoSprite('catphoto', PHOTO.w, PHOTO.h, (gg, w, h) => catPhoto(gg, w, h), { border: 18, cell: 7 });
+ shadowed(g, () => g.drawImage(sp, -sp.width / 2, -sp.height / 2)); tape(g, -sp.width / 2 + 30, -sp.height / 2 + 10, -0.6); tape(g, sp.width / 2 - 30, -sp.height / 2 + 10, 0.5);
+ });
+ // Borders 式黑底白字标签条
+ placed(g, 1260, 830, -0.02, (g) => { g.fillStyle = C.black; g.fillRect(-150, -40, 300, 80); g.fillStyle = C.paper; g.font = '46px "PuHui-Heavy"'; g.textAlign = 'center'; g.textBaseline = 'middle'; g.fillText('2012 · 谷歌', 0, 3); });
+ // —— 线索红线(一直在桌上;相机沿它追) ——
+ CL.string(g, CLUE.pts, CLUE.cum, 1e9, { col: C.red, lw: 5 });
+ pin(g, CLUE.a[0], CLUE.a[1], true); pin(g, CLUE.b[0], CLUE.b[1], true);
+ // —— 区域 2:调查墙(截图早就钉在墙上) ——
+ for (const [i, th] of THUMBS.entries()) placed(g, th.x, th.y, th.r, (g) => { const sp = photoSprite('th' + i, 168, 94, (gg, w, h) => thumbScene(gg, w, h, th.kind, th.seed), { border: 7, cell: 4 }); shadowed(g, () => g.drawImage(sp, -sp.width / 2, -sp.height / 2)); });
+ placed(g, CARDPOS.x, CARDPOS.y, CARDPOS.r, (g) => {
+ shadowed(g, () => g.drawImage(cardSprite(), -CARD.w / 2, -CARD.h / 2));
+ // 打字机:13 字/秒(MC 实测),按一拍二出字
+ const lines = ['没有人告诉它', '哪一张是猫'], t0 = PAN.a + PAN.d + 0.1;
+ g.fillStyle = C.ink; g.font = `600 52px ${SERIF}`; g.textBaseline = 'alphabetic';
+ const typed = TY.typedCount(st, t0, 13);
+ let k = 0; lines.forEach((ln, li) => { let x = -CARD.w / 2 + 40; for (const ch of ln) { if (k < typed) g.fillText(ch, x, -CARD.h / 2 + 140 + li * 104); x += g.measureText(ch).width; k++; } });
+ });
+ // 红线:每根 0.5s 描出(12fps),错开 0.15s;图钉随线头一起出现
+ const cats = THUMBS.filter(t => t.cat), cardPin = [CARDPOS.x - 40, CARDPOS.y - CARD.h / 2 + 22];
+ cats.forEach((th, i) => {
+ const t0 = PAN.a + PAN.d + 0.15 + i * 0.15, q = MO.sineInOut(seg(st, t0, t0 + 0.5)); if (q <= 0) return;
+ const a = [th.x + 40, th.y - 28], pts = stringPts(a, cardPin), L = DG.cum(pts);
+ CL.string(g, pts, L, L[L.length - 1] * q, { col: C.red, lw: 4 });
+ pin(g, a[0], a[1], true);
+ });
+ pin(g, cardPin[0], cardPin[1], st >= PAN.a + PAN.d + 0.15);
+ // 计数标签:黑胶带,数字 12fps 滚到 10,000,000(cubicOut)
+ placed(g, 2770, 1110, -0.03, (g) => {
+ const nq = MO.cubicOut(seg(st, PAN.a + 0.6, PAN.a + 2.0));
+ shadowed(g, () => { g.fillStyle = C.black; g.save(); g.translate(-380, -52); tornPoly(g, 760, 104, 77, 3); g.fill(); g.restore(); });
+ g.fillStyle = C.paper; g.textBaseline = 'middle'; g.font = `600 40px ${SERIF}`; g.fillText('视频截图', -350, 2);
+ g.fillStyle = C.hl; g.font = '74px "Anton-400"'; g.textAlign = 'right'; g.fillText('× ' + Math.round(10000000 * nq).toLocaleString('en-US'), 350, 6);
+ });
+ // 小照片:它脑中的「猫」,带倾斜滑入放平
+ slideIn(g, ft, PAN.a + PAN.d + 0.95, PRINT.x, PRINT.y, PRINT.r, (g) => {
+ const sp = photoSprite('neuron_s', PRINT.w, PRINT.h, neuronDraw, { border: 10, cell: 4 });
+ shadowed(g, () => g.drawImage(sp, -sp.width / 2, -sp.height / 2)); tape(g, 0, -sp.height / 2 + 2, 0.05, 90);
+ }, { from: [520, 120], tilt: 0.22, dur: 0.55 });
+ g.restore();
+};
+
+// 屏幕空间:暗角+静态颗粒(Vox 的纸纹是贴死的,不逐帧抖;调研 §9 实测)
+const finish = (c) => {
+ const v = PAINT.cached('y2_vig', W, H, (g) => { const r = g.createRadialGradient(W / 2, H / 2, H * 0.45, W / 2, H / 2, H * 1.05); r.addColorStop(0, 'rgba(40,30,20,0)'); r.addColorStop(1, 'rgba(40,30,20,.34)'); g.fillStyle = r; g.fillRect(0, 0, W, H); });
+ c.drawImage(v, 0, 0); c.drawImage(PAINT.grain('y2grain', 0.05, [40, 30, 20], 0.14), 0, 0);
+};
+const deskShot = (c, lt, t) => {
+ const ft = t - F0, cam = deskCam(ft);
+ const buf = PAINT.scratch('yt_y2desk'), g = buf.getContext('2d'); g.reset();
+ drawDesk(g, cam, ft);
+ c.fillStyle = C.desk; c.fillRect(0, 0, W, H);
+ // 快摇时沿速度方向的短模糊(PremiumBeat:模糊比相机运动更短)
+ const [vx, vy] = CAM.velocity(deskCam, ft);
+ CAM.motionBlur(c, buf, vx * 0.6, vy * 0.6, 7);
+ finish(c);
+};
+Y2.shot1 = deskShot; Y2.shot2 = deskShot;
+
+// ---------- 镜 3:黑底拼贴(MC 的「黑、纸白、一种红」) ----------
+const BIG = { x: 650, y: 610, w: 560, h: 560 };
+const s3cam = (ft) => {
+ const l = ft - Y2.SHOTS.s3[0];
+ // 拉出揭示:硬切后从同一张图铺满(z=3.68,和上一镜推满时照片的屏幕宽度一致)0.85s 长尾拉到 1.0;之后慢推 1%/s
+ const e = longTail(seg(l, 0, 0.85)), z = CAM.zlerp(3.68, 1.0, e) * (1 + 0.01 * Math.max(0, l - 0.85));
+ return CAM.anchor(BIG.x, BIG.y, z, lerp(W / 2, BIG.x, e), lerp(H / 2, BIG.y, e));
+};
+const NCIRC = DG.hand(DG.ellipsePts(0, 0, 340, 330, -2.2, 1.08, 48), { amp: 3, seed: 4 }), NCIRC_L = DG.cum(NCIRC);
+Y2.shot3 = (c, lt, t) => {
+ const ft = t - F0, l = ft - Y2.SHOTS.s3[0], cam = s3cam(ft), st = step(l);
+ c.save(); CAM.apply(c, cam);
+ // 结论还在同一张桌面上:一张大黑卡纸铺在桌上(MC 的黑底卡片),四边露出桌面纸纹
+ c.fillStyle = c.createPattern(CL.paperTile('desk', C.desk, { amt: 12, fibers: 320, fiberCol: [110, 95, 70] }), 'repeat'); c.fillRect(-800, -800, W + 1600, H + 1600);
+ placed(c, 960, 545, -0.012, (g) => { shadowed(g, () => { g.fillStyle = '#1b1b1a'; g.save(); g.translate(-890, -490); tornPoly(g, 1780, 980, 91, 3); g.fill(); g.restore(); });
+ g.save(); g.translate(-890, -490); tornPoly(g, 1780, 980, 91, 3); g.clip(); g.fillStyle = g.createPattern(CL.paperTile('black', '#1b1b1a', { amt: 5, fibers: 90, fiberCol: [90, 90, 85] }), 'repeat'); g.fillRect(0, 0, 1780, 980); g.restore(); });
+ placed(c, BIG.x, BIG.y, 0, (g) => { const sp = photoSprite('neuron', BIG.w, BIG.h, neuronDraw, { border: 20, cell: 9 }); g.drawImage(sp, -sp.width / 2, -sp.height / 2);
+ tape(g, 0, -sp.height / 2 + 4, 0.05, 220);
+ g.fillStyle = C.paper; g.font = `600 40px ${SERIF}`; g.textAlign = 'left'; g.fillText('它脑中的「猫」', -sp.width / 2, sp.height / 2 + 54); });
+ // 纸条标题:打字 13 字/秒(一拍二),随后荧光笔扫「猫神经元」
+ const T1 = '它自己长出了一个', T2 = '「猫神经元」', t0 = 0.4;
+ slideIn(c, l, 0.15, 1490, 330, -0.02, (g) => {
+ g.fillStyle = C.paper; g.save(); g.translate(-470, -150); tornPoly(g, 900, 290, 61, 4); g.fill(); g.restore();
+ g.fillStyle = C.ink; g.font = `900 70px ${SERIF}`; g.textBaseline = 'alphabetic';
+ const typed = TY.typedCount(st, t0, 13);
+ let x = -420; [...T1].forEach((ch, i) => { if (i < typed) g.fillText(ch, x, -40); x += g.measureText(ch).width; });
+ const w2 = g.measureText(T2).width; highlight(g, -428, 22, w2 + 20, 82, MO.sineInOut(seg(st, 1.5, 1.8)));
+ g.fillStyle = C.ink; x = -420; [...T2].forEach((ch, i) => { if (T1.length + i < typed) g.fillText(ch, x, 88); x += g.measureText(ch).width; });
+ }, { from: [700, -200], tilt: 0.18, dur: 0.4 });
+ // 红笔圈住(0.6s,12fps,首尾略交叉)
+ const cq = MO.cubicOut(seg(st, 0.95, 1.5));
+ if (cq > 0) { c.save(); c.translate(BIG.x, BIG.y); c.strokeStyle = C.red; c.lineWidth = 9; c.lineCap = 'round'; c.lineJoin = 'round'; DG.drawPartial(c, NCIRC, NCIRC_L, NCIRC_L[NCIRC_L.length - 1] * cq); c.restore(); }
+ // 花叔剪纸贴纸:带 12° 倾斜滑入放平;姿势按 12fps 步进(剪纸动画的一顿一顿)
+ const sq = clamp((st - 0.6) / 0.6);
+ if (sq > 0) {
+ const e = MO.quartOut(sq);
+ const pose = HUASHU.pose('point', 0, { ua1: 1.35 + 0.12 * Math.sin(st * 5), head: -0.05 + 0.04 * Math.sin(st * 3), mouth: 0.5 + 0.4 * Math.sin(st * 9) });
+ const HS = HUASHU.build({ x: 0, y: 0, s: 0.82, face: -1, pose });
+ const pal = { skin: '#f3c9a8', hair: '#171716', shirt: '#eeedeb', shorts: '#cdbf9f', hat: '#eeedeb', hatBand: '#b8433f', shoe: '#e8e4da', watch: '#171716', line: '#171716', lw: 5 };
+ const sp = PAINT.scratch('y2hs'), g = sp.getContext('2d'); g.reset(); if (!HERO.y2(g, st)) { g.translate(1500, 1040); HUASHU.draw(g, HS, pal); g.setTransform(1, 0, 0, 1, 0, 0); }
+ const sil = CL.stickerEdge(sp, 'y2sil', 12, '#f4f2ec'); // 剪纸贴纸:外扩 12px 的纸白边
+ c.save(); c.translate(1500 + 1100 * (1 - e), 1040 + 120 * (1 - e)); c.rotate(0.02 + 0.21 * (1 - Math.min(1, e * 1.15))); c.translate(-1500, -1040);
+ c.drawImage(sil, 0, 0); c.drawImage(sp, 0, 0); c.restore();
+ }
+ c.restore();
+ finish(c);
+};
+})();
+
+SCENES['y2_s1'] = { draw: (c, lt, t) => Y2.shot1(c, lt, t) };
+SCENES['y2_s2'] = { draw: (c, lt, t) => Y2.shot2(c, lt, t) };
+SCENES['y2_s3'] = { draw: (c, lt, t) => Y2.shot3(c, lt, t) };
diff --git a/scripts/engine/demos/y3_whiteboard/eras.js b/scripts/engine/demos/y3_whiteboard/eras.js
new file mode 100644
index 0000000..a42fec2
--- /dev/null
+++ b/scripts/engine/demos/y3_whiteboard/eras.js
@@ -0,0 +1,10 @@
+// 示范 · 白板手绘解说(RSA Animate 型)「AI 是怎么学会认猫的」(8 秒三镜)。语法卡:references/动画语法/y3_whiteboard.md
+// 预览 index.html?film=demos/y3_whiteboard 渲染 render.py --film demos/y3_whiteboard --out y3.mp4
+// 一整块大白板=世界,相机在板上移动;三段是同一个画面函数(DG.board 的笔画时间线),段只是为了 qa 分镜。
+window.PUNCH = 0;
+window.SCENE_LIBS = ['demos/_shared/hero.js', 'demos/y3_whiteboard/whiteboard.js'];
+window.ERAS = [
+ { id: 'y3_s1', dur: 2.5 }, // 画猫、写「猫?」、写问题
+ { id: 'y3_s2', dur: 2.25, transition: { type: 'same', dur: 0.8 } }, // 甩镜(0.8s 带运动模糊,笔不离板)
+ { id: 'y3_s3', dur: 3.25, transition: { type: 'same', dur: 0.85 } }, // 板上平滑移动 → 画花叔、「是猫!」→ 拉远看全图
+];
diff --git a/scripts/engine/demos/y3_whiteboard/whiteboard.js b/scripts/engine/demos/y3_whiteboard/whiteboard.js
new file mode 100644
index 0000000..ea9ab4a
--- /dev/null
+++ b/scripts/engine/demos/y3_whiteboard/whiteboard.js
@@ -0,0 +1,162 @@
+// Y3 · 白板手绘解说(RSA Animate 型:一整块大白板+相机移动):「AI 是怎么学会认猫的」
+// 依据:语法卡 y3_whiteboard.md(RSA 实测:黑 #0A0503+唯一强调色橙 #EB701F;写字≈16 字/秒、比口播晚 0.5s;
+// 平滑移动 easeInOutSine 中位 1.8s;远跳用 0.8s 带运动模糊的甩镜;手从右下入画、画完出画;结尾拉远看全图)
+// ①画一只猫、写「猫?」、写问题 → 转场 A「甩镜」:笔不离板,相机 0.8s 甩到板上远处,带运动模糊
+// ②画 1000 万张图的一摞(橙色数字直接弹出、不带手)、箭头、神经网络、「自己找规律」
+// → 转场 B「板上平滑移动」:相机 sine 缓入缓出 0.95s 斜移到旁边空白处,手在相机落定前就开始画
+// ③画花叔指着猫、打勾,橙色「是猫!」弹出 → 收尾「拉远看全图」(RSA / VideoScribe 默认的 Zoom at end),整板铺一层灰
+// 用到的库:DG.board(笔画时间线+跟随的笔)、DG.pen、DG.revealMask/zigzag(人物 Reveal)、CAM(关键帧相机、运动模糊)。
+(() => {
+const W = 1920, H = 1080;
+const { clamp, lerp, rng } = U;
+const seg = MO.seg;
+const Y3 = window.Y3 = {};
+const F0 = 0; Y3.F0 = F0;
+Y3.SHOTS = { s1: [0, 2.5], s2: [2.5, 4.75], s3: [4.75, 8.0] };
+const INK = '#0A0503', ORANGE = '#EF7226', WASH = 'rgba(239,114,38,.22)', BOARD = '#FBFBFB';
+const LW = 6.5; // RSA 实测笔画约画高 0.6–0.7%(1080p≈6–7px)
+const R1 = [960, 540], R2 = [3000, 540], R3 = [3700, 1360], K3 = 0.8;
+const L3 = (x, y) => [R3[0] + (x - 960) * K3, R3[1] + (y - 540) * K3];
+const SPEED = 2600; // 线条笔速:世界像素/秒(演示片比 RSA 实拍快约 2 倍,见卡片)
+
+// ---------- 笔画时间线:按顺序排,时长 = 长度 / 笔速 ----------
+const B = DG.board({ ink: INK, lw: LW, speed: SPEED, font: '"LXGWWenKai-500"' });
+const tr = DG.xform, arc = DG.arcPts, pathOf = pts => U.poly(pts);
+
+// 猫的笔画(本地坐标,原点 = 坐姿底部中心,约 400 高)
+const catStrokes = (ox, oy, s, sp, w, whiskers = true) => {
+ const P = (pts) => tr(pts, ox, oy, s);
+ B.line(P([[-60, -250], [-92, -330], [-30, -300], [30, -300], [92, -330], [60, -250]]), { w, speed: sp });
+ B.line(P(arc(0, -230, 100, 82, -0.55, Math.PI + 0.55, 26).reverse()), { w, speed: sp });
+ B.line(P([[-80, -170], [-120, -60], [-110, 0], [110, 0], [120, -60], [80, -170]]), { w, speed: sp });
+ B.line(P([[110, -20], [190, -40], [210, -130], [170, -190]]), { w, speed: sp });
+ B.line(P(arc(-38, -240, 12, 16, 0, Math.PI * 2, 14)), { w: w * 0.8, speed: sp * 1.6 });
+ B.line(P(arc(38, -240, 12, 16, 0, Math.PI * 2, 14)), { w: w * 0.8, speed: sp * 1.6 });
+ B.line(P([[-10, -205], [10, -205], [0, -194], [-10, -205]]), { w: w * 0.8, speed: sp * 1.6, smooth: false });
+ if (whiskers) for (const k of [-1, 1]) B.line(P([[k * 30, -196], [k * 110, -206]]), { w: w * 0.6, speed: sp * 2 });
+};
+const catBody = (ox, oy, s) => pathOf(tr([[-80, -170], [-120, -60], [-110, 0], [110, 0], [120, -60], [80, -170], [60, -160], [0, -150], [-60, -160]], ox, oy, s));
+
+// ===== 第一块 =====
+B.at(0.12);
+catStrokes(760, 820, 1.0, SPEED * 0.75, LW + 1);
+B.fill(catBody(760, 820, 1.0), WASH);
+B.text('猫?', 1060, 560, 150, { col: ORANGE, rate: 7.5 }); // 标题级:7.5 字/秒
+B.line([[1080, 610], [1020, 660], [930, 690]], { col: ORANGE });
+B.line([[960, 668], [928, 690], [966, 704]], { col: ORANGE, smooth: false });
+B.text('AI 怎么认出它?', 960, 960, 84, { align: 'center' }); // 正文:16 字/秒
+B.line([[1290, 590], [1500, 560], [1760, 540]], { col: ORANGE, speed: SPEED * 1.6 }); // 指向下一块的橙箭头:甩镜有了方向
+B.line([[1725, 512], [1764, 540], [1728, 572]], { col: ORANGE, smooth: false });
+const END1 = B.cur;
+// 甩镜时笔不离板:笔尖在屏幕上从第一块的箭头头滑向第二块的起笔点,板在笔下飞过,留下一条橙色连线(笔一直在画,视线一直被它领着)。
+// 轨迹 = 屏幕上的笔位置按当时的相机反算成世界点(第一次画时算好)。
+const trail = { kind: 'custom', from: [1764, 540], to: [2382, 278], t0: B.cur + 0.01, t1: 3.3, col: ORANGE, w: LW, wob: 14,
+ draw(g, q) {
+ const s = this;
+ if (!s.pts) { const N = 72, a = CAM.toScreen(camAt(s.t0), ...s.from), b = CAM.toScreen(camAt(s.t1), ...s.to); s.pts = [];
+ for (let i = 0; i <= N; i++) { const u = i / N, cm = camAt(lerp(s.t0, s.t1, u)), e = MO.sineInOut(u), sx = lerp(a[0], b[0], e), sy = lerp(a[1], b[1], e) + Math.sin(u * Math.PI * 3) * s.wob * Math.sin(u * Math.PI);
+ s.pts.push(CAM.toWorld(cm, sx, sy)); }
+ s.cum = DG.cum(s.pts); }
+ const k = q * (s.pts.length - 1), i = Math.floor(k), f = k - i, d = s.cum[i] + (i < s.pts.length - 1 ? (s.cum[i + 1] - s.cum[i]) * f : 0);
+ g.strokeStyle = s.col; g.lineWidth = s.w; return DG.drawPartial(g, s.pts, s.cum, d);
+ },
+ start() { return this.from; }, end() { return this.pts ? this.pts[this.pts.length - 1] : this.to; } };
+B.push(trail);
+
+// ===== 第二块(相机 2.5→3.3 甩过来) =====
+B.at(3.31);
+for (let i = 2; i >= 0; i--) { const x = 2330 + i * 26, y = 330 - i * 26; B.fill(pathOf([[x, y], [x + 260, y], [x + 260, y + 190], [x, y + 190]]), BOARD, 0.01); B.line([[x, y], [x + 260, y], [x + 260, y + 190], [x, y + 190], [x, y + 3]], { w: 6, speed: SPEED * 4.5, smooth: false, amp: 0 }); }
+B.line(tr([[-60, -250], [-92, -330], [-30, -300], [30, -300], [92, -330], [60, -250], ...arc(0, -230, 100, 82, -0.55, Math.PI + 0.55, 20).reverse(), [-60, -250]], 2460, 560, 0.4), { w: 5, speed: SPEED * 3, gap: 0 });
+B.line(tr([[-38, -240], [-38, -236], [38, -236], [38, -240]], 2460, 560, 0.4), { w: 6, speed: SPEED, smooth: false, gap: 0.01 });
+B.pop('×1000万张', 2470, 690, 74, { col: ORANGE });
+B.line([[2680, 450], [2800, 452], [2860, 450]]);
+B.line([[2830, 425], [2864, 450], [2830, 476]], { smooth: false });
+const NET = [[2960, [330, 450, 570]], [3090, [300, 450, 600]], [3220, [400, 500]]];
+for (const [x, ys] of NET) for (const y of ys) B.line(arc(x, y, 26, 26, -Math.PI / 2, Math.PI * 1.55, 16), { w: 6, speed: SPEED * 5, amp: 0.8, min: 0.03, gap: 0.01 });
+for (let a = 0; a < 2; a++) for (const y0 of NET[a][1]) for (const y1 of NET[a + 1][1]) B.segment([NET[a][0] + 26, y0], [NET[a + 1][0] - 26, y1], { w: 3 });
+B.at(B.cur + 0.05);
+B.text('自己找规律', 3090, 780, 64, { align: 'center' });
+// 橙色连线:从网络引向下一块(相机开始移动时画,手领着相机走)
+B.at(4.62); B.line([[3250, 470], [3420, 560], [3480, 760], [3420, 900]], { col: ORANGE, speed: SPEED * 1.4 }); B.line([[3392, 868], [3420, 902], [3452, 872]], { col: ORANGE, smooth: false });
+const END2 = B.cur;
+
+// ===== 第三块(相机 5.1→6.05 平滑斜移;手在 5.8 就入画开画) =====
+B.at(5.35);
+// VideoScribe 的 Reveal 画法——完整线稿藏在下面,笔尖从上往下走 8 行之字形,笔过之处揭开(笔尖永远在揭开的前沿上)
+const huashu = () => { const [x, y] = L3(500, 1010); return HUASHU.build({ x, y, s: 0.95 * K3, face: 1, pose: HUASHU.pose('point', 0, { ua1: 1.25, mouth: 0.8 }) }); };
+const rigZig = (HSb) => { if (rigZig.c) return rigZig.c; const js = Object.values(HSb.J).filter(v => Array.isArray(v)); const xs = js.map(v => v[0]), ys = js.map(v => v[1]);
+ const x0 = Math.min(...xs) - 70, x1 = Math.max(...xs) + 50, y0 = Math.min(...ys) - 20, y1 = Math.max(...ys) + 40, rows = 8;
+ rigZig.rowH = (y1 - y0) / rows; const zz = DG.zigzag(x0, y0, x1 - x0, y1 - y0, rows); return (rigZig.c = { zz, cum: DG.cum(zz) }); };
+const RIG3 = { t0: B.cur, t1: B.cur + 0.7 };
+B.push({ kind: 'custom', t0: RIG3.t0, t1: RIG3.t1,
+ draw(g, q, ft) {
+ const HSb = huashu(), { zz, cum } = rigZig(HSb), d = cum[cum.length - 1] * q;
+ g.save(); if (q < 1) g.clip(DG.revealMask(zz, cum, d, rigZig.rowH * 2.2)); g.lineJoin = 'round'; g.lineCap = 'round'; // 揭完就不再裁:之字形拐角处的三角会漏掉
+ const [fx, fy] = L3(500, 1010);
+ if (!HERO.y3(g, fx, fy, 0.95 * K3 * 740, ft)) {
+ for (const p of HSb.parts) { g.fillStyle = p.role === 'hair' ? INK : BOARD; g.fill(p.path); g.strokeStyle = INK; g.lineWidth = LW * 0.9; g.stroke(p.path); }
+ HUASHU.details(g, HSb, { line: INK, lw: 4.5, glass: INK, cheek: null, earLine: 'rgba(0,0,0,.5)', shoeHole: INK });
+ }
+ g.restore();
+ return q < 1 ? DG.pointAt(zz, cum, d) : null;
+ },
+ start() { return rigZig(huashu()).zz[0]; }, end() { const z = rigZig(huashu()).zz; return z[z.length - 1]; } });
+B.at(RIG3.t1 + 0.03);
+catStrokes(...L3(1150, 900), K3 * 0.95, SPEED * 1.6, LW, false);
+B.line([L3(1000, 330), L3(1070, 400), L3(1240, 200)], { col: ORANGE, w: LW + 2, speed: SPEED * 1.5, smooth: false });
+B.pop('是猫!', ...L3(1500, 410), 150 * K3, { col: ORANGE, align: 'left' });
+// 收尾:拉远的同时圈住「是猫!」,全景停住时回到第一块,在问题下面划一道——问题和答案连上,笔停在最后一笔上
+B.at(Math.max(B.cur + 0.02, 6.95));
+B.line(DG.ellipsePts(...L3(1720, 360), 300 * K3, 120 * K3, -2.9, 1.08, 40), { col: ORANGE, w: LW, speed: SPEED * 1.1 });
+B.at(Math.max(B.cur + 0.06, 7.52));
+B.line([[640, 1000], [960, 1006], [1290, 998]], { col: ORANGE, w: LW + 2, speed: SPEED * 0.9 });
+const END3 = B.cur;
+Y3.timeline = { END1, END2, END3, RIG3 };
+Y3.board = B;
+
+// ---------- 相机 ----------
+const OVER = { x: 2400, y: 930, z: 0.45 };
+const camAt = ft => CAM.at([
+ { t: 0, x: R1[0], y: R1[1], z: 1.0 },
+ { t: 2.5, x: R1[0] + 12, y: R1[1] + 6, z: 1.02, ease: MO.sineInOut },
+ // 甩镜:0.8s(RSA 实测远跳约 0.8s,带运动模糊)
+ { t: 3.3, x: R2[0], y: R2[1], z: 1.0, ease: MO.cubicInOut },
+ { t: 4.7, x: R2[0] + 16, y: R2[1] + 6, z: 1.02, ease: MO.sineInOut },
+ // 板上平滑移动:easeInOutSine 0.9s(实测中位 1.8s,演示片压缩)
+ { t: 5.6, x: R3[0], y: R3[1] - 20, z: 1.12, ease: MO.sineInOut },
+ { t: 6.85, x: R3[0] + 10, y: R3[1] - 14, z: 1.14, ease: MO.sineInOut },
+ // 拉远看全图,停 0.5s
+ { t: 7.5, ...OVER, ease: MO.sineInOut },
+ { t: 8.0, ...OVER, z: OVER.z * 0.985, ease: MO.sineInOut },
+], ft);
+Y3.camAt = camAt;
+
+// ---------- 画 ----------
+const drawBoard = (c, cam, ft) => {
+ // 结尾整板铺一层灰(RSA 实测),在拉远时 0.5s 淡入
+ const gray = MO.sineInOut(seg(ft, 6.9, 7.4));
+ c.fillStyle = gray > 0 ? PAINT.rgb(PAINT.mix(PAINT.hex(BOARD), [238, 238, 236], gray)) : BOARD; c.fillRect(0, 0, W, H);
+ // 极淡的擦痕:屏幕空间平铺、跟着相机平移走(不随缩放放大)
+ const sm = PAINT.cached('y3smudge', 1024, 1024, g => { const r = rng(5); for (let i = 0; i < 22; i++) { g.fillStyle = `rgba(120,120,130,${0.003 + r() * 0.005})`; g.beginPath(); g.ellipse(r() * 1024, r() * 1024, 80 + r() * 200, 14 + r() * 40, r() * 3, 0, 7); g.fill(); } });
+ c.save(); const ox = -(((cam.x * cam.z) % 1024) + 1024) % 1024, oy = -(((cam.y * cam.z) % 1024) + 1024) % 1024; c.translate(ox, oy); c.fillStyle = c.createPattern(sm, 'repeat'); c.fillRect(0, 0, W + 1024, H + 1024); c.restore();
+ c.save(); CAM.apply(c, cam);
+ const r = B.draw(c, ft);
+ c.restore();
+ return r;
+};
+const shot = (c, lt, t) => {
+ const ft = t - F0, cam = camAt(ft);
+ const buf = PAINT.scratch('yt_y3board'), g = buf.getContext('2d'); g.reset();
+ const { tip, col } = drawBoard(g, cam, ft);
+ const [vx, vy] = CAM.velocity(camAt, ft);
+ c.fillStyle = BOARD; c.fillRect(0, 0, W, H);
+ const whip = ft > 2.5 && ft < 3.3; // 只有甩镜带模糊;板上平滑移动和结尾拉远都是清楚的(RSA 实测)
+ CAM.motionBlur(c, buf, whip ? vx * 0.8 : 0, whip ? vy * 0.8 : 0, 9);
+ const [hx, hy] = B.penAt(ft, cam, tip);
+ DG.pen(c, hx, hy, col || B.penColor(ft), Math.sin(ft * 7) * 0.03); // 只有一支马克笔,笔尾帽 = 墨色
+};
+Y3.shot1 = shot; Y3.shot2 = shot; Y3.shot3 = shot;
+SCENES['y3_s1'] = { draw: shot };
+SCENES['y3_s2'] = { draw: shot };
+SCENES['y3_s3'] = { draw: shot };
+})();
diff --git a/scripts/engine/demos/y4_storytime/eras.js b/scripts/engine/demos/y4_storytime/eras.js
new file mode 100644
index 0000000..f7b1e4a
--- /dev/null
+++ b/scripts/engine/demos/y4_storytime/eras.js
@@ -0,0 +1,14 @@
+// 示范 · 故事型简笔角色(storytime)「我第一次让 AI 帮我写代码」(8.75 秒五镜)。语法卡:references/动画语法/y4_storytime.md
+// 预览 index.html?film=demos/y4_storytime 渲染 render.py --film demos/y4_storytime --out y4.mp4(口播音轨另配;口型读 vo_env.js 的包络)
+// 镜头按口播切(不是按节拍):一句口播 ≈ 一个镜头,反应镜头放在两句之间的「沉默」里。
+window.PUNCH = 0; // storytime 不卡音乐拍
+window.FILM_DURATION = 8.75;
+window.SCENE_LIBS = ['demos/y4_storytime/vo_env.js', 'demos/y4_storytime/story.js', 'demos/y4_storytime/world.js'];
+window.SCENE_DIR = 'demos/y4_storytime';
+window.ERAS = [
+ { id: 's1_desk', dur: 2.0 }, // 中景:对镜头讲
+ { id: 's2_screen', dur: 2.4, transition: { type: 'whip', dur: 0.26, dir: 1 } }, // 甩镜 → 屏幕(过肩)。甩在两句之间的换气里,别切在句中
+ { id: 's3_react', dur: 1.2, transition: { type: 'smash', dur: 0.32 } }, // 砸镜 → 反应大特写(沉默)
+ { id: 's4_wide', dur: 1.65, transition: { type: 'cut', dur: 0.02 } }, // 硬切 → 同一房间大全景
+ { id: 's5_close', dur: 1.5, transition: { type: 'cut', dur: 0.02 } }, // 跳近 → 近景,笑点+定住
+];
diff --git a/scripts/engine/demos/y4_storytime/s1_desk.js b/scripts/engine/demos/y4_storytime/s1_desk.js
new file mode 100644
index 0000000..6b55722
--- /dev/null
+++ b/scripts/engine/demos/y4_storytime/s1_desk.js
@@ -0,0 +1,18 @@
+// S1 中景:花叔坐在桌后对镜头讲。口播「我第一次让AI帮我写代码,」
+// 动:口型(口播包络,一拍二)、说话点头、呼吸、换姿势回弹(talk → point)、眼神跟手、眨眼、窗外云、镜头慢推+微漂。
+// 房间、桌子、笔记本都在 world.js(S4/S5 同一个房间换镜头)。
+(() => {
+const S = STORY;
+const KEYS = [[0, 'talk', 'happy'], [1.12, 'point', 'talk']];
+SCENES['s1_desk'] = {
+ draw(c, lt, t) {
+ const ts = MO.step(t, 24); // 角色按 24fps(Flash 默认帧率)走,镜头按 60fps 平滑
+ const zoom = 1.01 + 0.035 * MO.expoOut(Math.min(1, lt / 2.0)) + 0.03 * (1 - MO.expoOut(Math.min(1, lt / 0.5))); // 开场 1.04→1.01 落定,再慢推 3.5%
+ const [dx, dy] = CAM.drift(t, 4, 1);
+ CAM.with(c, { x: 900 + dx, y: 520 + dy, z: zoom }, c => {
+ const st = S.poseAt(KEYS, ts), al = S.alive(ts, 165);
+ S.world(c, t, { pose: st.pose, expr: st.expr, mouth: TOON.mouth(t), blink: S.blinkAt(ts), look: ts > 1.12 ? [1, 0] : [0, 0], squash: st.squash * al.breathe, bob: al.bob, tilt: ts > 1.12 ? 0.05 : -0.03 });
+ });
+ },
+};
+})();
diff --git a/scripts/engine/demos/y4_storytime/s2_screen.js b/scripts/engine/demos/y4_storytime/s2_screen.js
new file mode 100644
index 0000000..89e7932
--- /dev/null
+++ b/scripts/engine/demos/y4_storytime/s2_screen.js
@@ -0,0 +1,82 @@
+// S2 过肩看屏幕:他只打了一行「帮我做个网站」,AI 回了一整面墙的代码,越滚越快,计数器在「三千」那个字上砸出「3000 行」。
+// 动:打字、代码瀑布加速滚、行数计数、3000 砸出+屏幕震、前景花叔后脑勺随呼吸晃。
+(() => {
+const S = STORY, C = S.C, W = 1920, H = 1080;
+const { clamp, lerp, rng } = U;
+const T_TYPE = 2.30, T_SEND = 2.78, T_SLAM = 3.70; // 全片时间;3.70 = 口播「三千」
+// 代码行(色块表示,远看就是代码;颜色取常见编辑器主题)
+const COLS = ['#C792EA', '#82AAFF', '#C3E88D', '#F78C6C', '#89DDFF', '#FFCB6B', '#676E95'];
+const LINES = (() => { const r = rng(42), out = []; let ind = 0;
+ for (let i = 0; i < 400; i++) { if (r() < 0.18) ind = Math.min(4, ind + 1); else if (r() < 0.2) ind = Math.max(0, ind - 1);
+ const toks = []; let x = ind * 34; const n = 1 + (r() * 4 | 0); for (let k = 0; k < n; k++) { const w = 30 + r() * 150; toks.push([x, w, COLS[(r() * COLS.length) | 0]]); x += w + 14; }
+ out.push(toks); } return out; })();
+// 滚动位置:发送后 0.25s 开始,加速(三次方),在 SLAM 时达到每秒上千行的视觉速度
+const scrollAt = t => { const q = Math.max(0, t - T_SEND - 0.25); return 46 * (q * 6 + Math.pow(q * 2.6, 3) * 6); };
+const countAt = t => t >= T_SLAM ? 3000 : Math.min(2999, Math.floor(Math.pow(Math.max(0, (t - T_SEND - 0.25)) / (T_SLAM - T_SEND - 0.25), 2.4) * 2999));
+SCENES['s2_screen'] = {
+ draw(c, lt, t) {
+ const slam = t - T_SLAM;
+ const shake = slam > 0 && slam < 0.3 ? MO.settle(slam, 14, 9, 14) : 0; // 震:9Hz、0.3s 内衰减完
+ const zoom = 1.0 + 0.02 * Math.min(1, lt / 2.2) + (slam > 0 ? 0.04 * MO.expoOut(clamp(slam / 0.12)) : 0);
+ c.fillStyle = '#15161C'; c.fillRect(0, 0, W, H);
+ CAM.with(c, { x: 960 + shake, y: 540 - shake * 0.5, z: zoom }, c => {
+ // 屏幕边框
+ c.fillStyle = '#2B2D36'; c.beginPath(); c.roundRect(150, 40, 1620, 1000, 34); c.fill();
+ c.save(); c.beginPath(); c.roundRect(190, 80, 1540, 920, 14); c.clip();
+ c.fillStyle = C.screen; c.fillRect(190, 80, 1540, 920);
+ // 我的那一行:右侧气泡,打字
+ const sent = MO.at(t, T_SEND, 0.18), scr = scrollAt(t);
+ const bubY = 200 - Math.min(scr, 400);
+ const msg = TY.typed('帮我做个网站', MO.at(t, T_TYPE, 0.4));
+ if (bubY > 60) {
+ c.fillStyle = sent > 0 ? '#3B82F6' : '#2F3342'; const bw = TY.width(c, '帮我做个网站', 40, 'PuHui-Bold') + 60;
+ c.beginPath(); c.roundRect(1680 - bw, bubY - 52, bw, 78, 24); c.fill();
+ TY.text(c, msg + (sent <= 0 && Math.floor(t * 4) % 2 ? '|' : ''), 1680 - bw + 30, bubY + 2, { size: 40, fam: 'PuHui-Bold', color: '#fff', align: 'left' });
+ }
+ // AI 的回复:代码墙,从气泡下方开始往上滚
+ if (t > T_SEND + 0.1) {
+ const top = 300 - scr, lh = 46;
+ const i0 = Math.max(0, Math.floor((150 - top) / lh)), i1 = Math.min(LINES.length * 8, Math.ceil((1000 - top) / lh));
+ for (let i = i0; i < i1; i++) { const y = top + i * lh; if (y < 150 || y > 1000) continue;
+ const shown = MO.at(t, T_SEND + 0.1 + Math.min(i, 12) * 0.03, 0.05); if (shown <= 0) continue; // 头几行逐行冒出来
+ c.fillStyle = '#4A4F66'; c.fillRect(220, y - 12, 44, 16);
+ for (const [x, w, col] of LINES[i % LINES.length]) { c.fillStyle = col; c.globalAlpha = 0.9; c.beginPath(); c.roundRect(300 + x, y - 14, w * shown, 20, 10); c.fill(); }
+ c.globalAlpha = 1; }
+ // 速度线感:滚太快时整屏加一层竖向拖影
+ const v = (scrollAt(t + 1 / 60) - scr) * 60; if (v > 1500) { c.fillStyle = `rgba(32,34,45,${clamp((v - 1500) / 6000) * 0.5})`; c.fillRect(190, 150, 1540, 850); }
+ }
+ // 顶栏(画在内容之后:滚上去的内容钻到它下面)
+ c.fillStyle = '#2A2D3A'; c.fillRect(190, 80, 1540, 64);
+ ['#FF5F57', '#FEBC2E', '#28C840'].forEach((col, i) => { c.fillStyle = col; c.beginPath(); c.arc(232 + i * 34, 112, 10, 0, Math.PI * 2); c.fill(); });
+ TY.text(c, 'AI助手', 960, 124, { size: 30, fam: 'PuHui-Bold', color: '#9AA3B8' });
+ const n = countAt(t);
+ if (t > T_SEND + 0.2) TY.text(c, `${n}行`, 1700, 124, { size: 32, fam: 'PuHui-Bold', color: n >= 3000 ? '#FFCB6B' : '#9AA3B8', align: 'right' });
+ // 3000 行:砸出来(backOut 过冲 23%)+底板压暗
+ if (slam > 0) {
+ c.fillStyle = `rgba(10,10,16,${0.6 * MO.expoOut(clamp(slam / 0.15))})`; c.fillRect(190, 80, 1540, 920);
+ TY.pop(c, '3000行', 960, 600, clamp(slam / 0.24), { size: 230, fam: 'PuHui-Black', color: '#FFCB6B', over: 3.5, stroke: '#15161C', strokeW: 18 });
+ }
+ c.restore();
+ });
+ // 前景:花叔的背影(过肩)。不跟镜头推,只随呼吸起伏 —— 前景与屏幕的视差让镜头「有空间」。
+ // 返修:第一版是纯黑剪影,审片读成「另一个影子人」。现在画出主角背面的识别点:白帽+帽带、耳朵、眼镜腿、后颈、白 T,屏幕那侧加一圈冷色轮廓光。
+ const by = 840 + 6 * Math.sin(2 * Math.PI * t / 1.6) + (slam > 0 ? -MO.settle(slam, 18, 4, 7) : 0), hx = 330, L = C.line;
+ c.save(); c.lineWidth = 7; c.strokeStyle = L; c.lineJoin = 'round'; c.lineCap = 'round';
+ c.fillStyle = '#FFFFFF'; c.beginPath(); c.ellipse(hx, by + 300, 330, 200, 0, Math.PI, 0); c.fill(); c.stroke(); // 肩(白 T)
+ c.fillStyle = '#FFE2CC'; c.beginPath(); c.roundRect(hx - 70, by + 120, 140, 110, 30); c.fill(); c.stroke(); // 后颈
+ c.strokeStyle = '#E6E6EA'; c.lineWidth = 16; c.beginPath(); c.moveTo(hx - 95, by + 205); c.quadraticCurveTo(hx, by + 175, hx + 95, by + 205); c.stroke(); c.strokeStyle = L; c.lineWidth = 7; // 领口
+ for (const sx of [-1, 1]) { c.fillStyle = '#FFE2CC'; c.beginPath(); c.ellipse(hx + sx * 196, by + 40, 34, 52, sx * 0.2, 0, Math.PI * 2); c.fill(); c.stroke(); } // 耳朵
+ c.fillStyle = '#1B1B1F'; c.beginPath(); c.ellipse(hx, by + 40, 190, 175, 0, 0, Math.PI * 2); c.fill(); // 后脑(短黑发)
+ c.strokeStyle = '#3A3A44'; c.lineWidth = 4; for (let i = -3; i <= 3; i++) { c.beginPath(); c.moveTo(hx + i * 40, by + 130); c.lineTo(hx + i * 44, by + 175); c.stroke(); } // 发梢
+ c.strokeStyle = L; c.lineWidth = 9; for (const sx of [-1, 1]) { c.beginPath(); c.moveTo(hx + sx * 214, by + 10); c.lineTo(hx + sx * 236, by - 40); c.stroke(); } // 眼镜腿(挂在耳朵上,往前伸)
+ c.lineWidth = 7;
+ c.fillStyle = '#FFFFFF'; c.beginPath(); c.moveTo(hx - 180, by - 20); c.bezierCurveTo(hx - 180, by - 290, hx + 180, by - 290, hx + 180, by - 20); c.closePath(); c.fill(); c.stroke(); // 帽冠
+ c.save(); c.beginPath(); c.moveTo(hx - 180, by - 20); c.bezierCurveTo(hx - 180, by - 290, hx + 180, by - 290, hx + 180, by - 20); c.closePath(); c.clip(); c.fillStyle = '#E4E4E8'; c.fillRect(hx - 200, by - 85, 400, 40); c.restore(); // 帽带
+ c.fillStyle = '#FFFFFF'; c.beginPath(); c.ellipse(hx, by - 12, 280, 64, 0, 0, Math.PI * 2); c.fill(); c.stroke(); // 帽檐
+ // 屏幕光轮廓(右上侧,冷色)
+ c.globalCompositeOperation = 'source-atop'; c.strokeStyle = 'rgba(140,200,255,0.55)'; c.lineWidth = 14;
+ c.beginPath(); c.ellipse(hx, by - 12, 272, 58, 0, -1.2, 0.1); c.stroke(); c.beginPath(); c.ellipse(hx, by + 300, 322, 192, 0, -1.3, -0.2); c.stroke();
+ c.restore();
+ },
+};
+})();
diff --git a/scripts/engine/demos/y4_storytime/s3_react.js b/scripts/engine/demos/y4_storytime/s3_react.js
new file mode 100644
index 0000000..40c011e
--- /dev/null
+++ b/scripts/engine/demos/y4_storytime/s3_react.js
@@ -0,0 +1,39 @@
+// S3 反应大特写:砸镜进来,死鱼眼,一言不发。整段是沉默 —— 笑点在「停顿」里。
+// 动:砸镜回弹(转场里)、极慢推进 6%、镜片反光扫过、汗滴滑落、一次慢眨眼、背景暗角呼吸、嘴角抽一下。
+(() => {
+const S = STORY, C = S.C, W = 1920, H = 1080;
+const { clamp } = U;
+SCENES['s3_react'] = {
+ draw(c, lt, t) {
+ const ts = MO.step(t, 24);
+ const lts = ts - 4.4; // 本段局部(步进后)
+ // 虚空背景:纯色+暗角(反应镜头把环境拿掉,只留脸)
+ c.fillStyle = C.void; c.fillRect(0, 0, W, H);
+ const vg = c.createRadialGradient(960, 560, 200, 960, 560, 1100); vg.addColorStop(0, 'rgba(255,255,255,0.10)'); vg.addColorStop(1, 'rgba(0,0,0,0.35)');
+ c.fillStyle = vg; c.fillRect(0, 0, W, H);
+ // 集中线(很淡、极慢转):漫画「凝固」的符号
+ c.save(); c.translate(960, 560); c.rotate(t * 0.04); c.strokeStyle = 'rgba(255,255,255,0.07)'; c.lineWidth = 6;
+ for (let i = 0; i < 48; i++) { const a = i / 48 * Math.PI * 2; c.beginPath(); c.moveTo(Math.cos(a) * 640, Math.sin(a) * 640); c.lineTo(Math.cos(a) * 1300, Math.sin(a) * 1300); c.stroke(); }
+ c.restore();
+ const zoom = 1 + 0.06 * Math.min(1, lt / 1.2);
+ CAM.with(c, { x: 960, y: 560, z: zoom }, c => {
+ const R = 360;
+ const blink = (lts >= 0.62 && lts < 0.62 + 0.125) ? 1 : 0; // 慢眨眼:3 帧@24fps(比平时多 1 帧,读作「无语」)
+ const twitch = lts > 0.78 ? 'worry' : 'blank'; // 第二声蟋蟀后 0.15s 眉毛一垮(声画同一件事)
+ const info = TOON.bean(c, { x: 960, y: 560 + R * 2.1 + 40, s: R, pose: TOON.POSES.stiff, expr: twitch, mouth: 0, blink, look: [0, 0], lw: 12 });
+ // 镜片反光:一条白色斜带从左扫到右(0.15–0.45s)
+ const g = MO.at(lts, 0.15, 0.3);
+ if (g > 0 && g < 1) {
+ const hy = info.head[1];
+ for (const sx of [-1, 1]) { const gx = 960 + sx * R * 0.37, gy = hy + R * 0.2, gr = R * 0.27;
+ c.save(); c.beginPath(); c.arc(gx, gy, gr - 4, 0, Math.PI * 2); c.clip();
+ const bx = gx - gr * 1.6 + g * gr * 3.2; c.fillStyle = 'rgba(255,255,255,0.85)';
+ c.beginPath(); c.moveTo(bx - 30, gy - gr); c.lineTo(bx + 20, gy - gr); c.lineTo(bx - 40, gy + gr); c.lineTo(bx - 90, gy + gr); c.closePath(); c.fill(); c.restore(); }
+ }
+ // 汗滴:太阳穴处,0.35s 起滑落 0.9s
+ const sw = MO.at(lt, 0.35, 0.9);
+ if (sw > 0) TOON.sweat(c, 960 + R * 0.88, info.head[1] - R * 0.1, 34, MO.expoOut(sw) * 0.6 + sw * 0.4);
+ });
+ },
+};
+})();
diff --git a/scripts/engine/demos/y4_storytime/s4_wide.js b/scripts/engine/demos/y4_storytime/s4_wide.js
new file mode 100644
index 0000000..f091ceb
--- /dev/null
+++ b/scripts/engine/demos/y4_storytime/s4_wide.js
@@ -0,0 +1,16 @@
+// S4 大全景(同一个房间拉远到 0.5 倍):小小的花叔坐在大房间里。口播「我问它:这些……」
+// 全景让人显得渺小无助 —— 远景本身就是笑点的铺垫。返修:两段停顿里加「眼睛瞟一下电脑再看镜头」、说「这些」时指电脑。
+// 动:口型、眼神(6.2 瞟电脑 → 6.6 回到镜头)、换姿势回弹(talk → point)、吊灯摆、云飘、屏幕光闪、镜头极慢拉远。
+(() => {
+const S = STORY;
+SCENES['s4_wide'] = {
+ draw(c, lt, t) {
+ const ts = MO.step(t, 24);
+ const zoom = 0.53 - 0.03 * MO.quintOut(Math.min(1, lt / 1.65)); // 0.53 → 0.50
+ CAM.with(c, { x: 900, y: 470, z: zoom }, c => {
+ const st = S.poseAt(S.KEYS_END, ts), al = S.alive(ts, 165);
+ S.world(c, t, { pose: st.pose, expr: st.expr, mouth: TOON.mouth(t), blink: S.blinkAt(ts), look: S.lookEnd(ts), squash: st.squash * al.breathe, bob: al.bob, lw: 10 });
+ });
+ },
+};
+})();
diff --git a/scripts/engine/demos/y4_storytime/s5_close.js b/scripts/engine/demos/y4_storytime/s5_close.js
new file mode 100644
index 0000000..382abe0
--- /dev/null
+++ b/scripts/engine/demos/y4_storytime/s5_close.js
@@ -0,0 +1,18 @@
+// S5 近景(跳近:同机位直接切到 1.9 倍):「贴哪儿?」——摊手、眉毛内端抬高、头顶「?」弹出,然后定住 0.95s 给笑。
+// 返修:第一版把这句放在全景里,脸只有 110px 高,表情看不清,「?」出来 0.4s 片子就完了。
+(() => {
+const S = STORY;
+SCENES['s5_close'] = {
+ draw(c, lt, t) {
+ const ts = MO.step(t, 24);
+ const zoom = 1.9 + 0.08 * MO.quintOut(Math.min(1, lt / 1.5)); // 跳近后极慢再推 4%
+ CAM.with(c, { x: 870, y: 470, z: zoom }, c => {
+ const st = S.poseAt(S.KEYS_END, ts), al = S.alive(ts, 165);
+ const info = S.world(c, t, { pose: st.pose, expr: st.expr, mouth: TOON.mouth(t), blink: S.blinkAt(ts, [8.3]), look: S.lookEnd(ts), squash: st.squash * al.breathe, bob: al.bob, tilt: ts >= 7.45 ? -0.07 : 0, browUp: ts >= 7.45 ? 0.04 : 0 });
+ // 「?」:问完那一刻弹出(过冲 30%),之后 ±3° 轻晃
+ const q = MO.at(t, 7.80, 0.26);
+ if (q > 0) { c.save(); c.translate(info.head[0] + 165 * 1.4, info.head[1] - 165 * 0.5); c.rotate(0.14 + 0.05 * Math.sin(t * 6)); TOON.mark(c, '?', 0, 0, q, 120); c.restore(); }
+ });
+ },
+};
+})();
diff --git a/scripts/engine/demos/y4_storytime/story.js b/scripts/engine/demos/y4_storytime/story.js
new file mode 100644
index 0000000..2c96caf
--- /dev/null
+++ b/scripts/engine/demos/y4_storytime/story.js
@@ -0,0 +1,25 @@
+// y4 本片共用:配色、姿势时间线(pose-to-pose+换姿势回弹)、眨眼、字幕。
+// 用到的库:TOON(豆子花叔 bean、poseAt、blinkAt、alive、口型读 VO_ENV)、TY.text(字幕)、CAM(镜头)、MO(步进、弹簧)。
+(() => {
+const S = window.STORY = {};
+// 背景压低饱和与对比、线更细更灰;角色线最黑最粗 —— 视线永远先落到角色上
+S.C = { wall: '#DCE9EC', wall2: '#CFE0E4', floor: '#E8DCC8', desk: '#E2C29B', deskSide: '#CDA97F', bgLine: '#5B6470', line: '#1B1B1F',
+ sky: '#BFE3F5', cloud: '#FFFFFF', laptop: '#C9CDD6', screen: '#20222D', glow: 'rgba(120,200,255,0.35)', void: '#3D405B' };
+S.bgLW = 3;
+// 口播时间(秒,全片时间):与 共享/音频/build_y4.py 的摆放一致
+S.LINES = [[0.12, 2.0, '我第一次让AI帮我写代码,'], [2.13, 4.40, '它一口气,给了我三千行。'], [5.75, 8.75, '我问它:这些……贴哪儿?']]; // 字幕和镜头切点同一帧换
+
+// 姿势时间线:keys = [[t, poseName, expr], ...](全片时间)。换姿势 = TOON.poseAt:手臂 0.1s 快切、身体挤压 7% 后弹簧回弹
+S.poseAt = TOON.poseAt;
+// 眨眼:固定时刻表(「随机」间隔 2.4–3.6s 写死),闭眼 2 帧@24fps ≈ 0.083s
+S.blinkAt = (t, extra = []) => TOON.blinkAt(t, [0.9, 3.4, 6.1, ...extra]);
+// 说话时头随音节轻点+呼吸(1.6s 一周期,±1.2%)
+S.alive = TOON.alive;
+
+// 字幕(中文平台需要烧录;YouTube 原生 storytime 不烧,靠 CC):白字黑描边,整句切入切出,不做花样
+window.GLOBAL_OVERLAY = (c, t) => {
+ for (const [a, b, s] of S.LINES) if (t >= a && t < b) {
+ TY.text(c, s, 960, 1022, { size: 50, fam: 'PuHui-Bold', color: '#fff', stroke: '#1B1B1F', strokeW: 10, track: 1 });
+ }
+};
+})();
diff --git a/scripts/engine/demos/y4_storytime/vo_env.js b/scripts/engine/demos/y4_storytime/vo_env.js
new file mode 100644
index 0000000..3d6a609
--- /dev/null
+++ b/scripts/engine/demos/y4_storytime/vo_env.js
@@ -0,0 +1,2 @@
+// 由 共享/音频/build_y4.py 生成:口播 RMS 包络,60fps,0..1
+window.VO_ENV = {"fps": 60, "a": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.558, 0.959, 0.963, 0.984, 0.929, 0.834, 0.614, 0.501, 0.149, 0.385, 0.474, 0.541, 0.516, 0.521, 0.635, 0.651, 0.678, 0.671, 0.608, 0.611, 0.672, 0.455, 0.025, 0.058, 0.088, 0.071, 0.044, 0.639, 1.0, 1.0, 1.0, 0.965, 0.694, 0.498, 0.892, 1.0, 1.0, 0.654, 0.515, 0.5, 0.383, 0.159, 0.013, 0.006, 0.507, 0.883, 0.855, 0.89, 0.803, 0.691, 0.708, 0.498, 0.178, 0.018, 0.002, 0.0, 0.0, 0.0, 0.216, 0.78, 1.0, 1.0, 1.0, 0.99, 0.733, 0.615, 0.538, 0.598, 0.804, 0.838, 0.825, 0.785, 0.631, 0.584, 0.489, 0.348, 0.078, 0.106, 0.096, 0.062, 0.591, 0.877, 0.842, 0.844, 0.843, 0.696, 0.441, 0.207, 0.395, 0.516, 0.565, 0.479, 0.345, 0.422, 0.525, 0.795, 1.0, 1.0, 1.0, 0.917, 0.894, 0.88, 0.876, 0.653, 0.187, 0.05, 0.006, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.04, 0.047, 0.054, 0.698, 1.0, 1.0, 1.0, 0.81, 0.704, 0.724, 0.738, 0.694, 0.615, 0.567, 0.569, 0.461, 0.169, 0.072, 0.074, 0.065, 0.076, 0.679, 0.995, 0.908, 0.739, 0.652, 0.524, 0.315, 0.069, 0.089, 0.089, 0.067, 0.277, 0.744, 0.865, 0.818, 0.726, 0.655, 0.414, 0.039, 0.002, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.079, 0.633, 0.799, 0.847, 0.845, 0.785, 0.707, 0.678, 0.692, 0.724, 0.632, 0.626, 0.633, 0.571, 0.692, 0.86, 0.977, 0.923, 1.0, 0.729, 0.681, 0.407, 0.067, 0.061, 0.324, 0.616, 0.7, 0.654, 0.472, 0.321, 0.289, 0.295, 0.207, 0.054, 0.077, 0.081, 0.089, 0.111, 0.443, 0.625, 0.692, 0.771, 0.564, 0.419, 0.35, 0.274, 0.195, 0.065, 0.039, 0.034, 0.909, 1.0, 1.0, 1.0, 0.589, 0.432, 0.415, 0.315, 0.158, 0.011, 0.001, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.608, 0.957, 0.954, 0.955, 1.0, 0.946, 0.853, 0.768, 0.868, 0.969, 1.0, 1.0, 0.98, 0.714, 0.661, 0.65, 0.456, 0.417, 0.316, 0.051, 0.035, 0.046, 0.037, 0.07, 0.55, 0.946, 0.985, 0.849, 0.779, 0.715, 0.485, 0.151, 0.07, 0.049, 0.001, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.02, 0.068, 0.248, 0.875, 1.0, 1.0, 1.0, 0.98, 0.759, 0.404, 0.081, 0.095, 0.081, 0.387, 0.699, 0.75, 0.71, 0.75, 0.814, 0.513, 0.105, 0.014, 0.001, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.017, 0.056, 0.059, 0.046, 0.043, 0.371, 0.806, 0.956, 1.0, 0.903, 0.681, 0.602, 0.582, 0.514, 0.437, 0.513, 0.786, 0.765, 0.806, 0.761, 0.711, 0.376, 0.04, 0.006, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]};
diff --git a/scripts/engine/demos/y4_storytime/world.js b/scripts/engine/demos/y4_storytime/world.js
new file mode 100644
index 0000000..a279f1e
--- /dev/null
+++ b/scripts/engine/demos/y4_storytime/world.js
@@ -0,0 +1,73 @@
+// y4 的「世界画布」:S1 中景、S4 大全景、S5 近景是同一个房间、同一套世界坐标,只换镜头。
+// (返修:第一版 S4 另画了一个房间,审片指出空间不连贯;中景镜头偏移露出画框外的黑边。
+// 现在世界铺到 x −1000..2900、y −700..1700,最远的全景 zoom 0.5 也盖得满。)
+// S1 镜头看到的范围 ≈ x 0..1920、y 0..1080;全景时才看得到书架、绿植、吊灯、地板。
+(() => {
+const S = STORY, C = S.C;
+const X0 = -1000, Y0 = -700, WW = 3900, WH = 2400;
+const back = () => PAINT.cached('y4_world_back', WW, WH, g => {
+ g.translate(-X0, -Y0);
+ g.lineWidth = S.bgLW; g.strokeStyle = C.bgLine; g.lineJoin = 'round';
+ g.fillStyle = C.wall; g.fillRect(X0, Y0, WW, WH);
+ // 天花板线、地板
+ g.fillStyle = C.wall2; g.fillRect(X0, Y0, WW, 330); g.beginPath(); g.moveTo(X0, Y0 + 330); g.lineTo(X0 + WW, Y0 + 330); g.stroke();
+ g.fillStyle = C.floor; g.fillRect(X0, 1150, WW, 600); g.fillStyle = '#D2C3AA'; g.fillRect(X0, 1132, WW, 18);
+ g.beginPath(); g.moveTo(X0, 1132); g.lineTo(X0 + WW, 1132); g.moveTo(X0, 1150); g.lineTo(X0 + WW, 1150); g.stroke();
+ // 猫画框(小猫补光灯的草图)
+ g.fillStyle = '#F4EEE2'; g.beginPath(); g.roundRect(1380, 210, 230, 170, 10); g.fill(); g.stroke();
+ g.strokeStyle = '#B9A88E'; g.lineWidth = 4; g.beginPath(); g.arc(1495, 300, 46, 0, Math.PI * 2); g.stroke();
+ g.beginPath(); g.moveTo(1462, 266); g.lineTo(1470, 238); g.lineTo(1484, 258); g.moveTo(1528, 266); g.lineTo(1520, 238); g.lineTo(1506, 258); g.stroke();
+ g.strokeStyle = C.bgLine; g.lineWidth = S.bgLW;
+ // 书架(S1 画外左侧)
+ const r = U.rng(9); g.fillStyle = '#D9C3A0'; g.beginPath(); g.roundRect(-700, 420, 420, 712, 8); g.fill(); g.stroke();
+ for (const sy of [420, 600, 780, 960]) { g.beginPath(); g.moveTo(-700, sy + 160); g.lineTo(-280, sy + 160); g.stroke();
+ let x = -675; while (x < -310) { const w = 22 + r() * 24, h = 90 + r() * 50; g.fillStyle = ['#8FB3C9', '#E7A37B', '#B9C98F', '#C6A0C9'][(r() * 4) | 0]; g.fillRect(x, sy + 160 - h, w, h); g.strokeRect(x, sy + 160 - h, w, h); x += w + 6; } }
+ // 绿植(画外右侧,地上)
+ g.fillStyle = '#E7A37B'; g.beginPath(); g.moveTo(2240, 1140); g.lineTo(2270, 990); g.lineTo(2410, 990); g.lineTo(2440, 1140); g.closePath(); g.fill(); g.stroke();
+ g.fillStyle = '#8DBF8B'; for (const [x, y, rx, ry, a] of [[2290, 900, 40, 110, -0.5], [2340, 870, 40, 128, 0], [2392, 905, 40, 106, 0.5]]) { g.beginPath(); g.ellipse(x, y, rx, ry, a, 0, Math.PI * 2); g.fill(); g.stroke(); }
+});
+// 桌子:S1 里只看得到桌面和挡板上沿;全景看得到桌腿
+const desk = (g) => {
+ g.lineWidth = S.bgLW; g.strokeStyle = C.bgLine; g.lineJoin = 'round';
+ g.fillStyle = C.deskSide; for (const x of [-120, 1960]) { g.fillRect(x, 740, 60, 400); g.strokeRect(x, 740, 60, 400); }
+ g.fillRect(-60, 740, 2020, 320); g.strokeRect(-60, 740, 2020, 320);
+ g.fillStyle = C.desk; g.beginPath(); g.rect(-160, 690, 2240, 50); g.fill(); g.stroke();
+ // 马克杯
+ g.fillStyle = '#F26B4F'; g.beginPath(); g.roundRect(470, 600, 70, 92, 10); g.fill(); g.stroke();
+ g.beginPath(); g.arc(548, 640, 22, -1.2, 1.2); g.lineWidth = 9; g.stroke(); g.lineWidth = S.bgLW;
+};
+const front = () => PAINT.cached('y4_world_front', WW, WH, g => { g.translate(-X0, -Y0); desk(g); });
+
+// ch: 角色参数(TOON.bean 的 o,不含 x/y/s);返回 bean 的 info
+S.world = (c, t, ch) => {
+ c.drawImage(back(), X0, Y0);
+ // 窗:天空+慢飘的云(18px/s、12px/s)
+ c.save(); c.beginPath(); c.roundRect(220, 190, 420, 300, 12); c.clip(); c.fillStyle = C.sky; c.fillRect(220, 190, 420, 300);
+ for (const [cx, cy, r, sp] of [[300, 300, 46, 18], [560, 400, 34, 12]]) { const x = 180 + ((cx + t * sp) % 520); c.fillStyle = C.cloud;
+ c.beginPath(); c.arc(x, cy, r, 0, Math.PI * 2); c.arc(x + r * 0.9, cy + 6, r * 0.75, 0, Math.PI * 2); c.arc(x - r * 0.9, cy + 8, r * 0.65, 0, Math.PI * 2); c.fill(); }
+ c.restore();
+ c.lineWidth = S.bgLW; c.strokeStyle = C.bgLine; c.beginPath(); c.roundRect(220, 190, 420, 300, 12); c.stroke();
+ c.beginPath(); c.moveTo(430, 190); c.lineTo(430, 490); c.moveTo(220, 340); c.lineTo(640, 340); c.stroke();
+ // 吊灯(只有全景看得到):钟摆 1.9s、±4°
+ c.save(); c.translate(860, -370); c.rotate(0.07 * Math.sin(2 * Math.PI * t / 1.9)); c.lineWidth = S.bgLW; c.strokeStyle = C.bgLine;
+ c.beginPath(); c.moveTo(0, 0); c.lineTo(0, 240); c.stroke();
+ c.fillStyle = '#F2C86B'; c.beginPath(); c.moveTo(-90, 330); c.lineTo(-42, 240); c.lineTo(42, 240); c.lineTo(90, 330); c.closePath(); c.fill(); c.stroke(); c.restore();
+ // 角色
+ const info = TOON.bean(c, { x: 860, y: 760, s: 165, ...ch });
+ c.drawImage(front(), X0, Y0);
+ // 笔记本(背面朝镜头、斜对着他),屏幕光打在桌上,光随代码滚动微闪
+ c.save(); c.lineWidth = S.bgLW; c.strokeStyle = C.bgLine; c.lineJoin = 'round';
+ const glow = c.createRadialGradient(1240, 690, 10, 1240, 690, 260); glow.addColorStop(0, `rgba(140,210,255,${0.42 + 0.06 * Math.sin(t * 9)})`); glow.addColorStop(1, 'rgba(140,210,255,0)');
+ c.fillStyle = glow; c.fillRect(980, 560, 520, 180);
+ c.fillStyle = C.laptop; c.beginPath(); c.moveTo(1080, 692); c.lineTo(1130, 470); c.lineTo(1420, 470); c.lineTo(1380, 692); c.closePath(); c.fill(); c.stroke();
+ c.fillStyle = '#AEB3BE'; c.beginPath(); c.roundRect(1050, 684, 360, 16, 6); c.fill(); c.stroke();
+ const k = 1 + 0.06 * Math.sin(t * 5);
+ c.translate(1255, 580); c.scale(k, k); c.fillStyle = '#F2A33A'; c.beginPath();
+ for (let i = 0; i < 8; i++) { const a = i / 8 * Math.PI * 2, r = i % 2 ? 14 : 36; c.lineTo(Math.cos(a) * r, Math.sin(a) * r); } c.closePath(); c.fill(); c.stroke();
+ c.restore();
+ return info;
+};
+// S4/S5 共用的姿势时间线(全片时间,跨两个镜头连续)
+S.KEYS_END = [[5.6, 'talk', 'worry'], [6.81, 'point', 'worry'], [7.45, 'shrug', 'worry']];
+S.lookEnd = t => t >= 7.45 ? [0, 0] : t >= 6.81 ? [1, 0.1] : (t >= 6.2 && t < 6.6) ? [1, 0.35] : [0, 0];
+})();
diff --git a/scripts/engine/demos/y5_kinetic_type/eras.js b/scripts/engine/demos/y5_kinetic_type/eras.js
new file mode 100644
index 0000000..87285f3
--- /dev/null
+++ b/scripts/engine/demos/y5_kinetic_type/eras.js
@@ -0,0 +1,16 @@
+// 示范 · 动态文字排版(kinetic typography)「AI 写代码的 3 个阶段」 120 BPM,8 秒 = 4 小节 = 16 拍,再静住 0.5s。
+// 语法卡:references/动画语法/y5_kinetic_type.md
+// 预览 index.html?film=demos/y5_kinetic_type 渲染 render.py --film demos/y5_kinetic_type --out y5.mp4
+// 揭开那一帧落在拍上:段起点 = 小节线 − 揭开点 × 转场时长(MO.onBeat)——
+// fillZoom 揭开点 .55、dur .45 → 2.0−.25 = 1.75;bands 揭开点 ≈.6、dur .5 → 4.0−.3 = 3.7;push 到 90% 位移在 p≈.58、dur .35 → 6.0−.2 ≈ 5.80
+window.PUNCH = 0; // 拍点冲击由 kinetic.js 的 K.bump 自己做(每拍 1.2%)
+window.FILM_DURATION = 8.5;
+window.SCENE_LIBS = ['demos/y5_kinetic_type/kinetic.js'];
+window.SCENE_DIR = 'demos/y5_kinetic_type';
+window.ERAS = [
+ { id: 'k1_title', dur: 1.75 },
+ { id: 'k2_complete', dur: 1.95, // 冲进点选在圆内、避开「3」字形(冲进白字会一片白)
+ transition: { type: 'fillZoom', dur: 0.45, k: 0.55, cx: 1075, cy: 773, maxZoom: 30, fill: '#FF5A36' } },
+ { id: 'k3_chat', dur: 2.1, transition: { type: 'bands', dur: 0.5, gap: 0.12, colors: ['#FFD23F', '#FFFFFF', '#14213D'] } },
+ { id: 'k4_agent', dur: 2.7, transition: { type: 'push', dur: 0.35 } },
+];
diff --git a/scripts/engine/demos/y5_kinetic_type/k1_title.js b/scripts/engine/demos/y5_kinetic_type/k1_title.js
new file mode 100644
index 0000000..e45f677
--- /dev/null
+++ b/scripts/engine/demos/y5_kinetic_type/k1_title.js
@@ -0,0 +1,38 @@
+// K1 标题:「AI 写代码」两拍砸进来 →「的 3 个阶段」在第三拍落下 → 第四拍其余字快速退场,只剩「3」,镜头冲进 3 的圆里。
+// 入场慢(0.3–0.4s 弹簧)、退场快(0.18s expoIn)——退场比入场快,观众的注意力已经走了。
+(() => {
+const K = KT, C = K.C, b = K.b;
+const { clamp, lerp } = U;
+// 退场:t0 起 0.18s,缩到 0.6、下落 60px、透明
+const exitK = (t, t0) => MO.expoIn(clamp((t - t0) / 0.18));
+SCENES['k1_title'] = {
+ draw(c, lt, t) {
+ c.fillStyle = C.yellow; c.fillRect(0, 0, 1920, 1080);
+ K.dots(c, t, C.ink, 0.08);
+ K.cam(c, t, c => {
+ // 第一行:AI | 写代码
+ const s1 = 300, wAI = TY.width(c, 'AI', s1), wCode = TY.width(c, '写代码', s1), gap = 50, x0 = 960 - (wAI + gap + wCode) / 2, y1 = 470;
+ const ex = [exitK(t, 1.45), exitK(t, 1.48), exitK(t, 1.51), exitK(t, 1.54)];
+ // AI:第 0 拍砸进来,带 -8° → 0° 的旋转回正
+ if (t >= 0) { const k = MO.springHz(t, 2.2, 10), e = ex[0];
+ TY.text(c, 'AI', x0, y1 + 60 * e, { size: s1, align: 'left', color: C.ink, scale: lerp(1.7, 1, k) * (1 - 0.4 * e), rot: -0.14 * (1 - k), alpha: clamp(t / 0.06) * (1 - e), ox: x0 + wAI / 2, oy: y1 - s1 * 0.36 }); }
+ // 写代码:第 1 拍从槽里升起(遮罩),0.35s expoOut
+ { const e = ex[1]; c.save(); c.globalAlpha = 1 - e; c.translate(0, 60 * e);
+ TY.rise(c, '写代码', x0 + wAI + gap, y1, MO.at(t, b(1), 0.35), { size: s1, color: C.ink }); c.restore(); }
+ // 第二行:的 | (3) | 个阶段 圆心 (960, 773) —— 转场从这里冲进去
+ const cy = 773, r = 165;
+ const pc = MO.at(t, b(2), 0.42);
+ if (pc > 0) {
+ const k = MO.backOut(pc, 3.0) * (t > b(3) ? 1 + 0.12 * MO.expoOut(clamp((t - b(3)) / 0.2)) : 1);
+ c.save(); c.translate(960, cy); c.scale(k, k); c.rotate(0.25 * (1 - MO.expoOut(pc)));
+ c.fillStyle = C.coral; c.beginPath(); c.arc(0, 0, r, 0, Math.PI * 2); c.fill();
+ TY.text(c, '3', 0, 92, { size: 270, color: C.white });
+ c.restore();
+ }
+ { const e = ex[2]; TY.text(c, '的', 960 - r - 40, cy + 40 + 60 * e, { size: 120, fam: 'PuHui-Heavy', align: 'right', color: C.ink, alpha: MO.at(t, b(1.75), 0.08) * (1 - e) }); }
+ { const e = ex[3]; c.save(); c.globalAlpha = 1 - e; c.translate(0, 60 * e);
+ TY.rise(c, '个阶段', 960 + r + 40, cy + 52, MO.at(t, b(2.25), 0.35), { size: 150, fam: 'PuHui-Heavy', color: C.ink }); c.restore(); }
+ });
+ },
+};
+})();
diff --git a/scripts/engine/demos/y5_kinetic_type/k2_complete.js b/scripts/engine/demos/y5_kinetic_type/k2_complete.js
new file mode 100644
index 0000000..1d6fedf
--- /dev/null
+++ b/scripts/engine/demos/y5_kinetic_type/k2_complete.js
@@ -0,0 +1,55 @@
+// K2 阶段一「补全」(一小节 = 第 4–7 拍,2.0–4.0s)
+// 第 4 拍主词砸进+巨型「1」→ 4.5 拍代码卡滑入、开始打字 → 第 5 拍辅句「它补完」升起、5.25 拍「下一行」→
+// 第 6 拍灰色补全闪现+Tab 键弹出 → 6.5 拍按下 Tab、灰字变实、「下一行」放大 1.35 倍+荧光笔(字和动作说同一件事)。
+// 返修:辅句原在第 6 拍出、7 个字,到被色带盖住只剩 0.7s;现在提前一拍、压到 6 个字,可读 1.2s。
+(() => {
+const K = KT, C = K.C, b = K.b;
+const { clamp } = U;
+const MONO = 'Menlo'; // 代码用等宽(返修:第一版用了比例字体,不像代码)
+SCENES['k2_complete'] = {
+ draw(c, lt, t) {
+ c.fillStyle = C.coral; c.fillRect(0, 0, 1920, 1080);
+ K.dots(c, t, C.white, 0.1);
+ K.cam(c, t, c => {
+ K.bigNum(c, t, '1', b(4), 1880, 1150, 'rgba(255,255,255,0.13)');
+ TY.rise(c, '阶段 01', 140, 250, MO.at(t, b(4), 0.3), { size: K.SZ.label, fam: 'PuHui-Bold', color: C.white, track: 6 });
+ TY.underline(c, 140, 272, 170, MO.at(t, b(4.25), 0.3), C.white, 6);
+ K.slam(c, '补全', 130, 600, t, b(4), { color: C.white });
+ const sub = '它补完', key = '下一行', sw = TY.width(c, sub, K.SZ.sub, 'PuHui-Heavy'), kw = TY.width(c, key, K.SZ.sub, 'PuHui-Heavy');
+ const ky = 775, kx = 150 + sw;
+ TY.rise(c, sub, 140, ky, MO.at(t, b(5), 0.35), { size: K.SZ.sub, fam: 'PuHui-Heavy', color: C.white });
+ const ksc = t >= b(6.5) ? 1 + 0.35 * MO.springHz(t - b(6.5), 2.5, 9) : 1;
+ K.keyMarker(c, kx, ky, kw, K.SZ.sub, t, b(6.5), ksc, C.yellow);
+ K.key(c, key, kx, ky, t, b(5.25), b(6.5), { size: K.SZ.sub, fam: 'PuHui-Heavy', color: t >= b(6.5) ? C.ink : C.white });
+ // 代码卡:4.5 拍从右侧滑入(expoOut 0.4s,起点 +700px,带 3.4° 回正)
+ const pin = MO.expoOut(MO.at(t, b(4.5), 0.4));
+ if (pin > 0) {
+ const cx = 1010 + 700 * (1 - pin), cy = 330;
+ c.save(); c.translate(cx, cy); c.rotate(0.06 * (1 - pin));
+ c.fillStyle = 'rgba(0,0,0,0.18)'; c.beginPath(); c.roundRect(14, 18, 800, 330, 26); c.fill();
+ c.fillStyle = C.code; c.beginPath(); c.roundRect(0, 0, 800, 330, 26); c.fill();
+ ['#FF5F57', '#FEBC2E', '#28C840'].forEach((col, i) => { c.fillStyle = col; c.beginPath(); c.arc(40 + i * 30, 40, 9, 0, Math.PI * 2); c.fill(); });
+ const T = (s, x, y, col, a = 1) => TY.text(c, s, x, y, { size: 40, fam: MONO, color: col, align: 'left', alpha: a });
+ T('1', 40, 130, '#555A72'); T('function hello() {', 96, 130, '#82AAFF');
+ T('2', 40, 210, '#555A72');
+ const typed = TY.typed(' const name =', MO.at(t, b(4.75), 0.5)); T(typed, 96, 210, '#E9ECF5');
+ const tw = TY.width(c, typed, 40, MONO), acc = t >= b(6.5);
+ // 补全:第 6 拍整段灰字 0 帧闪现(补全本来就是瞬间出现),Tab 按下后变实色
+ if (t >= b(6)) T(" 'huashu';", 96 + tw, 210, acc ? '#C3E88D' : 'rgba(233,236,245,0.35)');
+ T('3', 40, 290, '#555A72'); if (acc) T('}', 96, 290, '#82AAFF', MO.at(t, b(6.6), 0.1));
+ if (Math.floor(t * 4) % 2 === 0) { const cxr = 96 + tw + (acc ? TY.width(c, " 'huashu';", 40, MONO) : 0); c.fillStyle = '#FFD23F'; c.fillRect(cxr + 4, 172, 5, 50); }
+ c.restore();
+ }
+ // Tab 键帽:第 6 拍弹出,6.5 拍按下(压 14%,e^-18t 回弹)
+ const kp = MO.at(t, b(6), 0.3); if (kp > 0) {
+ const press = t >= b(6.5) ? 1 - 0.14 * Math.exp(-(t - b(6.5)) * 18) : 1, s = MO.backOut(kp, 2.6) * press;
+ c.save(); c.translate(1410, 790); c.scale(s, s);
+ c.fillStyle = '#C24128'; c.beginPath(); c.roundRect(-130, -62, 260, 136, 22); c.fill();
+ c.fillStyle = C.white; c.beginPath(); c.roundRect(-130, -76 + (1 - press) * 70, 260, 128, 22); c.fill();
+ TY.text(c, 'TAB', 0, 12 + (1 - press) * 70, { size: 64, fam: 'PuHui-Black', color: C.coral });
+ c.restore();
+ }
+ });
+ },
+};
+})();
diff --git a/scripts/engine/demos/y5_kinetic_type/k3_chat.js b/scripts/engine/demos/y5_kinetic_type/k3_chat.js
new file mode 100644
index 0000000..22c6d53
--- /dev/null
+++ b/scripts/engine/demos/y5_kinetic_type/k3_chat.js
@@ -0,0 +1,47 @@
+// K3 阶段二「对话」(第 8–11 拍,4.0–6.0s;推页 5.8s 起、6.0s 到位)
+// 第 8 拍主词砸在画右+巨型「2」→ 8.5 拍你的气泡弹出 → 第 9 拍 AI 气泡长出、代码一行行流进来 → 9.5 拍辅句 → 10.5 拍「一整段」放大+荧光笔。
+// 版式和 K2 镜像(主词左↔右),同一套拍位换位置,观众不会觉得重复。
+// 返修:辅句原在第 10 拍、10 个字只停 0.55s,左端离 AI 面板只剩 14px;现在提前、压到 7 个字、右对齐留 250px 以上。
+(() => {
+const K = KT, C = K.C, b = K.b;
+const COLS = ['#C792EA', '#82AAFF', '#C3E88D', '#F78C6C', '#89DDFF', '#FFCB6B'];
+SCENES['k3_chat'] = {
+ draw(c, lt, t) {
+ c.fillStyle = C.navy; c.fillRect(0, 0, 1920, 1080);
+ K.dots(c, t, C.white, 0.07);
+ K.cam(c, t, c => {
+ K.bigNum(c, t, '2', b(8), 1880, 1150, 'rgba(255,255,255,0.07)');
+ TY.rise(c, '阶段 02', 1790, 250, MO.at(t, b(8), 0.3), { size: K.SZ.label, fam: 'PuHui-Bold', color: C.yellow, track: 6, align: 'right' });
+ TY.underline(c, 1620, 272, 170, MO.at(t, b(8.25), 0.3), C.yellow, 6);
+ const hw = TY.width(c, '对话', K.SZ.hero);
+ K.slam(c, '对话', 1790 - hw, 600, t, b(8), { color: C.yellow });
+ const s1 = '一句话换', key = '一整段', w1 = TY.width(c, s1, K.SZ.sub, 'PuHui-Heavy'), wk = TY.width(c, key, K.SZ.sub, 'PuHui-Heavy');
+ const ky = 775, x1 = 1790 - w1 - wk * 1.35 - 12, kx = x1 + w1 + 12;
+ TY.rise(c, s1, x1, ky, MO.at(t, b(9.5), 0.35), { size: K.SZ.sub, fam: 'PuHui-Heavy', color: C.white });
+ const ksc = t >= b(10.5) ? 1 + 0.35 * MO.springHz(t - b(10.5), 2.5, 9) : 1;
+ K.keyMarker(c, kx, ky, wk, K.SZ.sub, t, b(10.5), ksc, C.yellow);
+ K.key(c, key, kx, ky, t, b(9.75), b(10.5), { size: K.SZ.sub, fam: 'PuHui-Heavy', color: t >= b(10.5) ? C.navy : C.white });
+ // 你的气泡(右对齐到 x=820),8.5 拍弹出
+ const p1 = MO.at(t, b(8.5), 0.3);
+ if (p1 > 0) { const s = MO.backOut(p1, 2.6); c.save(); c.translate(820, 250); c.scale(s, s);
+ const w = TY.width(c, '帮我做个登录页', 48, 'PuHui-Bold') + 70;
+ c.fillStyle = C.blue; c.beginPath(); c.roundRect(-w, -50, w, 96, 30); c.fill();
+ c.beginPath(); c.moveTo(-26, 40); c.lineTo(10, 58); c.lineTo(-6, 26); c.fill();
+ TY.text(c, '帮我做个登录页', -w / 2, 16, { size: 48, fam: 'PuHui-Bold', color: C.white }); c.restore(); }
+ // AI 气泡:第 9 拍长出(高度 expoOut 0.35s),之后代码每 0.045s 流入一行
+ const p2 = MO.at(t, b(9), 0.35);
+ if (p2 > 0) {
+ const e = MO.expoOut(p2), x = 130, y = 340, w = 690, h = 620 * e;
+ c.fillStyle = C.white; c.beginPath(); c.roundRect(x, y, w, Math.max(40, h), 30); c.fill();
+ c.save(); c.beginPath(); c.roundRect(x, y, w, Math.max(40, h), 30); c.clip();
+ const n = Math.floor(Math.max(0, t - b(9) - 0.1) / 0.045), r = U.rng(5);
+ for (let i = 0; i < 22; i++) { const toks = 1 + (r() * 3 | 0), ind = (r() * 3 | 0) * 28; let xx = x + 40 + ind;
+ const yy = y + 40 + i * 26, vis = i < n;
+ for (let k = 0; k < toks; k++) { const ww = 40 + r() * 140; if (vis) { c.fillStyle = COLS[(r() * 6) | 0]; c.beginPath(); c.roundRect(xx, yy, ww, 14, 7); c.fill(); } else r(); xx += ww + 12; } }
+ c.restore();
+ c.fillStyle = C.white; c.beginPath(); c.moveTo(x + 30, y + 4); c.lineTo(x - 10, y - 26); c.lineTo(x + 70, y + 4); c.fill();
+ }
+ });
+ },
+};
+})();
diff --git a/scripts/engine/demos/y5_kinetic_type/k4_agent.js b/scripts/engine/demos/y5_kinetic_type/k4_agent.js
new file mode 100644
index 0000000..938d458
--- /dev/null
+++ b/scripts/engine/demos/y5_kinetic_type/k4_agent.js
@@ -0,0 +1,49 @@
+// K4 阶段三「代理」(第 12 拍起,6.0–8.5s)
+// 第 12 拍主词砸进+巨型「3」→ 12.5 拍「Agent」+任务卡升起 → 第 13 拍辅句「你只说」、13.25 拍「要什么」→
+// 13.5 / 14 / 14.5 拍三条任务自己打勾 → 第 15 拍「要什么」放大+下划线 → 第 16 拍收尾重拍:镜头拉远 6%、整屏一冲,留 0.5s 静住。
+// 返修:第一版高潮最弱——收尾无一击、打完勾全变灰、底部 28% 空着。现在内容整体下移 70px、勾完不变灰、加第 16 拍收尾。
+(() => {
+const K = KT, C = K.C, b = K.b;
+const { clamp } = U;
+const TASKS = [['写代码', 13.5], ['跑测试', 14], ['上线', 14.5]];
+SCENES['k4_agent'] = {
+ draw(c, lt, t) {
+ c.fillStyle = C.paper; c.fillRect(0, 0, 1920, 1080);
+ K.dots(c, t, C.ink, 0.06);
+ const pull = MO.expoOut(MO.at(t, b(16), 0.45)), hit = t >= b(16) ? 0.035 * Math.exp(-(t - b(16)) * 9) : 0;
+ K.cam(c, t, c => {
+ K.bigNum(c, t, '3', b(12), 1880, 1150, 'rgba(17,17,17,0.05)');
+ TY.rise(c, '阶段 03', 140, 300, MO.at(t, b(12), 0.3), { size: K.SZ.label, fam: 'PuHui-Bold', color: C.coral, track: 6 });
+ TY.underline(c, 140, 322, 170, MO.at(t, b(12.25), 0.3), C.coral, 6);
+ K.slam(c, '代理', 130, 650, t, b(12), { color: C.ink });
+ const hw = TY.width(c, '代理', K.SZ.hero);
+ TY.rise(c, 'Agent', 150 + hw, 650, MO.at(t, b(12.5), 0.35), { size: 96, fam: 'PuHui-Black', color: C.coral });
+ const s1 = '你只说', key = '要什么', w1 = TY.width(c, s1, K.SZ.sub, 'PuHui-Heavy'), wk = TY.width(c, key, K.SZ.sub, 'PuHui-Heavy');
+ const ky = 825, kx = 152 + w1;
+ TY.rise(c, s1, 140, ky, MO.at(t, b(13), 0.35), { size: K.SZ.sub, fam: 'PuHui-Heavy', color: C.ink });
+ const ksc = K.key(c, key, kx, ky, t, b(13.25), b(15), { size: K.SZ.sub, fam: 'PuHui-Heavy', color: C.coral });
+ TY.underline(c, kx, ky + 30 * ksc, wk * ksc, MO.at(t, b(15), 0.3), C.coral, 12);
+ // 任务卡:12.5 拍从下方升起
+ const pc = MO.expoOut(MO.at(t, b(12.5), 0.4)); if (pc <= 0) return;
+ c.save(); c.translate(1220, 360 + 260 * (1 - pc)); c.globalAlpha = clamp(pc * 2);
+ c.fillStyle = 'rgba(0,0,0,0.08)'; c.beginPath(); c.roundRect(12, 16, 600, 470, 28); c.fill();
+ c.fillStyle = C.white; c.beginPath(); c.roundRect(0, 0, 600, 470, 28); c.fill();
+ TY.text(c, 'TODO', 50, 80, { size: 40, fam: 'PuHui-Black', color: '#B5AFA4', align: 'left', track: 4 });
+ TASKS.forEach(([s, beat], i) => {
+ const y = 170 + i * 115, ck = MO.at(t, b(beat), 0.22), done = t >= b(beat);
+ // 打勾那一拍框先放大 1.25 再回,勾按弧长画出
+ const bs = done ? 1 + 0.25 * Math.exp(-(t - b(beat)) * 10) * Math.sin(Math.min(Math.PI, (t - b(beat)) * 20)) : 1;
+ c.save(); c.translate(80, y); c.scale(bs, bs);
+ c.fillStyle = done ? C.green : C.paper; c.strokeStyle = done ? C.green : '#CFC7BA'; c.lineWidth = 6;
+ c.beginPath(); c.roundRect(-30, -30, 60, 60, 14); c.fill(); c.stroke();
+ if (ck > 0) { c.strokeStyle = C.white; c.lineWidth = 10; c.lineCap = 'round'; c.lineJoin = 'round';
+ const L1 = Math.hypot(11, 12), L2 = Math.hypot(22, 26), d = MO.expoOut(ck) * (L1 + L2);
+ c.beginPath(); c.moveTo(-15, 0); if (d <= L1) c.lineTo(-15 + 11 * d / L1, 12 * d / L1); else { c.lineTo(-4, 12); const q = (d - L1) / L2; c.lineTo(-4 + 22 * q, 12 - 26 * q); } c.stroke(); }
+ c.restore();
+ TY.text(c, s, 140, y + 24, { size: 66, fam: 'PuHui-Heavy', color: done ? C.green : C.ink, align: 'left' });
+ });
+ c.restore();
+ }, { zoom: (1 - 0.06 * pull) * (1 + hit) });
+ },
+};
+})();
diff --git a/scripts/engine/demos/y5_kinetic_type/kinetic.js b/scripts/engine/demos/y5_kinetic_type/kinetic.js
new file mode 100644
index 0000000..b8381d9
--- /dev/null
+++ b/scripts/engine/demos/y5_kinetic_type/kinetic.js
@@ -0,0 +1,52 @@
+// y5 本片共用:节拍网格、配色、字号阶梯、拍点微冲、进度轨(全片唯一连续的叙事锚)、背景点阵。
+// 一切「落点」都写成拍号:b(4) = 第 4 拍 = 2.0s。120 BPM:一拍 0.5s,八分 0.25s。
+// 用到的库:TY(slam 砸入、rise 遮罩升起、keyword 关键词强调、marker 荧光笔、underline)、CAM(with、drift)、MO(springHz、拍号)。
+(() => {
+const { clamp, lerp } = U;
+window.BPM = 120;
+const K = window.KT = {};
+K.b = n => MO.beat(n, 120); // 拍 → 秒
+const C0 = K.C = { ink: '#111111', paper: '#F4EFE6', yellow: '#FFD23F', coral: '#FF5A36', navy: '#14213D', blue: '#3A86FF', green: '#2BB673', white: '#FFFFFF', code: '#1B1D29' };
+// 字号阶梯:主词 : 辅句 : 标签 ≈ 3.4 : 1 : 0.4(主词必须一眼读完,辅句给耳朵对位)
+K.SZ = { hero: 340, sub: 96, label: 40 };
+// 拍点微冲:每个四分拍让画面放大 1.2%,0.12s 衰减(e^-25t)——画面跟着鼓「呼吸」
+K.bump = t => { const ph = t % 0.5; return 1 + 0.012 * Math.exp(-ph * 25); };
+// 背景点阵:斜向缓慢平移 36px/s(持续运动,低对比 8%,不和字抢)
+K.dots = (c, t, col, alpha = 0.1) => {
+ const g = 64, ox = (t * 36) % g, oy = (t * 18) % g;
+ c.save(); c.globalAlpha = alpha; c.fillStyle = col;
+ for (let y = -g; y < 1080 + g; y += g) for (let x = -g; x < 1920 + g; x += g) { c.beginPath(); c.arc(x + ox, y + oy, 4, 0, Math.PI * 2); c.fill(); }
+ c.restore();
+};
+// 进度轨:右上三格,画在固定层(GLOBAL_OVERLAY),不跟页面一起被推走(返修:第一版画在各段里,推页时跟着跳)。
+// 颜色在转场「揭开」那一帧换(2.0 / 4.0 / 6.0s),亮格同一帧点亮。
+K.STAGES = [2.0, 4.0, 6.0];
+K.trackCol = t => t < 4.0 ? [C0.white, 'rgba(255,255,255,0.35)'] : t < 6.0 ? [C0.yellow, 'rgba(255,255,255,0.25)'] : [C0.coral, 'rgba(17,17,17,0.18)'];
+window.GLOBAL_OVERLAY = (c, t) => {
+ if (t < 2.0) return;
+ const [col, dim] = K.trackCol(t), a = MO.expoOut(clamp((t - 2.0) / 0.3));
+ c.save(); c.globalAlpha = a;
+ for (let i = 0; i < 3; i++) {
+ const x = 1520 + i * 120, y = 92, on = t >= K.STAGES[i], fill = on ? MO.expoOut(clamp((t - K.STAGES[i]) / 0.3)) : 0;
+ c.fillStyle = dim; c.fillRect(x, y, 100, 10); c.fillStyle = col; c.fillRect(x, y, 100 * fill, 10);
+ TY.text(c, '0' + (i + 1), x, y - 18, { size: 30, fam: 'PuHui-Bold', color: on ? col : dim, align: 'left', track: 2 });
+ }
+ c.restore();
+};
+// 背景巨型阶段数字(900px、低对比、斜向慢漂):数字是章节的主角之一,但不和主词抢(返修:审片说 01/02/03 太小,退成了装饰)
+K.bigNum = (c, t, s, t0, x, y, col) => {
+ const lt = t - t0; if (lt < 0) return;
+ const k = MO.springHz(lt, 2.0, 8), sc = lerp(1.35, 1, k);
+ TY.text(c, s, x + lt * 14, y - lt * 10, { size: 900, fam: 'PuHui-Black', align: 'right', color: col, scale: sc, alpha: clamp(lt / 0.08), ox: x - 250, oy: y - 320 });
+};
+// 关键词:先从槽里升起,到「强调拍」再放大 1.35 倍并钉住,荧光笔跟着放大(TY.keyword / TY.keywordMarker)
+K.key = TY.keyword;
+K.keyMarker = TY.keywordMarker;
+// 主词「砸」进来:从 1.7 倍缩到 1(弹簧 2.2Hz/10,过冲 ≈8%),前 0.06s 透明→不透明(TY.slam)
+K.slam = (c, s, x, y, t, t0, o = {}) => TY.slam(c, s, x, y, t - t0, { size: K.SZ.hero, ...o });
+// 镜头:微漂+极慢旋转(±0.5°)+拍点微冲
+K.cam = (c, t, fn, extra = {}) => {
+ const [dx, dy] = CAM.drift(t, 5, 2);
+ CAM.with(c, { x: 960 + dx + (extra.x || 0), y: 540 + dy + (extra.y || 0), z: K.bump(t) * (extra.zoom || 1), r: 0.009 * Math.sin(t * 0.8) + (extra.rot || 0) }, fn);
+};
+})();
diff --git a/scripts/engine/engine.js b/scripts/engine/engine.js
new file mode 100644
index 0000000..c5d09b4
--- /dev/null
+++ b/scripts/engine/engine.js
@@ -0,0 +1,265 @@
+// 引擎:时间 t(秒)→ 一帧画面。确定性:同一个 t 永远画出同一帧(随机数全部用种子)。
+// 时间轴由节拍网格驱动:128 BPM,每段占若干八分音符(见 eras.js 的 eighths)。
+(() => {
+const W = 1920, H = 1080;
+const cv = document.getElementById('c');
+const ctx = cv.getContext('2d');
+window.__canvas = cv;
+
+const EIGHTH = 60 / (window.BPM || 128) / 2; // 0.234375s @128;片子可设 window.BPM
+// 段长:eighths(八分音符数,卡节拍)或 dur(秒,按口播切的解说片)。写了 dur 就以 dur 为准。
+let acc = 0;
+for (const e of ERAS) { e.t0 = acc; acc += e.dur != null ? e.dur : e.eighths * EIGHTH; e.t1 = acc; }
+// 片长 = 最后一段的 t1;window.FILM_DURATION 优先。render.py / 预览都读 window.__total。
+window.__total = window.FILM_DURATION || ERAS[ERAS.length - 1].t1;
+ERAS[ERAS.length - 1].t1 = 1e9;
+
+// 离屏缓冲:A=上一段,B=当前段
+const mk = () => { const c = document.createElement('canvas'); c.width = W; c.height = H; return c; };
+const bufA = mk(), bufB = mk(), bufT = mk();
+window.__mk = mk;
+
+// ---------- 资源 ----------
+const IMG = {};
+function load(src) {
+ return new Promise((res, rej) => { const im = new Image(); im.onload = () => res(im); im.onerror = () => rej(src); im.src = src; });
+}
+async function boot() {
+ if (window.__bootErrors && __bootErrors.length) { window.__bootFailed = __bootErrors.join('\n'); console.error('BOOT FAILED\n' + window.__bootFailed); return; }
+ const list = new Set();
+ for (const e of ERAS) (e.assets || []).concat(e.plate ? [e.plate] : []).forEach(s => list.add(s));
+ (window.EXTRA_ASSETS || []).forEach(s => list.add(s));
+ await Promise.all([...list].map(async s => { IMG[s] = await load(s); }));
+ for (const f of (window.FONT_FACES || [])) { const ff = new FontFace(f.family, `url(${f.url})`, f.desc || {}); await ff.load(); document.fonts.add(ff); }
+ await document.fonts.ready;
+ await U.loadCmaps(); // 字形检查用(U.assertGlyphs)
+ for (const e of ERAS) if (e.init) e.init(IMG);
+ checkCounterGlyphs();
+ window.__ready = true;
+ renderFrame(0);
+}
+window.IMG = IMG;
+
+const U = window.U;
+
+// ---------- 角标(右上角):可插拔 ----------
+// 每段 era.counter 三种写法:
+// 1) 默认:年份计数器 U.yearCounter——数值只由全局时间决定(U.counterAt),跨段连续滚动;label 写风格名。
+// 2) counter.draw(c, lt, t)(别名 counter.custom(c, lt)):自绘。年代不单调、要印章/榜题/漫画旁白框时用。
+// 3) counter.mode = 'tag':U.styleTag 画「年份+风格名」两行静态牌(年代乱序时不滚动)。
+// 转场期间:默认(window.COUNTER_IN_TRANSITION = 'cut')新旧两层都不画角标,转场画完后在最上层按 p<0.5 硬切旧/新角标——
+// 各段角标版式不同时,局部揭示的转场(点灯、扫光、水波)会让两套字叠成一团(迁移测试 C、D 的独立审片都抓到)。
+// 'layers':角标留在各自层里随转场一起变(原片复刻:年份牌位置固定、数字连续滚动,混在一起看不出来)。单个转场可用 transition.counter 覆盖。
+function drawCounter(c, e, t) {
+ const ct = e.counter; if (!ct) return;
+ const lt = t - e.t0;
+ if (ct.draw) ct.draw(c, lt, t);
+ else if (ct.custom) ct.custom(c, lt);
+ else if (ct.mode === 'tag') U.styleTag(c, ct, lt);
+ else { const cv = U.counterAt(t); U.yearCounter(c, ct, cv.v, cv.rolling, lt); }
+}
+// 启动时检查角标用到的字形(缺字静默回退系统字体是迁移测试 B、D 都踩过的坑)。自绘角标的字请在 scene.init 里自己 U.assertGlyphs。
+function checkCounterGlyphs() {
+ for (const e of ERAS) { const ct = e.counter; if (!ct || ct.draw || ct.custom) continue;
+ if (ct.mode === 'tag') { if (ct.name) U.assertGlyphs(ct.nameFont || ct.font, ct.name, e.id + ' 角标'); if (ct.sub) U.assertGlyphs(ct.subFont || ct.nameFont || ct.font, ct.sub, e.id + ' 角标'); continue; }
+ U.assertGlyphs(ct.font, '0123456789' + (Math.abs(ct.year) >= 10000 ? ',' : ''), e.id + ' 年份');
+ if (ct.label) U.assertGlyphs(ct.label.font, ct.label.text, e.id + ' 角标');
+ if (ct.suffix) U.assertGlyphs(ct.suffix.font || ct.font, 'BCAD', e.id + ' 角标后缀');
+ }
+}
+// 「年份+风格名」静态牌:{ year, name, sub?, x, y, font, size, color, nameFont, nameColor, subFont, subColor, box(c,lt), shadow, align }
+U.styleTag = function (c, ct, lt) {
+ if (ct.box) ct.box(c, lt);
+ c.save(); c.textAlign = ct.align || 'right'; c.textBaseline = 'alphabetic';
+ if (ct.shadow) { c.shadowColor = ct.shadow.color; c.shadowBlur = ct.shadow.blur || 0; c.shadowOffsetX = ct.shadow.x || 0; c.shadowOffsetY = ct.shadow.y || 0; }
+ const x = ct.x ?? 1866, y = ct.y ?? 128;
+ if (ct.year != null) { c.font = `${ct.size || 96}px "${U.fontFamily(ct.font)}"`; c.fillStyle = ct.color || '#fff'; c.fillText(ct.yearText || (ct.year < 0 ? U.fmtYear(ct.year) + ' BC' : String(ct.year)), x, y); }
+ if (ct.name) { c.font = ct.nameFont || `34px "${U.fontFamily(ct.font)}"`; c.fillStyle = ct.nameColor || ct.color || '#fff'; c.fillText(ct.name, x, ct.ny ?? y + 52); }
+ if (ct.sub) { c.font = ct.subFont || ct.nameFont; c.fillStyle = ct.subColor || ct.nameColor || ct.color; c.fillText(ct.sub, x, ct.sy ?? y + 92); }
+ c.restore();
+};
+
+// ---------- 年份计数器(里程表逐位滚动) ----------
+// from/to 是数值;fmt 把数值格式化成字符串;滚动时每一位独立从旧字符滚到新字符,低位先动、错开 stagger。
+U.odometer = function (c, opt, p) {
+ const { x, y, size, font, color, fromStr, toStr, align = 'right', stagger = 0.12, spacing = 0, shadow } = opt;
+ c.save();
+ c.font = `${size}px ${font}`;
+ c.textBaseline = 'alphabetic';
+ c.fillStyle = color;
+ const n = Math.max(fromStr.length, toStr.length);
+ const a = fromStr.padStart(n, ' '), b = toStr.padStart(n, ' ');
+ const widths = [...b].map(ch => c.measureText(ch === ' ' ? '0' : ch).width + spacing);
+ const total = widths.reduce((s, w) => s + w, 0) - spacing;
+ let cx = align === 'right' ? x - total : align === 'center' ? x - total / 2 : x;
+ for (let i = 0; i < n; i++) {
+ const order = n - 1 - i; // 低位先滚
+ const pi = U.clamp((p - order * stagger) / Math.max(0.0001, 1 - (n - 1) * stagger));
+ const e = U.ease.inOut(pi);
+ const w = widths[i];
+ c.save();
+ c.beginPath(); c.rect(cx - 4, y - size * 1.05, w + 8, size * 1.35); c.clip();
+ if (shadow) { c.shadowColor = shadow.color; c.shadowBlur = shadow.blur || 0; c.shadowOffsetX = shadow.x || 0; c.shadowOffsetY = shadow.y || 0; }
+ if (a[i] === b[i]) c.fillText(b[i], cx, y);
+ else {
+ const dy = size * 1.1 * e;
+ c.globalAlpha = 1 - e * 0.6; if (a[i] !== ' ') c.fillText(a[i], cx, y - dy);
+ c.globalAlpha = 0.4 + e * 0.6; if (b[i] !== ' ') c.fillText(b[i], cx, y + size * 1.1 - dy);
+ }
+ c.restore();
+ cx += w;
+ }
+ c.restore();
+};
+
+// ---------- 年份计数器:数值插值(ease-out)+个位数滚动残影 ----------
+// ct: {year, x, y, size, font, color, suffix:{font,size,color,dy,gap}, label:{text,font,color,x,y,spacing}, box(c), shadow, spacing}
+U.fmtYear = (v) => { const a = Math.abs(Math.round(v)); return a >= 10000 ? a.toLocaleString('en-US') : String(a); };
+// 计数器的值只由全局时间决定:转场中新旧两层显示同一个数字
+U.counterAt = function (t) {
+ let k = 0; for (let i = 0; i < ERAS.length; i++) if (t >= ERAS[i].t0) k = i;
+ const cur = ERAS[k].counter, prv = k ? ERAS[k - 1].counter : cur;
+ const p = cur.roll ? U.clamp((t - ERAS[k].t0 - 0.03) / cur.roll) : 1;
+ return { v: prv.year + (cur.year - prv.year) * U.ease.inOut(p), rolling: p > 0 && p < 1 };
+};
+U.yearCounter = function (c, ct, v, rolling, lt) {
+ if (ct.box) ct.box(c, lt);
+ const vi = Math.round(v);
+ const str = U.fmtYear(vi);
+ const era = v < 0 ? 'BC' : 'AD';
+ c.save();
+ c.textBaseline = 'alphabetic';
+ if (ct.shadow) { c.shadowColor = ct.shadow.color; c.shadowBlur = ct.shadow.blur || 0; c.shadowOffsetX = ct.shadow.x || 0; c.shadowOffsetY = ct.shadow.y || 0; }
+ let x = ct.x;
+ // 后缀(BC/AD)
+ const sfx = ct.suffix && (ct.suffix.show === 'always' || (ct.suffix.show !== 'never')) ? ((ct.suffix.text === 'BC' || ct.suffix.text === 'AD') ? era : (ct.suffix.text || era)) : '';
+ if (sfx) {
+ c.font = `${ct.suffix.size}px "${ct.suffix.font || ct.font}"`; c.fillStyle = ct.suffix.color || ct.color; c.textAlign = 'right';
+ c.fillText(sfx, x, ct.y + (ct.suffix.dy || 0));
+ x -= c.measureText(sfx).width + (ct.suffix.gap || 12);
+ }
+ c.font = `${ct.size}px "${ct.font}"`; c.fillStyle = ct.color; c.textAlign = 'left';
+ if (ct.spacing) c.letterSpacing = ct.spacing + 'px';
+ const w = c.measureText(str).width - (ct.spacing || 0);
+ const x0 = x - w;
+ // 滚动中:除个位外照常画,个位画成上下滚动
+ if (rolling) {
+ const head = str.slice(0, -1), last = str.slice(-1);
+ c.fillText(head, x0, ct.y);
+ const hw = head ? c.measureText(head).width : 0;
+ const frac = (Math.abs(v) % 1);
+ const lw = c.measureText(last).width;
+ c.save(); c.beginPath(); c.rect(x0 + hw - 2, ct.y - ct.size * 1.0, lw + 30, ct.size * 1.25); c.clip();
+ c.fillText(last, x0 + hw, ct.y - frac * ct.size * 0.3);
+ c.globalAlpha = 0.35; c.fillText(String((+last + 1) % 10), x0 + hw, ct.y - ct.size * 0.85 - frac * ct.size * 0.3);
+ c.restore();
+ } else c.fillText(str, x0, ct.y);
+ c.restore();
+ if (ct.label) {
+ const L = ct.label; c.save(); c.font = L.font; c.fillStyle = L.color; c.textAlign = L.align || 'right'; c.textBaseline = 'alphabetic';
+ if (L.spacing) c.letterSpacing = L.spacing + 'px';
+ if (L.shadow) { c.shadowColor = L.shadow.color; c.shadowBlur = L.shadow.blur || 0; c.shadowOffsetX = L.shadow.x || 0; c.shadowOffsetY = L.shadow.y || 0; }
+ if (L.gradient) { const g = c.createLinearGradient(0, L.y - 30, 0, L.y); L.gradient.forEach((col, i) => g.addColorStop(i / (L.gradient.length - 1), col)); c.fillStyle = g; }
+ c.fillText(L.text, (L.x || ct.x) + (L.spacing && (L.align || 'right') === 'right' ? L.spacing : 0), L.y); c.restore();
+ }
+};
+
+// ---------- 热气(通用:多条正弦卷曲的半透明笔触) ----------
+U.steam = function (c, t, { x, y, h = 70, n = 3, w = 3, color = 'rgba(255,255,255,.8)', spread = 14, speed = 1, seed = 1, wobble = 8 }) {
+ c.save(); c.strokeStyle = color; c.lineCap = 'round'; c.lineWidth = w;
+ for (let k = 0; k < n; k++) {
+ const ox = (k - (n - 1) / 2) * spread;
+ const ph = t * 2.2 * speed + k * 1.7 + seed;
+ c.beginPath();
+ for (let s = 0; s <= 24; s++) {
+ const q = s / 24, yy = y - q * h, xx = x + ox + Math.sin(ph + q * 5) * wobble * q;
+ c.globalAlpha = 1;
+ s ? c.lineTo(xx, yy) : c.moveTo(xx, yy);
+ }
+ const g = c.createLinearGradient(0, y, 0, y - h); g.addColorStop(0, color); g.addColorStop(1, 'rgba(255,255,255,0)');
+ c.strokeStyle = g; c.stroke();
+ }
+ c.restore();
+};
+
+// ---------- 视频层:每个时代可挂一段帧序列(clips/<id>/%04d.jpg),按需异步加载 ----------
+// clip: {dir, fps, n, in, speed, loop} 本段局部时间 lt → 片内时间 in + lt*speed → 帧号
+const FRAMES = new Map(); // url -> Image(已 decode)
+function clipFrameUrl(e, lt) {
+ const c = e.clip; let ct = (c.in || 0) + Math.max(0, lt) * (c.speed || 1);
+ let i = Math.round(ct * c.fps);
+ if (c.loop === 'pingpong') { const m = 2 * (c.n - 1); i = i % m; if (i >= c.n) i = m - i; } else i = Math.min(c.n - 1, i);
+ return `${c.dir}/${String(i + 1).padStart(4, '0')}.jpg`;
+}
+async function need(url) {
+ if (FRAMES.has(url)) return;
+ const im = new Image(); im.src = url; await im.decode(); FRAMES.set(url, im);
+ if (FRAMES.size > 240) { const k = FRAMES.keys().next().value; FRAMES.delete(k); }
+}
+function layersAt(t) {
+ let k = ERAS.findIndex(e => t >= e.t0 && t < e.t1); if (k < 0) k = ERAS.length - 1;
+ const out = [k]; const e = ERAS[k];
+ if (k > 0 && e.transition && t - e.t0 < e.transition.dur + (e.transition.delay || 0)) out.push(k - 1);
+ return out;
+}
+window.prepare = async function (t) {
+ await Promise.all(layersAt(t).map(k => ERAS[k].clip ? need(clipFrameUrl(ERAS[k], t - ERAS[k].t0)) : null));
+};
+
+// ---------- 画一个时代(本段局部时间 lt) ----------
+function drawEra(c, e, t, prev, punchFrom, noCounter) {
+ const lt = t - e.t0;
+ c.save();
+ c.clearRect(0, 0, W, H);
+ // 拍点镜头冲击(只作用于场景层,年份牌不缩放):s(k)=1+0.03·(1-k/20)^1.5,k=转场开始后的帧数
+ // 冲击跟「正在进来的那一段」的转场起点走:转场期间旧段也一起放大(原片拍点那一帧整屏都在冲)
+ const pe = punchFrom || e;
+ // 幅度:transition.punch(数字;false/0 关掉)> 片级 window.PUNCH > 0.03。解说/发布会/数据片不要这一下,写 window.PUNCH = 0。
+ const pa = pe.transition ? (pe.transition.punch ?? window.PUNCH ?? 0.03) : 0, amp = pa === true ? 0.03 : +pa || 0;
+ const k60 = amp ? (t - pe.t0) * 60 : 99;
+ const punch = k60 >= 0 && k60 < 20 ? 1 + amp * Math.pow(1 - k60 / 20, 1.5) : 1;
+ c.save(); if (punch !== 1) { c.translate(W / 2, H / 2); c.scale(punch, punch); c.translate(-W / 2, -H / 2); }
+ if (e.clip) { const im = FRAMES.get(clipFrameUrl(e, lt)); if (im) c.drawImage(im, 0, 0, W, H); else if (e.plate) c.drawImage(IMG[e.plate], 0, 0, W, H); }
+ else if (e.plate && !e.draw) c.drawImage(IMG[e.plate], 0, 0, W, H);
+ if (e.draw) e.draw(c, lt, t, IMG, prev);
+ c.restore();
+ if (!noCounter) drawCounter(c, e, t);
+ c.restore();
+}
+
+// ---------- 主渲染 ----------
+function renderFrame(t) {
+ let k = ERAS.findIndex(e => t >= e.t0 && t < e.t1); if (k < 0) k = ERAS.length - 1;
+ const e = ERAS[k], prev = ERAS[k - 1];
+ const tr = e.transition;
+ const trDur = tr ? tr.dur + (tr.delay || 0) : 0;
+ const lt = t - e.t0;
+ if (prev && tr && lt < trDur) {
+ const cut = (tr.counter || window.COUNTER_IN_TRANSITION || 'cut') === 'cut';
+ drawEra(bufA.getContext('2d'), prev, t, ERAS[k - 2], e, cut);
+ drawEra(bufB.getContext('2d'), e, t, prev, undefined, cut);
+ const p = U.clamp((lt - (tr.delay || 0)) / tr.dur);
+ ctx.save(); ctx.clearRect(0, 0, W, H);
+ // o.id / o.from = 进入段 / 离开段的 id:依赖画面内容的转场缓存要带上它(transitions.js 的 once(k, f, o))
+ TRANSITIONS[tr.type](ctx, bufA, bufB, p, { ...tr, id: e.id, from: prev.id, lt, t, W, H, tmp: bufT, IMG });
+ ctx.restore();
+ if (cut) drawCounter(ctx, p < 0.5 ? prev : e, t);
+ } else {
+ drawEra(ctx, e, t, prev);
+ }
+ if (window.GLOBAL_OVERLAY) window.GLOBAL_OVERLAY(ctx, t);
+ return k;
+}
+window.renderFrame = renderFrame;
+// 单段预览:opt.counter = false 不画角标(自检量帧差时计数器滚动会抬高数字——迁移测试 B)
+window.renderSolo = function (id, lt, opt = {}) { const e = ERAS.find(x => x.id === id); if (!e) throw new Error('renderSolo: 没有这一段 ' + id); const k = ERAS.indexOf(e); drawEra(ctx, e, e.t0 + lt, ERAS[k - 1], undefined, opt.counter === false); };
+
+// ---------- 预览 UI ----------
+if (location.search.includes('render=1')) document.body.classList.add('render');
+const scrub = document.getElementById('scrub'), tt = document.getElementById('tt'); scrub.max = window.__total;
+let playing = false, t0 = 0, base = 0;
+scrub.oninput = () => { playing = false; renderFrame(+scrub.value); tt.textContent = (+scrub.value).toFixed(3); };
+document.getElementById('play').onclick = () => { playing = !playing; t0 = performance.now(); base = +scrub.value; if (playing) loop(); };
+function loop() { if (!playing) return; let t = base + (performance.now() - t0) / 1000; if (t > window.__total) { t = 0; base = 0; t0 = performance.now(); } scrub.value = t; tt.textContent = t.toFixed(3); renderFrame(t); requestAnimationFrame(loop); }
+boot().catch(err => { console.error('boot failed', err); });
+})();
diff --git a/scripts/engine/eras.js b/scripts/engine/eras.js
new file mode 100644
index 0000000..72e6f9f
--- /dev/null
+++ b/scripts/engine/eras.js
@@ -0,0 +1,60 @@
+// 纯代码版:每个时代的画面由 scenes/<id>.js 的 draw(c, lt, t) 程序化绘制。
+// 15 个时代 + 2026 结尾。eighths = 本段占几个八分音符(128 BPM,见 references/风格配方/_音轨_艺术史速通.md)。
+const R = 1866; // 右对齐基准
+const box = (x0, y0, x1, y1, fill, stroke, lw = 4, inset = 0) => c => {
+ c.save(); c.fillStyle = fill; c.fillRect(x0, y0, x1 - x0, y1 - y0);
+ if (stroke) { c.strokeStyle = stroke; c.lineWidth = lw; c.strokeRect(x0 + inset, y0 + inset, x1 - x0 - 2 * inset, y1 - y0 - 2 * inset); }
+ c.restore();
+};
+// 原片复刻:年份牌位置固定、数字连续滚动,转场时角标留在新旧两层里一起变(engine 默认是转场中点硬切,见 drawCounter)
+window.COUNTER_IN_TRANSITION = 'layers';
+window.ERAS = [
+ { id: '01_cave', eighths: 6,
+ counter: { year: -40000, roll: 0, x: R, y: 114, size: 84, font: 'GochiHand-400', color: '#f3ead8', spacing: 14,
+ suffix: { text: 'BC', size: 44, gap: 18, dy: 0 }, label: { text: 'Cave painting', font: '38px "Kalam-700"', color: '#efe4cf', y: 178 } } },
+ { id: '02_egypt', eighths: 4, transition: { type: 'tiles', dur: 0.42, delay: 0 },
+ counter: { year: -1350, roll: 0.45, x: R, y: 129, size: 100, font: 'IMFellEnglish-400', color: '#6b2318', spacing: 6,
+ suffix: { text: 'BC', size: 50, gap: 14 }, label: { text: 'Egyptian wall painting', font: '34px "EBGaramond-400"', color: '#4a3424', y: 186 } } },
+ { id: '03_greek', eighths: 4, transition: { type: 'cube', dur: 0.32, delay: 0 },
+ counter: { year: -530, roll: 0.47, x: 1855, y: 136, size: 98, font: 'Cinzel-700', color: '#e3a066',
+ box: box(1544, 42, 1888, 208, '#1b1310', '#c8743c', 3, 4),
+ suffix: { text: 'BC', size: 48, gap: 14 }, label: { text: 'ATTIC BLACK-FIGURE', font: '29px "Cinzel-700"', color: '#e8b27c', x: 1855, y: 184, spacing: 2 } } },
+ { id: '04_roman', eighths: 4, transition: { type: 'mosaic', dur: 0.38, delay: 0 },
+ counter: { year: 79, roll: 0.43, x: 1852, y: 132, size: 96, font: 'Cinzel-400', color: '#1d1a17',
+ box: box(1607, 40, 1888, 208, '#f4ede0', '#2b2724', 4, 0),
+ suffix: { text: 'AD', size: 46, gap: 18 }, label: { text: 'ROMAN MOSAIC', font: '26px "Cinzel-400"', color: '#2b2724', x: 1860, y: 182, spacing: 2 } } },
+ { id: '05_gothic', eighths: 4, transition: { type: 'pageTurn', dur: 0.32, delay: 0 },
+ counter: { year: 1290, roll: 0.45, x: R, y: 134, size: 100, font: 'LibreBaskerville-700', color: '#b3222b',
+ label: { text: 'Gothic illumination', font: '36px "IMFellEnglish-400"', color: '#2b211a', y: 184 } } },
+ { id: '06_renaissance', eighths: 4, transition: { type: 'godRays', dur: 0.4, delay: 0, cx: 560, cy: 290 },
+ counter: { year: 1503, roll: 0.42, x: R, y: 142, size: 104, font: 'CormorantGaramond-500', color: '#ece0bf', spacing: 22,
+ label: { text: 'HIGH RENAISSANCE', font: '30px "Cinzel-700"', color: '#e7d9b4', y: 184, spacing: 2 } } },
+ { id: '08_impressionism', eighths: 3, transition: { type: 'dabs', dur: 0.28, delay: 0 },
+ counter: { year: 1874, roll: 0.37, x: R, y: 139, size: 104, font: 'PlayfairDisplay-400i', color: '#5a4f9a',
+ label: { text: 'Impressionism', font: '30px "EBGaramond-600"', color: '#6a5a9a', y: 182 } } },
+ { id: '09_postimp', eighths: 3, transition: { type: 'swirl', dur: 0.28, delay: 0, cx: 560, cy: 340 },
+ counter: { year: 1889, roll: 0.34, x: R, y: 134, size: 104, font: 'LilitaOne-400', color: '#f5d03b', shadow: { color: '#2a2a6a', x: 3, y: 4 },
+ label: { text: 'Post-Impressionism', font: '34px "LilitaOne-400"', color: '#f5d03b', y: 182, shadow: { color: '#2a2a6a', x: 2, y: 3 } } } },
+ { id: '10_nouveau', eighths: 3, transition: { type: 'organic', dur: 0.24, delay: 0, cx: 1330, cy: 320 },
+ counter: { year: 1896, roll: 0.37, x: R, y: 134, size: 96, font: 'LibreBaskerville-700', color: '#3a2a1c',
+ label: { text: 'ART NOUVEAU POSTER', font: '29px "EBGaramond-600"', color: '#3a2a1c', y: 182, spacing: 3 } } },
+ { id: '11_cubism', eighths: 2, transition: { type: 'shards', dur: 0.24, delay: 0 },
+ counter: { year: 1912, roll: 0.23, x: R, y: 134, size: 98, font: 'AlfaSlabOne-400', color: '#1e1b18', spacing: 4,
+ label: { text: 'CUBISM', font: '27px "AlfaSlabOne-400"', color: '#1e1b18', y: 182, spacing: 3 } } },
+ { id: '12_bauhaus', eighths: 2, transition: { type: 'bauhaus', dur: 0.2, delay: 0, cx: 1330, cy: 590 },
+ counter: { year: 1923, roll: 0.2, x: R, y: 134, size: 104, font: 'ArchivoBlack-400', color: '#151515',
+ label: { text: 'bauhaus', font: '36px "Poppins-800"', color: '#c4202b', y: 184 } } },
+ { id: '13_pop', eighths: 2, transition: { type: 'zigzag', dur: 0.16, delay: 0 },
+ counter: { year: 1962, roll: 0.22, x: 1852, y: 144, size: 104, font: 'Anton-400', color: '#111',
+ box: c => { c.save(); c.fillStyle = '#111'; c.fillRect(1637, 40, 253, 170); c.fillStyle = '#f7e23a'; c.fillRect(1643, 46, 241, 158); c.restore(); },
+ label: { text: 'POP ART', font: '30px "Anton-400"', color: '#111', x: 1852, y: 192, spacing: 1 } } },
+ { id: '14_8bit', eighths: 1, transition: { type: 'pixelate', dur: 0.12, delay: 0 },
+ counter: { year: 1985, roll: 0.07, x: R + 4, y: 86, size: 60, font: 'PressStart2P-400', color: '#ffffff', shadow: { color: '#0b1d24', x: 4, y: 4 },
+ label: { text: '8-BIT', font: '30px "PressStart2P-400"', color: '#ffffff', y: 138, shadow: { color: '#0b1d24', x: 3, y: 3 } } } },
+ { id: '15_raytrace', eighths: 1, transition: { type: 'wireframe', dur: 0.14, delay: 0 },
+ counter: { year: 1993, roll: 0.07, x: R, y: 129, size: 104, font: 'Exo2-800i', color: '#ffffff', shadow: { color: '#d23aa6', x: 5, y: 5 },
+ label: { text: 'RAY-TRACED CGI', font: '30px "Exo2-800i"', gradient: ['#ffd84a', '#f08a2a'], y: 182, shadow: { color: '#7a2a7a', x: 2, y: 2 } } } },
+ { id: '16_2026', eighths: 1 + 9 + 8, dur: 4.28, finale: true, transition: { type: 'iris', dur: 0.183, delay: 0 },
+ counter: { year: 2026, roll: 0.4, x: R, y: 132, size: 100, font: 'Poppins-800', color: '#232a5c',
+ label: { text: 'Flat vector illustration', font: '30px "Poppins-600"', color: '#e2554e', y: 182 } } },
+];
diff --git a/scripts/engine/eras_gallery.js b/scripts/engine/eras_gallery.js
new file mode 100644
index 0000000..4134281
--- /dev/null
+++ b/scripts/engine/eras_gallery.js
@@ -0,0 +1,115 @@
+// 全风格样片:skill 里 35 种风格(15 原段+迁移测试 A–D 的 20 段)各一段,按年代排,用作回归测试与风格目录。
+// 打开:index.html?film=gallery 渲染:render.py --film gallery 验收:qa.py --project scripts/engine --film gallery
+// 每段 5 个八分音符(128 BPM ≈ 1.17s),最后一段 6 个。相邻段用「进入段」的签名转场(原 16 段沿用原片转场,A–D 组用各自配方卡里的转场;
+// 每组第一段原来在片头没有进入转场,样片补了 inkBloom / redWedge / comicPanels / chiaroscuro)。
+// 角标:年份严格单调,所以全片一个年份计数器连续滚动;各段沿用自己风格的字体与版式,label 写风格名。转场中点硬切新旧角标(引擎默认)。
+// name 字段只给总览图/文档用(「年份+风格名」),引擎不读。
+const R = 1866;
+const box = (x0, y0, x1, y1, fill, stroke, lw = 4, inset = 0) => c => {
+ c.save(); c.fillStyle = fill; c.fillRect(x0, y0, x1 - x0, y1 - y0);
+ if (stroke) { c.strokeStyle = stroke; c.lineWidth = lw; c.strokeRect(x0 + inset, y0 + inset, x1 - x0 - 2 * inset, y1 - y0 - 2 * inset); }
+ c.restore();
+};
+window.ERAS = [
+ { id: '01_cave', name: '洞穴壁画', eighths: 5,
+ counter: { year: -40000, roll: 0, x: R, y: 114, size: 84, font: 'GochiHand-400', color: '#f3ead8', spacing: 14,
+ suffix: { text: 'BC', size: 44, gap: 18, dy: 0 }, label: { text: 'Cave painting', font: '38px "Kalam-700"', color: '#efe4cf', y: 178 } } },
+ { id: '02_egypt', name: '古埃及壁画', eighths: 5, transition: { type: 'tiles', dur: 0.42 },
+ counter: { year: -1350, roll: 0.4, x: R, y: 129, size: 100, font: 'IMFellEnglish-400', color: '#6b2318', spacing: 6,
+ suffix: { text: 'BC', size: 50, gap: 14 }, label: { text: 'Egyptian wall painting', font: '34px "EBGaramond-400"', color: '#4a3424', y: 186 } } },
+ { id: '03_greek', name: '古希腊黑绘陶', eighths: 5, transition: { type: 'cube', dur: 0.32 },
+ counter: { year: -530, roll: 0.4, x: 1855, y: 136, size: 98, font: 'Cinzel-700', color: '#e3a066',
+ box: box(1544, 42, 1888, 208, '#1b1310', '#c8743c', 3, 4),
+ suffix: { text: 'BC', size: 48, gap: 14 }, label: { text: 'ATTIC BLACK-FIGURE', font: '29px "Cinzel-700"', color: '#e8b27c', x: 1855, y: 184, spacing: 2 } } },
+ { id: '04_roman', name: '罗马马赛克', eighths: 5, transition: { type: 'mosaic', dur: 0.38 },
+ counter: { year: 79, roll: 0.4, x: 1852, y: 132, size: 96, font: 'Cinzel-400', color: '#1d1a17',
+ box: box(1607, 40, 1888, 208, '#f4ede0', '#2b2724', 4, 0),
+ suffix: { text: 'AD', size: 46, gap: 18 }, label: { text: 'ROMAN MOSAIC', font: '26px "Cinzel-400"', color: '#2b2724', x: 1860, y: 182, spacing: 2 } } },
+ { id: '20_dunhuang', name: '敦煌壁画', eighths: 5, transition: { type: 'apsara', dur: 0.5 },
+ counter: { year: 720, roll: 0.4, x: 1852, y: 132, size: 92, font: 'LXGWWenKai-500', color: '#2a1a14', box: box(1500, 44, 1880, 204, '#e6d6b2', '#5a2414', 4, 6), suffix: { text: 'AD', size: 40, gap: 14, font: 'Cinzel-700' }, label: { text: '敦煌壁画 · 盛唐', font: '34px "LXGWWenKai-500"', color: '#8a2a1c', x: 1852, y: 184, spacing: 4 } } },
+ { id: '34_shadowpuppet', name: '皮影戏', eighths: 5, transition: { type: 'lampGlow', dur: 0.4, cx: 960, cy: 470 },
+ counter: { year: 1050, roll: 0.4, x: R, y: 132, size: 96, font: 'LXGWWenKai-500', color: '#7a1d12', spacing: 4, suffix: { text: 'AD', size: 40, gap: 14, font: 'Cinzel-700' }, label: { text: '皮影戏 · 北宋', font: '36px "LXGWWenKai-500"', color: '#5a2a14', y: 184, spacing: 4 } } },
+ { id: '05_gothic', name: '哥特手抄本', eighths: 5, transition: { type: 'pageTurn', dur: 0.32 },
+ counter: { year: 1290, roll: 0.4, x: R, y: 134, size: 100, font: 'LibreBaskerville-700', color: '#b3222b',
+ label: { text: 'Gothic illumination', font: '36px "IMFellEnglish-400"', color: '#2b211a', y: 184 } } },
+ { id: '06_renaissance', name: '文艺复兴', eighths: 5, transition: { type: 'godRays', dur: 0.4, cx: 560, cy: 290 },
+ counter: { year: 1503, roll: 0.4, x: R, y: 142, size: 104, font: 'CormorantGaramond-500', color: '#ece0bf', spacing: 22,
+ label: { text: 'HIGH RENAISSANCE', font: '30px "Cinzel-700"', color: '#e7d9b4', y: 184, spacing: 2 } } },
+ { id: '32_rembrandt', name: '伦勃朗明暗法', eighths: 5, transition: { type: 'chiaroscuro', dur: 0.45, cx: 580, cy: 300 },
+ counter: { year: 1642, roll: 0.4, x: R, y: 134, size: 104, font: 'CormorantGaramond-500', color: '#e9c98a', spacing: 10, label: { text: 'Rembrandt · chiaroscuro', font: '34px "IMFellEnglish-400i"', color: '#c9a467', y: 184 } } },
+ { id: '17_ink', name: '水墨写意', eighths: 5, transition: { type: 'inkBloom', dur: 0.45, cx: 560, cy: 740 },
+ counter: { year: 1690, roll: 0.4, x: R, y: 132, size: 100, font: 'LXGWWenKai-500', color: '#1a1612', spacing: 4, label: { text: '水墨写意 · 八大山人', font: '38px "LXGWWenKai-500"', color: '#3a2c22', y: 186, spacing: 4 } } },
+ { id: '08_impressionism', name: '印象派', eighths: 5, transition: { type: 'dabs', dur: 0.28 },
+ counter: { year: 1874, roll: 0.4, x: R, y: 139, size: 104, font: 'PlayfairDisplay-400i', color: '#5a4f9a',
+ label: { text: 'Impressionism', font: '30px "EBGaramond-600"', color: '#6a5a9a', y: 182 } } },
+ { id: '29_seurat', name: '修拉点彩', eighths: 5, transition: { type: 'pointill', dur: 0.34 },
+ counter: { year: 1884, roll: 0.4, x: R, y: 134, size: 100, font: 'Marcellus-400', color: '#20306a', spacing: 6,
+ label: { text: 'SEURAT · LA GRANDE JATTE', font: '27px "Marcellus-400"', color: '#7a3a2a', y: 182, spacing: 2 } } },
+ { id: '09_postimp', name: '后印象派(梵高)', eighths: 5, transition: { type: 'swirl', dur: 0.28, cx: 560, cy: 340 },
+ counter: { year: 1889, roll: 0.4, x: R, y: 134, size: 104, font: 'LilitaOne-400', color: '#f5d03b', shadow: { color: '#2a2a6a', x: 3, y: 4 },
+ label: { text: 'Post-Impressionism', font: '34px "LilitaOne-400"', color: '#f5d03b', y: 182, shadow: { color: '#2a2a6a', x: 2, y: 3 } } } },
+ { id: '19_munch', name: '蒙克表现主义', eighths: 5, transition: { type: 'screamWarp', dur: 0.5 },
+ counter: { year: 1893, roll: 0.4, x: R, y: 134, size: 100, font: 'IMFellEnglish-400', color: '#f6c040', shadow: { color: 'rgba(40,10,20,.6)', x: 4, y: 4 }, label: { text: 'Munch · The Scream', font: '38px "IMFellEnglish-400i"', color: '#f8d88a', y: 184, shadow: { color: 'rgba(40,10,20,.6)', x: 2, y: 3 } } } },
+ { id: '10_nouveau', name: '新艺术运动海报', eighths: 5, transition: { type: 'organic', dur: 0.24, cx: 1330, cy: 320 },
+ counter: { year: 1896, roll: 0.4, x: R, y: 134, size: 96, font: 'LibreBaskerville-700', color: '#3a2a1c',
+ label: { text: 'ART NOUVEAU POSTER', font: '29px "EBGaramond-600"', color: '#3a2a1c', y: 182, spacing: 3 } } },
+ { id: '28_monet', name: '莫奈睡莲', eighths: 5, transition: { type: 'ripple', dur: 0.34, cx: 1000, cy: 600 },
+ counter: { year: 1899, roll: 0.4, x: R, y: 136, size: 104, font: 'PlayfairDisplay-400i', color: '#3e5a86', spacing: 4, shadow: { color: 'rgba(252,248,238,1)', blur: 18, x: 0, y: 0 },
+ label: { text: 'Monet · Nymphéas', font: '36px "PlayfairDisplay-400i"', color: '#4a5f8e', y: 186, shadow: { color: 'rgba(252,248,238,1)', blur: 14, x: 0, y: 0 } } } },
+ { id: '36_picasso_blue', name: '毕加索蓝色时期', eighths: 5, transition: { type: 'blueBrush', dur: 0.42 },
+ counter: { year: 1903, roll: 0.4, x: R, y: 136, size: 108, font: 'Caveat-600', color: '#c9d6e4', label: { text: 'Picasso · période bleue', font: '38px "Caveat-600"', color: '#9fb3cc', y: 188 } } },
+ { id: '18_klimt', name: '克里姆特金色时期', eighths: 5, transition: { type: 'goldLeaf', dur: 0.5, cx: 1300, cy: 380 },
+ counter: { year: 1907, roll: 0.4, x: R, y: 134, size: 100, font: 'Marcellus-400', color: '#f6dc8a', shadow: { color: 'rgba(40,24,6,.7)', x: 3, y: 4, blur: 6 }, label: { text: '克里姆特 · 金色时期', font: '36px "LXGWWenKai-500"', color: '#f3d27a', y: 186, shadow: { color: 'rgba(40,24,6,.7)', x: 2, y: 3, blur: 4 } } } },
+ { id: '11_cubism', name: '立体主义', eighths: 5, transition: { type: 'shards', dur: 0.24 },
+ counter: { year: 1912, roll: 0.4, x: R, y: 134, size: 98, font: 'AlfaSlabOne-400', color: '#1e1b18', spacing: 4,
+ label: { text: 'CUBISM', font: '27px "AlfaSlabOne-400"', color: '#1e1b18', y: 182, spacing: 3 } } },
+ { id: '12_bauhaus', name: '包豪斯', eighths: 5, transition: { type: 'bauhaus', dur: 0.2, cx: 1330, cy: 590 },
+ counter: { year: 1923, roll: 0.4, x: R, y: 134, size: 104, font: 'ArchivoBlack-400', color: '#151515',
+ label: { text: 'bauhaus', font: '36px "Poppins-800"', color: '#c4202b', y: 184 } } },
+ { id: '22_constructivism', name: '构成主义海报', eighths: 5, transition: { type: 'redWedge', dur: 0.4 },
+ counter: { year: 1924, roll: 0.4, x: R, y: 132, size: 104, font: 'Anton-400', color: '#151311',
+ box: c => { c.save(); c.fillStyle = '#c8231c'; c.beginPath(); c.moveTo(1560, 46); c.lineTo(1892, 30); c.lineTo(1892, 152); c.lineTo(1560, 160); c.closePath(); c.fill(); c.restore(); },
+ label: { text: 'CONSTRUCTIVISM', font: '30px "ArchivoBlack-400"', color: '#151311', y: 196, spacing: 4 } } },
+ { id: '33_rubberhose', name: '橡皮管卡通', eighths: 5, transition: { type: 'irisFilm', dur: 0.4, cx: 1236, cy: 420 },
+ counter: { year: 1930, roll: 0.4, x: 1858, y: 134, size: 100, font: 'Rye-400', color: '#141210', spacing: 4, box: c => { c.save(); c.fillStyle = '#efe7d2'; c.strokeStyle = '#141210'; c.lineWidth = 6; c.beginPath(); c.roundRect(1560, 44, 330, 166, 26); c.fill(); c.stroke(); c.restore(); }, label: { text: 'RUBBER HOSE', font: '34px "LilitaOne-400"', color: '#141210', x: 1858, y: 186, spacing: 2 } } },
+ { id: '23_dali', name: '达利超现实', eighths: 5, transition: { type: 'melt', dur: 0.36 },
+ counter: { year: 1931, roll: 0.4, x: R, y: 136, size: 104, font: 'PlayfairDisplay-700i', color: '#f6e8c8', shadow: { color: 'rgba(10,20,50,.55)', x: 5, y: 5, blur: 4 },
+ label: { text: 'Surrealism', font: '34px "PlayfairDisplay-400i"', color: '#f0dcae', y: 184 } } },
+ { id: '24_hopper', name: '霍珀美国现实主义', eighths: 5, transition: { type: 'sunShaft', dur: 0.34 },
+ counter: { year: 1942, roll: 0.4, x: R, y: 134, size: 100, font: 'LibreBaskerville-700', color: '#f3e3b5', shadow: { color: 'rgba(20,30,25,.55)', x: 4, y: 4 },
+ label: { text: 'AMERICAN REALISM', font: '27px "LibreBaskerville-400"', color: '#f0dca8', y: 182, spacing: 3 } } },
+ { id: '30_matisse', name: '马蒂斯剪纸', eighths: 5, transition: { type: 'cutouts', dur: 0.36 },
+ counter: { year: 1947, roll: 0.4, x: R, y: 136, size: 108, font: 'Caveat-600', color: '#111', spacing: 2,
+ label: { text: 'Matisse · Jazz', font: '46px "Caveat-600"', color: '#c8242a', y: 188 } } },
+ { id: '13_pop', name: '波普艺术', eighths: 5, transition: { type: 'zigzag', dur: 0.16 },
+ counter: { year: 1962, roll: 0.4, x: 1852, y: 144, size: 104, font: 'Anton-400', color: '#111',
+ box: c => { c.save(); c.fillStyle = '#111'; c.fillRect(1637, 40, 253, 170); c.fillStyle = '#f7e23a'; c.fillRect(1643, 46, 241, 158); c.restore(); },
+ label: { text: 'POP ART', font: '30px "Anton-400"', color: '#111', x: 1852, y: 192, spacing: 1 } } },
+ { id: '21_kusama', name: '草间弥生波点', eighths: 5, transition: { type: 'dotBloom', dur: 0.48, cx: 540, cy: 760 },
+ counter: { year: 1965, roll: 0.4, x: R, y: 134, size: 104, font: 'Poppins-800', color: '#ffffff', shadow: { color: '#141414', x: 5, y: 5 }, label: { text: '草间弥生 · 无限波点', font: '36px "LXGWWenKai-500"', color: '#ffffff', y: 186, shadow: { color: '#141414', x: 3, y: 3 } } } },
+ { id: '27_kirby', name: 'Kirby 漫画', eighths: 5, transition: { type: 'comicPanels', dur: 0.42 },
+ counter: { year: 1966, roll: 0.4, x: 1858, y: 132, size: 100, font: 'Bangers-400', color: '#151313', spacing: 4,
+ box: c => { c.save(); c.translate(6, 7); c.fillStyle = '#151313'; c.fillRect(1560, 38, 330, 176); c.restore();
+ c.save(); c.fillStyle = '#ffe23a'; c.fillRect(1560, 38, 330, 176); c.strokeStyle = '#151313'; c.lineWidth = 6; c.strokeRect(1560, 38, 330, 176); c.restore(); },
+ label: { text: 'JACK KIRBY · MARVEL', font: '34px "Bangers-400"', color: '#d8202a', x: 1858, y: 190, spacing: 2 } } },
+ { id: '31_haring', name: '哈林涂鸦', eighths: 5, transition: { type: 'radiant', dur: 0.32, cx: 1000, cy: 600 },
+ counter: { year: 1982, roll: 0.4, x: R, y: 136, size: 108, font: 'Kalam-700', color: '#111', spacing: 2,
+ label: { text: 'KEITH HARING', font: '40px "Kalam-700"', color: '#111', y: 188, spacing: 2 } } },
+ { id: '14_8bit', name: '8-bit 像素', eighths: 5, transition: { type: 'pixelate', dur: 0.12 },
+ counter: { year: 1985, roll: 0.4, x: R + 4, y: 86, size: 60, font: 'PressStart2P-400', color: '#ffffff', shadow: { color: '#0b1d24', x: 4, y: 4 },
+ label: { text: '8-BIT', font: '30px "PressStart2P-400"', color: '#ffffff', y: 138, shadow: { color: '#0b1d24', x: 3, y: 3 } } } },
+ { id: '25_ghibli', name: '吉卜力水彩', eighths: 5, transition: { type: 'bleed', dur: 0.38, cx: 580, cy: 330 },
+ counter: { year: 1988, roll: 0.4, x: R, y: 132, size: 104, font: 'Kalam-700', color: '#3f6a4a',
+ label: { text: 'Ghibli-style watercolor', font: '34px "Caveat-600"', color: '#4d7a58', y: 182 } } },
+ { id: '15_raytrace', name: '光追 CGI', eighths: 5, transition: { type: 'wireframe', dur: 0.14 },
+ counter: { year: 1993, roll: 0.4, x: R, y: 129, size: 104, font: 'Exo2-800i', color: '#ffffff', shadow: { color: '#d23aa6', x: 5, y: 5 },
+ label: { text: 'RAY-TRACED CGI', font: '30px "Exo2-800i"', gradient: ['#ffd84a', '#f08a2a'], y: 182, shadow: { color: '#7a2a7a', x: 2, y: 2 } } } },
+ { id: '26_vaporwave', name: '蒸汽波', eighths: 5, transition: { type: 'vhs', dur: 0.3 },
+ counter: { year: 2011, roll: 0.4, x: R, y: 130, size: 104, font: 'Exo2-800i', color: '#ffffff', shadow: { color: '#ff2fb4', x: 6, y: 5 },
+ label: { text: 'VAPORWAVE', font: '32px "Righteous-400"', gradient: ['#7ff6ff', '#ff71ce'], y: 182, spacing: 7, shadow: { color: '#3a0a6a', x: 2, y: 2 } } } },
+ { id: '35_shinkai', name: '新海诚光影', eighths: 5, transition: { type: 'flareSweep', dur: 0.38 },
+ counter: { year: 2016, roll: 0.4, x: R, y: 134, size: 100, font: 'Poppins-600', color: '#ffffff', shadow: { color: 'rgba(40,90,150,.5)', x: 3, y: 4, blur: 4 }, label: { text: 'Makoto Shinkai light', font: '30px "Poppins-600"', color: '#eaf6ff', y: 182, shadow: { color: 'rgba(40,90,150,.5)', x: 2, y: 3 } } } },
+ { id: '16_2026', name: '2026 扁平插画', eighths: 6, transition: { type: 'iris', dur: 0.183 },
+ counter: { year: 2026, roll: 0.4, x: R, y: 132, size: 100, font: 'Poppins-800', color: '#232a5c',
+ label: { text: 'Flat vector illustration', font: '30px "Poppins-600"', color: '#e2554e', y: 182 } } },
+];
diff --git "a/scripts/engine/examples/assets/K\347\272\277\345\233\276_\346\250\252\345\261\217.png" "b/scripts/engine/examples/assets/K\347\272\277\345\233\276_\346\250\252\345\261\217.png"
new file mode 100644
index 0000000..9e681fc
Binary files /dev/null and "b/scripts/engine/examples/assets/K\347\272\277\345\233\276_\346\250\252\345\261\217.png" differ
diff --git "a/scripts/engine/examples/assets/\350\220\245\346\224\266\345\233\276_\347\253\226\345\261\217.png" "b/scripts/engine/examples/assets/\350\220\245\346\224\266\345\233\276_\347\253\226\345\261\217.png"
new file mode 100644
index 0000000..5735ce1
Binary files /dev/null and "b/scripts/engine/examples/assets/\350\220\245\346\224\266\345\233\276_\347\253\226\345\261\217.png" differ
diff --git "a/scripts/engine/examples/assets/\350\264\242\347\273\217\345\233\276\350\241\250_\346\250\252\345\261\217.png" "b/scripts/engine/examples/assets/\350\264\242\347\273\217\345\233\276\350\241\250_\346\250\252\345\261\217.png"
new file mode 100644
index 0000000..b001e61
Binary files /dev/null and "b/scripts/engine/examples/assets/\350\264\242\347\273\217\345\233\276\350\241\250_\346\250\252\345\261\217.png" differ
diff --git a/scripts/engine/examples/t1_3b1b.json b/scripts/engine/examples/t1_3b1b.json
new file mode 100644
index 0000000..bd577aa
--- /dev/null
+++ b/scripts/engine/examples/t1_3b1b.json
@@ -0,0 +1,20 @@
+{
+ "grammar": "t1_3b1b",
+ "duration": 10,
+ "fps": 30,
+ "width": 1920,
+ "height": 1080,
+ "cues": [
+ { "at": 0.0, "kind": "title", "text": "梯度下降:每一步都往坡下走" },
+ { "at": 1.2, "kind": "equation", "data": { "tokens": [
+ { "s": "L", "it": true, "col": "BLUE_C" }, { "s": "(", "gap": 4 }, { "s": "θ", "it": true, "col": "YELLOW", "gap": 4 }, { "s": ")" } ] } },
+ { "at": 2.0, "kind": "line", "text": "损失 L(θ)", "data": { "values": [9, 5.8, 3.4, 1.8, 1.0, 0.8, 1.0, 1.8, 3.4, 5.8, 9], "color": "BLUE_C" } },
+ { "at": 3.6, "kind": "equation", "data": { "tokens": [
+ { "s": "θ", "it": true, "col": "YELLOW" }, { "s": "←", "gap": 18 }, { "s": "θ", "it": true, "col": "YELLOW", "gap": 14 },
+ { "s": "−", "gap": 14 }, { "s": "η", "it": true, "col": "GREEN_C", "gap": 8 }, { "s": "∇", "gap": 4 }, { "s": "L", "it": true, "col": "BLUE_C" } ] } },
+ { "at": 4.6, "kind": "point", "text": "算出当前位置的坡度 ∇L" },
+ { "at": 5.8, "kind": "point", "text": "沿反方向走一小步,步长是 η" },
+ { "at": 7.0, "kind": "line", "text": "训练中的损失", "data": { "values": [9, 6.2, 4.4, 3.2, 2.4, 1.9, 1.55, 1.3, 1.15, 1.05, 1.0], "color": "TEAL_C" } },
+ { "at": 8.4, "kind": "highlight", "data": { "index": 1 } }
+ ]
+}
diff --git a/scripts/engine/examples/t2_keynote_ui.json b/scripts/engine/examples/t2_keynote_ui.json
new file mode 100644
index 0000000..d4e369b
--- /dev/null
+++ b/scripts/engine/examples/t2_keynote_ui.json
@@ -0,0 +1,17 @@
+{
+ "grammar": "t2_keynote_ui",
+ "duration": 10,
+ "fps": 30,
+ "width": 1920,
+ "height": 1080,
+ "data": { "eyebrow": "全 新 发 布", "title": "参数化动画片段", "subtitle": "一份 JSON,出一段时长精确的动画" },
+ "cues": [
+ { "at": 0.0, "kind": "title" },
+ { "at": 2.2, "kind": "card", "text": "8 种动画语法", "sub": "从 3Blue1Brown 到动态文字", "data": { "icon": "layers" } },
+ { "at": 3.0, "kind": "card", "text": "时长精确到帧", "sub": "帧数 = 时长 × 帧率", "data": { "icon": "clock", "value": 30, "suffix": " fps", "label": "默认帧率" } },
+ { "at": 3.8, "kind": "card", "text": "横竖屏都能出", "sub": "竖屏自动换一套排版", "data": { "icon": "phone" } },
+ { "at": 6.0, "kind": "number", "text": "英伟达五个财年的营收涨幅", "data": { "value": 7.8, "decimals": 1, "suffix": " 倍" } },
+ { "at": 7.2, "kind": "card", "text": "用 t3 财经图表出的一帧", "sub": "数据:英伟达 2021–2025 财年 10-K 年报", "image": "assets/财经图表_横屏.png" },
+ { "at": 8.4, "kind": "highlight", "data": { "rect": [0.648, 0.245, 0.104, 0.105] } }
+ ]
+}
diff --git a/scripts/engine/examples/t3_finance_chart.json b/scripts/engine/examples/t3_finance_chart.json
new file mode 100644
index 0000000..59b02d1
--- /dev/null
+++ b/scripts/engine/examples/t3_finance_chart.json
@@ -0,0 +1,27 @@
+{
+ "grammar": "t3_finance_chart",
+ "duration": 7,
+ "fps": 30,
+ "width": 1920,
+ "height": 1080,
+ "data": {
+ "title": "英伟达:五个财年营收涨到原来的 7.8 倍",
+ "unit": "年营收,十亿美元",
+ "source": "来源:英伟达 2021–2025 财年 10-K 年报(财年截至次年 1 月)",
+ "chart": "bar",
+ "decimals": 1,
+ "series": [
+ { "label": "FY2021", "value": 16.68 },
+ { "label": "FY2022", "value": 26.91 },
+ { "label": "FY2023", "value": 26.97 },
+ { "label": "FY2024", "value": 60.92 },
+ { "label": "FY2025", "value": 130.50 }
+ ],
+ "highlight": { "index": 4, "text": "7.8 倍", "sub": "130.5 ÷ 16.7" }
+ },
+ "cues": [
+ { "at": 0.0, "kind": "title" },
+ { "at": 1.2, "kind": "bar" },
+ { "at": 4.4, "kind": "highlight" }
+ ]
+}
diff --git a/scripts/engine/examples/y1_kurzgesagt.json b/scripts/engine/examples/y1_kurzgesagt.json
new file mode 100644
index 0000000..f3189b0
--- /dev/null
+++ b/scripts/engine/examples/y1_kurzgesagt.json
@@ -0,0 +1,18 @@
+{
+ "grammar": "y1_kurzgesagt",
+ "duration": 10,
+ "fps": 30,
+ "width": 1920,
+ "height": 1080,
+ "data": { "center": "大模型" },
+ "cues": [
+ { "at": 0.0, "kind": "title", "text": "一个大模型里面有什么?" },
+ { "at": 1.4, "kind": "point", "text": "几千亿个参数" },
+ { "at": 2.3, "kind": "point", "text": "几十层网络" },
+ { "at": 3.2, "kind": "point", "text": "一张词表" },
+ { "at": 4.2, "kind": "enter", "text": "其中一层", "data": { "index": 1 } },
+ { "at": 6.2, "kind": "point", "text": "注意力" },
+ { "at": 7.0, "kind": "point", "text": "前馈网络" },
+ { "at": 8.0, "kind": "highlight", "data": { "index": 0 } }
+ ]
+}
diff --git a/scripts/engine/examples/y2_vox.json b/scripts/engine/examples/y2_vox.json
new file mode 100644
index 0000000..eef18fb
--- /dev/null
+++ b/scripts/engine/examples/y2_vox.json
@@ -0,0 +1,14 @@
+{
+ "grammar": "y2_vox",
+ "duration": 9,
+ "fps": 30,
+ "width": 1920,
+ "height": 1080,
+ "cues": [
+ { "at": 0.0, "kind": "title", "text": "这两张图都是代码画的" },
+ { "at": 1.6, "kind": "image", "image": "assets/K线图_横屏.png", "text": "t3 财经图表:日 K 线(示意数据)" },
+ { "at": 3.4, "kind": "highlight", "data": { "rect": [0.74, 0.22, 0.22, 0.11] } },
+ { "at": 5.6, "kind": "point", "text": "收盘价在最后一根 K 线长出时落定" },
+ { "at": 7.0, "kind": "image", "image": "assets/营收图_竖屏.png", "text": "同一种图表,竖屏换一套排版" }
+ ]
+}
diff --git a/scripts/engine/examples/y3_whiteboard.json b/scripts/engine/examples/y3_whiteboard.json
new file mode 100644
index 0000000..20eb9e8
--- /dev/null
+++ b/scripts/engine/examples/y3_whiteboard.json
@@ -0,0 +1,17 @@
+{
+ "grammar": "y3_whiteboard",
+ "duration": 10,
+ "fps": 30,
+ "width": 1920,
+ "height": 1080,
+ "cues": [
+ { "at": 0.0, "kind": "title", "text": "AI 为什么会一本正经地胡说" },
+ { "at": 1.9, "kind": "point", "text": "它读过海量的文字" },
+ { "at": 2.8, "kind": "draw", "text": "海量文本", "data": { "icon": "stack" } },
+ { "at": 3.9, "kind": "point", "text": "学会的是下一个词最像什么" },
+ { "at": 4.9, "kind": "draw", "text": "猜下一个词", "data": { "icon": "network" } },
+ { "at": 6.0, "kind": "point", "text": "没人教过它说「不知道」" },
+ { "at": 6.9, "kind": "draw", "text": "照样作答", "data": { "icon": "chat" } },
+ { "at": 8.0, "kind": "highlight", "data": { "index": 2 } }
+ ]
+}
diff --git a/scripts/engine/examples/y4_storytime.json b/scripts/engine/examples/y4_storytime.json
new file mode 100644
index 0000000..a6d61fc
--- /dev/null
+++ b/scripts/engine/examples/y4_storytime.json
@@ -0,0 +1,14 @@
+{
+ "grammar": "y4_storytime",
+ "duration": 8.5,
+ "fps": 30,
+ "width": 1920,
+ "height": 1080,
+ "cues": [
+ { "at": 0.1, "kind": "point", "text": "我第一次让 AI 帮我写代码,", "sub": "AI,帮我写个网站!" },
+ { "at": 2.0, "kind": "insert", "text": "3000行", "sub": "帮我做个网站", "data": { "hit": 3.5, "count": 3000, "unit": "行" } },
+ { "at": 4.6, "kind": "react" },
+ { "at": 5.9, "kind": "point", "text": "这些……贴哪儿?", "data": { "pose": "point" } },
+ { "at": 7.2, "kind": "highlight", "data": { "mark": "?" } }
+ ]
+}
diff --git a/scripts/engine/examples/y5_kinetic_type.json b/scripts/engine/examples/y5_kinetic_type.json
new file mode 100644
index 0000000..b1651c9
--- /dev/null
+++ b/scripts/engine/examples/y5_kinetic_type.json
@@ -0,0 +1,14 @@
+{
+ "grammar": "y5_kinetic_type",
+ "duration": 8,
+ "fps": 30,
+ "width": 1920,
+ "height": 1080,
+ "cues": [
+ { "at": 0.0, "kind": "title", "text": "AI 写代码", "sub": "的三个阶段" },
+ { "at": 1.9, "kind": "point", "text": "补全", "sub": "它补完下一行", "data": { "label": "阶段 01", "key": "下一行" } },
+ { "at": 3.6, "kind": "point", "text": "对话", "sub": "一句话换一整段", "data": { "label": "阶段 02", "key": "一整段" } },
+ { "at": 5.3, "kind": "point", "text": "代理", "sub": "你只说要什么", "data": { "label": "阶段 03", "key": "要什么" } },
+ { "at": 6.4, "kind": "highlight", "data": { "word": "代理" } }
+ ]
+}
diff --git a/scripts/engine/index.html b/scripts/engine/index.html
new file mode 100644
index 0000000..257ad2d
--- /dev/null
+++ b/scripts/engine/index.html
@@ -0,0 +1,40 @@
+<!doctype html>
+<html><head><meta charset="utf-8"><title>Art History Speedrun · 复刻</title>
+<style>
+html,body{margin:0;background:#111;overflow:hidden}
+canvas{display:block;width:100vw;height:auto;max-width:1920px}
+#ui{position:fixed;left:8px;bottom:8px;color:#ddd;font:12px monospace}
+body.render #ui{display:none}
+</style></head>
+<body>
+<canvas id="c" width="1920" height="1080"></canvas>
+<div id="ui"><input id="scrub" type="range" min="0" max="60" step="0.0166667" value="0" style="width:600px"> <span id="tt"></span> <button id="play">play</button></div>
+<script src="lib/fonts.js"></script>
+<script src="lib/util.js"></script>
+<script src="lib/paint.js"></script>
+<script src="lib/brush.js"></script>
+<script src="lib/render.js"></script>
+<script src="lib/post.js"></script>
+<script src="lib/rig.js"></script>
+<script src="lib/rig_huashu.js"></script>
+<script src="lib/kit.js"></script>
+<!-- YouTube 解说语法库(references/09):动效时间、相机、图解形变、文字、图表、发布会界面、拼贴、卡通 -->
+<script src="lib/motion.js"></script>
+<script src="lib/camera.js"></script>
+<script src="lib/diagram.js"></script>
+<script src="lib/typo.js"></script>
+<script src="lib/chart.js"></script>
+<script src="lib/ui.js"></script>
+<script src="lib/collage.js"></script>
+<script src="lib/toon.js"></script>
+<script>
+// 选片子:默认 eras.js;?film=<名> → eras_<名>.js(如 ?film=gallery = 35 种风格样片);?film=demos/<名> → demos/<名>/eras.js(8 种 YouTube 语法示范)。
+// render.py / qa.py 用 --film 传。
+(() => { const f = new URLSearchParams(location.search).get('film');
+ const src = f && /^demos\/[a-z0-9_]+$/.test(f) ? `${f}/eras.js` : f && /^[a-z0-9_]+$/.test(f) ? `eras_${f}.js` : 'eras.js';
+ document.write(`<script src="${src}"><\/script>`); })();
+</script>
+<script src="transitions.js"></script>
+<script src="scenes/index.js"></script>
+<script src="engine.js"></script>
+</body></html>
diff --git a/scripts/engine/lib/brush.js b/scripts/engine/lib/brush.js
new file mode 100644
index 0000000..5c2eead
--- /dev/null
+++ b/scripts/engine/lib/brush.js
@@ -0,0 +1,149 @@
+// 笔与水:毛笔飞白、两头尖单笔、墨晕晕染、长弯流线笔、水彩洗染、厚涂鬃毛笔、剪刀折线。全部挂在 PAINT(P)上。
+// 来源:迁移测试 A(水墨/蒙克)、B(吉卜力)、C(马蒂斯)、D(伦勃朗)。确定性:所有随机都走种子。
+// P.brush(c, pts, opt) 毛笔:笔压起收+湿笔芯+逐根笔毛飞白,可按 reveal 写出(水墨、书法、白描衣纹)
+// P.leaf(c, x, y, ang, L, w) 两头尖的单笔(竹叶、兰叶、鸟翅、虾尾)
+// P.inkWash(c, key, grow, fn, o) 墨晕:形状先画到 scratch,再「外晕+本体」两遍模糊 multiply 到纸上,grow 0→1 是洇开
+// P.flowSeeds / P.flowLines 长弯流线笔:种子沿随时间扭动的方向场积分成 200–300px 的长笔(蒙克,不是梵高的短笔)
+// P.deform / P.watercolor 水彩洗染:中点位移变形多边形 × 多层低 α multiply + 每层淡描边=水痕边(吉卜力背景)
+// P.rectPts / P.ellipsePts 洗染常用的多边形点列
+// P.impasto(c, pts, w, col, hi) 厚涂鬃毛笔:一笔=若干平行细鬃(伦勃朗高光、梵高厚涂补笔)
+// P.cut(pts, seed, step, amp) 剪刀折线:沿轮廓每 step px 取点+抖动、直线相连(马蒂斯剪纸、剪影、木刻)
+(() => {
+const W = 1920, H = 1080;
+const P = window.PAINT;
+const { clamp, lerp, rng, ss } = U;
+
+// ---------- 毛笔 ----------
+// pts 控制点(会 Catmull-Rom 加密再按 4px 等弧长重采样——不重采样的话飞白噪声频率随笔画长短变)
+// w 最大宽;tone 墨色透明度(焦 .9/浓 .8/重 .6/淡 .35/清 .15);dry 0..1 飞白程度(越到笔尾越干);reveal 0..1 写出比例
+// head/tail 起笔/收笔占比;bristles 笔毛数;col 墨色 [r,g,b];per 加密倍数
+// 坑:笔毛必须每根一条连续 path(butt 头);按小段单独 stroke+round 头,接头处会叠出一节节深点,像竹节/麻绳。
+P.brush = (c, pts, { w = 10, tone = 0.85, dry = 0.45, seed = 1, reveal = 1, bristles = 8, col = [16, 14, 12], head = 0.12, tail = 0.4, per = 5 } = {}) => {
+ if (reveal <= 0) return;
+ const D = KIT.resample(KIT.densify(pts, per), 4), n = D.length, m = Math.max(2, Math.ceil(n * clamp(reveal)));
+ const r = rng(seed * 7919);
+ const prof = q => ss(0, head, q) * (1 - 0.7 * ss(1 - tail, 1, q)) * (0.85 + 0.15 * P.noise(seed * 3.3, q * 6)) + 0.08;
+ c.save(); c.lineCap = 'butt'; c.lineJoin = 'round';
+ const N = [];
+ for (let i = 0; i < n; i++) { const A = D[Math.max(0, i - 1)], B = D[Math.min(n - 1, i + 1)]; let dx = B[0] - A[0], dy = B[1] - A[1]; const d = Math.hypot(dx, dy) || 1; N.push([-dy / d, dx / d]); }
+ const core = q => w * prof(q) * (1 - dry * 0.85 * Math.pow(q, 0.8));
+ // 湿的笔芯:整笔都有,越往后越细越淡(墨在用完)
+ c.fillStyle = `rgba(${col[0]},${col[1]},${col[2]},${tone * 0.72})`; c.fill(KIT.ribbon(D.slice(0, m), (q, i) => core(i / (n - 1))));
+ // 笔毛:每根一条连续线,按噪声断开(飞白=笔毛之间露出的纸),越到笔尾断得越多
+ for (let k = 0; k < bristles; k++) {
+ const off = (k / (bristles - 1) - 0.5) * 0.95, bw = w / bristles * (0.9 + r() * 0.9), ph = r() * 50;
+ c.strokeStyle = `rgba(${col[0]},${col[1]},${col[2]},${tone * (0.45 + r() * 0.35)})`; c.lineWidth = Math.max(0.7, bw);
+ c.beginPath(); let on = false;
+ for (let i = 0; i < m; i++) {
+ const q = i / (n - 1), dryness = dry * Math.pow(q, 1.2);
+ const vis = P.noise(k * 1.9 + ph, i * 0.09) * 0.5 + 0.5 > dryness * 0.95 + 0.05;
+ const o = off * w * prof(q), x = D[i][0] + N[i][0] * o, y = D[i][1] + N[i][1] * o;
+ if (vis) { on ? c.lineTo(x, y) : c.moveTo(x, y); on = true; } else on = false;
+ }
+ c.stroke();
+ }
+ c.restore();
+};
+// 两头尖的单笔(个字竹叶、兰叶描、鸟翅):沿 ang 方向长 L,最宽 wmax,微弯
+P.leaf = (c, x, y, ang, L, wmax, tone = 0.88, col = [16, 14, 12]) => {
+ if (!Array.isArray(col)) col = [16, 14, 12];
+ const pts = []; for (let i = 0; i <= 10; i++) { const q = i / 10, bend = Math.sin(q * Math.PI) * 0.08 * L; pts.push([x + Math.cos(ang) * L * q - Math.sin(ang) * bend, y + Math.sin(ang) * L * q + Math.cos(ang) * bend]); }
+ c.fillStyle = `rgba(${col[0]},${col[1]},${col[2]},${tone})`; c.fill(KIT.ribbon(pts, q => wmax * Math.pow(Math.sin(Math.PI * Math.min(1, q * 1.1)), 0.7) + 0.6));
+};
+
+// ---------- 墨晕 / 晕染层 ----------
+// fn(g) 在 scratch 上画形状(实色即可);grow 0..1 控制洇开:外晕 blur 随 grow 变宽,本体 blur 随 grow 收紧。
+// halo 外晕模糊半径、haloA 外晕透明度、blur 本体模糊、alpha 整体透明度。返回 scratch(可再拿来做留白挖洞)。
+// 坑:multiply 是透明的,背后的墨线会透过晕染(窗台线透过猫耳)。先在剪影里补一层纸色(clip 后 drawImage 纸)再上晕染=「先留出这块地方」。
+P.inkWash = (c, key, grow, fn, { blur = 2, halo = 10, haloA = 0.22, alpha = 1 } = {}) => {
+ const S = P.scratch('inkw_' + key), g = S.getContext('2d'); g.reset(); fn(g);
+ c.save(); c.globalCompositeOperation = 'multiply';
+ if (grow > 0) {
+ c.globalAlpha = haloA * alpha * grow; c.filter = `blur(${(halo * (0.4 + grow)).toFixed(2)}px)`; c.drawImage(S, 0, 0);
+ c.globalAlpha = alpha * ss(0, 0.6, grow); c.filter = `blur(${(blur * (1.6 - grow * 0.6)).toFixed(2)}px)`; c.drawImage(S, 0, 0);
+ }
+ c.filter = 'none'; c.restore();
+ return S;
+};
+
+// ---------- 长弯流线笔(蒙克《呐喊》式表现主义) ----------
+// 种子:cell 抖动网格,每个种子带两个随机数 [x, y, r1, r2]
+P.flowSeeds = (cell = 24, seed = 5) => { const r = rng(seed), o = []; for (let y = -10; y < H + 10; y += cell) for (let x = -10; x < W + 10; x += cell) o.push([x + (r() - .5) * cell, y + (r() - .5) * cell, r(), r()]); return o; };
+// 每个种子:region(x,y,t) 判区 → 取该区参数 params[reg] = [steps, step, width, alpha] → 沿 angle(x,y,t,reg) 积分;越出本区就停(区域边界干净)。
+// color(reg, sx, sy, r1, t) 返回 [r,g,b]。不描边、半透明叠色——蒙克是薄涂长笔;照搬梵高的深色描边会变成一节节毛毛虫短笔。
+// 底下先铺同色系平涂,笔缝里露出的是同色而不是黑。长度:steps 26–42、step 6–8,一根笔走 200–300px。
+P.flowLines = (c, seeds, { t = 0, region, angle, color, params, extraSteps = 8 }) => {
+ c.lineCap = 'round'; c.lineJoin = 'round';
+ for (const [sx, sy, r1, r2] of seeds) {
+ const reg = region(sx, sy, t); const pr = params[reg]; if (!pr) continue; const [steps, step, width, alpha] = pr;
+ const col = color(reg, sx, sy, r1, t);
+ let x = sx, y = sy; c.beginPath(); c.moveTo(x, y);
+ const n = steps + ((r2 * extraSteps) | 0);
+ for (let i = 0; i < n; i++) { const a = angle(x, y, t, reg); x += Math.cos(a) * step; y += Math.sin(a) * step; if (region(x, y, t) !== reg) break; c.lineTo(x, y); }
+ c.strokeStyle = P.rgb(col, alpha); c.lineWidth = width * (0.7 + r2 * 0.6); c.stroke();
+ }
+};
+
+// ---------- 水彩洗染(吉卜力式背景美术) ----------
+// 中点位移:每轮在每条边中点沿法向推一个近似高斯量(3 个均匀数相加),幅度与边长成比例,每轮 amp×0.6
+P.deform = (pts, depth, amp, r) => {
+ let out = pts;
+ for (let d = 0; d < depth; d++) {
+ const n = [];
+ for (let i = 0; i < out.length; i++) {
+ const a = out[i], b = out[(i + 1) % out.length], len = Math.hypot(b[0] - a[0], b[1] - a[1]);
+ const g = (r() + r() + r() - 1.5) * amp * Math.min(1, len / 80), nx = -(b[1] - a[1]) / (len || 1), ny = (b[0] - a[0]) / (len || 1);
+ n.push(a, [(a[0] + b[0]) / 2 + nx * g, (a[1] + b[1]) / 2 + ny * g]);
+ }
+ out = n; amp *= 0.6;
+ }
+ return out;
+};
+const fillPts = (g, pts) => { g.beginPath(); pts.forEach((q, i) => i ? g.lineTo(q[0], q[1]) : g.moveTo(q[0], q[1])); g.closePath(); };
+// 一次洗染:基形 deform 3 轮;每层再 deform 2 轮、低 α 填(multiply = 透明颜料叠色)、α=edge 描 1.6px 同色边(颜料在边缘沉积 = 水痕边)。
+// fill 可传渐变;不透明的白(窗框、云、桌布)用 blend:'source-over'、alpha .9。
+// 常用:大墙 layers5 α.4 amp12;色晕 layers3 α.045 amp40;木板 layers3 α.5 amp3 edge.14。
+// 坑:暗部用大幅变形多边形(amp 60),别用矩形拼——矩形接缝处会出硬边。色晕 α 别超 .05×3 层,否则房间像发霉的羊皮纸。
+P.watercolor = (g, pts, color, { layers = 7, alpha = 0.13, amp = 10, seed = 1, edge = 0.1, blend = 'multiply', fill } = {}) => {
+ const r = rng(seed * 7919 + 13), base = P.deform(pts, 3, amp, r);
+ g.save(); g.globalCompositeOperation = blend; g.lineJoin = 'round';
+ for (let k = 0; k < layers; k++) {
+ const q = P.deform(base, 2, amp * 0.55, r);
+ fillPts(g, q); g.globalAlpha = alpha; g.fillStyle = fill || color; g.fill();
+ if (edge) { g.globalAlpha = edge; g.strokeStyle = color; g.lineWidth = 1.6; g.stroke(); }
+ }
+ g.restore();
+};
+P.rectPts = (x, y, w, h) => [[x, y], [x + w, y], [x + w, y + h], [x, y + h]];
+P.ellipsePts = (cx, cy, rx, ry, n = 18) => Array.from({ length: n }, (_, i) => [cx + Math.cos(i / n * Math.PI * 2) * rx, cy + Math.sin(i / n * Math.PI * 2) * ry]);
+
+// ---------- 厚涂鬃毛笔 ----------
+// 一笔 = round(w/1.3) 条平行细鬃(亮度各自 ±17 抖、两端随机缩 0–25%)+下侧一条淡投影+上侧零星亮点 → 读成「被刷开的一坨厚颜料」。
+// 只用在受光处(金发、领口、瓷器、珍珠、白毛)。坑:画成「暗影+主笔+亮脊」三条整齐的线会读成白色贴纸/创可贴。
+P.impasto = (c, pts, w, col, hi) => {
+ const base = col.startsWith('#') ? P.hex(col) : [240, 230, 210];
+ const A = pts[0], B = pts[pts.length - 1], ang = Math.atan2(B[1] - A[1], B[0] - A[0]), nx = -Math.sin(ang), ny = Math.cos(ang);
+ const r = rng((A[0] * 13 + A[1] * 7) | 0), nb = Math.max(3, Math.round(w / 1.3));
+ c.save(); c.lineCap = 'round';
+ c.strokeStyle = 'rgba(40,18,6,.28)'; c.lineWidth = w * 0.9; c.beginPath(); pts.forEach((p, i) => i ? c.lineTo(p[0] + nx * w * 0.45 + 1, p[1] + ny * w * 0.45 + 1.5) : c.moveTo(p[0] + nx * w * 0.45 + 1, p[1] + ny * w * 0.45 + 1.5)); c.stroke();
+ for (let k = 0; k < nb; k++) {
+ const o = (k / (nb - 1) - 0.5) * w, s0 = r() * 0.25, s1 = 1 - r() * 0.25, sh = (r() - 0.5) * 34 + (k < nb / 2 ? 14 : -10);
+ c.strokeStyle = P.rgb([base[0] + sh, base[1] + sh, base[2] + sh * 0.8], 0.55 + r() * 0.4); c.lineWidth = 1.4 + r() * 1.2; c.beginPath();
+ const n = pts.length - 1; for (let i = 0; i <= 8; i++) { const q = lerp(s0, s1, i / 8), j = Math.min(n - 1, Math.floor(q * n)), f = q * n - j, x = lerp(pts[j][0], pts[j + 1][0], f) + nx * o, y = lerp(pts[j][1], pts[j + 1][1], f) + ny * o; i ? c.lineTo(x, y) : c.moveTo(x, y); }
+ c.stroke();
+ }
+ c.fillStyle = hi || 'rgba(255,250,232,.7)'; for (let k = 0; k < 2 + w / 3; k++) { const q = r(), x = lerp(A[0], B[0], q) - nx * w * 0.3, y = lerp(A[1], B[1], q) - ny * w * 0.3; c.beginPath(); c.arc(x, y, 0.9 + r(), 0, Math.PI * 2); c.fill(); }
+ c.restore();
+};
+
+// ---------- 剪刀折线 ----------
+// 把一圈(闭合)点列按 step 重采样,每点加 ±amp 种子抖动,直线相连 → 手剪纸的边。RIG 部件可用 path.pts 喂进来重剪。
+P.cut = (pts, seed, step = 18, amp = 2.5) => {
+ const r = rng(seed), out = [];
+ for (let i = 0; i < pts.length; i++) {
+ const a = pts[i], b = pts[(i + 1) % pts.length], L = Math.hypot(b[0] - a[0], b[1] - a[1]), n = Math.max(1, Math.round(L / step));
+ for (let k = 0; k < n; k++) { const q = k / n; out.push([lerp(a[0], b[0], q) + (r() - 0.5) * amp * 2, lerp(a[1], b[1], q) + (r() - 0.5) * amp * 2]); }
+ }
+ return U.poly(out);
+};
+})();
diff --git a/scripts/engine/lib/camera.js b/scripts/engine/lib/camera.js
new file mode 100644
index 0000000..fed99d4
--- /dev/null
+++ b/scripts/engine/lib/camera.js
@@ -0,0 +1,61 @@
+// 世界相机 CAM:解说片不是「一段段画+转场」,而是「一张连续的世界画布+一台相机」。
+// 铁律:相机只由全片时间(或本段时间)算出来,场景每帧按相机矢量重画——缩放转场永远清楚,不会把 1920 的位图放大 20 倍糊掉;
+// 引擎在转场窗口里会把上一段继续按 t 画进 A 缓冲,所以「上一镜的相机继续推」天然成立(live 推进)。
+// cam = { x, y, z, r }:世界点 (x,y) 落在画面中心,缩放 z(>1 推近),绕中心旋转 r(弧度)。缺省 x=960,y=540,z=1,r=0。
+(() => {
+let W = 1920, H = 1080; U.onStage((w, h) => { W = w; H = h; }); // 画布尺寸跟 U.setStage 走(默认 1920×1080)
+const { clamp, lerp } = U;
+const CAM = window.CAM = {};
+const n = cam => ({ x: cam.x ?? W / 2, y: cam.y ?? H / 2, z: cam.z ?? 1, r: cam.r || 0 });
+
+// 把相机变换作用到 c 上(不 save/restore,调用方负责)
+CAM.apply = (c, cam) => { const k = n(cam); c.translate(W / 2, H / 2); if (k.r) c.rotate(k.r); c.scale(k.z, k.z); c.translate(-k.x, -k.y); };
+// 在相机下画 fn(c),自动 save/restore
+CAM.with = (c, cam, fn) => { c.save(); CAM.apply(c, cam); fn(c); c.restore(); };
+// 世界 → 屏幕 / 屏幕 → 世界
+CAM.toScreen = (cam, x, y) => { const k = n(cam); let dx = (x - k.x) * k.z, dy = (y - k.y) * k.z; if (k.r) { const cs = Math.cos(k.r), sn = Math.sin(k.r); [dx, dy] = [dx * cs - dy * sn, dx * sn + dy * cs]; } return [W / 2 + dx, H / 2 + dy]; };
+CAM.toWorld = (cam, sx, sy) => { const k = n(cam); let dx = sx - W / 2, dy = sy - H / 2; if (k.r) { const cs = Math.cos(-k.r), sn = Math.sin(-k.r); [dx, dy] = [dx * cs - dy * sn, dx * sn + dy * cs]; } return [k.x + dx / k.z, k.y + dy / k.z]; };
+
+// ---------- 缩放 ----------
+// 对数插值:z0→z1 每帧放大同样的倍数,观众感到「匀速穿越尺度」;线性插值会前慢后猛。所有推拉缩放都用它。
+CAM.zlerp = (z0, z1, e) => z0 * Math.pow(z1 / z0, e);
+// 「从一个半径 r 的圆形开口穿进去,开口要在转场结束前盖满屏」需要的最小放大倍数 = 开口中心到最远屏幕角的距离 / r。
+// 开口在画面中心时 ≈ 1101/r(卡片里写的「放大倍数 ≥ 1100/半径」)。小了,最后一帧开口没盖满会跳。
+CAM.coverZoom = (r, cx = W / 2, cy = H / 2) => Math.max(Math.hypot(cx, cy), Math.hypot(W - cx, cy), Math.hypot(cx, H - cy), Math.hypot(W - cx, H - cy)) / r;
+// 让世界点 (wx,wy) 在缩放 z 下出现在屏幕 (sx,sy):返回相机。推近某物时让它平滑移到画面中心就靠它。
+CAM.anchor = (wx, wy, z, sx, sy) => ({ x: wx - (sx - W / 2) / z, y: wy - (sy - H / 2) / z, z });
+// 推进某个世界点:从 base 相机出发,缩放按对数插值到 Z(进度 e);该点在屏幕上从原位置移向画面中心(进度 k,默认 = e;k=0 = 绕它原地推)。
+// 用于「钻进镜头」(y1)、「推满照片再硬切」(y2)、「推进最新数据点」(t3,k=0)。
+CAM.pushTo = (base, wx, wy, Z, e, k = e, to = [W / 2, H / 2]) => {
+ const s0 = CAM.toScreen(base, wx, wy), z = CAM.zlerp(n(base).z, Z, e);
+ return CAM.anchor(wx, wy, z, lerp(s0[0], to[0], k), lerp(s0[1], to[1], k));
+};
+
+// ---------- 关键帧 ----------
+// keys = [{t, x, y, z, r, ease}];ease 作用在「从上一键到这一键」,默认 cubicInOut;z 用对数插值。
+// 沿路径平移(Vox 桌面、白板上的平移/甩镜)就是一串关键帧:平滑移动用 sineInOut,远跳用 cubicInOut+运动模糊,沿线追用 MO.longTail。
+CAM.at = (keys, t) => {
+ if (t <= keys[0].t) return { ...keys[0] };
+ for (let i = 1; i < keys.length; i++) {
+ const a = keys[i - 1], b = keys[i];
+ if (t <= b.t) { const e = (b.ease || MO.cubicInOut)(MO.seg(t, a.t, b.t));
+ return { x: lerp(a.x, b.x, e), y: lerp(a.y, b.y, e), z: CAM.zlerp(a.z, b.z, e), r: lerp(a.r || 0, b.r || 0, e), v: e }; }
+ }
+ return { ...keys[keys.length - 1] };
+};
+
+// ---------- 视差 ----------
+// d=1 是主体平面,d<1 远、d>1 近。远层位移按 d 线性、缩放按 z^d:深推时远景几乎不动,这就是景深感(Kurzgesagt 5 层视差)。
+CAM.layer = (c, cam, d, fn) => { const k = n(cam); c.save(); CAM.apply(c, { x: lerp(W / 2, k.x, d), y: lerp(H / 2, k.y, d), z: Math.pow(k.z, d) }); fn(c); c.restore(); };
+
+// ---------- 运动 ----------
+// 相机在屏幕上的瞬时速度(像素/帧,60fps):camFn(t) → cam。给 motionBlur 用。
+CAM.velocity = (camFn, t, dt = 1 / 60) => { const a = camFn(t), b = camFn(t - dt); const z = n(a).z; return [(n(a).x - n(b).x) * z, (n(a).y - n(b).y) * z]; };
+// 动态模糊:沿速度方向把整帧叠 n 次(快摇/甩镜用;速度 <1.5px 自动退化成一次绘制)。模糊长度应短于相机位移(PremiumBeat)。
+CAM.motionBlur = (c, src, vx, vy, k = 7) => {
+ const sp = Math.hypot(vx, vy); if (sp < 1.5) { c.drawImage(src, 0, 0); return; }
+ c.save(); for (let i = 0; i < k; i++) { const q = i / (k - 1) - 0.5; c.globalAlpha = i === 0 ? 1 : 1 / (i + 1); c.drawImage(src, -vx * q, -vy * q); } c.restore();
+};
+// 手持感微漂:两路不同周期的正弦(连续时间,不闪),返回 [dx, dy] 像素
+CAM.drift = (t, amp = 6, seed = 0) => [amp * Math.sin(t * 0.9 + seed) + amp * 0.4 * Math.sin(t * 2.3 + seed * 2), amp * 0.7 * Math.sin(t * 1.1 + seed * 3)];
+})();
diff --git a/scripts/engine/lib/chart.js b/scripts/engine/lib/chart.js
new file mode 100644
index 0000000..e18de00
--- /dev/null
+++ b/scripts/engine/lib/chart.js
@@ -0,0 +1,152 @@
+// 数据图表动画 CH:比例尺、好看的刻度、网格(先出)、柱(从 0 长出)、折线(按时间画出、头部圆点)、K 线(逐根)、
+// 标注(点→引线→文字)、经济学人式版式(顶红线+红色小旗+标题+单位副标题+来源注+「示意数据」角标)。
+// 顺序铁律(准确性+可读性):坐标系先出 → 数据后出 → 标注最后、一镜只标一件事;柱状图基线必须是 0(纵轴不从 0 开始要在副标题写明);
+// 动画只改「怎么出现」,不改数值;单位写在副标题;虚构/示意数据每一镜角落都标。
+(() => {
+let W = 1920, H = 1080; U.onStage((w, h) => { W = w; H = h; }); // 画布尺寸跟 U.setStage 走(默认 1920×1080)
+const { clamp, lerp } = U;
+const CH = window.CH = {};
+const seg = (t, a, b) => clamp((t - a) / (b - a));
+
+// 线性比例尺:值 → 屏幕;f.inv 反查
+CH.lin = (d0, d1, r0, r1) => { const f = v => r0 + (v - d0) / (d1 - d0) * (r1 - r0); f.inv = y => d0 + (y - r0) / (r1 - r0) * (d1 - d0); return f; };
+// 1/2/2.5/5×10^k 的好看刻度
+CH.ticks = (min, max, n = 5) => {
+ const raw = (max - min) / n, mag = Math.pow(10, Math.floor(Math.log10(raw))), steps = [1, 2, 2.5, 5, 10];
+ const step = steps.map(s => s * mag).find(s => s >= raw) || 10 * mag;
+ const out = []; for (let v = Math.ceil(min / step) * step; v <= max + 1e-9; v += step) out.push(+v.toFixed(10)); return out;
+};
+CH.mixHex = (a, b, t) => { const A = PAINT.hex(a), B = PAINT.hex(b); return `rgb(${lerp(A[0], B[0], t) | 0},${lerp(A[1], B[1], t) | 0},${lerp(A[2], B[2], t) | 0})`; };
+
+// ---------- 网格:水平线从左往右逐条画出(lag 错开),零线更深更粗;刻度值跟着淡入 ----------
+// F = {x,y,w,h} 绘图区;ys = 刻度值;yS = 值→屏幕 y;p = 0..1
+CH.grid = (c, F, ys, yS, p, { col = 'rgba(0,0,0,.14)', zeroCol = '#121212', lw = 1.5, zeroLw = 3, lag = 0.12, font = '28px sans-serif', labelCol = '#5b5b5b', fmt = v => String(v), side = 'right', labelDy = -10 } = {}) => {
+ c.save(); c.font = font; c.textBaseline = 'alphabetic';
+ ys.forEach((v, i) => {
+ const q = MO.lagged(i, ys.length, p, lag), e = MO.quintOut(q); if (q <= 0) return;
+ const y = Math.round(yS(v)) + 0.5, isZero = Math.abs(v) < 1e-9;
+ c.strokeStyle = isZero ? zeroCol : col; c.lineWidth = isZero ? zeroLw : lw;
+ c.beginPath(); c.moveTo(F.x, y); c.lineTo(F.x + F.w * e, y); c.stroke();
+ c.globalAlpha = seg(q, 0.3, 1); c.fillStyle = labelCol;
+ if (side === 'right') { c.textAlign = 'right'; c.fillText(fmt(v), F.x + F.w, y + labelDy); }
+ else { c.textAlign = 'left'; c.fillText(fmt(v), F.x, y + labelDy); }
+ c.globalAlpha = 1;
+ });
+ c.restore();
+};
+// x 轴标签(年份等):逐个淡入上移。items = [{x, label}]
+CH.xLabels = (c, items, y, p, { font = '28px sans-serif', col = '#3a3a3a', lag = 0.1 } = {}) => {
+ c.save(); c.font = font; c.textAlign = 'center'; c.fillStyle = col;
+ items.forEach((it, i) => { const q = MO.quintOut(MO.lagged(i, items.length, p, lag)); if (q <= 0) return; c.globalAlpha = q; c.fillText(it.label, it.x, y + (1 - q) * 14); });
+ c.restore();
+};
+
+// ---------- 柱:从基线 0 长出(quintOut),数值标签与柱顶同步计数(等宽数字) ----------
+// data: [{x, v}];bw 柱宽;p 0..1 总进度;hi 高亮下标(其余按 hiP 过渡到 dimCol)。返回各柱顶 [[x,y]]
+CH.bars = (c, data, yS, bw, p, { lag = 0.18, col = '#1f5c99', hi = -1, hiP = 0, hiCol, dimCol = '#b9c3cc', label = true, fmt = v => v.toFixed(0), font = '30px sans-serif', labelCol = '#121212' } = {}) => {
+ const y0 = yS(0), tops = [];
+ data.forEach((d, i) => {
+ const q = MO.lagged(i, data.length, p, lag), e = MO.quintOut(q);
+ const v = d.v * e, y = yS(v);
+ let fill = col;
+ if (hi >= 0) fill = i === hi ? (hiCol || col) : CH.mixHex(col, dimCol, hiP);
+ c.fillStyle = fill; c.fillRect(d.x - bw / 2, y, bw, y0 - y);
+ tops.push([d.x, y]);
+ if (label && q > 0) {
+ c.save(); c.font = font; c.textAlign = 'center'; c.fillStyle = labelCol; c.globalAlpha = seg(q, 0.05, 0.4);
+ if (d.v < 0) { c.textBaseline = 'top'; TY.tabular(c, fmt(v), d.x, y + 12, { align: 'center' }); } // 负数柱:数值写在柱底下方,别写进柱子里
+ else TY.tabular(c, fmt(v), d.x, y - 14, { align: 'center' });
+ c.restore();
+ }
+ });
+ return tops;
+};
+
+// ---------- 折线:按 x(时间)推进画出;头部圆点;可选面积渐变;返回头部点 ----------
+// pts: 屏幕坐标(x 递增);p: 0..1 = 画到 x 范围的哪里。area = {top, base, c0, c1}
+CH.line = (c, pts, p, { col = '#e3120b', lw = 5, head = true, headR = 9, area, glow } = {}) => {
+ if (p <= 0) return null;
+ const xEnd = lerp(pts[0][0], pts[pts.length - 1][0], clamp(p));
+ const vis = [pts[0]];
+ for (let i = 1; i < pts.length; i++) {
+ if (pts[i][0] <= xEnd) vis.push(pts[i]);
+ else { const a = pts[i - 1], b = pts[i], q = (xEnd - a[0]) / (b[0] - a[0]); vis.push([xEnd, lerp(a[1], b[1], q)]); break; }
+ }
+ const hp = vis[vis.length - 1];
+ if (area) {
+ const g = c.createLinearGradient(0, area.top, 0, area.base); g.addColorStop(0, area.c0); g.addColorStop(1, area.c1);
+ c.save(); c.beginPath(); c.moveTo(vis[0][0], area.base); vis.forEach(q => c.lineTo(q[0], q[1])); c.lineTo(hp[0], area.base); c.closePath(); c.fillStyle = g; c.fill(); c.restore();
+ }
+ c.save(); c.strokeStyle = col; c.lineWidth = lw; c.lineJoin = 'round'; c.lineCap = 'round';
+ if (glow) { c.shadowColor = col; c.shadowBlur = glow; }
+ c.beginPath(); vis.forEach((q, i) => i ? c.lineTo(q[0], q[1]) : c.moveTo(q[0], q[1])); c.stroke(); c.restore();
+ if (head && p < 1.0001) { c.save(); c.fillStyle = col; c.beginPath(); c.arc(hp[0], hp[1], headR, 0, Math.PI * 2); c.fill();
+ c.strokeStyle = '#fff'; c.lineWidth = 3; c.stroke(); c.restore(); }
+ return hp;
+};
+// 折线在 x 处的 y(标注要钉在线上)
+CH.yAt = (pts, x) => { for (let i = 1; i < pts.length; i++) if (pts[i][0] >= x) { const a = pts[i - 1], b = pts[i]; return lerp(a[1], b[1], (x - a[0]) / (b[0] - a[0])); } return pts[pts.length - 1][1]; };
+
+// ---------- K 线:逐根出现,实体从开盘价长到收盘价,影线随后;默认红涨绿跌(A 股惯例,海外片换成绿涨红跌并在副标题写明) ----------
+// rows: [{o,h,l,c}];xs: 每根中心 x;cw 实体宽;p 0..1
+CH.candles = (c, rows, xs, yS, cw, p, { up = '#e0322f', down = '#11a05a', lag = 0.06, hollowUp = false } = {}) => {
+ rows.forEach((r, i) => {
+ const q = MO.lagged(i, rows.length, p, lag); if (q <= 0) return;
+ const e = MO.quintOut(seg(q, 0, 0.7)), w = MO.quintOut(seg(q, 0.35, 1));
+ const isUp = r.c >= r.o, col = isUp ? up : down, x = xs[i];
+ const yo = yS(r.o), yc = lerp(yo, yS(r.c), e);
+ c.save(); c.strokeStyle = col; c.fillStyle = col; c.lineWidth = 2.5;
+ if (w > 0) { const ym = (yo + yS(r.c)) / 2; c.beginPath(); c.moveTo(x, lerp(ym, yS(r.h), w)); c.lineTo(x, lerp(ym, yS(r.l), w)); c.stroke(); }
+ const top = Math.min(yo, yc), hgt = Math.max(2, Math.abs(yc - yo));
+ if (isUp && hollowUp) { c.fillStyle = '#fff'; c.fillRect(x - cw / 2, top, cw, hgt); c.strokeRect(x - cw / 2, top, cw, hgt); }
+ else c.fillRect(x - cw / 2, top, cw, hgt);
+ c.restore();
+ });
+};
+
+// ---------- 标注:圆点弹出(弹簧)→ 脉冲环 → 引线画出 → 文字淡入。时间用秒,便于对口播 ----------
+// lt 秒;t0 开始时刻;(x,y) 数据点;(tx,ty) 文字锚点;lines 第一行用 font、其余用 font2(数字先说,比较后说)
+CH.callout = (c, lt, t0, { x, y, tx, ty, lines = [], col = '#121212', dotCol = '#e3120b', font = '600 30px sans-serif', font2, align = 'left', r = 11 }) => {
+ const k = lt - t0; if (k <= 0) return;
+ const s = MO.spring(k, { duration: 0.45, bounce: 0.25 });
+ c.save();
+ c.fillStyle = dotCol; c.beginPath(); c.arc(x, y, r * Math.max(0, s), 0, Math.PI * 2); c.fill();
+ const pr = seg(k, 0, 0.6); if (pr > 0 && pr < 1) { c.strokeStyle = dotCol; c.globalAlpha = 1 - pr; c.lineWidth = 3; c.beginPath(); c.arc(x, y, r + pr * 34, 0, Math.PI * 2); c.stroke(); c.globalAlpha = 1; }
+ const lp = MO.quintOut(seg(k, 0.12, 0.45));
+ if (lp > 0) { c.strokeStyle = col; c.lineWidth = 2; c.beginPath(); c.moveTo(x, y); c.lineTo(lerp(x, tx, lp), lerp(y, ty, lp)); c.stroke(); }
+ const fp = MO.quintOut(seg(k, 0.3, 0.7));
+ if (fp > 0) {
+ c.globalAlpha = fp; c.fillStyle = col; c.textAlign = align; c.textBaseline = 'alphabetic';
+ const dx = align === 'left' ? 12 : align === 'right' ? -12 : 0;
+ lines.forEach((L, i) => { c.font = i === 0 ? font : (font2 || font); c.fillText(L, tx + dx + (1 - fp) * (align === 'right' ? 16 : -16), ty + 8 + i * 40); });
+ }
+ c.restore();
+};
+
+// ---------- 版式 ----------
+CH.tag = (c, x, y, w = 64, h = 14, col = '#e3120b') => { c.fillStyle = col; c.fillRect(x, y, w, h); };
+// 「示意数据」角标:右下圆角框。虚构数据每一镜都要有
+CH.demoBadge = (c, text = '示意数据', { x = W - 40, y = 1040, font = '600 24px sans-serif', col = '#7a7a7a', box = 'rgba(0,0,0,.06)' } = {}) => {
+ c.save(); c.font = font; c.textAlign = 'right'; c.textBaseline = 'middle';
+ const w = c.measureText(text).width + 28; c.fillStyle = box; c.beginPath(); c.roundRect(x - w, y - 22, w, 44, 8); c.fill();
+ c.strokeStyle = col; c.globalAlpha = 0.5; c.lineWidth = 1.5; c.stroke(); c.globalAlpha = 1;
+ c.fillStyle = col; c.fillText(text, x - 14, y + 1); c.restore();
+};
+// 经济学人式整页版式(每镜都画):白底 → 顶部细红线从左画出 → 左上红色小旗 → 标题 → 副标题(单位/口径)→ 左下来源 → 右下「示意数据」。
+// lt = 本镜时间(版式 0.6s 内全部到位,之后才出坐标系)。badge 传 false 不画角标(真实数据时)。
+CH.frame = (c, lt, { title, sub, source = '来源:示意数据', badge = '示意数据', bg = '#FFFFFF', red = '#E3120B', ink = '#0C0C0C', subCol = '#4F5B61', srcCol = '#7c868b',
+ font = '"NotoSansSC"', x = 90 } = {}) => {
+ c.fillStyle = bg; c.fillRect(0, 0, W, H);
+ const p = MO.quintOut(MO.seg(lt, 0, 0.45));
+ c.fillStyle = red; c.fillRect(0, 0, W * p, 8);
+ CH.tag(c, x, 56, 96 * p, 22, red);
+ c.save(); c.textBaseline = 'alphabetic'; c.textAlign = 'left';
+ const tp = MO.quintOut(MO.seg(lt, 0.05, 0.5));
+ c.globalAlpha = tp; c.font = `700 58px ${font}`; c.fillStyle = ink; c.fillText(title, x, 150 + (1 - tp) * 18);
+ const sp = MO.quintOut(MO.seg(lt, 0.15, 0.6));
+ c.globalAlpha = sp; c.font = `400 34px ${font}`; c.fillStyle = subCol; c.fillText(sub, x, 205 + (1 - sp) * 14);
+ c.globalAlpha = 1; c.font = `400 26px ${font}`; c.fillStyle = srcCol; c.fillText(source, x, 1040);
+ c.restore();
+ if (badge) CH.demoBadge(c, badge, { x: W - 60, y: 1030, font: `700 28px ${font}`, col: red, box: 'rgba(227,18,11,0.06)' });
+};
+})();
diff --git a/scripts/engine/lib/collage.js b/scripts/engine/lib/collage.js
new file mode 100644
index 0000000..f3491e4
--- /dev/null
+++ b/scripts/engine/lib/collage.js
@@ -0,0 +1,97 @@
+// 拼贴材料 CL(Vox / Missing Chapter / Borders 一路):纸纹、撕纸边、网点照片、胶带、图钉、红线(下垂的线索绳)、
+// 毛边荧光笔(multiply)、轻投影、带倾斜滑入放平、剪纸贴纸白边。
+// 节奏铁律(y2 调研):相机 60fps 平滑;桌上的纸片/荧光笔/红笔/打字按 12fps「一拍二」步进(MO.step)——stop-motion 手感的一半。
+// 纸纹是贴死的(静态颗粒,不逐帧抖)。素材一次画好走 PAINT.cached,确定性。
+(() => {
+let W = 1920, H = 1080; U.onStage((w, h) => { W = w; H = h; }); // 画布尺寸跟 U.setStage 走(默认 1920×1080)
+const { clamp, lerp, rng } = U;
+const CL = window.CL = {};
+
+// ---------- 纸 ----------
+// 可平铺纸纹 tile:环面取样的 fbm 明暗(无缝)+纤维短线+细颗粒。用 c.createPattern(tile, 'repeat') 铺
+CL.paperTile = (key, base, { size = 512, amt = 10, fibers = 260, grain = 10, fiberCol = [120, 100, 70], seed = 3 } = {}) => PAINT.cached('ytpaper_' + key, size, size, (g) => {
+ const img = g.createImageData(size, size), d = img.data, b = PAINT.hex(base), r = rng(seed);
+ for (let y = 0; y < size; y++) for (let x = 0; x < size; x++) {
+ const ax = x / size * Math.PI * 2, ay = y / size * Math.PI * 2;
+ const n = PAINT.fbm(Math.cos(ax) * 1.6 + 10, Math.sin(ax) * 1.6 + Math.cos(ay) * 1.6, 4) * 0.6 + PAINT.noise(Math.sin(ay) * 3 + 5, Math.cos(ay) * 3) * 0.4;
+ const gr = (r() - .5) * grain, i = (y * size + x) * 4;
+ d[i] = b[0] + n * amt + gr; d[i + 1] = b[1] + n * amt + gr; d[i + 2] = b[2] + n * amt * 0.9 + gr; d[i + 3] = 255;
+ }
+ g.putImageData(img, 0, 0);
+ g.lineCap = 'round';
+ for (let k = 0; k < fibers; k++) { const x = r() * size, y = r() * size, a = r() * Math.PI, l = 4 + r() * 14;
+ g.strokeStyle = PAINT.rgb(fiberCol, 0.05 + r() * 0.08); g.lineWidth = 0.6 + r() * 0.8;
+ for (const ox of [0, -size, size]) for (const oy of [0, -size, size]) { g.beginPath(); g.moveTo(x + ox, y + oy); g.quadraticCurveTo(x + ox + Math.cos(a + 1) * l * 0.5, y + oy + Math.sin(a + 1) * l * 0.5, x + ox + Math.cos(a) * l, y + oy + Math.sin(a) * l); g.stroke(); } }
+});
+CL.fillPaper = (c, tile, x, y, w, h) => { c.save(); c.fillStyle = c.createPattern(tile, 'repeat'); c.fillRect(x, y, w, h); c.restore(); };
+// 撕纸边:沿一条线生成锯齿+纤维的点列(左→右),amp 起伏、seed 固定
+CL.tornEdge = (x0, y0, x1, y1, { step = 9, amp = 10, seed = 5 } = {}) => {
+ const r = rng(seed), L = Math.hypot(x1 - x0, y1 - y0), n = Math.max(2, Math.round(L / step)), nx = -(y1 - y0) / L, ny = (x1 - x0) / L, o = [];
+ for (let i = 0; i <= n; i++) { const q = i / n, k = PAINT.noise(i * 0.18, seed) * amp + (r() - .5) * amp * 0.9; o.push([lerp(x0, x1, q) + nx * k, lerp(y0, y1, q) + ny * k]); }
+ return o;
+};
+// 撕边矩形 (0,0,w,h):只建路径(beginPath…closePath),调用方 fill / clip
+CL.tornRect = (g, w, h, seed, amp = 5) => {
+ const pts = [...CL.tornEdge(0, 0, w, 0, { amp, seed }), ...CL.tornEdge(w, 0, w, h, { amp, seed: seed + 1 }), ...CL.tornEdge(w, h, 0, h, { amp, seed: seed + 2 }), ...CL.tornEdge(0, h, 0, 0, { amp, seed: seed + 3 })];
+ g.beginPath(); pts.forEach((p, i) => i ? g.lineTo(p[0], p[1]) : g.moveTo(p[0], p[1])); g.closePath();
+};
+
+// ---------- 网点照片 ----------
+// 灰度网点:源图(canvas)按亮度转成 45° 网点,cell 像素一格;只留在源图不透明处。结果缓存(key 唯一)
+CL.halftone = (key, src, { cell = 7, ink = '#1b1b1b', paper = '#efe9dc', angle = Math.PI / 4, gamma = 1, contrast = 1.15 } = {}) => PAINT.cached('ytht_' + key, src.width, src.height, (g) => {
+ const w = src.width, h = src.height, sd = src.getContext('2d').getImageData(0, 0, w, h).data;
+ g.fillStyle = paper; g.fillRect(0, 0, w, h); g.fillStyle = ink;
+ const ca = Math.cos(angle), sa = Math.sin(angle), R = Math.hypot(w, h);
+ g.beginPath();
+ for (let v = -R; v < R; v += cell) for (let u = -R; u < R; u += cell) {
+ const x = w / 2 + u * ca - v * sa, y = h / 2 + u * sa + v * ca; if (x < -cell || y < -cell || x > w + cell || y > h + cell) continue;
+ const ix = clamp(x | 0, 0, w - 1), iy = clamp(y | 0, 0, h - 1), i = (iy * w + ix) * 4;
+ if (sd[i + 3] < 10) continue;
+ let L = (sd[i] * .3 + sd[i + 1] * .59 + sd[i + 2] * .11) / 255; L = clamp((L - 0.5) * contrast + 0.5); L = Math.pow(L, gamma);
+ const rr = cell * 0.62 * Math.sqrt(1 - L); if (rr < 0.4) continue;
+ g.moveTo(x + rr, y); g.arc(x, y, rr, 0, Math.PI * 2);
+ }
+ g.fill();
+ g.globalCompositeOperation = 'destination-in'; g.drawImage(src, 0, 0); g.globalCompositeOperation = 'source-over';
+});
+// 网点照片贴纸:draw(g, w, h) 画源图 → 网点 → 加 border 宽的纸边、一层旧纸色(multiply)。返回缓存 canvas(尺寸 w+2b × h+2b)
+CL.photo = (key, w, h, draw, { border = 14, cell = 6, paper = '#f2f0ea', ink = '#1a1a1a', htPaper = '#e8e4da', contrast = 1.3 } = {}) => PAINT.cached('clphoto_' + key, w + border * 2, h + border * 2, (g) => {
+ const src = PAINT.canvas(w, h); draw(src.getContext('2d'), w, h);
+ const ht = CL.halftone(key + '_ht', src, { cell, ink, paper: htPaper, contrast });
+ g.fillStyle = paper; g.fillRect(0, 0, w + border * 2, h + border * 2); g.drawImage(ht, border, border);
+ g.globalCompositeOperation = 'multiply'; g.fillStyle = 'rgba(214,205,185,.3)'; g.fillRect(0, 0, w + border * 2, h + border * 2); g.globalCompositeOperation = 'source-over';
+});
+
+// ---------- 摆放 ----------
+CL.placed = (g, x, y, r, fn) => { g.save(); g.translate(x, y); g.rotate(r); fn(g); g.restore(); };
+// 轻投影(Vox 桌面上留一点就够;黑底卡片几乎无投影)
+CL.shadowed = (g, fn, { col = 'rgba(50,40,25,.28)', blur = 10, x = 3, y = 6 } = {}) => { g.save(); g.shadowColor = col; g.shadowBlur = blur; g.shadowOffsetX = x; g.shadowOffsetY = y; fn(); g.restore(); };
+// 带倾斜滑入、到位放平(MC 实测:滑入带 5–15° 倾斜,约 0.6–0.8s),按 12fps 步进。返回进度 q
+CL.slideIn = (g, t, t0, x, y, r, fn, { from = [420, -60], tilt = 0.2, dur = 0.6, fps = 12 } = {}) => {
+ const q = clamp((MO.step(t, fps) - t0) / dur); if (q <= 0) return 0;
+ const e = MO.quartOut(q);
+ g.save(); g.translate(x + from[0] * (1 - e), y + from[1] * (1 - e)); g.rotate(r + tilt * (1 - Math.min(1, e * 1.15))); fn(g); g.restore(); return q;
+};
+// 胶带:一条半透明撕边纸条
+CL.tape = (g, x, y, a, w = 120, col = 'rgba(226,220,200,.85)') => { g.save(); g.translate(x, y); g.rotate(a); g.fillStyle = col; g.translate(-w / 2, -17); CL.tornRect(g, w, 34, (x * 7 + y) | 0, 3); g.fill(); g.restore(); };
+// 图钉
+CL.pin = (g, x, y, col = '#b8433f') => { g.save(); g.translate(x, y); g.fillStyle = 'rgba(0,0,0,.25)'; g.beginPath(); g.arc(3, 5, 12, 0, 7); g.fill(); g.fillStyle = col; g.beginPath(); g.arc(0, 0, 12, 0, 7); g.fill(); g.fillStyle = 'rgba(255,255,255,.55)'; g.beginPath(); g.arc(-4, -4, 4, 0, 7); g.fill(); g.restore(); };
+// 调查墙的线索绳:a→b 之间按长度 sag 下垂的二次曲线点列(配 DG.cum / DG.drawPartial 逐段描出)
+CL.stringPts = (a, b, sag = 0.08, n = 48) => { const mx = (a[0] + b[0]) / 2, my = (a[1] + b[1]) / 2 + Math.hypot(b[0] - a[0], b[1] - a[1]) * sag; const o = []; for (let i = 0; i <= n; i++) { const t = i / n, u = 1 - t; o.push([u * u * a[0] + 2 * u * t * mx + t * t * b[0], u * u * a[1] + 2 * u * t * my + t * t * b[1]]); } return o; };
+// 红线:带投影描出前 d 长度(d 用弧长;整根画完传 1e9)
+CL.string = (g, pts, cum, d, { col = '#b8433f', lw = 5, shadow = 'rgba(0,0,0,.16)' } = {}) => {
+ if (shadow) { g.save(); g.strokeStyle = shadow; g.lineWidth = lw; g.translate(3, 6); DG.drawPartial(g, pts, cum, d); g.restore(); }
+ g.save(); g.strokeStyle = col; g.lineWidth = lw; g.lineCap = 'round'; DG.drawPartial(g, pts, cum, d); g.restore();
+};
+// 毛边荧光笔(multiply,压在印刷字上):q 0..1 从左扫到右
+CL.highlight = (g, x0, y0, w, h, q, col = 'rgba(218,207,8,.9)') => { if (q <= 0) return; g.save(); g.globalCompositeOperation = 'multiply'; g.fillStyle = col;
+ g.beginPath(); const ww = w * q; g.moveTo(x0, y0 + 4); for (let i = 0; i <= 20; i++) g.lineTo(x0 + ww * i / 20, y0 + Math.sin(i * 1.7) * 2); g.lineTo(x0 + ww + 6, y0 + h / 2); g.lineTo(x0 + ww, y0 + h);
+ for (let i = 20; i >= 0; i--) g.lineTo(x0 + ww * i / 20, y0 + h + Math.sin(i * 2.3) * 2); g.closePath(); g.fill(); g.restore(); };
+// 剪纸贴纸白边:把 src(全屏离屏里的角色/物件)向四周膨胀 border 像素铺 col,返回同尺寸离屏;用法:先画返回值、再画 src
+CL.stickerEdge = (src, key, border = 12, col = '#f4f2ec', dirs = 16) => {
+ const sil = PAINT.scratch(key), sg = sil.getContext('2d'); sg.reset();
+ for (let a = 0; a < dirs; a++) sg.drawImage(src, Math.cos(a / dirs * 6.283) * border, Math.sin(a / dirs * 6.283) * border);
+ sg.globalCompositeOperation = 'source-in'; sg.fillStyle = col; sg.fillRect(0, 0, W, H);
+ return sil;
+};
+})();
diff --git a/scripts/engine/lib/diagram.js b/scripts/engine/lib/diagram.js
new file mode 100644
index 0000000..8baf28f
--- /dev/null
+++ b/scripts/engine/lib/diagram.js
@@ -0,0 +1,264 @@
+// 图解与形变 DG:点列、逐笔描出(draw-on)、揭开遮罩、手绘抖动线、manim 式 Transform / Write、白板笔画时间线+跟随的笔、
+// 神经网络(神经元/连线/信号闪过)、Indicate / Circumscribe / 大括号、3b1b 色板。
+// 约定:点列 pts = [[x,y],...];cum = DG.cum(pts) 是累计弧长;「画到 d」都按弧长算。确定性:随机全走种子。
+(() => {
+let W = 1920, H = 1080; U.onStage((w, h) => { W = w; H = h; }); // 画布尺寸跟 U.setStage 走(默认 1920×1080)
+const { clamp, lerp, rng } = U;
+const DG = window.DG = {};
+
+// ---------- 点列 ----------
+DG.cum = pts => { const L = [0]; for (let i = 1; i < pts.length; i++) L.push(L[i - 1] + Math.hypot(pts[i][0] - pts[i - 1][0], pts[i][1] - pts[i - 1][1])); return L; };
+DG.len = pts => { const L = DG.cum(pts); return L[L.length - 1]; };
+// 折线上弧长 d 处的点
+DG.pointAt = (pts, cum, d) => {
+ if (d <= 0) return pts[0]; const n = pts.length; if (d >= cum[n - 1]) return pts[n - 1];
+ let lo = 0, hi = n - 1; while (hi - lo > 1) { const m = (lo + hi) >> 1; if (cum[m] < d) lo = m; else hi = m; }
+ const q = (d - cum[lo]) / (cum[hi] - cum[lo] || 1); return [lerp(pts[lo][0], pts[hi][0], q), lerp(pts[lo][1], pts[hi][1], q)];
+};
+// 逐笔描出:画折线的前 d 长度(用当前 strokeStyle/lineWidth),返回笔尖位置。白板、红笔圈、红线连接都用它。
+DG.drawPartial = (c, pts, cum, d) => {
+ const n = pts.length; if (d <= 0 || n < 2) return pts[0];
+ c.beginPath(); c.moveTo(pts[0][0], pts[0][1]);
+ let i = 1; for (; i < n && cum[i] <= d; i++) c.lineTo(pts[i][0], pts[i][1]);
+ let tip = pts[n - 1];
+ if (i < n) { tip = DG.pointAt(pts, cum, d); c.lineTo(tip[0], tip[1]); }
+ c.stroke(); return tip;
+};
+// 变换点列:平移 (dx,dy)、缩放 s
+DG.xform = (pts, dx, dy, s = 1) => pts.map(([x, y]) => [dx + x * s, dy + y * s]);
+// 椭圆弧点列(a0→a1)
+DG.arcPts = (cx, cy, rx, ry, a0, a1, n = 24) => { const o = []; for (let i = 0; i <= n; i++) { const a = a0 + (a1 - a0) * i / n; o.push([cx + Math.cos(a) * rx, cy + Math.sin(a) * ry]); } return o; };
+// 手画的圈:从 a0 起转 turns 圈(>1 首尾略交叉,像真的用笔圈)
+DG.ellipsePts = (cx, cy, rx, ry, a0 = -Math.PI / 2, turns = 1.08, n = 64) => DG.arcPts(cx, cy, rx, ry, a0, a0 + turns * Math.PI * 2, n);
+// 手绘抖动:Catmull-Rom 加密后按种子加低频抖动(静态,不沸腾——白板上的线画完就不动)
+DG.hand = (pts, { per = 8, amp = 1.6, seed = 1, freq = 0.035 } = {}) => {
+ const d = KIT.densify(pts, per), r = rng(seed), ph = r() * 100;
+ return KIT.resample(d, 3).map(([x, y], i) => [x + PAINT.noise(i * freq + ph, 3.1) * amp * 2, y + PAINT.noise(i * freq + ph, 7.7) * amp * 2]);
+};
+// 揭开遮罩:沿折线前 d 长度,每段做成同向绕行的方条(方头延长 w/2),合成一条 Path2D 用来 clip。
+// VideoScribe 的「Reveal」画法:之字形笔触从上往下揭开一张画;也用于逐字书写。同向绕行保证 nonzero 下重叠处不抵消。
+DG.revealMask = (pts, cum, d, w) => {
+ const p = new Path2D(), h = w / 2;
+ for (let i = 1; i < pts.length && cum[i - 1] < d; i++) {
+ const a = pts[i - 1], b0 = pts[i], L = cum[i] - cum[i - 1]; if (L <= 0) continue;
+ const q = Math.min(1, (d - cum[i - 1]) / L), b = [a[0] + (b0[0] - a[0]) * q, a[1] + (b0[1] - a[1]) * q];
+ const ux = (b0[0] - a[0]) / L, uy = (b0[1] - a[1]) / L, nx = -uy * h, ny = ux * h;
+ const A = [a[0] - ux * h, a[1] - uy * h], B = [b[0] + ux * h, b[1] + uy * h];
+ p.moveTo(A[0] + nx, A[1] + ny); p.lineTo(B[0] + nx, B[1] + ny); p.lineTo(B[0] - nx, B[1] - ny); p.lineTo(A[0] - nx, A[1] - ny); p.closePath();
+ }
+ return p;
+};
+// 之字形揭开路径:在框 (x,y,w,h) 里从上往下 rows 行来回
+DG.zigzag = (x, y, w, h, rows) => { const o = []; for (let r = 0; r <= rows; r++) { const yy = y + h * r / rows; o.push(r % 2 ? [x + w, yy] : [x, yy]); } return o; };
+
+// ---------- manim Transform:两边点数相同、起点对齐(都从左上方向起、顺时针)才能逐点插值 ----------
+DG.rectPts = (cx, cy, w, h, n = 64) => {
+ const per = 2 * (w + h), out = [];
+ for (let i = 0; i < n; i++) {
+ let d = i / n * per; let x, y;
+ if (d < w) { x = cx - w / 2 + d; y = cy - h / 2; }
+ else if ((d -= w) < h) { x = cx + w / 2; y = cy - h / 2 + d; }
+ else if ((d -= h) < w) { x = cx + w / 2 - d; y = cy + h / 2; }
+ else { d -= w; x = cx - w / 2; y = cy + h / 2 - d; }
+ out.push([x, y]);
+ }
+ return out;
+};
+DG.circlePts = (cx, cy, r, n = 64) => { const out = []; for (let i = 0; i < n; i++) { const a = -3 * Math.PI / 4 + i / n * 2 * Math.PI; out.push([cx + Math.cos(a) * r, cy + Math.sin(a) * r]); } return out; };
+DG.morph = (A, B, p) => A.map((a, i) => [lerp(a[0], B[i][0], p), lerp(a[1], B[i][1], p)]);
+DG.shape = (c, pts, { fill, stroke, lw = 2 } = {}) => {
+ c.beginPath(); pts.forEach((q, i) => i ? c.lineTo(q[0], q[1]) : c.moveTo(q[0], q[1])); c.closePath();
+ if (fill) { c.fillStyle = fill; c.fill(); }
+ if (stroke && lw > 0) { c.strokeStyle = stroke; c.lineWidth = lw; c.lineJoin = 'round'; c.stroke(); }
+};
+
+// ---------- 颜色(接受 '#hex' 或 [r,g,b]) ----------
+DG.arr = h => Array.isArray(h) ? h : PAINT.hex(h);
+DG.mixA = (h1, h2, t) => { const a = DG.arr(h1), b = DG.arr(h2); return [lerp(a[0], b[0], t), lerp(a[1], b[1], t), lerp(a[2], b[2], t)]; };
+DG.rgba = (h, a = 1) => { const v = DG.arr(h); return `rgba(${v[0] | 0},${v[1] | 0},${v[2] | 0},${a})`; };
+DG.mix = (h1, h2, t) => DG.rgba(DG.mixA(h1, h2, t));
+// 3b1b 色板。Grant 的 custom_config 在 ffmpeg 导出时 saturation=1.5,照 manim 原色值直接用会发灰,所以 DG.MANIM 是饱和后的。
+DG.MANIM_RAW = { BLUE_C: '#58C4DD', BLUE_D: '#29ABCA', BLUE_E: '#1C758A', TEAL_C: '#5CD0B3', GREEN_C: '#83C167', YELLOW: '#FFFF00', GOLD_C: '#F0AC5F',
+ RED_C: '#FC6255', MAROON_C: '#C55F73', PURPLE_C: '#9A72AC', GREY_A: '#DDDDDD', GREY_B: '#BBBBBB', GREY_C: '#888888', GREY_D: '#444444', GREY_E: '#222222', WHITE: '#FFFFFF', BLACK: '#000000' };
+DG.saturate = (hex, s = 1.5) => { // CSS/SVG saturate 矩阵
+ const [r, g, b] = PAINT.hex(hex);
+ const R = (0.213 + 0.787 * s) * r + (0.715 - 0.715 * s) * g + (0.072 - 0.072 * s) * b;
+ const G = (0.213 - 0.213 * s) * r + (0.715 + 0.285 * s) * g + (0.072 - 0.072 * s) * b;
+ const B = (0.213 - 0.213 * s) * r + (0.715 - 0.715 * s) * g + (0.072 + 0.928 * s) * b;
+ const f = v => Math.round(clamp(v, 0, 255)).toString(16).padStart(2, '0');
+ return '#' + f(R) + f(G) + f(B);
+};
+DG.MANIM = {}; for (const k in DG.MANIM_RAW) DG.MANIM[k] = DG.saturate(DG.MANIM_RAW[k]);
+DG.U = H / 8; // manim:画面高 8 个单位 → 1 单位 = 135px(1080p)
+
+// ---------- Write 与公式(CMU = LaTeX Computer Modern;中文用思源宋) ----------
+DG.FONT = { rm: 'CMU-rm', it: 'CMU-it', zh: 'NotoSerifSC' };
+const famOf = tk => tk.zh ? DG.FONT.zh : tk.it ? DG.FONT.it : DG.FONT.rm;
+// tokens: [{s, it, zh, col, sub, sup, size, gap}];返回每个 token 的 {x,w,sz}(相对起点)
+DG.layout = (c, tokens, size) => {
+ let x = 0; return tokens.map(tk => {
+ const sz = (tk.size || 1) * size; c.font = `${sz}px "${famOf(tk)}"`;
+ const w = c.measureText(tk.s).width; let sw = 0;
+ if (tk.sub || tk.sup) { c.font = `${sz * 0.62}px "${DG.FONT.rm}"`; sw = c.measureText(tk.sub || tk.sup).width + sz * 0.04; }
+ const r = { x, w: w + sw, sz }; x += w + sw + (tk.gap != null ? tk.gap : sz * 0.06); return r;
+ });
+};
+// manim Write:每个 token 先沿轮廓描边(lineDash 推进),后半程填色、描边淡掉;token 间 lag = min(4/(n+1), 0.2)(3b1b creation.py)。
+// 尊重外层 globalAlpha(FadeOut 时整条公式一起淡)。返回每个 token 的屏幕 {x,w}。
+DG.math = (c, tokens, x, y, size, { p = 1, align = 'center', col = '#fff', lag } = {}) => {
+ const L = DG.layout(c, tokens, size), total = L.length ? L[L.length - 1].x + L[L.length - 1].w : 0;
+ const x0 = align === 'center' ? x - total / 2 : align === 'right' ? x - total : x;
+ const n = tokens.length, r = lag != null ? lag : Math.min(4 / (n + 1), 0.2);
+ const A0 = c.globalAlpha;
+ c.save(); c.textBaseline = 'alphabetic'; c.textAlign = 'left';
+ tokens.forEach((tk, i) => {
+ const q = MO.lagged(i, n, clamp(p), r); if (q <= 0) return;
+ const sz = L[i].sz, fx = x0 + L[i].x, colr = tk.col || col;
+ const draw = (txt, xx, yy, f, mode) => { c.font = f; mode === 's' ? c.strokeText(txt, xx, yy) : c.fillText(txt, xx, yy); };
+ const main = `${sz}px "${famOf(tk)}"`, small = `${sz * 0.62}px "${DG.FONT.rm}"`;
+ c.font = main; const mw = c.measureText(tk.s).width;
+ const parts = [[tk.s, fx, y, main]]; if (tk.sub) parts.push([tk.sub, fx + mw + sz * 0.02, y + sz * 0.22, small]); if (tk.sup) parts.push([tk.sup, fx + mw + sz * 0.02, y - sz * 0.42, small]);
+ const qs = MO.doubleSmooth(q);
+ if (qs < 1) { c.strokeStyle = colr; c.lineWidth = Math.max(1.2, sz * 0.025); c.setLineDash([sz * 5 * clamp(qs * 2), 1e5]); c.globalAlpha = A0 * (1 - clamp((qs - 0.6) / 0.4)); parts.forEach(pt => draw(pt[0], pt[1], pt[2], pt[3], 's')); c.setLineDash([]); }
+ const fa = clamp((qs - 0.4) / 0.6); if (fa > 0) { c.globalAlpha = A0 * fa; c.fillStyle = colr; parts.forEach(pt => draw(pt[0], pt[1], pt[2], pt[3], 'f')); }
+ c.globalAlpha = A0;
+ });
+ c.restore();
+ return L.map(l => ({ x: x0 + l.x, w: l.w }));
+};
+// 纯文本的 Write(中文标题也走这个:非 ASCII 字自动用 DG.FONT.zh)
+DG.write = (c, text, x, y, size, p, opt = {}) => DG.math(c, [...text].map(ch => ({ s: ch, zh: /[^\x00-\x7f]/.test(ch) || opt.zh, gap: 0 })), x, y, size, { ...opt, p });
+
+// ---------- 神经网络 ----------
+// 神经元:描边白 2px,填充不透明度 = 激活值(3b1b nn/part1.py 原做法)
+DG.neuron = (c, x, y, r, a, { stroke = '#fff', fill = '#fff', lw = 2, sa = 1 } = {}) => {
+ c.save(); c.beginPath(); c.arc(x, y, r, 0, Math.PI * 2);
+ if (a > 0) { c.globalAlpha = clamp(a); c.fillStyle = fill; c.fill(); }
+ c.globalAlpha = sa; c.strokeStyle = stroke; c.lineWidth = lw; c.stroke(); c.restore();
+};
+// 圆周到圆周的连线端点
+DG.edgeEnds = (ax, ay, ar, bx, by, br) => { const dx = bx - ax, dy = by - ay, d = Math.hypot(dx, dy) || 1; return [ax + dx / d * ar, ay + dy / d * ar, bx - dx / d * br, by - dy / d * br]; };
+// 连线:正权重蓝、负权重红;线宽 = minW + maxW·|w|³(nn/part2.py:3·(|w|/max)³);p = 画到哪(ShowCreation)
+DG.edge = (c, e, w, p = 1, { maxW = 3.2, minW = 0.6, pos = DG.MANIM.BLUE_C, neg = DG.MANIM.RED_C, alpha = 0.85, from = 0 } = {}) => {
+ if (p <= from) return;
+ const [x1, y1, x2, y2] = e;
+ c.save(); c.strokeStyle = w >= 0 ? pos : neg; c.globalAlpha = alpha; c.lineWidth = minW + maxW * Math.pow(Math.min(1, Math.abs(w)), 3);
+ c.beginPath(); c.moveTo(lerp(x1, x2, from), lerp(y1, y2, from)); c.lineTo(lerp(x1, x2, p), lerp(y1, y2, p)); c.stroke(); c.restore();
+};
+// ShowPassingFlash(time_width=2.0):信号沿线闪过,返回可见段 [lo, hi](0..1)
+DG.flash = (alpha, tw = 2) => { const up = lerp(0, 1 + tw, alpha); return [clamp(up - tw), clamp(up)]; };
+
+// ---------- 提示 ----------
+DG.indicate = p => ({ s: 1 + 0.2 * MO.thereAndBack(clamp(p)), k: MO.thereAndBack(clamp(p)) }); // 放大 1.2、染黄(k)、回来
+// Circumscribe:矩形框沿周长画出再收走(time_width 0.3 的近似)
+DG.circumscribe = (c, x, y, w, h, p, { col = DG.MANIM.YELLOW, lw = 4, tw = 0.3 } = {}) => {
+ if (p <= 0 || p >= 1) return; const pts = DG.rectPts(x + w / 2, y + h / 2, w, h, 160);
+ const hi = clamp(lerp(0, 1 + tw, p)), lo = clamp(hi - tw - (1 - p) * 0.7);
+ c.save(); c.strokeStyle = col; c.lineWidth = lw; c.beginPath();
+ const i0 = Math.floor(lo * 160), i1 = Math.floor(hi * 160); for (let i = i0; i <= Math.min(160, i1); i++) { const q = pts[i % 160]; i === i0 ? c.moveTo(q[0], q[1]) : c.lineTo(q[0], q[1]); } c.stroke(); c.restore();
+};
+// 大括号(竖直,开口朝右),从中间向两端长出
+DG.brace = (c, x, y0, y1, { col = '#fff', lw = 3, depth = 22, p = 1 } = {}) => {
+ if (p <= 0) return; const ym = (y0 + y1) / 2;
+ c.save(); c.strokeStyle = col; c.lineWidth = lw; c.lineCap = 'round'; c.globalAlpha = clamp(p * 1.5);
+ const k = MO.smooth(p), a0 = lerp(ym, y0, k), a1 = lerp(ym, y1, k);
+ c.beginPath(); c.moveTo(x, a0); c.quadraticCurveTo(x - depth * 0.5, a0, x - depth * 0.5, a0 + Math.min(40, (ym - a0) * 0.3));
+ c.lineTo(x - depth * 0.5, ym - Math.min(40, (ym - a0) * 0.3)); c.quadraticCurveTo(x - depth * 0.5, ym, x - depth, ym);
+ c.quadraticCurveTo(x - depth * 0.5, ym, x - depth * 0.5, ym + Math.min(40, (a1 - ym) * 0.3));
+ c.lineTo(x - depth * 0.5, a1 - Math.min(40, (a1 - ym) * 0.3)); c.quadraticCurveTo(x - depth * 0.5, a1, x, a1); c.stroke(); c.restore();
+};
+
+// ---------- 白板:笔画时间线 + 一支跟着画的笔 ----------
+// 按顺序往板上加笔画,每笔时长 = 长度 / 笔速,自动排成时间线;画的时候笔尖永远在最新那一笔的前沿,两笔之间沿弧线滑过去,笔从不离开画面。
+// const B = DG.board({ ink, lw, speed, font }); B.at(0.12); B.line(pts); B.text('猫?', x, y, 150, {rate: 7.5}); B.pop('×1000万张', x, y, 74); ...
+// 每帧:const { tip, col } = B.draw(g, ft)(在世界坐标里画,调用方先套相机);const [sx, sy] = B.penAt(ft, cam, tip);DG.pen(c, sx, sy, col || B.penColor(ft))。
+// 自定义笔画 B.push({ kind:'custom', t0, t1, col, draw(g, q, ft) → 笔尖|null, start() → 世界点, end() → 世界点, handed:true })。
+// 速度口径(RSA 实测):正文写字 ≈16 字/秒、标题 ≈7.5 字/秒;强调色关键词不带手、整词弹出(后期合成)。
+DG.board = ({ ink = '#0A0503', lw = 6.5, speed = 2600, font = '"LXGWWenKai-500"' } = {}) => {
+ const B = { S: [], cur: 0, ink, lw, speed, font };
+ B.at = t => { B.cur = t; return B; };
+ B.push = s => { B.S.push(s); return s; };
+ B.line = (raw, { w = lw, col = ink, speed: sp = speed, seed = B.S.length + 1, amp = 1.4, smooth = true, min = 0.04, gap = 0.02 } = {}) => {
+ const pts = smooth ? DG.hand(raw, { amp, seed, per: 8 }) : raw, cum = DG.cum(pts), len = cum[cum.length - 1];
+ const d = Math.max(min, len / sp); B.S.push({ kind: 'line', pts, cum, len, w, col, t0: B.cur, t1: B.cur + d }); B.cur += d + gap;
+ };
+ // 一笔直线(不抖、固定时长,比如网络连线),不推进太多时间
+ B.segment = (a, b, { w = 3, col = ink, dur = 0.06, gap = 0.012 } = {}) => {
+ const L = Math.hypot(b[0] - a[0], b[1] - a[1]); B.S.push({ kind: 'line', pts: [a, b], cum: [0, L], len: L, w, col, t0: B.cur, t1: B.cur + dur }); B.cur += gap;
+ };
+ // 手写字:rate 字/秒
+ B.text = (str, x, y, size, { col = ink, rate = 16, align = 'left', dur } = {}) => {
+ const d = dur || [...str].length / rate; B.S.push({ kind: 'text', str, x, y, size, col, align, t0: B.cur, t1: B.cur + d }); B.cur += d + 0.03;
+ };
+ // 强调词:不带手、0.3s 放大回落整词弹出
+ B.pop = (str, x, y, size, { col = ink, align = 'center', dur = 0.3 } = {}) => { B.S.push({ kind: 'pop', str, x, y, size, col, align, t0: B.cur, t1: B.cur + dur }); B.cur += 0.12; };
+ // 铺色(淡入,不推进时间)
+ B.fill = (path, col, dur = 0.18) => { B.S.push({ kind: 'fill', path, col, t0: B.cur, t1: B.cur + dur }); };
+
+ const drawOne = (g, s, ft) => {
+ if (ft < s.t0) return null;
+ const q = clamp((ft - s.t0) / (s.t1 - s.t0));
+ if (s.kind === 'custom') return s.draw(g, q, ft);
+ if (s.kind === 'fill') { g.save(); g.globalAlpha = q; g.fillStyle = s.col; g.fill(s.path); g.restore(); return null; }
+ if (s.kind === 'line') { g.strokeStyle = s.col; g.lineWidth = s.w; return DG.drawPartial(g, s.pts, s.cum, s.len * MO.sineInOut(q)); }
+ if (s.kind === 'pop') {
+ g.save(); g.font = `${s.size}px ${B.font}`; g.fillStyle = s.col; g.textBaseline = 'alphabetic'; g.textAlign = s.align;
+ const e = MO.backOut(q, 2.2); g.globalAlpha = clamp(q * 4); g.translate(s.x, s.y - s.size * 0.35); g.scale(e, e); g.fillText(s.str, 0, s.size * 0.35); g.restore(); return null;
+ }
+ if (s.kind === 'text') {
+ // 逐字写:笔尖在字框里 3 行之字形来回,遮罩跟着笔尖揭开这个字(Reveal 画法用在单字上)
+ g.save(); g.font = `${s.size}px ${B.font}`; g.fillStyle = s.col; g.textBaseline = 'alphabetic';
+ const chars = [...s.str], ws = chars.map(ch => g.measureText(ch).width), w = ws.reduce((a, b) => a + b, 0), x0 = s.align === 'center' ? s.x - w / 2 : s.x;
+ const n = chars.length, k = Math.min(n, q * n), done = Math.floor(k);
+ let x = x0, tip = null;
+ chars.forEach((ch, i) => {
+ if (i < done) g.fillText(ch, x, s.y);
+ else if (i === done && k < n) {
+ const zz = DG.zigzag(x - 2, s.y - s.size * 0.95, ws[i] + 4, s.size * 1.15, 3), cum = DG.cum(zz), d = cum[cum.length - 1] * (k - done);
+ g.save(); g.clip(DG.revealMask(zz, cum, d, s.size * 0.62)); g.fillText(ch, x, s.y); g.restore(); tip = DG.pointAt(zz, cum, d);
+ }
+ x += ws[i];
+ });
+ g.restore(); return tip || [x0 + w, s.y - s.size * 0.35];
+ }
+ return null;
+ };
+ // 画全部笔画(世界坐标)。返回正在画的那一笔的笔尖与墨色(没有在画的 → tip=null)
+ B.draw = (g, ft) => {
+ g.lineJoin = 'round'; g.lineCap = 'round';
+ let tip = null, col = null;
+ for (const s of B.S) { const p = drawOne(g, s, ft); if (p && ft < s.t1) { tip = p; col = s.col; } }
+ return { tip, col };
+ };
+ const handed = () => B.S.filter(s => s.kind !== 'pop' && s.kind !== 'fill' && (s.kind !== 'custom' || s.handed !== false));
+ const tw = s => s.size * [...s.str].length * 0.9;
+ const endPt = s => s.kind === 'custom' ? s.end() : s.kind === 'line' ? s.pts[s.pts.length - 1] : [s.align === 'center' ? s.x + tw(s) / 2 : s.x + tw(s), s.y - s.size * 0.3];
+ const startPt = s => s.kind === 'custom' ? s.start() : s.kind === 'line' ? s.pts[0] : [s.align === 'center' ? s.x - tw(s) / 2 : s.x, s.y - s.size * 0.3];
+ // 笔在屏幕上的位置:在画 → 笔尖;两笔之间 → 从上一笔终点沿弧线滑到下一笔起点;开场 → 从右下入画
+ B.penAt = (ft, cam, tip) => {
+ if (tip) return CAM.toScreen(cam, tip[0], tip[1]);
+ let prev = null, next = null;
+ for (const s of handed()) { if (s.t1 <= ft) prev = s; else if (s.t0 > ft && !next) next = s; }
+ if (prev && next) {
+ const q = MO.sineInOut((ft - prev.t1) / (next.t0 - prev.t1)), a = CAM.toScreen(cam, ...endPt(prev)), b = CAM.toScreen(cam, ...startPt(next));
+ return [lerp(a[0], b[0], q), lerp(a[1], b[1], q) - Math.sin(q * Math.PI) * Math.min(80, 20 + Math.hypot(b[0] - a[0], b[1] - a[1]) * 0.15)];
+ }
+ if (next) { const b = CAM.toScreen(cam, ...startPt(next)), q = MO.cubicOut(clamp(ft / next.t0)); return [lerp(W * 0.62, b[0], q), lerp(H * 0.7, b[1], q)]; }
+ return CAM.toScreen(cam, ...endPt(prev));
+ };
+ // 空档里笔的颜色 = 下一笔的墨色(没有下一笔就用上一笔)
+ B.penColor = ft => { const hs = handed(), nx = hs.find(s => s.t0 > ft), pv = [...hs].reverse().find(s => s.t1 <= ft); return (nx || pv || { col: ink }).col; };
+ return B;
+};
+// 一支马克笔(屏幕空间,笔尖在 (x,y),笔身朝右上)。笔尾帽 = 墨色;有高光和投影,浮在板上。用笔引导视线。
+DG.pen = (c, x, y, col, tilt = 0) => {
+ c.save(); c.translate(x, y); c.rotate(-0.72 + tilt);
+ c.fillStyle = 'rgba(0,0,0,.12)'; c.beginPath(); c.roundRect(30, 14, 250, 34, 16); c.fill();
+ c.fillStyle = col; c.beginPath(); c.moveTo(0, 0); c.lineTo(26, -8); c.lineTo(26, 8); c.closePath(); c.fill();
+ c.fillStyle = '#e8e8e4'; c.beginPath(); c.roundRect(24, -12, 26, 24, 4); c.fill();
+ c.fillStyle = '#26262a'; c.beginPath(); c.roundRect(48, -17, 190, 34, 12); c.fill();
+ c.fillStyle = col; c.beginPath(); c.roundRect(212, -18, 46, 36, 10); c.fill();
+ c.fillStyle = 'rgba(255,255,255,.22)'; c.beginPath(); c.roundRect(60, -12, 140, 7, 4); c.fill();
+ c.restore();
+};
+})();
diff --git a/scripts/engine/lib/fonts.js b/scripts/engine/lib/fonts.js
new file mode 100644
index 0000000..c96e0f2
--- /dev/null
+++ b/scripts/engine/lib/fonts.js
@@ -0,0 +1,56 @@
+// 每个字体文件注册成独立 family(文件名去扩展名),用法:ctx.font = '96px "Cinzel-700"'
+window.FONT_FACES = [
+ {family:'Cinzel-400', url:'lib/fonts/Cinzel-400.woff'},
+ {family:'Cinzel-700', url:'lib/fonts/Cinzel-700.woff'},
+ {family:'CormorantGaramond-500i', url:'lib/fonts/CormorantGaramond-500i.woff'},
+ {family:'CormorantGaramond-500', url:'lib/fonts/CormorantGaramond-500.woff'},
+ {family:'CormorantGaramond-700', url:'lib/fonts/CormorantGaramond-700.woff'},
+ {family:'EBGaramond-400i', url:'lib/fonts/EBGaramond-400i.woff'},
+ {family:'EBGaramond-400', url:'lib/fonts/EBGaramond-400.woff'},
+ {family:'EBGaramond-600', url:'lib/fonts/EBGaramond-600.woff'},
+ {family:'IMFellEnglish-400i', url:'lib/fonts/IMFellEnglish-400i.woff'},
+ {family:'IMFellEnglish-400', url:'lib/fonts/IMFellEnglish-400.woff'},
+ {family:'PlayfairDisplay-400i', url:'lib/fonts/PlayfairDisplay-400i.woff'},
+ {family:'PlayfairDisplay-700i', url:'lib/fonts/PlayfairDisplay-700i.woff'},
+ {family:'PlayfairDisplay-700', url:'lib/fonts/PlayfairDisplay-700.woff'},
+ {family:'PressStart2P-400', url:'lib/fonts/PressStart2P-400.woff'},
+ {family:'Poppins-600', url:'lib/fonts/Poppins-600.woff'},
+ {family:'Poppins-700', url:'lib/fonts/Poppins-700.woff'},
+ {family:'Poppins-800', url:'lib/fonts/Poppins-800.woff'},
+ {family:'JosefinSans-700', url:'lib/fonts/JosefinSans-700.woff'},
+ {family:'Bangers-400', url:'lib/fonts/Bangers-400.woff'},
+ {family:'GochiHand-400', url:'lib/fonts/GochiHand-400.woff'},
+ {family:'Caveat-600', url:'lib/fonts/Caveat-600.woff'},
+ {family:'LilitaOne-400', url:'lib/fonts/LilitaOne-400.woff'},
+ {family:'NotoSerifJP-600', url:'lib/fonts/NotoSerifJP-600.woff'},
+ {family:'Exo2-800i', url:'lib/fonts/Exo2-800i.woff'},
+ {family:'ArchivoBlack-400', url:'lib/fonts/ArchivoBlack-400.woff'},
+ {family:'Kalam-700', url:'lib/fonts/Kalam-700.woff'},
+ {family:'UnifrakturMaguntia-400', url:'lib/fonts/UnifrakturMaguntia-400.woff'},
+ {family:'Marcellus-400', url:'lib/fonts/Marcellus-400.woff'},
+ {family:'Righteous-400', url:'lib/fonts/Righteous-400.woff'},
+ {family:'Anton-400', url:'lib/fonts/Anton-400.woff'},
+ {family:'AlfaSlabOne-400', url:'lib/fonts/AlfaSlabOne-400.woff'},
+ {family:'Rye-400', url:'lib/fonts/Rye-400.woff'},
+ {family:'LibreBaskerville-400', url:'lib/fonts/LibreBaskerville-400.woff'},
+ {family:'LibreBaskerville-700', url:'lib/fonts/LibreBaskerville-700.woff'},
+ // 中文:霞鹜文楷 Medium 子集(OFL 1.1)。GB2312 全部汉字+预置字+skill 里用到的字(font_subset.py --gb2312),生僻字用 scripts/font_subset.py --text 补;NotoSerifJP 是日文子集,简体字不全(「戏」「蓝」都没有)
+ {family:'LXGWWenKai-500', url:'lib/fonts/LXGWWenKai-500.woff'},
+ // ---- YouTube 解说语法(references/09)----
+ // 中文黑体:family 名沿用 PuHui-*(代码里 97 处引用不用改),开源版文件是思源黑体 Noto Sans SC(OFL 1.1)500/700/800/900 四个字重的 GB2312 子集
+ // (scripts/font_subset.py --gb2312,单字重约 1.4MB)。作者原用阿里巴巴普惠体 3.0,其许可不允许转换、拆分后再分发,所以不随仓库附带;
+ // 你自己装了普惠体想换回去:按 font_subset.py 说明生成 PuHui-*.woff,把下面四行的 url 改回去即可。
+ {family:'PuHui-Medium', url:'lib/fonts/NotoSansSC-500.woff'},
+ {family:'PuHui-Bold', url:'lib/fonts/NotoSansSC-700.woff'},
+ {family:'PuHui-Heavy', url:'lib/fonts/NotoSansSC-800.woff'},
+ {family:'PuHui-Black', url:'lib/fonts/NotoSansSC-900.woff'},
+ // 3b1b 公式:CMU(LaTeX Computer Modern)正体/斜体
+ {family:'CMU-rm', url:'lib/fonts/cmunrm.woff'},
+ {family:'CMU-it', url:'lib/fonts/cmunti.woff'},
+ // 发布会 Inter(SF Pro 最接近的开源字)、财经 Roboto Condensed:可变字重,用 '600 220px "Inter"' 选字重
+ {family:'Inter', url:'lib/fonts/Inter-var.woff', desc:{weight:'100 900'}},
+ {family:'RobotoCondensed', url:'lib/fonts/RobotoCondensed-var.woff', desc:{weight:'100 900'}},
+ // 思源黑/宋(可变字重):只含 3b1b/发布会/财经三支示范片用到的字(源文件未随仓库附带,换题目缺字时改用 PuHui-*,或下 Google Fonts 的 NotoSansSC[wght].ttf 重做子集)
+ {family:'NotoSansSC', url:'lib/fonts/NotoSansSC-sub.woff', desc:{weight:'100 900'}},
+ {family:'NotoSerifSC', url:'lib/fonts/NotoSerifSC-sub.woff', desc:{weight:'200 900'}},
+];
diff --git a/scripts/engine/lib/fonts/AlfaSlabOne-400.woff b/scripts/engine/lib/fonts/AlfaSlabOne-400.woff
new file mode 100644
index 0000000..ed5ca89
Binary files /dev/null and b/scripts/engine/lib/fonts/AlfaSlabOne-400.woff differ
diff --git a/scripts/engine/lib/fonts/Anton-400.woff b/scripts/engine/lib/fonts/Anton-400.woff
new file mode 100644
index 0000000..af925c1
Binary files /dev/null and b/scripts/engine/lib/fonts/Anton-400.woff differ
diff --git a/scripts/engine/lib/fonts/ArchivoBlack-400.woff b/scripts/engine/lib/fonts/ArchivoBlack-400.woff
new file mode 100644
index 0000000..5273a9c
Binary files /dev/null and b/scripts/engine/lib/fonts/ArchivoBlack-400.woff differ
diff --git a/scripts/engine/lib/fonts/Bangers-400.woff b/scripts/engine/lib/fonts/Bangers-400.woff
new file mode 100644
index 0000000..46c8884
Binary files /dev/null and b/scripts/engine/lib/fonts/Bangers-400.woff differ
diff --git a/scripts/engine/lib/fonts/Caveat-600.woff b/scripts/engine/lib/fonts/Caveat-600.woff
new file mode 100644
index 0000000..a9fc847
Binary files /dev/null and b/scripts/engine/lib/fonts/Caveat-600.woff differ
diff --git a/scripts/engine/lib/fonts/Cinzel-400.woff b/scripts/engine/lib/fonts/Cinzel-400.woff
new file mode 100644
index 0000000..08649ed
Binary files /dev/null and b/scripts/engine/lib/fonts/Cinzel-400.woff differ
diff --git a/scripts/engine/lib/fonts/Cinzel-700.woff b/scripts/engine/lib/fonts/Cinzel-700.woff
new file mode 100644
index 0000000..28f02c1
Binary files /dev/null and b/scripts/engine/lib/fonts/Cinzel-700.woff differ
diff --git a/scripts/engine/lib/fonts/CormorantGaramond-500.woff b/scripts/engine/lib/fonts/CormorantGaramond-500.woff
new file mode 100644
index 0000000..4dccf36
Binary files /dev/null and b/scripts/engine/lib/fonts/CormorantGaramond-500.woff differ
diff --git a/scripts/engine/lib/fonts/CormorantGaramond-500i.woff b/scripts/engine/lib/fonts/CormorantGaramond-500i.woff
new file mode 100644
index 0000000..3bc493d
Binary files /dev/null and b/scripts/engine/lib/fonts/CormorantGaramond-500i.woff differ
diff --git a/scripts/engine/lib/fonts/CormorantGaramond-700.woff b/scripts/engine/lib/fonts/CormorantGaramond-700.woff
new file mode 100644
index 0000000..f1ddbfb
Binary files /dev/null and b/scripts/engine/lib/fonts/CormorantGaramond-700.woff differ
diff --git a/scripts/engine/lib/fonts/EBGaramond-400.woff b/scripts/engine/lib/fonts/EBGaramond-400.woff
new file mode 100644
index 0000000..7952db1
Binary files /dev/null and b/scripts/engine/lib/fonts/EBGaramond-400.woff differ
diff --git a/scripts/engine/lib/fonts/EBGaramond-400i.woff b/scripts/engine/lib/fonts/EBGaramond-400i.woff
new file mode 100644
index 0000000..f653494
Binary files /dev/null and b/scripts/engine/lib/fonts/EBGaramond-400i.woff differ
diff --git a/scripts/engine/lib/fonts/EBGaramond-600.woff b/scripts/engine/lib/fonts/EBGaramond-600.woff
new file mode 100644
index 0000000..d30aa9d
Binary files /dev/null and b/scripts/engine/lib/fonts/EBGaramond-600.woff differ
diff --git a/scripts/engine/lib/fonts/Exo2-800i.woff b/scripts/engine/lib/fonts/Exo2-800i.woff
new file mode 100644
index 0000000..7437aee
Binary files /dev/null and b/scripts/engine/lib/fonts/Exo2-800i.woff differ
diff --git a/scripts/engine/lib/fonts/GochiHand-400.woff b/scripts/engine/lib/fonts/GochiHand-400.woff
new file mode 100644
index 0000000..b500d9a
Binary files /dev/null and b/scripts/engine/lib/fonts/GochiHand-400.woff differ
diff --git a/scripts/engine/lib/fonts/IMFellEnglish-400.woff b/scripts/engine/lib/fonts/IMFellEnglish-400.woff
new file mode 100644
index 0000000..f9b84ad
Binary files /dev/null and b/scripts/engine/lib/fonts/IMFellEnglish-400.woff differ
diff --git a/scripts/engine/lib/fonts/IMFellEnglish-400i.woff b/scripts/engine/lib/fonts/IMFellEnglish-400i.woff
new file mode 100644
index 0000000..6c1d5e4
Binary files /dev/null and b/scripts/engine/lib/fonts/IMFellEnglish-400i.woff differ
diff --git a/scripts/engine/lib/fonts/Inter-var.woff b/scripts/engine/lib/fonts/Inter-var.woff
new file mode 100644
index 0000000..ace36e8
Binary files /dev/null and b/scripts/engine/lib/fonts/Inter-var.woff differ
diff --git a/scripts/engine/lib/fonts/JosefinSans-700.woff b/scripts/engine/lib/fonts/JosefinSans-700.woff
new file mode 100644
index 0000000..2e2bfbf
Binary files /dev/null and b/scripts/engine/lib/fonts/JosefinSans-700.woff differ
diff --git a/scripts/engine/lib/fonts/Kalam-700.woff b/scripts/engine/lib/fonts/Kalam-700.woff
new file mode 100644
index 0000000..b31a765
Binary files /dev/null and b/scripts/engine/lib/fonts/Kalam-700.woff differ
diff --git a/scripts/engine/lib/fonts/LICENSES.md b/scripts/engine/lib/fonts/LICENSES.md
new file mode 100644
index 0000000..0533dea
--- /dev/null
+++ b/scripts/engine/lib/fonts/LICENSES.md
@@ -0,0 +1,40 @@
+# 字体许可 · Font licenses
+
+本目录的字体都不属于本仓库的 MIT 授权,各自沿用原许可。全部是 SIL Open Font License 1.1(全文见同目录 `OFL.txt`),可以随软件再分发、可商用,但不能单独售卖字体文件。部分文件是按 GB2312 或按用字抽出的子集(`scripts/font_subset.py`),转成了 woff。
+
+The fonts in this directory are NOT covered by the repository's MIT license. Each keeps its own license; all of them are SIL Open Font License 1.1 (full text in `OFL.txt`). Some files are subsets converted to WOFF.
+
+| 文件 | 字体 | 版权 | 来源 |
+|---|---|---|---|
+| `AlfaSlabOne-400.woff` | Alfa Slab One | © 2016 The Alfa Slab One Project Authors,Reserved Font Name "Alfa Slab" | Google Fonts |
+| `Anton-400.woff` | Anton | © 2020 The Anton Project Authors | Google Fonts |
+| `ArchivoBlack-400.woff` | Archivo Black | © 2017 The Archivo Black Project Authors | Google Fonts |
+| `Bangers-400.woff` | Bangers | © 2010 The Bangers Project Authors | Google Fonts |
+| `Caveat-600.woff` | Caveat | © 2014 The Caveat Project Authors | Google Fonts |
+| `Cinzel-400.woff` `Cinzel-700.woff` | Cinzel | © 2020 The Cinzel Project Authors | Google Fonts |
+| `CormorantGaramond-500.woff` `-500i` `-700` | Cormorant Garamond | © 2015 The Cormorant Project Authors | Google Fonts |
+| `EBGaramond-400.woff` `-400i` `-600` | EB Garamond | © 2017 The EB Garamond Project Authors | Google Fonts |
+| `Exo2-800i.woff` | Exo 2 | © 2013 The Exo 2 Project Authors | Google Fonts |
+| `GochiHand-400.woff` | Gochi Hand | © 2011 Huerta Tipográfica,Reserved Font Names "Gochi" and "Gochi Hand" | Google Fonts |
+| `IMFellEnglish-400.woff` `-400i` | IM FELL English | © 2007 Igino Marini,Reserved Font Names "IM FELL English Roman/Italic" | Google Fonts |
+| `Inter-var.woff` | Inter | © 2016 The Inter Project Authors | github.com/rsms/inter |
+| `JosefinSans-700.woff` | Josefin Sans | © 2010 The Josefin Sans Project Authors,Reserved Font Name "Josefin Sans" | Google Fonts |
+| `Kalam-700.woff` | Kalam | © 2014 Indian Type Foundry | Google Fonts |
+| `LibreBaskerville-400.woff` `-700` | Libre Baskerville | © 2012 The Libre Baskerville Project Authors | Google Fonts |
+| `LilitaOne-400.woff` | Lilita One | © 2011 Juan Montoreano,Reserved Font Name "Lilita One" | Google Fonts |
+| `Marcellus-400.woff` | Marcellus | © 2012 Brian J. Bonislawsky (Astigmatic),Reserved Font Name "Marcellus" | Google Fonts |
+| `PlayfairDisplay-400i.woff` `-700` `-700i` | Playfair Display | © 2017 The Playfair Display Project Authors,Reserved Font Name "Playfair Display" | Google Fonts |
+| `Poppins-600.woff` `-700` `-800` | Poppins | © 2020 The Poppins Project Authors | Google Fonts |
+| `PressStart2P-400.woff` | Press Start 2P | © 2012 The Press Start 2P Project Authors,Reserved Font Name "Press Start 2P" | Google Fonts |
+| `Righteous-400.woff` | Righteous | © 2011 Brian J. Bonislawsky (Astigmatic),Reserved Font Name "Righteous" | Google Fonts |
+| `RobotoCondensed-var.woff` | Roboto Condensed | © 2011 The Roboto Project Authors | Google Fonts |
+| `Rye-400.woff` | Rye | © 2010 Sorkin Type Co,Reserved Font Name "Rye" | Google Fonts |
+| `UnifrakturMaguntia-400.woff` | UnifrakturMaguntia | © 2010 j. 'mach' wust,© 2009 Peter Wiegel,Reserved Font Name "UnifrakturMaguntia" | Google Fonts |
+| `cmunrm.woff` `cmunti.woff` | CMU Serif(Computer Modern Unicode) | Andrey V. Panov,部分字形来自 AMS Blue Sky fonts | CTAN cm-unicode |
+| `LXGWWenKai-500.woff` | 霞鹜文楷 LXGW WenKai(子集) | © 2021-2025 LXGW;© 2020 The Klee Project Authors | github.com/lxgw/LxgwWenKai |
+| `NotoSansSC-500/700/800/900.woff` | 思源黑体 Noto Sans SC(按字重实例化后的 GB2312 子集;代码里 family 名叫 `PuHui-*`) | © 2014-2021 Adobe,Reserved Font Name "Source" | Google Fonts |
+| `NotoSansSC-sub.woff` | 思源黑体 Noto Sans SC(按用字子集) | © 2014-2021 Adobe,Reserved Font Name "Source" | Google Fonts |
+| `NotoSerifSC-sub.woff` | 思源宋体 Noto Serif SC(按用字子集) | © 2017-2024 Adobe | Google Fonts |
+| `NotoSerifJP-600.woff` | Noto Serif JP | © 2017-2024 Adobe | Google Fonts |
+
+带 Reserved Font Name 的字体,改动过的版本不能沿用保留名。本目录里带保留名的这几款(拉丁字体)内部字体名都是原名(按 Google Fonts 发行的 woff 使用);如果你要对它们抽子集或改字形,请同时改掉 family 名。
diff --git a/scripts/engine/lib/fonts/LXGWWenKai-500.woff b/scripts/engine/lib/fonts/LXGWWenKai-500.woff
new file mode 100644
index 0000000..4f02c88
Binary files /dev/null and b/scripts/engine/lib/fonts/LXGWWenKai-500.woff differ
diff --git a/scripts/engine/lib/fonts/LibreBaskerville-400.woff b/scripts/engine/lib/fonts/LibreBaskerville-400.woff
new file mode 100644
index 0000000..70100bd
Binary files /dev/null and b/scripts/engine/lib/fonts/LibreBaskerville-400.woff differ
diff --git a/scripts/engine/lib/fonts/LibreBaskerville-700.woff b/scripts/engine/lib/fonts/LibreBaskerville-700.woff
new file mode 100644
index 0000000..1ede9e6
Binary files /dev/null and b/scripts/engine/lib/fonts/LibreBaskerville-700.woff differ
diff --git a/scripts/engine/lib/fonts/LilitaOne-400.woff b/scripts/engine/lib/fonts/LilitaOne-400.woff
new file mode 100644
index 0000000..73646ca
Binary files /dev/null and b/scripts/engine/lib/fonts/LilitaOne-400.woff differ
diff --git a/scripts/engine/lib/fonts/Marcellus-400.woff b/scripts/engine/lib/fonts/Marcellus-400.woff
new file mode 100644
index 0000000..8d59398
Binary files /dev/null and b/scripts/engine/lib/fonts/Marcellus-400.woff differ
diff --git a/scripts/engine/lib/fonts/NotoSansSC-500.woff b/scripts/engine/lib/fonts/NotoSansSC-500.woff
new file mode 100644
index 0000000..4c7cade
Binary files /dev/null and b/scripts/engine/lib/fonts/NotoSansSC-500.woff differ
diff --git a/scripts/engine/lib/fonts/NotoSansSC-700.woff b/scripts/engine/lib/fonts/NotoSansSC-700.woff
new file mode 100644
index 0000000..4e5c215
Binary files /dev/null and b/scripts/engine/lib/fonts/NotoSansSC-700.woff differ
diff --git a/scripts/engine/lib/fonts/NotoSansSC-800.woff b/scripts/engine/lib/fonts/NotoSansSC-800.woff
new file mode 100644
index 0000000..056fba6
Binary files /dev/null and b/scripts/engine/lib/fonts/NotoSansSC-800.woff differ
diff --git a/scripts/engine/lib/fonts/NotoSansSC-900.woff b/scripts/engine/lib/fonts/NotoSansSC-900.woff
new file mode 100644
index 0000000..664a8d5
Binary files /dev/null and b/scripts/engine/lib/fonts/NotoSansSC-900.woff differ
diff --git a/scripts/engine/lib/fonts/NotoSansSC-sub.woff b/scripts/engine/lib/fonts/NotoSansSC-sub.woff
new file mode 100644
index 0000000..972a3b1
Binary files /dev/null and b/scripts/engine/lib/fonts/NotoSansSC-sub.woff differ
diff --git a/scripts/engine/lib/fonts/NotoSerifJP-600.woff b/scripts/engine/lib/fonts/NotoSerifJP-600.woff
new file mode 100644
index 0000000..1416351
Binary files /dev/null and b/scripts/engine/lib/fonts/NotoSerifJP-600.woff differ
diff --git a/scripts/engine/lib/fonts/NotoSerifSC-sub.woff b/scripts/engine/lib/fonts/NotoSerifSC-sub.woff
new file mode 100644
index 0000000..62d4bee
Binary files /dev/null and b/scripts/engine/lib/fonts/NotoSerifSC-sub.woff differ
diff --git a/scripts/engine/lib/fonts/OFL.txt b/scripts/engine/lib/fonts/OFL.txt
new file mode 100644
index 0000000..a4670b0
--- /dev/null
+++ b/scripts/engine/lib/fonts/OFL.txt
@@ -0,0 +1,94 @@
+Copyright notices for each font file in this directory are listed in LICENSES.md
+(and are embedded in each font's name table).
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/scripts/engine/lib/fonts/PlayfairDisplay-400i.woff b/scripts/engine/lib/fonts/PlayfairDisplay-400i.woff
new file mode 100644
index 0000000..b1f80d0
Binary files /dev/null and b/scripts/engine/lib/fonts/PlayfairDisplay-400i.woff differ
diff --git a/scripts/engine/lib/fonts/PlayfairDisplay-700.woff b/scripts/engine/lib/fonts/PlayfairDisplay-700.woff
new file mode 100644
index 0000000..5070120
Binary files /dev/null and b/scripts/engine/lib/fonts/PlayfairDisplay-700.woff differ
diff --git a/scripts/engine/lib/fonts/PlayfairDisplay-700i.woff b/scripts/engine/lib/fonts/PlayfairDisplay-700i.woff
new file mode 100644
index 0000000..95def38
Binary files /dev/null and b/scripts/engine/lib/fonts/PlayfairDisplay-700i.woff differ
diff --git a/scripts/engine/lib/fonts/Poppins-600.woff b/scripts/engine/lib/fonts/Poppins-600.woff
new file mode 100644
index 0000000..5035ee7
Binary files /dev/null and b/scripts/engine/lib/fonts/Poppins-600.woff differ
diff --git a/scripts/engine/lib/fonts/Poppins-700.woff b/scripts/engine/lib/fonts/Poppins-700.woff
new file mode 100644
index 0000000..64fbbd9
Binary files /dev/null and b/scripts/engine/lib/fonts/Poppins-700.woff differ
diff --git a/scripts/engine/lib/fonts/Poppins-800.woff b/scripts/engine/lib/fonts/Poppins-800.woff
new file mode 100644
index 0000000..fe74641
Binary files /dev/null and b/scripts/engine/lib/fonts/Poppins-800.woff differ
diff --git a/scripts/engine/lib/fonts/PressStart2P-400.woff b/scripts/engine/lib/fonts/PressStart2P-400.woff
new file mode 100644
index 0000000..302418f
Binary files /dev/null and b/scripts/engine/lib/fonts/PressStart2P-400.woff differ
diff --git a/scripts/engine/lib/fonts/Righteous-400.woff b/scripts/engine/lib/fonts/Righteous-400.woff
new file mode 100644
index 0000000..59c797f
Binary files /dev/null and b/scripts/engine/lib/fonts/Righteous-400.woff differ
diff --git a/scripts/engine/lib/fonts/RobotoCondensed-var.woff b/scripts/engine/lib/fonts/RobotoCondensed-var.woff
new file mode 100644
index 0000000..1196643
Binary files /dev/null and b/scripts/engine/lib/fonts/RobotoCondensed-var.woff differ
diff --git a/scripts/engine/lib/fonts/Rye-400.woff b/scripts/engine/lib/fonts/Rye-400.woff
new file mode 100644
index 0000000..66c64f2
Binary files /dev/null and b/scripts/engine/lib/fonts/Rye-400.woff differ
diff --git a/scripts/engine/lib/fonts/UnifrakturMaguntia-400.woff b/scripts/engine/lib/fonts/UnifrakturMaguntia-400.woff
new file mode 100644
index 0000000..580bb9b
Binary files /dev/null and b/scripts/engine/lib/fonts/UnifrakturMaguntia-400.woff differ
diff --git a/scripts/engine/lib/fonts/cmunrm.woff b/scripts/engine/lib/fonts/cmunrm.woff
new file mode 100644
index 0000000..9efca12
Binary files /dev/null and b/scripts/engine/lib/fonts/cmunrm.woff differ
diff --git a/scripts/engine/lib/fonts/cmunti.woff b/scripts/engine/lib/fonts/cmunti.woff
new file mode 100644
index 0000000..122340a
Binary files /dev/null and b/scripts/engine/lib/fonts/cmunti.woff differ
diff --git a/scripts/engine/lib/fonts/index.json b/scripts/engine/lib/fonts/index.json
new file mode 100644
index 0000000..442742f
--- /dev/null
+++ b/scripts/engine/lib/fonts/index.json
@@ -0,0 +1 @@
+[["Cinzel-400.woff", "Cinzel", "normal", "400"], ["Cinzel-700.woff", "Cinzel", "normal", "700"], ["CormorantGaramond-500i.woff", "Cormorant Garamond", "italic", "500"], ["CormorantGaramond-500.woff", "Cormorant Garamond", "normal", "500"], ["CormorantGaramond-700.woff", "Cormorant Garamond", "normal", "700"], ["EBGaramond-400i.woff", "EB Garamond", "italic", "400"], ["EBGaramond-400.woff", "EB Garamond", "normal", "400"], ["EBGaramond-600.woff", "EB Garamond", "normal", "600"], ["IMFellEnglish-400i.woff", "IM Fell English", "italic", "400"], ["IMFellEnglish-400.woff", "IM Fell English", "normal", "400"], ["PlayfairDisplay-400i.woff", "Playfair Display", "italic", "400"], ["PlayfairDisplay-700i.woff", "Playfair Display", "italic", "700"], ["PlayfairDisplay-700.woff", "Playfair Display", "normal", "700"], ["PressStart2P-400.woff", "Press Start 2P", "normal", "400"], ["Poppins-600.woff", "Poppins", "normal", "600"], ["Poppins-700.woff", "Poppins", "normal", "700"], ["Poppins-800.woff", "Poppins", "normal", "800"], ["JosefinSans-700.woff", "Josefin Sans", "normal", "700"], ["Bangers-400.woff", "Bangers", "normal", "400"], ["GochiHand-400.woff", "Gochi Hand", "normal", "400"], ["Caveat-600.woff", "Caveat", "normal", "600"], ["LilitaOne-400.woff", "Lilita One", "normal", "400"], ["NotoSerifJP-600.woff", "Noto Serif JP", "normal", "600"], ["Exo2-800i.woff", "Exo 2", "italic", "800"], ["ArchivoBlack-400.woff", "Archivo Black", "normal", "400"], ["Kalam-700.woff", "Kalam", "normal", "700"], ["UnifrakturMaguntia-400.woff", "UnifrakturMaguntia", "normal", "400"], ["Marcellus-400.woff", "Marcellus", "normal", "400"], ["Righteous-400.woff", "Righteous", "normal", "400"], ["Anton-400.woff", "Anton", "normal", "400"], ["AlfaSlabOne-400.woff", "Alfa Slab One", "normal", "400"], ["Rye-400.woff", "Rye", "normal", "400"], ["LibreBaskerville-400.woff", "Libre Baskerville", "normal", "400"], ["LibreBaskerville-700.woff", "Libre Baskerville", "normal", "700"]]
\ No newline at end of file
diff --git a/scripts/engine/lib/kit.js b/scripts/engine/lib/kit.js
new file mode 100644
index 0000000..c4de23b
--- /dev/null
+++ b/scripts/engine/lib/kit.js
@@ -0,0 +1,91 @@
+// 跨场景共用的小工具:点列加密/等弧长重采样、可变线宽路径 ribbon、整幅行/列扭曲、手绘不规则圆、全片连续编舞、近侧手臂补盖、角标。
+// 渲染器在 lib/brush.js(笔与水)、lib/render.js(网点/点彩/赛璐珞/光影/皮影)、lib/post.js(VHS/胶片/泛光/纹理叠角色)。
+(() => {
+const W = 1920, H = 1080;
+const { clamp, lerp, rng } = U;
+const K = window.KIT = {};
+
+// Catmull-Rom 加密点列(开放)
+K.densify = (pts, per = 6) => {
+ const out = [], n = pts.length, P_ = i => pts[Math.max(0, Math.min(n - 1, i))];
+ for (let i = 0; i < n - 1; i++) {
+ const p0 = P_(i - 1), p1 = P_(i), p2 = P_(i + 1), p3 = P_(i + 2);
+ for (let k = 0; k < per; k++) {
+ const t = k / per, t2 = t * t, t3 = t2 * t;
+ out.push([0.5 * (2 * p1[0] + (-p0[0] + p2[0]) * t + (2 * p0[0] - 5 * p1[0] + 4 * p2[0] - p3[0]) * t2 + (-p0[0] + 3 * p1[0] - 3 * p2[0] + p3[0]) * t3),
+ 0.5 * (2 * p1[1] + (-p0[1] + p2[1]) * t + (2 * p0[1] - 5 * p1[1] + 4 * p2[1] - p3[1]) * t2 + (-p0[1] + 3 * p1[1] - 3 * p2[1] + p3[1]) * t3)]);
+ }
+ }
+ out.push(pts[n - 1]); return out;
+};
+// 按弧长等距重采样(让噪声、飞白、行波的频率与笔画长短无关)
+K.resample = (pts, step = 4) => {
+ const out = [pts[0]]; let acc = 0;
+ for (let i = 1; i < pts.length; i++) { const a = pts[i - 1], b = pts[i], L = Math.hypot(b[0] - a[0], b[1] - a[1]); let d = step - acc;
+ while (d <= L) { const q = d / L; out.push([a[0] + (b[0] - a[0]) * q, a[1] + (b[1] - a[1]) * q]); d += step; } acc = L - (d - step); }
+ out.push(pts[pts.length - 1]); return out;
+};
+// 可变线宽路径:点列两侧按 w(q) 偏移成闭合多边形(书法线、飘带、表现主义长笔)
+K.ribbon = (pts, w) => {
+ const n = pts.length, L = [], R = [];
+ for (let i = 0; i < n; i++) {
+ const a = pts[Math.max(0, i - 1)], b = pts[Math.min(n - 1, i + 1)];
+ let dx = b[0] - a[0], dy = b[1] - a[1]; const d = Math.hypot(dx, dy) || 1; dx /= d; dy /= d;
+ const hw = (typeof w === 'function' ? w(i / (n - 1), i) : w) / 2;
+ L.push([pts[i][0] - dy * hw, pts[i][1] + dx * hw]); R.push([pts[i][0] + dy * hw, pts[i][1] - dx * hw]);
+ }
+ const p = new Path2D(); L.forEach((q, i) => i ? p.lineTo(q[0], q[1]) : p.moveTo(q[0], q[1]));
+ for (let i = n - 1; i >= 0; i--) p.lineTo(R[i][0], R[i][1]); p.closePath(); return p;
+};
+// 少女部件按画序列出(远→近),给「不调 drawGirl、自己逐部件上色」的风格用
+K.girlOrder = ['farSleeve', 'farHand', 'farCuff', 'hairDown', 'skirt', 'shoe', 'torso', 'neck', 'hairBack', 'bun', 'face', 'bangs', 'upperArm', 'foreArm', 'cuff', 'hand']; // 完整画序(含五官、杯、钩子插槽名)见 RIG.GIRL_ORDER
+
+// 把 src 按「水平条带位移」画到 dst:fx(y) 返回该行的 x 位移(蒙克式整个世界在流动)
+// margin:每行横向多拉伸 2·margin 像素,位移后左右不露缝(margin ≥ 最大位移)
+K.warpRows = (dst, src, fx, band = 6, margin = 0) => {
+ for (let y = 0; y < H; y += band) { const dx = fx(y + band / 2); dst.drawImage(src, 0, y, W, band, dx - margin, y, W + 2 * margin, band); }
+};
+K.warpCols = (dst, src, fy, band = 6, margin = 0) => {
+ for (let x = 0; x < W; x += band) { const dy = fy(x + band / 2); dst.drawImage(src, x, 0, band, H, x, dy - margin, band, H + 2 * margin); }
+};
+
+// n 角星(剪纸星、爆炸框、闪光):外半径 r0、内半径 r1
+K.star = (cx, cy, r0, r1, n, rot = 0) => { const pts = []; for (let i = 0; i < n * 2; i++) { const a = rot + i / (n * 2) * Math.PI * 2 - Math.PI / 2, r = i % 2 ? r1 : r0; pts.push([cx + Math.cos(a) * r, cy + Math.sin(a) * r]); } return U.poly(pts); };
+// 手绘不规则圆(草间的点不是完美圆):n 个顶点、半径按种子起伏
+K.blob = (c, x, y, r, seed, wob = 0.08, n = 14) => {
+ const rr = rng(seed); const off = []; for (let i = 0; i < n; i++) off.push(1 + (rr() - .5) * 2 * wob);
+ const pts = []; for (let i = 0; i < n; i++) { const a = i / n * Math.PI * 2; pts.push([x + Math.cos(a) * r * off[i], y + Math.sin(a) * r * off[i]]); }
+ c.moveTo((pts[0][0] + pts[n - 1][0]) / 2, (pts[0][1] + pts[n - 1][1]) / 2);
+ for (let i = 0; i < n; i++) { const p = pts[i], q = pts[(i + 1) % n]; c.quadraticCurveTo(p[0], p[1], (p[0] + q[0]) / 2, (p[1] + q[1]) / 2); }
+ c.closePath();
+};
+
+// 全片连续的编舞:端杯按全局时间走(周期 = 两段 = 2.34s,在嘴边和桌上各停一会儿),
+// 换风格时姿势不重置——速通看的是「同一瞬间换了画风」,而不是每段重喝一次。转场正好落在杯子停住的时刻。
+K.choreo = (lt, t) => {
+ const ch = PAINT.choreo(lt, t), k = 0.5 - 0.5 * Math.cos(2 * Math.PI * t / 2.34375);
+ let q = clamp((k - 0.15) / 0.7); q = q * q * (3 - 2 * q);
+ ch.cup = q; ch.sip = Math.max(0, Math.sin(t * 6)) * 0.15 * q; return ch;
+};
+// drawGirl(mode:'line') 会把被近侧手臂挡住的躯干线画穿:线稿画完后,把近侧手臂、袖口、手、杯重新盖一遍
+K.nearArm = (c, G, { fill, line = '#111', lw = 3, skin, cuff, cupBody, cupRim, pattern } = {}) => {
+ const arm = new Path2D(); arm.addPath(G.upperArm); arm.addPath(G.foreArm);
+ c.save(); c.lineJoin = 'round'; c.fillStyle = fill; c.fill(arm); if (pattern) { c.save(); c.clip(arm); pattern(c); c.restore(); }
+ c.strokeStyle = line; c.lineWidth = lw; c.stroke(G.upperArm); c.stroke(G.foreArm);
+ if (cuff) { c.fillStyle = cuff; c.fill(G.cuff); c.stroke(G.cuff); }
+ c.fillStyle = skin; c.fill(G.hand); c.lineWidth = lw * 0.8; c.stroke(G.hand);
+ RIG.drawCup(c, G.cup, { body: cupBody, rim: cupRim, line, lw: lw * 0.8, hw: 7 });
+ c.fillStyle = skin; c.beginPath(); c.arc(G.thumb[0], G.thumb[1], 7, 0, Math.PI * 2); c.fill(); c.lineWidth = lw * 0.7; c.stroke();
+ c.restore();
+};
+// 右上角角标:标题(中文)+副标题;入场 0.18s 由各风格的 reveal(c,p) 决定怎么出现
+K.label = (c, { title, sub, tFont, sFont, tCol, sCol, x = 1866, y = 128, sy = 182, shadow, before, after, spacing = 0 }) => {
+ c.save(); c.textAlign = 'right'; c.textBaseline = 'alphabetic';
+ if (before) before(c);
+ if (shadow) { c.shadowColor = shadow.color; c.shadowOffsetX = shadow.x || 0; c.shadowOffsetY = shadow.y || 0; c.shadowBlur = shadow.blur || 0; }
+ c.font = tFont; c.fillStyle = tCol; if (spacing) c.letterSpacing = spacing + 'px'; c.fillText(title, x, y); c.letterSpacing = '0px';
+ if (sub) { c.font = sFont; c.fillStyle = sCol || tCol; c.fillText(sub, x, sy); }
+ if (after) after(c);
+ c.restore();
+};
+})();
diff --git a/scripts/engine/lib/motion.js b/scripts/engine/lib/motion.js
new file mode 100644
index 0000000..55e4005
--- /dev/null
+++ b/scripts/engine/lib/motion.js
@@ -0,0 +1,103 @@
+// 动效时间库 MO:缓动、弹簧、步进、错开、拍号。全部是「时间 → 数值」的纯函数,不读时钟,确定性。
+// 来源:YouTube 解说动画语法 8 支示范片(references/09-视频动画语法.md)。约定:p 是 0..1 的进度,t/lt 是秒。
+// 选缓动的一句话:讲解(3b1b/白板)用 smooth/sineInOut 两端都停稳;发布会用 appleOut/弹簧;动态文字用 expoOut+弹簧;
+// 拼贴(Vox)相机用 sineInOut 或长尾 longTail,纸片按 12fps 步进;Kurzgesagt 动作用 k75,循环用 easyEase。
+(() => {
+const { clamp, lerp } = U;
+const MO = window.MO = {};
+
+// ---------- 画布尺寸(片段渲染用) ----------
+// 引擎和全部示范片是 1920×1080。clip.html(口播管线的参数化片段)可能是竖屏 1080×1920:
+// 用到屏幕尺寸的库(CAM / UI / CH / DG / CL)用 U.onStage 登记,clip.js 启动时 U.setStage(w, h) 一次性改掉。
+const stageHooks = [];
+window.STAGE = { W: 1920, H: 1080 };
+U.onStage = f => { stageHooks.push(f); };
+U.setStage = (w, h) => { window.STAGE = { W: w, H: h }; stageHooks.forEach(f => f(w, h)); };
+
+// ---------- 时间片 ----------
+MO.seg = (t, a, b) => clamp((t - a) / (b - a)); // [a,b] → 0..1
+MO.at = (t, t0, dur) => clamp((t - t0) / dur); // [t0, t0+dur] → 0..1
+MO.anim = (lt, start, dur, ease = MO.smooth) => ease(clamp((lt - start) / dur));
+// 步进时间:把连续时间量化成 fps 步。拼贴纸片/打字/荧光笔「一拍二」= 12fps;故事型角色 24fps;相机仍按 60fps 平滑。
+MO.step = (t, fps = 12) => Math.floor(t * fps + 1e-6) / fps;
+
+// ---------- manim 缓动(3b1b/manim rate_functions.py) ----------
+// smooth = 6t⁵−15t⁴+10t³:两端速度、加速度都为 0。讲解类片子的默认缓动。
+MO.smooth = t => { t = clamp(t); return t * t * t * (10 - 15 * t + 6 * t * t); };
+const sig = x => 1 / (1 + Math.exp(-x));
+MO.smoothCE = (t, inflection = 10) => { const e = sig(-inflection / 2); return clamp((sig(inflection * (t - 0.5)) - e) / (1 - 2 * e)); }; // ManimCE 版
+MO.thereAndBack = t => MO.smooth(t < 0.5 ? 2 * t : 2 * (1 - t)); // Indicate 用:去了又回
+MO.rushInto = t => 2 * MO.smooth(t / 2); // 慢起、冲进终点
+MO.rushFrom = t => 2 * MO.smooth(t / 2 + 0.5) - 1; // 冲出、慢收
+MO.doubleSmooth = t => t < 0.5 ? 0.5 * MO.smooth(2 * t) : 0.5 * (1 + MO.smooth(2 * t - 1));
+MO.wiggle = (t, wiggles = 2) => MO.thereAndBack(t) * Math.sin(wiggles * Math.PI * t);
+// manim LaggedStart(lag_ratio=r):n 个子动画里第 i 个在总进度 p 下的局部进度。总长 = 1+(n-1)·r 个单位,第 i 个占 [i·r, i·r+1]。
+MO.lagged = (i, n, p, r = 0.05) => clamp(p * (1 + (n - 1) * r) - i * r);
+
+// ---------- 常用解析缓动(AE / CSS 名字) ----------
+MO.linear = p => p;
+MO.sineInOut = p => -(Math.cos(Math.PI * p) - 1) / 2;
+MO.cubicIn = p => p * p * p;
+MO.cubicOut = p => 1 - Math.pow(1 - p, 3);
+MO.cubicInOut = p => p < .5 ? 4 * p * p * p : 1 - Math.pow(-2 * p + 2, 3) / 2;
+MO.quartOut = p => 1 - Math.pow(1 - p, 4);
+MO.quintOut = p => 1 - Math.pow(1 - p, 5);
+MO.quintInOut = p => p < .5 ? 16 * p ** 5 : 1 - Math.pow(-2 * p + 2, 5) / 2;
+MO.expoIn = p => p <= 0 ? 0 : Math.pow(2, 10 * p - 10);
+MO.expoOut = p => p >= 1 ? 1 : 1 - Math.pow(2, -10 * p); // 动效设计最常用的「快出慢停」
+MO.expoInOut = p => p <= 0 ? 0 : p >= 1 ? 1 : p < .5 ? Math.pow(2, 20 * p - 10) / 2 : (2 - Math.pow(2, -20 * p + 10)) / 2;
+// backOut 过冲:s=1.70158 约 10%;2.2 约 13%;2.6 约 17%;3.5 约 23%
+MO.backOut = (p, s = 1.70158) => { const q = p - 1; return 1 + (s + 1) * q * q * q + s * q * q; };
+// 弹性落定:overshoot 一次再回(贴纸「啪」地落下)
+MO.elasticOut = p => p <= 0 ? 0 : p >= 1 ? 1 : Math.pow(2, -10 * p) * Math.sin((p * 10 - 0.75) * (2 * Math.PI / 3)) + 1;
+
+// ---------- CSS cubic-bezier(x1,y1,x2,y2):牛顿法由 x 求参数,再取 y ----------
+MO.bezier = (x1, y1, x2, y2) => {
+ const cx = 3 * x1, bx = 3 * (x2 - x1) - cx, ax = 1 - cx - bx;
+ const cy = 3 * y1, by = 3 * (y2 - y1) - cy, ay = 1 - cy - by;
+ const X = s => ((ax * s + bx) * s + cx) * s, Y = s => ((ay * s + by) * s + cy) * s, dX = s => (3 * ax * s + 2 * bx) * s + cx;
+ return p => {
+ if (p <= 0) return 0; if (p >= 1) return 1;
+ let s = p; for (let k = 0; k < 8; k++) { const e = X(s) - p, d = dX(s); if (Math.abs(e) < 1e-6 || Math.abs(d) < 1e-6) break; s -= e / d; }
+ s = clamp(s); return Y(s);
+ };
+};
+MO.appleOut = MO.bezier(0.25, 0.1, 0.25, 1); // CSS `ease`:苹果官网/发布会过渡
+MO.emphasized = MO.bezier(0.2, 0, 0, 1); // Material 3 emphasized:长尾减速
+MO.k75 = MO.bezier(0.75, 0, 0.25, 1); // Kurzgesagt「其他动作用 75% influence」(y1 调研 §6.2)
+MO.easyEase = MO.bezier(0.333, 0, 0.667, 1); // AE Easy Ease:循环动作
+MO.longTail = MO.bezier(0.33, 0, 0.2, 1); // Vox「沿线追过去」「拉出揭示」:起步快、长尾落定(y2 调研)
+
+// ---------- 弹簧 ----------
+// SwiftUI 参数化(WWDC23 Animate with springs):stiffness=(2π/duration)²,damping=4π(1-bounce)/duration → ζ=1-bounce,ω=2π/duration。
+// 返回 0→1 的位移(可 >1 = 过冲)。t 单位秒。发布会 UI 用它:.smooth(bounce 0) / .snappy(0.15) / .bouncy(0.3)。
+MO.spring = (t, { duration = 0.5, bounce = 0, v0 = 0 } = {}) => {
+ if (t <= 0) return 0;
+ const w = 2 * Math.PI / duration, z = 1 - bounce;
+ let x; // x = 剩余位移(1→0)
+ if (Math.abs(z - 1) < 1e-4) x = Math.exp(-w * t) * (1 + (w - v0) * t);
+ else if (z < 1) { const wd = w * Math.sqrt(1 - z * z); x = Math.exp(-z * w * t) * (Math.cos(wd * t) + ((z * w - v0) / wd) * Math.sin(wd * t)); }
+ else { const r = Math.sqrt(z * z - 1), a = -w * (z - r), b = -w * (z + r); const A = (-v0 - b) / (a - b); x = A * Math.exp(a * t) + (1 - A) * Math.exp(b * t); }
+ return 1 - x;
+};
+MO.smoothSpring = t => MO.spring(t, { duration: 0.5, bounce: 0 });
+MO.snappy = t => MO.spring(t, { duration: 0.5, bounce: 0.15 });
+MO.bouncy = t => MO.spring(t, { duration: 0.5, bounce: 0.3 });
+// 频率/衰减参数化的欠阻尼弹簧阶跃响应(动态文字用):freq Hz、decay 1/s。
+// freq 3 / decay 6 第一次过冲 ≈37%(砸进来的大字);2.5 / 9 ≈16%(常规弹入);2.2 / 10 ≈8%(主词落定)
+MO.springHz = (t, freq = 2.5, decay = 9) => t <= 0 ? 0 : 1 - Math.exp(-decay * t) * Math.cos(2 * Math.PI * freq * t);
+// 到位后的余振(Dan Ebberts 惯性回弹):amp·sin(2πft)/e^(decay·t)。换姿势的身体挤压、屏幕震动都用它。
+MO.settle = (t, amp, freq = 3, decay = 5) => t <= 0 ? 0 : amp * Math.sin(2 * Math.PI * freq * t) / Math.exp(decay * t);
+
+// ---------- 持续微动 ----------
+// 漂浮:两频正弦叠加。周期避开 5s 左右(HIG:~0.2Hz 的持续摆动让人不适)
+MO.float = (t, amp = 6, period = 4, ph = 0) => amp * (0.75 * Math.sin(2 * Math.PI * t / period + ph) + 0.25 * Math.sin(2 * Math.PI * t / (period * 0.53) + ph * 1.7));
+
+// ---------- 反查与拍号 ----------
+// 缓动的反函数(二分):「线头/计数在什么时刻到达 y」。例:折线按 smooth 画,求画到某个 x 的时刻(t3 镜 2 的事件标注)。
+MO.invert = (ease, y, iters = 30) => { let a = 0, b = 1; for (let i = 0; i < iters; i++) { const m = (a + b) / 2; if (ease(m) < y) a = m; else b = m; } return (a + b) / 2; };
+// 拍 → 秒
+MO.beat = (n, bpm = 120) => n * 60 / bpm;
+// 揭开那一帧落在拍上:段起点 = 小节线 − 揭开点 × 转场时长(y5:zoom 揭开点 .55、色带 .6、push 到 90% 位移在 .58)
+MO.onBeat = (barTime, revealP, trDur) => barTime - revealP * trDur;
+})();
diff --git a/scripts/engine/lib/paint.js b/scripts/engine/lib/paint.js
new file mode 100644
index 0000000..897661b
--- /dev/null
+++ b/scripts/engine/lib/paint.js
@@ -0,0 +1,200 @@
+// 纯代码绘画工具库:噪声、纹理、手绘线、风格渲染器(笔触/色点/马赛克/网点/像素/切面)、共享编舞。
+// 约定:所有随机都用种子;「抖动线条」按 boilFps 换种子(手绘动画的 boiling line),其余保持帧间稳定。
+(() => {
+const W = 1920, H = 1080;
+const P = window.PAINT = {};
+const { clamp, lerp, ease, rng } = U;
+
+// ---------- 画布 ----------
+P.canvas = (w = W, h = H) => { const c = document.createElement('canvas'); c.width = w; c.height = h; return c; };
+const CACHE = {};
+P.cached = (key, w, h, fn) => { if (!CACHE[key]) { const c = P.canvas(w, h); fn(c.getContext('2d'), c); CACHE[key] = c; } return CACHE[key]; };
+P.scratch = (key) => { if (!CACHE['s_' + key]) CACHE['s_' + key] = P.canvas(); return CACHE['s_' + key]; };
+
+// ---------- 噪声 ----------
+const perm = new Uint8Array(512); { const r = rng(1337); const p = [...Array(256).keys()]; for (let i = 255; i > 0; i--) { const j = (r() * (i + 1)) | 0; [p[i], p[j]] = [p[j], p[i]]; } for (let i = 0; i < 512; i++) perm[i] = p[i & 255]; }
+const fade = t => t * t * t * (t * (t * 6 - 15) + 10);
+const grad = (h, x, y) => { const u = (h & 1) ? x : -x, v = (h & 2) ? y : -y; return (h & 4) ? u + v * 0.5 : u * 0.5 + v; };
+P.noise = (x, y) => { // Perlin 2D,约 [-1,1]
+ const X = Math.floor(x) & 255, Y = Math.floor(y) & 255; x -= Math.floor(x); y -= Math.floor(y);
+ const u = fade(x), v = fade(y), a = perm[X] + Y, b = perm[X + 1] + Y;
+ return lerp(lerp(grad(perm[a], x, y), grad(perm[b], x - 1, y), u), lerp(grad(perm[a + 1], x, y - 1), grad(perm[b + 1], x - 1, y - 1), u), v);
+};
+P.fbm = (x, y, o = 4) => { let s = 0, a = 0.5, f = 1; for (let i = 0; i < o; i++) { s += a * P.noise(x * f, y * f); a *= 0.5; f *= 2; } return s; };
+
+// ---------- 颜色 ----------
+P.hex = h => { h = h.replace('#', ''); if (h.length === 3) h = h.split('').map(x => x + x).join(''); const n = parseInt(h, 16); return [n >> 16 & 255, n >> 8 & 255, n & 255]; };
+P.rgb = (c, a = 1) => `rgba(${c[0] | 0},${c[1] | 0},${c[2] | 0},${a})`;
+P.mix = (a, b, t) => [lerp(a[0], b[0], t), lerp(a[1], b[1], t), lerp(a[2], b[2], t)];
+P.jitter = (c, r, amt) => [c[0] + (r() - .5) * amt, c[1] + (r() - .5) * amt, c[2] + (r() - .5) * amt];
+
+// ---------- 纹理(缓存) ----------
+// 纸/墙/岩石:底色 + 多层噪声斑驳 + 细颗粒
+P.texture = (key, base, opt = {}) => P.cached('tex_' + key, W, H, (g) => {
+ const { scale = 0.004, amt = 26, grain = 14, dark = null, seed = 1 } = opt;
+ const img = g.createImageData(W, H), d = img.data, b = P.hex(base), r = rng(seed);
+ const dk = dark ? P.hex(dark) : null;
+ for (let y = 0; y < H; y++) for (let x = 0; x < W; x++) {
+ const n = P.fbm(x * scale + seed, y * scale, 5), gr = (r() - .5) * grain;
+ const i = (y * W + x) * 4;
+ let c = b;
+ if (dk) c = P.mix(b, dk, clamp(n * 1.2 + 0.25));
+ d[i] = c[0] + n * amt + gr; d[i + 1] = c[1] + n * amt + gr; d[i + 2] = c[2] + n * amt * 0.8 + gr; d[i + 3] = 255;
+ }
+ g.putImageData(img, 0, 0);
+});
+// 颗粒噪点叠层(扁平插画的 grain、旧印刷):透明底上的随机点
+P.grain = (key, density = 0.08, col = [0, 0, 0], alpha = 0.18) => P.cached('grain_' + key, W, H, (g) => {
+ const img = g.createImageData(W, H), d = img.data, r = rng(key.length * 97 + 3);
+ for (let i = 0; i < W * H; i++) if (r() < density) { d[i * 4] = col[0]; d[i * 4 + 1] = col[1]; d[i * 4 + 2] = col[2]; d[i * 4 + 3] = 255 * alpha * (0.4 + r() * 0.6); }
+ g.putImageData(img, 0, 0);
+});
+// 龟裂纹(古典油画):随机游走的细裂线网
+P.craquelure = (key, alpha = 0.35) => P.cached('crack_' + key, W, H, (g) => {
+ const r = rng(77); g.strokeStyle = `rgba(40,25,10,${alpha})`; g.lineWidth = 0.8;
+ for (let k = 0; k < 900; k++) {
+ let x = r() * W, y = r() * H, a = r() * Math.PI * 2; g.beginPath(); g.moveTo(x, y);
+ for (let s = 0; s < 6 + r() * 10; s++) { a += (r() - .5) * 1.6; x += Math.cos(a) * (6 + r() * 14); y += Math.sin(a) * (6 + r() * 14); g.lineTo(x, y); }
+ g.stroke();
+ }
+});
+
+// ---------- 手绘线 ----------
+// 把折线/曲线采样后加噪声抖动;boil = 当前时间换种子的频率(0 = 不抖)
+P.boilSeed = (t, fps = 12) => Math.floor(t * fps);
+P.roughPath = (c, pts, { amp = 2, seed = 1, closed = false, step = 6 } = {}) => {
+ const r = rng(seed);
+ // 先按 step 重采样
+ const out = [];
+ const N = closed ? pts.length : pts.length - 1;
+ for (let i = 0; i < N; i++) {
+ const a = pts[i], b = pts[(i + 1) % pts.length], L = Math.hypot(b[0] - a[0], b[1] - a[1]), n = Math.max(1, Math.round(L / step));
+ for (let k = 0; k < n; k++) { const q = k / n; out.push([lerp(a[0], b[0], q) + (r() - .5) * amp, lerp(a[1], b[1], q) + (r() - .5) * amp]); }
+ }
+ if (!closed) out.push([pts[pts.length - 1][0] + (r() - .5) * amp, pts[pts.length - 1][1] + (r() - .5) * amp]);
+ c.beginPath(); out.forEach((p, i) => i ? c.lineTo(p[0], p[1]) : c.moveTo(p[0], p[1])); if (closed) c.closePath();
+};
+// 三次贝塞尔采样成点列(便于 roughPath / 变形)
+P.bez = (p0, p1, p2, p3, n = 24) => { const o = []; for (let i = 0; i <= n; i++) { const t = i / n, u = 1 - t; o.push([u * u * u * p0[0] + 3 * u * u * t * p1[0] + 3 * u * t * t * p2[0] + t * t * t * p3[0], u * u * u * p0[1] + 3 * u * u * t * p1[1] + 3 * u * t * t * p2[1] + t * t * t * p3[1]]); } return o; };
+// SVG path 字符串 → Path2D(写复杂轮廓最省事)
+P.path = (d) => new Path2D(d);
+
+// ---------- 风格渲染器(对一张底稿 canvas 做「重画」) ----------
+// 1) 流场笔触(梵高/印象派):在抖动网格上取底稿颜色,沿 angle(x,y,t) 画短笔触,带深色描边
+// cap:宽笔(width ≥ 30)密排时圆头会连成一排排「人头/鹅卵石」(迁移测试 D 蓝色时期),改 'butt'。
+// boil:只给母题区域沸腾,静止区(地板、道具、角色)boil=0 种子固定——全屏 8fps 换种子读成满屏闪烁(迁移测试 C 莫奈)。
+P.strokes = (dst, src, { cell = 12, len = 22, width = 7, angle, seed = 1, t = 0, boil = 8, outline = 0.35, outlineCol = [20, 25, 60], outlineMix = 0.55, jitterCol = 18, mask, alphaMask = false, palette, cap = 'round' } = {}) => {
+ const sd = src.getContext('2d').getImageData(0, 0, W, H).data;
+ const r = rng(seed * 1000 + P.boilSeed(t, boil));
+ dst.lineCap = cap;
+ for (let y = 0; y < H + cell; y += cell) for (let x = 0; x < W + cell; x += cell) {
+ const px = x + (r() - .5) * cell, py = y + (r() - .5) * cell;
+ const ix = clamp(px | 0, 0, W - 1), iy = clamp(py | 0, 0, H - 1), i = (iy * W + ix) * 4;
+ if (mask && !mask(px, py)) continue;
+ if (alphaMask && sd[i + 3] < 200) continue;
+ let col = [sd[i], sd[i + 1], sd[i + 2]];
+ const pc = palette ? palette(px, py, col, r) : null; if (pc) col = pc; // 区域色板:从色组里抽一个颜色
+ const a = angle ? angle(px, py, t) : 0, l = len * (0.7 + r() * 0.6);
+ const dx = Math.cos(a) * l / 2, dy = Math.sin(a) * l / 2;
+ if (outline > 0) { dst.strokeStyle = P.rgb(P.mix(col, outlineCol, outlineMix), outline); dst.lineWidth = width + 2.5; dst.beginPath(); dst.moveTo(px - dx, py - dy); dst.lineTo(px + dx, py + dy); dst.stroke(); }
+ dst.strokeStyle = P.rgb(pc ? col : P.jitter(col, r, jitterCol)); dst.lineWidth = width;
+ dst.beginPath(); dst.moveTo(px - dx, py - dy); dst.lineTo(px + dx, py + dy); dst.stroke();
+ }
+};
+// 色组工具:给一组 hex 和权重,返回按随机数抽色的函数(配 strokes 的 palette 用);mixBase 把底稿色混进来保留明暗
+P.swatch = (hexes, mixBase = 0.35) => { const cs = hexes.map(P.hex); return (col, r) => { const k = cs[(r() * cs.length) | 0]; return P.mix(k, col, mixBase); }; };
+// 2) 色点(印象派):椭圆短点,颜色带冷暖偏移、大小不一。注意这不是点彩——修拉的点彩是「等大点+纯色板视觉混色」,用 P.pointillism(lib/render.js)
+P.dabs = (dst, src, { cell = 10, size = 9, seed = 2, t = 0, boil = 8, angle = -0.6, shift = 22 } = {}) => {
+ const sd = src.getContext('2d').getImageData(0, 0, W, H).data, r = rng(seed * 1000 + P.boilSeed(t, boil));
+ for (let y = 0; y < H + cell; y += cell) for (let x = 0; x < W + cell; x += cell) {
+ const px = x + (r() - .5) * cell * 1.2, py = y + (r() - .5) * cell * 1.2;
+ const i = (clamp(py | 0, 0, H - 1) * W + clamp(px | 0, 0, W - 1)) * 4;
+ const warm = r() < 0.5 ? [shift, shift * 0.5, -shift] : [-shift * 0.6, 0, shift];
+ dst.fillStyle = `rgb(${sd[i] + warm[0]},${sd[i + 1] + warm[1]},${sd[i + 2] + warm[2]})`;
+ dst.beginPath(); dst.ellipse(px, py, size * (0.8 + r() * 0.6), size * 0.45, angle + (r() - .5) * 0.5, 0, Math.PI * 2); dst.fill();
+ }
+};
+// 3) 马赛克:带缝隙的小石块,颜色取中心,略有抖动与倒角
+P.mosaic = (dst, src, { tile = 14, grout = '#3b352e', seed = 3, jitter = 0.25 } = {}) => {
+ const sd = src.getContext('2d').getImageData(0, 0, W, H).data, r = rng(seed);
+ dst.fillStyle = grout; dst.fillRect(0, 0, W, H);
+ for (let y = 0; y < H; y += tile) { const off = (y / tile) % 2 ? tile * 0.5 * jitter : 0; for (let x = -tile; x < W; x += tile) {
+ const cx = x + off + tile / 2, cy = y + tile / 2, i = (clamp(cy | 0, 0, H - 1) * W + clamp(cx | 0, 0, W - 1)) * 4;
+ const c = P.jitter([sd[i], sd[i + 1], sd[i + 2]], r, 14), s = tile * (0.82 + r() * 0.1);
+ dst.fillStyle = P.rgb(c); dst.fillRect(cx - s / 2 + (r() - .5) * 1.5, cy - s / 2 + (r() - .5) * 1.5, s, s);
+ dst.fillStyle = 'rgba(255,255,255,.12)'; dst.fillRect(cx - s / 2, cy - s / 2, s, 2);
+ } }
+};
+// 4) 网点(本戴点):颜色取中心,半径随暗度
+P.halftone = (dst, src, { cell = 14, paper = '#f4ecd8', seed = 4 } = {}) => {
+ const sd = src.getContext('2d').getImageData(0, 0, W, H).data;
+ dst.fillStyle = paper; dst.fillRect(0, 0, W, H);
+ for (let y = 0; y < H + cell; y += cell) for (let x = 0; x < W + cell; x += cell) {
+ const cx = x + ((y / cell) % 2) * cell / 2, i = (clamp(y | 0, 0, H - 1) * W + clamp(cx | 0, 0, W - 1)) * 4;
+ const L = (sd[i] * .3 + sd[i + 1] * .59 + sd[i + 2] * .11) / 255;
+ dst.fillStyle = `rgb(${sd[i]},${sd[i + 1]},${sd[i + 2]})`;
+ dst.beginPath(); dst.arc(cx, y, cell * 0.72 * (0.3 + (1 - L) * 0.9), 0, Math.PI * 2); dst.fill();
+ }
+};
+// 5) 像素:最近邻降采样,可选调色板量化
+P.pixelate = (dst, src, { size = 8, palette } = {}) => {
+ const w = Math.ceil(W / size), h = Math.ceil(H / size), s = P.scratch('px'), g = s.getContext('2d');
+ g.imageSmoothingEnabled = false; g.clearRect(0, 0, w, h); g.drawImage(src, 0, 0, w, h);
+ if (palette) { const pal = palette.map(P.hex), im = g.getImageData(0, 0, w, h), d = im.data;
+ for (let i = 0; i < d.length; i += 4) { let best = 0, bd = 1e9; for (let k = 0; k < pal.length; k++) { const q = pal[k], dd = (d[i] - q[0]) ** 2 + (d[i + 1] - q[1]) ** 2 + (d[i + 2] - q[2]) ** 2; if (dd < bd) { bd = dd; best = k; } } d[i] = pal[best][0]; d[i + 1] = pal[best][1]; d[i + 2] = pal[best][2]; }
+ g.putImageData(im, 0, 0); }
+ dst.imageSmoothingEnabled = false; dst.drawImage(s, 0, 0, w, h, 0, 0, w * size, h * size); dst.imageSmoothingEnabled = true;
+};
+// 6) 立体主义切面:抖动三角网,每块取「偏移视角」的颜色做线性渐变,描暗边
+P.facets = (dst, src, { nx = 22, ny = 13, seed = 5, t = 0, shiftAmt = 26, edge = 'rgba(40,30,20,.45)' } = {}) => {
+ const sd = src.getContext('2d').getImageData(0, 0, W, H).data, r = rng(seed);
+ const pts = []; for (let j = 0; j <= ny; j++) for (let i = 0; i <= nx; i++) { const e = i === 0 || j === 0 || i === nx || j === ny; pts.push([i / nx * W + (e ? 0 : (r() - .5) * W / nx * .9), j / ny * H + (e ? 0 : (r() - .5) * H / ny * .9)]); }
+ const col = (x, y) => { const i = (clamp(y | 0, 0, H - 1) * W + clamp(x | 0, 0, W - 1)) * 4; return [sd[i], sd[i + 1], sd[i + 2]]; };
+ for (let j = 0; j < ny; j++) for (let i = 0; i < nx; i++) {
+ const a = pts[j * (nx + 1) + i], b = pts[j * (nx + 1) + i + 1], c2 = pts[(j + 1) * (nx + 1) + i], d2 = pts[(j + 1) * (nx + 1) + i + 1];
+ for (const tri of (r() < .5 ? [[a, b, d2], [a, d2, c2]] : [[a, b, c2], [b, d2, c2]])) {
+ const cx = (tri[0][0] + tri[1][0] + tri[2][0]) / 3, cy = (tri[0][1] + tri[1][1] + tri[2][1]) / 3;
+ const sh = Math.sin(t * 3 + cx * 0.01) * shiftAmt * r();
+ const c0 = col(cx + sh, cy), c1 = P.mix(c0, [60, 45, 30], 0.35);
+ const g = dst.createLinearGradient(tri[0][0], tri[0][1], tri[2][0], tri[2][1]); g.addColorStop(0, P.rgb(P.mix(c0, [255, 250, 235], 0.12))); g.addColorStop(1, P.rgb(c1));
+ dst.fillStyle = g; dst.beginPath(); tri.forEach((p, k) => k ? dst.lineTo(p[0], p[1]) : dst.moveTo(p[0], p[1])); dst.closePath(); dst.fill();
+ dst.strokeStyle = edge; dst.lineWidth = 1.5; dst.stroke();
+ }
+ }
+};
+
+// ---------- 共享编舞:16 个时代用同一套动作曲线,各自用自己的画法画出来 ----------
+// lt = 本段局部时间(秒)。返回 0..1 或角度,时代代码按需取用。
+// 端杯循环(全片时间):2.4s 一轮——0.9s 举到嘴边、停 0.7s 喝、0.8s 放回
+P.cupCycle = (t, period = 2.4) => { const q = ((t % period) + period) % period;
+ if (q < 0.9) return 0.5 - 0.5 * Math.cos(q / 0.9 * Math.PI); if (q < 1.6) return 1; return 0.5 + 0.5 * Math.cos((q - 1.6) / 0.8 * Math.PI); };
+P.choreo = (lt, t) => ({
+ cupG: P.cupCycle(t), // 按全片时间的端杯(跨段连续:速通片换段时姿势不重置)
+ cup: 0.5 - 0.5 * Math.cos(Math.min(1, lt / 0.9) * Math.PI), // 端杯:0=在桌上 1=在嘴边(约 0.9s 举起)
+ sip: Math.max(0, Math.sin(lt * 6)) * 0.15, // 喝时头部微仰
+ tail: Math.sin(t * 5.2) * 0.35 + Math.sin(t * 11) * 0.08, // 猫尾摆(弧度)
+ blink: (t % 2.3) > 2.18 ? 1 : 0, // 眨眼
+ ear: Math.max(0, Math.sin(t * 9)) > 0.97 ? 1 : 0,
+ breathe: Math.sin(t * 4) * 0.012,
+ steam: t, // 热气用全局时间
+});
+
+// ---------- 通用元素 ----------
+// 热气:几条随时间上行的正弦曲线(风格化的 S 形可传 width/color)
+P.steam = (c, t, x, y, { h = 80, n = 3, color = 'rgba(255,255,255,.8)', width = 4, spread = 16, wobble = 10, seed = 1 } = {}) => {
+ c.save(); c.lineCap = 'round'; c.lineWidth = width;
+ for (let k = 0; k < n; k++) {
+ const ox = (k - (n - 1) / 2) * spread, ph = t * 3 + k * 2.1 + seed;
+ const g = c.createLinearGradient(0, y, 0, y - h); g.addColorStop(0, color); g.addColorStop(1, 'rgba(255,255,255,0)'); c.strokeStyle = g;
+ c.beginPath(); for (let s = 0; s <= 20; s++) { const q = s / 20; const xx = x + ox + Math.sin(ph - q * 5) * wobble * q, yy = y - q * h; s ? c.lineTo(xx, yy) : c.moveTo(xx, yy); } c.stroke();
+ }
+ c.restore();
+};
+// 粒子:给定种子与时间,返回确定的粒子位置(飘落/上浮)
+P.particles = (n, seed, t, { x0 = 0, x1 = W, y0 = -40, y1 = H + 40, speed = 80, drift = 30, life = 6 } = {}) => {
+ const r = rng(seed), out = [];
+ for (let i = 0; i < n; i++) { const bx = lerp(x0, x1, r()), ph = r() * life, sp = speed * (0.6 + r() * 0.8), q = ((t + ph) % life) / life;
+ out.push({ x: bx + Math.sin((t + ph) * 1.7 + i) * drift, y: lerp(y0, y1, q), a: r() * Math.PI * 2 + t * (r() - .5) * 3, s: 0.6 + r() * 0.8, q, i }); }
+ return out;
+};
+})();
diff --git a/scripts/engine/lib/post.js b/scripts/engine/lib/post.js
new file mode 100644
index 0000000..b4a9803
--- /dev/null
+++ b/scripts/engine/lib/post.js
@@ -0,0 +1,108 @@
+// 后期:整幅叠在画面上的「媒介层」。全部挂在 PAINT(P)上。
+// 来源:迁移测试 B(蒸汽波 VHS、吉卜力角色水彩肌理)、D(橡皮管胶片、新海诚泛光/光晕)、A(敦煌褪色)。
+// P.rgbSplit(c, S, opt) RGB 三通道分离错位:multiply 取单通道 → lighter 合成到黑底(VHS、故障、3D 眼镜)
+// P.vhs(c, S, t, lt, opt) VHS 全套:通道分离+跟踪噪声带下滚撕裂+扫描线+OSD+暗角(先把整幅画进离屏 S)
+// P.scanlines(c, a1, a2) 4px 扫描线 pattern
+// P.film(c, t, opt) 老胶片层:24fps 闪烁、跨格存活的竖划痕、灰尘毛发、颗粒抖动、圆角片门(1930 卡通、默片)
+// P.gateWeave(c, t, fn, amp) 抖片:fn 里画的内容整体按 24fps 微抖
+// P.bloom(c, opt) 泛光:整帧缩小糊化后 screen 回叠(新海诚、CG)
+// P.lensFlare(c, sun, t, opt) 镜头光晕:太阳核+慢转星芒+横向拉丝+沿 太阳→画心 的六边形光斑
+// P.textureInside(c, shapeLayer, drawTex, opt) 纹理只「乘」在角色上:纹理层 destination-in 角色剪影 → multiply 叠回
+// P.fade(c, opt) 褪色/单色化:saturation 混合去色+multiply 染色(壁画褪色、胶片单色)
+// P.vignette(c, opt) 径向暗角
+(() => {
+const W = 1920, H = 1080;
+const P = window.PAINT;
+const { rng } = U;
+
+// ---------- 通道分离 / VHS ----------
+P.rgbSplit = (c, S, { r = [-3, 0], g = [0, 0], b = [3, 1], key = 'rgbSplit' } = {}) => {
+ const T = P.scratch(key), tg = T.getContext('2d');
+ c.save(); c.fillStyle = '#000'; c.fillRect(0, 0, W, H); c.globalCompositeOperation = 'lighter';
+ [['#ff0000', r], ['#00ff00', g], ['#0000ff', b]].forEach(([col, [dx, dy]]) => {
+ tg.globalCompositeOperation = 'source-over'; tg.clearRect(0, 0, W, H); tg.drawImage(S, 0, 0);
+ tg.globalCompositeOperation = 'multiply'; tg.fillStyle = col; tg.fillRect(0, 0, W, H);
+ c.drawImage(T, dx, dy);
+ });
+ c.restore();
+};
+P.scanlines = (c, a1 = 0.28, a2 = 0.12) => {
+ const tile = P.cached(`scan_${a1}_${a2}`, 4, 4, g => { g.fillStyle = `rgba(0,0,0,${a1})`; g.fillRect(0, 0, 4, 1); g.fillStyle = `rgba(0,0,0,${a2})`; g.fillRect(0, 2, 4, 1); });
+ c.save(); c.fillStyle = c.createPattern(tile, 'repeat'); c.fillRect(0, 0, W, H); c.restore();
+};
+// osd: false 关掉;或 {label:'PLAY', date:'SEP. 04 2011', clock:'23:59', font:'PressStart2P-400'}(▶ 自己画:像素字体里没有这个字形)
+P.vhs = (c, S, t, lt, { osd = {}, band = 70, bandSpeed = 520, vignette = 'rgba(10,0,25,.55)' } = {}) => {
+ const f = Math.floor(t * 60), jit = U.hash(f >> 2, 9) < 0.12 ? 1 : 0;
+ const ca = 3 + jit * 6 + Math.sin(t * 7) * 1.5; // 色差错位量(偶发加大)
+ P.rgbSplit(c, S, { r: [-ca, 0], g: [0, 0], b: [ca, 1], key: 'vhsSplit' });
+ // 跟踪噪声带:从上往下滚,带内每 6px 横向撕裂+白噪声线
+ const by = ((lt * bandSpeed + 200) % (H + 160)) - 80, bh = band, r = rng(f * 7 + 1);
+ for (let y = by; y < by + bh; y += 6) { const dx = (r() - 0.5) * 60 * Math.sin((y - by) / bh * Math.PI); c.drawImage(S, 0, y, W, 6, dx, y, W, 6); }
+ c.save(); c.globalAlpha = 0.5; for (let i = 0; i < 90; i++) { c.fillStyle = r() < 0.5 ? '#ffffff' : '#bbbbbb'; c.fillRect(r() * W, by + r() * bh, 20 + r() * 120, 1.5); } c.restore();
+ P.scanlines(c);
+ if (osd) {
+ const font = osd.font || 'PressStart2P-400';
+ c.save(); c.font = `34px "${font}"`; c.fillStyle = '#ffffff'; c.shadowColor = 'rgba(0,0,0,.8)'; c.shadowOffsetX = 3; c.shadowOffsetY = 3;
+ if ((f >> 4) % 2 === 0 || lt < 0.2) { c.fillText(osd.label || 'PLAY', 60, 92); c.beginPath(); c.moveTo(232, 60); c.lineTo(262, 77); c.lineTo(232, 94); c.closePath(); c.fill(); }
+ c.font = `26px "${font}"`; c.fillText(osd.date || 'SEP. 04 2011', 60, 1020); c.fillText((osd.clock || '23:59') + ':' + String(30 + Math.floor(lt)).padStart(2, '0') + ':' + String(Math.floor(lt * 30) % 30).padStart(2, '0'), 60, 1056);
+ c.restore();
+ }
+ if (vignette) P.vignette(c, { inner: 500, outer: 1150, col: vignette });
+};
+
+// ---------- 胶片 ----------
+P.film = (c, t, { fps = 24, flicker = [0.02, 0.07, 0.06], scratches = 3, dust = 14, grain = 'film', grainDensity = 0.18, gate = true, ink = '20,16,10', light = '255,252,240' } = {}) => {
+ const fq = Math.floor(t * fps), r = rng(fq * 7919 + 11);
+ c.fillStyle = `rgba(255,250,235,${flicker[0] + r() * flicker[1]})`; c.fillRect(0, 0, W, H);
+ c.fillStyle = `rgba(${ink},${r() * flicker[2]})`; c.fillRect(0, 0, W, H);
+ // 竖划痕:用 floor(t*6) 当寿命,一条划痕能活好几格
+ const r6 = rng(Math.floor(t * 6) * 131 + 5);
+ for (let k = 0; k < scratches; k++) { const x = r6() * W + (r() - 0.5) * 6; c.strokeStyle = r6() < 0.5 ? `rgba(${light},.55)` : `rgba(${ink},.5)`; c.lineWidth = 1 + r6() * 2; c.beginPath(); c.moveTo(x, 0); c.lineTo(x + (r() - 0.5) * 12, H); c.stroke(); }
+ for (let k = 0; k < dust; k++) { c.fillStyle = r() < 0.6 ? `rgba(${ink},.7)` : `rgba(${light},.8)`; c.beginPath(); c.arc(r() * W, r() * H, 1 + r() * 3.5, 0, 7); c.fill(); }
+ if (r() < 0.5) { c.strokeStyle = `rgba(${ink},.6)`; c.lineWidth = 1.6; const x = r() * W, y = r() * H; c.beginPath(); c.moveTo(x, y); c.bezierCurveTo(x + 30, y - 20, x + 10, y + 40, x + 50, y + 30); c.stroke(); }
+ if (grain) c.drawImage(P.grain(grain, grainDensity, ink.split(',').map(Number), 0.25), (r() - 0.5) * 40, (r() - 0.5) * 40);
+ if (gate) c.drawImage(P.cached('film_gate', W, H, (g) => {
+ const vg = g.createRadialGradient(960, 540, 420, 960, 540, 1150); vg.addColorStop(0, 'rgba(10,8,5,0)'); vg.addColorStop(0.7, 'rgba(10,8,5,.18)'); vg.addColorStop(1, 'rgba(10,8,5,.85)'); g.fillStyle = vg; g.fillRect(0, 0, W, H);
+ g.fillStyle = '#0c0a07'; g.beginPath(); g.rect(0, 0, W, H); g.roundRect(18, 14, W - 36, H - 28, 60); g.fill('evenodd');
+ }), 0, 0);
+};
+P.gateWeave = (c, t, fn, amp = [3, 4], fps = 24) => { const r = rng(Math.floor(t * fps) * 31 + 7); c.save(); c.translate((r() - 0.5) * amp[0], (r() - 0.5) * amp[1]); fn(); c.restore(); };
+
+// ---------- 光 ----------
+P.bloom = (c, { scale = 4, blur = 6, brightness = 1.1, alpha = 0.28, key = 'bloom' } = {}) => {
+ const w = W / scale, h = H / scale, bl = P.scratch(key), g = bl.getContext('2d'); g.reset();
+ g.filter = `blur(${blur}px) brightness(${brightness})`; g.drawImage(c.canvas, 0, 0, w, h);
+ c.save(); c.globalCompositeOperation = 'screen'; c.globalAlpha = alpha; c.drawImage(bl, 0, 0, w, h, 0, 0, W, H); c.restore();
+};
+// 坑:太阳要放在玻璃里面、核半径 ≤130,否则光晕溢到墙上像墙上挂了盏灯;横丝别超过 ~840px,否则像 bug 线。
+P.lensFlare = (c, sun, t, { core = 130, rays = 10, streak = 840, ghosts = [[0.45, 34, '120,255,200', 0.09], [0.75, 18, '255,180,120', 0.12], [1.25, 56, '140,170,255', 0.06], [1.6, 24, '255,140,220', 0.09], [2.0, 90, '120,220,255', 0.04]] } = {}) => {
+ c.save(); c.globalCompositeOperation = 'lighter';
+ const sg = c.createRadialGradient(...sun, 0, ...sun, core); sg.addColorStop(0, 'rgba(255,255,250,.95)'); sg.addColorStop(0.18, 'rgba(255,248,220,.55)'); sg.addColorStop(1, 'rgba(255,230,180,0)'); c.fillStyle = sg; c.beginPath(); c.arc(...sun, core, 0, 7); c.fill();
+ for (let k = 0; k < rays; k++) { const a = k / rays * Math.PI * 2 + t * 0.25, L = (k % 2 ? 90 : 170) * (0.9 + 0.1 * Math.sin(t * 5 + k)); c.strokeStyle = 'rgba(255,250,235,.28)'; c.lineWidth = 2.5; c.beginPath(); c.moveTo(...sun); c.lineTo(sun[0] + Math.cos(a) * L, sun[1] + Math.sin(a) * L); c.stroke(); }
+ const hz = c.createLinearGradient(sun[0] - streak / 2, 0, sun[0] + streak / 2, 0); hz.addColorStop(0, 'rgba(120,200,255,0)'); hz.addColorStop(0.5, 'rgba(200,235,255,.35)'); hz.addColorStop(1, 'rgba(120,200,255,0)'); c.fillStyle = hz; c.fillRect(sun[0] - streak / 2, sun[1] - 2, streak, 4);
+ const cxp = 960 + Math.sin(t * 0.7) * 20, cyp = 540;
+ ghosts.forEach(([k, r, col, a]) => {
+ const x = sun[0] + (cxp - sun[0]) * k, y = sun[1] + (cyp - sun[1]) * k; c.fillStyle = `rgba(${col},${a})`; c.beginPath(); for (let i = 0; i < 6; i++) { const aa = i / 6 * Math.PI * 2 + 0.3; i ? c.lineTo(x + Math.cos(aa) * r, y + Math.sin(aa) * r) : c.moveTo(x + Math.cos(aa) * r, y + Math.sin(aa) * r); } c.closePath(); c.fill(); });
+ c.restore();
+};
+
+// ---------- 纹理叠在角色上 ----------
+// shapeLayer:只画了角色的离屏(透明底);drawTex(g) 往纹理层上画纸纹/颗粒/色晕。
+// 坑:直接 source-atop 叠纸纹会把纸的颜色盖上去,人物整体发白;正确做法是纹理层 destination-in 角色剪影,再 multiply 叠回(迁移测试 B)。
+P.textureInside = (c, shapeLayer, drawTex, { op = 'multiply', alpha = 1, key = 'texInside' } = {}) => {
+ const M = P.scratch(key), mg = M.getContext('2d'); mg.reset(); mg.clearRect(0, 0, W, H);
+ drawTex(mg);
+ mg.globalCompositeOperation = 'destination-in'; mg.globalAlpha = 1; mg.drawImage(shapeLayer, 0, 0);
+ c.save(); c.globalCompositeOperation = op; c.globalAlpha = alpha; c.drawImage(M, 0, 0); c.restore();
+};
+
+// ---------- 色调 ----------
+// sat: saturation 混合灰的 α(1 = 完全去色);tint: multiply 一层颜色(暖灰 '#f2e8d2' = 老胶片;土色纹理 = 壁画)
+P.fade = (c, { sat = 1, tint } = {}) => {
+ c.save(); c.globalCompositeOperation = 'saturation'; c.fillStyle = `rgba(128,128,128,${sat})`; c.fillRect(0, 0, W, H); c.restore();
+ if (tint) { c.save(); c.globalCompositeOperation = 'multiply'; c.fillStyle = tint; c.fillRect(0, 0, W, H); c.restore(); }
+};
+P.vignette = (c, { cx = 960, cy = 540, inner = 520, outer = 1150, col = 'rgba(0,0,0,.4)' } = {}) => {
+ const vg = c.createRadialGradient(cx, cy, inner, cx, cy, outer); vg.addColorStop(0, col.replace(/[\d.]+\)$/, '0)')); vg.addColorStop(1, col); c.fillStyle = vg; c.fillRect(0, 0, W, H);
+};
+})();
diff --git a/scripts/engine/lib/render.js b/scripts/engine/lib/render.js
new file mode 100644
index 0000000..6ae4a46
--- /dev/null
+++ b/scripts/engine/lib/render.js
@@ -0,0 +1,188 @@
+// 渲染器与光影:网点、点彩、赛璐珞、漫画阴影、体积、长影子、双版本光影、光照图、皮影皮件、手剪位移。全部挂在 PAINT(P)上。
+// 来源:迁移测试 B(构成主义/达利/霍珀/吉卜力)、C(Kirby/修拉/马蒂斯)、D(伦勃朗/皮影/新海诚)。
+// P.halftoneGray(c, src, bx,by,bw,bh, cell, col, gain, ang) 灰度照片网点:45° 网格、点径 ∝ √暗度、全部点并成一条 path 一次填(照片拼贴)
+// P.shadeDots(c, path, bx,by,bw,bh, cell, col, f) 路径内按函数 f(x,y)∈0..1 落网点(网点阴影)
+// P.dotPattern(c, key, pitch, r, col, bg, angleDeg) 本戴点 createPattern,带网屏角(四色印刷 C15° M75° Y0° K45°)
+// P.pointillism(c, src, opt) 修拉点彩=视觉混色:等大点、纯色板两两并置逼近目标色(P.dabs 是印象派,不是点彩)
+// P.clipBeside(c, path, dx, dy) clip 到「path 减去平移后的自身」——赛璐珞阴影带、Kirby 黑块、亮边的公共底
+// P.cel(c, p, base, shade, rim, opt) 赛璐珞两调+边缘光(新海诚、吉卜力角色)
+// P.kirbyShade(g, path, opt) Kirby 黑块阴影(spotted blacks)+羽化排线(feathering)
+// P.vol(c, path, x0,y0,x1,y1, a, b, occl, blur) 体积填色:线性渐变+路径内模糊暗边(学院派,无勾线)
+// P.castShadow(c, layers, opt) 剪切仿射长影子:剪影投到地面(达利的长影子、黄昏)
+// P.litClip(c, polys, drawLit) 双版本光影裁切:背光版先画好,光斑多边形里画受光版(霍珀的硬光块)
+// P.pool / P.lightMap / P.applyLight 光照图整幅相乘:环境光打底+lighter 叠光池+multiply(伦勃朗、烛光、夜景)
+// P.carve / P.piece / P.stamp 皮影:皮件填色→镂空刻纹→补皮边→描边;印到幕布 = 软影+multiply(剪影/镂空类风格)
+// P.roughen(layer, box, opt) 整层低频像素位移:RIG 角色的边也像手剪的(马蒂斯)
+// P.glowStroke(c, col, w, blur) 霓虹灯管:对当前路径用 shadowBlur 描辉光(再描一道近白细芯线就是灯管)
+(() => {
+const W = 1920, H = 1080, TAU = Math.PI * 2;
+const P = window.PAINT;
+const { clamp, lerp, rng } = U;
+
+// ---------- 网点 ----------
+P.halftoneGray = (c, src, bx, by, bw, bh, cell, col, gain = 0.78, ang = Math.PI / 4) => {
+ bx |= 0; by |= 0; bw |= 0; bh |= 0;
+ const d = src.getContext('2d', { willReadFrequently: true }).getImageData(bx, by, bw, bh).data;
+ const ca = Math.cos(ang), sa = Math.sin(ang), cx = bx + bw / 2, cy = by + bh / 2, R = Math.hypot(bw, bh) / 2;
+ c.beginPath();
+ for (let v = -R; v <= R; v += cell) for (let u = -R; u <= R; u += cell) {
+ const x = cx + u * ca - v * sa, y = cy + u * sa + v * ca, ix = (x - bx) | 0, iy = (y - by) | 0;
+ if (ix < 0 || iy < 0 || ix >= bw || iy >= bh) continue;
+ const i = (iy * bw + ix) * 4; if (d[i + 3] < 128) continue;
+ const L = (d[i] * .3 + d[i + 1] * .59 + d[i + 2] * .11) / 255, r = cell * gain * Math.sqrt(Math.max(0, 1 - L));
+ if (r < 0.45) continue; c.moveTo(x + r, y); c.arc(x, y, r, 0, TAU);
+ }
+ c.fillStyle = col; c.fill();
+};
+P.shadeDots = (c, path, bx, by, bw, bh, cell, col, f) => {
+ c.save(); c.clip(path); c.beginPath();
+ for (let y = by; y < by + bh; y += cell) for (let x = bx + ((((y - by) / cell) | 0) % 2) * cell / 2; x < bx + bw; x += cell) {
+ const r = cell * 0.62 * f(x, y); if (r < 0.5) continue; c.moveTo(x + r, y); c.arc(x, y, r, 0, TAU);
+ }
+ c.fillStyle = col; c.fill(); c.restore();
+};
+P.dotPattern = (c, key, pitch, r, col, bg, angleDeg = 45) => {
+ const tile = P.cached('dotpat_' + key, pitch, pitch, g => { if (bg) { g.fillStyle = bg; g.fillRect(0, 0, pitch, pitch); } g.fillStyle = col;
+ [[0, 0], [pitch, 0], [0, pitch], [pitch, pitch]].forEach(([x, y]) => { g.beginPath(); g.arc(x, y, r, 0, TAU); g.fill(); }); });
+ const p = c.createPattern(tile, 'repeat');
+ p.setTransform(new DOMMatrix().rotate(angleDeg));
+ return p;
+};
+
+// ---------- 点彩(修拉:视觉混色) ----------
+// 固定六角网格、点等大(pitch 10、rad 4.5、位置 ±1.2px 静态抖);每个点从纯色板 pal 里挑一对 (i,j):
+// 目标色投影到 Pj→Pi 上得连续比例 w(clamp .2–.8),距离加 0.004·|Pi−Pj|² 惩罚(别用黑白点混出灰),格子哈希 < w 选 i 否则 j。
+// 取色前给目标色加 ±colorJitter 哈希抖动——配对色分界变成交错的点,不出竖向色带(两个坑都踩过:偏好纯色→色带;连续比例→整列切换)。
+// compRate 的点换成补色 comp[idx];光渗:和 (+14,+6) 处亮度差 >45 时,亮侧放 white 点、暗侧放 dark 点。
+// shimmer(x,y) 为真的区域按 fps 重掷哈希(水面波光);flicker 比例的点按 fps 换成配对色(空气在颤,太低会被判「基本定格」)。
+// 色板要带淡色(和白混过的色),否则亮墙被拆成白+肤色+零星蓝点,像雪花噪声。约 2.4 万点、每色一条 Path2D 一次 fill,每帧约 100ms。
+const pointCache = new WeakMap();
+P.pointillism = (c, src, { pal, comp = {}, pitch = 10, rad = 4.5, posJitter = 2.4, colorJitter = 40, compRate = 0.08, flicker = 0.07, fps = 6, t = 0, shimmer, white = 12, dark = 0, bleed = 45 } = {}) => {
+ const PAL = pal.map(v => typeof v === 'string' ? P.hex(v) : v);
+ let cache = pointCache.get(pal); if (!cache) { cache = new Map(); pointCache.set(pal, cache); }
+ const pick = (r, g, b) => {
+ const key = (r >> 3) << 10 | (g >> 3) << 5 | (b >> 3);
+ let v = cache.get(key); if (v) return v;
+ let best = 1e18, bi = 0, bj = 0, bw = 1;
+ for (let i = 0; i < PAL.length; i++) for (let j = i + 1; j < PAL.length; j++) {
+ const pi = PAL[i], pj = PAL[j], ex = pi[0] - pj[0], ey = pi[1] - pj[1], ez = pi[2] - pj[2];
+ const w = clamp(((r - pj[0]) * ex + (g - pj[1]) * ey + (b - pj[2]) * ez) / (ex * ex + ey * ey + ez * ez + 1e-6), 0.2, 0.8);
+ const dr = pj[0] + w * ex - r, dg = pj[1] + w * ey - g, db = pj[2] + w * ez - b;
+ const d = dr * dr * 0.9 + dg * dg * 1.2 + db * db * 0.8 + ex * ex * 0.004 + ey * ey * 0.004 + ez * ez * 0.004;
+ if (d < best) { best = d; bi = i; bj = j; bw = w; }
+ }
+ v = [bi, bj, bw]; cache.set(key, v); return v;
+ };
+ const sd = src.getContext('2d', { willReadFrequently: true }).getImageData(0, 0, W, H).data;
+ const L = (x, y) => { const i = (clamp(y | 0, 0, H - 1) * W + clamp(x | 0, 0, W - 1)) * 4; return sd[i] * 0.3 + sd[i + 1] * 0.59 + sd[i + 2] * 0.11; };
+ const paths = PAL.map(() => new Path2D()), st = Math.floor(t * fps), ROWH = pitch * 0.866, hj = posJitter / 2;
+ for (let j = 0, y = 0; y < H + ROWH; j++, y += ROWH) for (let i = 0, x = (j % 2) * pitch / 2; x < W + pitch; i++, x += pitch) {
+ const jx = (U.hash(i, j * 7 + 1) - 0.5) * 2 * hj, jy = (U.hash(i * 3, j + 5) - 0.5) * 2 * hj, px = x + jx, py = y + jy;
+ const k = (clamp(py | 0, 0, H - 1) * W + clamp(px | 0, 0, W - 1)) * 4;
+ const dj = (U.hash(i * 7 + 3, j * 11) - 0.5) * colorJitter;
+ const [a, bb, w] = pick(clamp(sd[k] + dj, 0, 255), clamp(sd[k + 1] + dj * 0.8, 0, 255), clamp(sd[k + 2] - dj * 0.6, 0, 255));
+ const hseed = shimmer && shimmer(px, py) ? U.hash(i + st * 977, j) : U.hash(i, j);
+ let idx = hseed < w ? a : bb;
+ const h2 = U.hash(i * 5 + 2, j * 3 + 9);
+ if (h2 < compRate && comp[idx] != null) idx = comp[idx];
+ else if (U.hash(i * 13 + st * 31, j * 17) < flicker) idx = (U.hash(i, j + st) < w) ? bb : a;
+ else { const dl = L(px, py) - L(px + 14, py + 6); if (Math.abs(dl) > bleed && h2 < 0.45) idx = dl > 0 ? white : dark; }
+ paths[idx].moveTo(px + rad, py); paths[idx].arc(px, py, rad, 0, TAU);
+ }
+ paths.forEach((p, k) => { c.fillStyle = P.rgb(PAL[k]); c.fill(p); });
+};
+
+// ---------- 赛璐珞 / 漫画阴影 ----------
+const BIG = (() => { const p = new Path2D(); p.rect(-60, -60, W + 120, H + 120); return p; })();
+// clip 到 path ∩ ¬translate(path, dx, dy):沿 (dx,dy) 方向的那一侧之外留下一条带(光从 -(dx,dy) 来时就是背光侧的阴影带)
+P.clipBeside = (c, path, dx, dy) => { const m = new Path2D(); m.addPath(BIG); m.addPath(path, new DOMMatrix().translate(dx, dy)); c.clip(path); c.clip(m, 'evenodd'); };
+// 底色 → 背光侧硬阴影带(宽 sd,光方向 (lx,ly) 指向光源的反方向:lx=-1 光从左来、阴影在右)→ 受光侧亮边(宽 rw)→ 细描线。
+// 按部件顺序逐个 cel,遮挡天然正确,不需要 visibleLines。逆光(窗下的猫):lx/ly 取反并另加 lighter 暖色亮边。
+P.cel = (c, p, base, shade, rim, { sd = 22, rw = 7, line = '#6a4632', lw = 2.2, lx = -1, ly = -0.55 } = {}) => {
+ if (!p) return;
+ c.fillStyle = base; c.fill(p);
+ if (shade) { c.save(); P.clipBeside(c, p, lx * sd, ly * sd); c.fillStyle = shade; c.fill(p); c.restore(); }
+ if (rim) { c.save(); P.clipBeside(c, p, -lx * rw, -ly * rw); c.fillStyle = rim; c.fill(p); c.restore(); }
+ if (lw) { c.strokeStyle = line; c.lineWidth = lw; c.lineJoin = 'round'; c.stroke(p); }
+};
+// Kirby:light 指向光源(默认左上),黑块 = path ∩ ¬shift(d1),羽化带 = path ∩ ¬shift(d2) 里沿光方向的平行线(间距 gap)
+P.kirbyShade = (g, path, { d1 = 14, d2 = 30, gap = 9, light = [-0.86, -0.5], ink = '#141212', lw = 2.6 } = {}) => {
+ g.save(); P.clipBeside(g, path, light[0] * d2, light[1] * d2);
+ g.strokeStyle = ink; g.lineWidth = lw; g.lineCap = 'butt'; g.beginPath();
+ const a = Math.atan2(light[1], light[0]), nx = -Math.sin(a), ny = Math.cos(a);
+ for (let k = -260; k < 260; k++) { const ox = 960 + nx * k * gap, oy = 540 + ny * k * gap; g.moveTo(ox - light[0] * 1400, oy - light[1] * 1400); g.lineTo(ox + light[0] * 1400, oy + light[1] * 1400); }
+ g.stroke(); g.restore();
+ g.save(); P.clipBeside(g, path, light[0] * d1, light[1] * d1); g.fillStyle = ink; g.fillRect(0, 0, W, H); g.restore();
+};
+
+// ---------- 体积 / 影子 / 光 ----------
+P.vol = (c, path, x0, y0, x1, y1, a, b, occl = 'rgba(40,20,10,.45)', blur = 14) => {
+ const g = c.createLinearGradient(x0, y0, x1, y1); g.addColorStop(0, a); g.addColorStop(1, b);
+ c.fillStyle = g; c.fill(path);
+ if (occl) { c.save(); c.clip(path); c.shadowColor = occl; c.shadowBlur = blur; c.strokeStyle = occl; c.lineWidth = blur * 0.6; c.stroke(path); c.restore(); }
+};
+// layers: [[yg, g => { 在 g 上用黑色画这一组物体的剪影 }], ...],yg 是这组物体的着地线。
+// 剪切仿射 y' = yg − ky·(yg − y)、x' = x − kx·(y' 方向的高度),影子往右后方躺(太阳在左前方低空);kx 变大 = 影子变长(黄昏)。
+// 所有剪影先画进一张离屏(纯黑)再整体以 alpha 叠,重叠处不会加深;clipY 以下才是地面。坑:ky>0 往观众方向投会被画框底边吃掉。
+P.castShadow = (c, layers, { kx = 1, ky = 0.22, clipY = 0, alpha = 0.55, blur = 1.5, key = 'castShadow' } = {}) => {
+ const S = P.scratch(key), g = S.getContext('2d'); g.reset(); g.clearRect(0, 0, W, H); g.fillStyle = '#000'; g.strokeStyle = '#000';
+ for (const [yg, fn] of layers) { g.setTransform(1, 0, -kx, ky, kx * yg, yg * (1 - ky)); fn(g); }
+ g.setTransform(1, 0, 0, 1, 0, 0);
+ c.save(); c.beginPath(); c.rect(0, clipY, W, H); c.clip(); c.globalAlpha = alpha; if (blur) c.filter = `blur(${blur}px)`; c.drawImage(S, 0, 0); c.restore();
+};
+// 双版本光影裁切:先把整幅画成背光版,再 clip 到光斑多边形(可多个、可每帧平移)画受光版 → 光影边缘是硬的、能整体移动。
+// 人物同理:drawLit 里用受光色再画一遍。人在墙上的投影=剪影平移后 source-in 背光版,再画回光斑里。
+P.litClip = (c, polys, drawLit) => {
+ c.save(); c.beginPath(); polys.forEach(pp => { pp.forEach((q, i) => i ? c.lineTo(q[0], q[1]) : c.moveTo(q[0], q[1])); c.closePath(); }); c.clip(); drawLit(c); c.restore();
+};
+// 光池:径向渐变的一团光(col 为 'r,g,b' 字符串)
+P.pool = (g, x, y, r, col, a) => { const rg = g.createRadialGradient(x, y, 0, x, y, r); rg.addColorStop(0, `rgba(${col},${a})`); rg.addColorStop(0.45, `rgba(${col},${a * 0.55})`); rg.addColorStop(1, `rgba(${col},0)`); g.fillStyle = rg; g.fillRect(x - r, y - r, 2 * r, 2 * r); };
+// 光照图:ambient 打底(环境光,伦勃朗约 rgb(30,21,13) = 0.13),fn(g) 里用 P.pool 叠光池(已是 lighter),返回画布
+P.lightMap = (key, ambient, fn) => {
+ const S = P.scratch('light_' + key), g = S.getContext('2d'); g.reset();
+ g.fillStyle = ambient; g.fillRect(0, 0, W, H); g.globalCompositeOperation = 'lighter'; fn(g); g.globalCompositeOperation = 'source-over';
+ return S;
+};
+// 整幅乘光:亮态底稿 × 光照图。所有明暗法、烛光、夜景都这么做——比逐个物体画明暗统一得多。
+P.applyLight = (c, map) => { c.save(); c.globalCompositeOperation = 'multiply'; c.drawImage(map, 0, 0); c.restore(); };
+
+// ---------- 皮影 / 镂空 ----------
+// 刻纹库(在 clip 内用 destination-out 画):dots 鱼子纹、flowers 团花、clouds 云纹、lattice 方格、lines 刻线
+P.carve = {
+ dots(g, x0, y0, x1, y1, s = 18, r = 3.2) { for (let y = y0; y < y1; y += s) for (let x = x0 + ((y / s | 0) % 2) * s / 2; x < x1; x += s) { g.beginPath(); g.arc(x, y, r, 0, 7); g.fill(); } },
+ flowers(g, x0, y0, x1, y1, s = 46, r = 5) { for (let y = y0; y < y1; y += s) for (let x = x0 + ((y / s | 0) % 2) * s / 2; x < x1; x += s) { for (let k = 0; k < 5; k++) { const a = k / 5 * Math.PI * 2; g.beginPath(); g.ellipse(x + Math.cos(a) * r * 1.5, y + Math.sin(a) * r * 1.5, r, r * 0.6, a, 0, 7); g.fill(); } } },
+ clouds(g, x0, y0, x1, y1, s = 40) { g.lineWidth = 3.4; g.lineCap = 'round'; for (let y = y0; y < y1; y += s) for (let x = x0 + ((y / s | 0) % 2) * s / 2; x < x1; x += s) { g.beginPath(); for (let a = 0; a < 7; a += 0.3) { const rr = 2 + a * 1.9; const px = x + Math.cos(a) * rr, py = y + Math.sin(a) * rr; a ? g.lineTo(px, py) : g.moveTo(px, py); } g.stroke(); } },
+ lattice(g, x0, y0, x1, y1, s = 26, w = 12) { for (let y = y0; y < y1; y += s) for (let x = x0; x < x1; x += s) g.fillRect(x + (s - w) / 2, y + (s - w) / 2, w, w); },
+ lines(g, segs, w = 3.2) { g.lineWidth = w; g.lineCap = 'round'; segs.forEach(sg => { g.beginPath(); sg.forEach((p, i) => i ? g.lineTo(...p) : g.moveTo(...p)); g.stroke(); }); },
+};
+// 一块皮件:填色 → carve(g) 在 clip 内镂空 → 补 edge 宽的同色皮边(刻纹不刻穿外轮廓)→ 深色描边。
+// 白色部位(猫的白胸白爪)直接整块镂空只留皮边——所有剪影/镂空类风格都适用。
+P.piece = (g, path, col, carve, { edge = 5, line = '#3a160a', lw = 2.6 } = {}) => {
+ g.save(); g.fillStyle = col; g.fill(path);
+ if (carve) { g.save(); g.clip(path); g.globalCompositeOperation = 'destination-out'; g.fillStyle = '#000'; g.strokeStyle = '#000'; carve(g); g.restore(); }
+ g.strokeStyle = col; g.lineWidth = edge * 2; g.lineJoin = 'round'; g.save(); g.clip(path); g.stroke(path); g.restore();
+ g.strokeStyle = line; g.lineWidth = lw; g.stroke(path); g.restore();
+};
+// 把一层皮件印到幕布上:先 multiply 一层偏移软影(皮件没贴紧幕布的虚影),再 multiply 本体(透光 = 幕布色 × 皮色,重叠处自然变深)
+P.stamp = (c, layer, { dx = 7, dy = 5, shadow = 0.28, blur = 6 } = {}) => {
+ c.save(); c.globalCompositeOperation = 'multiply'; c.globalAlpha = shadow; c.filter = `blur(${blur}px)`; c.drawImage(layer, dx, dy); c.restore();
+ c.save(); c.globalCompositeOperation = 'multiply'; c.drawImage(layer, 0, 0); c.restore();
+};
+
+// ---------- 霓虹 ----------
+P.glowStroke = (c, col, w, blur) => { c.shadowColor = col; c.shadowBlur = blur; c.strokeStyle = col; c.lineWidth = w; c.stroke(); c.shadowBlur = 0; };
+
+// ---------- 手剪位移 ----------
+// 对 layer 的 box=[x0,y0,x1,y1] 区域做静态低频位移(fbm 频率 freq、幅度 amp px):RIG 角色不给剪刀折线时,整层边缘也像手剪的。约 15ms。
+const fields = {};
+P.roughen = (layer, box, { freq = 0.028, amp = 9, key = 'rough' } = {}) => {
+ const [X0, Y0, X1, Y1] = box, w = X1 - X0, h = Y1 - Y0, fk = `${key}|${box}|${freq}|${amp}`;
+ const f = fields[fk] || (fields[fk] = (() => { const o = { dx: new Int8Array(w * h), dy: new Int8Array(w * h) };
+ for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) { const gx = (x + X0) * freq, gy = (y + Y0) * freq; o.dx[y * w + x] = Math.round(P.fbm(gx, gy, 2) * amp); o.dy[y * w + x] = Math.round(P.fbm(gx + 40, gy + 17, 2) * amp); } return o; })());
+ const g = layer.getContext('2d', { willReadFrequently: true });
+ const src = g.getImageData(X0, Y0, w, h), out = g.createImageData(w, h), s = src.data, o = out.data;
+ for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) { const k = y * w + x, sx = clamp(x + f.dx[k], 0, w - 1), sy = clamp(y + f.dy[k], 0, h - 1), j = (sy * w + sx) * 4, i = k * 4;
+ o[i] = s[j]; o[i + 1] = s[j + 1]; o[i + 2] = s[j + 2]; o[i + 3] = s[j + 3]; }
+ g.putImageData(out, X0, Y0);
+};
+})();
diff --git a/scripts/engine/lib/rig.js b/scripts/engine/lib/rig.js
new file mode 100644
index 0000000..c4ef9fb
--- /dev/null
+++ b/scripts/engine/lib/rig.js
@@ -0,0 +1,390 @@
+// 角色骨架:17 岁欧洲金发少女(侧身朝左坐)+ 橘白猫(朝右坐)。
+// 每个部位输出 Path2D,时代代码自己决定填色/描边/剪影/渲染器——同一副骨架、同一套动作,只换画法。
+// 坐标基于标准构图(分镜表 §2.5):人 (1120,200)-(1500,910),猫 (390,610)-(690,905),桌 (810,620)-(1200,905)。
+(() => {
+const { clamp, lerp } = U;
+const R = window.RIG = {};
+
+// 二骨 IK:肩 S,目标 T,上臂 a,前臂 b,bendSign 决定肘向
+R.ik2 = (S, T, a, b, bendSign = 1) => {
+ let dx = T[0] - S[0], dy = T[1] - S[1], d = Math.hypot(dx, dy);
+ d = Math.min(d, a + b - 0.01);
+ const ang = Math.atan2(dy, dx), cosA = clamp((a * a + d * d - b * b) / (2 * a * d), -1, 1);
+ const e = ang + bendSign * Math.acos(cosA);
+ const E = [S[0] + Math.cos(e) * a, S[1] + Math.sin(e) * a];
+ const H = [S[0] + Math.cos(ang) * d, S[1] + Math.sin(ang) * d];
+ return { E, H };
+};
+// 粗细变化的肢体:沿 A→B 画一个圆头胶囊。两端半圆帽朝外(逆时针从 n 走到 n-π)。
+// 旧版 arc 方向反了,帽子凹进胶囊、路径自交,粗描边/平涂时关节处露洞(迁移测试 C:哈林小人被画成奶牛)。
+R.limb = (A, B, wA, wB) => {
+ const p = new Path2D(), a = Math.atan2(B[1] - A[1], B[0] - A[0]), n = a + Math.PI / 2;
+ p.moveTo(A[0] + Math.cos(n) * wA / 2, A[1] + Math.sin(n) * wA / 2);
+ p.lineTo(B[0] + Math.cos(n) * wB / 2, B[1] + Math.sin(n) * wB / 2);
+ p.arc(B[0], B[1], wB / 2, n, n - Math.PI, true);
+ p.lineTo(A[0] - Math.cos(n) * wA / 2, A[1] - Math.sin(n) * wA / 2);
+ p.arc(A[0], A[1], wA / 2, n - Math.PI, n - 2 * Math.PI, true);
+ p.closePath(); return p;
+};
+// 非等比拉长(毕加索蓝色时期、El Greco 式的瘦长人物):以 anchor 为轴把整副骨架按 (sx, sy) 缩放。
+// 所有 Path2D(含 .pts 点列)、锚点、杯子、眼睛、HP/T 坐标函数一起变换;线宽不变(不像 setTransform 那样把描边也压扁)。
+R.stretch = (O, sx = 1, sy = 1, anchor = [0, 0]) => {
+ if (sx === 1 && sy === 1) return O;
+ const m = new DOMMatrix().translate(anchor[0], anchor[1]).scale(sx, sy).translate(-anchor[0], -anchor[1]);
+ const mp = q => { const r = m.transformPoint(new DOMPoint(q[0], q[1])); return [r.x, r.y]; };
+ const isPt = v => Array.isArray(v) && v.length === 2 && typeof v[0] === 'number' && typeof v[1] === 'number';
+ const map = v => {
+ if (v instanceof Path2D) { const p = new Path2D(); p.addPath(v, m); if (v.pts) { p.pts = v.pts.map(mp); p.closed = v.closed; } return p; }
+ if (isPt(v)) return mp(v);
+ if (Array.isArray(v)) return v.map(map);
+ if (v && typeof v === 'object' && 'x' in v && 'y' in v) { const q = mp([v.x, v.y]), o = { ...v, x: q[0], y: q[1] }; if ('w' in v) { o.w = v.w * sx; o.h = v.h * sy; } if ('r' in v) o.r = v.r * Math.sqrt(sx * sy); if ('rx' in v) { o.rx = v.rx * sx; o.ry = v.ry * sy; } return o; }
+ if (v && typeof v === 'object' && v.constructor === Object) { const o = {}; for (const k in v) o[k] = map(v[k]); return o; }
+ return v;
+ };
+ const out = {};
+ for (const k in O) {
+ if (typeof O[k] === 'function') { const f = O[k]; out[k] = (...a) => mp(f(...a)); }
+ else if (k === 'rigid' || k === 'tilt' || k === 'blink' || k === 'tailW' || k === 'eyeR' || k === 'headR') out[k] = O[k];
+ else out[k] = map(O[k]);
+ }
+ out.stretch = { sx, sy, anchor, matrix: m };
+ return out;
+};
+
+// ---------------- 少女(v2:按设定稿逐部位量点,Catmull-Rom 平滑) ----------------
+// 关键点取自 生图/plates/09_postimp.png(AI 设定稿)叠网格读数;参考姿势 = 端杯在嘴边。
+R.smooth = (pts, closed = true, k = 0.5) => { // Catmull-Rom → 三次贝塞尔
+ const p = new Path2D(), n = pts.length; if (n < 2) return p;
+ const P_ = i => pts[closed ? (i + n) % n : Math.max(0, Math.min(n - 1, i))];
+ p.moveTo(...pts[0]);
+ for (let i = 0; i < (closed ? n : n - 1); i++) {
+ const p0 = P_(i - 1), p1 = P_(i), p2 = P_(i + 1), p3 = P_(i + 2);
+ p.bezierCurveTo(p1[0] + (p2[0] - p0[0]) * k / 3, p1[1] + (p2[1] - p0[1]) * k / 3, p2[0] - (p3[0] - p1[0]) * k / 3, p2[1] - (p3[1] - p1[1]) * k / 3, p2[0], p2[1]);
+ }
+ if (closed) p.closePath(); return p;
+};
+R.taper = (A, B, wA, wB, bulge = 0) => { // 锥形肢体(袖子/手臂),bulge 让中段鼓起
+ const a = Math.atan2(B[1] - A[1], B[0] - A[0]), nx = Math.cos(a + Math.PI / 2), ny = Math.sin(a + Math.PI / 2);
+ const M = [(A[0] + B[0]) / 2, (A[1] + B[1]) / 2], wM = (wA + wB) / 2 + bulge;
+ return R.smooth([[A[0] + nx * wA / 2, A[1] + ny * wA / 2], [M[0] + nx * wM / 2, M[1] + ny * wM / 2], [B[0] + nx * wB / 2, B[1] + ny * wB / 2],
+ [B[0] + Math.cos(a) * wB * 0.35, B[1] + Math.sin(a) * wB * 0.35], [B[0] - nx * wB / 2, B[1] - ny * wB / 2], [M[0] - nx * wM / 2, M[1] - ny * wM / 2], [A[0] - nx * wA / 2, A[1] - ny * wA / 2], [A[0] - Math.cos(a) * wA * 0.3, A[1] - Math.sin(a) * wA * 0.3]]);
+};
+// opt: { cup:0..1, sip, dx, dy, s, hat:'straw'|null, hair:'bun'|'long'|'braid'|'down', breathe,
+// sx, sy, anchor:[x,y](非等比拉长,默认以脚底 (1240,932) 为轴,见 R.stretch) }
+// 返回 G:每个部件一个 Path2D(RIG.smooth 生成的带 .pts 点列,可沿轮廓逐点改线宽/重剪);G.A 锚点;
+// G.pivots 关节枢轴+G.rigid 刚体分组(皮影/剪纸偶:每组只绕自己的枢轴转,见文件末 R.rigidPose)。
+R.girl = (opt = {}) => {
+ const { cup = 0, sip = 0, dx = 0, dy = 0, s = 1, breathe = 0 } = opt;
+ const T = (x, y) => [dx + 1300 + (x - 1300) * s, dy + 620 + (y - 620) * s];
+ const neck = T(1300, 425), tilt = -0.07 * cup - sip * 0.6;
+ const HP = (x, y) => { const p = T(x, y), c = Math.cos(tilt), si = Math.sin(tilt), X = p[0] - neck[0], Y = p[1] - neck[1]; return [neck[0] + X * c - Y * si, neck[1] + X * si + Y * c]; };
+ const TB = (x, y) => T(x, y + (y < 600 ? breathe * 150 * (600 - y) / 170 : 0)); // 呼吸只动上身
+ const sm = (f, pts, closed = true) => { const q = pts.map(p => f(...p)); return Object.assign(R.smooth(q, closed), { pts: q, closed }); }; // Path2D 带点列 .pts
+ const G = {};
+ // —— 头部组 ——
+ G.hairBack = sm(HP, [[1262, 312], [1300, 290], [1350, 293], [1392, 322], [1408, 368], [1398, 420], [1372, 448], [1346, 442], [1332, 412], [1318, 380], [1292, 340]]);
+ const style = opt.hair || 'bun';
+ G.bun = style === 'bun' ? (() => { const c0 = HP(1390, 372), p = new Path2D(); p.arc(c0[0], c0[1], 31 * s, 0, Math.PI * 2); return p; })() : null;
+ G.bunSpiral = HP(1390, 372);
+ G.hairDown = (style === 'long' || style === 'down') ? sm(HP, [[1340, 420], [1385, 430], [1418, 480], [1425, 560], [1405, 600], [1385, 540], [1360, 470]]) : null;
+ G.braid = style === 'braid' ? [0, 1, 2, 3, 4].map(k => HP(1392 - k * 2, 440 + k * 30)) : null;
+ G.face = sm(HP, [[1258, 318], [1252, 335], [1250, 352], [1242, 366], [1249, 373], [1256, 378], [1253, 386], [1259, 391], [1255, 398], [1263, 406], [1276, 413], [1296, 412], [1316, 398], [1326, 370], [1320, 335], [1296, 314]]);
+ G.neck = sm(T, [[1286, 400], [1314, 400], [1324, 445], [1290, 448]]);
+ G.bangs = sm(HP, [[1248, 322], [1260, 300], [1290, 293], [1322, 304], [1338, 330], [1332, 364], [1320, 346], [1302, 328], [1282, 322], [1266, 330], [1257, 346]]);
+ G.locks = [sm(HP, [[1318, 345], [1308, 372], [1314, 398], [1306, 420], [1314, 440]], false), sm(HP, [[1326, 352], [1322, 380], [1330, 405], [1324, 430]], false)];
+ G.hairLines = [sm(HP, [[1262, 312], [1300, 300], [1345, 312], [1380, 340]], false), sm(HP, [[1275, 322], [1315, 318], [1350, 338], [1372, 372]], false), sm(HP, [[1300, 330], [1340, 352], [1360, 395]], false)];
+ const ec = HP(1268, 350); G.eye = { x: ec[0], y: ec[1], r: 5.5 * s };
+ G.lid = sm(HP, [[1259, 348], [1268, 343], [1279, 348]], false);
+ G.lashes = [[HP(1259, 348), HP(1254, 343)], [HP(1262, 345), HP(1258, 339)]];
+ G.brow = sm(HP, [[1257, 335], [1268, 330], [1281, 334]], false);
+ G.nostril = HP(1250, 382);
+ G.lips = [HP(1252, 389), HP(1259, 390), HP(1254, 397)];
+ G.cheek = HP(1283, 380); G.ear = HP(1318, 372);
+ if (opt.hat === 'straw' || opt.hat === 'bonnet') {
+ G.brim = (() => { const c0 = HP(1326, 300), p = new Path2D(); p.ellipse(c0[0], c0[1], 130 * s, 25 * s, tilt + 0.19, 0, Math.PI * 2); return p; })();
+ G.crown = (() => { const c0 = HP(1336, 290), p = new Path2D(); p.ellipse(c0[0], c0[1], 62 * s, 44 * s, tilt + 0.14, Math.PI, 0); p.closePath(); return p; })();
+ G.band = sm(HP, [[1276, 283], [1336, 296], [1398, 306], [1396, 318], [1336, 309], [1276, 296]]);
+ G.bow = HP(1404, 318);
+ }
+ // —— 身体 ——
+ G.torso = sm(TB, [[1290, 432], [1318, 428], [1350, 434], [1380, 446], [1404, 482], [1416, 542], [1424, 600], [1412, 622], [1300, 618], [1285, 560], [1282, 500], [1286, 460]]);
+ G.bib = sm(TB, [[1291, 438], [1313, 436], [1307, 500], [1303, 560], [1305, 612], [1286, 612], [1283, 520]]);
+ G.skirt = sm(T, [[1300, 605], [1420, 612], [1446, 650], [1452, 722], [1440, 762], [1362, 772], [1342, 802], [1352, 926], [1220, 932], [1104, 926], [1118, 820], [1150, 722], [1190, 656], [1242, 630]]);
+ G.apronSkirt = sm(T, [[1300, 612], [1352, 642], [1332, 702], [1316, 822], [1200, 824], [1192, 702], [1200, 656], [1252, 630]]);
+ G.folds = [sm(T, [[1230, 670], [1222, 760], [1226, 815]], false), sm(T, [[1268, 668], [1262, 760], [1268, 818]], false), sm(T, [[1160, 760], [1150, 860], [1146, 920]], false), sm(T, [[1300, 820], [1306, 880], [1300, 925]], false)];
+ G.apronBow = [T(1428, 616), T(1450, 600), T(1452, 634), T(1440, 690)];
+ G.shoe = sm(T, [[1098, 918], [1120, 910], [1146, 914], [1150, 928], [1100, 930]]);
+ // 远侧手臂:搭在桌上(在躯干后面画)
+ G.farSleeve = sm(TB, [[1332, 468], [1364, 520], [1346, 600], [1250, 632], [1212, 626], [1220, 604], [1300, 584], [1318, 520]]);
+ G.farCuff = sm(T, [[1222, 604], [1236, 604], [1238, 630], [1220, 632]]);
+ G.farHand = sm(T, [[1218, 606], [1180, 604], [1150, 609], [1146, 618], [1180, 626], [1218, 630]]);
+ // 近侧手臂:IK,杯子从桌面(1196,598)举到嘴边(1226,380)
+ const S = TB(1352, 456);
+ const cupTable = T(1190, 596), cupMouth = HP(1226, 376);
+ const cp = [lerp(cupTable[0], cupMouth[0], cup), lerp(cupTable[1], cupMouth[1], cup)];
+ const handT = [cp[0] + 28 * s, cp[1] + 16 * s];
+ const { E, H } = R.ik2(S, handT, 165 * s, 122 * s, -1);
+ G.upperArm = R.taper(S, E, 54 * s, 40 * s, 10 * s);
+ const W_ = [lerp(E[0], H[0], 0.82), lerp(E[1], H[1], 0.82)];
+ G.foreArm = R.taper(E, W_, 40 * s, 30 * s, 2 * s);
+ G.cuff = R.taper([lerp(E[0], H[0], 0.76), lerp(E[1], H[1], 0.76)], W_, 32 * s, 31 * s);
+ const fa = Math.atan2(H[1] - E[1], H[0] - E[0]);
+ G.hand = (() => { const p = new Path2D(), r = 15 * s; p.ellipse(H[0], H[1], r * 1.15, r, fa, 0, Math.PI * 2); return p; })();
+ G.thumb = [H[0] + Math.cos(fa - 1.2) * 14 * s, H[1] + Math.sin(fa - 1.2) * 14 * s];
+ G.cup = { x: cp[0], y: cp[1] - 18 * s, w: 44 * s, h: 38 * s, tilt: -0.45 * cup };
+ G.hipSeat = T(1400, 700);
+ // 锚点:给时代代码加服饰/头饰/光环用(都已跟随缩放、头部点跟随头部倾斜)
+ G.A = { headTop: HP(1320, 288), headC: HP(1318, 360), forehead: HP(1262, 318), nape: HP(1360, 420), ear: HP(1318, 372), chin: HP(1270, 410),
+ neck: T(1305, 435), chest: TB(1300, 500), shoulder: S, back: TB(1410, 520), waist: T(1350, 612), lap: T(1250, 640), knee: T(1190, 660), hemL: T(1104, 926), hemR: T(1352, 926), elbow: E, hand: H };
+ G.tilt = tilt;
+ G.HP = HP; G.T = T; // 头部局部坐标(随仰头旋转)与身体坐标,加头饰/服饰用
+ G.A.wrist = W_; G.A.cupBottom = [G.cup.x, G.cup.y + G.cup.h];
+ G.box = [T(1100, 240), T(1460, 935)];
+ // 刚体部件+枢轴:head 组绕 neck 转(仰头就是这么转的),upperArm 绕 shoulder,foreArm/cuff 绕 elbow,hand 绕 wrist
+ G.pivots = { neck, shoulder: S, elbow: E, wrist: W_, hip: T(1400, 700), farShoulder: TB(1332, 468), knee: G.A.knee };
+ G.rigid = { head: ['hairBack', 'bun', 'hairDown', 'braid', 'face', 'bangs', 'locks', 'hairLines', 'lid', 'brow', 'brim', 'crown', 'band'], neck: ['neck'],
+ torso: ['torso', 'bib'], skirt: ['skirt', 'apronSkirt', 'folds', 'shoe'], farArm: ['farSleeve', 'farCuff', 'farHand'],
+ upperArm: ['upperArm'], foreArm: ['foreArm', 'cuff'], hand: ['hand'] };
+ G.rigidPivot = { head: 'neck', neck: 'neck', torso: 'hip', skirt: 'hip', farArm: 'farShoulder', upperArm: 'shoulder', foreArm: 'elbow', hand: 'wrist' };
+ if (opt.sx || opt.sy) return R.stretch(G, opt.sx || 1, opt.sy || 1, opt.anchor || [1240, 932]);
+ return G;
+};
+// ---------- 分层绘制的钩子(迁移测试 C 的 X.girl/X.cat 思路,正式并入) ----------
+// pal.before = {部件名: (c, G, pal) => {}}、pal.after = {部件名: fn}:在任意部件前/后插画(领子、裙撑、刺绣、发饰、项圈……)。
+// pal.hooks = {别名: fn}:常用插槽的简写,别名表见 GIRL_SLOTS / CAT_SLOTS。
+// 钩子画的东西和部件一样参与遮挡:在 mode:'line'(visibleLines)下也只露出看得见的线——钩子里描线请用 pal.line,别写死颜色。
+const GIRL_SLOTS = { back: ['before', 'farSleeve'], skirt: ['after', 'skirt'], torso: ['after', 'torso'], head: ['after', 'bangs'], face: ['after', 'features'], arm: ['after', 'cuff'], end: ['after', 'thumb'] };
+const CAT_SLOTS = { back: ['before', 'tail'], body: ['after', 'white'], head: ['after', 'stripes'], end: ['after', 'whiskers'] };
+const hooker = (c, O, pal, slots) => {
+ const B = { ...(pal.before || {}) }, A = { ...(pal.after || {}) };
+ if (pal.hooks) for (const k in pal.hooks) { const sl = slots[k]; if (!sl) throw new Error(`RIG 钩子别名不存在:${k}(可用 ${Object.keys(slots).join('/')},或用 before/after:{部件名})`); (sl[0] === 'before' ? B : A)[sl[1]] = pal.hooks[k]; }
+ return (name, fn) => { if (B[name]) B[name](c, O, pal); fn(); if (A[name]) A[name](c, O, pal); };
+};
+// 少女部件画序(远→近)。自己逐部件上色时照这个顺序画,遮挡就是对的。
+R.GIRL_ORDER = ['farSleeve', 'farHand', 'farCuff', 'hairDown', 'skirt', 'apronSkirt', 'folds', 'shoe', 'torso', 'bib', 'apronBow', 'neck', 'hairBack', 'bun', 'bunSpiral', 'face', 'cheek', 'ear',
+ 'bangs', 'hairLines', 'locks', 'features', 'hat', 'upperArm', 'foreArm', 'cuff', 'hand', 'cup', 'thumb'];
+// 端杯手与杯子的前后:杯子在手前面(侧身朝左时杯子靠观众这侧)
+// pal 颜色:dress(skirt/torso/farSleeve 可单独覆盖)sleeve skin hair hairLine cuff apron fold shoe iris lip cheek browC hat hatBand cupBody cupRim
+// pal 线:line lw lwOf:{部件名:线宽} mode:'both'|'fill'|'line'(line 内部走 visibleLines)lineKey
+// pal 分层:before/after/hooks(见上);paint(c, path, color, name) 接管每个部件的「填+描」(赛璐珞、网点、剪纸边……);
+// features(c, G, pal) 接管五官;cup(c, G, pal) 接管杯子;blink 闭眼;locks:false 不画鬓角发绺。
+R.drawGirl = (c, G, pal) => {
+ if (pal.mode === 'line') { // 线稿模式:内部走 visibleLines,被遮住的轮廓(远侧袖子、帽檐后半圈、被手臂挡住的躯干线)不会画穿
+ const [a, b] = G.box, box = [a[0] - 60, a[1] - 90, b[0] + 60, b[1] + 30];
+ c.drawImage(R.visibleLines(pal.lineKey || 'girl', (g, lc) => R.drawGirl(g, G, { ...pal, mode: 'both', line: lc }), pal.line || '#1b1d3a', box), 0, 0); return;
+ }
+ const L = pal.line || '#1b1d3a', lw = pal.lw ?? 3, mode = pal.mode || 'both';
+ const step = hooker(c, G, pal, GIRL_SLOTS);
+ const LWof = (name, d = lw) => pal.lwOf && pal.lwOf[name] != null ? pal.lwOf[name] : d;
+ const F = (name, p, col, line = true) => step(name, () => {
+ if (!p || !col) return;
+ if (pal.paint) { pal.paint(c, p, col, name); return; }
+ if (mode !== 'line') { c.fillStyle = col; c.fill(p); }
+ const w = LWof(name); if (w && line && mode !== 'fill') { c.strokeStyle = L; c.lineWidth = w; c.stroke(p); }
+ });
+ const S_ = (p, col, w) => { if (!p) return; c.strokeStyle = col; c.lineWidth = w; c.stroke(p); };
+ c.save(); c.lineJoin = 'round'; c.lineCap = 'round';
+ F('farSleeve', G.farSleeve, pal.farSleeve || pal.dress); F('farHand', G.farHand, pal.skin); F('farCuff', G.farCuff, pal.cuff || pal.apron || '#f3eee2');
+ F('hairDown', G.hairDown, pal.hair);
+ F('skirt', G.skirt, pal.skirt || pal.dress); if (pal.apron) F('apronSkirt', G.apronSkirt, pal.apron);
+ step('folds', () => { if (pal.fold) G.folds.forEach(f => S_(f, pal.fold, 2.5)); });
+ F('shoe', G.shoe, pal.shoe || '#4a2c1a');
+ F('torso', G.torso, pal.torso || pal.dress); if (pal.apron) F('bib', G.bib, pal.apron);
+ step('apronBow', () => { if (!pal.apron) return; c.strokeStyle = L; c.lineWidth = lw; c.fillStyle = pal.apron; const b = G.apronBow; c.beginPath(); c.ellipse(b[0][0] + 10, b[0][1] - 6, 16, 10, -0.5, 0, Math.PI * 2); c.fill(); c.stroke(); c.beginPath(); c.moveTo(...b[0]); c.lineTo(...b[3]); c.lineWidth = 9; c.strokeStyle = pal.apron; c.stroke(); });
+ F('neck', G.neck, pal.skin);
+ F('hairBack', G.hairBack, pal.hair); F('bun', G.bun, pal.hair);
+ step('bunSpiral', () => { if (G.bun && pal.hairLine) { c.strokeStyle = pal.hairLine; c.lineWidth = 2.5; c.beginPath(); for (let a = 0; a < 9; a += 0.2) { const r = 4 + a * 2.6; const x = G.bunSpiral[0] + Math.cos(a) * r, y = G.bunSpiral[1] + Math.sin(a) * r; a ? c.lineTo(x, y) : c.moveTo(x, y); } c.stroke(); } });
+ F('face', G.face, pal.skin);
+ step('cheek', () => { c.save(); c.clip(G.face); if (pal.cheek) { c.fillStyle = pal.cheek; c.beginPath(); c.arc(G.cheek[0], G.cheek[1], 13, 0, Math.PI * 2); c.fill(); } c.restore(); });
+ step('ear', () => { if (G.ear && pal.skin) { c.fillStyle = pal.skin; c.beginPath(); c.ellipse(G.ear[0], G.ear[1], 8, 12, 0.2, 0, Math.PI * 2); c.fill(); const w = LWof('ear', lw * 0.7); if (w) { c.strokeStyle = L; c.lineWidth = w; c.stroke(); } } });
+ F('bangs', G.bangs, pal.hair);
+ step('hairLines', () => { if (pal.hairLine) { G.hairLines.forEach(h => S_(h, pal.hairLine, 2.2)); } });
+ step('locks', () => { if (pal.locks !== false) G.locks.forEach(h => { S_(h, L, 9); S_(h, pal.hair, 6); }); });
+ // 五官
+ step('features', () => {
+ if (pal.features) { pal.features(c, G, pal); return; }
+ if (pal.blink) { c.strokeStyle = L; c.lineWidth = 2.8; c.beginPath(); c.arc(G.eye.x, G.eye.y - 1, 7, 0.25, Math.PI - 0.25); c.stroke(); }
+ else {
+ S_(G.lid, L, 2.6); G.lashes.forEach(l => { c.beginPath(); c.moveTo(...l[0]); c.lineTo(...l[1]); c.strokeStyle = L; c.lineWidth = 2; c.stroke(); });
+ c.fillStyle = pal.iris || '#2b4d8a'; c.beginPath(); c.ellipse(G.eye.x - 1, G.eye.y + 1.5, G.eye.r * 0.8, G.eye.r, 0, 0, Math.PI * 2); c.fill();
+ c.fillStyle = '#fff'; c.beginPath(); c.arc(G.eye.x - 2.5, G.eye.y - 0.5, 1.6, 0, Math.PI * 2); c.fill();
+ }
+ S_(G.brow, pal.browC || pal.hairLine || L, 2.4);
+ c.fillStyle = pal.lip || '#cf5a58'; c.beginPath(); c.moveTo(...G.lips[0]); c.lineTo(...G.lips[1]); c.lineTo(...G.lips[2]); c.closePath(); c.fill();
+ });
+ // 帽
+ step('hat', () => { if (G.brim && pal.hat) { F('brim', G.brim, pal.hat); F('crown', G.crown, pal.hat); F('band', G.band, pal.hatBand || '#2d4fa0', false); c.fillStyle = pal.hatBand || '#2d4fa0'; c.beginPath(); c.ellipse(G.bow[0], G.bow[1], 14, 9, 0.6, 0, Math.PI * 2); c.fill(); } });
+ // 近侧手臂、杯、手
+ F('upperArm', G.upperArm, pal.sleeve || pal.dress); F('foreArm', G.foreArm, pal.sleeve || pal.dress); F('cuff', G.cuff, pal.cuff || pal.apron || '#f3eee2');
+ F('hand', G.hand, pal.skin);
+ step('cup', () => { if (pal.cup) pal.cup(c, G, pal); else R.drawCup(c, G.cup, { body: pal.cupBody || '#2a4fa8', rim: pal.cupRim || '#5a3216', line: L, lw: lw * 0.8, hw: 7 }); });
+ step('thumb', () => { c.fillStyle = pal.skin; c.beginPath(); c.arc(G.thumb[0], G.thumb[1], 7, 0, Math.PI * 2); c.fill(); const w = LWof('thumb', lw * 0.7); if (w) { c.strokeStyle = L; c.lineWidth = w; c.stroke(); } });
+ c.restore();
+};
+
+// 只画五官(迁移测试 C 的 X.features):「先渲染器、后补五官」的画法用——平涂进笔触/点彩后五官会糊,最后单独补一遍。
+// s: { line, featureW(线宽倍数), iris, brow, lip, cheek, blink }
+R.drawFeatures = (c, G, s = {}) => {
+ const L = s.line || '#111', k = s.featureW || 1;
+ c.save(); c.lineCap = 'round'; c.lineJoin = 'round';
+ if (s.blink) { c.strokeStyle = L; c.lineWidth = 3 * k; c.beginPath(); c.arc(G.eye.x, G.eye.y - 1, 7, 0.25, Math.PI - 0.25); c.stroke(); }
+ else {
+ c.strokeStyle = L; c.lineWidth = 2.8 * k; c.stroke(G.lid);
+ G.lashes.forEach(l => { c.beginPath(); c.moveTo(...l[0]); c.lineTo(...l[1]); c.lineWidth = 2 * k; c.stroke(); });
+ c.fillStyle = s.iris || '#2b4d8a'; c.beginPath(); c.ellipse(G.eye.x - 1, G.eye.y + 1.5, G.eye.r * 0.8, G.eye.r, 0, 0, Math.PI * 2); c.fill();
+ c.fillStyle = '#fff'; c.beginPath(); c.arc(G.eye.x - 2.5, G.eye.y - 0.5, 1.6, 0, Math.PI * 2); c.fill();
+ }
+ c.strokeStyle = s.brow || L; c.lineWidth = 2.6 * k; c.stroke(G.brow);
+ c.fillStyle = s.lip || '#cf5a58'; c.beginPath(); c.moveTo(...G.lips[0]); c.lineTo(...G.lips[1]); c.lineTo(...G.lips[2]); c.closePath(); c.fill();
+ if (s.cheek) { c.save(); c.clip(G.face); c.fillStyle = s.cheek; c.beginPath(); c.arc(G.cheek[0], G.cheek[1], 13, 0, Math.PI * 2); c.fill(); c.restore(); }
+ c.restore();
+};
+
+// 画杯子(通用):c.translate 到杯口中心再画,style: {body, rim, line, handle:true}
+R.drawCup = (c, cup, st = {}) => {
+ c.save(); c.translate(cup.x, cup.y); c.rotate(cup.tilt || 0);
+ const w = cup.w, h = cup.h;
+ c.beginPath(); c.moveTo(-w / 2, 0); c.lineTo(-w * 0.42, h); c.quadraticCurveTo(0, h * 1.12, w * 0.42, h); c.lineTo(w / 2, 0); c.closePath();
+ c.fillStyle = st.body || '#2a4fa8'; c.fill();
+ if (st.line) { c.strokeStyle = st.line; c.lineWidth = st.lw || 3; c.stroke(); }
+ if (st.handle !== false) { c.beginPath(); c.arc(w * 0.55, h * 0.4, h * 0.26, -1.2, 1.4); c.strokeStyle = st.body || '#2a4fa8'; c.lineWidth = st.hw || 7; c.stroke(); }
+ c.beginPath(); c.ellipse(0, 0, w / 2, h * 0.14, 0, 0, Math.PI * 2); c.fillStyle = st.rim || '#6b3f1f'; c.fill();
+ if (st.line) { c.strokeStyle = st.line; c.lineWidth = st.lw || 3; c.stroke(); }
+ c.restore();
+};
+
+// ---------------- 猫(橘白,朝右坐) ----------------
+// opt: { tail(弧度), blink, ear, breathe, dx, dy, s, look, sx, sy, anchor }
+// 返回 K:K.body 已平滑(Catmull-Rom,带 .pts;旧折线在 K.bodyPoly);白区拆成 K.chest / K.muzzle / K.paws,
+// K.white = 三者合在一条 Path2D(兼容旧代码),K.whitePts 给点列/椭圆参数;K.pivots / K.rigid 同少女。
+R.cat = (opt = {}) => {
+ const { tail = 0, blink = 0, breathe = 0, dx = 0, dy = 0, s = 1, look = 0 } = opt;
+ const T = (x, y) => [dx + 540 + (x - 540) * s, dy + 905 + (y - 905) * s];
+ const P = {};
+ // 身体:梨形
+ const body = new Path2D();
+ P.bodyPts = [[470, 900], [430, 860], [425, 790], [450, 720], [500, 680], [570, 668], [625, 690], [650, 750], [660, 830], [650, 900]].map(p => T(p[0], p[1] - (p[1] < 800 ? breathe * 300 : 0)));
+ P.bodyPts.forEach((p, i) => i ? body.lineTo(...p) : body.moveTo(...p)); body.closePath(); P.bodyPoly = body;
+ P.body = Object.assign(R.smooth(P.bodyPts), { pts: P.bodyPts, closed: true }); // 卡通/赛璐珞/不描线的画法里折线身体会露直边(迁移测试 B、D)
+ // 头
+ const hc = T(600 + look * 6, 625); P.headC = hc; P.headR = 64 * s;
+ const head = new Path2D(); head.ellipse(hc[0], hc[1], 66 * s, 58 * s, 0, 0, Math.PI * 2);
+ // 耳朵
+ const ear = (bx, by, tx, ty, ex, ey) => { head.moveTo(...T(bx, by)); head.lineTo(...T(tx, ty)); head.lineTo(...T(ex, ey)); head.closePath(); };
+ ear(555, 590, 560, 535, 595, 575); ear(615, 575, 652, 540, 650, 600);
+ P.head = head;
+ P.earInner = [[T(563, 585), T(565, 550), T(588, 578)], [T(622, 578), T(646, 553), T(644, 596)]];
+ // 白色部分:口鼻、胸口、爪子(橘白猫的标志)。胸口用平滑闭合曲线:旧版直线多边形在不描线的画法里像一块「盾牌」(迁移测试 B)
+ const mz = T(628, 650), chestPts = [[560, 700], [610, 690], [640, 740], [630, 820], [590, 860], [560, 800]].map(p => T(...p));
+ P.chest = Object.assign(R.smooth(chestPts), { pts: chestPts, closed: true });
+ P.muzzle = new Path2D(); P.muzzle.ellipse(mz[0], mz[1], 34 * s, 24 * s, 0, 0, Math.PI * 2);
+ P.paws = new Path2D(); const pawC = [585, 635].map(x => T(x, 893));
+ pawC.forEach(c0 => { P.paws.moveTo(c0[0] + 22 * s, c0[1]); P.paws.ellipse(c0[0], c0[1], 22 * s, 13 * s, 0, 0, Math.PI * 2); });
+ const white = new Path2D(); white.addPath(P.muzzle); white.addPath(P.chest); white.addPath(P.paws);
+ P.white = white;
+ P.whitePts = { chest: chestPts, muzzle: { x: mz[0], y: mz[1], rx: 34 * s, ry: 24 * s }, paws: pawC.map(c0 => ({ x: c0[0], y: c0[1], rx: 22 * s, ry: 13 * s })) };
+ // 前腿
+ P.legs = [R.limb(T(588, 740), T(584, 888), 34 * s, 28 * s), R.limb(T(630, 742), T(634, 888), 34 * s, 28 * s)];
+ // 眼睛(朝右看)、鼻、嘴、胡须
+ P.eyes = [{ x: T(612, 615)[0], y: T(612, 615)[1] }, { x: T(648, 612)[0], y: T(648, 612)[1] }]; P.eyeR = 9 * s; P.blink = blink;
+ P.nose = T(655, 640); P.mouth = [T(645, 655), T(655, 650), T(664, 655)];
+ P.whiskers = [[T(660, 645), T(712, 632)], [T(660, 650), T(715, 655)], [T(598, 648), T(552, 640)]];
+ // 虎斑条纹(头顶、背)
+ P.stripes = [[T(585, 572), T(590, 595)], [T(605, 568), T(607, 592)], [T(625, 572), T(622, 594)],
+ [T(452, 740), T(490, 750)], [T(440, 780), T(482, 790)], [T(436, 822), T(478, 830)], [T(500, 690), T(520, 715)]];
+ // 尾巴:从臀部绕到身前,末端随 tail 摆
+ const t0 = T(455, 885), tip = T(380 + Math.sin(tail) * 40, 830 - Math.cos(tail) * 30);
+ P.tailPts = P_bez(t0, T(360, 900), T(330, 860 + tail * 40), tip);
+ P.tail = (() => { const p = new Path2D(); const pts = P.tailPts; pts.forEach((q, i) => i ? p.lineTo(...q) : p.moveTo(...q)); return p; })();
+ P.tailW = 26 * s;
+ P.box = [T(390, 540), T(700, 905)];
+ P.pivots = { neck: T(588 + look * 6, 680), tailBase: t0, shoulder: T(600, 735), hip: T(470, 870) };
+ P.rigid = { head: ['head', 'earInner', 'eyes', 'nose', 'mouth', 'whiskers', 'muzzle'], body: ['body', 'chest', 'stripes'], legs: ['legs', 'paws'], tail: ['tail'] };
+ P.rigidPivot = { head: 'neck', body: 'hip', legs: 'shoulder', tail: 'tailBase' };
+ if (opt.sx || opt.sy) return R.stretch(P, opt.sx || 1, opt.sy || 1, opt.anchor || [540, 905]);
+ return P;
+};
+function P_bez(p0, p1, p2, p3, n = 20) { const o = []; for (let i = 0; i <= n; i++) { const t = i / n, u = 1 - t; o.push([u * u * u * p0[0] + 3 * u * u * t * p1[0] + 3 * u * t * t * p2[0] + t * t * t * p3[0], u * u * u * p0[1] + 3 * u * u * t * p1[1] + 3 * u * t * t * p2[1] + t * t * t * p3[1]]); } return o; }
+
+// 猫只描线(给「先渲染器、后补线」的时代用)
+R.drawCatLines = (c, K, pal) => {
+ const L = pal.line || '#1b1d3a', lw = pal.lw ?? 3; c.save(); c.lineJoin = 'round'; c.lineCap = 'round'; c.strokeStyle = L; c.lineWidth = lw;
+ c.stroke(K.body); c.stroke(K.head); K.legs.forEach(l => c.stroke(l));
+ K.eyes.forEach(e => { if (K.blink) { c.beginPath(); c.arc(e.x, e.y, K.eyeR, 0.2, Math.PI - 0.2); c.stroke(); } else { c.fillStyle = pal.eye || '#6aa84f'; c.beginPath(); c.arc(e.x, e.y, K.eyeR, 0, Math.PI * 2); c.fill(); c.stroke(); c.fillStyle = L; c.beginPath(); c.ellipse(e.x + 2, e.y, K.eyeR * 0.35, K.eyeR * 0.8, 0, 0, Math.PI * 2); c.fill(); } });
+ c.fillStyle = pal.noseC || '#d8746a'; c.beginPath(); c.arc(K.nose[0], K.nose[1], 6, 0, Math.PI * 2); c.fill();
+ c.lineWidth = 2.5; c.beginPath(); c.moveTo(...K.mouth[0]); c.quadraticCurveTo(...K.mouth[1], ...K.mouth[2]); c.stroke();
+ c.lineWidth = 1.5; K.whiskers.forEach(w => { c.beginPath(); c.moveTo(...w[0]); c.lineTo(...w[1]); c.stroke(); });
+ c.restore();
+};
+// 只取「看得见的线」:同一个完整画法(填色+描线,按部件顺序所以遮挡正确)画两遍,一遍用真线色、一遍用白色当哨兵;
+// 两遍不同的像素 = 没被遮住的线(含用线色画的眼睑、眉、胡须、嘴)。取第一遍的颜色输出。
+// 用于「平涂→风格肌理→补线」:直接 mode:'line' 叠最上层会把被遮住的轮廓(远侧袖子、帽檐后半圈)画穿。
+// drawWith(g, lineColor) 由调用方提供,box=[x0,y0,x1,y1] 限定计算范围。
+R._lc = {};
+R.visibleLines = (key, drawWith, lineColor, box, thresh = 90) => {
+ const [x0, y0, x1, y1] = box.map(Math.round), w = x1 - x0, h = y1 - y0;
+ const mk = n => R._lc[key + n] || (R._lc[key + n] = (() => { const c = document.createElement('canvas'); c.width = 1920; c.height = 1080; return c; })());
+ const A = mk('a'), B = mk('b'), O = mk('o');
+ const ga = A.getContext('2d', { willReadFrequently: true }), gb = B.getContext('2d', { willReadFrequently: true }), go = O.getContext('2d');
+ ga.clearRect(0, 0, 1920, 1080); gb.clearRect(0, 0, 1920, 1080); go.clearRect(0, 0, 1920, 1080);
+ drawWith(ga, lineColor); drawWith(gb, '#ffffff');
+ const da = ga.getImageData(x0, y0, w, h), db = gb.getImageData(x0, y0, w, h).data, d = da.data;
+ for (let i = 0; i < d.length; i += 4) {
+ const diff = Math.abs(d[i] - db[i]) + Math.abs(d[i + 1] - db[i + 1]) + Math.abs(d[i + 2] - db[i + 2]);
+ if (diff < thresh) d[i + 3] = 0; else d[i + 3] = Math.min(255, d[i + 3] * Math.min(1, diff / 300));
+ }
+ go.putImageData(da, x0, y0); return O;
+};
+// 一站式默认画法见上方 R.drawGirl;猫:
+// pal:orange white stripe stripeW eye earInner noseC(=nose) whisker line lw lwOf mode('line' 走 visibleLines) lineKey
+// 分层:before/after/hooks(别名 back/body/head/end);paint(c, path, color, name, stroke) 接管部件填描;
+// face(c, K, pal) 接管眼鼻嘴须;tail(c, K, pal) 接管尾巴;noStripes 不画条纹。
+// 部件画序:tail body legs white head muzzleWhite earInner stripes eyes nose mouth whiskers
+R.drawCat = (c, K, pal) => {
+ const L = pal.line || '#1b1d3a', lw = pal.lw ?? 3;
+ if (pal.mode === 'line') { const [a, b] = K.box, box = [a[0] - 60, a[1] - 40, b[0] + 70, b[1] + 30];
+ c.drawImage(R.visibleLines(pal.lineKey || 'cat', (g, lc) => R.drawCat(g, K, { ...pal, mode: 'both', line: lc, whisker: lc }), pal.line || '#1b1d3a', box), 0, 0); return; }
+ const step = hooker(c, K, pal, CAT_SLOTS), O = pal.orange || '#e8913a', Wt = pal.white || '#fff6ea';
+ const LWof = name => pal.lwOf && pal.lwOf[name] != null ? pal.lwOf[name] : lw;
+ const F = (name, p, col, stroke = true) => { if (pal.paint) { pal.paint(c, p, col, name, stroke); return; } c.fillStyle = col; c.fill(p); const w = LWof(name); if (w && stroke) { c.strokeStyle = L; c.lineWidth = w; c.stroke(p); } };
+ c.save(); c.lineJoin = 'round'; c.lineCap = 'round';
+ // 尾巴
+ step('tail', () => { if (pal.tail) { pal.tail(c, K, pal); return; }
+ c.strokeStyle = L; c.lineWidth = K.tailW + lw * 2; c.stroke(K.tail); c.strokeStyle = O; c.lineWidth = K.tailW; c.stroke(K.tail);
+ const tip = K.tailPts[K.tailPts.length - 1]; c.fillStyle = Wt; c.beginPath(); c.arc(tip[0], tip[1], K.tailW / 2, 0, Math.PI * 2); c.fill(); });
+ // 身体、腿、头
+ step('body', () => F('body', K.body, O));
+ step('legs', () => K.legs.forEach(l => F('leg', l, Wt)));
+ step('white', () => F('white', K.white, Wt, false));
+ step('head', () => F('head', K.head, O));
+ step('muzzleWhite', () => { c.save(); c.clip(K.head); c.fillStyle = Wt; c.beginPath(); c.ellipse(K.nose[0] - 22, K.nose[1] + 12, 36, 26, 0, 0, Math.PI * 2); c.fill(); c.restore(); });
+ step('earInner', () => { c.fillStyle = pal.earInner || '#f2a7a0'; K.earInner.forEach(e => { c.beginPath(); e.forEach((p, i) => i ? c.lineTo(...p) : c.moveTo(...p)); c.fill(); }); });
+ // 条纹
+ step('stripes', () => { if (pal.noStripes) return; c.strokeStyle = pal.stripe || '#c0621a'; c.lineWidth = pal.stripeW || 7; K.stripes.forEach(s => { c.beginPath(); c.moveTo(...s[0]); c.lineTo(...s[1]); c.stroke(); }); });
+ if (pal.face) step('face', () => pal.face(c, K, pal));
+ else {
+ // 眼
+ step('eyes', () => K.eyes.forEach(e => { if (K.blink) { c.strokeStyle = L; c.lineWidth = 3; c.beginPath(); c.arc(e.x, e.y, K.eyeR, 0.2, Math.PI - 0.2); c.stroke(); }
+ else { c.fillStyle = pal.eye || '#6aa84f'; c.beginPath(); c.arc(e.x, e.y, K.eyeR, 0, Math.PI * 2); c.fill(); c.fillStyle = L; c.beginPath(); c.ellipse(e.x + 2, e.y, K.eyeR * 0.35, K.eyeR * 0.8, 0, 0, Math.PI * 2); c.fill(); } }));
+ step('nose', () => { c.fillStyle = pal.noseC || pal.nose || '#d8746a'; c.beginPath(); c.arc(K.nose[0], K.nose[1], 6, 0, Math.PI * 2); c.fill(); });
+ step('mouth', () => { c.strokeStyle = L; c.lineWidth = 2.5; c.beginPath(); c.moveTo(...K.mouth[0]); c.quadraticCurveTo(...K.mouth[1], ...K.mouth[2]); c.stroke(); });
+ step('whiskers', () => { c.lineWidth = 1.5; c.strokeStyle = pal.whisker || L; K.whiskers.forEach(w => { c.beginPath(); c.moveTo(...w[0]); c.lineTo(...w[1]); c.stroke(); }); });
+ }
+ c.restore();
+};
+// 刚体姿态(皮影、剪纸偶、提线木偶):把 rigid 分组里的部件绕各自枢轴旋转。angles = {组名: 弧度},
+// 返回新对象(Path2D 与点都转好),子组不自动跟随父组——需要链式时自己把父组的角度加到子组上(如 foreArm += upperArm)。
+R.rigidPose = (O, angles) => {
+ const out = { ...O };
+ for (const grp in angles) {
+ const a = angles[grp], piv = O.pivots[O.rigidPivot[grp]]; if (!a || !piv) continue;
+ const m = new DOMMatrix().translate(piv[0], piv[1]).rotate(a * 180 / Math.PI).translate(-piv[0], -piv[1]);
+ const mp = q => { const r = m.transformPoint(new DOMPoint(q[0], q[1])); return [r.x, r.y]; };
+ const map = v => { if (v instanceof Path2D) { const p = new Path2D(); p.addPath(v, m); if (v.pts) { p.pts = v.pts.map(mp); p.closed = v.closed; } return p; }
+ if (Array.isArray(v) && v.length === 2 && typeof v[0] === 'number') return mp(v); if (Array.isArray(v)) return v.map(map);
+ if (v && typeof v === 'object' && 'x' in v) { const q = mp([v.x, v.y]); return { ...v, x: q[0], y: q[1] }; } return v; };
+ O.rigid[grp].forEach(name => { if (out[name] != null) out[name] = map(out[name]); });
+ }
+ return out;
+};
+})();
diff --git a/scripts/engine/lib/rig_huashu.js b/scripts/engine/lib/rig_huashu.js
new file mode 100644
index 0000000..1beff16
--- /dev/null
+++ b/scripts/engine/lib/rig_huashu.js
@@ -0,0 +1,171 @@
+// 花叔卡通形象骨架(侧面,FK 关节)。来源:花叔形象的 superflat 三视图设定稿(未随仓库附带),侧视图叠网格读点。
+// 角色定规:纯白渔夫帽、圆框黑眼镜、白 T、卡其短裤、白洞洞鞋、近侧手腕黑手表、大头小身体(头≈全身 38%)。
+// 坐标:本地单位 1 = 设定图侧视 1px;原点 = 双脚之间的地面;y 向上为负;原生朝左(-x 为前)。全身高 740 单位。
+// 用法:
+// const H = HUASHU.build({ x, y, s: 0.6, face: 1 /*1朝右 -1朝左*/, pose: HUASHU.pose('walk', phase) });
+// HUASHU.draw(c, H, pal) // 默认扁平画法;pal.mode: 'fill' | 'line' | 'both'
+// H.parts = [{ name, role, path, z }] // 按画序;role ∈ skin/shirt/shorts/hat/hair/shoe/watch/glass/line
+// H.J = { hip, knee1, ankle1, toe1, knee2, ..., shoulder1, elbow1, wrist1, ..., neck, head, hatTop, mouth, eye }
+// 角度约定:0 = 自然下垂;正 = 往脸朝的方向(前)转;大头小身体手够不到头顶:举手=近侧手臂向前上(~1.9)、远侧向后上(~-1.9),侧视里成 V 字,不要直上。1 = 近侧肢体(画在最前),2 = 远侧。
+(() => {
+const HS = window.HUASHU = {};
+const { lerp, clamp } = U;
+const D = (a, b, c, d, e, f) => new DOMMatrix([a, b, c, d, e, f]);
+const P2 = (pts, closed = true) => (RIG && RIG.smooth) ? RIG.smooth(pts, closed) : (() => { const p = new Path2D(); pts.forEach((q, i) => i ? p.lineTo(...q) : p.moveTo(...q)); if (closed) p.closePath(); return p; })();
+const add = (dst, path, m) => { dst.addPath(path, m); return dst; };
+const tf = (m, x, y) => { const p = m.transformPoint(new DOMPoint(x, y)); return [p.x, p.y]; };
+
+// ---------- 局部形状(各自骨骼坐标系,原点 = 该骨骼起点关节,沿 +y 向下) ----------
+const SHAPE = {
+ // 头:原点 = 颈点;脸朝 -x
+ face: P2([[-30, -158], [-78, -150], [-108, -128], [-122, -98], [-124, -66], [-118, -38], [-102, -14], [-80, 2], [-50, 8], [-18, 2], [8, -14], [22, -40], [24, -78], [10, -120]]),
+ hairBack: P2([[-70, -168], [-10, -176], [56, -168], [102, -140], [118, -96], [112, -58], [86, -30], [52, -18], [26, -28], [20, -62], [8, -110], [-30, -140], [-62, -140]]),
+ bangs: P2([[-122, -120], [-110, -146], [-76, -164], [-34, -166], [-10, -150], [-28, -138], [-52, -132], [-70, -118], [-86, -132], [-102, -116]]),
+ ear: (() => { const p = new Path2D(); p.ellipse(16, -66, 17, 22, 0.15, 0, Math.PI * 2); return p; })(),
+ crown: P2([[-100, -170], [-94, -232], [-64, -262], [-4, -274], [62, -266], [100, -236], [116, -180], [124, -110], [64, -118], [-10, -150], [-60, -166]]),
+ brim: P2([[-160, -166], [-112, -186], [-30, -190], [52, -164], [116, -112], [134, -62], [116, -52], [64, -86], [-16, -128], [-100, -150], [-156, -150]]),
+ band: P2([[-100, -186], [-30, -196], [60, -176], [118, -128], [120, -112], [60, -158], [-30, -180], [-100, -172]]),
+ lens: (() => { const p = new Path2D(); p.roundRect(-128, -118, 44, 62, 16); return p; })(),
+ // 躯干(T 恤):原点 = 胯;肩约 (0,-250)
+ shirt: P2([[-18, -272], [-40, -258], [-60, -200], [-72, -120], [-82, -42], [-84, -32], [74, -34], [72, -40], [70, -140], [62, -230], [44, -262], [14, -274]]),
+ collar: P2([[-18, -272], [0, -262], [14, -274]], false),
+ shorts: P2([[-74, -44], [76, -42], [80, 18], [70, 44], [-70, 46], [-78, 16]]),
+ // 大腿裤管:原点 = 胯侧关节;长 62
+ thigh: P2([[-40, -6], [38, -6], [42, 58], [-40, 62]]),
+ // 小腿:原点 = 膝;长 66
+ shin: P2([[-24, 0], [22, 0], [21, 66], [-21, 66]]),
+ // 洞洞鞋:原点 = 踝;鞋尖朝 -x
+ shoe: P2([[-104, 26], [-100, 6], [-80, -4], [-50, -8], [-20, -12], [18, -10], [46, -2], [58, 18], [56, 46], [40, 60], [-60, 62], [-96, 54], [-106, 40]]),
+ // 袖子:原点 = 肩;长 112
+ sleeve: P2([[-40, -10], [36, -14], [44, 100], [-34, 112]]),
+ upper: P2([[-19, 0], [19, 0], [18, 126], [-18, 126]]),
+ fore: P2([[-18, 0], [18, 0], [16, 74], [-16, 74]]),
+ hand: (() => { const p = new Path2D(); p.ellipse(0, 18, 22, 25, 0, 0, Math.PI * 2); return p; })(),
+ watch: (() => { const p = new Path2D(); p.roundRect(-24, 50, 48, 22, 6); return p; })(),
+ watchFace: (() => { const p = new Path2D(); p.roundRect(-16, 46, 32, 30, 7); return p; })(),
+};
+const SHOE_HOLES = [[-80, 18], [-58, 12], [-34, 10], [-10, 12], [-70, 32], [-46, 30], [-22, 30]];
+
+// ---------- 姿势库 ----------
+// 每个姿势返回关节角(弧度)与根偏移。phase 用于循环动作(0..1)。
+HS.pose = (name, ph = 0, k = {}) => {
+ const s = Math.sin(2 * Math.PI * ph), c = Math.cos(2 * Math.PI * ph);
+ const P = { lean: 0, head: 0, bob: 0, dx: 0, th1: 0, sh1: 0, ft1: 0, th2: 0, sh2: 0, ft2: 0, ua1: 0, fa1: 0, ua2: 0, fa2: 0, pocket1: 0, pocket2: 0, mouth: 0.3, blink: 0 };
+ switch (name) {
+ case 'idle': Object.assign(P, { pocket1: 1, pocket2: 1, ua1: -0.05, fa1: 0.25, ua2: -0.05, fa2: 0.25, bob: 2 * s, head: 0.03 * s }); break;
+ case 'walk': Object.assign(P, { lean: 0.05, bob: -6 * Math.abs(c), th1: 0.42 * s, sh1: -0.55 * Math.max(0, -s) - 0.15, ft1: 0.1 * s, th2: -0.42 * s, sh2: -0.55 * Math.max(0, s) - 0.15, ft2: -0.1 * s,
+ ua1: -0.45 * s, fa1: 0.35, ua2: 0.45 * s, fa2: 0.35, head: 0.03 * c }); break;
+ case 'run': Object.assign(P, { lean: 0.22, bob: -14 * Math.abs(c), th1: 0.8 * s + 0.1, sh1: -1.1 * Math.max(0, -s) - 0.3, th2: -0.8 * s + 0.1, sh2: -1.1 * Math.max(0, s) - 0.3,
+ ua1: -0.9 * s, fa1: 1.4, ua2: 0.9 * s, fa2: 1.4, head: -0.06, mouth: 0.6 }); break;
+ case 'crouch': Object.assign(P, { lean: 0.35, bob: 52, th1: 1.25, sh1: -1.9, ft1: 0.5, th2: 1.05, sh2: -1.8, ft2: 0.6, ua1: 0.5, fa1: 0.4, ua2: 0.3, fa2: 0.5, head: -0.2 }); break;
+ case 'jump': Object.assign(P, { lean: 0.05, th1: 0.7, sh1: -1.2, th2: 0.2, sh2: -0.6, ua1: 1.95, fa1: 0.7, ua2: -1.95, fa2: -0.7, head: -0.15, mouth: 1 }); break;
+ case 'wave': Object.assign(P, { pocket2: 1, ua2: -0.05, fa2: 0.25, ua1: 2.15, fa1: 0.15 + 0.5 * (0.5 + 0.5 * s), head: 0.08, mouth: 0.8, bob: 2 * s }); break;
+ case 'sit': Object.assign(P, { bob: 62, th1: 1.55, sh1: -1.55, th2: 1.5, sh2: -1.5, ua1: 0.5, fa1: 0.9, ua2: 0.4, fa2: 0.9, lean: -0.05 }); break;
+ case 'point': Object.assign(P, { pocket2: 1, ua2: -0.05, fa2: 0.25, ua1: 1.45, fa1: 0.05, head: -0.05, mouth: 0.7 }); break;
+ case 'think': Object.assign(P, { pocket2: 1, ua2: -0.05, fa2: 0.25, ua1: 0.6, fa1: 2.3, head: -0.1, mouth: 0.1 }); break;
+ case 'cheer': Object.assign(P, { ua1: 2.05, fa1: 0.55, ua2: -2.05, fa2: -0.55, bob: -10 * Math.abs(s), head: -0.12, mouth: 1 }); break;
+ // 侧身甩臂扔(打水漂):ph 0→1 = 蓄力 → 出手 → 随挥
+ case 'throw': { const w = ph < 0.45 ? ph / 0.45 : 1, r = ph < 0.45 ? 0 : clamp((ph - 0.45) / 0.25), f = clamp((ph - 0.7) / 0.3);
+ Object.assign(P, { lean: lerp(lerp(0, -0.12, w), 0.32, r), bob: lerp(0, 34, w) - 10 * r, th1: lerp(0, 0.65, w) - 0.3 * r, sh1: lerp(0, -0.9, w) + 0.4 * r, th2: lerp(0, -0.35, w) + 0.25 * r, sh2: lerp(-0.1, -0.5, w),
+ ua1: lerp(lerp(0, -1.3, w), 1.1, r) + 0.3 * f, fa1: lerp(lerp(0.3, 0.9, w), 0.15, r), ua2: lerp(0, 0.9, w) - 0.5 * r, fa2: 0.6, head: lerp(0, -0.05, w), mouth: 0.5 + 0.5 * r }); break; }
+ }
+ return Object.assign(P, k);
+};
+
+// ---------- 组装 ----------
+// o: { x, y, s, face, pose, squash } squash = 竖向挤压(落地 0.85、起跳 1.1)
+HS.build = (o = {}) => {
+ const { x = 960, y = 900, s = 0.6, face = 1, pose = HS.pose('idle'), squash = 1, rot = 0 } = o;
+ const P = pose;
+ // 根:先挪到世界坐标,按朝向镜像(原生朝左,face=1 朝右要翻),挤压以脚底为轴
+ const root = new DOMMatrix().translate(x, y).rotate(rot * 180 / Math.PI).scale(-face * s, s * squash);
+ const hip = root.translate(P.dx, -185 + P.bob).rotate(-P.lean * 180 / Math.PI); // lean>0 往前倾;本地前=-x,rotate 负角让上身朝 -x 倒
+ const deg = a => a * 180 / Math.PI;
+ const parts = [], J = {};
+ const push = (name, role, shape, m, z) => parts.push({ name, role, path: add(new Path2D(), shape, m), z, m });
+ const leg = (i, th, sh, ft, zBase) => {
+ const hipJ = hip.translate(i === 1 ? -8 : 10, 0);
+ const mT = hipJ.rotate(deg(th)); // 大腿往前(-x):正角 rotate → (0,1) 转向 -x ✓
+ const knee = mT.translate(0, 60), mS = knee.rotate(deg(sh)), ankle = mS.translate(0, 64), mF = ankle.rotate(deg(ft));
+ push('thigh' + i, 'shorts', SHAPE.thigh, mT, zBase + 2);
+ push('shin' + i, 'skin', SHAPE.shin, mS, zBase);
+ push('shoe' + i, 'shoe', SHAPE.shoe, mF, zBase + 1);
+ J['hip' + i] = tf(hipJ, 0, 0); J['knee' + i] = tf(knee, 0, 0); J['ankle' + i] = tf(ankle, 0, 0); J['toe' + i] = tf(mF, -104, 40); J['heel' + i] = tf(mF, 56, 46);
+ J['shoeM' + i] = mF;
+ };
+ const arm = (i, ua, fa, pocket, zBase) => {
+ const sh = hip.translate(i === 1 ? -4 : 14, -250);
+ const mU = sh.rotate(deg(ua)), elbow = mU.translate(0, 124), mFo = elbow.rotate(deg(fa)), wrist = mFo.translate(0, 70);
+ push('sleeve' + i, 'shirt', SHAPE.sleeve, mU, zBase + 3);
+ push('upper' + i, 'skin', SHAPE.upper, mU, zBase);
+ if (!pocket) { push('fore' + i, 'skin', SHAPE.fore, mFo, zBase + 1); push('hand' + i, 'skin', SHAPE.hand, wrist, zBase + 2); }
+ else push('fore' + i, 'skin', SHAPE.fore, mFo, zBase - 30); // 插兜:前臂藏到裤子后面
+ if (i === 1) { push('watch', 'watch', SHAPE.watch, mFo, zBase + (pocket ? -29 : 2)); push('watchFace', 'watch', SHAPE.watchFace, mFo, zBase + (pocket ? -28 : 3)); }
+ J['shoulder' + i] = tf(sh, 0, 0); J['elbow' + i] = tf(elbow, 0, 0); J['wrist' + i] = tf(wrist, 0, 0); J['hand' + i] = tf(wrist, 0, 18); J['handM' + i] = wrist;
+ };
+ // 远侧在后
+ leg(2, P.th2, P.sh2, P.ft2, 0);
+ arm(2, P.ua2, P.fa2, P.pocket2, 10);
+ push('shorts', 'shorts', SHAPE.shorts, hip, 40);
+ push('shirt', 'shirt', SHAPE.shirt, hip, 50);
+ leg(1, P.th1, P.sh1, P.ft1, 60);
+ push('shortsFront', 'shorts', SHAPE.shorts, hip, 64);
+ push('shirtFront', 'shirt', SHAPE.shirt, hip, 66);
+ // 头
+ const neck = hip.translate(6, -272), mH = neck.rotate(deg(-P.head));
+ push('hairBack', 'hair', SHAPE.hairBack, mH, 80);
+ push('face', 'skin', SHAPE.face, mH, 81);
+ push('ear', 'skin', SHAPE.ear, mH, 82);
+ push('bangs', 'hair', SHAPE.bangs, mH, 83);
+ push('crown', 'hat', SHAPE.crown, mH, 85);
+ push('band', 'hatBand', SHAPE.band, mH, 86);
+ push('brim', 'hat', SHAPE.brim, mH, 87);
+ arm(1, P.ua1, P.fa1, P.pocket1, 70);
+ parts.sort((a, b) => a.z - b.z);
+ J.hip = tf(hip, 0, 0); J.neck = tf(neck, 0, 0); J.head = tf(mH, -40, -80); J.hatTop = tf(mH, 0, -275); J.mouth = tf(mH, -104, -34); J.eye = tf(mH, -104, -88);
+ J.chest = tf(hip, -40, -180); J.face = face; J.s = s;
+ return { parts, J, mH, root, hip, P, s, face };
+};
+
+// 五官与细节线(在头部坐标里画)
+HS.details = (c, H, pal) => {
+ const L = pal.line || '#151515', lw = (pal.lw ?? 5);
+ c.save(); c.setTransform(c.getTransform().multiply(H.mH)); c.lineCap = 'round'; c.lineJoin = 'round';
+ // 眼镜:前镜片+镜腿;镜片里一只黑眼睛
+ c.fillStyle = pal.lensFill || 'rgba(255,255,255,0.0)'; c.fill(SHAPE.lens);
+ if (!H.P.blink) { c.fillStyle = pal.eye || L; c.beginPath(); c.ellipse(-104, -86, 9, 13, 0, 0, Math.PI * 2); c.fill(); c.fillStyle = '#fff'; c.beginPath(); c.arc(-107, -91, 3, 0, Math.PI * 2); c.fill(); }
+ else { c.strokeStyle = pal.eye || L; c.lineWidth = lw * 0.8; c.beginPath(); c.arc(-104, -90, 9, 0.2, Math.PI - 0.2); c.stroke(); }
+ c.strokeStyle = pal.glass || L; c.lineWidth = lw * 1.6; c.stroke(SHAPE.lens);
+ c.lineWidth = lw * 1.3; c.beginPath(); c.moveTo(-84, -96); c.lineTo(8, -84); c.stroke();
+ // 嘴:mouth 0 闭嘴微笑 → 1 张嘴
+ const m = H.P.mouth;
+ c.strokeStyle = L; c.lineWidth = lw * 0.8;
+ if (m < 0.5) { c.beginPath(); c.moveTo(-112, -40); c.quadraticCurveTo(-100, -28 - 8 * m, -88, -38); c.stroke(); }
+ else { c.fillStyle = pal.mouthFill || '#7a2e2e'; c.beginPath(); c.ellipse(-102, -34, 9, 6 + 6 * m, 0, 0, Math.PI * 2); c.fill(); c.stroke(); }
+ // 腮红、耳廓
+ if (pal.cheek) { c.fillStyle = pal.cheek; c.beginPath(); c.ellipse(-70, -48, 14, 9, 0, 0, Math.PI * 2); c.fill(); }
+ c.strokeStyle = pal.earLine || 'rgba(190,110,90,.8)'; c.lineWidth = lw * 0.6; c.beginPath(); c.arc(16, -66, 8, -1.2, 1.6); c.stroke();
+ c.restore();
+ // 鞋洞
+ for (const i of [1, 2]) { const m2 = H.J['shoeM' + i]; c.save(); c.setTransform(c.getTransform().multiply(m2)); c.fillStyle = pal.shoeHole || '#2a2a2a'; SHOE_HOLES.forEach(([x, y]) => { c.beginPath(); c.ellipse(x, y, 4.5, 3.5, 0, 0, Math.PI * 2); c.fill(); }); c.strokeStyle = pal.shoeHole || '#2a2a2a'; c.lineWidth = 3; c.beginPath(); c.arc(40, 24, 9, 0, Math.PI * 2); c.stroke(); c.restore(); }
+};
+
+HS.PAL = { skin: '#fbd9bf', hair: '#151515', shirt: '#ffffff', shorts: '#d8cdb8', hat: '#ffffff', hatBand: '#e9e9e9', shoe: '#fbfaf6', watch: '#1d1f22', line: '#151515', lw: 5, cheek: 'rgba(245,140,120,.35)' };
+
+// 默认画法:逐部件「填→描」,天然只剩看得见的线(遮挡正确)
+HS.draw = (c, H, pal = HS.PAL) => {
+ pal = { ...HS.PAL, ...pal };
+ const mode = pal.mode || 'both', L = pal.line, lw = pal.lw / H.s * H.s; // 线宽按世界像素
+ c.save(); c.lineJoin = 'round'; c.lineCap = 'round';
+ for (const p of H.parts) {
+ const col = pal[p.role] ?? pal.skin;
+ if (mode !== 'line') { c.fillStyle = col; c.fill(p.path); }
+ if (mode !== 'fill' && lw) {
+ if (mode === 'line') { c.save(); c.globalCompositeOperation = 'destination-out'; c.fill(p.path); c.restore(); } // 线稿模式:后画的部件先挖掉前面的线
+ c.strokeStyle = L; c.lineWidth = lw; c.stroke(p.path);
+ }
+ }
+ HS.details(c, H, pal);
+ c.restore();
+};
+})();
diff --git a/scripts/engine/lib/toon.js b/scripts/engine/lib/toon.js
new file mode 100644
index 0000000..606b828
--- /dev/null
+++ b/scripts/engine/lib/toon.js
@@ -0,0 +1,159 @@
+// 卡通与扁平插画 TOON:Kurzgesagt 式「无描边、双色分面」、柔光;故事型(storytime)极简角色「豆子花叔」、
+// pose-to-pose 换姿势(快切+身体挤压回弹)、眨眼时刻表、口型读口播包络(一拍二)、汗滴、漫画符号。
+(() => {
+const W = 1920, H = 1080;
+const { clamp, lerp } = U;
+const TOON = window.TOON = {};
+
+// ---------- 扁平插画 ----------
+// 双色分面(无描边、靠色块分面):clip(S) → 整块阴影色 → 往光源方向平移 v 填高光 → 再往回挪 w 填本色:右下留阴影带、左上留细高光边
+TOON.flat = (c, path, base, sh, hi, v = [10, 12], w = [4, 5]) => {
+ c.save(); c.clip(path);
+ c.fillStyle = sh || base; c.fill(path);
+ c.save(); c.translate(-v[0], -v[1]); c.fillStyle = hi || base; c.fill(path); c.restore();
+ c.save(); c.translate(-v[0] + w[0], -v[1] + w[1]); c.fillStyle = base; c.fill(path); c.restore();
+ c.restore();
+};
+// 柔光:径向渐变方块(发光物、眼睛、信号脉冲)
+TOON.glow = (c, x, y, r, col, a = 1) => { const g = c.createRadialGradient(x, y, 0, x, y, r); g.addColorStop(0, PAINT.rgb(PAINT.hex(col), a)); g.addColorStop(1, PAINT.rgb(PAINT.hex(col), 0)); c.fillStyle = g; c.fillRect(x - r, y - r, 2 * r, 2 * r); };
+// 竖向渐变(天空)
+TOON.vgrad = (c, y0, y1, cols) => { const g = c.createLinearGradient(0, y0, 0, y1); cols.forEach((k, i) => g.addColorStop(i / (cols.length - 1), k)); return g; };
+TOON.circle = (x, y, r) => { const p = new Path2D(); p.arc(x, y, r, 0, Math.PI * 2); return p; };
+TOON.ellipse = (x, y, rx, ry, a = 0) => { const p = new Path2D(); p.ellipse(x, y, rx, ry, a, 0, Math.PI * 2); return p; };
+
+// ---------- 口型:读口播包络 ----------
+// window.VO_ENV = {fps, a:[...]}(0..1 的 RMS 包络,由音频脚本从口播 wav 生成)。口型「一拍二」:每 1/12 秒才换一次形。
+TOON.env = t => { const E = window.VO_ENV; if (!E) return 0; const i = Math.round(t * E.fps); return i < 0 || i >= E.a.length ? 0 : E.a[i]; };
+TOON.mouth = (t, fps = 12) => { const v = TOON.env(MO.step(t, fps)); return v < 0.06 ? 0 : v < 0.22 ? 1 : 2; }; // 0 闭 1 半 2 张
+
+// ---------- 豆子花叔(故事型极简角色) ----------
+// 正面、圆头、豆子身体、面条手臂。标志物:纯白渔夫帽、圆框黑眼镜(另:白T、卡其短裤、黑手表)。
+// o: { x, y(脚底), s(头半径 px), pose:{l,r}(手臂目标点,相对肩,头半径单位), expr, mouth(0/1/2), blink, look:[dx,dy],
+// squash(竖向缩放,以脚底为轴,体积守恒), tilt(头歪), bob(头下沉), browUp, lw }
+// expr: 'talk' | 'happy' | 'blank'(死鱼眼) | 'worry' | 'shock'。返回 { hl, hr(两手位置), head:[x,y] }
+const SK = '#FFE2CC', LINE = '#1B1B1F', HAT = '#FFFFFF', BAND = '#E4E4E8', SHIRT = '#FFFFFF', SHORTS = '#CDBB97', HAIR = '#1B1B1F';
+TOON.POSES = {
+ rest: { l: [-0.95, 1.05], r: [0.95, 1.05] },
+ talk: { l: [-0.95, 1.05], r: [1.05, 0.55] }, // 一只手微抬,口播默认
+ point: { l: [-0.95, 1.05], r: [1.75, -0.15] }, // 指向画右
+ type: { l: [-0.55, 0.62], r: [0.55, 0.62] }, // 双手在胸前(打字)
+ shrug: { l: [-1.45, -0.05], r: [1.45, -0.05], palms: 1 },
+ stiff: { l: [-0.78, 1.25], r: [0.78, 1.25] }, // 僵住
+};
+TOON.bean = (c, o) => {
+ const R = o.s, x = o.x, y = o.y, lw = o.lw || Math.max(4, R * 0.05), sq = o.squash || 1;
+ const pose = o.pose || TOON.POSES.rest;
+ c.save(); c.translate(x, y); c.scale(1 / Math.sqrt(sq), sq);
+ c.lineJoin = 'round'; c.lineCap = 'round'; c.strokeStyle = LINE; c.lineWidth = lw;
+ const bodyTop = -R * 1.32;
+ const shoulderY = bodyTop + R * 0.32, shL = [-R * 0.42, shoulderY], shR = [R * 0.42, shoulderY];
+ for (const sx of [-1, 1]) { // 腿:两截短圆柱+白鞋
+ c.fillStyle = SK; c.beginPath(); c.roundRect(sx * R * 0.2 - R * 0.09, -R * 0.24, R * 0.18, R * 0.2, R * 0.05); c.fill(); c.stroke();
+ c.fillStyle = '#FAFAF6'; c.beginPath(); c.ellipse(sx * R * 0.22, -R * 0.03, R * 0.17, R * 0.08, 0, 0, Math.PI * 2); c.fill(); c.stroke();
+ }
+ const body = new Path2D(); // 身体(豆子)
+ body.moveTo(-R * 0.5, -R * 0.2);
+ body.bezierCurveTo(-R * 0.62, -R * 0.75, -R * 0.55, bodyTop + R * 0.05, 0, bodyTop);
+ body.bezierCurveTo(R * 0.55, bodyTop + R * 0.05, R * 0.62, -R * 0.75, R * 0.5, -R * 0.2);
+ body.bezierCurveTo(R * 0.3, -R * 0.12, -R * 0.3, -R * 0.12, -R * 0.5, -R * 0.2); body.closePath();
+ c.fillStyle = SHIRT; c.fill(body);
+ c.save(); c.clip(body); c.fillStyle = SHORTS; c.fillRect(-R, -R * 0.42, R * 2, R * 0.5);
+ c.strokeStyle = LINE; c.lineWidth = lw * 0.6; c.beginPath(); c.moveTo(0, -R * 0.36); c.lineTo(0, -R * 0.12); c.stroke(); c.restore();
+ c.stroke(body);
+ c.beginPath(); c.moveTo(-R * 0.6, -R * 0.42); c.quadraticCurveTo(0, -R * 0.36, R * 0.6, -R * 0.42); c.lineWidth = lw * 0.8; c.stroke(); c.lineWidth = lw;
+ // 面条手臂:肩 → 手(二次曲线,肘自然下垂),双描边做出「管子」
+ const arm = (sh, tgt, side) => {
+ const hx = sh[0] + tgt[0] * R * 0.62, hy = sh[1] + tgt[1] * R * 0.62;
+ const mx = (sh[0] + hx) / 2 + side * R * 0.08, my = Math.max(sh[1], hy) + R * 0.12;
+ c.beginPath(); c.moveTo(sh[0], sh[1]); c.quadraticCurveTo(mx, my, hx, hy);
+ c.strokeStyle = LINE; c.lineWidth = R * 0.17 + lw; c.stroke(); c.strokeStyle = SK; c.lineWidth = R * 0.17; c.stroke();
+ c.beginPath(); c.moveTo(sh[0], sh[1]); const q = 0.28; c.lineTo(lerp(sh[0], mx, q * 2), lerp(sh[1], my, q * 2));
+ c.strokeStyle = LINE; c.lineWidth = R * 0.26 + lw; c.stroke(); c.strokeStyle = SHIRT; c.lineWidth = R * 0.26; c.stroke();
+ c.fillStyle = SK; c.strokeStyle = LINE; c.lineWidth = lw; c.beginPath(); c.arc(hx, hy, R * 0.13, 0, Math.PI * 2); c.fill(); c.stroke();
+ if (side > 0) { // 近侧(画右)手腕黑手表
+ const ang = Math.atan2(hy - my, hx - mx), wx = hx - Math.cos(ang) * R * 0.17, wy = hy - Math.sin(ang) * R * 0.17;
+ c.save(); c.translate(wx, wy); c.rotate(ang + Math.PI / 2); c.fillStyle = '#1D1F22'; c.fillRect(-R * 0.1, -R * 0.04, R * 0.2, R * 0.08); c.restore();
+ }
+ return [hx, hy];
+ };
+ c.lineWidth = lw;
+ const hl = arm(shL, pose.l, -1), hr = arm(shR, pose.r, 1);
+ // 头:略宽的圆,压在身体上
+ c.restore(); c.save(); c.translate(x, y); c.scale(1 / Math.sqrt(sq), sq);
+ c.lineJoin = 'round'; c.lineCap = 'round'; c.strokeStyle = LINE; c.lineWidth = lw;
+ const hy = bodyTop - R * 0.78 + (o.bob || 0);
+ c.translate(0, hy); c.rotate(o.tilt || 0);
+ c.fillStyle = HAIR; // 鬓角(帽檐下露一点黑发)
+ for (const sx of [-1, 1]) { c.beginPath(); c.ellipse(sx * R * 0.86, -R * 0.12, R * 0.16, R * 0.3, sx * 0.2, 0, Math.PI * 2); c.fill(); }
+ c.fillStyle = SK; c.beginPath(); c.ellipse(0, 0, R * 1.0, R * 0.93, 0, 0, Math.PI * 2); c.fill(); c.stroke();
+ // 帽子:帽冠+帽带+往下斜的帽檐
+ const crown = new Path2D(); crown.moveTo(-R * 0.78, -R * 0.42); crown.bezierCurveTo(-R * 0.8, -R * 1.25, R * 0.8, -R * 1.25, R * 0.78, -R * 0.42); crown.closePath();
+ c.fillStyle = HAT; c.fill(crown); c.stroke(crown);
+ c.save(); c.clip(crown); c.fillStyle = BAND; c.fillRect(-R, -R * 0.62, R * 2, R * 0.18); c.restore();
+ c.beginPath(); c.moveTo(-R * 0.79, -R * 0.62); c.quadraticCurveTo(0, -R * 0.7, R * 0.79, -R * 0.62); c.lineWidth = lw * 0.7; c.stroke(); c.lineWidth = lw;
+ const brim = new Path2D(); brim.moveTo(-R * 1.18, -R * 0.24); brim.quadraticCurveTo(0, -R * 0.66, R * 1.18, -R * 0.24);
+ brim.quadraticCurveTo(R * 1.22, -R * 0.12, R * 1.08, -R * 0.12); brim.quadraticCurveTo(0, -R * 0.44, -R * 1.08, -R * 0.12); brim.quadraticCurveTo(-R * 1.22, -R * 0.12, -R * 1.18, -R * 0.24); brim.closePath();
+ c.fillStyle = HAT; c.fill(brim); c.stroke(brim);
+ // 眉毛(表情主载体):[整体上下, 内端相对外端的高差](负 = 内端抬高 = 担心/委屈)
+ const ex = o.expr || 'talk', lk = o.look || [0, 0];
+ const brow = { talk: [0, 0], happy: [-0.05, 0.03], blank: [0.03, 0], worry: [-0.02, -0.11], shock: [-0.11, 0.02] }[ex] || [0, 0];
+ if (o.browUp) brow[0] -= o.browUp;
+ c.lineWidth = lw * 1.4;
+ for (const sx of [-1, 1]) { const by = -R * 0.13 + brow[0] * R; c.beginPath(); c.moveTo(sx * R * 0.52, by); c.lineTo(sx * R * 0.2, by + brow[1] * R); c.stroke(); }
+ c.lineWidth = lw;
+ // 眼镜:两只圆框(标志物,线比轮廓粗 1.4 倍)+鼻梁;眼睛是黑点
+ const gy = R * 0.2, gr = R * 0.27;
+ for (const sx of [-1, 1]) {
+ const gx = sx * R * 0.37;
+ c.fillStyle = 'rgba(255,255,255,0.35)'; c.beginPath(); c.arc(gx, gy, gr, 0, Math.PI * 2); c.fill();
+ const pr = ex === 'blank' ? R * 0.035 : ex === 'shock' ? R * 0.05 : R * 0.075;
+ c.fillStyle = LINE;
+ if (o.blink) { c.beginPath(); c.moveTo(gx - R * 0.08 + lk[0] * R * 0.08, gy + lk[1] * R * 0.06); c.lineTo(gx + R * 0.08 + lk[0] * R * 0.08, gy + lk[1] * R * 0.06); c.lineWidth = lw; c.stroke(); }
+ else { c.beginPath(); c.ellipse(gx + lk[0] * R * 0.09, gy + lk[1] * R * 0.07, pr, pr * (ex === 'blank' ? 1 : 1.25), 0, 0, Math.PI * 2); c.fill();
+ if (ex !== 'blank') { c.fillStyle = '#fff'; c.beginPath(); c.arc(gx + lk[0] * R * 0.09 - pr * 0.35, gy + lk[1] * R * 0.07 - pr * 0.45, pr * 0.32, 0, Math.PI * 2); c.fill(); } }
+ c.lineWidth = lw * 1.5; c.strokeStyle = LINE; c.beginPath(); c.arc(gx, gy, gr, 0, Math.PI * 2); c.stroke();
+ }
+ c.beginPath(); c.moveTo(-R * 0.1, gy - R * 0.02); c.quadraticCurveTo(0, gy - R * 0.08, R * 0.1, gy - R * 0.02); c.stroke();
+ c.lineWidth = lw;
+ c.fillStyle = 'rgba(255,140,120,0.35)'; for (const sx of [-1, 1]) { c.beginPath(); c.ellipse(sx * R * 0.68, R * 0.5, R * 0.11, R * 0.06, 0, 0, Math.PI * 2); c.fill(); }
+ // 嘴
+ const m = o.mouth || 0, my = R * 0.6;
+ c.strokeStyle = LINE; c.lineWidth = lw;
+ if (ex === 'blank' && !m) { c.beginPath(); c.moveTo(-R * 0.1, my); c.lineTo(R * 0.1, my); c.stroke(); }
+ else if (ex === 'worry' && !m) { c.beginPath(); c.moveTo(-R * 0.13, my + R * 0.03); c.quadraticCurveTo(-R * 0.05, my - R * 0.04, 0, my + R * 0.01); c.quadraticCurveTo(R * 0.06, my + R * 0.05, R * 0.13, my - R * 0.01); c.stroke(); }
+ else if (!m) { c.beginPath(); c.moveTo(-R * 0.13, my - R * 0.02); c.quadraticCurveTo(0, my + R * 0.1, R * 0.13, my - R * 0.02); c.stroke(); }
+ else {
+ const mh = m === 1 ? R * 0.1 : R * 0.2, mw = m === 1 ? R * 0.14 : R * 0.18;
+ c.fillStyle = '#6E2430'; c.beginPath(); c.moveTo(-mw, my - R * 0.03); c.quadraticCurveTo(0, my - R * 0.06, mw, my - R * 0.03); c.quadraticCurveTo(mw * 0.9, my + mh, 0, my + mh); c.quadraticCurveTo(-mw * 0.9, my + mh, -mw, my - R * 0.03); c.closePath(); c.fill();
+ c.save(); c.clip(); c.fillStyle = '#F07B7B'; c.beginPath(); c.ellipse(0, my + mh, mw * 0.6, mh * 0.45, 0, 0, Math.PI * 2); c.fill(); c.restore(); c.stroke();
+ }
+ c.restore();
+ return { hl, hr, head: [x, y + hy * sq] };
+};
+
+// ---------- pose-to-pose ----------
+// keys = [[t, poseName, expr], ...](同一条时间轴的秒)。换姿势:手臂 0.1s expoOut 过去(24fps 下 3 帧的「快切」),
+// 身体同时挤压 7% 后按弹簧回弹(3.5Hz / 衰减 9)。返回 { pose, expr, squash, since }
+TOON.poseAt = (keys, t, poses = TOON.POSES) => {
+ let k = 0; for (let i = 0; i < keys.length; i++) if (t >= keys[i][0]) k = i;
+ const cur = poses[keys[k][1]], prv = poses[keys[Math.max(0, k - 1)][1]];
+ const dt = t - keys[k][0], q = k === 0 ? 1 : MO.expoOut(clamp(dt / 0.1));
+ const mix = (a, b) => [lerp(a[0], b[0], q), lerp(a[1], b[1], q)];
+ return { pose: { l: mix(prv.l, cur.l), r: mix(prv.r, cur.r), palms: cur.palms }, expr: keys[k][2], squash: k === 0 ? 1 : 1 + MO.settle(dt, -0.07, 3.5, 9), since: dt };
+};
+// 眨眼:固定时刻表(间隔 2.4–3.6s 的「随机」写死),闭眼 dur 秒(24fps 下 2 帧 ≈ 0.083s;「无语」的慢眨眼 3 帧)
+TOON.blinkAt = (t, times, dur = 0.083) => times.some(b => t >= b && t < b + dur) ? 1 : 0;
+// 活着:说话时头随口型轻点(每次张嘴下沉 0.015R)+呼吸(1.6s 一周期,身体 ±1.2%)
+TOON.alive = (t, R) => ({ bob: TOON.mouth(t) * R * 0.015, breathe: 1 + 0.012 * Math.sin(2 * Math.PI * t / 1.6) });
+
+// ---------- 漫画符号 ----------
+// 汗滴:p 0..1 沿脸侧滑下
+TOON.sweat = (c, x, y, r, p) => {
+ const yy = y + p * r * 3.2, a = p < 0.85 ? 1 : 1 - (p - 0.85) / 0.15;
+ c.save(); c.globalAlpha = a; c.fillStyle = '#9ED8F5'; c.strokeStyle = LINE; c.lineWidth = Math.max(3, r * 0.12);
+ c.beginPath(); c.moveTo(x, yy - r * 1.5); c.quadraticCurveTo(x + r * 1.05, yy + r * 0.1, x, yy + r); c.quadraticCurveTo(x - r * 1.05, yy + r * 0.1, x, yy - r * 1.5); c.fill(); c.stroke();
+ c.fillStyle = '#fff'; c.beginPath(); c.ellipse(x - r * 0.3, yy - r * 0.05, r * 0.18, r * 0.32, 0, 0, Math.PI * 2); c.fill(); c.restore();
+};
+// 「?」「!」弹出(白描边,过冲 30%)
+TOON.mark = (c, ch, x, y, p, size = 160, color = LINE) => { if (p <= 0) return; TY.pop(c, ch, x, y, p, { size, fam: 'PuHui-Black', color, stroke: '#fff', strokeW: size * 0.12, over: 3 }); };
+})();
diff --git a/scripts/engine/lib/typo.js b/scripts/engine/lib/typo.js
new file mode 100644
index 0000000..da397e5
--- /dev/null
+++ b/scripts/engine/lib/typo.js
@@ -0,0 +1,122 @@
+// 文字动效 TY:逐字/逐词弹入、遮罩升起、弹入、打字、从模糊浮出、荧光笔、下划线、主词砸入、关键词强调、数字计数与等宽数字。
+// 约定:p 是 0..1 进度;lt/t 是秒。字体用 CSS 字体串或 family 名(中文默认 PuHui-*,开源版是思源黑体,见 lib/fonts.js)。
+// 可读性底线(y5/y1 卡片):主词 : 辅句 : 标签 ≈ 3.4 : 1 : 0.4;一句辅句在屏 ≥1.2s;入场慢(0.3–0.4s)、退场快(≈0.18s)。
+(() => {
+const { clamp, lerp } = U;
+const TY = window.TY = {};
+
+// ---------- 基础 ----------
+TY.font = (size, fam = 'PuHui-Black') => `${size}px "${fam}"`;
+// 画一段字:可带透明、缩放、旋转(绕 ox,oy)、字距 track、描边
+TY.text = (c, s, x, y, { size = 120, fam = 'PuHui-Black', color = '#111', align = 'center', base = 'alphabetic', alpha = 1, scale = 1, rot = 0, track = 0, stroke, strokeW = 0, ox = x, oy = y } = {}) => {
+ if (alpha <= 0 || scale <= 0) return;
+ c.save(); c.globalAlpha *= alpha; c.translate(ox, oy); c.rotate(rot); c.scale(scale, scale); c.translate(-ox, -oy);
+ c.font = TY.font(size, fam); c.textAlign = align; c.textBaseline = base; if (track) c.letterSpacing = track + 'px';
+ if (stroke && strokeW) { c.lineJoin = 'round'; c.strokeStyle = stroke; c.lineWidth = strokeW; c.strokeText(s, x, y); }
+ c.fillStyle = color; c.fillText(s, x, y); c.restore();
+};
+TY.width = (c, s, size, fam = 'PuHui-Black', track = 0) => { c.save(); c.font = TY.font(size, fam); if (track) c.letterSpacing = track + 'px'; const w = c.measureText(s).width; c.restore(); return w; };
+// 折行:按 maxW 把一段字拆成多行(中文逐字可断;英文/数字按词断;行首不放中文标点)。font 是 CSS 字体串
+TY.wrap = (c, text, maxW, font) => {
+ c.save(); if (font) c.font = font;
+ const toks = String(text).match(/[A-Za-z0-9.,%+\-'’]+\s*|\s+|./gu) || [], lines = []; let cur = '';
+ for (const tk of toks) {
+ if (tk === '\n') { lines.push(cur); cur = ''; continue; }
+ if (cur && c.measureText(cur + tk.trimEnd()).width > maxW && !/^[,。、:;!?」』)》,.!?)]$/.test(tk)) { lines.push(cur.trimEnd()); cur = tk.trimStart(); }
+ else cur += tk;
+ }
+ if (cur.trim()) lines.push(cur.trimEnd());
+ c.restore(); return lines;
+};
+// 把字号从 size 往下缩,直到真放得下:折行后不超过 maxLines 行,而且量过每行宽 ≤ maxW(单个长英文词/长数字折不开,只数行数会超宽)。返回 {size, lines, ok}
+// 先在 [min, 1] 倍里找;找不到时 soft:true 返回 ok:false 让调用方换方案(如改折两行),否则继续缩(最低 0.2 倍)。balance:true 时多行折成等长。
+TY.fit = (c, text, maxW, size, fam, { maxLines = 2, min = 0.45, weight = '', soft = false, balance = false } = {}) => {
+ const font = s => `${weight}${s}px "${fam}"`, ok = (s, lines) => { c.save(); c.font = font(s); const r = lines.length <= maxLines && lines.every(l => c.measureText(l).width <= maxW + 0.5); c.restore(); return r; };
+ let s = size, lines = [String(text)], good = false;
+ for (; s >= size * (soft ? min : 0.2) - 1e-9; s *= 0.94) { lines = TY.wrap(c, text, maxW, font(s)); if (ok(s, lines)) { good = true; break; } if (s < size * min && soft) break; }
+ if (!good && !soft) s /= 0.94;
+ if (good && balance && lines.length > 1) { const n = lines.length; let lo = maxW * 0.4, hi = maxW; for (let k = 0; k < 14; k++) { const m = (lo + hi) / 2; if (TY.wrap(c, text, m, font(s)).length > n) lo = m; else hi = m; } lines = TY.wrap(c, text, hi, font(s)); }
+ return { size: s, lines, ok: good };
+};
+
+// ---------- 入场 ----------
+// 逐字错开出现:每字 dur 秒,从 dy 往上、透明→不透明、可带缩放;Kurzgesagt 标题 0.5s/字、错开 45ms。返回总宽。
+TY.charsIn = (c, str, x, y, lt, { font, color, dur = 0.35, stagger = 0.04, dy = 24, scale0 = 1, align = 'left', ease = MO.cubicOut, shadow, spacing = 0 } = {}) => {
+ c.save(); c.font = font; c.textBaseline = 'alphabetic'; c.fillStyle = color; const A0 = c.globalAlpha; // 乘上调用方的透明度(外面包一层淡出才生效)
+ const chars = [...str]; const ws = chars.map(ch => c.measureText(ch).width + spacing); const tw = ws.reduce((a, b) => a + b, 0) - spacing;
+ let cx = align === 'center' ? x - tw / 2 : align === 'right' ? x - tw : x;
+ chars.forEach((ch, i) => {
+ const q = clamp((lt - i * stagger) / dur); if (q > 0) {
+ const e = ease(q); c.save(); c.globalAlpha = A0 * clamp(q * 2.2);
+ c.translate(cx + ws[i] / 2, y + dy * (1 - e)); const s = lerp(scale0, 1, e); c.scale(s, s);
+ if (shadow) { c.shadowColor = shadow.color; c.shadowOffsetX = shadow.x || 0; c.shadowOffsetY = shadow.y || 0; c.shadowBlur = shadow.blur || 0; }
+ c.fillText(ch, -ws[i] / 2 + spacing / 2, 0); c.restore();
+ }
+ cx += ws[i];
+ });
+ c.restore(); return tw;
+};
+// 遮罩升起:字从基线下的「槽」里推上来(动态文字最常见的出字法)。p 0..1,o.dir=+1 往上出,-1 往下收。o 同 TY.text
+TY.rise = (c, s, x, y, p, o = {}) => {
+ const size = o.size || 120, e = MO.expoOut(clamp(p)), w = TY.width(c, s, size, o.fam, o.track), a = o.align || 'left';
+ const x0 = a === 'left' ? x : a === 'center' ? x - w / 2 : x - w;
+ c.save(); c.beginPath(); c.rect(x0 - 20, y - size * 1.05, w + 40, size * 1.32); c.clip();
+ TY.text(c, s, x, y + size * 1.2 * (1 - e) * (o.dir || 1), { ...o, align: a }); c.restore();
+};
+// 弹入:从 0 放大到 1,backOut 过冲后停(以字中心为轴)。o.over = backOut 的 s
+TY.pop = (c, s, x, y, p, o = {}) => {
+ if (p <= 0) return; const size = o.size || 120, sc = MO.backOut(clamp(p), o.over ?? 2.2) * (o.scale || 1);
+ TY.text(c, s, x, y, { ...o, scale: sc, ox: x, oy: y - size * 0.36 });
+};
+// 从模糊浮出(发布会标题):模糊→清晰+上移+透明→不透明。用调用方设好的 font/fillStyle/textAlign。
+TY.blurIn = (c, text, x, y, p, { blur = 18, dy = 28, scale = 0 } = {}) => {
+ if (p <= 0) return;
+ c.save(); c.globalAlpha *= clamp(p * 1.4);
+ const b = (1 - p) * blur; if (b > 0.3) c.filter = `blur(${b.toFixed(2)}px)`;
+ c.translate(x, y + (1 - p) * dy); if (scale) { const s = 1 + (1 - p) * scale; c.scale(s, s); }
+ c.fillText(text, 0, 0); c.restore();
+};
+// 打字:按字符数截断(p 0..1)
+TY.typed = (s, p) => [...s].slice(0, Math.round(clamp(p) * [...s].length)).join('');
+// 打字机:t 时刻已打出的字数(rate 字/秒,可按 fps 步进;Vox 13 字/秒+12fps,白板正文 16 字/秒)
+TY.typedCount = (t, t0, rate, fps = 0) => Math.max(0, Math.floor(((fps ? MO.step(t, fps) : t) - t0) * rate + 1e-6) + 1);
+
+// ---------- 强调 ----------
+// 荧光笔:从左往右刷出的斜切色块,放在字后面(动态文字)。拼贴风的毛边 multiply 荧光笔见 CL.highlight
+TY.marker = (c, x, y, w, h, p, color = '#FFE14D', skew = 0.18) => {
+ if (p <= 0) return; const e = MO.expoOut(clamp(p)), ww = w * e;
+ c.save(); c.fillStyle = color; c.beginPath(); c.moveTo(x + h * skew, y); c.lineTo(x + ww + h * skew, y); c.lineTo(x + ww, y + h); c.lineTo(x, y + h); c.closePath(); c.fill(); c.restore();
+};
+TY.underline = (c, x, y, w, p, color, lw = 10) => { if (p <= 0) return; c.save(); c.strokeStyle = color; c.lineCap = 'round'; c.lineWidth = lw; c.beginPath(); c.moveTo(x, y); c.lineTo(x + w * MO.expoOut(clamp(p)), y); c.stroke(); c.restore(); };
+// 主词「砸」进来:从 from 倍缩到 1(弹簧 2.2Hz/10,过冲 ≈8%),前 0.06s 透明→不透明。lt = 本词出现后的秒数
+TY.slam = (c, s, x, y, lt, o = {}) => {
+ if (lt < 0) return; const size = o.size || 340, k = MO.springHz(lt, o.freq || 2.2, o.decay || 10), sc = lerp(o.from || 1.7, 1, k);
+ TY.text(c, s, x, y, { size, fam: 'PuHui-Black', align: 'left', ...o, scale: sc * (o.scale || 1), alpha: clamp(lt / 0.06), ox: o.ox ?? x, oy: o.oy ?? y - size * 0.36 });
+};
+// 关键词:tIn 起从槽里升起,到「强调拍」tHit 放大到 1.35 倍并钉住(弹簧 2.5Hz/9)。返回当前缩放(给荧光笔/下划线跟着放大)。
+// 字和动作说同一件事:「下一行」放大的那一拍正好按下 Tab(y5)。
+TY.keyword = (c, s, x, y, t, tIn, tHit, o) => {
+ if (t < tHit) { TY.rise(c, s, x, y, MO.at(t, tIn, 0.35), { ...o, align: 'left' }); return 1; }
+ const sc = lerp(1, 1.35, MO.springHz(t - tHit, 2.5, 9));
+ TY.text(c, s, x, y, { ...o, align: 'left', scale: sc, ox: x, oy: y });
+ return sc;
+};
+// 关键词后面的荧光笔:跟关键词同一拍出现、同一缩放
+TY.keywordMarker = (c, x, y, w, size, t, tHit, sc, col) => { if (t < tHit) return; TY.marker(c, x - 8, y - size * 0.98 * sc, (w + 16) * sc, size * 1.18 * sc, MO.at(t, tHit, 0.3), col); };
+
+// ---------- 数字 ----------
+// 千分位格式;负号用真减号「−」
+TY.fmt = (v, dec = 0, sep = true) => { const s = Math.abs(v).toFixed(dec); const [i, f] = s.split('.'); const ii = sep ? i.replace(/\B(?=(\d{3})+(?!\d))/g, ',') : i; return (v < 0 ? '−' : '') + ii + (f ? '.' + f : ''); };
+// 计数:[start, start+dur] 内从 a 滚到 b;默认 expoOut(先快后慢,最后一位落定)。数字和动画只改「怎么出现」,不改口径。
+TY.count = (lt, start, dur, a, b, ease = MO.expoOut) => lerp(a, b, ease(clamp((lt - start) / dur)));
+// 等宽数字排布:canvas 开不了 tnum,滚动时数字宽度会抖,必须每个数字占同宽格子自己排。用调用方设好的 font/fillStyle。返回总宽
+TY.tabular = (c, str, x, y, { align = 'left', digitW } = {}) => {
+ const dw = digitW || c.measureText('0').width;
+ const ws = [...str].map(ch => /[0-9]/.test(ch) ? dw : c.measureText(ch).width);
+ const total = ws.reduce((s, w) => s + w, 0);
+ let cx = align === 'right' ? x - total : align === 'center' ? x - total / 2 : x;
+ const ta = c.textAlign; c.textAlign = 'center';
+ [...str].forEach((ch, i) => { c.fillText(ch, cx + ws[i] / 2, y); cx += ws[i]; });
+ c.textAlign = ta; return total;
+};
+})();
diff --git a/scripts/engine/lib/ui.js b/scripts/engine/lib/ui.js
new file mode 100644
index 0000000..8dbf8f1
--- /dev/null
+++ b/scripts/engine/lib/ui.js
@@ -0,0 +1,141 @@
+// 发布会式界面 UI:渐变光斑底(mesh gradient 近似)、毛玻璃卡片、伪 3D 透视(切片)、光扫过(sheen)、只画影子的投影、线性图标。
+// 约定:坐标是 1920×1080 屏幕坐标;所有动画参数由调用方用时间算好传进来,本库不读时钟。
+// 卡片展开成全屏、模糊推进是转场(transitions.js 的 expandRect / blurPush)。
+// 坑:blur 会从画布外拉进透明像素——画进不清空的离屏会逐帧累积(qa 确定性 ✗),所以先铺原图再叠模糊版;
+// 切片透视的条带取整像素首尾相接,别用「重叠 0.75px 防缝」,半透明下重叠处出竖纹。
+(() => {
+let W = 1920, H = 1080; U.onStage((w, h) => { W = w; H = h; }); // 画布尺寸跟 U.setStage 走(默认 1920×1080)
+const { clamp, lerp } = U;
+const UI = window.UI = {};
+const cvs = {};
+const scratch = (k, w, h) => { let c = cvs[k]; if (!c || c.width !== w || c.height !== h) { c = cvs[k] = document.createElement('canvas'); c.width = w; c.height = h; } return c; };
+UI.scratch = scratch;
+
+UI.rr = (c, x, y, w, h, r) => { c.beginPath(); c.roundRect(x, y, w, h, r); };
+UI.rrPath = (x, y, w, h, r) => { const p = new Path2D(); p.roundRect(x, y, w, h, r); return p; };
+
+// ---------- 渐变光斑底(mesh gradient 的廉价近似) ----------
+// 小画布上画几团径向渐变(screen 叠加)→ 小画布上模糊 → 放大铺满 → 叠静态颗粒防色带。
+// blobs: [{x,y,r,col:[r,g,b],a, ax,ay,period,ph}] 位置单位是屏幕像素,ax/ay 漂移振幅,period 秒
+UI.mesh = (c, t, { base = '#05060a', blobs = [], blur = 40, scale = 0.25, grain = 0.04, key = 'mesh' } = {}) => {
+ const sw = Math.round(W * scale), sh = Math.round(H * scale);
+ const a = scratch(key + 'a', sw, sh), g = a.getContext('2d');
+ g.globalCompositeOperation = 'source-over'; g.fillStyle = base; g.fillRect(0, 0, sw, sh);
+ g.globalCompositeOperation = 'screen';
+ for (const b of blobs) {
+ const w = 2 * Math.PI / (b.period || 10), ph = b.ph || 0;
+ const x = (b.x + (b.ax || 0) * Math.sin(w * t + ph)) * scale, y = (b.y + (b.ay || 0) * Math.cos(w * t * 0.83 + ph)) * scale, r = b.r * scale * (1 + 0.06 * Math.sin(w * t * 1.3 + ph));
+ const gr = g.createRadialGradient(x, y, 0, x, y, r);
+ const [R, G, B] = b.col, A = b.a == null ? 1 : b.a;
+ gr.addColorStop(0, `rgba(${R},${G},${B},${A})`); gr.addColorStop(0.45, `rgba(${R},${G},${B},${A * 0.45})`); gr.addColorStop(1, `rgba(${R},${G},${B},0)`);
+ g.fillStyle = gr; g.fillRect(0, 0, sw, sh);
+ }
+ const bb = scratch(key + 'b', sw, sh), gb = bb.getContext('2d');
+ // 先铺不模糊的原图再叠模糊版:blur 会从画布外拉进透明像素,边缘半透明——画进不清空的离屏会逐帧累积(qa 确定性 ✗ 就是这么来的)
+ gb.clearRect(0, 0, sw, sh); gb.drawImage(a, 0, 0); gb.filter = `blur(${blur * scale}px)`; gb.drawImage(a, 0, 0); gb.filter = 'none';
+ c.save(); c.imageSmoothingQuality = 'high'; c.drawImage(bb, 0, 0, W, H);
+ if (grain) { c.globalAlpha = grain; c.drawImage(UI.grainTex(), 0, 0); }
+ c.restore();
+};
+// 静态颗粒(种子固定):对抗 8bit 视频编码里大面积渐变的色带
+UI.grainTex = () => PAINT.cached('gl_grain' + W + 'x' + H, W, H, (g) => {
+ const r = U.rng(77), im = g.createImageData(W, H), d = im.data;
+ for (let i = 0; i < d.length; i += 4) { const v = r() * 255; d[i] = d[i + 1] = d[i + 2] = v; d[i + 3] = 255; }
+ g.putImageData(im, 0, 0);
+});
+
+// ---------- 背景的模糊副本(毛玻璃取样用) ----------
+UI.backdrop = (src, { scale = 0.25, blur = 28, key = 'bd' } = {}) => {
+ const sw = Math.round(W * scale), sh = Math.round(H * scale);
+ const a = scratch(key, sw, sh), g = a.getContext('2d');
+ g.clearRect(0, 0, sw, sh); g.drawImage(src, 0, 0, sw, sh); g.filter = `blur(${blur * scale}px)`; g.drawImage(src, 0, 0, sw, sh); g.filter = 'none'; // 同上:先垫原图防边缘透明
+ return a;
+};
+
+// ---------- 阴影(只画影子,不画形状本身:形状移到屏外,影子偏移回来) ----------
+UI.shadow = (c, x, y, w, h, r, { blur = 60, oy = 28, alpha = 0.45 } = {}) => {
+ c.save(); c.shadowColor = `rgba(0,0,0,${alpha})`; c.shadowBlur = blur; c.shadowOffsetX = 4000; c.shadowOffsetY = oy;
+ c.fillStyle = '#000'; UI.rr(c, x - 4000, y, w, h, r); c.fill(); c.restore();
+};
+
+// ---------- 毛玻璃卡片 ----------
+// bd = UI.backdrop(...) 的结果;sample = 取样的屏幕矩形(默认与卡片同位,卡片画进离屏纹理时要传屏幕位置)
+UI.glass = (c, { x, y, w, h, r = 28, bd, sample, tint = 0.07, stroke = 0.22, light = 0.16, shadow = true }) => {
+ if (shadow) UI.shadow(c, x, y, w, h, r, { blur: 70, oy: 30, alpha: 0.5 });
+ c.save(); UI.rr(c, x, y, w, h, r); c.clip();
+ if (bd) { const s = bd.width / W, S = sample || { x, y, w, h }; c.drawImage(bd, S.x * s, S.y * s, S.w * s, S.h * s, x, y, w, h); }
+ c.fillStyle = `rgba(255,255,255,${tint})`; c.fillRect(x, y, w, h);
+ // 顶部受光:上缘一道柔和亮带(玻璃的厚度感)
+ const g = c.createLinearGradient(0, y, 0, y + h * 0.5); g.addColorStop(0, `rgba(255,255,255,${light})`); g.addColorStop(1, 'rgba(255,255,255,0)');
+ c.fillStyle = g; c.fillRect(x, y, w, h * 0.5);
+ c.restore();
+ // 1px 描边:左上亮、右下暗(光从左上来)
+ c.save(); const sg = c.createLinearGradient(x, y, x + w, y + h);
+ sg.addColorStop(0, `rgba(255,255,255,${stroke * 1.8})`); sg.addColorStop(0.5, `rgba(255,255,255,${stroke * 0.5})`); sg.addColorStop(1, `rgba(255,255,255,${stroke})`);
+ c.strokeStyle = sg; c.lineWidth = 1.5; UI.rr(c, x + 0.75, y + 0.75, w - 1.5, h - 1.5, r); c.stroke(); c.restore();
+};
+
+// ---------- 光扫过(sheen) ----------
+// 在 clip 区域里让一道斜向亮带从左扫到右;p∈[0,1];band 宽 width;angle 弧度
+// comp:默认 'lighter'(叠在画面上);在只含文字的离屏上用 'source-atop'(光只落在字上)
+UI.sheen = (c, clipPath, p, { x0 = 0, x1 = W, width = 260, angle = -0.35, alpha = 0.32, col = '255,255,255', comp = 'lighter' } = {}) => {
+ if (p <= 0 || p >= 1) return;
+ const cx = lerp(x0 - width * 2, x1 + width * 2, p);
+ c.save(); if (clipPath) c.clip(clipPath);
+ c.globalCompositeOperation = comp;
+ c.translate(cx, H / 2); c.rotate(angle);
+ const g = c.createLinearGradient(-width, 0, width, 0);
+ g.addColorStop(0, `rgba(${col},0)`); g.addColorStop(0.5, `rgba(${col},${alpha})`); g.addColorStop(1, `rgba(${col},0)`);
+ c.fillStyle = g; c.fillRect(-width, -H * 1.5, width * 2, H * 3);
+ c.restore();
+};
+
+// ---------- 伪 3D:把一张纹理绕 Y 轴(竖条切片)或 X 轴(横条切片)转 ----------
+// tex: 卡片纹理(任意分辨率),屏幕中心 cx,cy,屏幕尺寸 w×h(未旋转时),ry/rx 弧度,persp 透视距离(px)
+// 远侧变暗 shade(0..1),模拟侧光。条宽 strip px。
+// 切片边界取整像素、首尾相接(不重叠也不留缝):重叠 0.75px 防缝的老办法,在半透明纹理/半透明绘制下重叠处透明度叠加,出一条条竖纹横纹。
+// 另外先画进离屏再整体按 alpha 贴回,整卡淡入淡出时也不出纹。
+UI.persp = (c0, tex, { cx, cy, w, h, ry = 0, rx = 0, persp = 1600, strip = 3, shade = 0.35, alpha = 1 }) => {
+ const sc = scratch('persp', W, H), c = sc.getContext('2d'); c.reset();
+ c.save();
+ const tw = tex.width, th = tex.height;
+ if (Math.abs(ry) >= Math.abs(rx)) {
+ const n = Math.max(8, Math.ceil(w / strip)), cs = Math.cos(ry), sn = Math.sin(ry);
+ const P = u => { const X = (u - 0.5) * w, z = X * sn, s = persp / (persp + z); return [cx + X * cs * s, s]; };
+ for (let i = 0; i < n; i++) {
+ const u0 = i / n, u1 = (i + 1) / n, [x0, s0] = P(u0), [x1, s1] = P(u1), s = (s0 + s1) / 2;
+ const hh = h * s, xa = Math.round(Math.min(x0, x1)), xb = Math.round(Math.max(x0, x1)); if (xb > xa) c.drawImage(tex, u0 * tw, 0, (u1 - u0) * tw, th, xa, cy - hh / 2, xb - xa, hh);
+ }
+ if (shade && ry) { // 转离观众的一侧暗一点
+ const [xa] = P(0), [xb] = P(1), g = c.createLinearGradient(xa, 0, xb, 0), k = Math.min(1, Math.abs(Math.sin(ry)) * 2) * shade;
+ g.addColorStop(0, `rgba(0,0,0,${ry > 0 ? 0 : k})`); g.addColorStop(1, `rgba(0,0,0,${ry > 0 ? k : 0})`);
+ c.globalCompositeOperation = 'source-atop'; c.fillStyle = g; c.fillRect(Math.min(xa, xb), cy - h, Math.abs(xb - xa), h * 2);
+ }
+ } else {
+ const n = Math.max(8, Math.ceil(h / strip)), cs = Math.cos(rx), sn = Math.sin(rx);
+ const P = v => { const Y = (v - 0.5) * h, z = -Y * sn, s = persp / (persp + z); return [cy + Y * cs * s, s]; };
+ for (let i = 0; i < n; i++) {
+ const v0 = i / n, v1 = (i + 1) / n, [y0, s0] = P(v0), [y1, s1] = P(v1), s = (s0 + s1) / 2;
+ const ww = w * s, ya = Math.round(Math.min(y0, y1)), yb = Math.round(Math.max(y0, y1)); if (yb > ya) c.drawImage(tex, 0, v0 * th, tw, (v1 - v0) * th, cx - ww / 2, ya, ww, yb - ya);
+ }
+ }
+ c.restore();
+ c0.save(); c0.globalAlpha *= alpha; c0.drawImage(sc, 0, 0); c0.restore();
+};
+
+// ---------- 线性图标(SF Symbols 气质:圆头、等线宽) ----------
+UI.icon = (c, kind, x, y, s, col, t = 0, lw = 0.075) => {
+ c.save(); c.translate(x, y); c.scale(s, s); c.strokeStyle = col; c.fillStyle = col; c.lineWidth = lw; c.lineCap = 'round'; c.lineJoin = 'round';
+ if (kind === 'wave') { // 语音:5 根会跳的竖条
+ const hs = [0.35, 0.7, 1, 0.6, 0.3];
+ hs.forEach((h0, i) => { const h = h0 * (0.75 + 0.25 * Math.sin(t * 7 + i * 1.3)); const xx = -0.4 + i * 0.2; c.beginPath(); c.moveTo(xx, -h * 0.45); c.lineTo(xx, h * 0.45); c.stroke(); });
+ } else if (kind === 'memory') { // 记忆:三层叠片
+ for (let k = 0; k < 3; k++) { const yy = -0.28 + k * 0.24 + 0.02 * Math.sin(t * 2 + k); c.beginPath(); c.moveTo(-0.45, yy); c.lineTo(0, yy - 0.18); c.lineTo(0.45, yy); c.lineTo(0, yy + 0.18); c.closePath(); c.globalAlpha = k === 0 ? 1 : 0.6; c.stroke(); }
+ } else if (kind === 'agent') { // 智能体:四角星 + 小星
+ const r = 0.42 * (1 + 0.05 * Math.sin(t * 3));
+ c.beginPath(); c.moveTo(0, -r); c.quadraticCurveTo(0, 0, r, 0); c.quadraticCurveTo(0, 0, 0, r); c.quadraticCurveTo(0, 0, -r, 0); c.quadraticCurveTo(0, 0, 0, -r); c.fill();
+ const r2 = 0.16; c.translate(0.36, -0.36); c.beginPath(); c.moveTo(0, -r2); c.quadraticCurveTo(0, 0, r2, 0); c.quadraticCurveTo(0, 0, 0, r2); c.quadraticCurveTo(0, 0, -r2, 0); c.quadraticCurveTo(0, 0, 0, -r2); c.globalAlpha = 0.7; c.fill();
+ }
+ c.restore();
+};
+})();
diff --git a/scripts/engine/lib/util.js b/scripts/engine/lib/util.js
new file mode 100644
index 0000000..3a78464
--- /dev/null
+++ b/scripts/engine/lib/util.js
@@ -0,0 +1,82 @@
+// 通用工具(最先加载,转场库与引擎共用)
+(() => {
+// ---------- 工具 ----------
+window.U = {
+ TAU: Math.PI * 2,
+ clamp: (x, a = 0, b = 1) => Math.max(a, Math.min(b, x)),
+ lerp: (a, b, p) => a + (b - a) * p,
+ // smoothstep:x 在 [a,b] 内平滑地从 0 走到 1(开场写出、渐显、段内节奏都用它)
+ ss: (a, b, x) => { const t = Math.max(0, Math.min(1, (x - a) / (b - a))); return t * t * (3 - 2 * t); },
+ // 把 p 的 [a,b] 段线性拉成 0..1(转场里分阶段用)
+ seg: (p, a, b) => Math.max(0, Math.min(1, (p - a) / (b - a))),
+ // 步进帧率:把连续时间量化成 fps 步——「一顿一顿」是很多风格的味道本身:
+ // 橡皮管卡通 12fps(一拍二)、皮影杆操 10fps、哈林跳舞小人 8fps 硬切、手绘线条沸腾 8–12fps、胶片层 24fps。
+ stepTime: (t, fps) => Math.floor(t * fps) / fps,
+ ease: {
+ linear: p => p,
+ inOut: p => p < .5 ? 4 * p * p * p : 1 - Math.pow(-2 * p + 2, 3) / 2,
+ out: p => 1 - Math.pow(1 - p, 3),
+ in: p => p * p * p,
+ outBack: p => { const c1 = 1.70158, c3 = c1 + 1; return 1 + c3 * Math.pow(p - 1, 3) + c1 * Math.pow(p - 1, 2); },
+ },
+ // 种子随机:mulberry32
+ rng(seed) { let a = seed >>> 0; return () => { a |= 0; a = a + 0x6D2B79F5 | 0; let t = Math.imul(a ^ a >>> 15, 1 | a); t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t; return ((t ^ t >>> 14) >>> 0) / 4294967296; }; },
+ hash(i, j = 0) { let h = (i * 374761393 + j * 668265263) | 0; h = (h ^ (h >>> 13)) * 1274126177; return ((h ^ (h >>> 16)) >>> 0) / 4294967296; },
+ // 点列 → Path2D(折线)
+ poly(pts, closed = true) { const p = new Path2D(); pts.forEach((q, i) => i ? p.lineTo(q[0], q[1]) : p.moveTo(q[0], q[1])); if (closed) p.closePath(); return p; },
+};
+
+// ---------- 字形检查 ----------
+// 字体文件缺某个字时浏览器会静默回退到系统字体:measureText 不报错、宽度也对,换台机器就变样(迁移测试 B、D:全角字母、▶、「戏」「蓝」都踩过)。
+// 做法:启动时(engine boot,字体加载完)把 FONT_FACES 里每个字体文件的 cmap 表读出来(WOFF1 用 DecompressionStream 解 zlib),查表判断有没有这个字。
+// 不用 measureText 对比回退字体:macOS 上 Chromium 的逐字回退以首选字体为基准挑系统字体,两种写法会落到不同字体上,缺字也测不出来(实测误判)。
+// font 可以是 family 名('LXGWWenKai-500')或 CSS 字体串('80px "LXGWWenKai-500"')。family 不在 FONT_FACES 里 → 当作全缺。
+const famOf = font => { const m = /"([^"]+)"/.exec(font) || /'([^']+)'/.exec(font); return m ? m[1] : String(font).replace(/^(italic\s+|bold\s+|\d+\s+)*[\d.]+px\s+/, '').trim(); };
+const CMAPS = {};
+const inflate = async (buf) => new Uint8Array(await new Response(new Blob([buf]).stream().pipeThrough(new DecompressionStream('deflate'))).arrayBuffer());
+async function readCmap(url) {
+ const ab = await (await fetch(url)).arrayBuffer(), dv = new DataView(ab), sig = dv.getUint32(0);
+ let tab = null;
+ if (sig === 0x774F4646) { // 'wOFF'
+ const n = dv.getUint16(12);
+ for (let i = 0; i < n; i++) { const o = 44 + i * 20; if (dv.getUint32(o) !== 0x636D6170) continue; // 'cmap'
+ const off = dv.getUint32(o + 4), comp = dv.getUint32(o + 8), orig = dv.getUint32(o + 12), raw = new Uint8Array(ab, off, comp);
+ tab = comp < orig ? await inflate(raw) : raw.slice(); }
+ } else { // 裸 TTF/OTF
+ const n = dv.getUint16(4);
+ for (let i = 0; i < n; i++) { const o = 12 + i * 16; if (dv.getUint32(o) === 0x636D6170) tab = new Uint8Array(ab, dv.getUint32(o + 8), dv.getUint32(o + 12)).slice(); }
+ }
+ if (!tab) throw new Error('没有 cmap 表');
+ const t = new DataView(tab.buffer, tab.byteOffset, tab.byteLength), set = new Set(), nt = t.getUint16(2);
+ for (let i = 0; i < nt; i++) {
+ const so = t.getUint32(4 + i * 8 + 4), fmt = t.getUint16(so);
+ if (fmt === 4) { const segX2 = t.getUint16(so + 6), ends = so + 14, starts = ends + segX2 + 2, deltas = starts + segX2, ros = deltas + segX2;
+ for (let k = 0; k < segX2 / 2; k++) { const e = t.getUint16(ends + k * 2), s = t.getUint16(starts + k * 2), d = t.getInt16(deltas + k * 2), ro = t.getUint16(ros + k * 2);
+ for (let ch = s; ch <= e && ch !== 0xFFFF; ch++) { let g; if (!ro) g = (ch + d) & 0xFFFF; else { g = t.getUint16(ros + k * 2 + ro + (ch - s) * 2); if (g) g = (g + d) & 0xFFFF; } if (g) set.add(ch); } } }
+ else if (fmt === 12 || fmt === 13) { const ng = t.getUint32(so + 12); for (let k = 0; k < ng; k++) { const o = so + 16 + k * 12, s = t.getUint32(o), e = t.getUint32(o + 4), g = t.getUint32(o + 8);
+ for (let ch = s; ch <= e; ch++) if (fmt === 13 ? g : g + ch - s) set.add(ch); } }
+ else if (fmt === 0) { for (let ch = 0; ch < 256; ch++) if (t.getUint8(so + 6 + ch)) set.add(ch); }
+ else if (fmt === 6) { const first = t.getUint16(so + 6), cnt = t.getUint16(so + 8); for (let k = 0; k < cnt; k++) if (t.getUint16(so + 10 + k * 2)) set.add(first + k); }
+ }
+ return set;
+}
+// 引擎 boot 里调用一次(字体加载之后)。读失败的字体记 console.error,不阻断启动。
+U.loadCmaps = async (faces = window.FONT_FACES || []) => {
+ await Promise.all(faces.map(async f => { try { CMAPS[f.family] = await readCmap(f.url); } catch (e) { console.error(`读不了字体 ${f.family} 的 cmap:${e}`); } }));
+};
+U.missingGlyphs = (font, text) => {
+ const fam = famOf(font), cm = CMAPS[fam];
+ const chars = [...new Set([...String(text)])].filter(ch => !/\s/.test(ch));
+ if (!cm) return chars;
+ return chars.filter(ch => !cm.has(ch.codePointAt(0)));
+};
+// 缺字就 console.error(qa.py / render.py 会把页面 console.error 当失败)。返回 true = 全都有。
+U.assertGlyphs = (font, text, where = '') => {
+ const fam = famOf(font), miss = U.missingGlyphs(font, text);
+ if (miss.length) console.error(!CMAPS[fam] ? `字体「${fam}」没注册或没读到 cmap(lib/fonts.js 的 FONT_FACES)${where ? '(' + where + ')' : ''}`
+ : `缺字形:字体「${fam}」里没有「${miss.join('')}」${where ? '(' + where + ')' : ''}——会静默回退系统字体。用 scripts/font_subset.py 补进子集,或改用路径自画。`);
+ return miss.length === 0;
+};
+U.fontFamily = famOf;
+
+})();
diff --git a/scripts/engine/reference_films/spacex/README.md b/scripts/engine/reference_films/spacex/README.md
new file mode 100644
index 0000000..3a8abdf
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/README.md
@@ -0,0 +1,25 @@
+# SpaceX口播动画参考代码
+
+包含混合风格、白板、Vox拼贴、讲解员四种表达的场景代码快照。用于学习并迁移镜头、关键词时间锚和布局方法,不是开箱可渲染的完整示范;不代表最新公开成片的完整工程。
+
+- `spacex/tm.js`:`TM.cue(段, '原文子串')`将动作挂到口播关键词;`timing.js`是这条示例的时间数据,做新题材时需要替换。
+- `spacex_wb/common.js`:内容取景`fit/declip/shot`、笔画调度`build`、按笔顺揭示`so/soAt`。
+- `spacex_vox/common.js`:累积桌面`item/drawWorld/camEnd`、插入镜头、遮挡登记。
+- `spacex_lin/common.js`:讲解员换帧、脚底锚点、跨段姿态和顶栏;`tools/prep_presenter.py`演示绿幕切帧。
+- `eras_*.js`:四种段落表;`transitions/`:配套转场。
+
+## 使用边界
+
+1. 先复制上层`scripts/engine/`到自己的工程,再将这里选中的片子目录、段落表和转场放到工程根对应位置。白板段落表文件名保留`eras_wbx.js`,实际素材路径统一为`spacex_wb/`。
+2. 讲解员sprite、混合版人物帧、源生图提示词和口播音频不随本快照分发。`presenter_meta.js`只提供帧表结构;需要用自己的角色重新生成素材和元数据。已有帧表不代表素材存在。
+3. 字体沿用上层工程`lib/fonts.js`及随包字体;Vox正文和打字机数字已分别改用随包霞鹜文楷与CMU,避免额外字体缺失,预处理脚本需`numpy`和`Pillow`;运行`make_hand.py`须先在其目录准备自己的`hand_raw_1.png`至`hand_raw_3.png`。
+4. 这里的示例文字和数字是历史创作素材,不是可直接引用的最新SpaceX事实资料。新作品需自行核实脚本,并重建口播时间轴。
+5. 如只想先运行完整示范,使用上层`demos/`或`clips/`,不要从本目录开始。
+
+## 第三方笔顺数据
+
+`spacex_wb/assets/strokes.js`取自hanzi-writer-data 2.0.1/Make Me a Hanzi的笔画中线;只保留示例所用字符的medians数组并包装为浏览器变量,不包括原始字形轮廓。该衍生数据沿用Arphic Public License,原文见同目录`ARPHICPL.TXT`,不属于本仓库MIT授权范围。
+
+上游:https://github.com/chanind/hanzi-writer-data/tree/v2.0.1
+原始数据项目:https://github.com/skishore/makemeahanzi
+许可原文:https://github.com/chanind/hanzi-writer-data/blob/master/ARPHICPL.TXT
diff --git a/scripts/engine/reference_films/spacex/eras_lin.js b/scripts/engine/reference_films/spacex/eras_lin.js
new file mode 100644
index 0000000..17603af
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/eras_lin.js
@@ -0,0 +1,6 @@
+// SpaceX 这 24 年 · 单风格版(lin)。段长来自 spacex/timing.js(与混合风格版同一条口播),勿手改段长。
+// 每段进入转场由该段 scene 文件写:ERAS.find(e => e.id === 'sXX').transition = { type, dur }(单风格片常用 same=同一画布相机运动即转场)。
+window.PUNCH = 0;
+window.SCENE_LIBS = ['spacex/timing.js', 'spacex/tm.js', 'spacex/rockets.js', 'transitions/lin_page.js', 'spacex_lin/presenter_meta.js', 'spacex_lin/common.js']; // 本片共用:翻页转场、讲解员帧表、LIN 库(讲解员+顶栏在 GLOBAL_OVERLAY)
+window.SCENE_DIR = 'spacex_lin/scenes';
+window.ERAS = ['s01','s02','s03','s04','s05','s06','s07','s08','s09','s10','s11','s12'].map(id => ({ id, get dur() { return TIMING.seg[id].dur; } }));
diff --git a/scripts/engine/reference_films/spacex/eras_spacex.js b/scripts/engine/reference_films/spacex/eras_spacex.js
new file mode 100644
index 0000000..9b2bac7
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/eras_spacex.js
@@ -0,0 +1,7 @@
+// SpaceX 这 24 年 · 段落表。段长来自 spacex/timing.js(按口播实测生成,勿手改);
+// 每段的进入转场由该段 scene 文件在加载时写:ERAS.find(e => e.id === 'sXX').transition = { type, dur }。
+window.PUNCH = 0;
+window.FPS_HINT = 30;
+window.SCENE_LIBS = ['spacex/timing.js', 'spacex/tm.js', 'spacex/rockets.js'];
+window.SCENE_DIR = 'spacex/scenes';
+window.ERAS = ['s01','s02','s03','s04','s05','s06','s07','s08','s09','s10','s11','s12'].map(id => ({ id, get dur() { return TIMING.seg[id].dur; } }));
diff --git a/scripts/engine/reference_films/spacex/eras_vox.js b/scripts/engine/reference_films/spacex/eras_vox.js
new file mode 100644
index 0000000..07c6596
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/eras_vox.js
@@ -0,0 +1,6 @@
+// SpaceX 这 24 年 · 单风格版(vox)。段长来自 spacex/timing.js(与混合风格版同一条口播),勿手改段长。
+// 每段进入转场由该段 scene 文件写:ERAS.find(e => e.id === 'sXX').transition = { type, dur }(单风格片常用 same=同一画布相机运动即转场)。
+window.PUNCH = 0;
+window.SCENE_LIBS = ['spacex/timing.js', 'spacex/tm.js', 'spacex/rockets.js', 'spacex_vox/common.js']; // 本片自己的共用脚本可追加到这里(如 'spacex_vox/common.js')
+window.SCENE_DIR = 'spacex_vox/scenes';
+window.ERAS = ['s01','s02','s03','s04','s05','s06','s07','s08','s09','s10','s11','s12'].map(id => ({ id, get dur() { return TIMING.seg[id].dur; } }));
diff --git a/scripts/engine/reference_films/spacex/eras_wbx.js b/scripts/engine/reference_films/spacex/eras_wbx.js
new file mode 100644
index 0000000..490bc50
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/eras_wbx.js
@@ -0,0 +1,7 @@
+// SpaceX 这 24 年 · 单风格版(wbx:白板参考实现)。段长来自 spacex/timing.js(与混合风格版同一条口播),勿手改段长。
+// 每段进入转场由该段 scene 文件写:ERAS.find(e => e.id === 'sXX').transition = { type, dur }(单风格片常用 same=同一画布相机运动即转场)。
+window.PUNCH = 0;
+window.SCENE_LIBS = ['spacex/timing.js', 'spacex/tm.js', 'spacex/rockets.js', 'spacex_wb/assets/strokes.js', 'spacex_wb/common.js']; // 本片自己的共用脚本可追加到这里(如 'spacex_wb/common.js')
+window.SCENE_DIR = 'spacex_wb/scenes';
+window.EXTRA_ASSETS = ['spacex_wb/assets/hand_1.png', 'spacex_wb/assets/hand_2.png', 'spacex_wb/assets/hand_3.png']; // 握笔手(gpt-image 线稿,绿幕抠图,见 assets/make_hand.py)
+window.ERAS = ['s01','s02','s03','s04','s05','s06','s07','s08','s09','s10','s11','s12'].map(id => ({ id, get dur() { return TIMING.seg[id].dur; } }));
diff --git a/scripts/engine/reference_films/spacex/spacex/rockets.js b/scripts/engine/reference_films/spacex/spacex/rockets.js
new file mode 100644
index 0000000..bf827ca
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex/rockets.js
@@ -0,0 +1,154 @@
+// SpaceX 短片共用:火箭/飞船/发射塔的通用几何(不含任何官方 logo、字样)。
+// 坐标:单位=米,原点=箭体底部(发动机喷口平面)中心,向上为 −y。调用方自己 translate/rotate/scale(px/m)。
+// 每个函数返回 { parts:[{k, p:Path2D}], h(总高 m), w(最大宽 m), a:{锚点} }。
+// k:'body' 主体(白漆/不锈钢)、'dark' 深色部件(级间段、栅格舵、着陆腿、发动机)、'nose' 头锥/整流罩、
+// 'window' 舷窗、'trunk' 龙飞船尾段、'flap' 星舰襟翼、'engine' 发动机喷管。
+// 风格怎么画由各 scene 决定:RK.fill(c, shape, palette) 是最朴素的平涂,各风格可以只拿 parts 自己处理。
+// 比例按真实外形(约数):猎鹰1 21×1.7m;猎鹰9 70×3.7m;重型猎鹰三芯并联;星舰全箭 ~123×9m(超重 71m+飞船 52m)。
+window.RK = (() => {
+ const rect = (p, x, y, w, h) => p.rect(x, y, w, h);
+ const P2 = () => new Path2D();
+ const poly = (pts) => { const p = P2(); pts.forEach(([x, y], i) => i ? p.lineTo(x, y) : p.moveTo(x, y)); p.closePath(); return p; };
+ // 尖拱头锥(ogive):底宽 w、高 h,底边 y0
+ const ogive = (w, h, y0, n = 18) => { const pts = []; for (let i = 0; i <= n; i++) { const u = i / n; pts.push([-w / 2 * Math.sqrt(1 - u * u) * (1 - 0.15 * u), y0 - h * u]); }
+ for (let i = n; i >= 0; i--) { const u = i / n; pts.push([w / 2 * Math.sqrt(1 - u * u) * (1 - 0.15 * u), y0 - h * u]); } return poly(pts); };
+ const bell = (x, y, w, h) => poly([[x - w * 0.28, y - h], [x + w * 0.28, y - h], [x + w / 2, y], [x - w / 2, y]]);
+
+ // 猎鹰1:单级细长箭体+二级+小整流罩(2006–2008)
+ function falcon1() {
+ const D = 1.7, parts = [];
+ const body = P2(); rect(body, -D / 2, -15.5, D, 15.5); rect(body, -D / 2 * 0.95, -19.5, D * 0.95, 3.6); parts.push({ k: 'body', p: body });
+ const dark = P2(); rect(dark, -D / 2, -16.1, D, 0.6); rect(dark, -D / 2, -1.2, D, 1.2); parts.push({ k: 'dark', p: dark });
+ parts.push({ k: 'nose', p: ogive(D * 0.95, 3.2, -19.5) });
+ parts.push({ k: 'engine', p: bell(0, 0.9, 1.2, 0.9) });
+ return { parts, h: 22.7, w: D, a: { top: [0, -22.7], base: [0, 0.9] } };
+ }
+
+ // 猎鹰9:opts.payload = 'fairing' | 'dragon' | 'none';opts.legs 0..1 着陆腿展开;opts.fins 0..1 栅格舵展开;opts.stage = 'full' | 'booster'
+ function falcon9(o = {}) {
+ const D = 3.7, parts = [], legs = o.legs ?? 0, fins = o.fins ?? 0, booster = o.stage === 'booster';
+ const H1 = 41; // 一级(含级间段)
+ const body = P2(); rect(body, -D / 2, -H1, D, H1);
+ if (!booster) rect(body, -D / 2, -H1 - 13, D, 13);
+ parts.push({ k: 'body', p: body });
+ const dark = P2();
+ rect(dark, -D / 2, -H1, D, 4.2); // 黑色级间段
+ rect(dark, -D / 2, -1.4, D, 1.4); // 底部发动机罩
+ parts.push({ k: 'dark', p: dark });
+ // 栅格舵(顶部四片,侧视两片):展开时向外翻出
+ const gf = P2(), fy = -H1 + 0.6, fl = 1.0 + fins * 0.9;
+ rect(gf, -D / 2 - fl, fy, fl, 1.4); rect(gf, D / 2, fy, fl, 1.4); parts.push({ k: 'dark', p: gf });
+ // 着陆腿:铰接在箭体底部,收起时贴着箭体朝上,展开时向下外翻,脚落在发动机喷口平面略下方(legs=1 时脚底 y≈+1.3)
+ const lg = P2(), L = 9.5, ang = legs * 1.82;
+ for (const s of [-1, 1]) { const x0 = s * D / 2, y0 = -1.2, x1 = x0 + s * Math.sin(ang) * L, y1 = y0 - Math.cos(ang) * L;
+ lg.moveTo(x0, y0); lg.lineTo(x0, y0 - 0.6); lg.lineTo(x1 + s * 0.15, y1 - 0.2); lg.lineTo(x1 + s * 0.45, y1 + 0.3); lg.lineTo(x1 - s * 0.35, y1 + 0.3); lg.closePath(); }
+ parts.push({ k: 'dark', p: lg });
+ parts.push({ k: 'engine', p: bell(0, 1.0, 2.6, 1.0) });
+ let h = H1;
+ if (!booster) {
+ if (o.payload === 'dragon') { const dr = dragon({ trunk: true }); dr.parts.forEach(q => { const p = P2(); p.addPath(q.p, new DOMMatrix().translate(0, -H1 - 13)); parts.push({ k: q.k, p }); }); h = H1 + 13 + dr.h; }
+ else if (o.payload !== 'none') { const f = P2(); rect(f, -2.6, -H1 - 13 - 6.5, 5.2, 6.5); parts.push({ k: 'nose', p: f }); parts.push({ k: 'nose', p: ogive(5.2, 6.5, -H1 - 13 - 6.5) }); h = H1 + 26; }
+ else h = H1 + 13;
+ }
+ return { parts, h, w: D, a: { top: [0, -h], base: [0, 1.0], interstage: [0, -H1], legs: [0, -9.5] } };
+ }
+
+ // 龙飞船(载人龙外形:截锥舱体+尾段 trunk),底部在 y=0
+ function dragon(o = {}) {
+ const parts = [], tr = o.trunk !== false, y0 = tr ? -2.8 : 0;
+ if (tr) { const t = P2(); rect(t, -1.85, -2.8, 3.7, 2.8); parts.push({ k: 'trunk', p: t }); }
+ parts.push({ k: 'body', p: poly([[-1.95, y0], [1.95, y0], [1.25, y0 - 3.6], [-1.25, y0 - 3.6]]) });
+ const nose = P2(); nose.ellipse(0, y0 - 3.6, 1.25, 0.75, 0, Math.PI, 0); parts.push({ k: 'nose', p: nose });
+ const win = P2(); for (const x of [-0.75, 0.75]) { win.moveTo(x + 0.28, y0 - 2.0); win.ellipse(x, y0 - 2.0, 0.28, 0.32, 0, 0, Math.PI * 2); } parts.push({ k: 'window', p: win });
+ const h = (tr ? 2.8 : 0) + 4.35;
+ return { parts, h, w: 3.9, a: { top: [0, -h], port: [0, -h] } };
+ }
+
+ // 重型猎鹰:三个一级并排+中芯二级+整流罩;opts 同 falcon9
+ function heavy(o = {}) {
+ const parts = [], D = 3.7, gap = 0.35;
+ const c = falcon9({ ...o, payload: o.payload || 'fairing' });
+ c.parts.forEach(q => parts.push(q));
+ for (const s of [-1, 1]) {
+ const sb = falcon9({ ...o, stage: 'booster' });
+ const m = new DOMMatrix().translate(s * (D + gap), 0);
+ sb.parts.forEach(q => { const p = P2(); p.addPath(q.p, m); parts.push({ k: q.k, p }); });
+ const cone = P2(); cone.addPath(ogive(D, 4.5, -41), m); parts.push({ k: 'nose', p: cone });
+ }
+ return { parts, h: c.h, w: 3 * D + 2 * gap, a: { top: [0, -c.h], base: [0, 1.0] } };
+ }
+
+ // 超重助推器(Super Heavy):9m 直径不锈钢,顶部热分离环+四片栅格舵(侧视两片)
+ function superHeavy(o = {}) {
+ const D = 9, H = 71, parts = [];
+ const b = P2(); rect(b, -D / 2, -H, D, H); parts.push({ k: 'body', p: b });
+ const d = P2(); rect(d, -D / 2, -H, D, 1.8); for (let i = 0; i < 6; i++) rect(d, -D / 2 + 0.6 + i * 1.35, -H + 0.3, 0.7, 1.2); // 热分离环(镂空格)
+ rect(d, -D / 2 - 2.6 * (o.fins ?? 1), -H + 3.5, 2.6 * (o.fins ?? 1), 2.2); rect(d, D / 2, -H + 3.5, 2.6 * (o.fins ?? 1), 2.2); // 栅格舵
+ parts.push({ k: 'dark', p: d });
+ // 接驳销(被「筷子」接住的位置),在栅格舵下方两侧
+ const pin = P2(); rect(pin, -D / 2 - 0.9, -H + 7.2, 0.9, 0.8); rect(pin, D / 2, -H + 7.2, 0.9, 0.8); parts.push({ k: 'dark', p: pin });
+ const eng = P2(); for (let i = -3; i <= 3; i++) { eng.addPath(bell(i * 1.2, 1.2, 1.1, 1.2)); } parts.push({ k: 'engine', p: eng });
+ return { parts, h: H, w: D, a: { top: [0, -H], base: [0, 1.2], pins: [0, -H + 7.6] } };
+ }
+
+ // 星舰飞船(Ship):不锈钢圆柱+尖拱头锥+前后两对襟翼(侧视各两片)
+ function ship(o = {}) {
+ const D = 9, H = 52, Hc = 36, parts = [], fl = o.flap ?? 0; // flap:襟翼摆角(弧度,±0.6)
+ const b = P2(); rect(b, -D / 2, -Hc, D, Hc); parts.push({ k: 'body', p: b });
+ parts.push({ k: 'nose', p: ogive(D, H - Hc, -Hc) });
+ const f = P2();
+ for (const s of [-1, 1]) {
+ const fx = s * D / 2; // 后襟翼(大)
+ const aft = [[fx, -2], [fx + s * 3.2, -1 + Math.sin(fl) * 2], [fx + s * 3.2, -9 + Math.sin(fl) * 2], [fx, -11]];
+ f.addPath(poly(aft));
+ const fw = [[s * D * 0.42, -Hc - 6], [s * (D * 0.42 + 2.2), -Hc - 5 + Math.sin(-fl) * 1.5], [s * (D * 0.38 + 2.0), -Hc - 11 + Math.sin(-fl) * 1.5], [s * D * 0.36, -Hc - 12]];
+ f.addPath(poly(fw));
+ }
+ parts.push({ k: 'flap', p: f });
+ const eng = P2(); for (let i = -1; i <= 1; i++) eng.addPath(bell(i * 2.4, 1.6, 2.0, 1.6)); parts.push({ k: 'engine', p: eng });
+ const tiles = P2(); rect(tiles, -D / 2, -Hc, D * 0.32, Hc); parts.push({ k: 'tiles', p: tiles }); // 迎风面黑色隔热瓦(左半)
+ return { parts, h: H, w: D, a: { top: [0, -H], base: [0, 1.6] } };
+ }
+
+ // 全箭:超重+飞船叠放
+ function starship(o = {}) {
+ const sh = superHeavy(o), sp = ship(o), parts = [...sh.parts];
+ const m = new DOMMatrix().translate(0, -sh.h);
+ sp.parts.forEach(q => { if (q.k === 'engine') return; const p = P2(); p.addPath(q.p, m); parts.push({ k: q.k, p }); });
+ return { parts, h: sh.h + sp.h, w: 9, a: { top: [0, -(sh.h + sp.h)], base: [0, 1.2], stage: [0, -sh.h] } };
+ }
+
+ // 发射塔(「机甲哥斯拉」):桁架塔+两只「筷子」机械臂。opts.armY 臂所在高度(m,向上为正),opts.open 0..1 张开角
+ function tower(o = {}) {
+ const H = 146, Wt = 12, parts = [], armY = o.armY ?? 70, open = o.open ?? 0;
+ const t = P2(); rect(t, 0, -H, Wt, H); parts.push({ k: 'body', p: t });
+ const lat = P2(); // 桁架斜撑(细线,作为 dark 填充的细条)
+ for (let y = 0; y < H; y += 8) { lat.moveTo(0, -y); lat.lineTo(Wt, -y - 8); lat.lineTo(Wt, -y - 7.4); lat.lineTo(0.6, -y); lat.closePath(); }
+ parts.push({ k: 'truss', p: lat });
+ const arm = P2(), L = o.len ?? 30; // 两只臂从塔左侧伸出(略俯视的 V 字):open=0 合拢夹住,1 张开
+ for (const s of [-1, 1]) {
+ const y0 = -armY, dy = s * (1.3 + open * 5.5);
+ arm.moveTo(0, y0 + s * 1.3 - 1.1); arm.lineTo(-L, y0 + dy - 0.9); arm.lineTo(-L, y0 + dy + 0.9); arm.lineTo(0, y0 + s * 1.3 + 1.1); arm.closePath();
+ }
+ parts.push({ k: 'dark', p: arm });
+ return { parts, h: H, w: Wt, a: { top: [Wt / 2, -H], armRoot: [0, -armY], armTip: [-L, -armY] } };
+ }
+
+ // 尾焰:在 (x, y) 向下(局部 +y)喷 len 长,w 宽;t 驱动闪烁(确定性);pal = [外, 中, 芯]
+ function flame(c, x, y, len, w, t, pal = ['rgba(255,120,30,0.85)', 'rgba(255,200,80,0.95)', '#fff6d8'], seed = 0) {
+ const fl = (k) => 1 + 0.08 * Math.sin(t * 37 + k + seed) + 0.05 * Math.sin(t * 61 + 2 * k + seed);
+ const layer = (sc, col, k) => { const L = len * sc * fl(k), ww = w * (0.55 + 0.45 * sc);
+ c.fillStyle = col; c.beginPath(); c.moveTo(x - ww / 2, y); c.quadraticCurveTo(x - ww * 0.55, y + L * 0.45, x, y + L); c.quadraticCurveTo(x + ww * 0.55, y + L * 0.45, x + ww / 2, y); c.closePath(); c.fill(); };
+ layer(1, pal[0], 1); layer(0.66, pal[1], 2); layer(0.36, pal[2], 3);
+ }
+
+ // 朴素平涂:pal = {body, dark, nose, window, trunk, flap, engine, tiles, truss, line?, lw?}
+ function fill(c, shape, pal) {
+ for (const q of shape.parts) { const col = pal[q.k] ?? pal.body; if (!col) continue; c.fillStyle = col; c.fill(q.p); }
+ if (pal.line) { c.lineWidth = pal.lw || 0.25; c.strokeStyle = pal.line; c.lineJoin = 'round'; for (const q of shape.parts) if (q.k !== 'truss') c.stroke(q.p); }
+ }
+ // 放置:在屏幕 (x, y) 处、以 px/m 缩放、旋转 rot(弧度,0=竖直向上)画 fn(c)
+ function at(c, x, y, s, rot, fn) { c.save(); c.translate(x, y); c.rotate(rot || 0); c.scale(s, s); fn(c); c.restore(); }
+
+ return { falcon1, falcon9, dragon, heavy, superHeavy, ship, starship, tower, flame, fill, at, ogive, poly };
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex/scenes/s01.js b/scripts/engine/reference_films/spacex/spacex/scenes/s01.js
new file mode 100644
index 0000000..c9cc01e
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex/scenes/s01.js
@@ -0,0 +1,211 @@
+// S01 · 动态文字(y5 kinetic type)· 全片开场 hook。语法卡 references/动画语法/y5_kinetic_type.md
+// 字就是演员:每个关键词踩口播砸进来(TM.cue),一屏一个焦点;字落定后不动,动的是镜头微漂、背景点阵、火箭和尾焰。
+// 四个底色=四章:藏青(连败三次/最后一发)→ 黄(9.28 成了/18 年后同一天/尺寸对比)→ 珊瑚(24 年标题卡)。
+// 章内换页是画面里的东西带出来的:最后一枚火箭点火,尾焰处长出黄色圆把藏青吃掉;星舰升空,镜头跟着往上推到标题卡。
+(() => {
+const W = 1920, H = 1080, ID = 's01';
+const { clamp, lerp } = U;
+const C = { navy: '#14213D', yel: '#FFD23F', coral: '#FF5A36', ink: '#111111', white: '#FFFFFF', dim: '#56607A' };
+const F1 = RK.falcon1(), SS = RK.starship();
+let Q = null;
+const cues = () => Q || (Q = {
+ spx: TM.cue(ID, 'SpaceX'), lian: TM.cue(ID, '连败三次'), x3: TM.cue(ID, '次,'),
+ qian: TM.cue(ID, '钱只够'), zuihou: TM.cue(ID, '最后一发'), yifa: TM.cue(ID, '一发。'),
+ d928: TM.cue(ID, '9月28号'), cheng: TM.cue(ID, '成了'), n18: TM.cue(ID, '18年'), tyt: TM.cue(ID, '同一天'),
+ xj: TM.cue(ID, '星舰'), jr: TM.cue(ID, '进入了地球轨道'), lfz: TM.cue(ID, '两分钟'), kw: TM.cue(ID, '看完'),
+ n24: TM.cue(ID, '24年'), voEnd: TM.vo(ID)[1],
+});
+const exitK = (lt, t0) => MO.expoIn(clamp((lt - t0) / 0.18)); // 退场比入场快:0.18s expoIn
+
+// ---------- 小工具 ----------
+// 背景点阵:64px 网格斜向慢移(屏幕空间,持续运动,不和字抢)
+const dots = (c, t, col, a) => {
+ const g = 64, ox = (t * 36) % g, oy = (t * 18) % g;
+ c.save(); c.globalAlpha = a; c.fillStyle = col; c.beginPath();
+ for (let y = -g; y < H + g; y += g) for (let x = -g; x < W + g; x += g) { c.moveTo(x + ox + 4, y + oy); c.arc(x + ox, y + oy, 4, 0, 7); }
+ c.fill(); c.restore();
+};
+// 火箭剪影:shape 来自 RK,x,y = 箭底中心,hpx = 箭高(像素),深色部件用 dark
+const sil = (c, shape, x, y, hpx, rot, col, dark, alpha = 1) => {
+ if (alpha <= 0) return;
+ c.save(); c.globalAlpha *= alpha;
+ RK.at(c, x, y, hpx / shape.h, rot, g => { for (const q of shape.parts) { g.fillStyle = (q.k === 'dark' || q.k === 'engine' || q.k === 'tiles') ? (dark || col) : col; g.fill(q.p); } });
+ c.restore();
+};
+const flame = (c, x, y, hpx, rot, len, w, t, pal, seed) => {
+ c.save(); c.translate(x, y); c.rotate(rot || 0); RK.flame(c, 0, hpx * 0.04, len, w, t, pal, seed); c.restore();
+};
+// 红叉:两笔粗圆头线,从 1.7 倍砸到 1
+const cross = (c, x, y, s, lt, col) => {
+ if (lt < 0) return; const k = MO.springHz(lt, 2.4, 10), sc = lerp(1.8, 1, k);
+ c.save(); c.globalAlpha *= clamp(lt / 0.05); c.translate(x, y); c.scale(sc, sc); c.rotate(-0.06);
+ c.strokeStyle = col; c.lineCap = 'round'; c.lineWidth = s * 0.2;
+ c.beginPath(); c.moveTo(-s / 2, -s / 2); c.lineTo(s / 2, s / 2); c.moveTo(s / 2, -s / 2); c.lineTo(-s / 2, s / 2); c.stroke(); c.restore();
+};
+// 砸入时整个画面跟着冲一下(School of Motion:撞击时合成放大再回 100%)
+const hit = (lt, ts) => { let z = 0; for (const s of ts) { const d = lt - s; if (d >= 0 && d < 0.4) z += 0.018 * Math.exp(-d * 14); } return 1 + z; };
+const cam = (c, t, z, fn, oy = 0) => {
+ const [dx, dy] = CAM.drift(t, 5, 2);
+ CAM.with(c, { x: 960 + dx, y: 540 + dy - oy, z, r: 0.006 * Math.sin(t * 0.8) }, fn);
+};
+
+// ---------- 镜头里的东西 ----------
+// 三枚失败的猎鹰1号:章一大(545px)站右侧,章二缩成一排(330px)
+const rk3 = (lt) => {
+ const q = cues(), m = MO.expoInOut(clamp((lt - q.qian + 0.02) / 0.42));
+ return [0, 1, 2].map(i => ({ x: lerp(1240 + i * 190, 1250 + i * 112, m), y: lerp(850, 800, m), h: lerp(545, 330, m) }));
+};
+// 第四枚(最后一发):最后一发砸进来时出现,「一发」点火,起飞;藏青→黄的圆从它的尾焰长出来;在黄底继续爬升出画
+const R4X = 1650;
+const rk4 = (lt) => {
+ const q = cues(), L0 = q.yifa + 0.06, u = Math.max(0, lt - L0);
+ const h = lerp(330, 430, MO.expoOut(clamp(u / 0.5)));
+ return { x: R4X - 60 * MO.smooth(clamp(u / 1.5)), y: 800 - 150 * Math.pow(u, 1.6) - 18 * u, h, u, fire: lt > q.yifa ? clamp((lt - q.yifa) / 0.1) : 0 };
+};
+
+// 章一+章二(藏青)
+function navyLayer(c, lt, t) {
+ const q = cues();
+ const ex1 = exitK(lt, q.qian - 0.12);
+ // 「2008」:第 0 帧就在砸(开场不留空白)
+ if (ex1 < 1) {
+ c.save(); c.globalAlpha = 1 - ex1; c.translate(0, 60 * ex1);
+ TY.slam(c, '2008', 150, 600, lt + 0.05, { size: 330, color: C.white });
+ TY.rise(c, '连败三次', 158, 790, MO.at(lt, q.lian, 0.32), { size: 130, fam: 'PuHui-Heavy', color: C.coral });
+ c.restore();
+ }
+ // 章二:「钱只够再打」→「最后一发」
+ TY.rise(c, '钱只够再打', 152, 360, MO.at(lt, q.qian + 0.06, 0.32), { size: 100, fam: 'PuHui-Heavy', color: 'rgba(255,255,255,.75)' });
+ TY.slam(c, '最后一发', 150, 650, lt - q.zuihou, { size: 250, color: C.white });
+ if (lt > q.zuihou + 0.12) TY.marker(c, 150, 676, 1000, 18, MO.at(lt, q.zuihou + 0.12, 0.3), C.yel, 0.6);
+ // 三枚失败:先一枚枚弹上来,「连败三次」三个红叉一个接一个砸下,被砸中的火箭熄灭变灰、歪一下
+ const R = rk3(lt), popT = [q.spx, q.spx + 0.22, q.spx + 0.44], xT = [q.lian, (q.lian + q.x3) / 2, q.x3];
+ R.forEach((r, i) => {
+ // 第 0 帧就站在台上(暗剪影);念到「SpaceX的火箭」时一枚枚亮起、弹一下
+ const p = MO.at(lt, popT[i], 0.38), on = MO.expoOut(clamp(p * 2.5)), sc = p > 0 ? MO.backOut(p, 2.6) * 0.12 + 0.88 : 0.88;
+ const dead = MO.expoOut(clamp((lt - xT[i]) / 0.25)), tilt = dead * (i - 1 || 0.5) * 0.08;
+ const lit = DG.mix('#2A3656', C.white, on), col = dead > 0 ? DG.mix(lit, C.dim, dead) : lit;
+ const dk = DG.mix(DG.mix('#222C47', '#C9D2E6', on), '#3A4560', dead);
+ c.save(); c.translate(r.x, r.y); c.scale(sc, sc); c.translate(-r.x, -r.y);
+ sil(c, F1, r.x, r.y, r.h, tilt, col, dk);
+ c.restore();
+ if (p <= 0) return;
+ cross(c, r.x + Math.sin(tilt) * r.h * 0.45, r.y - r.h * 0.46, r.h * 0.38, lt - xT[i], C.coral);
+ });
+ // 第四枚:和「最后一发」同时弹出,带一圈黄色计数环;「一发」点火
+ const p4 = MO.at(lt, q.zuihou + 0.1, 0.4);
+ if (p4 > 0) {
+ const r = rk4(lt), s = MO.backOut(p4, 2.4);
+ if (r.u <= 0) { c.save(); c.globalAlpha = clamp(p4 * 3); c.strokeStyle = C.yel; c.lineWidth = 8; c.setLineDash([18, 14]); c.lineDashOffset = -t * 40;
+ c.beginPath(); c.arc(r.x, r.y - r.h * 0.5, r.h * 0.42 * s, 0, 7); c.stroke(); c.restore(); }
+ if (r.fire > 0) flame(c, r.x, r.y, r.h, 0, r.h * (0.25 + 0.5 * clamp(r.u / 0.3)) * r.fire, r.h * 0.07, t, ['rgba(255,90,54,.9)', 'rgba(255,210,63,.95)', '#ffffff'], 7);
+ c.save(); c.translate(r.x, r.y); c.scale(s, s); c.translate(-r.x, -r.y); sil(c, F1, r.x, r.y, r.h, 0, C.white, '#C9D2E6', clamp(p4 * 3)); c.restore();
+ }
+}
+
+// 章三+章四(黄)
+function yellowLayer(c, lt, t) {
+ const q = cues();
+ // 年份:2008 落定 → 「整整18年后」像里程表滚到 2026(日期 9.28 不动)
+ const pY = MO.at(lt, q.d928 + 0.16, 0.35);
+ if (pY > 0) {
+ const roll = clamp((lt - (q.n18 - 0.14)) / 0.62);
+ c.save(); c.globalAlpha = clamp(pY * 3);
+ c.beginPath(); c.rect(100, 160, 900, 260); c.clip();
+ const e = MO.expoOut(pY); c.translate(0, 230 * (1 - e));
+ U.odometer(c, { x: 156, y: 380, size: 210, font: '"PuHui-Black"', color: C.ink, fromStr: '2008', toStr: roll > 0 ? '2026' : '2008', align: 'left', stagger: 0.18 }, roll);
+ c.restore();
+ }
+ // 「18年后」珊瑚药丸:跟着「18」弹出
+ { const p = MO.at(lt, q.n18, 0.36); if (p > 0) { const s = MO.backOut(p, 2.6); c.save(); c.translate(860, 300); c.scale(s, s); c.rotate(-0.05);
+ c.fillStyle = C.coral; c.beginPath(); c.roundRect(-10, -70, 330, 116, 58); c.fill();
+ TY.text(c, '18年后', 155, 15, { size: 76, fam: 'PuHui-Heavy', color: C.white }); c.restore(); } }
+ // 主词「9.28」
+ TY.slam(c, '9.28', 140, 760, lt - q.d928, { size: 400, color: C.ink });
+ // 「同一天」:9.28 下面一道珊瑚下划线+标签
+ if (lt > q.tyt) {
+ TY.underline(c, 160, 800, 700, MO.at(lt, q.tyt, 0.3), C.coral, 16);
+ TY.rise(c, '同一天', 160, 900, MO.at(lt, q.tyt + 0.08, 0.32), { size: 84, fam: 'PuHui-Heavy', color: C.ink });
+ }
+ // 那一发:在黄底继续爬升出画(「成了」)
+ const r = rk4(lt);
+ if (r.y + 600 > 0 && lt < q.n18) {
+ flame(c, r.x, r.y, r.h, 0, r.h * (0.75 + 0.15 * Math.sin(t * 9)), r.h * 0.08, t, ['rgba(255,90,54,.95)', 'rgba(255,255,255,.95)', '#ffffff'], 7);
+ sil(c, F1, r.x, r.y, r.h, 0, C.ink, '#3b3320');
+ }
+ // 「成了」:珊瑚印章砸下,盖在 9.28 右上
+ { const p = lt - q.cheng, ex = exitK(lt, q.n18 - 0.3);
+ if (p > 0 && ex < 1) { const k = MO.springHz(p, 2.6, 11), s = lerp(2.0, 1, k) * (1 - 0.4 * ex);
+ c.save(); c.globalAlpha = clamp(p / 0.05) * (1 - ex); c.translate(1150, 470); c.rotate(-0.12); c.scale(s, s);
+ c.fillStyle = C.coral; c.beginPath(); c.roundRect(-190, -110, 380, 200, 26); c.fill();
+ c.strokeStyle = C.white; c.lineWidth = 8; c.beginPath(); c.roundRect(-172, -92, 344, 164, 18); c.stroke();
+ TY.text(c, '成了', 0, 48, { size: 140, fam: 'PuHui-Black', color: C.white }); c.restore(); } }
+ // 尺寸对比:「星舰」——小小的猎鹰1号旁边,巨大的星舰升起来(按 RK 真实比例:22.7m : 124m)
+ if (lt > q.xj - 0.1) {
+ const GY = 812, pxm = 5.4, pG = MO.at(lt, q.xj - 0.1, 0.35);
+ c.save(); c.strokeStyle = C.ink; c.lineWidth = 6; c.lineCap = 'round'; c.beginPath(); c.moveTo(1180, GY); c.lineTo(1180 + 640 * MO.expoOut(pG), GY); c.stroke(); c.restore();
+ const pf = MO.at(lt, q.xj, 0.35), ps = MO.at(lt, q.xj + 0.1, 0.55);
+ c.save(); c.beginPath(); c.rect(0, -2000, W, GY - 3 + 2000); c.clip();
+ sil(c, F1, 1290, GY + (1 - MO.backOut(pf, 2)) * 140, F1.h * pxm, 0, C.ink, '#3b3320', clamp(pf * 4));
+ // 「进入地球轨道」:星舰点火、加速升空、略向右转出画
+ const u = Math.max(0, lt - q.jr), sy = GY + (1 - MO.expoOut(ps)) * 720 - (300 * u + 1500 * u * u), rot = 0.1 * u * u;
+ if (ps > 0) {
+ if (u > 0) flame(c, 1580 + 120 * u * u, sy, SS.h * pxm, rot, 140 + 900 * clamp(u / 0.5), 70, t, ['rgba(255,90,54,.95)', 'rgba(255,255,255,.95)', '#ffffff'], 3);
+ sil(c, SS, 1580 + 120 * u * u, sy, SS.h * pxm, rot, C.ink, '#3b3320');
+ }
+ c.restore();
+ TY.rise(c, '猎鹰1号 · 2008', 1290, 878, MO.at(lt, q.xj + 0.05, 0.3), { size: 40, fam: 'PuHui-Bold', color: C.ink, align: 'center' });
+ TY.rise(c, '星舰 · 2026', 1600, 878, MO.at(lt, q.xj + 0.2, 0.3), { size: 40, fam: 'PuHui-Bold', color: C.ink, align: 'center' });
+ }
+}
+
+// 章五(珊瑚):标题卡
+function coralLayer(c, lt, t) {
+ const q = cues();
+ TY.rise(c, 'SpaceX', 960, 300, MO.at(lt, q.lfz + 0.22, 0.34), { size: 72, fam: 'PuHui-Heavy', color: C.ink, align: 'center', track: 14 });
+ // 时间线 2002 ——— 2026
+ const p = MO.at(lt, q.kw - 0.3, 0.7), x0 = 520, x1 = 1400, y = 760;
+ if (p > 0) {
+ c.save(); c.strokeStyle = C.ink; c.lineWidth = 10; c.lineCap = 'round';
+ c.beginPath(); c.moveTo(x0, y); c.lineTo(lerp(x0, x1, MO.expoOut(p)), y); c.stroke();
+ const d0 = MO.backOut(MO.at(lt, q.kw - 0.3, 0.3), 2.6), d1 = MO.backOut(MO.at(lt, q.kw + 0.25, 0.3), 2.6);
+ c.fillStyle = C.ink; c.beginPath(); c.arc(x0, y, 20 * d0, 0, 7); c.fill(); c.beginPath(); c.arc(x1, y, 20 * Math.max(0, d1), 0, 7); c.fill(); c.restore();
+ TY.pop(c, '2002', x0, 850, MO.at(lt, q.kw - 0.25, 0.32), { size: 64, fam: 'PuHui-Black', color: C.ink, over: 2.4 });
+ TY.pop(c, '2026', x1, 850, MO.at(lt, q.kw + 0.3, 0.32), { size: 64, fam: 'PuHui-Black', color: C.ink, over: 2.4 });
+ }
+ // 主词「24年」
+ TY.slam(c, '24年', 960, 640, lt - q.n24, { size: 330, color: C.white, align: 'center', oy: 640 - 330 * 0.36 });
+}
+
+SCENES[ID] = {
+ init() { U.assertGlyphs('PuHui-Black', '20089.2824年最后一发成了', ID); U.assertGlyphs('PuHui-Heavy', '连败三次钱只够再打同一天18年后SpaceX', ID); U.assertGlyphs('PuHui-Bold', '猎鹰1号·2008星舰26', ID); },
+ draw(c, lt, t) {
+ const q = cues();
+ // 换页时刻:藏青→黄(圆从第四枚火箭的尾焰长出,在「9」被念出时盖满);黄→珊瑚(镜头往上推,揭开在「两分钟」)
+ const irisA = q.d928 - 0.26, irisP = clamp((lt - irisA) / 0.26);
+ const pushA = q.lfz - 0.58 * 0.45, pushP = clamp((lt - pushA) / 0.45), pe = MO.expoInOut(pushP);
+ const z = hit(lt, [0, q.lian, (q.lian + q.x3) / 2, q.x3, q.zuihou, q.d928, q.cheng, q.n24]) * (1 - 0.06 * MO.expoOut(clamp((lt - q.voEnd) / 0.5)));
+ // 藏青
+ if (irisP < 1) {
+ c.fillStyle = C.navy; c.fillRect(0, 0, W, H); dots(c, t, C.white, 0.07);
+ cam(c, t, z, c => navyLayer(c, lt, t));
+ }
+ // 黄(圆形揭开)
+ if (irisP > 0 && pushP < 1) {
+ c.save();
+ if (irisP < 1) { const r = rk4(lt); c.beginPath(); c.arc(r.x, r.y + 40, 2300 * Math.pow(irisP, 2.2), 0, 7); c.clip(); }
+ c.translate(0, H * pe);
+ c.fillStyle = C.yel; c.fillRect(0, 0, W, H); dots(c, t, C.ink, 0.07);
+ cam(c, t, z, c => yellowLayer(c, lt, t));
+ c.restore();
+ }
+ // 珊瑚(从上方推进来)
+ if (pushP > 0) {
+ c.save(); c.translate(0, -H + H * pe);
+ c.fillStyle = C.coral; c.fillRect(0, 0, W, H); dots(c, t, C.ink, 0.08);
+ cam(c, t, z, c => coralLayer(c, lt, t));
+ c.restore();
+ }
+ },
+};
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex/scenes/s02.js b/scripts/engine/reference_films/spacex/spacex/scenes/s02.js
new file mode 100644
index 0000000..b264e0b
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex/scenes/s02.js
@@ -0,0 +1,102 @@
+// S02 · 白板手绘(y3 RSA 型:一整块大白板+一台相机+一支马克笔)。语法卡 references/动画语法/y3_whiteboard.md
+// 说一句写一句:开写比口播晚 0.3–0.5s;黑线+唯一强调色橙。
+// 第一块:「2002年」→ 火柴人「马斯克」→ 箭头 →「SpaceX」;相机平滑移到第二块:「目标」→ 地球 → 小火箭沿橙色虚线飞向橙色排线的星球 → 星球上插一座小房子;收尾拉远看全图。
+// 进入转场 paperSlide(transitions/paperSlide.js):一张白纸从右边盖住上一段的珊瑚色标题卡。
+(() => {
+const W = 1920, H = 1080, ID = 's02';
+const { clamp, lerp } = U;
+const INK = '#0A0503', OR = '#EF7226', BOARD = '#FBFBFB';
+const SPEED = 2600;
+let B = null, CAMK = null, END = 0;
+
+function build() {
+ const q = k => TM.cue(ID, k);
+ const tY = q('2002年'), tM = q('马斯克'), tS = q('SpaceX'), tG = q('目标'), tR = q('有一天'), tP = q('别的星球'), tZ = q('住到');
+ B = DG.board({ ink: INK, lw: 6.5, speed: SPEED, font: '"LXGWWenKai-500"' });
+ const arc = DG.arcPts;
+ // ===== 第一块 =====
+ B.at(Math.max(0.52, tY + 0.3)); B.text('2002年', 260, 380, 150, { rate: 12 });
+ // 火柴人(不画五官):头、身、手、腿
+ B.at(Math.max(B.cur, tM - 0.38));
+ B.line(arc(430, 470, 44, 48, -Math.PI / 2, Math.PI * 1.55, 22), { w: 7 });
+ B.line([[430, 520], [432, 600], [430, 680]], { w: 7 });
+ B.line([[350, 600], [390, 570], [432, 560], [476, 572], [520, 548]], { w: 7 });
+ B.line([[372, 790], [404, 740], [430, 680], [458, 740], [490, 792]], { w: 7 });
+ B.text('马斯克', 430, 875, 66, { align: 'center', rate: 16 });
+ // 箭头 → SpaceX(普通手写字,不是字标)
+ B.at(Math.max(B.cur, tS - 0.28));
+ B.line([[548, 620], [640, 610], [722, 616]], { speed: SPEED * 1.4 });
+ B.line([[694, 590], [726, 616], [692, 642]], { smooth: false, speed: SPEED * 1.4 });
+ B.text('SpaceX', 768, 650, 128, { rate: 18 });
+ B.line([[772, 690], [960, 700], [1150, 688]], { col: OR, w: 9, speed: SPEED * 1.6 });
+ // ===== 第二块(相机 2.45→3.25 平滑移动过来) =====
+ B.at(Math.max(B.cur + 0.05, tG + 0.3)); B.text('目标', 1440, 330, 118, { col: OR, rate: 11 });
+ // 地球:圈+两块大陆
+ B.at(Math.max(B.cur, tG + 0.55));
+ B.line(DG.ellipsePts(1560, 640, 140, 140, -Math.PI / 2, 1.04, 48), { w: 7 });
+ B.line([[1452, 560], [1490, 536], [1540, 548], [1566, 532], [1600, 556], [1572, 590], [1588, 626], [1546, 640], [1528, 610], [1494, 622], [1466, 600], [1452, 560]], { w: 5, speed: SPEED * 2.2 });
+ B.line([[1556, 690], [1610, 668], [1662, 684], [1676, 718], [1640, 750], [1600, 772], [1584, 740], [1556, 690]], { w: 5, speed: SPEED * 2.2 });
+ // 小火箭从地球飞向星球,身后留下橙色虚线(不带手:动画元素)
+ const P0 = [1655, 545], P1 = [2000, 250], P2 = [2300, 470];
+ const bez = u => [lerp(lerp(P0[0], P1[0], u), lerp(P1[0], P2[0], u), u), lerp(lerp(P0[1], P1[1], u), lerp(P1[1], P2[1], u), u)];
+ const pts = []; for (let i = 0; i <= 60; i++) pts.push(bez(i / 60));
+ const cum = DG.cum(pts), L = cum[cum.length - 1];
+ const fly0 = Math.max(B.cur + 0.05, tR + 0.25), fly1 = fly0 + 1.0;
+ B.push({ kind: 'custom', t0: fly0, t1: fly1, handed: false, start: () => P0, end: () => P2,
+ draw(g, qq) {
+ const e = MO.sineInOut(qq), d = L * e;
+ g.save(); g.strokeStyle = OR; g.lineWidth = 6; g.setLineDash([22, 16]); DG.drawPartial(g, pts, cum, Math.max(0, d - 40)); g.setLineDash([]);
+ // 箭头头(到站后画在终点)
+ const [x, y] = DG.pointAt(pts, cum, d), [x2, y2] = DG.pointAt(pts, cum, Math.min(L, d + 2)), a = Math.atan2(y2 - y, x2 - x) || 0.3;
+ if (qq >= 1) { g.lineWidth = 6; g.beginPath(); g.moveTo(x - Math.cos(a - 0.5) * 30, y - Math.sin(a - 0.5) * 30); g.lineTo(x, y); g.lineTo(x - Math.cos(a + 0.5) * 30, y - Math.sin(a + 0.5) * 30); g.stroke(); }
+ else { // 小火箭(线稿)
+ g.translate(x, y); g.rotate(a + Math.PI / 2); g.strokeStyle = INK; g.fillStyle = BOARD; g.lineWidth = 5; g.lineJoin = 'round';
+ g.beginPath(); g.moveTo(0, -38); g.quadraticCurveTo(16, -22, 14, 4); g.lineTo(14, 22); g.lineTo(-14, 22); g.lineTo(-14, 4); g.quadraticCurveTo(-16, -22, 0, -38); g.closePath(); g.fill(); g.stroke();
+ g.beginPath(); g.moveTo(-14, 8); g.lineTo(-26, 26); g.lineTo(-14, 22); g.moveTo(14, 8); g.lineTo(26, 26); g.lineTo(14, 22); g.stroke();
+ g.fillStyle = OR; g.beginPath(); g.moveTo(-8, 26); g.lineTo(0, 46 + 6 * Math.sin(qq * 40)); g.lineTo(8, 26); g.closePath(); g.fill();
+ }
+ g.restore(); return null;
+ } });
+ // 另一颗星球:圈+橙色排线+插一座小房子
+ B.at(Math.max(fly0 + 0.55, tP + 0.05));
+ const MX = 2420, MY = 500, MR = 112;
+ B.line(DG.ellipsePts(MX, MY, MR, MR, Math.PI, 1.04, 44), { w: 7, speed: SPEED * 1.3 });
+ for (let d = -84; d <= 84; d += 21) { const h = Math.sqrt(MR * MR - d * d) * 0.86, nx = Math.SQRT1_2, ux = Math.SQRT1_2;
+ const cx = MX + nx * d, cy = MY + nx * d; B.line([[cx - ux * h, cy + ux * h], [cx + ux * h, cy - ux * h]], { col: OR, w: 5, speed: SPEED * 3.2, gap: 0.004, min: 0.025 }); }
+ B.at(Math.max(B.cur, tZ + 0.62));
+ B.line([[2378, 394], [2378, 306], [2462, 306], [2462, 394]], { w: 7, speed: SPEED * 1.4, smooth: false });
+ B.line([[2358, 314], [2420, 250], [2482, 314]], { w: 7, speed: SPEED * 1.4, smooth: false });
+ B.line([[2408, 394], [2408, 350], [2434, 350], [2434, 394]], { w: 6, speed: SPEED * 1.8, smooth: false });
+ END = B.cur;
+ // 相机:第一块 → 平滑移到第二块(sineInOut)→ 拉远看全图
+ const mv0 = Math.max(tG - 0.15, 2.4), out0 = Math.max(END + 0.08, TM.vo(ID)[1] - 0.25);
+ CAMK = [
+ { t: 0, x: 700, y: 600, z: 1.08 },
+ { t: mv0, x: 724, y: 604, z: 1.11, ease: MO.sineInOut },
+ { t: mv0 + 0.8, x: 2080, y: 560, z: 1.1, ease: MO.sineInOut }, // 落定后第一块(含「SpaceX」)整段出画,不留半截字
+ { t: out0, x: 2094, y: 556, z: 1.12, ease: MO.sineInOut },
+ { t: out0 + 0.6, x: 1390, y: 600, z: 0.7, ease: MO.sineInOut },
+ { t: out0 + 3, x: 1390, y: 600, z: 0.69, ease: MO.sineInOut },
+ ];
+}
+
+const smudge = () => PAINT.cached('s02smudge', 1024, 1024, g => { const r = U.rng(5); for (let i = 0; i < 22; i++) { g.fillStyle = `rgba(120,120,130,${0.0015 + r() * 0.0025})`; g.beginPath(); g.ellipse(r() * 1024, r() * 1024, 80 + r() * 200, 14 + r() * 40, r() * 3, 0, 7); g.fill(); } });
+
+SCENES[ID] = {
+ init() { U.assertGlyphs('LXGWWenKai-500', '2002年马斯克SpaceX目标', ID); build(); },
+ draw(c, lt, t) {
+ if (!B) build();
+ const cam = CAM.at(CAMK, lt);
+ c.fillStyle = BOARD; c.fillRect(0, 0, W, H);
+ c.save(); const ox = -(((cam.x * cam.z) % 1024) + 1024) % 1024, oy = -(((cam.y * cam.z) % 1024) + 1024) % 1024;
+ c.translate(ox, oy); c.fillStyle = c.createPattern(smudge(), 'repeat'); c.fillRect(0, 0, W + 1024, H + 1024); c.restore();
+ c.save(); CAM.apply(c, cam); const { tip, col } = B.draw(c, lt); c.restore();
+ // 笔:画的时候在笔尖,两笔之间沿弧线滑,画完 0.25s 后从右下退出画面
+ let [hx, hy] = B.penAt(lt, cam, tip);
+ const out = MO.cubicIn(clamp((lt - END - 0.2) / 0.4)), inn = MO.cubicOut(clamp((lt - 0.3) / 0.25));
+ hx = lerp(lerp(W * 0.9, hx, inn), W + 200, out); hy = lerp(lerp(H * 1.1, hy, inn), H + 300, out);
+ DG.pen(c, hx, hy, col || B.penColor(lt), Math.sin(lt * 7) * 0.03);
+ },
+};
+ERAS.find(e => e.id === ID).transition = { type: 'paperSlide', dur: 0.5 };
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex/scenes/s03.js b/scripts/engine/reference_films/spacex/spacex/scenes/s03.js
new file mode 100644
index 0000000..d41b769
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex/scenes/s03.js
@@ -0,0 +1,253 @@
+// S03 · 8-bit 像素游戏「闯关」。风格卡 references/风格配方/14_8bit.md、标杆 scenes/14_8bit.js。
+// 管线:整幅在 240×135 低分辨率上逐像素画(1 低像素 = 8 屏幕像素),限 NES 色板 → 最近邻放大 8 倍;
+// 火箭=RK.falcon1 的真实比例路径缩到低分辨率 → 阈值去抗锯齿+量化+1px 黑描边(spriteize);
+// 动作按 20fps 步进(像素游戏的一顿一顿),HUD 用 PressStart2P 64/128px(1 字体像素 = 8/16 屏幕像素);中文年份牌用普惠体在低分辨率上画再二值化(像素化中文)。
+// 剧情:太平洋小岛发射台(夸贾林环礁欧姆莱克岛:棕榈、海)→ FALCON 1 标题 → 2006/2007/2008年8月 三次 GAME OVER,右上 4 颗心一颗颗灭
+// → 第四次 LAST TRY(最后一颗心)→ 升空、卷轴进太空 → 绕像素地球入轨 STAGE CLEAR → 对话框打出 1ST PRIVATE LIQUID-FUEL ROCKET IN ORBIT。
+(() => {
+const W = 1920, H = 1080, S = 8, LW = 240, LH = 135, ID = 's03';
+const { clamp, lerp, rng } = U, P = PAINT;
+const C = {
+ k: '#000000', w: '#fcfcfc', g: '#bcbcbc', gd: '#7c7c7c', gdd: '#404040',
+ sky0: '#0078f8', sky1: '#3cbcfc', sky2: '#a4e4fc', sea: '#0058f8', seaDk: '#0000bc', navy: '#000058',
+ sand: '#f8d878', sandDk: '#d8a038', trunk: '#ac7c00', trunkDk: '#503000', leaf: '#00a800', leafHi: '#58d854', leafDk: '#005800',
+ y: '#f8b800', o: '#fca044', r: '#e45c10', rd: '#a81000', pink: '#f878f8', red: '#d82800', land: '#00a800', landDk: '#005800',
+};
+const PAL = Object.values(C).map(P.hex);
+const px = (g, x, y, w, h, col) => { g.fillStyle = col; g.fillRect(x, y, w, h); };
+let Q = null;
+const cues = () => Q || (Q = (() => {
+ const q = k => TM.cue(ID, k);
+ return { spawn: q('火箭'), title: q('猎鹰1号'), a: [q('2006年'), q('2007年'), q('2008年8月'), q('第四次')],
+ f: [q('失败;2007'), q('失败;2008'), q('失败。')], ok: q('成了'), le: q('了,成为'), banner: q('成为第一枚'), voEnd: TM.vo(ID)[1] };
+})());
+
+// ---------- 精灵化:低分辨率 AA 路径 → 阈值+量化到色板+外描黑边 ----------
+function spriteize(g, w, h) {
+ const im = g.getImageData(0, 0, w, h), d = im.data, op = new Uint8Array(w * h);
+ for (let i = 0; i < w * h; i++) {
+ if (d[i * 4 + 3] < 100) { d[i * 4 + 3] = 0; continue; }
+ let best = 0, bd = 1e9; for (let j = 0; j < PAL.length; j++) { const q = PAL[j], dd = (d[i * 4] - q[0]) ** 2 + (d[i * 4 + 1] - q[1]) ** 2 + (d[i * 4 + 2] - q[2]) ** 2; if (dd < bd) { bd = dd; best = j; } }
+ const q = PAL[best]; d[i * 4] = q[0]; d[i * 4 + 1] = q[1]; d[i * 4 + 2] = q[2]; d[i * 4 + 3] = 255; op[i] = 1;
+ }
+ for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) { const i = y * w + x; if (op[i]) continue;
+ if ((x > 0 && op[i - 1]) || (x < w - 1 && op[i + 1]) || (y > 0 && op[i - w]) || (y < h - 1 && op[i + w])) { d[i * 4] = d[i * 4 + 1] = d[i * 4 + 2] = 0; d[i * 4 + 3] = 255; } }
+ g.putImageData(im, 0, 0);
+}
+// 猎鹰1号精灵(RK.falcon1 真实比例,高 hpx 低像素),按角度缓存;锚点 = 箭底中心
+const F1 = RK.falcon1(), SPR = {};
+function rocketSprite(hpx, ang) {
+ const a = Math.round(ang / 0.13) * 0.13, key = hpx + '|' + a.toFixed(2);
+ if (SPR[key]) return SPR[key];
+ const N = Math.ceil(hpx * 1.3) + 6, cv = document.createElement('canvas'); cv.width = cv.height = N;
+ const g = cv.getContext('2d', { willReadFrequently: true }), s = hpx / F1.h;
+ g.translate(N / 2, N / 2); g.rotate(a); g.translate(0, hpx * 0.45); g.scale(s, s);
+ for (const q of F1.parts) { g.fillStyle = q.k === 'dark' ? C.k : q.k === 'engine' ? C.gd : C.w; g.fill(q.p); }
+ g.fillStyle = C.g; g.fillRect(F1.w * 0.12, -15.4, F1.w * 0.38, 15.2); // 右侧一道灰:圆柱的明暗
+ g.setTransform(1, 0, 0, 1, 0, 0); spriteize(g, N, N);
+ return (SPR[key] = { cv, ox: N / 2 - Math.sin(a) * hpx * 0.45, oy: N / 2 + Math.cos(a) * hpx * 0.45 });
+}
+const drawRocket = (g, x, y, hpx, ang = 0) => { const s = rocketSprite(hpx, ang); g.drawImage(s.cv, Math.round(x - s.ox), Math.round(y - s.oy)); };
+// 像素尾焰:三帧交替(20fps)
+const flamePx = (g, x, y, len, st, big = 1) => {
+ const f = Math.floor(st * 20) % 3, L = len + [0, 2, 1][f];
+ for (let j = 0; j < L; j++) { const q = j / L, w = Math.max(1, Math.round((3 - q * 2.5) * big)), col = q < 0.25 ? C.w : q < 0.55 ? C.y : q < 0.8 ? C.o : C.r;
+ px(g, Math.round(x - w / 2 + ((j + f) % 3 === 0 && q > 0.5 ? 1 : 0)), y + j, w, 1, col); }
+};
+// 爆炸:种子粒子,颜色按年龄 白→黄→橙→红→灰
+const boom = (g, x, y, age, seed, big = 1) => {
+ if (age < 0 || age > 0.9) return;
+ const r = rng(seed); if (age < 0.12) { const R = Math.round((3 + age * 60) * big); for (let j = -R; j <= R; j++) { const w = Math.round(Math.sqrt(R * R - j * j)); px(g, x - w, y + j, w * 2 + 1, 1, age < 0.06 ? C.w : C.y); } }
+ for (let i = 0; i < 70; i++) {
+ const a = r() * Math.PI * 2, v = (14 + r() * 46) * big, life = 0.35 + r() * 0.5, sz = r() < 0.35 ? 3 : 2; if (age > life) continue;
+ const q = age / life, d = v * (1 - Math.exp(-age * 5)) / 5 * 5 * 0.25 * 4;
+ const col = q < 0.18 ? C.w : q < 0.38 ? C.y : q < 0.6 ? C.o : q < 0.8 ? C.r : C.gd;
+ px(g, Math.round(x + Math.cos(a) * d), Math.round(y + Math.sin(a) * d * 0.8 + age * age * 30), sz, sz, col);
+ }
+};
+
+// ---------- 静态背景:岛、海、天 ----------
+function islandBg(g) {
+ for (let y = 0; y < 78; y++) for (let x = 0; x < LW; x++) {
+ const q = y / 78; let col = q < 0.35 ? C.sky0 : q < 0.7 ? C.sky1 : C.sky2;
+ if (Math.abs(q - 0.35) < 0.04 && (x + y) % 2) col = C.sky1; if (Math.abs(q - 0.7) < 0.04 && (x + y) % 2) col = q < 0.7 ? C.sky2 : C.sky1;
+ px(g, x, y, 1, 1, col);
+ }
+ px(g, 0, 78, LW, 1, C.sky2); px(g, 0, 79, LW, 56, C.sea);
+ for (let y = 100; y < LH; y++) for (let x = 0; x < LW; x++) if ((y > 118 || (x + y) % 2 === 0 && y > 108)) px(g, x, y, 1, 1, C.seaDk);
+ // 远处的环礁小岛
+ for (const [cx, w] of [[26, 16], [58, 8]]) { px(g, cx - w / 2, 77, w, 2, C.sandDk); px(g, cx - w / 2 + 2, 76, w - 4, 1, C.leafDk); }
+ // 主岛(沙丘)
+ for (let x = 84; x <= 220; x++) { const u = (x - 152) / 68, h = Math.round(9 * Math.sqrt(Math.max(0, 1 - u * u))); if (h <= 0) continue;
+ px(g, x, 104 - h, 1, h + 6, C.sand); px(g, x, 104 - h, 1, 1, '#fcfcfc'); px(g, x, 108, 1, 2, C.sandDk); }
+ // 发射台:混凝土台+导流槽;勤务塔(桁架)
+ px(g, 158, 96, 28, 1, C.k); px(g, 158, 97, 28, 4, C.g); px(g, 158, 100, 28, 1, C.gd); px(g, 166, 97, 10, 2, C.gdd);
+ px(g, 180, 46, 1, 51, C.k); px(g, 185, 46, 1, 51, C.k); px(g, 181, 46, 4, 51, C.gd);
+ for (let y = 48; y < 96; y += 6) { for (let i = 0; i < 4; i++) { px(g, 181 + i, y + i, 1, 1, C.gdd); px(g, 184 - i, y + i + 3 > 95 ? 95 : y + i + 3, 1, 1, C.gdd); } px(g, 180, y, 6, 1, C.k); }
+ px(g, 179, 45, 8, 1, C.k); px(g, 182, 42, 2, 3, C.gdd); px(g, 177, 62, 3, 1, C.gdd); px(g, 177, 78, 3, 1, C.gdd); // 塔顶避雷针、两根脐带臂
+}
+// 棕榈树:树干一段段弯,叶片 5 条弧,sway 整像素摆
+function palm(g, x0, y0, h, lean, sway) {
+ let x = x0; for (let j = 0; j < h; j++) { const xx = Math.round(x0 + lean * (j / h) ** 2 * h * 0.35 + (j > h * 0.7 ? sway * (j - h * 0.7) / (h * 0.3) : 0)); px(g, xx - 1, y0 - j, 3, 1, j % 3 ? C.trunk : C.trunkDk); px(g, xx - 2, y0 - j, 1, 1, C.k); px(g, xx + 2, y0 - j, 1, 1, C.k); x = xx; }
+ const tx = x, ty = y0 - h;
+ const fr = [[-1, 0.15], [-0.55, -0.5], [0, -0.85], [0.55, -0.5], [1, 0.15]];
+ for (const [dx, dy] of fr) for (let i = 1; i <= 10; i++) { const fx = Math.round(tx + dx * i + sway * (i / 10)), fy = Math.round(ty + dy * i * 0.7 + (i * i) * 0.06);
+ px(g, fx - 1, fy - 1, 3, 3, C.k); }
+ for (const [dx, dy] of fr) for (let i = 1; i <= 10; i++) { const fx = Math.round(tx + dx * i + sway * (i / 10)), fy = Math.round(ty + dy * i * 0.7 + (i * i) * 0.06);
+ px(g, fx, fy, 1 + (i < 8 ? 1 : 0), 1, i % 2 ? C.leaf : C.leafHi); }
+ px(g, tx - 1, ty, 3, 2, C.trunkDk);
+}
+// 会动的部分:云、浪、棕榈
+function islandLive(g, st) {
+ const cs = Math.floor(st * 6);
+ for (const [x0, y, w] of [[30, 14, 22], [130, 26, 16], [210, 8, 18]]) { const x = ((x0 - cs) % (LW + 40) + LW + 40) % (LW + 40) - 20;
+ px(g, x + 3, y - 2, w - 8, 2, C.w); px(g, x, y, w, 3, C.w); px(g, x + 2, y + 3, w - 4, 1, C.sky2); }
+ const wf = Math.floor(st * 5);
+ for (let r = 0; r < 6; r++) { const y = 84 + r * 6 + (r > 2 ? 4 : 0); for (let x = (r * 13 + wf * (r % 2 ? 2 : -2)) % 24 - 24; x < LW; x += 24) if (y < 100 || x < 80 || x > 222) px(g, x, y, 4, 1, r > 3 ? C.sea : C.sky1); }
+ for (let x = 84; x <= 220; x += 1) { if ((x + wf) % 4 === 0) px(g, x, 110, 2, 1, C.w); }
+ const sw = [0, 1, 0, -1][Math.floor(st * 4) % 4];
+ palm(g, 100, 101, 26, -1, sw); palm(g, 118, 99, 20, 1, -sw); palm(g, 206, 100, 22, 1, sw);
+}
+// ---------- 地球(入轨画面):逐像素球面+噪声大陆+明暗交界抖动 ----------
+const ER = 105, ECX = 150, ECY = 206, ORB = 126;
+function earth(st) {
+ const key = 'e' + Math.floor(st * 10), cv = P.cached('s03_earth', ER * 2 + 4, ER * 2 + 4, () => {});
+ if (earth.k === key) return cv; earth.k = key;
+ const g = cv.getContext('2d', { willReadFrequently: true }), N = ER * 2 + 4, im = g.createImageData(N, N), d = im.data, rot = Math.floor(st * 10) * 0.02;
+ const put = (i, hex) => { const c = P.hex(hex); d[i * 4] = c[0]; d[i * 4 + 1] = c[1]; d[i * 4 + 2] = c[2]; d[i * 4 + 3] = 255; };
+ for (let y = 0; y < N; y++) for (let x = 0; x < N; x++) {
+ const nx = (x - N / 2 + 0.5) / ER, ny = (y - N / 2 + 0.5) / ER, r2 = nx * nx + ny * ny, i = y * N + x;
+ if (r2 > 1.0) { if (r2 < 1.06) put(i, C.sky1); continue; }
+ const nz = Math.sqrt(1 - r2), lon = Math.atan2(nx, nz) + rot, lat = Math.asin(-ny);
+ const land = P.noise(lon * 1.6 + 10, lat * 2.4) + 0.4 * P.noise(lon * 4 + 3, lat * 5) > 0.18, cloud = P.noise(lon * 3 + 40 + rot * 2, lat * 7) > 0.42;
+ const lit = -0.55 * nx - 0.45 * ny + 0.7 * nz;
+ let col = cloud ? C.w : land ? C.land : C.sea;
+ if (lit < 0.25 && ((x + y) % 2 || lit < 0.05)) col = cloud ? C.g : land ? C.landDk : C.seaDk;
+ if (lit < -0.15) col = C.navy;
+ put(i, col);
+ }
+ g.putImageData(im, 0, 0); return cv;
+}
+// ---------- 字 ----------
+const ptext = (c, s, x, y, size, col, align = 'center', alpha = 1) => {
+ c.save(); c.globalAlpha = alpha; c.font = `${size}px "PressStart2P-400"`; c.textBaseline = 'top'; c.textAlign = align;
+ const o = size / 8; c.fillStyle = '#000'; c.fillText(s, x + o, y + o); c.fillStyle = col; c.fillText(s, x, y); c.restore();
+};
+// 像素化中文:普惠体在低分辨率上画 → 二值化 → 外描黑边
+const LTX = {};
+function lowText(str, size = 13) {
+ if (LTX[str]) return LTX[str];
+ const cv = document.createElement('canvas'), g = cv.getContext('2d', { willReadFrequently: true }); g.font = `${size}px "PuHui-Heavy"`;
+ cv.width = Math.ceil(g.measureText(str).width) + 4; cv.height = size + 6;
+ g.font = `${size}px "PuHui-Heavy"`; g.textBaseline = 'top'; g.fillStyle = C.w; g.fillText(str, 2, 2);
+ const im = g.getImageData(0, 0, cv.width, cv.height), d = im.data;
+ for (let i = 0; i < d.length; i += 4) { if (d[i + 3] >= 120) { d[i] = d[i + 1] = d[i + 2] = 252; d[i + 3] = 255; } else d[i + 3] = 0; }
+ g.putImageData(im, 0, 0); spriteize(g, cv.width, cv.height);
+ return (LTX[str] = cv);
+}
+const HEART = ['.kk.kk.', 'krrkrrk', 'krwrrrk', 'krrrrrk', '.krrrk.', '..krk..', '...k...'];
+const HEARTE = ['.kk.kk.', 'k..k..k', 'k.....k', 'k.....k', '.k...k.', '..k.k..', '...k...'];
+const heart = (c, rows, x, y, map) => rows.forEach((row, j) => [...row].forEach((ch, i) => { if (ch !== '.') { c.fillStyle = map[ch]; c.fillRect(x + i * S, y + j * S, S, S); } }));
+
+// ---------- 每次尝试的火箭轨迹 ----------
+// 返回 {x, y(箭底), ang, flame, vis, alt(卷轴高度)};u = 起飞后秒数(20fps 步进)
+const PADX = 171, PADY = 96, RH = 48;
+function attempt(i, st) {
+ const q = cues(), a = q.a[i], L = a + 0.42, u = Math.max(0, st - L);
+ const o = { x: PADX, y: PADY, ang: 0, flame: st > a + 0.24 ? (u > 0 ? 7 + Math.min(10, u * 30) : 3) : 0, vis: true, alt: 0, u };
+ if (i < 3) {
+ const uf = q.f[i] - 0.03 - L, yf = [68, 60, 52][i], k = (PADY - yf) / (uf * uf);
+ const uu = Math.min(u, uf); o.y = PADY - k * uu * uu;
+ if (i === 1 && u > uf) { const d = u - uf; o.flame = 0; o.ang = 2.6 * d + 0.6 * d * d; o.y = yf + 260 * d * d - 18 * d; o.x = PADX + 22 * d; } // 2007:熄火、翻滚、掉下去
+ else if (u > uf) o.vis = false; // 2006 / 2008.8:炸了
+ } else {
+ const alt = 120 * u * u + 200 * u * u * u; o.alt = alt;
+ o.y = Math.max(PADY - alt, 60); o.alt = Math.max(0, alt - (PADY - 60));
+ }
+ o.y = Math.round(o.y); return o;
+}
+
+SCENES[ID] = {
+ init() {
+ U.assertGlyphs('PressStart2P-400', 'FALCON 1GAMEOVERLASTTRYSTAGECLEAR!1STPRIVATELIQUID-FUELROCKETINORBIT', ID);
+ U.assertGlyphs('PuHui-Heavy', '2006年2007年2008年8月9月', ID);
+ },
+ draw(c, lt, t) {
+ const q = cues(), st = U.stepTime(lt, 20);
+ const L = P.cached('s03_low', LW, LH, () => {}), g = L.getContext('2d'); g.setTransform(1, 0, 0, 1, 0, 0); g.imageSmoothingEnabled = false;
+ const tOrb = q.le - 0.08, inOrbit = st >= tOrb;
+ let k = 0; for (let i = 0; i < 4; i++) if (st >= q.a[i]) k = i; // 当前第几次(开场到 2006 之前算第 0 次的待机)
+ // 屏幕抖动:爆炸后 0.25s
+ let shake = 0; for (let i = 0; i < 3; i++) { const d = st - q.f[i]; if (d >= 0 && d < 0.25 && i !== 1) shake = [1, -1, 1, 0, -1][Math.floor(d * 20) % 5]; }
+ if (!inOrbit) {
+ const A = attempt(k, st), scroll = k === 3 ? Math.round(A.alt) : 0;
+ // 天:卷轴往上时,上面接深蓝→午夜蓝→黑(带星)
+ px(g, 0, 0, LW, LH, C.k);
+ g.drawImage(P.cached('s03_island', LW, LH, islandBg), shake, scroll);
+ if (scroll > 0) for (let y = 0; y < Math.min(LH, scroll); y++) { const wy = y - scroll; const col = wy > -30 ? C.sky0 : wy > -70 ? C.seaDk : wy > -110 ? C.navy : C.k;
+ if (col !== C.k) px(g, 0, y, LW, 1, col); else { const r = U.hash(y, 7); if (r < 0.12) px(g, Math.floor(U.hash(y, 3) * LW), y, 1, 1, C.w); } }
+ g.save(); g.translate(shake, scroll); islandLive(g, st);
+ // 火箭:开场「火箭」时闪着刷出来;每次重来也闪着刷出
+ const spawn = k === 0 && st < q.a[0] ? q.spawn : q.a[k] - 0.02, blink = st - spawn < 0.4 && Math.floor((st - spawn) * 15) % 2 === 1;
+ if (st >= q.spawn && A.vis && !blink) {
+ if (A.u > 0 && A.u < 0.7) for (let j = 0; j < 6; j++) { const r = Math.round(2 + A.u * 18 + j % 3), sx = PADX + (j - 2.5) * 6 * (0.4 + A.u); px(g, Math.round(sx - r / 2), PADY + 1 - Math.round(r / 3), r, Math.round(r / 2), j % 2 ? C.w : C.g); }
+ if (A.flame > 0) flamePx(g, A.x, A.y + 2, Math.round(A.flame), st, A.u > 0 ? 1.2 : 0.8);
+ drawRocket(g, A.x, A.y, RH, A.ang);
+ }
+ // 三次失败的爆炸(2007 是熄火翻滚后在海面炸开一朵小的)
+ for (let i = 0; i < 3; i++) { if (k !== i) continue; const Ai = attempt(i, q.f[i] - 0.03);
+ if (i === 1) { const d = st - q.f[i]; if (d > 0.36) boom(g, PADX + 14, 92, d - 0.36, 21, 0.5); }
+ else boom(g, Ai.x, Ai.y - RH * 0.55, st - q.f[i] + 0.03, 11 + i * 7, i === 2 ? 1.25 : 1); }
+ g.restore();
+ } else {
+ // 入轨:黑底、闪星、像素地球自转、火箭沿椭圆轨道飞
+ px(g, 0, 0, LW, LH, C.k);
+ const tw = Math.floor(st * 6);
+ for (let i = 0; i < 90; i++) { const x = Math.floor(U.hash(i, 1) * LW), y = Math.floor(U.hash(i, 2) * 110), on = U.hash(i, tw) > 0.15; if (on) px(g, x, y, 1, 1, U.hash(i, 5) < 0.2 ? C.y : U.hash(i, 6) < 0.5 ? C.g : C.w); if (U.hash(i, 9) < 0.08 && U.hash(i, tw + 50) > 0.6) { px(g, x - 1, y, 3, 1, C.w); px(g, x, y - 1, 1, 3, C.w); } }
+ g.drawImage(earth(st), ECX - ER - 2, ECY - ER - 2);
+ const oa = -Math.PI * 0.77 + (st - tOrb) * 0.38, ox = ECX + Math.cos(oa) * ORB, oy = ECY + Math.sin(oa) * ORB;
+ for (let j = 0; j < 240; j += 2) { const a = -Math.PI + j / 240 * Math.PI; if (j % 6) px(g, Math.round(ECX + Math.cos(a) * ORB), Math.round(ECY + Math.sin(a) * ORB), 1, 1, C.gd); }
+ const tang = Math.atan2(Math.cos(oa), -Math.sin(oa));
+ drawRocket(g, ox, oy, 28, tang + Math.PI / 2);
+ const fx = Math.round(ox - Math.cos(tang) * 3), fy = Math.round(oy - Math.sin(tang) * 3);
+ if (Math.floor(st * 20) % 2) px(g, fx - Math.round(Math.cos(tang) * 13), fy - Math.round(Math.sin(tang) * 13), 3, 3, C.y);
+ }
+ // 放大 8 倍(最近邻)
+ c.imageSmoothingEnabled = false; c.drawImage(L, 0, 0, LW, LH, 0, 0, W, H); c.imageSmoothingEnabled = true;
+ // 入轨白闪 2 帧
+ if (Math.abs(lt - tOrb) < 0.05) { c.fillStyle = '#fcfcfc'; c.fillRect(0, 0, W, H); }
+
+ // ---------- HUD ----------
+ if (st >= q.a[0] - 0.02) ptext(c, 'FALCON 1', 96, 64, 64, C.w, 'left');
+ const lost = [0, 1, 2].filter(i => st > q.f[i] + 0.15).length;
+ for (let i = 0; i < 4; i++) {
+ const x = 1544 + i * 72, y = 64;
+ let full = i < 4 - lost;
+ for (let j = 0; j < 3; j++) { const d = st - q.f[j] - 0.15; if (3 - j === i && d > -0.15 && d < 0.15) full = Math.floor(st * 20) % 2 === 0; }
+ if (i === 0 && lost === 3 && !inOrbit && st > q.a[3] - 0.02 && Math.floor(st * 10) % 2) full = false; // 最后一颗心在闪
+ heart(c, full ? HEART : HEARTE, x, y, { k: '#000', r: C.red, w: C.w });
+ }
+ // 年份牌(像素化中文)
+ const PL = ['2006年', '2007年', '2008年8月', '2008年9月'];
+ if (st >= q.a[0] - 0.02) { const tx = lowText(PL[k]), pop = st - q.a[k] < 0.15 && Math.floor(st * 20) % 2; if (!pop) c.drawImage(tx, 0, 0, tx.width, tx.height, Math.round((960 - tx.width * S / 2) / 8) * 8, 40, tx.width * S, tx.height * S); }
+ // 大字:FALCON 1 标题 / GAME OVER / LAST TRY / STAGE CLEAR!
+ if (st >= q.title && st < q.a[0]) { const d = st - q.title, y = Math.round(lerp(-160, 176, MO.backOut(clamp(d / 0.3), 1.6)) / 8) * 8; ptext(c, 'FALCON 1', 960, y, 128, C.y); }
+ for (let i = 0; i < 3; i++) { if (st > q.f[i] + 0.08 && st < q.a[i + 1] - 0.06) ptext(c, 'GAME OVER', 960, 320, 128, Math.floor(st * 10) % 4 === 0 ? C.w : C.red); }
+ if (st >= q.a[3] && st < q.a[3] + 0.75 && (st - q.a[3] < 0.35 || Math.floor(st * 8) % 2 === 0)) ptext(c, 'LAST TRY', 960, 320, 128, C.y);
+ if (st >= q.le) { const d = st - q.le, cols = [C.w, C.y, C.o, C.y]; ptext(c, 'STAGE CLEAR!', 960, Math.round(lerp(320, 168, MO.expoOut(clamp((st - q.banner) / 0.3))) / 8) * 8, 128, d < 0.6 ? cols[Math.floor(st * 20) % 4] : C.y); }
+ // 对话框:一行行打出来
+ if (st >= q.banner - 0.05) {
+ const bx = 112, by = 336, bw = 1696, bh = 200, op = MO.expoOut(clamp((st - q.banner + 0.05) / 0.12));
+ c.save(); c.fillStyle = '#000'; c.fillRect(bx, by + bh / 2 * (1 - op), bw, bh * op);
+ if (op > 0.9) { c.fillStyle = C.w; c.fillRect(bx + 8, by + 8, bw - 16, 8); c.fillRect(bx + 8, by + bh - 16, bw - 16, 8); c.fillRect(bx + 8, by + 8, 8, bh - 24); c.fillRect(bx + bw - 16, by + 8, 8, bh - 24);
+ const L1 = '1ST PRIVATE LIQUID-FUEL', L2 = 'ROCKET IN ORBIT', n = Math.floor((st - q.banner - 0.1) * 15);
+ ptext(c, L1.slice(0, clamp(n, 0, L1.length)), bx + 72, by + 40, 64, C.w, 'left');
+ ptext(c, L2.slice(0, clamp(n - L1.length - 2, 0, L2.length)), bx + 72, by + 112, 64, C.y, 'left');
+ if (n > L1.length + L2.length + 2 && Math.floor(st * 4) % 2) heart(c, ['kkkkkkk', '.kkkkk.', '..kkk..', '...k...'], bx + bw - 104, by + bh - 64, { k: C.w });
+ }
+ c.restore();
+ }
+ },
+};
+ERAS.find(e => e.id === ID).transition = { type: 'pixelate', dur: 0.5 };
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex/scenes/s04.js b/scripts/engine/reference_films/spacex/spacex/scenes/s04.js
new file mode 100644
index 0000000..1273dda
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex/scenes/s04.js
@@ -0,0 +1,263 @@
+// S04 · Vox 拼贴桌面(y2_vox 语法)——「三个月后,NASA 给了它一份合同,16亿美元,往空间站送货。2012年,龙飞船成了第一艘造访国际空间站的私人飞船。」
+// 一张大桌面=世界;相机 60fps 平滑地推、移(长尾 bezier / sineInOut),桌上的纸片、红线、荧光笔、打字、剪纸龙飞船按 12fps「一拍二」步进。
+// 时间线(全挂在口播 cue 上):
+// 进入转场 deskPullOut:上一段的像素游戏画面原地变成桌上的一张网点照片,相机从「照片铺满」拉出(Vox「从单张照片拉出 → 露出整面拼贴」)
+// 「三个月后」红线从照片(2008.9)牵到剪报,相机沿线追过去 →「16亿美元」「往空间站送货」两次荧光笔
+// 「2012年」相机沿第二根红线掠过「2010 猎鹰9号首飞」小卡,落到网点照片:剪纸龙飞船一顿一顿靠近空间站对接,黑底标签打字,红笔圈住对接口
+// 段尾相机推满黑色标签条 → 下一段(3b1b 黑底)从黑里长出来
+// 材料:CL 纸纹/网点/图钉/红线/荧光笔/倾斜滑入;CAM 关键帧相机;DG 手画圈;TY 打字机;MO 一拍二。不仿真实报纸刊头,不画任何机构标志。
+(() => {
+const W = 1920, H = 1080, { clamp, lerp } = U, seg = MO.seg, step = MO.step, TAU = Math.PI * 2;
+const ID = 's04', TR = { type: 'deskPullOut', dur: 0.85 };
+ERAS.find(e => e.id === ID).transition = TR;
+const DUR = TM.dur(ID), cue = k => TM.cue(ID, k), cend = k => TM.end(ID, k);
+
+const C = { desk: '#e4ddcf', news: '#eeedeb', ink: '#171716', red: '#b8433f', black: '#1b1b1a', paper: '#eeedeb', card: '#f6f4ee', yel: '#dacf08' };
+const F = { heavy: 'PuHui-Heavy', bold: 'PuHui-Bold', med: 'PuHui-Medium', num: 'Anton-400' };
+const T = {
+ photoTag: '2008.9 · 猎鹰1号入轨', tag3: '三个月后',
+ kicker: '2008.12', head: 'NASA 商业补给合同', l1a: '合同金额', l1b: '16亿美元', l2a: '任务', l2b: '12次空间站补给',
+ c10: '2010 · 猎鹰9号首飞', lbYear: '2012', lbText: '第一艘造访国际空间站的私人飞船',
+};
+
+// ---------- 世界布局(桌面坐标,px) ----------
+const PH = { x: 360, y: 430, w: 576, h: 324, b: 16 }; // 上一段画面变成的照片(内框 16:9)
+const N1 = { x: 1400, y: 540, w: 760, h: 560, r: -0.025 }; // 剪报:2008.12 商业补给合同
+const C10 = { x: 2150, y: 850, w: 380, h: 300, r: 0.045 }; // 小卡:2010 猎鹰9号首飞(只上画面)
+const P2 = { x: 2950, y: 430, w: 840, h: 520, b: 18, r: 0.02 }; // 网点照片:空间站
+const LB = { x: 2730, y: 690, w: 640, h: 180, r: -0.02 }; // Borders 式黑底标签条(压在照片左下角)
+const rot = (x, y, r) => [x * Math.cos(r) - y * Math.sin(r), x * Math.sin(r) + y * Math.cos(r)];
+const local = (o, x, y) => { const [a, b] = rot(x, y, o.r || 0); return [o.x + a, o.y + b]; };
+
+// ---------- 时刻(全部挂 cue) ----------
+const tStr1 = [0.7, 1.45]; // 「三个月后」:红线从照片牵到剪报
+const hl1 = [cue('16亿美元'), cend('16亿美元')];
+const hl2 = [cue('往空间站送货'), cend('往空间站送货')];
+const pan2 = cue('2012年') - 0.1;
+const tStr2 = [pan2 + 0.05, pan2 + 0.6], tStr3 = [pan2 + 0.55, pan2 + 1.15];
+const tLabel = pan2 + 1.05; // 标签条滑入
+const tType = cue('第一艘');
+const tDragon = cue('龙飞船') - 0.15, tDock = cue('国际空间站') + 0.15;
+const tCirc = tDock + 0.12;
+
+// ---------- 相机 ----------
+const KEYS = [
+ { t: 0, x: PH.x, y: PH.y, z: W / PH.w }, // 照片内框正好铺满画面(= 上一段的最后一帧)
+ { t: TR.dur, x: PH.x + 210, y: PH.y + 50, z: 1.18, ease: MO.longTail }, // 拉出揭示:起步快、长尾落定
+ { t: 1.05, x: PH.x + 240, y: PH.y + 55, z: 1.17, ease: MO.sineInOut },
+ { t: 2.2, x: N1.x - 10, y: N1.y - 10, z: 1.16, ease: MO.sineInOut }, // 沿红线追到剪报(「找下一张卡」用对称 Easy Ease,峰速低)
+ { t: hl2[1], x: N1.x - 40, y: N1.y + 40, z: 1.34, ease: MO.sineInOut }, // 荧光笔期间慢推向那两行
+ { t: pan2, x: N1.x - 40, y: N1.y + 42, z: 1.345 },
+ { t: pan2 + 0.65, x: C10.x + 40, y: 650, z: 1.0, ease: MO.cubicInOut }, // 「找下一张卡」:拉开、掠过 2010 小卡
+ { t: pan2 + 1.3, x: P2.x - 20, y: P2.y + 120, z: 1.12, ease: MO.longTail },
+ { t: DUR - 0.1, x: P2.x - 40, y: P2.y + 140, z: 1.2, ease: MO.sineInOut },
+];
+const LBK = local(LB, 130, -38); // 标签条右上的纯黑区:段尾推满它
+const camAt = (lt) => {
+ const p0 = DUR - 0.1, base = CAM.at(KEYS, Math.min(lt, p0));
+ if (lt <= p0) return base;
+ const e = MO.sineInOut(seg(lt, p0, DUR + 0.3));
+ return CAM.pushTo(base, LBK[0], LBK[1], 18, e, MO.smooth(seg(lt, p0, DUR + 0.2)));
+};
+
+// ---------- 网点化(上一段画面 → 桌上的照片;转场里逐帧算,照片里用缓存的那一帧) ----------
+const HT = { w: 960, h: 540, cell: 7 };
+let dsC = null, dsG = null;
+function halftone(out, src) {
+ if (!dsC) { dsC = PAINT.canvas(HT.w, HT.h); dsG = dsC.getContext('2d', { willReadFrequently: true }); }
+ dsG.reset(); dsG.drawImage(src, 0, 0, HT.w, HT.h);
+ const d = dsG.getImageData(0, 0, HT.w, HT.h).data, g = out.getContext('2d'); g.reset();
+ g.fillStyle = '#ece6d8'; g.fillRect(0, 0, HT.w, HT.h); g.fillStyle = '#1b1b1b';
+ const cell = HT.cell, k = Math.SQRT1_2, R = Math.hypot(HT.w, HT.h) / 2 + cell;
+ g.beginPath();
+ for (let v = -R; v < R; v += cell) for (let u = -R; u < R; u += cell) {
+ const x = HT.w / 2 + (u - v) * k, y = HT.h / 2 + (u + v) * k; if (x < -cell || y < -cell || x > HT.w + cell || y > HT.h + cell) continue;
+ const i = (clamp(y | 0, 0, HT.h - 1) * HT.w + clamp(x | 0, 0, HT.w - 1)) * 4;
+ const L = clamp(((d[i] * .3 + d[i + 1] * .59 + d[i + 2] * .11) / 255 - 0.5) * 1.2 + 0.5);
+ const rr = cell * 0.62 * Math.sqrt(1 - L); if (rr < 0.45) continue;
+ g.moveTo(x + rr, y); g.arc(x, y, rr, 0, TAU);
+ }
+ g.fill();
+ g.globalCompositeOperation = 'multiply'; g.fillStyle = 'rgba(214,205,185,.3)'; g.fillRect(0, 0, HT.w, HT.h); g.globalCompositeOperation = 'source-over';
+}
+// 照片里的画面 = 上一段在「转场结束那一刻」的画面(确定性:同一个 t 重画一次 s03,不依赖渲染顺序)
+let snapHT = null;
+function snapshot() {
+ if (snapHT) return snapHT;
+ const i3 = ERAS.findIndex(e => e.id === 's03'), e3 = ERAS[i3], e4 = ERAS.find(e => e.id === ID), t = e4.t0 + TR.dur;
+ const src = PAINT.canvas(W, H), g = src.getContext('2d');
+ g.save(); e3.draw(g, t - e3.t0, t, window.IMG, ERAS[i3 - 1]); g.restore();
+ snapHT = PAINT.canvas(HT.w, HT.h); halftone(snapHT, src); return snapHT;
+}
+// 屏幕空间:暗角+静态颗粒(Vox 的纸纹是贴死的,不逐帧抖)
+const finish = (c) => {
+ c.drawImage(PAINT.cached('s04_vig', W, H, (g) => { const r = g.createRadialGradient(W / 2, H / 2, H * 0.45, W / 2, H / 2, H * 1.05); r.addColorStop(0, 'rgba(40,30,20,0)'); r.addColorStop(1, 'rgba(40,30,20,.32)'); g.fillStyle = r; g.fillRect(0, 0, W, H); }), 0, 0);
+ c.drawImage(PAINT.grain('s04grain', 0.05, [40, 30, 20], 0.14), 0, 0);
+};
+// 转场用:在桌面相机下,把旧画面 A 画进照片内框;k 从 0(原样全彩)到 1(网点照片,和段内缓存那帧一致)
+let liveHT = null;
+const photoLive = (c, A, lt, p) => {
+ const k = MO.smooth(seg(p, 0.08, 0.72));
+ c.save(); CAM.apply(c, camAt(lt));
+ const x = PH.x - PH.w / 2, y = PH.y - PH.h / 2;
+ c.drawImage(A, x, y, PH.w, PH.h);
+ if (k > 0) { if (!liveHT) liveHT = PAINT.canvas(HT.w, HT.h); halftone(liveHT, A); c.globalAlpha = k; c.drawImage(liveHT, x, y, PH.w, PH.h); }
+ c.restore();
+ // 照片区域也要叠段内的暗角+颗粒(权重同 k),否则转场结束那一帧照片会突然变暗
+ if (k > 0) { c.save(); CAM.apply(c, camAt(lt)); c.beginPath(); c.rect(x, y, PH.w, PH.h); c.restore(); c.save(); c.clip(); c.globalAlpha = k; finish(c); c.restore(); }
+};
+window.S04X = { photoLive, camAt };
+
+// ---------- 素材(一次画好缓存;2 倍分辨率,推近时不糊) ----------
+const S2 = 2, sprite = (key, w, h, fn) => PAINT.cached('s04_' + key, w * S2, h * S2, (g) => { g.scale(S2, S2); fn(g); });
+const font = (sz, fam) => `${sz}px "${fam}"`;
+const NEWS = {}; // 荧光笔的位置(剪报局部坐标,原点在左上)
+const newsSprite = () => sprite('news', N1.w, N1.h, (g) => {
+ const tile = CL.paperTile('s04news', C.news, { amt: 9, fibers: 160, seed: 11 });
+ g.save(); CL.tornRect(g, N1.w, N1.h, 21, 4); g.clip(); g.fillStyle = g.createPattern(tile, 'repeat'); g.fillRect(0, 0, N1.w, N1.h);
+ const yel = g.createRadialGradient(N1.w * 0.4, N1.h * 0.4, 50, N1.w * 0.5, N1.h * 0.5, N1.w * 0.75); yel.addColorStop(0, 'rgba(255,255,255,0)'); yel.addColorStop(1, 'rgba(170,150,110,.22)'); g.fillStyle = yel; g.fillRect(0, 0, N1.w, N1.h);
+ g.fillStyle = C.ink; g.textBaseline = 'alphabetic';
+ g.font = font(30, F.bold); g.fillText(T.kicker, 54, 76);
+ g.fillRect(54, 94, N1.w - 108, 3); g.fillRect(54, 101, N1.w - 108, 1);
+ g.font = font(64, F.heavy); g.fillText(T.head, 54, 192);
+ g.fillRect(54, 222, N1.w - 108, 1.5);
+ g.font = font(38, F.med); g.fillStyle = '#2a2723'; g.fillText(T.l1a, 54, 305); let x1 = 54 + g.measureText(T.l1a).width + 22;
+ g.font = font(62, F.heavy); g.fillStyle = C.ink; g.fillText(T.l1b, x1, 310); NEWS.hl1 = { x: x1 - 10, y: 252, w: g.measureText(T.l1b).width + 20, h: 72 };
+ g.font = font(38, F.med); g.fillStyle = '#2a2723'; g.fillText(T.l2a, 54, 395); let x2 = 54 + g.measureText(T.l2a).width + 22;
+ g.font = font(46, F.heavy); g.fillStyle = C.ink; g.fillText(T.l2b, x2, 398); NEWS.hl2 = { x: x2 - 10, y: 352, w: g.measureText(T.l2b).width + 20, h: 60 };
+ g.fillStyle = 'rgba(40,36,30,.28)'; [640, 600, 650, 420].forEach((w, i) => g.fillRect(54, 444 + i * 26, w, 11));
+ g.restore();
+});
+// 2010 小卡:横线索引卡+网点小照片(猎鹰9号立在发射台上)
+const c10Sprite = () => sprite('c10', C10.w, C10.h, (g) => {
+ g.fillStyle = C.card; g.fillRect(0, 0, C10.w, C10.h);
+ g.strokeStyle = 'rgba(80,140,200,.28)'; g.lineWidth = 1.5; for (let y = 70; y < C10.h; y += 34) { g.beginPath(); g.moveTo(0, y); g.lineTo(C10.w, y); g.stroke(); }
+ const ph = CL.photo('s04_f9', 300, 170, (gg, w, h) => {
+ const sk = gg.createLinearGradient(0, 0, 0, h); sk.addColorStop(0, '#9a9a9a'); sk.addColorStop(1, '#d8d8d8'); gg.fillStyle = sk; gg.fillRect(0, 0, w, h);
+ gg.fillStyle = '#555'; gg.fillRect(0, h - 22, w, 22); gg.fillStyle = '#3a3a3a'; gg.fillRect(w * 0.62, 20, 10, h - 40); // 地面、塔
+ RK.at(gg, w * 0.5, h - 20, 1.95, 0, q => RK.fill(q, RK.falcon9({ payload: 'fairing' }), { body: '#f2f2f2', dark: '#2a2a2a', nose: '#f2f2f2', engine: '#333' }));
+ }, { border: 8, cell: 4 });
+ g.save(); g.translate(C10.w / 2, 112); g.rotate(-0.02); g.drawImage(ph, -ph.width / 2, -ph.height / 2); g.restore();
+ g.fillStyle = C.ink; g.font = font(32, F.bold); g.textAlign = 'center'; g.fillText(T.c10, C10.w / 2, C10.h - 34);
+});
+// 网点照片:近地轨道上的空间站(自己画的简化桁架+太阳翼+舱段,过 45° 网点)
+const stationDraw = (g, w, h) => {
+ g.scale(w / P2.w, h / P2.h); const cx = P2.w / 2, cy = P2.h / 2;
+ const sk = g.createLinearGradient(0, 0, 0, P2.h); sk.addColorStop(0, '#0b0b0b'); sk.addColorStop(1, '#222'); g.fillStyle = sk; g.fillRect(0, 0, P2.w, P2.h);
+ const eg = g.createRadialGradient(cx + 120, cy + 1420, 1100, cx + 120, cy + 1420, 1210); eg.addColorStop(0, '#b9b9b9'); eg.addColorStop(0.86, '#8c8c8c'); eg.addColorStop(1, 'rgba(60,60,60,0)');
+ g.fillStyle = eg; g.beginPath(); g.arc(cx + 120, cy + 1420, 1210, 0, TAU); g.fill(); // 地球边缘
+ g.fillStyle = 'rgba(230,230,230,.5)'; g.beginPath(); g.arc(cx + 120, cy + 1420, 1166, Math.PI * 1.25, Math.PI * 1.75); g.lineTo(cx + 120, cy + 1420); g.fill();
+ g.save(); g.translate(cx, cy - 40);
+ const panel = (x, y, pw, ph) => { g.fillStyle = '#585858'; g.fillRect(x, y, pw, ph); g.strokeStyle = '#9d9d9d'; g.lineWidth = 2; for (let k = 1; k < 4; k++) { g.beginPath(); g.moveTo(x + pw * k / 4, y); g.lineTo(x + pw * k / 4, y + ph); g.stroke(); } for (let k = 1; k < 8; k++) { g.beginPath(); g.moveTo(x, y + ph * k / 8); g.lineTo(x + pw, y + ph * k / 8); g.stroke(); } };
+ for (const x of [-300, -228, 178, 250]) { panel(x, -58 - 150, 52, 150); panel(x, -42, 52, 150); }
+ g.fillStyle = '#d9d9d9'; g.fillRect(-330, -58, 660, 16); // 桁架
+ g.strokeStyle = '#7a7a7a'; g.lineWidth = 2; for (let x = -330; x < 330; x += 22) { g.beginPath(); g.moveTo(x, -58); g.lineTo(x + 11, -42); g.lineTo(x + 22, -58); g.stroke(); }
+ g.fillStyle = '#c9c9c9'; for (const x of [-120, 90]) g.fillRect(x, -40, 30, 60); // 散热板
+ const cyl = (x, y, cw, ch) => { const gr = g.createLinearGradient(x, 0, x + cw, 0); gr.addColorStop(0, '#9a9a9a'); gr.addColorStop(0.45, '#f4f4f4'); gr.addColorStop(1, '#8a8a8a'); g.fillStyle = gr; g.beginPath(); g.roundRect(x, y, cw, ch, 8); g.fill(); };
+ cyl(-24, -96, 48, 70); cyl(-22, -30, 44, 82); cyl(-18, 50, 36, 46); // 舱段(竖直一串)
+ g.fillStyle = '#e8e8e8'; g.beginPath(); g.roundRect(-110, -20, 220, 36, 12); g.fill(); // 横向节点舱
+ g.fillStyle = '#bdbdbd'; g.fillRect(-12, 96, 24, 14); // 对接口(朝下)
+ g.restore();
+};
+const PORT = [0, -40 + 110]; // 对接口,照片局部坐标(原点在照片中心)
+const p2Sprite = () => CL.photo('s04_iss', P2.w * S2, P2.h * S2, stationDraw, { border: P2.b * S2, cell: 9 });
+// 剪纸龙飞船:RK.dragon 平涂 → 网点 → 纸白贴纸边(16 方向外扩)
+const DR = { s: 16, w: 3.9 * 16, h: (2.8 + 4.35) * 16 };
+const dragonSprite = () => PAINT.cached('s04_dragon', 220 * S2, 300 * S2, (g) => {
+ const src = PAINT.canvas(220 * S2, 300 * S2), sg = src.getContext('2d');
+ RK.at(sg, 110 * S2, 150 * S2 + DR.h * S2 / 2, DR.s * S2, 0, q => RK.fill(q, RK.dragon({ trunk: true }), { body: '#ececec', trunk: '#b5b5b5', nose: '#dadada', window: '#202020', line: '#3a3a3a', lw: 0.12 }));
+ const ht = CL.halftone('s04_dragon_ht', src, { cell: 7, paper: '#f1ede4', contrast: 1.35 });
+ for (let a = 0; a < 16; a++) g.drawImage(ht, Math.cos(a / 16 * TAU) * 7 * S2, Math.sin(a / 16 * TAU) * 7 * S2);
+ g.globalCompositeOperation = 'source-in'; g.fillStyle = '#f4f2ec'; g.fillRect(0, 0, g.canvas.width, g.canvas.height);
+ g.globalCompositeOperation = 'source-over'; g.drawImage(ht, 0, 0);
+});
+const tile = () => CL.paperTile('s04desk', C.desk, { amt: 12, fibers: 320, fiberCol: [110, 95, 70], seed: 7 });
+
+// ---------- 红线 ----------
+const PIN_A = [PH.x + PH.w / 2 + PH.b / 2 + 6, PH.y - PH.h / 2 + 34]; // 照片右边框(不压进内框:转场时旧画面盖在内框上)
+const PIN_N1 = local(N1, -N1.w / 2 + 40, -N1.h / 2 + 36), PIN_N1R = local(N1, N1.w / 2 - 36, -N1.h / 2 + 40);
+const PIN_C10 = local(C10, 0, -C10.h / 2 + 20), PIN_P2 = local(P2, -P2.w / 2 + 50, -P2.h / 2 - 2);
+const mkStr = (a, b, sag) => { const pts = CL.stringPts(a, b, sag); return { a, b, pts, cum: DG.cum(pts) }; };
+const STR1 = mkStr(PIN_A, PIN_N1, 0.12), STR2 = mkStr(PIN_N1R, PIN_C10, 0.06), STR3 = mkStr(PIN_C10, PIN_P2, 0.08);
+const strAt = (S, q) => { const L = S.cum[S.cum.length - 1]; return { d: L * q, tip: DG.pointAt(S.pts, S.cum, L * q) }; };
+const RCIRC = DG.hand(DG.ellipsePts(0, 0, 96, 74, -2.4, 1.1, 44), { amp: 2.2, seed: 13 }), RCIRC_L = DG.cum(RCIRC);
+
+// ---------- 画桌面 ----------
+const shadowed = CL.shadowed, placed = CL.placed;
+const tag = (g, x, y, r, text, size, { bg = C.black, col = C.paper, padX = 22, h = size * 1.7, fam = F.heavy } = {}) => placed(g, x, y, r, (g) => {
+ g.font = font(size, fam); const w = g.measureText(text).width + padX * 2;
+ shadowed(g, () => { g.fillStyle = bg; g.fillRect(-w / 2, -h / 2, w, h); });
+ g.fillStyle = col; g.textAlign = 'center'; g.textBaseline = 'middle'; g.fillText(text, 0, size * 0.04);
+});
+function drawDesk(g, cam, lt) {
+ const st = step(lt);
+ g.save(); CAM.apply(g, cam);
+ g.fillStyle = g.createPattern(tile(), 'repeat'); g.fillRect(-1500, -1200, 6600, 3600);
+ // —— 照片(上一段)——
+ shadowed(g, () => { g.fillStyle = '#f2f0ea'; g.fillRect(PH.x - PH.w / 2 - PH.b, PH.y - PH.h / 2 - PH.b, PH.w + PH.b * 2, PH.h + PH.b * 2); });
+ g.drawImage(snapshot(), PH.x - PH.w / 2, PH.y - PH.h / 2, PH.w, PH.h);
+ tag(g, PH.x - 70, PH.y + PH.h / 2 + 58, -0.015, T.photoTag, 38);
+ // —— 剪报 ——
+ placed(g, N1.x, N1.y, N1.r, (g) => {
+ const sp = newsSprite(); shadowed(g, () => g.drawImage(sp, -N1.w / 2, -N1.h / 2, N1.w, N1.h));
+ const o = [-N1.w / 2, -N1.h / 2];
+ CL.highlight(g, o[0] + NEWS.hl1.x, o[1] + NEWS.hl1.y, NEWS.hl1.w, NEWS.hl1.h, MO.sineInOut(seg(st, hl1[0], hl1[0] + 0.75)));
+ CL.highlight(g, o[0] + NEWS.hl2.x, o[1] + NEWS.hl2.y, NEWS.hl2.w, NEWS.hl2.h, MO.sineInOut(seg(st, hl2[0], hl2[0] + 0.85)));
+ });
+ // —— 2010 小卡 ——
+ placed(g, C10.x, C10.y, C10.r, (g) => shadowed(g, () => g.drawImage(c10Sprite(), -C10.w / 2, -C10.h / 2, C10.w, C10.h)));
+ // —— 网点照片:空间站 + 剪纸龙飞船 ——
+ placed(g, P2.x, P2.y, P2.r, (g) => {
+ const sp = p2Sprite(), ww = P2.w + P2.b * 2, hh = P2.h + P2.b * 2;
+ shadowed(g, () => g.drawImage(sp, -ww / 2, -hh / 2, ww, hh));
+ CL.tape(g, ww / 2 - 70, -hh / 2 + 8, 0.45, 130);
+ // 龙飞船:一拍二地从照片下方靠近对接口(12fps 步进+到位前一点点姿态修正)
+ const q = clamp((st - tDragon) / (tDock - tDragon));
+ if (q > 0) {
+ const e = MO.smooth(q), dock = [PORT[0], PORT[1] + DR.h / 2 + 2];
+ const x = lerp(-150, dock[0], e), y = lerp(P2.h / 2 + 150, dock[1], e) + (q >= 1 ? MO.settle(st - tDock, 3, 3, 6) : 0);
+ const r = lerp(-0.32, 0, MO.smooth(q)) + (q < 1 ? 0.02 * Math.sin(st * 9) : 0);
+ const ds = dragonSprite();
+ g.save(); g.translate(x, y); g.rotate(r);
+ shadowed(g, () => g.drawImage(ds, -110, -150, 220, 300), { blur: 8, x: 3, y: 5, col: 'rgba(0,0,0,.35)' });
+ g.restore();
+ }
+ const cq = MO.cubicOut(seg(st, tCirc, tCirc + 0.6)); // 红笔圈住对接口(首尾略交叉)
+ if (cq > 0) { g.save(); g.translate(PORT[0], PORT[1] + 36); g.strokeStyle = C.red; g.lineWidth = 7; g.lineCap = 'round'; g.lineJoin = 'round'; DG.drawPartial(g, RCIRC, RCIRC_L, RCIRC_L[RCIRC_L.length - 1] * cq); g.restore(); }
+ });
+ // —— 红线(一拍二描出;图钉随线头出现)——
+ const string = (S, t0, t1, tagText) => {
+ const q = MO.sineInOut(seg(st, t0, t1)); if (q <= 0) return;
+ const { d } = strAt(S, q); CL.string(g, S.pts, S.cum, d, { col: C.red, lw: 5 }); CL.pin(g, S.a[0], S.a[1], C.red); if (q >= 1) CL.pin(g, S.b[0], S.b[1], C.red);
+ if (tagText && q > 0.5) { const m = DG.pointAt(S.pts, S.cum, S.cum[S.cum.length - 1] * 0.5); tag(g, m[0], m[1] + 44, 0.05, tagText, 36, { bg: '#f6f4ee', col: C.ink, fam: F.bold }); }
+ };
+ string(STR1, tStr1[0], tStr1[1], T.tag3);
+ string(STR2, tStr2[0], tStr2[1]); string(STR3, tStr3[0], tStr3[1]);
+ // —— 黑底标签条:「2012」随条滑入,下一行按 13 字/秒打出 ——
+ CL.slideIn(g, lt, tLabel, LB.x, LB.y, LB.r, (g) => {
+ shadowed(g, () => { g.fillStyle = C.black; g.save(); g.translate(-LB.w / 2, -LB.h / 2); CL.tornRect(g, LB.w, LB.h, 77, 3); g.fill(); g.restore(); });
+ g.fillStyle = C.yel; g.font = font(78, F.num); g.textBaseline = 'alphabetic'; g.fillText(T.lbYear, -LB.w / 2 + 28, -LB.h / 2 + 92);
+ g.fillStyle = C.paper; g.font = font(34, F.heavy);
+ const n = TY.typedCount(st, tType, 13); let x = -LB.w / 2 + 30;
+ [...T.lbText].forEach((ch, i) => { if (i < n) g.fillText(ch, x, LB.h / 2 - 30); x += g.measureText(ch).width; });
+ }, { from: [-60, 380], tilt: -0.14, dur: 0.5 });
+ g.restore();
+}
+
+const blurOn = lt => (lt > 1.0 && lt < 2.2) || (lt > pan2 && lt < pan2 + 1.3);
+
+SCENES[ID] = {
+ init() {
+ const all = Object.values(T).join('');
+ U.assertGlyphs(F.heavy, all, ID); U.assertGlyphs(F.bold, all, ID); U.assertGlyphs(F.med, T.l1a + T.l2a, ID); U.assertGlyphs(F.num, T.lbYear, ID);
+ },
+ draw(c, lt) {
+ const cam = camAt(lt);
+ const buf = PAINT.scratch('s04desk'), g = buf.getContext('2d'); g.reset();
+ drawDesk(g, cam, lt);
+ c.fillStyle = C.desk; c.fillRect(0, 0, W, H);
+ if (blurOn(lt)) { const [vx, vy] = CAM.velocity(camAt, lt); CAM.motionBlur(c, buf, vx * 0.4, vy * 0.4, 7); } else c.drawImage(buf, 0, 0);
+ finish(c);
+ },
+};
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex/scenes/s05.js b/scripts/engine/reference_films/spacex/spacex/scenes/s05.js
new file mode 100644
index 0000000..ddb5e5f
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex/scenes/s05.js
@@ -0,0 +1,216 @@
+// S05 · 3Blue1Brown 物理示意(t1_3b1b 语法)——「它想把火箭的一级飞回来,重复用。2015年12月,猎鹰9号的一级竖着落回了地面,轨道火箭里这是头一回;2017年,回收的一级又一次飞上了天。」
+// 纯黑底,manim 色板(×1.5 饱和),颜色=概念、全段不换:白=箭体,灰=上升轨迹,蓝=一级返回的弹道,黄=推力(矢量箭头与「头一回」的强调),青=着陆区。
+// 一个连续场景,几乎不切:上升 → 分离 → 掉头(回推点火)→ 再入点火 → 着陆点火、着陆腿展开、竖着落在着陆区 → Indicate「头一回」
+// → 2017:同一枚一级 Transform 回发射台、长出二级,再次升空(第2次飞行)。阶段标签用 Write 写出,跟着口播 cue。
+// 箭体照 spacex/rockets.js 的猎鹰9号比例自己重画(manim 式白描边+黑填充),着陆腿按真实结构:底部铰接、向下外翻、脚垫低于发动机。
+(() => {
+const W = 1920, H = 1080, { clamp, lerp } = U, seg = MO.seg, sm = MO.smooth, TAU = Math.PI * 2;
+const ID = 's05';
+ERAS.find(e => e.id === ID).transition = { type: 'matchCut', dur: 0.6, at: 0.62, width: 0.16 }; // 上一段推满黑标签 → 黑里长出本段
+const DUR = TM.dur(ID), cue = k => TM.cue(ID, k);
+const M = DG.MANIM, ZH = 'PuHui-Medium';
+const T = { title: '把一级飞回来,重复用', sep: '分离', flip: '掉头', thrust: '推力', entry: '再入', land: '着陆', y15: '2015.12', first: '轨道火箭 · 头一回', y17: '2017', second: '第2次飞行', lz: '着陆区' };
+
+// ---------- 时刻(全部挂 cue) ----------
+const tTitle = cue('它想把'), tLift = 0.55, tSep = cue('一级飞回来') + 0.05;
+const tFlip = [tSep + 0.1, tSep + 0.75], tBoost = [tSep + 0.6, 3.35], tUpright = [3.35, 4.05], tFins = [3.3, 3.7];
+const tY15 = cue('2015年12月'), tEntry = [cue('猎鹰9号') - 0.3, cue('猎鹰9号') + 0.25];
+const tLand = cue('落回'), tLburn = [tLand - 0.75, tLand], tLegs = [tLand - 0.6, tLand - 0.08];
+const tInd = cue('轨道火箭'), tFirst = cue('头一回');
+const t17 = cue('2017年'), tRetract = [t17 + 0.08, t17 + 0.45], tMove = [t17 + 0.35, t17 + 1.05], tStack = [t17 + 0.8, t17 + 1.3];
+const tSecond = cue('回收的一级'), tRelift = cue('飞上了天') - 0.45;
+
+// ---------- 几何(px;1 m = K px,比例照 RK.falcon9:一级 41 m、二级 13 m、整流罩 13 m、直径 3.7 m) ----------
+const K = 4.2, GROUND = 800, PAD = 420, LZ = 700;
+const LEGTIP = 3.6; // 展开后脚垫低于发动机平面 3.6 m
+const BASE_ON_GROUND = GROUND - 1.0 * K, BASE_ON_LEGS = GROUND - LEGTIP * K;
+const HALF = 20.5; // 一级中心到底的距离(m)
+const bez = (a, b, c2, d, u) => { const v = 1 - u; return [v * v * v * a[0] + 3 * v * v * u * b[0] + 3 * v * u * u * c2[0] + u * u * u * d[0], v * v * v * a[1] + 3 * v * v * u * b[1] + 3 * v * u * u * c2[1] + u * u * u * d[1]]; };
+const ASC = [[PAD, BASE_ON_GROUND], [PAD, 560], [800, 470], [1060, 300]]; // 上升轨迹(箭底)
+const ascAt = u => bez(...ASC, u);
+const ascRot = u => { const a = ascAt(Math.max(0, u - 0.002)), b = ascAt(Math.min(1, u + 0.002)); return Math.atan2(b[0] - a[0], -(b[1] - a[1])); };
+const ROT_SEP = ascRot(1), DIR = [Math.sin(ROT_SEP), -Math.cos(ROT_SEP)];
+const SEP_BASE = ascAt(1), B0 = [SEP_BASE[0] + DIR[0] * HALF * K, SEP_BASE[1] + DIR[1] * HALF * K];
+const LAND_C = [LZ, BASE_ON_LEGS - HALF * K], PAD_C = [PAD, BASE_ON_GROUND - HALF * K];
+// 一级返回弹道(中心点):向右上冲出 → 回推掉头 → 落回着陆区
+const RET = (() => { const o = [];
+ const P = [B0, [1300, 120], [1090, 60], [910, 200]], Q = [[910, 200], [730, 340], [LZ + 8, 520], LAND_C];
+ for (let i = 0; i <= 80; i++) o.push(bez(...P, i / 80)); for (let i = 1; i <= 80; i++) o.push(bez(...Q, i / 80)); return o; })();
+const RET_L = DG.cum(RET), RET_LEN = RET_L[RET_L.length - 1];
+// 时间 → 弧长:回推段(到掉头的弧顶以下)带着初速走完,下降段先加速、着陆点火时速度归零
+const L1 = RET_L[80], tCurl = 3.75, e1 = MO.bezier(0.25, 0.35, 0.65, 0.8), e2 = MO.bezier(0.35, 0.25, 0.3, 1);
+const retS = t => t < tCurl ? L1 * e1(seg(t, tSep, tCurl)) : L1 + (RET_LEN - L1) * e2(seg(t, tCurl, tLand));
+// 相机(manim MovingCamera):着陆前推近着陆区,2017 拉回全景;标题与年份固定在屏幕上,不随相机动
+const CAMK = [
+ { t: 0, x: 960, y: 540, z: 1 }, { t: 4.3, x: 960, y: 540, z: 1.02, ease: MO.sineInOut },
+ { t: 5.2, x: 760, y: 620, z: 1.3, ease: MO.smooth }, { t: t17, x: 760, y: 620, z: 1.36, ease: MO.sineInOut },
+ { t: t17 + 0.8, x: 960, y: 540, z: 1.0, ease: MO.smooth }, { t: DUR + 1, x: 960, y: 535, z: 1.025, ease: MO.linear }];
+
+// ---------- 箭体(米制路径,原点=发动机平面中心,向上 −y) ----------
+const P2D = () => new Path2D();
+const bell = (p, w0, w1, y0, y1) => { p.moveTo(-w0 / 2, y0); p.lineTo(w0 / 2, y0); p.lineTo(w1 / 2, y1); p.lineTo(-w1 / 2, y1); p.closePath(); };
+const D = 3.7, H1 = 41;
+function boosterPaths(fins, legs) {
+ const body = P2D(); body.rect(-D / 2, -H1, D, H1);
+ const inter = P2D(); inter.rect(-D / 2, -H1, D, 4.2);
+ const eng = P2D(); bell(eng, 1.5, 2.6, 0, 1.0);
+ const fn = P2D(), fl = 0.6 + fins * 1.3; fn.rect(-D / 2 - fl, -H1 + 0.7, fl, 1.3); fn.rect(D / 2, -H1 + 0.7, fl, 1.3);
+ const lg = P2D(), a = legs * 2.1, L = 9.5; // 底部铰接:收起时贴着箭体朝上,展开时向下外翻 120°
+ for (const s of [-1, 1]) { const hx = s * D / 2, hy = -1.2, tx = hx + s * Math.sin(a) * L, ty = hy - Math.cos(a) * L;
+ lg.moveTo(hx, hy); lg.lineTo(tx, ty); if (legs > 0.05) { const mx = lerp(hx, tx, 0.55), my = lerp(hy, ty, 0.55); lg.moveTo(hx, -8.5); lg.lineTo(mx, my); lg.moveTo(tx - s * 0.9 * legs, ty); lg.lineTo(tx + s * 0.6 * legs, ty); } }
+ return { body, inter, eng, fn, lg };
+}
+const upperPaths = (() => { const s2 = P2D(); s2.rect(-D / 2, -H1 - 13, D, 13);
+ const fair = P2D(); fair.rect(-2.6, -H1 - 19.5, 5.2, 6.5);
+ const og = RK.ogive(5.2, 6.5, -H1 - 19.5);
+ return { s2, fair, og }; })();
+const LW = 2.6 / K;
+// 在 (x, y) 处画,旋转 rot(0=竖直),anchor=该屏幕点对应箭体上距底部多少米;opt: fins, legs, upper(0..1 长出二级), tint(0..1 染黄), s(缩放)
+function rocket(c, x, y, rot, anchor, { fins = 0, legs = 0, upper = 0, tint = 0, s = 1, alpha = 1, only } = {}) {
+ const P = boosterPaths(fins, legs), stroke = tint > 0 ? DG.mix('#ffffff', M.YELLOW, tint) : '#ffffff';
+ c.save(); c.globalAlpha *= alpha; c.translate(x, y); c.rotate(rot); c.scale(K * s, K * s); c.translate(0, anchor);
+ c.lineJoin = 'round'; c.lineCap = 'round'; c.lineWidth = LW / s; c.strokeStyle = stroke;
+ if (only !== 'upper') {
+ c.fillStyle = '#000'; c.fill(P.body); c.fillStyle = M.GREY_D; c.fill(P.inter); c.fill(P.eng);
+ c.stroke(P.body); c.stroke(P.eng); c.stroke(P.lg); c.fillStyle = '#000'; c.fill(P.fn); c.stroke(P.fn);
+ }
+ if (upper > 0) {
+ c.save(); const top = -H1 - (19.5 + 6.6) * upper; c.beginPath(); c.rect(-4, top, 8, -H1 - top + 0.01); c.clip();
+ c.fillStyle = '#000'; c.fill(upperPaths.s2); c.fill(upperPaths.fair); c.fill(upperPaths.og);
+ c.stroke(upperPaths.s2); c.stroke(upperPaths.fair); c.stroke(upperPaths.og); c.restore();
+ }
+ c.restore();
+}
+// 尾焰:沿箭体轴向后喷(不发光,manim 式平涂两层),len 像素
+function plume(c, x, y, rot, anchor, len, t, k = 1) {
+ if (len <= 0) return;
+ c.save(); c.translate(x, y); c.rotate(rot); c.translate(0, anchor * K + 1.0 * K);
+ const f = len * (1 + 0.08 * Math.sin(t * 41) + 0.05 * Math.sin(t * 67 + 1)) * k, w = 2.3 * K;
+ const lay = (sc, col) => { c.fillStyle = col; c.beginPath(); c.moveTo(-w * sc / 2, 0); c.quadraticCurveTo(-w * sc * 0.6, f * sc * 0.45, 0, f * sc); c.quadraticCurveTo(w * sc * 0.6, f * sc * 0.45, w * sc / 2, 0); c.closePath(); c.fill(); };
+ lay(1, DG.rgba(M.GOLD_C, 0.9)); lay(0.55, M.YELLOW);
+ c.restore();
+}
+// 矢量箭头(manim Arrow:线+实心三角头)
+function arrow(c, x0, y0, x1, y1, col, lw = 6, head = 24) {
+ const dx = x1 - x0, dy = y1 - y0, L = Math.hypot(dx, dy); if (L < 2) return;
+ const ux = dx / L, uy = dy / L, hb = Math.min(head, L * 0.5);
+ c.save(); c.strokeStyle = col; c.fillStyle = col; c.lineWidth = lw; c.lineCap = 'round';
+ c.beginPath(); c.moveTo(x0, y0); c.lineTo(x1 - ux * hb * 0.7, y1 - uy * hb * 0.7); c.stroke();
+ c.beginPath(); c.moveTo(x1, y1); c.lineTo(x1 - ux * hb - uy * hb * 0.42, y1 - uy * hb + ux * hb * 0.42); c.lineTo(x1 - ux * hb + uy * hb * 0.42, y1 - uy * hb - ux * hb * 0.42); c.closePath(); c.fill(); c.restore();
+}
+// Write:中文换成普惠体(DG.write 默认的思源宋子集缺本片的字),数字仍走 CMU(LaTeX 字体)
+const wr = (c, text, x, y, size, p, opt = {}) => { if (p <= 0) return; const z = DG.FONT.zh; DG.FONT.zh = ZH; DG.write(c, text, x, y, size, p, opt); DG.FONT.zh = z; };
+const line = (c, pts, col, lw, alpha = 1, dash) => { if (pts.length < 2) return; c.save(); c.globalAlpha *= alpha; c.strokeStyle = col; c.lineWidth = lw; c.lineCap = 'round'; c.lineJoin = 'round'; if (dash) c.setLineDash(dash); c.beginPath(); pts.forEach((q, i) => i ? c.lineTo(q[0], q[1]) : c.moveTo(q[0], q[1])); c.stroke(); c.restore(); };
+const dot = (c, x, y, a) => { if (a <= 0) return; c.save(); c.globalAlpha *= a; c.fillStyle = '#fff'; c.beginPath(); c.arc(x, y, 6, 0, TAU); c.fill(); c.restore(); };
+
+// ---------- 一级的状态(位置、朝向、腿、舵、推力) ----------
+function booster(t) {
+ if (t < tSep) return null;
+ if (t < t17) {
+ const p = DG.pointAt(RET, RET_L, retS(t));
+ let rot = ROT_SEP;
+ rot = lerp(rot, -1.35, sm(seg(t, ...tFlip))); // 掉头:转到机头朝回(左)
+ rot = lerp(rot, 0, sm(seg(t, ...tUpright))); // 回推结束后转正、发动机朝下再入
+ if (t > tUpright[1] && t < tLand) rot += 0.025 * Math.sin((t - tUpright[1]) * 5.5) * (1 - seg(t, tLburn[0], tLand));
+ return { x: p[0], y: p[1], rot, legs: sm(seg(t, ...tLegs)), fins: sm(seg(t, ...tFins)) };
+ }
+ // 2017:腿收起 → Transform 回发射台 → 长出二级 → 再次升空
+ const m = sm(seg(t, ...tMove)), legs = 1 - sm(seg(t, ...tRetract));
+ let x = lerp(LAND_C[0], PAD_C[0], m), y = lerp(LAND_C[1], PAD_C[1], m);
+ let rot = 0;
+ if (t > tRelift) { // 再飞一次:沿第一次的上升轨迹,过了分离点继续沿切线飞出右上(不穿过标题)
+ const q = (t - tRelift) / 1.0, u = Math.min(1, Math.pow(q, 1.5)), extra = q > 1 ? 900 * (q - 1) + 600 * (q - 1) ** 2 : 0;
+ const b = ascAt(u), r = ascRot(u), bx = b[0] + DIR[0] * extra, by = b[1] + DIR[1] * extra;
+ rot = r; x = bx + Math.sin(r) * HALF * K; y = by - Math.cos(r) * HALF * K;
+ }
+ return { x, y, rot, legs, fins: 1 - sm(seg(t, ...tMove)), upper: sm(seg(t, ...tStack)) };
+}
+
+SCENES[ID] = {
+ init() { U.assertGlyphs(ZH, Object.values(T).filter(s => /[^\x00-\x7f]/.test(s)).join('').replace(/[\x00-\x7f]/g, ''), ID); U.assertGlyphs('CMU-rm', '2015.122017', ID); },
+ draw(c, lt) {
+ const t = lt;
+ c.fillStyle = '#000'; c.fillRect(0, 0, W, H);
+ const cam = CAM.at(CAMK, t);
+ // —— 标题(Write,先问后演),年份角标:屏幕坐标 ——
+ wr(c, T.title, 140, 128, 54, seg(t, tTitle, tTitle + 1.0), { align: 'left' });
+ { const out = sm(seg(t, t17, t17 + 0.35)); c.save(); c.globalAlpha = 1 - out; c.translate(0, -40 * out); wr(c, T.y15, 1780, 128, 72, seg(t, tY15, tY15 + 0.8), { align: 'right' }); c.restore(); }
+ wr(c, T.y17, 1780, 128, 72, seg(t, t17 + 0.2, t17 + 0.8), { align: 'right' });
+ c.save(); CAM.apply(c, cam);
+ const fade17 = 1 - sm(seg(t, t17, t17 + 0.45)); // 2017:旧的上升轨迹、头一回标签淡走
+ const dim17 = lerp(1, 0.3, sm(seg(t, t17, t17 + 0.5))); // 返回弹道与阶段标签留作「历史」,压暗
+
+ // —— 地面、发射台、着陆区(Create) ——
+ const gq = sm(seg(t, 0.0, 0.42)); // 转场揭开(约 0.32s)时地平线、发射台、火箭都已在画里
+ if (gq > 0) line(c, [[140, GROUND], [lerp(140, 1780, gq), GROUND]], M.GREY_B, 3);
+ const pq = sm(seg(t, 0.08, 0.45));
+ if (pq > 0) { c.save(); c.globalAlpha = pq; c.strokeStyle = M.GREY_B; c.lineWidth = 3; c.strokeRect(PAD - 34, GROUND, 68, 12); c.restore();
+ c.save(); c.strokeStyle = M.TEAL_C; c.lineWidth = 4; c.beginPath(); c.ellipse(LZ, GROUND + 2, 62, 13, 0, Math.PI * (1 - pq), Math.PI * (1 + pq * 2) ); c.stroke(); c.restore();
+ c.save(); c.globalAlpha = pq; c.fillStyle = M.TEAL_C; c.font = `34px "${ZH}"`; c.textAlign = 'center'; c.fillText(T.lz, LZ, GROUND + 66); c.restore(); }
+
+
+ // —— 轨迹:上升(灰)、二级继续(灰虚线)、一级返回(蓝) ——
+ const ua = Math.pow(seg(t, tLift, tSep), 1.5);
+ if (t > tLift) { const pts = []; for (let i = 0; i <= 60; i++) pts.push(ascAt(ua * i / 60)); line(c, pts, M.GREY_B, 2.5, fade17); }
+ const d2 = t > tSep ? 300 * (t - tSep) + 260 * (t - tSep) ** 2 : 0;
+ const U0 = [SEP_BASE[0] + DIR[0] * H1 * K, SEP_BASE[1] + DIR[1] * H1 * K];
+ if (d2 > 0) line(c, [U0, [U0[0] + DIR[0] * d2, U0[1] + DIR[1] * d2]], M.GREY_B, 2.5, 0.8 * (1 - sm(seg(t, 4.35, 4.9))), [10, 12]);
+ if (t > tRelift) { const u2 = Math.min(1, Math.pow((t - tRelift) / 1.0, 1.5)), pts = []; for (let i = 0; i <= 60; i++) pts.push(ascAt(u2 * i / 60)); line(c, pts, M.GREY_B, 2.5); }
+ const bs = t > tSep ? (t < t17 ? retS(t) : RET_LEN) : 0;
+ if (bs > 0) { const pts = []; for (let i = 0; i < RET.length && RET_L[i] <= bs; i++) pts.push(RET[i]); pts.push(DG.pointAt(RET, RET_L, bs)); line(c, pts, M.BLUE_C, 4, dim17); }
+
+ // —— 阶段标签(Write)+轨迹上的点 ——
+ const P_FLIP = DG.pointAt(RET, RET_L, retS(tFlip[1])), P_ENTRY = DG.pointAt(RET, RET_L, retS(tEntry[0]));
+ // 「分离」「掉头」在相机推近着陆区时淡出(不和屏幕上固定的年份叠字),2017 拉回全景时以历史的暗度回来
+ const histA = t < t17 ? 1 - sm(seg(t, 4.35, 4.9)) : 0.3 * sm(seg(t, t17, t17 + 0.5));
+ c.save(); c.globalAlpha = histA;
+ dot(c, B0[0], B0[1], sm(seg(t, tSep, tSep + 0.2))); wr(c, T.sep, B0[0] + 40, B0[1] + 92, 44, seg(t, tSep + 0.05, tSep + 0.6), { align: 'left' });
+ dot(c, P_FLIP[0], P_FLIP[1], sm(seg(t, tFlip[1], tFlip[1] + 0.2))); wr(c, T.flip, 1000, 92, 44, seg(t, tFlip[0] + 0.15, tFlip[0] + 0.7), { align: 'right' });
+ c.restore();
+ c.save(); c.globalAlpha = dim17;
+ dot(c, P_ENTRY[0], P_ENTRY[1], sm(seg(t, tEntry[0], tEntry[0] + 0.2))); wr(c, T.entry, P_ENTRY[0] + 34, P_ENTRY[1] + 16, 44, seg(t, tEntry[0], tEntry[0] + 0.55), { align: 'left' });
+ wr(c, T.land, 560, 768, 44, seg(t, tLburn[0] + 0.1, tLburn[0] + 0.65), { align: 'center' });
+ c.restore();
+
+ // —— 箭体 ——
+ if (t < tSep) { // 整箭:发射台上 → 升空
+ const u = t > tLift ? ua : 0, p = ascAt(u), r = ascRot(u), on = sm(seg(t, 0.0, 0.3));
+ c.save(); c.globalAlpha = on; c.translate(0, 30 * (1 - on)); // FadeIn(shift=UP)
+ if (t > tLift - 0.1) plume(c, p[0], p[1], r, 0, 70 * sm(seg(t, tLift - 0.1, tLift + 0.15)), t);
+ rocket(c, p[0], p[1], r, 0, { upper: 1 }); c.restore();
+ } else {
+ // 二级:沿分离时的方向继续飞走(带尾焰),出画
+ if (d2 < 1500) { const ux = U0[0] + DIR[0] * d2, uy = U0[1] + DIR[1] * d2; plume(c, ux, uy, ROT_SEP, 0, 60, t); rocket(c, ux, uy, ROT_SEP, H1, { upper: 1, only: 'upper' }); }
+ const b = booster(t);
+ // 推力:回推、再入、着陆三次点火(2017 升空也点火)
+ const burn = Math.max(sm(seg(t, tBoost[0], tBoost[0] + 0.15)) * (1 - sm(seg(t, tBoost[1] - 0.15, tBoost[1]))),
+ sm(seg(t, tEntry[0], tEntry[0] + 0.12)) * (1 - sm(seg(t, tEntry[1] - 0.12, tEntry[1]))),
+ sm(seg(t, tLburn[0], tLburn[0] + 0.12)) * (1 - sm(seg(t, tLand - 0.05, tLand + 0.05))),
+ sm(seg(t, tRelift - 0.15, tRelift + 0.1)));
+ if (b) {
+ const ind = DG.indicate(seg(t, tInd, tInd + 0.9));
+ if (burn > 0) plume(c, b.x, b.y, b.rot, HALF, 70, t, burn);
+ // 2017 后同一枚一级;长出二级时以箭底为轴(底部锚点 = 中心 + 20.5 m)
+ rocket(c, b.x, b.y, b.rot, HALF, { fins: b.fins, legs: b.legs, upper: b.upper || 0, tint: ind.k, s: t < t17 ? ind.s : 1 });
+ // 推力矢量(黄):从机头前方沿推力方向伸出——掉头后指向发射场、再入与着陆时朝上
+ if (burn > 0 && t < t17) {
+ const dx = Math.sin(b.rot), dy = -Math.cos(b.rot), r0 = (HALF + 2) * K, L = 120 * burn;
+ const x0 = b.x + dx * r0, y0 = b.y + dy * r0; arrow(c, x0, y0, x0 + dx * L, y0 + dy * L, M.YELLOW);
+ const tq = seg(t, tBoost[0] + 0.1, tBoost[0] + 0.5) * (1 - seg(t, tBoost[1] - 0.2, tBoost[1]));
+ if (tq > 0) { c.save(); c.globalAlpha = Math.min(1, tq * 3); c.fillStyle = M.YELLOW; c.font = `36px "${ZH}"`; c.textAlign = 'center'; c.fillText(T.thrust, x0 + dx * (L + 52), y0 + dy * (L + 52) + 12); c.restore(); }
+ }
+ }
+ // 着陆那一下:两道扬尘弧
+ const dq = seg(t, tLand, tLand + 0.7);
+ if (dq > 0 && dq < 1) { c.save(); c.strokeStyle = M.GREY_B; c.globalAlpha = 1 - dq; c.lineWidth = 3; for (const s of [-1, 1]) { c.beginPath(); c.arc(LZ + s * (40 + 70 * MO.cubicOut(dq)), GROUND - 4, 16 + 20 * dq, Math.PI * (s > 0 ? 1.1 : 1.6), Math.PI * (s > 0 ? 1.4 : 1.9)); c.stroke(); } c.restore(); }
+ }
+
+ // —— 「轨道火箭里这是头一回」:Circumscribe 黄框+黄字 ——
+ DG.circumscribe(c, LZ - 62, LAND_C[1] - HALF * K - 18, 124, (H1 + LEGTIP) * K + 36, seg(t, tFirst - 0.25, tFirst + 0.75), { col: M.YELLOW, lw: 4 });
+ c.save(); c.globalAlpha = fade17; wr(c, T.first, 790, 668, 46, seg(t, tFirst, tFirst + 0.8), { align: 'left', col: M.YELLOW }); c.restore();
+ // —— 2017:第2次飞行 ——
+ wr(c, T.second, 362, 610, 46, seg(t, tSecond, tSecond + 0.8), { align: 'right' });
+ c.restore();
+ },
+};
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex/scenes/s06.js b/scripts/engine/reference_films/spacex/spacex/scenes/s06.js
new file mode 100644
index 0000000..61499bb
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex/scenes/s06.js
@@ -0,0 +1,216 @@
+// S06 · 蒸汽波 / 赛博霓虹(风格卡 26_vaporwave)——「2018年,重型猎鹰首飞,把一辆跑车送上了绕太阳的轨道,两枚助推器并排落回地面。」
+// 管线:整幅先画进离屏 S → P.vhs 后期(RGB 通道分离、跟踪噪声带撕裂、扫描线、暗角;OSD 自己画在右上,不进字幕区)。
+// 天空渐变+星星(视差 0.6)→ 横条落日(这个太阳就是跑车要绕的太阳,视差 0.12)+霓虹椭圆轨道(后半在日后、前半在日前)
+// → 线框山+洋红透视网格地面(滚动)+棕榈剪影 → 发射台/两个着陆圈 → 重型猎鹰(三芯并联,深紫剪影+粉/青双色轮廓辉光)→ 霓虹灯管字「2018」
+// 镜头只做竖直摇:升空时跟着火箭摇上去(地面掉出画面、只剩太阳和星空,跑车放出来绕日);「两枚助推器」时跟着它们摇回地面,并排落在两个发光圈上。
+// 跑车:通用造型的红色敞篷车,无任何品牌标志;驾驶座上是头盔面罩不透明的宇航服剪影(无脸)。
+(() => {
+const W = 1920, H = 1080, { clamp, lerp, rng } = U, P = PAINT, seg = MO.seg, sm = MO.smooth, TAU = Math.PI * 2;
+const ID = 's06';
+ERAS.find(e => e.id === ID).transition = { type: 'vhs', dur: 0.6 }; // 签名转场:磁带撕裂、场同步丢失上滚
+const DUR = TM.dur(ID), cue = k => TM.cue(ID, k);
+const C = { pink: '#ff4fd8', hot: '#ff2f8f', cyan: '#3ff6ff', deep: '#12052a', yellow: '#ffd84a', orange: '#ff8a3a', sil: '#1c0838', sil2: '#0f0322' };
+const glow = P.glowStroke;
+const T = { sub: '重型猎鹰首飞' };
+
+// ---------- 时刻 ----------
+const t18 = cue('2018年'), tSub = cue('重型猎鹰'), tLift = cue('首飞') - 0.15;
+const tUp = [tLift + 0.3, tLift + 1.4];
+const tCar = cue('跑车') + 0.1, tOrbit = [cue('绕太阳'), cue('轨道') + 0.35];
+const tB0 = cue('两枚') - 0.05, tTouch = cue('落回'), tDown = [cue('两枚'), cue('两枚') + 1.2];
+const tBurn = [tTouch - 0.95, tTouch + 0.02], tLegs = [tTouch - 0.6, tTouch - 0.1];
+
+// ---------- 布局 ----------
+const HOR = 640, VPX = 960, K = 7; // 地平线、消失点;火箭 1 m = 7 px
+const PADX = 900, LZX = [1220, 1440], FLOORY = 880;
+const SUN = { x: 960, y: 430, r: 262 };
+const ORB = { rx: 610, ry: 150, tilt: -0.08 };
+const camY = t => 900 * MO.sineInOut(seg(t, ...tUp)) * (1 - MO.sineInOut(seg(t, ...tDown)));
+const sunAt = cy => [SUN.x, SUN.y + cy * 0.12];
+
+// ---------- 天空、星星 ----------
+const STARS = (() => { const r = rng(606), o = []; for (let i = 0; i < 240; i++) o.push({ x: r() * W, y: -1500 + r() * 2150, s: 0.8 + r() * 2.2, ph: r() * TAU, f: 1.5 + r() * 3, col: r() < 0.2 ? C.cyan : r() < 0.4 ? '#ffb8f0' : '#ffffff' }); return o; })();
+function sky(g, cy, t) {
+ const gr = g.createLinearGradient(0, -1300 + cy, 0, HOR + cy);
+ gr.addColorStop(0, '#03010a'); gr.addColorStop(0.5, '#0e0326'); gr.addColorStop(0.78, '#33095a'); gr.addColorStop(0.93, '#9a1a86'); gr.addColorStop(1, '#ff4f9e');
+ g.fillStyle = gr; g.fillRect(0, 0, W, H);
+ for (const s of STARS) { const y = s.y + cy * 0.6; if (y < -4 || y > HOR + cy - 30) continue;
+ const a = (0.45 + 0.55 * Math.sin(t * s.f + s.ph)) * clamp((HOR + cy - 60 - y) / 300); if (a <= 0.02) continue;
+ g.globalAlpha = a; g.fillStyle = s.col; g.fillRect(s.x - s.s / 2, y - s.s / 2, s.s, s.s); if (s.s > 2.2) { g.fillRect(s.x - s.s * 2, y - 0.5, s.s * 4, 1); g.fillRect(s.x - 0.5, y - s.s * 2, 1, s.s * 4); } }
+ g.globalAlpha = 1;
+}
+// ---------- 横条落日(离屏画,destination-out 切横缝,缝随时间上移、越往下越宽) ----------
+function sun(g, t, cx, cy) {
+ const R = SUN.r, sc = P.scratch('s06sun'), s = sc.getContext('2d'); s.reset();
+ const ox = 300, oy = 300;
+ const gl = g.createRadialGradient(cx, cy, R * 0.7, cx, cy, R * 1.9); gl.addColorStop(0, 'rgba(255,79,216,.45)'); gl.addColorStop(1, 'rgba(255,79,216,0)');
+ g.fillStyle = gl; g.fillRect(cx - R * 2, cy - R * 2, R * 4, R * 4);
+ const sg = s.createLinearGradient(0, oy - R, 0, oy + R); sg.addColorStop(0, C.yellow); sg.addColorStop(0.5, C.orange); sg.addColorStop(1, C.hot);
+ s.fillStyle = sg; s.beginPath(); s.arc(ox, oy, R, 0, TAU); s.fill();
+ s.globalCompositeOperation = 'destination-out';
+ const ph = (t * 0.55) % 1;
+ for (let k = 0; k < 9; k++) { const q = (k + ph) / 9, y = oy + R * (q * 1.05 - 0.02), h = 2 + q * q * 22; s.fillRect(ox - R, y, R * 2, h); }
+ g.drawImage(sc, 0, 0, 600, 600, cx - ox, cy - oy, 600, 600);
+}
+// ---------- 轨道与跑车 ----------
+const orbPt = (cx, cy, f) => { const x = ORB.rx * Math.cos(f), y = ORB.ry * Math.sin(f), c = Math.cos(ORB.tilt), s = Math.sin(ORB.tilt); return [cx + x * c - y * s, cy + x * s + y * c]; };
+const F0 = -0.35, OMEGA = 0.85;
+const carPhi = t => F0 + OMEGA * (t - tCar);
+function orbitArc(g, cx, cy, f0, f1, front) {
+ // 只画落在前半(sin>0)或后半的那部分
+ const n = Math.max(2, Math.ceil(Math.abs(f1 - f0) * 40)); g.beginPath(); let on = false;
+ for (let i = 0; i <= n; i++) { const f = lerp(f0, f1, i / n), isF = Math.sin(f) > 0; const [x, y] = orbPt(cx, cy, f);
+ if (isF === front) { on ? g.lineTo(x, y) : g.moveTo(x, y); on = true; } else on = false; }
+ g.lineCap = 'round'; glow(g, C.pink, 5, 22); g.strokeStyle = '#ffe6fa'; g.lineWidth = 1.6; g.stroke();
+}
+// 跑车(车头朝右,长约 200 px):车身红、深色车轮、斜挡风、驾驶座上无脸宇航服剪影(面罩不透明)
+const CAR = (() => {
+ const body = new Path2D();
+ [[-100, 12], [-102, -6], [-72, -15], [-30, -17], [-12, -14], [10, -15], [24, -19], [62, -15], [100, -5], [100, 12], [82, 12], [80, 0], [62, -8], [44, 0], [42, 12], [-42, 12], [-44, 0], [-62, -8], [-80, 0], [-82, 12]].forEach(([x, y], i) => i ? body.lineTo(x, y) : body.moveTo(x, y)); body.closePath();
+ const wheels = new Path2D(); for (const x of [-62, 62]) { wheels.moveTo(x + 17, 12); wheels.arc(x, 12, 17, 0, TAU); }
+ const suit = new Path2D(); suit.moveTo(-30, -16); suit.lineTo(-28, -40); suit.quadraticCurveTo(-18, -48, -6, -40); suit.lineTo(10, -30); suit.lineTo(12, -24); suit.lineTo(-4, -30); suit.lineTo(-4, -16); suit.closePath();
+ const helmet = new Path2D(); helmet.arc(-16, -56, 13, 0, TAU);
+ const visor = new Path2D(); visor.ellipse(-11, -56, 7, 8, 0, 0, TAU);
+ return { body, wheels, suit, helmet, visor };
+})();
+function car(g, x, y, s, rot) {
+ g.save(); g.translate(x, y); g.rotate(rot); g.scale(s, s);
+ // 双色轮廓辉光:同一剪影向左偏一点填粉、向右偏一点填青,再盖本色
+ g.save(); g.shadowBlur = 18; g.shadowColor = C.pink; g.fillStyle = C.pink; g.translate(-3, 0); g.fill(CAR.body); g.fill(CAR.helmet); g.restore();
+ g.save(); g.shadowBlur = 18; g.shadowColor = C.cyan; g.fillStyle = C.cyan; g.translate(3, 0); g.fill(CAR.body); g.fill(CAR.helmet); g.restore();
+ g.fillStyle = '#f0f0ff'; g.fill(CAR.suit); g.fill(CAR.helmet); g.fillStyle = '#1a0630'; g.fill(CAR.visor);
+ const bg = g.createLinearGradient(0, -20, 0, 14); bg.addColorStop(0, '#ff5a6e'); bg.addColorStop(1, '#b0102e'); g.fillStyle = bg; g.fill(CAR.body);
+ g.strokeStyle = '#ffd0e0'; g.lineWidth = 2; g.beginPath(); g.moveTo(24, -19); g.lineTo(10, -40); g.stroke(); // 挡风玻璃框
+ g.fillStyle = '#12052a'; g.fill(CAR.wheels); g.strokeStyle = C.cyan; g.lineWidth = 2.5; g.stroke(CAR.wheels);
+ g.restore();
+}
+// ---------- 地面:线框山、洋红透视网格(滚动)、棕榈 ----------
+const MTN = (() => { const r = rng(61), o = [[0, HOR]]; for (let x = 0; x <= W; x += 60) o.push([x, HOR - 18 - (Math.abs(x - 960) > 300 ? 40 + 70 * r() * clamp((Math.abs(x - 960) - 300) / 400) : 10 * r())]); o.push([W, HOR]); return o; })();
+function ground(g, cy, t) {
+ const hy = HOR + cy; if (hy > H + 10) return;
+ g.save(); g.translate(0, cy);
+ g.beginPath(); MTN.forEach(([x, y], i) => i ? g.lineTo(x, y) : g.moveTo(x, y)); g.closePath(); g.fillStyle = '#16052c'; g.fill();
+ g.beginPath(); MTN.slice(1, -1).forEach(([x, y], i) => i ? g.lineTo(x, y) : g.moveTo(x, y)); glow(g, C.pink, 2.5, 10);
+ g.fillStyle = '#0a0118'; g.fillRect(0, HOR, W, 900);
+ g.beginPath(); g.moveTo(0, HOR); g.lineTo(W, HOR); glow(g, C.cyan, 3, 16);
+ g.save(); g.beginPath(); g.rect(0, HOR, W, 900); g.clip(); g.strokeStyle = C.pink; g.shadowColor = C.pink; g.shadowBlur = 10; g.lineWidth = 2;
+ const far = HOR + 2;
+ for (let i = -18; i <= 18; i++) { g.beginPath(); g.moveTo(VPX + i * 40, far); g.lineTo(VPX + i * 230, HOR + 900); g.stroke(); }
+ const ph = (t * 1.2) % 1;
+ for (let k = 0; k < 16; k++) { const d = k + 1 - ph, y = HOR + 300 / d; if (y > HOR + 900) continue; g.lineWidth = 1 + 2.4 * clamp((y - HOR) / 440); g.beginPath(); g.moveTo(0, y); g.lineTo(W, y); g.stroke(); }
+ g.restore();
+ // 棕榈剪影(左右各一,摇)
+ [[150, 780, 1], [1770, 790, -1]].forEach(([x, y, s], k) => {
+ const sw = Math.sin(t * 1.8 + k * 1.4) * 0.05;
+ g.save(); g.translate(x, y); g.rotate(sw * s); g.fillStyle = '#090114'; g.strokeStyle = '#090114';
+ g.lineWidth = 14; g.lineCap = 'round'; g.beginPath(); g.moveTo(0, 0); g.quadraticCurveTo(s * 26, -170, s * 8, -330); g.stroke();
+ for (let f = 0; f < 8; f++) { const a = -Math.PI / 2 + (f - 3.5) * 0.42 + Math.sin(t * 2.6 + f) * 0.05, L = 110 + (f % 3) * 24; g.save(); g.translate(s * 8, -330); g.rotate(a); g.beginPath(); g.moveTo(0, 0); g.quadraticCurveTo(L * 0.5, -20, L, 18); g.quadraticCurveTo(L * 0.5, 6, 0, 6); g.fill(); g.restore(); }
+ g.restore(); });
+ // 发射台+两个着陆圈
+ g.fillStyle = '#1a0830'; g.fillRect(PADX - 70, FLOORY, 140, 16); g.beginPath(); g.moveTo(PADX - 70, FLOORY); g.lineTo(PADX + 70, FLOORY); glow(g, C.cyan, 3, 14);
+ const pulse = seg(t, tTouch, tTouch + 0.9);
+ for (const x of LZX) {
+ g.beginPath(); g.ellipse(x, FLOORY + 6, 96, 20, 0, 0, TAU); glow(g, C.cyan, 4, 20);
+ g.beginPath(); g.ellipse(x, FLOORY + 6, 60, 12, 0, 0, TAU); glow(g, C.pink, 2.5, 12);
+ if (pulse > 0 && pulse < 1) { g.save(); g.globalAlpha = 1 - pulse; g.beginPath(); g.ellipse(x, FLOORY + 6, 96 + 160 * MO.cubicOut(pulse), 20 + 32 * MO.cubicOut(pulse), 0, 0, TAU); glow(g, C.cyan, 3, 18); g.restore(); }
+ }
+ g.restore();
+}
+// ---------- 火箭:深紫剪影+粉/青双色轮廓辉光 ----------
+function silhouette(g, parts, x, y, rot) {
+ g.save(); g.translate(x, y); g.rotate(rot); g.scale(K, K);
+ for (const [col, dx] of [[C.pink, -3.5 / K], [C.cyan, 3.5 / K]]) { g.save(); g.translate(dx, 0); g.shadowColor = col; g.shadowBlur = 16; g.fillStyle = col; parts.forEach(q => g.fill(q.p)); g.restore(); }
+ parts.forEach(q => { g.fillStyle = q.k === 'dark' || q.k === 'engine' ? C.sil2 : C.sil; g.fill(q.p); });
+ g.restore();
+}
+function neonFlame(g, x, y, len, w, t, seed) {
+ g.save(); g.globalCompositeOperation = 'lighter'; g.shadowColor = C.hot; g.shadowBlur = 24;
+ RK.flame(g, x, y, len, w, t, ['rgba(255,47,143,.85)', 'rgba(255,216,74,.9)', '#fff6fb'], seed); g.restore();
+}
+const HEAVY = RK.heavy({ payload: 'fairing' }).parts;
+// 侧助推器(落回时):一级+头锥+自画着陆腿(底部铰接、向下外翻,脚垫低于发动机)+栅格舵
+function sideBooster(legs) {
+ const parts = RK.falcon9({ stage: 'booster', fins: 1 }).parts.filter((q, i) => i !== 3); // 去掉 RK 的收起态腿,换成下面的展开腿
+ parts.push({ k: 'nose', p: RK.ogive(3.7, 4.5, -41) });
+ const lg = new Path2D(), a = legs * 2.1, L = 9.5;
+ for (const s of [-1, 1]) { const hx = s * 1.85, hy = -1.2, tx = hx + s * Math.sin(a) * L, ty = hy - Math.cos(a) * L, nx = -Math.cos(a) * 0.35 * s, ny = -Math.sin(a) * 0.35;
+ lg.moveTo(hx + nx, hy + ny); lg.lineTo(tx + nx, ty + ny); lg.lineTo(tx - nx, ty - ny); lg.lineTo(hx - nx, hy - ny); lg.closePath(); }
+ parts.push({ k: 'dark', p: lg });
+ return parts;
+}
+// ---------- 霓虹灯管字「2018」(自画折线,不依赖字体) ----------
+const ell = (cx, cy, rx, ry, n = 28) => { const o = []; for (let i = 0; i <= n; i++) { const a = -Math.PI / 2 + i / n * TAU; o.push([cx + rx * Math.cos(a), cy + ry * Math.sin(a)]); } return o; };
+const DIG = {
+ '2': [[[0.1, 0.24], [0.22, 0.06], [0.5, 0.0], [0.78, 0.06], [0.9, 0.26], [0.8, 0.46], [0.1, 1.0], [0.94, 1.0]]],
+ '0': [ell(0.5, 0.5, 0.4, 0.5)],
+ '1': [[[0.22, 0.2], [0.58, 0.0], [0.58, 1.0]]],
+ '8': [ell(0.5, 0.25, 0.32, 0.25), ell(0.5, 0.73, 0.4, 0.27)],
+};
+const flick = (t, t0, seed) => { if (t < t0) return 0; const f = Math.floor(t * 30); if (t - t0 < 0.4) return U.hash(f, seed) < 0.55 ? 1 : 0.12; return U.hash(f, seed + 9) < 0.035 ? 0.35 : 1; };
+function neon18(g, t) {
+ const x0 = 120, y0 = 92, h = 118, w = 74, gap = 22;
+ [...'2018'].forEach((ch, k) => {
+ const on = flick(t, t18 + k * 0.06, 31 + k); const x = x0 + k * (w + gap);
+ DIG[ch].forEach(st => { g.beginPath(); st.forEach(([u, v], i) => { const px = x + u * w + (1 - v) * 14, py = y0 + v * h; i ? g.lineTo(px, py) : g.moveTo(px, py); });
+ g.lineJoin = 'round'; g.lineCap = 'round';
+ if (on > 0.5) { glow(g, C.cyan, 11, 30); g.strokeStyle = '#efffff'; g.lineWidth = 3.5; g.stroke(); }
+ else { g.globalAlpha = on > 0 ? 1 : 0.55; g.strokeStyle = 'rgba(70,90,130,.7)'; g.lineWidth = 7; g.stroke(); g.globalAlpha = 1; } });
+ });
+ const so = flick(t, tSub, 77);
+ if (so > 0) { g.save(); g.globalAlpha = so; g.transform(1, 0, -0.16, 1, 0, 0); g.font = '56px "PuHui-Heavy"'; g.textBaseline = 'alphabetic';
+ g.shadowColor = C.pink; g.shadowBlur = 24; g.fillStyle = '#ffe1f6'; g.fillText(T.sub, 120 + 0.16 * 300, 300); g.shadowBlur = 0; g.restore(); }
+}
+
+SCENES[ID] = {
+ init() { U.assertGlyphs('PuHui-Heavy', T.sub, ID); U.assertGlyphs('PressStart2P-400', 'PLAY', ID); },
+ draw(c, lt, t) {
+ const tt = lt, cy = camY(tt);
+ const S = P.scratch('s06S'), g = S.getContext('2d'); g.reset();
+ sky(g, cy, tt);
+ const [sx, sy] = sunAt(cy);
+ // —— 轨道+跑车(后半在太阳后面) ——
+ const oq = sm(seg(tt, ...tOrbit)), f = carPhi(tt);
+ let carXY = null, front = Math.sin(f) > 0;
+ if (tt >= tCar) {
+ const op = orbPt(sx, sy, f), rel = sm(seg(tt, tCar, tCar + 0.75));
+ const noseY = 880 - 1900 * Math.pow(clamp((tCar - tLift) / 1.45), 2.2) - 490 + cy; // 放出时火箭头锥所在的屏幕位置
+ const start = [PADX, Math.min(noseY, 40)];
+ carXY = [lerp(start[0], op[0], rel), lerp(start[1], op[1], rel) - Math.sin(rel * Math.PI) * 60];
+ }
+ const carScale = 0.95 + 0.28 * Math.sin(f), carRot = -0.18 + 0.22 * Math.sin(tt * 0.9);
+ if (oq > 0) orbitArc(g, sx, sy, F0, F0 + TAU * oq, false);
+ if (carXY && !front) car(g, carXY[0], carXY[1], carScale, carRot);
+ sun(g, tt, sx, sy);
+ if (oq > 0) orbitArc(g, sx, sy, F0, F0 + TAU * oq, true);
+ if (carXY && front) car(g, carXY[0], carXY[1], carScale, carRot);
+ // 跑车放出时的霓虹火花
+ const sp = seg(tt, tCar, tCar + 0.6);
+ if (sp > 0 && sp < 1 && carXY) { const r = rng(808); g.save(); g.globalCompositeOperation = 'lighter'; for (let i = 0; i < 18; i++) { const a = r() * TAU, d = 30 + 110 * MO.cubicOut(sp) * (0.5 + r()); g.fillStyle = r() < 0.5 ? C.cyan : C.pink; g.globalAlpha = 1 - sp; g.fillRect(carXY[0] + Math.cos(a) * d, carXY[1] + Math.sin(a) * d, 4, 4); } g.restore(); }
+ // —— 地面 ——
+ ground(g, cy, tt);
+ // —— 重型猎鹰:发射台上排气 → 点火升空(三芯三道霓虹尾焰) ——
+ const ry = FLOORY - K - 1900 * Math.pow(clamp((tt - tLift) / 1.45), 2.2) + cy;
+ if (ry > -40) {
+ const ig = sm(seg(tt, tLift - 0.35, tLift + 0.1));
+ if (ig > 0) for (const dx of [-4.05, 0, 4.05]) neonFlame(g, PADX + dx * K, ry + 7, (90 + 160 * clamp((tt - tLift) / 0.8)) * ig, 30, tt, dx);
+ silhouette(g, HEAVY, PADX, ry, 0);
+ if (tt < tLift + 0.6) { const r = rng(17); g.save(); g.globalCompositeOperation = 'lighter'; // 排气白雾(粉/青)
+ for (let i = 0; i < 9; i++) { const ph = (tt * 0.5 + r()) % 1, x = PADX + (r() - 0.5) * 220 * (0.4 + ph), y = FLOORY + cy - 30 - ph * 90; g.globalAlpha = 0.18 * (1 - ph) * (1 + 2 * ig); g.fillStyle = r() < 0.5 ? C.pink : C.cyan; g.beginPath(); g.arc(x, y, 26 + ph * 40, 0, TAU); g.fill(); } g.restore(); }
+ }
+ // —— 两枚侧助推器同步竖直落回两个相邻的发光圈 ——
+ if (tt > tB0) {
+ const e = MO.bezier(0.3, 0.1, 0.25, 1)(seg(tt, tB0, tTouch)), by = lerp(-820, FLOORY - 3.6 * K, e) + cy;
+ const legs = sm(seg(tt, ...tLegs)), parts = sideBooster(legs), burn = sm(seg(tt, tBurn[0], tBurn[0] + 0.15)) * (1 - sm(seg(tt, tBurn[1] - 0.12, tBurn[1])));
+ LZX.forEach((x, i) => { const wob = tt < tTouch ? 0.012 * Math.sin(tt * 6 + i) : 0;
+ if (burn > 0) neonFlame(g, x, by + 7, 120 * burn, 26, tt, 5 + i);
+ silhouette(g, parts, x, by, wob); });
+ }
+ // —— HUD:霓虹灯管字、OSD ——
+ neon18(g, tt);
+ // —— VHS 后期 ——
+ P.vhs(c, S, t, lt, { osd: false });
+ const f30 = Math.floor(t * 60);
+ if ((f30 >> 4) % 2 === 0) { c.save(); c.font = '30px "PressStart2P-400"'; c.fillStyle = '#ffffff'; c.shadowColor = 'rgba(0,0,0,.8)'; c.shadowOffsetX = 3; c.shadowOffsetY = 3; c.fillText('PLAY', 1610, 104); c.beginPath(); c.moveTo(1770, 76); c.lineTo(1798, 91); c.lineTo(1770, 106); c.closePath(); c.fill(); c.restore(); }
+ },
+};
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex/scenes/s07.js b/scripts/engine/reference_films/spacex/spacex/scenes/s07.js
new file mode 100644
index 0000000..071d34e
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex/scenes/s07.js
@@ -0,0 +1,356 @@
+// S07 · Kurzgesagt 扁平科普(y1 语法):2020 年 5 月,载人龙飞船把两名宇航员送往空间站。
+// 世界画布+一台相机(CAM.at 关键帧、对数缩放):发光地球弧面、星空、轨道。所有动作挂在口播 cue 上。
+// ①「2020年5月」猎鹰9号+龙飞船从佛罗里达升空 →「载人龙飞船」标签 → 拉远,一二级分离 →「两名宇航员」放大气泡:舷窗里两个头盔
+// ②「空间站」龙飞船追上空间站对接,一圈光 → ③「近9年」2011→2020 小时间轴,航天飞机在 2011 处淡出 →「本土」拉远,佛罗里达发射点亮起
+// ④「私人公司」推近龙飞船高亮 →「送进轨道」拉远,整条轨道被描亮。
+// 画法:无描边、双色分面(TOON.flat)、发光体径向辉光、深靛底+青/橙黄/品红强调色。持续微动:星闪、大气呼吸、云漂、虚线流动、帆板扫光、微粒漂。
+(() => {
+const W = 1920, H = 1080, ID = 's07';
+const { clamp, lerp, rng } = U;
+const seg = MO.seg, flat = TOON.flat, glow = TOON.glow, circ = TOON.circle, K75 = MO.k75;
+const TAU = Math.PI * 2;
+
+// ---------- 口播对位 ----------
+const Q = {
+ date: TM.cue(ID, '2020年5月'), dragon: TM.cue(ID, '载人龙飞船'), crew: TM.cue(ID, '两名宇航员'),
+ iss: TM.cue(ID, '空间站'), issEnd: TM.end(ID, '空间站'), gap: TM.cue(ID, '美国时隔'), nine: TM.cue(ID, '近9年'), nineEnd: TM.end(ID, '近9年'),
+ home: TM.cue(ID, '本土'), first: TM.cue(ID, '也是第一次'), priv: TM.cue(ID, '私人公司'), orbit: TM.cue(ID, '送进轨道'), orbitEnd: TM.end(ID, '送进轨道'),
+ dur: TM.dur(ID),
+};
+
+// ---------- 色板(2025 深色系) ----------
+const C = {
+ sky: ['#05020F', '#0E0631', '#25155E'], star: '#F9FCFB',
+ ocean: '#2a62d8', oceanSh: '#1b3f9e', oceanHi: '#7DD3DC', land: '#4fb35a', landSh: '#2f8a45', landHi: '#9be07a',
+ cloud: '#F9FCFB', cloudSh: '#c9c3ea', atmo: '#7DD3DC',
+ white: '#E7DFE1', whiteSh: '#9b8fd0', whiteHi: '#ffffff', dark: '#25155E', darkSh: '#140b3d', darkHi: '#3826A3',
+ panel: '#E07919', panelSh: '#a9550f', panelHi: '#FACC12', cyan: '#32BAEE', mag: '#BE3A95', yellow: '#FACC12', glowCore: '#F9EF93',
+};
+
+// ---------- 世界几何 ----------
+const E = [960, 4300], R = 3400, ORB = 700, RO = R + ORB, KW = 4.5; // KW:每米多少世界像素(飞行器放大画,Kurzgesagt 式比例作弊)
+const P = (th, r) => [E[0] + r * Math.sin(th), E[1] - r * Math.cos(th)];
+const TH_PAD = -0.10, PAD = P(TH_PAD, R);
+const TD = Q.issEnd, L0 = 0.55, LA = TD - 0.95, TS = L0 + (LA - L0) * 0.68; // 对接、点火、入轨交接、一二级分离
+const TH_D = 0.16, W_ISS = 0.010; // 空间站对接时的角位置、角速度(rad/s)
+const SC2 = 2.0, DOCK_Y = 80, DH = 3.575; // 龙飞船分离后放大倍数;对接口在空间站本地 y=+80;龙飞船半高(米)
+const DCY = DOCK_Y + DH * KW * SC2; // 对接后龙飞船中心(空间站本地 y)
+
+const issTh = lt => TH_D + W_ISS * (lt - TD);
+const issF = lt => { const th = issTh(lt), p = P(th, RO); return { x: p[0], y: p[1], a: th }; };
+const toW = (F, lx, ly) => [F.x + lx * Math.cos(F.a) - ly * Math.sin(F.a), F.y + lx * Math.sin(F.a) + ly * Math.cos(F.a)];
+const toL = (F, wx, wy) => { const dx = wx - F.x, dy = wy - F.y; return [dx * Math.cos(F.a) + dy * Math.sin(F.a), -dx * Math.sin(F.a) + dy * Math.cos(F.a)]; };
+const lerpAng = (a, b, k) => a + (((b - a + Math.PI) % TAU + TAU) % TAU - Math.PI) * k;
+
+// 上升段:龙飞船中心沿极坐标走,起步竖直、入轨时水平
+const R0 = R + (54 + DH) * KW, TH_A = issTh(LA) - 0.055, RA = RO - DCY - 70;
+const ascent = lt => { const u = seg(lt, L0, LA), s = Math.pow(u, 1.55); return P(TH_PAD + (TH_A - TH_PAD) * s * s, R0 + (RA - R0) * (1 - (1 - s) * (1 - s))); };
+const O0 = toL(issF(LA), ...ascent(LA));
+const appE = MO.bezier(0.25, 0.55, 0.3, 1);
+// 龙飞船中心(世界)
+const dPos = lt => {
+ if (lt <= LA) return ascent(lt);
+ const F = issF(lt); if (lt >= TD) return toW(F, 0, DCY);
+ const k = appE(seg(lt, LA, TD)); return toW(F, lerp(O0[0], 0, k), lerp(O0[1], DCY, k));
+};
+// 机头朝向(0 = 竖直向上,顺时针为正)
+const dHead = lt => {
+ if (lt <= L0 + 0.02) return TH_PAD;
+ if (lt >= TD) return issF(lt).a;
+ const a = dPos(lt - 0.02), b = dPos(lt + 0.02), vx = b[0] - a[0], vy = b[1] - a[1];
+ let h = Math.hypot(vx, vy) < 1e-3 ? TH_PAD : Math.atan2(vx, -vy);
+ if (lt > LA) h = lerpAng(h, issF(lt).a, MO.smooth(seg(lt, LA, LA + (TD - LA) * 0.75)));
+ return h;
+};
+const dScale = lt => lerp(1, SC2, MO.sineInOut(seg(lt, TS, TS + 0.8)));
+
+// ---------- 相机关键帧 ----------
+const KEYS = (() => {
+ const d = lt => dPos(lt), F3 = issF(TD + 0.1), F4 = issF(Q.home - 0.55);
+ const D7 = d(Q.priv + 0.2), D8 = d(Q.orbit - 0.6);
+ return [
+ { t: 0, x: PAD[0] + 180, y: PAD[1] - 250, z: 1.0 },
+ { t: L0 + 1.0, x: d(L0 + 1.0)[0] + 140, y: d(L0 + 1.0)[1] + 90, z: 0.86, ease: MO.sineInOut },
+ { t: TS + 0.35, x: 1260, y: 470, z: 0.5, ease: K75 },
+ { t: TD + 0.1, x: F3.x, y: F3.y + 30, z: 0.95, ease: K75 },
+ { t: Q.home - 0.55, x: F4.x, y: F4.y + 30, z: 1.02, ease: MO.linear },
+ { t: Q.home + 0.3, x: 1150, y: 560, z: 0.47, ease: K75 },
+ { t: Q.first + 0.05, x: 1175, y: 560, z: 0.45, ease: MO.linear },
+ { t: Q.priv + 0.2, x: D7[0] + 70, y: D7[1] - 10, z: 2.5, ease: K75 },
+ { t: Q.orbit - 0.6, x: D8[0] + 70, y: D8[1] - 10, z: 2.62, ease: MO.linear },
+ { t: Q.dur, x: 1150, y: 1150, z: 0.36, ease: MO.sineInOut },
+ { t: Q.dur + 1.2, x: 1150, y: 1160, z: 0.345, ease: MO.linear },
+ ];
+})();
+const camAt = lt => CAM.at(KEYS, lt);
+
+// ---------- 静态布置(种子) ----------
+const STARS = (() => { const r = rng(701), o = []; for (let i = 0; i < 230; i++) o.push({ x: r() * 2600 - 340, y: r() * 1500 - 300, r: 0.8 + r() * r() * 3.4, ph: r() * TAU, sp: 1 + r() * 2.5 }); return o; })();
+const MOTES = (() => { const r = rng(702), o = []; for (let i = 0; i < 26; i++) o.push({ x: r() * W, y: r() * H, ph: r() * TAU, s: 2 + r() * 3 }); return o; })();
+const CLOUDS = (() => { const r = rng(703), o = []; for (let i = 0; i < 26; i++) o.push({ th: -0.7 + i * 0.056 + r() * 0.03, d: 60 + r() * 520, w: 70 + r() * 110, ph: r() * TAU }); return o; })();
+const PUFFS = (() => { const r = rng(704), o = []; for (let i = 0; i < 30; i++) o.push({ tb: L0 + i * 0.05, dx: (r() - 0.5) * 2, sz: 0.6 + r() * 0.7, ph: r() * TAU }); return o; })();
+// 陆地:极坐标 (θ, 深度) 的团块(深度 = 从地表往下的世界像素)
+const LANDS = [
+ [[-0.62, 70], [-0.5, 30], [-0.36, 40], [-0.24, 26], [-0.155, 60], [-0.118, 30], [-0.096, 60], [-0.108, 190], [-0.14, 260], [-0.2, 330], [-0.32, 420], [-0.46, 560], [-0.6, 520], [-0.68, 300]],
+ [[-0.27, 760], [-0.16, 720], [-0.1, 860], [-0.13, 1100], [-0.2, 1350], [-0.27, 1200], [-0.31, 950]],
+ [[0.24, 120], [0.34, 70], [0.46, 110], [0.52, 260], [0.46, 520], [0.36, 760], [0.3, 560], [0.22, 330]],
+ [[0.6, 40], [0.74, 30], [0.86, 120], [0.8, 320], [0.66, 280]],
+];
+const landPaths = LANDS.map(L => RIG.smooth(L.map(([th, d]) => P(th, R - d)), true));
+const earthPath = (() => { const p = new Path2D(); p.arc(E[0], E[1], R, 0, TAU); return p; })();
+
+// ---------- 小工具 ----------
+const rrP = (x, y, w, h, r) => { const p = new Path2D(); p.roundRect(x, y, w, h, r); return p; };
+// 标签胶囊:引线先画出,再弹出(backOut),退场 0.25s
+function chip(c, text, x, y, k, kout, { col = C.mag, size = 40, to, sh } = {}) {
+ if (k <= 0 || kout >= 1) return;
+ const s = MO.backOut(clamp(k / 0.5), 1.1) * (1 - MO.cubicIn(clamp(kout))), a = clamp(k / 0.15) * (1 - clamp(kout));
+ c.save(); c.globalAlpha *= a;
+ if (to) { const lp = MO.cubicOut(clamp(k / 0.35)); c.strokeStyle = 'rgba(249,252,251,.9)'; c.lineWidth = 3; c.lineCap = 'round';
+ c.beginPath(); c.moveTo(x, y); c.lineTo(lerp(x, to[0], lp), lerp(y, to[1], lp)); c.stroke();
+ if (lp > 0.95) { glow(c, to[0], to[1], 26, '#ffffff', 0.5); c.fillStyle = '#fff'; c.beginPath(); c.arc(to[0], to[1], 6, 0, TAU); c.fill(); } }
+ c.font = `${size}px "PuHui-Heavy"`; const tw = c.measureText(text).width, ph = size * 1.55, pw = tw + size * 1.1;
+ c.translate(x, y); c.scale(s, s);
+ c.fillStyle = sh || 'rgba(14,6,49,.55)'; c.fill(rrP(-pw / 2 + 4, -ph / 2 + 7, pw, ph, ph / 2));
+ c.fillStyle = col; c.fill(rrP(-pw / 2, -ph / 2, pw, ph, ph / 2));
+ c.fillStyle = 'rgba(255,255,255,.22)'; c.fill(rrP(-pw / 2 + ph * 0.25, -ph / 2 + 5, pw - ph * 0.5, ph * 0.22, ph * 0.11));
+ c.fillStyle = '#fff'; c.textAlign = 'center'; c.textBaseline = 'middle'; c.fillText(text, 0, size * 0.04);
+ c.restore();
+}
+
+// ---------- 飞行器(单位:米;flat 分面量用米) ----------
+const PALR = { body: [C.white, C.whiteSh, C.whiteHi], nose: [C.white, C.whiteSh, C.whiteHi], trunk: ['#cfc6ee', C.whiteSh, C.whiteHi],
+ dark: [C.dark, C.darkSh, C.darkHi], engine: ['#3826A3', '#1d1366', '#5F58DB'], window: ['#0E0631', '#0E0631', '#0E0631'] };
+const drawParts = (c, shape, v = [0.55, 0.65], w = [0.22, 0.26]) => {
+ for (const q of shape.parts) { if (q.k === 'window') continue; const p = PALR[q.k] || PALR.body; flat(c, q.p, p[0], p[1], p[2], v, w); }
+};
+const F9 = RK.falcon9({ payload: 'dragon' }), F9S = RK.falcon9({ payload: 'none' }), DRG = RK.dragon({ trunk: true });
+// 龙飞船(原点 = 中心):舷窗放大,窗里两个头盔(不透明面罩,不画脸)
+function drawDragon(c, t, { win = 0.42, wx = 0.72, helmets = true, hi = 0 } = {}) {
+ c.save(); c.translate(0, DH);
+ if (hi > 0) { glow(c, 0, -DH, 9, C.yellow, 0.55 * hi); }
+ drawParts(c, DRG, [0.32, 0.38], [0.12, 0.14]);
+ for (const [k, x] of [[0, -wx], [1, wx]]) {
+ const y = -4.8; c.save(); c.beginPath(); c.arc(x, y, win, 0, TAU); c.fillStyle = '#0E0631'; c.fill(); c.clip();
+ glow(c, x - win * 0.3, y - win * 0.5, win * 1.2, '#5F58DB', 0.5); // 舱内灯
+ if (helmets) { const b = 0.035 * Math.sin(t * 2.1 + k * 1.9), hr = win * 0.5, hx = x - win * 0.04, hy = y + win * 0.08 + b;
+ c.fillStyle = '#E7DFE1'; c.beginPath(); c.ellipse(x, y + win * 0.98 + b, win * 0.82, win * 0.45, 0, 0, TAU); c.fill(); // 肩
+ c.fillStyle = '#b3a6d6'; c.beginPath(); c.ellipse(x + win * 0.25, y + win * 1.05 + b, win * 0.6, win * 0.4, 0, 0, TAU); c.fill();
+ c.fillStyle = '#F9FCFB'; c.beginPath(); c.arc(hx, hy, hr, 0, TAU); c.fill(); // 头盔
+ c.fillStyle = '#c9c3ea'; c.beginPath(); c.arc(hx, hy, hr, -0.2, 1.6); c.lineTo(hx, hy); c.fill();
+ const vg = c.createLinearGradient(hx - hr * 0.3, hy - hr * 0.5, hx + hr * 0.7, hy + hr * 0.5); // 金色面罩(不透明,不画脸)
+ vg.addColorStop(0, '#FACC12'); vg.addColorStop(0.55, '#E07919'); vg.addColorStop(1, '#8a3f08');
+ c.fillStyle = vg; c.beginPath(); c.ellipse(hx + hr * 0.22, hy + hr * 0.02, hr * 0.62, hr * 0.48, 0.15, 0, TAU); c.fill();
+ c.strokeStyle = 'rgba(255,255,255,.75)'; c.lineWidth = hr * 0.09; c.lineCap = 'round'; c.beginPath(); c.arc(hx + hr * 0.22, hy + hr * 0.02, hr * 0.45, -2.5, -1.7); c.stroke(); }
+ c.fillStyle = 'rgba(255,255,255,.18)'; c.beginPath(); c.ellipse(x - win * 0.35, y - win * 0.45, win * 0.32, win * 0.13, -0.6, 0, TAU); c.fill();
+ c.restore();
+ c.strokeStyle = C.whiteSh; c.lineWidth = win * 0.16; c.beginPath(); c.arc(x, y, win * 1.04, 0, TAU); c.stroke();
+ }
+ c.restore();
+}
+// 气泡特写:龙飞船舱壁上的一扇大舷窗,窗里并排两名宇航员(头盔面罩不透明,不画脸)
+function drawCrewWindow(c, t) {
+ const hull = new Path2D(); hull.moveTo(-330, 260); hull.lineTo(-170, -300); hull.lineTo(330, -300); hull.lineTo(330, 260); hull.closePath();
+ flat(c, hull, C.white, C.whiteSh, C.whiteHi, [22, 18], [8, 7]);
+ c.strokeStyle = 'rgba(155,143,208,.55)'; c.lineWidth = 5; c.beginPath(); c.moveTo(-250, 70); c.lineTo(330, 70); c.moveTo(-205, -110); c.lineTo(330, -110); c.stroke();
+ const r = 128; c.save(); c.beginPath(); c.arc(0, 0, r, 0, TAU); c.fillStyle = '#0E0631'; c.fill(); c.clip();
+ glow(c, -40, -70, 220, '#5F58DB', 0.55); glow(c, 0, 120, 160, C.cyan, 0.25 + 0.08 * Math.sin(t * 3)); // 舱内灯、仪表光
+ for (const [k, x] of [[0, -52], [1, 56]]) {
+ const b = 3 * Math.sin(t * 2.0 + k * 2.1), hx = x, hy = -6 + b, hr = 40;
+ flat(c, RIG.smooth([[x - 46, -40], [x + 46, -40], [x + 52, 140], [x - 52, 140]], true), '#3826A3', '#25155E', '#5F58DB', [6, 6], [2, 2]); // 座椅
+ const sh = new Path2D(); sh.ellipse(x, hy + 88, 66, 46, 0, 0, TAU); flat(c, sh, '#F9FCFB', '#b3a6d6', '#fff', [10, 10], [3, 3]); // 肩
+ flat(c, circ(hx, hy + 30, 24), '#c9c3ea', '#9b8fd0', '#fff', [3, 3], [1, 1]); // 颈圈
+ flat(c, circ(hx, hy, hr), '#F9FCFB', '#b3a6d6', '#fff', [8, 8], [3, 3]); // 头盔
+ const vg = c.createLinearGradient(hx - 20, hy - 26, hx + 30, hy + 24); vg.addColorStop(0, '#FACC12'); vg.addColorStop(0.55, '#E07919'); vg.addColorStop(1, '#8a3f08');
+ c.fillStyle = vg; c.beginPath(); c.ellipse(hx + 4, hy + 4, hr * 0.74, hr * 0.56, 0, 0, TAU); c.fill(); // 金色面罩
+ c.strokeStyle = 'rgba(255,255,255,.8)'; c.lineWidth = 4; c.lineCap = 'round'; c.beginPath(); c.arc(hx + 4, hy + 4, hr * 0.55, -2.6, -1.8); c.stroke();
+ }
+ c.restore();
+ c.fillStyle = 'rgba(255,255,255,.14)'; c.beginPath(); c.ellipse(-50, -70, 70, 22, -0.6, 0, TAU); c.fill();
+ c.strokeStyle = C.whiteSh; c.lineWidth = 16; c.beginPath(); c.arc(0, 0, r + 8, 0, TAU); c.stroke();
+ c.strokeStyle = '#F9FCFB'; c.lineWidth = 5; c.beginPath(); c.arc(0, 0, r + 1, 0, TAU); c.stroke();
+}
+// 空间站(本地坐标:世界像素,y 向下 = 朝地球;对接口在 (0, DOCK_Y))
+function drawISS(c, t) {
+ const sweep = ((t * 0.32) % 1.6) - 0.3; // 帆板扫光(母题循环,周期 5s)
+ for (const sx of [-1, 1]) for (const px of [150, 212]) for (const sy of [-1, 1]) {
+ const x = sx * px - 15, y = sy > 0 ? 18 : -148, p = rrP(x, y, 30, 130, 3);
+ flat(c, p, C.panel, C.panelSh, C.panelHi, [4, 5], [1.5, 2]);
+ c.save(); c.clip(p); c.strokeStyle = 'rgba(80,30,0,.35)'; c.lineWidth = 1.4;
+ for (let k = 1; k < 8; k++) { c.beginPath(); c.moveTo(x, y + k * 16.25); c.lineTo(x + 30, y + k * 16.25); c.stroke(); }
+ const u = sweep - (sx * px + 245) / 490 * 0.4; if (u > -0.2 && u < 1.2) { const yy = y + u * 130; const g = c.createLinearGradient(0, yy - 22, 0, yy + 22); g.addColorStop(0, 'rgba(255,248,200,0)'); g.addColorStop(0.5, 'rgba(255,248,200,.65)'); g.addColorStop(1, 'rgba(255,248,200,0)'); c.fillStyle = g; c.fillRect(x, yy - 22, 30, 44); }
+ c.restore();
+ }
+ flat(c, rrP(-248, -7, 496, 14, 5), '#cfc6ee', C.whiteSh, C.whiteHi, [3, 4], [1, 1.5]); // 桁架
+ for (const sx of [-1, 1]) flat(c, rrP(sx * 70 - 9, -78, 18, 64, 3), '#F9FCFB', C.cloudSh, '#fff', [2, 3], [1, 1]); // 散热板
+ const mods = [[-92, 26], [-58, 34], [-20, 40], [22, 34], [56, 26]]; // 舱段串(竖直,穿过桁架)
+ for (const [y, h] of mods) flat(c, rrP(-15, y, 30, h, 9), C.white, C.whiteSh, C.whiteHi, [4, 5], [1.5, 2]);
+ flat(c, rrP(-34, -12, 68, 24, 10), C.white, C.whiteSh, C.whiteHi, [4, 5], [1.5, 2]);
+ flat(c, rrP(-9, DOCK_Y - 4, 18, 8, 3), '#cfc6ee', C.whiteSh, C.whiteHi, [1, 2], [0.5, 0.5]);
+ const bl = 0.5 + 0.5 * Math.sin(t * 4.2); glow(c, 0, DOCK_Y + 2, 16, C.cyan, 0.5 * bl); glow(c, -248, 0, 14, '#ff5d8f', 0.6 * (0.5 + 0.5 * Math.sin(t * 3.1 + 1)));
+}
+// 航天飞机(俯视平面图,机头朝上,单位 px)
+function drawShuttle(c) {
+ const wing = U.poly([[0, -60], [12, -40], [14, -6], [58, 44], [58, 56], [14, 56], [-14, 56], [-58, 56], [-58, 44], [-14, -6], [-12, -40]]);
+ flat(c, wing, '#F9FCFB', '#a9a2cf', '#fff', [4, 5], [1.5, 2]);
+ flat(c, RIG.smooth([[0, -80], [11, -60], [13, -20], [13, 58], [-13, 58], [-13, -20], [-11, -60]], true), '#F9FCFB', '#b9b3dc', '#fff', [4, 5], [1.5, 2]);
+ c.fillStyle = '#25155E'; c.beginPath(); c.ellipse(0, -66, 9, 15, 0, 0, TAU); c.fill();
+ c.fillStyle = '#25155E'; c.fillRect(-58, 50, 44, 6); c.fillRect(14, 50, 44, 6);
+ c.fillStyle = '#3826A3'; for (const x of [-7, 0, 7]) { c.beginPath(); c.arc(x, 64, 4.5, 0, TAU); c.fill(); }
+}
+
+// ---------- 场景 ----------
+SCENES[ID] = {
+ init() {
+ U.assertGlyphs('PuHui-Heavy', '2020年5月载人龙飞船两名宇航员空间站近9年美国本土私人公司的飞船轨道2011', ID);
+ },
+ draw(c, lt, t) {
+ const cam = camAt(lt), z = cam.z;
+ // 天空
+ c.fillStyle = TOON.vgrad(c, 0, H, C.sky); c.fillRect(0, 0, W, H);
+ // 星空 d=0.05:各自相位闪烁
+ CAM.layer(c, cam, 0.05, g => { for (const s of STARS) { g.globalAlpha = 0.35 + 0.65 * (0.5 + 0.5 * Math.sin(lt * s.sp + s.ph)); g.fillStyle = C.star; g.beginPath(); g.arc(s.x, s.y, s.r, 0, TAU); g.fill(); } g.globalAlpha = 1; });
+
+ CAM.with(c, cam, g => {
+ const px = 1 / z; // 1 屏幕像素对应的世界像素
+ // 大气辉光(呼吸)
+ const ab = 1 + 0.08 * Math.sin(lt * 1.6);
+ const ag = g.createRadialGradient(E[0], E[1], R - 30, E[0], E[1], R + 320 * ab);
+ ag.addColorStop(0, 'rgba(125,211,220,0.55)'); ag.addColorStop(0.25, 'rgba(50,186,238,0.22)'); ag.addColorStop(1, 'rgba(50,186,238,0)');
+ g.fillStyle = ag; g.beginPath(); g.arc(E[0], E[1], R + 330, 0, TAU); g.fill();
+ // 地球:双色分面+陆地+云(裁在球内)
+ flat(g, earthPath, C.ocean, C.oceanSh, C.oceanHi, [60, 44], [40, 28]);
+ g.save(); g.clip(earthPath);
+ for (const lp of landPaths) flat(g, lp, C.land, C.landSh, C.landHi, [16, 14], [6, 5]);
+ for (const cl of CLOUDS) {
+ const th = cl.th + lt * 0.0045, [x, y] = P(th, R - cl.d), a = th;
+ g.save(); g.translate(x, y); g.rotate(a); const bob = 3 * Math.sin(lt * 0.9 + cl.ph);
+ const p = new Path2D(); p.ellipse(0, bob, cl.w, cl.w * 0.32, 0, 0, TAU); p.ellipse(-cl.w * 0.35, bob - cl.w * 0.18, cl.w * 0.45, cl.w * 0.3, 0, 0, TAU); p.ellipse(cl.w * 0.3, bob - cl.w * 0.12, cl.w * 0.38, cl.w * 0.26, 0, 0, TAU);
+ g.globalAlpha = 0.92; flat(g, p, C.cloud, C.cloudSh, '#fff', [8, 9], [3, 3]); g.restore();
+ }
+ const dg = g.createRadialGradient(E[0], E[1], R - 1700, E[0], E[1], R); // 往球心变暗:球体感
+ dg.addColorStop(0, 'rgba(14,6,49,.55)'); dg.addColorStop(1, 'rgba(14,6,49,0)'); g.fillStyle = dg; g.fillRect(E[0] - R, E[1] - R, 2 * R, 2 * R);
+ g.restore();
+ // 轨道虚线(常在,淡)
+ g.save(); g.strokeStyle = 'rgba(125,211,220,.16)'; g.lineWidth = 3 * px; g.setLineDash([14 * px, 16 * px]); g.lineDashOffset = -lt * 30 * px;
+ g.beginPath(); g.arc(E[0], E[1], RO, 0, TAU); g.stroke(); g.restore();
+ // 「送进轨道」:整条轨道被描亮(从空间站处向两边长)
+ const op = MO.k75(seg(lt, Q.orbit, Q.orbit + 1.0));
+ if (op > 0) { const ph = issTh(lt) - Math.PI / 2, sp = Math.PI * op;
+ g.save(); g.lineCap = 'round'; g.strokeStyle = 'rgba(50,186,238,.28)'; g.lineWidth = 22 * px; g.beginPath(); g.arc(E[0], E[1], RO, ph - sp, ph + sp); g.stroke();
+ g.strokeStyle = 'rgba(200,250,255,.95)'; g.lineWidth = 5 * px; g.stroke(); g.restore(); }
+ // 发射台:塔+闪灯
+ g.save(); g.translate(PAD[0], PAD[1]); g.rotate(TH_PAD); g.globalAlpha = 1 - MO.smooth(seg(lt, Q.first + 0.2, Q.first + 0.8));
+ flat(g, rrP(-46, -62 * KW, 22, 62 * KW, 3), '#191670', '#0E0631', '#3826A3', [3, 3], [1, 1]);
+ flat(g, rrP(-70, -8, 140, 12, 4), '#191670', '#0E0631', '#3826A3', [3, 3], [1, 1]);
+ glow(g, -35, -62 * KW, 22, '#ff5d8f', 0.8 * (0.5 + 0.5 * Math.sin(lt * 5)));
+ g.globalAlpha = 1;
+ // 「本土」:发射点脉冲环
+ const hp = seg(lt, Q.home, Q.first + 0.3);
+ if (hp > 0 && hp < 1) { for (let k = 0; k < 2; k++) { const q = ((lt - Q.home) * 0.9 + k * 0.5) % 1; g.strokeStyle = `rgba(250,204,18,${(1 - q) * 0.8 * Math.min(1, (1 - hp) * 5)})`; g.lineWidth = 4 * px; g.beginPath(); g.arc(0, 0, 20 * px + q * 120 * px, 0, TAU); g.stroke(); }
+ glow(g, 0, 0, 60 * px, C.yellow, 0.6); }
+ g.restore();
+ // 发射烟团(扁平圆,膨胀后淡出)
+ for (const f of PUFFS) { const k = lt - f.tb; if (k < 0 || k > 2.6) continue;
+ const r = (16 + k * 42) * f.sz, x = PAD[0] + f.dx * (30 + k * 110), y = PAD[1] - 10 - k * 8, a = (1 - k / 2.6);
+ g.globalAlpha = a; flat(g, circ(x, y, r), '#e4def8', '#a9a2cf', '#fff', [r * 0.18, r * 0.2], [r * 0.07, r * 0.08]); }
+ g.globalAlpha = 1;
+ // 轨迹(虚线流动;「本土」时变亮)
+ const tEnd = Math.min(lt, TD);
+ if (tEnd > L0 + 0.05) { const hb = MO.smooth(seg(lt, Q.home - 0.2, Q.home + 0.3)) * (1 - MO.smooth(seg(lt, Q.first, Q.first + 0.4)));
+ g.save(); g.strokeStyle = `rgba(249,252,251,${0.35 + 0.55 * hb})`; g.lineWidth = (3 + 3 * hb) * px; g.setLineDash([12 * px, 12 * px]); g.lineDashOffset = -lt * (40 + 80 * hb) * px;
+ g.beginPath(); for (let i = 0; i <= 80; i++) { const q = dPos(lerp(L0, tEnd, i / 80)); i ? g.lineTo(q[0], q[1]) : g.moveTo(q[0], q[1]); } g.stroke(); g.restore();
+ if (hb > 0) { g.save(); g.globalAlpha = hb; g.strokeStyle = 'rgba(250,204,18,.25)'; g.lineWidth = 16 * px; g.beginPath(); for (let i = 0; i <= 80; i++) { const q = dPos(lerp(L0, tEnd, i / 80)); i ? g.lineTo(q[0], q[1]) : g.moveTo(q[0], q[1]); } g.stroke(); g.restore(); } }
+ // 空间站
+ const F = issF(lt);
+ g.save(); g.translate(F.x, F.y); g.rotate(F.a); drawISS(g, lt);
+ const dk = lt - TD; // 对接:一圈光
+ if (dk > 0 && dk < 0.9) { const q = MO.cubicOut(dk / 0.9); g.strokeStyle = `rgba(249,239,147,${1 - q})`; g.lineWidth = 6 * (1 - q) + 2; g.beginPath(); g.arc(0, DOCK_Y, 10 + q * 150, 0, TAU); g.stroke(); glow(g, 0, DOCK_Y, 60 + q * 80, C.glowCore, 0.8 * (1 - q)); }
+ g.restore();
+ // 分离后的一二级:后退、下坠、翻滚、淡出
+ if (lt > TS && lt < TS + 1.4) { const k = lt - TS, h0 = dHead(TS), d0 = dPos(TS), sc = KW, L = (54 + DH) * KW;
+ const bx = d0[0] - Math.sin(h0) * L, by = d0[1] + Math.cos(h0) * L;
+ const rad = [Math.sin(issTh(TS)), -Math.cos(issTh(TS))];
+ const x = bx - Math.sin(h0) * k * 60 - rad[0] * k * k * 90, y = by + Math.cos(h0) * k * 60 - rad[1] * k * k * 90;
+ g.save(); g.globalAlpha = 1 - k / 1.4; g.translate(x, y); g.rotate(h0 + k * 0.5); g.scale(sc, sc); drawParts(g, F9S); g.restore(); }
+ // 火箭 / 龙飞船
+ const D = dPos(lt), hd = dHead(lt), ds = dScale(lt);
+ const hiP = MO.smooth(seg(lt, Q.priv - 0.1, Q.priv + 0.4)) * (1 - MO.smooth(seg(lt, Q.orbit + 0.2, Q.orbit + 0.8)));
+ g.save(); g.translate(D[0], D[1]); g.rotate(hd); g.scale(KW * ds, KW * ds);
+ if (lt < TS) { // 整箭:火箭底在龙飞船中心下方 57.6 米
+ g.translate(0, 54 + DH);
+ if (lt > L0 - 0.15) { const fl = clamp((lt - L0 + 0.15) / 0.5); glow(g, 0, 6, 26 * fl, '#FACC12', 0.45 * fl); RK.flame(g, 0, 1.0, (14 + 22 * fl) * fl, 3.2, lt, ['rgba(244,131,1,.9)', 'rgba(250,204,18,.95)', '#F9EF93']); }
+ drawParts(g, F9);
+ g.translate(0, -54 - DH); g.save(); g.translate(0, 0); drawDragon(g, lt, { win: 0.42 }); g.restore();
+ } else {
+ if (lt < TD + 0.05) { const pf = 0.5 + 0.5 * Math.sin(lt * 31); for (const sx of [-1, 1]) { glow(g, sx * 2.2, -1.2, 1.4 * pf, '#ffffff', 0.8); } } // 姿控喷气(Draco)闪
+ if (hiP > 0) { glow(g, 0, 0, 10 + 1.2 * Math.sin(lt * 6), C.yellow, 0.5 * hiP); }
+ drawDragon(g, lt, { win: 0.42 });
+ if (hiP > 0) { g.save(); g.strokeStyle = `rgba(250,204,18,${hiP})`; g.lineWidth = 0.22; g.setLineDash([0.9, 0.7]); g.lineDashOffset = -lt * 2; g.beginPath(); g.arc(0, 0, 5.6, 0, TAU); g.stroke(); g.restore(); }
+ }
+ g.restore();
+ });
+ // 前景微粒 d≈1.2(屏幕空间漂移,景深感)
+ for (const m of MOTES) { const x = (m.x + Math.sin(lt * 0.7 + m.ph) * 40 - cam.x * 0.08 + 4000) % W, y = (m.y - lt * 14 - cam.y * 0.05 + 4000) % H;
+ c.globalAlpha = 0.35 + 0.35 * Math.sin(lt * 1.8 + m.ph); glow(c, x, y, m.s * 5, '#ffe9a8', 0.4); c.fillStyle = '#fff6d0'; c.beginPath(); c.arc(x, y, m.s * 0.8, 0, TAU); c.fill(); }
+ c.globalAlpha = 1;
+
+ // ---------- 屏幕层:字与标签 ----------
+ const S = (x, y) => CAM.toScreen(cam, x, y);
+ // 「2020年5月」:逐字上浮,左上
+ const dOut = 1 - MO.sineInOut(seg(lt, Q.crew - 0.35, Q.crew + 0.1));
+ if (dOut > 0) { c.save(); c.globalAlpha = dOut; TY.charsIn(c, '2020年5月', 120, 190, lt - Q.date + 0.1, { font: '92px "PuHui-Heavy"', color: '#F9FCFB', dur: 0.5, stagger: 0.045, dy: 30, shadow: { color: 'rgba(10,8,40,.5)', y: 6 } }); c.restore(); }
+ // 「载人龙飞船」:指向箭顶的龙飞船
+ { const D = S(...dPos(lt)); chip(c, '载人龙飞船', D[0] + 260, D[1] - 70, lt - Q.dragon + 0.05, seg(lt, TS + 0.2, TS + 0.45), { col: C.mag, to: [D[0] + 18, D[1]] }); }
+ // 「两名宇航员」:放大气泡,舷窗里两个头盔
+ const bk = lt - (Q.crew - 0.15), bo = seg(lt, TD + 0.35, TD + 0.65);
+ if (bk > 0 && bo < 1) {
+ const bs = MO.backOut(clamp(bk / 0.5), 1.2) * (1 - MO.cubicIn(bo)), bx = 470, by = 470, br = 205 * bs, D = S(...dPos(lt));
+ c.save(); c.strokeStyle = 'rgba(125,211,220,.8)'; c.lineWidth = 3; c.setLineDash([8, 8]); c.lineDashOffset = -lt * 30;
+ const ang = Math.atan2(D[1] - by, D[0] - bx); c.globalAlpha = clamp(bk / 0.3) * (1 - bo);
+ c.beginPath(); c.moveTo(bx + Math.cos(ang) * br, by + Math.sin(ang) * br); c.lineTo(D[0], D[1]); c.stroke(); c.restore();
+ if (br > 2) {
+ c.save(); c.beginPath(); c.arc(bx, by, br, 0, TAU); c.clip();
+ c.fillStyle = TOON.vgrad(c, by - br, by + br, ['#0E0631', '#25155E']); c.fillRect(bx - br, by - br, 2 * br, 2 * br);
+ for (let i = 0; i < 22; i++) { const sx = bx - 200 + ((U.hash(i, 1) * 400 - lt * 60) % 400 + 400) % 400, sy = by - 200 + U.hash(i, 2) * 400; c.fillStyle = `rgba(249,252,251,${0.3 + 0.5 * U.hash(i, 3)})`; c.beginPath(); c.arc(sx, sy, 1.5 + 2 * U.hash(i, 4), 0, TAU); c.fill(); }
+ c.translate(bx, by); c.scale(bs, bs); c.rotate(-0.08 + 0.04 * Math.sin(lt * 1.1)); c.translate(0, MO.float(lt, 5, 3.3)); drawCrewWindow(c, lt); c.restore();
+ c.save(); c.strokeStyle = 'rgba(125,211,220,.95)'; c.lineWidth = 8 * bs; c.beginPath(); c.arc(bx, by, br + 4, 0, TAU); c.stroke();
+ c.strokeStyle = 'rgba(50,186,238,.25)'; c.lineWidth = 22 * bs; c.beginPath(); c.arc(bx, by, br + 16, 0, TAU); c.stroke(); c.restore();
+ chip(c, '两名宇航员', bx, by + br + 46, bk - 0.25, bo, { col: C.cyan, size: 36 });
+ }
+ }
+ // 「空间站」
+ { const F = issF(lt), A = S(...toW(F, 150, -150)); chip(c, '空间站', A[0] + 150, A[1] - 90, lt - Q.iss, seg(lt, TD + 0.5, TD + 0.8), { col: C.cyan, to: A }); }
+ // 「近9年」:2011 → 2020 小时间轴,航天飞机在 2011 处淡出
+ const tin = lt - (Q.gap + 0.05), tout = seg(lt, Q.first - 0.15, Q.first + 0.2);
+ if (tin > 0 && tout < 1) {
+ c.save(); c.globalAlpha = 1 - tout;
+ const x0 = 610, x1 = 1310, y = 236, lp = MO.k75(clamp(tin / 0.55));
+ c.lineCap = 'round'; c.strokeStyle = '#3826A3'; c.lineWidth = 10; c.beginPath(); c.moveTo(x0 - 50, y); c.lineTo(lerp(x0 - 50, x1 + 50, lp), y); c.stroke();
+ const tp = MO.k75(seg(lt, Q.nine, Q.nineEnd + 0.1));
+ if (tp > 0) { c.strokeStyle = C.yellow; c.lineWidth = 10; c.beginPath(); c.moveTo(x0, y); c.lineTo(lerp(x0, x1, tp), y); c.stroke(); }
+ for (const [k, x, yr] of [[0, x0, '2011'], [1, x1, '2020']]) {
+ const q = MO.backOut(clamp((tin - 0.15 - k * 0.12) / 0.4), 1.4); if (q <= 0) continue;
+ flat(c, circ(x, y, 16 * q), k && tp >= 1 ? C.yellow : '#F9FCFB', '#a9a2cf', '#fff', [3, 3], [1, 1]);
+ c.save(); c.globalAlpha *= clamp(q); c.font = '46px "PuHui-Heavy"'; c.textAlign = 'center'; c.fillStyle = '#F9FCFB'; c.fillText(yr, x, y + 70); c.restore();
+ }
+ if (tp > 0 && tp < 1) { const x = lerp(x0, x1, tp); glow(c, x, y, 50, C.yellow, 0.8); c.fillStyle = '#fff'; c.beginPath(); c.arc(x, y, 9, 0, TAU); c.fill(); }
+ // 航天飞机:2011 处出现,「近9年」念起时变灰、下沉、淡出
+ const sIn = MO.backOut(clamp((tin - 0.2) / 0.45), 1.3), sOut = MO.sineInOut(seg(lt, Q.nine - 0.2, Q.nine + 0.5));
+ if (sIn > 0 && sOut < 1) { c.save(); c.globalAlpha *= (1 - sOut); c.translate(x0, y - 105 + sOut * 30 + MO.float(lt, 3, 2.7)); c.scale(0.95 * sIn, 0.95 * sIn); if (sOut > 0) c.filter = `grayscale(${sOut})`; drawShuttle(c); c.restore(); }
+ chip(c, '近9年', (x0 + x1) / 2, y - 78, lt - Q.nine - 0.05, 0, { col: C.mag, size: 44 });
+ const dI = lt - Q.nineEnd + 0.05; if (dI > 0) { c.save(); c.translate(x1, y - 92 + MO.float(lt, 4, 2.9)); const q = MO.backOut(clamp(dI / 0.45), 1.4); c.scale(q * 12, q * 12); c.rotate(0.12); drawDragon(c, lt, { win: 0.42, helmets: false }); c.restore(); }
+ c.restore();
+ }
+ // 「本土」:指向佛罗里达发射点
+ { const A = S(...PAD); chip(c, '美国本土', A[0] - 30, A[1] - 190, lt - Q.home - 0.15, seg(lt, Q.first, Q.first + 0.3), { col: '#E07919', to: [A[0], A[1] - 6] }); }
+ // 「私人公司」:龙飞船高亮
+ { const D = S(...dPos(lt)); chip(c, '私人公司的飞船', D[0] + 360, D[1] - 140, lt - Q.priv, seg(lt, Q.orbit - 0.1, Q.orbit + 0.2), { col: '#E07919', size: 46, to: [D[0] + 60, D[1] - 30] }); }
+ // 「轨道」
+ { const A = S(...P(issTh(lt) - 0.42, RO)); chip(c, '轨道', A[0], A[1] - 70, lt - Q.orbit - 0.55, 0, { col: C.cyan, size: 44, to: A }); }
+ },
+};
+
+// 进入本段:Kurzgesagt 的「光铺满画面」——一团暖光从发射台处长大铺满,再退开露出新世界
+ERAS.find(e => e.id === ID).transition = { type: 'kzBloom', dur: 0.7, cx: 960, cy: 400 };
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex/scenes/s08.js b/scripts/engine/reference_films/spacex/spacex/scenes/s08.js
new file mode 100644
index 0000000..f7d6842
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex/scenes/s08.js
@@ -0,0 +1,167 @@
+// S08 · 财经图表(t3 语法,经济学人式):回收之后发射越来越密;2025 年猎鹰9号 165 次;一枚助推器飞了 37 次。
+// 版式先出(顶红线+红色小旗+结论标题+单位副标题+来源行)→ 网格从左往右画出 → 柱子从 0 依次长出 →「2025年」高亮、其余变灰 →
+// 2025 柱在「165」念完时落定 → 标注「平均两天多一发」→ 文字标注「比全世界其他火箭加起来还多」(不画没有出处的对比数字)→
+// 「有一枚助推器」版式不动、内容横推:助推器图标+飞行计数一格格涨到 37,在「37」念完时落定。
+// 数据(事实核对表 16–18):2017 18、2022 61、2023 96、2024 134、2025 165(2018–2021 只有维基汇总,不上图,用「…」断开)。真实数据,不加示意角标。
+(() => {
+const W = 1920, H = 1080, ID = 's08';
+const { clamp, lerp } = U;
+const seg = MO.seg;
+const RED = '#E3120B', BLUE = '#006BA2', DIM = '#C6D2D8', INK = '#0C0C0C', SUB = '#4F5B61', SRC = '#6b767b', GRID = 'rgba(12,12,12,0.13)';
+const CN = 'PuHui-Medium', CNB = 'PuHui-Bold', NUM = '"RobotoCondensed", "PuHui-Medium"';
+const f = (size, fam, w = '') => `${w}${size}px "${fam}"`;
+
+const Q = {
+ rec: TM.cue(ID, '回收之后'), dense: TM.cue(ID, '发射越来越密'), y25: TM.cue(ID, '2025年'), f9: TM.cue(ID, '猎鹰9号'),
+ land: TM.end(ID, '165') - 0.15, avg: TM.cue(ID, '平均两天多一发'), more: TM.cue(ID, '比全世界'),
+ one: TM.cue(ID, '有一枚助推器'), n37: TM.cue(ID, '37次'), land37: TM.end(ID, '37') - 0.08, dur: TM.dur(ID),
+};
+
+// ---- 图表几何 ----
+const DATA = [{ l: '2017', v: 18 }, { l: '…', v: null }, { l: '2022', v: 61 }, { l: '2023', v: 96 }, { l: '2024', v: 134 }, { l: '2025', v: 165 }];
+const F = { x: 150, y: 300, w: 1590, h: 460 };
+const TICKS = [0, 50, 100, 150, 200], yS = CH.lin(0, 200, F.y + F.h, F.y);
+const SLOT = (F.w - 90) / DATA.length, XS = DATA.map((_, i) => F.x + SLOT * (i + 0.5)), BW = 132;
+const HI = 5;
+
+// 一根柱:从 0 长出(quintOut)+数值同步计数(等宽数字)
+function bar(c, i, p, col, { big = false } = {}) {
+ const d = DATA[i]; if (p <= 0) return yS(0);
+ const e = MO.quintOut(clamp(p)), v = d.v * e, y = yS(v), x = XS[i];
+ c.fillStyle = col; c.fillRect(x - BW / 2, y, BW, yS(0) - y);
+ c.save(); c.globalAlpha = seg(p, 0.02, 0.3); c.fillStyle = big ? RED : INK; c.font = `${big ? 700 : 600} ${big ? 58 : 36}px ${NUM}`; c.textAlign = 'center'; c.textBaseline = 'alphabetic';
+ TY.tabular(c, TY.fmt(v, 0), x, y - (big ? 18 : 14), { align: 'center' }); c.restore();
+ return y;
+}
+// 版式:顶红线、小旗、标题(可换)、副标题、来源
+function header(c, lt, title, sub, src, a = 1, dy = 0) {
+ c.save(); c.globalAlpha *= a; c.textAlign = 'left'; c.textBaseline = 'alphabetic';
+ const tp = MO.quintOut(seg(lt, 0.05, 0.5)); c.globalAlpha *= tp; c.fillStyle = INK; c.font = f(60, CNB, '700 '); c.fillText(title, 96, 168 + (1 - tp) * 18 + dy);
+ const sp = MO.quintOut(seg(lt, 0.15, 0.6)); c.globalAlpha = a * sp; c.font = f(34, CN); c.fillStyle = SUB; c.fillText(sub, 96, 224 + (1 - sp) * 14 + dy);
+ c.globalAlpha = a * seg(lt, 0.2, 0.6); c.font = f(26, CN); c.fillStyle = SRC; c.fillText(src, 96, 900);
+ c.restore();
+}
+// 标注:红点弹出 → 引线画出 → 文字淡入
+function note(c, k, x, y, tx, ty, lines) {
+ if (k <= 0) return;
+ const s = MO.spring(k, { duration: 0.45, bounce: 0.25 }), lp = MO.quintOut(seg(k, 0.12, 0.45)), fp = MO.quintOut(seg(k, 0.3, 0.7));
+ c.save(); c.fillStyle = RED; c.beginPath(); c.arc(x, y, 11 * Math.max(0, s), 0, 7); c.fill();
+ const pr = seg(k, 0, 0.6); if (pr > 0 && pr < 1) { c.strokeStyle = RED; c.globalAlpha = 1 - pr; c.lineWidth = 3; c.beginPath(); c.arc(x, y, 11 + pr * 34, 0, 7); c.stroke(); c.globalAlpha = 1; }
+ if (lp > 0) { c.strokeStyle = INK; c.lineWidth = 2; c.beginPath(); c.moveTo(x - 12, y - 4); c.lineTo(lerp(x - 12, tx, lp), lerp(y - 4, ty, lp)); c.stroke(); }
+ c.globalAlpha = fp; c.textAlign = 'right'; c.textBaseline = 'alphabetic';
+ c.fillStyle = INK; c.font = f(50, CNB, '700 '); c.fillText(lines[0], tx - 14 - (1 - fp) * 16, ty + 14);
+ c.fillStyle = SUB; c.font = f(30, CN); c.fillText(lines[1], tx - 14 - (1 - fp) * 16, ty + 62);
+ c.restore();
+}
+// 助推器(Falcon 9 一级,着陆腿展开):经济学人式线描图标
+const BOOST = RK.falcon9({ stage: 'booster', legs: 1, fins: 1 });
+function booster(c, x, y, s) {
+ c.save(); c.translate(x, y); c.scale(s * 1.45, s);
+ const sg = c.createLinearGradient(0, -41, 0, 0); sg.addColorStop(0, '#F2F5F6'); sg.addColorStop(0.45, '#d9dfe2'); sg.addColorStop(1, '#7d878c');
+ RK.fill(c, BOOST, { body: sg, dark: '#2a3236', engine: '#2a3236', nose: '#F2F5F6' });
+ c.restore();
+ RK.at(c, x, y, 1, 0, g => { g.scale(s * 1.45, s); g.lineWidth = 2.6 / s; g.strokeStyle = INK; g.lineJoin = 'round'; for (const q of BOOST.parts) if (q.k === 'body') g.stroke(q.p); });
+}
+// 计数标记:小火箭(圆角箭体+尖头)
+function mark(c, x, y, s, col) {
+ c.save(); c.translate(x, y); c.scale(s, s); c.fillStyle = col;
+ c.beginPath(); c.moveTo(-11, 0); c.lineTo(-11, -52); c.quadraticCurveTo(-11, -70, 0, -78); c.quadraticCurveTo(11, -70, 11, -52); c.lineTo(11, 0); c.closePath(); c.fill();
+ c.beginPath(); c.moveTo(-11, -14); c.lineTo(-20, 0); c.lineTo(-11, 0); c.closePath(); c.fill(); c.beginPath(); c.moveTo(11, -14); c.lineTo(20, 0); c.lineTo(11, 0); c.closePath(); c.fill();
+ c.restore();
+}
+
+SCENES[ID] = {
+ init() {
+ U.assertGlyphs(CNB, '猎鹰火箭的发射越来越密一枚助推器飞行次数', ID);
+ U.assertGlyphs(CN, '猎鹰9号与重型猎鹰年发射次数,次(2025 年全部为猎鹰9号)来源:SpaceNews、CBS News、CNBC、Ars Technica2018–2021 未画出365 天 ÷ 165 次 ≈ 2.2 天比全世界其他火箭加起来还多9号一级助推器Space.comSpaceflight Now已经飞了', ID);
+ U.assertGlyphs(NUM, '0123456789,', ID);
+ },
+ draw(c, lt) {
+ c.fillStyle = '#FFFFFF'; c.fillRect(0, 0, W, H);
+ // 顶红线+小旗(全段不动)
+ const p0 = MO.quintOut(seg(lt, 0, 0.45)); c.fillStyle = RED; c.fillRect(0, 0, W * p0, 8); CH.tag(c, 96, 70, 96 * p0, 22, RED);
+ // 相机:匀速慢推 1 → 1.03(图表镜头的呼吸)
+ const z = 1 + 0.03 * lt / (Q.dur + 0.6);
+ c.save(); c.translate(960, 560); c.scale(z, z); c.translate(-960, -560);
+ // 内容横推:「有一枚助推器」时图表左移出、助推器面板右侧推入(版式不动)
+ const sw = MO.bezier(0.7, 0, 0.2, 1)(seg(lt, Q.one - 0.05, Q.one + 0.6));
+ // ---------- 第一页:年发射次数 ----------
+ if (sw < 1) {
+ header(c, lt, '猎鹰火箭的发射越来越密', '猎鹰9号与重型猎鹰年发射次数,次(2025 年全部为猎鹰9号)', '来源:SpaceNews、CBS News、CNBC、Ars Technica', 1 - seg(sw, 0, 0.5));
+ c.save(); c.translate(-sw * W, 0);
+ CH.grid(c, F, TICKS, yS, seg(lt, 0.35, 0.95), { col: GRID, zeroCol: INK, font: `400 30px ${NUM}`, labelCol: '#5b666b', side: 'right', lw: 1.5, zeroLw: 3, labelDy: -10 });
+ // x 轴:年份;「…」是断开标记(中间年份未画)
+ const xp = seg(lt, 0.5, 1.0), hiq = MO.smooth(seg(lt, Q.y25, Q.y25 + 0.35));
+ DATA.forEach((d, i) => {
+ const q = MO.quintOut(MO.lagged(i, DATA.length, xp, 0.1)); if (q <= 0) return;
+ c.save(); c.globalAlpha = q; c.textAlign = 'center';
+ if (d.v == null) {
+ c.fillStyle = '#5b666b'; for (const k of [-1, 0, 1]) { c.beginPath(); c.arc(XS[i] + k * 20, F.y + F.h + 40 + (1 - q) * 14, 5, 0, 7); c.fill(); }
+ c.font = f(22, CN); c.fillText('2018–2021 未画出', XS[i], F.y + F.h + 82);
+ c.strokeStyle = INK; c.lineWidth = 3; for (const k of [-1, 1]) { c.beginPath(); c.moveTo(XS[i] + k * 9 - 8, yS(0) + 12); c.lineTo(XS[i] + k * 9 + 8, yS(0) - 12); c.stroke(); }
+ } else {
+ const isHi = i === HI; c.font = `${isHi ? 700 : 400} 36px ${NUM}`; c.fillStyle = isHi ? CH.mixHex('#3a4246', RED, hiq) : '#3a4246';
+ c.fillText(d.l, XS[i], F.y + F.h + 50 + (1 - q) * 14);
+ }
+ c.restore();
+ });
+ // 「2025年」:这一格先亮出一道浅色高亮带
+ if (hiq > 0) { c.save(); c.globalAlpha = hiq * (0.55 + 0.1 * Math.sin(lt * 2.4)); c.fillStyle = 'rgba(227,18,11,0.07)'; c.fillRect(XS[HI] - SLOT / 2 + 8, F.y - 10, SLOT - 16, F.h + 10); c.restore(); }
+ // 柱:2017、2022–2024 在「越来越密」依次长出;「2025年」后变灰;2025 在「165」落定
+ const bp = seg(lt, Q.dense - 0.1, Q.dense + 1.25), dimP = MO.smooth(seg(lt, Q.y25 + 0.15, Q.y25 + 0.6));
+ [0, 2, 3, 4].forEach((i, k) => bar(c, i, MO.lagged(k, 4, bp, 0.22), CH.mixHex(BLUE, DIM, dimP)));
+ const g0 = Q.land - 1.5, top = bar(c, HI, seg(lt, g0, Q.land) ** 0.8, BLUE, { big: true });
+ // 标注:平均两天多一发(365 ÷ 165 ≈ 2.2,算术)
+ note(c, lt - Q.avg, XS[HI] - BW / 2, top + 4, 1060, 352, ['平均两天多一发', '365 天 ÷ 165 次 ≈ 2.2 天']);
+ // 关键数据点的脉冲环(每 1.3s 一次,持续微动)
+ if (lt > Q.avg + 0.8) { const q = ((lt - Q.avg - 0.8) / 1.3) % 1; c.save(); c.strokeStyle = RED; c.globalAlpha = (1 - q) * 0.7; c.lineWidth = 3; c.beginPath(); c.arc(XS[HI] - BW / 2, top + 4, 12 + q * 40, 0, 7); c.stroke(); c.restore(); }
+ // 文字标注:比全世界其他火箭加起来还多(只用文字,不画对比数字)
+ const mk = lt - Q.more;
+ if (mk > 0) {
+ const fp = MO.quintOut(seg(mk, 0, 0.45)), tx = 1046, ty = 478;
+ c.save(); c.font = f(40, CNB, '700 '); const tw = c.measureText('比全世界其他火箭加起来还多').width;
+ TY.marker(c, tx - tw - 10, ty - 36, tw + 20, 48, seg(mk, 0.15, 0.75), 'rgba(227,18,11,0.16)', 0.1);
+ c.globalAlpha = fp; c.fillStyle = INK; c.textAlign = 'right'; c.fillText('比全世界其他火箭加起来还多', tx - (1 - fp) * 16, ty);
+ c.fillStyle = RED; c.fillRect(tx - tw - 34, ty - 34, 6, 42 * fp);
+ c.restore();
+ }
+ c.restore();
+ }
+ // ---------- 第二页:一枚助推器飞了 37 次 ----------
+ if (sw > 0) {
+ header(c, lt - Q.one - 0.1, '一枚助推器的飞行次数', '同一枚猎鹰9号一级助推器,次', '来源:Space.com、Spaceflight Now', seg(sw, 0.4, 1));
+ c.save(); c.translate((1 - sw) * W, 0);
+ const bx = 300, by = 862;
+ booster(c, bx, by + MO.float(lt, 3, 4.1) * 0, 11.6);
+ // 计数:37 个小火箭标记一格格出现,与大数字同一条缓动,在「37」念完时落定
+ const c0 = Q.one + 0.55, cp = MO.sineInOut(seg(lt, c0, Q.land37)), n = Math.floor(cp * 37 + 1e-6);
+ for (let i = 0; i < 37; i++) {
+ const col = i % 10, row = Math.floor(i / 10), x = 560 + col * 84, y = 448 + row * 128;
+ const ti = c0 + MO.invert(MO.sineInOut, (i + 1) / 37) * (Q.land37 - c0), k = lt - ti;
+ c.save(); c.globalAlpha = 0.9; mark(c, x, y, 1, '#E4EAED'); c.restore();
+ if (k > 0) {
+ const s = MO.backOut(clamp(k / 0.22), 2.2), wave = lt > Q.land37 ? 0.06 * Math.max(0, Math.sin((lt - Q.land37) * 5 - i * 0.18)) * Math.exp(-(lt - Q.land37) * 1.2) : 0;
+ mark(c, x, y, s * (1 + wave), i === 36 ? RED : BLUE);
+ }
+ }
+ // 后段:一道浅光沿标记扫过(持续微动)
+ if (lt > Q.land37 + 0.3) { const sp = ((lt - Q.land37 - 0.3) * 0.55) % 1.4;
+ const gx = lerp(480, 1400, sp); const g = c.createLinearGradient(gx - 60, 0, gx + 60, 0); g.addColorStop(0, 'rgba(255,255,255,0)'); g.addColorStop(0.5, 'rgba(255,255,255,0.55)'); g.addColorStop(1, 'rgba(255,255,255,0)');
+ c.fillStyle = g; c.fillRect(gx - 60, 360, 120, 420); }
+ // 大数字
+ const v = Math.round(cp * 37);
+ c.save(); c.textAlign = 'right'; c.textBaseline = 'alphabetic'; c.globalAlpha = seg(lt, c0 - 0.2, c0 + 0.1);
+ c.fillStyle = SUB; c.font = f(36, CN); c.fillText('已经飞了', 1724, 500);
+ c.fillStyle = RED; c.font = `700 230px ${NUM}`; const nw = TY.tabular(c, String(v), 1660, 720, { align: 'right' });
+ c.fillStyle = INK; c.font = f(56, CNB, '700 '); c.textAlign = 'left'; c.fillText('次', 1670, 718);
+ const lk = lt - Q.land37; if (lk > 0) { c.strokeStyle = RED; c.lineWidth = 6; c.beginPath(); c.moveTo(1660 - nw, 752); c.lineTo(1660 - nw + (nw + 64) * MO.quintOut(clamp(lk / 0.35)), 752); c.stroke(); }
+ c.restore();
+ c.restore();
+ }
+ c.restore();
+ },
+};
+
+// 进入本段:经济学人式面板横推,品牌红竖条领路(新面板推入时就在搭版式)
+ERAS.find(e => e.id === ID).transition = { type: 'slidePush', dur: 0.55, bar: RED };
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex/scenes/s09.js b/scripts/engine/reference_films/spacex/spacex/scenes/s09.js
new file mode 100644
index 0000000..0262e7d
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex/scenes/s09.js
@@ -0,0 +1,229 @@
+// S09 · 发布会界面(t2 语法):这些发射大多在送星链卫星;2019 年第一批 60 颗;现在在轨超过 1.1 万颗,用户超过 1200 万。
+// 深色光斑底(UI.mesh,Stripe 一系紫/蓝/青+一点暖红)+一颗点阵地球;卫星是通用小亮点,沿倾斜轨道流动(3D 投影、球后遮挡)。
+// ①「这些发射」三道发射光迹从地表升入轨道,每到一道就有一批卫星点亮 →「星链卫星」标题从模糊里浮出
+// ②「2019年」地球左移,右侧玻璃卡:第一批「60 颗」,地球上 60 个点排成一列的「火车」沿轨道走,数字在「60」念完时落定
+// ③「现在」卡片散去,卫星从 60 个暴涨到满壳层,大数字 11,000+ 在「1.1万」念完时落定 ④「用户」两张玻璃卡并排,1200 万+ 落定,地表亮起一片用户终端
+// 字从模糊里浮出、弹簧轻回弹落位;相机全段线性慢推 1→1.045(减速到停会让画面死掉)。
+// 事实(核对表 19–21、21a):2019 年第一批 60 颗;在轨约 11,156 颗(截至 2026-10-02)→「11,000+」;用户超过 1200 万 →「1200 万+」。
+(() => {
+const W = 1920, H = 1080, ID = 's09';
+const { clamp, lerp, rng } = U;
+const seg = MO.seg, TAU = Math.PI * 2;
+const SANS = '"Inter", "PuHui-Medium"', ZH = '"PuHui-Medium"', ZHB = '"PuHui-Bold"';
+
+const Q = {
+ these: TM.cue(ID, '这些发射'), sl: TM.cue(ID, '星链卫星'), y19: TM.cue(ID, '2019年'), n60: TM.cue(ID, '60颗'), land60: TM.end(ID, '60'),
+ now: TM.cue(ID, '现在'), n11: TM.cue(ID, '1.1万'), land11: TM.end(ID, '1.1万'), users: TM.cue(ID, '用户'), land12: TM.end(ID, '1200') + 0.05, dur: TM.dur(ID),
+};
+
+// ---------- 光斑底 ----------
+const BLOBS = [
+ { x: 380, y: 260, r: 760, col: [150, 90, 238], a: 0.62, ax: 220, ay: 120, period: 11, ph: 0 },
+ { x: 1560, y: 240, r: 700, col: [56, 104, 255], a: 0.6, ax: 200, ay: 160, period: 13, ph: 2.1 },
+ { x: 1380, y: 920, r: 560, col: [120, 214, 255], a: 0.42, ax: 260, ay: 100, period: 9.5, ph: 4 },
+ { x: 480, y: 960, r: 520, col: [255, 96, 84], a: 0.32, ax: 180, ay: 90, period: 12, ph: 1.3 },
+];
+const bg = (c, lt) => {
+ UI.mesh(c, lt + 20, { base: '#050508', blobs: BLOBS, blur: 90, scale: 0.25, grain: 0.035, key: 's09mesh' });
+ const g = c.createRadialGradient(W / 2, H / 2, 100, W / 2, H / 2, 1000); g.addColorStop(0, 'rgba(0,0,0,0.42)'); g.addColorStop(1, 'rgba(0,0,0,0.12)');
+ c.fillStyle = g; c.fillRect(0, 0, W, H);
+};
+const track = (c, size, em = -0.02) => { c.letterSpacing = (size * em).toFixed(2) + 'px'; };
+
+// ---------- 地球与轨道(3D:Y 朝北,Z 朝观众;视线俯 TILT) ----------
+const TILT = 0.36;
+const view = lt => 0.6 + lt * 0.07; // 整个场景绕地轴慢转
+function proj(G, X, Y, Z, psi) {
+ const x1 = X * Math.cos(psi) + Z * Math.sin(psi), z1 = -X * Math.sin(psi) + Z * Math.cos(psi);
+ const y2 = Y * Math.cos(TILT) - z1 * Math.sin(TILT), z2 = Y * Math.sin(TILT) + z1 * Math.cos(TILT);
+ return [G.x + G.r * x1, G.y - G.r * y2, z2];
+}
+const GLOBE_DOTS = (() => { const n = 1100, o = []; for (let i = 0; i < n; i++) { const y = 1 - 2 * (i + 0.5) / n, rr = Math.sqrt(1 - y * y), th = i * 2.399963; o.push([rr * Math.cos(th), y, rr * Math.sin(th)]); } return o; })();
+// 卫星:0..59 = 2019 年那一列「火车」;其余分布在 72 个轨道面、三档倾角(通用造型,只是亮点)
+const SATS = (() => {
+ const r = rng(909), a = [];
+ for (let i = 0; i < 60; i++) a.push({ inc: 0.925, raan: 2.35, u0: 0.55 - i * 0.0085, sh: 1.2, train: true });
+ const planes = []; for (let k = 0; k < 72; k++) planes.push({ inc: k % 9 === 0 ? 1.7 : k % 4 === 0 ? 1.22 : 0.925, raan: k * TAU / 72 + r() * 0.03 });
+ for (let i = 60; i < 1560; i++) { const p = planes[i % 72]; a.push({ inc: p.inc, raan: p.raan, u0: r() * TAU, sh: 1.13 + 0.12 * r(), ph: r() }); }
+ return a;
+})();
+const satXYZ = (s, lt) => { const u = s.u0 + lt * TAU / 26, ci = Math.cos(s.inc), si = Math.sin(s.inc);
+ const X = Math.cos(u), Y = Math.sin(u) * si, Z = Math.sin(u) * ci;
+ const cr = Math.cos(s.raan), sr = Math.sin(s.raan); return [s.sh * (X * cr + Z * sr), s.sh * Y, s.sh * (-X * sr + Z * cr)]; };
+const ORBITS = [0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66].map(k => ({ inc: k % 9 === 0 ? 1.7 : k % 4 === 0 ? 1.22 : 0.925, raan: k * TAU / 72 }));
+const TERM = (() => { const r = rng(910), o = []; for (let i = 0; i < 170; i++) { const lat = -0.95 + 1.95 * r(), lon = r() * TAU; o.push({ v: [Math.cos(lat) * Math.cos(lon), Math.sin(lat), Math.cos(lat) * Math.sin(lon)], k: r(), ph: r() * TAU }); } return o; })();
+const LAUNCH = [{ t: 0.35, lat: 0.5, lon: 0.9 }, { t: 0.95, lat: 0.2, lon: 0.3 }, { t: 1.55, lat: 0.62, lon: 1.35 }].map(L => ({ ...L, v: [Math.cos(L.lat) * Math.sin(L.lon), Math.sin(L.lat), Math.cos(L.lat) * Math.cos(L.lon)] }));
+const LAUNCH_DUR = 0.85;
+
+// 地球位置:① 居中 → ②「2019年」左移 → ③「现在」回中(弹簧,不回弹)
+function globeAt(lt) {
+ const a = { x: 960, y: 640, r: 196 }, b = { x: 600, y: 590, r: 186 };
+ const k1 = MO.spring(lt - (Q.y19 - 0.05), { duration: 0.8 }), k2 = MO.spring(lt - (Q.now + 0.05), { duration: 0.8 });
+ const k = clamp(k1) * (1 - clamp(k2));
+ return { x: lerp(a.x, b.x, k), y: lerp(a.y, b.y, k), r: lerp(a.r, b.r, k) };
+}
+// 第 j 个普通卫星点亮的时刻(① 随三次发射成批点亮;③ 随计数暴涨)
+const A_PER = 80;
+const appearA = j => { const L = Math.floor(j / A_PER); return L < LAUNCH.length ? LAUNCH[L].t + LAUNCH_DUR + (j % A_PER) * 0.004 : 1e9; };
+const C0 = Q.now + 0.15, cntE = p => MO.expoOut(p);
+const appearC = j => C0 + MO.invert(cntE, (j + 1) / 1500) * (Q.land11 - C0);
+
+function drawGlobe(c, G, lt, psi) {
+ // 大气外辉光
+ const ag = c.createRadialGradient(G.x, G.y, G.r * 0.9, G.x, G.y, G.r * 1.45);
+ ag.addColorStop(0, 'rgba(110,170,255,0.35)'); ag.addColorStop(0.35, 'rgba(90,120,255,0.12)'); ag.addColorStop(1, 'rgba(90,120,255,0)');
+ c.fillStyle = ag; c.fillRect(G.x - G.r * 1.5, G.y - G.r * 1.5, G.r * 3, G.r * 3);
+ // 球体:左上受光的径向渐变
+ const sg = c.createRadialGradient(G.x - G.r * 0.38, G.y - G.r * 0.45, G.r * 0.05, G.x, G.y, G.r);
+ sg.addColorStop(0, '#3a56b8'); sg.addColorStop(0.45, '#1a2766'); sg.addColorStop(1, '#070a22');
+ c.fillStyle = sg; c.beginPath(); c.arc(G.x, G.y, G.r, 0, TAU); c.fill();
+ // 点阵表面(随场景转):越靠边越暗
+ c.fillStyle = '#9fb8ff';
+ for (const [X, Y, Z] of GLOBE_DOTS) { const [x, y, z] = proj(G, X, Y, Z, psi); if (z <= 0.02) continue; c.globalAlpha = 0.08 + 0.32 * z * z; c.fillRect(x - 1.1, y - 1.1, 2.2, 2.2); }
+ c.globalAlpha = 1;
+ // 右侧边缘光
+ c.save(); c.beginPath(); c.arc(G.x, G.y, G.r, 0, TAU); c.clip();
+ const rg = c.createRadialGradient(G.x - G.r * 0.25, G.y - G.r * 0.1, G.r * 0.88, G.x - G.r * 0.25, G.y - G.r * 0.1, G.r * 1.25);
+ rg.addColorStop(0, 'rgba(140,200,255,0)'); rg.addColorStop(1, 'rgba(140,200,255,0.55)'); c.fillStyle = rg; c.fillRect(G.x - G.r, G.y - G.r, G.r * 2, G.r * 2); c.restore();
+}
+
+SCENES[ID] = {
+ init() {
+ U.assertGlyphs('PuHui-Medium', '这些发射,大多在送2019年第一批颗现在在轨卫星用户万', ID);
+ U.assertGlyphs('PuHui-Bold', '星链卫星颗万', ID);
+ U.assertGlyphs('Inter', '0123456789,+', ID);
+ },
+ draw(c, lt) {
+ const bgc = UI.scratch('s09bg', W, H), bx = bgc.getContext('2d'); bg(bx, lt); c.drawImage(bgc, 0, 0);
+ const bd = UI.backdrop(bgc, { blur: 40, key: 's09bd' });
+ const z = lerp(1, 1.045, lt / (Q.dur + 0.8));
+ c.save(); c.translate(W / 2, H / 2); c.scale(z, z); c.translate(-W / 2, -H / 2);
+ const G = globeAt(lt), psi = view(lt);
+ const bFade = 1 - MO.smooth(seg(lt, Q.y19 - 0.1, Q.y19 + 0.35)); // ① 的点在「2019年」时散去
+ // 每颗卫星的可见度与「刚点亮」的闪
+ const satA = (i) => {
+ if (i < 60) { const ti = Q.y19 + 0.25 + (i / 59) * (Q.land60 - Q.y19 - 0.25); return [clamp((lt - ti) / 0.12), lt - ti]; }
+ const j = i - 60, ta = appearA(j), tc = appearC(j);
+ if (lt < Q.now) return [clamp((lt - ta) / 0.15) * bFade, lt - ta];
+ return [clamp((lt - tc) / 0.15), lt - tc];
+ };
+ const trainHi = MO.smooth(seg(lt, Q.y19 + 0.2, Q.y19 + 0.6)) * (1 - MO.smooth(seg(lt, Q.now + 0.2, Q.now + 0.9)));
+ const pts = [];
+ for (let i = 0; i < SATS.length; i++) { const [a, k] = satA(i); if (a <= 0) continue; const [X, Y, Z] = satXYZ(SATS[i], lt); const [x, y, zz] = proj(G, X, Y, Z, psi); pts.push([x, y, zz, a, k, i]); }
+ const hidden = (x, y, zz) => zz < 0 && Math.hypot(x - G.x, y - G.y) < G.r;
+ const dot = (x, y, zz, a, k, i) => {
+ const tr = i < 60, fl = k < 0.35 ? 1 - k / 0.35 : 0, back = zz < 0 ? 0.35 : 1;
+ const r = (tr ? lerp(2.4, 3.6, trainHi) : 2.3) * (1 + 1.3 * fl);
+ c.globalAlpha = a * back * (0.55 + 0.45 * Math.max(0, zz));
+ c.fillStyle = tr && trainHi > 0 ? '#ffffff' : '#cfe4ff'; c.beginPath(); c.arc(x, y, r, 0, TAU); c.fill();
+ if (fl > 0 || (tr && trainHi > 0)) { c.globalAlpha = a * back * Math.max(fl, tr ? trainHi * 0.7 : 0); TOON.glow(c, x, y, 14, tr ? '#9fe3ff' : '#ffffff', 0.6); }
+ };
+ // 轨道细线(几条,给壳层一个形)
+ c.save(); c.lineWidth = 1.2; c.strokeStyle = 'rgba(170,200,255,1)';
+ for (const o of ORBITS) { c.beginPath(); let pen = false;
+ for (let s = 0; s <= 96; s++) { const [X, Y, Z] = satXYZ({ inc: o.inc, raan: o.raan, u0: s / 96 * TAU, sh: 1.2 }, 0); const [x, y, zz] = proj(G, X, Y, Z, psi);
+ if (hidden(x, y, zz)) { pen = false; continue; } c.globalAlpha = zz < 0 ? 0.035 : 0.08; if (pen) c.lineTo(x, y); else { c.stroke(); c.beginPath(); c.moveTo(x, y); pen = true; } }
+ c.stroke(); }
+ c.restore();
+ // 球后的点 → 地球 → 球前的点
+ c.save(); for (const p of pts) if (p[2] < 0 && !hidden(p[0], p[1], p[2])) dot(...p); c.restore();
+ drawGlobe(c, G, lt, psi);
+ // ④ 用户终端:地表亮起一片暖色点
+ const u0 = Q.users + 0.1;
+ if (lt > u0) { c.save();
+ for (const T of TERM) { const ti = u0 + MO.invert(MO.expoOut, Math.max(0.02, T.k)) * (Q.land12 - u0), k = lt - ti; if (k <= 0) continue;
+ const [x, y, zz] = proj(G, T.v[0] * 1.002, T.v[1] * 1.002, T.v[2] * 1.002, psi); if (zz <= 0.05) continue;
+ const fl = k < 0.3 ? 1 - k / 0.3 : 0; c.globalAlpha = clamp(k / 0.1) * (0.5 + 0.5 * zz) * (0.8 + 0.2 * Math.sin(lt * 5 + T.ph));
+ c.fillStyle = '#FFB35C'; c.beginPath(); c.arc(x, y, 2.6 + 2 * fl, 0, TAU); c.fill(); TOON.glow(c, x, y, 12 + 10 * fl, '#FF9A3C', 0.5); }
+ c.restore(); }
+ c.save(); for (const p of pts) if (p[2] >= 0) dot(...p); c.restore();
+ // ① 发射光迹:从地表升入轨道
+ for (const L of LAUNCH) { const k = (lt - L.t) / LAUNCH_DUR; if (k <= 0 || k > 1.6) continue;
+ const head = MO.cubicInOut(clamp(k)), tail = MO.cubicInOut(clamp(k - 0.35)), fade = 1 - clamp((k - 1) / 0.6);
+ const at = q => { const rr = 1 + 0.2 * q, ex = 0.5 * q * q; const v = [L.v[0] + ex * 0.6, L.v[1] + ex * 0.1, L.v[2] - ex * 0.3], n = Math.hypot(...v); return proj(G, v[0] / n * rr, v[1] / n * rr, v[2] / n * rr, psi); };
+ c.save(); c.globalAlpha = fade; c.lineCap = 'round'; c.lineWidth = 4;
+ const N = 16; for (let s = 0; s < N; s++) { const q0 = lerp(tail, head, s / N), q1 = lerp(tail, head, (s + 1) / N), A = at(q0), B = at(q1); c.strokeStyle = `rgba(255,214,150,${(s + 1) / N})`; c.beginPath(); c.moveTo(A[0], A[1]); c.lineTo(B[0], B[1]); c.stroke(); }
+ const Hh = at(head); TOON.glow(c, Hh[0], Hh[1], 26, '#FFD08A', 0.9); c.fillStyle = '#fff'; c.beginPath(); c.arc(Hh[0], Hh[1], 4, 0, TAU); c.fill();
+ if (k > 1) { const q = (k - 1) / 0.6; c.strokeStyle = `rgba(207,228,255,${1 - q})`; c.lineWidth = 2; c.beginPath(); c.arc(Hh[0], Hh[1], 10 + q * 60, 0, TAU); c.stroke(); }
+ c.restore(); }
+
+ // ---------- 字与卡片 ----------
+ c.textAlign = 'center'; c.textBaseline = 'alphabetic';
+ // ① 眉题+标题
+ const tOut = MO.appleOut(seg(lt, Q.y19 - 0.15, Q.y19 + 0.3));
+ if (tOut < 1) { c.save(); c.globalAlpha = 1 - tOut; if (tOut > 0) c.filter = `blur(${(tOut * 16).toFixed(1)}px)`;
+ c.font = `500 40px ${ZH}`; c.fillStyle = '#a7a7b4'; c.letterSpacing = '6px';
+ TY.blurIn(c, '这些发射,大多在送', W / 2, 168, MO.appleOut(seg(lt, Q.these - 0.15, Q.these + 0.75)), { blur: 12, dy: 18 });
+ const tp = MO.appleOut(seg(lt, Q.sl - 0.35, Q.sl + 0.55));
+ if (tp > 0) { const tx = UI.scratch('s09title', W, 220), g = tx.getContext('2d'); g.reset();
+ g.font = `150px ${ZHB}`; track(g, 150, -0.02); g.textAlign = 'center'; g.textBaseline = 'alphabetic';
+ const gr = g.createLinearGradient(640, 0, 1280, 0); gr.addColorStop(0, '#ffffff'); gr.addColorStop(0.55, '#ddd2ff'); gr.addColorStop(1, '#a8dcff'); g.fillStyle = gr; g.fillText('星链卫星', W / 2, 170);
+ UI.sheen(g, null, seg(lt, Q.sl + 0.3, Q.sl + 1.1), { x0: 640, x1: 1280, width: 120, angle: -0.38, alpha: 0.85, comp: 'source-atop' });
+ c.save(); c.globalAlpha *= clamp(tp * 1.5); const b = (1 - tp) * 24; if (b > 0.3) c.filter = `blur(${b.toFixed(1)}px)`; c.drawImage(tx, 0, 330 - 170 + (1 - tp) * 36); c.restore(); }
+ c.restore(); }
+ // ② 2019 年卡片(先画进离屏,退场的模糊只作用在这张小图上——直接在大画布上开 filter 画玻璃卡要 600ms/帧)
+ const k2 = lt - (Q.y19 + 0.1), k2o = MO.appleOut(seg(lt, Q.now - 0.05, Q.now + 0.35));
+ if (k2 > 0 && k2o < 1) {
+ const sp = MO.spring(k2, { duration: 0.75, bounce: 0.15 }), x = 1050, y = 250 + (1 - sp) * 140 + MO.float(lt, 6, 3.6), w = 640, h = 520, s = (0.92 + 0.08 * sp) * (1 - 0.04 * k2o);
+ const ox = x - 110, oy = y - 110, cs = UI.scratch('s09card2', w + 220, h + 260), g = cs.getContext('2d'); g.reset(); g.translate(-ox, -oy);
+ g.translate(x + w / 2, y + h / 2); g.scale(s, s); g.translate(-x - w / 2, -y - h / 2);
+ UI.glass(g, { x, y, w, h, r: 36, bd, tint: 0.075, stroke: 0.2, light: 0.14 });
+ g.textAlign = 'left'; g.textBaseline = 'alphabetic'; g.font = `500 40px ${ZH}`; g.fillStyle = '#a7a7b4'; g.letterSpacing = '4px';
+ TY.blurIn(g, '2019年', x + 56, y + 100, MO.appleOut(seg(k2, 0.15, 0.85)), { blur: 10, dy: 14 });
+ g.letterSpacing = '0px'; g.font = `500 46px ${ZH}`; g.fillStyle = 'rgba(235,235,245,0.7)';
+ TY.blurIn(g, '第一批', x + 56, y + 176, MO.appleOut(seg(lt, Q.y19 + 0.7, Q.y19 + 1.4)), { blur: 10, dy: 14 });
+ const v = TY.count(lt, Q.land60 - 0.9, 0.9, 0, 60);
+ if (lt > Q.land60 - 0.95) { g.font = `600 250px ${SANS}`; track(g, 250, -0.03); g.fillStyle = '#ffffff'; const nw = TY.tabular(g, TY.fmt(v, 0), x + 44, y + 420);
+ g.letterSpacing = '0px'; g.font = `90px ${ZHB}`; g.fillStyle = 'rgba(235,235,245,0.75)'; g.fillText('颗', x + 44 + nw + 18, y + 420); }
+ // 卡底:一列 60 个小点(火车),随计数逐个亮
+ for (let i = 0; i < 60; i++) { const on = v >= i + 1 - 1e-6, xx = x + 60 + i * 8.9, yy = y + 470 - i * 0.6 + 2 * Math.sin(lt * 2.4 - i * 0.18);
+ g.globalAlpha = on ? 0.95 : 0.18; g.fillStyle = on ? '#ffffff' : '#8a8aa0'; g.beginPath(); g.arc(xx, yy, 2.8, 0, TAU); g.fill(); }
+ c.save(); c.globalAlpha = clamp(k2 / 0.25) * (1 - k2o); if (k2o > 0.01) c.filter = `blur(${(k2o * 20).toFixed(1)}px)`; c.drawImage(cs, ox, oy); c.restore();
+ }
+ // ③ 在轨 11,000+ ;④ 移进左卡,右卡 1200 万+
+ const k3 = lt - (Q.now + 0.1);
+ if (k3 > 0) {
+ const m = MO.spring(lt - (Q.users - 0.05), { duration: 0.7, bounce: 0 }), mm = clamp(m);
+ const cx = lerp(960, 640, mm), base = lerp(300, 300, mm), sz = lerp(176, 120, mm);
+ // 左卡(④ 才出现)
+ if (mm > 0.01) { c.save(); c.globalAlpha = mm; UI.glass(c, { x: 340, y: 116 + (1 - mm) * 20, w: 600, h: 254, r: 36, bd, tint: 0.075, stroke: 0.2, light: 0.14 }); c.restore(); }
+ c.save(); c.textAlign = 'center';
+ c.font = `500 ${lerp(40, 34, mm)}px ${ZH}`; c.fillStyle = '#a7a7b4'; c.letterSpacing = '4px';
+ TY.blurIn(c, '在轨卫星', cx, lerp(150, 186, mm), MO.appleOut(seg(k3, 0, 0.7)), { blur: 12, dy: 16 });
+ c.letterSpacing = '0px';
+ const v = TY.count(lt, C0, Q.land11 - C0, 60, 11000, cntE), str = TY.fmt(v, 0), plus = MO.appleOut(seg(lt, Q.land11 - 0.05, Q.land11 + 0.45));
+ c.font = `600 ${sz}px ${SANS}`; track(c, sz, -0.03); c.fillStyle = '#ffffff';
+ const dw = c.measureText('0').width, wNum = [...'11,000'].reduce((s, ch) => s + (/[0-9]/.test(ch) ? dw : c.measureText(ch).width), 0);
+ c.font = `${sz * 0.42}px ${ZHB}`; const wU = c.measureText('颗').width; c.font = `600 ${sz}px ${SANS}`; const wP = c.measureText('+').width;
+ const x0 = cx - (wNum + wP + wU + sz * 0.1) / 2;
+ c.globalAlpha = clamp(k3 / 0.2); TY.tabular(c, str, x0 + wNum, base + (1 - clamp(k3 / 0.4)) * 20, { align: 'right' });
+ if (plus > 0) { c.save(); c.globalAlpha = plus; c.textAlign = 'left'; if (plus < 1) c.filter = `blur(${((1 - plus) * 10).toFixed(1)}px)`; c.fillText('+', x0 + wNum + 4, base - (1 - plus) * 14); c.restore(); }
+ c.letterSpacing = '0px'; c.font = `${sz * 0.42}px ${ZHB}`; c.fillStyle = 'rgba(235,235,245,0.75)'; c.textAlign = 'left'; c.globalAlpha = plus; c.fillText('颗', x0 + wNum + wP + sz * 0.1, base);
+ c.restore();
+ // 右卡:用户 1200 万+
+ const k4 = lt - (Q.users - 0.05);
+ if (k4 > 0) {
+ const sp = MO.spring(k4, { duration: 0.75, bounce: 0.15 }), x = 980, y = 116 + (1 - sp) * 120, w = 600, h = 254;
+ c.save(); c.globalAlpha = clamp(k4 / 0.25); UI.glass(c, { x, y, w, h, r: 36, bd, tint: 0.075, stroke: 0.2, light: 0.14 });
+ c.textAlign = 'center'; c.font = `500 34px ${ZH}`; c.fillStyle = '#a7a7b4'; c.letterSpacing = '4px';
+ TY.blurIn(c, '用户', x + w / 2, y + 70, MO.appleOut(seg(k4, 0.1, 0.8)), { blur: 10, dy: 14 }); c.letterSpacing = '0px';
+ const v2 = TY.count(lt, Q.land12 - 0.95, 0.95, 0, 1200), p2 = MO.appleOut(seg(lt, Q.land12 - 0.05, Q.land12 + 0.45));
+ c.font = `600 120px ${SANS}`; track(c, 120, -0.03); c.fillStyle = '#ffffff';
+ const dw2 = c.measureText('0').width, wN = dw2 * 4; c.font = `50px ${ZHB}`; const wW = c.measureText('万').width; c.font = `600 120px ${SANS}`; const wP2 = c.measureText('+').width;
+ const xs = x + w / 2 - (wN + wW + wP2 + 16) / 2, by = y + 184;
+ if (lt > Q.land12 - 1.0) { TY.tabular(c, TY.fmt(v2, 0, false), xs + wN, by, { align: 'right' });
+ c.letterSpacing = '0px'; c.font = `50px ${ZHB}`; c.fillStyle = 'rgba(235,235,245,0.75)'; c.textAlign = 'left'; c.fillText('万', xs + wN + 8, by);
+ if (p2 > 0) { c.save(); c.globalAlpha *= p2; c.font = `600 120px ${SANS}`; c.fillStyle = '#ffffff'; if (p2 < 1) c.filter = `blur(${((1 - p2) * 10).toFixed(1)}px)`; c.fillText('+', xs + wN + 8 + wW + 6, by - (1 - p2) * 14); c.restore(); } }
+ // 落定后一道光扫过两张卡
+ const sw = seg(lt, Q.land12 + 0.2, Q.land12 + 1.0);
+ if (sw > 0 && sw < 1) { UI.sheen(c, UI.rrPath(x, y, w, h, 36), sw, { x0: 340, x1: 1580, width: 110, angle: -0.35, alpha: 0.2 }); UI.sheen(c, UI.rrPath(340, 116, 600, 254, 36), sw, { x0: 340, x1: 1580, width: 110, angle: -0.35, alpha: 0.2 }); }
+ c.restore();
+ }
+ }
+ c.restore();
+ },
+};
+
+// 进入本段:发布会式模糊推进(旧画面后退、模糊、变暗,新画面从 1.06 带模糊落到 1.0)
+ERAS.find(e => e.id === ID).transition = { type: 'blurPush', dur: 0.55 };
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex/scenes/s10.js b/scripts/engine/reference_films/spacex/spacex/scenes/s10.js
new file mode 100644
index 0000000..2b9555e
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex/scenes/s10.js
@@ -0,0 +1,279 @@
+// S10 · 波普漫画(利希滕斯坦式)——「再说星舰……一次就把落回来的助推器夹住了。」
+// 风格卡 13_pop:本戴点=createPattern(零成本、对齐屏幕不游泳)、5px 粗黑描边+饱和原色平涂、黄色旁白框、拟声大字(PuHui-Black+粗黑描边+红投影)。
+// 分格(都挂在口播词上):
+// ① 英雄仰拍:不锈钢星舰全箭+放射光芒,旁白框「星舰 / 史上最大、最强的火箭」
+// ② 斜切推格「2023年首飞」:升空、竖向速度线、地面滚出漫画云;「四分钟左右」开始翻滚
+// ③「炸」:硬切爆炸格——层叠尖爆炸+放射动作线+「轰!」
+// ④ 斜切推格「2024年10月」:发射塔、助推器带尾焰落回(速度线);「伸出两只机械臂」张开;「像筷子一样」右上小格一双筷子同步空夹;
+// 「夹住了」那一帧臂合拢+「咔!」+镜头冲一下
+SCENES['s10'] = (() => {
+ const ID = 's10', W = 1920, H = 1080, { clamp, lerp, ss, ease } = U, P = PAINT, TAU = Math.PI * 2;
+ const C = { ink: '#141414', paper: '#f3eedb', blue: '#2f5cc8', blueL: '#9fc2ee', yellow: '#f7d52c', red: '#d8232a', redD: '#a8161c', white: '#fbf8ee',
+ steel: '#d4d9e0', steelD: '#8c97a8', orange: '#f39a2c', wood: '#e8b56a' };
+ const cue = k => TM.cue(ID, k), DUR = TM.dur(ID);
+ const T_SX = cue('星舰'), T_SHI = cue('史上'), T_2023 = cue('2023年'), T_FIRE = cue('首飞'), T_4MIN = cue('四分钟左右'), T_BOOM = cue('炸'),
+ T_2024 = cue('2024年10月'), T_TA = cue('发射塔'), T_SHEN = cue('伸出'), T_KZ = cue('筷子'), T_LUO = cue('落回来'), T_JZ = cue('夹住');
+ const W12 = [T_2023 - 0.1, T_2023 + 0.22]; // ①→② 推格
+ const W34 = [T_2024 - 0.06, T_2024 + 0.26]; // ③→④ 推格
+ const poly = U.poly;
+ const pxs = c => { const m = c.getTransform(); return Math.hypot(m.a, m.b) || 1; };
+ const ink = (c, p, fill, lw = 5) => { if (fill) { c.fillStyle = fill; c.fill(p); } c.strokeStyle = C.ink; c.lineWidth = lw / pxs(c); c.lineJoin = 'round'; c.lineCap = 'round'; c.stroke(p); };
+ // 本戴点:图案按屏幕像素算(在「米」坐标里也不放大),网屏角 ang
+ const dots = (c, key, pitch, r, col, bg, ang = 45) => { const p = P.dotPattern(c, 's10' + key, pitch, r, col, bg, ang), s = pxs(c); p.setTransform(new DOMMatrix().scale(1 / s, 1 / s).rotate(ang)); return p; };
+ const fps15 = t => Math.floor(t * 15);
+
+ // ---------- 通用漫画件 ----------
+ // 并集轮廓:一组路径先统一描粗黑再统一填色(13 号的思考泡泡写法)
+ function union(c, paths, fill, lw = 10) { c.save(); c.lineJoin = 'round'; c.strokeStyle = C.ink; c.lineWidth = lw / pxs(c); paths.forEach(p => c.stroke(p)); c.fillStyle = fill; paths.forEach(p => c.fill(p)); c.restore(); }
+ function puff(c, x, y, r, seed, fill = C.white) {
+ const rr = U.rng(seed), ps = [];
+ for (let i = 0; i < 7; i++) { const a = rr() * TAU, d = r * (0.25 + rr() * 0.5); const p = new Path2D(); p.arc(x + Math.cos(a) * d, y + Math.sin(a) * d * 0.6, r * (0.4 + rr() * 0.3), 0, TAU); ps.push(p); }
+ union(c, ps, fill, 9);
+ }
+ // 漫画火焰:锯齿外缘(15fps 步进抖),红/黄/白三层,黑描边
+ function flame(c, x, y, len, w, t, seed = 0) {
+ const f = fps15(t);
+ const layer = (k, col) => { const L = len * k, ww = w * (0.5 + 0.5 * k), n = 9, pts = [[x - ww / 2, y]];
+ for (let i = 1; i <= n; i++) { const q = i / n, j = (U.hash(f + i, seed + k * 10) - 0.5) * ww * 0.5; const side = i % 2 ? -1 : 1, prof = (1 - q) * 0.5 + 0.08;
+ pts.push([x + side * ww * prof + j, y + L * q * (0.85 + 0.3 * U.hash(f, i + seed))]); }
+ pts.push([x + ww / 2, y]); ink(c, poly(pts), col, 4); };
+ layer(1, C.red); layer(0.68, C.yellow); layer(0.36, C.white);
+ }
+ // 尖角爆炸框
+ function burst(c, x, y, R, n, seed, fill, t, lw = 6) {
+ const f = fps15(t), p = new Path2D();
+ for (let i = 0; i < n * 2; i++) { const a = i / (n * 2) * TAU + seed, rr = i % 2 ? R * (0.55 + 0.1 * U.hash(i, seed * 7 + f)) : R * (0.85 + 0.25 * U.hash(i, seed * 3 + f)); const px = x + Math.cos(a) * rr, py = y + Math.sin(a) * rr; i ? p.lineTo(px, py) : p.moveTo(px, py); }
+ p.closePath(); ink(c, p, fill, lw);
+ }
+ // 拟声字:PuHui-Black,黄字+粗黑描边+红投影,30fps 卡点抖
+ function sfx(c, text, x, y, size, t, a = 1, rot = -0.08) {
+ const f = Math.floor(t * 30), jx = (U.hash(f, 1) - 0.5) * 12, jy = (U.hash(f, 2) - 0.5) * 10, jr = (U.hash(f, 3) - 0.5) * 0.05;
+ c.save(); c.translate(x + jx, y + jy); c.rotate(rot + jr); c.scale(a, a); c.font = `${size}px "PuHui-Black"`; c.textAlign = 'center'; c.textBaseline = 'middle'; c.lineJoin = 'round';
+ c.fillStyle = C.ink; c.fillText(text, 12, 12);
+ c.strokeStyle = C.ink; c.lineWidth = size * 0.16; c.strokeText(text, 0, 0);
+ c.fillStyle = C.yellow; c.fillText(text, 0, 0);
+ c.restore();
+ }
+ // 黄色旁白框(弹入:1.15 → 1 回弹)
+ function caption(c, lines, x, y, at, lt) {
+ const q = clamp((lt - at) / 0.18); if (q <= 0) return;
+ const s = 1.15 - 0.15 * ease.outBack(q);
+ c.save(); c.font = `${lines[0][1]}px "PuHui-Heavy"`;
+ let w = 0, h = 26; lines.forEach(([tx, sz]) => { c.font = `${sz}px "PuHui-Heavy"`; w = Math.max(w, c.measureText(tx).width); h += sz * 1.22; });
+ w += 52;
+ c.translate(x, y); c.scale(s, s); c.globalAlpha = Math.min(1, q * 3);
+ c.fillStyle = C.ink; c.fillRect(8, 8, w, h); c.fillStyle = C.yellow; c.fillRect(0, 0, w, h); c.strokeStyle = C.ink; c.lineWidth = 5; c.strokeRect(0, 0, w, h);
+ let yy = 14; c.fillStyle = C.ink; c.textBaseline = 'top';
+ lines.forEach(([tx, sz, at2]) => { const qa = at2 == null ? 1 : clamp((lt - at2) / 0.12); c.globalAlpha = Math.min(1, q * 3) * qa; c.font = `${sz}px "PuHui-Heavy"`; c.fillText(tx, 26, yy + sz * 0.04); yy += sz * 1.22; });
+ c.restore();
+ }
+ // 速度线(竖向,dir=+1 往下流=物体往上冲;-1 往上流)
+ function speedLines(c, t, dir, x0, x1, n, seed, col = C.white, lw = 5) {
+ c.save(); c.strokeStyle = col; c.lineCap = 'round';
+ for (let i = 0; i < n; i++) { const x = lerp(x0, x1, U.hash(i, seed)), L = 180 + U.hash(i, seed + 1) * 380, sp = 1600 + U.hash(i, seed + 2) * 900;
+ const y = ((U.hash(i, seed + 3) * 2000 + dir * t * sp) % 2000 + 2000) % 2000 - 500; c.lineWidth = lw * (0.5 + U.hash(i, seed + 4));
+ c.beginPath(); c.moveTo(x, y); c.lineTo(x, y + L); c.stroke(); }
+ c.restore();
+ }
+
+ // ---------- 不锈钢箭体:平涂浅钢灰+右侧本戴点暗部(点网随呼吸缩放)+左缘白高光条+粗黑描边 ----------
+ function steel(c, sh, t) {
+ const hull = new Path2D(); sh.parts.forEach(q => { if (q.k === 'body' || q.k === 'nose') hull.addPath(q.p); });
+ sh.parts.forEach(q => { if (q.k !== 'body' && q.k !== 'nose' && q.k !== 'tiles' && q.k !== 'truss') { c.fillStyle = q.k === 'flap' ? '#5b6474' : C.ink; c.fill(q.p); } });
+ c.fillStyle = C.steel; c.fill(hull);
+ c.save(); c.clip(hull);
+ const s = pxs(c), pat = dots(c, 'steelDot', 14, 3.6, C.steelD, null, 45), br = 1 + 0.12 * Math.sin(t * 3.2); // 网点阴影呼吸
+ pat.setTransform(new DOMMatrix().scale(br / s, br / s).rotate(45));
+ c.fillStyle = pat; c.fillRect(sh.w * 0.12, -sh.h - 2, sh.w, sh.h + 4);
+ c.fillStyle = C.blueL; c.fillRect(-sh.w * 0.36, -sh.h - 2, sh.w * 0.08, sh.h + 4); // 天光反射条
+ c.fillStyle = C.white; c.fillRect(-sh.w * 0.25, -sh.h - 2, sh.w * 0.07, sh.h + 4); // 白高光条
+ const tl = sh.parts.find(q => q.k === 'tiles'); if (tl) { c.fillStyle = C.ink; c.fill(tl.p); }
+ c.strokeStyle = C.ink; c.lineWidth = 2.2 / s; for (let y = -6; y > -sh.h; y -= 6) { c.beginPath(); c.moveTo(-sh.w, y); c.lineTo(sh.w, y); c.stroke(); }
+ c.restore();
+ sh.parts.forEach(q => { if (q.k !== 'truss' && q.k !== 'tiles' && q.k !== 'body' && q.k !== 'nose') ink(c, q.p, null, 4); });
+ ink(c, hull, null, 5.5);
+ }
+ const FULL = RK.starship({ fins: 1 }), BOOST = RK.superHeavy({ fins: 1 });
+
+ // ---------- ① 英雄仰拍 ----------
+ function sunburst(c, cx, cy, t, cols, n = 24) {
+ const a0 = t * 0.06;
+ for (let i = 0; i < n; i++) { const a = a0 + i / n * TAU, b = a + TAU / n; c.fillStyle = cols[i % 2]; c.beginPath(); c.moveTo(cx, cy); c.lineTo(cx + Math.cos(a) * 2600, cy + Math.sin(a) * 2600); c.lineTo(cx + Math.cos(b) * 2600, cy + Math.sin(b) * 2600); c.closePath(); c.fill(); }
+ }
+ function panel1(c, lt, t) {
+ const zoom = 1 + 0.05 * ss(0, T_2023, lt);
+ c.save(); c.translate(1180, 620); c.scale(zoom, zoom); c.translate(-1180, -620);
+ sunburst(c, 1180, 470, t, [C.yellow, C.orange]);
+ c.save(); c.globalAlpha = 0.5; c.fillStyle = dots(c, 'burstDot', 18, 3.4, C.red, null, 15); c.fillRect(-200, -200, W + 400, H + 400); c.restore();
+ // 发射台
+ ink(c, poly([[960, 1100], [1010, 990], [1350, 990], [1400, 1100]]), '#57606e', 5);
+ c.save(); c.clip(poly([[960, 1100], [1010, 990], [1350, 990], [1400, 1100]])); c.fillStyle = dots(c, 'mountDot', 12, 3, C.ink, null, 45); c.fillRect(1180, 980, 240, 140); c.restore();
+ // 全箭:仰拍——先画进离屏,再按横条做梯形透视(越往下越宽=离镜头越近),读出「巨大」
+ const R1 = P.scratch('s10hero'), rg = R1.getContext('2d'); rg.reset();
+ rg.translate(1180, 1010); rg.scale(7.9, 7.9); steel(rg, FULL, t); rg.setTransform(1, 0, 0, 1, 0, 0);
+ const top = 1010 - FULL.h * 7.9;
+ for (let y = Math.floor(top) - 4; y < 1080; y += 6) { const q = clamp((y - top) / (1010 - top)), f = lerp(0.95, 2.1, Math.pow(q, 1.35)), hw = 120;
+ c.drawImage(R1, 1180 - hw, y, hw * 2, 6.6, 1180 - hw * f, y, hw * 2 * f, 6.6); }
+ // 闪光:箭体上两颗四芒星
+ [[1150, 330, 0], [1210, 720, 1.7]].forEach(([x, y, ph]) => { const k = 0.5 + 0.5 * Math.sin(t * 4 + ph), L = 30 + 26 * k; c.fillStyle = C.white; c.strokeStyle = C.ink; c.lineWidth = 3;
+ const p = new Path2D(); p.moveTo(x - L, y); p.quadraticCurveTo(x, y, x, y - L); p.quadraticCurveTo(x, y, x + L, y); p.quadraticCurveTo(x, y, x, y + L); p.quadraticCurveTo(x, y, x - L, y); c.fill(p); c.stroke(p); });
+ // 加注白汽:底部漫画云左右滚
+ for (let i = 0; i < 6; i++) { const side = i % 2 ? 1 : -1, ph = (lt * 0.35 + i * 0.17) % 1; puff(c, 1180 + side * (140 + ph * 260 + i * 20), 990 - (i % 3) * 30 - ph * 40, 55 + (i % 3) * 18, 70 + i); }
+ c.restore();
+ caption(c, [['星舰', 92, T_SX - 0.05], ['史上最大、最强的火箭', 54, T_SHI - 0.03]], 96, 66, T_SX - 0.08, lt);
+ }
+
+ // ---------- ② 升空 → 翻滚 ----------
+ function panel2(c, lt, t) {
+ const u = Math.max(0, lt - (T_FIRE + 0.08));
+ const climb = 260 * ss(0, 0.9, u) + 1100 * u * u * 0.18; // 地面往下退的量(镜头跟着火箭往上)
+ c.fillStyle = C.white; c.fillRect(0, 0, W, H);
+ c.fillStyle = dots(c, 'sky2', 22, 6.2, C.blue, C.blueL, 45); c.fillRect(0, 0, W, H);
+ if (u > 0) speedLines(c, t, 1, 120, 1800, 34, 11, C.white, 6);
+ // 地面、塔、发射台随镜头下退
+ c.save(); c.translate(0, climb);
+ ink(c, poly([[-20, 1020], [W + 20, 1000], [W + 20, 1200], [-20, 1200]]), C.yellow, 6);
+ c.save(); c.translate(960, 1010); c.scale(4.25, 4.25); const tw = RK.tower({ armY: 88, open: 0.9 });
+ ink(c, tw.parts.find(q => q.k === 'body').p, '#8b95a5', 5); c.fillStyle = C.ink; c.fill(tw.parts.find(q => q.k === 'truss').p); c.restore();
+ ink(c, poly([[700, 1010], [740, 900], [1020, 900], [1060, 1010]]), '#57606e', 5);
+ c.restore();
+ // 火箭:先在发射台上点火,再往上冲到画面中段,「四分钟左右」开始翻滚
+ const rise = Math.min(260, 120 * u + 160 * u * u);
+ const tumble = lt > T_4MIN ? 0.9 * Math.pow(clamp((lt - T_4MIN) / (T_BOOM - T_4MIN)), 1.6) + 0.06 * Math.sin(lt * 18) * ss(T_4MIN, T_4MIN + 0.3, lt) : 0;
+ const bx = 880 + 60 * tumble, by = 900 - rise;
+ c.save(); c.translate(bx, by - 260); c.rotate(tumble); c.translate(0, 260); c.scale(4.25, 4.25);
+ const ig = ss(T_FIRE - 0.08, T_FIRE + 0.15, lt);
+ if (ig > 0) flame(c, 0, 1.2, (30 + 26 * ss(0, 1, u)) * ig, 12, t, 1);
+ steel(c, FULL, t);
+ c.restore();
+ // 晃动标记线(翻滚时)
+ if (tumble > 0.05) { c.save(); c.strokeStyle = C.ink; c.lineWidth = 6; c.lineCap = 'round'; const k = fps15(t) % 2;
+ [[-1, 0], [1, 0.4]].forEach(([s, ph]) => { const x = bx + s * 150, y = by - 380 + ph * 120, a0 = s > 0 ? 0 : Math.PI; c.beginPath(); c.arc(x - s * 60, y, 60 + k * 10, a0 - 0.8, a0 + 0.8); c.stroke(); c.beginPath(); c.arc(x - s * 60, y, 90 + k * 10, a0 - 0.6, a0 + 0.6); c.stroke(); }); c.restore(); }
+ // 地面滚出的漫画云
+ if (u > 0) for (let i = 0; i < 10; i++) { const side = i % 2 ? 1 : -1, g = ss(0, 0.8, u), x = 880 + side * (90 + g * (120 + i * 46)), y = 960 + climb - (i % 3) * 40 - g * 50;
+ if (y < 1200) puff(c, x, y, (60 + (i % 4) * 16) * (0.45 + 0.55 * g), 200 + i); }
+ caption(c, [['2023年首飞', 72], ['四分钟左右……', 50, T_4MIN - 0.03]], 96, 66, T_2023 - 0.05, lt);
+ }
+
+ // ---------- ③ 爆炸格 ----------
+ function panel3(c, lt, t) {
+ const u = Math.max(0, lt - T_BOOM + 0.03);
+ sunburst(c, 900, 470, t * 3, [C.red, C.yellow], 28);
+ c.save(); c.globalAlpha = 0.55; c.fillStyle = dots(c, 'boomDot', 16, 3.6, C.redD, null, 75); c.fillRect(0, 0, W, H); c.restore();
+ // 放射动作线
+ c.save(); c.strokeStyle = C.ink; c.lineCap = 'round';
+ for (let i = 0; i < 26; i++) { const a = i / 26 * TAU + 0.1, r0 = 330 + 60 * U.hash(i, 4), L = (120 + 140 * U.hash(i, 5)) * (0.8 + 0.3 * Math.sin(t * 30 + i)); c.lineWidth = 6 + 6 * U.hash(i, 6);
+ c.beginPath(); c.moveTo(900 + Math.cos(a) * r0, 470 + Math.sin(a) * r0 * 0.8); c.lineTo(900 + Math.cos(a) * (r0 + L), 470 + Math.sin(a) * (r0 + L) * 0.8); c.stroke(); }
+ c.restore();
+ const g = ease.outBack(clamp(u / 0.22));
+ burst(c, 900, 470, 380 * g, 14, 0.2, C.white, t, 7);
+ burst(c, 900, 470, 290 * g, 12, 0.9, C.yellow, t, 6);
+ burst(c, 900, 470, 190 * g, 10, 1.7, C.red, t, 6);
+ // 碎片
+ for (let i = 0; i < 9; i++) { const a = i / 9 * TAU + 0.4, v = 520 + 300 * U.hash(i, 8), x = 900 + Math.cos(a) * v * u, y = 470 + Math.sin(a) * v * u * 0.8 + 300 * u * u;
+ c.save(); c.translate(x, y); c.rotate(u * (8 + i)); ink(c, poly([[-22, -8], [26, -12], [20, 10], [-18, 8]]), i % 2 ? C.steel : '#57606e', 4); c.restore(); }
+ sfx(c, '轰!', 930, 470, 260, t, 0.6 + 0.4 * ease.outBack(clamp(u / 0.18)));
+ }
+
+ // ---------- ④ 发射塔「筷子」夹住助推器 ----------
+ const PX4 = 10, TWX = 1190, GY = 380 + 88 * PX4, RX = TWX - 16 * PX4, ARMY = 88, BASE_CATCH = ARMY + 0.8 - 63;
+ function armTheta(lt) {
+ let th = lerp(1.25, 0.5, ease.inOut(ss(T_SHEN, T_SHEN + 0.7, lt)));
+ const q = clamp((lt - T_KZ) / 0.75); th -= 0.26 * Math.abs(Math.sin(q * Math.PI * 2));
+ return lerp(th, 0.03, ease.in(ss(T_JZ - 0.3, T_JZ + 0.05, lt)));
+ }
+ function arm(c, th, s) {
+ const L = 30, kV = 0.5, r0 = 0.25 + Math.sin(th) * 1.6, x1 = -L * Math.cos(th), y1 = -ARMY + s * L * Math.sin(th) * kV, y0 = -ARMY + s * r0;
+ const ang = Math.atan2(y1 - y0, x1), nx = -Math.sin(ang), ny = Math.cos(ang);
+ const body = poly([[nx, y0 + ny], [x1 + nx * 0.75, y1 + ny * 0.75], [x1 - nx * 0.75, y1 - ny * 0.75], [-nx, y0 - ny]]);
+ ink(c, body, s < 0 ? '#3b4250' : '#57606e', 5);
+ c.save(); c.clip(body); c.strokeStyle = C.ink; c.lineWidth = 2.5 / pxs(c); for (let i = 0; i < 12; i++) { const a = i / 12, b = (i + 1) / 12; c.beginPath(); c.moveTo(x1 * a + nx, lerp(y0, y1, a) + ny); c.lineTo(x1 * b - nx, lerp(y0, y1, b) - ny); c.stroke(); } c.restore();
+ ink(c, poly([[x1 + 1.3, y1 - 1.1], [x1 - 0.4, y1 - 1.1], [x1 - 0.4, y1 + 1.1], [x1 + 1.3, y1 + 1.1]]), C.red, 4);
+ }
+ function boosterY(lt) {
+ const t0 = T_TA + 0.05, t1 = T_JZ - 0.06, p = clamp((lt - t0) / (t1 - t0));
+ let base = lerp(122, BASE_CATCH + 0.9, 1 - Math.pow(1 - p, 1.7));
+ const st = ss(T_JZ - 0.02, T_JZ + 0.16, lt); base -= 0.9 * st - 0.4 * Math.sin(st * Math.PI);
+ return { y: GY - base * PX4, p, x: RX + Math.sin(lt * 2.3) * 9 * (1 - p) };
+ }
+ function chopsticks(c, lt, t, th) { // 右上小格:一双筷子跟臂同步空夹
+ const q0 = clamp((lt - (T_KZ - 0.12)) / 0.25), qi = ease.outBack(q0), qo = ss(T_LUO + 0.1, T_LUO + 0.4, lt); if (q0 <= 0 || qo >= 1) return;
+ const x = 1500, y = 150, w = 330, h = 250;
+ c.save(); c.translate(x + w / 2, y + h / 2 + 40 * qo); const s = (0.6 + 0.4 * qi) * (1 - qo); c.scale(s, s); c.rotate(0.03); c.translate(-w / 2, -h / 2);
+ c.fillStyle = C.ink; c.fillRect(10, 10, w, h);
+ c.fillStyle = C.yellow; c.fillRect(0, 0, w, h); c.save(); c.beginPath(); c.rect(0, 0, w, h); c.clip();
+ c.fillStyle = dots(c, 'insetDot', 14, 3.2, C.orange, null, 0); c.fillRect(0, 0, w, h);
+ const open = Math.sin(th) * 0.55;
+ [[-1, '#e8b56a'], [1, '#d99c48']].forEach(([sd, col]) => { c.save(); c.translate(w + 20, h / 2 + sd * 26); c.rotate(Math.PI + sd * (0.087 - open * 1.1)); ink(c, poly([[0, -12], [300, -5], [300, 5], [0, 12]]), col, 5); c.fillStyle = C.red; c.fillRect(0, -12, 46, 24); c.strokeRect(0, -12, 46, 24); c.restore(); });
+ c.restore(); c.strokeStyle = C.ink; c.lineWidth = 6; c.strokeRect(0, 0, w, h);
+ c.restore();
+ }
+ function panel4(c, lt, t) {
+ // 「夹住」那一下的镜头冲击
+ const hit = lt - T_JZ, punch = hit > 0 ? 1 + 0.07 * Math.exp(-hit * 5) * Math.cos(hit * 14) + 0.03 * ss(0, 0.3, hit) : 1;
+ c.save(); c.translate(RX, 400); c.scale(punch, punch); c.translate(-RX, -400);
+ c.fillStyle = C.white; c.fillRect(-100, -100, W + 200, H + 200);
+ c.fillStyle = dots(c, 'sky4', 22, 6.2, C.blue, C.blueL, 45); c.fillRect(-100, -100, W + 200, H + 200);
+ // 漫画白云漂
+ [[260, 300, 70, 1], [560, 600, 54, 2], [1560, 700, 60, 3], [330, 820, 64, 4]].forEach(([x, y, r, k]) => puff(c, x + lt * (14 + k * 4), y, r, 400 + k));
+ const B = boosterY(lt), th = armTheta(lt);
+ // 塔身
+ c.save(); c.translate(TWX, GY); c.scale(PX4, PX4); const tw = RK.tower({ armY: ARMY });
+ ink(c, tw.parts.find(q => q.k === 'body').p, '#8b95a5', 6);
+ c.save(); c.clip(tw.parts.find(q => q.k === 'body').p); c.fillStyle = dots(c, 'towerDot', 12, 3.2, C.ink, null, 45); c.fillRect(7, -150, 6, 152); c.restore();
+ c.fillStyle = C.ink; c.fill(tw.parts.find(q => q.k === 'truss').p);
+ ink(c, poly([[-1.4, -ARMY - 4.5], [3.5, -ARMY - 4.5], [3.5, -ARMY + 4.5], [-1.4, -ARMY + 4.5]]), C.yellow, 5);
+ arm(c, th, -1);
+ c.restore();
+ // 助推器+尾焰+上方速度线
+ if (lt > T_TA - 0.1) {
+ const fl = 1 - ss(T_JZ - 0.05, T_JZ + 0.2, lt);
+ if (fl > 0.02 && B.p < 0.97) { c.save(); c.beginPath(); c.rect(B.x - 70, -100, 140, B.y - 700 + 100); c.clip(); speedLines(c, t, -1, B.x - 60, B.x + 60, 7, 31, C.ink, 5); c.restore(); }
+ c.save(); c.translate(B.x, B.y); c.scale(PX4, PX4);
+ if (fl > 0) flame(c, 0, 1.2, (24 - 8 * B.p) * fl, 7 * (0.6 + 0.4 * fl), t, 3);
+ steel(c, BOOST, t); c.restore();
+ }
+ c.save(); c.translate(TWX, GY); c.scale(PX4, PX4); arm(c, th, 1); c.restore();
+ // 接住:放射动作线
+ if (hit > 0 && hit < 1.2) { const k = 1 - ss(0.4, 1.2, hit); c.save(); c.strokeStyle = C.ink; c.lineCap = 'round';
+ for (let i = 0; i < 16; i++) { const a = i / 16 * TAU + 0.2, r0 = 120 + 40 * U.hash(i, 9), L = (80 + 90 * U.hash(i, 10)) * k; c.lineWidth = 5; c.beginPath(); c.moveTo(RX + Math.cos(a) * r0, 380 + Math.sin(a) * r0); c.lineTo(RX + Math.cos(a) * (r0 + L), 380 + Math.sin(a) * (r0 + L)); c.stroke(); } c.restore(); }
+ c.restore();
+ chopsticks(c, lt, t, th);
+ if (hit > -0.02) { const a = ease.outBack(clamp((hit + 0.02) / 0.16)); burst(c, 760, 300, 150 * a, 11, 0.4, C.white, t, 6); sfx(c, '咔!', 770, 300, 150, t, a, -0.1); }
+ caption(c, [['2024年10月', 72]], 96, 66, T_2024 - 0.02, lt);
+ }
+
+ // ---------- 推格:新格从右边斜切推进来,中间一条白色格缝+两道黑格线 ----------
+ function wipe(c, q, drawA, drawB) {
+ const X = lerp(W + 420, -420, ease.inOut(q)), k = 0.32, edge = y => X + (y - 540) * k;
+ drawA(c);
+ c.save(); c.beginPath(); c.moveTo(edge(-20), -20); c.lineTo(W + 600, -20); c.lineTo(W + 600, H + 20); c.lineTo(edge(H + 20), H + 20); c.closePath(); c.clip(); drawB(c); c.restore();
+ c.save(); c.strokeStyle = C.paper; c.lineWidth = 30; c.beginPath(); c.moveTo(edge(-20) - 12, -20); c.lineTo(edge(H + 20) - 12, H + 20); c.stroke();
+ c.strokeStyle = C.ink; c.lineWidth = 6; [-30, 4].forEach(d => { c.beginPath(); c.moveTo(edge(-20) + d, -20); c.lineTo(edge(H + 20) + d, H + 20); c.stroke(); }); c.restore();
+ }
+ const FRAME = () => P.cached('s10_frame', W, H, (g) => {
+ g.fillStyle = C.paper; g.beginPath(); g.rect(0, 0, W, H); g.rect(20, 17, W - 40, H - 34); g.fill('evenodd');
+ g.strokeStyle = C.ink; g.lineWidth = 6; g.strokeRect(17, 14, W - 34, H - 28);
+ g.drawImage(P.grain('s10pop', 0.03, [60, 50, 30], 0.1), 0, 0);
+ });
+
+ return {
+ init() {
+ U.assertGlyphs('PuHui-Heavy', '星舰史上最大、最强的火箭2023年首飞四分钟左右……2024年10月', ID);
+ U.assertGlyphs('PuHui-Black', '轰!咔!', ID);
+ },
+ draw(c, lt, t) {
+ const p1 = g => panel1(g, lt, t), p2 = g => panel2(g, lt, t), p3 = g => panel3(g, lt, t), p4 = g => panel4(g, lt, t);
+ c.save(); c.beginPath(); c.rect(20, 17, W - 40, H - 34); c.clip();
+ if (lt < W12[0]) p1(c);
+ else if (lt < W12[1]) wipe(c, (lt - W12[0]) / (W12[1] - W12[0]), p1, p2);
+ else if (lt < T_BOOM - 0.03) p2(c);
+ else if (lt < W34[0]) { p3(c); if (lt < T_BOOM + 0.03) { c.fillStyle = 'rgba(255,255,255,.85)'; c.fillRect(0, 0, W, H); } }
+ else if (lt < W34[1]) wipe(c, (lt - W34[0]) / (W34[1] - W34[0]), p3, p4);
+ else p4(c);
+ c.restore();
+ c.drawImage(FRAME(), 0, 0);
+ },
+ };
+})();
+ERAS.find(e => e.id === 's10').transition = { type: 'zigzag', dur: 0.55 };
diff --git a/scripts/engine/reference_films/spacex/spacex/scenes/s11.js b/scripts/engine/reference_films/spacex/spacex/scenes/s11.js
new file mode 100644
index 0000000..5a2cec6
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex/scenes/s11.js
@@ -0,0 +1,374 @@
+// S11 ·讲解员式财经讲解。只借画面语法:米白纸面、扁平可爱的信息图标、深色均匀描边的圆角贴纸卡、
+// 关键词放进彩色圆角框/荧光底、手绘箭头和圈注(8fps 沸腾)、一侧大头小身体的讲解员指着信息图;一屏一个知识点。
+// 讲解员=花叔本人的卡通形象(10 号 C 法):gpt-image 按本段扁平画风生成 4 张 3 帧 sprite(指向 / 摊手展示 / 张臂比大 / 举手惊讶),
+// 绿幕抠图、按脚底中心对齐切帧(spacex/assets/s11_*),按口播换姿势、8.5fps 换口型帧;代码加眨眼、点头、呼吸、说话颠动、换姿势挤压回弹。
+// 三屏:①收购(SpaceX 卡吞下 xAI 卡)→ ②6月上市·募资超过 750 亿美元(计数落定+金币长高+荧光圈「史上最大」)
+// → ③9月28号星舰入轨(日历撕页、小星舰绕地球、26 颗卫星从飞船里依次弹出排好)。所有动作挂在 TM.cue 上。
+// 母题小循环:背景手绘小涂鸦漂浮、页眉标签轻摆、讲解员呼吸+口型、金币闪光、地球自转、轨道虚线流动、卫星浮动闪烁、圈注沸腾。
+(() => {
+const W = 1920, H = 1080, ID = 's11';
+const { clamp, lerp, rng } = U;
+const TAU = Math.PI * 2;
+
+// ---------- 讲解员帧(引擎 boot 前登记,路径相对 代码工程/) ----------
+// 本段 4 套 AI 帧(s11_sheet_* 生成、绿幕抠图、按脚底中心对齐切帧)+闭眼变体 *_b(素材修图:瞳孔涂成肤色+闭眼弧线);
+// 「比数字」帧复制自小Lin单风格版的 count 帧(已拷进 spacex/assets/s11_count_*,两片互不依赖)。
+// m: ax/ay 帧内脚底中心;px/py 脖子枢轴(点头时头部分块绕它转,py=下巴下沿);k 尺寸校正;nod 是否点头;blink 是否有闭眼帧
+const SA = 'spacex/assets/';
+const POSES = {
+ point: { n: 3, src: i => `${SA}s11_point_${i}.png`, ax: 206, ay: 782, px: 237, py: 301, k: 1, nod: 1, blink: 1 },
+ present: { n: 3, src: i => `${SA}s11_present_${i}.png`, ax: 209, ay: 784, px: 241, py: 302, k: 1, nod: 1, blink: 1 },
+ big: { n: 3, src: i => `${SA}s11_big_${i}.png`, ax: 260, ay: 707, px: 280, py: 280, k: 1.11, nod: 0, blink: 1 },
+ wow: { n: 3, src: i => `${SA}s11_wow_${i}.png`, ax: 258, ay: 855, px: 0, py: 0, k: 1, nod: 0, blink: 0 },
+ count: { n: 3, src: i => `spacex/assets/s11_count_${i}.png`, ax: 193, ay: 787, px: 194, py: 312, k: 1, nod: 0, blink: 0 },
+};
+const ALLFR = [];
+for (const P of Object.values(POSES)) for (let i = 0; i < P.n; i++) { ALLFR.push(P.src(i)); if (P.blink) ALLFR.push(P.src(i).replace('.png', '_b.png')); }
+(window.EXTRA_ASSETS = window.EXTRA_ASSETS || []).push(...ALLFR);
+
+const C = { bg: '#F7F0E1', dot: '#E3D8C2', ink: '#2B2A33', sub: '#6E6878', white: '#FFFFFF', red: '#F25F5C', yel: '#FFD447',
+ hl: 'rgba(255,222,77,0.85)', blue: '#4C8DF6', teal: '#22B39C', purple: '#8A72F0', pink: '#FF9BB0', orange: '#FF9F43',
+ gold: '#F7C948', goldD: '#D9961C', sea: '#5BAEF2', seaD: '#3E8FD6', land: '#7DCB78', steel: '#E8ECF2', tile: '#3A3F4B' };
+const F = (s, w = 'Heavy') => `${s}px "PuHui-${w}"`;
+
+let Q = null;
+const q = () => Q || (Q = {
+ y26: TM.cue(ID, '2026年'), spx: TM.cue(ID, 'SpaceX'), sg: TM.cue(ID, '收购'), msk: TM.cue(ID, '马斯克'), xai: TM.cue(ID, 'xAI'),
+ jun: TM.cue(ID, '6月上市'), ss: TM.cue(ID, '上市'), mz: TM.cue(ID, '募资'), n750: TM.cue(ID, '750亿美元'),
+ zd: TM.cue(ID, '史上最大'), ycE: TM.end(ID, '一次上市'), d928: TM.cue(ID, '9月28号'), rg: TM.cue(ID, '星舰入轨'),
+ fc: TM.cue(ID, '放出'), n26E: TM.end(ID, '26颗'), xyd: TM.cue(ID, '新一代'),
+});
+
+// ---------- 小工具 ----------
+const rrp = (x, y, w, h, r) => { const p = new Path2D(); p.roundRect(x, y, w, h, r); return p; };
+// 扁平贴纸卡:填色+深色描边+错位硬阴影
+function card(g, x, y, w, h, { fill = C.white, r = 26, lw = 4, sh = 8 } = {}) {
+ const p = rrp(x, y, w, h, r);
+ g.save(); g.translate(sh * 0.6, sh); g.fillStyle = 'rgba(43,42,51,0.14)'; g.fill(p); g.restore();
+ g.fillStyle = fill; g.fill(p); g.lineWidth = lw; g.strokeStyle = C.ink; g.lineJoin = 'round'; g.stroke(p);
+}
+const popK = (lt, t0, d = 0.38, s = 2.2) => lt < t0 ? 0 : MO.backOut(clamp((lt - t0) / d), s); // 弹入(过冲)
+const outK = (lt, t0, d = 0.22) => MO.cubicIn(clamp((lt - t0) / d)); // 退场比入场快
+function at(g, x, y, k, fn, rot = 0) { if (k <= 0.001) return; g.save(); g.translate(x, y); g.rotate(rot); g.scale(k, k); fn(g); g.restore(); }
+function txt(g, s, x, y, size, { w = 'Heavy', col = C.ink, align = 'left', base = 'alphabetic' } = {}) {
+ g.font = F(size, w); g.fillStyle = col; g.textAlign = align; g.textBaseline = base; g.fillText(s, x, y);
+}
+// 手绘线:点列按 8fps 换种子抖一点(只给线稿沸腾,不整屏重洗)
+const boil = (lt, seed) => rng(seed * 977 + Math.floor(lt * 8 + 1e-6));
+function jitter(pts, r, amp) { return pts.map(([x, y]) => [x + (r() - 0.5) * 2 * amp, y + (r() - 0.5) * 2 * amp]); }
+function strokePart(g, pts, frac) { if (frac <= 0) return; const cum = DG.cum(pts); DG.drawPartial(g, pts, cum, cum[cum.length - 1] * clamp(frac)); }
+function spark(g, x, y, r, col = C.yel) { // 四角小闪光
+ g.save(); g.translate(x, y); g.fillStyle = col; g.strokeStyle = C.ink; g.lineWidth = 2.5; g.lineJoin = 'round';
+ g.beginPath(); for (let i = 0; i < 8; i++) { const a = i * Math.PI / 4 - Math.PI / 2, rr = i % 2 ? r * 0.38 : r; g.lineTo(Math.cos(a) * rr, Math.sin(a) * rr); }
+ g.closePath(); g.fill(); g.stroke(); g.restore();
+}
+
+// ---------- 背景:米白纸+淡点阵(缓存)+漂浮的手绘小涂鸦 ----------
+const bg = () => PAINT.cached('s11_bg', W, H, g => {
+ g.fillStyle = C.bg; g.fillRect(0, 0, W, H);
+ g.fillStyle = C.dot; for (let y = 30; y < H; y += 44) for (let x = 30; x < W; x += 44) { g.beginPath(); g.arc(x, y, 2.4, 0, TAU); g.fill(); }
+ const r = rng(1107); g.fillStyle = 'rgba(120,100,70,0.05)'; for (let i = 0; i < 2600; i++) g.fillRect(r() * W, r() * H, 2, 2);
+});
+const DOODLES = (() => { const r = rng(2611), pos = [[110, 120], [560, 90], [1860, 120], [1880, 420], [1860, 760], [640, 980], [1180, 1000], [1560, 990], [80, 520], [260, 60]];
+ return pos.map(([x, y], i) => ({ x, y, k: i % 4, s: 16 + r() * 12, ph: r() * TAU, col: [C.pink, C.yel, C.blue, C.teal][(i + 1) % 4] })); })();
+function doodles(g, lt) {
+ g.save(); g.lineWidth = 3.5; g.lineCap = 'round'; g.lineJoin = 'round';
+ for (const d of DOODLES) {
+ const x = d.x + 6 * Math.sin(lt * 0.9 + d.ph), y = d.y + 8 * Math.sin(lt * 1.3 + d.ph * 1.7), a = 0.35 * Math.sin(lt * 0.7 + d.ph);
+ g.save(); g.translate(x, y); g.rotate(a); g.globalAlpha = 0.55; g.strokeStyle = d.col; g.fillStyle = d.col; const s = d.s;
+ if (d.k === 0) { g.beginPath(); g.moveTo(-s, 0); g.lineTo(s, 0); g.moveTo(0, -s); g.lineTo(0, s); g.stroke(); }
+ else if (d.k === 1) { g.beginPath(); g.arc(0, 0, s * 0.7, 0, TAU); g.stroke(); }
+ else if (d.k === 2) { g.beginPath(); for (let i = 0; i <= 12; i++) g.lineTo(-s * 1.3 + i * s * 2.6 / 12, Math.sin(i * 1.3) * s * 0.35); g.stroke(); }
+ else { g.globalAlpha = 0.45; spark(g, 0, 0, s * 0.9, d.col); }
+ g.restore();
+ }
+ g.restore();
+}
+
+// ---------- 讲解员(AI 帧;代码只管位置、换帧、眨眼、点头、呼吸、挤压回弹) ----------
+// 姿势按口播换:收购→双手摊开展示;750亿美元→张开双臂比「这么多」(第三帧竖大拇指);史上最大→举手惊讶;
+// 星舰入轨→摊手指向地球;26颗→比数字;新一代星链卫星→摊手展示。其余时间指向信息图。
+const TALK = [1, 0, 1, 1, 0, 2, 2, 1, 0, 1, 2, 1];
+function speaking(lt) {
+ const s = TIMING.seg[ID];
+ for (let i = 0; i < s.text.length; i++) { if (',。、;'.includes(s.text[i])) continue; if (lt >= s.charStart[i] && lt < s.charEnd[i] + 0.05) return true; }
+ return false;
+}
+const env = lt => { let k = 0; for (let j = 0; j < 6; j++) k += speaking(lt - j * 0.03) ? 1 : 0; return k / 6; }; // 说话包络(防抖)
+let SCHED = null;
+const sched = () => SCHED || (SCHED = (() => { const Qv = q(); return [
+ [-9, 'point'], [Qv.sg - 0.06, 'present'], [Qv.jun - 0.04, 'point'], [Qv.n750 - 0.1, 'big'], [Qv.zd - 0.05, 'wow'], [Qv.ycE + 0.12, 'point'],
+ [Qv.rg - 0.06, 'present'], [TM.cue(ID, '26颗') - 0.06, 'count'], [Qv.xyd - 0.04, 'present']]; })());
+const ACC = () => { const Qv = q(); return [Qv.y26, Qv.sg, Qv.jun, Qv.mz, Qv.d928, Qv.rg, Qv.xyd]; }; // 点头的重音
+const BLINKS = (() => { const r = rng(1111), a = []; for (let t = 0.9; t < 13; t += 1.9 + r() * 1.4) a.push(t); return a; })();
+const PX = 330, PY = 902, PS = 0.74;
+const headClip = (m, w, cut) => { const p = new Path2D(); p.rect(-10, -10, w + 20, 238); p.rect(-10, 228, m.px + 70 + 10, cut - 228); return p; };
+function presenter(g, lt) {
+ const S = sched(); let k = 0; while (k + 1 < S.length && lt >= S[k + 1][0]) k++;
+ const pose = S[k][1], ts = S[k][0], m = POSES[pose];
+ const f = (fps) => Math.floor(lt * fps + 1e-6), e = env(lt);
+ let fi;
+ if (pose === 'wow') fi = [0, 1, 2, 1][f(8.5) % 4];
+ else if (pose === 'big') fi = [0, 1, 2, 2, 2, 1][f(6) % 6];
+ else if (pose === 'count') fi = [0, 1, 2][f(4) % 3];
+ else fi = e > 0.5 ? TALK[f(8.5) % TALK.length] : 0;
+ const blink = m.blink && BLINKS.some(b => lt >= b && lt < b + 0.12);
+ const im = window.IMG[blink ? m.src(fi).replace('.png', '_b.png') : m.src(fi)];
+ const en = popK(lt, 0.18, 0.45, 1.8), sq = MO.settle(lt - ts, 0.08, 3, 6);
+ const br = 1 + 0.014 * Math.sin(lt * TAU / 1.7), sway = 0.012 * Math.sin(lt * TAU / 2.6) + 0.01 * e * Math.sin(lt * TAU * 1.05);
+ const hop = -4 * e * Math.abs(Math.sin(lt * TAU * 1.05)); // 说话时身体轻轻一颠一颠
+ g.save(); g.fillStyle = 'rgba(43,42,51,0.13)'; g.beginPath(); g.ellipse(PX, PY + 4, 150 * en * (1 + 0.04 * hop / -4), 20 * en, 0, 0, TAU); g.fill(); g.restore();
+ if (en <= 0.001 || !im) return;
+ g.save(); g.translate(PX, PY + hop); g.rotate(sway); g.scale(PS * m.k * en * (1 - sq * 0.5), PS * m.k * en * (1 + sq) * br);
+ if (m.nod) {
+ let nod = 0.035 * e * Math.sin(lt * TAU * 2.1); for (const ta of ACC()) nod += MO.settle(lt - ta, 0.09, 2.2, 5);
+ const cut = m.py, W2 = im.width;
+ const body = new Path2D(); body.rect(-m.ax - 10, -m.ay - 10, W2 + 20, im.height + 20); body.addPath(headClip(m, W2, cut), new DOMMatrix().translate(-m.ax, -m.ay));
+ g.save(); g.clip(body, 'evenodd'); g.drawImage(im, -m.ax, -m.ay); g.restore(); // 身体(挖掉头部分块)
+ g.save(); g.translate(m.px - m.ax, cut - m.ay); g.rotate(nod); g.translate(0, 4 * Math.max(0, nod) / 0.09); g.translate(-m.px, -cut);
+ g.clip(headClip(m, W2, cut + 7)); g.drawImage(im, 0, 0); g.restore();
+ } else g.drawImage(im, -m.ax, -m.ay);
+ g.restore();
+}
+
+// ---------- 页眉「2026年」 ----------
+function header(g, lt) {
+ at(g, 790, 116, popK(lt, q().y26, 0.4), h => { card(h, -100, -32, 200, 64, { fill: C.red, r: 32, lw: 3.5, sh: 5 }); txt(h, '2026年', 0, 3, 38, { col: C.white, align: 'center', base: 'middle' }); },
+ 0.025 * Math.sin(lt * 1.7));
+}
+
+// ---------- 日历(6月 → 撕页 → 9月28号) ----------
+function calPage(g, top, big, col, unit) {
+ card(g, -110, -110, 220, 220, { r: 22 });
+ g.save(); g.clip(rrp(-110, -110, 220, 220, 22)); g.fillStyle = col; g.fillRect(-110, -110, 220, 64); g.restore();
+ g.lineWidth = 4; g.strokeStyle = C.ink; g.beginPath(); g.moveTo(-110, -46); g.lineTo(110, -46); g.stroke(); g.stroke(rrp(-110, -110, 220, 220, 22));
+ for (const x of [-56, 56]) { g.fillStyle = C.white; g.fill(rrp(x - 8, -128, 16, 36, 8)); g.stroke(rrp(x - 8, -128, 16, 36, 8)); }
+ txt(g, top, 0, -76, 34, { col: C.white, align: 'center', base: 'middle' });
+ if (unit) { txt(g, big, -14, 44, 104, { w: 'Black', align: 'center', base: 'middle' }); txt(g, unit, 62, 76, 34, { w: 'Bold', col: C.sub, align: 'center' }); }
+ else txt(g, big, 0, 44, 92, { w: 'Black', align: 'center', base: 'middle' });
+}
+function calendar(g, lt) {
+ const Qv = q(), k = popK(lt, Qv.jun, 0.42);
+ at(g, 810, 292, k, h => {
+ const fl = clamp((lt - Qv.d928) / 0.6);
+ if (fl > 0) calPage(h, '9月', '28', C.blue, '号');
+ if (fl < 1) { // 6月那页从左上角撕下、翻着落出画
+ const e = MO.cubicIn(fl); h.save(); h.translate(-100, -100); h.rotate(-e * 1.1); h.translate(100 - e * 60, 100 + e * e * 700);
+ h.globalAlpha = 1 - clamp((fl - 0.7) / 0.3); calPage(h, '2026', '6月', C.red); h.restore();
+ }
+ });
+}
+
+// ---------- 右上关键词框:「上市」→「星舰入轨」 ----------
+function upArrow(g, x, y, s) {
+ g.save(); g.translate(x, y); g.scale(s, s); g.lineWidth = 5; g.lineCap = 'round'; g.lineJoin = 'round'; g.strokeStyle = C.white;
+ g.beginPath(); g.moveTo(-18, 14); g.lineTo(-4, -2); g.lineTo(6, 8); g.lineTo(20, -12); g.stroke();
+ g.beginPath(); g.moveTo(8, -13); g.lineTo(21, -13); g.lineTo(21, 0); g.stroke(); g.restore();
+}
+function slot(g, lt) {
+ const Qv = q(), k1 = popK(lt, Qv.ss, 0.36), o1 = outK(lt, Qv.d928 - 0.12);
+ at(g, 950, 292, k1 * (1 - o1), h => { card(h, 0, -44, 200, 88, { fill: C.teal, r: 24 }); upArrow(h, 50, 0, 1.2); txt(h, '上市', 86, 3, 50, { col: C.white, base: 'middle' }); });
+ at(g, 950, 292, popK(lt, Qv.rg, 0.36), h => { card(h, 0, -44, 270, 88, { fill: C.blue, r: 24 }); txt(h, '星舰入轨', 135, 3, 50, { col: C.white, align: 'center', base: 'middle' }); });
+}
+
+// ---------- 屏①:收购 ----------
+function rocketIcon(g, x, y, s) { // 通用扁平小火箭(不画任何标识)
+ g.save(); g.translate(x, y); g.scale(s, s); g.lineWidth = 3.5; g.strokeStyle = C.ink; g.lineJoin = 'round';
+ const fin = (d) => { g.beginPath(); g.moveTo(d * 13, 10); g.lineTo(d * 30, 30); g.lineTo(d * 30, 40); g.lineTo(d * 13, 32); g.closePath(); g.fillStyle = C.red; g.fill(); g.stroke(); };
+ fin(-1); fin(1);
+ g.beginPath(); g.moveTo(0, -46); g.bezierCurveTo(22, -28, 16, 20, 13, 36); g.lineTo(-13, 36); g.bezierCurveTo(-16, 20, -22, -28, 0, -46); g.closePath(); g.fillStyle = C.steel; g.fill(); g.stroke();
+ g.beginPath(); g.arc(0, -8, 8, 0, TAU); g.fillStyle = C.blue; g.fill(); g.stroke();
+ g.restore();
+}
+function chipIcon(g, x, y, s) { // 通用 AI 芯片图标
+ g.save(); g.translate(x, y); g.scale(s, s); g.lineWidth = 3.5; g.strokeStyle = C.ink; g.lineCap = 'round';
+ for (let i = -1; i <= 1; i++) { g.beginPath(); g.moveTo(i * 14, -34); g.lineTo(i * 14, -42); g.moveTo(i * 14, 34); g.lineTo(i * 14, 42); g.moveTo(-34, i * 14); g.lineTo(-42, i * 14); g.moveTo(34, i * 14); g.lineTo(42, i * 14); g.stroke(); }
+ card(g, -32, -32, 64, 64, { fill: C.purple, r: 12, lw: 3.5, sh: 0 });
+ txt(g, 'AI', 0, 2, 28, { w: 'Black', col: C.white, align: 'center', base: 'middle' }); g.restore();
+}
+function handArrow(g, lt, x0, y0, x1, y1, p, seed) {
+ if (p <= 0) return;
+ const r = boil(lt, seed), n = 16, pts = [];
+ for (let i = 0; i <= n; i++) { const u = i / n; pts.push([lerp(x0, x1, u), lerp(y0, y1, u) - Math.sin(Math.PI * u) * 26]); }
+ const jp = jitter(pts, r, 1.6);
+ g.save(); g.strokeStyle = C.ink; g.lineWidth = 7; g.lineCap = 'round'; g.lineJoin = 'round';
+ strokePart(g, jp, p);
+ if (p > 0.85) { const hk = clamp((p - 0.85) / 0.15), e = jp[n], a = Math.atan2(jp[n][1] - jp[n - 2][1], jp[n][0] - jp[n - 2][0]);
+ g.beginPath(); for (const d of [-1, 1]) { g.moveTo(e[0], e[1]); g.lineTo(e[0] - Math.cos(a + d * 0.6) * 34 * hk, e[1] - Math.sin(a + d * 0.6) * 34 * hk); } g.stroke(); }
+ g.restore();
+}
+function panelA(g, lt) {
+ const Qv = q(), out = outK(lt, Qv.jun + 0.4, 0.25); if (out >= 1) return;
+ g.save(); g.globalAlpha = 1 - out; g.translate(0, -50 * out);
+ const sw = MO.cubicInOut(clamp((lt - (Qv.xai + 0.06)) / 0.42)); // 吞并进度
+ g.save(); g.globalAlpha *= 1 - sw; handArrow(g, lt, 1070, 545, 1392, 545, MO.cubicOut(clamp((lt - Qv.sg) / 0.4)), 11); g.restore();
+ at(g, 1231, 452, popK(lt, Qv.sg, 0.35), h => { card(h, -78, -34, 156, 68, { fill: C.yel, r: 20, lw: 3.5, sh: 5 }); txt(h, '收购', 0, 3, 42, { align: 'center', base: 'middle' }); });
+ if (sw < 1) { // xAI 卡:被拖进 SpaceX 卡、缩小消失(画在它后面)
+ const cx = lerp(1610, 870, sw), cy = 545 - Math.sin(Math.PI * sw) * 70, sc = lerp(1, 0.12, MO.cubicIn(sw));
+ at(g, cx, cy, popK(lt, Qv.msk, 0.4) * sc, h => {
+ card(h, -190, -115, 380, 230); chipIcon(h, 0, -48, 0.8);
+ txt(h, 'xAI', 0, 46, 62, { align: 'center' }); txt(h, '马斯克的AI公司', 0, 92, 32, { w: 'Bold', col: C.sub, align: 'center' });
+ }, -0.5 * sw);
+ }
+ const gulp = MO.settle(lt - (Qv.xai + 0.46), 0.09, 3, 6);
+ at(g, 870, 545, popK(lt, Qv.spx, 0.4) * (1 + gulp), h => {
+ card(h, -170, -115, 340, 230); rocketIcon(h, 0, -44, 1);
+ txt(h, 'SpaceX', 0, 80, 60, { align: 'center' });
+ at(h, 150, -112, popK(lt, Qv.xai + 0.46, 0.35, 2.6), b => { card(b, -66, -26, 132, 52, { fill: C.purple, r: 26, lw: 3.5, sh: 4 }); txt(b, '+ xAI', 0, 2, 32, { col: C.white, align: 'center', base: 'middle' }); }, 0.12);
+ });
+ g.restore();
+}
+
+// ---------- 屏②:上市募资 ----------
+const STACKS = [{ x: 1562, n: 12 }, { x: 1662, n: 18 }, { x: 1762, n: 15 }], CB = 712, CT = 11;
+function coin(g, x, y) {
+ g.lineWidth = 2.5; g.strokeStyle = C.ink;
+ g.beginPath(); g.ellipse(x, y, 42, 13, 0, 0, Math.PI); g.lineTo(x - 42, y - CT); g.ellipse(x, y - CT, 42, 13, 0, Math.PI, 0, true); g.closePath(); g.fillStyle = C.goldD; g.fill(); g.stroke();
+ g.beginPath(); g.ellipse(x, y - CT, 42, 13, 0, 0, TAU); g.fillStyle = C.gold; g.fill(); g.stroke();
+ g.beginPath(); g.ellipse(x, y - CT, 26, 7, 0, 0, TAU); g.strokeStyle = 'rgba(43,42,51,0.35)'; g.lineWidth = 2; g.stroke();
+}
+function coins(g, lt, cp) {
+ for (const [si, s] of STACKS.entries()) {
+ const f = s.n * cp, n = Math.floor(f + 1e-6), fr = f - n;
+ for (let i = 0; i < n; i++) coin(g, s.x, CB - i * CT);
+ if (fr > 0.02) { g.save(); g.globalAlpha = clamp(fr * 3); coin(g, s.x, CB - n * CT - (1 - MO.cubicOut(fr)) * 90); g.restore(); }
+ if (cp > 0.98) { // 母题:顶上的金币轮流闪一下
+ const ph = (lt * 0.9 + si * 0.37) % 1; if (ph < 0.3) spark(g, s.x + 22, CB - s.n * CT - 14, 14 * Math.sin(Math.PI * ph / 0.3), C.white);
+ }
+ }
+}
+function ringPts(cx, cy, rx, ry, seed) { // 手绘圈(圆角方的超椭圆,贴着字框):起笔收笔不闭合,略多绕一点
+ const r = rng(seed), pts = [], a0 = -2.5, n = 72, sp = (v) => Math.sign(v) * Math.pow(Math.abs(v), 0.5);
+ for (let i = 0; i <= n; i++) { const u = i / n, a = a0 + u * TAU * 1.08, k = 1 + 0.025 * Math.sin(u * 9 + r() * 0.3) + 0.035 * u; pts.push([cx + sp(Math.cos(a)) * rx * k, cy + sp(Math.sin(a)) * ry * k]); }
+ return pts;
+}
+const RING = ringPts(1058, 622, 420, 108, 7);
+function panelB(g, lt) {
+ const Qv = q(); if (lt < Qv.mz - 0.02) return; const out = outK(lt, Qv.d928 - 0.12, 0.25); if (out >= 1) return;
+ g.save(); g.globalAlpha = 1 - out; g.translate(0, 50 * out);
+ const a1 = MO.expoOut(clamp((lt - Qv.mz) / 0.35));
+ g.save(); g.globalAlpha *= a1; txt(g, '募资超过', 724, 496 + 24 * (1 - a1), 50, { w: 'Bold', col: C.sub }); g.restore();
+ const c0 = Qv.mz + 0.08, c1 = Qv.n750 + 0.42, cp = MO.expoOut(clamp((lt - c0) / (c1 - c0)));
+ const v = Math.round(750 * cp), nk = popK(lt, c0, 0.35);
+ // 史上最大:荧光笔先刷在字后面
+ const hk = MO.cubicOut(clamp((lt - Qv.zd - 0.12) / 0.32));
+ if (hk > 0) { const r = rng(31); g.fillStyle = C.hl; g.beginPath(); g.moveTo(708, 796 + r() * 4);
+ const x1 = 708 + 600 * hk; g.lineTo(x1, 790 + r() * 4); g.lineTo(x1 - 6, 858); g.lineTo(712, 862); g.closePath(); g.fill(); }
+ at(g, 1110, 700, nk, h => { txt(h, String(v), 0, 0, 230, { w: 'Black', col: C.red, align: 'right' }); txt(h, '亿美元', 22, 0, 92); });
+ coins(g, lt, cp);
+ const bp = popK(lt, Qv.zd + 0.05, 0.36);
+ at(g, 720, 840, bp, h => txt(h, '史上最大的一次上市', 0, 0, 62));
+ const rp = clamp((lt - Qv.zd) / 0.42);
+ if (rp > 0) { g.save(); g.strokeStyle = C.red; g.lineWidth = 8; g.lineCap = 'round'; g.lineJoin = 'round'; strokePart(g, jitter(RING, boil(lt, 5), 2.2), MO.cubicOut(rp)); g.restore();
+ if (rp >= 1) for (const [i, [x, y]] of [[640, 520], [1490, 512], [1500, 735]].entries()) { const ph = (lt * 1.6 + i * 0.33) % 1; spark(g, x, y, 20 * (0.6 + 0.4 * Math.sin(ph * TAU)), C.yel); } }
+ g.restore();
+}
+
+// ---------- 屏③:星舰入轨+26 颗卫星 ----------
+const EX = 1040, EY = 650, ER = 135, RX = 300, RY = 92, TILT = -0.14, CT_ = Math.cos(TILT), ST_ = Math.sin(TILT), OMEGA = TAU / 2.0;
+const orbitAt = th => { const x = RX * Math.cos(th), y = RY * Math.sin(th); return [EX + x * CT_ - y * ST_, EY + x * ST_ + y * CT_]; };
+const orbitVel = th => { const x = -RX * Math.sin(th), y = RY * Math.cos(th); return [x * CT_ - y * ST_, x * ST_ + y * CT_]; };
+const SHIP = RK.ship(), SHIP_S = 1.75;
+const TH0 = Math.PI;
+function shipState(lt) { // → {x, y, rot, s, th, front, launching}
+ const Qv = q(), tL = Qv.d928 + 0.6, tR = Qv.rg;
+ if (lt < tR) {
+ const e = MO.cubicInOut(clamp((lt - tL) / (tR - tL))), [ox, oy] = orbitAt(TH0), dx = ox - EX, dy = oy - EY, dl = Math.hypot(dx, dy);
+ const sx = EX + dx / dl * ER * 0.8, sy = EY + dy / dl * ER * 0.8, [vx, vy] = orbitVel(TH0);
+ const aOut = Math.atan2(dy, dx) + Math.PI / 2, aTan = Math.atan2(vy, vx) + Math.PI / 2;
+ return { x: lerp(sx, ox, e), y: lerp(sy, oy, e), rot: lerp(aOut, aTan, MO.smooth(e)), s: lerp(0.55, 1, e), th: TH0, front: e > 0.6, launching: lt >= tL, burn: 1 };
+ }
+ const th = TH0 + OMEGA * (lt - tR), [x, y] = orbitAt(th), [vx, vy] = orbitVel(th);
+ return { x, y, rot: Math.atan2(vy, vx) + Math.PI / 2, s: 1, th, front: Math.sin(th) > 0, launching: true, burn: clamp(1 - (lt - tR) / 0.4) };
+}
+function drawShip(g, st, lt) {
+ if (!st.launching) return;
+ const s = SHIP_S * st.s;
+ RK.at(g, st.x, st.y, s, st.rot, h => {
+ h.scale(1.45, 1); h.translate(0, 26); // 以箭体中部为旋转中心
+ if (st.burn > 0) RK.flame(h, 0, 2, 22 * st.burn, 8, lt, ['rgba(255,159,67,0.9)', 'rgba(255,212,71,0.95)', '#FFF6D8']);
+ h.lineJoin = 'round';
+ for (const p of SHIP.parts) { h.fillStyle = p.k === 'tiles' || p.k === 'flap' || p.k === 'engine' ? C.tile : C.steel; h.fill(p.p); }
+ h.lineWidth = 2.6 / s; h.strokeStyle = C.ink; for (const p of SHIP.parts) if (p.k !== 'tiles') h.stroke(p.p);
+ });
+}
+// 地球:海+陆块贴图横向循环(取模周期=贴图宽)
+const LANDW = ER * 4;
+const landTex = () => PAINT.cached('s11_land', LANDW, ER * 2, g => {
+ const r = rng(4242); g.lineWidth = 3; g.strokeStyle = C.ink; g.fillStyle = C.land; g.lineJoin = 'round';
+ const blobs = [[60, 80, 46], [190, 150, 60], [300, 70, 38], [420, 190, 52], [500, 110, 40], [130, 230, 30], [350, 250, 34]];
+ for (const [bx, by, br] of blobs) for (const off of [-LANDW, 0, LANDW]) {
+ g.beginPath(); for (let i = 0; i <= 24; i++) { const a = i / 24 * TAU, rr = br * (1 + 0.22 * Math.sin(a * 3 + bx) + 0.12 * Math.sin(a * 5 + by)); g.lineTo(bx + off + Math.cos(a) * rr, by + Math.sin(a) * rr * 0.8); }
+ g.closePath(); g.fill(); g.stroke();
+ }
+});
+function earth(g, lt, k) {
+ at(g, EX, EY, k, h => {
+ h.save(); h.beginPath(); h.arc(0, 0, ER, 0, TAU); h.fillStyle = C.sea; h.fill(); h.clip();
+ const off = (lt * 34) % LANDW, tex = landTex();
+ h.drawImage(tex, -ER - off, -ER); h.drawImage(tex, -ER - off + LANDW, -ER);
+ h.fillStyle = 'rgba(43,62,120,0.16)'; h.beginPath(); h.arc(ER * 0.35, ER * 0.15, ER * 1.05, 0, TAU); h.arc(-ER * 0.2, -ER * 0.1, ER * 1.1, 0, TAU, true); h.fill('evenodd');
+ h.restore();
+ h.lineWidth = 4.5; h.strokeStyle = C.ink; h.beginPath(); h.arc(0, 0, ER, 0, TAU); h.stroke();
+ h.fillStyle = 'rgba(255,255,255,0.55)'; h.beginPath(); h.ellipse(-ER * 0.48, -ER * 0.5, 22, 11, -0.7, 0, TAU); h.fill();
+ });
+}
+function orbitLine(g, lt, p, half) { // half: 'back' 上半(地球后)/ 'front' 下半
+ if (p <= 0) return;
+ g.save(); g.strokeStyle = C.ink; g.globalAlpha = half === 'back' ? 0.35 : 0.6; g.lineWidth = 3.5; g.setLineDash([14, 12]); g.lineDashOffset = -lt * 40; g.lineCap = 'round';
+ g.beginPath(); const a0 = half === 'back' ? Math.PI : 0, n = 40;
+ for (let i = 0; i <= n; i++) { const u = i / n; if (u > p) break; const [x, y] = orbitAt(a0 + u * Math.PI); i ? g.lineTo(x, y) : g.moveTo(x, y); }
+ g.stroke(); g.restore();
+}
+function sat(g, x, y, k, tw) { // 扁平小卫星:机身+两块太阳能板+小天线
+ if (k <= 0.001) return;
+ g.save(); g.translate(x, y); g.scale(k, k); g.lineWidth = 2.5; g.strokeStyle = C.ink; g.lineJoin = 'round'; g.lineCap = 'round';
+ g.beginPath(); g.moveTo(0, -10); g.lineTo(0, -17); g.stroke(); g.fillStyle = C.red; g.beginPath(); g.arc(0, -18, 3, 0, TAU); g.fill(); g.stroke();
+ for (const d of [-1, 1]) { const x0 = d < 0 ? -22 : 10; g.fillStyle = C.blue; g.fill(rrp(x0, -8, 12, 16, 2)); g.stroke(rrp(x0, -8, 12, 16, 2));
+ g.beginPath(); g.moveTo(x0, 0); g.lineTo(x0 + 12, 0); g.stroke(); }
+ g.fillStyle = C.steel; g.fill(rrp(-10, -10, 20, 20, 5)); g.stroke(rrp(-10, -10, 20, 20, 5));
+ if (tw > 0) spark(g, 15, -15, 9 * tw, C.white);
+ g.restore();
+}
+const NS = 26, emitT = i => q().fc + 0.1 + i * 0.038;
+const slotXY = i => [990 + (i % 13) * 66, 398 + Math.floor(i / 13) * 66];
+function panelC(g, lt) {
+ const Qv = q(); if (lt < Qv.d928) return;
+ const ek = popK(lt, Qv.d928 + 0.1, 0.45, 1.8), op = MO.cubicOut(clamp((lt - (Qv.d928 + 0.45)) / 0.55)), st = shipState(lt);
+ orbitLine(g, lt, op, 'back');
+ if (!st.front) drawShip(g, st, lt);
+ earth(g, lt, ek);
+ orbitLine(g, lt, op, 'front');
+ if (st.front) drawShip(g, st, lt);
+ // 26 颗卫星:从飞船当时的位置弹出,沿弧线飞到右上两排
+ let n = 0;
+ for (let i = 0; i < NS; i++) {
+ const te = emitT(i); if (lt < te) continue; n++;
+ const u = clamp((lt - te) / 0.5), e = MO.quintOut(u), s0 = shipState(te), [x1, y1] = slotXY(i);
+ const cx = (s0.x + x1) / 2 + 40, cy = Math.min(s0.y, y1) - 140;
+ const x = (1 - e) * (1 - e) * s0.x + 2 * (1 - e) * e * cx + e * e * x1, y = (1 - e) * (1 - e) * s0.y + 2 * (1 - e) * e * cy + e * e * y1;
+ const bob = u >= 1 ? 2.5 * Math.sin(lt * 3 + i * 0.7) : 0, ph = (lt * 0.8 + i * 0.137) % 1;
+ sat(g, x, y + bob, 1.22 * lerp(0.4, 1, MO.backOut(clamp(u * 1.6), 2)), u >= 1 && ph < 0.12 ? Math.sin(Math.PI * ph / 0.12) : 0);
+ }
+ // 计数:每弹出一颗加一,最后一颗落在「26颗」念完时
+ if (lt >= emitT(0)) at(g, 1640, 690, popK(lt, emitT(0), 0.3), h => { txt(h, String(n), 0, 0, 180, { w: 'Black', col: C.blue, align: 'right' }); txt(h, '颗', 14, 0, 76); });
+ at(g, 1450, 775, popK(lt, Qv.xyd, 0.36), h => { card(h, 0, -40, 360, 80, { fill: C.yel, r: 22, lw: 3.5, sh: 5 }); txt(h, '新一代星链卫星', 180, 3, 44, { align: 'center', base: 'middle' }); });
+}
+
+SCENES[ID] = {
+ init() {
+ U.assertGlyphs('PuHui-Heavy', '2026年收购上市亿美元史上最大的一次星舰入轨颗新一代星链卫星SpaceX+xAI6月9月28号0123456789', ID);
+ U.assertGlyphs('PuHui-Bold', '马斯克的AI公司募资超过号', ID);
+ U.assertGlyphs('PuHui-Black', '0123456789AI月', ID);
+ for (const k of ALLFR) if (!window.IMG[k]) console.error(`s11 讲解员帧没加载:${k}`);
+ },
+ draw(c, lt) {
+ c.drawImage(bg(), 0, 0);
+ doodles(c, lt);
+ panelA(c, lt); panelB(c, lt); panelC(c, lt);
+ calendar(c, lt); slot(c, lt); header(c, lt);
+ presenter(c, lt);
+ },
+};
+ERAS.find(e => e.id === ID).transition = { type: 'cardFlip', dur: 0.6, bg: C.bg };
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex/scenes/s12.js b/scripts/engine/reference_films/spacex/spacex/scenes/s12.js
new file mode 100644
index 0000000..9d86fa9
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex/scenes/s12.js
@@ -0,0 +1,294 @@
+// S12 · 新海诚光影(片尾)——「接下来,它要用筷子夹住飞船,在太空里加油,争取把美国人重新送上月球。再往后,是火星。」
+// 风格卡 35_shinkai:积雨云(剪影+偏向太阳的亮球+糊/清两层)、丁达尔光柱、赛璐珞硬阴影带+受光亮边、光尘、镜头光晕、泛光、冷暖分离。
+// 这里是天空外景,一条竖长的世界画布,镜头只往上摇(只进不退):
+// A 夕光里的发射塔:星舰飞船剪影沿虚线落向张开的「筷子」,虚线轮廓=预演(未来时,不画成新闻画面)→「夹住」合拢、接驳点闪光
+// B「在太空里加油」:高空两艘星舰并排,一条细光线连起来,光点沿线流过去
+// C「月球」:镜头上摇到月亮,星舰尾迹弧线从左下划向它
+// D「火星」:月亮右上更远处,一颗小红星点亮;片尾 1.8s 停在这里,天色慢慢压暗一点(不黑屏、无署名)
+SCENES['s12'] = (() => {
+ const ID = 's12', W = 1920, H = 1080, { clamp, lerp, ss, ease, rng } = U, P = PAINT;
+ const cue = k => TM.cue(ID, k), DUR = TM.dur(ID), VO = TM.vo(ID);
+ const T_KZ = cue('筷子'), T_JZ = cue('夹住'), T_TK = cue('在太空里'), T_JY = cue('加油'), T_ZQ = cue('争取'), T_YQ = cue('月球'), T_ZWH = cue('再往后'), T_HX = cue('火星');
+ // ---------- 镜头:只往上摇 ----------
+ const OY1 = 720, OY2 = 1470;
+ function camAt(lt) {
+ let oy = lerp(0, OY1, ease.inOut(ss(T_TK - 0.2, T_JY + 0.05, lt)));
+ oy += (OY2 - OY1) * ease.inOut(ss(T_ZQ + 0.1, T_YQ - 0.15, lt));
+ oy += 26 * ss(T_YQ, DUR, lt); // 停留段也在极慢地上浮
+ const ox = -70 * ease.inOut(ss(T_ZWH - 0.2, T_HX + 0.4, lt)); //「再往后」轻轻右移,把火星让进来
+ return { ox, oy };
+ }
+ // ---------- 世界坐标里的东西 ----------
+ const SUN = [960, 900];
+ const TW = { x: 1560, base: 1100, pxm: 6.4, armY: 95 };
+ const SHIP_CATCH = TW.armY + 0.8 - 38; // 飞船接住时底部高度(m):接驳点在前襟翼下方约 38m
+ const SHIPX = TW.x - 16 * TW.pxm;
+ const MOON = [1236, -1110], MR = 148, MARS = [1650, -1335];
+ const TRAIL = [[210, -110], [300, -780], [780, -1210], [1076, -1124]];
+ // 天空:世界 y → 颜色(地平线金→粉→紫→蓝→深靛)
+ const SKY = [[1100, '#ffd28a'], [930, '#ffae7c'], [720, '#f08c98'], [470, '#a77cc4'], [160, '#5d6fd0'], [-350, '#3550b4'], [-850, '#253684'], [-1700, '#151b52']];
+
+ // 积雨云团(种子):左侧主塔+右下低云
+ // g:所属云团(0 主塔、1 右下低云、2 左下低云),用来算「这一团朝不朝太阳」
+ const GC = [[400, 640], [1500, 1000], [100, 1020]];
+ const BLOBS = (() => { const r = rng(1212), out = [];
+ for (let i = 0; i < 170; i++) { const h = Math.pow(r(), 0.75), y = 1100 - h * 820, w = h > 0.84 ? 620 : lerp(760, 420, h); out.push({ g: 0, h, x: 380 + (r() - 0.5) * w + h * 90 + (h > 0.84 ? 150 : 0), y: y + (r() - 0.5) * 40, r: lerp(118, 52, h) * (0.6 + r() * 0.7), ph: r() * 6 }); }
+ for (let i = 0; i < 30; i++) out.push({ g: 1, h: 0.2, x: 1220 + r() * 760, y: 960 + r() * 110, r: 30 + r() * 40, ph: r() * 6 });
+ for (let i = 0; i < 12; i++) out.push({ g: 2, h: 0.2, x: -40 + r() * 280, y: 1000 + r() * 80, r: 40 + r() * 36, ph: r() * 6 });
+ return out.sort((a, b) => b.y - a.y); })();
+ const STARS = (() => { const r = rng(77), out = []; for (let i = 0; i < 260; i++) out.push([r() * W * 1.1 - 40, -1720 + r() * 1900, 0.6 + r() * 1.6, r() * 6]); return out; })();
+
+ function skyFill(c, cam) {
+ const g = c.createLinearGradient(0, SKY[SKY.length - 1][0] + cam.oy, 0, SKY[0][0] + cam.oy);
+ const y0 = SKY[SKY.length - 1][0], y1 = SKY[0][0];
+ SKY.forEach(([y, col]) => g.addColorStop((y - y0) / (y1 - y0), col));
+ c.fillStyle = g; c.fillRect(0, 0, W, H);
+ // 太阳周围的大光晕(暖白)
+ const sx = SUN[0] + cam.ox, sy = SUN[1] + cam.oy;
+ if (sy < 1700) { const sg = c.createRadialGradient(sx, sy, 0, sx, sy, 900); sg.addColorStop(0, 'rgba(255,248,225,.95)'); sg.addColorStop(0.12, 'rgba(255,226,170,.55)'); sg.addColorStop(0.45, 'rgba(255,170,140,.18)'); sg.addColorStop(1, 'rgba(255,160,140,0)'); c.fillStyle = sg; c.fillRect(0, 0, W, H); }
+ }
+ function stars(c, cam, t) {
+ for (const [x, y, s, ph] of STARS) { const sy = y + cam.oy, sx = x + cam.ox; if (sy < -10 || sy > H + 10) continue;
+ const a = ss(-60, -800, y) * (0.55 + 0.45 * Math.sin(t * (2 + ph) + ph * 3)); if (a < 0.03) continue;
+ c.fillStyle = `rgba(255,250,235,${a})`; c.beginPath(); c.arc(sx, sy, s, 0, 7); c.fill(); }
+ }
+ // 丁达尔光柱:从太阳往上扇开的楔形(缓存,糊 22px),screen 叠,明灭
+ const RAYS = () => P.cached('s12_rays', W, 1700, (g) => {
+ g.filter = 'blur(22px)'; const sx = SUN[0], sy = 1200;
+ [[-2.35, 0.07, .30], [-2.05, 0.05, .22], [-1.82, 0.09, .34], [-1.55, 0.05, .26], [-1.3, 0.08, .3], [-1.02, 0.05, .22], [-0.78, 0.06, .2]].forEach(([a, w, al]) => {
+ const L = 1500, g2 = g.createLinearGradient(sx, sy, sx + Math.cos(a) * L, sy + Math.sin(a) * L); g2.addColorStop(0, `rgba(255,236,200,${al})`); g2.addColorStop(1, 'rgba(255,236,200,0)');
+ g.fillStyle = g2; g.beginPath(); g.moveTo(sx, sy); g.lineTo(sx + Math.cos(a - w) * L, sy + Math.sin(a - w) * L); g.lineTo(sx + Math.cos(a + w) * L, sy + Math.sin(a + w) * L); g.closePath(); g.fill(); });
+ });
+ function rays(c, cam, t) {
+ const top = SUN[1] - 1200 + cam.oy; if (top > H) return;
+ c.save(); c.globalCompositeOperation = 'screen'; c.globalAlpha = 0.8 + 0.2 * Math.sin(t * 2.6); c.drawImage(RAYS(), cam.ox * 0.5, SUN[1] - 1200 + cam.oy); c.restore();
+ }
+ // 高空卷云:被夕阳从下面照亮的粉色细丝
+ const CIRRUS = () => P.cached('s12_cirrus', W + 400, 520, (g) => {
+ const r = rng(404); g.filter = 'blur(2.5px)';
+ for (let i = 0; i < 46; i++) { const x = r() * (W + 400), y = 60 + r() * 400, L = 160 + r() * 420, h = 4 + r() * 10, a = 0.12 + r() * 0.28;
+ const lg = g.createLinearGradient(x - L / 2, 0, x + L / 2, 0); lg.addColorStop(0, 'rgba(255,190,200,0)'); lg.addColorStop(0.5, `rgba(255,${200 + (r() * 40 | 0)},${200 + (r() * 30 | 0)},${a})`); lg.addColorStop(1, 'rgba(255,190,200,0)');
+ g.fillStyle = lg; g.beginPath(); g.ellipse(x, y, L / 2, h, -0.06, 0, 7); g.fill(); }
+ });
+ function cirrus(c, cam, lt) { const y = -520 + cam.oy; if (y > H || y + 520 < 0) return; c.save(); c.globalAlpha = 0.9; c.drawImage(CIRRUS(), -200 + cam.ox - (lt * 12) % 200, y); c.restore(); }
+ // 高积云:一片片小云,暗紫剪影+上缘受光(source-atop 只亮在云上),慢漂
+ const ALTO = () => P.cached('s12_alto', W + 600, 280, (g) => {
+ const r = rng(515);
+ for (let k = 0; k < 16; k++) { const cx = 60 + k * 150 + r() * 80, cy = 120 + (r() - 0.5) * 120, s = 0.6 + r() * 0.7, bl = [];
+ for (let i = 0; i < 6; i++) bl.push([cx + (i - 2.5) * 22 * s + (r() - 0.5) * 10, cy - Math.sin(i / 5 * Math.PI) * 18 * s + (r() - 0.5) * 8, (16 + r() * 14) * s]);
+ g.globalCompositeOperation = 'source-over'; g.fillStyle = '#6f66ad'; g.beginPath(); bl.forEach(([x, y, rr]) => { g.moveTo(x + rr, y); g.arc(x, y, rr, 0, 7); }); g.fill();
+ g.globalCompositeOperation = 'source-atop'; g.fillStyle = '#e9def6'; g.beginPath(); bl.forEach(([x, y, rr]) => { g.moveTo(x + rr * 0.85, y - rr * 0.32); g.arc(x, y - rr * 0.32, rr * 0.85, 0, 7); }); g.fill(); }
+ });
+ function alto(c, cam, lt) { const y = -720 + cam.oy; if (y > H || y + 280 < 0) return; c.save(); c.globalAlpha = 0.85; c.drawImage(ALTO(), -300 + cam.ox + lt * 10, y); c.restore(); }
+ // 月亮(缓存精灵):冷白圆盘+淡淡的月海+清晰边,外面一圈晕
+ const MOONIMG = () => P.cached('s12_moon', 520, 520, (g) => {
+ const cx = 260, cy = 260;
+ const halo = g.createRadialGradient(cx, cy, MR * 0.9, cx, cy, 255); halo.addColorStop(0, 'rgba(255,244,220,.32)'); halo.addColorStop(1, 'rgba(255,244,220,0)'); g.fillStyle = halo; g.fillRect(0, 0, 520, 520);
+ const d = g.createRadialGradient(cx - 30, cy - 34, 10, cx, cy, MR); d.addColorStop(0, '#fffdf6'); d.addColorStop(0.75, '#fbf1da'); d.addColorStop(1, '#ecdcb8'); g.fillStyle = d; g.beginPath(); g.arc(cx, cy, MR, 0, 7); g.fill();
+ g.save(); g.beginPath(); g.arc(cx, cy, MR, 0, 7); g.clip(); g.filter = 'blur(3px)';
+ [[-34, -30, 36, 26], [12, -40, 26, 20], [30, 6, 34, 30], [-18, 22, 22, 16], [-52, 10, 16, 22], [46, 50, 18, 12]].forEach(([dx, dy, rx, ry]) => { g.fillStyle = 'rgba(205,190,165,.42)'; g.beginPath(); g.ellipse(cx + dx, cy + dy, rx, ry, 0.4, 0, 7); g.fill(); });
+ g.filter = 'none'; g.fillStyle = 'rgba(150,140,190,.09)'; g.beginPath(); g.arc(cx + 34, cy + 30, MR, 0, 7); g.fill(); // 背光一侧冷影(赛璐珞式硬边)
+ g.restore();
+ g.strokeStyle = 'rgba(255,255,250,.85)'; g.lineWidth = 2; g.beginPath(); g.arc(cx, cy, MR - 1, Math.PI * 0.75, Math.PI * 1.6); g.stroke();
+ });
+ function moon(c, cam, t) { const x = MOON[0] + cam.ox, y = MOON[1] + cam.oy; if (y < -400 || y > H + 400) return; c.drawImage(MOONIMG(), x - 260, y - 260); }
+ function mars(c, cam, lt, t) {
+ const a = ease.out(ss(T_HX - 0.12, T_HX + 0.3, lt)); if (a <= 0) return;
+ const x = MARS[0] + cam.ox, y = MARS[1] + cam.oy, pulse = 1 + 0.12 * Math.sin(t * 3.1);
+ c.save(); c.globalCompositeOperation = 'lighter';
+ const gl = c.createRadialGradient(x, y, 0, x, y, 95 * pulse); gl.addColorStop(0, `rgba(255,120,80,${0.85 * a})`); gl.addColorStop(0.3, `rgba(255,80,60,${0.32 * a})`); gl.addColorStop(1, 'rgba(255,80,60,0)'); c.fillStyle = gl; c.fillRect(x - 100, y - 100, 200, 200);
+ // 点亮那一下的十字星芒,慢慢收成常亮
+ const fl = a * (0.35 + 0.65 * (1 - ss(T_HX + 0.2, T_HX + 1.4, lt))) * (0.85 + 0.15 * Math.sin(t * 5));
+ c.strokeStyle = `rgba(255,190,160,${0.7 * fl})`; c.lineWidth = 1.6;
+ for (let k = 0; k < 4; k++) { const ang = k * Math.PI / 2 + 0.2 + t * 0.15, L = (k % 2 ? 36 : 62) * (0.6 + fl); c.beginPath(); c.moveTo(x, y); c.lineTo(x + Math.cos(ang) * L, y + Math.sin(ang) * L); c.stroke(); }
+ c.restore();
+ c.fillStyle = `rgba(240,86,56,${a})`; c.beginPath(); c.arc(x, y, 12 * (0.6 + 0.4 * a), 0, 7); c.fill();
+ c.fillStyle = `rgba(255,205,175,${a})`; c.beginPath(); c.arc(x - 3, y - 3, 4, 0, 7); c.fill();
+ }
+ // 积雨云:35 号的「剪影+偏向太阳的亮球」改成赛璐珞三调——一团团圆的并集当剪影(暗紫平涂),
+ // 朝阳的团块往太阳方向平移、缩小后的并集=亮面(暖色),再平移一次=高光;亮面只留在剪影里(destination-in)。边缘是硬的,所以不像肥皂泡。
+ BLOBS.forEach(b => { const [gx, gy] = GC[b.g], vx = b.x - gx, vy = b.y - gy, vl = Math.hypot(vx, vy) || 1, sxg = SUN[0] - gx, syg = SUN[1] - gy, sl = Math.hypot(sxg, syg) || 1;
+ const face = (vx * sxg + vy * syg) / vl / sl; b.lit = clamp(0.15 + 0.9 * Math.max(0, face) * Math.min(1, vl / 150) + 0.7 * Math.max(0, b.h - 0.6)); });
+ function clouds(c, cam, lt, t) {
+ if (cam.oy > 1180) return;
+ const S = P.scratch('s12CloudS'), g = S.getContext('2d'); g.reset();
+ const L = P.scratch('s12CloudL'), l = L.getContext('2d'); l.reset();
+ const at = b => [b.x + lt * 7 + cam.ox, b.y + cam.oy - Math.sin(t * 0.8 + b.ph) * 3, b.r * (1 + 0.05 * Math.sin(t * 1.3 + b.ph))];
+ const vis = []; BLOBS.forEach(b => { const [x, y, r] = at(b); if (y - r > H + 40 || y + r < -40) return; vis.push([b, x, y, r]); });
+ if (!vis.length) return;
+ const sg = g.createLinearGradient(0, 260 + cam.oy, 0, 1100 + cam.oy); sg.addColorStop(0, '#a48fcf'); sg.addColorStop(0.6, '#7d6cb4'); sg.addColorStop(1, '#5e5098');
+ g.fillStyle = sg; g.beginPath(); vis.forEach(([b, x, y, r]) => { g.moveTo(x + r, y); g.arc(x, y, r, 0, 7); }); g.fill();
+ const sx = SUN[0] + cam.ox, sy = SUN[1] + cam.oy;
+ const lg = l.createRadialGradient(sx, sy, 0, sx, sy, 1150); lg.addColorStop(0, '#fff3de'); lg.addColorStop(0.45, '#ffd4ae'); lg.addColorStop(1, '#f2a9bd');
+ const off = (x, y, r, k, sh) => { const dx = sx - x, dy = sy - y, d = Math.hypot(dx, dy) || 1; return [x + dx / d * r * k, y + dy / d * r * k - r * 0.06, r * sh]; };
+ l.fillStyle = lg; l.beginPath(); vis.forEach(([b, x, y, r]) => { if (b.lit < 0.32) return; const [ox, oy, rr] = off(x, y, r, 0.26, 0.86); l.moveTo(ox + rr, oy); l.arc(ox, oy, rr, 0, 7); }); l.fill();
+ l.fillStyle = 'rgba(255,251,242,.92)'; l.beginPath(); vis.forEach(([b, x, y, r]) => { if (b.lit < 0.62) return; const [ox, oy, rr] = off(x, y, r, 0.5, 0.6); l.moveTo(ox + rr, oy); l.arc(ox, oy, rr, 0, 7); }); l.fill();
+ l.globalCompositeOperation = 'destination-in'; l.drawImage(S, 0, 0);
+ g.drawImage(L, 0, 0);
+ // 云底一层冷色暈,云体内部有体积感
+ g.globalCompositeOperation = 'source-atop'; const vg = g.createLinearGradient(0, 700 + cam.oy, 0, 1100 + cam.oy); vg.addColorStop(0, 'rgba(70,60,140,0)'); vg.addColorStop(1, 'rgba(70,60,140,.35)'); g.fillStyle = vg; g.fillRect(0, 0, W, H);
+ c.drawImage(S, 0, 0);
+ }
+ // ---------- 发射塔、「筷子」、飞船(夕光剪影:赛璐珞暗部+向阳亮边) ----------
+ // 局部坐标版赛璐珞(P.cel 的反选大矩形是屏幕像素范围,在「米」坐标里会把整个上半截选进亮边)
+ const BIGL = (() => { const p = new Path2D(); p.rect(-1e4, -1e4, 2e4, 2e4); return p; })();
+ const beside = (c, path, dx, dy) => { const m = new Path2D(); m.addPath(BIGL); m.addPath(path, new DOMMatrix().translate(dx, dy)); c.clip(path); c.clip(m, 'evenodd'); };
+ function cel(c, p, base, shade, rim, { sd = 1, rw = 0.3, line, lw = 0, lx = -1, ly = -0.55 } = {}) {
+ c.fillStyle = base; c.fill(p);
+ if (shade) { c.save(); beside(c, p, lx * sd, ly * sd); c.fillStyle = shade; c.fill(p); c.restore(); }
+ if (rim) { c.save(); beside(c, p, -lx * rw, -ly * rw); c.fillStyle = rim; c.fill(p); c.restore(); }
+ if (lw) { c.strokeStyle = line; c.lineWidth = lw; c.lineJoin = 'round'; c.stroke(p); }
+ }
+ const SIL = { b: '#2c2752', s: '#1d1a3c', r: '#ffb27c' };
+ const lit = { lx: -1, ly: 0.35 }; // 光从左下(太阳)来
+ function armTheta(lt) { return lerp(0.55, 0.03, ease.in(ss(T_JZ - 0.28, T_JZ + 0.1, lt))); }
+ function tower(c, cam, lt, t, front) {
+ const th = armTheta(lt);
+ c.save(); c.translate(TW.x + cam.ox, TW.base + cam.oy); c.scale(TW.pxm, TW.pxm);
+ const arm = (s) => { const L = 30, kV = 0.5, x1 = -L * Math.cos(th), y1 = -TW.armY + s * L * Math.sin(th) * kV, y0 = -TW.armY + s * (0.2 + Math.sin(th) * 1.4);
+ const ang = Math.atan2(y1 - y0, x1), nx = -Math.sin(ang), ny = Math.cos(ang);
+ const p = U.poly([[nx * 0.9, y0 + ny * 0.9], [x1 + nx * 0.65, y1 + ny * 0.65], [x1 - nx * 0.65, y1 - ny * 0.65], [-nx * 0.9, y0 - ny * 0.9]]);
+ cel(c, p, s < 0 ? '#25213f' : SIL.b, null, SIL.r, { rw: 0.3, lw: 0, ...lit }); };
+ if (!front) {
+ const tw = RK.tower({ armY: TW.armY });
+ const body = tw.parts.find(q => q.k === 'body').p;
+ cel(c, body, SIL.b, SIL.s, SIL.r, { sd: 4, rw: 0.45, lw: 0, ...lit });
+ c.save(); c.clip(body); c.strokeStyle = 'rgba(120,100,170,.55)'; c.lineWidth = 0.18; for (let y = 0; y < 146; y += 6) { c.beginPath(); c.moveTo(0, -y); c.lineTo(12, -y - 6); c.moveTo(0, -y); c.lineTo(12, -y); c.stroke(); } c.restore();
+ c.fillStyle = SIL.s; c.fillRect(5.6, -158, 0.8, 12); // 避雷杆
+ const blink = 0.5 + 0.5 * Math.sin(t * 4); // 塔顶航空障碍灯
+ c.fillStyle = `rgba(255,70,60,${0.4 + 0.6 * blink})`; c.beginPath(); c.arc(6, -158.5, 0.7, 0, 7); c.fill();
+ c.fillStyle = '#211d3a'; c.fillRect(-1.2, -TW.armY - 4, 4.4, 8);
+ arm(-1);
+ } else arm(1);
+ c.restore();
+ }
+ const SHIP = RK.ship({});
+ function shipHull(sh) { const h = new Path2D(); sh.parts.forEach(q => { if (q.k === 'body' || q.k === 'nose') h.addPath(q.p); }); return h; }
+ function shipPose(lt) {
+ const p = clamp(lt / (T_JZ + 0.06)), e = 1 - Math.pow(1 - p, 1.8);
+ let base = lerp(SHIP_CATCH + 150, SHIP_CATCH + 0.6, e);
+ const settle = ss(T_JZ + 0.02, T_JZ + 0.25, lt); base -= 0.6 * settle - 0.25 * Math.sin(settle * Math.PI);
+ return { x: SHIPX + Math.sin(lt * 1.9) * 1.2 * (1 - p) * TW.pxm, y: TW.base - base * TW.pxm, p };
+ }
+ function ship(c, cam, lt, t) {
+ const S = shipPose(lt), hull = shipHull(SHIP);
+ // 预演:落点处的虚线轮廓+下落虚线(未来时)
+ const ga = ss(0.3, 0.9, lt) * (1 - ss(T_JZ - 0.1, T_JZ + 0.3, lt));
+ if (ga > 0) { c.save(); c.translate(SHIPX + cam.ox, TW.base - SHIP_CATCH * TW.pxm + cam.oy); c.scale(TW.pxm, TW.pxm);
+ c.setLineDash([2.2, 1.6]); c.lineDashOffset = -t * 6; c.strokeStyle = `rgba(255,232,196,${0.75 * ga})`; c.lineWidth = 0.32; c.stroke(hull); c.setLineDash([]); c.restore(); }
+ c.save(); c.translate(S.x + cam.ox, S.y + cam.oy); c.scale(TW.pxm, TW.pxm);
+ const fl = 1 - ss(T_JZ - 0.05, T_JZ + 0.2, lt);
+ if (fl > 0) RK.flame(c, 0, 1.6, 16 * fl * (1 - 0.3 * S.p), 5.5 * (0.6 + 0.4 * fl), t, ['rgba(255,150,90,.75)', 'rgba(255,214,150,.9)', '#fff8e6'], 4);
+ const flaps = SHIP.parts.filter(q => q.k === 'flap' || q.k === 'engine');
+ const flapSh = RK.ship({ flap: Math.sin(t * 2.2) * 0.25 * fl });
+ flapSh.parts.filter(q => q.k === 'flap').forEach(q => cel(c, q.p, '#26223f', null, SIL.r, { rw: 0.3, lw: 0, ...lit }));
+ cel(c, hull, '#38325f', SIL.s, SIL.r, { sd: 2.6, rw: 0.42, lw: 0, ...lit });
+ flaps.filter(q => q.k === 'engine').forEach(q => { c.fillStyle = SIL.s; c.fill(q.p); });
+ c.restore();
+ }
+ // 接住那一刻:接驳点闪两颗四芒星
+ function glints(c, cam, lt, t) {
+ const u = lt - T_JZ; if (u < -0.02 || u > 0.9) return;
+ const a = Math.sin(Math.PI * clamp(u / 0.9));
+ [[SHIPX - 6 * TW.pxm, 0], [SHIPX + 6 * TW.pxm, 0.12]].forEach(([x, d]) => {
+ const y = TW.base - TW.armY * TW.pxm + cam.oy, xx = x + cam.ox, k = a * (1 - d), L = 60 * k;
+ c.save(); c.globalCompositeOperation = 'lighter'; c.fillStyle = `rgba(255,236,200,${0.9 * k})`;
+ c.beginPath(); c.moveTo(xx - L, y); c.quadraticCurveTo(xx, y, xx, y - L * 0.7); c.quadraticCurveTo(xx, y, xx + L, y); c.quadraticCurveTo(xx, y, xx, y + L * 0.7); c.quadraticCurveTo(xx, y, xx - L, y); c.fill();
+ const g = c.createRadialGradient(xx, y, 0, xx, y, 40); g.addColorStop(0, `rgba(255,240,210,${0.8 * k})`); g.addColorStop(1, 'rgba(255,240,210,0)'); c.fillStyle = g; c.fillRect(xx - 40, y - 40, 80, 80); c.restore(); });
+ }
+ // ---------- B:高空两艘星舰并排,一条细光线 ----------
+ const PAIR = [{ x: 780, y: -350, a: -0.1 }, { x: 1120, y: -232, a: -0.1 }], PXB = 6.2;
+ function refuelShip(c, cam, S, lt) {
+ const hull = shipHull(SHIP), dr = lt * 9;
+ c.save(); c.translate(S.x + cam.ox + dr, S.y + cam.oy + Math.sin(lt * 1.3 + S.x) * 4); c.rotate(Math.PI / 2 + S.a); c.scale(PXB, PXB); c.translate(0, SHIP.h / 2 - 1);
+ const th = Math.PI / 2 + S.a, Lx = -1, Ly = 0.35, lx = Lx * Math.cos(th) + Ly * Math.sin(th), ly = -Lx * Math.sin(th) + Ly * Math.cos(th);
+ const L = { lx, ly, line: '#3b3460', lw: 0.12 };
+ SHIP.parts.filter(q => q.k === 'flap').forEach(q => cel(c, q.p, '#9aa0bf', '#6a6f96', '#ffd2a2', { sd: 0.7, rw: 0.3, ...L }));
+ cel(c, hull, '#d9dcea', '#8e93b6', '#ffe0b6', { sd: 2.2, rw: 0.45, ...L });
+ c.save(); c.clip(hull); const tl = SHIP.parts.find(q => q.k === 'tiles'); c.fillStyle = '#3a3a5c'; c.fill(tl.p); c.restore();
+ SHIP.parts.filter(q => q.k === 'engine').forEach(q => { c.fillStyle = '#3a3a5c'; c.fill(q.p); });
+ c.restore();
+ }
+ function belly(S, s, cam, t) { const n = [-Math.sin(S.a), Math.cos(S.a)], u = [Math.cos(S.a), Math.sin(S.a)]; return [S.x + cam.ox + t * 9 + n[0] * 4.6 * PXB * s - u[0] * 30, S.y + cam.oy + Math.sin(t * 1.3 + S.x) * 4 + n[1] * 4.6 * PXB * s - u[1] * 30]; }
+ function refuel(c, cam, lt, t) {
+ if (cam.oy < 200) return;
+ refuelShip(c, cam, PAIR[0], lt); refuelShip(c, cam, PAIR[1], lt);
+ const A = belly(PAIR[0], 1, cam, lt), B = belly(PAIR[1], -1, cam, lt), q = ease.inOut(ss(T_JY - 0.15, T_JY + 0.3, lt)); if (q <= 0) return;
+ const E = [lerp(A[0], B[0], q), lerp(A[1], B[1], q)];
+ c.save(); c.globalCompositeOperation = 'lighter'; c.lineCap = 'round';
+ c.strokeStyle = 'rgba(255,214,160,.22)'; c.lineWidth = 12; c.beginPath(); c.moveTo(...A); c.lineTo(...E); c.stroke();
+ c.strokeStyle = 'rgba(255,246,226,.95)'; c.lineWidth = 2.2; c.stroke();
+ // 光点沿线从左舰流向右舰
+ if (q >= 1) for (let i = 0; i < 7; i++) { const s = ((lt - T_JY) * 0.9 + i / 7) % 1, x = lerp(A[0], B[0], s), y = lerp(A[1], B[1], s), g = c.createRadialGradient(x, y, 0, x, y, 11);
+ g.addColorStop(0, 'rgba(255,250,235,.95)'); g.addColorStop(1, 'rgba(255,220,170,0)'); c.fillStyle = g; c.fillRect(x - 11, y - 11, 22, 22); }
+ c.restore();
+ }
+ // ---------- C:星舰尾迹弧线划向月亮 ----------
+ const bez = (s) => { const [a, b, c2, d] = TRAIL, m = 1 - s; return [m * m * m * a[0] + 3 * m * m * s * b[0] + 3 * m * s * s * c2[0] + s * s * s * d[0], m * m * m * a[1] + 3 * m * m * s * b[1] + 3 * m * s * s * c2[1] + s * s * s * d[1]]; };
+ function trail(c, cam, lt, t) {
+ const s1 = ease.inOut(ss(T_ZQ + 0.15, T_YQ + 0.05, lt)); if (s1 <= 0) return;
+ const n = 70, s0 = Math.max(0, s1 - 0.95);
+ const pts = []; for (let i = 0; i <= n; i++) { const s = lerp(s0, s1, i / n), p = bez(s); pts.push([p[0] + cam.ox, p[1] + cam.oy, i / n]); }
+ c.save(); c.globalCompositeOperation = 'lighter'; c.lineCap = 'round';
+ for (const [w, a0, col] of [[22, 0.1, '255,200,170'], [8, 0.3, '255,226,196'], [2.4, 0.95, '255,250,238']]) {
+ for (let i = 0; i < n; i++) { const [x0, y0, u] = pts[i], [x1, y1] = pts[i + 1], shimmer = 0.85 + 0.15 * Math.sin(t * 6 - u * 14);
+ c.strokeStyle = `rgba(${col},${a0 * Math.pow(u, 1.4) * shimmer})`; c.lineWidth = w * (0.4 + 0.6 * u); c.beginPath(); c.moveTo(x0, y0); c.lineTo(x1, y1); c.stroke(); } }
+ // 弧头:一点亮光(星舰)+小星芒
+ const [hx, hy] = pts[n], k = 1 - 0.4 * ss(T_YQ + 0.1, T_YQ + 1.2, lt), g = c.createRadialGradient(hx, hy, 0, hx, hy, 30 * k);
+ g.addColorStop(0, 'rgba(255,252,240,1)'); g.addColorStop(0.3, 'rgba(255,230,190,.55)'); g.addColorStop(1, 'rgba(255,220,180,0)'); c.fillStyle = g; c.fillRect(hx - 32, hy - 32, 64, 64);
+ c.strokeStyle = `rgba(255,246,226,${0.6 * k})`; c.lineWidth = 1.4; for (let i = 0; i < 4; i++) { const a = i * Math.PI / 2 + t * 0.4, L = (i % 2 ? 16 : 30) * k; c.beginPath(); c.moveTo(hx, hy); c.lineTo(hx + Math.cos(a) * L, hy + Math.sin(a) * L); c.stroke(); }
+ c.restore();
+ }
+ // 鸟群(A 段,剪影扇翅)
+ function birds(c, cam, lt, t) {
+ for (let k = 0; k < 5; k++) { const x = 220 + lt * 70 + k * 38 + cam.ox, y = 470 + k * 13 + Math.sin(t * 2.4 + k) * 7 + cam.oy, f = Math.sin(t * 13 + k * 2) * 7; if (y > H + 20) continue;
+ c.strokeStyle = '#3a2f5a'; c.lineWidth = 2.4; c.lineCap = 'round'; c.beginPath(); c.moveTo(x - 11, y - f); c.quadraticCurveTo(x - 4, y - 2, x, y); c.quadraticCurveTo(x + 4, y - 2, x + 11, y - f); c.stroke(); }
+ }
+ // 片尾回扣:月亮与火星下方淡入「2002 → 2026」(白色细字+柔光,箭头用路径画),口播结束后出现、保持到段尾
+ function coda(c, lt) {
+ const a = ss(VO[1] + 0.15, VO[1] + 1.0, lt); if (a <= 0) return;
+ const y = 772 - 10 * ease.out(a), sz = 64, gap = 128;
+ c.save(); c.globalAlpha = a; c.font = `${sz}px "PuHui-Medium"`; c.textBaseline = 'middle'; c.letterSpacing = '6px';
+ const wL = c.measureText('2002').width, wR = c.measureText('2026').width, x0 = 960 - (wL + gap + wR) / 2;
+ c.shadowColor = 'rgba(255,236,210,.85)'; c.shadowBlur = 22; c.fillStyle = '#fffaf0';
+ c.textAlign = 'left'; c.fillText('2002', x0, y); c.fillText('2026', x0 + wL + gap, y);
+ const ax0 = x0 + wL + 30, ax1 = x0 + wL + gap - 30; c.strokeStyle = '#fffaf0'; c.lineWidth = 3; c.lineCap = 'round';
+ c.beginPath(); c.moveTo(ax0, y); c.lineTo(ax1, y); c.moveTo(ax1 - 14, y - 11); c.lineTo(ax1, y); c.lineTo(ax1 - 14, y + 11); c.stroke();
+ c.restore();
+ }
+ // 光尘(屏幕空间,缓慢上浮、闪烁)
+ function motes(c, t) {
+ const ms = P.particles(34, 91, t * 0.5, { x0: 40, x1: 1880, y0: 1060, y1: 40, speed: 24, drift: 36, life: 9 });
+ c.save(); c.globalCompositeOperation = 'lighter';
+ ms.forEach((m, i) => { const tw = 0.5 + 0.5 * Math.sin(t * 5 + i * 1.3), rr = (1 + m.s * 2) * 2.4, g = c.createRadialGradient(m.x, m.y, 0, m.x, m.y, rr); g.addColorStop(0, `rgba(255,244,220,${0.55 * tw})`); g.addColorStop(1, 'rgba(255,244,220,0)'); c.fillStyle = g; c.fillRect(m.x - rr, m.y - rr, rr * 2, rr * 2); });
+ c.restore();
+ }
+
+ return {
+ init() { U.assertGlyphs('PuHui-Medium', '20022026', ID); RAYS(); CIRRUS(); MOONIMG(); ALTO(); // 预热缓存,免得第一次用到的那帧超时
+ ['筷子', '夹住', '在太空里', '加油', '争取', '月球', '再往后', '火星'].forEach(k => { if (!TM.text(ID).includes(k)) throw new Error('s12 cue 不在字幕里:' + k); }); },
+ draw(c, lt, t) {
+ const cam = camAt(lt);
+ skyFill(c, cam);
+ stars(c, cam, t);
+ rays(c, cam, t);
+ cirrus(c, cam, lt);
+ alto(c, cam, lt);
+ moon(c, cam, t);
+ mars(c, cam, lt, t);
+ clouds(c, cam, lt, t);
+ trail(c, cam, lt, t);
+ refuel(c, cam, lt, t);
+ if (cam.oy < 1100) { birds(c, cam, lt, t); tower(c, cam, lt, t, false); ship(c, cam, lt, t); tower(c, cam, lt, t, true); glints(c, cam, lt, t); }
+ motes(c, t);
+ const sy = SUN[1] + cam.oy; if (sy < 1250) P.lensFlare(c, [SUN[0] + cam.ox, sy], t, { core: 120 });
+ P.bloom(c, { key: 's12Bloom', alpha: 0.3 });
+ c.save(); c.globalCompositeOperation = 'soft-light'; const tg = c.createLinearGradient(0, 0, 0, H); tg.addColorStop(0, 'rgba(70,100,220,.35)'); tg.addColorStop(1, 'rgba(255,200,150,.35)'); c.fillStyle = tg; c.fillRect(0, 0, W, H); c.restore();
+ // 片尾余韵:口播结束后天色慢慢压暗一点(不黑屏)
+ const dk = 0.3 * ss(VO[1] + 0.1, DUR - 0.6, lt);
+ if (dk > 0) { c.save(); c.globalCompositeOperation = 'multiply'; c.fillStyle = `rgba(60,60,120,${dk})`; c.fillRect(0, 0, W, H); c.restore(); }
+ coda(c, lt);
+ },
+ };
+})();
+ERAS.find(e => e.id === 's12').transition = { type: 'flareSweep', dur: 0.6 };
diff --git a/scripts/engine/reference_films/spacex/spacex/timing.js b/scripts/engine/reference_films/spacex/spacex/timing.js
new file mode 100644
index 0000000..aed95b0
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex/timing.js
@@ -0,0 +1,2 @@
+// 由 口播/build_timing.py 生成,勿手改。seg[id]: dur 段长;voStart/voEnd 口播起止;charStart/charEnd 字幕文本逐字起止(本段局部秒)
+window.TIMING = {"total": 131.3844, "seg": {"s01": {"text": "2008年,SpaceX的火箭已经连败三次,钱只够再打最后一发。9月28号,那一发成了。整整18年后的同一天,星舰第一次进入了地球轨道。两分钟,看完它这24年。", "dur": 13.7607, "voStart": 0.06, "voEnd": 13.0107, "t0": 0.0, "charStart": [0.35, 0.35, 0.38, 0.54, 0.84, 1.0, 1.0, 1.056, 1.112, 1.168, 1.224, 1.28, 1.6, 1.7, 1.86, 2.04, 2.14, 2.24, 2.44, 2.62, 2.82, 3.1, 3.1, 3.52, 3.72, 3.84, 4.0, 4.16, 4.32, 4.48, 4.62, 4.76, 4.76, 5.36, 5.44, 5.58, 5.72, 6.02, 6.02, 6.26, 6.36, 6.54, 6.82, 7.08, 7.08, 7.66, 7.8, 7.89, 7.98, 8.14, 8.26, 8.36, 8.5, 8.64, 8.955, 9.07, 9.185, 9.3, 9.41, 9.52, 9.72, 9.84, 9.96, 10.06, 10.16, 10.3, 10.42, 10.62, 10.62, 11.14, 11.3, 11.52, 11.52, 11.82, 11.98, 12.1, 12.2, 12.33, 12.46, 12.77], "charEnd": [0.35, 0.38, 0.54, 0.84, 1.0, 1.0, 1.056, 1.112, 1.168, 1.224, 1.28, 1.6, 1.7, 1.86, 2.04, 2.14, 2.24, 2.44, 2.62, 2.82, 3.1, 3.1, 3.52, 3.72, 3.84, 4.0, 4.16, 4.32, 4.48, 4.62, 4.76, 4.76, 5.36, 5.44, 5.58, 5.72, 6.02, 6.02, 6.26, 6.36, 6.54, 6.82, 7.08, 7.08, 7.66, 7.8, 7.89, 7.98, 8.14, 8.26, 8.36, 8.5, 8.64, 8.84, 8.955, 9.07, 9.185, 9.41, 9.52, 9.72, 9.84, 9.96, 10.06, 10.16, 10.3, 10.42, 10.62, 10.62, 11.14, 11.3, 11.52, 11.52, 11.82, 11.98, 12.1, 12.2, 12.33, 12.46, 12.72, 12.77], "match": 0.972, "lines": ["2008年,SpaceX的火箭已经连败三次,", "钱只够再打最后一发。", "9月28号,那一发成了。", "整整18年后的同一天,", "星舰第一次进入了地球轨道。", "两分钟,看完它这24年。"]}, "s02": {"text": "2002年,马斯克创办了SpaceX。目标是,有一天让人类住到别的星球上。", "dur": 5.8363, "voStart": 0.15, "voEnd": 5.6363, "t0": 13.7607, "charStart": [0.45, 0.45, 0.457, 0.61, 0.89, 1.15, 1.25, 1.33, 1.41, 1.53, 1.67, 1.79, 1.89, 1.922, 1.954, 1.986, 2.018, 2.05, 2.41, 2.41, 2.79, 2.93, 3.13, 3.13, 3.31, 3.49, 3.75, 4.05, 4.21, 4.35, 4.49, 4.63, 4.81, 4.93, 5.03, 5.21, 5.4], "charEnd": [0.45, 0.457, 0.61, 0.89, 1.05, 1.15, 1.33, 1.41, 1.53, 1.67, 1.79, 1.89, 1.922, 1.954, 1.986, 2.018, 2.05, 2.41, 2.41, 2.79, 2.93, 3.13, 3.13, 3.31, 3.49, 3.75, 4.05, 4.21, 4.35, 4.49, 4.63, 4.81, 4.93, 5.03, 5.21, 5.35, 5.4], "match": 1.0, "lines": ["2002年,马斯克创办了SpaceX。", "目标是,有一天让人类住到别的星球上。"]}, "s03": {"text": "它的第一款火箭,叫猎鹰1号。2006年,失败;2007年,失败;2008年8月,还是失败。第四次,成了,成为第一枚私人研制、进入轨道的液体燃料火箭。", "dur": 14.4235, "voStart": 0.15, "voEnd": 13.8735, "t0": 19.5971, "charStart": [0.44, 0.44, 0.51, 0.61, 0.71, 0.85, 1.07, 1.27, 1.27, 1.71, 1.81, 1.91, 2.01, 2.15, 2.15, 2.397, 2.643, 2.89, 3.13, 3.37, 3.37, 3.81, 3.97, 3.97, 4.223, 4.477, 4.73, 5.01, 5.31, 5.31, 5.65, 5.89, 5.89, 6.09, 6.29, 6.49, 6.73, 6.87, 7.07, 7.25, 7.25, 7.52, 7.79, 8.05, 8.47, 8.47, 8.79, 8.95, 9.15, 9.15, 9.67, 10.09, 10.09, 10.47, 10.59, 10.72, 10.85, 11.07, 11.35, 11.51, 11.67, 11.87, 11.87, 12.07, 12.21, 12.39, 12.57, 12.73, 12.95, 13.13, 13.23, 13.33, 13.47, 13.68], "charEnd": [0.44, 0.51, 0.61, 0.71, 0.85, 1.07, 1.27, 1.27, 1.61, 1.71, 1.81, 1.91, 2.15, 2.15, 2.397, 2.643, 2.89, 3.13, 3.37, 3.37, 3.81, 3.97, 3.97, 4.223, 4.477, 4.73, 5.01, 5.31, 5.31, 5.65, 5.89, 5.89, 6.09, 6.29, 6.49, 6.73, 6.87, 7.07, 7.25, 7.25, 7.52, 7.79, 8.05, 8.47, 8.47, 8.79, 8.95, 9.15, 9.15, 9.67, 10.09, 10.09, 10.47, 10.59, 10.72, 10.85, 11.07, 11.35, 11.51, 11.67, 11.87, 11.87, 12.07, 12.21, 12.39, 12.57, 12.73, 12.95, 13.13, 13.23, 13.33, 13.47, 13.63, 13.68], "match": 0.952, "lines": ["它的第一款火箭,叫猎鹰1号。", "2006年,失败;2007年,失败;", "2008年8月,还是失败。", "第四次,成了,", "成为第一枚私人研制、进入轨道的液体燃料火箭。"]}, "s04": {"text": "三个月后,NASA给了它一份合同,16亿美元,往空间站送货。2012年,龙飞船成了第一艘造访国际空间站的私人飞船。", "dur": 8.7209, "voStart": 0.15, "voEnd": 8.5209, "t0": 34.0205, "charStart": [0.48, 0.53, 0.61, 0.71, 0.89, 0.89, 0.96, 1.03, 1.1, 1.17, 1.41, 1.49, 1.61, 1.73, 1.83, 2.03, 2.19, 2.19, 2.44, 2.69, 2.93, 3.07, 3.21, 3.21, 3.49, 3.69, 3.81, 3.95, 4.11, 4.35, 4.35, 4.63, 4.91, 5.05, 5.19, 5.39, 5.39, 5.57, 5.69, 5.87, 6.05, 6.19, 6.29, 6.39, 6.65, 6.79, 6.95, 7.07, 7.21, 7.35, 7.49, 7.65, 7.73, 7.93, 8.05, 8.15, 8.42], "charEnd": [0.53, 0.61, 0.71, 0.89, 0.89, 0.96, 1.03, 1.1, 1.17, 1.41, 1.49, 1.61, 1.73, 1.83, 2.03, 2.19, 2.19, 2.44, 2.69, 2.93, 3.07, 3.21, 3.21, 3.49, 3.69, 3.81, 3.95, 4.11, 4.35, 4.35, 4.63, 4.91, 5.05, 5.19, 5.39, 5.39, 5.57, 5.69, 5.87, 6.05, 6.19, 6.29, 6.39, 6.65, 6.79, 6.95, 7.07, 7.21, 7.35, 7.49, 7.65, 7.73, 7.93, 8.05, 8.15, 8.37, 8.42], "match": 1.0, "lines": ["三个月后,NASA给了它一份合同,", "16亿美元,往空间站送货。", "2012年,龙飞船成了第一艘", "造访国际空间站的私人飞船。"]}, "s05": {"text": "接着呢,它想把火箭的一级飞回来,重复用。2015年12月,猎鹰9号的一级竖着落回了地面,轨道火箭里这是头一回;2017年,回收的一级又一次飞上了天。", "dur": 11.177, "voStart": 0.15, "voEnd": 10.977, "t0": 42.7415, "charStart": [0.47, 0.634, 0.718, 0.802, 0.886, 0.97, 1.11, 1.25, 1.47, 1.59, 1.67, 1.79, 1.89, 2.07, 2.19, 2.31, 2.31, 2.55, 2.71, 2.85, 2.85, 3.005, 3.16, 3.315, 3.47, 3.79, 3.9, 4.01, 4.32, 4.41, 4.5, 4.59, 4.73, 4.89, 4.95, 5.11, 5.43, 5.61, 5.79, 5.93, 6.09, 6.15, 6.27, 6.49, 6.49, 6.87, 6.97, 7.15, 7.31, 7.41, 7.5, 7.59, 7.81, 7.93, 8.07, 8.07, 8.2, 8.33, 8.46, 8.59, 9.05, 9.05, 9.23, 9.37, 9.45, 9.59, 9.73, 9.91, 10.03, 10.15, 10.31, 10.47, 10.55, 10.72], "charEnd": [0.55, 0.634, 0.718, 0.802, 0.886, 1.11, 1.25, 1.47, 1.59, 1.67, 1.79, 1.89, 2.07, 2.19, 2.31, 2.31, 2.55, 2.71, 2.85, 2.85, 3.005, 3.16, 3.315, 3.47, 3.79, 3.9, 4.01, 4.23, 4.32, 4.41, 4.5, 4.73, 4.89, 4.95, 5.11, 5.25, 5.43, 5.61, 5.93, 6.09, 6.15, 6.27, 6.49, 6.49, 6.87, 6.97, 7.15, 7.31, 7.41, 7.5, 7.59, 7.81, 7.93, 8.07, 8.07, 8.2, 8.33, 8.46, 8.59, 9.05, 9.05, 9.23, 9.37, 9.45, 9.59, 9.73, 9.91, 10.03, 10.15, 10.31, 10.47, 10.55, 10.67, 10.72], "match": 0.894, "lines": ["接着呢,它想把火箭的一级飞回来,重复用。", "2015年12月,猎鹰9号的一级竖着落回了地面,", "轨道火箭里这是头一回;", "2017年,回收的一级又一次飞上了天。"]}, "s06": {"text": "2018年,重型猎鹰首飞,把一辆跑车送上了绕太阳的轨道,两枚助推器并排落回地面。", "dur": 7.1103, "voStart": 0.15, "voEnd": 6.9103, "t0": 53.9185, "charStart": [0.4, 0.4, 0.45, 0.6, 0.75, 1.17, 1.21, 1.27, 1.523, 1.617, 1.71, 1.91, 2.17, 2.17, 2.43, 2.55, 2.67, 2.85, 3.11, 3.29, 3.47, 3.59, 3.73, 3.89, 4.03, 4.13, 4.25, 4.43, 4.43, 4.87, 5.03, 5.13, 5.31, 5.55, 5.81, 6.03, 6.19, 6.35, 6.47, 6.7], "charEnd": [0.4, 0.45, 0.6, 0.75, 1.13, 1.17, 1.27, 1.43, 1.523, 1.617, 1.91, 2.17, 2.17, 2.43, 2.55, 2.67, 2.85, 3.11, 3.29, 3.47, 3.59, 3.73, 3.89, 4.03, 4.13, 4.25, 4.43, 4.43, 4.87, 5.03, 5.13, 5.31, 5.55, 5.81, 6.03, 6.19, 6.35, 6.47, 6.65, 6.7], "match": 0.944, "lines": ["2018年,重型猎鹰首飞,", "把一辆跑车送上了绕太阳的轨道,", "两枚助推器并排落回地面。"]}, "s07": {"text": "2020年5月,载人龙飞船把两名宇航员送往空间站。美国时隔近9年,重新从本土送人上天;也是第一次,由私人公司的飞船把人送进轨道。", "dur": 11.0536, "voStart": 0.15, "voEnd": 10.8536, "t0": 61.0288, "charStart": [0.46, 0.46, 0.46, 0.54, 0.67, 0.99, 1.15, 1.35, 1.35, 1.67, 1.81, 1.97, 2.11, 2.31, 2.47, 2.61, 2.73, 2.83, 2.95, 3.15, 3.31, 3.41, 3.55, 3.69, 3.93, 3.93, 4.2, 4.47, 4.75, 4.89, 5.03, 5.29, 5.53, 5.53, 5.79, 6.01, 6.17, 6.33, 6.53, 6.75, 6.87, 7.01, 7.25, 7.25, 7.57, 7.89, 8.0, 8.11, 8.39, 8.39, 8.59, 8.83, 8.97, 9.11, 9.25, 9.35, 9.47, 9.73, 9.89, 10.05, 10.19, 10.33, 10.45, 10.68], "charEnd": [0.46, 0.46, 0.54, 0.67, 0.99, 1.15, 1.35, 1.35, 1.67, 1.81, 1.97, 2.11, 2.31, 2.47, 2.61, 2.73, 2.83, 2.95, 3.15, 3.31, 3.41, 3.55, 3.69, 3.93, 3.93, 4.2, 4.47, 4.75, 4.89, 5.03, 5.29, 5.53, 5.53, 5.79, 6.01, 6.17, 6.33, 6.53, 6.75, 6.87, 7.01, 7.25, 7.25, 7.57, 7.89, 8.0, 8.11, 8.39, 8.39, 8.59, 8.83, 8.97, 9.11, 9.25, 9.35, 9.47, 9.73, 9.89, 10.05, 10.19, 10.33, 10.45, 10.63, 10.68], "match": 1.0, "lines": ["2020年5月,", "载人龙飞船把两名宇航员送往空间站。", "美国时隔近9年,重新从本土送人上天;", "也是第一次,由私人公司的飞船把人送进轨道。"]}, "s08": {"text": "回收之后,发射越来越密。2025年,猎鹰9号发射了165次,平均两天多一发,比全世界其他火箭加起来还多。有一枚助推器,已经飞了37次。", "dur": 12.2743, "voStart": 0.15, "voEnd": 12.0743, "t0": 72.0824, "charStart": [0.37, 0.57, 0.71, 0.83, 1.05, 1.05, 1.39, 1.63, 1.79, 1.93, 2.07, 2.25, 2.25, 2.55, 2.85, 2.97, 3.09, 3.485, 3.6, 3.715, 3.83, 4.01, 4.15, 4.31, 4.45, 4.53, 4.7, 4.87, 5.27, 5.49, 5.49, 5.93, 6.07, 6.27, 6.45, 6.59, 6.75, 6.91, 6.91, 7.35, 7.49, 7.59, 7.69, 7.87, 8.01, 8.13, 8.25, 8.43, 8.59, 8.71, 8.83, 9.01, 9.01, 9.36, 9.71, 9.89, 10.01, 10.15, 10.41, 10.41, 10.64, 10.87, 11.11, 11.17, 11.34, 11.51, 11.84], "charEnd": [0.57, 0.71, 0.83, 1.05, 1.05, 1.39, 1.63, 1.79, 1.93, 2.07, 2.25, 2.25, 2.55, 2.85, 2.97, 3.09, 3.37, 3.485, 3.6, 3.715, 4.01, 4.15, 4.31, 4.45, 4.53, 4.7, 4.87, 5.27, 5.49, 5.49, 5.93, 6.07, 6.27, 6.45, 6.59, 6.75, 6.91, 6.91, 7.35, 7.49, 7.59, 7.69, 7.87, 8.01, 8.13, 8.25, 8.43, 8.59, 8.71, 8.83, 9.01, 9.01, 9.36, 9.71, 9.89, 10.01, 10.15, 10.41, 10.41, 10.64, 10.87, 11.11, 11.17, 11.34, 11.51, 11.79, 11.84], "match": 0.966, "lines": ["回收之后,发射越来越密。", "2025年,猎鹰9号发射了165次,", "平均两天多一发,", "比全世界其他火箭加起来还多。", "有一枚助推器,已经飞了37次。"]}, "s09": {"text": "这些发射呢,大多在送自家的星链卫星。2019年,第一批60颗;现在,在轨的超过1.1万颗,用户超过1200万。", "dur": 9.2297, "voStart": 0.15, "voEnd": 9.0297, "t0": 84.3567, "charStart": [0.45, 0.53, 0.65, 0.79, 0.97, 0.97, 0.97, 1.29, 1.41, 1.57, 1.75, 1.95, 2.11, 2.31, 2.41, 2.55, 2.71, 2.91, 2.91, 3.045, 3.18, 3.315, 3.45, 3.91, 3.91, 4.02, 4.13, 4.33, 4.47, 4.61, 4.83, 4.83, 5.09, 5.35, 5.35, 5.75, 5.93, 6.07, 6.25, 6.43, 6.67, 6.71, 6.85, 6.97, 7.31, 7.31, 7.57, 7.69, 7.85, 8.05, 8.18, 8.31, 8.47, 8.63, 8.8], "charEnd": [0.53, 0.65, 0.79, 0.97, 0.97, 0.97, 1.29, 1.41, 1.57, 1.75, 1.95, 2.11, 2.21, 2.31, 2.55, 2.71, 2.91, 2.91, 3.045, 3.18, 3.315, 3.45, 3.91, 3.91, 4.02, 4.13, 4.33, 4.47, 4.61, 4.83, 4.83, 5.09, 5.35, 5.35, 5.75, 5.93, 6.07, 6.25, 6.43, 6.63, 6.67, 6.85, 6.97, 7.31, 7.31, 7.57, 7.69, 7.85, 8.05, 8.18, 8.31, 8.47, 8.63, 8.75, 8.8], "match": 0.957, "lines": ["这些发射呢,大多在送自家的星链卫星。", "2019年,第一批60颗;", "现在,在轨的超过1.1万颗,", "用户超过1200万。"]}, "s10": {"text": "再说星舰,史上最大、最强的火箭。2023年首飞,升空四分钟左右就炸了。2024年10月,发射塔伸出两只机械臂,像筷子一样,一次就把落回来的助推器夹住了。", "dur": 14.2117, "voStart": 0.15, "voEnd": 13.6617, "t0": 93.5864, "charStart": [0.5, 0.57, 0.775, 0.86, 0.945, 1.03, 1.45, 1.63, 1.81, 2.03, 2.03, 2.25, 2.43, 2.53, 2.65, 2.87, 2.87, 3.06, 3.25, 3.38, 3.51, 3.65, 3.83, 4.18, 4.33, 4.41, 4.65, 4.77, 4.84, 4.91, 5.13, 5.35, 5.65, 5.83, 6.94, 6.94, 7.17, 7.4, 7.53, 7.66, 7.82, 7.93, 8.04, 8.36, 8.48, 8.54, 8.66, 8.82, 9.0, 9.12, 9.36, 9.44, 9.6, 9.74, 9.92, 9.92, 10.3, 10.5, 10.66, 10.76, 10.86, 10.86, 11.11, 11.36, 11.68, 11.78, 11.92, 12.03, 12.14, 12.34, 12.4, 12.56, 12.82, 13.18, 13.38, 13.55], "charEnd": [0.57, 0.69, 0.775, 0.86, 0.945, 1.45, 1.63, 1.81, 2.03, 2.03, 2.25, 2.43, 2.53, 2.65, 2.87, 2.87, 3.06, 3.25, 3.38, 3.51, 3.65, 3.83, 4.03, 4.18, 4.41, 4.53, 4.65, 4.84, 4.91, 5.13, 5.35, 5.65, 5.83, 6.94, 6.94, 7.17, 7.4, 7.53, 7.66, 7.82, 7.93, 8.04, 8.24, 8.36, 8.54, 8.66, 8.82, 9.0, 9.12, 9.28, 9.36, 9.6, 9.74, 9.92, 9.92, 10.3, 10.5, 10.66, 10.76, 10.86, 10.86, 11.11, 11.36, 11.68, 11.78, 11.92, 12.03, 12.14, 12.28, 12.34, 12.56, 12.82, 13.18, 13.38, 13.5, 13.55], "match": 0.925, "lines": ["再说星舰,史上最大、最强的火箭。", "2023年首飞,升空四分钟左右就炸了。", "2024年10月,", "发射塔伸出两只机械臂,像筷子一样,", "一次就把落回来的助推器夹住了。"]}, "s11": {"text": "2026年,SpaceX收购了马斯克的AI公司xAI,6月上市,募资超过750亿美元,是史上最大的一次上市。9月28号,星舰入轨,放出了26颗新一代星链卫星。", "dur": 13.399, "voStart": 0.15, "voEnd": 12.449, "t0": 107.7981, "charStart": [0.48, 0.48, 0.57, 0.72, 0.87, 1.07, 1.07, 1.114, 1.158, 1.202, 1.246, 1.29, 1.61, 1.85, 2.03, 2.17, 2.31, 2.37, 2.51, 2.59, 2.66, 2.73, 2.91, 3.09, 3.31, 3.43, 3.55, 3.55, 4.13, 4.25, 4.39, 4.57, 4.57, 4.77, 4.93, 5.11, 5.27, 5.397, 5.523, 5.65, 5.97, 6.11, 6.25, 6.25, 6.47, 6.59, 6.75, 6.93, 7.02, 7.11, 7.21, 7.31, 7.49, 7.81, 7.81, 8.33, 8.43, 8.54, 8.65, 9.58, 9.66, 9.74, 9.82, 9.96, 10.12, 10.12, 10.4, 10.56, 10.66, 10.81, 10.96, 11.18, 11.44, 11.58, 11.75, 11.84, 11.94, 12.06, 12.29], "charEnd": [0.48, 0.57, 0.72, 0.87, 1.07, 1.07, 1.114, 1.158, 1.202, 1.246, 1.29, 1.61, 1.85, 2.03, 2.17, 2.31, 2.37, 2.51, 2.59, 2.66, 2.73, 2.91, 3.09, 3.31, 3.43, 3.55, 3.55, 4.13, 4.25, 4.39, 4.57, 4.57, 4.77, 4.93, 5.11, 5.27, 5.397, 5.523, 5.65, 5.97, 6.11, 6.25, 6.25, 6.47, 6.59, 6.75, 6.93, 7.02, 7.11, 7.21, 7.31, 7.49, 7.81, 7.81, 8.33, 8.43, 8.54, 8.65, 9.5, 9.58, 9.66, 9.74, 9.96, 10.12, 10.12, 10.4, 10.56, 10.66, 10.81, 10.96, 11.18, 11.44, 11.58, 11.66, 11.75, 11.94, 12.06, 12.24, 12.29], "match": 0.958, "lines": ["2026年,SpaceX收购了马斯克的AI公司xAI,", "6月上市,募资超过750亿美元,", "是史上最大的一次上市。", "9月28号,星舰入轨,", "放出了26颗新一代星链卫星。"]}, "s12": {"text": "接下来,它要用筷子夹住飞船,在太空里加油,争取把美国人重新送上月球。再往后,是火星。", "dur": 10.1873, "voStart": 0.15, "voEnd": 8.3373, "t0": 121.1971, "charStart": [0.43, 0.43, 0.497, 0.823, 0.977, 1.13, 1.23, 1.33, 1.53, 1.77, 1.95, 2.09, 2.25, 2.55, 2.55, 2.81, 2.99, 3.15, 3.29, 3.42, 3.55, 3.55, 4.07, 4.21, 4.33, 4.48, 4.63, 4.89, 5.29, 5.53, 5.71, 5.87, 6.01, 6.33, 6.33, 6.81, 7.01, 7.21, 7.21, 7.61, 7.85, 8.1], "charEnd": [0.43, 0.497, 0.67, 0.823, 0.977, 1.23, 1.33, 1.53, 1.77, 1.95, 2.09, 2.25, 2.55, 2.55, 2.81, 2.99, 3.15, 3.29, 3.42, 3.55, 3.55, 4.07, 4.21, 4.33, 4.48, 4.63, 4.89, 5.29, 5.53, 5.71, 5.87, 6.01, 6.33, 6.33, 6.81, 7.01, 7.21, 7.21, 7.61, 7.85, 8.05, 8.1], "match": 0.972, "lines": ["接下来,它要用筷子夹住飞船,", "在太空里加油,", "争取把美国人重新送上月球。", "再往后,是火星。"]}}};
diff --git a/scripts/engine/reference_films/spacex/spacex/tm.js b/scripts/engine/reference_films/spacex/spacex/tm.js
new file mode 100644
index 0000000..a001419
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex/tm.js
@@ -0,0 +1,19 @@
+// 口播对位:TM.cue('s03', '2007年') = 「2007年」这几个字开始被念出的时刻(本段局部秒,lt)。
+// TM.end('s03', '2007年') = 这几个字念完的时刻。TM.dur('s03') 段长;TM.vo('s03') = [口播开始, 口播结束](局部秒)。
+// 键必须是该段字幕文本里的原样子串(第一次出现);写错了会 console.error 并让渲染失败。
+window.TM = (() => {
+ const seg = id => { const s = TIMING.seg[id]; if (!s) throw new Error('TIMING 没有段 ' + id); return s; };
+ function find(id, key, which) {
+ const s = seg(id), i = s.text.indexOf(key);
+ if (i < 0) { console.error(`TM: 段 ${id} 的字幕里没有「${key}」`); return 0; }
+ const j = which === 'end' ? i + key.length - 1 : i;
+ return which === 'end' ? s.charEnd[j] : s.charStart[j];
+ }
+ return {
+ cue: (id, key) => find(id, key, 'start'),
+ end: (id, key) => find(id, key, 'end'),
+ dur: id => seg(id).dur,
+ vo: id => [seg(id).voStart, seg(id).voEnd],
+ text: id => seg(id).text,
+ };
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex_lin/common.js b/scripts/engine/reference_films/spacex/spacex_lin/common.js
new file mode 100644
index 0000000..90ff436
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_lin/common.js
@@ -0,0 +1,495 @@
+// SpaceX 这 24 年 · 讲解员式财经科普讲解(单风格版 lin)共用库 window.LIN。
+// 画面语法(只借语法,不模仿任何真人形象或频道标识):米白纸面+淡点阵、扁平可爱的信息图标(深色均匀描边、平涂、错位硬阴影的贴纸卡)、
+// 关键词进彩色圆角框/荧光底、手绘箭头和圈注(8fps 沸腾)、一屏一个知识点;讲解员(自备卡通形象,AI 生帧)贯穿全片。
+// 全片层级:各段 scene 画「页面」→ 引擎做页面转场 → GLOBAL_OVERLAY 画顶栏时间轴(2002→2026)和讲解员(全片时间驱动,跨转场连续)。
+(() => {
+const W = 1920, H = 1080, TAU = Math.PI * 2;
+const { clamp, lerp, rng } = U;
+
+const C = { bg: '#F8F2E6', dot: '#E4DAC6', ink: '#2B2A33', sub: '#6E6878', mute: '#B9B2A6', white: '#FFFFFF', red: '#F25F5C', redD: '#C9413F',
+ yel: '#FFD447', hl: 'rgba(255,214,64,0.78)', blue: '#4C8DF6', blueL: '#DCE9FF', teal: '#22B39C', tealL: '#D4F2EB', purple: '#8A72F0', pink: '#FF9BB0',
+ orange: '#FF9F43', green: '#3CB371', gold: '#F7C948', goldD: '#D9961C', sea: '#5BAEF2', land: '#7DCB78', steel: '#E8ECF2', steelD: '#C5CCD8',
+ tile: '#3A3F4B', mars: '#E8774A', marsD: '#C25A33', moon: '#E6E1D6', moonD: '#C9C2B4', cream: '#FFF8E7', shadow: 'rgba(43,42,51,0.14)' };
+const F = (s, w = 'Heavy') => `${s}px "PuHui-${w}"`;
+
+// ---------- 时间 ----------
+const T0 = id => TIMING.seg[id].t0;
+const popK = (lt, t0, d = 0.38, s = 2.2) => lt < t0 ? 0 : 0.3 + 0.7 * MO.backOut(clamp((lt - t0) / d), s); // 弹入(过冲):从 30% 大小起跳,第一帧不是一粒噪点
+const inK = (lt, t0, d = 0.4, ease = MO.cubicOut) => ease(clamp((lt - t0) / d));
+const outK = (lt, t0, d = 0.25) => MO.cubicIn(clamp((lt - t0) / d)); // 退场比入场快
+const boil = (lt, seed) => rng(seed * 977 + Math.floor(lt * 8 + 1e-6)); // 线稿 8fps 沸腾
+// 当前时刻有没有在念字(口型用):查全片逐字时间
+function speakingAt(T) {
+ for (const id in TIMING.seg) { const s = TIMING.seg[id], lt = T - s.t0; if (lt < 0 || lt >= s.dur) continue;
+ for (let i = 0; i < s.text.length; i++) { if (',。、;'.includes(s.text[i])) continue; if (lt >= s.charStart[i] - 0.02 && lt < s.charEnd[i] + 0.04) return true; }
+ return false; }
+ return false;
+}
+
+// 同一个词第 n 次出现(0 起)被念出的时刻
+function cueN(id, key, n = 0, end = false) { const s = TIMING.seg[id]; let i = -1; for (let k = 0; k <= n; k++) { i = s.text.indexOf(key, i + 1); if (i < 0) { console.error(`LIN.cueN: ${id} 里没有第 ${n + 1} 个「${key}」`); return 0; } }
+ return end ? s.charEnd[i + key.length - 1] : s.charStart[i]; }
+
+// ---------- 画图小工具 ----------
+const rrp = (x, y, w, h, r) => { const p = new Path2D(); p.roundRect(x, y, w, h, r); return p; }, L_rrp = rrp;
+function card(g, x, y, w, h, { fill = C.white, r = 26, lw = 4, sh = 8, stroke = C.ink } = {}) {
+ const p = rrp(x, y, w, h, r);
+ if (sh) { g.save(); g.translate(sh * 0.6, sh); g.fillStyle = C.shadow; g.fill(p); g.restore(); }
+ g.fillStyle = fill; g.fill(p); if (lw) { g.lineWidth = lw; g.strokeStyle = stroke; g.lineJoin = 'round'; g.stroke(p); }
+}
+function at(g, x, y, k, fn, rot = 0) { if (k <= 0.001) return; g.save(); g.translate(x, y); g.rotate(rot); g.scale(k, k); fn(g); g.restore(); }
+function txt(g, s, x, y, size, { w = 'Heavy', col = C.ink, align = 'left', base = 'alphabetic', ls = 0 } = {}) {
+ g.font = F(size, w); g.fillStyle = col; g.textAlign = align; g.textBaseline = base; if (ls) g.letterSpacing = ls + 'px'; g.fillText(s, x, y); if (ls) g.letterSpacing = '0px';
+}
+const tw = (s, size, w = 'Heavy', g) => { const c = g || LIN._mc || (LIN._mc = document.createElement('canvas').getContext('2d')); c.font = F(size, w); return c.measureText(s).width; };
+// 关键词彩框:以 (x,y) 为中心
+function kw(g, s, x, y, { size = 48, fill = C.red, col = C.white, w = 'Heavy', padX = 26, h, r, lw = 4, sh = 6, align = 'center' } = {}) {
+ const ww = tw(s, size, w, g) + padX * 2, hh = h || size * 1.62, x0 = align === 'left' ? x : align === 'right' ? x - ww : x - ww / 2;
+ card(g, x0, y - hh / 2, ww, hh, { fill, r: r ?? hh * 0.32, lw, sh });
+ txt(g, s, x0 + ww / 2, y + size * 0.05, size, { w, col, align: 'center', base: 'middle' });
+ return ww;
+}
+// 荧光笔:从左往右刷开(p 0..1),带一点手抖斜边
+function marker(g, x, y, w, h, p, col = C.hl, seed = 3) {
+ if (p <= 0) return; const r = rng(seed), x1 = x + w * p;
+ g.fillStyle = col; g.beginPath(); g.moveTo(x - 4, y + r() * 5); g.lineTo(x1, y - 2 + r() * 5); g.lineTo(x1 - 6, y + h + r() * 4); g.lineTo(x - 2, y + h - 3 + r() * 4); g.closePath(); g.fill();
+}
+function jitter(pts, r, amp) { return pts.map(([x, y]) => [x + (r() - 0.5) * 2 * amp, y + (r() - 0.5) * 2 * amp]); }
+function strokePart(g, pts, frac) { if (frac <= 0) return; const cum = DG.cum(pts); DG.drawPartial(g, pts, cum, cum[cum.length - 1] * clamp(frac)); }
+// 手绘弧线箭头 (x0,y0)→(x1,y1),bend 拱起高度,p 画出进度
+function arrow(g, lt, x0, y0, x1, y1, p, { seed = 1, bend = 30, col = C.ink, lw = 7, head = 30, dash } = {}) {
+ if (p <= 0) return;
+ const r = boil(lt, seed), n = 18, pts = [], dx = x1 - x0, dy = y1 - y0, L = Math.hypot(dx, dy) || 1, nx = -dy / L, ny = dx / L;
+ for (let i = 0; i <= n; i++) { const u = i / n, b = Math.sin(Math.PI * u) * bend; pts.push([x0 + dx * u + nx * b, y0 + dy * u + ny * b]); }
+ const jp = jitter(pts, r, 1.4);
+ g.save(); g.strokeStyle = col; g.lineWidth = lw; g.lineCap = 'round'; g.lineJoin = 'round'; if (dash) g.setLineDash(dash);
+ strokePart(g, jp, p); g.setLineDash([]);
+ if (p > 0.85) { const hk = clamp((p - 0.85) / 0.15), e = jp[n], a = Math.atan2(jp[n][1] - jp[n - 2][1], jp[n][0] - jp[n - 2][0]);
+ g.beginPath(); for (const d of [-1, 1]) { g.moveTo(e[0], e[1]); g.lineTo(e[0] - Math.cos(a + d * 0.55) * head * hk, e[1] - Math.sin(a + d * 0.55) * head * hk); } g.stroke(); }
+ g.restore();
+}
+// 手绘圈注(圆角方超椭圆),起笔收笔不闭合
+function ring(g, lt, cx, cy, rx, ry, p, { seed = 7, col = C.red, lw = 8 } = {}) {
+ if (p <= 0) return;
+ const r = rng(seed), pts = [], a0 = -2.5, n = 72, sp = v => Math.sign(v) * Math.pow(Math.abs(v), 0.55);
+ for (let i = 0; i <= n; i++) { const u = i / n, a = a0 + u * TAU * 1.08, k = 1 + 0.03 * Math.sin(u * 9 + r() * 0.3) + 0.04 * u; pts.push([cx + sp(Math.cos(a)) * rx * k, cy + sp(Math.sin(a)) * ry * k]); }
+ g.save(); g.strokeStyle = col; g.lineWidth = lw; g.lineCap = 'round'; g.lineJoin = 'round'; strokePart(g, jitter(pts, boil(lt, seed), 2), MO.cubicOut(clamp(p))); g.restore();
+}
+// 手绘下划线(波浪)
+function underline(g, lt, x, y, w, p, { col = C.red, lw = 7, seed = 5 } = {}) {
+ if (p <= 0) return; const pts = []; for (let i = 0; i <= 20; i++) pts.push([x + w * i / 20, y + Math.sin(i * 1.1) * 4]);
+ g.save(); g.strokeStyle = col; g.lineWidth = lw; g.lineCap = 'round'; strokePart(g, jitter(pts, boil(lt, seed), 1.5), p); g.restore();
+}
+function spark(g, x, y, r, col = C.yel) {
+ if (r <= 0.5) return;
+ g.save(); g.translate(x, y); g.fillStyle = col; g.strokeStyle = C.ink; g.lineWidth = 2.5; g.lineJoin = 'round';
+ g.beginPath(); for (let i = 0; i < 8; i++) { const a = i * Math.PI / 4 - Math.PI / 2, rr = i % 2 ? r * 0.38 : r; g.lineTo(Math.cos(a) * rr, Math.sin(a) * rr); }
+ g.closePath(); g.fill(); g.stroke(); g.restore();
+}
+// 一圈闪光:在 (x,y) 周围 n 个小星星轮流闪
+function twinkles(g, lt, pts, { r = 18, col = C.yel, speed = 1.4 } = {}) {
+ pts.forEach(([x, y], i) => { const ph = (lt * speed + i * 0.37) % 1; spark(g, x, y, r * (0.55 + 0.45 * Math.sin(ph * TAU)), col); });
+}
+// 强调放射线(「啪」)
+function burstLines(g, x, y, r0, r1, k, { n = 8, col = C.ink, lw = 6, a0 = 0 } = {}) {
+ if (k <= 0 || k >= 1) return; const e = MO.cubicOut(k);
+ g.save(); g.strokeStyle = col; g.lineWidth = lw; g.lineCap = 'round'; g.globalAlpha = 1 - clamp((k - 0.6) / 0.4);
+ for (let i = 0; i < n; i++) { const a = a0 + i * TAU / n, ra = r0 + (r1 - r0) * e * 0.55, rb = r0 + (r1 - r0) * e;
+ g.beginPath(); g.moveTo(x + Math.cos(a) * ra, y + Math.sin(a) * ra); g.lineTo(x + Math.cos(a) * rb, y + Math.sin(a) * rb); g.stroke(); }
+ g.restore();
+}
+// 彩纸:从 (x,y) 炸开,k = 炸开后的秒数
+function confetti(g, x, y, k, { n = 46, seed = 9, spread = 620, up = 760, life = 2.2 } = {}) {
+ if (k <= 0 || k > life) return; const r = rng(seed), cols = [C.red, C.yel, C.blue, C.teal, C.pink, C.purple, C.orange];
+ g.save(); g.globalAlpha = 1 - clamp((k - life + 0.5) / 0.5);
+ for (let i = 0; i < n; i++) {
+ const a = -Math.PI / 2 + (r() - 0.5) * 2.4, v = 0.45 + r() * 0.75, vx = Math.cos(a) * spread * v, vy = Math.sin(a) * up * v;
+ const px = x + vx * k * (1 - 0.35 * k / life), py = y + vy * k + 820 * k * k * 0.5, rot = r() * TAU + k * (r() - 0.5) * 14, col = cols[i % cols.length];
+ if (py > 880) continue; // 彩纸落到字幕带就消失
+ g.save(); g.translate(px, py); g.rotate(rot); g.fillStyle = col; g.strokeStyle = C.ink; g.lineWidth = 2;
+ if (i % 3 === 0) { g.beginPath(); g.arc(0, 0, 8, 0, TAU); g.fill(); g.stroke(); } else { g.beginPath(); g.rect(-11, -5, 22, 10); g.fill(); g.stroke(); }
+ g.restore();
+ }
+ g.restore();
+}
+// 卡通爆炸(橙黄火球+灰烟团),k = 爆炸后的秒数
+function puff(g, x, y, k, { s = 1, seed = 4, smoke = true } = {}) {
+ if (k <= 0 || k > 1.6) return; const r = rng(seed);
+ g.save(); g.translate(x, y); g.scale(s, s); g.lineWidth = 4; g.strokeStyle = C.ink; g.lineJoin = 'round';
+ const fire = MO.backOut(clamp(k / 0.28), 2.5) * (1 - clamp((k - 0.5) / 0.5)), sm = clamp(k / 0.5);
+ if (smoke) for (let i = 0; i < 9; i++) { const a = r() * TAU, d = 50 + r() * 40, rr = (34 + r() * 26) * MO.cubicOut(sm) * (1 - clamp((k - 1.1) / 0.5));
+ if (rr > 1) { g.beginPath(); g.arc(Math.cos(a) * d * sm, Math.sin(a) * d * sm - k * 30, rr, 0, TAU); g.fillStyle = '#D9D4CB'; g.fill(); g.stroke(); } }
+ if (fire > 0.01) {
+ const star = (R, col) => { g.beginPath(); for (let i = 0; i < 20; i++) { const a = i * TAU / 20, rr = (i % 2 ? 0.62 : 1) * R * (1 + 0.08 * Math.sin(i * 3.1)); g.lineTo(Math.cos(a) * rr, Math.sin(a) * rr); } g.closePath(); g.fillStyle = col; g.fill(); g.stroke(); };
+ star(110 * fire, C.orange); star(70 * fire, C.yel); g.beginPath(); g.arc(0, 0, 28 * fire, 0, TAU); g.fillStyle = C.white; g.fill();
+ }
+ g.restore();
+}
+// 扬尘:落地时两侧卷起的扁平云团,边扩散边上浮边淡出(k = 落地后的秒数)
+function dust(g, x, y, k, { spread = 260, seed = 7, n = 7 } = {}) {
+ if (k <= 0 || k > 1.5) return; const r = rng(seed), e = MO.cubicOut(clamp(k / 1.2));
+ g.save(); g.globalAlpha *= 0.75 * (1 - clamp((k - 0.5) / 1.0));
+ for (let i = 0; i < n * 2; i++) { const d = i % 2 ? 1 : -1, u = r(), dx = d * (40 + spread * (0.4 + 0.6 * u) * e), dy = -12 - 50 * e * r(), rr = (16 + 22 * r()) * (0.6 + 0.9 * e);
+ g.fillStyle = i % 3 ? '#E9E2D6' : '#DCD3C4'; g.beginPath(); g.arc(x + dx, y + dy, rr, 0, TAU); g.fill(); }
+ g.restore();
+}
+// 盖章 ✓ / ✗:k = 盖下后的秒数(从大砸到小+余振)
+function stamp(g, kind, x, y, k, { s = 1, rot = -0.12 } = {}) {
+ if (k <= 0) return; const e = k < 0.16 ? lerp(2.1, 1, MO.cubicIn(k / 0.16)) : 1 + MO.settle(k - 0.16, 0.08, 3, 7);
+ g.save(); g.translate(x, y); g.rotate(rot); g.scale(s * e, s * e); g.globalAlpha = clamp(k / 0.08); g.lineCap = 'round'; g.lineJoin = 'round';
+ const path = new Path2D();
+ if (kind === 'x') { path.moveTo(-42, -42); path.lineTo(42, 42); path.moveTo(42, -42); path.lineTo(-42, 42); }
+ else { path.moveTo(-50, 0); path.lineTo(-14, 36); path.lineTo(52, -40); }
+ g.strokeStyle = C.ink; g.lineWidth = 34; g.stroke(path); g.strokeStyle = kind === 'x' ? C.red : C.green; g.lineWidth = 22; g.stroke(path);
+ g.restore();
+}
+
+// ---------- 图标(都以中心为原点,s 缩放) ----------
+// 可爱火箭:用 RK 的真实比例轮廓,横向放宽 sx 倍更像图标;粗描边平涂
+const PAL = { body: C.white, dark: C.tile, nose: C.white, // 猎鹰9号整流罩是白的;猎鹰1号图标(fins)单独用红鼻头区分
+ window: C.blue, trunk: C.tile, flap: C.tile, engine: C.tile, tiles: C.tile, truss: C.tile };
+function rocket(g, shape, x, y, pxm, { rot = 0, sx = 1.6, pal = {}, lw = 4, flame = 0, lt = 0, seed = 0, fins = false } = {}) {
+ const P = { ...PAL, ...(fins ? { nose: C.red } : {}), ...pal };
+ RK.at(g, x, y, pxm, rot, h => {
+ h.scale(sx, 1);
+ if (fins) { const w = shape.w / 2, fh = shape.h * 0.2; h.fillStyle = C.red; h.strokeStyle = C.ink; h.lineJoin = 'round'; h.lineWidth = lw / (pxm * Math.sqrt(sx)); // 图标化尾翼:让小火箭一眼读成火箭
+ for (const d of [-1, 1]) { h.beginPath(); h.moveTo(d * w * 0.9, -fh); h.lineTo(d * w * 2.1, -fh * 0.25); h.lineTo(d * w * 2.1, 0.6); h.lineTo(d * w * 0.9, 0); h.closePath(); h.fill(); h.stroke(); } }
+ if (flame > 0) RK.flame(h, 0, shape.a.base ? shape.a.base[1] : 1, shape.w * 2.2 * flame, shape.w * 0.75, lt, ['rgba(255,159,67,0.92)', 'rgba(255,212,71,0.96)', '#FFF6D8'], seed);
+ for (const q of shape.parts) { const col = P[q.k] ?? P.body; if (!col) continue; h.fillStyle = col; h.fill(q.p);
+ if (q.k === 'body' || q.k === 'nose') { h.save(); h.clip(q.p); h.fillStyle = 'rgba(43,42,51,0.10)'; h.fillRect(shape.w * 0.12, -400, shape.w, 800); // 扁平插画的背光面:右侧一条暗带,箭体有体积
+ h.fillStyle = 'rgba(255,255,255,0.55)'; h.fillRect(-shape.w * 0.36, -400, shape.w * 0.09, 800); h.restore(); } }
+ h.lineJoin = 'round'; h.strokeStyle = C.ink;
+ // 描边宽度在屏幕上保持 lw 像素(非等比缩放下取均值近似)
+ h.lineWidth = lw / (pxm * Math.sqrt(sx));
+ for (const q of shape.parts) if (q.k !== 'truss' && q.k !== 'tiles') h.stroke(q.p);
+ });
+}
+const SH = {};
+const shape = (k, o) => SH[k] || (SH[k] = o());
+const F1 = () => shape('f1', () => RK.falcon1());
+const F9 = (legs = 0, fins = 0, payload = 'fairing') => RK.falcon9({ legs, fins, payload });
+const F9B = (legs = 0, fins = 0) => RK.falcon9({ legs, fins, stage: 'booster' });
+// 星舰:飞船不锈钢灰
+const SS_PAL = { body: C.steel, nose: C.steel, dark: C.tile, flap: C.tile, engine: C.tile, tiles: C.tile };
+
+function earth(g, x, y, R, lt, { spin = 30, k = 1 } = {}) {
+ at(g, x, y, k, h => {
+ h.save(); h.beginPath(); h.arc(0, 0, R, 0, TAU); h.fillStyle = C.sea; h.fill(); h.clip();
+ const LW = 540, tex = landTex(), sc = R / 135, off = ((lt * spin) % LW + LW) % LW;
+ h.scale(sc, sc); h.drawImage(tex, -135 - off, -135); h.drawImage(tex, -135 - off + LW, -135); h.scale(1 / sc, 1 / sc);
+ h.fillStyle = 'rgba(43,62,120,0.16)'; h.beginPath(); h.arc(R * 0.35, R * 0.15, R * 1.05, 0, TAU); h.arc(-R * 0.2, -R * 0.1, R * 1.1, 0, TAU, true); h.fill('evenodd');
+ h.restore();
+ h.lineWidth = 4.5; h.strokeStyle = C.ink; h.beginPath(); h.arc(0, 0, R, 0, TAU); h.stroke();
+ h.fillStyle = 'rgba(255,255,255,0.55)'; h.beginPath(); h.ellipse(-R * 0.48, -R * 0.5, R * 0.16, R * 0.08, -0.7, 0, TAU); h.fill();
+ });
+}
+const landTex = () => PAINT.cached('lin_land', 540, 270, g => {
+ g.lineWidth = 3; g.strokeStyle = C.ink; g.fillStyle = C.land; g.lineJoin = 'round';
+ const blobs = [[60, 80, 46], [190, 150, 60], [300, 70, 38], [420, 190, 52], [500, 110, 40], [130, 230, 30], [350, 250, 34]];
+ for (const [bx, by, br] of blobs) for (const off of [-540, 0, 540]) {
+ g.beginPath(); for (let i = 0; i <= 24; i++) { const a = i / 24 * TAU, rr = br * (1 + 0.22 * Math.sin(a * 3 + bx) + 0.12 * Math.sin(a * 5 + by)); g.lineTo(bx + off + Math.cos(a) * rr, by + Math.sin(a) * rr * 0.8); }
+ g.closePath(); g.fill(); g.stroke();
+ }
+});
+function planet(g, x, y, R, { col = C.mars, colD = C.marsD, craters = 3, seed = 2, k = 1, rot = 0 } = {}) {
+ at(g, x, y, k, h => {
+ h.beginPath(); h.arc(0, 0, R, 0, TAU); h.fillStyle = col; h.fill();
+ h.save(); h.clip(); const r = rng(seed); h.fillStyle = colD;
+ for (let i = 0; i < craters; i++) { const a = r() * TAU + rot, d = r() * R * 0.6, rr = R * (0.1 + r() * 0.14); h.beginPath(); h.arc(Math.cos(a) * d, Math.sin(a) * d, rr, 0, TAU); h.fill(); }
+ h.fillStyle = 'rgba(43,42,51,0.13)'; h.beginPath(); h.arc(R * 0.35, R * 0.2, R * 1.05, 0, TAU); h.arc(-R * 0.2, -R * 0.1, R * 1.1, 0, TAU, true); h.fill('evenodd'); h.restore();
+ h.lineWidth = 4.5; h.strokeStyle = C.ink; h.beginPath(); h.arc(0, 0, R, 0, TAU); h.stroke();
+ });
+}
+function sun(g, x, y, R, lt, k = 1) {
+ at(g, x, y, k, h => {
+ h.save(); h.rotate(lt * 0.4); h.fillStyle = C.orange; h.strokeStyle = C.ink; h.lineWidth = 4; h.lineJoin = 'round';
+ h.beginPath(); for (let i = 0; i < 24; i++) { const a = i * TAU / 24, rr = i % 2 ? R * 1.12 : R * 1.36; h.lineTo(Math.cos(a) * rr, Math.sin(a) * rr); } h.closePath(); h.fill(); h.stroke(); h.restore();
+ h.beginPath(); h.arc(0, 0, R, 0, TAU); h.fillStyle = C.yel; h.fill(); h.lineWidth = 4.5; h.strokeStyle = C.ink; h.stroke();
+ h.fillStyle = 'rgba(255,255,255,0.6)'; h.beginPath(); h.ellipse(-R * 0.4, -R * 0.45, R * 0.18, R * 0.09, -0.7, 0, TAU); h.fill();
+ });
+}
+function sat(g, x, y, k, tw = 0, rot = 0) { // 扁平小卫星
+ if (k <= 0.001) return;
+ g.save(); g.translate(x, y); g.rotate(rot); g.scale(k, k); g.lineWidth = 2.5; g.strokeStyle = C.ink; g.lineJoin = 'round'; g.lineCap = 'round';
+ g.beginPath(); g.moveTo(0, -10); g.lineTo(0, -17); g.stroke(); g.fillStyle = C.red; g.beginPath(); g.arc(0, -18, 3, 0, TAU); g.fill(); g.stroke();
+ for (const d of [-1, 1]) { const x0 = d < 0 ? -22 : 10; g.fillStyle = C.blue; g.fill(rrp(x0, -8, 12, 16, 2)); g.stroke(rrp(x0, -8, 12, 16, 2)); g.beginPath(); g.moveTo(x0, 0); g.lineTo(x0 + 12, 0); g.stroke(); }
+ g.fillStyle = C.steel; g.fill(rrp(-10, -10, 20, 20, 5)); g.stroke(rrp(-10, -10, 20, 20, 5));
+ if (tw > 0) spark(g, 15, -15, 9 * tw, C.white);
+ g.restore();
+}
+function iss(g, x, y, s = 1, rot = 0) { // 空间站:桁架+四对太阳翼+舱段
+ g.save(); g.translate(x, y); g.rotate(rot); g.scale(s, s); g.lineWidth = 3.5 / s * s; g.strokeStyle = C.ink; g.lineJoin = 'round';
+ g.fillStyle = C.tile; g.fill(rrp(-150, -6, 300, 12, 4)); g.stroke(rrp(-150, -6, 300, 12, 4));
+ for (const px of [-128, -84, 84, 128]) for (const d of [-1, 1]) { g.fillStyle = C.blue; const p = rrp(px - 17, d < 0 ? -92 : 10, 34, 82, 4); g.fill(p); g.stroke(p);
+ g.beginPath(); for (let i = 1; i < 4; i++) { const yy = (d < 0 ? -92 : 10) + i * 20.5; g.moveTo(px - 17, yy); g.lineTo(px + 17, yy); } g.stroke(); }
+ g.fillStyle = C.white; const m1 = rrp(-46, -20, 92, 40, 16); g.fill(m1); g.stroke(m1);
+ const m2 = rrp(-16, 14, 32, 58, 12); g.fill(m2); g.stroke(m2);
+ g.fillStyle = C.steelD; g.beginPath(); g.arc(0, 0, 9, 0, TAU); g.fill(); g.stroke();
+ g.restore();
+}
+function capsule(g, x, y, s = 1, { rot = 0, crew = 0, flame = 0, lt = 0, cargo = false } = {}) { // 龙飞船(扁平):截锥舱体+鼻锥盖+一排小舷窗+底部隔热罩,底部中心为原点;cargo=货运龙(带尾段和两片太阳翼)
+ g.save(); g.translate(x, y); g.rotate(rot); g.scale(s, s); g.lineWidth = 4; g.strokeStyle = C.ink; g.lineJoin = 'round';
+ if (cargo) { for (const d of [-1, 1]) { g.fillStyle = C.blue; const p = rrp(d < 0 ? -190 : 62, 40, 128, 34, 4); g.fill(p); g.stroke(p); g.beginPath(); for (let i = 1; i < 4; i++) { const xx = (d < 0 ? -190 : 62) + i * 32; g.moveTo(xx, 40); g.lineTo(xx, 74); } g.stroke(); }
+ g.fillStyle = C.white; g.fill(rrp(-56, 8, 112, 96, 6)); g.stroke(rrp(-56, 8, 112, 96, 6)); g.fillStyle = C.tile; g.fill(rrp(-56, 44, 112, 22, 3)); }
+ if (flame) RK.flame(g, 0, cargo ? 104 : 4, 46 * flame, 30, lt);
+ g.beginPath(); g.moveTo(-56, 0); g.lineTo(56, 0); g.lineTo(32, -96); g.lineTo(-32, -96); g.closePath(); g.fillStyle = C.white; g.fill(); g.stroke();
+ g.beginPath(); g.moveTo(-32, -96); g.quadraticCurveTo(-30, -128, 0, -130); g.quadraticCurveTo(30, -128, 32, -96); g.closePath(); g.fillStyle = C.steel; g.fill(); g.stroke(); // 鼻锥盖
+ g.lineWidth = 3; g.beginPath(); g.moveTo(-44, -48); g.lineTo(44, -48); g.stroke(); // 舱段接缝
+ g.fillStyle = C.tile; for (const wx of [-27, -9, 9, 27]) { g.beginPath(); g.arc(wx, -70, 5.5, 0, TAU); g.fill(); } // 一排小舷窗
+ g.lineWidth = 4; g.fillStyle = C.tile; g.fill(L_rrp(-58, -6, 116, 14, 6)); g.stroke(L_rrp(-58, -6, 116, 14, 6));
+ g.restore();
+}
+function astro(g, x, y, s = 1) { // 宇航员图标:头盔面罩不透明,无脸
+ g.save(); g.translate(x, y); g.scale(s, s); g.lineWidth = 4; g.strokeStyle = C.ink; g.lineJoin = 'round';
+ g.fillStyle = C.white; g.beginPath(); g.moveTo(-46, 70); g.quadraticCurveTo(-48, 10, 0, 8); g.quadraticCurveTo(48, 10, 46, 70); g.closePath(); g.fill(); g.stroke();
+ g.fillStyle = C.blue; g.fill(rrp(-14, 26, 28, 20, 5)); g.stroke(rrp(-14, 26, 28, 20, 5));
+ g.beginPath(); g.arc(0, -24, 40, 0, TAU); g.fillStyle = C.white; g.fill(); g.stroke();
+ g.beginPath(); g.ellipse(2, -22, 28, 21, 0, 0, TAU); g.fillStyle = C.tile; g.fill(); g.stroke();
+ g.fillStyle = 'rgba(255,255,255,0.5)'; g.beginPath(); g.ellipse(-8, -30, 9, 5, -0.5, 0, TAU); g.fill();
+ g.restore();
+}
+function person(g, x, y, s = 1, col = C.mute) { // 无脸人形图标
+ g.save(); g.translate(x, y); g.scale(s, s); g.lineWidth = 4; g.strokeStyle = C.ink; g.fillStyle = col;
+ g.beginPath(); g.moveTo(-40, 60); g.quadraticCurveTo(-42, 8, 0, 6); g.quadraticCurveTo(42, 8, 40, 60); g.closePath(); g.fill(); g.stroke();
+ g.beginPath(); g.arc(0, -24, 26, 0, TAU); g.fill(); g.stroke(); g.restore();
+}
+function coin(g, x, y, r = 42, th = 11) {
+ g.lineWidth = 2.5; g.strokeStyle = C.ink; const ry = r * 0.31;
+ g.beginPath(); g.ellipse(x, y, r, ry, 0, 0, Math.PI); g.lineTo(x - r, y - th); g.ellipse(x, y - th, r, ry, 0, Math.PI, 0, true); g.closePath(); g.fillStyle = C.goldD; g.fill(); g.stroke();
+ g.beginPath(); g.ellipse(x, y - th, r, ry, 0, 0, TAU); g.fillStyle = C.gold; g.fill(); g.stroke();
+ g.beginPath(); g.ellipse(x, y - th, r * 0.62, ry * 0.55, 0, 0, TAU); g.strokeStyle = 'rgba(43,42,51,0.35)'; g.lineWidth = 2; g.stroke();
+}
+function flatCoin(g, x, y, r = 30) { // 正面金币
+ g.save(); g.lineWidth = 3.5; g.strokeStyle = C.ink; g.beginPath(); g.arc(x, y, r, 0, TAU); g.fillStyle = C.gold; g.fill(); g.stroke();
+ g.beginPath(); g.arc(x, y, r * 0.66, 0, TAU); g.strokeStyle = 'rgba(43,42,51,0.35)'; g.lineWidth = 2.5; g.stroke();
+ g.font = F(r * 0.9, 'Black'); g.fillStyle = C.goldD; g.textAlign = 'center'; g.textBaseline = 'middle'; g.fillText('$', x, y + r * 0.04); g.restore();
+}
+// 日历页(2026 上方红条+大字),以中心为原点
+function calPage(g, top, big, col = C.red, unit = '', { w = 220, h = 220, bigSize } = {}) {
+ const x = -w / 2, y = -h / 2;
+ card(g, x, y, w, h, { r: 22 });
+ g.save(); g.clip(rrp(x, y, w, h, 22)); g.fillStyle = col; g.fillRect(x, y, w, h * 0.29); g.restore();
+ g.lineWidth = 4; g.strokeStyle = C.ink; g.beginPath(); g.moveTo(x, y + h * 0.29); g.lineTo(x + w, y + h * 0.29); g.stroke(); g.stroke(rrp(x, y, w, h, 22));
+ for (const dx of [-w * 0.25, w * 0.25]) { g.fillStyle = C.white; g.fill(rrp(dx - 8, y - 18, 16, 36, 8)); g.stroke(rrp(dx - 8, y - 18, 16, 36, 8)); }
+ txt(g, top, 0, y + h * 0.145 + 2, h * 0.155, { col: C.white, align: 'center', base: 'middle' });
+ const bs = bigSize || h * (unit ? 0.47 : 0.42);
+ if (unit) { const bw = tw(big, bs, 'Black', g), uw = tw(unit, h * 0.155, 'Bold', g), x0 = -(bw + uw + 6) / 2;
+ txt(g, big, x0, y + h * 0.66, bs, { w: 'Black', base: 'middle' }); txt(g, unit, x0 + bw + 6, y + h * 0.82, h * 0.155, { w: 'Bold', col: C.sub }); }
+ else txt(g, big, 0, y + h * 0.66, bs, { w: 'Black', align: 'center', base: 'middle' });
+}
+function stopwatch(g, x, y, R, frac, { col = C.red, k = 1 } = {}) {
+ at(g, x, y, k, h => {
+ h.lineWidth = 4.5; h.strokeStyle = C.ink; h.lineJoin = 'round';
+ h.fillStyle = C.tile; h.fill(rrp(-16, -R - 30, 32, 22, 6)); h.stroke(rrp(-16, -R - 30, 32, 22, 6));
+ h.beginPath(); h.arc(0, 0, R, 0, TAU); h.fillStyle = C.white; h.fill(); h.stroke();
+ h.beginPath(); h.moveTo(0, 0); h.arc(0, 0, R - 12, -Math.PI / 2, -Math.PI / 2 + TAU * frac); h.closePath(); h.fillStyle = col; h.save(); h.globalAlpha *= 0.85; h.fill(); h.restore();
+ for (let i = 0; i < 12; i++) { const a = i * TAU / 12; h.beginPath(); h.moveTo(Math.cos(a) * (R - 4), Math.sin(a) * (R - 4)); h.lineTo(Math.cos(a) * (R - 14), Math.sin(a) * (R - 14)); h.stroke(); }
+ const a = -Math.PI / 2 + TAU * frac; h.lineWidth = 6; h.lineCap = 'round'; h.beginPath(); h.moveTo(0, 0); h.lineTo(Math.cos(a) * (R - 18), Math.sin(a) * (R - 18)); h.stroke();
+ h.beginPath(); h.arc(0, 0, 8, 0, TAU); h.fillStyle = C.ink; h.fill();
+ });
+}
+// 顶部徽章(知识点标题):左上角彩色胶囊
+function pageTitle(g, lt, s, t0, { col = C.blue, x = 120, y = 104, size = 42, num } = {}) {
+ const k = popK(lt, t0, 0.42, 1.8); if (k <= 0) return;
+ const pk = LIN.CUR_T != null ? pushK(LIN.CUR_T) : 0; if (pk >= 0.98) return; // 镜头推近时页眉让开,不被切半截
+ g.save(); g.globalAlpha *= 1 - pk;
+ at(g, x, y, k, h => {
+ let ox = 0;
+ if (num) { h.beginPath(); h.arc(30, 0, 30, 0, TAU); h.fillStyle = C.ink; h.fill(); txt(h, num, 30, 2, 32, { col: C.white, align: 'center', base: 'middle', w: 'Black' }); ox = 70; }
+ kw(h, s, ox, 0, { size, fill: col, align: 'left', sh: 5 });
+ }, 0.02 * Math.sin(lt * 1.6));
+ g.restore();
+}
+
+// ---------- 背景:米白纸+淡点阵(缓存)+漂浮小涂鸦 ----------
+const bgImg = () => PAINT.cached('lin_bg', W, H, g => {
+ g.fillStyle = C.bg; g.fillRect(0, 0, W, H);
+ g.fillStyle = C.dot; for (let y = 30; y < H; y += 44) for (let x = 30; x < W; x += 44) { g.beginPath(); g.arc(x, y, 2.4, 0, TAU); g.fill(); }
+ const r = rng(1107); g.fillStyle = 'rgba(120,100,70,0.05)'; for (let i = 0; i < 2600; i++) g.fillRect(r() * W, r() * H, 2, 2);
+});
+const DOODLE_POS = [[110, 200], [560, 92], [1860, 230], [1880, 470], [1856, 800], [700, 1000], [1240, 1010], [1600, 1000], [70, 560], [1030, 60], [1500, 160]];
+function bg(g, lt, { seed = 2611, skip = [] } = {}) {
+ g.drawImage(bgImg(), 0, 0);
+ const r = rng(seed);
+ g.save(); g.lineWidth = 3.5; g.lineCap = 'round'; g.lineJoin = 'round';
+ DOODLE_POS.forEach(([x0, y0], i) => {
+ const kind = Math.floor(r() * 4), s = 15 + r() * 12, ph = r() * TAU, col = [C.pink, C.yel, C.blue, C.teal][Math.floor(r() * 4)];
+ if (skip.includes(i)) return;
+ const x = x0 + 6 * Math.sin(lt * 0.9 + ph), y = y0 + 8 * Math.sin(lt * 1.3 + ph * 1.7);
+ g.save(); g.translate(x, y); g.rotate(0.35 * Math.sin(lt * 0.7 + ph)); g.globalAlpha = 0.5; g.strokeStyle = col; g.fillStyle = col;
+ if (kind === 0) { g.beginPath(); g.moveTo(-s, 0); g.lineTo(s, 0); g.moveTo(0, -s); g.lineTo(0, s); g.stroke(); }
+ else if (kind === 1) { g.beginPath(); g.arc(0, 0, s * 0.7, 0, TAU); g.stroke(); }
+ else if (kind === 2) { g.beginPath(); for (let k = 0; k <= 12; k++) g.lineTo(-s * 1.3 + k * s * 2.6 / 12, Math.sin(k * 1.3) * s * 0.35); g.stroke(); }
+ else { g.globalAlpha = 0.42; spark(g, 0, 0, s * 0.9, col); }
+ g.restore();
+ });
+ g.restore();
+}
+// 页面相机:以 (cx,cy) 为中心缩放 s,再平移
+function cam(g, s, cx = W / 2, cy = H / 2, dx = 0, dy = 0) { g.translate(cx + dx, cy + dy); g.scale(s, s); g.translate(-cx, -cy); }
+
+// ---------- 讲解员(AI 帧,代码只管位置、朝向、换帧、挤压回弹和材质) ----------
+const META = window.LIN_META || {};
+const POSES = Object.keys(META);
+(window.EXTRA_ASSETS = window.EXTRA_ASSETS || []).push(...POSES.flatMap(p => META[p].map(f => f.src)));
+const BODY = 780; // 统一「帽顶到脚底」身高(sprite 像素)
+const POSE_K = {}; for (const p of POSES) { const b = META[p].map(f => f.body).sort((a, b) => a - b); POSE_K[p] = BODY / b[Math.floor(b.length / 2)]; }
+// 坐姿只画到坐面、胸像只画到胸口:按站姿「帽顶→胯」530px、「帽顶→胸口」367px 对齐,和站着的同一个大小
+if (META.sit) POSE_K.sit = 530 / META.sit[0].body; if (META.bust) POSE_K.bust = 367 / META.bust[0].body;
+const SHADOWS = {};
+function shadowOf(src) { // 材质:贴纸卡同款错位硬阴影(墨色 14%)
+ if (SHADOWS[src]) return SHADOWS[src];
+ const im = window.IMG[src], c = document.createElement('canvas'); c.width = im.width; c.height = im.height;
+ const g = c.getContext('2d'); g.drawImage(im, 0, 0); g.globalCompositeOperation = 'source-in'; g.fillStyle = 'rgb(43,42,51)'; g.fillRect(0, 0, c.width, c.height);
+ return (SHADOWS[src] = c);
+}
+const CAST = []; // 全片关键帧(全片秒)
+// cast(id, [{t, pose, fr, x, y, s, flip, walk}...]):t 是本段局部秒;walk>0 表示从上一个位置走过来(用 walk 帧)
+function cast(id, keys) { const t0 = T0(id); for (const k of keys) CAST.push({ ...k, T: t0 + k.t, id }); CAST.sort((a, b) => a.T - b.T); }
+const TALK = [1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1];
+const WALK_FPS = 10; // 只在张嘴/闭嘴之间换(8.5fps),不让手势跟着口型抖
+const ALT = { stick: 1, present: 1, shrug: 1, lookup: 1, point: 1 }; // 这些姿势第 3 帧是另一个手势:说话时每 1.4 秒换一次手势
+const LIFT = { cheer: [0, 90, 0] }; // 跳起来那帧离地(sprite 像素)
+function presenterState(T) {
+ let i = -1; for (let j = 0; j < CAST.length; j++) if (CAST[j].T <= T + 1e-9) i = j;
+ if (i < 0) return null;
+ const k = CAST[i], prev = CAST[i - 1] || k;
+ const st = { pose: k.pose, x: k.x ?? 300, y: k.y ?? 908, s: k.s ?? 0.66, flip: !!k.flip, fr: k.fr ?? 'talk', T0: k.T, hide: !!k.hide, enter: k.enter };
+ // 位置/大小继承:没写就沿用上一个关键帧
+ for (let j = i; j >= 0; j--) { if (CAST[j].x != null) { st.x = CAST[j].x; break; } }
+ for (let j = i; j >= 0; j--) { if (CAST[j].s != null) { st.s = CAST[j].s; break; } }
+ for (let j = i; j >= 0; j--) { if (CAST[j].y != null) { st.y = CAST[j].y; break; } }
+ if (k.glide) { // 滑动换位/缩放(不走路):大画面时缩到角落、讲完再回来
+ let px = st.x, ps = st.s; for (let j = i - 1; j >= 0; j--) if (CAST[j].x != null) { px = CAST[j].x; break; }
+ for (let j = i - 1; j >= 0; j--) if (CAST[j].s != null) { ps = CAST[j].s; break; }
+ const u = MO.cubicInOut(clamp((T - k.T) / k.glide)); st.x = lerp(px, st.x, u); st.s = lerp(ps, st.s, u);
+ }
+ if (k.walk) {
+ let px = st.x; for (let j = i - 1; j >= 0; j--) if (CAST[j].x != null) { px = CAST[j].x; break; }
+ const u = clamp((T - k.T) / k.walk);
+ if (u < 1) { st.walking = true; st.pose = 'walk'; st.flip = k.x < px; st.x = lerp(px, st.x, MO.sineInOut(u)); st.fr = 'walk'; st.wT = T - k.T; }
+ else st.T0 = k.T + k.walk;
+ }
+ return st;
+}
+function presenterFrame(st, T) {
+ const fr = META[st.pose], n = fr.length, dt = T - st.T0, f8 = Math.floor(T * 8.5 + 1e-6), wT = st.wT ?? dt;
+ let fi = 0;
+ if (st.fr === 'walk') fi = Math.floor(wT * WALK_FPS + 1e-6) % n;
+ else if (st.fr === 'talk') { fi = speakingAt(T) ? TALK[f8 % TALK.length] : 0; if (fi === 1 && n > 2 && ALT[st.pose] && Math.floor(dt / 1.4) % 2 === 1) fi = 2; }
+ else if (st.fr === 'cycle') fi = Math.floor(dt * 3 + 1e-6) % n;
+ else if (st.fr === 'loop') fi = f8 % n;
+ else if (st.fr === 'bounce') fi = [0, 1, 2, 1][Math.floor(T * 4 + 1e-6) % 4] % n; // 4fps:跳得开心但不抽
+ else if (typeof st.fr === 'number') fi = Math.min(n - 1, st.fr);
+ else if (Array.isArray(st.fr)) { const sq = st.fr; let v = sq[0]; for (const [tt, ff] of sq) if (dt >= tt) v = ff; fi = typeof v === 'number' ? v : 0; if (v === 'talk') fi = speakingAt(T) ? TALK[f8 % TALK.length] : 0; }
+ return fi;
+}
+function drawFigure(g, st, T, alpha, withShadow) {
+ const fr = META[st.pose], fi = presenterFrame(st, T), m = fr[fi], im = window.IMG[m.src]; if (!im) return;
+ const dt = T - st.T0, wT = st.wT ?? dt, walking = st.walking || st.fr === 'walk', kk = POSE_K[st.pose] * st.s;
+ const sq = walking ? 0 : MO.settle(dt, 0.1, 3, 6), pop = walking ? 1 : 0.93 + 0.07 * MO.backOut(clamp(dt / 0.16), 3); // 换姿势:先缩一下再弹出+挤压回弹
+ const br = 1 + 0.007 * Math.sin(T * TAU / 1.7); // 呼吸
+ const talkBob = !walking && speakingAt(T) ? 0.012 * Math.abs(Math.sin(T * 8.5)) : 0; // 说话时身体跟着节奏轻点
+ const sway = walking ? 0 : 0.018 * Math.sin(T * 1.25 + 0.7) + 0.008 * Math.sin(T * 2.9); // 站着也不僵:绕脚底轻轻摇
+ const bob = (walking ? -Math.abs(Math.sin(wT * WALK_FPS * Math.PI / (META.walk.length / 2))) * 7 : 0) - (LIFT[st.pose] ? LIFT[st.pose][fi] * st.s : 0);
+ if (withShadow) { g.save(); g.globalAlpha *= alpha; g.fillStyle = 'rgba(43,42,51,0.12)'; g.beginPath(); g.ellipse(st.x, st.y + 6, 150 * st.s, 20 * st.s, 0, 0, TAU); g.fill(); g.restore(); }
+ g.save(); g.translate(st.x, st.y + bob); g.rotate(sway); g.scale((st.flip ? -1 : 1) * kk * pop * (1 - sq * 0.5), kk * pop * (1 + sq + talkBob) * br);
+ g.globalAlpha = 0.15 * alpha; g.drawImage(shadowOf(m.src), -m.ax + (st.flip ? -16 : 16), -m.ay + 10, m.w, m.h); // 材质:贴纸卡同款错位硬阴影
+ g.globalAlpha = alpha; g.drawImage(im, -m.ax, -m.ay, m.w, m.h);
+ g.restore();
+}
+// 反应特写卡:一张贴纸卡里的胸像(大头特写),出现时全身讲解员让位——景别真的变了,不是推镜
+const BUSTS = [];
+function bustCard(id, a, b, frames, { x = 70, y = 300, w = 520, h = 590 } = {}) { BUSTS.push({ a: T0(id) + a, b: T0(id) + b, frames: frames.map(([t, f]) => [T0(id) + t, f]), x, y, w, h }); }
+function drawBust(g, T) {
+ for (const B of BUSTS) { if (T < B.a || T > B.b || !META.bust) continue;
+ const kin = MO.backOut(clamp((T - B.a) / 0.28), 2.2), kout = 1 - MO.cubicIn(clamp((T - (B.b - 0.18)) / 0.18)), k = Math.max(0, Math.min(kin, kout));
+ let fi = B.frames[0][1]; for (const [t, f] of B.frames) if (T >= t) fi = f;
+ if (fi === 'talk') fi = speakingAt(T) ? TALK[Math.floor(T * 8.5 + 1e-6) % TALK.length] : 0;
+ const m = META.bust[fi], im = window.IMG[m.src]; if (!im) return true;
+ g.save(); g.translate(B.x + B.w / 2, B.y + B.h); g.scale(k, k); g.rotate(-0.03 + 0.012 * Math.sin(T * 2));
+ const rr = rrp(-B.w / 2, -B.h, B.w, B.h, 34);
+ g.save(); g.translate(10, 12); g.fillStyle = C.shadow; g.fill(rr); g.restore();
+ g.fillStyle = C.blueL; g.fill(rr);
+ g.save(); g.clip(rr); const sc = (B.w * 0.98) / m.w, bob = speakingAt(T) ? 4 * Math.abs(Math.sin(T * 8.5)) : 0;
+ g.drawImage(im, -m.w * sc / 2, -m.h * sc + 6 - bob, m.w * sc, m.h * sc); g.restore();
+ g.lineWidth = 6; g.strokeStyle = C.ink; g.stroke(rr);
+ g.restore(); return true; }
+ return false;
+}
+function drawPresenter(g, T) {
+ if (drawBust(g, T)) return;
+ const st = presenterState(T); if (!st || st.hide || !META[st.pose]) return;
+ // 换姿势不硬切:0.12 秒交叉溶解+挤压回弹
+ const dt = T - st.T0, XF = 0; // 不做溶解,硬切+弹一下
+ if (dt < XF && dt >= 0) { const pv = presenterState(st.T0 - 1e-4);
+ if (pv && !pv.hide && META[pv.pose] && pv.pose !== st.pose && pv.pose !== 'walk' && st.pose !== 'walk' && Math.abs(pv.x - st.x) < 5) { const a = dt / XF; drawFigure(g, st, T, 1, true); drawFigure(g, pv, T, 1 - a, false); return; } }
+ drawFigure(g, st, T, 1, true);
+}
+
+// ---------- 顶栏时间轴(2002 → 2026,全片秒驱动) ----------
+const TL = { x0: 1300, x1: 1700, y: 72, y0: 2002, y1: 2026 };
+const yearX = y => lerp(TL.x0, TL.x1, (y - TL.y0) / (TL.y1 - TL.y0));
+const YEARKEYS = []; // [T, year]
+function year(id, keys) { const t0 = T0(id); for (const [lt, y] of keys) YEARKEYS.push([t0 + lt, y]); YEARKEYS.sort((a, b) => a[0] - b[0]); }
+function yearAt(T) {
+ let v = YEARKEYS.length ? YEARKEYS[0][1] : 2002, from = v, t = -9;
+ for (let i = 0; i < YEARKEYS.length; i++) { if (YEARKEYS[i][0] <= T) { from = i ? YEARKEYS[i - 1][1] : YEARKEYS[i][1]; v = YEARKEYS[i][1]; t = YEARKEYS[i][0]; } }
+ // 相邻年份(≤3 年)滚过去;大跳(2026→2002、2019→现在)直接换,不倒着滚
+ const big = Math.abs(v - from) > 5, u = big ? (T >= t ? 1 : 0) : MO.cubicInOut(clamp((T - t) / 0.35));
+ return { y: lerp(from, v, u), target: v, moving: u > 0 && u < 1, since: T - t };
+}
+let HUD_ON = 0, HUD_OFF = 1e9; // 全片秒:顶栏出现的时刻(s01 标题卡收进来)
+function hud(g, T) {
+ if (T < HUD_ON) return;
+ const k = clamp((T - HUD_ON) / 0.5) * (1 - clamp((T - HUD_OFF) / 0.4)), Y = yearAt(T);
+ if (k <= 0) return;
+ const x = yearX(Math.min(Y.y, 2026.6)), fut = Math.max(0, Y.y - 2026);
+ g.save(); g.globalAlpha *= k;
+ // 底卡
+ card(g, TL.x0 - 150, TL.y - 34, TL.x1 - TL.x0 + 300, 68, { fill: 'rgba(255,255,255,0.92)', r: 34, lw: 3.5, sh: 5 });
+ txt(g, '2002', TL.x0 - 62, TL.y + 1, 26, { w: 'Heavy', col: C.sub, align: 'right', base: 'middle' });
+ g.save(); g.globalAlpha *= 1 - clamp((Y.y - 2025.2) / 0.4); txt(g, '2026', TL.x1 + 62, TL.y + 1, 26, { w: 'Heavy', col: C.sub, align: 'left', base: 'middle' }); g.restore();
+ g.lineCap = 'round'; g.lineWidth = 8; g.strokeStyle = '#E7DFD0'; g.beginPath(); g.moveTo(TL.x0, TL.y); g.lineTo(TL.x1, TL.y); g.stroke();
+ g.strokeStyle = C.red; g.beginPath(); g.moveTo(TL.x0, TL.y); g.lineTo(Math.min(x, TL.x1), TL.y); g.stroke();
+ // 走过的里程碑小点
+ for (const yy of [2002, 2008, 2012, 2015, 2018, 2020, 2025, 2026]) { const px = yearX(yy), on = px <= x + 1;
+ g.beginPath(); g.arc(px, TL.y, 6, 0, TAU); g.fillStyle = on ? C.red : C.white; g.fill(); g.lineWidth = 2.5; g.strokeStyle = C.ink; g.stroke(); }
+ // 当前位置:年份小牌(跟着走,动的时候轻轻歪一下)
+ const wob = Y.moving ? 0.12 * Math.sin(T * 30) : MO.settle(Y.since - 0.35, 0.12, 2.5, 5);
+ g.save(); g.translate(x, TL.y); g.rotate(wob);
+ const lab = fut > 0.5 ? '未来' : String(Math.round(Y.y));
+ card(g, -48, -22, 96, 44, { fill: C.ink, r: 22, lw: 0, sh: 0 }); txt(g, lab, 0, 2, 28, { col: C.white, align: 'center', base: 'middle', w: 'Black' });
+ g.restore();
+ g.restore();
+}
+
+// ---------- 全片叠加层 ----------
+const FRONT = {}; // 段 id → (c, lt, T) 画在讲解员前面的东西
+// 全片镜头推近(连讲解员一起推):高光时刻用,push(id, 起, 止, 倍数, 中心x, 中心y)
+const PUSHES = [];
+function push(id, a, b, z, x = W / 2, y = H / 2, cut = false, then) { PUSHES.push({ a: T0(id) + a, b: T0(id) + b, z, x, y, cut, then: then && { ...then, t: T0(id) + then.t } }); } // then:{t, z, x, y} 推到一半再推进一层 // cut=硬切的反应特写(不推不拉)
+function pushAt(T) { for (const p of PUSHES) { if (T < p.a || T > p.b) continue; if (p.cut) return { z: p.z, x: p.x, y: p.y }; const k = Math.min(MO.cubicInOut(clamp((T - p.a) / 0.45)), 1 - MO.cubicInOut(clamp((T - (p.b - 0.4)) / 0.4)));
+ if (k > 0) { if (p.then && T > p.then.t) { const u = MO.cubicInOut(clamp((T - p.then.t) / 0.6)); return { z: lerp(1 + (p.z - 1) * k, p.then.z, u), x: lerp(p.x, p.then.x, u), y: lerp(p.y, p.then.y, u) }; }
+ return { z: 1 + (p.z - 1) * k, x: p.x, y: p.y }; } } return null; }
+function pushK(T) { for (const p of PUSHES) { if (T < p.a || T > p.b) continue; if (p.cut) return 1; const k = Math.min(MO.cubicInOut(clamp((T - p.a) / 0.45)), 1 - MO.cubicInOut(clamp((T - (p.b - 0.4)) / 0.4))); if (k > 0) return k; } return 0; }
+let TMP = null;
+// 顶栏在高光处让位
+const HUD_HIDE = [];
+function hudHide(id, a, b) { HUD_HIDE.push([T0(id) + a, T0(id) + b]); }
+function hudVis(T) { let v = 1; for (const [a, b] of HUD_HIDE) v = Math.min(v, 1 - Math.min(clamp((T - a) / 0.25), clamp((b - T) / 0.25))); return v; }
+window.GLOBAL_OVERLAY = (c, T) => {
+ drawPresenter(c, T);
+ let id = null; for (const k in TIMING.seg) { const s = TIMING.seg[k]; if (T >= s.t0 && T < s.t0 + s.dur) id = k; }
+ if (id && FRONT[id]) FRONT[id](c, T - T0(id), T);
+ const P = pushAt(T);
+ if (P) { if (!TMP) { TMP = document.createElement('canvas'); TMP.width = W; TMP.height = H; }
+ const t = TMP.getContext('2d'); t.clearRect(0, 0, W, H); t.drawImage(c.canvas, 0, 0);
+ c.save(); c.setTransform(1, 0, 0, 1, 0, 0); c.fillStyle = C.bg; c.fillRect(0, 0, W, H); c.translate(P.x, P.y); c.scale(P.z, P.z); c.translate(-P.x, -P.y); c.drawImage(TMP, 0, 0); c.restore(); }
+ c.save(); c.globalAlpha = hudVis(T); if (c.globalAlpha > 0.01) hud(c, T); c.restore();
+};
+
+window.LIN = { W, H, TAU, C, F, T0, cueN, popK, inK, outK, boil, speakingAt, rrp, card, at, txt, tw, kw, marker, jitter, strokePart, arrow, ring, underline, spark, twinkles,
+ burstLines, confetti, puff, stamp, dust, rocket, F1, F9, F9B, SS_PAL, earth, planet, sun, sat, iss, capsule, astro, person, coin, flatCoin, calPage, stopwatch, pageTitle,
+ bg, cam, cast, year, yearX, FRONT, push, hudHide, pushK, bustCard, CUR_T: null, presenterState, setHud: T => { HUD_ON = T; }, setHudOff: T => { HUD_OFF = T; }, TL, META };
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex_lin/presenter_meta.js b/scripts/engine/reference_films/spacex/spacex_lin/presenter_meta.js
new file mode 100644
index 0000000..4d4f536
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_lin/presenter_meta.js
@@ -0,0 +1,2 @@
+// 由 tools/prep_presenter.py 生成,勿手改
+window.LIN_META = {"bust": [{"src": "spacex_lin/assets/p_bust_0.png", "w": 640, "h": 705, "ax": 319.7, "ay": 705, "top": 8, "body": 697}, {"src": "spacex_lin/assets/p_bust_1.png", "w": 639, "h": 705, "ax": 319.1, "ay": 705, "top": 8, "body": 697}, {"src": "spacex_lin/assets/p_bust_2.png", "w": 639, "h": 705, "ax": 318.1, "ay": 705, "top": 8, "body": 697}, {"src": "spacex_lin/assets/p_bust_3.png", "w": 641, "h": 705, "ax": 320.0, "ay": 705, "top": 8, "body": 697}], "cheer": [{"src": "spacex_lin/assets/p_cheer_0.png", "w": 410, "h": 765, "ax": 204.6, "ay": 765, "top": 6, "body": 759}, {"src": "spacex_lin/assets/p_cheer_1.png", "w": 394, "h": 702, "ax": 177.7, "ay": 702, "top": 6, "body": 696}, {"src": "spacex_lin/assets/p_cheer_2.png", "w": 340, "h": 759, "ax": 184.5, "ay": 759, "top": 6, "body": 753}], "count": [{"src": "spacex_lin/assets/p_count_0.png", "w": 386, "h": 787, "ax": 193.2, "ay": 787, "top": 5, "body": 782}, {"src": "spacex_lin/assets/p_count_1.png", "w": 387, "h": 787, "ax": 193.0, "ay": 787, "top": 5, "body": 782}, {"src": "spacex_lin/assets/p_count_2.png", "w": 386, "h": 787, "ax": 192.9, "ay": 787, "top": 5, "body": 782}], "lean": [{"src": "spacex_lin/assets/p_lean_0.png", "w": 384, "h": 794, "ax": 167.0, "ay": 794, "top": 6, "body": 788}, {"src": "spacex_lin/assets/p_lean_1.png", "w": 384, "h": 794, "ax": 167.5, "ay": 794, "top": 6, "body": 788}, {"src": "spacex_lin/assets/p_lean_2.png", "w": 384, "h": 794, "ax": 167.6, "ay": 794, "top": 6, "body": 788}], "lookup": [{"src": "spacex_lin/assets/p_lookup_0.png", "w": 350, "h": 787, "ax": 191.9, "ay": 787, "top": 7, "body": 780}, {"src": "spacex_lin/assets/p_lookup_1.png", "w": 355, "h": 786, "ax": 197.3, "ay": 786, "top": 7, "body": 779}, {"src": "spacex_lin/assets/p_lookup_2.png", "w": 449, "h": 790, "ax": 204.1, "ay": 790, "top": 7, "body": 783}], "nervous": [{"src": "spacex_lin/assets/p_nervous_0.png", "w": 401, "h": 799, "ax": 206.0, "ay": 799, "top": 6, "body": 793}, {"src": "spacex_lin/assets/p_nervous_1.png", "w": 402, "h": 799, "ax": 206.0, "ay": 799, "top": 6, "body": 793}, {"src": "spacex_lin/assets/p_nervous_2.png", "w": 397, "h": 779, "ax": 210.6, "ay": 779, "top": 6, "body": 773}], "present": [{"src": "spacex_lin/assets/p_present_0.png", "w": 441, "h": 776, "ax": 190.6, "ay": 776, "top": 5, "body": 771}, {"src": "spacex_lin/assets/p_present_1.png", "w": 441, "h": 776, "ax": 190.4, "ay": 776, "top": 5, "body": 771}, {"src": "spacex_lin/assets/p_present_2.png", "w": 436, "h": 777, "ax": 193.8, "ay": 777, "top": 5, "body": 772}], "sad": [{"src": "spacex_lin/assets/p_sad_0.png", "w": 367, "h": 766, "ax": 179.3, "ay": 766, "top": 6, "body": 760}, {"src": "spacex_lin/assets/p_sad_1.png", "w": 374, "h": 774, "ax": 188.9, "ay": 774, "top": 6, "body": 768}, {"src": "spacex_lin/assets/p_sad_2.png", "w": 363, "h": 765, "ax": 168.9, "ay": 765, "top": 6, "body": 759}], "shrug": [{"src": "spacex_lin/assets/p_shrug_0.png", "w": 466, "h": 793, "ax": 230.1, "ay": 793, "top": 6, "body": 787}, {"src": "spacex_lin/assets/p_shrug_1.png", "w": 464, "h": 793, "ax": 230.7, "ay": 793, "top": 6, "body": 787}, {"src": "spacex_lin/assets/p_shrug_2.png", "w": 444, "h": 793, "ax": 225.0, "ay": 793, "top": 6, "body": 787}], "sit": [{"src": "spacex_lin/assets/p_sit_0.png", "w": 454, "h": 625, "ax": 223.6, "ay": 625, "top": 6, "body": 619}, {"src": "spacex_lin/assets/p_sit_1.png", "w": 448, "h": 625, "ax": 225.5, "ay": 625, "top": 6, "body": 619}, {"src": "spacex_lin/assets/p_sit_2.png", "w": 432, "h": 621, "ax": 264.0, "ay": 621, "top": 8, "body": 613}], "stick": [{"src": "spacex_lin/assets/p_stick_0.png", "w": 455, "h": 709, "ax": 168.9, "ay": 709, "top": 6, "body": 703}, {"src": "spacex_lin/assets/p_stick_1.png", "w": 450, "h": 708, "ax": 170.4, "ay": 708, "top": 6, "body": 702}, {"src": "spacex_lin/assets/p_stick_2.png", "w": 462, "h": 709, "ax": 179.0, "ay": 709, "top": 6, "body": 703}], "think": [{"src": "spacex_lin/assets/p_think_0.png", "w": 346, "h": 782, "ax": 192.6, "ay": 782, "top": 6, "body": 776}, {"src": "spacex_lin/assets/p_think_1.png", "w": 346, "h": 782, "ax": 192.1, "ay": 782, "top": 6, "body": 776}, {"src": "spacex_lin/assets/p_think_2.png", "w": 348, "h": 782, "ax": 197.7, "ay": 782, "top": 6, "body": 776}], "thumb": [{"src": "spacex_lin/assets/p_thumb_0.png", "w": 405, "h": 791, "ax": 204.2, "ay": 791, "top": 5, "body": 786}, {"src": "spacex_lin/assets/p_thumb_1.png", "w": 405, "h": 793, "ax": 204.6, "ay": 793, "top": 6, "body": 787}, {"src": "spacex_lin/assets/p_thumb_2.png", "w": 403, "h": 791, "ax": 204.9, "ay": 791, "top": 5, "body": 786}], "walk": [{"src": "spacex_lin/assets/p_walk_0.png", "w": 438, "h": 755, "ax": 206.2, "ay": 755, "top": 7, "body": 748}, {"src": "spacex_lin/assets/p_walk_1.png", "w": 390, "h": 761, "ax": 211.9, "ay": 761, "top": 8, "body": 753}, {"src": "spacex_lin/assets/p_walk_2.png", "w": 371, "h": 784, "ax": 209.1, "ay": 784, "top": 7, "body": 777}, {"src": "spacex_lin/assets/p_walk_3.png", "w": 432, "h": 758, "ax": 215.1, "ay": 758, "top": 8, "body": 750}, {"src": "spacex_lin/assets/p_walk_4.png", "w": 381, "h": 761, "ax": 212.5, "ay": 761, "top": 8, "body": 753}, {"src": "spacex_lin/assets/p_walk_5.png", "w": 376, "h": 777, "ax": 256.6, "ay": 777, "top": 8, "body": 769}], "wave": [{"src": "spacex_lin/assets/p_wave_0.png", "w": 408, "h": 780, "ax": 221.5, "ay": 780, "top": 6, "body": 774}, {"src": "spacex_lin/assets/p_wave_1.png", "w": 423, "h": 778, "ax": 188.3, "ay": 778, "top": 6, "body": 772}, {"src": "spacex_lin/assets/p_wave_2.png", "w": 426, "h": 780, "ax": 196.8, "ay": 780, "top": 6, "body": 774}], "point": [{"src": "spacex_lin/assets/p_point_0.png", "w": 438, "h": 777, "ax": 190.3, "ay": 777, "top": 6, "body": 771}, {"src": "spacex_lin/assets/p_point_1.png", "w": 438, "h": 777, "ax": 190.7, "ay": 777, "top": 6, "body": 771}, {"src": "spacex_lin/assets/p_point_2.png", "w": 425, "h": 777, "ax": 191.5, "ay": 777, "top": 6, "body": 771}], "wow": [{"src": "spacex_lin/assets/p_wow_0.png", "w": 475, "h": 836, "ax": 235.4, "ay": 836, "top": 69, "body": 767}, {"src": "spacex_lin/assets/p_wow_1.png", "w": 505, "h": 850, "ax": 252.0, "ay": 850, "top": 63, "body": 787}, {"src": "spacex_lin/assets/p_wow_2.png", "w": 384, "h": 821, "ax": 196.3, "ay": 821, "top": 59, "body": 762}]};
diff --git a/scripts/engine/reference_films/spacex/spacex_lin/scenes/s01.js b/scripts/engine/reference_films/spacex/spacex_lin/scenes/s01.js
new file mode 100644
index 0000000..5cbd160
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_lin/scenes/s01.js
@@ -0,0 +1,203 @@
+// S01 · 开头钩子(快切段,13 秒六个知识点):第 0 帧就是「2008」+第一张失败卡已盖红叉+讲解员竖一根手指。
+// ① 连败三次:三张猎鹰1号卡依次盖红叉、火箭歪倒冒烟,讲解员 1→2→3 比数字 ② 钱只够最后一发:小猪存钱罐抖出最后一枚金币,飞进第四张卡
+// ③ 9月28号那一发成了:日历弹出,第四枚火箭点火升空,绿勾+彩纸,讲解员跳起来 ④ 整整18年后的同一天:两张 9月28号日历并排、弧线箭头「18年后」、等号
+// ⑤ 星舰第一次进入地球轨道:小地球+轨道虚线,星舰入轨绕圈 ⑥ 两分钟看完这24年:标题卡+秒表+2002→2026 时间轴,时间轴缩进顶栏,成为全片的进度条。
+(() => {
+const ID = 's01', L = LIN, { C, W, H, TAU } = L, { clamp, lerp } = U;
+let Q = null;
+const q = () => Q || (Q = {
+ y08: TM.cue(ID, '2008年'), hj: TM.cue(ID, '火箭'), lb: TM.cue(ID, '连败'), sc: TM.cue(ID, '三次'), qian: TM.cue(ID, '钱只够'), zh: TM.cue(ID, '最后一发'),
+ d928: TM.cue(ID, '9月28号'), nyf: TM.cue(ID, '那一发'), cl: TM.cue(ID, '成了'), zz: TM.cue(ID, '整整'), n18: TM.cue(ID, '18年后'), tyt: TM.cue(ID, '同一天'),
+ xj: TM.cue(ID, '星舰'), dyc: TM.cue(ID, '第一次'), gd: TM.cue(ID, '地球轨道'), lfz: TM.cue(ID, '两分钟'), kw: TM.cue(ID, '看完'), n24: TM.cue(ID, '24年'), end: TM.dur(ID),
+});
+
+// ---------- ① 三张失败卡 ----------
+const CARD_X = [840, 1190, 1540], CARD_Y = 450;
+function failCard(g, lt, i, xT) { // xT:盖红叉的时刻
+ const k = lt - xT;
+ L.card(g, -120, -165, 240, 330, { fill: C.white });
+ // 火箭:盖叉那一刻歪倒,冒烟
+ const fall = MO.backOut(clamp(k / 0.45), 1.4) * 0.62 * (i % 2 ? -1 : 1);
+ g.save(); g.beginPath(); g.rect(-116, -161, 232, 260); g.clip();
+ L.rocket(g, L.F1(), 0, 72, 8.4, { fins: true, rot: fall, sx: 3.6, pal: { nose: C.mute, body: '#F1EEE8' } });
+ if (k > 0) for (let j = 0; j < 3; j++) { const ph = ((lt * 0.7 + j / 3) % 1); g.globalAlpha = 0.5 * (1 - ph); g.fillStyle = '#CFC8BC';
+ g.beginPath(); g.arc(-10 + j * 14 + Math.sin(ph * 6 + j) * 10, 40 - ph * 150, 14 + ph * 22, 0, TAU); g.fill(); }
+ g.restore();
+ L.txt(g, ['2006年', '2007年', '2008年8月'][i], 0, 140, 36, { align: 'center', col: C.sub, w: 'Heavy' });
+ L.stamp(g, 'x', 0, -20, k, { s: 1.25, rot: -0.1 + i * 0.08 });
+}
+function beat1(g, lt) {
+ const Qv = q(), xs = [-0.07, Qv.hj, Qv.sc - 0.05]; // 第 0 帧就是第一个红叉正砸下来
+ // 三张卡在 ② 时缩到上方一排,当背景证据
+ const up = MO.cubicInOut(clamp((lt - (Qv.qian - 0.15)) / 0.45)), gone = L.outK(lt, Qv.d928 - 0.1, 0.3);
+ if (gone >= 1) return;
+ g.save(); g.globalAlpha = 1 - gone;
+ for (let i = 0; i < 3; i++) {
+ const k = 1;
+ const x = lerp(CARD_X[i], 700 + i * 150, up), y = lerp(CARD_Y, 250, up), s = lerp(1.22, 0.42, up);
+ L.at(g, x, y + 4 * Math.sin(lt * 2.2 + i), k * s, h => failCard(h, lt, i, xs[i]), 0.02 * Math.sin(lt * 1.3 + i * 2));
+ }
+ // 「连败三次」
+ const kb = L.popK(lt, Qv.lb, 0.4, 2.6), ob = up;
+ if (kb > 0 && ob < 1) { g.save(); g.globalAlpha *= 1 - ob; L.at(g, 1190, 800, kb, h => { L.kw(h, '连败三次', 0, 0, { size: 72, fill: C.red }); L.burstLines(h, 0, 0, 200, 270, clamp((lt - Qv.lb) / 0.45), { n: 10, col: C.red }); }); g.restore(); }
+ g.restore();
+}
+// ---------- ② 存钱罐 → 最后一枚金币 ----------
+function piggy(g, shake) {
+ g.save(); g.rotate(shake); g.lineWidth = 5; g.strokeStyle = C.ink; g.lineJoin = 'round';
+ for (const lx of [-70, -30, 30, 70]) { g.fillStyle = C.pink; g.fill(L.rrp(lx - 16, 60, 32, 50, 10)); g.stroke(L.rrp(lx - 16, 60, 32, 50, 10)); }
+ g.beginPath(); g.ellipse(0, 0, 150, 108, 0, 0, TAU); g.fillStyle = '#FFB8C6'; g.fill(); g.stroke();
+ g.beginPath(); g.ellipse(146, 4, 30, 38, 0, 0, TAU); g.fillStyle = C.pink; g.fill(); g.stroke();
+ g.fillStyle = C.ink; for (const ny of [-8, 16]) { g.beginPath(); g.ellipse(150, ny, 5, 7, 0, 0, TAU); g.fill(); }
+ g.beginPath(); g.arc(88, -40, 9, 0, TAU); g.fill();
+ g.beginPath(); g.moveTo(40, -96); g.lineTo(70, -150); g.lineTo(100, -88); g.closePath(); g.fillStyle = C.pink; g.fill(); g.stroke();
+ g.fillStyle = C.ink; g.fill(L.rrp(-50, -112, 100, 14, 7));
+ g.restore();
+}
+const LAST = { x: 1400, y: 560 };
+function beat2(g, lt) {
+ const Qv = q(); if (lt < Qv.qian - 0.05) return;
+ const kp = L.popK(lt, Qv.qian + 0.22, 0.4), out = L.outK(lt, Qv.d928 - 0.1, 0.3);
+ const shake = lt > Qv.qian + 0.35 && lt < Qv.zh ? 0.16 * Math.sin(lt * 42) : 0;
+ if (out < 1) L.at(g, 870, 600, kp * (1 - out), h => {
+ piggy(h, shake);
+ // 罐口上方一个「空」的小虚线框:只剩一枚
+ if (lt > Qv.qian + 0.35) { h.save(); h.setLineDash([10, 9]); h.lineWidth = 4; h.strokeStyle = C.mute; h.beginPath(); h.ellipse(0, -170, 60, 22, 0, 0, TAU); h.stroke(); h.restore(); }
+ });
+ // 金币:从罐口弹起,抛物线飞进第四张卡
+ const c0 = Qv.qian + 0.55, c1 = Qv.zh + 0.15, u = clamp((lt - c0) / (c1 - c0));
+ if (lt >= c0 && u < 1) { const e = MO.sineInOut(u), x = lerp(870, LAST.x, e), y = lerp(500, LAST.y - 40, e) - Math.sin(Math.PI * e) * 260;
+ g.save(); g.translate(x, y); g.rotate(lt * 9); g.scale(1, Math.abs(Math.cos(lt * 9)) * 0.8 + 0.2); g.rotate(-lt * 9); L.flatCoin(g, 0, 0, 60); g.restore(); }
+ if (lt >= c0 && u >= 1 && lt < Qv.d928) L.spark(g, LAST.x + 70, LAST.y - 120, 22 * Math.abs(Math.sin((lt - c1) * 6)), C.yel);
+}
+// ---------- 第四张卡:最后一发 → 点火升空 → 成了 ----------
+function beat3(g, lt) {
+ const Qv = q(); if (lt < Qv.zh - 0.1) return;
+ const out = L.outK(lt, Qv.zz - 0.05, 0.3); if (out >= 1) return;
+ const k = L.popK(lt, Qv.zh - 0.05, 0.42, 2.2), x = lerp(LAST.x, 1450, MO.cubicInOut(clamp((lt - Qv.d928) / 0.4)));
+ g.save(); g.globalAlpha = 1 - out;
+ L.at(g, x, LAST.y, k, h => {
+ L.card(h, -140, -190, 280, 380, { fill: C.cream, lw: 5 });
+ const lift = lt < Qv.nyf ? 0 : Math.pow(Math.max(0, lt - Qv.nyf), 2) * 520, fl = lt >= Qv.nyf - 0.15 ? clamp((lt - Qv.nyf + 0.15) / 0.2) : 0;
+ h.save(); h.beginPath(); h.rect(-136, -186, 272, 372); h.clip();
+ if (fl > 0) { for (let j = 0; j < 4; j++) { const ph = (lt * 1.6 + j / 4) % 1; h.globalAlpha = 0.45 * (1 - ph); h.fillStyle = '#E6DFD2'; h.beginPath(); h.arc(-60 + j * 40, 160 - ph * 30, 20 + ph * 26, 0, TAU); h.fill(); } h.globalAlpha = 1; }
+ L.rocket(h, L.F1(), 0, 110 - lift, 9.2, { fins: true, sx: 3.6, flame: fl, lt });
+ h.restore();
+ if (lt < Qv.cl) L.kw(h, '最后一发', 0, 236, { size: 44, fill: C.yel, col: C.ink });
+ else L.kw(h, '成了!', 0, 236, { size: 52, fill: C.green });
+ L.stamp(h, 'v', 0, -10, lt - Qv.cl, { s: 1.6, rot: -0.12 });
+ });
+ g.restore();
+ // 日历 2008 年 9 月 28 号
+ const kc = L.popK(lt, Qv.d928, 0.42, 2.2);
+ // 日历不退场:念到「整整」时它自己挪到左边,变成 ④ 的左日历(beat4 接手)
+ if (kc > 0 && lt < Qv.zz) L.at(g, 890, 560, kc, h => L.calPage(h, '2008年9月', '28', C.red, '号', { w: 280, h: 280 }), -0.05 + 0.02 * Math.sin(lt * 1.5));
+}
+// ---------- ④ 18 年后的同一天 ----------
+const CL = { x: 820, y: 470 }, CR = { x: 1560, y: 470 };
+function beat4(g, lt) {
+ const Qv = q(); if (lt < Qv.zz - 0.05) return;
+ const out = L.outK(lt, Qv.lfz - 0.1, 0.3); if (out >= 1) return;
+ g.save(); g.globalAlpha = 1 - out;
+ const toTop = MO.cubicInOut(clamp((lt - (Qv.xj - 0.1)) / 0.5));
+ const kl = 1, kr = L.popK(lt, Qv.n18 + 0.15, 0.42, 2.4), mv = MO.cubicInOut(clamp((lt - Qv.zz) / 0.4));
+ const lx = lerp(lerp(890, CL.x, mv), 760, toTop), ly = lerp(lerp(560, CL.y, mv), 330, toTop), ls = lerp(lerp(280 / 260, 1, mv), 0.62, toTop);
+ const rx = lerp(CR.x, 1560, toTop), ry = lerp(CR.y, 260, toTop), rs = lerp(1, 0.55, toTop);
+ L.at(g, lx, ly, kl * ls, h => { L.calPage(h, '2008年9月', '28', C.red, '号', { w: 260, h: 260 }); }, lerp(-0.05, 0, mv));
+ if (kl > 0) L.at(g, lx, ly + 230 * ls, kl * ls, h => L.rocket(h, L.F1(), 0, 50, 3.6, { fins: true, sx: 3.6 })); // 小小的猎鹰1号
+ L.at(g, rx, ry, kr * rs, h => { L.calPage(h, '2026年9月', '28', C.blue, '号', { w: 260, h: 260 }); });
+ // 弧线箭头+「整整18年」
+ const ap = MO.cubicOut(clamp((lt - Qv.n18 + 0.25) / 0.45)) * (1 - toTop);
+ L.arrow(g, lt, CL.x + 150, CL.y - 120, CR.x - 150, CR.y - 120, ap, { seed: 3, bend: 120, lw: 8 });
+ const k18 = L.popK(lt, Qv.n18, 0.4, 2.4) * (1 - toTop);
+ if (k18 > 0) L.at(g, (CL.x + CR.x) / 2, 250, k18, h => L.kw(h, '整整18年', 0, 0, { size: 50, fill: C.purple }));
+ // 同一天:等号+两个「28」都被圈出来
+ const ke = L.popK(lt, Qv.tyt, 0.36, 2.6) * (1 - toTop);
+ if (ke > 0) { L.at(g, (CL.x + CR.x) / 2, CL.y + 30, ke, h => { h.lineCap = 'round'; for (const dy of [-18, 18]) { h.strokeStyle = C.ink; h.lineWidth = 22; h.beginPath(); h.moveTo(-54, dy); h.lineTo(54, dy); h.stroke(); h.strokeStyle = C.yel; h.lineWidth = 12; h.stroke(); } });
+ L.at(g, (CL.x + CR.x) / 2, CL.y + 170, ke, h => L.kw(h, '同一天', 0, 0, { size: 48, fill: C.yel, col: C.ink }));
+ const rp = toTop > 0.02 ? 0 : clamp((lt - Qv.tyt) / 0.4); // 日历一动就收掉圈,不留孤儿圈
+ L.ring(g, lt, CL.x, CL.y + 40, 110, 80, rp, { seed: 11, col: C.red, lw: 7 }); L.ring(g, lt, CR.x, CR.y + 40, 110, 80, rp, { seed: 12, col: C.red, lw: 7 }); }
+ g.restore();
+}
+// ---------- ⑤ 星舰第一次进入地球轨道 ----------
+const EX = 1250, EY = 590, ER = 165, ORX = 370, ORY = 118, TILT = -0.16, ct = Math.cos(TILT), st = Math.sin(TILT);
+const orb = th => { const x = ORX * Math.cos(th), y = ORY * Math.sin(th); return [EX + x * ct - y * st, EY + x * st + y * ct]; };
+const orbV = th => { const x = -ORX * Math.sin(th), y = ORY * Math.cos(th); return [x * ct - y * st, x * st + y * ct]; };
+function orbitHalf(g, lt, p, back) {
+ if (p <= 0) return; g.save(); g.strokeStyle = C.ink; g.globalAlpha *= back ? 0.35 : 0.65; g.lineWidth = 4; g.setLineDash([16, 13]); g.lineDashOffset = -lt * 40; g.lineCap = 'round';
+ g.beginPath(); const a0 = back ? Math.PI : 0; for (let i = 0; i <= 40; i++) { const u = i / 40; if (u > p) break; const [x, y] = orb(a0 + u * Math.PI); i ? g.lineTo(x, y) : g.moveTo(x, y); } g.stroke(); g.restore();
+}
+function ship(g, x, y, rot, s, lt, burn) {
+ L.rocket(g, RK.ship(), x, y, s, { rot, sx: 1.9, pal: L.SS_PAL, flame: burn, lt, lw: 3.5 });
+}
+function beat5(g, lt) {
+ const Qv = q(); if (lt < Qv.xj - 0.1) return;
+ const out = L.outK(lt, Qv.lfz - 0.1, 0.3); if (out >= 1) return;
+ g.save(); g.globalAlpha = 1 - out;
+ const ek = L.popK(lt, Qv.xj - 0.05, 0.45, 1.8), op = MO.cubicOut(clamp((lt - Qv.xj - 0.2) / 0.5));
+ const tL = Qv.xj + 0.15, tR = Qv.gd + 0.1, TH0 = Math.PI * 0.98;
+ let sx, sy, rot, front, burn = 1, sc = 3.6;
+ if (lt < tR) { const e = MO.cubicInOut(clamp((lt - tL) / (tR - tL))), [ox, oy] = orb(TH0), dx = ox - EX, dy = oy - EY, dl = Math.hypot(dx, dy);
+ sx = lerp(EX + dx / dl * ER * 0.7, ox, e); sy = lerp(EY + dy / dl * ER * 0.7, oy, e); const [vx, vy] = orbV(TH0);
+ rot = lerp(Math.atan2(dy, dx) + Math.PI / 2, Math.atan2(vy, vx) + Math.PI / 2, MO.smooth(e)); front = e > 0.6; sc = lerp(2.4, 3.6, e); }
+ else { const th = TH0 + (lt - tR) * TAU / 2.4, [x, y] = orb(th), [vx, vy] = orbV(th); sx = x; sy = y; rot = Math.atan2(vy, vx) + Math.PI / 2; front = Math.sin(th) > 0; burn = clamp(1 - (lt - tR) / 0.4); }
+ orbitHalf(g, lt, op, true);
+ if (lt >= tL && !front) ship(g, sx, sy, rot, sc, lt, burn);
+ L.earth(g, EX, EY, ER, lt, { k: ek });
+ orbitHalf(g, lt, op, false);
+ if (lt >= tL && front) ship(g, sx, sy, rot, sc, lt, burn);
+ const kk = L.popK(lt, Qv.dyc, 0.4, 2.4);
+ if (kk > 0) L.at(g, EX, 830, kk, h => L.kw(h, '星舰 · 第一次进入地球轨道', 0, 0, { size: 46, fill: C.blue }));
+ g.restore();
+}
+// ---------- ⑥ 两分钟看完这 24 年 → 时间轴缩进顶栏 ----------
+const TLX0 = 760, TLX1 = 1560, TLY = 640;
+function beat6(g, lt) {
+ const Qv = q(); if (lt < Qv.lfz - 0.1) return;
+ const fly = MO.cubicInOut(clamp((lt - (Qv.end - 0.62)) / 0.5));
+ const kt = L.popK(lt, Qv.lfz + 0.22, 0.45, 1.9), fade = 0; // 标题留到转场(色带擦除),不留空帧
+ g.save(); g.globalAlpha = 1 - fade;
+ L.at(g, 1160, 420, kt, h => {
+ L.txt(h, 'SpaceX', -20, 0, 150, { w: 'Black', align: 'right' });
+ L.txt(h, '这', 10, 0, 120, { w: 'Black' });
+ L.txt(h, '24', 140, 6, 168, { w: 'Black', col: C.red }); L.txt(h, '年', 345, 0, 120, { w: 'Black' });
+ });
+ const ks = L.popK(lt, Qv.lfz + 0.1, 0.4, 2.4);
+ if (ks > 0) { L.stopwatch(g, 760, 250, 64, clamp((lt - Qv.lfz) / 2.2), { k: ks, col: C.teal }); L.at(g, 900, 250, ks, h => L.kw(h, '2分钟', 0, 0, { size: 44, fill: C.teal, align: 'left' })); }
+ g.restore();
+ // 时间轴:念到「24年」画出来,片尾飞进顶栏
+ const tp = MO.cubicOut(clamp((lt - Qv.kw) / 0.7)); if (tp <= 0) return;
+ const x0 = lerp(TLX0, L.TL.x0, fly), x1 = lerp(TLX0 + (TLX1 - TLX0) * tp, L.TL.x1, fly), y = lerp(TLY, L.TL.y, fly);
+ g.save(); g.lineCap = 'round'; g.lineWidth = lerp(14, 8, fly); g.strokeStyle = C.red; g.beginPath(); g.moveTo(x0, y); g.lineTo(x1, y); g.stroke();
+ for (const [yy, lab] of [[2002, '2002'], [2026, '2026']]) { const px = lerp(x0, lerp(TLX1, L.TL.x1, fly), (yy - 2002) / 24); if (px > x1 + 1) continue;
+ g.beginPath(); g.arc(px, y, lerp(14, 6, fly), 0, TAU); g.fillStyle = C.white; g.fill(); g.lineWidth = 4; g.strokeStyle = C.ink; g.stroke();
+ g.globalAlpha = 1 - fly; L.txt(g, lab, px, y + 62, 44, { align: 'center', w: 'Black' }); g.globalAlpha = 1; }
+ g.restore();
+}
+
+SCENES[ID] = {
+ init() { U.assertGlyphs('PuHui-Heavy', '2006年2007年2008年8月第1次2次3次连败三次最后一发成了!2008年9月2026年整整18年同一天第一次进入地球轨道2分钟号星舰·', ID);
+ U.assertGlyphs('PuHui-Black', 'SpaceX这24年2820262002', ID); U.assertGlyphs('PuHui-Bold', '号', ID); },
+ draw(c, lt) {
+ L.CUR_T = L.T0(ID) + lt;
+ L.bg(c, lt);
+ const Qv = q();
+ if (lt < Qv.zz) L.pageTitle(c, lt, '2008年', -1, { col: C.red, size: 46 });
+ else if (lt < Qv.lfz - 0.1) L.pageTitle(c, lt, '2026年', Qv.n18 + 0.1, { col: C.blue, size: 46 });
+ beat1(c, lt); beat2(c, lt); beat3(c, lt); beat4(c, lt); beat5(c, lt); beat6(c, lt);
+ },
+};
+// 讲解员:第 0 帧就在(竖一根手指)
+L.cast(ID, [
+ { t: 0, pose: 'count', fr: [[0, 0], [TM.cue(ID, '火箭'), 1], [TM.cue(ID, '三次') - 0.05, 2]], x: 330, s: 0.66 },
+ { t: TM.cue(ID, '钱只够') - 0.05, pose: 'nervous', fr: 'talk' },
+ { t: TM.cue(ID, '成了') - 0.02, pose: 'cheer', fr: 'bounce' },
+ { t: TM.cue(ID, '整整') - 0.05, pose: 'present', fr: 'talk' },
+ { t: TM.cue(ID, '星舰') - 0.05, pose: 'wow', fr: 'bounce' },
+ { t: TM.cue(ID, '两分钟') - 0.05, pose: 'wave', fr: 'loop' },
+]);
+L.setHud(L.T0(ID) + TM.dur(ID) - 0.1);
+L.push(ID, TM.cue(ID, '成了') - 0.1, TM.cue(ID, '整整') - 0.05, 1.08, 1450, 900); // 「成了」那一下整屏推近
+L.year(ID, [[0, 2002]]);
+L.push(ID, TM.cue(ID, '星舰') - 0.1, TM.cue(ID, '两分钟') - 0.1, 1.1, 1250, 900); // 开头的钩子:星舰入轨推近
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex_lin/scenes/s02.js b/scripts/engine/reference_films/spacex/spacex_lin/scenes/s02.js
new file mode 100644
index 0000000..44133d0
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_lin/scenes/s02.js
@@ -0,0 +1,86 @@
+// S02 · 2002 创办(快段 6 秒,两个知识点):① 无脸人形图标「马斯克」—手绘箭头「创办」→ 小厂房挂上「SpaceX」招牌
+// ② 目标:一行缩到上方,地球到一颗红色星球拉出虚线弧,小火箭沿弧飞过去,星球上冒出小圆顶房子;「住到别的星球上」荧光笔。
+// 转场:整页推走(lin_slide),讲解员和顶栏留在原地——像翻到讲稿下一页。
+(() => {
+const ID = 's02', L = LIN, { C, TAU } = L, { clamp, lerp } = U;
+let Q = null;
+const q = () => Q || (Q = { y02: TM.cue(ID, '2002年'), msk: TM.cue(ID, '马斯克'), cb: TM.cue(ID, '创办'), spx: TM.cue(ID, 'SpaceX'), mb: TM.cue(ID, '目标'),
+ yyt: TM.cue(ID, '有一天'), rl: TM.cue(ID, '让人类'), zd: TM.cue(ID, '住到'), bdx: TM.cue(ID, '别的星球') });
+
+function building(g, lt) {
+ g.lineWidth = 5; g.strokeStyle = C.ink; g.lineJoin = 'round';
+ g.beginPath(); g.moveTo(-170, -40); g.lineTo(-170, 150); g.lineTo(170, 150); g.lineTo(170, -40); g.lineTo(60, -110); g.lineTo(60, -40); g.lineTo(-50, -110); g.lineTo(-50, -40); g.lineTo(-170, -110); g.closePath();
+ g.fillStyle = C.white; g.fill(); g.stroke();
+ g.fillStyle = C.blueL; for (const wx of [-130, -60, 70]) { g.fill(L.rrp(wx, 10, 50, 44, 8)); g.stroke(L.rrp(wx, 10, 50, 44, 8)); }
+ g.fillStyle = C.orange; g.fill(L.rrp(-10, 50, 60, 100, 8)); g.stroke(L.rrp(-10, 50, 60, 100, 8));
+ // 烟囱的一缕烟
+ for (let j = 0; j < 3; j++) { const ph = (lt * 0.8 + j / 3) % 1; g.globalAlpha = 0.5 * (1 - ph); g.fillStyle = '#D9D4CB'; g.beginPath(); g.arc(140 + ph * 30, -130 - ph * 110, 14 + ph * 20, 0, TAU); g.fill(); }
+ g.globalAlpha = 1; g.fillStyle = C.tile; g.fill(L.rrp(120, -150, 34, 80, 4)); g.stroke(L.rrp(120, -150, 34, 80, 4));
+}
+function row(g, lt) {
+ const Qv = q(), up = MO.cubicInOut(clamp((lt - (Qv.mb - 0.1)) / 0.45));
+ g.save(); L.cam(g, lerp(1, 0.72, up), 1200, 480, 0, lerp(0, -200, up));
+ const kp = L.popK(lt, Qv.msk - 0.05, 0.42, 2.2);
+ L.at(g, 760, 470, kp, h => { L.person(h, 0, 0, 1.7, C.mute); L.kw(h, '马斯克', 0, 170, { size: 50, fill: C.ink }); }, 0.02 * Math.sin(lt * 2));
+ L.arrow(g, lt, 900, 430, 1150, 430, MO.cubicOut(clamp((lt - Qv.cb) / 0.35)), { seed: 2, bend: 60, lw: 8 });
+ const kc = L.popK(lt, Qv.cb, 0.35, 2.4);
+ if (kc > 0) L.at(g, 1025, 330, kc, h => L.kw(h, '创办', 0, 0, { size: 48, fill: C.yel, col: C.ink }));
+ const kb = L.popK(lt, Qv.spx - 0.1, 0.45, 2);
+ L.at(g, 1420, 470, kb, h => { building(h, lt); L.at(h, -10, -150, L.popK(lt, Qv.spx + 0.1, 0.4, 2.6), s => L.kw(s, 'SpaceX', 0, 0, { size: 52, fill: C.red }), -0.05 + 0.03 * Math.sin(lt * 2.2)); });
+ g.restore();
+}
+function goal(g, lt) {
+ const Qv = q(); if (lt < Qv.mb - 0.05) return;
+ const kg = L.popK(lt, Qv.mb + 0.3, 0.4, 2.2); // 等上面一行收好再插旗
+ L.at(g, 690, 450, kg, h => { // 小旗「目标」(放在剪影左下方的空白里)
+ h.lineWidth = 5; h.strokeStyle = C.ink; h.lineCap = 'round'; h.beginPath(); h.moveTo(-60, 60); h.lineTo(-60, -60); h.stroke();
+ h.beginPath(); h.moveTo(-58, -60); h.quadraticCurveTo(-20, -74 + 8 * Math.sin(lt * 6), 20, -60); h.quadraticCurveTo(50, -46 + 8 * Math.sin(lt * 6 + 1), 80, -56); h.lineTo(80, -10); h.quadraticCurveTo(40, 0, -58, -12); h.closePath();
+ h.fillStyle = C.red; h.fill(); h.stroke(); L.kw(h, '目标', 10, 110, { size: 42, fill: C.ink });
+ });
+ const ke = L.popK(lt, Qv.mb + 0.15, 0.45, 1.8), kp = L.popK(lt, Qv.yyt, 0.5, 1.8);
+ L.earth(g, 980, 650, 105, lt, { k: ke });
+ L.planet(g, 1610, 560, 120, { k: kp, rot: lt * 0.2, craters: 4 });
+ // 虚线弧+小火箭沿弧飞
+ const P0 = [1085, 600], P1 = [1490, 520], CP = [1290, 330];
+ const bz = u => [(1 - u) ** 2 * P0[0] + 2 * (1 - u) * u * CP[0] + u * u * P1[0], (1 - u) ** 2 * P0[1] + 2 * (1 - u) * u * CP[1] + u * u * P1[1]];
+ const ap = MO.cubicOut(clamp((lt - Qv.yyt) / 0.5));
+ if (ap > 0) { g.save(); g.setLineDash([16, 14]); g.lineDashOffset = -lt * 50; g.lineWidth = 5; g.strokeStyle = C.ink; g.globalAlpha = 0.55; g.lineCap = 'round';
+ g.beginPath(); for (let i = 0; i <= 30; i++) { const u = i / 30 * ap, [x, y] = bz(u); i ? g.lineTo(x, y) : g.moveTo(x, y); } g.stroke(); g.restore(); }
+ const ru = MO.sineInOut(clamp((lt - Qv.rl) / (Qv.bdx - Qv.rl + 0.2)));
+ if (lt > Qv.rl && ru < 1) { const [x, y] = bz(ru), [x2, y2] = bz(Math.min(1, ru + 0.02)); L.rocket(g, L.F1(), x, y, 3.4, { fins: true, rot: Math.atan2(y2 - y, x2 - x) + Math.PI / 2, sx: 3.6, flame: 0.8, lt }); }
+ // 星球上冒出小圆顶房子
+ const kh = L.popK(lt, Qv.zd, 0.4, 2.4);
+ if (kh > 0) L.at(g, 1600, 452, kh, h => { h.lineWidth = 4; h.strokeStyle = C.ink;
+ h.beginPath(); h.arc(0, 0, 44, Math.PI, 0); h.closePath(); h.fillStyle = C.white; h.fill(); h.stroke();
+ h.fillStyle = C.blueL; h.beginPath(); h.arc(0, 0, 30, Math.PI, 0); h.closePath(); h.fill(); h.stroke();
+ h.fillStyle = C.orange; h.fill(L.rrp(36, -26, 30, 26, 6)); h.stroke(L.rrp(36, -26, 30, 26, 6));
+ h.fillStyle = C.yel; h.beginPath(); h.arc(-8, -14, 5, 0, TAU); h.fill(); });
+ // 关键词
+ const kw = L.popK(lt, Qv.zd - 0.1, 0.4, 2);
+ if (kw > 0) L.at(g, 1300, 845, kw, h => {
+ const w0 = L.tw('住到', 54, 'Heavy', h), w1 = L.tw('别的星球', 54, 'Heavy', h), w2 = L.tw('上', 54, 'Heavy', h), x0 = -(w0 + w1 + w2) / 2;
+ L.marker(h, x0 + w0 - 4, -34, w1 + 8, 58, MO.cubicOut(clamp((lt - Qv.bdx) / 0.3)), L.C.hl, 4);
+ L.txt(h, '住到别的星球上', x0, 18, 54);
+ });
+}
+
+SCENES[ID] = {
+ init() { U.assertGlyphs('PuHui-Heavy', '2002年马斯克创办SpaceX目标住到别的星球上', ID); U.assertGlyphs('PuHui-Black', '2002年', ID); },
+ draw(c, lt) {
+ L.CUR_T = L.T0(ID) + lt;
+ L.bg(c, lt, { seed: 2612 });
+ L.pageTitle(c, lt, '2002年', 1.2, { col: C.red, size: 46 });
+ // 开场:大号「2002」砸在页中间,念到「马斯克」前缩进左上角页眉
+ const kY = L.popK(lt, q().y02 - 0.12, 0.4, 2.4), fly = MO.cubicInOut(clamp((lt - 0.95) / 0.32));
+ if (kY > 0 && fly < 1) { c.save(); c.globalAlpha = 1 - clamp((fly - 0.75) / 0.25);
+ L.at(c, lerp(1200, 160, fly), lerp(500, 104, fly), kY * lerp(1, 0.22, fly), h => { L.txt(h, '2002', 0, 70, 260, { w: 'Black', col: C.red, align: 'center' }); L.txt(h, '年', 296, 70, 110, { w: 'Black', align: 'left' }); }, -0.04 * (1 - fly)); c.restore(); }
+ row(c, lt); goal(c, lt);
+ },
+};
+ERAS.find(e => e.id === ID).transition = { type: 'lin_wipe', dur: 0.6, cols: [C.red, C.yel] };
+L.cast(ID, [
+ { t: 0.05, pose: 'present', fr: 'talk' },
+ { t: TM.cue(ID, '目标') - 0.05, pose: 'think', fr: 'talk' },
+]);
+L.year(ID, [[TM.cue(ID, '2002年'), 2002]]);
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex_lin/scenes/s03.js b/scripts/engine/reference_films/spacex/spacex_lin/scenes/s03.js
new file mode 100644
index 0000000..8e42c93
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_lin/scenes/s03.js
@@ -0,0 +1,152 @@
+// S03 · 猎鹰1号「闯关记」(慢推+高光段):① 大号猎鹰1号亮相、名字牌 ② 四个发射台一字排开:2006、2007、2008年8月
+// 每次火箭刚升空就「噗」地炸成一团烟,红叉盖在台上,讲解员一次比一次沮丧 ③ 第四次:镜头推近第四个台,点火、冲出画面——绿勾、彩纸、背景放射光,留一拍
+// ④ 「第一枚」奖章+三个限定词贴纸依次贴上:私人研制 / 进入轨道 / 液体燃料。
+(() => {
+const ID = 's03', L = LIN, { C, W, H, TAU } = L, { clamp, lerp } = U;
+let Q = null;
+const q = () => Q || (Q = { dyk: TM.cue(ID, '第一款'), lyh: TM.cue(ID, '猎鹰1号'),
+ L1: TM.cue(ID, '2006年'), F1: L.cueN(ID, '失败', 0), L2: TM.cue(ID, '2007年'), F2: L.cueN(ID, '失败', 1), L3: TM.cue(ID, '2008年8月'), F3: L.cueN(ID, '失败', 2),
+ d4: TM.cue(ID, '第四次'), cl: TM.cue(ID, '成了'), cw: TM.cue(ID, '成为'), dym: TM.cue(ID, '第一枚'), sr: TM.cue(ID, '私人研制'), jr: TM.cue(ID, '进入轨道'), yt: TM.cue(ID, '液体燃料'),
+ end: TM.dur(ID) });
+
+const PADS = [{ x: 760, lab: '2006年' }, { x: 1010, lab: '2007年' }, { x: 1260, lab: '2008年8月' }, { x: 1580, lab: '第四次' }], BASE = 700;
+function pad(g, x, k, hot) {
+ L.at(g, x, BASE, k, h => {
+ h.lineWidth = 4.5; h.strokeStyle = C.ink; h.lineJoin = 'round';
+ h.fillStyle = hot ? C.yel : C.steelD; h.fill(L.rrp(-80, 0, 160, 34, 10)); h.stroke(L.rrp(-80, 0, 160, 34, 10));
+ h.fillStyle = C.tile; h.fill(L.rrp(-56, 34, 18, 34, 4)); h.stroke(L.rrp(-56, 34, 18, 34, 4)); h.fill(L.rrp(38, 34, 18, 34, 4)); h.stroke(L.rrp(38, 34, 18, 34, 4));
+ });
+}
+function attempt(g, lt, i, tL, tF) {
+ const P = PADS[i], kp = L.popK(lt, tL - 0.25, 0.4, 2);
+ pad(g, P.x, kp, false);
+ if (kp > 0) L.at(g, P.x, BASE + 120, kp, h => L.txt(h, P.lab, 0, 0, 36, { align: 'center', col: lt > tF ? C.red : C.ink }));
+ if (lt < tL - 0.25) return;
+ // 火箭:念到年份时上台,随后升空,念到「失败」时在半空炸开
+ // 三次各不一样:第一次刚离台就炸,第二次飞得歪歪扭扭,第三次飞得最高
+ const HH = [190, 260, 300][i], u = clamp((lt - tL - 0.15) / (tF - tL - 0.15)), rise = lt < tL + 0.15 ? 0 : Math.pow(u, 1.7) * HH;
+ const rot = i === 1 ? 0.3 * Math.sin(lt * 13) * u : i === 2 ? 0.12 * u : 0, dx = i === 1 ? 40 * Math.sin(lt * 6) * u : i === 2 ? 60 * u * u : 0;
+ if (lt < tF && !(i === 0 && lt < q().L1 + 0.25)) L.rocket(g, L.F1(), P.x + dx, BASE - 4 - rise, 9.5, { fins: true, sx: 3.6, flame: lt > tL + 0.05 ? 0.9 : 0, lt, seed: i, rot });
+ if (lt < q().d4 + 0.1) L.puff(g, P.x + (i === 2 ? 60 : 0), BASE - 110 - HH, lt - tF, { s: 0.9 + i * 0.06, seed: 4 + i }); // 第四次之前把烟清掉
+ // 碎片落下
+ if (lt > tF && lt < tF + 0.75) { const r = U.rng(40 + i); for (let j = 0; j < 6; j++) { const k = lt - tF, vx = (r() - 0.5) * 340, vy = -120 - r() * 160;
+ g.save(); g.translate(P.x + vx * k, BASE - 110 - HH + vy * k + 900 * k * k); g.rotate(k * (r() * 12 - 6)); g.fillStyle = j % 2 ? C.white : C.red; g.strokeStyle = C.ink; g.lineWidth = 3;
+ g.beginPath(); g.rect(-9, -5, 18, 10); g.fill(); g.stroke(); g.restore(); } }
+ L.stamp(g, 'x', P.x, BASE - 70, lt - tF - 0.12, { s: 1.15, rot: -0.12 + i * 0.1 });
+}
+function hero(g, lt) { // ① 大号猎鹰1号+名牌,2.1 秒时缩到第四个台位
+ const Qv = q(), sh = MO.cubicInOut(clamp((lt - (Qv.L1 - 0.25)) / 0.5));
+ if (sh >= 1) return;
+ const x = lerp(1200, PADS[0].x, sh), y = lerp(800, BASE - 4, sh), s = lerp(21, 9.5, sh), k = L.popK(lt, 0.05, 0.5, 1.6); // 大火箭直接变成 2006 年那一枚
+ g.save();
+ L.at(g, x, y, k, h => L.rocket(h, L.F1(), 0, 0, s, { fins: true, sx: lerp(2.4, 3.6, sh), lw: 5 }), 0.02 * Math.sin(lt * 2));
+ const kn = L.popK(lt, Qv.lyh, 0.4, 2.4) * (1 - clamp(sh * 4));
+ if (kn > 0) L.at(g, 1470, 420, kn, h => { L.kw(h, '猎鹰1号', 0, 0, { size: 72, fill: C.red }); });
+ const kd = L.popK(lt, Qv.dyk, 0.4, 2) * (1 - clamp(sh * 4));
+ if (kd > 0) L.at(g, 1470, 300, kd, h => L.kw(h, '第一款火箭', 0, 0, { size: 40, fill: C.white, col: C.ink }));
+ if (kn > 0) L.arrow(g, lt, 1340, 470, 1260, 540, MO.cubicOut(clamp((lt - Qv.lyh - 0.1) / 0.3)) * (1 - sh), { seed: 9, bend: -20, lw: 6, head: 22 });
+ g.restore();
+}
+// 资金条:每失败一次掉一截,第四次前只剩一点点红(回扣「钱只够再打最后一发」)
+function fund(g, lt) {
+ const Qv = q(), k = L.popK(lt, Qv.L1 - 0.1, 0.4, 2) * (1 - L.outK(lt, Qv.cl + 0.4, 0.3)); if (k <= 0) return;
+ const lv = [[Qv.F1, 0.62], [Qv.F2, 0.3], [Qv.F3, 0.09]]; let v = 1, tl = -9;
+ for (const [t, to] of lv) if (lt > t) { const u = MO.cubicOut(clamp((lt - t) / 0.4)); v = lerp(v, to, u); tl = t; }
+ const low = v < 0.15, blink = low ? 0.55 + 0.45 * Math.sin(lt * 12) : 1;
+ L.at(g, 900, 190, k, h => {
+ L.card(h, -230, -42, 460, 84, { fill: C.white, r: 42, lw: 4, sh: 5 });
+ L.flatCoin(h, -186, 0, 26);
+ L.txt(h, '资金', -146, 2, 34, { base: 'middle' });
+ h.fillStyle = '#EEE7DA'; h.fill(L.rrp(-60, -16, 270, 32, 16));
+ h.save(); h.globalAlpha *= blink; h.fillStyle = low ? C.red : v < 0.4 ? C.orange : C.green; h.fill(L.rrp(-60, -16, Math.max(16, 270 * v), 32, 16)); h.restore();
+ h.lineWidth = 3.5; h.strokeStyle = C.ink; h.stroke(L.rrp(-60, -16, 270, 32, 16));
+ if (lt > Qv.d4 - 0.1 && lt < Qv.cl) L.at(h, 0, 90, L.popK(lt, Qv.d4 - 0.1, 0.35, 2.4), s => L.kw(s, '只够最后一发', 0, 0, { size: 40, fill: C.red }));
+ }, MO.settle(lt - tl, 0.06, 4, 6));
+}
+function board(g, lt) {
+ const Qv = q(); if (lt < Qv.L1 - 0.3) return;
+ const out = L.outK(lt, Qv.cw - 0.12, 0.3); if (out >= 1) return;
+ // 第四次:镜头推近第四个台
+ const push = MO.cubicInOut(clamp((lt - (Qv.d4 - 0.1)) / 0.6)) * (1 - MO.cubicInOut(clamp((lt - (Qv.cl + 0.6)) / 0.5)));
+ g.save(); g.globalAlpha = 1 - out; L.cam(g, 1 + 0.16 * push, PADS[3].x, 560);
+ // 放射光留给结尾的星舰入轨,这里只用彩纸+绿勾(降一级)
+ const sb = 0;
+ if (sb > 0) { g.save(); g.translate(PADS[3].x, 420); g.rotate(lt * 0.25); g.globalAlpha *= 0.55 * MO.cubicOut(sb); g.fillStyle = C.yel;
+ for (let i = 0; i < 14; i++) { const a = i * TAU / 14; g.beginPath(); g.moveTo(0, 0); g.arc(0, 0, 1100 * MO.cubicOut(sb), a, a + TAU / 28); g.closePath(); g.fill(); } g.restore(); }
+ attempt(g, lt, 0, Qv.L1, Qv.F1); attempt(g, lt, 1, Qv.L2, Qv.F2); attempt(g, lt, 2, Qv.L3, Qv.F3);
+ // 第四台
+ const P = PADS[3], k4 = L.popK(lt, Qv.L1 + 0.45, 0.4, 2); pad(g, P.x, k4, lt > Qv.d4);
+ L.at(g, P.x, BASE + 120, L.popK(lt, Qv.d4 - 0.1, 0.4, 2.4), h => L.kw(h, '第四次', 0, -6, { size: 38, fill: C.yel, col: C.ink }));
+ if (lt < Qv.d4 - 0.1) L.at(g, P.x, BASE + 116, k4, h => L.txt(h, '?', 0, 0, 40, { align: 'center', col: C.sub }));
+ const tIg = Qv.d4 + 0.35, rise = lt < Qv.cl - 0.15 ? 0 : Math.pow(lt - (Qv.cl - 0.15), 2) * 4200; // 一下冲出画面,绿勾等它走了再落
+ const shake = lt > tIg && lt < Qv.cl ? 3 * Math.sin(lt * 70) : 0;
+ g.save(); g.globalAlpha *= clamp((BASE - rise - 260) / 200); // 冲出去时在年份胶囊下方淡出
+ if (k4 > 0) L.at(g, P.x + shake, BASE, k4, h => L.rocket(h, L.F1(), 0, -4 - rise, 9.5, { fins: true, sx: 3.6, flame: lt > tIg ? lerp(0.7, 1.6, clamp((lt - tIg) / 0.5)) : 0, lt, seed: 7 }));
+ g.restore();
+ if (lt > tIg && lt < Qv.cl + 0.6) for (let j = 0; j < 5; j++) { const ph = (lt * 2 + j / 5) % 1; g.save(); g.globalAlpha = 0.5 * (1 - ph); g.fillStyle = '#E6DFD2';
+ g.beginPath(); g.arc(P.x - 90 + j * 45, BASE + 10 - ph * 24, 24 + ph * 30, 0, TAU); g.fill(); g.restore(); }
+ L.stamp(g, 'v', P.x, BASE - 190, lt - Qv.cl - 0.28, { s: 2.0, rot: -0.12 });
+ const kc = L.popK(lt, Qv.cl + 0.3, 0.4, 2.6);
+ if (kc > 0) L.at(g, P.x - 60, BASE - 400, kc, h => L.kw(h, '成了!', 0, 0, { size: 72, fill: C.green }), -0.06);
+ g.restore();
+}
+// ④ 奖章+限定词贴纸
+function medal(g, lt, k) {
+ L.at(g, 820, 470, k, h => {
+ h.lineWidth = 5; h.strokeStyle = C.ink; h.lineJoin = 'round';
+ for (const d of [-1, 1]) { h.beginPath(); h.moveTo(d * 30, 60); h.lineTo(d * 90, 230); h.lineTo(d * 52, 214); h.lineTo(d * 30, 250); h.lineTo(d * 0, 80); h.closePath(); h.fillStyle = d < 0 ? C.red : C.blue; h.fill(); h.stroke(); }
+ h.beginPath(); for (let i = 0; i < 24; i++) { const a = i * TAU / 24 + lt * 0.3, rr = i % 2 ? 150 : 166; h.lineTo(Math.cos(a) * rr, Math.sin(a) * rr); } h.closePath(); h.fillStyle = C.goldD; h.fill(); h.stroke();
+ h.beginPath(); h.arc(0, 0, 130, 0, TAU); h.fillStyle = C.gold; h.fill(); h.stroke();
+ h.beginPath(); h.arc(0, 0, 104, 0, TAU); h.strokeStyle = 'rgba(43,42,51,0.35)'; h.lineWidth = 4; h.stroke();
+ L.txt(h, '第一枚', 0, 16, 64, { w: 'Black', align: 'center', base: 'middle' });
+ h.fillStyle = 'rgba(255,255,255,0.6)'; h.beginPath(); h.ellipse(-60, -70, 26, 12, -0.7, 0, TAU); h.fill();
+ }, 0.05 * Math.sin(lt * 1.7));
+}
+function chipIcon(g, kind, lt) {
+ g.lineWidth = 4; g.strokeStyle = C.ink; g.lineJoin = 'round';
+ if (kind === 0) L.person(g, 0, -6, 0.62, C.white);
+ else if (kind === 1) { L.earth(g, 0, 0, 26, lt, { spin: 20 }); g.save(); g.setLineDash([7, 6]); g.lineWidth = 3; g.beginPath(); g.ellipse(0, 0, 44, 14, -0.3, 0, TAU); g.stroke(); g.restore(); }
+ else { g.beginPath(); g.moveTo(0, -36); g.bezierCurveTo(16, -12, 30, 6, 30, 16); g.arc(0, 16, 30, 0, Math.PI); g.bezierCurveTo(-30, 6, -16, -12, 0, -36); g.closePath(); g.fillStyle = C.sea; g.fill(); g.stroke();
+ g.fillStyle = 'rgba(255,255,255,0.6)'; g.beginPath(); g.ellipse(-12, 14, 6, 10, 0.3, 0, TAU); g.fill(); }
+}
+const CHIPS = [{ s: '私人研制', col: C.purple }, { s: '进入轨道', col: C.blue }, { s: '液体燃料', col: C.teal }];
+function page2(g, lt) {
+ const Qv = q(); if (lt < Qv.cw - 0.1) return;
+ medal(g, lt, L.popK(lt, Qv.dym - 0.15, 0.5, 2));
+ const ts = [Qv.sr, Qv.jr, Qv.yt];
+ CHIPS.forEach((c, i) => {
+ const t0 = ts[i] - 0.08, u = clamp((lt - t0) / 0.38); if (u <= 0) return;
+ const x = lerp(1900, 1340, MO.backOut(u, 1.6)), y = 330 + i * 170;
+ L.at(g, x, y, 1, h => { L.card(h, -40, -62, 520, 124, { fill: C.white, r: 30 }); h.save(); h.translate(46, 0); chipIcon(h, i, lt); h.restore();
+ L.kw(h, c.s, 300, 0, { size: 50, fill: c.col }); }, (i - 1) * 0.025 + 0.012 * Math.sin(lt * 2 + i));
+ });
+ // 连接线:奖章 → 三张贴纸
+ ts.forEach((t, i) => L.arrow(g, lt, 1000, 470, 1290, 330 + i * 170, MO.cubicOut(clamp((lt - t) / 0.3)), { seed: 20 + i, bend: 0, lw: 5, head: 0, dash: [2, 12] }));
+ L.underline(g, lt, 1420, 755, 280, MO.cubicOut(clamp((lt - Qv.yt - 0.3) / 0.35)), { col: C.red });
+}
+
+SCENES[ID] = {
+ init() { U.assertGlyphs('PuHui-Heavy', '资金只够最后一发猎鹰1号第一款火箭2006年2007年2008年8月第四次?成了!私人研制进入轨道液体燃料', ID); U.assertGlyphs('PuHui-Black', '第一枚', ID); },
+ draw(c, lt) {
+ L.CUR_T = L.T0(ID) + lt;
+ L.bg(c, lt, { seed: 2613 });
+ L.pageTitle(c, lt, '猎鹰1号', q().lyh - 0.1, { col: C.red, size: 44 });
+ hero(c, lt); board(c, lt); fund(c, lt); page2(c, lt);
+ },
+};
+ERAS.find(e => e.id === ID).transition = { type: 'lin_flip', dur: 0.6 };
+FRONT_CONFETTI: { L.FRONT[ID] = (c, lt) => { const Qv = q(); L.confetti(c, 1580, 560, lt - Qv.cl - 0.3, { n: 60, seed: 31, spread: 900, up: 900, life: 2.4 }); }; }
+L.cast(ID, [
+ { t: 0.05, pose: 'point', fr: 'talk' },
+ { t: q().F1 - 0.02, pose: 'sad', fr: 0 },
+ { t: q().F2 - 0.02, pose: 'sad', fr: 1 },
+ { t: q().F3 - 0.02, pose: 'sad', fr: 2 },
+ { t: q().d4 - 0.05, pose: 'nervous', fr: 'talk' },
+ { t: q().cl - 0.02, pose: 'cheer', fr: 'bounce' },
+ { t: q().cw - 0.05, pose: 'thumb', fr: 'talk' },
+]);
+L.push(ID, q().cl - 0.1, q().cw + 0.25, 1.12, 1350, 900);
+L.bustCard(ID, q().F3 - 0.02, q().d4 - 0.04, [[q().F3 - 0.02, 3]]); // 第三次失败:切到讲解员苦笑冒汗的大头特写
+L.hudHide(ID, q().F3 - 0.1, q().d4); // 第三次失败:给讲解员一个反应特写
+L.year(ID, [[q().L1, 2006], [q().L2, 2007], [q().L3, 2008]]);
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex_lin/scenes/s04.js b/scripts/engine/reference_films/spacex/spacex_lin/scenes/s04.js
new file mode 100644
index 0000000..51126a8
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_lin/scenes/s04.js
@@ -0,0 +1,108 @@
+// S04 · NASA 合同与龙飞船(大数字砸入段):① 日历翻页「3个月后」→ 合同纸卡盖章「合同」→ 「16亿美元」计数落定+钱袋 → 货箱沿虚线送到空间站
+// ② 页面上推:2012 年,龙飞船从左下飞来对接空间站,「第一艘」绶带+「私人飞船」关键词框。
+// 转场:从上一页「第一枚」奖章的圆心扩张揭开(lin_iris)。
+(() => {
+const ID = 's04', L = LIN, { C, TAU } = L, { clamp, lerp } = U;
+let Q = null;
+const q = () => Q || (Q = { sgy: TM.cue(ID, '三个月后'), nasa: TM.cue(ID, 'NASA'), ht: TM.cue(ID, '合同'), n16: TM.cue(ID, '16亿美元'), kj: TM.cue(ID, '往空间站'), sh: TM.cue(ID, '送货'),
+ y12: TM.cue(ID, '2012年'), lfc: TM.cue(ID, '龙飞船'), cl: TM.cue(ID, '成了'), dys: TM.cue(ID, '第一艘'), gj: TM.cue(ID, '国际空间站'), sr: TM.cue(ID, '私人飞船') });
+
+function moneyBag(g, lt) {
+ g.lineWidth = 5; g.strokeStyle = C.ink; g.lineJoin = 'round';
+ g.beginPath(); g.moveTo(-40, -110); g.quadraticCurveTo(0, -80, 40, -110); g.lineTo(30, -70); g.bezierCurveTo(130, -30, 130, 110, 0, 110); g.bezierCurveTo(-130, 110, -130, -30, -30, -70); g.closePath();
+ g.fillStyle = C.gold; g.fill(); g.stroke();
+ g.fillStyle = C.goldD; g.fill(L.rrp(-36, -82, 72, 16, 8)); g.stroke(L.rrp(-36, -82, 72, 16, 8));
+ L.txt(g, '$', 0, 30, 110, { w: 'Black', col: C.goldD, align: 'center', base: 'middle' });
+}
+function cargo(g, s = 1) {
+ g.save(); g.scale(s, s); g.lineWidth = 4; g.strokeStyle = C.ink; g.lineJoin = 'round';
+ g.fillStyle = '#E7B776'; g.fill(L.rrp(-40, -34, 80, 68, 6)); g.stroke(L.rrp(-40, -34, 80, 68, 6));
+ g.beginPath(); g.moveTo(-40, -8); g.lineTo(40, -8); g.moveTo(-12, -34); g.lineTo(-12, 34); g.moveTo(12, -34); g.lineTo(12, 34); g.stroke(); g.restore();
+}
+function pageA(g, lt) {
+ const Qv = q();
+ // 日历:9月 → 12月(撕页)+「3个月后」
+ const kc = L.popK(lt, 0.02, 0.4, 2), fl = clamp((lt - 0.35) / 0.55);
+ L.at(g, 760, 300, kc, h => {
+ if (fl > 0) L.calPage(h, '2008年', '12月', C.blue, '', { w: 220, h: 220 });
+ if (fl < 1) { const e = MO.cubicIn(fl); h.save(); h.translate(-100, -100); h.rotate(-e * 1.1); h.translate(100 - e * 60, 100 + e * e * 700); h.globalAlpha = 1 - clamp((fl - 0.7) / 0.3);
+ L.calPage(h, '2008年', '9月', C.red, '', { w: 220, h: 220 }); h.restore(); }
+ }, -0.04);
+ const k3 = L.popK(lt, Qv.sgy + 0.1, 0.4, 2.4);
+ if (k3 > 0) L.at(g, 760, 470, k3, h => L.kw(h, '3个月后', 0, 0, { size: 44, fill: C.purple }));
+ // 合同
+ const kd = L.popK(lt, Qv.nasa - 0.1, 0.45, 1.8);
+ L.at(g, 1070, 520, kd, h => {
+ L.card(h, -150, -200, 300, 400, { fill: C.white, r: 18 });
+ L.kw(h, 'NASA', 0, -138, { size: 40, fill: C.blue, h: 62 });
+ h.lineCap = 'round'; h.lineWidth = 7; h.strokeStyle = '#D8D1C4'; for (let i = 0; i < 5; i++) { h.beginPath(); h.moveTo(-104, -50 + i * 44); h.lineTo(i === 4 ? 10 : 104, -50 + i * 44); h.stroke(); }
+ // 签名:念到「合同」时一笔写出
+ const sp = clamp((lt - Qv.ht) / 0.45), pts = []; for (let i = 0; i <= 30; i++) { const u = i / 30; pts.push([-20 + u * 120, 150 + Math.sin(u * 14) * 14 - u * 20]); }
+ h.strokeStyle = C.blue; h.lineWidth = 5; L.strokePart(h, pts, sp);
+ L.at(h, 92, 120, L.popK(lt, Qv.ht + 0.05, 0.3, 2.6), s => { s.lineWidth = 6; s.strokeStyle = C.red; s.beginPath(); s.arc(0, 0, 52, 0, TAU); s.stroke(); L.txt(s, '合同', 0, 4, 36, { col: C.red, align: 'center', base: 'middle' }); }, -0.25);
+ }, 0.03 * Math.sin(lt * 1.6));
+ // 16 亿美元
+ const c0 = Qv.n16 - 0.05, cp = lt >= c0 ? 1 : 0; // 16 直接砸下来,不计数(计数会闪过 15)
+ const kn = L.popK(lt, c0, 0.35, 2.2);
+ if (kn > 0) L.at(g, 1530, 400, kn * (1 + MO.settle(lt - c0 - 0.3, 0.1, 3, 6)), h => { L.txt(h, '16', 20, 0, 190, { w: 'Black', col: C.red, align: 'right' }); L.txt(h, '亿美元', 34, 0, 70); });
+ const kbg = L.popK(lt, c0 + 0.15, 0.4, 2.2);
+ if (kbg > 0) L.at(g, 1690, 600, kbg * 0.78, h => moneyBag(h, lt), 0.06 * Math.sin(lt * 3));
+ if (cp >= 1) L.twinkles(g, lt, [[1300, 250], [1800, 270], [1560, 470]], { r: 20 });
+ L.ring(g, lt, 1440, 335, 150, 100, clamp((lt - c0 - 0.35) / 0.4), { seed: 61, col: C.red, lw: 7 });
+ // 送货:货箱沿虚线飞向空间站
+ const ks = L.popK(lt, Qv.kj, 0.45, 1.8);
+ if (ks > 0) {
+ L.at(g, 1610, 790, ks * 0.62, h => L.iss(h, 0, 0, 1));
+ g.save(); g.setLineDash([14, 12]); g.lineDashOffset = -lt * 50; g.lineWidth = 5; g.strokeStyle = C.ink; g.globalAlpha = 0.5 * ks; g.lineCap = 'round';
+ g.beginPath(); g.moveTo(1180, 800); g.quadraticCurveTo(1330, 700, 1480, 790); g.stroke(); g.restore();
+ const u = ((lt - Qv.kj) * 0.9) % 1, bx = lerp(1180, 1480, u), by = (1 - u) ** 2 * 800 + 2 * (1 - u) * u * 700 + u * u * 790;
+ g.save(); g.globalAlpha = Math.sin(Math.PI * u); g.translate(bx, by); cargo(g, 0.8); g.restore();
+ L.at(g, 1180, 800, L.popK(lt, Qv.sh - 0.05, 0.35, 2.4), h => L.kw(h, '送货', 0, 0, { size: 48, fill: C.orange }));
+ }
+}
+function pageB(g, lt) {
+ const Qv = q(); if (lt < Qv.y12 - 0.4) return;
+ // 空间站居中偏右,龙飞船从左下飞来对接
+ const ki = L.popK(lt, Qv.y12 - 0.1, 0.5, 1.6), sx = 1300, sy = 330, IS = 1.9, CS = 1.55;
+ L.at(g, sx, sy + 6 * Math.sin(lt * 1.3), ki * IS, h => L.iss(h, 0, 0, 1), 0.03);
+ if (lt > Qv.gj - 0.05) L.at(g, sx + 380, sy - 150, L.popK(lt, Qv.gj - 0.05, 0.36, 2.4), h => L.kw(h, '国际空间站', 0, 0, { size: 38, fill: C.white, col: C.ink }));
+ const t0 = Qv.lfc - 0.3, t1 = Qv.cl + 0.1, u = MO.cubicInOut(clamp((lt - t0) / (t1 - t0)));
+ const dockX = sx, baseY = sy + 70 * IS + 128 * CS; // 鼻锥顶住空间站下方舱段
+ if (lt > t0 - 0.2) {
+ const x = lerp(1880, dockX, u), y = lerp(560, baseY, u) - Math.sin(Math.PI * u) * 60, // 从右边飞进来,全程不进字幕区
+ rot = lerp(-0.55, 0, MO.smooth(u));
+ L.capsule(g, x, y, CS, { rot, flame: u < 0.95 ? 0.7 : 0, lt, cargo: true }); // 2012 年是货运龙(带太阳翼尾段)
+ }
+ L.burstLines(g, dockX, sy + 70 * IS, 100, 180, clamp((lt - t1) / 0.5), { n: 10, col: C.ink, lw: 6 });
+ const kb = L.popK(lt, Qv.dys, 0.4, 2.6);
+ if (kb > 0) L.at(g, 800, 330, kb, h => { // 「第一艘」绶带
+ h.lineWidth = 5; h.strokeStyle = C.ink; h.lineJoin = 'round';
+ h.beginPath(); h.moveTo(-170, -44); h.lineTo(170, -44); h.lineTo(140, 0); h.lineTo(170, 44); h.lineTo(-170, 44); h.lineTo(-140, 0); h.closePath(); h.fillStyle = C.red; h.fill(); h.stroke();
+ L.txt(h, '第一艘', 0, 4, 56, { w: 'Black', col: C.white, align: 'center', base: 'middle' });
+ }, -0.06);
+ const kr = L.popK(lt, Qv.sr - 0.05, 0.4, 2.4);
+ if (kr > 0) L.at(g, 1650, 640, kr, h => { L.kw(h, '私人飞船', 0, 0, { size: 60, fill: C.blue }); });
+ if (kr > 0) L.twinkles(g, lt, [[1450, 570], [1820, 720]], { r: 18 });
+}
+
+SCENES[ID] = {
+ init() { U.assertGlyphs('PuHui-Heavy', '2010猎鹰9号首飞2008年12月9月3个月后NASA合同亿美元送货2012年国际空间站第一艘私人飞船0123456789', ID); U.assertGlyphs('PuHui-Black', '0123456789$第一艘', ID); },
+ draw(c, lt) {
+ L.CUR_T = L.T0(ID) + lt;
+ const Qv = q();
+ L.bg(c, lt, { seed: 2614 });
+ // 页内上推:念到「2012年」整页往上滑走,下一屏从下面上来
+ const up = MO.cubicInOut(clamp((lt - (Qv.y12 - 0.35)) / 0.55));
+ if (up < 1) { c.save(); c.globalAlpha = Math.max(0, 1 - 2 * up); c.translate(0, -1080 * up); pageA(c, lt); c.restore(); }
+ if (up > 0) { c.save(); if (up < 1) { c.beginPath(); c.rect(0, 0, 1920, 905); c.clip(); } c.translate(0, 1080 * (1 - up)); pageB(c, lt); c.restore(); }
+ if (up < 0.5) L.pageTitle(c, lt, 'NASA合同', Qv.nasa - 0.15, { col: C.blue, size: 42 }); else L.pageTitle(c, lt, '2012年', Qv.y12 - 0.1, { col: C.red, size: 46 });
+ },
+};
+ERAS.find(e => e.id === ID).transition = { type: 'lin_iris', dur: 0.65, x: 1300, y: 760, col: C.yel };
+L.cast(ID, [
+ { t: 0.05, pose: 'stick', fr: 'talk' },
+ { t: TM.cue(ID, '2012年') - 0.2, pose: 'present', fr: 'talk', x: 450, walk: 0.7 }, // 走近一点,看空间站
+ { t: TM.cue(ID, '第一艘') - 0.05, pose: 'thumb', fr: 'talk' },
+]);
+L.year(ID, [[0.3, 2008], [TM.cue(ID, '2012年') - 0.45, 2012]]); // 龙飞船那句开口前,年份已经走到 2012
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex_lin/scenes/s05.js b/scripts/engine/reference_films/spacex/spacex_lin/scenes/s05.js
new file mode 100644
index 0000000..281126f
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_lin/scenes/s05.js
@@ -0,0 +1,133 @@
+// S05 · 回收一级(慢推段,三个知识点):① 猎鹰9号剖面:「二级」「一级」标签,一级发亮、分离、沿 U 形虚线箭头飞回地面,「重复用」循环箭头
+// ② 2015年12月:一级从天而降、展开着陆腿、点火减速,竖着落在着陆台上,扬尘+「轨道火箭里 头一回」
+// ③ 2017年:同一枚一级贴上「回收」圆标,再次点火升空。转场:斜向黄蓝色带扫过(lin_wipe)。
+(() => {
+const ID = 's05', L = LIN, { C, TAU } = L, { clamp, lerp } = U;
+let Q = null;
+const q = () => Q || (Q = { jz: TM.cue(ID, '接着呢'), yj: L.cueN(ID, '一级', 0), fhl: TM.cue(ID, '飞回来'), cfy: TM.cue(ID, '重复用'), y15: TM.cue(ID, '2015年12月'),
+ lyh: TM.cue(ID, '猎鹰9号'), szh: TM.cue(ID, '竖着'), dm: TM.cue(ID, '地面'), dmE: TM.end(ID, '地面'), gd: TM.cue(ID, '轨道火箭'), tyh: TM.cue(ID, '头一回'), y17: TM.cue(ID, '2017年'),
+ hs: TM.cue(ID, '回收的'), yyc: TM.cue(ID, '又一次'), fst: TM.cue(ID, '飞上了天') });
+
+const SX = 1.75, SXA = 2.5; // 剖面图更胖一点 // 猎鹰9号横向放宽(图标化)
+function recycle(g, lt, s) { // 循环箭头图标
+ g.save(); g.scale(s, s); g.rotate(lt * 1.2); g.lineCap = 'round'; g.lineJoin = 'round';
+ for (let i = 0; i < 3; i++) { g.save(); g.rotate(i * TAU / 3);
+ g.strokeStyle = C.ink; g.lineWidth = 22; g.beginPath(); g.arc(0, 0, 60, -0.95, 0.75); g.stroke(); g.strokeStyle = C.teal; g.lineWidth = 13; g.stroke();
+ g.fillStyle = C.teal; g.strokeStyle = C.ink; g.lineWidth = 4; const a = 0.75, x = Math.cos(a) * 60, y = Math.sin(a) * 60;
+ g.beginPath(); g.moveTo(x + Math.cos(a) * 24, y + Math.sin(a) * 24); g.lineTo(x - Math.cos(a) * 24, y - Math.sin(a) * 24); g.lineTo(x - Math.sin(a) * 30, y + Math.cos(a) * 30); g.closePath(); g.fill(); g.stroke();
+ g.restore(); }
+ g.restore();
+}
+function pageA(g, lt) {
+ const Qv = q(), x = 900, base = 860, pxm = 8.4;
+ const sep = clamp((lt - Qv.fhl + 0.05) / 0.35); // 一级分离
+ const glow = clamp((lt - Qv.yj) / 0.2);
+ // 二级(上半截):分离后继续往上飞走
+ const up = sep > 0 ? Math.pow(Math.max(0, lt - Qv.fhl), 2) * 900 : 0;
+ g.save(); g.beginPath(); g.rect(0, 0, 1920, base - 41 * pxm - 2 + 0); g.clip();
+ L.rocket(g, RK.falcon9({ payload: 'fairing' }), x, base - up, pxm, { sx: SXA, flame: sep > 0 ? 0.8 : 0, lt });
+ g.restore();
+ // 一级:分离后先停住发亮,再沿 U 形箭头翻回去(画面上只画轨迹箭头+小火箭沿线走)
+ g.save(); g.beginPath(); g.rect(0, base - 41 * pxm - 2, 1920, 1080); g.clip();
+ const fuA = MO.sineInOut(clamp((lt - Qv.fhl - 0.25) / 0.9)); // 一级「变成」沿箭头飞走的那枚小火箭:原位的一级同时淡出
+ g.globalAlpha *= 1 - clamp(fuA * 2.5);
+ if (glow > 0) { g.save(); g.shadowColor = 'rgba(255,212,71,0.95)'; g.shadowBlur = 40 * glow; L.rocket(g, F9B(), x, base, pxm, { sx: SXA, pal: { body: glow > 0.5 ? '#FFF2C2' : C.white } }); g.restore(); }
+ else L.rocket(g, F9B(), x, base, pxm, { sx: SXA });
+ g.restore();
+ // 标签
+ const kl = L.popK(lt, Qv.jz + 0.4, 0.4, 2);
+ if (kl > 0) { L.at(g, x - 200, base - 470, kl, h => L.kw(h, '二级', 0, 0, { size: 38, fill: C.white, col: C.ink })); L.arrow(g, lt, x - 140, base - 470, x - 40, base - 440, kl, { seed: 4, bend: -10, lw: 5, head: 18 }); }
+ const k1 = L.popK(lt, Qv.yj - 0.05, 0.4, 2.6);
+ if (k1 > 0) { L.at(g, x - 210, base - 200, k1, h => L.kw(h, '一级', 0, 0, { size: 48, fill: C.yel, col: C.ink })); L.arrow(g, lt, x - 140, base - 200, x - 40, base - 210, k1, { seed: 5, bend: 10, lw: 5, head: 18 }); }
+ // 二级继续往上:一条虚线弧通向右上角的小卫星(入轨),和一级「掉头飞回」形成对照
+ const up2 = MO.cubicOut(clamp((lt - Qv.fhl - 0.1) / 0.7));
+ if (up2 > 0) { L.arrow(g, lt, x + 40, base - 600, 1240, 190, up2, { seed: 13, bend: 90, lw: 6, dash: [14, 12], head: 22 }); if (up2 > 0.9) L.sat(g, 1290, 170, 1.4, 0, 0); }
+ // U 形「飞回来」箭头:从一级顶上拱到右边的着陆台
+ const ap = MO.cubicOut(clamp((lt - Qv.fhl) / 0.55));
+ L.arrow(g, lt, x + 60, base - 380, 1420, base - 60, ap, { seed: 6, bend: -260, lw: 8, dash: [18, 14] });
+ // 小一级沿箭头飞回(同 arrow() 的弧线公式)
+ const fu = MO.sineInOut(clamp((lt - Qv.fhl - 0.25) / 0.9));
+ if (fu > 0 && fu < 1) { const x0 = x + 60, y0 = base - 380, x1 = 1420, y1 = base - 60, dx = x1 - x0, dy = y1 - y0, Ln = Math.hypot(dx, dy), nx = -dy / Ln, ny = dx / Ln;
+ const P = u => [x0 + dx * u + nx * Math.sin(Math.PI * u) * -260, y0 + dy * u + ny * Math.sin(Math.PI * u) * -260], [px, py] = P(fu), [qx, qy] = P(Math.min(1, fu + 0.02));
+ L.rocket(g, F9B(fu > 0.7 ? 1 : 0, 1), px, py, 3.2, { sx: SX, rot: Math.atan2(qy - py, qx - px) - Math.PI / 2, flame: fu > 0.75 ? 0.8 : 0, lt }); }
+ if (ap > 0) L.at(g, 1420, base + 14, ap, h => { h.lineWidth = 4.5; h.strokeStyle = C.ink; h.fillStyle = C.steelD; h.beginPath(); h.ellipse(0, 0, 110, 22, 0, 0, TAU); h.fill(); h.stroke(); });
+ const kr = L.popK(lt, Qv.cfy - 0.05, 0.45, 2.2);
+ if (kr > 0) L.at(g, 1520, 360, kr, h => { recycle(h, lt, 0.9); L.kw(h, '重复用', 0, 130, { size: 50, fill: C.teal }); });
+}
+const F9B = (legs = 0, fins = 0) => RK.falcon9({ legs, fins, stage: 'booster' });
+// ② 着陆 ③ 复飞:同一枚一级
+const LX = 1180, GY = 820, PXM = 9.2;
+function boosterAt(lt) {
+ const Qv = q(), tA = Qv.y15 - 0.1, tD = Qv.dm + 0.05; // tD 触地
+ if (lt < tD) { const u = clamp((lt - tA) / (tD - tA)), e = 1 - Math.pow(1 - u, 2.2); return { a: clamp(u / 0.15), y: lerp(520, GY, e), legs: clamp((lt - (tD - 0.9)) / 0.6), flame: lt > tD - 1.2 ? 1 : 0.25, fins: 1, rot: 0.25 * (1 - MO.smooth(clamp(u * 1.4))) }; }
+ const tL = Qv.fst - 0.35;
+ if (lt < tL) return { y: GY, legs: lt > Qv.hs ? 1 - clamp((lt - Qv.yyc) / 0.4) : 1, flame: lt < tD + 0.15 ? 1 : 0, fins: 1, rot: 0 };
+ const k = lt - tL; return { y: GY - k * k * 900, legs: 0, flame: 1.3, fins: 0, rot: 0 };
+}
+function pageB(g, lt) {
+ const Qv = q(); if (lt < Qv.y15 - 0.4) return;
+ // 地面+着陆台
+ g.save(); g.lineWidth = 5; g.strokeStyle = C.ink; g.fillStyle = '#EADFCB'; g.beginPath(); g.rect(0, GY + 12, 1920, 300); g.fill(); // 地面铺满全宽,讲解员也站在地上
+ g.beginPath(); g.moveTo(0, GY + 12); g.lineTo(1920, GY + 12); g.stroke();
+ g.fillStyle = C.steelD; g.beginPath(); g.ellipse(LX, GY + 14, 150, 24, 0, 0, TAU); g.fill(); g.stroke(); g.restore();
+ // 返回轨迹:从左上方高空划下来的虚线(一级就是沿它飞回来的)
+ const tp = MO.cubicOut(clamp((lt - Qv.y15 + 0.1) / 1.2));
+ if (tp > 0 && lt < Qv.y17) { g.save(); g.setLineDash([16, 14]); g.lineDashOffset = -lt * 50; g.lineWidth = 5; g.strokeStyle = C.ink; g.globalAlpha = 0.4; g.lineCap = 'round';
+ g.beginPath(); for (let i = 0; i <= 30; i++) { const u = i / 30 * tp, x = lerp(640, LX, u) , y = lerp(140, GY - 420, Math.pow(u, 0.6)); i ? g.lineTo(x - (1 - u) * (1 - u) * 0, y) : g.moveTo(x, y); } g.stroke(); g.restore(); }
+ const b = boosterAt(lt), Bs = RK.falcon9({ legs: b.legs, fins: b.fins, stage: 'booster' });
+ // 2017 复飞的不是 2015 落地的那一枚(核对:SES-10 用的是另一枚回收一级):2015 那枚滑出画面,另一枚「回收的一级」吊装上台
+ const sw = Qv.y17 - 0.05, so = MO.cubicIn(clamp((lt - sw) / 0.4)), si = MO.cubicOut(clamp((lt - sw - 0.25) / 0.45));
+ if (lt < sw + 0.4) { g.save(); g.globalAlpha *= (b.a ?? 1) * clamp((b.y - 420) / 160) * (1 - so); L.rocket(g, RK.falcon9({ legs: lt < sw ? b.legs : 1, fins: 1, stage: 'booster' }), LX - 700 * so, lt < sw ? b.y : GY, PXM, { sx: SX, flame: lt < sw ? b.flame : 0, lt, rot: lt < sw ? b.rot : 0 }); g.restore(); }
+ if (lt > sw + 0.25) { const yIn = lt < sw + 0.7 ? lerp(GY - 300, GY, si) : b.y; g.save(); g.globalAlpha *= clamp((lt - sw - 0.25) / 0.2) * clamp((yIn - 420) / 160);
+ L.rocket(g, RK.falcon9({ legs: lt < sw + 0.7 ? 1 : b.legs, fins: b.fins, stage: 'booster' }), LX, yIn, PXM, { sx: SX, flame: lt < sw + 0.7 ? 0 : b.flame, lt, rot: 0, pal: { body: '#ECE6DA' } }); // 身上发黄发旧:飞过的一级
+ g.restore(); }
+ // 触地扬尘+放射线
+ const kd = lt - (Qv.dm + 0.05);
+ L.dust(g, LX, GY + 6, kd, { spread: 280, seed: 77 });
+ L.burstLines(g, LX, GY - 200, 300, 380, clamp(kd / 0.5), { n: 12, col: C.ink, lw: 6 });
+ // 标签
+ const kn = L.popK(lt, Qv.lyh - 0.05, 0.4, 2);
+ if (kn > 0 && lt < Qv.y17) L.at(g, LX - 330, 380, kn, h => L.kw(h, '猎鹰9号的一级', 0, 0, { size: 40, fill: C.white, col: C.ink }));
+ const ks = L.popK(lt, Qv.szh, 0.38, 2.4);
+ if (ks > 0 && lt < Qv.y17) L.at(g, LX + 330, 520, ks, h => { h.lineCap = 'round'; h.strokeStyle = C.ink; h.lineWidth = 8; h.beginPath(); h.moveTo(0, -110); h.lineTo(0, 110); h.stroke();
+ for (const d of [-1, 1]) { h.beginPath(); h.moveTo(-20, d * 86); h.lineTo(0, d * 112); h.lineTo(20, d * 86); h.stroke(); }
+ L.kw(h, '竖着落回', 80, 0, { size: 40, fill: C.yel, col: C.ink, align: 'left' }); });
+ const kt = L.popK(lt, Qv.tyh - 0.05, 0.42, 2.6);
+ if (kt > 0 && lt < Qv.y17 + 0.2) { g.save(); g.globalAlpha = 1 - L.outK(lt, Qv.y17 - 0.1, 0.25);
+ L.at(g, 1580, 300, kt, h => { L.txt(h, '轨道火箭里', 0, -70, 38, { align: 'center', col: C.sub }); L.kw(h, '头一回!', 0, 0, { size: 64, fill: C.red }); }, -0.05);
+ L.twinkles(g, lt, [[1390, 230], [1780, 240], [1760, 390]], { r: 20 }); g.restore(); }
+ // ③ 2017:贴「回收」圆标,再飞一次
+ const kh = L.popK(lt, Qv.hs - 0.05, 0.36, 2.8);
+ if (kh > 0 && b.y > 300) L.at(g, LX + 70, b.y - 250, kh, h => { h.lineWidth = 5; h.strokeStyle = C.ink; h.beginPath(); h.arc(0, 0, 58, 0, TAU); h.fillStyle = C.teal; h.fill(); h.stroke();
+ L.txt(h, '回收', 0, 3, 34, { col: C.white, align: 'center', base: 'middle' }); }, 0.15);
+ const kq = L.popK(lt, Qv.fst - 0.15, 0.4, 2.2); // 火箭飞走后,台上留一张小卡
+ if (kq > 0) L.at(g, LX, GY - 150, kq, h => { L.kw(h, '回收的一级 · 再飞一次', 0, 0, { size: 48, fill: C.white, col: C.ink }); }, -0.03);
+ const ky = L.popK(lt, Qv.yyc - 0.05, 0.4, 2.4);
+ if (ky > 0) L.at(g, 1580, 330, ky, h => L.kw(h, '又一次飞上天', 0, 0, { size: 54, fill: C.blue }), 0.04);
+}
+
+SCENES[ID] = {
+ init() { U.assertGlyphs('PuHui-Heavy', '二级一级重复用2015年12月猎鹰9号的一级竖着落回轨道火箭里头一回!2017年回收又一次飞上天回收的一级·再飞一次', ID); },
+ draw(c, lt) {
+ L.CUR_T = L.T0(ID) + lt;
+ const Qv = q();
+ L.bg(c, lt, { seed: 2615 });
+ // 页内切换:念到「2015年12月」时纸面往上卷(内容只在讲解员右边上下走,不扫过他);页眉不跟着卷,原地换
+ const sw = MO.cubicInOut(clamp((lt - (Qv.y15 - 0.4)) / 0.5));
+ if (sw < 1) { c.save(); c.globalAlpha = Math.max(0, 1 - 2 * sw); c.translate(0, -1080 * sw); pageA(c, lt); c.restore(); }
+ if (sw > 0) { c.save(); c.translate(0, 1080 * (1 - sw)); pageB(c, lt); c.restore(); }
+ if (lt < Qv.y15 - 0.15) L.pageTitle(c, lt, '回收一级', Qv.jz, { col: C.teal, size: 42 });
+ else if (lt < Qv.y17 - 0.05) L.pageTitle(c, lt, '2015年12月', Qv.y15 - 0.1, { col: C.red, size: 44 }); else L.pageTitle(c, lt, '2017年', Qv.y17 - 0.05, { col: C.red, size: 46 });
+ },
+};
+ERAS.find(e => e.id === ID).transition = { type: 'lin_wipe', dur: 0.6, cols: [C.yel, C.blue] };
+L.cast(ID, [
+ { t: 0.05, pose: 'think', fr: 'talk' },
+ { t: TM.cue(ID, '2015年12月') - 0.1, pose: 'stick', fr: 'talk', x: 560, walk: 0.8 }, // 走到着陆台跟前讲
+ { t: TM.cue(ID, '地面') + 0.05, pose: 'wow', fr: 'bounce' },
+ { t: TM.cue(ID, '2017年') - 0.05, pose: 'point', fr: 'talk' },
+ { t: TM.cue(ID, '飞上了天') - 0.2, pose: 'cheer', fr: 'bounce' },
+ { t: TM.dur(ID) - 0.32, pose: 'walk', fr: 'walk', x: -260, walk: 0.32 }, // 段尾才快步出画,下一段立刻从右边进
+]);
+L.year(ID, [[TM.cue(ID, '2015年12月'), 2015], [TM.cue(ID, '2017年'), 2017]]);
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex_lin/scenes/s06.js b/scripts/engine/reference_films/spacex/spacex_lin/scenes/s06.js
new file mode 100644
index 0000000..e2d9f28
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_lin/scenes/s06.js
@@ -0,0 +1,83 @@
+// S06 · 重型猎鹰(快切段 7 秒):① 三芯并联的重型猎鹰「首飞」点火冲出画面 ② 右边太阳+椭圆轨道,一辆红色小跑车沿轨道绕太阳跑,讲解员摊手
+// ③ 两枚助推器从天而降、同一帧并排落地,中间「并排」双箭头。转场:整页向上推(lin_slide up)。
+(() => {
+const ID = 's06', L = LIN, { C, TAU } = L, { clamp, lerp } = U;
+let Q = null;
+const q = () => Q || (Q = { y18: TM.cue(ID, '2018年'), zx: TM.cue(ID, '重型猎鹰'), sf: TM.cue(ID, '首飞'), pc: TM.cue(ID, '跑车'), rty: TM.cue(ID, '绕太阳'),
+ lm: TM.cue(ID, '两枚'), bp: TM.cue(ID, '并排'), dm: TM.cue(ID, '落回地面'), dmE: TM.end(ID, '落回地面') });
+
+function car(g, s = 1) {
+ g.save(); g.scale(s, s); g.lineWidth = 4; g.strokeStyle = C.ink; g.lineJoin = 'round';
+ // 敞篷跑车:低矮、长车头、斜挡风玻璃,座位露在外面
+ g.beginPath(); g.moveTo(-80, 10); g.lineTo(-80, -10); g.quadraticCurveTo(-60, -22, -20, -22); g.lineTo(6, -22); g.lineTo(20, -14); g.quadraticCurveTo(60, -16, 82, -6); g.lineTo(84, 10); g.closePath(); g.fillStyle = C.red; g.fill(); g.stroke();
+ g.fillStyle = C.blueL; g.beginPath(); g.moveTo(-4, -22); g.lineTo(12, -44); g.lineTo(18, -44); g.lineTo(8, -22); g.closePath(); g.fill(); g.stroke();
+ g.fillStyle = C.tile; g.beginPath(); g.moveTo(-46, -22); g.lineTo(-40, -42); g.lineTo(-28, -42); g.lineTo(-26, -22); g.closePath(); g.fill(); g.stroke();
+ for (const wx of [-40, 44]) { g.beginPath(); g.arc(wx, 10, 15, 0, TAU); g.fillStyle = C.tile; g.fill(); g.stroke(); g.beginPath(); g.arc(wx, 10, 5, 0, TAU); g.fillStyle = C.steel; g.fill(); }
+ g.restore();
+}
+const SUN = { x: 920, y: 470 }, ORX = 380, ORY = 165; // 这一段讲解员站到右边,信息图整体左移
+function heavyLaunch(g, lt) {
+ const Qv = q(), x = 520, base = 780, ig = Qv.sf - 0.2, rise = lt < ig + 0.25 ? 0 : Math.pow(lt - ig - 0.25, 2) * 700;
+ if (base - rise < -200) return;
+ const sh = lt > ig && lt < ig + 0.4 ? 3 * Math.sin(lt * 70) : 0;
+ L.rocket(g, RK.heavy({ payload: 'fairing' }), x + sh, base - rise, 7.4, { sx: 1.6, flame: lt > ig ? 0.5 : 0, lt }); // 尾焰收短,不伸进字幕区
+ if (lt > ig) for (let j = 0; j < 6; j++) { const ph = (lt * 1.8 + j / 6) % 1; g.save(); g.globalAlpha = 0.5 * (1 - ph) * (1 - clamp((lt - ig - 1.2) / 0.6)); g.fillStyle = '#E6DFD2';
+ g.beginPath(); g.arc(x - 130 + j * 52, base + 10 - ph * 30, 28 + ph * 34, 0, TAU); g.fill(); g.restore(); }
+ const kn = L.popK(lt, Qv.zx - 0.05, 0.4, 2) * (1 - L.outK(lt, Qv.pc - 0.2, 0.3));
+ if (kn > 0) L.at(g, x + 250, 420, kn, h => { L.kw(h, '重型猎鹰', 0, 0, { size: 52, fill: C.red }); L.at(h, 0, 84, L.popK(lt, Qv.sf, 0.36, 2.6), s => L.kw(s, '首飞', 0, 0, { size: 42, fill: C.yel, col: C.ink })); });
+}
+function orbit(g, lt) {
+ const Qv = q(); if (lt < Qv.pc - 0.5) return;
+ const shrink = MO.cubicInOut(clamp((lt - (Qv.lm - 0.15)) / 0.5));
+ g.save(); L.cam(g, lerp(1, 0.5, shrink), SUN.x, SUN.y, lerp(0, -330, shrink), lerp(0, -240, shrink));
+ const ks = L.popK(lt, Qv.pc - 0.15, 0.5, 1.7), op = MO.cubicOut(clamp((lt - Qv.rty + 0.1) / 0.6));
+ if (op > 0) { g.save(); g.setLineDash([18, 14]); g.lineDashOffset = -lt * 40; g.lineWidth = 5; g.strokeStyle = C.ink; g.globalAlpha = 0.6; g.lineCap = 'round';
+ g.beginPath(); g.ellipse(SUN.x, SUN.y, ORX, ORY, -0.08, -Math.PI / 2, -Math.PI / 2 + TAU * op); g.stroke(); g.restore(); }
+ L.sun(g, SUN.x, SUN.y, 90, lt, ks);
+ const kc = L.popK(lt, Qv.pc - 0.1, 0.4, 2.4);
+ if (kc > 0) { const th = -Math.PI / 2 + (lt - Qv.pc) * 0.9, cx = SUN.x + ORX * Math.cos(th) * Math.cos(-0.08) - ORY * Math.sin(th) * Math.sin(-0.08), cy = SUN.y + ORX * Math.cos(th) * Math.sin(-0.08) + ORY * Math.sin(th) * Math.cos(-0.08);
+ L.ring(g, lt, cx, cy - 10, 120, 70, clamp((lt - Qv.pc - 0.1) / 0.4), { seed: 71, col: C.red, lw: 6 });
+ L.at(g, cx, cy, kc, h => car(h, 1.3), Math.atan2(ORY * Math.cos(th), -ORX * Math.sin(th)) * 0.25); }
+ const kr = L.popK(lt, Qv.rty - 0.05, 0.4, 2.2);
+ if (kr > 0 && shrink < 0.6) { g.save(); g.globalAlpha *= 1 - clamp(shrink / 0.4); L.at(g, SUN.x, SUN.y + ORY + 110, kr, h => L.kw(h, '绕太阳的轨道', 0, 0, { size: 50, fill: C.orange })); g.restore(); } // 缩成角落小图时标签先退场
+ g.restore();
+}
+const GY = 830, BX = [640, 930];
+function landing(g, lt) {
+ const Qv = q(); if (lt < Qv.lm - 0.3) return;
+ const kg = MO.cubicOut(clamp((lt - Qv.lm + 0.3) / 0.4));
+ g.save(); g.globalAlpha = kg; g.lineWidth = 5; g.strokeStyle = C.ink; g.fillStyle = '#EADFCB'; g.beginPath(); g.rect(0, GY + 12, 1920, 300); g.fill(); g.beginPath(); g.moveTo(0, GY + 12); g.lineTo(1920, GY + 12); g.stroke();
+ for (const x of BX) { g.fillStyle = C.steelD; g.beginPath(); g.ellipse(x, GY + 14, 110, 20, 0, 0, TAU); g.fill(); g.stroke(); } g.restore();
+ const tA = Qv.lm - 0.1, tD = Qv.dm + 0.1, u = clamp((lt - tA) / (tD - tA)), e = 1 - Math.pow(1 - u, 2.2), y = lerp(420, GY, e), fin = clamp(u / 0.18);
+ g.save(); g.globalAlpha *= fin; // 从时间轴胶囊下方淡入,不穿过它
+ for (const [i, x] of BX.entries()) L.rocket(g, RK.falcon9({ stage: 'booster', legs: clamp((lt - (tD - 0.8)) / 0.5), fins: 1 }), x, y, 6.8, { sx: 1.75, flame: lt < tD + 0.12 ? 1 : 0, lt, seed: i });
+ g.restore();
+ const kd = lt - tD;
+ for (const x of BX) L.burstLines(g, x, GY - 120, 190, 260, clamp(kd / 0.5), { n: 10, col: C.ink, lw: 5 });
+ for (const [i, x] of BX.entries()) L.dust(g, x, GY + 4, kd, { spread: 150, seed: 11 + i, n: 5 });
+ const kb = L.popK(lt, Qv.bp - 0.05, 0.38, 2.6);
+ if (kb > 0) L.at(g, (BX[0] + BX[1]) / 2, 420, kb, h => { h.lineCap = 'round'; h.strokeStyle = C.ink; h.lineWidth = 8; h.beginPath(); h.moveTo(-100, 80); h.lineTo(100, 80); h.stroke();
+ for (const d of [-1, 1]) { h.beginPath(); h.moveTo(d * 76, 58); h.lineTo(d * 102, 80); h.lineTo(d * 76, 102); h.stroke(); }
+ L.kw(h, '并排落回', 0, 0, { size: 48, fill: C.blue }); });
+}
+
+SCENES[ID] = {
+ init() { U.assertGlyphs('PuHui-Heavy', '2018年重型猎鹰首飞绕太阳的轨道并排落回', ID); },
+ draw(c, lt) {
+ L.CUR_T = L.T0(ID) + lt;
+ L.bg(c, lt, { seed: 2616 });
+ L.pageTitle(c, lt, '2018年', q().y18 - 0.1, { col: C.red, size: 46 });
+ heavyLaunch(c, lt); orbit(c, lt); landing(c, lt);
+ },
+};
+ERAS.find(e => e.id === ID).transition = { type: 'lin_slide', dur: 0.55, dir: 'up' };
+L.cast(ID, [
+ { t: 0.0, pose: 'walk', fr: 'walk', x: 2150 }, // 换场:讲解员从右边走进来,这一段站在右边
+ { t: 0.02, pose: 'point', fr: 'talk', x: 1600, walk: 0.6, flip: true },
+ { t: TM.cue(ID, '跑车') - 0.05, pose: 'shrug', fr: 'talk', flip: true },
+ { t: TM.cue(ID, '两枚') - 0.05, pose: 'stick', fr: 'talk', flip: true },
+ { t: TM.end(ID, '落回地面') - 0.1, pose: 'thumb', fr: 2, flip: true },
+ { t: TM.end(ID, '落回地面') + 0.05, pose: 'walk', fr: 'walk', x: 2150, walk: 0.45 }, // 从右边退场
+]);
+L.year(ID, [[TM.cue(ID, '2018年'), 2018]]);
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex_lin/scenes/s07.js b/scripts/engine/reference_films/spacex/spacex_lin/scenes/s07.js
new file mode 100644
index 0000000..b7b5299
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_lin/scenes/s07.js
@@ -0,0 +1,101 @@
+// S07 · 载人龙飞船(慢推→留白段):① 大号载人龙飞船,舷窗里两个面罩不透明的宇航员头盔,旁边两个宇航员图标「两名宇航员」
+// → 飞船缩小沿虚线飞向右上的空间站 ② 时间条:2011 —— 2020,中间一段空白、大括号「近9年」;「本土」发射台上一枚火箭升空
+// ③ 「第一次」:私人公司的飞船 → 箭头 → 把人送进轨道(地球+轨道+宇航员)。转场:从画面中心的圆扩开(lin_iris,青色边)。
+(() => {
+const ID = 's07', L = LIN, { C, TAU } = L, { clamp, lerp } = U;
+let Q = null;
+const q = () => Q || (Q = { y20: TM.cue(ID, '2020年5月'), zr: TM.cue(ID, '载人龙飞船'), lm: TM.cue(ID, '两名宇航员'), sw: TM.cue(ID, '送往空间站'), mg: TM.cue(ID, '美国'),
+ jg: TM.cue(ID, '近9年'), cx: TM.cue(ID, '重新从本土'), bt: TM.cue(ID, '本土'), srst: TM.cue(ID, '送人上天'), dyc: TM.cue(ID, '第一次'), sr: TM.cue(ID, '私人公司'),
+ fc: TM.cue(ID, '的飞船'), sj: TM.cue(ID, '送进轨道') });
+
+function pageA(g, lt) {
+ const Qv = q();
+ const kd = L.popK(lt, 0.2, 0.4, 2) * (1 - L.outK(lt, Qv.sw - 0.35, 0.25)); // 日历页:2020 年 5 月
+ if (kd > 0) L.at(g, 1500, 300, kd * 0.85, h => L.calPage(h, '2020年', '5月', C.red, '', { w: 220, h: 220 }), 0.05);
+ const fly = MO.cubicInOut(clamp((lt - Qv.sw) / 0.8));
+ const ki = L.popK(lt, Qv.sw - 0.2, 0.45, 1.8);
+ if (ki > 0) { L.at(g, 1620, 300 + 5 * Math.sin(lt * 1.4), ki * 0.95, h => L.iss(h, 0, 0, 1), 0.05);
+ g.save(); g.setLineDash([16, 14]); g.lineDashOffset = -lt * 50; g.lineWidth = 5; g.strokeStyle = C.ink; g.globalAlpha = 0.5 * ki; g.lineCap = 'round';
+ g.beginPath(); g.moveTo(1000, 560); g.quadraticCurveTo(1250, 300, 1560, 400); g.stroke(); g.restore(); }
+ // 飞船:先大号亮相,念到「送往空间站」时缩小沿弧线飞去对接
+ const kc = L.popK(lt, 0.15, 0.5, 1.8), u = fly, bx = (1 - u) ** 2 * 1000 + 2 * (1 - u) * u * 1250 + u * u * 1600, by = (1 - u) ** 2 * 700 + 2 * (1 - u) * u * 340 + u * u * 470;
+ L.at(g, bx, by + (1 - fly) * 6 * Math.sin(lt * 2), kc * lerp(3.0, 0.8, fly), h => L.capsule(h, 0, 0, 1, {}), lerp(0.04 * Math.sin(lt * 1.3), 0, fly));
+ // 两名宇航员
+ const ka = L.popK(lt, Qv.lm - 0.05, 0.42, 2.2) * (1 - fly);
+ if (ka > 0) { L.at(g, 1340, 560, ka, h => L.astro(h, 0, 0, 1.2), -0.06 + 0.04 * Math.sin(lt * 2.4)); L.at(g, 1500, 570, ka, h => L.astro(h, 0, 0, 1.2), 0.06 + 0.04 * Math.sin(lt * 2.4 + 1));
+ L.at(g, 1420, 740, ka, h => L.kw(h, '两名宇航员', 0, 0, { size: 46, fill: C.blue })); }
+ const kz = L.popK(lt, Qv.zr, 0.4, 2) * (1 - fly);
+ if (kz > 0) L.at(g, 1000, 270, kz, h => L.kw(h, '载人龙飞船', 0, 0, { size: 50, fill: C.white, col: C.ink }));
+ if (fly > 0.98) L.burstLines(g, 1600, 440, 70, 140, clamp((lt - Qv.sw - 0.8) / 0.5), { n: 9, lw: 5 });
+}
+// ② 2011 —— 2020:近 9 年
+const TY = 420, X11 = 760, X20 = 1640;
+function pageB(g, lt) {
+ const Qv = q(); if (lt < Qv.mg - 0.4) return;
+ const lp = MO.cubicOut(clamp((lt - Qv.mg + 0.2) / 0.6));
+ g.save(); g.lineCap = 'round'; g.lineWidth = 14; g.strokeStyle = '#E2D9C8'; g.beginPath(); g.moveTo(X11, TY); g.lineTo(lerp(X11, X20, lp), TY); g.stroke(); g.restore();
+ for (const [x, lab, t] of [[X11, '2011', Qv.mg - 0.2], [X20, '2020', Qv.mg + 0.25]]) { const k = L.popK(lt, t, 0.35, 2.2); if (k <= 0) continue;
+ L.at(g, x, TY, k, h => { h.beginPath(); h.arc(0, 0, 20, 0, TAU); h.fillStyle = x === X20 ? C.red : C.white; h.fill(); h.lineWidth = 5; h.strokeStyle = C.ink; h.stroke(); L.txt(h, lab, 0, -42, 48, { align: 'center', w: 'Black' }); }); }
+ // 空白段里的小问号在晃
+ if (lp > 0.5) for (let i = 0; i < 3; i++) { const x = lerp(X11, X20, 0.3 + i * 0.2); g.save(); g.globalAlpha = 0.45; L.txt(g, '?', x, TY + 8 + 6 * Math.sin(lt * 3 + i), 40, { align: 'center', col: C.sub, base: 'middle' }); g.restore(); }
+ // 大括号+近9年
+ const bp = MO.cubicOut(clamp((lt - Qv.jg + 0.1) / 0.4));
+ if (bp > 0) { g.save(); g.strokeStyle = C.purple; g.lineWidth = 7; g.lineCap = 'round'; g.lineJoin = 'round'; const m = (X11 + X20) / 2, y = TY + 50, w = (X20 - X11) / 2 * bp;
+ g.beginPath(); g.moveTo(m - w, y); g.quadraticCurveTo(m - w, y + 30, m - w + 30, y + 30); g.lineTo(m - 30, y + 30); g.quadraticCurveTo(m, y + 30, m, y + 60); g.quadraticCurveTo(m, y + 30, m + 30, y + 30); g.lineTo(m + w - 30, y + 30); g.quadraticCurveTo(m + w, y + 30, m + w, y); g.stroke(); g.restore();
+ L.at(g, (X11 + X20) / 2, TY + 160, L.popK(lt, Qv.jg, 0.4, 2.4), h => L.kw(h, '近9年', 0, 0, { size: 60, fill: C.purple })); }
+ // 本土发射台+地图钉
+ const kb = L.popK(lt, Qv.bt - 0.1, 0.42, 2);
+ if (kb > 0) { const px = 1430, gy = 830;
+ L.at(g, px, gy, kb, h => { h.lineWidth = 5; h.strokeStyle = C.ink; h.fillStyle = C.steelD; h.fill(L.rrp(-90, 0, 180, 30, 10)); h.stroke(L.rrp(-90, 0, 180, 30, 10)); });
+ L.at(g, px - 240, gy - 70, kb, h => { h.lineWidth = 5; h.strokeStyle = C.ink; h.beginPath(); h.moveTo(0, 50); h.bezierCurveTo(-50, -10, -40, -70, 0, -70); h.bezierCurveTo(40, -70, 50, -10, 0, 50); h.fillStyle = C.red; h.fill(); h.stroke();
+ h.beginPath(); h.arc(0, -30, 16, 0, TAU); h.fillStyle = C.white; h.fill(); h.stroke(); L.kw(h, '本土', 0, 100, { size: 40, fill: C.ink }); }, 0.06 * Math.sin(lt * 2));
+ const rise = lt < Qv.cx + 0.4 ? 0 : Math.pow(lt - Qv.cx - 0.4, 2) * 520;
+ L.rocket(g, RK.falcon9({ payload: 'dragon' }), px, gy - rise, 3.6, { sx: 1.75, flame: lt > Qv.cx + 0.2 ? 1.1 : 0, lt });
+ L.at(g, px + 260, gy - 200, L.popK(lt, Qv.cx + 0.3, 0.38, 2.4), h => L.kw(h, '送人上天', 0, 0, { size: 44, fill: C.yel, col: C.ink }));
+ }
+}
+// ③ 第一次:私人公司的飞船 → 送人进轨道
+function pageC(g, lt) {
+ const Qv = q(); if (lt < Qv.dyc - 0.5) return;
+ const kf = L.popK(lt, Qv.dyc + 0.25, 0.45, 2.6); // 等纸面卷到位再弹,不从字幕区里冒出来
+ if (kf > 0) L.at(g, 1060, 230, kf, h => { L.kw(h, '第一次', 0, 0, { size: 74, fill: C.red }); }, -0.04);
+ if (kf > 0) L.burstLines(g, 1060, 230, 170, 230, clamp((lt - Qv.dyc) / 0.5), { n: 10, col: C.red, lw: 6 });
+ const k1 = L.popK(lt, Qv.sr - 0.05, 0.45, 2);
+ if (k1 > 0) L.at(g, 600, 560, k1 * 1.12, h => { L.card(h, -200, -170, 400, 340, { fill: C.white }); L.capsule(h, 0, 50, 1.25, {}); L.kw(h, '私人公司的飞船', 0, 120, { size: 36, fill: C.blue }); }, 0.02 * Math.sin(lt * 1.7));
+ L.arrow(g, lt, 840, 470, 920, 470, MO.cubicOut(clamp((lt - Qv.fc - 0.2) / 0.3)), { seed: 8, bend: -12, lw: 8, head: 24 }); // 分屏:左边飞船 → 中间讲解员 → 右边送进轨道
+ L.arrow(g, lt, 1220, 470, 1300, 470, MO.cubicOut(clamp((lt - Qv.fc + 0.05) / 0.3)), { seed: 9, bend: -12, lw: 8, head: 24 });
+ const k2 = L.popK(lt, Qv.sj - 0.25, 0.45, 2);
+ if (k2 > 0) L.at(g, 1540, 560, k2 * 1.12, h => { L.card(h, -200, -170, 400, 340, { fill: C.white });
+ h.save(); h.setLineDash([10, 9]); h.lineDashOffset = -lt * 30; h.lineWidth = 4; h.strokeStyle = C.ink; h.beginPath(); h.ellipse(0, -10, 150, 46, -0.15, 0, TAU); h.stroke(); h.restore();
+ L.earth(h, 0, -10, 70, lt, { spin: 24 }); const th = lt * 2.2; L.astro(h, 150 * Math.cos(th) * 0.99, -10 + 46 * Math.sin(th) - 30, 0.45);
+ L.kw(h, '送进轨道', 0, 120, { size: 36, fill: C.teal }); }, -0.02 * Math.sin(lt * 1.7));
+}
+
+SCENES[ID] = {
+ init() { U.assertGlyphs('PuHui-Heavy', '私人公司2020年5月载人龙飞船两名宇航员20112020?近9年本土送人上天第一次私人公司的飞船送进轨道', ID); U.assertGlyphs('PuHui-Black', '20112020', ID); },
+ draw(c, lt) {
+ L.CUR_T = L.T0(ID) + lt;
+ const Qv = q();
+ L.bg(c, lt, { seed: 2617 });
+ const s1 = MO.cubicInOut(clamp((lt - (Qv.mg - 0.45)) / 0.5)), s2 = MO.cubicInOut(clamp((lt - (Qv.dyc - 0.25)) / 0.45));
+ // 三屏横向排开,同一张纸往左拉
+ const off = -1080 * (s1 + s2); // 纸面往上卷:内容只在讲解员右边上下走
+ if (s1 < 1) { c.save(); c.globalAlpha = Math.max(0, 1 - 2 * s1); c.translate(0, off); pageA(c, lt); c.restore(); }
+ if (s1 > 0 && s2 < 1) { c.save(); if (s1 < 1) { c.beginPath(); c.rect(0, 0, 1920, 905); c.clip(); } c.globalAlpha = Math.max(0, 1 - 2 * s2); c.translate(0, off + 1080); pageB(c, lt); c.restore(); }
+ if (s2 > 0) { c.save(); if (s2 < 1) { c.beginPath(); c.rect(0, 0, 1920, 905); c.clip(); } c.translate(0, off + 2160); pageC(c, lt); c.restore(); }
+ if (lt < Qv.mg - 0.3) L.pageTitle(c, lt, '2020年5月', Qv.y20 - 0.1, { col: C.red, size: 44 }); else if (lt < Qv.dyc - 0.25) L.pageTitle(c, lt, '时隔近9年', Qv.mg - 0.3, { col: C.purple, size: 42 });
+ else L.pageTitle(c, lt, '私人公司', Qv.dyc - 0.2, { col: C.blue, size: 42 });
+ },
+};
+ERAS.find(e => e.id === ID).transition = { type: 'lin_iris', dur: 0.6, x: 1180, y: 520, col: C.teal };
+L.cast(ID, [
+ { t: 0.0, pose: 'walk', fr: 'walk', x: -260 },
+ { t: 0.05, pose: 'present', fr: 'talk', x: 330, walk: 0.85 }, // 从左边走回来
+ { t: TM.cue(ID, '美国') - 0.05, pose: 'think', fr: 'talk' },
+ { t: TM.cue(ID, '送人上天') - 0.05, pose: 'point', fr: 'talk' },
+ { t: TM.cue(ID, '也是第一次') - 0.1, pose: 'count', fr: 0, x: 1060, walk: 0.75 }, // 走到画面中间,左右两张卡分列两边
+ { t: TM.cue(ID, '私人公司') - 0.05, pose: 'present', fr: 'talk', flip: true }, // 先朝左指飞船
+ { t: TM.cue(ID, '送进轨道') - 0.05, pose: 'present', fr: 'talk', flip: false },
+]);
+L.year(ID, [[TM.cue(ID, '2020年5月'), 2020]]);
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex_lin/scenes/s08.js b/scripts/engine/reference_films/spacex/spacex_lin/scenes/s08.js
new file mode 100644
index 0000000..d01900b
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_lin/scenes/s08.js
@@ -0,0 +1,151 @@
+// S08 · 发射越来越密(数据段,纸面往上滚三屏):① 可爱柱状图:猎鹰火箭年发射次数 2017 / 2022–2025 依次长出(2017 与 2022 之间断轴),
+// 念到 2025 其余变灰,165 计数落定+红圈 ② 两周小日历里每隔两天多冒出一枚小火箭「平均两天多一发」;天平:猎鹰9号这边比「全世界其他火箭」更沉
+// ③ 一枚助推器+37 个小火箭图标逐个点亮(Isotype),「37次」。数据只用核对表第 16–18 条。转场:整页左推(lin_slide)。
+(() => {
+const ID = 's08', L = LIN, { C, TAU } = L, { clamp, lerp } = U;
+let Q = null;
+const q = () => Q || (Q = { hs: TM.cue(ID, '回收之后'), fs: TM.cue(ID, '发射越来越密'), y25: TM.cue(ID, '2025年'), n165: TM.cue(ID, '165次'), n165E: TM.end(ID, '165次'),
+ pj: TM.cue(ID, '平均两天多一发'), pjE: TM.end(ID, '一发'), sj: TM.cue(ID, '比全世界'), qt: TM.cue(ID, '其他火箭'), hd: TM.cue(ID, '还多'), yym: TM.cue(ID, '有一枚助推器'),
+ yj: TM.cue(ID, '已经飞了'), n37: TM.cue(ID, '37次'), n37E: TM.end(ID, '37次') });
+
+const BARS = [{ y: '2017', v: 18, x: 800 }, { y: '2022', v: 61, x: 1090 }, { y: '2023', v: 96, x: 1270 }, { y: '2024', v: 134, x: 1450 }, { y: '2025', v: 165, x: 1630 }];
+const BASE = 790, KH = 2.85, BW = 128;
+function pageA(g, lt) {
+ const Qv = q();
+ const hiK = clamp((lt - Qv.y25) / 0.35);
+ // 2025 柱的计数:从「2025年」开始爬,念到「165」那个字时落定;落定后才圈、才放大
+ const t5 = Qv.y25 - 0.4, land = Qv.n165 + 0.12, vp5 = MO.cubicOut(clamp((lt - t5) / (land - t5)));
+ const hit = lt - land, punch = hit > 0 ? MO.settle(hit, 0.18, 2.5, 6) : 0;
+ // 镜头:落定那一下推近 2025 柱,停住,翻页前拉回
+ const push = MO.cubicInOut(clamp((lt - (land - 0.15)) / 0.45)) * (1 - MO.cubicInOut(clamp((lt - (Qv.pj + 0.25)) / 0.35)));
+ const dimAll = 0.82 * push; // 大数字砸入时,整张图退到背景
+ g.save(); g.globalAlpha *= 1 - dimAll;
+ // 底线+断轴
+ const ax = MO.cubicOut(clamp((lt - 0.05) / 0.45));
+ g.save(); g.lineCap = 'round'; g.strokeStyle = C.ink; g.lineWidth = 6; g.beginPath(); g.moveTo(690, BASE); g.lineTo(lerp(690, 940, ax), BASE); g.stroke();
+ if (ax > 0.5) { g.beginPath(); g.moveTo(1000, BASE); g.lineTo(lerp(1000, 1740, ax), BASE); g.stroke();
+ g.lineWidth = 5; for (const dx of [0, 22]) { g.beginPath(); g.moveTo(950 + dx, BASE + 18); g.lineTo(966 + dx, BASE - 18); g.stroke(); } }
+ g.restore();
+ BARS.forEach((b, i) => {
+ const last = i === 4, t0 = last ? t5 : Qv.hs + 0.2 + i * 0.28, gp = last ? vp5 : MO.cubicOut(clamp((lt - t0) / 0.35));
+ if (lt < t0) return;
+ const h = Math.max(2, b.v * KH * gp), dim = last ? 0 : hiK;
+ g.save(); g.globalAlpha = 1 - 0.55 * dim;
+ L.card(g, b.x - BW / 2, BASE - h, BW, h, { fill: last ? C.red : C.blue, r: 14, lw: 4, sh: 6 });
+ L.txt(g, b.y, b.x, BASE + 52, 38, { align: 'center', col: last ? C.red : C.ink });
+ if (last) L.at(g, b.x, BASE - h - 22, 1 + punch, hh => L.txt(hh, String(Math.round(165 * vp5)), 0, 0, 74, { align: 'center', w: 'Black', col: C.red }));
+ else L.at(g, b.x, BASE - h - 22, L.popK(lt, t0 + 0.3, 0.3, 2.4), hh => L.txt(hh, String(b.v), 0, 0, 46, { align: 'center', w: 'Black' })); // 柱子长完才亮出数,不出现中途倒挂
+ g.restore();
+ });
+ const h5 = 165 * KH * vp5;
+ if (lt > t5) L.rocket(g, L.F1(), BARS[4].x + 112, BASE - h5 + 40 - 8 * Math.abs(Math.sin(lt * 4)), 4.2, { fins: true, sx: 3.6, rot: 0.3 });
+ L.ring(g, lt, BARS[4].x, BASE - h5 - 48, 124, 66, clamp((lt - land - 0.05) / 0.35), { seed: 17, col: C.red, lw: 7 });
+ if (hit > 0) L.twinkles(g, lt, [[BARS[4].x - 150, BASE - h5 - 90], [BARS[4].x + 150, BASE - h5 - 70]], { r: 18 });
+ g.restore();
+ // 大数字砸入:165 次独占一屏(停 1.3 秒左右),翻页前收回
+ // 卡片从 2025 那根红柱顶上长出来、讲完再缩回红柱
+ // 进场:从 2025 红柱顶上长出来;退场:原地淡出(不再缩回去压住柱顶的数)
+ const entering = lt < land + 0.6, ks = push > 0.01 ? (entering ? 0.15 + 0.85 * push : 1) * (1 + MO.settle(lt - land - 0.3, 0.06, 3, 6)) : 0, kx = entering ? lerp(1630, 1000, push) : 1000, ky = entering ? lerp(300, 520, push) : 520;
+ if (ks > 0) { g.save(); g.globalAlpha *= entering ? 1 : push; L.at(g, kx, ky, ks, h => {
+ L.card(h, -380, -230, 760, 430, { fill: C.white, r: 40, lw: 6, sh: 12 });
+ L.txt(h, '2025年 · 猎鹰9号发射', 0, -150, 44, { align: 'center', col: C.sub });
+ L.txt(h, '165', 60, 105, 230, { align: 'right', w: 'Black', col: C.red }); L.txt(h, '次', 80, 105, 110, { w: 'Black' });
+ L.marker(h, -300, 130, 600, 26, MO.cubicOut(clamp((lt - land - 0.25) / 0.3)), C.hl, 9);
+ }, -0.03); g.restore(); }
+ if (push > 0.9) L.burstLines(g, 1000, 520, 460, 580, clamp((lt - land) / 0.55), { n: 14, col: C.red, lw: 8 });
+ const kk = L.popK(lt, Qv.y25 + 0.1, 0.4, 2.4);
+ if (kk > 0) L.at(g, 1060, 210, kk, h => L.kw(h, '2025年 · 全是猎鹰9号', 0, 0, { size: 46, fill: C.yel, col: C.ink }), -0.03); // 和图题「猎鹰火箭」对上口径
+ // 因果链:回收 → 发射越来越密(念「回收之后,发射越来越密」)
+ const out = 1 - hiK;
+ if (out > 0) { g.save(); g.globalAlpha *= out;
+ const k1 = L.popK(lt, Qv.hs, 0.4, 2.2), k2 = L.popK(lt, Qv.fs, 0.4, 2.2);
+ if (k1 > 0) L.at(g, 820, 220, k1, h => L.kw(h, '回收重复用', 0, 0, { size: 42, fill: C.teal }));
+ L.arrow(g, lt, 990, 220, 1120, 220, MO.cubicOut(clamp((lt - Qv.fs + 0.2) / 0.3)), { seed: 31, bend: -14, lw: 7, head: 24 });
+ if (k2 > 0) L.at(g, 1290, 220, k2, h => L.kw(h, '发射越来越密', 0, 0, { size: 42, fill: C.blue }));
+ g.restore(); }
+}
+// ② 日历+天平
+const DAYS = [0, 2, 5, 7, 9, 12]; // 两周 6 发≈2.3 天一发(「两天多一发」)
+function calendar(g, lt) {
+ const Qv = q(), k = L.popK(lt, Qv.pj + 0.6, 0.45, 1.8); if (k <= 0) return;
+ L.at(g, 840, 560, k * 0.94, h => { // 日历放低一点:讲解员要坐在它上沿
+ L.card(h, -280, -190, 560, 380, { fill: C.white }); h.save(); h.clip(L.rrp(-280, -190, 560, 380, 26)); h.fillStyle = C.red; h.fillRect(-280, -190, 560, 70); h.restore();
+ h.lineWidth = 4; h.strokeStyle = C.ink; h.stroke(L.rrp(-280, -190, 560, 380, 26)); h.beginPath(); h.moveTo(-280, -120); h.lineTo(280, -120); h.stroke();
+ L.txt(h, '两周', 0, -152, 38, { col: C.white, align: 'center', base: 'middle' });
+ for (let d = 0; d < 14; d++) { const cx = -234 + (d % 7) * 78, cy = -60 + Math.floor(d / 7) * 130;
+ h.fillStyle = '#F4EFE6'; h.fill(L.rrp(cx - 32, cy - 50, 64, 110, 12));
+ const i = DAYS.indexOf(d); if (i < 0) continue; const kr = L.popK(lt, Qv.pj + 0.75 + i * 0.1, 0.3, 2.6);
+ if (kr > 0) L.at(h, cx, cy + 40, kr, s => L.rocket(s, L.F1(), 0, 0, 3.4, { fins: true, sx: 3.6, flame: 0.6, lt, seed: d })); }
+ });
+ const kw = L.popK(lt, Qv.pj + 0.8, 0.4, 2.2);
+ if (kw > 0) L.at(g, 840, 868, kw, h => L.kw(h, '平均两天多一发', 0, 0, { size: 46, fill: C.teal }));
+}
+function scale(g, lt) {
+ const Qv = q(), k = L.popK(lt, Qv.sj - 0.1, 0.45, 1.8); if (k <= 0) return;
+ const tilt = 0.06 * MO.cubicInOut(clamp((lt - Qv.qt) / 0.5)) + 0.26 * MO.cubicInOut(clamp((lt - Qv.hd + 0.2) / 0.35)) + MO.settle(lt - Qv.hd - 0.2, 0.05, 2.5, 4) + 0.012 * Math.sin(lt * 2);
+ L.at(g, 1430, 560, k * 0.92, h => {
+ h.lineWidth = 5; h.strokeStyle = C.ink; h.lineJoin = 'round'; h.lineCap = 'round';
+ h.fillStyle = C.tile; h.beginPath(); h.moveTo(-90, 250); h.lineTo(90, 250); h.lineTo(20, 200); h.lineTo(20, -40); h.lineTo(-20, -40); h.lineTo(-20, 200); h.closePath(); h.fill(); h.stroke();
+ h.save(); h.rotate(-tilt); h.fillStyle = C.goldD; h.fill(L.rrp(-260, -56, 520, 22, 11)); h.stroke(L.rrp(-260, -56, 520, 22, 11)); h.restore();
+ h.beginPath(); h.arc(0, -45, 16, 0, TAU); h.fillStyle = C.gold; h.fill(); h.stroke();
+ for (const d of [-1, 1]) { const ex = d * 240 * Math.cos(tilt), yy = -45 - d * 240 * Math.sin(tilt);
+ h.beginPath(); h.moveTo(ex, yy); h.lineTo(ex - 70, yy + 120); h.moveTo(ex, yy); h.lineTo(ex + 70, yy + 120); h.stroke();
+ h.beginPath(); h.moveTo(ex - 100, yy + 120); h.quadraticCurveTo(ex, yy + 175, ex + 100, yy + 120); h.closePath(); h.fillStyle = C.steel; h.fill(); h.stroke();
+ if (d < 0) { for (let i = 0; i < 5; i++) L.rocket(h, L.F1(), ex - 64 + i * 32, yy + 124, 3.2, { fins: true, sx: 3.2 }); L.kw(h, '猎鹰9号', ex, yy + 214, { size: 38, fill: C.red }); }
+ else { const r = U.rng(5); for (let i = 0; i < 4; i++) L.rocket(h, L.F1(), ex - 54 + i * 36, yy + 124, 2.4 + r() * 0.8, { fins: true, sx: 3.2, pal: { nose: C.mute, body: '#EDEAE4' } }); L.kw(h, '其他火箭加起来', ex - 20, yy + 214, { size: 38, fill: C.white, col: C.ink }); }
+ }
+ });
+ const kh = L.popK(lt, Qv.hd - 0.05, 0.38, 2.8);
+ if (kh > 0) L.at(g, 1430, 300, kh, h => L.kw(h, '还多!', 0, 0, { size: 56, fill: C.red }), -0.05);
+}
+// ③ 37 次
+function pageC(g, lt) {
+ const Qv = q(), kb = L.popK(lt, Qv.yym - 0.2, 0.45, 1.8);
+ if (kb > 0) L.at(g, 1440, 850, kb, h => { L.rocket(h, RK.falcon9({ stage: 'booster', legs: 1, fins: 1 }), 0, 0, 10.5, { sx: 1.75, lw: 5 });
+ // 身上贴满飞行贴纸
+ const n = Math.round(37 * MO.expoOut(clamp((lt - Qv.yj + 0.4) / (Qv.n37E - Qv.yj + 0.4))));
+ for (let i = 0; i < Math.min(n, 12); i++) { const yy = -90 - i * 26, xx = (i % 2 ? 1 : -1) * 4; h.fillStyle = [C.yel, C.teal, C.pink, C.blue][i % 4]; h.beginPath(); h.arc(xx, yy, 8, 0, TAU); h.fill(); h.lineWidth = 2; h.strokeStyle = C.ink; h.stroke(); } }, 0.015 * Math.sin(lt * 1.8));
+ if (kb > 0) L.at(g, 1440, 350, kb, h => L.kw(h, '有一枚助推器', 0, 0, { size: 40, fill: C.white, col: C.ink }));
+ if (kb > 0) L.at(g, 840, 872, L.popK(lt, Qv.n37 + 0.1, 0.4, 2.2), h => L.kw(h, '截至2026年8月', 0, 0, { size: 36, fill: C.yel, col: C.ink }), 0.03);
+ const c0 = Qv.yj - 0.4, c1 = Qv.n37E, cp = clamp((lt - c0) / (c1 - c0)), n = Math.floor(37 * MO.cubicOut(cp) + 1e-6);
+ if (lt < c0 - 0.3) return;
+ for (let i = 0; i < 37; i++) { const x = 548 + (i % 10) * 64, y = 270 + Math.floor(i / 10) * 108, on = i < n; // 这一屏讲解员在右边,点数图挪到左边
+ g.save(); g.globalAlpha = on ? 1 : 0.22; const pk = on ? MO.settle(lt - (c0 + (c1 - c0) * MO.invert(MO.cubicOut, (i + 1) / 37)), 0.25, 3, 8) : 0;
+ L.rocket(g, L.F1(), x, y + 34, 3.4 * (1 + pk), { fins: true, sx: 3.6, pal: on ? {} : { nose: C.mute } }); g.restore(); }
+ const kn = L.popK(lt, c0, 0.35, 2);
+ if (kn > 0) L.at(g, 850, 790, kn, h => { L.txt(h, String(n), 30, 0, 150, { w: 'Black', col: C.red, align: 'right' }); L.txt(h, '次', 44, 0, 70); });
+ if (cp >= 1) { L.ring(g, lt, 840, 740, 170, 80, clamp((lt - c1) / 0.4), { seed: 23, col: C.red, lw: 7 }); L.twinkles(g, lt, [[600, 720], [1100, 700]], { r: 20 }); }
+}
+
+SCENES[ID] = {
+ init() { U.assertGlyphs('PuHui-Heavy', '全是截至2026年8月回收重复用发射越来越密猎鹰火箭每年发射次数20172022202320242025年·猎鹰9号165次越来越密两周平均两天多一发其他火箭加起来还多!有一枚助推器0123456789', ID); U.assertGlyphs('PuHui-Black', '0123456789', ID); },
+ draw(c, lt) {
+ L.CUR_T = L.T0(ID) + lt;
+ const Qv = q();
+ L.bg(c, lt, { seed: 2618 });
+ const s1 = MO.cubicInOut(clamp((lt - (Qv.pj + 0.55)) / 0.5)), s2 = MO.cubicInOut(clamp((lt - (Qv.yym - 0.5)) / 0.5)), off = -1080 * (s1 + s2);
+ if (s1 < 1) { c.save(); c.globalAlpha = Math.max(0, 1 - 2 * s1); c.translate(0, off); pageA(c, lt); c.restore(); }
+ if (s1 > 0 && s2 < 1) { c.save(); if (s1 < 1) { c.beginPath(); c.rect(0, 0, 1920, 905); c.clip(); } c.globalAlpha = Math.max(0, 1 - 2 * s2); c.translate(0, off + 1080); calendar(c, lt); scale(c, lt); c.restore(); }
+ if (s2 > 0) { c.save(); if (s2 < 1) { c.beginPath(); c.rect(0, 0, 1920, 905); c.clip(); } c.translate(0, off + 2160); pageC(c, lt); c.restore(); }
+ // 页眉不跟着卷(卷动的内容只在讲解员右边走)
+ if (s1 < 0.5) L.pageTitle(c, lt, '猎鹰火箭每年发射次数', Qv.hs - 0.1, { col: C.blue, size: 40 });
+ else if (s2 < 0.5) L.pageTitle(c, lt, '发射有多密', Qv.pj + 0.75, { col: C.teal, size: 42 }); else L.pageTitle(c, lt, '最能飞的一枚', Qv.yym - 0.25, { col: C.red, size: 42 });
+ },
+};
+ERAS.find(e => e.id === ID).transition = { type: 'lin_zoom', dur: 0.6, x: 1560, y: 560 }; // 推镜穿过「送进轨道」那张卡
+L.cast(ID, [
+ { t: 0.05, pose: 'stick', fr: 'talk', x: 330, walk: 0.85 }, // 退回左边,给图表让出位置
+ { t: TM.cue(ID, '2025年') - 0.1, pose: 'stick', fr: 'talk', x: 165, s: 0.4, glide: 0.45 }, // 图表和 165 满屏,讲解员退到角落
+ { t: TM.cue(ID, '165次') + 0.1, pose: 'wow', fr: 'bounce' },
+ { t: TM.cue(ID, '平均两天多一发') + 0.6, pose: 'count', fr: 1, x: 330, s: 0.66, glide: 0.45 },
+ { t: TM.cue(ID, '比全世界') - 0.3, pose: 'sit', fr: 'talk', x: 700, y: 383, s: 0.6 }, // 跳上日历坐着,指着右边的天平
+ { t: TM.cue(ID, '还多') - 0.05, pose: 'sit', fr: 2 },
+ { t: TM.cue(ID, '有一枚助推器') - 0.5, pose: 'point', fr: 'talk', x: 330, y: 908, s: 0.66 }, // 日历卷走之前先跳下来
+ { t: TM.cue(ID, '有一枚助推器') - 0.02, pose: 'walk', fr: 'walk', x: -260, walk: 0.4 }, // 从左边出画,再从右边进来:这一屏换边,不从图上走过去
+ { t: TM.cue(ID, '有一枚助推器') + 0.4, pose: 'walk', fr: 'walk', x: 2150 },
+ { t: TM.cue(ID, '有一枚助推器') + 0.42, pose: 'lean', fr: 'talk', x: 1600, walk: 0.6, flip: true }, // 从右边进来,胳膊肘搭在这枚助推器上
+ { t: TM.cue(ID, '37次'), pose: 'lean', fr: 2, flip: true },
+]);
+L.year(ID, [[0.3, 2017], [TM.cue(ID, '2025年'), 2025], [TM.cue(ID, '有一枚助推器') - 0.2, 2026]]); // 第 37 次是 2026 年 8 月
+L.push(ID, TM.cue(ID, '165次') - 0.1, TM.cue(ID, '平均两天多一发') + 0.5, 1.07, 1050, 900);
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex_lin/scenes/s09.js b/scripts/engine/reference_films/spacex/spacex_lin/scenes/s09.js
new file mode 100644
index 0000000..c01b7bb
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_lin/scenes/s09.js
@@ -0,0 +1,104 @@
+// S09 · 星链(大数字段):① 环形图「大多」(2025 年 165 次里 123 次是星链,核对表 21a)+整流罩打开、一摞扁平卫星弹出
+// ② 2019:60 颗卫星图标 10×6 依次点亮,「60颗」③ 60 颗缩成一个小方块飞向地球,地球外面一圈圈卫星群越来越密,「1.1万+ 颗在轨」→「1200万+ 用户」小人一排排冒出来。
+// 转场:粉青两色色带从右往左扫(lin_wipe)。
+(() => {
+const ID = 's09', L = LIN, { C, TAU } = L, { clamp, lerp } = U;
+let Q = null;
+const q = () => Q || (Q = { zx: TM.cue(ID, '这些发射'), dd: TM.cue(ID, '大多'), sz: TM.cue(ID, '送自家的'), xl: TM.cue(ID, '星链卫星'), y19: TM.cue(ID, '2019年'), dyp: TM.cue(ID, '第一批'),
+ n60: TM.cue(ID, '60颗'), n60E: TM.end(ID, '60颗'), xz: TM.cue(ID, '现在'), zg: TM.cue(ID, '在轨的'), n11: TM.cue(ID, '1.1万颗'), n11E: TM.end(ID, '1.1万颗'), yh: TM.cue(ID, '用户'),
+ n12: TM.cue(ID, '1200万'), n12E: TM.end(ID, '1200万') });
+
+function pageA(g, lt) {
+ const Qv = q(), k = L.popK(lt, 0.05, 0.45, 1.6), sp = MO.cubicOut(clamp((lt - Qv.dd + 0.2) / 0.6)) * (123 / 165);
+ L.at(g, 860, 470, k, h => {
+ h.lineWidth = 84; h.strokeStyle = '#E4DDD0'; h.beginPath(); h.arc(0, 0, 170, 0, TAU); h.stroke();
+ h.strokeStyle = C.teal; h.beginPath(); h.arc(0, 0, 170, -Math.PI / 2, -Math.PI / 2 + TAU * sp); h.stroke();
+ h.lineWidth = 4.5; h.strokeStyle = C.ink; for (const r of [128, 212]) { h.beginPath(); h.arc(0, 0, r, 0, TAU); h.stroke(); }
+ if (sp > 0) for (const a of [-Math.PI / 2, -Math.PI / 2 + TAU * sp]) { h.beginPath(); h.moveTo(Math.cos(a) * 128, Math.sin(a) * 128); h.lineTo(Math.cos(a) * 212, Math.sin(a) * 212); h.stroke(); }
+ L.at(h, 0, 0, L.popK(lt, Qv.dd, 0.4, 2.4), s => L.txt(s, '大多', 0, 8, 76, { w: 'Black', align: 'center', base: 'middle', col: C.teal }));
+ });
+ const kc = L.popK(lt, Qv.sz, 0.4, 2);
+ if (kc > 0) L.at(g, 860, 770, kc, h => L.txt(h, '2025年:165次发射里,123次送星链', 0, 0, 46, { align: 'center', col: C.ink, w: 'Heavy' }));
+ // 整流罩打开,卫星一摞弹出
+ const fx = 1480, fy = 490, op = MO.backOut(clamp((lt - Qv.sz) / 0.5), 1.5);
+ g.save(); g.beginPath(); g.rect(0, 0, 1920, 830); g.clip(); L.rocket(g, RK.falcon9({ payload: 'none' }), fx, fy + 330, 6.2, { sx: 2.3 }); g.restore();
+ // 云层:先描所有圆、再填一遍盖住内线,只留外轮廓(一团云,而不是一排球)
+ const CL = [[-150, 18, 44], [-95, -6, 58], [-30, -20, 66], [40, -8, 60], [105, 6, 52], [160, 22, 40], [0, 30, 60], [-80, 34, 50], [90, 34, 50]];
+ g.save(); g.translate(fx, 812 + 3 * Math.sin(lt * 1.5)); g.lineWidth = 9; g.strokeStyle = C.ink; for (const [x, y, r] of CL) { g.beginPath(); g.arc(x, y, r, 0, TAU); g.stroke(); }
+ g.fillStyle = C.white; for (const [x, y, r] of CL) { g.beginPath(); g.arc(x, y, r, 0, TAU); g.fill(); } g.restore();
+ const top = fy + 330 - 54 * 6.2; // 二级顶端
+ // 不画整流罩(几次都被读成刀片):二级顶端敞口,星链卫星一片片叠着往上推出来
+ for (let i = 0; i < 6; i++) { const ki = L.popK(lt, Qv.sz + 0.25 + i * 0.07, 0.35, 2.2); if (ki <= 0) continue;
+ const yy = top - 30 - i * 40, xx = fx + (i % 2 ? 24 : -24) * ki;
+ g.save(); g.translate(xx, yy); g.rotate((i % 2 ? 1 : -1) * 0.12 * ki); g.scale(ki, ki); g.lineWidth = 4; g.strokeStyle = C.ink; g.fillStyle = C.blue; g.fill(L.rrp(-70, -14, 140, 28, 6)); g.stroke(L.rrp(-70, -14, 140, 28, 6));
+ g.beginPath(); for (let j = 1; j < 5; j++) { g.moveTo(-70 + j * 28, -14); g.lineTo(-70 + j * 28, 14); } g.stroke(); g.restore(); }
+ const kx = L.popK(lt, Qv.xl - 0.05, 0.4, 2.4);
+ if (kx > 0) L.at(g, 1500, 165, kx, h => L.kw(h, '自家的星链卫星', 0, 0, { size: 46, fill: C.blue }));
+}
+// ② 60 颗
+const gx = i => 880 + (i % 12) * 78, gy = i => 270 + Math.floor(i / 12) * 84; // 12×5,大一号,手机上读得出是卫星
+function pageB(g, lt) {
+ const Qv = q(), t0 = Qv.dyp - 0.1, t1 = Qv.n60E - 0.05, shrink = MO.cubicInOut(clamp((lt - (Qv.xz - 0.1)) / 0.55));
+ if (shrink >= 1) return;
+ g.save(); L.cam(g, lerp(1, 0.12, shrink), 1309, 438, lerp(0, EX - 1309, shrink), lerp(0, 520 - 438, shrink)); g.globalAlpha = 1 - clamp((shrink - 0.7) / 0.3);
+ let n = 0;
+ for (let i = 0; i < 60; i++) { const ti = t0 + (t1 - t0) * i / 59, k = L.popK(lt, ti, 0.25, 2.6); if (lt >= ti) n++;
+ g.save(); g.globalAlpha *= k > 0 ? 1 : 0.18; L.sat(g, gx(i), gy(i), k > 0 ? 1.65 * k : 1.65, 0, 0); g.restore(); }
+ g.restore();
+ const kn = L.popK(lt, t0, 0.35, 2) * (1 - shrink);
+ if (kn > 0) L.at(g, 1324, 780, kn, h => { L.txt(h, String(n), 10, 0, 150, { w: 'Black', col: C.blue, align: 'right' }); L.txt(h, '颗', 24, 0, 70); L.kw(h, '第一批', -300, -40, { size: 48, fill: C.yel, col: C.ink }); });
+}
+// ③ 地球+卫星群+两个大数
+const EX = 960, EY = 520, ER = 160;
+const SW = (() => { const r = U.rng(909), a = []; for (let i = 0; i < 520; i++) a.push({ sh: Math.floor(r() * 5), ph: r() * TAU, sp: 0.35 + r() * 0.25, t: r() }); return a; })();
+const SHELLS = [[230, 70, -0.35], [250, 95, 0.25], [210, 120, 0.9], [270, 60, -1.1], [240, 150, 1.5]];
+function pageC(g, lt) {
+ const Qv = q(); if (lt < Qv.xz - 0.2) return;
+ const ke = L.popK(lt, Qv.xz - 0.1, 0.45, 1.6), dens = MO.cubicOut(clamp((lt - Qv.zg + 0.1) / (Qv.n11E - Qv.zg)));
+ const pts = [];
+ for (const s of SW) { if (s.t > dens) continue; const [rx, ry, tl] = SHELLS[s.sh], th = s.ph + lt * s.sp, x = rx * Math.cos(th), y = ry * Math.sin(th);
+ pts.push([EX + x * Math.cos(tl) - y * Math.sin(tl), EY + x * Math.sin(tl) + y * Math.cos(tl), Math.sin(th) > 0]); }
+ const dot = (p) => { g.beginPath(); g.arc(p[0], p[1], 5, 0, TAU); g.fillStyle = C.yel; g.fill(); g.lineWidth = 2; g.strokeStyle = C.ink; g.stroke(); };
+ for (const p of pts) if (!p[2]) dot(p);
+ L.earth(g, EX, EY, ER, lt, { k: ke });
+ for (const p of pts) if (p[2]) dot(p);
+ // 1.1万+
+ const c0 = Qv.zg, c1 = Qv.n11E, cp = MO.cubicInOut(clamp((lt - c0) / (c1 - c0))), k1 = L.popK(lt, c0, 0.4, 2), land1 = lt >= c1;
+ if (k1 > 0) L.at(g, 1340, 400, k1, h => { // 从第一批的 60 颗数起,数的过程只显示整数颗,落定才换成「1.1万+」
+ if (!land1) { const v = Math.round(lerp(60, 11000, cp)).toLocaleString('en-US'); L.txt(h, v, 0, 0, 108, { w: 'Black', col: C.blue }); }
+ else { L.at(h, 0, 0, 1 + MO.settle(lt - c1, 0.12, 3, 6), z => { L.txt(z, '1.1', 0, 0, 190, { w: 'Black', col: C.blue }); L.txt(z, '万+', L.tw('1.1', 190, 'Black', z) + 8, 0, 96, { w: 'Black', col: C.blue }); }); }
+ L.kw(h, '颗在轨', 46, 70, { size: 38, fill: C.white, col: C.ink, align: 'left' }); });
+ L.underline(g, lt, 1340, 422, 300, MO.cubicOut(clamp((lt - c1 - 0.05) / 0.35)), { col: C.red, seed: 81 });
+ // 1200万+ 用户
+ const d0 = Qv.yh - 0.05, d1 = Qv.n12E, dp = MO.cubicInOut(clamp((lt - d0) / (d1 - d0))), k2 = L.popK(lt, d0, 0.4, 2), land2 = lt >= d1;
+ if (k2 > 0) { L.at(g, 1340, 680, k2, h => { const v = String(Math.round(1200 * dp)); L.txt(h, v, 0, 0, 150, { w: 'Black', col: C.red }); L.txt(h, land2 ? '万+' : '万', L.tw(v, 150, 'Black', h) + 8, 0, 76, { w: 'Black', col: C.red });
+ L.kw(h, '用户', 46, 66, { size: 38, fill: C.white, col: C.ink, align: 'left' }); });
+ L.ring(g, lt, 1520, 640, 220, 80, clamp((lt - d1 - 0.05) / 0.4), { seed: 82, col: C.red, lw: 7 });
+ for (let i = 0; i < 9; i++) { const kp = L.popK(lt, d0 + i * 0.07, 0.3, 2.4); if (kp > 0) L.at(g, 1360 + i * 40, 820, kp, h => L.person(h, 0, 0, 0.42, [C.pink, C.teal, C.yel][i % 3])); } }
+}
+
+SCENES[ID] = {
+ init() { U.assertGlyphs('PuHui-Heavy', '大多自家的星链卫星第一批颗在轨用户2019年0123456789', ID); U.assertGlyphs('PuHui-Bold', '2025年:165次发射里,123次送星链', ID); U.assertGlyphs('PuHui-Black', '0123456789.,万+大多颗', ID); },
+ draw(c, lt) {
+ L.CUR_T = L.T0(ID) + lt;
+ const Qv = q();
+ L.bg(c, lt, { seed: 2619 });
+ const s1 = MO.cubicInOut(clamp((lt - (Qv.y19 - 0.4)) / 0.5));
+ if (s1 < 1) { c.save(); c.globalAlpha = Math.max(0, 1 - 2 * s1); c.translate(0, -1080 * s1); pageA(c, lt); c.restore(); }
+ if (s1 > 0) { c.save(); if (s1 < 1) { c.beginPath(); c.rect(0, 0, 1920, 905); c.clip(); } c.translate(0, 1080 * (1 - s1)); pageC(c, lt); pageB(c, lt); c.restore(); }
+ if (s1 < 0.5) L.pageTitle(c, lt, '星链', Qv.xl - 0.1, { col: C.blue, size: 44 });
+ else if (lt < Qv.xz - 0.1) L.pageTitle(c, lt, '2019年', Qv.y19 - 0.1, { col: C.red, size: 46 }); else L.pageTitle(c, lt, '现在', Qv.xz - 0.05, { col: C.red, size: 46 });
+ },
+};
+ERAS.find(e => e.id === ID).transition = { type: 'lin_zoom', dur: 0.6, x: 840, y: 720 }; // 推镜穿过 37 次那张图
+L.cast(ID, [
+ { t: 0.0, pose: 'walk', fr: 'walk', x: 2150, walk: 0.3 }, // 快步从右边出画、左边回来
+ { t: 0.31, pose: 'walk', fr: 'walk', x: -260 },
+ { t: 0.32, pose: 'point', fr: 'talk', x: 330, walk: 0.55 },
+ { t: TM.cue(ID, '2019年') - 0.1, pose: 'present', fr: 'talk' },
+ { t: TM.cue(ID, '在轨的') - 0.1, pose: 'wow', fr: 'bounce', x: 165, s: 0.4, glide: 0.45 }, // 两个大数字满屏,讲解员退到角落
+ { t: TM.cue(ID, '用户') - 0.05, pose: 'thumb', fr: 'talk' },
+ { t: TM.end(ID, '1200万') + 0.1, pose: 'thumb', fr: 2, x: 330, s: 0.66, glide: 0.4 },
+]);
+L.year(ID, [[TM.cue(ID, '2019年'), 2019], [TM.cue(ID, '现在'), 2026]]);
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex_lin/scenes/s10.js b/scripts/engine/reference_films/spacex/spacex_lin/scenes/s10.js
new file mode 100644
index 0000000..046741d
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_lin/scenes/s10.js
@@ -0,0 +1,127 @@
+// S10 · 星舰(高光段:爆炸与筷子):① 身高对比:猎鹰1号、猎鹰9号、星舰按真实比例并排,星舰从地面升起,讲解员仰头看,「史上最大」「最强」
+// ② 2023 首飞:星舰升空,秒表转到「四分钟左右」,翻滚、炸成一大团,讲解员抱头 ③ 2024年10月:发射塔伸出两只机械臂;气泡里一双筷子夹饺子(「像筷子一样」);
+// 助推器从天而降,两臂一合——夹住!放射线+彩纸,留一拍。转场:纸卡翻面(lin_flip)。
+(() => {
+const ID = 's10', L = LIN, { C, TAU } = L, { clamp, lerp } = U;
+let Q = null;
+const q = () => Q || (Q = { xj: TM.cue(ID, '星舰'), zd: TM.cue(ID, '最大'), zq: TM.cue(ID, '最强'), y23: TM.cue(ID, '2023年'), sf: TM.cue(ID, '首飞'), sk: TM.cue(ID, '升空'),
+ sfz: TM.cue(ID, '四分钟左右'), sfzE: TM.end(ID, '四分钟左右'), zl: TM.cue(ID, '炸了'), y24: TM.cue(ID, '2024年10月'), fst: TM.cue(ID, '发射塔'), sc: TM.cue(ID, '伸出'), jxb: TM.end(ID, '机械臂'),
+ kz: TM.cue(ID, '筷子'), ycj: TM.cue(ID, '一次就'), lh: TM.cue(ID, '落回来'), jz: TM.cue(ID, '夹住了'), end: TM.dur(ID) });
+
+const GY = 850, PXM = 5.0, SXS = 1.45;
+function ground(g, x0 = 0) { g.save(); g.lineWidth = 5; g.strokeStyle = C.ink; g.fillStyle = '#EADFCB'; g.beginPath(); g.rect(x0, GY + 2, 1920 - x0, 400); g.fill(); g.beginPath(); g.moveTo(x0, GY + 2); g.lineTo(1920, GY + 2); g.stroke(); g.restore(); }
+function pageA(g, lt) { // 身高对比 → 首飞 → 炸
+ const Qv = q(); ground(g);
+ const fade = L.outK(lt, Qv.sf - 0.25, 0.35); // 三枚火箭的身高对比留到「首飞」前
+ if (fade < 1) { g.save(); g.globalAlpha = 1 - fade;
+ const k1 = L.popK(lt, 0.05, 0.4, 2), k9 = L.popK(lt, 0.25, 0.4, 2);
+ L.at(g, 800, GY, k1, h => L.rocket(h, L.F1(), 0, 0, PXM, { sx: SXS * 1.3 })); L.at(g, 800, GY + 44, k1, h => L.txt(h, '猎鹰1号', 0, 0, 32, { align: 'center', col: C.sub }));
+ L.at(g, 1000, GY, k9, h => L.rocket(h, RK.falcon9({}), 0, 0, PXM, { sx: SXS })); L.at(g, 1000, GY + 44, k9, h => L.txt(h, '猎鹰9号', 0, 0, 32, { align: 'center', col: C.sub }));
+ g.restore(); }
+ // 星舰:从地下升起(裁在地面以上),首飞时点火升空,四分钟后翻滚、炸
+ const up = MO.backOut(clamp((lt - Qv.xj + 0.1) / 0.7), 1.2), rise = lt < Qv.sf ? 0 : Math.pow(lt - Qv.sf, 1.6) * 70;
+ const tumble = lt > Qv.sfzE - 0.5 ? (lt - (Qv.sfzE - 0.5)) * 0.9 : 0, boom = Qv.zl;
+ if (lt < boom + 0.05 && up > 0) {
+ g.save(); g.beginPath(); g.rect(0, 0, 1920, GY + 2); g.clip();
+ L.rocket(g, RK.starship(), 1330, GY + (1 - up) * 650 - rise, PXM, { sx: 1.95, pal: L.SS_PAL, // 星舰更粗:不锈钢大胖子,和细长的猎鹰一眼分开
+ flame: lt > Qv.sf - 0.2 ? 1 : 0, lt, rot: tumble, lw: 4.5 });
+ g.restore();
+ }
+ if (fade < 1) { g.save(); g.globalAlpha = 1 - fade; L.at(g, 1330, GY + 44, L.popK(lt, Qv.xj, 0.4, 2), h => L.txt(h, '星舰', 0, 0, 32, { align: 'center', col: C.sub }));
+ // 高度虚线
+ if (up > 0.9) { g.setLineDash([10, 10]); g.lineWidth = 3; g.strokeStyle = C.mute; for (const [x, hh] of [[800, 22.7], [1000, 70], [1330, 123]]) { g.beginPath(); g.moveTo(x - 60, GY - hh * PXM - 4); g.lineTo(x + 60, GY - hh * PXM - 4); g.stroke(); } g.setLineDash([]); }
+ g.restore(); }
+ const ka = L.popK(lt, Qv.zd - 0.3, 0.4, 2.4) * (1 - fade), kb = L.popK(lt, Qv.zq - 0.05, 0.4, 2.4) * (1 - fade);
+ if (ka > 0) L.at(g, 1640, 380, ka, h => L.kw(h, '史上最大', 0, 0, { size: 58, fill: C.red }), -0.04);
+ if (kb > 0) L.at(g, 1640, 500, kb, h => L.kw(h, '最强', 0, 0, { size: 58, fill: C.orange }), 0.04);
+ // 秒表:首飞后开始转,念到「四分钟左右」落定
+ const ks = L.popK(lt, Qv.sk - 0.1, 0.4, 2), sp = MO.cubicOut(clamp((lt - Qv.sk) / (Qv.sfzE - Qv.sk)));
+ const pf = 1 - L.pushK(L.CUR_T); // 推到讲解员特写时秒表先退场,不被切成半截
+ if (ks > 0 && lt < Qv.y24 + 1 && pf > 0.02) { g.save(); g.globalAlpha *= pf; L.stopwatch(g, 1730, 420, 90, sp * 0.999, { k: ks, col: C.red });
+ L.at(g, 1730, 590, L.popK(lt, Qv.sfz, 0.4, 2.2), h => L.kw(h, '四分钟左右', 0, 0, { size: 42, fill: C.white, col: C.ink })); g.restore(); }
+ // 炸
+ const by = GY - 62 * PXM - Math.pow(boom - Qv.sf, 1.6) * 70;
+ L.puff(g, 1330, by + 40, lt - boom, { s: 1.75, seed: 12 });
+ const kz = L.popK(lt, boom + 0.05, 0.35, 2.8);
+ if (kz > 0 && lt < Qv.y24 + 1) L.at(g, 1000, 300, kz, h => L.kw(h, '炸了!', 0, 0, { size: 76, fill: C.red }), -0.08);
+}
+// ③ 筷子
+const TX = 1590, TPX = 4.6, TSX = 1.3, ARMY = 74;
+function chopsticks(g, lt) {
+ const Qv = q(), k = L.popK(lt, Qv.kz - 0.25, 0.45, 2); if (k <= 0) return;
+ const out = L.outK(lt, Qv.ycj - 0.1, 0.3); if (out >= 1) return;
+ L.at(g, 860, 360, k * (1 - out), h => {
+ // 思考气泡
+ h.lineWidth = 5; h.strokeStyle = C.ink; h.fillStyle = C.white;
+ h.beginPath(); for (let i = 0; i < 12; i++) { const a = i * TAU / 12; h.arc(Math.cos(a) * 190, Math.sin(a) * 120, 52, a - 1.2, a + 1.2); } h.closePath(); h.fill(); h.stroke();
+ h.beginPath(); h.arc(-150, 170, 22, 0, TAU); h.fill(); h.stroke(); h.beginPath(); h.arc(-185, 210, 12, 0, TAU); h.fill(); h.stroke();
+ // 饺子
+ h.beginPath(); h.moveTo(-70, 40); h.quadraticCurveTo(0, -60, 70, 40); h.quadraticCurveTo(0, 62, -70, 40); h.closePath(); h.fillStyle = C.cream; h.fill(); h.stroke();
+ h.lineWidth = 3; for (let i = -2; i <= 2; i++) { h.beginPath(); h.moveTo(i * 18, -6 + Math.abs(i) * 8); h.lineTo(i * 20, 10 + Math.abs(i) * 6); h.stroke(); }
+ // 一双筷子:一开一合
+ const cl = 0.5 + 0.5 * Math.sin(lt * 5);
+ for (const d of [-1, 1]) { h.save(); h.translate(120, -110); h.rotate(0.95 + d * (0.08 + 0.1 * cl)); h.fillStyle = '#C98B4F'; h.lineWidth = 4; h.fill(L.rrp(-8, 0, 16, 210, 6)); h.stroke(L.rrp(-8, 0, 16, 210, 6)); h.restore(); }
+ });
+ const kw = L.popK(lt, Qv.kz, 0.4, 2.4) * (1 - out);
+ if (kw > 0) L.at(g, 860, 560, kw, h => L.kw(h, '像筷子一样', 0, 0, { size: 46, fill: C.yel, col: C.ink }));
+}
+function pageB(g, lt) {
+ const Qv = q();
+ // 高光:助推器落下时镜头推近到机械臂,夹住那一下独占全屏
+ const zk = MO.cubicInOut(clamp((lt - (Qv.ycj - 0.15)) / 0.8)), cx = TX - 15 * TPX * TSX, cy = GY - ARMY * TPX, z = 1 + 0.55 * zk;
+ g.save(); L.cam(g, z, cx, cy, 0, -140 * zk); // 推近时整体上提,助推器底部不进字幕区
+ ground(g, 0);
+ const len = 30 * MO.backOut(clamp((lt - Qv.sc) / (Qv.jxb - Qv.sc + 0.1)), 1.4), cT = Qv.jz - 0.05, open = lt < cT ? 1 : 1 - MO.backOut(clamp((lt - cT) / 0.18), 2.5);
+ const kt = L.popK(lt, Qv.y24 + 0.2, 0.5, 1.6);
+ // 助推器:从天而降,落到「夹住」那一刻
+ const tA = Qv.ycj - 0.1, ybase = 8.6, u = clamp((lt - tA) / (cT - tA)), e = 1 - Math.pow(1 - u, 2.4);
+ // 助推器一开始就悬在高处(小小的、带火),讲到「一次就」才落下来:塔页不空
+ const tH = Qv.y24 + 0.6, alt = lt < tA ? lerp(150, 132, clamp((lt - tH) / (tA - tH))) : lerp(132, ybase, e);
+ const bx = TX - 15 * TPX * TSX, by = GY - alt * TPX + (lt > cT ? MO.settle(lt - cT, 10, 3, 7) : 0);
+ if (lt > tH) L.rocket(g, RK.superHeavy({ fins: 1 }), bx, by, TPX, { sx: TSX, pal: L.SS_PAL, flame: lt < cT + 0.1 ? (lt < tA ? 0.6 : 1) : 0, lt, lw: 4.5 });
+ g.save(); g.beginPath(); g.rect(0, GY - 146 * TPX * kt, 1920, 1080); g.clip();
+ if (kt > 0) L.rocket(g, RK.tower({ armY: ARMY, open, len: Math.max(0.01, len) }), TX, GY, TPX * kt, { sx: TSX, pal: { body: C.steelD, truss: C.tile, dark: C.red }, lw: 4.5 });
+ g.restore();
+ if (lt > Qv.fst - 0.1 && len <= 1) L.at(g, TX + 150, GY - 560, L.popK(lt, Qv.fst - 0.1, 0.4, 2.2), h => L.kw(h, '发射塔', 0, 0, { size: 40, fill: C.white, col: C.ink }));
+ if (len > 1 && lt < Qv.ycj - 0.15) L.at(g, TX + 160, GY - 520, L.popK(lt, Qv.sc + 0.2, 0.4, 2.2), h => L.kw(h, '两只机械臂', 0, 0, { size: 38, fill: C.white, col: C.ink }));
+ L.burstLines(g, bx, GY - ARMY * TPX, 140, 230, clamp((lt - cT) / 0.5), { n: 12, col: C.ink, lw: 7 });
+ g.restore();
+ L.burstLines(g, cx, cy - 140 * zk, 260, 420, clamp((lt - cT - 0.04) / 0.55), { n: 16, col: C.yel, lw: 10 });
+ const kj = L.popK(lt, cT + 0.05, 0.4, 2.8);
+ if (kj > 0) L.at(g, 1000, 780, kj, h => L.kw(h, '一次就夹住了!', 0, 0, { size: 70, fill: C.green }), -0.04);
+ const ky = lt < cT ? L.popK(lt, Qv.ycj - 0.05, 0.38, 2.4) : 0;
+ if (ky > 0) L.at(g, 1000, 760, ky, h => L.kw(h, '一次就……', 0, 0, { size: 50, fill: C.white, col: C.ink }));
+}
+
+SCENES[ID] = {
+ init() { U.assertGlyphs('PuHui-Heavy', '猎鹰1号猎鹰9号星舰史上最大最强四分钟左右炸了!2023年首飞2024年10月两只机械臂像筷子一样一次就夹住了!……发射塔', ID); },
+ draw(c, lt) {
+ L.CUR_T = L.T0(ID) + lt;
+ const Qv = q();
+ L.bg(c, lt, { seed: 2620 });
+ const sw = MO.cubicInOut(clamp((lt - (Qv.y24 - 0.15)) / 0.5)); // 炸完留一拍再翻页
+ // 炸的那一下整页抖
+ const sh = lt > Qv.zl && lt < Qv.zl + 0.5 ? 14 * (1 - (lt - Qv.zl) / 0.5) * Math.sin(lt * 80) : 0;
+ if (sw < 1) { c.save(); c.globalAlpha = Math.max(0, 1 - 2 * sw); c.translate(sh, -1080 * sw + sh * 0.6); pageA(c, lt); c.restore(); }
+ if (sw > 0) { c.save(); c.translate(0, 1080 * (1 - sw)); pageB(c, lt); chopsticks(c, lt); c.restore(); }
+ if (lt < Qv.y23 - 0.1) L.pageTitle(c, lt, '星舰', Qv.xj - 0.1, { col: C.blue, size: 46 }); else if (lt < Qv.y24 - 0.1) L.pageTitle(c, lt, '2023年 首飞', Qv.y23 - 0.1, { col: C.red, size: 44 });
+ else L.pageTitle(c, lt, '2024年10月', Qv.y24 - 0.1, { col: C.red, size: 44 });
+ },
+};
+ERAS.find(e => e.id === ID).transition = { type: 'lin_flip', dur: 0.6 };
+L.FRONT[ID] = (c, lt) => { const Qv = q(); L.confetti(c, TX - 15 * TPX * TSX, GY - ARMY * TPX - 140, lt - Qv.jz, { n: 56, seed: 41, spread: 900, up: 800, life: 1.8 }); };
+L.cast(ID, [
+ { t: 0.05, pose: 'lookup', fr: 'talk', x: 560, s: 0.66, walk: 0.75 }, // 走到火箭跟前仰头看
+ { t: TM.cue(ID, '2023年') - 0.3, pose: 'stick', fr: 'talk', x: 330, walk: 0.55 },
+ { t: TM.cue(ID, '炸了') - 0.02, pose: 'sad', fr: 1 },
+ { t: TM.cue(ID, '2024年10月') - 0.1, pose: 'present', fr: 'talk' },
+ { t: TM.cue(ID, '筷子') - 0.2, pose: 'think', fr: 'talk' },
+ { t: TM.cue(ID, '一次就') - 0.05, pose: 'nervous', fr: 'talk' },
+ { t: TM.cue(ID, '夹住了') - 0.05, pose: 'cheer', fr: 'bounce' },
+]);
+L.hudHide(ID, TM.cue(ID, '2024年10月') + 0.5, TM.dur(ID) + 0.3); // 接住的高光:顶栏让位
+L.push(ID, TM.end(ID, '夹住了') + 0.15, TM.dur(ID) + 0.1, 1.4, 330, 908, true); // 夹住之后硬切讲解员欢呼的特写
+L.bustCard(ID, TM.cue(ID, '炸了') + 0.45, TM.cue(ID, '2024年10月') - 0.05, [[TM.cue(ID, '炸了') + 0.45, 2], [TM.cue(ID, '炸了') + 0.9, 3]]); // 炸完的气口:大头特写,先惊后苦笑
+L.hudHide(ID, TM.cue(ID, '炸了') - 0.1, TM.cue(ID, '2024年10月') + 0.4);
+L.year(ID, [[TM.cue(ID, '2023年'), 2023], [TM.cue(ID, '2024年10月'), 2024]]);
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex_lin/scenes/s11.js b/scripts/engine/reference_films/spacex/spacex_lin/scenes/s11.js
new file mode 100644
index 0000000..7ee58fe
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_lin/scenes/s11.js
@@ -0,0 +1,317 @@
+// S11 · 2026 这一年(三屏信息图,同一页里换内容):①收购:SpaceX 卡把 xAI 卡「吞」进来,冒出「+ xAI」小标
+// ②6月上市:日历 6月、绿色「上市」框、募资计数到 750 亿美元+金币长高+荧光笔「史上最大的一次上市」+红圈
+// ③9月28号:6月那页撕下露出 9月28号(回扣开头那张日历),星舰从地球升入轨道绕圈,26 颗卫星从飞船里依次弹出排好,计数到 26。
+// 由混合版 S11 改来:讲解员和顶栏挪进全片叠加层(LIN),背景、页眉换成本片统一的。转场:整页上推(lin_slide up)。
+(() => {
+const W = 1920, H = 1080, ID = 's11';
+const { clamp, lerp, rng } = U;
+const TAU = Math.PI * 2;
+
+const C = { bg: '#F7F0E1', dot: '#E3D8C2', ink: '#2B2A33', sub: '#6E6878', white: '#FFFFFF', red: '#F25F5C', yel: '#FFD447',
+ hl: 'rgba(255,222,77,0.85)', blue: '#4C8DF6', teal: '#22B39C', purple: '#8A72F0', pink: '#FF9BB0', orange: '#FF9F43',
+ gold: '#F7C948', goldD: '#D9961C', sea: '#5BAEF2', seaD: '#3E8FD6', land: '#7DCB78', steel: '#E8ECF2', tile: '#3A3F4B' };
+const F = (s, w = 'Heavy') => `${s}px "PuHui-${w}"`;
+
+let Q = null;
+const q = () => Q || (Q = {
+ y26: TM.cue(ID, '2026年'), spx: TM.cue(ID, 'SpaceX'), sg: TM.cue(ID, '收购'), msk: TM.cue(ID, '马斯克'), xai: TM.cue(ID, 'xAI'),
+ jun: TM.cue(ID, '6月上市'), ss: TM.cue(ID, '上市'), mz: TM.cue(ID, '募资'), n750: TM.cue(ID, '750亿美元'),
+ zd: TM.cue(ID, '史上最大'), ycE: TM.end(ID, '一次上市'), d928: TM.cue(ID, '9月28号'), rg: TM.cue(ID, '星舰入轨'),
+ fc: TM.cue(ID, '放出'), n26E: TM.end(ID, '26颗'), xyd: TM.cue(ID, '新一代'),
+});
+
+// ---------- 小工具 ----------
+const rrp = (x, y, w, h, r) => { const p = new Path2D(); p.roundRect(x, y, w, h, r); return p; };
+// 扁平贴纸卡:填色+深色描边+错位硬阴影
+function card(g, x, y, w, h, { fill = C.white, r = 26, lw = 4, sh = 8 } = {}) {
+ const p = rrp(x, y, w, h, r);
+ g.save(); g.translate(sh * 0.6, sh); g.fillStyle = 'rgba(43,42,51,0.14)'; g.fill(p); g.restore();
+ g.fillStyle = fill; g.fill(p); g.lineWidth = lw; g.strokeStyle = C.ink; g.lineJoin = 'round'; g.stroke(p);
+}
+const popK = (lt, t0, d = 0.38, s = 2.2) => lt < t0 ? 0 : MO.backOut(clamp((lt - t0) / d), s); // 弹入(过冲)
+const outK = (lt, t0, d = 0.22) => MO.cubicIn(clamp((lt - t0) / d)); // 退场比入场快
+function at(g, x, y, k, fn, rot = 0) { if (k <= 0.001) return; g.save(); g.translate(x, y); g.rotate(rot); g.scale(k, k); fn(g); g.restore(); }
+function txt(g, s, x, y, size, { w = 'Heavy', col = C.ink, align = 'left', base = 'alphabetic' } = {}) {
+ g.font = F(size, w); g.fillStyle = col; g.textAlign = align; g.textBaseline = base; g.fillText(s, x, y);
+}
+// 手绘线:点列按 8fps 换种子抖一点(只给线稿沸腾,不整屏重洗)
+const boil = (lt, seed) => rng(seed * 977 + Math.floor(lt * 8 + 1e-6));
+function jitter(pts, r, amp) { return pts.map(([x, y]) => [x + (r() - 0.5) * 2 * amp, y + (r() - 0.5) * 2 * amp]); }
+function strokePart(g, pts, frac) { if (frac <= 0) return; const cum = DG.cum(pts); DG.drawPartial(g, pts, cum, cum[cum.length - 1] * clamp(frac)); }
+function spark(g, x, y, r, col = C.yel) { // 四角小闪光
+ g.save(); g.translate(x, y); g.fillStyle = col; g.strokeStyle = C.ink; g.lineWidth = 2.5; g.lineJoin = 'round';
+ g.beginPath(); for (let i = 0; i < 8; i++) { const a = i * Math.PI / 4 - Math.PI / 2, rr = i % 2 ? r * 0.38 : r; g.lineTo(Math.cos(a) * rr, Math.sin(a) * rr); }
+ g.closePath(); g.fill(); g.stroke(); g.restore();
+}
+
+function header(g, lt) { LIN.pageTitle(g, lt, '2026年', 1.08, { col: C.blue, size: 46 }); }
+
+// ---------- 日历(6月 → 撕页 → 9月28号) ----------
+function calPage(g, top, big, col, unit) {
+ card(g, -110, -110, 220, 220, { r: 22 });
+ g.save(); g.clip(rrp(-110, -110, 220, 220, 22)); g.fillStyle = col; g.fillRect(-110, -110, 220, 64); g.restore();
+ g.lineWidth = 4; g.strokeStyle = C.ink; g.beginPath(); g.moveTo(-110, -46); g.lineTo(110, -46); g.stroke(); g.stroke(rrp(-110, -110, 220, 220, 22));
+ for (const x of [-56, 56]) { g.fillStyle = C.white; g.fill(rrp(x - 8, -128, 16, 36, 8)); g.stroke(rrp(x - 8, -128, 16, 36, 8)); }
+ txt(g, top, 0, -76, 34, { col: C.white, align: 'center', base: 'middle' });
+ if (unit) { txt(g, big, -14, 44, 104, { w: 'Black', align: 'center', base: 'middle' }); txt(g, unit, 62, 76, 34, { w: 'Bold', col: C.sub, align: 'center' }); }
+ else txt(g, big, 0, 44, 92, { w: 'Black', align: 'center', base: 'middle' });
+}
+function calendar(g, lt) {
+ const Qv = q(), k = popK(lt, Qv.jun, 0.42);
+ at(g, 810, 292, k, h => {
+ const fl = clamp((lt - Qv.d928 + 0.15) / 0.6);
+ if (fl > 0) calPage(h, '2026年9月', '28', C.blue, '号');
+ if (fl < 1) { // 6月那页从左上角撕下、翻着落出画
+ const e = MO.cubicIn(fl); h.save(); h.translate(-100, -100); h.rotate(-e * 1.1); h.translate(100 - e * 60, 100 + e * e * 700);
+ h.globalAlpha = 1 - clamp(fl / 0.45); calPage(h, '2026', '6月', C.red); h.restore();
+ }
+ });
+}
+
+// ---------- 右上关键词框:「上市」→「星舰入轨」 ----------
+function upArrow(g, x, y, s) {
+ g.save(); g.translate(x, y); g.scale(s, s); g.lineWidth = 5; g.lineCap = 'round'; g.lineJoin = 'round'; g.strokeStyle = C.white;
+ g.beginPath(); g.moveTo(-18, 14); g.lineTo(-4, -2); g.lineTo(6, 8); g.lineTo(20, -12); g.stroke();
+ g.beginPath(); g.moveTo(8, -13); g.lineTo(21, -13); g.lineTo(21, 0); g.stroke(); g.restore();
+}
+function slot(g, lt) {
+ const Qv = q(), k1 = popK(lt, Qv.ss, 0.36), o1 = outK(lt, Qv.d928 - 0.12);
+ at(g, 950, 292, k1 * (1 - o1), h => { card(h, 0, -44, 200, 88, { fill: C.teal, r: 24 }); upArrow(h, 50, 0, 1.2); txt(h, '上市', 86, 3, 50, { col: C.white, base: 'middle' }); });
+ at(g, 950, 292, popK(lt, Qv.rg, 0.36), h => { card(h, 0, -44, 270, 88, { fill: C.blue, r: 24 }); txt(h, '星舰入轨', 135, 3, 50, { col: C.white, align: 'center', base: 'middle' }); });
+}
+
+// ---------- 屏①:收购 ----------
+function rocketIcon(g, x, y, s) { // 通用扁平小火箭(不画任何标识)
+ g.save(); g.translate(x, y); g.scale(s, s); g.lineWidth = 3.5; g.strokeStyle = C.ink; g.lineJoin = 'round';
+ const fin = (d) => { g.beginPath(); g.moveTo(d * 13, 10); g.lineTo(d * 30, 30); g.lineTo(d * 30, 40); g.lineTo(d * 13, 32); g.closePath(); g.fillStyle = C.red; g.fill(); g.stroke(); };
+ fin(-1); fin(1);
+ g.beginPath(); g.moveTo(0, -46); g.bezierCurveTo(22, -28, 16, 20, 13, 36); g.lineTo(-13, 36); g.bezierCurveTo(-16, 20, -22, -28, 0, -46); g.closePath(); g.fillStyle = C.steel; g.fill(); g.stroke();
+ g.beginPath(); g.arc(0, -8, 8, 0, TAU); g.fillStyle = C.blue; g.fill(); g.stroke();
+ g.restore();
+}
+function chipIcon(g, x, y, s) { // 通用 AI 芯片图标
+ g.save(); g.translate(x, y); g.scale(s, s); g.lineWidth = 3.5; g.strokeStyle = C.ink; g.lineCap = 'round';
+ for (let i = -1; i <= 1; i++) { g.beginPath(); g.moveTo(i * 14, -34); g.lineTo(i * 14, -42); g.moveTo(i * 14, 34); g.lineTo(i * 14, 42); g.moveTo(-34, i * 14); g.lineTo(-42, i * 14); g.moveTo(34, i * 14); g.lineTo(42, i * 14); g.stroke(); }
+ card(g, -32, -32, 64, 64, { fill: C.purple, r: 12, lw: 3.5, sh: 0 });
+ txt(g, 'AI', 0, 2, 28, { w: 'Black', col: C.white, align: 'center', base: 'middle' }); g.restore();
+}
+function handArrow(g, lt, x0, y0, x1, y1, p, seed) {
+ if (p <= 0) return;
+ const r = boil(lt, seed), n = 16, pts = [];
+ for (let i = 0; i <= n; i++) { const u = i / n; pts.push([lerp(x0, x1, u), lerp(y0, y1, u) - Math.sin(Math.PI * u) * 26]); }
+ const jp = jitter(pts, r, 1.6);
+ g.save(); g.strokeStyle = C.ink; g.lineWidth = 7; g.lineCap = 'round'; g.lineJoin = 'round';
+ strokePart(g, jp, p);
+ if (p > 0.85) { const hk = clamp((p - 0.85) / 0.15), e = jp[n], a = Math.atan2(jp[n][1] - jp[n - 2][1], jp[n][0] - jp[n - 2][0]);
+ g.beginPath(); for (const d of [-1, 1]) { g.moveTo(e[0], e[1]); g.lineTo(e[0] - Math.cos(a + d * 0.6) * 34 * hk, e[1] - Math.sin(a + d * 0.6) * 34 * hk); } g.stroke(); }
+ g.restore();
+}
+function panelA(g, lt) {
+ const Qv = q(), out = outK(lt, Qv.jun + 0.4, 0.25); if (out >= 1) return;
+ g.save(); g.globalAlpha = 1 - out; g.translate(0, -50 * out);
+ const sw = MO.cubicInOut(clamp((lt - (Qv.xai + 0.06)) / 0.42)); // 吞并进度
+ g.save(); g.globalAlpha *= 1 - sw; handArrow(g, lt, 1070, 545, 1392, 545, MO.cubicOut(clamp((lt - Qv.sg) / 0.4)), 11); g.restore();
+ at(g, 1231, 452, popK(lt, Qv.sg, 0.35), h => { card(h, -78, -34, 156, 68, { fill: C.yel, r: 20, lw: 3.5, sh: 5 }); txt(h, '收购', 0, 3, 42, { align: 'center', base: 'middle' }); });
+ if (sw < 1) { // xAI 卡:被拖进 SpaceX 卡、缩小消失(画在它后面)
+ const cx = lerp(1610, 870, sw), cy = 545 - Math.sin(Math.PI * sw) * 70, sc = lerp(1, 0.12, MO.cubicIn(sw));
+ at(g, cx, cy, popK(lt, Qv.msk, 0.4) * sc, h => {
+ card(h, -190, -115, 380, 230); chipIcon(h, 0, -48, 0.8);
+ txt(h, 'xAI', 0, 46, 62, { align: 'center' }); txt(h, '马斯克的AI公司', 0, 96, 40, { w: 'Bold', col: C.sub, align: 'center' });
+ }, -0.5 * sw);
+ }
+ const gulp = MO.settle(lt - (Qv.xai + 0.46), 0.09, 3, 6);
+ at(g, 870, 545, popK(lt, Qv.spx, 0.4) * (1 + gulp), h => {
+ card(h, -170, -115, 340, 230); rocketIcon(h, 0, -44, 1);
+ txt(h, 'SpaceX', 0, 80, 60, { align: 'center' });
+ at(h, 150, -112, popK(lt, Qv.xai + 0.46, 0.35, 2.6), b => { card(b, -66, -26, 132, 52, { fill: C.purple, r: 26, lw: 3.5, sh: 4 }); txt(b, '+ xAI', 0, 2, 32, { col: C.white, align: 'center', base: 'middle' }); }, 0.12);
+ });
+ g.restore();
+}
+
+// ---------- 屏②:上市募资 ----------
+const STACKS = [{ x: 1562, n: 12 }, { x: 1662, n: 18 }, { x: 1762, n: 15 }], CB = 712, CT = 11;
+function coin(g, x, y) {
+ g.lineWidth = 2.5; g.strokeStyle = C.ink;
+ g.beginPath(); g.ellipse(x, y, 42, 13, 0, 0, Math.PI); g.lineTo(x - 42, y - CT); g.ellipse(x, y - CT, 42, 13, 0, Math.PI, 0, true); g.closePath(); g.fillStyle = C.goldD; g.fill(); g.stroke();
+ g.beginPath(); g.ellipse(x, y - CT, 42, 13, 0, 0, TAU); g.fillStyle = C.gold; g.fill(); g.stroke();
+ g.beginPath(); g.ellipse(x, y - CT, 26, 7, 0, 0, TAU); g.strokeStyle = 'rgba(43,42,51,0.35)'; g.lineWidth = 2; g.stroke();
+}
+function coins(g, lt, cp) {
+ for (const [si, s] of STACKS.entries()) {
+ const f = s.n * cp, n = Math.floor(f + 1e-6), fr = f - n;
+ for (let i = 0; i < n; i++) coin(g, s.x, CB - i * CT);
+ if (fr > 0.02) { g.save(); g.globalAlpha = clamp(fr * 3); coin(g, s.x, CB - n * CT - (1 - MO.cubicOut(fr)) * 90); g.restore(); }
+ if (cp > 0.98) { // 母题:顶上的金币轮流闪一下
+ const ph = (lt * 0.9 + si * 0.37) % 1; if (ph < 0.3) spark(g, s.x + 22, CB - s.n * CT - 14, 14 * Math.sin(Math.PI * ph / 0.3), C.white);
+ }
+ }
+}
+function ringPts(cx, cy, rx, ry, seed) { // 手绘圈(圆角方的超椭圆,贴着字框):起笔收笔不闭合,略多绕一点
+ const r = rng(seed), pts = [], a0 = -2.5, n = 72, sp = (v) => Math.sign(v) * Math.pow(Math.abs(v), 0.5);
+ for (let i = 0; i <= n; i++) { const u = i / n, a = a0 + u * TAU * 1.08, k = 1 + 0.025 * Math.sin(u * 9 + r() * 0.3) + 0.035 * u; pts.push([cx + sp(Math.cos(a)) * rx * k, cy + sp(Math.sin(a)) * ry * k]); }
+ return pts;
+}
+const RING = ringPts(1058, 622, 420, 108, 7);
+function panelB(g, lt) {
+ const Qv = q(); if (lt < Qv.mz - 0.02) return; const out = outK(lt, Qv.d928 - 0.12, 0.25); if (out >= 1) return;
+ g.save(); g.globalAlpha = 1 - out; g.translate(0, 50 * out);
+ const a1 = MO.expoOut(clamp((lt - Qv.mz) / 0.35));
+ g.save(); g.globalAlpha *= a1; txt(g, '募资超过', 724, 496 + 24 * (1 - a1), 50, { w: 'Bold', col: C.sub }); g.restore();
+ const c0 = Qv.mz + 0.08, c1 = Qv.n750 + 0.42, cp = MO.expoOut(clamp((lt - c0) / (c1 - c0)));
+ const v = Math.round(750 * cp), nk = popK(lt, c0, 0.35);
+ // 史上最大:荧光笔先刷在字后面
+ const hk = MO.cubicOut(clamp((lt - Qv.zd - 0.12) / 0.32));
+ if (hk > 0) { const r = rng(31); g.fillStyle = C.hl; g.beginPath(); g.moveTo(708, 796 + r() * 4);
+ const x1 = 708 + 600 * hk; g.lineTo(x1, 790 + r() * 4); g.lineTo(x1 - 6, 858); g.lineTo(712, 862); g.closePath(); g.fill(); }
+ at(g, 1110, 700, nk, h => { txt(h, String(v), 0, 0, 230, { w: 'Black', col: C.red, align: 'right' }); txt(h, '亿美元', 22, 0, 92); });
+ coins(g, lt, cp);
+ const bp = popK(lt, Qv.zd + 0.05, 0.36);
+ at(g, 720, 840, bp, h => txt(h, '史上最大的一次上市', 0, 0, 62));
+ const rp = clamp((lt - Qv.zd) / 0.42);
+ if (rp > 0) { g.save(); g.strokeStyle = C.red; g.lineWidth = 8; g.lineCap = 'round'; g.lineJoin = 'round'; strokePart(g, jitter(RING, boil(lt, 5), 2.2), MO.cubicOut(rp)); g.restore();
+ if (rp >= 1) for (const [i, [x, y]] of [[640, 520], [1490, 512], [1500, 735]].entries()) { const ph = (lt * 1.6 + i * 0.33) % 1; spark(g, x, y, 20 * (0.6 + 0.4 * Math.sin(ph * TAU)), C.yel); } }
+ g.restore();
+}
+
+// ---------- 屏③:星舰入轨+26 颗卫星 ----------
+const EX = 960, EY = 665, ER = 165, RX = 340, RY = 108, TILT = -0.14, CT_ = Math.cos(TILT), ST_ = Math.sin(TILT), OMEGA = TAU / 2.0;
+const orbitAt = th => { const x = RX * Math.cos(th), y = RY * Math.sin(th); return [EX + x * CT_ - y * ST_, EY + x * ST_ + y * CT_]; };
+const orbitVel = th => { const x = -RX * Math.sin(th), y = RY * Math.cos(th); return [x * CT_ - y * ST_, x * ST_ + y * CT_]; };
+const SHIP = RK.ship(), SHIP_S = 3.0;
+const TH0 = Math.PI;
+function shipState(lt) { // → {x, y, rot, s, th, front, launching}
+ const Qv = q(), tL = Qv.d928 + 0.6, tR = Qv.rg;
+ if (lt < tR) {
+ const e = MO.cubicInOut(clamp((lt - tL) / (tR - tL))), [ox, oy] = orbitAt(TH0), dx = ox - EX, dy = oy - EY, dl = Math.hypot(dx, dy);
+ const sx = EX + dx / dl * ER * 0.8, sy = EY + dy / dl * ER * 0.8, [vx, vy] = orbitVel(TH0);
+ const aOut = Math.atan2(dy, dx) + Math.PI / 2, aTan = Math.atan2(vy, vx) + Math.PI / 2;
+ return { x: lerp(sx, ox, e), y: lerp(sy, oy, e), rot: lerp(aOut, aTan, MO.smooth(e)), s: lerp(0.55, 1, e), th: TH0, front: e > 0.6, launching: lt >= tL, burn: 1 };
+ }
+ const th = TH0 + OMEGA * (lt - tR), [x, y] = orbitAt(th), [vx, vy] = orbitVel(th);
+ return { x, y, rot: Math.atan2(vy, vx) + Math.PI / 2, s: 1, th, front: Math.sin(th) > 0, launching: true, burn: clamp(1 - (lt - tR) / 0.4) };
+}
+function drawShip(g, st, lt) {
+ if (!st.launching) return;
+ const s = SHIP_S * st.s;
+ RK.at(g, st.x, st.y, s, st.rot, h => {
+ h.scale(1.9, 1); h.translate(0, 26); // 以箭体中部为旋转中心
+ if (st.burn > 0) RK.flame(h, 0, 2, 22 * st.burn, 8, lt, ['rgba(255,159,67,0.9)', 'rgba(255,212,71,0.95)', '#FFF6D8']);
+ h.lineJoin = 'round';
+ for (const p of SHIP.parts) { h.fillStyle = p.k === 'tiles' || p.k === 'flap' || p.k === 'engine' ? C.tile : C.steel; h.fill(p.p); }
+ h.lineWidth = 2.6 / s; h.strokeStyle = C.ink; for (const p of SHIP.parts) if (p.k !== 'tiles') h.stroke(p.p);
+ });
+}
+// 地球:海+陆块贴图横向循环(取模周期=贴图宽)
+const LANDW = ER * 4;
+const landTex = () => PAINT.cached('s11_land', LANDW, ER * 2, g => {
+ const r = rng(4242); g.lineWidth = 3; g.strokeStyle = C.ink; g.fillStyle = C.land; g.lineJoin = 'round';
+ const blobs = [[60, 80, 46], [190, 150, 60], [300, 70, 38], [420, 190, 52], [500, 110, 40], [130, 230, 30], [350, 250, 34]];
+ for (const [bx, by, br] of blobs) for (const off of [-LANDW, 0, LANDW]) {
+ g.beginPath(); for (let i = 0; i <= 24; i++) { const a = i / 24 * TAU, rr = br * (1 + 0.22 * Math.sin(a * 3 + bx) + 0.12 * Math.sin(a * 5 + by)); g.lineTo(bx + off + Math.cos(a) * rr, by + Math.sin(a) * rr * 0.8); }
+ g.closePath(); g.fill(); g.stroke();
+ }
+});
+function earth(g, lt, k) {
+ at(g, EX, EY, k, h => {
+ h.save(); h.beginPath(); h.arc(0, 0, ER, 0, TAU); h.fillStyle = C.sea; h.fill(); h.clip();
+ const off = (lt * 34) % LANDW, tex = landTex();
+ h.drawImage(tex, -ER - off, -ER); h.drawImage(tex, -ER - off + LANDW, -ER);
+ h.fillStyle = 'rgba(43,62,120,0.16)'; h.beginPath(); h.arc(ER * 0.35, ER * 0.15, ER * 1.05, 0, TAU); h.arc(-ER * 0.2, -ER * 0.1, ER * 1.1, 0, TAU, true); h.fill('evenodd');
+ h.restore();
+ h.lineWidth = 4.5; h.strokeStyle = C.ink; h.beginPath(); h.arc(0, 0, ER, 0, TAU); h.stroke();
+ h.fillStyle = 'rgba(255,255,255,0.55)'; h.beginPath(); h.ellipse(-ER * 0.48, -ER * 0.5, 22, 11, -0.7, 0, TAU); h.fill();
+ });
+}
+function orbitLine(g, lt, p, half) { // half: 'back' 上半(地球后)/ 'front' 下半
+ if (p <= 0) return;
+ g.save(); g.strokeStyle = C.ink; g.globalAlpha = half === 'back' ? 0.35 : 0.6; g.lineWidth = 3.5; g.setLineDash([14, 12]); g.lineDashOffset = -lt * 40; g.lineCap = 'round';
+ g.beginPath(); const a0 = half === 'back' ? Math.PI : 0, n = 40;
+ for (let i = 0; i <= n; i++) { const u = i / n; if (u > p) break; const [x, y] = orbitAt(a0 + u * Math.PI); i ? g.lineTo(x, y) : g.moveTo(x, y); }
+ g.stroke(); g.restore();
+}
+function sat(g, x, y, k, tw) { // 扁平小卫星:机身+两块太阳能板+小天线
+ if (k <= 0.001) return;
+ g.save(); g.translate(x, y); g.scale(k, k); g.lineWidth = 2.5; g.strokeStyle = C.ink; g.lineJoin = 'round'; g.lineCap = 'round';
+ g.beginPath(); g.moveTo(0, -10); g.lineTo(0, -17); g.stroke(); g.fillStyle = C.red; g.beginPath(); g.arc(0, -18, 3, 0, TAU); g.fill(); g.stroke();
+ for (const d of [-1, 1]) { const x0 = d < 0 ? -22 : 10; g.fillStyle = C.blue; g.fill(rrp(x0, -8, 12, 16, 2)); g.stroke(rrp(x0, -8, 12, 16, 2));
+ g.beginPath(); g.moveTo(x0, 0); g.lineTo(x0 + 12, 0); g.stroke(); }
+ g.fillStyle = C.steel; g.fill(rrp(-10, -10, 20, 20, 5)); g.stroke(rrp(-10, -10, 20, 20, 5));
+ if (tw > 0) spark(g, 15, -15, 9 * tw, C.white);
+ g.restore();
+}
+const NS = 26, emitT = i => q().fc + 0.05 + i * 0.026;
+const slotXY = i => [940 + (i % 13) * 58, 400 + Math.floor(i / 13) * 62]; // 整组收进安全区
+function panelC(g, lt) {
+ const Qv = q(); if (lt < Qv.d928) return;
+ const ek = popK(lt, Qv.d928 + 0.1, 0.45, 1.8), op = MO.cubicOut(clamp((lt - (Qv.d928 + 0.45)) / 0.55)), st = shipState(lt);
+ orbitLine(g, lt, op, 'back');
+ if (!st.front) drawShip(g, st, lt);
+ earth(g, lt, ek);
+ orbitLine(g, lt, op, 'front');
+ if (st.front) drawShip(g, st, lt);
+ // 26 颗卫星:从飞船当时的位置弹出,沿弧线飞到右上两排
+ let n = 0;
+ for (let i = 0; i < NS; i++) {
+ const te = emitT(i); if (lt < te) continue;
+ const u = clamp((lt - te) / 0.4); if (u > 0.8) n++; // 卫星飞到位才计数
+ const e = MO.quintOut(u), s0 = shipState(te), [x1, y1] = slotXY(i);
+ const cx = (s0.x + x1) / 2 + 40, cy = Math.min(s0.y, y1) - 140;
+ const x = (1 - e) * (1 - e) * s0.x + 2 * (1 - e) * e * cx + e * e * x1, y = (1 - e) * (1 - e) * s0.y + 2 * (1 - e) * e * cy + e * e * y1;
+ const bob = u >= 1 ? 2.5 * Math.sin(lt * 3 + i * 0.7) : 0, ph = (lt * 0.8 + i * 0.137) % 1;
+ sat(g, x, y + bob, 1.22 * lerp(0.4, 1, MO.backOut(clamp(u * 1.6), 2)), u >= 1 && ph < 0.12 ? Math.sin(Math.PI * ph / 0.12) : 0);
+ }
+ // 计数:每弹出一颗加一,最后一颗落在「26颗」念完时
+ const hero = clamp((lt - TIMING.seg[ID].voEnd) / 0.3); // 气口的大画面里,数字和标签先让开
+ g.save(); g.globalAlpha *= 1 - hero;
+ if (n > 0) at(g, 1630, 690, popK(lt, emitT(0), 0.3), h => { txt(h, String(n), 0, 0, 180, { w: 'Black', col: C.blue, align: 'right' }); txt(h, '颗', 14, 0, 76); });
+ at(g, 1300, 790, popK(lt, Qv.xyd, 0.36), h => { card(h, 0, -40, 360, 80, { fill: C.yel, r: 22, lw: 3.5, sh: 5 }); txt(h, '新一代星链卫星', 180, 3, 44, { align: 'center', base: 'middle' }); });
+ g.restore();
+}
+
+SCENES[ID] = {
+ init() {
+ U.assertGlyphs('PuHui-Heavy', '2026年收购上市亿美元史上最大的一次星舰入轨颗新一代星链卫星SpaceX+xAI6月9月28号0123456789', ID);
+ U.assertGlyphs('PuHui-Bold', '马斯克的AI公司募资超过号', ID); U.assertGlyphs('PuHui-Heavy', '18年后·同一天2008年9月28号', ID);
+ U.assertGlyphs('PuHui-Black', '0123456789AI月年', ID);
+ },
+ draw(c, lt) {
+ LIN.CUR_T = LIN.T0(ID) + lt;
+ LIN.bg(c, lt, { seed: 2621 });
+ panelA(c, lt); panelB(c, lt);
+ // 高光:星舰入轨——地球后面放射光,2008 年那张日历飞回来并排,两个「28」一起圈:开头的钩子在这里兑现
+ const Qv = q(), sb = clamp((lt - Qv.rg) / 0.35);
+ if (sb > 0) { c.save(); c.translate(EX, EY); c.rotate(lt * 0.25); c.globalAlpha = (0.5 - 0.22 * clamp((lt - Qv.rg - 1.2) / 0.6)) * MO.cubicOut(sb); c.fillStyle = C.yel;
+ for (let i = 0; i < 16; i++) { const a = i * TAU / 16; c.beginPath(); c.moveTo(0, 0); c.arc(0, 0, 900 * MO.cubicOut(sb), a, a + TAU / 32); c.closePath(); c.fill(); } c.restore(); }
+ panelC(c, lt);
+ const heroK = clamp((lt - TIMING.seg[ID].voEnd) / 0.3); // 气口大画面:日历和标签让开
+ c.save(); c.globalAlpha *= 1 - heroK;
+ calendar(c, lt); slot(c, lt); header(c, lt);
+ const k8 = popK(lt, Qv.d928 + 0.2, 0.42), fly8 = MO.backOut(clamp((lt - Qv.d928 - 0.2) / 0.45), 3.2); // 2008 那张飞过来「撞」上 2026 这张再弹回
+ LIN.burstLines(c, 690, 292, 40, 150, clamp((lt - Qv.d928 - 0.5) / 0.4), { n: 8, col: C.red, lw: 7 });
+ if (k8 > 0) at(c, lerp(360, 572, fly8), 292, k8 * 0.92, h => LIN.calPage(h, '2008年9月', '28', C.red, '号', { w: 220, h: 220 }), -0.06 * (1 - fly8));
+ const rp = clamp((lt - Qv.rg + 0.1) / 0.45);
+ if (rp > 0) { LIN.ring(c, lt, 572, 330, 92, 62, rp, { seed: 51, col: C.red, lw: 7 }); LIN.ring(c, lt, 810, 334, 100, 66, rp, { seed: 52, col: C.red, lw: 7 });
+ at(c, 705, 470, popK(lt, Qv.rg + 0.15, 0.4, 2.4), h => LIN.kw(h, '18年后 · 同一天', 0, 0, { size: 36, fill: C.yel, col: C.ink })); }
+ c.restore();
+ // 开场:大号「2026」砸在页中间,念到「SpaceX」前缩进左上角页眉(同 S02 的「2002」,首尾呼应)
+ const kY = popK(lt, 0.02, 0.4, 2.4), fly = MO.cubicInOut(clamp((lt - 0.8) / 0.32));
+ if (kY > 0 && fly < 1) { c.save(); c.globalAlpha = 1 - clamp((fly - 0.75) / 0.25);
+ at(c, lerp(1200, 160, fly), lerp(500, 104, fly), kY * lerp(1, 0.22, fly), h => { txt(h, '2026', 0, 70, 260, { w: 'Black', col: C.blue, align: 'center' }); txt(h, '年', 296, 70, 110, { w: 'Black', align: 'left' }); }, -0.04 * (1 - fly)); c.restore(); }
+ },
+};
+ERAS.find(e => e.id === ID).transition = { type: 'lin_slide', dur: 0.55, dir: 'up' };
+LIN.cast(ID, [
+ { t: 0.05, pose: 'point', fr: 'talk' },
+ { t: TM.cue(ID, '6月上市') - 0.05, pose: 'stick', fr: 'talk' },
+ { t: TM.cue(ID, '史上最大') - 0.05, pose: 'wow', fr: 'bounce' },
+ { t: TM.end(ID, '一次上市') + 0.1, pose: 'present', fr: 'talk' },
+ { t: TM.cue(ID, '放出') - 0.05, pose: 'count', fr: 'cycle' },
+ { t: TM.end(ID, '26颗') + 0.05, pose: 'cheer', fr: 'bounce' },
+ { t: TIMING.seg[ID].voEnd, pose: 'cheer', fr: 'bounce', x: 540, glide: 0.4 }, // 气口大画面里往里挪,推镜时整个人留在画内
+]);
+LIN.year(ID, [[TM.cue(ID, '2026年'), 2026]]);
+LIN.push(ID, TM.cue(ID, '9月28号') + 0.05, TM.cue(ID, '星舰入轨') - 0.3, 1.2, 700, 908); // 先在日历上停一下:2026 年 9 月 28 号
+LIN.push(ID, TM.cue(ID, '星舰入轨') - 0.15, TM.dur(ID) + 0.05, 1.12, 820, 900, false, { t: TIMING.seg[ID].voEnd + 0.02, z: 1.3, x: 1000, y: 900 }); // 口播念完的 0.95 秒气口:再推进一层,地球、星舰和 26 颗卫星占满画面
+LIN.bustCard(ID, TM.cue(ID, '史上最大') - 0.05, TM.end(ID, '一次上市') + 0.2, [[TM.cue(ID, '史上最大') - 0.05, 2], [TM.cue(ID, '史上最大') + 0.45, 'talk']]); // 史上最大:大头特写惊叹 // 史上最大:讲解员和 750 一起推近
+LIN.FRONT[ID] = (c, lt) => { LIN.confetti(c, 1450, 640, lt - TM.cue(ID, '星舰入轨') - 0.1, { n: 36, seed: 91, spread: 800, up: 800, life: 2.2 }); };
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex_lin/scenes/s12.js b/scripts/engine/reference_films/spacex/spacex_lin/scenes/s12.js
new file mode 100644
index 0000000..6d5221d
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_lin/scenes/s12.js
@@ -0,0 +1,134 @@
+// S12 · 接下来(路线图+收尾):一条从地球出发的虚线小路,讲解员原地走路、纸面往左卷过去(跑步机式跟拍),路边四站待办:
+// ☐ 筷子夹住飞船(小塔两臂一合)☐ 在太空里加油(两艘飞船头尾相接、油滴流过)☐ 重新送人上月球(月面上的星舰和小宇航员)☐ 火星。
+// 念完后镜头拉远看全图,顶栏小牌走到「未来」,讲解员挥手,「SpaceX 这24年」小标题回扣片头。转场:圆形扩开(lin_iris)。
+(() => {
+const ID = 's12', L = LIN, { C, TAU } = L, { clamp, lerp } = U;
+let Q = null;
+const q = () => Q || (Q = { jxl: TM.cue(ID, '接下来'), kz: TM.cue(ID, '筷子'), jzfc: TM.cue(ID, '夹住飞船'), tk: TM.cue(ID, '在太空里'), jy: TM.cue(ID, '加油'), zq: TM.cue(ID, '争取'),
+ yq: TM.cue(ID, '月球'), zwh: TM.cue(ID, '再往后'), hx: TM.cue(ID, '火星'), hxE: TM.end(ID, '火星'), end: TM.dur(ID) });
+
+const ST = [1250, 2150, 3050, 3950], EARTH = 640; // 站距 900:上一站正好退到讲解员身后淡掉
+const roadY = x => 660 + 60 * Math.sin(x / 300);
+// 相机:screen = (world - cx) * s + 1220
+function camAt(lt) {
+ const Qv = q();
+ const keys = [[0, 1000], [Qv.kz - 0.3, 1000], [Qv.kz + 0.15, ST[0] + 30], [Qv.tk - 0.25, ST[0] + 30], [Qv.tk + 0.35, ST[1]], [Qv.zq - 0.2, ST[1]], [Qv.zq + 0.6, ST[2]],
+ [Qv.zwh - 0.15, ST[2]], [Qv.zwh + 0.55, ST[3]], [Qv.hxE + 0.25, ST[3]], [Qv.hxE + 1.25, ST[3]]];
+ let cx = keys[0][1]; for (let i = 1; i < keys.length; i++) { const [t0, a] = keys[i - 1], [t1, b] = keys[i]; if (lt >= t0) cx = lt >= t1 ? b : lerp(a, b, MO.sineInOut((lt - t0) / (t1 - t0))); }
+ const s = 1;
+ return { cx, s };
+}
+function checkbox(h, x, y, done) { h.lineWidth = 5; h.strokeStyle = C.ink; h.fillStyle = C.white; h.fill(L.rrp(x - 22, y - 22, 44, 44, 8)); h.stroke(L.rrp(x - 22, y - 22, 44, 44, 8)); }
+function label(g, lt, x, s, t0, col, y = 215) {
+ const k = L.popK(lt, t0, 0.4, 2.2); if (k <= 0) return;
+ L.at(g, x, y, k, h => { const w = L.kw(h, s, 30, 0, { size: 48, fill: col }); checkbox(h, -w / 2 - 14, 0); }, 0.02 * Math.sin(lt * 1.8 + x));
+}
+function stop1(g, lt) { // 小塔夹飞船
+ const Qv = q(), x = ST[0], gy = roadY(x) - 30, cT = Qv.jzfc + 0.1, open = lt < cT ? 1 : 1 - MO.backOut(clamp((lt - cT) / 0.2), 2.5);
+ const k = L.popK(lt, Qv.kz - 0.4, 0.45, 1.8); if (k <= 0) return;
+ const pxm = 3.0 * k, sx = 1.3, tx = x + 60;
+ const u = clamp((lt - (Qv.kz - 0.2)) / (cT - Qv.kz + 0.2)), e = 1 - Math.pow(1 - u, 2.2), shipBase = lerp(118, 70, e);
+ L.rocket(g, RK.ship(), tx - 15 * pxm * sx, gy - shipBase * pxm + (lt > cT ? MO.settle(lt - cT, 5, 3, 7) : 0), pxm, { sx, pal: L.SS_PAL, flame: lt < cT ? 0.9 : 0, lt, lw: 3.5 });
+ L.rocket(g, RK.tower({ armY: 110, open, len: 30 }), tx, gy, pxm, { sx, pal: { body: C.steelD, truss: C.tile, dark: C.red }, lw: 3.5 });
+ L.burstLines(g, tx - 15 * pxm * sx, gy - 110 * pxm, 60, 110, clamp((lt - cT) / 0.45), { n: 9, lw: 5 });
+}
+function stop2(g, lt) { // 太空加油:两艘飞船头尾相接
+ const Qv = q(), x = ST[1], y = 500, k = L.popK(lt, Qv.tk - 0.2, 0.45, 1.8); if (k <= 0) return;
+ L.at(g, x, y, k * 1.3, h => {
+ h.save(); h.fillStyle = C.ink; h.globalAlpha *= 0.9; h.fill(L.rrp(-330, -150, 660, 300, 40)); h.restore(); // 透明度要乘,不然外层的淡出被覆盖、整块一帧消失
+ const r = U.rng(3); for (let i = 0; i < 18; i++) { const sx = -310 + r() * 620, sy = -130 + r() * 260; L.spark(h, sx, sy, 5 + 4 * Math.sin(lt * 3 + i), C.white); }
+ L.rocket(h, RK.ship(), -40, 0, 2.6, { rot: Math.PI / 2, sx: 1.8, pal: L.SS_PAL, lw: 3.5 });
+ L.rocket(h, RK.ship(), 40, 0, 2.6, { rot: -Math.PI / 2, sx: 1.8, pal: L.SS_PAL, lw: 3.5 });
+ // 油滴从右流到左
+ for (let i = 0; i < 3; i++) { const ph = ((lt - Qv.jy) * 0.9 + i / 3) % 1; if (lt < Qv.jy - 0.2) break; const dx = lerp(60, -60, ph);
+ h.save(); h.translate(dx, -40); h.scale(0.6, 0.6); h.beginPath(); h.moveTo(0, -30); h.bezierCurveTo(14, -10, 24, 4, 24, 12); h.arc(0, 12, 24, 0, Math.PI); h.bezierCurveTo(-24, 4, -14, -10, 0, -30); h.closePath();
+ h.fillStyle = C.yel; h.fill(); h.lineWidth = 5; h.strokeStyle = C.ink; h.stroke(); h.restore(); }
+ });
+}
+function stop3(g, lt) { // 月球
+ const Qv = q(), x = ST[2], y = 500, k = L.popK(lt, Qv.zq - 0.1, 0.75, 1.5); if (k <= 0) return;
+ L.planet(g, x, y + 60, 200, { col: C.moon, colD: C.moonD, craters: 6, seed: 8, k });
+ const kl = L.popK(lt, Qv.yq - 0.6, 0.45, 2);
+ if (kl > 0) L.at(g, x - 40, y - 140, kl * 1.25, h => { L.rocket(h, RK.ship(), 0, 0, 2.6, { sx: 1.8, pal: L.SS_PAL, lw: 3.5 }); L.astro(h, 70, -10, 0.42); });
+ L.at(g, x - 300, 330, L.popK(lt, Qv.zq, 0.36, 2.4), h => L.kw(h, '争取', 0, 0, { size: 34, fill: C.white, col: C.ink }), -0.08);
+}
+function stop4(g, lt) {
+ const Qv = q(), x = ST[3], y = 500, k = L.popK(lt, Qv.zwh - 0.1, 0.55, 1.6); if (k <= 0) return;
+ L.planet(g, x, y + 50, 240, { k, craters: 5, seed: 3, rot: lt * 0.15 });
+ L.twinkles(g, lt, [[x - 290, y - 130], [x + 290, y - 100], [x + 260, y + 240]], { r: 22 });
+}
+function world(g, lt, cam) {
+ const Qv = q();
+ // 小路:从地球出发,一路画出来(跟着镜头)
+ const rp = clamp((lt + 0.6) / (Qv.hx + 0.3 + 0.6));
+ const xEnd = lerp(EARTH, ST[3] - 200, MO.sineInOut(rp));
+ g.save(); g.setLineDash([26, 20]); g.lineDashOffset = -lt * 60; g.lineCap = 'round'; g.lineWidth = 12; g.strokeStyle = '#E2D6BF';
+ g.beginPath(); for (let x = EARTH; x <= xEnd; x += 20) { const y = roadY(x) + 40; x === EARTH ? g.moveTo(x, y) : g.lineTo(x, y); } g.stroke();
+ g.lineWidth = 6; g.strokeStyle = C.ink; g.globalAlpha = 0.65; g.stroke(); g.restore();
+ // 走过的站滑到讲解员身后时淡掉(镜头拉远看全图时再回来)
+ const fadeAt = (wx) => clamp(((wx - cam.cx) * cam.s + 1220 - 380) / 420); // wx 传的是这一站的左边缘:左边缘一碰到讲解员就开始淡
+ const F = (wx, fn) => { const a = fadeAt(wx); if (a <= 0) return; g.save(); g.globalAlpha *= a; fn(); g.restore(); };
+ F(EARTH + 300, () => { L.earth(g, EARTH - 40, roadY(EARTH) - 20, 120, lt, { spin: 26 }); L.at(g, EARTH - 40, roadY(EARTH) - 190, 1, h => L.kw(h, '现在', 0, 0, { size: 34, fill: C.ink })); });
+ F(ST[0] - 230, () => { stop1(g, lt); label(g, lt, ST[0] - 330, '筷子夹住飞船', Qv.kz - 0.1, C.red, 330); }); // 标签放在塔左边,不压住夹的动作
+ F(ST[1] - 440, () => { stop2(g, lt); label(g, lt, ST[1], '在太空里加油', Qv.jy - 0.25, C.orange); });
+ F(ST[2] - 320, () => { stop3(g, lt); label(g, lt, ST[2], '重新送人上月球', Qv.yq - 0.6, C.blue); });
+ stop4(g, lt);
+ label(g, lt, ST[3], '火星', Qv.hx - 0.1, C.mars);
+}
+
+// 收尾卡(口播念完后 2.3 秒):路线图淡出,「SpaceX 这24年」+一条大时间轴 2002 → 2008 → 2026,
+// 两个「9.28」被同时圈出来(回扣开头的同一天),虚线延伸到火星。顶栏小时间轴同时淡出,由这条大的接班。
+const EY0 = 600, EX0 = 830, EX1 = 1600, MX = 1752; // 时间轴整体右移,不被讲解员挡住 2002
+const ex = y => lerp(EX0, EX1, (y - 2002) / 24);
+function endCard(g, lt) {
+ const Qv = q(), t0 = Qv.hxE + 0.12; if (lt < t0) return;
+ const kt = L.popK(lt, t0, 0.5, 1.8);
+ L.at(g, 1160, 250, kt, h => { L.txt(h, 'SpaceX', -14, 0, 104, { w: 'Black', align: 'right' }); L.txt(h, '这', 4, 0, 84, { w: 'Black' });
+ L.txt(h, '24', 94, 4, 116, { w: 'Black', col: C.red }); L.txt(h, '年', 236, 0, 84, { w: 'Black' }); });
+ const lp = MO.cubicOut(clamp((lt - t0 - 0.1) / 0.45));
+ g.save(); g.lineCap = 'round'; g.lineWidth = 16; g.strokeStyle = C.red; g.beginPath(); g.moveTo(EX0, EY0); g.lineTo(lerp(EX0, EX1, lp), EY0); g.stroke();
+ const dp = MO.cubicOut(clamp((lt - t0 - 0.5) / 0.4));
+ if (dp > 0) { g.setLineDash([22, 18]); g.lineDashOffset = -lt * 50; g.lineWidth = 10; g.strokeStyle = C.ink; g.globalAlpha = 0.6; g.beginPath(); g.moveTo(EX1 + 30, EY0); g.lineTo(lerp(EX1 + 30, MX - 80, dp), EY0); g.stroke(); }
+ g.restore();
+ L.planet(g, MX, EY0, 56, { k: L.popK(lt, t0 + 0.75, 0.45, 2.2), craters: 4, seed: 3, rot: lt * 0.2 });
+ if (lt > t0 + 0.85) L.at(g, MX, EY0 + 116, L.popK(lt, t0 + 0.85, 0.4, 2.4), h => L.kw(h, '火星', 0, 0, { size: 40, fill: C.mars }));
+ const marks = [[2002, '创办', C.ink], [2008, '9月28号', C.red], [2026, '9月28号', C.red]];
+ marks.forEach(([y, lab, col], i) => {
+ const td = t0 + 0.12 + i * 0.15, k = L.popK(lt, td, 0.35, 2.4); if (k <= 0) return;
+ L.at(g, ex(y), EY0, k, h => { h.beginPath(); h.arc(0, 0, 22, 0, TAU); h.fillStyle = i ? C.red : C.white; h.fill(); h.lineWidth = 5; h.strokeStyle = C.ink; h.stroke();
+ L.txt(h, String(y), 0, 78, 46, { w: 'Black', align: 'center' }); L.kw(h, lab, 0, -78, { size: 36, fill: i ? C.red : C.white, col: i ? C.white : C.ink }); });
+ });
+ // 两个「同一天」一起被圈:首尾呼应
+ const rp = clamp((lt - t0 - 0.55) / 0.4);
+ L.ring(g, lt, ex(2008), EY0 - 78, 110, 46, rp, { seed: 41, col: C.red, lw: 6 }); L.ring(g, lt, ex(2026), EY0 - 78, 110, 46, rp, { seed: 42, col: C.red, lw: 6 });
+ L.arrow(g, lt, ex(2008) + 70, EY0 - 150, ex(2026) - 70, EY0 - 150, MO.cubicOut(clamp((lt - t0 - 0.65) / 0.35)), { seed: 43, bend: 60, lw: 6, head: 22 });
+ if (lt > t0 + 0.8) L.at(g, (ex(2008) + ex(2026)) / 2, EY0 - 250, L.popK(lt, t0 + 0.8, 0.4, 2.4), h => L.kw(h, '同一天', 0, 0, { size: 40, fill: C.yel, col: C.ink }));
+}
+SCENES[ID] = {
+ init() { U.assertGlyphs('PuHui-Heavy', '接下来现在筷子夹住飞船在太空里加油重新送人上月球争取火星SpaceX这24年创办9月28号同一天', ID); U.assertGlyphs('PuHui-Black', 'SpaceX这24年200820262002', ID); },
+ draw(c, lt) {
+ L.CUR_T = L.T0(ID) + lt;
+ const Qv = q();
+ L.bg(c, lt, { seed: 2622 });
+ const { cx, s } = camAt(lt), wf = 1 - clamp((lt - Qv.hxE + 0.05) / 0.3);
+ if (wf > 0) { c.save(); c.globalAlpha = wf; c.translate(1220, 0); c.scale(s, s); c.translate(-cx, 0); world(c, lt, { cx, s }); c.restore();
+ c.save(); c.globalAlpha = wf; L.pageTitle(c, lt, '接下来', Qv.jxl - 0.1, { col: C.purple, size: 46 }); c.restore(); }
+ endCard(c, lt);
+ },
+};
+ERAS.find(e => e.id === ID).transition = { type: 'lin_iris', dur: 0.65, x: 960, y: 665, col: C.blue };
+const Qv = q();
+L.cast(ID, [
+ { t: 0.05, pose: 'walk', fr: 'walk', x: 330, glide: 0.5 },
+ { t: Qv.kz + 0.15, pose: 'point', fr: 'talk' },
+ { t: Qv.tk - 0.25, pose: 'walk', fr: 'walk' },
+ { t: Qv.tk + 0.35, pose: 'stick', fr: 'talk' },
+ { t: Qv.zq - 0.2, pose: 'walk', fr: 'walk' },
+ { t: Qv.zq + 0.6, pose: 'present', fr: 'talk' },
+ { t: Qv.zwh - 0.15, pose: 'walk', fr: 'walk' },
+ { t: Qv.zwh + 0.55, pose: 'lookup', fr: 'talk' },
+ { t: Qv.hxE + 0.2, pose: 'wave', fr: 'loop' },
+]);
+L.year(ID, [[0.3, 2028]]);
+L.setHudOff(L.T0(ID) + Qv.hxE + 0.2); // 收尾卡的大时间轴接班,顶栏淡出
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex_lin/tools/prep_presenter.py b/scripts/engine/reference_films/spacex/spacex_lin/tools/prep_presenter.py
new file mode 100644
index 0000000..892ab71
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_lin/tools/prep_presenter.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python3
+"""讲解员帧:绿幕 sprite 表 → 抠图切帧 → 量脚底中心与「帽顶到脚底」身高 → spacex_lin/assets/p_<姿势>_<i>.png + spacex_lin/presenter_meta.js
+用法:python3 prep_presenter.py (扫 assets/src/sheet_*.png,外加混合版 s11 的指向表与已切好的惊讶帧)"""
+from pathlib import Path
+import json
+import numpy as np
+from PIL import Image
+
+ROOT = Path(__file__).resolve().parents[1]; SRC = ROOT / 'assets' / 'src'; OUT = ROOT / 'assets'
+MIX = ROOT.parent / 'spacex' / 'assets'
+SHEETS = {p.stem[6:]: p for p in sorted(SRC.glob('sheet_*.png'))}
+SHEETS.setdefault('point', MIX / 's11_sheet_point.png')
+PRECUT = {'wow': [MIX / f's11_wow_{i}.png' for i in range(3)]} # 混合版已切好(三帧手臂相连,按列切不开)
+EXPECT = {'walk': 6, 'bust': 4}
+
+
+def key(im):
+ a = np.asarray(im.convert('RGB')).astype(np.float32); r, g, b = a[..., 0], a[..., 1], a[..., 2]
+ spill = g - np.maximum(r, b); al = 1 - np.clip((spill - 30) / 70, 0, 1)
+ g2 = np.where(spill > 0, np.minimum(g, np.maximum(r, b) + 0.25 * np.clip(spill, 0, 30)), g)
+ return np.dstack([r, g2, b, al * 255]).clip(0, 255).astype(np.uint8)
+
+
+def runs(mask):
+ cols = mask.sum(0) > 2; out = []; x = 0; W = len(cols)
+ while x < W:
+ if cols[x]:
+ x0 = x
+ while x < W and cols[x:x + 14].any(): x += 1
+ if x - x0 > 60: out.append((x0, x))
+ x += 1
+ if out:
+ mw = max(b - a for a, b in out); out = [r for r in out if r[1] - r[0] >= 0.45 * mw] # 汗珠、强调线这类碎块不算一帧
+ return out
+
+
+def crop(fr):
+ m = fr[..., 3] > 127; ys = np.where(m.any(1))[0]; xs = np.where(m.any(0))[0]
+ return fr[ys.min():ys.max() + 1, xs.min():xs.max() + 1]
+
+
+def measure(fr):
+ m = fr[..., 3] > 127; h, w = m.shape
+ bot = m[int(h * 0.94):]; xs = np.where(bot)[1]; ax = float(xs.mean()) if len(xs) else w / 2 # 脚底中心
+ white = (fr[..., :3].astype(int).min(2) > 228) & m; cnt = white.sum(1) # 帽顶:第一行近白像素 ≥ 40
+ top = int(np.argmax(cnt >= 40)) if (cnt >= 40).any() else 0
+ return w, h, round(ax, 1), top
+
+
+meta = {}
+jobs = [(p, None, s) for p, s in SHEETS.items()] + [(p, l, None) for p, l in PRECUT.items()]
+for pose, pre, sheet in jobs:
+ if pre: frames = [crop(np.asarray(Image.open(q).convert('RGBA'))) for q in pre]
+ else:
+ rgba = key(Image.open(sheet)); mask = rgba[..., 3] > 127
+ frames = [crop(rgba[:, x0:x1]) for x0, x1 in runs(mask)]
+ meta[pose] = []
+ for k, fr in enumerate(frames):
+ w, h, ax, top = measure(fr); name = f'p_{pose}_{k}.png'
+ Image.fromarray(fr, 'RGBA').save(OUT / name)
+ meta[pose].append({'src': f'spacex_lin/assets/{name}', 'w': w, 'h': h, 'ax': ax, 'ay': h, 'top': top, 'body': h - top})
+ print(pose, len(frames), [(f['w'], f['h'], f['body']) for f in meta[pose]], '' if len(frames) == EXPECT.get(pose, 3) else '⚠️ 帧数不对')
+(ROOT / 'presenter_meta.js').write_text('// 由 tools/prep_presenter.py 生成,勿手改\nwindow.LIN_META = ' + json.dumps(meta, ensure_ascii=False) + ';\n')
diff --git a/scripts/engine/reference_films/spacex/spacex_vox/common.js b/scripts/engine/reference_films/spacex/spacex_vox/common.js
new file mode 100644
index 0000000..4b09a7b
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_vox/common.js
@@ -0,0 +1,407 @@
+// SpaceX 这 24 年 · Vox 拼贴单风格版(片子名 vox)的共用库 VOX。
+// 世界观:整支片子是「同一张调查桌」。桌面 9600×5400(世界坐标 px),切成 4 列 × 3 行的格子,每段口播占一格,按蛇形排:
+// 第 1 行 →:S02 2002 | S03 2006–08 | S04 2008–12 | S05 2015–17
+// 第 2 行 ←:S09 星链 | S08 发射次数 | S07 2020 | S06 2018
+// 第 3 行 →:S10 星舰 | S11 2026 | S01「9.28」| S12 接下来(再往右是火星)
+// 一根红线(调查线)沿每行顶部的带子把 12 格串起来,每格挂一个黑底年份标签。开场(S01)在「9.28」格里调查,
+// 「两分钟,看完它这 24 年」时相机拉到全桌、红线一口气走完全程;S12 结尾再拉到全桌,桌上已经铺满 24 年的证据。
+// 两层帧率(y2 调研):相机 60fps 平滑;桌上的纸片、荧光笔、红笔、打字、剪纸都按 12fps「一拍二」步进。
+// 桌上东西(item)按「全片时间 T」决定状态:哪一段放上去的,之后一直留在桌上(越铺越多)。
+// 只画剪影和无脸符号人,不画任何官方 logo/字标;示例文字是历史创作素材,复用前自行核实。
+(() => {
+const W = 1920, H = 1080, TAU = Math.PI * 2, { clamp, lerp, rng } = U;
+
+const VOX = window.VOX = {};
+const C = VOX.C = { desk: '#e4ddcf', paper: '#eeedeb', card: '#f6f4ee', ink: '#171716', ink2: '#2a2723', red: '#b8433f', red2: '#93403c', yel: '#dacf08', black: '#1b1b1a', graphite: '#4a4a48', blue: 'rgba(80,140,200,.30)' };
+const F = VOX.F = { heavy: 'PuHui-Heavy', black: 'PuHui-Black', bold: 'PuHui-Bold', med: 'PuHui-Medium', serif: 'LXGWWenKai-500', type: 'CMU-rm', num: 'Anton-400', hand: 'LXGWWenKai-500' };
+const font = VOX.font = (sz, fam) => `${sz}px "${fam}"`;
+const step = VOX.step = (t) => MO.step(t, 12);
+const seg = MO.seg;
+
+// ---------- 时间 ----------
+VOX.t0 = id => TIMING.seg[id].t0;
+VOX.cue = (id, k) => VOX.t0(id) + TM.cue(id, k); // 全片秒
+VOX.cend = (id, k) => VOX.t0(id) + TM.end(id, k);
+// 同一个词第 n 次(从 0 起)被念出的局部秒
+VOX.cueN = (id, key, n) => { const s = TIMING.seg[id]; let i = -1; for (let k = 0; k <= n; k++) { i = s.text.indexOf(key, i + 1); if (i < 0) { console.error('VOX.cueN: 段 ' + id + ' 没有第 ' + (n + 1) + ' 个「' + key + '」'); return 0; } } return s.charStart[i]; };
+
+// ---------- 格子 ----------
+VOX.CW = 2400; VOX.CH = 1800; VOX.DW = 9600; VOX.DH = 5400;
+const CELL = { s02: [0, 0], s03: [1, 0], s04: [2, 0], s05: [3, 0], s06: [3, 1], s07: [2, 1], s08: [1, 1], s09: [0, 1], s10: [0, 2], s11: [1, 2], s01: [2, 2], s12: [3, 2] };
+VOX.cell = id => { const [c, r] = CELL[id]; return { x: c * 2400, y: r * 1800, cx: c * 2400 + 1200, cy: r * 1800 + 900, col: c, row: r }; };
+VOX.BAND = r => r * 1800 + 170; // 每行红线带子的 y
+
+// ---------- 相机 ----------
+// 世界点 (x,y) 放到屏幕 (960, sy):默认 sy=470,让主体整体在字幕带(y>920)之上
+VOX.at = (x, y, z, sy = 470, sx = 960) => CAM.anchor(x, y, z, sx, sy);
+VOX.cams = {}; // 各段相机 lt → cam(下一段用它接上一段的末帧)
+VOX.camEnd = id => VOX.cams[id](TM.dur(id));
+VOX.key = (t, cam, ease) => ({ t, x: cam.x, y: cam.y, z: cam.z, ease });
+VOX.overview = () => ({ x: VOX.DW / 2, y: VOX.DH / 2 + 100, z: Math.min(W / (VOX.DW + 260), H / (VOX.DH + 200)) });
+
+// ---------- 精灵:一次画好缓存,投影烘进去 ----------
+// fn(g, w, h) 在 (0,0)-(w,h) 里画;返回 canvas,带 vw/vh/vpad(世界尺寸)。S 倍分辨率(推近不糊)。
+VOX.spr = (key, w, h, fn, { pad = 26, S = 2, shadow = true, sh = {} } = {}) => PAINT.cached('vx_' + key, Math.ceil((w + pad * 2) * S), Math.ceil((h + pad * 2) * S), (g, cv) => {
+ const tmp = PAINT.canvas(Math.ceil(w * S), Math.ceil(h * S)), tg = tmp.getContext('2d'); tg.scale(S, S); fn(tg, w, h);
+ if (shadow) { g.shadowColor = sh.col || 'rgba(50,40,25,.30)'; g.shadowBlur = (sh.blur ?? 12) * S; g.shadowOffsetX = (sh.x ?? 3) * S; g.shadowOffsetY = (sh.y ?? 7) * S; }
+ g.drawImage(tmp, pad * S, pad * S);
+ cv.vw = w; cv.vh = h; cv.vpad = pad;
+});
+// 以中心 (x,y) 画精灵
+// ---------- 自检:文字可见性记录(VOX.DBG = [] 时开启;qa 脚本逐帧读它,查「字被后放的纸压住 / 被画框裁掉 / 落进字幕带」)----------
+VOX.DBG = null; VOX._cur = ''; let _noRec = 0;
+VOX.rec = (g, kind, x, y, w, h, s) => {
+ if (!VOX.DBG || _noRec) return; const m = g.getTransform(); let x0 = 1e9, y0 = 1e9, x1 = -1e9, y1 = -1e9;
+ for (const [px, py] of [[x, y], [x + w, y], [x, y + h], [x + w, y + h]]) { const X = m.a * px + m.c * py + m.e, Y = m.b * px + m.d * py + m.f; x0 = Math.min(x0, X); y0 = Math.min(y0, Y); x1 = Math.max(x1, X); y1 = Math.max(y1, Y); }
+ VOX.DBG.push({ kind, item: VOX._cur, s, b: [x0, y0, x1, y1] });
+};
+VOX.blit = (g, sp, x = 0, y = 0, k = 1) => { const p = sp.vpad, w = (sp.vw + p * 2) * k, h = (sp.vh + p * 2) * k; g.drawImage(sp, x - w / 2, y - h / 2, w, h); VOX.rec(g, 'spr', x - sp.vw * k / 2, y - sp.vh * k / 2, sp.vw * k, sp.vh * k); };
+
+// ---------- 纸 ----------
+VOX.tile = (key, base, o = {}) => CL.paperTile('vx' + key, base, { amt: 10, fibers: 220, seed: 5, ...o });
+VOX.deskTile = () => CL.paperTile('vxdesk', C.desk, { amt: 12, fibers: 320, fiberCol: [110, 95, 70], seed: 7 });
+// 撕边纸片(填纸纹+边缘一圈旧黄)
+VOX.paper = (g, w, h, seed, { col = C.paper, amp = 4, torn = true, age = 0.2 } = {}) => {
+ g.save(); if (torn) CL.tornRect(g, w, h, seed, amp); else { g.beginPath(); g.rect(0, 0, w, h); }
+ g.clip(); g.fillStyle = g.createPattern(VOX.tile('p' + col, col, { seed: seed % 9 + 1 }), 'repeat'); g.fillRect(0, 0, w, h);
+ if (age) { const r = g.createRadialGradient(w * 0.45, h * 0.42, Math.min(w, h) * 0.2, w * 0.5, h * 0.5, Math.max(w, h) * 0.75); r.addColorStop(0, 'rgba(255,255,255,0)'); r.addColorStop(1, `rgba(170,150,110,${age})`); g.fillStyle = r; g.fillRect(0, 0, w, h); }
+ g.restore();
+};
+// 横线索引卡
+VOX.indexCard = (g, w, h, { top = 64, gap = 46 } = {}) => {
+ g.fillStyle = C.card; g.fillRect(0, 0, w, h);
+ g.fillStyle = g.createPattern(VOX.tile('card', C.card, { amt: 6, fibers: 80 }), 'repeat'); g.fillRect(0, 0, w, h);
+ g.strokeStyle = 'rgba(184,67,63,.45)'; g.lineWidth = 2; g.beginPath(); g.moveTo(0, top); g.lineTo(w, top); g.stroke();
+ g.strokeStyle = C.blue; g.lineWidth = 1.6; for (let y = top + gap; y < h; y += gap) { g.beginPath(); g.moveTo(0, y); g.lineTo(w, y); g.stroke(); }
+};
+// 黑卡纸(Missing Chapter 的黑底)
+VOX.blackCard = (g, w, h, seed) => {
+ g.save(); CL.tornRect(g, w, h, seed, 3); g.clip();
+ g.fillStyle = g.createPattern(CL.paperTile('vxblack', C.black, { amt: 5, fibers: 90, fiberCol: [90, 90, 85], seed: 4 }), 'repeat'); g.fillRect(0, 0, w, h); g.restore();
+};
+// 胶带
+VOX.tape = (g, x, y, a, w = 120) => CL.tape(g, x, y, a, w);
+
+// ---------- 字 ----------
+VOX.text = (g, s, x, y, size, fam, col = C.ink, align = 'left', base = 'alphabetic') => { g.font = font(size, fam); g.fillStyle = col; g.textAlign = align; g.textBaseline = base; g.fillText(s, x, y); if (VOX.DBG) { const w = g.measureText(s).width, x0 = align === 'center' ? x - w / 2 : align === 'right' ? x - w : x; VOX.rec(g, 'txt', x0, y - size * 0.8, w, size * 0.9, s); } };
+// 宋体加粗:描一圈同色细边(思源宋体只有 Regular)
+VOX.serifBold = (g, s, x, y, size, col = C.ink, k = 0.045, align = 'left') => { g.font = font(size, F.serif); g.fillStyle = col; g.strokeStyle = col; g.lineWidth = size * k; g.lineJoin = 'round'; g.textAlign = align; g.textBaseline = 'alphabetic'; g.strokeText(s, x, y); g.fillText(s, x, y); if (VOX.DBG) VOX.rec(g, 'txt', x, y - size * 0.8, g.measureText(s).width, size * 0.9, s); };
+// 打字机:前 n 个字(逐字量宽,一拍二由调用方传 step 后的时间)
+VOX.typed = (g, s, x, y, n, size, fam, col = C.ink) => { g.font = font(size, fam); g.fillStyle = col; g.textAlign = 'left'; g.textBaseline = 'alphabetic'; let xx = x, vis = 0; [...s].forEach((ch, i) => { if (i < n) { g.fillText(ch, xx, y); vis = xx + g.measureText(ch).width; } xx += g.measureText(ch).width; }); if (n > 0) VOX.rec(g, 'txt', x, y - size * 0.8, vis - x, size * 0.9, [...s].slice(0, n).join('')); return xx - x; };
+VOX.nTyped = (T, t0, rate = 13) => TY.typedCount(step(T), t0, rate);
+// 量一段字里某个子串的位置(荧光笔要画在它下面):返回 {x, w}
+VOX.span = (g, s, sub, x, size, fam) => { g.font = font(size, fam); const i = s.indexOf(sub); if (i < 0) { console.error('VOX.span: 没有「' + sub + '」于「' + s + '」'); return { x, w: 0 }; } return { x: x + g.measureText(s.slice(0, i)).width, w: g.measureText(sub).width }; };
+// Borders 式黑底标签条(静态):返回宽度
+VOX.labelW = (g, s, size, fam = F.heavy, padX = 24) => { g.font = font(size, fam); return g.measureText(s).width + padX * 2; };
+VOX.label = (g, s, size, { fam = F.heavy, bg = C.black, col = C.paper, padX = 24, h = size * 1.62, n = 1e9, seed = 77 } = {}) => {
+ if (n <= 0) return 0; // 还没开始打字:整条标签都不出现(不留空黑条)
+ g.font = font(size, fam); const w = g.measureText(s).width + padX * 2;
+ g.save(); g.translate(-w / 2, -h / 2); g.fillStyle = bg; CL.tornRect(g, w, h, seed, 2.5); g.fill(); g.restore();
+ _noRec++; VOX.typed(g, s, -w / 2 + padX, size * 0.36, n, size, fam, col); _noRec--; VOX.rec(g, 'txt', -w / 2, -h / 2, w, h, [...s].slice(0, n).join('')); return w;
+};
+
+// ---------- 红笔 / 荧光笔 ----------
+const strokeCache = {};
+VOX.handPts = (key, pts, o = {}) => strokeCache[key] || (strokeCache[key] = (() => { const p = DG.hand(pts, { amp: 1.8, seed: 3, ...o }); return { p, L: DG.cum(p) }; })());
+// 画一笔的前 q(0..1),笔头是圆的
+VOX.pen = (g, S, q, { col = C.red, lw = 7, alpha = 1 } = {}) => { if (q <= 0) return; g.save(); g.globalAlpha *= alpha; g.strokeStyle = col; g.lineWidth = lw; g.lineCap = 'round'; g.lineJoin = 'round'; DG.drawPartial(g, S.p, S.L, S.L[S.L.length - 1] * Math.min(1, q)); g.restore(); };
+VOX.circle = (key, rx, ry, seed = 5, a0 = -2.4, turns = 1.1) => VOX.handPts('c' + key, DG.ellipsePts(0, 0, rx, ry, a0, turns, 56), { amp: 2.2, seed });
+// 红叉:两笔
+VOX.cross = (key, s, seed = 2) => [VOX.handPts('x1' + key, [[-s, -s * 0.92], [s * 0.95, s]], { amp: 2.6, seed, per: 10 }), VOX.handPts('x2' + key, [[s * 0.96, -s], [-s, s * 0.9]], { amp: 2.6, seed: seed + 7, per: 10 })];
+VOX.drawCross = (g, X, T, t0, { lw = 12, d = 0.25 } = {}) => { const st = step(T); VOX.pen(g, X[0], seg(st, t0, t0 + d), { lw }); VOX.pen(g, X[1], seg(st, t0 + d * 0.9, t0 + d * 1.9), { lw }); };
+VOX.hl = (g, x, y, w, h, q) => CL.highlight(g, x, y, w, h, q);
+// 计数划记(正字式五道一组,红笔):n 道,每道 dur 秒
+VOX.tally = (g, x, y, n, h = 60, gapX = 20, groupGap = 34, lw = 6) => {
+ g.save(); g.strokeStyle = C.red; g.lineWidth = lw; g.lineCap = 'round';
+ for (let i = 0; i < n; i++) { const gi = Math.floor(i / 5), k = i % 5, gx = x + gi * (gapX * 4 + groupGap);
+ g.beginPath(); if (k < 4) { const xx = gx + k * gapX + Math.sin(i * 7.3) * 2; g.moveTo(xx, y + Math.sin(i * 3.1) * 3); g.lineTo(xx + 3, y + h); } else { g.moveTo(gx - 10, y + h * 0.75); g.lineTo(gx + gapX * 3 + 12, y + h * 0.2); } g.stroke(); }
+ g.restore();
+};
+// 图钉
+VOX.pin = (g, x, y, col = C.red, r = 12) => CL.pin(g, x, y, col);
+
+// ---------- 照片工作室:灰度源图 → 45° 网点照片 ----------
+const GREY = { body: '#ececec', dark: '#262626', nose: '#f2f2f2', engine: '#3c3c3c', window: '#1c1c1c', trunk: '#b8b8b8', flap: '#303030', tiles: '#2a2a2a', truss: '#5a5a5a' };
+VOX.GREY = GREY;
+const PH = VOX.PH = {};
+PH.sky = (g, w, h, top = '#7a7a7a', bot = '#cfcfcf') => { const s = g.createLinearGradient(0, 0, 0, h); s.addColorStop(0, top); s.addColorStop(1, bot); g.fillStyle = s; g.fillRect(0, 0, w, h); };
+PH.blob = (g, x, y, rx, ry, col, blur) => { g.save(); g.filter = `blur(${blur}px)`; g.fillStyle = col; g.beginPath(); g.ellipse(x, y, rx, ry, 0, 0, TAU); g.fill(); g.restore(); };
+// 一团烟:若干软圆(种子固定)
+PH.smoke = (g, x, y, r, n, seed, col = '#e6e6e6', spread = 1) => { const q = rng(seed); for (let i = 0; i < n; i++) { const a = q() * TAU, d = q() * r * spread; PH.blob(g, x + Math.cos(a) * d, y + Math.sin(a) * d * 0.6, r * (0.35 + q() * 0.45), r * (0.3 + q() * 0.4), col, r * 0.12); } };
+// 烟柱:从 (x0,y0) 到 (x1,y1) 一串变粗的软圆
+PH.plume = (g, pts, r0, r1, seed, col = '#e2e2e2') => { const q = rng(seed); const L = DG.cum(pts), tot = L[L.length - 1]; for (let d = 0; d <= tot; d += Math.max(6, r0 * 0.6)) { const k = d / tot, p = DG.pointAt(pts, L, d), r = lerp(r0, r1, k); PH.blob(g, p[0] + (q() - .5) * r * 0.5, p[1] + (q() - .5) * r * 0.4, r * (0.8 + q() * 0.4), r * (0.7 + q() * 0.4), col, r * 0.18); } };
+PH.glow = (g, x, y, r, a = 1, col = '255,255,255') => { const gr = g.createRadialGradient(x, y, 0, x, y, r); gr.addColorStop(0, `rgba(${col},${a})`); gr.addColorStop(1, `rgba(${col},0)`); g.fillStyle = gr; g.fillRect(x - r, y - r, r * 2, r * 2); };
+PH.flame = (g, x, y, len, w, rot = 0) => { g.save(); g.translate(x, y); g.rotate(rot); RK.flame(g, 0, 0, len, w, 0.37, ['rgba(255,255,255,.75)', 'rgba(255,255,255,.92)', '#ffffff']); g.restore(); };
+// 火箭:平涂后叠一层圆柱明暗(左暗、偏左高光、右暗),进网点后读作「有体积的金属箭体」,不是一根白棒
+VOX.shadeFill = (q, shape, pal) => {
+ RK.fill(q, shape, pal);
+ q.save(); const all = new Path2D(); shape.parts.forEach(pp => all.addPath(pp.p)); q.clip(all);
+ const W2 = shape.w * 0.62, gr = q.createLinearGradient(-W2, 0, W2, 0);
+ gr.addColorStop(0, 'rgba(0,0,0,.5)'); gr.addColorStop(0.3, 'rgba(0,0,0,.05)'); gr.addColorStop(0.45, 'rgba(255,255,255,.35)'); gr.addColorStop(0.7, 'rgba(0,0,0,.12)'); gr.addColorStop(1, 'rgba(0,0,0,.55)');
+ q.fillStyle = gr; q.fillRect(-shape.w * 3, -shape.h - 20, shape.w * 6, shape.h + 40); q.restore();
+};
+PH.rocket = (g, shape, x, y, s, rot = 0, pal = GREY) => RK.at(g, x, y, s, rot, q => VOX.shadeFill(q, shape, pal));
+// 照片质感:低频云状明暗(overlay)+暗角——网点因此有了照片式的起伏,而不是一块块平涂
+const NOISE = () => PAINT.cached('vxphnoise', 256, 256, (g) => { const im = g.createImageData(256, 256), d = im.data; for (let y = 0; y < 256; y++) for (let x = 0; x < 256; x++) { const v = 128 + PAINT.fbm(x / 48 + 3.1, y / 48 + 7.7, 5) * 150, i = (y * 256 + x) * 4; d[i] = d[i + 1] = d[i + 2] = clamp(v, 0, 255); d[i + 3] = 255; } g.putImageData(im, 0, 0); });
+PH.texture = (g, w, h, seed = 0) => {
+ g.save(); g.globalCompositeOperation = 'overlay'; g.globalAlpha = 0.32; const n = NOISE(), o = (seed * 37) % 128; g.drawImage(n, o, o, 128, 128, 0, 0, w, h); g.restore();
+ g.save(); const r = g.createRadialGradient(w / 2, h / 2, Math.min(w, h) * 0.35, w / 2, h / 2, Math.hypot(w, h) * 0.62); r.addColorStop(0, 'rgba(0,0,0,0)'); r.addColorStop(1, 'rgba(0,0,0,.28)'); g.fillStyle = r; g.fillRect(0, 0, w, h); g.restore();
+};
+PH.stars = (g, w, h, seed, n = 80) => { const q = rng(seed); g.fillStyle = '#fff'; for (let i = 0; i < n; i++) { const r = q() < 0.85 ? 1.2 : 2.2; g.beginPath(); g.arc(q() * w, q() * h, r, 0, TAU); g.fill(); } };
+// 地球边缘(大圆弧,带云团)
+PH.earthLimb = (g, cx, cy, R, seed = 3) => {
+ g.save(); g.beginPath(); g.arc(cx, cy, R, 0, TAU); g.clip();
+ const e = g.createRadialGradient(cx - R * 0.2, cy - R * 0.3, R * 0.2, cx, cy, R); e.addColorStop(0, '#9c9c9c'); e.addColorStop(0.85, '#6e6e6e'); e.addColorStop(1, '#4a4a4a'); g.fillStyle = e; g.fillRect(cx - R, cy - R, R * 2, R * 2);
+ const q = rng(seed); for (let i = 0; i < 160; i++) { const a = -Math.PI / 2 + (q() - 0.5) * 1.9, d = R * (0.55 + q() * 0.44), x = cx + Math.cos(a) * d, y = cy + Math.sin(a) * d; // 云带:沿纬线拉长的薄云
+ g.save(); g.translate(x, y); g.rotate(a + Math.PI / 2); g.filter = `blur(${R * 0.006}px)`; g.fillStyle = `rgba(238,238,238,${0.35 + q() * 0.5})`; g.beginPath(); g.ellipse(0, 0, R * (0.03 + q() * 0.08), R * (0.006 + q() * 0.012), 0, 0, TAU); g.fill(); g.restore(); }
+ for (let i = 0; i < 6; i++) { const a = -Math.PI / 2 + (q() - 0.5) * 1.4, d = R * (0.7 + q() * 0.25); PH.blob(g, cx + Math.cos(a) * d, cy + Math.sin(a) * d, R * (0.08 + q() * 0.1), R * (0.03 + q() * 0.03), 'rgba(40,40,40,.45)', R * 0.02); }
+ g.restore();
+ g.save(); g.strokeStyle = 'rgba(235,235,235,.8)'; g.lineWidth = R * 0.012; g.filter = `blur(${R * 0.006}px)`; g.beginPath(); g.arc(cx, cy, R * 1.004, 0, TAU); g.stroke(); g.restore();
+};
+// 整个地球(圆盘):逐像素球面投影——噪声大陆(暗)、海洋(中灰)、云带(亮),左上来光;结果进网点后读作「一张地球照片」
+PH.globe = (g, cx, cy, R, seed = 4) => {
+ const S = Math.ceil(R * 2), img = g.createImageData(S, S), d = img.data, ox = seed * 13.7, L = [-0.55, -0.6, 0.58];
+ for (let y = 0; y < S; y++) for (let x = 0; x < S; x++) {
+ const nx = (x + 0.5 - R) / R, ny = (y + 0.5 - R) / R, r2 = nx * nx + ny * ny, i = (y * S + x) * 4; if (r2 > 1) continue;
+ const nz = Math.sqrt(1 - r2), lon = Math.atan2(nx, nz) * 1.6 + ox, lat = Math.asin(ny) * 1.6;
+ const land = PAINT.fbm(lon * 1.1 + 3, lat * 1.3 + 7, 5), cloud = PAINT.fbm(lon * 2.2 + 11, lat * 6 + 2, 4);
+ let v = land > 0.06 ? 70 + (land - 0.06) * 60 : 128 + land * 30;
+ if (cloud > 0.18) v = lerp(v, 240, clamp((cloud - 0.18) * 4));
+ const lam = clamp(nx * L[0] + ny * L[1] + nz * L[2]); v = v * (0.35 + 0.75 * lam) + 25 * Math.pow(1 - nz, 3);
+ d[i] = d[i + 1] = d[i + 2] = clamp(v, 0, 255); d[i + 3] = 255;
+ }
+ const tmp = PAINT.canvas(S, S); tmp.getContext('2d').putImageData(img, 0, 0); g.drawImage(tmp, cx - R, cy - R);
+};
+// 月球 / 火星:圆盘+环形坑
+PH.moon = (g, cx, cy, R, seed = 8, base = '#cfcfcf') => {
+ g.save(); g.beginPath(); g.arc(cx, cy, R, 0, TAU); g.clip();
+ const e = g.createRadialGradient(cx - R * 0.35, cy - R * 0.35, R * 0.1, cx, cy, R); e.addColorStop(0, base); e.addColorStop(1, '#4c4c4c'); g.fillStyle = e; g.fillRect(cx - R, cy - R, R * 2, R * 2);
+ const q = rng(seed); for (let i = 0; i < 26; i++) { const x = cx + (q() - .5) * R * 1.6, y = cy + (q() - .5) * R * 1.6, r = R * (0.04 + q() * 0.12); PH.blob(g, x, y, r, r * 0.9, 'rgba(70,70,70,.45)', r * 0.25); PH.blob(g, x - r * 0.25, y - r * 0.25, r * 0.5, r * 0.45, 'rgba(230,230,230,.35)', r * 0.2); }
+ g.restore();
+};
+// 网点照片精灵:w×h 的照片+border 纸边+旧纸色,投影烘进去
+VOX.photo = (key, w, h, draw, { cell = 6, border = 14, S = 2, contrast = 1.3, pad = 26, tex = true } = {}) => VOX.spr('ph_' + key, w + border * 2, h + border * 2, (g) => {
+ const ph = CL.photo('vx_' + key, Math.round(w * S), Math.round(h * S), (gg, ww, hh) => { gg.scale(S, S); draw(gg, w, h); if (tex) PH.texture(gg, w, h, key.length); }, { border: border * S, cell: cell * S, contrast });
+ const W2 = w + border * 2, H2 = h + border * 2; g.drawImage(ph, 0, 0, W2, H2);
+ // 右下角微微翘起:一道亮边+角下的软阴影(照片是放在桌上的,不是贴死的图层)
+ const k = Math.min(W2, H2) * 0.16, cg = g.createLinearGradient(W2 - k, H2 - k, W2, H2); cg.addColorStop(0, 'rgba(255,255,255,0)'); cg.addColorStop(0.55, 'rgba(255,255,255,.22)'); cg.addColorStop(1, 'rgba(60,45,30,.25)');
+ g.fillStyle = cg; g.beginPath(); g.moveTo(W2, H2 - k); g.lineTo(W2, H2); g.lineTo(W2 - k, H2); g.closePath(); g.fill();
+}, { S, pad, sh: { blur: 16, x: 5, y: 10, col: 'rgba(50,40,25,.32)' } });
+// 剪纸:draw(g, w, h) 在透明底上画平涂形 → 网点(可关)→ 外扩 edge 的纸白贴纸边 → 投影
+VOX.cutout = (key, w, h, draw, { edge = 7, S = 2, ht = true, cell = 5, contrast = 1.35, paper = '#f1ede4', ink = '#1b1b1b', edgeCol = '#f4f2ec', pad = 24, sh } = {}) => VOX.spr('co_' + key, w + edge * 2, h + edge * 2, (g) => {
+ const cw = Math.ceil((w + edge * 2) * S), ch = Math.ceil((h + edge * 2) * S);
+ const src = PAINT.canvas(cw, ch), sg = src.getContext('2d'); sg.scale(S, S); sg.translate(edge, edge); draw(sg, w, h);
+ const art = ht ? CL.halftone('vxco_' + key, src, { cell: cell * S, paper, ink, contrast }) : src;
+ const tmp = PAINT.canvas(cw, ch), tg = tmp.getContext('2d');
+ if (edge > 0) { for (let a = 0; a < 16; a++) tg.drawImage(art, Math.cos(a / 16 * TAU) * edge * S, Math.sin(a / 16 * TAU) * edge * S); tg.globalCompositeOperation = 'source-in'; tg.fillStyle = edgeCol; tg.fillRect(0, 0, cw, ch); tg.globalCompositeOperation = 'source-over'; }
+ tg.drawImage(art, 0, 0);
+ g.drawImage(tmp, 0, 0, w + edge * 2, h + edge * 2);
+}, { S, pad, sh });
+
+// ---------- 照片源图(S01 与 S03 共用)----------
+const sky = (g, w, h, a, b) => PH.sky(g, w, h, a, b), RK0 = RK;
+VOX.DRAW = {};
+const tower = (g, x, gy, hgt, wd = 14) => { g.fillStyle = '#3c3c3c'; g.fillRect(x, gy - hgt, 4, hgt); g.fillRect(x + wd, gy - hgt, 4, hgt); g.strokeStyle = '#3c3c3c'; g.lineWidth = 2; for (let y = gy - hgt; y < gy - 8; y += 14) { g.beginPath(); g.moveTo(x, y); g.lineTo(x + wd + 4, y + 14); g.stroke(); } };
+const failDraw = VOX.DRAW.failDraw = (k) => (g, w, h) => {
+ const s = w / 52;
+ if (k === 0) { // 2006:刚离开发射台就歪了,侧面起火(左边是发射塔)
+ sky(g, w, h, '#7c7c7c', '#d2d2d2'); g.fillStyle = '#3a3a3a'; g.fillRect(0, h * 0.86, w, h * 0.14); tower(g, w * 0.12, h * 0.86, h * 0.62);
+ PH.smoke(g, w * 0.26, h * 0.86, 30, 7, 4, '#eeeeee'); PH.plume(g, [[w * 0.26, h * 0.84], [w * 0.36, h * 0.72], [w * 0.47, h * 0.62]], 7, 14, 11, '#f0f0f0');
+ PH.flame(g, w * 0.5, h * 0.6, 40, 12, 2.0); PH.rocket(g, RK0.falcon1(), w * 0.5, h * 0.6, s, 0.75); PH.glow(g, w * 0.53, h * 0.55, 34, 0.9);
+ } else if (k === 1) { // 2007:高空,箭体打转,螺旋尾迹;下面是地球的弧线
+ sky(g, w, h, '#161616', '#5c5c5c'); PH.earthLimb(g, w * 0.5, h * 3.2, h * 2.45, 7);
+ const pts = []; for (let i = 0; i <= 40; i++) { const u = i / 40; pts.push([w * (0.08 + 0.52 * u) + Math.sin(u * 16) * 14 * u, h * (0.92 - 0.5 * u) + Math.cos(u * 16) * 8 * u]); }
+ PH.plume(g, pts, 4, 10, 12, '#e8e8e8'); PH.flame(g, w * 0.66, h * 0.4, 30, 10, 1.3 + Math.PI / 2); PH.rocket(g, RK0.falcon1(), w * 0.66, h * 0.4, s * 0.9, 1.3 - Math.PI / 2 + Math.PI);
+ } else { // 2008.8:级间分离后两截撞在一起,一团闪光
+ sky(g, w, h, '#141414', '#525252');
+ PH.plume(g, [[w * 0.36, h * 1.02], [w * 0.42, h * 0.7]], 5, 10, 13, '#dcdcdc');
+ PH.rocket(g, RK0.falcon1(), w * 0.44, h * 0.74, s * 0.85, 0.22);
+ g.save(); g.translate(w * 0.62, h * 0.3); g.rotate(-0.9); PH.rocket(g, RK0.falcon1(), 0, 0, s * 0.85, 0); g.restore();
+ PH.glow(g, w * 0.53, h * 0.47, 46, 1); PH.smoke(g, w * 0.53, h * 0.47, 22, 7, 7, '#f4f4f4');
+ }
+};
+const padDraw = VOX.DRAW.padDraw = (g, w, h) => { // 发射台上的猎鹰1号(最后一发)
+ sky(g, w, h, '#9a9a9a', '#e2e2e2');
+ g.fillStyle = '#3c3c3c'; g.fillRect(0, h * 0.86, w, h * 0.14);
+ g.fillStyle = '#555'; g.fillRect(w * 0.66, h * 0.2, 9, h * 0.66); g.fillRect(w * 0.76, h * 0.2, 9, h * 0.66);
+ g.strokeStyle = '#555'; g.lineWidth = 3; for (let y = h * 0.22; y < h * 0.84; y += 26) { g.beginPath(); g.moveTo(w * 0.66, y); g.lineTo(w * 0.77, y + 26); g.stroke(); }
+ PH.rocket(g, RK0.falcon1(), w * 0.47, h * 0.86, h / 31);
+ PH.smoke(g, w * 0.4, h * 0.86, 26, 5, 21, 'rgba(250,250,250,.85)');
+};
+const launchDraw = VOX.DRAW.launchDraw = (g, w, h) => { // 大幅扫描:2008.9.28 那一发升空
+ sky(g, w, h, '#2c2c2c', '#bdbdbd');
+ PH.plume(g, [[w * 0.47, h * 1.05], [w * 0.475, h * 0.82], [w * 0.48, h * 0.66]], 26, 60, 31, '#efefef');
+ PH.smoke(g, w * 0.46, h * 1.02, 150, 14, 33, '#f6f6f6', 1.5);
+ PH.glow(g, w * 0.482, h * 0.66, 150, 0.95);
+ PH.flame(g, w * 0.482, h * 0.62, 210, 54, 0.03);
+ PH.rocket(g, RK0.falcon1(), w * 0.482, h * 0.62, h / 40, 0.03);
+};
+const shipDraw = VOX.DRAW.shipDraw = (g, w, h) => { // 2026:星舰在轨,下面是地球边缘
+ g.fillStyle = '#121212'; g.fillRect(0, 0, w, h); PH.stars(g, w, h, 9, 60);
+ PH.earthLimb(g, w * 0.5, h * 1.75, h * 1.05, 5);
+ PH.rocket(g, RK0.ship(), w * 0.54, h * 0.52, w / 72, 1.05);
+};
+
+// ---------- 桌上物件 ----------
+VOX.ITEMS = [];
+// o: { key, x, y, r, at(全片秒,出现), until?, z(层,默认 10), rad(剔除半径), enter?: {from:[dx,dy], tilt, dur}, draw(g, T) }
+VOX.item = (o) => { const it = { r: 0, z: 10, rad: 900, ...o }; VOX.ITEMS.push(it); VOX._sorted = null; return it; };
+const enterXf = (it, T) => {
+ const en = it.enter; if (!en) return null;
+ const q = clamp(step(T - it.at) / (en.dur || 0.5)); if (q >= 1) return null;
+ const e = MO.quartOut(q), from = en.from || [0, -300];
+ if (en.drop) { const s = 1 + (en.drop) * (1 - e); return { dx: 0, dy: 0, dr: (en.tilt || 0) * (1 - e), s }; }
+ return { dx: from[0] * (1 - e), dy: from[1] * (1 - e), dr: (en.tilt ?? 0.18) * (1 - Math.min(1, e * 1.15)), s: 1 };
+};
+VOX.view = (cam) => { const a = CAM.toWorld(cam, 0, 0), b = CAM.toWorld(cam, W, H); return [a[0], a[1], b[0], b[1]]; };
+VOX.drawWorld = (g, cam, T, { only } = {}) => {
+ if (!VOX._sorted) VOX._sorted = VOX.ITEMS.map((it, i) => [it, i]).sort((a, b) => (a[0].z - b[0].z) || (a[1] - b[1])).map(a => a[0]);
+ const [x0, y0, x1, y1] = VOX.view(cam);
+ g.save(); CAM.apply(g, cam); g.imageSmoothingQuality = 'high';
+ g.fillStyle = g.createPattern(VOX.deskTile(), 'repeat'); g.fillRect(x0 - 10, y0 - 10, x1 - x0 + 20, y1 - y0 + 20);
+ VOX.zoom = cam.z;
+ for (const it of VOX._sorted) {
+ if (T < it.at || (it.until != null && T >= it.until)) continue;
+ if (only && !only(it)) continue;
+ const rad = it.rad; if (it.x + rad < x0 || it.x - rad > x1 || it.y + rad < y0 || it.y - rad > y1) continue;
+ const xf = enterXf(it, T);
+ g.save(); g.translate(it.x + (xf ? xf.dx : 0), it.y + (xf ? xf.dy : 0)); if (it.r || xf) g.rotate(it.r + (xf ? xf.dr : 0)); if (xf && xf.s !== 1) g.scale(xf.s, xf.s);
+ VOX._cur = it.key; it.draw(g, T); g.restore();
+ }
+ g.restore();
+};
+// ---------- 前景道具(近景层,视差 d>1,轻微失焦):铅笔、长尾夹、胶带卷、放大镜——相机在桌上移动时它们比纸片动得快,桌面有了前后景 ----------
+const propSpr = {
+ pencil: () => VOX.spr('prop_pencil', 620, 40, (g, w, h) => {
+ g.fillStyle = '#b8433f'; g.fillRect(70, 4, w - 130, h - 8); g.fillStyle = 'rgba(255,255,255,.25)'; g.fillRect(70, 8, w - 130, 7); g.fillStyle = 'rgba(0,0,0,.18)'; g.fillRect(70, h - 14, w - 130, 6);
+ g.fillStyle = '#c9a77a'; g.fillRect(w - 60, 4, 30, h - 8); g.fillStyle = '#9a9a96'; g.fillRect(w - 66, 4, 8, h - 8);
+ g.fillStyle = '#e2c9a0'; g.beginPath(); g.moveTo(70, 4); g.lineTo(10, h / 2); g.lineTo(70, h - 4); g.closePath(); g.fill(); g.fillStyle = '#2a2a28'; g.beginPath(); g.moveTo(28, h / 2 - 7); g.lineTo(6, h / 2); g.lineTo(28, h / 2 + 7); g.closePath(); g.fill();
+ }, { sh: { blur: 22, x: 14, y: 26, col: 'rgba(40,30,20,.38)' } }),
+ clip: () => VOX.spr('prop_clip', 150, 150, (g, w, h) => {
+ g.fillStyle = '#1e1e1d'; g.beginPath(); g.moveTo(15, 70); g.lineTo(135, 70); g.lineTo(122, 140); g.lineTo(28, 140); g.closePath(); g.fill();
+ g.strokeStyle = '#b9b9b6'; g.lineWidth = 7; g.lineCap = 'round'; g.beginPath(); g.moveTo(38, 78); g.lineTo(52, 12); g.lineTo(98, 12); g.lineTo(112, 78); g.stroke();
+ g.fillStyle = 'rgba(255,255,255,.18)'; g.fillRect(22, 78, 106, 10);
+ }, { sh: { blur: 20, x: 12, y: 22, col: 'rgba(40,30,20,.4)' } }),
+ tape: () => VOX.spr('prop_tape', 220, 220, (g, w, h) => {
+ g.fillStyle = 'rgba(226,220,200,.92)'; g.beginPath(); g.arc(w / 2, h / 2, 104, 0, TAU); g.arc(w / 2, h / 2, 62, 0, TAU, true); g.fill();
+ g.strokeStyle = 'rgba(180,170,150,.6)'; g.lineWidth = 2; for (let r = 66; r < 104; r += 7) { g.beginPath(); g.arc(w / 2, h / 2, r, 0, TAU); g.stroke(); }
+ g.fillStyle = '#8a7a62'; g.beginPath(); g.arc(w / 2, h / 2, 62, 0, TAU); g.arc(w / 2, h / 2, 52, 0, TAU, true); g.fill();
+ }, { sh: { blur: 22, x: 12, y: 24, col: 'rgba(40,30,20,.35)' } }),
+ lens: () => VOX.spr('prop_lens', 360, 200, (g, w, h) => {
+ g.fillStyle = '#2a2826'; g.save(); g.translate(190, 100); g.rotate(0); g.fillRect(0, -14, 170, 28); g.restore();
+ g.strokeStyle = '#3a3836'; g.lineWidth = 16; g.beginPath(); g.arc(100, 100, 86, 0, TAU); g.stroke();
+ const r = g.createRadialGradient(80, 76, 10, 100, 100, 80); r.addColorStop(0, 'rgba(255,255,255,.35)'); r.addColorStop(1, 'rgba(255,255,255,.06)'); g.fillStyle = r; g.beginPath(); g.arc(100, 100, 80, 0, TAU); g.fill();
+ }, { sh: { blur: 26, x: 16, y: 30, col: 'rgba(40,30,20,.35)' } }),
+};
+VOX.PROP = (k) => propSpr[k]();
+const PROPS = [
+ { k: 'pencil', x: 2330, y: 1450, r: 0.6, d: 1.14, s: 1 }, { k: 'clip', x: 4700, y: 1560, r: -0.3, d: 1.1, s: 1 }, { k: 'tape', x: 7140, y: 1560, r: 0, d: 1.12, s: 1 },
+ { k: 'lens', x: 4720, y: 3320, r: 0.5, d: 1.15, s: 1 }, { k: 'pencil', x: 2470, y: 5060, r: -0.35, d: 1.14, s: 0.8 },
+];
+VOX.drawProps = (g, cam) => {
+ for (const p of PROPS) {
+ const sp = propSpr[p.k](), [sx0, sy0] = CAM.toScreen(cam, p.x, p.y), k = p.d, sx = W / 2 + (sx0 - W / 2) * k, sy = H / 2 + (sy0 - H / 2) * k, sc = cam.z * Math.pow(k, 1.6) * p.s;
+ const R = (sp.vw + sp.vpad * 2) * sc * 0.6; if (sx + R < 0 || sx - R > W || sy + R < 0 || sy - R > H) continue;
+ g.save(); g.translate(sx, sy); g.rotate(p.r); g.scale(sc, sc); g.filter = `blur(${Math.max(0.5, 1.6 * cam.z).toFixed(2)}px)`; VOX.blit(g, sp); g.restore();
+ }
+};
+// 屏幕空间收尾:暗角+静态颗粒(纸纹是贴死的,不逐帧抖)
+VOX.finish = (c) => {
+ c.drawImage(PAINT.cached('vx_vig', W, H, (g) => { const r = g.createRadialGradient(W / 2, H / 2, H * 0.45, W / 2, H / 2, H * 1.05); r.addColorStop(0, 'rgba(40,30,20,0)'); r.addColorStop(1, 'rgba(40,30,20,.30)'); g.fillStyle = r; g.fillRect(0, 0, W, H); }), 0, 0);
+ c.drawImage(PAINT.grain('vxgrain', 0.05, [40, 30, 20], 0.14), 0, 0);
+};
+// 一帧桌面:camFn(lt) 给相机;快摇时沿速度方向叠帧模糊(模糊短于位移)
+VOX.desk = (c, camFn, lt, T, { blur = 0.5 } = {}) => {
+ const cam = camFn(lt), buf = PAINT.scratch('vxdesk'), g = buf.getContext('2d'); g.reset();
+ VOX.drawWorld(g, cam, T); VOX.drawProps(g, cam);
+ c.fillStyle = C.desk; c.fillRect(0, 0, W, H);
+ const [vx, vy] = CAM.velocity(camFn, lt), z0 = camFn(Math.max(0, lt - 1 / 30)).z, dz = Math.abs(Math.log(cam.z / z0));
+ // 快推快拉时网点会在缩放中出摩尔纹:按缩放速度给一点点模糊(和平移的运动模糊一起,都是镜头在动的痕迹)
+ const zb = dz > 0.02 && dz < 1 ? Math.min(2.5, (dz - 0.02) * 40) : 0;
+ if (zb > 0.2) { c.save(); c.filter = `blur(${zb.toFixed(2)}px)`; }
+ if (Math.hypot(vx, vy) > 220) c.drawImage(buf, 0, 0); else CAM.motionBlur(c, buf, vx * blur, vy * blur, 7); // 速度离谱=硬切那一帧,不叠
+ if (zb > 0.2) c.restore();
+ VOX.finish(c);
+};
+// 插入镜头(推满照片后硬切成的「大幅扫描」):画一张照片精灵铺满画面,带慢推
+VOX.insert = (c, sp, lt, { z0 = 1.0, z1 = 1.05, d = 2, cx = 0, cy = 0, bg = C.black, sy = 0 } = {}) => {
+ c.fillStyle = bg; c.fillRect(0, 0, W, H);
+ const z = lerp(z0, z1, MO.sineInOut(clamp(lt / d)));
+ c.save(); c.translate(W / 2, H / 2 + sy); c.scale(z, z); c.imageSmoothingQuality = 'high'; VOX.blit(c, sp, cx, cy); c.restore();
+ VOX.finish(c);
+};
+
+// ---------- 调查红线(全桌一根)----------
+// 节点:每格一个年份标签挂在红线下;行尾沿桌边拐下去。reveal:S01「两分钟」时一口气走完全程。
+const TAGS = [['s02', '2002'], ['s03', '2006–2008'], ['s04', '2008–2012'], ['s05', '2015–2017'], ['s06', '2018'], ['s07', '2020'], ['s08', '发射次数'], ['s09', '星链'], ['s10', '星舰'], ['s11', '2026'], ['s01', '2026.9.28'], ['s12', '接下来']];
+VOX.TAGS = TAGS;
+VOX.tagPos = id => { const c = VOX.cell(id), rtl = c.row === 1; return [c.x + (rtl ? 2400 - 300 : 300), VOX.BAND(c.row)]; };
+const NODES = (() => {
+ const o = [[60, VOX.BAND(0)]];
+ for (const [id] of TAGS) {
+ const p = VOX.tagPos(id), c = VOX.cell(id);
+ if (id === 's06') { o.push([9540, VOX.BAND(0)]); o.push([9540, VOX.BAND(1)]); }
+ if (id === 's10') { o.push([60, VOX.BAND(1)]); o.push([60, VOX.BAND(2)]); }
+ o.push(p);
+ }
+ o.push([9540, VOX.BAND(2)]);
+ return o;
+})();
+const STRING = (() => { let pts = []; for (let i = 1; i < NODES.length; i++) { const a = NODES[i - 1], b = NODES[i], s = CL.stringPts(a, b, Math.abs(a[1] - b[1]) > 10 ? 0.01 : 0.025, 40); pts = pts.concat(i > 1 ? s.slice(1) : s); } return { pts, cum: DG.cum(pts) }; })();
+VOX.STRING = STRING;
+// 红线揭开:从开场那格(「9.28」)的节点向两头同时长出去——相机正从这格往外拉,观众看着线从脚下跑开(12fps 步进)
+const ND = NODES.map((n) => { let best = 0, bd = 1e18; STRING.pts.forEach((p, i) => { const d = Math.hypot(p[0] - n[0], p[1] - n[1]); if (d < bd) { bd = d; best = i; } }); return STRING.cum[best]; });
+VOX.nodeD = (k) => ND[k];
+const D01 = ND[NODES.findIndex(n => { const p = VOX.tagPos('s01'); return n[0] === p[0] && n[1] === p[1]; })], LTOT = STRING.cum[STRING.cum.length - 1];
+VOX.stringReveal = (T) => { const a = VOX.cue('s01', '两分钟') + 0.05; return MO.sineInOut(clamp((step(T) - a) / 1.75)); };
+const CHEV = (() => { const o = [], step = 520; for (let d = 300; d < LTOT - 100; d += step) { const p = DG.pointAt(STRING.pts, STRING.cum, d), q = DG.pointAt(STRING.pts, STRING.cum, d + 6); if (NODES.some(n => Math.hypot(n[0] - p[0], n[1] - p[1]) < 260)) continue; o.push([p[0], p[1], Math.atan2(q[1] - p[1], q[0] - p[0]), d]); } return o; })();
+VOX.strR = (T) => VOX.stringReveal(T) * Math.max(D01, LTOT - D01) * 1.001;
+VOX.strVisible = (T, d) => VOX.stringReveal(T) > 0 && Math.abs(d - D01) <= VOX.strR(T) + 1;
+const drawRange = (g, pts, cum, d0, d1) => { g.beginPath(); const a = DG.pointAt(pts, cum, d0); g.moveTo(a[0], a[1]); for (let i = 0; i < pts.length; i++) if (cum[i] > d0 && cum[i] < d1) g.lineTo(pts[i][0], pts[i][1]); const b = DG.pointAt(pts, cum, d1); g.lineTo(b[0], b[1]); g.stroke(); };
+VOX.item({ key: 'string', x: VOX.DW / 2, y: VOX.DH / 2, rad: 1e6, z: 50, at: 0, draw(g, T) {
+ if (VOX.stringReveal(T) <= 0) return;
+ g.save(); g.translate(-VOX.DW / 2, -VOX.DH / 2);
+ const r = VOX.strR(T), d0 = Math.max(0, D01 - r), d1 = Math.min(LTOT, D01 + r), lw = Math.max(5, 2.4 / VOX.zoom);
+ g.lineCap = 'round'; g.lineJoin = 'round';
+ g.save(); g.strokeStyle = 'rgba(0,0,0,.16)'; g.lineWidth = lw; g.translate(3, 6); drawRange(g, STRING.pts, STRING.cum, d0, d1); g.restore();
+ g.strokeStyle = C.red; g.lineWidth = lw; drawRange(g, STRING.pts, STRING.cum, d0, d1);
+ NODES.forEach((n, k) => { if (VOX.strVisible(T, ND[k])) { g.save(); g.translate(n[0], n[1]); const s = Math.max(1, 0.5 / VOX.zoom); g.scale(s, s); VOX.pin(g, 0, 0); g.restore(); } });
+ // 走向箭头:红笔小箭头标出调查线的走向(第 2 行从右往左、行尾往下拐),全景时一眼读出时间顺序
+ CHEV.forEach(([x, y, a, d]) => { if (!VOX.strVisible(T, d)) return; const s = Math.max(1, 0.55 / VOX.zoom); g.save(); g.translate(x, y); g.rotate(a); g.scale(s, s); g.strokeStyle = C.red; g.lineWidth = 7; g.lineCap = 'round'; g.lineJoin = 'round'; g.beginPath(); g.moveTo(-14, -16); g.lineTo(6, 0); g.lineTo(-14, 16); g.stroke(); g.restore(); });
+ g.restore();
+} });
+// 年份标签(黑底大字,挂在红线下;红线走到这儿才出现)
+TAGS.forEach(([id, s], k) => {
+ const [x, y] = VOX.tagPos(id), ni = NODES.findIndex(n => n[0] === x && n[1] === y);
+ VOX.item({ key: 'tag' + id, x, y: y + 140, r: (k % 2 ? 0.02 : -0.018), rad: 700, z: 49, at: 0, draw(g, T) {
+ if (!VOX.strVisible(T, VOX.nodeD(ni))) return;
+ const sp = VOX.spr('tag' + id, VOX.tagW(s), 230, (gg, w, h) => { gg.save(); CL.tornRect(gg, w, h, 31 + k, 3); gg.fillStyle = C.black; gg.fill(); gg.restore(); VOX.text(gg, s, w / 2, h / 2 + 56, 160, /\d/.test(s) ? F.num : F.heavy, C.paper, 'center'); }, { S: 1.2 });
+ VOX.blit(g, sp);
+ } });
+});
+VOX.tagW = (s) => { const g = PAINT.scratch('vxmeasure').getContext('2d'); g.font = font(160, /\d/.test(s) ? F.num : F.heavy); return g.measureText(s).width + 90; };
+
+// ---------- 预热:启动时把所有缓存精灵画一遍(不然第一次用到的那一帧要现做网点,单帧会到 1–2 秒) ----------
+VOX.warm = []; // 场景里额外要预热的函数(插入镜头的大照片)
+VOX.prewarm = () => {
+ const g = PAINT.scratch('vxwarm').getContext('2d'); VOX.zoom = 1;
+ for (const it of VOX.ITEMS) for (const T of [it.at + 0.02, it.at + 0.6, it.at + 1.5, it.at + 3, 1e4]) { g.reset(); g.translate(960, 540); try { it.draw(g, T); } catch (e) { console.error('prewarm ' + it.key + ' ' + e); } }
+ VOX.warm.forEach(f => f()); Object.values(propSpr).forEach(f => f());
+};
+// ---------- 通用:场景注册 ----------
+// 每段一个 shots 表:[{t: 起点 lt, kind: 'desk'|'fn', fn?}];desk 镜头用该段相机。段与段之间没有转场(同一张桌子:相机运动即转场,或在句读处硬切)。
+VOX.scene = (id, { cam, shots = [], init } = {}) => {
+ VOX.cams[id] = cam;
+ SCENES[id] = {
+ init() { if (init) init(); },
+ draw(c, lt, t) {
+ let sh = null; for (const s of shots) if (lt >= s.t) sh = s;
+ if (sh && sh.fn) { VOX._cur = 'insert:' + id; sh.fn(c, lt, t); return; }
+ VOX.desk(c, cam, lt, t);
+ },
+ };
+};
+// 字形检查:一段里所有上屏文字
+VOX.glyphs = (id, list) => { for (const [fam, s] of list) U.assertGlyphs(fam, s, id); };
+VOX.checkTags = () => { TAGS.forEach(([, s]) => U.assertGlyphs(/\d/.test(s) ? F.num : F.heavy, s, 'tags')); };
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex_vox/scenes/s01.js b/scripts/engine/reference_films/spacex/spacex_vox/scenes/s01.js
new file mode 100644
index 0000000..ee62f12
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_vox/scenes/s01.js
@@ -0,0 +1,128 @@
+// S01 · 冷开场:「9.28」那一格。第 0 帧就是证据——黑底「2008」标签+三张失败发射的网点照片。
+// 连败三次 → 三个红叉一顿一顿划上去;最后一发 → 相机移到发射台照片,打字条「最后一发」被红笔圈住;
+// 9月28号 → 日历页滑进来;成了 → 推满照片、硬切成同一次发射的大幅扫描;18 年后的同一天 → 两张日历一根红线;
+// 星舰入轨 → 照片滑进来红圈圈住;两分钟,看完它这 24 年 → 相机长尾拉到全桌,红线一口气走完 12 格,「24年」打出来。
+(() => {
+const ID = 's01', V = VOX, C = V.C, F = V.F, PH = V.PH, RK0 = RK, TAU = Math.PI * 2;
+const { clamp, lerp } = U, seg = MO.seg, step = V.step;
+const cell = V.cell(ID), X0 = cell.x, Y0 = cell.y, P = (x, y) => [X0 + x, Y0 + y];
+const cue = k => TM.cue(ID, k), G = k => V.cue(ID, k);
+const T = { y2008: '2008', f: ['2006', '2007', '2008.8'], last: '最后一发', cal: ['2008', '2026'], m: '9月', d: '28', y18: '18年', big: '24年', ins: '2008.9.28', ok: '成了' };
+
+const { failDraw, padDraw, launchDraw, shipDraw } = V.DRAW;
+const S = {};
+const calSprite = (yr) => V.spr('s01cal' + yr, 300, 380, (g, w, h) => {
+ V.paper(g, w, h, 5 + +yr % 7, { col: '#f3f1ea', amp: 2, age: 0.15 });
+ g.fillStyle = C.black; g.fillRect(0, 0, w, 50); g.fillStyle = '#c9c2b2'; for (const x of [70, w - 70]) { g.beginPath(); g.arc(x, 25, 9, 0, TAU); g.fill(); }
+ g.fillStyle = 'rgba(40,36,30,.35)'; for (let x = 12; x < w; x += 14) { g.beginPath(); g.arc(x, 60, 2.2, 0, TAU); g.fill(); }
+ V.text(g, yr, w / 2, 112, 42, F.type, C.ink2, 'center'); V.text(g, T.m, w / 2, 168, 44, F.heavy, C.red, 'center');
+ V.text(g, T.d, w / 2, 352, 190, F.num, C.ink, 'center');
+});
+
+// ---------- 桌上物件 ----------
+const at0 = -1;
+V.item({ key: 's01lab', ...xy(330, 520), r: -0.02, at: at0, draw(g) { V.blit(g, S.lab || (S.lab = V.spr('s01lab', V.labelW(PAINT.scratch('m').getContext('2d'), T.y2008, 118, F.num, 34), 190, (gg, w, h) => { gg.save(); CL.tornRect(gg, w, h, 41, 3); gg.fillStyle = C.black; gg.fill(); gg.restore(); V.text(gg, T.y2008, w / 2, h / 2 + 42, 118, F.num, C.paper, 'center'); }, { S: 1.5 }))); } });
+const UL = V.handPts('s01ul', [[-150, 0], [-40, 6], [80, 2], [160, 8]], { amp: 1.6, seed: 9 });
+V.item({ key: 's01ul', ...xy(330, 620), r: -0.02, z: 12, at: 0.25, draw(g, T_) { V.pen(g, UL, MO.cubicOut(seg(step(T_), 0.3, 0.85)), { lw: 9 }); } });
+const tLose = G('连败');
+V.item({ key: 's01lose', ...xy(720, 520), r: 0.025, z: 12, at: at0, draw(g) { V.label(g, '连败三次', 64, { bg: C.red2, padX: 26 }); } }); // 第 0 帧就把冲突摆出来
+const FP = [[330, 800, -0.03], [745, 780, 0.025], [1150, 810, -0.015]];
+const FX = FP.map((_, i) => V.cross('s01f' + i, 120, 3 + i * 5));
+const tX = [cue('连'), cue('败'), cue('三')];
+FP.forEach(([x, y, r], i) => {
+ V.item({ key: 's01f' + i, ...xy(x, y), r, at: at0, draw(g, T_) {
+ const sp = V.photo('s01f' + i, 370, 250, failDraw(i), { cell: 5, border: 13 }); V.blit(g, sp);
+ V.tape(g, -150, -134, -0.5, 100); V.tape(g, 150, -134, 0.45, 100);
+ // 打字机日期条
+ g.save(); g.translate(-110, 180); g.rotate(0.02); g.fillStyle = C.paper; CL.tornRect(g, 220, 64, 9 + i, 2); g.fill(); V.text(g, T.f[i], 110, 46, 40, F.type, C.ink, 'center'); g.restore();
+ V.drawCross(g, FX[i], T_, V.t0(ID) + tX[i], { lw: 13, d: 0.17 });
+ } });
+});
+function xy(x, y) { const [a, b] = P(x, y); return { x: a, y: b }; }
+// 发射台照片+「最后一发」字条
+const tNote = G('最后'), tCirc = G('一发');
+const NC = V.circle('s01note', 170, 58, 7);
+V.item({ key: 's01pad', ...xy(1480, 760), r: 0.03, at: at0, draw(g) { const sp = V.photo('s01pad', 340, 460, padDraw, { cell: 5, border: 14 }); V.blit(g, sp); V.tape(g, 0, -244, 0.04, 140); } });
+V.item({ key: 's01note', ...xy(1480, 545), r: -0.035, z: 12, at: tNote - 0.25, enter: { from: [60, -200], tilt: -0.12, dur: 0.4 }, draw(g, T_) {
+ g.save(); g.translate(-150, -48); V.paper(g, 300, 96, 13, { amp: 3 }); g.restore();
+ V.typed(g, T.last, -116, 22, V.nTyped(T_, tNote, 14), 60, F.heavy, C.ink);
+ V.pen(g, NC, MO.cubicOut(seg(step(T_), tCirc + 0.15, tCirc + 0.65)), { lw: 7 });
+} });
+// 日历两页+中间红线「18年」
+V.item({ key: 's01cal08', ...xy(1890, 745), r: 0.04, z: 11, at: G('月') - 0.12, enter: { from: [320, -260], tilt: 0.2, dur: 0.45 }, draw(g, T_) {
+ V.blit(g, calSprite('2008')); V.hl(g, -104, 16, 208, 154, MO.sineInOut(seg(step(T_), G('同一') - 0.05, G('同一') + 0.35)));
+} });
+V.item({ key: 's01cal26', ...xy(1890, 1310), r: -0.03, z: 11, at: G('年后') - 0.1, enter: { from: [260, 380], tilt: -0.2, dur: 0.45 }, draw(g, T_) {
+ V.blit(g, calSprite('2026')); V.hl(g, -104, 16, 208, 154, MO.sineInOut(seg(step(T_), G('一天') - 0.05, G('一天') + 0.35)));
+} });
+const s18 = (() => { const a = P(1895, 950), b = P(1885, 1105), pts = CL.stringPts(a, b, 0.05, 20); return { a, b, pts, cum: DG.cum(pts) }; })();
+V.item({ key: 's01str', x: s18.a[0], y: (s18.a[1] + s18.b[1]) / 2, z: 13, at: G('整整') + 0.3, draw(g, T_) {
+ const q = MO.sineInOut(seg(step(T_), G('整整') + 0.3, G('18年'))); g.save(); g.translate(-s18.a[0], -(s18.a[1] + s18.b[1]) / 2);
+ CL.string(g, s18.pts, s18.cum, s18.cum[s18.cum.length - 1] * q, { col: C.red, lw: 5 }); V.pin(g, s18.a[0], s18.a[1]); if (q >= 1) V.pin(g, s18.b[0], s18.b[1]);
+ if (step(T_) >= G('18年') - 0.05) { g.save(); g.translate(s18.a[0] + 112, (s18.a[1] + s18.b[1]) / 2); g.rotate(0.03); g.fillStyle = C.card; g.fillRect(-90, -44, 180, 88); V.text(g, T.y18, 0, 24, 62, F.heavy, C.ink, 'center'); g.restore(); }
+ g.restore();
+} });
+// 星舰在轨照片:滑进来、红笔圈住
+const SC = V.circle('s01ship', 165, 120, 11);
+V.item({ key: 's01ship', ...xy(1290, 1385), r: -0.045, z: 12, at: G('星舰') - 0.12, enter: { from: [-520, 140], tilt: -0.2, dur: 0.5 }, draw(g, T_) {
+ const sp = V.photo('s01ship', 400, 470, shipDraw, { cell: 5, border: 14 }); V.blit(g, sp); V.tape(g, -160, -246, -0.45, 110); V.tape(g, 160, -246, 0.5, 110);
+ g.save(); g.translate(16, 10); V.pen(g, SC, MO.cubicOut(seg(step(T_), G('进入'), G('进入') + 0.6)), { lw: 8 }); g.restore();
+} });
+// 承诺:拉到全桌时红笔圈出三个转折点——连败(2006–2008)、回收(2015–2017)、入轨(2026.9.28)
+const TURN = [['s03', '2006–2008'], ['s05', '2015–2017'], ['s01', '2026.9.28']].map(([id, txt], k) => { const [x, y] = V.tagPos(id); return { x, y: y + 140, c: V.circle('s01turn' + k, V.tagW(txt) / 2 + 110, 210, 3 + k) }; });
+V.item({ key: 's01turn', x: V.DW / 2, y: V.DH / 2, z: 61, rad: 1e6, at: G('看完') - 0.05, until: V.t0('s02') + 1.3, draw(g, T_) {
+ const st = step(T_); g.save(); g.translate(-V.DW / 2, -V.DH / 2);
+ TURN.forEach((t, k) => { const t0_ = G('看完') + k * 0.22; g.save(); g.translate(t.x, t.y); V.pen(g, t.c, MO.cubicOut(seg(st, t0_, t0_ + 0.3)), { lw: Math.max(9, 3.2 / V.zoom) }); g.restore(); });
+ g.restore();
+} });
+// 「24年」:拉到全桌时在桌子正中打出来(下一段飞进 2002 后撤掉)
+V.item({ key: 's01big', x: 5750, y: 1975, r: -0.015, z: 60, rad: 3000, at: G('24') - 0.1, until: V.t0('s02') + 1.3, enter: { drop: 0.25, dur: 0.3 }, draw(g, T_) { g.scale(0.68, 0.68);
+ V.blit(g, S.big || (S.big = V.spr('s01big', 1500, 640, (gg, w, h) => { gg.save(); CL.tornRect(gg, w, h, 55, 6); gg.fillStyle = C.black; gg.fill(); gg.restore(); V.text(gg, '24', 120, h / 2 + 205, 560, F.num, C.yel); V.text(gg, '年', 120 + 470, h / 2 + 200, 420, F.heavy, C.paper); }, { S: 0.6, pad: 40, sh: { blur: 30, y: 20 } })));
+} });
+
+// ---------- 相机 ----------
+const ins0 = cue('成了'), ins1 = cue('整整') + 0.45;
+const OV = V.overview(), OV1 = { ...OV, y: OV.y + 220, z: OV.z * 0.92 }; // 这一次全景下面有字幕:整张桌子往上让一点
+const at = (x, y, z, sy) => { const [a, b] = P(x, y); return V.at(a, b, z, sy); };
+const K = [
+ V.key(0, at(740, 735, 1.44)),
+ V.key(2.2, at(740, 730, 1.33), MO.longTail),
+ V.key(cue('钱') - 0.1, at(745, 728, 1.335), MO.sineInOut),
+ V.key(cue('够'), at(1300, 820, 1.2), MO.sineInOut), // 「找下一张卡」:对称 Easy Ease
+ V.key(cue('9'), at(1310, 815, 1.22), MO.sineInOut),
+ V.key(cue('号'), at(1400, 820, 1.08), MO.longTail),
+ V.key(cue('那一'), at(1410, 822, 1.1), MO.sineInOut),
+ V.key(ins1 - 0.001, at(1420, 822, 1.11), MO.sineInOut),
+ V.key(ins1, at(1500, 1000, 0.86)), // 硬切回桌面:两张日历
+ V.key(cue('星舰') + 0.05, at(1510, 1005, 0.89), MO.sineInOut),
+ V.key(cue('进入') + 0.1, at(1600, 1270, 1.06), MO.sineInOut),
+ V.key(cue('两分钟') + 0.08, at(1590, 1272, 1.09), MO.sineInOut),
+ V.key(cue('24') + 0.1, OV1, MO.longTail), // 拉出揭示:长尾,红线跟着走完全桌
+ V.key(TM.dur(ID) + 0.01, { ...OV1, z: OV1.z * 1.012 }, MO.sineInOut),
+];
+const PUSH = [cue('那一') + 0.02, ins0];
+const cam = (lt) => {
+ const base = CAM.at(K, lt);
+ if (lt < PUSH[0] || lt >= ins1) return base;
+ const [px, py] = P(1480, 760);
+ return CAM.pushTo(base, px, py, 4.2, MO.sineInOut(seg(lt, PUSH[0], PUSH[1])));
+};
+// 插入镜头:大幅扫描+红笔圈+黑标签打字
+const IC = V.circle('s01ins', 130, 300, 4, -2.2, 1.08);
+const insertShot = (c, lt) => {
+ const sp = V.photo('s01ins', 1640, 900, launchDraw, { cell: 8, border: 22, S: 1 });
+ V.insert(c, sp, lt - ins0, { z0: 0.95, z1: 0.99, d: 1.2, bg: C.desk, sy: -75 });
+ const st = step(lt), z = lerp(0.95, 0.99, MO.sineInOut(clamp((lt - ins0) / 1.2)));
+ c.save(); c.translate(960, 465); c.scale(z, z);
+ c.save(); c.translate(-29, -147); V.pen(c, IC, MO.cubicOut(seg(st, ins0 + 0.12, ins0 + 0.62)), { lw: 9 }); c.restore();
+ c.restore();
+ c.save(); c.translate(520, 210); c.rotate(-0.02); const n = TY.typedCount(st, ins0 + 0.05, 16); V.label(c, T.ins, 54, { fam: F.type, n }); c.restore();
+ if (st >= cue('了') - 0.02) { c.save(); c.translate(1360, 760); c.rotate(-0.06); const s = 1 + 0.25 * (1 - MO.quartOut(clamp(step(lt - cue('了') + 0.02) / 0.25))); c.scale(s, s); V.label(c, T.ok, 96, { bg: C.red2, padX: 30 }); c.restore(); }
+};
+V.warm.push(() => V.photo('s01ins', 1640, 900, launchDraw, { cell: 8, border: 22, S: 1 }));
+V.scene(ID, {
+ cam,
+ shots: [{ t: 0 }, { t: ins0, fn: insertShot }, { t: ins1 }],
+ init() { V.checkTags(); V.glyphs(ID, [[F.num, T.y2008 + T.d + '24'], [F.type, T.f.join('') + T.ins + '20082026'], [F.heavy, T.last + T.m + T.y18 + T.ok + '年连败三次']]); },
+});
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex_vox/scenes/s02.js b/scripts/engine/reference_films/spacex/spacex_vox/scenes/s02.js
new file mode 100644
index 0000000..f793f04
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_vox/scenes/s02.js
@@ -0,0 +1,60 @@
+// S02 · 2002:从全桌飞进左上角第一格。黑纸剪影(不画脸)+打字索引卡「2002 · 创办 SpaceX」;
+// 「目标是……住到别的星球上」:相机沿桌移到一张剪报引语,荧光笔跟读;地球网点照片到一颗红色网点星球之间,红线一顿一顿描出航线(Vox 地图描线:线头带红点)。
+(() => {
+const ID = 's02', V = VOX, C = V.C, F = V.F, PH = V.PH, TAU = Math.PI * 2;
+const { clamp, lerp } = U, seg = MO.seg, step = V.step;
+const cell = V.cell(ID), X0 = cell.x, Y0 = cell.y, xy = (x, y) => ({ x: X0 + x, y: Y0 + y });
+const cue = k => TM.cue(ID, k), G = k => V.cue(ID, k);
+const T = { name: '马斯克', yr: '2002', act: '创办 SpaceX', q1: '目标:', q2: '有一天,让人类', q3: '住到别的星球上', earth: '地球' };
+
+// 黑纸剪影:西装男子(无五官,只有轮廓)
+const man = () => V.cutout('s02man', 300, 520, (g, w, h) => {
+ // 黑纸剪出来的人形(只有轮廓、没有五官):圆肩、收腰的西装外套、略分开的手臂和裤腿,边缘是剪刀剪出来的微抖曲线
+ const tile = CL.paperTile('vxblackman', '#1d1d1c', { amt: 6, fibers: 60, seed: 3 }), cx = w / 2;
+ const R = [[0, 10], [24, 16], [40, 44], [42, 80], [32, 110], [20, 124], [22, 142], [66, 154], [108, 170], [122, 196], [128, 260], [130, 330], [126, 384], [110, 392], [102, 340], [100, 262], [86, 300], [84, 404], [70, 404], [66, h - 30], [72, h - 10], [30, h - 6], [26, h - 30], [14, 412], [0, 404]];
+ const P = R.concat(R.slice(1, -1).reverse().map(([x, y]) => [-x, y]));
+ const pts = KIT.densify(P.map(([x, y]) => [cx + x, y]).concat([[cx, 10]]), 4).map(([x, y], i) => [x + PAINT.noise(i * 0.31, 2.2) * 1.6, y + PAINT.noise(i * 0.27, 5.1) * 1.6]);
+ g.fillStyle = g.createPattern(tile, 'repeat'); g.beginPath(); pts.forEach(([x, y], i) => i ? g.lineTo(x, y) : g.moveTo(x, y)); g.closePath(); g.fill();
+ g.fillStyle = '#4a4a48'; g.beginPath(); g.moveTo(cx - 24, 150); g.lineTo(cx, 236); g.lineTo(cx + 24, 150); g.closePath(); g.fill(); // 衬衫领口(灰)
+}, { ht: false, edge: 8 });
+const globe = (key, R, draw, ink) => V.cutout(key, R * 2, R * 2, (g) => draw(g, R, R, R), { cell: 5, edge: 6, ink });
+
+V.item({ key: 's02man', ...xy(470, 700), r: -0.02, z: 12, at: G('2002') - 0.05, enter: { from: [-420, 80], tilt: -0.2, dur: 0.5 }, draw(g, T_) {
+ V.blit(g, man());
+ g.save(); g.translate(0, 296); g.rotate(0.02); g.fillStyle = C.paper; g.save(); g.translate(-110, -38); CL.tornRect(g, 220, 76, 7, 2); g.fill(); g.restore();
+ V.typed(g, T.name, -78, 20, V.nTyped(T_, G('马斯克'), 12), 52, F.heavy, C.ink); g.restore();
+} });
+V.item({ key: 's02card', ...xy(1000, 700), r: 0.025, z: 11, at: G('创办') - 0.2, enter: { from: [380, -120], tilt: 0.16, dur: 0.45 }, draw(g, T_) {
+ const sp = V.spr('s02card', 520, 300, (gg, w, h) => V.indexCard(gg, w, h, { top: 78, gap: 54 })); V.blit(g, sp);
+ const n = V.nTyped(T_, G('创办'), 13); V.typed(g, T.yr, -220, -78, n, 56, F.type, C.red); V.typed(g, T.act, -220, 30, n - 4, 64, F.heavy, C.ink);
+} });
+// 引语剪报(打字机印好,荧光笔跟读「住到别的星球上」)
+const QW = 720, QH = 250;
+V.item({ key: 's02quote', ...xy(1720, 1060), r: -0.02, z: 11, at: G('目标') - 0.25, enter: { from: [0, 300], tilt: -0.1, dur: 0.4 }, draw(g, T_) {
+ const sp = V.spr('s02quote', QW, QH, (gg, w, h) => { V.paper(gg, w, h, 23, { amp: 4 }); V.text(gg, T.q1, 46, 80, 40, F.heavy, C.red); V.serifBold(gg, T.q2, 46, 150, 56); V.serifBold(gg, T.q3, 46, 218, 56); }); V.blit(g, sp);
+ g.save(); g.translate(-QW / 2, -QH / 2); g.font = V.font(56, F.serif); const w3 = g.measureText(T.q3).width;
+ V.hl(g, 38, 170, w3 + 18, 62, MO.sineInOut(seg(step(T_), G('住到') - 0.05, G('上') + 0.1))); g.restore();
+} });
+// 地球 → 星球:红线描路(线头实心红点)
+const E = xy(1440, 620), M = xy(2150, 520), ER = 170, MR = 120;
+V.item({ key: 's02earth', ...E, r: 0, z: 10, at: G('目标') - 0.3, draw(g) { V.blit(g, globe('s02earth', ER, (gg, cx, cy, R) => PH.globe(gg, cx, cy, R, 4))); g.save(); g.translate(0, ER + 46); g.fillStyle = C.paper; g.fillRect(-70, -30, 140, 60); V.text(g, T.earth, 0, 18, 40, F.heavy, C.ink, 'center'); g.restore(); } });
+V.item({ key: 's02mars', ...M, r: 0, z: 10, at: G('别的') - 0.1, enter: { from: [420, -80], tilt: 0.25, dur: 0.45 }, draw(g) { V.blit(g, globe('s02mars', MR, (gg, cx, cy, R) => PH.moon(gg, cx, cy, R, 6, '#d8d8d8'), C.red2)); } });
+const ROUTE = (() => { const a = [E.x + ER * 0.8, E.y - ER * 0.55], b = [M.x - MR * 1.05, M.y + 10], pts = []; for (let i = 0; i <= 60; i++) { const u = i / 60; pts.push([lerp(a[0], b[0], u), lerp(a[1], b[1], u) - Math.sin(u * Math.PI) * 190]); } return { pts, cum: DG.cum(pts) }; })();
+V.item({ key: 's02route', x: (E.x + M.x) / 2, y: E.y - 120, z: 13, rad: 700, at: G('让人') - 0.1, draw(g, T_) {
+ const q = MO.sineInOut(seg(step(T_), G('让人'), G('星球') + 0.1)); g.save(); g.translate(-(E.x + M.x) / 2, -(E.y - 120));
+ const L = ROUTE.cum[ROUTE.cum.length - 1] * q; g.setLineDash([22, 16]); CL.string(g, ROUTE.pts, ROUTE.cum, L, { col: C.red, lw: 7, shadow: null }); g.setLineDash([]);
+ const tip = DG.pointAt(ROUTE.pts, ROUTE.cum, L); g.fillStyle = C.red; g.beginPath(); g.arc(tip[0], tip[1], 13, 0, TAU); g.fill(); g.restore();
+} });
+
+// ---------- 相机:从全桌长尾飞进 2002 → 沿桌移到引语和航线 → 末尾沿红线往右滑进下一格 ----------
+const at = (x, y, z, sy) => V.at(X0 + x, Y0 + y, z, sy);
+const cam = (lt) => CAM.at([
+ V.key(0, V.camEnd('s01')),
+ V.key(0.85, at(760, 600, 1.0), MO.longTail),
+ V.key(cue('目标') - 0.1, at(790, 610, 1.04), MO.sineInOut),
+ V.key(cue('有一') + 0.15, at(1760, 700, 0.92), MO.sineInOut),
+ V.key(TM.dur(ID) - 0.35, at(1790, 700, 0.95), MO.sineInOut),
+ V.key(TM.dur(ID), at(1900, 700, 0.95), MO.cubicIn),
+], lt);
+V.scene(ID, { cam, init() { V.glyphs(ID, [[F.heavy, T.name + T.act + T.q1 + T.earth], [F.type, T.yr], [F.serif, T.q2 + T.q3]]); } });
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex_vox/scenes/s03.js b/scripts/engine/reference_films/spacex/spacex_vox/scenes/s03.js
new file mode 100644
index 0000000..53260a2
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_vox/scenes/s03.js
@@ -0,0 +1,111 @@
+// S03 · 猎鹰1号四次发射:摄影编辑的「印样」(contact sheet)。
+// 剪纸猎鹰1号立在桌上+黑标签;一条胶片印样四格,相机一格一格快切过去(快档节奏),每念一次「失败」红色蜡笔打一个叉,
+// 片边印着日期;第四格被红圈圈住 → 推满 → 硬切成大幅扫描:它进了轨道(全片第一个高光,留一拍);
+// 再切到剪报,荧光笔跟读「私人研制」「液体燃料」。
+(() => {
+const ID = 's03', V = VOX, C = V.C, F = V.F, PH = V.PH, TAU = Math.PI * 2;
+const { clamp, lerp } = U, seg = MO.seg, step = V.step;
+const cell = V.cell(ID), X0 = cell.x, Y0 = cell.y, xy = (x, y) => ({ x: X0 + x, y: Y0 + y });
+const cue = k => TM.cue(ID, k), G = k => V.cue(ID, k), t0 = V.t0(ID);
+const fail = [V.cueN(ID, '失败', 0), V.cueN(ID, '失败', 1), V.cueN(ID, '失败', 2)];
+const T = { name: '猎鹰1号', d: ['2006', '2007', '2008.8', '2008.9'], kick: '2008.9.28', h1: '第一枚私人研制、', h2: '进入轨道的液体燃料火箭', ok: '入轨' };
+
+// 剪纸猎鹰1号(细长:21×1.7 m)
+const f1 = () => V.cutout('s03f1', 90, 800, (g, w, h) => PH.rocket(g, RK.falcon1(), w / 2, h - 30, (h - 40) / 22.7), { cell: 5, edge: 7 });
+V.item({ key: 's03f1', ...xy(230, 860), r: -0.03, z: 12, at: G('第一款') - 0.1, enter: { from: [-260, 420], tilt: -0.25, dur: 0.5 }, draw(g) { V.blit(g, f1()); } });
+V.item({ key: 's03name', ...xy(620, 470), r: -0.02, z: 13, at: G('猎鹰') - 0.12, enter: { drop: 0.25, dur: 0.25 }, draw(g, T_) { V.label(g, T.name, 82, { n: V.nTyped(T_, G('猎鹰'), 12) }); } });
+
+// 胶片印样:白相纸上一条黑胶片,四格正片(网点),片边印日期
+const SW = 1740, SH = 430, FW = 370, FH = 240, fx = i => 70 + FW / 2 + i * (FW + 40) - SW / 2, FY = -12;
+const okDraw = (g, w, h) => { PH.sky(g, w, h, '#1c1c1c', '#7a7a7a'); PH.plume(g, [[w * 0.36, h * 1.02], [w * 0.42, h * 0.74], [w * 0.5, h * 0.5]], 8, 20, 17, '#e4e4e4'); PH.glow(g, w * 0.53, h * 0.45, 40, 0.9); PH.flame(g, w * 0.53, h * 0.45, 46, 13, 0.45 + Math.PI * 0); PH.rocket(g, RK.falcon1(), w * 0.53, h * 0.45, h / 70, 0.45); };
+const frameDraw = [V.DRAW.failDraw(0), V.DRAW.failDraw(1), V.DRAW.failDraw(2), okDraw];
+const sheet = () => V.spr('s03sheet', SW, SH, (g, w, h) => {
+ V.paper(g, w, h, 17, { col: '#f2f0ea', torn: false, age: 0.12 });
+ g.fillStyle = '#151515'; g.fillRect(30, 40, w - 60, h - 80);
+ g.fillStyle = '#e9e5da'; for (let x = 52; x < w - 60; x += 46) { for (const y of [48, h - 66]) { g.beginPath(); g.roundRect(x, y, 22, 18, 4); g.fill(); } }
+ for (let i = 0; i < 4; i++) {
+ const src = CL.photo('s03fr' + i, FW * 2, FH * 2, (gg, ww, hh) => { gg.scale(2, 2); frameDraw[i](gg, FW, FH); }, { border: 0, cell: 8, contrast: 1.35 });
+ g.drawImage(src, w / 2 + fx(i) - FW / 2, h / 2 + FY - FH / 2, FW, FH);
+ V.text(g, T.d[i], w / 2 + fx(i) - FW / 2 + 6, h / 2 + FY + FH / 2 + 27, 24, F.type, '#d9b56a');
+ V.text(g, String(i + 1), w / 2 + fx(i) + FW / 2 - 18, h / 2 + FY + FH / 2 + 27, 24, F.type, '#d9b56a', 'right');
+ }
+});
+const SX = 1350, SY = 820, SR = 0.012;
+const GX = [0, 1, 2].map(i => V.cross('s03x' + i, 118, 5 + i * 3)), GC = V.circle('s03c4', 222, 160, 9, -2.6, 1.12);
+V.item({ key: 's03sheet', ...xy(SX, SY), r: SR, z: 10, at: t0 - 0.5, draw(g, T_) {
+ V.blit(g, sheet()); V.tape(g, -SW / 2 + 40, -SH / 2 + 10, -0.6, 120); V.tape(g, SW / 2 - 40, -SH / 2 + 10, 0.55, 120);
+ for (let i = 0; i < 3; i++) { g.save(); g.translate(fx(i), FY); V.drawCross(g, GX[i], T_, t0 + fail[i] + 0.04, { lw: 15, d: 0.17 }); g.restore(); }
+ g.save(); g.translate(fx(3), FY); V.pen(g, GC, MO.cubicOut(seg(step(T_), G('四次'), G('四次') + 0.5)), { lw: 13 }); g.restore();
+} });
+// 剪报
+const NW = 1000, NH = 420, N = xy(1500, 1390);
+const news = () => V.spr('s03news', NW, NH, (g, w, h) => {
+ V.paper(g, w, h, 29, { amp: 5 });
+ V.text(g, T.kick, 56, 70, 34, F.type, C.ink2); g.fillStyle = C.ink; g.fillRect(56, 88, w - 112, 3); g.fillRect(56, 96, w - 112, 1);
+ V.serifBold(g, T.h1, 56, 190, 76); V.serifBold(g, T.h2, 56, 286, 76);
+ g.fillStyle = 'rgba(40,36,30,.26)'; [820, 760, 880].forEach((ww, i) => g.fillRect(56, 326 + i * 24, ww, 10));
+});
+const HL = (() => { const g = PAINT.scratch('vxmeasure').getContext('2d'); return [V.span(g, T.h1, '私人研制', 56, 76, F.serif), V.span(g, T.h2, '液体燃料', 56, 76, F.serif)]; })();
+V.item({ key: 's03news', ...N, r: -0.018, z: 11, at: t0 - 0.5, draw(g, T_) {
+ V.blit(g, news()); g.save(); g.translate(-NW / 2, -NH / 2); const st = step(T_);
+ V.hl(g, HL[0].x - 6, 128, HL[0].w + 12, 80, MO.sineInOut(seg(st, G('私人'), G('制') + 0.15)));
+ V.hl(g, HL[1].x - 6, 224, HL[1].w + 12, 80, MO.sineInOut(seg(st, G('液体'), G('料') + 0.15)));
+ g.restore();
+} });
+
+// ---------- 插入镜头:第四格的大幅扫描(它在轨道上)----------
+const orbitDraw = (g, w, h) => {
+ g.fillStyle = '#101010'; g.fillRect(0, 0, w, h); PH.stars(g, w, h, 21, 120);
+ PH.earthLimb(g, w * 0.32, h * 2.05, h * 1.45, 9);
+ const pts = []; for (let i = 0; i <= 30; i++) { const u = i / 30; pts.push([lerp(w * 0.12, w * 0.6, u), h * 0.86 - Math.sin(u * 1.5) * h * 0.5]); }
+ PH.plume(g, pts, 4, 10, 41, 'rgba(230,230,230,.7)');
+ PH.glow(g, w * 0.6, h * 0.41, 90, 0.8); PH.flame(g, w * 0.6, h * 0.41, 90, 24, -1.9 + Math.PI);
+ PH.rocket(g, RK.falcon1(), w * 0.6, h * 0.41, h / 58, 1.24);
+};
+const ins0 = cue('了,成') + 0.02, ins1 = cue('私人') - 0.18;
+const IC = V.circle('s03ins', 300, 150, 6, -2.8, 1.1);
+const insertShot = (c, lt) => {
+ const sp = V.photo('s03ins', 1680, 940, orbitDraw, { cell: 8, border: 22, S: 1 });
+ const z = lerp(0.95, 0.985, MO.sineInOut(clamp((lt - ins0) / (ins1 - ins0))));
+ V.insert(c, sp, lt - ins0, { z0: 0.95, z1: 0.985, d: ins1 - ins0, bg: C.desk, sy: -75 });
+ const st = step(lt);
+ c.save(); c.translate(960, 465); c.scale(z, z); c.translate(1680 * 0.1 + 20, 940 * -0.09 - 10); c.rotate(-0.3); V.pen(c, IC, MO.cubicOut(seg(st, ins0 + 0.1, ins0 + 0.55)), { lw: 10 }); c.restore();
+ if (st >= ins0 + 0.35) { c.save(); c.translate(560, 250); c.rotate(-0.05); const s = 1 + 0.3 * (1 - MO.quartOut(clamp(step(lt - ins0 - 0.35) / 0.25))); c.scale(s, s); V.label(c, T.ok, 110, { bg: C.red2, padX: 34 }); c.restore(); }
+};
+
+// ---------- 相机 ----------
+const at = (x, y, z, sy) => V.at(X0 + x, Y0 + y, z, sy);
+const FR = i => { const a = fx(i) * Math.cos(SR) - FY * Math.sin(SR), b = fx(i) * Math.sin(SR) + FY * Math.cos(SR); return [SX + a, SY + b]; };
+const frameCam = (i, z = 2.05) => { const [x, y] = FR(i); return at(x, y + 30, z, 500); };
+const d1 = cue('2006年'), d2 = cue('2007年'), d3 = cue('2008年'), d4 = cue('第四次');
+const K = [
+ V.key(0, V.camEnd('s02')),
+ V.key(1.0, at(620, 820, 0.98), MO.longTail),
+ V.key(d1 - 0.12, at(660, 820, 1.02), MO.sineInOut),
+ V.key(d1 + 0.28, frameCam(0), MO.cubicInOut), // 快切档:0.4s 跳到第一格
+ V.key(d2 - 0.12, frameCam(0, 2.1), MO.sineInOut),
+ V.key(d2 + 0.22, frameCam(1), MO.cubicInOut),
+ V.key(d3 - 0.12, frameCam(1, 2.1), MO.sineInOut),
+ V.key(d3 + 0.22, frameCam(2), MO.cubicInOut),
+ V.key(d4 - 0.12, frameCam(2, 2.1), MO.sineInOut),
+ V.key(d4 + 0.22, frameCam(3, 1.7), MO.cubicInOut),
+ V.key(cue('成了'), frameCam(3, 1.78), MO.sineInOut),
+];
+const push = [cue('成了'), ins0];
+const K2 = [
+ V.key(ins1, at(1500, 1330, 1.12)),
+ V.key(cue('液体'), at(1520, 1340, 1.2), MO.sineInOut),
+ V.key(TM.dur(ID) - 0.55, at(1540, 1340, 1.22), MO.sineInOut),
+ V.key(TM.dur(ID), at(1760, 1240, 1.14), MO.cubicIn), // 沿红线往右起步(下一段接着追)
+];
+const cam = (lt) => {
+ if (lt >= ins1) return CAM.at(K2, lt);
+ const base = CAM.at(K, lt); if (lt < push[0]) return base;
+ const [x, y] = FR(3); return CAM.pushTo(base, X0 + x, Y0 + y, 6.0, MO.sineInOut(seg(lt, push[0], push[1])));
+};
+V.warm.push(() => V.photo('s03ins', 1680, 940, orbitDraw, { cell: 8, border: 22, S: 1 }));
+V.scene(ID, {
+ cam, shots: [{ t: 0 }, { t: ins0, fn: insertShot }, { t: ins1 }],
+ init() { V.glyphs(ID, [[F.heavy, T.name + T.ok], [F.type, T.d.join('') + T.kick + '1234'], [F.serif, T.h1 + T.h2]]); },
+});
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex_vox/scenes/s04.js b/scripts/engine/reference_films/spacex/spacex_vox/scenes/s04.js
new file mode 100644
index 0000000..4de6ccd
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_vox/scenes/s04.js
@@ -0,0 +1,110 @@
+// S04 · 2008.12 合同 → 2012 龙飞船:红线「三个月后」从上一格的剪报牵到一份别着回形针的合同,荧光笔跟读「16亿美元」「12次空间站补给」;
+// 相机沿第二根红线掠过「2010 猎鹰9号首飞」小卡,落到空间站网点照片:剪纸龙飞船一顿一顿靠上去对接,红笔圈住,黑标签打字。
+(() => {
+const ID = 's04', V = VOX, C = V.C, F = V.F, PH = V.PH, TAU = Math.PI * 2;
+const { clamp, lerp } = U, seg = MO.seg, step = V.step;
+const cell = V.cell(ID), X0 = cell.x, Y0 = cell.y, xy = (x, y) => ({ x: X0 + x, y: Y0 + y });
+const cue = k => TM.cue(ID, k), G = k => V.cue(ID, k), t0 = V.t0(ID);
+const T = { tag3: '三个月后', kick: '2008.12', head: 'NASA 商业补给合同', l1a: '合同金额', l1b: '16亿美元', l2a: '任务', l2b: '12次空间站补给', c10: '2010 · 猎鹰9号首飞', yr: '2012', lb: '第一艘造访国际空间站的私人飞船' };
+
+// ---------- 合同(回形针+打字表格)----------
+const NW = 780, NH = 600, N = xy(640, 1000), NR = -0.022;
+const POS = {};
+const doc = () => V.spr('s04doc', NW, NH, (g, w, h) => {
+ V.paper(g, w, h, 21, { col: '#efeee9', torn: false, age: 0.16 });
+ V.text(g, T.kick, 54, 78, 34, F.type, C.ink2); g.fillStyle = C.ink; g.fillRect(54, 96, w - 108, 3); g.fillRect(54, 103, w - 108, 1);
+ V.text(g, T.head, 54, 190, 60, F.heavy, C.ink); g.fillRect(54, 222, w - 108, 1.5);
+ V.text(g, T.l1a, 54, 310, 38, F.med, C.ink2); g.font = V.font(38, F.med); let x1 = 54 + g.measureText(T.l1a).width + 26;
+ V.text(g, T.l1b, x1, 316, 66, F.heavy, C.ink); g.font = V.font(66, F.heavy); POS.h1 = { x: x1 - 10, y: 254, w: g.measureText(T.l1b).width + 20, h: 76 };
+ V.text(g, T.l2a, 54, 404, 38, F.med, C.ink2); g.font = V.font(38, F.med); let x2 = 54 + g.measureText(T.l2a).width + 26;
+ V.text(g, T.l2b, x2, 408, 50, F.heavy, C.ink); g.font = V.font(50, F.heavy); POS.h2 = { x: x2 - 10, y: 360, w: g.measureText(T.l2b).width + 20, h: 64 };
+ g.fillStyle = 'rgba(40,36,30,.26)'; [640, 600, 660, 380].forEach((ww, i) => g.fillRect(54, 456 + i * 26, ww, 11));
+});
+const clip = (g, x, y, a) => { g.save(); g.translate(x, y); g.rotate(a); g.strokeStyle = '#8d8d8a'; g.lineWidth = 5; g.lineCap = 'round'; g.beginPath(); g.moveTo(0, 60); g.lineTo(0, -40); g.arc(13, -40, 13, Math.PI, 0); g.lineTo(26, 70); g.arc(6, 70, 20, 0, Math.PI); g.lineTo(-14, -20); g.stroke(); g.restore(); };
+V.item({ key: 's04doc', ...N, r: NR, z: 11, at: t0 - 1, draw(g, T_) {
+ V.blit(g, doc()); clip(g, -NW / 2 + 70, -NH / 2 + 18, 0.15);
+ g.save(); g.translate(-NW / 2, -NH / 2); const st = step(T_);
+ V.hl(g, POS.h1.x, POS.h1.y, POS.h1.w, POS.h1.h, MO.sineInOut(seg(st, G('16亿'), G('16亿') + 0.75)));
+ V.hl(g, POS.h2.x, POS.h2.y, POS.h2.w, POS.h2.h, MO.sineInOut(seg(st, G('往空间站'), G('送货') + 0.2)));
+ g.restore();
+} });
+// ---------- 2010 小卡 ----------
+const C10 = xy(1180, 1420);
+V.item({ key: 's04c10', ...C10, r: 0.045, z: 10, at: t0 - 1, draw(g) {
+ V.blit(g, V.spr('s04c10', 380, 300, (gg, w, h) => {
+ V.indexCard(gg, w, h, { top: 40, gap: 34 });
+ const ph = CL.photo('s04f9', 600, 340, (q, ww, hh) => { q.scale(2, 2); PH.sky(q, 300, 170, '#9a9a9a', '#d8d8d8'); q.fillStyle = '#555'; q.fillRect(0, 148, 300, 22); q.fillStyle = '#3a3a3a'; q.fillRect(186, 20, 10, 130); PH.rocket(q, RK.falcon9({ payload: 'fairing' }), 150, 150, 1.95); }, { border: 16, cell: 8 });
+ gg.save(); gg.translate(w / 2, 112); gg.rotate(-0.02); gg.drawImage(ph, -158, -93, 316, 186); gg.restore();
+ V.text(gg, T.c10, w / 2, h - 34, 30, F.bold, C.ink, 'center');
+ }));
+} });
+// ---------- 空间站网点照片+剪纸龙飞船 ----------
+const P2 = xy(1700, 880), PW = 820, PHh = 520, PR = 0.02;
+const stationDraw = (g, w, h) => {
+ const cx = w / 2, cy = h / 2;
+ const sk = g.createLinearGradient(0, 0, 0, h); sk.addColorStop(0, '#0b0b0b'); sk.addColorStop(1, '#222'); g.fillStyle = sk; g.fillRect(0, 0, w, h); PH.stars(g, w, h, 3, 40);
+ PH.earthLimb(g, cx + 120, cy + 1400, 1180, 12);
+ g.save(); g.translate(cx, cy - 60);
+ const panel = (x, y, pw, ph) => { g.fillStyle = '#585858'; g.fillRect(x, y, pw, ph); g.strokeStyle = '#9d9d9d'; g.lineWidth = 2; for (let k = 1; k < 4; k++) { g.beginPath(); g.moveTo(x + pw * k / 4, y); g.lineTo(x + pw * k / 4, y + ph); g.stroke(); } for (let k = 1; k < 8; k++) { g.beginPath(); g.moveTo(x, y + ph * k / 8); g.lineTo(x + pw, y + ph * k / 8); g.stroke(); } };
+ for (const x of [-300, -228, 178, 250]) { panel(x, -58 - 150, 52, 150); panel(x, -42, 52, 150); }
+ g.fillStyle = '#d9d9d9'; g.fillRect(-330, -58, 660, 16);
+ g.strokeStyle = '#7a7a7a'; g.lineWidth = 2; for (let x = -330; x < 330; x += 22) { g.beginPath(); g.moveTo(x, -58); g.lineTo(x + 11, -42); g.lineTo(x + 22, -58); g.stroke(); }
+ g.fillStyle = '#c9c9c9'; for (const x of [-120, 90]) g.fillRect(x, -40, 30, 60);
+ const cyl = (x, y, cw, ch) => { const gr = g.createLinearGradient(x, 0, x + cw, 0); gr.addColorStop(0, '#9a9a9a'); gr.addColorStop(0.45, '#f4f4f4'); gr.addColorStop(1, '#8a8a8a'); g.fillStyle = gr; g.beginPath(); g.roundRect(x, y, cw, ch, 8); g.fill(); };
+ cyl(-24, -96, 48, 70); cyl(-22, -30, 44, 82); cyl(-18, 50, 36, 46);
+ g.fillStyle = '#e8e8e8'; g.beginPath(); g.roundRect(-110, -20, 220, 36, 12); g.fill();
+ g.fillStyle = '#bdbdbd'; g.fillRect(-12, 96, 24, 14);
+ g.restore();
+};
+const PORT = [0, -60 + 110]; // 对接口(照片中心坐标系)
+const dragon = () => V.cutout('s04dragon', 64, 118, (g, w, h) => RK.at(g, w / 2, h, 16.5, 0, q => V.shadeFill(q, RK.dragon({ trunk: true }), { body: '#ececec', trunk: '#b5b5b5', nose: '#dadada', window: '#202020', line: '#3a3a3a', lw: 0.12 })), { cell: 4, edge: 6, sh: { blur: 8, x: 3, y: 5, col: 'rgba(0,0,0,.4)' } });
+const tDr = G('龙飞船') - 0.15, tDock = G('国际空间站') + 0.2, DC = V.circle('s04dock', 96, 74, 13);
+V.item({ key: 's04iss', ...P2, r: PR, z: 10, at: t0 - 1, draw(g, T_) {
+ const sp = V.photo('s04iss', PW, PHh, stationDraw, { cell: 6, border: 16 }); V.blit(g, sp); V.tape(g, PW / 2 - 60, -PHh / 2 - 6, 0.45, 130);
+ const st = step(T_), q = clamp((st - tDr) / (tDock - tDr));
+ if (q > 0) {
+ const e = MO.smooth(q), dock = [PORT[0], PORT[1] + 59 + 4];
+ const x = lerp(-170, dock[0], e), y = lerp(PHh / 2 + 120, dock[1], e) + (q >= 1 ? MO.settle(st - tDock, 3, 3, 6) : 0);
+ g.save(); g.translate(x, y); g.rotate(lerp(-0.32, 0, e) + (q < 1 ? 0.02 * Math.sin(st * 9) : 0)); V.blit(g, dragon()); g.restore();
+ }
+ g.save(); g.translate(PORT[0], PORT[1] + 40); V.pen(g, DC, MO.cubicOut(seg(st, tDock + 0.1, tDock + 0.7)), { lw: 7 }); g.restore();
+} });
+// 黑底标签条(压在照片左下角):「2012」随条滑入,下一行打字
+const LB = xy(1640, 1215);
+V.item({ key: 's04lb', ...LB, r: -0.02, z: 12, at: G('2012') - 0.05, enter: { from: [-60, 380], tilt: -0.14, dur: 0.45 }, draw(g, T_) {
+ // 黑条跟着打字往右长(不留一大截空黑条)
+ const n = V.nTyped(T_, G('第一艘'), 13); g.font = V.font(34, F.heavy); const tw = g.measureText([...T.lb].slice(0, n).join('')).width;
+ const W0 = 660, w = Math.max(240, Math.min(W0, tw + 70)), h = 180; g.save(); g.translate(-W0 / 2, -h / 2); g.fillStyle = C.black; CL.tornRect(g, w, h, 77, 3); g.fill(); g.restore();
+ V.text(g, T.yr, -W0 / 2 + 30, -h / 2 + 92, 78, F.num, C.yel);
+ V.typed(g, T.lb, -W0 / 2 + 30, h / 2 - 32, n, 34, F.heavy, C.paper);
+} });
+// ---------- 红线:上一格剪报 → 合同(三个月后);合同 → 2010 小卡 → 照片 ----------
+const PREV = [V.cell('s03').x + 1500 + 420, 1390 - 150];
+const A1 = PREV, B1 = [N.x - NW / 2 + 40, N.y - NH / 2 + 30];
+const mk = (a, b, sag) => { const pts = CL.stringPts(a, b, sag); return { a, b, pts, cum: DG.cum(pts) }; };
+const S1 = mk(A1, B1, 0.08), S2 = mk([N.x + NW / 2 - 30, N.y + 40], [C10.x, C10.y - 130], 0.06), S3 = mk([C10.x + 40, C10.y - 130], [P2.x - PW / 2 + 40, P2.y - PHh / 2 + 10], 0.07);
+const tS1 = [G('三个') - 0.05, G('后') + 0.25], tS2 = [G('2012') - 0.25, G('2012') + 0.2], tS3 = [G('2012') + 0.1, G('2012') + 0.55];
+V.item({ key: 's04str', x: X0 + 600, y: 1000, rad: 2600, z: 48, at: tS1[0], draw(g, T_) {
+ g.save(); g.translate(-(X0 + 600), -1000); const st = step(T_);
+ const str = (S, a, b, tag) => { const q = MO.sineInOut(seg(st, a, b)); if (q <= 0) return; const L = S.cum[S.cum.length - 1]; CL.string(g, S.pts, S.cum, L * q, { col: C.red, lw: 5 }); V.pin(g, S.a[0], S.a[1]); if (q >= 1) V.pin(g, S.b[0], S.b[1]);
+ if (tag && q > 0.45) { const m = DG.pointAt(S.pts, S.cum, L * 0.5); g.save(); g.translate(m[0], m[1] + 50); g.rotate(0.04); g.fillStyle = C.card; const tw = 250; g.fillRect(-tw / 2, -36, tw, 72); V.text(g, tag, 0, 16, 44, F.heavy, C.ink, 'center'); g.restore(); } };
+ str(S1, tS1[0], tS1[1], T.tag3); str(S2, tS2[0], tS2[1]); str(S3, tS3[0], tS3[1]);
+ g.restore();
+} });
+
+// ---------- 相机 ----------
+const at = (x, y, z, sy) => V.at(X0 + x, Y0 + y, z, sy);
+const pan2 = cue('2012') - 0.25;
+const cam = (lt) => CAM.at([
+ V.key(0, V.camEnd('s03')),
+ V.key(0.35, at(-420, 1180, 0.95), MO.cubicIn),
+ V.key(1.35, at(620, 970, 1.14), MO.longTail), // 沿红线追过去:长尾
+ V.key(cue('16亿'), at(610, 975, 1.17), MO.sineInOut),
+ V.key(cue('送货') + 0.3, at(600, 1010, 1.32), MO.sineInOut), // 荧光笔期间慢推向那两行
+ V.key(pan2, at(605, 1012, 1.33), MO.sineInOut),
+ V.key(pan2 + 0.6, at(1250, 1120, 0.95), MO.cubicInOut), // 「找下一张卡」:拉开、掠过 2010 小卡
+ V.key(pan2 + 1.25, at(1690, 960, 1.08), MO.longTail),
+ V.key(TM.dur(ID), at(1700, 975, 1.2), MO.sineInOut),
+], lt);
+V.scene(ID, { cam, init() { V.glyphs(ID, [[F.heavy, T.tag3 + T.head + T.l1b + T.l2b + T.lb], [F.med, T.l1a + T.l2a], [F.bold, T.c10], [F.type, T.kick], [F.num, T.yr]]); } });
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex_vox/scenes/s05.js b/scripts/engine/reference_films/spacex/spacex_vox/scenes/s05.js
new file mode 100644
index 0000000..2a21c48
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_vox/scenes/s05.js
@@ -0,0 +1,108 @@
+// S05 · 一级飞回来:一张着陆场的网点照片上盖一层硫酸纸,红笔在纸上画「上去—掉头—回来」的回旋箭头,
+// 一枚小剪纸火箭沿线一顿一顿走一遍(解释);然后推近着陆圈:大剪纸一级拖着纸做的火焰竖着落下来,着陆腿张开、烟团冒出(全片第二个高光);
+// 「头一回」索引卡被红笔圈住;「2017」——同一枚一级沾着烟灰,再飞一次,冲出照片上沿。
+(() => {
+const ID = 's05', V = VOX, C = V.C, F = V.F, PH = V.PH, TAU = Math.PI * 2;
+const { clamp, lerp } = U, seg = MO.seg, step = V.step;
+const cell = V.cell(ID), X0 = cell.x, Y0 = cell.y, xy = (x, y) => ({ x: X0 + x, y: Y0 + y });
+const cue = k => TM.cue(ID, k), G = k => V.cue(ID, k), t0 = V.t0(ID);
+const T = { y15: '2015.12', first: '轨道火箭着陆', first2: '头一回', d15: '2015.12', y17: '2017', re: '复飞', up: '分离', back: '飞回来', f9: '猎鹰9号 · 一级' };
+
+// ---------- 着陆场照片+硫酸纸 ----------
+const PW = 1400, PHh = 820, PC = xy(1120, 1010);
+const zoneDraw = (g, w, h) => {
+ PH.sky(g, w, h, '#3a3a3a', '#d8d8d8');
+ const gy = h * 0.6; const gr = g.createLinearGradient(0, gy, 0, h); gr.addColorStop(0, '#7a7a7a'); gr.addColorStop(1, '#262626'); g.fillStyle = gr; g.fillRect(0, gy, w, h - gy);
+ g.fillStyle = '#5c5c5c'; g.fillRect(w * 0.06, gy - 120, 14, 120); g.fillRect(w * 0.06 + 40, gy - 90, 10, 90); // 远处的发射塔
+ PH.smoke(g, w * 0.2, gy + 6, 40, 5, 3, 'rgba(230,230,230,.6)');
+ g.strokeStyle = '#e4e4e4'; g.lineWidth = 9; g.beginPath(); g.ellipse(w * 0.77, h * 0.8, 170, 46, 0, 0, TAU); g.stroke(); // 着陆圈
+ g.lineWidth = 4; g.beginPath(); g.ellipse(w * 0.77, h * 0.8, 110, 29, 0, 0, TAU); g.stroke();
+};
+const PAD = [PW * 0.27, PHh * 0.3]; // 着陆圈中心(照片中心坐标)
+V.item({ key: 's05zone', ...PC, r: -0.012, z: 10, at: t0 - 1, draw(g) { V.blit(g, V.photo('s05zone', PW, PHh, zoneDraw, { cell: 7, border: 18 })); V.tape(g, -PW / 2 + 40, -PHh / 2 - 4, -0.5, 140); V.tape(g, PW / 2 - 40, -PHh / 2 - 4, 0.5, 140); } });
+// 硫酸纸:半透明,红笔回旋箭头+两处小字
+const TP = { w: 1200, h: 700 };
+const PATH = (() => { const L = [-PW * 0.36, PHh * 0.08], A = [-PW * 0.02, -PHh * 0.36], P = [PAD[0], PAD[1] - 30], o = [];
+ for (let i = 0; i <= 40; i++) { const u = i / 40, v = 1 - u; o.push([v * v * L[0] + 2 * v * u * (L[0] + 40) + u * u * A[0], v * v * L[1] + 2 * v * u * (-PHh * 0.42) + u * u * A[1]]); }
+ for (let i = 1; i <= 50; i++) { const u = i / 50, v = 1 - u; o.push([v * v * A[0] + 2 * v * u * (PAD[0] + 60) + u * u * P[0], v * v * A[1] + 2 * v * u * (-PHh * 0.42) + u * u * P[1]]); }
+ return o; })();
+const HP = V.handPts('s05path', PATH, { amp: 2.4, seed: 4 });
+const tDraw = [G('想把') - 0.05, G('重复') + 0.1];
+V.item({ key: 's05trace', ...PC, r: 0.008, z: 14, at: G('接着') - 0.1, enter: { from: [520, -60], tilt: 0.1, dur: 0.45 }, draw(g, T_) {
+ g.save(); g.translate(-TP.w / 2, -TP.h / 2 + 20); g.fillStyle = 'rgba(246,246,240,.38)'; CL.tornRect(g, TP.w, TP.h, 63, 4); g.fill(); g.strokeStyle = 'rgba(255,255,255,.5)'; g.lineWidth = 2; g.stroke(); g.restore();
+ V.tape(g, -TP.w / 2 + 20, -TP.h / 2 + 30, -0.6, 110); V.tape(g, TP.w / 2 - 20, -TP.h / 2 + 30, 0.6, 110);
+ const st = step(T_), q = MO.sineInOut(seg(st, tDraw[0], tDraw[1]));
+ g.save(); g.setLineDash([26, 18]); V.pen(g, HP, q, { lw: 9 }); g.restore();
+ if (q >= 1) { const n = HP.p[HP.p.length - 1], m = HP.p[HP.p.length - 6], a = Math.atan2(n[1] - m[1], n[0] - m[0]); g.save(); g.translate(n[0], n[1]); g.rotate(a); g.strokeStyle = C.red; g.lineWidth = 9; g.lineCap = 'round'; g.beginPath(); g.moveTo(-34, -22); g.lineTo(0, 0); g.lineTo(-34, 22); g.stroke(); g.restore(); }
+ const lab = (s, x, y, t) => { if (st < t) return; g.save(); g.translate(x, y); g.rotate(-0.03); g.fillStyle = C.card; g.font = V.font(44, F.heavy); const w = g.measureText(s).width + 36; g.fillRect(-w / 2, -34, w, 68); V.text(g, s, 0, 16, 44, F.heavy, C.ink, 'center'); g.restore(); };
+ lab(T.up, -PW * 0.02, -PHh * 0.36 - 64, tDraw[0] + 0.75); lab(T.back, PW * 0.19, -PHh * 0.47, G('飞回') + 0.05);
+} });
+// ---------- 剪纸一级 ----------
+const booster = (legs, soot) => V.cutout('s05b' + legs + soot, 96, 420, (g, w, h) => {
+ RK.at(g, w / 2, h - 34, 9.2, 0, q => V.shadeFill(q, RK.falcon9({ stage: 'booster', legs, fins: 1 }), { ...V.GREY, body: soot ? '#bdbdbd' : '#efefef' }));
+ if (soot) { g.save(); g.globalCompositeOperation = 'source-atop'; const gr = g.createLinearGradient(0, h, 0, h * 0.25); gr.addColorStop(0, 'rgba(30,30,30,.75)'); gr.addColorStop(1, 'rgba(30,30,30,0)'); g.fillStyle = gr; g.fillRect(0, 0, w, h); g.restore(); }
+}, { cell: 4, edge: 6 });
+// 纸火焰:荧光黄纸+红纸芯(12fps 两帧交替)
+const paperFlame = (g, x, y, len, w, st, k = 0) => {
+ const f = (Math.floor(st * 12) + k) % 2 ? 1 : 0.86;
+ g.save(); g.translate(x, y); g.shadowColor = 'rgba(50,40,25,.25)'; g.shadowBlur = 6; g.shadowOffsetY = 4;
+ const sh = (sc, col) => { g.fillStyle = col; g.beginPath(); g.moveTo(-w * sc / 2, 0); g.lineTo(-w * sc * 0.3, len * sc * f * 0.5); g.lineTo(-w * 0.08, len * sc * f * 0.8); g.lineTo(0, len * sc * f); g.lineTo(w * 0.1, len * sc * f * 0.78); g.lineTo(w * sc * 0.32, len * sc * f * 0.45); g.lineTo(w * sc / 2, 0); g.closePath(); g.fill(); };
+ sh(1, '#e9d84a'); g.shadowColor = 'transparent'; sh(0.55, C.red); g.restore();
+};
+// 小剪纸火箭沿回旋线走一遍(解释)
+const tok = [tDraw[0] + 0.1, tDraw[1] + 0.05];
+const along = (q) => { const L = HP.L[HP.L.length - 1], d = L * q, p = DG.pointAt(HP.p, HP.L, d), p2 = DG.pointAt(HP.p, HP.L, Math.min(L, d + 6)); return { p, a: Math.atan2(p2[1] - p[1], p2[0] - p[0]) }; };
+V.item({ key: 's05tok', ...PC, r: 0.008, z: 15, at: tok[0], until: G('2015') + 0.3, draw(g, T_) {
+ const st = step(T_), q = MO.sineInOut(seg(st, tok[0], tok[1])), { p, a } = along(q); if (q > 0.86) return; // 示意小火箭到着陆圈上方就收走:真正的竖直着陆只在推近镜头里演一次
+ const up = q < 0.45, rot = up ? a + Math.PI / 2 : a - Math.PI / 2; // 上升时头朝前;过了顶点翻过来尾朝前(掉头)
+ g.save(); g.translate(p[0], p[1]); g.rotate(rot); g.scale(0.6, 0.6); V.blit(g, booster(0, 0)); if (up) paperFlame(g, 0, 190, 120, 40, st); g.restore();
+} });
+// 大剪纸一级:竖着落回着陆圈
+const tLand = G('落回'), tDesc = G('2015') + 0.1, tLift = G('又一次') - 0.1;
+const LAND = [PC.x + PAD[0], PC.y + PAD[1] - 180];
+V.item({ key: 's05big', x: LAND[0], y: LAND[1], z: 16, rad: 1400, at: tDesc, draw(g, T_) {
+ const st = step(T_);
+ let y = 0, legs = 0, soot = st >= G('2017') ? 1 : 0, fl = 0;
+ if (st < tLand) { const q = clamp((st - tDesc) / (tLand - tDesc)); y = -900 * Math.pow(1 - q, 1.6); legs = clamp((st - (tLand - 0.6)) / 0.35); fl = 1; }
+ else if (st < tLift) { y = MO.settle(st - tLand, 6, 3, 7); legs = 1; }
+ else { const q = (st - tLift); y = -Math.pow(q, 2) * 520 - q * 60; legs = clamp(1 - q / 0.35); fl = 2; }
+ g.save(); g.translate(0, y);
+ if (fl) { const qd = fl === 1 ? clamp((st - tDesc) / (tLand - tDesc)) : 0; paperFlame(g, 0, 196, fl === 2 ? 260 : 150 * (1 - 0.7 * qd * qd), fl === 2 ? 70 : 44, st); }
+ V.blit(g, booster(legs > 0.5 ? 1 : 0, soot)); g.restore();
+ // 着陆烟团(网点剪纸,一拍二胀开)
+ const pq = clamp((st - tLand) / 0.5), pq2 = st >= tLift ? clamp((st - tLift) / 0.5) : 0, pv = Math.max(pq * (1 - clamp((st - tLand - 1.6) / 0.6)), pq2);
+ if (pv > 0) { const sp = V.cutout('s05puff', 520, 190, (q) => { PH.smoke(q, 260, 110, 120, 12, 9, '#dcdcdc'); PH.smoke(q, 250, 90, 80, 8, 19, '#f6f6f6'); }, { cell: 4, edge: 0, contrast: 1.1 }); g.save(); g.translate(0, 205); const s = 0.4 + 0.6 * MO.quartOut(pv); g.scale(s, s); g.globalAlpha = Math.min(1, pv * 1.4); V.blit(g, sp); g.restore(); }
+} });
+// 标签与索引卡
+V.item({ key: 's05y15', ...xy(600, 690), r: -0.03, z: 17, at: G('2015') - 0.05, until: G('2017') - 0.05, enter: { from: [-300, -80], tilt: -0.16, dur: 0.4 }, draw(g, T_) { V.label(g, T.y15, 76, { fam: F.num, n: V.nTyped(T_, G('2015'), 12) }); } });
+V.item({ key: 's05f9', ...xy(1820, 1080), r: 0.03, z: 17, at: G('猎鹰') - 0.1, enter: { drop: 0.25, dur: 0.25 }, draw(g, T_) { V.label(g, T.f9, 46, { n: V.nTyped(T_, G('猎鹰'), 14) }); } });
+const FC = V.circle('s05first', 150, 62, 21);
+V.item({ key: 's05card', ...xy(1560, 1365), r: -0.035, z: 18, at: G('轨道火箭') - 0.15, enter: { from: [300, 300], tilt: 0.14, dur: 0.4 }, draw(g, T_) {
+ V.blit(g, V.spr('s05card', 560, 230, (gg, w, h) => V.indexCard(gg, w, h, { top: 50, gap: 46 })));
+ const st = step(T_), n = V.nTyped(T_, G('轨道火箭'), 14);
+ V.typed(g, T.first, -240, -12, n, 56, F.heavy, C.ink); V.typed(g, T.first2, -240 + 250, 70, n - 6, 72, F.heavy, C.red); if (n > 0) V.text(g, T.d15, 250, -80, 26, F.type, C.ink2, 'right');
+ g.save(); g.translate(-240 + 250 + 108, 46); V.pen(g, FC, MO.cubicOut(seg(st, G('头一回') + 0.1, G('头一回') + 0.6)), { lw: 7 }); g.restore();
+} });
+const SAME = V.handPts('s05same', [[-250, -40], [-150, 10], [-60, 60]], { amp: 1.4, seed: 2 });
+V.item({ key: 's05same', x: LAND[0], y: LAND[1], z: 20, rad: 900, at: G('回收') - 0.05, until: G('飞上') + 0.4, draw(g, T_) { // 「回收的一级」:红笔箭头指着这枚刚落回来的一级——就是同一枚
+ const st = step(T_); g.save(); g.translate(-60, -40); V.pen(g, SAME, MO.cubicOut(seg(st, G('回收'), G('回收') + 0.35)), { lw: 8 }); g.restore();
+ g.save(); g.translate(-420, -110); g.rotate(-0.05); V.label(g, '同一枚一级', 50, { bg: C.red2, n: V.nTyped(T_, G('回收'), 12) }); g.restore();
+} });
+V.item({ key: 's05y17', ...xy(560, 700), r: 0.025, z: 19, at: G('2017') - 0.05, enter: { drop: 0.3, dur: 0.25 }, draw(g, T_) { g.save(); V.label(g, T.y17, 80, { fam: F.num, n: V.nTyped(T_, G('2017'), 12) }); g.translate(230, 20); g.rotate(0.05); V.label(g, T.re, 60, { bg: C.red2, n: V.nTyped(T_, G('回收'), 8) }); g.restore(); } });
+
+// ---------- 相机:硬切进来(全景)→ 推近着陆圈 → 拉开 → 跟着复飞往上 ----------
+const at = (x, y, z, sy) => V.at(X0 + x, Y0 + y, z, sy);
+const LX = LAND[0] - X0, LY = LAND[1] - Y0;
+const cam = (lt) => CAM.at([
+ V.key(0, at(1130, 940, 1.0)),
+ V.key(cue('2015') - 0.1, at(1110, 930, 1.04), MO.sineInOut),
+ V.key(cue('猎鹰') + 0.1, at(LX - 40, LY + 40, 1.55), MO.sineInOut), // 推近着陆圈
+ V.key(cue('落回') + 0.2, at(LX - 30, LY + 60, 1.68), MO.sineInOut),
+ V.key(cue('轨道火箭') + 0.1, at(LX - 120, LY + 160, 1.2), MO.cubicInOut),
+ V.key(cue('2017') - 0.1, at(LX - 140, LY + 150, 1.24), MO.sineInOut),
+ V.key(cue('2017') + 0.5, at(LX - 360, LY - 16, 0.92), MO.cubicInOut),
+ V.key(cue('飞上'), at(LX - 330, LY - 40, 0.95), MO.sineInOut),
+ V.key(TM.dur(ID), at(LX - 260, LY - 380, 1.0), MO.cubicIn),
+], lt);
+V.scene(ID, { cam, init() { V.glyphs(ID, [[F.heavy, '同一枚一级' + T.first + T.first2 + T.re + T.up + T.back + T.f9], [F.num, T.y15 + T.y17], [F.type, T.d15]]); } });
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex_vox/scenes/s06.js b/scripts/engine/reference_films/spacex/spacex_vox/scenes/s06.js
new file mode 100644
index 0000000..785b2fb
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_vox/scenes/s06.js
@@ -0,0 +1,84 @@
+// S06 · 2018 重型猎鹰(快档:三张卡、两次快移)。
+// ①硬切进一张竖幅网点照片:三芯并联的重型猎鹰升空,黑标签「2018 · 重型猎鹰首飞」打字;
+// ②一张黑卡纸上的轨道图:纸太阳、地球轨道(白铅笔)、红笔画出跑车的椭圆轨道,剪纸小跑车一顿一顿沿红线走;
+// ③两张并排的照片(双联):两枚剪纸助推器同一拍落下、同一拍冒烟——「并排落回」。
+(() => {
+const ID = 's06', V = VOX, C = V.C, F = V.F, PH = V.PH, TAU = Math.PI * 2;
+const { clamp, lerp } = U, seg = MO.seg, step = V.step;
+const cell = V.cell(ID), X0 = cell.x, Y0 = cell.y, xy = (x, y) => ({ x: X0 + x, y: Y0 + y });
+const cue = k => TM.cue(ID, k), G = k => V.cue(ID, k), t0 = V.t0(ID);
+const T = { lab: '2018 · 重型猎鹰首飞', sun: '太阳', earth: '地球轨道', orbit: '绕太阳的轨道', car: '跑车', pair: '两枚助推器 · 并排落回' };
+
+// ① 重型猎鹰升空照片
+const fhDraw = (g, w, h) => {
+ PH.sky(g, w, h, '#262626', '#b8b8b8');
+ PH.smoke(g, w * 0.5, h * 1.0, 170, 18, 5, '#f2f2f2', 1.6);
+ PH.plume(g, [[w * 0.5, h * 1.02], [w * 0.5, h * 0.62]], 50, 90, 7, '#ececec');
+ PH.glow(g, w * 0.5, h * 0.74, 170, 0.95);
+ for (const dx of [-1, 0, 1]) PH.flame(g, w * 0.5 + dx * 18, h * 0.7, 200, 34);
+ PH.rocket(g, RK.heavy({ payload: 'fairing' }), w * 0.5, h * 0.7, h / 125);
+};
+const FH = xy(2070, 880), FW = 560, FHh = 760;
+V.item({ key: 's06fh', ...FH, r: 0.02, z: 10, at: t0 - 1, draw(g) { V.blit(g, V.photo('s06fh', FW, FHh, fhDraw, { cell: 6, border: 16 })); V.tape(g, 0, -FHh / 2 - 8, 0.03, 160); } });
+V.item({ key: 's06lab', ...xy(2075, 1190), r: -0.025, z: 12, at: G('2018') - 0.05, enter: { drop: 0.25, dur: 0.25 }, draw(g, T_) { V.label(g, T.lab, 46, { n: V.nTyped(T_, G('2018'), 11) }); } });
+
+// ② 黑卡纸轨道图
+const BW = 980, BH = 640, B = xy(1010, 840), SUN = [-60, 20], ORX = 330, ORY = 200;
+const ORB = (() => { const o = []; for (let i = 0; i <= 80; i++) { const a = -2.2 + i / 80 * TAU * 0.98; o.push([SUN[0] + 60 + Math.cos(a) * ORX * 1.18, SUN[1] + Math.sin(a) * ORY * 1.25]); } return V.handPts('s06orb', o, { amp: 1.5, seed: 8 }); })();
+const EARTH = V.handPts('s06earth', DG.ellipsePts(SUN[0], SUN[1], ORX * 0.82, ORY * 0.82, -1, 1.02, 64), { amp: 1.2, seed: 3 });
+const sun = () => V.cutout('s06sun', 220, 220, (g, w, h) => { const r = g.createRadialGradient(w / 2, h / 2, 10, w / 2, h / 2, w / 2); r.addColorStop(0, '#fafafa'); r.addColorStop(1, '#9a9a9a'); g.fillStyle = r; g.beginPath(); g.arc(w / 2, h / 2, w / 2, 0, TAU); g.fill(); }, { cell: 5, edge: 6 });
+const car = () => V.cutout('s06car', 150, 70, (g, w, h) => {
+ // 敞篷跑车(侧面,没有车顶),驾驶座上坐着一个白色宇航服小人(头盔面罩不透明)
+ g.fillStyle = '#efefef'; g.beginPath(); g.ellipse(70, 22, 12, 13, 0, 0, Math.PI * 2); g.fill(); g.fillRect(60, 30, 20, 22); // 宇航服小人
+ g.fillStyle = '#1b1b1a'; g.beginPath(); g.ellipse(74, 22, 8, 7, 0, 0, Math.PI * 2); g.fill(); // 面罩
+ g.fillStyle = C.red2; g.beginPath(); g.moveTo(4, 56); g.lineTo(10, 42); g.lineTo(44, 38); g.lineTo(58, 40); g.lineTo(86, 40); g.lineTo(104, 36); g.lineTo(140, 40); g.lineTo(146, 52); g.lineTo(140, 58); g.lineTo(8, 58); g.closePath(); g.fill();
+ g.strokeStyle = 'rgba(255,255,255,.6)'; g.lineWidth = 3; g.beginPath(); g.moveTo(92, 40); g.lineTo(100, 26); g.stroke(); // 挡风玻璃框
+ g.fillStyle = '#1b1b1a'; for (const x of [32, 118]) { g.beginPath(); g.arc(x, 58, 11, 0, Math.PI * 2); g.fill(); }
+}, { ht: false, edge: 5 });
+const tOrb = [G('绕太阳') - 0.1, G('轨道') + 0.15], tCar = [tOrb[0] + 0.25, G('两枚') + 0.2];
+V.item({ key: 's06card', ...B, r: -0.015, z: 11, at: t0 - 1, draw(g, T_) {
+ V.blit(g, V.spr('s06bk', BW, BH, (gg, w, h) => V.blackCard(gg, w, h, 91), { sh: { blur: 8, y: 5 } }));
+ const st = step(T_);
+ g.save(); g.setLineDash([10, 12]); V.pen(g, EARTH, 1, { col: 'rgba(238,237,235,.55)', lw: 3 }); g.restore();
+ V.text(g, T.earth, SUN[0] - ORX * 0.6, SUN[1] + ORY * 0.82 + 52, 30, F.bold, 'rgba(238,237,235,.7)');
+ V.blit(g, sun(), SUN[0], SUN[1]); V.text(g, T.sun, SUN[0], SUN[1] + 146, 34, F.heavy, C.paper, 'center');
+ V.pen(g, ORB, MO.sineInOut(seg(st, tOrb[0], tOrb[1])), { lw: 7 });
+ const q = seg(st, tCar[0], tCar[1]);
+ if (st >= G('跑车') - 0.1) { const L = ORB.L[ORB.L.length - 1], d = L * (0.02 + 0.5 * q), p = DG.pointAt(ORB.p, ORB.L, d), p2 = DG.pointAt(ORB.p, ORB.L, d + 8);
+ g.save(); g.translate(p[0], p[1]); g.rotate(Math.atan2(p[1] - SUN[1], p[0] - SUN[0] - 60) + Math.PI / 2); V.blit(g, car(), 0, -30); g.restore(); }
+ if (st >= G('绕太阳')) { g.save(); g.translate(BW / 2 - 320, -BH / 2 + 76); V.typed(g, T.orbit, 0, 0, V.nTyped(T_, G('绕太阳'), 12), 46, F.heavy, C.paper); g.restore(); }
+} });
+
+// ③ 双联照片:两枚助推器同一拍落下
+const DW = 400, DHh = 330, D = xy(820, 1460), gapX = 222;
+const padDraw = (k) => (g, w, h) => { PH.sky(g, w, h, '#7a7a7a', '#d0d0d0'); const gy = h * 0.74; g.fillStyle = '#5a5a5a'; g.fillRect(0, gy, w, h - gy); g.strokeStyle = '#e6e6e6'; g.lineWidth = 6; g.beginPath(); g.ellipse(w * 0.5, h * 0.86, 120, 22, 0, 0, TAU); g.stroke(); };
+const boost = () => V.cutout('s06b', 50, 220, (g, w, h) => RK.at(g, w / 2, h - 20, 4.8, 0, q => V.shadeFill(q, RK.falcon9({ stage: 'booster', legs: 1, fins: 1 }), V.GREY)), { cell: 3, edge: 4 });
+const cone = () => V.cutout('s06bc', 50, 40, (g, w, h) => { g.fillStyle = '#e8e8e8'; g.beginPath(); g.moveTo(5, h); g.quadraticCurveTo(w / 2, -h * 0.6, w - 5, h); g.closePath(); g.fill(); }, { cell: 3, edge: 4 });
+const tL = G('落回'), tD = G('两枚') - 0.1;
+V.item({ key: 's06dip', ...D, r: 0.01, z: 11, at: t0 - 1, draw(g, T_) {
+ const st = step(T_);
+ for (const s of [-1, 1]) {
+ g.save(); g.translate(s * gapX, s * 6); g.rotate(s * 0.02); V.blit(g, V.photo('s06pad' + s, DW, DHh, padDraw(s), { cell: 5, border: 12 }));
+ g.save(); g.beginPath(); g.rect(-DW / 2, -DHh / 2, DW, DHh); g.clip();
+ const q = clamp((st - tD) / (tL - tD)), y = st < tL ? -360 * Math.pow(1 - q, 1.7) : MO.settle(st - tL, 3, 3, 7);
+ g.translate(0, DHh * 0.36 - 110 + y); V.blit(g, boost()); g.save(); g.translate(0, -132); V.blit(g, cone()); g.restore();
+ if (st < tL) { g.fillStyle = '#e9d84a'; g.beginPath(); g.moveTo(-10, 112); g.lineTo(0, 112 + 60 * (1 - q * 0.6)); g.lineTo(10, 112); g.fill(); }
+ else { const pv = clamp((st - tL) / 0.4); g.globalAlpha = 0.9; PH.smoke(g, 0, 118, 26 + 30 * pv, 6, 3, '#f0f0f0'); }
+ g.restore(); g.restore();
+ }
+ g.save(); g.translate(0, -DHh / 2 - 66); g.rotate(-0.02); V.label(g, T.pair, 50, { n: V.nTyped(T_, G('两枚'), 14) }); g.restore();
+} });
+
+// ---------- 相机:硬切进来 → 快移到黑卡 → 快移到双联 → 往左起步 ----------
+const at = (x, y, z, sy) => V.at(X0 + x, Y0 + y, z, sy);
+const cam = (lt) => CAM.at([
+ V.key(0, at(2050, 920, 1.0)),
+ V.key(cue('跑车') - 0.45, at(2040, 930, 1.07), MO.sineInOut),
+ V.key(cue('跑车') + 0.05, at(980, 860, 1.18), MO.cubicInOut),
+ V.key(cue('两枚') - 0.15, at(990, 860, 1.24), MO.sineInOut),
+ V.key(cue('两枚') + 0.35, at(820, 1390, 1.42), MO.cubicInOut),
+ V.key(TM.dur(ID) - 0.3, at(820, 1400, 1.5), MO.sineInOut),
+ V.key(TM.dur(ID), at(700, 1380, 1.42), MO.cubicIn),
+], lt);
+V.scene(ID, { cam, init() { V.glyphs(ID, [[F.heavy, T.lab + T.sun + T.orbit + T.pair], [F.bold, T.earth]]); } });
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex_vox/scenes/s07.js b/scripts/engine/reference_films/spacex/spacex_vox/scenes/s07.js
new file mode 100644
index 0000000..a770a78
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_vox/scenes/s07.js
@@ -0,0 +1,92 @@
+// S07 · 2020.5 载人龙飞船:竖幅网点照片(猎鹰9号顶着载人龙升空)+两个剪纸宇航员(面罩不透明,没有脸)滑进来;
+// 「时隔近9年」:桌上一把纸尺子,2011 到 2020,红笔把中间那段空白排线涂满、括号标「近9年」(Vox 地图色块生长的翻译);
+// 「第一次……私人公司的飞船」:剪报,红圈圈「第一次」,荧光笔跟读「私人公司的飞船」。
+(() => {
+const ID = 's07', V = VOX, C = V.C, F = V.F, PH = V.PH, TAU = Math.PI * 2;
+const { clamp, lerp } = U, seg = MO.seg, step = V.step;
+const cell = V.cell(ID), X0 = cell.x, Y0 = cell.y, xy = (x, y) => ({ x: X0 + x, y: Y0 + y });
+const cue = k => TM.cue(ID, k), G = k => V.cue(ID, k), t0 = V.t0(ID);
+const T = { lab: '2020.5', crew: '两名宇航员', gap: '近9年', y11: '航天飞机退役', y20: '载人龙飞船', h0: '第一次,', h1: '由私人公司的飞船', h2: '把人送进轨道', kick: '2020.5' };
+
+// 照片:猎鹰9号+载人龙升空(夜里)
+const crewDraw = (g, w, h) => {
+ PH.sky(g, w, h, '#141414', '#5a5a5a');
+ PH.smoke(g, w * 0.5, h * 1.02, 150, 16, 9, '#e8e8e8', 1.5);
+ PH.plume(g, [[w * 0.5, h * 1.02], [w * 0.5, h * 0.72]], 30, 60, 3, '#e2e2e2');
+ PH.glow(g, w * 0.5, h * 0.68, 150, 1);
+ PH.flame(g, w * 0.5, h * 0.66, 170, 34);
+ PH.rocket(g, RK.falcon9({ payload: 'dragon' }), w * 0.5, h * 0.66, h / 125);
+};
+const P = xy(1880, 840), PW = 500, PHh = 700;
+V.item({ key: 's07ph', ...P, r: 0.025, z: 10, at: t0 - 1, draw(g) { V.blit(g, V.photo('s07crew', PW, PHh, crewDraw, { cell: 6, border: 15 })); V.tape(g, -PW / 2 + 30, -PHh / 2 - 6, -0.55, 120); V.tape(g, PW / 2 - 30, -PHh / 2 - 6, 0.5, 120); } });
+V.item({ key: 's07lab', ...xy(1760, 1140), r: -0.02, z: 12, at: G('2020') - 0.05, enter: { drop: 0.25, dur: 0.25 }, draw(g, T_) { V.label(g, T.lab, 78, { fam: F.num, n: V.nTyped(T_, G('2020'), 10) }); } });
+// 剪纸载人龙飞船(胶囊+尾段),念到「载人龙飞船」滑进来、红笔圈住
+const capsule = () => V.cutout('s07cap', 200, 300, (g, w, h) => RK.at(g, w / 2, h - 6, 41, 0, q => V.shadeFill(q, RK.dragon({ trunk: true }), { ...V.GREY, window: '#d8d8d8', trunk: '#9a9a9a', nose: '#cfcfcf' })), { cell: 4, edge: 7 }); // 截锥舱体+圆柱尾段(不画舷窗,免得读成一张脸)
+const CC = V.circle('s07cap', 150, 190, 5);
+V.item({ key: 's07cap', ...xy(1120, 930), r: 0.04, z: 12, at: G('载人') - 0.25, enter: { from: [-420, -160], tilt: 0.2, dur: 0.45 }, draw(g, T_) {
+ V.blit(g, capsule()); g.save(); g.translate(0, 10); V.pen(g, CC, MO.cubicOut(seg(step(T_), G('龙飞船'), G('龙飞船') + 0.55)), { lw: 8 }); g.restore();
+ g.save(); g.translate(0, 230); g.rotate(-0.02); V.label(g, T.y20, 46, { n: V.nTyped(T_, G('载人'), 12) }); g.restore();
+} });
+// 剪纸宇航员:白色宇航服+不透明黑面罩(没有五官)
+const astro = (k) => V.cutout('s07astro' + k, 170, 380, (g, w, h) => {
+ g.fillStyle = '#ececec';
+ g.beginPath(); g.ellipse(w / 2, 62, 58, 62, 0, 0, TAU); g.fill(); // 头盔
+ g.beginPath(); g.roundRect(w / 2 - 70, 112, 140, 150, 34); g.fill(); // 躯干
+ g.beginPath(); g.roundRect(w / 2 - 92, 126, 34, 120, 16); g.roundRect(w / 2 + 58, 126, 34, 120, 16); g.fill(); // 手臂
+ g.beginPath(); g.roundRect(w / 2 - 60, 250, 54, 126, 18); g.roundRect(w / 2 + 6, 250, 54, 126, 18); g.fill(); // 腿
+ g.fillStyle = '#9a9a9a'; g.fillRect(w / 2 - 70, 200, 140, 14); g.fillRect(w / 2 - 60, 340, 120, 10);
+ g.fillStyle = '#1a1a1a'; g.beginPath(); g.ellipse(w / 2 + (k ? 6 : -6), 66, 40, 34, 0, 0, TAU); g.fill(); // 面罩
+ g.fillStyle = 'rgba(255,255,255,.5)'; g.beginPath(); g.ellipse(w / 2 + (k ? -8 : -20), 52, 10, 6, -0.5, 0, TAU); g.fill();
+}, { cell: 4, edge: 7 });
+V.item({ key: 's07a', ...xy(1410, 900), r: -0.03, z: 12, at: G('两名') - 0.12, enter: { from: [-380, 120], tilt: -0.2, dur: 0.45 }, draw(g, T_) {
+ V.blit(g, astro(0), -90, 0); V.blit(g, astro(1), 90, 10);
+ g.save(); g.translate(0, -250); g.rotate(0.02); g.fillStyle = C.paper; g.fillRect(-150, -36, 300, 72); V.typed(g, T.crew, -122, 18, V.nTyped(T_, G('两名'), 12), 50, F.heavy, C.ink); g.restore();
+} });
+// 纸尺:2011 → 2020,空白处红笔排线
+const R = xy(900, 1440), RW = 1360, RH = 130, yx = y => -RW / 2 + 90 + (y - 2011) * (RW - 180) / 9;
+const ruler = () => V.spr('s07ruler', RW, RH, (g, w, h) => {
+ V.paper(g, w, h, 37, { col: '#ece3c8', torn: false, age: 0.2 });
+ g.fillStyle = C.ink; for (let y = 2011; y <= 2020; y++) { const x = w / 2 + yx(y); g.fillRect(x - 1.5, h - 46, 3, 46); V.text(g, String(y), x, 44, 32, F.type, C.ink, 'center'); for (let m = 1; m < 4 && y < 2020; m++) g.fillRect(x + m * (w - 180) / 36 - 1, h - 22, 2, 22); }
+});
+const HATCH = (() => { const a = yx(2011.55), b = yx(2020.4), o = []; for (let x = a, k = 0; x < b; x += 26, k++) o.push(V.handPts('s07h' + k, [[x, 58], [x + 30, 124]], { amp: 1, seed: k, per: 6 })); return o; })();
+const BR = V.handPts('s07br', [[yx(2011.55), 6], [yx(2011.55), -24], [yx(2020.4), -24], [yx(2020.4), 6]], { amp: 1.4, seed: 2 });
+const tH = [G('时隔') - 0.05, G('近9') + 0.3];
+V.item({ key: 's07ruler', ...R, r: -0.012, z: 11, at: G('美国') - 0.2, enter: { from: [0, 340], tilt: -0.06, dur: 0.4 }, draw(g, T_) {
+ V.blit(g, ruler()); const st = step(T_), q = seg(st, tH[0], tH[1]);
+ g.save(); g.translate(0, -RH / 2); HATCH.forEach((H, k) => VOX.pen(g, H, clamp(q * HATCH.length - k), { lw: 6, col: C.red })); g.restore();
+ g.save(); g.translate(0, -RH / 2 - 36); V.pen(g, BR, MO.cubicOut(seg(st, G('近9') - 0.1, G('近9') + 0.35)), { lw: 6 });
+ if (st >= G('近9') + 0.05) { g.translate((yx(2011.55) + yx(2020.4)) / 2, -70); g.rotate(-0.02); V.label(g, T.gap, 74, { bg: C.red2, padX: 30 }); } g.restore();
+ // 两头的小字:2011 航天飞机退役 / 2020 载人龙飞船
+ if (st >= tH[0]) { V.text(g, T.y11, yx(2011), RH / 2 + 52, 34, F.bold, C.ink2, 'center'); }
+ if (st >= G('重新')) { V.text(g, T.y20, yx(2020), RH / 2 + 52, 34, F.bold, C.red, 'center'); V.pin(g, yx(2020), -RH / 2 + 6); }
+} });
+// 剪报:第一次 / 私人公司的飞船
+const NW = 1000, NH = 400, N = xy(600, 640);
+const news = () => V.spr('s07news', NW, NH, (g, w, h) => {
+ V.paper(g, w, h, 43, { amp: 5 }); V.text(g, T.kick, 56, 70, 34, F.type, C.ink2); g.fillStyle = C.ink; g.fillRect(56, 88, w - 112, 3); g.fillRect(56, 96, w - 112, 1);
+ V.serifBold(g, T.h0 + T.h1, 56, 190, 70); V.serifBold(g, T.h2, 56, 282, 70);
+ g.fillStyle = 'rgba(40,36,30,.26)'; [700, 660].forEach((ww, i) => g.fillRect(56, 320 + i * 26, ww, 10));
+});
+const SP = (() => { const g = PAINT.scratch('vxmeasure').getContext('2d'); return [V.span(g, T.h0 + T.h1, '第一次', 56, 70, F.serif), V.span(g, T.h0 + T.h1, '私人公司的飞船', 56, 70, F.serif)]; })();
+const NC = V.circle('s07first', 128, 56, 31);
+V.item({ key: 's07news', ...N, r: 0.018, z: 12, at: G('也是') - 0.45, enter: { from: [-520, -120], tilt: -0.14, dur: 0.4 }, draw(g, T_) {
+ V.blit(g, news()); g.save(); g.translate(-NW / 2, -NH / 2); const st = step(T_);
+ V.hl(g, SP[1].x - 6, 128, SP[1].w + 12, 80, MO.sineInOut(seg(st, G('私人'), t0 + V.cueN(ID, '飞船', 1) + 0.25)));
+ g.translate(SP[0].x + SP[0].w / 2, 164); V.pen(g, NC, MO.cubicOut(seg(st, G('第一次'), G('第一次') + 0.55)), { lw: 7 }); g.restore();
+} });
+
+// ---------- 相机 ----------
+const at = (x, y, z, sy) => V.at(X0 + x, Y0 + y, z, sy);
+const cam = (lt) => CAM.at([
+ V.key(0, at(1630, 855, 1.04)), // 进场:上一镜像一张纸被抽走(vox_pull)
+ V.key(0.85, at(1640, 860, 1.06), MO.sineInOut),
+ V.key(cue('美国') - 0.2, at(1600, 870, 1.12), MO.sineInOut),
+ V.key(cue('时隔') + 0.15, at(1000, 1300, 1.06), MO.cubicInOut),
+ V.key(cue('也是') - 0.15, at(990, 1310, 1.1), MO.sineInOut),
+ V.key(cue('第一次') + 0.05, at(470, 600, 1.2), MO.cubicInOut),
+ V.key(TM.dur(ID) - 0.4, at(470, 605, 1.24), MO.sineInOut),
+ V.key(TM.dur(ID), at(380, 620, 1.22), MO.cubicIn),
+], lt);
+ERAS.find(e => e.id === ID).transition = { type: 'vox_pull', dur: 0.5, punch: 0 };
+V.scene(ID, { cam, init() { V.glyphs(ID, [[F.num, T.lab], [F.heavy, T.crew + T.gap], [F.bold, T.y11 + T.y20], [F.type, '20112020.5'], [F.serif, T.h0 + T.h1 + T.h2]]); } });
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex_vox/scenes/s08.js b/scripts/engine/reference_films/spacex/spacex_vox/scenes/s08.js
new file mode 100644
index 0000000..2a5fff5
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_vox/scenes/s08.js
@@ -0,0 +1,98 @@
+// S08 · 发射越来越密(快档:四张卡,一张一个点子)。
+// ①坐标纸上用撕下的纸条贴出柱状图(猎鹰火箭年发射次数:2017、2022–2025,只画有权威出处的年份),2025 那根是红纸,长到 165 落定;
+// ②一页月历,红笔每隔两天多划一道——「平均两天多一发」;③剪纸天平往「猎鹰9号」那边沉下去——「比其他火箭加起来还多」;
+// ④一枚沾烟灰的剪纸助推器躺在索引卡上,红笔一道道划记,37 道写满。
+(() => {
+const ID = 's08', V = VOX, C = V.C, F = V.F, PH = V.PH, TAU = Math.PI * 2;
+const { clamp, lerp } = U, seg = MO.seg, step = V.step;
+const cell = V.cell(ID), X0 = cell.x, Y0 = cell.y, xy = (x, y) => ({ x: X0 + x, y: Y0 + y });
+const cue = k => TM.cue(ID, k), G = k => V.cue(ID, k), t0 = V.t0(ID);
+const T = { title: '猎鹰系列火箭年发射次数', unit: '次', src: '来源:SpaceNews、CBS、CNBC、Ars Technica', avg: '≈2.2天一发', month: '一个月', l: '猎鹰9号', r: '全世界其他公司', one: '一枚助推器', n37: '37次' };
+const DATA = [['2017', 18], ['2022', 61], ['2023', 96], ['2024', 134], ['2025', 165]];
+
+// ① 坐标纸柱状图
+const CW = 1240, CH = 800, CP = xy(1480, 860), BASE = 300, KH = 3.25, BW = 140, bx = i => -CW / 2 + 190 + i * 205 + (i > 0 ? 40 : 0);
+const graph = () => V.spr('s08graph', CW, CH, (g, w, h) => {
+ g.fillStyle = '#f3f1e8'; g.fillRect(0, 0, w, h);
+ g.strokeStyle = 'rgba(80,140,200,.22)'; g.lineWidth = 1; for (let x = 0; x < w; x += 20) { g.beginPath(); g.moveTo(x, 0); g.lineTo(x, h); g.stroke(); } for (let y = 0; y < h; y += 20) { g.beginPath(); g.moveTo(0, y); g.lineTo(w, y); g.stroke(); }
+ g.strokeStyle = 'rgba(80,140,200,.4)'; g.lineWidth = 1.6; for (let x = 0; x < w; x += 100) { g.beginPath(); g.moveTo(x, 0); g.lineTo(x, h); g.stroke(); } for (let y = 0; y < h; y += 100) { g.beginPath(); g.moveTo(0, y); g.lineTo(w, y); g.stroke(); }
+ V.text(g, T.title, 60, 84, 54, F.heavy, C.ink); V.text(g, T.src, 62, 122, 22, F.med, C.ink2);
+ g.strokeStyle = C.ink; g.lineWidth = 5; g.lineCap = 'round'; g.beginPath(); g.moveTo(70, h / 2 + BASE); g.lineTo(w - 50, h / 2 + BASE); g.stroke();
+ DATA.forEach(([y], i) => V.text(g, y, w / 2 + bx(i), h / 2 + BASE + 54, 40, F.type, i === 4 ? C.red : C.ink, 'center'));
+ const zx = w / 2 + (bx(0) + bx(1)) / 2; g.lineWidth = 4; g.beginPath(); g.moveTo(zx - 16, h / 2 + BASE - 14); g.lineTo(zx - 4, h / 2 + BASE + 14); g.moveTo(zx + 4, h / 2 + BASE - 14); g.lineTo(zx + 16, h / 2 + BASE + 14); g.stroke(); // 年份不连续的断开记号
+});
+const strip = (key, hgt, col) => V.spr('s08bar' + key, BW, hgt, (g, w, h) => V.paper(g, w, h, 50 + hgt % 13, { col, amp: 3, age: 0.1 }), { pad: 16, sh: { blur: 6, x: 2, y: 4 } });
+const tBar = [G('回收') + 0.05, G('越来越密') + 0.2], t165 = [G('2025') + 0.1, G('165') + 0.2];
+V.item({ key: 's08chart', ...CP, r: -0.01, z: 10, at: t0 - 1, draw(g, T_) {
+ V.blit(g, graph()); const st = step(T_);
+ DATA.forEach(([y, v], i) => {
+ const q = i < 4 ? MO.quartOut(seg(st, tBar[0] + i * 0.3, tBar[0] + i * 0.3 + 0.7)) : MO.cubicOut(seg(st, t165[0], t165[1])); if (q <= 0) return;
+ const hh = v * KH, sp = strip(i, Math.round(hh), i === 4 ? '#c0574f' : '#2a2928'), vis = hh * q;
+ g.save(); g.beginPath(); g.rect(bx(i) - BW, BASE - vis - 30, BW * 2, vis + 30); g.clip(); V.blit(g, sp, bx(i), BASE - hh / 2); g.restore();
+ const shown = i < 4 ? (q >= 1 ? v : 0) : Math.round(v * q);
+ if (shown) V.text(g, String(shown), bx(i), BASE - vis - 22, i === 4 ? 86 : 50, F.num, i === 4 ? C.red : C.ink, 'center');
+ });
+ if (st >= G('165') + 0.3) V.text(g, '全为猎鹰9号', bx(4), BASE + 100, 26, F.bold, C.red, 'center');
+ const hq = MO.sineInOut(seg(st, G('165'), G('165') + 0.6)); if (hq > 0) { g.save(); g.translate(bx(4), BASE - 165 * KH - 22); V.hl(g, -96, -80, 192, 84, hq); g.restore(); }
+} });
+// ② 月历:每 2.2 天一道红划
+const MW = 520, MH = 560, MP = xy(560, 760);
+const DAYS = (() => { const o = []; for (let k = 0; k * 365 / 165 < 30; k++) o.push(Math.round(k * 365 / 165)); return o; })();
+const SL = DAYS.map((d, k) => V.handPts('s08sl' + k, [[-26, 18], [26, -18]], { amp: 1.4, seed: k + 3, per: 5 }));
+const month = () => V.spr('s08month', MW, MH, (g, w, h) => {
+ V.paper(g, w, h, 61, { col: '#f4f2ec', torn: false, age: 0.1 }); g.fillStyle = C.black; g.fillRect(0, 0, w, 70);
+ V.text(g, T.month, 30, 50, 40, F.heavy, C.paper);
+ g.strokeStyle = 'rgba(40,36,30,.35)'; g.lineWidth = 1.5; for (let i = 0; i <= 7; i++) { g.beginPath(); g.moveTo(20 + i * 68, 100); g.lineTo(20 + i * 68, h - 30); g.stroke(); } for (let j = 0; j <= 5; j++) { g.beginPath(); g.moveTo(20, 100 + j * 86); g.lineTo(w - 24, 100 + j * 86); g.stroke(); }
+ for (let d = 0; d < 30; d++) V.text(g, String(d + 1), 20 + (d % 7) * 68 + 8, 100 + Math.floor(d / 7) * 86 + 28, 24, F.type, C.ink2);
+});
+const tCal = [G('平均') + 0.05, G('一发') + 0.25];
+V.item({ key: 's08month', ...MP, r: 0.03, z: 13, at: G('平均') - 0.35, enter: { from: [-360, -200], tilt: -0.18, dur: 0.35 }, draw(g, T_) {
+ V.blit(g, month()); const st = step(T_);
+ DAYS.forEach((d, k) => { const t = tCal[0] + k * (tCal[1] - tCal[0]) / DAYS.length; if (st < t) return; g.save(); g.translate(-MW / 2 + 20 + (d % 7) * 68 + 34, -MH / 2 + 100 + Math.floor(d / 7) * 86 + 50); V.pen(g, SL[k], clamp((st - t) / 0.08), { lw: 7 }); g.restore(); });
+ if (st >= tCal[1] - 0.15) { g.save(); g.translate(0, MH / 2 + 50); g.rotate(-0.03); V.label(g, T.avg, 56, { bg: C.red2, n: V.nTyped(T_, tCal[1] - 0.15, 16) }); g.restore(); }
+} });
+// ③ 剪纸天平
+const SC = xy(620, 1430), tTip = G('其他') - 0.05;
+const mini = () => V.cutout('s08mini', 22, 120, (g, w, h) => PH.rocket(g, RK.falcon9({ payload: 'fairing' }), w / 2, h - 4, 1.65), { cell: 3, edge: 3 });
+const pan = (key) => V.cutout('s08pan' + key, 300, 70, (g, w, h) => { g.fillStyle = '#7d7d7a'; g.beginPath(); g.moveTo(0, 10); g.lineTo(w, 10); g.quadraticCurveTo(w / 2, h * 1.6, 0, 10); g.fill(); }, { ht: false, edge: 5 });
+const post = () => V.cutout('s08post', 380, 360, (g, w, h) => { g.fillStyle = '#5c5b58'; g.fillRect(w / 2 - 12, 30, 24, h - 70); g.beginPath(); g.moveTo(w / 2 - 110, h); g.lineTo(w / 2 + 110, h); g.lineTo(w / 2 + 40, h - 44); g.lineTo(w / 2 - 40, h - 44); g.fill(); g.beginPath(); g.arc(w / 2, 30, 22, 0, TAU); g.fill(); }, { ht: false, edge: 5 });
+V.item({ key: 's08scale', ...SC, r: 0, z: 12, at: G('比全') - 0.25, enter: { from: [0, 420], tilt: 0.1, dur: 0.4 }, draw(g, T_) {
+ const st = step(T_), q = MO.backOut(clamp((st - tTip) / 0.8), 1.3), ang = -0.2 * q;
+ V.blit(g, post(), 0, 60);
+ g.save(); g.translate(0, -110); g.rotate(ang); g.fillStyle = '#4a4a48'; g.fillRect(-330, -8, 660, 16);
+ for (const s of [-1, 1]) { g.save(); g.translate(s * 320, 0); g.rotate(-ang); g.strokeStyle = '#4a4a48'; g.lineWidth = 3; g.beginPath(); g.moveTo(0, 0); g.lineTo(-120, 110); g.moveTo(0, 0); g.lineTo(120, 110); g.stroke(); V.blit(g, pan(s), 0, 120); { const nr = s < 0 ? 5 : 2; for (let r = 0; r < nr; r++) for (let j = 0; j < 4; j++) { g.save(); g.translate(-102 + j * 68, 100 - r * 17); g.rotate(-Math.PI / 2); V.blit(g, mini(), 0, 0, 0.55); g.restore(); } }
+ const lab = s < 0 ? T.l : T.r; g.font = V.font(44, F.heavy); const lw = g.measureText(lab).width + 36; g.fillStyle = s < 0 ? C.red2 : C.card; g.fillRect(-lw / 2, 160, lw, 66); V.text(g, lab, 0, 208, 44, F.heavy, s < 0 ? C.paper : C.ink, 'center'); g.restore(); }
+ g.restore();
+} });
+// ④ 37 道划记
+const KP = xy(1800, 1500), KW = 1000, KHh = 340, tT = [G('飞了') - 0.55, G('37') - 0.1];
+const booster = () => V.cutout('s08boost', 96, 420, (g, w, h) => {
+ RK.at(g, w / 2, h - 34, 9.2, 0, q => V.shadeFill(q, RK.falcon9({ stage: 'booster', legs: 0, fins: 0.4 }), { ...V.GREY, body: '#c4c4c4' }));
+ g.save(); g.globalCompositeOperation = 'source-atop'; const gr = g.createLinearGradient(0, h, 0, h * 0.2); gr.addColorStop(0, 'rgba(25,25,25,.85)'); gr.addColorStop(1, 'rgba(25,25,25,0)'); g.fillStyle = gr; g.fillRect(0, 0, w, h); g.restore();
+}, { cell: 4, edge: 6 });
+V.item({ key: 's08tally', ...KP, r: -0.02, z: 13, at: G('有一枚') - 0.3, enter: { from: [420, 120], tilt: 0.14, dur: 0.4 }, draw(g, T_) {
+ V.blit(g, V.spr('s08card', KW, KHh, (gg, w, h) => V.indexCard(gg, w, h, { top: 56, gap: 48 })));
+ g.save(); g.translate(60, -70); g.rotate(-Math.PI / 2); V.blit(g, booster(), 0, 0, 1.3); g.restore();
+ const st = step(T_), n = Math.min(37, Math.floor(37 * MO.sineInOut(seg(st, tT[0], tT[1])) + 1e-6));
+ V.typed(g, T.one, -KW / 2 + 50, -KHh / 2 + 44, V.nTyped(T_, G('助推器') - 0.2, 12), 36, F.heavy, C.ink2);
+ if (st >= tT[0]) V.tally(g, -KW / 2 + 70, 18, n, 84, 13, 20, 6);
+ if (st >= tT[1] - 0.05) { g.save(); g.translate(KW / 2 - 150, 70); g.rotate(-0.05); const s = 1 + 0.25 * (1 - MO.quartOut(clamp(step(T_ - tT[1] + 0.05) / 0.25))); g.scale(s, s); V.text(g, T.n37, 0, 34, 104, F.heavy, C.red, 'center'); g.restore(); }
+} });
+
+// ---------- 相机 ----------
+const at = (x, y, z, sy) => V.at(X0 + x, Y0 + y, z, sy);
+const cam = (lt) => CAM.at([
+ V.key(0, at(1470, 845, 1.0)), // 句读处硬切(Vox 最常用的转场)
+ V.key(0.9, at(1480, 840, 1.02), MO.sineInOut),
+ V.key(cue('165'), at(1560, 860, 1.08), MO.sineInOut),
+ V.key(cue('平均') - 0.05, at(1600, 870, 1.14), MO.sineInOut),
+ V.key(cue('平均') + 0.3, at(620, 840, 1.2), MO.cubicInOut),
+ V.key(cue('比全') - 0.1, at(610, 850, 1.25), MO.sineInOut),
+ V.key(cue('比全') + 0.3, at(640, 1370, 1.18), MO.cubicInOut),
+ V.key(cue('有一枚') - 0.1, at(640, 1380, 1.22), MO.sineInOut),
+ V.key(cue('有一枚') + 0.3, at(1860, 1440, 1.25), MO.cubicInOut),
+ V.key(TM.dur(ID) - 0.3, at(1870, 1445, 1.3), MO.sineInOut),
+ V.key(TM.dur(ID), at(1740, 1400, 1.26), MO.cubicIn),
+], lt);
+V.scene(ID, { cam, init() { V.glyphs(ID, [[F.bold, '全为猎鹰9号'], [F.heavy, T.title + T.avg + T.month + T.l + T.r + T.one + T.n37], [F.med, T.src], [F.num, '0123456789'], [F.type, '0123456789']]); } });
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex_vox/scenes/s09.js b/scripts/engine/reference_films/spacex/spacex_vox/scenes/s09.js
new file mode 100644
index 0000000..a9722d1
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_vox/scenes/s09.js
@@ -0,0 +1,63 @@
+// S09 · 星链:一大张黑卡纸,中间一个网点地球剪纸。卫星=打孔机打下来的纸屑圆点。
+// 「大多在送自家的星链卫星」:小剪纸火箭从地球边上一顿一顿爬到轨道、吐出一叠卫星;「2019,第一批60颗」:60 粒纸屑排成一串绕地球;
+// 「现在,在轨超过1.1万颗」:纸屑像撒出来一样一把一把铺满几层轨道壳(12fps 一把),所有纸屑慢慢绕地球转;「用户超过1200万」:黑标签打字。
+(() => {
+const ID = 's09', V = VOX, C = V.C, F = V.F, PH = V.PH, TAU = Math.PI * 2;
+const { clamp, lerp, rng } = U, seg = MO.seg, step = V.step;
+const cell = V.cell(ID), X0 = cell.x, Y0 = cell.y, xy = (x, y) => ({ x: X0 + x, y: Y0 + y });
+const cue = k => TM.cue(ID, k), G = k => V.cue(ID, k), t0 = V.t0(ID);
+const T = { sl: '星链卫星', y19: '2019 · 第一批', n60: '60颗', now: '现在 · 在轨', n11: '1.1万+颗', user: '用户', n12: '1200万+' };
+
+const BW = 1560, BH = 920, B = xy(1150, 990), E = [-260, 30], R = 210;
+const earth = () => V.cutout('s09earth', R * 2, R * 2, (g) => PH.globe(g, R, R, R, 11), { cell: 5, edge: 6 });
+// 纸屑:位置、轨道壳、出现时刻(全部种子固定)
+const DOTS = (() => { const r = rng(91), o = [];
+ for (let i = 0; i < 60; i++) o.push({ a: -1.2 + i * 0.022, rx: R * 1.42, ry: R * 0.5, tilt: -0.35, s: 7, k: 0 }); // 第一批:一串
+ for (let i = 0; i < 1300; i++) { const sh = r(); const rr = R * (1.16 + sh * 0.7); o.push({ a: r() * TAU, rx: rr, ry: rr * (0.35 + r() * 0.65), tilt: (r() - 0.5) * 1.6, s: 4.5 + r() * 3.5, k: 1, b: Math.floor(r() * 18) }); }
+ return o; })();
+const tFirst = [G('第一批'), G('60') + 0.15], tAll = [G('在轨') - 0.1, G('1.1') + 0.25];
+const dotAt = (d, T_) => { const w = 0.05 + 0.25 / (d.rx / R), a = d.a + step(T_) * w; const x = Math.cos(a) * d.rx, y = Math.sin(a) * d.ry; return [E[0] + x * Math.cos(d.tilt) - y * Math.sin(d.tilt), E[1] + x * Math.sin(d.tilt) + y * Math.cos(d.tilt), Math.sin(a)]; };
+// 小火箭吐卫星(解释「送星链」)
+const rocket = () => V.cutout('s09f9', 34, 200, (g, w, h) => RK.at(g, w / 2, h - 10, 2.6, 0, q => V.shadeFill(q, RK.falcon9({ payload: 'fairing' }), V.GREY)), { cell: 3, edge: 4 });
+const sat = () => V.cutout('s09sat', 120, 40, (g, w, h) => { g.fillStyle = '#d8d8d8'; g.fillRect(0, 8, 44, 24); g.fillStyle = '#4a4a4a'; g.fillRect(48, 4, 70, 32); g.strokeStyle = '#999'; g.lineWidth = 2; for (let x = 58; x < 118; x += 12) { g.beginPath(); g.moveTo(x, 4); g.lineTo(x, 36); g.stroke(); } }, { cell: 3, edge: 4 });
+const tRk = [t0 + 0.35, G('星链') + 0.1];
+const RKP = (() => { const pts = []; for (let i = 0; i <= 30; i++) { const u = i / 30, a = -2.2 + u * 1.3, rr = R * (1.02 + u * 0.55); pts.push([E[0] + Math.cos(a) * rr, E[1] + Math.sin(a) * rr]); } return { p: pts, L: DG.cum(pts) }; })();
+
+V.item({ key: 's09card', ...B, r: 0.008, z: 10, at: t0 - 1, draw(g, T_) {
+ V.blit(g, V.spr('s09bk', BW, BH, (gg, w, h) => V.blackCard(gg, w, h, 97), { sh: { blur: 10, y: 6 } }));
+ const st = step(T_);
+ // 背面的纸屑先画(在地球后面),再画地球,再画前面的
+ const nFirst = Math.round(60 * MO.sineInOut(seg(st, tFirst[0], tFirst[1]))), qa = seg(st, tAll[0], tAll[1]);
+ const vis = (d, i) => d.k === 0 ? i < nFirst : d.b < Math.floor(qa * 18 + 1e-6);
+ const drawDots = (front) => { g.fillStyle = '#f2efe6'; g.beginPath(); DOTS.forEach((d, i) => { if (!vis(d, i)) return; const [x, y, z] = dotAt(d, T_); if ((z > 0) !== front) return; g.moveTo(x + d.s, y); g.arc(x, y, d.s, 0, TAU); }); g.fill(); };
+ g.save(); g.shadowColor = 'rgba(0,0,0,.5)'; g.shadowBlur = 3; g.shadowOffsetY = 2; drawDots(false); g.restore();
+ V.blit(g, earth(), E[0], E[1]);
+ g.save(); g.shadowColor = 'rgba(0,0,0,.5)'; g.shadowBlur = 3; g.shadowOffsetY = 2; drawDots(true); g.restore();
+ // 小火箭+卫星叠
+ const rq = seg(st, tRk[0], tRk[1]);
+ if (rq > 0 && st < tFirst[0] + 0.4) { const L = RKP.L[RKP.L.length - 1], p = DG.pointAt(RKP.p, RKP.L, L * MO.sineInOut(Math.min(1, rq * 1.25))), p2 = DG.pointAt(RKP.p, RKP.L, Math.min(L, L * MO.sineInOut(Math.min(1, rq * 1.25)) + 6));
+ g.save(); g.translate(p[0], p[1]); g.rotate(Math.atan2(p2[1] - p[1], p2[0] - p[0]) + Math.PI / 2); V.blit(g, rocket()); g.restore();
+ if (rq > 0.8) for (let k = 0; k < 4; k++) { g.save(); g.translate(p[0] + 60 + k * 10, p[1] - 40 - k * 16); g.rotate(0.3); V.blit(g, sat()); g.restore(); } }
+ // 标签(全在卡片上半/右侧,避开字幕带)
+ const lab = (t, x, y, s1, num, unit, size, col) => { if (st < t) return; g.save(); g.translate(x, y); g.rotate(-0.02);
+ V.typed(g, s1, 0, 0, V.nTyped(T_, t, 14), 46, F.heavy, 'rgba(238,237,235,.85)');
+ const tn = t + 0.25; if (st >= tn) { const k = 1 + 0.3 * (1 - MO.quartOut(clamp(step(T_ - tn) / 0.25))); g.translate(0, size * 1.16); g.scale(k, k); V.text(g, num, 0, 0, size, F.num, col); g.font = V.font(size, F.num); const w = g.measureText(num).width; V.text(g, unit, w + 10, 0, size * 0.5, F.heavy, col); }
+ g.restore(); };
+ if (st >= G('星链') - 0.1) { g.save(); g.translate(E[0] - 40, E[1] - R - 120); g.rotate(-0.02); V.label(g, T.sl, 54, { bg: C.paper, col: C.ink, n: V.nTyped(T_, G('星链') - 0.1, 12) }); g.restore(); }
+ lab(G('2019'), 200, -330, T.y19, '60', '颗', 110, C.paper);
+ lab(G('现在'), 200, -60, T.now, '1.1', '万+颗', 120, C.yel);
+ lab(G('用户'), 200, 210, T.user, '1200', '万+', 110, C.paper);
+} });
+
+// ---------- 相机:沿桌往左进黑卡 → 跟着计数慢推 ----------
+const at = (x, y, z, sy) => V.at(X0 + x, Y0 + y, z, sy);
+const cam = (lt) => CAM.at([
+ V.key(0, at(1170, 965, 0.99)), // 进场:黑卡纸像一张新纸被拍到桌上(vox_slap)
+ V.key(0.85, at(1180, 960, 1.0), MO.sineInOut),
+ V.key(cue('2019') - 0.1, at(1090, 980, 1.08), MO.sineInOut),
+ V.key(cue('现在') + 0.1, at(1150, 960, 0.98), MO.sineInOut),
+ V.key(TM.dur(ID), at(1170, 965, 1.04), MO.sineInOut),
+], lt);
+ERAS.find(e => e.id === ID).transition = { type: 'vox_slap', dur: 0.5, punch: 0 };
+V.scene(ID, { cam, init() { V.glyphs(ID, [[F.heavy, T.sl + T.y19 + T.now + T.user], [F.num, '601.11200'], [F.heavy, '颗万+']]); } });
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex_vox/scenes/s10.js b/scripts/engine/reference_films/spacex/spacex_vox/scenes/s10.js
new file mode 100644
index 0000000..6ac534e
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_vox/scenes/s10.js
@@ -0,0 +1,109 @@
+// S10 · 星舰(全片最强的两个高光都在这格)。
+// ①量身高:一把竖着的纸尺旁边站着三枚剪纸火箭(按真实比例)——猎鹰1号、猎鹰9号,星舰最后滑进来一下子顶到尺子上头,红笔括出「最大、最强」;
+// ②硬切到「2023 首飞」网点照片 → 念到「炸了」,这张照片当场被撕成两半,网点爆炸团从裂口里炸出来(留一拍);
+// ③纸偶发射塔:两只机械臂用铜脚钉(两脚钉)钉在塔上,一顿一顿张开;旁边贴一张真筷子的网点照片(像筷子一样);
+// 剪纸助推器拖着纸火焰落下来,两臂合拢夹住,红圈+「夹住了」(全片高光,留到段尾)。
+(() => {
+const ID = 's10', V = VOX, C = V.C, F = V.F, PH = V.PH, TAU = Math.PI * 2;
+const { clamp, lerp } = U, seg = MO.seg, step = V.step;
+const cell = V.cell(ID), X0 = cell.x, Y0 = cell.y, xy = (x, y) => ({ x: X0 + x, y: Y0 + y });
+const cue = k => TM.cue(ID, k), G = k => V.cue(ID, k), t0 = V.t0(ID);
+const T = { f1: '猎鹰1号', f9: '猎鹰9号', ss: '星舰', big: '最大、最强', y23: '2023 · 首飞', boom: '约4分钟', y24: '2024.10', chop: '筷子', got: '夹住了', arms: '机械臂' };
+
+// ① 量身高(6.6 px/m)
+// 两块衬底:量身高那组钉在一张旧羊皮纸上,发射塔那组钉在一张黑卡纸上(画面不再是大片空桌面)
+V.item({ key: 's10bg1', ...xy(640, 1230), r: -0.012, z: 5, at: t0 - 1, draw(g) { V.blit(g, V.spr('s10bg1', 1300, 1180, (gg, w, h) => V.paper(gg, w, h, 91, { col: '#d9cba9', amp: 6, age: 0.3 }), { sh: { blur: 14, y: 8 } })); V.tape(g, -600, -560, -0.6, 150); V.tape(g, 600, -560, 0.55, 150); } });
+V.item({ key: 's10bg2', ...xy(1930, 1170), r: 0.01, z: 5, at: t0 - 1, draw(g) { V.blit(g, V.spr('s10bg2', 640, 1160, (gg, w, h) => V.blackCard(gg, w, h, 93), { sh: { blur: 12, y: 6 } })); } });
+const PX = 6.6, GB = xy(640, 1560); // 地面线(剪纸脚底)
+const cut = (key, shape, w, h, pal = V.GREY) => V.cutout('s10' + key, w, h, (g, ww, hh) => RK.at(g, ww / 2, hh - 6, PX, 0, q => V.shadeFill(q, shape, pal)), { cell: 4, edge: 6 });
+const SHAPES = { f1: [RK.falcon1(), 30, 160], f9: [RK.falcon9({ payload: 'fairing' }), 44, 560], ss: [RK.starship({ fins: 1 }), 120, 830] };
+const RXS = { f1: -250, f9: -60, ss: 230 };
+const rulerS = () => V.spr('s10ruler', 90, 900, (g, w, h) => { V.paper(g, w, h, 71, { col: '#ece3c8', torn: false, age: 0.2 }); g.fillStyle = C.ink; for (let m = 0; m <= 130; m += 10) { const y = h - 12 - m * PX; g.fillRect(w - 34, y - 1.5, 34, 3); if (m % 50 === 0) V.text(g, String(m), 8, y + 10, 26, F.type, C.ink); } for (let m = 0; m <= 130; m += 5) { const y = h - 12 - m * PX; g.fillRect(w - 16, y - 1, 16, 2); } V.text(g, 'm', 10, 30, 26, F.type, C.ink2); });
+V.item({ key: 's10ruler', x: GB.x - 470, y: GB.y - 438, r: 0, z: 10, at: t0 - 1, draw(g) { V.blit(g, rulerS()); } });
+for (const k of ['f1', 'f9', 'ss']) {
+ const [sh, w, h] = SHAPES[k], ent = k === 'ss';
+ V.item({ key: 's10' + k, x: GB.x + RXS[k], y: GB.y - h / 2 - 6, r: 0, z: 11, at: ent ? G('星舰') - 0.2 : t0 - 1, enter: ent ? { from: [0, -900], tilt: 0.06, dur: 0.35 } : null, draw(g, T_) {
+ V.blit(g, cut(k, sh, w + 12, h + 12));
+ g.save(); g.translate(0, h / 2 + 44); g.rotate(0.02); g.font = V.font(40, F.heavy); const lw = g.measureText(T[k]).width + 30; g.fillStyle = k === 'ss' ? C.black : C.card; g.fillRect(-lw / 2, -30, lw, 60); V.text(g, T[k], 0, 14, 40, F.heavy, k === 'ss' ? C.paper : C.ink, 'center'); g.restore();
+ } });
+}
+const BRK = V.handPts('s10brk', [[0, 0], [30, 0], [30, 830], [0, 830]], { amp: 1.5, seed: 6 });
+V.item({ key: 's10brk', x: GB.x + RXS.ss + 90, y: GB.y - 840, z: 12, rad: 1000, at: G('最大') - 0.1, until: G('2023') - 0.32, draw(g, T_) {
+ const st = step(T_); V.pen(g, BRK, MO.cubicOut(seg(st, G('最大'), G('最大') + 0.4)), { lw: 7 });
+ if (st >= G('最强') - 0.05) { g.save(); g.translate(150, 300); g.rotate(-0.04); V.label(g, T.big, 56, { bg: C.red2, n: V.nTyped(T_, G('最强') - 0.05, 12) }); g.restore(); }
+} });
+
+// ② 2023 首飞:照片被撕开
+const PW = 540, PHh = 680, P = xy(1280, 900);
+const launchSS = (g, w, h) => { PH.sky(g, w, h, '#4a4a4a', '#cfcfcf'); PH.smoke(g, w * 0.5, h * 1.02, 180, 18, 13, '#f0f0f0', 1.6); PH.plume(g, [[w * 0.5, h], [w * 0.5, h * 0.66]], 40, 80, 9, '#ececec'); PH.glow(g, w * 0.5, h * 0.63, 160, 1); PH.flame(g, w * 0.5, h * 0.6, 200, 58); PH.rocket(g, RK.starship({ fins: 1 }), w * 0.5, h * 0.6, h / 175); };
+const TEAR = (() => { const r = U.rng(5), o = []; for (let i = 0; i <= 26; i++) o.push([(r() - 0.5) * 50 + (i % 2 ? 14 : -14), -PHh / 2 - 20 + i * (PHh + 40) / 26]); return o; })();
+const tBoom = G('炸了') - 0.05;
+const burst = () => V.cutout('s10boom', 520, 480, (g, w, h) => { PH.glow(g, w / 2, h / 2, 240, 1); PH.smoke(g, w / 2, h / 2, 160, 16, 23, '#bdbdbd', 1.1); PH.smoke(g, w / 2, h / 2, 100, 10, 29, '#ffffff'); }, { cell: 5, edge: 0, contrast: 1.4 });
+V.item({ key: 's10photo', ...P, r: -0.02, z: 13, at: G('2023') - 0.3, draw(g, T_) {
+ const st = step(T_), sp = V.photo('s10ss', PW, PHh, launchSS, { cell: 6, border: 16 }), q = MO.quartOut(clamp((st - tBoom) / 0.35));
+ const half = (s) => { g.save(); g.translate(s * 46 * q, s * 8 * q); g.rotate(s * 0.07 * q); g.beginPath(); g.moveTo(s * 400, -PHh); TEAR.forEach(p => g.lineTo(p[0], p[1])); g.lineTo(s * 400, PHh); g.closePath(); g.clip(); V.blit(g, sp); if (q > 0) { g.strokeStyle = '#f4f2ec'; g.lineWidth = 8; g.beginPath(); TEAR.forEach((p, i) => i ? g.lineTo(p[0], p[1]) : g.moveTo(p[0], p[1])); g.stroke(); } g.restore(); };
+ half(-1); half(1);
+ if (st >= tBoom) { const k = 0.6 + 0.5 * MO.backOut(clamp((st - tBoom) / 0.3), 2.2); g.save(); g.translate(0, -60); g.scale(k, k); V.blit(g, burst()); g.restore(); }
+ g.save(); g.translate(-PW / 2 + 120, PHh / 2 - 40); g.rotate(-0.04); V.label(g, T.y23, 56, { n: V.nTyped(T_, G('2023'), 12) }); g.restore();
+ if (st >= G('四分钟')) { g.save(); g.translate(PW / 2 - 60, -PHh / 2 + 70); g.rotate(0.05); V.label(g, T.boom, 54, { bg: C.red2, n: V.nTyped(T_, G('四分钟'), 10) }); g.restore(); }
+} });
+
+// ③ 纸偶发射塔+筷子照片+助推器
+const TB = xy(2050, 1640), TS = 5.6, ARM = 31, ARMY = 70; // 塔脚、px/m、臂长(m)、臂高(m)
+const towerS = () => V.cutout('s10tower', 12 * TS + 20, 146 * TS + 10, (g, w, h) => {
+ g.fillStyle = '#5e5e5c'; g.fillRect(10, 0, 12 * TS, 146 * TS);
+ g.strokeStyle = '#2c2c2b'; g.lineWidth = 3; for (let y = 0; y < 146 * TS; y += 8 * TS) { g.beginPath(); g.moveTo(10, y); g.lineTo(10 + 12 * TS, y + 8 * TS); g.moveTo(10 + 12 * TS, y); g.lineTo(10, y + 8 * TS); g.stroke(); }
+ g.strokeRect(10, 0, 12 * TS, 146 * TS);
+}, { ht: false, edge: 6 });
+const armS = () => V.cutout('s10arm', ARM * TS + 30, 26, (g, w, h) => { g.fillStyle = '#3d3d3b'; g.beginPath(); g.moveTo(0, 4); g.lineTo(w - 10, 2); g.lineTo(w, 13); g.lineTo(w - 10, 24); g.lineTo(0, 22); g.closePath(); g.fill(); g.fillStyle = '#6a6a68'; for (let x = 16; x < w - 20; x += 22) g.fillRect(x, 9, 12, 8); }, { ht: false, edge: 5 });
+const shS = () => V.cutout('s10sh', 9 * TS + 70, 71 * TS + 20, (g, w, h) => { RK.at(g, w / 2, h - 10, TS, 0, q => V.shadeFill(q, RK.superHeavy({ fins: 1 }), V.GREY)); g.fillStyle = '#2a2a2a'; const ty = h - 10 - 71 * TS + 3.4 * TS; for (const s of [-1, 1]) { const x = w / 2 + s * (4.5 * TS + 4); g.fillRect(s < 0 ? x - 26 : x, ty, 26, 20); g.fillStyle = '#5a5a5a'; for (let k = 1; k < 4; k++) g.fillRect((s < 0 ? x - 26 : x) + k * 6.5, ty, 1.5, 20); g.fillStyle = '#2a2a2a'; } }, { cell: 4, edge: 6 }); // 顶上加两片看得清的栅格舵
+const brad = (g, x, y) => { g.save(); g.translate(x, y); const gr = g.createRadialGradient(-4, -4, 1, 0, 0, 14); gr.addColorStop(0, '#f3dd9a'); gr.addColorStop(1, '#9c7a2e'); g.fillStyle = gr; g.beginPath(); g.arc(0, 0, 13, 0, TAU); g.fill(); g.restore(); };
+const tOpen = [G('伸出') - 0.05, G('机械臂') + 0.2], tDesc = [G('一次') - 0.1, G('夹住') - 0.04], tClose = [G('夹住') - 0.04, G('夹住') + 0.2];
+const pivot = [TB.x - 10, TB.y - ARMY * TS];
+V.item({ key: 's10tower', x: TB.x + 6 * TS, y: TB.y - 73 * TS, z: 11, rad: 1100, at: t0 - 1, draw(g) { V.blit(g, towerS()); } });
+V.item({ key: 's10catch', x: pivot[0], y: pivot[1], z: 14, rad: 1100, at: t0 - 1, draw(g, T_) {
+ const st = step(T_), op = MO.quartOut(seg(st, tOpen[0], tOpen[1])), cl = MO.backOut(seg(st, tClose[0], tClose[1]), 1.6), a = 0.62 * op * (1 - cl) + 0.07 * (1 - cl) * 0;
+ // 助推器(在臂后面):落下 → 被夹住后随臂轻晃
+ const bx = -ARM * TS * 0.74, catchY = 71 * TS / 2 - 7.6 * TS, dq = clamp((st - tDesc[0]) / (tDesc[1] - tDesc[0]));
+ if (st >= tDesc[0]) { const y = st < tDesc[1] ? catchY - 900 * Math.pow(1 - dq, 1.5) : catchY + MO.settle(st - tDesc[1], 7, 3, 6);
+ g.save(); g.translate(bx, y); if (st < tDesc[1]) { g.fillStyle = '#e9d84a'; g.beginPath(); g.moveTo(-36, 71 * TS / 2); g.lineTo(0, 71 * TS / 2 + 160 * (1 - dq * 0.7) * ((Math.floor(st * 12) % 2) ? 1 : 0.85)); g.lineTo(36, 71 * TS / 2); g.fill(); g.fillStyle = C.red; g.beginPath(); g.moveTo(-18, 71 * TS / 2); g.lineTo(0, 71 * TS / 2 + 80 * (1 - dq * 0.7)); g.lineTo(18, 71 * TS / 2); g.fill(); }
+ V.blit(g, shS()); g.restore(); }
+ for (const s of [-1, 1]) { g.save(); g.rotate(Math.PI + s * a); g.translate(0, s * 18); V.blit(g, armS(), (ARM * TS + 30) / 2 - 6, 0); g.restore(); }
+ brad(g, 0, -18); brad(g, 0, 18);
+ if (st >= tOpen[0] + 0.2 && st < G('一次')) { g.save(); g.translate(-ARM * TS * 0.55, -150); g.rotate(-0.03); V.label(g, T.arms, 44, { bg: C.card, col: C.ink, n: V.nTyped(T_, tOpen[0] + 0.2, 10) }); g.restore(); }
+ const cc = V.circle('s10got', 150, 120, 17); g.save(); g.translate(bx, 0); V.pen(g, cc, MO.cubicOut(seg(st, tClose[1], tClose[1] + 0.5)), { lw: 9 }); g.restore();
+ if (st >= G('住了') - 0.05) { g.save(); g.translate(bx - 300, 160); g.rotate(-0.06); const k = 1 + 0.3 * (1 - MO.quartOut(clamp(step(T_ - G('住了') + 0.05) / 0.25))); g.scale(k, k); V.label(g, T.got, 84, { bg: C.red2, padX: 30 }); g.restore(); }
+} });
+V.item({ key: 's10y24', ...xy(1960, 940), r: 0.03, z: 15, at: G('2024') - 0.05, enter: { drop: 0.25, dur: 0.25 }, draw(g, T_) { V.label(g, T.y24, 72, { fam: F.num, n: V.nTyped(T_, G('2024'), 10) }); } });
+const chopDraw = (g, w, h) => { // 一双筷子斜放在深色桌布上(方头、尖细的筷子头、木纹)
+ PH.sky(g, w, h, '#3a3a3a', '#1c1c1c');
+ for (const [o, a] of [[-16, -0.5], [16, -0.43]]) { g.save(); g.translate(w / 2 + o, h / 2 + o * 0.3); g.rotate(a);
+ const gr = g.createLinearGradient(0, -8, 0, 8); gr.addColorStop(0, '#f4f4f4'); gr.addColorStop(1, '#a8a8a8'); g.fillStyle = gr;
+ g.beginPath(); g.moveTo(-190, -9); g.lineTo(170, -3.5); g.lineTo(184, 0); g.lineTo(170, 3.5); g.lineTo(-190, 9); g.closePath(); g.fill();
+ g.strokeStyle = 'rgba(80,80,80,.5)'; g.lineWidth = 1.2; for (let k = -1; k <= 1; k++) { g.beginPath(); g.moveTo(-180, k * 3); g.lineTo(120, k * 1.5); g.stroke(); } g.fillStyle = '#6a6a6a'; g.fillRect(-190, -9, 34, 18); g.restore(); }
+};
+V.item({ key: 's10chop', ...xy(1430, 1465), r: -0.05, z: 13, at: G('像筷子') - 0.05, enter: { from: [-380, 160], tilt: -0.2, dur: 0.4 }, draw(g, T_) {
+ V.blit(g, V.photo('s10chop', 360, 250, chopDraw, { cell: 4, border: 11 })); V.tape(g, 0, -137, 0.05, 110);
+ g.save(); g.translate(0, 170); g.rotate(0.03); V.label(g, T.chop, 50, { bg: C.card, col: C.ink, n: V.nTyped(T_, G('筷子'), 8) }); g.restore();
+} });
+
+// ---------- 相机 ----------
+const at = (x, y, z, sy) => V.at(X0 + x, Y0 + y, z, sy);
+const cutB = cue('2023') - 0.02, moveC = cue('2024') - 0.15;
+const PV = [pivot[0] - X0, pivot[1] - Y0];
+const cam = (lt) => CAM.at([
+ V.key(0, V.camEnd('s09')),
+ V.key(0.5, at(780, 1150, 0.93), MO.longTail),
+ V.key(cutB - 0.001, at(790, 1155, 0.97), MO.sineInOut),
+ V.key(cutB, at(1280, 900, 1.06)), // 硬切:首飞照片
+ V.key(cue('炸了') - 0.05, at(1280, 890, 1.14), MO.sineInOut),
+ V.key(cue('炸了') + 0.3, at(1280, 880, 1.02), MO.quartOut), // 撕开那一下镜头往后一弹
+ V.key(moveC, at(1285, 885, 1.0), MO.sineInOut),
+ V.key(moveC + 0.7, at(PV[0] - 260, PV[1] - 40, 0.92), MO.cubicInOut),
+ V.key(cue('像筷子') - 0.1, at(PV[0] - 250, PV[1] - 30, 0.95), MO.sineInOut),
+ V.key(cue('一次'), at(PV[0] - 330, PV[1] - 10, 0.9), MO.sineInOut),
+ V.key(cue('夹住') + 0.1, at(PV[0] - 200, PV[1] + 20, 1.08), MO.sineInOut),
+ V.key(TM.dur(ID), at(PV[0] - 190, PV[1] + 25, 1.16), MO.sineInOut),
+], lt);
+V.scene(ID, { cam, init() { V.glyphs(ID, [[F.heavy, T.f1 + T.f9 + T.ss + T.big + T.y23 + T.boom + T.chop + T.got + T.arms], [F.num, T.y24], [F.type, '050100m']]); } });
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex_vox/scenes/s11.js b/scripts/engine/reference_films/spacex/spacex_vox/scenes/s11.js
new file mode 100644
index 0000000..a3a8426
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_vox/scenes/s11.js
@@ -0,0 +1,125 @@
+// S11 · 2026:①两张名片纸——「SpaceX」和「xAI · 马斯克的AI公司」,念到「收购」小卡片滑到大卡片底下,订书钉「咔」地钉住;
+// ②一条行情纸带打出「SPCX 2026.06.12」,然后「750亿美元」像勒索信一样,每个字从不同的剪报上剪下来,一个一个拍上桌(第三个高光);
+// ③剪报标题「史上最大的一次上市」荧光笔+红圈;④「9月28号,星舰入轨」:相机一路滑回开场那格(9.28 的日历和星舰照片),
+// 26 粒卫星纸屑一粒一粒从照片里蹦出来排成一道弧——片子的头和尾在这张桌子上接上。
+(() => {
+const ID = 's11', V = VOX, C = V.C, F = V.F, PH = V.PH, TAU = Math.PI * 2;
+const { clamp, lerp, rng } = U, seg = MO.seg, step = V.step;
+const cell = V.cell(ID), X0 = cell.x, Y0 = cell.y, xy = (x, y) => ({ x: X0 + x, y: Y0 + y });
+const cue = k => TM.cue(ID, k), G = k => V.cue(ID, k), t0 = V.t0(ID);
+const T = { yr: '2026', sx: 'SpaceX', xa: 'xAI', xs: '马斯克的AI公司', buy: '收购', tape: 'SPCX 2026.06.12', ipo: '6月上市', over: '超过', unit: '亿美元', head: '史上最大的一次上市', kick: '2026.6', n26: '26颗', s26: '新一代星链卫星' };
+
+// ① 名片纸
+const card = (key, title, sub, w, h, dark) => V.spr('s11' + key, w, h, (g) => {
+ if (dark) { g.fillStyle = C.black; g.fillRect(0, 0, w, h); } else V.paper(g, w, h, 81 + w % 7, { col: '#f4f2ec', torn: false, age: 0.08 });
+ V.text(g, title, 44, sub ? h / 2 + 10 : h / 2 + 36, 96, F.black, dark ? C.paper : C.ink);
+ if (sub) V.text(g, sub, 46, h / 2 + 70, 38, F.bold, dark ? 'rgba(238,237,235,.75)' : C.ink2);
+});
+const CA = xy(600, 760), CB = xy(1180, 1120), tBuy = G('收购');
+const ARW = V.handPts('s11arw', [[560, 300], [420, 250], [250, 175]], { amp: 1.5, seed: 3 }); // SpaceX 卡坐标系里:从 xAI 卡指向 SpaceX 卡
+V.item({ key: 's11date', ...xy(1080, 640), r: 0.04, z: 13, at: G('2026') - 0.1, enter: { drop: 0.25, dur: 0.25 }, draw(g, T_) { g.fillStyle = C.paper; g.save(); g.translate(-110, -34); CL.tornRect(g, 220, 68, 5, 2); g.fill(); g.restore(); V.typed(g, '2026.2', -84, 16, V.nTyped(T_, G('2026'), 10), 40, F.type, C.ink); } });
+V.item({ key: 's11xai', x: CB.x, y: CB.y, r: 0.04, z: 11, at: G('收购') - 0.35, enter: { from: [460, 160], tilt: 0.2, dur: 0.4 }, draw(g, T_) {
+ // 念到「xAI」:小卡片挪过去,上沿塞到 SpaceX 卡下面(名字整行露在外面),订书钉钉住
+ const st = step(T_), q = MO.quartOut(clamp((st - G('xAI')) / 0.45)); g.save(); g.translate(-450 * q, -150 * q); g.rotate(-0.07 * q); V.blit(g, card('xa', T.xa, T.xs, 460, 230, true)); g.restore();
+} });
+V.item({ key: 's11sx', ...CA, r: -0.02, z: 12, at: t0 - 1, draw(g, T_) {
+ V.blit(g, card('sx', T.sx, null, 560, 250, false));
+ const st = step(T_), tS = G('xAI') + 0.45;
+ // 「收购」:红笔从 xAI 卡画一支箭指向 SpaceX 卡,标签落在箭杆中间;卡片塞进去以后箭收走、长尾夹夹住两张卡
+ const tTuck = G('xAI') + 0.45;
+ if (st >= tBuy && st < tTuck) { g.save(); g.rotate(0.02); V.pen(g, ARW, MO.cubicOut(seg(st, tBuy, tBuy + 0.45)), { lw: 9 }); if (st >= tBuy + 0.4) { const e = ARW.p[ARW.p.length - 1]; g.strokeStyle = C.red; g.lineWidth = 9; g.lineCap = 'round'; g.beginPath(); g.moveTo(e[0] + 34, e[1] - 4); g.lineTo(e[0], e[1]); g.lineTo(e[0] + 14, e[1] + 32); g.stroke(); } g.restore(); }
+ if (st >= tBuy) { g.save(); g.translate(470, 170); g.rotate(-0.06); V.label(g, T.buy, 60, { bg: C.red2, n: V.nTyped(T_, tBuy, 8) }); g.restore(); }
+ if (st >= tTuck) { const k = 1 + 0.35 * (1 - MO.quartOut(clamp((st - tTuck) / 0.25))); g.save(); g.translate(240, 140); g.rotate(-0.12); g.scale(k * 0.8, k * 0.8); V.blit(g, V.PROP('clip')); g.restore(); }
+} });
+// ② 行情纸带+勒索信式大数字
+const TP = xy(1300, 560), TW = 1500;
+V.item({ key: 's11tape', ...TP, r: -0.015, z: 10, at: G('6月') - 0.2, draw(g, T_) {
+ const st = step(T_), q = MO.quartOut(seg(st, G('6月') - 0.2, G('6月') + 0.35)), w = TW * q;
+ g.save(); g.beginPath(); g.rect(-TW / 2 - 20, -80, w + 40, 160); g.clip();
+ g.save(); g.translate(-TW / 2, -46); V.paper(g, TW, 92, 101, { col: '#efe9d6', torn: false, age: 0.1 }); g.restore();
+ g.fillStyle = 'rgba(40,36,30,.3)'; for (let x = -TW / 2 + 20; x < TW / 2; x += 30) { g.beginPath(); g.arc(x, -36, 3, 0, TAU); g.arc(x, 36, 3, 0, TAU); g.fill(); }
+ V.typed(g, T.tape, -TW / 2 + 40, 18, V.nTyped(T_, G('6月'), 16), 54, F.type, C.ink);
+ g.restore();
+ if (st >= G('上市') - 0.05) { g.save(); g.translate(TW / 2 - 210, 4); g.rotate(0.04); V.label(g, T.ipo, 58, { bg: C.red2, n: V.nTyped(T_, G('上市') - 0.05, 10) }); g.restore(); }
+} });
+const RN = [['7', 'n', -0.08], ['5', 'r', 0.06], ['0', 'b', -0.04]];
+const glyphScrap = (ch, kind) => V.spr('s11rn' + ch, 200, 270, (g, w, h) => {
+ g.save(); CL.tornRect(g, w, h, ch.charCodeAt(0), 6); g.clip();
+ if (kind === 'n') { V.paper(g, w, h, 3, { torn: false, col: '#f1efe8' }); g.fillStyle = 'rgba(40,36,30,.18)'; for (let y = 20; y < h; y += 22) g.fillRect(10, y, w - 20, 6); }
+ else { g.fillStyle = kind === 'r' ? C.red2 : C.black; g.fillRect(0, 0, w, h); }
+ g.restore(); V.text(g, ch, w / 2, h - 34, 250, F.num, kind === 'n' ? C.ink : C.paper, 'center');
+});
+const unitScrap = () => V.spr('s11unit', 420, 150, (g, w, h) => { V.paper(g, w, h, 33, { col: '#f6f4ee' }); V.text(g, T.unit, w / 2, h / 2 + 38, 104, F.black, C.ink, 'center'); });
+const RNP = xy(1600, 900), tN = [G('750'), G('750') + 0.13, G('750') + 0.25], tU = G('亿美元');
+V.item({ key: 's11num', ...RNP, r: 0, z: 14, rad: 1200, at: G('超过') - 0.05, draw(g, T_) {
+ const st = step(T_);
+ g.save(); g.translate(-430, -170); g.rotate(-0.04); V.label(g, T.over, 50, { bg: C.card, col: C.ink, n: V.nTyped(T_, G('超过'), 10) }); g.restore();
+ RN.forEach(([ch, kind, r], i) => { if (st < tN[i] - 0.02) return; const k = 1 + 0.45 * (1 - MO.quartOut(clamp((st - tN[i] + 0.02) / 0.17))); g.save(); g.translate(-330 + i * 205, 30 + (i % 2) * 18); g.rotate(r); g.scale(k, k); V.blit(g, glyphScrap(ch, kind)); g.restore(); });
+ if (st >= tU - 0.02) { const k = 1 + 0.35 * (1 - MO.quartOut(clamp((st - tU + 0.02) / 0.17))); g.save(); g.translate(380, 100); g.rotate(0.05); g.scale(k, k); V.blit(g, unitScrap()); g.restore(); }
+} });
+// ③ 剪报标题
+const NW = 980, NH = 300, N = xy(1450, 1420);
+const news = () => V.spr('s11news', NW, NH, (g, w, h) => { V.paper(g, w, h, 107, { amp: 5 }); V.text(g, T.kick, 56, 66, 34, F.type, C.ink2); g.fillStyle = C.ink; g.fillRect(56, 84, w - 112, 3); V.serifBold(g, T.head, 56, 190, 92); g.fillStyle = 'rgba(40,36,30,.26)'; g.fillRect(56, 232, 760, 10); g.fillRect(56, 256, 640, 10); });
+const HS = (() => { const g = PAINT.scratch('vxmeasure').getContext('2d'); return [V.span(g, T.head, '史上最大', 56, 92, F.serif), V.span(g, T.head, '最大', 56, 92, F.serif)]; })();
+const NC = V.circle('s11big', 120, 70, 37);
+V.item({ key: 's11news', ...N, r: 0.015, z: 12, at: G('是史上') - 0.35, enter: { from: [0, 380], tilt: 0.08, dur: 0.35 }, draw(g, T_) {
+ V.blit(g, news()); g.save(); g.translate(-NW / 2, -NH / 2); const st = step(T_);
+ V.hl(g, HS[0].x - 6, 112, HS[0].w + 12, 100, MO.sineInOut(seg(st, G('史上'), G('最大') + 0.25)));
+ g.translate(HS[1].x + HS[1].w / 2, 160); V.pen(g, NC, MO.cubicOut(seg(st, G('一次上市'), G('一次上市') + 0.5)), { lw: 8 }); g.restore();
+} });
+// ④ 回到「9.28」那格:26 粒卫星从星舰照片里蹦出来
+const c01 = V.cell('s01'), SHIP = [c01.x + 1290, c01.y + 1385];
+const SATS = (() => { const o = [], a = [c01.x + 1470, c01.y + 1480], m = [c01.x + 1830, c01.y + 1840], b = [c01.x + 2290, c01.y + 1560]; for (let i = 0; i < 26; i++) { const u = i / 25, v = 1 - u; o.push([v * v * a[0] + 2 * u * v * m[0] + u * u * b[0], v * v * a[1] + 2 * u * v * m[1] + u * u * b[1]]); } return o; })();
+const tSat = [G('放出') + 0.05, G('颗') + 0.4];
+V.item({ key: 's11sats', x: SHIP[0], y: SHIP[1], z: 30, rad: 1200, at: tSat[0], draw(g, T_) {
+ const st = step(T_), n = Math.min(26, Math.floor((st - tSat[0]) / ((tSat[1] - tSat[0]) / 26)) + 1);
+ g.save(); g.translate(-SHIP[0], -SHIP[1]); g.shadowColor = 'rgba(40,30,20,.35)'; g.shadowBlur = 4; g.shadowOffsetY = 3;
+ for (let i = 0; i < n; i++) { const [x, y] = SATS[i], age = st - (tSat[0] + i * (tSat[1] - tSat[0]) / 26), k = 1 + 0.6 * (1 - clamp(age / 0.17)); g.fillStyle = '#f4f2ec'; g.beginPath(); g.arc(x, y, 15 * k, 0, TAU); g.fill(); g.fillStyle = C.red; g.beginPath(); g.arc(x, y, 6 * k, 0, TAU); g.fill(); }
+ g.restore();
+ if (st >= G('26颗') - 0.05) { g.save(); g.translate(900, -170); g.rotate(-0.04); V.label(g, T.n26, 90, { bg: C.red2, padX: 30 }); g.translate(-30, 110); V.label(g, T.s26, 50, { n: V.nTyped(T_, G('新一代'), 14) }); g.restore(); }
+} });
+
+// ---------- 相机 ----------
+const at = (x, y, z, sy) => V.at(X0 + x, Y0 + y, z, sy);
+const back = cue('9月') - 0.45, pushA = cue('星舰') - 0.4, ins0 = cue('入轨') - 0.08;
+const cam0 = (lt) => CAM.at([
+ V.key(0, at(710, 865, 0.99)), // 进场:名片纸那一镜被拍到桌上(vox_slap)
+ V.key(0.45, at(720, 870, 1.0), MO.sineInOut),
+ V.key(cue('xAI') + 0.2, at(780, 900, 1.13), MO.sineInOut), // 慢推向两张卡
+ V.key(cue('6月') - 0.15, at(780, 895, 1.12), MO.sineInOut),
+ V.key(cue('6月') + 0.35, at(1300, 790, 0.98), MO.cubicInOut),
+ V.key(cue('是史上') - 0.25, at(1320, 800, 1.04), MO.sineInOut),
+ V.key(cue('是史上') + 0.2, at(1450, 1360, 1.12), MO.cubicInOut),
+ V.key(back, at(1460, 1365, 1.18), MO.sineInOut),
+ V.key(back + 0.8, V.at(SHIP[0] + 300, SHIP[1] - 20, 1.0), MO.cubicInOut), // 一路滑回开场那格(快摇+运动模糊):9.28 的日历和星舰照片
+ V.key(TM.dur(ID), V.at(SHIP[0] + 300, SHIP[1] - 20, 1.04), MO.sineInOut),
+], lt);
+const cam = (lt) => { const b = cam0(lt); if (lt < pushA) return b; return CAM.pushTo(b, SHIP[0], SHIP[1], 5.2, MO.sineInOut(seg(lt, pushA, ins0))); };
+// ---------- 插入镜头:推满那张星舰照片 → 硬切成大幅扫描:星舰在轨道上,红笔画出轨道,26 粒卫星从它身后一粒粒放出来(第四个高光,留到段尾)----------
+const OW = 1700, OH = 950, OC = [OW * 0.16, OH * 1.75], OS = [OW * 0.6, OH * 0.36], ORB = Math.hypot(OS[0] - OC[0], OS[1] - OC[1]), OA = Math.atan2(OS[1] - OC[1], OS[0] - OC[0]);
+const orbitDraw = (g, w, h) => {
+ g.fillStyle = '#0f0f0f'; g.fillRect(0, 0, w, h); PH.stars(g, w, h, 33, 140);
+ PH.earthLimb(g, OC[0], OC[1], ORB * 0.84, 17);
+ PH.glow(g, OS[0], OS[1], 70, 0.5);
+ PH.rocket(g, RK.ship(), OS[0], OS[1], h / 112, OA);
+};
+const OP = V.handPts('s11orbit', DG.arcPts(OC[0] - OW / 2, OC[1] - OH / 2, ORB, ORB, OA - 0.55, OA + 0.5, 70), { amp: 2, seed: 4 });
+const tSat2 = [cue('放出') + 0.05, cue('颗') + 0.45];
+const insertShot = (c, lt) => {
+ const sp = V.photo('s11orb', OW, OH, orbitDraw, { cell: 8, border: 22, S: 1 }), d = TM.dur(ID) - ins0;
+ V.insert(c, sp, lt - ins0, { z0: 0.95, z1: 0.99, d, bg: C.desk, sy: -75 });
+ const z = lerp(0.95, 0.99, MO.sineInOut(clamp((lt - ins0) / d))), st = step(lt);
+ c.save(); c.translate(960, 465); c.scale(z, z);
+ V.pen(c, OP, MO.cubicOut(seg(st, ins0 + 0.1, ins0 + 0.75)), { lw: 9 });
+ // 卫星:沿轨道落在星舰身后,一粒一粒放出来(12fps)
+ const n = Math.min(26, Math.max(0, Math.floor((st - tSat2[0]) / ((tSat2[1] - tSat2[0]) / 26)) + 1));
+ for (let i = 0; i < n; i++) { const a = OA + 0.13 + i * 0.0135, rr = ORB + 30 + (i % 2) * 14, x = OC[0] - OW / 2 + Math.cos(a) * rr, y = OC[1] - OH / 2 + Math.sin(a) * rr, age = st - (tSat2[0] + i * (tSat2[1] - tSat2[0]) / 26), k = 1 + 0.6 * (1 - clamp(age / 0.17));
+ c.fillStyle = '#f4f2ec'; c.beginPath(); c.arc(x, y, 11 * k, 0, TAU); c.fill(); c.fillStyle = C.red; c.beginPath(); c.arc(x, y, 4.5 * k, 0, TAU); c.fill(); }
+ c.restore();
+ c.save(); c.translate(400, 150); c.rotate(-0.03); V.label(c, '2026.9.28 · 入轨', 60, { fam: F.heavy, n: TY.typedCount(st, ins0 + 0.05, 14) }); c.restore();
+ if (st >= cue('26颗') - 0.05) { c.save(); c.translate(1420, 230); c.rotate(-0.04); const k = 1 + 0.3 * (1 - MO.quartOut(clamp(step(lt - cue('26颗') + 0.05) / 0.25))); c.scale(k, k); V.label(c, T.n26, 110, { bg: C.red2, padX: 34 }); c.translate(-20, 130); V.label(c, T.s26, 54, { n: TY.typedCount(st, cue('新一代'), 14) }); c.restore(); }
+};
+V.warm.push(() => V.photo('s11orb', OW, OH, orbitDraw, { cell: 8, border: 22, S: 1 }));
+ERAS.find(e => e.id === ID).transition = { type: 'vox_slap', dur: 0.5, punch: 0 };
+V.scene(ID, { cam, shots: [{ t: 0 }, { t: ins0, fn: insertShot }], init() { V.glyphs(ID, [[F.num, '750'], [F.black, T.sx + T.xa + T.unit], [F.bold, T.xs], [F.heavy, T.buy + T.ipo + T.over + T.n26 + T.s26 + '2026.9.28 · 入轨'], [F.type, T.tape + T.kick + '2026.2'], [F.serif, T.head]]); } });
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex_vox/scenes/s12.js b/scripts/engine/reference_films/spacex/spacex_vox/scenes/s12.js
new file mode 100644
index 0000000..f6210fb
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_vox/scenes/s12.js
@@ -0,0 +1,82 @@
+// S12 · 接下来(还没发生的事一律是硫酸纸上的铅笔草图+虚线,和桌上已发生的网点照片区分开)。
+// ①草图:发射塔两只臂夹住飞船(铅笔一笔笔扫出来);②草图:两艘星舰尾对尾,红虚线箭头「加油」;
+// ③地球剪纸到月球网点照片之间,红虚线描出航线「重返月球」;④「再往后,是火星」:红线从月球一路牵到桌子最右边的一颗红色网点火星;
+// ⑤口播结束,相机长尾拉到全桌——24 年的证据铺满整张桌子,「24年」黑标签再落一次(回扣开场)。
+(() => {
+const ID = 's12', V = VOX, C = V.C, F = V.F, PH = V.PH, TAU = Math.PI * 2;
+const { clamp, lerp } = U, seg = MO.seg, step = V.step;
+const cell = V.cell(ID), X0 = cell.x, Y0 = cell.y, xy = (x, y) => ({ x: X0 + x, y: Y0 + y });
+const cue = k => TM.cue(ID, k), G = k => V.cue(ID, k), t0 = V.t0(ID);
+const T = { catch: '用筷子夹住飞船', fuel: '太空加油', moon: '重返月球', mars: '火星', plan: '计划', earth: '地球' };
+const GR = 'rgba(52,52,48,.95)', NONE = 'rgba(0,0,0,0)';
+const pencil = { body: 'rgba(80,80,74,.10)', dark: 'rgba(80,80,74,.25)', nose: 'rgba(255,255,255,.18)', engine: 'rgba(80,80,74,.3)', window: NONE, trunk: NONE, flap: 'rgba(80,80,74,.2)', tiles: 'rgba(80,80,74,.12)', truss: 'rgba(80,80,74,.25)', line: GR, lw: 0.95 };
+// 硫酸纸+铅笔草图(缓存),用之字形「揭开」模拟一笔笔画出来
+const sheet = (key, w, h) => V.spr('s12sh' + key, w, h, (g) => { g.fillStyle = 'rgba(248,248,242,.55)'; CL.tornRect(g, w, h, key.length * 17, 4); g.fill(); g.strokeStyle = 'rgba(255,255,255,.7)'; g.lineWidth = 2; g.stroke(); }, { sh: { blur: 6, y: 3, col: 'rgba(50,40,25,.18)' } });
+const trace = (key, w, h, draw, dash = [14, 9]) => V.spr('s12' + key, w, h, (g) => { g.save(); g.setLineDash(dash); draw(g, w, h); g.restore(); }, { shadow: false });
+const reveal = (g, sp, w, h, q, rows = 7, bx = [-w / 2, -h / 2, w, h]) => { if (q <= 0) return; if (q >= 1) { V.blit(g, sp); return; } const pts = DG.zigzag(bx[0], bx[1], bx[2], bx[3], rows), L = DG.cum(pts), m = DG.revealMask(pts, L, L[L.length - 1] * q, h / rows * 1.25); g.save(); g.clip(m); V.blit(g, sp); g.restore(); if (q < 1) { const tip = DG.pointAt(pts, L, L[L.length - 1] * q); g.save(); g.translate(tip[0], tip[1]); g.rotate(-0.6); g.fillStyle = '#d7b46a'; g.fillRect(0, -6, 70, 12); g.fillStyle = '#3a3a36'; g.beginPath(); g.moveTo(0, -6); g.lineTo(-16, 0); g.lineTo(0, 6); g.fill(); g.restore(); } };
+V.item({ key: 's12bg', ...xy(1180, 1120), r: 0.008, z: 5, at: t0 - 1, draw(g) { V.blit(g, V.spr('s12bg', 1700, 1250, (gg, w, h) => V.paper(gg, w, h, 97, { col: '#d9cba9', amp: 6, age: 0.3 }), { sh: { blur: 14, y: 8 } })); V.tape(g, -790, -590, -0.6, 150); V.tape(g, 790, -590, 0.55, 150); } });
+// ① 塔夹飞船
+const S1W = 760, S1H = 980, S1 = xy(600, 1000), S1t = [-0.25 + t0, G('飞船') + 0.1];
+const sk1 = () => trace('catch', S1W, S1H, (g, w, h) => { // 铅笔实线:塔(下半截画出纸外)、两只臂合拢、臂间夹着一艘飞船
+ const s = 6.2, base = h + 220, tx = w * 0.68; RK.at(g, tx, base, s, 0, q => RK.fill(q, RK.tower({ armY: 100, open: 0, len: 28 }), pencil));
+ RK.at(g, tx - 22 * s, base - 100 * s + 40 * s, s, 0, q => RK.fill(q, RK.ship(), pencil));
+ g.strokeStyle = GR; g.lineWidth = 3; g.strokeRect(tx, base - 146 * s, 12 * s, 146 * s); // 塔身外框连续描一遍(不再断成几段)
+ g.strokeStyle = 'rgba(52,52,48,.35)'; g.lineWidth = 2; for (let k = 0; k < 14; k++) { const y = base - 100 * s - 30 + k * 4; g.beginPath(); g.moveTo(tx - 28 * s, y); g.lineTo(tx - 28 * s + 30, y - 18); g.stroke(); }
+}, []);
+V.item({ key: 's12s1', ...S1, r: -0.025, z: 12, at: t0 - 1, draw(g, T_) {
+ V.blit(g, sheet('catch', S1W, S1H)); V.tape(g, -S1W / 2 + 40, -S1H / 2 + 14, -0.6, 110); V.tape(g, S1W / 2 - 40, -S1H / 2 + 14, 0.55, 110); reveal(g, sk1(), S1W, S1H, MO.cubicOut(seg(step(T_), S1t[0], S1t[1])), 6, [-200, -S1H / 2, 460, S1H]);
+ g.save(); g.translate(-60, -S1H / 2 + 70); g.rotate(0.02); V.label(g, T.catch, 46, { bg: C.card, col: C.ink, n: V.nTyped(T_, G('用筷子'), 12) }); g.restore();
+} });
+// ② 两艘星舰尾对尾加油
+const S2W = 640, S2H = 300, S2 = xy(1360, 720), S2t = [G('飞船') - 0.05, G('加油') + 0.15];
+const sk2 = () => trace('fuel', S2W, S2H, (g, w, h) => { RK.at(g, w / 2 - 6, h / 2, 5.0, -Math.PI / 2, q => RK.fill(q, RK.ship(), pencil)); RK.at(g, w / 2 + 6, h / 2, 5.0, Math.PI / 2, q => RK.fill(q, RK.ship(), pencil)); });
+const FA = V.handPts('s12fa', [[-150, -96], [-40, -122], [80, -110], [150, -80]], { amp: 1.4, seed: 4 });
+V.item({ key: 's12s2', ...S2, r: 0.02, z: 12, at: G('飞船') - 0.4, enter: { from: [420, -160], tilt: 0.14, dur: 0.35 }, draw(g, T_) {
+ const st = step(T_); V.blit(g, sheet('fuel', S2W, S2H)); V.tape(g, 0, -S2H / 2 + 6, 0.04, 120); reveal(g, sk2(), S2W, S2H, MO.sineInOut(seg(st, S2t[0], S2t[1])), 4);
+ g.save(); g.setLineDash([18, 12]); V.pen(g, FA, MO.sineInOut(seg(st, G('加油') - 0.1, G('加油') + 0.3)), { lw: 7 }); g.restore();
+ if (st >= G('加油')) { g.save(); g.translate(150, -80); g.rotate(0.5); g.strokeStyle = C.red; g.lineWidth = 7; g.lineCap = 'round'; g.beginPath(); g.moveTo(-26, -18); g.lineTo(0, 0); g.lineTo(-26, 18); g.stroke(); g.restore(); g.save(); g.translate(0, -170); V.label(g, T.fuel, 46, { bg: C.card, col: C.ink, n: V.nTyped(T_, G('加油'), 10) }); g.restore(); }
+} });
+// ③ 地球 → 月球
+const ER = 165, MR = 105, EP = xy(1000, 1480), MP = xy(1660, 1290);
+const earth = () => V.cutout('s12earth', ER * 2, ER * 2, (g) => PH.globe(g, ER, ER, ER, 4), { cell: 4, edge: 5 });
+const moon = () => V.cutout('s12moon', MR * 2, MR * 2, (g) => PH.moon(g, MR, MR, MR, 31, '#e0e0e0'), { cell: 5, edge: 6 });
+const ROUTE = (() => { const a = [EP.x + ER, EP.y - 30], b = [MP.x - MR - 10, MP.y + 20], o = []; for (let i = 0; i <= 50; i++) { const u = i / 50; o.push([lerp(a[0], b[0], u), lerp(a[1], b[1], u) - Math.sin(u * Math.PI) * 160]); } return { p: o, L: DG.cum(o) }; })();
+V.item({ key: 's12earth', ...EP, z: 11, at: G('争取') - 0.3, enter: { from: [-200, 260], tilt: -0.2, dur: 0.35 }, draw(g) { V.blit(g, earth()); g.save(); g.translate(ER * 0.75, -ER - 10); g.rotate(-0.04); V.label(g, T.earth, 44, { bg: C.card, col: C.ink }); g.restore(); } });
+V.item({ key: 's12moon', ...MP, z: 11, at: G('争取') - 0.1, enter: { from: [300, 260], tilt: 0.2, dur: 0.4 }, draw(g, T_) { V.blit(g, moon()); V.tape(g, 0, -MR - 2, 0.05, 110); if (step(T_) >= G('月球') - 0.05) { g.save(); g.translate(0, -MR - 70); g.rotate(-0.03); V.label(g, T.moon, 56, { n: V.nTyped(T_, G('月球') - 0.05, 10) }); g.restore(); } } });
+V.item({ key: 's12route', x: (EP.x + MP.x) / 2, y: EP.y - 150, z: 13, rad: 900, at: G('把美国') - 0.1, draw(g, T_) {
+ const q = MO.sineInOut(seg(step(T_), G('把美国') - 0.05, G('月球') + 0.1)), Lq = ROUTE.L[ROUTE.L.length - 1] * q;
+ g.save(); g.translate(-(EP.x + MP.x) / 2, -(EP.y - 150)); g.setLineDash([22, 16]); CL.string(g, ROUTE.p, ROUTE.L, Lq, { col: C.red, lw: 7, shadow: null }); g.setLineDash([]);
+ const tip = DG.pointAt(ROUTE.p, ROUTE.L, Lq); g.fillStyle = C.red; g.beginPath(); g.arc(tip[0], tip[1], 13, 0, TAU); g.fill(); g.restore();
+} });
+// ④ 红线牵到桌子最右边的火星
+const MARS = xy(2150, 880), MRR = 140;
+const mars = () => V.cutout('s12mars', MRR * 2, MRR * 2, (g) => PH.moon(g, MRR, MRR, MRR, 47, '#d6d6d6'), { cell: 6, edge: 7, ink: C.red2 });
+const SM = (() => { const a = [MP.x + MR * 0.7, MP.y - MR * 0.7], b = [MARS.x - MRR * 0.75, MARS.y + MRR * 0.6], pts = CL.stringPts(a, b, 0.06); return { a, b, pts, cum: DG.cum(pts) }; })();
+V.item({ key: 's12mars', ...MARS, z: 11, at: G('再往后') + 0.3, enter: { from: [380, -200], tilt: 0.22, dur: 0.4 }, draw(g, T_) { V.blit(g, mars()); V.tape(g, -MRR + 30, -MRR + 30, -0.7, 120); const tm = G('再往后') + 0.65; if (step(T_) >= tm) { g.save(); g.translate(0, MRR + 70); g.rotate(0.03); V.label(g, T.mars, 72, { bg: C.red2, n: V.nTyped(T_, tm, 8) }); g.restore(); } } });
+V.item({ key: 's12str', x: (SM.a[0] + SM.b[0]) / 2, y: (SM.a[1] + SM.b[1]) / 2, z: 48, rad: 900, at: G('再往后') - 0.05, draw(g, T_) {
+ const q = MO.sineInOut(seg(step(T_), G('再往后') - 0.05, G('再往后') + 0.75)); g.save(); g.translate(-(SM.a[0] + SM.b[0]) / 2, -(SM.a[1] + SM.b[1]) / 2);
+ CL.string(g, SM.pts, SM.cum, SM.cum[SM.cum.length - 1] * q, { col: C.red, lw: Math.max(5, 2.4 / V.zoom) }); V.pin(g, SM.a[0], SM.a[1]); if (q >= 1) V.pin(g, SM.b[0], SM.b[1]); g.restore();
+} });
+// ⑤ 全桌:「24年」再落一次
+V.item({ key: 's12big', x: 5750, y: 1975, r: 0.012, z: 60, rad: 3000, at: t0 + TM.cue(ID, '火星') + 0.85, enter: { drop: 0.3, dur: 0.3 }, draw(g) { g.scale(0.68, 0.68);
+ V.blit(g, V.spr('s12big', 1500, 640, (gg, w, h) => { gg.save(); CL.tornRect(gg, w, h, 57, 6); gg.fillStyle = C.black; gg.fill(); gg.restore(); V.text(gg, '24', 120, h / 2 + 205, 560, F.num, C.yel); V.text(gg, '年', 120 + 470, h / 2 + 200, 420, F.heavy, C.paper); }, { S: 0.6, pad: 40, sh: { blur: 30, y: 20 } }));
+} });
+
+// ---------- 相机 ----------
+const at = (x, y, z, sy) => V.at(X0 + x, Y0 + y, z, sy);
+const OV0 = V.overview(), OV = { ...OV0, y: OV0.y + 220, z: OV0.z * 0.92 }, vEnd = TM.vo(ID)[1];
+const cam = (lt) => CAM.at([
+ V.key(0, V.camEnd('s11')),
+ V.key(0.6, at(1000, 950, 0.98), MO.longTail),
+ V.key(cue('在太空') - 0.15, at(1000, 945, 1.03), MO.sineInOut),
+ V.key(cue('在太空') + 0.3, at(1340, 780, 1.12), MO.cubicInOut),
+ V.key(cue('争取') - 0.05, at(1340, 790, 1.15), MO.sineInOut),
+ V.key(cue('争取') + 0.45, at(1330, 1270, 0.98), MO.cubicInOut),
+ V.key(cue('再往后') - 0.05, at(1340, 1270, 1.03), MO.sineInOut),
+ V.key(cue('再往后') + 0.85, at(1820, 1020, 0.95), MO.longTail), // 沿红线追到火星
+ V.key(cue('火星') - 0.15, at(1840, 1020, 0.98), MO.sineInOut),
+ V.key(cue('火星') + 0.95, OV, MO.longTail), // 拉出揭示:整张桌子,留足一拍
+ V.key(TM.dur(ID) + 0.01, { ...OV, z: OV.z * 1.015 }, MO.sineInOut),
+], lt);
+V.scene(ID, { cam, init() { V.prewarm(); V.glyphs(ID, [[F.heavy, T.catch + T.fuel + T.moon + T.mars + T.earth + '年'], [F.num, '24']]); } });
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex_wb/assets/ARPHICPL.TXT b/scripts/engine/reference_films/spacex/spacex_wb/assets/ARPHICPL.TXT
new file mode 100644
index 0000000..de7491a
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_wb/assets/ARPHICPL.TXT
@@ -0,0 +1,58 @@
+ARPHIC PUBLIC LICENSE
+
+Copyright (C) 1999 Arphic Technology Co., Ltd.
+11Fl. No.168, Yung Chi Rd., Taipei, 110 Taiwan
+All rights reserved except as specified below.
+
+Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is forbidden.
+
+Preamble
+
+ The licenses for most software are designed to take away your freedom to share and change it. By contrast, the ARPHIC PUBLIC LICENSE specifically permits and encourages you to use this software, provided that you give the recipients all the rights that we gave you and make sure they can get the modifications of this software.
+
+Legal Terms
+
+0. Definitions:
+ Throughout this License, "Font" means the TrueType fonts "AR PL Mingti2L Big5", "AR PL KaitiM Big5" (BIG-5 character set) and "AR PL SungtiL GB", "AR PL KaitiM GB" (GB character set) which are originally distributed by Arphic, and the derivatives of those fonts created through any modification including modifying glyph, reordering glyph, converting format, changing font name, or adding/deleting some characters in/from glyph table.
+
+ "PL" means "Public License".
+
+ "Copyright Holder" means whoever is named in the copyright or copyrights for the Font.
+
+ "You" means the licensee, or person copying, redistributing or modifying the Font.
+
+ "Freely Available" means that you have the freedom to copy or modify the Font as well as redistribute copies of the Font under the same conditions you received, not price. If you wish, you can charge for this service.
+
+1. Copying & Distribution
+ You may copy and distribute verbatim copies of this Font in any medium, without restriction, provided that you retain this license file (ARPHICPL.TXT) unaltered in all copies.
+
+2. Modification
+ You may otherwise modify your copy of this Font in any way, including modifying glyph, reordering glyph, converting format, changing font name, or adding/deleting some characters in/from glyph table, and copy and distribute such modifications under the terms of Section 1 above, provided that the following conditions are met:
+
+ a) You must insert a prominent notice in each modified file stating how and when you changed that file.
+
+ b) You must make such modifications Freely Available as a whole to all third parties under the terms of this License, such as by offering access to copy the modifications from a designated place, or distributing the modifications on a medium customarily used for software interchange.
+
+ c) If the modified fonts normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the Font under these conditions, and telling the user how to view a copy of this License.
+
+ These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Font, and can be reasonably considered independent and separate works in themselves, then this License and its terms, do not apply to those sections when you distribute them as separate works. Therefore, mere aggregation of another work not based on the Font with the Font on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
+
+3. Condition Subsequent
+ You may not copy, modify, sublicense, or distribute the Font except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Font will automatically retroactively void your rights under this License. However, parties who have received copies or rights from you under this License will keep their licenses valid so long as such parties remain in full compliance.
+
+4. Acceptance
+ You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to copy, modify, sublicense or distribute the Font. These actions are prohibited by law if you do not accept this License. Therefore, by copying, modifying, sublicensing or distributing the Font, you indicate your acceptance of this License and all its terms and conditions.
+
+5. Automatic Receipt
+ Each time you redistribute the Font, the recipient automatically receives a license from the original licensor to copy, distribute or modify the Font subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
+
+6. Contradiction
+ If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Font at all. For example, if a patent license would not permit royalty-free redistribution of the Font by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Font.
+
+ If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
+
+7. NO WARRANTY
+ BECAUSE THE FONT IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE FONT, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS OR OTHER PARTIES PROVIDE THE FONT "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE FONT IS WITH YOU. SHOULD THE FONT PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+8. DAMAGES WAIVER
+ UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, IN NO EVENT WILL ANY COPYRIGHTT HOLDERS, OR OTHER PARTIES WHO MAY COPY, MODIFY OR REDISTRIBUTE THE FONT AS PERMITTED ABOVE, BE LIABLE TO YOU FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR EXEMPLARY DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE FONT (INCLUDING BUT NOT LIMITED TO PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA OR PROFITS; OR BUSINESS INTERRUPTION), EVEN IF SUCH HOLDERS OR OTHER PARTIES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
\ No newline at end of file
diff --git a/scripts/engine/reference_films/spacex/spacex_wb/assets/hand_1.png b/scripts/engine/reference_films/spacex/spacex_wb/assets/hand_1.png
new file mode 100644
index 0000000..a8146eb
Binary files /dev/null and b/scripts/engine/reference_films/spacex/spacex_wb/assets/hand_1.png differ
diff --git a/scripts/engine/reference_films/spacex/spacex_wb/assets/hand_2.png b/scripts/engine/reference_films/spacex/spacex_wb/assets/hand_2.png
new file mode 100644
index 0000000..29e9420
Binary files /dev/null and b/scripts/engine/reference_films/spacex/spacex_wb/assets/hand_2.png differ
diff --git a/scripts/engine/reference_films/spacex/spacex_wb/assets/hand_3.png b/scripts/engine/reference_films/spacex/spacex_wb/assets/hand_3.png
new file mode 100644
index 0000000..1a611d7
Binary files /dev/null and b/scripts/engine/reference_films/spacex/spacex_wb/assets/hand_3.png differ
diff --git a/scripts/engine/reference_films/spacex/spacex_wb/assets/make_hand.py b/scripts/engine/reference_films/spacex/spacex_wb/assets/make_hand.py
new file mode 100644
index 0000000..81d0b8c
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_wb/assets/make_hand.py
@@ -0,0 +1,19 @@
+# 握笔手三姿势:hand_raw_N.png(gpt-image 生成,绿幕;2、3 以 1 为参考图)→ hand_N.png(去绿、保留 1024 原坐标,缩到 640)
+# 并量出:笔尖 tip、袖子出画的上沿点 U / 下沿点 L、袖子方向 d(都是 1024 坐标)→ 打印成 JS 常量,贴进 common.js 的 HANDS。
+# 用法:python3 make_hand.py
+import json, numpy as np
+from PIL import Image
+TIPDIR = {1: (1, 1), 2: (1, 0.3), 3: (0.5, 1)} # 笔尖朝哪个方向最远:取 x*a+y*b 最小的不透明像素
+out = {}
+for n in (1, 2, 3):
+ im = np.asarray(Image.open(f'hand_raw_{n}.png').convert('RGB').resize((1024, 1024))).astype(np.float32); r, g, b = im[..., 0], im[..., 1], im[..., 2]
+ spill = g - np.maximum(r, b); al = 1 - np.clip((spill - 30) / 70, 0, 1)
+ g2 = np.where(spill > 0, np.minimum(g, np.maximum(r, b) + 0.25 * np.clip(spill, 0, 30)), g)
+ Image.fromarray(np.dstack([r, g2, b, al * 255]).clip(0, 255).astype(np.uint8), 'RGBA').resize((640, 640), Image.LANCZOS).save(f'hand_{n}.png', optimize=True)
+ a = al > 0.5; ys, xs = np.where(a); A, B = TIPDIR[n]; i = np.argmin(xs * A + ys * B); tip = [int(xs[i]), int(ys[i])]
+ ry = np.where(a[:, 1023])[0]; bx = np.where(a[1023])[0]
+ U = [1023, int(ry.min())]; L = [int(bx.min()), 1023] if len(bx) else [1023, int(ry.max())]
+ cols = range(840, 1024, 8); tops = [(x, np.where(a[:, x])[0].min()) for x in cols if a[:, x].any()]
+ k = np.polyfit([p[0] for p in tops], [p[1] for p in tops], 1)[0]; d = np.array([1, k]); d = (d / np.linalg.norm(d)).round(3).tolist()
+ out[n] = {'tip': tip, 'U': U, 'L': L, 'd': d}
+print(json.dumps(out))
diff --git a/scripts/engine/reference_films/spacex/spacex_wb/assets/strokes.js b/scripts/engine/reference_films/spacex/spacex_wb/assets/strokes.js
new file mode 100644
index 0000000..a449d40
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_wb/assets/strokes.js
@@ -0,0 +1,2 @@
+// 汉字笔顺中线(来源:hanzi-writer-data 2.0.1 / Make Me a Hanzi,Arphic 公共许可):只用来决定「按笔顺露出字」的路径,字形本身仍是霞鹜文楷
+window.WB_STROKES = {"年":[[[375,845],[402,804],[358,712],[298,635],[267,604],[216,567]],[[385,693],[473,691],[689,735],[735,733]],[[345,510],[379,494],[665,542],[733,534]],[[287,518],[318,492],[328,470],[342,358],[346,345],[361,332]],[[83,293],[109,281],[158,275],[451,316],[815,347],[872,341],[929,318]],[[490,668],[536,641],[544,630],[531,-76]]],"连":[[[408,647],[430,640],[493,639],[733,682],[787,683]],[[551,833],[582,788],[518,591],[454,442],[491,436],[706,472],[760,473],[790,466]],[[366,281],[418,272],[576,295],[780,315],[837,311],[883,297]],[[590,571],[622,538],[611,105]],[[218,767],[307,707],[330,670]],[[93,470],[143,474],[241,511],[266,506],[282,492],[277,449],[243,386],[236,354],[247,312],[286,237],[294,207],[293,193],[284,186]],[[96,128],[139,118],[229,156],[303,159],[377,137],[577,54],[697,21],[786,13],[913,38]]],"败":[[[157,686],[191,651],[200,597],[199,423],[181,282],[183,232]],[[216,672],[236,664],[296,682],[371,695],[383,691],[409,661],[402,535],[406,322],[399,256]],[[263,578],[278,573],[306,548],[299,340],[273,190],[244,127],[204,81],[134,33],[109,27]],[[323,182],[399,122],[419,82]],[[580,799],[608,777],[621,756],[597,671],[534,535],[495,466],[453,411]],[[557,520],[569,526],[644,529],[809,577],[859,575]],[[666,502],[704,475],[703,434],[693,349],[658,244],[635,201],[604,162],[533,112],[473,87]],[[494,390],[543,356],[654,201],[767,90],[799,69],[954,38]]],"三":[[[316,655],[367,645],[416,648],[660,692],[722,692]],[[331,407],[375,405],[628,443],[657,443],[700,432]],[[127,152],[158,142],[195,139],[500,178],[846,204],[881,200],[955,174]]],"次":[[[196,639],[282,575],[306,529]],[[118,228],[141,203],[166,190],[173,195],[338,419]],[[519,807],[538,794],[558,768],[538,675],[490,559],[455,504],[397,437]],[[523,559],[738,616],[781,610],[800,588],[796,570],[692,461]],[[508,438],[546,402],[544,369],[527,280],[485,190],[439,137],[402,109],[332,72],[263,54]],[[572,326],[577,297],[634,225],[698,152],[759,96],[795,69],[938,46]]],"最":[[[335,775],[364,749],[404,562]],[[394,768],[405,760],[590,796],[629,797],[652,789],[666,773],[671,749],[619,602],[596,595]],[[406,664],[417,673],[480,688],[547,697],[584,694]],[[425,587],[433,597],[570,613],[590,625]],[[161,464],[208,456],[490,502],[748,528],[823,512]],[[262,444],[288,421],[288,194],[274,179]],[[427,473],[452,444],[451,243],[441,29],[453,-44]],[[318,354],[326,368],[354,378],[406,380]],[[315,258],[324,272],[341,277],[386,287],[406,284]],[[169,136],[224,122],[408,190],[516,237]],[[524,379],[589,380],[674,407],[708,406],[728,396],[714,337],[676,242],[637,187],[599,153],[558,128],[506,109],[477,105]],[[504,327],[550,303],[673,171],[771,96],[789,88],[946,68]]],"后":[[[711,747],[627,762],[543,710],[451,668],[364,639],[360,628]],[[272,662],[300,639],[314,620],[314,610],[299,442],[267,306],[232,225],[187,160],[123,98],[66,66]],[[334,461],[357,451],[378,450],[539,486],[789,525],[837,520],[873,508]],[[337,296],[362,275],[376,249],[416,16]],[[395,292],[408,282],[425,279],[567,302],[678,329],[703,330],[726,321],[760,284],[718,162],[683,132]],[[438,53],[453,68],[482,74],[681,99],[732,98],[764,86]]],"一":[[[121,393],[193,372],[417,402],[827,434],[920,401]]],"发":[[[270,680],[303,634],[289,560],[272,512],[270,481],[321,485],[491,538],[627,565],[747,578],[804,561]],[[462,833],[513,787],[504,700],[474,579],[411,435],[351,330],[272,228],[195,154],[96,87]],[[410,372],[469,382],[598,421],[613,417],[639,392],[612,297],[588,243],[552,187],[504,136],[460,106],[404,82],[283,50],[242,47]],[[389,317],[438,296],[583,158],[655,101],[730,52],[744,45],[804,38],[943,29]],[[653,769],[747,706],[767,673]]],"成":[[[309,521],[327,510],[357,513],[570,565],[644,590],[713,598]],[[231,539],[263,515],[273,492],[268,337],[249,229],[229,173],[197,118],[153,68],[97,30]],[[300,322],[334,344],[419,362],[434,362],[454,343],[447,252],[435,191],[409,134],[392,118],[327,162]],[[452,841],[507,790],[524,616],[552,493],[616,315],[667,217],[700,168],[760,98],[814,49],[849,25],[893,12],[908,15],[918,44],[938,177]],[[722,463],[748,425],[723,347],[682,265],[650,219],[600,167],[499,93]],[[653,777],[727,741],[763,708]]],"了":[[[228,705],[296,678],[401,712],[502,736],[666,768],[699,764],[716,739],[721,715],[534,568],[513,563]],[[461,574],[532,506],[551,451],[564,290],[556,153],[541,101],[515,68],[470,84],[367,141]]],"同":[[[224,749],[257,713],[266,684],[271,521],[249,228],[228,128],[227,63]],[[292,729],[315,713],[708,784],[744,771],[772,742],[770,682],[791,210],[788,92],[771,50],[763,50],[713,59],[625,92]],[[377,577],[387,572],[439,571],[575,603],[628,604]],[[360,443],[385,421],[391,406],[421,243]],[[416,420],[433,433],[541,459],[562,463],[586,455],[608,433],[583,349],[562,333]],[[440,280],[454,291],[553,308],[591,308],[615,300]]],"天":[[[326,698],[350,691],[403,691],[654,741],[700,747],[727,744]],[[179,421],[204,414],[238,414],[519,462],[749,490],[800,484],[839,472]],[[438,664],[485,643],[491,633],[466,401],[450,336],[424,268],[394,216],[340,158],[212,87],[134,63]],[[505,431],[510,408],[533,366],[596,270],[714,122],[771,78],[947,35]]],"星":[[[296,749],[338,699],[387,499]],[[320,756],[368,740],[624,776],[683,769],[712,731],[685,672],[641,537]],[[393,619],[400,627],[446,638],[550,656],[587,650]],[[407,523],[424,535],[450,540],[606,557],[618,563]],[[317,462],[330,446],[338,422],[316,380],[260,304],[184,242]],[[334,351],[493,363],[682,398],[725,396]],[[336,207],[386,198],[611,234],[677,228]],[[477,497],[492,488],[515,455],[510,103],[493,84]],[[116,25],[188,5],[372,44],[464,57],[558,66],[682,66],[837,59],[934,19]]],"舰":[[[337,828],[360,812],[369,796],[291,674],[284,654],[266,637]],[[192,645],[214,630],[228,608],[233,458],[223,321],[201,223],[177,153],[135,66],[106,26]],[[260,612],[271,623],[368,650],[396,634],[406,620],[403,488],[413,201],[409,91],[394,61],[360,68],[282,98]],[[295,543],[329,493],[332,479]],[[72,350],[122,331],[178,353],[361,406],[378,420]],[[275,313],[321,266],[332,229]],[[504,709],[529,682],[535,643],[533,455],[519,366],[519,312]],[[551,695],[573,691],[721,737],[738,734],[769,701],[763,635],[766,387],[759,322]],[[600,624],[619,615],[644,589],[625,363],[612,307],[570,201],[535,147],[494,106],[459,85]],[[648,358],[681,305],[670,215],[675,96],[689,64],[713,48],[799,35],[885,42],[935,57],[944,64],[946,78],[948,211]]],"入":[[[499,510],[499,455],[403,320],[273,191],[191,131],[115,88]],[[342,683],[416,659],[466,608],[512,537],[580,405],[638,308],[732,184],[763,157],[780,150],[970,92]]],"轨":[[[148,602],[202,598],[370,642],[442,651]],[[298,819],[330,762],[253,549],[193,409],[186,374],[231,373],[396,421],[424,415]],[[306,507],[335,471],[322,77],[333,-12]],[[100,206],[155,189],[452,313]],[[587,740],[628,698],[618,544],[589,370],[558,272],[501,147],[416,30]],[[448,462],[474,457],[514,462],[644,500],[718,530],[758,530],[769,520],[746,405],[737,276],[744,201],[753,164],[775,116],[792,92],[843,47],[880,31],[910,31],[927,77],[946,202]]],"马":[[[289,716],[339,709],[439,733],[570,755],[609,751],[630,735],[645,717],[623,635],[605,507],[589,443]],[[331,643],[351,626],[372,595],[354,412],[360,360],[403,356],[560,388],[719,406],[782,400],[812,370],[762,134],[746,81],[723,38],[698,18],[669,28],[569,86]],[[127,185],[188,171],[385,207],[613,234],[688,212]]],"斯":[[[134,601],[177,597],[238,607],[469,665],[516,661]],[[215,741],[253,696],[256,647],[254,328],[238,314]],[[392,813],[425,788],[438,770],[423,376],[418,360],[406,349]],[[281,501],[290,514],[317,522],[349,527],[369,523]],[[280,402],[299,420],[348,428],[369,423]],[[47,263],[82,253],[119,255],[465,335],[516,332]],[[290,203],[257,196],[222,149],[171,99],[106,54]],[[376,247],[414,211],[433,181]],[[751,783],[774,741],[710,682],[633,626],[631,619]],[[554,635],[591,607],[597,581],[596,428],[579,315],[565,269],[528,197],[476,135],[425,100]],[[631,483],[642,490],[654,488],[856,531],[893,532],[939,521]],[[728,481],[770,451],[767,-41]]],"克":[[[264,632],[319,623],[637,682],[686,684],[721,677]],[[452,840],[492,797],[451,533],[431,512]],[[263,489],[289,470],[307,438],[339,295]],[[318,489],[342,477],[441,490],[556,516],[598,514],[634,475],[602,400],[564,372]],[[357,305],[377,317],[565,345],[622,348],[646,339]],[[366,266],[384,224],[358,175],[319,123],[240,58],[154,16]],[[490,313],[527,285],[535,269],[524,157],[531,65],[555,28],[602,6],[656,-3],[766,-5],[843,6],[898,29],[903,81],[900,194]]],"目":[[[281,723],[309,693],[320,667],[321,645],[317,286],[302,147],[308,76]],[[338,711],[365,698],[385,700],[636,747],[665,730],[687,706],[697,152],[683,110],[605,132]],[[348,498],[368,510],[516,532],[578,532]],[[346,342],[365,353],[462,359],[540,372],[581,369]],[[335,121],[361,139],[483,152],[576,160],[626,150]]],"标":[[[111,512],[134,508],[183,513],[370,572],[419,573]],[[265,808],[317,753],[300,202],[287,103],[287,7]],[[281,509],[275,504],[259,416],[227,354],[149,238],[66,143]],[[338,463],[351,438],[373,422],[384,404]],[[513,573],[574,569],[717,608],[785,612]],[[438,397],[469,392],[506,396],[658,428],[810,451],[895,438]],[[603,389],[634,366],[635,357],[642,125],[635,84],[621,61],[496,103]],[[480,268],[459,209],[414,128]],[[745,284],[849,197],[868,166],[878,131]]],"别":[[[194,704],[223,675],[252,484]],[[256,669],[268,684],[282,689],[417,724],[449,719],[475,694],[445,598],[419,579]],[[275,530],[285,523],[302,524],[413,549],[471,542]],[[138,368],[185,358],[429,407],[458,409],[483,395],[491,382],[470,245],[452,170],[426,102],[407,79],[386,68],[305,126]],[[308,498],[339,478],[329,394],[298,282],[268,217],[231,157],[170,84],[116,36]],[[602,595],[631,562],[633,256]],[[760,788],[777,780],[811,748],[811,461],[824,75],[804,25],[754,39],[679,72],[677,78],[666,78]]],"的":[[[278,780],[303,766],[314,753],[313,740],[225,565],[216,559],[212,543],[196,533]],[[135,540],[157,518],[174,485],[185,219],[196,166]],[[188,518],[225,512],[356,552],[381,543],[400,520],[391,288],[382,213],[365,182],[369,130]],[[208,364],[225,372],[291,383],[325,382]],[[215,177],[231,194],[292,202],[323,214]],[[630,839],[651,822],[672,790],[648,723],[613,651],[534,518],[470,444]],[[577,537],[775,572],[805,568],[834,541],[827,499],[816,261],[801,171],[772,87],[753,58],[719,32],[621,94],[619,102],[604,107]],[[517,386],[594,325],[619,279]]],"球":[[[147,616],[208,616],[332,654],[380,655]],[[139,397],[169,394],[218,403],[328,440],[366,437]],[[293,596],[266,579],[266,288],[260,253],[249,241]],[[87,176],[140,162],[384,272]],[[430,546],[474,542],[683,590],[729,596],[759,592]],[[560,814],[601,783],[606,769],[598,623],[604,101],[599,71],[583,40],[466,83]],[[429,440],[480,409],[509,376]],[[344,184],[385,176],[396,182],[540,304]],[[825,468],[790,479],[669,365],[661,368]],[[623,386],[637,356],[690,302],[803,207],[853,190],[982,168]],[[730,753],[806,712],[839,672]]],"猎":[[[338,780],[355,759],[364,734],[322,653],[227,531],[178,490],[132,463]],[[161,696],[179,672],[215,654],[257,620],[296,573],[327,512],[351,391],[351,222],[340,147],[321,88],[296,59],[191,116]],[[305,484],[295,413],[259,358],[166,246],[71,163]],[[449,569],[483,561],[529,563],[759,615],[812,616]],[[498,729],[539,684],[551,460],[538,441]],[[681,816],[724,773],[686,479],[667,459]],[[409,404],[462,399],[615,428],[812,455],[846,455],[902,440]],[[477,311],[493,296],[499,278],[504,210],[489,84],[490,41]],[[520,306],[537,299],[558,301],[707,333],[730,325],[741,314],[748,301],[749,138],[738,89],[749,9]],[[528,182],[538,192],[604,208],[634,212],[664,207]],[[518,68],[534,80],[652,99],[664,99],[686,82]]],"鹰":[[[469,860],[542,829],[563,803]],[[321,742],[351,728],[696,785],[755,778]],[[254,761],[283,732],[290,711],[271,545],[229,362],[190,265],[142,177],[89,103],[57,70]],[[421,706],[438,676],[425,651],[368,577],[317,536]],[[402,588],[410,554],[402,472],[406,427]],[[573,705],[554,697],[517,636],[457,577]],[[531,623],[539,586],[530,468],[534,427]],[[629,734],[671,705]],[[576,655],[619,651],[681,661],[726,676],[763,675]],[[602,583],[713,608],[749,605]],[[599,523],[719,546],[764,542]],[[651,634],[668,616],[665,503],[656,485]],[[555,448],[732,476],[757,477],[806,467]],[[488,446],[465,444],[427,387]],[[447,350],[455,361],[476,367],[633,398],[657,394],[668,381],[664,332],[652,283],[640,260],[633,251],[614,245],[570,268]],[[476,329],[511,306],[527,287]],[[391,390],[415,358],[407,214],[413,181],[431,179],[660,219],[782,231],[802,224],[820,205],[824,196],[797,76],[767,3],[746,-13],[658,35]],[[223,71],[271,60],[379,80],[626,111],[690,91]]],"号":[[[312,750],[342,727],[349,710],[388,532]],[[373,748],[389,736],[604,777],[627,774],[662,740],[631,650],[604,630]],[[406,556],[423,572],[602,602],[643,603],[672,595]],[[119,433],[182,424],[504,470],[787,495],[830,493],[890,475]],[[414,434],[444,409],[409,318],[408,301],[443,299],[560,327],[606,331],[632,321],[654,301],[648,239],[629,166],[589,79],[564,48],[530,25],[432,103]]],"第":[[[303,804],[328,768],[287,680],[221,597],[175,562]],[[341,707],[353,714],[412,716],[486,735],[530,735]],[[367,649],[400,625],[415,603]],[[595,835],[622,800],[604,754],[567,694],[511,639]],[[632,736],[688,742],[787,764],[819,763]],[[648,683],[703,657],[735,622]],[[312,526],[383,525],[648,573],[669,564],[687,535],[663,482],[637,471]],[[330,404],[345,395],[620,440],[669,439],[686,433]],[[273,425],[293,401],[299,380],[275,263],[307,261],[418,289],[716,333],[765,335],[793,317],[807,291],[775,168],[754,128],[743,119],[728,123],[642,162]],[[481,527],[507,497],[509,451],[506,-52]],[[479,274],[463,251],[457,228],[367,131],[259,46],[167,-2]]],"四":[[[132,606],[163,582],[189,529],[224,229],[244,159]],[[187,595],[227,581],[466,625],[712,650],[801,654],[833,638],[866,588],[816,348],[781,226],[760,193],[755,149]],[[377,587],[408,560],[387,462],[351,379],[298,316]],[[530,611],[571,584],[566,446],[579,393],[608,377],[638,373],[699,371],[732,379]],[[263,216],[285,201],[651,229],[697,224],[706,211]]],"枚":[[[113,498],[181,495],[394,547],[433,547]],[[273,812],[288,802],[325,757],[310,273],[291,72],[291,-17]],[[291,490],[283,484],[268,415],[221,330],[173,256],[61,129]],[[341,396],[405,356],[426,325]],[[598,786],[627,765],[638,747],[626,693],[556,534],[516,465],[477,415]],[[569,501],[577,507],[657,510],[818,559],[867,561]],[[665,482],[692,467],[707,447],[707,398],[695,305],[662,223],[628,178],[575,136],[482,86],[416,67]],[[490,357],[509,354],[530,341],[694,152],[802,58],[965,32]]],"私":[[[503,751],[486,758],[433,763],[300,688],[204,653],[195,656],[171,642]],[[68,448],[128,440],[428,508],[491,515],[514,510]],[[325,676],[357,661],[376,633],[368,335],[349,75],[349,-19]],[[340,459],[310,399],[245,313],[167,230],[83,153],[51,131]],[[393,402],[404,398],[411,385],[466,356],[491,325]],[[659,660],[680,644],[695,619],[631,444],[558,292],[547,243],[580,241],[806,292],[821,286]],[[764,417],[876,282],[893,233],[891,204]]],"人":[[[483,736],[508,702],[511,678],[473,552],[408,416],[328,303],[271,244],[144,139],[72,95]],[[474,477],[477,459],[490,439],[571,333],[691,200],[753,145],[798,119],[986,90]]],"研":[[[136,664],[159,659],[212,661],[361,703],[421,706]],[[230,636],[257,614],[240,552],[209,477],[152,374],[96,303],[58,263],[34,248],[33,241]],[[155,460],[186,419],[217,239]],[[213,435],[234,452],[315,479],[329,479],[351,463],[356,447],[338,357],[316,345]],[[236,277],[250,294],[313,312],[359,315],[377,310]],[[474,661],[512,655],[571,661],[781,707],[836,708]],[[406,388],[443,382],[469,385],[620,416],[848,449],[880,449],[940,436]],[[507,580],[546,546],[547,437],[532,308],[505,225],[480,180],[434,125],[378,84]],[[687,654],[726,635],[737,605],[731,-61]]],"制":[[[249,721],[277,689],[272,673],[229,583],[200,544],[168,522],[166,515]],[[271,599],[284,605],[342,609],[489,648],[524,647]],[[115,447],[166,440],[491,507],[544,513],[582,508]],[[227,361],[246,342],[251,323],[248,214],[237,156],[240,123]],[[280,328],[289,341],[316,347],[455,374],[522,377],[543,357],[544,345],[545,228],[537,186],[527,171],[519,172],[442,199]],[[357,817],[406,766],[392,260],[374,77],[377,-3]],[[633,603],[663,570],[665,439],[657,335],[661,292]],[[774,802],[790,794],[822,762],[814,494],[819,132],[814,101],[798,70],[730,94],[690,112],[688,119],[677,119]]],"进":[[[423,555],[501,549],[727,598],[784,598]],[[385,384],[435,379],[601,409],[785,431],[845,424],[869,411]],[[492,687],[512,676],[530,652],[534,527],[521,401],[502,346],[466,285],[431,246],[398,223]],[[637,791],[683,745],[684,361],[674,225],[677,142]],[[237,767],[319,710],[341,671]],[[85,446],[151,451],[258,491],[272,492],[296,475],[294,438],[259,366],[257,349],[265,314],[304,230],[304,193],[292,182]],[[92,129],[136,116],[226,152],[305,155],[379,135],[587,61],[676,39],[765,28],[824,33],[934,62]]],"道":[[[489,779],[541,737],[558,712]],[[718,839],[732,824],[738,805],[643,700]],[[396,608],[440,602],[618,638],[776,661],[812,662],[868,650]],[[572,606],[592,579],[566,534],[554,522],[541,519]],[[467,511],[489,483],[495,454],[495,314],[488,239],[493,170]],[[514,498],[540,493],[713,534],[740,518],[755,501],[761,224],[749,191],[717,199],[700,219]],[[524,390],[530,400],[602,415],[646,421],[668,415]],[[520,301],[552,316],[630,329],[653,330],[675,323]],[[517,191],[530,205],[692,224]],[[217,751],[290,697],[318,652]],[[117,463],[173,465],[263,496],[277,496],[302,477],[297,433],[266,359],[270,323],[302,260],[308,236],[308,212],[287,187]],[[102,142],[145,127],[249,160],[332,156],[594,63],[752,29],[824,33],[914,58]]],"液":[[[206,747],[284,703],[313,665]],[[128,543],[211,489],[228,466]],[[179,75],[166,104],[161,154],[277,399]],[[515,807],[609,766],[642,730]],[[370,591],[436,586],[600,620],[728,654],[804,662]],[[442,558],[473,527],[445,467],[343,316],[275,248]],[[384,336],[387,309],[397,290],[396,174],[386,62],[391,3]],[[619,572],[643,539],[622,489],[586,433],[510,361]],[[627,450],[731,474],[756,469],[770,453],[732,360],[676,273],[585,171],[521,120],[477,96]],[[564,383],[577,381],[625,352],[639,336]],[[480,322],[521,306],[670,162],[789,80],[819,70],[959,67]]],"体":[[[299,785],[316,770],[334,735],[296,659],[179,486],[104,401],[67,370]],[[226,509],[230,479],[245,448],[245,304],[228,98],[234,38]],[[344,540],[403,537],[514,563],[734,602],[794,603],[842,592]],[[537,817],[577,780],[587,757],[579,197],[565,58],[568,-26]],[[558,545],[544,530],[539,502],[521,461],[447,343],[354,236],[293,187]],[[606,532],[617,502],[699,391],[750,329],[812,269],[968,225]],[[435,212],[469,206],[652,240],[703,236]]],"燃":[[[142,578],[148,520],[139,426]],[[343,651],[354,624],[300,579],[288,554]],[[219,804],[254,778],[267,754],[261,518],[241,311],[224,241],[188,159],[142,100],[79,54]],[[272,335],[285,318],[331,290],[350,258]],[[474,755],[492,739],[500,718],[471,645],[414,543],[368,480],[348,462]],[[477,600],[581,607],[598,589],[563,490],[516,413],[439,321],[382,281]],[[439,548],[484,514],[499,489]],[[400,474],[442,426],[451,398]],[[640,509],[676,505],[713,511],[834,550],[879,551]],[[690,808],[715,797],[740,770],[729,620],[709,494],[679,402],[654,349],[592,266],[555,238]],[[739,482],[737,470],[779,402],[878,281],[972,252]],[[823,696],[874,668],[892,648]],[[399,163],[370,90],[327,18]],[[494,168],[530,108],[541,75]],[[630,170],[680,117],[703,78]],[[790,175],[892,82],[914,22]]],"料":[[[179,642],[233,589],[253,555]],[[455,683],[472,657],[409,579]],[[77,440],[129,431],[401,491],[457,497],[478,493]],[[297,828],[349,774],[339,312],[322,98],[323,7]],[[316,446],[307,441],[287,367],[236,295],[162,214],[70,143]],[[364,347],[430,308],[455,278]],[[557,668],[605,639],[632,611]],[[539,528],[601,494],[617,472]],[[490,368],[527,362],[555,365],[669,389],[890,422],[971,407]],[[670,839],[697,832],[734,798],[727,523],[731,-62]]],"火":[[[216,534],[299,440],[316,391]],[[714,618],[736,593],[744,571],[696,522],[587,433]],[[436,773],[475,753],[497,733],[503,713],[488,443],[470,321],[456,275],[418,195],[368,138],[279,78],[174,36]],[[513,375],[521,341],[606,223],[689,127],[745,76],[768,60],[934,25]]],"箭":[[[308,805],[332,773],[307,710],[269,652],[210,594]],[[342,715],[384,717],[477,737],[510,735]],[[357,665],[396,647],[416,625]],[[575,846],[603,817],[587,766],[553,694],[527,656],[501,631]],[[602,730],[684,742],[748,762],[795,762]],[[638,683],[689,657],[702,644]],[[353,575],[408,549],[421,529]],[[573,619],[593,590],[557,537],[528,509]],[[107,441],[162,431],[401,467],[813,509],[835,508],[902,487]],[[274,377],[298,351],[303,282],[282,107],[268,56],[264,11]],[[324,368],[337,360],[425,383],[461,354],[461,41],[444,14],[361,53]],[[327,242],[333,253],[349,260],[400,259]],[[319,146],[338,165],[386,172],[408,166]],[[559,353],[582,326],[581,119]],[[663,427],[713,377],[710,285],[718,97],[713,36],[693,5],[658,18],[591,57]]],"个":[[[478,800],[498,780],[507,752],[477,686],[415,589],[320,473],[269,423],[198,365],[116,313]],[[522,690],[521,679],[623,568],[726,467],[780,425],[822,408],[976,388]],[[479,494],[490,488],[511,456],[500,70],[515,-13]]],"月":[[[339,773],[379,742],[387,685],[385,504],[366,342],[341,259],[296,169],[236,93],[184,43],[145,17]],[[415,764],[429,752],[503,762],[634,796],[666,780],[681,758],[687,291],[683,93],[664,56],[632,63],[538,104]],[[417,542],[430,550],[535,566],[588,564]],[[399,368],[413,375],[535,394],[588,392]]],"亿":[[[350,812],[369,797],[390,760],[326,640],[198,457],[99,348],[72,327]],[[248,479],[254,446],[268,415],[265,245],[246,58],[252,5]],[[432,577],[526,583],[636,608],[676,602],[684,593],[666,558],[545,407],[499,331],[471,264],[462,205],[469,162],[490,132],[521,111],[603,87],[704,81],[779,87],[870,113],[910,138],[919,306]]],"美":[[[353,789],[418,749],[443,713]],[[604,838],[623,819],[632,800],[529,685]],[[282,604],[343,596],[682,658],[713,656]],[[349,487],[375,482],[449,486],[593,520],[650,521]],[[468,594],[497,569],[501,550],[497,429],[480,406]],[[208,364],[260,353],[460,376],[706,415],[746,416],[791,407]],[[261,229],[281,223],[331,224],[524,255],[678,272],[754,253]],[[436,353],[466,332],[481,310],[466,204],[432,121],[401,77],[356,34],[266,-12],[201,-30]],[[505,222],[510,208],[610,112],[736,7],[769,-3],[916,-16]]],"元":[[[337,695],[369,690],[425,695],[569,736],[644,744]],[[178,453],[235,447],[667,552],[713,556],[750,551]],[[338,433],[361,419],[365,399],[341,319],[287,219],[213,133],[134,72],[111,61]],[[493,480],[523,464],[537,435],[520,296],[521,200],[540,115],[576,82],[645,65],[733,60],[839,69],[906,92],[916,100],[917,115],[912,266]]],"送":[[[488,733],[536,681],[553,645]],[[709,805],[732,789],[742,772],[668,652],[658,646],[658,638]],[[473,553],[534,547],[623,562],[737,594],[783,591]],[[404,392],[449,386],[771,442],[815,441],[860,430]],[[580,524],[608,505],[608,493],[599,412],[575,329],[538,269],[512,244],[460,209],[417,194]],[[677,324],[777,233],[791,209],[798,174]],[[241,755],[329,692],[354,650]],[[105,446],[161,450],[244,484],[261,483],[286,466],[281,420],[253,356],[258,321],[289,263],[302,223],[300,197],[287,184]],[[105,132],[148,121],[230,154],[272,160],[314,156],[610,57],[760,29],[828,33],[939,62]]],"货":[[[329,835],[345,813],[351,790],[331,762],[256,674],[206,626],[133,567],[104,551]],[[307,682],[304,661],[310,623],[299,512],[304,454]],[[761,774],[712,774],[657,723],[604,687],[506,635],[443,615]],[[512,841],[546,795],[535,704],[539,623],[552,596],[582,573],[612,564],[707,558],[809,568],[851,582],[872,596],[872,719]],[[347,481],[376,449],[382,401],[383,311],[368,190],[371,144]],[[408,461],[417,454],[440,456],[606,486],[640,461],[650,448],[653,219],[647,153]],[[462,397],[482,388],[511,358],[497,213],[468,112],[440,66],[387,22],[312,-13],[240,-30]],[[565,116],[669,34],[695,2],[710,-41]]],"艘":[[[286,817],[312,790],[284,730],[227,636]],[[180,630],[215,591],[214,431],[200,309],[151,154],[107,68],[79,29]],[[247,601],[254,614],[335,639],[353,634],[373,611],[371,497],[381,178],[376,69],[360,39],[258,82]],[[262,523],[301,482],[308,464]],[[49,355],[97,336],[324,394],[341,399],[347,408]],[[258,299],[299,257],[312,234]],[[582,663],[552,664],[505,611],[488,603]],[[440,601],[470,574],[516,370]],[[515,505],[522,513],[559,525],[602,524]],[[729,661],[825,661],[848,651],[862,631],[822,490],[798,431],[799,410]],[[725,544],[798,553],[812,561]],[[533,397],[550,405],[684,430],[750,437],[760,428]],[[609,829],[653,790],[656,765],[647,361],[645,339],[630,320]],[[524,285],[579,285],[698,316],[727,309],[740,290],[727,236],[705,181],[678,137],[634,89],[547,47],[445,26]],[[511,233],[561,211],[688,90],[778,25],[806,12],[974,-3]]],"龙":[[[231,506],[277,498],[339,502],[510,533],[655,568],[715,568]],[[435,811],[476,765],[447,538],[397,353],[359,273],[296,188],[236,131],[162,79],[128,63]],[[482,496],[505,484],[529,445],[515,345],[511,188],[524,109],[553,68],[607,47],[720,38],[822,47],[877,64],[896,75],[903,229]],[[700,445],[720,403],[719,390],[705,373],[535,216],[474,174],[422,148]],[[669,744],[759,691],[788,652]]],"飞":[[[126,574],[175,562],[203,565],[421,625],[531,664],[589,669],[604,654],[571,519],[567,400],[577,311],[590,257],[631,164],[690,97],[736,66],[803,39],[852,31],[902,46],[905,176]],[[740,594],[760,573],[768,553],[741,521],[631,420]],[[603,388],[609,374],[681,345],[757,303],[791,272],[808,242]]],"船":[[[377,800],[391,793],[411,770],[362,682],[322,622],[308,611]],[[232,613],[252,599],[268,577],[272,421],[263,302],[220,140],[183,58],[142,-6]],[[297,599],[310,594],[417,627],[436,623],[457,598],[453,542],[458,141],[452,48],[435,16],[408,23],[338,58]],[[334,513],[366,469],[372,450]],[[64,322],[119,301],[413,379],[428,392]],[[315,284],[358,229],[361,203]],[[564,655],[596,631],[603,614],[606,549],[600,481],[590,440],[570,398],[538,360],[513,343]],[[623,649],[643,639],[746,669],[765,664],[778,649],[755,571],[750,516],[751,468],[771,429],[797,418],[838,414],[918,430],[960,424]],[[528,264],[552,244],[562,224],[596,4]],[[585,260],[593,252],[608,251],[782,284],[802,283],[816,275],[843,245],[803,123],[775,103]],[[617,47],[628,59],[774,77],[820,77],[843,68]]],"首":[[[364,790],[437,725],[448,702]],[[633,842],[656,820],[662,802],[590,702],[517,622]],[[136,565],[188,556],[431,592],[822,631],[863,629],[923,612]],[[457,572],[479,544],[426,453],[404,436]],[[333,438],[358,416],[369,396],[373,361],[371,211],[354,76],[355,20]],[[382,427],[408,417],[424,419],[638,460],[664,445],[683,423],[683,91],[670,54],[607,68]],[[400,297],[435,310],[510,322],[548,325],[574,319]],[[397,183],[409,193],[505,207],[560,210],[582,203]],[[386,61],[401,70],[471,81],[619,92]]],"回":[[[147,659],[182,626],[205,584],[224,455],[242,220],[266,125]],[[210,649],[220,640],[259,627],[508,650],[763,691],[788,686],[821,662],[832,649],[832,639],[801,317],[782,216],[755,169],[755,104]],[[363,499],[392,474],[428,306]],[[427,469],[438,481],[450,484],[554,503],[592,504],[620,475],[595,396],[569,379]],[[445,324],[461,337],[552,352],[621,344]],[[289,156],[303,171],[717,211]]],"来":[[[300,647],[322,639],[384,638],[489,651],[647,682],[719,682]],[[304,554],[370,507],[397,465]],[[660,609],[678,574],[575,482]],[[163,369],[215,358],[372,381],[768,413],[812,409],[862,392]],[[456,824],[486,800],[510,770],[505,291],[489,47],[491,-41]],[[476,364],[392,253],[298,167],[211,110],[137,81]],[[535,370],[578,310],[669,204],[771,105],[947,65]]],"重":[[[668,760],[601,776],[512,731],[429,701],[419,703],[354,682],[345,685],[320,674]],[[142,553],[200,545],[366,575],[794,623],[842,619],[890,605]],[[286,475],[307,458],[322,428],[361,235]],[[327,479],[362,464],[651,501],[688,496],[704,487],[725,458],[674,278],[679,256]],[[416,367],[564,390],[606,384]],[[380,254],[389,261],[634,294]],[[475,692],[508,675],[517,621],[509,71],[507,57],[490,40]],[[357,145],[407,136],[606,163],[667,154]],[[202,3],[256,-7],[563,23],[764,33],[800,30],[850,12]]],"复":[[[361,841],[386,800],[360,746],[304,668],[228,602]],[[387,727],[493,736],[686,784],[725,781]],[[332,632],[357,610],[366,593],[395,415],[402,405]],[[378,627],[408,621],[591,657],[632,657],[660,645],[679,618],[636,476],[624,454],[597,470]],[[408,514],[419,524],[491,541],[534,548],[567,543]],[[418,432],[428,441],[546,457],[568,458],[584,447]],[[394,393],[420,353],[369,275],[274,178],[180,111],[162,106],[150,95],[138,96],[132,88]],[[431,310],[496,314],[591,336],[644,317],[592,198],[555,145],[508,99],[449,62],[367,28],[297,11],[255,9]],[[389,257],[406,257],[435,241],[579,114],[650,63],[708,31],[828,19],[916,18]]],"用":[[[245,748],[281,717],[289,667],[286,523],[271,384],[250,292],[208,178],[136,63]],[[321,732],[336,720],[413,729],[683,775],[726,767],[760,734],[757,676],[771,178],[765,106],[748,66],[708,74],[624,111]],[[384,523],[469,523],[600,558],[638,557]],[[371,371],[425,364],[605,397],[658,392]],[[461,718],[501,696],[512,679],[503,95]]],"头":[[[329,700],[412,650],[436,624]],[[262,555],[356,497],[388,456]],[[124,322],[182,312],[388,345],[805,386],[857,379],[898,364]],[[514,770],[551,748],[570,726],[574,705],[534,410],[518,339],[488,256],[442,177],[367,109],[280,60],[207,33],[174,27]],[[607,234],[700,162],[765,101],[790,69],[808,19]]],"型":[[[218,714],[277,709],[473,749],[518,753],[547,748]],[[97,535],[123,528],[170,528],[498,589],[546,594],[586,589]],[[282,684],[321,658],[316,537],[303,469],[287,423],[241,351],[193,304],[151,277]],[[429,716],[461,689],[464,557],[453,410],[457,376]],[[622,693],[647,656],[641,490],[646,447]],[[761,826],[786,810],[805,786],[799,653],[803,396],[787,358],[681,399]],[[340,219],[399,208],[506,221],[634,246],[703,246]],[[480,349],[520,315],[510,94],[495,73]],[[183,26],[247,15],[392,36],[786,70],[822,65],[873,47]]],"跑":[[[159,679],[191,649],[228,486]],[[220,658],[228,666],[337,697],[372,694],[391,672],[389,663],[359,575],[335,561]],[[246,505],[255,515],[326,534],[388,534]],[[273,500],[298,482],[303,461],[302,250],[297,233],[286,223]],[[334,365],[344,381],[372,391],[422,390]],[[135,403],[176,365],[199,207],[186,192]],[[75,142],[131,126],[416,253]],[[586,830],[602,818],[621,787],[604,739],[517,576],[442,482]],[[545,576],[607,575],[796,618],[811,613],[829,596],[807,426],[794,377],[772,331],[744,309],[683,346]],[[521,428],[531,421],[616,455],[638,444],[648,433],[643,409],[623,350],[604,338]],[[507,275],[528,293],[595,311],[649,308]],[[470,439],[490,417],[496,398],[480,236],[483,131],[499,80],[512,63],[548,42],[622,24],[705,22],[798,34],[858,56],[901,91],[908,251]]],"车":[[[276,638],[346,625],[471,638],[681,676],[741,672]],[[474,831],[494,802],[501,777],[414,579],[325,415],[318,388],[364,382],[672,426],[707,427],[745,417]],[[113,210],[181,190],[372,219],[796,258],[872,243],[901,232],[911,221]],[[483,518],[514,480],[516,268],[508,32],[523,-50]]],"并":[[[341,765],[424,708],[448,670]],[[644,839],[665,821],[676,801],[611,714],[561,661]],[[300,569],[357,558],[411,562],[700,615],[734,618],[760,612]],[[124,330],[148,322],[197,321],[472,360],[808,388],[870,382],[924,364]],[[369,529],[403,508],[416,492],[410,382],[391,261],[376,216],[337,143],[284,84],[230,50]],[[580,561],[622,537],[632,523],[631,-60]]],"排":[[[123,532],[192,534],[337,579],[384,579]],[[256,814],[281,798],[301,775],[291,442],[295,130],[288,100],[271,73],[173,119]],[[46,243],[91,241],[348,427]],[[497,720],[534,685],[543,663],[538,230],[527,124],[529,42]],[[388,504],[494,527],[512,543]],[[380,372],[500,398],[513,410]],[[347,228],[382,221],[398,224],[487,273],[501,275],[506,292]],[[645,795],[699,742],[701,241],[688,79],[692,-16]],[[726,554],[738,565],[812,581],[862,587],[890,579]],[[728,407],[758,419],[837,434],[894,429]],[[727,261],[748,272],[880,292],[936,281]]],"两":[[[267,681],[317,670],[683,728],[752,720]],[[180,492],[210,464],[219,432],[219,254],[200,128],[203,69]],[[254,441],[268,460],[526,501],[759,523],[778,522],[802,507],[817,486],[814,293],[804,173],[791,113],[764,70],[721,81],[624,127]],[[362,650],[399,618],[394,545],[377,441],[341,340],[300,274],[279,252]],[[375,362],[441,307],[457,277]],[[548,675],[578,656],[586,641],[581,542],[569,455],[540,351],[509,278],[444,185]],[[583,364],[584,353],[672,285],[688,263],[699,232]]],"名":[[[496,828],[517,782],[448,681],[355,591],[314,561],[245,525]],[[476,673],[501,682],[575,689],[635,702],[672,697],[687,688],[669,648],[603,554],[533,468],[409,337],[318,256],[180,151],[49,75]],[[355,564],[434,500],[451,465]],[[367,261],[395,244],[407,214],[440,11]],[[427,263],[443,250],[610,273],[702,294],[741,291],[781,253],[736,131],[705,110]],[[462,38],[474,53],[693,80],[753,79],[776,69]]],"宇":[[[437,844],[532,792],[562,751]],[[228,671],[239,640],[196,543],[187,488]],[[266,614],[280,624],[408,651],[747,697],[798,680],[813,654],[746,572]],[[351,507],[380,500],[448,504],[612,539],[669,538]],[[178,317],[219,308],[250,310],[453,343],[723,370],[771,369],[827,353]],[[485,485],[513,468],[520,457],[531,393],[539,295],[540,159],[530,59],[511,17],[492,0],[373,64]]],"航":[[[339,797],[352,793],[375,771],[335,673],[304,619]],[[204,605],[227,590],[241,564],[246,451],[239,309],[205,167],[153,53],[126,14]],[[267,597],[283,588],[380,617],[408,604],[421,584],[417,408],[423,161],[418,79],[400,48],[370,55],[286,98]],[[305,502],[348,450]],[[49,318],[99,298],[190,328],[382,378],[389,388]],[[300,286],[336,249],[350,224]],[[613,791],[703,729],[729,686]],[[524,540],[548,534],[609,540],[801,594],[869,602]],[[540,413],[558,401],[574,376],[573,305],[563,234],[531,147],[487,95],[457,76]],[[606,400],[615,395],[696,421],[721,417],[731,405],[699,242],[700,180],[707,135],[723,97],[747,70],[775,51],[811,38],[859,34],[896,41],[933,60],[942,77],[947,220]]],"员":[[[291,768],[311,751],[323,730],[356,562]],[[339,767],[348,758],[368,754],[603,799],[637,799],[675,766],[650,686],[625,668]],[[374,612],[387,603],[616,639],[660,639],[686,630]],[[298,513],[323,487],[331,466],[333,316],[320,199],[323,156]],[[349,502],[374,489],[510,509],[522,516],[635,537],[658,533],[682,513],[693,498],[687,437],[690,214],[683,153]],[[455,433],[474,426],[506,397],[499,208],[474,111],[447,69],[399,30],[310,-13],[236,-31]],[[571,108],[705,20],[735,-16],[749,-49]]],"空":[[[454,832],[536,785],[564,750]],[[237,653],[248,622],[245,598],[204,520],[196,463]],[[280,623],[293,609],[305,609],[579,659],[722,677],[758,676],[789,659],[805,634],[726,540]],[[362,515],[379,496],[385,474],[307,371],[233,308]],[[577,521],[681,461],[711,421]],[[332,291],[365,282],[401,283],[522,299],[619,322],[664,327],[687,323]],[[474,267],[502,240],[498,123],[478,109]],[[171,58],[225,46],[453,75],[774,99],[809,94],[861,76]]],"间":[[[289,773],[354,720],[376,688]],[[189,696],[231,648],[233,583],[224,283],[218,213],[200,119],[199,50]],[[480,738],[512,731],[546,734],[654,759],[742,768],[771,758],[795,732],[801,94],[779,41],[721,57],[638,99]],[[371,533],[392,513],[399,437],[384,231]],[[423,507],[432,517],[452,523],[464,521],[474,528],[582,552],[599,548],[622,527],[628,325],[624,285],[613,260],[617,208]],[[423,386],[432,396],[495,410],[544,407]],[[415,267],[427,277],[450,282],[562,297],[583,294]]],"站":[[[273,768],[355,713],[378,672]],[[144,504],[178,499],[215,503],[397,554],[459,561]],[[185,371],[224,304],[234,272]],[[371,454],[396,422],[354,279],[338,240],[322,223]],[[113,157],[168,140],[380,218],[448,249]],[[606,767],[658,725],[659,713],[650,336],[632,310]],[[683,516],[707,532],[834,567],[884,567]],[[468,287],[492,267],[504,245],[548,16]],[[522,284],[546,273],[660,291],[760,316],[796,310],[832,275],[793,155],[760,129]],[[566,88],[579,77],[591,76],[746,99],[800,97],[826,89]]],"近":[[[774,743],[701,750],[649,713],[556,668],[552,656]],[[468,678],[486,668],[511,639],[513,543],[499,409],[476,338],[452,295],[400,235],[361,209]],[[543,484],[555,491],[804,543],[835,544],[893,532]],[[663,485],[700,466],[704,451],[699,98]],[[233,767],[319,708],[341,670]],[[102,471],[142,468],[263,505],[276,504],[302,484],[293,439],[261,381],[258,362],[267,322],[287,285],[301,235],[297,212],[280,195]],[[87,148],[128,135],[217,167],[291,171],[366,152],[605,55],[716,25],[809,16],[884,28],[927,42]]],"本":[[[212,574],[269,563],[704,630],[753,631],[790,622]],[[451,825],[506,769],[499,210],[485,51],[486,-52]],[[472,562],[462,553],[454,515],[438,481],[366,375],[309,307],[208,207],[130,146],[78,116]],[[529,540],[538,510],[618,414],[713,310],[792,239],[847,222],[995,198]],[[307,183],[329,176],[374,174],[596,205],[649,196]]],"土":[[[283,438],[312,430],[379,430],[486,445],[692,487],[741,485]],[[461,760],[517,714],[518,685],[498,173],[476,153]],[[129,99],[188,87],[378,115],[818,156],[866,149],[922,129]]],"公":[[[314,654],[347,614],[296,512],[215,404],[128,322],[68,282]],[[473,790],[518,770],[544,742],[671,540],[756,445],[783,424],[803,418],[874,400],[982,383]],[[423,420],[446,395],[457,378],[455,372],[389,250],[316,147],[303,108],[347,103],[439,127],[608,159],[639,151]],[[582,276],[662,191],[706,132],[724,81],[723,57]]],"司":[[[331,731],[372,718],[416,719],[724,772],[755,760],[781,730],[766,648],[755,491],[757,117],[751,62],[732,29],[697,37],[597,84]],[[290,559],[325,552],[360,554],[520,586],[576,586]],[[220,405],[261,356],[307,175]],[[243,412],[292,394],[381,408],[484,435],[522,428],[550,400],[521,307],[495,290]],[[322,242],[340,232],[485,260],[531,260],[556,253]]],"把":[[[127,520],[161,517],[203,524],[380,582],[428,583]],[[277,810],[325,768],[313,403],[316,124],[310,91],[294,60],[191,102],[189,110],[178,110]],[[60,222],[80,216],[105,218],[240,326],[413,449]],[[521,531],[539,548],[728,603],[749,608],[773,604],[808,574],[769,442],[743,425]],[[612,547],[635,525],[638,507],[631,413],[614,399]],[[505,337],[528,354],[733,396],[781,397],[803,390]],[[461,568],[482,547],[489,520],[481,270],[490,191],[510,133],[547,98],[611,71],[679,60],[798,69],[872,92],[905,111],[929,139],[936,280]]],"射":[[[337,825],[370,794],[285,651],[273,647]],[[223,651],[246,626],[254,589],[253,370],[249,358],[236,351]],[[271,636],[291,625],[302,626],[413,655],[431,648],[453,624],[448,158],[442,56],[424,26],[318,65]],[[279,512],[291,522],[328,533],[377,532]],[[280,427],[289,437],[331,449],[381,448]],[[104,309],[152,289],[382,354],[419,377]],[[423,374],[401,301],[313,201],[228,136],[121,84]],[[520,452],[571,449],[665,473],[857,505],[938,494]],[[706,761],[754,722],[750,515],[762,112],[757,66],[737,34],[662,65],[610,92],[608,99],[597,99]],[[543,358],[607,307],[623,274]]],"数":[[[224,698],[283,661],[307,624]],[[548,723],[519,731],[444,657]],[[143,542],[172,535],[202,537],[461,592],[501,597],[547,592]],[[356,807],[374,796],[398,767],[375,434],[381,386]],[[358,544],[297,469],[227,402],[148,356]],[[444,512],[493,470],[506,450]],[[327,380],[340,367],[348,344],[274,165],[447,69],[508,5]],[[432,340],[463,314],[459,274],[439,202],[404,136],[363,89],[317,55],[250,24],[185,10]],[[103,261],[151,238],[412,297],[429,293]],[[651,791],[677,773],[692,753],[673,667],[608,507],[573,439],[548,406]],[[606,464],[674,468],[846,516],[899,518]],[[714,449],[746,426],[734,330],[700,227],[668,179],[636,148],[572,109],[526,95]],[[550,354],[595,323],[725,146],[793,81],[835,54],[976,26]]],"多":[[[476,838],[494,796],[452,737],[366,655],[336,634],[262,599]],[[484,726],[630,734],[666,717],[645,678],[606,630],[494,520],[354,421],[250,370]],[[358,625],[407,597],[421,583],[432,557]],[[596,478],[567,472],[505,397],[398,306],[331,264],[295,249]],[[531,383],[672,411],[722,402],[734,384],[682,294],[619,204],[510,93],[428,34],[338,-13],[270,-39],[190,-54]],[[382,273],[402,266],[460,220],[486,178]]],"其":[[[231,648],[288,640],[369,650],[711,711],[749,713],[793,705]],[[341,792],[383,742],[389,659],[387,303],[370,288]],[[581,851],[631,808],[605,335],[586,311]],[[414,522],[425,530],[514,548],[549,548],[557,543]],[[417,400],[422,411],[433,414],[527,429],[556,426]],[[107,237],[162,228],[451,270],[840,308],[922,287]],[[427,158],[392,154],[350,105],[289,56],[227,17],[189,1]],[[581,187],[669,119],[717,73],[742,35],[753,-3]]],"他":[[[300,793],[317,780],[338,747],[308,679],[201,496],[136,410],[83,355]],[[250,521],[267,436],[266,292],[252,106],[258,46]],[[326,383],[378,384],[429,404],[756,569],[782,572],[804,560],[768,406],[739,327],[715,309],[677,329],[645,356]],[[562,780],[583,769],[606,740],[603,552],[576,254]],[[420,566],[442,543],[457,515],[441,364],[444,266],[453,212],[473,171],[509,143],[601,121],[710,117],[817,126],[895,150],[916,163],[927,326]]],"加":[[[119,464],[162,452],[186,455],[477,521],[506,508],[517,494],[487,270],[458,158],[433,105],[412,83],[393,73],[299,127]],[[312,766],[349,741],[371,707],[332,474],[304,366],[248,233],[206,164],[128,79],[87,49],[51,33]],[[586,458],[610,435],[620,414],[653,112]],[[645,450],[656,441],[687,443],[830,478],[855,469],[887,438],[842,245],[812,220]],[[677,159],[694,175],[801,190],[854,190],[883,181]]],"起":[[[224,590],[280,587],[350,600],[459,631],[501,630]],[[334,821],[380,781],[370,504],[353,477]],[[84,416],[116,407],[148,408],[288,442],[457,474],[509,478],[526,473]],[[342,431],[372,402],[369,221],[387,191]],[[400,311],[414,324],[468,335],[515,329]],[[229,361],[256,323],[200,206],[161,155],[113,106],[59,66]],[[263,252],[266,240],[312,208],[463,118],[583,61],[686,22],[756,17],[936,46]],[[602,599],[623,596],[672,604],[745,625],[773,611],[783,599],[763,527],[758,516],[733,497]],[[638,439],[648,454],[734,472],[772,474],[796,468]],[[576,476],[603,450],[608,436],[601,356],[606,291],[622,260],[650,245],[693,235],[766,232],[837,238],[884,256],[889,280],[888,371]]],"链":[[[249,788],[270,769],[280,744],[235,640],[190,559],[128,467],[82,407],[46,373]],[[237,592],[262,606],[317,622],[370,627]],[[165,468],[219,469],[296,497],[348,504]],[[106,311],[164,313],[293,358],[341,364]],[[192,447],[225,421],[232,405],[236,288],[224,148],[229,126],[272,145],[339,200]],[[545,606],[580,600],[622,602],[779,642],[837,643]],[[661,795],[680,770],[690,743],[641,580],[574,404],[621,400],[756,425],[827,431],[854,424]],[[509,280],[562,273],[734,301],[849,312],[894,307],[925,296]],[[689,534],[718,504],[711,124]],[[408,682],[460,633],[475,605]],[[334,433],[366,436],[415,457],[438,457],[458,442],[453,398],[425,332],[427,309],[463,234],[462,198],[452,192]],[[356,181],[375,171],[446,172],[488,158],[695,60],[756,40],[789,39],[940,58]]],"卫":[[[232,616],[270,609],[298,611],[420,642],[566,667],[576,664],[716,683],[744,681],[771,658],[782,638],[757,566],[724,426],[708,388],[688,363],[592,416]],[[473,626],[506,609],[514,556],[507,163],[489,151]],[[151,105],[192,89],[224,86],[435,111],[803,132],[878,103]]],"颗":[[[178,715],[212,677],[252,478]],[[231,718],[245,706],[425,742],[461,743],[486,733],[503,712],[473,565],[459,528],[463,505]],[[272,599],[389,627],[429,624]],[[267,492],[278,501],[425,536]],[[85,361],[119,353],[156,355],[457,416],[514,412]],[[332,705],[354,682],[356,651],[342,32]],[[322,363],[312,353],[303,318],[291,300],[224,221],[170,170],[90,118]],[[408,322],[470,282],[495,244]],[[569,718],[603,712],[651,716],[729,731],[856,769],[913,771]],[[727,684],[711,684],[699,673],[668,601],[652,584]],[[551,585],[576,560],[584,525],[587,402],[572,263],[575,220]],[[603,569],[618,563],[662,567],[785,598],[801,595],[831,564],[825,454],[828,299],[819,224]],[[652,491],[668,484],[697,457],[688,287],[662,175],[638,128],[587,76],[526,43],[478,30]],[[745,187],[846,92],[872,49],[880,15]]],"现":[[[131,636],[154,632],[212,637],[325,672],[375,673]],[[135,434],[178,433],[226,442],[325,476],[371,477]],[[233,616],[263,595],[265,551],[261,279],[244,256]],[[74,178],[132,167],[386,297]],[[438,741],[466,710],[472,692],[476,548],[457,370],[459,324]],[[496,725],[507,718],[541,724],[686,766],[711,752],[729,729],[723,654],[726,389],[719,322]],[[548,628],[590,601],[597,577],[586,418],[572,314],[540,215],[511,165],[478,125],[447,99],[383,57],[300,23]],[[607,345],[629,295],[621,152],[630,90],[647,57],[694,31],[741,22],[802,21],[871,37],[908,58],[921,72],[928,224]]],"在":[[[247,593],[289,585],[349,589],[497,615],[681,659],[747,661]],[[467,843],[483,835],[511,802],[511,780],[424,585],[340,435],[278,348],[218,282],[127,204],[49,153]],[[258,433],[297,362],[291,159],[280,54],[286,-6]],[[422,315],[495,310],[699,357],[768,362]],[[555,519],[592,491],[602,470],[594,157],[577,136]],[[368,93],[420,84],[522,100],[801,128],[849,121],[887,108]]],"超":[[[213,606],[271,601],[438,639],[489,639]],[[326,813],[372,773],[362,529],[345,503]],[[87,434],[148,427],[418,494],[465,502],[512,499]],[[339,449],[369,422],[368,234],[387,205]],[[401,330],[424,352],[456,356],[483,351]],[[220,375],[245,338],[195,226],[167,183],[109,116],[55,75]],[[257,271],[260,259],[295,232],[467,124],[561,75],[664,32],[725,15],[750,15],[947,41]],[[547,669],[599,664],[777,705],[793,705],[815,687],[797,554],[770,494],[745,470],[668,508]],[[627,651],[651,631],[655,618],[639,576],[582,479],[526,422]],[[536,359],[566,324],[597,159]],[[586,358],[594,350],[614,350],[729,374],[760,386],[791,378],[812,356],[780,263],[763,257]],[[615,189],[626,202],[750,224],[812,214]]],"过":[[[407,540],[463,532],[808,596],[874,589]],[[648,786],[689,755],[694,741],[686,603],[696,257],[692,226],[676,193],[551,231],[548,237],[537,236]],[[449,434],[511,392],[537,353]],[[215,763],[301,715],[330,675]],[[129,459],[159,456],[185,462],[261,492],[277,492],[302,476],[306,464],[299,435],[266,358],[275,317],[308,254],[316,220],[316,204],[301,186]],[[121,136],[164,125],[245,157],[299,161],[352,154],[577,72],[670,47],[753,33],[837,39],[922,66]]],"万":[[[162,654],[187,646],[226,644],[444,680],[777,714],[818,712],[877,695]],[[486,487],[500,494],[594,487],[679,490],[697,479],[720,445],[631,175],[599,114],[572,86],[539,69],[419,146]],[[476,657],[506,620],[449,488],[369,344],[272,224],[201,162],[117,108]]],"户":[[[467,832],[479,821],[563,781],[597,737]],[[392,579],[406,568],[642,629],[673,633],[693,627],[731,590],[691,486],[652,460]],[[371,370],[408,386],[642,429],[705,432],[731,424]],[[307,600],[325,589],[348,562],[351,534],[332,316],[304,200],[267,116],[227,60],[152,-14],[97,-46]]],"史":[[[262,618],[281,605],[308,568],[359,379]],[[303,621],[339,606],[352,607],[567,635],[661,655],[680,653],[708,637],[725,616],[683,501],[655,483]],[[372,431],[392,421],[432,422],[642,452],[693,451],[722,441]],[[457,822],[486,804],[512,777],[502,374],[494,298],[477,229],[452,179],[381,109],[289,62],[149,21]],[[215,336],[279,337],[337,315],[541,140],[648,59],[713,22],[740,13],[796,12],[942,24]]],"上":[[[446,781],[462,775],[498,734],[493,159],[472,136]],[[531,448],[551,462],[627,473],[698,493],[768,496]],[[134,92],[171,76],[212,72],[458,103],[841,132],[932,99]]],"大":[[[210,458],[268,453],[514,503],[719,534],[770,529],[810,517]],[[416,810],[444,799],[482,759],[469,518],[448,394],[426,320],[386,231],[361,196],[307,140],[202,67],[138,41]],[[486,430],[500,393],[576,284],[660,182],[722,118],[774,77],[953,42]]],"强":[[[200,696],[235,694],[346,724],[363,722],[379,709],[389,695],[352,580],[323,560]],[[221,525],[246,517],[323,535],[366,538],[387,533]],[[177,533],[199,510],[206,487],[178,362],[209,359],[252,373],[311,377],[336,369],[354,348],[323,159],[301,91],[283,60],[245,30],[167,80]],[[468,677],[495,658],[506,639],[543,483]],[[531,674],[552,666],[711,706],[735,703],[765,672],[737,594],[711,582]],[[564,512],[578,526],[701,549],[749,552],[771,544]],[[440,385],[470,361],[512,210]],[[498,383],[508,374],[537,377],[673,402],[734,420],[770,422],[791,414],[809,389],[789,334],[763,320]],[[527,230],[543,245],[754,288],[805,291],[823,284]],[[604,507],[632,491],[640,463],[638,157],[621,134]],[[410,82],[461,62],[753,142],[783,142]],[[750,215],[840,109],[862,66],[866,37]]],"分":[[[333,687],[347,674],[362,642],[306,551],[231,465],[158,407],[100,373]],[[454,803],[495,791],[527,765],[659,579],[707,524],[757,480],[783,463],[819,454],[978,435]],[[251,378],[303,368],[607,435],[626,429],[646,410],[634,299],[609,167],[591,110],[565,64],[541,41],[523,39],[420,94]],[[398,358],[424,334],[391,252],[355,194],[319,149],[261,96],[200,54],[156,32]]],"钟":[[[304,816],[329,792],[340,769],[305,700],[228,575],[186,519],[108,425],[55,378]],[[286,612],[423,657],[458,659]],[[206,479],[255,478],[386,522],[427,525]],[[163,321],[211,319],[294,339],[401,375],[445,380]],[[270,458],[293,446],[311,417],[314,282],[300,170],[305,141],[355,155],[446,213]],[[468,567],[497,542],[508,515],[544,328]],[[527,561],[545,550],[636,570],[847,597],[881,560],[842,441],[817,431]],[[564,375],[584,364],[807,396],[850,394],[875,386]],[[629,797],[654,791],[689,757],[681,597],[679,-15]]],"左":[[[267,537],[291,529],[357,528],[521,555],[701,594],[757,594]],[[470,826],[519,780],[512,707],[488,594],[417,422],[354,312],[278,211],[182,117],[68,38]],[[411,319],[432,312],[497,313],[694,352],[741,349]],[[531,293],[559,264],[553,116],[534,101]],[[283,53],[335,43],[508,66],[784,90],[827,85],[878,68]]],"右":[[[143,506],[201,497],[394,533],[812,587],[872,583],[922,568]],[[467,792],[513,742],[499,647],[472,556],[399,401],[321,281],[267,218],[154,118],[65,63]],[[380,301],[424,12]],[[415,273],[435,290],[530,305],[654,337],[680,340],[703,333],[736,300],[699,157],[671,135]],[[446,52],[463,67],[662,103],[720,106],[746,97]]],"轰":[[[276,693],[296,686],[356,684],[514,704],[667,733],[721,732]],[[447,836],[472,790],[424,669],[358,547],[397,536],[610,569],[674,571],[706,562]],[[151,393],[206,383],[412,414],[774,448],[824,441],[862,427]],[[500,625],[525,588],[511,353],[523,279]],[[257,247],[302,248],[407,277],[425,269],[437,251],[421,189],[393,126],[340,61],[269,24],[170,1]],[[246,171],[337,113],[403,62],[427,35],[439,9]],[[553,284],[603,284],[710,311],[723,308],[744,287],[716,175],[682,106],[651,67],[581,25],[484,-1]],[[519,230],[558,206],[641,106],[690,55],[740,16],[781,-7],[906,-24]]],"像":[[[300,784],[316,770],[334,736],[296,662],[184,495],[109,409],[72,379]],[[236,524],[240,497],[259,464],[262,400],[257,225],[244,101],[250,36]],[[540,843],[556,822],[559,800],[506,723],[469,684],[435,659]],[[548,738],[639,758],[658,758],[680,747],[623,666],[602,653]],[[396,616],[417,600],[428,580],[456,462]],[[435,616],[459,606],[627,635],[635,641],[717,651],[747,645],[770,614],[718,487]],[[472,471],[491,479],[698,511]],[[572,614],[595,586],[543,468],[511,423],[462,374],[390,324],[382,325],[378,317]],[[530,407],[542,408],[573,380],[601,347],[627,301],[648,242],[654,172],[651,134],[634,58],[606,10],[595,5],[494,53]],[[550,369],[553,340],[525,308],[437,241],[365,207]],[[598,307],[588,256],[510,173],[420,104],[353,74]],[[734,439],[750,405],[652,323],[652,315]],[[659,288],[709,239],[815,167],[889,156],[973,155]]],"筷":[[[284,813],[312,779],[285,704],[237,630],[174,567]],[[315,703],[445,729],[499,731]],[[336,638],[399,593],[411,568]],[[592,832],[620,797],[601,744],[559,672],[502,612]],[[622,717],[709,727],[780,746],[837,747]],[[621,645],[704,591],[722,563]],[[184,375],[177,315],[147,219]],[[321,409],[329,396],[365,381],[381,366]],[[251,565],[293,520],[273,-47]],[[424,390],[480,388],[672,425],[696,422],[728,392],[699,311],[673,287]],[[350,232],[403,224],[557,248],[782,271],[827,271],[884,255]],[[520,544],[555,517],[566,492],[556,275],[538,169],[509,102],[474,57],[415,17],[344,-10]],[[578,225],[583,211],[661,121],[753,32],[783,19],[901,-4]]],"子":[[[294,711],[355,686],[462,717],[620,752],[658,752],[675,732],[681,708],[549,578],[536,574]],[[472,588],[516,549],[530,478],[550,263],[549,179],[537,99],[523,64],[505,42],[490,34],[383,79],[368,91],[353,93]],[[119,405],[142,394],[186,386],[410,420],[826,459],[855,457],[916,439],[937,422]]],"夹":[[[311,625],[342,617],[401,618],[487,630],[633,663],[709,666]],[[293,517],[371,459],[397,417]],[[662,577],[684,544],[619,468],[578,430]],[[127,318],[181,307],[363,334],[788,370],[827,366],[881,348]],[[451,808],[480,788],[507,759],[482,347],[458,227],[421,149],[355,83],[268,36],[173,6]],[[508,319],[519,293],[643,140],[740,43],[807,21],[912,1]]],"住":[[[330,775],[349,760],[370,724],[336,654],[280,558],[204,450],[131,362],[84,319]],[[253,473],[258,443],[273,417],[272,213],[260,69],[266,4]],[[540,765],[639,710],[670,667]],[[423,531],[444,524],[492,524],[629,546],[764,576],[827,578]],[[435,303],[483,295],[723,336],[794,332]],[[593,515],[622,491],[625,433],[622,153],[605,131]],[[351,89],[409,79],[655,111],[830,123],[873,119],[922,102]]],"收":[[[157,578],[197,541],[200,386],[191,277],[243,290],[295,328],[325,342],[336,357]],[[318,773],[347,749],[369,719],[361,246],[346,86],[348,-2]],[[589,811],[610,796],[628,769],[611,709],[582,636],[534,543],[476,462]],[[538,508],[617,519],[830,584],[866,585]],[[658,500],[684,486],[698,466],[698,416],[681,312],[650,241],[608,189],[556,150],[482,112],[399,87]],[[463,403],[503,384],[522,367],[684,179],[779,102],[982,60]]],"购":[[[176,718],[201,690],[208,642],[209,495],[191,355],[191,300]],[[230,704],[243,695],[367,727],[388,721],[414,691],[406,594],[407,365],[399,297]],[[263,602],[278,597],[306,572],[299,391],[279,263],[259,208],[233,166],[176,118],[142,97],[116,90]],[[331,254],[401,198],[414,183],[427,151]],[[581,818],[605,798],[617,777],[602,718],[542,583],[507,520],[474,476]],[[552,560],[796,609],[828,594],[846,572],[823,219],[806,148],[779,81],[757,53],[728,32],[682,63],[627,110],[625,120],[612,126]],[[585,484],[612,451],[583,386],[538,317],[527,280],[571,280],[660,306],[678,300]],[[663,369],[726,297],[736,272],[736,254]]],"市":[[[435,843],[528,788],[552,752]],[[127,623],[150,613],[190,607],[424,649],[801,697],[849,694],[914,672]],[[276,489],[304,468],[311,445],[314,364],[299,253],[302,199]],[[337,481],[353,468],[683,520],[705,518],[720,508],[732,483],[729,306],[718,261],[708,246],[698,247],[649,258],[599,278]],[[466,627],[511,599],[507,-56]]],"募":[[[208,711],[230,705],[282,705],[486,733],[738,757],[778,756],[824,742]],[[364,825],[401,799],[424,675]],[[600,873],[614,866],[632,835],[576,687]],[[304,636],[333,611],[376,446]],[[361,608],[372,622],[457,640],[586,653],[600,659],[640,659],[663,650],[676,634],[681,612],[647,519],[626,480],[627,460]],[[382,533],[390,541],[403,539],[414,546],[479,556],[557,566],[576,562]],[[393,462],[411,471],[593,498]],[[170,355],[222,347],[468,381],[785,407],[829,403],[875,388]],[[417,449],[439,425],[429,405],[375,320],[320,262],[249,208],[172,167],[113,146]],[[608,374],[629,364],[718,285],[809,218],[870,204],[980,193]],[[294,175],[323,166],[352,166],[620,215],[642,216],[658,209],[672,193],[658,126],[634,52],[601,7],[582,-6],[575,-4],[500,39]],[[474,293],[495,259],[469,186],[434,122],[399,76],[342,20],[294,-16],[247,-40]]],"资":[[[249,765],[335,727],[363,693]],[[235,416],[232,435],[241,480],[367,617]],[[513,835],[534,807],[509,745],[481,700],[425,646]],[[520,720],[690,761],[733,767],[762,759],[775,742],[770,732],[707,662]],[[575,685],[592,656],[561,588],[502,524],[442,485]],[[603,607],[605,598],[689,534],[782,480],[851,471],[931,473]],[[339,454],[365,425],[369,411],[366,269],[356,209],[356,156]],[[392,437],[418,427],[426,433],[469,436],[621,469],[638,465],[656,450],[670,429],[666,348],[673,225],[666,161]],[[463,380],[483,372],[512,343],[498,175],[471,97],[447,64],[410,36],[337,2],[298,-10],[268,-11]],[[582,124],[687,44],[715,7],[726,-29]]],"新":[[[311,831],[382,794],[415,755]],[[209,653],[219,648],[271,648],[473,693],[524,696]],[[234,594],[271,556],[287,526]],[[434,642],[451,608],[409,525],[383,497]],[[77,428],[129,419],[444,490],[485,494],[510,489]],[[142,308],[186,304],[448,368],[508,366]],[[327,441],[360,415],[358,143],[349,117],[335,99],[252,146]],[[208,253],[193,182],[164,111]],[[386,277],[453,244],[469,223]],[[767,757],[776,745],[782,711],[666,632],[639,617],[630,619]],[[560,631],[585,611],[599,586],[597,440],[583,332],[559,240],[533,177],[496,108],[467,71]],[[628,454],[643,463],[878,514],[937,504]],[[738,450],[782,425],[775,-66]]],"代":[[[334,760],[359,735],[369,708],[336,636],[298,569],[224,464],[131,354],[95,323]],[[311,536],[314,496],[325,473],[319,269],[302,113],[307,45]],[[411,443],[422,439],[491,447],[647,499],[755,544],[815,550]],[[488,824],[527,810],[556,785],[584,601],[626,433],[669,313],[739,188],[775,143],[832,88],[866,70],[896,64],[917,114],[933,214]],[[709,763],[786,717],[799,706],[818,673]]],"接":[[[136,550],[195,549],[361,595],[414,599]],[[273,806],[290,798],[321,766],[307,455],[308,129],[301,98],[285,69],[223,95],[185,115],[184,122],[173,122]],[[76,262],[118,259],[277,379],[399,461]],[[572,809],[648,767],[679,728]],[[501,633],[531,628],[571,632],[751,674],[812,680]],[[524,560],[556,524],[568,500]],[[690,634],[713,614],[720,598],[674,482],[658,464]],[[451,424],[489,417],[773,466],[813,469],[843,464]],[[563,403],[590,380],[514,186],[547,166],[685,112],[759,72],[797,47],[845,-2]],[[704,343],[730,314],[717,257],[682,181],[635,120],[589,86],[549,66],[481,44],[422,37]],[[361,264],[415,257],[665,297],[860,316],[910,311],[941,300]]],"下":[[[113,682],[145,669],[181,664],[440,706],[807,745],[870,736],[903,726],[924,710]],[[487,681],[516,656],[519,479],[510,-2]],[[555,519],[562,502],[645,466],[706,429],[729,407],[748,377]]],"油":[[[210,723],[292,669],[316,629]],[[126,504],[205,454],[234,421]],[[193,7],[178,47],[175,92],[199,132],[302,354]],[[329,483],[366,449],[379,419],[412,170],[431,105]],[[397,465],[422,450],[606,478],[773,516],[808,514],[832,497],[848,478],[829,327],[806,182],[799,155],[776,118],[775,59]],[[465,305],[536,301],[684,333],[720,332]],[[540,789],[595,744],[598,704],[590,212],[588,191],[571,171]],[[451,115],[463,130],[527,141],[685,163],[723,166],[748,161]]]};
diff --git a/scripts/engine/reference_films/spacex/spacex_wb/common.js b/scripts/engine/reference_films/spacex/spacex_wb/common.js
new file mode 100644
index 0000000..007a263
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_wb/common.js
@@ -0,0 +1,551 @@
+// SpaceX 这 24 年 · 白板版(wb)共用:一整块超大白板 + 一台相机 + 一支马克笔(RSA Animate 型,语法卡 y3_whiteboard)。
+// 全片 12 段画在同一块板上,每段的 scene 文件只往板上「排笔画」和「排相机」,画面只由全片时间 t 决定——段与段之间没有转场函数,
+// 转场就是相机在板上移动(平移 / 甩镜+运动模糊 / 拉远再扎进去 / 云团擦除),板上的东西永远不跳。
+// 版式:四行,像一页手写笔记:A 行 S01–S02,B 行 S03–S05,C 行 S06–S08,D 行 S09–S12;行内左→右按时间走,换行时甩镜或拉远。
+// 颜色:黑线 #0A0503 + 唯一强调色橙 #EF7226(关键词、数字、斜线排线);字:霞鹜文楷。
+// 约定:WB.cur 是「下一笔从什么时候开始」(全片秒);WB.line/text 会把它往后推;WB.pop/fill/custom 不推(或只推一点)。
+(() => {
+const W = 1920, H = 1080;
+const { clamp, lerp } = U;
+const INK = '#0A0503', OR = '#EF7226', BOARD = '#FBFBFB', WASH = 'rgba(239,114,38,.2)', FONT = '"LXGWWenKai-500"';
+const SPEED = 2500, LW = 6.5;
+const WB = window.WB = { INK, OR, BOARD, WASH, FONT, SPEED, LW, S: [], K: [], FX: [], WHIP: [], CH: {}, cur: 0, built: false, texts: [] };
+const ROW = { A: 0, B: 1150, C: 2300, D: 3450 };
+WB.ROW = ROW;
+
+// ---------- 时间 ----------
+WB.T0 = id => TIMING.seg[id].t0;
+WB.q = (id, key) => TIMING.seg[id].t0 + TM.cue(id, key);
+WB.qe = (id, key) => TIMING.seg[id].t0 + TM.end(id, key);
+WB.at = t => (WB.cur = t);
+WB.go = t => (WB.cur = Math.max(WB.cur, t));
+
+// ---------- 几何 ----------
+const bbOf = (pts, pad = 0) => { let x0 = 1e9, y0 = 1e9, x1 = -1e9, y1 = -1e9; for (const [x, y] of pts) { if (x < x0) x0 = x; if (x > x1) x1 = x; if (y < y0) y0 = y; if (y > y1) y1 = y; } return [x0 - pad, y0 - pad, x1 + pad, y1 + pad]; };
+WB.bbOf = bbOf;
+WB.circ = (cx, cy, r, turns = 1.06, a0 = -Math.PI / 2) => DG.arcPts(cx, cy, r, r, a0, a0 + turns * Math.PI * 2, Math.max(18, Math.round(r * turns / 3)));
+WB.ell = (cx, cy, rx, ry, a0 = -Math.PI / 2, turns = 1.03, rot = 0, n = 64) => { const c = Math.cos(rot), s = Math.sin(rot);
+ return DG.arcPts(0, 0, rx, ry, a0, a0 + turns * Math.PI * 2, n).map(([x, y]) => [cx + x * c - y * s, cy + x * s + y * c]); };
+// 折线加密(保角:每条边各自加密,手绘抖动后角还是角)
+WB.dense = (P, k = 10) => { const out = []; for (let i = 0; i < P.length - 1; i++) for (let j = 0; j < k; j++) out.push([lerp(P[i][0], P[i + 1][0], j / k), lerp(P[i][1], P[i + 1][1], j / k)]); out.push(P[P.length - 1]); return out; };
+WB.rect = (x, y, w, h) => WB.dense([[x, y], [x + w, y], [x + w, y + h], [x, y + h], [x, y + 2]], 12);
+WB.quad = (a, c, b, n = 28) => { const o = []; for (let i = 0; i <= n; i++) { const u = i / n; o.push([(1 - u) * (1 - u) * a[0] + 2 * u * (1 - u) * c[0] + u * u * b[0], (1 - u) * (1 - u) * a[1] + 2 * u * (1 - u) * c[1] + u * u * b[1]]); } return o; };
+WB.xf = (pts, x, y, s = 1, r = 0) => { const c = Math.cos(r), n = Math.sin(r); return pts.map(([a, b]) => [x + (a * c - b * n) * s, y + (a * n + b * c) * s]); };
+
+// ---------- 笔画 ----------
+WB.line = (raw, o = {}) => {
+ const { w = LW, col = INK, speed = SPEED, smooth = true, amp = 1.9, min = 0.04, gap = 0.02, dash = null, until = null } = o;
+ const pts = smooth ? DG.hand(raw, { amp, seed: o.seed ?? WB.S.length + 7, per: 8 }) : raw;
+ const cum = DG.cum(pts), len = cum[cum.length - 1], d = o.dur ?? Math.max(min, len / speed);
+ const s = { kind: 'line', pts, cum, len, w, col, dash, t0: o.t0 ?? WB.cur, until, bb: bbOf(pts, w + 4), handed: o.handed !== false, nofit: !!o.nofit };
+ s.t1 = s.t0 + d; WB.S.push(s); if (o.t0 == null) WB.cur += d + gap; return s;
+};
+const mctx = () => WB._m || (WB._m = document.createElement('canvas').getContext('2d'));
+const DIGF = '"Kalam-700"', isDig = ch => false; // 数字仍用霞鹜文楷(Kalam 只留作备用)
+WB.cf = (ch, size) => isDig(ch) ? `${Math.round(size * 1.02)}px ${DIGF}` : `${size}px ${FONT}`;
+WB.measure = (str, size) => { const g = mctx(); let w = 0; for (const ch of str) { g.font = WB.cf(ch, size); w += g.measureText(ch).width; } return w; };
+// 笔顺:汉字沿 hanzi-writer 的笔画中线一笔一笔露出霞鹜文楷的字(1024 格,y 朝上,顶边 900);数字用手写中线(按字的墨迹框归一化);
+// 其余字符(拉丁字母、标点)仍用之字形揭开。中线只决定「先露哪里、笔尖走哪」,字形本身不变,写完正好是整字。
+const DIGM = {
+ '0': [[[0.55, 0.02], [0.2, 0.15], [0.05, 0.5], [0.2, 0.88], [0.5, 0.98], [0.82, 0.86], [0.95, 0.5], [0.82, 0.13], [0.5, 0.02], [0.3, 0.1]]],
+ '1': [[[0.15, 0.22], [0.6, 0.02], [0.6, 0.98]]],
+ '2': [[[0.1, 0.25], [0.35, 0.03], [0.7, 0.05], [0.88, 0.28], [0.75, 0.55], [0.08, 0.97], [0.95, 0.97]]],
+ '3': [[[0.1, 0.12], [0.45, 0.02], [0.82, 0.15], [0.8, 0.38], [0.45, 0.5], [0.85, 0.62], [0.88, 0.85], [0.5, 0.98], [0.08, 0.88]]],
+ '4': [[[0.68, 0.98], [0.68, 0.02], [0.05, 0.7], [0.97, 0.7]]],
+ '5': [[[0.88, 0.04], [0.25, 0.04], [0.15, 0.48], [0.5, 0.4], [0.88, 0.58], [0.85, 0.85], [0.5, 0.98], [0.1, 0.88]]],
+ '6': [[[0.8, 0.04], [0.35, 0.25], [0.1, 0.62], [0.25, 0.92], [0.55, 0.98], [0.88, 0.8], [0.85, 0.55], [0.5, 0.45], [0.15, 0.6]]],
+ '7': [[[0.05, 0.04], [0.95, 0.04], [0.65, 0.45], [0.38, 0.98]]],
+ '8': [[[0.55, 0.48], [0.2, 0.3], [0.3, 0.06], [0.55, 0.02], [0.8, 0.12], [0.78, 0.32], [0.45, 0.52], [0.12, 0.72], [0.25, 0.94], [0.55, 0.98], [0.88, 0.8], [0.75, 0.6], [0.5, 0.5]]],
+ '9': [[[0.85, 0.32], [0.55, 0.5], [0.2, 0.42], [0.12, 0.18], [0.45, 0.02], [0.85, 0.12], [0.9, 0.4], [0.75, 0.75], [0.45, 0.98]]],
+};
+const soCache = new Map();
+WB.so = (ch, size, wch) => {
+ const key = ch + '|' + size; if (soCache.has(key)) return soCache.get(key);
+ let strokes = null, bw = 0; const M = window.WB_STROKES && window.WB_STROKES[ch];
+ if (M) { const k = size / 1024; strokes = M.map(st => st.map(([X, Y]) => [X * k + (wch - size) / 2, -size * 0.88 + (900 - Y) * k])); bw = size * 0.2; }
+ else if (DIGM[ch]) { const g = mctx(); g.font = WB.cf(ch, size); const m = g.measureText(ch), x0 = -m.actualBoundingBoxLeft, x1 = m.actualBoundingBoxRight, y0 = -m.actualBoundingBoxAscent, y1 = m.actualBoundingBoxDescent;
+ strokes = DIGM[ch].map(st => st.map(([u, v]) => [x0 + u * (x1 - x0), y0 + v * (y1 - y0)])); bw = size * 0.24; }
+ let r = null;
+ if (strokes) { const cums = strokes.map(DG.cum), lens = cums.map(c => c[c.length - 1]), gap = size * 0.1; r = { strokes, cums, lens, gap, bw, tot: lens.reduce((a, b) => a + b, 0) + gap * (strokes.length - 1) }; }
+ soCache.set(key, r); return r;
+};
+// 写到 f(0–1):[遮罩, 笔尖],坐标相对这个字的左边、基线。两笔之间笔尖空中滑到下一笔起点。
+WB.soAt = (so, f, mask = true) => {
+ let d = f * so.tot, tip = so.strokes[0][0]; const p = mask ? new Path2D() : null;
+ for (let j = 0; j < so.strokes.length && d > 0; j++) {
+ const dd = Math.min(d, so.lens[j]); if (mask) p.addPath(DG.revealMask(so.strokes[j], so.cums[j], dd, so.bw)); tip = DG.pointAt(so.strokes[j], so.cums[j], dd);
+ d -= so.lens[j];
+ if (d > 0 && j < so.strokes.length - 1) { if (d < so.gap) { const a = so.strokes[j][so.strokes[j].length - 1], b = so.strokes[j + 1][0], u = d / so.gap; tip = [a[0] + (b[0] - a[0]) * u, a[1] + (b[1] - a[1]) * u]; } d -= so.gap; }
+ }
+ return [p, tip];
+};
+// 手写字:rate 字/秒(正文 ≈14–16,标题 ≈7.5–10)
+WB.text = (str, x, y, size, o = {}) => {
+ const { col = INK, rate = 14, align = 'left', until = null } = o;
+ const chars = [...str], d = o.dur ?? chars.length / rate, g = mctx();
+ const ws = chars.map(ch => { g.font = WB.cf(ch, size); return g.measureText(ch).width; }), w = ws.reduce((a, b) => a + b, 0), x0 = align === 'center' ? x - w / 2 : align === 'right' ? x - w : x;
+ const s = { kind: 'text', str, chars, ws, w, x: x0, y, size, col, t0: o.t0 ?? WB.cur, until, bb: [x0 - 12, y - size * 1.05, x0 + w + 12, y + size * 0.35], handed: true };
+ s.t1 = s.t0 + d; WB.S.push(s); WB.texts.push(str); if (o.t0 == null) WB.cur += d + 0.04; return s;
+};
+// 强调词:不带手,0.32s 放大回落整词弹出。o.at = 落定时刻(念到它的那一刻)
+WB.pop = (str, x, y, size, o = {}) => {
+ const { col = OR, align = 'center', rot = 0, until = null } = o;
+ if (!o.stamp) { // 默认:笔快写出来。写完的那一刻= o.at(念到它的时刻)
+ const n = [...str].length, dur = o.wdur ?? Math.max(0.22, Math.min(0.6, n / 15));
+ const t0 = o.at != null ? o.at - dur : WB.cur;
+ const s = WB.text(str, x, y, size, { col, align, dur, t0, until });
+ s.emph = true; if (o.at != null && o.wdur == null) s.slow = Math.max(0.42, Math.min(0.95, n * 0.17)); // 重点词想慢一点写(看得见笔顺),build 时在不和别的笔打架的前提下往前延
+ if (o.at == null) WB.cur = t0 + dur + 0.04; return s;
+ }
+ const dur = o.dur ?? 0.34, w = WB.measure(str, size), x0 = align === 'center' ? x - w / 2 : align === 'right' ? x - w : x;
+ const t0 = o.at != null ? o.at - dur * 0.55 : WB.cur;
+ const s = { kind: 'pop', str, x: x0 + w / 2, y, w, size, col, rot, t0, t1: t0 + dur, until, bb: [x0 - size * 0.3, y - size * 1.3, x0 + w + size * 0.3, y + size * 0.5] };
+ WB.S.push(s); WB.texts.push(str); if (o.at == null) WB.cur += o.adv ?? 0.1; return s;
+};
+// 铺色(淡入,不推进时间):pts 多边形或 Path2D(Path2D 要给 bb)
+WB.fill = (pts, col = WASH, dur = 0.25, o = {}) => {
+ const path = pts instanceof Path2D ? pts : U.poly(pts);
+ const s = { kind: 'fill', path, col, t0: o.t0 ?? WB.cur, t1: (o.t0 ?? WB.cur) + dur, until: o.until ?? null, bb: o.bb || (pts instanceof Path2D ? null : bbOf(pts, 4)) };
+ WB.S.push(s); return s;
+};
+// 自定义:{ t0, t1, draw(g, q, t) → 笔尖|null, bb, handed, start(), end(), until }
+WB.fade = (arr, t, dur = 0.3) => arr.forEach(s => { s.fadeAt = t; s.fadeDur = dur; });
+WB.custom = o => { const s = { kind: 'custom', handed: false, bb: null, until: null, ...o }; WB.S.push(s); return s; };
+// 斜线排线(橙色浅面):在多边形/圆里画平行斜线,笔速很快
+WB.hatchCircle = (cx, cy, r, o = {}) => {
+ const { gap = 22, ang = -0.8, col = OR, w = 4.2, speed = SPEED * 3.2 } = o, ux = Math.cos(ang), uy = Math.sin(ang), nx = -uy, ny = ux;
+ const out = []; for (let d = -r + gap * 0.6; d <= r - gap * 0.4; d += gap) { const h = Math.sqrt(r * r - d * d) * 0.9;
+ out.push(WB.line([[cx + nx * d - ux * h, cy + ny * d - uy * h], [cx + nx * d + ux * h, cy + ny * d + uy * h]], { col, w, speed, min: 0.022, gap: 0.006, amp: 0.8, until: o.until })); }
+ return out;
+};
+WB.hatchRect = (x, y, w0, h0, o = {}) => { // 45° 斜线填满矩形(逐条裁到矩形内)
+ const { gap = 20, col = OR, w = 4.2, speed = SPEED * 3.4 } = o, out = [];
+ for (let k = gap * 0.5; k < w0 + h0; k += gap) { const a = [x + Math.min(k, w0), y + Math.max(0, k - w0)], b = [x + Math.max(0, k - h0), y + Math.min(k, h0)];
+ out.push(WB.line([[a[0], a[1]], [b[0], b[1]]], { col, w, speed, min: 0.016, gap: 0.004, amp: 0.6, smooth: false, until: o.until })); }
+ return out;
+};
+// 引线:笔在相机平移时画一支橙色虚线箭头,从上一块的尾巴连到下一块的开头(手领着相机走;全图里它们把各块串成一条线)
+WB.lead = (a, b, t0, dur = 0.55, o = {}) => {
+ const mx = (a[0] + b[0]) / 2, my = (a[1] + b[1]) / 2, dx = b[0] - a[0], dy = b[1] - a[1], L = Math.hypot(dx, dy) || 1, bend = o.bend ?? -0.18 * L;
+ const pts = WB.quad(a, [mx - dy / L * bend, my + dx / L * bend], b, 30);
+ const s1 = WB.line(pts, { col: OR, w: 8, dash: [1, 15], t0, dur: dur * 0.85, amp: 1.0, nofit: true });
+ const e = pts[pts.length - 1], p = pts[pts.length - 4], an = Math.atan2(e[1] - p[1], e[0] - p[0]), h = 26;
+ WB.line([[e[0] - Math.cos(an - 0.5) * h, e[1] - Math.sin(an - 0.5) * h], e, [e[0] - Math.cos(an + 0.5) * h, e[1] - Math.sin(an + 0.5) * h]], { col: OR, w: 6, smooth: false, t0: t0 + dur * 0.87, dur: dur * 0.13, nofit: true });
+ return s1;
+};
+WB.arrow = (a, b, o = {}) => {
+ const { bend = 0, col = INK, w = LW, head = 30, dash = null, speed = SPEED * 1.3 } = o;
+ const mx = (a[0] + b[0]) / 2, my = (a[1] + b[1]) / 2, dx = b[0] - a[0], dy = b[1] - a[1], L = Math.hypot(dx, dy) || 1;
+ const c = [mx - dy / L * bend, my + dx / L * bend], pts = WB.quad(a, c, b, 30);
+ const s1 = WB.line(pts, { col, w, dash, speed, until: o.until, amp: o.amp ?? 1.4 });
+ const e = pts[pts.length - 1], p = pts[pts.length - 4], an = Math.atan2(e[1] - p[1], e[0] - p[0]);
+ const s2 = WB.line([[e[0] - Math.cos(an - 0.5) * head, e[1] - Math.sin(an - 0.5) * head], e, [e[0] - Math.cos(an + 0.5) * head, e[1] - Math.sin(an + 0.5) * head]], { col, w, smooth: false, speed: speed * 0.8, until: o.until });
+ return [s1, s2];
+};
+// 一组局部笔画([{p, o:橙, w:线宽倍数, dash, smooth}])放到 (x,y)、缩放 s、旋转 r 后逐笔画出;返回笔画对象数组(方便设 until)
+WB.sk = (strokes, x, y, o = {}) => {
+ const s = o.s || 1, r = o.rot || 0, out = [];
+ for (const k of strokes) {
+ if (k.fillPts) { out.push(WB.fill(WB.xf(k.fillPts, x, y, s, r), k.fillCol || WASH, 0.2, { until: o.until })); continue; }
+ const pts = WB.xf(k.p, x, y, s, r);
+ out.push(WB.line(pts, { w: (k.w || 1) * (o.w || LW), col: k.o ? OR : (o.col || INK), speed: (o.speed || SPEED) * (k.fast ? 2 : 1), smooth: k.smooth !== false, dash: k.dash, until: o.until, gap: o.gap ?? 0.01, min: o.min ?? 0.025, amp: k.amp ?? 1.2 }));
+ }
+ return out;
+};
+// 精灵(会动的画好的东西):笔画在局部坐标里抖动一次就固定(不沸腾),每帧按位置/角度画
+WB.prep = (strokes, lw = LW) => strokes.map(k => k.fillPts ? { fill: U.poly(k.fillPts), col: k.fillCol || WASH } :
+ ({ pts: k.smooth === false ? k.p : DG.hand(k.p, { amp: k.amp ?? 1.1, seed: (k.p.length * 13 + Math.round(k.p[0][0] * 7)) | 0, per: 8 }), w: (k.w || 1) * lw, col: k.o ? OR : INK, dash: k.dash }));
+WB.drawPrep = (g, P, x, y, s = 1, r = 0, alpha = 1) => {
+ g.save(); g.translate(x, y); if (r) g.rotate(r); if (s !== 1) g.scale(s, s); g.globalAlpha *= alpha; g.lineJoin = 'round'; g.lineCap = 'round';
+ for (const k of P) {
+ if (k.fill) { g.fillStyle = k.col; g.fill(k.fill); continue; }
+ g.strokeStyle = k.col; g.lineWidth = k.w / s; if (k.dash) g.setLineDash(k.dash.map(v => v / s));
+ g.beginPath(); k.pts.forEach((p, i) => i ? g.lineTo(p[0], p[1]) : g.moveTo(p[0], p[1])); g.stroke(); if (k.dash) g.setLineDash([]);
+ }
+ g.restore();
+};
+// 一笔画出一个预备好的精灵(逐笔描出,画完后不动),用于「先画后飞」:返回最后一笔的 t1
+WB.drawOn = (P, x, y, o = {}) => {
+ const s = o.s || 1, r = o.rot || 0, out = [];
+ for (const k of P) {
+ if (k.fill) { out.push(WB.custom({ t0: WB.cur, t1: WB.cur + 0.2, until: o.until, bb: o.bb || null, draw(g, q) { g.save(); g.globalAlpha = q; g.translate(x, y); if (r) g.rotate(r); g.scale(s, s); g.fillStyle = k.col; g.fill(k.fill); g.restore(); return null; } })); continue; }
+ const pts = WB.xf(k.pts, x, y, s, r);
+ out.push(WB.line(pts, { w: k.w * (o.lws || 1), col: k.col, dash: k.dash, smooth: false, speed: o.speed || SPEED, until: o.until, gap: 0.01, min: 0.025 }));
+ }
+ return out;
+};
+
+// ---------- 相机 ----------
+// 关键帧全片秒。WB.move(t0,t1,x,y,z) = 从 t0 时的位置移到 (x,y,z),t1 到位。停留期间默认很慢地推近(creep),画面不会死。
+WB.cam0 = (x, y, z) => { WB.K.length = 0; WB.K.push({ t: 0, x, y, z }); };
+WB.move = (t0, t1, x, y, z, o = {}) => {
+ const K = WB.K, last = K[K.length - 1];
+ if (t0 < last.t - 1e-4) { console.warn(`WB.move: ${t0.toFixed(2)} 早于上一个相机键 ${last.t.toFixed(2)},顺延`); t0 = last.t; }
+ if (t0 > last.t + 1e-3) { const hold = t0 - last.t, cr = o.creep ?? 0.007; K.push({ t: t0, x: last.x, y: last.y, z: last.z * (1 + Math.min(0.035, cr * hold)), ease: MO.sineInOut }); }
+ K.push({ t: Math.max(t1, t0 + 0.05), x, y, z, ease: o.ease || MO.sineInOut });
+ if (o.whip) WB.WHIP.push([t0, Math.max(t1, t0 + 0.05)]); // 换行甩镜:WB.draw 里按纯平移做密集拖影
+};
+WB.camAt = t => CAM.at(WB.K, t);
+// 取景:把「t0 落在 [a,b) 里的笔画」框进画面(上下留在屏幕 70–870,左右各留 96),返回 [x,y,z]。
+// 会动的精灵(custom)默认不算,除非它带 fit:true;地面线这类横贯的线可以标 nofit。o.add 追加世界矩形。
+WB.fit = (a, b, o = {}) => {
+ let x0 = 1e9, y0 = 1e9, x1 = -1e9, y1 = -1e9; const ext = r => { x0 = Math.min(x0, r[0]); y0 = Math.min(y0, r[1]); x1 = Math.max(x1, r[2]); y1 = Math.max(y1, r[3]); };
+ for (const s of WB.S) { if (s.t0 < a || s.t0 >= b || !s.bb || s.nofit || s.kind === 'fill') continue; if (s.kind === 'custom' && !s.fit) continue; ext(s.bb); }
+ (o.add || []).forEach(ext);
+ if (x0 > x1) { console.warn(`WB.fit: [${a.toFixed(2)}, ${b.toFixed(2)}) 里没有笔画`); const k = WB.K[WB.K.length - 1]; return [k.x, k.y, k.z]; }
+ const pad = o.pad ?? 50, w = x1 - x0 + 2 * pad, h = y1 - y0 + 2 * pad;
+ const z = U.clamp(Math.min((W - 192) / w, 800 / h), o.zmin ?? 0.12, o.zmax ?? 1.25);
+ return [(x0 + x1) / 2 + (o.dx || 0), (y0 + y1) / 2 + (540 - (o.sy ?? 470)) / z, z, [x0, y0, x1, y1]];
+};
+WB.declip = (cam, a, b, o = {}) => {
+ let [x, y, z, cb] = cam; const z0 = z, M = 30, ok = xx => !cb || (cb[0] >= xx - W / 2 / z + 20 / z && cb[2] <= xx + W / 2 / z - 20 / z);
+ for (let it = 0; it < 8; it++) {
+ const hw = W / 2 / z, hh = H / 2 / z, v = [x - hw, y - hh, x + hw, y + hh]; let moved = false;
+ for (const s of WB.S) {
+ if ((s.kind !== 'text' && s.kind !== 'pop') || s.t0 >= b || (s.t0 >= a && s.t0 < b) || !s.bb || s.fadeAt != null) continue;
+ const bb = s.bb, inter = !(bb[2] < v[0] || bb[0] > v[2] || bb[3] < v[1] || bb[1] > v[3]); if (!inter) continue;
+ const inside = bb[0] >= v[0] + M / z && bb[2] <= v[2] - M / z && bb[1] >= v[1] && bb[3] <= v[3]; if (inside) continue;
+ // 横向被裁:把画框推开,让这串字整个出画(推的距离不超过 o.maxShift)
+ const cx = (bb[0] + bb[2]) / 2, maxS = (o.maxShift ?? 420) / z;
+ if (cx < x && bb[2] > v[0] && bb[2] - v[0] + M / z < maxS && ok(x + bb[2] - v[0] + M / z)) { x += bb[2] - v[0] + M / z; moved = true; break; }
+ if (cx >= x && bb[0] < v[2] && v[2] - bb[0] + M / z < maxS && ok(x - (v[2] - bb[0] + M / z))) { x -= v[2] - bb[0] + M / z; moved = true; break; }
+ // 推不开就把这串字整个框进来(缩放最多让出 20%)
+ if (cb) { const nb = [Math.min(cb[0], bb[0]), cb[1], Math.max(cb[2], bb[2]), cb[3]], z2 = Math.min(z, (W - 192) / (nb[2] - nb[0] + 100));
+ if (z2 >= z0 * 0.8 && (nb[0] !== cb[0] || nb[2] !== cb[2])) { cb = nb; x = (nb[0] + nb[2]) / 2; y = y + 0; z = z2; moved = true; break; } }
+ }
+ if (!moved) break;
+ }
+ return [x, y, z, cb];
+};
+WB.shot = (t, dur, a, b, o = {}) => { let c = WB.fit(a, b, o); if (o.declip !== false) c = WB.declip(c, a, b, o); WB.move(t, t + dur, c[0], c[1], c[2], o); return c; };
+WB.view = cam => { const hw = W / 2 / cam.z, hh = H / 2 / cam.z; return [cam.x - hw, cam.y - hh, cam.x + hw, cam.y + hh]; };
+
+// ---------- 屏幕层特效 ----------
+WB.fx = (t0, t1, draw) => WB.FX.push({ t0, t1, draw });
+
+// ---------- 章节 ----------
+WB.chapter = (id, fn) => { WB.CH[id] = fn; };
+WB.build = () => {
+ if (WB.built) return; WB.built = true;
+ for (const e of ERAS) { const fn = WB.CH[e.id]; if (fn) { const n0 = WB.S.length; fn(e.id); WB.S.slice(n0).forEach(s => (s.ch = e.id)); } }
+ WB.K.sort((a, b) => a.t - b.t);
+ const hs = WB.S.filter(s => s.handed && (s.kind === 'line' || s.kind === 'text' || s.kind === 'custom'));
+ for (const s of hs) if (s.slow && s.t1 - s.t0 < s.slow) { const t0o = s.t0; let lb = s.t1 - s.slow;
+ for (const o of hs) if (o !== s && o.t0 < t0o + 1e-6 && o.t1 > lb - 0.03) lb = o.t1 + 0.03;
+ s.t0 = Math.min(t0o, lb); }
+ // 一支笔同时只能画一笔:后起的那笔(线或普通字)顺延到前一笔写完;顺延不超过 0.35s,自定义动画和重点词不动
+ hs.sort((a, b) => a.t0 - b.t0);
+ for (let pass = 0; pass < 6; pass++) { let moved = false;
+ for (let i = 1; i < hs.length; i++) { const p = hs[i - 1], b = hs[i]; const sh = p.t1 + 0.02 - b.t0;
+ if (sh > 0.03 && sh <= 0.35 && b.kind !== 'custom' && !b.emph) { b.t0 += sh; b.t1 += sh; moved = true; }
+ else if (sh > 0.03 && b.emph && b.t1 - (p.t1 + 0.02) >= 0.1) { b.t0 = p.t1 + 0.02; moved = true; } }
+ hs.sort((a, b) => a.t0 - b.t0); if (!moved) break; }
+ WB.HS = hs;
+ U.assertGlyphs('LXGWWenKai-500', WB.texts.join(''), 'wb');
+};
+// 每章笔画排到了哪(调试):[id, 段起, 段止, 最早笔, 最晚笔]
+WB.report = () => ERAS.map(e => { const ss = WB.S.filter(s => s.ch === e.id); const T = TIMING.seg[e.id];
+ return [e.id, +T.t0.toFixed(2), +(T.t0 + T.dur).toFixed(2), ss.length ? +Math.min(...ss.map(s => s.t0)).toFixed(2) : null, ss.length ? +Math.max(...ss.map(s => s.t1)).toFixed(2) : null, ss.length]; });
+
+// ---------- 画 ----------
+const drawOne = (g, s, t) => {
+ if (t < s.t0 || (s.until != null && t >= s.until)) return null;
+ const q = s.t1 > s.t0 ? clamp((t - s.t0) / (s.t1 - s.t0)) : 1;
+ if (s.kind === 'line') {
+ g.strokeStyle = s.col; g.lineWidth = s.w; if (s.dash) g.setLineDash(s.dash);
+ const tip = DG.drawPartial(g, s.pts, s.cum, s.len * MO.sineInOut(q)); if (s.dash) g.setLineDash([]); return tip;
+ }
+ if (s.kind === 'text') {
+ g.font = `${s.size}px ${FONT}`; g.fillStyle = s.col; g.textBaseline = 'alphabetic'; g.textAlign = 'left';
+ const n = s.chars.length, k = Math.min(n, q * n), done = Math.floor(k); let x = s.x, tip = null;
+ const sd = (s.x * 7 + s.y * 3) | 0, jit = i => [U.hash(sd, i) - 0.5, U.hash(sd + 1, i) - 0.5];
+ let bump = 1; if (s.emph && t > s.t1) { const u = (t - s.t1) / 0.28; if (u < 1) bump = 1 + 0.07 * Math.sin(u * Math.PI); }
+ if (bump !== 1) { const cx = s.x + s.w / 2, cy = s.y - s.size * 0.35; g.save(); g.translate(cx, cy); g.scale(bump, bump); g.translate(-cx, -cy); }
+ const put = (i, xx) => { const [a, b] = jit(i); g.save(); g.font = WB.cf(s.chars[i], s.size); g.translate(xx + s.ws[i] / 2, s.y + b * s.size * 0.05); g.rotate(a * 0.07); g.fillText(s.chars[i], -s.ws[i] / 2, 0); g.restore(); };
+ for (let i = 0; i < n; i++) {
+ if (i < done) put(i, x);
+ else if (i === done && k < n) {
+ const so = WB.so(s.chars[i], s.size, s.ws[i]);
+ if (so) { const [m, tp] = WB.soAt(so, k - done); g.save(); g.translate(x, s.y); g.clip(m); g.translate(-x, -s.y); put(i, x); g.restore(); tip = [x + tp[0], s.y + tp[1]]; }
+ else { const zz = DG.zigzag(x - 2, s.y - s.size * 0.95, s.ws[i] + 4, s.size * 1.15, 3), cum = DG.cum(zz), d = cum[cum.length - 1] * (k - done);
+ g.save(); g.clip(DG.revealMask(zz, cum, d, s.size * 0.62)); put(i, x); g.restore(); tip = DG.pointAt(zz, cum, d); }
+ } else break;
+ x += s.ws[i];
+ }
+ if (bump !== 1) g.restore();
+ return tip;
+ }
+ if (s.kind === 'pop') {
+ const e = MO.backOut(q, 2.4);
+ g.save(); g.font = `${s.size}px ${FONT}`; g.fillStyle = s.col; g.textBaseline = 'alphabetic'; g.textAlign = 'center'; g.globalAlpha *= clamp(q * 4);
+ g.translate(s.x, s.y - s.size * 0.35); if (s.rot) g.rotate(s.rot); g.scale(e, e); g.fillText(s.str, 0, s.size * 0.35); g.restore(); return null;
+ }
+ if (s.kind === 'fill') { g.save(); g.globalAlpha *= q; g.fillStyle = s.col; g.fill(s.path); g.restore(); return null; }
+ if (s.kind === 'custom') { g.save(); const r = s.draw(g, q, t); g.restore(); return r; }
+ return null;
+};
+const smudge = () => PAINT.cached('wb_smudge', 1024, 1024, g => { const r = U.rng(5); for (let i = 0; i < 26; i++) { g.fillStyle = `rgba(120,120,130,${0.0006 + r() * 0.0011})`; g.beginPath(); g.ellipse(r() * 1024, r() * 1024, 80 + r() * 220, 14 + r() * 40, r() * 3, 0, 7); g.fill(); } });
+function drawBoard(c, t, cam) {
+ c.fillStyle = BOARD; c.fillRect(0, 0, W, H);
+ c.save(); const ox = -(((cam.x * cam.z) % 1024) + 1024) % 1024, oy = -(((cam.y * cam.z) % 1024) + 1024) % 1024;
+ c.translate(ox, oy); c.fillStyle = c.createPattern(smudge(), 'repeat'); c.fillRect(0, 0, W + 1024, H + 1024); c.restore();
+ const [vx0, vy0, vx1, vy1] = WB.view(cam);
+ c.save(); CAM.apply(c, cam); c.lineJoin = 'round'; c.lineCap = 'round';
+ let tip = null, col = null;
+ for (const s of WB.S) {
+ if (t < s.t0) continue;
+ const b = s.bb; if (b && (b[2] < vx0 || b[0] > vx1 || b[3] < vy0 || b[1] > vy1)) continue;
+ let p;
+ if (s.fadeAt != null && t >= s.fadeAt) { // 擦掉(白板语言,不用淡出):板擦从左往右抹过去,抹过的地方只留一层很淡的残影
+ const k = (t - s.fadeAt) / (s.fadeDur || 0.3), b = s.bb;
+ if (!b) { if (k >= 1) continue; c.save(); c.globalAlpha = 1 - k; p = drawOne(c, s, t); c.restore(); }
+ else { const x = b[0] - 30 + (b[2] - b[0] + 60) * MO.sineInOut(clamp(k)), sl = (b[3] - b[1]) * 0.25;
+ c.save(); c.globalAlpha = 0.07; drawOne(c, s, t); c.restore();
+ if (k < 1) { c.save(); c.beginPath(); c.moveTo(x + sl, b[1] - 60); c.lineTo(b[2] + 1e4, b[1] - 60); c.lineTo(b[2] + 1e4, b[3] + 60); c.lineTo(x - sl, b[3] + 60); c.closePath(); c.clip(); p = drawOne(c, s, t); c.restore(); } } }
+ else p = drawOne(c, s, t);
+ if (p && t < s.t1 && s.handed) { tip = p; col = s.col; }
+ }
+ c.restore();
+ return { tip, col };
+}
+// 笔:在画 → 笔尖;两笔空档 ≤0.7s → 沿弧线滑过去;更长 → 0.35s 退到右下屏外,下一笔前 0.35s 再进来
+const OFF = [W + 180, H + 340];
+const endPt = s => s.kind === 'line' ? s.pts[s.pts.length - 1] : s.kind === 'text' ? [s.x + s.w, s.y - s.size * 0.35] : s.end ? s.end() : [(s.bb[0] + s.bb[2]) / 2, (s.bb[1] + s.bb[3]) / 2];
+const startPt = s => s.kind === 'line' ? s.pts[0] : s.kind === 'text' ? [s.x, s.y - s.size * 0.6] : s.start ? s.start() : [(s.bb[0] + s.bb[2]) / 2, (s.bb[1] + s.bb[3]) / 2];
+function penAt(t, cam, tip) {
+ if (tip) return CAM.toScreen(cam, tip[0], tip[1]);
+ let prev = null, next = null;
+ for (const s of WB.HS) { if (s.t1 <= t) { if (!prev || s.t1 > prev.t1) prev = s; } else if (s.t0 > t) { next = s; break; } else return null; }
+ if (prev && next && next.t0 - prev.t1 <= 0.7) {
+ const q = MO.sineInOut((t - prev.t1) / (next.t0 - prev.t1)), a = CAM.toScreen(cam, ...endPt(prev)), b = CAM.toScreen(cam, ...startPt(next));
+ return [lerp(a[0], b[0], q), lerp(a[1], b[1], q) - Math.sin(q * Math.PI) * Math.min(90, 20 + Math.hypot(b[0] - a[0], b[1] - a[1]) * 0.15)];
+ }
+ const inn = next ? MO.cubicOut(clamp((t - (next.t0 - 0.35)) / 0.35)) : 0;
+ if (inn > 0) { const b = CAM.toScreen(cam, ...startPt(next)); return [lerp(OFF[0], b[0], inn), lerp(OFF[1], b[1], inn)]; }
+ if (prev) { const out = MO.cubicIn(clamp((t - prev.t1) / 0.35)); if (out >= 1) return null; const a = CAM.toScreen(cam, ...endPt(prev)); return [lerp(a[0], OFF[0], out), lerp(a[1], OFF[1], out)]; }
+ return null;
+}
+// 不画也能算出某时刻笔尖在哪(只算线和字;自定义笔画返回 null,退回到滑行位置)——给笔的倾斜/抬起算速度用
+function tipAt(t) {
+ let cur = null; for (const s of WB.HS) { if (s.t0 > t) break; if (t < s.t1 && (s.until == null || t < s.until)) cur = s; }
+ if (!cur) return null; const q = U.clamp((t - cur.t0) / (cur.t1 - cur.t0));
+ if (cur.kind === 'line') return DG.pointAt(cur.pts, cur.cum, cur.len * MO.sineInOut(q));
+ if (cur.kind === 'text') { const n = cur.chars.length, k = Math.min(n - 1e-6, q * n), i = Math.floor(k); let x = cur.x; for (let j = 0; j < i; j++) x += cur.ws[j];
+ const so = WB.so(cur.chars[i], cur.size, cur.ws[i]); if (so) { const tp = WB.soAt(so, k - i, false)[1]; return [x + tp[0], cur.y + tp[1]]; }
+ const zz = DG.zigzag(x - 2, cur.y - cur.size * 0.95, cur.ws[i] + 4, cur.size * 1.15, 3), cm = DG.cum(zz); return DG.pointAt(zz, cm, cm[cm.length - 1] * (k - i)); }
+ return null;
+}
+WB.draw = (c, t) => {
+ if (!WB.built) WB.build();
+ const cam = WB.camAt(t);
+ const whip = WB.WHIP.some(([a, b]) => t > a && t < b);
+ // 运动模糊。原则:叠出来的每一层间距 ≤ 几个像素,看起来是一道顺滑的拖影,不是台阶状的残影。
+ // 换行甩镜(纯平移):板子只画一次,沿速度方向密集错位叠 n 层(半帧快门);其余快速运镜(带缩放):按时间取 N 个时刻各画一遍再等权叠,快门按「每层间距 ≤ 8px」收窄。
+ const cp = WB.camAt(t - 1 / 30), vw = WB.view(cam), pts = [[cam.x, cam.y], [vw[0], vw[1]], [vw[2], vw[3]]];
+ const disp = pts.map(p => { const a = CAM.toScreen(cam, p[0], p[1]), b = CAM.toScreen(cp, p[0], p[1]); return [a[0] - b[0], a[1] - b[1]]; }), dpx = Math.max(...disp.map(d => Math.hypot(d[0], d[1])));
+ const buf = () => WB._buf || (WB._buf = (() => { const b = document.createElement('canvas'); b.width = W; b.height = H; return b; })());
+ let res;
+ if (dpx < 24) res = drawBoard(c, t, cam);
+ else if (whip) {
+ const b = buf(), g = b.getContext('2d'); g.setTransform(1, 0, 0, 1, 0, 0); res = drawBoard(g, t, cam);
+ // 倍增法做 2^m 层等权错位(m 次叠加就够,比逐层叠快得多)
+ const [vx, vy] = disp[0], L = 0.5, m = Math.min(6, Math.max(2, Math.ceil(Math.log2(dpx * L / 2))));
+ const b2 = WB._buf2 || (WB._buf2 = (() => { const x = document.createElement('canvas'); x.width = W; x.height = H; return x; })());
+ let A = b, B = b2; for (let k = 0; k < m; k++) { const f = L / Math.pow(2, k + 1), gB = B.getContext('2d'); gB.setTransform(1, 0, 0, 1, 0, 0); gB.globalAlpha = 1; gB.fillStyle = BOARD; gB.fillRect(0, 0, W, H); gB.drawImage(A, 0, 0); gB.globalAlpha = 0.5; gB.drawImage(A, vx * f, vy * f); gB.globalAlpha = 1; [A, B] = [B, A]; }
+ c.drawImage(A, 0, 0);
+ } else {
+ const b = buf(), g = b.getContext('2d'), N = Math.min(cam.z < 0.5 ? 6 : 8, Math.ceil(dpx / 10)), sh = Math.min(0.6, 4 * (N - 1) / dpx);
+ for (let i = 0; i < N; i++) { const ti = t - (sh / 30) * i / (N - 1); g.setTransform(1, 0, 0, 1, 0, 0); const r = drawBoard(g, ti, WB.camAt(ti)); if (!i) res = r; c.save(); c.globalAlpha = 1 / (i + 1); c.drawImage(b, 0, 0); c.restore(); }
+ }
+ let fxTip = null;
+ for (const f of WB.FX) if (t >= f.t0 && t < f.t1) { c.save(); const r = f.draw(c, t, cam); c.restore(); if (r) fxTip = r; }
+ const pen = fxTip ? fxTip.slice(0, 2) : penAt(t, cam, res.tip); if (fxTip) res.col = fxTip[2] || INK;
+ if (pen) {
+ const t1 = t - 1 / 30, c1 = WB.camAt(t1), tp = tipAt(t1), p0 = penAt(t1, c1, tp) || pen, vx = pen[0] - p0[0], vy = pen[1] - p0[1];
+ const tilt = U.clamp(vx * 0.004 - vy * 0.002, -0.22, 0.22) + Math.sin(t * 7) * 0.03, lift = res.tip ? 0 : Math.min(14, Math.hypot(vx, vy) * 0.25);
+ const ha = fxTip ? 1 : U.clamp((cam.z - 0.36) / 0.16); // 全景拉远时手淡出,笔画自己长出来
+ if (WB.HANDI) { if (ha > 0) { c.save(); c.globalAlpha = ha; WB.drawHand(c, pen[0] + lift * 0.5, pen[1] - lift, res.col || INK, tilt, fxTip ? 1 : poseAt(t), U.clamp(0.45 + 0.6 * cam.z, 0.62, 1)); c.restore(); } } else DG.pen(c, pen[0] + lift * 0.5, pen[1] - lift, res.col || INK, tilt);
+ }
+};
+// 握笔手:AI 生成的线稿手三种姿势(1 写字/短笔画,2 拉长横线,3 抬笔悬空),1024 坐标里的笔尖 tip 对准落笔点;
+// 袖子从出画的上下沿 U、L 沿方向 d 用代码延伸出去,手永远不会在画面里「断」掉。写橙色时把笔尖涂成橙色。投影=同图黑色剪影,往右下错开、很淡。
+// 数据由 assets/make_hand.py 量出。
+const HANDS = { 1: { tip: [182, 143], U: [1023, 799], L: [747, 1023], d: [0.748, 0.664] }, 2: { tip: [108, 254], U: [1023, 657], L: [959, 1023], d: [0.904, 0.427] }, 3: { tip: [240, 91], U: [1023, 821], L: [757, 1023], d: [0.733, 0.68] } };
+const HS = 0.6;
+const handSh = n => { const k = '_hsh' + n; if (WB[k]) return WB[k]; const im = WB.HANDI[n], b = document.createElement('canvas'); b.width = im.width; b.height = im.height; const g = b.getContext('2d'); g.drawImage(im, 0, 0); g.globalCompositeOperation = 'source-in'; g.fillStyle = 'rgba(0,0,0,0.13)'; g.fillRect(0, 0, b.width, b.height); return (WB[k] = b); };
+WB.drawHand = (c, x, y, col, tilt, pose = 1, f = 1) => {
+ const H = HANDS[pose], im = WB.HANDI[pose], { tip, U, L, d } = H, far = 3000;
+ c.save(); c.translate(x, y); c.rotate(tilt * 0.8); c.scale(HS * f, HS * f); c.translate(-tip[0], -tip[1]);
+ const sleeve = (dx, dy, fill, line) => { c.beginPath(); c.moveTo(U[0] - 2 + dx, U[1] + dy); c.lineTo(U[0] + d[0] * far + dx, U[1] + d[1] * far + dy); c.lineTo(L[0] + d[0] * far + dx, L[1] + d[1] * far + dy); c.lineTo(L[0] + dx, L[1] - 2 + dy); c.lineTo(1023 + dx, 1023 + dy); c.lineTo(1023 + dx, U[1] + dy); c.closePath(); c.fillStyle = fill; c.fill();
+ if (line) { c.strokeStyle = '#111'; c.lineWidth = 6; c.beginPath(); c.moveTo(U[0] - 1, U[1] - 1); c.lineTo(U[0] + d[0] * far, U[1] + d[1] * far); c.moveTo(L[0] - 1, L[1]); c.lineTo(L[0] + d[0] * far, L[1] + d[1] * far); c.stroke(); } };
+ sleeve(26, 30, 'rgba(0,0,0,0.13)', false); c.drawImage(handSh(pose), 26, 30, 1024, 1024);
+ sleeve(0, 0, '#fdfdfd', true); c.drawImage(im, 0, 0, 1024, 1024);
+ if (col !== INK) { const a = Math.atan2(H.d[1], H.d[0]); c.translate(tip[0], tip[1]); c.rotate(pose === 3 ? 0.95 : pose === 2 ? 0.28 : 0.62); c.fillStyle = col; c.beginPath(); c.moveTo(-3, 0); c.lineTo(36, -11); c.lineTo(36, 11); c.closePath(); c.fill(); }
+ c.restore();
+};
+// 这一刻用哪种姿势:正在画长横线→2;正在画别的→1;两笔之间空档超过 0.25s→3(抬笔),短空档沿用上一笔的姿势
+const strokePose = s => { if (s._pose) return s._pose; let p = 1; if (s.kind === 'line' && s.len > 220) { const a = s.pts[0], b = s.pts[s.pts.length - 1]; if (Math.abs(b[0] - a[0]) > 2.2 * Math.abs(b[1] - a[1])) p = 2; } return (s._pose = p); };
+function poseAt(t) {
+ let prev = null, next = null;
+ for (const s of WB.HS) { if (s.t0 <= t && t < s.t1 && (s.until == null || t < s.until)) return strokePose(s); if (s.t1 <= t) { if (!prev || s.t1 > prev.t1) prev = s; } else if (s.t0 > t && !next) next = s; }
+ if (prev && next && next.t0 - prev.t1 < 0.25) return strokePose(prev);
+ return 3;
+}
+WB.scene = { init(IMG) { const I = n => IMG && IMG[`spacex_wb/assets/hand_${n}.png`]; WB.HANDI = I(1) ? { 1: I(1), 2: I(2), 3: I(3) } : null; WB.build(); }, draw(c, lt, t) { WB.draw(c, t); } };
+
+// =====================================================================================
+// 画稿库:全部返回局部笔画 [{p, o, w, dash, smooth, fillPts}],原点见各函数说明
+// =====================================================================================
+const A = (cx, cy, rx, ry, a0, a1, n = 20) => DG.arcPts(cx, cy, rx, ry, a0, a1, n);
+const ogive = (w, h, y0, n = 12) => { const L = [], R = []; for (let i = 0; i <= n; i++) { const u = i / n, hw = w / 2 * Math.sqrt(1 - u * u) * (1 - 0.12 * u); L.push([-hw, y0 - h * u]); R.push([hw, y0 - h * u]); } return L.concat(R.reverse()); };
+const D = WB.D = {};
+// 猎鹰1号:底部中心 (0,0),高 h(不含喷管)
+// 尖头锥:底宽 w、高 h、底边 y0;从左下沿左边上到尖、再沿右边下来(尖头,不是圆头)
+const cone = (w, h, y0, n = 12) => { const L = [], R = []; for (let i = 0; i <= n; i++) { const u = i / n, hw = w / 2 * (1 - Math.pow(u, 1.7)); L.push([-hw, y0 - h * u]); R.push([hw, y0 - h * u]); } return L.concat(R.reverse().slice(1)); };
+const shiftUp = (out, dy) => out.map(k => k.fillPts ? { ...k, fillPts: k.fillPts.map(([x, y]) => [x, y - dy]) } : { ...k, p: k.p.map(([x, y]) => [x, y - dy]) });
+// 发动机喷口:平底梯形,整支火箭往上挪,让喷口底边落在 y=0(站在地平线上)
+const nozzle = (d, y, k = 0.42, hh = 0.42) => ({ p: [[-d * 0.26, y], [-d * k, y + d * hh], [d * k, y + d * hh], [d * 0.26, y]], w: 0.85, smooth: false });
+// 猎鹰1号:喷口底中心 (0,0),箭体高 h
+D.falcon1 = (h) => { const m = h / 22.7, d = 1.7 * m * 2.3, yb = -19.5 * m, yi = -16 * m;
+ const out = [{ p: [...WB.dense([[d / 2, 0], [-d / 2, 0], [-d / 2, yb]], 8), ...cone(d, 3.6 * m * 1.15, yb).slice(1, -1), ...WB.dense([[d / 2, yb], [d / 2, 0]], 8)] },
+ { p: [[-d / 2, yi], [d / 2, yi]], w: 0.8, smooth: false }, { p: [[-d / 2, yi - 0.9 * m], [d / 2, yi - 0.9 * m]], w: 0.6, smooth: false },
+ { p: [[-d / 2, -2.4 * m], [d / 2, -2.4 * m]], w: 0.7, smooth: false }, nozzle(d, 0)];
+ for (let k = 0; k < 3; k++) out.push({ p: [[-d / 2 + d * (0.1 + k * 0.3), yi], [-d / 2 + d * (0.3 + k * 0.3), yi - 0.9 * m]], w: 0.45, smooth: false });
+ return shiftUp(out, d * 0.42); };
+// 猎鹰9号:o.stage 'full'|'booster';o.legs 0..1;o.fins;o.payload 'fairing'|'dragon';喷口底中心 (0,0),总高 h
+D.falcon9 = (h, o = {}) => {
+ const booster = o.stage === 'booster', m = h / (booster ? 41 : o.payload === 'dragon' ? 61 : 67), d = 3.7 * m * 1.7, H1 = 41 * m, out = [];
+ if (booster) out.push({ p: WB.dense([[-d / 2, 0], [-d / 2, -H1], [d / 2, -H1], [d / 2, 0], [-d / 2, 0]], 8) });
+ else if (o.payload === 'dragon') { const top = -54 * m; out.push({ p: WB.dense([[-d / 2, 0], [-d / 2, top], [d / 2, top], [d / 2, 0], [-d / 2, 0]], 8) });
+ const cw = d * 1.04; out.push({ p: [[-cw / 2, top], [-cw * 0.33, top - 3.6 * m * 1.4], ...A(0, top - 3.6 * m * 1.4, cw * 0.33, cw * 0.18, Math.PI, Math.PI * 2, 10), [cw * 0.33, top - 3.6 * m * 1.4], [cw / 2, top]] }); }
+ else { const tf = -56 * m; // 整流罩与箭体同宽,尖头
+ out.push({ p: [...WB.dense([[d / 2, 0], [-d / 2, 0], [-d / 2, tf]], 10), ...cone(d, 11 * m, tf).slice(1, -1), ...WB.dense([[d / 2, tf], [d / 2, 0]], 10)] });
+ out.push({ p: [[-d / 2, tf + 0.2 * m], [d / 2, tf + 0.2 * m]], w: 0.6, smooth: false }); }
+ out.push({ p: [[-d / 2, -H1 + 4.2 * m], [d / 2, -H1 + 4.2 * m]], w: 0.75, smooth: false }); // 级间段
+ out.push({ fillPts: [[-d / 2, -H1 + 4.2 * m], [d / 2, -H1 + 4.2 * m], [d / 2, -H1], [-d / 2, -H1]], fillCol: 'rgba(10,5,3,.82)' }); // 猎鹰9号标志性的黑色级间段(和猎鹰1号一眼区分)
+ if (o.fins) for (const s of [-1, 1]) out.push({ p: WB.dense([[s * d / 2, -H1 + 0.6 * m], [s * (d / 2 + 1.3 * m * o.fins), -H1 + 0.6 * m], [s * (d / 2 + 1.3 * m * o.fins), -H1 + 2.2 * m], [s * d / 2, -H1 + 2.2 * m]], 3), w: 0.65, smooth: false });
+ const lg = o.legs ?? 0, L = 9 * m, ang = lg * 1.95;
+ if (lg > 0.02) for (const s of [-1, 1]) { const x0 = s * d / 2, y0 = -0.8 * m, x1 = x0 + s * Math.sin(ang) * L, y1 = y0 - Math.cos(ang) * L;
+ out.push({ p: [[x0, y0 - 3 * m], [x1, y1]], w: 0.85, smooth: false }); if (lg > 0.5) out.push({ p: [[x1 - s * 0.6 * m, y1], [x1 + s * 0.9 * m, y1]], w: 0.85, smooth: false }); }
+ out.push(nozzle(d, 0, 0.36, 0.3));
+ return shiftUp(out, d * 0.3);
+};
+// 重型猎鹰:三芯并联(中芯带整流罩,两侧助推器尖头锥);喷口底中心 (0,0),高 h
+D.heavy = (h) => { const m = h / 67, d = 3.7 * m * 1.7, gap = d * 0.12, out = D.falcon9(h, {});
+ const side = []; for (const s of [-1, 1]) { const dx = s * (d + gap), H1 = 41 * m;
+ side.push({ p: [...WB.dense([[dx + d / 2, 0], [dx - d / 2, 0], [dx - d / 2, -H1]], 8), ...cone(d, 7 * m, -H1).slice(1, -1).map(([x, y]) => [x + dx, y]), ...WB.dense([[dx + d / 2, -H1], [dx + d / 2, 0]], 8)] });
+ side.push({ p: [[dx - d / 2, -H1 + 4.2 * m], [dx + d / 2, -H1 + 4.2 * m]], w: 0.75, smooth: false });
+ side.push({ p: [[dx - d * 0.26, 0], [dx - d * 0.36, d * 0.3], [dx + d * 0.36, d * 0.3], [dx + d * 0.26, 0]], w: 0.85, smooth: false }); }
+ return out.concat(shiftUp(side, d * 0.3)); };
+// 龙飞船舱体(载人龙外形):底部中心 (0,0),底宽 w;o.crew 舷窗里两个不透明面罩的头盔;o.trunk 尾段
+D.dragon = (w, o = {}) => { const out = [], y0 = o.trunk ? -w * 0.62 : 0, top = y0 - w * 0.9;
+ if (o.trunk) out.push({ p: WB.dense([[-w * 0.47, y0], [-w * 0.47, 0], [w * 0.47, 0], [w * 0.47, y0]], 6) });
+ out.push({ p: [[-w / 2, y0], [-w * 0.32, top], ...A(0, top, w * 0.32, w * 0.2, Math.PI, Math.PI * 2, 12), [w * 0.32, top], [w / 2, y0], [-w / 2, y0]] });
+ out.push({ p: WB.circ(w * 0.14, y0 - w * 0.6, w * 0.075, 1.05), w: 0.75 });
+ out.push({ p: WB.dense([[-w * 0.3, y0 - w * 0.12], [-w * 0.24, y0 - w * 0.62], [-w * 0.05, y0 - w * 0.62], [-w * 0.08, y0 - w * 0.12]], 4), w: 0.6, smooth: false });
+ out.push({ p: [[-w * 0.5, y0 - w * 0.06], [w * 0.5, y0 - w * 0.06]], w: 0.6, smooth: false });
+ return out; };
+// 星舰:part 'full'|'ship'|'booster';底部中心 (0,0),高 h(全箭按 123m 比例);o.flap 襟翼摆角
+D.starship = (h, part = 'full', o = {}) => {
+ const tot = part === 'full' ? 123 : part === 'ship' ? 52 : 71, m = h / tot, d = 9 * m * 1.35, out = [];
+ const boost = (y) => { const H = 71 * m;
+ out.push({ p: WB.dense([[-d / 2, y], [-d / 2, y - H], [d / 2, y - H], [d / 2, y], [-d / 2, y]], 10) });
+ out.push({ p: [[-d / 2, y - H + 2.2 * m], [d / 2, y - H + 2.2 * m]], w: 0.7 });
+ for (const s of [-1, 1]) out.push({ p: WB.dense([[s * d / 2, y - H + 4 * m], [s * (d / 2 + 2.6 * m), y - H + 4 * m], [s * (d / 2 + 2.6 * m), y - H + 7 * m], [s * d / 2, y - H + 7 * m]], 3), w: 0.7, smooth: false });
+ out.push({ p: [[-d * 0.32, y], [-d * 0.4, y + d * 0.18], [d * 0.4, y + d * 0.18], [d * 0.32, y]], w: 0.8, smooth: false }); };
+ const shp = (y) => { const Hc = 36 * m, Hn = 16 * m;
+ out.push({ p: [[-d / 2, y], [-d / 2, y - Hc], ...ogive(d, Hn, y - Hc), [d / 2, y - Hc], [d / 2, y], [-d / 2, y]] });
+ for (const k of [0.3, 0.6]) out.push({ p: [[-d / 2, y - Hc * k], [d / 2, y - Hc * k]], w: 0.45, smooth: false }); // 不锈钢分段线
+ for (let k = 0; k < 4; k++) out.push({ p: [[-d / 2, y - Hc * (0.12 + k * 0.22)], [-d * 0.18, y - Hc * (0.2 + k * 0.22)]], w: 0.45, smooth: false }); // 迎风面隔热瓦
+ const f = o.flap || 0;
+ for (const s of [-1, 1]) { out.push({ p: [[s * d / 2, y - 2 * m], [s * (d / 2 + 3.4 * m), y - 1 * m + f * 2 * m], [s * (d / 2 + 3.4 * m), y - 10 * m + f * 2 * m], [s * d / 2, y - 11 * m]], w: 0.8, smooth: false });
+ out.push({ p: [[s * d * 0.42, y - Hc - 5 * m], [s * (d * 0.42 + 2.4 * m), y - Hc - 4 * m], [s * (d * 0.36 + 2.0 * m), y - Hc - 10 * m], [s * d * 0.34, y - Hc - 11 * m]], w: 0.75, smooth: false }); }
+ if (part === 'ship') out.push({ p: [[-d * 0.3, y], [-d * 0.36, y + d * 0.16], [d * 0.36, y + d * 0.16], [d * 0.3, y]], w: 0.8, smooth: false }); };
+ if (part === 'booster') boost(0); else if (part === 'ship') shp(0); else { boost(0); shp(-71 * m); }
+ return out;
+};
+// 发射塔(格构):底部中心 (0,0),高 h、宽 w;不含机械臂
+D.tower = (h, w = 90) => { const out = [{ p: [[-w / 2, 0], [-w / 2, -h]], smooth: false }, { p: [[w / 2, 0], [w / 2, -h]], smooth: false }];
+ const n = Math.round(h / w), zz = []; for (let i = 0; i <= n; i++) zz.push([i % 2 ? w / 2 : -w / 2, -h * i / n]); out.push({ p: zz, w: 0.6, smooth: false });
+ out.push({ p: [[-w * 0.7, -h], [w * 0.7, -h]], smooth: false }, { p: [[-w * 1.2, 0], [w * 1.2, 0]], smooth: false }); return out; };
+// 国际空间站:中心 (0,0),总宽 s
+D.iss = (s) => { const out = [], tw = s, th = s * 0.03;
+ out.push({ p: WB.dense([[-tw / 2, -th / 2], [tw / 2, -th / 2], [tw / 2, th / 2], [-tw / 2, th / 2], [-tw / 2, -th / 2]], 8), w: 0.8 });
+ for (const x of [-0.42, -0.3, 0.3, 0.42]) for (const sy of [-1, 1]) { const px = x * tw, pw = s * 0.09, ph = s * 0.28, py = sy < 0 ? -th / 2 - ph : th / 2;
+ out.push({ p: WB.dense([[px - pw / 2, py], [px + pw / 2, py], [px + pw / 2, py + ph], [px - pw / 2, py + ph], [px - pw / 2, py]], 4), w: 0.7 });
+ out.push({ p: [[px, py], [px, py + ph]], w: 0.4, smooth: false }); out.push({ p: [[px - pw / 2, py + ph / 2], [px + pw / 2, py + ph / 2]], w: 0.4, smooth: false }); }
+ out.push({ p: WB.dense([[-s * 0.05, th / 2], [-s * 0.05, s * 0.2], [s * 0.05, s * 0.2], [s * 0.05, th / 2]], 6), w: 0.85 }); // 竖着的舱段
+ out.push({ p: WB.dense([[-s * 0.13, s * 0.06], [s * 0.13, s * 0.06], [s * 0.13, s * 0.12], [-s * 0.13, s * 0.12], [-s * 0.13, s * 0.06]], 4), w: 0.8 }); // 横舱
+ out.push({ p: WB.dense([[-s * 0.03, s * 0.2], [-s * 0.03, s * 0.24], [s * 0.03, s * 0.24], [s * 0.03, s * 0.2]], 2), w: 0.75 }); // 对接口(下)
+ return out; };
+WB.issPort = (x, y, s) => [x, y + s * 0.24];
+D.earth = (r) => [{ p: WB.circ(0, 0, r, 1.05) },
+ { p: [[-r * 0.62, -r * 0.42], [-r * 0.36, -r * 0.6], [-r * 0.02, -r * 0.5], [r * 0.08, -r * 0.62], [r * 0.32, -r * 0.42], [r * 0.12, -r * 0.18], [r * 0.2, r * 0.06], [-r * 0.12, r * 0.1], [-r * 0.24, -r * 0.1], [-r * 0.5, -r * 0.08], [-r * 0.62, -r * 0.42]], w: 0.75 },
+ { p: [[-r * 0.02, r * 0.36], [r * 0.32, r * 0.24], [r * 0.6, r * 0.34], [r * 0.66, r * 0.56], [r * 0.36, r * 0.7], [r * 0.18, r * 0.58], [-r * 0.02, r * 0.36]], w: 0.75 }];
+D.moon = (r) => [{ p: WB.circ(0, 0, r, 1.05) }, { p: WB.circ(-r * 0.3, -r * 0.25, r * 0.2, 1.05), w: 0.7 }, { p: WB.circ(r * 0.35, r * 0.1, r * 0.14, 1.05), w: 0.7 }, { p: WB.circ(-r * 0.1, r * 0.45, r * 0.1, 1.05), w: 0.7 }];
+D.house = (s) => [{ p: [[-s * 0.5, 0], [-s * 0.5, -s * 0.9], [s * 0.5, -s * 0.9], [s * 0.5, 0]], smooth: false }, { p: [[-s * 0.7, -s * 0.82], [0, -s * 1.5], [s * 0.7, -s * 0.82]], smooth: false }, { p: [[-s * 0.15, 0], [-s * 0.15, -s * 0.5], [s * 0.15, -s * 0.5], [s * 0.15, 0]], w: 0.85, smooth: false }];
+D.sat = (s) => [{ p: WB.dense([[-s * 0.16, -s * 0.12], [s * 0.16, -s * 0.12], [s * 0.16, s * 0.12], [-s * 0.16, s * 0.12], [-s * 0.16, -s * 0.12]], 3), smooth: false },
+ { p: WB.dense([[-s * 0.2, -s * 0.08], [-s * 0.62, -s * 0.08], [-s * 0.62, s * 0.08], [-s * 0.2, s * 0.08]], 3), w: 0.8, smooth: false }, { p: WB.dense([[s * 0.2, -s * 0.08], [s * 0.62, -s * 0.08], [s * 0.62, s * 0.08], [s * 0.2, s * 0.08]], 3), w: 0.8, smooth: false },
+ { p: [[-s * 0.41, -s * 0.08], [-s * 0.41, s * 0.08]], w: 0.5, smooth: false }, { p: [[s * 0.41, -s * 0.08], [s * 0.41, s * 0.08]], w: 0.5, smooth: false }];
+// 火柴人:脚底中心 (0,0),高 h;pose: stand / cheer / head(抱头)/ point / wave
+WB.figPose = (h, pose = 'stand') => { const k = h / 300, hy = -250 * k, r = 32 * k, nk = -218 * k, hip = -110 * k, sh = -190 * k;
+ const arms = { stand: [[-55, -120], [55, -120]], cheer: [[-70, -290], [70, -290]], head: [[-40, -262], [40, -262]], point: [[-50, -125], [95, -215]], wave: [[-55, -120], [80, -280]], shrug: [[-80, -215], [80, -215]] }[pose] || [[-55, -120], [55, -120]];
+ const elb = { stand: [[-40, -160], [40, -160]], cheer: [[-58, -240], [58, -240]], head: [[-62, -215], [62, -215]], point: [[-40, -160], [50, -200]], wave: [[-40, -160], [62, -225]], shrug: [[-50, -175], [50, -175]] }[pose] || [[-40, -160], [40, -160]];
+ return { head: [0, hy, r], lines: [[[0, nk], [0, hip]], [[-60 * k, 0], [0, hip], [60 * k, 0]], [[elb[0][0] * k, elb[0][1] * k], [0, sh], [elb[1][0] * k, elb[1][1] * k]],
+ [[arms[0][0] * k, arms[0][1] * k], [elb[0][0] * k, elb[0][1] * k]], [[elb[1][0] * k, elb[1][1] * k], [arms[1][0] * k, arms[1][1] * k]]] };
+};
+D.fig = (h, pose = 'stand', o = {}) => { const P = WB.figPose(h, pose), out = [{ p: WB.circ(P.head[0], P.head[1], P.head[2], 1.06) }];
+ if (o.helmet) out.push({ fillPts: A(P.head[0] + P.head[2] * 0.15, P.head[1], P.head[2] * 0.62, P.head[2] * 0.5, 0, Math.PI * 2, 16), fillCol: INK });
+ P.lines.forEach(l => out.push({ p: l, amp: 0.9 })); return out; };
+// 画一个会换姿势的火柴人(pose-to-pose,0.18s 回弹),keys = [[t, pose], ...]
+WB.drawFig = (g, x, y, h, keys, t, o = {}) => {
+ let i = 0; while (i < keys.length - 1 && t >= keys[i + 1][0]) i++;
+ const cur = WB.figPose(h, keys[i][1]), prv = i > 0 ? WB.figPose(h, keys[i - 1][1]) : cur, u = i > 0 ? MO.backOut(clamp((t - keys[i][0]) / 0.2), 1.6) : 1;
+ const mix = (a, b) => a.map((p, j) => [lerp(b[j][0], p[0], u), lerp(b[j][1], p[1], u)]);
+ const bob = Math.sin(t * 5 + x * 0.01) * h * 0.006;
+ g.save(); g.translate(x, y + bob); g.strokeStyle = INK; g.lineWidth = o.w || LW; g.lineCap = g.lineJoin = 'round';
+ g.beginPath(); g.arc(cur.head[0], cur.head[1], cur.head[2], 0, Math.PI * 2); g.stroke();
+ if (o.helmet) { g.fillStyle = INK; g.beginPath(); g.ellipse(cur.head[0] + cur.head[2] * 0.15, cur.head[1], cur.head[2] * 0.62, cur.head[2] * 0.5, 0, 0, 7); g.fill(); }
+ cur.lines.forEach((l, j) => { const m = mix(l, prv.lines[j]); g.beginPath(); m.forEach((p, k) => k ? g.lineTo(p[0], p[1]) : g.moveTo(p[0], p[1])); g.stroke(); });
+ g.restore();
+};
+// 会换姿势的火柴人:先用笔画出 keys[0] 的姿势,画完交给 WB.drawFig 按 keys(全片秒)换姿势
+WB.figure = (x, y, h, keys, o = {}) => {
+ const st = WB.sk(D.fig(h, keys[0][1], { helmet: o.helmet }), x, y, { speed: o.speed || 3200, w: o.w });
+ const tA = WB.cur; st.forEach(s => (s.until = tA));
+ WB.custom({ t0: tA, t1: tA + 0.01, bb: [x - h * 0.5, y - h * 1.05, x + h * 0.5, y + h * 0.05], draw(g, qq, t) { WB.drawFig(g, x, y, h, keys, t, { helmet: o.helmet, w: o.w || WB.LW }); return null; } });
+ return st;
+};
+// 爆炸:参差的星形(局部中心 (0,0),半径 r)+ 内圈
+D.burst = (r, seed = 3) => { const rr = U.rng(seed), o = [], n = 11; for (let i = 0; i <= n * 2; i++) { const a = i / (n * 2) * Math.PI * 2 - Math.PI / 2, R = (i % 2 ? 0.45 : 0.85 + rr() * 0.3) * r; o.push([Math.cos(a) * R, Math.sin(a) * R]); }
+ const i2 = []; for (let i = 0; i <= 14; i++) { const a = i / 14 * Math.PI * 2, R = (i % 2 ? 0.2 : 0.42) * r; i2.push([Math.cos(a) * R, Math.sin(a) * R]); }
+ return [{ p: o, smooth: false, w: 0.9 }, { p: i2, smooth: false, o: 1, w: 0.8 }]; };
+D.cross = (s) => [{ p: [[-s / 2, -s / 2], [s / 2, s / 2]], o: 1, w: 1.4, smooth: false }, { p: [[s / 2, -s / 2], [-s / 2, s / 2]], o: 1, w: 1.4, smooth: false }];
+D.check = (s) => [{ p: [[-s * 0.45, 0], [-s * 0.12, s * 0.32], [s * 0.5, -s * 0.42]], o: 1, w: 1.6, smooth: false }];
+D.bag = (s) => [{ p: [[-s * 0.16, -s * 0.42], [-s * 0.42, -s * 0.06], [-s * 0.44, s * 0.3], [-s * 0.3, s * 0.44], [s * 0.3, s * 0.44], [s * 0.44, s * 0.3], [s * 0.42, -s * 0.06], [s * 0.16, -s * 0.42]] },
+ { p: [[-s * 0.2, -s * 0.42], [-s * 0.28, -s * 0.56], [0, -s * 0.48], [s * 0.28, -s * 0.56], [s * 0.2, -s * 0.42], [-s * 0.2, -s * 0.42]], w: 0.85 }];
+D.doc = (s) => { const w = s * 0.72, h = s; return [{ p: [[w * 0.2, -h / 2], [-w / 2, -h / 2], [-w / 2, h / 2], [w / 2, h / 2], [w / 2, -h * 0.3], [w * 0.2, -h / 2], [w * 0.2, -h * 0.3], [w / 2, -h * 0.3]] },
+ { p: [[-w * 0.34, -h * 0.08], [w * 0.34, -h * 0.08]], w: 0.6 }, { p: [[-w * 0.34, h * 0.06], [w * 0.34, h * 0.06]], w: 0.6 }, { p: [[-w * 0.34, h * 0.2], [w * 0.1, h * 0.2]], w: 0.6 },
+ { p: [[-w * 0.3, h * 0.38], [-w * 0.18, h * 0.3], [-w * 0.1, h * 0.4], [0, h * 0.28], [w * 0.06, h * 0.38], [w * 0.3, h * 0.33]], o: 1, w: 0.8 }]; };
+D.box = (s) => [{ p: WB.dense([[-s / 2, -s * 0.3], [s * 0.3, -s * 0.3], [s * 0.3, s * 0.5], [-s / 2, s * 0.5], [-s / 2, -s * 0.3]], 4), smooth: false },
+ { p: [[-s / 2, -s * 0.3], [-s * 0.3, -s * 0.5], [s * 0.5, -s * 0.5], [s * 0.3, -s * 0.3]], smooth: false }, { p: [[s * 0.5, -s * 0.5], [s * 0.5, s * 0.3], [s * 0.3, s * 0.5]], smooth: false },
+ { p: [[-s * 0.1, -s * 0.3], [-s * 0.1, s * 0.5]], w: 0.5, o: 1, smooth: false }];
+D.clock = (r) => [{ p: WB.circ(0, 0, r, 1.05) }, { p: [[0, -r * 0.62], [0, 0], [r * 0.45, r * 0.2]], w: 0.9, smooth: false }];
+D.trophy = (s) => [{ p: [[-s * 0.32, -s * 0.5], [-s * 0.3, -s * 0.15], [-s * 0.12, s * 0.05], [-s * 0.06, s * 0.2], [-s * 0.2, s * 0.32], [s * 0.2, s * 0.32], [s * 0.06, s * 0.2], [s * 0.12, s * 0.05], [s * 0.3, -s * 0.15], [s * 0.32, -s * 0.5], [-s * 0.32, -s * 0.5]] },
+ { p: A(-s * 0.32, -s * 0.3, s * 0.14, s * 0.16, -Math.PI / 2, -Math.PI * 1.5, 10), w: 0.8 }, { p: A(s * 0.32, -s * 0.3, s * 0.14, s * 0.16, -Math.PI / 2, Math.PI / 2, 10), w: 0.8 },
+ { p: WB.dense([[-s * 0.3, s * 0.32], [s * 0.3, s * 0.32], [s * 0.3, s * 0.46], [-s * 0.3, s * 0.46], [-s * 0.3, s * 0.32]], 3), w: 0.9, smooth: false }];
+D.car = (s) => [{ p: [[-s * 0.5, 0], [-s * 0.5, -s * 0.16], [-s * 0.2, -s * 0.2], [-s * 0.06, -s * 0.34], [s * 0.18, -s * 0.34], [s * 0.3, -s * 0.2], [s * 0.5, -s * 0.16], [s * 0.52, 0], [-s * 0.5, 0]] },
+ { p: WB.circ(-s * 0.3, 0, s * 0.11, 1.05), w: 0.9 }, { p: WB.circ(s * 0.3, 0, s * 0.11, 1.05), w: 0.9 }];
+D.drop = (s) => [{ p: [[0, -s * 0.5], ...A(0, s * 0.12, s * 0.28, s * 0.28, Math.PI * 1.1, -Math.PI * 0.1, 18), [0, -s * 0.5]], o: 1 }];
+D.bell = (s) => [{ p: [[-s * 0.42, s * 0.3], [-s * 0.34, s * 0.2], [-s * 0.3, -s * 0.12], ...A(0, -s * 0.12, s * 0.3, s * 0.3, Math.PI, Math.PI * 2, 16).slice(1), [s * 0.34, s * 0.2], [s * 0.42, s * 0.3], [-s * 0.42, s * 0.3]] },
+ { p: WB.circ(0, s * 0.38, s * 0.07, 1.05), w: 0.9 }, { p: [[0, -s * 0.42], [0, -s * 0.52]], w: 1.2, smooth: false }, { p: WB.circ(0, -s * 0.56, s * 0.05, 1.05), w: 0.8 },
+ { p: [[-s * 0.55, -s * 0.2], [-s * 0.68, -s * 0.28]], o: 1, smooth: false }, { p: [[-s * 0.56, s * 0.02], [-s * 0.72, s * 0.02]], o: 1, smooth: false }, { p: [[s * 0.55, -s * 0.2], [s * 0.68, -s * 0.28]], o: 1, smooth: false }, { p: [[s * 0.56, s * 0.02], [s * 0.72, s * 0.02]], o: 1, smooth: false }];
+// 一个简笔大脑(AI 的符号):中心 (0,0),宽 s
+D.brain = (s) => [{ p: [[0, s * 0.3], ...A(-s * 0.22, 0, s * 0.27, s * 0.3, Math.PI / 2, Math.PI * 1.5, 14), ...A(0, -s * 0.28, s * 0.22, s * 0.12, Math.PI, Math.PI * 2, 10), ...A(s * 0.22, 0, s * 0.27, s * 0.3, -Math.PI / 2, Math.PI / 2, 14), [0, s * 0.3]] },
+ { p: [[0, -s * 0.3], [0, s * 0.3]], w: 0.7 }, { p: [[-s * 0.36, -s * 0.05], [-s * 0.22, -s * 0.12], [-s * 0.1, 0]], w: 0.6 }, { p: [[s * 0.36, s * 0.06], [s * 0.22, -s * 0.06], [s * 0.1, s * 0.08]], w: 0.6 }];
+// 补丁:中心 (0,0),边长 s,带十字缝线
+D.patch = (s, r = 0.2) => { const c = Math.cos(r), n = Math.sin(r), R = ([x, y]) => [x * c - y * n, x * n + y * c];
+ return [{ p: WB.dense([[-s / 2, -s / 2.4], [s / 2, -s / 2.4], [s / 2, s / 2.4], [-s / 2, s / 2.4], [-s / 2, -s / 2.4]], 3).map(R), w: 0.75, smooth: false },
+ ...[-0.25, 0, 0.25].map(f => ({ p: [[f * s - 5, -s / 2.4 - 6], [f * s + 5, -s / 2.4 + 6]].map(R), w: 0.5, smooth: false }))]; };
+D.chopsticks = (L) => [{ p: [[-L * 0.5, -L * 0.1], [L * 0.5, L * 0.02]], w: 1.4, smooth: false }, { p: [[-L * 0.5, L * 0.1], [L * 0.5, L * 0.06]], w: 1.4, smooth: false }];
+})();
diff --git a/scripts/engine/reference_films/spacex/spacex_wb/scenes/s01.js b/scripts/engine/reference_films/spacex/spacex_wb/scenes/s01.js
new file mode 100644
index 0000000..643bcf0
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_wb/scenes/s01.js
@@ -0,0 +1,86 @@
+// S01 · 开场钩子(A 行左半,x 0–4000)。第 0 帧板上已经有「2008年」和三枚猎鹰1号,第一枚已被橙色打叉(冲突先到);
+// 笔接着叉掉第二、第三枚 →「连败三次」→ 钱袋 → 箭头 → 第四枚「最后一发」→ 9.28 → 它升空入轨「成了」;
+// 橙色长箭头「18年后」领着相机右移 → 9.28「同一天」→ 2026年、地球、星舰绕轨道;最后拉远,笔在底下画一条 2002—2026 的时间线,「24年」弹出。
+WB.chapter('s01', id => {
+ const q = k => WB.q(id, k), { OR, INK } = WB, D = WB.D;
+ const BASE = 860, RH = 420;
+ // ---- 第 0 帧之前就画好的(开场即冲突)----
+ WB.at(-6);
+ WB.text('2008', 120, 330, 180, { dur: 0.6 });
+ const RX = [215, 395, 575];
+ RX.forEach(x => WB.sk(D.falcon1(RH), x, BASE));
+ WB.sk(D.cross(150), RX[0], BASE - RH * 0.5);
+ ['2006', '2007', '2008.8'].forEach((y, i) => WB.text(y, RX[i], BASE + 92, 46, { align: 'center', dur: 0.2 }));
+ WB.at(0.5); WB.text('年', 120 + WB.measure('2008', 180), 330, 180, { dur: 0.36 });
+ // ---- 叉掉第二、第三枚 ----
+ WB.at(0.2); WB.sk(D.cross(150), RX[1], BASE - RH * 0.5, { speed: 1500 }); // 第 0 帧干净:手 0.2s 后才从右下进来叉第二枚
+ WB.go(q('连败') - 0.05); WB.sk(D.cross(150), RX[2], BASE - RH * 0.5, { speed: 2600 });
+ WB.go(q('三次') - 0.05); WB.text('连败三次', 700, 700, 108, { col: OR, rate: 9 });
+ WB.figure(905, 880, 150, [[0, 'stand'], [WB.cur + 0.3, 'head']], { speed: 5200, w: 6 }); // 一个抱头的小人
+ // ---- 钱只够再打最后一发 ----
+ WB.go(q('钱') + 0.15);
+ WB.sk(D.bag(220), 1280, 650, { speed: 3400 }); WB.hatchCircle(1280, 690, 72, { gap: 19, speed: 26000 }); // 钱袋:橙色斜线排线(不用第三种颜色)
+ WB.text('$', 1280 - 26, 735, 110, { dur: 0.14 });
+ WB.go(q('最后') + 0.05); WB.text('最后一发', 1250, 430, 92, { col: OR, rate: 12, align: 'center' });
+ WB.arrow([1405, 650], [1545, 650], { head: 26 });
+ WB.sk(D.falcon1(RH), 1660, BASE, { speed: 4200 });
+ // ---- 9月28号,那一发成了 ----
+ WB.go(q('9月') + 0.25); WB.text('9.28', 1790, 760, 140, { rate: 10 });
+ const EX = 2060, EY = 250, ER = 70;
+ WB.go(WB.cur + 0.02); WB.sk(D.earth(ER), EX, EY, { speed: 3400 });
+ const orb = WB.ell(EX, EY, 135, 46, Math.PI, 1.0, -0.12, 48);
+ WB.line(orb, { col: OR, w: 4.5, speed: 5000, smooth: false });
+ // 第四发:火箭留在原地,笔从箭头画一条橙色弧线进到小地球的轨道;轨道上出现一枚小火箭,一直绕着转
+ const tL = Math.max(WB.cur + 0.02, q('那一发') + 0.02), tA = tL + 0.5;
+ const P = WB.prep(D.falcon1(RH)), FL = WB.prep([{ p: [[-14, 2], [0, 70], [14, 2]], o: 1, w: 0.9 }]);
+ WB.line(WB.quad([1660, BASE - RH * 1.2], [1700, 330], [EX - 132, EY + 22], 30), { col: OR, w: 5, t0: tL, dur: tA - tL, smooth: false, handed: false });
+ WB.custom({ t0: tA, t1: tA + 0.2, bb: [EX - 200, EY - 120, EX + 200, EY + 120], draw(g, qq, t) {
+ const w = (t - tA) * 2.2 + Math.PI * 0.92, x = EX + Math.cos(w) * 135 * 0.993 - Math.sin(w) * 46 * -0.12, y = EY + Math.cos(w) * 135 * -0.12 + Math.sin(w) * 46, a = w + Math.PI, s = 0.3 * MO.backOut(qq, 2);
+ WB.drawPrep(g, FL, x, y, s, a, 0.7 + 0.3 * Math.sin(t * 40)); WB.drawPrep(g, P, x, y, s, a); return null; } });
+ WB.at(q('成了') - 0.1); WB.sk(D.check(110), 1930, 470, { speed: 2600 });
+ WB.pop('成了', 2090, 520, 110, { at: q('成了') + 0.2, rot: -0.08 });
+ // ---- 整整18年后的同一天 ----
+ WB.go(q('整整') + 0.05);
+ WB.arrow([2130, 712], [2660, 668], { col: OR, bend: -40, w: 7, head: 34, speed: 2600 });
+ WB.text('18年后', 2390, 620, 84, { align: 'center', rate: 14 });
+ WB.go(q('同一天') - 0.25); WB.text('9.28', 2800, 700, 140, { rate: 12 });
+ WB.line([[2790, 730], [2960, 736], [3110, 728]], { col: OR, w: 7, speed: 4000 }); WB.line([[2800, 748], [2960, 754], [3100, 746]], { col: OR, w: 6, speed: 4500 });
+ WB.pop('同一天', 2955, 850, 84, { at: q('同一天') + 0.55 });
+ // ---- 星舰第一次进入了地球轨道 ----
+ WB.go(q('星舰') - 0.15); WB.text('2026年', 2780, 320, 180, { rate: 11 });
+ const SX = 3700, SY = 590, SR = 165;
+ WB.go(q('进入') - 0.3); WB.sk(D.earth(SR), SX, SY, { speed: 3600 });
+ const RX2 = 300, RY2 = 98, ROT = -0.18;
+ WB.line(WB.ell(SX, SY, RX2, RY2, Math.PI * 0.9, 1.03, ROT, 64), { col: OR, w: 5, speed: 6000 });
+ const SP = WB.prep(D.starship(270, 'full'), 6.5);
+ const tS = WB.cur;
+ WB.custom({ t0: tS, t1: tS + 0.35, bb: [SX - 420, SY - 300, SX + 420, SY + 300], draw(g, qq, t) {
+ const w = (t - tS) * 0.9 + Math.PI * 1.05, x0 = Math.cos(w) * RX2, y0 = Math.sin(w) * RY2, c = Math.cos(ROT), s = Math.sin(ROT);
+ const x = SX + x0 * c - y0 * s, y = SY + x0 * s + y0 * c, a = Math.atan2(Math.cos(w) * RY2, -Math.sin(w) * RX2) + ROT + Math.PI / 2;
+ const front = Math.sin(w) > -0.15; // 转到地球背后时被地球挡住
+ if (!front) { g.beginPath(); g.rect(-1e5, -1e5, 2e5, 2e5); g.arc(SX, SY, SR + 4, 0, Math.PI * 2, true); g.clip(); }
+ WB.drawPrep(g, SP, x, y, 1, a, MO.smooth(qq));
+ return null; } });
+ WB.at(q('地球') + 0.1); WB.text('星舰入轨', SX, 340, 84, { align: 'center', col: OR, rate: 12 });
+ // ---- 两分钟,看完它这24年:拉远,时间线 ----
+ WB.go(q('两分钟') + 0.25);
+ // 一条横跨整块的时间线:两端写 2002、2026,上面一道橙色大括号罩住整段,「24年」写在括号尖上(不标中间刻度,不让火箭站在某个年份上)
+ const TY = 1062, X0 = 130, X1 = 3860, XM = (X0 + X1) / 2;
+ WB.text('2002', X0 - 30, TY + 30, 92, { align: 'right', rate: 26 });
+ WB.line([[X0, TY], [X1, TY]], { speed: 7600, w: 7 });
+ [X0, X1].forEach(x => WB.line([[x, TY - 26], [x, TY + 26]], { smooth: false, speed: 3000, min: 0.03 }));
+ WB.text('2026', X1 + 30, TY + 30, 92, { rate: 26 });
+ const br = []; for (let i = 0; i <= 60; i++) { const u = i / 60, k = Math.abs(u - 0.5) * 2; br.push([X0 + 10 + (X1 - X0 - 20) * u, TY - 30 - 22 * (1 - Math.pow(k, 8)) - (k < 0.04 ? 26 * (1 - k / 0.04) : 0)]); }
+ WB.line(br, { col: OR, w: 7, dur: 0.28 });
+ WB.pop('24年', XM, TY - 92, 140, { at: Math.max(WB.cur + 0.3, q('24年') + 0.2) });
+ // ---- 相机 ----
+ const T = WB.T0(id) + TIMING.seg[id].dur;
+ WB.cam0(...WB.fit(-7, q('钱'), { zmax: 1.15 }));
+ WB.shot(q('钱') - 0.15, 0.9, q('钱'), q('9月'));
+ WB.move(q('9月') - 0.05, q('9月') + 0.4, 1950, 720, 1.75, { ease: MO.cubicInOut }); // 特写:笔尖写「9.28」
+ WB.shot(q('那一发') - 0.3, 0.6, q('钱'), q('整整'), { ease: MO.cubicInOut });
+ WB.shot(q('整整') - 0.05, 1.15, q('整整'), q('两分钟'));
+ WB.shot(q('两分钟') + 0.05, 0.95, -7, T, { zmax: 0.6, pad: 60, sy: 430, declip: false });
+});
+const clamp01 = x => Math.max(0, Math.min(1, x));
+SCENES['s01'] = WB.scene;
diff --git a/scripts/engine/reference_films/spacex/spacex_wb/scenes/s02.js b/scripts/engine/reference_films/spacex/spacex_wb/scenes/s02.js
new file mode 100644
index 0000000..795e20d
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_wb/scenes/s02.js
@@ -0,0 +1,57 @@
+// S02 · 创立与目标(A 行右半,x 4300–6800)。起点是混合版 S02:「2002年」→ 火柴人「马斯克」→ 箭头 →「SpaceX」;
+// 相机平滑右移:「目标」→ 地球 → 小火箭拖着橙色虚线飞向一颗橙色排线的星球 → 星球上插一座小房子(全片最后火星上会再出现这座房子)。
+WB.chapter('s02', id => {
+ const q = k => WB.q(id, k), { OR, INK, SPEED } = WB, D = WB.D, X = 4360, lerp = U.lerp;
+ // ---- 从 S01 时间线的「2002」画一条橙色长路,笔领着相机甩到 A 行右边的「2002年」 ----
+ const tR0 = Math.max(WB.cur, WB.q('s01', '24年') + 0.6);
+ WB.at(tR0); WB.line(WB.ell(40, 1067, 140, 62, 0.4, 1.0, 0, 40), { col: OR, w: 6, speed: 4200 });
+ const road = [...WB.dense([[-100, 1072], [-130, 1010], [-130, 900], [-130, 60]], 10), ...WB.quad([-130, 60], [-130, -80], [40, -80], 10).slice(1), ...WB.dense([[40, -80], [4440, -80]], 30).slice(1), ...WB.quad([4440, -80], [4560, -78], [4570, 60], 10).slice(1), [4572, 250]];
+ const rd = WB.line(road, { col: OR, w: 8, dur: 0.95, dash: [1, 15], amp: 1.0 });
+ WB.line([[4542, 216], [4572, 256], [4602, 216]], { col: OR, w: 7, smooth: false, speed: 2600 });
+ const tRe = rd.t1;
+ // 相机跟着笔:从全景缩进来,沿路一路追(带运动模糊),最后落在「2002年」那一块
+ const rp = u => DG.pointAt(rd.pts, rd.cum, rd.len * MO.sineInOut(u));
+ WB.move(rd.t0 - 0.05, rd.t0 + 0.25, ...(([x, y]) => [x + 700, y + 250])(rp(0.2)), 0.55, { ease: MO.cubicIn });
+ WB.move(rd.t0 + 0.25, rd.t0 + 0.62, ...(([x, y]) => [x, y + 300])(rp(0.7)), 0.55, { whip: true, ease: MO.linear });
+ WB.texts.push('');
+ // ---- 第一块 ----
+ WB.go(q('2002年') + 0.14); WB.text('2002年', 260 + X, 380, 150, { rate: 11 });
+ WB.go(q('马斯克') - 0.3);
+ WB.figure(430 + X, 790, 330, [[0, 'stand'], [q('马斯克') + 0.5, 'wave'], [q('SpaceX') + 0.1, 'point']], { speed: 3000 });
+ WB.text('马斯克', 430 + X, 875, 66, { align: 'center', rate: 16 });
+ WB.go(q('SpaceX') - 0.25);
+ WB.arrow([548 + X, 620], [722 + X, 616], { head: 30 });
+ WB.text('SpaceX', 768 + X, 650, 128, { rate: 18 });
+ WB.line([[772 + X, 690], [960 + X, 700], [1150 + X, 688]], { col: OR, w: 9, speed: SPEED * 1.6 });
+ // ---- 第二块 ----
+ WB.go(q('目标') + 0.3); WB.text('目标', 1440 + X, 330, 118, { col: OR, rate: 11 });
+ const EX = 1560 + X, EY = 640;
+ WB.sk(D.earth(140), EX, EY, { speed: 3600 });
+ const P0 = [EX + 95, 545], P1 = [2000 + X, 250], P2 = [2300 + X, 470];
+ const bez = u => [lerp(lerp(P0[0], P1[0], u), lerp(P1[0], P2[0], u), u), lerp(lerp(P0[1], P1[1], u), lerp(P1[1], P2[1], u), u)];
+ const pts = []; for (let i = 0; i <= 60; i++) pts.push(bez(i / 60));
+ const cum = DG.cum(pts), L = cum[cum.length - 1];
+ const R = WB.prep([{ p: [[0, -38], [10, -28], [14, 4], [14, 22], [-14, 22], [-14, 4], [-10, -28], [0, -38]] }, { p: [[-14, 8], [-26, 26], [-14, 22]] }, { p: [[14, 8], [26, 26], [14, 22]] }], 5);
+ const fly0 = Math.max(WB.cur + 0.05, q('有一天') + 0.2), fly1 = fly0 + 1.05;
+ WB.custom({ t0: fly0, t1: fly1, handed: false, bb: [P0[0] - 60, 180, P2[0] + 60, 620], draw(g, qq, t) {
+ const e = MO.sineInOut(qq), d = L * e;
+ g.strokeStyle = OR; g.lineWidth = 6; DG.drawPartial(g, pts, cum, Math.max(0, d - 40)); g.setLineDash([]);
+ const [x, y] = DG.pointAt(pts, cum, d), [x2, y2] = DG.pointAt(pts, cum, Math.min(L, d + 2)), a = Math.atan2(y2 - y, x2 - x) || 0.3;
+ if (qq >= 1) { g.lineWidth = 6; g.beginPath(); g.moveTo(x - Math.cos(a - 0.5) * 30, y - Math.sin(a - 0.5) * 30); g.lineTo(x, y); g.lineTo(x - Math.cos(a + 0.5) * 30, y - Math.sin(a + 0.5) * 30); g.stroke(); }
+ else { WB.drawPrep(g, R, x, y, 1, a + Math.PI / 2); g.fillStyle = OR; g.translate(x, y); g.rotate(a + Math.PI / 2); g.beginPath(); g.moveTo(-8, 26); g.lineTo(0, 46 + 6 * Math.sin(t * 40)); g.lineTo(8, 26); g.closePath(); g.fill(); }
+ return null; } });
+ WB.at(Math.max(fly0 + 0.55, q('别的星球') + 0.05));
+ const MX = 2420 + X, MY = 500, MR = 112;
+ WB.line(WB.circ(MX, MY, MR, 1.04, Math.PI), { w: 7, speed: SPEED * 1.3 });
+ WB.hatchCircle(MX, MY, MR, { gap: 21, ang: -Math.PI / 4 });
+ WB.go(q('住到') + 0.62);
+ WB.sk(D.house(84), MX, 394, { speed: 3000 });
+ WB.text('别的星球', MX, 690, 66, { align: 'center', rate: 20 });
+ // ---- 相机:S01 拉远 → 扎进第一块 → 平移到第二块 → 稍拉远 ----
+ const t0 = WB.T0(id), mv0 = Math.max(q('目标') - 0.15, t0 + 2.4), out0 = t0 + TIMING.seg[id].dur - 1.05;
+ const T = t0 + TIMING.seg[id].dur;
+ WB.shot(tRe - 0.3, 0.6, tRe + 0.1, q('目标'), { zmax: 1.12, ease: MO.cubicOut, add: [[4530, 200, 4620, 300]] });
+ WB.shot(mv0, 0.8, q('目标'), T, { zmax: 1.1 });
+ WB.shot(out0, 0.6, t0, T, { zmax: 0.85 });
+});
+SCENES['s02'] = WB.scene;
diff --git a/scripts/engine/reference_films/spacex/spacex_wb/scenes/s03.js b/scripts/engine/reference_films/spacex/spacex_wb/scenes/s03.js
new file mode 100644
index 0000000..4a1b35e
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_wb/scenes/s03.js
@@ -0,0 +1,78 @@
+// S03 · 猎鹰1号四次发射(B 行左段,x 0–3700)。甩镜从 A 行末尾跳到 B 行开头。
+// 一枚大猎鹰1号+标题,旁边站着一个看发射的火柴人;地面上一排四个发射台:每念一个年份,台上画一枚小火箭、写年份,
+// 它升空、在越来越高的地方炸成一团(2006 低、2007 高一点、2008.8 更高),火柴人抱头;第四次它一路飞进绕地球的轨道,「成了」,火柴人举手。
+// 高光后留一拍:笔退场,相机慢慢推近,只有轨道上的火箭在转;然后一字一字写下「第一枚私人研制、进入轨道的液体燃料火箭」。
+WB.chapter('s03', id => {
+ const q = k => WB.q(id, k), { OR, INK, SPEED } = WB, D = WB.D, Y = v => WB.ROW.B + v;
+ const t0 = WB.T0(id);
+ // ---- 换行:笔从 A 行末尾「别的星球」拉一条橙色点线,沿 A、B 两行之间一路向左,拐下来指向 B 行开头;相机跟着笔走 ----
+ const road = WB.dense([[6900, 720], [6960, 1120], [6860, 1180], [140, 1180], [40, 1260], [30, 1600], [80, 1680], [130, 1680]], 16);
+ const rd = WB.line(road, { col: OR, w: 8, dur: 0.9, dash: [1, 15], amp: 1.0, t0: Math.max(WB.cur + 0.02, t0 - 0.35), nofit: true });
+ WB.line([[100, 1652], [134, 1680], [100, 1708]], { col: OR, w: 8, smooth: false, t0: rd.t1 + 0.01, dur: 0.08, nofit: true });
+ WB.fade([rd, WB.S[WB.S.indexOf(rd) + 1]], rd.t1 + 1.2, 0.5); // 换行用的路走完就淡掉,不压在下一行的画面顶上
+ const rp = u => DG.pointAt(rd.pts, rd.cum, rd.len * MO.sineInOut(u));
+ // ---- 第一款火箭,叫猎鹰1号 ----
+ const FX = 800, FG = Y(860);
+ WB.go(Math.max(q('它的') + 0.05, rd.t1 + 0.1)); WB.sk(D.falcon1(600), 230, Y(860), { speed: 4400 }); // 先画火箭、标题跟着口播写,看火箭的小人最后补
+ WB.go(q('猎鹰') - 0.2); WB.text('猎鹰1号', 360, Y(330), 140, { rate: 11 });
+ WB.go(WB.cur + 0.02); WB.sk(D.fig(250, 'stand'), FX, FG, { speed: 4200 });
+ const figStrokes = WB.S.slice(-6);
+ // ---- 四个发射台 ----
+ const G = Y(780), PX = [1140, 1520, 1900, 2280], RH = 250, LB = ['2006', '2007', '2008.8', '第四次'];
+ const P = WB.prep(D.falcon1(RH), 5.5), FL = WB.prep([{ p: [[-12, 2], [0, 64], [12, 2]], o: 1, w: 0.9 }], 5.5);
+ WB.go(q('2006年') - 0.05);
+ WB.line([[980, G], [2480, G]], { speed: 9000, w: 6, nofit: true });
+ // 每次失败:台上的火箭留着(白板上东西不凭空消失),笔从箭头往上画一条歪歪扭扭的橙色飞行线,线的尽头炸成一团
+ const fail = (i, yrKey, failKey, burstY) => {
+ const x = PX[i], top = G - RH * 1.2;
+ WB.go(q(yrKey) + 0.05);
+ WB.sk(D.falcon1(RH), x, G, { speed: 3800, w: 5.5 });
+ WB.text(LB[i], x, G + 78, 62, { align: 'center', rate: 16 });
+ const tB = q(failKey) + 0.05, tL = Math.max(WB.cur + 0.05, tB - 0.45);
+ const path = []; for (let k = 0; k <= 16; k++) { const u = k / 16; path.push([x + Math.sin(u * 7 + i) * 14 * u + u * u * 26 * (i % 2 ? -1 : 1), top - (top - burstY - 60) * u]); }
+ WB.line(path, { col: OR, w: 5, t0: tL, dur: tB - tL - 0.02, smooth: false });
+ WB.at(tB); WB.sk(D.burst(95, 11 + i), x + (i % 2 ? -26 : 26), burstY, { speed: 5200 });
+ [[-1, 0.3], [1, 0.5], [-0.5, 1], [0.7, 1.1]].forEach(([dx, dy]) => WB.line([[x + dx * 110, burstY + dy * 70], [x + dx * 135, burstY + dy * 70 + 30]], { speed: 3000, min: 0.02, gap: 0.004, w: 5, smooth: false }));
+ return tB;
+ };
+ const b1 = fail(0, '2006年', '失败', Y(400));
+ const b2 = fail(1, '2007年', '失败;2008', Y(300));
+ const b3 = fail(2, '2008年8月', '还是失败', Y(200));
+ // ---- 第四次,成了 ----
+ const EX = 2680, EY = Y(250), ER = 115, ORX = 190, ORY = 62, ROT = -0.1;
+ WB.go(b3 + 0.42); WB.sk(D.earth(ER), EX, EY, { speed: 4400 });
+ WB.line(WB.ell(EX, EY, ORX, ORY, Math.PI, 1.02, ROT, 56), { col: OR, w: 4.5, speed: 7000, smooth: false });
+ const x4 = PX[3]; WB.sk(D.falcon1(RH), x4, G, { speed: 4600, w: 5.5 });
+ WB.go(q('第四次') + 0.08); WB.text(LB[3], x4, G + 78, 62, { align: 'center', rate: 12, col: OR });
+ // 第四次:火箭留在台上,笔从箭头画一条橙色弧线一路进到地球轨道;轨道上出现一枚小火箭,一直绕着转
+ const tL = Math.max(WB.cur + 0.02, q('成了') - 0.55), tA = tL + 0.6;
+ const a0 = [x4, G - RH * 1.2], c0 = [x4 + 40, Y(230)], b0 = [EX - ORX + 4, EY + 20];
+ const tr = WB.quad(a0, c0, b0, 30);
+ WB.line(tr, { col: OR, w: 5, t0: tL, dur: tA - tL, smooth: false, handed: false });
+ WB.custom({ t0: tA, t1: tA + 0.2, bb: [EX - ORX - 60, EY - ORY - 80, EX + ORX + 60, EY + ORY + 80], draw(g, qq, t) {
+ const w = (t - tA) * 1.9 + Math.PI, X0 = Math.cos(w) * ORX, Y0 = Math.sin(w) * ORY, c = Math.cos(ROT), n = Math.sin(ROT);
+ const x = EX + X0 * c - Y0 * n, y = EY + X0 * n + Y0 * c, a = Math.atan2(Math.cos(w) * ORY, -Math.sin(w) * ORX) + ROT + Math.PI / 2, s = 0.4 * MO.backOut(qq, 2);
+ if (Math.sin(w) < -0.2) { g.beginPath(); g.rect(-1e5, -1e5, 2e5, 2e5); g.arc(EX, EY, ER + 3, 0, Math.PI * 2, true); g.clip(); }
+ WB.drawPrep(g, FL, x, y, s, a, 0.7 + 0.3 * Math.sin(t * 40)); WB.drawPrep(g, P, x, y, s, a); return null; } });
+ WB.pop('成了', 2110, Y(560), 150, { at: q('成了') + 0.18, rot: -0.07 });
+ // 火柴人:画完后换成会动的那个(看 → 抱头 → 看 → 抱头 → 看 → 抱头 → 举手)
+ const tFig = q('2006年');
+ figStrokes.forEach(s => (s.until = tFig));
+ const keys = [[0, 'stand'], [b1 + 0.08, 'head'], [b1 + 0.75, 'stand'], [b2 + 0.08, 'head'], [b2 + 0.75, 'point'], [b3 + 0.08, 'head'], [q('第四次') + 0.1, 'stand'], [q('成了') + 0.05, 'cheer']];
+ WB.custom({ t0: tFig, t1: tFig + 0.01, bb: [FX - 150, FG - 330, FX + 150, FG + 20], draw(g, qq, t) { WB.drawFig(g, FX, FG, 250, keys, t); return null; } });
+ // ---- 第一枚私人研制、进入轨道的液体燃料火箭 ----
+ WB.go(q('第一枚') + 0.12);
+ WB.text('第一枚', 2900, Y(560), 72, { col: OR, rate: 8 });
+ WB.text('私人研制、', 2900 + WB.measure('第一枚', 72), Y(560), 72, { rate: 8 });
+ WB.go(q('进入') + 0.05); WB.text('进入轨道的液体燃料火箭', 2900, Y(665), 68, { rate: 8.5 });
+ WB.line([[2900 + WB.measure('进入轨道的', 68), Y(685)], [2900 + WB.measure('进入轨道的液体燃料', 68), Y(691)]], { col: OR, w: 7, speed: 3000 });
+ // ---- 相机 ----
+ const T = t0 + TIMING.seg[id].dur;
+ WB.move(rd.t0 - 0.05, rd.t0 + 0.25, ...(([x, y]) => [x - 500, y + 120])(rp(0.2)), 0.55, { ease: MO.cubicIn });
+ WB.move(rd.t0 + 0.25, rd.t0 + 0.62, ...(([x, y]) => [x + 500, y + 120])(rp(0.75)), 0.55, { whip: true, ease: MO.linear });
+ WB.shot(rd.t0 + 0.62, 0.5, rd.t1, q('2007年'), { ease: MO.cubicOut, add: [[980, G - 10, 1700, G + 100], [90, 1640, 300, 1720]] });
+ WB.shot(q('2008年8月') - 0.35, 0.95, q('2007年'), q('成了'), { add: [[EX - ORX, EY - ORY - 60, EX + ORX, EY + ER]] });
+ WB.move(q('成了') - 0.35, q('成了') + 0.1, 2400, Y(540), 1.15, { ease: MO.cubicInOut }); // 「成了」那一下推近
+ WB.shot(q('成了') + 0.55, 1.0, q('第四次'), T, { zmax: 1.1, add: [[EX - ORX, EY - ER, EX + ORX, EY + ER]] });
+});
+SCENES['s03'] = WB.scene;
diff --git a/scripts/engine/reference_films/spacex/spacex_wb/scenes/s04.js b/scripts/engine/reference_films/spacex/spacex_wb/scenes/s04.js
new file mode 100644
index 0000000..69f23e8
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_wb/scenes/s04.js
@@ -0,0 +1,50 @@
+// S04 · NASA 合同与龙飞船(B 行中段,x 3650–6000)。笔画一支橙色箭头「三个月后」领着相机右移;
+// 一份合同(顶上写 NASA)→「16亿美元」整词弹出、笔划线 → 一只货箱沿虚线飞向空间站(「送货」);
+// 相机再右移:「2012年」→ 龙飞船沿虚线飞来对接空间站 →「第一艘私人飞船」,「第一艘」橙圈圈住。
+WB.chapter('s04', id => {
+ const q = k => WB.q(id, k), { OR, INK } = WB, D = WB.D, Y = v => WB.ROW.B + v;
+ // ---- 三个月后 ----
+ WB.go(q('三个月后') - 0.3);
+ WB.arrow([3640, Y(760)], [4060, Y(700)], { col: OR, bend: -30, w: 7, head: 30, speed: 2600 });
+ WB.text('三个月后', 3850, Y(820), 64, { align: 'center', rate: 12 });
+ // ---- NASA 给了它一份合同 ----
+ const DX = 4300, DY = Y(450);
+ WB.go(q('NASA') + 0.1); WB.sk(D.doc(300), DX, DY, { speed: 3000 });
+ WB.go(q('合同') + 0.05); WB.text('NASA', DX, Y(275), 76, { align: 'center', rate: 14 }); WB.text('2008.12', DX, Y(668), 46, { align: 'center', rate: 24 });
+ // ---- 16亿美元 ----
+ WB.pop('16亿美元', 4780, Y(500), 140, { at: q('美元') + 0.05 });
+ WB.go(q('美元') + 0.2); WB.line([[4510, Y(530)], [4780, Y(540)], [5050, Y(526)]], { col: OR, w: 8, speed: 3600 });
+ // ---- 往空间站送货 ----
+ const IX = 5450, IY = Y(560), IS = 540;
+ WB.go(q('往空间站') - 0.1); WB.sk(D.iss(IS), IX, IY, { speed: 9000, min: 0.014, gap: 0.006 });
+ WB.go(q('送货') - 0.3); WB.sk(D.box(100), 4330, Y(760), { speed: 5200 });
+ const port = WB.issPort(IX, IY, IS);
+ const bx0 = [4400, Y(730)], bx1 = [port[0] - 10, port[1] + 30];
+ WB.line(WB.quad(bx0, [4900, Y(820)], bx1, 30), { col: INK, w: 3.5, speed: 6000, smooth: false });
+ WB.text('送货', 4870, Y(840), 60, { align: 'center', rate: 18 });
+ // ---- 2012年,龙飞船成了第一艘造访国际空间站的私人飞船 ----
+ WB.go(q('2012年') + 0.25); WB.text('2012年', 4720, Y(240), 120, { rate: 10 });
+ const CW = 100, CP = WB.prep(D.dragon(CW, { trunk: true }), 5.5);
+ const c0 = [4950, Y(830)], c1 = [5330, Y(870)], cEnd = [port[0], port[1] + CW * 1.2];
+ const cz = u => [(1 - u) ** 2 * c0[0] + 2 * u * (1 - u) * c1[0] + u * u * cEnd[0], (1 - u) ** 2 * c0[1] + 2 * u * (1 - u) * c1[1] + u * u * cEnd[1]];
+ const path = []; for (let i = 0; i <= 30; i++) path.push(cz(i / 30)); const pc = DG.cum(path);
+ const tF0 = q('龙飞船') - 0.05, tF1 = q('第一艘') + 0.15;
+ WB.custom({ t0: tF0, t1: tF1, bb: [4800, Y(380), 5500, Y(950)], draw(g, qq, t) {
+ const e = MO.sineInOut(qq), [x, y] = cz(e), [x2, y2] = cz(Math.min(1, e + 0.02));
+ g.strokeStyle = OR; g.lineWidth = 4; DG.drawPartial(g, path, pc, pc[pc.length - 1] * e); g.setLineDash([]);
+ const a = qq < 0.98 ? Math.atan2(y2 - y, x2 - x) + Math.PI / 2 : 0;
+ WB.drawPrep(g, CP, x, y, 1, U.lerp(a, 0, MO.smooth(U.clamp((qq - 0.55) / 0.45))));
+ if (qq >= 1) { const k = U.clamp((t - tF1) / 0.5); if (k < 1) { g.strokeStyle = OR; g.lineWidth = 4; g.globalAlpha = 1 - k; for (let i = 0; i < 5; i++) { const an = -0.3 + i * 0.6 + Math.PI * 0, r0 = 30 + 40 * k; g.beginPath(); g.moveTo(port[0] + Math.cos(an) * r0, port[1] + Math.sin(an) * r0); g.lineTo(port[0] + Math.cos(an) * (r0 + 26), port[1] + Math.sin(an) * (r0 + 26)); g.stroke(); } } }
+ return null; } });
+ WB.go(q('第一艘') + 0.08);
+ WB.text('第一艘', 5250, Y(300), 84, { col: OR, rate: 9 });
+ WB.line(WB.ell(5250 + WB.measure('第一艘', 84) / 2, Y(270), WB.measure('第一艘', 84) * 0.62, 66, -2.9, 1.07, 0, 44), { col: OR, w: 6, speed: 4200 });
+ WB.text('龙飞船', 5370, Y(790), 58, { align: 'right', rate: 14 });
+ WB.go(q('私人飞船') + 0.05); WB.text('私人飞船', 5250 + WB.measure('第一艘', 84) + 14, Y(300), 84, { rate: 10 });
+ // ---- 相机 ----
+ const t0 = WB.T0(id), T = t0 + TIMING.seg[id].dur;
+ WB.shot(q('三个月后') - 0.6, 0.8, t0, q('往空间站'));
+ WB.shot(q('往空间站') - 0.15, 0.75, q('NASA'), q('2012年'));
+ WB.shot(q('2012年') - 0.05, 0.85, q('往空间站'), T, { add: [[cEnd[0] - 60, cEnd[1] - 60, cEnd[0] + 60, cEnd[1] + 60]] });
+});
+SCENES['s04'] = WB.scene;
diff --git a/scripts/engine/reference_films/spacex/spacex_wb/scenes/s05.js b/scripts/engine/reference_films/spacex/spacex_wb/scenes/s05.js
new file mode 100644
index 0000000..649bfaf
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_wb/scenes/s05.js
@@ -0,0 +1,73 @@
+// S05 · 一级回收与复飞(B 行右段,x 6350–8750)。白板上的「飞行示意图」:
+// 猎鹰9号 → 橙色虚线一路上去、在分离点画一颗星 → 一条橙色回旋箭头绕回地面(「飞回来 · 重复用」);
+// 「2015.12」→ 一级从分离点沿回旋线掉头、点火、展开着陆腿,竖着落在圆形着陆点上,笔画放射线 →「头一回!」;
+// 相机右移「2017年」→ 同一枚一级沿一条橙色弧线被挪到第二个发射台,标上「同一枚」,再次点火升空。
+WB.chapter('s05', id => {
+ const q = k => WB.q(id, k), { OR, INK } = WB, D = WB.D, Y = v => WB.ROW.B + v;
+ const G = Y(800), RX = 6580, RH = 560;
+ WB.lead([6000, Y(320)], [6450, Y(300)], q('接着呢') - 0.12 - 0.62, 0.5); // 引线和相机同时走:笔领着相机,落位那一刻正好开写
+ WB.go(q('接着呢') - 0.12);
+ const f9 = WB.sk(D.falcon9(RH, {}), RX, G, { speed: 3400, w: 6 });
+ WB.line([[6370, G], [8730, G]], { speed: 9000, w: 6, nofit: true });
+ WB.text('猎鹰9号', RX - 60, Y(650), 50, { align: 'right', rate: 20 }); WB.text('2010年首飞', RX - 60, Y(715), 44, { align: 'right', rate: 24 });
+ // 上升轨迹+分离点
+ const SEP = [7130, Y(150)];
+ WB.go(q('一级') - 0.2);
+ WB.line(WB.quad([RX, G - RH - 20], [RX + 60, Y(120)], SEP, 26), { col: OR, w: 5, speed: 4200, smooth: false });
+ WB.sk([{ p: [[-26, 0], [26, 0]], smooth: false }, { p: [[0, -26], [0, 26]], smooth: false }, { p: [[-18, -18], [18, 18]], smooth: false }, { p: [[18, -18], [-18, 18]], smooth: false }], SEP[0], SEP[1], { col: OR, w: 4.5, speed: 3000 });
+ WB.arrow(SEP, [7500, Y(70)], { col: OR, bend: 10, head: 22, w: 5 }); // 二级继续往上
+ // 回旋线:分离点 → 掉头 → 落回着陆点
+ const LX = 7070, ret = [...WB.quad(SEP, [7370, Y(150)], [7250, Y(330)], 18), ...WB.quad([7250, Y(330)], [LX + 10, Y(480)], [LX, G - 24], 24).slice(1)];
+ WB.go(q('飞回来') - 0.1);
+ WB.line(ret, { col: OR, w: 6, speed: 3600, smooth: false });
+ const e = ret[ret.length - 1], p = ret[ret.length - 4], an = Math.atan2(e[1] - p[1], e[0] - p[0]);
+ WB.line([[e[0] - Math.cos(an - 0.5) * 28, e[1] - Math.sin(an - 0.5) * 28], e, [e[0] - Math.cos(an + 0.5) * 28, e[1] - Math.sin(an + 0.5) * 28]], { col: OR, w: 6, smooth: false, speed: 2600 });
+ WB.go(q('重复用') + 0.05); WB.text('飞回来,重复用', 7410, Y(330), 66, { col: OR, rate: 12 });
+ // ---- 2015年12月 ----
+ WB.go(q('2015年') + 0.28); WB.text('2015.12', 6130, Y(440), 100, { rate: 11 });
+ WB.line(WB.ell(LX, G + 4, 120, 26, Math.PI, 1.03, 0, 40), { w: 5, speed: 5200 });
+ // 一级沿回旋线回来:先小、远,掉头,最后竖直、展开着陆腿落地
+ const BH = 380, Bp0 = WB.prep(D.falcon9(BH, { stage: 'booster', legs: 0, fins: 1 }), 5.5), Bp1 = WB.prep(D.falcon9(BH, { stage: 'booster', legs: 1, fins: 1 }), 5.5);
+ const FL = WB.prep([{ p: [[-16, 2], [0, 80], [16, 2]], o: 1, w: 0.9 }], 5.5);
+ const rc = DG.cum(ret), RL = rc[rc.length - 1];
+ const tR0 = q('猎鹰9号') - 0.1, tR1 = q('落回') + 0.32;
+ let landed = null;
+ WB.custom({ t0: tR0, t1: tR1, bb: [6850, Y(40), 7550, G + 60], draw(g, qq, t) {
+ const u = MO.sineInOut(qq), d = RL * u, [x, y] = DG.pointAt(ret, rc, d), [x2, y2] = DG.pointAt(ret, rc, Math.min(RL, d + 4));
+ const s = U.lerp(0.32, 1, MO.smooth(U.clamp((qq - 0.25) / 0.65)));
+ const dir = Math.atan2(y2 - y, x2 - x) + Math.PI / 2, a = qq < 0.55 ? dir + Math.PI : U.lerp(dir + Math.PI, 0, MO.smooth(U.clamp((qq - 0.55) / 0.35)));
+ const leg = U.clamp((qq - 0.82) / 0.14), P = leg > 0.5 ? Bp1 : Bp0, by = y + 40 * (1 - s);
+ if (qq < 1) { if (qq > 0.5) WB.drawPrep(g, FL, x, by, s, a, (0.7 + 0.3 * Math.sin(t * 43)) * (1 - U.clamp((qq - 0.97) / 0.03)));
+ WB.drawPrep(g, P, x, by, s, a); }
+ if (qq >= 1) { const k = U.clamp((t - tR1) / 0.6); g.globalAlpha = 1 - k; g.strokeStyle = INK; g.lineWidth = 4; for (const sx of [-1, 1]) for (let i = 0; i < 3; i++) { g.beginPath(); g.arc(x + sx * (60 + i * 26 + k * 40), G - 10 - i * 6, 10 + i * 4, Math.PI, Math.PI * 2); g.stroke(); } }
+ return null; } });
+ // 落地后:放射线 +「头一回!」
+ WB.go(q('头一回') - 0.55);
+ [[-1, -0.2], [-0.8, -0.75], [0, -1], [0.8, -0.75], [1, -0.2]].forEach(([dx, dy]) => WB.line([[LX + dx * 150, G - BH * 0.55 + dy * 230], [LX + dx * 210, G - BH * 0.55 + dy * 300]], { col: OR, w: 6, speed: 3000, min: 0.03, gap: 0.01, smooth: false }));
+ WB.text('轨道火箭', 7490, Y(470), 60, { rate: 14, t0: q('轨道') + 0.05 });
+ WB.pop('头一回!', 7480, Y(590), 120, { at: q('头一回') + 0.3, align: 'left' });
+ // ---- 2017年,回收的一级又一次飞上了天 ----
+ const P2X = 8150;
+ WB.go(q('2017年') + 0.28); WB.text('2017年', 7850, Y(230), 110, { rate: 10 });
+ WB.go(q('回收的') - 0.05);
+ WB.arrow([LX + 110, Y(700)], [P2X - 110, Y(700)], { col: OR, bend: -40, head: 24, w: 5 });
+ WB.text('同一枚', (LX + P2X) / 2, Y(775), 58, { align: 'center', rate: 12, col: OR });
+ WB.line(WB.ell(P2X, G + 4, 110, 24, Math.PI, 1.03, 0, 40), { w: 5, speed: 5200 });
+ const b2 = WB.sk(D.falcon9(BH, { stage: 'booster', legs: 1, fins: 1 }), P2X, G - 24, { speed: 5200, w: 5.5 });
+ const tUp = Math.max(WB.cur + 0.05, q('飞上') - 0.1), tUp1 = tUp + 1.7;
+ b2.forEach(s => (s.until = tUp));
+ WB.custom({ t0: tUp, t1: tUp1, bb: [P2X - 200, Y(-700), P2X + 200, G + 60], draw(g, qq, t) {
+ const x = P2X, y = G - 24 - 1300 * MO.cubicIn(qq), fa = 1 - U.clamp((t - tUp1) / 0.5); if (fa <= 0) return null;
+ g.globalAlpha = fa; g.strokeStyle = OR; g.lineWidth = 4.5; g.beginPath(); g.moveTo(x, G - 8); g.lineTo(x, Math.max(y + 80, G - 900)); g.stroke(); g.setLineDash([]); g.globalAlpha = 1;
+ if (qq < 1) { WB.drawPrep(g, FL, x, y, 1, 0, 0.75 + 0.25 * Math.sin(t * 43)); WB.drawPrep(g, Bp1, x, y, 1, 0); }
+ return null; } });
+ // 落地那一枚的静止版:落地 → 被挪走之前
+ WB.custom({ t0: tR1, t1: tR1 + 0.01, bb: [LX - 200, G - BH - 60, LX + 200, G + 60], draw(g, qq, t) { WB.drawPrep(g, Bp1, LX, G - 24, 1, 0); return null; } });
+ // ---- 相机 ----
+ const t0 = WB.T0(id);
+ const T = t0 + TIMING.seg[id].dur;
+ WB.shot(q('接着呢') - 0.12 - 0.62, 0.6, t0, q('2015年'), { add: [[RX - 50, G - 40, LX + 150, G + 40]] });
+ WB.shot(q('2015年') - 0.1, 0.8, t0, q('2017年'), { zmax: 1.1, add: [[7450, Y(450), 8000, Y(600)]] });
+ WB.shot(q('2017年') - 0.25, 0.8, q('2015年'), T, { add: [[LX - 150, G - BH - 40, P2X + 150, G + 40]] });
+});
+SCENES['s05'] = WB.scene;
diff --git a/scripts/engine/reference_films/spacex/spacex_wb/scenes/s06.js b/scripts/engine/reference_films/spacex/spacex_wb/scenes/s06.js
new file mode 100644
index 0000000..ad08d87
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_wb/scenes/s06.js
@@ -0,0 +1,55 @@
+// S06 · 重型猎鹰(C 行左段,x 0–2300)。换行用「拉远再扎进去」:相机先退到能看见 A、B 两行的远处(全片第一次看到这块板有多大),再扎进 C 行。
+// 快节奏三拍:「2018年」+三芯并联的重型猎鹰 → 相机快推到一颗橙色太阳,一辆小跑车(车里一个戴头盔的小人)沿虚线绕太阳转 →
+// 两个着陆圈,两枚助推器同步竖着落下,「并排」弹出,落地扬起两团小尘。
+WB.chapter('s06', id => {
+ const q = k => WB.q(id, k), { OR, INK } = WB, D = WB.D, Y = v => WB.ROW.C + v;
+ const t0 = WB.T0(id);
+ // ---- 换行:拉远 → 扎进 C 行 ----
+ // ---- 2018年,重型猎鹰首飞 ----
+ WB.go(t0 + 0.9); WB.text('2018年', 130, Y(250), 130, { rate: 11 });
+ WB.go(q('重型猎鹰') - 0.1); WB.text('重型猎鹰首飞', 130, Y(370), 66, { rate: 15 }); // 标签先写完,镜头走之前不留半截字
+ WB.go(WB.cur + 0.02); WB.sk(D.heavy(520), 720, Y(820), { speed: 6200, w: 5.5 });
+ // ---- 把一辆跑车送上了绕太阳的轨道 ----
+ const SX = 1470, SY = Y(430), SR = 105;
+ WB.go(q('跑车') - 0.3);
+ WB.line(WB.circ(SX, SY, SR, 1.04), { col: OR, w: 7, speed: 4200 });
+ WB.hatchCircle(SX, SY, SR, { gap: 20, ang: -Math.PI / 4 });
+ for (let i = 0; i < 10; i++) { const a = i / 10 * Math.PI * 2 + 0.2; WB.line([[SX + Math.cos(a) * (SR + 22), SY + Math.sin(a) * (SR + 22)], [SX + Math.cos(a) * (SR + 56), SY + Math.sin(a) * (SR + 56)]], { col: OR, w: 5.5, speed: 4000, min: 0.018, gap: 0.004, smooth: false }); }
+ const tRays = WB.cur, ORX = 370, ORY = 150, ROT = -0.08;
+ WB.go(q('绕太阳') - 0.25); WB.line(WB.ell(SX, SY, ORX, ORY, Math.PI * 0.6, 1.02, ROT, 72), { w: 3.2, speed: 7000, smooth: false });
+ const CAR = WB.prep([...D.car(150), ...D.fig(70, 'wave', { helmet: true }).map(k => k.fillPts ? { ...k, fillPts: k.fillPts.map(([x, y]) => [x + 4, y - 30]) } : { ...k, p: k.p.map(([x, y]) => [x + 4, y - 30]) })], 5);
+ const tC = q('跑车') + 0.1;
+ WB.custom({ t0: tC, t1: tC + 0.3, bb: [SX - ORX - 160, SY - ORY - 160, SX + ORX + 160, SY + ORY + 160], draw(g, qq, t) {
+ const w = (t - tC) * 0.75 + Math.PI * 0.75, c = Math.cos(ROT), n = Math.sin(ROT), X0 = Math.cos(w) * ORX, Y0 = Math.sin(w) * ORY;
+ const x = SX + X0 * c - Y0 * n, y = SY + X0 * n + Y0 * c, a = Math.atan2(Math.cos(w) * ORY, -Math.sin(w) * ORX) + ROT;
+ const behind = Math.sin(w) < 0;
+ if (behind) { g.beginPath(); g.rect(-1e5, -1e5, 2e5, 2e5); g.arc(SX, SY, SR + 60, 0, Math.PI * 2, true); g.clip(); }
+ const flip = Math.cos(a) < 0 ? -1 : 1;
+ g.translate(x, y); g.rotate((flip < 0 ? a + Math.PI : a) * 0.3); g.scale(flip, 1); WB.drawPrep(g, CAR, 0, 0, MO.backOut(qq, 2), 0); return null; } });
+ WB.text('跑车', SX - ORX - 30, SY + ORY + 70, 60, { rate: 14, t0: Math.max(q('跑车') + 0.45, tRays + 0.02) });
+ // ---- 两枚助推器并排落回地面 ----
+ const G = Y(800), BX = [2060, 2290], BH = 330;
+ WB.go(q('两枚') - 0.2);
+ WB.line([[1900, G], [2460, G]], { speed: 8000, w: 6 });
+ BX.forEach(x => WB.line(WB.ell(x, G + 4, 90, 20, Math.PI, 1.03, 0, 36), { w: 5, speed: 6000 }));
+ const B0 = WB.prep(D.falcon9(BH, { stage: 'booster', legs: 0, fins: 1 }), 5.5), B1 = WB.prep(D.falcon9(BH, { stage: 'booster', legs: 1, fins: 1 }), 5.5);
+ const FL = WB.prep([{ p: [[-15, 2], [0, 76], [15, 2]], o: 1, w: 0.9 }], 5.5), m = BH / 41;
+ const tD0 = q('助推器') - 0.15, tD1 = q('地面') + 0.02;
+ WB.custom({ t0: tD0, t1: tD1, bb: [1830, Y(-700), 2530, G + 80], draw(g, qq, t) {
+ const u = 1 - Math.pow(1 - qq, 2.2), yb = U.lerp(Y(-260), G - 2.5 * m, u), leg = U.clamp((qq - 0.7) / 0.2);
+ BX.forEach((x, i) => {
+ if (qq < 1) WB.drawPrep(g, FL, x, yb, 1, 0, 0.7 + 0.3 * Math.sin(t * 41 + i));
+ WB.drawPrep(g, leg > 0.5 ? B1 : B0, x, yb, 1, 0);
+ if (qq >= 1) { const k = U.clamp((t - tD1) / 0.7); if (k < 1) { g.save(); g.globalAlpha = 1 - k; g.strokeStyle = INK; g.lineWidth = 4; for (const sx of [-1, 1]) for (let j = 0; j < 3; j++) { g.beginPath(); g.arc(x + sx * (70 + j * 24 + k * 36), G - 10 - j * 6, 9 + j * 4, Math.PI, Math.PI * 2); g.stroke(); } g.restore(); } }
+ });
+ return null; } });
+ WB.pop('并排', 2175, Y(250), 110, { at: q('并排') + 0.2 });
+ WB.line([[2070, Y(285)], [2280, Y(292)]], { col: OR, w: 6, t0: q('并排') + 0.35, dur: 0.18 });
+ // ---- 相机 ----
+ const T = t0 + TIMING.seg[id].dur;
+ WB.shot(t0 - 1.0, 0.7, -10, t0, { zmax: 0.3, pad: 80, sy: 520, ease: MO.cubicInOut, creep: 0 });
+ WB.shot(t0 + 0.45, 0.7, t0, q('跑车') - 0.32, { zmax: 1.15, ease: MO.cubicInOut, creep: 0 });
+ WB.shot(q('跑车') - 0.45, 0.4, q('跑车') - 0.32, q('两枚') - 0.25, { zmax: 1.2, ease: MO.cubicInOut, add: [[SX - ORX - 80, SY - ORY - 80, SX + ORX + 80, SY + ORY + 80]] });
+ WB.shot(q('两枚') - 0.35, 0.6, q('两枚') - 0.25, T, { ease: MO.cubicInOut, add: [[SX + 100, SY - 50, 2460, G + 30], [1950, Y(330), 2400, Y(400)]] });
+});
+SCENES['s06'] = WB.scene;
diff --git a/scripts/engine/reference_films/spacex/spacex_wb/scenes/s07.js b/scripts/engine/reference_films/spacex/spacex_wb/scenes/s07.js
new file mode 100644
index 0000000..5f4f138
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_wb/scenes/s07.js
@@ -0,0 +1,67 @@
+// S07 · 载人龙飞船(C 行中段,x 2800–5000)。「2020年5月」→ 一个大大的载人龙飞船舱体,两个舷窗里各一个面罩不透明的头盔(两名宇航员)→
+// 它沿虚线飞向右上角的小空间站对接;相机右移:一条 2011 —— 2020 的时间线,中间一道橙色大括号「近9年」弹出,
+// 2020 那头一枚小火箭从「本土」升空;最后「第一次」弹出,笔写「私人公司的飞船把人送进轨道」。
+WB.chapter('s07', id => {
+ const q = k => WB.q(id, k), { OR, INK } = WB, D = WB.D, Y = v => WB.ROW.C + v;
+ WB.lead([2420, Y(600)], [2950, Y(620)], q('2020年') - 0.12 - 0.62, 0.5); // 引线和相机同时走:笔领着相机,落位那一刻正好开写
+ WB.go(q('2020年') - 0.12); WB.text('2020年5月', 2820, Y(250), 120, { rate: 10 });
+ const CX = 3100, CY = Y(760), CW = 250;
+ WB.go(q('载人') - 0.05);
+ const cap = WB.sk(D.dragon(CW, {}), CX, CY, { speed: 3400, w: 7 });
+ WB.go(q('两名') - 0.1); WB.figure(CX + 210, CY, 150, [[0, 'stand'], [q('宇航员') + 0.3, 'wave'], [q('空间站') + 0.2, 'stand'], [q('美国') + 0.1, 'wave']], { helmet: true, speed: 3800, w: 6 }); WB.figure(CX + 300, CY, 150, [[0, 'stand'], [q('宇航员') + 0.5, 'cheer'], [q('空间站') + 0.4, 'stand']], { helmet: true, speed: 3800, w: 6 });
+ WB.text('两名宇航员', CX + 255, CY + 80, 58, { align: 'center', rate: 12 });
+ // 空间站+飞过去对接
+ const IX = 3720, IY = Y(310), IS = 380;
+ WB.go(q('送往') - 0.1); WB.sk(D.iss(IS), IX, IY, { speed: 7000, w: 5.5 });
+ const port = WB.issPort(IX, IY, IS), SC = WB.prep(D.dragon(70, {}), 5);
+ const p0 = [CX + 60, CY - CW * 1.0], p1 = [CX + 420, Y(560)], p2 = [port[0], port[1] + 70 * 0.95];
+ const bz = u => [(1 - u) ** 2 * p0[0] + 2 * u * (1 - u) * p1[0] + u * u * p2[0], (1 - u) ** 2 * p0[1] + 2 * u * (1 - u) * p1[1] + u * u * p2[1]];
+ const path = []; for (let i = 0; i <= 30; i++) path.push(bz(i / 30)); const pc = DG.cum(path);
+ const tF0 = q('空间站') - 0.25, tF1 = tF0 + 0.95;
+ WB.custom({ t0: tF0, t1: tF1, bb: [CX, Y(200), IX + 260, Y(760)], draw(g, qq, t) {
+ const e = MO.sineInOut(qq), [x, y] = bz(e), [x2, y2] = bz(Math.min(1, e + 0.02));
+ g.strokeStyle = OR; g.lineWidth = 4; DG.drawPartial(g, path, pc, pc[pc.length - 1] * e); g.setLineDash([]);
+ const a = U.lerp(Math.atan2(y2 - y, x2 - x) + Math.PI / 2, 0, MO.smooth(U.clamp((qq - 0.5) / 0.5)));
+ WB.drawPrep(g, SC, x, y, 1, qq >= 1 ? 0 : a); return null; } });
+ WB.text('空间站', IX + 70, Y(505), 56, { rate: 14, t0: Math.max(tF1 - 0.1, WB.cur + 0.02) });
+ // ---- 美国时隔近9年,重新从本土送人上天 ----
+ const L0 = 3650, L1 = 4700, LY = Y(760);
+ WB.go(q('美国') + 0.15);
+ WB.line([[L0, LY], [L1, LY]], { speed: 6000, w: 6 });
+ [L0, L1].forEach(x => WB.line([[x, LY - 24], [x, LY + 24]], { smooth: false, speed: 3200, min: 0.03 }));
+ WB.text('2011', L0, LY + 80, 60, { align: 'center', rate: 30 });
+ WB.text('2020', L1, LY + 80, 60, { align: 'center', rate: 30 });
+ // 大括号(开口朝下)
+ WB.go(q('时隔') - 0.05);
+ const br = []; const bw = L1 - L0 - 40, bx = L0 + 20, by = LY - 40;
+ for (let i = 0; i <= 40; i++) { const u = i / 40, x = bx + bw * u, k = Math.abs(u - 0.5) * 2, y = by - 22 * (1 - Math.pow(k, 6)) - (u > 0.47 && u < 0.53 ? 24 * (1 - Math.abs(u - 0.5) / 0.03) : 0); br.push([x, y]); }
+ WB.line(br, { col: OR, w: 6, speed: 4400 });
+ const p9 = WB.pop('近9年', (L0 + L1) / 2, LY - 110, 104, { at: Math.max(WB.cur + 0.3, q('近9年') + 0.25) }); WB.at(p9.t1 + 0.03);
+ // 空着的这些年:时间线下挂一张蜘蛛网(闲置太久)
+ { const cx = (L0 + L1) / 2 - 260, cy = LY + 6, R = 70; const web = [];
+ for (let k = 0; k < 5; k++) { const a = Math.PI * (0.1 + k * 0.2); web.push({ p: [[cx, cy], [cx + Math.cos(a) * R, cy + Math.sin(a) * R]], w: 0.45, smooth: false }); }
+ for (const r of [0.35, 0.7]) web.push({ p: Array.from({ length: 5 }, (_, k) => { const a = Math.PI * (0.1 + k * 0.2); return [cx + Math.cos(a) * R * r, cy + Math.sin(a) * R * r]; }), w: 0.45, smooth: false });
+ web.push({ p: [[cx + 30, cy], [cx + 30, cy + 95]], w: 0.4, smooth: false }, { p: WB.circ(cx + 30, cy + 104, 9, 1.05), w: 0.7 });
+ WB.sk(web, 0, 0, { speed: 9000, w: 5 }); }
+ // 2020 那头:本土发射
+ WB.go(q('本土') - 0.1); WB.text('本土', L1 + 70, LY - 30, 58, { rate: 12 });
+ const RP = WB.prep(D.falcon9(260, { payload: 'dragon' }), 5), FL = WB.prep([{ p: [[-10, 2], [0, 56], [10, 2]], o: 1, w: 0.9 }], 5);
+ const tU = q('上天') - 0.4;
+ const r0 = WB.sk(D.falcon9(260, { payload: 'dragon' }), L1, LY - 8, { speed: 5600, w: 5 });
+ WB.go(tU); r0.forEach(s => (s.until = tU));
+ WB.custom({ t0: tU, t1: tU + 1.3, bb: [L1 - 120, Y(-600), L1 + 120, LY + 20], draw(g, qq, t) {
+ const y = LY - 8 - 900 * MO.cubicIn(qq), fa = 1 - U.clamp((t - tU - 1.3) / 0.5); if (fa <= 0) return null;
+ g.globalAlpha = fa; g.strokeStyle = OR; g.lineWidth = 4; g.beginPath(); g.moveTo(L1, LY - 10); g.lineTo(L1, Math.max(y + 60, LY - 700)); g.stroke(); g.setLineDash([]); g.globalAlpha = 1;
+ if (qq < 1) { WB.drawPrep(g, FL, L1, y, 1, 0, 0.75 + 0.25 * Math.sin(t * 43)); WB.drawPrep(g, RP, L1, y, 1, 0); } return null; } });
+ // ---- 也是第一次,由私人公司的飞船把人送进轨道 ----
+ WB.pop('第一次', 4220, Y(290), 120, { at: q('第一次') + 0.2, rot: -0.04 });
+ WB.go(q('私人公司') + 0.05); WB.text('私人公司的飞船', 4220, Y(395), 64, { align: 'center', rate: 9 });
+ WB.go(q('把人送进') + 0.05); WB.text('把人送进轨道', 4220, Y(480), 64, { align: 'center', rate: 9 });
+ // ---- 相机 ----
+ const t0 = WB.T0(id);
+ const T = t0 + TIMING.seg[id].dur;
+ WB.shot(q('2020年') - 0.12 - 0.62, 0.6, t0, q('美国'), { dx: 130 }); // 多走 130:上一段的线头完全出画
+ WB.shot(q('美国') - 0.2, 0.8, q('美国'), q('也是'), { add: [[IX - 200, IY - 170, IX + 200, IY + 120]] });
+ WB.shot(q('第一次') - 0.3, 0.7, q('美国'), T, { add: [[4000, Y(240), 4450, Y(340)]] });
+});
+SCENES['s07'] = WB.scene;
diff --git a/scripts/engine/reference_films/spacex/spacex_wb/scenes/s08.js b/scripts/engine/reference_films/spacex/spacex_wb/scenes/s08.js
new file mode 100644
index 0000000..b2a0882
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_wb/scenes/s08.js
@@ -0,0 +1,93 @@
+// S08 · 发射越来越密(C 行右段,x 5400–8450)。手绘柱状图:先画坐标轴,2017、2022、2023、2024 四根黑色斜线柱一根比一根高(真实数据,
+// 2018–2021 只有百科口径,不上图,横轴用「…」隔开),2025 那根橙色柱慢慢长到顶,「165」落定;
+// 相机右移:一页小日历,隔一天点一个橙点 →「两天多一发」;一架跷跷板:左边「猎鹰9号」把右边「其他火箭加起来」翘起来;
+// 再右移:一枚一级,旁边笔一道一道划计数(正字记数的西式写法,五道一组),划到 37,「37次」弹出。
+WB.chapter('s08', id => {
+ const q = k => WB.q(id, k), { OR, INK } = WB, D = WB.D, Y = v => WB.ROW.C + v;
+ // ---- 图表 ----
+ const OX = 5480, OY = Y(790), HMAX = 500, val = v => v / 165 * HMAX;
+ const bars = [['2017', 18, 5560], ['2022', 61, 5780], ['2023', 96, 5920], ['2024', 134, 6060], ['2025', 165, 6200]], BW = 100;
+ WB.lead([4930, Y(560)], [5430, Y(500)], q('回收之后') - 0.12 - 0.62, 0.5); // 引线和相机同时走:笔领着相机,落位那一刻正好开写
+ WB.go(q('回收之后') - 0.12);
+ WB.text('猎鹰火箭年发射次数', OX, Y(210), 58, { rate: 18 });
+ WB.line(WB.dense([[OX, Y(250)], [OX, OY], [6330, OY]], 10), { speed: 6500, w: 5.5 });
+ WB.text('…', 5665, OY + 62, 50, { dur: 0.06, align: 'center' });
+ bars.slice(0, 4).forEach(([yr, v, x], i) => {
+ const h = val(v);
+ WB.line(WB.dense([[x - BW / 2, OY], [x - BW / 2, OY - h], [x + BW / 2, OY - h], [x + BW / 2, OY]], 6), { speed: 7000, w: 5, min: 0.05, gap: 0.01 });
+ WB.hatchRect(x - BW / 2 + 6, OY - h + 6, BW - 12, h - 8, { col: INK, w: 2.6, gap: 26, speed: 26000 });
+ WB.text(String(v), x, OY - h - 18, 46, { align: 'center', rate: 30 });
+ WB.text(yr, x, OY + 62, 44, { align: 'center', rate: 30 });
+ });
+ // 2025:橙色柱长出来,165 落定
+ const x5 = bars[4][2], h5 = val(165), tG0 = q('2025年') + 0.2, tG1 = q('165次') + 0.12;
+ WB.go(tG0 - 0.3); WB.text('2025', x5, OY + 62, 44, { align: 'center', rate: 24, col: OR });
+ WB.custom({ t0: tG0, t1: tG1, handed: false, bb: [x5 - 80, OY - h5 - 40, x5 + 80, OY + 10],
+ start: () => [x5 + BW / 2, OY], end: () => [x5 + BW / 2, OY - h5],
+ draw(g, qq) { const h = h5 * MO.quintOut(qq);
+ g.save(); g.beginPath(); g.rect(x5 - BW / 2, OY - h, BW, h); g.clip(); g.strokeStyle = OR; g.lineWidth = 3.4;
+ for (let k = 10; k < BW + h5; k += 20) { g.beginPath(); g.moveTo(x5 - BW / 2 + Math.min(k, BW), OY - h5 + Math.max(0, k - BW)); g.lineTo(x5 - BW / 2 + Math.max(0, k - h5), OY - h5 + Math.min(k, h5)); g.stroke(); }
+ g.restore();
+ g.strokeStyle = OR; g.lineWidth = 7; g.beginPath(); g.moveTo(x5 - BW / 2, OY); g.lineTo(x5 - BW / 2, OY - h); g.lineTo(x5 + BW / 2, OY - h); g.lineTo(x5 + BW / 2, OY); g.stroke();
+ return qq < 1 ? [x5 + BW / 2, OY - h] : null; } });
+ WB.pop('165', x5, OY - h5 - 26, 104, { at: q('165次') + 0.15 });
+ // ---- 平均两天多一发:小日历 ----
+ const CX = 6600, CY = Y(280), CWd = 330, CH = 250;
+ WB.go(q('平均') - 0.05);
+ WB.line(WB.rect(CX - CWd / 2, CY - CH / 2, CWd, CH), { speed: 7500, w: 5.5 });
+ WB.line([[CX - CWd / 2, CY - CH / 2 + 56], [CX + CWd / 2, CY - CH / 2 + 56]], { speed: 7500, w: 5, smooth: false });
+ for (const dx of [-0.25, 0.25]) WB.line([[CX + dx * CWd, CY - CH / 2 - 22], [CX + dx * CWd, CY - CH / 2 + 18]], { speed: 5500, w: 6, smooth: false, min: 0.02 });
+ for (let r = 1; r < 3; r++) WB.line([[CX - CWd / 2, CY - CH / 2 + 56 + r * (CH - 56) / 3], [CX + CWd / 2, CY - CH / 2 + 56 + r * (CH - 56) / 3]], { speed: 12000, w: 2.6, smooth: false, min: 0.018, gap: 0.004 });
+ for (let c = 1; c < 7; c++) WB.line([[CX - CWd / 2 + c * CWd / 7, CY - CH / 2 + 56], [CX - CWd / 2 + c * CWd / 7, CY + CH / 2]], { speed: 12000, w: 2.6, smooth: false, min: 0.016, gap: 0.004 });
+ const tD = WB.cur;
+ WB.custom({ t0: tD, t1: tD + 0.55, bb: [CX - CWd / 2, CY - CH / 2, CX + CWd / 2, CY + CH / 2], draw(g, qq) {
+ g.fillStyle = OR; const cw = CWd / 7, ch = (CH - 56) / 3;
+ for (let i = 0; i < 21; i++) { if (i % 2) continue; const k = U.clamp(qq * 11 - i / 2); if (k <= 0) continue;
+ const cx = CX - CWd / 2 + (i % 7 + 0.5) * cw, cy = CY - CH / 2 + 56 + (Math.floor(i / 7) + 0.5) * ch, r = 11 * MO.backOut(k, 2.4);
+ g.beginPath(); g.arc(cx, cy, r, 0, Math.PI * 2); g.fill(); } return null; } });
+ WB.at(tD + 0.1); WB.text('两天多一发', CX, CY + CH / 2 + 84, 66, { align: 'center', rate: 12 });
+ // ---- 比全世界其他火箭加起来还多:跷跷板 ----
+ const SX = 7230, SY = Y(820), PL = 720, PH = 160;
+ WB.go(q('比全世界') + 0.05);
+ WB.line([[SX - 50, SY], [SX, SY - PH + 8], [SX + 50, SY], [SX - 50, SY]], { speed: 4200, smooth: false });
+ const tilt = q('还多') - 0.32, tilt1 = tilt + 0.24, ANG = -0.24;
+ const board = WB.custom({ t0: WB.cur, t1: WB.cur + 0.55, handed: true, bb: [SX - PL / 2 - 40, SY - PH - 300, SX + PL / 2 + 40, SY + 20], fit: true,
+ start: () => [SX - PL / 2, SY - PH], end: () => [SX + PL / 2, SY - PH],
+ draw(g, qq, t) {
+ const a = ANG * MO.backOut(U.clamp((t - tilt) / (tilt1 - tilt)), 2.6), c = Math.cos(a), n = Math.sin(a);
+ g.translate(SX, SY - PH); g.rotate(a); g.strokeStyle = INK; g.lineWidth = 6; g.lineCap = 'round';
+ const L = PL * Math.min(1, qq * 1.6); g.beginPath(); g.moveTo(-PL / 2, 0); g.lineTo(-PL / 2 + L, 0); g.stroke();
+ const k = U.clamp(qq * 1.6 - 0.6) / 1;
+ if (k > 0) { g.globalAlpha = Math.min(1, k * 2);
+ // 左边重:一大块;右边轻:一小块
+ // 两边差不多大(只说「更多」,不画成碾压);左边铺橙色斜线
+ g.lineWidth = 5.5; g.strokeRect(-PL / 2 + 16, -175, 275, 175); g.strokeRect(PL / 2 - 236, -130, 220, 130);
+ g.save(); g.beginPath(); g.rect(-PL / 2 + 16, -175, 275, 175); g.clip(); g.strokeStyle = 'rgba(239,114,38,.75)'; g.lineWidth = 3.2;
+ for (let d = -175; d < 290; d += 20) { g.beginPath(); g.moveTo(-PL / 2 + 16 + d, 0); g.lineTo(-PL / 2 + 16 + d + 175, -175); g.stroke(); } g.restore();
+ g.textAlign = 'center'; g.fillStyle = INK; g.font = `54px ${WB.FONT}`; g.fillText('猎鹰9号', -PL / 2 + 153, -68);
+ g.font = `46px ${WB.FONT}`; g.fillText('其他火箭', PL / 2 - 126, -72); g.fillText('加起来', PL / 2 - 126, -22); }
+ // 砸下去那一下:左端一圈「咚」的冲击线
+ if (t > tilt1 - 0.05) { const k = U.clamp((t - tilt1 + 0.05) / 0.45); if (k < 1) { g.globalAlpha = 1 - k; g.lineWidth = 5; g.strokeStyle = INK; for (const [ax, ay] of [[-1, -0.6], [-1.3, 0], [-1, 0.6]]) { g.beginPath(); g.moveTo(-PL / 2 - 10 + ax * (20 + 30 * k), 10 + ay * (20 + 30 * k)); g.lineTo(-PL / 2 - 10 + ax * (50 + 30 * k), 10 + ay * (50 + 30 * k)); g.stroke(); } } }
+ return qq < 1 ? [-PL / 2 + L, 0].map((v, i) => i ? SY - PH + v : SX + v) : null; } });
+ WB.texts.push('猎鹰9号其他火箭加起来');
+ // ---- 有一枚助推器,已经飞了37次:划计数 ----
+ const BX = 7830, G = Y(800);
+ WB.go(q('有一枚') - 0.1); WB.sk(D.falcon9(540, { stage: 'booster', legs: 1, fins: 1 }), BX, G - 24, { speed: 9500, w: 6.5 });
+ [[-10, -430, 0.25], [16, -300, -0.2], [-8, -175, 0.1]].forEach(([dx, dy, r]) => WB.sk(D.patch(40, r), BX + dx, G - 24 + dy, { speed: 9000, w: 5 }));
+ for (let k = 0; k < 5; k++) WB.line([[BX - 34 + k * 14, G - 60 - (k % 2) * 30], [BX - 22 + k * 14, G - 120 - (k % 2) * 30]], { w: 3, speed: 9000, min: 0.015, gap: 0.004, smooth: false }); // 底部烧痕 // 飞了很多次的旧助推器:打满补丁
+ const TX = 8030, TYp = Y(420), GWd = 112, RH2 = 120;
+ const tallies = []; for (let i = 0; i < 37; i++) { const gi = Math.floor(i / 5), j = i % 5, gx = TX + (gi % 4) * GWd, gy = TYp + Math.floor(gi / 4) * (RH2 + 40);
+ tallies.push(j < 4 ? [[gx + j * 20, gy], [gx + j * 20 + 2, gy + RH2 * 0.75]] : [[gx - 12, gy + RH2 * 0.6], [gx + 78, gy + RH2 * 0.12]]); }
+ const tT0 = WB.cur, tT1 = q('37次') - 0.02, dt = (tT1 - tT0) / 37;
+ tallies.forEach((p, i) => WB.line(p, { t0: tT0 + i * dt, dur: dt * 0.8, w: 6, col: i >= 35 ? OR : INK, smooth: false }));
+ WB.at(tT1);
+ WB.pop('37次', TX + 190, Y(330), 120, { at: q('37次') + 0.3 });
+ // ---- 相机 ----
+ const t0 = WB.T0(id);
+ const T = t0 + TIMING.seg[id].dur;
+ WB.shot(q('回收之后') - 0.12 - 0.62, 0.6, t0, q('平均'), { add: [[x5 - 60, OY - h5 - 120, x5 + 60, OY]] });
+ WB.move(q('165次') - 0.35, q('165次') + 0.15, x5 - 260, OY - 228, 1.17, { ease: MO.cubicInOut }); // 「165」落定那一下推近最高那根柱
+ WB.shot(q('平均') - 0.3, 0.75, q('平均'), q('有一枚'), { add: [[x5 - 60, OY - h5 - 120, x5 + 60, OY]] });
+ WB.shot(q('有一枚') - 0.2, 0.8, q('有一枚'), T, { add: [[TX + 100, Y(240), TX + 300, Y(340)]] });
+});
+SCENES['s08'] = WB.scene;
diff --git a/scripts/engine/reference_films/spacex/spacex_wb/scenes/s09.js b/scripts/engine/reference_films/spacex/spacex_wb/scenes/s09.js
new file mode 100644
index 0000000..1d3776f
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_wb/scenes/s09.js
@@ -0,0 +1,53 @@
+// S09 · 星链(D 行左段,x 0–2200)。甩镜从 C 行末尾跳到 D 行开头。
+// 一颗大地球;左上一颗星链卫星(箭头从地球边的小火箭指向它)+「星链卫星」;「2019年」→ 一小串 60 个点沿弧线排上轨道,「60颗」;
+// 「现在」→ 笔绕着地球点出一整层密密麻麻的点(几百个,一层层铺满,之后整层慢慢转),「1.1万颗」砸入;
+// 右下一排小房子,「1200万用户」弹出。
+WB.chapter('s09', id => {
+ const q = k => WB.q(id, k), { OR, INK } = WB, D = WB.D, Y = v => WB.ROW.D + v;
+ const t0 = WB.T0(id);
+ // ---- 换行:笔从 C 行末尾的计数那儿拉一条橙色长路,沿两行之间的空当一路向左,拐下来指向地球;相机跟着笔走 ----
+ const road = WB.dense([[8470, 3000], [8520, 3240], [8380, 3290], [260, 3290], [150, 3360], [140, 3900], [200, 3990], [500, 3990]], 16);
+ const tR0 = Math.max(WB.cur + 0.02, t0 - 0.6);
+ const rd = WB.line(road, { col: OR, w: 8, dur: 0.95, dash: [1, 15], amp: 1.0, t0: tR0, nofit: true });
+ WB.line([[470, 3962], [506, 3990], [470, 4018]], { col: OR, w: 7, smooth: false, t0: rd.t1 + 0.01, dur: 0.08, nofit: true });
+ WB.fade([rd, WB.S[WB.S.indexOf(rd) + 1]], rd.t1 + 1.2, 0.5); // 换行用的路走完就淡掉,不压在下一行的画面顶上
+ const tRe = rd.t1 + 0.1, rp = u => DG.pointAt(rd.pts, rd.cum, rd.len * MO.sineInOut(u));
+ WB.move(rd.t0 - 0.05, rd.t0 + 0.25, ...(([x, y]) => [x - 500, y - 100])(rp(0.2)), 0.55, { ease: MO.cubicIn });
+ WB.move(rd.t0 + 0.25, rd.t0 + 0.65, ...(([x, y]) => [x + 300, y - 100])(rp(0.72)), 0.55, { whip: true, ease: MO.linear });
+ const EX = 780, EY = Y(540), ER = 220;
+ WB.go(Math.max(tRe, q('这些') + 0.1)); WB.sk(D.earth(ER), EX, EY, { speed: 3600, w: 7 });
+ // 小火箭 → 卫星
+ WB.go(q('大多') - 0.05); WB.sk(D.falcon9(220, {}), 250, Y(820), { speed: 6000, w: 5 });
+ WB.arrow([280, Y(570)], [250, Y(380)], { col: OR, head: 22, w: 5, bend: -20 });
+ WB.go(q('星链') - 0.2); WB.sk(D.sat(190), 250, Y(300), { speed: 5200 });
+ WB.text('星链卫星', 250, Y(200), 66, { align: 'center', rate: 12 });
+ // 2019年,第一批60颗
+ WB.go(q('2019年') + 0.2); WB.text('2019年', 1160, Y(240), 96, { rate: 11 });
+ const tS0 = q('第一批') + 0.05, tS1 = q('60颗') + 0.05;
+ WB.custom({ t0: tS0, t1: tS1, bb: [EX - 400, EY - 400, EX + 400, EY + 400], draw(g, qq, t) {
+ g.fillStyle = INK; const R = ER + 58;
+ for (let i = 0; i < 60; i++) { const k = U.clamp(qq * 60 - i); if (k <= 0) break; const a = -2.35 + i * 0.022 + (t - tS1) * 0.05 * (t > tS1); g.beginPath(); g.arc(EX + Math.cos(a) * R, EY + Math.sin(a) * R, 4.2 * k, 0, 7); g.fill(); }
+ return null; } });
+ WB.pop('60颗', 1270, Y(360), 90, { at: q('60颗') + 0.2 });
+ // 现在,在轨的超过1.1万颗:一整层点
+ const N = 520, rr = U.rng(19), dots = []; for (let i = 0; i < N; i++) dots.push({ a: rr() * Math.PI * 2, r: ER + 34 + rr() * 110, s: 2.6 + rr() * 2.4, o: rr() });
+ dots.sort((a, b) => a.o - b.o);
+ const tC0 = q('在轨') - 0.05, tC1 = q('万颗') + 0.05;
+ WB.custom({ t0: tC0, t1: tC1, handed: true, bb: [EX - 420, EY - 420, EX + 420, EY + 420], start: () => [EX - ER - 80, EY], end: () => [EX + ER + 80, EY],
+ draw(g, qq, t) {
+ const n = Math.floor(N * MO.sineInOut(qq)), rot = (t - tC0) * 0.06; g.fillStyle = INK;
+ for (let i = 0; i < n; i++) { const d = dots[i], a = d.a + rot * (300 / d.r); g.beginPath(); g.arc(EX + Math.cos(a) * d.r, EY + Math.sin(a) * d.r * 0.96, d.s, 0, 7); g.fill(); }
+ if (qq < 1 && n > 0) { const d = dots[n - 1], a = d.a + rot * (300 / d.r); return [EX + Math.cos(a) * d.r, EY + Math.sin(a) * d.r * 0.96]; }
+ return null; } });
+ WB.text('现在在轨', 1480, Y(400), 56, { rate: 14, t0: q('现在') + 0.15 });
+ WB.pop('超过1.1万颗', 1440, Y(510), 100, { at: q('万颗') + 0.2 });
+ // 用户超过1200万
+ WB.go(q('用户') - 0.05);
+ for (let i = 0; i < 4; i++) WB.sk(D.house(52), 1240 + i * 120, Y(720), { speed: 7000, w: 5.5 });
+ WB.pop('超过1200万用户', 1440, Y(840), 84, { at: q('1200') + 0.5 });
+ // 相机:右移一点,给右边的数字留位
+ const T = t0 + TIMING.seg[id].dur, shell = [[EX - ER - 150, EY - ER - 150, EX + ER + 150, EY + ER + 150]];
+ WB.shot(rd.t0 + 0.65, 0.5, tRe, q('2019年'), { ease: MO.cubicOut, add: shell, zmax: 1.1 });
+ WB.shot(q('现在') - 0.2, 0.8, t0, T, { add: shell });
+});
+SCENES['s09'] = WB.scene;
diff --git a/scripts/engine/reference_films/spacex/spacex_wb/scenes/s10.js b/scripts/engine/reference_films/spacex/spacex_wb/scenes/s10.js
new file mode 100644
index 0000000..0b05bb2
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_wb/scenes/s10.js
@@ -0,0 +1,119 @@
+// S10 · 星舰(D 行中段,x 2500–5200)。三拍:
+// ① 相机先贴地推得很近,只看见一个小小的火柴人;笔从他身边开始往上画星舰,相机跟着笔一路往上摇、往后拉——画完才看清它有多高,「史上最大、最强」。
+// ② 「2023年首飞」,旁边一只钟、指针在走,「四分钟左右」;星舰升空、开始翻滚 → 笔画一团大爆炸 → 卡通烟团铺满整屏(RSA 的云团擦除),烟里「轰!」;
+// ③ 烟散开,相机已经到了右边:「2024年10月」→ 格构发射塔 → 两只橙色机械臂 → 旁边画一双筷子「像筷子」→ 助推器喷着火落下来,两只臂一合,「夹住了!」。
+WB.chapter('s10', id => {
+ const q = k => WB.q(id, k), { OR, INK } = WB, D = WB.D, Y = v => WB.ROW.D + v;
+ const t0 = WB.T0(id);
+ // ---- ① 史上最大、最强 ----
+ const SX = 2760, G = Y(880), SH = 800;
+ WB.lead([1760, Y(690)], [2420, Y(820)], WB.T0(id) - 0.65, 0.5); // 笔从星链那块拉一条点线到星舰脚下,相机跟着扎下去
+ WB.go(Math.max(WB.cur + 0.02, WB.T0(id) - 0.12));
+ WB.line([[2450, G], [2980, G]], { speed: 4300, w: 6, nofit: true });
+ WB.sk(D.fig(84, 'stand'), 2600, G, { speed: 1800, w: 5 });
+ WB.go(q('星舰') - 0.05);
+ const ship = WB.sk(D.starship(SH, 'full'), SX, G - 8, { speed: 2400, w: 7 });
+ const tUp0 = q('星舰'), tUp1 = q('最强') + 0.05;
+ WB.go(q('最大') - 0.15); WB.text('史上最大、最强', 2920, Y(250), 84, { col: OR, rate: 9.5 });
+ // ---- ② 2023年首飞,升空四分钟左右就炸了 ----
+ WB.go(q('2023年') + 0.2); WB.text('2023年首飞', 2920, Y(420), 84, { rate: 10 });
+ const CKX = 3060, CKY = Y(610), CKR = 70;
+ WB.go(q('四分钟') - 0.2); WB.line(WB.circ(CKX, CKY, CKR, 1.05), { speed: 4300, w: 6 });
+ WB.text('四分钟左右', CKX + 100, CKY + 26, 70, { rate: 12 });
+ const tK = WB.cur - 0.6;
+ WB.custom({ t0: tK, t1: tK + 0.01, bb: [CKX - 90, CKY - 90, CKX + 90, CKY + 90], draw(g, qq, t) {
+ const a = -Math.PI / 2 + (t - tK) * 4.2; g.strokeStyle = INK; g.lineWidth = 6; g.lineCap = 'round';
+ g.beginPath(); g.moveTo(CKX, CKY); g.lineTo(CKX + Math.cos(a) * CKR * 0.7, CKY + Math.sin(a) * CKR * 0.7); g.stroke();
+ g.beginPath(); g.moveTo(CKX, CKY); g.lineTo(CKX + Math.cos(-Math.PI / 2 + (t - tK) * 0.35) * CKR * 0.45, CKY + Math.sin(-Math.PI / 2 + (t - tK) * 0.35) * CKR * 0.45); g.stroke();
+ g.fillStyle = INK; g.beginPath(); g.arc(CKX, CKY, 6, 0, 7); g.fill(); return null; } });
+ // 升空、翻滚
+ const tL = q('升空') - 0.05, tBoom = q('炸了') - 0.15;
+ ship.forEach(s => (s.until = tL));
+ const SP = WB.prep(D.starship(SH, 'full'), 7), FL = WB.prep([{ p: [[-30, 2], [-12, 120], [0, 70], [12, 130], [30, 2]], o: 1, w: 0.9 }], 7);
+ const flight = t => { const u = U.clamp((t - tL) / (tBoom - tL)), y = G - 8 - 470 * MO.cubicIn(u), a = 0.9 * MO.cubicIn(U.clamp((u - 0.6) / 0.4)); return [SX - 110 * MO.cubicIn(u), y, -a, 1 - 0.55 * MO.cubicIn(u)]; };
+ WB.custom({ t0: tL, t1: tBoom, bb: [SX - 600, Y(-500), SX + 600, G + 40], draw(g, qq, t) {
+ const [x, y, a, s] = flight(Math.min(t, tBoom - 0.001)); if (t > tBoom + 0.07) return null;
+ g.strokeStyle = OR; g.lineWidth = 4; g.beginPath(); g.moveTo(SX, G - 10); g.quadraticCurveTo(SX, (G + y) / 2, x, y); g.stroke(); // 上升线
+ g.translate(x, y); g.rotate(a); g.scale(s, s); g.translate(0, -SH * 0.5);
+ WB.drawPrep(g, FL, 0, SH * 0.5, 1, 0, 0.7 + 0.3 * Math.sin(t * 40)); WB.drawPrep(g, SP, 0, SH * 0.5, 1, 0); return null; } });
+ // 爆炸:笔画一团,随后整屏烟团
+ const BXp = flight(tBoom - 0.001), BCX = BXp[0] + Math.sin(BXp[2]) * SH * 0.5 * BXp[3], BCY = BXp[1] - Math.cos(BXp[2]) * SH * 0.5 * BXp[3];
+ WB.at(tBoom); WB.sk(D.burst(160, 29), BCX, BCY, { speed: 9000, w: 7 });
+ [[-1, -0.4], [1, -0.3], [-0.7, 0.8], [0.8, 0.7], [0, -1]].forEach(([dx, dy]) => WB.line([[BCX + dx * 185, BCY + dy * 150], [BCX + dx * 230, BCY + dy * 195]], { speed: 6300, min: 0.016, gap: 0.004, w: 6, smooth: false }));
+ // 云团擦除(RSA 的转场):笔在屏幕上一团一团画出卡通烟云(先描边、描完填白),盖满整屏;笔在云上写「轰!」;相机在云后面换位;云团缩散
+ const cw0 = tBoom + 0.04, cwM = Math.max(cw0 + 0.62, q('2024年') - 0.05), cw1 = cwM + 0.42; // 云团铺满后一直停到下一句开口(口播留了多少气口就停多久)
+ const FIGH = WB.prep(D.fig(170, 'head'), 6); // 云里一个抱头的小人(反应镜头)
+ const puffs = []; { const r = U.rng(41); for (let i = 0; i < 14; i++) puffs.push({ x: 120 + r() * 1680, y: 80 + r() * 900, r: 230 + r() * 170, ph: r() * 6 }); }
+ const c0s = () => CAM.toScreen(WB.camAt(cw0), BCX, BCY);
+ puffs.sort((a, b) => Math.hypot(a.x - 960, a.y - 520) - Math.hypot(b.x - 960, b.y - 520));
+ const puffPath = (c, x, y, R, ph, q) => { // 一团云=七个小圆弧的外轮廓,q 控制描到哪
+ const n = 7, pts = []; for (let j = 0; j <= 168; j++) { const a = j / 168 * Math.PI * 2, bump = 0.82 + 0.18 * Math.abs(Math.sin(a * n / 2 + ph)); pts.push([x + Math.cos(a) * R * bump, y + Math.sin(a) * R * bump]); }
+ const m = Math.max(2, Math.round(168 * q)); c.beginPath(); for (let j = 0; j <= m; j++) j ? c.lineTo(pts[j][0], pts[j][1]) : c.moveTo(pts[j][0], pts[j][1]); return pts[Math.min(168, m)];
+ };
+ WB.fx(cw0, cw1, (c, t) => {
+ const dn = U.clamp((t - cwM) / (cw1 - cwM)), c0 = c0s(); let tip = null;
+ const cov = Math.pow(U.clamp((t - cw0 - 0.24) / 0.2) * (1 - MO.cubicIn(dn)), 1.5);
+ if (cov > 0) { c.fillStyle = WB.BOARD; c.globalAlpha = cov; c.fillRect(0, 0, 1920, 1080); c.globalAlpha = 1; }
+ puffs.forEach((p, i) => {
+ const s0 = cw0 + i * 0.02, q = U.clamp((t - s0) / 0.08); if (q <= 0) return;
+ const shrink = 1 - MO.cubicIn(U.clamp(dn * 1.4 - i * 0.03)); if (shrink <= 0.02) return;
+ const x = U.lerp(c0[0], p.x, MO.cubicOut(U.clamp((t - cw0) / 0.35))), y = U.lerp(c0[1], p.y, MO.cubicOut(U.clamp((t - cw0) / 0.35))), R = p.r * shrink * (0.55 + 0.45 * MO.cubicOut(q));
+ if (q >= 1) { puffPath(c, x, y, R, p.ph, 1); c.closePath(); c.fillStyle = WB.BOARD; c.fill(); }
+ const e = puffPath(c, x, y, R, p.ph, q); c.strokeStyle = INK; c.lineWidth = 6; c.lineJoin = c.lineCap = 'round'; c.stroke();
+ if (q < 1) tip = [e[0], e[1], INK];
+ });
+ // 「轰!」:笔按笔顺写出来,写完轻弹一下,手马上离开;旁边弹出一个抱头的小人;随云散去
+ const w0 = cw0 + 0.14, w1 = w0 + 0.34, fa = 1;
+ if (t > w1) { const k = MO.backOut(U.clamp((t - w1) / 0.22), 2.2), shr = (1 - MO.cubicIn(U.clamp(dn * 1.4))) * k; if (shr > 0.02) WB.drawPrep(c, FIGH, 1390, 840, shr, 0); }
+ if (t > w0 && fa > 0) {
+ c.save(); c.globalAlpha = fa; c.font = `300px ${WB.FONT}`; c.fillStyle = OR; c.textBaseline = 'alphabetic';
+ const chars = ['轰', '!'], ws = chars.map(ch => c.measureText(ch).width), W0 = ws[0] + ws[1], k = U.clamp((t - w0) / (w1 - w0)) * 2, done = Math.floor(k);
+ let x = 760 - W0 / 2; const y = 560, bump = t > w1 ? 1 + 0.08 * Math.sin(U.clamp((t - w1) / 0.25) * Math.PI) : 1;
+ const shr = 1 - MO.cubicIn(U.clamp(dn * 1.4)); if (shr <= 0.02) { c.restore(); return tip; } c.translate(760, 450); c.scale(bump * shr, bump * shr); c.rotate(-0.05); c.translate(-760, -450);
+ chars.forEach((ch, i) => { if (i < done) c.fillText(ch, x, y); else if (i === done && k < 2) {
+ const so = WB.so(ch, 300, ws[i]);
+ if (so) { const [m, tp] = WB.soAt(so, k - done); c.save(); c.translate(x, y); c.clip(m); c.fillText(ch, 0, 0); c.restore(); const p = c.getTransform().transformPoint(new DOMPoint(x + tp[0], y + tp[1])); tip = [p.x, p.y, OR]; }
+ else { const zz = DG.zigzag(x - 4, y - 290, ws[i] + 8, 350, 3), cm = DG.cum(zz), d = cm[cm.length - 1] * (k - done);
+ c.save(); c.clip(DG.revealMask(zz, cm, d, 190)); c.fillText(ch, x, y); c.restore(); const p0 = DG.pointAt(zz, cm, d), p = c.getTransform().transformPoint(new DOMPoint(p0[0], p0[1])); tip = [p.x, p.y, OR]; } } x += ws[i]; });
+ c.restore();
+ }
+ return tip;
+ });
+ WB.texts.push('轰!');
+ // ---- ③ 2024年10月,筷子夹住助推器 ----
+ const TX = 5200, TH = 720;
+ WB.go(cw1 - 0.1); WB.text('2024年10月', 4190, Y(240), 100, { rate: 11 });
+ WB.go(WB.cur + 0.05); WB.sk(D.tower(TH, 90), TX, G, { speed: 7000, w: 6 });
+ const AY = G - TH + 150, AX0 = TX - 45, AL = 300;
+ const arm = (open) => [[[AX0, AY - 12], [AX0 - AL, AY - 12 - open * 70]], [[AX0, AY + 12], [AX0 - AL, AY + 12 + open * 70]]];
+ WB.go(q('机械臂') - 0.15);
+ const a0 = arm(1), arms = a0.map(p => WB.line(p, { col: OR, w: 11, speed: 2800, smooth: false }));
+ // 筷子
+ WB.go(q('筷子') - 0.1); WB.sk(D.chopsticks(300), 5610, Y(330), { speed: 3400 });
+ WB.sk(D.starship(170, 'booster'), 5746, Y(470), { speed: 6000, w: 4 }); // 筷子尖上夹着一枚小火箭(视觉双关)
+ WB.text('像筷子', 5575, Y(460), 66, { align: 'center', rate: 11 });
+ const tC0 = q('落回来') - 0.55, tC1 = q('夹住') + 0.05, tClose = tC1 - 0.25;
+ arms.forEach(s => (s.until = tC0));
+ const BH = 470, m = BH / 71, BP = WB.prep(D.starship(BH, 'booster'), 6.5), BF = WB.prep([{ p: [[-22, 2], [0, 90], [22, 2]], o: 1, w: 0.9 }], 6.5);
+ const BXc = AX0 - AL * 0.55, yEnd = AY + (71 - 7.6) * m; // 接驳销对准臂
+ WB.custom({ t0: tC0, t1: tC1 + 0.5, bb: [TX - 520, Y(-700), TX + 80, G + 40], draw(g, qq, t) {
+ const op = 1 - MO.backOut(U.clamp((t - tClose) / 0.3), 2.2);
+ const yb = t < tC1 ? U.lerp(Y(-260) + BH, yEnd, 1 - Math.pow(1 - U.clamp((t - tC0) / (tC1 - tC0)), 2.4)) : yEnd;
+ if (t < tC1 + 0.1) WB.drawPrep(g, BF, BXc, yb, 1, 0, (0.7 + 0.3 * Math.sin(t * 41)) * (1 - U.clamp((t - tC1) / 0.1)));
+ WB.drawPrep(g, BP, BXc, yb, 1, 0);
+ g.strokeStyle = OR; g.lineWidth = 11; g.lineCap = 'round';
+ for (const p of arm(Math.max(0.16, op))) { g.beginPath(); g.moveTo(p[0][0], p[0][1]); g.lineTo(p[1][0], p[1][1]); g.stroke(); }
+ if (t > tC1) { const k = U.clamp((t - tC1) / 0.45); if (k < 1) { g.globalAlpha = 1 - k; g.lineWidth = 5; for (let i = 0; i < 6; i++) { const an = i / 6 * Math.PI * 2, r0 = 70 + 50 * k; g.beginPath(); g.moveTo(BXc + Math.cos(an) * r0, AY + Math.sin(an) * r0); g.lineTo(BXc + Math.cos(an) * (r0 + 30), AY + Math.sin(an) * (r0 + 30)); g.stroke(); } } }
+ return null; } });
+ WB.pop('夹住了!', 4480, Y(700), 120, { at: q('夹住') + 0.2, rot: -0.05 });
+ // ---- 相机 ----
+ const T = t0 + TIMING.seg[id].dur, catchBox = [BXc - 120, AY - 120, TX + 80, G + 20];
+ WB.move(t0 - 0.7, t0 + 0.2, 2640, Y(790), 2.4, { ease: MO.sineInOut });
+ WB.shot(tUp0, tUp1 - tUp0, q('星舰'), q('2023年'), { ease: MO.sineInOut, zmax: 1.0 });
+ WB.shot(q('2023年') - 0.1, 0.8, q('星舰'), tL, { zmax: 1.0, add: [[2150, Y(150), 2600, Y(580)]] });
+ const [cx, cy, cz] = WB.fit(cwM, q('像筷子'), { add: [catchBox] });
+ WB.move(cwM - 0.01, cwM + 0.01, cx, cy, cz, { ease: MO.linear, creep: 0 });
+ WB.shot(q('像筷子') - 0.3, 0.7, cwM, q('夹住') - 0.5, { add: [catchBox] });
+ WB.move(q('夹住') - 0.45, q('夹住') + 0.2, BXc - 230, Y(470), 1.42, { ease: MO.cubicInOut }); // 夹住的那一下推近
+});
+SCENES['s10'] = WB.scene;
diff --git a/scripts/engine/reference_films/spacex/spacex_wb/scenes/s11.js b/scripts/engine/reference_films/spacex/spacex_wb/scenes/s11.js
new file mode 100644
index 0000000..4996fc9
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_wb/scenes/s11.js
@@ -0,0 +1,76 @@
+// S11 · 2026(D 行右中段,x 6150–9550)。三拍:
+// ① 「2026年」→ 大圈「SpaceX」→ 箭头「收购」→ 小圈「xAI」(下注「马斯克的AI公司」)→ 小圈被吸进大圈里;
+// ② 相机右移:「6月上市」+一条往上走的橙色折线 →「募资超过」+「750亿美元」砸入 → 奖杯「史上最大的一次上市」;
+// ③ 再右移:「9.28」(和开头那个 9.28 同样画两道橙线)→ 地球、轨道、星舰绕着走,一颗一颗放出 26 颗卫星,「26颗」弹出。
+WB.chapter('s11', id => {
+ const q = k => WB.q(id, k), { OR, INK } = WB, D = WB.D, Y = v => WB.ROW.D + v;
+ const t0 = WB.T0(id);
+ // ---- ① 收购 xAI ----
+ WB.lead([5800, Y(600)], [6270, Y(580)], q('2026年') - 0.12 - 0.62, 0.5); // 引线和相机同时走:笔领着相机,落位那一刻正好开写
+ WB.go(q('2026年') - 0.12); WB.text('2026年', 6210, Y(240), 120, { rate: 10 });
+ const AX = 6490, AY = Y(570), AR = 180, BX = 7010, BR = 100;
+ WB.go(q('SpaceX') - 0.05); WB.line(WB.circ(AX, AY, AR, 1.05), { speed: 4400, w: 7 });
+ WB.text('SpaceX', AX, AY - 30, 72, { align: 'center', rate: 16 });
+ WB.go(q('收购') + 0.05);
+ const arr = WB.arrow([AX + AR + 15, AY], [BX - BR - 15, AY], { head: 26, w: 6 });
+ const lab = WB.text('收购', (AX + AR + BX - BR) / 2, AY - 34, 54, { align: 'center', rate: 12, col: OR });
+ WB.go(q('马斯克') - 0.05);
+ const bc = WB.line(WB.circ(BX, AY, BR, 1.05), { speed: 4400, w: 6 });
+ const lab2 = WB.text('马斯克的AI公司', BX, AY + BR + 70, 46, { align: 'center', rate: 14 });
+ WB.go(q('xAI') + 0.05);
+ const bt = WB.text('xAI', BX, AY + 50, 56, { align: 'center', rate: 12 });
+ const br = WB.sk(D.brain(80), BX, AY - 34, { speed: 4000, w: 5 }); // 一个大脑:AI
+ const tM0 = Math.max(WB.cur + 0.05, q('6月') - 0.1), tM1 = tM0 + 0.55;
+ [bc, bt, ...br].forEach(s => (s.until = tM0)); WB.fade([...arr, lab, lab2], tM0, 0.35);
+ const BCp = WB.prep([{ p: WB.circ(0, 0, BR, 1.05) }], 6), BRp = WB.prep(WB.xf ? D.brain(80).map(k => ({ ...k, p: k.p.map(([x, y]) => [x, y - 34]) })) : [], 5);
+ WB.custom({ t0: tM0, t1: tM1, bb: [AX - 250, AY - 250, BX + 150, AY + 250], draw(g, qq) {
+ const e = MO.backOut(qq, 1.4), x = U.lerp(BX, AX + 10, e), y = U.lerp(AY, AY + 82, e), s = U.lerp(1, 0.42, MO.smooth(qq));
+ WB.drawPrep(g, BCp, x, y, s, 0); WB.drawPrep(g, BRp, x, y, s, 0); g.font = `${56 * s}px ${WB.FONT}`; g.textAlign = 'center'; g.fillStyle = INK; g.fillText('xAI', x, y + 50 * s); return null; } });
+ // ---- ② 6月上市,募资超过750亿美元,史上最大的一次上市 ----
+ WB.go(q('6月') + 0.25); WB.text('6月上市', 7230, Y(250), 92, { rate: 10 });
+ WB.sk(D.bell(260), 7480, Y(520), { speed: 4800 });
+ WB.go(q('募资') + 0.05); WB.text('募资超过', 7850, Y(400), 60, { rate: 12 });
+ WB.pop('750亿美元', 8150, Y(545), 130, { at: q('亿美元') + 0.15 });
+ WB.go(q('史上最大') - 0.05); WB.sk(D.trophy(140), 7410, Y(775), { speed: 4600 }); WB.fill(WB.xf(D.trophy(140)[0].p, 7410, Y(775)), WB.WASH, 0.3);
+ WB.text('史上最大的一次上市', 7520, Y(800), 58, { rate: 11 });
+ // ---- ③ 9月28号,星舰入轨,放出了26颗新一代星链卫星 ----
+ WB.go(q('9月28号') + 0.1); WB.text('9.28', 8710, Y(250), 110, { rate: 12 });
+ WB.line([[8702, Y(276)], [8830, Y(282)], [8950, Y(274)]], { col: OR, w: 7, speed: 4000 }); WB.line([[8710, Y(294)], [8830, Y(300)], [8942, Y(292)]], { col: OR, w: 6, speed: 4500 });
+ // 回扣开头:相机一口气退到能同时看见开头那个 9.28 和这个 9.28,两个各画一个橙圈,中间牵一条橙色点线(随后淡掉,圈留着)
+ // 回扣停多久跟着口播走:「星舰入轨」前留出的气口越长,拉远停得越久(最多 1.7s)
+ const tBack = WB.cur + 0.02, tRet = Math.max(tBack + 0.95, Math.min(tBack + 1.7, q('星舰入轨') - 0.5)), R1 = [2955, 648, 240, 104], R2 = [8830, Y(212), 200, 100];
+ [R1, R2].forEach(([x, y, rx, ry], i) => WB.line(WB.ell(x, y, rx, ry, -2.4, 1.06, -0.05, 48), { col: OR, w: 18, t0: tBack + 0.3 + i * 0.14, dur: 0.3, handed: false, nofit: true }));
+ const link = WB.line(WB.quad([R1[0] + 250, R1[1] + 40], [6800, 1200], [R2[0] - 210, R2[1] - 20], 40), { col: OR, w: 18, dash: [1, 34], t0: tBack + 0.5, dur: 0.35, handed: false, nofit: true });
+ WB.fade([link], tRet - 0.05, 0.4);
+ const EX = 9130, EY = Y(600), ER = 160, RX = 360, RY = 116, ROT = -0.12;
+ WB.go(Math.max(q('星舰入轨') - 0.05, tRet + 0.35)); WB.sk(D.earth(ER), EX, EY, { speed: 5850 });
+ WB.line(WB.ell(EX, EY, RX, RY, Math.PI * 0.9, 1.03, ROT, 64), { col: OR, w: 4.5, speed: 7850 });
+ WB.text('星舰入轨', 9070, Y(250), 66, { rate: 12, col: OR });
+ const SP = WB.prep(D.starship(250, 'ship'), 6.5);
+ const tS = WB.cur, tR0 = q('放出') - 0.05, tR1 = tR0 + 1.6, W0 = Math.PI * 0.95, SPD = 1.15, SPD2 = 2.1;
+ const pos = (w, f = 1) => { const X0 = Math.cos(w) * RX * f, Y0 = Math.sin(w) * RY * f, c = Math.cos(ROT), n = Math.sin(ROT); return [EX + X0 * c - Y0 * n, EY + X0 * n + Y0 * c]; };
+ WB.custom({ t0: tS, t1: tS + 0.3, bb: [EX - 420, EY - 300, EX + 420, EY + 300], draw(g, qq, t) {
+ const wAt = tt => W0 + (Math.min(tt, tR0) - tS) * SPD + U.clamp(tt - tR0, 0, tR1 - tR0) * SPD2 + Math.max(0, tt - tR1) * SPD, w = wAt(t); // 放卫星时船走得快一点,卫星才排得开
+ // 卫星:放出时刻 ti 时在船的位置,之后沿同一轨道稍慢地走、往外散一点
+ // 26 颗卫星:在船经过的位置一颗颗放出,然后沿径向慢慢往外散开(一串小珠子:黑点+两片橙色小太阳翼)
+ g.lineCap = 'round';
+ for (let i = 0; i < 26; i++) { const ti = tR0 + (tR1 - tR0) * i / 25; if (t < ti) break;
+ const u = MO.cubicOut(U.clamp((t - ti) / 1.2)), wi = wAt(ti) - 0.06, [x, y] = pos(wi, 1 + 0.32 * u), k = MO.backOut(U.clamp((t - ti) / 0.16), 2.2);
+ if (Math.sin(wi) < -0.2 && Math.hypot(x - EX, y - EY) < ER + 8) continue;
+ g.fillStyle = INK; g.fillRect(x - 5 * k, y - 4.5 * k, 10 * k, 9 * k);
+ g.fillStyle = OR; g.fillRect(x - 16 * k, y - 2.5 * k, 9 * k, 5 * k); g.fillRect(x + 7 * k, y - 2.5 * k, 9 * k, 5 * k); }
+ const [x, y] = pos(w), a = Math.atan2(Math.cos(w) * RY, -Math.sin(w) * RX) + ROT + Math.PI / 2;
+ if (Math.sin(w) < -0.15) { g.beginPath(); g.rect(-1e5, -1e5, 2e5, 2e5); g.arc(EX, EY, ER + 4, 0, Math.PI * 2, true); g.clip(); }
+ WB.drawPrep(g, SP, x, y, 1, a, MO.smooth(qq)); return null; } });
+ WB.pop('26颗', 9800, Y(380), 110, { at: q('26颗') + 0.3 });
+ WB.go(q('新一代') + 0.05); WB.text('新一代星链卫星', 9800, Y(480), 54, { align: 'center', rate: 14 });
+ // ---- 相机 ----
+ const T = t0 + TIMING.seg[id].dur;
+ WB.shot(q('2026年') - 0.12 - 0.62, 0.6, t0, q('6月'), { zmax: 1.2 });
+ WB.shot(q('6月') - 0.05, 0.75, q('6月'), q('9月28号'), { zmax: 1.15, add: [[7820, Y(380), 8480, Y(560)]] }); // 上市这一拍一个中景到底,不再特写→拉远
+ WB.shot(q('9月28号') - 0.15, 0.55, q('9月28号'), q('9月28号') + 0.3, { zmax: 1.2, add: [[8660, Y(120), 9220, Y(330)]] });
+ const [bx, by, bz] = WB.fit(0, 0, { add: [[R1[0] - 300, R1[1] - 200, R1[0] + 300, R1[1] + 160], [R2[0] - 260, R2[1] - 160, R2[0] + 260, R2[1] + 160]], pad: 120, sy: 450 });
+ WB.move(tBack - 0.02, tBack + 0.55, bx, by, bz, { ease: MO.cubicInOut });
+ WB.shot(tRet, 0.55, q('9月28号'), T, { zmax: 1.15, ease: MO.cubicInOut, add: [[EX - RX - 60, EY - RY - 60, EX + RX + 60, EY + RY + 60], [9660, Y(270), 9980, Y(500)]] });
+});
+SCENES['s11'] = WB.scene;
diff --git a/scripts/engine/reference_films/spacex/spacex_wb/scenes/s12.js b/scripts/engine/reference_films/spacex/spacex_wb/scenes/s12.js
new file mode 100644
index 0000000..31616ba
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/spacex_wb/scenes/s12.js
@@ -0,0 +1,66 @@
+// S12 · 接下来(D 行末段,x 10410–12610)+全片收尾。还没发生的事一律画成虚线(白板上「计划」的写法):
+// 「接下来」→ 虚线发射塔用两只橙臂夹住一艘虚线飞船 → 两艘飞船尾对尾、中间一滴橙色燃料「加油」→ 虚线弧飞向月球,月面上一艘小船和一个戴头盔的小人;
+// 相机右移「再往后」→ 火星:橙色排线+插着 S02 那座小房子,「火星」弹出。
+// 最后相机一口气拉到最远,整块白板 24 年的笔记一次看全;一支小火箭沿一条长长的橙色虚线,从 S02 那颗「别的星球」一路飞到火星。
+WB.chapter('s12', id => {
+ const q = k => WB.q(id, k), { OR, INK } = WB, D = WB.D, Y = v => WB.ROW.D + v;
+ const t0 = WB.T0(id), G = Y(880), DASH = [18, 14];
+ const dashed = (arr, d = DASH) => arr.map(k => k.fillPts ? k : { ...k, dash: d });
+ // ---- 接下来,它要用筷子夹住飞船 ----
+ WB.lead([10040, Y(620)], [10410, Y(300)], q('接下来') - 0.12 - 0.62, 0.5); // 引线和相机同时走:笔领着相机,落位那一刻正好开写
+ WB.go(q('接下来') - 0.12); WB.text('接下来', 10430, Y(240), 104, { rate: 9 });
+ WB.arrow([10770, Y(205)], [10940, Y(205)], { col: OR, head: 24, w: 6 });
+ const TX = 10710, TH = 600;
+ WB.go(q('筷子') - 0.25); WB.line([[10510, G], [11010, G]], { speed: 8300, w: 6 });
+ WB.sk(D.tower(TH, 80), TX, G, { speed: 8300, w: 5.5 });
+ const AY = G - TH + 160;
+ WB.line([[TX + 40, AY - 12], [TX + 300, AY - 30]], { col: OR, w: 10, speed: 3600, smooth: false, dash: [24, 14] });
+ WB.line([[TX + 40, AY + 12], [TX + 300, AY + 30]], { col: OR, w: 10, speed: 3600, smooth: false, dash: [24, 14] });
+ const SH = 380, m = SH / 52;
+ WB.go(q('飞船') - 0.1); WB.sk(dashed(D.starship(SH, 'ship', { flap: 0.2 })), TX + 190, AY + (52 - 30) * m, { speed: 6300, w: 5.5 });
+ // ---- 在太空里加油 ----
+ WB.go(q('在太空') - 0.05);
+ const RY0 = Y(330), RS = 210;
+ WB.sk(dashed(D.starship(RS, 'ship')), 11270, RY0, { rot: -Math.PI / 2, speed: 10710, w: 5 });
+ WB.sk(dashed(D.starship(RS, 'ship')), 11380, RY0, { rot: Math.PI / 2, speed: 10710, w: 5 });
+ WB.sk(D.drop(70), 11325, RY0, { speed: 4000 });
+ WB.text('加油', 11325, RY0 + 130, 62, { align: 'center', rate: 12, col: OR });
+ // ---- 争取把美国人重新送上月球 ----
+ const MX = 11960, MY = Y(470), MR = 150;
+ WB.go(q('美国人') - 0.05); WB.sk(D.moon(MR), MX, MY, { speed: 5300 });
+ WB.line(WB.quad([11590, RY0 - 40], [11810, Y(160)], [MX - 40, MY - MR - 10], 26), { col: OR, w: 5, dash: [14, 12], speed: 5300, smooth: false });
+ WB.go(q('送上') - 0.15);
+ WB.sk(dashed(D.starship(110, 'ship')), MX + 20, MY - MR + 4, { speed: 7300, w: 4.5 });
+ WB.sk(dashed(D.fig(64, 'wave', { helmet: true }), [5, 9]), MX - 50, MY - MR + 8, { speed: 5300, w: 4.5 });
+ WB.go(q('月球') + 0.05); WB.text('月球', MX, MY + MR + 80, 66, { align: 'center', rate: 10 });
+ // ---- 再往后,是火星:相机一边往后拉到全板,笔一边在板的最右端画一颗很大的火星(橙色排线+S02 那座小房子,虚线=还没发生)----
+ const FX = MX + 780, FY = Y(500), FR = 400;
+ const tOut0 = q('再往后') + 0.05, tOut1 = tOut0 + 1.75;
+ WB.go(q('再往后') + 0.15); WB.line(WB.circ(FX, FY, FR, 1.04, Math.PI), { w: 12, speed: 6500 });
+ WB.hatchCircle(FX, FY, FR, { gap: 40, ang: -Math.PI / 4, w: 8, speed: WB.SPEED * 9 });
+ WB.sk(dashed(D.house(240), [30, 22]).map(k => ({ ...k, w: 1.8 })), FX, FY - FR + 14, { speed: 7000 });
+ WB.go(q('火星') - 0.1); WB.pop('火星', FX + FR + 60, FY + 70, 230, { align: 'left', wdur: 0.32 });
+ // ---- 收尾:一条橙色虚线从 S02 的「别的星球」一路飞到火星;然后全板定格 ----
+ const A0 = [6840, 430], C0 = [14010, 700], B0 = [FX + 20, FY - FR - 260];
+ const bz = u => [(1 - u) ** 2 * A0[0] + 2 * u * (1 - u) * C0[0] + u * u * B0[0], (1 - u) ** 2 * A0[1] + 2 * u * (1 - u) * C0[1] + u * u * B0[1]];
+ const path = []; for (let i = 0; i <= 80; i++) path.push(bz(i / 80)); const pc = DG.cum(path), PL = pc[pc.length - 1];
+ const RK1 = WB.prep([{ p: [[0, -38], [10, -28], [14, 4], [14, 22], [-14, 22], [-14, 4], [-10, -28], [0, -38]] }, { p: [[-14, 8], [-26, 26], [-14, 22]] }, { p: [[14, 8], [26, 26], [14, 22]] }], 5);
+ const tF0 = tOut0 + 1.0, tF1 = tF0 + 1.25;
+ WB.custom({ t0: tF0, t1: tF1, bb: null, draw(g, qq, t) {
+ const e = MO.sineInOut(qq), d = PL * e;
+ g.strokeStyle = OR; g.lineWidth = 26; g.setLineDash([70, 52]); DG.drawPartial(g, path, pc, Math.max(0, d - 60)); g.setLineDash([]);
+ const [x, y] = DG.pointAt(path, pc, d), [x2, y2] = DG.pointAt(path, pc, Math.min(PL, d + 4)), a = Math.atan2(y2 - y, x2 - x) || 0.3;
+ if (qq < 1) { g.translate(x, y); g.rotate(a + Math.PI / 2); g.scale(5, 5); g.fillStyle = OR; g.beginPath(); g.moveTo(-8, 26); g.lineTo(0, 46 + 6 * Math.sin(t * 40)); g.lineTo(8, 26); g.closePath(); g.fill(); WB.drawPrep(g, RK1, 0, 0, 1, 0); }
+ else { g.strokeStyle = OR; g.lineWidth = 26; g.lineCap = 'round'; g.beginPath(); g.moveTo(x - Math.cos(a - 0.5) * 140, y - Math.sin(a - 0.5) * 140); g.lineTo(x, y); g.lineTo(x - Math.cos(a + 0.5) * 140, y - Math.sin(a + 0.5) * 140); g.stroke(); }
+ return null; } });
+ // ---- 相机 ----
+ const T = t0 + TIMING.seg[id].dur;
+ WB.shot(q('接下来') - 0.12 - 0.62, 0.6, t0, q('美国人'), { zmax: 1.15 });
+ WB.shot(q('美国人') - 0.3, 0.8, q('加油') - 0.4, q('再往后'), { zmax: 1.15 });
+ const [cx, cy, zF] = WB.fit(-10, T, { zmax: 0.3, pad: 90, sy: 520, add: [[A0[0], A0[1], 13660, B0[1]], [FX + FR, FY - 100, FX + FR + 560, FY + 120]] });
+ WB.move(tOut0, tOut1, cx, cy, zF, { ease: MO.sineInOut });
+ // 全板定格,最后一秒往火星轻推 6%(火星在画面上的位置不动)
+ const ms = CAM.toScreen({ x: cx, y: cy, z: zF }, FX, FY), fin = CAM.anchor(FX, FY, zF * 1.06, ms[0], ms[1]);
+ WB.move(Math.max(tOut1 + 0.05, T - 1.15), T, fin.x, fin.y, fin.z, { ease: MO.sineInOut, creep: 0 });
+});
+SCENES['s12'] = WB.scene;
diff --git a/scripts/engine/reference_films/spacex/transitions/cardFlip.js b/scripts/engine/reference_films/spacex/transitions/cardFlip.js
new file mode 100644
index 0000000..93a219c
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/transitions/cardFlip.js
@@ -0,0 +1,33 @@
+// 卡片翻面(S10 浮世绘 → S11讲解员式财经讲解):上一段整幅画退远成一张纸卡,绕竖轴翻过去,
+// 背面就是米白信息页,翻完卡片回到满屏。透视按竖条切片:每条按深度(相机距离 d)缩放高度,过 90° 换面。
+// 参数:o.bg 翻卡时露出的底色(默认 S11 的米白)。p=0 与旧画面、p=1 与新画面逐像素一致。
+(() => {
+const W = 1920, H = 1080;
+TRANSITIONS.cardFlip = (c, A, B, p, o) => {
+ const e = MO.cubicInOut(U.clamp(p)), ang = e * Math.PI;
+ const s = 1 - 0.24 * Math.sin(Math.PI * e); // 翻的时候卡片退远
+ const front = ang < Math.PI / 2, img = front ? A : B, a = front ? ang : ang - Math.PI;
+ const cs = Math.cos(a), sn = Math.sin(a), d = 2600, N = 120, sw = W / N;
+ c.fillStyle = o.bg || '#F7F0E1'; c.fillRect(0, 0, W, H);
+ const proj = u => { const f = d / (d + u * sn); return [W / 2 + u * cs * f * s, f]; };
+ const [xl, fl] = proj(-W / 2), [xr, fr] = proj(W / 2);
+ const k = Math.sin(Math.PI * e); // 卡片边、影子只在翻的过程中出现
+ if (k < 0.002) { c.drawImage(img, 0, 0); return; } // 两端不切片,免得重采样发虚
+ if (k > 0.001) { // 落在纸面上的软影
+ c.save(); c.globalAlpha = 0.16 * k; c.fillStyle = '#2B2A33';
+ c.beginPath(); c.moveTo(xl + 14, H / 2 - H * fl * s / 2 + 22); c.lineTo(xr + 14, H / 2 - H * fr * s / 2 + 22);
+ c.lineTo(xr + 14, H / 2 + H * fr * s / 2 + 22); c.lineTo(xl + 14, H / 2 + H * fl * s / 2 + 22); c.closePath(); c.fill(); c.restore();
+ }
+ for (let i = 0; i < N; i++) {
+ const [x0, f0] = proj(-W / 2 + i * sw), [x1, f1] = proj(-W / 2 + (i + 1) * sw);
+ const h = H * (f0 + f1) / 2 * s, lo = Math.min(x0, x1), w = Math.abs(x1 - x0) + 0.8;
+ if (w < 0.85) continue;
+ c.drawImage(img, i * sw, 0, sw, H, lo, H / 2 - h / 2, w, h);
+ }
+ if (k > 0.001) { // 纸卡描边(扁平信息图的深色线)
+ c.save(); c.globalAlpha = k; c.strokeStyle = '#2B2A33'; c.lineWidth = 5; c.lineJoin = 'round';
+ c.beginPath(); c.moveTo(xl, H / 2 - H * fl * s / 2); c.lineTo(xr, H / 2 - H * fr * s / 2);
+ c.lineTo(xr, H / 2 + H * fr * s / 2); c.lineTo(xl, H / 2 + H * fl * s / 2); c.closePath(); c.stroke(); c.restore();
+ }
+};
+})();
diff --git a/scripts/engine/reference_films/spacex/transitions/deskPullOut.js b/scripts/engine/reference_films/spacex/transitions/deskPullOut.js
new file mode 100644
index 0000000..3f852ea
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/transitions/deskPullOut.js
@@ -0,0 +1,4 @@
+// S03 → S04 进入转场(Vox「从单张照片拉出 → 露出整面拼贴」):
+// 旧画面原地变成桌上一张网点照片——p=0 时照片内框正好铺满画面(= 旧画面原样),相机长尾拉出,桌面、剪报、红线露出来;
+// 旧画面逐帧过 45° 网点、叠旧纸色,p=1 时与 s04 段内缓存的那张照片逐像素一致。相机与网点都在 spacex/scenes/s04.js(S04X)。
+TRANSITIONS.deskPullOut = (c, A, B, p, o) => { c.drawImage(B, 0, 0); S04X.photoLive(c, A, o.lt, p); };
diff --git a/scripts/engine/reference_films/spacex/transitions/kzBloom.js b/scripts/engine/reference_films/spacex/transitions/kzBloom.js
new file mode 100644
index 0000000..0bf6c09
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/transitions/kzBloom.js
@@ -0,0 +1,23 @@
+// 【Kurzgesagt】kzBloom 光铺满画面:一团暖光(辉光芯 #F9EF93)从 (o.cx, o.cy) 长大,前半程铺满成白场,后半程退开,新世界从 1.1 倍落回 1。
+// Kurzgesagt 的转场 4「用画面里的光源做白场,约 0.5s」;用在从别的风格进入 Kurzgesagt 段:光一退,就是深靛底上的发光世界。
+TRANSITIONS.kzBloom = (c, A, B, p, o) => {
+ const W = o.W || 1920, H = o.H || 1080, cx = o.cx ?? W / 2, cy = o.cy ?? H / 2, k = o.peak ?? 0.48;
+ const veil = (a) => { if (a <= 0) return; c.save(); c.globalAlpha = Math.min(1, a); c.fillStyle = '#FFF8DC'; c.fillRect(0, 0, W, H); c.restore(); };
+ if (p < k) {
+ const q = p / k, s = 1 + 0.06 * q * q;
+ c.save(); c.translate(cx, cy); c.scale(s, s); c.translate(-cx, -cy); c.drawImage(A, 0, 0); c.restore();
+ const r = 40 + Math.pow(q, 2.1) * 2500;
+ const g = c.createRadialGradient(cx, cy, 0, cx, cy, r);
+ g.addColorStop(0, 'rgba(255,253,240,0.85)'); g.addColorStop(0.3, 'rgba(249,239,147,0.7)'); g.addColorStop(0.62, 'rgba(250,204,18,0.55)'); g.addColorStop(1, 'rgba(244,131,1,0)');
+ c.fillStyle = g; c.fillRect(0, 0, W, H);
+ veil(MO.smooth(Math.max(0, (q - 0.55) / 0.45)) * 0.5); // 白场上限 0.95→0.5:前后都是深色,满屏闪白太刺眼
+ } else {
+ const q = (p - k) / (1 - k), e = MO.k75(q), s = 1.1 - 0.1 * e;
+ c.save(); c.translate(cx, cy); c.scale(s, s); c.translate(-cx, -cy); c.drawImage(B, 0, 0); c.restore();
+ const r = 2600 * (1 - e) + 60;
+ const g = c.createRadialGradient(cx, cy, 0, cx, cy, r);
+ g.addColorStop(0, `rgba(255,253,240,${0.9 * (1 - e)})`); g.addColorStop(0.5, `rgba(249,239,147,${0.6 * (1 - e)})`); g.addColorStop(1, 'rgba(250,204,18,0)');
+ c.fillStyle = g; c.fillRect(0, 0, W, H);
+ veil(Math.pow(1 - q, 2.2) * 0.5);
+ }
+};
diff --git a/scripts/engine/reference_films/spacex/transitions/lin_page.js b/scripts/engine/reference_films/spacex/transitions/lin_page.js
new file mode 100644
index 0000000..82a9ed9
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/transitions/lin_page.js
@@ -0,0 +1,81 @@
+// 讲解员版(lin)的翻页转场:讲解员和顶栏画在全片叠加层,不参与转场——换的只是「这一页」。
+// 一个文件注册四种(eras_lin.js 的 SCENE_LIBS 里先加载它):
+// lin_page = lin_slide 的别名(按文件名自动加载的入口)
+// lin_slide 整页推走:o.dir 'left'(默认)/ 'up' / 'right';新页边缘带一条纸卡投影
+// lin_iris 圆形扩张揭开:o.x, o.y 圆心(画面坐标),o.col 圆边彩带色
+// lin_wipe 斜向彩色色带扫过:o.cols 色带颜色(2–3 条),o.dir 1 从左往右 / -1 从右往左
+// lin_flip 纸卡绕竖轴翻面(退远→翻→回满屏),o.bg 翻卡时露出的底色
+// p=0 与旧画面、p=1 与新画面逐像素一致。
+(() => {
+const W = 1920, H = 1080, INK = '#2B2A33';
+const cl = x => Math.max(0, Math.min(1, x));
+const ease = p => p < .5 ? 4 * p * p * p : 1 - Math.pow(-2 * p + 2, 3) / 2;
+
+TRANSITIONS.lin_slide = (c, A, B, p, o) => {
+ if (p <= 0) { c.drawImage(A, 0, 0); return; } if (p >= 1) { c.drawImage(B, 0, 0); return; }
+ const e = ease(cl(p)), dir = o.dir || 'left';
+ const [dx, dy] = dir === 'up' ? [0, -H] : dir === 'right' ? [W, 0] : [-W, 0];
+ const ax = dx * e, ay = dy * e, bx = ax - dx, by = ay - dy;
+ c.drawImage(A, ax, ay);
+ c.save(); c.fillStyle = 'rgba(43,42,51,0.16)'; // 新页压在旧页上的投影
+ if (dir === 'up') c.fillRect(0, by - 14, W, 14); else if (dir === 'right') c.fillRect(bx + W, 0, 18, H); else c.fillRect(bx - 18, 0, 18, H);
+ c.restore();
+ c.drawImage(B, bx, by);
+};
+TRANSITIONS.lin_page = TRANSITIONS.lin_slide;
+
+TRANSITIONS.lin_iris = (c, A, B, p, o) => {
+ if (p <= 0) { c.drawImage(A, 0, 0); return; } if (p >= 1) { c.drawImage(B, 0, 0); return; }
+ const x = o.x ?? W / 2, y = o.y ?? H / 2, Rmax = Math.hypot(Math.max(x, W - x), Math.max(y, H - y)) + 60;
+ const e = p < 0.5 ? 0.5 * Math.pow(2 * p, 2.2) : 1 - 0.5 * Math.pow(2 - 2 * p, 1.6), R = Rmax * e, band = 34 * (1 - e * 0.4);
+ c.drawImage(A, 0, 0);
+ c.save(); c.beginPath(); c.arc(x, y, R, 0, Math.PI * 2); c.clip(); c.drawImage(B, 0, 0); c.restore();
+ c.save(); c.lineWidth = band; c.strokeStyle = o.col || '#FFD447'; c.beginPath(); c.arc(x, y, R + band / 2, 0, Math.PI * 2); c.stroke();
+ c.lineWidth = 5; c.strokeStyle = INK; c.beginPath(); c.arc(x, y, R, 0, Math.PI * 2); c.stroke(); c.beginPath(); c.arc(x, y, R + band, 0, Math.PI * 2); c.stroke(); c.restore();
+};
+
+TRANSITIONS.lin_wipe = (c, A, B, p, o) => {
+ if (p <= 0) { c.drawImage(A, 0, 0); return; } if (p >= 1) { c.drawImage(B, 0, 0); return; }
+ const cols = o.cols || ['#FFD447', '#4C8DF6'], d = o.dir || 1, sl = 420, bw = 150, n = cols.length;
+ const span = W + sl + bw * n + 40, e = ease(cl(p)), lead = -sl - bw * n + span * e; // 最前一条色带的左边(从左往右)
+ const quad = (x0, x1) => { c.beginPath(); c.moveTo(x0 + sl, 0); c.lineTo(x1 + sl, 0); c.lineTo(x1, H); c.lineTo(x0, H); c.closePath(); };
+ const flip = d < 0;
+ c.save(); if (flip) { c.translate(W, 0); c.scale(-1, 1); }
+ // 新页:色带后面
+ c.save(); c.beginPath(); c.moveTo(-sl - 10, 0); c.lineTo(lead + sl, 0); c.lineTo(lead, H); c.lineTo(-sl - 10, H); c.closePath(); c.clip();
+ if (flip) { c.translate(W, 0); c.scale(-1, 1); } c.drawImage(B, 0, 0); c.restore();
+ c.save(); c.beginPath(); c.moveTo(lead + bw * n + sl, 0); c.lineTo(W + sl + 10, 0); c.lineTo(W + sl + 10, H); c.lineTo(lead + bw * n, H); c.closePath(); c.clip();
+ if (flip) { c.translate(W, 0); c.scale(-1, 1); } c.drawImage(A, 0, 0); c.restore();
+ for (let i = 0; i < n; i++) { const x0 = lead + i * bw; quad(x0, x0 + bw); c.fillStyle = cols[n - 1 - i]; c.fill(); c.lineWidth = 5; c.strokeStyle = INK; c.stroke(); }
+ c.restore();
+};
+
+// lin_zoom 推镜穿过:旧页以 (o.x,o.y) 为中心放大淡出,新页从 0.86 倍放大到满屏淡入(讲解员与顶栏不动)
+TRANSITIONS.lin_zoom = (c, A, B, p, o) => {
+ if (p <= 0) { c.drawImage(A, 0, 0); return; } if (p >= 1) { c.drawImage(B, 0, 0); return; }
+ const e = ease(cl(p)), x = o.x ?? W / 2, y = o.y ?? H / 2;
+ c.fillStyle = o.bg || '#F8F2E6'; c.fillRect(0, 0, W, H);
+ const za = 1 + 2.2 * e, zb = 0.86 + 0.14 * e;
+ c.save(); c.globalAlpha = 1 - cl(e * 1.6); c.translate(x, y); c.scale(za, za); c.translate(-x, -y); c.drawImage(A, 0, 0); c.restore();
+ c.save(); c.globalAlpha = cl((e - 0.25) / 0.6); c.translate(W / 2, H / 2); c.scale(zb, zb); c.translate(-W / 2, -H / 2); c.drawImage(B, 0, 0); c.restore();
+};
+TRANSITIONS.lin_flip = (c, A, B, p, o) => {
+ if (p <= 0) { c.drawImage(A, 0, 0); return; } if (p >= 1) { c.drawImage(B, 0, 0); return; }
+ const e = ease(cl(p)), ang = e * Math.PI, s = 1 - 0.24 * Math.sin(Math.PI * e);
+ const front = ang < Math.PI / 2, img = front ? A : B, a = front ? ang : ang - Math.PI;
+ const cs = Math.cos(a), sn = Math.sin(a), dist = 2600, N = 120, sw = W / N;
+ c.fillStyle = o.bg || '#F8F2E6'; c.fillRect(0, 0, W, H);
+ const proj = u => { const f = dist / (dist + u * sn); return [W / 2 + u * cs * f * s, f]; };
+ const [xl, fl] = proj(-W / 2), [xr, fr] = proj(W / 2), k = Math.sin(Math.PI * e);
+ c.save(); c.globalAlpha = 0.16 * k; c.fillStyle = INK;
+ c.beginPath(); c.moveTo(xl + 14, H / 2 - H * fl * s / 2 + 22); c.lineTo(xr + 14, H / 2 - H * fr * s / 2 + 22); c.lineTo(xr + 14, H / 2 + H * fr * s / 2 + 22); c.lineTo(xl + 14, H / 2 + H * fl * s / 2 + 22); c.closePath(); c.fill(); c.restore();
+ for (let i = 0; i < N; i++) {
+ const [x0, f0] = proj(-W / 2 + i * sw), [x1, f1] = proj(-W / 2 + (i + 1) * sw);
+ const h = H * (f0 + f1) / 2 * s, lo = Math.min(x0, x1), w = Math.abs(x1 - x0) + 0.8;
+ if (w < 0.85) continue;
+ c.drawImage(img, i * sw, 0, sw, H, lo, H / 2 - h / 2, w, h);
+ }
+ c.save(); c.globalAlpha = k; c.strokeStyle = INK; c.lineWidth = 5; c.lineJoin = 'round';
+ c.beginPath(); c.moveTo(xl, H / 2 - H * fl * s / 2); c.lineTo(xr, H / 2 - H * fr * s / 2); c.lineTo(xr, H / 2 + H * fr * s / 2); c.lineTo(xl, H / 2 + H * fl * s / 2); c.closePath(); c.stroke(); c.restore();
+};
+})();
diff --git a/scripts/engine/reference_films/spacex/transitions/paperSlide.js b/scripts/engine/reference_films/spacex/transitions/paperSlide.js
new file mode 100644
index 0000000..ac12cad
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/transitions/paperSlide.js
@@ -0,0 +1,15 @@
+// paperSlide 白纸推入:一张白板纸从右边滑进来盖住上一页(带左缘投影、微微回正的 1.2° 倾角),纸到位=白板段开始。
+// 给「色块页 → 白板手绘」用:白板的签名是「一张白纸」,所以转场就是纸本身进场。揭开点 ≈ p 0.6(纸盖住 90%)。
+(() => {
+const { clamp } = U;
+TRANSITIONS.paperSlide = (c, A, B, p, o) => {
+ const W = o.W, H = o.H, e = MO.cubicInOut(clamp(p)), x = W * (1 - e) * 1.03, rot = 0.021 * (1 - e);
+ c.drawImage(A, 0, 0);
+ c.fillStyle = `rgba(0,0,0,${0.18 * e})`; c.fillRect(0, 0, W, H); // 旧页被纸盖住前稍微压暗
+ c.save(); c.translate(x, 0); c.rotate(rot);
+ const g = c.createLinearGradient(-60, 0, 0, 0); g.addColorStop(0, 'rgba(0,0,0,0)'); g.addColorStop(1, 'rgba(0,0,0,.28)');
+ c.fillStyle = g; c.fillRect(-60, -40, 60, H + 80); // 纸的左缘投影
+ c.drawImage(B, 0, 0); c.fillStyle = '#FBFBFB'; c.fillRect(0, H, W, 80); c.fillRect(0, -80, W, 80); // 倾斜时上下补纸边
+ c.restore();
+};
+})();
diff --git a/scripts/engine/reference_films/spacex/transitions/vox_pull.js b/scripts/engine/reference_films/spacex/transitions/vox_pull.js
new file mode 100644
index 0000000..b7580da
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/transitions/vox_pull.js
@@ -0,0 +1,7 @@
+// Vox 拼贴桌面(vox 片)的「抽纸」:上一镜像一张纸被抽走,带倾斜滑出画外,露出压在下面的下一镜(12fps 步进)。
+TRANSITIONS.vox_pull = (c, A, B, p, o) => {
+ const n = Math.max(1, Math.round(o.dur * 12)), q = Math.floor(p * n + 1e-6) / n, e = MO.cubicIn(q), W = o.W, H = o.H;
+ c.drawImage(B, 0, 0);
+ c.save(); c.translate(W / 2 - e * W * 1.12, H / 2 - e * 90); c.rotate(-e * 0.14);
+ c.shadowColor = 'rgba(40,30,20,.45)'; c.shadowBlur = 10 + 30 * e; c.shadowOffsetX = 12; c.shadowOffsetY = 18; c.drawImage(A, -W / 2, -H / 2); c.restore();
+};
diff --git a/scripts/engine/reference_films/spacex/transitions/vox_slap.js b/scripts/engine/reference_films/spacex/transitions/vox_slap.js
new file mode 100644
index 0000000..c4c128a
--- /dev/null
+++ b/scripts/engine/reference_films/spacex/transitions/vox_slap.js
@@ -0,0 +1,8 @@
+// Vox 拼贴桌面(vox 片)的「盖纸」:下一张卡像一张新纸被拍到桌上,带倾斜从画外滑进来、到位放平,盖住上一镜(12fps 步进)。
+TRANSITIONS.vox_slap = (c, A, B, p, o) => {
+ const n = Math.max(1, Math.round(o.dur * 12)), q = Math.floor(p * n + 1e-6) / n, e = MO.quartOut(q), W = o.W, H = o.H;
+ c.drawImage(A, 0, 0);
+ c.save(); c.fillStyle = `rgba(30,20,10,${0.18 * e})`; c.fillRect(0, 0, W, H); c.restore();
+ c.save(); c.translate(W / 2 + (1 - e) * W * 1.08, H / 2 + (1 - e) * 120); c.rotate((1 - e) * 0.16); const s = 1 + 0.03 * (1 - e); c.scale(s, s);
+ c.shadowColor = 'rgba(40,30,20,.45)'; c.shadowBlur = 40 * (1 - e) + 6; c.shadowOffsetX = 10; c.shadowOffsetY = 18; c.drawImage(B, -W / 2, -H / 2); c.restore();
+};
diff --git a/scripts/engine/render.py b/scripts/engine/render.py
new file mode 100644
index 0000000..2ff8a54
--- /dev/null
+++ b/scripts/engine/render.py
@@ -0,0 +1,107 @@
+#!/usr/bin/env python3
+"""逐帧渲染:起本地 http 服务 → 无头 Chromium 打开 index.html → 对每帧调用 window.renderFrame(t)
+→ 读 canvas 像素 → 管道送 ffmpeg 出 60fps mp4,最后混入音轨。
+
+uv run --with playwright python render.py --out ../成片/复刻_v1.mp4 [--audio ../音频/复刻音轨.wav] [--from 0 --to 片长] [--fps 60]
+ [--film gallery](读 eras_gallery.js)[--solo <id> --stills 0.2,0.6 --no-counter]
+uv run --with playwright python render.py --spec clip.json --out 片段.mp4 [--alpha] [--stills 0.5,2]
+ 参数化片段(口播管线的「动画段」,契约见 references/09):时长严格 = spec.duration(帧数 round(duration×fps)),
+ 宽高/fps 从 spec 读;默认无声 H.264 yuv420p、每秒一个关键帧(GOP=fps,管线渲染器按秒 seek),--alpha 出 ProRes 4444 带透明(.mov)。spec 里图片路径相对 spec 文件。
+页面里有 pageerror 或 console.error(场景报错、缺字形)→ 渲完后非零退出。
+"""
+import argparse, base64, http.server, json, socketserver, subprocess, threading, functools, time, urllib.parse
+from pathlib import Path
+from playwright.sync_api import sync_playwright
+
+ap = argparse.ArgumentParser()
+ap.add_argument('--out', required=True)
+ap.add_argument('--audio')
+ap.add_argument('--fps', type=int, default=60)
+ap.add_argument('--from', dest='t0', type=float, default=0)
+ap.add_argument('--to', dest='t1', type=float, default=None, help='默认 = 段落表算出的片长 window.__total')
+ap.add_argument('--stills', help='逗号分隔秒数:只导出这些时刻的 png 到 --out 目录')
+ap.add_argument('--solo', help='只渲某个时代(时间为本段局部时间),配合 --stills 或 --from/--to')
+ap.add_argument('--film', default='', help='片子名:读 eras_<名>.js(默认 eras.js)')
+ap.add_argument('--no-counter', action='store_true', help='--solo 时不画角标')
+ap.add_argument('--crf', type=int, default=14)
+ap.add_argument('--spec', help='参数化片段 spec.json(走 clip.html,不读段落表)')
+ap.add_argument('--alpha', action='store_true', help='--spec 时出 ProRes 4444 带透明(背景不画)')
+a = ap.parse_args()
+
+root = Path(__file__).parent
+spec = None
+if a.spec:
+ sp = Path(a.spec).resolve(); spec = json.loads(sp.read_text())
+ def ref(v): # 本地图片 → /__file__/<绝对路径>(只服务 spec 里点名的文件)
+ if not v or v.startswith(('data:', 'http:', 'https:')): return v
+ f = (sp.parent / v).resolve()
+ if not f.exists(): raise SystemExit(f'spec 里的图片不存在:{v}(相对 {sp.parent})')
+ ALLOWED.add(str(f)); return '/__file__/' + urllib.parse.quote(str(f))
+ ALLOWED = set()
+ for q in spec.get('cues', []):
+ if q.get('image'): q['image'] = ref(q['image'])
+ if (spec.get('data') or {}).get('image'): spec['data']['image'] = ref(spec['data']['image'])
+ if a.alpha: spec['alpha'] = True
+class Q(http.server.SimpleHTTPRequestHandler):
+ def log_message(self, *x): pass
+ def translate_path(self, path):
+ if path.startswith('/__file__/'):
+ f = urllib.parse.unquote(path[len('/__file__/'):].split('?')[0])
+ return f if spec and f in ALLOWED else '/nonexistent'
+ return super().translate_path(path)
+srv = socketserver.TCPServer(('127.0.0.1', 0), functools.partial(Q, directory=str(root)))
+port = srv.server_address[1]
+threading.Thread(target=srv.serve_forever, daemon=True).start()
+
+with sync_playwright() as p:
+ b = p.chromium.launch(args=['--disable-web-security', '--enable-gpu-rasterization', '--ignore-gpu-blocklist'])
+ pg = b.new_page(viewport={'width': 1920, 'height': 1080}, device_scale_factor=1)
+ errors = []
+ def on_console(m):
+ if m.type in ('error', 'warning'): print('[page]', m.text)
+ if m.type == 'error': errors.append(m.text)
+ pg.on('console', on_console)
+ pg.on('pageerror', lambda e: (print('[pageerror]', e), errors.append(str(e))))
+ if spec:
+ pg.set_viewport_size({'width': spec.get('width', 1920), 'height': spec.get('height', 1080)})
+ pg.add_init_script('window.CLIP_SPEC = ' + json.dumps(spec, ensure_ascii=False) + ';')
+ pg.goto(f'http://127.0.0.1:{port}/clip.html?render=1')
+ else:
+ pg.goto(f'http://127.0.0.1:{port}/index.html?render=1' + (f'&film={a.film}' if a.film else ''))
+ pg.wait_for_function('window.__ready === true || !!window.__bootFailed', timeout=120000)
+ bf = pg.evaluate('window.__bootFailed || null')
+ if bf: raise SystemExit('场景加载失败,拒绝渲染:\n' + bf)
+ if a.t1 is None: a.t1 = pg.evaluate('window.__total')
+ if spec: a.fps = spec.get('fps', 30); a.t0 = 0; a.t1 = spec['duration']
+ grab = '''async (t)=>{ await window.prepare(t); window.renderFrame(t); return window.__canvas.toDataURL('image/png').split(',')[1]; }'''
+ if a.solo:
+ grab = '''async (t)=>{ window.renderSolo(%s, t, {counter: %s}); return window.__canvas.toDataURL('image/png').split(',')[1]; }''' % (repr(a.solo), 'false' if a.no_counter else 'true')
+ if a.stills:
+ out = Path(a.out); out.mkdir(parents=True, exist_ok=True)
+ for s in a.stills.split(','):
+ (out / f't{float(s):06.2f}.png').write_bytes(base64.b64decode(pg.evaluate(grab, float(s))))
+ print('stills ->', out)
+ else:
+ Path(a.out).parent.mkdir(parents=True, exist_ok=True)
+ vid = a.out if not a.audio else a.out + '.noaudio.mp4'
+ enc = ['-c:v', 'prores_ks', '-profile:v', '4444', '-pix_fmt', 'yuva444p10le', '-alpha_bits', '16'] if (spec and a.alpha) else \
+ ['-c:v', 'libx264', '-preset', 'slow', '-crf', str(a.crf), '-pix_fmt', 'yuv420p', '-movflags', '+faststart'] + \
+ (['-g', str(a.fps), '-keyint_min', str(a.fps), '-sc_threshold', '0'] if spec else []) # 片段要被管线的渲染器按秒 seek:每秒一个关键帧,否则冻帧
+ if spec and a.alpha and not vid.endswith('.mov'): print('提示:ProRes 4444 一般用 .mov 容器')
+ ff = subprocess.Popen(['ffmpeg', '-y', '-v', 'error', '-f', 'image2pipe', '-framerate', str(a.fps), '-c:v', 'png', '-i', '-'] + enc + [vid],
+ stdin=subprocess.PIPE)
+ n0, n1 = round(a.t0 * a.fps), round(a.t1 * a.fps)
+ st = time.time()
+ for i in range(n0, n1):
+ ff.stdin.write(base64.b64decode(pg.evaluate(grab, i / a.fps)))
+ if (i - n0) % 60 == 0:
+ print(f'{i}/{n1} {time.time()-st:.0f}s', flush=True)
+ ff.stdin.close(); ff.wait()
+ if a.audio:
+ subprocess.run(['ffmpeg', '-y', '-v', 'error', '-i', vid, '-ss', str(a.t0), '-t', str(a.t1 - a.t0), '-i', a.audio,
+ '-map', '0:v', '-map', '1:a', '-c:v', 'copy', '-c:a', 'aac', '-b:a', '256k', '-shortest', a.out], check=True)
+ Path(vid).unlink()
+ print('done ->', a.out)
+ b.close()
+srv.shutdown()
+if errors: raise SystemExit(f'❌ 页面报错 {len(errors)} 条(见上方 [page]/[pageerror])')
diff --git a/scripts/engine/scenes/01_cave.js b/scripts/engine/scenes/01_cave.js
new file mode 100644
index 0000000..d9b9dae
--- /dev/null
+++ b/scripts/engine/scenes/01_cave.js
@@ -0,0 +1,364 @@
+// 40,000 BC 洞穴岩画——纯代码。
+// 管线:①岩壁(半分辨率 fbm 高度场 → 法线 × 左上光 → 浮雕明暗;底色噪声;颗粒;裂缝;手印/爪印喷绘;暗角)全部缓存
+// ②「颜料层」:所有图形先描炭黑粗边(带孔洞的炭笔图案描边)再平涂赭石,painter 顺序保证遮挡;
+// 整层再 source-atop 叠一张「岩面明暗+颗粒」贴图 → 颜料吃进凹凸岩石
+// ③会动的:野牛/马两张姿态每 7 帧交替、举杯、热气、猫尾/眨眼、火光摇曳、金色余烬、标题淡出(全片 t 0.933–1.133)
+SCENES['01_cave'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, rng } = U, P = PAINT;
+ const C = {
+ wallL: [206, 146, 90], wallD: [110, 68, 38], wallR: [182, 100, 58],
+ ink: '#21150d', red: '#9c3520', redD: '#74261a', ochre: '#c9772f', ochreL: '#d49a5a', hair: '#cf8f2c', hairD: '#6e3c0e', coat: '#b06a2c',
+ chalk: '#f0dfbf', bison: '#8c3d22', horse: '#cf8236', stone: '#c98c50', stoneD: '#c08048', spot: '#4e2610',
+ };
+
+ // ---------- 炭笔图案(描边用):炭黑 + 随机孔洞 → 颗粒边 ----------
+ const inkTile = () => P.cached('cave_inkpat', 256, 256, (g) => {
+ const img = g.createImageData(256, 256), d = img.data, r = rng(91);
+ for (let i = 0; i < 256 * 256; i++) {
+ const x = i % 256, y = (i / 256) | 0, n = P.noise(x * 0.09, y * 0.09) * 0.5 + P.noise(x * 0.3 + 9, y * 0.3) * 0.5;
+ const hole = r() < 0.07 || n > 0.58;
+ d[i * 4] = 33; d[i * 4 + 1] = 21; d[i * 4 + 2] = 13; d[i * 4 + 3] = hole ? 255 * r() * 0.35 : 225 + r() * 30;
+ }
+ g.putImageData(img, 0, 0);
+ });
+ const fuzzTile = () => P.cached('cave_fuzzpat', 256, 256, (g) => {
+ const r = rng(57); g.fillStyle = '#21150d';
+ for (let i = 0; i < 2600; i++) { g.globalAlpha = 0.35 + r() * 0.6; g.beginPath(); g.arc(r() * 256, r() * 256, 0.7 + r() * 1.5, 0, Math.PI * 2); g.fill(); }
+ });
+ const FPATS = new WeakMap();
+ const fuzzPat = (g, t) => { let p = FPATS.get(g); if (!p) { p = g.createPattern(fuzzTile(), 'repeat'); FPATS.set(g, p); } const r = rng(P.boilSeed(t, 9) * 13 + 5); p.setTransform(new DOMMatrix().translate((r() * 256) | 0, (r() * 256) | 0)); return p; };
+ const PATS = new WeakMap();
+ const inkPat = (g, t) => {
+ let p = PATS.get(g); if (!p) { p = g.createPattern(inkTile(), 'repeat'); PATS.set(g, p); }
+ const b = P.boilSeed(t, 9), r = rng(b * 7 + 3); // 9fps:图案整体错位 → 炭笔颗粒「沸腾」
+ p.setTransform(new DOMMatrix().translate((r() * 256) | 0, (r() * 256) | 0)); return p;
+ };
+ // 先描粗边(2×lw,外半圈露出)再填色 —— 颜料图形的统一画法
+ function shape(g, path, fill, lw, t, alpha = 1) {
+ if (lw) { g.lineJoin = 'round'; g.lineCap = 'round'; g.strokeStyle = fuzzPat(g, t); g.lineWidth = lw * 2 + 7; g.stroke(path); g.strokeStyle = inkPat(g, t); g.lineWidth = lw * 2; g.stroke(path); }
+ if (fill) { g.globalAlpha = alpha; g.fillStyle = fill; g.fill(path); g.globalAlpha = 1; }
+ }
+ function inkLine(g, path, lw, t) { if (lw > 3.5) { g.strokeStyle = fuzzPat(g, t); g.lineWidth = lw + 5; g.lineCap = 'round'; g.stroke(path); } g.strokeStyle = inkPat(g, t); g.lineWidth = lw; g.lineCap = 'round'; g.lineJoin = 'round'; g.stroke(path); }
+ const poly = (pts, closed = true) => { const p = new Path2D(); pts.forEach((q, i) => i ? p.lineTo(q[0], q[1]) : p.moveTo(q[0], q[1])); if (closed) p.closePath(); return p; };
+ const sm = (pts, closed = true) => RIG.smooth(pts, closed);
+
+ // ---------- 岩壁(缓存) ----------
+ const HW = 960, HH = 540;
+ const relief = () => P.cached('cave_relief', HW, HH, (g) => {
+ // 高度场(全分辨率坐标):大起伏 + 中频鼓包
+ const hgt = new Float32Array((HW + 1) * (HH + 1));
+ for (let y = 0; y <= HH; y++) for (let x = 0; x <= HW; x++) { const X = x * 2, Y = y * 2;
+ hgt[y * (HW + 1) + x] = P.fbm(X * 0.0022 + 3, Y * 0.0022, 4) * 1.0 + P.fbm(X * 0.011, Y * 0.011 + 7, 3) * 0.16 + P.noise(X * 0.05, Y * 0.05) * 0.03; }
+ const img = g.createImageData(HW, HH), d = img.data, L = [-0.55, -0.62, 0.56];
+ const shade = new Float32Array(HW * HH);
+ for (let y = 0; y < HH; y++) for (let x = 0; x < HW; x++) {
+ const i = y * (HW + 1) + x, dx = (hgt[i + 1] - hgt[i]) * 52, dy = (hgt[i + HW + 1] - hgt[i]) * 52;
+ const nl = Math.hypot(dx, dy, 1), dot = (-dx * L[0] - dy * L[1] + L[2]) / nl;
+ const s = clamp(0.5 + (dot - 0.56) * 0.9, 0, 1); shade[y * HW + x] = s;
+ const X = x * 2, Y = y * 2, n2 = P.fbm(X * 0.0016 + 11, Y * 0.0016 + 2, 3), n3 = P.fbm(X * 0.004 + 40, Y * 0.004, 2);
+ let col = P.mix(C.wallL, C.wallD, clamp(0.35 - n2 * 1.3, 0, 1)); col = P.mix(col, C.wallR, clamp(n3 * 1.4, 0, 0.45));
+ const k = 0.72 + s * 0.55, j = (y * HW + x) * 4;
+ d[j] = col[0] * k; d[j + 1] = col[1] * k; d[j + 2] = col[2] * k; d[j + 3] = 255;
+ }
+ g.putImageData(img, 0, 0); g.__shade = shade;
+ });
+ // 给颜料层用的「岩面贴图」:阴影处压暗、亮处提亮 + 颗粒(source-atop 用)
+ const figTex = () => P.cached('cave_figtex', W, H, (g) => {
+ const rl = relief(), sh = rl.getContext('2d').__shade || relief().getContext('2d').__shade;
+ const s = P.canvas(HW, HH), sg = s.getContext('2d'), img = sg.createImageData(HW, HH), d = img.data;
+ for (let i = 0; i < HW * HH; i++) { const v = sh ? sh[i] : 0.5; const dk = v < 0.5; d[i * 4] = d[i * 4 + 1] = d[i * 4 + 2] = dk ? 20 : 255; if (!dk) { d[i * 4 + 1] = 236; d[i * 4 + 2] = 200; } d[i * 4 + 3] = (dk ? (0.5 - v) * 150 : (v - 0.5) * 50); }
+ sg.putImageData(img, 0, 0); g.drawImage(s, 0, 0, W, H);
+ g.drawImage(P.grain('cave_fdk', 0.14, [30, 18, 8], 0.32), 0, 0);
+ g.drawImage(P.grain('cave_flt', 0.05, [255, 236, 200], 0.22), 0, 0);
+ // 颜料干湿不均的大斑(低频)
+ const m = P.canvas(240, 135), mg = m.getContext('2d'), mi = mg.createImageData(240, 135);
+ for (let i = 0; i < 240 * 135; i++) { const x = i % 240, y = (i / 240) | 0, n = P.fbm(x * 0.08 + 21, y * 0.08, 3); mi.data[i * 4] = mi.data[i * 4 + 1] = mi.data[i * 4 + 2] = n > 0 ? 255 : 0; mi.data[i * 4 + 3] = Math.abs(n) * 70; }
+ mg.putImageData(mi, 0, 0); g.drawImage(m, 0, 0, W, H);
+ });
+
+ // 手形(负形手印用),中心在原点、指尖朝上
+ function handPath(s = 1) { // 返回若干块(逐块填)
+ const out = [], pal = new Path2D(); pal.ellipse(0, 8 * s, 26 * s, 31 * s, 0, 0, Math.PI * 2); out.push(pal);
+ const cap = (A, B, w) => { const p = new Path2D(); const a = Math.atan2(B[1] - A[1], B[0] - A[0]); p.moveTo(A[0], A[1]); p.lineTo(B[0], B[1]); return { p, w }; };
+ [[-0.5, 54, -17], [-0.17, 64, -6], [0.14, 62, 6], [0.46, 50, 17], [-1.25, 46, -20]].forEach(([a, l, ox], k) => {
+ const A = k < 4 ? [ox * s, -8 * s] : [-18 * s, 18 * s], B = [A[0] + Math.sin(a) * l * s, A[1] - Math.cos(a) * l * s];
+ const p = new Path2D(); const n = Math.atan2(B[1] - A[1], B[0] - A[0]) + Math.PI / 2, w = (k < 4 ? 7 : 8) * s;
+ p.moveTo(A[0] + Math.cos(n) * w, A[1] + Math.sin(n) * w); p.lineTo(B[0] + Math.cos(n) * w * 0.85, B[1] + Math.sin(n) * w * 0.85);
+ p.arc(B[0], B[1], w * 0.85, n, n + Math.PI, true); p.lineTo(A[0] - Math.cos(n) * w, A[1] - Math.sin(n) * w); p.closePath(); out.push(p); void cap; });
+ const wr = new Path2D(); wr.rect(-16 * s, 26 * s, 32 * s, 46 * s); out.push(wr); return out;
+ }
+ function spray(g, cx, cy, sigma, n, col, seed, rmin = 0.8, rmax = 3.2, amin = 0.25, amax = 0.75) {
+ const r = rng(seed); g.fillStyle = col;
+ for (let i = 0; i < n; i++) { const a = r() * Math.PI * 2, rr = Math.sqrt(-2 * Math.log(1 - r() * 0.999)) * sigma; g.globalAlpha = amin + r() * (amax - amin); g.beginPath(); g.arc(cx + Math.cos(a) * rr, cy + Math.sin(a) * rr, rmin + r() * (rmax - rmin), 0, Math.PI * 2); g.fill(); }
+ g.globalAlpha = 1;
+ }
+ function stencil(g, x, y, rot, s, col, seed, shapeFn) {
+ const tmp = P.canvas(320, 320), tg = tmp.getContext('2d');
+ spray(tg, 160, 160, 46 * s, 3200, col, seed, 0.8, 3.2, 0.15, 0.6);
+ spray(tg, 160, 160, 28 * s, 1400, col, seed + 1, 1, 3.5, 0.3, 0.75);
+ // 手形先画成实心蒙版(逐块 fill,避免 Path2D 子路径绕向相反造成的「缺口」)
+ const mk = P.canvas(320, 320), mg = mk.getContext('2d'); mg.translate(160, 160); mg.rotate(rot); mg.fillStyle = '#f6e2bc'; shapeFn(s).forEach(p => mg.fill(p));
+ tg.globalCompositeOperation = 'destination-out'; tg.globalAlpha = 0.95; tg.drawImage(mk, 0, 0);
+ tg.globalCompositeOperation = 'source-over'; tg.globalAlpha = 0.3; tg.drawImage(mk, 0, 0);
+ g.drawImage(tmp, x - 160, y - 160);
+ }
+ function pawPath(s = 1) { const out = []; const p = new Path2D(); p.ellipse(0, 8 * s, 15 * s, 12 * s, 0, 0, Math.PI * 2); out.push(p); [[-16, -10], [-6, -19], [6, -19], [16, -10]].forEach(([x, y]) => { const q = new Path2D(); q.ellipse(x * s, y * s, 6 * s, 7.5 * s, 0, 0, Math.PI * 2); out.push(q); }); return out; }
+
+ function cracks(g) {
+ const r = rng(404);
+ const starts = [[860, 0, 1.5], [930, 0, 1.75], [1540, 0, 1.7], [0, 600, -0.15], [0, 760, 0.05], [1920, 520, 3.0], [1920, 860, 3.25], [1250, 1080, -1.4], [230, 1080, -1.6], [0, 160, 0.4]];
+ const walk = (x, y, a, n, w, depth) => {
+ const pts = [[x, y]];
+ for (let s = 0; s < n; s++) { a += (r() - .5) * 0.9; const l = 14 + r() * 26; x += Math.cos(a) * l; y += Math.sin(a) * l; pts.push([x, y]);
+ if (depth < 2 && r() < 0.12) walk(x, y, a + (r() < .5 ? 1 : -1) * (0.6 + r() * 0.6), (n - s) * 0.5 | 0, w * 0.7, depth + 1); }
+ g.lineJoin = 'round';
+ g.strokeStyle = 'rgba(255,226,180,.22)'; g.lineWidth = w + 1; g.beginPath(); pts.forEach((p, i) => i ? g.lineTo(p[0] + 1.6, p[1] + 1.6) : g.moveTo(p[0] + 1.6, p[1] + 1.6)); g.stroke();
+ g.strokeStyle = 'rgba(40,22,10,.62)'; g.lineWidth = w; g.beginPath(); pts.forEach((p, i) => i ? g.lineTo(p[0], p[1]) : g.moveTo(p[0], p[1])); g.stroke();
+ };
+ starts.forEach(([x, y, a]) => walk(x, y, a, 12 + (r() * 14 | 0), 2.2, 0));
+ }
+
+ const HANDS = [[150, 232, -0.35, 0.95], [238, 442, 0.25, 0.9], [1098, 138, 0.05, 0.95], [1742, 440, -0.2, 1.0], [1800, 662, 0.3, 0.92]];
+ // 静态画面(岩壁 + 所有不动的颜料图形)
+ const bg = () => P.cached('cave_bg', W, H, (g) => {
+ g.imageSmoothingQuality = 'high'; g.drawImage(relief(), 0, 0, W, H);
+ g.drawImage(P.grain('cave_wdk', 0.22, [60, 36, 18], 0.32), 0, 0);
+ g.drawImage(P.grain('cave_wlt', 0.10, [255, 238, 205], 0.28), 0, 0);
+ cracks(g);
+ // 手印(红赭石喷绘负形)+ 爪印(炭黑)+ 红点虚线
+ HANDS.forEach(([x, y, a, s], k) => { if (s) stencil(g, x, y, a, s, '#8e2a1a', 31 + k * 17, handPath); });
+ stencil(g, 262, 762, 0, 0.5, '#1a0f08', 77, pawPath);
+ g.fillStyle = '#9a2e1c'; for (let k = 0; k < 9; k++) { const x = 100 + k * 28, y = 972 - k * 4.5; spray(g, x, y, 3.5, 40, '#9a2e1c', 200 + k, 0.8, 2, 0.4, 0.8); g.globalAlpha = 0.75; g.beginPath(); g.arc(x, y, 5.5, 0, Math.PI * 2); g.fill(); g.globalAlpha = 1; }
+ // 静态颜料图形画到一张临时层,再叠岩面贴图
+ const L = P.canvas(), lg = L.getContext('2d');
+ // 壁画框
+ const fr = new Path2D(); P.roughPath({ moveTo: (...a) => fr.moveTo(...a), lineTo: (...a) => fr.lineTo(...a), closePath: () => fr.closePath(), beginPath() {} }, [[367, 126], [793, 124], [796, 552], [366, 550]], { amp: 3, seed: 5, closed: true, step: 18 });
+ inkLine(lg, fr, 8, 0);
+ const dot = (x, y) => { spray(lg, x, y, 5, 26, '#a8331f', (x * 7 + y) | 0, 0.8, 2.2, 0.3, 0.8); lg.fillStyle = '#a8331f'; lg.globalAlpha = 0.85; lg.beginPath(); lg.ellipse(x, y, 8.5, 8, (x + y) * 0.1, 0, Math.PI * 2); lg.fill(); lg.globalAlpha = 1; };
+ for (let x = 398; x <= 768; x += 37) { dot(x, 152); dot(x, 524); }
+ for (let y = 190; y <= 490; y += 37) { dot(392, y); dot(770, y); }
+ // 太阳+射线
+ spray(lg, 470, 228, 14, 200, '#a8301c', 9, 1, 3, 0.3, 0.8); lg.fillStyle = '#a8301c'; lg.globalAlpha = 0.9; lg.beginPath(); lg.arc(470, 228, 28, 0, Math.PI * 2); lg.fill(); lg.globalAlpha = 1;
+ lg.strokeStyle = '#a8301c'; lg.lineWidth = 4.5; lg.lineCap = 'round';
+ for (let k = 0; k < 9; k++) { const a = Math.PI * (0.95 + k * 0.13); lg.beginPath(); lg.moveTo(470 + Math.cos(a) * 38, 228 + Math.sin(a) * 38); lg.lineTo(470 + Math.cos(a) * 56, 228 + Math.sin(a) * 56); lg.stroke(); }
+ // 桌子上方的淡炭笔涂鸦(之前画过的人形)
+ lg.strokeStyle = 'rgba(40,26,16,.5)'; lg.lineWidth = 3;
+ [[[858, 342], [872, 300], [905, 262], [945, 250], [972, 268], [1000, 258], [1040, 250], [1080, 272], [1098, 318], [1100, 365]], [[880, 330], [885, 380], [890, 395]], [[928, 300], [924, 360], [926, 412]], [[955, 352], [990, 342], [1008, 352], [1012, 384]], [[1040, 360], [1048, 400]], [[1060, 330], [1078, 352], [1088, 392]]]
+ .forEach((pts, k) => { P.roughPath(lg, pts, { amp: 1.6, seed: 50 + k, step: 10 }); lg.stroke(); });
+ // 石凳(少女坐)、石板桌、长矛
+ shape(lg, sm([[1288, 768], [1325, 738], [1420, 730], [1492, 748], [1518, 806], [1514, 882], [1484, 908], [1300, 910], [1276, 872], [1272, 806]]), C.stone, 7, 0, 0.92);
+ inkLine(lg, sm([[1460, 790], [1478, 840], [1470, 880]], false), 3, 0); inkLine(lg, sm([[1320, 860], [1340, 890]], false), 3, 0);
+ shape(lg, sm([[958, 668], [1078, 668], [1086, 760], [1100, 870], [1094, 906], [936, 906], [926, 872], [944, 760]]), C.stoneD, 7, 0, 0.92);
+ inkLine(lg, sm([[985, 720], [978, 790], [984, 830]], false), 3, 0); inkLine(lg, sm([[1048, 790], [1060, 850]], false), 3, 0);
+ shape(lg, sm([[818, 650], [842, 636], [1000, 632], [1182, 636], [1210, 650], [1198, 668], [1000, 674], [830, 670]]), C.ochreL, 7, 0, 0.92);
+ const sp = new Path2D(); sp.moveTo(1562, 902); sp.lineTo(1512, 340); inkLine(lg, sp, 7, 0);
+ shape(lg, sm([[1508, 296], [1522, 322], [1520, 350], [1510, 362], [1500, 350], [1497, 322]]), C.red, 4, 0);
+ lg.globalCompositeOperation = 'source-atop'; lg.drawImage(figTex(), 0, 0); lg.globalCompositeOperation = 'source-over';
+ g.drawImage(L, 0, 0);
+ // 洞穴暗角(四角压暗)+ 中心暖光(静态部分)
+ const v = g.createRadialGradient(990, 560, 260, 990, 560, 1180); v.addColorStop(0, 'rgba(30,14,4,0)'); v.addColorStop(0.5, 'rgba(30,14,4,.16)'); v.addColorStop(1, 'rgba(18,8,2,.8)');
+ g.fillStyle = v; g.fillRect(0, 0, W, H);
+ const fl = g.createRadialGradient(1000, 520, 20, 1000, 520, 620); fl.addColorStop(0, 'rgba(255,190,110,.36)'); fl.addColorStop(0.5, 'rgba(255,150,70,.14)'); fl.addColorStop(1, 'rgba(255,150,70,0)');
+ g.globalCompositeOperation = 'lighter'; g.fillStyle = fl; g.fillRect(0, 0, W, H); g.globalCompositeOperation = 'source-over';
+ });
+
+ // ---------- 壁画动物:两张姿态(每 7 帧换一张) ----------
+ const BISON = sm([[470, 300], [495, 280], [545, 268], [595, 250], [632, 240], [660, 246], [682, 268], [692, 300], [686, 330], [668, 350], [640, 356], [590, 352], [530, 348], [488, 342], [468, 324]]);
+ const BHEAD = sm([[672, 270], [698, 280], [716, 302], [724, 326], [714, 340], [696, 338], [682, 326], [668, 300]]);
+ const HORSE = sm([[452, 474], [470, 458], [510, 456], [548, 452], [566, 432], [582, 414], [598, 410], [614, 432], [612, 444], [598, 444], [586, 438], [578, 458], [574, 478], [540, 488], [486, 488], [458, 486]]);
+ function animals(g, t) {
+ const ph = Math.floor(t * 60 / 7) % 2, rb = P.boilSeed(t, 9);
+ // 野牛
+ g.save(); g.translate(ph ? 3 : -3, ph ? -7 : 2);
+ const bl = ph ? [[652, 340, 698, 384], [632, 346, 672, 394], [500, 340, 458, 378], [520, 344, 482, 390]]
+ : [[652, 340, 648, 392], [632, 346, 618, 396], [500, 340, 504, 394], [520, 344, 530, 394]];
+ bl.forEach(([x0, y0, x1, y1], k) => { const pth = sm([[x0, y0], [(x0 + x1) / 2 + (ph ? 0 : 8 * (k < 2 ? -1 : 1)), (y0 + y1) / 2 + 2], [x1, y1]], false); inkLine(g, pth, 6, t); const hf = new Path2D(); hf.moveTo(x1 - 6, y1); hf.lineTo(x1 + 7, y1 + 2); inkLine(g, hf, 6, t); });
+ g.save(); g.translate(698, 300); g.rotate(ph ? 0.12 : -0.09); g.translate(-698, -300);
+ shape(g, BISON, C.bison, 7, t, 0.95);
+ g.save(); g.clip(BISON); g.strokeStyle = 'rgba(70,24,10,.55)'; g.lineWidth = 22; g.stroke(sm([[480, 292], [545, 276], [600, 258], [640, 252], [672, 268]], false)); g.restore();
+ shape(g, BHEAD, '#76301a', 6, t);
+ inkLine(g, sm([[700, 284], [708, 262], [722, 248]], false), 5, t); inkLine(g, sm([[688, 280], [688, 258], [698, 242]], false), 4.5, t);
+ inkLine(g, sm([[690, 340], [688, 352]], false), 4, t); inkLine(g, sm([[702, 342], [702, 354]], false), 4, t);
+ g.fillStyle = C.ink; g.beginPath(); g.arc(704, 304, 3.5, 0, Math.PI * 2); g.fill();
+ g.restore();
+ g.fillStyle = C.ink; for (let k = 0; k < 6; k++) { g.beginPath(); g.arc(538 + k * 13, 301, 3.2, 0, Math.PI * 2); g.fill(); }
+ inkLine(g, sm([[468, 296], [452, 314], [446, 336]], false), 4, t);
+ g.restore();
+ // 马(与野牛反相)
+ g.save(); g.translate(ph ? -3 : 3, ph ? 2 : -7);
+ const hl = ph ? [[566, 486, 562, 528], [552, 488, 544, 530], [484, 488, 488, 528], [470, 486, 466, 526]]
+ : [[566, 486, 596, 520], [552, 488, 580, 528], [484, 488, 456, 520], [470, 486, 442, 516]];
+ hl.forEach(([x0, y0, x1, y1]) => { inkLine(g, sm([[x0, y0], [(x0 + x1) / 2, (y0 + y1) / 2 + 2], [x1, y1]], false), 5.5, t); });
+ g.save(); g.translate(590, 440); g.rotate(ph ? -0.08 : 0.1); g.translate(-590, -440);
+ shape(g, HORSE, C.horse, 6, t, 0.95);
+ shape(g, poly([[592, 414], [598, 396], [606, 414]]), C.horse, 3.5, t);
+ for (let k = 0; k < 6; k++) { const p = new Path2D(); p.moveTo(566 + k * 4.5, 446 - k * 6); p.lineTo(558 + k * 4.5, 438 - k * 6); inkLine(g, p, 3.2, t); }
+ g.fillStyle = C.ink; g.beginPath(); g.arc(600, 424, 3, 0, Math.PI * 2); g.fill();
+ g.restore();
+ inkLine(g, sm([[454, 468], [440, 480], [432, 500]], false), 4.5, t);
+ g.restore();
+ void rb;
+ }
+
+ // ---------- 猫(岩画画法,橘白) ----------
+ function cat(g, ch, t, lt) {
+ const K = RIG.cat({ tail: ch.tail, blink: ch.blink, breathe: ch.breathe, look: hq(lt) * 1.5 });
+ const ha = -0.16 * hq(lt), ear = hq(lt) > 0.2 ? Math.sin(lt * 60) * 0.06 : 0;
+ const br = (x, y) => [x, y - (y < 800 ? ch.breathe * 300 : 0)];
+ // 尾巴(在身后)
+ g.lineCap = 'round'; g.lineJoin = 'round';
+ g.strokeStyle = fuzzPat(g, t); g.lineWidth = K.tailW + 18; g.stroke(K.tail); g.strokeStyle = inkPat(g, t); g.lineWidth = K.tailW + 12; g.stroke(K.tail);
+ g.strokeStyle = C.ochre; g.lineWidth = K.tailW; g.stroke(K.tail);
+ const tp = K.tailPts; g.strokeStyle = '#55210b'; g.lineWidth = 6;
+ for (let k = 5; k < tp.length - 1; k += 4) { const a = Math.atan2(tp[k + 1][1] - tp[k][1], tp[k + 1][0] - tp[k][0]) + Math.PI / 2; g.beginPath(); g.moveTo(tp[k][0] + Math.cos(a) * 10, tp[k][1] + Math.sin(a) * 10); g.lineTo(tp[k][0] - Math.cos(a) * 10, tp[k][1] - Math.sin(a) * 10); g.stroke(); }
+ // 身体
+ const body = sm([[560, 684], [505, 702], [464, 756], [446, 826], [450, 884], [488, 906], [600, 906], [654, 902], [662, 858], [654, 790], [642, 734], [616, 698]].map(p => br(...p)));
+ shape(g, body, C.ochre, 7, t);
+ g.save(); g.clip(body); g.strokeStyle = '#55210b'; g.lineCap = 'round';
+ [[716, 12], [748, 11], [780, 11], [812, 10], [846, 9]].forEach(([y, w], k) => { const yy = br(0, y)[1]; g.lineWidth = w; g.beginPath(); g.moveTo(430, yy - 6); g.quadraticCurveTo(470 + k * 2, yy + 2, 512 - k * 3, yy + 16); g.stroke(); });
+ g.lineWidth = 9; g.beginPath(); g.moveTo(520, 690); g.lineTo(540, 716); g.stroke(); g.beginPath(); g.moveTo(548, 686); g.lineTo(562, 708); g.stroke();
+ g.restore();
+ // 白胸肚
+ g.fillStyle = C.chalk; g.fill(sm([[612, 700], [640, 736], [652, 792], [656, 860], [644, 898], [592, 902], [584, 830], [592, 748]].map(p => br(...p))));
+ // 大腿弧线
+ inkLine(g, sm([[478, 842], [508, 826], [546, 838], [566, 872], [566, 904]], false), 4, t);
+ // 前腿+爪(白)
+ [[592, 600], [634, 640]].forEach(([x0, x1]) => { const leg = sm([[x0 - 4, 790], [x0 + 22, 792], [x0 + 24, 880], [x0 + 32, 892], [x0 + 26, 906], [x0 - 12, 906], [x0 - 10, 884]]); shape(g, leg, C.chalk, 6, t); });
+ // 头(原片 65–81 帧猫头有小动作:绕颈点抬头转向,耳朵抖)
+ g.save(); g.translate(596, 680); g.rotate(ha + ear); g.translate(-596, -680);
+ shape(g, K.head, C.ochre, 7, t);
+ g.save(); g.clip(K.head);
+ g.fillStyle = C.chalk; g.beginPath(); g.ellipse(K.nose[0] - 22, K.nose[1] + 16, 38, 28, 0, 0, Math.PI * 2); g.fill();
+ g.strokeStyle = '#55210b'; g.lineWidth = 7; g.lineCap = 'round'; K.stripes.slice(0, 3).forEach(s => { g.beginPath(); g.moveTo(...s[0]); g.lineTo(...s[1]); g.stroke(); });
+ g.restore();
+ g.fillStyle = '#c0644a'; K.earInner.forEach(e => g.fill(poly(e)));
+ // 眼、鼻、嘴、须
+ K.eyes.forEach(e => { if (K.blink) { const p = new Path2D(); p.arc(e.x, e.y, 8, 0.2, Math.PI - 0.2); inkLine(g, p, 3.5, t); }
+ else { const p = new Path2D(); p.ellipse(e.x, e.y, 9, 7.5, 0, 0, Math.PI * 2); g.fillStyle = '#e8b54a'; g.fill(p); inkLine(g, p, 3, t); g.fillStyle = C.ink; g.beginPath(); g.ellipse(e.x + 2, e.y, 2.6, 6, 0, 0, Math.PI * 2); g.fill(); } });
+ g.fillStyle = '#8a2a1a'; g.fill(poly([[K.nose[0] - 6, K.nose[1] - 4], [K.nose[0] + 6, K.nose[1] - 4], [K.nose[0], K.nose[1] + 4]]));
+ const m = new Path2D(); m.moveTo(...K.mouth[0]); m.quadraticCurveTo(...K.mouth[1], ...K.mouth[2]); inkLine(g, m, 3, t);
+ K.whiskers.forEach(w => { const p = new Path2D(); p.moveTo(...w[0]); p.lineTo(...w[1]); inkLine(g, p, 2.2, t); });
+ g.restore();
+ }
+ const hq = (lt) => { const q = clamp((lt - 1.08) / 0.27); return Math.sin(q * Math.PI); };
+
+ // ---------- 少女(岩画人形,金发长卷发,及膝豹纹兽皮外衣) ----------
+ function girl(g, lt, t, ch) {
+ const k = P.choreo(Math.max(0, lt - 0.95), t).cup; // 0.95s 起举杯(choreo 曲线平移)
+ const G = RIG.girl({ cup: k, sip: ch.sip * k, breathe: ch.breathe, hair: 'long' });
+ const nk = [1300, 425], ct = Math.cos(G.tilt), st = Math.sin(G.tilt);
+ const HP = (x, y) => { const X = x - nk[0], Y = y - nk[1]; return [nk[0] + X * ct - Y * st, nk[1] + X * st + Y * ct]; };
+ const HB = (x, y) => (y < 440 ? HP(x, y) : [x + (y < 520 ? (HP(x, y)[0] - x) * (520 - y) / 80 : 0), y]); // 头发:越往下越不跟头转
+ // 远侧小腿(在后)
+ const leg = (ox, oy) => sm([[1140, 770], [1128, 830], [1120, 878], [1094, 896], [1084, 910], [1172, 912], [1178, 890], [1192, 830], [1198, 778]].map(([x, y]) => [x + ox, y + oy]));
+ shape(g, leg(40, -6), C.redD, 6, t);
+ // 背后长发(黄赭石,波浪边)
+ const back = [], front = [];
+ for (let i = 0; i <= 10; i++) { const q = i / 10, y = 330 + q * 300; back.push(HB(1398 + q * 52 + Math.sin(q * 13) * 13 * q, y)); front.push(HB(1332 + q * 68 + Math.sin(q * 12 + 1) * 11 * q, 345 + q * 270)); }
+ const tips = [[1440, 640], [1428, 622], [1418, 646], [1406, 626]];
+ const hairPts = [HP(1262, 312), HP(1300, 288), HP(1352, 290), HP(1392, 314), ...back, ...tips, ...front.reverse(), HP(1320, 330), HP(1290, 318)];
+ const hairP = sm(hairPts);
+ // 兽皮外衣(躯干 + 及膝下摆,毛边)
+ const fr = [], rr = rng(17);
+ for (let x = 1448, i = 0; x >= 1126; x -= 15, i++) fr.push([x, 782 + (i % 2 ? 16 : 0) + (rr() - .5) * 6]);
+ const coatLow = sm([[1300, 600], [1420, 608], [1446, 650], [1452, 722], [1450, 770], ...fr, [1124, 764], [1148, 722], [1190, 656], [1242, 628]]);
+ // 近侧小腿
+ // 外衣描边 → 填色(两块一起,接缝被盖住)
+ g.lineJoin = 'round'; g.strokeStyle = fuzzPat(g, t); g.lineWidth = 19; g.stroke(G.torso); g.stroke(coatLow); g.strokeStyle = inkPat(g, t); g.lineWidth = 13; g.stroke(G.torso); g.stroke(coatLow);
+ shape(g, leg(0, 0), C.red, 6, t);
+ g.fillStyle = C.coat; g.fill(G.torso); g.fill(coatLow);
+ // 豹纹斑点
+ g.save(); const clipP = new Path2D(); clipP.addPath(G.torso); clipP.addPath(coatLow); g.clip(clipP);
+ const r = rng(23);
+ for (let i = 0; i < 26; i++) { const x = 1150 + r() * 300, y = 450 + r() * 330, s = 7 + r() * 6; g.fillStyle = C.spot; g.beginPath(); g.arc(x, y, s, 0, Math.PI * 2); g.fill();
+ for (let j = 0; j < 7; j++) { const a = j / 7 * Math.PI * 2 + r(); g.beginPath(); g.arc(x + Math.cos(a) * s * 1.6, y + Math.sin(a) * s * 1.6, 2.4, 0, Math.PI * 2); g.fill(); } }
+ g.strokeStyle = 'rgba(78,38,16,.55)'; g.lineWidth = 2.5; for (let i = 0; i < 18; i++) { const x = 1170 + r() * 270, y = 470 + r() * 300; g.beginPath(); g.moveTo(x, y); g.lineTo(x - 6, y + 12); g.stroke(); }
+ g.restore();
+ // 腰带(皮绳)
+ inkLine(g, sm([[1292, 606], [1360, 612], [1424, 614]], false), 6, t);
+ // 头发、脖子、脸
+ shape(g, G.neck, C.red, 6, t);
+ shape(g, hairP, C.hair, 7, t);
+ g.save(); g.clip(hairP); g.strokeStyle = C.hairD; g.lineWidth = 3; g.lineCap = 'round';
+ for (let j = 0; j < 6; j++) { const pts = []; for (let i = 0; i <= 12; i++) { const q = i / 12; pts.push(HB(1338 + j * 17 + q * (56 - j * 2) + Math.sin(q * 13 + j * 0.7) * 12 * Math.min(1, q * 2.5), 300 + q * 330)); } g.stroke(sm(pts, false)); }
+ g.restore();
+ shape(g, G.face, C.red, 7, t);
+ shape(g, G.bangs, C.hair, 6, t);
+ g.save(); g.clip(G.bangs); g.strokeStyle = C.hairD; g.lineWidth = 2.5; G.hairLines.forEach(h => g.stroke(h)); g.restore();
+ // 眼(侧脸一笔:杏仁+睫毛;眨眼时只剩一条线)
+ if (ch.blink) { const p = new Path2D(); p.moveTo(G.eye.x - 8, G.eye.y + 1); p.quadraticCurveTo(G.eye.x, G.eye.y + 5, G.eye.x + 8, G.eye.y + 1); inkLine(g, p, 3, t); }
+ else { const p = new Path2D(); p.ellipse(G.eye.x, G.eye.y, 7.5, 4.2, -0.1, 0, Math.PI * 2); g.fillStyle = '#f0dcb8'; g.fill(p); inkLine(g, p, 2.6, t); g.fillStyle = C.ink; g.beginPath(); g.arc(G.eye.x - 2, G.eye.y, 2.8, 0, Math.PI * 2); g.fill();
+ const l = new Path2D(); l.moveTo(G.eye.x - 7, G.eye.y - 2); l.lineTo(G.eye.x - 12, G.eye.y - 6); inkLine(g, l, 2.4, t); }
+ inkLine(g, G.brow, 2.4, t);
+ // 端杯手臂:自定 IK(伸臂端在半空 → 举到嘴边)
+ const hold = [1084, 506], mouth = HP(1224, 380), cp = [lerp(hold[0], mouth[0], k), lerp(hold[1], mouth[1], k)];
+ const S = G.A.shoulder, hand = [cp[0] + 34, cp[1] + 10];
+ const { E, H: Hd } = RIG.ik2(S, hand, 170, 128, -1);
+ const ua = RIG.taper(S, E, 50, 36, 6), fa = RIG.taper(E, Hd, 36, 26, 2);
+ g.strokeStyle = fuzzPat(g, t); g.lineWidth = 18; g.stroke(ua); g.stroke(fa); g.strokeStyle = inkPat(g, t); g.lineWidth = 12; g.stroke(ua); g.stroke(fa);
+ g.fillStyle = C.red; g.fill(ua); g.fill(fa);
+ // 杯(红赭小碗)
+ g.save(); g.translate(cp[0], cp[1]); g.rotate(-0.45 * k);
+ const cup = sm([[-34, -2], [-28, 22], [-12, 40], [12, 40], [28, 22], [34, -2]]);
+ shape(g, cup, C.red, 6, t);
+ const rim = new Path2D(); rim.ellipse(0, -2, 34, 7, 0, 0, Math.PI * 2); g.fillStyle = C.redD; g.fill(rim); inkLine(g, rim, 3.5, t);
+ g.restore();
+ // 手+手指(岩画式几道短线)
+ const hp = new Path2D(); hp.ellipse(Hd[0], Hd[1], 15, 12, Math.atan2(Hd[1] - E[1], Hd[0] - E[0]), 0, Math.PI * 2); shape(g, hp, C.red, 5, t);
+ const fa_ = Math.atan2(Hd[1] - E[1], Hd[0] - E[0]);
+ for (let j = -1; j <= 1; j++) { const p = new Path2D(), ox = Math.cos(fa_ + Math.PI / 2) * j * 7, oy = Math.sin(fa_ + Math.PI / 2) * j * 7; p.moveTo(Hd[0] + ox + Math.cos(fa_) * 12, Hd[1] + oy + Math.sin(fa_) * 12); p.lineTo(Hd[0] + ox + Math.cos(fa_) * 30, Hd[1] + oy + Math.sin(fa_) * 30); inkLine(g, p, 3, t); }
+ // 热气:三道波浪炭线,向上蠕动
+ for (let j = -1; j <= 1; j++) { const p = new Path2D(), x0 = cp[0] + j * 16, y0 = cp[1] - 22;
+ for (let s = 0; s <= 18; s++) { const q = s / 18, y = y0 - q * 58, x = x0 + Math.sin(q * 13 - t * 11 + j * 1.3) * 6; s ? p.lineTo(x, y) : p.moveTo(x, y); }
+ inkLine(g, p, 3.4, t); }
+ return G;
+ }
+
+ // ---------- 标题(全片 0.933–1.133s 淡出) ----------
+ function title(g, t) {
+ const a = t < 0.933 ? 1 : 1 - clamp((t - 0.933) / 0.2); if (a <= 0) return;
+ g.save(); g.globalAlpha = a; g.font = '78px "Kalam-700"'; g.letterSpacing = '7px'; g.textBaseline = 'alphabetic';
+ const txt = 'TEA ACROSS THE AGES', w = g.measureText(txt).width, sx = 930 / w;
+ g.translate(955, 1024); g.scale(sx, 1); g.fillStyle = '#9b2a18'; g.fillText(txt, -w / 2, 0);
+ g.restore();
+ }
+
+ return {
+ draw(c, lt, t) {
+ const ch = P.choreo(lt, t);
+ c.drawImage(bg(), 0, 0);
+ // 颜料层:动物 → 猫 → 少女 → 标题,整层叠岩面贴图
+ const L = P.scratch('cave_fig'), g = L.getContext('2d'); g.clearRect(0, 0, W, H);
+ animals(g, t);
+ // 猫整体以脚底 (540,905) 为锚缩 0.86:耳尖从 y≈535 降到 ≈587,和壁画框底边(550)留出 ≥35px
+ g.save(); g.translate(540, 905); g.scale(0.86, 0.86); g.translate(-540, -905); cat(g, ch, t, lt); g.restore();
+ girl(g, lt, t, ch); title(g, t);
+ g.globalCompositeOperation = 'source-atop'; g.drawImage(figTex(), 0, 0); g.globalCompositeOperation = 'source-over';
+ c.drawImage(L, 0, 0);
+ // 火光摇曳:中心与强度随噪声抖动
+ const n1 = P.noise(t * 3.1, 1.7), n2 = P.noise(t * 2.3, 8.1), fl = 0.14 + 0.11 * P.noise(t * 9.5, 3.3) + 0.04 * Math.sin(t * 23) + 0.03 * Math.sin(t * 37);
+ const fx = 1000 + n1 * 60, fy = 540 + n2 * 36;
+ // overlay 合成:提亮暖化但不洗白颜料的饱和度(lighter 会把人物洗成粉黄)
+ const gr = c.createRadialGradient(fx, fy, 10, fx, fy, 700 + n2 * 60); gr.addColorStop(0, `rgba(255,196,110,${fl * 2.6})`); gr.addColorStop(0.5, `rgba(255,160,80,${fl * 1.3})`); gr.addColorStop(1, 'rgba(255,140,60,0)');
+ c.save(); c.globalCompositeOperation = 'overlay'; c.fillStyle = gr; c.fillRect(0, 0, W, H);
+ // 暗处随火光一起「呼吸」
+ c.globalCompositeOperation = 'source-over';
+ const dk = c.createRadialGradient(fx, fy, 380, fx, fy, 1150); dk.addColorStop(0, 'rgba(20,8,2,0)'); dk.addColorStop(1, `rgba(20,8,2,${0.12 - fl * 0.4 + 0.08})`);
+ c.fillStyle = dk; c.fillRect(0, 0, W, H);
+ // 手印忽明忽暗:每个手印上叠一块独立噪声驱动的暖光
+ c.globalCompositeOperation = 'lighter';
+ HANDS.forEach(([x, y], k) => { const v = clamp(0.5 + 0.9 * P.noise(t * 7 + k * 3.7, k)); if (v < 0.05) return;
+ const hg = c.createRadialGradient(x, y, 5, x, y, 105); hg.addColorStop(0, `rgba(255,150,80,${0.2 * v})`); hg.addColorStop(1, 'rgba(255,120,60,0)'); c.fillStyle = hg; c.fillRect(x - 105, y - 105, 210, 210); });
+ // 金色余烬:左右两侧缓慢上漂、闪烁
+ c.globalCompositeOperation = 'lighter';
+ [[0, 380, 20], [1520, 1920, 20], [380, 1520, 9]].forEach(([x0, x1, n], s) => {
+ P.particles(n, 300 + s * 31, t, { x0, x1, y0: H + 30, y1: 120, drift: 22, life: 5.5 }).forEach(p => {
+ const tw = 0.3 + 0.7 * Math.abs(Math.sin(t * 7 + p.i * 1.9)), fade = Math.sin(p.q * Math.PI), r0 = 2.6 + p.s * 2.8;
+ c.fillStyle = `rgba(255,170,60,${0.32 * tw * fade})`; c.beginPath(); c.arc(p.x, p.y, r0 * 3.6, 0, Math.PI * 2); c.fill();
+ c.fillStyle = `rgba(255,224,130,${0.95 * tw * fade})`; c.beginPath(); c.arc(p.x, p.y, r0, 0, Math.PI * 2); c.fill();
+ });
+ });
+ c.restore();
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/02_egypt.js b/scripts/engine/scenes/02_egypt.js
new file mode 100644
index 0000000..b562fdb
--- /dev/null
+++ b/scripts/engine/scenes/02_egypt.js
@@ -0,0 +1,524 @@
+// 公元前 1350 年 埃及墓室壁画(阿马尔纳时期)——纯代码。
+// 管线:①静态层(灰泥墙+彩色几何边框+象形文字栏+窗/阿顿日盘+陶罐/供桌/椅)缓存
+// → ②会动的母题(阿顿光线末端小手一张一合、水纹象形字流动、圣甲虫推日球)
+// → ③角色:埃及程式(侧脸正面眼、正面肩、平涂+深色勾线)→ ④壁画表面(斑驳 multiply+裂纹+颗粒)
+SCENES['02_egypt'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp } = U, P = PAINT;
+ const C = {
+ wall: '#eadcb8', wall2: '#d8c597', line: '#2a1810', rule: '#9a2b22',
+ red: '#b8322a', blue: '#2a58a8', green: '#2e8a55', yellow: '#e2b13a', black: '#231a14',
+ gold: '#e0ab38', goldD: '#a8741c', goldL: '#f3d27a', navy: '#1c2236', cream: '#f2ead6', white: '#f6f2e8',
+ skin: '#e6b282', skinD: '#c98d5c', terra: '#d4936a', lapis: '#2c56b0', turq: '#3fa6a0',
+ catO: '#e08a3c', catS: '#b45a1c', catW: '#f6efe0',
+ };
+ const BAND = [C.red, C.blue, C.yellow, C.green]; // 埃及边框四色
+
+ // ---------------- 小工具 ----------------
+ const poly = (g, pts, close = true) => { g.beginPath(); pts.forEach((p, i) => i ? g.lineTo(p[0], p[1]) : g.moveTo(p[0], p[1])); if (close) g.closePath(); };
+ const fs = (g, fill, stroke, lw = 2.5) => { if (fill) { g.fillStyle = fill; g.fill(); } if (stroke) { g.strokeStyle = stroke; g.lineWidth = lw; g.stroke(); } };
+ const sm = (pts, closed = true) => RIG.smooth(pts, closed);
+
+ // ---------------- 象形文字字形库(原点居中,约 50px 宽;h = 占位高度) ----------------
+ // 每个字形:{h, cols:[可选颜色], d(g) };g 已设好 strokeStyle/fillStyle/lineWidth
+ const GL = {
+ ankh: { h: 60, cols: [C.blue, C.green, C.black, C.red], d(g) { g.lineWidth = 3.6; g.beginPath(); g.ellipse(0, -17, 8, 11, 0, 0, 7); g.moveTo(-16, -3); g.lineTo(16, -3); g.moveTo(0, -5); g.lineTo(0, 29); g.stroke(); } },
+ sun: { h: 40, cols: [C.black, C.blue, C.red], d(g) { g.lineWidth = 3; g.beginPath(); g.arc(0, 0, 15, 0, 7); g.stroke(); g.beginPath(); g.arc(0, 0, 4, 0, 7); g.fill(); } },
+ bread: { h: 26, cols: [C.red, C.blue, C.green], d(g) { g.beginPath(); g.arc(0, 9, 19, Math.PI, 0); g.closePath(); g.stroke(); g.beginPath(); g.moveTo(-12, 4); g.lineTo(12, 4); g.stroke(); } },
+ reed: { h: 62, cols: [C.black, C.green, C.red], d(g) { g.beginPath(); g.moveTo(-2, 29); g.quadraticCurveTo(-11, 0, 1, -29); g.quadraticCurveTo(7, -2, 4, 29); g.stroke(); g.beginPath(); g.moveTo(1, -29); g.quadraticCurveTo(9, -31, 10, -24); g.stroke(); } },
+ owl: { h: 60, cols: [C.black, C.blue], d(g) { g.beginPath(); g.ellipse(3, 6, 12, 19, 0.1, 0, 7); g.stroke(); g.beginPath(); g.arc(-2, -18, 10, 0, 7); g.stroke(); g.beginPath(); g.arc(-6, -19, 2.4, 0, 7); g.arc(2, -19, 2.4, 0, 7); g.fill(); g.beginPath(); g.moveTo(-2, -14); g.lineTo(-3, -9); g.moveTo(9, 22); g.lineTo(18, 29); g.moveTo(-3, 24); g.lineTo(-5, 30); g.moveTo(4, 24); g.lineTo(3, 30); g.stroke(); } },
+ falcon: { h: 60, cols: [C.black, C.red, C.blue], d(g) { g.beginPath(); g.arc(-6, -20, 7, 0, 7); g.fill(); poly(g, [[-12, -21], [-19, -16], [-11, -15]]); g.fill(); g.beginPath(); g.ellipse(2, 1, 10, 20, -0.35, 0, 7); g.stroke(); poly(g, [[8, 16], [20, 30], [6, 27]]); g.fill(); g.beginPath(); g.moveTo(-3, 19); g.lineTo(-5, 30); g.moveTo(2, 19); g.lineTo(1, 30); g.moveTo(-1, -8); g.quadraticCurveTo(10, 0, 12, 14); g.stroke(); } },
+ heron: { h: 64, cols: [C.green, C.black, C.blue], d(g) { g.beginPath(); g.moveTo(-20, -22); g.lineTo(-8, -26); g.quadraticCurveTo(0, -28, -1, -18); g.quadraticCurveTo(-6, -8, 2, -2); g.stroke(); g.beginPath(); g.ellipse(8, 4, 13, 8, 0.4, 0, 7); g.stroke(); g.beginPath(); g.moveTo(4, 11); g.lineTo(2, 31); g.moveTo(10, 11); g.lineTo(12, 31); g.moveTo(18, 9); g.lineTo(24, 14); g.stroke(); } },
+ snake: { h: 30, cols: [C.green, C.black, C.red], d(g) { g.lineWidth = 3.2; g.beginPath(); g.moveTo(22, 8); g.bezierCurveTo(10, -4, 4, 14, -6, 6); g.bezierCurveTo(-14, 0, -16, -4, -20, -2); g.stroke(); g.beginPath(); g.moveTo(-20, -2); g.lineTo(-23, -9); g.moveTo(-17, -3); g.lineTo(-15, -10); g.stroke(); } },
+ eye: { h: 36, cols: [C.green, C.black, C.blue], d(g) { g.beginPath(); g.moveTo(-18, 0); g.quadraticCurveTo(0, -12, 18, 0); g.quadraticCurveTo(0, 9, -18, 0); g.stroke(); g.beginPath(); g.arc(0, -1, 4.5, 0, 7); g.fill(); g.beginPath(); g.moveTo(-18, -12); g.quadraticCurveTo(0, -20, 20, -11); g.moveTo(-4, 6); g.lineTo(-6, 16); g.moveTo(6, 5); g.quadraticCurveTo(14, 18, 4, 16); g.stroke(); } },
+ cartouche: { h: 74, cols: [C.black, C.red], d(g) { g.beginPath(); g.ellipse(0, -2, 15, 31, 0, 0, 7); g.stroke(); g.beginPath(); g.moveTo(-14, 33); g.lineTo(14, 33); g.stroke(); g.lineWidth = 2; g.beginPath(); g.arc(0, -18, 5, 0, 7); g.moveTo(-7, -2); g.lineTo(7, -2); g.moveTo(-6, 8); g.lineTo(-3, 13); g.lineTo(0, 8); g.lineTo(3, 13); g.lineTo(6, 8); g.stroke(); } },
+ scarab: { h: 46, cols: [C.blue, C.black], d(g) { g.beginPath(); g.ellipse(0, 6, 10, 14, 0, 0, 7); g.fill(); g.beginPath(); g.arc(0, -11, 6, 0, 7); g.fill(); g.beginPath(); for (const s of [-1, 1]) for (const k of [-1, 0, 1]) { g.moveTo(s * 9, 6 + k * 8); g.lineTo(s * 17, 2 + k * 11); } g.stroke(); } },
+ seated: { h: 58, cols: [C.red, C.black, C.blue], d(g) { g.beginPath(); g.arc(-2, -21, 6.5, 0, 7); g.fill(); poly(g, [[-6, -13], [4, -13], [6, 6], [16, 8], [17, 18], [-10, 18], [-10, 2]]); g.fill(); g.beginPath(); g.moveTo(-6, -8); g.lineTo(-17, -16); g.stroke(); g.beginPath(); g.moveTo(-14, 26); g.lineTo(18, 26); g.stroke(); } },
+ leg: { h: 50, cols: [C.green, C.black, C.red], d(g) { poly(g, [[-3, -24], [6, -24], [6, 18], [16, 22], [16, 26], [-4, 26]]); g.stroke(); } },
+ arm: { h: 24, cols: [C.black, C.red], d(g) { poly(g, [[-22, -4], [10, -4], [16, -8], [22, -6], [16, 2], [-22, 4]]); g.stroke(); } },
+ basket: { h: 26, cols: [C.blue, C.green, C.black], d(g) { g.beginPath(); g.moveTo(-20, -4); g.lineTo(20, -4); g.quadraticCurveTo(18, 12, 0, 12); g.quadraticCurveTo(-18, 12, -20, -4); g.stroke(); g.beginPath(); g.arc(22, 2, 5, -1.5, 1.6); g.stroke(); } },
+ house: { h: 36, cols: [C.black, C.red], d(g) { g.beginPath(); g.moveTo(-6, 14); g.lineTo(-18, 14); g.lineTo(-18, -14); g.lineTo(18, -14); g.lineTo(18, 14); g.lineTo(6, 14); g.stroke(); } },
+ strokes: { h: 34, cols: [C.red, C.black], d(g) { g.beginPath(); for (const x of [-8, 0, 8]) { g.moveTo(x, -14); g.lineTo(x, 14); } g.stroke(); } },
+ feather: { h: 60, cols: [C.blue, C.green, C.black], d(g) { g.beginPath(); g.moveTo(-2, 29); g.quadraticCurveTo(-8, -10, 4, -29); g.quadraticCurveTo(12, -18, 6, 0); g.quadraticCurveTo(3, 15, 2, 29); g.stroke(); } },
+ djed: { h: 62, cols: [C.blue, C.green], d(g) { g.beginPath(); g.moveTo(-6, 29); g.lineTo(-6, -10); g.moveTo(6, 29); g.lineTo(6, -10); for (let k = 0; k < 4; k++) { g.moveTo(-13, -12 - k * 5); g.lineTo(13, -12 - k * 5); } g.moveTo(-12, 29); g.lineTo(12, 29); g.stroke(); } },
+ shen: { h: 42, cols: [C.red, C.blue], d(g) { g.beginPath(); g.arc(0, -4, 13, 0, 7); g.stroke(); g.beginPath(); g.moveTo(-14, 13); g.lineTo(14, 13); g.stroke(); } },
+ jug: { h: 50, cols: [C.red, C.green, C.blue], d(g) { g.beginPath(); g.moveTo(-6, -22); g.lineTo(6, -22); g.lineTo(5, -14); g.quadraticCurveTo(16, -6, 12, 12); g.quadraticCurveTo(8, 22, 0, 22); g.quadraticCurveTo(-8, 22, -12, 12); g.quadraticCurveTo(-16, -6, -5, -14); g.closePath(); g.stroke(); g.beginPath(); g.moveTo(-10, 0); g.lineTo(10, 0); g.stroke(); } },
+ lotus: { h: 56, cols: [C.green, C.blue], d(g) { g.beginPath(); g.moveTo(0, 27); g.lineTo(0, -6); g.stroke(); poly(g, [[0, -6], [-12, -18], [-6, -26], [0, -16], [6, -26], [12, -18]]); g.stroke(); } },
+ nfr: { h: 56, cols: [C.black, C.red], d(g) { g.beginPath(); g.ellipse(0, 12, 10, 14, 0, 0, 7); g.moveTo(0, -2); g.lineTo(0, -26); g.moveTo(-6, -18); g.lineTo(6, -18); g.moveTo(-6, -12); g.lineTo(6, -12); g.stroke(); } },
+ mouth: { h: 20, cols: [C.red], d(g) { g.beginPath(); g.moveTo(-18, 0); g.quadraticCurveTo(0, -9, 18, 0); g.quadraticCurveTo(0, 9, -18, 0); g.stroke(); } },
+ water: { h: 30, cols: [C.blue], water: true, d(g, ph = 0) { g.lineWidth = 2.6; for (let r = -1; r <= 1; r++) { g.beginPath(); for (let i = 0; i <= 16; i++) { const x = -21 + i * 2.625, y = r * 9 + ((i + ph) % 2 < 1 ? -3 : 3); i ? g.lineTo(x, y) : g.moveTo(x, y); } g.stroke(); } } },
+ };
+ const GN = Object.keys(GL);
+ // 栏位:[分栏线 x 列表, y0, y1](照原片量的位置)
+ const GROUPS = [[[78, 154, 230, 306], 66, 566], [[852, 932, 1012, 1092, 1172], 66, 452], [[1560, 1637, 1713, 1790, 1866], 252, 882], [[298, 366], 614, 886]];
+ const GLYPHS = (() => { // 种子化排布,模块初始化时算好(水纹字要单独动起来,需要知道位置)
+ const r = U.rng(1350), out = [];
+ GROUPS.forEach(([xs, y0, y1]) => { for (let k = 0; k < xs.length - 1; k++) {
+ const used = {};
+ const cx = (xs[k] + xs[k + 1]) / 2; let y = y0 + 8, prev = '';
+ while (true) {
+ let n; do { n = GN[(r() * GN.length) | 0]; } while (n === prev || used[n] > 2 || ((n === 'scarab' || n === 'water') && r() < 0.6)); prev = n; used[n] = (used[n] || 0) + 1;
+ const gl = GL[n], s = (xs[k + 1] - xs[k]) / 78 * (1.0 + r() * 0.14);
+ if (y + gl.h * s > y1) break;
+ out.push({ n, x: cx + (r() - 0.5) * 4, y: y + gl.h * s / 2, s, col: gl.cols[(r() * gl.cols.length) | 0], ph: r() * 2 });
+ y += gl.h * s + 6 + r() * 5;
+ }
+ } });
+ // 保证有 ≥6 个水纹字(它们是会流动的那批),不够就把扁字形换成水纹
+ let nw = out.filter(q => q.n === 'water').length;
+ for (const q of out) { if (nw >= 6) break; if (['mouth', 'bread', 'basket', 'arm', 'strokes'].includes(q.n)) { q.n = 'water'; q.col = C.blue; nw++; } }
+ return out;
+ })();
+ const drawGlyph = (g, q, ph = 0, rv = 1) => { g.save(); g.translate(q.x, q.y); g.scale(q.s, q.s); g.strokeStyle = q.col; g.fillStyle = q.col; g.lineWidth = 3.1; g.lineCap = 'round'; g.lineJoin = 'round';
+ if (rv < 1) { g.setLineDash([Math.max(0.01, rv * 95), 999]); if (rv < 0.55) g.fillStyle = 'rgba(0,0,0,0)'; }
+ GL[q.n].d(g, ph); g.restore(); };
+ // 「铭文被写出来」:每 0.12s 从打乱的字表里取 4 个字(分散在各栏),擦掉→按笔画描出(dash 揭示),笔迹先是亮金再落回原色
+ const WRITERS = (() => { const r = U.rng(77), idx = GLYPHS.map((q, i) => i).filter(i => !GL[GLYPHS[i].n].water); for (let i = idx.length - 1; i > 0; i--) { const j = (r() * (i + 1)) | 0; [idx[i], idx[j]] = [idx[j], idx[i]]; } return idx; })();
+ const WRITE_SLOT = 0.12, WRITE_DUR = 0.36, WRITE_N = 6;
+ function writeGlyphs(c, lt) {
+ const wall = P.texture('eg_wall', C.wall), s0 = Math.floor(lt / WRITE_SLOT);
+ for (let s = Math.max(0, s0 - 2); s <= s0; s++) for (let m = 0; m < WRITE_N; m++) {
+ const q = GLYPHS[WRITERS[(s * WRITE_N + m) % WRITERS.length]], p = clamp((lt - s * WRITE_SLOT) / WRITE_DUR);
+ if (p >= 1) continue;
+ const w = 64 * q.s, h = (GL[q.n].h + 10) * q.s, x0 = q.x - w / 2, y0 = q.y - h / 2;
+ c.drawImage(wall, x0, y0, w, h, x0, y0, w, h);
+ const glow = 1 - p, col = P.rgb(P.mix(P.hex(q.col), [246, 200, 70], glow * 0.85));
+ c.save(); c.shadowColor = `rgba(255,200,80,${0.9 * glow})`; c.shadowBlur = 10 * glow;
+ drawGlyph(c, { ...q, col }, q.ph, Math.min(1, p * 1.35));
+ c.restore();
+ }
+ }
+
+ // ---------------- 彩色几何边框 ----------------
+ function blocks(g, x0, y0, x1, y1, len, off = 0) { // 沿长边排彩块,块间米白细缝,外框黑线
+ const hor = (x1 - x0) > (y1 - y0), L = hor ? x1 - x0 : y1 - y0;
+ g.fillStyle = C.cream; g.fillRect(x0, y0, x1 - x0, y1 - y0);
+ for (let s = 0, k = off; s < L; s += len, k++) {
+ g.fillStyle = BAND[k % 4];
+ if (hor) g.fillRect(x0 + s + 3, y0 + 3, Math.min(len - 6, L - s - 3), y1 - y0 - 6); else g.fillRect(x0 + 3, y0 + s + 3, x1 - x0 - 6, Math.min(len - 6, L - s - 3));
+ g.fillStyle = C.black; if (hor) g.fillRect(x0 + s, y0, 2, y1 - y0); else g.fillRect(x0, y0 + s, x1 - x0, 2);
+ }
+ g.strokeStyle = C.black; g.lineWidth = 2; g.strokeRect(x0, y0, x1 - x0, y1 - y0);
+ }
+
+ // ---------------- 静态层 ----------------
+ const DISK = [580, 266];
+ function staticLayer(g) {
+ // 灰泥墙:底色+斑驳+颗粒
+ g.drawImage(P.texture('eg_wall', C.wall, { scale: 0.0035, amt: 16, grain: 12, dark: C.wall2, seed: 13 }), 0, 0);
+ // 象形文字栏:分栏红线+字形
+ g.lineCap = 'round';
+ GROUPS.forEach(([xs, y0, y1]) => xs.forEach(x => { g.strokeStyle = C.rule; g.lineWidth = 2.6; g.beginPath(); g.moveTo(x, y0); g.lineTo(x, y1); g.stroke(); }));
+ GLYPHS.forEach(q => { if (!GL[q.n].water) drawGlyph(g, q); });
+ // —— 窗 ——
+ // 檐口(cavetto):上宽下窄的竖条纹弧面
+ const top = [338, 822], bot = [362, 798], cy0 = 128, cy1 = 172, st = [C.blue, C.white, C.red, C.white, C.green, C.white];
+ const n = 30;
+ for (let i = 0; i < n; i++) {
+ const a = i / n, b = (i + 1) / n;
+ poly(g, [[lerp(top[0], top[1], a), cy0], [lerp(top[0], top[1], b), cy0], [lerp(bot[0], bot[1], b), cy1], [lerp(bot[0], bot[1], a), cy1]]);
+ g.fillStyle = st[i % 6]; g.fill();
+ }
+ g.strokeStyle = C.black; g.lineWidth = 1.5;
+ for (let i = 0; i <= n; i++) { const a = i / n; g.beginPath(); g.moveTo(lerp(top[0], top[1], a), cy0); g.lineTo(lerp(bot[0], bot[1], a), cy1); g.stroke(); }
+ // 檐口内凹的阴影(上部暗一点)
+ const cg = g.createLinearGradient(0, cy0, 0, cy1); cg.addColorStop(0, 'rgba(40,20,10,.28)'); cg.addColorStop(0.5, 'rgba(40,20,10,0)'); g.fillStyle = cg;
+ poly(g, [[top[0], cy0], [top[1], cy0], [bot[1], cy1], [bot[0], cy1]]); g.fill();
+ g.fillStyle = C.gold; g.fillRect(334, 118, 492, 11); g.strokeStyle = C.black; g.lineWidth = 2; g.strokeRect(334, 118, 492, 11);
+ g.fillStyle = C.gold; g.fillRect(358, 172, 444, 13); g.strokeRect(358, 172, 444, 13);
+ g.fillStyle = C.goldD; for (let x = 364; x < 798; x += 14) g.fillRect(x, 175, 6, 7);
+ // 窗框:彩块(左、右、下)+顶部蓝带
+ blocks(g, 378, 185, 408, 560, 40, 1); blocks(g, 772, 185, 802, 560, 40, 3); blocks(g, 378, 530, 802, 560, 40, 0);
+ g.fillStyle = C.blue; g.fillRect(408, 185, 364, 15); g.strokeStyle = C.black; g.strokeRect(408, 185, 364, 15);
+ // 窗内:白底(略带灰泥纹)
+ g.fillStyle = '#f2ede1'; g.fillRect(408, 200, 364, 330);
+ g.globalAlpha = 0.25; g.drawImage(P.texture('eg_wall', C.wall), 408, 200, 364, 330, 408, 200, 364, 330); g.globalAlpha = 1;
+ g.fillStyle = C.blue; g.fillRect(408, 200, 364, 9); g.fillRect(762, 200, 10, 30); poly(g, [[740, 209], [772, 209], [772, 222]]); g.fill();
+ g.strokeStyle = C.black; g.lineWidth = 2; g.strokeRect(408, 200, 364, 330);
+ // 阿顿日盘+圣蛇+安卡
+ g.beginPath(); g.arc(DISK[0], DISK[1], 46, 0, 7); g.fillStyle = '#c8372b'; g.fill(); g.lineWidth = 3; g.strokeStyle = '#7a1c14'; g.stroke();
+ g.beginPath(); g.arc(DISK[0], DISK[1], 38, 0, 7); g.strokeStyle = 'rgba(255,200,150,.35)'; g.lineWidth = 2; g.stroke();
+ g.fillStyle = C.gold; g.beginPath(); g.ellipse(580, 300, 7, 10, 0, 0, 7); g.fill(); g.strokeStyle = C.black; g.lineWidth = 1.6; g.stroke();
+ g.beginPath(); g.moveTo(580, 290); g.quadraticCurveTo(592, 305, 580, 318); g.lineWidth = 4; g.strokeStyle = C.gold; g.stroke();
+ drawGlyph(g, { n: 'ankh', x: 580, y: 332, s: 0.42, col: C.blue });
+ // —— 左侧尖底陶罐 ×2,桌边小罐 ——
+ jar(g, 108, 644, 1); jar(g, 212, 644, 1); jar(g, 886, 714, 0.72);
+ // —— 供桌 ——
+ poly(g, [[975, 660], [962, 702], [984, 748], [984, 792], [950, 862], [930, 900], [1090, 900], [1070, 862], [1036, 792], [1036, 748], [1058, 702], [1045, 660]]); fs(g, C.white, C.line, 2.5);
+ g.save(); g.clip(); g.fillStyle = C.blue; g.fillRect(940, 752, 140, 10); g.fillStyle = C.red; g.fillRect(940, 768, 140, 10); g.restore();
+ g.strokeStyle = 'rgba(140,110,80,.5)'; g.lineWidth = 1.5; g.beginPath(); g.moveTo(1000, 800); g.quadraticCurveTo(990, 850, 960, 890); g.stroke();
+ g.fillStyle = C.white; g.fillRect(820, 640, 380, 20); g.strokeStyle = C.line; g.lineWidth = 2.5; g.strokeRect(820, 640, 380, 20);
+ g.strokeStyle = C.red; g.lineWidth = 2; g.beginPath(); g.moveTo(824, 655); g.lineTo(1196, 655); g.stroke();
+ // 供品:白圆锥面包、金碟、蓝葡萄、绿荷叶盘
+ poly(g, [[836, 640], [844, 590], [852, 568], [860, 590], [870, 640]]); fs(g, C.white, C.line, 2.2);
+ g.beginPath(); g.moveTo(870, 640); g.quadraticCurveTo(872, 604, 908, 602); g.quadraticCurveTo(944, 604, 946, 640); g.closePath(); fs(g, C.gold, C.line, 2.2);
+ g.beginPath(); g.arc(908, 626, 5, 0, 7); g.strokeStyle = C.goldD; g.lineWidth = 2; g.stroke();
+ [[892, 600], [906, 600], [920, 600], [899, 587], [913, 587], [906, 574], [885, 588], [927, 588], [892, 575], [920, 575], [906, 561]].forEach(([x, y]) => { g.beginPath(); g.arc(x, y, 8, 0, 7); fs(g, '#2c4aa0', '#141a3a', 1.5); g.fillStyle = 'rgba(160,190,255,.6)'; g.beginPath(); g.arc(x - 2.5, y - 2.5, 2.2, 0, 7); g.fill(); });
+ g.beginPath(); g.ellipse(888, 541, 52, 9, 0, 0, 7); fs(g, C.green, C.line, 2); g.strokeStyle = '#1f6a40'; g.lineWidth = 1.5; g.beginPath(); g.moveTo(842, 541); g.lineTo(934, 541); g.stroke();
+ // —— 椅子(金色细腿椅,椅背红蓝块) ——
+ chair(g);
+ // 脚边蓝碗
+ g.beginPath(); g.moveTo(1342, 878); g.lineTo(1418, 878); g.quadraticCurveTo(1412, 900, 1380, 900); g.quadraticCurveTo(1348, 900, 1342, 878); fs(g, '#3a78c8', C.line, 2);
+ g.beginPath(); g.ellipse(1380, 878, 38, 5, 0, 0, 7); fs(g, '#8cc0ee', C.line, 1.6);
+ // —— 地线与底部多层饰带 ——
+ g.fillStyle = C.black; g.fillRect(0, 898, W, 6);
+ g.fillStyle = C.cream; g.fillRect(0, 904, W, 106);
+ blocks(g, -20, 914, W + 20, 948, 64, 0);
+ g.fillStyle = C.yellow; g.fillRect(0, 961, W, 15); g.fillStyle = C.red; g.fillRect(0, 984, W, 14);
+ g.fillStyle = C.black; [912, 960, 977, 983, 999, 1008].forEach(y => g.fillRect(0, y, W, 1.6));
+ // 深蓝带(细颗粒)
+ g.fillStyle = C.navy; g.fillRect(0, 1010, W, 70);
+ const r = U.rng(7); for (let i = 0; i < 2600; i++) { g.fillStyle = r() < 0.5 ? 'rgba(90,100,140,.35)' : 'rgba(5,8,20,.45)'; g.fillRect(r() * W, 1010 + r() * 70, 1 + r() * 2, 1 + r() * 2); }
+ // —— 顶部与两侧彩色边框 ——
+ blocks(g, -10, 6, W + 10, 40, 56, 2);
+ blocks(g, 32, 40, 58, 898, 46, 1); blocks(g, 1890, 40, 1916, 898, 46, 3);
+ }
+ function jar(g, cx, y0, s) {
+ g.save(); g.translate(cx, y0); g.scale(s, s);
+ // 支架(X 形白腿)
+ g.strokeStyle = C.line; g.lineWidth = 2.5; g.fillStyle = C.white;
+ poly(g, [[-26, 256], [-20, 256], [10, 196], [4, 196]]); fs(g, C.white, C.line, 2); poly(g, [[26, 256], [20, 256], [-10, 196], [-4, 196]]); fs(g, C.white, C.line, 2);
+ g.fillRect(-24, 198, 48, 6); g.strokeRect(-24, 198, 48, 6);
+ // 罐身:圆肩、尖底
+ g.beginPath(); g.moveTo(-10, 30); g.bezierCurveTo(-40, 50, -38, 120, -20, 180); g.quadraticCurveTo(-6, 222, 0, 228); g.quadraticCurveTo(6, 222, 20, 180); g.bezierCurveTo(38, 120, 40, 50, 10, 30); g.closePath(); fs(g, C.terra, C.line, 2.5);
+ g.save(); g.clip();
+ g.fillStyle = C.green; g.fillRect(-40, 52, 80, 6); g.fillStyle = C.blue; g.fillRect(-40, 58, 80, 4);
+ g.fillStyle = '#2f9a8a'; for (let x = -36; x < 36; x += 9) { poly(g, [[x, 62], [x + 9, 62], [x + 4.5, 82]]); g.fill(); }
+ g.strokeStyle = 'rgba(80,40,20,.6)'; g.lineWidth = 1.6; [[150], [158]].forEach(([y]) => { g.beginPath(); g.moveTo(-40, y); g.lineTo(40, y); g.stroke(); });
+ g.fillStyle = 'rgba(255,230,200,.25)'; g.beginPath(); g.ellipse(-14, 110, 6, 40, 0, 0, 7); g.fill();
+ g.restore();
+ // 颈与盖
+ g.fillStyle = C.terra; g.fillRect(-9, 18, 18, 14); g.strokeStyle = C.line; g.lineWidth = 2; g.strokeRect(-9, 18, 18, 14);
+ g.beginPath(); g.moveTo(-14, 20); g.quadraticCurveTo(-14, -6, 0, -6); g.quadraticCurveTo(14, -6, 14, 20); g.closePath(); fs(g, '#3a302a', C.line, 2);
+ g.restore();
+ }
+ function chair(g) {
+ g.lineJoin = 'round';
+ // 后腿、前腿(收腰的金腿+红白条纹狮爪座)
+ const leg = (x) => { g.beginPath(); g.moveTo(x - 9, 748); g.bezierCurveTo(x - 16, 790, x - 4, 830, x - 12, 872); g.lineTo(x + 12, 872); g.bezierCurveTo(x + 4, 830, x + 16, 790, x + 9, 748); g.closePath(); fs(g, C.gold, C.line, 2.4);
+ g.fillStyle = C.white; g.fillRect(x - 16, 872, 32, 26); g.strokeStyle = C.line; g.lineWidth = 2; g.strokeRect(x - 16, 872, 32, 26); g.fillStyle = C.red; g.fillRect(x - 16, 878, 32, 5); g.fillRect(x - 16, 888, 32, 5); };
+ leg(1458); leg(1312);
+ // 座下竖栏+横档
+ g.fillStyle = C.gold; for (let x = 1330; x < 1446; x += 20) { g.fillRect(x, 750, 7, 54); g.strokeStyle = C.line; g.lineWidth = 1.4; g.strokeRect(x, 750, 7, 54); }
+ g.fillRect(1300, 802, 170, 8); g.strokeRect(1300, 802, 170, 8);
+ // 椅背:竖柱(红蓝块)
+ g.beginPath(); g.moveTo(1476, 742); g.lineTo(1478, 478); g.quadraticCurveTo(1480, 458, 1492, 458); g.quadraticCurveTo(1504, 460, 1500, 478); g.lineTo(1498, 742); g.closePath(); fs(g, C.gold, C.line, 2.4);
+ for (let k = 0; k < 9; k++) { g.fillStyle = k % 2 ? C.blue : C.red; g.fillRect(1483, 494 + k * 28, 10, 13); }
+ // 座面
+ g.fillStyle = C.gold; g.fillRect(1292, 734, 210, 16); g.strokeStyle = C.line; g.lineWidth = 2.4; g.strokeRect(1292, 734, 210, 16);
+ g.fillStyle = C.red; for (let x = 1300; x < 1496; x += 24) g.fillRect(x, 739, 10, 6);
+ }
+
+ // ---------------- 壁画表面:斑驳(multiply)+裂纹+颗粒 ----------------
+ const surface = () => P.cached('eg_surface', W, H, (g) => {
+ const img = g.createImageData(W, H), d = img.data, r = U.rng(99);
+ for (let y = 0; y < H; y += 2) for (let x = 0; x < W; x += 2) {
+ const n = P.fbm(x * 0.006 + 40, y * 0.006, 4), m = P.fbm(x * 0.03, y * 0.03 + 9, 2);
+ const v = 243 + n * 30 + m * 12 + (r() - 0.5) * 18;
+ for (const [dx, dy] of [[0, 0], [1, 0], [0, 1], [1, 1]]) { const i = ((y + dy) * W + x + dx) * 4; d[i] = v; d[i + 1] = v - 6; d[i + 2] = v - 16; d[i + 3] = 255; }
+ }
+ g.putImageData(img, 0, 0);
+ // 发丝裂纹(墙面老化,跨过人物)
+ const rr = U.rng(5);
+ [[0, 610, 0.1], [700, 0, 1.3], [1210, 0, 1.1], [1500, 980, -0.9], [380, 1080, -1.2], [1920, 420, 2.9]].forEach(([x, y, a0]) => {
+ g.strokeStyle = 'rgba(90,70,50,.55)'; g.lineWidth = 1.1; let a = a0;
+ g.beginPath(); g.moveTo(x, y); for (let s = 0; s < 34; s++) { a += (rr() - 0.5) * 0.7; x += Math.cos(a) * 14; y += Math.sin(a) * 14; g.lineTo(x, y); if (rr() < 0.08) { g.moveTo(x, y); } } g.stroke();
+ });
+ });
+ const specks = () => P.grain('eg_specks', 0.018, [70, 50, 30], 0.4);
+
+ // ---------------- 阿顿光线:末端小手一张一合 ----------------
+ const HANDS = [[444, 322], [436, 358], [428, 402], [440, 462], [446, 508], [492, 512], [538, 498], [612, 470], [680, 452], [712, 424], [732, 390], [746, 356], [748, 326]];
+ function handAt(g, x, y, ang, open, col = '#b4452c') {
+ g.save(); g.translate(x, y); g.rotate(ang);
+ g.fillStyle = col; g.strokeStyle = '#5a1c10'; g.lineWidth = 1.3;
+ g.scale(1.35, 1.35);
+ g.lineCap = 'round'; g.lineWidth = 4.2;
+ g.scale(0.9 + 0.3 * open, 0.9 + 0.3 * open);
+ for (let k = 0; k < 4; k++) { const a = (k - 1.5) * (0.03 + open * 0.42); g.beginPath(); g.moveTo(Math.cos(a) * 5, Math.sin(a) * 5); g.lineTo(Math.cos(a) * (12.5 + open * 1.5), Math.sin(a) * (12.5 + open * 1.5)); g.strokeStyle = '#5a1c10'; g.lineWidth = 5.6; g.stroke(); g.strokeStyle = col; g.lineWidth = 3.4; g.stroke(); }
+ g.beginPath(); g.moveTo(1, -5); g.lineTo(5, -10 - open * 3); g.strokeStyle = '#5a1c10'; g.lineWidth = 5.4; g.stroke(); g.strokeStyle = col; g.lineWidth = 3.2; g.stroke();
+ g.beginPath(); g.ellipse(0, 0, 8, 6.6, 0, 0, 7); g.fillStyle = col; g.fill(); g.strokeStyle = '#5a1c10'; g.lineWidth = 1.2; g.stroke();
+ g.beginPath(); g.moveTo(-9, 0); g.lineTo(-14, 0); g.strokeStyle = col; g.lineWidth = 4; g.stroke(); // 手腕
+ g.restore();
+ }
+ function rays(c, lt, t) {
+ c.save(); c.lineCap = 'round';
+ // 日盘脉动光晕(周期 0.45s)
+ const pu = 0.5 + 0.5 * Math.sin(lt * Math.PI * 2 / 0.45);
+ c.save(); c.beginPath(); c.rect(408, 200, 364, 330); c.clip();
+ const hg = c.createRadialGradient(DISK[0], DISK[1], 46, DISK[0], DISK[1], 70 + 30 * pu); hg.addColorStop(0, `rgba(255,180,80,${0.5 * pu + 0.12})`); hg.addColorStop(1, 'rgba(255,170,70,0)');
+ c.fillStyle = hg; c.beginPath(); c.arc(DISK[0], DISK[1], 100 + 30 * pu, 0, 7); c.fill();
+ c.beginPath(); c.arc(DISK[0], DISK[1], 52 + 6 * pu, 0, 7); c.strokeStyle = `rgba(255,214,110,${0.75 * pu})`; c.lineWidth = 5; c.stroke();
+ c.beginPath(); c.arc(DISK[0], DISK[1], 46, 0, 7); c.fillStyle = '#c8372b'; c.fill(); c.lineWidth = 3; c.strokeStyle = '#7a1c14'; c.stroke();
+ c.fillStyle = C.gold; c.beginPath(); c.ellipse(580, 300, 7, 10, 0, 0, 7); c.fill(); c.strokeStyle = C.black; c.lineWidth = 1.6; c.stroke();
+ c.restore();
+ const ray = (ex0, ey0, k, long) => {
+ // 光线沿扇形依次伸缩(波沿 k 传播),末端 ±9%
+ const ext = 1 + 0.09 * Math.sin(lt * Math.PI * 2 / 0.45 - k * 0.55);
+ let ex = DISK[0] + (ex0 - DISK[0]) * ext, ey = DISK[1] + (ey0 - DISK[1]) * ext; if (!long) { ex = clamp(ex, 428, 752); ey = Math.min(ey, 512); }
+ const wob = Math.sin(t * 7 + k * 1.3) * 3, wx = ex + wob, wy = ey + Math.cos(t * 6 + k) * 2;
+ const ang = Math.atan2(wy - DISK[1], wx - DISK[0]);
+ c.strokeStyle = '#c23a2a'; c.lineWidth = (long ? 2.6 : 2.2) + 1.6 * (ext - 0.91) / 0.18;
+ c.beginPath(); c.moveTo(DISK[0] + Math.cos(ang) * 44, DISK[1] + Math.sin(ang) * 44); c.lineTo(wx - Math.cos(ang) * 6, wy - Math.sin(ang) * 6); c.stroke();
+ const open = 0.5 + 0.5 * Math.sin(lt * Math.PI * 2 / 0.4 + k * 0.9);
+ handAt(c, wx, wy, ang, open);
+ return [wx, wy, ang];
+ };
+ c.save(); c.beginPath(); c.rect(408, 200, 364, 330); c.clip();
+ HANDS.forEach(([x, y], k) => ray(x, y, k, false));
+ c.restore();
+ // 两条长光线的窗内段(窗外段与小手在画猫之后补,压在猫上)
+ LONG.forEach(([x, y, k]) => { const wx = x + Math.sin(t * 7 + k * 1.3) * 3, wy = y + Math.cos(t * 6 + k) * 2, ang = Math.atan2(wy - DISK[1], wx - DISK[0]);
+ c.strokeStyle = '#c23a2a'; c.lineWidth = 2.6; c.beginPath(); c.moveTo(DISK[0] + Math.cos(ang) * 44, DISK[1] + Math.sin(ang) * 44); c.lineTo(lerp(DISK[0], wx, 0.64), lerp(DISK[1], wy, 0.64)); c.stroke(); });
+ c.restore();
+ }
+
+ // ---------------- 圣甲虫推日球 ----------------
+ function scarab(c, lt) {
+ let x = 800 + 642 * (lt - 0.394); x = ((x + 120) % 2160 + 2160) % 2160 - 120;
+ const y = 1044, bx = x + 54, br = 23, rot = bx / br, pose = Math.floor(lt * 15) % 2;
+ c.save(); c.lineCap = 'round'; c.lineJoin = 'round';
+ c.translate(x + 27, y); c.scale(1.22, 1.22); c.translate(-x - 27, -y);
+ // 日球:红底黄点,随前进滚动
+ c.beginPath(); c.arc(bx, y - 2, br, 0, 7); c.fillStyle = '#c8302a'; c.fill(); c.strokeStyle = '#3a0c08'; c.lineWidth = 2.2; c.stroke();
+ c.save(); c.clip(); c.fillStyle = '#f2c23a';
+ for (let k = 0; k < 9; k++) { const a = rot + k * 0.698, rr = k % 3 === 0 ? 0 : 14; const px = bx + Math.cos(a) * rr, py = y - 2 + Math.sin(a) * rr * 0.9; if (k % 3 === 0 && k) continue; c.beginPath(); c.arc(px, py, 3.6, 0, 7); c.fill(); }
+ c.restore();
+ // 腿:两套姿态,每 4 帧(60fps)换一次
+ c.strokeStyle = '#141a30'; c.lineWidth = 3;
+ const legs = pose ? [[-14, -16, -26], [0, -18, -6], [14, -14, 18]] : [[-14, -14, -32], [0, -19, 2], [14, -18, 24]];
+ legs.forEach(([lx, ly, ex], i) => { for (const s of [-1, 1]) { const q = s * (i === 1 ? 1 : (pose ? 1 : -1)); c.beginPath(); c.moveTo(x + lx, y); c.lineTo(x + lx + (ex - lx) * 0.5, y + s * (ly - 4)); c.lineTo(x + ex + q * 2, y + s * (ly + 4)); c.stroke(); } });
+ // 前足顶着球
+ c.beginPath(); c.moveTo(x + 26, y - 4); c.lineTo(bx - br + 2, y - 12 + pose * 3); c.moveTo(x + 26, y + 4); c.lineTo(bx - br + 1, y + 8 - pose * 3); c.stroke();
+ // 身体:青金石蓝+绿松石鞘翅高光
+ c.beginPath(); c.ellipse(x - 4, y, 24, 17, 0, 0, 7); c.fillStyle = C.lapis; c.fill(); c.strokeStyle = '#0d1430'; c.lineWidth = 2.2; c.stroke();
+ c.beginPath(); c.moveTo(x - 28, y); c.lineTo(x + 18, y); c.stroke();
+ c.fillStyle = C.turq; c.beginPath(); c.ellipse(x - 8, y - 8, 12, 4, -0.1, 0, 7); c.fill(); c.beginPath(); c.ellipse(x - 8, y + 8, 12, 4, 0.1, 0, 7); c.fill();
+ c.beginPath(); c.ellipse(x + 22, y, 8, 11, 0, 0, 7); c.fillStyle = '#3a68c4'; c.fill(); c.strokeStyle = '#0d1430'; c.stroke();
+ c.fillStyle = C.gold; c.beginPath(); c.arc(x + 25, y, 3, 0, 7); c.fill();
+ c.restore();
+ }
+
+ // ---------------- 巴斯特坐姿的橘白猫 ----------------
+ const CAT_S = 0.85, CAT_ANCHOR = [540, 898];
+ const catPt = (x, y) => [CAT_ANCHOR[0] + (x - CAT_ANCHOR[0]) * CAT_S, CAT_ANCHOR[1] + (y - CAT_ANCHOR[1]) * CAT_S];
+ const LONG = [[...catPt(540, 676), 20], [...catPt(668, 626), 21]]; // 两条长光线的末端:跟着猫头缩放
+ function cat(c, K, ch) {
+ const L = C.line, hc = K.headC, br = ch.breathe * 260;
+ const B = (x, y) => [x, y - (y < 800 ? br * (800 - y) / 130 : 0)];
+ c.save(); c.lineJoin = 'round'; c.lineCap = 'round';
+ // 以脚底 (540,898) 为锚整体缩到 0.85:耳尖从 y≈530 落到 ≈585,和窗框底边(y≈560)留出空隙
+ c.translate(CAT_ANCHOR[0], CAT_ANCHOR[1]); c.scale(CAT_S, CAT_S); c.translate(-CAT_ANCHOR[0], -CAT_ANCHOR[1]);
+ // 尾巴:从臀后绕向身前
+ const tp = K.tailPts;
+ c.strokeStyle = L; c.lineWidth = 24; c.beginPath(); tp.forEach((p, i) => i ? c.lineTo(p[0], p[1] - 4) : c.moveTo(p[0], p[1] - 4)); c.stroke();
+ c.strokeStyle = C.catO; c.lineWidth = 19; c.stroke();
+ c.strokeStyle = C.catS; c.lineWidth = 4;
+ for (let i = 3; i < tp.length - 3; i += 3) { const a = tp[i], b = tp[i + 1], ang = Math.atan2(b[1] - a[1], b[0] - a[0]) + Math.PI / 2; c.beginPath(); c.moveTo(a[0] + Math.cos(ang) * 8, a[1] - 4 + Math.sin(ang) * 8); c.lineTo(a[0] - Math.cos(ang) * 8, a[1] - 4 - Math.sin(ang) * 8); c.stroke(); }
+ const tip = tp[tp.length - 1]; c.fillStyle = C.catW; c.beginPath(); c.arc(tip[0], tip[1] - 4, 9, 0, 7); c.fill(); c.strokeStyle = L; c.lineWidth = 2; c.beginPath(); c.arc(tip[0], tip[1] - 4, 10.5, -1.2, 1.9); c.stroke();
+ // 身体:挺直上身、圆臀;前腿并在剪影里(胸口到前爪一整片白)
+ const body = sm([[568, 666], [538, 690], [506, 726], [482, 772], [468, 818], [464, 860], [474, 897], [560, 899], [666, 899], [663, 862], [659, 800], [654, 744], [646, 706], [640, 680]].map(p => B(...p)));
+ const cw = sm([B(616, 688), B(640, 678), B(650, 716), B(656, 790), [661, 860], [666, 899], [598, 899], [600, 850], [604, 790], B(610, 736)]);
+ c.fillStyle = C.catO; c.fill(body);
+ c.save(); c.clip(body);
+ c.fillStyle = C.catW; c.fill(cw);
+ c.strokeStyle = C.catS; c.lineWidth = 6;
+ [[[548, 690], [532, 716]], [[524, 704], [508, 736]], [[500, 730], [484, 766]], [[480, 764], [466, 800]], [[464, 806], [456, 840]], [[558, 716], [542, 748]], [[536, 744], [520, 780]], [[512, 776], [498, 812]], [[578, 742], [566, 770]]].forEach(([a, b]) => { c.beginPath(); c.moveTo(...B(...a)); c.quadraticCurveTo(a[0] - 14, (a[1] + b[1]) / 2, ...B(...b)); c.stroke(); });
+ // 后腿(大腿弧)+腿上条纹
+ c.strokeStyle = C.catS; c.lineWidth = 5; [[496, 850, 512, 826], [520, 836, 536, 812], [546, 830, 560, 810], [568, 836, 578, 818]].forEach(([a, b, x2, y2]) => { c.beginPath(); c.moveTo(a, b); c.lineTo(x2, y2); c.stroke(); });
+ c.strokeStyle = L; c.lineWidth = 2.6; c.beginPath(); c.moveTo(492, 897); c.bezierCurveTo(484, 830, 552, 796, 598, 852); c.stroke();
+ // 两条前腿的分界、前爪趾线
+ c.lineWidth = 2.2; c.beginPath(); c.moveTo(631, 792); c.quadraticCurveTo(634, 850, 632, 899); c.stroke();
+ c.beginPath(); c.moveTo(604, 800); c.quadraticCurveTo(600, 850, 601, 899); c.stroke();
+ c.lineWidth = 1.4; for (const x of [612, 621, 642, 652]) { c.beginPath(); c.moveTo(x, 890); c.lineTo(x, 898); c.stroke(); }
+ c.restore();
+ c.strokeStyle = L; c.lineWidth = 2.8; c.stroke(body);
+ // 后爪(白)
+ c.beginPath(); c.ellipse(574, 893, 22, 6.5, 0, 0, 7); c.fillStyle = C.catW; c.fill(); c.lineWidth = 2.2; c.stroke();
+ // 头:侧脸、高耸尖耳
+ const Hd = (x, y) => [hc[0] + x, hc[1] + y];
+ // 耳朵抖:每 ~0.38s 一次 0.1s 的快速一抖(两耳错相),绕耳根中点转
+ const twitch = (ph) => { const f = (ch.lt * 2.6 + ph) % 1; return f < 0.26 ? Math.sin(f / 0.26 * Math.PI) : 0; };
+ const earRot = (e, a) => { const bx = (e[0][0] + e[2][0]) / 2, by = (e[0][1] + e[2][1]) / 2, cs = Math.cos(a), sn = Math.sin(a); return e.map(([x, y]) => [bx + (x - bx) * cs - (y - by) * sn, by + (x - bx) * sn + (y - by) * cs]); };
+ const ear1 = earRot([Hd(-40, -26), Hd(-30, -84), Hd(-8, -36)], -0.38 * twitch(0.1)), ear2 = earRot([Hd(4, -38), Hd(22, -90), Hd(36, -28)], 0.32 * twitch(0.6));
+ [ear1, ear2].forEach((e, k) => { poly(c, e); fs(c, C.catO, L, 2.6); poly(c, [[lerp(e[0][0], e[1][0], 0.2) + 4, lerp(e[0][1], e[1][1], 0.2)], [lerp(e[0][0], e[1][0], 0.85) + (k ? 2 : 3), lerp(e[0][1], e[1][1], 0.85) + 4], [lerp(e[2][0], e[1][0], 0.2) - 3, lerp(e[2][1], e[1][1], 0.2)]]); c.fillStyle = '#e99a86'; c.fill(); });
+ const head = sm([Hd(-44, 40), Hd(-50, 4), Hd(-38, -30), Hd(-6, -40), Hd(30, -32), Hd(52, -16), Hd(64, 2), Hd(72, 14), Hd(68, 30), Hd(52, 44), Hd(22, 52), Hd(-10, 52)]);
+ c.fillStyle = C.catO; c.fill(head);
+ c.save(); c.clip(head);
+ c.fillStyle = C.catW; c.beginPath(); c.ellipse(...Hd(54, 34), 30, 22, -0.2, 0, 7); c.fill(); c.beginPath(); c.ellipse(...Hd(30, 52), 30, 12, 0, 0, 7); c.fill();
+ c.strokeStyle = C.catS; c.lineWidth = 4.5; [[-8, -38, -4, -20], [6, -40, 8, -22], [18, -36, 20, -20], [-34, -6, -18, 0], [-36, 10, -20, 12]].forEach(([a, b, x2, y2]) => { c.beginPath(); c.moveTo(...Hd(a, b)); c.lineTo(...Hd(x2, y2)); c.stroke(); });
+ c.restore();
+ c.strokeStyle = L; c.lineWidth = 2.8; c.stroke(head);
+ // 正面眼(埃及式杏仁大眼+眼线拖尾)
+ const e = Hd(32, -8);
+ if (K.blink) { c.strokeStyle = L; c.lineWidth = 3; c.beginPath(); c.moveTo(e[0] - 14, e[1]); c.quadraticCurveTo(e[0], e[1] + 5, e[0] + 14, e[1]); c.stroke(); }
+ else {
+ c.beginPath(); c.moveTo(e[0] - 15, e[1]); c.quadraticCurveTo(e[0], e[1] - 13, e[0] + 15, e[1] - 1); c.quadraticCurveTo(e[0], e[1] + 10, e[0] - 15, e[1]); c.closePath(); fs(c, '#e8cf4a', L, 2.6);
+ c.fillStyle = L; c.beginPath(); c.ellipse(e[0] + 2, e[1] - 1, 3, 7, 0, 0, 7); c.fill();
+ }
+ c.strokeStyle = L; c.lineWidth = 3.4; c.beginPath(); c.moveTo(e[0] - 15, e[1]); c.lineTo(e[0] - 30, e[1] - 3); c.stroke();
+ // 鼻、嘴、胡须
+ poly(c, [Hd(66, 8), Hd(73, 9), Hd(70, 15)]); c.fillStyle = '#d0706a'; c.fill();
+ c.strokeStyle = L; c.lineWidth = 2; c.beginPath(); c.moveTo(...Hd(70, 15)); c.quadraticCurveTo(...Hd(66, 26), ...Hd(58, 28)); c.stroke();
+ c.lineWidth = 1.2; [[60, 22, 104, 12], [60, 26, 106, 28], [58, 30, 100, 40]].forEach(([a, b, x2, y2]) => { c.beginPath(); c.moveTo(...Hd(a, b)); c.lineTo(...Hd(x2, y2)); c.stroke(); });
+ // 金耳环
+ c.strokeStyle = C.gold; c.lineWidth = 3.4; c.beginPath(); c.arc(...Hd(-28, -18), 7, 0.3, 5.9); c.stroke();
+ // 彩色项圈(红蓝金)+荷鲁斯之眼坠子
+ const clipU = new Path2D(); clipU.addPath(body); clipU.addPath(head);
+ c.save(); c.clip(clipU);
+ const col = [B(556, 664), B(600, 690), B(652, 694)];
+ [[C.gold, 22], [C.red, 16], [C.blue, 9], [C.gold, 3]].forEach(([cc, w]) => { c.strokeStyle = cc; c.lineWidth = w; c.beginPath(); c.moveTo(...col[0]); c.quadraticCurveTo(...col[1], ...col[2]); c.stroke(); });
+ c.strokeStyle = L; c.lineWidth = 1.6; for (const s of [-1, 1]) { c.beginPath(); c.moveTo(col[0][0], col[0][1] + s * 11); c.quadraticCurveTo(col[1][0], col[1][1] + s * 11, col[2][0], col[2][1] + s * 11); c.stroke(); }
+ c.fillStyle = C.gold; for (let q = 0.1; q < 1; q += 0.12) { const x = (1 - q) * (1 - q) * col[0][0] + 2 * q * (1 - q) * col[1][0] + q * q * col[2][0], y = (1 - q) * (1 - q) * col[0][1] + 2 * q * (1 - q) * col[1][1] + q * q * col[2][1]; c.beginPath(); c.arc(x, y + 15, 3, 0, 7); c.fill(); }
+ c.restore();
+ const pd = B(640, 742);
+ c.strokeStyle = C.goldD; c.lineWidth = 2; c.beginPath(); c.moveTo(col[2][0] - 14, col[2][1] + 8); c.lineTo(pd[0], pd[1] - 14); c.stroke();
+ c.beginPath(); c.arc(pd[0], pd[1], 13, 0, 7); fs(c, C.gold, L, 2);
+ c.beginPath(); c.moveTo(pd[0] - 8, pd[1]); c.quadraticCurveTo(pd[0], pd[1] - 6, pd[0] + 8, pd[1]); c.quadraticCurveTo(pd[0], pd[1] + 5, pd[0] - 8, pd[1]); fs(c, '#f4f0e4', '#14204a', 1.5);
+ c.fillStyle = '#14204a'; c.beginPath(); c.arc(pd[0], pd[1], 2.4, 0, 7); c.fill();
+ c.strokeStyle = '#14204a'; c.lineWidth = 1.6; c.beginPath(); c.moveTo(pd[0] - 1, pd[1] + 3); c.lineTo(pd[0] - 3, pd[1] + 9); c.stroke();
+ c.restore();
+ }
+
+ // ---------------- 少女:埃及程式(侧脸正面眼、正面双肩、白亚麻长裙、宽领项圈、金发辫) ----------------
+ const DY = -25;
+ function girl(c, G, ch) {
+ const L = C.line, tilt = G.tilt, nk = [1300, 425 + DY], cs = Math.cos(tilt), sn = Math.sin(tilt);
+ const HP = (x, y) => { const X = x - nk[0], Y = y + DY - nk[1]; return [nk[0] + X * cs - Y * sn, nk[1] + X * sn + Y * cs]; };
+ const TB = (x, y) => [x, y + DY + (y < 600 ? ch.breathe * 150 * (600 - y) / 170 : 0)];
+ const T = (x, y) => [x, y + DY];
+ c.save(); c.lineJoin = 'round'; c.lineCap = 'round';
+ // 躯干(正面化双肩;亚麻半透明:先肤色再罩白)
+ const torso = sm([[1270, 466], [1298, 450], [1340, 447], [1420, 454], [1452, 474], [1452, 530], [1440, 590], [1432, 616], [1300, 616], [1288, 560], [1280, 504]].map(p => TB(...p)));
+ // 长裙下摆:膝前垂直落到脚踝
+ const skirt = sm([[1300, 600], [1238, 620], [1186, 642], [1156, 670], [1145, 724], [1140, 800], [1134, 905], [1262, 905], [1270, 820], [1282, 762], [1330, 754], [1462, 758], [1470, 700], [1452, 640], [1432, 602]].map(p => T(...p)));
+ // 脚(赤足,侧面)
+ [[1198, 1118], [1170, 1092]].forEach(([hx, tx], k) => { const y0 = 900 - 0; const f = sm([[hx + 10, y0 - 22], [hx + 14, y0 - 6], [hx + 6, y0], [tx + 4, y0], [tx - 2, y0 - 6], [tx + 10, y0 - 12], [hx - 30, y0 - 20]]); c.fillStyle = k ? C.skin : C.skinD; c.fill(f); c.strokeStyle = L; c.lineWidth = 2.2; c.stroke(f); });
+ c.fillStyle = C.skin; c.fill(torso);
+ c.globalAlpha = 0.9; c.fillStyle = C.white; c.fill(torso); c.fill(skirt); c.globalAlpha = 1;
+ // 褶:裙身扇形细褶(从腰往膝、再垂到下摆)
+ c.save(); c.clip(skirt); c.strokeStyle = 'rgba(120,96,70,.5)'; c.lineWidth = 1.3;
+ for (let i = 0; i <= 26; i++) { const a = i / 26; c.beginPath(); c.moveTo(lerp(1290, 1460, a), 600 + DY); c.bezierCurveTo(lerp(1200, 1460, a), lerp(650, 752, a) + DY, lerp(1150, 1272, a), lerp(700, 790, a) + DY, lerp(1134, 1262, a), 905 + DY); c.stroke(); }
+ c.strokeStyle = 'rgba(90,60,40,.55)'; c.lineWidth = 1.8; c.beginPath(); c.moveTo(1170, 686 + DY); c.quadraticCurveTo(1320, 700 + DY, 1462, 742 + DY); c.stroke();
+ c.restore();
+ c.save(); c.clip(torso); c.strokeStyle = 'rgba(120,96,70,.45)'; c.lineWidth = 1.2;
+ for (let x = 1290; x < 1455; x += 9) { c.beginPath(); c.moveTo(x, 470 + DY); c.quadraticCurveTo(x + 6, 540 + DY, x + 2, 620 + DY); c.stroke(); }
+ c.fillStyle = 'rgba(255,255,255,.0)'; c.restore();
+ c.strokeStyle = L; c.lineWidth = 2.4; c.stroke(skirt); c.stroke(torso);
+ // 腰带(红色细带,垂两条带尾)
+ c.strokeStyle = C.red; c.lineWidth = 6; c.beginPath(); c.moveTo(...T(1298, 604)); c.quadraticCurveTo(...T(1370, 616), ...T(1440, 606)); c.stroke();
+ c.lineWidth = 4; c.beginPath(); c.moveTo(...T(1306, 606)); c.lineTo(...T(1292, 660)); c.moveTo(...T(1316, 607)); c.lineTo(...T(1310, 664)); c.stroke();
+ // 宽领项圈(同心色带+水滴坠)
+ const cc = TB(1358, 440);
+ const bands = [[C.blue, 50, 24], [C.red, 60, 32], [C.green, 70, 40], [C.gold, 80, 48], [C.blue, 88, 55]];
+ for (let k = bands.length - 1; k >= 0; k--) { const [col, rx, ry] = bands[k]; c.beginPath(); c.ellipse(cc[0], cc[1], rx + 4, ry + 4, 0.05, 0, Math.PI); c.lineTo(cc[0] - rx - 4, cc[1]); c.fillStyle = col; c.fill(); }
+ c.strokeStyle = L; c.lineWidth = 1.2; bands.forEach(([, rx, ry]) => { c.beginPath(); c.ellipse(cc[0], cc[1], rx + 4, ry + 4, 0.05, 0.05, Math.PI - 0.05); c.stroke(); });
+ for (let a = 0.12; a < Math.PI - 0.1; a += 0.17) { const x = cc[0] + Math.cos(a) * 99, y = cc[1] + Math.sin(a) * 66; c.save(); c.translate(x, y); c.rotate(a - Math.PI / 2); c.beginPath(); c.moveTo(-4, -6); c.quadraticCurveTo(-5, 4, 0, 7); c.quadraticCurveTo(5, 4, 4, -6); c.closePath(); c.fillStyle = (Math.round(a / 0.17) % 2) ? C.red : C.blue; c.fill(); c.lineWidth = 1; c.stroke(); c.restore(); }
+ // 后侧手臂:沿身侧下垂,前臂搭在腿上(金臂环、手镯)
+ const sh2 = TB(1446, 478), el2 = T(1452, 612), hd2 = T(1300, 662);
+ c.fillStyle = C.skin; c.strokeStyle = L; c.lineWidth = 2.4;
+ const ua = RIG.taper(sh2, el2, 36, 28, 4), fa = RIG.taper(el2, hd2, 28, 20, 2);
+ c.fill(ua); c.stroke(ua); c.fill(fa); c.stroke(fa);
+ const hand2 = sm([[hd2[0] + 14, hd2[1] - 10], [hd2[0] - 14, hd2[1] - 8], [hd2[0] - 36, hd2[1] - 2], [hd2[0] - 38, hd2[1] + 5], [hd2[0] - 10, hd2[1] + 9], [hd2[0] + 14, hd2[1] + 9]]); c.fill(hand2); c.stroke(hand2);
+ c.lineWidth = 1.2; for (const s of [-3, 2]) { c.beginPath(); c.moveTo(hd2[0] - 12, hd2[1] + s); c.lineTo(hd2[0] - 34, hd2[1] + s + 2); c.stroke(); }
+ const band = (A, B, q, w) => { const x = lerp(A[0], B[0], q), y = lerp(A[1], B[1], q), a = Math.atan2(B[1] - A[1], B[0] - A[0]) + Math.PI / 2; c.strokeStyle = C.gold; c.lineWidth = 8; c.beginPath(); c.moveTo(x + Math.cos(a) * w, y + Math.sin(a) * w); c.lineTo(x - Math.cos(a) * w, y - Math.sin(a) * w); c.stroke(); c.strokeStyle = C.blue; c.lineWidth = 2.5; c.stroke(); };
+ band(sh2, el2, 0.32, 19); band(el2, hd2, 0.84, 12);
+ // 颈、脸
+ const neck = sm([[1286, 400], [1316, 400], [1326, 450], [1288, 452]].map(p => T(...p)));
+ c.fillStyle = C.skin; c.fill(neck); c.strokeStyle = L; c.lineWidth = 2.2; c.stroke(neck);
+ // 假发:头顶到肩后的金色编发(一束束竖向、分节)
+ const wig = sm([[1258, 322], [1266, 298], [1300, 283], [1348, 285], [1388, 304], [1410, 342], [1416, 400], [1422, 470], [1418, 548], [1396, 556], [1372, 548], [1360, 470], [1344, 432], [1328, 404], [1316, 372], [1312, 336], [1290, 324]].map(p => HP(...p)));
+ c.fillStyle = '#9a6a18'; c.fill(wig);
+ c.save(); c.clip(wig);
+ // 一束束竖向编发:每束 = 金色圆头长条+斜向分节(人字纹),末端长短错落
+ for (let i = 0; i < 15; i++) {
+ const x0 = 1260 + i * 11, yEnd = (i < 5 ? 420 : 560) - (i * 37 % 23);
+ const pts = []; for (let y = 284; y <= yEnd; y += 8) pts.push(HP(x0 + (y > 420 ? (y - 420) * 0.06 : 0), y));
+ c.strokeStyle = '#7a4e10'; c.lineWidth = 11.5; c.beginPath(); pts.forEach((p, k) => k ? c.lineTo(...p) : c.moveTo(...p)); c.stroke();
+ c.strokeStyle = (i % 3 === 1) ? C.goldL : C.gold; c.lineWidth = 8.5; c.stroke();
+ c.strokeStyle = '#8a5a12'; c.lineWidth = 1.4;
+ for (let k = 1; k < pts.length; k++) { const p = pts[k], side = k % 2 ? 1 : -1; c.beginPath(); c.moveTo(p[0] - 4.2, p[1] - 3 * side); c.lineTo(p[0] + 4.2, p[1] + 3 * side); c.stroke(); }
+ }
+ c.restore();
+ c.strokeStyle = L; c.lineWidth = 2.4; c.stroke(wig);
+ // 脸(rig 侧脸轮廓)
+ c.fillStyle = C.skin; c.fill(G.face); c.strokeStyle = L; c.lineWidth = 2.4; c.stroke(G.face);
+ // 耳+大金耳环
+ c.beginPath(); c.ellipse(G.ear[0] - 2, G.ear[1], 7, 11, 0.2, 0, 7); fs(c, C.skin, L, 1.8);
+ c.beginPath(); c.arc(G.ear[0] - 2, G.ear[1] + 22, 9, 0, 7); fs(c, C.gold, L, 1.8); c.beginPath(); c.arc(G.ear[0] - 2, G.ear[1] + 22, 3.5, 0, 7); c.fillStyle = C.red; c.fill();
+ // 金发箍+后垂带
+ const hb = [HP(1260, 314), HP(1300, 300), HP(1352, 302), HP(1398, 324)];
+ c.strokeStyle = L; c.lineWidth = 15; c.beginPath(); c.moveTo(...hb[0]); c.bezierCurveTo(...hb[1], ...hb[2], ...hb[3]); c.stroke();
+ c.strokeStyle = C.gold; c.lineWidth = 11; c.stroke(); c.strokeStyle = C.goldL; c.lineWidth = 3; c.stroke();
+ const kn = HP(1402, 326), kt = HP(1440, 392), kt2 = HP(1430, 410);
+ poly(c, [kn, kt, kt2, HP(1396, 340)]); fs(c, C.gold, L, 1.8);
+ c.fillStyle = C.blue; c.beginPath(); c.arc(...HP(1262, 314), 5, 0, 7); c.fill();
+ // 正面眼(杏仁形、黑眼线拖尾、长眉)
+ const ex = G.eye.x + 2, ey = G.eye.y;
+ if (ch.blink) { c.strokeStyle = L; c.lineWidth = 3; c.beginPath(); c.moveTo(ex - 11, ey); c.quadraticCurveTo(ex, ey + 4, ex + 12, ey); c.stroke(); }
+ else {
+ c.beginPath(); c.moveTo(ex - 11, ey); c.quadraticCurveTo(ex, ey - 9, ex + 12, ey - 1); c.quadraticCurveTo(ex, ey + 6, ex - 11, ey); c.closePath(); fs(c, '#fbf7ee', null);
+ c.fillStyle = '#1a120c'; c.beginPath(); c.arc(ex - 1, ey - 1.5, 4.2, 0, 7); c.fill();
+ }
+ c.strokeStyle = '#140c08'; c.lineWidth = 3.2; c.beginPath(); c.moveTo(ex - 12, ey); c.quadraticCurveTo(ex, ey - 10, ex + 12, ey - 1); c.lineTo(ex + 30, ey - 3); c.stroke();
+ c.lineWidth = 1.8; c.beginPath(); c.moveTo(ex - 10, ey + 1); c.quadraticCurveTo(ex, ey + 6, ex + 14, ey + 1); c.stroke();
+ c.lineWidth = 3; c.beginPath(); c.moveTo(ex - 12, ey - 12); c.quadraticCurveTo(ex + 4, ey - 19, ex + 26, ey - 12); c.stroke();
+ // 唇
+ c.fillStyle = '#b6443a'; c.beginPath(); c.moveTo(...G.lips[0]); c.lineTo(...G.lips[1]); c.lineTo(...G.lips[2]); c.closePath(); c.fill();
+ // 近侧手臂:从前肩抬到嘴边端杯(自己的 IK,肘向下垂)
+ // 手托在杯身下(握杯脚),而不是 rig 默认的杯侧:肘才能像设定稿那样垂到胸前
+ const cpp = G.cup, hd = [cpp.x + 4 - Math.sin(cpp.tilt) * 40, cpp.y + Math.cos(cpp.tilt) * 42];
+ const sh = TB(1282, 476);
+ const { E } = RIG.ik2(sh, hd, 140, 160, -1);
+ const ua1 = RIG.taper(sh, E, 38, 30, 4), fa1 = RIG.taper(E, hd, 30, 22, 2);
+ c.fillStyle = C.skin; c.strokeStyle = L; c.lineWidth = 2.4; c.fill(ua1); c.stroke(ua1); c.fill(fa1); c.stroke(fa1);
+ band(sh, E, 0.4, 19); band(E, hd, 0.8, 13);
+ // 蓝色莲花杯
+ const cp = G.cup;
+ c.save(); c.translate(cp.x, cp.y); c.rotate(cp.tilt);
+ c.beginPath(); c.moveTo(-26, 0); c.quadraticCurveTo(-22, 26, -5, 34); c.lineTo(-4, 44); c.quadraticCurveTo(-14, 46, -14, 50); c.lineTo(14, 50); c.quadraticCurveTo(14, 46, 4, 44); c.lineTo(5, 34); c.quadraticCurveTo(22, 26, 26, 0); c.closePath(); fs(c, '#2f62c4', L, 2.2);
+ c.strokeStyle = '#8ab8f0'; c.lineWidth = 1.6; [[-14, 2, -4, 30], [0, 1, 0, 32], [14, 2, 4, 30]].forEach(([a, b, x2, y2]) => { c.beginPath(); c.moveTo(a, b); c.quadraticCurveTo((a + x2) / 2 + (a < 0 ? -4 : a > 0 ? 4 : 0), 18, x2, y2); c.stroke(); });
+ c.beginPath(); c.ellipse(0, 0, 26, 4.5, 0, 0, 7); fs(c, '#1c3f8a', L, 1.8);
+ c.restore();
+ // 手:握杯
+ const hf = sm([[hd[0] - 20, hd[1] - 4], [hd[0] - 8, hd[1] - 10], [hd[0] + 10, hd[1] - 8], [hd[0] + 16, hd[1] + 6], [hd[0] + 2, hd[1] + 14], [hd[0] - 18, hd[1] + 6]]);
+ c.fillStyle = C.skin; c.fill(hf); c.strokeStyle = L; c.lineWidth = 2.2; c.stroke(hf);
+ c.lineWidth = 1.2; for (const s of [-4, 2]) { c.beginPath(); c.moveTo(hd[0] - 18, hd[1] + s); c.lineTo(hd[0] - 4, hd[1] + s + 1); c.stroke(); }
+ c.restore();
+ }
+
+ return {
+ init() { P.cached('eg_static', W, H, staticLayer); surface(); specks(); },
+ draw(c, lt, t) {
+ const ch = P.choreo(lt, t);
+ c.drawImage(P.cached('eg_static', W, H, staticLayer), 0, 0);
+ // 水纹象形字:zigzag 相位流动(12fps 步进,像手绘逐张)
+ const wp = Math.floor(lt * 12) * 0.5; // 每 1/12s 走半个齿,4 步一循环(0.33s)
+ GLYPHS.forEach(q => { if (GL[q.n].water) drawGlyph(c, q, wp + q.ph); });
+ rays(c, lt, t);
+ writeGlyphs(c, lt);
+ ch.lt = lt;
+ const K = RIG.cat({ tail: ch.tail * 2.1 + 0.25 * Math.sin(t * 9.5), blink: ch.blink, breathe: ch.breathe, dy: -5 });
+ cat(c, K, ch);
+ // 两条长光线要压在猫上
+ c.save(); c.lineCap = 'round';
+ LONG.forEach(([x, y, k]) => {
+ const wx = x + Math.sin(t * 7 + k * 1.3) * 3, wy = y + Math.cos(t * 6 + k) * 2, ang = Math.atan2(wy - DISK[1], wx - DISK[0]);
+ c.strokeStyle = '#c23a2a'; c.lineWidth = 2.6; c.beginPath(); c.moveTo(lerp(DISK[0], wx, 0.62), lerp(DISK[1], wy, 0.62)); c.lineTo(wx - Math.cos(ang) * 6, wy - Math.sin(ang) * 6); c.stroke();
+ handAt(c, wx, wy, ang, 0.5 + 0.5 * Math.sin(lt * Math.PI * 2 / 0.4 + k * 0.9)); // 开合幅度在 handAt 里已放大
+ drawGlyph(c, { n: 'ankh', x: wx + Math.cos(ang) * 16, y: wy + Math.sin(ang) * 16 + 4, s: 0.36, col: C.blue });
+ });
+ c.restore();
+ // 少女:杯基本一直在嘴边(原片如此),choreo 的举杯只走最后一小段+小口啜饮
+ // 端杯:先按 choreo 举到嘴边;lt>0.35 起每 0.6s 一个循环:杯离嘴下放(cup 1→0.62)再举回,杯在嘴边时仰头大口喝(倾角到 ~0.2rad)
+ let cupV = lerp(0.8, 1, ch.cup), sipV = ch.sip;
+ if (lt > 0.35) { const u = (lt - 0.35) / 0.6; cupV = 1 - 0.46 * (1 - Math.cos(u * Math.PI * 2)) / 2; }
+ sipV += 0.3 * clamp((cupV - 0.78) / 0.22) * (0.65 + 0.35 * Math.sin(lt * 13));
+ const G = RIG.girl({ cup: cupV, sip: sipV, breathe: ch.breathe, dy: DY, hair: 'down' });
+ girl(c, G, ch);
+ scarab(c, lt);
+ // 壁画表面:斑驳 multiply + 颗粒
+ c.save(); c.globalCompositeOperation = 'multiply'; c.drawImage(surface(), 0, 0); c.restore();
+ c.drawImage(specks(), 0, 0);
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/03_greek.js b/scripts/engine/scenes/03_greek.js
new file mode 100644
index 0000000..731f616
--- /dev/null
+++ b/scripts/engine/scenes/03_greek.js
@@ -0,0 +1,448 @@
+// 公元前530 阿提卡黑绘陶器(Exekias 酒神杯 + 双耳瓶母题)——纯代码。
+// 管线:①缓存陶土底(低频斑驳 + 拉坯水平细纹 + 颗粒 + 裂纹)→ ②缓存静态黑绘(画框、桌、椅、双耳瓶、希腊铭文)
+// → ③滚动纹带(顶回纹左滚、底莲苞链+射线纹右滚)→ ④画框内船与海豚、里拉琴摆、玫瑰花饰转
+// → ⑤橘白猫(橘剪影+黑虎斑+陶土留白)→ ⑥少女(黑釉剪影 + 刻线 + 紫红/白点附加色 + 金色卷发)→ ⑦热气、暗角
+// 黑绘三件套:黑釉剪影(C.black)+刻线(在黑上「刻穿」露出陶土色细线 C.inc)+附加色(紫红 C.red、白点 C.white)。
+SCENES['03_greek'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, rng } = U, P = PAINT, IO = U.ease.inOut;
+ const C = {
+ clay: '#dc6a2f', clayHi: '#e8803f', black: '#1b120d', red: '#8a2a37', white: '#f6ead6',
+ inc: '#e8904c', gold: '#f2bd48', resv: '#f3cfa4', catO: '#f2913f', pink: '#e7897a',
+ };
+ const TAU = Math.PI * 2;
+ const GS = 0.97, GDY = -14; // 少女缩放/上移:脚落在地线 y≈903
+ const Tg = (x, y) => [1300 + (x - 1300) * GS, GDY + 620 + (y - 620) * GS];
+ const sm = (pts, closed = true) => RIG.smooth(pts, closed);
+ const smT = (pts, closed = false) => RIG.smooth(pts.map(p => Tg(p[0], p[1])), closed);
+ const line = (g, pts) => { g.beginPath(); pts.forEach((p, i) => i ? g.lineTo(p[0], p[1]) : g.moveTo(p[0], p[1])); };
+
+ // ---------------- ① 陶土底 ----------------
+ function crack(g, pts, seed) {
+ const r = rng(seed); g.save(); g.strokeStyle = 'rgba(52,18,6,.55)'; g.lineWidth = 1.3; g.lineJoin = 'round'; g.beginPath();
+ g.moveTo(pts[0][0], pts[0][1]);
+ for (let i = 1; i < pts.length; i++) { const a = pts[i - 1], b = pts[i], n = Math.max(2, Math.round(Math.hypot(b[0] - a[0], b[1] - a[1]) / 9));
+ for (let k = 1; k <= n; k++) g.lineTo(lerp(a[0], b[0], k / n) + (r() - .5) * 4, lerp(a[1], b[1], k / n) + (r() - .5) * 4); }
+ g.stroke();
+ g.strokeStyle = 'rgba(255,190,140,.18)'; g.translate(1, 1.2); g.stroke(); g.restore(); // 裂缝下沿的一丝亮边
+ }
+ const bg = () => P.cached('gr_bg', W, H, (g) => {
+ const lw = 480, lh = 270, lo = P.canvas(lw, lh), lg = lo.getContext('2d'), img = lg.createImageData(lw, lh), d = img.data, b = P.hex(C.clay);
+ for (let y = 0; y < lh; y++) for (let x = 0; x < lw; x++) {
+ const n = P.fbm(x * 0.016 + 3, y * 0.016, 4), s = P.noise(x * 0.006, y * 0.85) * 0.6 + P.noise(x * 0.013 + 7, y * 0.4) * 0.4;
+ const k = n * 30 + s * 9, i = (y * lw + x) * 4;
+ d[i] = b[0] + k; d[i + 1] = b[1] + k * 0.75; d[i + 2] = b[2] + k * 0.45; d[i + 3] = 255;
+ }
+ lg.putImageData(img, 0, 0); g.imageSmoothingEnabled = true; g.drawImage(lo, 0, 0, W, H);
+ const hl = g.createRadialGradient(980, 520, 60, 980, 520, 900); hl.addColorStop(0, 'rgba(255,170,90,.16)'); hl.addColorStop(1, 'rgba(255,170,90,0)');
+ g.fillStyle = hl; g.fillRect(0, 0, W, H);
+ const r = rng(31); // 拉坯留下的水平细纹
+ for (let i = 0; i < 560; i++) { const y = r() * H, x = r() * W - 300, L = 150 + r() * 900;
+ g.strokeStyle = r() < 0.55 ? `rgba(120,38,8,${0.03 + r() * 0.05})` : `rgba(255,196,140,${0.03 + r() * 0.05})`; g.lineWidth = 0.7 + r() * 1.8;
+ g.beginPath(); g.moveTo(x, y); g.lineTo(x + L, y + (r() - .5) * 2); g.stroke(); }
+ for (let i = 0; i < 420; i++) { g.fillStyle = `rgba(70,24,8,${0.25 + r() * 0.45})`; g.beginPath(); g.arc(r() * W, r() * H, 0.6 + r() * 1.6, 0, TAU); g.fill(); }
+ for (let i = 0; i < 120; i++) { g.fillStyle = `rgba(255,205,160,${0.2 + r() * 0.3})`; g.beginPath(); g.arc(r() * W, r() * H, 0.6 + r() * 1.2, 0, TAU); g.fill(); }
+ g.drawImage(P.grain('gr_grainA', 0.07, [70, 22, 6], 0.16), 0, 0); g.drawImage(P.grain('gr_grainBB', 0.04, [255, 214, 170], 0.12), 0, 0);
+ crack(g, [[1018, 96], [1030, 170], [1062, 240], [1100, 330], [1112, 430], [1104, 560], [1120, 620]], 3);
+ crack(g, [[0, 606], [160, 628], [300, 662], [440, 690], [560, 650], [650, 572], [700, 470]], 4);
+ crack(g, [[1500, 560], [1570, 590], [1615, 640], [1720, 668], [1920, 704]], 5);
+ crack(g, [[1500, 720], [1528, 800], [1522, 896]], 6); crack(g, [[300, 662], [330, 600], [322, 540]], 7);
+ });
+ const vignette = () => P.cached('gr_vig', W, H, (g) => {
+ const v = g.createRadialGradient(960, 540, 380, 960, 540, 1180); v.addColorStop(0, 'rgba(40,10,0,0)'); v.addColorStop(1, 'rgba(30,6,0,.62)');
+ g.fillStyle = v; g.fillRect(0, 0, W, H);
+ });
+
+ // ---------------- ② 希腊铭文:笔画表(单位格 0..1,y 向下) ----------------
+ const GL = {
+ 'Χ': [[[0, 0], [1, 1]], [[1, 0], [0, 1]]], 'Α': [[[0, 1], [.5, 0], [1, 1]], [[.24, .62], [.76, .62]]], 'Ι': [[[.5, 0], [.5, 1]]],
+ 'Ρ': [[[0, 1], [0, 0], [.6, 0], [.92, .2], [.62, .45], [0, .45]]], 'Ε': [[[.92, 0], [0, 0], [0, 1], [.92, 1]], [[0, .5], [.68, .5]]],
+ 'Κ': [[[0, 0], [0, 1]], [[.9, 0], [0, .56]], [[.3, .38], [.95, 1]]], 'Π': [[[0, 1], [0, 0], [.9, 0], [.9, 1]]], 'Λ': [[[0, 1], [.5, 0], [1, 1]]],
+ 'Υ': [[[0, 0], [.5, .48], [1, 0]], [[.5, .48], [.5, 1]]], 'Σ': [[[1, .02], [.05, 0], [.55, .5], [0, 1], [1, .98]]],
+ };
+ function greek(g, str, x, y, h, gap, seed) {
+ const r = rng(seed); g.save(); g.strokeStyle = C.black; g.lineWidth = 3.4; g.lineCap = 'round'; g.lineJoin = 'round';
+ let cx = x;
+ for (const ch of str) {
+ if (ch === ' ') { cx += h * 0.6; continue; }
+ const hh = h * (0.9 + r() * 0.16), oy = y + (r() - .5) * h * 0.12;
+ if (ch === 'Ο') { const rr = hh * 0.25; g.beginPath(); g.ellipse(cx + rr, oy + hh * 0.55, rr, rr * 1.05, 0, 0, TAU); g.stroke(); cx += rr * 2 + gap; continue; }
+ const w = ch === 'Ι' ? 2 : h * 0.62;
+ GL[ch].forEach(st => { g.beginPath(); st.forEach((p, i) => { const px = cx + p[0] * w + (r() - .5) * 1.4, py = oy + p[1] * hh + (r() - .5) * 1.4; i ? g.lineTo(px, py) : g.moveTo(px, py); }); g.stroke(); });
+ cx += w + gap;
+ }
+ g.restore();
+ }
+
+ // ---------------- 黑绘小件 ----------------
+ const dots = (g, pts, r = 2.6, col = C.white) => { g.fillStyle = col; pts.forEach(p => { g.beginPath(); g.arc(p[0], p[1], r, 0, TAU); g.fill(); }); };
+ const dotRow = (x0, x1, y, step) => { const o = []; for (let x = x0; x <= x1; x += step) o.push([x, y]); return o; };
+ function rosette(g, x, y, r, a) {
+ g.save(); g.translate(x, y); g.rotate(a); g.fillStyle = C.black;
+ for (let k = 0; k < 8; k++) { const q = k / 8 * TAU; g.beginPath(); g.ellipse(Math.cos(q) * r * 0.6, Math.sin(q) * r * 0.6, r * 0.42, r * 0.3, q, 0, TAU); g.fill(); }
+ g.beginPath(); g.arc(0, 0, r * 0.45, 0, TAU); g.fill();
+ g.strokeStyle = C.inc; g.lineWidth = 1.2; for (let k = 0; k < 8; k++) { const q = (k + 0.5) / 8 * TAU; g.beginPath(); g.moveTo(Math.cos(q) * r * 0.3, Math.sin(q) * r * 0.3); g.lineTo(Math.cos(q) * r * 0.85, Math.sin(q) * r * 0.85); g.stroke(); }
+ g.fillStyle = C.red; g.beginPath(); g.arc(0, 0, r * 0.24, 0, TAU); g.fill(); g.restore();
+ }
+ function dolphin(g, x, y, ang, s) {
+ g.save(); g.translate(x, y); g.rotate(ang); g.scale(s, s); g.fillStyle = C.black;
+ g.beginPath(); g.moveTo(34, 1); g.quadraticCurveTo(28, -4, 22, -6); g.bezierCurveTo(10, -13, -12, -12, -26, -4);
+ g.lineTo(-38, -12); g.lineTo(-34, 0); g.lineTo(-38, 12); g.lineTo(-26, 4); g.bezierCurveTo(-10, 10, 10, 10, 22, 5); g.quadraticCurveTo(28, 4, 34, 1); g.fill();
+ g.beginPath(); g.moveTo(-2, -10); g.quadraticCurveTo(-10, -22, -16, -21); g.lineTo(-12, -9); g.fill();
+ g.beginPath(); g.moveTo(4, 7); g.lineTo(-4, 16); g.lineTo(-8, 8); g.fill();
+ g.strokeStyle = C.inc; g.lineWidth = 1.4; g.beginPath(); g.moveTo(22, 2); g.bezierCurveTo(8, 6, -10, 5, -24, 1); g.stroke();
+ g.fillStyle = C.white; g.beginPath(); g.arc(18, -3, 1.8, 0, TAU); g.fill(); g.restore();
+ }
+
+ // ---------------- ② 静态黑绘层 ----------------
+ const stat = () => P.cached('gr_static', W, H, (g) => {
+ g.lineJoin = 'round'; g.lineCap = 'round';
+ // 顶:深色口沿 + 回纹带上下黑线;底:地线
+ const tg = g.createLinearGradient(0, 0, 0, 24); tg.addColorStop(0, 'rgba(18,10,6,.95)'); tg.addColorStop(1, 'rgba(26,14,8,.85)');
+ g.fillStyle = tg; g.fillRect(0, 0, W, 21); g.fillStyle = C.black; g.fillRect(0, 24, W, 4); g.fillRect(0, 86, W, 5);
+ g.fillRect(0, 899, W, 6);
+ // 画框:黑边 + 白点串 + 内细线
+ g.fillStyle = C.black; g.fillRect(362, 122, 436, 436); g.clearRect(380, 140, 400, 400);
+ dots(g, dotRow(371, 790, 131, 11.6), 2.3); dots(g, dotRow(371, 790, 549, 11.6), 2.3);
+ dots(g, dotRow(143, 540, 371, 11.6).map(p => [p[1], p[0]]), 2.3); dots(g, dotRow(143, 540, 789, 11.6).map(p => [p[1], p[0]]), 2.3);
+ g.strokeStyle = C.black; g.lineWidth = 2.5; g.strokeRect(386, 146, 388, 388);
+ // 葡萄藤(画框顶)
+ g.save(); g.beginPath(); g.rect(386, 146, 388, 388); g.clip();
+ g.strokeStyle = C.black; g.lineWidth = 3; g.beginPath(); for (let x = 392; x <= 770; x += 4) { const y = 160 + Math.sin((x - 392) / 378 * Math.PI * 3.5) * 9; x === 392 ? g.moveTo(x, y) : g.lineTo(x, y); } g.stroke();
+ [[420, 166], [470, 178], [545, 182], [600, 160], [665, 164], [742, 172]].forEach(([x, y], k) => {
+ g.fillStyle = C.black; for (let row = 0; row < 3; row++) for (let i = 0; i <= 2 - row; i++) { g.beginPath(); g.arc(x - (2 - row) * 4.5 + i * 9, y + 6 + row * 8, 4.6, 0, TAU); g.fill(); }
+ const lx = x + (k % 2 ? 16 : -16), ly = y - 6; g.beginPath(); g.ellipse(lx, ly, 9, 5, k % 2 ? -0.5 : 0.5, 0, TAU); g.fill();
+ g.strokeStyle = C.inc; g.lineWidth = 1; g.beginPath(); g.moveTo(lx - 6, ly); g.lineTo(lx + 6, ly); g.stroke();
+ });
+ g.restore();
+ // 桌
+ g.fillStyle = C.black; g.fillRect(820, 640, 380, 17); g.fillStyle = C.red; g.fillRect(824, 659, 372, 6); g.fillStyle = C.black; g.fillRect(820, 665, 380, 3);
+ dots(g, dotRow(832, 1190, 648.5, 13), 2.1);
+ const leg = (x) => { g.fillStyle = C.black; g.beginPath(); g.moveTo(x - 7, 668); g.lineTo(x + 7, 668); g.lineTo(x + 5, 682); g.lineTo(x + 4, 878); g.lineTo(x - 4, 878); g.lineTo(x - 5, 682); g.closePath(); g.fill();
+ g.beginPath(); g.ellipse(x + 1, 891, 11, 9, 0, Math.PI, 0); g.lineTo(x + 12, 900); g.lineTo(x - 10, 900); g.fill();
+ g.strokeStyle = C.inc; g.lineWidth = 1.2; g.beginPath(); g.moveTo(x - 4, 690); g.lineTo(x + 4, 690); g.stroke(); };
+ [866, 893, 1078, 1104].forEach(leg); g.fillStyle = C.black; g.fillRect(866, 706, 240, 5);
+ // 椅:天鹅颈椅背 + 车旋腿 + 紫红坐垫
+ const bal = (x) => { const ys = [[756, 9], [778, 22], [800, 11], [826, 9], [846, 21], [866, 11], [890, 15], [900, 15]];
+ g.fillStyle = C.black; g.beginPath(); ys.forEach(([y, w], i) => i ? g.lineTo(x + w / 2, y) : g.moveTo(x + w / 2, y)); [...ys].reverse().forEach(([y, w]) => g.lineTo(x - w / 2, y)); g.closePath(); g.fill();
+ g.fillStyle = C.red; g.fillRect(x - 10, 842, 20, 7); };
+ bal(1322); bal(1468);
+ g.fillStyle = C.black; g.fillRect(1288, 738, 206, 14); g.fillStyle = C.red; g.fillRect(1290, 752, 202, 7); dots(g, dotRow(1298, 1486, 745, 12), 2);
+ g.fillStyle = C.red; g.beginPath(); g.moveTo(1470, 738); g.quadraticCurveTo(1492, 718, 1506, 726); g.lineTo(1494, 740); g.closePath(); g.fill();
+ g.strokeStyle = C.black; g.lineWidth = 13; g.beginPath(); g.moveTo(1466, 742); g.lineTo(1470, 520); g.quadraticCurveTo(1468, 452, 1488, 440); g.quadraticCurveTo(1504, 432, 1512, 446); g.stroke();
+ g.fillStyle = C.black; g.beginPath(); g.ellipse(1512, 448, 13, 8, 0.1, 0, TAU); g.fill(); g.beginPath(); g.moveTo(1520, 444); g.lineTo(1543, 455); g.lineTo(1520, 454); g.fill();
+ g.fillStyle = C.white; g.beginPath(); g.arc(1513, 446, 2, 0, TAU); g.fill();
+ g.strokeStyle = C.inc; g.lineWidth = 1.5; [560, 600, 640, 690].forEach(y => { g.beginPath(); g.moveTo(1464, y); g.lineTo(1476, y); g.stroke(); });
+ // 双耳瓶
+ const am = [[1662, 604], [1738, 604], [1736, 620], [1722, 632], [1722, 662], [1764, 684], [1792, 724], [1796, 764], [1780, 812], [1748, 852], [1724, 868], [1730, 882], [1748, 900],
+ [1652, 900], [1670, 882], [1676, 868], [1652, 852], [1620, 812], [1604, 764], [1608, 724], [1636, 684], [1678, 662], [1678, 632], [1664, 620]];
+ const amp = new Path2D(); am.forEach((p, i) => i ? amp.lineTo(p[0], p[1]) : amp.moveTo(p[0], p[1])); amp.closePath();
+ const ams = sm(am);
+ g.strokeStyle = C.black; g.lineWidth = 12; g.beginPath(); g.moveTo(1724, 642); g.bezierCurveTo(1770, 626, 1784, 650, 1770, 692); g.stroke();
+ g.beginPath(); g.moveTo(1676, 642); g.bezierCurveTo(1630, 626, 1616, 650, 1630, 692); g.stroke();
+ g.fillStyle = C.black; g.fill(ams); g.fillRect(1656, 600, 88, 8);
+ g.save(); g.clip(ams);
+ const sh = g.createLinearGradient(1600, 0, 1800, 0); sh.addColorStop(0, 'rgba(255,220,180,0)'); sh.addColorStop(0.72, 'rgba(255,220,180,.09)'); sh.addColorStop(0.8, 'rgba(255,220,180,0)'); g.fillStyle = sh; g.fillRect(1600, 600, 200, 300);
+ g.fillStyle = C.red; g.fillRect(1600, 708, 200, 6); g.fillRect(1600, 806, 200, 5);
+ g.fillStyle = C.clayHi; g.fillRect(1658, 722, 84, 76); g.strokeStyle = C.black; g.lineWidth = 2.5; g.strokeRect(1658, 722, 84, 76);
+ g.fillStyle = C.clayHi; g.fillRect(1600, 822, 200, 32);
+ g.fillStyle = C.black; for (let x = 1600; x < 1800; x += 14) { g.beginPath(); g.moveTo(x, 854); g.lineTo(x + 7, 826); g.lineTo(x + 14, 854); g.fill(); }
+ g.restore();
+ // 瓶上小黑猫
+ g.fillStyle = C.black; g.beginPath(); g.ellipse(1696, 782, 15, 13, 0, 0, TAU); g.fill(); g.beginPath(); g.arc(1708, 760, 9, 0, TAU); g.fill();
+ g.beginPath(); g.moveTo(1701, 755); g.lineTo(1703, 743); g.lineTo(1708, 752); g.lineTo(1713, 742); g.lineTo(1716, 756); g.fill();
+ g.strokeStyle = C.black; g.lineWidth = 4; g.beginPath(); g.moveTo(1683, 790); g.quadraticCurveTo(1670, 792, 1672, 778); g.stroke();
+ g.fillRect(1680, 792, 34, 4);
+ dots(g, [[1705, 759], [1712, 759]], 1.6, '#f4f0d0');
+ // 铭文
+ greek(g, 'ΧΑΙΡΕ ΚΑΙ ΠΙΕΙ', 866, 474, 30, 9, 11);
+ greek(g, 'ΑΙΛΟΥΡΟΣ ΚΑΛΟΣ', 86, 708, 30, 10, 12);
+ });
+
+ // ---------------- ③ 滚动纹带 ----------------
+ const TOP_P = 60, BOT_P = 76;
+ const topStrip = () => P.cached('gr_topStrip', W + TOP_P * 2, 60, (g) => {
+ g.strokeStyle = C.black; g.lineWidth = 7; g.lineCap = 'square'; g.lineJoin = 'miter';
+ const y0 = 6, h = 46;
+ g.beginPath(); g.moveTo(0, y0 + h); g.lineTo(W + TOP_P * 2, y0 + h); g.stroke();
+ for (let x = 0; x < W + TOP_P * 2; x += TOP_P) {
+ line(g, [[x + 4, y0 + h], [x + 4, y0], [x + 50, y0], [x + 50, y0 + 34], [x + 18, y0 + 34], [x + 18, y0 + 14], [x + 36, y0 + 14], [x + 36, y0 + 22]]); g.stroke();
+ }
+ });
+ const botStrip = () => P.cached('gr_botStrip', W + BOT_P * 2, 150, (g) => {
+ const Y = 930; // 条带局部 y = 画面 y - 930
+ g.fillStyle = C.black; g.fillRect(0, 934 - Y, W + BOT_P * 2, 4); g.fillRect(0, 996 - Y, W + BOT_P * 2, 6); g.fillRect(0, 1072 - Y, W + BOT_P * 2, 8);
+ g.lineCap = 'round'; g.lineJoin = 'round';
+ for (let i = 0, x = 0; x < W + BOT_P * 2; i++, x += BOT_P / 2) {
+ g.strokeStyle = C.black; g.lineWidth = 2.6; g.beginPath(); g.moveTo(x, 946 - Y); g.quadraticCurveTo(x + 19, 962 - Y, x + 38, 946 - Y); g.stroke();
+ const bud = new Path2D(); bud.moveTo(x, 948 - Y); bud.bezierCurveTo(x + 11, 954 - Y, x + 10, 972 - Y, x, 988 - Y); bud.bezierCurveTo(x - 10, 972 - Y, x - 11, 954 - Y, x, 948 - Y);
+ g.fillStyle = i % 2 ? C.red : C.black; g.fill(bud); g.strokeStyle = C.black; g.lineWidth = 2.4; g.stroke(bud);
+ if (i % 2) { g.strokeStyle = C.black; g.lineWidth = 1.6; g.beginPath(); g.moveTo(x, 953 - Y); g.lineTo(x, 982 - Y); g.stroke(); }
+ g.fillStyle = C.black; g.beginPath(); g.arc(x + 19, 972 - Y, 2.6, 0, TAU); g.fill();
+ g.beginPath(); g.moveTo(x - 17, 1074 - Y); g.lineTo(x + 2, 1008 - Y); g.lineTo(x + 21, 1074 - Y); g.fill(); // 射线纹
+ }
+ });
+
+ // ---------------- ④ 画框里的船、海豚 ----------------
+ function panel(c, lt) {
+ c.save(); c.beginPath(); c.rect(388, 148, 384, 384); c.clip();
+ const w = Math.sin(lt * TAU / 0.9), w2 = Math.cos(lt * TAU / 0.9);
+ // 海豚:沿自身朝向来回游 + 微摆
+ [[416, 266, 1.45, 0.95], [748, 276, 1.75, 0.92], [462, 352, -1.05, 0.9], [442, 498, -0.25, 1.05], [652, 496, -0.12, 1.05], [738, 455, 0.25, 0.85]].forEach(([x, y, a, s], k) => {
+ const ph = lt * TAU / 0.85 + k * 1.3, d = 9 * Math.sin(ph);
+ dolphin(c, x + Math.cos(a) * d, y + Math.sin(a) * d, a + 0.12 * Math.cos(ph), s);
+ });
+ // 船:随波起伏、微微摇
+ c.translate(560, 420); c.rotate(0.025 * w2); c.translate(0, 4 * w); c.translate(-560, -420);
+ c.lineCap = 'round'; c.lineJoin = 'round';
+ c.strokeStyle = C.black; c.lineWidth = 1.6; line(c, [[458, 302], [418, 396]]); c.stroke(); line(c, [[662, 302], [700, 392]]); c.stroke();
+ c.lineWidth = 4.5; line(c, [[560, 214], [560, 400]]); c.stroke();
+ const sail = new Path2D(); sail.moveTo(458, 210); sail.lineTo(662, 210); sail.quadraticCurveTo(672, 258, 662, 304); sail.quadraticCurveTo(560, 312, 458, 304); sail.quadraticCurveTo(448, 258, 458, 210);
+ c.fillStyle = '#f1e7d6'; c.fill(sail); c.lineWidth = 2.6; c.strokeStyle = C.black; c.stroke(sail);
+ c.strokeStyle = C.red; c.lineWidth = 1.6; [500, 540, 582, 622].forEach(x => { c.beginPath(); c.moveTo(x, 212); c.lineTo(x + 1, 306); c.stroke(); });
+ c.fillStyle = '#7a3a2a'; [[478, 240], [512, 278], [596, 236], [640, 284], [548, 296]].forEach(([x, y]) => { c.beginPath(); c.arc(x, y, 1.6, 0, TAU); c.fill(); });
+ c.strokeStyle = C.black; c.lineWidth = 6; line(c, [[446, 208], [674, 208]]); c.stroke();
+ // 船身(新月形,船尾蝎尾般卷起)
+ c.fillStyle = C.black; c.beginPath(); c.moveTo(404, 400); c.quadraticCurveTo(430, 394, 470, 398); c.lineTo(690, 392); c.quadraticCurveTo(712, 370, 712, 330);
+ c.quadraticCurveTo(708, 312, 696, 316); c.quadraticCurveTo(718, 300, 728, 326); c.quadraticCurveTo(734, 384, 700, 420); c.quadraticCurveTo(600, 452, 470, 440); c.quadraticCurveTo(428, 430, 404, 400); c.fill();
+ c.fillStyle = C.red; c.beginPath(); c.moveTo(470, 410); c.lineTo(690, 404); c.quadraticCurveTo(600, 424, 470, 422); c.closePath(); c.fill();
+ c.strokeStyle = C.inc; c.lineWidth = 1.4; c.beginPath(); c.moveTo(440, 426); c.quadraticCurveTo(560, 444, 700, 414); c.stroke();
+ c.fillStyle = C.white; c.beginPath(); c.arc(428, 404, 3, 0, TAU); c.fill();
+ c.strokeStyle = C.black; c.lineWidth = 4; line(c, [[690, 410], [722, 474]]); c.stroke(); line(c, [[702, 406], [744, 462]]); c.stroke();
+ c.fillStyle = C.black; c.beginPath(); c.ellipse(724, 478, 5, 10, -0.5, 0, TAU); c.fill(); c.beginPath(); c.ellipse(746, 466, 5, 10, -0.7, 0, TAU); c.fill();
+ // 船上斜倚的人(酒神)
+ c.fillStyle = C.red; c.beginPath(); c.moveTo(520, 398); c.quadraticCurveTo(580, 372, 640, 384); c.lineTo(640, 398); c.closePath(); c.fill();
+ c.fillStyle = C.black; c.beginPath(); c.moveTo(560, 396); c.quadraticCurveTo(596, 360, 632, 362); c.quadraticCurveTo(652, 372, 646, 396); c.closePath(); c.fill();
+ c.beginPath(); c.arc(636, 348, 13, 0, TAU); c.fill();
+ c.strokeStyle = C.black; c.lineWidth = 7; line(c, [[620, 368], [596, 342], [594, 326]]); c.stroke();
+ c.strokeStyle = C.inc; c.lineWidth = 1.2; c.beginPath(); c.arc(638, 346, 5, 0, TAU); c.stroke();
+ c.restore();
+ }
+
+ // ---------------- ④ 里拉琴(以钉子为轴摆) ----------------
+ function lyre(c, lt) {
+ const piv = [1050, 150], a = 0.09 * Math.sin(lt * TAU / 0.8 + 0.5);
+ c.save(); c.translate(piv[0], piv[1]); c.rotate(a); c.translate(-piv[0], -piv[1]);
+ c.lineCap = 'round'; c.lineJoin = 'round';
+ c.strokeStyle = C.red; c.lineWidth = 2.4; line(c, [[986, 214], [1050, 150], [1112, 210]]); c.stroke();
+ c.strokeStyle = C.black; c.lineWidth = 8; c.beginPath(); c.moveTo(1004, 326); c.quadraticCurveTo(960, 270, 990, 200); c.stroke();
+ c.beginPath(); c.moveTo(1034, 326); c.quadraticCurveTo(1080, 272, 1104, 204); c.stroke();
+ c.lineWidth = 7; line(c, [[978, 214], [1116, 212]]); c.stroke();
+ c.fillStyle = C.black; [[976, 214], [1118, 212]].forEach(([x, y]) => { c.beginPath(); c.arc(x, y, 6, 0, TAU); c.fill(); });
+ c.lineWidth = 1.5; for (let k = 0; k < 7; k++) { c.beginPath(); c.moveTo(1000 + k * 14, 214); c.lineTo(1008 + k * 3.6, 322); c.stroke(); }
+ c.beginPath(); c.arc(1019, 356, 44, 0, TAU); c.fill();
+ c.strokeStyle = C.inc; c.lineWidth = 1.6; c.beginPath(); c.arc(1019, 356, 37, 0, TAU); c.stroke();
+ c.beginPath(); c.arc(1019, 332, 8, 0.1, Math.PI - 0.1); c.stroke();
+ [[1019, 360], [1004, 352], [1034, 352], [1008, 372], [1030, 372]].forEach(([x, y]) => { c.beginPath(); c.arc(x, y, 6.5, 0, TAU); c.stroke(); });
+ c.restore();
+ c.fillStyle = C.black; c.beginPath(); c.arc(piv[0], piv[1], 5, 0, TAU); c.fill();
+ }
+
+ // ---------------- ⑤ 橘白猫:黑绘画法(黑釉剪影 + 陶土橙刻线虎斑 + 紫红/白附加色) ----------------
+ // 「橘」= 陶土橙刻线条纹 + 背/头顶紫红附加色;「白」= 白彩(胸、口鼻、爪);眼 = 古风刻线杏仁眼。
+ const CAT_W = '#efe1c8';
+ function cat(c, ch) {
+ const K = RIG.cat({ tail: ch.tail, blink: ch.blink, breathe: ch.breathe });
+ c.save(); c.lineJoin = 'round'; c.lineCap = 'round';
+ c.translate(548, 903); c.scale(0.9, 0.9); c.translate(-548, -903); // 猫整体缩到标准框 (390,610)-(690,905)
+ // 尾巴:黑剪影 + 紫红芯 + 陶土橙刻线环
+ const tp = K.tailPts, tail = new Path2D(); tp.forEach((p, i) => i ? tail.lineTo(p[0], p[1]) : tail.moveTo(p[0], p[1]));
+ c.strokeStyle = C.black; c.lineWidth = 22; c.stroke(tail); c.strokeStyle = C.red; c.lineWidth = 7; c.stroke(tail);
+ c.strokeStyle = C.catO; c.lineWidth = 2.6;
+ for (let i = 2; i < tp.length - 1; i += 2) { const a = tp[i - 1], b = tp[i + 1], ang = Math.atan2(b[1] - a[1], b[0] - a[0]) + Math.PI / 2; c.beginPath(); c.moveTo(tp[i][0] - Math.cos(ang) * 9, tp[i][1] - Math.sin(ang) * 9); c.lineTo(tp[i][0] + Math.cos(ang) * 9, tp[i][1] + Math.sin(ang) * 9); c.stroke(); }
+ c.translate(540, 902); c.scale(1, 1 + ch.breathe); c.translate(-540, -902); // 呼吸
+ const body = sm([[566, 680], [520, 698], [480, 736], [454, 790], [444, 850], [454, 896], [520, 902], [672, 902], [676, 886], [660, 872], [654, 800], [648, 738], [636, 698]]);
+ c.fillStyle = C.black; c.fill(body);
+ c.save(); c.clip(body);
+ // 背部紫红附加色鞍区(沿背轮廓内侧一条宽带)
+ c.strokeStyle = C.red; c.lineWidth = 26; c.beginPath(); c.moveTo(575, 690); c.bezierCurveTo(500, 700, 456, 760, 456, 880); c.stroke();
+ // 白彩胸
+ const white = sm([[600, 692], [640, 700], [646, 760], [636, 830], [628, 886], [604, 888], [596, 820], [590, 740]]);
+ c.fillStyle = CAT_W; c.fill(white);
+ // 刻线虎斑:沿背轮廓等距取点、朝身体中心刻弯线(陶土橙)
+ const back = [[570, 680], [520, 698], [480, 736], [454, 790], [444, 850], [454, 896]], seg = [];
+ for (let i = 1; i < back.length; i++) seg.push(Math.hypot(back[i][0] - back[i - 1][0], back[i][1] - back[i - 1][1]));
+ const tot = seg.reduce((a, b) => a + b, 0);
+ const at = (u) => { let d = u * tot, i = 0; while (i < seg.length - 1 && d > seg[i]) { d -= seg[i]; i++; } const q = d / seg[i]; return [lerp(back[i][0], back[i + 1][0], q), lerp(back[i][1], back[i + 1][1], q)]; };
+ c.strokeStyle = C.catO; c.lineWidth = 3;
+ for (let k = 0; k < 14; k++) { const a = at(0.03 + k * 0.068), dir = Math.atan2(800 - a[1], 575 - a[0]) + 0.25, L = 40 + (k % 3) * 12, nx = Math.cos(dir + Math.PI / 2), ny = Math.sin(dir + Math.PI / 2);
+ const b = [a[0] + Math.cos(dir) * L, a[1] + Math.sin(dir) * L]; c.beginPath(); c.moveTo(a[0] - Math.cos(dir) * 6, a[1] - Math.sin(dir) * 6); c.quadraticCurveTo((a[0] + b[0]) / 2 + nx * 6, (a[1] + b[1]) / 2 + ny * 6, b[0], b[1]); c.stroke(); }
+ [[[500, 830], [530, 806], [566, 816]], [[494, 858], [530, 838], [570, 850]], [[508, 884], [534, 868], [566, 878]]].forEach(s => { c.beginPath(); c.moveTo(...s[0]); c.quadraticCurveTo(...s[1], ...s[2]); c.stroke(); });
+ [[[650, 776], [670, 772]], [[650, 806], [670, 804]], [[648, 836], [666, 836]]].forEach(([a, b]) => { c.beginPath(); c.moveTo(...a); c.lineTo(...b); c.stroke(); });
+ c.restore();
+ // 刻线:后腿大腿弧、前腿分界
+ c.strokeStyle = C.inc; c.lineWidth = 2.2; c.beginPath(); c.arc(512, 860, 52, Math.PI * 1.08, Math.PI * 1.95); c.stroke();
+ c.beginPath(); c.moveTo(626, 770); c.lineTo(628, 884); c.stroke();
+ // 爪:白彩 + 黑刻趾
+ c.fillStyle = CAT_W; [[606, 893], [650, 893]].forEach(([x, y]) => { c.beginPath(); c.ellipse(x, y, 21, 10, 0, 0, TAU); c.fill(); c.strokeStyle = C.black; c.lineWidth = 1.8; [-7, 1, 9].forEach(o => { c.beginPath(); c.moveTo(x + o, y - 3); c.lineTo(x + o, y + 8); c.stroke(); }); });
+ c.fillStyle = C.black; c.beginPath(); c.ellipse(512, 894, 22, 9, 0, 0, TAU); c.fill();
+ c.strokeStyle = C.inc; c.lineWidth = 1.6; [504, 512, 520].forEach(x => { c.beginPath(); c.moveTo(x, 889); c.lineTo(x - 1, 900); c.stroke(); });
+ // 头:黑剪影,头顶紫红,白彩口鼻
+ const head = new Path2D(); head.ellipse(600, 630, 60, 52, 0, 0, TAU);
+ const ears = new Path2D(); ears.moveTo(548, 606); ears.lineTo(556, 540); ears.lineTo(592, 584); ears.closePath(); ears.moveTo(612, 582); ears.lineTo(650, 540); ears.lineTo(656, 606); ears.closePath();
+ c.fillStyle = C.black; c.fill(ears); c.fill(head);
+ c.save(); c.clip(head);
+ c.fillStyle = C.red; c.beginPath(); c.ellipse(600, 586, 46, 22, 0, 0, TAU); c.fill();
+ c.fillStyle = CAT_W; c.beginPath(); c.ellipse(608, 664, 32, 20, 0, 0, TAU); c.fill();
+ c.strokeStyle = C.catO; c.lineWidth = 2.6;
+ [[[584, 580], [590, 604]], [[600, 578], [600, 604]], [[616, 580], [610, 604]], [[542, 628], [562, 634]], [[544, 646], [562, 646]], [[658, 626], [640, 634]], [[658, 642], [642, 646]]].forEach(([a, b]) => { c.beginPath(); c.moveTo(...a); c.lineTo(...b); c.stroke(); });
+ c.restore();
+ c.strokeStyle = C.inc; c.lineWidth = 1.8; c.beginPath(); c.moveTo(560, 592); c.lineTo(563, 558); c.lineTo(580, 584); c.moveTo(624, 584); c.lineTo(645, 558); c.lineTo(648, 596); c.stroke();
+ // 古风刻线杏仁眼(白彩眼白 + 黑瞳)/ 眨眼
+ [[580, 622, -0.08], [628, 618, 0.08]].forEach(([x, y, r]) => {
+ c.save(); c.translate(x, y); c.rotate(r); c.strokeStyle = C.inc; c.lineWidth = 2;
+ if (ch.blink) { c.beginPath(); c.moveTo(-15, 0); c.quadraticCurveTo(0, 6, 15, 0); c.stroke(); c.restore(); return; }
+ const eye = new Path2D(); eye.moveTo(-15, 1); eye.quadraticCurveTo(0, -13, 15, 0); eye.quadraticCurveTo(0, 10, -15, 1);
+ c.fillStyle = CAT_W; c.fill(eye); c.stroke(eye);
+ c.fillStyle = C.black; c.beginPath(); c.ellipse(3, -1, 3.4, 5.6, 0, 0, TAU); c.fill();
+ c.beginPath(); c.moveTo(15, 0); c.lineTo(20, -2); c.stroke(); c.restore(); });
+ // 鼻(紫红)、刻线嘴、须
+ c.fillStyle = C.red; c.beginPath(); c.moveTo(603, 646); c.lineTo(619, 646); c.lineTo(611, 656); c.closePath(); c.fill();
+ c.strokeStyle = C.black; c.lineWidth = 2; c.beginPath(); c.moveTo(611, 656); c.lineTo(611, 662); c.moveTo(597, 662); c.quadraticCurveTo(604, 669, 611, 662); c.quadraticCurveTo(618, 669, 625, 662); c.stroke();
+ c.strokeStyle = C.inc; c.lineWidth = 1.4; [[[568, 652], [534, 646]], [[568, 660], [536, 666]]].forEach(([a, b]) => { c.beginPath(); c.moveTo(...a); c.lineTo(...b); c.stroke(); });
+ c.strokeStyle = C.black; [[[640, 656], [690, 648]], [[640, 662], [692, 668]]].forEach(([a, b]) => { c.beginPath(); c.moveTo(...a); c.lineTo(...b); c.stroke(); });
+ // 紫红项圈 + 白点
+ c.strokeStyle = C.red; c.lineWidth = 14; c.beginPath(); c.moveTo(556, 684); c.quadraticCurveTo(604, 704, 652, 688); c.stroke();
+ c.strokeStyle = C.inc; c.lineWidth = 1.4; [-7, 7].forEach(o => { c.beginPath(); c.moveTo(556, 684 + o); c.quadraticCurveTo(604, 704 + o, 652, 688 + o); c.stroke(); });
+ dots(c, [0.1, 0.25, 0.4, 0.55, 0.7, 0.85].map(u => { const x = (1 - u) * (1 - u) * 556 + 2 * u * (1 - u) * 604 + u * u * 652, y = (1 - u) * (1 - u) * 684 + 2 * u * (1 - u) * 704 + u * u * 688; return [x, y]; }), 2.2);
+ c.restore();
+ }
+
+ // ---------------- ⑥ 少女:黑釉剪影 + 刻线 + 附加色 + 金色卷发 ----------------
+ const R6 = rng(606);
+ const crownStrands = [...Array(11).keys()].map(k => ({ A: [1259 + k * 3.4, 311 + k * 5], C: [1314 + k * 2.6, 272 + k * 8.5], B: [1388 + k * 2.2, 318 + k * 6.5], ph: R6() * 6 }));
+ const locks = [...Array(8).keys()].map(k => ({ x0: 1374 + k * 5.5, y0: 372 + k * 2, x1: 1380 + k * 4.6, y1: 516 + (k % 3) * 13, ph: R6() * 6, a: 4.5 + R6() * 2.5 }));
+ const hairOut = [[1262, 296], [1298, 281], [1342, 284], [1378, 302], [1398, 326], [1414, 344], [1410, 372], [1416, 402], [1424, 452], [1422, 510], [1410, 550], [1392, 558], [1380, 512], [1366, 464], [1346, 436]];
+ const hairSil = [[1251, 320], ...hairOut, [1326, 422]];
+ const hairRegion = sm([[1254, 318], ...hairOut, [1326, 420], [1314, 396], [1306, 372], [1298, 348], [1284, 330], [1266, 322]]);
+ const faceSil = sm([[1290, 432], [1282, 418], [1262, 411], [1251, 403], [1246, 395], [1250, 389], [1244, 384], [1246, 377], [1235, 370], [1240, 358], [1246, 345], [1251, 330], [1254, 318],
+ ...hairSil.slice(1)]);
+ function curl(c, x, y, r, turns, dir = 1) { c.beginPath(); for (let a = 0; a <= turns * TAU; a += 0.3) { const rr = r * (1 - a / (turns * TAU) * 0.75); const px = x + Math.cos(a * dir) * rr, py = y + Math.sin(a * dir) * rr; a ? c.lineTo(px, py) : c.moveTo(px, py); } c.stroke(); }
+ const headM = (G) => { const NP = Tg(1300, 425); return new DOMMatrix().translate(NP[0], NP[1]).rotate(G.tilt * 180 / Math.PI).translate(-NP[0], -NP[1]).translate(1300, GDY + 620).scale(GS, GS).translate(-1300, -620); };
+ function head(c, G, ch, lt) {
+ const NP = Tg(1300, 425);
+ c.save(); c.translate(NP[0], NP[1]); c.rotate(G.tilt); c.translate(-NP[0], -NP[1]);
+ c.translate(1300, GDY + 620); c.scale(GS, GS); c.translate(-1300, -620);
+ c.lineCap = 'round'; c.lineJoin = 'round';
+ c.fillStyle = C.black; c.fill(faceSil);
+ // 金色卷发:头顶波浪发丝 + 发髻螺旋 + 背后长卷发绺(裁进发区)
+ c.save(); c.clip(hairRegion); c.strokeStyle = C.gold; c.lineWidth = 2.5;
+ crownStrands.forEach(({ A, C: Q, B, ph }) => { c.beginPath(); for (let i = 0; i <= 34; i++) { const u = i / 34, v = 1 - u;
+ const x = v * v * A[0] + 2 * u * v * Q[0] + u * u * B[0], y = v * v * A[1] + 2 * u * v * Q[1] + u * u * B[1];
+ const dx = 2 * v * (Q[0] - A[0]) + 2 * u * (B[0] - Q[0]), dy = 2 * v * (Q[1] - A[1]) + 2 * u * (B[1] - Q[1]), L = Math.hypot(dx, dy) || 1, o = 2.6 * Math.sin(u * Math.PI * 7 + ph);
+ i ? c.lineTo(x - dy / L * o, y + dx / L * o) : c.moveTo(x - dy / L * o, y + dx / L * o); } c.stroke(); });
+ locks.forEach(({ x0, y0, x1, y1, ph, a }) => { c.beginPath(); for (let i = 0; i <= 30; i++) { const u = i / 30, x = lerp(x0, x1, u) + a * Math.sin(u * Math.PI * 4.5 + ph), y = lerp(y0, y1, u); i ? c.lineTo(x, y) : c.moveTo(x, y); } c.stroke();
+ curl(c, x1 + a * Math.sin(Math.PI * 4.5 + ph) - 4, y1 + 2, 5.5, 1.3); });
+ curl(c, 1398, 344, 17, 2.4); curl(c, 1398, 344, 10, 1.4, -1);
+ c.restore();
+ // 额前小卷 + 鬓角螺旋卷
+ c.strokeStyle = C.gold; c.lineWidth = 2; [[1262, 314], [1268, 305], [1277, 298], [1288, 293]].forEach(([x, y]) => curl(c, x, y, 4.2, 1.4));
+ c.lineWidth = 2.2; [[1298, 350, 1300, 420], [1307, 356, 1312, 428]].forEach(([x0, y0, x1, y1], k) => { c.strokeStyle = C.black; c.lineWidth = 6; const pth = new Path2D();
+ for (let i = 0; i <= 40; i++) { const u = i / 40, x = lerp(x0, x1, u) + 5 * Math.sin(u * Math.PI * 9 + k), y = lerp(y0, y1, u); i ? pth.lineTo(x, y) : pth.moveTo(x, y); }
+ c.stroke(pth); c.strokeStyle = C.gold; c.lineWidth = 2.2; c.stroke(pth); });
+ // 紫红发带 + 白点
+ const band = new Path2D(); band.moveTo(1259, 307); band.quadraticCurveTo(1318, 276, 1406, 322);
+ c.strokeStyle = C.black; c.lineWidth = 14; c.stroke(band); c.strokeStyle = C.red; c.lineWidth = 10; c.stroke(band);
+ dots(c, [0.12, 0.3, 0.48, 0.66, 0.84].map(u => [(1 - u) * (1 - u) * 1259 + 2 * u * (1 - u) * 1318 + u * u * 1406, (1 - u) * (1 - u) * 307 + 2 * u * (1 - u) * 276 + u * u * 322]), 1.9);
+ // 耳 + 金耳环
+ c.fillStyle = C.black; c.beginPath(); c.ellipse(1316, 374, 9, 13, 0.15, 0, TAU); c.fill();
+ c.strokeStyle = C.inc; c.lineWidth = 1.6; c.beginPath(); c.ellipse(1316, 374, 9, 13, 0.15, -1.9, 1.6); c.stroke(); c.beginPath(); c.arc(1316, 374, 4, -1.5, 1.6); c.stroke();
+ c.fillStyle = C.gold; c.beginPath(); c.arc(1317, 393, 4, 0, TAU); c.fill();
+ // 刻线五官:杏仁大眼(古风正面眼)、眉、鼻翼、唇
+ c.strokeStyle = C.inc; c.lineWidth = 1.7;
+ c.beginPath(); c.moveTo(1251, 335); c.quadraticCurveTo(1264, 326, 1281, 333); c.stroke();
+ if (ch.blink) { c.beginPath(); c.moveTo(1253, 347); c.quadraticCurveTo(1266, 351, 1281, 346); c.stroke(); }
+ else {
+ const eye = new Path2D(); eye.moveTo(1252, 346); eye.quadraticCurveTo(1265, 335, 1282, 345); eye.quadraticCurveTo(1266, 354, 1252, 346);
+ c.fillStyle = '#f3dcc0'; c.fill(eye); c.stroke(eye);
+ c.fillStyle = C.black; c.beginPath(); c.arc(1263, 345, 4, 0, TAU); c.fill();
+ c.beginPath(); c.moveTo(1282, 345); c.lineTo(1287, 343); c.stroke();
+ }
+ c.beginPath(); c.moveTo(1241, 373); c.quadraticCurveTo(1247, 376, 1250, 372); c.stroke();
+ c.beginPath(); c.moveTo(1247, 389); c.quadraticCurveTo(1252, 391, 1256, 387); c.stroke();
+ c.beginPath(); c.moveTo(1262, 402); c.quadraticCurveTo(1270, 404, 1276, 400); c.stroke();
+ c.restore();
+ }
+ function girl(c, ch, lt, t) {
+ const G = RIG.girl({ cup: ch.cup, sip: ch.sip, breathe: ch.breathe, s: GS, dy: GDY, hair: 'long' });
+ c.save(); c.lineCap = 'round'; c.lineJoin = 'round';
+ // 剪影:远侧袖与手、裙、身、颈
+ c.fillStyle = C.black; [G.farSleeve, G.skirt, G.torso, G.neck].forEach(p => c.fill(p));
+ const fh = Tg(1212, 618); c.beginPath(); c.ellipse(fh[0], fh[1], 15, 11, 0.2, 0, TAU); c.fill();
+ const foot = smT([[1118, 906], [1080, 912], [1052, 922], [1048, 930], [1128, 931], [1142, 914]], true); c.fill(foot);
+ c.strokeStyle = C.inc; c.lineWidth = 1.6; [[[1074, 914], [1082, 930]], [[1096, 910], [1102, 930]], [[1052, 927], [1128, 927]], [[1080, 912], [1112, 922]]].forEach(s => { c.stroke(smT(s)); });
+ const body = new Path2D(); [G.torso, G.skirt, G.farSleeve, G.neck].forEach(p => body.addPath(p));
+ // 刻线衣褶(希顿长袍)
+ c.save(); c.clip(body); c.strokeStyle = C.inc; c.lineWidth = 1.8;
+ [[[1292, 448], [1312, 458], [1336, 452]], [[1342, 470], [1322, 520], [1300, 566]], [[1366, 478], [1346, 540], [1320, 596]], [[1392, 498], [1374, 560], [1352, 606]], [[1404, 522], [1410, 572], [1406, 612]],
+ [[1288, 614], [1340, 604], [1416, 614]], [[1180, 690], [1262, 668], [1360, 686], [1438, 698]], [[1164, 736], [1262, 724], [1352, 750]], [[1446, 660], [1440, 720], [1420, 760]],
+ [[1150, 770], [1134, 846], [1122, 912]], [[1184, 776], [1174, 852], [1166, 916]], [[1220, 780], [1216, 852], [1214, 918]], [[1260, 784], [1262, 856], [1262, 920]], [[1304, 786], [1308, 856], [1310, 920]], [[1340, 800], [1344, 860], [1344, 918]],
+ [[1240, 634], [1218, 662], [1196, 700]]].forEach(s => c.stroke(smT(s)));
+ // 下摆紫红宽带 + 白点 + 白点小花
+ const hb = smT([[1080, 892], [1220, 896], [1370, 892]]); c.strokeStyle = C.red; c.lineWidth = 15; c.stroke(hb);
+ c.strokeStyle = C.inc; c.lineWidth = 1.4; c.stroke(smT([[1080, 880], [1220, 884], [1370, 880]])); c.stroke(smT([[1080, 905], [1220, 909], [1370, 905]]));
+ dots(c, dotRow(1104, 1350, 894, 17).map(p => Tg(p[0], p[1] + (p[0] - 1220) * 0.0)), 2.2);
+ [[1235, 845], [1290, 826], [1172, 866], [1330, 712], [1388, 566], [1340, 530], [1206, 742], [1300, 680]].forEach(([x, y]) => { const p = Tg(x, y); dots(c, [[p[0] - 4, p[1]], [p[0] + 4, p[1]], [p[0], p[1] - 4], [p[0], p[1] + 4]], 1.7); });
+ c.restore();
+ // 长卷发 + 头(含倾斜)
+ head(c, G, ch, lt);
+ // 近侧手臂:黑 + 与身体重叠处刻线分隔 + 袖口紫红带 + 紫红手镯
+ // 时代化端杯:杯沿右端贴在嘴唇(不是 RIG 的鼻尖附近),杯身近水平,手托在杯脚下、不挡下巴
+ const HM = headM(G), lip = new DOMPoint(1243, 391).matrixTransform(HM), tab = Tg(1190, 596), q = ch.cup;
+ const rim = [lerp(tab[0] - 4, lip.x - 30, q), lerp(tab[1] - 14, lip.y + 1, q)];
+ G.kylix = { x: rim[0], y: rim[1], tilt: -0.08 * q };
+ const S = G.A.shoulder, hT = [rim[0] + lerp(32, 6, q), rim[1] + 30];
+ const { E, H: Hd } = RIG.ik2(S, hT, 165 * GS, 122 * GS, -1), fa = Math.atan2(Hd[1] - E[1], Hd[0] - E[0]);
+ const Wr = [lerp(E[0], Hd[0], 0.82), lerp(E[1], Hd[1], 0.82)];
+ const upperArm = RIG.taper(S, E, 54 * GS, 40 * GS, 10 * GS), foreArm = RIG.taper(E, Wr, 40 * GS, 30 * GS, 2 * GS);
+ const hand = new Path2D(); hand.ellipse(Hd[0], Hd[1], 17 * GS, 14 * GS, fa, 0, TAU);
+ c.fillStyle = C.black; [upperArm, foreArm, hand].forEach(p => c.fill(p));
+ const bodyH = new Path2D(); bodyH.addPath(body); bodyH.addPath(faceSil, HM);
+ c.save(); c.clip(bodyH); c.strokeStyle = C.inc; c.lineWidth = 2; [upperArm, foreArm, hand].forEach(p => c.stroke(p)); c.restore();
+ c.save(); c.clip(upperArm);
+ const M = [lerp(S[0], E[0], 0.6), lerp(S[1], E[1], 0.6)], aa = Math.atan2(E[1] - S[1], E[0] - S[0]), nx = Math.cos(aa + Math.PI / 2), ny = Math.sin(aa + Math.PI / 2);
+ c.strokeStyle = C.red; c.lineWidth = 15; c.beginPath(); c.moveTo(M[0] - nx * 40, M[1] - ny * 40); c.lineTo(M[0] + nx * 40, M[1] + ny * 40); c.stroke();
+ dots(c, [-12, 0, 12].map(k => [M[0] + nx * k, M[1] + ny * k]), 1.9);
+ c.strokeStyle = C.inc; c.lineWidth = 1.4; [-9, 9].forEach(o => { c.beginPath(); c.moveTo(M[0] + Math.cos(aa) * o - nx * 40, M[1] + Math.sin(aa) * o - ny * 40); c.lineTo(M[0] + Math.cos(aa) * o + nx * 40, M[1] + Math.sin(aa) * o + ny * 40); c.stroke(); });
+ c.restore();
+ const wr = [lerp(E[0], Hd[0], 0.74), lerp(E[1], Hd[1], 0.74)], qx = Math.cos(fa + Math.PI / 2), qy = Math.sin(fa + Math.PI / 2);
+ c.strokeStyle = C.red; c.lineWidth = 6; c.beginPath(); c.moveTo(wr[0] - qx * 14, wr[1] - qy * 14); c.lineTo(wr[0] + qx * 14, wr[1] + qy * 14); c.stroke();
+ // 基里克斯杯(宽浅双耳)
+ const cp = G.kylix; c.save(); c.translate(cp.x, cp.y); c.rotate(cp.tilt);
+ c.fillStyle = C.black; c.beginPath(); c.moveTo(-32, 0); c.quadraticCurveTo(0, 26, 32, 0); c.closePath(); c.fill();
+ c.fillRect(-3, 11, 6, 10); c.beginPath(); c.ellipse(0, 21, 12, 3.5, 0, 0, TAU); c.fill();
+ c.strokeStyle = C.black; c.lineWidth = 3.6; c.beginPath(); c.moveTo(-26, 5); c.quadraticCurveTo(-44, 0, -38, -8); c.stroke(); c.beginPath(); c.moveTo(26, 5); c.quadraticCurveTo(44, 0, 38, -8); c.stroke();
+ c.strokeStyle = C.red; c.lineWidth = 3; c.beginPath(); c.moveTo(-30, 1); c.lineTo(30, 1); c.stroke();
+ c.restore();
+ // 手:刻线手指
+ c.strokeStyle = C.inc; c.lineWidth = 1.5; [-5, 1, 7].forEach(o => { c.beginPath(); c.moveTo(Hd[0] - 10 + Math.cos(fa) * o * 0, Hd[1] + o); c.lineTo(Hd[0] + 4, Hd[1] + o - 2); c.stroke(); });
+ c.restore();
+ return G;
+ }
+ // 热气:杯口上方三道「≀」卷曲细线
+ function steam(c, G, t) {
+ const cp = G.kylix; c.save(); c.strokeStyle = C.black; c.lineWidth = 2.6; c.lineCap = 'round';
+ for (let k = -1; k <= 1; k++) { c.beginPath(); for (let i = 0; i <= 16; i++) { const u = i / 16, x = cp.x - 10 + k * 14 + 4.5 * Math.sin(u * TAU * 1.2 + t * 9 + k * 1.3), y = cp.y - 14 - u * 28; i ? c.lineTo(x, y) : c.moveTo(x, y); } c.stroke(); }
+ c.restore();
+ }
+
+ return {
+ draw(c, lt, t) {
+ const ch = P.choreo(lt, t);
+ c.drawImage(bg(), 0, 0);
+ // 纹带:原片节拍上的一次 easeInOut 周期跳 + 全程匀速漂移
+ const topOff = 48 * lt + TOP_P * IO(clamp((lt - 0.49) / 0.35));
+ const botOff = -(30 * lt + BOT_P * IO(clamp((lt - 0.477) / 0.367)));
+ const ts = ((topOff % TOP_P) + TOP_P) % TOP_P, bs = ((botOff % BOT_P) + BOT_P) % BOT_P;
+ c.drawImage(topStrip(), -ts, 30);
+ c.drawImage(botStrip(), -bs, 930);
+ c.drawImage(stat(), 0, 0);
+ panel(c, lt);
+ lyre(c, lt);
+ [[498, 628, 12], [436, 662, 20], [745, 742, 20], [330, 800, 16], [752, 860, 12]].forEach(([x, y, r], k) => rosette(c, x, y, r, lt * 1.6 * (k % 2 ? 1 : -1) + k));
+ cat(c, ch);
+ const G = girl(c, ch, lt, t);
+ steam(c, G, t);
+ c.drawImage(vignette(), 0, 0);
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/04_roman.js b/scripts/engine/scenes/04_roman.js
new file mode 100644
index 0000000..a0c8134
--- /dev/null
+++ b/scripts/engine/scenes/04_roman.js
@@ -0,0 +1,555 @@
+// 公元79年 庞贝马赛克(opus tessellatum / vermiculatum)——纯代码。
+// 管线:①平涂底稿(静态部分缓存,少女/猫/火山烟/边框卷涡每帧重画)
+// →②自写镶嵌渲染器:init 时一次性算好「石块布局」——距离场等值线上走线放石块(沿轮廓排,andamento)、
+// 远处规则成行;每块石头是带四边独立抖动的旋转方块,用「加权 L∞ Voronoi」光栅成 ID 图,相邻石块之间自然留灰浆缝;
+// 每像素预存斜面明暗(左上受光)+石纹颗粒
+// →③每帧只在动态矩形(少女、猫、火山画、边框带)里按石块中心去底稿取色重填——石块不动,颜色在石块间流动。
+SCENES['04_roman'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, rng } = U, P = PAINT;
+ const BW = 84; // 外框波浪纹带宽
+ const C = {
+ wall: '#e4ddcd', halo: '#f5f1e8', outline: '#46322a',
+ floor: '#dac9a0', floorLine: '#8f6c40',
+ bW: '#ece6d8', bK: '#24201d',
+ red: '#a8322a', red2: '#7c221d', gold: '#d0a23c', gold2: '#9f7420',
+ sky: '#9ec0d8', sky2: '#d3e3e4', cloud: '#88847d', cloud2: '#a9a49b',
+ cone: '#4e5796', coneL: '#7c84b8', coneD: '#2f3672', ridge: '#373e7c', green: '#6f9341', green2: '#92b254', ground: '#cba344', ground2: '#a67d2a',
+ cyp: '#2b5a2f', cyp2: '#4b7c3c', lava: '#d64a22', lava2: '#f2952c',
+ table: '#7f95ab', tableHi: '#aebfcd', tableD: '#5d7288',
+ chair: '#c69c3c', amph: '#b4472e', amphHi: '#d66c4a', amphD: '#7e2c1e',
+ stola: '#efe7d5', stolaF: '#cbbd9c', skin: '#efc4a0', hair: '#dcaa42', hairD: '#9c6c1c', lip: '#b8433a', eye: '#2a2420',
+ catO: '#dc8530', catO2: '#c06a24', catS: '#9c4818', catW: '#f7f2e8', catEye: '#e9c22c', collar: '#b02a22',
+ };
+ // 石块类别:尺寸 / 沿轮廓排几圈(99=全部沿轮廓)/ 颜色抖动幅度
+ const K_WALL = 0, K_HALO = 1, K_FIG = 2, K_FACE = 3, K_HAIR = 4, K_PIC = 5, K_FRAME = 6, K_BORDER = 7, K_TEXT = 8, K_FLOOR = 9, K_OBJ = 10, K_CAT = 11;
+ const SZ = [12, 11, 10, 5, 8, 9, 9, 7.6, 7, 13, 10, 9];
+ const KR = [1, 9, 99, 99, 99, 2, 99, 0, 99, 1, 99, 99];
+ const JIT = [.08, .05, .05, .04, .05, .06, .05, .05, .05, .065, .05, .05];
+
+ // ---------- 静态物件的路径 ----------
+ const rectP = (x, y, w, h) => { const p = new Path2D(); p.rect(x, y, w, h); return p; };
+ const FRAME = rectP(360, 120, 440, 440);
+ const TABLE_TOP = (() => { const p = new Path2D(); p.roundRect(820, 634, 380, 30, 15); return p; })();
+ const TABLE_PED = (() => { const p = new Path2D(); [[994, 664], [1026, 664], [1022, 700], [1034, 738], [1026, 780], [1040, 840], [1076, 882], [1080, 898], [940, 898], [944, 882], [980, 840], [994, 780], [986, 738], [998, 700]].forEach((q, i) => i ? p.lineTo(...q) : p.moveTo(...q)); p.closePath(); return p; })();
+ const CHAIR = (() => { const p = new Path2D(); p.rect(1460, 462, 14, 440); p.rect(1296, 724, 184, 14); p.rect(1306, 738, 12, 164); p.rect(1306, 818, 168, 9); p.moveTo(1476, 454); p.arc(1467, 454, 9, 0, Math.PI * 2); return p; })();
+ const AMPH = RIG.smooth([[1712, 616], [1744, 616], [1746, 652], [1772, 690], [1768, 760], [1752, 830], [1734, 884], [1729, 900], [1724, 884], [1704, 830], [1688, 760], [1686, 690], [1710, 652]]);
+ const AMPH_LIP = rectP(1702, 604, 52, 13);
+ const AMPH_H = (() => { const p = new Path2D(); p.moveTo(1714, 628); p.bezierCurveTo(1684, 628, 1682, 660, 1692, 690); p.moveTo(1742, 628); p.bezierCurveTo(1772, 628, 1774, 660, 1764, 690); return p; })();
+ // 少女的罗马服饰:披肩 palla(背后斜披+盖过膝+前襟垂下)
+ const PALLA_BACK = RIG.smooth([[1350, 436], [1384, 440], [1408, 472], [1422, 532], [1432, 600], [1448, 662], [1454, 722], [1440, 766], [1392, 772], [1398, 700], [1394, 620], [1380, 540], [1362, 482]]);
+ const PALLA_LAP = RIG.smooth([[1418, 612], [1448, 652], [1454, 722], [1440, 766], [1362, 778], [1290, 768], [1226, 744], [1200, 722], [1236, 712], [1300, 716], [1360, 700], [1392, 660]]);
+ const PALLA_HANG = RIG.smooth([[1322, 768], [1366, 774], [1360, 850], [1356, 912], [1324, 914], [1330, 840]]);
+ const PALLA_FOLDS = [[[1372, 470], [1398, 560], [1412, 660], [1418, 740]], [[1236, 730], [1300, 742], [1370, 744], [1424, 734]]].map(q => RIG.smooth(q, false));
+
+ // ---------- 平涂底稿:静态部分 ----------
+ function picture(g) {
+ g.save(); g.beginPath(); g.rect(392, 152, 376, 376); g.clip();
+ const sg = g.createLinearGradient(0, 152, 0, 470); sg.addColorStop(0, C.sky); sg.addColorStop(1, C.sky2); g.fillStyle = sg; g.fillRect(392, 152, 376, 376);
+ g.strokeStyle = '#e4eeee'; g.lineWidth = 5; [[410, 250, 500], [620, 262, 760], [400, 300, 470], [640, 318, 750]].forEach(([a, y, b]) => { g.beginPath(); g.moveTo(a, y); g.lineTo(b, y); g.stroke(); });
+ // 火山:三面
+ const poly = (pts, col) => { g.fillStyle = col; g.beginPath(); pts.forEach((q, i) => i ? g.lineTo(...q) : g.moveTo(...q)); g.closePath(); g.fill(); };
+ poly([[402, 472], [535, 222], [560, 222], [520, 472]], C.coneL);
+ poly([[520, 472], [560, 222], [586, 222], [646, 472]], C.cone);
+ poly([[646, 472], [586, 222], [738, 472]], C.coneD);
+ g.strokeStyle = C.ridge; g.lineWidth = 5; [[[548, 226], [500, 330], [470, 420]], [[574, 226], [600, 330], [620, 440]]].forEach(l => { g.beginPath(); l.forEach((q, i) => i ? g.lineTo(...q) : g.moveTo(...q)); g.stroke(); });
+ g.fillStyle = '#2a2c48'; g.beginPath(); g.ellipse(560, 222, 27, 6, 0, 0, Math.PI * 2); g.fill();
+ // 熔岩
+ g.lineCap = 'round'; g.lineJoin = 'round';
+ g.strokeStyle = C.lava; g.lineWidth = 8; g.beginPath(); g.moveTo(566, 226); g.lineTo(580, 262); g.lineTo(596, 298); g.lineTo(614, 334); g.stroke();
+ g.strokeStyle = C.lava2; g.lineWidth = 5; g.beginPath(); g.moveTo(552, 228); g.lineTo(544, 262); g.lineTo(538, 290); g.stroke();
+ // 山坡、地面、柏树
+ g.fillStyle = C.green; g.beginPath(); g.moveTo(392, 462); g.quadraticCurveTo(470, 430, 560, 456); g.quadraticCurveTo(650, 482, 768, 448); g.lineTo(768, 528); g.lineTo(392, 528); g.fill();
+ g.fillStyle = C.green2; g.beginPath(); g.moveTo(392, 482); g.quadraticCurveTo(480, 462, 580, 484); g.quadraticCurveTo(680, 502, 768, 476); g.lineTo(768, 528); g.lineTo(392, 528); g.fill();
+ g.fillStyle = C.ground; g.beginPath(); g.moveTo(392, 502); g.quadraticCurveTo(560, 488, 768, 504); g.lineTo(768, 528); g.lineTo(392, 528); g.fill();
+ g.strokeStyle = C.ground2; g.lineWidth = 4; g.beginPath(); g.moveTo(400, 515); for (let x = 400; x <= 768; x += 24) g.quadraticCurveTo(x + 6, 510, x + 12, 516); g.stroke();
+ [[702, 258, 500, 17], [740, 276, 498, 14]].forEach(([x, top, bot, w]) => {
+ g.fillStyle = C.cyp; g.beginPath(); g.moveTo(x, top); g.quadraticCurveTo(x + w * 1.1, top + 110, x + w * 0.75, bot); g.lineTo(x - w * 0.75, bot); g.quadraticCurveTo(x - w * 1.1, top + 110, x, top); g.fill();
+ g.strokeStyle = C.cyp2; g.lineWidth = 5; g.beginPath(); g.moveTo(x - 3, top + 30); g.lineTo(x - 6, bot - 10); g.stroke();
+ });
+ g.restore();
+ }
+ function staticScene(g) {
+ g.fillStyle = C.wall; g.fillRect(0, 0, W, H);
+ g.fillStyle = C.floor; g.fillRect(BW, 905, W - 2 * BW, H - BW - 905);
+ // 物件晕圈(白石沿轮廓)
+ g.lineJoin = 'round'; g.strokeStyle = C.halo;
+ g.lineWidth = 44; g.stroke(FRAME); g.stroke(TABLE_TOP); g.stroke(TABLE_PED); g.stroke(AMPH); g.stroke(AMPH_LIP); g.stroke(AMPH_H);
+ g.lineWidth = 34; g.stroke(CHAIR);
+ g.strokeStyle = C.floorLine; g.lineWidth = 6; g.beginPath(); g.moveTo(BW, 905); g.lineTo(W - BW, 905); g.stroke();
+ // 画框:红框 → 深线 → 金线 → 深线 → 画
+ g.fillStyle = C.red; g.fillRect(360, 120, 440, 440);
+ g.fillStyle = C.red2; g.fillRect(376, 136, 408, 408);
+ g.fillStyle = C.gold; g.fillRect(381, 141, 398, 398);
+ g.fillStyle = '#3a2a22'; g.fillRect(387, 147, 386, 386);
+ picture(g);
+ g.strokeStyle = C.outline; g.lineWidth = 5; g.stroke(FRAME);
+ // 椅子(在少女后面)
+ g.fillStyle = C.chair; g.fill(CHAIR); g.strokeStyle = '#7d5c1c'; g.lineWidth = 5; g.stroke(CHAIR);
+ // 桌子:蓝灰圆桌面+喇叭形单柱
+ g.fillStyle = C.table; g.fill(TABLE_PED);
+ g.save(); g.clip(TABLE_PED); g.fillStyle = '#93a8bb'; g.fillRect(940, 660, 52, 240); g.fillStyle = C.tableD; g.fillRect(1030, 660, 60, 240);
+ g.fillStyle = '#c33a2c'; g.fillRect(940, 736, 140, 9); g.fillStyle = '#3d5a9a'; g.fillRect(940, 748, 140, 7); g.restore();
+ g.strokeStyle = C.outline; g.lineWidth = 6; g.stroke(TABLE_PED);
+ g.fillStyle = C.table; g.fill(TABLE_TOP); g.fillStyle = C.tableHi; g.fillRect(834, 638, 352, 9); g.stroke(TABLE_TOP);
+ // 陶罐
+ g.strokeStyle = C.amphD; g.lineWidth = 9; g.lineCap = 'round'; g.stroke(AMPH_H);
+ g.fillStyle = C.amph; g.fill(AMPH); g.fill(AMPH_LIP);
+ g.save(); g.clip(AMPH); g.fillStyle = C.amphHi; g.fillRect(1698, 640, 14, 200); g.fillStyle = C.amphD; g.fillRect(1748, 640, 30, 260); g.restore();
+ g.strokeStyle = C.outline; g.lineWidth = 6; g.stroke(AMPH); g.stroke(AMPH_LIP);
+ // CAVE CATTVM:碑刻大写,黑石
+ // 字母自己写笔画(等宽粗笔画最像石块拼字;字体的细横笔在 7px 石块下会断):60px 高,笔画 12px
+ const GL = { C: [44, g2 => g2.ellipse(22, 30, 19, 26, 0, Math.PI * 0.27, Math.PI * 1.73)], A: [46, [[[0, 60], [23, 0], [46, 60]], [[11, 38], [35, 38]]]], V: [46, [[[0, 0], [23, 60], [46, 0]]]],
+ E: [38, [[[38, 6], [6, 6], [6, 54], [38, 54]], [[6, 30], [32, 30]]]], T: [46, [[[0, 6], [46, 6]], [[23, 6], [23, 60]]]], M: [52, [[[4, 60], [6, 0], [26, 46], [46, 0], [48, 60]]]] };
+ g.save(); g.strokeStyle = '#1d1a18'; g.lineWidth = 14; g.lineJoin = 'miter'; g.lineCap = 'butt';
+ const TXT = 'CAVE CATTVM', gap = 16; let tx = 0; const lay = [];
+ for (const ch of TXT) { if (ch === ' ') { tx += 30; continue; } lay.push([ch, tx]); tx += GL[ch][0] + gap; }
+ const sc = 600 / (tx - gap); g.translate(270, 922); g.scale(sc, 1);
+ for (const [ch, x0] of lay) { const gl = GL[ch][1]; g.beginPath(); if (typeof gl === 'function') { g.save(); g.translate(x0, 0); gl(g); g.restore(); } else gl.forEach(l => l.forEach((q, k) => k ? g.lineTo(x0 + q[0], q[1]) : g.moveTo(x0 + q[0], q[1]))); g.stroke(); }
+ g.restore();
+ // 鱼与老鼠(小石块)
+ g.fillStyle = '#5f5b57'; g.beginPath(); g.ellipse(1446, 950, 40, 8, 0, 0, Math.PI * 2); g.fill();
+ g.beginPath(); g.moveTo(1408, 950); g.lineTo(1386, 938); g.lineTo(1386, 962); g.closePath(); g.fill();
+ g.strokeStyle = '#d8ccb0'; g.lineWidth = 2.5; for (let k = 0; k < 5; k++) { g.beginPath(); g.moveTo(1420 + k * 11, 944); g.lineTo(1426 + k * 11, 956); g.stroke(); }
+ g.fillStyle = '#86807a'; g.beginPath(); g.ellipse(1784, 960, 22, 10, 0, 0, Math.PI * 2); g.fill();
+ g.beginPath(); g.moveTo(1800, 952); g.lineTo(1824, 962); g.lineTo(1800, 968); g.fill(); g.beginPath(); g.arc(1798, 950, 5, 0, Math.PI * 2); g.fill();
+ g.strokeStyle = '#86807a'; g.lineWidth = 3; g.beginPath(); g.moveTo(1764, 962); g.quadraticCurveTo(1748, 950, 1738, 966); g.stroke();
+ // 内框黑线
+ g.fillStyle = C.bK; g.fillRect(BW - 2, BW - 2, W - 2 * BW + 4, 6); g.fillRect(BW - 2, H - BW - 4, W - 2 * BW + 4, 6); g.fillRect(BW - 2, BW - 2, 6, H - 2 * BW + 4); g.fillRect(W - BW - 4, BW - 2, 6, H - 2 * BW + 4);
+ }
+
+ // ---------- 平涂底稿:会动的部分 ----------
+ // 四边波浪纹(维特鲁威卷涡),每条边在自己的局部坐标里画同一个图案:u 沿顺时针方向,v 从外往里
+ const PER = 81;
+ const SIDES = [[1, 0, 0, 1, 0, 0, W], [0, 1, -1, 0, W, 0, H], [-1, 0, 0, -1, W, H, W], [0, -1, 1, 0, 0, H, H]];
+ function border(g, phase) {
+ for (const [a, b, c2, d, e, f, len] of SIDES) {
+ g.save(); g.setTransform(a, b, c2, d, e, f);
+ g.beginPath(); g.rect(BW, 0, len - 2 * BW, BW); g.clip();
+ g.fillStyle = C.bW; g.fillRect(0, 0, len, BW);
+ g.fillStyle = C.bK; g.fillRect(0, 0, len, 8); g.fillRect(0, 66, len, BW - 66);
+ g.strokeStyle = C.bK; g.lineWidth = 13; g.lineCap = 'round'; g.lineJoin = 'round';
+ const off = ((phase % PER) + PER) % PER;
+ for (let u0 = BW - 2 * PER + off; u0 < len + PER; u0 += PER) {
+ const cx = u0 + PER * 0.52, cy = 38, r0 = 24;
+ g.beginPath(); g.moveTo(u0 - 6, 68); g.quadraticCurveTo(u0 + 2, 42, cx - r0, cy);
+ for (let th = Math.PI; th <= Math.PI * 3.25; th += 0.14) { const r = r0 - (th - Math.PI) / (Math.PI * 2.25) * (r0 - 5); g.lineTo(cx + Math.cos(th) * r, cy + Math.sin(th) * r); }
+ g.stroke();
+ }
+ g.restore();
+ }
+ // 四角方块饰
+ for (const [x, y] of [[0, 0], [W - BW, 0], [0, H - BW], [W - BW, H - BW]]) {
+ g.fillStyle = C.bK; g.fillRect(x, y, BW, BW); g.fillStyle = C.bW; g.fillRect(x + 10, y + 10, BW - 20, BW - 20);
+ g.fillStyle = C.bK; g.fillRect(x + 22, y + 22, BW - 44, BW - 44); g.fillStyle = C.red; g.fillRect(x + 33, y + 33, BW - 66, BW - 66);
+ }
+ }
+ // 火山烟团+火星(全局时间驱动,连续)
+ function volcanoFX(g, t) {
+ g.save(); g.beginPath(); g.rect(392, 152, 376, 376); g.clip();
+ // 云带(火山灰云)向右漂:周期 380px,一秒 55px
+ const cx0 = (t * 55) % 380;
+ for (const ox of [-380, 0]) [[28, 168, 46, 18, C.cloud], [108, 162, 52, 16, C.cloud2], [218, 166, 50, 18, C.cloud], [308, 170, 58, 17, C.cloud2], [63, 192, 36, 10, C.cloud2], [278, 195, 40, 10, C.cloud]]
+ .forEach(([x, y, rx, ry, col]) => { g.fillStyle = col; g.beginPath(); g.ellipse(392 + x + ox + cx0, y, rx, ry, 0, 0, Math.PI * 2); g.fill(); });
+ const N = 9;
+ for (let i = 0; i < N; i++) {
+ const q = ((t * 0.85 + i / N) % 1), e = 1 - Math.pow(1 - q, 1.6);
+ const x = 560 + e * 175 + Math.sin(t * 2 + i * 2.1) * 10, y = 212 - e * 62 - Math.sin(e * 3.1) * 18, r = 13 + q * 40; // 烟柱往右压低飘(留在画框天空里才看得见)
+ const col = P.mix(P.hex('#3f3c3a'), P.hex('#a29c94'), Math.min(1, q * 1.1));
+ g.globalAlpha = q > 0.8 ? (1 - q) / 0.2 : 1;
+ g.fillStyle = P.rgb(col); g.beginPath(); g.arc(x, y, r, 0, Math.PI * 2); g.fill();
+ g.fillStyle = P.rgb(P.mix(col, [255, 255, 255], 0.3)); g.beginPath(); g.arc(x - r * 0.3, y - r * 0.3, r * 0.45, 0, Math.PI * 2); g.fill();
+ }
+ g.globalAlpha = 1;
+ const r = rng(79);
+ for (let i = 0; i < 12; i++) {
+ const ang = -Math.PI / 2 + (r() - 0.5) * 2.0, sp = 130 + r() * 110, ph = r();
+ const q = (t * 1.25 + ph) % 1, tt = q * 0.9;
+ const x = 560 + Math.cos(ang) * sp * tt, y = 216 + Math.sin(ang) * sp * tt + 260 * tt * tt;
+ g.fillStyle = r() < 0.5 ? '#f6d23c' : '#f08a22'; g.fillRect(x - 5, y - 5, 10, 10);
+ }
+ // 火山口熔岩脉动
+ g.fillStyle = `rgba(246,160,40,${0.55 + 0.45 * Math.sin(t * 9)})`; g.beginPath(); g.ellipse(560, 220, 20, 6, 0, 0, Math.PI * 2); g.fill();
+ g.restore();
+ }
+ // 少女:罗马斯托拉+红色披肩+金发罗马发髻
+ const rot = (G, x, y) => { const c = Math.cos(G.tilt), s = Math.sin(G.tilt), X = x - 1300, Y = y - 425; return [1300 + X * c - Y * s, 425 + X * s + Y * c]; };
+ // 近侧手臂:不用骨架原举杯路线(终点杯子戳在鼻子上、手臂挡脸)。杯沿右端贴到唇高、倾角 ≤8.6°,手托在杯脚下,
+ // 杯子走「桌面 → 前上方 → 唇前」的二次贝塞尔;IK 用骨架同一副臂长(165/122)与肘向。
+ function armPose(G, k) {
+ const S = G.A.shoulder, lip = G.lips[0];
+ const A0 = [1186, 584], A2 = [lip[0] - 31, lip[1] - 3], A1 = [1150, 470], u = 1 - k;
+ const cp = [u * u * A0[0] + 2 * u * k * A1[0] + k * k * A2[0], u * u * A0[1] + 2 * u * k * A1[1] + k * k * A2[1]];
+ const cup = { x: cp[0], y: cp[1], w: 44, h: 38, tilt: 0.15 * k };
+ const hT = [cp[0] + lerp(40, 3, k), cp[1] + lerp(32, 56, k)];
+ const { E, H } = RIG.ik2(S, hT, 165, 122, -1);
+ const W_ = [lerp(E[0], H[0], 0.82), lerp(E[1], H[1], 0.82)], fa = Math.atan2(H[1] - E[1], H[0] - E[0]);
+ const hand = new Path2D(); hand.ellipse(H[0], H[1], 17, 14, fa, 0, Math.PI * 2);
+ return { S, E, H, cup, upperArm: RIG.taper(S, E, 54, 40, 10), foreArm: RIG.taper(E, W_, 40, 30, 2), cuff: RIG.taper([lerp(E[0], H[0], 0.74), lerp(E[1], H[1], 0.74)], W_, 32, 31), hand };
+ }
+ function girl(g, G, { nearArm = true, steam = 0, t = 0, blink = 0, cup = 0 } = {}) {
+ const AP = armPose(G, cup);
+ g.save(); g.lineJoin = 'round'; g.lineCap = 'round';
+ const sil = [G.skirt, G.torso, G.farSleeve, G.farHand, G.hairBack, G.bun, G.neck, G.face, G.bangs, PALLA_BACK, PALLA_LAP, PALLA_HANG, G.shoe];
+ const arm = nearArm ? [AP.upperArm, AP.foreArm, AP.hand] : [];
+ g.strokeStyle = C.halo; g.lineWidth = 50; sil.concat(arm).forEach(p => p && g.stroke(p));
+ if (nearArm) { g.fillStyle = C.halo; g.beginPath(); g.arc(AP.cup.x, AP.cup.y + 26, 60, 0, Math.PI * 2); g.fill(); }
+ const F = (p, col, lw = 8) => { if (!p) return; g.fillStyle = col; g.fill(p); if (lw) { g.strokeStyle = C.outline; g.lineWidth = lw; g.stroke(p); } };
+ F(G.farSleeve, C.stola); F(G.farHand, C.skin, 6); F(G.farCuff, C.gold, 0);
+ F(G.skirt, C.stola);
+ g.save(); g.clip(G.skirt); g.fillStyle = C.red; g.fillRect(1080, 878, 400, 10); g.fillRect(1080, 897, 400, 9);
+ g.strokeStyle = C.stolaF; g.lineWidth = 6; G.folds.forEach(f => g.stroke(f)); g.restore();
+ g.strokeStyle = C.outline; g.lineWidth = 8; g.stroke(G.skirt);
+ F(G.shoe, '#6b4428', 6);
+ F(G.torso, C.stola);
+ g.save(); g.clip(G.torso); g.strokeStyle = C.stolaF; g.lineWidth = 6; [[1300, 470, 1306, 600], [1330, 480, 1340, 605]].forEach(([a, b, c2, d]) => { g.beginPath(); g.moveTo(a, b); g.quadraticCurveTo(a + 8, (b + d) / 2, c2, d); g.stroke(); }); g.restore();
+ F(PALLA_BACK, C.red); F(PALLA_LAP, C.red); F(PALLA_HANG, C.red, 7);
+ g.strokeStyle = C.red2; g.lineWidth = 7; PALLA_FOLDS.forEach(f => g.stroke(f));
+ g.fillStyle = C.gold; g.beginPath(); g.arc(1372, 446, 10, 0, Math.PI * 2); g.fill(); g.strokeStyle = C.gold2; g.lineWidth = 3; g.stroke();
+ F(G.neck, C.skin, 6);
+ F(G.hairBack, C.hair, 7); F(G.bun, C.hair, 7);
+ g.strokeStyle = C.hairD; g.lineWidth = 4; g.beginPath(); for (let a = 0; a < 8; a += 0.25) { const r = 4 + a * 3, x = G.bunSpiral[0] + Math.cos(a) * r, y = G.bunSpiral[1] + Math.sin(a) * r; a ? g.lineTo(x, y) : g.moveTo(x, y); } g.stroke();
+ F(G.face, C.skin, 10);
+ g.fillStyle = C.skin; g.beginPath(); g.ellipse(G.ear[0], G.ear[1], 8, 12, 0.2, 0, Math.PI * 2); g.fill(); g.strokeStyle = C.outline; g.lineWidth = 4; g.stroke();
+ g.fillStyle = C.gold; g.beginPath(); g.arc(G.ear[0] - 1, G.ear[1] + 16, 5, 0, Math.PI * 2); g.fill();
+ F(G.bangs, C.hair, 6);
+ g.strokeStyle = C.hairD; g.lineWidth = 4; G.hairLines.forEach(h => g.stroke(h));
+ // 红色发带
+ const f0 = rot(G, 1256, 322), f1 = rot(G, 1282, 294), f2 = rot(G, 1342, 286), f3 = rot(G, 1378, 334);
+ g.strokeStyle = C.red; g.lineWidth = 8; g.beginPath(); g.moveTo(...f0); g.bezierCurveTo(...f1, ...f2, ...f3); g.stroke();
+ // 五官(小石块尺度:眼一块深色,眉、唇)
+ if (blink) { g.strokeStyle = C.eye; g.lineWidth = 4; g.stroke(G.lid); }
+ else { g.fillStyle = '#fbf8f0'; g.beginPath(); g.ellipse(G.eye.x + 3, G.eye.y + 1, 13, 7, 0, 0, Math.PI * 2); g.fill(); g.fillStyle = C.eye; g.beginPath(); g.ellipse(G.eye.x - 1, G.eye.y + 1, 8, 7, 0, 0, Math.PI * 2); g.fill(); g.strokeStyle = C.eye; g.lineWidth = 5; g.stroke(G.lid); }
+ g.strokeStyle = '#4a3020'; g.lineWidth = 6; g.stroke(G.brow);
+ { const l0 = G.lips[0], l2 = G.lips[2]; g.fillStyle = '#a8282a'; g.beginPath(); g.ellipse((l0[0] + l2[0]) / 2 + 4, (l0[1] + l2[1]) / 2, 8.5, 6, -0.3, 0, Math.PI * 2); g.fill(); }
+ if (nearArm) {
+ F(AP.upperArm, C.skin, 6); F(AP.foreArm, C.skin, 6);
+ g.save(); g.clip(AP.upperArm); const sh0 = G.A.shoulder; g.fillStyle = C.stola; g.beginPath(); g.arc(sh0[0], sh0[1], 62, 0, Math.PI * 2); g.fill(); g.strokeStyle = C.red; g.lineWidth = 9; g.beginPath(); g.arc(sh0[0], sh0[1], 62, 0, Math.PI * 2); g.stroke(); g.restore(); g.strokeStyle = C.outline; g.lineWidth = 6; g.stroke(AP.upperArm);
+ F(AP.cuff, C.gold, 0);
+ F(AP.hand, C.skin, 6); // 手托杯脚;杯子本身由 cupSprite 叠在马赛克上
+ }
+ g.restore();
+ }
+ // 猫:用 RIG.cat 的锚点重画——平滑梨形身体、虎斑、白胸白爪、大黄眼、红项圈
+ const CATS = 0.85, catT = (g) => { g.translate(540, 905); g.scale(CATS, CATS); g.translate(-540, -905); };
+ const catPt = ([x, y]) => [540 + (x - 540) * CATS, 905 + (y - 905) * CATS];
+ function cat(g, K) {
+ g.save(); catT(g); g.lineJoin = 'round'; g.lineCap = 'round';
+ const body = RIG.smooth(K.bodyPts);
+ const tail = new Path2D(); K.tailPts.forEach((q, i) => i ? tail.lineTo(...q) : tail.moveTo(...q));
+ g.strokeStyle = C.halo; g.lineWidth = 50; g.stroke(body); g.stroke(K.head); K.legs.forEach(l => g.stroke(l)); g.lineWidth = K.tailW + 50; g.stroke(tail);
+ // 尾巴:深描边 → 橘 → 深橘环纹 → 白尖
+ g.strokeStyle = C.outline; g.lineWidth = K.tailW + 12; g.stroke(tail);
+ g.strokeStyle = C.catO; g.lineWidth = K.tailW; g.stroke(tail);
+ g.strokeStyle = C.catS; g.setLineDash([9, 13]); g.lineDashOffset = 4; g.lineWidth = K.tailW - 2; g.lineCap = 'butt'; g.stroke(tail); g.setLineDash([]); g.lineCap = 'round';
+ const tip = K.tailPts[K.tailPts.length - 1]; g.fillStyle = C.catW; g.beginPath(); g.arc(tip[0], tip[1], K.tailW / 2, 0, Math.PI * 2); g.fill();
+ // 身体
+ g.fillStyle = C.catO; g.fill(body);
+ g.save(); g.clip(body); g.fillStyle = C.catO2; g.beginPath(); g.ellipse(K.bodyPts[2][0] + 10, K.bodyPts[2][1] + 40, 52, 110, 0.1, 0, Math.PI * 2); g.fill();
+ g.strokeStyle = C.catS; g.lineWidth = 10; K.stripes.slice(3).forEach(s => { g.beginPath(); g.moveTo(...s[0]); g.lineTo(...s[1]); g.stroke(); });
+ const hx = K.bodyPts[1][0], hy = K.bodyPts[1][1];
+ g.lineWidth = 8; g.strokeStyle = C.catS; g.beginPath(); g.arc(hx + 62, hy - 6, 50, Math.PI * 0.95, Math.PI * 1.6); g.stroke(); // 后腿轮廓
+ g.beginPath(); g.arc(hx + 62, hy - 6, 30, Math.PI * 1.0, Math.PI * 1.55); g.stroke();
+ g.restore();
+ g.strokeStyle = C.outline; g.lineWidth = 8; g.stroke(body);
+ K.legs.forEach(l => { g.fillStyle = C.catW; g.fill(l); });
+ g.fillStyle = C.catW; g.fill(K.white);
+ K.legs.forEach(l => { g.strokeStyle = C.outline; g.lineWidth = 5; g.stroke(l); });
+ // 红项圈+金坠
+ const hc = K.headC;
+ g.strokeStyle = C.collar; g.lineWidth = 13; g.beginPath(); g.moveTo(hc[0] - 46, hc[1] + 52); g.quadraticCurveTo(hc[0] + 2, hc[1] + 80, hc[0] + 52, hc[1] + 52); g.stroke();
+ g.fillStyle = C.gold; g.beginPath(); g.arc(hc[0] + 6, hc[1] + 76, 7, 0, Math.PI * 2); g.fill();
+ // 头
+ // 头:正脸(庞贝猫马赛克是正面瞪眼)。脸中线 x≈604(两耳尖中点)
+ const fx = hc[0] + 4, fy = hc[1];
+ g.fillStyle = C.catO; g.fill(K.head);
+ g.save(); g.clip(K.head); g.fillStyle = C.catW; g.beginPath(); g.ellipse(fx, fy + 30, 34, 24, 0, 0, Math.PI * 2); g.fill();
+ g.strokeStyle = C.catS; g.lineWidth = 7; K.stripes.slice(0, 3).forEach(s => { g.beginPath(); g.moveTo(...s[0]); g.lineTo(...s[1]); g.stroke(); });
+ [[-1], [1]].forEach(([d]) => { g.beginPath(); g.moveTo(fx + d * 66, fy + 4); g.lineTo(fx + d * 44, fy + 8); g.stroke(); g.beginPath(); g.moveTo(fx + d * 64, fy + 20); g.lineTo(fx + d * 46, fy + 20); g.stroke(); });
+ g.restore();
+ g.strokeStyle = C.outline; g.lineWidth = 11; g.stroke(K.head);
+ g.fillStyle = '#e9a08e'; K.earInner.forEach(e => { g.beginPath(); e.forEach((p, i) => i ? g.lineTo(...p) : g.moveTo(...p)); g.fill(); });
+ // 大黄圆眼+黑竖瞳+深色眼眶(庞贝猫标志)
+ [[fx - 24, fy - 8], [fx + 24, fy - 10]].forEach(([ex, ey]) => {
+ const R = 17;
+ if (K.blink) { g.fillStyle = C.catO; g.beginPath(); g.arc(ex, ey, R, 0, Math.PI * 2); g.fill(); g.strokeStyle = C.eye; g.lineWidth = 7; g.beginPath(); g.moveTo(ex - R, ey + 2); g.quadraticCurveTo(ex, ey + 8, ex + R, ey + 2); g.stroke(); }
+ else { g.fillStyle = C.catEye; g.beginPath(); g.arc(ex, ey, R, 0, Math.PI * 2); g.fill(); g.strokeStyle = C.eye; g.lineWidth = 7; g.stroke(); g.fillStyle = C.eye; g.beginPath(); g.ellipse(ex, ey, 4.5, 11, 0, 0, Math.PI * 2); g.fill(); }
+ });
+ g.fillStyle = '#c96a5c'; g.beginPath(); g.moveTo(fx - 8, fy + 16); g.lineTo(fx + 8, fy + 16); g.lineTo(fx, fy + 25); g.closePath(); g.fill();
+ g.strokeStyle = C.eye; g.lineWidth = 4; g.beginPath(); g.moveTo(fx, fy + 25); g.lineTo(fx, fy + 31); g.moveTo(fx - 12, fy + 36); g.quadraticCurveTo(fx - 5, fy + 38, fx, fy + 31); g.quadraticCurveTo(fx + 5, fy + 38, fx + 12, fy + 36); g.stroke();
+ g.restore();
+ }
+
+ // ---------- 编舞 ----------
+ const ease = U.ease.inOut;
+ const borderPhase = (lt) => 15 * lt + PER * ease(clamp((lt - 0.485) / 0.365)); // 匀速漂移+原片 226–248 帧走一个周期
+ const poses = (lt, t) => {
+ const ch = P.choreo(lt, t);
+ return { ch, G: RIG.girl({ cup: ch.cup, sip: ch.sip, breathe: ch.breathe }), K: RIG.cat({ tail: ch.tail * 1.6, blink: ch.blink, breathe: ch.breathe }) };
+ };
+ function fullBase(g, sb, lt, t) {
+ const { ch, G, K } = poses(lt, t);
+ g.drawImage(sb, 0, 0);
+ border(g, borderPhase(lt));
+ volcanoFX(g, t);
+ cat(g, K);
+ girl(g, G, { steam: 1 - ch.cup * 0.85, t, blink: ch.blink, cup: ch.cup });
+ }
+
+ // ---------- 镶嵌渲染器:布局(只算一次) ----------
+ let S = null;
+ function build() {
+ const t0 = performance.now();
+ const sb = P.cached('rm_static', W, H, g => staticScene(g));
+ const mk = () => { const cv = P.canvas(); return [cv, cv.getContext('2d', { willReadFrequently: true })]; };
+ // 结构图(决定石块怎么排):静态+少女(不含会动的近侧手臂)+猫
+ const [sc, sg] = mk(); sg.drawImage(sb, 0, 0);
+ const G0 = RIG.girl({ cup: 0 }), K0 = RIG.cat({});
+ cat(sg, K0); girl(sg, G0, { nearArm: false, steam: 0 });
+ // 类别图
+ const [cc, cg] = mk(); const cs = k => `rgb(${k * 16},0,0)`;
+ cg.fillStyle = cs(K_WALL); cg.fillRect(0, 0, W, H);
+ cg.fillStyle = cs(K_FLOOR); cg.fillRect(BW, 905, W - 2 * BW, H - BW - 905);
+ cg.lineJoin = 'round'; cg.strokeStyle = cs(K_HALO); cg.lineWidth = 44; [FRAME, TABLE_TOP, TABLE_PED, AMPH, AMPH_LIP].forEach(p => cg.stroke(p)); cg.lineWidth = 34; cg.stroke(CHAIR);
+ cg.fillStyle = cs(K_FRAME); cg.fill(FRAME); cg.fillStyle = cs(K_PIC); cg.fillRect(388, 148, 384, 384);
+ cg.fillStyle = cs(K_OBJ); [TABLE_TOP, TABLE_PED, AMPH, AMPH_LIP, CHAIR].forEach(p => cg.fill(p));
+ const gs = [G0.skirt, G0.torso, G0.farSleeve, G0.farHand, G0.neck, PALLA_BACK, PALLA_LAP, PALLA_HANG, G0.shoe], gh = [G0.hairBack, G0.bun, G0.bangs];
+ const kb = [RIG.smooth(K0.bodyPts), K0.head].concat(K0.legs), ktail = new Path2D(); K0.tailPts.forEach((q, i) => i ? ktail.lineTo(...q) : ktail.moveTo(...q));
+ cg.strokeStyle = cs(K_HALO); cg.lineWidth = 50; gs.concat(gh, [G0.face]).forEach(p => cg.stroke(p)); cg.save(); catT(cg); kb.forEach(p => cg.stroke(p)); cg.lineWidth = K0.tailW + 50; cg.stroke(ktail); cg.restore();
+ cg.lineWidth = 9; cg.fillStyle = cg.strokeStyle = cs(K_FIG); gs.forEach(p => { cg.fill(p); cg.stroke(p); }); cg.fillStyle = cg.strokeStyle = cs(K_HAIR); gh.forEach(p => { cg.fill(p); cg.stroke(p); }); cg.fillStyle = cg.strokeStyle = cs(K_FACE); cg.fill(G0.face); cg.stroke(G0.face);
+ cg.save(); catT(cg); cg.lineWidth = 9; cg.fillStyle = cg.strokeStyle = cs(K_CAT); kb.forEach(p => { cg.fill(p); cg.stroke(p); }); cg.strokeStyle = cs(K_CAT); cg.lineWidth = K0.tailW + 12; cg.stroke(ktail); cg.fillStyle = cg.strokeStyle = cs(K_FACE); cg.lineWidth = 13; cg.fill(K0.head); cg.stroke(K0.head); cg.restore();
+ cg.fillStyle = cs(K_BORDER); cg.fillRect(0, 0, W, BW); cg.fillRect(0, H - BW, W, BW); cg.fillRect(0, 0, BW, H); cg.fillRect(W - BW, 0, BW, H);
+ const cd = cg.getImageData(0, 0, W, H).data, CL = new Uint8Array(W * H);
+ for (let i = 0; i < W * H; i++) CL[i] = Math.round(cd[i * 4] / 16);
+ const sdat = sg.getImageData(0, 0, W, H).data;
+ for (let y = 905; y < H - BW; y++) for (let x = 255; x < 885; x++) { const i = y * W + x; if (sdat[i * 4] + sdat[i * 4 + 1] + sdat[i * 4 + 2] < 240) CL[i] = K_TEXT; }
+ // 半分辨率:边缘 → 精确欧氏距离变换(Felzenszwalb)
+ const HW = 960, HH = 540, N = HW * HH;
+ const hc = P.canvas(HW, HH), hg = hc.getContext('2d', { willReadFrequently: true }); hg.drawImage(sc, 0, 0, HW, HH);
+ const hd = hg.getImageData(0, 0, HW, HH).data;
+ const CH = new Uint8Array(N); for (let y = 0; y < HH; y++) for (let x = 0; x < HW; x++) CH[y * HW + x] = CL[(2 * y) * W + 2 * x];
+ const F = new Float64Array(N);
+ for (let y = 0; y < HH; y++) for (let x = 0; x < HW; x++) {
+ const i = y * HW + x, o = i * 4; let e = false;
+ if (x < HW - 1) { const q = o + 4; e = Math.abs(hd[o] - hd[q]) + Math.abs(hd[o + 1] - hd[q + 1]) + Math.abs(hd[o + 2] - hd[q + 2]) > 34; }
+ if (!e && y < HH - 1) { const q = o + HW * 4; e = Math.abs(hd[o] - hd[q]) + Math.abs(hd[o + 1] - hd[q + 1]) + Math.abs(hd[o + 2] - hd[q + 2]) > 34; }
+ if (!e && x < HW - 1 && CH[i] !== CH[i + 1] && (CH[i] === K_BORDER || CH[i + 1] === K_BORDER)) e = true;
+ if (!e && y < HH - 1 && CH[i] !== CH[i + HW] && (CH[i] === K_BORDER || CH[i + HW] === K_BORDER)) e = true;
+ F[i] = e ? 0 : 1e20;
+ }
+ const D = edt(F, HW, HH); // 半分辨率像素的平方距离 → 全分辨率像素距离
+ for (let i = 0; i < N; i++) D[i] = Math.sqrt(D[i]) * 2;
+ const tangent = (i) => { const x = i % HW, y = (i / HW) | 0; const gx = D[i + (x < HW - 1 ? 1 : 0)] - D[i - (x > 0 ? 1 : 0)], gy = D[i + (y < HH - 1 ? HW : 0)] - D[i - (y > 0 ? HW : 0)]; return Math.atan2(gy, gx) + Math.PI / 2; };
+ // 石块种子:空间哈希保证最小间距
+ const sx = [], sy = [], ss = [], sa = [], scl = [];
+ const CS = 24, GWc = Math.ceil(W / CS), GHc = Math.ceil(H / CS), cell = Array.from({ length: GWc * GHc }, () => []);
+ const ok = (x, y, s, f) => { const cx = (x / CS) | 0, cy = (y / CS) | 0; for (let j = cy - 1; j <= cy + 1; j++) for (let i = cx - 1; i <= cx + 1; i++) { if (i < 0 || j < 0 || i >= GWc || j >= GHc) continue; for (const k of cell[j * GWc + i]) { const m = f * (s + ss[k]) / 2; const dx = sx[k] - x, dy = sy[k] - y; if (dx * dx + dy * dy < m * m) return false; } } return true; };
+ const add = (x, y, s, a, c) => { const k = sx.length; sx.push(x); sy.push(y); ss.push(s); sa.push(a); scl.push(c); cell[((y / CS) | 0) * GWc + ((x / CS) | 0)].push(k); return k; };
+ // ① 外框:沿边成行
+ const r = rng(2079), NR = 11, bs = BW / NR;
+ for (const [a, b, c2, d, e, f, len] of SIDES) {
+ for (let j = 0; j < NR; j++) { let u = BW + (j % 2) * bs * 0.5 + r() * 2; while (u < len - BW) { const w = bs * (0.86 + r() * 0.28), uc = u + w / 2, v = (j + 0.5) * bs; add(a * uc + c2 * v + e, b * uc + d * v + f, bs, Math.atan2(b, a) + (r() - .5) * 0.06, K_BORDER); u += w; } }
+ }
+ for (const [x0, y0] of [[0, 0], [W - BW, 0], [0, H - BW], [W - BW, H - BW]]) for (let j = 0; j < NR; j++) for (let i = 0; i < NR; i++) add(x0 + (i + 0.5) * bs, y0 + (j + 0.5) * bs, bs, (r() - .5) * 0.06, K_BORDER);
+ // ② 沿轮廓:在距离场等值线 d=(k+½)s 上走线,每走一个石块宽放一块
+ const cand = new Uint8Array(N), vis = new Uint8Array(N);
+ for (let i = 0; i < N; i++) { const c = CH[i]; if (c === K_BORDER) continue; const s = SZ[c], d = D[i]; if (d < 1) continue; const k = Math.floor(d / s); if (k >= KR[c]) continue; if (Math.abs(d - (k + 0.5) * s) < 1.5) cand[i] = 1; }
+ const NB = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]];
+ for (let i0 = 0; i0 < N; i0++) {
+ if (!cand[i0] || vis[i0]) continue;
+ let cur = i0, px = -1e9, py = -1e9, dx = 1, dy = 0;
+ for (;;) {
+ vis[cur] = 1; const hx = cur % HW, hy = (cur / HW) | 0, x = 2 * hx + 1, y = 2 * hy + 1, c = CH[cur], s = SZ[c];
+ if ((x - px) ** 2 + (y - py) ** 2 >= s * s * 0.98 && ok(x, y, s, 0.8)) { add(x, y, s, tangent(cur), c); px = x; py = y; }
+ let best = -1, bd = -9, bx = 0, by = 0;
+ for (const [ox, oy] of NB) { const nx = hx + ox, ny = hy + oy; if (nx < 0 || ny < 0 || nx >= HW || ny >= HH) continue; const n = ny * HW + nx; if (!cand[n] || vis[n]) continue; const l = Math.hypot(ox, oy), dt = (ox * dx + oy * dy) / l; if (dt > bd) { bd = dt; best = n; bx = ox / l; by = oy / l; } }
+ if (best < 0) break;
+ dx = dx * 0.6 + bx * 0.4; dy = dy * 0.6 + by * 0.4; const l = Math.hypot(dx, dy) || 1; dx /= l; dy /= l; cur = best;
+ }
+ }
+ // ③ 其余:规则成行(砖缝错半块)+补洞
+ for (let c = 0; c < SZ.length; c++) {
+ if (c === K_BORDER) continue; const s = SZ[c];
+ for (let j = 0; (j + 0.5) * s < H; j++) for (let i = -1; (i + 0.5) * s < W; i++) {
+ const x = (i + 0.5 + (j % 2) * 0.5) * s + (r() - .5) * 0.18 * s, y = (j + 0.5) * s + (r() - .5) * 0.1 * s;
+ if (x < 0 || y < 0 || x >= W || y >= H) continue;
+ if (CL[(y | 0) * W + (x | 0)] !== c) continue;
+ const hi = Math.min(HH - 1, (y / 2) | 0) * HW + Math.min(HW - 1, (x / 2) | 0);
+ const contour = KR[c] >= 99 || D[hi] < KR[c] * s;
+ if (ok(x, y, s, 0.86)) add(x, y, s, contour ? tangent(hi) : (r() - .5) * 0.07, c);
+ }
+ }
+ // ④ 光栅化:加权 L∞ Voronoi(每块石头四边独立抖动 → 不规则方块),D2−D1 太小处是灰浆缝
+ const n = sx.length;
+ const HUP = new Float32Array(n), HUM = new Float32Array(n), HVP = new Float32Array(n), HVM = new Float32Array(n), CA = new Float32Array(n), SA = new Float32Array(n);
+ const JL = new Float32Array(n), TR = new Float32Array(n), TG = new Float32Array(n), TB = new Float32Array(n), SIDX = new Int32Array(n);
+ for (let k = 0; k < n; k++) {
+ const h = ss[k] / 2, c = scl[k];
+ HUP[k] = h * (1.08 + r() * 0.2); HUM[k] = h * (1.08 + r() * 0.2); HVP[k] = h * (1.08 + r() * 0.2); HVM[k] = h * (1.08 + r() * 0.2);
+ const a = sa[k] + (r() - .5) * 0.12; CA[k] = Math.cos(a); SA[k] = Math.sin(a);
+ JL[k] = (r() - .5) * 2 * JIT[c]; const add_ = (r() - .5) * 14; TR[k] = add_; TG[k] = add_; TB[k] = add_;
+ const q = r(); if (q < 0.09) { TR[k] += 12; TG[k] += 4; TB[k] -= 8; } else if (q < 0.16) { TR[k] -= 6; TB[k] += 9; }
+ if (c === K_WALL && r() < 0.07) JL[k] -= 0.12;
+ SIDX[k] = clamp(Math.round(sy[k]), 0, H - 1) * W + clamp(Math.round(sx[k]), 0, W - 1);
+ }
+ const D1 = new Float32Array(W * H).fill(9), D2 = new Float32Array(W * H).fill(9), ID = new Int32Array(W * H).fill(-1);
+ for (let k = 0; k < n; k++) {
+ const cx = sx[k], cy = sy[k], ca = CA[k], sn = SA[k], hm = Math.max(HUP[k], HUM[k], HVP[k], HVM[k]), R = Math.ceil(hm * 1.5) + 1;
+ const x0 = Math.max(0, (cx - R) | 0), x1 = Math.min(W - 1, (cx + R) | 0), y0 = Math.max(0, (cy - R) | 0), y1 = Math.min(H - 1, (cy + R) | 0);
+ const hup = HUP[k], hum = HUM[k], hvp = HVP[k], hvm = HVM[k];
+ for (let y = y0; y <= y1; y++) { const ddy = y + 0.5 - cy; let p = y * W + x0; for (let x = x0; x <= x1; x++, p++) {
+ const ddx = x + 0.5 - cx, u = ddx * ca + ddy * sn, v = -ddx * sn + ddy * ca;
+ const du = u > 0 ? u / hup : -u / hum, dv = v > 0 ? v / hvp : -v / hvm, Dd = du > dv ? du : dv;
+ if (Dd < D1[p]) { D2[p] = D1[p]; D1[p] = Dd; ID[p] = k; } else if (Dd < D2[p]) D2[p] = Dd;
+ } }
+ }
+ // ⑤ 每像素:石块 or 灰浆;石面斜面明暗(左上受光)+颗粒
+ const SH = new Uint8Array(W * H), LX = -0.6, LY = -0.8;
+ const gr = rng(7);
+ for (let y = 0; y < H; y++) for (let x = 0; x < W; x++) {
+ const p = y * W + x, k = ID[p]; if (k < 0) continue;
+ const h = (HUP[k] + HUM[k] + HVP[k] + HVM[k]) / 4, g = clamp(0.1 * ss[k], 0.75, 1.25), d1 = D1[p];
+ const gap = (D2[p] - d1) * h / 2;
+ if (d1 > 1 || gap < g) { ID[p] = -1; continue; }
+ const e = Math.min((1 - d1) * h, gap - g);
+ let sh = 1 - 0.05 * d1 * d1 + (gr() - 0.5) * 0.06;
+ if (e < 2.2) {
+ const ddx = x + 0.5 - sx[k], ddy = y + 0.5 - sy[k], ca = CA[k], sn = SA[k], u = ddx * ca + ddy * sn, v = -ddx * sn + ddy * ca;
+ const du = u > 0 ? u / HUP[k] : -u / HUM[k], dv = v > 0 ? v / HVP[k] : -v / HVM[k];
+ const nx = du > dv ? Math.sign(u) * ca : -Math.sign(v) * sn, ny = du > dv ? Math.sign(u) * sn : Math.sign(v) * ca;
+ sh += 0.16 * (1 - e / 2.2) * (nx * LX + ny * LY);
+ }
+ SH[p] = clamp(Math.round(sh * 128), 0, 255);
+ }
+ // ⑥ 第 0 帧全幅上色 → 静态马赛克
+ const [bc, bg] = mk();
+ fullBase(bg, sb, 0, 3.28125);
+ const bd = bg.getImageData(0, 0, W, H).data;
+ const TCr = new Uint8ClampedArray(n), TCg = new Uint8ClampedArray(n), TCb = new Uint8ClampedArray(n);
+ const color = (k, d) => { const o = SIDX[k] * 4, f = 1 + JL[k]; TCr[k] = d[o] * f + TR[k]; TCg[k] = d[o + 1] * f + TG[k]; TCb[k] = d[o + 2] * f + TB[k]; };
+ for (let k = 0; k < n; k++) color(k, bd);
+ const [oc, og] = mk(), oimg = og.createImageData(W, H), SO = oimg.data, grr = rng(13);
+ for (let p = 0; p < W * H; p++) {
+ const k = ID[p], o = p * 4;
+ if (k < 0) { const nz = (grr() - 0.5) * 16; SO[o] = 112 + nz; SO[o + 1] = 103 + nz; SO[o + 2] = 92 + nz; }
+ else { const sh = SH[p]; SO[o] = (TCr[k] * sh) >> 7; SO[o + 1] = (TCg[k] * sh) >> 7; SO[o + 2] = (TCb[k] * sh) >> 7; }
+ SO[o + 3] = 255;
+ }
+ og.putImageData(oimg, 0, 0);
+ // ⑦ 动态矩形:由各姿态的包围盒算出
+ const bbox = (pts, m) => { let x0 = 1e9, y0 = 1e9, x1 = -1e9, y1 = -1e9; pts.forEach(([x, y]) => { x0 = Math.min(x0, x); y0 = Math.min(y0, y); x1 = Math.max(x1, x); y1 = Math.max(y1, y); }); return [Math.max(0, (x0 - m) | 0), Math.max(0, (y0 - m) | 0), Math.min(W, Math.ceil(x1 + m)), Math.min(H, Math.ceil(y1 + m))]; };
+ const gp = [[1180, 270], [1460, 720]];
+ for (let cu = 0; cu <= 1.001; cu += 0.05) for (const sip of [0, 0.15]) { const G = RIG.girl({ cup: cu, sip }), A = armPose(G, cu); gp.push(A.H, A.E, G.A.headTop, G.A.forehead, G.A.chin, G.A.nape, [A.cup.x - 40, A.cup.y - 95], [A.cup.x + 40, A.cup.y + 60], [G.bunSpiral[0] + 36, G.bunSpiral[1] - 36]); }
+ const kp = [[420, 540], [700, 912]];
+ for (let tl = -0.75; tl <= 0.75; tl += 0.05) { const K = RIG.cat({ tail: tl }); kp.push(...K.tailPts.map(catPt)); }
+ const rects = [[392, 152, 768, 528], bbox(gp, 58), bbox(kp, 58)]
+ .map(([x0, y0, x1, y1]) => ({ x: x0, y: y0, w: x1 - x0, h: y1 - y0, img: og.createImageData(x1 - x0, y1 - y0) }));
+ const mark = new Uint8Array(n), dyn = [];
+ for (const R of rects) for (let y = R.y; y < R.y + R.h; y++) for (let x = R.x; x < R.x + R.w; x++) { const k = ID[y * W + x]; if (k >= 0 && !mark[k]) { mark[k] = 1; dyn.push(k); } }
+ S = { sb, bc, bg, oc, og, ID, SH, SO, TCr, TCg, TCb, color, rects, dyn: Int32Array.from(dyn), n, strip: borderStrip(), cupSp: cupSprite(), ms: performance.now() - t0 };
+ window.__rm_stats = { tiles: n, dynTiles: dyn.length, buildMs: Math.round(S.ms), rects: rects.map(R => [R.x, R.y, R.w, R.h]) };
+ }
+ // 外框:一条「周期 = 卷涡周期 81px」的石块带(石块布局也按 81px 循环),每帧整条平移相位——
+ // 石块跟着图案一起走(像传送带),比「石块不动只换色」明显得多(7.6px 石块会把 1–3px/帧的相位移动量化掉)。
+ function borderStrip() {
+ const NP = 26, SL = PER * NP, NR = 11, bs = BW / NR;
+ const pc = P.canvas(SL, BW), pg = pc.getContext('2d', { willReadFrequently: true });
+ pg.fillStyle = C.bW; pg.fillRect(0, 0, SL, BW); pg.fillStyle = C.bK; pg.fillRect(0, 0, SL, 8); pg.fillRect(0, 66, SL, BW - 66);
+ pg.strokeStyle = C.bK; pg.lineWidth = 13; pg.lineCap = 'round'; pg.lineJoin = 'round';
+ for (let k = -1; k <= NP; k++) { const u0 = k * PER, cx = u0 + PER * 0.52, cy = 38, r0 = 24;
+ pg.beginPath(); pg.moveTo(u0 - 6, 68); pg.quadraticCurveTo(u0 + 2, 42, cx - r0, cy);
+ for (let th = Math.PI; th <= Math.PI * 3.25; th += 0.14) { const r = r0 - (th - Math.PI) / (Math.PI * 2.25) * (r0 - 5); pg.lineTo(cx + Math.cos(th) * r, cy + Math.sin(th) * r); } pg.stroke(); }
+ const pd = pg.getImageData(0, 0, SL, BW).data;
+ const sc = P.canvas(SL, BW), g = sc.getContext('2d');
+ g.fillStyle = 'rgb(112,103,92)'; g.fillRect(0, 0, SL, BW);
+ for (let j = 0; j < NR; j++) {
+ const r = rng(500 + j), n = Math.round(PER / bs), ws = Array.from({ length: n }, () => 0.84 + r() * 0.32), sum = ws.reduce((a, b) => a + b, 0);
+ const tiles = []; let u = (j % 2) * bs * 0.5;
+ ws.forEach(w0 => { const w = w0 / sum * PER; tiles.push([u, w, Array.from({ length: 8 }, () => (r() - .5) * 1.4), (r() - .5) * 0.12, (r() - .5) * 14]); u += w; });
+ for (let k = -1; k <= NP; k++) for (const [u0, w, jt, jl, ja] of tiles) {
+ const x0 = k * PER + u0, y0 = j * bs, cx = x0 + w / 2, cy = y0 + bs / 2;
+ if (cx < -w || cx > SL + w) continue;
+ const o = (Math.min(BW - 1, cy | 0) * SL + Math.max(0, Math.min(SL - 1, cx | 0))) * 4, f = 1 + jl;
+ const col = [pd[o] * f + ja, pd[o + 1] * f + ja, pd[o + 2] * f + ja], q = [[x0 + 0.9, y0 + 0.9], [x0 + w - 0.9, y0 + 0.9], [x0 + w - 0.9, y0 + bs - 0.9], [x0 + 0.9, y0 + bs - 0.9]].map((p, i) => [p[0] + jt[i * 2] * 0.6, p[1] + jt[i * 2 + 1] * 0.6]);
+ g.fillStyle = P.rgb(col); g.beginPath(); q.forEach((p, i) => i ? g.lineTo(...p) : g.moveTo(...p)); g.closePath(); g.fill();
+ g.strokeStyle = P.rgb(P.mix(col, [255, 255, 255], 0.22)); g.lineWidth = 1; g.beginPath(); g.moveTo(...q[0]); g.lineTo(...q[1]); g.stroke();
+ g.strokeStyle = P.rgb(P.mix(col, [0, 0, 0], 0.18)); g.beginPath(); g.moveTo(...q[3]); g.lineTo(...q[2]); g.stroke();
+ }
+ }
+ return sc;
+ }
+ // 杯子:4.4px 小石块拼片(深色描边石块+金色杯身+亮杯口+双耳+杯脚),整块随手移动
+ const CSC = 1.3, CSP = [80, 24];
+ function cupSprite() {
+ const w = 170, h = 110, fc = P.canvas(w, h), fg = fc.getContext('2d', { willReadFrequently: true });
+ fg.translate(CSP[0], CSP[1]); fg.scale(CSC, CSC);
+ const cw = 46, ch = 38;
+ fg.lineJoin = 'round'; fg.lineCap = 'round';
+ fg.strokeStyle = C.outline; fg.lineWidth = 11; [-1, 1].forEach(d => { fg.beginPath(); fg.arc(d * cw * 0.5, ch * 0.28, ch * 0.27, d < 0 ? Math.PI * 0.5 : -Math.PI * 0.5, d < 0 ? Math.PI * 1.5 : Math.PI * 0.5); fg.stroke(); });
+ fg.strokeStyle = C.gold; fg.lineWidth = 5; [-1, 1].forEach(d => { fg.beginPath(); fg.arc(d * cw * 0.5, ch * 0.28, ch * 0.27, d < 0 ? Math.PI * 0.5 : -Math.PI * 0.5, d < 0 ? Math.PI * 1.5 : Math.PI * 0.5); fg.stroke(); });
+ const bowl = new Path2D(); bowl.moveTo(-cw / 2, 0); bowl.quadraticCurveTo(-cw * 0.46, ch * 0.74, 0, ch * 0.74); bowl.quadraticCurveTo(cw * 0.46, ch * 0.74, cw / 2, 0); bowl.closePath();
+ const foot = new Path2D(); foot.rect(-4, ch * 0.7, 8, ch * 0.3); foot.ellipse(0, ch * 1.02, cw * 0.3, 5, 0, 0, Math.PI * 2);
+ fg.lineWidth = 6; fg.strokeStyle = C.outline; fg.stroke(bowl); fg.stroke(foot);
+ fg.fillStyle = C.gold; fg.fill(bowl); fg.fill(foot);
+ fg.save(); fg.clip(bowl); fg.fillStyle = C.gold2; fg.fillRect(cw * 0.12, 0, cw, ch); fg.fillStyle = '#f4d77a'; fg.fillRect(-cw * 0.36, 6, 6, ch * 0.5); fg.restore();
+ fg.fillStyle = '#f2d77c'; fg.beginPath(); fg.ellipse(0, 0, cw / 2, 5.5, 0, 0, Math.PI * 2); fg.fill(); fg.strokeStyle = C.outline; fg.lineWidth = 4; fg.stroke();
+ fg.fillStyle = '#7a5418'; fg.beginPath(); fg.ellipse(0, 0.5, cw / 2 - 6, 2.6, 0, 0, Math.PI * 2); fg.fill();
+ const fd = fg.getImageData(0, 0, w, h).data, sp = P.canvas(w, h), sg = sp.getContext('2d'), ts = 4.4, r = rng(91);
+ // 灰浆底:只在杯形(alpha)里
+ sg.drawImage(fc, 0, 0); sg.globalCompositeOperation = 'source-in'; sg.fillStyle = 'rgb(96,86,74)'; sg.fillRect(0, 0, w, h); sg.globalCompositeOperation = 'source-over';
+ for (let y = 0; y < h; y += ts) for (let x = ((y / ts) % 2) * ts * 0.5 - ts; x < w; x += ts) {
+ const cx = x + ts / 2, cy = y + ts / 2; if (cx < 0 || cx >= w || cy >= h) continue;
+ const o = ((cy | 0) * w + (cx | 0)) * 4; if (fd[o + 3] < 110) continue;
+ const f = 1 + (r() - .5) * 0.12; sg.fillStyle = P.rgb([fd[o] * f, fd[o + 1] * f, fd[o + 2] * f]);
+ sg.fillRect(x + 0.6 + (r() - .5) * 0.5, y + 0.6 + (r() - .5) * 0.5, ts - 1.2, ts - 1.2);
+ }
+ return sp;
+ }
+ function steamTiles(c, cup, t, a) { // 白石热气:两列方石沿正弦上行
+ if (a < 0.03) return;
+ c.save(); c.globalAlpha = a;
+ for (let k = 0; k < 2; k++) for (let i = 0; i < 7; i++) {
+ const q = ((i + (t * 2.2) % 1) / 7), x = cup.x - 9 + k * 18 + Math.sin(t * 6 + k * 2.2 - q * 6) * 9 * q, y = cup.y - 12 - q * 76, s = 7 - q * 2;
+ c.globalAlpha = a * (1 - q * 0.7); c.fillStyle = 'rgb(96,86,74)'; c.fillRect(x - s / 2 - 1, y - s / 2 - 1, s + 2, s + 2); c.fillStyle = '#fbf8f0'; c.fillRect(x - s / 2, y - s / 2, s, s);
+ }
+ c.restore();
+ }
+ function edt(F, w, h) { // 2D 平方欧氏距离变换(Felzenszwalb–Huttenlocher)
+ const n = Math.max(w, h), f = new Float64Array(n), d = new Float64Array(n), v = new Int32Array(n), z = new Float64Array(n + 1);
+ const pass = (len) => { let k = 0; v[0] = 0; z[0] = -1e30; z[1] = 1e30;
+ for (let q = 1; q < len; q++) { let s = ((f[q] + q * q) - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k]); while (s <= z[k]) { k--; s = ((f[q] + q * q) - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k]); } k++; v[k] = q; z[k] = s; z[k + 1] = 1e30; }
+ k = 0; for (let q = 0; q < len; q++) { while (z[k + 1] < q) k++; d[q] = (q - v[k]) * (q - v[k]) + f[v[k]]; } };
+ const out = new Float64Array(w * h);
+ for (let x = 0; x < w; x++) { for (let y = 0; y < h; y++) f[y] = F[y * w + x]; pass(h); for (let y = 0; y < h; y++) out[y * w + x] = d[y]; }
+ for (let y = 0; y < h; y++) { for (let x = 0; x < w; x++) f[x] = out[y * w + x]; pass(w); for (let x = 0; x < w; x++) out[y * w + x] = d[x]; }
+ return out;
+ }
+
+ return {
+ init() { if (!S) build(); },
+ draw(c, lt, t) {
+ if (!S) build();
+ const { bg, og, ID, SH, SO, TCr, TCg, TCb } = S;
+ fullBase(bg, S.sb, lt, t);
+ const bd = bg.getImageData(0, 0, W, H).data;
+ const dyn = S.dyn; for (let i = 0; i < dyn.length; i++) S.color(dyn[i], bd);
+ for (const R of S.rects) {
+ const dd = R.img.data; let o = 0;
+ for (let y = R.y; y < R.y + R.h; y++) { let p = y * W + R.x; for (let x = 0; x < R.w; x++, p++, o += 4) {
+ const k = ID[p];
+ if (k < 0) { const q = p * 4; dd[o] = SO[q]; dd[o + 1] = SO[q + 1]; dd[o + 2] = SO[q + 2]; }
+ else { const sh = SH[p]; dd[o] = (TCr[k] * sh) >> 7; dd[o + 1] = (TCg[k] * sh) >> 7; dd[o + 2] = (TCb[k] * sh) >> 7; }
+ dd[o + 3] = 255;
+ } }
+ og.putImageData(R.img, R.x, R.y);
+ }
+ c.drawImage(S.oc, 0, 0);
+ // 外框传送带:同一条周期石块带,四边各自局部坐标(顺时针),按相位平移
+ const off = ((borderPhase(lt) % PER) + PER) % PER;
+ for (const [a, b, c2, d, e, f, len] of SIDES) { c.save(); c.transform(a, b, c2, d, e, f); c.beginPath(); c.rect(BW, 0, len - 2 * BW, BW); c.clip(); c.drawImage(S.strip, BW - 2 * PER + off, 0); c.restore(); }
+ // 杯子拼片与热气(跟着手走)
+ const { ch, G } = poses(lt, t), AP = armPose(G, ch.cup);
+ c.save(); c.translate(AP.cup.x, AP.cup.y); c.rotate(AP.cup.tilt); c.drawImage(S.cupSp, -CSP[0], -CSP[1]); c.restore();
+ steamTiles(c, AP.cup, t, 1 - ch.cup * 0.85);
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/05_gothic.js b/scripts/engine/scenes/05_gothic.js
new file mode 100644
index 0000000..5df30d9
--- /dev/null
+++ b/scripts/engine/scenes/05_gothic.js
@@ -0,0 +1,522 @@
+// 1290 哥特泥金手抄本——纯代码。
+// 管线:①静态层(羊皮纸+逐像素金箔+菱格压花+哥特尖拱/小尖塔/彩窗/桌/宝座/拉丁文栏)缓存
+// → ②金箔掩膜(从静态层按「金色度」逐像素分类得到)→ ③每帧:彩窗闪烁、藤蔓花饰摇摆、斜向高光扫过(只落在金上)
+// → ④角色:平涂+粗墨线(光环、金发、红袍金细条、蓝斗篷、金杯),稚拙人脸猫拎着老鼠 → ⑤蜗牛爬、老鼠跑、金杯闪光
+SCENES['05_gothic'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp } = U, P = PAINT;
+ const INK = '#2b1a12';
+ const C = {
+ parch: '#ecdfc0', parchDk: '#c9ae80', gold: '#d9a63a', goldHi: '#f8de86', goldLo: '#9c6a1a',
+ red: '#c3262e', redDk: '#7e1318', blue: '#24449e', blueDk: '#142a6a', pink: '#e7a3aa', green: '#55a03c', greenDk: '#2f6e26',
+ white: '#f8f2e2', wood: '#8a5a2c', woodDk: '#5a3818', skin: '#f5dcc2', hair: '#e9b746', hairDk: '#9a6618',
+ };
+ const ease = U.ease.inOut;
+ const R_ = (seed) => U.rng(seed);
+
+ // ---------- 小工具 ----------
+ const F = (c, p, fill, line = INK, lw = 3) => { if (!p) return; if (fill) { c.fillStyle = fill; c.fill(p); } if (line && lw) { c.strokeStyle = line; c.lineWidth = lw; c.stroke(p); } };
+ const poly = (pts, closed = true) => { const p = new Path2D(); pts.forEach((q, i) => i ? p.lineTo(q[0], q[1]) : p.moveTo(q[0], q[1])); if (closed) p.closePath(); return p; };
+ // 尖拱:xl..xr,起拱线 ys,底 yb,半径 r(>宽/2 才是尖的)
+ const arch = (xl, xr, ys, yb, r) => {
+ const p = new Path2D(), w = xr - xl, mid = (xl + xr) / 2, h = Math.sqrt(r * r - (r - w / 2) ** 2);
+ const a1 = Math.atan2(-h, mid - (xl + r)), a2 = Math.atan2(-h, mid - (xr - r));
+ p.moveTo(xl, yb); p.lineTo(xl, ys); p.arc(xl + r, ys, r, Math.PI, a1 + Math.PI * 2); p.arc(xr - r, ys, r, a2, 0); p.lineTo(xr, yb); p.closePath(); return p;
+ };
+ const dot = (c, x, y, r, fill, line = INK, lw = 1.5) => { c.beginPath(); c.arc(x, y, r, 0, Math.PI * 2); if (fill) { c.fillStyle = fill; c.fill(); } if (line) { c.strokeStyle = line; c.lineWidth = lw; c.stroke(); } };
+
+ // ---------- 金箔:逐像素(大尺度斑驳+横向打磨细纹+颗粒+左上受光) ----------
+ const goldTex = () => P.cached('goth_goldTex', W, H, (g) => {
+ const x0 = 290, x1 = 1480, y0 = 20, y1 = 960, img = g.createImageData(W, H), d = img.data, r = R_(5);
+ const lo = P.hex(C.goldLo), mid = P.hex(C.gold), hi = P.hex(C.goldHi);
+ for (let y = y0; y < y1; y++) for (let x = x0; x < x1; x++) {
+ const big = P.fbm(x * 0.0035, y * 0.0035 + 7, 3);
+ const brush = P.noise(x * 0.004, y * 0.09) * 0.5 + P.noise(x * 0.012, y * 0.25) * 0.3; // 横向打磨纹
+ const light = 0.18 - (x - x0) / (x1 - x0) * 0.12 - (y - y0) / (y1 - y0) * 0.16;
+ let f = 0.52 + big * 0.42 + brush * 0.22 + light + (r() - .5) * 0.10;
+ f = clamp(f, 0, 1);
+ const c0 = f < 0.5 ? P.mix(lo, mid, f * 2) : P.mix(mid, hi, (f - 0.5) * 2);
+ const i = (y * W + x) * 4; d[i] = c0[0]; d[i + 1] = c0[1]; d[i + 2] = c0[2]; d[i + 3] = 255;
+ }
+ g.putImageData(img, 0, 0);
+ });
+
+ // ---------- 几何 ----------
+ const PANEL = poly([[328, 255], [328, 205], [580, 66], [830, 205], [985, 96], [1135, 205], [1285, 96], [1440, 205], [1440, 255], [1440, 895], [328, 895]]);
+ const WIN = arch(362, 798, 360, 540, 240);
+ const LANCETS = [arch(392, 565, 414, 532, 131), arch(595, 768, 414, 532, 131)];
+
+ // 羊皮纸+边缘做旧
+ function parchment(g) {
+ g.drawImage(P.texture('goth_parch', C.parch, { scale: 0.0028, amt: 20, grain: 9, dark: C.parchDk, seed: 3 }), 0, 0);
+ const v = g.createRadialGradient(W / 2, H / 2, 380, W / 2, H / 2, 1150);
+ v.addColorStop(0, 'rgba(120,80,30,0)'); v.addColorStop(1, 'rgba(110,70,25,.5)');
+ g.fillStyle = v; g.fillRect(0, 0, W, H);
+ }
+
+ // 菱格压花:深线+错 1px 亮线 = 刻进金箔的感觉;菱心四点压印(上亮下暗)
+ function lattice(g) {
+ const s = 46;
+ g.save(); g.clip(PANEL);
+ g.drawImage(goldTex(), 0, 0);
+ g.lineWidth = 1.6;
+ for (const [col, off] of [['rgba(255,240,180,.55)', 1.2], ['rgba(110,66,10,.55)', 0]]) {
+ g.strokeStyle = col; g.beginPath();
+ for (let k = -40; k < 80; k++) { const u = k * s; g.moveTo(u - 1200 + off, 1200 + off); g.lineTo(u + 1200 + off, -1200 + off); g.moveTo(u - 1200 + off, -1200 + off); g.lineTo(u + 1200 + off, 1200 + off); }
+ g.stroke();
+ }
+ for (let a = -10; a < 70; a++) for (let b = -40; b < 40; b++) {
+ const u = (a + 0.5) * s, v = (b + 0.5) * s, x = (u + v) / 2, y = (u - v) / 2;
+ if (x < 320 || x > 1450 || y < 60 || y > 900) continue;
+ for (const [dx, dy] of [[-5, 0], [5, 0], [0, -5], [0, 5]]) {
+ g.fillStyle = 'rgba(255,245,200,.7)'; g.beginPath(); g.arc(x + dx - .6, y + dy - .6, 1.9, 0, 7); g.fill();
+ g.fillStyle = 'rgba(120,70,10,.55)'; g.beginPath(); g.arc(x + dx + .7, y + dy + .7, 1.5, 0, 7); g.fill();
+ }
+ }
+ // 金箔接缝:几条极淡的方块拼接线(金箔是一片片贴上去的)
+ g.strokeStyle = 'rgba(120,75,15,.18)'; g.lineWidth = 1;
+ for (let x = 328 + 118; x < 1440; x += 118) { g.beginPath(); g.moveTo(x, 60); g.lineTo(x + 3, 895); g.stroke(); }
+ for (let y = 140; y < 895; y += 125) { g.beginPath(); g.moveTo(328, y); g.lineTo(1440, y + 2); g.stroke(); }
+ g.restore();
+ g.strokeStyle = INK; g.lineWidth = 3; g.stroke(PANEL);
+ }
+
+ // 山墙、小尖塔、侧柱、下边框、草地
+ function architecture(g) {
+ const band = (pts, col, w) => {
+ g.lineJoin = 'miter'; g.lineCap = 'butt';
+ g.strokeStyle = INK; g.lineWidth = w + 6; g.beginPath(); pts.forEach((p, i) => i ? g.lineTo(...p) : g.moveTo(...p)); g.stroke();
+ g.strokeStyle = col; g.lineWidth = w; g.stroke();
+ // 白点
+ for (let i = 0; i < pts.length - 1; i++) { const [a, b] = [pts[i], pts[i + 1]], L = Math.hypot(b[0] - a[0], b[1] - a[1]), n = Math.floor(L / 22);
+ for (let k = 1; k < n; k++) { const q = k / n; dot(g, lerp(a[0], b[0], q), lerp(a[1], b[1], q), 2.6, '#fff', null); } }
+ // 卷叶饰金球(沿外沿)
+ for (let i = 0; i < pts.length - 1; i++) { const [a, b] = [pts[i], pts[i + 1]], L = Math.hypot(b[0] - a[0], b[1] - a[1]), n = Math.floor(L / 34);
+ const nx = (b[1] - a[1]) / L, ny = -(b[0] - a[0]) / L, sg = ny < 0 ? 1 : -1;
+ for (let k = 1; k < n; k++) { const q = k / n; dot(g, lerp(a[0], b[0], q) + nx * sg * (w / 2 + 9), lerp(a[1], b[1], q) + ny * sg * (w / 2 + 9), 6, C.gold, INK, 2); } }
+ };
+ band([[322, 196], [580, 52], [838, 196]], C.pink, 30);
+ band([[836, 196], [985, 82], [1135, 196]], C.blue, 26);
+ band([[1135, 196], [1285, 82], [1446, 196]], C.blue, 26);
+ // 三叶拱(中、右山墙之下):深金描线
+ g.strokeStyle = 'rgba(110,66,10,.8)'; g.lineWidth = 3;
+ for (const cx of [985, 1285]) { g.beginPath(); g.arc(cx - 88, 262, 62, Math.PI * 1.05, Math.PI * 1.85); g.arc(cx, 205, 70, Math.PI * 1.12, Math.PI * 1.88); g.arc(cx + 88, 262, 62, Math.PI * 1.15, Math.PI * 1.95); g.stroke(); }
+ // 吊坠尖
+ for (const x of [835, 1135]) { const p = poly([[x - 16, 238], [x + 16, 238], [x, 282]]); F(g, p, C.white, INK, 2.5); dot(g, x, 252, 4.5, C.red, null); }
+ // 十字顶饰
+ for (const [x, y] of [[580, 30], [985, 60], [1285, 60]]) { g.fillStyle = C.gold; g.strokeStyle = INK; g.lineWidth = 2; g.fillRect(x - 4, y - 22, 8, 30); g.strokeRect(x - 4, y - 22, 8, 30); g.fillRect(x - 12, y - 14, 24, 7); g.strokeRect(x - 12, y - 14, 24, 7); }
+ // 小尖塔
+ for (const [x, top, bot] of [[312, 68, 248], [835, 92, 236], [1135, 92, 236], [1455, 68, 248]]) {
+ const sw = 22, shaftTop = top + 62;
+ g.fillStyle = C.white; g.fillRect(x - sw / 2, shaftTop, sw, bot - shaftTop);
+ g.fillStyle = C.blue; for (const dx of [-5, 3]) g.fillRect(x + dx, shaftTop + 8, 3, bot - shaftTop - 16);
+ g.strokeStyle = INK; g.lineWidth = 2.5; g.strokeRect(x - sw / 2, shaftTop, sw, bot - shaftTop);
+ F(g, poly([[x - 15, shaftTop], [x, top], [x + 15, shaftTop]]), C.red, INK, 2.5);
+ g.fillStyle = C.gold; g.fillRect(x - 15, shaftTop - 2, 30, 7); g.strokeRect(x - 15, shaftTop - 2, 30, 7);
+ dot(g, x, top - 4, 5, C.gold, INK, 2);
+ }
+ // 侧柱:红/蓝/粉方块+白点
+ const cols = [C.red, C.blue, C.pink, C.blue];
+ for (const x0 of [298, 1440]) for (let y = 250, k = 0; y < 945; y += 31, k++) {
+ g.fillStyle = cols[k % 4]; g.fillRect(x0, y, 30, 31); g.strokeStyle = INK; g.lineWidth = 2; g.strokeRect(x0, y, 30, 31);
+ dot(g, x0 + 15, y + 15.5, 4, '#fff', null);
+ }
+ g.fillStyle = C.gold; g.fillRect(296, 240, 34, 12); g.fillRect(1438, 240, 34, 12); g.strokeStyle = INK; g.strokeRect(296, 240, 34, 12); g.strokeRect(1438, 240, 34, 12);
+ // 草地
+ g.fillStyle = C.green; g.fillRect(328, 892, 1112, 53);
+ g.fillStyle = C.greenDk; g.fillRect(328, 892, 1112, 5);
+ const r = R_(11); g.strokeStyle = C.greenDk; g.lineWidth = 2;
+ for (let i = 0; i < 90; i++) { const x = 340 + r() * 1090, y = 905 + r() * 34; g.beginPath(); g.moveTo(x - 4, y - 6); g.lineTo(x, y + 2); g.lineTo(x + 5, y - 7); g.stroke(); }
+ for (const x of [1000, 1040, 1052, 1085, 1118, 1180, 760, 690]) { const y = 900 + (x % 7); for (let k = 0; k < 5; k++) dot(g, x + Math.cos(k * 1.26) * 4, y + Math.sin(k * 1.26) * 4, 2.4, '#fff', null); dot(g, x, y, 2, '#f2c230', null); }
+ // 下边框:红蓝相间+白波浪
+ for (let x = 322, k = 0; x < 1440; x += 52, k++) {
+ const w = Math.min(52, 1440 - x); g.fillStyle = k % 2 ? C.blue : C.red; g.fillRect(x, 945, w, 26);
+ g.strokeStyle = '#fff'; g.lineWidth = 2; g.beginPath(); for (let s = 0; s <= w - 10; s += 2) { const yy = 958 + Math.sin(s / (w - 10) * Math.PI * 2) * 4; s ? g.lineTo(x + 5 + s, yy) : g.moveTo(x + 5, yy); } g.stroke();
+ g.strokeStyle = INK; g.lineWidth = 2; g.strokeRect(x, 945, w, 26);
+ }
+ g.lineWidth = 3; g.strokeRect(298, 943, 1172, 30);
+ for (const [x, y] of [[310, 958], [1458, 958]]) { g.fillStyle = C.gold; g.fillRect(x - 13, y - 13, 26, 26); g.strokeStyle = INK; g.strokeRect(x - 13, y - 13, 26, 26); }
+ dot(g, 1468, 968, 8, C.gold, INK, 2);
+ }
+
+ // 尖拱窗:四叶玫瑰窗+两扇柳叶窗的红蓝菱格彩玻璃
+ function windowStatic(g) {
+ g.save(); g.shadowColor = 'rgba(80,40,0,.35)'; g.shadowOffsetX = 5; g.shadowOffsetY = 5; F(g, WIN, '#f6eedb', INK, 4); g.restore();
+ g.strokeStyle = INK; g.lineWidth = 3; g.stroke(WIN);
+ // 内圈细线
+ const inner = arch(374, 786, 362, 540, 228); g.strokeStyle = 'rgba(140,110,70,.5)'; g.lineWidth = 2; g.stroke(inner);
+ // 四叶玫瑰窗
+ const rc = [580, 222];
+ const q = new Path2D(); for (let k = 0; k < 4; k++) { const a = k * Math.PI / 2 - Math.PI / 2; q.moveTo(rc[0] + Math.cos(a) * 33 + 30, rc[1] + Math.sin(a) * 33); q.arc(rc[0] + Math.cos(a) * 33, rc[1] + Math.sin(a) * 33, 30, 0, Math.PI * 2); }
+ F(g, q, C.red, INK, 3);
+ for (let k = 0; k < 4; k++) { const a = k * Math.PI / 2 - Math.PI / 2; dot(g, rc[0] + Math.cos(a) * 33, rc[1] + Math.sin(a) * 33, 20, C.blue, INK, 2.5); dot(g, rc[0] + Math.cos(a) * 33, rc[1] + Math.sin(a) * 33, 6, C.gold, INK, 1.5); }
+ dot(g, rc[0], rc[1], 13, C.gold, INK, 2.5);
+ for (const [dx, dy] of [[0, -9], [-9, 6], [9, 6]]) dot(g, 578 + dx, 316 + dy, 8, C.blue, INK, 2);
+ // 柳叶窗:红蓝菱格+金铅条+白点
+ LANCETS.forEach((L, li) => {
+ g.save(); g.clip(L);
+ const s = 38;
+ for (let a = -30; a < 60; a++) for (let b = -30; b < 30; b++) {
+ const u = a * s, v = b * s, x = (u + v) / 2, y = (u - v) / 2;
+ if (x < 370 || x > 790 || y < 260 || y > 560) continue;
+ const dm = poly([[x, y - s / 2], [x + s / 2, y], [x, y + s / 2], [x - s / 2, y]]);
+ g.fillStyle = (a + b) % 2 ? C.red : C.blue; g.fill(dm);
+ if ((a + b) % 2 === 0) for (const [dx, dy] of [[-4, 0], [4, 0], [0, -4], [0, 4], [0, 0]]) dot(g, x + dx, y + dy, 1.8, '#fff', null);
+ else dot(g, x, y, 4, C.gold, null);
+ }
+ // 铅条:沿菱形边(x+y、x−y 为常数的两族斜线)
+ g.strokeStyle = C.gold; g.lineWidth = 3; g.beginPath();
+ for (let k = -60; k < 120; k++) { const c0 = (k + 0.5) * s; g.moveTo(c0 - 1000, 1000); g.lineTo(c0 + 1000, -1000); g.moveTo(c0 - 1000, -1000); g.lineTo(c0 + 1000, 1000); }
+ g.stroke(); g.restore();
+ F(g, L, null, INK, 4);
+ });
+ // 窗台
+ const sill = new Path2D(); sill.rect(345, 538, 470, 24); F(g, sill, C.pink, INK, 3);
+ g.fillStyle = 'rgba(255,255,255,.5)'; g.fillRect(350, 542, 460, 4);
+ }
+
+ // 桌(白桌布+蓝竖条+扇贝边)、宝座、面包、刀
+ function furniture(g) {
+ // 支架腿(A 字)
+ g.lineCap = 'round';
+ for (const x of [872, 1142]) for (const [a, b] of [[-26, 18], [26, -18]]) { g.strokeStyle = INK; g.lineWidth = 15; g.beginPath(); g.moveTo(x + b, 715); g.lineTo(x + a, 898); g.stroke(); g.strokeStyle = C.wood; g.lineWidth = 10; g.stroke(); }
+ for (const x of [872, 1142]) { g.fillStyle = C.wood; g.fillRect(x - 22, 830, 44, 8); g.strokeStyle = INK; g.lineWidth = 2; g.strokeRect(x - 22, 830, 44, 8); }
+ // 桌面
+ const top = poly([[805, 578], [1215, 578], [1210, 645], [810, 645]]); F(g, top, C.white, INK, 3);
+ g.fillStyle = 'rgba(150,140,120,.18)'; g.fillRect(810, 630, 400, 14);
+ g.strokeStyle = C.blue; g.lineWidth = 2.5; for (const x of [828, 836, 1184, 1192]) { g.beginPath(); g.moveTo(x, 580); g.lineTo(x + (x < 1000 ? 2 : -2), 644); g.stroke(); }
+ // 垂布:扇贝下摆
+ const cl = new Path2D(); cl.moveTo(812, 645); cl.lineTo(1208, 645); cl.lineTo(1205, 712);
+ for (let x = 1205; x > 815; x -= 26) cl.quadraticCurveTo(x - 13, 742, x - 26, 712);
+ cl.closePath(); F(g, cl, C.white, INK, 3);
+ g.save(); g.clip(cl);
+ g.strokeStyle = 'rgba(36,68,158,.8)'; g.lineWidth = 2; for (let x = 822; x < 1205; x += 26) { g.beginPath(); g.moveTo(x, 648); g.quadraticCurveTo(x + 3, 690, x + 1, 735); g.stroke(); }
+ g.strokeStyle = 'rgba(150,140,120,.45)'; g.lineWidth = 1.5; for (let x = 834; x < 1205; x += 26) { g.beginPath(); g.moveTo(x, 650); g.lineTo(x + 2, 725); g.stroke(); }
+ g.restore();
+ for (let x = 826; x < 1200; x += 13) dot(g, x, 700, 2.3, C.red, null);
+ // 面包+刀
+ const br = new Path2D(); br.ellipse(880, 616, 34, 19, 0, 0, Math.PI * 2); F(g, br, '#d9a058', INK, 2.5);
+ g.strokeStyle = '#8a5524'; g.lineWidth = 2.5; g.beginPath(); g.moveTo(880, 600); g.lineTo(880, 632); g.moveTo(862, 616); g.quadraticCurveTo(880, 606, 898, 616); g.stroke();
+ g.strokeStyle = INK; g.lineWidth = 6; g.beginPath(); g.moveTo(1106, 636); g.lineTo(1140, 632); g.stroke(); g.strokeStyle = '#7a4a20'; g.lineWidth = 4; g.stroke();
+ g.strokeStyle = INK; g.lineWidth = 4; g.beginPath(); g.moveTo(1140, 632); g.lineTo(1186, 627); g.stroke(); g.strokeStyle = '#d8d8d8'; g.lineWidth = 2.5; g.stroke();
+ // 宝座:绿靠背+金顶球、红坐垫、粉色基座+蓝尖拱
+ const back = poly([[1438, 430], [1478, 430], [1480, 748], [1438, 748]]); F(g, back, '#3c8a3a', INK, 3);
+ g.strokeStyle = 'rgba(255,255,255,.3)'; g.lineWidth = 3; g.beginPath(); g.moveTo(1446, 440); g.lineTo(1446, 740); g.stroke();
+ dot(g, 1458, 422, 9, C.gold, INK, 2); dot(g, 1478, 460, 7, C.gold, INK, 2);
+ const base = poly([[1302, 748], [1482, 748], [1482, 882], [1302, 882]]); F(g, base, C.pink, INK, 3);
+ for (let k = 0; k < 4; k++) { const x = 1318 + k * 40; F(g, arch(x, x + 26, 790, 872, 17), C.blue, INK, 2.5); }
+ F(g, poly([[1296, 880], [1488, 880], [1488, 898], [1296, 898]]), C.gold, INK, 2.5);
+ F(g, poly([[1300, 726], [1484, 726], [1486, 750], [1300, 750]]), C.red, INK, 3);
+ dot(g, 1484, 735, 7, C.gold, INK, 2);
+ }
+
+ // 正文栏:格线、红蓝笔花、蓝底金字首字母 H、哥特体拉丁文(句首红字=朱批)
+ const LINES = [['ic sedet homo', 1640], ['cum poculo suo', 1640], ['et bibit. Cattus', 1515], ['eum spectat.', 1515], ['Cattus semper', 1515], ['spectat. Nemo', 1515], ['scit quare. Mus', 1515], ['autem scit et', 1515], ['tacet in eternum.', 1515]];
+ function textColumn(g) {
+ g.strokeStyle = 'rgba(150,110,70,.28)'; g.lineWidth = 1.2;
+ for (let k = 0; k < 10; k++) { const y = 300 + k * 62; g.beginPath(); g.moveTo(1495, y); g.lineTo(1895, y); g.stroke(); }
+ g.beginPath(); g.moveTo(1505, 240); g.lineTo(1505, 920); g.stroke(); g.beginPath(); g.moveTo(1888, 240); g.lineTo(1888, 920); g.stroke();
+ // 笔花
+ g.lineWidth = 2; g.strokeStyle = C.red; g.beginPath(); for (let y = 235; y < 500; y += 2) { const x = 1497 + Math.sin(y * 0.09) * 6; y === 235 ? g.moveTo(x, y) : g.lineTo(x, y); } g.stroke();
+ g.strokeStyle = C.blue; g.beginPath(); for (let y = 260; y < 330; y += 2) { const x = 1506 + Math.sin(y * 0.11 + 1) * 5; y === 260 ? g.moveTo(x, y) : g.lineTo(x, y); } g.stroke();
+ // 首字母 H
+ g.save(); g.shadowColor = 'rgba(60,30,0,.3)'; g.shadowOffsetX = 3; g.shadowOffsetY = 3; g.fillStyle = C.gold; g.fillRect(1508, 304, 120, 118); g.restore();
+ g.fillStyle = C.blue; g.fillRect(1517, 313, 102, 100); g.strokeStyle = INK; g.lineWidth = 2.5; g.strokeRect(1508, 304, 120, 118); g.strokeRect(1517, 313, 102, 100);
+ g.strokeStyle = 'rgba(255,255,255,.85)'; g.lineWidth = 1.6;
+ for (const [x, y, s] of [[1600, 330, 1], [1532, 395, -1], [1600, 396, 1]]) { g.beginPath(); for (let a = 0; a < 9; a += 0.25) { const rr = 1 + a * 1.4; const px = x + Math.cos(a * s) * rr, py = y + Math.sin(a * s) * rr; a ? g.lineTo(px, py) : g.moveTo(px, py); } g.stroke(); }
+ for (let k = 0; k < 7; k++) dot(g, 1528 + k * 13, 320, 1.6, '#fff', null);
+ g.font = '118px "UnifrakturMaguntia-400"'; g.textAlign = 'center'; g.textBaseline = 'alphabetic';
+ g.lineWidth = 6; g.strokeStyle = INK; g.strokeText('H', 1568, 404); g.fillStyle = C.gold; g.fillText('H', 1568, 404);
+ g.fillStyle = 'rgba(255,245,200,.6)'; g.font = '118px "UnifrakturMaguntia-400"'; g.save(); g.beginPath(); g.rect(1517, 313, 102, 46); g.clip(); g.fillText('H', 1567, 403); g.restore();
+ // 正文
+ g.textAlign = 'left'; g.font = '44px "UnifrakturMaguntia-400"';
+ LINES.forEach(([s, x], k) => {
+ const y = 350 + k * 62; let cx = x;
+ for (const word of s.split(' ')) {
+ const red = /^(Cattus|Nemo|Mus)/.test(word);
+ g.fillStyle = red ? C.red : '#2a1c12';
+ g.fillText(word, cx, y); cx += g.measureText(word + ' ').width;
+ }
+ if (k === 3) { // 行尾填充波折线
+ g.lineWidth = 2.4; g.strokeStyle = C.red; g.beginPath(); for (let i = 0; i <= 10; i++) g.lineTo(cx + 6 + i * 11, y - 14 + (i % 2) * 12); g.stroke();
+ g.strokeStyle = C.blue; g.beginPath(); for (let i = 0; i <= 10; i++) g.lineTo(cx + 12 + i * 11, y - 14 + (i % 2) * 12); g.stroke();
+ }
+ });
+ }
+
+ // 小骑士(页边滑稽画)
+ function knight(g) {
+ g.save(); g.translate(760, 1010);
+ F(g, poly([[-10, -8], [10, -8], [14, 26], [-14, 26]]), C.red, INK, 2.5);
+ g.strokeStyle = INK; g.lineWidth = 6; g.lineCap = 'round'; g.beginPath(); g.moveTo(-6, 24); g.lineTo(-14, 48); g.moveTo(6, 24); g.lineTo(18, 44); g.stroke();
+ g.strokeStyle = '#d0d0d8'; g.lineWidth = 3.5; g.stroke();
+ const helm = new Path2D(); helm.rect(-12, -34, 24, 26); F(g, helm, '#c8ccd6', INK, 2.5);
+ g.fillStyle = INK; g.fillRect(-8, -24, 16, 3);
+ F(g, poly([[6, -6], [30, -6], [30, 14], [18, 26], [6, 14]]), C.blue, INK, 2.5);
+ g.strokeStyle = '#fff'; g.lineWidth = 3; g.beginPath(); g.moveTo(18, -2); g.lineTo(18, 20); g.moveTo(10, 6); g.lineTo(26, 6); g.stroke();
+ g.restore();
+ }
+
+ const STATIC = () => P.cached('goth_static', W, H, (g) => { parchment(g); lattice(g); architecture(g); windowStatic(g); furniture(g); textColumn(g); knight(g); });
+ // 金色度掩膜(只让高光落在金上)
+ const MASK = () => P.cached('goth_mask', W, H, (g) => {
+ const s = STATIC().getContext('2d').getImageData(0, 0, W, H).data, img = g.createImageData(W, H), d = img.data;
+ for (let i = 0; i < W * H * 4; i += 4) {
+ const r = s[i], gg = s[i + 1], b = s[i + 2];
+ const k = clamp((r - b - 70) / 50) * clamp((gg - b - 30) / 40) * clamp((r - 140) / 40);
+ d[i] = d[i + 1] = d[i + 2] = 255; d[i + 3] = k * 255;
+ }
+ g.putImageData(img, 0, 0);
+ });
+
+ // ---------- 藤蔓花饰(每帧画,枝条与叶子各自轻摇) ----------
+ const VINES = (() => {
+ const L = [], B = [];
+ for (let y = 30; y <= 990; y += 8) L.push([172 + 48 * Math.sin(y * 0.0125) + 18 * Math.sin(y * 0.033 + 1), y]);
+ for (let x = 230; x <= 1900; x += 8) B.push([x, 1012 + 26 * Math.sin(x * 0.011) + 10 * Math.sin(x * 0.035 + 2) - (x > 1500 ? (x - 1500) * 0.06 : 0)]);
+ const joinL = [[L[L.length - 1][0], L[L.length - 1][1]], [200, 1005], [230, B[0][1]]];
+ return [L.concat(joinL.slice(1)), B];
+ })();
+ const LEAFCOL = [C.blue, C.red, C.gold, C.blue, C.red];
+ function ivy(c, x, y, a, s, col) { // 三瓣常春藤叶/喇叭花:哥特页边最常见的叶饰
+ c.save(); c.translate(x, y); c.rotate(a); c.scale(s, s);
+ const p = new Path2D(); p.moveTo(0, 0); p.quadraticCurveTo(-10, -6, -14, -18); p.quadraticCurveTo(-6, -14, -2, -22); p.quadraticCurveTo(0, -30, 2, -22);
+ p.quadraticCurveTo(6, -14, 14, -18); p.quadraticCurveTo(10, -6, 0, 0); p.closePath();
+ c.fillStyle = col; c.fill(p); c.strokeStyle = INK; c.lineWidth = 1.6 / s; c.stroke(p);
+ c.restore();
+ }
+ function vines(c, t) {
+ c.save(); c.lineCap = 'round'; c.lineJoin = 'round';
+ VINES.forEach((pts, vi) => {
+ const sway = (i) => [Math.sin(t * 2.6 + i * 0.09 + vi) * 5, Math.cos(t * 2.1 + i * 0.07) * 4];
+ const pp = pts.map((p, i) => { const s = sway(i); return [p[0] + s[0], p[1] + s[1]]; });
+ c.strokeStyle = '#3a2416'; c.lineWidth = 2.6; c.beginPath(); pp.forEach((p, i) => i ? c.lineTo(...p) : c.moveTo(...p)); c.stroke();
+ const r = R_(31 + vi * 7);
+ for (let i = 3, k = 0; i < pp.length - 3; i += 3 + ((r() * 3) | 0), k++) {
+ const p = pp[i], q = pp[i + 1], ta = Math.atan2(q[1] - p[1], q[0] - p[0]), side = k % 2 ? 1 : -1;
+ const na = ta + side * (Math.PI / 2 - 0.5);
+ const L = 18 + r() * 16, sw = Math.sin(t * 3.6 + k * 1.7 + vi) * 0.42;
+ const ex = p[0] + Math.cos(na + sw * 0.5) * L, ey = p[1] + Math.sin(na + sw * 0.5) * L;
+ c.strokeStyle = '#3a2416'; c.lineWidth = 1.6; c.beginPath(); c.moveTo(p[0], p[1]); c.quadraticCurveTo(p[0] + Math.cos(na) * L * 0.6 + side * 4, p[1] + Math.sin(na) * L * 0.6, ex, ey); c.stroke();
+ if (r() < 0.62) ivy(c, ex, ey, na + Math.PI / 2 + sw, 1.05 + r() * 0.4, LEAFCOL[(k + vi) % 5]);
+ else { dot(c, ex, ey, 5.5, C.gold, INK, 1.4); c.strokeStyle = '#3a2416'; c.lineWidth = 1; for (let h = -1; h <= 1; h++) { const a2 = na + h * 0.6 + sw; c.beginPath(); c.moveTo(ex + Math.cos(a2) * 6, ey + Math.sin(a2) * 6); c.lineTo(ex + Math.cos(a2) * 13, ey + Math.sin(a2) * 13); c.stroke(); } }
+ }
+ });
+ c.restore();
+ }
+
+ // ---------- 动态金:斜向高光 ----------
+ const K_SLANT = 0.45;
+ const sweepX = (lt) => lerp(150, 1650, clamp((lt - 0.08) / 1.15)); // 匀速:0.3s 就扫到窗边,0.9s 扫过少女
+ function goldSweep(c, lt) {
+ const xc = sweepX(lt), bx = Math.round(xc - 460), bw = 920, s = P.scratch('gothSweep'), g = s.getContext('2d');
+ g.clearRect(0, 0, W, H); g.globalCompositeOperation = 'source-over';
+ const gr = g.createLinearGradient(xc - 170, 540 - 170 * K_SLANT, xc + 170, 540 + 170 * K_SLANT);
+ gr.addColorStop(0, 'rgba(255,240,190,0)'); gr.addColorStop(0.25, 'rgba(255,236,170,.32)'); gr.addColorStop(0.47, 'rgba(255,252,230,.85)');
+ gr.addColorStop(0.53, 'rgba(255,252,230,.85)'); gr.addColorStop(0.75, 'rgba(255,236,170,.32)'); gr.addColorStop(1, 'rgba(255,240,190,0)');
+ g.fillStyle = gr; g.fillRect(bx, 0, bw, H);
+ g.globalCompositeOperation = 'destination-in'; g.drawImage(MASK(), bx, 0, bw, H, bx, 0, bw, H); g.globalCompositeOperation = 'source-over';
+ c.save(); c.globalCompositeOperation = 'lighter'; c.globalAlpha = 0.85; c.drawImage(s, bx, 0, bw, H, bx, 0, bw, H); c.restore();
+ }
+ const glint = (c, x, y, s, a = 1) => { // 四角星闪光
+ if (s <= 0.02) return; c.save(); c.globalCompositeOperation = 'lighter'; c.globalAlpha = a; c.fillStyle = '#fff6d0';
+ c.beginPath(); c.moveTo(x, y - 18 * s); c.quadraticCurveTo(x, y, x + 18 * s, y); c.quadraticCurveTo(x, y, x, y + 18 * s); c.quadraticCurveTo(x, y, x - 18 * s, y); c.quadraticCurveTo(x, y, x, y - 18 * s); c.fill();
+ c.globalAlpha = a * 0.5; c.beginPath(); c.arc(x, y, 6 * s, 0, 7); c.fill(); c.restore();
+ };
+ const SPARKS = [[452, 640], [760, 330], [930, 470], [1090, 300], [1250, 520], [700, 780], [1010, 820], [1380, 330], [560, 115], [1300, 150], [1568, 360]];
+ const nearSweep = (x, y, lt) => { const u = x + K_SLANT * (y - 540); return clamp(1 - Math.abs(u - sweepX(lt)) / 70); };
+
+ // 彩窗闪烁:几块菱格轮流亮起
+ function glassTwinkle(c, t) {
+ c.save(); c.globalCompositeOperation = 'lighter';
+ LANCETS.forEach((L, li) => { c.save(); c.clip(L);
+ for (let k = 0; k < 40; k++) { const h = U.hash(k, li + 3), x = (li ? 600 : 396) + U.hash(k, 9 + li) * 170, y = 300 + h * 230;
+ const a = Math.max(0, Math.sin(t * 5 + h * 40)); if (a < 0.6) continue;
+ const gr = c.createRadialGradient(x, y, 0, x, y, 22); gr.addColorStop(0, `rgba(255,255,255,${(a - 0.6) * 1.1})`); gr.addColorStop(1, 'rgba(255,255,255,0)'); c.fillStyle = gr; c.fillRect(x - 22, y - 22, 44, 44); }
+ c.restore(); });
+ c.restore();
+ }
+
+ // ---------- 少女:哥特圣像画法 ----------
+ function girl(c, G, lt, t, ch) {
+ const A = G.A;
+ c.save(); c.lineJoin = 'round'; c.lineCap = 'round';
+ // 光环(头后)
+ const hc = [A.headC[0] + 16, A.headC[1] - 22], hr = 114;
+ const hg = c.createRadialGradient(hc[0] - 30, hc[1] - 30, 10, hc[0], hc[1], hr);
+ hg.addColorStop(0, '#fbe597'); hg.addColorStop(0.6, '#e2b445'); hg.addColorStop(1, '#b98222');
+ c.fillStyle = hg; c.beginPath(); c.arc(hc[0], hc[1], hr, 0, 7); c.fill(); c.strokeStyle = INK; c.lineWidth = 3; c.stroke();
+ c.strokeStyle = C.red; c.lineWidth = 3; c.beginPath(); c.arc(hc[0], hc[1], hr - 9, 0, 7); c.stroke();
+ for (let k = 0; k < 36; k++) { const a = k / 36 * Math.PI * 2; dot(c, hc[0] + Math.cos(a) * (hr - 18), hc[1] + Math.sin(a) * (hr - 18), 2.3, '#fff3c0', 'rgba(120,70,10,.6)', 1); }
+ const hs = nearSweep(hc[0], hc[1], lt); if (hs > 0) { c.save(); c.globalCompositeOperation = 'lighter'; c.globalAlpha = hs * 0.5; c.fillStyle = '#fff4c8'; c.beginPath(); c.arc(hc[0], hc[1], hr, 0, 7); c.fill(); c.restore(); }
+ // 长金发(背后,波浪)
+ const nape = A.nape, sw = Math.sin(t * 2.4) * 3;
+ const hair = RIG.smooth([[nape[0] + 30, nape[1] - 100], [nape[0] + 58, nape[1] - 40], [nape[0] + 72, nape[1] + 30], [nape[0] + 84 + sw, nape[1] + 110], [nape[0] + 78 + sw, nape[1] + 190], [nape[0] + 92 + sw, nape[1] + 250],
+ [nape[0] + 62 + sw, nape[1] + 262], [nape[0] + 50, nape[1] + 200], [nape[0] + 34, nape[1] + 120], [nape[0] + 10, nape[1] + 50], [nape[0] - 20, nape[1] + 10]]);
+ F(c, hair, C.hair, INK, 3);
+ c.strokeStyle = C.hairDk; c.lineWidth = 2;
+ for (let k = 0; k < 4; k++) { c.beginPath(); for (let s = 0; s <= 20; s++) { const q = s / 20, x = nape[0] + 30 + k * 12 + Math.sin(q * 9 + k) * 6 + q * 30, y = nape[1] - 60 + q * 300; s ? c.lineTo(x, y) : c.moveTo(x, y); } c.stroke(); }
+ // 远侧袖、手
+ F(c, G.farSleeve, C.red); F(c, G.farCuff, C.gold); F(c, G.farHand, C.skin);
+ // 裙:红+金细竖条+金下摆
+ F(c, G.skirt, C.red, INK, 3.5);
+ c.save(); c.clip(G.skirt); c.strokeStyle = 'rgba(240,190,80,.75)'; c.lineWidth = 1.6;
+ for (let x = 1080; x < 1470; x += 20) { c.beginPath(); c.moveTo(x, 600); c.quadraticCurveTo(x - 14, 780, x - 22, 940); c.stroke(); }
+ c.strokeStyle = C.redDk; c.lineWidth = 3; G.folds.forEach(f => c.stroke(f));
+ c.strokeStyle = C.gold; c.lineWidth = 12; c.beginPath(); c.moveTo(1090, 924); c.quadraticCurveTo(1230, 940, 1360, 924); c.stroke();
+ c.restore();
+ F(c, G.shoe, '#3a2418', INK, 2.5);
+ // 躯干
+ F(c, G.torso, C.red, INK, 3.5);
+ c.save(); c.clip(G.torso); c.strokeStyle = 'rgba(240,190,80,.75)'; c.lineWidth = 1.6; for (let x = 1280; x < 1440; x += 20) { c.beginPath(); c.moveTo(x, 420); c.lineTo(x + 6, 630); c.stroke(); } c.restore();
+ // 蓝斗篷:从后肩垂到座位,金边
+ const b = A.back, cloak = RIG.smooth([[A.nape[0] - 6, A.nape[1] + 12], [A.nape[0] + 40, A.nape[1] + 22], [b[0] + 30, b[1] + 10], [b[0] + 44, b[1] + 140], [b[0] + 46, b[1] + 230], [b[0] + 10, b[1] + 236], [b[0] + 4, b[1] + 120], [b[0] - 18, b[1] + 10], [A.nape[0] - 10, A.nape[1] + 40]]);
+ F(c, cloak, C.blue, INK, 3.5);
+ c.save(); c.clip(cloak); c.strokeStyle = C.blueDk; c.lineWidth = 3; for (let k = 0; k < 3; k++) { c.beginPath(); c.moveTo(b[0] + 6 + k * 12, b[1] - 20); c.quadraticCurveTo(b[0] + 18 + k * 12, b[1] + 100, b[0] + 14 + k * 12, b[1] + 230); c.stroke(); } c.restore();
+ c.strokeStyle = C.gold; c.lineWidth = 4; c.beginPath(); c.moveTo(A.nape[0] - 8, A.nape[1] + 30); c.quadraticCurveTo(b[0] - 14, b[1] + 20, b[0] + 6, b[1] + 232); c.stroke();
+ // 领口金边
+ F(c, G.neck, C.skin, INK, 2.5);
+ c.strokeStyle = C.gold; c.lineWidth = 5; c.beginPath(); c.moveTo(A.neck[0] - 18, A.neck[1] + 2); c.quadraticCurveTo(A.neck[0] + 6, A.neck[1] + 18, A.neck[0] + 30, A.neck[1] - 2); c.stroke();
+ // 头
+ F(c, G.hairBack, C.hair, INK, 3);
+ F(c, G.face, C.skin, INK, 3);
+ c.save(); c.clip(G.face); c.fillStyle = 'rgba(232,110,110,.55)'; c.beginPath(); c.arc(G.cheek[0] - 4, G.cheek[1], 12, 0, 7); c.fill(); c.restore();
+ c.fillStyle = C.skin; c.beginPath(); c.ellipse(G.ear[0], G.ear[1], 8, 12, 0.2, 0, 7); c.fill(); c.strokeStyle = INK; c.lineWidth = 2; c.stroke();
+ F(c, G.bangs, C.hair, INK, 3);
+ c.strokeStyle = C.hairDk; c.lineWidth = 2; G.hairLines.forEach(h => c.stroke(h));
+ G.locks.forEach(h => { c.strokeStyle = INK; c.lineWidth = 9; c.stroke(h); c.strokeStyle = C.hair; c.lineWidth = 6; c.stroke(h); });
+ // 五官:哥特圣像的杏眼、细眉、小红唇
+ const closed = ch.blink || ch.cup > 0.86;
+ if (closed) { c.strokeStyle = INK; c.lineWidth = 2.6; c.beginPath(); c.arc(G.eye.x, G.eye.y - 2, 7, 0.3, Math.PI - 0.3); c.stroke(); }
+ else {
+ c.fillStyle = '#fff'; c.beginPath(); c.ellipse(G.eye.x, G.eye.y, 9, 5, -0.1, 0, 7); c.fill(); c.strokeStyle = INK; c.lineWidth = 2.2; c.stroke();
+ c.fillStyle = '#3a2a1c'; c.beginPath(); c.arc(G.eye.x - 3, G.eye.y, 3.6, 0, 7); c.fill();
+ c.strokeStyle = INK; c.lineWidth = 2.6; c.stroke(G.lid);
+ }
+ c.strokeStyle = '#8a5a20'; c.lineWidth = 2.2; c.stroke(G.brow);
+ c.fillStyle = '#c0303a'; c.beginPath(); c.moveTo(...G.lips[0]); c.lineTo(...G.lips[1]); c.lineTo(...G.lips[2]); c.closePath(); c.fill();
+ // 近侧手臂:红袖+金袖口
+ F(c, G.upperArm, C.red, INK, 3.5); F(c, G.foreArm, C.red, INK, 3.5); F(c, G.cuff, C.gold, INK, 2.5);
+ F(c, G.hand, C.skin, INK, 2.5);
+ chalice(c, G.cup, lt, t);
+ c.fillStyle = C.skin; c.beginPath(); c.arc(G.thumb[0], G.thumb[1], 7, 0, 7); c.fill(); c.strokeStyle = INK; c.lineWidth = 2; c.stroke();
+ c.restore();
+ }
+ // 金圣杯:杯口在 cup.x,cup.y;杯身半椭圆+节+杯脚;红酒
+ function chalice(c, cup, lt, t) {
+ c.save(); c.translate(cup.x, cup.y); c.rotate(cup.tilt || 0);
+ const w = 52, gg = c.createLinearGradient(-w / 2, 0, w / 2, 0); gg.addColorStop(0, '#a87020'); gg.addColorStop(0.35, '#fbe08a'); gg.addColorStop(0.6, '#e0ad40'); gg.addColorStop(1, '#8a5a14');
+ const bowl = new Path2D(); bowl.moveTo(-w / 2, 0); bowl.bezierCurveTo(-w / 2, 26, -10, 36, 0, 36); bowl.bezierCurveTo(10, 36, w / 2, 26, w / 2, 0); bowl.closePath();
+ F(c, bowl, gg, INK, 2.5);
+ const stem = poly([[-5, 34], [5, 34], [4, 58], [-4, 58]]); F(c, stem, gg, INK, 2);
+ const knot = new Path2D(); knot.ellipse(0, 46, 9, 5, 0, 0, 7); F(c, knot, '#f0c860', INK, 2);
+ const foot = new Path2D(); foot.moveTo(-20, 66); foot.quadraticCurveTo(0, 50, 20, 66); foot.closePath(); F(c, foot, gg, INK, 2);
+ const rim = new Path2D(); rim.ellipse(0, 0, w / 2, 7, 0, 0, 7); F(c, rim, '#7a1018', INK, 2.2);
+ c.fillStyle = 'rgba(255,255,255,.45)'; c.beginPath(); c.ellipse(-8, -1.5, 9, 2, 0, 0, 7); c.fill();
+ c.restore();
+ // 闪光:杯沿一颗四角星
+ const tw = Math.max(0, Math.sin(t * 7 + 1)); glint(c, cup.x + 18, cup.y - 4, 0.5 + tw * 0.5, 0.5 + tw * 0.5);
+ // 热气(细墨线弯曲上升)
+ c.save(); c.globalAlpha = 0.7; P.steam(c, t, cup.x, cup.y - 12, { h: 64, n: 3, color: 'rgba(120,110,100,.9)', width: 2.2, spread: 10, wobble: 7 }); c.restore();
+ }
+
+ // ---------- 猫:手抄本里的稚拙人脸猫,拎着老鼠 ----------
+ function cat(c, K, t, ch) {
+ const O = '#e3913e', ODk = '#b45a18', Wt = C.white;
+ c.save(); c.lineJoin = 'round'; c.lineCap = 'round';
+ // 尾巴(环纹)
+ c.strokeStyle = INK; c.lineWidth = K.tailW + 6; c.stroke(K.tail); c.strokeStyle = O; c.lineWidth = K.tailW; c.stroke(K.tail);
+ const tp = K.tailPts; c.strokeStyle = ODk; c.lineWidth = 6;
+ for (let i = 3; i < tp.length - 1; i += 3) { const a = Math.atan2(tp[i + 1][1] - tp[i][1], tp[i + 1][0] - tp[i][0]) + Math.PI / 2; c.beginPath(); c.moveTo(tp[i][0] - Math.cos(a) * 11, tp[i][1] - Math.sin(a) * 11); c.lineTo(tp[i][0] + Math.cos(a) * 11, tp[i][1] + Math.sin(a) * 11); c.stroke(); }
+ // 身体
+ const body = RIG.smooth(K.bodyPts); F(c, body, O, INK, 3.5);
+ c.save(); c.clip(body);
+ c.strokeStyle = ODk; c.lineWidth = 7;
+ for (let k = 0; k < 7; k++) { const y = 700 + k * 28; c.beginPath(); c.moveTo(418, y + 8); c.quadraticCurveTo(470, y - 10, 520, y + 14); c.stroke(); }
+ c.fillStyle = Wt; c.fill(K.white);
+ c.restore();
+ // 后腿团(坐姿大腿)
+ c.strokeStyle = INK; c.lineWidth = 2.5; c.beginPath(); c.arc(505, 840, 52, Math.PI * 1.05, Math.PI * 1.9); c.stroke();
+ // 前腿:一条着地,一条抬起拎老鼠
+ c.fillStyle = Wt; c.fill(K.legs[0]); c.strokeStyle = INK; c.lineWidth = 3; c.stroke(K.legs[0]);
+ for (let k = -1; k <= 1; k++) { c.beginPath(); c.moveTo(584 + k * 7, 880); c.lineTo(584 + k * 7, 892); c.lineWidth = 1.6; c.stroke(); }
+ const sh = [632, 744], pw = [664, 778];
+ const arm = RIG.limb(sh, pw, 32, 26); F(c, arm, Wt, INK, 3);
+ // 老鼠:尾巴挂在爪子上,钟摆摆动
+ const sw = Math.sin(t * 5.5) * 0.32, ml = 56, mx = pw[0] + Math.sin(sw) * ml, my = pw[1] + Math.cos(sw) * ml;
+ c.strokeStyle = '#6a4a40'; c.lineWidth = 2; c.beginPath(); c.moveTo(pw[0], pw[1] + 6); c.quadraticCurveTo(pw[0] + Math.sin(sw) * 30 + 6, pw[1] + 30, mx, my - 12); c.stroke();
+ c.save(); c.translate(mx, my); c.rotate(-sw);
+ const mb = new Path2D(); mb.ellipse(0, 6, 10, 17, 0, 0, 7); F(c, mb, '#4c3e38', INK, 2);
+ dot(c, -8, 20, 5, '#4c3e38', INK, 1.5); dot(c, 8, 20, 5, '#4c3e38', INK, 1.5); dot(c, 0, 24, 2, '#e8a0a0', null);
+ c.strokeStyle = '#4c3e38'; c.lineWidth = 3; c.beginPath(); c.moveTo(-6, 4); c.lineTo(-12, 12 + Math.sin(t * 9) * 3); c.moveTo(6, 4); c.lineTo(12, 12 - Math.sin(t * 9) * 3); c.stroke();
+ c.restore();
+ c.fillStyle = Wt; c.beginPath(); c.ellipse(pw[0], pw[1] + 2, 15, 12, 0.3, 0, 7); c.fill(); c.strokeStyle = INK; c.lineWidth = 2.5; c.stroke();
+ // 头:橘色,稚拙的人脸
+ F(c, K.head, O, INK, 3.5);
+ c.fillStyle = '#f2a8a0'; K.earInner.forEach(e => { c.beginPath(); e.forEach((p, i) => i ? c.lineTo(...p) : c.moveTo(...p)); c.fill(); });
+ c.save(); c.clip(K.head);
+ c.strokeStyle = ODk; c.lineWidth = 6; K.stripes.slice(0, 3).forEach(s => { c.beginPath(); c.moveTo(...s[0]); c.lineTo(...s[1]); c.stroke(); });
+ const hc = K.headC, fx = hc[0] + 10, fy = hc[1] + 6;
+ c.fillStyle = '#f7e6cc'; c.beginPath(); c.ellipse(fx, fy + 6, 42, 34, 0, 0, 7); c.fill();
+ c.restore();
+ // 脸颊红晕
+ c.fillStyle = 'rgba(232,110,110,.45)'; dot(c, fx - 26, fy + 14, 9, 'rgba(232,110,110,.45)', null); dot(c, fx + 28, fy + 12, 9, 'rgba(232,110,110,.45)', null);
+ // 眼:杏眼斜睨(瞳孔挤到右边看少女),厚上眼皮
+ const eyes = [[fx - 18, fy - 6], [fx + 18, fy - 8]];
+ eyes.forEach(([x, y], k) => {
+ if (ch.blink) { c.strokeStyle = INK; c.lineWidth = 2.5; c.beginPath(); c.moveTo(x - 10, y); c.lineTo(x + 10, y); c.stroke(); return; }
+ c.fillStyle = '#fff'; c.beginPath(); c.ellipse(x, y, 11, 7, 0, 0, 7); c.fill(); c.strokeStyle = INK; c.lineWidth = 2; c.stroke();
+ dot(c, x + 5, y + 1, 4.2, '#2a1c12', null);
+ c.lineWidth = 3; c.beginPath(); c.moveTo(x - 12, y - 2); c.quadraticCurveTo(x, y - 9, x + 12, y - 3); c.stroke();
+ c.lineWidth = 2; c.beginPath(); c.moveTo(x - 10, y - 15 - k * 2); c.quadraticCurveTo(x, y - 20 - k * 3, x + 11, y - 15 + k * 2); c.stroke();
+ });
+ // 鼻、撇嘴、胡须
+ c.strokeStyle = INK; c.lineWidth = 2; c.beginPath(); c.moveTo(fx + 1, fy + 2); c.quadraticCurveTo(fx + 5, fy + 12, fx - 1, fy + 14); c.stroke();
+ c.lineWidth = 2.4; c.beginPath(); c.moveTo(fx - 12, fy + 28); c.quadraticCurveTo(fx, fy + 20, fx + 12, fy + 27); c.stroke();
+ c.lineWidth = 1.4; for (const [a, b] of [[[fx + 34, fy + 14], [fx + 80, fy + 6]], [[fx + 34, fy + 20], [fx + 78, fy + 26]], [[fx - 34, fy + 16], [fx - 74, fy + 10]], [[fx - 34, fy + 22], [fx - 72, fy + 28]]]) { c.beginPath(); c.moveTo(...a); c.lineTo(...b); c.stroke(); }
+ c.restore();
+ }
+
+ // ---------- 蜗牛、老鼠 ----------
+ function snail(c, lt, t) {
+ const x = 912 - 62 * lt, y = 1040, st = Math.sin(t * 6) * 4;
+ c.save(); c.lineJoin = 'round';
+ const body = new Path2D(); body.moveTo(x + 52, y + 26); body.lineTo(x - 54 - st, y + 26); body.quadraticCurveTo(x - 70 - st, y + 22, x - 62 - st, y + 6); body.quadraticCurveTo(x - 40, y + 4, x - 10, y + 12); body.lineTo(x + 52, y + 18); body.closePath();
+ F(c, body, '#aab6cc', INK, 2.5);
+ c.strokeStyle = INK; c.lineWidth = 2.4; const ex = x - 58 - st;
+ for (const [dx, dy] of [[-12, -30], [2, -34]]) { const wob = Math.sin(t * 8 + dx) * 3; c.beginPath(); c.moveTo(ex + 4, y + 8); c.quadraticCurveTo(ex + dx * 0.5, y - 10, ex + dx + wob, y + dy); c.stroke(); dot(c, ex + dx + wob, y + dy, 3.5, INK, null); }
+ const shell = new Path2D(); shell.arc(x + 4, y - 10, 34, 0, 7); F(c, shell, '#e3a447', INK, 3);
+ c.strokeStyle = '#9a5a1a'; c.lineWidth = 3; c.beginPath(); for (let a = 0; a < 15; a += 0.2) { const r = 2 + a * 2.05; const px = x + 4 + Math.cos(a) * r, py = y - 10 + Math.sin(a) * r; a ? c.lineTo(px, py) : c.moveTo(px, py); } c.stroke();
+ c.restore();
+ }
+ function runMouse(c, lt, t) {
+ const q = clamp((lt - 0.12) / 1.05), x = lerp(1890, 1530, q), y = 898, leg = Math.sin(t * 40);
+ c.save(); c.lineCap = 'round';
+ c.fillStyle = 'rgba(80,50,20,.18)'; c.beginPath(); c.ellipse(x, y + 12, 30, 5, 0, 0, 7); c.fill();
+ c.strokeStyle = '#3a2a24'; c.lineWidth = 2; c.beginPath(); c.moveTo(x + 22, y); c.bezierCurveTo(x + 50, y - 12 + Math.sin(t * 14) * 6, x + 60, y + 10, x + 82, y - 4 + Math.sin(t * 14 + 1) * 6); c.stroke();
+ c.lineWidth = 3; c.beginPath(); c.moveTo(x - 10, y + 4); c.lineTo(x - 16 - leg * 7, y + 12); c.moveTo(x + 12, y + 4); c.lineTo(x + 16 + leg * 7, y + 12); c.stroke();
+ const b = new Path2D(); b.ellipse(x, y - 2, 25, 12, 0, 0, 7); F(c, b, '#3e302c', INK, 1.5);
+ const hd = new Path2D(); hd.moveTo(x - 14, y - 10); hd.quadraticCurveTo(x - 30, y - 8, x - 38, y + 2); hd.quadraticCurveTo(x - 24, y + 6, x - 12, y + 6); hd.closePath(); F(c, hd, '#3e302c', INK, 1.5);
+ dot(c, x - 16, y - 13, 6, '#5a4640', INK, 1.2); dot(c, x - 30, y - 2, 1.6, '#fff', null);
+ c.restore();
+ }
+
+ return {
+ init() { STATIC(); MASK(); },
+ draw(c, lt, t) {
+ const ch = P.choreo(lt, t);
+ c.drawImage(STATIC(), 0, 0);
+ glassTwinkle(c, t);
+ goldSweep(c, lt);
+ SPARKS.forEach(([x, y], k) => { const n = nearSweep(x, y, lt); if (n > 0) glint(c, x, y, 0.4 + n * 0.8, n); });
+ vines(c, t);
+ snail(c, lt, t);
+ runMouse(c, lt, t);
+ const K = RIG.cat({ tail: ch.tail, blink: ch.blink, breathe: ch.breathe });
+ cat(c, K, t, ch);
+ const G = RIG.girl({ cup: ch.cup, sip: ch.sip, hair: 'long', breathe: ch.breathe });
+ girl(c, G, lt, t, ch);
+ // 做旧:极淡的颗粒
+ c.drawImage(P.grain('goth', 0.05, [90, 60, 20], 0.16), 0, 0);
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/06_renaissance.js b/scripts/engine/scenes/06_renaissance.js
new file mode 100644
index 0000000..d6df5f9
--- /dev/null
+++ b/scripts/engine/scenes/06_renaissance.js
@@ -0,0 +1,338 @@
+// 1503 文艺复兴盛期油画(达芬奇式)——纯代码。
+// 管线:①静态层(暗褐抹灰墙+窗光晕、拱窗石框与窗洞内的「空气透视」远景:层叠蓝山/湖/蜿蜒银河/柏树、透视棋盘地砖、方桌白布、梯背椅)
+// 整层 blur 1.3px 做 sfumato → ②每帧:扑翼机扇翅飞过窗、飞鸟、河面碎光、光柱里的浮尘
+// → ③角色画进离屏层(渐变体积+天鹅绒高光+写实毛发短线),整层 blur 1.6px 再叠 0.45 清晰层=晕涂柔边
+// → ④罩一层「画面」:龟裂纹+画布经纬+暗角+黄釉(缓存,一次 drawImage)
+SCENES['06_renaissance'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp } = U, P = PAINT;
+ const R_ = (s) => U.rng(s);
+ const poly = (pts, closed = true) => { const p = new Path2D(); pts.forEach((q, i) => i ? p.lineTo(q[0], q[1]) : p.moveTo(q[0], q[1])); if (closed) p.closePath(); return p; };
+ const archPath = (xl, xr, cy, yb) => { const p = new Path2D(), r = (xr - xl) / 2; p.moveTo(xl, yb); p.lineTo(xl, cy); p.arc(xl + r, cy, r, Math.PI, 0); p.lineTo(xr, yb); p.closePath(); return p; };
+ const OUTER = archPath(360, 810, 335, 560), INNER = archPath(422, 800, 330, 542);
+
+ // ---------- 远景(窗洞内) ----------
+ const RIVER = [[548, 362], [620, 372], [676, 388], [652, 404], [580, 420], [548, 438], [590, 458], [668, 474], [720, 492], [748, 512], [790, 534]];
+ function landscape(g) {
+ g.save(); g.clip(INNER);
+ const sky = g.createLinearGradient(0, 140, 0, 350); sky.addColorStop(0, '#93b0b6'); sky.addColorStop(0.6, '#c8d4cc'); sky.addColorStop(1, '#e4e2cf');
+ g.fillStyle = sky; g.fillRect(400, 130, 420, 230);
+ // 云:柔软的横向团块
+ const r = R_(7);
+ for (let k = 0; k < 14; k++) { const x = 420 + r() * 380, y = 175 + r() * 90, rw = 50 + r() * 70; const cg = g.createRadialGradient(x, y, 0, x, y, rw); cg.addColorStop(0, 'rgba(240,238,225,.55)'); cg.addColorStop(1, 'rgba(240,238,225,0)'); g.fillStyle = cg; g.save(); g.translate(x, y); g.scale(1, 0.32); g.translate(-x, -y); g.beginPath(); g.arc(x, y, rw, 0, 7); g.fill(); g.restore(); }
+ // 层叠山(越远越蓝越淡=空气透视)
+ const ranges = [[300, '#9fb4b8', 0.010, 26, 3], [318, '#8aa1a6', 0.016, 22, 5], [336, '#7d9294', 0.02, 14, 9]];
+ for (const [base, col, f, amp, sd] of ranges) { g.fillStyle = col; g.beginPath(); g.moveTo(410, 360); for (let x = 410; x <= 810; x += 4) g.lineTo(x, base - Math.abs(P.fbm(x * f, sd, 4)) * amp * 3 - P.noise(x * f * 3, sd) * amp * 0.4); g.lineTo(810, 360); g.closePath(); g.fill(); }
+ // 湖
+ const lake = g.createLinearGradient(0, 340, 0, 366); lake.addColorStop(0, '#dfe3d6'); lake.addColorStop(1, '#c9d2c2'); g.fillStyle = lake; g.fillRect(410, 340, 400, 24);
+ // 河谷:近处转暖
+ const vg = g.createLinearGradient(0, 360, 0, 545); vg.addColorStop(0, '#93a08a'); vg.addColorStop(0.45, '#7a8462'); vg.addColorStop(1, '#7c7048');
+ g.fillStyle = vg; g.beginPath(); g.moveTo(410, 366); for (let x = 410; x <= 810; x += 6) g.lineTo(x, 362 + P.noise(x * 0.02, 3) * 4); g.lineTo(810, 545); g.lineTo(410, 545); g.closePath(); g.fill();
+ // 远丘斑块
+ for (let k = 0; k < 40; k++) { const x = 420 + r() * 380, y = 380 + r() * 150, s = 0.4 + (y - 370) / 180; g.fillStyle = `rgba(${90 + r() * 30},${100 + r() * 20},${60 + r() * 15},.35)`; g.beginPath(); g.ellipse(x, y, 30 * s, 6 * s, 0, 0, 7); g.fill(); }
+ // 河:宽度随距离变大
+ g.lineCap = 'round'; g.lineJoin = 'round';
+ for (let pass = 0; pass < 2; pass++) for (let i = 0; i < RIVER.length - 1; i++) {
+ const a = RIVER[i], b = RIVER[i + 1], w = 3 + i * 1.3;
+ g.strokeStyle = pass ? '#eef0e8' : 'rgba(90,100,80,.6)'; g.lineWidth = pass ? w : w + 3;
+ g.beginPath(); g.moveTo(...a); g.lineTo(...b); g.stroke();
+ }
+ // 小路
+ g.strokeStyle = 'rgba(200,190,150,.6)'; g.lineWidth = 3; g.beginPath(); g.moveTo(470, 545); g.bezierCurveTo(500, 500, 470, 470, 510, 440); g.stroke();
+ // 树:柏树(深色竖椭圆)+圆树
+ for (let k = 0; k < 26; k++) { const x = 425 + r() * 370, y = 395 + r() * 140, s = 0.4 + (y - 380) / 150; if (Math.abs(x - 640) < 30 && y < 420) continue;
+ g.fillStyle = r() < 0.5 ? '#3f4c30' : '#4c5a36';
+ if (r() < 0.55) { g.beginPath(); g.ellipse(x, y - 14 * s, 4 * s, 15 * s, 0, 0, 7); g.fill(); } else { g.beginPath(); g.arc(x, y - 6 * s, 9 * s, 0, 7); g.fill(); } }
+ // 石桥
+ g.fillStyle = '#b8ad8c'; g.fillRect(566, 452, 56, 7); g.fillStyle = '#6e6650'; for (let k = 0; k < 3; k++) { g.beginPath(); g.arc(578 + k * 16, 460, 5, Math.PI, 0); g.fill(); }
+ g.restore();
+ }
+
+ // ---------- 静态层 ----------
+ const VP = { yh: 420, cx: 960, f: 1029, h: 5.75 };
+ const proj = (X, Z) => [VP.cx + VP.f * X / Z, VP.yh + VP.f * VP.h / Z];
+ function room(g) {
+ // 墙:抹灰斑驳+窗光晕
+ g.drawImage(P.texture('ren_wall', '#43321f', { scale: 0.0024, amt: 30, grain: 12, dark: '#22180e', seed: 21 }), 0, 0);
+ const top = g.createLinearGradient(0, 0, 0, 780); top.addColorStop(0, 'rgba(12,7,3,.45)'); top.addColorStop(0.5, 'rgba(12,7,3,0)'); top.addColorStop(1, 'rgba(12,7,3,.15)'); g.fillStyle = top; g.fillRect(0, 0, W, 780);
+ const glow = g.createRadialGradient(585, 360, 60, 585, 380, 900); glow.addColorStop(0, 'rgba(190,150,100,.42)'); glow.addColorStop(0.45, 'rgba(150,110,70,.16)'); glow.addColorStop(1, 'rgba(0,0,0,0)');
+ g.fillStyle = glow; g.fillRect(0, 0, W, H);
+ // 墙裙阴影线
+ const bb = g.createLinearGradient(0, 760, 0, 792); bb.addColorStop(0, 'rgba(20,12,6,0)'); bb.addColorStop(0.7, 'rgba(20,12,6,.45)'); bb.addColorStop(1, 'rgba(20,12,6,.7)'); g.fillStyle = bb; g.fillRect(0, 760, W, 32);
+ // 地砖:透视棋盘(Z 从墙 16 往前,砖宽 1.4)
+ const zs = []; for (let z = 16; z > 5; z -= 1.4) zs.push(z);
+ for (let j = 0; j < zs.length; j++) { const z0 = zs[j], z1 = z0 - 1.4;
+ for (let i = -14; i < 14; i++) { const X0 = i * 1.4, X1 = X0 + 1.4;
+ const p = [proj(X0, z0), proj(X1, z0), proj(X1, z1), proj(X0, z1)];
+ if (p[2][0] < -300 || p[3][0] > W + 300) continue;
+ g.fillStyle = (i + j) % 2 ? '#a88c64' : '#5c2418'; g.beginPath(); p.forEach((q, k) => k ? g.lineTo(...q) : g.moveTo(...q)); g.closePath(); g.fill();
+ g.strokeStyle = 'rgba(30,15,8,.35)'; g.lineWidth = 1.2; g.stroke(); } }
+ // 地面受光:窗光落在猫前方
+ g.save(); g.globalCompositeOperation = 'soft-light';
+ const lp = g.createRadialGradient(700, 950, 30, 700, 950, 520); lp.addColorStop(0, 'rgba(255,230,180,.95)'); lp.addColorStop(1, 'rgba(255,230,180,0)'); g.fillStyle = lp; g.fillRect(0, 780, W, 300);
+ g.restore();
+ const fd = g.createLinearGradient(0, 790, 0, 1080); fd.addColorStop(0, 'rgba(25,14,8,.55)'); fd.addColorStop(0.35, 'rgba(25,14,8,.2)'); fd.addColorStop(1, 'rgba(25,14,8,.45)'); g.fillStyle = fd; g.fillRect(0, 790, W, 290);
+ const fside = g.createRadialGradient(760, 960, 120, 760, 960, 1100); fside.addColorStop(0, 'rgba(18,9,4,0)'); fside.addColorStop(0.5, 'rgba(18,9,4,.3)'); fside.addColorStop(1, 'rgba(18,9,4,.75)'); g.fillStyle = fside; g.fillRect(0, 790, W, 290);
+ // 拱窗:石框(左侧受光)+窗洞
+ g.save(); g.shadowColor = 'rgba(0,0,0,.5)'; g.shadowBlur = 30; g.shadowOffsetX = 10; g.shadowOffsetY = 14;
+ const st = g.createLinearGradient(360, 0, 810, 0); st.addColorStop(0, '#c6b08a'); st.addColorStop(0.5, '#a48c68'); st.addColorStop(1, '#7c6a4e');
+ g.fillStyle = st; g.fill(OUTER); g.restore();
+ const lightR = g.createLinearGradient(360, 0, 430, 0); lightR.addColorStop(0, 'rgba(255,240,210,.0)'); lightR.addColorStop(1, 'rgba(255,240,210,.35)'); g.fillStyle = lightR; g.fill(OUTER);
+ landscape(g);
+ g.strokeStyle = 'rgba(60,40,20,.55)'; g.lineWidth = 3; g.stroke(INNER);
+ // 窗台
+ const sl = g.createLinearGradient(0, 556, 0, 582); sl.addColorStop(0, '#d8c8a4'); sl.addColorStop(1, '#8c7a5a'); g.fillStyle = sl; g.fillRect(335, 556, 490, 24);
+ g.fillStyle = 'rgba(0,0,0,.35)'; g.fillRect(345, 580, 480, 10);
+ // 桌子影子
+ g.fillStyle = 'rgba(15,8,4,.45)'; g.beginPath(); g.ellipse(1000, 905, 230, 22, 0, 0, 7); g.fill();
+ // 椅(梯背,在少女后)
+ const wood = (x, y, w, h) => { const wg = g.createLinearGradient(x, 0, x + w, 0); wg.addColorStop(0, '#7a4a26'); wg.addColorStop(0.4, '#9a6234'); wg.addColorStop(1, '#4a2c16'); g.fillStyle = wg; g.fillRect(x, y, w, h); };
+ wood(1458, 445, 18, 455); g.fillStyle = '#9a6234'; g.beginPath(); g.ellipse(1467, 447, 11, 6, 0, 0, 7); g.fill();
+ for (let k = 0; k < 4; k++) wood(1440, 490 + k * 58, 30, 8);
+ wood(1430, 560, 14, 340);
+ g.fillStyle = 'rgba(15,8,4,.4)'; g.beginPath(); g.ellipse(1400, 905, 130, 14, 0, 0, 7); g.fill();
+ // 方桌:桌腿+横撑+白桌布
+ wood(838, 750, 16, 155); wood(1160, 750, 16, 155); wood(852, 818, 310, 9); wood(905, 748, 12, 120);
+ const cl = poly([[815, 626], [1205, 626], [1210, 758], [812, 760]]);
+ const cg = g.createLinearGradient(815, 0, 1210, 0); cg.addColorStop(0, '#e8dcbc'); cg.addColorStop(0.5, '#d6c8a4'); cg.addColorStop(1, '#a8987a'); g.fillStyle = cg; g.fill(cl);
+ g.save(); g.clip(cl);
+ for (let x = 830; x < 1210; x += 34) { const fg = g.createLinearGradient(x, 0, x + 34, 0); fg.addColorStop(0, 'rgba(255,250,235,.25)'); fg.addColorStop(0.5, 'rgba(80,60,40,.12)'); fg.addColorStop(1, 'rgba(255,250,235,.0)'); g.fillStyle = fg; g.fillRect(x, 640, 34, 120); }
+ g.fillStyle = 'rgba(255,250,235,.55)'; g.fillRect(815, 626, 395, 12);
+ g.fillStyle = '#7f95a8'; g.fillRect(812, 734, 400, 3); g.fillRect(812, 741, 400, 2);
+ g.restore();
+ g.strokeStyle = 'rgba(60,45,30,.35)'; g.lineWidth = 2; g.stroke(cl);
+ }
+ const STATIC = () => P.cached('ren_static', W, H, (g) => {
+ const raw = P.canvas(), rg = raw.getContext('2d'); room(rg);
+ g.filter = 'blur(1.3px)'; g.drawImage(raw, 0, 0); g.filter = 'none';
+ });
+ // 罩层:龟裂纹+画布纹+暗角+黄釉
+ const OVER = () => P.cached('ren_over', W, H, (g) => {
+ const v = g.createRadialGradient(820, 520, 300, 900, 560, 1250); v.addColorStop(0, 'rgba(20,10,4,0)'); v.addColorStop(0.55, 'rgba(20,10,4,.3)'); v.addColorStop(1, 'rgba(10,5,2,.8)'); g.fillStyle = v; g.fillRect(0, 0, W, H);
+ g.fillStyle = 'rgba(150,110,40,.07)'; g.fillRect(0, 0, W, H);
+ const r = R_(4); g.lineWidth = 1;
+ for (let y = 0; y < H; y += 3) { g.strokeStyle = `rgba(0,0,0,${0.03 + r() * 0.04})`; g.beginPath(); g.moveTo(0, y + .5); g.lineTo(W, y + .5); g.stroke(); }
+ for (let x = 0; x < W; x += 3) { g.strokeStyle = `rgba(255,240,210,${0.015 + r() * 0.03})`; g.beginPath(); g.moveTo(x + .5, 0); g.lineTo(x + .5, H); g.stroke(); }
+ // 油彩笔触肌理:几万笔极淡的短笔(亮暗各半,方向随噪声),让平涂面有「刷过」的感觉
+ g.lineCap = 'round';
+ for (let k = 0; k < 9000; k++) { const x = r() * W, y = r() * H, a = r() * Math.PI, L = 10 + r() * 16;
+ g.strokeStyle = r() < 0.5 ? 'rgba(255,235,200,.022)' : 'rgba(20,10,0,.028)'; g.lineWidth = 5 + r() * 5; g.beginPath(); g.moveTo(x, y); g.lineTo(x + Math.cos(a) * L, y + Math.sin(a) * L); g.stroke(); }
+ // 龟裂:暗线+右下错 1px 的亮边(漆皮翘起)
+ g.globalAlpha = 0.32; g.drawImage(P.craquelure('ren', 0.55), 0, 0);
+ g.globalAlpha = 0.16; g.globalCompositeOperation = 'lighter'; g.filter = 'brightness(0) invert(1)'; g.drawImage(P.craquelure('ren', 0.55), 1, 1); g.filter = 'none';
+ g.globalAlpha = 1; g.globalCompositeOperation = 'source-over';
+ });
+
+ // ---------- 动态:扑翼机、飞鸟、河光、浮尘 ----------
+ function ornithopter(c, lt, t) {
+ // 达芬奇扑翼机:木架上趴一个红衣人,两张蝙蝠翼(前缘梁+放射肋+扇贝后缘膜)上下扇,后有扇形尾舵
+ const q = clamp(lt / 1.3), x = lerp(440, 790, q), y = 226 + Math.sin(lt * 5) * 14 - q * 24, flap = Math.sin(t * 12);
+ c.save(); c.clip(INNER); c.translate(x, y); c.rotate(-0.08 + Math.sin(lt * 5 + 1) * 0.07); c.scale(1.6, 1.6); // 放大 1.6:窗里一眼看得到
+ const wing = (sc, dark, ph) => {
+ const up = 0.5 + 0.5 * Math.sin(t * 12 + ph); // 0=翼压下 1=翼抬起
+ const tip = [-26 * sc, (-118 * up + 24 * (1 - up)) * sc];
+ const back = [-128 * sc, (-30 * up + 18) * sc];
+ const ribs = 5, ends = [];
+ for (let k = 0; k <= ribs; k++) { const u = k / ribs; ends.push([lerp(tip[0], back[0], u) - Math.sin(u * Math.PI) * 26 * sc, lerp(tip[1], back[1], u) - Math.sin(u * Math.PI) * 8 * sc * (up - 0.3)]); }
+ c.fillStyle = dark ? 'rgba(150,118,80,.92)' : 'rgba(214,188,140,.95)';
+ c.beginPath(); c.moveTo(0, 0); c.lineTo(...ends[0]);
+ for (let k = 1; k <= ribs; k++) { const a = ends[k - 1], b = ends[k], m = [(a[0] + b[0]) / 2 + 6 * sc, (a[1] + b[1]) / 2 + 9 * sc]; c.quadraticCurveTo(m[0], m[1], b[0], b[1]); }
+ c.lineTo(-30 * sc, 6 * sc); c.closePath(); c.fill();
+ c.strokeStyle = '#4e321a'; c.lineWidth = 1.6; c.stroke();
+ c.lineWidth = 2.2; ends.forEach((e, k) => { c.beginPath(); c.moveTo(-4, 0); c.lineTo(e[0], e[1]); c.lineWidth = k ? 1.4 : 3; c.stroke(); });
+ };
+ wing(0.78, true, 0.5); // 远翼:小一号、暗一点、相位略错
+ c.strokeStyle = '#4e321a'; c.lineWidth = 3.5; c.beginPath(); c.moveTo(40, 8); c.lineTo(-80, 12); c.stroke();
+ c.lineWidth = 2; c.beginPath(); c.moveTo(-10, 10); c.lineTo(-30, 30); c.lineTo(10, 30); c.closePath(); c.stroke();
+ // 尾舵
+ c.fillStyle = 'rgba(214,188,140,.95)'; c.beginPath(); c.moveTo(-78, 12); c.lineTo(-118, -6 + Math.sin(t * 6) * 4); c.quadraticCurveTo(-112, 12, -116, 32 + Math.sin(t * 6) * 4); c.closePath(); c.fill(); c.strokeStyle = '#4e321a'; c.lineWidth = 1.6; c.stroke();
+ // 驾驶者
+ c.fillStyle = '#a02a1e'; c.beginPath(); c.ellipse(6, 14, 30, 6.5, 0.03, 0, 7); c.fill();
+ c.fillStyle = '#d8b090'; c.beginPath(); c.arc(38, 11, 6, 0, 7); c.fill();
+ c.strokeStyle = '#a02a1e'; c.lineWidth = 3.5; c.beginPath(); c.moveTo(-22, 15); c.lineTo(-40, 18 + flap * 4); c.stroke();
+ wing(1.0, false, 0);
+ c.restore();
+ }
+ function birds(c, lt, t) {
+ c.save(); c.clip(INNER); c.strokeStyle = 'rgba(50,40,30,.85)'; c.lineWidth = 1.8; c.lineCap = 'round';
+ const r = R_(9);
+ for (let k = 0; k < 14; k++) { const x0 = 520 + r() * 300, y0 = 180 + r() * 120, s = 1.0 + r() * 0.8, sp = 30 + r() * 40, ph = r() * 7;
+ const x = x0 - lt * sp, y = y0 + Math.sin(lt * 3 + ph) * 4, f = Math.sin(t * 11 + ph) * 5 * s;
+ c.beginPath(); c.moveTo(x - 7 * s, y - f); c.quadraticCurveTo(x - 3 * s, y - 2, x, y + 1); c.quadraticCurveTo(x + 3 * s, y - 2, x + 7 * s, y - f); c.stroke(); }
+ c.restore();
+ }
+ function riverGlints(c, t) {
+ // 云影:几块淡暗椭圆从左往右掠过河谷(阳光一明一暗)
+ c.save(); c.clip(INNER); for (let k = 0; k < 3; k++) { const x = 360 + ((t * 70 + k * 190) % 560), y = 400 + k * 45; const g = c.createRadialGradient(x, y, 5, x, y, 90); g.addColorStop(0, 'rgba(30,40,40,.28)'); g.addColorStop(1, 'rgba(30,40,40,0)'); c.fillStyle = g; c.save(); c.translate(x, y); c.scale(1, 0.35); c.translate(-x, -y); c.beginPath(); c.arc(x, y, 90, 0, 7); c.fill(); c.restore(); } c.restore();
+ c.save(); c.clip(INNER); c.globalCompositeOperation = 'lighter';
+ for (let k = 0; k < 24; k++) { const u = ((t * 0.22 + k / 24) % 1) * (RIVER.length - 1), i = Math.floor(u), f = u - i, a = RIVER[i], b = RIVER[i + 1];
+ const x = lerp(a[0], b[0], f), y = lerp(a[1], b[1], f), tw = Math.max(0, Math.sin(t * 9 + k * 2.3));
+ c.fillStyle = `rgba(255,255,245,${0.6 * tw})`; c.beginPath(); c.ellipse(x, y, 2 + i * 0.5, 1.2, 0, 0, 7); c.fill(); }
+ c.restore();
+ }
+ // 光柱(窗→地面)+浮尘
+ const BEAM = poly([[440, 330], [790, 360], [1000, 1080], [400, 1080]]);
+ const BEAMC = () => P.cached('ren_beam', W, H, (g) => { // 光柱只算一次:大半径模糊让两条边化开
+ const bg = g.createLinearGradient(560, 300, 700, 1080); bg.addColorStop(0, 'rgba(255,225,170,.0)'); bg.addColorStop(0.3, 'rgba(255,225,170,.13)'); bg.addColorStop(1, 'rgba(255,225,170,.07)');
+ g.filter = 'blur(28px)'; g.fillStyle = bg; g.fill(BEAM); g.filter = 'none';
+ });
+ function beamAndDust(c, lt, t) {
+ c.save(); c.globalCompositeOperation = 'screen';
+ c.globalAlpha = 0.75 + 0.35 * Math.sin(t * 2.3); c.drawImage(BEAMC(), 0, 0); c.globalAlpha = 1; // 云过日:光柱时强时弱
+ const ps = P.particles(70, 17, t, { x0: 440, x1: 880, y0: 1000, y1: 430, speed: 60, drift: 18, life: 6 });
+ for (const p of ps) { const tw = 0.5 + 0.5 * Math.sin(t * 6 + p.i * 1.7), a = 0.9 * tw * Math.sin(p.q * Math.PI);
+ const g = c.createRadialGradient(p.x, p.y, 0, p.x, p.y, 4 * p.s + 1); g.addColorStop(0, `rgba(255,240,200,${a})`); g.addColorStop(1, 'rgba(255,240,200,0)'); c.fillStyle = g; c.fillRect(p.x - 6, p.y - 6, 12, 12); }
+ c.restore();
+ }
+
+ // ---------- 角色 ----------
+ const SK = '#e6bf9c', SK_D = '#b88866', HAIR = '#c49a4e', HAIR_L = '#e8c87e', HAIR_D = '#6e4a1c';
+ const VEL = '#2c4628', VEL_L = '#6e8c56', RED = '#7c1818', RED_L = '#b8302a', RED_D = '#3e0808', GOLD = '#c9a24a';
+ // 在 path 里画「沿骨骼的光带」:天鹅绒的高光在褶子顶上,最亮处偏白
+ const sheen = (c, path, A, B, col, w) => { c.save(); c.clip(path); c.strokeStyle = col; c.lineWidth = w; c.lineCap = 'round'; c.beginPath(); c.moveTo(...A); c.lineTo(...B); c.stroke(); c.restore(); };
+ function girl(c, G, lt, t, ch) {
+ const A = G.A;
+ c.save(); c.lineJoin = 'round'; c.lineCap = 'round';
+ // 长发(背后):中分,波浪垂到腰
+ const nape = A.nape, sw = Math.sin(t * 3) * 11;
+ const hair = RIG.smooth([[nape[0] - 40, nape[1] - 120], [nape[0] + 40, nape[1] - 110], [nape[0] + 66, nape[1] - 40], [nape[0] + 74, nape[1] + 30], [nape[0] + 92 + sw, nape[1] + 80], [nape[0] + 82 + sw, nape[1] + 130], [nape[0] + 98 + sw, nape[1] + 180], [nape[0] + 84 + sw, nape[1] + 228],
+ [nape[0] + 58 + sw, nape[1] + 236], [nape[0] + 36, nape[1] + 170], [nape[0] + 20, nape[1] + 90], [nape[0] - 10, nape[1] + 30], [nape[0] - 40, nape[1] - 20]]);
+ const hg = c.createLinearGradient(nape[0], nape[1] - 100, nape[0] + 80, nape[1] + 220); hg.addColorStop(0, HAIR_L); hg.addColorStop(0.5, HAIR); hg.addColorStop(1, HAIR_D);
+ c.fillStyle = hg; c.fill(hair);
+ c.save(); c.clip(hair); c.lineWidth = 3;
+ for (let k = 0; k < 9; k++) { c.strokeStyle = k % 2 ? 'rgba(255,226,150,.7)' : 'rgba(80,50,14,.65)'; c.beginPath(); for (let s = 0; s <= 24; s++) { const q = s / 24, x = nape[0] - 20 + k * 11 + q * 50 + Math.sin(q * 11 + k) * 7, y = nape[1] - 110 + q * 340; s ? c.lineTo(x, y) : c.moveTo(x, y); } c.stroke(); }
+ c.restore();
+ // 远侧袖与手
+ c.fillStyle = VEL; c.fill(G.farSleeve); c.fillStyle = GOLD; c.fill(G.farCuff); c.fillStyle = SK; c.fill(G.farHand);
+ // 红天鹅绒长裙:底色+褶上高光+褶间暗
+ const sg = c.createLinearGradient(1100, 600, 1450, 940); sg.addColorStop(0, RED_L); sg.addColorStop(0.5, RED); sg.addColorStop(1, RED_D);
+ c.fillStyle = sg; c.fill(G.skirt);
+ c.save(); c.clip(G.skirt);
+ const folds = [[1150, 700, 1120, 925, 22], [1200, 680, 1180, 930, 26], [1250, 660, 1250, 932, 20], [1300, 660, 1310, 930, 18], [1360, 700, 1380, 920, 16]];
+ folds.forEach(([x0, y0, x1, y1, w], k) => { c.strokeStyle = 'rgba(200,70,60,.3)'; c.lineWidth = w; c.beginPath(); c.moveTo(x0 - 6, y0 + 60); c.quadraticCurveTo((x0 + x1) / 2 - 10, (y0 + y1) / 2, x1, y1); c.stroke();
+ c.strokeStyle = 'rgba(40,0,0,.45)'; c.lineWidth = w * 0.7; c.beginPath(); c.moveTo(x0 + 26, y0 + 10); c.quadraticCurveTo((x0 + x1) / 2 + 18, (y0 + y1) / 2, x1 + 26, y1); c.stroke(); });
+ c.strokeStyle = GOLD; c.lineWidth = 5; c.beginPath(); c.moveTo(1100, 922); c.quadraticCurveTo(1230, 940, 1360, 922); c.stroke();
+ c.restore();
+ c.fillStyle = '#2a1608'; c.fill(G.shoe);
+ // 胸衣:红,方领金边
+ const tg = c.createLinearGradient(1280, 430, 1420, 620); tg.addColorStop(0, RED_L); tg.addColorStop(1, RED_D); c.fillStyle = tg; c.fill(G.torso);
+ sheen(c, G.torso, [1300, 470], [1300, 600], 'rgba(230,100,80,.35)', 18);
+ c.fillStyle = SK; c.fill(G.neck);
+ c.strokeStyle = GOLD; c.lineWidth = 5; c.beginPath(); c.moveTo(A.neck[0] - 16, A.neck[1] + 4); c.lineTo(A.neck[0] - 6, A.neck[1] + 34); c.lineTo(A.neck[0] + 34, A.neck[1] + 30); c.lineTo(A.neck[0] + 36, A.neck[1] + 2); c.stroke();
+ c.fillStyle = '#7a1414'; c.beginPath(); c.arc(A.neck[0] + 4, A.neck[1] + 24, 4, 0, 7); c.fill(); // 小垂饰
+ // 头发(头顶)+脸
+ c.fillStyle = HAIR; c.fill(G.hairBack);
+ const fg = c.createLinearGradient(G.A.forehead[0] - 10, 0, G.A.ear[0] + 10, 0); fg.addColorStop(0, '#f0d0b0'); fg.addColorStop(0.6, SK); fg.addColorStop(1, SK_D);
+ c.fillStyle = fg; c.fill(G.face);
+ c.save(); c.clip(G.face); c.fillStyle = 'rgba(220,120,100,.28)'; c.beginPath(); c.arc(G.cheek[0] - 2, G.cheek[1], 18, 0, 7); c.fill();
+ c.fillStyle = 'rgba(120,70,40,.22)'; c.beginPath(); c.ellipse(G.eye.x + 8, G.eye.y + 2, 14, 9, 0, 0, 7); c.fill(); c.restore(); // 眼窝阴影(晕涂)
+ c.fillStyle = SK_D; c.beginPath(); c.ellipse(G.ear[0], G.ear[1], 7, 11, 0.2, 0, 7); c.fill();
+ // 中分刘海:两片从发缝向后梳
+ c.fillStyle = HAIR; c.fill(G.bangs);
+ c.save(); c.clip(G.bangs); c.strokeStyle = 'rgba(250,225,160,.6)'; c.lineWidth = 2.5; G.hairLines.forEach(h => c.stroke(h)); c.restore();
+ c.strokeStyle = HAIR_D; c.lineWidth = 2; G.hairLines.forEach(h => c.stroke(h));
+ G.locks.forEach(h => { c.strokeStyle = HAIR_D; c.lineWidth = 8; c.stroke(h); c.strokeStyle = HAIR; c.lineWidth = 5; c.stroke(h); });
+ // 珍珠额链
+ const f0 = A.forehead, e0 = A.ear; for (let k = 0; k <= 12; k++) { const q = k / 12, x = lerp(f0[0] + 6, e0[0] + 4, q), y = lerp(f0[1] + 4, e0[1] - 28, q) - Math.sin(q * Math.PI) * 10; c.fillStyle = '#f4ecd8'; c.beginPath(); c.arc(x, y, 2.6, 0, 7); c.fill(); c.fillStyle = 'rgba(120,100,80,.6)'; c.beginPath(); c.arc(x + .8, y + .8, 1, 0, 7); c.fill(); }
+ // 五官:啜饮时闭眼
+ const closed = ch.blink || ch.cup > 0.7;
+ c.strokeStyle = '#4a2a18'; c.lineWidth = 2.2;
+ if (closed) { c.beginPath(); c.arc(G.eye.x + 1, G.eye.y - 3, 7, 0.35, Math.PI - 0.5); c.stroke(); c.lineWidth = 1.4; for (let k = 0; k < 3; k++) { c.beginPath(); c.moveTo(G.eye.x - 4 + k * 4, G.eye.y + 3); c.lineTo(G.eye.x - 6 + k * 4, G.eye.y + 7); c.stroke(); } }
+ else { c.fillStyle = '#f2e6d8'; c.beginPath(); c.ellipse(G.eye.x, G.eye.y, 7.5, 4.2, 0, 0, 7); c.fill(); c.fillStyle = '#4a3420'; c.beginPath(); c.arc(G.eye.x - 2.5, G.eye.y + 0.5, 3.2, 0, 7); c.fill(); c.stroke(G.lid); }
+ c.strokeStyle = 'rgba(120,80,40,.7)'; c.lineWidth = 1.8; c.stroke(G.brow);
+ c.fillStyle = '#a8423a'; c.beginPath(); c.moveTo(...G.lips[0]); c.lineTo(...G.lips[1]); c.lineTo(...G.lips[2]); c.closePath(); c.fill();
+ // 近侧手臂:绿天鹅绒袖(沿臂高光)+肩部金线珍珠+金袖口
+ for (const [p, a, b] of [[G.upperArm, A.shoulder, A.elbow], [G.foreArm, A.elbow, A.hand]]) {
+ const ag = c.createLinearGradient(a[0] - 30, a[1] - 30, a[0] + 30, a[1] + 30); ag.addColorStop(0, VEL_L); ag.addColorStop(1, VEL); c.fillStyle = ag; c.fill(p);
+ sheen(c, p, [lerp(a[0], b[0], 0.1) - 4, lerp(a[1], b[1], 0.1) - 6], [lerp(a[0], b[0], 0.85) - 4, lerp(a[1], b[1], 0.85) - 6], 'rgba(170,200,140,.45)', 10);
+ }
+ for (let k = 0; k < 4; k++) { const q = k / 3; c.fillStyle = '#f4ecd8'; c.beginPath(); c.arc(lerp(A.shoulder[0] - 22, A.shoulder[0] + 24, q), lerp(A.shoulder[1] - 8, A.shoulder[1] + 10, q), 3.4, 0, 7); c.fill(); }
+ c.fillStyle = GOLD; c.fill(G.cuff);
+ c.fillStyle = SK; c.fill(G.hand);
+ goblet(c, G.cup);
+ c.fillStyle = SK; c.beginPath(); c.arc(G.thumb[0], G.thumb[1], 6.5, 0, 7); c.fill();
+ c.restore();
+ }
+ function goblet(c, cup) { // 银高脚杯,红酒
+ c.save(); c.translate(cup.x, cup.y); c.rotate(cup.tilt || 0);
+ const sg = c.createLinearGradient(-24, 0, 24, 0); sg.addColorStop(0, '#6c6c70'); sg.addColorStop(0.3, '#f4f4f0'); sg.addColorStop(0.55, '#b4b4b6'); sg.addColorStop(1, '#4a4a50');
+ c.fillStyle = sg; c.beginPath(); c.moveTo(-23, 0); c.bezierCurveTo(-23, 22, -8, 32, 0, 32); c.bezierCurveTo(8, 32, 23, 22, 23, 0); c.closePath(); c.fill();
+ c.fillRect(-3, 30, 6, 24); c.beginPath(); c.ellipse(0, 42, 6, 3.5, 0, 0, 7); c.fill();
+ c.beginPath(); c.ellipse(0, 56, 17, 4.5, 0, 0, 7); c.fill();
+ c.fillStyle = '#5a0c14'; c.beginPath(); c.ellipse(0, 1, 21, 5, 0, 0, 7); c.fill();
+ c.fillStyle = 'rgba(255,255,255,.7)'; c.fillRect(-15, 6, 3, 14);
+ c.restore();
+ }
+ function cat(c, K, t, ch) {
+ const OR = '#d88a3e', OR_D = '#9a5520', OR_L = '#f2b46a', WH = '#f4ece0';
+ c.save(); c.lineCap = 'round'; c.lineJoin = 'round';
+ // 地面投影
+ c.fillStyle = 'rgba(20,10,4,.45)'; c.beginPath(); c.ellipse(545, 905, 150, 18, 0, 0, 7); c.fill();
+ // 尾巴:橘,环纹,白尖
+ c.strokeStyle = OR; c.lineWidth = K.tailW; c.stroke(K.tail);
+ const tp = K.tailPts; c.strokeStyle = OR_D; c.lineWidth = 5; for (let i = 2; i < tp.length - 2; i += 3) { const a = Math.atan2(tp[i + 1][1] - tp[i][1], tp[i + 1][0] - tp[i][0]) + Math.PI / 2; c.beginPath(); c.moveTo(tp[i][0] - Math.cos(a) * 11, tp[i][1] - Math.sin(a) * 11); c.lineTo(tp[i][0] + Math.cos(a) * 11, tp[i][1] + Math.sin(a) * 11); c.stroke(); }
+ const tip = tp[tp.length - 1]; c.fillStyle = WH; c.beginPath(); c.arc(tip[0], tip[1], K.tailW / 2, 0, 7); c.fill();
+ // 身体:径向体积
+ const body = RIG.smooth(K.bodyPts);
+ // 白底(胸腹受光)→ 背上橘色毛被用大半径径向渐变「晕」进来,没有硬边界
+ const bg = c.createLinearGradient(430, 0, 660, 0); bg.addColorStop(0, '#e8dccb'); bg.addColorStop(0.55, WH); bg.addColorStop(1, '#a89478');
+ c.fillStyle = bg; c.fill(body);
+ c.save(); c.clip(body);
+ const coat = c.createRadialGradient(455, 760, 30, 470, 770, 170); coat.addColorStop(0, OR); coat.addColorStop(0.55, 'rgba(216,138,62,.92)'); coat.addColorStop(1, 'rgba(216,138,62,0)');
+ c.fillStyle = coat; c.fillRect(380, 640, 300, 280);
+ const coat2 = c.createRadialGradient(520, 690, 10, 520, 690, 90); coat2.addColorStop(0, OR); coat2.addColorStop(1, 'rgba(216,138,62,0)'); c.fillStyle = coat2; c.fillRect(420, 600, 200, 200);
+ // 虎斑:只在橘毛区,软边
+ c.strokeStyle = 'rgba(150,75,20,.38)';
+ for (let k = 0; k < 7; k++) { const y = 706 + k * 27 + Math.sin(k * 2.7) * 6; c.lineWidth = 5 + (k % 3) * 2; c.beginPath(); c.moveTo(420, y + 14); c.quadraticCurveTo(450 + k * 3, y - 10, 488 + (k % 2) * 20, y + 16 - k); c.stroke(); }
+ // 腹侧阴影
+ const sh = c.createLinearGradient(0, 760, 0, 905); sh.addColorStop(0, 'rgba(80,40,10,0)'); sh.addColorStop(1, 'rgba(80,40,10,.35)'); c.fillStyle = sh; c.fillRect(400, 760, 280, 150);
+ // 毛:短线(受光侧亮、背光侧暗)
+ const r = R_(3);
+ for (let k = 0; k < 420; k++) { const x = 425 + r() * 240, y = 670 + r() * 230, a = Math.PI / 2 + (x - 540) * 0.004 + (r() - .5) * 0.5, L = 6 + r() * 8;
+ c.strokeStyle = r() < 0.5 ? 'rgba(255,220,170,.45)' : 'rgba(110,55,15,.35)'; c.lineWidth = 1.4; c.beginPath(); c.moveTo(x, y); c.lineTo(x + Math.cos(a) * L, y + Math.sin(a) * L); c.stroke(); }
+ c.strokeStyle = 'rgba(90,50,15,.22)'; c.lineWidth = 14; c.stroke(body); // 轮廓内侧轻压暗=体积(太重会像玻璃罩)
+ c.restore();
+ K.legs.forEach(l => { const lg = c.createLinearGradient(570, 0, 650, 0); lg.addColorStop(0, '#fbf6ec'); lg.addColorStop(1, '#c8bcaa'); c.fillStyle = lg; c.fill(l); });
+ c.fillStyle = 'rgba(120,90,60,.25)'; K.legs.forEach(l => { c.save(); c.clip(l); c.fillRect(600, 740, 60, 160); c.restore(); });
+ for (const x of [585, 635]) { const pg = c.createRadialGradient(x - 4, 886, 2, x, 890, 22); pg.addColorStop(0, '#fffaf0'); pg.addColorStop(1, '#cfc2ae'); c.fillStyle = pg; c.beginPath(); c.ellipse(x, 892, 21, 12, 0, 0, 7); c.fill(); }
+ // 头:绕脖子左右歪头蹭(眯眼享受),幅度 0.1rad
+ const pv = [K.headC[0] - 10, K.headC[1] + 58]; c.save(); c.translate(...pv); c.rotate(0.16 * Math.sin(t * 3.4) + 0.05 * Math.sin(t * 8.1)); c.translate(-pv[0], -pv[1]);
+ const hc = K.headC, hg = c.createRadialGradient(hc[0] - 10, hc[1] - 20, 8, hc[0], hc[1], 80); hg.addColorStop(0, OR_L); hg.addColorStop(0.6, OR); hg.addColorStop(1, OR_D);
+ c.fillStyle = hg; c.fill(K.head);
+ c.fillStyle = 'rgba(230,150,140,.8)'; K.earInner.forEach(e => { c.beginPath(); e.forEach((p, i) => i ? c.lineTo(...p) : c.moveTo(...p)); c.fill(); });
+ c.save(); c.clip(K.head);
+ c.strokeStyle = 'rgba(140,70,20,.6)'; c.lineWidth = 6; K.stripes.slice(0, 3).forEach(s => { c.beginPath(); c.moveTo(...s[0]); c.lineTo(...s[1]); c.stroke(); });
+ const mg = c.createRadialGradient(K.nose[0] - 20, K.nose[1] + 10, 4, K.nose[0] - 20, K.nose[1] + 10, 46); mg.addColorStop(0, WH); mg.addColorStop(0.7, 'rgba(244,236,224,.9)'); mg.addColorStop(1, 'rgba(244,236,224,0)');
+ c.fillStyle = mg; c.beginPath(); c.arc(K.nose[0] - 20, K.nose[1] + 10, 46, 0, 7); c.fill();
+ c.strokeStyle = 'rgba(80,35,8,.4)'; c.lineWidth = 18; c.stroke(K.head);
+ c.restore();
+ // 眯眼微笑
+ c.strokeStyle = '#3a2210'; c.lineWidth = 3;
+ const sq = 0.5 + 0.5 * Math.sin(t * 4.5); // 眯得更紧/稍松,交替
+ K.eyes.forEach(e => { c.beginPath(); c.arc(e.x, e.y + 4 + sq * 2, 9, Math.PI * (1.15 + sq * 0.08), Math.PI * (1.85 - sq * 0.08)); c.stroke(); });
+ c.fillStyle = '#d07a70'; c.beginPath(); c.moveTo(K.nose[0] - 5, K.nose[1] - 3); c.lineTo(K.nose[0] + 5, K.nose[1] - 3); c.lineTo(K.nose[0], K.nose[1] + 3); c.closePath(); c.fill();
+ c.strokeStyle = '#4a2a18'; c.lineWidth = 2.2; c.beginPath(); c.moveTo(K.nose[0], K.nose[1] + 3); c.lineTo(K.nose[0], K.nose[1] + 8);
+ c.moveTo(K.nose[0] - 12, K.nose[1] + 8); c.quadraticCurveTo(K.nose[0] - 6, K.nose[1] + 15, K.nose[0], K.nose[1] + 8); c.quadraticCurveTo(K.nose[0] + 6, K.nose[1] + 15, K.nose[0] + 12, K.nose[1] + 7); c.stroke();
+ c.strokeStyle = 'rgba(250,245,235,.85)'; c.lineWidth = 1.3; K.whiskers.forEach(w => { c.beginPath(); c.moveTo(...w[0]); c.lineTo(...w[1]); c.stroke(); });
+ c.restore();
+ c.restore();
+ }
+
+ return {
+ init() { STATIC(); OVER(); },
+ draw(c, lt, t) {
+ const ch = P.choreo(lt, t);
+ c.drawImage(STATIC(), 0, 0);
+ riverGlints(c, t); birds(c, lt, t); ornithopter(c, lt, t);
+ // 角色:离屏 → 模糊层+清晰层叠加=晕涂
+ const L = P.scratch('renChars'), g = L.getContext('2d'); g.clearRect(320, 180, 1200, 780);
+ const K = RIG.cat({ tail: ch.tail * 2.2 + Math.sin(t * 2.6) * 0.35, blink: 0, breathe: ch.breathe * 3, look: Math.sin(t * 2.5) * 1.6 });
+ const G = RIG.girl({ cup: ch.cup, sip: ch.sip * 1.6, hair: 'long', breathe: ch.breathe * 2.5 });
+ g.fillStyle = 'rgba(15,8,4,.35)'; g.beginPath(); g.ellipse(1240, 935, 170, 16, 0, 0, 7); g.fill();
+ cat(g, K, t, ch); girl(g, G, lt, t, ch);
+ c.filter = 'blur(1.6px)'; c.drawImage(L, 320, 180, 1200, 780, 320, 180, 1200, 780); c.filter = 'none';
+ c.globalAlpha = 0.82; c.drawImage(L, 320, 180, 1200, 780, 320, 180, 1200, 780); c.globalAlpha = 1;
+ beamAndDust(c, lt, t);
+ c.drawImage(OVER(), 0, 0);
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/08_impressionism.js b/scripts/engine/scenes/08_impressionism.js
new file mode 100644
index 0000000..faaf347
--- /dev/null
+++ b/scripts/engine/scenes/08_impressionism.js
@@ -0,0 +1,206 @@
+// 1874 印象派(莫奈)——纯代码。
+// 管线:①平涂底稿(粉紫墙+右上斜射阳光、窗外花园:天/树/红顶屋/草地/摇曳的罂粟/撑伞女子、墙上《日出·印象》、圆桌、花瓶、右侧盆栽)
+// → ②P.strokes 短笔触重画(无描边、区域粉彩色板、方向场:墙斜向右上、地面横、植物放射;8fps 沸腾=整幅画在呼吸)
+// → ③角色平涂(白裙蓝腰带、系丝带草帽、金发;橘白猫)→ 同一渲染器细笔触重画 → 只给五官补极淡的色线
+// → ④光斑:地面/桌面的阳光斑块按各自节奏明灭跳动;猫背上的毛尖闪光;花瓣色点
+SCENES['08_impressionism'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp } = U, P = PAINT;
+ const poly = (pts) => { const p = new Path2D(); pts.forEach((q, i) => i ? p.lineTo(q[0], q[1]) : p.moveTo(q[0], q[1])); p.closePath(); return p; };
+ const WX0 = 372, WX1 = 790, WY0 = 132, WY1 = 548; // 窗洞
+ const POPPIES = (() => { const r = U.rng(8), o = []; for (let i = 0; i < 70; i++) { const x = 380 + r() * 200 + (r() < 0.25 ? r() * 200 : 0), y = 420 + r() * 125; o.push([x, y, 5 + r() * 6 + (y - 420) * 0.05, r() * 7]); } return o; })();
+
+ function base(g, t) {
+ // 墙:粉紫,右上方暖黄阳光
+ const wg = g.createLinearGradient(0, 0, W, 300); wg.addColorStop(0, '#d8bede'); wg.addColorStop(0.5, '#f0c8cc'); wg.addColorStop(1, '#f2c4d4');
+ g.fillStyle = wg; g.fillRect(0, 0, W, 790);
+ const sun = g.createRadialGradient(1400, -100, 50, 1400, -100, 900); sun.addColorStop(0, 'rgba(255,240,170,.85)'); sun.addColorStop(1, 'rgba(255,240,170,0)'); g.fillStyle = sun; g.fillRect(700, 0, 1220, 790);
+ // 地板
+ const fg = g.createLinearGradient(0, 780, 0, H); fg.addColorStop(0, '#d9a8b0'); fg.addColorStop(1, '#d88a80'); g.fillStyle = fg; g.fillRect(0, 780, W, 300);
+ g.fillStyle = '#b8a8dc'; g.fillRect(0, 768, W, 18);
+ // 窗外花园
+ g.save(); g.beginPath(); g.rect(WX0, WY0, WX1 - WX0, WY1 - WY0); g.clip();
+ const sk = g.createLinearGradient(0, WY0, 0, 300); sk.addColorStop(0, '#7aa6e2'); sk.addColorStop(1, '#bcd4f0'); g.fillStyle = sk; g.fillRect(WX0, WY0, 420, 180);
+ g.fillStyle = '#f6f6ff'; for (const [x, y, rx] of [[450, 175, 50], [520, 165, 40], [640, 190, 60], [720, 160, 40]]) { g.beginPath(); g.ellipse(WX0 - 60 + ((t * 45 + x - WX0 + 60) % 540), y, rx, rx * 0.35, 0, 0, 7); g.fill(); }
+ g.fillStyle = '#3e8a46'; g.beginPath(); g.moveTo(WX0, 360); for (let x = WX0; x <= WX1; x += 10) g.lineTo(x, 330 - Math.abs(P.noise(x * 0.02, 1)) * 60 - (x > 600 && x < 720 ? 60 * Math.sin((x - 600) / 120 * Math.PI) : 0)); g.lineTo(WX1, 360); g.closePath(); g.fill();
+ g.fillStyle = '#f0e6d0'; g.fillRect(455, 305, 50, 40); g.fillStyle = '#d0402a'; g.beginPath(); g.moveTo(448, 308); g.lineTo(480, 285); g.lineTo(512, 308); g.closePath(); g.fill();
+ const mg = g.createLinearGradient(0, 350, 0, WY1); mg.addColorStop(0, '#9ccc5a'); mg.addColorStop(1, '#6aa840'); g.fillStyle = mg; g.fillRect(WX0, 350, 420, 200);
+ // 罂粟:随风摇(茎底不动、花头横摆)
+ for (const [x, y, r, ph] of POPPIES) { const sw = Math.sin(t * 3.6 + ph + x * 0.02) * (10 + r * 0.8), hx = x + sw, hy = y - r * 0.6;
+ g.strokeStyle = '#3e7a30'; g.lineWidth = 2; g.beginPath(); g.moveTo(x, y + r * 1.4); g.quadraticCurveTo(x + sw * 0.3, y, hx, hy); g.stroke();
+ g.fillStyle = '#e8281e'; g.beginPath(); g.ellipse(hx, hy, r, r * 0.75, sw * 0.03, 0, 7); g.fill(); }
+ // 撑阳伞的女子+孩子(《罂粟田》)
+ const wx = 545, wy = 470; g.fillStyle = '#2a3a6a'; g.beginPath(); g.moveTo(wx - 12, wy + 50); g.lineTo(wx + 14, wy + 50); g.lineTo(wx + 5, wy); g.lineTo(wx - 5, wy); g.closePath(); g.fill();
+ g.fillStyle = '#f6f0e8'; g.beginPath(); g.arc(wx, wy - 6, 6, 0, 7); g.fill();
+ g.fillStyle = '#4aa0c8'; g.beginPath(); g.ellipse(wx - 4, wy - 22, 26, 12, -0.3, Math.PI, 0); g.fill(); g.strokeStyle = '#2a3a6a'; g.lineWidth = 2; g.beginPath(); g.moveTo(wx - 4, wy - 22); g.lineTo(wx + 2, wy + 8); g.stroke();
+ g.fillStyle = '#f6f0e8'; g.fillRect(505, 492, 10, 22); g.fillStyle = '#e8b040'; g.beginPath(); g.arc(510, 488, 6, 0, 7); g.fill();
+ // 花丛
+ g.fillStyle = '#5a9a40'; g.beginPath(); g.ellipse(735, 505, 44, 34, 0, 0, 7); g.fill();
+ for (let k = 0; k < 14; k++) { g.fillStyle = k % 2 ? '#f4a0c0' : '#fff0f4'; g.beginPath(); g.arc(710 + (k * 37 % 56), 485 + (k * 23 % 40), 6, 0, 7); g.fill(); }
+ g.fillStyle = '#c87a40'; g.fillRect(722, 530, 26, 20);
+ g.restore();
+ // 窗框(白)+窗格+窗帘杆+淡紫窗帘
+ g.strokeStyle = '#fbf6ee'; g.lineWidth = 18; g.strokeRect(WX0 - 9, WY0 - 9, WX1 - WX0 + 18, WY1 - WY0 + 18);
+ g.lineWidth = 9; g.beginPath(); g.moveTo(581, WY0); g.lineTo(581, WY1); g.moveTo(WX0, 270); g.lineTo(WX1, 270); g.moveTo(WX0, 410); g.lineTo(WX1, 410); g.stroke();
+ g.fillStyle = '#fbf6ee'; g.fillRect(345, 560, 470, 20);
+ g.fillStyle = '#d8b040'; g.fillRect(270, 92, 640, 9);
+ for (const [x0, x1] of [[292, 352], [812, 880]]) { const cg = g.createLinearGradient(x0, 0, x1, 0); cg.addColorStop(0, '#c4baf2'); cg.addColorStop(0.5, '#e6e0fc'); cg.addColorStop(1, '#a89ee6'); g.fillStyle = cg; g.beginPath(); g.moveTo(x0, 98); g.lineTo(x1, 98); g.quadraticCurveTo(x1 + 18 * Math.sin(t * 2.2), 380, x1 + 4 + 22 * Math.sin(t * 2.2 - 0.6), 620); g.lineTo(x0 - 4 + 22 * Math.sin(t * 2.2 - 0.6), 620); g.closePath(); g.fill(); }
+ // 《日出·印象》
+ g.fillStyle = '#e0b850'; g.fillRect(938, 192, 250, 180);
+ const sg = g.createLinearGradient(0, 205, 0, 360); sg.addColorStop(0, '#9aa8c8'); sg.addColorStop(1, '#5a78a8'); g.fillStyle = sg; g.fillRect(950, 204, 226, 156);
+ g.fillStyle = '#f05a28'; g.beginPath(); g.arc(1092, 246, 11, 0, 7); g.fill();
+ for (let k = 0; k < 5; k++) { g.fillRect(1078 + (k % 2) * 6, 270 + k * 16, 26 - k * 3, 6); }
+ g.fillStyle = '#1e2a4a'; g.beginPath(); g.moveTo(1018, 318); g.lineTo(1062, 318); g.lineTo(1056, 328); g.lineTo(1024, 328); g.closePath(); g.fill(); g.fillRect(1038, 300, 3, 18);
+ // 椅背
+ g.fillStyle = '#8a5a40'; g.fillRect(1476, 470, 14, 420);
+ // 圆桌:桌腿、桌布、花瓶、茶壶
+ g.fillStyle = '#5a4a6a'; g.fillRect(992, 790, 16, 90); g.beginPath(); g.moveTo(940, 892); g.lineTo(1000, 868); g.lineTo(1060, 892); g.lineWidth = 8; g.strokeStyle = '#5a4a6a'; g.stroke();
+ const cl = g.createLinearGradient(840, 0, 1200, 0); cl.addColorStop(0, '#f2eefc'); cl.addColorStop(0.6, '#d8d0f4'); cl.addColorStop(1, '#b8aee8');
+ g.fillStyle = cl; g.beginPath(); g.moveTo(842, 632); g.lineTo(1198, 632); g.lineTo(1206, 800); g.quadraticCurveTo(1020, 815, 836, 800); g.closePath(); g.fill();
+ g.fillStyle = '#faf6ff'; g.beginPath(); g.ellipse(1020, 632, 180, 18, 0, 0, 7); g.fill();
+ g.fillStyle = '#a8d0e8'; g.beginPath(); g.moveTo(860, 630); g.quadraticCurveTo(850, 580, 875, 560); g.lineTo(905, 560); g.quadraticCurveTo(925, 590, 912, 630); g.closePath(); g.fill();
+ for (let k = 0; k < 22; k++) { const a = k / 22 * Math.PI * 2, rr = 22 + (k * 13 % 30), sw = Math.sin(t * 2.5 + k) * 3; g.fillStyle = ['#f06a8a', '#ffffff', '#c88af0', '#f8c040', '#ff9ab0'][k % 5]; g.beginPath(); g.arc(888 + Math.cos(a) * rr + sw, 525 + Math.sin(a) * rr * 0.8, 9, 0, 7); g.fill(); }
+ g.fillStyle = '#5a9a50'; for (let k = 0; k < 6; k++) { g.beginPath(); g.ellipse(870 + k * 8, 556, 5, 14, -0.6 + k * 0.25, 0, 7); g.fill(); }
+ g.fillStyle = '#f4f4fc'; g.beginPath(); g.moveTo(962, 630); g.lineTo(966, 578); g.quadraticCurveTo(992, 566, 1016, 578); g.lineTo(1020, 630); g.closePath(); g.fill(); g.fillStyle = '#7a8ac8'; g.fillRect(964, 600, 54, 8);
+ g.fillStyle = '#c89878'; g.beginPath(); g.ellipse(991, 574, 24, 7, 0, 0, 7); g.fill();
+ // 右侧盆栽:一大团绿+粉花,叶团随风摆
+ const sw = Math.sin(t * 2.8) * 24;
+ g.fillStyle = '#4fa050'; g.beginPath(); g.moveTo(1560, 780); g.bezierCurveTo(1500 + sw * 0.5, 560, 1600 + sw, 330, 1710 + sw, 300); g.bezierCurveTo(1830 + sw, 330, 1930 + sw * 0.5, 560, 1880, 780); g.closePath(); g.fill();
+ g.fillStyle = '#8acc60'; g.beginPath(); g.ellipse(1680 + sw, 480, 90, 140, -0.3, 0, 7); g.fill();
+ for (let k = 0; k < 18; k++) { const x = 1590 + (k * 71 % 270) + sw * (1 - (k * 37 % 400) / 500), y = 380 + (k * 53 % 380); g.fillStyle = k % 3 ? '#f070a8' : '#ffd0e4'; g.beginPath(); g.arc(x, y, 9, 0, 7); g.fill(); }
+ g.fillStyle = '#f2f4fc'; g.beginPath(); g.moveTo(1650, 780); g.lineTo(1786, 780); g.lineTo(1770, 900); g.lineTo(1666, 900); g.closePath(); g.fill();
+ g.fillStyle = '#4a6ad0'; for (let k = 0; k < 6; k++) g.fillRect(1664 + k * 20, 806 + (k % 2) * 30, 12, 20);
+ // 地面阴影(猫、桌、少女)
+ g.fillStyle = 'rgba(150,100,170,.5)'; g.beginPath(); g.ellipse(540, 905, 150, 18, 0, 0, 7); g.fill(); g.beginPath(); g.ellipse(1010, 892, 150, 14, 0, 0, 7); g.fill(); g.beginPath(); g.ellipse(1300, 930, 210, 18, 0, 0, 7); g.fill();
+ }
+ const inWin = (x, y) => x > WX0 && x < WX1 && y > WY0 && y < WY1;
+ const angle = (x, y, t) => {
+ if (x > 945 && x < 1182 && y > 200 && y < 365) return 0.03 * Math.sin(y * 0.3); // 《日出》:横向水波笔
+ if (inWin(x, y)) return y < 300 ? 0.05 * Math.sin(x * 0.05) : -0.5 + 0.6 * P.noise(x * 0.03, y * 0.03) + 0.22 * Math.sin(t * 3.2 + x * 0.02); // 花草的笔随风轻转
+ if (x > 1520 && y < 790 && y > 280) return Math.atan2(y - 800, x - 1715) + 0.3 * P.noise(x * 0.02, y * 0.02) + 0.12 * Math.sin(t * 1.9); // 盆栽:从盆口放射
+ if (y > 780) return 0.12 * P.noise(x * 0.004, y * 0.01) - 0.05;
+ if ((x > 280 && x < 360) || (x > 805 && x < 890)) return -Math.PI / 2 + 0.15 * P.noise(x * 0.02, y * 0.01);
+ if (x > 830 && x < 1210 && y > 620 && y < 810) return -Math.PI / 2 + 0.2;
+ const sunny = x > 1000 && y < 500;
+ return (sunny ? -0.95 : -0.55) + 0.55 * P.noise(x * 0.006, y * 0.006 + 5); // 墙:向右上斜,莫奈式短促
+ };
+ const SW = {
+ wall: P.swatch(['#f3c6d2', '#e8b6dc', '#f6dcc0', '#d8c0ec', '#fbe8b0', '#f0a8c0', '#c8b8f0', '#fff2d8', '#e8c8f0'], 0.35),
+ sunny: P.swatch(['#fff0b0', '#fbe08a', '#ffe8c8', '#f8d0d8', '#fff8e0', '#f0c0d8', '#e8d0f8'], 0.3),
+ floor: P.swatch(['#e8a090', '#d88aa0', '#f0b890', '#c890b8', '#f6c8a0', '#b0a0d8', '#e89880'], 0.4),
+ sky: P.swatch(['#8ab4e8', '#a8c8f0', '#f0f4ff', '#7aa0e0', '#c0d8f8'], 0.4),
+ green: P.swatch(['#5aa84a', '#8ac860', '#3a8a4a', '#b8d870', '#2f7a50', '#a0e080'], 0.4),
+ lav: P.swatch(['#b8b0f0', '#d0c8f8', '#9890e0', '#e8e0ff', '#ffffff'], 0.35),
+ cloth: P.swatch(['#ece8fa', '#b8b0ec', '#f8f4ff', '#a49ce0', '#fff8f0', '#9a96d8'], 0.45),
+ };
+ const palette = (x, y, col, r) => {
+ if (inWin(x, y)) { const red = col[0] > 180 && col[1] < 90; if (red || (x < 600 && y > 440 && y < 520)) return null; return y < 300 && col[2] > col[1] ? SW.sky(col, r) : (col[1] > col[0] ? SW.green(col, r) : null); }
+ if (x > 935 && x < 1192 && y > 188 && y < 376) return null; // 墙上的画保留
+ if (x > 1520 && y > 290 && y < 785) return col[1] > col[0] ? SW.green(col, r) : null;
+ if (x > 1640 && y >= 780 && y < 905) return null;
+ if (x > 835 && x < 935 && y > 490 && y < 640) return null; // 花瓶花束
+ if (col[0] > 240 && col[1] > 236 && col[2] > 225 && x > 330 && x < 830 && y > 115 && y < 585) return P.mix([255, 252, 246], col, 0.3); // 白窗框
+ if ((x > 280 && x < 360 || x > 800 && x < 890) && y > 90 && y < 625) return SW.lav(col, r);
+ if (x > 830 && x < 1212 && y > 612 && y < 815) return SW.cloth(col, r);
+ if (y > 780) return SW.floor(col, r);
+ if (x > 1000 && y < 520) return SW.sunny(col, r);
+ return SW.wall(col, r);
+ };
+
+ // 阳光斑:每个斑块是一簇亮黄白短笔,强度按自己的相位明灭,位置缓慢漂移
+ const SPOTS = (() => { const r = U.rng(5), o = []; for (let i = 0; i < 34; i++) { const onTable = i < 7; o.push({ x: onTable ? 880 + r() * 300 : 380 + r() * 1150, y: onTable ? 632 + r() * 10 : 830 + r() * 220, rx: onTable ? 50 + r() * 50 : 70 + r() * 110, ry: onTable ? 7 : 12 + r() * 18, ph: r() * 7, sp: 5 + r() * 6, seed: i }); } return o; })();
+ function sunSpots(c, t) {
+ c.save(); c.lineCap = 'round';
+ for (const s of SPOTS) {
+ const k = 0.5 + 0.5 * Math.sin(t * s.sp + s.ph) * Math.sin(t * s.sp * 0.53 + s.ph * 2), a = clamp(k * 1.3 - 0.15);
+ if (a <= 0.02) continue;
+ const r = U.rng(s.seed * 31), dx = Math.sin(t * 2.6 + s.ph) * 44, dy = Math.cos(t * 2.0 + s.ph) * 8; // 种子固定:斑块里每一笔不换位置,只整体漂移+明灭
+ for (let i = 0; i < 40; i++) { const u = r() * 2 - 1, v = r() * 2 - 1; if (u * u + v * v > 1) continue;
+ const x = s.x + dx + u * s.rx, y = s.y + dy + v * s.ry, L = 14 + r() * 16;
+ c.strokeStyle = `rgba(255,${244 + r() * 11 | 0},${180 + r() * 50 | 0},${0.95 * a})`; c.lineWidth = 8 + r() * 5;
+ c.beginPath(); c.moveTo(x - L / 2, y + r() * 2); c.lineTo(x + L / 2, y - r() * 3); c.stroke(); }
+ }
+ c.restore();
+ }
+ // 斜射光线中的亮点(右上墙面)
+ function wallGlints(c, t) {
+ c.save(); c.globalCompositeOperation = 'screen'; c.lineCap = 'round'; const r = U.rng(900);
+ for (let i = 0; i < 60; i++) { const x = 1050 + r() * 800, y = 20 + r() * 450, a = Math.max(0, Math.sin(t * 5 + i)); if (a < 0.3) continue;
+ c.strokeStyle = `rgba(255,248,200,${0.5 * a})`; c.lineWidth = 6; c.beginPath(); c.moveTo(x, y); c.lineTo(x + 14, y - 18); c.stroke(); }
+ c.restore();
+ }
+
+ const girlPal = { skin: '#f8d8c8', hair: '#f0cc6a', dress: '#f6f4fc', sleeve: '#f6f4fc', cuff: '#f6f4fc', hat: '#f0d890', hatBand: '#4a6ad8', fold: '#c8c0ec', cheek: 'rgba(240,130,130,.5)', lip: '#e0606a', iris: '#4a70c0', cupBody: '#f4f4fc', cupRim: '#b07850', shoe: '#c8b8e8', line: '#d6a84e', lw: 0 };
+ const catPal = { orange: '#f09a40', white: '#fcf4e8', stripe: '#d0702a', eye: '#78c060', line: '#b0602a', whisker: 'rgba(255,255,255,.7)', lw: 0 };
+ function girlExtras(g, G, t) {
+ // 长卷发(背后)
+ const n = G.A.nape, sw = Math.sin(t * 2.3) * 3;
+ g.fillStyle = '#ecc460'; g.beginPath(); g.moveTo(n[0] - 20, n[1] - 60); g.bezierCurveTo(n[0] + 60, n[1] - 40, n[0] + 70 + sw, n[1] + 80, n[0] + 66 + sw, n[1] + 170); g.bezierCurveTo(n[0] + 40, n[1] + 190, n[0] + 20, n[1] + 120, n[0] - 10, n[1] + 40); g.closePath(); g.fill();
+ }
+ function girlTop(g, G, t) {
+ // 蓝腰带+飘带、帽上小花、帽带飘动
+ const w = G.A.waist; g.fillStyle = '#4a6ad8'; g.beginPath(); g.moveTo(w[0] - 70, w[1] - 20); g.lineTo(w[0] + 72, w[1] - 22); g.lineTo(w[0] + 72, w[1] + 2); g.lineTo(w[0] - 64, w[1] + 4); g.closePath(); g.fill();
+ const fl = Math.sin(t * 6) * 6; g.beginPath(); g.moveTo(w[0] + 66, w[1] - 10); g.quadraticCurveTo(w[0] + 100 + fl, w[1] + 60, w[0] + 86 + fl, w[1] + 140); g.lineTo(w[0] + 72 + fl, w[1] + 136); g.quadraticCurveTo(w[0] + 82, w[1] + 60, w[0] + 58, w[1]); g.closePath(); g.fill();
+ if (G.bow) { const b = G.bow, rf = Math.sin(t * 7) * 8; g.fillStyle = '#4a6ad8'; g.beginPath(); g.moveTo(b[0], b[1]); g.quadraticCurveTo(b[0] + 30, b[1] + 40 + rf, b[0] + 20 + rf, b[1] + 110); g.lineTo(b[0] + 8 + rf, b[1] + 106); g.quadraticCurveTo(b[0] + 14, b[1] + 40, b[0] - 6, b[1] + 4); g.closePath(); g.fill(); }
+ const top = G.A.headTop; [['#f06a8a', -40, 2], ['#ffffff', -22, -2], ['#f8b040', -4, 4], ['#c88af0', 14, 0], ['#f06a8a', 30, 6]].forEach(([col, dx, dy]) => { g.fillStyle = col; g.beginPath(); g.arc(top[0] + dx + 20, top[1] + dy - 2, 8, 0, 7); g.fill(); });
+ }
+
+ function charStrokes(g, src, t) {
+ const x0 = 330, y0 = 190, w = 1200, h = 780, cell = 7, sd = src.getContext('2d', { willReadFrequently: true }).getImageData(x0, y0, w, h).data;
+ g.save(); g.globalCompositeOperation = 'source-atop'; g.lineCap = 'round'; g.lineWidth = 5;
+ for (let j = 0; j < h / cell; j++) for (let i = 0; i < w / cell; i++) {
+ const hx = U.hash(i, j), hy = U.hash(j + 7919, i), px = (i + hx) * cell, py = (j + hy) * cell, k = ((py | 0) * w + (px | 0)) * 4;
+ if (sd[k + 3] < 200) continue;
+ const X = x0 + px, Y = y0 + py, h3 = U.hash(i + 31, j + 17), h4 = U.hash(i + 97, j + 53);
+ let col = [sd[k], sd[k + 1], sd[k + 2]];
+ if (X > 1080 && col[0] > 235 && col[1] > 235 && col[2] > 240) col = P.mix([[255, 255, 255], [220, 214, 250], [250, 240, 220], [200, 196, 240]][(h3 * 4) | 0], col, 0.4);
+ else col = [col[0] + (h3 - .5) * 30, col[1] + (h4 - .5) * 30, col[2] + (hx - .5) * 30];
+ const a = X < 760 ? Math.atan2(Y - 790, X - 545) + Math.PI / 2 * 0.8 : (Y < 330 ? -0.2 : -Math.PI / 2 + 0.25 * Math.sin(Y * 0.03)), L = 13 * (0.7 + h4 * 0.6);
+ g.strokeStyle = P.rgb(col); g.beginPath(); g.moveTo(X - Math.cos(a) * L / 2, Y - Math.sin(a) * L / 2); g.lineTo(X + Math.cos(a) * L / 2, Y + Math.sin(a) * L / 2); g.stroke();
+ }
+ g.restore();
+ }
+ // 让笔触真正「不动」:P.strokes 的随机数是一条顺序流,palette 返回 null 时会多吃 3 个数(jitter),
+ // 而 null 与否取决于底稿颜色(罂粟一摇、盆栽一摆就变)→ 后面所有笔整体重洗。这里每格只吃 1 个数、永不返回 null。
+ const stable = (pal) => (x, y, col, r) => { const u = r(), rr = U.rng((u * 4294967296) >>> 0); return pal(x, y, col, rr) || P.jitter(col, rr, 24); };
+ return {
+ draw(c, lt, t) {
+ const ch = P.choreo(lt, t);
+ const b = P.scratch('impBase'), bg = b.getContext('2d', { willReadFrequently: true });
+ base(bg, t);
+ c.fillStyle = '#f2e6ee'; c.fillRect(0, 0, W, H); // 浅色画布底,笔触间露出
+ const fine = (x, y) => inWin(x, y) || (x > 945 && x < 1182 && y > 200 && y < 365);
+ P.strokes(c, b, { cell: 11, len: 20, width: 7, angle, seed: 12, t, boil: 0, outline: 0, palette: stable(palette), mask: (x, y) => !fine(x, y) });
+ P.strokes(c, b, { cell: 6, len: 11, width: 4.5, angle, seed: 13, t, boil: 0, outline: 0, palette: stable(palette), mask: fine }); // 窗景与墙上小画用更细的笔
+ sunSpots(c, t); wallGlints(c, t);
+ // 角色
+ const L = P.scratch('impChars'), lg = L.getContext('2d', { willReadFrequently: true }); lg.clearRect(0, 0, W, H);
+ const K = RIG.cat({ tail: ch.tail * 2.2, blink: ch.blink, breathe: ch.breathe * 3, look: Math.sin(t * 3) * 2 }); // 猫在阳光里扭头、甩尾
+ const G = RIG.girl({ cup: ch.cup, sip: ch.sip, hat: 'straw', hair: 'long', breathe: ch.breathe });
+ RIG.drawCat(lg, K, catPal);
+ girlExtras(lg, G, t);
+ RIG.drawGirl(lg, G, { ...girlPal, mode: 'fill' });
+ girlTop(lg, G, t);
+ // 角色笔触:自写循环,每格随机数用 U.hash(格号) —— 与其它格是否落笔无关,端杯一动也只有手臂那几笔变,不会整层重洗
+ charStrokes(lg, L, t);
+ c.drawImage(L, 0, 0);
+ // 五官与少量结构线:淡紫色细线(印象派不勾轮廓,只点出眼口)
+ c.save(); c.strokeStyle = 'rgba(110,90,170,.75)'; c.lineWidth = 2.4; c.lineCap = 'round';
+ if (ch.blink || ch.cup > 0.85) { c.beginPath(); c.arc(G.eye.x, G.eye.y - 2, 6, 0.3, Math.PI - 0.3); c.stroke(); }
+ else { c.fillStyle = '#4a60b0'; c.beginPath(); c.arc(G.eye.x - 1, G.eye.y + 1, 4.2, 0, 7); c.fill(); c.stroke(G.lid); }
+ c.lineWidth = 1.8; c.stroke(G.brow);
+ c.fillStyle = '#e05a6a'; c.beginPath(); c.moveTo(...G.lips[0]); c.lineTo(...G.lips[1]); c.lineTo(...G.lips[2]); c.closePath(); c.fill();
+ K.eyes.forEach(e => { if (K.blink) { c.beginPath(); c.arc(e.x, e.y, 8, 0.2, Math.PI - 0.2); c.stroke(); } else { c.fillStyle = '#7ac060'; c.beginPath(); c.arc(e.x, e.y, 8, 0, 7); c.fill(); c.fillStyle = '#3a3050'; c.beginPath(); c.ellipse(e.x + 2, e.y, 2.6, 6.5, 0, 0, 7); c.fill(); } });
+ c.fillStyle = '#e07a80'; c.beginPath(); c.arc(K.nose[0], K.nose[1], 5, 0, 7); c.fill();
+ c.lineWidth = 1.3; c.strokeStyle = 'rgba(255,255,255,.8)'; K.whiskers.forEach(w => { c.beginPath(); c.moveTo(...w[0]); c.lineTo(...w[1]); c.stroke(); });
+ c.restore();
+ // 猫毛在阳光里闪亮:背上的毛尖亮笔明灭
+ c.save(); c.globalCompositeOperation = 'screen'; c.lineCap = 'round';
+ const catBody = RIG.smooth(K.bodyPts);
+ for (let i = 0; i < 60; i++) { const h = U.hash(i, 77), x = 430 + U.hash(i, 3) * 230, y = 570 + U.hash(i, 5) * 200, a = Math.max(0, Math.sin(t * 7 + h * 30));
+ if (a < 0.35 || !(c.isPointInPath(catBody, x, y) || c.isPointInPath(K.head, x, y)) || x > 560 + (y - 560) * 0.1) continue; // 只亮在猫身上、受光的左半
+ c.strokeStyle = `rgba(255,250,210,${0.9 * a})`; c.lineWidth = 3.5; c.beginPath(); c.moveTo(x, y); c.lineTo(x + 6, y + 9); c.stroke(); }
+ c.restore();
+ P.steam(c, t, G.cup.x, G.cup.y - 8, { h: 60, n: 2, color: 'rgba(255,255,255,.85)', width: 5, spread: 14, wobble: 9 });
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/09_postimp.js b/scripts/engine/scenes/09_postimp.js
new file mode 100644
index 0000000..483ecbf
--- /dev/null
+++ b/scripts/engine/scenes/09_postimp.js
@@ -0,0 +1,183 @@
+// 1889 后印象派(梵高《阿尔的卧室》+《星月夜》)——纯代码。质量标杆:其他时代照这个结构写。
+// 管线:①平涂底稿 → ②流场笔触重画(墙竖、地板沿透视、星空沿漩涡、灯晕沿圆周,8fps 沸腾)
+// → ③角色平涂+细笔触 → ④角色轮廓与五官补线 → ⑤会动的高光(星星、灯晕、热气)
+SCENES['09_postimp'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp } = U, P = PAINT;
+ const C = {
+ wall: '#5b7bd3', wall2: '#4462bd', sky: '#1d2c7c', sky2: '#3a5bc0', swirl: '#8fb3ec', star: '#f6d84a', halo: '#fbeea0',
+ frame: '#2f8f58', frameHi: '#6fd08a', floor: '#b5553b', floor2: '#8a3a2c', wood: '#e3ad38', wood2: '#b57d1c',
+ bed: '#d9472f', line: '#1c2458', cypress: '#1f4a2c', village: '#1a2160',
+ };
+ const VP = [960, 330]; // 地板透视消失点
+ const swirls = [[520, 300, 90], [660, 240, 60], [450, 420, 55], [700, 400, 45]];
+ const stars = [[410, 180, 16], [520, 170, 12], [610, 190, 14], [745, 200, 24], [560, 260, 10], [700, 300, 11], [470, 300, 9]];
+
+ function base(g, t) {
+ // 墙
+ const wg = g.createLinearGradient(0, 0, 0, 720); wg.addColorStop(0, C.wall); wg.addColorStop(1, C.wall2);
+ g.fillStyle = wg; g.fillRect(0, 0, W, 720);
+ // 地板 + 木板缝(汇向消失点)
+ g.fillStyle = C.floor; g.fillRect(0, 700, W, H - 700);
+ g.strokeStyle = C.floor2; g.lineWidth = 6;
+ for (let i = -14; i <= 14; i++) { g.beginPath(); g.moveTo(VP[0] + i * 60, 700); g.lineTo(VP[0] + i * 230, H); g.stroke(); }
+ g.fillStyle = '#3a2a6a'; g.fillRect(0, 696, W, 10);
+ // 灯晕底色(大面积,交给笔触)
+ { const hg = g.createRadialGradient(1000, 180, 10, 1000, 180, 105); hg.addColorStop(0, '#fff7c8'); hg.addColorStop(0.55, '#f4d65a'); hg.addColorStop(1, 'rgba(120,150,220,0)'); g.fillStyle = hg; g.beginPath(); g.arc(1000, 180, 105, 0, Math.PI * 2); g.fill(); }
+ // 窗:星空
+ g.save(); g.beginPath(); g.rect(370, 140, 420, 400); g.clip();
+ const sg = g.createLinearGradient(0, 140, 0, 540); sg.addColorStop(0, C.sky); sg.addColorStop(1, C.sky2); g.fillStyle = sg; g.fillRect(370, 140, 420, 400);
+ // 漩涡:螺旋色带,随时间旋转
+ g.lineCap = 'round';
+ swirls.forEach(([x, y, r], k) => { for (let ring = 0; ring < 3; ring++) { g.strokeStyle = ring % 2 ? C.swirl : '#5a82d6'; g.lineWidth = 14 - ring * 3; g.beginPath();
+ for (let a = 0; a < Math.PI * 3; a += 0.15) { const rr = r * (0.25 + a / (Math.PI * 3)) * (1 - ring * 0.12), aa = a + t * (0.9 + k * 0.2) * (k % 2 ? -1 : 1); const px = x + Math.cos(aa) * rr, py = y + Math.sin(aa) * rr * 0.8; a ? g.lineTo(px, py) : g.moveTo(px, py); } g.stroke(); } });
+ // 月亮
+ g.fillStyle = C.star; g.beginPath(); g.arc(745, 200, 30, 0, Math.PI * 2); g.fill(); g.fillStyle = C.sky; g.beginPath(); g.arc(732, 192, 24, 0, Math.PI * 2); g.fill();
+ // 柏树(火焰形)与村庄
+ g.fillStyle = C.cypress; g.beginPath(); g.moveTo(400, 545); g.bezierCurveTo(372, 430, 420, 330, 425, 200); g.bezierCurveTo(445, 320, 470, 430, 452, 545); g.closePath(); g.fill();
+ g.fillStyle = C.village; g.beginPath(); g.moveTo(370, 545); [[420, 500], [470, 505], [500, 480], [540, 500], [590, 470], [610, 440], [625, 470], [680, 495], [730, 485], [790, 500], [790, 545]].forEach(p => g.lineTo(...p)); g.closePath(); g.fill();
+ g.fillStyle = '#f2c94c'; [[480, 512], [520, 520], [560, 508], [650, 512], [700, 520], [740, 510]].forEach(([x, y]) => g.fillRect(x, y, 8, 8));
+ g.restore();
+ // 窗框(绿)+ 中梃 + 窗台
+ g.lineWidth = 26; g.strokeStyle = C.frame; g.strokeRect(357, 127, 446, 426);
+ g.lineWidth = 6; g.strokeStyle = C.frameHi; g.strokeRect(366, 136, 428, 408);
+ g.fillStyle = C.frame; g.fillRect(568, 140, 20, 400);
+ g.fillStyle = C.frameHi; g.fillRect(330, 552, 500, 22); g.fillStyle = C.frame; g.fillRect(330, 570, 500, 14);
+ // 床(右侧)
+ g.fillStyle = C.wood; g.fillRect(1610, 560, 330, 420); g.fillStyle = C.wood2; g.fillRect(1640, 640, 290, 300);
+ g.fillStyle = C.bed; g.beginPath(); g.moveTo(1620, 600); g.quadraticCurveTo(1760, 500, 1940, 520); g.lineTo(1940, 640); g.quadraticCurveTo(1780, 620, 1620, 660); g.closePath(); g.fill();
+ g.fillStyle = C.wood; g.fillRect(1598, 520, 26, 470); g.beginPath(); g.arc(1611, 515, 18, 0, Math.PI * 2); g.fill();
+ }
+ function props(g, t) {
+ // 墙上两幅小画
+ [[1590, 250, 100, 120, '#d9733a', '#66a35a'], [1730, 250, 100, 120, '#e8d36a', '#4f7fc9']].forEach(([x, y, w, h, a, b]) => {
+ g.fillStyle = '#d8a83a'; g.fillRect(x - 10, y - 10, w + 20, h + 20); g.fillStyle = b; g.fillRect(x, y, w, h); g.fillStyle = a; g.beginPath(); g.ellipse(x + w / 2, y + h * 0.55, w * 0.28, h * 0.25, 0, 0, Math.PI * 2); g.fill(); });
+ // 椅子(梯背,在少女后面)
+ g.fillStyle = C.wood; [[1432, 470, 16, 440], [1478, 480, 16, 430]].forEach(r => g.fillRect(...r));
+ for (let k = 0; k < 4; k++) g.fillRect(1436, 510 + k * 55, 56, 10);
+ g.fillRect(1250, 742, 250, 16); g.fillRect(1262, 750, 14, 160);
+ // 桌子
+ g.fillStyle = C.wood; g.fillRect(810, 618, 400, 32); g.fillStyle = C.wood2; g.fillRect(830, 650, 360, 52);
+ g.fillStyle = '#e9c46a'; g.fillRect(960, 664, 90, 22); g.fillStyle = '#6b4a1a'; g.beginPath(); g.arc(1005, 675, 5, 0, Math.PI * 2); g.fill();
+ g.fillStyle = C.wood; g.fillRect(842, 700, 22, 205); g.fillRect(1160, 700, 22, 205); g.fillRect(842, 860, 340, 12);
+ // 花瓶+向日葵
+ g.fillStyle = '#e8c255'; g.beginPath(); g.moveTo(852, 618); g.quadraticCurveTo(838, 575, 862, 548); g.lineTo(898, 548); g.quadraticCurveTo(920, 575, 905, 618); g.closePath(); g.fill();
+ g.strokeStyle = '#4d8a3a'; g.lineWidth = 6; [[870, 548, 842, 490], [880, 548, 890, 462], [890, 548, 930, 502], [875, 548, 868, 528]].forEach(([a, b, c2, d]) => { g.beginPath(); g.moveTo(a, b); g.lineTo(c2, d); g.stroke(); });
+ [[842, 490, 26], [890, 462, 28], [930, 502, 24], [866, 526, 18]].forEach(([x, y, r], k) => { const sp = Math.sin(t * 3 + k) * 0.08;
+ g.fillStyle = '#f2b51c'; for (let i = 0; i < 12; i++) { const a = i / 12 * Math.PI * 2 + sp; g.beginPath(); g.ellipse(x + Math.cos(a) * r * 0.8, y + Math.sin(a) * r * 0.8, r * 0.45, r * 0.18, a, 0, Math.PI * 2); g.fill(); }
+ g.fillStyle = '#8a4b14'; g.beginPath(); g.arc(x, y, r * 0.45, 0, Math.PI * 2); g.fill(); });
+ // 吊灯
+ g.strokeStyle = '#3a2a2a'; g.lineWidth = 4; g.beginPath(); g.moveTo(1000, 0); g.lineTo(1000, 150); g.stroke();
+ g.fillStyle = '#f1c232'; g.beginPath(); g.moveTo(968, 176); g.quadraticCurveTo(1000, 132, 1032, 176); g.closePath(); g.fill();
+
+ g.fillStyle = '#fff6c0'; g.beginPath(); g.arc(1000, 182, 12, 0, Math.PI * 2); g.fill();
+ }
+ // 笔触方向场
+ const angle = (x, y, t) => {
+ if (x > 370 && x < 790 && y > 140 && y < 540) { // 星空:沿最近漩涡的切线
+ let best = null, bd = 1e9; swirls.forEach(s => { const d = Math.hypot(x - s[0], y - s[1]) / s[2]; if (d < bd) { bd = d; best = s; } });
+ if (bd < 1.6) return Math.atan2(y - best[1], x - best[0]) + Math.PI / 2 + t * 0.3;
+ return 0.15 * Math.sin(x * 0.02 + t) ;
+ }
+ const dl = Math.hypot(x - 1000, y - 180); if (dl < 150) return Math.atan2(y - 180, x - 1000) + Math.PI / 2; // 灯晕:圆周
+ if (y > 700) return Math.atan2(y - VP[1], x - VP[0]) + 0.06 * Math.sin(t * 2 + x * 0.01); // 地板:透视线
+ if (x > 1600 && y > 520) return y < 640 ? -0.12 : -Math.PI / 2;
+ if (x > 810 && x < 1210 && y > 610 && y < 705) return 0.02;
+ return -Math.PI / 2 + 0.26 * P.noise(x * 0.008 + t * 0.5, y * 0.008 + 3 - t * 0.8); // 墙:竖向,随时间像火苗一样缓慢摇曳
+ };
+ // 区域色板:每一笔从所在区域的色组里抽色,再混一点底稿色保留明暗(梵高的「同一面墙十几种蓝」)
+ const SW = {
+ wall: P.swatch(['#7f9be6', '#5f7fd8', '#a7bbf2', '#6c6fd2', '#8ad0e6', '#c3cbf6', '#4f6cc8', '#9a8fe0'], 0.3),
+ sky: P.swatch(['#22339a', '#2f4fb8', '#5c86dc', '#8fb6ee', '#1b2a78', '#3c6bd0'], 0.45),
+ floor: P.swatch(['#c0573c', '#a8453a', '#d7774a', '#8e3b30', '#5f8f6a', '#c96a52', '#e08a5c'], 0.3),
+ wood: P.swatch(['#f2c13a', '#e0a020', '#f8d860', '#d08a18', '#b8c040'], 0.15),
+ bed: P.swatch(['#e04a32', '#c63a2a', '#f06b45', '#b83224'], 0.4),
+ green: P.swatch(['#2f9a5c', '#4fc27a', '#1f7a48', '#8be09a'], 0.35),
+ halo: P.swatch(['#fff2a0', '#f6d84a', '#ffe680', '#f0c040'], 0.3),
+ };
+ const palette = (x, y, col, r) => {
+ if (Math.hypot(x - 1000, y - 180) < 92) return SW.halo(col, r);
+ if (x > 370 && x < 790 && y > 140 && y < 540) { const L = col[0] + col[1] + col[2]; return L > 500 ? null : SW.sky(col, r); }
+ if (x > 340 && x < 830 && y > 115 && y < 590) return SW.green(col, r);
+ if (y > 706) return SW.floor(col, r);
+ if (x > 1595 && y > 600) return SW.wood(col, r);
+ if (x > 1600 && y > 505 && y <= 640) return SW.bed(col, r);
+ return SW.wall(col, r);
+ };
+ // 环境线稿:桌、椅、床、窗框、画框、花瓶的深蓝轮廓(8fps 轻微抖动)
+ function lines(c, t) {
+ const sd = P.boilSeed(t, 8); c.save(); c.strokeStyle = C.line; c.lineWidth = 4.5; c.lineJoin = 'round';
+ const R_ = (pts, closed = true) => { P.roughPath(c, pts, { amp: 2.2, seed: sd * 31 + pts.length + (pts[0][0] | 0), closed, step: 14 }); c.stroke(); };
+ R_([[344, 114], [816, 114], [816, 566], [344, 566]]); R_([[370, 140], [790, 140], [790, 540], [370, 540]]); R_([[568, 140], [588, 140], [588, 540], [568, 540]]);
+ R_([[330, 552], [830, 552], [830, 584], [330, 584]]);
+ R_([[810, 618], [1210, 618], [1210, 650], [810, 650]]); R_([[830, 650], [1190, 650], [1190, 702], [830, 702]]); R_([[960, 664], [1050, 664], [1050, 686], [960, 686]]);
+ R_([[842, 700], [864, 700], [864, 905], [842, 905]]); R_([[1160, 700], [1182, 700], [1182, 905], [1160, 905]]);
+ R_([[1432, 470], [1448, 470], [1448, 910], [1432, 910]]); R_([[1478, 480], [1494, 480], [1494, 910], [1478, 910]]);
+ for (let k = 0; k < 4; k++) R_([[1436, 510 + k * 55], [1492, 510 + k * 55], [1492, 520 + k * 55], [1436, 520 + k * 55]]);
+ R_([[1610, 560], [1940, 560], [1940, 980], [1610, 980]]); R_([[1640, 640], [1930, 640], [1930, 940], [1640, 940]]); R_([[1598, 520], [1624, 520], [1624, 990], [1598, 990]]);
+ R_([[1580, 240], [1700, 240], [1700, 380], [1580, 380]]); R_([[1720, 240], [1840, 240], [1840, 380], [1720, 380]]);
+ R_([[852, 618], [840, 580], [862, 548], [898, 548], [918, 580], [905, 618]]);
+ R_([[0, 700], [1940, 700]], false);
+ c.lineWidth = 3.5; for (let i = -12; i <= 12; i++) { if (i % 2) continue; R_([[VP[0] + i * 62 * 1.2, 704], [VP[0] + i * 240, 1080]], false); }
+ c.restore();
+ }
+ const girlPal = { skin: '#f8dcc6', hair: '#f2c552', hairLine: '#c4922c', dress: '#3a5fb4', fold: '#2a4386', apron: '#f6f1e6', hat: '#ecc860', hatBand: '#2f50a8',
+ cheek: 'rgba(240,120,110,.45)', lip: '#d0504e', iris: '#2a4d90', line: C.line, lw: 4, cupBody: '#2a50b0', cupRim: '#4a2a12' };
+ const catPal = { orange: '#ec9433', white: '#fbf1dd', stripe: '#c0621a', line: C.line, lw: 4, eye: '#7ec850' };
+
+ return {
+ draw(c, lt, t) {
+ const ch = P.choreo(lt, t);
+ const b = P.scratch('vgBase'), bg = b.getContext('2d');
+ base(bg, t);
+ c.drawImage(b, 0, 0);
+ const isWall = (x, y) => y < 700 && !(x > 340 && x < 830 && y > 110 && y < 590) && !(x > 1595 && y > 505) && Math.hypot(x - 1000, y - 180) > 125;
+ P.strokes(c, b, { cell: 10, len: 22, width: 6.5, angle, seed: 9, t, boil: 0, outline: 0.9, outlineMix: 0.45, palette, mask: (x, y) => !isWall(x, y) && (y <= 704 || (x > 1595 && y < 995)) });
+ P.strokes(c, b, { cell: 14, len: 64, width: 8, angle, seed: 19, t, boil: 0, outline: 0.8, outlineMix: 0.38, palette, mask: isWall });
+ P.strokes(c, b, { cell: 12, len: 46, width: 8, angle, seed: 29, t, boil: 0, outline: 0.85, outlineMix: 0.45, palette, mask: (x, y) => y > 704 && !(x > 1595 && y < 995) });
+ // 道具层:桌、椅、花瓶向日葵、画框、吊灯——单独画、单独上细肌理,避免被大笔触打碎
+ const Pr = P.scratch('vgProps'), pg = Pr.getContext('2d'); pg.clearRect(0, 0, W, H); props(pg, t);
+ pg.save(); pg.globalCompositeOperation = 'source-atop';
+ P.strokes(pg, Pr, { cell: 7, len: 14, width: 4.5, seed: 7, t, boil: 0, outline: 0.5, outlineMix: 0.35, jitterCol: 34, alphaMask: true,
+ angle: (x, y) => (y > 650 && y < 905 && ((x > 836 && x < 870) || (x > 1154 && x < 1188) || x > 1425)) ? -Math.PI / 2 : 0.05 });
+ pg.restore(); c.drawImage(Pr, 0, 0);
+ lines(c, t);
+ // 灯晕:一圈圈向外脉动
+ c.save(); c.globalCompositeOperation = 'lighter'; c.lineCap = 'round';
+ for (let k = 0; k < 3; k++) { const ph = ((t * 0.9 + k / 3) % 1), r = 40 + ph * 110; c.strokeStyle = `rgba(255,236,140,${0.28 * (1 - ph)})`; c.lineWidth = 18; c.setLineDash([22, 14]); c.lineDashOffset = -t * 60; c.beginPath(); c.arc(1000, 180, r, 0, Math.PI * 2); c.stroke(); }
+ c.setLineDash([]);
+ c.restore();
+ // 星星:闪烁+光圈
+ stars.forEach(([x, y, r], k) => { const tw = 0.75 + 0.35 * Math.sin(t * 5 + k * 1.7); c.fillStyle = 'rgba(251,238,160,.55)'; c.beginPath(); c.arc(x, y, r * 1.9 * tw, 0, Math.PI * 2); c.fill(); c.fillStyle = C.star; c.beginPath(); c.arc(x, y, r * 0.75 * tw, 0, Math.PI * 2); c.fill(); });
+ // 角色:平涂 → 细笔触 → 补线
+ const L = P.scratch('vgChars'), lg = L.getContext('2d'); lg.clearRect(0, 0, W, H);
+ const K = RIG.cat({ tail: ch.tail, blink: ch.blink, breathe: ch.breathe });
+ const G = RIG.girl({ cup: ch.cup, sip: ch.sip, hat: 'straw', breathe: ch.breathe });
+ RIG.drawCat(lg, K, { ...catPal, lw: 0 }); RIG.drawGirl(lg, G, { ...girlPal, mode: 'fill' });
+ lg.save(); lg.globalCompositeOperation = 'source-atop';
+ P.strokes(lg, L, { cell: 8, len: 16, width: 5, seed: 4, t, boil: 0, outline: 0, jitterCol: 22, alphaMask: true,
+ angle: (x, y) => (x < 760 ? Math.atan2(y - 760, x - 545) + Math.PI / 2 : -Math.PI / 2 + 0.3 * Math.sin(y * 0.02)) }); // 猫身体打旋(梵高式),少女竖向
+ lg.restore();
+ // 猫身上的梵高漩涡纹(原片那只「漩涡猫」)
+ lg.save(); lg.clip(K.body); lg.lineCap = 'round';
+ for (let ring = 0; ring < 7; ring++) { lg.strokeStyle = ring % 2 ? '#f7c063' : '#c96a1e'; lg.lineWidth = 7; lg.beginPath();
+ for (let a = 0; a < Math.PI * 1.7; a += 0.12) { const rr = 18 + ring * 17, aa = a + ring * 0.7 + t * 0.6; const px = 505 + Math.cos(aa) * rr, py = 805 + Math.sin(aa) * rr * 0.9; a ? lg.lineTo(px, py) : lg.moveTo(px, py); } lg.stroke(); }
+ lg.restore();
+ c.drawImage(L, 0, 0);
+ c.drawImage(RIG.visibleLines('vgCat', (g, lc) => RIG.drawCat(g, K, { ...catPal, line: lc, whisker: lc }), C.line, [340, 500, 740, 940]), 0, 0);
+ c.drawImage(RIG.visibleLines('vgGirl', (g, lc) => RIG.drawGirl(g, G, { ...girlPal, line: lc }), C.line, [1060, 200, 1520, 950]), 0, 0);
+ // 线稿层会把帽檐后半圈画穿到头发上:线稿之后把帽子整顶重新盖一遍(填色+草编短笔+外轮廓)
+ c.save(); c.lineJoin = 'round'; c.lineCap = 'round';
+ [G.brim, G.crown].forEach(p => { c.fillStyle = girlPal.hat; c.fill(p); });
+ c.save(); c.clip(G.brim); c.clip(G.brim);
+ const hr = U.rng(55); c.lineWidth = 3.5;
+ for (let i = 0; i < 70; i++) { const x = G.A.headTop[0] - 140 + hr() * 280, y = G.A.headTop[1] - 40 + hr() * 70; c.strokeStyle = hr() < .5 ? '#f6d977' : '#c99a2e'; c.beginPath(); c.moveTo(x, y); c.lineTo(x + 16, y + 2); c.stroke(); }
+ c.restore();
+ c.save(); c.clip(G.crown); for (let i = 0; i < 30; i++) { const x = G.A.headTop[0] - 60 + hr() * 130, y = G.A.headTop[1] - 50 + hr() * 50; c.strokeStyle = hr() < .5 ? '#f6d977' : '#c99a2e'; c.beginPath(); c.moveTo(x, y); c.lineTo(x + 3, y + 14); c.stroke(); } c.restore();
+ c.fillStyle = girlPal.hatBand; c.fill(G.band);
+ c.strokeStyle = C.line; c.lineWidth = 4; c.stroke(G.brim); c.stroke(G.crown);
+ c.restore();
+ // 热气(从杯口卷曲上升)
+ P.steam(c, t, G.cup.x, G.cup.y - 6, { h: 70, n: 2, color: 'rgba(240,244,255,.85)', width: 4, spread: 14, wobble: 9 });
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/10_nouveau.js b/scripts/engine/scenes/10_nouveau.js
new file mode 100644
index 0000000..0cff9a9
--- /dev/null
+++ b/scripts/engine/scenes/10_nouveau.js
@@ -0,0 +1,334 @@
+// 1896 新艺术运动(慕夏海报)——纯代码。
+// 管线:①缓存底版(灰绿渐变+圆点花纹+金框+马赛克地砖带+绿横幅+标题)
+// → ②会动的母题(彩色玻璃拱窗里太阳升起、铅条光芒转动;罂粟/百合摇摆;光环转动)
+// → ③角色平涂进离屏层 → 整体剪影往右下错位填深棕 = 慕夏式「外轮廓粗、内线细」
+// → ④细内线 + 可变线宽的金色长卷发、花环、S 形装饰热气
+SCENES['10_nouveau'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp } = U, P = PAINT;
+ const C = {
+ paper: '#efe6cf', gold: '#c9a24a', goldD: '#9c7a2e', line: '#4e3320', green: '#b9cba0', green2: '#cfd3a6', peach: '#ecc9a2',
+ dot: 'rgba(120,140,100,.38)', banner: '#8fac80', bannerD: '#6f8f63', cream: '#f6eedb',
+ poppy: '#d9706a', poppyD: '#b4504b', stem: '#5f8a58', leaf: '#8fb38a', leafD: '#5f8a58', lily: '#f7f2e6',
+ iron: '#3d7763', ironHi: '#5f9a82', wood: '#7a5234',
+ };
+ const TAU = Math.PI * 2;
+
+ // ---------- 小工具 ----------
+ // Catmull-Rom 加密成点列
+ const dense = (pts, n = 10) => {
+ const o = [], N = pts.length; const g = i => pts[Math.max(0, Math.min(N - 1, i))];
+ for (let i = 0; i < N - 1; i++) { const p0 = g(i - 1), p1 = g(i), p2 = g(i + 1), p3 = g(i + 2);
+ for (let k = 0; k < n; k++) { const t = k / n, t2 = t * t, t3 = t2 * t;
+ o.push([0.5 * ((2 * p1[0]) + (-p0[0] + p2[0]) * t + (2 * p0[0] - 5 * p1[0] + 4 * p2[0] - p3[0]) * t2 + (-p0[0] + 3 * p1[0] - 3 * p2[0] + p3[0]) * t3),
+ 0.5 * ((2 * p1[1]) + (-p0[1] + p2[1]) * t + (2 * p0[1] - 5 * p1[1] + 4 * p2[1] - p3[1]) * t2 + (-p0[1] + 3 * p1[1] - 3 * p2[1] + p3[1]) * t3)]); } }
+ o.push(pts[N - 1]); return o;
+ };
+ // 可变线宽路径:沿点列两侧偏移 w(q)/2,返回闭合 Path2D(慕夏的「粗细变化的勾线」靠它)
+ const ribbon = (pts, wf) => {
+ const L = [], R = [], n = pts.length;
+ for (let i = 0; i < n; i++) {
+ const a = pts[Math.max(0, i - 1)], b = pts[Math.min(n - 1, i + 1)];
+ let dx = b[0] - a[0], dy = b[1] - a[1]; const d = Math.hypot(dx, dy) || 1; dx /= d; dy /= d;
+ const w = wf(i / (n - 1)) / 2; L.push([pts[i][0] - dy * w, pts[i][1] + dx * w]); R.push([pts[i][0] + dy * w, pts[i][1] - dx * w]);
+ }
+ const p = new Path2D(); L.forEach((q, i) => i ? p.lineTo(q[0], q[1]) : p.moveTo(q[0], q[1])); for (let i = n - 1; i >= 0; i--) p.lineTo(R[i][0], R[i][1]); p.closePath(); return p;
+ };
+ const taperW = (w0, w1, mid = 1) => q => lerp(w0, w1, q) * (0.55 + 0.45 * Math.sin(Math.PI * Math.min(1, q * 1.15)) * mid + (1 - mid) * 0.45);
+ const swellW = (wmax, wend = 1.2) => q => wend + (wmax - wend) * Math.sin(Math.PI * q); // 两头尖中间粗
+ // 螺旋收尾的点列(新艺术的「鞭线」卷曲)
+ const spiral = (cx, cy, r0, a0, turns, dir = 1, n = 28) => { const o = []; for (let i = 0; i <= n; i++) { const q = i / n, a = a0 + dir * q * turns * TAU, r = r0 * (1 - q * 0.85); o.push([cx + Math.cos(a) * r, cy + Math.sin(a) * r]); } return o; };
+ const inkLine = (c, pts, wmax, col = C.line, wend = 1) => { c.fillStyle = col; c.fill(ribbon(dense(pts, 8), swellW(wmax, wend))); };
+
+ // ---------- ① 底版(缓存) ----------
+ const bg = () => P.cached('nv_bg', W, H, (g) => {
+ g.fillStyle = C.paper; g.fillRect(0, 0, W, H);
+ const gr = g.createLinearGradient(0, 30, 0, 905); gr.addColorStop(0, C.green); gr.addColorStop(0.55, C.green2); gr.addColorStop(1, C.peach);
+ g.fillStyle = gr; g.fillRect(34, 32, W - 68, 875);
+ // 圆点花纹:环+心点,菱形交错
+ g.strokeStyle = C.dot; g.fillStyle = C.dot; g.lineWidth = 1.6;
+ for (let j = 0, y = 62; y < 900; y += 54, j++) for (let x = 64 + (j % 2) * 31; x < 1880; x += 62) {
+ g.beginPath(); g.arc(x, y, 10, 0, TAU); g.stroke(); g.beginPath(); g.arc(x, y, 2.6, 0, TAU); g.fill(); }
+ // 轻微的石版印刷斑驳(小噪声图放大)
+ const nz = P.canvas(240, 135), ng = nz.getContext('2d'), im = ng.createImageData(240, 135);
+ for (let y = 0; y < 135; y++) for (let x = 0; x < 240; x++) { const v = P.fbm(x * 0.05, y * 0.05, 4), i = (y * 240 + x) * 4; im.data[i] = 90; im.data[i + 1] = 70; im.data[i + 2] = 40; im.data[i + 3] = clamp(v * 1.4 + 0.15) * 60; }
+ ng.putImageData(im, 0, 0); g.globalAlpha = 0.5; g.drawImage(nz, 0, 0, W, H); g.globalAlpha = 1;
+ // 马赛克地砖带
+ const tiles = ['#f1ead6', '#8fb08a', '#c9a24a', '#f1ead6', '#a9c39a', '#d98c8c', '#c9a24a', '#f1ead6', '#6f9a80'];
+ g.fillStyle = C.line; g.fillRect(34, 898, W - 68, 34);
+ for (let k = 0, x = 38; x < 1880; x += 24, k++) { g.fillStyle = tiles[(k * 7 + (k >> 2)) % tiles.length]; g.fillRect(x, 903, 20, 24); }
+ // 绿横幅
+ g.fillStyle = C.banner; g.fillRect(34, 934, W - 68, 114);
+ g.fillStyle = C.line; g.fillRect(34, 932, W - 68, 3); g.fillRect(34, 1046, W - 68, 3);
+ // 横幅两侧的鞭线卷草(左右镜像)
+ const whip = (s) => { g.save(); if (s < 0) { g.translate(W, 0); g.scale(-1, 1); }
+ g.fillStyle = C.cream; g.fill(ribbon(dense([[100, 960], [112, 948], [128, 958], [200, 985], [300, 990], [400, 984]], 10), swellW(7, 1)));
+ g.fillStyle = C.gold; g.fill(ribbon(dense([[130, 1010], [150, 1022], [180, 1004], [260, 985], [330, 975], [380, 975]], 10), swellW(8, 1)));
+ g.fillStyle = C.cream; g.fill(ribbon(dense(spiral(112, 956, 16, Math.PI, 0.9, 1), 2), q => 4.5 - q * 3));
+ g.fillStyle = C.gold; g.fill(ribbon(dense(spiral(142, 1012, 15, 0, 0.8, -1), 2), q => 5 - q * 3.5));
+ g.strokeStyle = C.line; g.lineWidth = 1.2; g.fill(ribbon(dense([[200, 1030], [260, 1010], [340, 1000]], 10), swellW(3, .6)));
+ g.fillStyle = '#d07a86'; g.beginPath(); g.arc(420, 993, 8, 0, TAU); g.fill();
+ g.restore(); };
+ whip(1); whip(-1);
+ // 标题
+ g.font = '76px "Marcellus-400"'; g.textAlign = 'center'; g.textBaseline = 'middle'; g.letterSpacing = '12px';
+ g.lineJoin = 'round'; g.strokeStyle = C.line; g.lineWidth = 7; g.strokeText('THÉ DU CHAT ROUX', 966, 994);
+ g.fillStyle = C.cream; g.fillText('THÉ DU CHAT ROUX', 966, 994); g.letterSpacing = '0px';
+ // 金框:外粗金线+内细棕线
+ g.strokeStyle = C.gold; g.lineWidth = 6; g.strokeRect(22, 20, W - 44, H - 40);
+ g.strokeStyle = C.line; g.lineWidth = 2; g.strokeRect(31, 29, W - 62, H - 58); g.strokeRect(16, 14, W - 32, H - 28);
+ });
+
+ // ---------- ② 彩色玻璃拱窗 ----------
+ const WX0 = 362, WX1 = 800, WY = 548, ACX = 581, ACY = 250, ARX = 219, ARY = 130;
+ const archPath = (ins) => { const p = new Path2D(); p.moveTo(WX0 + ins, WY - ins); p.lineTo(WX0 + ins, ACY); p.ellipse(ACX, ACY, ARX - ins, ARY - ins, 0, Math.PI, TAU); p.lineTo(WX1 - ins, WY - ins); p.closePath(); return p; };
+ const archPts = (ins) => { const o = []; for (let y = WY - ins; y > ACY; y -= 4) o.push([WX0 + ins, y]); for (let a = Math.PI; a <= TAU + 1e-6; a += 0.02) o.push([ACX + Math.cos(a) * (ARX - ins), ACY + Math.sin(a) * (ARY - ins)]); for (let y = ACY; y < WY - ins; y += 4) o.push([WX1 - ins, y]); return o; };
+ const hill = (y0, amp, ph, f = 0.016) => { const o = []; for (let x = WX0; x <= WX1 + 10; x += 12) o.push([x, y0 + Math.sin(x * f + ph) * amp + Math.sin(x * f * 2.3 + ph * 2) * amp * 0.35]); return o; };
+ const bands = [[372, 16, 0.5, '#f2dd9c'], [398, 18, 2.2, '#efc39c'], [424, 16, 4.1, '#e6a7a0'], [452, 14, 1.3, '#a9cfa0'], [490, 10, 3.3, '#7fb5a8']];
+ function windowGlass(c, lt, t) {
+ const inner = archPath(30);
+ c.save(); c.clip(inner);
+ const sg = c.createLinearGradient(0, 130, 0, 400); sg.addColorStop(0, '#86bfbd'); sg.addColorStop(0.6, '#b9d8b3'); sg.addColorStop(1, '#e9e2a8');
+ c.fillStyle = sg; c.fillRect(WX0, 110, WX1 - WX0, 440);
+ // 太阳:从山后升起(原片 ~-5px/帧)
+ const k = clamp(lt, 0, 1.4), sx = 583 - (k - 0.267) * 20, sy = 400 - (k - 0.267) * 288;
+ // 铅条光芒:从太阳中心放射,随时间转动
+ c.strokeStyle = C.line; c.lineWidth = 3.5; c.lineCap = 'round';
+ const rot = lt * 0.9;
+ for (let i = 0; i < 14; i++) { const a = Math.PI + (i + 0.5) / 14 * Math.PI + Math.sin(rot + i) * 0.04 + rot * 0.25; c.beginPath(); c.moveTo(sx + Math.cos(a) * 92, sy + Math.sin(a) * 92); c.lineTo(sx + Math.cos(a) * 420, sy + Math.sin(a) * 420); c.stroke(); }
+ // 天空里两道弧形铅条
+ c.lineWidth = 3; [[0.78, 150], [1.15, 200]].forEach(([e, r]) => { c.beginPath(); c.ellipse(sx, sy, r * 1.25, r * e * 0.75, 0, Math.PI, TAU); c.stroke(); });
+ // 光晕环+日盘
+ c.fillStyle = '#f7e2a0'; c.beginPath(); c.arc(sx, sy, 80, 0, TAU); c.fill(); c.stroke();
+ const sun = c.createRadialGradient(sx - 14, sy - 14, 6, sx, sy, 64); sun.addColorStop(0, '#f8c860'); sun.addColorStop(1, '#e8a43c');
+ c.fillStyle = sun; c.beginPath(); c.arc(sx, sy, 62, 0, TAU); c.fill(); c.lineWidth = 4; c.stroke();
+ // 山丘色带(挡住太阳下半)
+ bands.forEach(([y0, amp, ph, col], i) => { const pts = hill(y0, amp, ph + Math.sin(t * 1.4 + i) * 0.12); c.fillStyle = col; c.beginPath(); c.moveTo(WX0 - 10, 560); pts.forEach(p => c.lineTo(p[0], p[1])); c.lineTo(WX1 + 10, 560); c.closePath(); c.fill(); c.lineWidth = 3.5; c.beginPath(); pts.forEach((p, j) => j ? c.lineTo(p[0], p[1]) : c.moveTo(p[0], p[1])); c.stroke(); });
+ // 鸢尾:白色旗瓣+紫/粉垂瓣,叶片剑形
+ [[456, 452, '#b27ec4', 0], [580, 462, '#e3a0b0', 1.7], [704, 452, '#a777c0', 3.1]].forEach(([x, y, fc, ph]) => {
+ const sw = Math.sin(t * 5 + ph) * 4;
+ c.fillStyle = '#6aa860'; c.lineWidth = 2.5;
+ [[-34, -40], [30, -46], [-14, -60], [46, -20]].forEach(([dx, dy], j) => { const p = ribbon(dense([[x + dx * 0.2, 560], [x + dx * 0.6 + sw * 0.5, y + 50], [x + dx + sw, y + dy + 40]], 8), q => 14 * (1 - q) + 1); c.fill(p); c.stroke(p); });
+ c.strokeStyle = C.line; c.lineWidth = 6; c.beginPath(); c.moveTo(x, 560); c.quadraticCurveTo(x + sw * 0.5, y + 50, x + sw, y); c.stroke(); c.strokeStyle = '#6aa860'; c.lineWidth = 3; c.stroke(); c.strokeStyle = C.line;
+ const fx = x + sw;
+ [-1, 1].forEach(s => { c.fillStyle = fc; c.lineWidth = 3; c.beginPath(); c.ellipse(fx + s * 26, y + 12, 26, 17, s * 0.5, 0, TAU); c.fill(); c.stroke(); });
+ c.fillStyle = '#f5f0e4'; c.beginPath(); c.moveTo(fx, y + 6); c.bezierCurveTo(fx - 22, y - 14, fx - 14, y - 50, fx, y - 66); c.bezierCurveTo(fx + 14, y - 50, fx + 22, y - 14, fx, y + 6); c.fill(); c.stroke();
+ });
+ c.restore();
+ // 彩色小玻璃边带(沿拱形内缘,一格一色)
+ const pts = archPts(22); let acc = 0, k2 = 0; const cols = ['#3f7fa0', '#e0b040', '#6fb0a0', '#e9e0c4', '#3f7fa0', '#d9a03a'];
+ c.lineWidth = 1.5; c.strokeStyle = C.line;
+ for (let i = 1; i < pts.length; i++) { acc += Math.hypot(pts[i][0] - pts[i - 1][0], pts[i][1] - pts[i - 1][1]); if (acc >= 17) { acc = 0; const a = Math.atan2(pts[i][1] - pts[i - 1][1], pts[i][0] - pts[i - 1][0]); c.save(); c.translate(pts[i][0], pts[i][1]); c.rotate(a); c.fillStyle = cols[k2++ % cols.length]; c.fillRect(-7, -7, 14, 14); c.strokeRect(-7, -7, 14, 14); c.restore(); } }
+ // 木拱框+窗台
+ c.lineWidth = 16; c.strokeStyle = '#6b4a2e'; c.stroke(archPath(8)); c.lineWidth = 3; c.strokeStyle = C.line; c.stroke(archPath(0)); c.stroke(archPath(15)); c.stroke(archPath(30));
+ c.fillStyle = '#6b4a2e'; c.fillRect(348, 540, 466, 22); c.strokeRect(348, 540, 466, 22);
+ }
+
+ // ---------- 两侧花:罂粟(左)、百合(右),摇摆 ----------
+ const poppyHead = (c, x, y, r, rot) => {
+ c.save(); c.translate(x, y); c.rotate(rot);
+ for (let i = 0; i < 5; i++) { const a = i / 5 * TAU; c.save(); c.rotate(a); c.fillStyle = i % 2 ? C.poppy : '#df7d74';
+ c.beginPath(); c.moveTo(0, 0); c.bezierCurveTo(r * 0.9, -r * 0.55, r * 1.12, r * 0.25, r * 0.4, r * 0.62); c.closePath(); c.fill(); c.strokeStyle = C.line; c.lineWidth = 2.5; c.stroke(); c.restore(); }
+ c.strokeStyle = C.poppyD; c.lineWidth = 2; for (let i = 0; i < 10; i++) { const a = i / 10 * TAU + 0.3; c.beginPath(); c.moveTo(Math.cos(a) * r * 0.3, Math.sin(a) * r * 0.3); c.lineTo(Math.cos(a) * r * 0.75, Math.sin(a) * r * 0.75); c.stroke(); }
+ c.fillStyle = '#3f6a4a'; c.beginPath(); c.arc(0, 0, r * 0.24, 0, TAU); c.fill(); c.strokeStyle = C.line; c.lineWidth = 2.5; c.stroke();
+ c.fillStyle = '#e2b84a'; for (let i = 0; i < 10; i++) { const a = i / 10 * TAU; c.beginPath(); c.arc(Math.cos(a) * r * 0.36, Math.sin(a) * r * 0.36, 3, 0, TAU); c.fill(); }
+ c.restore();
+ };
+ const lilyHead = (c, x, y, r, rot) => {
+ c.save(); c.translate(x, y); c.rotate(rot); c.lineWidth = 2.5; c.strokeStyle = C.line;
+ for (let i = 0; i < 6; i++) { c.save(); c.rotate(i / 6 * TAU + (i % 2) * 0.1); const rr = i % 2 ? r * 0.85 : r;
+ c.fillStyle = C.lily; c.beginPath(); c.moveTo(0, 0); c.quadraticCurveTo(rr * 0.35, -rr * 0.28, rr, 0); c.quadraticCurveTo(rr * 0.35, rr * 0.28, 0, 0); c.fill(); c.stroke();
+ c.strokeStyle = '#b9a98a'; c.lineWidth = 1.2; c.beginPath(); c.moveTo(rr * 0.15, 0); c.lineTo(rr * 0.8, 0); c.stroke(); c.strokeStyle = C.line; c.lineWidth = 2.5; c.restore(); }
+ c.strokeStyle = '#a07a2a'; c.lineWidth = 1.5; for (let i = 0; i < 5; i++) { const a = -1.2 + i * 0.6; c.beginPath(); c.moveTo(0, 0); c.lineTo(Math.cos(a) * r * 0.42, Math.sin(a) * r * 0.42); c.stroke(); c.fillStyle = '#d99a2a'; c.beginPath(); c.arc(Math.cos(a) * r * 0.42, Math.sin(a) * r * 0.42, 3, 0, TAU); c.fill(); }
+ c.restore();
+ };
+ // 茎:从根部到花头的鞭线,sway 只推动上段
+ const stem = (c, base, head, bend, w = 9) => { const pts = dense([base, [lerp(base[0], head[0], 0.35) + bend, lerp(base[1], head[1], 0.35)], [lerp(base[0], head[0], 0.7) - bend * 0.6, lerp(base[1], head[1], 0.7)], head], 8);
+ c.fillStyle = C.line; c.fill(ribbon(pts, q => w + 3 - q * 3)); c.fillStyle = C.stem; c.fill(ribbon(pts, q => w - 1 - q * 3)); };
+ const blade = (c, base, tip, bend, w = 34) => { const pts = dense([base, [lerp(base[0], tip[0], 0.45) + bend, lerp(base[1], tip[1], 0.45)], tip], 10);
+ const p = ribbon(pts, q => w * Math.sin(Math.PI * Math.min(1, 0.12 + q * 0.88)) + 1); c.fillStyle = C.leaf; c.fill(p); c.strokeStyle = C.line; c.lineWidth = 2.5; c.stroke(p);
+ c.strokeStyle = C.leafD; c.lineWidth = 2; c.beginPath(); pts.slice(2, -3).forEach((q, i) => i ? c.lineTo(q[0], q[1]) : c.moveTo(q[0], q[1])); c.stroke(); };
+ function flowers(c, t) {
+ const sw = (ph, amp = 1) => (Math.sin(t * 7.5 + ph) * 13 + Math.sin(t * 3.1 + ph * 2) * 5) * amp;
+ // 左:罂粟
+ blade(c, [70, 900], [40, 640], 30 + sw(0.4, 0.3)); blade(c, [120, 900], [190, 690], -20 + sw(1.4, 0.3), 28); blade(c, [200, 900], [300, 640], -30 + sw(2.2, 0.3), 30);
+ const ps = [[[100, 900], [110, 215], 66, 0], [[150, 900], [234, 372], 62, 1.3], [[180, 900], [162, 495], 52, 2.6]];
+ ps.forEach(([b, h, r, ph]) => { const d = sw(ph); stem(c, b, [h[0] + d, h[1] + Math.abs(d) * 0.2], 40 - ph * 20); });
+ // 花苞
+ { const d = sw(3.5); stem(c, [230, 900], [272 + d, 222], -40, 8); c.fillStyle = '#9fc3a0'; c.strokeStyle = C.line; c.lineWidth = 2.5; c.beginPath(); c.ellipse(272 + d, 205, 24, 28, 0.2, 0, TAU); c.fill(); c.stroke();
+ c.beginPath(); c.arc(240 + d * 0.8, 222, 12, 0, TAU); c.stroke(); }
+ ps.forEach(([b, h, r, ph]) => { const d = sw(ph); poppyHead(c, h[0] + d, h[1] + Math.abs(d) * 0.2, r, d * 0.012 + ph); });
+ // 右:百合
+ blade(c, [1690, 900], [1600, 640], 40 + sw(5, 0.3), 30); blade(c, [1760, 900], [1830, 600], -20 + sw(6, 0.3), 26); blade(c, [1830, 900], [1880, 720], -10 + sw(4.4, 0.3), 24); blade(c, [1720, 900], [1660, 760], 30, 22);
+ const ls = [[[1730, 900], [1712, 300], 82, 4.0], [[1700, 900], [1652, 520], 62, 5.1], [[1800, 900], [1822, 470], 64, 6.3]];
+ ls.forEach(([b, h, r, ph]) => { const d = -sw(ph); stem(c, b, [h[0] + d, h[1]], -30 + (ph - 5) * 30, 8); });
+ { const d = -sw(7); stem(c, [1820, 900], [1838 + d, 360], 20, 7); c.fillStyle = C.lily; c.strokeStyle = C.line; c.lineWidth = 2.5; c.beginPath(); c.ellipse(1840 + d, 330, 11, 34, 0.1, 0, TAU); c.fill(); c.stroke(); }
+ ls.forEach(([b, h, r, ph]) => { const d = -sw(ph); lilyHead(c, h[0] + d, h[1], r, -0.3 + d * 0.01 + ph); });
+ }
+
+ // ---------- 光环(缓慢转动) ----------
+ function girlHalo(c, cx, cy, t) {
+ const R = 172, rot = t * 0.9;
+ c.save(); c.lineWidth = 3; c.strokeStyle = C.line;
+ c.fillStyle = C.gold; c.beginPath(); c.arc(cx, cy, R, 0, TAU); c.fill(); c.stroke();
+ // 金环上的圆钉(转动)
+ for (let i = 0; i < 18; i++) { const a = rot + i / 18 * TAU; const x = cx + Math.cos(a) * (R - 13), y = cy + Math.sin(a) * (R - 13);
+ c.fillStyle = C.cream; c.beginPath(); c.arc(x, y, 7.5, 0, TAU); c.fill(); c.lineWidth = 2; c.stroke(); c.fillStyle = '#c0606a'; c.beginPath(); c.arc(x, y, 3, 0, TAU); c.fill(); }
+ c.lineWidth = 3; c.fillStyle = '#5f9a8a'; c.beginPath(); c.arc(cx, cy, R - 26, 0, TAU); c.fill(); c.stroke();
+ c.fillStyle = '#ebb8b2'; c.beginPath(); c.arc(cx, cy, R - 34, 0, TAU); c.fill(); c.stroke();
+ // 玫瑰窗花瓣(反向转)
+ c.save(); c.translate(cx, cy); c.rotate(-rot * 0.7); c.strokeStyle = '#c98a86'; c.lineWidth = 2;
+ for (let ring = 0; ring < 2; ring++) for (let i = 0; i < 16; i++) { c.save(); c.rotate(i / 16 * TAU + ring * TAU / 32); const r0 = ring ? 40 : 70, r1 = ring ? 95 : 132;
+ c.fillStyle = ring ? '#e3a5a0' : '#efc4be'; c.beginPath(); c.moveTo(r0, 0); c.quadraticCurveTo((r0 + r1) / 2, -20 + ring * 6, r1, 0); c.quadraticCurveTo((r0 + r1) / 2, 20 - ring * 6, r0, 0); c.fill(); c.stroke(); c.restore(); }
+ c.restore(); c.restore();
+ }
+ function catHalo(c, cx, cy, t) {
+ const R = 106, rot = -t * 1.1;
+ c.save(); c.strokeStyle = C.line; c.lineWidth = 3;
+ c.fillStyle = C.gold; c.beginPath(); c.arc(cx, cy, R, 0, TAU); c.fill(); c.stroke();
+ c.setLineDash([10, 8]); c.lineDashOffset = rot * 40; c.strokeStyle = C.goldD; c.lineWidth = 6; c.beginPath(); c.arc(cx, cy, R - 8, 0, TAU); c.stroke(); c.setLineDash([]);
+ c.strokeStyle = C.line; c.lineWidth = 3; c.fillStyle = '#b8473a'; c.beginPath(); c.arc(cx, cy, R - 16, 0, TAU); c.fill(); c.stroke();
+ c.save(); c.translate(cx, cy); c.rotate(rot);
+ for (let i = 0; i < 8; i++) { c.save(); c.rotate(i / 8 * TAU); c.fillStyle = '#e8924a'; c.beginPath(); c.moveTo(14, 0); c.quadraticCurveTo(48, -20, 84, 0); c.quadraticCurveTo(48, 20, 14, 0); c.fill(); c.lineWidth = 2; c.stroke(); c.restore(); }
+ c.fillStyle = '#e0b84a'; c.beginPath(); c.arc(0, 0, 18, 0, TAU); c.fill(); c.stroke(); c.restore(); c.restore();
+ }
+
+ // ---------- 桌(绿铁艺卷脚)、椅、碟 ----------
+ function table(c) {
+ const iron = (pts, w) => { const d = dense(pts, 10); c.fillStyle = C.line; c.fill(ribbon(d, q => w + 4)); c.fillStyle = C.iron; c.fill(ribbon(d, q => w)); };
+ iron([[1004, 660], [1004, 760], [1006, 890]], 16);
+ iron([[1000, 672], [930, 682], [870, 690], [848, 712], [862, 736], [886, 730], [884, 712]], 10);
+ iron([[1010, 672], [1080, 682], [1140, 690], [1162, 712], [1148, 736], [1124, 730], [1126, 712]], 10);
+ iron([[1000, 760], [960, 790], [930, 800], [938, 828], [960, 822]], 9); iron([[1010, 760], [1050, 790], [1080, 800], [1072, 828], [1050, 822]], 9);
+ iron([[1004, 860], [940, 872], [860, 880], [842, 868], [852, 852], [866, 860]], 10); iron([[1006, 860], [1070, 872], [1150, 880], [1168, 868], [1158, 852], [1144, 860]], 10);
+ c.fillStyle = C.ironHi; c.fillRect(1001, 670, 4, 200);
+ // 桌面
+ c.fillStyle = '#f3ead8'; c.strokeStyle = C.line; c.lineWidth = 3.5; c.beginPath(); c.moveTo(812, 640); c.lineTo(1208, 640); c.lineTo(1196, 660); c.lineTo(824, 660); c.closePath(); c.fill(); c.stroke();
+ c.fillStyle = '#d9cdb2'; c.fillRect(826, 655, 368, 4);
+ }
+ function chair(c) {
+ c.fillStyle = C.line; c.fill(ribbon(dense([[1468, 900], [1478, 760], [1470, 600], [1486, 470], [1500, 450]], 8), q => 22 - q * 6));
+ c.fillStyle = C.wood; c.fill(ribbon(dense([[1468, 900], [1478, 760], [1470, 600], [1486, 470], [1500, 450]], 8), q => 15 - q * 6));
+ }
+
+ // ---------- 少女的长卷发:发团(波浪外缘)+ 一绺绺可变线宽的 S 形卷发,末端螺旋 ----------
+ function hairMass(c, G, t) {
+ const h = G.A.headC, ox = h[0] - 1318, oy = h[1] - 360;
+ const pts = [[1286, 300], [1350, 286], [1404, 318], [1432, 380], [1462, 440], [1496, 510], [1520, 590], [1530, 660], [1512, 730], [1470, 760], [1440, 712], [1420, 640], [1396, 560], [1368, 490], [1340, 440], [1318, 410]]
+ .map(([x, y], i) => { const w = i > 2 && i < 10 ? Math.sin(t * 6 + y * 0.035) * 9 * (y - 300) / 400 : 0; return [x + ox * (1 - (y - 300) / 500) + w, y + oy * (1 - (y - 300) / 500)]; });
+ const p = RIG.smooth(pts, true); c.fillStyle = '#e2b54c'; c.fill(p);
+ }
+ const lockDefs = {
+ back: [[1392, 360, 330, 120, 18, 0.2, 1], [1420, 400, 300, 150, 16, 1.4, -1], [1440, 450, 290, 105, 17, 2.5, 1], [1404, 430, 330, 60, 18, 3.3, -1], [1460, 520, 220, 120, 15, 4.2, 1], [1376, 470, 300, 30, 16, 5.0, 1], [1470, 600, 160, 70, 14, 0.9, -1]],
+ front: [[1316, 420, 170, -24, 15, 2.0, -1], [1334, 430, 140, 4, 13, 3.6, 1]],
+ };
+ const hairLocks = (G, t, which) => {
+ const h = G.A.headC, ox = h[0] - 1318, oy = h[1] - 360;
+ return lockDefs[which].map(([sx, sy, len, drift, w, ph, dir]) => {
+ const pts = []; for (let i = 0; i <= 12; i++) { const q = i / 12; const wave = Math.sin(q * 7.4 + ph - t * 7) * (6 + 20 * q);
+ pts.push([sx + ox * (1 - q) + drift * q + wave, sy + oy * (1 - q) + len * q]); }
+ const e = pts[pts.length - 1], a0 = Math.atan2(pts[12][1] - pts[11][1], pts[12][0] - pts[11][0]);
+ const r = 13 + w * 0.5, cx = e[0] + Math.cos(a0 + dir * Math.PI / 2) * r, cy = e[1] + Math.sin(a0 + dir * Math.PI / 2) * r;
+ const sp = spiral(cx, cy, r, a0 - dir * Math.PI / 2, 1.2, dir, 16);
+ return { pts: dense(pts.concat(sp.slice(1)), 4), w };
+ });
+ };
+ function drawHair(c, locks) {
+ locks.forEach(({ pts, w }) => { const rb = ribbon(pts, q => 2.5 + (w - 2.5) * Math.pow(1 - q, 0.6));
+ c.fillStyle = '#e8bf55'; c.fill(rb); c.strokeStyle = C.line; c.lineWidth = 2.2; c.stroke(rb);
+ const mid = pts.slice(3, -6); c.fillStyle = '#f6dc8a'; c.fill(ribbon(mid, q => 1 + 2.4 * (1 - q)));
+ c.strokeStyle = '#b9862a'; c.lineWidth = 1.2; c.beginPath(); mid.forEach((p, i) => i ? c.lineTo(p[0] + 3, p[1] + 2) : c.moveTo(p[0] + 3, p[1] + 2)); c.stroke(); });
+ }
+ // 头顶外缘的小卷(让头发有体积,像设定稿那样蓬)
+ function crownCurls(c, G, t) {
+ const h = G.A.headC;
+ [[-20, -66, 15, 1], [22, -64, 17, -1], [58, -40, 18, 1], [80, -2, 17, -1], [88, 38, 16, 1], [70, 70, 15, -1]].forEach(([dx, dy, r, dir], k) => {
+ const cx = h[0] + dx + Math.sin(t * 6 + k) * 2, cy = h[1] + dy;
+ const sp = dense(spiral(cx, cy, r, k * 1.3 + t * 2 * dir, 1.15, dir, 18), 2), rb = ribbon(sp, q => 9 * (1 - q) + 2);
+ c.fillStyle = '#e8bf55'; c.fill(rb); c.strokeStyle = C.line; c.lineWidth = 1.8; c.stroke(rb);
+ });
+ }
+ // 花环:沿额头—头顶—后脑的弧线排 5 朵粉花
+ function wreath(c, G, t) {
+ const a = G.A, p0 = a.forehead, p1 = [a.headTop[0] + 6, a.headTop[1] - 14], p2 = [a.nape[0] + 14, a.nape[1] - 70];
+ const at = q => [(1 - q) * (1 - q) * p0[0] + 2 * q * (1 - q) * p1[0] + q * q * p2[0], (1 - q) * (1 - q) * p0[1] + 2 * q * (1 - q) * p1[1] + q * q * p2[1]];
+ c.strokeStyle = C.gold; c.lineWidth = 5; c.beginPath(); for (let i = 0; i <= 20; i++) { const p = at(i / 20); i ? c.lineTo(p[0], p[1] + 8) : c.moveTo(p[0], p[1] + 8); } c.stroke();
+ [0.22, 0.42, 0.6, 0.78, 0.95].forEach((q, k) => { const [x, y] = at(q), r = k % 2 ? 15 : 19, rot = t * 0.8 + k;
+ c.fillStyle = '#7fa86a'; c.strokeStyle = C.line; c.lineWidth = 1.8; [-1, 1].forEach(s => { c.beginPath(); c.ellipse(x + s * r * 0.9, y + r * 0.5, r * 0.6, r * 0.28, s * 0.6, 0, TAU); c.fill(); c.stroke(); });
+ c.save(); c.translate(x, y); c.rotate(rot); for (let i = 0; i < 5; i++) { c.rotate(TAU / 5); c.fillStyle = k % 2 ? '#e7a0aa' : '#f0b4bb'; c.beginPath(); c.ellipse(r * 0.55, 0, r * 0.55, r * 0.4, 0, 0, TAU); c.fill(); c.stroke(); }
+ c.fillStyle = '#e0b04a'; c.beginPath(); c.arc(0, 0, r * 0.3, 0, TAU); c.fill(); c.stroke(); c.restore(); });
+ }
+ // S 形装饰热气:奶白可变宽带+棕双线,顶端螺旋,整体随时间卷动
+ function steam(c, x, y, t, cup) {
+ const H0 = 360 * (1 - 0.25 * cup), lean = -90 - 160 * cup;
+ const defs = [[-6, 0, 1, 26], [22, 2.3, -1, 20], [-26, 4.2, 1, 14]];
+ defs.forEach(([ox, ph, dir, w], k) => {
+ const pts = []; for (let i = 0; i <= 10; i++) { const q = i / 10; pts.push([x + ox * (1 + 2.6 * q) + Math.sin(q * 4.0 + ph - t * 6) * (18 + 70 * q) * dir + lean * q * q, y - q * H0 * (1 - k * 0.12)]); }
+ const e = pts[pts.length - 1]; const sp = spiral(e[0] + dir * 32, e[1] + 4, 34, dir > 0 ? Math.PI : 0, 1.1, dir > 0 ? 1 : -1, 14).map(([px, py], i) => [px, py]);
+ const all = dense(pts.concat(sp.slice(1)), 5), rb = ribbon(all, q => 2 + (w - 2) * Math.sin(Math.PI * Math.min(1, 0.15 + q * 1.1)));
+ c.globalAlpha = 0.95; c.fillStyle = '#fbf7ec'; c.fill(rb); c.strokeStyle = '#8a6a4a'; c.lineWidth = 1.8; c.stroke(rb);
+ c.strokeStyle = 'rgba(160,130,100,.6)'; c.lineWidth = 1.2; c.beginPath(); all.forEach((p, i) => i ? c.lineTo(p[0], p[1]) : c.moveTo(p[0], p[1])); c.stroke(); c.globalAlpha = 1;
+ });
+ }
+
+ const girlPal = { skin: '#f6dcc4', hair: '#e8bf55', hairLine: '#b9862a', dress: '#f4ecda', sleeve: '#f6dcc4', apron: '#e6aaa5', cuff: '#c9a24a', fold: '#c9b89a', shoe: '#c9a24a',
+ cheek: 'rgba(235,130,130,.45)', lip: '#c8505a', iris: '#4a6a3a', browC: '#9a6a2a', line: C.line, lw: 2.2, cupBody: '#f8f1e2', cupRim: '#7a4a24' };
+ const catPal = { orange: '#e39a4c', white: '#fbf3e3', stripe: '#b8622a', eye: '#e6c040', earInner: '#eaa0a0', line: C.line, lw: 2.2 };
+
+ return {
+ draw(c, lt, t) {
+ const ch = P.choreo(lt, t);
+ c.drawImage(bg(), 0, 0);
+ windowGlass(c, lt, t);
+ flowers(c, t);
+ catHalo(c, 606, 640, t);
+ const G = RIG.girl({ cup: ch.cup, sip: ch.sip, hair: 'long', breathe: ch.breathe });
+ girlHalo(c, 1342, 332, t);
+ chair(c);
+ table(c);
+ // 碟(杯子举起后仍在桌上)
+ c.fillStyle = '#f6efe0'; c.strokeStyle = C.line; c.lineWidth = 2.5; c.beginPath(); c.ellipse(992, 634, 58, 9, 0, 0, TAU); c.fill(); c.stroke();
+ // —— 角色层 ——
+ const L = P.scratch('nvChars'), lg = L.getContext('2d'); lg.clearRect(0, 0, W, H);
+ const K = RIG.cat({ tail: ch.tail, blink: ch.blink, breathe: ch.breathe });
+ RIG.drawCat(lg, K, { ...catPal, lw: 2 });
+ hairMass(lg, G, t); drawHair(lg, hairLocks(G, t, 'back'));
+ RIG.drawGirl(lg, G, { ...girlPal, lw: 2 });
+ // 短袖:上臂靠肩一段盖奶白
+ lg.save(); lg.beginPath(); lg.arc(G.A.shoulder[0], G.A.shoulder[1], 62, 0, TAU); lg.clip(); lg.fillStyle = '#f4ecda'; lg.fill(G.upperArm); lg.strokeStyle = C.line; lg.lineWidth = 2; lg.stroke(G.upperArm); lg.restore();
+ // 粉色披帛:从肩头沿背垂到腰后
+ { const a = G.A; const d = dense([[a.shoulder[0] + 6, a.shoulder[1] - 18], [a.back[0] - 4, a.back[1] - 30], [a.back[0] + 14, a.back[1] + 50], [a.waist[0] + 80, a.waist[1] + 40], [a.waist[0] + 96, a.waist[1] + 120]], 10);
+ const dr = ribbon(d, q => 30 + 26 * q); lg.fillStyle = '#e6aaa5'; lg.fill(dr); lg.strokeStyle = C.line; lg.lineWidth = 2; lg.stroke(dr); lg.fillStyle = '#d68f8c'; lg.fill(ribbon(d.slice(4), q => 4 + 6 * q)); }
+ // 粉色下摆的褶(深粉弧带)
+ lg.save(); lg.clip(G.apronSkirt); lg.fillStyle = '#d48e8c';
+ [[[1290, 640], [1250, 720], [1236, 830]], [[1250, 650], [1214, 740], [1206, 830]], [[1320, 680], [1296, 760], [1290, 830]]].forEach(pts => lg.fill(ribbon(dense(pts, 8), swellW(7, 1))));
+ lg.restore();
+ // 裙摆金色锯齿饰边
+ lg.save(); lg.clip(G.skirt); lg.lineJoin = 'miter';
+ { const zz = (y0, w, col) => { lg.strokeStyle = col; lg.lineWidth = w; lg.beginPath(); for (let k = 0, x = 1080; x <= 1380; x += 28, k++) { const y = y0 + (x - 1080) * 0.02 + (k % 2 ? 30 : 0); k ? lg.lineTo(x, y) : lg.moveTo(x, y); } lg.stroke(); };
+ zz(850, 13, C.line); zz(850, 8, C.gold); lg.fillStyle = C.cream; for (let k = 0, x = 1080; x <= 1380; x += 56, k++) { lg.beginPath(); lg.arc(x, 850 + (x - 1080) * 0.02 - 2, 4, 0, TAU); lg.fill(); } }
+ lg.restore();
+ // 猫的弧形虎斑(可变线宽)
+ lg.fillStyle = '#c0672c';
+ [[[450, 735], [470, 728], [500, 738]], [[436, 772], [462, 764], [496, 776]], [[430, 812], [458, 806], [490, 818]], [[432, 850], [458, 846], [486, 858]], [[520, 700], [536, 690], [556, 694]], [[580, 572], [586, 586], [590, 600]], [[604, 566], [606, 582], [606, 598]], [[626, 570], [622, 584], [620, 598]]]
+ .forEach(pts => { const d = dense(pts, 8); lg.fill(ribbon(d, swellW(9, 1))); });
+ // 金腰带+胸针
+ lg.fillStyle = C.gold; lg.save(); lg.clip(G.torso); lg.fillRect(G.A.waist[0] - 140, G.A.waist[1] - 22, 200, 16); lg.restore();
+ lg.beginPath(); lg.arc(G.A.waist[0] + 50, G.A.waist[1] - 14, 13, 0, TAU); lg.fill();
+ // 粗外轮廓:剪影染深棕,往右下错位垫在下面
+ const S = P.scratch('nvSil'), sg = S.getContext('2d'); sg.clearRect(0, 0, W, H); sg.drawImage(L, 0, 0); sg.globalCompositeOperation = 'source-in'; sg.fillStyle = C.line; sg.fillRect(0, 0, W, H); sg.globalCompositeOperation = 'source-over';
+ [[-1.5, -1.5], [3.5, 4.5], [2, 2.5]].forEach(([dx, dy]) => c.drawImage(S, dx, dy));
+ c.drawImage(L, 0, 0);
+ // 金臂环、耳坠
+ c.strokeStyle = C.gold; c.lineWidth = 6; c.beginPath(); c.arc(G.A.shoulder[0] - 6, G.A.shoulder[1] + 40, 22, 0.6, 2.4); c.stroke();
+ c.fillStyle = C.gold; c.strokeStyle = C.line; c.lineWidth = 2; c.beginPath(); c.arc(G.A.ear[0] - 4, G.A.ear[1] + 22, 8, 0, TAU); c.fill(); c.stroke();
+ // 肩前的发卷、花环
+ drawHair(c, hairLocks(G, t, 'front'));
+ crownCurls(c, G, t);
+ wreath(c, G, t);
+ // 杯上的点饰
+ c.fillStyle = '#d07a86'; [-12, 0, 12].forEach((d, i) => { c.fillStyle = i === 1 ? '#6fa08a' : '#d07a86'; c.beginPath(); c.arc(G.cup.x + d, G.cup.y + 20, 3.5, 0, TAU); c.fill(); });
+ steam(c, G.cup.x, G.cup.y - 8, t, ch.cup);
+ c.drawImage(P.grain('nv', 0.05, [70, 50, 30], 0.14), 0, 0);
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/11_cubism.js b/scripts/engine/scenes/11_cubism.js
new file mode 100644
index 0000000..e26e76a
--- /dev/null
+++ b/scripts/engine/scenes/11_cubism.js
@@ -0,0 +1,265 @@
+// 1912 分析立体主义(毕加索/布拉克)——纯代码。
+// 管线:①缓存底版:赭灰米色「透明叠面」(每面一条明→暗线性渐变,alpha 0.35–0.7 叠出层次)
+// + 点画/排线肌理面 + 布拉克式短划砂纹 + 贯穿的细直线(passage)+ 仿木纹(桌、木板)+ 藤编椅背
+// → ②会动的:窗格碎面各自滑动(窗景缓存成一张大图,四格各自错位取景)、CAFÉ 字母跳动换位(12fps 卡点)、报纸微颤
+// → ③角色:RIG 平涂进离屏层 → 自写切面器 facetize(抖动三角网,取色+随机明暗+两端渐变,三角不裁剪 = 轮廓被切成直边)
+// → 补毕加索式五官(侧脸+正面杏眼、半边脸蓝灰面)、裙摆放射切线、直线外轮廓(端点外伸)
+// → ④最上层再压几片低透明度的叠面,让人和猫「嵌」进空间
+SCENES['11_cubism'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp } = U, P = PAINT, TAU = Math.PI * 2;
+ const C = { paper: '#d6c8ac', cream: '#ece3cf', ochre: '#b8975f', brown: '#6e5538', dbrown: '#3a2c1e', grey: '#a8a395', bgrey: '#8e9eab', dgrey: '#5a5852', ink: '#2e241a' };
+ const H2 = P.hex;
+ // 要 getImageData 的离屏层必须一开始就声明 willReadFrequently:否则第一帧走 GPU、读回后 Chrome 改走 CPU,抗锯齿不同 → 第一帧与之后不一致(不确定性)
+ const LAYERS = {}; const layer = (k) => { if (!LAYERS[k]) { const cv = document.createElement('canvas'); cv.width = W; cv.height = H; cv.getContext('2d', { willReadFrequently: true }); LAYERS[k] = cv; } return LAYERS[k]; };
+ const poly = (g, pts) => { g.beginPath(); pts.forEach((p, i) => i ? g.lineTo(p[0], p[1]) : g.moveTo(p[0], p[1])); g.closePath(); };
+ // 一个「切面」:沿某方向从亮到暗的渐变(立体主义的明暗切面)
+ const plane = (g, pts, col, alpha, r, dark = 0.4, light = 0.25) => {
+ const c0 = Array.isArray(col) ? col : H2(col);
+ let a = pts[0], b = pts[(r() * pts.length) | 0]; if (a === b) b = pts[(pts.length / 2) | 0];
+ const gr = g.createLinearGradient(a[0], a[1], b[0], b[1]);
+ gr.addColorStop(0, P.rgb(P.mix(c0, [250, 244, 228], light), alpha)); gr.addColorStop(0.55, P.rgb(c0, alpha)); gr.addColorStop(1, P.rgb(P.mix(c0, [45, 35, 25], dark), alpha));
+ g.fillStyle = gr; poly(g, pts); g.fill();
+ };
+ // 仿木纹(布拉克用木纹梳画的假木头)
+ const wood = (g, x, y, w, h, vertical, seed, base = '#b8874a', dark = '#7a5228') => {
+ const r = U.rng(seed); g.save(); g.beginPath(); g.rect(x, y, w, h); g.clip(); g.fillStyle = base; g.fillRect(x, y, w, h);
+ g.strokeStyle = dark; const L = vertical ? h : w, S = vertical ? w : h, kx = 0.35 + r() * 0.3, ky = 0.3 + r() * 0.4;
+ for (let i = 0; i < S / 6; i++) { g.lineWidth = 0.8 + r() * 1.6; g.globalAlpha = 0.35 + r() * 0.4; g.beginPath();
+ for (let s = 0; s <= L; s += 6) { const u = s / L, off = i * 6 + Math.sin(u * 7 + i * 0.4) * 3 + 14 * Math.exp(-((u - kx) ** 2) / 0.01) * Math.sign(i * 6 - S * ky);
+ const X = vertical ? x + off : x + s, Y = vertical ? y + s : y + off; s ? g.lineTo(X, Y) : g.moveTo(X, Y); } g.stroke(); }
+ g.globalAlpha = 1; const kX = vertical ? x + S * ky : x + L * kx, kY = vertical ? y + L * kx : y + S * ky;
+ for (let k = 0; k < 4; k++) { g.lineWidth = 1.6; g.beginPath(); g.ellipse(kX, kY, (vertical ? 6 : 16) + k * 5, (vertical ? 16 : 6) + k * 4, 0, 0, TAU); g.stroke(); }
+ g.fillStyle = dark; g.beginPath(); g.ellipse(kX, kY, vertical ? 4 : 10, vertical ? 10 : 4, 0, 0, TAU); g.fill(); g.restore();
+ };
+
+ // ---------- ① 底版 ----------
+ const bg = () => P.cached('cb_bg', W, H, (g) => {
+ const r = U.rng(1912);
+ g.fillStyle = C.paper; g.fillRect(0, 0, W, H);
+ // 手工排的大叠面(参照原片构图)
+ const big = [
+ [[[0, 0], [330, 0], [180, 330], [0, 260]], C.grey, .6], [[[60, 0], [560, 0], [340, 110]], C.cream, .6], [[[0, 280], [200, 330], [110, 1080], [0, 1080]], C.dgrey, .45],
+ [[[160, 520], [350, 600], [280, 860], [120, 780]], C.ochre, .5], [[[820, 0], [1010, 0], [930, 330]], C.cream, .55], [[[880, 120], [1220, 40], [1100, 420], [860, 380]], C.bgrey, .5],
+ [[[1050, 0], [1500, 0], [1320, 240], [1180, 210]], C.grey, .45], [[[1500, 0], [1920, 0], [1920, 330], [1640, 260]], C.cream, .35], [[[1290, 170], [1720, 310], [1610, 620], [1240, 450]], C.grey, .45],
+ [[[1700, 340], [1920, 290], [1920, 900], [1760, 880]], C.ochre, .45], [[[840, 380], [1150, 320], [1210, 560], [880, 600]], C.grey, .5], [[[350, 560], [820, 600], [800, 900], [300, 930]], C.cream, .45],
+ [[[690, 620], [860, 560], [910, 1080], [630, 1080]], C.brown, .4], [[[1250, 600], [1560, 640], [1500, 1080], [1200, 1080]], C.dgrey, .35], [[[0, 640], [380, 560], [420, 1080], [0, 1080]], C.ochre, .35],
+ [[[560, 0], [880, 0], [820, 120], [600, 90]], C.ochre, .45], [[[1560, 620], [1920, 560], [1920, 1080], [1500, 1080]], C.ochre, .4], [[[300, 70], [520, 40], [470, 300], [280, 260]], C.dgrey, .3],
+ ];
+ big.forEach(([pts, col, a]) => plane(g, pts, col, a, r));
+ // 桌下放射扇面
+ for (let i = 0; i < 9; i++) { const a0 = -Math.PI + 0.25 + i * 0.3, a1 = a0 + 0.16; plane(g, [[1000, 1090], [1000 + Math.cos(a0) * 620, 1090 + Math.sin(a0) * 520], [1000 + Math.cos(a1) * 620, 1090 + Math.sin(a1) * 520]], i % 2 ? C.cream : C.brown, 0.3, r, 0.5, 0.3); }
+ // 随机小切面
+ for (let i = 0; i < 70; i++) { const cx = r() * W, cy = r() * H, s = 60 + r() * 200, a0 = r() * TAU, n = r() < 0.6 ? 3 : 4;
+ const pts = []; for (let k = 0; k < n; k++) { const a = a0 + k / n * TAU + (r() - .5) * 0.8; pts.push([cx + Math.cos(a) * s * (0.5 + r() * 0.6), cy + Math.sin(a) * s * (0.5 + r() * 0.6)]); }
+ if (cx > 1480 && cy < 230) continue;
+ plane(g, pts, [C.cream, C.grey, C.ochre, C.bgrey, C.brown, C.dgrey][(r() * 6) | 0], 0.18 + r() * 0.3, r); }
+ // 点画面、排线面
+ [[[930, 430], [1080, 380], [1060, 520], [960, 560]], [[1540, 420], [1700, 380], [1660, 520]], [[130, 380], [260, 420], [210, 560]], [[720, 700], [820, 690], [800, 820]]].forEach((pts, k) => {
+ g.save(); poly(g, pts); g.clip(); g.fillStyle = 'rgba(40,30,20,.45)'; for (let y = 0; y < H; y += 9) for (let x = (y / 9 % 2) * 4.5; x < W; x += 9) { if (x < pts[0][0] - 200 || x > pts[0][0] + 260 || y < pts[0][1] - 200 || y > pts[0][1] + 260) continue; g.beginPath(); g.arc(x, y, 1.6, 0, TAU); g.fill(); } g.restore(); });
+ [[[1040, 470], [1200, 400], [1220, 520], [1080, 560]], [[40, 300], [110, 280], [80, 640], [20, 660]], [[1230, 690], [1330, 660], [1310, 840]], [[600, 160], [700, 130], [690, 300]]].forEach((pts, k) => {
+ g.save(); poly(g, pts); g.clip(); g.strokeStyle = 'rgba(50,38,26,.45)'; g.lineWidth = 1.2; g.beginPath(); for (let d = -1200; d < 1200; d += 7) { g.moveTo(pts[0][0] + d, pts[0][1] - 300); g.lineTo(pts[0][0] + d + (k % 2 ? 300 : -120), pts[0][1] + 300); } g.stroke(); g.restore(); });
+ // 左侧竖排线(纸页)
+ g.save(); poly(g, [[0, 280], [100, 290], [70, 800], [0, 820]]); g.clip(); g.fillStyle = 'rgba(236,227,207,.7)'; g.fillRect(0, 280, 110, 560); g.strokeStyle = 'rgba(60,45,30,.4)'; g.lineWidth = 1; g.beginPath(); for (let y = 290; y < 820; y += 8) { g.moveTo(0, y); g.lineTo(110, y - 6); } g.stroke(); g.restore();
+ // 右侧木板(布拉克的假木纹)
+ g.save(); g.translate(1615, 590); g.rotate(-0.04); wood(g, -66, -205, 130, 410, true, 7, '#c4925a', '#7a4f26'); g.strokeStyle = C.ink; g.lineWidth = 2; g.strokeRect(-66, -205, 130, 410); g.restore();
+ // 藤编椅背+椅框
+ g.save(); poly(g, [[1484, 492], [1588, 470], [1588, 692], [1486, 700]]); g.clip(); g.fillStyle = '#c9a466'; g.fillRect(1480, 460, 120, 250);
+ g.fillStyle = 'rgba(70,46,24,.85)'; for (let y = 470; y < 705; y += 10) for (let x = 1480 + (y / 10 % 2) * 5; x < 1600; x += 10) { g.beginPath(); g.arc(x, y, 2.6, 0, TAU); g.fill(); }
+ g.strokeStyle = 'rgba(240,220,170,.5)'; g.lineWidth = 1.2; g.beginPath(); for (let d = -260; d < 260; d += 10) { g.moveTo(1480 + d, 460); g.lineTo(1480 + d + 250, 710); g.moveTo(1600 - d, 460); g.lineTo(1600 - d - 250, 710); } g.stroke(); g.restore();
+ g.strokeStyle = C.dbrown; g.lineWidth = 9; g.lineCap = 'round'; g.beginPath(); g.moveTo(1478, 900); g.lineTo(1478, 470); g.quadraticCurveTo(1530, 455, 1590, 486); g.lineTo(1590, 710); g.stroke();
+ g.lineWidth = 7; g.beginPath(); g.moveTo(1380, 720); g.lineTo(1488, 718); g.moveTo(1384, 720); g.lineTo(1384, 900); g.stroke();
+ // 桌:木纹桌面+深色裙板+抽屉+独脚+菱形
+ g.save(); poly(g, [[818, 600], [1202, 596], [1196, 644], [824, 646]]); g.clip(); wood(g, 810, 590, 400, 60, false, 3, '#b98b52', '#6e4a24'); g.restore();
+ g.strokeStyle = C.ink; g.lineWidth = 2.5; poly(g, [[818, 600], [1202, 596], [1196, 644], [824, 646]]); g.stroke();
+ plane(g, [[826, 646], [1194, 644], [1188, 702], [834, 704]], '#5a4128', 0.95, r, 0.35, 0.15);
+ g.fillStyle = '#8a6a44'; g.fillRect(952, 668, 118, 26); g.strokeStyle = C.ink; g.lineWidth = 2; g.strokeRect(952, 668, 118, 26); g.fillStyle = '#efe6d0'; g.beginPath(); g.arc(1011, 681, 5, 0, TAU); g.fill();
+ plane(g, [[988, 704], [1018, 704], [1022, 892], [984, 892]], '#8a6338', 0.95, r, 0.45, 0.25);
+ g.fillStyle = '#d8c39a'; poly(g, [[1004, 740], [1036, 780], [1004, 820], [972, 780]]); g.fill(); g.strokeStyle = C.ink; g.lineWidth = 2; g.stroke();
+ g.fillStyle = '#3a2c1e'; poly(g, [[1004, 780], [1036, 780], [1004, 820]]); g.fill();
+ plane(g, [[900, 860], [1110, 860], [1150, 900], [860, 900]], C.brown, 0.6, r);
+ // 碟(杯子举走后仍在桌上)
+ g.fillStyle = '#e8e0cc'; g.beginPath(); g.ellipse(990, 636, 54, 9, 0, 0, TAU); g.fill(); g.strokeStyle = C.ink; g.lineWidth = 2; g.stroke();
+ // 窗右侧透明「盒子」面与透视线
+ plane(g, [[815, 110], [892, 140], [890, 545], [815, 565]], C.bgrey, 0.3, r);
+ g.strokeStyle = 'rgba(46,36,26,.7)'; g.lineWidth = 1.4; g.beginPath(); g.moveTo(815, 105); g.lineTo(892, 140); g.lineTo(890, 545); g.lineTo(815, 565); g.stroke();
+ // 布拉克短划砂纹(亮暗两种)
+ for (let i = 0; i < 9000; i++) { const x = r() * W, y = r() * H; g.fillStyle = r() < 0.55 ? 'rgba(246,238,220,.28)' : 'rgba(60,45,30,.16)'; g.fillRect(x, y, 3 + r() * 5, 1.5); }
+ // 贯穿的细直线
+ g.strokeStyle = 'rgba(40,30,20,.55)'; g.lineWidth = 1.3;
+ for (let i = 0; i < 46; i++) { const x = r() * W, y = r() * H, a = r() * Math.PI, L = 120 + r() * 520; if (x > 1460 && y < 240) continue; g.beginPath(); g.moveTo(x, y); g.lineTo(x + Math.cos(a) * L, y + Math.sin(a) * L); g.stroke(); }
+ g.drawImage(P.grain('cb', 0.05, [50, 40, 30], 0.18), 0, 0);
+ });
+
+ // 窗景(缓存一张比窗大的图,四格各自错位取景)
+ const winScene = () => P.cached('cb_win', 560, 540, (g) => {
+ const r = U.rng(77); g.fillStyle = '#9fb0bd'; g.fillRect(0, 0, 560, 540);
+ const ox = 300, oy = 60; // 场景坐标 = 屏幕坐标 - (ox, oy)
+ for (let i = 0; i < 55; i++) { const cx = r() * 560, cy = r() * 540, s = 40 + r() * 170, a0 = r() * TAU; const pts = [0, 1, 2].map(k => { const a = a0 + k * 2.1 + (r() - .5) * 0.6; return [cx + Math.cos(a) * s, cy + Math.sin(a) * s * (0.4 + r())]; });
+ plane(g, pts, ['#c9d3da', '#8fa3b3', '#e4e6e2', '#6f8597', '#b4c1cb', '#5f7385'][(r() * 6) | 0], 0.45 + r() * 0.4, r, 0.45, 0.35); }
+ // 斜向长条光束
+ [[150, 0, 60], [230, 0, 30], [80, 120, 40]].forEach(([x, y, w]) => plane(g, [[x, y], [x + w, y], [x + w + 300, y + 420], [x + 300, y + 420]], '#e8ecec', 0.55, r, 0.3, 0.5));
+ // 埃菲尔铁塔(右侧,碎成两段)
+ const tx = 690 - ox; g.fillStyle = '#4a4c50'; poly(g, [[tx - 6, 120 - oy], [tx + 6, 120 - oy], [tx + 14, 330 - oy], [tx - 14, 330 - oy]]); g.fill();
+ poly(g, [[tx - 22, 330 - oy], [tx + 22, 330 - oy], [tx + 70, 560 - oy], [tx + 44, 560 - oy], [tx, 470 - oy], [tx - 44, 560 - oy], [tx - 70, 560 - oy]]); g.fill();
+ g.strokeStyle = 'rgba(220,226,230,.6)'; g.lineWidth = 1; g.beginPath(); for (let y = 340; y < 560; y += 9) { const w = 22 + (y - 330) * 0.21; g.moveTo(tx - w, y - oy); g.lineTo(tx + w, y - oy + 9); g.moveTo(tx + w, y - oy); g.lineTo(tx - w, y - oy + 9); } g.stroke();
+ g.fillStyle = '#4a4c50'; g.fillRect(tx - 46, 452 - oy, 92, 9);
+ // 白色海鸥弧
+ g.strokeStyle = '#f4f2ec'; g.lineWidth = 4; g.lineCap = 'round'; [[420, 200], [455, 190], [400, 390], [440, 380]].forEach(([x, y]) => { g.beginPath(); g.arc(x - ox, y - oy + 18, 18, -2.6, -0.5); g.stroke(); });
+ g.drawImage(P.grain('cbw', 0.04, [255, 255, 255], 0.2), 0, 0, 560, 540, 0, 0, 560, 540);
+ });
+ function windowPanes(c, lt, t) {
+ const panes = [[362, 120, 218, 212], [588, 120, 214, 212], [362, 340, 218, 212], [588, 340, 214, 212]];
+ const st = P.boilSeed(t, 10);
+ panes.forEach(([x, y, w, h], i) => {
+ const dx = Math.sin(lt * 9 + i * 1.7) * 18 + (U.hash(st, i) - 0.5) * 6, dy = Math.cos(lt * 7 + i) * 8;
+ c.save(); c.beginPath(); c.rect(x, y, w, h); c.clip(); c.drawImage(winScene(), 300 - 30 + dx, 60 - 30 + dy, 560, 540);
+ // 每格一片自己滑动的碎面
+ const sx = x + ((lt * 260 + i * 70) % (w + 120)) - 60;
+ c.fillStyle = 'rgba(232,236,236,.5)'; poly(c, [[sx, y + 20 + i * 12], [sx + 70, y + 60], [sx + 10, y + 150]]); c.fill(); c.strokeStyle = 'rgba(40,40,46,.6)'; c.lineWidth = 1.5; c.stroke();
+ c.restore();
+ });
+ c.strokeStyle = '#4a3420'; c.lineWidth = 15; c.strokeRect(352, 112, 457, 448); c.lineWidth = 10; c.beginPath(); c.moveTo(584, 112); c.lineTo(584, 560); c.moveTo(352, 336); c.lineTo(809, 336); c.stroke();
+ c.strokeStyle = C.ink; c.lineWidth = 2; c.strokeRect(345, 105, 471, 462);
+ c.fillStyle = '#8a6a44'; poly(c, [[330, 566], [826, 566], [818, 584], [338, 584]]); c.fill(); c.stroke();
+ }
+
+ // ---------- CAFÉ:模版字,12fps 跳动、偶尔换位 ----------
+ const ORDERS = ['CAFÉ', 'CAFÉ', 'ACFÉ', 'CAFÉ', 'CAÉF', 'CFAÉ', 'CAFÉ', 'CAFÉ', 'ACFÉ', 'CAFÉ'];
+ function cafe(c, lt) {
+ const L = P.scratch('cbCafe'), g = L.getContext('2d'); g.clearRect(0, 0, 420, 170);
+ const st = Math.floor(Math.max(0, lt) * 12), order = ORDERS[st % ORDERS.length];
+ const slots = [20, 108, 196, 284];
+ g.font = '104px "AlfaSlabOne-400"'; g.textBaseline = 'alphabetic'; g.fillStyle = '#3b2e22';
+ [...order].forEach((ch, i) => { const h = U.hash(st, i * 3 + 1), jy = (h - 0.5) * 26 - (i === 1 ? 8 : 0), rot = (U.hash(st, i * 5 + 2) - 0.5) * 0.22;
+ g.save(); g.translate(slots[i] + 40, 128 + jy); g.rotate(rot + (i === 2 ? -0.06 : 0)); g.fillText(ch, -40, 0); g.restore(); });
+ // 模版字的断口
+ g.globalCompositeOperation = 'destination-out'; g.fillStyle = '#000';
+ [[44, 60], [132, 92], [220, 70], [306, 84]].forEach(([x, y], i) => { g.fillRect(x - 40 + (i * 7) % 20, y, 90, 6); g.fillRect(x + 4, 40, 5, 100); });
+ g.globalCompositeOperation = 'source-over';
+ c.drawImage(L, 0, 0, 420, 170, 868, 120, 420, 170);
+ }
+
+ // ---------- 报纸 JOU(缓存成小图,逐帧微颤) ----------
+ const paper = () => P.cached('cb_jou', 300, 190, (g) => {
+ g.fillStyle = '#ebe3cc'; g.fillRect(0, 0, 300, 190); g.strokeStyle = 'rgba(60,45,30,.6)'; g.lineWidth = 1; g.strokeRect(0.5, 0.5, 299, 189);
+ g.fillStyle = '#2b2219'; g.font = '84px "LibreBaskerville-700"'; g.textBaseline = 'alphabetic'; g.fillText('JOU', 16, 82);
+ g.fillRect(12, 94, 276, 3); g.font = '12px "LibreBaskerville-700"'; g.fillText('LA BATAILLE', 14, 118); g.fillText("S'EST ENGAGÉ UN CHAT", 112, 118); g.fillRect(12, 126, 276, 1.5);
+ g.fillStyle = 'rgba(50,40,30,.55)'; for (let col = 0; col < 3; col++) for (let y = 136; y < 185; y += 5) g.fillRect(14 + col * 94, y, 84 - ((y * 7 + col * 13) % 23), 2);
+ g.strokeStyle = 'rgba(40,30,20,.5)'; g.beginPath(); g.moveTo(106, 128); g.lineTo(106, 186); g.moveTo(200, 128); g.lineTo(200, 186); g.stroke();
+ });
+ function news(c, lt, t) {
+ const st = P.boilSeed(t, 8), a = -0.12 + (U.hash(st, 9) - 0.5) * 0.025, dx = (U.hash(st, 4) - 0.5) * 3;
+ c.save(); c.translate(205 + dx, 912); c.rotate(a); c.drawImage(paper(), -150, -95);
+ // 翘起的折角(随帧翻动)
+ const f = 18 + Math.sin(lt * 20) * 6; c.fillStyle = '#d8ceb4'; poly(c, [[150, -95], [150 - f, -95], [150, -95 + f]]); c.fill(); c.strokeStyle = 'rgba(40,30,20,.6)'; c.stroke();
+ c.restore();
+ // 报纸下的支脚线(原片里的两根斜线)
+ c.strokeStyle = 'rgba(40,30,20,.7)'; c.lineWidth = 2; c.beginPath(); c.moveTo(320, 960); c.lineTo(352, 1010); c.moveTo(80, 1010); c.lineTo(60, 1060); c.stroke();
+ }
+
+ // ---------- 切面器:抖动三角网,三角不裁剪(轮廓被切成直边) ----------
+ function facetize(g, src, box, cell, seed, t, { boilFrac = 0.25, alpha = 0.95, edge = 'rgba(40,30,20,.32)', light = 0.2, dark = 0.32, minA = 120, only = null } = {}) {
+ const [x0, y0, x1, y1] = box, w = x1 - x0, h = y1 - y0, d = src.getContext('2d').getImageData(x0, y0, w, h).data;
+ const nx = Math.ceil(w / cell), ny = Math.ceil(h / cell), r = U.rng(seed), pts = [];
+ const st = P.boilSeed(t, 8);
+ for (let j = 0; j <= ny; j++) for (let i = 0; i <= nx; i++) { const k = j * (nx + 1) + i; pts.push([x0 + i * cell + (r() - .5) * cell * 0.85 + (U.hash(k, st * 3 + seed) - .5) * cell * 0.16, y0 + j * cell + (r() - .5) * cell * 0.85 + (U.hash(k, st * 5 + seed) - .5) * cell * 0.16]); }
+ const at = (x, y) => { const ix = clamp(Math.round(x - x0), 0, w - 1), iy = clamp(Math.round(y - y0), 0, h - 1), k = (iy * w + ix) * 4; return [d[k], d[k + 1], d[k + 2], d[k + 3]]; };
+ g.lineJoin = 'round';
+ for (let j = 0; j < ny; j++) for (let i = 0; i < nx; i++) {
+ const A = pts[j * (nx + 1) + i], B = pts[j * (nx + 1) + i + 1], Cc = pts[(j + 1) * (nx + 1) + i], D = pts[(j + 1) * (nx + 1) + i + 1];
+ const tris = r() < 0.5 ? [[A, B, D], [A, D, Cc]] : [[A, B, Cc], [B, D, Cc]];
+ tris.forEach((tri, k) => {
+ const cx = (tri[0][0] + tri[1][0] + tri[2][0]) / 3, cy = (tri[0][1] + tri[1][1] + tri[2][1]) / 3, s = at(cx, cy);
+ const shadeR = r(); if (s[3] < minA || (only && !only(s))) return;
+ const flick = U.hash(i * 31 + j, k + st * 7) < boilFrac ? (U.hash(i, j + st) - 0.5) * 0.25 : 0;
+ const sh = 0.8 + shadeR * 0.38 + flick, col = [s[0] * sh, s[1] * sh, s[2] * sh];
+ const gr = g.createLinearGradient(tri[0][0], tri[0][1], tri[2][0], tri[2][1]);
+ gr.addColorStop(0, P.rgb(P.mix(col, [250, 244, 228], light), alpha)); gr.addColorStop(1, P.rgb(P.mix(col, [40, 32, 24], dark), alpha));
+ g.fillStyle = gr; poly(g, tri); g.fill(); g.strokeStyle = edge; g.lineWidth = 1; g.stroke();
+ });
+ }
+ }
+ // 直线外轮廓:每段两端各外伸 ext(立体派的线常常画出界)
+ const segs = (g, pts, ext = 16, col = 'rgba(40,30,20,.72)', w = 2.2) => { g.strokeStyle = col; g.lineWidth = w; g.lineCap = 'round'; g.beginPath();
+ for (let i = 0; i < pts.length - 1; i++) { const a = pts[i], b = pts[i + 1], L = Math.hypot(b[0] - a[0], b[1] - a[1]) || 1, ux = (b[0] - a[0]) / L, uy = (b[1] - a[1]) / L;
+ g.moveTo(a[0] - ux * ext, a[1] - uy * ext); g.lineTo(b[0] + ux * ext, b[1] + uy * ext); } g.stroke(); };
+
+ const girlPal = { skin: '#e2cfae', hair: '#c9a256', hairLine: '#8a6a2e', dress: '#6a7a8b', sleeve: '#3c4857', fold: null, apron: '#c9cbc4', cuff: '#d9d4c4', shoe: '#2e241a', cheek: null, lip: '#a8443a', iris: '#2b2219', line: C.ink, lw: 0, mode: 'fill', cupBody: '#e6e2d8', cupRim: '#2a1e14' };
+ const catPal = { orange: '#c8773a', white: '#e8dfc9', stripe: '#7e4420', eye: '#c9a43a', line: C.ink, lw: 0, earInner: '#d79a88' };
+
+ function girl(c, G, lt, t, ch) {
+ const L = layer('girl'), g = L.getContext('2d'); g.reset(); // reset 清像素+清状态(lineJoin/lineCap 等会从上一帧残留,导致第一帧与之后不一致)
+ RIG.drawGirl(g, G, girlPal);
+ // 金发再加一条垂到背后的辫子(切面后变成三角发片)
+ g.fillStyle = '#c9a256'; g.beginPath(); const a = G.A; g.moveTo(a.nape[0] - 8, a.nape[1] - 40); g.lineTo(a.nape[0] + 52, a.nape[1] + 10); g.lineTo(a.back[0] + 36, a.back[1] + 70); g.lineTo(a.back[0] + 6, a.back[1] + 92); g.lineTo(a.nape[0] - 6, a.nape[1] + 30); g.closePath(); g.fill();
+ facetize(g, L, [1060, 230, 1540, 945], 58, 19, t, { boilFrac: 0.2, edge: 'rgba(40,30,20,.22)', light: 0.28, dark: 0.4 });
+ // 发区再细切一遍(更多金色三角)
+ g.save(); g.beginPath(); g.arc(a.headC[0] + 30, a.headC[1] - 10, 95, 0, TAU); g.rect(a.back[0] - 60, a.nape[1] - 30, 110, 260); g.clip();
+ facetize(g, L, [1240, 250, 1500, 640], 26, 23, t, { boilFrac: 0.3, alpha: 0.85, light: 0.3, minA: 200, only: s => s[0] > 150 && s[2] < 130 && s[0] - s[2] > 60 }); g.restore();
+ // 裙摆:从腰部放射的切线+明暗交替楔面
+ g.save(); g.clip(G.skirt); const O = [a.waist[0] - 40, a.waist[1] + 10];
+ [[1100, 930], [1150, 935], [1200, 935], [1250, 935], [1300, 935], [1350, 930], [1400, 900], [1450, 780]].forEach((p, i, arr) => { if (i < arr.length - 1) { g.fillStyle = i % 2 ? 'rgba(235,228,210,.22)' : 'rgba(30,36,46,.28)'; poly(g, [O, p, arr[i + 1]]); g.fill(); } g.strokeStyle = 'rgba(30,24,18,.42)'; g.lineWidth = 1.8; g.beginPath(); g.moveTo(...O); g.lineTo(...p); g.stroke(); });
+ g.restore();
+ // 毕加索式脸:前半张脸压一块蓝灰面,正面杏眼,红唇
+ // 脸重铺:肤色两块明暗面(切面会把发色带进脸里,这里还原)
+ g.save(); g.clip(G.face); g.fillStyle = '#e4d1b0'; g.fill(G.face); g.fillStyle = '#c9b28c'; poly(g, [[a.ear[0] - 30, a.ear[1] - 60], [a.ear[0] + 20, a.ear[1] - 40], [a.chin[0] + 50, a.chin[1] + 10], [a.chin[0] + 10, a.chin[1] - 10]]); g.fill(); g.restore();
+ g.fillStyle = '#e4d1b0'; g.fill(G.neck);
+ g.save(); g.clip(G.face); g.fillStyle = 'rgba(82,104,128,.82)'; poly(g, [[a.forehead[0] - 20, a.forehead[1] - 10], [a.forehead[0] + 22, a.forehead[1] - 4], [a.chin[0] + 8, a.chin[1] - 30], [a.chin[0] + 6, a.chin[1] + 10], [a.chin[0] - 40, a.chin[1] + 10]]); g.fill(); g.restore();
+ const e = G.eye; g.fillStyle = '#efe8d8'; g.beginPath(); g.moveTo(e.x - 14, e.y); g.quadraticCurveTo(e.x + 2, e.y - 12, e.x + 18, e.y); g.quadraticCurveTo(e.x + 2, e.y + 11, e.x - 14, e.y); g.fill(); g.strokeStyle = C.ink; g.lineWidth = 2.4; g.stroke();
+ if (ch.blink) { g.beginPath(); g.moveTo(e.x - 14, e.y); g.lineTo(e.x + 18, e.y); g.stroke(); } else { g.fillStyle = '#231a12'; g.beginPath(); g.arc(e.x + 3, e.y, 5.5, 0, TAU); g.fill(); }
+ g.lineWidth = 2.2; g.beginPath(); g.moveTo(e.x - 12, e.y - 14); g.quadraticCurveTo(e.x + 4, e.y - 22, e.x + 20, e.y - 13); g.stroke();
+ g.fillStyle = '#a8443a'; g.beginPath(); g.moveTo(...G.lips[0]); g.lineTo(G.lips[1][0] + 3, G.lips[1][1]); g.lineTo(...G.lips[2]); g.closePath(); g.fill();
+ // 耳(螺旋)
+ g.strokeStyle = C.ink; g.lineWidth = 2; g.beginPath(); for (let k = 0; k < 14; k++) { const q = k / 13, ang = q * 5.5, rr = 11 * (1 - q * 0.7); const x = a.ear[0] + Math.cos(ang) * rr, y = a.ear[1] + Math.sin(ang) * rr * 1.3; k ? g.lineTo(x, y) : g.moveTo(x, y); } g.stroke();
+ // 白领(两块明暗三角)
+ { const n = a.neck; g.fillStyle = '#e9e2d0'; poly(g, [[n[0] - 30, n[1] + 2], [n[0] + 4, n[1] + 12], [n[0] - 14, n[1] + 46]]); g.fill(); g.fillStyle = '#bdb5a2'; poly(g, [[n[0] + 4, n[1] + 12], [n[0] + 40, n[1] + 2], [n[0] + 18, n[1] + 44]]); g.fill();
+ g.strokeStyle = C.ink; g.lineWidth = 1.8; poly(g, [[n[0] - 30, n[1] + 2], [n[0] + 40, n[1] + 2], [n[0] + 18, n[1] + 44], [n[0] + 4, n[1] + 12], [n[0] - 14, n[1] + 46]]); g.stroke();
+ g.fillStyle = '#2e241a'; [0, 1, 2].forEach(k => { g.beginPath(); g.arc(n[0] + 6 - k * 2, n[1] + 60 + k * 26, 3, 0, TAU); g.fill(); }); }
+ // 直线外轮廓
+ segs(g, [a.forehead, [a.forehead[0] - 12, a.forehead[1] + 40], [a.chin[0] - 14, a.chin[1] - 18], a.chin, a.neck]);
+ segs(g, [a.headTop, [a.nape[0] + 30, a.nape[1] - 40], a.nape, a.back, [a.back[0] + 14, a.back[1] + 90]]);
+ segs(g, [a.neck, a.chest, [a.chest[0] - 4, a.chest[1] + 100], a.lap, a.knee, [a.knee[0] - 50, a.knee[1] + 160], a.hemL]);
+ segs(g, [a.shoulder, a.elbow, a.hand], 12, 'rgba(40,30,20,.7)', 2.2);
+ // 杯:重画清楚(半边暗面)
+ const k = G.cup; g.save(); g.translate(k.x, k.y); g.rotate(k.tilt); g.fillStyle = '#ebe6da'; poly(g, [[-24, 0], [-21, 40], [21, 40], [24, 0]]); g.fill(); g.fillStyle = '#56606a'; poly(g, [[4, 0], [24, 0], [21, 40], [4, 40]]); g.fill();
+ g.strokeStyle = C.ink; g.lineWidth = 2.2; poly(g, [[-24, 0], [-21, 40], [21, 40], [24, 0]]); g.stroke(); g.beginPath(); g.arc(28, 18, 11, -1.3, 1.4); g.lineWidth = 4; g.stroke();
+ g.fillStyle = '#231a12'; g.beginPath(); g.ellipse(0, 1, 23, 5, 0, 0, TAU); g.fill(); g.restore();
+ c.drawImage(L, 0, 0);
+ }
+ function cat(c, K, lt, t, ch) {
+ const L = layer('cat'), g = L.getContext('2d'); g.reset();
+ RIG.drawCat(g, K, catPal);
+ facetize(g, L, [320, 520, 740, 920], 26, 31, t, { boilFrac: 0.35, light: 0.25, dark: 0.36 });
+ // 头的直线轮廓+毕加索式双眼(一只正面、一只侧面)+侧面鼻
+ const h = K.headC, e = K.eyes;
+ segs(g, [[h[0] - 66, h[1] + 4], [h[0] - 44, h[1] - 50], [h[0] - 40, h[1] - 88], [h[0] - 6, h[1] - 50], [h[0] + 30, h[1] - 58], [h[0] + 52, h[1] - 86], [h[0] + 60, h[1] - 30], [h[0] + 66, h[1] + 14], [h[0] + 30, h[1] + 52], [h[0] - 34, h[1] + 50], [h[0] - 66, h[1] + 4]], 10);
+ segs(g, K.bodyPts.concat([K.bodyPts[0]]), 12);
+ e.forEach((p, i) => { g.fillStyle = '#d6b040'; g.beginPath(); g.moveTo(p.x - 12, p.y); g.lineTo(p.x, p.y - 9); g.lineTo(p.x + 12, p.y); g.lineTo(p.x, p.y + 9); g.closePath(); g.fill(); g.strokeStyle = C.ink; g.lineWidth = 2; g.stroke();
+ if (ch.blink) { g.beginPath(); g.moveTo(p.x - 12, p.y); g.lineTo(p.x + 12, p.y); g.stroke(); } else { g.fillStyle = '#1a140e'; g.fillRect(p.x - 2 + (i ? 3 : 0), p.y - 7, 5, 14); } });
+ g.fillStyle = '#c4706a'; poly(g, [[K.nose[0] - 6, K.nose[1] - 8], [K.nose[0] + 12, K.nose[1] + 2], [K.nose[0] - 4, K.nose[1] + 6]]); g.fill();
+ g.strokeStyle = 'rgba(30,24,18,.8)'; g.lineWidth = 1.4; K.whiskers.forEach(w => { g.beginPath(); g.moveTo(...w[0]); g.lineTo(w[1][0] + 20, w[1][1]); g.stroke(); });
+ c.drawImage(L, 0, 0, 820, 1080, 0, 0, 820, 1080);
+ }
+ // 最上层的透明叠面(缓慢错动),把角色嵌进空间
+ function overPlanes(c, lt, t) {
+ const st = P.boilSeed(t, 8), r = U.rng(5);
+ [[[1150, 260], [1330, 220], [1290, 470]], [[1180, 520], [1300, 470], [1330, 700], [1200, 720]], [[420, 640], [560, 600], [520, 780]], [[880, 300], [1060, 260], [1000, 420]], [[1350, 600], [1450, 560], [1470, 780]]].forEach((pts, i) => {
+ const dx = Math.sin(lt * 6 + i) * 8 + (U.hash(st, i) - .5) * 3; const q = pts.map(([x, y]) => [x + dx, y]);
+ plane(c, q, [C.cream, C.bgrey, C.ochre, C.cream, C.grey][i], 0.2, r, 0.35, 0.4); c.strokeStyle = 'rgba(40,30,20,.45)'; c.lineWidth = 1.2; poly(c, q); c.stroke(); });
+ }
+
+ return {
+ draw(c, lt, t) {
+ const ch = P.choreo(lt, t);
+ c.drawImage(bg(), 0, 0);
+ windowPanes(c, lt, t);
+ cafe(c, lt);
+ news(c, lt, t);
+ const G = RIG.girl({ cup: ch.cup, sip: ch.sip, hair: 'long', breathe: ch.breathe });
+ girl(c, G, lt, t, ch);
+ const K = RIG.cat({ tail: ch.tail, blink: ch.blink, breathe: ch.breathe });
+ cat(c, K, lt, t, ch);
+ overPlanes(c, lt, t);
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/12_bauhaus.js b/scripts/engine/scenes/12_bauhaus.js
new file mode 100644
index 0000000..feade9f
--- /dev/null
+++ b/scripts/engine/scenes/12_bauhaus.js
@@ -0,0 +1,214 @@
+// 1923 包豪斯海报(施莱默《三元芭蕾》人偶+蒙德里安格窗+构成主义斜杆)——纯代码。
+// 管线:①缓存底版(米白旧纸+斑驳+竖排大字 bauhaus+红黑条+katze+右下两行小字+地线+黄三角)
+// → ②会动的构成(斜长黑杆像指针绕轴转、越转越陡;格窗色块按拍轮换;红圆右侧同心弧扫动;杯上波浪热气)
+// → ③角色全由几何体拼:人偶=圆头/梯形躯干/黑杆四肢/白关节盘(锚点全取自 RIG.girl);猫=圆身方头三角耳,拨球
+SCENES['12_bauhaus'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, ease } = U, P = PAINT, TAU = Math.PI * 2;
+ const C = { paper: '#ebe3cf', ink: '#161514', red: '#d3262b', blue: '#2a58b4', yellow: '#efc12f', lblue: '#b9cee0', lblue2: '#a6c0da', grey: '#c6c3bb', cream: '#f2ecdf', orange: '#ee8a2a', orangeD: '#c25a14', chrome: '#c9c9c6' };
+ const font = (px, f = 'Poppins-800') => `${px}px "${f}"`;
+
+ // 斑驳小噪声图(放大使用):给纸、红圆、黑字做旧
+ const mottle = (key, seed, col, amt) => P.cached('bh_m_' + key, 320, 180, (g) => {
+ const im = g.createImageData(320, 180), r = U.rng(seed);
+ for (let y = 0; y < 180; y++) for (let x = 0; x < 320; x++) { const v = P.fbm(x * 0.045 + seed, y * 0.045, 4), i = (y * 320 + x) * 4;
+ im.data[i] = col[0]; im.data[i + 1] = col[1]; im.data[i + 2] = col[2]; im.data[i + 3] = clamp(v * 1.6 + 0.1) * 255 * amt + r() * 10; }
+ g.putImageData(im, 0, 0); });
+
+ // ---------- ① 底版 ----------
+ const bg = () => P.cached('bh_bg', W, H, (g) => {
+ g.fillStyle = C.paper; g.fillRect(0, 0, W, H);
+ g.globalAlpha = 0.5; g.drawImage(mottle('paper', 3, [150, 130, 95], 0.35), 0, 0, W, H); g.globalAlpha = 1;
+ // 长细斜线(贯穿画面,压在窗后)
+ g.strokeStyle = C.ink; g.lineWidth = 2.2; g.beginPath(); g.moveTo(40, 170); g.lineTo(1900, 840); g.stroke();
+ // 左上黑横条、红竖条
+ g.fillStyle = C.ink; g.fillRect(60, 61, 256, 13);
+ g.fillStyle = C.red; g.fillRect(292, 105, 24, 468);
+ // 竖排 bauhaus(自下而上读)
+ g.save(); g.translate(262, 1000); g.rotate(-Math.PI / 2); g.font = font(210); g.fillStyle = C.ink; g.textBaseline = 'alphabetic';
+ const w = g.measureText('bauhaus').width; g.scale(820 / w, 1); g.fillText('bauhaus', 0, 0); g.restore();
+ // 小灰方块
+ g.fillStyle = '#9a9894'; g.fillRect(875, 150, 31, 31);
+ // 地线、黄三角
+ g.fillStyle = C.ink; g.fillRect(345, 898, 1515, 17);
+ g.fillStyle = C.yellow; g.beginPath(); g.moveTo(1738, 898); g.lineTo(1822, 898); g.lineTo(1822, 793); g.closePath(); g.fill();
+ // 右侧细斜线
+ g.strokeStyle = C.ink; g.lineWidth = 2; g.beginPath(); g.moveTo(1610, 740); g.lineTo(1900, 842); g.stroke();
+ // katze
+ g.fillStyle = C.ink; g.fillRect(345, 946, 25, 25);
+ g.font = font(150); g.fillStyle = C.red; g.textBaseline = 'alphabetic'; g.fillText('katze', 392, 1042);
+ g.strokeStyle = C.ink; g.lineWidth = 2; g.beginPath(); g.moveTo(800, 1040); g.lineTo(1180, 1040); g.stroke();
+ // 右下两行小字
+ g.fillStyle = C.ink; g.fillRect(1224, 953, 12, 60);
+ g.font = font(31, 'Poppins-600'); g.letterSpacing = '1px'; g.fillText('staatliches bauhaus weimar', 1250, 977); g.fillText('ausstellung juli – september', 1250, 1014); g.letterSpacing = '0px';
+ // 桌(黑面+镀铬管腿+黑底座)
+ g.fillStyle = C.ink; g.fillRect(820, 643, 380, 21); g.fillRect(925, 883, 170, 17);
+ const cg = g.createLinearGradient(1000, 0, 1017, 0); cg.addColorStop(0, '#8a8a88'); cg.addColorStop(0.4, '#f2f2ee'); cg.addColorStop(1, '#7a7a78');
+ g.fillStyle = cg; g.fillRect(1000, 664, 17, 220); g.strokeStyle = '#555'; g.lineWidth = 1.5; g.strokeRect(1000, 664, 17, 220);
+ // 布劳耶式悬臂椅(镀铬管)
+ const tube = (pts) => { [[15, '#4a4a48'], [10, C.chrome], [3, '#fafaf6']].forEach(([w, col], k) => { g.strokeStyle = col; g.lineWidth = w; g.lineJoin = 'round'; g.lineCap = 'round'; g.beginPath(); pts.forEach((p, i) => i ? g.lineTo(p[0] - (k === 2 ? 2 : 0), p[1] - (k === 2 ? 2 : 0)) : g.moveTo(p[0], p[1])); g.stroke(); }); };
+ tube([[1508, 888], [1318, 888], [1300, 868], [1300, 770], [1318, 742], [1450, 736]]);
+ tube([[1466, 738], [1470, 480]]);
+ g.fillStyle = C.ink; g.fillRect(1450, 486, 14, 44);
+ // 纸面颗粒+黑色斑点(旧印刷)
+ g.drawImage(P.grain('bh', 0.02, [40, 35, 30], 0.35), 0, 0);
+ });
+
+ // 红圆(斑驳,缓存)
+ const redDisc = () => P.cached('bh_red', 520, 520, (g) => {
+ g.fillStyle = C.red; g.beginPath(); g.arc(260, 260, 252, 0, TAU); g.fill();
+ g.save(); g.clip(); g.globalCompositeOperation = 'source-atop'; g.globalAlpha = 0.55; g.drawImage(mottle('red', 9, [245, 150, 140], 0.5), -100, -60, 760, 640); g.restore();
+ });
+
+ // ---------- ② 蒙德里安格窗(色块轮换) ----------
+ const GX = 366, GY = 126, CW = 100, CH = 101, GAP = 9.5;
+ const base = [['cream', 'lblue', 'quarter', 'lblue'], ['yellow', 'grey', 'cream', 'lblue'], ['lblue', 'grid', 'lblue2', 'cream'], ['blue', 'cream', 'grid', 'lblue']];
+ const cycle = ['red', 'yellow', 'blue', 'cream', 'lblue', 'grey'];
+ const swaps = { '0,0': 0, '1,2': 2, '2,0': 4, '3,1': 1, '0,3': 3, '2,3': 5 }; // 哪几格在换色,各自相位
+ const fillOf = { cream: C.cream, lblue: C.lblue, lblue2: C.lblue2, yellow: C.yellow, grey: C.grey, blue: C.blue, red: C.red, ink: '#222' };
+ function grid(c, lt) {
+ c.fillStyle = C.ink; c.fillRect(352, 112, 456, 463); c.fillRect(800, 565, 32, 10);
+ const step = Math.floor(clamp(lt, 0, 9) * 13);
+ for (let r = 0; r < 4; r++) for (let k = 0; k < 4; k++) {
+ const x = GX + k * (CW + GAP) - (k ? 0 : 0), y = GY + r * (CH + GAP);
+ let kind = base[r][k]; const sw = swaps[r + ',' + k];
+ if (sw !== undefined && lt > 0.12) { const s = (step + sw * 2) % 9; if (s < cycle.length) kind = cycle[(s + sw) % cycle.length]; }
+ if (kind === 'grid') { c.fillStyle = C.cream; c.fillRect(x, y, CW, CH); c.strokeStyle = 'rgba(30,30,30,.7)'; c.lineWidth = 1; c.beginPath(); for (let q = 6; q < CW; q += 9) { c.moveTo(x + q, y); c.lineTo(x + q, y + CH); } for (let q = 6; q < CH; q += 9) { c.moveTo(x, y + q); c.lineTo(x + CW, y + q); } c.stroke(); }
+ else if (kind === 'quarter') { c.fillStyle = C.grey; c.fillRect(x, y, CW, CH); c.fillStyle = C.cream; c.beginPath(); c.moveTo(x, y + CH); c.arc(x, y + CH, CW * 0.72, -Math.PI / 2, 0); c.closePath(); c.fill(); }
+ else { c.fillStyle = fillOf[kind]; c.fillRect(x, y, CW, CH); }
+ }
+ c.save(); c.globalAlpha = 0.35; c.drawImage(mottle('paper', 3, [150, 130, 95], 0.35), 352, 112, 456, 463, 352, 112, 456, 463); c.restore();
+ }
+
+ // ---------- 斜长黑杆:绕毂转动(原片 575–591 帧 28°→49.5°) ----------
+ const PIV = [1125, 195];
+ function rod(c, lt) {
+ const k = ease.out(clamp((lt - 0.26) / 0.22)), deg = 28 + 21.5 * k + Math.sin(clamp((lt - 0.48) / 0.3) * Math.PI) * 1.5;
+ const a = deg * Math.PI / 180, u = [Math.cos(a), -Math.sin(a)], n = [Math.sin(a), Math.cos(a)]; // n = 垂直方向(右下)
+ const at = (s, o = 0) => [PIV[0] + u[0] * s + n[0] * o, PIV[1] + u[1] * s + n[1] * o];
+ // 毂圆
+ c.strokeStyle = C.ink; c.lineWidth = 2.2; c.beginPath(); c.arc(PIV[0], PIV[1], 76, 0, TAU); c.stroke();
+ c.beginPath(); c.arc(PIV[0], PIV[1], 58, -a + 0.9, -a + 0.9 + 3.6); c.stroke();
+ // 细平行线
+ c.lineWidth = 2.4; c.beginPath(); c.moveTo(...at(-540, 30)); c.lineTo(...at(240, 30)); c.stroke();
+ // 粗黑杆
+ c.lineWidth = 27; c.lineCap = 'butt'; c.beginPath(); c.moveTo(...at(-432)); c.lineTo(...at(150)); c.stroke();
+ // 红短杆
+ c.strokeStyle = C.red; c.lineWidth = 12; c.beginPath(); c.moveTo(...at(52, -30)); c.lineTo(...at(150, -30)); c.stroke();
+ c.fillStyle = C.ink; c.beginPath(); c.arc(PIV[0], PIV[1], 13, 0, TAU); c.fill();
+ }
+ // 红圆右侧的同心弧(像声波一样往外扫)
+ function arcs(c, lt) {
+ c.strokeStyle = C.ink; c.lineCap = 'butt';
+ const sweep = clamp(lt / 0.4);
+ [[272, -1.05, 0.95, 2.2], [292, -1.0, 0.9, 2.2], [312, -0.95, 0.85, 2.2], [332, -0.88, 0.8, 2.2], [352, -0.8, 0.7, 2.2], [420, -0.25, 0.62, 2]].forEach(([r, a0, a1, w], i) => {
+ const d = Math.sin(lt * 9 - i * 0.7) * 0.05; c.lineWidth = w; c.beginPath(); c.arc(1410, 595, r + Math.sin(lt * 12 - i) * 3, a0 + d, lerp(a0, a1, 0.55 + 0.45 * sweep) + d); c.stroke(); });
+ }
+
+ // ---------- 人偶少女(施莱默):锚点取自 RIG.girl ----------
+ const joint = (c, x, y, r) => { c.fillStyle = C.cream; c.beginPath(); c.arc(x, y, r, 0, TAU); c.fill(); c.strokeStyle = C.ink; c.lineWidth = 5; c.stroke(); c.fillStyle = C.ink; c.beginPath(); c.arc(x, y, r * 0.3, 0, TAU); c.fill(); };
+ const bar = (c, A, B, w, col = C.ink) => { c.strokeStyle = col; c.lineWidth = w; c.lineCap = 'round'; c.beginPath(); c.moveTo(A[0], A[1]); c.lineTo(B[0], B[1]); c.stroke(); };
+ function doll(c, G, lt, t, ch) {
+ const a = G.A, hc = [a.headC[0] + 14, a.headC[1] - 18];
+ // 远侧手臂:平放桌上
+ bar(c, [1352, 482], [1300, 600], 24); bar(c, [1300, 600], [1150, 614], 22); joint(c, 1300, 600, 17); joint(c, 1140, 616, 16);
+ // 背后的金色发片(半圆)
+ c.fillStyle = C.yellow; c.beginPath(); c.arc(a.back[0] - 18, a.back[1] - 32, 56, -Math.PI / 2, Math.PI / 2); c.closePath(); c.fill();
+ // 裙:黑扇面+蓝梯形
+ c.fillStyle = C.ink; c.beginPath(); c.moveTo(1356, 612); c.arc(1356, 612, 178, -0.05, 1.05); c.closePath(); c.fill();
+ c.fillStyle = C.blue; c.beginPath(); c.moveTo(1278, 606); c.lineTo(1420, 606); c.lineTo(1446, 728); c.lineTo(1236, 728); c.closePath(); c.fill();
+ // 腿
+ const hip = [1390, 716], knee = [1224, 722], ank = [1198, 878];
+ bar(c, hip, knee, 42); bar(c, knee, ank, 36);
+ c.fillStyle = C.ink; c.beginPath(); c.moveTo(1214, 860); c.lineTo(1224, 900); c.lineTo(1124, 900); c.lineTo(1150, 878); c.closePath(); c.fill();
+ joint(c, hip[0], hip[1], 24); joint(c, knee[0], knee[1], 21); joint(c, ank[0], ank[1], 10);
+ // 躯干:蓝梯形(随呼吸)
+ const top = a.neck[1] + 12, bot = 612, br = ch.breathe * 140;
+ c.fillStyle = C.blue; c.beginPath(); c.moveTo(1298, top - br); c.lineTo(1398, top + 8 - br); c.lineTo(1414, bot); c.lineTo(1290, bot); c.closePath(); c.fill();
+ c.fillStyle = C.ink; c.beginPath(); c.moveTo(1340, top - br); c.lineTo(1398, top + 8 - br); c.lineTo(1414, bot); c.lineTo(1380, bot); c.closePath(); c.globalAlpha = 0.9; c.fill(); c.globalAlpha = 1;
+ // 脖子
+ bar(c, [a.neck[0] + 8, a.neck[1] - 24], [a.neck[0] + 8, top - br + 4], 15);
+ // 头(随喝的仰头一起转)
+ c.save(); c.translate(a.neck[0], a.neck[1]); c.rotate(G.tilt); c.translate(-a.neck[0], -a.neck[1]);
+ const R = 70;
+ c.fillStyle = C.cream; c.beginPath(); c.arc(hc[0], hc[1], R, 0, TAU); c.fill();
+ // 金色几何发片:后半个头+额前三角+发髻圆
+ c.fillStyle = C.yellow; c.beginPath(); c.moveTo(hc[0], hc[1]); c.arc(hc[0], hc[1], R, -1.95, 1.15); c.closePath(); c.fill();
+ c.beginPath(); c.moveTo(hc[0] - 50, hc[1] - 50); c.lineTo(hc[0] + 2, hc[1] - R); c.lineTo(hc[0] + 4, hc[1] - 18); c.closePath(); c.fill();
+ c.beginPath(); c.arc(hc[0] + 78, hc[1] + 30, 34, 0, TAU); c.fill(); c.strokeStyle = C.ink; c.lineWidth = 3; c.stroke();
+ c.strokeStyle = C.ink; c.lineWidth = 5; c.beginPath(); c.arc(hc[0], hc[1], R, 0, TAU); c.stroke();
+ c.lineWidth = 2.5; c.beginPath(); c.moveTo(hc[0], hc[1] - R); c.lineTo(hc[0], hc[1] + R); c.stroke();
+ // 五官:黑竖条眼、红方腮、伸出头外的黑横杠(口)
+ if (ch.blink) { c.fillStyle = C.ink; c.fillRect(hc[0] - 42, hc[1] - 4, 14, 5); } else { c.fillStyle = C.ink; c.fillRect(hc[0] - 40, hc[1] - 18, 10, 30); }
+ c.fillStyle = C.red; c.fillRect(hc[0] - 22, hc[1] + 2, 20, 20);
+ c.fillStyle = C.ink; c.fillRect(hc[0] - 62, hc[1] + 30, 24, 6);
+ c.restore();
+ // 近侧手臂(IK 跟着端杯)
+ bar(c, a.shoulder, a.elbow, 28); bar(c, a.elbow, a.hand, 24);
+ mug(c, G, t);
+ joint(c, a.shoulder[0], a.shoulder[1], 22); joint(c, a.elbow[0], a.elbow[1], 19); joint(c, a.hand[0], a.hand[1], 17);
+ }
+ function mug(c, G, t) {
+ const k = G.cup; c.save(); c.translate(k.x, k.y); c.rotate(k.tilt);
+ c.fillStyle = '#fbf8f0'; c.strokeStyle = C.ink; c.lineWidth = 3.5; c.fillRect(-28, -6, 56, 64); c.strokeRect(-28, -6, 56, 64);
+ c.fillStyle = C.blue; c.fillRect(-28, 14, 56, 8);
+ c.lineWidth = 6; c.beginPath(); c.arc(30, 24, 14, -1.3, 1.3); c.stroke();
+ c.restore();
+ // 一根细波浪热气(像弹簧)
+ c.strokeStyle = C.ink; c.lineWidth = 2.2; c.beginPath();
+ for (let i = 0; i <= 60; i++) { const q = i / 60, y = k.y - 16 - q * 170, x = k.x - 4 + Math.sin(q * 26 - t * 18) * 9 * (1 - q * 0.3); i ? c.lineTo(x, y) : c.moveTo(x, y); }
+ const gg = c.createLinearGradient(0, k.y, 0, k.y - 190); gg.addColorStop(0, C.ink); gg.addColorStop(1, 'rgba(22,21,20,0)'); c.strokeStyle = gg; c.stroke();
+ }
+
+ // ---------- 几何猫:圆身方头三角耳,拨球 ----------
+ function cat(c, K, lt, t, ch) {
+ const bc = [K.box[0][0] + 146, K.box[1][1] - 100], br = 100 * (1 + ch.breathe * 2);
+ // 动作弧线
+ c.strokeStyle = C.ink; c.lineWidth = 2.5; [[150, -2.5, -1.75], [130, -2.45, -1.95]].forEach(([r, a0, a1]) => { c.beginPath(); c.arc(bc[0] + 50, bc[1] + 20, r, a0 + Math.PI * 0.62, a1 + Math.PI * 0.62); c.stroke(); });
+ // 尾巴:粗橙弧,带深橙条纹,跟着 choreo 摆
+ const ta0 = Math.PI * 0.62 + ch.tail * 0.5, ta1 = Math.PI * 1.22 + ch.tail * 0.5, tc = [bc[0] - 20, bc[1] + 10];
+ c.lineCap = 'butt'; c.strokeStyle = C.orange; c.lineWidth = 26; c.beginPath(); c.arc(tc[0], tc[1], 108, ta0, ta1); c.stroke();
+ c.strokeStyle = C.orangeD; c.lineWidth = 26; c.setLineDash([10, 14]); c.beginPath(); c.arc(tc[0], tc[1], 108, ta0 + 0.08, ta1); c.stroke(); c.setLineDash([]);
+ // 身体圆+左侧条纹(夹在圆里)
+ c.fillStyle = C.orange; c.beginPath(); c.arc(bc[0], bc[1], br, 0, TAU); c.fill();
+ c.save(); c.beginPath(); c.arc(bc[0], bc[1], br, 0, TAU); c.clip();
+ c.fillStyle = C.orangeD; [[-100, -40, 70], [-100, -12, 80], [-100, 16, 74], [-100, 44, 60]].forEach(([x, y, w]) => c.fillRect(bc[0] + x, bc[1] + y, w, 13));
+ c.fillStyle = C.cream; c.beginPath(); c.moveTo(bc[0] + 10, bc[1] + br); c.arc(bc[0], bc[1], br, 0.15, 1.45); c.closePath(); c.fill();
+ c.fillStyle = 'rgba(255,240,220,.18)'; c.beginPath(); c.arc(bc[0] - 30, bc[1] - 30, 40, 0, TAU); c.fill();
+ c.restore();
+ // 爪:三颗白圆;最右那只在 0.06–0.2s 伸出去拨球
+ const tap = Math.sin(clamp((lt - 0.05) / 0.16) * Math.PI);
+ [[-62, 0], [16, 0], [88 + tap * 36, -tap * 10]].forEach(([dx, dy], i) => { const x = bc[0] + dx, y = 878 + dy; c.fillStyle = C.cream; c.beginPath(); c.arc(x, y, 23, 0, TAU); c.fill(); c.strokeStyle = C.ink; c.lineWidth = 2.5; c.stroke(); });
+ // 蓝球:被拨后滚一下(转角 = 位移 / 半径)
+ const roll = ease.out(clamp((lt - 0.13) / 0.34)), bx = 712 + roll * 104, rb = 31;
+ c.fillStyle = C.blue; c.beginPath(); c.arc(bx, 898 - rb, rb, 0, TAU); c.fill();
+ c.save(); c.translate(bx, 898 - rb); c.rotate(roll * 104 / rb); c.strokeStyle = C.cream; c.lineWidth = 4; c.beginPath(); c.moveTo(-rb + 6, 0); c.lineTo(rb - 6, 0); c.stroke(); c.fillStyle = C.cream; c.beginPath(); c.arc(0, -rb * 0.55, 5, 0, TAU); c.fill(); c.restore();
+ if (roll > 0 && roll < 0.95) { c.strokeStyle = C.ink; c.lineWidth = 2; [0, 1].forEach(j => { c.beginPath(); c.moveTo(bx - rb - 14 - j * 16, 850 + j * 18); c.lineTo(bx - rb - 44 - j * 16 - 30 * (1 - roll), 850 + j * 18); c.stroke(); }); }
+ // 头:方块(微转),黄三角耳,白口鼻块
+ const hc = [K.headC[0] + 14, K.headC[1] + 48], s = 104, rot = -0.06 + ch.tail * 0.08;
+ c.save(); c.translate(hc[0], hc[1]); c.rotate(rot);
+ c.fillStyle = C.yellow; c.beginPath(); c.moveTo(-52, -50); c.lineTo(-38, -104); c.lineTo(-4, -50); c.closePath(); c.fill(); c.beginPath(); c.moveTo(14, -50); c.lineTo(50, -104); c.lineTo(54, -50); c.closePath(); c.fill();
+ c.fillStyle = C.orange; c.fillRect(-s / 2, -s / 2, s, s);
+ c.fillStyle = C.cream; c.fillRect(-s / 2, 8, s, s / 2 - 8);
+ c.fillStyle = C.orangeD; c.fillRect(-s / 2, -s / 2, s, 12);
+ [[-22, -10], [22, -10]].forEach(([x, y]) => { if (ch.blink) { c.fillStyle = C.ink; c.fillRect(x - 13, y, 26, 4); return; } c.fillStyle = '#fff'; c.beginPath(); c.arc(x, y, 15, 0, TAU); c.fill(); c.strokeStyle = C.ink; c.lineWidth = 3; c.stroke(); c.fillStyle = C.ink; c.fillRect(x - 1, y - 11, 8, 22); });
+ c.fillStyle = C.ink; c.beginPath(); c.moveTo(-8, 16); c.lineTo(8, 16); c.lineTo(0, 27); c.closePath(); c.fill();
+ c.strokeStyle = C.ink; c.lineWidth = 1.8; c.beginPath(); [[16, 20, 140, 6], [16, 26, 142, 30], [16, 32, 136, 52], [-16, 22, -120, 10], [-16, 30, -122, 34]].forEach(([x0, y0, x1, y1]) => { c.moveTo(x0, y0); c.lineTo(x1, y1); }); c.stroke();
+ c.restore();
+ }
+
+ return {
+ draw(c, lt, t) {
+ const ch = P.choreo(lt, t);
+ c.drawImage(bg(), 0, 0);
+ c.drawImage(redDisc(), 1410 - 260, 595 - 260);
+ arcs(c, lt);
+ grid(c, lt);
+ rod(c, lt);
+ const G = RIG.girl({ cup: ch.cup, sip: ch.sip, breathe: ch.breathe });
+ doll(c, G, lt, t, ch);
+ const K = RIG.cat({ tail: ch.tail, blink: ch.blink, breathe: ch.breathe });
+ cat(c, K, lt, t, ch);
+ c.drawImage(P.grain('bh2', 0.012, [30, 28, 26], 0.5), 0, 0);
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/13_pop.js b/scripts/engine/scenes/13_pop.js
new file mode 100644
index 0000000..04c1fc8
--- /dev/null
+++ b/scripts/engine/scenes/13_pop.js
@@ -0,0 +1,269 @@
+// 1962 波普(利希滕斯坦漫画格+沃霍尔四宫格)——纯代码。
+// 管线:①缓存底版(米白漫画格+45°本戴网点蓝墙+白踢脚线+黄地+红带+MEANWHILE 框)
+// → ②会动的母题(沃霍尔四格猫按拍换配色、思考泡泡三点依次闪、WIGGLE 爆炸框抖、猫扭屁股)
+// → ③角色:粗黑勾线平涂+皮肤红色本戴点(createPattern,零成本)+高光白条 + 斜线阴影
+SCENES['13_pop'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp } = U, P = PAINT, TAU = Math.PI * 2;
+ const C = { ink: '#141414', paper: '#f3eedb', blue: '#2f5cc8', yellow: '#f7d52c', red: '#d8232a', redD: '#a8161c', white: '#fbf8ee',
+ skin: '#fae0cc', dotRed: '#e2483c', hair: '#f8d62c', hairD: '#d9a514', orange: '#f39a2c', orangeD: '#c4561a' };
+ const hash = (i, j = 0) => U.hash(i, j);
+
+ // 本戴点图案:方格 + 中心点 = 45° 网格。pitch 是方格边长
+ const dotPattern = (c, key, pitch, r, col, bg) => {
+ const tile = P.cached('pop_tile_' + key, pitch, pitch, (g) => { if (bg) { g.fillStyle = bg; g.fillRect(0, 0, pitch, pitch); } g.fillStyle = col;
+ [[0, 0], [pitch, 0], [0, pitch], [pitch, pitch], [pitch / 2, pitch / 2]].forEach(([x, y]) => { g.beginPath(); g.arc(x, y, r, 0, TAU); g.fill(); }); });
+ return c.createPattern(tile, 'repeat');
+ };
+ // 斜线阴影(漫画的投影)
+ const hatch = (c, cx, cy, rx, ry, gap = 10, w = 3.5) => { c.save(); c.beginPath(); c.ellipse(cx, cy, rx, ry, 0, 0, TAU); c.clip();
+ c.strokeStyle = C.ink; c.lineWidth = w; c.beginPath(); for (let x = cx - rx - ry * 2; x < cx + rx + ry; x += gap) { c.moveTo(x, cy + ry); c.lineTo(x + ry * 2.2, cy - ry); } c.stroke(); c.restore(); };
+ const ink = (c, p, fill, lw = 5) => { if (fill) { c.fillStyle = fill; c.fill(p); } c.strokeStyle = C.ink; c.lineWidth = lw; c.lineJoin = 'round'; c.lineCap = 'round'; c.stroke(p); };
+ const poly = (pts, closed = true) => { const p = new Path2D(); pts.forEach((q, i) => i ? p.lineTo(q[0], q[1]) : p.moveTo(q[0], q[1])); if (closed) p.closePath(); return p; };
+
+ // ---------- ① 底版 ----------
+ const bg = () => P.cached('pop_bg', W, H, (g) => {
+ g.fillStyle = C.paper; g.fillRect(0, 0, W, H);
+ // 蓝网点墙
+ g.fillStyle = dotPattern(g, 'wall', 24, 5.6, C.blue, C.white); g.fillRect(20, 16, W - 40, 738);
+ // 踢脚线、黄地、红带
+ g.fillStyle = C.white; g.fillRect(20, 754, W - 40, 38);
+ g.fillStyle = C.ink; g.fillRect(20, 750, W - 40, 6); g.fillRect(20, 790, W - 40, 6);
+ g.fillStyle = C.yellow; g.beginPath(); g.moveTo(20, 796); g.lineTo(W - 20, 796); g.lineTo(W - 20, 990); g.lineTo(20, 1003); g.closePath(); g.fill();
+ // 黄地上浅浅的网点(印刷感)
+ g.save(); g.clip(); g.globalAlpha = 0.18; g.fillStyle = dotPattern(g, 'floor', 14, 2.2, '#c99a10'); g.fillRect(20, 796, W - 40, 210); g.restore();
+ g.fillStyle = C.red; g.beginPath(); g.moveTo(20, 1003); g.lineTo(W - 20, 990); g.lineTo(W - 20, 1064); g.lineTo(20, 1064); g.closePath(); g.fill();
+ g.strokeStyle = C.ink; g.lineWidth = 6; g.beginPath(); g.moveTo(20, 1003); g.lineTo(W - 20, 990); g.stroke();
+ // 漫画格外框
+ g.strokeStyle = C.ink; g.lineWidth = 6; g.strokeRect(17, 14, W - 34, H - 28);
+ // MEANWHILE...
+ g.fillStyle = C.yellow; g.fillRect(32, 32, 272, 70); g.lineWidth = 5; g.strokeRect(32, 32, 272, 70);
+ g.font = '46px "Bangers-400"'; g.fillStyle = C.ink; g.textBaseline = 'middle'; g.letterSpacing = '1px'; g.fillText('MEANWHILE...', 50, 70); g.letterSpacing = '0px';
+ // 沃霍尔画框(白框)+窗台
+ g.fillStyle = C.white; g.fillRect(350, 110, 462, 472); g.lineWidth = 5; g.strokeRect(350, 110, 462, 472);
+ g.fillStyle = C.white; g.fillRect(334, 574, 496, 22); g.strokeRect(334, 574, 496, 22); g.fillStyle = C.blue; g.fillRect(338, 592, 488, 4);
+ // 椅子(蓝)
+ const blue = '#2448b0';
+ [[1452, 478, 24, 420], [1300, 760, 18, 140], [1460, 760, 18, 140]].forEach(([x, y, w, h]) => { g.fillStyle = blue; g.fillRect(x, y, w, h); g.lineWidth = 4; g.strokeRect(x, y, w, h); });
+ g.fillStyle = blue; g.fillRect(1282, 740, 210, 24); g.strokeRect(1282, 740, 210, 24);
+ [[1440, 560], [1440, 640]].forEach(([x, y]) => { g.fillRect(x, y, 30, 12); });
+ g.fillStyle = '#6f8ee8'; g.fillRect(1458, 486, 6, 400);
+ // 纸面颗粒
+ g.drawImage(P.grain('pop', 0.035, [60, 50, 30], 0.12), 0, 0);
+ });
+
+ // ---------- ② 沃霍尔四格猫 ----------
+ const SCHEMES = [
+ { bg: '#9ccf3a', face: '#e0302a', low: '#9a6ad0', eye: '#3a7ad8', lip: '#f06a3a' },
+ { bg: '#e0359a', face: '#f0902a', low: '#78d6e6', eye: '#2a9a5a', lip: '#e0302a' },
+ { bg: '#2fc0b0', face: '#f27fb2', low: '#f8e040', eye: '#7a3ac8', lip: '#e0302a' },
+ { bg: '#f08a2a', face: '#f8d830', low: '#f6a2c4', eye: '#2ab0d8', lip: '#e0302a' },
+ ];
+ function warholCat(c, cx, cy, s) {
+ c.save(); c.translate(cx, cy);
+ const head = poly([[-70, -14], [-64, -78], [-30, -44], [30, -44], [64, -78], [70, -14], [62, 32], [30, 58], [-30, 58], [-62, 32]]);
+ const hd = RIG.smooth([[-70, -10], [-66, -76], [-28, -46], [28, -46], [66, -76], [70, -10], [60, 34], [0, 62], [-60, 34]], true, 0.35);
+ c.fillStyle = s.face; c.fill(hd);
+ c.save(); c.clip(hd); c.fillStyle = s.low; c.beginPath(); c.ellipse(4, 34, 58, 30, 0, 0, TAU); c.fill();
+ c.fillStyle = 'rgba(20,20,20,.88)'; c.beginPath(); c.moveTo(40, -40); c.quadraticCurveTo(76, 0, 52, 60); c.lineTo(90, 60); c.lineTo(90, -40); c.fill(); c.restore(); // 丝网错版的黑块
+ c.strokeStyle = C.ink; c.lineWidth = 5; c.lineJoin = 'round'; c.stroke(hd);
+ // 眼影+眼
+ [-26, 26].forEach(x => { c.fillStyle = s.eye; c.beginPath(); c.ellipse(x, -10, 19, 13, 0, Math.PI, TAU); c.fill();
+ c.fillStyle = '#fff'; c.beginPath(); c.ellipse(x, -4, 14, 9, 0, 0, TAU); c.fill(); c.lineWidth = 3; c.stroke();
+ c.fillStyle = C.ink; c.beginPath(); c.arc(x + 2, -4, 6, 0, TAU); c.fill(); c.lineWidth = 3.5; c.beginPath(); c.moveTo(x - 16, -10); c.lineTo(x - 22, -18); c.moveTo(x + 14, -12); c.lineTo(x + 20, -19); c.stroke(); });
+ // 嘴(口红)、鼻、胡须
+ c.fillStyle = s.lip; c.beginPath(); c.moveTo(-14, 30); c.quadraticCurveTo(0, 22, 14, 30); c.quadraticCurveTo(0, 44, -14, 30); c.fill(); c.lineWidth = 2.5; c.stroke();
+ c.fillStyle = C.ink; c.beginPath(); c.moveTo(-6, 14); c.lineTo(6, 14); c.lineTo(0, 21); c.fill();
+ c.lineWidth = 2; c.beginPath(); [[-1, 18], [1, 22], [-1, 26]].forEach(([d, y]) => { c.moveTo(-36, y); c.lineTo(-74, y - 4 + d * 2); c.moveTo(36, y); c.lineTo(74, y - 4 + d * 2); }); c.stroke();
+ // 耳内
+ c.fillStyle = C.ink; c.beginPath(); c.moveTo(-58, -64); c.lineTo(-56, -38); c.lineTo(-38, -44); c.fill();
+ c.restore();
+ }
+ function warhol(c, lt) {
+ const step = Math.floor(clamp(lt, 0, 9) * 11); // ~每 5–6 帧换一次配色
+ const cells = [[372, 132], [585, 132], [372, 350], [585, 350]];
+ cells.forEach(([x, y], i) => { const s = SCHEMES[(i + step) % 4];
+ c.fillStyle = s.bg; c.fillRect(x, y, 206, 212); warholCat(c, x + 103, y + 116, s);
+ c.strokeStyle = C.ink; c.lineWidth = 4; c.strokeRect(x, y, 206, 212); });
+ // 玻璃反光
+ c.strokeStyle = 'rgba(255,255,255,.85)'; c.lineWidth = 6; c.beginPath(); c.moveTo(712, 140); c.lineTo(660, 222); c.moveTo(736, 140); c.lineTo(684, 222); c.stroke();
+ }
+
+ // ---------- 思考泡泡(三点依次闪) ----------
+ const cloud = [[975, 220, 62], [1040, 180, 64], [1110, 170, 62], [1180, 200, 58], [1210, 250, 50], [1160, 292, 48], [1090, 300, 52], [1010, 292, 50], [960, 262, 46], [1080, 240, 90]];
+ function bubble(c, lt) {
+ c.lineWidth = 11; c.strokeStyle = C.ink; cloud.forEach(([x, y, r]) => { c.beginPath(); c.arc(x, y, r, 0, TAU); c.stroke(); });
+ c.fillStyle = C.white; cloud.forEach(([x, y, r]) => { c.beginPath(); c.arc(x, y, r, 0, TAU); c.fill(); });
+ [[1196, 334, 18], [1236, 338, 12]].forEach(([x, y, r]) => { c.beginPath(); c.arc(x, y, r, 0, TAU); c.fillStyle = C.white; c.fill(); c.lineWidth = 5; c.stroke(); });
+ const f = lt * 60;
+ [1025, 1082, 1139].forEach((x, k) => { const ph = ((f - 2 * k) % 12 + 12) % 12, on = ph < 4;
+ c.fillStyle = C.ink; c.beginPath(); c.arc(x, 242 - (on ? 6 : 0), on ? 20 : 12, 0, TAU); c.fill(); });
+ }
+
+ // ---------- WIGGLE WIGGLE 爆炸框 ----------
+ const burst = (cx, cy, r0, r1, n, seed) => { const pts = []; for (let i = 0; i < n * 2; i++) { const a = i / (n * 2) * TAU + 0.1, r = i % 2 ? r0 * (0.92 + hash(i, seed) * 0.12) : r1 * (0.85 + hash(i, seed + 1) * 0.3); pts.push([cx + Math.cos(a) * r * 1.12, cy + Math.sin(a) * r * 0.8]); } return poly(pts); };
+ function wiggleBox(c, lt) {
+ const st = Math.floor(lt * 30), jx = (hash(st, 3) - 0.5) * 16, jy = (hash(st, 7) - 0.5) * 12, rot = (hash(st, 11) - 0.5) * 0.06;
+ const cx = 222, cy = 690;
+ // 放射动作线(黑三角)
+ c.fillStyle = C.ink;
+ [[-2.45, 1], [-2.0, 0.9], [-1.62, 1.1], [-1.25, 0.8], [2.2, 1], [1.85, 0.9], [1.5, 1.1], [1.15, 0.8], [2.7, 0.7], [-2.85, 0.8]].forEach(([a, k], i) => {
+ const pl = 0.85 + 0.25 * Math.sin(lt * 40 + i * 2), r0 = 230 * k, r1 = r0 + 90 * pl, w = 0.06;
+ c.beginPath(); c.moveTo(cx + Math.cos(a - w) * r0 * 1.12, cy + Math.sin(a - w) * r0 * 0.9); c.lineTo(cx + Math.cos(a) * r1 * 1.12, cy + Math.sin(a) * r1 * 0.9); c.lineTo(cx + Math.cos(a + w) * r0 * 1.12, cy + Math.sin(a + w) * r0 * 0.9); c.fill(); });
+ c.save(); c.translate(cx + jx, cy + jy); c.rotate(rot); c.translate(-cx, -cy);
+ const outer = burst(cx, cy, 128, 178, 14, 1); c.fillStyle = C.white; c.fill(outer); c.lineWidth = 6; c.strokeStyle = C.ink; c.stroke(outer);
+ const inner = burst(cx, cy, 104, 140, 12, 5); c.fillStyle = C.yellow; c.fill(inner);
+ c.font = '82px "Bangers-400"'; c.textAlign = 'center'; c.textBaseline = 'middle'; c.lineJoin = 'round';
+ c.save(); c.translate(cx, cy); c.rotate(-0.08); c.letterSpacing = '2px';
+ [['WIGGLE', -34], ['WIGGLE', 40]].forEach(([s, y], i) => { c.lineWidth = 12; c.strokeStyle = C.ink; c.strokeText(s, i * 14 - 4, y + 5); c.fillStyle = C.ink; c.fillText(s, i * 14 - 4 + 4, y + 9); c.fillStyle = C.red; c.fillText(s, i * 14 - 4, y + 5); });
+ c.restore(); c.restore();
+ }
+
+ // ---------- 桌、杯 ----------
+ function table(c) {
+ hatch(c, 1010, 902, 150, 18);
+ c.fillStyle = C.ink; c.beginPath(); c.moveTo(985, 668); c.lineTo(1015, 668); c.lineTo(1024, 860); c.lineTo(976, 860); c.closePath(); c.fill();
+ c.beginPath(); c.moveTo(920, 900); c.quadraticCurveTo(930, 852, 1000, 848); c.quadraticCurveTo(1070, 852, 1080, 900); c.closePath(); c.fill();
+ c.strokeStyle = '#4a7ae8'; c.lineWidth = 5; c.lineCap = 'round'; c.beginPath(); c.moveTo(1030, 862); c.quadraticCurveTo(1062, 870, 1068, 892); c.moveTo(1010, 690); c.lineTo(1014, 830); c.stroke();
+ const top = poly([[822, 640], [1200, 640], [1196, 664], [826, 668]]); ink(c, top, C.red, 5);
+ c.strokeStyle = C.white; c.lineWidth = 5; c.beginPath(); c.moveTo(850, 650); c.lineTo(960, 650); c.moveTo(985, 650); c.lineTo(1010, 650); c.stroke();
+ }
+ function cup(c, G, t) {
+ const k = G.cup; c.save(); c.translate(k.x, k.y); c.rotate(k.tilt); const w = 50, h = 48;
+ const body = poly([[-w / 2, 0], [-w * 0.46, h], [w * 0.46, h], [w / 2, 0]]);
+ c.fillStyle = C.white; c.fill(body);
+ c.save(); c.clip(body); c.strokeStyle = '#2f5cc8'; c.lineWidth = 5; for (let x = 4; x < 50; x += 11) { c.beginPath(); c.moveTo(x, 0); c.lineTo(x - 18, h); c.stroke(); } c.restore();
+ c.strokeStyle = C.ink; c.lineWidth = 4; c.stroke(body); c.beginPath(); c.arc(w * 0.6, h * 0.45, 14, -1.3, 1.4); c.lineWidth = 6; c.stroke();
+ c.fillStyle = '#5a3016'; c.beginPath(); c.ellipse(0, 1, w / 2 - 2, 6, 0, 0, TAU); c.fill(); c.lineWidth = 3.5; c.stroke();
+ c.restore();
+ // 漫画热气:两条交叉的黑色波浪
+ c.save(); c.strokeStyle = C.ink; c.lineWidth = 4; c.lineCap = 'round';
+ [[-8, 0], [10, 2]].forEach(([dx, ph]) => { c.beginPath(); for (let i = 0; i <= 14; i++) { const q = i / 14, x = k.x + dx + Math.sin(q * 7 + ph + t * 14) * 9 * (dx < 0 ? 1 : -1), y = k.y - 14 - q * 62; i ? c.lineTo(x, y) : c.moveTo(x, y); } c.stroke(); });
+ c.restore();
+ }
+
+ // ---------- 少女(利希滕斯坦) ----------
+ function girl(c, G, lt, t, ch) {
+ const skinDots = dotPattern(c, 'skin', 13, 3.3, C.dotRed, C.skin);
+ const fillSkin = (p) => { c.fillStyle = skinDots; c.fill(p); c.strokeStyle = C.ink; c.lineWidth = 5; c.stroke(p); };
+ const a = G.A, h = a.headC, sh = [h[0] - 1318, h[1] - 360];
+ // 大波浪发团(背后)
+ const sway = Math.sin(t * 5) * 6;
+ // 外缘做成一串大波浪(利希滕斯坦的金发):沿后缘按弧长加 sin 鼓包
+ const spine = [[1262, 300], [1290, 262], [1346, 250], [1404, 276], [1440, 330], [1462, 396], [1492, 452], [1522, 510], [1540, 570], [1520, 624]];
+ const inner = [[1488, 640], [1452, 610], [1420, 628], [1392, 596], [1372, 548], [1356, 496], [1342, 452], [1330, 418], [1320, 392]];
+ const wav = spine.map(([x, y], i) => i < 4 ? [x, y] : [x + Math.sin(i * 2.1 + t * 4) * 14 + 10, y + Math.cos(i * 2.1) * 6]);
+ const hairPts = wav.concat(inner).map(([x, y]) => [x + sh[0] * (y < 430 ? 1 : 0.4) + (y > 430 ? sway * (y - 430) / 180 : 0), y + sh[1] * (y < 430 ? 1 : 0.4)]);
+ const hair = RIG.smooth(hairPts, true, 0.75);
+ // 大波浪:发团+沿后缘的一串卷团(先统一描粗黑边再统一填黄 = 并集轮廓)
+ const lobes = [[1440, 360, 44], [1478, 430, 46], [1500, 505, 48], [1520, 578, 44], [1478, 622, 38], [1430, 606, 34], [1400, 560, 30]]
+ .map(([x, y, r], i) => [x + sh[0] * (y < 430 ? 1 : 0.4) + sway * Math.max(0, y - 430) / 180 + Math.sin(t * 6 + i) * 3, y + sh[1] * (y < 430 ? 1 : 0.4), r]);
+ c.strokeStyle = C.ink; c.lineWidth = 10; c.stroke(hair); lobes.forEach(([x, y, r]) => { c.beginPath(); c.arc(x, y, r, 0, TAU); c.stroke(); });
+ c.fillStyle = C.hair; c.fill(hair); lobes.forEach(([x, y, r]) => { c.beginPath(); c.arc(x, y, r, 0, TAU); c.fill(); });
+ c.lineWidth = 4.5; c.lineCap = 'round'; lobes.forEach(([x, y, r], i) => { c.beginPath(); c.arc(x - 4, y + 2, r * 0.58, i % 2 ? -2.6 : -0.6, i % 2 ? 0.9 : 2.9); c.stroke(); });
+ c.strokeStyle = C.hairD; c.lineWidth = 7; lobes.forEach(([x, y, r]) => { c.beginPath(); c.arc(x, y, r - 6, 0.2, 1.2); c.stroke(); });
+ // 远侧手臂(桌上)
+ ink(c, G.farSleeve, C.red); fillSkin(G.farHand);
+ // 腿+红高跟
+ const knee = [1222, 760], ank = [1196, 878];
+ const leg = RIG.taper(knee, ank, 46, 30, 4); fillSkin(leg);
+ const leg2 = RIG.taper([1262, 772], [1236, 878], 44, 28, 4); fillSkin(leg2);
+ const shoe = (x, y) => { const p = poly([[x - 40, y + 2], [x - 30, y - 16], [x + 6, y - 14], [x + 16, y + 20], [x + 8, y + 22], [x - 2, y + 4], [x - 26, y + 12]]); ink(c, p, C.red, 4.5); c.strokeStyle = C.white; c.lineWidth = 3; c.beginPath(); c.moveTo(x - 26, y - 8); c.lineTo(x - 6, y - 8); c.stroke(); };
+ shoe(1236, 884); shoe(1196, 884);
+ // 裙(截短到膝)
+ c.save(); c.beginPath(); c.moveTo(0, 0); c.lineTo(W, 0); c.lineTo(W, 786); c.lineTo(1400, 786); c.quadraticCurveTo(1280, 806, 1150, 790); c.lineTo(0, 790); c.closePath(); c.clip();
+ ink(c, G.skirt, C.red, 5); c.restore();
+ c.strokeStyle = C.ink; c.lineWidth = 5; c.beginPath(); c.moveTo(1150, 790); c.quadraticCurveTo(1280, 806, 1400, 786); c.stroke();
+ ink(c, G.torso, C.red, 5);
+ // 高光白条
+ c.strokeStyle = C.white; c.lineWidth = 7; c.lineCap = 'round';
+ c.beginPath(); c.moveTo(a.chest[0] + 20, a.chest[1] - 10); c.quadraticCurveTo(a.chest[0] + 34, a.chest[1] + 40, a.chest[0] + 26, a.chest[1] + 80); c.moveTo(1200, 700); c.quadraticCurveTo(1250, 690, 1300, 700); c.stroke();
+ c.strokeStyle = C.redD; c.lineWidth = 4; c.beginPath(); c.moveTo(1380, 640); c.quadraticCurveTo(1400, 700, 1390, 760); c.stroke();
+ fillSkin(G.neck);
+ // 头
+ fillSkin(G.face);
+ c.fillStyle = C.skin; c.beginPath(); c.ellipse(G.ear[0], G.ear[1], 9, 13, 0.2, 0, TAU); c.fill(); c.lineWidth = 4; c.strokeStyle = C.ink; c.stroke();
+ // 刘海+头顶(大波浪)
+ const bangs = RIG.smooth([[1246, 330], [1250, 296], [1282, 268], [1336, 262], [1384, 284], [1404, 330], [1384, 312], [1350, 300], [1312, 302], [1280, 314], [1262, 340]].map(([x, y]) => [x + sh[0], y + sh[1]]), true, 0.5);
+ ink(c, bangs, C.hair, 5);
+ // 发丝黑线与白高光
+ c.strokeStyle = C.ink; c.lineWidth = 4;
+ [[1300, 272, 1418, 420, 0], [1350, 300, 1460, 520, 1], [1420, 360, 1520, 600, 2], [1380, 440, 1470, 630, 3], [1336, 420, 1410, 600, 4]].forEach(([x0, y0, x1, y1, k]) => {
+ c.beginPath(); for (let i = 0; i <= 24; i++) { const q = i / 24, x = lerp(x0, x1, q) + Math.sin(q * 9 + k) * 16 * q, y = lerp(y0, y1, q);
+ const X = x + sh[0] * 0.7 + (y > 430 ? sway * (y - 430) / 180 : 0), Y = y + sh[1] * 0.7; i ? c.lineTo(X, Y) : c.moveTo(X, Y); } c.stroke(); });
+ c.strokeStyle = C.white; c.lineWidth = 6; c.beginPath(); c.moveTo(1300 + sh[0], 280 + sh[1]); c.quadraticCurveTo(1340 + sh[0], 276 + sh[1], 1370 + sh[0], 292 + sh[1]); c.moveTo(1440 + sway * 0.3, 470); c.lineTo(1456 + sway * 0.4, 500); c.stroke();
+ // 五官:大眼、浓睫毛、红唇
+ const e = G.eye;
+ if (ch.blink) { c.strokeStyle = C.ink; c.lineWidth = 4; c.beginPath(); c.arc(e.x, e.y - 2, 9, 0.2, Math.PI - 0.2); c.stroke(); }
+ else { c.fillStyle = C.white; c.beginPath(); c.ellipse(e.x - 1, e.y, 12, 8.5, 0, 0, TAU); c.fill(); c.fillStyle = '#3a8ae0'; c.beginPath(); c.arc(e.x - 3, e.y + 1, 7, 0, TAU); c.fill(); c.fillStyle = C.ink; c.beginPath(); c.arc(e.x - 3, e.y + 1, 3.2, 0, TAU); c.fill(); c.fillStyle = '#fff'; c.beginPath(); c.arc(e.x - 6, e.y - 2, 2, 0, TAU); c.fill();
+ c.strokeStyle = C.ink; c.lineWidth = 4.5; c.stroke(G.lid); c.lineWidth = 3.5; G.lashes.forEach(l => { c.beginPath(); c.moveTo(...l[0]); c.lineTo(l[1][0] - 5, l[1][1] - 5); c.stroke(); }); c.beginPath(); c.moveTo(e.x + 10, e.y - 6); c.lineTo(e.x + 16, e.y - 12); c.stroke(); }
+ c.save(); c.translate(0, -5); c.strokeStyle = C.ink; c.lineWidth = 4; c.stroke(G.brow); c.restore();
+ c.fillStyle = C.red; c.beginPath(); c.moveTo(G.lips[0][0] - 3, G.lips[0][1] - 1); c.quadraticCurveTo(G.lips[1][0] + 4, G.lips[1][1] - 4, G.lips[1][0] + 3, G.lips[1][1] + 2); c.quadraticCurveTo(G.lips[2][0] + 3, G.lips[2][1] + 3, G.lips[2][0] - 3, G.lips[2][1]); c.closePath(); c.fill(); c.lineWidth = 2.5; c.stroke();
+ // 近侧手臂(无袖:皮肤点)+杯+手
+ fillSkin(G.upperArm); fillSkin(G.foreArm);
+ cup(c, G, t);
+ fillSkin(G.hand); c.fillStyle = C.skin; c.beginPath(); c.arc(G.thumb[0], G.thumb[1], 7, 0, TAU); c.fill(); c.lineWidth = 3.5; c.stroke();
+ c.fillStyle = C.red; c.beginPath(); c.arc(G.thumb[0] - 4, G.thumb[1] - 1, 3, 0, TAU); c.fill(); // 红指甲
+ }
+
+ // ---------- 猫:趴低、准备扑,屁股左右扭 ----------
+ function cat(c, K, lt, t, ch) {
+ const wig = Math.sin(lt * TAU * 6) * 16; // 6Hz 扭屁股
+ const bx = K.box[0][0] - 390, by = K.box[1][1] - 905; // 骨架原点偏移
+ const def = ([x, y]) => { const w = clamp((560 - x) / 140); return [x + bx + wig * w, y + by - Math.abs(wig) * 0.6 * w]; };
+ hatch(c, 580, 912, 230, 22);
+ // 尾巴
+ const tailBase = def([440, 870]), tip = [318 + bx + wig * 1.4 + Math.sin(ch.tail) * 20, 846 + by - Math.cos(ch.tail) * 18];
+ const tailPts = P.bez(tailBase, [400 + bx + wig, 900 + by], [350 + bx + wig * 1.2, 900 + by], tip, 16);
+ c.lineCap = 'round'; c.strokeStyle = C.ink; c.lineWidth = 34; c.beginPath(); tailPts.forEach((p, i) => i ? c.lineTo(p[0], p[1]) : c.moveTo(p[0], p[1])); c.stroke();
+ c.strokeStyle = C.orange; c.lineWidth = 24; c.stroke();
+ c.strokeStyle = C.orangeD; c.lineWidth = 6; [4, 8, 12].forEach(i => { const p = tailPts[i], q = tailPts[i + 1], a = Math.atan2(q[1] - p[1], q[0] - p[0]) + Math.PI / 2; c.beginPath(); c.moveTo(p[0] + Math.cos(a) * 11, p[1] + Math.sin(a) * 11); c.lineTo(p[0] - Math.cos(a) * 11, p[1] - Math.sin(a) * 11); c.stroke(); });
+ c.fillStyle = C.white; c.beginPath(); c.arc(tip[0], tip[1], 12, 0, TAU); c.fill(); c.lineWidth = 4; c.strokeStyle = C.ink; c.stroke();
+ // 身体(翘起的屁股在左)
+ const body = RIG.smooth([[452, 900], [420, 872], [418, 820], [440, 780], [482, 756], [540, 756], [600, 770], [652, 800], [690, 850], [700, 900]].map(def), true, 0.55);
+ ink(c, body, C.orange, 5);
+ c.save(); c.clip(body);
+ c.fillStyle = C.white; c.beginPath(); c.ellipse(610 + bx, 880 + by, 120, 46, 0, 0, TAU); c.fill();
+ c.strokeStyle = C.orangeD; c.lineWidth = 9; c.lineCap = 'round';
+ [[450, 790, 486, 830], [478, 772, 512, 816], [512, 764, 540, 806], [546, 766, 566, 806], [430, 830, 470, 858]].forEach(([x0, y0, x1, y1]) => { const p0 = def([x0, y0]), p1 = def([x1, y1]); c.beginPath(); c.moveTo(...p0); c.quadraticCurveTo(p0[0] + 18, (p0[1] + p1[1]) / 2, p1[0], p1[1]); c.stroke(); });
+ c.restore(); c.strokeStyle = C.ink; c.lineWidth = 5; c.stroke(body);
+ // 前爪(向前伸)
+ [[650, 886], [704, 888]].forEach(([x, y]) => { const p = new Path2D(); p.ellipse(x + bx, y + by, 30, 15, 0, 0, TAU); ink(c, p, C.white, 4.5); c.lineWidth = 3; c.beginPath(); c.moveTo(x + bx + 6, y + by - 8); c.lineTo(x + bx + 6, y + by + 6); c.moveTo(x + bx + 16, y + by - 7); c.lineTo(x + bx + 16, y + by + 5); c.stroke(); });
+ // 头(压低,盯着前方)
+ const hc = [K.headC[0] + 22, K.headC[1] + 104], r = 58;
+ const head = new Path2D(); head.ellipse(hc[0], hc[1], r * 1.08, r * 0.92, 0, 0, TAU);
+ const ears = poly([[hc[0] - 50, hc[1] - 30], [hc[0] - 46, hc[1] - 94], [hc[0] - 8, hc[1] - 52], [hc[0] + 14, hc[1] - 54], [hc[0] + 52, hc[1] - 96], [hc[0] + 56, hc[1] - 30]]);
+ ink(c, ears, C.orange, 5); ink(c, head, C.orange, 5);
+ c.fillStyle = '#f39ab8'; c.beginPath(); c.moveTo(hc[0] - 40, hc[1] - 50); c.lineTo(hc[0] - 40, hc[1] - 80); c.lineTo(hc[0] - 18, hc[1] - 56); c.fill(); c.beginPath(); c.moveTo(hc[0] + 44, hc[1] - 52); c.lineTo(hc[0] + 46, hc[1] - 82); c.lineTo(hc[0] + 22, hc[1] - 58); c.fill();
+ c.save(); c.clip(head); c.fillStyle = C.white; c.beginPath(); c.ellipse(hc[0] + 4, hc[1] + 36, 44, 34, 0, 0, TAU); c.fill();
+ c.strokeStyle = C.orangeD; c.lineWidth = 7; [[-14, -60, -10, -38], [4, -62, 4, -40], [22, -60, 18, -38]].forEach(([a0, b0, a1, b1]) => { c.beginPath(); c.moveTo(hc[0] + a0, hc[1] + b0); c.lineTo(hc[0] + a1, hc[1] + b1); c.stroke(); });
+ c.restore(); c.strokeStyle = C.ink; c.lineWidth = 5; c.stroke(head);
+ [[-22, -2], [24, -2]].forEach(([dx, dy]) => { const x = hc[0] + dx, y = hc[1] + dy;
+ if (ch.blink) { c.lineWidth = 4; c.beginPath(); c.arc(x, y, 13, 0.2, Math.PI - 0.2); c.stroke(); return; }
+ c.fillStyle = '#f8d020'; c.beginPath(); c.arc(x, y, 16, 0, TAU); c.fill(); c.lineWidth = 4; c.stroke();
+ c.fillStyle = C.ink; c.beginPath(); c.ellipse(x + 4, y + 1, 7, 12, 0, 0, TAU); c.fill(); c.fillStyle = '#fff'; c.beginPath(); c.arc(x + 7, y - 5, 4, 0, TAU); c.fill(); });
+ c.fillStyle = '#f07aa0'; c.beginPath(); c.moveTo(hc[0] - 7, hc[1] + 18); c.lineTo(hc[0] + 7, hc[1] + 18); c.lineTo(hc[0], hc[1] + 27); c.closePath(); c.fill(); c.lineWidth = 2.5; c.stroke();
+ c.lineWidth = 3.5; c.beginPath(); c.moveTo(hc[0] - 14, hc[1] + 32); c.quadraticCurveTo(hc[0] - 7, hc[1] + 40, hc[0], hc[1] + 30); c.quadraticCurveTo(hc[0] + 7, hc[1] + 40, hc[0] + 14, hc[1] + 32); c.stroke();
+ c.lineWidth = 2.5; c.beginPath(); [[-40, 22, -96, 12], [-40, 30, -98, 34], [40, 22, 98, 12], [40, 30, 100, 34]].forEach(([a0, b0, a1, b1]) => { c.moveTo(hc[0] + a0, hc[1] + b0); c.lineTo(hc[0] + a1, hc[1] + b1); }); c.stroke();
+ // 动作线:屁股旁的弧线跟着扭
+ c.strokeStyle = C.ink; c.lineWidth = 5; c.lineCap = 'round';
+ const side = wig > 0 ? 1 : -1;
+ [[0, 0], [1, 12], [2, 24]].forEach(([k, off]) => { c.beginPath(); c.arc(476 + bx + wig * 0.6, 760 + by - off, 46 + off, -Math.PI * 0.86, -Math.PI * 0.62); c.stroke(); });
+ [[0, 0], [1, 14]].forEach(([k, off]) => { c.beginPath(); c.arc(430 + bx + wig, 830 + by, 40 + off, Math.PI * (side > 0 ? 0.8 : 0.9), Math.PI * (side > 0 ? 1.05 : 1.15)); c.stroke(); });
+ }
+
+ return {
+ draw(c, lt, t) {
+ const ch = P.choreo(lt, t);
+ c.drawImage(bg(), 0, 0);
+ warhol(c, lt);
+ bubble(c, lt);
+ table(c);
+ hatch(c, 1340, 905, 170, 18);
+ const G = RIG.girl({ cup: ch.cup, sip: ch.sip, hair: 'long', breathe: ch.breathe });
+ girl(c, G, lt, t, ch);
+ const K = RIG.cat({ tail: ch.tail, blink: ch.blink, breathe: ch.breathe });
+ cat(c, K, lt, t, ch);
+ wiggleBox(c, lt);
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/14_8bit.js b/scripts/engine/scenes/14_8bit.js
new file mode 100644
index 0000000..8418bef
--- /dev/null
+++ b/scripts/engine/scenes/14_8bit.js
@@ -0,0 +1,238 @@
+// 1985 8-bit 像素游戏(超级马里奥式)——纯代码。
+// 管线:整幅在 240×135 低分辨率上逐像素画(1 低像素 = 8 屏幕像素)→ 角色用 RIG 路径缩到低分辨率填色
+// → 调色板量化 + 阈值去抗锯齿 + 每个部件单独描 1px 黑边(NES 精灵的分层描边)→ 最近邻放大 8 倍
+// → HUD 用 PressStart2P 64px(字体 1 像素 = 8 屏幕像素,坐标对齐 8 的倍数)直接画在全分辨率上。
+// 片中只停约 0.23s(可见约 11 帧),所以所有小循环都是 15–30fps 的「步进」动画,幅度按整像素给。
+SCENES['14_8bit'] = (() => {
+ const W = 1920, H = 1080, S = 8, LW = 240, LH = 135, P = PAINT;
+ const C = {
+ wall: '#064556', plus: '#0b988a', black: '#000000', white: '#fcfcfc', gray: '#bcbcbc',
+ wood: '#a77f06', woodHi: '#eeba18', brick: '#d85214', mortar: '#fbe2a6', base: '#0b988a',
+ sky0: '#0856ef', sky1: '#47c4f8', sky2: '#aae9fb', sun: '#f1bc08', hill: '#62ee58', hill2: '#0dc405',
+ red: '#e82704', redDk: '#7c0b02', blue: '#0856ef', blueDk: '#0838a8', skin: '#f9e0ab', skinDk: '#e8a878',
+ hair: '#f8d038', hairDk: '#c89010', orange: '#f39d48', orangeDk: '#d85214', pink: '#f8a0b0', leaf: '#0dc405', leafHi: '#62ee58',
+ };
+ const PAL_CHAR = ['#000000', '#fcfcfc', '#bcbcbc', '#e82704', '#7c0b02', '#0856ef', '#0838a8', '#f9e0ab', '#e8a878', '#f8d038', '#c89010', '#f39d48', '#d85214', '#f8a0b0'].map(P.hex);
+
+ // ---------- 低分辨率画布工具 ----------
+ const lc = (k) => P.cached('8b_' + k, LW, LH, () => {});
+ const px = (g, x, y, w = 1, h = 1, col) => { g.fillStyle = col; g.fillRect(x, y, w, h); };
+ // 把一层(在低分辨率上用抗锯齿画的路径)量化到调色板、alpha 阈值化,再在外轮廓描 1px 黑边
+ function spriteize(g, outline = true) {
+ const im = g.getImageData(0, 0, LW, LH), d = im.data, N = LW * LH, op = new Uint8Array(N);
+ for (let i = 0; i < N; i++) {
+ const a = d[i * 4 + 3];
+ if (a < 110) { d[i * 4 + 3] = 0; continue; }
+ // 去预乘后找最近色
+ const r = d[i * 4], gg = d[i * 4 + 1], b = d[i * 4 + 2];
+ let best = 0, bd = 1e9; for (let j = 0; j < PAL_CHAR.length; j++) { const q = PAL_CHAR[j], dd = (r - q[0]) ** 2 + (gg - q[1]) ** 2 + (b - q[2]) ** 2; if (dd < bd) { bd = dd; best = j; } }
+ const q = PAL_CHAR[best]; d[i * 4] = q[0]; d[i * 4 + 1] = q[1]; d[i * 4 + 2] = q[2]; d[i * 4 + 3] = 255; op[i] = 1;
+ }
+ if (outline) for (let y = 0; y < LH; y++) for (let x = 0; x < LW; x++) {
+ const i = y * LW + x; if (op[i]) continue;
+ if ((x > 0 && op[i - 1]) || (x < LW - 1 && op[i + 1]) || (y > 0 && op[i - LW]) || (y < LH - 1 && op[i + LW])) { d[i * 4] = 0; d[i * 4 + 1] = 0; d[i * 4 + 2] = 0; d[i * 4 + 3] = 255; }
+ }
+ g.putImageData(im, 0, 0);
+ }
+ // 一个精灵层:在低分辨率画布上以 1/8 缩放画全分辨率坐标的路径,再 spriteize
+ function layer(key, fn, outline = true) {
+ const cv = lc('L_' + key), g = cv.getContext('2d');
+ g.setTransform(1, 0, 0, 1, 0, 0); g.clearRect(0, 0, LW, LH);
+ g.save(); g.scale(1 / S, 1 / S); fn(g); g.restore();
+ spriteize(g, outline); return cv;
+ }
+
+ // ---------- 静态背景(低分辨率,逐像素) ----------
+ function background(g) {
+ px(g, 0, 0, LW, LH, C.wall);
+ // 十字点纹墙:6px 网格、隔行错 3px
+ for (let j = 0; j * 6 < 100; j++) for (let i = -1; i * 6 < LW + 6; i++) {
+ const x = i * 6 + (j % 2 ? 3 : 0) + 1, y = j * 6 + 2;
+ if (y > 97) continue;
+ px(g, x, y - 1, 1, 3, C.plus); px(g, x - 1, y, 3, 1, C.plus);
+ }
+ px(g, 0, 100, LW, 1, C.base);
+ // 木地板条
+ px(g, 0, 106, LW, 1, C.black); px(g, 0, 107, LW, 6, C.wood); px(g, 0, 107, LW, 1, C.woodHi);
+ for (let x = 7; x < LW; x += 24) px(g, x, 107, 1, 6, C.black);
+ // 砖块地面:行高 7(含缝),砖宽 16,隔行错 8
+ px(g, 0, 113, LW, LH - 113, C.black);
+ for (let r = 0; 113 + r * 7 < LH; r++) { const y = 114 + r * 7; for (let x = -16 + (r % 2 ? 8 : 0); x < LW; x += 16) {
+ px(g, x, y, 15, 6, C.brick); px(g, x, y, 15, 1, C.mortar); px(g, x, y, 1, 6, C.mortar);
+ } }
+ // 窗(45,15)-(100,73)
+ px(g, 44, 14, 57, 60, C.black); px(g, 45, 15, 55, 58, C.white); px(g, 98, 15, 2, 58, C.gray); px(g, 45, 71, 55, 2, C.gray);
+ const pane = (x0, y0, w, h) => {
+ for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) {
+ const q = (y0 + y - 17) / 52, X = x0 + x, Y = y0 + y;
+ // 天空:深蓝→浅蓝→淡蓝,交界用 2×2 棋盘抖动(NES 渐变)
+ let col = q < 0.36 ? C.sky0 : q < 0.62 ? C.sky1 : C.sky2;
+ if (Math.abs(q - 0.36) < 0.05 && (X + Y) % 2) col = C.sky1;
+ if (Math.abs(q - 0.62) < 0.05 && (X + Y) % 2) col = q < 0.62 ? C.sky2 : C.sky1;
+ px(g, X, Y, 1, 1, col);
+ }
+ };
+ pane(47, 17, 24, 25); pane(75, 17, 23, 25); pane(47, 45, 24, 25); pane(75, 45, 23, 25);
+ px(g, 71, 17, 4, 53, C.white); px(g, 73, 17, 2, 53, C.gray); px(g, 47, 42, 51, 3, C.white); px(g, 47, 44, 51, 1, C.gray);
+ // 太阳(像素圆)
+ for (let y = -4; y <= 4; y++) for (let x = -4; x <= 4; x++) if (x * x + y * y <= 17) px(g, 58 + x, 28 + y, 1, 1, (x + y < -3) ? '#f8e858' : C.sun);
+ // 绿山(下两格)
+ const hill = (cx, cy, r, x0, x1, col) => { for (let x = x0; x < x1; x++) { const h = Math.sqrt(Math.max(0, r * r - (x - cx) ** 2)); if (h <= 0) continue; const top = Math.round(cy - h); px(g, x, top, 1, 70 - top, col); px(g, x, top, 1, 1, C.black); } };
+ hill(56, 70, 9, 47, 71, C.hill); hill(66, 72, 8, 47, 71, C.hill2);
+ hill(90, 76, 18, 75, 98, C.hill2);
+ for (const [x, y] of [[52, 64], [55, 62], [86, 63], [92, 66], [80, 68]]) px(g, x, y, 2, 1, C.hill);
+ // 砖块+问号块(右下格上方)
+ for (let k = 0; k < 2; k++) { const x = 81 + k * 4; px(g, x, 47, 4, 4, C.black); px(g, x, 47, 3, 3, C.brick); px(g, x, 47, 3, 1, C.mortar); }
+ px(g, 89, 47, 4, 4, C.black); px(g, 89, 47, 3, 3, C.sun); px(g, 90, 48, 1, 1, C.black);
+ px(g, 43, 73, 59, 3, C.black); px(g, 43, 73, 59, 2, C.gray); px(g, 43, 73, 59, 1, C.white);
+ // 鱼画框
+ px(g, 114, 29, 20, 15, C.black); px(g, 115, 30, 18, 13, C.woodHi); px(g, 117, 32, 14, 9, C.sky2);
+ px(g, 120, 35, 7, 3, C.brick); px(g, 119, 36, 1, 1, C.brick); px(g, 127, 34, 2, 5, C.brick); px(g, 121, 35, 1, 1, C.black);
+ px(g, 123, 27, 2, 2, C.gray);
+ // 椅子(梯背,人后面)
+ px(g, 178, 57, 3, 57, C.black); px(g, 179, 58, 2, 55, C.woodHi);
+ px(g, 185, 59, 3, 55, C.black); px(g, 186, 60, 2, 53, C.woodHi);
+ for (let k = 0; k < 4; k++) { px(g, 180, 63 + k * 7, 6, 2, C.black); px(g, 180, 63 + k * 7, 6, 1, C.wood); }
+ px(g, 160, 91, 28, 3, C.black); px(g, 160, 91, 28, 2, C.woodHi);
+ px(g, 163, 94, 2, 19, C.woodHi); px(g, 162, 94, 1, 19, C.black);
+ // 桌子 (102,80)-(150,113)
+ px(g, 101, 79, 50, 4, C.black); px(g, 102, 79, 48, 2, C.woodHi); px(g, 102, 81, 48, 1, C.wood);
+ px(g, 104, 83, 44, 3, C.wood); px(g, 104, 85, 44, 1, C.black);
+ for (const x of [106, 144]) { px(g, x - 1, 86, 4, 27, C.black); px(g, x, 86, 2, 27, C.woodHi); }
+ px(g, 107, 102, 38, 2, C.black); px(g, 107, 102, 38, 1, C.wood);
+ }
+ // 盆栽(会摆):叶子用整像素偏移 sway
+ function plant(g, sway) {
+ const pot = (x, y, w, h) => { px(g, x - 1, y - 1, w + 2, h + 2, C.black); px(g, x, y, w, h, C.brick); px(g, x + 1, y, 2, h, '#f39d48'); };
+ pot(208, 99, 20, 13); px(g, 206, 97, 24, 3, C.black); px(g, 207, 97, 22, 2, C.brick);
+ px(g, 217, 82, 2, 16, C.black); px(g, 218, 82, 1, 16, C.leaf);
+ const leaf = (cx, cy, w, h, dx) => { // 圆角像素叶:先画黑色外轮廓(缺角),再填绿、上沿一行高光、中间一条叶脉
+ const x0 = cx + dx - w / 2;
+ for (let j = -1; j <= h; j++) { const cut = (j === -1 || j === h) ? 1 : 0; px(g, x0 - 1 + cut, cy + j, w + 2 - cut * 2, 1, C.black); }
+ for (let j = 0; j < h; j++) { const cut = (j === 0 || j === h - 1) ? 1 : 0; px(g, x0 + cut, cy + j, w - cut * 2, 1, C.leaf); }
+ px(g, x0 + 1, cy, w - 3, 1, C.leafHi); px(g, x0 + 1, cy + (h >> 1), w - 2, 1, '#0a8a04');
+ };
+ leaf(218, 70, 6, 6, sway); leaf(213, 76, 6, 4, sway); leaf(224, 76, 6, 4, sway);
+ leaf(209, 84, 8, 4, Math.round(sway * 0.6)); leaf(227, 84, 8, 4, Math.round(sway * 0.6)); leaf(212, 91, 7, 3, 0); leaf(225, 91, 7, 3, 0);
+ }
+
+ // ---------- HUD(全分辨率,PressStart2P 64px,对齐 8px 网格) ----------
+ const BM = { // 位图:. 透明 o 橘 w 白 k 黑 r 红 p 粉
+ cat: ['o.....o.', 'oo...oo.', 'ooooooo.', 'okoooko.', 'ooopooo.', 'wwwwwww.', '.wwwww..'],
+ heart: ['.rr.rr.', 'rrrrrrr', 'rrrrrrr', '.rrrrr.', '..rrr..', '...r...'],
+ heartE: ['.ww.ww.', 'w..w..w', 'w.....w', '.w...w.', '..w.w..', '...w...'],
+ apple: ['...w....', '..w.....', '.wwwwww.', 'wwwwwwww', 'wwwwwwkw', 'wwwwwwww', '.wwwwww.', '..w..w..'],
+ };
+ const COL = { o: C.orange, w: C.white, k: C.black, r: C.red, p: C.pink, R: C.white };
+ const bitmap = (c, rows, x, y, map = COL, shadow = true) => {
+ if (shadow) rows.forEach((row, j) => [...row].forEach((ch, i) => { if (ch !== '.') { c.fillStyle = '#0b1d24'; c.fillRect(x + i * S + S, y + j * S + S, S, S); } }));
+ rows.forEach((row, j) => [...row].forEach((ch, i) => { if (ch !== '.') { c.fillStyle = map[ch]; c.fillRect(x + i * S, y + j * S, S, S); } }));
+ };
+ const text = (c, s, x, y) => { c.font = '48px "PressStart2P-400"'; c.textBaseline = 'top'; c.fillStyle = '#0b1d24'; c.fillText(s, x + S, y + S); c.fillStyle = C.white; c.fillText(s, x, y); };
+ function hud(c, lt) {
+ bitmap(c, BM.cat, 64, 40);
+ text(c, 'x9', 144, 48);
+ // 心:第 630 帧(本段 lt≈0.19)闪一下——两颗满心变白、空心变红,2 帧一换
+ const fl = lt > 0.16 && lt < 0.23 && Math.floor(lt * 30) % 2 === 0;
+ const red = fl ? { ...COL, r: C.white } : COL, emp = fl ? { ...COL, w: C.red } : COL;
+ bitmap(c, BM.heart, 312, 48, red); bitmap(c, BM.heart, 384, 48, red); bitmap(c, fl ? BM.heart.map(r => r) : BM.heartE, 456, 48, fl ? { ...COL, r: C.red } : emp);
+ text(c, 'WORLD 1-1', 624, 48);
+ bitmap(c, BM.apple, 1168, 40);
+ text(c, 'x03', 1248, 48);
+ }
+
+ // ---------- 角色 ----------
+ const legs = (g, G) => { // 牛仔裤腿+白球鞋(替换 RIG 的裙子)
+ const hip = G.hipSeat, knee = [1222, 724], ank = [1214, 872];
+ g.fillStyle = C.blueDk; g.fill(RIG.taper([hip[0] + 10, hip[1] - 6], [knee[0] + 26, knee[1] - 8], 84, 70)); g.fill(RIG.taper([knee[0] + 26, knee[1] - 8], [ank[0] + 30, ank[1]], 64, 50));
+ g.fillStyle = C.blue; g.fill(RIG.taper(hip, knee, 92, 76)); g.fill(RIG.taper(knee, ank, 70, 56));
+ g.fillStyle = C.white; g.fill(RIG.smooth([[1150, 868], [1238, 862], [1250, 900], [1124, 904], [1118, 888]]));
+ g.fillStyle = C.red; g.fillRect(1176, 880, 30, 8);
+ };
+ function girlLayers(ch, lt) {
+ const G = RIG.girl({ cup: ch.cup, sip: ch.sip, hair: 'long', breathe: ch.breathe });
+ // 每个部件单独成层、单独描黑边:NES 精灵靠这些「内轮廓」分出头发/脸/手臂
+ const back = layer('gBack', g => { g.fillStyle = C.red; g.fill(G.farSleeve); g.fillStyle = C.skin; g.fill(G.farHand); });
+ const body = layer('gBody', g => {
+ legs(g, G);
+ g.fillStyle = C.red; g.fill(G.torso);
+ g.fillStyle = C.redDk; g.fillRect(G.A.waist[0] - 40, G.A.waist[1] - 18, 120, 16); // 毛衣下摆罗纹
+ g.fillStyle = C.red; g.fillRect(G.A.neck[0] - 28, G.A.neck[1] - 10, 56, 22); // 高领
+ });
+ const hair = layer('gHair', g => { g.fillStyle = C.hair; g.fill(G.hairBack); g.fill(G.hairDown); g.fillStyle = C.hairDk; g.fillRect(G.A.nape[0] + 10, G.A.nape[1] + 20, 14, 120); });
+ const face = layer('gFace', g => { g.fillStyle = C.skin; g.fill(G.face); g.beginPath(); g.ellipse(G.ear[0], G.ear[1], 9, 13, 0.2, 0, 7); g.fill(); });
+ const bangs = layer('gBangs', g => { g.fillStyle = C.hair; g.fill(G.bangs); });
+ const arm = layer('gArm', g => {
+ g.fillStyle = C.red; g.fill(G.upperArm); g.fill(G.foreArm); g.fillStyle = C.redDk; g.fill(G.cuff);
+ g.fillStyle = C.skin; g.fill(G.hand);
+ });
+ return { G, back, body, hair, face, bangs, arm };
+ }
+ // 白底红条马克杯:直接在低分辨率上逐像素画(6×5 + 把手),杯子跟着手走
+ function cupPx(g, G) {
+ const x = Math.round(G.cup.x / S) - 3, y = Math.round(G.cup.y / S);
+ px(g, x - 1, y - 1, 8, 7, C.black); px(g, x + 6, y, 3, 4, C.black); px(g, x + 6, y + 1, 2, 2, C.white); px(g, x + 6, y + 1, 1, 2, C.black);
+ px(g, x, y, 6, 5, C.white); px(g, x, y, 6, 1, C.gray); px(g, x, y + 2, 6, 1, C.red); px(g, x, y + 4, 6, 1, C.red); px(g, x + 5, y + 1, 1, 4, C.gray);
+ px(g, Math.round(G.thumb[0] / S), Math.round(G.thumb[1] / S), 2, 2, C.skin);
+ return [x + 3, y - 1];
+ }
+ function catLayers(ch, lt) {
+ // 尾巴:15fps 步进,4 个姿态循环(像素动画的「两三张图交替」)
+ const step = Math.floor(lt * 15) % 4, tail = [-0.55, 0, 0.55, 0][step];
+ const K = RIG.cat({ tail, blink: ch.blink, breathe: 0 });
+ const body = layer('catB', g => {
+ g.lineCap = 'round'; g.strokeStyle = C.orange; g.lineWidth = K.tailW; g.stroke(K.tail);
+ const tip = K.tailPts[K.tailPts.length - 1]; g.fillStyle = C.white; g.beginPath(); g.arc(tip[0], tip[1], 14, 0, 7); g.fill();
+ g.fillStyle = C.orange; g.fill(K.body);
+ g.fillStyle = C.white; g.fill(K.white); K.legs.forEach(l => g.fill(l));
+ g.strokeStyle = C.orangeDk; g.lineWidth = 9; K.stripes.slice(3).forEach(s => { g.beginPath(); g.moveTo(...s[0]); g.lineTo(...s[1]); g.stroke(); });
+ });
+ const head = layer('catH', g => {
+ g.fillStyle = C.orange; g.fill(K.head);
+ g.save(); g.clip(K.head); g.fillStyle = C.white; g.beginPath(); g.ellipse(K.nose[0] - 14, K.nose[1] + 20, 34, 22, 0, 0, 7); g.fill(); g.restore();
+ g.strokeStyle = C.orangeDk; g.lineWidth = 9; K.stripes.slice(0, 3).forEach(s => { g.beginPath(); g.moveTo(...s[0]); g.lineTo(...s[1]); g.stroke(); });
+ g.fillStyle = C.pink; K.earInner.forEach(e => { g.beginPath(); e.forEach((p, i) => i ? g.lineTo(...p) : g.moveTo(...p)); g.fill(); });
+ });
+ return { K, body, head };
+ }
+
+ return {
+ draw(c, lt, t) {
+ const ch = P.choreo(lt, t);
+ const L = lc('frame'), g = L.getContext('2d');
+ g.setTransform(1, 0, 0, 1, 0, 0);
+ g.drawImage(P.cached('8b_bg', LW, LH, background), 0, 0);
+ // 窗里的云:2 帧挪 1px 往左;问号块 lt≈0.08 起顶出一枚金币(上去再落回)
+ const cx = 92 - Math.floor(lt * 30);
+ for (const [x, y, w] of [[cx - 34, 35, 8], [cx, 22, 9]]) { if (x < 47 || x + w > 98 || (x + w > 70 && x < 75)) continue; px(g, x + 1, y - 1, w - 2, 1, C.white); px(g, x, y, w, 2, C.white); px(g, x, y + 2, w, 1, C.gray); }
+ const cq = (lt - 0.06) / 0.16;
+ if (cq > 0 && cq < 1) { const y = Math.round(46 - Math.sin(cq * Math.PI) * 9); px(g, 90, y - 3, 2, 3, C.sun); px(g, 90, y - 3, 1, 3, '#f8e858'); }
+ // 盆栽在 630 帧(lt≈0.19)抖一下
+ const sw = lt > 0.15 && lt < 0.24 ? [0, 1, 0, -1][Math.floor(lt * 30) % 4] : 0;
+ plant(g, sw);
+ // 角色
+ const CL = catLayers(ch, lt), K = CL.K;
+ g.drawImage(CL.body, 0, 0); g.drawImage(CL.head, 0, 0);
+ // 猫脸:像素眼(2×2 黑+1 白高光)、粉鼻、白胡须
+ K.eyes.forEach(e => { const x = Math.round(e.x / S), y = Math.round(e.y / S); if (ch.blink) px(g, x - 1, y, 2, 1, C.black); else { px(g, x - 1, y - 1, 2, 2, C.black); px(g, x - 1, y - 1, 1, 1, C.white); } });
+ px(g, Math.round(K.nose[0] / S), Math.round(K.nose[1] / S), 1, 1, C.pink);
+ const hx = Math.round((K.headC[0] + 70) / S), hy = Math.round(K.headC[1] / S) + 2;
+ px(g, hx, hy, 3, 1, C.white); px(g, hx, hy + 2, 3, 1, C.white); px(g, hx - 17, hy + 1, 2, 1, C.white); px(g, hx - 17, hy + 3, 2, 1, C.white);
+ const GL = girlLayers(ch, lt), G = GL.G;
+ g.drawImage(GL.back, 0, 0); g.drawImage(GL.body, 0, 0); g.drawImage(GL.hair, 0, 0); g.drawImage(GL.face, 0, 0); g.drawImage(GL.bangs, 0, 0);
+ // 少女五官(逐像素):1×2 黑眼+眉、腮红、红唇
+ const ex = Math.round(G.eye.x / S), ey = Math.round(G.eye.y / S);
+ if (ch.blink) px(g, ex - 1, ey, 2, 1, C.black); else { px(g, ex, ey - 1, 1, 2, C.black); px(g, ex - 1, ey - 3, 2, 1, C.hairDk); }
+ px(g, Math.round(G.cheek[0] / S) - 1, Math.round(G.cheek[1] / S), 2, 1, C.pink);
+ px(g, Math.round(G.lips[1][0] / S), Math.round(G.lips[1][1] / S), 1, 1, C.red);
+ g.drawImage(GL.arm, 0, 0);
+ const [sx, sy0] = cupPx(g, G);
+ // 像素热气:三列 1×2 的点,30fps 每帧上移 1px,循环 6px
+ const ph = Math.floor(lt * 30), sy = sy0 - 1;
+ for (let k = 0; k < 3; k++) for (let j = 0; j < 2; j++) { const y = sy - ((ph + k * 2 + j * 3) % 6) - j * 3; px(g, sx - 2 + k * 2 + ((ph + k) % 2), y, 1, 2, k === 1 ? C.white : C.gray); }
+ // 放大 8 倍(最近邻)
+ c.imageSmoothingEnabled = false; c.drawImage(L, 0, 0, LW, LH, 0, 0, W, H); c.imageSmoothingEnabled = true;
+ hud(c, lt);
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/15_raytrace.js b/scripts/engine/scenes/15_raytrace.js
new file mode 100644
index 0000000..1183897
--- /dev/null
+++ b/scripts/engine/scenes/15_raytrace.js
@@ -0,0 +1,300 @@
+// 1993 早期光线追踪 CGI——纯代码(不用 3D 引擎)。
+// 管线:①静态底(青绿墙+窗外粉紫夕阳远山,缓存)→ ②逐像素透视棋盘地面(2×2 超采样,缓存)
+// → ③物体层(椅/玻璃桌/少女/猫)先「倒着」画一遍当地面反射(按各自接地线镜像、半透明、往下渐隐)→ ④正着画物体
+// → ⑤道具(绿锥、铬球逐像素环境映射、紫环 48 颗球按深度排序拼成圆环并自转)→ ⑥镜头光晕(lighter 叠加)。
+// 「90 年代塑料感」= 每个部件:底色 → 径向渐变(高光点亮、边缘压暗)→ 左侧青色环境反光 → 一颗硬边白色镜面高光。
+SCENES['15_raytrace'] = (() => {
+ const W = 1920, H = 1080, P = PAINT, { clamp, lerp } = U;
+ const FLOOR_Y = 790, VP = [960, 480];
+ const SUN = [695, 225];
+ const rgba = (h, a) => P.rgb(P.hex(h), a);
+
+ // ---------- 塑料着色 ----------
+ // 球面感:(hx,hy) 高光中心,R 影响半径;dark 边缘压暗量
+ function plastic(c, path, base, hx, hy, R, { dark = 0.42, spec = 0.85, specR = 0.16, rim = true, specAng = -0.5 } = {}) {
+ c.fillStyle = base; c.fill(path);
+ c.save(); c.clip(path);
+ const g = c.createRadialGradient(hx, hy, 0, hx + R * 0.25, hy + R * 0.3, R);
+ g.addColorStop(0, 'rgba(255,255,255,.55)'); g.addColorStop(0.28, 'rgba(255,255,255,.06)'); g.addColorStop(0.62, 'rgba(0,0,0,0)'); g.addColorStop(1, `rgba(10,0,30,${dark})`);
+ c.fillStyle = g; c.fillRect(hx - R * 3, hy - R * 3, R * 6, R * 6);
+ if (rim) { c.globalCompositeOperation = 'lighter'; c.lineWidth = R * 0.18; c.strokeStyle = 'rgba(70,150,150,.28)'; c.translate(-R * 0.04, 0); c.stroke(path); c.globalCompositeOperation = 'source-over'; }
+ c.restore();
+ if (spec) { c.save(); c.clip(path); c.fillStyle = `rgba(255,255,255,${spec})`; c.beginPath(); c.ellipse(hx, hy, R * specR, R * specR * 0.55, specAng, 0, 7); c.fill(); c.restore(); }
+ }
+ // 圆柱感:沿 A→B 的肢体,渐变横跨宽度方向
+ function cyl(c, path, base, A, B, w, { spec = 0.7 } = {}) {
+ c.fillStyle = base; c.fill(path);
+ const a = Math.atan2(B[1] - A[1], B[0] - A[0]), nx = Math.cos(a + Math.PI / 2), ny = Math.sin(a + Math.PI / 2);
+ const M = [(A[0] + B[0]) / 2, (A[1] + B[1]) / 2];
+ const s = ny < 0 ? -1 : 1; // 让渐变从「上方」到「下方」
+ const g = c.createLinearGradient(M[0] - nx * s * w / 2, M[1] - ny * s * w / 2, M[0] + nx * s * w / 2, M[1] + ny * s * w / 2);
+ g.addColorStop(0, 'rgba(10,0,30,.25)'); g.addColorStop(0.22, 'rgba(255,255,255,.5)'); g.addColorStop(0.34, 'rgba(255,255,255,.08)'); g.addColorStop(0.7, 'rgba(0,0,0,.05)'); g.addColorStop(1, 'rgba(10,0,30,.45)');
+ c.save(); c.clip(path); c.fillStyle = g; c.fillRect(Math.min(A[0], B[0]) - w * 2, Math.min(A[1], B[1]) - w * 2, Math.abs(B[0] - A[0]) + w * 4, Math.abs(B[1] - A[1]) + w * 4);
+ if (spec) { c.strokeStyle = `rgba(255,255,255,${spec})`; c.lineWidth = w * 0.09; c.lineCap = 'round'; const o = w * 0.22 * s; c.beginPath(); c.moveTo(lerp(A[0], B[0], .2) - nx * o, lerp(A[1], B[1], .2) - ny * o); c.lineTo(lerp(A[0], B[0], .75) - nx * o, lerp(A[1], B[1], .75) - ny * o); c.stroke(); }
+ c.restore();
+ }
+
+ // ---------- 静态底:墙、踢脚线、窗 ----------
+ function background(g) {
+ const wg = g.createRadialGradient(560, 260, 50, 700, 400, 1500); wg.addColorStop(0, '#7dbcb9'); wg.addColorStop(0.45, '#64a6a6'); wg.addColorStop(1, '#3f8285');
+ g.fillStyle = wg; g.fillRect(0, 0, W, FLOOR_Y);
+ // 窗的投影(右下偏移、软边)
+ g.save(); g.filter = 'blur(10px)'; g.fillStyle = 'rgba(20,60,70,.45)'; g.fillRect(372, 140, 450, 452); g.restore();
+ // 窗外:粉紫夕阳
+ g.save(); g.beginPath(); g.rect(375, 135, 410, 410); g.clip();
+ const sg = g.createLinearGradient(0, 135, 0, 480); sg.addColorStop(0, '#a24cc4'); sg.addColorStop(0.45, '#df62ae'); sg.addColorStop(0.8, '#f5a08a'); sg.addColorStop(1, '#f8c070');
+ g.fillStyle = sg; g.fillRect(375, 135, 410, 410);
+ // 远山(两层)+雪顶+线框网格
+ const mtn = (pts, col, snow) => {
+ g.beginPath(); g.moveTo(375, 545); pts.forEach(p => g.lineTo(...p)); g.lineTo(785, 545); g.closePath();
+ const mg = g.createLinearGradient(0, 340, 0, 545); mg.addColorStop(0, col[0]); mg.addColorStop(1, col[1]); g.fillStyle = mg; g.fill();
+ g.save(); g.clip(); g.strokeStyle = 'rgba(255,170,230,.45)'; g.lineWidth = 1.5;
+ for (let x = 375; x < 785; x += 28) { g.beginPath(); g.moveTo(x, 330); g.lineTo(x, 545); g.stroke(); }
+ for (let y = 360; y < 545; y += 26) { g.beginPath(); g.moveTo(375, y); g.lineTo(785, y); g.stroke(); }
+ g.fillStyle = '#fbeef6'; snow.forEach(([x, y, w]) => { g.beginPath(); g.moveTo(x - w, y + w * 0.9); g.lineTo(x, y); g.lineTo(x + w, y + w * 0.9); g.lineTo(x + w * 0.4, y + w * 0.6); g.lineTo(x, y + w * 0.95); g.lineTo(x - w * 0.5, y + w * 0.6); g.closePath(); g.fill(); });
+ g.restore();
+ };
+ mtn([[375, 380], [430, 352], [462, 345], [520, 400], [585, 440], [640, 420], [700, 390], [760, 395], [785, 400]], ['#b06ab8', '#8a50a8'], [[462, 345, 30], [700, 390, 22], [430, 352, 18]]);
+ mtn([[375, 470], [470, 430], [560, 470], [610, 440], [690, 480], [785, 440]], ['#8f5aa8', '#6c3f94'], [[610, 440, 18], [470, 430, 16]]);
+ g.restore();
+ // 白窗框(立体:亮边+暗边)
+ const frame = (x, y, w, h) => { const fg = g.createLinearGradient(x, y, x + w, y + h); fg.addColorStop(0, '#ffffff'); fg.addColorStop(1, '#d6dde0'); g.fillStyle = fg; g.fillRect(x, y, w, h); };
+ frame(355, 118, 445, 18); frame(355, 118, 20, 437); frame(783, 118, 17, 437); frame(355, 538, 445, 17); frame(571, 135, 14, 405); frame(375, 330, 410, 14);
+ g.fillStyle = 'rgba(0,40,60,.25)'; g.fillRect(375, 136, 410, 4); g.fillRect(375, 136, 4, 402);
+ // 窗台
+ const sl = g.createLinearGradient(0, 555, 0, 572); sl.addColorStop(0, '#ffffff'); sl.addColorStop(1, '#c9d2d6'); g.fillStyle = sl; g.fillRect(330, 555, 490, 16);
+ g.fillStyle = 'rgba(20,60,70,.35)'; g.fillRect(340, 571, 490, 12);
+ // 踢脚线
+ const bb = g.createLinearGradient(0, 760, 0, FLOOR_Y); bb.addColorStop(0, '#ffffff'); bb.addColorStop(1, '#d9dde0'); g.fillStyle = bb; g.fillRect(0, 760, W, FLOOR_Y - 760);
+ g.fillStyle = 'rgba(0,40,50,.25)'; g.fillRect(0, 756, W, 4);
+ }
+ // ---------- 透视棋盘地面(逐像素、2×2 超采样) ----------
+ function floor(g) {
+ const im = g.createImageData(W, H), d = im.data, TX = 0.27, TZ = 0.00029;
+ const A = P.hex('#d9dadf'), B = P.hex('#3e5d62');
+ for (let y = FLOOR_Y; y < H; y++) for (let x = 0; x < W; x++) {
+ let s = 0;
+ for (let k = 0; k < 4; k++) {
+ const yy = y + (k >> 1) * 0.5 + 0.25, xx = x + (k & 1) * 0.5 + 0.25, dy = yy - VP[1];
+ const X = (xx - VP[0]) / dy, Z = 1 / dy;
+ s += ((Math.floor(X / TX + 0.5) + Math.floor(Z / TZ)) & 1);
+ }
+ const q = s / 4, i = (y * W + x) * 4, fog = clamp(1 - (y - FLOOR_Y) / 140) * 0.35;
+ for (let ch = 0; ch < 3; ch++) d[i + ch] = lerp(lerp(A[ch], B[ch], q), [150, 190, 192][ch], fog);
+ d[i + 3] = 255;
+ }
+ g.putImageData(im, 0, 0);
+ // 地面上的环境光:窗光在地上的亮斑
+ const lg = g.createRadialGradient(560, 900, 20, 560, 900, 520); lg.addColorStop(0, 'rgba(255,200,230,.22)'); lg.addColorStop(1, 'rgba(255,200,230,0)');
+ g.fillStyle = lg; g.fillRect(0, FLOOR_Y, W, H - FLOOR_Y);
+ }
+
+ // ---------- 家具 ----------
+ function chair(c) {
+ const wood = '#b77a40', post = (x, y0, y1, w) => { const p = new Path2D(); p.rect(x, y0, w, y1 - y0); cyl(c, p, wood, [x + w / 2, y0], [x + w / 2, y1], w, { spec: 0.5 }); grain(c, x, y0, w, y1 - y0); };
+ post(1478, 455, 912, 22); post(1442, 470, 760, 18);
+ for (let k = 0; k < 4; k++) { const p = new Path2D(); p.rect(1444, 500 + k * 52, 52, 12); cyl(c, p, '#a86a34', [1444, 506 + k * 52], [1496, 506 + k * 52], 12, { spec: 0.4 }); }
+ const seat = new Path2D(); seat.rect(1290, 738, 214, 22); cyl(c, seat, wood, [1290, 749], [1504, 749], 22); grain(c, 1290, 738, 214, 22);
+ post(1312, 760, 900, 18);
+ }
+ function grain(c, x, y, w, h) { // 木纹:细噪声线
+ c.save(); c.beginPath(); c.rect(x, y, w, h); c.clip(); c.strokeStyle = 'rgba(90,45,15,.35)'; c.lineWidth = 1.2;
+ const r = U.rng((x * 7 + y) | 0), vert = h > w;
+ for (let k = 0; k < (vert ? w : h) / 3; k++) { const o = r() * (vert ? w : h); c.beginPath(); for (let s = 0; s <= 20; s++) { const q = s / 20, n = P.noise(o * 0.3 + k, q * 4) * 3; vert ? (s ? c.lineTo(x + o + n, y + q * h) : c.moveTo(x + o + n, y + q * h)) : (s ? c.lineTo(x + q * w, y + o + n) : c.moveTo(x + q * w, y + o + n)); } c.stroke(); }
+ c.restore();
+ }
+ function table(c) {
+ // 大理石柱:竖向凹槽 + 圆柱明暗
+ const col = new Path2D(); col.rect(984, 664, 52, 212); cyl(c, col, '#efe6ea', [984, 770], [1036, 770], 52, { spec: 0 });
+ c.save(); c.clip(col); c.strokeStyle = 'rgba(120,100,140,.35)'; c.lineWidth = 2; for (let x = 990; x < 1036; x += 9) { c.beginPath(); c.moveTo(x, 664); c.lineTo(x, 876); c.stroke(); }
+ c.strokeStyle = 'rgba(150,130,170,.25)'; c.lineWidth = 1.5; c.beginPath(); for (let s = 0; s < 30; s++) c.lineTo(990 + P.noise(s * 0.3, 2) * 30 + 20, 664 + s * 7.3); c.stroke(); c.restore();
+ const lg = c.createLinearGradient(984, 0, 1036, 0); lg.addColorStop(0, 'rgba(255,255,255,0)'); lg.addColorStop(0.3, 'rgba(255,255,255,.6)'); lg.addColorStop(0.45, 'rgba(255,255,255,0)'); c.fillStyle = lg; c.fillRect(984, 664, 52, 212);
+ // 底座
+ const base = new Path2D(); base.ellipse(1010, 884, 56, 14, 0, 0, 7); base.rect(954, 872, 112, 12); plastic(c, base, '#e9e1e6', 985, 876, 80, { spec: 0.6, rim: false });
+ const cap = new Path2D(); cap.ellipse(1010, 668, 40, 9, 0, 0, 7); plastic(c, cap, '#efe6ea', 995, 664, 50, { spec: 0, rim: false });
+ }
+ function glassTop(c, t) {
+ // 玻璃桌面:半透明绿 + 厚边 + 高光条 + 一道会滑动的反光
+ c.save();
+ const top = new Path2D(); top.ellipse(1010, 650, 192, 20, 0, 0, 7);
+ const edge = new Path2D(); edge.ellipse(1010, 660, 192, 20, 0, 0, Math.PI); edge.lineTo(818, 650); edge.ellipse(1010, 650, 192, 20, 0, Math.PI, 0, true); edge.closePath();
+ c.fillStyle = 'rgba(40,140,90,.75)'; c.fill(edge);
+ const tg = c.createLinearGradient(818, 630, 1202, 670); tg.addColorStop(0, 'rgba(140,230,190,.55)'); tg.addColorStop(0.5, 'rgba(70,170,120,.45)'); tg.addColorStop(1, 'rgba(30,110,80,.6)');
+ c.fillStyle = tg; c.fill(top);
+ c.strokeStyle = 'rgba(220,255,240,.8)'; c.lineWidth = 2; c.stroke(top);
+ c.clip(top); const sx = 860 + ((t * 260) % 420);
+ c.fillStyle = 'rgba(255,255,255,.35)'; c.beginPath(); c.moveTo(sx, 630); c.lineTo(sx + 40, 630); c.lineTo(sx + 10, 672); c.lineTo(sx - 30, 672); c.fill();
+ c.restore();
+ }
+ // ---------- 角色(塑料人偶) ----------
+ const SK = '#f2c39c', HAIR = '#f6c624', RED = '#e3283c', BLUE = '#2c55d8';
+ function girl(c, G) {
+ const A = G.A;
+ plastic(c, G.farSleeve, '#b81f30', 1300, 560, 140, { spec: 0.4 });
+ plastic(c, G.farHand, SK, 1170, 608, 50, { spec: 0.7 });
+ // 腿:牛仔蓝塑料圆柱
+ const hip = G.hipSeat, knee = [1222, 722], ank = [1212, 870];
+ const th2 = RIG.taper([hip[0] + 14, hip[1] - 4], [knee[0] + 30, knee[1] - 8], 84, 70); cyl(c, th2, '#1e3c9c', hip, knee, 84, { spec: 0.3 });
+ const sh2 = RIG.taper([knee[0] + 30, knee[1] - 8], [ank[0] + 30, ank[1]], 62, 52); cyl(c, sh2, '#1e3c9c', knee, ank, 62, { spec: 0.3 });
+ const th = RIG.taper(hip, knee, 92, 78), sh = RIG.taper(knee, ank, 72, 58);
+ cyl(c, sh, BLUE, knee, ank, 72); cyl(c, th, BLUE, hip, knee, 92);
+ const kneeBall = new Path2D(); kneeBall.arc(knee[0], knee[1], 40, 0, 7); plastic(c, kneeBall, BLUE, knee[0] - 14, knee[1] - 16, 60, { spec: 0.6 });
+ const shoe = RIG.smooth([[1150, 868], [1238, 860], [1252, 902], [1124, 906], [1116, 890]]); plastic(c, shoe, '#5a2c1c', 1160, 872, 80, { spec: 0.8 });
+ // 身体
+ plastic(c, G.torso, RED, 1318, 478, 200, { spec: 0.75, specR: 0.1 });
+ plastic(c, G.neck, SK, 1296, 420, 40, { spec: 0 });
+ // 头发(后)、脸、刘海——塑料头发要有几条亮带
+ if (G.hairDown) plastic(c, G.hairDown, HAIR, 1380, 470, 140, { spec: 0.5 });
+ plastic(c, G.hairBack, HAIR, 1330, 320, 130, { spec: 0.8 });
+ plastic(c, G.face, SK, 1268, 340, 95, { spec: 0.55, specR: 0.12 });
+ c.fillStyle = 'rgba(240,120,120,.22)'; c.beginPath(); c.arc(G.cheek[0], G.cheek[1], 10, 0, 7); c.fill();
+ const ear = new Path2D(); ear.ellipse(G.ear[0], G.ear[1], 9, 13, 0.2, 0, 7); plastic(c, ear, SK, G.ear[0] - 3, G.ear[1] - 4, 18, { spec: 0 });
+ plastic(c, G.bangs, HAIR, 1282, 306, 80, { spec: 0.9, specR: 0.2 });
+ c.save(); c.lineCap = 'round'; G.hairLines.forEach((h, k) => { c.strokeStyle = 'rgba(255,255,230,.55)'; c.lineWidth = 5 - k; c.stroke(h); c.strokeStyle = 'rgba(180,120,0,.35)'; c.lineWidth = 2; c.translate(0, 8); c.stroke(h); c.translate(0, -8); }); c.restore();
+ // 眼(蓝色玻璃珠)、眉、唇
+ const ey = G.eye; c.fillStyle = '#fff'; c.beginPath(); c.ellipse(ey.x, ey.y, 6.5, 7, 0, 0, 7); c.fill();
+ if (G.blink) { c.strokeStyle = '#4a2a1a'; c.lineWidth = 2.5; c.stroke(G.lid); }
+ else { const ig = c.createRadialGradient(ey.x - 2, ey.y - 1, 1, ey.x - 1, ey.y + 1, 6); ig.addColorStop(0, '#6fa0ff'); ig.addColorStop(1, '#1a2c8a'); c.fillStyle = ig; c.beginPath(); c.arc(ey.x - 1.5, ey.y + 1, 5, 0, 7); c.fill(); c.fillStyle = '#fff'; c.beginPath(); c.arc(ey.x - 3, ey.y - 1.5, 1.6, 0, 7); c.fill(); c.strokeStyle = '#4a2a1a'; c.lineWidth = 2.2; c.stroke(G.lid); }
+ c.strokeStyle = '#b8862a'; c.lineWidth = 2.6; c.stroke(G.brow);
+ c.fillStyle = '#d0505a'; c.beginPath(); c.moveTo(...G.lips[0]); c.lineTo(...G.lips[1]); c.lineTo(...G.lips[2]); c.closePath(); c.fill();
+ // 近侧手臂(圆柱+球关节)、杯子、手
+ const S = A.shoulder, E = A.elbow, Hd = A.hand;
+ cyl(c, G.upperArm, RED, S, E, 54); cyl(c, G.foreArm, RED, E, Hd, 40);
+ const sb = new Path2D(); sb.arc(S[0], S[1], 30, 0, 7); plastic(c, sb, RED, S[0] - 10, S[1] - 12, 44, { spec: 0.8 });
+ // 杯子:白瓷,椭圆口+高光
+ const u = G.cup; c.save(); c.translate(u.x, u.y); c.rotate(u.tilt);
+ const body = new Path2D(); body.moveTo(-u.w / 2, 0); body.lineTo(-u.w * 0.42, u.h); body.quadraticCurveTo(0, u.h * 1.12, u.w * 0.42, u.h); body.lineTo(u.w / 2, 0); body.closePath();
+ c.strokeStyle = '#e8e8f0'; c.lineWidth = 7; c.beginPath(); c.arc(u.w * 0.55, u.h * 0.4, u.h * 0.26, -1.2, 1.4); c.stroke();
+ plastic(c, body, '#f4f2f8', -u.w * 0.2, u.h * 0.3, 40, { spec: 0.9, rim: false });
+ c.fillStyle = '#6a3a1a'; c.beginPath(); c.ellipse(0, 0, u.w / 2, u.h * 0.14, 0, 0, 7); c.fill(); c.strokeStyle = '#fff'; c.lineWidth = 2; c.stroke();
+ c.restore();
+ plastic(c, G.hand, SK, Hd[0] - 5, Hd[1] - 6, 26, { spec: 0.8 });
+ }
+ function cat(c, K, t) {
+ const O = '#ee8f2e', Wt = '#f6f2ee';
+ // 尾巴:粗管+高光线
+ c.save(); c.lineCap = 'round'; c.strokeStyle = '#b35f14'; c.lineWidth = K.tailW + 4; c.stroke(K.tail); c.strokeStyle = O; c.lineWidth = K.tailW; c.stroke(K.tail);
+ c.strokeStyle = 'rgba(255,240,200,.75)'; c.lineWidth = 4; c.translate(-2, -7); c.stroke(K.tail); c.restore();
+ const tip = K.tailPts[K.tailPts.length - 1]; const tp = new Path2D(); tp.arc(tip[0], tip[1], K.tailW / 2 + 1, 0, 7); plastic(c, tp, Wt, tip[0] - 4, tip[1] - 5, 20);
+ const body = RIG.smooth(K.bodyPts); // RIG 的猫身是折线,塑料质感要先 Catmull-Rom 平滑
+ plastic(c, body, O, 500, 735, 230, { spec: 0.8, specR: 0.09 });
+ c.save(); c.clip(body); plastic(c, K.white, Wt, 585, 720, 120, { spec: 0.5, rim: false }); c.restore();
+ c.save(); c.clip(body); const wg = c.createLinearGradient(560, 700, 650, 860); wg.addColorStop(0, 'rgba(0,0,0,0)'); wg.addColorStop(1, 'rgba(40,0,60,.3)'); c.fillStyle = wg; c.fillRect(540, 680, 140, 220); c.restore();
+ c.save(); c.clip(body); c.filter = 'blur(2px)'; c.strokeStyle = 'rgba(170,70,10,.5)'; c.lineWidth = 12; c.lineCap = 'round'; K.stripes.slice(3).forEach(s => { c.beginPath(); c.moveTo(...s[0]); c.lineTo(...s[1]); c.stroke(); }); c.restore();
+ K.legs.forEach((l, k) => { plastic(c, l, Wt, 578 + k * 44, 770, 110, { spec: 0.7, specR: 0.08, dark: 0.5 }); const pw = new Path2D(); pw.ellipse(585 + k * 50, 892, 25, 14, 0, 0, 7); plastic(c, pw, Wt, 578 + k * 50, 884, 34, { spec: 0.8, dark: 0.5 }); c.strokeStyle = 'rgba(120,90,110,.5)'; c.lineWidth = 2; [-8, 8].forEach(o => { c.beginPath(); c.moveTo(585 + k * 50 + o, 888); c.lineTo(585 + k * 50 + o, 903); c.stroke(); }); });
+ plastic(c, K.head, O, 580, 598, 100, { spec: 0.9, specR: 0.13 });
+ c.save(); c.clip(K.head); const mz = new Path2D(); mz.ellipse(K.nose[0] - 14, K.nose[1] + 16, 27, 19, 0, 0, 7); plastic(c, mz, Wt, K.nose[0] - 20, K.nose[1] + 8, 34, { spec: 0.4, rim: false, dark: 0.3 });
+ c.filter = 'blur(1.5px)'; c.strokeStyle = 'rgba(170,70,10,.5)'; c.lineWidth = 8; c.lineCap = 'round'; K.stripes.slice(0, 3).forEach(s => { c.beginPath(); c.moveTo(...s[0]); c.lineTo(...s[1]); c.stroke(); }); c.restore();
+ c.fillStyle = '#f2a0a8'; K.earInner.forEach(e => { c.beginPath(); e.forEach((p, i) => i ? c.lineTo(...p) : c.moveTo(...p)); c.fill(); });
+ c.fillStyle = '#e66a7a'; c.beginPath(); c.arc(K.nose[0], K.nose[1], 6, 0, 7); c.fill();
+ c.strokeStyle = 'rgba(255,255,255,.85)'; c.lineWidth = 1.6; K.whiskers.forEach(w => { c.beginPath(); c.moveTo(...w[0]); c.lineTo(...w[1]); c.stroke(); });
+ // 猫眼:发绿光(lighter 叠加、随时间脉动)
+ const pulse = 0.75 + 0.25 * Math.sin(t * 18);
+ K.eyes.forEach(e => {
+ c.fillStyle = '#0a3a10'; c.beginPath(); c.arc(e.x, e.y, 10, 0, 7); c.fill();
+ c.save(); c.globalCompositeOperation = 'lighter';
+ const gg = c.createRadialGradient(e.x, e.y, 0, e.x, e.y, 46 * pulse); gg.addColorStop(0, 'rgba(200,255,200,1)'); gg.addColorStop(0.25, 'rgba(80,255,120,.8)'); gg.addColorStop(1, 'rgba(40,255,90,0)');
+ c.fillStyle = gg; c.beginPath(); c.arc(e.x, e.y, 46 * pulse, 0, 7); c.fill(); c.restore();
+ });
+ }
+
+ // ---------- 道具:绿锥、铬球(逐像素环境映射)、紫环(自转) ----------
+ function cone(c) {
+ const p = new Path2D(); p.moveTo(1592, 612); p.lineTo(1660, 780); p.ellipse(1592, 780, 68, 14, 0, 0, Math.PI); p.closePath();
+ c.fillStyle = '#25835a'; c.fill(p);
+ c.save(); c.clip(p); const g = c.createLinearGradient(1524, 0, 1660, 0); g.addColorStop(0, 'rgba(0,30,20,.35)'); g.addColorStop(0.3, 'rgba(160,255,200,.55)'); g.addColorStop(0.4, 'rgba(255,255,255,.15)'); g.addColorStop(1, 'rgba(0,20,10,.55)');
+ c.fillStyle = g; c.fillRect(1520, 600, 150, 200); c.restore();
+ }
+ function chromeSphere(c, t, cx, cy, r) {
+ const sc = P.scratch('rt_sph'), g = sc.getContext('2d'), D = r * 2 + 2;
+ const im = g.createImageData(D, D), d = im.data, rot = t * 4.5;
+ for (let y = 0; y < D; y++) for (let x = 0; x < D; x++) {
+ const nx = (x - r) / r, ny = (y - r) / r, q = nx * nx + ny * ny; if (q > 1) continue;
+ const nz = Math.sqrt(1 - q), i = (y * D + x) * 4;
+ // 反射方向 R = 2(N·V)N - V, V=(0,0,1)
+ const rx = 2 * nz * nx, ry = 2 * nz * ny, rz = 2 * nz * nz - 1;
+ let col;
+ if (ry > 0.05) { // 往下看到棋盘
+ const u = rx / ry * 1.6 + rot, v = rz / ry * 1.6; const ck = (Math.floor(u * 2) + Math.floor(v * 2)) & 1; col = ck ? [40, 60, 70] : [225, 225, 235];
+ } else { const k = clamp(-ry * 1.4); col = [lerp(245, 160, k), lerp(160, 80, k), lerp(170, 200, k)]; if (Math.abs(rx - 0.4) < 0.08 && ry < -0.2 && ry > -0.7) col = [255, 255, 255]; }
+ const f = 0.35 + 0.65 * Math.pow(1 - nz, 0.3) * 0.5 + 0.3; // 边缘更亮(菲涅尔)
+ d[i] = col[0] * f + 20; d[i + 1] = col[1] * f + 20; d[i + 2] = col[2] * f + 25; d[i + 3] = 255;
+ }
+ g.clearRect(0, 0, D + 4, D + 4); g.putImageData(im, 0, 0);
+ c.drawImage(sc, 0, 0, D, D, cx - r - 1, cy - r - 1, D, D);
+ c.save(); c.globalCompositeOperation = 'lighter'; const hg = c.createRadialGradient(cx - r * 0.38, cy - r * 0.45, 0, cx - r * 0.38, cy - r * 0.45, r * 0.3); hg.addColorStop(0, 'rgba(255,255,255,1)'); hg.addColorStop(1, 'rgba(255,255,255,0)'); c.fillStyle = hg; c.beginPath(); c.arc(cx - r * 0.38, cy - r * 0.45, r * 0.3, 0, 7); c.fill(); c.restore();
+ }
+ function torus(c, t, cx, cy, R, rr) {
+ const th = t * 7, tilt = 0.35, out = [], N = 140;
+ for (let k = 0; k < N; k++) {
+ const ph = k / N * Math.PI * 2, x0 = R * Math.cos(ph), y0 = R * Math.sin(ph);
+ const X = x0 * Math.cos(th), Z = x0 * Math.sin(th);
+ const Y = y0 * Math.cos(tilt) - Z * Math.sin(tilt), Z2 = y0 * Math.sin(tilt) + Z * Math.cos(tilt);
+ out.push([cx + X, cy + Y, Z2]);
+ }
+ out.sort((a, b) => a[2] - b[2]);
+ // 先画一层暗色底让球之间连成管,再逐颗加高光
+ out.forEach(([x, y]) => { c.fillStyle = '#7a1aa0'; c.beginPath(); c.arc(x, y, rr, 0, 7); c.fill(); });
+ out.forEach(([x, y, z]) => {
+ const g = c.createRadialGradient(x - rr * 0.35, y - rr * 0.4, 1, x, y, rr); const l = 0.5 + 0.5 * z / R;
+ g.addColorStop(0, `rgba(255,${190 + l * 50},255,1)`); g.addColorStop(0.3, '#d850f6'); g.addColorStop(0.75, '#9a28c4'); g.addColorStop(1, 'rgba(110,20,150,0)');
+ c.fillStyle = g; c.beginPath(); c.arc(x, y, rr * 0.92, 0, 7); c.fill();
+ });
+ }
+ function props(c, t, mirror) {
+ // mirror: 画反射时各自按接地线镜像
+ const M = (yC, fn) => { c.save(); if (mirror) { c.translate(0, 2 * yC); c.scale(1, -1); } fn(); c.restore(); };
+ M(780, () => cone(c));
+ M(846, () => torus(c, t, 1818, 772, 52, 22));
+ M(800, () => chromeSphere(c, t, 1712, 748, 52));
+ }
+
+ // ---------- 镜头光晕 ----------
+ function flare(c, t) {
+ c.save(); c.globalCompositeOperation = 'lighter';
+ const pul = 1 + 0.08 * Math.sin(t * 23);
+ const glow = c.createRadialGradient(...SUN, 0, ...SUN, 170 * pul); glow.addColorStop(0, 'rgba(255,255,255,1)'); glow.addColorStop(0.15, 'rgba(255,240,250,.9)'); glow.addColorStop(0.4, 'rgba(255,170,220,.25)'); glow.addColorStop(1, 'rgba(255,150,220,0)');
+ c.fillStyle = glow; c.beginPath(); c.arc(...SUN, 170 * pul, 0, 7); c.fill();
+ // 星芒(缓慢旋转)
+ const rot = t * 1.6;
+ for (let k = 0; k < 12; k++) { const a = rot + k / 12 * Math.PI * 2, L = (k % 2 ? 70 : 120) * pul; const g = c.createLinearGradient(SUN[0], SUN[1], SUN[0] + Math.cos(a) * L, SUN[1] + Math.sin(a) * L); g.addColorStop(0, 'rgba(255,255,255,.8)'); g.addColorStop(1, 'rgba(255,255,255,0)'); c.strokeStyle = g; c.lineWidth = 2.5; c.beginPath(); c.moveTo(...SUN); c.lineTo(SUN[0] + Math.cos(a) * L, SUN[1] + Math.sin(a) * L); c.stroke(); }
+ // 水平长条光
+ const hs = c.createLinearGradient(220, 0, 1180, 0); hs.addColorStop(0, 'rgba(255,255,255,0)'); hs.addColorStop(0.5, `rgba(255,255,255,${0.75 * pul})`); hs.addColorStop(1, 'rgba(255,255,255,0)');
+ c.fillStyle = hs; c.fillRect(220, SUN[1] - 2, 960, 4);
+ c.strokeStyle = 'rgba(255,255,255,.18)'; c.lineWidth = 3; c.beginPath(); c.arc(...SUN, 150, 0, 7); c.stroke();
+ // 鬼影:沿 太阳→画面中心 的直线排布,随时间轻微滑动
+ const C0 = [960, 540], dx = C0[0] - SUN[0], dy = C0[1] - SUN[1], sl = Math.sin(t * 5) * 0.03;
+ [[0.62, 58, 'rgba(180,255,240,.16)', 0], [0.95, 17, 'rgba(160,255,255,.4)', 6], [1.25, 40, 'rgba(255,200,255,.12)', 6], [1.55, 34, 'rgba(200,255,230,.18)', 0], [0.8, 12, 'rgba(255,255,200,.3)', 6]].forEach(([k, r, col, sides]) => {
+ const x = SUN[0] + dx * (k + sl), y = SUN[1] + dy * (k + sl); c.fillStyle = col; c.beginPath();
+ if (sides) for (let i = 0; i < sides; i++) { const a = i / sides * Math.PI * 2 + 0.3; c.lineTo(x + Math.cos(a) * r, y + Math.sin(a) * r); } else c.arc(x, y, r, 0, 7);
+ c.closePath(); c.fill();
+ });
+ c.restore();
+ }
+
+ return {
+ draw(c, lt, t) {
+ const ch = P.choreo(lt, t);
+ c.drawImage(P.cached('rt_bg', W, H, background), 0, 0);
+ c.drawImage(P.cached('rt_floor', W, H, floor), 0, FLOOR_Y, W, H - FLOOR_Y, 0, FLOOR_Y, W, H - FLOOR_Y);
+ const K = RIG.cat({ tail: ch.tail, blink: 0, breathe: ch.breathe });
+ const G = RIG.girl({ cup: ch.cup, sip: ch.sip, hair: 'long', breathe: ch.breathe }); G.blink = ch.blink;
+ // 物体层
+ const L = P.scratch('rt_obj'), lg = L.getContext('2d'); lg.clearRect(0, 0, W, H);
+ chair(lg); table(lg); glassTop(lg, t); girl(lg, G); cat(lg, K, t);
+ // 反射:物体层按接地线 y=905 镜像,往下渐隐
+ c.save(); c.beginPath(); c.rect(0, FLOOR_Y, W, H - FLOOR_Y); c.clip();
+ c.globalAlpha = 0.34; c.translate(0, 2 * 906); c.scale(1, -1); c.drawImage(L, 0, 0); c.restore();
+ const R2 = P.scratch('rt_ref2'), rg = R2.getContext('2d'); rg.clearRect(0, 0, W, H); props(rg, t, true); // 道具反射先画到独立层再整体半透明,避免小球叠加变实
+ c.save(); c.beginPath(); c.rect(0, FLOOR_Y, W, H - FLOOR_Y); c.clip(); c.globalAlpha = 0.34; c.drawImage(R2, 0, 0); c.restore();
+ const fg = c.createLinearGradient(0, 905, 0, H); fg.addColorStop(0, 'rgba(160,190,195,0)'); fg.addColorStop(1, 'rgba(160,190,195,.25)'); c.fillStyle = fg; c.fillRect(0, 905, W, H - 905);
+ // 接触阴影
+ c.fillStyle = 'rgba(10,30,35,.35)'; [[540, 906, 130, 10], [1010, 900, 70, 8], [1190, 905, 80, 8], [1400, 912, 110, 8], [1592, 782, 70, 8]].forEach(([x, y, rx, ry]) => { c.beginPath(); c.ellipse(x, y, rx, ry, 0, 0, 7); c.fill(); });
+ c.drawImage(L, 0, 0);
+ props(c, t, false);
+ // 热气:半透明白色管状
+ P.steam(c, t, G.cup.x, G.cup.y - 6, { h: 60, n: 2, color: 'rgba(255,255,255,.7)', width: 5, spread: 14, wobble: 8 });
+ flare(c, t);
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/16_2026.js b/scripts/engine/scenes/16_2026.js
new file mode 100644
index 0000000..2d344cc
--- /dev/null
+++ b/scripts/engine/scenes/16_2026.js
@@ -0,0 +1,565 @@
+// 2026 扁平矢量插画(Dribbble 风)+ 全片笑点收尾——纯代码。
+// 结构:①静态底(米白墙/地、粉圆与淡紫色块的颗粒点彩、窗与城市剪影、桌椅地毯、盆,缓存)
+// → ②会动的环境(云左移、飞机、太阳光芒、装饰符号 4fps 沸腾、吊灯与光锥摆、两盆植物晃)
+// → ③角色(自写 2026 姿势库;少女头部/躯干取自 RIG.girl,手臂用 RIG.ik2;猫按姿势关键点插值)
+// → ④道具表演(杯子三次被拍、坠落、碎裂、咖啡渍与涟漪)→ ⑤签名手写 → ⑥角色颗粒噪点(source-atop)。
+// 所有表演时间都按「全片帧号 F = t*60」写,数字直接抄 ../拆解/分镜表.md §4。
+SCENES['16_2026'] = (() => {
+ const W = 1920, H = 1080, P = PAINT, { clamp, lerp, ease } = U;
+ const C = {
+ wall: '#f6efe2', floor: '#eedfc7', navy: '#262a5c', coral: '#e8655a', coralLt: '#f08b7d', coralDk: '#d1514a',
+ pink: '#f5cdc6', pinkDot: '#e8807b', lav: '#e4dbf6', lavDot: '#b9a4ea', red: '#e65a52', yellow: '#f2b33d', sun: '#f3b13c',
+ green: '#2f8a5d', greenDk: '#22704a', greenLt: '#57b07a', mint: '#d6ece0', chair: '#7cb791', white: '#fffaf2',
+ skin: '#f8d3bd', skinDk: '#eab79f', hair: '#f4c24f', hairDk: '#dca23a', blush: '#f39a8d', pants: '#262a5c', sock: '#b9a4ea',
+ orange: '#f0a23c', orangeDk: '#d8832a', catWhite: '#fff8ee', earIn: '#f4aaa0', laptop: '#9a88df', laptopDk: '#7563c4',
+ coffee: '#b8782f', coffeeLt: '#d79a4a', cup: '#e35b55', cupDk: '#c4433e',
+ };
+ const FR = t => t * 60; // 全片帧号
+ const seg = (f, a, b) => clamp((f - a) / (b - a));
+ // 关键帧插值:[[帧, 值], ...],段内 ease
+ const kf = (f, tab, e = ease.inOut) => { if (f <= tab[0][0]) return tab[0][1]; for (let i = 1; i < tab.length; i++) if (f <= tab[i][0]) { const q = (f - tab[i - 1][0]) / (tab[i][0] - tab[i - 1][0]); return lerp(tab[i - 1][1], tab[i][1], e(q)); } return tab[tab.length - 1][1]; };
+ // 点表的 Catmull-Rom 插值(分镜表的质心/杯子轨迹都是每 2 帧一个实测点)
+ const path = (f, tab) => {
+ if (f <= tab[0][0]) return [tab[0][1], tab[0][2]]; const n = tab.length; if (f >= tab[n - 1][0]) return [tab[n - 1][1], tab[n - 1][2]];
+ let i = 1; while (tab[i][0] < f) i++;
+ const p0 = tab[Math.max(0, i - 2)], p1 = tab[i - 1], p2 = tab[i], p3 = tab[Math.min(n - 1, i + 1)], q = (f - p1[0]) / (p2[0] - p1[0]);
+ const cr = (a, b, c, d) => 0.5 * (2 * b + (-a + c) * q + (2 * a - 5 * b + 4 * c - d) * q * q + (-a + 3 * b - 3 * c + d) * q * q * q);
+ return [cr(p0[1], p1[1], p2[1], p3[1]), cr(p0[2], p1[2], p2[2], p3[2])];
+ };
+ // 阻尼摆:从 f0 开始的二次动作
+ const damped = (f, f0, amp, period, decay) => f < f0 ? 0 : amp * Math.exp(-(f - f0) / decay) * Math.sin((f - f0) / period * Math.PI * 2);
+ const smooth = (pts, closed = true) => RIG.smooth(pts, closed);
+
+ // ---------- 颗粒点彩:在一个形状里撒点,密度随位置变化 ----------
+ function stipple(g, pathOrFn, box, col, density, seed, size = 2.2) {
+ const r = U.rng(seed); const [x0, y0, x1, y1] = box; g.save(); if (pathOrFn instanceof Path2D) g.clip(pathOrFn); g.fillStyle = col;
+ const n = Math.round((x1 - x0) * (y1 - y0) * 0.02);
+ for (let i = 0; i < n; i++) { const x = lerp(x0, x1, r()), y = lerp(y0, y1, r()); if (r() < density(x, y)) { const s = size * (0.6 + r() * 0.8); g.fillRect(x, y, s, s); } }
+ g.restore();
+ }
+
+ // ---------- 静态背景 ----------
+ const PINK = [560, 485, 392], LAVP = [[1215, 230], [1330, 196], [1460, 230], [1545, 330], [1585, 470], [1560, 610], [1480, 720], [1350, 765], [1215, 740], [1140, 640], [1120, 470], [1150, 320]];
+ function background(g) {
+ g.fillStyle = C.wall; g.fillRect(0, 0, W, 790);
+ const fg = g.createLinearGradient(0, 790, 0, H); fg.addColorStop(0, '#eedec4'); fg.addColorStop(1, '#f2e6d2'); g.fillStyle = fg; g.fillRect(0, 790, W, H - 790);
+ // 粉色大圆:淡粉底 + 越往下越密的红点(扁平插画的颗粒渐变)
+ const pc = new Path2D(); pc.arc(PINK[0], PINK[1], PINK[2], 0, 7);
+ g.save(); g.clip(pc); const pg = g.createLinearGradient(0, PINK[1] - PINK[2], 0, PINK[1] + PINK[2]); pg.addColorStop(0, 'rgba(246,214,206,.55)'); pg.addColorStop(1, 'rgba(244,196,188,.95)'); g.fillStyle = pg; g.fill(pc); g.restore();
+ stipple(g, pc, [PINK[0] - PINK[2], PINK[1] - PINK[2], PINK[0] + PINK[2], PINK[1] + PINK[2]], C.pinkDot, (x, y) => 0.12 + 0.75 * clamp((y - PINK[1] + 120) / 420) * (0.6 + 0.4 * clamp((PINK[0] + 100 - x) / 300)), 11);
+ // 淡紫色块
+ const lp = smooth(LAVP); g.fillStyle = C.lav; g.fill(lp);
+ stipple(g, lp, [1110, 190, 1600, 770], C.lavDot, (x, y) => 0.06 + 0.6 * clamp((x - 1250) / 340) * clamp((y - 300) / 400 + 0.3), 12);
+ // 地毯
+ const rug = new Path2D(); rug.ellipse(1232, 902, 385, 33, 0, 0, 7); g.fillStyle = C.mint; g.fill(rug); stipple(g, rug, [847, 869, 1617, 935], '#9fcfb4', () => 0.35, 13, 2.4);
+ // 地面软影
+ g.fillStyle = 'rgba(160,140,120,.22)'; [[185, 902, 100, 9], [1010, 897, 95, 8], [1720, 903, 110, 9]].forEach(([x, y, rx, ry]) => { g.beginPath(); g.ellipse(x, y, rx, ry, 0, 0, 7); g.fill(); });
+ // 窗:白色圆角框
+ g.save(); g.shadowColor = 'rgba(150,120,110,.18)'; g.shadowBlur = 18; g.shadowOffsetY = 8; g.fillStyle = C.white; g.beginPath(); g.roundRect(360, 120, 440, 445, 34); g.fill(); g.restore();
+ const panes = new Path2D(); panes.roundRect(380, 140, 400, 400, 22);
+ g.save(); g.clip(panes);
+ const sg = g.createLinearGradient(0, 140, 0, 540); sg.addColorStop(0, '#a6d4f1'); sg.addColorStop(0.6, '#cbe9f3'); sg.addColorStop(1, '#e0f2ef'); g.fillStyle = sg; g.fillRect(380, 140, 400, 400);
+ stipple(g, null, [380, 140, 780, 540], '#7fb8e6', (x, y) => 0.22 * (1 - (y - 140) / 400), 14, 2);
+ // 城市剪影
+ const bld = (x, y, w, h, col, win, round = 0) => { g.fillStyle = col; g.beginPath(); round ? (g.moveTo(x, y + h), g.lineTo(x, y + round), g.arc(x + w / 2, y + round, w / 2, Math.PI, 0), g.lineTo(x + w, y + h)) : g.rect(x, y, w, h); g.fill();
+ if (win) { g.fillStyle = win; for (let yy = y + (round ? round : 0) + 14; yy < y + h - 10; yy += 22) for (let xx = x + 10; xx < x + w - 12; xx += 20) g.fillRect(xx, yy, 9, 10); } };
+ bld(380, 420, 74, 120, '#c5b2ec'); bld(505, 372, 68, 168, '#ec9e9a'); bld(398, 452, 88, 88, '#a98fe2', '#fffaf2');
+ bld(690, 395, 90, 145, '#c9b6ee', null, 45); bld(597, 430, 78, 110, '#7fb593', '#d6ecd9', 39);
+ bld(470, 478, 95, 62, '#e85f57', '#fff3e6'); bld(550, 500, 70, 40, '#f2b33d'); bld(662, 468, 118, 72, C.navy, '#f6c445');
+ g.fillStyle = '#4c9a69'; [[405, 540, 28], [768, 540, 22]].forEach(([x, y, r]) => { g.beginPath(); g.arc(x, y, r, Math.PI, 0); g.fill(); });
+ g.restore();
+ g.fillStyle = C.white; g.fillRect(572, 140, 15, 400); g.fillRect(380, 332, 400, 15);
+ // 窗台
+ g.save(); g.shadowColor = 'rgba(150,120,110,.22)'; g.shadowBlur = 10; g.shadowOffsetY = 6; g.fillStyle = C.white; g.beginPath(); g.roundRect(338, 545, 484, 24, 12); g.fill(); g.restore();
+ // 椅子(在少女后面)
+ g.fillStyle = C.chair; g.beginPath(); g.roundRect(1448, 470, 44, 300, 22); g.fill();
+ g.fillStyle = '#6aa680'; g.beginPath(); g.roundRect(1300, 738, 190, 24, 12); g.fill();
+ g.strokeStyle = C.chair; g.lineWidth = 12; g.lineCap = 'round'; [[1330, 762, 1312, 898], [1462, 762, 1478, 898], [1478, 770, 1500, 893]].forEach(([a, b, c2, d]) => { g.beginPath(); g.moveTo(a, b); g.lineTo(c2, d); g.stroke(); });
+ // 桌子(藏青、圆角)
+ g.fillStyle = C.navy; g.beginPath(); g.moveTo(996, 662); g.lineTo(1024, 662); g.lineTo(1030, 882); g.lineTo(990, 882); g.closePath(); g.fill();
+ g.beginPath(); g.roundRect(925, 878, 170, 20, 10); g.fill();
+ g.beginPath(); g.roundRect(820, 640, 380, 24, 12); g.fill();
+ stipple(g, null, [820, 640, 1200, 664], '#3c4178', () => 0.4, 15, 2);
+ // 盆
+ g.fillStyle = C.red; g.beginPath(); g.moveTo(118, 800); g.lineTo(252, 800); g.lineTo(246, 875); g.quadraticCurveTo(244, 900, 220, 900); g.lineTo(150, 900); g.quadraticCurveTo(126, 900, 124, 875); g.closePath(); g.fill();
+ g.fillStyle = C.white; g.fillRect(120, 822, 130, 16);
+ stipple(g, null, [118, 800, 252, 900], '#c2403a', (x, y) => y > 838 ? 0.4 : 0.2, 16);
+ g.fillStyle = '#9a7ee0'; g.beginPath(); g.roundRect(1628, 735, 176, 24, 8); g.fill();
+ g.fillStyle = '#ac94ea'; g.beginPath(); g.moveTo(1640, 758); g.lineTo(1792, 758); g.lineTo(1782, 838); g.quadraticCurveTo(1778, 860, 1755, 860); g.lineTo(1677, 860); g.quadraticCurveTo(1654, 860, 1650, 838); g.closePath(); g.fill();
+ stipple(g, null, [1628, 735, 1804, 860], '#8a6cd6', () => 0.4, 17);
+ g.strokeStyle = C.navy; g.lineWidth = 7; [[1662, 858, 1648, 902], [1770, 858, 1784, 902]].forEach(([a, b, c2, d]) => { g.beginPath(); g.moveTo(a, b); g.lineTo(c2, d); g.stroke(); });
+ }
+ // 整体纸面颗粒(静态,叠在最上面很淡一层)
+ const grainTex = () => P.cached('fl_grain', W, H, (g) => {
+ const im = g.createImageData(W, H), d = im.data, r = U.rng(2026);
+ for (let i = 0; i < W * H; i++) { const v = r(); if (v < 0.05) { d[i * 4] = 60; d[i * 4 + 1] = 40; d[i * 4 + 2] = 70; d[i * 4 + 3] = 70; } else if (v > 0.965) { d[i * 4] = d[i * 4 + 1] = d[i * 4 + 2] = 255; d[i * 4 + 3] = 90; } }
+ g.putImageData(im, 0, 0);
+ });
+
+ // ---------- 会动的环境 ----------
+ function sky(c, t) {
+ c.save(); const panes = new Path2D(); panes.rect(380, 140, 192, 192); panes.rect(587, 140, 193, 192); c.clip(panes);
+ // 太阳:光芒慢转+脉动
+ const S = [676, 232];
+ c.strokeStyle = C.sun; c.lineWidth = 6; c.lineCap = 'round';
+ for (let k = 0; k < 12; k++) { const a = k / 12 * Math.PI * 2 + t * 0.35, r0 = 68, r1 = 80 + (k % 2 ? 0 : 6) + Math.sin(t * 5 + k) * 3; c.beginPath(); c.moveTo(S[0] + Math.cos(a) * r0, S[1] + Math.sin(a) * r0); c.lineTo(S[0] + Math.cos(a) * r1, S[1] + Math.sin(a) * r1); c.stroke(); }
+ c.drawImage(P.cached('fl_sun', 130, 130, (g) => { g.fillStyle = C.sun; g.beginPath(); g.arc(65, 65, 56, 0, 7); g.fill(); const r = U.rng(5); g.fillStyle = '#e8743a'; for (let i = 0; i < 2600; i++) { const a = r() * 7, d = Math.sqrt(r()) * 55, x = 65 + Math.cos(a) * d, y = 65 + Math.sin(a) * d; if (r() < 0.15 + 0.7 * clamp((x + y - 100) / 110)) g.fillRect(x, y, 2, 2); } }), S[0] - 65, S[1] - 65);
+ // 云:往左慢移(约 0.25px/帧)
+ const cloud = (x, y, s) => { c.fillStyle = C.white; c.beginPath(); c.arc(x, y, 22 * s, Math.PI, 0); c.arc(x + 30 * s, y - 10 * s, 28 * s, Math.PI, 0); c.arc(x + 62 * s, y, 20 * s, Math.PI, 0); c.closePath(); c.fill(); c.beginPath(); c.roundRect(x - 22 * s, y - 2, 104 * s, 18 * s, 9 * s); c.fill(); };
+ const dx = -(t - 10.8) * 15;
+ cloud(445 + dx, 192, 0.8); cloud(540 + dx, 270, 1.15); cloud(760 + dx * 1.2, 310, 0.7);
+ // 小飞机+虚线尾迹:12.0s 在 x≈440,13.75s 在 x≈750
+ const px = 440 + (t - 12) * 177, py = 156 - (t - 12) * 4;
+ c.strokeStyle = 'rgba(255,255,255,.9)'; c.lineWidth = 3; c.setLineDash([10, 8]); c.beginPath(); c.moveTo(px - 140, py + 6); c.lineTo(px - 18, py + 2); c.stroke(); c.setLineDash([]);
+ c.fillStyle = '#e65a52'; c.beginPath(); c.roundRect(px - 22, py - 5, 40, 11, 6); c.fill(); c.beginPath(); c.moveTo(px - 4, py); c.lineTo(px - 14, py + 14); c.lineTo(px + 2, py + 2); c.fill(); c.beginPath(); c.moveTo(px - 20, py - 2); c.lineTo(px - 26, py - 13); c.lineTo(px - 14, py - 3); c.fill();
+ c.restore();
+ }
+ // 彩色小装饰:4fps 沸腾(每 0.25s 换一次微小的位移/旋转)
+ const DECOS = [['plus', 192, 140, C.red, 1.2], ['dots', 258, 248, '#8dc7a2', 1], ['dot', 86, 318, C.yellow, 1], ['squig', 242, 395, C.navy, 1], ['dots', 304, 482, C.navy, 0.9], ['tri', 118, 553, '#b59bec', 1.1], ['dot', 302, 603, C.red, 0.8],
+ ['squig', 80, 712, C.yellow, 0.7], ['half', 898, 130, '#8dc7a2', 1], ['tri', 866, 292, C.yellow, 0.9], ['ring', 1172, 99, C.yellow, 1], ['squig', 1268, 113, C.red, 1], ['dot', 1393, 76, C.navy, 0.8], ['plus', 1190, 190, '#b59bec', 0.9],
+ ['dot', 1570, 274, C.yellow, 1], ['x', 1786, 258, C.navy, 1], ['half', 1846, 318, C.red, 1]];
+ function decos(c, t) {
+ const b = Math.floor(t * 4);
+ DECOS.forEach(([k, x, y, col, s], i) => {
+ const jx = (U.hash(i, b) - 0.5) * 3, jy = (U.hash(i + 50, b) - 0.5) * 3, ja = (U.hash(i + 99, b) - 0.5) * 0.18;
+ c.save(); c.translate(x + jx, y + jy); c.rotate(ja); c.scale(s, s); c.fillStyle = col; c.strokeStyle = col; c.lineCap = 'round'; c.lineJoin = 'round';
+ if (k === 'plus' || k === 'x') { if (k === 'x') c.rotate(0.78); c.lineWidth = 8; c.beginPath(); c.moveTo(-13, 0); c.lineTo(13, 0); c.moveTo(0, -13); c.lineTo(0, 13); c.stroke(); }
+ else if (k === 'dot') { c.beginPath(); c.arc(0, 0, 11, 0, 7); c.fill(); }
+ else if (k === 'ring') { c.lineWidth = 6; c.beginPath(); c.arc(0, 0, 13, 0, 7); c.stroke(); }
+ else if (k === 'tri') { c.beginPath(); c.moveTo(0, -16); c.lineTo(15, 12); c.lineTo(-15, 12); c.closePath(); c.fill(); }
+ else if (k === 'half') { c.beginPath(); c.arc(0, 6, 20, Math.PI, 0); c.closePath(); c.fill(); }
+ else if (k === 'squig') { c.lineWidth = 5; c.beginPath(); for (let s2 = 0; s2 <= 24; s2++) { const xx = -32 + s2 * 2.7, yy = Math.sin(s2 / 24 * Math.PI * 3 + i) * 8; s2 ? c.lineTo(xx, yy) : c.moveTo(xx, yy); } c.stroke(); }
+ else if (k === 'dots') { for (let a = 0; a < 3; a++) for (let d = 0; d < 4; d++) { c.beginPath(); c.arc(d * 15 - 22, a * 15 - 15, 3.6, 0, 7); c.fill(); } }
+ c.restore();
+ });
+ }
+ // 吊灯+光锥:绕天花板 (1010,0) 摆
+ function lamp(c, ang) {
+ c.save(); c.translate(1010, 0); c.rotate(ang); c.translate(-1010, 0);
+ // 光锥:颗粒黄光(缓存贴图)
+ c.drawImage(P.cached('fl_cone', 340, 420, (g) => {
+ const r = U.rng(31); for (let i = 0; i < 26000; i++) { const y = r() * 400, w = lerp(56, 150, y / 400), x = 170 + (r() * 2 - 1) * w; const edge = 1 - Math.abs(x - 170) / w;
+ const a = (1 - y / 430) * (0.35 + 0.65 * Math.min(1, edge * 3)); if (r() < a) { g.fillStyle = r() < 0.7 ? 'rgba(245,205,95,.75)' : 'rgba(255,240,190,.9)'; g.fillRect(x, y, 2.4, 2.4); } }
+ }), 840, 240);
+ c.strokeStyle = C.navy; c.lineWidth = 4; c.beginPath(); c.moveTo(1010, 0); c.lineTo(1010, 152); c.stroke();
+ c.fillStyle = C.navy; c.beginPath(); c.roundRect(999, 146, 22, 22, 5); c.fill();
+ c.fillStyle = C.yellow; c.beginPath(); c.arc(1010, 238, 22, 0, Math.PI); c.fill();
+ c.fillStyle = C.red; c.beginPath(); c.moveTo(936, 240); c.bezierCurveTo(936, 190, 970, 164, 1010, 164); c.bezierCurveTo(1050, 164, 1084, 190, 1084, 240); c.closePath(); c.fill();
+ c.save(); c.clip(); c.drawImage(P.cached('fl_shadeDots', 150, 80, (g) => { const r = U.rng(41); g.fillStyle = '#c4433e'; for (let i = 0; i < 1500; i++) { const x = r() * 150, y = r() * 78; if (r() < (x / 150) * 0.8) g.fillRect(x, y, 2, 2); } }), 935, 162, 150, 78); c.restore();
+ c.restore();
+ }
+ // 植物:叶子绕盆口摆;cached 叶片贴图
+ function snakePlant(c, ang) {
+ c.save(); c.translate(185, 805); c.rotate(ang); c.translate(-185, -805);
+ const leaf = (bx, tipx, tipy, w, col, edge) => { c.fillStyle = edge; c.beginPath(); c.moveTo(bx - w, 805); c.quadraticCurveTo(bx - w * 0.6, (805 + tipy) / 2, tipx, tipy); c.quadraticCurveTo(bx + w * 0.8, (805 + tipy) / 2, bx + w, 805); c.closePath(); c.fill();
+ c.fillStyle = col; c.beginPath(); c.moveTo(bx - w + 5, 805); c.quadraticCurveTo(bx - w * 0.5, (805 + tipy) / 2 + 10, tipx, tipy + 14); c.quadraticCurveTo(bx + w * 0.6, (805 + tipy) / 2 + 10, bx + w - 5, 805); c.closePath(); c.fill(); };
+ leaf(150, 98, 600, 18, '#3f9a62', C.yellow); leaf(222, 272, 625, 17, '#3f9a62', C.yellow); leaf(170, 160, 505, 20, '#2e7f50', '#2e7f50'); leaf(200, 215, 545, 19, '#4aa86c', C.yellow); leaf(186, 120, 690, 14, '#2e7f50', C.yellow); leaf(196, 252, 700, 14, '#4aa86c', '#4aa86c');
+ c.restore();
+ }
+ const leafTex = () => P.cached('fl_mleaf', 200, 150, (g) => {
+ // 龟背竹叶:叶片(上半深一点)→ 从主脉两侧斜向叶缘的浅色长缝 → 主脉
+ g.translate(100, 75); const leaf = new Path2D(); leaf.ellipse(0, 0, 94, 66, 0, 0, 7);
+ g.fillStyle = '#2f8a5d'; g.fill(leaf); g.save(); g.clip(leaf); g.fillStyle = '#26774f'; g.fillRect(-100, -70, 200, 70);
+ g.strokeStyle = '#eef3ea'; g.lineCap = 'round'; g.lineWidth = 8;
+ for (const sg of [-1, 1]) for (let k = 0; k < 5; k++) { const x0 = -58 + k * 28, a = sg * (0.95 - k * 0.05); g.beginPath(); g.moveTo(x0 + 6, sg * 13); g.lineTo(x0 + 6 + Math.cos(a) * 70 * 0.45, sg * 13 + Math.sin(a) * 70); g.stroke(); }
+ g.fillStyle = '#eef3ea'; [[-30, -34], [26, 36], [-6, 40]].forEach(([x, y]) => { g.beginPath(); g.ellipse(x, y, 6, 4, 0.4, 0, 7); g.fill(); });
+ g.restore();
+ g.strokeStyle = '#1f6844'; g.lineWidth = 4; g.beginPath(); g.moveTo(-94, 0); g.lineTo(94, 0); g.stroke();
+ });
+ const MLEAVES = [[1705, 352, 1.0, -1.57], [1590, 468, 0.82, -2.4], [1845, 448, 0.9, -0.7], [1563, 665, 0.62, -2.9], [1883, 640, 0.66, -0.25]];
+ function monstera(c, ang, f) {
+ c.save(); c.translate(1715, 738); c.rotate(ang); c.translate(-1715, -738);
+ MLEAVES.forEach(([x, y, s, a], i) => {
+ const w = Math.sin(f * 0.05 + i * 1.7) * 0.02 + ang * (1 + i * 0.4);
+ c.strokeStyle = '#2f8a5d'; c.lineWidth = 6; c.beginPath(); c.moveTo(1715, 738); c.quadraticCurveTo(lerp(1715, x, 0.6), lerp(738, y, 0.3), x, y); c.stroke();
+ c.save(); c.translate(x, y); c.rotate(a + Math.PI / 2 + w); c.scale(s, s); c.drawImage(leafTex(), -100, -75); c.restore();
+ });
+ c.restore();
+ }
+
+ // ---------- 少女(头/躯干=RIG.girl,手臂=RIG.ik2,腿自画) ----------
+ // 姿势:type(闭眼微笑打字)→ pet(睁眼、小 o 嘴、手伸向猫)→ shock(举双手、大张嘴、紧张线)
+ function girl(c, f, t, layer) {
+ const G = RIG.girl({ s: 1.12, hair: 'bun' });
+ const Hd = RIG.girl({ s: 1.344, dy: 43.7, hair: 'bun' }); // 头部放大 1.2 倍(围绕颈点),扁平插画大头比例
+ const A = G.A;
+ const pet = seg(f, 688, 704), shock = seg(f, 791, 798), shockE = ease.outBack(shock);
+ const jit = f > 830 && f < 888 ? [(U.hash(Math.floor(f / 2), 3) - 0.5) * 4, (U.hash(Math.floor(f / 2), 4) - 0.5) * 3] : [0, 0];
+ const breathe = Math.sin(t * 3.2) * 2;
+ // 手的目标点
+ const typ = (k) => [1128 + k * 30, 612 - Math.max(0, Math.sin(t * 22 + k * 2.4)) * 7];
+ const petN = [1222 + Math.sin(t * 6) * 6, 548 + Math.cos(t * 6) * 3], petF = [1238, 590];
+ const shN = [1228, 432], shF = [1262, 462];
+ const tgt = (k) => { let p = typ(k); const q = ease.inOut(pet); p = [lerp(p[0], (k ? petF : petN)[0], q), lerp(p[1], (k ? petF : petN)[1], q)]; return [lerp(p[0], (k ? shF : shN)[0], shockE), lerp(p[1], (k ? shF : shN)[1], shockE)]; };
+ const S = [A.shoulder[0] + 6, A.shoulder[1] + 4 + breathe];
+ const arm = (Tg, dark, k) => {
+ const Sh = [S[0] + (k ? 28 : 0), S[1] + (k ? 10 : 0)];
+ const { E, H: Hn } = RIG.ik2(Sh, Tg, 150, 140, -1);
+ const sleeve = dark ? C.coralDk : C.coral;
+ c.fillStyle = sleeve; c.fill(RIG.taper(Sh, E, 62, 50, 6)); c.fill(RIG.taper(E, Hn, 50, 44, 2));
+ const cuffA = [lerp(E[0], Hn[0], 0.82), lerp(E[1], Hn[1], 0.82)];
+ c.fillStyle = dark ? '#b8413b' : C.coralDk; c.fill(RIG.taper(cuffA, Hn, 46, 46));
+ // 手:手套形+拇指;举手时手指朝上张开
+ const a = Math.atan2(Hn[1] - E[1], Hn[0] - E[0]), hc = [Hn[0] + Math.cos(a) * 18, Hn[1] + Math.sin(a) * 18];
+ c.save(); c.translate(...hc); c.rotate(lerp(a, -Math.PI / 2 - 0.25 + k * 0.2, shockE));
+ c.fillStyle = dark ? C.skinDk : C.skin; c.beginPath(); c.ellipse(4, 0, 24, 19, 0, 0, 7); c.fill();
+ if (shock > 0.3) { for (let i = 0; i < 3; i++) { c.beginPath(); c.roundRect(14, -15 + i * 11, 22 * shockE, 10, 5); c.fill(); } }
+ c.beginPath(); c.ellipse(-2, (k ? 1 : -1) * -14, 10, 7, -0.6, 0, 7); c.fill();
+ c.restore();
+ };
+ if (layer === 'back') {
+ // 远侧腿+粉色鞋、远侧手臂(在身体后面)
+ c.fillStyle = '#1d2050'; c.fill(RIG.taper([1440, 718], [1232, 730], 86, 74)); c.fill(RIG.taper([1238, 728], [1246, 848], 68, 58));
+ c.fillStyle = C.sock; c.fillRect(1218, 826, 56, 26); c.fillStyle = '#f2a7a0'; c.beginPath(); c.roundRect(1222, 848, 52, 38, 16); c.fill();
+ arm(tgt(1), true, 1);
+ return;
+ }
+ if (layer === 'body') {
+ // 腿:藏青长裤+淡紫袜+白球鞋(珊瑚鞋底)
+ c.fillStyle = C.pants; c.fill(RIG.taper([1430, 712], [1206, 728], 96, 84)); c.fill(RIG.taper([1206, 724], [1214, 840], 78, 64));
+ c.fillStyle = C.sock; c.fillRect(1186, 822, 58, 30);
+ c.fillStyle = C.white; c.beginPath(); c.moveTo(1112, 886); c.quadraticCurveTo(1118, 852, 1176, 850); c.lineTo(1236, 850); c.quadraticCurveTo(1244, 870, 1240, 886); c.closePath(); c.fill();
+ c.fillStyle = C.red; c.beginPath(); c.roundRect(1106, 884, 136, 12, 6); c.fill();
+ // 毛衣:RIG 躯干 + 下摆延到胯部;亮面斜块
+ c.save(); c.translate(0, breathe * 0.5);
+ const sweater = smooth([[A.neck[0] - 18, A.neck[1] + 2], [A.neck[0] + 40, A.neck[1] - 2], [1418, 446], [1452, 520], [1468, 640], [1462, 740], [1420, 762], [1320, 760], [1296, 690], [1286, 560], [1284, 470]]);
+ c.fillStyle = C.coral; c.fill(sweater);
+ c.save(); c.clip(sweater); c.fillStyle = C.coralLt; c.beginPath(); c.moveTo(1284, 470); c.lineTo(1340, 440); c.lineTo(1410, 760); c.lineTo(1290, 760); c.closePath(); c.fill();
+ c.fillStyle = C.coralDk; c.fillRect(1290, 744, 190, 20); c.restore();
+ c.fillStyle = C.coralDk; c.beginPath(); c.roundRect(A.neck[0] - 26, A.neck[1] - 8, 64, 22, 10); c.fill();
+ c.restore();
+ // 头:颈 → 后发/丸子 → 脸 → 刘海 → 耳机
+ c.save(); c.translate(jit[0], jit[1] + breathe * 0.4);
+ const nk = [1300, 401]; c.translate(...nk); c.rotate(-0.04 * pet + 0.05 * shockE); c.translate(-nk[0], -nk[1]);
+ c.fillStyle = C.skinDk; c.fill(G.neck);
+ c.fillStyle = C.hair; c.fill(Hd.hairBack); c.fill(Hd.bun);
+ c.fillStyle = C.hairDk; c.save(); c.clip(Hd.bun); c.beginPath(); c.arc(Hd.bunSpiral[0] + 14, Hd.bunSpiral[1] + 12, 40, 0, 7); c.fill(); c.restore();
+ c.fillStyle = C.skin; c.fill(Hd.face);
+ c.fillStyle = C.hair; c.fill(Hd.bangs);
+ c.strokeStyle = C.hairDk; c.lineWidth = 3.5; c.lineCap = 'round'; Hd.hairLines.forEach(h => c.stroke(h));
+ // 腮红
+ c.fillStyle = C.blush; c.beginPath(); c.arc(Hd.cheek[0] - 2, Hd.cheek[1] + 2, 15, 0, 7); c.fill();
+ // 眼睛:打字时闭眼弧线 → 睁眼圆点(反应①)→ 大眼(反应②)→ 838 帧后挤眼
+ const ex = Hd.eye.x + 2, ey = Hd.eye.y + 2;
+ c.strokeStyle = C.navy; c.fillStyle = C.navy; c.lineWidth = 4;
+ if (f < 686) { c.beginPath(); c.arc(ex, ey - 4, 10, 0.25 * Math.PI, 0.8 * Math.PI); c.stroke(); }
+ else if (f > 838) { c.beginPath(); c.moveTo(ex + 9, ey - 8); c.lineTo(ex - 4, ey - 1); c.lineTo(ex + 9, ey + 5); c.stroke(); }
+ else { const big = 1 + 0.35 * shockE; c.beginPath(); c.ellipse(ex, ey, 6.5 * big, 7.5 * big, 0, 0, 7); c.fill(); c.fillStyle = '#fff'; c.beginPath(); c.arc(ex - 2, ey - 3, 2.2, 0, 7); c.fill();
+ c.strokeStyle = C.hairDk; c.lineWidth = 4; c.beginPath(); c.arc(ex + 2, ey - 6 - 6 * big, 12, 1.15 * Math.PI, 1.75 * Math.PI); c.stroke(); }
+ // 嘴:微笑 → 小 o → 大张嘴
+ const m = [Hd.lips[1][0] + 2, Hd.lips[1][1] + 6];
+ if (f < 686) { c.strokeStyle = C.navy; c.lineWidth = 3.5; c.beginPath(); c.arc(m[0] + 4, m[1] - 8, 10, 0.55 * Math.PI, 0.95 * Math.PI); c.stroke(); }
+ else if (shock < 0.01) { const o = ease.outBack(seg(f, 686, 692)); c.fillStyle = '#7a2a3a'; c.beginPath(); c.ellipse(m[0] + 2, m[1], 5 * o, 7 * o, 0, 0, 7); c.fill(); }
+ else { const o = shockE; c.fillStyle = '#7a2a3a'; c.beginPath(); c.ellipse(m[0] + 3, m[1] + 4 * o, 8 + 4 * o, 8 + 9 * o, 0.1, 0, 7); c.fill(); c.fillStyle = '#ec7a86'; c.beginPath(); c.ellipse(m[0] + 4, m[1] + 4 + 11 * o, 6 * o, 4 * o, 0, 0, 7); c.fill(); }
+ // 耳机:白色头梁 + 黄色耳罩
+ const er = [Hd.ear[0] + 4, Hd.ear[1]];
+ c.strokeStyle = C.white; c.lineWidth = 10; c.lineCap = 'round'; c.beginPath(); c.moveTo(er[0] + 2, er[1] - 34); c.quadraticCurveTo(er[0] - 4, Hd.A.headTop[1] - 34, Hd.A.headTop[0] - 40, Hd.A.headTop[1] + 4); c.stroke();
+ c.fillStyle = '#dc9a2c'; c.beginPath(); c.roundRect(er[0] - 18, er[1] - 38, 42, 76, 20); c.fill();
+ c.fillStyle = C.yellow; c.beginPath(); c.roundRect(er[0] - 24, er[1] - 34, 34, 68, 17); c.fill();
+ c.fillStyle = '#f8cf6a'; c.beginPath(); c.roundRect(er[0] - 18, er[1] - 24, 12, 40, 6); c.fill();
+ c.restore();
+ return { headTop: [Hd.A.headTop[0] + jit[0], Hd.A.headTop[1] + jit[1]], face: Hd.A.forehead };
+ }
+ if (layer === 'front') { arm(tgt(0), false, 0); }
+ }
+ // 紧张线:头顶前方 3 道,793 淡粉 → 796 全红;830–888 轻抖
+ function tension(c, f, headTop) {
+ if (f < 792) return;
+ const q = seg(f, 792, 797), col = P.mix(P.hex('#f6c4c0'), P.hex('#e5463e'), seg(f, 793, 796));
+ const j = f > 830 && f < 888 ? (U.hash(Math.floor(f / 2), 9) - 0.5) * 5 : 0;
+ const o = [headTop[0] - 30, headTop[1] + 95]; // 从头顶前上方放射(分镜表:紧张线在 (1215–1290, 200–295))
+ c.save(); c.strokeStyle = P.rgb(col); c.lineWidth = 7; c.lineCap = 'round';
+ [[-2.6, 84, 30], [-2.05, 88, 34], [-1.5, 96, 34]].forEach(([a, r0, L], i) => {
+ const r1 = r0 + L * ease.outBack(q), aa = a + j * 0.01 * (i - 1);
+ c.beginPath(); c.moveTo(o[0] + Math.cos(aa) * r0 + j, o[1] + Math.sin(aa) * r0); c.lineTo(o[0] + Math.cos(aa) * r1 + j, o[1] + Math.sin(aa) * r1); c.stroke();
+ });
+ c.restore();
+ }
+
+ // ---------- 猫:姿势库(局部坐标,朝右,原点=质心) ----------
+ // 每个姿势:body 10 点、chest 6 点、head[x,y,rx,ry]、front 两条前腿[肩x,肩y,爪x,爪y]、hind 后腿、tail 4 点、ear 角度
+ const rel = (o, pts) => pts.map(p => [p[0] - o[0], p[1] - o[1]]);
+ const mir = (o, pts) => pts.map(p => [o[0] - (p[0] - o[0]), p[1]]);
+ const SIT_F = (() => { const o = [555, 795], R = (pts) => rel(o, pts); return {
+ body: R([[430, 905], [428, 852], [452, 794], [505, 760], [570, 752], [626, 768], [662, 818], [672, 872], [658, 905], [540, 908]]),
+ chest: R([[612, 762], [660, 800], [674, 862], [660, 906], [622, 906], [606, 840]]),
+ haunch: [482 - o[0], 862 - o[1], 54, 44], stripes: [R([[505, 760], [512, 784]]).flat(), R([[466, 780], [486, 796]]).flat(), R([[446, 815], [470, 826]]).flat()],
+ head: [628 - o[0], 708 - o[1], 64, 56], front: [R([[648, 842], [650, 896]]).flat(), R([[612, 842], [612, 896]]).flat()],
+ tipW: 1, hind: R([[478, 870], [506, 900]]).flat(), tail: R([[438, 893], [392, 905], [380, 945], [420, 950]]), ear: 0, gy: 905 - o[1] }; })();
+ const SIT_T = (() => { const o = [1118, 497], M = (pts) => rel(o, mir(o, pts)); return { // 桌上坐姿:实测朝左,镜像成朝右存
+ body: M([[1040, 628], [1034, 580], [1046, 515], [1072, 470], [1120, 455], [1170, 470], [1215, 520], [1248, 580], [1250, 628], [1140, 632]]),
+ chest: M([[1058, 470], [1104, 466], [1114, 545], [1104, 606], [1060, 612], [1042, 540]]),
+ haunch: [-(1196 - o[0]), 588 - o[1], 56, 46], stripes: [M([[1172, 468], [1160, 492]]).flat(), M([[1208, 505], [1188, 520]]).flat(), M([[1234, 548], [1210, 556]]).flat()],
+ head: [-(1080 - o[0]), 400 - o[1], 68, 58], front: [M([[1062, 545], [1060, 618]]).flat(), M([[1100, 545], [1100, 618]]).flat()],
+ tipW: 0, hind: M([[1196, 600], [1162, 622]]).flat(), tail: M([[1240, 620], [1296, 626], [1318, 596], [1300, 562]]), ear: 0, gy: 629 - o[1] }; })();
+ const LEAP = { body: [[-125, 12], [-120, -24], [-80, -46], [0, -48], [70, -42], [114, -20], [122, 12], [90, 36], [0, 40], [-90, 36]],
+ chest: [[56, 8], [110, -2], [118, 22], [84, 38], [40, 36], [38, 20]], haunch: [-80, 6, 46, 36], stripes: [[-60, -46, -56, -28], [-22, -48, -18, -30], [18, -47, 20, -30]],
+ head: [150, -46, 58, 52], front: [[84, 18, 182, 34], [66, 16, 168, 48]],
+ tipW: 1, hind: [-92, 16, -190, 40], tail: [[-122, -6], [-172, -22], [-214, -44], [-252, -30]], ear: 0.35, gy: 40 };
+ const LAND = { ...LEAP, front: [[84, 18, 118, 74], [66, 16, 98, 76]], hind: [-92, 16, -150, 56], head: [140, -30, 60, 54], body: LEAP.body.map(p => [p[0] * 0.92, p[1] * 1.08]), gy: 76 };
+ const mixA = (a, b, q) => Array.isArray(a) ? a.map((v, i) => mixA(v, b[i], q)) : lerp(a, b, q);
+ const mixPose = (a, b, q) => { const o = {}; for (const k in a) o[k] = mixA(a[k], b[k], q); return o; };
+
+ function catState(f, t) {
+ // 质心轨迹(分镜表实测 + 起跳前与落桌后的补点)
+ const traj = [[657, 555, 795], [660, 555, 800], [662, 560, 752], [664, 573, 691], [666, 606, 639], [668, 660, 599], [670, 719, 563], [672, 784, 536], [674, 849, 518], [676, 916, 508], [678, 979, 505], [680, 1038, 510], [682, 1088, 518], [684, 1126, 524], [686, 1160, 548]];
+ const s = { pose: SIT_F, x: 555, y: 795, rot: 0, sx: 1, sy: 1, dir: 1, pivot: 'ground', eyes: 'open', look: 0, paw: null, dust: 0 };
+ if (f < 661) { // 静坐 → 下蹲预备(657–661)
+ const q = seg(f, 657.5, 661); s.sy = 1 - 0.14 * ease.inOut(q); s.sx = 1 + 0.07 * ease.inOut(q); s.look = 3 * q; s.poseHeadDy = 8 * q;
+ } else if (f < 664) { // 蹬地:身体上扬、拉伸
+ const q = seg(f, 661, 664); [s.x, s.y] = path(f, traj); s.pivot = 'center'; s.pose = mixPose(SIT_F, LEAP, ease.in(q) * 0.45);
+ s.rot = -0.75 * ease.out(q); s.sy = lerp(0.86, 1.12, ease.out(q)); s.sx = lerp(1.07, 0.92, ease.out(q));
+ } else if (f < 686) { // 腾空弧线:身体沿切线方向,672–684 水平拉长
+ [s.x, s.y] = path(f, traj); s.pivot = 'center';
+ const a = path(f + 0.5, traj), b = path(f - 0.5, traj); const tang = Math.atan2(a[1] - b[1], a[0] - b[0]);
+ s.pose = mixPose(SIT_F, LEAP, clamp(0.45 + seg(f, 664, 670) * 0.55)); s.rot = tang * 0.8 * (1 - 0.85 * ease.inOut(seg(f, 679, 686))); // 落地前把身体放平,前爪先着
+ const st = seg(f, 670, 676); s.sx = lerp(0.95, 1.12, st); s.sy = lerp(1.08, 0.9, st);
+ if (f > 682) { const q = seg(f, 682, 686); s.pose = mixPose(s.pose, LAND, q); s.sx = lerp(s.sx, 1.0, q); s.sy = lerp(s.sy, 1.0, q); }
+ } else if (f < 698) { // 落桌挤压 → 转身坐起(690 帧压到最扁时翻面)
+ s.pivot = 'ground'; const flip = f >= 690; s.dir = flip ? -1 : 1;
+ s.x = kf(f, [[686, 1160], [688, 1168], [690, 1150], [694, 1122], [698, 1118]], ease.out);
+ s.pose = f < 688 ? LAND : mixPose(LAND, SIT_T, ease.out(seg(f, 688, 696)));
+ s.sy = kf(f, [[686, 0.86], [688, 0.72], [690, 0.7], [692, 0.96], [694, 1.07], [696, 0.98], [698, 1]], ease.inOut);
+ s.sx = kf(f, [[686, 1.12], [688, 1.18], [690, 1.15], [692, 1.0], [694, 0.95], [698, 1]], ease.inOut);
+ s.y = 628 - s.pose.gy; // 爪子踩在笔记本面上
+ } else { // 桌上坐
+ s.pose = SIT_T; s.x = 1118; s.y = 497; s.dir = -1; s.pivot = 'ground';
+ s.sy = 1 + Math.sin(t * 3) * 0.006;
+ }
+ // 起跳烟尘 664–670
+ s.dust = seg(f, 662, 672);
+ // 表情
+ if (f >= 664 && f < 692) s.eyes = 'wide';
+ if (f >= 835) { s.eyes = 'smug'; if ((f >= 856 && f < 876) || (f >= 886 && f < 893)) s.eyes = 'happy'; }
+ s.look = f >= 698 && f < 744 ? 0 : f >= 744 && f < 800 ? -4 : s.look;
+ return s;
+ }
+ // 拍杯:每次 f0 = 杯子开始动的帧;爪子预备 6 帧→ 4 帧击出→ 停 4 帧→ 6 帧收回
+ const SWIPES = [744, 766, 786];
+ function pawReach(f) {
+ for (const f0 of SWIPES) {
+ if (f >= f0 - 7 && f < f0 + 16) {
+ if (f < f0) return { k: 'wind', q: ease.inOut(seg(f, f0 - 7, f0)), f0 };
+ if (f < f0 + 4) return { k: 'hit', q: ease.out(seg(f, f0, f0 + 4)), f0 };
+ if (f < f0 + 8) return { k: 'hold', q: 1, f0 };
+ return { k: 'back', q: ease.inOut(seg(f, f0 + 8, f0 + 16)), f0 };
+ }
+ }
+ return null;
+ }
+ function drawCat(c, s, f, t, cupX) {
+ const p = s.pose;
+ c.save(); c.translate(s.x, s.y);
+ const gy = p.gy;
+ if (s.pivot === 'ground') { c.translate(0, gy); c.rotate(s.rot); c.scale(s.dir * s.sx, s.sy); c.translate(0, -gy); }
+ else { c.rotate(s.rot); c.scale(s.dir * s.sx, s.sy); }
+ // 拍杯时:身体前倾,前爪伸向杯子(世界坐标 → 局部)
+ let front = p.front.map(l => l.slice()), lean = 0;
+ const pr = f >= 736 && f < 805 ? pawReach(f) : null;
+ const watch = f >= 724 && f < 812 ? Math.min(seg(f, 724, 736), 1 - seg(f, 800, 812)) * 0.08 : 0; // 拍杯段之间盯着杯子、身子微倾
+ if (pr) {
+ // 先按「肩到杯沿的世界距离」定这一拍要趴多低,再施加前倾,最后用当前变换的逆矩阵把杯沿换回局部坐标——保证爪子真的碰到杯子
+ const cxw = (pr.k === 'wind' ? cupX(pr.f0) : cupX(Math.min(f, pr.f0 + 4))) + 34; // 杯子右沿(世界)
+ const Lmax = 0.1 + 0.28 * clamp((s.x - 70 - cxw - 40) / 130);
+ lean = pr.k === 'wind' ? lerp(watch, Lmax * 0.45, pr.q) : pr.k === 'hit' ? lerp(Lmax * 0.45, Lmax, pr.q) : pr.k === 'hold' ? Lmax : lerp(Lmax, watch, pr.q);
+ c.translate(0, gy); c.rotate(-lean); c.scale(1, 1 - lean * 0.35); c.translate(0, -gy);
+ const m = c.getTransform().invertSelf(), tw = m.transformPoint(new DOMPoint(cxw, 606)), tgt = [tw.x, tw.y];
+ const rest = [p.front[0][2], p.front[0][3]], up = [p.front[0][0] + 34, p.front[0][1] - 30];
+ let pt;
+ if (pr.k === 'wind') pt = [lerp(rest[0], up[0], pr.q), lerp(rest[1], up[1], pr.q)];
+ else if (pr.k === 'hit') pt = [lerp(up[0], tgt[0], pr.q), lerp(up[1], tgt[1], pr.q)];
+ else if (pr.k === 'hold') pt = tgt;
+ else pt = [lerp(tgt[0], rest[0], pr.q), lerp(tgt[1], rest[1], pr.q)];
+ front[0] = [p.front[0][0] + 8, p.front[0][1] - 10, pt[0], pt[1]];
+ } else if (watch) { lean = watch; c.translate(0, gy); c.rotate(-lean); c.scale(1, 1 - lean * 0.35); c.translate(0, -gy); }
+ // 尾巴:粗线条,尖端白;坐着时慢摆,拍杯时甩
+ const tl = p.tail.map(q => q.slice()); const sw = Math.sin(t * 4.4) * 14 + (pr ? Math.sin(t * 14) * 10 : 0);
+ tl[3][0] += sw * 0.6; tl[3][1] += sw; tl[2][0] += sw * 0.3;
+ c.lineCap = 'round'; c.lineJoin = 'round';
+ const tailP = new Path2D(); tailP.moveTo(...tl[0]); tailP.bezierCurveTo(...tl[1], ...tl[2], ...tl[3]);
+ c.strokeStyle = C.orange; c.lineWidth = 30; c.stroke(tailP);
+ c.save(); c.setLineDash([9, 16]); c.lineDashOffset = 4; c.strokeStyle = C.orangeDk; c.lineWidth = 30; c.lineCap = 'butt'; c.stroke(tailP); c.restore(); // 尾巴环纹
+ if (p.tipW > 0.05) { c.save(); c.globalAlpha = p.tipW; c.clip((() => { const q = new Path2D(); q.arc(tl[3][0], tl[3][1], 26, 0, 7); return q; })()); c.strokeStyle = C.catWhite; c.lineWidth = 30; c.stroke(tailP); c.restore(); }
+ // 后腿(腾空时可见)
+ const hindP = RIG.taper([p.hind[0], p.hind[1]], [p.hind[2], p.hind[3]], 46, 30, 6); c.fillStyle = C.orangeDk; c.fill(hindP);
+ // 远侧前腿
+ const leg = (l, col) => { c.fillStyle = col; c.fill(RIG.taper([l[0], l[1]], [l[2], l[3]], 32, 28)); c.fillStyle = C.catWhite; c.beginPath(); c.ellipse(l[2], l[3] - 2, 21, 13, 0, 0, 7); c.fill(); c.strokeStyle = '#e6d6c2'; c.lineWidth = 2.5; c.stroke(); };
+ leg(front[1], '#f3e9dc');
+ // 身体
+ const body = smooth(p.body); c.fillStyle = C.orange; c.fill(body);
+ c.save(); c.clip(body);
+ c.fillStyle = C.catWhite; c.fill(smooth(p.chest));
+ // 背部虎斑
+ c.strokeStyle = C.orangeDk; c.lineWidth = 10; c.lineCap = 'round';
+ p.stripes.forEach(st => { c.beginPath(); c.moveTo(st[0], st[1]); c.lineTo(st[2], st[3]); c.stroke(); });
+ // 后腿大腿(haunch):同色块+一道深色弧边,扁平插画靠这一笔分出体块
+ const [hX, hY, hrx, hry] = p.haunch;
+ c.fillStyle = '#f3ad4c'; c.beginPath(); c.ellipse(hX, hY, hrx, hry, 0, 0, 7); c.fill();
+ c.strokeStyle = C.orangeDk; c.lineWidth = 6; c.beginPath(); c.ellipse(hX, hY, hrx, hry, 0, -0.2 * Math.PI, 0.75 * Math.PI, true); c.stroke();
+ c.lineWidth = 8; [[-0.5, 0.15], [-0.15, 0.2]].forEach(([a0, w]) => { c.beginPath(); c.moveTo(hX + Math.cos(Math.PI + a0) * hrx * 0.95, hY + Math.sin(Math.PI + a0) * hry * 0.95); c.lineTo(hX + Math.cos(Math.PI + a0) * hrx * 0.55, hY + Math.sin(Math.PI + a0) * hry * 0.55); c.stroke(); });
+ c.restore();
+ c.fillStyle = C.catWhite; c.beginPath(); c.ellipse(p.hind[2], p.hind[3], 20, 12, 0, 0, 7); c.fill();
+ // 近侧前腿(拍杯那只)
+ leg(front[0], C.catWhite);
+ // 头
+ const [hx, hy0, rx, ry] = p.head, hy = hy0 + (s.poseHeadDy || 0);
+ c.save(); c.translate(hx, hy); c.rotate(pr ? -0.08 : 0);
+ const ea = p.ear;
+ const ear = (x, sgn) => { c.fillStyle = C.orange; c.beginPath(); c.moveTo(x - 26, -ry * 0.55); c.lineTo(x + sgn * 4 - ea * 30 * sgn * 0 - ea * 20, -ry - 30 + ea * 22); c.lineTo(x + 26, -ry * 0.62); c.closePath(); c.fill();
+ c.fillStyle = C.earIn; c.beginPath(); c.moveTo(x - 13, -ry * 0.62); c.lineTo(x + sgn * 3 - ea * 20, -ry - 16 + ea * 20); c.lineTo(x + 13, -ry * 0.66); c.closePath(); c.fill(); };
+ ear(-30, -1); ear(32, 1);
+ c.fillStyle = C.orange; c.beginPath(); c.ellipse(0, 0, rx, ry, 0, 0, 7); c.fill();
+ c.fillStyle = C.catWhite; c.beginPath(); c.ellipse(10, ry * 0.42, rx * 0.55, ry * 0.42, 0, 0, 7); c.fill();
+ c.strokeStyle = C.orangeDk; c.lineWidth = 6; c.lineCap = 'round'; [-10, 4, 18].forEach(x => { c.beginPath(); c.moveTo(x, -ry + 8); c.lineTo(x, -ry + 26); c.stroke(); });
+ // 五官
+ const E1 = [-14 + s.look, -4], E2 = [32 + s.look, -4];
+ c.fillStyle = C.blush; [[-28, 18], [50, 18]].forEach(([x, y]) => { c.globalAlpha = s.eyes === 'smug' || s.eyes === 'happy' ? 0.95 : 0.7; c.beginPath(); c.ellipse(x, y, s.eyes === 'smug' || s.eyes === 'happy' ? 15 : 12, 9, 0, 0, 7); c.fill(); }); c.globalAlpha = 1;
+ c.strokeStyle = C.navy; c.fillStyle = C.navy; c.lineWidth = 4.5;
+ [E1, E2].forEach(([x, y]) => {
+ if (s.eyes === 'smug') { c.beginPath(); c.arc(x, y - 6, 10, 0.2 * Math.PI, 0.8 * Math.PI); c.stroke(); }
+ else if (s.eyes === 'happy') { c.beginPath(); c.arc(x, y + 4, 9, 1.1 * Math.PI, 1.9 * Math.PI); c.stroke(); }
+ else { const r = s.eyes === 'wide' ? 9 : 8; c.beginPath(); c.ellipse(x, y, r * 0.85, r, 0, 0, 7); c.fill(); c.fillStyle = '#fff'; c.beginPath(); c.arc(x - 2, y - 3, 2.6, 0, 7); c.fill(); c.fillStyle = C.navy; }
+ });
+ c.fillStyle = '#e8706a'; c.beginPath(); c.moveTo(4, 12); c.lineTo(14, 12); c.lineTo(9, 18); c.closePath(); c.fill();
+ c.strokeStyle = C.navy; c.lineWidth = 2.6; c.beginPath(); c.moveTo(-1, 19); c.quadraticCurveTo(4, 25, 9, 19); c.quadraticCurveTo(14, 25, 19, 19); c.stroke();
+ c.strokeStyle = '#ffffff'; c.lineWidth = 2.2; [[-40, 10, -78, 2], [-40, 18, -80, 22], [58, 10, 98, 2], [58, 18, 100, 22]].forEach(([a, b2, c2, d]) => { c.beginPath(); c.moveTo(a, b2); c.lineTo(c2, d); c.stroke(); });
+ c.restore();
+ c.restore();
+ }
+ // 起跳烟尘:几团米色小圆往外扩散、变淡
+ function dust(c, q) {
+ if (q <= 0 || q >= 1) return; c.save(); c.fillStyle = `rgba(214,196,170,${0.7 * (1 - q)})`;
+ [[-1, 0.8], [-0.5, 1.2], [0.4, 1], [1, 0.7]].forEach(([d, s]) => { c.beginPath(); c.arc(560 + d * (30 + 60 * q), 900 - 10 * q * s, (8 + 16 * q) * s, 0, 7); c.fill(); });
+ c.restore();
+ }
+
+ // ---------- 杯子 ----------
+ const CUPX = [[744, 981], [746, 975], [748, 949], [750, 937], [752, 932], [766, 932], [768, 906], [770, 887], [772, 879], [774, 877], [786, 877], [788, 865], [790, 830], [792, 811], [794, 802], [796, 801]];
+ const cupX = (f) => kf(f, CUPX, ease.linear);
+ const FALL = [[796, 801, 605], [798, 794, 612], [800, 786, 623], [802, 776, 640], [804, 766, 664], [806, 755, 695], [808, 746, 733], [810, 739, 779], [812, 738, 831], [814, 743, 887], [815, 744, 896]];
+ function cupState(f) {
+ if (f < 796) return { x: cupX(f), y: 605, rot: f > 790 ? -0.12 * seg(f, 790, 796) : 0, on: true };
+ if (f < 815) { const [x, y] = path(f, FALL); return { x, y, rot: -0.12 - 2.3 * Math.pow(seg(f, 796, 815), 1.3), on: false }; }
+ return null;
+ }
+ function drawMug(c, x, y, rot, s = 1) {
+ c.save(); c.translate(x, y); c.rotate(rot); c.scale(s, s);
+ c.strokeStyle = C.cup; c.lineWidth = 9; c.beginPath(); c.arc(-34, -2, 15, 0, 7); c.stroke();
+ c.fillStyle = C.cup; c.beginPath(); c.roundRect(-30, -32, 60, 66, [6, 6, 14, 14]); c.fill();
+ c.fillStyle = C.cupDk; c.beginPath(); c.roundRect(12, -32, 18, 66, [0, 6, 14, 0]); c.fill();
+ c.fillStyle = '#7a3a1a'; c.beginPath(); c.ellipse(0, -32, 30, 5, 0, 0, 7); c.fill();
+ c.strokeStyle = '#fff4ea'; c.lineWidth = 1.6; c.beginPath(); c.moveTo(-4, -33); c.lineTo(-6, -8); c.stroke();
+ c.fillStyle = '#fff4ea'; c.beginPath(); c.roundRect(-14, -8, 16, 18, 3); c.fill(); c.fillStyle = '#4aa36a'; c.beginPath(); c.arc(-6, 1, 4, 0, 7); c.fill();
+ c.restore();
+ }
+ // 杯子坠落时身后的咖啡滴:沿杯子过去的轨迹排一串,越早越小
+ function drips(c, f) {
+ if (f < 799 || f > 816) return;
+ for (let k = 1; k <= 6; k++) { const ff = f - k * 1.3; if (ff < 797) continue; const [x, y] = path(ff, FALL); const r = 7 - k * 0.8;
+ c.fillStyle = C.coffee; c.beginPath(); c.ellipse(x + 10 + k * 3, y - 30 - k * 2, r * 0.8, r * 1.2, 0, 0, 7); c.fill(); }
+ }
+ // 拍杯的动线记号:杯子右侧 3 道短线(击中后 10 帧淡出)
+ function motionMarks(c, f) {
+ for (const f0 of SWIPES) { const q = (f - f0) / 12; if (q < 0 || q > 1) continue; const x = cupX(f) + 44, a = 1 - q;
+ c.save(); c.strokeStyle = `rgba(38,42,92,${a})`; c.lineWidth = 4; c.lineCap = 'round';
+ [[-0.6, 0], [0, 6], [0.6, 2]].forEach(([ang, o], i) => { c.beginPath(); const r0 = 12 + q * 10, r1 = 30 + q * 14; c.moveTo(x + Math.cos(ang) * r0, 588 + Math.sin(ang) * r0 * 1.5); c.lineTo(x + Math.cos(ang) * r1, 588 + Math.sin(ang) * r1 * 1.5); c.stroke(); });
+ c.restore(); }
+ }
+ // 碎裂:放射线、两块大碎片抛物线(分镜表三点)、小碎屑、咖啡渍扩散、灰色涟漪
+ const quad3 = (f, a, b, c3) => { // 三点 (f,x,y) 抛物线插值(拉格朗日)
+ const L = (x0, x1, x2, v0, v1, v2) => v0 * ((f - x1) * (f - x2)) / ((x0 - x1) * (x0 - x2)) + v1 * ((f - x0) * (f - x2)) / ((x1 - x0) * (x1 - x2)) + v2 * ((f - x0) * (f - x1)) / ((x2 - x0) * (x2 - x1));
+ return [L(a[0], b[0], c3[0], a[1], b[1], c3[1]), L(a[0], b[0], c3[0], a[2], b[2], c3[2])];
+ };
+ const SHARDS = [{ a: [818, 723, 860], b: [824, 683, 827], c: [834, 673, 897], pts: [[-26, -14], [10, -24], [24, 6], [-6, 22], [-22, 10]], rot: -3 },
+ { a: [818, 792, 849], b: [824, 830, 797], c: [834, 830, 891], pts: [[-20, -20], [22, -12], [18, 18], [-14, 16]], rot: 4 }];
+ const BITS = Array.from({ length: 9 }, (_, i) => { const r = U.rng(300 + i); return { vx: (r() - 0.5) * 9, vy: -4 - r() * 6, s: 6 + r() * 7, col: [C.cup, C.cup, C.coffee, '#fff4ea', C.cupDk][i % 5], spin: (r() - 0.5) * 0.6, land: 893 + r() * 18 }; });
+ function smash(c, f) {
+ if (f < 815) return;
+ const X = 744, Y = 896;
+ // 咖啡渍(818: 宽140 → 822: 220 → 826: 235)
+ const sw = kf(f, [[815, 30], [818, 140], [822, 220], [826, 235]], ease.out);
+ c.fillStyle = C.coffee; c.beginPath(); c.ellipse(X + 8, Y + 4, sw / 2, sw * 0.085 + 4, 0, 0, 7); c.fill();
+ c.fillStyle = C.coffeeLt; c.beginPath(); c.ellipse(X - 10, Y + 1, sw * 0.18, sw * 0.022 + 1, 0, 0, 7); c.fill();
+ // 灰色涟漪:两圈,最宽 ~560,838 消失
+ [[818, 838], [822, 840]].forEach(([a, b], i) => { const q = seg(f, a, b); if (q <= 0 || q >= 1) return; const w = lerp(160, 560 - i * 100, ease.out(q));
+ c.strokeStyle = `rgba(110,105,130,${0.75 * (1 - q)})`; c.lineWidth = 3.5; c.beginPath(); c.ellipse(X + 10, Y + 6, w / 2, w * 0.075, 0, 0, 7); c.stroke(); });
+ // 冲击放射线(815–823)
+ const iq = seg(f, 815, 823); if (iq < 1) { c.save(); c.strokeStyle = `rgba(38,42,92,${1 - iq})`; c.lineWidth = 5; c.lineCap = 'round';
+ for (let k = 0; k < 7; k++) { const a = -Math.PI + (k + 0.5) / 7 * Math.PI, r0 = 30 + iq * 40, r1 = 58 + iq * 52; c.beginPath(); c.moveTo(X + Math.cos(a) * r0, Y - 6 + Math.sin(a) * r0 * 0.75); c.lineTo(X + Math.cos(a) * r1, Y - 6 + Math.sin(a) * r1 * 0.75); c.stroke(); } c.restore(); }
+ // 小碎屑:抛出去落地后停住
+ BITS.forEach((b, i) => { const tt = Math.max(0, f - 815); let x = X + b.vx * tt, y = Y - 10 + b.vy * tt + 0.9 * tt * tt * 0.5; if (y > b.land) { const tl = (-b.vy + Math.sqrt(b.vy * b.vy + 2 * 0.45 * 2 * (b.land - Y + 10))) / 0.9; x = X + b.vx * Math.max(0, tl); y = b.land; }
+ c.save(); c.translate(x, y); c.rotate(b.spin * Math.min(tt, 18)); c.fillStyle = b.col; c.beginPath(); c.moveTo(-b.s / 2, -b.s / 3); c.lineTo(b.s / 2, -b.s / 2); c.lineTo(b.s / 3, b.s / 2); c.lineTo(-b.s / 2, b.s / 3); c.closePath(); c.fill(); c.restore(); });
+ // 两块大碎片
+ SHARDS.forEach(s => { const ff = Math.min(f, 834); const [x, y] = ff < 818 ? [lerp(X, s.a[1], seg(ff, 815, 818)), lerp(Y - 10, s.a[2], seg(ff, 815, 818))] : quad3(ff, s.a, s.b, s.c);
+ c.save(); c.translate(x, y); c.rotate(s.rot * seg(ff, 815, 834) * 0.6); c.fillStyle = C.cup; c.beginPath(); s.pts.forEach((p, i) => i ? c.lineTo(...p) : c.moveTo(...p)); c.closePath(); c.fill();
+ c.fillStyle = C.cupDk; c.beginPath(); c.moveTo(...s.pts[0]); c.lineTo(...s.pts[1]); c.lineTo(0, 0); c.closePath(); c.fill(); c.restore(); });
+ // 把手(半圆)和茶包标签留在地上
+ if (f > 817) { c.strokeStyle = C.cup; c.lineWidth = 8; c.beginPath(); c.arc(X + 30, Y - 4, 13, Math.PI, 0); c.stroke(); c.fillStyle = '#fff4ea'; c.save(); c.translate(X - 12, Y - 4); c.rotate(0.5); c.fillRect(-8, -8, 16, 16); c.fillStyle = '#4aa36a'; c.beginPath(); c.arc(0, 0, 4, 0, 7); c.fill(); c.restore(); }
+ }
+
+ // ---------- 笔记本+打字气泡 ----------
+ function laptop(c, f, t) {
+ const lid = ease.in(seg(f, 685, 689)); // 猫落下来把盖子压上
+ c.fillStyle = C.laptop; c.beginPath(); c.roundRect(1062, 626, 130, 14, 4); c.fill();
+ c.fillStyle = C.laptopDk; c.fillRect(1066, 636, 122, 4);
+ const a = lerp(-1.91, 0.02, lid), L = 116;
+ c.save(); c.translate(1066, 628); c.rotate(a); c.fillStyle = '#b6a8ee'; c.beginPath(); c.roundRect(0, -5, L, 9, 4); c.fill(); c.restore();
+ // 「•••」正在输入气泡
+ const bs = f < 685 ? 1 : 1 - ease.in(seg(f, 685, 689));
+ if (bs > 0.01) { c.save(); c.translate(1088, 482); c.scale(bs, bs); c.fillStyle = C.white; c.beginPath(); c.roundRect(-30, -18, 60, 36, 18); c.fill(); c.beginPath(); c.moveTo(-14, 14); c.lineTo(-22, 30); c.lineTo(-2, 16); c.fill();
+ c.fillStyle = '#8a7ad8'; for (let k = 0; k < 3; k++) { const j = Math.max(0, Math.sin(t * 10 - k * 0.9)) * 5; c.beginPath(); c.arc(-14 + k * 14, -j, 5, 0, 7); c.fill(); } c.restore(); }
+ }
+ function steam(c, t, x, y, a) {
+ if (a <= 0) return; c.save(); c.globalAlpha = a; c.strokeStyle = '#ffffff'; c.lineWidth = 5; c.lineCap = 'round';
+ for (let k = 0; k < 2; k++) { c.beginPath(); for (let s = 0; s <= 16; s++) { const q = s / 16, yy = y - q * 70, xx = x + (k - 0.5) * 18 + Math.sin(t * 6 + k * 2 - q * 6) * 7 * q; s ? c.lineTo(xx, yy) : c.moveTo(xx, yy); } c.stroke(); }
+ c.restore();
+ }
+
+ // ---------- 签名:844–870 从左往右写出,下划线跟着画 ----------
+ function signature(c, f) {
+ if (f < 842) return;
+ const front = kf(f, [[842, 1606], [844, 1646], [848, 1682], [852, 1721], [856, 1762], [860, 1801], [864, 1835], [868, 1861], [870, 1868]], ease.linear);
+ const txt = window.SIGNATURE || 'Opus 5.5';
+ c.save(); c.font = '64px "Caveat-600"'; const w = c.measureText(txt).width, sc = Math.min(1.3, 236 / w);
+ c.beginPath(); c.rect(0, 960, front, 120); c.clip();
+ c.fillStyle = C.navy; c.translate(1614, 1032); c.rotate(-0.03); c.scale(sc, sc); c.fillText(txt, 0, 0); c.restore();
+ // 下划线:一笔略弯的线,尾端渐细
+ c.save(); c.beginPath(); c.rect(0, 960, front, 120); c.clip(); c.strokeStyle = C.navy; c.lineCap = 'round';
+ for (let k = 0; k < 24; k++) { const q0 = k / 24, q1 = (k + 1) / 24, X = q => lerp(1606, 1866, q), Y = q => 1046 - Math.sin(q * Math.PI) * 4 - q * 7; c.lineWidth = 3.4 * (1 - q0 * 0.6); c.beginPath(); c.moveTo(X(q0), Y(q0)); c.lineTo(X(q1), Y(q1)); c.stroke(); }
+ c.restore();
+ }
+
+ return {
+ draw(c, lt, t) {
+ const f = FR(t);
+ c.drawImage(P.cached('fl_bg', W, H, background), 0, 0);
+ sky(c, t); decos(c, t);
+ // 环境二次动作:吊灯 686–737 / 830–884,植物 697–741 晃 / 821–889 抖
+ const lampA = damped(f, 686, 0.055, 26, 22) + damped(f, 830, 0.045, 22, 20) + Math.sin(t * 1.3) * 0.004;
+ const plantA = damped(f, 697, 0.035, 22, 18) + damped(f, 821, 0.05, 9, 26) + Math.sin(t * 1.7) * 0.006;
+ snakePlant(c, -plantA * 0.8); monstera(c, plantA, f);
+ lamp(c, lampA);
+ // 地上的碎片在桌子前
+ smash(c, f);
+ // 角色层(之后整体加颗粒)
+ const L = P.scratch('fl_chars'), g = L.getContext('2d'); g.clearRect(0, 0, W, H);
+ const cs = cupState(f);
+ if (cs && cs.on) { drawMug(g, cs.x, cs.y, cs.rot); }
+ girl(g, f, t, 'back');
+ laptop(g, f, t);
+ const hd = girl(g, f, t, 'body');
+ const st = catState(f, t);
+ if (f < 690) girl(g, f, t, 'front');
+ drawCat(g, st, f, t, cupX);
+ if (f >= 690) girl(g, f, t, 'front');
+ if (cs && !cs.on) { drips(g, f); drawMug(g, cs.x, cs.y, cs.rot); }
+ g.save(); g.globalCompositeOperation = 'source-atop'; g.globalAlpha = 0.9; g.drawImage(grainTex(), 0, 0); g.restore();
+ c.drawImage(L, 0, 0);
+ dust(c, st.dust);
+ if (cs && cs.on) steam(c, t, cs.x - 2, cs.y - 42, 1 - seg(f, 786, 796));
+ motionMarks(c, f);
+ tension(c, f, hd.headTop);
+ signature(c, f);
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/17_ink.js b/scripts/engine/scenes/17_ink.js
new file mode 100644
index 0000000..59cc47c
--- /dev/null
+++ b/scripts/engine/scenes/17_ink.js
@@ -0,0 +1,273 @@
+// 中国水墨写意(八大山人/齐白石)——纯代码。
+// 管线:①宣纸(缓存)→ ②淡墨远山+朱日(晕染层)→ ③窗/桌:飞白笔触 → ④竹枝(浓墨个字叶,随风摆)
+// → ⑤挂轴里的齐白石虾(游动)→ ⑥猫:赭石没骨晕染+留白+焦墨点斑,八大式白眼
+// → ⑦少女:花青淡彩汉服+藤黄金发+白描面部 → ⑧热气、钤印
+// 「画出来」开场:lt 0→0.45 各笔按序写出、各晕染层从无到有洇开;之后墨晕继续缓慢外扩(墨在纸上晕开)。
+SCENES['17_ink'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, rng, ease } = U, P = PAINT;
+ const { ss } = U;
+
+ // ---------- 宣纸 ----------
+ const paper = () => P.cached('ink_paper', W, H, (g) => {
+ g.drawImage(P.texture('xuan', '#efe6d0', { scale: 0.0025, amt: 9, grain: 7, seed: 5 }), 0, 0);
+ const r = rng(41);
+ g.lineCap = 'round';
+ for (let i = 0; i < 2600; i++) { // 纸纤维:短弧,亮暗混合
+ const x = r() * W, y = r() * H, a = r() * Math.PI * 2, l = 6 + r() * 26;
+ g.strokeStyle = r() < 0.5 ? `rgba(150,125,90,${0.05 + r() * 0.08})` : `rgba(255,252,240,${0.12 + r() * 0.15})`;
+ g.lineWidth = 0.6 + r() * 0.8; g.beginPath(); g.moveTo(x, y); g.quadraticCurveTo(x + Math.cos(a + 0.6) * l * 0.5, y + Math.sin(a + 0.6) * l * 0.5, x + Math.cos(a) * l, y + Math.sin(a) * l); g.stroke();
+ }
+ const vg = g.createRadialGradient(W / 2, H / 2, 500, W / 2, H / 2, 1250); vg.addColorStop(0, 'rgba(0,0,0,0)'); vg.addColorStop(1, 'rgba(120,90,50,.22)');
+ g.fillStyle = vg; g.fillRect(0, 0, W, H);
+ });
+
+ // 笔、叶、晕染都用库:P.brush(毛笔飞白)、P.leaf(两头尖单笔)、P.inkWash(墨晕洇开)
+ const brush = P.brush, leaf = P.leaf;
+ const washLayer = (c, key, grow, fn, o) => P.inkWash(c, 'ink_' + key, grow, fn, o);
+
+ // ---------- 静态笔触表(窗、桌、地) ----------
+ const WIN = [
+ { p: [[338, 116], [520, 112], [700, 118], [824, 114]], w: 16, d: 0.06, l: 0.18, dry: 0.55 },
+ { p: [[352, 104], [348, 300], [356, 470], [350, 578]], w: 15, d: 0.1, l: 0.16, dry: 0.5 },
+ { p: [[808, 108], [812, 330], [806, 572]], w: 14, d: 0.14, l: 0.16, dry: 0.6 },
+ { p: [[318, 572], [560, 566], [842, 574]], w: 18, d: 0.18, l: 0.16, dry: 0.45 },
+ { p: [[372, 140], [420, 140], [420, 186]], w: 4, d: 0.22, l: 0.08, dry: 0.3 }, { p: [[788, 140], [740, 140], [740, 186]], w: 4, d: 0.24, l: 0.08, dry: 0.3 },
+ { p: [[372, 546], [420, 546], [420, 500]], w: 4, d: 0.26, l: 0.08, dry: 0.3 }, { p: [[788, 546], [740, 546], [740, 500]], w: 4, d: 0.28, l: 0.08, dry: 0.3 },
+ ];
+ const TABLE = [
+ { p: [[800, 622], [1000, 614], [1212, 620]], w: 22, d: 0.12, l: 0.15, dry: 0.5 },
+ { p: [[820, 640], [1000, 646], [1196, 640]], w: 7, d: 0.2, l: 0.1, dry: 0.4 },
+ { p: [[842, 640], [846, 760], [838, 906]], w: 13, d: 0.18, l: 0.16, dry: 0.65 },
+ { p: [[1176, 640], [1172, 780], [1182, 906]], w: 13, d: 0.22, l: 0.16, dry: 0.65 },
+ { p: [[848, 664], [900, 690], [960, 676]], w: 5, d: 0.26, l: 0.1, dry: 0.4 }, { p: [[1170, 664], [1118, 690], [1058, 676]], w: 5, d: 0.28, l: 0.1, dry: 0.4 },
+ { p: [[300, 912], [700, 904], [1100, 914], [1520, 908]], w: 5, d: 0.3, l: 0.15, dry: 0.85, tone: 0.35 },
+ ];
+ const SKIRT = [
+ { p: [[1244, 630], [1190, 656], [1150, 722], [1118, 820], [1104, 926]], w: 6, dry: 0.3 },
+ { p: [[1420, 612], [1446, 650], [1452, 722], [1440, 762], [1366, 774], [1344, 806], [1352, 926]], w: 6, dry: 0.4 },
+ { p: [[1104, 928], [1220, 934], [1352, 928]], w: 5, dry: 0.6 },
+ { p: [[1232, 668], [1222, 760], [1226, 815]], w: 4, dry: 0.3 }, { p: [[1268, 668], [1262, 760], [1270, 840]], w: 4, dry: 0.3 },
+ { p: [[1160, 770], [1150, 860], [1146, 920]], w: 4, dry: 0.4 }, { p: [[1302, 830], [1308, 880], [1300, 925]], w: 4, dry: 0.4 },
+ { p: [[1350, 434], [1382, 448], [1406, 486], [1418, 546], [1424, 604]], w: 6, dry: 0.35 },
+ ];
+
+ // ---------- 远山、朱日 ----------
+ function mountains(g) {
+ g.save(); g.beginPath(); g.rect(366, 132, 428, 428); g.clip();
+ const R1 = rng(3);
+ const ridge = (y0, amp, f, seed) => { const pts = []; for (let x = 340; x <= 830; x += 10) pts.push([x, y0 - amp * (0.5 + 0.5 * P.fbm(x * f + seed, seed, 3)) - amp * 0.6 * Math.exp(-Math.pow((x - 560 - seed * 40) / 120, 2))]); return pts; };
+ const fill = (pts, a, y1) => { const gr = g.createLinearGradient(0, Math.min(...pts.map(p => p[1])), 0, y1); gr.addColorStop(0, `rgba(40,40,44,${a})`); gr.addColorStop(1, 'rgba(40,40,44,0)'); g.fillStyle = gr; g.beginPath(); pts.forEach((p, i) => i ? g.lineTo(...p) : g.moveTo(...p)); g.lineTo(830, y1); g.lineTo(340, y1); g.closePath(); g.fill(); };
+ fill(ridge(380, 120, 0.006, 1), 0.32, 520); fill(ridge(450, 90, 0.009, 2.4), 0.5, 560);
+ g.restore();
+ }
+
+ // ---------- 竹(窗前,从右上斜入) ----------
+ function bamboo(c, t, rev) {
+ const sw = Math.sin(t * 2.9) * 0.11 + Math.sin(t * 6.1 + 1) * 0.025;
+ const base = [835, 70];
+ const rot = (x, y, k) => { const a = sw * k, dx = x - base[0], dy = y - base[1]; return [base[0] + dx * Math.cos(a) - dy * Math.sin(a), base[1] + dx * Math.sin(a) + dy * Math.cos(a)]; };
+ // 主枝:分节(每节一笔,节间留白),淡墨
+ const nodes = [[835, 70], [760, 150], [690, 215], [620, 268], [550, 312]];
+ for (let i = 0; i < nodes.length - 1; i++) {
+ const a = rot(...nodes[i], i / 4), b = rot(...nodes[i + 1], (i + 1) / 4);
+ const q0 = 0.04, A = [lerp(a[0], b[0], q0), lerp(a[1], b[1], q0)], B = [lerp(a[0], b[0], 0.94), lerp(a[1], b[1], 0.94)];
+ brush(c, [A, [lerp(A[0], B[0], .5), lerp(A[1], B[1], .5)], B], { w: 9, tone: 0.5, dry: 0.3, seed: 60 + i, reveal: ss(0.08 + i * 0.03, 0.18 + i * 0.03, rev), head: 0.06, tail: 0.1, bristles: 5 });
+ }
+ // 叶:个字、介字组,浓墨
+ const groups = [[2, -0.2, 0], [3, 0.4, 1], [4, -0.9, 2], [3, 2.2, 3], [4, 0.9, 4]];
+ groups.forEach(([ni, a0, gi]) => {
+ const np = nodes[Math.min(nodes.length - 1, ni)];
+ const p = rot(np[0], np[1], ni / 4); const flut = Math.sin(t * 7 + gi * 1.3) * 0.2;
+ const rv = ss(0.2 + gi * 0.04, 0.3 + gi * 0.04, rev); if (rv <= 0) return;
+ [[0, 1], [0.45, 0.82], [-0.42, 0.78]].forEach(([da, ls], k) => leaf(c, p[0], p[1], a0 + 1.4 + da + flut * (1 + k * 0.4) + sw * 2, 110 * ls * rv, 15, 0.86));
+ });
+ }
+
+ // ---------- 挂轴+齐白石虾 ----------
+ function scrollStatic(g) {
+ g.fillStyle = 'rgba(170,140,95,.32)'; g.fillRect(1560, 240, 230, 640); // 绫边
+ g.fillStyle = 'rgba(250,246,234,.9)'; g.fillRect(1580, 290, 190, 540);
+ g.fillStyle = 'rgba(60,40,25,.85)'; g.fillRect(1548, 870, 254, 16); g.fillRect(1556, 232, 238, 10);
+ g.strokeStyle = 'rgba(60,40,25,.6)'; g.lineWidth = 1.5; g.beginPath(); g.moveTo(1640, 232); g.lineTo(1675, 196); g.lineTo(1710, 232); g.stroke();
+ g.fillStyle = '#c23a2b'; g.fillRect(1742, 788, 16, 16);
+ }
+ function shrimp(c, x, y, ang, s, t, ph) {
+ c.save(); c.translate(x, y); c.rotate(ang); c.scale(s, s);
+ const flex = Math.sin(t * 7 + ph) * 0.12;
+ // 身体:6 节淡墨弧,从头到尾弯曲
+ let px = 0, py = 0, a = 0; const segs = [];
+ for (let i = 0; i < 6; i++) { a += 0.2 + flex; const l = 13 - i * 1.2; px += Math.cos(a) * l; py += Math.sin(a) * l; segs.push([px, py, a, 11 - i * 1.3]); }
+ segs.forEach(([sx, sy, sa, sw], i) => { c.fillStyle = `rgba(30,28,26,${0.22 + i * 0.03})`; c.beginPath(); c.ellipse(sx, sy, 9, sw * 1.05, sa + 0.25, 0, Math.PI * 2); c.fill(); c.strokeStyle = 'rgba(20,18,16,.3)'; c.lineWidth = 2.4; c.beginPath(); c.ellipse(sx, sy, 9, sw * 1.05, sa + 0.25, -1.2, 1.2); c.stroke(); });
+ const tl = segs[5]; [-0.5, 0, 0.5].forEach(d => leaf(c, tl[0], tl[1], tl[2] + d + 0.4, 15, 6, 0.4));
+ // 头胸甲:淡墨+中间一笔焦墨
+ c.fillStyle = 'rgba(30,28,26,.33)'; c.beginPath(); c.ellipse(-10, -2, 17, 10, -0.15, 0, Math.PI * 2); c.fill();
+ c.fillStyle = 'rgba(10,10,10,.9)'; c.beginPath(); c.ellipse(-8, -3, 7, 3.2, -0.2, 0, Math.PI * 2); c.fill();
+ c.beginPath(); c.arc(-24, -8, 2.6, 0, Math.PI * 2); c.arc(-23, -1, 2.6, 0, Math.PI * 2); c.fill();
+ // 须:两长两短,波动
+ c.strokeStyle = 'rgba(10,10,10,.8)'; c.lineWidth = 1.1;
+ [[-1, 120, 0.9], [1, 105, 1.4], [-1, 40, 2.1], [1, 36, 2.8]].forEach(([sg, L, q]) => { c.beginPath(); c.moveTo(-26, -4); for (let i = 1; i <= 12; i++) { const u = i / 12; c.lineTo(-26 - u * L, -4 + sg * u * L * 0.18 + Math.sin(t * 5 + q + u * 4) * 6 * u); } c.stroke(); });
+ // 钳:长臂三节+钳
+ [[-0.35, 0], [0.1, 1]].forEach(([da, k]) => { c.strokeStyle = 'rgba(10,10,10,.75)'; c.lineWidth = 1.6; const sw2 = Math.sin(t * 4 + k * 2 + ph) * 0.15; let qx = -20, qy = 4; c.beginPath(); c.moveTo(qx, qy);
+ [[22, 2.4], [20, 2.6], [16, 2.9]].forEach(([l, aa]) => { qx += Math.cos(aa + da + sw2) * l; qy += Math.sin(aa + da + sw2) * l; c.lineTo(qx, qy); }); c.stroke();
+ c.fillStyle = 'rgba(10,10,10,.82)'; c.beginPath(); c.ellipse(qx - 6, qy + 2, 8, 3, 2.9 + da, 0, Math.PI * 2); c.fill(); });
+ // 腿
+ c.strokeStyle = 'rgba(20,20,20,.5)'; c.lineWidth = 1; for (let i = 0; i < 5; i++) { const sg = segs[Math.min(4, i)]; c.beginPath(); c.moveTo(sg[0] - 2, sg[1] + 5); c.lineTo(sg[0] - 6 + Math.sin(t * 12 + i) * 2, sg[1] + 14); c.stroke(); }
+ c.restore();
+ }
+
+ // ---------- 猫(赭石没骨+留白+焦墨点斑+八大白眼) ----------
+ function catWash(g, K) {
+ g.fillStyle = '#c47a3c'; g.fill(K.body); g.fill(K.head);
+ g.lineCap = 'round'; g.lineJoin = 'round'; g.strokeStyle = '#c47a3c'; g.lineWidth = K.tailW; g.stroke(K.tail);
+ g.save(); g.globalCompositeOperation = 'destination-out'; g.fill(K.white); K.legs.forEach(l => g.fill(l));
+ g.beginPath(); g.ellipse(K.nose[0] - 22, K.nose[1] + 12, 36, 26, 0, 0, Math.PI * 2); g.fill(); g.restore();
+ }
+ function catInk(c, K, t, rev) {
+ const R_ = (pts, o) => brush(c, pts, { ...o, reveal: ss(o.d || 0, (o.d || 0) + 0.18, rev) });
+ // 背线、头顶:焦墨几笔
+ const b = K.bodyPts;
+ R_([b[5], b[4], b[3], b[2]], { w: 12, dry: 0.55, seed: 81, d: 0.12, tone: 0.9 });
+ R_([b[2], b[1], b[0]], { w: 8, dry: 0.7, seed: 82, d: 0.18, tone: 0.75 });
+ R_([b[6], b[7], b[8]], { w: 5, dry: 0.6, seed: 83, d: 0.2, tone: 0.55 });
+ K.stripes.forEach((s, i) => R_([s[0], [(s[0][0] + s[1][0]) / 2 + 3, (s[0][1] + s[1][1]) / 2], s[1]], { w: i < 3 ? 9 : 13, dry: 0.4, seed: 90 + i, d: 0.2 + i * 0.015, tone: 0.92, head: 0.2, tail: 0.6, bristles: 5 }));
+ if (rev < 0.25) return;
+ c.save(); c.globalAlpha = ss(0.25, 0.4, rev);
+ // 耳:两笔焦墨三角
+ c.fillStyle = 'rgba(14,12,10,.9)'; K.earInner.forEach(e => { c.beginPath(); c.moveTo(...e[0]); c.lineTo(...e[1]); c.lineTo(...e[2]); c.closePath(); c.fill(); });
+ // 头轮廓:一笔淡墨
+ c.strokeStyle = 'rgba(20,18,16,.55)'; c.lineWidth = 3; c.stroke(K.head);
+ // 八大式白眼:圆眶,瞳点顶到上方(白眼向天)
+ K.eyes.forEach((e, i) => { c.strokeStyle = 'rgba(10,10,10,.92)'; c.lineWidth = 2.6; c.beginPath(); c.ellipse(e.x, e.y, K.eyeR * 1.15, K.eyeR * (K.blink ? 0.15 : 1), 0, 0, Math.PI * 2); c.stroke();
+ if (!K.blink) { c.fillStyle = 'rgba(8,8,8,.95)'; c.beginPath(); c.arc(e.x + 2.5, e.y - K.eyeR * 0.55 + Math.sin(t * 2) * 1.2, K.eyeR * 0.42, 0, Math.PI * 2); c.fill(); } });
+ c.fillStyle = 'rgba(14,12,10,.9)'; c.beginPath(); c.ellipse(K.nose[0], K.nose[1], 6, 4, 0, 0, Math.PI * 2); c.fill();
+ c.strokeStyle = 'rgba(14,12,10,.8)'; c.lineWidth = 2; c.beginPath(); c.moveTo(...K.mouth[0]); c.quadraticCurveTo(...K.mouth[1], ...K.mouth[2]); c.stroke();
+ K.whiskers.forEach((w, i) => brush(c, [w[0], [(w[0][0] + w[1][0]) / 2, (w[0][1] + w[1][1]) / 2 - 2], w[1]], { w: 2.4, dry: 0.5, bristles: 3, seed: 99 + i, tone: 0.8, head: 0.05, tail: 0.6 }));
+ // 腿、爪:淡墨轻勾
+ c.strokeStyle = 'rgba(20,18,16,.38)'; c.lineWidth = 2; K.legs.forEach(l => c.stroke(l));
+ // 尾:焦墨环纹
+ const tp = K.tailPts; [5, 9, 13, 17].forEach((i, k) => { const p = tp[i], q = tp[i + 1], a = Math.atan2(q[1] - p[1], q[0] - p[0]) + Math.PI / 2; brush(c, [[p[0] - Math.cos(a) * 12, p[1] - Math.sin(a) * 12], [p[0] + Math.cos(a) * 12, p[1] + Math.sin(a) * 12]], { w: 8, dry: 0.3, bristles: 4, seed: 120 + k, tone: 0.85 }); });
+ c.restore();
+ }
+
+ // ---------- 少女 ----------
+ function sleeveShape(G) {
+ const S = G.A.shoulder, E = G.A.elbow, Hd = G.A.hand;
+ const Wr = [lerp(E[0], Hd[0], 0.8), lerp(E[1], Hd[1], 0.8)];
+ const low = Math.max(S[1], E[1]) + 120;
+ return RIG.smooth([[S[0] + 22, S[1] - 18], [S[0] - 26, S[1] - 6], [E[0] - 22, E[1] - 6], [Wr[0] - 16, Wr[1] - 14], [Wr[0] + 14, Wr[1] + 18], [Wr[0] + 20, Math.max(Wr[1] + 40, low - 30)], [lerp(Wr[0], E[0], 0.5) + 30, low], [E[0] + 40, low - 10], [S[0] + 40, S[1] + 70]]);
+ }
+ function girlWash(g, G) {
+ g.fillStyle = '#6f8aa0'; [G.farSleeve, G.skirt, G.torso].forEach(p => g.fill(p));
+ g.save(); g.globalCompositeOperation = 'destination-out'; g.fill(G.bib); g.restore(); // 交领内衫留白
+ g.fillStyle = '#7d97ab'; g.fill(sleeveShape(G)); // 广袖与衣身同一层晕染(没骨),只靠线分开
+ }
+ function girlInk(c, G, t, rev, ch) {
+ const A = G.A;
+ SKIRT.forEach((s, i) => brush(c, s.p, { w: s.w, dry: s.dry, seed: 200 + i, tone: 0.78, reveal: ss(0.05 + i * 0.02, 0.25 + i * 0.02, rev), head: 0.08, tail: 0.5, bristles: 5 }));
+ // 腰带:胭脂红,两条垂带随动作摆(齐白石的一点红)
+ const wx = A.waist[0] - 40, wy = A.waist[1] - 8, sw = Math.sin(t * 3.4) * 10;
+ brush(c, [[1300, wy - 4], [1360, wy], [1420, wy - 2]], { w: 14, dry: 0.25, seed: 230, col: [190, 40, 40], tone: 0.85, reveal: ss(0.25, 0.4, rev) });
+ [[0, 0], [16, 1]].forEach(([o, k]) => brush(c, [[1400 + o, wy + 4], [1408 + o + sw * 0.4, wy + 70], [1404 + o + sw, wy + 150]], { w: 7, dry: 0.4, seed: 240 + k, col: [190, 40, 40], tone: 0.8, reveal: ss(0.3, 0.45, rev), tail: 0.6, bristles: 4 }));
+ if (rev < 0.12) return;
+ const al = ss(0.12, 0.32, rev);
+ c.save(); c.globalAlpha = al;
+ // 头发:藤黄晕+几笔淡墨发丝
+ c.globalCompositeOperation = 'multiply';
+ c.fillStyle = 'rgba(226,170,52,.75)'; [G.hairBack, G.bun, G.bangs].forEach(p => p && c.fill(p));
+ c.globalCompositeOperation = 'source-over';
+ c.strokeStyle = 'rgba(70,50,20,.55)'; c.lineWidth = 1.6; G.hairLines.forEach(h => c.stroke(h));
+ c.lineWidth = 1.4; c.strokeStyle = 'rgba(30,24,16,.7)'; c.stroke(G.hairBack); if (G.bun) c.stroke(G.bun);
+ // 发簪
+ const bc = G.bunSpiral; c.strokeStyle = 'rgba(14,12,10,.9)'; c.lineWidth = 3.5; c.beginPath(); c.moveTo(bc[0] - 36, bc[1] - 26); c.lineTo(bc[0] + 30, bc[1] + 16); c.stroke();
+ c.fillStyle = '#c0392b'; c.beginPath(); c.arc(bc[0] - 38, bc[1] - 28, 6, 0, Math.PI * 2); c.fill();
+ // 白描面部:细线勾脸,纸色留白
+ c.fillStyle = 'rgba(250,240,224,.9)'; c.fill(G.face); c.fillStyle = 'rgba(246,232,212,.85)'; c.fill(G.neck); c.strokeStyle = 'rgba(18,16,14,.6)'; c.lineWidth = 1.4; c.stroke(G.neck);
+ c.strokeStyle = 'rgba(18,16,14,.85)'; c.lineWidth = 1.8; c.stroke(G.face);
+ c.save(); c.clip(G.face); c.fillStyle = 'rgba(214,92,92,.16)'; c.filter = 'blur(5px)'; c.beginPath(); c.arc(G.cheek[0] - 4, G.cheek[1] + 2, 10, 0, Math.PI * 2); c.fill(); c.filter = 'none'; c.restore();
+ c.fillStyle = 'rgba(226,170,52,.75)'; c.fill(G.bangs); c.strokeStyle = 'rgba(30,24,16,.6)'; c.lineWidth = 1.3; c.stroke(G.bangs);
+ c.strokeStyle = 'rgba(12,10,8,.95)'; c.lineWidth = ch.blink ? 2 : 2.4; c.stroke(G.lid);
+ if (!ch.blink) { c.fillStyle = 'rgba(12,10,8,.95)'; c.beginPath(); c.ellipse(G.eye.x - 1, G.eye.y + 1.5, 3, 3.6, 0, 0, Math.PI * 2); c.fill(); }
+ c.lineWidth = 1.5; c.stroke(G.brow);
+ c.fillStyle = '#b8322c'; c.beginPath(); c.arc(G.lips[0][0] + 3, G.lips[0][1] + 3, 3.2, 0, Math.PI * 2); c.fill();
+ c.restore();
+ }
+ function girlArm(c, G, rev) {
+ const al = ss(0.12, 0.32, rev); if (al <= 0) return;
+ c.save(); c.globalAlpha = al;
+ // 广袖:花青淡彩一大片,垂坠
+ const sl = sleeveShape(G);
+ c.strokeStyle = 'rgba(18,16,14,.7)'; c.lineWidth = 2.2; c.stroke(sl);
+ // 手:白描
+ c.fillStyle = 'rgba(250,240,224,.95)'; c.fill(G.hand); c.strokeStyle = 'rgba(18,16,14,.8)'; c.lineWidth = 1.6; c.stroke(G.hand);
+ // 杯:白瓷,一圈青花
+ const cp = G.cup; c.save(); c.translate(cp.x, cp.y); c.rotate(cp.tilt);
+ c.beginPath(); c.moveTo(-cp.w / 2, 0); c.lineTo(-cp.w * 0.36, cp.h * 0.9); c.lineTo(cp.w * 0.36, cp.h * 0.9); c.lineTo(cp.w / 2, 0); c.closePath();
+ c.fillStyle = 'rgba(252,250,244,.96)'; c.fill(); c.strokeStyle = 'rgba(18,16,14,.85)'; c.lineWidth = 1.8; c.stroke();
+ c.strokeStyle = 'rgba(40,70,140,.75)'; c.lineWidth = 4; c.beginPath(); c.moveTo(-cp.w * 0.45, cp.h * 0.28); c.lineTo(cp.w * 0.45, cp.h * 0.28); c.stroke();
+ c.restore();
+ c.fillStyle = 'rgba(250,240,224,.95)'; c.beginPath(); c.arc(G.thumb[0], G.thumb[1], 6.5, 0, Math.PI * 2); c.fill(); c.strokeStyle = 'rgba(18,16,14,.8)'; c.lineWidth = 1.4; c.stroke();
+ c.restore();
+ }
+
+ return {
+ draw(c, lt, t) {
+ lt += 0.12; // 开场不从一张白纸开始:第 0 帧已经落下前几笔
+ const ch = KIT.choreo(lt, t);
+ const rev = clamp(lt / 0.45); // 开场「画出来」
+ const grow = ss(0, 1.15, lt); // 墨晕外扩
+ c.drawImage(paper(), 0, 0);
+ // 晕染:远山+朱日
+ washLayer(c, 'mtn', ss(0, 0.3, lt) * (0.6 + 0.4 * grow), mountains, { blur: 3, halo: 14, haloA: 0.3 });
+ c.save(); c.globalCompositeOperation = 'multiply'; c.globalAlpha = ss(0.1, 0.3, lt); c.filter = `blur(${2 + grow * 3}px)`; c.fillStyle = '#d8553f'; c.beginPath(); c.arc(700, 230, 30 + grow * 3, 0, Math.PI * 2); c.fill(); c.filter = 'none'; c.restore();
+ // 雾带:纸色横向晕带缓缓左移,远山时隐时现
+ c.save(); c.beginPath(); c.rect(366, 132, 428, 428); c.clip(); c.filter = 'blur(14px)';
+ [[420, 46, 0], [500, 34, 1], [330, 28, 2], [460, 30, 3]].forEach(([y, h, k]) => { const x = 900 - ((lt * (150 + k * 40) + k * 230) % 900); c.fillStyle = `rgba(242,234,214,${0.72 * ss(0.15, 0.4, lt)})`; c.beginPath(); c.ellipse(x, y, 230, h, 0, 0, Math.PI * 2); c.fill(); });
+ c.filter = 'none'; c.restore();
+ // 一只八大式小鸟掠过窗外(两笔翅,每 0.12s 扇一次)
+ if (lt > 0.25) { const bx = 820 - (lt - 0.25) * 420, by = 470 - Math.sin(lt * 3) * 26, fl = Math.sin(lt * 52) ;
+ c.save(); c.beginPath(); c.rect(366, 132, 428, 428); c.clip(); c.fillStyle = 'rgba(14,12,10,.9)';
+ c.beginPath(); c.ellipse(bx, by, 11, 6, -0.2, 0, Math.PI * 2); c.fill(); c.beginPath(); c.arc(bx - 11, by - 4, 5, 0, Math.PI * 2); c.fill();
+ leaf(c, bx - 2, by - 2, -1.2 - fl * 0.7, 28, 9, 0.9); leaf(c, bx + 4, by - 1, -0.5 - fl * 0.5, 24, 8, 0.75);
+ c.fillStyle = '#f2ead6'; c.beginPath(); c.arc(bx - 13, by - 5, 2, 0, Math.PI * 2); c.fill(); c.restore(); }
+ // 静态笔触(写完就缓存)
+ const stat = (c2, rv) => { WIN.forEach((s, i) => brush(c2, s.p, { w: s.w, dry: s.dry, seed: 10 + i, reveal: ss(s.d, s.d + s.l, rv), tone: s.tone || 0.88 })); TABLE.forEach((s, i) => brush(c2, s.p, { w: s.w, dry: s.dry, seed: 30 + i, reveal: ss(s.d, s.d + s.l, rv), tone: s.tone || 0.88 })); };
+ if (rev < 1) stat(c, rev); else c.drawImage(P.cached('ink_static', W, H, g => stat(g, 1)), 0, 0);
+ bamboo(c, t, rev);
+ // 挂轴+虾(三只,沿各自弧线游)
+ c.save(); c.globalAlpha = ss(0.15, 0.35, lt); scrollStatic(c);
+ c.beginPath(); c.rect(1580, 290, 190, 540); c.clip();
+ [[1716, 450, 0.5, 0], [1700, 700, 1.4, 1]].forEach(([x, y, a0, k]) => { const u = lt * 1.6 + k * 2; shrimp(c, x - 26 * Math.sin(u * 1.5) - lt * 40, y + Math.sin(u * 2) * 16 - lt * 30, -0.35 + a0 * 0.1 + Math.sin(u * 1.5) * 0.18, 1.45, t, k * 2); });
+ c.restore();
+ // 猫:赭石晕染 → 焦墨
+ const K = RIG.cat({ tail: ch.tail, blink: ch.blink, breathe: ch.breathe });
+ c.save(); const ks = new Path2D(); ks.addPath(K.body); ks.addPath(K.head); c.clip(ks); c.drawImage(paper(), 0, 0); c.restore(); // 猫身下先补回纸色:窗台墨线不透过赭石
+ washLayer(c, 'cat', ss(0.02, 0.3, lt) * (0.7 + 0.3 * grow), g => catWash(g, K), { blur: 2.5, halo: 9, haloA: 0.28, alpha: 0.78 });
+ catInk(c, K, t, rev);
+ // 少女:花青淡彩 → 白描与衣纹
+ const G = RIG.girl({ cup: ch.cup, sip: ch.sip, breathe: ch.breathe, hair: 'bun' });
+ c.save(); const gs = new Path2D(); [G.skirt, G.torso, G.farSleeve].forEach(p => gs.addPath(p)); c.clip(gs); c.drawImage(paper(), 0, 0); c.restore(); // 桌腿、桌面不透过衣裙
+ washLayer(c, 'girl', ss(0.0, 0.3, lt) * (0.7 + 0.3 * grow), g => girlWash(g, G), { blur: 2.5, halo: 12, haloA: 0.24, alpha: 0.6 });
+ girlInk(c, G, t, rev, ch);
+ girlArm(c, G, rev);
+ // 热气:两缕淡墨游丝
+ if (lt > 0.3) { c.save(); c.globalAlpha = ss(0.3, 0.5, lt);
+ [0, 1].forEach(k => { const pts = []; for (let i = 0; i <= 8; i++) { const q = i / 8; pts.push([G.cup.x - 8 + k * 14 + Math.sin(t * 3.5 + q * 5 + k * 2) * 10 * q - q * 40 * ch.cup, G.cup.y - 8 - q * 80]); } brush(c, pts, { w: 3, dry: 0.7, bristles: 3, seed: 300 + k + P.boilSeed(t, 10), tone: 0.45, head: 0.05, tail: 0.8 }); });
+ c.restore(); }
+ },
+ label(c, lt) {
+ const a = ss(0.0, 0.25, lt);
+ KIT.label(c, { title: '水墨写意', sub: '八大山人 · 齐白石', tFont: '80px "LXGWWenKai-500"', sFont: '30px "LXGWWenKai-500"', tCol: `rgba(14,12,10,${0.92 * a})`, sCol: `rgba(40,34,28,${0.85 * a})`, spacing: 6 });
+ // 钤印:朱文方印「白石」,0.32s 盖下(先放大再压实,印泥略洇)
+ const q = ss(0.3, 0.4, lt); if (q <= 0) return;
+ const s = 1.5 - 0.5 * ease.out(q);
+ const seal = P.cached('ink_seal', 80, 80, g => { g.translate(40, 40);
+ g.fillStyle = '#c4281e'; g.fillRect(-34, -34, 68, 68);
+ g.globalCompositeOperation = 'destination-out'; g.font = '30px "LXGWWenKai-500"'; g.textAlign = 'center'; g.textBaseline = 'middle';
+ g.fillText('白', 0, -14); g.fillText('石', 0, 16);
+ const r = rng(7); for (let i = 0; i < 40; i++) g.fillRect(-34 + r() * 68, -34 + r() * 68, 1 + r() * 3, 1 + r() * 2); // 印面斑驳
+ });
+ c.save(); c.translate(1500, 98); c.scale(s, s); c.globalAlpha = Math.min(1, q * 1.6); c.globalCompositeOperation = 'multiply';
+ c.drawImage(seal, -40, -40); c.restore();
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/18_klimt.js b/scripts/engine/scenes/18_klimt.js
new file mode 100644
index 0000000..3ebe5dc
--- /dev/null
+++ b/scripts/engine/scenes/18_klimt.js
@@ -0,0 +1,227 @@
+// 克里姆特金色时期(《吻》《阿黛尔·布洛赫-鲍尔肖像 I》,1907)——纯代码。
+// 管线:①金箔墙(逐像素:斑驳+拉丝+金粉,缓存)→ ②窗:《白桦林》点彩风景 + 黑白方格金框
+// → ③花草地(《吻》崖边的花毯)→ ④桌:维也纳工坊黑白方格 → ⑤猫:橘色螺旋纹+白色小圆环(装饰化)
+// → ⑥少女:金袍(眼形纹、螺旋、同心圆、黑白长方块,平面)+ 写实的脸与手(渐变体积)
+// → ⑦会动的:金粉闪烁、斜向流光扫过、袍上眼睛轮流眨、螺旋转、花点头、窗里落叶
+SCENES['18_klimt'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, rng } = U, P = PAINT;
+ const { ss } = U;
+ const C = { goldLo: [120, 78, 18], gold: [196, 148, 52], goldHi: [246, 216, 128], ink: '#1d140c', skin: '#f2d6c2' };
+
+ // ---------- 金箔(逐像素) ----------
+ const goldTex = () => P.cached('kl_gold', W, H, (g) => {
+ const img = g.createImageData(W, H), d = img.data, r = rng(19);
+ for (let y = 0; y < H; y++) for (let x = 0; x < W; x++) {
+ const mott = P.fbm(x * 0.004 + 3, y * 0.004, 4), brush = P.noise(x * 0.003, y * 0.08) * 0.45, gr = (r() - 0.5) * 0.1;
+ let f = clamp(0.5 + mott * 0.55 + brush * 0.5 + gr);
+ const lo = C.goldLo, mi = C.gold, hi = C.goldHi; let col = f < 0.5 ? P.mix(lo, mi, f * 2) : P.mix(mi, hi, (f - 0.5) * 2);
+ const i = (y * W + x) * 4; d[i] = col[0]; d[i + 1] = col[1]; d[i + 2] = col[2]; d[i + 3] = 255;
+ }
+ g.putImageData(img, 0, 0);
+ // 金箔接缝:一片片贴上去的方块
+ g.strokeStyle = 'rgba(90,55,10,.18)'; g.lineWidth = 1; for (let y = 0; y < H; y += 96) for (let x = (y / 96 % 2) * 48; x < W; x += 96) g.strokeRect(x + 0.5, y + 0.5, 96, 96);
+ });
+ // 墙:金箔压暗成《吻》的褐金斑驳底,撒金粉
+ const wall = () => P.cached('kl_wall', W, H, (g) => {
+ g.drawImage(goldTex(), 0, 0);
+ g.globalCompositeOperation = 'multiply';
+ const img = P.cached('kl_mott', 480, 270, (h) => { const im = h.createImageData(480, 270), d = im.data; for (let y = 0; y < 270; y++) for (let x = 0; x < 480; x++) { const n = P.fbm(x * 0.012 + 9, y * 0.012, 4); const v = clamp(0.62 + n * 0.7); const i = (y * 480 + x) * 4; d[i] = 255 * v; d[i + 1] = 235 * v; d[i + 2] = 190 * v; d[i + 3] = 255; } h.putImageData(im, 0, 0); });
+ g.drawImage(img, 0, 0, W, H);
+ g.globalCompositeOperation = 'source-over';
+ const r = rng(23); for (let i = 0; i < 9000; i++) { const x = r() * W, y = r() * H, s = 0.6 + r() * 2.2; g.fillStyle = r() < 0.7 ? `rgba(250,226,140,${0.3 + r() * 0.5})` : `rgba(70,40,10,${0.2 + r() * 0.3})`; g.fillRect(x, y, s, s); }
+ });
+ const DUST = (() => { const r = rng(31), o = []; for (let i = 0; i < 420; i++) o.push([r() * W, r() * H, 1.5 + r() * 3.5, r() * 6.28, 3 + r() * 6]); return o; })();
+
+ // ---------- 窗:克里姆特《白桦林》 ----------
+ const windowArt = () => P.cached('kl_win', W, H, (g) => {
+ g.save(); g.beginPath(); g.rect(370, 140, 420, 400); g.clip();
+ g.fillStyle = '#5a3a1c'; g.fillRect(370, 140, 420, 400);
+ const r = rng(41);
+ for (let i = 0; i < 2600; i++) { const x = 370 + r() * 420, y = 140 + r() * 400; const deep = (y - 140) / 400;
+ const pal = deep < 0.65 ? ['#c86a2a', '#e09a3a', '#a84c22', '#d8b04a', '#7a8a3a', '#e8c070'] : ['#b8502a', '#d8803a', '#8a3a1a', '#e0a050', '#c86a7a'];
+ g.fillStyle = pal[(r() * pal.length) | 0]; g.beginPath(); g.ellipse(x, y, 3 + r() * 5, 2 + r() * 4, r() * 3, 0, Math.PI * 2); g.fill(); }
+ [[410, 10], [470, 14], [545, 9], [612, 16], [690, 11], [748, 13]].forEach(([x, w], k) => {
+ g.fillStyle = '#efe8da'; g.fillRect(x, 140, w, 400); g.fillStyle = '#2a2018';
+ for (let y = 150; y < 540; y += 14 + (k * 7 + y) % 19) g.fillRect(x + ((y * 3) % w) * 0.4, y, w * (0.3 + ((y * 7) % 10) / 20), 3 + (y % 4)); });
+ g.restore();
+ // 金框+黑白小方格(维也纳分离派)
+ g.fillStyle = '#d6a845'; g.fillRect(346, 116, 468, 24); g.fillRect(346, 540, 468, 26); g.fillRect(346, 116, 24, 450); g.fillRect(790, 116, 24, 450);
+ for (let x = 350; x < 812; x += 12) { g.fillStyle = ((x / 12) | 0) % 2 ? '#111' : '#f4efe2'; g.fillRect(x, 122, 10, 10); g.fillRect(x, 549, 10, 10); }
+ for (let y = 140; y < 540; y += 12) { g.fillStyle = ((y / 12) | 0) % 2 ? '#111' : '#f4efe2'; g.fillRect(352, y, 10, 10); g.fillRect(798, y, 10, 10); }
+ g.strokeStyle = C.ink; g.lineWidth = 3; g.strokeRect(346, 116, 468, 450); g.strokeRect(370, 140, 420, 400);
+ });
+
+ // ---------- 地:花草地 ----------
+ const FLOW = (() => { const r = rng(57), o = []; for (let i = 0; i < 260; i++) { const y = 712 + Math.pow(r(), 0.8) * 370; o.push([r() * W, y, 6 + (y - 700) / 380 * 14 * (0.6 + r() * 0.6), (r() * 5) | 0, r() * 6.28]); } return o.sort((a, b) => a[1] - b[1]); })();
+ const FCOL = [['#d8402a', '#f4d65a'], ['#3a5ab0', '#f2eee0'], ['#f2eee0', '#d8402a'], ['#8a4ab0', '#f4d65a'], ['#e08aa0', '#3a5ab0']];
+ function meadow(c, t) {
+ c.drawImage(P.cached('kl_meadowBase', W, H, (g) => { const gr = g.createLinearGradient(0, 700, 0, H); gr.addColorStop(0, '#2c4a2a'); gr.addColorStop(1, '#1a3020'); g.fillStyle = gr; g.fillRect(0, 700, W, H - 700);
+ const r = rng(61); for (let i = 0; i < 1600; i++) { g.strokeStyle = r() < 0.5 ? '#4f7a3a' : '#7aa04a'; g.lineWidth = 2; const x = r() * W, y = 705 + r() * 380; g.beginPath(); g.moveTo(x, y); g.lineTo(x + (r() - .5) * 8, y - 8 - r() * 14); g.stroke(); }
+ g.fillStyle = '#d6a845'; g.fillRect(0, 696, W, 8); }), 0, 0);
+ FLOW.forEach(([x, y, s, k, ph]) => { const nod = Math.sin(t * 4.2 + ph) * s * 0.35, fc = FCOL[k];
+ c.fillStyle = fc[0]; c.beginPath(); c.arc(x + nod, y, s, 0, Math.PI * 2); c.fill();
+ c.strokeStyle = fc[1]; c.lineWidth = Math.max(1.5, s * 0.18); c.beginPath(); c.arc(x + nod, y, s * 0.62, 0, Math.PI * 2); c.stroke();
+ c.fillStyle = fc[1]; c.beginPath(); c.arc(x + nod, y, s * 0.25, 0, Math.PI * 2); c.fill(); });
+ }
+
+ // ---------- 桌:黑白方格(约瑟夫·霍夫曼) ----------
+ const table = () => P.cached('kl_table', W, H, (g) => {
+ g.fillStyle = '#111'; g.fillRect(810, 616, 400, 36); g.fillRect(836, 652, 348, 50); g.fillRect(842, 700, 26, 205); g.fillRect(1156, 700, 26, 205);
+ g.fillStyle = '#f4efe2'; for (let x = 814; x < 1206; x += 16) for (let y = 620; y < 648; y += 16) if (((x - 814) / 16 + (y - 620) / 16) % 2 === 0) g.fillRect(x, y, 12, 12);
+ for (let x = 842; x < 1180; x += 22) g.fillRect(x, 662, 14, 30);
+ for (let y = 706; y < 900; y += 20) { g.fillRect(848, y, 14, 12); g.fillRect(1162, y, 14, 12); }
+ g.fillStyle = '#d6a845'; g.fillRect(810, 612, 400, 6); g.fillRect(836, 698, 348, 5);
+ });
+
+ // ---------- 纹样 ----------
+ function spiral(c, x, y, R, rot, col, lw = 2.2) { c.strokeStyle = col; c.lineWidth = lw; c.beginPath(); for (let a = 0; a < Math.PI * 5.2; a += 0.22) { const rr = R * a / (Math.PI * 5.2); const px = x + Math.cos(a + rot) * rr, py = y + Math.sin(a + rot) * rr; a ? c.lineTo(px, py) : c.moveTo(px, py); } c.stroke(); }
+ function eye(c, x, y, L, open, iris) {
+ const h = L * 0.42 * open;
+ c.fillStyle = '#f6f0e0'; c.strokeStyle = C.ink; c.lineWidth = 2.2;
+ c.beginPath(); c.moveTo(x - L / 2, y); c.quadraticCurveTo(x, y - h * 2, x + L / 2, y); c.quadraticCurveTo(x, y + h * 2, x - L / 2, y); c.closePath(); c.fill(); c.stroke();
+ if (open > 0.25) { c.save(); c.clip(); c.fillStyle = iris; c.beginPath(); c.arc(x, y, L * 0.22, 0, Math.PI * 2); c.fill(); c.fillStyle = C.ink; c.beginPath(); c.arc(x, y, L * 0.1, 0, Math.PI * 2); c.fill(); c.restore(); }
+ c.beginPath(); c.moveTo(x - L / 2 - 4, y); c.quadraticCurveTo(x, y - L * 0.42 * 2 - 3, x + L / 2 + 4, y); c.stroke(); // 上眼睑弧(不随开合,像埃及荷鲁斯之眼的勾)
+ }
+ const ROBE = (() => { const r = rng(71), o = []; for (let i = 0; i < 150; i++) { const x = 1090 + r() * 380, y = 420 + r() * 520; o.push({ x, y, k: r(), s: 0.7 + r() * 0.6, ph: r() * 6.28 }); } return o; })();
+ function robePattern(c, t, lt) {
+ c.drawImage(goldTex(), 0, 0);
+ // 下摆的黑白长方块(《吻》男子袍的语言,竖向排)
+ const r = rng(77); for (let i = 0; i < 60; i++) { const x = 1100 + r() * 360, y = 640 + r() * 300, w = 10 + r() * 14, h = 26 + r() * 40; c.fillStyle = r() < 0.55 ? '#141010' : '#f4efe2'; c.fillRect(x, y, w, h); c.strokeStyle = '#d6a845'; c.lineWidth = 2; c.strokeRect(x, y, w, h); }
+ ROBE.forEach(({ x, y, k, s, ph }, i) => {
+ if (k < 0.3) { // 同心圆(彩色)
+ const R = 16 * s, cols = [['#c03a2a', '#f4efe2', '#2a4a9a'], ['#2a4a9a', '#d6a845', '#c03a2a'], ['#6a3a8a', '#f4efe2', '#d6a845']][i % 3];
+ cols.forEach((col, j) => { c.fillStyle = col; c.beginPath(); c.arc(x, y, R * (1 - j * 0.3), 0, Math.PI * 2); c.fill(); });
+ } else if (k < 0.62) { // 深褐底金螺旋,转
+ c.fillStyle = '#3a2410'; c.beginPath(); c.arc(x, y, 15 * s, 0, Math.PI * 2); c.fill();
+ spiral(c, x, y, 13 * s, t * 5 * (i % 2 ? 1 : -1) + ph, '#f2cf6a', 2);
+ } else if (k < 0.84) { // 眼形纹:轮流眨
+ const bl = Math.sin(t * 2.2 + ph * 3); const open = bl > 0.86 ? clamp(1 - (bl - 0.86) / 0.07) : 1;
+ eye(c, x, y, 34 * s, Math.max(0.08, open), ['#2a4a9a', '#2a7a5a', '#8a2a2a'][i % 3]);
+ } else { // 小三角+圆点簇
+ c.fillStyle = '#f4efe2'; for (let j = 0; j < 5; j++) { c.beginPath(); c.arc(x + Math.cos(j * 1.26) * 9 * s, y + Math.sin(j * 1.26) * 9 * s, 3.2 * s, 0, Math.PI * 2); c.fill(); }
+ c.fillStyle = '#c03a2a'; c.beginPath(); c.arc(x, y, 4 * s, 0, Math.PI * 2); c.fill();
+ }
+ });
+ }
+
+ // ---------- 写实的脸与手:柔和渐变体积,几乎无轮廓线(与平面金袍对比) ----------
+ function skin(c, path, cx, cy, R, lightDx = -0.35, lightDy = -0.4) {
+ const g = c.createRadialGradient(cx + R * lightDx, cy + R * lightDy, R * 0.1, cx, cy, R * 1.25);
+ g.addColorStop(0, '#fbe8da'); g.addColorStop(0.5, '#f0cfb8'); g.addColorStop(0.85, '#d8a88c'); g.addColorStop(1, '#b88068');
+ c.fillStyle = g; c.fill(path);
+ }
+ function face(c, G, ch) {
+ skin(c, G.neck, G.A.neck[0] - 8, G.A.neck[1] - 10, 36, -0.5, -0.6);
+ c.save(); c.clip(G.neck); c.fillStyle = 'rgba(120,70,50,.28)'; c.filter = 'blur(6px)'; c.beginPath(); c.ellipse(G.A.chin[0] + 20, G.A.chin[1] + 8, 40, 14, 0, 0, Math.PI * 2); c.fill(); c.filter = 'none'; c.restore();
+ skin(c, G.face, G.A.headC[0] - 20, G.A.headC[1], 72);
+ c.save(); c.clip(G.face); c.filter = 'blur(7px)';
+ c.fillStyle = 'rgba(232,120,110,.38)'; c.beginPath(); c.arc(G.cheek[0] - 6, G.cheek[1] - 2, 15, 0, Math.PI * 2); c.fill();
+ c.fillStyle = 'rgba(150,90,70,.3)'; c.beginPath(); c.ellipse(G.eye.x + 2, G.eye.y - 2, 14, 8, 0, 0, Math.PI * 2); c.fill(); // 眼窝阴影
+ c.filter = 'none'; c.restore();
+ // 眼:睫毛浓、半垂(克里姆特女人的倦眼)
+ c.strokeStyle = '#3a2216'; c.lineWidth = 2.6; c.stroke(G.lid);
+ if (!ch.blink) { c.fillStyle = '#4a3020'; c.beginPath(); c.ellipse(G.eye.x - 1, G.eye.y + 2, 3.4, 3.6, 0, 0, Math.PI * 2); c.fill(); c.fillStyle = 'rgba(255,255,255,.85)'; c.beginPath(); c.arc(G.eye.x - 2.4, G.eye.y + 0.6, 1.1, 0, Math.PI * 2); c.fill(); }
+ G.lashes.forEach(l => { c.beginPath(); c.moveTo(...l[0]); c.lineTo(...l[1]); c.lineWidth = 1.8; c.stroke(); });
+ c.strokeStyle = 'rgba(120,80,40,.8)'; c.lineWidth = 2; c.stroke(G.brow);
+ const lp = G.lips; c.fillStyle = '#b8323a'; c.beginPath(); c.moveTo(...lp[0]); c.quadraticCurveTo(lp[1][0] + 2, lp[1][1] - 2, lp[1][0], lp[1][1]); c.quadraticCurveTo(lp[1][0] + 1, lp[2][1] + 2, lp[2][0], lp[2][1]); c.closePath(); c.fill();
+ c.strokeStyle = 'rgba(150,90,70,.55)'; c.lineWidth = 1.2; c.stroke(G.face);
+ }
+ function hair(c, G, t) {
+ const hg = c.createLinearGradient(G.A.headTop[0], G.A.headTop[1], G.A.nape[0], G.A.nape[1] + 30); hg.addColorStop(0, '#f6dc8a'); hg.addColorStop(0.5, '#dcae4a'); hg.addColorStop(1, '#a8782a');
+ c.fillStyle = hg; [G.hairBack, G.bun].forEach(p => p && c.fill(p));
+ c.strokeStyle = 'rgba(120,80,20,.55)'; c.lineWidth = 1.3; G.hairLines.forEach(h => c.stroke(h));
+ if (G.bun) { spiral(c, G.bunSpiral[0], G.bunSpiral[1], 26, 0.5, 'rgba(130,90,25,.75)', 1.6); }
+ }
+ // 花冠:发间一串小花(《吻》),微微转
+ function wreath(c, G, t) {
+ const A = G.A, pts = [[A.headTop[0] - 40, A.headTop[1] + 18], [A.headTop[0] - 8, A.headTop[1] + 2], [A.headTop[0] + 28, A.headTop[1] + 6], [A.headTop[0] + 60, A.headTop[1] + 22], [A.headTop[0] + 82, A.headTop[1] + 50]];
+ pts.forEach(([x, y], k) => { const fc = FCOL[k % 5], rr = 11; c.save(); c.translate(x, y); c.rotate(t * 1.5 + k);
+ c.fillStyle = fc[0]; for (let j = 0; j < 5; j++) { c.beginPath(); c.arc(Math.cos(j * 1.256) * rr * 0.6, Math.sin(j * 1.256) * rr * 0.6, rr * 0.5, 0, Math.PI * 2); c.fill(); }
+ c.fillStyle = fc[1]; c.beginPath(); c.arc(0, 0, rr * 0.35, 0, Math.PI * 2); c.fill(); c.restore(); });
+ }
+ function bangs(c, G) {
+ const hg = c.createLinearGradient(G.A.forehead[0], G.A.forehead[1] - 20, G.A.forehead[0] + 70, G.A.forehead[1] + 40); hg.addColorStop(0, '#f8e098'); hg.addColorStop(1, '#c89a3a');
+ c.fillStyle = hg; c.fill(G.bangs); c.strokeStyle = 'rgba(120,80,20,.5)'; c.lineWidth = 1.2; c.stroke(G.bangs);
+ G.locks.forEach(h => { c.strokeStyle = '#c89a3a'; c.lineWidth = 6; c.stroke(h); });
+ }
+
+ // ---------- 猫 ----------
+ function cat(c, K, t) {
+ const L = P.scratch('kl_cat'), g = L.getContext('2d'); g.reset();
+ RIG.drawCat(g, K, { orange: '#d8873a', white: '#f6ecd8', stripe: '#a8501a', line: '#3a2414', lw: 3, eye: '#5aa04a' });
+ // 橘色区:金螺旋+红点(装饰化毛色)
+ g.save(); g.globalCompositeOperation = 'source-atop';
+ const r = rng(91); for (let i = 0; i < 46; i++) { const x = 420 + r() * 260, y = 560 + r() * 340; const inWhite = g.isPointInPath(K.white, x, y); if (inWhite) { g.strokeStyle = ['#3a5ab0', '#d8402a', '#d6a845'][i % 3]; g.lineWidth = 2.4; g.beginPath(); g.arc(x, y, 6, 0, Math.PI * 2); g.stroke(); } else if (g.isPointInPath(K.body, x, y) && !g.isPointInPath(K.head, x, y)) { spiral(g, x, y, 9, t * 2.5 + i, '#f2cf6a', 1.8); } }
+ g.restore();
+ c.drawImage(L, 0, 0);
+ }
+
+ return {
+ draw(c, lt, t) {
+ const ch = KIT.choreo(lt, t);
+ c.drawImage(wall(), 0, 0);
+ // 金粉闪烁(四角星),并缓缓上浮,保证每帧都在动
+ c.save(); c.globalCompositeOperation = 'lighter';
+ DUST.forEach(([x0, y0, s, ph, sp]) => { const x = x0 + Math.sin(t * 0.8 + ph) * 14, y = ((y0 - t * 26) % H + H) % H; const tw = Math.sin(t * sp + ph); if (tw < 0.55) return; const a = (tw - 0.55) / 0.45, R = s * (0.6 + a * 1.1);
+ c.fillStyle = `rgba(255,236,160,${0.8 * a})`; c.beginPath(); c.moveTo(x, y - R * 2); c.lineTo(x + R * 0.35, y - R * 0.35); c.lineTo(x + R * 2, y); c.lineTo(x + R * 0.35, y + R * 0.35); c.lineTo(x, y + R * 2); c.lineTo(x - R * 0.35, y + R * 0.35); c.lineTo(x - R * 2, y); c.lineTo(x - R * 0.35, y - R * 0.35); c.closePath(); c.fill(); });
+ c.restore();
+ // 金箔碎片飘落(《吻》背景里的金屑):翻面的小方块和小圆片,保证每一帧都在动
+ P.particles(34, 77, t, { x0: 0, x1: W, y0: -30, y1: 720, speed: 150, drift: 36, life: 3.2 }).forEach(p => { c.save(); c.translate(p.x, p.y); c.rotate(p.a); c.scale(1, Math.cos(t * 5 + p.i));
+ const s2 = 7 + p.s * 8, g2 = c.createLinearGradient(-s2, -s2, s2, s2); g2.addColorStop(0, '#fbe6a0'); g2.addColorStop(1, '#a8741e'); c.fillStyle = g2;
+ if (p.i % 3) c.fillRect(-s2, -s2, s2 * 2, s2 * 2); else { c.beginPath(); c.arc(0, 0, s2, 0, Math.PI * 2); c.fill(); } c.strokeStyle = 'rgba(70,40,10,.6)'; c.lineWidth = 1.2; c.strokeRect && (p.i % 3) && c.strokeRect(-s2, -s2, s2 * 2, s2 * 2); c.restore(); });
+ // 窗+落叶
+ c.drawImage(windowArt(), 0, 0);
+ c.save(); c.beginPath(); c.rect(370, 140, 420, 400); c.clip();
+ P.particles(14, 5, t, { x0: 380, x1: 780, y0: 130, y1: 560, speed: 120, drift: 22, life: 2.4 }).forEach(p => { c.save(); c.translate(p.x, p.y); c.rotate(p.a); c.scale(1, Math.cos(t * 6 + p.i)); c.fillStyle = ['#e8a83a', '#d8603a', '#f2d070'][p.i % 3]; c.beginPath(); c.ellipse(0, 0, 9, 5, 0, 0, Math.PI * 2); c.fill(); c.restore(); });
+ c.restore();
+ meadow(c, t);
+ c.drawImage(table(), 0, 0);
+ // 流光:斜向亮带匀速扫过整面金墙(角色在之后画,自然挡住)
+ const sweep = (c2, x0) => { const gr = c2.createLinearGradient(x0 - 260, 0, x0 + 260, 0); gr.addColorStop(0, 'rgba(255,240,180,0)'); gr.addColorStop(0.5, 'rgba(255,240,180,.24)'); gr.addColorStop(1, 'rgba(255,240,180,0)'); c2.save(); c2.globalCompositeOperation = 'lighter'; c2.transform(1, 0, -0.45, 1, 0, 0); c2.fillStyle = gr; c2.fillRect(x0 - 260 - 600, 0, 520 + 1200, 700); c2.restore(); };
+ const sx = lerp(-200, 2300, clamp(lt / 1.15));
+ sweep(c, sx);
+ // 猫
+ const K = RIG.cat({ tail: ch.tail, blink: ch.blink, breathe: ch.breathe });
+ cat(c, K, t);
+ // 少女:先金袍(剪影里填金+纹样),再写实的脸手
+ const G = RIG.girl({ cup: ch.cup, sip: ch.sip, breathe: ch.breathe, hair: 'bun' });
+ const R_ = P.scratch('kl_robe'), rg = R_.getContext('2d'); rg.reset();
+ const Pt = P.scratch('kl_pat'), pt = Pt.getContext('2d'); pt.reset(); robePattern(pt, t, lt); // 纹样先画满一张,再按剪影一次性 source-in(逐个纹样 source-in 会互相清掉)
+ rg.fillStyle = '#000'; [G.farSleeve, G.skirt, G.torso].forEach(p => rg.fill(p));
+ rg.globalCompositeOperation = 'source-in'; rg.drawImage(Pt, 0, 0);
+ rg.globalCompositeOperation = 'source-atop'; sweep(rg, sx + 260);
+ rg.globalCompositeOperation = 'source-over';
+ rg.strokeStyle = C.ink; rg.lineWidth = 3; [G.farSleeve, G.skirt, G.torso].forEach(p => rg.stroke(p));
+ skin(rg, G.farHand, 1180, 614, 40);
+ hair(rg, G, t);
+ // 远侧袖口:一圈黑白方格
+ face(rg, G, ch); bangs(rg, G); wreath(rg, G, t);
+ // 近侧手臂(金袖)在脸前
+ rg.save(); rg.beginPath(); rg.rect(0, 0, W, H); rg.clip();
+ rg.fillStyle = '#000'; const arm = new Path2D(); arm.addPath(G.upperArm); arm.addPath(G.foreArm);
+ rg.save(); rg.clip(arm); rg.drawImage(Pt, 0, 0); rg.restore(); rg.strokeStyle = C.ink; rg.lineWidth = 3; rg.stroke(G.upperArm); rg.stroke(G.foreArm);
+ rg.fillStyle = '#141010'; rg.fill(G.cuff); rg.save(); rg.clip(G.cuff); rg.fillStyle = '#f4efe2'; for (let k = 0; k < 40; k++) rg.fillRect(G.A.elbow[0] - 100 + (k % 10) * 20, G.A.elbow[1] - 100 + ((k / 10) | 0) * 50 + (k % 2) * 8, 8, 8); rg.restore();
+ rg.restore();
+ skin(rg, G.hand, G.A.hand[0], G.A.hand[1], 20);
+ // 金杯(黑方格)
+ const cp = G.cup; rg.save(); rg.translate(cp.x, cp.y); rg.rotate(cp.tilt);
+ rg.beginPath(); rg.moveTo(-cp.w / 2, 0); rg.lineTo(-cp.w * 0.38, cp.h); rg.lineTo(cp.w * 0.38, cp.h); rg.lineTo(cp.w / 2, 0); rg.closePath();
+ const cg = rg.createLinearGradient(-cp.w / 2, 0, cp.w / 2, 0); cg.addColorStop(0, '#f6d880'); cg.addColorStop(0.5, '#c8962e'); cg.addColorStop(1, '#8a5a14'); rg.fillStyle = cg; rg.fill(); rg.strokeStyle = C.ink; rg.lineWidth = 2; rg.stroke();
+ rg.fillStyle = '#141010'; for (let k = 0; k < 3; k++) rg.fillRect(-cp.w * 0.3 + k * cp.w * 0.24, cp.h * 0.35, 7, 7);
+ rg.restore();
+ rg.fillStyle = '#f0cfb8'; rg.beginPath(); rg.arc(G.thumb[0], G.thumb[1], 6.5, 0, Math.PI * 2); rg.fill();
+ c.drawImage(R_, 0, 0);
+ // 热气:金色细螺旋线上升
+ c.save(); c.globalAlpha = 0.85; [0, 1].forEach(k => { c.strokeStyle = '#f6e6a8'; c.lineWidth = 2.4; c.beginPath(); for (let i = 0; i <= 30; i++) { const q = i / 30; const x = G.cup.x - 6 + k * 14 - q * 50 * ch.cup + Math.sin(t * 4 + q * 8 + k * 2) * 9 * q, y = G.cup.y - 8 - q * 85; i ? c.lineTo(x, y) : c.moveTo(x, y); } c.stroke(); }); c.restore();
+ },
+ label(c, lt) {
+ c.save();
+ c.fillStyle = '#141010'; c.fillRect(1468, 36, 422, 176);
+ c.fillStyle = '#d6a845'; c.fillRect(1468, 36, 422, 6); c.fillRect(1468, 206, 422, 6);
+ for (let x = 1472; x < 1886; x += 14) { c.fillStyle = ((x - 1472) / 14) % 2 ? '#f4efe2' : '#d6a845'; c.fillRect(x, 48, 9, 9); c.fillRect(x, 192, 9, 9); }
+ c.restore();
+ const g = c.createLinearGradient(0, 60, 0, 136); g.addColorStop(0, '#fbe6a0'); g.addColorStop(0.5, '#d6a845'); g.addColorStop(1, '#9a6a1c');
+ KIT.label(c, { title: '金色时期', sub: 'GUSTAV KLIMT · 1907', tFont: '78px "LXGWWenKai-500"', sFont: '27px "Marcellus-400"', tCol: g, sCol: '#e8cf86', x: 1858, y: 140, sy: 182, spacing: 8 });
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/19_munch.js b/scripts/engine/scenes/19_munch.js
new file mode 100644
index 0000000..c9d3519
--- /dev/null
+++ b/scripts/engine/scenes/19_munch.js
@@ -0,0 +1,153 @@
+// 蒙克《呐喊》式表现主义(1893)——纯代码。
+// 管线:①流线渲染器(每个种子点沿「随时间扭动的方向场」积分 9–14 步画成长弯笔,颜色按区域色带)铺满墙/天/峡湾/地板
+// → ②窗里:桥、栏杆、捂脸尖叫的小人、两个远处的人影 → ③桌、椅(摇晃的腿)
+// → ④角色:平涂+流线肌理(source-atop)+深色粗轮廓 → ⑤整幅按行做正弦位移:整个世界在流动
+SCENES['19_munch'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, rng } = U, P = PAINT;
+ const { ss } = U;
+ const WIN = [370, 140, 790, 540];
+ const inWin = (x, y) => x > WIN[0] && x < WIN[2] && y > WIN[1] && y < WIN[3];
+ const VP = [1000, 640];
+ const PAL = {
+ sky: ['#e2541c', '#f08a24', '#f4c03a', '#c8301e', '#e8743a', '#f6a63a', '#b82a1e'],
+ fjord: ['#1d3a6a', '#2c5a8a', '#3a4a7a', '#14243e', '#4a6aa0'],
+ hill: ['#2a4a2a', '#1e3a3a', '#43603a', '#5a6a2a'],
+ wall: ['#8a2e1c', '#a8441e', '#6a2418', '#b8562a', '#7a3020', '#c86a2a', '#3a2a4a'],
+ floor: ['#8a5a2a', '#a8703a', '#6a3a1e', '#c88a42', '#4a2a1a'],
+ };
+ const hx = Object.fromEntries(Object.entries(PAL).map(([k, v]) => [k, v.map(P.hex)]));
+ // 区域:窗内上部天空(色带随波浪起伏),中部峡湾,左下山坡;窗外是墙/地板
+ function region(x, y, t) {
+ if (inWin(x, y)) {
+ const shore = 330 + 60 * Math.sin((x - 370) * 0.012 + 0.5) + 10 * Math.sin(t * 2 + x * 0.02);
+ if (y < shore) return 'sky';
+ if (x < 470 + (y - shore) * 0.6) return 'hill';
+ return 'fjord';
+ }
+ return y > 700 ? 'floor' : 'wall';
+ }
+ function angle(x, y, t, reg) {
+ switch (reg) {
+ case 'sky': return 0.55 * Math.sin(x * 0.011 + y * 0.018 - t * 2.4) + 0.15 * Math.sin(y * 0.05 + t * 3);
+ case 'fjord': { const a = Math.atan2(y - 470, x - 620); return a + Math.PI / 2 + 0.3 * Math.sin(t * 2 + a * 2); }
+ case 'hill': return -0.9 + 0.4 * Math.sin(y * 0.03 + t * 2);
+ case 'floor': return Math.atan2(y - VP[1], x - VP[0]) + 0.18 * Math.sin(x * 0.01 + t * 2.6);
+ default: return -Math.PI / 2 + 0.5 * Math.sin(y * 0.011 + x * 0.005 + t * 2.4) + 0.2 * Math.sin(x * 0.03 - t * 3);
+ }
+ }
+ const SEEDS = P.flowSeeds(24, 5);
+ // 区域底色:先铺平涂,长笔之间的缝露出的是同色系底,不是黑
+ function baseFill(g, t) {
+ const wg = g.createLinearGradient(0, 0, 0, 700); wg.addColorStop(0, '#a8401e'); wg.addColorStop(1, '#5a1a14'); g.fillStyle = wg; g.fillRect(0, 0, W, 700);
+ const fg = g.createLinearGradient(0, 700, 0, H); fg.addColorStop(0, '#7a4a22'); fg.addColorStop(1, '#4a2614'); g.fillStyle = fg; g.fillRect(0, 700, W, H - 700);
+ const sg = g.createLinearGradient(0, 140, 0, 400); sg.addColorStop(0, '#f08a24'); sg.addColorStop(0.5, '#d8401c'); sg.addColorStop(1, '#2c4a7a'); g.fillStyle = sg; g.fillRect(370, 140, 420, 400);
+ }
+ // 流线:沿方向场积分画长弯笔(不描边、半透明叠色,蒙克是薄涂长笔,不是梵高的厚涂短笔)
+ // 天空色由「波浪化的 y」决定色带——呐喊的血色天空就是横向色带在扭
+ const RS = { sky: [32, 7, 10, 0.78], fjord: [26, 6, 9, 0.78], hill: [12, 6, 8, 0.8], wall: [42, 7, 13, 0.5], floor: [32, 8, 12, 0.55] }; // 长、宽、薄:一根笔走 200–300px
+ // 长弯流线笔:P.flowLines(种子沿方向场积分,越区即停);这里只给区域、方向场、配色
+ const flowColor = (reg, sx, sy, r1, t) => {
+ if (reg === 'sky') { const yy = sy + 22 * Math.sin(sx * 0.014 - t * 2.2) + 8 * Math.sin(sx * 0.05 + t * 3); const band = Math.floor((yy - 140) / 28 + r1 * 0.6); return hx.sky[((band % 7) + 7) % 7]; }
+ const pal = hx[reg]; const col = pal[(r1 * pal.length) | 0]; return reg === 'wall' ? P.mix(col, [30, 12, 10], clamp((sy - 300) / 900) * 0.4) : col;
+ };
+ const flowLines = (c, t) => P.flowLines(c, SEEDS, { t, region, angle, color: flowColor, params: RS });
+
+ function bridge(c, t) {
+ c.save(); c.beginPath(); c.rect(370, 140, 420, 400); c.clip();
+ // 桥面+栏杆(从右下斜向左上,栏杆随世界一起扭)
+ c.fillStyle = '#8a5a3a'; c.beginPath(); c.moveTo(790, 470); c.lineTo(370, 410); c.lineTo(370, 540); c.lineTo(790, 540); c.closePath(); c.fill();
+ c.lineCap = 'round'; for (let k = 0; k < 14; k++) { c.strokeStyle = ['#a8703a', '#6a3a22', '#c88a52', '#7a4a2a'][k % 4]; c.lineWidth = 6; c.beginPath(); for (let i = 0; i <= 12; i++) { const q = i / 12, x = lerp(800, 360, q), y = lerp(478 + k * 5, 418 + k * 9, q) + Math.sin(q * 5 + t * 3 + k) * 3; i ? c.lineTo(x, y) : c.moveTo(x, y); } c.stroke(); }
+ c.strokeStyle = '#3a1e14'; c.lineCap = 'round';
+ for (let k = 0; k < 3; k++) { c.lineWidth = 6 - k; c.beginPath(); for (let i = 0; i <= 20; i++) { const q = i / 20, x = lerp(800, 360, q), y = lerp(452 + k * 18, 372 + k * 12, q) + Math.sin(q * 6 + t * 3) * 4; i ? c.lineTo(x, y) : c.moveTo(x, y); } c.stroke(); }
+ for (let i = 0; i < 9; i++) { const q = i / 8, x = lerp(790, 380, q); c.lineWidth = 4; c.beginPath(); c.moveTo(x, lerp(452, 372, q)); c.lineTo(x + 2, lerp(500, 410, q)); c.stroke(); }
+ // 远处两个戴帽人影
+ [[480, 395], [515, 400]].forEach(([x, y], k) => { c.fillStyle = '#1a1420'; c.beginPath(); c.ellipse(x, y, 7, 22, 0.05 * Math.sin(t * 2 + k), 0, Math.PI * 2); c.fill(); c.fillRect(x - 9, y - 26, 18, 4); c.fillRect(x - 5, y - 32, 10, 7); });
+ // 尖叫者:骷髅般的头,双手捂脸,身体是一道扭动的黑袍
+ const fx = 690, fy = 470, sway = Math.sin(t * 3.2) * 0.12;
+ c.save(); c.translate(fx, fy + 70); c.rotate(sway);
+ c.fillStyle = '#2a1e2e'; c.beginPath(); c.moveTo(-30, 0); c.bezierCurveTo(-40, -40, -14, -50, -20, -86); c.lineTo(20, -86); c.bezierCurveTo(20, -50, 44, -30, 34, 0); c.closePath(); c.fill();
+ c.translate(0, -104); c.rotate(-sway * 0.6);
+ c.fillStyle = '#d8c890'; c.beginPath(); c.ellipse(0, 0, 21, 28, 0, 0, Math.PI * 2); c.fill();
+ c.strokeStyle = '#2a1e2e'; c.lineWidth = 2.5; c.stroke();
+ c.fillStyle = '#2a1e2e'; c.beginPath(); c.ellipse(-8, -6, 5, 7, 0, 0, Math.PI * 2); c.ellipse(8, -6, 5, 7, 0, 0, Math.PI * 2); c.fill();
+ const mo = 7 + Math.sin(t * 9) * 2; c.beginPath(); c.ellipse(0, 13, 5, mo, 0, 0, Math.PI * 2); c.fill();
+ c.fillStyle = '#c8b480'; [[-1], [1]].forEach(([s]) => { c.beginPath(); c.ellipse(s * 22, 4, 7, 15, -s * 0.25, 0, Math.PI * 2); c.fill(); c.stroke(); });
+ c.strokeStyle = '#2a1e2e'; c.lineWidth = 9; [[-1], [1]].forEach(([s]) => { c.beginPath(); c.moveTo(s * 22, 14); c.quadraticCurveTo(s * 30, 50, s * 20, 72); c.stroke(); });
+ c.restore();
+ c.restore();
+ }
+ function furniture(c, t) {
+ const wob = (x0, y0, x1, y1, w, col, ph) => { c.strokeStyle = col; c.lineWidth = w; c.lineCap = 'round'; c.beginPath(); for (let i = 0; i <= 12; i++) { const q = i / 12; const x = lerp(x0, x1, q) + Math.sin(q * 5 + t * 3.5 + ph) * 7 * Math.sin(q * Math.PI), y = lerp(y0, y1, q); i ? c.lineTo(x, y) : c.moveTo(x, y); } c.stroke(); };
+ // 椅子(在少女后)
+ wob(1440, 470, 1446, 910, 16, '#2a1a14', 0); wob(1486, 480, 1490, 910, 16, '#2a1a14', 1);
+ // 桌
+ c.fillStyle = '#5a2e1c'; c.beginPath(); c.moveTo(808, 618); c.quadraticCurveTo(1010, 606 + Math.sin(t * 3) * 6, 1212, 620); c.lineTo(1206, 652); c.quadraticCurveTo(1010, 642, 814, 652); c.closePath(); c.fill();
+ c.strokeStyle = '#1a0e14'; c.lineWidth = 5; c.stroke();
+ wob(846, 650, 840, 905, 22, '#3a1e14', 2); wob(1176, 650, 1182, 905, 22, '#3a1e14', 3);
+ wob(846, 650, 840, 905, 6, '#8a4a2a', 2.3); wob(1176, 650, 1182, 905, 6, '#8a4a2a', 3.3);
+ // 窗框:深色、歪的
+ c.strokeStyle = '#1a1020'; c.lineWidth = 16; c.lineJoin = 'round'; c.beginPath(); c.moveTo(358, 128); c.quadraticCurveTo(580, 116 + Math.sin(t * 2.5) * 8, 804, 132); c.quadraticCurveTo(810, 340, 800, 552); c.quadraticCurveTo(580, 562, 360, 550); c.quadraticCurveTo(352, 340, 358, 128); c.stroke();
+ c.lineWidth = 9; c.beginPath(); c.moveTo(580, 128); c.quadraticCurveTo(586 + Math.sin(t * 3) * 6, 340, 578, 552); c.stroke();
+ }
+ // 角色
+ const girlPal = { skin: '#e8d4a0', hair: '#e2b84a', hairLine: '#a8782a', dress: '#1e2238', line: '#120c18', lw: 5, cheek: 'rgba(200,90,70,.18)', lip: '#a8282a', iris: '#1a1420', cuff: '#e8e0c8', cupBody: '#e8e0c8', cupRim: '#6a2a1a', shoe: '#120c18', browC: '#6a4a2a' };
+ const catPal = { orange: '#e07a2a', white: '#efe6c8', stripe: '#8a3a14', line: '#120c18', lw: 5, eye: '#c8d040', noseC: '#c84a3a' };
+ function chars(c, t, lt, ch) {
+ const L = P.scratch('mu_chars'), g = L.getContext('2d'); g.reset();
+ const K = RIG.cat({ tail: ch.tail * 1.4, blink: 0, breathe: ch.breathe });
+ const G = RIG.girl({ cup: ch.cup, sip: ch.sip, breathe: ch.breathe, hair: 'long' });
+ RIG.drawCat(g, K, { ...catPal, lw: 0 });
+ RIG.drawGirl(g, G, { ...girlPal, lw: 0, mode: 'fill', apron: null });
+ // 绿影:蒙克脸上的黄绿阴影
+ g.save(); g.clip(G.face); g.fillStyle = 'rgba(120,150,70,.4)'; g.filter = 'blur(8px)'; g.beginPath(); g.ellipse(G.A.headC[0] + 20, G.A.headC[1] + 10, 40, 50, 0, 0, Math.PI * 2); g.fill(); g.filter = 'none'; g.restore();
+ // 流线肌理(角色身上也是长弯笔)
+ g.save(); g.globalCompositeOperation = 'source-atop'; g.globalAlpha = 0.55; g.lineCap = 'round';
+ const r = rng(17 + P.boilSeed(t, 10));
+ for (let i = 0; i < 900; i++) { const x = 380 + r() * 1100, y = 260 + r() * 680;
+ const a = x < 760 ? Math.atan2(y - 780, x - 540) + Math.PI / 2 : -Math.PI / 2 + 0.6 * Math.sin(y * 0.02 + t * 3);
+ g.strokeStyle = x < 760 ? (r() < 0.5 ? '#f0a040' : '#b8501a') : (y < 450 ? (r() < 0.5 ? '#f4d070' : '#b88a2a') : (r() < 0.5 ? '#34406a' : '#0e1020')); g.lineWidth = 5;
+ g.beginPath(); g.moveTo(x, y); g.quadraticCurveTo(x + Math.cos(a) * 14 + Math.sin(t * 4 + i) * 6, y + Math.sin(a) * 14, x + Math.cos(a) * 28, y + Math.sin(a) * 28); g.stroke(); }
+ g.restore();
+ c.drawImage(L, 0, 0);
+ // 白领(端庄的 1890 年代挪威少女裙)
+ c.fillStyle = '#ece4cc'; c.beginPath(); c.ellipse(G.A.neck[0] + 4, G.A.neck[1] + 8, 30, 12, -0.15, 0, Math.PI * 2); c.fill();
+ RIG.drawCat(c, K, { ...catPal, mode: 'line' });
+ RIG.drawGirl(c, G, { ...girlPal, mode: 'line', apron: null });
+ KIT.nearArm(c, G, { fill: girlPal.dress, line: girlPal.line, lw: 5, skin: girlPal.skin, cuff: girlPal.cuff, cupBody: girlPal.cupBody, cupRim: girlPal.cupRim,
+ pattern: g3 => { g3.lineCap = 'round'; g3.lineWidth = 5; for (let i = 0; i < 26; i++) { const x = 1150 + (i * 37) % 280, y = 330 + (i * 53) % 300; g3.strokeStyle = i % 2 ? '#34406a' : '#0e1020'; g3.beginPath(); g3.moveTo(x, y); g3.quadraticCurveTo(x + 6 + Math.sin(t * 4 + i) * 6, y + 14, x + 2, y + 30); g3.stroke(); } } });
+ // 长金发:一绺绺波浪线,向下传的行波
+ c.save(); c.lineCap = 'round';
+ for (let k = 0; k < 9; k++) { const x0 = G.A.nape[0] - 30 + k * 7, y0 = G.A.nape[1] - 60 + k * 4; c.strokeStyle = k % 2 ? '#f0c858' : '#b8862a'; c.lineWidth = 7;
+ c.beginPath(); for (let i = 0; i <= 16; i++) { const q = i / 16; const x = x0 + 18 * q + Math.sin(q * 9 - t * 7 + k) * (4 + 12 * q), y = y0 + q * 230; i ? c.lineTo(x, y) : c.moveTo(x, y); } c.stroke(); }
+ c.restore();
+ // 猫:张嘴(被画外的尖叫传染)
+ c.fillStyle = '#3a1418'; c.beginPath(); c.ellipse(K.nose[0] - 4, K.nose[1] + 16, 6, 7 + Math.sin(t * 9) * 3, 0, 0, Math.PI * 2); c.fill();
+ return G;
+ }
+
+ return {
+ draw(c, lt, t) {
+ const ch = KIT.choreo(lt, t);
+ const S = P.scratch('mu_frame'), g = S.getContext('2d'); g.reset();
+ baseFill(g, t);
+ flowLines(g, t);
+ bridge(g, t);
+ furniture(g, t);
+ const G = chars(g, t, lt, ch);
+ // 热气:三道粗波浪线(像天空色带)
+ g.save(); g.lineCap = 'round'; [0, 1].forEach(k => { g.strokeStyle = ['#f6e0a0', '#f4c03a'][k]; g.lineWidth = 3.5; g.beginPath(); for (let i = 0; i <= 20; i++) { const q = i / 20, x = G.cup.x - 10 + k * 10 - q * 60 * ch.cup + Math.sin(q * 7 - t * 8 + k) * 12 * q, y = G.cup.y - 10 - q * 90; i ? g.lineTo(x, y) : g.moveTo(x, y); } g.stroke(); }); g.restore();
+ // 整个世界在流动:行位移+轻微列位移
+ const T2 = P.scratch('mu_warp'), g2 = T2.getContext('2d'); g2.reset();
+ g2.fillStyle = '#3a1410'; g2.fillRect(0, 0, W, H);
+ KIT.warpRows(g2, S, y => 9 * Math.sin(y * 0.012 + t * 4.2) + 4 * Math.sin(y * 0.031 - t * 6), 4, 14);
+ c.fillStyle = '#3a1410'; c.fillRect(0, 0, W, H);
+ KIT.warpCols(c, T2, x => 6 * Math.sin(x * 0.009 - t * 3.6), 4, 8);
+ },
+ label(c, lt, t) {
+ const L = P.scratch('mu_label'), g = L.getContext('2d'); g.reset();
+ KIT.label(g, { title: '表现主义', sub: 'EDVARD MUNCH · 1893', tFont: '84px "LXGWWenKai-500"', sFont: '34px "IMFellEnglish-400"', tCol: '#f4c03a', sCol: '#f08a24', y: 132, sy: 186, spacing: 4,
+ before: g2 => { g2.save(); g2.font = '84px "LXGWWenKai-500"'; g2.letterSpacing = '4px'; g2.textAlign = 'right'; g2.lineWidth = 10; g2.strokeStyle = '#1a0a10'; g2.lineJoin = 'round'; g2.strokeText('表现主义', 1866, 132); g2.font = '34px "IMFellEnglish-400"'; g2.letterSpacing = '0px'; g2.lineWidth = 7; g2.strokeText('EDVARD MUNCH · 1893', 1866, 186); g2.restore(); } });
+ KIT.warpRows(c, L, y => (y > 30 && y < 210) ? 5 * Math.sin(y * 0.09 + t * 7) : 0, 3);
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/20_dunhuang.js b/scripts/engine/scenes/20_dunhuang.js
new file mode 100644
index 0000000..376bcc5
--- /dev/null
+++ b/scripts/engine/scenes/20_dunhuang.js
@@ -0,0 +1,215 @@
+// 敦煌壁画(莫高窟·盛唐)——纯代码。
+// 管线:①土红地仗(斑驳、烟熏,缓存)→ ②顶部垂幔纹+卷草边 → ③窗=石青天:飞天带飘带飞过、祥云流动
+// → ④莲花砖地、低案、油灯 → ⑤猫:赭红平涂+铁线描 → ⑥少女:唐代供养人(高髻、花钿、间色裙、披帛飘动)
+// → ⑦天花(散落的花瓣)飘下 → ⑧罩层:颜料不匀、龟裂、剥落露出白灰地仗、整体褪色;剥落的颜料片偶尔掉下
+SCENES['20_dunhuang'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, rng } = U, P = PAINT;
+ const { ss } = U;
+ const C = { red: '#a5452f', redDk: '#7a2e1e', ochre: '#e08a3a', green: '#3f8f6e', green2: '#6ab08e', blue: '#2f5f8f', blue2: '#5a86b0', white: '#ecdfc4', ink: '#2a1a14', line: '#5a2414', skin: '#f2dcc4', gold: '#d8b05a', plaster: '#d8c6a2' };
+ const LW = 2.6;
+ const F = (c, p, fill, lw = LW, line = C.line) => { if (fill) { c.fillStyle = fill; c.fill(p); } if (lw) { c.strokeStyle = line; c.lineWidth = lw; c.stroke(p); } };
+
+ // ---------- 地仗:土红,斑驳 ----------
+ const ground = () => P.cached('dh_ground', W, H, (g) => {
+ g.drawImage(P.texture('dh_red', C.red, { scale: 0.003, amt: 30, grain: 16, dark: '#7a3020', seed: 3 }), 0, 0);
+ // 团花:稀疏的淡色圆形花饰(褪色)
+ const r = rng(8);
+ for (let i = 0; i < 16; i++) { const x = 100 + r() * 1700, y = 260 + r() * 400; if (x > 330 && x < 840 && y < 600) continue; if (x > 1080 && x < 1520) continue;
+ g.save(); g.translate(x, y); g.globalAlpha = 0.5;
+ for (let k = 0; k < 8; k++) { g.rotate(Math.PI / 4); g.fillStyle = k % 2 ? C.green2 : C.white; g.beginPath(); g.ellipse(0, -16, 7, 14, 0, 0, Math.PI * 2); g.fill(); }
+ g.fillStyle = C.blue2; g.beginPath(); g.arc(0, 0, 8, 0, Math.PI * 2); g.fill(); g.restore(); }
+ // 顶部:卷草边+垂幔纹(三角垂帐,石青石绿土红交替)
+ g.fillStyle = C.redDk; g.fillRect(0, 0, W, 34);
+ g.strokeStyle = C.green2; g.lineWidth = 4; g.beginPath(); for (let x = 0; x <= W; x += 4) { const y = 17 + Math.sin(x * 0.05) * 9; x ? g.lineTo(x, y) : g.moveTo(x, y); } g.stroke();
+ for (let x = 0; x < W; x += 80) { g.strokeStyle = C.white; g.lineWidth = 2.5; g.beginPath(); g.arc(x + 40, 17 + Math.sin((x + 40) * 0.05) * 9, 8, 0, Math.PI * 1.5); g.stroke(); }
+ const cols = [C.blue, C.green, C.white, C.red];
+ for (let x = 0, k = 0; x < W; x += 64, k++) { g.fillStyle = cols[k % 4]; g.beginPath(); g.moveTo(x, 34); g.lineTo(x + 64, 34); g.lineTo(x + 32, 84); g.closePath(); g.fill(); g.strokeStyle = C.line; g.lineWidth = 2; g.stroke();
+ g.fillStyle = C.gold; g.beginPath(); g.arc(x + 32, 88, 5, 0, Math.PI * 2); g.fill(); }
+ g.fillStyle = C.redDk; g.fillRect(0, 34, W, 5);
+ });
+
+ // ---------- 窗:石青天、祥云、飞天 ----------
+ function cloud(c, x, y, s, t, ph) {
+ c.save(); c.translate(x, y); c.scale(s, s);
+ c.fillStyle = C.white; c.strokeStyle = C.line; c.lineWidth = 2.2 / s;
+ [[0, 0, 18], [-22, 6, 13], [20, 6, 14], [-8, -14, 12], [10, -12, 11]].forEach(([dx, dy, r]) => { c.beginPath(); c.arc(dx, dy, r, 0, Math.PI * 2); c.fill(); c.stroke(); });
+ c.fillStyle = C.white; c.beginPath(); c.ellipse(0, 4, 32, 12, 0, 0, Math.PI * 2); c.fill();
+ [[0, 0, 10], [-22, 6, 7], [20, 6, 8]].forEach(([dx, dy, r]) => { c.strokeStyle = C.green; c.beginPath(); c.arc(dx, dy, r, 0.3, Math.PI * 1.7); c.stroke(); });
+ // 云尾:一条渐细的尾巴
+ c.fillStyle = C.white; c.fill(KIT.ribbon(KIT.densify([[30, 8], [60, 14 + Math.sin(ph) * 3], [95, 6 + Math.sin(ph + 1) * 5], [120, 12]], 5), q => 16 * (1 - q) + 1)); c.restore();
+ }
+ function apsara(c, t, lt) {
+ // 飞天:横卧的身体朝左飞,头在左,两条长飘带拖在身后成 S 形(行波)
+ const x = 760 - lt * 300, y = 300 + Math.sin(lt * 3.2) * 22;
+ c.save(); c.translate(x, y); c.scale(1.35, 1.35); c.rotate(-0.12 + Math.sin(lt * 3.2) * 0.05);
+ const rib = (ox, oy, len, col, ph, amp) => { const pts = []; for (let i = 0; i <= 18; i++) { const q = i / 18; pts.push([ox + q * len, oy + Math.sin(q * 5.5 - t * 7 + ph) * amp * (0.3 + q) - q * 30]); } const p = KIT.ribbon(pts, q => 15 * (1 - q * 0.7)); F(c, p, col, 2); };
+ rib(40, -6, 300, C.green, 0, 26); rib(30, 10, 270, C.red, 1.6, 30);
+ // 绕过头顶的大弧飘带(飞天最有辨识度的形):从肩起,弧过头顶,再甩到身后
+ { const pts = []; for (let i = 0; i <= 30; i++) { const q = i / 30; let x, y; if (q < 0.45) { const a = Math.PI * 0.9 - q / 0.45 * Math.PI * 1.15; x = -40 + Math.cos(a) * 70; y = -30 - Math.abs(Math.sin(a)) * 80; } else { const u = (q - 0.45) / 0.55; x = -40 + Math.cos(Math.PI * 0.9 - Math.PI * 1.15) * 70 + u * 260; y = -30 - Math.abs(Math.sin(-Math.PI * 0.25)) * 80 + Math.sin(u * 5 - t * 7) * 26 * u - u * 20; } pts.push([x, y]); }
+ F(c, KIT.ribbon(pts, q => 13 * (1 - q * 0.6)), C.blue2, 2); }
+ // 长裙(向后飘)
+ F(c, RIG.smooth([[0, -16], [70, -18], [150, -10 + Math.sin(t * 6) * 6], [190, 4 + Math.sin(t * 6 + 1) * 8], [140, 20], [60, 18], [0, 14]]), C.blue, 2.2);
+ for (let k = 0; k < 3; k++) { c.strokeStyle = C.white; c.lineWidth = 2; c.beginPath(); c.moveTo(30 + k * 40, -12); c.quadraticCurveTo(60 + k * 40, 0, 40 + k * 46, 16); c.stroke(); }
+ // 上身、手臂托花盘
+ F(c, RIG.smooth([[-40, -18], [0, -22], [8, 0], [0, 16], [-36, 12]]), C.skin, 2.2);
+ F(c, RIG.smooth([[-30, -14], [-70, -34], [-86, -30], [-78, -20], [-40, -4]]), C.skin, 2);
+ c.fillStyle = C.gold; c.beginPath(); c.ellipse(-90, -36, 18, 6, -0.2, 0, Math.PI * 2); c.fill(); c.strokeStyle = C.line; c.lineWidth = 2; c.stroke();
+ [[-98, -44, C.red], [-88, -46, C.white], [-80, -42, C.red]].forEach(([fx, fy, fc]) => { c.fillStyle = fc; c.beginPath(); c.arc(fx, fy, 5, 0, Math.PI * 2); c.fill(); });
+ // 头:头光(圆光)+发髻
+ c.fillStyle = 'rgba(106,176,142,.28)'; c.beginPath(); c.arc(-56, -24, 30, 0, Math.PI * 2); c.fill(); c.strokeStyle = C.line; c.lineWidth = 1.4; c.stroke();
+ c.strokeStyle = C.white; c.lineWidth = 2.5; c.beginPath(); c.arc(-56, -24, 24, 0, Math.PI * 2); c.stroke();
+ F(c, (() => { const p = new Path2D(); p.ellipse(-56, -22, 15, 17, 0, 0, Math.PI * 2); return p; })(), C.skin, 2);
+ c.fillStyle = '#1e1410'; c.beginPath(); c.ellipse(-52, -38, 13, 9, 0.3, 0, Math.PI * 2); c.fill(); c.beginPath(); c.arc(-46, -48, 7, 0, Math.PI * 2); c.fill();
+ c.fillStyle = C.line; c.fillRect(-64, -23, 4, 1.6); c.fillStyle = '#c0392b'; c.beginPath(); c.arc(-66, -14, 1.8, 0, Math.PI * 2); c.fill();
+ c.restore();
+ }
+ function windowPanel(c, t, lt) {
+ c.save(); c.beginPath(); c.rect(370, 140, 420, 400); c.clip();
+ const sg = c.createLinearGradient(0, 140, 0, 540); sg.addColorStop(0, '#2a5a86'); sg.addColorStop(1, '#4f86a8'); c.fillStyle = sg; c.fillRect(370, 140, 420, 400);
+ [[460, 200, 0.9, 0], [700, 450, 1.1, 1], [520, 490, 0.8, 2], [760, 190, 0.7, 3]].forEach(([x, y, s, k]) => cloud(c, ((x - lt * (40 + k * 12) - 370 + 1000) % 520) + 330, y + Math.sin(t * 1.5 + k) * 4, s, t, t * 3 + k));
+ apsara(c, t, lt);
+ c.restore();
+ // 窗框:卷草纹边框(石绿+白卷须)
+ c.fillStyle = C.green; c.fillRect(348, 118, 464, 22); c.fillRect(348, 540, 464, 24); c.fillRect(348, 118, 22, 446); c.fillRect(790, 118, 22, 446);
+ c.strokeStyle = C.white; c.lineWidth = 2.5;
+ const vine = (x0, y0, x1, y1) => { const L = Math.hypot(x1 - x0, y1 - y0), n = Math.floor(L / 34); for (let i = 0; i < n; i++) { const q = (i + 0.5) / n, x = lerp(x0, x1, q), y = lerp(y0, y1, q); c.beginPath(); c.arc(x, y, 7, i % 2 ? 0 : Math.PI, (i % 2 ? 0 : Math.PI) + Math.PI * 1.4); c.stroke(); } };
+ vine(359, 129, 801, 129); vine(359, 552, 801, 552); vine(359, 140, 359, 540); vine(801, 140, 801, 540);
+ c.strokeStyle = C.line; c.lineWidth = 3; c.strokeRect(348, 118, 464, 446); c.strokeRect(370, 140, 420, 400);
+ }
+ // ---------- 地:莲花砖 ----------
+ const floor = () => P.cached('dh_floor', W, H, (g) => {
+ g.fillStyle = '#b8654a'; g.fillRect(0, 704, W, H - 704);
+ g.fillStyle = C.redDk; g.fillRect(0, 700, W, 8);
+ for (let x = 0; x < W; x += 150) for (let y = 714; y < H; y += 150) {
+ g.strokeStyle = 'rgba(70,30,20,.6)'; g.lineWidth = 2; g.strokeRect(x + 3, y + 3, 144, 144);
+ g.save(); g.translate(x + 75, y + 75);
+ for (let k = 0; k < 8; k++) { g.rotate(Math.PI / 4); g.fillStyle = k % 2 ? C.green2 : C.white; g.beginPath(); g.ellipse(0, -34, 12, 26, 0, 0, Math.PI * 2); g.fill(); g.strokeStyle = C.line; g.lineWidth = 1.6; g.stroke(); }
+ g.fillStyle = C.blue2; g.beginPath(); g.arc(0, 0, 16, 0, Math.PI * 2); g.fill(); g.stroke(); g.fillStyle = C.gold; g.beginPath(); g.arc(0, 0, 6, 0, Math.PI * 2); g.fill();
+ g.restore(); }
+ });
+ // ---------- 案与油灯 ----------
+ function table(c, t) {
+ F(c, new Path2D('M806 616 L1214 616 L1206 650 L814 650 Z'), C.green);
+ F(c, new Path2D('M830 650 L1190 650 L1190 700 L830 700 Z'), C.red);
+ c.fillStyle = C.redDk; [[880, 660], [990, 660], [1100, 660]].forEach(([x, y]) => { c.beginPath(); c.moveTo(x, y + 34); c.quadraticCurveTo(x + 6, y + 4, x + 40, y + 6); c.quadraticCurveTo(x + 74, y + 4, x + 80, y + 34); c.closePath(); c.fill(); }); // 壸门
+ F(c, new Path2D('M838 700 L868 700 L862 905 L842 905 Z'), C.red); F(c, new Path2D('M1152 700 L1182 700 L1178 905 L1158 905 Z'), C.red);
+ // 油灯:灯盏+跳动的火苗
+ F(c, new Path2D('M880 604 Q910 618 940 604 L934 616 Q910 626 886 616 Z'), C.gold, 2);
+ const fl = 1 + Math.sin(t * 17) * 0.12 + Math.sin(t * 29) * 0.08, sw = Math.sin(t * 11) * 4;
+ c.save(); c.globalCompositeOperation = 'lighter'; const gg = c.createRadialGradient(910, 585, 2, 910, 585, 60); gg.addColorStop(0, 'rgba(255,200,90,.45)'); gg.addColorStop(1, 'rgba(255,200,90,0)'); c.fillStyle = gg; c.fillRect(850, 525, 120, 120); c.restore();
+ F(c, new Path2D(`M902 604 Q${898 + sw} ${598 - 14 * fl} ${910 + sw} ${574 - 14 * fl} Q${922 + sw * 0.5} ${596 - 10 * fl} 918 604 Z`), '#f2a43a', 1.8);
+ c.fillStyle = '#fbe7a0'; c.beginPath(); c.ellipse(910 + sw * 0.4, 596, 4, 7 * fl, 0, 0, Math.PI * 2); c.fill();
+ }
+
+ // 披帛:石绿正面+白色描花,带一点翻面(窄处露出土红里子)
+ function shawl(c, pts, w, t) {
+ const D = KIT.densify(pts, 3), wq = q => w * (0.75 + 0.25 * Math.sin(q * 9 - t * 5)) * (1 - q * 0.25);
+ F(c, KIT.ribbon(D, wq), C.green2, 2.2);
+ c.strokeStyle = C.white; c.lineWidth = 2; c.beginPath(); D.forEach((p, i) => i ? c.lineTo(p[0], p[1]) : c.moveTo(p[0], p[1])); c.setLineDash([3, 9]); c.stroke(); c.setLineDash([]);
+ D.forEach((p, i) => { if (i % 9 !== 4) return; c.fillStyle = C.red; c.beginPath(); c.arc(p[0], p[1], 3.2, 0, Math.PI * 2); c.fill(); });
+ }
+ // ---------- 少女:唐代供养人 ----------
+ function girl(c, t, ch) {
+ const G = RIG.girl({ cup: ch.cup, sip: ch.sip, breathe: ch.breathe, hair: 'bun' });
+ const A = G.A;
+ // 披帛(背后那段):搭过肩、从椅背后飘出一个大 S,末端向外扬(行波,越往下摆幅越大)
+ const pbBack = []; for (let i = 0; i <= 26; i++) { const q = i / 26; pbBack.push([A.back[0] - 10 + q * 230 + Math.sin(q * 4.2 - t * 5.5) * 64 * q, A.nape[1] - 6 + q * 400 - Math.max(0, q - 0.7) * 300 * (0.7 + 0.3 * Math.sin(t * 4))]); }
+ shawl(c, pbBack, 32, t);
+ F(c, G.farSleeve, C.green); F(c, G.farHand, C.skin); F(c, G.farCuff, C.red, 2);
+ // 间色裙:红绿竖条(唐代女装最有辨识度的一条)
+ F(c, G.skirt, C.red);
+ c.save(); c.clip(G.skirt); for (let x = 1090; x < 1470; x += 44) { c.fillStyle = C.green; c.beginPath(); c.moveTo(x + 6, 600); c.lineTo(x + 26, 600); c.lineTo(x + 12 - (x - 1300) * 0.18, 940); c.lineTo(x - 10 - (x - 1300) * 0.18, 940); c.closePath(); c.fill(); }
+ c.restore(); c.strokeStyle = C.line; c.lineWidth = LW; c.stroke(G.skirt);
+ G.folds.forEach(f => { c.strokeStyle = C.line; c.lineWidth = 1.6; c.stroke(f); });
+ F(c, G.shoe, C.ink);
+ // 襦:石青短衫,白边交领;高腰红带
+ F(c, G.torso, C.blue);
+ c.strokeStyle = C.white; c.lineWidth = 7; c.beginPath(); c.moveTo(A.neck[0] - 14, A.neck[1] + 2); c.quadraticCurveTo(A.chest[0] + 6, A.chest[1] - 20, A.chest[0] + 26, A.chest[1] + 40); c.stroke();
+ c.fillStyle = C.red; c.beginPath(); c.moveTo(1290, 590); c.lineTo(1422, 594); c.lineTo(1424, 616); c.lineTo(1294, 614); c.closePath(); c.fill(); c.strokeStyle = C.line; c.lineWidth = 2; c.stroke();
+ F(c, G.neck, C.skin);
+ // 高髻:金发盘在头顶(把 bun 移上去、加大),簪花、金钗
+ F(c, G.hairBack, '#e2b850', 2);
+ const top = A.headTop, bunC = [top[0] + 18, top[1] - 22];
+ F(c, (() => { const p = new Path2D(); p.ellipse(bunC[0], bunC[1], 34, 30, -0.3, 0, Math.PI * 2); p.moveTo(bunC[0] + 40, bunC[1] - 6); p.ellipse(bunC[0] + 22, bunC[1] - 14, 22, 20, 0.4, 0, Math.PI * 2); return p; })(), '#e2b850', 2);
+ c.strokeStyle = '#a8782a'; c.lineWidth = 1.6; for (let k = 0; k < 4; k++) { c.beginPath(); c.arc(bunC[0], bunC[1], 10 + k * 7, -2.4, -0.4); c.stroke(); }
+ c.strokeStyle = C.gold; c.lineWidth = 3.5; c.beginPath(); c.moveTo(bunC[0] - 50, bunC[1] + 6); c.lineTo(bunC[0] + 40, bunC[1] - 24); c.stroke();
+ [[bunC[0] - 30, bunC[1] - 26, C.red], [bunC[0] + 4, bunC[1] - 40, C.white], [bunC[0] + 44, bunC[1] - 30, C.red]].forEach(([x, y, fc], k) => { const sw = Math.sin(t * 5 + k) * 3; for (let j = 0; j < 5; j++) { c.fillStyle = fc; c.beginPath(); c.arc(x + sw + Math.cos(j * 1.26) * 6, y + Math.sin(j * 1.26) * 6, 4.5, 0, Math.PI * 2); c.fill(); } c.fillStyle = C.gold; c.beginPath(); c.arc(x + sw, y, 3, 0, Math.PI * 2); c.fill(); });
+ // 脸:白面、红线(铁线描)、花钿、斜红、点唇
+ F(c, G.face, C.skin, 2.2, '#8a3a24');
+ F(c, G.bangs, '#e2b850', 2);
+ c.fillStyle = '#c0392b'; const fh = G.A.forehead; c.save(); c.translate(fh[0] + 10, fh[1] + 12); for (let j = 0; j < 4; j++) { c.rotate(Math.PI / 2); c.beginPath(); c.ellipse(0, -4, 2, 4, 0, 0, Math.PI * 2); c.fill(); } c.restore();
+ c.strokeStyle = 'rgba(200,60,50,.32)'; c.lineWidth = 2; c.beginPath(); c.moveTo(G.eye.x + 16, G.eye.y - 4); c.quadraticCurveTo(G.eye.x + 22, G.eye.y + 10, G.eye.x + 16, G.eye.y + 22); c.stroke();
+ c.strokeStyle = C.ink; c.lineWidth = ch.blink ? 2 : 2.4; c.stroke(G.lid); if (!ch.blink) { c.fillStyle = C.ink; c.beginPath(); c.ellipse(G.eye.x - 1, G.eye.y + 1.5, 3, 3.4, 0, 0, Math.PI * 2); c.fill(); }
+ c.strokeStyle = '#5a3a1a'; c.lineWidth = 3; c.beginPath(); c.moveTo(G.eye.x - 10, G.eye.y - 14); c.quadraticCurveTo(G.eye.x + 2, G.eye.y - 20, G.eye.x + 14, G.eye.y - 15); c.stroke(); // 蛾眉
+ c.fillStyle = '#c0392b'; c.beginPath(); c.arc(G.lips[0][0] + 3, G.lips[0][1] + 3, 3.4, 0, Math.PI * 2); c.fill();
+ // 近侧手臂:石青窄袖+红袖口,披帛前段绕臂垂下
+ F(c, G.upperArm, C.blue); F(c, G.foreArm, C.blue); F(c, G.cuff, C.red, 2);
+ const E = A.elbow; const pbF = []; for (let i = 0; i <= 22; i++) { const q = i / 22; pbF.push([E[0] + 6 - q * 70 + Math.sin(q * 5 - t * 6 + 1) * 46 * q, E[1] + 6 + q * 300 - Math.max(0, q - 0.65) * 200 * (0.7 + 0.3 * Math.sin(t * 4.6 + 1))]); }
+ shawl(c, pbF, 28, t);
+ F(c, G.hand, C.skin, 2, '#8a3a24');
+ // 茶盏:越窑青瓷
+ const cp = G.cup; c.save(); c.translate(cp.x, cp.y); c.rotate(cp.tilt);
+ F(c, new Path2D(`M${-cp.w / 2} 0 Q0 ${cp.h * 1.3} ${cp.w / 2} 0 Z`), '#8ab89a', 2.2);
+ c.restore();
+ c.fillStyle = C.skin; c.beginPath(); c.arc(G.thumb[0], G.thumb[1], 6.5, 0, Math.PI * 2); c.fill(); c.strokeStyle = '#8a3a24'; c.lineWidth = 1.6; c.stroke();
+ return G;
+ }
+ function cat(c, t, ch) {
+ const K = RIG.cat({ tail: ch.tail, blink: ch.blink, breathe: ch.breathe * 2.5, look: Math.sin(t * 2.6) });
+ RIG.drawCat(c, K, { orange: C.ochre, white: C.white, stripe: '#8a3a1e', line: C.line, lw: LW, eye: '#5a9a6a', earInner: '#d88a7a' });
+ // 项圈:卷草小铃
+ c.strokeStyle = C.green; c.lineWidth = 7; c.beginPath(); c.arc(K.headC[0] - 6, K.headC[1] + 18, 52, 0.7, 2.3); c.stroke();
+ const bx = K.headC[0] + 4 + Math.sin(t * 8) * 4, by = K.headC[1] + 72; c.fillStyle = C.gold; c.beginPath(); c.arc(bx, by, 9, 0, Math.PI * 2); c.fill(); c.strokeStyle = C.line; c.lineWidth = 2; c.stroke();
+ }
+ // ---------- 罩层:颜料不匀、龟裂、剥落、褪色 ----------
+ const AGE_MASK = (x, y) => { const n = P.fbm(x * 0.006 + 11, y * 0.006 + 4, 4) + 0.18 * P.noise(x * 0.04, y * 0.04); const keep = (x > 1180 && x < 1360 && y > 260 && y < 470); return !keep && n > 0.33; };
+ const aging = () => P.cached('dh_age', W, H, (g) => {
+ const img = g.createImageData(W, H), d = img.data, pl = P.hex(C.plaster), r = rng(91);
+ for (let y = 0; y < H; y++) for (let x = 0; x < W; x++) {
+ const i = (y * W + x) * 4;
+ const n = P.fbm(x * 0.0032 + 11, y * 0.0032 + 4, 5) + 0.12 * P.noise(x * 0.03, y * 0.03);
+ const keep = (x > 1180 && x < 1360 && y > 260 && y < 470) || (x > 380 && x < 720 && y > 530 && y < 920) || (x > 1070 && x < 1530 && y > 240 && y < 950); // 角色身上不剥落(剥落在人身上会读成「衣服破洞」)
+ if (!keep && n > 0.3) { const v = (r() - 0.5) * 22 + (n - 0.3) * 60; d[i] = pl[0] + v; d[i + 1] = pl[1] + v; d[i + 2] = pl[2] + v * 0.8; d[i + 3] = 255; }
+ else if (!keep && n > 0.28) { d[i] = 70; d[i + 1] = 45; d[i + 2] = 30; d[i + 3] = 150; } // 剥落边缘的暗线
+ else { const m = P.fbm(x * 0.02, y * 0.02 + 7, 3); d[i] = 255; d[i + 1] = 245; d[i + 2] = 225; d[i + 3] = clamp(m * 0.5 + 0.1) * 80; } // 颜料粉化发白
+ }
+ g.putImageData(img, 0, 0);
+ // 龟裂
+ g.strokeStyle = 'rgba(50,25,15,.35)'; g.lineWidth = 1;
+ for (let k = 0; k < 500; k++) { let x = r() * W, y = r() * H, a = r() * 6.28; g.beginPath(); g.moveTo(x, y); for (let s = 0; s < 5 + r() * 8; s++) { a += (r() - .5) * 1.4; x += Math.cos(a) * (5 + r() * 12); y += Math.sin(a) * (5 + r() * 12); g.lineTo(x, y); } g.stroke(); }
+ // 顶部烟熏
+ const sg = g.createLinearGradient(0, 0, 0, 380); sg.addColorStop(0, 'rgba(40,20,10,.35)'); sg.addColorStop(1, 'rgba(40,20,10,0)'); g.fillStyle = sg; g.fillRect(0, 0, W, 380);
+ });
+ const FLAKES = (() => { const r = rng(55), o = []; let n = 0; while (o.length < 10 && n < 2000) { n++; const x = 100 + r() * 1700, y = 120 + r() * 700; { const n = P.fbm(x * 0.0032 + 11, y * 0.0032 + 4, 5); if (n > 0.26 && n < 0.3) o.push([x, y, 0.05 + r() * 0.7, 8 + r() * 10, r()]); } } return o; })();
+
+ return {
+ draw(c, lt, t) {
+ const ch = KIT.choreo(lt, t);
+ c.drawImage(ground(), 0, 0);
+ windowPanel(c, t, lt);
+ c.drawImage(floor(), 0, 0);
+ table(c, t);
+ cat(c, t, ch);
+ const G = girl(c, t, ch);
+ // 热气:几道白色卷云线
+ c.save(); c.strokeStyle = C.white; c.lineWidth = 3; c.lineCap = 'round'; [0, 1].forEach(k => { c.beginPath(); for (let i = 0; i <= 18; i++) { const q = i / 18, x = G.cup.x - 4 + k * 12 - q * 50 * ch.cup + Math.sin(q * 6 - t * 6 + k) * 8 * q, y = G.cup.y - 6 - q * 70; i ? c.lineTo(x, y) : c.moveTo(x, y); } c.stroke(); const e = [G.cup.x - 4 + k * 12 - 50 * ch.cup + Math.sin(6 - t * 6 + k) * 8, G.cup.y - 76]; c.beginPath(); c.arc(e[0] + 5, e[1], 5, Math.PI, Math.PI * 2.6); c.stroke(); }); c.restore();
+ // 天花:花瓣从窟顶散落
+ P.particles(30, 13, t, { x0: 0, x1: W, y0: 60, y1: H, speed: 90, drift: 50, life: 3 }).forEach(p => { c.save(); c.translate(p.x, p.y); c.rotate(p.a); c.scale(p.s * 1.6, p.s * 1.6 * (Math.abs(Math.cos(t * 3 + p.i)) * 0.8 + 0.2));
+ const fc = [C.white, C.red, C.green2, '#e8a0a0'][p.i % 4]; for (let j = 0; j < 4; j++) { c.rotate(Math.PI / 2); c.fillStyle = fc; c.beginPath(); c.ellipse(0, -7, 4, 8, 0, 0, Math.PI * 2); c.fill(); c.strokeStyle = C.line; c.lineWidth = 1.2; c.stroke(); } c.restore(); });
+ // 罩层
+ c.save(); c.globalCompositeOperation = 'saturation'; c.fillStyle = 'rgba(128,128,128,.3)'; c.fillRect(0, 0, W, H); c.restore();
+ c.save(); c.globalCompositeOperation = 'multiply'; c.globalAlpha = 0.5; c.drawImage(P.texture('dh_dirt', '#e8dcc8', { scale: 0.002, amt: 40, grain: 20, seed: 9 }), 0, 0); c.restore();
+ c.drawImage(aging(), 0, 0);
+ // 颜料片掉落:剥落边缘处一小片颜料脱开、旋转着落下
+ FLAKES.forEach(([x, y, t0, s, ph], k) => { const q = (lt - t0 * 0.9); if (q < 0) return; const fy = y + q * q * 600, fx = x + Math.sin(q * 6 + ph * 6) * 12; if (fy > H) return;
+ c.save(); c.translate(fx, fy); c.rotate(q * 6 + ph * 3); c.scale(1, Math.cos(q * 9 + ph)); c.fillStyle = [C.red, C.green, C.blue2][k % 3]; c.beginPath(); c.moveTo(-s, -s * 0.4); c.lineTo(s * 0.6, -s * 0.8); c.lineTo(s, s * 0.5); c.lineTo(-s * 0.3, s * 0.7); c.closePath(); c.fill(); c.restore(); });
+ },
+ label(c, lt) {
+ // 榜题框:浅色长方块、墨书,带剥落
+ c.save(); c.fillStyle = '#e6d6b2'; c.fillRect(1500, 52, 380, 150); c.strokeStyle = C.line; c.lineWidth = 4; c.strokeRect(1500, 52, 380, 150); c.strokeRect(1508, 60, 364, 134);
+ c.restore();
+ KIT.label(c, { title: '敦煌壁画', sub: '莫高窟 · 盛唐', tFont: '78px "LXGWWenKai-500"', sFont: '32px "LXGWWenKai-500"', tCol: '#2a1a14', sCol: C.redDk, x: 1858, y: 134, sy: 180, spacing: 6 });
+ c.save(); const r = rng(4); c.fillStyle = 'rgba(216,198,162,.9)'; for (let i = 0; i < 14; i++) { const x = 1500 + r() * 380, y = 52 + r() * 150; c.beginPath(); KIT.blob(c, x, y, 4 + r() * 10, i, 0.3, 8); c.fill(); } c.restore();
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/21_kusama.js b/scripts/engine/scenes/21_kusama.js
new file mode 100644
index 0000000..a0925da
--- /dev/null
+++ b/scripts/engine/scenes/21_kusama.js
@@ -0,0 +1,124 @@
+// 草间弥生无限波点(《Infinity Mirror Room》1965–、黄南瓜 1994)——纯代码。
+// 管线:①红房间:墙/地铺白点(大小两套网格,地板压扁成透视椭圆)→ ②窗=无限镜屋:黑底彩灯点从深处飞来、镜面倒影
+// → ③桌上黄南瓜(瓣+黑点)→ ④角色:平涂+细黑线;红裙白点、猫的橘色区白点、白色区红点
+// → ⑤会动的:所有点按「从猫出发的行波」一胀一缩(蠕动),裙上的点顺着裙子往下爬,镜屋灯飞来,南瓜呼吸
+// → ⑥结尾 0.3s:自我消融(点越胀越大吞掉一切)
+SCENES['21_kusama'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, rng } = U, P = PAINT;
+ const { ss } = U;
+ const C = { red: '#d8181e', redDk: '#a80e14', white: '#fbf6ee', yellow: '#f6d02a', black: '#141210', skin: '#f6dcc8' };
+ const O = [540, 760]; // 行波原点(猫)
+ const wave = (x, y, t, k = 1) => 0.82 + 0.28 * Math.sin(Math.hypot(x - O[0], y - O[1]) * 0.012 - t * 6 * k);
+ const grid = (x0, y0, x1, y1, sp, seed, jit = 0.25) => { const r = rng(seed), o = []; for (let y = y0, j = 0; y < y1; y += sp * 0.87, j++) for (let x = x0 + (j % 2) * sp / 2; x < x1; x += sp) o.push([x + (r() - .5) * sp * jit, y + (r() - .5) * sp * jit, 0.75 + r() * 0.5, r() * 6.28, 0.85 + r() * 0.3]); return o; };
+ const WALL_BIG = grid(-40, 20, W + 40, 720, 104, 3), WALL_SM = grid(12, 64, W + 40, 720, 104, 4, 0.5);
+ const FLOOR = (() => { const r = rng(6), o = []; for (let row = 0; row < 9; row++) { const q = row / 8, y = 712 + Math.pow(q, 1.4) * 360, sp = 46 + q * 70, rr = 6 + q * 22; for (let x = -40 + (row % 2) * sp / 2; x < W + 40; x += sp) o.push([x + (r() - .5) * 10, y, rr * (0.8 + r() * 0.4), r() * 6.28, 0.9]); } return o; })();
+ const dot = (c, x, y, r, rot, asp, col) => { c.fillStyle = col; c.beginPath(); c.ellipse(x, y, r, r * asp, rot, 0, Math.PI * 2); c.fill(); };
+ let OBL = 0; // 消融程度(结尾)
+
+ function room(c, t) {
+ c.fillStyle = C.red; c.fillRect(0, 0, W, 708);
+ const fg = c.createLinearGradient(0, 700, 0, H); fg.addColorStop(0, '#c0141a'); fg.addColorStop(1, '#e02024'); c.fillStyle = fg; c.fillRect(0, 700, W, H - 700);
+ c.fillStyle = C.redDk; c.fillRect(0, 700, W, 6);
+ const g = 1 + OBL * 2.2;
+ WALL_BIG.forEach(([x, y, s, rot, asp]) => dot(c, x, y, 30 * s * wave(x, y, t) * g, rot, asp, C.white));
+ WALL_SM.forEach(([x, y, s, rot, asp]) => dot(c, x, y, 10 * s * wave(x, y, t, 1.3) * g, rot, asp, C.white));
+ FLOOR.forEach(([x, y, rr, rot]) => dot(c, x, y, rr * wave(x, y, t) * g, 0, 0.42, C.white));
+ }
+ // 无限镜屋:3D 点向镜头飞来(z 循环),投影+光晕;地面镜像
+ // 灯在一个 3D 格子上(镜面无限反射的感觉来自规则重复),z 循环向镜头飞来
+ const LIGHTS = (() => { const r = rng(9), o = []; for (let gx = -6; gx <= 6; gx++) for (let gy = -3; gy <= 3; gy++) for (let gz = 0; gz < 3; gz++) o.push([gx * 0.42 + (r() - .5) * 0.06, gy * 0.38 + (r() - .5) * 0.06, (gz + r() * 0.3) / 3, ['#ff3a4a', '#ffd43a', '#3aa8ff', '#6aff7a', '#ff7ad0', '#ffffff'][(r() * 6) | 0]]); return o; })();
+ function mirrorRoom(c, t) {
+ c.save(); c.beginPath(); c.rect(370, 140, 420, 400); c.clip();
+ c.fillStyle = '#05040a'; c.fillRect(370, 140, 420, 400);
+ const cx = 580, cy = 330, F = 150;
+ c.strokeStyle = 'rgba(120,120,160,.22)'; c.lineWidth = 1; [[370, 140], [790, 140], [370, 540], [790, 540]].forEach(([x, y]) => { c.beginPath(); c.moveTo(cx, cy); c.lineTo(x, y); c.stroke(); });
+ c.globalCompositeOperation = 'lighter';
+ const sorted = LIGHTS.map(([x, y, z0, col]) => [x, y, ((z0 - t * 0.3) % 1 + 1) % 1 * 3.6 + 0.4, col]).sort((a, b) => b[2] - a[2]);
+ for (const [x, y, z, col] of sorted) {
+ const px = cx + x * F / z, py = cy + y * F / z, r = 3.2 / z + 0.6; if (px < 350 || px > 810 || py < 120 || py > 560) continue;
+ const fade = clamp((4 - z) / 1.0) * clamp((z - 0.4) / 0.25);
+ c.globalAlpha = fade * 0.5; const g = c.createRadialGradient(px, py, 0, px, py, r * 3.2); g.addColorStop(0, col); g.addColorStop(1, col + '00'); c.fillStyle = g; c.beginPath(); c.arc(px, py, r * 3.2, 0, Math.PI * 2); c.fill();
+ c.globalAlpha = fade; c.fillStyle = col; c.beginPath(); c.arc(px, py, r, 0, Math.PI * 2); c.fill();
+ }
+ c.restore();
+ // 窗框:黄底黑点
+ c.save(); c.fillStyle = C.yellow; c.fillRect(348, 118, 464, 22); c.fillRect(348, 540, 464, 24); c.fillRect(348, 118, 22, 446); c.fillRect(790, 118, 22, 446);
+ c.fillStyle = C.black; for (let x = 360; x < 806; x += 22) { dot(c, x, 129, 6 * wave(x, 129, t), 0, 1, C.black); dot(c, x, 552, 6 * wave(x, 552, t), 0, 1, C.black); } for (let y = 150; y < 540; y += 22) { dot(c, 359, y, 6 * wave(359, y, t), 0, 1, C.black); dot(c, 801, y, 6 * wave(801, y, t), 0, 1, C.black); }
+ c.strokeStyle = C.black; c.lineWidth = 3; c.strokeRect(348, 118, 464, 446); c.restore();
+ }
+ // 黄南瓜:5 瓣,瓣间黑线,每瓣按行排黑点(中间大、两边小),整体呼吸
+ function pumpkin(c, t) {
+ const cx = 960, cy = 540, br = 1 + Math.sin(t * 5) * 0.025;
+ c.save(); c.translate(cx, cy + 78); c.scale(br, 2 - br); c.translate(-cx, -(cy + 78));
+ const lobes = [[-88, 46, 70], [-44, 58, 74], [0, 62, 80], [44, 58, 74], [88, 46, 70]];
+ [0, 4, 1, 3, 2].forEach(k => { const [dx, rx, ry] = lobes[k]; const p = new Path2D(); p.ellipse(cx + dx, cy + 8, rx, ry, 0, 0, Math.PI * 2);
+ c.fillStyle = C.yellow; c.fill(p); c.strokeStyle = C.black; c.lineWidth = 4; c.stroke(p);
+ c.save(); c.clip(p);
+ for (let row = -4; row <= 4; row++) { const y = cy + 8 + row * 17; const wRow = Math.sqrt(Math.max(0, 1 - Math.pow(row * 17 / ry, 2))) * rx; for (let col = -3; col <= 3; col++) { const x = cx + dx + col * wRow * 0.3; const edge = 1 - Math.abs(col) / 4; const r = (3 + 6.5 * edge) * (1 - Math.abs(row) / 6) * wave(x, y, t, 1.5); if (r > 0.8) dot(c, x, y, r, 0, 1, C.black); } }
+ c.restore(); });
+ c.fillStyle = '#2a3a14'; c.beginPath(); c.moveTo(cx - 10, cy - 50); c.quadraticCurveTo(cx - 14, cy - 86, cx + 6, cy - 92); c.lineTo(cx + 14, cy - 84); c.quadraticCurveTo(cx + 4, cy - 70, cx + 10, cy - 50); c.closePath(); c.fill(); c.strokeStyle = C.black; c.lineWidth = 3; c.stroke();
+ c.restore();
+ }
+ function table(c, t) {
+ c.fillStyle = C.yellow; c.strokeStyle = C.black; c.lineWidth = 4;
+ [[806, 616, 408, 34], [834, 650, 352, 46], [842, 696, 26, 210], [1152, 696, 26, 210]].forEach(([x, y, w, h]) => { c.fillRect(x, y, w, h); c.strokeRect(x, y, w, h);
+ c.save(); c.beginPath(); c.rect(x, y, w, h); c.clip(); for (let yy = y + 8; yy < y + h; yy += 18) for (let xx = x + 8 + ((yy / 18) | 0) % 2 * 9; xx < x + w; xx += 18) dot(c, xx, yy, 4.2 * wave(xx, yy, t), 0, 1, C.black); c.restore(); });
+ }
+ // 角色:平涂(RIG fill)+各区域点+细黑线
+ function chars(c, t, lt, ch) {
+ const L = P.scratch('ku_chars'), g = L.getContext('2d'); g.reset();
+ const K = RIG.cat({ tail: ch.tail, blink: ch.blink, breathe: ch.breathe });
+ const G = RIG.girl({ cup: ch.cup, sip: ch.sip, breathe: ch.breathe, hair: 'bun' });
+ const gp = { skin: C.skin, hair: '#f2c84a', hairLine: '#c8962a', dress: C.red, line: C.black, lw: 3, cheek: 'rgba(240,110,110,.4)', lip: '#d8181e', iris: '#2a2a2a', cuff: C.white, apron: null, cupBody: C.yellow, cupRim: '#6a3a14', shoe: C.black };
+ RIG.drawCat(g, K, { orange: '#ec8a2a', white: C.white, stripe: '#b85a14', line: C.black, lw: 3, eye: '#2a2a2a' });
+ // 猫:橘色区白点、白色区红点
+ const catDots = (path, col, sp, r0, dy) => { g.save(); g.clip(path); for (let y = 540 + dy, j = 0; y < 920; y += sp * 0.87, j++) for (let x = 380 + (j % 2) * sp / 2; x < 720; x += sp) dot(g, x, y, r0 * wave(x, y, t) * (1 + OBL * 2), 0, 1, col); g.restore(); };
+ catDots(K.body, C.white, 34, 7, (t * 30) % (34 * 0.87 * 2)); catDots(K.head, C.white, 26, 5, 0);
+ RIG.drawCat(g, K, { line: C.black, lw: 3, mode: 'line', eye: '#2a2a2a' });
+ // 少女
+ RIG.drawGirl(g, G, { ...gp, mode: 'fill' });
+ // 红裙白点:顺着裙子往下爬(点的 y 随时间平移,爬出下摆再从腰上出来)
+ const dress = new Path2D(); [G.skirt, G.torso, G.farSleeve].forEach(p => dress.addPath(p));
+ g.save(); g.clip(dress); const off = (t * 46) % (52 * 0.87 * 2); // 周期必须是「两行」的行距(奇偶行错位),取 52 会在回绕时整片跳一帧
+ for (let y = 380 - 52, j = 0; y < 960; y += 52 * 0.87, j++) for (let x = 1080 + (j % 2) * 26; x < 1480; x += 52) dot(g, x, y + off, 13 * wave(x, y, t) * (1 + OBL * 2.2), 0.2, 0.92, C.white);
+ g.restore();
+ const arm = new Path2D(); arm.addPath(G.upperArm); arm.addPath(G.foreArm);
+ g.fillStyle = C.red; g.fill(arm);
+ g.save(); g.clip(arm); for (let y = 300, j = 0; y < 700; y += 30, j++) for (let x = 1130 + (j % 2) * 15; x < 1420; x += 30) dot(g, x, y + off * 0.6, 8 * wave(x, y, t), 0, 1, C.white); g.restore();
+ RIG.drawGirl(g, G, { ...gp, mode: 'line', lw: 4.5 });
+ KIT.nearArm(g, G, { fill: C.red, line: C.black, lw: 4, skin: C.skin, cuff: C.white, cupBody: C.yellow, cupRim: '#6a3a14', pattern: gg => { for (let y = 300, j = 0; y < 700; y += 30, j++) for (let x = 1130 + (j % 2) * 15; x < 1420; x += 30) dot(gg, x, y + (off * 0.6) % 60, 8 * wave(x, y, t), 0, 1, C.white); } });
+ // 脸颊上画了两个点(草间的身体彩绘)
+ dot(g, G.cheek[0] - 4, G.cheek[1] + 2, 5 * wave(G.cheek[0], G.cheek[1], t), 0, 1, C.red);
+ // 发箍:红底白点蝴蝶结
+ const ht = G.A.headTop; g.fillStyle = C.red; g.beginPath(); g.ellipse(ht[0] + 34, ht[1] + 6, 24, 13, 0.4, 0, Math.PI * 2); g.ellipse(ht[0] + 70, ht[1] + 26, 22, 12, 0.9, 0, Math.PI * 2); g.fill(); g.strokeStyle = C.black; g.lineWidth = 2.5; g.stroke();
+ dot(g, ht[0] + 34, ht[1] + 6, 5, 0, 1, C.white); dot(g, ht[0] + 70, ht[1] + 26, 5, 0, 1, C.white);
+ c.drawImage(L, 0, 0);
+ return G;
+ }
+
+ return {
+ draw(c, lt, t) {
+ const ch = KIT.choreo(lt, t);
+ OBL = Math.pow(ss(1.0, 1.26, lt), 1.4); // 1.26 后停住 0.15s,给结尾一个落点
+ room(c, t);
+ mirrorRoom(c, t);
+ table(c, t);
+ pumpkin(c, t);
+ const G = chars(c, t, lt, ch);
+ // 热气:一串由小到大的白点往上飘(热气也是点)
+ for (let i = 0; i < 7; i++) { const q = ((t * 1.4 + i / 7) % 1); dot(c, G.cup.x - 4 - q * 50 * ch.cup + Math.sin(q * 6 + t * 3) * 10, G.cup.y - 10 - q * 90, 3 + q * 7, 0, 1, `rgba(251,246,238,${1 - q})`); }
+ // 自我消融:最后 0.3s,全屏红底白点从猫的位置一圈圈胀开,把人、猫、南瓜都「消」进波点里(停在点阵,不是白屏)
+ if (OBL > 0) { const sp = 120; c.save(); c.globalAlpha = clamp(OBL * 1.4); c.fillStyle = C.red; c.fillRect(0, 0, W, H); c.globalAlpha = 1;
+ for (let y = 0, j = 0; y < H + sp; y += sp * 0.87, j++) for (let x = (j % 2) * sp / 2; x < W + sp; x += sp) { const d = Math.hypot(x - O[0], y - O[1]); const r = clamp(OBL * 1.5 - d / 2600) * 0.47 * sp * wave(x, y, t); if (r > 0.5) dot(c, x, y, r, 0, 1, C.white); }
+ c.restore(); }
+ },
+ label(c, lt, t) {
+ c.save(); c.fillStyle = C.yellow; c.strokeStyle = C.black; c.lineWidth = 5;
+ c.beginPath(); c.roundRect(1488, 44, 392, 160, 80); c.fill(); c.stroke();
+ c.beginPath(); c.roundRect(1488, 44, 392, 160, 80); c.clip();
+ [[1520, 76, 12], [1530, 172, 9], [1850, 80, 10], [1858, 170, 13], [1690, 60, 6], [1612, 192, 7], [1780, 196, 6]].forEach(([x, y, r]) => dot(c, x, y, r * wave(x, y, t, 1.4), 0, 1, C.black));
+ c.restore();
+ KIT.label(c, { title: '无限波点', sub: 'YAYOI KUSAMA · 1965–', tFont: '74px "LXGWWenKai-500"', sFont: '26px "Poppins-800"', tCol: C.black, sCol: C.red, x: 1838, y: 128, sy: 172, spacing: 6 });
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/22_constructivism.js b/scripts/engine/scenes/22_constructivism.js
new file mode 100644
index 0000000..ca468b5
--- /dev/null
+++ b/scripts/engine/scenes/22_constructivism.js
@@ -0,0 +1,205 @@
+// 1924 俄罗斯构成主义海报(罗德琴科 / 李西茨基)——纯代码。
+// 管线:①缓存底版(米白旧纸+斜红地面+黑圆+窗内网点照片与舒霍夫塔+排版小构件)
+// → ②会动的母题(红楔刺入黑圆、塔顶无线电波外扩、黑圆外虚线环旋转、标语字逐个盖章后波浪跳)
+// → ③角色:平涂剪纸(红头巾共青团少女)+皮肤是 45° 网点照片(照片拼贴)+白色剪切边
+SCENES['22_constructivism'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, ease } = U, P = PAINT, TAU = Math.PI * 2;
+ const C = { paper: '#e9dfc4', red: '#c8231c', redD: '#8f1711', ink: '#151311', cream: '#f4ecd6', gray: '#4a4640', ochre: '#e3b03e', ochreD: '#a87a1c', orange: '#e2741c' };
+ const poly = U.poly;
+
+ // 网点:P.halftoneGray(灰度照片网点,照片拼贴的核心)、P.shadeDots(路径内按函数落点的网点阴影)
+ const halftone = P.halftoneGray, shadeDots = P.shadeDots;
+
+ // ---------- 几何西里尔字(5×7 模块,罗德琴科式手绘方块字) ----------
+ const GL = {
+ 'П': [[0, 0, 5, 1.3], [0, 0, 1.3, 7], [3.7, 0, 1.3, 7]],
+ 'Е': [[0, 0, 1.3, 7], [0, 0, 5, 1.3], [0, 2.9, 4, 1.2], [0, 5.7, 5, 1.3]],
+ 'Т': [[0, 0, 5, 1.3], [1.85, 0, 1.3, 7]],
+ 'Ч': [[0, 0, 1.3, 4], [3.7, 0, 1.3, 7], [0, 2.9, 5, 1.2]],
+ 'А': [{ p: [[0, 7], [1.8, 0], [3.2, 0], [1.4, 7]] }, { p: [[5, 7], [3.2, 0], [1.8, 0], [3.6, 7]] }, [1.0, 4.3, 3.0, 1.15]],
+ 'Й': [[0, 1.7, 1.3, 5.3], [3.7, 1.7, 1.3, 5.3], { p: [[1.3, 5.5], [3.7, 2.0], [3.7, 3.7], [1.3, 7]] }, [1.2, 0, 2.6, 1.0]], // 短音符收在字格内:伸出格外会被相邻字母/人物盖掉(第一版踩到)
+ '!': [[1.85, 0, 1.3, 4.8], [1.85, 5.7, 1.3, 1.3]],
+ };
+ function glyph(c, ch, x, y, u) {
+ const g = GL[ch]; if (!g) return;
+ // 逐部件各自 fill:同一 path 里反向绕行的两条斜腿会按 nonzero 规则互相抵消出洞(А 第一版踩到)
+ g.forEach(r => { c.beginPath(); if (r.p) { r.p.forEach((q, i) => i ? c.lineTo(x + q[0] * u, y + q[1] * u) : c.moveTo(x + q[0] * u, y + q[1] * u)); c.closePath(); } else c.rect(x + r[0] * u, y + r[1] * u, r[2] * u, r[3] * u); c.fill(); });
+ }
+
+ // ---------- ① 底版 ----------
+ const TOWER = [[540, 170, 430, 108], [430, 100, 342, 70], [342, 66, 268, 47], [268, 44, 208, 32], [208, 30, 168, 22]];
+ const TX = 600;
+ const bg = () => P.cached('cs_bg', W, H, (g) => {
+ g.drawImage(P.texture('cs_paper', C.paper, { scale: 0.0035, amt: 16, grain: 18, seed: 5, dark: '#d9c9a4' }), 0, 0);
+ // 左侧排版构件:斜黑条、红方块、几行「正文」黑条
+ g.save(); g.translate(170, 610); g.rotate(-0.5); g.fillStyle = C.ink; g.fillRect(-260, -30, 560, 58); g.restore();
+ g.save(); g.translate(150, 200); g.rotate(0.26); g.fillStyle = C.red; g.fillRect(-70, -70, 140, 140); g.restore();
+ g.save(); g.translate(60, 330); g.rotate(-0.08); g.fillStyle = C.ink; [180, 150, 200, 120, 170].forEach((w, k) => g.fillRect(0, k * 26, w, 10)); g.restore();
+ // 右侧:细斜线+红圆点+竖排「ЧАЙ」
+ g.strokeStyle = C.ink; g.lineWidth = 6; g.beginPath(); g.moveTo(1520, 250); g.lineTo(1920, 760); g.stroke();
+ g.fillStyle = C.red; g.beginPath(); g.arc(1790, 340, 46, 0, TAU); g.fill();
+ g.fillStyle = C.ink; g.fillRect(1660, 430, 120, 400);
+ g.fillStyle = C.cream; ['Ч', 'А', 'Й'].forEach((ch, k) => glyph(g, ch, 1682, 470 + k * 120, 15.5));
+ // 大黑圆(人物头后)
+ g.fillStyle = C.ink; g.beginPath(); g.arc(1330, 395, 215, 0, TAU); g.fill();
+ // 红色斜地面
+ g.fillStyle = C.red; g.beginPath(); g.moveTo(0, 905); g.lineTo(W, 856); g.lineTo(W, H); g.lineTo(0, H); g.closePath(); g.fill();
+ g.fillStyle = C.ink; g.beginPath(); g.moveTo(0, 899); g.lineTo(W, 850); g.lineTo(W, 862); g.lineTo(0, 911); g.closePath(); g.fill();
+ // 窗:网点照片(天空+云)
+ const ph = P.canvas(), pg = ph.getContext('2d');
+ const sg = pg.createLinearGradient(0, 140, 0, 540); sg.addColorStop(0, '#5e5e5e'); sg.addColorStop(0.75, '#cfcfcf'); sg.addColorStop(1, '#e8e8e8');
+ pg.fillStyle = sg; pg.fillRect(370, 140, 420, 400);
+ [[460, 240, 90, 34], [700, 300, 110, 30], [520, 400, 140, 26]].forEach(([x, y, rx, ry]) => { const rg = pg.createRadialGradient(x, y, 4, x, y, rx); rg.addColorStop(0, 'rgba(250,250,250,.95)'); rg.addColorStop(1, 'rgba(250,250,250,0)'); pg.fillStyle = rg; pg.beginPath(); pg.ellipse(x, y, rx, ry * 2, 0, 0, TAU); pg.fill(); });
+ pg.fillStyle = '#2a2a2a'; pg.fillRect(370, 505, 420, 35); // 远处厂房屋脊(暗)
+ [[390, 470, 50], [470, 485, 36], [690, 460, 70], [760, 480, 30]].forEach(([x, y, w]) => pg.fillRect(x, y, w, 60));
+ pg.fillRect(712, 360, 18, 120); // 烟囱
+ g.fillStyle = C.cream; g.fillRect(370, 140, 420, 400);
+ halftone(g, ph, 370, 140, 420, 400, 7, C.ink, 0.8);
+ // 舒霍夫塔:五节双曲面,两组直母线
+ g.save(); g.beginPath(); g.rect(370, 140, 420, 400); g.clip();
+ g.strokeStyle = C.ink; g.lineCap = 'round';
+ TOWER.forEach(([y0, w0, y1, w1], k) => {
+ g.lineWidth = 2.6 - k * 0.25;
+ for (const dir of [1, -1]) for (let i = 0; i < 18; i++) {
+ const a = i / 18 * TAU, b = a + dir * 1.1;
+ const x0 = TX + Math.cos(a) * w0 / 2, x1 = TX + Math.cos(b) * w1 / 2;
+ if (Math.sin(a) < -0.2 && Math.sin(b) < -0.2) continue; // 背面的线省掉,读起来更清楚
+ g.beginPath(); g.moveTo(x0, y0 + Math.sin(a) * w0 * 0.08); g.lineTo(x1, y1 + Math.sin(b) * w1 * 0.08); g.stroke();
+ }
+ g.lineWidth = 4; g.beginPath(); g.ellipse(TX, y1, w1 / 2, w1 * 0.08, 0, 0, TAU); g.stroke();
+ });
+ g.lineWidth = 4; g.beginPath(); g.moveTo(TX, 168); g.lineTo(TX, 140); g.stroke();
+ g.restore();
+ // 窗框(粗黑)+红窗台
+ g.strokeStyle = C.ink; g.lineWidth = 26; g.strokeRect(357, 127, 446, 426);
+ g.fillStyle = C.red; g.fillRect(330, 554, 500, 30); g.fillStyle = C.ink; g.fillRect(330, 584, 500, 8);
+ // 桌:黑板面+红边+斜撑
+ g.fillStyle = C.ink; g.fillRect(810, 618, 400, 34); g.fillStyle = C.red; g.fillRect(810, 652, 400, 12);
+ g.fillStyle = C.ink; g.fillRect(842, 664, 24, 220); g.fillRect(1158, 664, 24, 220);
+ g.lineWidth = 14; g.strokeStyle = C.ink; g.beginPath(); g.moveTo(854, 870); g.lineTo(1170, 680); g.stroke();
+ // 凳:黑块
+ g.fillStyle = C.ink; g.fillRect(1440, 470, 34, 420); g.fillRect(1290, 740, 190, 26); g.fillRect(1300, 760, 22, 120);
+ });
+
+ // ---------- 少女 ----------
+ const girlPal = { skin: C.cream, hair: C.ochre, dress: '#2f2c29', sleeve: C.cream, cuff: C.red, line: C.ink, lw: 3 };
+ function girl(c, G, ch, lt) {
+ const tilt = G.tilt, nk = [1300, 425];
+ const HP = (x, y) => { const X = x - nk[0], Y = y - nk[1], cs = Math.cos(tilt), sn = Math.sin(tilt); return [nk[0] + X * cs - Y * sn, nk[1] + X * sn + Y * cs]; };
+ const L = C.ink;
+ const F = (p, col, lw = 3) => { if (!p) return; c.fillStyle = col; c.fill(p); if (lw) { c.strokeStyle = L; c.lineWidth = lw; c.stroke(p); } };
+ c.save(); c.lineJoin = 'round'; c.lineCap = 'round';
+ // 远侧袖(白衬衫)+手
+ F(G.farSleeve, C.cream); F(G.farCuff, C.red, 2);
+ // 裙:深灰平涂+网点阴影
+ F(G.skirt, '#34302c', 0);
+ shadeDots(c, G.skirt, 1090, 600, 380, 340, 9, '#0d0c0b', (x, y) => clamp((x - 1180) / 260) * 0.9);
+ c.strokeStyle = L; c.lineWidth = 3; c.stroke(G.skirt);
+ F(G.shoe, L, 0);
+ // 上身:白衬衫+红领巾三角
+ F(G.torso, C.cream);
+ shadeDots(c, G.torso, 1270, 420, 170, 210, 8, '#7d766a', (x, y) => clamp((x - 1350) / 80));
+ const nkA = G.A.neck;
+ c.fillStyle = C.red; c.beginPath(); c.moveTo(nkA[0] - 18, nkA[1] - 2); c.lineTo(nkA[0] + 26, nkA[1] + 2); c.lineTo(nkA[0] - 2, nkA[1] + 62); c.closePath(); c.fill();
+ // 头发(金)+红头巾
+ F(G.hairBack, C.ochre, 0); F(G.bangs, C.ochre, 0);
+ c.strokeStyle = C.ochreD; c.lineWidth = 3; G.hairLines.forEach(h => c.stroke(h));
+ // 皮肤:先画灰度「照片」到离屏,再网点化 → 照片拼贴
+ const S = P.scratch('csSkin'), sg = S.getContext('2d', { willReadFrequently: true });
+ sg.reset(); sg.clearRect(1100, 270, 300, 400);
+ const shade = (p, x0, x1, a, b) => { const gr = sg.createLinearGradient(x0, 0, x1, 0); gr.addColorStop(0, a); gr.addColorStop(1, b); sg.fillStyle = gr; sg.fill(p); };
+ shade(G.neck, 1285, 1325, '#b4b4b4', '#767676');
+ shade(G.face, 1250, 1330, '#fafafa', '#9c9c9c');
+ sg.fillStyle = 'rgba(90,90,90,.28)'; sg.beginPath(); sg.ellipse(G.cheek[0] + 16, G.cheek[1] + 4, 16, 12, 0, 0, TAU); sg.fill(); // 颧下阴影(轻)
+ shade(G.hand, G.A.hand[0] - 20, G.A.hand[0] + 20, '#d8d8d8', '#8a8a8a'); shade(G.farHand, 1146, 1218, '#f4f4f4', '#b0b0b0');
+ // 白色剪切边 + 网点
+ c.save(); c.strokeStyle = '#fbf7ea'; c.lineWidth = 7; [G.neck, G.face, G.farHand].forEach(p => c.stroke(p)); c.restore();
+ [G.neck, G.face, G.farHand].forEach(p => { c.fillStyle = C.cream; c.fill(p); });
+ halftone(c, S, 1135, 280, 220, 360, 4.6, C.ink, 0.74);
+ // 五官(照片上手工补的清晰笔画)+红唇
+ if (ch.blink) { c.strokeStyle = L; c.lineWidth = 3; c.stroke(G.lid); }
+ else { c.fillStyle = L; c.beginPath(); c.ellipse(G.eye.x - 1, G.eye.y + 1, 5, 6.5, 0, 0, TAU); c.fill(); c.strokeStyle = L; c.lineWidth = 3; c.stroke(G.lid); G.lashes.forEach(l => { c.beginPath(); c.moveTo(...l[0]); c.lineTo(...l[1]); c.stroke(); }); }
+ c.lineWidth = 3.4; c.stroke(G.brow);
+ c.fillStyle = C.red; c.beginPath(); c.moveTo(...G.lips[0]); c.lineTo(...G.lips[1]); c.lineTo(...G.lips[2]); c.closePath(); c.fill();
+ // 头巾:盖住头顶与后脑,额前露金发;颈后打结两条尾
+ const kf = poly([[1280, 296], [1300, 285], [1330, 280], [1368, 291], [1402, 321], [1415, 368], [1405, 414], [1382, 440], [1356, 442], [1350, 410], [1342, 372], [1326, 334], [1304, 309]].map(p => HP(...p)));
+ const lock = poly([[1352, 425], [1372, 432], [1380, 470], [1372, 505], [1360, 470]].map(p => HP(...p)));
+ F(lock, C.ochre, 0); c.strokeStyle = C.ochreD; c.lineWidth = 2.5; c.stroke(lock);
+ F(kf, C.red, 3);
+ c.strokeStyle = C.redD; c.lineWidth = 3; c.beginPath(); [[1300, 300, 1390, 360], [1330, 292, 1400, 330]].forEach(([a, b, x, y]) => { const p0 = HP(a, b), p1 = HP(x, y); c.moveTo(...p0); c.lineTo(...p1); }); c.stroke();
+ const sw = Math.sin(lt * 9) * 6; // 头巾尾随动作轻摆
+ [[[1384, 432], [1446, 470 + sw], [1416, 478 + sw]], [[1378, 438], [1428, 500 - sw], [1400, 498 - sw]]].forEach(tri => F(poly(tri.map(p => HP(...p))), C.red, 3));
+ // 近侧手臂(白袖+红袖口)、杯、手
+ F(G.upperArm, C.cream); F(G.foreArm, C.cream); F(G.cuff, C.red, 2);
+ sg.reset(); sg.clearRect(1100, 270, 300, 400); shade(G.hand, G.A.hand[0] - 18, G.A.hand[0] + 18, '#dcdcdc', '#7a7a7a');
+ c.save(); c.strokeStyle = '#fbf7ea'; c.lineWidth = 7; c.stroke(G.hand); c.restore(); c.fillStyle = C.cream; c.fill(G.hand);
+ halftone(c, S, G.A.hand[0] - 26, G.A.hand[1] - 26, 52, 52, 4.6, C.ink, 0.74);
+ RIG.drawCup(c, G.cup, { body: C.cream, rim: C.ink, line: L, lw: 3, hw: 7 });
+ c.save(); c.translate(G.cup.x, G.cup.y); c.rotate(G.cup.tilt); c.fillStyle = C.red; c.fillRect(-G.cup.w * 0.46, G.cup.h * 0.38, G.cup.w * 0.92, 9); c.restore();
+ c.fillStyle = C.cream; c.beginPath(); c.arc(G.thumb[0], G.thumb[1], 7, 0, TAU); c.fill(); c.strokeStyle = L; c.lineWidth = 2.4; c.stroke();
+ c.restore();
+ }
+
+ // ---------- 猫:剪纸平涂+网点阴影+粗黑条纹 ----------
+ function cat(c, K) {
+ c.save(); c.lineJoin = 'round'; c.lineCap = 'butt';
+ c.strokeStyle = C.ink; c.lineWidth = K.tailW + 8; c.stroke(K.tail); c.strokeStyle = C.orange; c.lineWidth = K.tailW; c.stroke(K.tail);
+ c.setLineDash([12, 14]); c.strokeStyle = C.ink; c.lineWidth = K.tailW * 0.9; c.stroke(K.tail); c.setLineDash([]);
+ const tip = K.tailPts[K.tailPts.length - 1]; c.fillStyle = C.cream; c.beginPath(); c.arc(tip[0], tip[1], K.tailW / 2, 0, TAU); c.fill();
+ c.fillStyle = C.orange; c.fill(K.body); shadeDots(c, K.body, 420, 660, 250, 250, 9, '#7a2f0c', (x, y) => clamp((x - 520) / 140) * 0.8 + clamp((y - 820) / 90) * 0.3);
+ c.strokeStyle = C.ink; c.lineWidth = 4; c.stroke(K.body);
+ K.legs.forEach(l => { c.fillStyle = C.cream; c.fill(l); c.stroke(l); });
+ c.fillStyle = C.cream; c.fill(K.white);
+ c.fillStyle = C.orange; c.fill(K.head); c.stroke(K.head);
+ c.save(); c.clip(K.head); c.fillStyle = C.cream; c.beginPath(); c.ellipse(K.nose[0] - 22, K.nose[1] + 12, 36, 26, 0, 0, TAU); c.fill(); c.restore();
+ c.fillStyle = C.red; K.earInner.forEach(e => { c.beginPath(); e.forEach((p, i) => i ? c.lineTo(...p) : c.moveTo(...p)); c.fill(); });
+ c.strokeStyle = C.ink; c.lineWidth = 10; K.stripes.forEach(s => { c.beginPath(); c.moveTo(...s[0]); c.lineTo(...s[1]); c.stroke(); });
+ K.eyes.forEach(e => { if (K.blink) { c.lineWidth = 4; c.beginPath(); c.moveTo(e.x - 9, e.y); c.lineTo(e.x + 9, e.y); c.stroke(); }
+ else { c.fillStyle = C.cream; c.beginPath(); c.arc(e.x, e.y, 10, 0, TAU); c.fill(); c.lineWidth = 3; c.stroke(); c.fillStyle = C.ink; c.fillRect(e.x - 1, e.y - 8, 5, 16); } });
+ c.fillStyle = C.red; c.beginPath(); c.moveTo(K.nose[0] - 7, K.nose[1] - 4); c.lineTo(K.nose[0] + 7, K.nose[1] - 4); c.lineTo(K.nose[0], K.nose[1] + 5); c.fill();
+ c.lineWidth = 2; K.whiskers.forEach(w => { c.beginPath(); c.moveTo(...w[0]); c.lineTo(...w[1]); c.stroke(); });
+ c.restore();
+ }
+
+ const SLOGAN = 'ПЕЙТЕ ЧАЙ!';
+ return {
+ draw(c, lt, t) {
+ const ch = P.choreo(lt, t);
+ c.drawImage(bg(), 0, 0);
+ // 黑圆外的红虚线环(旋转)
+ c.save(); c.strokeStyle = C.red; c.lineWidth = 12; c.setLineDash([46, 22]); c.lineDashOffset = -lt * 260;
+ c.beginPath(); c.arc(1330, 395, 242, 0, TAU); c.stroke(); c.restore();
+ // 李西茨基红楔:沿轴线刺入黑圆(1.6Hz 进退)
+ const thrust = 70 * (0.5 - 0.5 * Math.cos(lt * TAU * 1.6)), ax = Math.cos(0.34), ay = Math.sin(0.34);
+ const tipX = 1150 + ax * thrust, tipY = 360 + ay * thrust;
+ c.fillStyle = C.red; c.beginPath(); c.moveTo(tipX, tipY); c.lineTo(tipX - ax * 330 - ay * 95, tipY - ay * 330 + ax * 95); c.lineTo(tipX - ax * 330 + ay * 95, tipY - ay * 330 - ax * 95); c.closePath(); c.fill();
+ // 窗内:塔顶无线电波(红弧外扩)
+ c.save(); c.beginPath(); c.rect(370, 140, 420, 400); c.clip(); c.strokeStyle = C.red; c.lineCap = 'butt';
+ for (let k = 0; k < 4; k++) { const ph = (lt * 1.4 + k / 4) % 1, r = 18 + ph * 230; c.globalAlpha = 1 - ph; c.lineWidth = 10 - ph * 6;
+ c.beginPath(); c.arc(TX, 150, r, Math.PI * 0.05, Math.PI * 0.95, true); c.stroke(); }
+ c.restore();
+ // 角色
+ const K = RIG.cat({ tail: ch.tail, blink: ch.blink, breathe: ch.breathe });
+ cat(c, K);
+ const G = RIG.girl({ cup: ch.cup, sip: ch.sip, breathe: ch.breathe });
+ girl(c, G, ch, lt);
+ // 地面标语(画在角色之上:海报字压人物):逐字盖章(0–0.5s)→ 之后波浪跳
+ c.save(); c.translate(0, 0); const ang = Math.atan2(-49, W); c.rotate(ang);
+ const u = 19, adv = 6.3 * u; let x = 350;
+ [...SLOGAN].forEach((chh, k) => {
+ if (chh === ' ') { x += 3.5 * u; return; }
+ const q = clamp((lt - k * 0.045) / 0.12); if (q <= 0) { x += adv; return; }
+ const s = 1 + 0.5 * (1 - ease.out(q)), hop = -10 * Math.max(0, Math.sin(lt * 11 - k * 0.8));
+ c.save(); c.translate(x + 2.5 * u, 990 + hop); c.scale(s, s); c.globalAlpha = q;
+ c.fillStyle = k % 4 === 3 ? C.ink : C.cream; glyph(c, chh, -2.5 * u, -3.5 * u, u); c.restore();
+ x += adv;
+ });
+ c.restore();
+ // 杯上热气:三条黑折线上行
+ c.save(); c.strokeStyle = C.ink; c.lineWidth = 4; c.lineJoin = 'miter';
+ for (let k = 0; k < 3; k++) { const ph = (lt * 2 + k / 3) % 1, x0 = G.cup.x - 14 + k * 14, y0 = G.cup.y - 12 - ph * 60; c.globalAlpha = 1 - ph;
+ c.beginPath(); c.moveTo(x0, y0); c.lineTo(x0 + 7, y0 - 9); c.lineTo(x0, y0 - 18); c.lineTo(x0 + 7, y0 - 27); c.stroke(); }
+ c.restore();
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/23_dali.js b/scripts/engine/scenes/23_dali.js
new file mode 100644
index 0000000..2b02d6e
--- /dev/null
+++ b/scripts/engine/scenes/23_dali.js
@@ -0,0 +1,221 @@
+// 1931 达利超现实主义(《记忆的永恒》)——纯代码。
+// 管线:①缓存底版(群青→淡黄天空、玻璃般静海、克雷乌斯角金色礁岩、赭色荒原、开窗的断墙残片、石块桌)
+// → ②长影子:每个物体的剪影用一个剪切仿射投到地面(kx 随时间增大=影子缓慢变长),先进离屏再整体半透明叠,避免重叠加深
+// → ③软钟:圆盘 (u,v) → 屏幕的折叠映射,越过边缘的部分垂下并随时间继续下垂;刻度与指针走同一映射
+// → ④会动的母题(软钟下垂+指针转、高跷象在地平线上迈步、蚂蚁绕怀表爬、影子变长)
+// → ⑤角色:无勾线学院派体积(线性渐变+clip 内模糊描边做内阴影)+细五官
+SCENES['23_dali'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, ease } = U, P = PAINT, TAU = Math.PI * 2;
+ const HZ = 560, GROUND = 592; // 海平线、岸线
+ const C = { sky0: '#22407c', sky1: '#5f88bd', sky2: '#e9dcae', sea: '#6f8fa6', ground0: '#d2ad70', ground1: '#7a5129', shadow: '#2a1a10',
+ wall: '#e7dcc3', wallD: '#a99a7c', wood: '#7a4a24', woodL: '#a8703a', block: '#8a5a32', blockL: '#b98754', gold: '#d9b25a', dial: '#efe6c8', orange: '#d8621f' };
+
+ const vol = P.vol; // 体积填色:线性渐变+路径内模糊暗边(学院派,无勾线)
+
+ // ---------- ① 底版 ----------
+ const bg = () => P.cached('dali_bg', W, H, (g) => {
+ const sg = g.createLinearGradient(0, 0, 0, HZ); sg.addColorStop(0, C.sky0); sg.addColorStop(0.55, C.sky1); sg.addColorStop(1, C.sky2);
+ g.fillStyle = sg; g.fillRect(0, 0, W, HZ + 2);
+ // 细长粉云
+ [[200, 300, 260, 7], [700, 250, 340, 6], [1280, 330, 300, 8], [900, 420, 420, 5]].forEach(([x, y, w, h]) => { const rg = g.createLinearGradient(x - w, 0, x + w, 0); rg.addColorStop(0, 'rgba(250,215,200,0)'); rg.addColorStop(0.5, 'rgba(250,215,200,.55)'); rg.addColorStop(1, 'rgba(250,215,200,0)'); g.fillStyle = rg; g.beginPath(); g.ellipse(x, y, w, h, 0, 0, TAU); g.fill(); });
+ // 静海(玻璃般,几道高光线)
+ const mg = g.createLinearGradient(0, HZ, 0, GROUND); mg.addColorStop(0, '#8aa6b8'); mg.addColorStop(1, '#4f6f86'); g.fillStyle = mg; g.fillRect(0, HZ, W, GROUND - HZ);
+ g.strokeStyle = 'rgba(240,235,210,.6)'; g.lineWidth = 1.5; [568, 574, 583].forEach((y, k) => { g.beginPath(); g.moveTo(80 + k * 140, y); g.lineTo(700 + k * 200, y); g.stroke(); });
+ // 克雷乌斯角礁岩(右侧,金色,光滑高光)
+ const cliff = new Path2D(); cliff.moveTo(1380, GROUND); [[1420, 540], [1470, 500], [1520, 470], [1590, 460], [1640, 430], [1700, 440], [1760, 410], [1830, 430], [1920, 420], [1920, GROUND]].forEach(p => cliff.lineTo(...p)); cliff.closePath();
+ vol(g, cliff, 1400, 420, 1500, 600, '#e8c27a', '#9a6a34', 'rgba(70,40,15,.5)', 18);
+ g.strokeStyle = 'rgba(255,240,200,.7)'; g.lineWidth = 3; g.beginPath(); g.moveTo(1470, 505); g.quadraticCurveTo(1530, 480, 1590, 470); g.moveTo(1650, 440); g.quadraticCurveTo(1700, 445, 1760, 418); g.stroke();
+ // 荒原:近暗远亮,几道细地层线
+ const gg = g.createLinearGradient(0, GROUND, 0, H); gg.addColorStop(0, C.ground0); gg.addColorStop(0.45, '#a87a44'); gg.addColorStop(1, C.ground1); g.fillStyle = gg; g.fillRect(0, GROUND, W, H - GROUND);
+ g.strokeStyle = 'rgba(90,55,25,.25)'; g.lineWidth = 2; for (let k = 0; k < 9; k++) { const y = GROUND + Math.pow(k / 9, 1.6) * 480 + 10; g.beginPath(); g.moveTo(0, y); g.bezierCurveTo(600, y - 6, 1300, y + 8, W, y - 2); g.stroke(); }
+ // 画布纹+暖色上光油
+ g.fillStyle = 'rgba(255,200,120,.06)'; g.fillRect(0, 0, W, H);
+ g.drawImage(P.grain('dali', 0.05, [70, 45, 20], 0.10), 0, 0);
+ });
+
+ const wallLayer = () => P.cached('dali_wall', W, H, (g) => {
+ // 断墙残片(开窗,立在荒原上,基线 y=700)
+ const wall = new Path2D(); wall.moveTo(300, 700); [[300, 120], [330, 96], [372, 108], [410, 78], [470, 92], [540, 70], [610, 88], [680, 64], [760, 90], [820, 80], [858, 104], [860, 700]].forEach(p => wall.lineTo(...p)); wall.closePath();
+ wall.rect(370, 140, 420, 400); // 窗洞(evenodd 挖空)
+ g.save(); const wg = g.createLinearGradient(300, 0, 860, 0); wg.addColorStop(0, '#f4ead2'); wg.addColorStop(1, '#cdbf9f'); g.fillStyle = wg; g.fill(wall, 'evenodd'); g.restore();
+ g.fillStyle = '#9d8c6c'; g.beginPath(); g.moveTo(860, 104); g.lineTo(892, 120); g.lineTo(892, 712); g.lineTo(860, 700); g.closePath(); g.fill(); // 墙侧面
+ g.strokeStyle = 'rgba(110,90,60,.55)'; g.lineWidth = 1.6; [[[330, 300], [352, 340], [344, 390], [360, 430]], [[820, 600], [800, 640], [812, 690]], [[640, 92], [652, 118], [646, 136]]].forEach(cr => { g.beginPath(); cr.forEach((p, i) => i ? g.lineTo(...p) : g.moveTo(...p)); g.stroke(); });
+ // 窗内:同一片风景(更亮更远)+窗框
+ g.save(); g.beginPath(); g.rect(370, 140, 420, 400); g.clip();
+ const ig = g.createLinearGradient(0, 140, 0, 540); ig.addColorStop(0, '#3d64a2'); ig.addColorStop(0.85, '#f0e1b4'); ig.addColorStop(1, '#f6ecc8'); g.fillStyle = ig; g.fillRect(370, 140, 420, 400);
+ g.fillStyle = '#7f9db3'; g.fillRect(370, 505, 420, 35); g.strokeStyle = 'rgba(250,245,220,.7)'; g.lineWidth = 1.4; g.beginPath(); g.moveTo(400, 515); g.lineTo(600, 515); g.moveTo(520, 528); g.lineTo(760, 528); g.stroke();
+ // 窗里漂浮的一只蛋(达利母题)
+ const eg = g.createRadialGradient(560, 300, 6, 580, 330, 70); eg.addColorStop(0, '#fffaf0'); eg.addColorStop(1, '#bfae8e'); g.fillStyle = eg; g.beginPath(); g.ellipse(580, 330, 46, 60, 0, 0, TAU); g.fill();
+ g.restore();
+ g.lineWidth = 18; g.strokeStyle = C.wood; g.strokeRect(361, 131, 438, 418); g.lineWidth = 4; g.strokeStyle = C.woodL; g.strokeRect(356, 126, 448, 428);
+ g.fillStyle = C.woodL; g.fillRect(340, 548, 480, 18); g.fillStyle = C.wood; g.fillRect(340, 566, 480, 12);
+ // 枯橄榄枝:从墙头右上角伸出(挂软钟用)
+ g.strokeStyle = '#4a3020'; g.lineCap = 'round'; g.lineWidth = 12; g.beginPath(); g.moveTo(850, 112); g.bezierCurveTo(900, 90, 960, 104, 1040, 96); g.stroke();
+ g.lineWidth = 6; g.beginPath(); g.moveTo(960, 100); g.quadraticCurveTo(990, 70, 1000, 46); g.moveTo(1010, 98); g.lineTo(1070, 112); g.stroke();
+ });
+ const blockLayer = () => P.cached('dali_block', W, H, (g) => {
+ // 石块桌:顶面+正面(光从左来)
+ g.fillStyle = C.blockL; g.beginPath(); g.moveTo(810, 620); g.lineTo(1205, 620); g.lineTo(1190, 600); g.lineTo(826, 600); g.closePath(); g.fill();
+ const bk = new Path2D(); bk.rect(810, 620, 395, 285); vol(g, bk, 810, 0, 1205, 0, '#b07a46', '#6e4422', 'rgba(40,20,8,.5)', 22);
+ // 少女的凳子(深色木块)
+ const st = new Path2D(); st.rect(1300, 742, 190, 163); vol(g, st, 1300, 0, 1490, 0, '#8a5a32', '#4a2c14', 'rgba(30,15,5,.5)', 16);
+ });
+
+ // ---------- ③ 软钟:圆盘局部坐标 (u,v)∈半径 R → 屏幕;v 越过折线 fold 的部分垂下 ----------
+ function softMap(o, sag) {
+ const { cx, cy, R, fold, top = 0.32, flare = -0.12, drip = 0.18 } = o; // flare<0:垂下部分像软布一样往外摊开,下缘圆而不是尖
+ return (u, v) => {
+ if (v <= fold) return [cx + u, cy + v * top + Math.sin(u * 0.05) * 2];
+ const d = v - fold, q = d / R;
+ return [cx + u * (1 - flare * q) + Math.sin(q * 3) * 5 * sag, cy + fold * top + d * (0.62 + 0.3 * sag) + sag * R * drip * Math.exp(-(((u + R * 0.2) / (R * 0.6)) ** 2)) * q * q + Math.sin(u * 0.06 + 1) * 6 * q];
+ };
+ }
+ function softClock(c, o, sag, t, handSpeed) {
+ const m = softMap(o, sag), R = o.R;
+ const ring = (r) => { const pts = []; for (let i = 0; i <= 120; i++) { const a = i / 120 * TAU; pts.push(m(Math.cos(a) * r, Math.sin(a) * r)); } return pts; };
+ const path = pts => { const p = new Path2D(); pts.forEach((q, i) => i ? p.lineTo(...q) : p.moveTo(...q)); p.closePath(); return p; };
+ const outer = path(ring(R)), inner = path(ring(R * 0.86));
+ // 投影(贴着表面的软影)
+ c.save(); c.translate(-8, 10); c.fillStyle = 'rgba(30,15,5,.35)'; c.filter = 'blur(6px)'; c.fill(outer); c.restore();
+ vol(c, outer, o.cx - R, 0, o.cx + R, 0, '#f0d27c', '#9a7426', 'rgba(70,45,10,.5)', 8);
+ const fg = c.createLinearGradient(0, o.cy - R * 0.3, 0, o.cy + R * 1.4); fg.addColorStop(0, '#f6efd6'); fg.addColorStop(0.45, '#e8dcb6'); fg.addColorStop(1, '#bfae84');
+ c.fillStyle = fg; c.fill(inner);
+ // 刻度与罗马数字的「点」:走同一映射
+ c.fillStyle = '#3a2a18';
+ for (let k = 0; k < 12; k++) { const a = k / 12 * TAU - Math.PI / 2, p0 = m(Math.cos(a) * R * 0.74, Math.sin(a) * R * 0.74), p1 = m(Math.cos(a) * R * 0.8, Math.sin(a) * R * 0.8);
+ c.strokeStyle = '#3a2a18'; c.lineWidth = k % 3 ? 2 : 4; c.beginPath(); c.moveTo(...p0); c.lineTo(...p1); c.stroke(); }
+ // 指针(沿映射采样成软线)
+ const hand = (ang, len, w) => { c.lineWidth = w; c.lineCap = 'round'; c.beginPath(); for (let i = 0; i <= 12; i++) { const r = len * i / 12, q = m(Math.cos(ang) * r, Math.sin(ang) * r); i ? c.lineTo(...q) : c.moveTo(...q); } c.stroke(); };
+ c.strokeStyle = '#2a1c10'; hand(t * handSpeed - 1.2, R * 0.66, 4); hand(t * handSpeed / 12 + 0.6, R * 0.46, 6);
+ const cc = m(0, 0); c.fillStyle = '#2a1c10'; c.beginPath(); c.arc(cc[0], cc[1], 4, 0, TAU); c.fill();
+ // 折线上的高光(柔软的「棱」)
+ c.strokeStyle = 'rgba(255,250,225,.55)'; c.lineWidth = 3; c.beginPath(); for (let i = 0; i <= 30; i++) { const u = -R * 0.9 + i / 30 * R * 1.8, q = m(u, o.fold + 2); i ? c.lineTo(...q) : c.moveTo(...q); } c.stroke();
+ return outer;
+ }
+
+ // ---------- 高跷象 ----------
+ function elephant(c, x, lt) {
+ const y = 400, legH = GROUND - 2 - y;
+ c.save(); c.fillStyle = '#5a4a46'; c.strokeStyle = '#5a4a46'; c.lineCap = 'round';
+ // 四条细长腿:交替迈步(关节处微弯)
+ [[-26, 0], [-12, Math.PI], [18, Math.PI * 0.5], [30, Math.PI * 1.5]].forEach(([ox, ph]) => {
+ const sw = Math.sin(lt * 7 + ph), fx = x + ox + sw * 10, kx = x + ox + sw * 4 + 3, ky = y + legH * 0.52 - Math.max(0, sw) * 6;
+ c.lineWidth = 2.6; c.beginPath(); c.moveTo(x + ox, y + 8); c.lineTo(kx, ky); c.lineTo(fx, GROUND - 2 - Math.max(0, sw) * 5); c.stroke();
+ });
+ const bob = Math.sin(lt * 14) * 1.5;
+ c.beginPath(); c.ellipse(x, y + bob, 54, 28, 0, 0, TAU); c.fill();
+ c.beginPath(); c.ellipse(x - 44, y - 8 + bob, 18, 16, 0, 0, TAU); c.fill(); // 头(朝左)
+ c.lineWidth = 6; c.beginPath(); c.moveTo(x - 56, y - 2 + bob); c.quadraticCurveTo(x - 72, y + 30, x - 64 + Math.sin(lt * 5) * 6, y + 52); c.stroke(); // 象鼻
+ // 背上的方尖碑与鞍布
+ c.fillStyle = '#c8402c'; c.fillRect(x - 22, y - 26 + bob, 40, 8);
+ c.fillStyle = '#e6d6b0'; c.beginPath(); c.moveTo(x - 10, y - 26 + bob); c.lineTo(x + 6, y - 26 + bob); c.lineTo(x - 2, y - 96 + bob); c.closePath(); c.fill();
+ c.fillStyle = 'rgba(255,235,200,.35)'; c.beginPath(); c.ellipse(x - 14, y - 10 + bob, 26, 6, -0.2, 0, TAU); c.fill(); // 左上受光
+ c.restore();
+ }
+
+ // ---------- 蚂蚁怀表 ----------
+ function antWatch(c, lt) {
+ const x = 1030, y = 606;
+ const wg = c.createRadialGradient(x - 10, y - 8, 3, x, y, 40); wg.addColorStop(0, '#f39a4a'); wg.addColorStop(1, '#9a3a10');
+ c.fillStyle = 'rgba(30,15,5,.35)'; c.beginPath(); c.ellipse(x + 10, y + 8, 40, 11, 0, 0, TAU); c.fill();
+ c.fillStyle = wg; c.beginPath(); c.ellipse(x, y, 38, 13, 0, 0, TAU); c.fill();
+ c.fillStyle = '#c9a24a'; c.beginPath(); c.ellipse(x + 36, y - 4, 7, 5, 0, 0, TAU); c.fill();
+ c.fillStyle = '#120a06';
+ for (let k = 0; k < 9; k++) { const a = lt * (1.6 + (k % 3) * 0.5) * (k % 2 ? 1 : -1) + k * 0.7, r = 0.35 + (k % 4) * 0.14;
+ const ax = x + Math.cos(a) * 32 * r, ay = y + Math.sin(a) * 10 * r, d = a + (k % 2 ? Math.PI / 2 : -Math.PI / 2);
+ for (let s = -1; s <= 1; s++) { c.beginPath(); c.ellipse(ax + Math.cos(d) * s * 3.2, ay + Math.sin(d) * s * 1.2, 2, 1.4, d, 0, TAU); c.fill(); } }
+ }
+
+ // ---------- 角色 ----------
+ function girl(c, G, ch) {
+ c.save();
+ const sk = ['#f6dcc6', '#d9a888'], dress = ['#c9d9e6', '#6e8aa6'], hair = ['#f4d98a', '#b98a34'];
+ vol(c, G.farSleeve, 1200, 560, 1340, 600, dress[0], dress[1]); vol(c, G.farHand, 1150, 0, 1218, 0, sk[0], sk[1], 'rgba(120,60,40,.35)', 6);
+ vol(c, G.skirt, 1100, 650, 1450, 900, '#dce8f0', dress[1], 'rgba(40,50,70,.45)', 26);
+ c.save(); c.clip(G.skirt); c.strokeStyle = 'rgba(60,80,110,.35)'; c.lineWidth = 10; c.filter = 'blur(5px)'; G.folds.forEach(f => c.stroke(f)); c.restore();
+ vol(c, G.shoe, 1100, 0, 1150, 0, '#6a3a22', '#2a140a', null);
+ vol(c, G.torso, 1290, 440, 1420, 600, dress[0], dress[1], 'rgba(40,50,70,.45)', 18);
+ // 白色小翻领
+ c.fillStyle = '#fbf6ea'; c.beginPath(); const nk = G.A.neck; c.ellipse(nk[0] + 4, nk[1] + 6, 30, 12, 0.1, 0, TAU); c.fill();
+ vol(c, G.neck, 1286, 0, 1324, 0, sk[0], sk[1], 'rgba(120,60,40,.35)', 6);
+ vol(c, G.hairBack, 1270, 300, 1400, 440, hair[0], hair[1], 'rgba(110,70,20,.45)', 12); vol(c, G.bun, 1360, 340, 1420, 400, hair[0], hair[1], 'rgba(110,70,20,.45)', 8);
+ // 卷发细线(波浪)
+ c.save(); c.clip(G.hairBack); c.strokeStyle = 'rgba(150,105,40,.6)'; c.lineWidth = 2; G.hairLines.forEach(h => c.stroke(h)); c.restore();
+ vol(c, G.face, 1245, 0, 1330, 0, sk[0], sk[1], 'rgba(150,80,60,.3)', 10);
+ c.save(); c.clip(G.face); c.fillStyle = 'rgba(235,130,120,.3)'; c.filter = 'blur(6px)'; c.beginPath(); c.arc(G.cheek[0], G.cheek[1], 12, 0, TAU); c.fill(); c.restore();
+ vol(c, G.bangs, 1250, 295, 1330, 360, hair[0], hair[1], 'rgba(110,70,20,.4)', 8);
+ c.strokeStyle = 'rgba(150,105,40,.7)'; c.lineWidth = 2; G.locks.forEach(h => c.stroke(h));
+ // 五官(细、暗褐、无黑线)
+ c.lineCap = 'round';
+ if (ch.blink) { c.strokeStyle = '#5a3420'; c.lineWidth = 2.2; c.stroke(G.lid); }
+ else { c.fillStyle = '#fbf3ea'; c.beginPath(); c.ellipse(G.eye.x, G.eye.y + 1, 6, 4, 0, 0, TAU); c.fill(); c.fillStyle = '#4a6a8a'; c.beginPath(); c.arc(G.eye.x - 1.5, G.eye.y + 1, 3.6, 0, TAU); c.fill(); c.fillStyle = '#1a1008'; c.beginPath(); c.arc(G.eye.x - 1.5, G.eye.y + 1, 1.6, 0, TAU); c.fill(); c.strokeStyle = '#4a2a18'; c.lineWidth = 2; c.stroke(G.lid); }
+ c.strokeStyle = '#a0763a'; c.lineWidth = 2; c.stroke(G.brow);
+ c.fillStyle = '#c8645e'; c.beginPath(); c.moveTo(...G.lips[0]); c.lineTo(...G.lips[1]); c.lineTo(...G.lips[2]); c.closePath(); c.fill();
+ c.fillStyle = 'rgba(120,60,40,.5)'; c.beginPath(); c.arc(G.nostril[0] + 2, G.nostril[1], 1.8, 0, TAU); c.fill();
+ vol(c, G.upperArm, 1300, 0, 1380, 0, dress[0], dress[1], 'rgba(40,50,70,.4)', 10); vol(c, G.foreArm, 1200, 0, 1320, 0, dress[0], dress[1], 'rgba(40,50,70,.4)', 10);
+ vol(c, G.cuff, 1200, 0, 1300, 0, '#fbf6ea', '#c8bea8', null);
+ vol(c, G.hand, G.A.hand[0] - 15, 0, G.A.hand[0] + 15, 0, sk[0], sk[1], 'rgba(120,60,40,.35)', 6);
+ RIG.drawCup(c, G.cup, { body: '#f3efe4', rim: '#7a4a2a', hw: 6 });
+ c.save(); c.translate(G.cup.x, G.cup.y); c.rotate(G.cup.tilt); const cg = c.createLinearGradient(-G.cup.w / 2, 0, G.cup.w / 2, 0); cg.addColorStop(0, 'rgba(255,255,255,0)'); cg.addColorStop(1, 'rgba(90,70,50,.45)'); c.fillStyle = cg; c.beginPath(); c.moveTo(-G.cup.w / 2, 0); c.lineTo(-G.cup.w * 0.42, G.cup.h); c.lineTo(G.cup.w * 0.42, G.cup.h); c.lineTo(G.cup.w / 2, 0); c.fill(); c.restore();
+ c.fillStyle = sk[0]; c.beginPath(); c.arc(G.thumb[0], G.thumb[1], 7, 0, TAU); c.fill();
+ c.restore();
+ }
+ function cat(c, K, lt) {
+ c.save(); c.lineCap = 'round';
+ // 尾巴:软化下垂(达利式融化)
+ const pts = K.tailPts.map((p, i) => { const q = i / (K.tailPts.length - 1); return [p[0], p[1] + q * q * 34 * (0.6 + 0.4 * Math.sin(lt * 2))]; });
+ const tail = new Path2D(); pts.forEach((p, i) => i ? tail.lineTo(...p) : tail.moveTo(...p));
+ c.strokeStyle = '#8a3c10'; c.lineWidth = K.tailW + 4; c.stroke(tail); c.strokeStyle = '#e48a3a'; c.lineWidth = K.tailW; c.stroke(tail);
+ const tip = pts[pts.length - 1]; c.fillStyle = '#fbf2e2'; c.beginPath(); c.ellipse(tip[0], tip[1] + 6, K.tailW / 2, K.tailW * 0.75, 0, 0, TAU); c.fill();
+ vol(c, K.body, 430, 0, 660, 0, '#f2a24c', '#a24a14', 'rgba(70,25,5,.5)', 22);
+ c.save(); c.clip(K.body); c.strokeStyle = 'rgba(150,60,15,.55)'; c.lineWidth = 9; c.filter = 'blur(2px)'; K.stripes.slice(3).forEach(s => { c.beginPath(); c.moveTo(...s[0]); c.lineTo(...s[1]); c.stroke(); }); c.restore();
+ K.legs.forEach(l => vol(c, l, 560, 0, 650, 0, '#fffaf0', '#cbbca0', 'rgba(90,70,40,.35)', 6));
+ c.save(); c.clip(K.body); const wch = new Path2D(); wch.ellipse(606, 768, 40, 92, -0.05, 0, TAU); vol(c, wch, 560, 0, 650, 0, '#fffaf0', '#d6c8ac', 'rgba(90,70,40,.3)', 10); c.restore();
+ vol(c, K.head, 540, 560, 660, 690, '#f6ac58', '#b25618', 'rgba(70,25,5,.45)', 14);
+ c.save(); c.clip(K.head); c.fillStyle = '#fbf3e4'; c.beginPath(); c.ellipse(K.nose[0] - 22, K.nose[1] + 12, 36, 26, 0, 0, TAU); c.fill(); c.restore();
+ c.fillStyle = '#e8a0a0'; K.earInner.forEach(e => { c.beginPath(); e.forEach((p, i) => i ? c.lineTo(...p) : c.moveTo(...p)); c.fill(); });
+ c.save(); c.clip(K.head); c.strokeStyle = 'rgba(150,60,15,.6)'; c.lineWidth = 7; c.filter = 'blur(1.5px)'; K.stripes.slice(0, 3).forEach(s => { c.beginPath(); c.moveTo(...s[0]); c.lineTo(...s[1]); c.stroke(); }); c.restore();
+ K.eyes.forEach(e => { if (K.blink) { c.strokeStyle = '#3a200c'; c.lineWidth = 2.5; c.beginPath(); c.arc(e.x, e.y, 8, 0.2, Math.PI - 0.2); c.stroke(); }
+ else { const eg = c.createRadialGradient(e.x - 2, e.y - 2, 1, e.x, e.y, 9); eg.addColorStop(0, '#e8f0a0'); eg.addColorStop(1, '#7a9a30'); c.fillStyle = eg; c.beginPath(); c.arc(e.x, e.y, 9, 0, TAU); c.fill(); c.fillStyle = '#120a04'; c.beginPath(); c.ellipse(e.x + 2, e.y, 2.6, 7, 0, 0, TAU); c.fill(); c.fillStyle = '#fff'; c.beginPath(); c.arc(e.x - 2, e.y - 3, 1.8, 0, TAU); c.fill(); } });
+ c.fillStyle = '#c86a64'; c.beginPath(); c.arc(K.nose[0], K.nose[1], 5, 0, TAU); c.fill();
+ c.strokeStyle = 'rgba(60,30,10,.8)'; c.lineWidth = 2; c.beginPath(); c.moveTo(...K.mouth[0]); c.quadraticCurveTo(...K.mouth[1], ...K.mouth[2]); c.stroke();
+ c.strokeStyle = 'rgba(255,250,235,.85)'; c.lineWidth = 1.2; K.whiskers.forEach(w => { c.beginPath(); c.moveTo(...w[0]); c.lineTo(...w[1]); c.stroke(); });
+ c.restore();
+ }
+
+ // ---------- ② 长影子:剪影 → 剪切仿射投到地面 ----------
+ function shadows(c, lt, K, G) { // 剪切仿射长影子:P.castShadow
+ const kx = 0.85 + 0.6 * ease.inOut(clamp(lt / 1.2));
+ P.castShadow(c, [
+ [700, g => { g.beginPath(); g.moveTo(300, 700); [[300, 120], [410, 78], [540, 70], [680, 64], [858, 104], [892, 120], [892, 700]].forEach(p => g.lineTo(...p)); g.closePath(); g.rect(370, 140, 420, 400); g.fill('evenodd'); }],
+ [905, g => { g.fillRect(810, 600, 395, 305); g.fill(K.body); g.fill(K.head); g.lineWidth = K.tailW; g.stroke(K.tail); }],
+ [930, g => { [G.skirt, G.torso, G.hairBack, G.bun, G.face, G.upperArm, G.foreArm, G.hand].forEach(p => p && g.fill(p)); g.fillRect(1300, 742, 190, 163); }],
+ ], { kx, ky: 0.22, clipY: GROUND + 2, alpha: 0.55, blur: 1.5, key: 'daliSh' });
+ }
+
+ return {
+ draw(c, lt, t) {
+ const ch = P.choreo(lt, t);
+ c.drawImage(bg(), 0, 0);
+ elephant(c, 1060 - lt * 70, lt);
+ const K = RIG.cat({ tail: ch.tail * 0.5, blink: ch.blink, breathe: ch.breathe });
+ const G = RIG.girl({ cup: ch.cup, sip: ch.sip, breathe: ch.breathe, hair: 'bun' });
+ shadows(c, lt, K, G);
+ c.drawImage(wallLayer(), 0, 0); c.drawImage(blockLayer(), 0, 0);
+ // 枯枝上的软钟(大部分垂下)
+ softClock(c, { cx: 975, cy: 104, R: 64, fold: -34, top: 0.25, drip: 0.25 }, 0.1 + 1.2 * ease.inOut(clamp(lt / 1.2)), t + 7, 4.5);
+ // 窗台上的软钟(垂在墙面上,慢慢往下流)
+ const sag = 0.1 + 1.3 * ease.inOut(clamp(lt / 1.2)); // 钟在 1.2s 里明显往下流
+ softClock(c, { cx: 740, cy: 548, R: 72, fold: 4, top: 0.3, drip: 0.4 }, sag, t, 6.5);
+ // 石块桌前沿的软钟
+ softClock(c, { cx: 912, cy: 610, R: 88, fold: 12, top: 0.28, drip: 0.3 }, sag * 0.9, t + 3, -2.4);
+ antWatch(c, lt);
+ cat(c, K, lt);
+ girl(c, G, ch);
+ // 热气:很淡的两缕
+ P.steam(c, t, G.cup.x, G.cup.y - 8, { h: 60, n: 2, color: 'rgba(255,250,240,.55)', width: 3, spread: 12, wobble: 7 });
+ // 暗角(博物馆灯下的画)
+ const vg = c.createRadialGradient(960, 520, 520, 960, 540, 1150); vg.addColorStop(0, 'rgba(0,0,0,0)'); vg.addColorStop(1, 'rgba(25,12,4,.38)'); c.fillStyle = vg; c.fillRect(0, 0, W, H);
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/24_hopper.js b/scripts/engine/scenes/24_hopper.js
new file mode 100644
index 0000000..4f9eb11
--- /dev/null
+++ b/scripts/engine/scenes/24_hopper.js
@@ -0,0 +1,150 @@
+// 1942 霍珀美国现实主义(《晨光》《夜鹰》的硬光块面)——纯代码。
+// 核心手法「双版本裁切」:整幅底版画两张缓存——背光版(冷绿墙、暗地板)和受光版(暖黄墙、亮地板);
+// 每帧用会移动的光斑多边形把受光版裁进来 → 光影边缘是硬的、而且能整体平移。人物也画两遍(背光色/受光色),
+// 第二遍裁进斜向光带。少女在墙上的投影 = 在光斑里把背光版透出来(剪影平移后 ∩ 光斑)。
+// 母题动画:光斑缓慢右→左移动(光边扫过少女的脸)、窗外理发店旋转柱、卷帘拉绳轻摆、光里浮尘、热气。
+SCENES['24_hopper'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, ease } = U, P = PAINT, TAU = Math.PI * 2;
+ const FLOOR = 730;
+ const SH = { wall: '#5d8679', dado: '#4b6d63', floor: '#5b3d2b', board: '#4a3122', trim: '#a7b3a5', trimD: '#7f8d80', blind: '#cfc3a0' };
+ const LT = { wall: '#efcf8f', dado: '#d8ad68', floor: '#c98b52', board: '#b0743e', trim: '#f7eed2', trimD: '#d9c9a2', blind: '#f4e8c4' };
+ const poly = (c, pts) => { c.beginPath(); pts.forEach((q, i) => i ? c.lineTo(q[0], q[1]) : c.moveTo(q[0], q[1])); c.closePath(); };
+
+ // 窗外:对街的红砖立面(《星期天的清晨》),阳光从左来,每个窗洞右侧有硬投影
+ function street(g) {
+ g.save(); g.beginPath(); g.rect(370, 140, 420, 400); g.clip();
+ const sk = g.createLinearGradient(0, 140, 0, 220); sk.addColorStop(0, '#5f97c9'); sk.addColorStop(1, '#a9c8dc'); g.fillStyle = sk; g.fillRect(370, 140, 420, 80);
+ g.fillStyle = '#b4553a'; g.fillRect(370, 205, 420, 335); // 砖立面
+ g.fillStyle = '#d27a52'; g.fillRect(370, 196, 420, 14); g.fillStyle = '#5a2418'; g.fillRect(370, 210, 420, 10); // 檐口+檐下硬影
+ for (let row = 0; row < 2; row++) for (let k = 0; k < 4; k++) {
+ const x = 392 + k * 102, y = 240 + row * 92;
+ g.fillStyle = '#e8dcc0'; g.fillRect(x - 6, y - 6, 58, 76); // 窗套
+ g.fillStyle = '#1f2a24'; g.fillRect(x, y, 46, 64);
+ const sh = [0.55, 0.3, 0.7, 0.42, 0.25, 0.6, 0.5, 0.35][row * 4 + k]; // 半拉的深绿卷帘,高低不一
+ g.fillStyle = '#3d6a4e'; g.fillRect(x, y, 46, 64 * sh);
+ g.fillStyle = 'rgba(40,10,5,.55)'; g.fillRect(x + 46, y - 6, 10, 76); // 窗洞右侧硬影
+ }
+ g.fillStyle = '#2d5a44'; g.fillRect(370, 432, 420, 108); // 店面
+ g.fillStyle = '#c9d6c8'; [[386, 448, 150], [560, 448, 150]].forEach(([x, y, w]) => { g.fillRect(x, y, w, 70); });
+ g.fillStyle = 'rgba(30,50,40,.75)'; [[386, 448, 150], [560, 448, 150]].forEach(([x, y, w]) => { g.fillRect(x, y + 30, w, 40); });
+ g.fillStyle = '#e9e0c8'; g.fillRect(370, 424, 420, 10);
+ g.fillStyle = '#d8c9a8'; g.fillRect(370, 526, 420, 14); // 人行道
+ g.restore();
+ }
+ function room(g, K) {
+ g.fillStyle = K.wall; g.fillRect(0, 0, W, FLOOR);
+ g.fillStyle = K.dado; g.fillRect(0, 640, W, FLOOR - 640); g.fillStyle = K.trim; g.fillRect(0, 636, W, 8); g.fillRect(0, FLOOR - 14, W, 14);
+ g.fillStyle = K.floor; g.fillRect(0, FLOOR, W, H - FLOOR);
+ g.strokeStyle = K.board; g.lineWidth = 3; for (let k = 1; k < 8; k++) { const y = FLOOR + Math.pow(k / 8, 1.5) * (H - FLOOR); g.beginPath(); g.moveTo(0, y); g.lineTo(W, y); g.stroke(); }
+ street(g);
+ // 窗套(白漆)+窗台+中梃
+ g.fillStyle = K.trim; g.fillRect(346, 116, 468, 24); g.fillRect(346, 116, 24, 446); g.fillRect(790, 116, 24, 446); g.fillRect(330, 540, 500, 26);
+ g.fillStyle = K.trimD; g.fillRect(330, 566, 500, 10); g.fillRect(370, 330, 420, 10); g.fillRect(575, 140, 10, 400);
+ // 卷帘(拉下来一截)
+ g.fillStyle = K.blind; g.fillRect(366, 140, 428, 92); g.fillStyle = K.trimD; g.fillRect(366, 228, 428, 6);
+ // 墙上一幅小画框(霍珀房间里常有的空白小画)
+ g.fillStyle = K.trimD; g.fillRect(1560, 300, 160, 120); g.fillStyle = K.dado; g.fillRect(1572, 312, 136, 96);
+ }
+ const bgShade = () => P.cached('hop_sh', W, H, g => room(g, SH));
+ const bgLit = () => P.cached('hop_lt', W, H, g => room(g, LT));
+ // 油画刷痕:竖向拉长的 fbm 为主、斜向为辅,soft-light 叠 α0.2
+ const brush = () => P.cached('hop_brush', W, H, (g) => {
+ const s = 4, w = W / s, h = H / s, sm = P.canvas(w, h), sg = sm.getContext('2d'), im = sg.createImageData(w, h), d = im.data;
+ for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) { const n = P.fbm(x * 0.06, y * 0.006, 4) * 0.7 + P.fbm(x * 0.02 + y * 0.02, 3.3, 3) * 0.3, v = 128 + n * 110, i = (y * w + x) * 4; d[i] = d[i + 1] = d[i + 2] = v; d[i + 3] = 255; }
+ sg.putImageData(im, 0, 0); g.imageSmoothingQuality = 'high'; g.drawImage(sm, 0, 0, W, H);
+ });
+
+ // ---------- 家具与角色:同一个函数,传背光/受光两套色 ----------
+ const TS = { wood: '#4f3322', woodD: '#3a2418', skin: '#c89a84', skinD: '#a87866', hair: '#a8893f', hairD: '#7f6428', dress: '#7a2c2a', dressD: '#5e1f1e', collar: '#b9b09c',
+ orange: '#a6602c', orangeD: '#80461c', white: '#dcd6c8', stripe: '#6e3a18', cup: '#bfb8a8', eye: '#6a8a3a', band: '#3a5a8a' };
+ const TL = { wood: '#a86c3c', woodD: '#7a4a26', skin: '#f7d3b4', skinD: '#e0ad8c', hair: '#f3d67e', hairD: '#c9a24a', dress: '#cc4a3c', dressD: '#9e3328', collar: '#f6efdc',
+ orange: '#f0a04a', orangeD: '#c8722a', white: '#fbf5e6', stripe: '#c0642a', cup: '#fbf8f0', eye: '#a8d050', band: '#4a78c0' };
+ function furniture(c, K) {
+ c.fillStyle = K.wood; c.fillRect(810, 618, 400, 26); c.fillStyle = K.woodD; c.fillRect(826, 644, 368, 22);
+ c.fillStyle = K.wood; c.fillRect(840, 644, 20, 261); c.fillRect(1160, 644, 20, 261);
+ c.fillStyle = K.woodD; c.fillRect(1436, 470, 18, 440); c.fillRect(1474, 478, 18, 430); c.fillStyle = K.wood; c.fillRect(1290, 744, 210, 18); c.fillRect(1300, 760, 16, 150);
+ }
+ function cat(c, K, KK) {
+ c.save(); c.lineCap = 'round';
+ c.strokeStyle = K.orange; c.lineWidth = KK.tailW; c.stroke(KK.tail);
+ const tip = KK.tailPts[KK.tailPts.length - 1]; c.fillStyle = K.white; c.beginPath(); c.arc(tip[0], tip[1], KK.tailW / 2, 0, TAU); c.fill();
+ c.fillStyle = K.orange; c.fill(KK.body);
+ c.save(); c.clip(KK.body); c.fillStyle = K.orangeD; c.beginPath(); c.ellipse(450, 830, 70, 120, 0.1, 0, TAU); c.fill(); c.restore(); // 背侧暗面(块面)
+ KK.legs.forEach(l => { c.fillStyle = K.white; c.fill(l); });
+ c.save(); c.clip(KK.body); c.fillStyle = K.white; c.beginPath(); c.ellipse(606, 768, 40, 92, -0.05, 0, TAU); c.fill(); c.restore(); // 白胸:平滑椭圆(RIG 的 white 是直线多边形,不描线时像贴片)
+ c.fillStyle = K.orange; c.fill(KK.head);
+ c.save(); c.clip(KK.head); c.fillStyle = K.white; c.beginPath(); c.ellipse(KK.nose[0] - 22, KK.nose[1] + 12, 36, 26, 0, 0, TAU); c.fill(); c.restore();
+ c.strokeStyle = K.stripe; c.lineWidth = 7; KK.stripes.forEach(s => { c.beginPath(); c.moveTo(...s[0]); c.lineTo(...s[1]); c.stroke(); });
+ KK.eyes.forEach(e => { if (KK.blink) { c.strokeStyle = '#2a1a0e'; c.lineWidth = 3; c.beginPath(); c.moveTo(e.x - 8, e.y + 1); c.lineTo(e.x + 8, e.y + 1); c.stroke(); }
+ else { c.fillStyle = K.eye; c.beginPath(); c.arc(e.x, e.y, 8, 0, TAU); c.fill(); c.fillStyle = '#1a120a'; c.beginPath(); c.ellipse(e.x + 2, e.y, 2.4, 6.5, 0, 0, TAU); c.fill(); } });
+ c.fillStyle = '#b8605a'; c.beginPath(); c.arc(KK.nose[0], KK.nose[1], 5, 0, TAU); c.fill();
+ c.strokeStyle = '#3a2416'; c.lineWidth = 2; c.beginPath(); c.moveTo(...KK.mouth[0]); c.quadraticCurveTo(...KK.mouth[1], ...KK.mouth[2]); c.stroke();
+ c.restore();
+ }
+ function girl(c, K, G, ch) {
+ c.save(); c.lineCap = 'round'; c.lineJoin = 'round';
+ const f = (p, col) => { if (p) { c.fillStyle = col; c.fill(p); } };
+ f(G.farSleeve, K.dressD); f(G.farHand, K.skinD); f(G.farCuff, K.collar);
+ f(G.skirt, K.dress);
+ c.save(); c.clip(G.skirt); c.fillStyle = K.dressD; c.beginPath(); c.moveTo(1330, 640); c.lineTo(1460, 640); c.lineTo(1460, 940); c.lineTo(1300, 940); c.lineTo(1352, 780); c.closePath(); c.fill(); c.restore(); // 膝后暗块
+ c.strokeStyle = K.dressD; c.lineWidth = 4; G.folds.forEach(p => c.stroke(p));
+ f(G.shoe, '#2a1810');
+ f(G.torso, K.dress);
+ c.save(); c.clip(G.torso); c.fillStyle = K.dressD; c.fillRect(1375, 420, 80, 220); c.restore();
+ const nk = G.A.neck; c.fillStyle = K.collar; c.beginPath(); c.moveTo(nk[0] - 20, nk[1] - 2); c.lineTo(nk[0] + 24, nk[1]); c.lineTo(nk[0] + 6, nk[1] + 30); c.closePath(); c.fill(); // 白领尖
+ f(G.hairDown, K.hair); f(G.neck, K.skinD); f(G.hairBack, K.hair);
+ c.save(); c.clip(G.hairBack); c.fillStyle = K.hairD; c.beginPath(); c.ellipse(G.A.nape[0] + 20, G.A.nape[1] - 10, 50, 40, 0, 0, TAU); c.fill(); c.restore();
+ f(G.face, K.skin);
+ c.save(); c.clip(G.face); c.fillStyle = K.skinD; c.beginPath(); c.ellipse(G.A.ear[0] + 6, G.A.ear[1] + 10, 26, 46, 0, 0, TAU); c.fill(); c.restore(); // 颊后暗面
+ f(G.bangs, K.hair);
+ { const a = G.A.headTop, nk = G.A.nape; c.strokeStyle = K.band; c.lineWidth = 9; c.beginPath(); c.moveTo(a[0] - 52, a[1] + 26); c.quadraticCurveTo(a[0] + 10, a[1] - 6, nk[0] + 30, nk[1] - 62); c.stroke(); } // 发带(少女感)
+ c.strokeStyle = K.hairD; c.lineWidth = 3; G.hairLines.forEach(p => c.stroke(p));
+ if (ch.blink) { c.strokeStyle = '#3a2418'; c.lineWidth = 2.6; c.stroke(G.lid); }
+ else { c.fillStyle = '#2e2018'; c.beginPath(); c.ellipse(G.eye.x - 1, G.eye.y + 1, 3.6, 4.6, 0, 0, TAU); c.fill(); c.strokeStyle = '#3a2418'; c.lineWidth = 2.4; c.stroke(G.lid); }
+ c.strokeStyle = K.hairD; c.lineWidth = 2.4; c.stroke(G.brow);
+ c.fillStyle = '#a83a36'; c.beginPath(); c.moveTo(...G.lips[0]); c.lineTo(...G.lips[1]); c.lineTo(...G.lips[2]); c.closePath(); c.fill();
+ f(G.upperArm, K.dress); f(G.foreArm, K.dress); f(G.cuff, K.collar); f(G.hand, K.skin);
+ RIG.drawCup(c, G.cup, { body: K.cup, rim: '#5a3a22', hw: 6 });
+ c.fillStyle = K.skin; c.beginPath(); c.arc(G.thumb[0], G.thumb[1], 7, 0, TAU); c.fill();
+ c.restore();
+ }
+
+ return {
+ draw(c, lt, t) {
+ const ch = P.choreo(lt, t);
+ const dx = 30 - 95 * ease.inOut(clamp(lt / 1.25)); // 光斑 1.2s 里向左移 ~95px(太阳在走)
+ const KK = RIG.cat({ tail: ch.tail * 0.6, blink: ch.blink, breathe: ch.breathe });
+ const G = RIG.girl({ cup: ch.cup, sip: ch.sip, breathe: ch.breathe, hair: 'long' });
+ // ① 背光底版 → 墙/地光斑里透出受光底版
+ c.drawImage(bgShade(), 0, 0);
+ const WP = [[1420 + dx, 250], [1920, 470], [1920, FLOOR], [1420 + dx, FLOOR]];
+ const FP = [[1420 + dx, FLOOR], [1920, FLOOR], [1920, H], [1700 + dx, H]];
+ P.litClip(c, [WP, FP], c => { c.drawImage(bgLit(), 0, 0);
+ // 光斑里的窗棂影(竖+斜横)与少女投在墙上的影:都把背光版透出来
+ const S = P.scratch('hopSh'), sg = S.getContext('2d'); sg.reset(); sg.clearRect(0, 0, W, H); sg.fillStyle = '#000';
+ sg.fillRect(1650 + dx, 200, 24, FLOOR - 200); poly(sg, [[1650 + dx, FLOOR], [1674 + dx, FLOOR], [1820 + dx, H], [1796 + dx, H]]); sg.fill();
+ poly(sg, [[1420 + dx, 470], [1920, 680], [1920, 702], [1420 + dx, 492]]); sg.fill();
+ sg.save(); sg.translate(150, 18); [G.torso, G.hairBack, G.bun, G.face, G.bangs, G.upperArm, G.foreArm, G.hand, G.skirt].forEach(p => p && sg.fill(p)); sg.restore();
+ sg.globalCompositeOperation = 'source-in'; sg.drawImage(bgShade(), 0, 0); sg.globalCompositeOperation = 'source-over';
+ c.drawImage(S, 0, 0); });
+ // ② 窗外理发店旋转柱(红白蓝斜纹上行)
+ c.save(); const bx = 742, by = 446, bw = 18, bh = 64; c.beginPath(); c.rect(bx, by, bw, bh); c.clip(); c.fillStyle = '#f4efe2'; c.fillRect(bx, by, bw, bh);
+ const off = (lt * 60) % 24; c.lineWidth = 6; for (let k = -4; k < 6; k++) { const y = by + k * 24 - off; c.strokeStyle = k % 2 ? '#c8302a' : '#2a4a9a'; c.beginPath(); c.moveTo(bx - 4, y + 14); c.lineTo(bx + bw + 4, y); c.stroke(); }
+ c.restore(); c.fillStyle = '#d9d2bf'; c.fillRect(bx - 3, by - 8, bw + 6, 8); c.fillRect(bx - 3, by + bh, bw + 6, 8);
+ // 卷帘拉绳轻摆
+ const sw = Math.sin(lt * 4.2) * 0.07; c.save(); c.translate(580, 232); c.rotate(sw); c.strokeStyle = '#7a6a4a'; c.lineWidth = 2; c.beginPath(); c.moveTo(0, 0); c.lineTo(0, 70); c.stroke();
+ c.strokeStyle = '#c9b88a'; c.lineWidth = 4; c.beginPath(); c.arc(0, 78, 8, 0, TAU); c.stroke(); c.restore();
+ // ③ 家具与角色:先背光色,再裁进斜光带画受光色
+ furniture(c, TS); cat(c, TS, KK); girl(c, TS, G, ch);
+ const OP = [[1345 + dx, 0], [W, 0], [W, H], [1185 + dx, H]];
+ P.litClip(c, [OP], c => { furniture(c, TL); girl(c, TL, G, ch); });
+ // 光带里的浮尘
+ c.save(); c.globalCompositeOperation = 'lighter'; P.particles(26, 42, t, { x0: 1250, x1: 1900, y0: 760, y1: 120, speed: 40, drift: 18, life: 9 }).forEach(p => {
+ const ex = 1345 + dx - (p.y / H) * 160; if (p.x < ex) return; c.fillStyle = `rgba(255,235,180,${0.35 + 0.3 * Math.sin(t * 6 + p.i)})`; c.beginPath(); c.arc(p.x, p.y, 2.2 * p.s, 0, TAU); c.fill(); });
+ c.restore();
+ P.steam(c, t, G.cup.x, G.cup.y - 8, { h: 55, n: 2, color: 'rgba(255,248,230,.5)', width: 3, spread: 12, wobble: 6 });
+ // 画布刷痕
+ c.save(); c.globalCompositeOperation = 'soft-light'; c.globalAlpha = 0.2; c.drawImage(brush(), 0, 0); c.restore();
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/25_ghibli.js b/scripts/engine/scenes/25_ghibli.js
new file mode 100644
index 0000000..bc9255f
--- /dev/null
+++ b/scripts/engine/scenes/25_ghibli.js
@@ -0,0 +1,251 @@
+// 1988 吉卜力式手绘水彩背景美术(宫崎骏/男鹿和雄的夏日房间)——纯代码。
+// 管线:①缓存底版:纸 → 水彩洗染 wash(中点位移变形的多边形 × 多层低 α multiply 叠色 + 每层描一圈淡边 = 水痕边)
+// → 窗外蓝天、积雨云(白色不透明+底部蓝灰透明叠色)、远山、草坡、大樟树;室内灰泥墙、木地板、扫帚、小架子
+// → ②会动的母题(白纱窗帘被风鼓起、窗外草叶成片摆、云慢慢飘、树冠轻摇、墙上树影光斑闪、桌上雏菊点头、发丝与红蝴蝶结飘)
+// → ③角色:赛璐璐两色(基色+「路径减去朝光平移的自身」得到的月牙阴影)+暖褐细线
+SCENES['25_ghibli'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, ease, rng } = U, P = PAINT, TAU = Math.PI * 2;
+ const FLOOR = 720, WIN = [370, 140, 420, 400];
+ const LINE = '#6a4a38';
+
+ // 水彩:P.watercolor(中点位移多边形 × 多层低 α multiply + 水痕边)、P.deform、P.rectPts / P.ellipsePts
+ const deform = P.deform, wash = P.watercolor, rect = P.rectPts, ellipsePts = P.ellipsePts;
+ const fillPts = (g, pts) => { g.beginPath(); pts.forEach((q, i) => i ? g.lineTo(q[0], q[1]) : g.moveTo(q[0], q[1])); g.closePath(); };
+
+ // ---------- 云(缓存精灵):白色不透明块 + 底部蓝灰透明叠 ----------
+ const cloud = (key, w, h, seed) => P.cached('gh_cloud_' + key, w, h, (g) => {
+ const r = rng(seed), puffs = [];
+ for (let i = 0; i < 16; i++) { const x = w * (0.15 + r() * 0.7), base = h * 0.78, yy = base - Math.sin((x / w) * Math.PI) * h * (0.35 + r() * 0.3); puffs.push([x, yy, 30 + r() * 46]); }
+ puffs.push([w * 0.5, h * 0.72, w * 0.36]);
+ puffs.forEach(([x, y, rr], i) => wash(g, ellipsePts(x, y, rr, rr * 0.82, 14), '#ffffff', { layers: 3, alpha: 0.9, amp: 6, seed: seed + i, edge: 0, blend: 'source-over' }));
+ g.save(); g.globalCompositeOperation = 'source-atop';
+ const sh = g.createLinearGradient(0, h * 0.35, 0, h); sh.addColorStop(0, 'rgba(150,175,205,0)'); sh.addColorStop(1, 'rgba(120,145,190,.75)'); g.fillStyle = sh; g.fillRect(0, 0, w, h);
+ g.restore();
+ });
+ // 大樟树(缓存精灵,轻摇时绕树根转)
+ const tree = () => P.cached('gh_tree', 300, 360, (g) => {
+ g.fillStyle = '#4a3a2a'; g.fillRect(140, 210, 22, 150);
+ const r = rng(77);
+ for (let i = 0; i < 22; i++) { const x = 150 + (r() - .5) * 220, y = 150 + (r() - .5) * 170, rr = 34 + r() * 40;
+ wash(g, ellipsePts(x, y, rr, rr * 0.8, 12), i % 3 ? '#3f7a3a' : '#2a5a32', { layers: 3, alpha: 0.6, amp: 10, seed: i + 5, edge: 0.15, blend: 'source-over' }); }
+ for (let i = 0; i < 14; i++) { const x = 120 + (r() - .5) * 180, y = 110 + (r() - .5) * 120, rr = 18 + r() * 22;
+ wash(g, ellipsePts(x, y, rr, rr * 0.7, 10), '#8cc65a', { layers: 2, alpha: 0.45, amp: 6, seed: i + 50, edge: 0, blend: 'source-over' }); }
+ });
+
+ // ---------- ① 底版 ----------
+ const bg = () => P.cached('gh_bg', W, H, (g) => {
+ g.drawImage(P.texture('gh_paper', '#fbf6ea', { scale: 0.02, amt: 6, grain: 10, seed: 3 }), 0, 0);
+ // 室内:暖灰泥墙——窗边亮、角落暗的渐变洗染 → 再叠 28 块大幅变形的透明色晕(暖黄/粉/蓝灰交替 = 透明叠色)
+ const wl = g.createRadialGradient(580, 340, 100, 700, 420, 1500); wl.addColorStop(0, '#fbf3e0'); wl.addColorStop(0.6, '#f1e1bf'); wl.addColorStop(1, '#dcc49a');
+ wash(g, rect(-20, -20, W + 40, FLOOR + 30), '#efdcb4', { layers: 5, alpha: 0.4, amp: 12, seed: 2, edge: 0, fill: wl });
+ { const r = rng(404), tints = ['#f2c48a', '#e9b4a2', '#b9c9d8', '#f3dca0', '#d6ae80', '#c8d4b0'];
+ for (let i = 0; i < 28; i++) { const x = r() * W, y = r() * 600, rx = 90 + r() * 220, ry = 60 + r() * 160;
+ if (x > 340 && x < 820 && y > 110 && y < 560) continue;
+ wash(g, ellipsePts(x, y, rx, ry, 10), tints[i % tints.length], { layers: 3, alpha: 0.045, amp: 40, seed: 100 + i, edge: 0.04 }); } }
+ wash(g, [[1700, -20], [1940, -20], [1940, 740], [1620, 740], [1680, 400]], '#b89a6c', { layers: 4, alpha: 0.06, amp: 60, seed: 3, edge: 0.03 }); // 右角落暗
+ wash(g, [[-20, -20], [200, -20], [140, 400], [220, 740], [-20, 740]], '#b89a6c', { layers: 4, alpha: 0.06, amp: 60, seed: 4, edge: 0.03 });
+ // 木护墙板(腰线以下竖板,逐块不同色调)
+ { const r = rng(505); for (let x = -10; x < W; x += 64) wash(g, rect(x, 588, 62, FLOOR - 588), ['#c08a56', '#b47e4c', '#c99460', '#ad7848'][(r() * 4) | 0], { layers: 3, alpha: 0.32, amp: 3, seed: 200 + x, edge: 0.12 }); }
+ wash(g, rect(-20, 576, W + 40, 16), '#8a5a34', { layers: 3, alpha: 0.4, amp: 2, seed: 7, edge: 0.15 });
+ // 地板:逐条木板洗染
+ { const r = rng(606); let y = FLOOR; for (let k = 0; k < 8; k++) { const h = 26 + k * 12; wash(g, rect(-20, y, W + 40, h), ['#a86e3a', '#9a6232', '#b07a44', '#a06836'][(r() * 4) | 0], { layers: 3, alpha: 0.5, amp: 3, seed: 300 + k, edge: 0.14 }); y += h; } }
+ // 窗投到地上的暖光斑(软边、带窗棂十字影)
+ g.save(); g.globalCompositeOperation = 'screen'; g.filter = 'blur(10px)'; g.fillStyle = 'rgba(255,236,180,.55)';
+ g.beginPath(); g.moveTo(400, 740); g.lineTo(800, 740); g.lineTo(930, 1040); g.lineTo(450, 1040); g.closePath(); g.fill(); g.restore();
+ g.save(); g.globalCompositeOperation = 'multiply'; g.filter = 'blur(6px)'; g.fillStyle = 'rgba(190,150,110,.5)';
+ g.beginPath(); g.moveTo(596, 740); g.lineTo(606, 740); g.lineTo(700, 1040); g.lineTo(684, 1040); g.closePath(); g.fill(); g.fillRect(420, 880, 470, 10); g.restore();
+ wash(g, rect(-20, FLOOR - 26, W + 40, 26), '#9a6a40', { layers: 4, alpha: 0.25, amp: 4, seed: 6, edge: 0.1 }); // 踢脚板
+ // 窗外:蓝天(渐变洗染)
+ g.save(); g.beginPath(); g.rect(...WIN); g.clip();
+ const sky = g.createLinearGradient(0, 140, 0, 440); sky.addColorStop(0, '#3a86d4'); sky.addColorStop(1, '#bfe2f4');
+ wash(g, rect(360, 130, 440, 330), '#5a9ad8', { layers: 5, alpha: 0.5, amp: 6, seed: 7, edge: 0, blend: 'source-over', fill: sky });
+ // 远山(蓝绿)
+ wash(g, [[360, 430], [420, 400], [500, 410], [560, 385], [640, 402], [720, 380], [800, 400], [800, 470], [360, 470]], '#7aa6a0', { layers: 5, alpha: 0.35, amp: 6, seed: 8, edge: 0.12 });
+ // 草坡(亮绿 → 深绿)
+ const gr = g.createLinearGradient(0, 430, 0, 540); gr.addColorStop(0, '#9ccc5a'); gr.addColorStop(1, '#4c8a3a');
+ wash(g, [[360, 450], [480, 432], [620, 446], [800, 428], [800, 560], [360, 560]], '#6aa848', { layers: 6, alpha: 0.5, amp: 6, seed: 9, edge: 0.1, blend: 'source-over', fill: gr });
+ g.restore();
+ // 窗框(白漆木,蓝绿阴影)+窗台
+ const frame = [[346, 116, 468, 24], [346, 116, 24, 446], [790, 116, 24, 446], [575, 140, 10, 400], [370, 330, 420, 9]];
+ frame.forEach(([x, y, w, h], i) => wash(g, rect(x, y, w, h), '#f6f1e2', { layers: 3, alpha: 0.95, amp: 2, seed: 20 + i, edge: 0.2, blend: 'source-over' }));
+ frame.forEach(([x, y, w, h], i) => wash(g, rect(x + w * 0.55, y, w * 0.45, h), '#9fb8c0', { layers: 2, alpha: 0.25, amp: 2, seed: 30 + i, edge: 0 }));
+ wash(g, rect(326, 540, 508, 28), '#f3ecd8', { layers: 3, alpha: 0.95, amp: 2, seed: 40, edge: 0.2, blend: 'source-over' });
+ wash(g, rect(326, 556, 508, 12), '#a8b7b8', { layers: 2, alpha: 0.35, amp: 2, seed: 41, edge: 0 });
+ // 窗帘杆
+ g.strokeStyle = '#6a4a30'; g.lineWidth = 7; g.lineCap = 'round'; g.beginPath(); g.moveTo(300, 98); g.lineTo(860, 98); g.stroke();
+ // 墙上小木架+瓶罐、挂着的干花束
+ wash(g, rect(1540, 300, 260, 14), '#8a5a34', { layers: 3, alpha: 0.6, amp: 2, seed: 50, edge: 0.15 });
+ [[1560, 240, 34, 60, '#6a9ac0'], [1610, 262, 40, 38, '#d8a050'], [1670, 236, 28, 64, '#9ab86a'], [1720, 254, 46, 46, '#c86a50']].forEach(([x, y, w, h, col], i) => wash(g, rect(x, y, w, h), col, { layers: 4, alpha: 0.3, amp: 4, seed: 60 + i, edge: 0.15 }));
+ // 靠墙的扫帚(致敬魔女宅急便)
+ g.save(); g.translate(1760, 330); g.rotate(0.12);
+ wash(g, rect(-7, 0, 14, 470), '#7a5030', { layers: 3, alpha: 0.5, amp: 2, seed: 70, edge: 0.2 });
+ wash(g, [[-10, 460], [10, 460], [46, 620], [-46, 620]], '#c89a4a', { layers: 4, alpha: 0.45, amp: 5, seed: 71, edge: 0.2 });
+ g.strokeStyle = 'rgba(120,80,30,.6)'; g.lineWidth = 1.5; for (let k = -5; k <= 5; k++) { g.beginPath(); g.moveTo(k * 2, 470); g.lineTo(k * 8.5, 616); g.stroke(); }
+ g.fillStyle = '#c84a3a'; g.fillRect(-12, 452, 24, 10); g.restore();
+ // 桌(木)+白桌布,椅子
+ wash(g, rect(842, 640, 22, 265), '#8a5a34', { layers: 3, alpha: 0.6, amp: 3, seed: 80, edge: 0.15 });
+ wash(g, rect(1160, 640, 22, 265), '#8a5a34', { layers: 3, alpha: 0.6, amp: 3, seed: 81, edge: 0.15 });
+ wash(g, rect(1436, 470, 18, 440), '#7a4c2a', { layers: 3, alpha: 0.6, amp: 3, seed: 82, edge: 0.15 });
+ wash(g, rect(1474, 478, 18, 430), '#7a4c2a', { layers: 3, alpha: 0.6, amp: 3, seed: 83, edge: 0.15 });
+ wash(g, rect(1290, 744, 210, 16), '#8a5a34', { layers: 3, alpha: 0.6, amp: 3, seed: 84, edge: 0.15 });
+ // 整体:纸纹颗粒(颜料在纸凹处沉积)
+ g.save(); g.globalCompositeOperation = 'multiply'; g.globalAlpha = 0.3; g.drawImage(P.texture('gh_gran', '#f4efe2', { scale: 0.06, amt: 18, grain: 26, seed: 9 }), 0, 0); g.restore();
+ });
+ // 桌布(垂边随风轻摆,每帧画)
+ function tablecloth(c, lt) {
+ const sw = Math.sin(lt * 5) * 5;
+ const pts = [[800, 612], [1214, 612], [1222, 700 + sw], [1150, 712 - sw], [1060, 704 + sw], [980, 714 - sw], [890, 704 + sw], [804, 712 - sw]];
+ wash(c, pts, '#fffdf6', { layers: 2, alpha: 0.95, amp: 3, seed: 90, edge: 0.25, blend: 'source-over' });
+ wash(c, pts.map(([x, y]) => [x, y + (y > 640 ? 0 : 30)]), '#b8c8d8', { layers: 2, alpha: 0.18, amp: 3, seed: 91, edge: 0 });
+ }
+
+ // ---------- ② 窗帘:白纱两幅,下摆被风往屋里鼓 ----------
+ function curtain(c, side, lt) {
+ const x0 = side < 0 ? 300 : 860, inner = side < 0 ? 420 : 740;
+ const gust = 0.5 + 0.5 * Math.sin(lt * 5.4 + (side < 0 ? 0 : 1.3));
+ const pts = [], N = 14;
+ for (let i = 0; i <= N; i++) { const q = i / N, y = 100 + q * 500, bulge = q * q * (60 + 150 * gust), w = Math.sin(lt * 9 + q * 6 + side) * 16 * q;
+ pts.push([inner + side * 0 - side * (bulge * 0.15) + w + (side < 0 ? 1 : -1) * bulge * 0.9, y]); }
+ for (let i = N; i >= 0; i--) { const q = i / N, y = 100 + q * 500 + (i === N ? 0 : 0); pts.push([x0 + (side < 0 ? -1 : 1) * q * 30 * gust, y + Math.sin(lt * 6 + q * 4) * 4]); }
+ c.save(); c.globalAlpha = 0.85;
+ wash(c, pts, '#ffffff', { layers: 3, alpha: 0.42, amp: 4, seed: side < 0 ? 101 : 102, edge: 0, blend: 'source-over' });
+ c.restore();
+ // 褶线(蓝灰透明,跟随鼓起)
+ c.save(); c.globalCompositeOperation = 'multiply'; c.strokeStyle = 'rgba(150,175,200,.45)'; c.lineWidth = 3; c.lineCap = 'round';
+ for (let k = 1; k < 4; k++) { const f = k / 4; c.beginPath(); for (let i = 0; i <= 10; i++) { const q = i / 10; const a = pts[Math.round(q * N)], b = pts[2 * N + 1 - Math.round(q * N)]; const x = lerp(b[0], a[0], f), y = lerp(b[1], a[1], f); i ? c.lineTo(x, y) : c.moveTo(x, y); } c.stroke(); }
+ c.restore();
+ }
+ // 窗外草叶:成片同向摆(风是一阵一阵的)
+ function grass(c, t) {
+ c.save(); c.beginPath(); c.rect(...WIN); c.clip(); c.lineCap = 'round';
+ const r = rng(5), cols = ['#5c9a3e', '#7fb84a', '#3f7a32', '#9ccc5a', '#4a8a3a'];
+ for (let i = 0; i < 360; i++) {
+ const x = 360 + r() * 440, y = 470 + r() * 75, h = 16 + r() * 26 + (y - 470) * 0.35, ph = r() * TAU;
+ const wind = Math.sin(t * 3.1 - x * 0.018) * 0.5 + 0.5, sway = (0.25 + wind * 0.75) * h * 0.55 + Math.sin(t * 9 + ph) * 2;
+ c.strokeStyle = cols[i % 5]; c.lineWidth = 2 + r() * 2;
+ c.beginPath(); c.moveTo(x, y); c.quadraticCurveTo(x + sway * 0.3, y - h * 0.6, x + sway, y - h); c.stroke();
+ }
+ c.restore();
+ }
+ // 墙上的树影光斑(komorebi):暖黄亮斑用 screen 叠,位置随噪声慢漂、亮度闪
+ function komorebi(c, t) {
+ c.save(); c.globalCompositeOperation = 'screen';
+ const r = rng(33);
+ for (let i = 0; i < 34; i++) {
+ const bx = 830 + r() * 380, by = 160 + r() * 420, rr = 10 + r() * 26;
+ const x = bx + P.noise(i * 1.3, t * 0.9) * 26, y = by + P.noise(i * 2.1 + 5, t * 0.9) * 18, a = 0.18 + 0.22 * (0.5 + 0.5 * Math.sin(t * 5 + i * 1.7));
+ const gg = c.createRadialGradient(x, y, 0, x, y, rr); gg.addColorStop(0, `rgba(255,236,170,${a})`); gg.addColorStop(1, 'rgba(255,236,170,0)'); c.fillStyle = gg; c.beginPath(); c.ellipse(x, y, rr * 1.3, rr, 0.4, 0, TAU); c.fill();
+ }
+ c.restore();
+ }
+ // 桌上雏菊(玻璃瓶),花头点头
+ function daisies(c, t) {
+ const vx = 900, vy = 612;
+ c.save(); c.fillStyle = 'rgba(190,220,230,.55)'; c.beginPath(); c.moveTo(vx - 16, vy); c.quadraticCurveTo(vx - 22, vy - 30, vx - 10, vy - 46); c.lineTo(vx + 10, vy - 46); c.quadraticCurveTo(vx + 22, vy - 30, vx + 16, vy); c.closePath(); c.fill();
+ c.strokeStyle = 'rgba(90,120,140,.6)'; c.lineWidth = 1.5; c.stroke();
+ [[-30, -120, 0], [6, -140, 1.3], [34, -112, 2.1], [-8, -100, 3.2]].forEach(([dx, dy, ph]) => {
+ const sw = Math.sin(t * 3.2 + ph) * 7, hx = vx + dx + sw, hy = vy + dy + Math.abs(sw) * 0.2;
+ c.strokeStyle = '#5a8a3a'; c.lineWidth = 3; c.beginPath(); c.moveTo(vx + dx * 0.2, vy - 40); c.quadraticCurveTo(vx + dx * 0.6, vy + dy * 0.5, hx, hy); c.stroke();
+ c.fillStyle = '#fffdf4'; for (let k = 0; k < 10; k++) { const a = k / 10 * TAU + ph; c.beginPath(); c.ellipse(hx + Math.cos(a) * 9, hy + Math.sin(a) * 6, 7, 3, a, 0, TAU); c.fill(); }
+ c.fillStyle = '#f2b830'; c.beginPath(); c.arc(hx, hy, 5, 0, TAU); c.fill();
+ });
+ c.restore();
+ }
+
+ // ---------- ③ 赛璐璐角色 ----------
+ // 赛璐珞两色:P.cel——背光侧(光从左上来,阴影带宽 (dx,dy))一道月牙阴影+暖褐细线
+ const cel = (c, p, base, shade, dx = 9, dy = 6, line = true) => P.cel(c, p, base, shade, null, { sd: 1, lx: -dx, ly: -dy, line: LINE, lw: line ? 2.4 : 0 });
+ const GP = { skin: '#fde6d2', skinS: '#efbfa4', hair: '#f8dc8c', hairS: '#d9a95a', dress: '#3f8590', dressS: '#2b6470', white: '#fffaf0', whiteS: '#d8dde4', bow: '#d93a30', bowS: '#a0261f' };
+ function girl(c, G, ch, lt, t) {
+ c.save(); c.lineJoin = 'round'; c.lineCap = 'round';
+ cel(c, G.farSleeve, GP.dress, GP.dressS); cel(c, G.farCuff, GP.white, GP.whiteS); cel(c, G.farHand, GP.skin, GP.skinS, 4, 3);
+ // 长发(被风吹向右后方)
+ const wind = Math.sin(lt * 3.2) * 0.5 + 0.5;
+ const nape = G.A.nape, hd = G.A.headC;
+ const flow = new Path2D(); const fp = [[hd[0] + 30, hd[1] - 40], [nape[0] + 50 + wind * 14, nape[1] - 30], [nape[0] + 78 + wind * 30, nape[1] + 40 + Math.sin(t * 6) * 6], [nape[0] + 60 + wind * 26, nape[1] + 120 + Math.sin(t * 5 + 1) * 8], [nape[0] + 20, nape[1] + 130], [nape[0] - 6, nape[1] + 40], [hd[0] + 4, hd[1] + 10]];
+ const fpath = RIG.smooth(fp); cel(c, fpath, GP.hair, GP.hairS, 10, 4);
+ cel(c, G.skirt, GP.dress, GP.dressS, 16, 8);
+ c.strokeStyle = GP.dressS; c.lineWidth = 3; G.folds.forEach(f => c.stroke(f));
+ cel(c, G.apronSkirt, GP.white, GP.whiteS, 10, 6);
+ cel(c, G.shoe, '#6a3a24', '#4a2414', 4, 2);
+ cel(c, G.torso, GP.dress, GP.dressS, 14, 6); cel(c, G.bib, GP.white, GP.whiteS, 6, 4);
+ cel(c, G.neck, GP.skin, GP.skinS, 6, 2);
+ cel(c, G.hairBack, GP.hair, GP.hairS, 10, 6);
+ cel(c, G.face, GP.skin, GP.skinS, 10, 4);
+ c.save(); c.clip(G.face); c.fillStyle = 'rgba(240,140,130,.35)'; c.beginPath(); c.ellipse(G.cheek[0], G.cheek[1], 12, 7, 0, 0, TAU); c.fill(); c.restore();
+ cel(c, G.bangs, GP.hair, GP.hairS, 6, 6);
+ c.strokeStyle = GP.hairS; c.lineWidth = 2; G.hairLines.forEach(h => c.stroke(h));
+ // 红蝴蝶结(后脑上方),飘带随风
+ const bc = [G.A.headTop[0] + 46, G.A.headTop[1] + 14];
+ const tails = [[bc[0] + 6, bc[1] + 8], [bc[0] + 40 + wind * 18, bc[1] + 44 + Math.sin(t * 8) * 6], [bc[0] + 26 + wind * 10, bc[1] + 54], [bc[0] + 2, bc[1] + 14]];
+ cel(c, RIG.smooth(tails), GP.bow, GP.bowS, 4, 3);
+ [[-1, -0.5], [1, 0.4]].forEach(([s, rot]) => { const p = new Path2D(); p.ellipse(bc[0] + s * 24, bc[1] - 4, 26, 15, rot, 0, TAU); cel(c, p, GP.bow, GP.bowS, 5, 4); });
+ { const p = new Path2D(); p.arc(bc[0], bc[1], 9, 0, TAU); cel(c, p, GP.bow, GP.bowS, 2, 2); }
+ // 五官(吉卜力式:大而简单的眼)
+ if (ch.blink) { c.strokeStyle = LINE; c.lineWidth = 3; c.beginPath(); c.arc(G.eye.x, G.eye.y - 2, 7, 0.2, Math.PI - 0.2); c.stroke(); }
+ else { c.fillStyle = '#3a2a24'; c.beginPath(); c.ellipse(G.eye.x - 1, G.eye.y + 1, 5, 7.5, 0, 0, TAU); c.fill(); c.fillStyle = '#5a8ac8'; c.beginPath(); c.ellipse(G.eye.x - 1, G.eye.y + 3, 3.5, 4, 0, 0, TAU); c.fill(); c.fillStyle = '#fff'; c.beginPath(); c.arc(G.eye.x - 2.5, G.eye.y - 2, 2, 0, TAU); c.fill();
+ c.strokeStyle = LINE; c.lineWidth = 2.8; c.stroke(G.lid); }
+ c.strokeStyle = '#c08a40'; c.lineWidth = 2.4; c.stroke(G.brow);
+ c.strokeStyle = '#a8443a'; c.lineWidth = 2.2; c.beginPath(); c.moveTo(...G.lips[0]); c.lineTo(G.lips[1][0] - 1, G.lips[1][1] + 2); c.stroke();
+ cel(c, G.upperArm, GP.dress, GP.dressS, 8, 6); cel(c, G.foreArm, GP.dress, GP.dressS, 8, 6); cel(c, G.cuff, GP.white, GP.whiteS, 4, 3);
+ cel(c, G.hand, GP.skin, GP.skinS, 4, 3);
+ RIG.drawCup(c, G.cup, { body: '#fdf8ee', rim: '#7a4a2a', line: LINE, lw: 2.2, hw: 6 });
+ c.save(); c.translate(G.cup.x, G.cup.y); c.rotate(G.cup.tilt); c.strokeStyle = '#5a8ac8'; c.lineWidth = 3; c.beginPath(); c.moveTo(-G.cup.w * 0.45, G.cup.h * 0.35); c.lineTo(G.cup.w * 0.45, G.cup.h * 0.35); c.stroke(); c.restore();
+ c.fillStyle = GP.skin; c.beginPath(); c.arc(G.thumb[0], G.thumb[1], 7, 0, TAU); c.fill(); c.strokeStyle = LINE; c.lineWidth = 2; c.stroke();
+ c.restore();
+ }
+ function cat(c, K) {
+ const O = '#f3a24c', OS = '#d27a2c', Wt = '#fffaf2', WS = '#e2d8ca';
+ c.save(); c.lineJoin = 'round'; c.lineCap = 'round';
+ c.strokeStyle = LINE; c.lineWidth = K.tailW + 5; c.stroke(K.tail); c.strokeStyle = O; c.lineWidth = K.tailW; c.stroke(K.tail);
+ const tip = K.tailPts[K.tailPts.length - 1]; c.fillStyle = Wt; c.beginPath(); c.arc(tip[0], tip[1], K.tailW / 2, 0, TAU); c.fill();
+ cel(c, K.body, O, OS, 18, 10);
+ c.save(); c.clip(K.body); c.strokeStyle = '#c8682a'; c.lineWidth = 8; K.stripes.slice(3).forEach(s => { c.beginPath(); c.moveTo(...s[0]); c.lineTo(...s[1]); c.stroke(); }); c.restore();
+ K.legs.forEach(l => cel(c, l, Wt, WS, 6, 3));
+ c.save(); c.clip(K.body); cel(c, K.white, Wt, WS, 10, 6, false); c.restore();
+ cel(c, K.head, O, OS, 12, 8);
+ c.save(); c.clip(K.head); c.fillStyle = Wt; c.beginPath(); c.ellipse(K.nose[0] - 22, K.nose[1] + 12, 36, 26, 0, 0, TAU); c.fill(); c.restore();
+ c.strokeStyle = LINE; c.lineWidth = 2.4; c.stroke(K.head);
+ c.fillStyle = '#f2a8a0'; K.earInner.forEach(e => { c.beginPath(); e.forEach((p, i) => i ? c.lineTo(...p) : c.moveTo(...p)); c.fill(); });
+ c.strokeStyle = '#c8682a'; c.lineWidth = 6; K.stripes.slice(0, 3).forEach(s => { c.beginPath(); c.moveTo(...s[0]); c.lineTo(...s[1]); c.stroke(); });
+ K.eyes.forEach(e => { if (K.blink) { c.strokeStyle = LINE; c.lineWidth = 3; c.beginPath(); c.arc(e.x, e.y - 2, 8, 0.2, Math.PI - 0.2); c.stroke(); }
+ else { c.fillStyle = '#2a1a12'; c.beginPath(); c.ellipse(e.x, e.y, 6, 8, 0, 0, TAU); c.fill(); c.fillStyle = '#fff'; c.beginPath(); c.arc(e.x - 2, e.y - 3, 2.4, 0, TAU); c.fill(); } });
+ c.fillStyle = '#d8746a'; c.beginPath(); c.arc(K.nose[0], K.nose[1], 5, 0, TAU); c.fill();
+ c.strokeStyle = LINE; c.lineWidth = 2; c.beginPath(); c.moveTo(...K.mouth[0]); c.quadraticCurveTo(...K.mouth[1], ...K.mouth[2]); c.stroke();
+ c.lineWidth = 1.4; K.whiskers.forEach(w => { c.beginPath(); c.moveTo(...w[0]); c.lineTo(...w[1]); c.stroke(); });
+ c.restore();
+ }
+
+ // 角色用的透明色晕层(multiply 叠在角色上,做出水彩填色的深浅不匀)
+ const charBloom = () => P.cached('gh_charBloom', W, H, (g) => { const r = rng(808); for (let i = 0; i < 40; i++) { const x = 380 + r() * 1120, y = 280 + r() * 660; wash(g, ellipsePts(x, y, 30 + r() * 70, 24 + r() * 50, 9), ['#e8b890', '#a8c0d8', '#f0d0a0', '#c8a8c0'][i % 4], { layers: 2, alpha: 0.1, amp: 16, seed: 900 + i, edge: 0.08 }); } });
+ return {
+ draw(c, lt, t) {
+ const ch = P.choreo(lt, t);
+ c.drawImage(bg(), 0, 0);
+ // 窗外:云飘、树摇、草摆(都在窗洞里)
+ c.save(); c.beginPath(); c.rect(...WIN); c.clip();
+ c.drawImage(cloud('a', 380, 230, 11), 300 + t * 22, 150); c.drawImage(cloud('b', 260, 160, 23), 590 + t * 30, 210);
+ c.save(); c.translate(700, 540); c.rotate(Math.sin(t * 2.4) * 0.025); c.drawImage(tree(), -150, -360); c.restore();
+ c.restore();
+ grass(c, t);
+ // 窗框中梃压在外景上(从底版里再取一次窗框条,保证树和云在框后)
+ c.save(); c.beginPath(); [[575, 140, 10, 400], [370, 330, 420, 9]].forEach(r => c.rect(...r)); c.clip(); c.drawImage(bg(), 0, 0); c.restore();
+ komorebi(c, t);
+ curtain(c, -1, lt); curtain(c, 1, lt);
+ tablecloth(c, lt);
+ daisies(c, t);
+ // 角色先画进离屏,再把水彩颗粒+透明色晕按角色剪影 multiply 上去:赛璐璐平涂变成「水彩填色」
+ const L = P.scratch('ghChars'), cl = L.getContext('2d'); cl.reset(); cl.clearRect(0, 0, W, H);
+ const K = RIG.cat({ tail: ch.tail, blink: ch.blink, breathe: ch.breathe });
+ cat(cl, K);
+ const G = RIG.girl({ cup: ch.cup, sip: ch.sip, breathe: ch.breathe, hair: 'long' });
+ girl(cl, G, ch, lt, t);
+ c.drawImage(L, 0, 0);
+ // 水彩肌理只「乘」在角色上:纹理层 destination-in 角色剪影 → multiply 叠回(source-atop 会把纸色盖上去,人物整体发白,第一版踩到)
+ P.textureInside(c, L, mg => { mg.globalAlpha = 0.8; mg.drawImage(P.texture('gh_gran', '#f4efe2', { scale: 0.06, amt: 18, grain: 26, seed: 9 }), 0, 0); mg.globalAlpha = 1; mg.drawImage(charBloom(), 0, 0); }, { key: 'ghCharTex' });
+ P.steam(c, t, G.cup.x, G.cup.y - 8, { h: 60, n: 2, color: 'rgba(255,255,255,.75)', width: 3.5, spread: 12, wobble: 8 });
+ // 柔光:窗口方向一层暖色 screen 光晕
+ c.save(); c.globalCompositeOperation = 'screen'; const lg = c.createRadialGradient(580, 340, 60, 580, 340, 900); lg.addColorStop(0, 'rgba(255,240,200,.28)'); lg.addColorStop(1, 'rgba(255,240,200,0)'); c.fillStyle = lg; c.fillRect(0, 0, W, H); c.restore();
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/26_vaporwave.js b/scripts/engine/scenes/26_vaporwave.js
new file mode 100644
index 0000000..02eb85d
--- /dev/null
+++ b/scripts/engine/scenes/26_vaporwave.js
@@ -0,0 +1,191 @@
+// 2011 蒸汽波 / 赛博霓虹——纯代码。
+// 管线:①先把整幅画进离屏 S:深紫渐变墙+洋红透视网格地面(滚动)+窗里落日(横条切口上移)与青色网格、棕榈剪影摇
+// +自绘灯管字「カフェ」霓虹招牌(按帧哈希闪)+Win95 对话框 TEA.EXE 进度条+大理石胸像 +角色(深色平涂+粉/青双色轮廓辉光)
+// → ②VHS 后期:RGB 三通道分离错位(multiply 取单通道 → lighter 合成)+跟踪噪声带下滚(带内横向撕裂)+扫描线 + OSD(PLAY ▶、时间码)
+SCENES['26_vaporwave'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, ease, rng } = U, P = PAINT, TAU = Math.PI * 2;
+ const FLOOR = 720;
+ const C = { pink: '#ff4fd8', hot: '#ff2f8f', cyan: '#3ff6ff', purple: '#2a0b4a', deep: '#12052a', violet: '#7a2ae0', yellow: '#ffd84a', orange: '#ff8a3a' };
+ const glowLine = P.glowStroke; // 霓虹灯管:shadowBlur 辉光+近白芯线
+
+ // ---------- 静态底版:墙、窗框灯管、胸像底座 ----------
+ const bg = () => P.cached('vw_bg', W, H, (g) => {
+ const wg = g.createLinearGradient(0, 0, 0, FLOOR); wg.addColorStop(0, '#0d0322'); wg.addColorStop(0.7, '#2c0b52'); wg.addColorStop(1, '#4a0f6a'); g.fillStyle = wg; g.fillRect(0, 0, W, FLOOR);
+ // 墙上淡淡的竖向渐变色带(粉→青),像霓虹打在墙上
+ const bl = g.createRadialGradient(580, 340, 60, 580, 340, 760); bl.addColorStop(0, 'rgba(255,79,216,.35)'); bl.addColorStop(1, 'rgba(255,79,216,0)'); g.fillStyle = bl; g.fillRect(0, 0, W, FLOOR);
+ const br = g.createRadialGradient(1000, 220, 20, 1000, 220, 520); br.addColorStop(0, 'rgba(63,246,255,.22)'); br.addColorStop(1, 'rgba(63,246,255,0)'); g.fillStyle = br; g.fillRect(0, 0, W, FLOOR);
+ g.fillStyle = '#08020f'; g.fillRect(0, FLOOR, W, H - FLOOR);
+ // 墙脚灯带
+ g.beginPath(); g.moveTo(0, FLOOR); g.lineTo(W, FLOOR); glowLine(g, C.cyan, 4, 18);
+ // 椅子:黑色亚克力+粉色边灯
+ g.fillStyle = '#1a0830'; g.fillRect(1436, 470, 18, 440); g.fillRect(1474, 478, 18, 430); g.fillRect(1290, 744, 210, 16);
+ g.beginPath(); g.rect(1436, 470, 18, 440); g.rect(1474, 478, 18, 430); glowLine(g, C.pink, 2, 10);
+ });
+
+ // ---------- 窗里的落日 ----------
+ function sunset(c, t) {
+ c.save(); c.beginPath(); c.rect(370, 140, 420, 400); c.clip();
+ const sk = c.createLinearGradient(0, 140, 0, 470); sk.addColorStop(0, '#1a0640'); sk.addColorStop(0.55, '#a0207a'); sk.addColorStop(1, '#ff7a5a'); c.fillStyle = sk; c.fillRect(370, 140, 420, 330);
+ // 太阳:黄→洋红渐变,横条切口随时间上移(越往下切口越宽)
+ const sx = 580, sy = 400, sr = 118;
+ c.save(); c.beginPath(); c.arc(sx, sy, sr, 0, TAU); c.clip();
+ const sg = c.createLinearGradient(0, sy - sr, 0, sy + sr); sg.addColorStop(0, C.yellow); sg.addColorStop(0.5, C.orange); sg.addColorStop(1, C.hot); c.fillStyle = sg; c.fillRect(sx - sr, sy - sr, sr * 2, sr * 2);
+ c.globalCompositeOperation = 'destination-out';
+ const ph = (t * 0.9) % 1;
+ for (let k = 0; k < 7; k++) { const q = (k + ph) / 7, y = sy + sr * (q * 1.1 - 0.05), h = 2 + q * q * 16; c.fillRect(sx - sr, y, sr * 2, h); }
+ c.restore();
+ // 地平线上的线框山
+ c.beginPath(); c.moveTo(370, 470); [[420, 430], [470, 452], [520, 410], [560, 460], [640, 420], [700, 448], [760, 418], [790, 440]].forEach(p => c.lineTo(...p)); c.lineTo(790, 470);
+ c.fillStyle = '#1a0636'; c.fill(); glowLine(c, C.pink, 2.5, 10);
+ // 地面网格(青)往观众方向滚动
+ c.fillStyle = '#0b0220'; c.fillRect(370, 470, 420, 70);
+ c.save(); c.beginPath(); c.rect(370, 470, 420, 70); c.clip(); c.strokeStyle = C.cyan; c.lineWidth = 1.6; c.shadowColor = C.cyan; c.shadowBlur = 8;
+ for (let i = -10; i <= 10; i++) { c.beginPath(); c.moveTo(580 + i * 12, 470); c.lineTo(580 + i * 70, 540); c.stroke(); }
+ const sc = (t * 1.6) % 1; for (let k = 0; k < 8; k++) { const d = k + 1 - sc, y = 470 + 70 * (1 / (1 + 6 / (d * d + 0.01))) ; c.beginPath(); c.moveTo(370, y); c.lineTo(790, y); c.stroke(); }
+ c.restore();
+ // 棕榈剪影(左右各一,摇)
+ [[400, 540, 1], [770, 540, -1]].forEach(([x, y, s], k) => {
+ const sw = Math.sin(t * 2.2 + k * 1.4) * 0.06;
+ c.save(); c.translate(x, y); c.rotate(sw * s); c.fillStyle = '#0a0216'; c.strokeStyle = '#0a0216';
+ c.lineWidth = 10; c.lineCap = 'round'; c.beginPath(); c.moveTo(0, 0); c.quadraticCurveTo(s * 18, -120, s * 6, -230); c.stroke();
+ for (let f = 0; f < 7; f++) { const a = -Math.PI / 2 + (f - 3) * 0.45 + Math.sin(t * 3 + f) * 0.05, L = 70 + (f % 3) * 16; c.save(); c.translate(s * 6, -230); c.rotate(a); c.beginPath(); c.moveTo(0, 0); c.quadraticCurveTo(L * 0.5, -14, L, 12); c.quadraticCurveTo(L * 0.5, 4, 0, 4); c.fill(); c.restore(); }
+ c.restore(); });
+ c.restore();
+ // 窗框:青色灯管
+ c.beginPath(); c.rect(360, 130, 440, 420); glowLine(c, C.cyan, 6, 26); c.beginPath(); c.rect(360, 130, 440, 420); c.strokeStyle = '#e8ffff'; c.lineWidth = 2; c.stroke();
+ c.fillStyle = '#1a0830'; c.fillRect(330, 550, 500, 22); c.beginPath(); c.moveTo(330, 550); c.lineTo(830, 550); glowLine(c, C.pink, 3, 14);
+ }
+
+ // ---------- 地面:洋红透视网格(滚动) ----------
+ function floorGrid(c, t) {
+ c.save(); c.beginPath(); c.rect(0, FLOOR, W, H - FLOOR); c.clip();
+ const VX = 960, VY = 600; c.strokeStyle = C.pink; c.shadowColor = C.pink; c.shadowBlur = 12; c.lineWidth = 2.5;
+ for (let i = -16; i <= 16; i++) { c.beginPath(); c.moveTo(VX + i * 160 * (FLOOR - VY) / (H - VY), FLOOR); c.lineTo(VX + i * 160, H); c.stroke(); }
+ const ph = (t * 1.3) % 1;
+ for (let k = 0; k < 14; k++) { const d = k + 1 - ph, y = VY + 520 / d; if (y < FLOOR || y > H + 4) continue; c.lineWidth = 1.2 + 2.4 * (y - FLOOR) / (H - FLOOR); c.beginPath(); c.moveTo(0, y); c.lineTo(W, y); c.stroke(); }
+ c.restore();
+ }
+
+ // ---------- 霓虹灯管字「カフェ」(自绘折线,不依赖字体) ----------
+ const KANA = {
+ 'カ': [[[0.12, 0.34], [0.86, 0.34], [0.84, 0.62], [0.74, 0.94], [0.6, 0.86]], [[0.46, 0.08], [0.42, 0.5], [0.3, 0.78], [0.12, 0.96]]],
+ 'フ': [[[0.12, 0.24], [0.86, 0.24], [0.8, 0.56], [0.62, 0.82], [0.34, 0.96]]],
+ 'ェ': [[[0.28, 0.46], [0.72, 0.46]], [[0.5, 0.46], [0.5, 0.86]], [[0.18, 0.86], [0.82, 0.86]]],
+ };
+ function neonSign(c, t) {
+ const f = Math.floor(t * 30), on = (k) => { const h = U.hash(f, k); return !(h < 0.07 || (k === 1 && h < 0.22 && (f % 17) < 5)); };
+ const x0 = 868, y0 = 150, s = 104;
+ // 灯管底板
+ c.fillStyle = 'rgba(10,2,20,.55)'; c.fillRect(x0 - 18, y0 - 18, s * 3 + 24, s + 70);
+ [...'カフェ'].forEach((ch, k) => {
+ const lit = on(k), col = k === 1 ? C.cyan : C.pink;
+ KANA[ch].forEach(st => { c.beginPath(); st.forEach(([u, v], i) => { const x = x0 + k * s + u * (s - 14), y = y0 + v * s; i ? c.lineTo(x, y) : c.moveTo(x, y); });
+ c.lineJoin = 'round'; c.lineCap = 'round';
+ if (lit) { glowLine(c, col, 9, 30); c.strokeStyle = '#fff4fd'; c.lineWidth = 3; c.stroke(); } else { c.strokeStyle = 'rgba(120,60,120,.6)'; c.lineWidth = 6; c.stroke(); } });
+ });
+ // 小字 TEA ROOM(字体霓虹)
+ c.save(); c.font = '34px "Righteous-400"'; c.letterSpacing = '10px'; c.textBaseline = 'alphabetic';
+ c.shadowColor = C.yellow; c.shadowBlur = on(5) ? 18 : 0; c.fillStyle = on(5) ? '#fff2b0' : 'rgba(140,110,60,.6)'; c.fillText('TEA ROOM', x0 + 34, y0 + s + 44); c.restore();
+ }
+
+ // ---------- Win95 对话框 TEA.EXE ----------
+ function dialog(c, lt) {
+ const x = 26, y = 330, w = 300, h = 168;
+ c.save(); c.fillStyle = '#c0c0c0'; c.fillRect(x, y, w, h);
+ c.fillStyle = '#ffffff'; c.fillRect(x, y, w, 3); c.fillRect(x, y, 3, h); c.fillStyle = '#404040'; c.fillRect(x, y + h - 3, w, 3); c.fillRect(x + w - 3, y, 3, h);
+ const tg = c.createLinearGradient(x, 0, x + w, 0); tg.addColorStop(0, '#000080'); tg.addColorStop(1, '#1084d0'); c.fillStyle = tg; c.fillRect(x + 6, y + 6, w - 12, 30);
+ c.font = '18px "Poppins-700"'; c.fillStyle = '#fff'; c.textBaseline = 'middle'; c.fillText('TEA.EXE', x + 14, y + 22);
+ c.fillStyle = '#c0c0c0'; c.fillRect(x + w - 32, y + 10, 22, 20); c.fillStyle = '#000'; c.font = '16px "Poppins-700"'; c.fillText('×', x + w - 26, y + 20);
+ c.font = '17px "Poppins-600"'; c.fillStyle = '#000'; c.fillText('Brewing tea... ' + Math.min(99, Math.floor(18 + lt * 70)) + '%', x + 16, y + 64);
+ c.fillStyle = '#fff'; c.fillRect(x + 16, y + 86, w - 32, 26); c.fillStyle = '#808080'; c.fillRect(x + 16, y + 86, w - 32, 2);
+ const n = Math.min(17, Math.floor(3 + lt * 14)); c.fillStyle = '#000080'; for (let i = 0; i < n; i++) c.fillRect(x + 20 + i * 15.5, y + 90, 12, 18);
+ c.fillStyle = '#c0c0c0'; c.fillRect(x + w / 2 - 44, y + 124, 88, 30); c.fillStyle = '#fff'; c.fillRect(x + w / 2 - 44, y + 124, 88, 2); c.fillStyle = '#404040'; c.fillRect(x + w / 2 - 44, y + 152, 88, 2);
+ c.fillStyle = '#000'; c.font = '16px "Poppins-600"'; c.fillText('OK', x + w / 2 - 12, y + 140);
+ c.restore();
+ }
+
+ // ---------- 桌+大理石胸像 ----------
+ function table(c, t) {
+ c.fillStyle = '#0e0420'; c.fillRect(810, 618, 400, 28); c.fillRect(842, 646, 20, 259); c.fillRect(1160, 646, 20, 259);
+ c.beginPath(); c.moveTo(810, 618); c.lineTo(1210, 618); glowLine(c, C.cyan, 3, 16);
+ c.beginPath(); c.moveTo(810, 646); c.lineTo(1210, 646); glowLine(c, C.pink, 2, 10);
+ // 胸像(朝右的侧脸剪影+大理石渐变+粉青轮廓光)
+ const bust = new Path2D(); const bx = 900, by = 618;
+ [[-48, 0], [-50, -22], [-30, -38], [-18, -44], [-16, -62], [-24, -76], [-26, -100], [-18, -122], [0, -132], [20, -128], [30, -112], [36, -100], [44, -92], [38, -86], [42, -78], [36, -72], [36, -62], [24, -58], [20, -46], [34, -38], [52, -22], [50, 0]].forEach(([x, y], i) => i ? bust.lineTo(bx + x, by + y) : bust.moveTo(bx + x, by + y)); bust.closePath();
+ const mg = c.createLinearGradient(bx - 50, by - 130, bx + 50, by); mg.addColorStop(0, '#f6eefa'); mg.addColorStop(0.6, '#c9b8d8'); mg.addColorStop(1, '#8a6aa8'); c.fillStyle = mg; c.fill(bust);
+ c.save(); c.clip(bust); c.strokeStyle = 'rgba(140,110,160,.5)'; c.lineWidth = 1.2; [[[-40, -10], [-10, -40], [10, -70]], [[20, -20], [30, -50]], [[-20, -90], [0, -110]]].forEach(v => { c.beginPath(); v.forEach(([x, y], i) => i ? c.lineTo(bx + x, by + y) : c.moveTo(bx + x, by + y)); c.stroke(); }); c.restore();
+ c.strokeStyle = 'rgba(255,79,216,.9)'; c.lineWidth = 2.5; c.shadowColor = C.pink; c.shadowBlur = 14; c.stroke(bust); c.shadowBlur = 0;
+ c.fillStyle = '#5a3a7a'; c.beginPath(); c.arc(bx + 22, by - 98, 3, 0, TAU); c.fill();
+ // 胸像戴的复古太阳镜(梗)
+ c.fillStyle = '#111'; c.fillRect(bx + 8, by - 104, 34, 9); c.fillStyle = C.cyan; c.fillRect(bx + 12, by - 102, 26, 2);
+ }
+
+ // ---------- 角色:深色平涂 → 双色轮廓辉光 ----------
+ function girl(c, G, ch, t) {
+ const pal = { skin: '#f4c4d8', skinS: '#b8789e', hair: '#ffe08a', hairS: '#d89a5a', top: '#8f7cf6', topS: '#5a44c8', skirt: '#4fd0e0', skirtS: '#2a7a9a' };
+ c.save(); c.lineJoin = 'round'; c.lineCap = 'round';
+ const fill = (p, a, b, x0 = 1100, x1 = 1460) => { if (!p) return; const g = c.createLinearGradient(x0, 0, x1, 0); g.addColorStop(0, a); g.addColorStop(1, b); c.fillStyle = g; c.fill(p); };
+ fill(G.farSleeve, pal.topS, pal.topS); fill(G.farHand, pal.skinS, pal.skinS);
+ fill(G.skirt, pal.skirt, pal.skirtS);
+ c.save(); c.clip(G.skirt); c.strokeStyle = 'rgba(20,40,80,.35)'; c.lineWidth = 3; for (let x = 1100; x < 1460; x += 22) { c.beginPath(); c.moveTo(x, 640); c.lineTo(x - 30, 940); c.stroke(); } c.restore(); // 百褶
+ fill(G.shoe, '#fff', '#c8c8ff');
+ fill(G.torso, pal.top, pal.topS, 1290, 1420);
+ fill(G.neck, pal.skin, pal.skinS, 1286, 1324);
+ { const nk = G.A.neck; c.fillStyle = '#ffffff'; c.beginPath(); c.moveTo(nk[0] - 22, nk[1] - 4); c.lineTo(nk[0] + 26, nk[1]); c.lineTo(nk[0] + 4, nk[1] + 34); c.closePath(); c.fill(); c.fillStyle = C.cyan; c.fillRect(nk[0] - 4, nk[1] + 40, 6, 120); } // 白领口+青色拉链线
+ fill(G.hairBack, pal.hair, pal.hairS, 1260, 1410); fill(G.bun, pal.hair, pal.hairS);
+ // 发圈(粉)
+ c.strokeStyle = C.hot; c.lineWidth = 8; c.beginPath(); c.arc(G.bunSpiral[0] - 18, G.bunSpiral[1] + 6, 14, -1.2, 1.6); c.stroke();
+ fill(G.face, pal.skin, pal.skinS, 1250, 1330); fill(G.bangs, pal.hair, pal.hairS, 1250, 1335);
+ c.strokeStyle = 'rgba(200,120,60,.6)'; c.lineWidth = 2; G.hairLines.forEach(h => c.stroke(h));
+ if (ch.blink) { c.strokeStyle = '#2a0a3a'; c.lineWidth = 2.6; c.stroke(G.lid); }
+ else { c.fillStyle = '#2a0a3a'; c.beginPath(); c.ellipse(G.eye.x - 1, G.eye.y + 1, 4, 5.5, 0, 0, TAU); c.fill(); c.fillStyle = C.cyan; c.beginPath(); c.arc(G.eye.x - 2, G.eye.y - 1, 1.6, 0, TAU); c.fill(); c.strokeStyle = '#2a0a3a'; c.lineWidth = 2.4; c.stroke(G.lid); }
+ c.fillStyle = C.hot; c.beginPath(); c.moveTo(...G.lips[0]); c.lineTo(...G.lips[1]); c.lineTo(...G.lips[2]); c.closePath(); c.fill();
+ fill(G.upperArm, pal.top, pal.topS, 1200, 1380); fill(G.foreArm, pal.top, pal.topS, 1200, 1380); fill(G.cuff, '#fff', '#d8c8ff', 1200, 1300); fill(G.hand, pal.skin, pal.skinS, 1180, 1260);
+ RIG.drawCup(c, G.cup, { body: '#1a0830', rim: '#ff9ad6', hw: 6 });
+ c.save(); c.translate(G.cup.x, G.cup.y); c.rotate(G.cup.tilt); c.beginPath(); c.moveTo(-G.cup.w / 2, 0); c.lineTo(-G.cup.w * 0.42, G.cup.h); c.lineTo(G.cup.w * 0.42, G.cup.h); c.lineTo(G.cup.w / 2, 0); glowLine(c, C.cyan, 2, 10); c.restore();
+ c.fillStyle = pal.skin; c.beginPath(); c.arc(G.thumb[0], G.thumb[1], 7, 0, TAU); c.fill();
+ // 轮廓辉光:朝窗(左)的一侧粉、背面青——同一条路径描两次,用 clip 半屏分色
+ const outline = [G.skirt, G.torso, G.face, G.hairBack, G.bun, G.upperArm, G.foreArm];
+ [[C.pink, 0, 1290], [C.cyan, 1290, W]].forEach(([col, a, b]) => { c.save(); c.beginPath(); c.rect(a, 0, b - a, H); c.clip(); c.shadowColor = col; c.shadowBlur = 16; c.strokeStyle = col; c.lineWidth = 3; outline.forEach(p => p && c.stroke(p)); c.restore(); });
+ c.restore();
+ }
+ function cat(c, K) {
+ c.save(); c.lineCap = 'round'; c.lineJoin = 'round';
+ c.strokeStyle = '#ff9a4a'; c.lineWidth = K.tailW; c.stroke(K.tail);
+ const tip = K.tailPts[K.tailPts.length - 1]; c.fillStyle = '#fff0fa'; c.beginPath(); c.arc(tip[0], tip[1], K.tailW / 2, 0, TAU); c.fill();
+ const og = c.createLinearGradient(420, 0, 660, 0); og.addColorStop(0, '#ffb070'); og.addColorStop(1, '#c0502a'); c.fillStyle = og; c.fill(K.body);
+ K.legs.forEach(l => { c.fillStyle = '#fff0fa'; c.fill(l); }); c.fillStyle = '#fff0fa'; c.fill(K.white);
+ c.fillStyle = og; c.fill(K.head);
+ c.save(); c.clip(K.head); c.fillStyle = '#fff0fa'; c.beginPath(); c.ellipse(K.nose[0] - 22, K.nose[1] + 12, 36, 26, 0, 0, TAU); c.fill(); c.restore();
+ c.strokeStyle = '#a03a1a'; c.lineWidth = 7; K.stripes.forEach(s => { c.beginPath(); c.moveTo(...s[0]); c.lineTo(...s[1]); c.stroke(); });
+ c.fillStyle = '#ff9ad6'; K.earInner.forEach(e => { c.beginPath(); e.forEach((p, i) => i ? c.lineTo(...p) : c.moveTo(...p)); c.fill(); });
+ K.eyes.forEach(e => { if (K.blink) { c.strokeStyle = '#2a0a3a'; c.lineWidth = 3; c.beginPath(); c.moveTo(e.x - 8, e.y); c.lineTo(e.x + 8, e.y); c.stroke(); }
+ else { c.shadowColor = C.cyan; c.shadowBlur = 10; c.fillStyle = C.cyan; c.beginPath(); c.arc(e.x, e.y, 8, 0, TAU); c.fill(); c.shadowBlur = 0; c.fillStyle = '#12052a'; c.beginPath(); c.ellipse(e.x + 2, e.y, 2.4, 6.5, 0, 0, TAU); c.fill(); } });
+ c.fillStyle = C.hot; c.beginPath(); c.arc(K.nose[0], K.nose[1], 5, 0, TAU); c.fill();
+ c.strokeStyle = '#ffe8ff'; c.lineWidth = 1.4; K.whiskers.forEach(w => { c.beginPath(); c.moveTo(...w[0]); c.lineTo(...w[1]); c.stroke(); });
+ [[C.pink, 0, 560], [C.cyan, 560, 900]].forEach(([col, a, b]) => { c.save(); c.beginPath(); c.rect(a, 0, b - a, H); c.clip(); c.shadowColor = col; c.shadowBlur = 14; c.strokeStyle = col; c.lineWidth = 3; [K.body, K.head].forEach(p => c.stroke(p)); c.restore(); });
+ c.restore();
+ }
+
+ // ---------- ② VHS 后期:P.vhs(RGB 通道分离+跟踪噪声带撕裂+扫描线+OSD+暗角) ----------
+ const vhs = (c, S, t, lt) => P.vhs(c, S, t, lt, { osd: { label: 'PLAY', date: 'SEP. 04 2011', clock: '23:59' } });
+
+ return {
+ draw(c, lt, t) {
+ const ch = P.choreo(lt, t);
+ const S = P.scratch('vwS'), g = S.getContext('2d'); g.reset();
+ g.drawImage(bg(), 0, 0);
+ floorGrid(g, t);
+ sunset(g, t);
+ neonSign(g, t);
+ dialog(g, lt);
+ table(g, t);
+ const K = RIG.cat({ tail: ch.tail, blink: ch.blink, breathe: ch.breathe });
+ cat(g, K);
+ const G = RIG.girl({ cup: ch.cup, sip: ch.sip, breathe: ch.breathe });
+ girl(g, G, ch, t);
+ P.steam(g, t, G.cup.x, G.cup.y - 8, { h: 60, n: 2, color: 'rgba(63,246,255,.85)', width: 3, spread: 12, wobble: 8 });
+ vhs(c, S, t, lt);
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/27_kirby.js b/scripts/engine/scenes/27_kirby.js
new file mode 100644
index 0000000..16b54bc
--- /dev/null
+++ b/scripts/engine/scenes/27_kirby.js
@@ -0,0 +1,255 @@
+// 1966 漫威银河时代(Jack Kirby + 四色胶印)——纯代码。
+// 管线:同一份几何画两遍 →
+// 色版层:纸+平涂+本戴网点(C 15°、M 75°、Y 0°),整层偏移 (4,3) = 套色不准
+// 墨线层:白填+黑描边+黑块阴影(spotted blacks)+羽化排线(feathering)+ Kirby krackle 黑点
+// 合成:色版 → 墨线 multiply(墨线层白色=透明)。墨线层逐部件「白填→阴影→描边」,后画的部件盖掉前面的线,天然只剩看得见的线。
+// 母题:窗外宇宙能量流里的 krackle 黑点群 12fps 流动、端杯速度线、SLURRP! 拟声大字弹出、右侧分格猫眼特写瞳孔追杯、聚焦线闪。
+SCENES['27_kirby'] = (() => {
+ const W = 1920, H = 1080, TAU = Math.PI * 2, { clamp, lerp } = U, P = PAINT;
+ const INK = '#141212', PAPER = '#f4ecd6';
+ const C = { cyan: '#2a9fd8', blue: '#1f3f9e', mag: '#e0287a', red: '#e3262d', yel: '#ffd62a', org: '#f6921e', orgD: '#d2541c',
+ skin: '#fbd9b8', wall: '#cfe7f2', floor: '#2b3f9c', wood: '#f2a524', space: '#121a52', energy: '#ffe14a', energy2: '#ff8a2a', planet: '#b04ac8' };
+ const LIGHT = [-0.86, -0.5]; // 光从窗(左上)来,阴影在右下边缘
+
+ // ---- 墨线层工具:阴影月牙 + 羽化排线 ----
+ const big = (() => { const p = new Path2D(); p.rect(-50, -50, W + 100, H + 100); return p; })();
+ const outsideShift = (path, d) => { const m = new Path2D(); m.addPath(big); m.addPath(path, new DOMMatrix().translate(LIGHT[0] * d, LIGHT[1] * d)); return m; };
+ function shade(g, path, d1 = 14, d2 = 30, gap = 9) {
+ // 羽化带:path ∩ ¬shift(d2),画沿光方向的平行短线
+ g.save(); g.clip(path); g.clip(outsideShift(path, d2), 'evenodd');
+ g.strokeStyle = INK; g.lineWidth = 2.6; g.lineCap = 'butt'; g.beginPath();
+ const a = Math.atan2(LIGHT[1], LIGHT[0]), nx = -Math.sin(a), ny = Math.cos(a);
+ for (let k = -260; k < 260; k++) { const ox = 960 + nx * k * gap, oy = 540 + ny * k * gap; g.moveTo(ox - LIGHT[0] * 1400, oy - LIGHT[1] * 1400); g.lineTo(ox + LIGHT[0] * 1400, oy + LIGHT[1] * 1400); }
+ g.stroke(); g.restore();
+ // 黑块:path ∩ ¬shift(d1)
+ g.save(); g.clip(path); g.clip(outsideShift(path, d1), 'evenodd'); g.fillStyle = INK; g.fillRect(0, 0, W, H); g.restore();
+ }
+ // 一个部件:色版层填色;墨线层白填→阴影→描边
+ const mkPart = (g, mode) => (path, col, o = {}) => {
+ if (!path) return;
+ if (mode === 'color') { g.fillStyle = col; g.fill(path); return; }
+ g.fillStyle = '#fff'; g.fill(path);
+ if (o.shade) shade(g, path, o.shade[0], o.shade[1]);
+ if (o.lw !== 0) { g.strokeStyle = INK; g.lineWidth = o.lw || 6; g.lineJoin = 'round'; g.stroke(path); }
+ };
+
+ // ---- Kirby krackle:一簇大小不一的黑点,按 12fps 换形 ----
+ function krackle(g, cx, cy, R, seed, t, n = 22) {
+ const st = Math.floor(t * 12), r = U.rng(seed * 131 + st * 7);
+ g.fillStyle = INK;
+ for (let i = 0; i < n; i++) {
+ const a = r() * TAU, d = Math.pow(r(), 0.7) * R, rr = R * (0.05 + 0.2 * (1 - d / R) * r()) * (0.8 + 0.3 * Math.sin(t * 18 + i));
+ g.beginPath(); g.arc(cx + Math.cos(a) * d, cy + Math.sin(a) * d * 0.8, Math.max(2, rr), 0, TAU); g.fill();
+ }
+ }
+
+ // ---- 窗外:宇宙+能量流 ----
+ const WIN = [372, 142, 416, 396];
+ const stream = (s, w) => { // 能量流中线:从左下到右上的 S 形
+ const x = lerp(330, 840, s), y = lerp(560, 120, s) + Math.sin(s * 5.2 + 0.4) * 46; return [x, y + w];
+ };
+ function windowArt(g, mode, t) {
+ const [x, y, w, h] = WIN;
+ g.save(); g.beginPath(); g.rect(x, y, w, h); g.clip();
+ if (mode === 'color') {
+ g.fillStyle = C.space; g.fillRect(x, y, w, h);
+ // 星云网点(M 75°)
+ g.fillStyle = P.dotPattern(g, 'neb', 10, 3.2, C.mag, null, 75); g.beginPath(); g.ellipse(700, 230, 160, 90, -0.4, 0, TAU); g.fill();
+ // 行星
+ g.lineWidth = 9; g.strokeStyle = C.yel; g.beginPath(); g.ellipse(470, 230, 112, 20, -0.25, Math.PI, TAU); g.stroke();
+ g.fillStyle = C.planet; g.beginPath(); g.arc(470, 230, 64, 0, TAU); g.fill();
+ g.beginPath(); g.ellipse(470, 230, 112, 20, -0.25, 0, Math.PI); g.stroke();
+ // 能量流带
+ const band = new Path2D(); for (let i = 0; i <= 40; i++) band.lineTo(...stream(i / 40, -58)); for (let i = 40; i >= 0; i--) band.lineTo(...stream(i / 40, 58)); band.closePath();
+ g.fillStyle = C.energy2; g.fill(band);
+ const core = new Path2D(); for (let i = 0; i <= 40; i++) core.lineTo(...stream(i / 40, -34)); for (let i = 40; i >= 0; i--) core.lineTo(...stream(i / 40, 34)); core.closePath();
+ g.fillStyle = C.energy; g.fill(core);
+ // 星
+ g.fillStyle = '#fff'; [[400, 170, 7], [760, 420, 6], [560, 170, 5], [740, 170, 8], [420, 470, 5]].forEach(([sx, sy, r], k) => { const tw = 0.7 + 0.4 * Math.sin(t * 9 + k * 2); g.fill(KIT.star(sx, sy, r * 2.6 * tw, r * 0.5, 4)); });
+ } else {
+ g.fillStyle = '#fff'; g.fillRect(x, y, w, h);
+ // 行星阴影
+ g.strokeStyle = INK; g.lineWidth = 3; g.beginPath(); g.ellipse(470, 230, 112, 20, -0.25, Math.PI, TAU); g.stroke(); const pl = new Path2D(); pl.arc(470, 230, 64, 0, TAU); g.fillStyle = '#fff'; g.fill(pl); shade(g, pl, 18, 34, 8); g.strokeStyle = INK; g.lineWidth = 5; g.stroke(pl); g.lineWidth = 3; g.beginPath(); g.ellipse(470, 230, 112, 20, -0.25, 0, Math.PI); g.stroke();
+ // krackle:沿能量流移动(300px/s),每簇 12fps 换形
+ for (let k = 0; k < 6; k++) { const s = ((k / 6 + t * 0.42) % 1); const [cx, cy] = stream(s, Math.sin(k * 2.3) * 12); krackle(g, cx, cy, 44 + (k % 3) * 12, k + 1, t, 26); }
+ // 能量流边缘的锯齿墨线
+ g.strokeStyle = INK; g.lineWidth = 4;
+ [-58, 58].forEach(o => { g.beginPath(); for (let i = 0; i <= 40; i++) { const [px, py] = stream(i / 40, o + (i % 2 ? 6 : -6)); i ? g.lineTo(px, py) : g.moveTo(px, py); } g.stroke(); });
+ }
+ g.restore();
+ }
+
+ // ---- 室内底版 ----
+ function room(g, mode, t) {
+ const part = mkPart(g, mode);
+ if (mode === 'color') {
+ g.fillStyle = PAPER; g.fillRect(0, 0, W, H);
+ g.fillStyle = C.wall; g.fillRect(0, 0, 1540, 700);
+ g.fillStyle = P.dotPattern(g, 'wallc', 9, 2.7, C.cyan, null, 15); g.fillRect(0, 0, 1540, 700);
+ g.fillStyle = C.floor; g.fillRect(0, 700, 1540, 380);
+ g.fillStyle = P.dotPattern(g, 'floorm', 9, 3.2, '#7a2a9a', null, 75); g.fillRect(0, 700, 1540, 380);
+ } else {
+ g.fillStyle = '#fff'; g.fillRect(0, 0, W, H);
+ // 地板缝(Kirby 的方块透视)+地平线
+ g.strokeStyle = INK; g.lineWidth = 5; g.beginPath(); g.moveTo(0, 700); g.lineTo(1540, 700); g.stroke();
+ g.lineWidth = 3; for (let i = -10; i <= 12; i++) { g.beginPath(); g.moveTo(760 + i * 70, 700); g.lineTo(760 + i * 230, 1080); g.stroke(); }
+ [760, 830, 930, 1060].forEach(y => { g.beginPath(); g.moveTo(0, y); g.lineTo(1540, y); g.stroke(); });
+ }
+ // 窗框(红)+窗台
+ const frame = new Path2D(); frame.rect(344, 114, 472, 452); frame.rect(372, 142, 416, 396);
+ if (mode === 'color') { g.fillStyle = C.red; g.fill(frame, 'evenodd'); } else { g.fillStyle = '#fff'; g.fill(frame, 'evenodd'); g.strokeStyle = INK; g.lineWidth = 6; g.stroke(frame); }
+ windowArt(g, mode, t);
+ const mull = new Path2D(); mull.rect(570, 142, 20, 396); part(mull, C.red, { lw: 5 });
+ const sill = new Path2D(); sill.rect(322, 556, 516, 30); part(sill, C.red, { lw: 6, shade: [8, 16] });
+ // 郁金香椅(1956 Saarinen,60 年代的家具)
+ const shell = RIG.smooth([[1376, 470], [1420, 452], [1468, 480], [1484, 600], [1470, 712], [1330, 726], [1300, 700], [1420, 680], [1430, 560], [1400, 500]], true, 0.5);
+ part(shell, '#fff', { lw: 6, shade: [10, 22] });
+ const stem = new Path2D(); stem.moveTo(1380, 724); stem.lineTo(1400, 724); stem.lineTo(1412, 880); stem.lineTo(1368, 880); stem.closePath(); part(stem, '#fff', { lw: 5, shade: [6, 12] });
+ const base = new Path2D(); base.ellipse(1390, 892, 74, 16, 0, 0, TAU); part(base, '#fff', { lw: 5, shade: [5, 10] });
+ // 桌
+ const top = new Path2D(); top.rect(806, 616, 404, 30); part(top, C.wood, { lw: 6, shade: [10, 18] });
+ const apron = new Path2D(); apron.rect(826, 646, 364, 44); part(apron, C.orgD, { lw: 5, shade: [10, 22] });
+ [[842, 690], [1158, 690]].forEach(([x, y]) => { const l = new Path2D(); l.rect(x, y, 26, 214); part(l, C.orgD, { lw: 5, shade: [8, 14] }); });
+ // 茶壶(桌上,红白)
+ const pot = RIG.smooth([[868, 616], [856, 586], [872, 556], [912, 548], [948, 558], [962, 590], [952, 616]], true, 0.5);
+ const spout = U.poly([[862, 590], [828, 560], [836, 552], [870, 574]]);
+ part(spout, C.red, { lw: 4 }); part(pot, C.red, { lw: 5, shade: [8, 16] });
+ const lid = new Path2D(); lid.ellipse(910, 548, 26, 9, 0, 0, TAU); part(lid, '#fff', { lw: 4 });
+ }
+
+ // ---- 角色 ----
+ function chars(g, mode, t, ch, G, K) {
+ const part = mkPart(g, mode);
+ const SH = { skirt: [16, 34], torso: [14, 30], farSleeve: [10, 22], upperArm: [10, 22], foreArm: [8, 18], hairDown: [12, 26], hairBack: [12, 24], bangs: [6, 14], body: [16, 34], head: [12, 26] };
+ const LW = { skirt: 6, torso: 6, hand: 4, farHand: 4, neck: 4, face: 4.5, cuff: 4, farCuff: 4, shoe: 5, leg: 5 };
+ const skinFill = mode === 'color' ? P.dotPattern(g, 'skin', 7, 1.5, '#ef8a8a', C.skin, 75) : null;
+ // 猫
+ RIG.drawCat(g, K, { line: INK, lw: 6, orange: C.org, white: mode === 'color' ? PAPER : '#fff', stripe: mode === 'color' ? C.orgD : INK, stripeW: 6, eye: '#8ad24a',
+ paint: (c, p, col, name, stroke) => { if (mode === 'color') { c.fillStyle = col; c.fill(p); return; } c.fillStyle = '#fff'; c.fill(p); if (SH[name]) shade(c, p, SH[name][0], SH[name][1]); if (stroke) { c.strokeStyle = INK; c.lineWidth = LW[name] || 6; c.stroke(p); } },
+ tail: (c, K) => { c.lineCap = 'round'; if (mode === 'color') { c.strokeStyle = C.org; c.lineWidth = K.tailW; c.stroke(K.tail); return; } c.strokeStyle = INK; c.lineWidth = K.tailW + 12; c.stroke(K.tail); c.strokeStyle = '#fff'; c.lineWidth = K.tailW; c.stroke(K.tail);
+ [5, 10, 15].forEach(i => { const p = K.tailPts[i], q = K.tailPts[i + 1], a = Math.atan2(q[1] - p[1], q[0] - p[0]) + Math.PI / 2; c.lineWidth = 6; c.strokeStyle = INK; c.beginPath(); c.moveTo(p[0] + Math.cos(a) * 12, p[1] + Math.sin(a) * 12); c.lineTo(p[0] - Math.cos(a) * 4, p[1] - Math.sin(a) * 4); c.stroke(); }); },
+ face: mode === 'color' ? (c) => { } : undefined });
+ // 少女:60 年代红色 A 字长裙、白色彼得潘领、黑发箍、外翻发尾
+ const fills = { skin: mode === 'color' ? skinFill : '#fff', hair: C.yel, dress: C.red, cuff: mode === 'color' ? PAPER : '#fff', shoe: INK, cupBody: '#fff', cupRim: '#7a3a16', locks: false };
+ RIG.drawGirl(g, G, { line: INK, lw: 6, ...fills, lwOf: LW, blink: ch.blink, iris: '#2a7ad8', lip: '#e3262d', featureW: 1.35,
+ paint: (c, p, col, name) => { if (mode === 'color') { c.fillStyle = col; c.fill(p); return; } c.fillStyle = '#fff'; c.fill(p); if (SH[name]) shade(c, p, SH[name][0], SH[name][1]); const w = LW[name] ?? 6; c.strokeStyle = INK; c.lineWidth = w; c.stroke(p); },
+ features: mode === 'color' ? () => { } : (c, G) => RIG.drawFeatures(c, G, { line: INK, iris: '#2a7ad8', lip: '#e3262d', featureW: 1.35, blink: ch.blink }),
+ cup: (c, G) => { const k = G.cup; c.save(); c.translate(k.x, k.y); c.rotate(k.tilt); const w = 50, h = 44;
+ const body = U.poly([[-w / 2, 0], [-w * 0.42, h], [w * 0.42, h], [w / 2, 0]]); const hd = new Path2D(); hd.arc(w * 0.58, h * 0.42, 13, -1.3, 1.4);
+ if (mode === 'color') { c.fillStyle = '#fff'; c.fill(body); c.fillStyle = C.cyan; c.fillRect(-w / 2, h * 0.35, w, 10); c.strokeStyle = '#fff'; c.lineWidth = 7; c.stroke(hd); c.fillStyle = '#7a3a16'; c.beginPath(); c.ellipse(0, 1, w / 2 - 2, 6, 0, 0, TAU); c.fill(); }
+ else { c.fillStyle = '#fff'; c.fill(body); c.strokeStyle = INK; c.lineWidth = 5; c.stroke(body); c.lineWidth = 11; c.stroke(hd); c.strokeStyle = '#fff'; c.lineWidth = 4; c.stroke(hd); c.strokeStyle = INK; c.lineWidth = 4; c.beginPath(); c.ellipse(0, 1, w / 2 - 2, 6, 0, 0, TAU); c.stroke(); }
+ c.restore(); },
+ hooks: {
+ skirt: (c) => { // 外翻发尾(在躯干后面)
+ const hp = (x, y) => [x + G.A.headC[0] - 1318, y + G.A.headC[1] - 360];
+ const flip = RIG.smooth([[1360, 430], [1404, 452], [1424, 520], [1430, 560], [1462, 556], [1474, 590], [1430, 604], [1396, 590], [1372, 520]].map(p => hp(...p)), true, 0.5);
+ if (mode === 'color') { c.fillStyle = C.yel; c.fill(flip); } else { c.fillStyle = '#fff'; c.fill(flip); shade(c, flip, 12, 26); c.strokeStyle = INK; c.lineWidth = 6; c.stroke(flip); }
+ if (mode !== 'color') { c.lineWidth = 3; c.strokeStyle = INK; [[0, 0], [14, 8]].forEach(([dx, dy]) => { c.beginPath(); c.moveTo(...hp(1376 + dx, 470 + dy)); c.quadraticCurveTo(...hp(1410 + dx, 520 + dy), ...hp(1440 + dx / 2, 584)); c.stroke(); }); }
+ },
+ torso: (c) => { // 彼得潘白领+一排纽扣
+ const n = G.A.neck; const col = new Path2D(); col.ellipse(n[0] - 10, n[1] + 6, 26, 15, -0.2, 0, TAU); col.ellipse(n[0] + 26, n[1] + 4, 24, 14, 0.3, 0, TAU);
+ if (mode === 'color') { c.fillStyle = PAPER; c.fill(col); } else { c.fillStyle = '#fff'; c.fill(col); c.strokeStyle = INK; c.lineWidth = 4.5; c.stroke(col); c.fillStyle = INK; [0, 1, 2].forEach(i => { c.beginPath(); c.arc(G.A.chest[0] + 2, G.A.chest[1] - 20 + i * 34, 4.5, 0, TAU); c.fill(); }); }
+ },
+ head: (c) => { // 黑发箍+发丝墨线
+ if (mode === 'color') return;
+ const h = G.A.headC, rot = G.tilt;
+ c.save(); c.translate(h[0], h[1]); c.rotate(rot); c.strokeStyle = INK; c.lineWidth = 11; c.lineCap = 'round'; c.beginPath(); c.ellipse(6, 4, 60, 66, -0.25, -2.35, -0.95); c.stroke(); c.restore();
+ c.lineWidth = 3; c.strokeStyle = INK; G.hairLines.forEach(l => c.stroke(l));
+ G.locks.forEach(l => { c.lineWidth = 3; c.stroke(l); });
+ },
+ } });
+ // 少女与猫的地面黑影
+ if (mode !== 'color') { g.fillStyle = INK; g.beginPath(); g.ellipse(560, 908, 150, 14, 0, 0, TAU); g.fill(); g.beginPath(); g.ellipse(1260, 932, 170, 12, 0, 0, TAU); g.fill(); }
+ }
+
+ // ---- 顶层:速度线、拟声字、旁白框、右侧特写格、格框 ----
+ function speedLines(c, G, lt, t) {
+ const v = Math.abs(Math.sin(Math.min(1, lt / 0.9) * Math.PI)) * (lt < 0.95 ? 1 : 0); // 端杯速度(正比)
+ if (v < 0.08) return;
+ const st = Math.floor(t * 12), r = U.rng(500 + st);
+ const k = G.cup, dir = [-0.16, 1]; // 杯往上走 → 速度线拖在下面
+ c.save(); c.strokeStyle = INK; c.lineCap = 'round';
+ for (let i = 0; i < 9; i++) { const ox = k.x - 40 + i * 12 + (r() - 0.5) * 6, oy = k.y + 50 + r() * 26, L = (70 + r() * 110) * v;
+ c.lineWidth = 2.5 + r() * 2.5; c.beginPath(); c.moveTo(ox, oy); c.lineTo(ox + dir[0] * L, oy + dir[1] * L); c.stroke(); }
+ // 手肘后方两道动作弧
+ const E = G.A.elbow; c.lineWidth = 5; [0, 1].forEach(j => { c.beginPath(); c.arc(E[0] + 6, E[1] + 10, 46 + j * 18, 0.1, 1.1); c.stroke(); });
+ c.restore();
+ }
+ function sfx(c, lt, t) {
+ const q = clamp((lt - 0.52) / 0.16); if (q <= 0) return;
+ const s = U.ease.outBack(q), st = Math.floor(t * 12), jx = (U.hash(st, 3) - 0.5) * 6, jy = (U.hash(st, 9) - 0.5) * 6;
+ c.save(); c.translate(990 + jx, 318 + jy); c.rotate(-0.14); c.scale(s * 0.82, s * 0.82);
+ // 爆炸放射底
+ c.fillStyle = C.yel; c.strokeStyle = INK; c.lineWidth = 7; const burst = []; for (let i = 0; i < 26; i++) { const a = i / 26 * TAU, r = (i % 2 ? 108 : 178) * (0.9 + U.hash(i, 77) * 0.2); burst.push([Math.cos(a) * r * 1.5, Math.sin(a) * r * 0.75]); }
+ const bp = U.poly(burst); c.fill(bp); c.stroke(bp);
+ c.font = '132px "Bangers-400"'; c.textAlign = 'center'; c.textBaseline = 'middle'; c.letterSpacing = '4px';
+ for (let d = 14; d > 0; d -= 2) { c.fillStyle = INK; c.fillText('SLURRP!', d * 0.8, d); } // Kirby 的立体积木字:黑色挤出
+ c.lineWidth = 10; c.strokeStyle = INK; c.strokeText('SLURRP!', 0, 0); c.fillStyle = C.red; c.fillText('SLURRP!', 0, 0);
+ c.fillStyle = C.yel; c.save(); c.beginPath(); c.rect(-400, -70, 800, 46); c.clip(); c.fillText('SLURRP!', 0, 0); c.restore();
+ c.restore();
+ }
+ function caption(c) {
+ c.save(); c.translate(5, 5); c.fillStyle = INK; c.fillRect(40, 38, 420, 62); c.restore();
+ c.fillStyle = C.yel; c.fillRect(40, 38, 420, 62); c.strokeStyle = INK; c.lineWidth = 5; c.strokeRect(40, 38, 420, 62);
+ c.font = '38px "Bangers-400"'; c.fillStyle = INK; c.textBaseline = 'middle'; c.letterSpacing = '2px'; c.fillText('MEANWHILE, AT TEA TIME...', 56, 70); c.letterSpacing = '0px';
+ }
+ function catPanel(c, lt, t, ch) {
+ const x0 = 1556, y0 = 236, x1 = 1892, y1 = 1050, cx = 1724, cy = 560;
+ c.save(); c.beginPath(); c.rect(x0, y0, x1 - x0, y1 - y0); c.clip();
+ c.fillStyle = C.mag; c.fillRect(x0, y0, x1 - x0, y1 - y0);
+ c.fillStyle = P.dotPattern(c, 'pnl', 10, 3.6, C.yel, null, 0); c.fillRect(x0, y0, x1 - x0, y1 - y0);
+ // 聚焦线:12fps 换种子
+ const r = U.rng(900 + Math.floor(t * 12)); c.fillStyle = INK;
+ for (let i = 0; i < 44; i++) { const a = i / 44 * TAU + r() * 0.08, w = 0.012 + r() * 0.02, r0 = 230 + r() * 60; c.beginPath(); c.moveTo(cx + Math.cos(a - w) * r0, cy + Math.sin(a - w) * r0); c.lineTo(cx + Math.cos(a) * 900, cy + Math.sin(a) * 900); c.lineTo(cx + Math.cos(a + w) * r0, cy + Math.sin(a + w) * r0); c.fill(); }
+ // krackle 在头周围
+ for (let k = 0; k < 6; k++) { const a = k / 6 * TAU + t * 0.8; krackle(c, cx + Math.cos(a) * 200, cy + Math.sin(a) * 250, 30, 40 + k, t, 12); }
+ // 特写猫头
+ const head = new Path2D(); head.ellipse(cx, cy, 150, 132, 0, 0, TAU);
+ const ears = U.poly([[cx - 140, cy - 40], [cx - 120, cy - 200], [cx - 40, cy - 120], [cx + 40, cy - 120], [cx + 120, cy - 200], [cx + 140, cy - 40]]);
+ c.lineJoin = 'round'; c.fillStyle = C.org; c.strokeStyle = INK; c.lineWidth = 8; c.fill(ears); c.stroke(ears); c.fill(head); c.stroke(head);
+ c.save(); c.clip(head); c.fillStyle = PAPER; c.beginPath(); c.ellipse(cx, cy + 80, 96, 72, 0, 0, TAU); c.fill();
+ c.fillStyle = INK; c.beginPath(); c.ellipse(cx + 168, cy + 30, 48, 150, 0, 0, TAU); c.fill(); // 右侧黑块月牙
+ c.strokeStyle = C.orgD; c.lineWidth = 12; [[-40, -128, -30, -80], [0, -132, 0, -84], [40, -128, 30, -80]].forEach(([a, b, d, e]) => { c.beginPath(); c.moveTo(cx + a, cy + b); c.lineTo(cx + d, cy + e); c.stroke(); });
+ c.restore(); c.lineWidth = 8; c.strokeStyle = INK; c.stroke(head);
+ // 眼:瞳孔追着杯子(杯往上→瞳孔往上,往左看)
+ const look = ch.cup;
+ [-62, 62].forEach(dx => { const ex = cx + dx, ey = cy - 18; c.fillStyle = '#b6e04a'; c.beginPath(); c.ellipse(ex, ey, 42, 48, 0, 0, TAU); c.fill(); c.lineWidth = 6; c.stroke();
+ const px = ex - 14, py = ey + lerp(14, -18, look); c.fillStyle = INK; c.beginPath(); c.ellipse(px, py, 10 + look * 6, 30, 0, 0, TAU); c.fill();
+ c.fillStyle = '#fff'; c.beginPath(); c.arc(ex - 22, ey - 22, 8, 0, TAU); c.fill(); });
+ c.fillStyle = '#f07aa0'; c.beginPath(); c.moveTo(cx - 16, cy + 46); c.lineTo(cx + 16, cy + 46); c.lineTo(cx, cy + 64); c.closePath(); c.fill(); c.lineWidth = 4; c.stroke();
+ c.lineWidth = 5; c.beginPath(); c.moveTo(cx - 36, cy + 84); c.quadraticCurveTo(cx - 14, cy + 102, cx, cy + 72); c.quadraticCurveTo(cx + 14, cy + 102, cx + 36, cy + 84); c.stroke();
+ c.lineWidth = 3.5; [[-1, 60], [-1, 76], [1, 60], [1, 76]].forEach(([s, y]) => { c.beginPath(); c.moveTo(cx + s * 70, cy + y); c.lineTo(cx + s * 170, cy + y - 14 + (y - 60)); c.stroke(); });
+ // 旁白
+ c.fillStyle = '#fff'; c.fillRect(x0 + 14, y1 - 132, 308, 100); c.strokeStyle = INK; c.lineWidth = 5; c.strokeRect(x0 + 14, y1 - 132, 308, 100);
+ c.font = '34px "Bangers-400"'; c.fillStyle = INK; c.textAlign = 'center'; c.letterSpacing = '1px'; c.fillText('BUT THE CAT', x0 + 168, y1 - 92); c.fillText('IS WATCHING!', x0 + 168, y1 - 52); c.letterSpacing = '0px'; c.textAlign = 'left';
+ c.restore();
+ }
+ function gutters(c) {
+ c.fillStyle = PAPER; c.fillRect(0, 0, W, 24); c.fillRect(0, H - 24, W, 24); c.fillRect(0, 0, 24, H); c.fillRect(W - 24, 0, 24, H);
+ c.fillRect(1534, 0, 22, H); c.fillRect(1556, 214, W - 1556, 22);
+ c.strokeStyle = INK; c.lineWidth = 7; c.strokeRect(24, 24, 1510, H - 48); c.strokeRect(1556, 236, 340, H - 260);
+ }
+
+ return {
+ draw(c, lt, t) {
+ const ch = P.choreo(lt, t);
+ const G = RIG.girl({ cup: ch.cup, sip: ch.sip, hair: 'long', breathe: ch.breathe });
+ const K = RIG.cat({ tail: ch.tail, blink: ch.blink, breathe: ch.breathe, look: ch.cup });
+ const cc = P.scratch('kbColor'), cg = cc.getContext('2d'), ic = P.scratch('kbInk'), ig = ic.getContext('2d');
+ cg.reset(); ig.reset();
+ room(cg, 'color', t); chars(cg, 'color', t, ch, G, K);
+ room(ig, 'ink', t); chars(ig, 'ink', t, ch, G, K);
+ c.fillStyle = PAPER; c.fillRect(0, 0, W, H);
+ c.drawImage(cc, 4, 3); // 套色不准:色版相对墨版偏 (4,3)
+ c.save(); c.globalCompositeOperation = 'multiply'; c.drawImage(ic, 0, 0); c.restore();
+ speedLines(c, G, lt, t);
+ // 热气 = krackle 小点上升
+ for (let k = 0; k < 4; k++) { const q = ((t * 1.6 + k / 4) % 1); krackle(c, G.cup.x + Math.sin(q * 6 + k) * 14, G.cup.y - 24 - q * 120, 20 * (1 - q * 0.5), 60 + k, t, 9); }
+ sfx(c, lt, t);
+ caption(c);
+ catPanel(c, lt, t, ch);
+ gutters(c);
+ c.save(); c.globalCompositeOperation = 'multiply'; c.drawImage(P.grain('kb', 0.05, [120, 100, 60], 0.25), 0, 0); c.restore();
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/28_monet.js b/scripts/engine/scenes/28_monet.js
new file mode 100644
index 0000000..424e9a1
--- /dev/null
+++ b/scripts/engine/scenes/28_monet.js
@@ -0,0 +1,176 @@
+// 1899 莫奈《睡莲》+《睡莲池上的日本桥》——纯代码。
+// 管线(照 09_postimp 标杆):①平涂底稿(墙=橘园式睡莲壁画、窗=绿色拱桥、地板、桌布)
+// → ②流场笔触分遍重画(水面横笔 / 窗景细笔 / 地板 / 道具),区域色板
+// → ③角色平涂+source-atop 细笔触,只补五官(印象派不勾轮廓)
+// → ④会动的高光:水面光斑颤动(10fps 闪)、睡莲漂浮、柳影横向波动、涟漪扩散、紫藤摆动
+SCENES['28_monet'] = (() => {
+ const W = 1920, H = 1080, TAU = Math.PI * 2, { clamp, lerp } = U, P = PAINT;
+ const WIN = [372, 142, 416, 396]; // 窗内
+ const inWin = (x, y) => x > 360 && x < 800 && y > 130 && y < 550;
+ const inFrame = (x, y) => x > 300 && x < 862 && y > 100 && y < 598;
+ const isFloor = (x, y) => y > 704;
+
+ // 壁画里的睡莲叶丛(固定布局,随时间漂浮)
+ const r0 = U.rng(4242), PADS = [];
+ [[150, 210, 7], [260, 520, 9], [930, 170, 6], [1030, 430, 8], [1640, 330, 7], [1760, 600, 8], [120, 400, 5], [1450, 120, 5], [1250, 600, 6], [700, 640, 7]].forEach(([cx, cy, n], k) => {
+ for (let i = 0; i < n + 3; i++) PADS.push({ x: cx + (r0() - 0.5) * 300, y: cy + (r0() - 0.5) * 90, rx: 38 + r0() * 40, ry: 12 + r0() * 9, notch: r0() * TAU, flower: r0() < 0.4, ph: r0() * TAU, k });
+ });
+ const pad = (p, t) => [p.x + Math.sin(t * 1.3 + p.ph) * 7 + t * 6, p.y + Math.sin(t * 1.9 + p.ph * 1.3) * 2.5];
+
+ function base(g, t) {
+ // ---- 壁画:水面(上浅下深,紫蓝绿) ----
+ const wg = g.createLinearGradient(0, 0, 0, 700); wg.addColorStop(0, '#b9c7e6'); wg.addColorStop(0.35, '#8fa6d6'); wg.addColorStop(0.7, '#6c84bf'); wg.addColorStop(1, '#5a72a8');
+ g.fillStyle = wg; g.fillRect(0, 0, W, 704);
+ // 天光倒影(浅粉黄云)
+ [[600, 120, 260, 50], [1300, 260, 300, 60], [200, 600, 200, 40], [1500, 520, 220, 40]].forEach(([x, y, rx, ry], k) => { g.fillStyle = k % 2 ? '#e8d6e8' : '#f2e2c4'; g.beginPath(); g.ellipse(x + Math.sin(t * 0.8 + k) * 10, y, rx, ry, 0, 0, TAU); g.fill(); });
+ // 柳影(竖向暗绿紫,横向随时间波动)
+ [[70, 0.9], [150, 0.7], [1560, 0.8], [1660, 1], [1840, 0.7]].forEach(([x0, a], k) => {
+ g.fillStyle = k % 2 ? '#3f6a58' : '#4f5f8f';
+ g.beginPath(); for (let y = 0; y <= 700; y += 20) g.lineTo(x0 + Math.sin(y * 0.03 - t * 3.2 + k) * 14, y);
+ for (let y = 700; y >= 0; y -= 20) g.lineTo(x0 + 46 * a + Math.sin(y * 0.03 - t * 3.2 + k + 0.6) * 14, y); g.closePath(); g.fill(); });
+ // 睡莲叶 + 花
+ PADS.forEach(p => { const [x, y] = pad(p, t); g.fillStyle = p.k % 2 ? '#5f8f4a' : '#7aa85a'; g.beginPath(); g.ellipse(x, y, p.rx, p.ry, 0, p.notch + 0.35, p.notch + TAU - 0.35); g.lineTo(x, y); g.closePath(); g.fill();
+ if (p.flower) { g.fillStyle = p.k % 3 ? '#f2a6bf' : '#fbf4f0'; g.beginPath(); g.ellipse(x + 6, y - 7, 17, 10, 0, 0, TAU); g.fill(); g.fillStyle = p.k % 3 ? '#fff2f2' : '#f6d86a'; g.beginPath(); g.ellipse(x + 6, y - 11, 8, 6, 0, 0, TAU); g.fill(); } });
+ // ---- 地板:暖木 ----
+ const fg = g.createLinearGradient(0, 704, 0, H); fg.addColorStop(0, '#b98a6a'); fg.addColorStop(1, '#d6a874'); g.fillStyle = fg; g.fillRect(0, 700, W, H - 700);
+ g.fillStyle = '#7a6a9a'; g.fillRect(0, 696, W, 10);
+ // ---- 窗:日本桥 ----
+ g.save(); g.beginPath(); g.rect(...WIN); g.clip();
+ g.fillStyle = '#3f6a3a'; g.fillRect(...WIN);
+ // 上半:浓密树叶+紫藤
+ for (let i = 0; i < 60; i++) { const r = U.rng(i * 17 + 3), x = 372 + r() * 416, y = 142 + r() * 150; g.fillStyle = ['#4f8a3a', '#6fa040', '#2f5a30', '#9cbf58', '#3a6a5a'][i % 5]; g.beginPath(); g.ellipse(x, y, 30 + r() * 30, 20 + r() * 20, 0, 0, TAU); g.fill(); }
+ // 下半:池水+睡莲(透视:越远越小)
+ const pg = g.createLinearGradient(0, 330, 0, 538); pg.addColorStop(0, '#6f8f9a'); pg.addColorStop(1, '#4f6f8a'); g.fillStyle = pg; g.fillRect(372, 330, 416, 210);
+ for (let row = 0; row < 7; row++) { const y = 352 + row * row * 4.2 + row * 6, s = 0.4 + row * 0.16; for (let i = 0; i < 6; i++) { const x = 380 + ((i * 83 + row * 47) % 420) + Math.sin(t * 1.4 + i + row) * 5;
+ g.fillStyle = (i + row) % 2 ? '#7aa85a' : '#9cc070'; g.beginPath(); g.ellipse(x, y, 28 * s, 7 * s, 0, 0, TAU); g.fill(); if ((i * 3 + row) % 4 === 0) { g.fillStyle = '#f4b0c4'; g.beginPath(); g.arc(x, y - 3 * s, 6 * s, 0, TAU); g.fill(); } } }
+ // 桥的倒影(绿色弧,波动)
+ g.strokeStyle = '#4f8a6a'; g.lineWidth = 9; g.beginPath(); for (let x = 372; x <= 788; x += 8) { const q = (x - 580) / 208, y = 352 + 46 * (1 - q * q) + Math.sin(x * 0.08 + t * 6) * 3; x === 372 ? g.moveTo(x, y) : g.lineTo(x, y); } g.stroke();
+ // 桥:绿色拱+栏杆+竖栏
+ g.fillStyle = '#24452a'; g.beginPath(); for (let x = 350; x <= 810; x += 6) g.lineTo(x, arc(x, 62) - 60); g.lineTo(810, 360); g.lineTo(350, 360); g.closePath(); g.fill(); // 桥后的深色树荫衬底
+ g.restore();
+ }
+ const arc = (x, lift) => { const q = (x - 580) / 230; return 330 - lift * (1 - q * q); };
+ function bridge(g, t) {
+ g.save(); g.beginPath(); g.rect(...WIN); g.clip();
+ g.strokeStyle = '#7fcf9a'; g.lineCap = 'round';
+ g.strokeStyle = '#3f8a62'; g.lineWidth = 20; g.beginPath(); for (let x = 350; x <= 810; x += 6) { const y = arc(x, 62); x === 350 ? g.moveTo(x, y) : g.lineTo(x, y); } g.stroke(); g.strokeStyle = '#8fdcae'; // 桥面
+ g.lineWidth = 8; g.beginPath(); for (let x = 350; x <= 810; x += 6) { const y = arc(x, 62) - 46; x === 350 ? g.moveTo(x, y) : g.lineTo(x, y); } g.stroke(); // 扶手
+ g.lineWidth = 6; g.beginPath(); for (let x = 350; x <= 810; x += 6) { const y = arc(x, 62) - 24; x === 350 ? g.moveTo(x, y) : g.lineTo(x, y); } g.stroke();
+ g.lineWidth = 5; for (let x = 360; x <= 800; x += 30) { g.beginPath(); g.moveTo(x, arc(x, 62)); g.lineTo(x, arc(x, 62) - 46); g.stroke(); }
+ // 紫藤垂花(摆动)
+ for (let i = 0; i < 12; i++) { const x = 386 + i * 36, sw = Math.sin(t * 2.4 + i * 0.9) * 8, L = 40 + (i * 37 % 50); for (let j = 0; j < 9; j++) { const q = j / 8, px = x + sw * q * q + Math.sin(j * 2.1 + i) * 4, py = 150 + L * q * 1.2; g.fillStyle = ['#b8a0dc', '#d6c0ee', '#9a86c8', '#e8dcf6'][(i + j) % 4]; g.beginPath(); g.ellipse(px, py, 8 * (1 - q * 0.6), 6 * (1 - q * 0.5), 0.3, 0, TAU); g.fill(); } }
+ g.restore();
+ }
+ function frameArt(g) {
+ // 窗框(奶白)+两侧绿色百叶(吉维尼的房子)
+ g.fillStyle = '#4f9a6a'; g.fillRect(268, 110, 70, 470); g.fillRect(822, 110, 70, 470);
+ g.lineWidth = 22; g.strokeStyle = '#f3ecdc'; g.strokeRect(357, 127, 446, 426);
+ g.fillStyle = '#f3ecdc'; g.fillRect(570, 142, 18, 396); g.fillRect(330, 548, 500, 28);
+ }
+ function props(g, t) {
+ // 圆桌+白桌布(下垂褶)
+ g.fillStyle = '#f2ecf2'; g.beginPath(); g.moveTo(800, 618); g.lineTo(1214, 618); g.lineTo(1226, 780); for (let x = 1226; x >= 788; x -= 24) g.lineTo(x, 780 + Math.sin(x * 0.12) * 8); g.closePath(); g.fill();
+ g.fillStyle = '#d0c8e6'; for (let x = 830; x < 1200; x += 48) { g.beginPath(); g.moveTo(x, 640); g.lineTo(x + 10, 640); g.lineTo(x + 18, 780); g.lineTo(x + 2, 780); g.closePath(); g.fill(); }
+ g.fillStyle = '#8a6a4a'; g.fillRect(860, 780, 20, 124); g.fillRect(1140, 780, 20, 124);
+ // 蓝白瓷壶+一瓶鸢尾
+ g.fillStyle = '#e8eef8'; g.beginPath(); g.ellipse(900, 596, 40, 30, 0, 0, TAU); g.fill(); g.fillStyle = '#3f6ab8'; g.fillRect(864, 590, 72, 8); g.beginPath(); g.ellipse(900, 566, 18, 6, 0, 0, TAU); g.fill();
+ g.strokeStyle = '#e8eef8'; g.lineWidth = 8; g.beginPath(); g.moveTo(862, 596); g.lineTo(838, 574); g.stroke();
+ g.fillStyle = '#c8d8e0'; g.beginPath(); g.moveTo(1030, 618); g.quadraticCurveTo(1016, 586, 1036, 560); g.lineTo(1060, 560); g.quadraticCurveTo(1080, 586, 1066, 618); g.closePath(); g.fill();
+ g.strokeStyle = '#5f8f4a'; g.lineWidth = 5; [[1040, 560, 1010, 480], [1048, 560, 1052, 456], [1056, 560, 1092, 490]].forEach(([a, b, c2, d], k) => { const sw = Math.sin(t * 2 + k) * 4; g.beginPath(); g.moveTo(a, b); g.lineTo(c2 + sw, d); g.stroke(); g.fillStyle = '#6a5ac8'; g.beginPath(); g.ellipse(c2 + sw, d - 8, 12, 16, 0, 0, TAU); g.fill(); });
+ // 藤椅(椅背在少女身后)
+ g.strokeStyle = '#c9a46a'; g.lineWidth = 12; g.beginPath(); g.moveTo(1440, 900); g.lineTo(1446, 500); g.quadraticCurveTo(1470, 460, 1494, 500); g.lineTo(1488, 900); g.stroke();
+ g.lineWidth = 6; for (let y = 530; y < 720; y += 36) { g.beginPath(); g.moveTo(1446, y); g.lineTo(1490, y); g.stroke(); }
+ }
+ const angle = (x, y, t) => {
+ if (inWin(x, y)) return y < 300 ? -1.2 + 0.8 * P.noise(x * 0.02, y * 0.02) : 0.04 * Math.sin(x * 0.03 + t);
+ if (isFloor(x, y)) return 0.08 + 0.12 * P.noise(x * 0.01, y * 0.01);
+ return 0.06 * Math.sin(y * 0.05 + x * 0.004) + 0.05 * P.noise(x * 0.01, y * 0.01); // 水面:横笔
+ };
+ const SW = {
+ water: P.swatch(['#5b6fb5', '#7d8fd0', '#9db5e0', '#6aa0a8', '#b7a6d8', '#d9c8e8', '#8fb8a8', '#a6c4e8', '#c8b0d8'], 0.45),
+ green: P.swatch(['#5f8f4a', '#7fae5a', '#3f6f4a', '#9cc070', '#6f9a7a', '#b4cc78'], 0.4),
+ pink: P.swatch(['#f0a0b8', '#f7d0dc', '#fff2f4', '#e88aa0'], 0.3),
+ willow: P.swatch(['#3f6a58', '#557a4a', '#2e5048', '#6a5f9a', '#4a6aa0'], 0.4),
+ floor: P.swatch(['#c69a6a', '#b07a5a', '#d8b08a', '#9a6a7a', '#8a7aa8', '#e0bc90'], 0.35),
+ leaf: P.swatch(['#4f7f3a', '#6f9a40', '#2f5a30', '#9cbf58', '#c0d070', '#3a6a5a', '#b8a0dc'], 0.35),
+ };
+ const palette = (x, y, col, r) => {
+ const [R, G, B] = col;
+ if (inWin(x, y)) return (R > 150 && G < 200) || (B > R + 30 && R > 150) ? null : SW.leaf(col, r);
+ if (inFrame(x, y)) return null;
+ if (isFloor(x, y)) return SW.floor(col, r);
+ if (R > 200 && G < 190) return SW.pink(col, r);
+ if (G > R + 15 && G > B - 10) return SW.green(col, r);
+ if (G > R && B < 140) return SW.willow(col, r);
+ return SW.water(col, r);
+ };
+
+ const girlFill = { skin: '#f6d8c4', hair: '#f0cc6a', dress: '#f6f2ec', cuff: '#f6f2ec', shoe: '#d8cce4', cupBody: '#eef2fa', cupRim: '#a8703a', locks: false };
+ return {
+ draw(c, lt, t) {
+ const ch = P.choreo(lt, t);
+ const b = P.scratch('moBase'), bg = b.getContext('2d'); bg.reset(); base(bg, t); frameArt(bg);
+ c.fillStyle = '#e8e0ec'; c.fillRect(0, 0, W, H);
+ c.drawImage(b, 0, 0);
+ // 笔触三遍:水面壁画 / 窗景细笔 / 地板
+ P.strokes(c, b, { cell: 9, len: 34, width: 6.5, angle, seed: 21, t, boil: 6, outline: 0, jitterCol: 14, palette, mask: (x, y) => !isFloor(x, y) && !inFrame(x, y) });
+ P.strokes(c, b, { cell: 6, len: 13, width: 4.5, angle, seed: 22, t, boil: 6, outline: 0, jitterCol: 16, palette, mask: (x, y) => inWin(x, y) });
+ P.strokes(c, b, { cell: 12, len: 34, width: 8, angle, seed: 23, t, boil: 0, outline: 0, jitterCol: 12, palette, mask: isFloor });
+ // 窗框和百叶:细一点的竖/横笔(单独一遍,免得被大笔打碎)
+ P.strokes(c, b, { cell: 6, len: 12, width: 4, seed: 24, t, boil: 0, outline: 0, jitterCol: 18, mask: (x, y) => inFrame(x, y) && !inWin(x, y), angle: (x, y) => (x < 350 || x > 810 || (x > 566 && x < 592)) ? -Math.PI / 2 : 0 });
+ // 桥:单独一层,浅蓝绿细笔(不让树叶色板吞掉)
+ const Bp = P.scratch('moBridge'), bpg = Bp.getContext('2d'); bpg.clearRect(0, 0, W, H); bridge(bpg, t);
+ bpg.save(); bpg.globalCompositeOperation = 'source-atop';
+ P.strokes(bpg, Bp, { cell: 5, len: 10, width: 4, seed: 27, t, boil: 6, outline: 0, alphaMask: true, angle: () => 0.1,
+ palette: (x, y, col, r) => col[1] > 150 && col[0] < 180 ? P.mix(P.hex(['#8fdcae', '#a8e8c0', '#6fc49a', '#c0f0d0', '#7fb8d8'][(r() * 5) | 0]), col, 0.3) : null });
+ bpg.restore(); c.drawImage(Bp, 0, 0);
+ // 水面光斑颤动:横向亮短笔,亮度随时间不规则闪(10fps 换位)
+ const st = Math.floor(t * 10); c.save(); c.lineCap = 'round';
+ for (let i = 0; i < 160; i++) { const r = U.rng(i * 31 + 7), x = r() * W, y = 20 + r() * 670; if (inFrame(x, y)) continue;
+ const a = clamp(Math.sin(t * (5 + r() * 6) + r() * TAU) * Math.sin(t * 2.3 + i), 0, 1); if (a < 0.15) continue;
+ const jx = (U.hash(i, st) - 0.5) * 10; c.strokeStyle = ['#fffbe8', '#fdf0d0', '#f8e0ec', '#e8f4ff'][i % 4]; c.globalAlpha = 0.85 * a; c.lineWidth = 4 + r() * 3;
+ c.beginPath(); c.moveTo(x + jx, y); c.lineTo(x + jx + 14 + r() * 26, y + (r() - 0.5) * 3); c.stroke(); }
+ // 涟漪:两处同心椭圆外扩
+ [[300, 640], [1250, 160], [560, 470]].forEach(([x, y], k) => { for (let j = 0; j < 3; j++) { const q = (t * 0.9 + j / 3 + k * 0.3) % 1; c.globalAlpha = 0.6 * (1 - q); c.strokeStyle = '#eef4ff'; c.lineWidth = 3; c.setLineDash([12, 10]); c.beginPath(); c.ellipse(x, y, 20 + q * 90, (20 + q * 90) * 0.22, 0, 0, TAU); c.stroke(); } });
+ c.setLineDash([]); c.globalAlpha = 1; c.restore();
+ // 道具层:桌布、瓷壶、鸢尾、藤椅
+ const Pr = P.scratch('moProps'), pg = Pr.getContext('2d'); pg.clearRect(0, 0, W, H); props(pg, t);
+ pg.save(); pg.globalCompositeOperation = 'source-atop';
+ P.strokes(pg, Pr, { cell: 6, len: 13, width: 4.5, seed: 25, t, boil: 0, outline: 0, jitterCol: 22, alphaMask: true, angle: (x, y) => (y > 640 && x > 790 && x < 1230) ? -Math.PI / 2 + 0.1 : 0.1,
+ palette: (x, y, col, r) => (col[0] > 225 && col[2] > 225) ? P.mix(P.hex(['#fbf8f4', '#e6e0f4', '#d8d4f0', '#f6ecd8'][(r() * 4) | 0]), col, 0.3) : null });
+ pg.restore(); c.drawImage(Pr, 0, 0);
+ // 角色:平涂 → 笔触 → 五官
+ const L = P.scratch('moChars'), lg = L.getContext('2d'); lg.clearRect(0, 0, W, H);
+ const K = RIG.cat({ tail: ch.tail, blink: ch.blink, breathe: ch.breathe });
+ const G = RIG.girl({ cup: ch.cup, sip: ch.sip, hat: 'straw', hair: 'bun', breathe: ch.breathe });
+ RIG.drawCat(lg, K, { lw: 0, orange: '#ec9a48', white: '#faf2e6', stripe: '#c8702a', face: () => { } });
+ RIG.drawGirl(lg, G, { lw: 0, line: '#111', ...girlFill, features: () => { },
+ hooks: { torso: (c) => { // 1899 白色夏裙:高领+泡泡袖+浅蓝腰带
+ const n = G.A.neck; c.fillStyle = '#f6f2ec'; c.fillRect(n[0] - 16, n[1] - 30, 30, 34);
+ c.strokeStyle = '#8fa8d8'; c.lineWidth = 16; c.beginPath(); c.moveTo(G.A.waist[0] - 60, G.A.waist[1] - 6); c.lineTo(G.A.waist[0] + 70, G.A.waist[1] - 2); c.stroke(); },
+ arm: (c) => { const S = G.A.shoulder; c.fillStyle = '#f6f2ec'; c.beginPath(); c.ellipse(S[0] - 6, S[1] + 22, 42, 52, 0.4, 0, TAU); c.fill(); },
+ head: (c) => { // 草帽(RIG 的帽檐)+蓝丝带飘动
+ c.fillStyle = '#ecd28a'; c.fill(G.brim); c.fill(G.crown); c.fillStyle = '#5f86c8'; c.fill(G.band);
+ const b0 = G.bow, sw = Math.sin(t * 4.5) * 10; c.strokeStyle = '#5f86c8'; c.lineWidth = 10; c.lineCap = 'round'; c.beginPath(); c.moveTo(b0[0], b0[1]); c.quadraticCurveTo(b0[0] + 30, b0[1] + 30 + sw, b0[0] + 46 + sw, b0[1] + 74); c.stroke(); } } });
+ lg.save(); lg.globalCompositeOperation = 'source-atop';
+ P.strokes(lg, L, { cell: 6, len: 12, width: 4.5, seed: 26, t, boil: 0, outline: 0, jitterCol: 18, alphaMask: true,
+ angle: (x, y) => x < 760 ? Math.atan2(y - 780, x - 540) + Math.PI / 2 : -Math.PI / 2 + 0.35 * Math.sin(y * 0.03),
+ palette: (x, y, col, r) => { const L_ = col[0] + col[1] + col[2]; if (x > 900 && L_ > 690) return P.mix(P.hex(['#fbf8f2', '#e4e0f6', '#cfd2ee', '#f8ecd0', '#d8e8f2'][(r() * 5) | 0]), col, 0.25);
+ if (x > 900 && col[0] > 220 && col[1] > 180 && col[2] < 150) return P.mix(P.hex(['#f2d27a', '#e8c060', '#f8e4a0', '#d8a850'][(r() * 4) | 0]), col, 0.3); return null; } });
+ // 受光侧暖、背光侧冷:一层淡紫阴影+暖黄高光(印象派的色彩阴影)
+ lg.globalCompositeOperation = 'source-atop';
+ const sg = lg.createLinearGradient(1150, 0, 1480, 0); sg.addColorStop(0, 'rgba(255,236,170,0.22)'); sg.addColorStop(1, 'rgba(110,100,190,0.32)'); lg.fillStyle = sg; lg.fillRect(1080, 200, 420, 760);
+ const cg = lg.createLinearGradient(400, 0, 700, 0); cg.addColorStop(0, 'rgba(120,110,200,0.25)'); cg.addColorStop(1, 'rgba(255,230,160,0.2)'); lg.fillStyle = cg; lg.fillRect(380, 520, 340, 400);
+ lg.restore();
+ c.drawImage(L, 0, 0);
+ // 五官与猫脸:细紫线(不勾外轮廓)
+ RIG.drawFeatures(c, G, { line: '#5a4f8a', iris: '#4a6ab0', lip: '#d8707a', featureW: 0.9, blink: ch.blink, cheek: 'rgba(240,140,140,.35)' });
+ c.save(); c.strokeStyle = '#5a4f8a'; c.lineWidth = 2.2; c.lineCap = 'round';
+ K.eyes.forEach(e => { if (K.blink) { c.beginPath(); c.arc(e.x, e.y, 7, 0.2, Math.PI - 0.2); c.stroke(); } else { c.fillStyle = '#7ab060'; c.beginPath(); c.arc(e.x, e.y, 8, 0, TAU); c.fill(); c.fillStyle = '#2a2a4a'; c.beginPath(); c.ellipse(e.x + 2, e.y, 2.5, 6, 0, 0, TAU); c.fill(); } });
+ c.fillStyle = '#d8746a'; c.beginPath(); c.arc(K.nose[0], K.nose[1], 5, 0, TAU); c.fill();
+ K.whiskers.forEach(w => { c.beginPath(); c.moveTo(...w[0]); c.lineTo(...w[1]); c.stroke(); });
+ c.restore();
+ P.steam(c, t, G.cup.x, G.cup.y - 6, { h: 70, n: 2, color: 'rgba(250,246,255,.8)', width: 5, spread: 14, wobble: 9 });
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/29_seurat.js b/scripts/engine/scenes/29_seurat.js
new file mode 100644
index 0000000..3cb8617
--- /dev/null
+++ b/scripts/engine/scenes/29_seurat.js
@@ -0,0 +1,104 @@
+// 1884 修拉《大碗岛的星期天下午》——纯代码点彩。
+// 管线:①整幅平涂底稿(含角色,每帧重画,几毫秒)
+// → ②底层:底稿模糊提亮当「打底色」(点与点的缝里露出来)
+// → ③点彩渲染器:固定六角网格、点大小一致(pitch 10、r 4.5);每个点按「视觉混色」从 14 色纯色板里挑:
+// 找一对纯色 (i,j) 和比例 w∈{0,¼,½,¾,1} 使 w·Pi+(1-w)·Pj 最接近目标色,再用格子哈希 < w 决定这一点是 i 还是 j
+// + 12% 概率换成补色点(绿里的橙、蓝里的橙、橙里的蓝)+ 明暗交界处的光渗(亮侧加白、暗侧加深蓝)
+// → ④修拉自己画的点彩边框(深蓝+橙)
+// 静穆:点的位置不动,只有底稿变了的地方点才换色。母题:河上帆船漂移、水面点闪(6fps 换哈希)、蝴蝶扑翅、汽船冒烟。
+SCENES['29_seurat'] = (() => {
+ const W = 1920, H = 1080, TAU = Math.PI * 2, { clamp, lerp } = U, P = PAINT;
+ const PAL = ['#1a2058', '#2a3a9a', '#3f6fd0', '#6aaee6', '#1f6a52', '#2f9a5a', '#a8c83a', '#f2cf3a', '#f08a2a', '#e0432a', '#c0306a', '#7a4aa8', '#f8f4e8', '#e8b48a', '#f6e49a', '#f6c48a', '#cfe08a', '#b0cff0', '#f2b8c8', '#c99a4a', '#9a7ac8'];
+ // 补色索引:每个纯色对应的「对比色」
+ const COMP = { 0: 8, 1: 8, 2: 8, 3: 9, 4: 9, 5: 10, 6: 11, 7: 11, 8: 2, 9: 5, 10: 5, 11: 7, 12: 17, 13: 17, 14: 20, 15: 17, 16: 18, 17: 15, 18: 16, 19: 2, 20: 14 };
+
+ // ---- 底稿 ----
+ const WIN = [372, 142, 416, 396];
+ const inWater = (x, y) => x > 372 && x < 788 && y > 300 && y < 380;
+ function base(g, t, ch, G, K) {
+ // 墙:阳光奶黄,右侧转冷
+ const wg = g.createLinearGradient(0, 0, W, 0); wg.addColorStop(0, '#f0d488'); wg.addColorStop(0.55, '#ecc88e'); wg.addColorStop(1, '#b4aecc'); g.fillStyle = wg; g.fillRect(0, 0, W, 700);
+ // 墙上窗投下的光斑
+ g.fillStyle = '#f8e8a0'; g.beginPath(); g.moveTo(880, 140); g.lineTo(1120, 180); g.lineTo(1120, 560); g.lineTo(880, 560); g.closePath(); g.fill();
+ // 地板:暖橙木,阴影紫
+ const fg = g.createLinearGradient(0, 700, 0, H); fg.addColorStop(0, '#c08a58'); fg.addColorStop(1, '#dca86a'); g.fillStyle = fg; g.fillRect(0, 700, W, H - 700);
+ g.fillStyle = '#5a4a7a'; g.fillRect(0, 696, W, 10);
+ g.fillStyle = 'rgba(70,50,110,.55)'; g.beginPath(); g.ellipse(560, 915, 170, 22, 0, 0, TAU); g.fill(); g.beginPath(); g.ellipse(1010, 910, 220, 18, 0, 0, TAU); g.fill(); g.beginPath(); g.ellipse(1300, 930, 200, 18, 0, 0, TAU); g.fill();
+ // ---- 窗:大碗岛 ----
+ g.save(); g.beginPath(); g.rect(...WIN); g.clip();
+ const sg = g.createLinearGradient(0, 142, 0, 300); sg.addColorStop(0, '#bcd4ec'); sg.addColorStop(1, '#e8eef0'); g.fillStyle = sg; g.fillRect(372, 142, 416, 160);
+ g.fillStyle = '#3f7a4a'; g.beginPath(); g.moveTo(372, 300); for (let x = 372; x <= 788; x += 26) g.lineTo(x, 280 - Math.abs(Math.sin(x * 0.04)) * 30); g.lineTo(788, 302); g.closePath(); g.fill(); // 对岸树
+ g.fillStyle = '#3d6fc0'; g.fillRect(372, 300, 416, 80); // 塞纳河
+ // 帆船(漂移)+汽船烟
+ [[0, 470, 1], [1, 690, 0.8]].forEach(([k, x0, s]) => { const x = 372 + ((x0 - 372 + t * 40 * (k ? -0.7 : 1)) % 416 + 416) % 416, y = 336 + k * 12;
+ g.fillStyle = '#f8f4e8'; g.beginPath(); g.moveTo(x, y); g.lineTo(x, y - 46 * s); g.lineTo(x + 28 * s, y); g.closePath(); g.fill(); g.fillStyle = '#7a4a3a'; g.fillRect(x - 18 * s, y, 50 * s, 7 * s); });
+ const sx = 420 + t * 18; g.fillStyle = '#2a2a3a'; g.fillRect(sx, 316, 46, 10); g.fillRect(sx + 26, 300, 7, 16);
+ for (let i = 0; i < 5; i++) { const q = (t * 0.8 + i / 5) % 1; g.fillStyle = `rgba(200,200,210,${0.9 - q * 0.6})`; g.beginPath(); g.arc(sx + 30 - q * 40, 292 - q * 50, 8 + q * 14, 0, TAU); g.fill(); }
+ // 草地:前景阳光黄绿,树荫翠绿
+ g.fillStyle = '#b8c84a'; g.fillRect(372, 380, 416, 160);
+ g.fillStyle = '#2f6a4a'; g.beginPath(); g.moveTo(372, 430); g.quadraticCurveTo(520, 400, 640, 440); g.lineTo(640, 540); g.lineTo(372, 540); g.closePath(); g.fill();
+ // 树干(右)+树冠
+ g.fillStyle = '#4a3a3a'; g.fillRect(730, 150, 22, 390); g.fillStyle = '#1f5a3a'; g.beginPath(); g.ellipse(740, 150, 120, 60, 0, 0, TAU); g.fill();
+ // 撑伞的侧影女士(大碗岛的标志:裙撑+阳伞)+小猴
+ const lx = 600, ly = 520;
+ g.fillStyle = '#23244a'; g.beginPath(); g.moveTo(lx, ly); g.lineTo(lx + 4, ly - 70); g.quadraticCurveTo(lx + 30, ly - 60, lx + 34, ly - 30); g.quadraticCurveTo(lx + 44, ly - 10, lx + 36, ly); g.closePath(); g.fill(); // 裙+裙撑
+ g.beginPath(); g.ellipse(lx + 6, ly - 84, 8, 12, 0, 0, TAU); g.fill(); g.fillRect(lx - 1, ly - 76, 14, 14);
+ g.fillStyle = '#c8603a'; g.beginPath(); g.ellipse(lx + 4, ly - 112, 30, 12, 0, Math.PI, TAU); g.fill(); g.strokeStyle = '#23244a'; g.lineWidth = 2; g.beginPath(); g.moveTo(lx + 4, ly - 112); g.lineTo(lx + 8, ly - 70); g.stroke();
+ g.fillStyle = '#4a3a3a'; g.beginPath(); g.ellipse(lx - 30, ly - 6, 10, 7, 0, 0, TAU); g.fill(); g.strokeStyle = '#4a3a3a'; g.lineWidth = 3; g.beginPath(); g.moveTo(lx - 40, ly - 6); g.quadraticCurveTo(lx - 54, ly - 20, lx - 44, ly - 28); g.stroke();
+ // 蝴蝶(扑翅)
+ const bx = 470 + Math.sin(t * 2.2) * 60, by = 420 + Math.sin(t * 3.7) * 30, fl = Math.abs(Math.sin(t * 22));
+ g.fillStyle = '#f08a2a'; g.beginPath(); g.ellipse(bx - 8, by, 10 * fl + 2, 7, -0.4, 0, TAU); g.ellipse(bx + 8, by, 10 * fl + 2, 7, 0.4, 0, TAU); g.fill();
+ g.restore();
+ // 窗框(白)+窗台
+ g.lineWidth = 22; g.strokeStyle = '#f2ede0'; g.strokeRect(357, 127, 446, 426); g.fillStyle = '#f2ede0'; g.fillRect(570, 142, 18, 396); g.fillRect(330, 548, 500, 28);
+ // 曲木椅(索耐特)
+ g.strokeStyle = '#4a2a2a'; g.lineWidth = 12; g.lineCap = 'round'; g.beginPath(); g.moveTo(1450, 900); g.lineTo(1452, 520); g.quadraticCurveTo(1478, 470, 1500, 530); g.lineTo(1486, 900); g.stroke(); g.beginPath(); g.ellipse(1474, 600, 18, 60, 0, 0, TAU); g.stroke();
+ // 桌:白桌布
+ g.fillStyle = '#f2eee0'; g.fillRect(806, 616, 404, 140); g.fillStyle = '#9aa6d8'; for (let x = 830; x < 1200; x += 60) g.fillRect(x, 640, 14, 116);
+ g.fillStyle = '#6a3a2a'; g.fillRect(846, 756, 22, 148); g.fillRect(1150, 756, 22, 148);
+ // 茶壶(白瓷)+一束罂粟
+ g.fillStyle = '#f6f2ea'; g.beginPath(); g.ellipse(900, 590, 40, 30, 0, 0, TAU); g.fill(); g.fillStyle = '#e0432a'; [[1030, 540], [1052, 520], [1074, 546]].forEach(([x, y]) => { g.beginPath(); g.arc(x, y, 14, 0, TAU); g.fill(); });
+ g.strokeStyle = '#2f9a5a'; g.lineWidth = 5; [[1030, 540], [1052, 520], [1074, 546]].forEach(([x, y]) => { g.beginPath(); g.moveTo(x, y + 12); g.lineTo(1052, 616); g.stroke(); });
+ // 角色(平涂,进点彩)
+ RIG.drawCat(g, K, { lw: 0, orange: '#ec8a34', white: '#f8f2e4', stripe: '#c0501a', stripeW: 9, face: (c, K) => {
+ K.eyes.forEach(e => { c.fillStyle = K.blink ? '#c0501a' : '#2f9a5a'; c.beginPath(); c.arc(e.x, e.y, 9, 0, TAU); c.fill(); if (!K.blink) { c.fillStyle = '#1a2058'; c.beginPath(); c.arc(e.x + 2, e.y, 4, 0, TAU); c.fill(); } });
+ c.fillStyle = '#e0605a'; c.beginPath(); c.arc(K.nose[0], K.nose[1], 6, 0, TAU); c.fill(); } });
+ RIG.drawGirl(g, G, { lw: 0, line: '#111', locks: false, skin: '#f2cca8', hair: '#f0c850', dress: '#2c2c64', sleeve: '#2c2c64', cuff: '#f2eee0', shoe: '#1a2058', cupBody: '#f6f2ea', cupRim: '#9a5a2a',
+ features: (c, G) => { c.fillStyle = '#1a2058'; c.beginPath(); c.arc(G.eye.x, G.eye.y, 4.5, 0, TAU); c.fill(); c.fillStyle = '#d8584a'; c.beginPath(); c.arc(G.lips[1][0] - 2, G.lips[1][1] + 2, 4, 0, TAU); c.fill();
+ c.fillStyle = 'rgba(232,120,110,.6)'; c.beginPath(); c.arc(G.cheek[0], G.cheek[1], 11, 0, TAU); c.fill(); },
+ hooks: {
+ back: (c, G) => { // 1880 年代裙撑(腰后鼓起)
+ const w = G.A.waist; c.fillStyle = '#2c2c64'; c.beginPath(); c.moveTo(w[0] - 10, w[1] - 10); c.quadraticCurveTo(w[0] + 110, w[1] - 6, w[0] + 98, w[1] + 90); c.quadraticCurveTo(w[0] + 60, w[1] + 140, w[0] - 10, w[1] + 120); c.closePath(); c.fill(); },
+ torso: (c, G) => { // 高领白蕾丝+前襟一排橙色纽
+ const n = G.A.neck; c.fillStyle = '#f2eee0'; c.fillRect(n[0] - 18, n[1] - 26, 34, 30);
+ c.fillStyle = '#f08a2a'; [0, 1, 2, 3].forEach(i => { c.beginPath(); c.arc(G.A.chest[0] + 4, G.A.chest[1] - 30 + i * 28, 5, 0, TAU); c.fill(); }); },
+ head: (c, G) => { // 小圆帽+红羽毛(大碗岛女帽)
+ const h = G.A.headTop; c.save(); c.translate(h[0], h[1]); c.rotate(G.tilt - 0.15);
+ c.fillStyle = '#2a3a9a'; c.beginPath(); c.ellipse(0, 4, 64, 12, 0, 0, TAU); c.fill(); c.beginPath(); c.ellipse(4, -10, 36, 22, 0, Math.PI, TAU); c.fill();
+ c.fillStyle = '#e0432a'; c.beginPath(); c.ellipse(34, -20, 26, 8, -0.6, 0, TAU); c.fill(); c.restore(); } } });
+ // 椅背上靠着一把收拢的阳伞
+ g.strokeStyle = '#4a2a2a'; g.lineWidth = 4; g.beginPath(); g.moveTo(1510, 900); g.lineTo(1556, 560); g.stroke();
+ g.fillStyle = '#e0432a'; g.beginPath(); g.moveTo(1550, 610); g.lineTo(1560, 560); g.lineTo(1528, 760); g.lineTo(1518, 752); g.closePath(); g.fill();
+ // 室内的蝴蝶(大碗岛画面中央那只),在桌上方扑翅绕飞
+ { const bx = 1000 + Math.sin(t * 2.6) * 120, by = 400 + Math.sin(t * 4.1) * 50 - t * 20, fl = 0.25 + 0.75 * Math.abs(Math.sin(t * 20)), dir = Math.cos(t * 2.6) > 0 ? 1 : -1;
+ g.save(); g.translate(bx, by); g.scale(dir, 1); g.fillStyle = '#f08a2a'; g.beginPath(); g.ellipse(-14, -6, 22 * fl, 16, -0.5, 0, TAU); g.ellipse(14, -6, 22 * fl, 16, 0.5, 0, TAU); g.fill();
+ g.fillStyle = '#e0432a'; g.beginPath(); g.ellipse(-10, 10, 12 * fl, 9, -0.2, 0, TAU); g.ellipse(10, 10, 12 * fl, 9, 0.2, 0, TAU); g.fill(); g.fillStyle = '#1a2058'; g.fillRect(-2, -14, 4, 28); g.restore(); }
+ // 修拉画的边框:深蓝带
+ g.fillStyle = '#1e2a78'; g.fillRect(0, 0, W, 28); g.fillRect(0, H - 28, W, 28); g.fillRect(0, 0, 28, H); g.fillRect(W - 28, 0, 28, H);
+ }
+
+ return {
+ draw(c, lt, t) {
+ const ch = P.choreo(lt, t);
+ const G = RIG.girl({ cup: ch.cup, sip: ch.sip, hair: 'bun', breathe: ch.breathe });
+ const K = RIG.cat({ tail: ch.tail, blink: ch.blink, breathe: ch.breathe });
+ const b = P.scratch('seBase'), bg = b.getContext('2d', { willReadFrequently: true }); bg.reset(); base(bg, t, ch, G, K);
+ // 打底:模糊提亮
+ c.save(); c.filter = 'blur(4px) saturate(0.85) brightness(1.06)'; c.drawImage(b, 0, 0); c.restore();
+ // 点彩:P.pointillism——等大点、纯色板两两并置做视觉混色;水面点 6fps 重掷=波光;12=白点、0=深蓝点做光渗
+ P.pointillism(c, b, { pal: PAL, comp: COMP, t, fps: 6, shimmer: inWater, white: 12, dark: 0 });
+ // 边框内沿一道细深线(修拉画框的收边)
+ c.strokeStyle = 'rgba(20,24,70,.8)'; c.lineWidth = 3; c.strokeRect(29, 29, W - 58, H - 58);
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/30_matisse.js b/scripts/engine/scenes/30_matisse.js
new file mode 100644
index 0000000..2617fd7
--- /dev/null
+++ b/scripts/engine/scenes/30_matisse.js
@@ -0,0 +1,151 @@
+// 1947 马蒂斯《爵士》剪纸(Jazz / Polynesia / Icarus / Lagoon)——纯代码。
+// 手法:一切是「刷过水粉的彩纸剪出来、钉在墙上」:
+// ①剪形:自生成形状一律做成剪刀折线(沿轮廓每 14–24px 取点+±2.5px 抖动、直线相连)
+// ②RIG 角色的 Path2D 拿不到点 → 角色整层画完后做低频位移(fbm 波长≈35px、幅度 5px)让边缘像手剪的
+// ③每张纸带投影(偏移 5,6、模糊 4、α.28)=钉在墙上
+// ④整幅叠水粉刷痕(缓存的长条笔痕,overlay)
+// 母题:海藻像纸片一样绕根部摆动+卷边(scaleX 呼吸)、伊卡洛斯的黄星转动闪、红心跳、一片黄纸翻飞飘落、白鸟扑翅。
+SCENES['30_matisse'] = (() => {
+ const W = 1920, H = 1080, TAU = Math.PI * 2, { clamp, lerp } = U, P = PAINT;
+ const C = { cobalt: '#1d4fb8', sky: '#4f95dc', yel: '#f7d21e', red: '#e2322a', black: '#141414', white: '#f7f3e8', green: '#1f9a5a', pink: '#ef6f9a', org: '#f28a24', orgD: '#c8521a', skin: '#f3c9a6', violet: '#5b3a9a' };
+ const cut = P.cut; // 剪刀折线:沿轮廓每 step px 取点+抖动、直线相连
+ // 海藻形(马蒂斯 Lagoon/Polynesia 里那种):锥形茎 + 左右交替伸出的圆头「手指」。
+ // 每块都是剪刀折线;同向绕行的子路径用 nonzero 一次填充=并集(投影也只算一次)。
+ function capsule(A, th, L, w) { // th:相对竖直向上的角度
+ const d = [Math.sin(th), -Math.cos(th)], n = [-d[1], d[0]], T = [A[0] + d[0] * (L - w / 2), A[1] + d[1] * (L - w / 2)], pts = [];
+ pts.push([A[0] + n[0] * w * 0.42, A[1] + n[1] * w * 0.42]);
+ pts.push([A[0] + d[0] * L * 0.5 + n[0] * w * 0.55, A[1] + d[1] * L * 0.5 + n[1] * w * 0.55]);
+ for (let k = 0; k <= 6; k++) { const a = Math.atan2(n[1], n[0]) - k / 6 * Math.PI; pts.push([T[0] + Math.cos(a) * w / 2, T[1] + Math.sin(a) * w / 2]); }
+ pts.push([A[0] + d[0] * L * 0.5 - n[0] * w * 0.55, A[1] + d[1] * L * 0.5 - n[1] * w * 0.55]);
+ pts.push([A[0] - n[0] * w * 0.42, A[1] - n[1] * w * 0.42]);
+ return pts;
+ }
+ function algaeShape(len, width, lobes, seed, bend) {
+ const r = U.rng(seed), p = new Path2D(), sp = u => [Math.sin(u * 1.6) * bend * len * 0.25, -u * len];
+ p.addPath(cut(capsule(sp(0), bend * 0.2, len, width * 0.24), seed, 16, 2));
+ const n = Math.round(lobes * 2);
+ for (let k = 0; k < n; k++) { const u = 0.12 + 0.78 * k / Math.max(1, n - 1), side = k % 2 ? 1 : -1, A = sp(u);
+ const th = side * (1.05 - 0.55 * u) + bend * 0.2 + (r() - 0.5) * 0.25, L = width * (1.0 - 0.45 * u) * (0.8 + r() * 0.3), w = width * (0.34 - 0.12 * u);
+ p.addPath(cut(capsule(A, th, L, w), seed + k * 11, 15, 1.8)); }
+ return p;
+ }
+ const shapeCache = {};
+ const algaePath = (k, len, width, lobes, bend) => shapeCache['a' + k] || (shapeCache['a' + k] = algaeShape(len, width, lobes, k * 7 + 3, bend));
+ const starPath = (k, r0, r1, n) => shapeCache['s' + k] || (shapeCache['s' + k] = (() => { const r = U.rng(k * 31 + 5), pts = []; for (let i = 0; i < n * 2; i++) { const a = i / (n * 2) * TAU + (r() - 0.5) * 0.25, rr = (i % 2 ? r1 : r0) * (0.75 + r() * 0.45); pts.push([Math.cos(a) * rr, Math.sin(a) * rr]); } return cut(pts, k * 17, 14, 1.8); })());
+ const birdPath = () => shapeCache.bird || (shapeCache.bird = cut([[0, 0], [-26, -14], [-58, -10], [-34, 2], [-62, 18], [-18, 10], [0, 22], [24, 8], [50, 12], [30, -2], [44, -18]], 99, 12, 1.6));
+ const paperShadow = (c, fn) => { c.save(); c.shadowColor = 'rgba(10,20,40,.3)'; c.shadowOffsetX = 5; c.shadowOffsetY = 6; c.shadowBlur = 4; fn(); c.restore(); };
+ const placed = (c, path, x, y, rot, sx, sy, col) => { c.save(); c.translate(x, y); c.rotate(rot); c.scale(sx, sy); c.fillStyle = col; c.fill(path); c.restore(); };
+
+ // ---- 静态底:墙的双蓝棋盘(剪纸块)+地+桌(缓存) ----
+ const bg = () => P.cached('mt_bg', W, H, (g) => {
+ g.fillStyle = C.white; g.fillRect(0, 0, W, H);
+ const cw = 240, chh = 236;
+ for (let j = 0; j < 3; j++) for (let i = 0; i < 8; i++) { const x = i * cw, y = j * chh, r = U.rng(i * 7 + j * 31);
+ g.fillStyle = (i + j) % 2 ? C.cobalt : C.sky;
+ g.fill(cut([[x - 2 + r() * 4, y - 2], [x + cw + 2, y + r() * 4 - 2], [x + cw + r() * 4, y + chh + 2], [x - 2, y + chh + r() * 4]], i * 13 + j, 22, 2)); }
+ // 地:翠绿纸+黑踢脚条
+ g.fillStyle = C.green; g.fill(cut([[0, 704], [W, 698], [W, H], [0, H]], 5, 24, 2.5));
+ g.fillStyle = C.black; g.fill(cut([[0, 690], [W, 686], [W, 712], [0, 716]], 6, 20, 2));
+ // 地上的粉色大圆片、黄色剪纸碎片(《爵士》的散落纸片)
+ paperShadow(g, () => { g.fillStyle = C.pink; g.fill(cut(Array.from({ length: 24 }, (_, k) => [180 + Math.cos(k / 24 * TAU) * 120, 990 + Math.sin(k / 24 * TAU) * 44]), 8, 18, 3)); });
+ // 窗:白纸框里的《伊卡洛斯》蓝底
+ paperShadow(g, () => { g.fillStyle = C.white; g.fill(cut([[344, 114], [818, 118], [814, 568], [340, 564]], 11, 26, 2)); });
+ g.fillStyle = C.cobalt; g.fill(cut([[372, 142], [790, 144], [788, 540], [370, 538]], 12, 24, 2));
+ paperShadow(g, () => { g.fillStyle = C.white; g.fill(cut([[326, 550], [836, 552], [834, 584], [324, 582]], 13, 24, 2)); });
+ // 桌:黑色剪纸桌面+两条腿
+ paperShadow(g, () => { g.fillStyle = C.black; g.fill(cut([[806, 616], [1212, 612], [1206, 648], [810, 652]], 14, 20, 2)); g.fill(cut([[846, 648], [872, 648], [878, 904], [842, 906]], 15, 20, 2)); g.fill(cut([[1150, 648], [1176, 648], [1182, 904], [1146, 906]], 16, 20, 2)); });
+ // 椅:黄色剪纸椅背
+ paperShadow(g, () => { g.fillStyle = C.yel; g.fill(cut([[1430, 480], [1488, 470], [1500, 900], [1470, 902], [1462, 560], [1442, 560], [1446, 902], [1420, 902]], 17, 18, 2)); });
+ });
+ // 水粉刷痕叠层
+ const gouache = () => P.cached('mt_gouache', W, H, (g) => {
+ const r = U.rng(2024); g.lineCap = 'round';
+ for (let i = 0; i < 2600; i++) { const x = r() * W, y = r() * H, a = -0.25 + (r() - 0.5) * 0.5, L = 60 + r() * 240;
+ g.strokeStyle = r() < 0.5 ? `rgba(255,255,255,${0.05 + r() * 0.07})` : `rgba(0,0,0,${0.04 + r() * 0.06})`; g.lineWidth = 6 + r() * 16;
+ g.beginPath(); g.moveTo(x, y); g.lineTo(x + Math.cos(a) * L, y + Math.sin(a) * L); g.stroke(); }
+ });
+ // 角色层的「手剪」位移场(静态)
+ const BX = [330, 470, 1600, 980]; // x0,y0,x1,y1(猫+桌上+少女)
+ const roughen = layer => P.roughen(layer, BX, { freq: 0.028, amp: 9, key: 'matisse' }); // 整层低频位移=手剪边
+
+ // ---- 会动的剪纸母题 ----
+ const ALGAE = [ // x,y(根), 长, 宽, 叶数, 弯, 颜色, 相位
+ [110, 690, 400, 150, 3.5, 0.4, C.white, 0], [1600, 690, 440, 160, 4, -0.4, C.white, 1.3], [1810, 690, 300, 130, 3, 0.3, C.yel, 2.1],
+ [250, 470, 230, 110, 2.5, -0.3, C.white, 3.1], [1010, 540, 280, 120, 3, 0.3, C.pink, 0.7], [1780, 440, 200, 100, 2.5, 0.3, C.white, 2.6],
+ ];
+ function wallLife(c, t) {
+ ALGAE.forEach(([x, y, len, wd, lobes, bend, col, ph], k) => {
+ const rot = Math.sin(t * 2.8 + ph) * 0.13, sx = 0.93 + 0.07 * Math.sin(t * 3.6 + ph * 1.7); // 摆+卷边
+ paperShadow(c, () => placed(c, algaePath(k, len, wd, lobes, bend), x, y, rot, sx, 1, col));
+ });
+ // 白鸟(《波利尼西亚》)扑翅滑过
+ [[1220, 120, 0], [190, 160, 1.7]].forEach(([x0, y0, ph], k) => { const x = x0 + Math.sin(t * 1.2 + ph) * 40, y = y0 + Math.sin(t * 2.4 + ph) * 12, fl = 0.55 + 0.45 * Math.cos(t * 13 + ph);
+ paperShadow(c, () => placed(c, birdPath(), x, y, -0.15 + Math.sin(t * 2 + ph) * 0.08, 1.5, 1.5 * fl, C.white)); });
+ }
+ function icarus(c, t) {
+ c.save(); c.beginPath(); c.rect(372, 142, 418, 398); c.clip();
+ // 黄星:转+闪
+ [[420, 190, 34, 0], [740, 200, 42, 1], [460, 470, 30, 2], [752, 452, 36, 3], [560, 180, 22, 4], [700, 330, 26, 5], [410, 340, 24, 6]].forEach(([x, y, r, k]) => {
+ const s = 0.82 + 0.22 * Math.sin(t * 7 + k * 1.9); placed(c, starPath(k, r, r * 0.42, 5 + (k % 3)), x, y, t * (k % 2 ? 0.8 : -0.6), s, s, C.yel); });
+ // 伊卡洛斯:黑色人形,两臂张开,上下漂
+ const by = Math.sin(t * 2.4) * 10, ax = Math.sin(t * 3.1) * 0.12;
+ c.save(); c.translate(580, 340 + by); c.rotate(-0.08 + Math.sin(t * 1.7) * 0.05); c.fillStyle = C.black;
+ c.fill(shapeCache.icarus || (shapeCache.icarus = cut([[0, -118], [18, -112], [22, -90], [12, -78], [44, -70], [96, -94], [118, -84], [64, -40], [40, -20], [52, 40], [86, 110], [66, 118], [26, 60], [6, 40], [-18, 64], [-48, 118], [-70, 108], [-36, 40], [-40, -20], [-66, -42], [-118, -76], [-100, -92], [-44, -70], [-12, -78], [-22, -92], [-18, -112]], 77, 14, 1.8)));
+ const hb = 1 + 0.18 * Math.max(0, Math.sin(t * 9)); c.fillStyle = C.red; c.beginPath(); c.ellipse(6, -44, 14 * hb, 13 * hb, 0, 0, TAU); c.fill(); // 红心跳
+ c.restore();
+ c.restore();
+ }
+ function fallingPaper(c, t) {
+ // 一片黄纸从左上翻飞飘到右下(scaleX=cos 做翻面)
+ const q = (t * 0.32 + 0.15) % 1, x = lerp(130, 320, q) + Math.sin(t * 3) * 60, y = lerp(-60, 640, q), fl = Math.cos(t * 6);
+ paperShadow(c, () => placed(c, algaePath(20, 110, 60, 2.5, 0.2), x, y, t * 1.4, fl, 1, C.pink));
+ }
+
+ // ---- 角色 ----
+ function chars(g, t, ch, G, K) {
+ RIG.drawCat(g, K, { lw: 0, orange: C.org, white: C.white, stripe: C.orgD, stripeW: 12, earInner: C.pink,
+ face: (c, K) => { K.eyes.forEach(e => { c.fillStyle = K.blink ? C.orgD : C.green; c.beginPath(); c.ellipse(e.x, e.y, 10, K.blink ? 3 : 9, 0, 0, TAU); c.fill(); if (!K.blink) { c.fillStyle = C.black; c.beginPath(); c.ellipse(e.x + 2, e.y, 3, 7, 0, 0, TAU); c.fill(); } });
+ c.fillStyle = C.pink; c.beginPath(); c.moveTo(K.nose[0] - 7, K.nose[1] - 4); c.lineTo(K.nose[0] + 7, K.nose[1] - 4); c.lineTo(K.nose[0], K.nose[1] + 6); c.fill(); } });
+ // 少女:马蒂斯《罗马尼亚衬衫》——白色宽袖刺绣衬衫+红长裙+黑腰带
+ RIG.drawGirl(g, G, { lw: 0, line: '#111', locks: false, skin: C.skin, hair: C.yel, dress: C.white, skirt: C.red, sleeve: C.white, cuff: C.white, shoe: C.black, cupBody: C.yel, cupRim: C.orgD,
+ features: (c, G) => { c.fillStyle = C.black; c.beginPath(); c.ellipse(G.eye.x - 1, G.eye.y + 1, 7, ch.blink ? 1.5 : 4, 0, 0, TAU); c.fill();
+ c.save(); c.translate(0, -3); c.strokeStyle = C.black; c.lineWidth = 3.5; c.stroke(G.brow); c.restore();
+ c.fillStyle = C.red; c.beginPath(); c.moveTo(...G.lips[0]); c.lineTo(...G.lips[1]); c.lineTo(...G.lips[2]); c.closePath(); c.fill(); c.fillStyle = C.pink; c.beginPath(); c.arc(G.cheek[0], G.cheek[1], 10, 0, TAU); c.fill(); },
+ hooks: {
+ skirt: (c, G) => { c.fillStyle = C.black; const w = G.A.waist; c.fillRect(w[0] - 70, w[1] - 14, 150, 22); },
+ torso: (c, G) => { // 前襟刺绣竖带:红蓝交错的小三角
+ const ch0 = G.A.chest; c.fillStyle = C.cobalt; c.fillRect(ch0[0] - 6, ch0[1] - 60, 18, 150);
+ for (let i = 0; i < 9; i++) { c.fillStyle = i % 2 ? C.red : C.yel; c.beginPath(); c.moveTo(ch0[0] - 6, ch0[1] - 56 + i * 16); c.lineTo(ch0[0] + 12, ch0[1] - 48 + i * 16); c.lineTo(ch0[0] - 6, ch0[1] - 40 + i * 16); c.fill(); } },
+ head: (c, G) => { // 卷曲金发:一圈剪纸卷团
+ const h = G.A.headC; c.fillStyle = C.yel; [[60, -40, 30], [82, 4, 28], [70, 46, 26], [30, -64, 26], [-8, -66, 22]].forEach(([dx, dy, r]) => { c.beginPath(); c.arc(h[0] + dx, h[1] + dy, r, 0, TAU); c.fill(); }); },
+ arm: (c, G) => { // 袖上的刺绣横带(随手臂走)
+ const S = G.A.shoulder, E = G.A.elbow; c.save(); c.clip(G.upperArm);
+ const a = Math.atan2(E[1] - S[1], E[0] - S[0]); [0.25, 0.45].forEach((q, k) => { const x = lerp(S[0], E[0], q), y = lerp(S[1], E[1], q); c.save(); c.translate(x, y); c.rotate(a + Math.PI / 2);
+ c.fillStyle = k ? C.cobalt : C.red; c.fillRect(-40, -8, 80, 16); c.fillStyle = C.yel; for (let i = -3; i <= 3; i++) { c.beginPath(); c.arc(i * 11, 0, 4, 0, TAU); c.fill(); } c.restore(); });
+ c.restore(); } } });
+ }
+
+ return {
+ draw(c, lt, t) {
+ const ch = P.choreo(lt, t);
+ c.drawImage(bg(), 0, 0);
+ icarus(c, t);
+ wallLife(c, t);
+ // 桌上:白茶壶、一碗黄柠檬(剪纸)
+ paperShadow(c, () => { c.fillStyle = C.white; c.fill(shapeCache.pot || (shapeCache.pot = cut([[860, 616], [850, 584], [866, 556], [906, 548], [944, 556], [958, 588], [950, 616]], 51, 14, 1.8))); c.fill(shapeCache.spout || (shapeCache.spout = cut([[856, 590], [822, 560], [832, 552], [868, 578]], 52, 10, 1.4)));
+ c.fillStyle = C.yel; [[1040, 596], [1072, 592], [1056, 572]].forEach(([x, y], k) => { c.beginPath(); c.ellipse(x, y, 20, 15, 0.3 * k, 0, TAU); c.fill(); }); });
+ const G = RIG.girl({ cup: ch.cup, sip: ch.sip, hair: 'bun', breathe: ch.breathe, dy: Math.sin(t * 8) * 1.5 });
+ const K = RIG.cat({ tail: ch.tail, blink: ch.blink, breathe: ch.breathe });
+ const L = P.scratch('mtChars'), lg = L.getContext('2d', { willReadFrequently: true }); lg.reset();
+ chars(lg, t, ch, G, K);
+ roughen(L);
+ paperShadow(c, () => c.drawImage(L, 0, 0));
+ // 热气:两条白色剪纸卷须
+ const cp = G.cup; [0, 1].forEach(k => { const sw = Math.sin(t * 5 + k * 2) * 0.25; paperShadow(c, () => placed(c, algaePath(30 + k, 70, 16, 1.5, 0.6), cp.x - 8 + k * 18, cp.y - 10, sw, 1, 1, C.white)); });
+ fallingPaper(c, t);
+ c.save(); c.globalCompositeOperation = 'overlay'; c.drawImage(gouache(), 0, 0); c.restore();
+ // 计数器底:白纸片
+ paperShadow(c, () => { c.fillStyle = C.white; c.fill(shapeCache.lab || (shapeCache.lab = cut([[1500, 44], [1892, 38], [1888, 214], [1504, 208]], 61, 26, 2.2))); });
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/31_haring.js b/scripts/engine/scenes/31_haring.js
new file mode 100644
index 0000000..aca6822
--- /dev/null
+++ b/scripts/engine/scenes/31_haring.js
@@ -0,0 +1,109 @@
+// 1982 凯斯·哈林(地铁粉笔画 → 波普商店的纯色涂鸦)——纯代码。
+// 手法:纯色底(黄墙、绿地)+一切都是 12–14px 圆头黑马克笔轮廓+平涂;人物无五官(少女保留一点眼和唇以便认人)。
+// 小人=胶囊肢体,「先全部描粗黑、再统一填色」得到并集轮廓;4 个姿势 8fps 硬切(不插值)=哈林的跳舞小人。
+// 放射动作线:物体外围成对的短直线,8fps 闪。
+// 一切按 128 BPM 弹跳:少女/猫上下颠、桌子挤压拉伸、茶壶跳、窗框摇。
+// 母题:窗里的光芒宝宝(光芒 8fps 闪)、墙上 3 个跳舞小人、桌上方的放射红心。
+SCENES['31_haring'] = (() => {
+ const W = 1920, H = 1080, TAU = Math.PI * 2, { clamp, lerp } = U, P = PAINT;
+ const C = { yel: '#ffd51c', green: '#16a54a', red: '#e8262b', blue: '#1f62d6', pink: '#ff6fb0', org: '#ff8a1c', white: '#ffffff', ink: '#111111', skin: '#ffd9b8' };
+ const BEAT = 128 / 60; // 每秒拍数
+ const bounce = (t, ph = 0) => Math.pow(Math.abs(Math.sin((t * BEAT + ph) * Math.PI)), 0.6); // 0..1,拍点在 0
+ const LW = 13;
+ const ink = (c, p, fill, lw = LW) => { c.lineJoin = 'round'; c.lineCap = 'round'; if (fill) { c.fillStyle = fill; c.fill(p); } c.strokeStyle = C.ink; c.lineWidth = lw; c.stroke(p); };
+ // 放射动作线:围绕中心 (cx,cy) 半径 r 外的 n 对短线,8fps 换角度
+ function action(c, cx, cy, rx, ry, n, t, seed, len = 34, lw = 9) {
+ const st = Math.floor(t * 8), r = U.rng(seed * 97 + st * 13); c.save(); c.strokeStyle = C.ink; c.lineWidth = lw; c.lineCap = 'round';
+ for (let i = 0; i < n; i++) { const a = (i / n) * TAU + r() * 0.5; const x0 = cx + Math.cos(a) * rx, y0 = cy + Math.sin(a) * ry, L = len * (0.7 + r() * 0.6);
+ c.beginPath(); c.moveTo(x0, y0); c.lineTo(x0 + Math.cos(a) * L, y0 + Math.sin(a) * L); c.stroke(); }
+ c.restore();
+ }
+ // 跳舞小人:4 个姿势(局部坐标,原点=脚底中心,朝上为负)
+ const POSES = [
+ { head: [0, -210], neck: [0, -168], hip: [0, -86], hl: [-74, -150], hr: [70, -250], kl: [-30, -42], kr: [34, -42], fl: [-46, 0], fr: [44, 0] },
+ { head: [10, -200], neck: [6, -160], hip: [0, -84], hl: [-90, -220], hr: [86, -200], kl: [-40, -50], kr: [58, -64], fl: [-36, 0], fr: [96, -40] },
+ { head: [-12, -206], neck: [-6, -166], hip: [0, -86], hl: [-70, -250], hr: [80, -150], kl: [-50, -60], kr: [26, -40], fl: [-100, -36], fr: [40, 0] },
+ { head: [0, -224], neck: [0, -182], hip: [0, -100], hl: [-84, -256], hr: [84, -256], kl: [-40, -54], kr: [40, -54], fl: [-60, -14], fr: [60, -14] },
+ ];
+ function dancer(c, x, y, s, col, t, ph, flip = 1) {
+ const k = (Math.floor(t * 8) + ph) % 4, p = POSES[k], T = q => [x + q[0] * s * flip, y + q[1] * s];
+ const parts = [RIG.limb(T(p.neck), T(p.hip), 64 * s, 54 * s), RIG.limb(T(p.neck), T(p.hl), 34 * s, 30 * s), RIG.limb(T(p.neck), T(p.hr), 34 * s, 30 * s),
+ RIG.limb(T(p.hip), T(p.kl), 36 * s, 32 * s), RIG.limb(T(p.kl), T(p.fl), 32 * s, 30 * s), RIG.limb(T(p.hip), T(p.kr), 36 * s, 32 * s), RIG.limb(T(p.kr), T(p.fr), 32 * s, 30 * s)];
+ const hd = new Path2D(); const hc = T(p.head); hd.arc(hc[0], hc[1], 38 * s, 0, TAU); parts.push(hd);
+ c.save(); c.lineJoin = 'round'; c.strokeStyle = C.ink; c.lineWidth = LW * 2 * Math.max(0.7, s); parts.forEach(q => c.stroke(q)); c.fillStyle = col; parts.forEach(q => c.fill(q)); c.restore();
+ // 手脚旁的动作弧
+ c.save(); c.strokeStyle = C.ink; c.lineWidth = 8 * s; c.lineCap = 'round';
+ [p.hl, p.hr].forEach((h, i) => { const q = T(h); c.beginPath(); c.arc(q[0], q[1], 40 * s, (i ? -0.6 : 2.4), (i ? 0.4 : 3.4)); c.stroke(); });
+ c.restore();
+ }
+ function radiantBaby(c, x, y, s, t) {
+ // 光芒:12 根短线,8fps 交替长短
+ const st = Math.floor(t * 8); c.save(); c.strokeStyle = C.ink; c.lineWidth = 10; c.lineCap = 'round';
+ for (let i = 0; i < 14; i++) { const a = -Math.PI + i / 13 * Math.PI, L = (i + st) % 2 ? 40 : 66; c.beginPath(); c.moveTo(x + Math.cos(a) * 120 * s, y + Math.sin(a) * 96 * s); c.lineTo(x + Math.cos(a) * (120 * s + L), y + Math.sin(a) * (96 * s + L)); c.stroke(); }
+ c.restore();
+ // 爬行的宝宝:圆头+身体+四肢(两帧交替爬)
+ const cr = st % 2, parts = [];
+ const B = (q) => [x + q[0] * s, y + q[1] * s];
+ parts.push(RIG.limb(B([-40, -10]), B([40, -20]), 70 * s, 60 * s));
+ parts.push(RIG.limb(B([-34, 0]), B([-60 + cr * 14, 50]), 26 * s, 24 * s), RIG.limb(B([30, -8]), B([60 - cr * 14, 50]), 26 * s, 24 * s));
+ const hd = new Path2D(), hc = B([-82, -40]); hd.arc(hc[0], hc[1], 40 * s, 0, TAU); parts.push(hd);
+ c.save(); c.strokeStyle = C.ink; c.lineWidth = 22; parts.forEach(q => c.stroke(q)); c.fillStyle = C.white; parts.forEach(q => c.fill(q)); c.restore();
+ }
+ function heart(c, x, y, s, t) {
+ const b = 1 + 0.15 * bounce(t, 0.5), p = new Path2D();
+ p.moveTo(x, y + 40 * s * b); p.bezierCurveTo(x - 70 * s * b, y - 10 * s * b, x - 40 * s * b, y - 60 * s * b, x, y - 28 * s * b); p.bezierCurveTo(x + 40 * s * b, y - 60 * s * b, x + 70 * s * b, y - 10 * s * b, x, y + 40 * s * b); p.closePath();
+ ink(c, p, C.red, 11); action(c, x, y - 6, 78 * s, 70 * s, 10, t, 5, 30, 8);
+ }
+
+ return {
+ draw(c, lt, t) {
+ const ch = P.choreo(lt, t);
+ const bb = bounce(t), bob = -bb * 12;
+ // 底色
+ c.fillStyle = C.yel; c.fillRect(0, 0, W, 702); c.fillStyle = C.green; c.fillRect(0, 702, W, H - 702);
+ c.strokeStyle = C.ink; c.lineWidth = 14; c.beginPath(); c.moveTo(0, 702); c.lineTo(W, 702); c.stroke();
+ // 窗:黑粗框、蓝底、光芒宝宝;整个窗随拍子轻摇
+ c.save(); c.translate(580, 560); c.rotate(Math.sin(t * BEAT * Math.PI) * 0.025); c.translate(-580, -560);
+ const win = new Path2D(); win.rect(350, 122, 460, 436); ink(c, win, C.blue, 16);
+ c.strokeStyle = C.ink; c.lineWidth = 10; c.beginPath(); c.moveTo(580, 122); c.lineTo(580, 250); c.stroke();
+ c.save(); c.clip(win); radiantBaby(c, 610, 430 + bob * 0.5, 1.05, t); c.restore();
+ const sill = new Path2D(); sill.rect(326, 556, 508, 30); ink(c, sill, C.red, 12);
+ c.restore();
+ // 墙上的跳舞小人
+ dancer(c, 175, 660, 0.95, C.red, t, 0);
+ dancer(c, 1000, 520, 0.62, C.blue, t, 2, -1);
+ dancer(c, 1720, 680, 1.05, C.pink, t, 1, -1);
+ action(c, 1720, 520, 130, 160, 8, t, 9, 30, 8);
+ heart(c, 1000, 210, 1.0, t);
+ // 桌:挤压拉伸(以桌脚着地为轴)
+ const sy = 1 - 0.07 * (1 - bb), sx = 1 + 0.05 * (1 - bb);
+ c.save(); c.translate(1008, 904); c.scale(sx, sy); c.translate(-1008, -904);
+ [[846, 640], [1150, 640]].forEach(([x, y], k) => { const leg = new Path2D(); leg.moveTo(x, y); leg.quadraticCurveTo(x + (k ? 18 : -18) * (1 - bb), 780, x + 6, 904); c.strokeStyle = C.ink; c.lineWidth = 36; c.lineCap = 'round'; c.stroke(leg); c.strokeStyle = C.red; c.lineWidth = 12; c.stroke(leg); });
+ const top = new Path2D(); top.rect(806, 616, 404, 34); ink(c, top, C.red, 13);
+ // 茶壶在桌上跳
+ const jy = -Math.max(0, Math.sin((t * BEAT + 0.25) * Math.PI)) * 26;
+ const pot = RIG.smooth([[870, 616], [858, 586], [874, 556], [912, 548], [948, 556], [962, 588], [952, 616]].map(([x, y]) => [x, y + jy]), true, 0.5);
+ const sp = new Path2D(); sp.moveTo(864, 592 + jy); sp.lineTo(830, 562 + jy); ink(c, sp, null, 13); c.strokeStyle = C.white; c.lineWidth = 3; ink(c, pot, C.white, 12);
+ c.restore();
+ action(c, 910, 584 + jy, 70, 46, 6, t, 3, 22, 7);
+ // 地上影子小横线(哈林的「跳起来」标志)
+ c.strokeStyle = C.ink; c.lineWidth = 9; c.lineCap = 'round'; [[480, 932], [620, 932], [1200, 948], [1360, 948]].forEach(([x, y], k) => { const L = 30 + 30 * (1 - bb); c.beginPath(); c.moveTo(x - L, y); c.lineTo(x + L, y); c.stroke(); });
+ // 猫(橘白、粗黑线、跟着拍子颠;眼睛是两个黑点)
+ const K = RIG.cat({ tail: ch.tail * 1.6, blink: ch.blink, breathe: ch.breathe, dy: -bounce(t, 0.5) * 16 }) // RIG.limb 端帽已修,粗描边下腿关节不再露洞;
+ RIG.drawCat(c, K, { line: C.ink, lw: LW, orange: C.org, white: C.white, stripe: C.ink, stripeW: 8, earInner: C.pink,
+ tail: (c, K) => { c.lineCap = 'round'; c.strokeStyle = C.ink; c.lineWidth = K.tailW + LW * 2; c.stroke(K.tail); c.strokeStyle = C.org; c.lineWidth = K.tailW; c.stroke(K.tail); },
+ face: (c, K) => { K.eyes.forEach(e => { c.fillStyle = C.ink; c.beginPath(); c.arc(e.x, e.y, K.blink ? 3 : 8, 0, TAU); c.fill(); }); c.fillStyle = C.pink; c.beginPath(); c.arc(K.nose[0], K.nose[1], 7, 0, TAU); c.fill(); } });
+ action(c, 540, 760 - bounce(t, 0.5) * 16, 190, 200, 10, t, 7, 34, 9);
+ // 少女:80 年代纽约少女——宽大红毛衣+牛仔蓝长裙+白高帮球鞋;颠头;只留眼点和唇
+ const G = RIG.girl({ cup: ch.cup, sip: ch.sip, hair: 'long', breathe: ch.breathe, dy: bob });
+ RIG.drawGirl(c, G, { line: C.ink, lw: LW, lwOf: { hand: 9, farHand: 9, face: 10, neck: 9, cuff: 10, farCuff: 10 }, locks: false, skin: C.skin, hair: C.yel, dress: C.red, skirt: C.blue, sleeve: C.red, cuff: C.red, shoe: C.white, cupBody: C.white, cupRim: C.ink,
+ features: (c, G) => { c.fillStyle = C.ink; c.beginPath(); c.arc(G.eye.x, G.eye.y, ch.blink ? 2.5 : 6, 0, TAU); c.fill(); c.strokeStyle = C.red; c.lineWidth = 6; c.lineCap = 'round'; c.beginPath(); c.moveTo(...G.lips[0]); c.lineTo(...G.lips[2]); c.stroke(); },
+ hooks: { torso: (c, G) => { c.strokeStyle = C.ink; c.lineWidth = 8; const w = G.A.waist; c.beginPath(); c.moveTo(w[0] - 90, w[1] - 30); c.lineTo(w[0] + 60, w[1] - 26); c.stroke(); }, // 毛衣下摆罗纹
+ } });
+ action(c, G.A.headC[0] + 10, G.A.headC[1], 110, 110, 9, t, 11, 30, 9);
+ // 杯子上的放射线+热气(哈林式波浪线)
+ action(c, G.cup.x, G.cup.y + 14, 48, 40, 7, t, 13, 24, 7);
+ c.save(); c.strokeStyle = C.ink; c.lineWidth = 8; c.lineCap = 'round'; [0, 1].forEach(k => { c.beginPath(); for (let i = 0; i <= 10; i++) { const q = i / 10, x = G.cup.x - 10 + k * 20 + Math.sin(q * 8 + t * 14 + k) * 8, y = G.cup.y - 24 - q * 60; i ? c.lineTo(x, y) : c.moveTo(x, y); } c.stroke(); }); c.restore();
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/32_rembrandt.js b/scripts/engine/scenes/32_rembrandt.js
new file mode 100644
index 0000000..264178b
--- /dev/null
+++ b/scripts/engine/scenes/32_rembrandt.js
@@ -0,0 +1,217 @@
+// 1642 伦勃朗明暗法 —— 纯代码。
+// 管线:①亮态底稿(按「全亮」时的颜色画房间、桌毯、窗)→ ②褐色笔触重画(静态缓存)→ ③角色平涂+体积渐变+细笔触
+// → ④光照图 multiply(环境≈0.13,窗光池/人脸/猫/桌面/烛光,缓慢摇曳)→ ⑤厚涂高光(凸起:暗影偏移+主笔+亮脊)
+// → ⑥光柱浮尘、烛焰、热气 → ⑦金褐釉+龟裂+暗角+颗粒
+SCENES['32_rembrandt'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, rng } = U, P = PAINT;
+ const WIN = [350, 120, 810, 560];
+ const flick = (t, k = 0) => 0.5 * P.noise(t * 2.2 + k * 7.3, k * 3.1) + 0.25 * P.noise(t * 6.5 + k, 9 + k); // 约 ±0.35
+
+ // ---------- ① 亮态底稿(静态) ----------
+ function room(g) {
+ // 墙:暖褐,向右变深
+ const wg = g.createLinearGradient(0, 0, W, 0); wg.addColorStop(0, '#6a4a2a'); wg.addColorStop(0.5, '#4a321c'); wg.addColorStop(1, '#2a1a0e');
+ g.fillStyle = wg; g.fillRect(0, 0, W, H);
+ // 地面
+ g.fillStyle = '#3a2614'; g.fillRect(0, 880, W, 200);
+ // 窗洞(厚墙斜面)
+ g.fillStyle = '#8a6a44'; g.beginPath(); g.moveTo(322, 96); g.lineTo(838, 96); g.lineTo(810, 120); g.lineTo(350, 120); g.closePath(); g.fill();
+ g.fillStyle = '#9a7a50'; g.beginPath(); g.moveTo(322, 96); g.lineTo(350, 120); g.lineTo(350, 560); g.lineTo(322, 590); g.closePath(); g.fill();
+ g.fillStyle = '#5a3e22'; g.beginPath(); g.moveTo(838, 96); g.lineTo(810, 120); g.lineTo(810, 560); g.lineTo(838, 590); g.closePath(); g.fill();
+ // 玻璃:铅条菱格+牛眼玻璃
+ g.save(); g.beginPath(); g.rect(350, 120, 460, 440); g.clip();
+ const gg = g.createRadialGradient(560, 300, 20, 580, 340, 360); gg.addColorStop(0, '#fff6dc'); gg.addColorStop(0.6, '#f0d8a0'); gg.addColorStop(1, '#c49a5a');
+ g.fillStyle = gg; g.fillRect(350, 120, 460, 440);
+ const r = rng(42);
+ for (let i = 0; i < 70; i++) { const x = 350 + r() * 460, y = 120 + r() * 440, rr = 6 + r() * 14; g.fillStyle = `rgba(${r() < .5 ? '255,250,230' : '190,150,90'},${0.15 + r() * 0.2})`; g.beginPath(); g.arc(x, y, rr, 0, Math.PI * 2); g.fill(); }
+ g.strokeStyle = '#3a2a1a'; g.lineWidth = 3;
+ for (let k = -12; k < 16; k++) { g.beginPath(); g.moveTo(350 + k * 46, 120); g.lineTo(350 + k * 46 + 440 * 0.55, 560); g.stroke(); g.beginPath(); g.moveTo(350 + k * 46, 560); g.lineTo(350 + k * 46 + 440 * 0.55, 120); g.stroke(); }
+ g.restore();
+ // 窗框与中梃、横档
+ g.fillStyle = '#2a1a0e'; g.fillRect(350, 120, 460, 12); g.fillRect(350, 548, 460, 12); g.fillRect(350, 120, 12, 440); g.fillRect(798, 120, 12, 440);
+ g.fillRect(573, 120, 14, 440); g.fillRect(350, 330, 460, 12);
+ // 窗台
+ g.fillStyle = '#7a5a36'; g.fillRect(310, 560, 540, 24); g.fillStyle = '#4a321c'; g.fillRect(310, 584, 540, 14);
+ // 右侧重帷幕(深红褐,大褶)
+ const cg = g.createLinearGradient(1500, 0, 1920, 0); cg.addColorStop(0, '#4a1a10'); cg.addColorStop(1, '#2a0c06'); g.fillStyle = cg;
+ g.beginPath(); g.moveTo(1560, 0); g.bezierCurveTo(1600, 300, 1540, 600, 1600, 1080); g.lineTo(1920, 1080); g.lineTo(1920, 0); g.closePath(); g.fill();
+ g.strokeStyle = 'rgba(120,50,30,.6)'; g.lineWidth = 10; [1640, 1720, 1810].forEach((x, k) => { g.beginPath(); g.moveTo(x, 0); g.bezierCurveTo(x + 30, 300, x - 30, 650, x + 10 * k, 1080); g.stroke(); });
+ // 椅背(少女身后,深色雕花)
+ g.fillStyle = '#2e1c0e'; g.fillRect(1428, 450, 22, 470); g.fillRect(1476, 460, 20, 460); g.fillRect(1424, 440, 80, 24);
+ g.fillStyle = '#6a3a22'; g.fillRect(1440, 500, 50, 180);
+ }
+ function table(g) {
+ // 桌:土耳其桌毯盖住,垂到地面,金色流苏
+ g.fillStyle = '#7a2a18'; g.beginPath(); g.moveTo(800, 618); g.lineTo(1215, 618); g.lineTo(1240, 880); g.quadraticCurveTo(1020, 900, 790, 885); g.closePath(); g.fill();
+ g.fillStyle = '#9a3a1e'; g.fillRect(800, 610, 415, 22);
+ // 毯面纹样:菱形徽章+边带
+ g.strokeStyle = '#c8943a'; g.lineWidth = 6; g.beginPath(); g.moveTo(805, 660); g.lineTo(1220, 660); g.stroke(); g.beginPath(); g.moveTo(800, 840); g.lineTo(1236, 840); g.stroke();
+ g.fillStyle = '#2a3a5a'; [[900, 750], [1020, 755], [1140, 750]].forEach(([x, y]) => { g.beginPath(); g.moveTo(x, y - 60); g.lineTo(x + 45, y); g.lineTo(x, y + 60); g.lineTo(x - 45, y); g.closePath(); g.fill(); });
+ g.fillStyle = '#c8943a'; [[900, 750], [1020, 755], [1140, 750]].forEach(([x, y]) => { g.beginPath(); g.moveTo(x, y - 26); g.lineTo(x + 20, y); g.lineTo(x, y + 26); g.lineTo(x - 20, y); g.closePath(); g.fill(); });
+ g.strokeStyle = '#d0a050'; g.lineWidth = 3; for (let x = 795; x < 1238; x += 9) { g.beginPath(); g.moveTo(x, 884); g.lineTo(x + 2, 902); g.stroke(); }
+ }
+ function tableProps(g) {
+ // 桌上:打开的书、锡壶、烛台
+ g.fillStyle = '#e8d6aa'; g.beginPath(); g.moveTo(940, 612); g.lineTo(1010, 598); g.lineTo(1080, 612); g.lineTo(1010, 624); g.closePath(); g.fill();
+ g.strokeStyle = '#8a6a3a'; g.lineWidth = 2; g.beginPath(); g.moveTo(1010, 598); g.lineTo(1010, 624); g.stroke();
+ g.fillStyle = '#7a7466'; g.beginPath(); g.moveTo(1100, 610); g.quadraticCurveTo(1090, 560, 1108, 530); g.lineTo(1132, 530); g.quadraticCurveTo(1150, 560, 1140, 610); g.closePath(); g.fill();
+ g.strokeStyle = '#7a7466'; g.lineWidth = 7; g.beginPath(); g.arc(1150, 565, 18, -1.3, 1.3); g.stroke();
+ // 烛台(黄铜)+蜡烛
+ g.fillStyle = '#9a7432'; g.beginPath(); g.ellipse(870, 612, 36, 9, 0, 0, Math.PI * 2); g.fill(); g.fillRect(864, 560, 12, 52); g.beginPath(); g.ellipse(870, 560, 20, 5, 0, 0, Math.PI * 2); g.fill();
+ g.fillStyle = '#efe2c0'; g.fillRect(861, 500, 18, 60);
+ }
+ // ---------- ② 褐色笔触重画(静态,缓存) ----------
+ const SW = {
+ wall: P.swatch(['#5a3c20', '#6e4a28', '#4e3418', '#6a4a28', '#4a3018', '#765030'], 0.7),
+ dark: P.swatch(['#2a1a0c', '#3a2412', '#1e1208', '#4a2e16'], 0.5),
+ rug: P.swatch(['#8a2e18', '#6a2010', '#a8441e', '#c8943a', '#2a3a5a'], 0.7),
+ glass: P.swatch(['#fff2d0', '#f2d8a0', '#e8c888', '#fff8e8'], 0.6),
+ };
+ const stat = () => P.cached('rb_static', W, H, (g, cv) => {
+ const b = P.canvas(), bg = b.getContext('2d'); room(bg);
+ g.drawImage(b, 0, 0);
+ // 背景:宽松的褐色笔触(伦勃朗背景的刷痕),再整体轻模糊成「揉开」的底子
+ P.strokes(g, b, { cell: 18, len: 54, width: 16, seed: 3, t: 0, boil: 0, outline: 0, jitterCol: 6,
+ angle: (x, y) => -0.9 + 1.6 * P.noise(x * 0.003, y * 0.003),
+ palette: (x, y, col, r) => (x > 1520 || y > 880 ? SW.dark(col, r) : SW.wall(col, r)),
+ mask: (x, y) => !(x > 300 && x < 860 && y > 80 && y < 610) });
+ { const tmp = P.canvas(), tg = tmp.getContext('2d'); tg.filter = 'blur(2.2px)'; tg.drawImage(cv, 0, 0); g.globalAlpha = 0.75; g.drawImage(tmp, 0, 0); g.globalAlpha = 1; }
+ g.drawImage(b, 300, 80, 560, 530, 300, 80, 560, 530); // 窗与窗台保留清楚的木作
+ // 桌毯:单独一层、单独更细的笔触(小物件不被大笔触打碎),再放桌上小物
+ const tb = P.canvas(), tbg = tb.getContext('2d'); table(tbg);
+ tbg.save(); tbg.globalCompositeOperation = 'source-atop';
+ P.strokes(tbg, tb, { cell: 8, len: 16, width: 6, seed: 5, t: 0, boil: 0, outline: 0.25, outlineCol: [30, 10, 5], outlineMix: 0.6, jitterCol: 14, alphaMask: true, angle: (x, y) => y > 840 ? Math.PI / 2 : 0.1 * P.noise(x * 0.02, y * 0.02) });
+ tbg.restore(); tableProps(tbg); g.drawImage(tb, 0, 0);
+ });
+
+ // ---------- 光照图(每帧) ----------
+ const pool = P.pool; // 光池(径向渐变)
+ const beam = () => P.cached('rb_beam', W, H, (g) => {
+ g.filter = 'blur(40px)'; g.fillStyle = 'rgba(255,232,190,0.55)';
+ g.beginPath(); g.moveTo(360, 130); g.lineTo(800, 130); g.lineTo(1500, 760); g.lineTo(1300, 1000); g.lineTo(380, 1000); g.lineTo(340, 560); g.closePath(); g.fill();
+ g.filter = 'none';
+ });
+ const cloudAt = t => 0.5 + 0.5 * Math.sin(t * 2.2 - 0.6); // 云影:窗光慢慢暗下去又回来
+ // 光照图:环境光 rgb(30,21,13) 打底,lighter 叠光池(P.lightMap),之后整幅 multiply(P.applyLight)
+ function lightMap(t, G, K) {
+ const f = flick(t), fc = flick(t * 1.7, 3);
+ return P.lightMap('rembrandt', 'rgb(30,21,13)', g => {
+ const cloud = cloudAt(t);
+ g.globalAlpha = (0.8 + 0.15 * f) * (1 - 0.35 * cloud); g.drawImage(beam(), 0, 0); g.globalAlpha = 1;
+ pool(g, 580, 340, 330, '255,246,225', 1 - 0.3 * cloud); // 窗本身
+ pool(g, 1470, 400, 300, '200,150,90', 0.35); // 背后墙面的分离光(暗侧亮墙)
+ const dx = 14 * P.noise(t * 0.9, 1), dy = 10 * P.noise(t * 0.9, 5); // 光池缓慢漂移(云影/烛焰摇曳)
+ pool(g, G.A.headC[0] - 30 + dx, G.A.headC[1] + 10 + dy, 250, '255,226,180', 0.95 + 0.08 * f);
+ pool(g, G.A.chest[0] - 40 + dx, G.A.chest[1] + 40, 230, '255,214,160', 0.55);
+ pool(g, K.headC[0] - 10, K.headC[1] + 90 + dy, 240, '255,220,170', 0.8 + 0.08 * f);
+ pool(g, 1010, 640 + dy, 280, '255,214,160', 0.6);
+ pool(g, 870, 490, 190 + 40 * fc, '255,180,90', 0.6 + 0.4 * fc); // 烛光(快闪)
+ });
+ }
+ // ---------- 厚涂:凸起的颜料(暗影偏移+主笔+亮脊) ----------
+ // 第一版「暗影+主笔+亮脊」三条整齐的线读成贴纸。改成鬃毛笔:一笔 = 若干条平行细鬃(各自明暗抖动、两端随机缩短),
+ // 下侧一条很淡的投影,上侧零星亮点——读成「一坨被刷开的厚颜料」。
+ const impasto = P.impasto; // 厚涂鬃毛笔
+
+ const girlPal = { skin: '#eccaa0', hair: '#b8873a', hairLine: '#6a4818', dress: '#3a2014', sleeve: '#5c2c18', fold: '#24120a', cuff: '#efe6d0',
+ cheek: 'rgba(220,120,90,.35)', lip: '#b8524a', iris: '#4a3a2a', line: '#3a2010', lw: 0, cupBody: '#e6e4dc', cupRim: '#6a4a28', shoe: '#1a0e06', browC: '#9a6a2a' };
+ const catPal = { orange: '#c47a34', white: '#eedcb8', stripe: '#8a4a18', line: '#2a160a', lw: 0, eye: '#b89a3a', earInner: '#c88a70', noseC: '#b86a5a', whisker: '#efe0c0' };
+
+ return {
+ draw(c, lt, t) {
+ const ch = P.choreo(lt, t);
+ const G = RIG.girl({ cup: ch.cup, sip: ch.sip, breathe: ch.breathe, hair: 'bun' });
+ const K = RIG.cat({ tail: ch.tail, blink: ch.blink, breathe: ch.breathe });
+ // ① ② 静态底
+ const S = P.scratch('rbScene'), sg = S.getContext('2d'); sg.reset(); sg.drawImage(stat(), 0, 0);
+ // ③ 角色层
+ const L = P.scratch('rbChars'), lg = L.getContext('2d'); lg.reset();
+ RIG.drawCat(lg, K, catPal);
+ RIG.drawGirl(lg, G, { ...girlPal, mode: 'fill' });
+ // 服饰:宽白领(平摊在肩上的花边大领)、白亚麻小帽、珍珠耳坠
+ lg.save(); lg.lineJoin = 'round';
+ const n = G.A.neck, ch_ = G.A.chest, bk = G.A.back;
+ lg.fillStyle = '#f0e8d4';
+ const collar = [[n[0] - 22, n[1] - 8], [n[0] - 30, n[1] + 22], [ch_[0] - 14, ch_[1] - 4], [n[0] + 10, ch_[1] + 16], [n[0] + 52, ch_[1] + 6], [bk[0] - 26, n[1] + 52], [n[0] + 46, n[1] - 4], [n[0] + 10, n[1] - 14]];
+ lg.fill(RIG.smooth(collar));
+ lg.fillStyle = '#f6f0e2'; for (let k = 0; k < 11; k++) { const q = k / 10, x = lerp(ch_[0] - 14, bk[0] - 26, q), y = lerp(ch_[1] - 4, n[1] + 52, q) + Math.sin(q * Math.PI) * 22; lg.beginPath(); lg.arc(x, y, 7, 0, Math.PI * 2); lg.fill(); }
+ lg.strokeStyle = 'rgba(150,130,100,.7)'; lg.lineWidth = 1.5; lg.setLineDash([2, 4]); lg.stroke(RIG.smooth(collar.map(p => [lerp(p[0], n[0] + 14, 0.25), lerp(p[1], n[1] + 30, 0.25)]))); lg.setLineDash([]);
+ const hc = G.A.headC;
+ lg.fillStyle = '#efe6d0'; for (let k = 0; k < 9; k++) { const a = -2.2 + k * 0.32; lg.beginPath(); lg.arc(G.bunSpiral[0] + Math.cos(a) * 27, G.bunSpiral[1] + Math.sin(a) * 27, 4.5, 0, Math.PI * 2); lg.fill(); }
+ lg.fillStyle = '#f6f0e0'; lg.beginPath(); lg.arc(G.ear[0] - 2, G.ear[1] + 24, 5, 0, Math.PI * 2); lg.fill();
+ lg.restore();
+ // 体积:左上受光 → 右下沉入暗部(source-atop 只染在角色上)
+ lg.save(); lg.globalCompositeOperation = 'source-atop';
+ let vg = lg.createLinearGradient(1180, 300, 1480, 760); vg.addColorStop(0, 'rgba(255,240,200,.12)'); vg.addColorStop(0.5, 'rgba(30,14,6,.15)'); vg.addColorStop(1, 'rgba(10,5,2,.7)'); lg.fillStyle = vg; lg.fillRect(1060, 200, 460, 760);
+ vg = lg.createLinearGradient(420, 600, 680, 900); vg.addColorStop(0, 'rgba(255,240,200,.1)'); vg.addColorStop(1, 'rgba(20,10,4,.55)'); lg.fillStyle = vg; lg.fillRect(380, 520, 360, 400);
+ // 裙子厚褶:几道深浅交替的宽笔
+ lg.lineCap = 'round'; G.folds.forEach((f, i) => { lg.strokeStyle = 'rgba(10,4,2,.5)'; lg.lineWidth = 16; lg.stroke(f); lg.strokeStyle = 'rgba(120,70,40,.25)'; lg.lineWidth = 6; lg.save(); lg.translate(-12, 0); lg.stroke(f); lg.restore(); });
+ // 细笔触肌理(不沸腾:古典油画)
+ P.strokes(lg, L, { cell: 6, len: 13, width: 5, seed: 8, t: 0, boil: 0, outline: 0, jitterCol: 9, alphaMask: true,
+ angle: (x, y) => x < 760 ? Math.atan2(y - 780, x - 540) + Math.PI / 2 : 1.2 + 0.4 * P.noise(x * 0.01, y * 0.01) });
+ lg.restore();
+ // 脸再盖一层平滑(伦勃朗的脸是揉开的,不留碎笔)+眼睛
+ lg.save(); lg.clip(G.face); const fg = lg.createRadialGradient(G.A.forehead[0], G.A.forehead[1] + 20, 5, G.A.headC[0], G.A.headC[1], 90);
+ fg.addColorStop(0, '#f6dcb6'); fg.addColorStop(0.6, '#d8a87a'); fg.addColorStop(1, '#7a4a2a'); lg.fillStyle = fg; lg.fill(G.face); lg.restore();
+ // 面部塑形:脸后半(靠耳)沉入暖褐半调;眼窝一抹阴影;颧骨一块三角受光(伦勃朗光的小三角)
+ lg.save(); lg.clip(G.face);
+ let sg2 = lg.createLinearGradient(G.A.forehead[0], 0, G.ear[0] + 10, 0); sg2.addColorStop(0, 'rgba(0,0,0,0)'); sg2.addColorStop(0.5, 'rgba(120,60,25,.25)'); sg2.addColorStop(1, 'rgba(70,32,12,.75)'); lg.fillStyle = sg2; lg.fill(G.face);
+ lg.fillStyle = 'rgba(110,55,25,.35)'; lg.beginPath(); lg.ellipse(G.eye.x + 4, G.eye.y - 2, 13, 8, 0.2, 0, 7); lg.fill();
+ lg.fillStyle = 'rgba(255,232,190,.55)'; lg.beginPath(); lg.moveTo(G.eye.x - 4, G.eye.y + 10); lg.lineTo(G.eye.x + 20, G.eye.y + 12); lg.lineTo(G.eye.x + 4, G.eye.y + 34); lg.closePath(); lg.fill();
+ lg.restore();
+ lg.fillStyle = '#c48a70'; lg.beginPath(); lg.moveTo(...G.lips[0]); lg.lineTo(...G.lips[1]); lg.lineTo(...G.lips[2]); lg.fill();
+ lg.strokeStyle = '#4a2a14'; lg.lineWidth = 2.6; lg.lineCap = 'round'; lg.stroke(G.lid); lg.strokeStyle = '#8a5a2a'; lg.lineWidth = 2; lg.stroke(G.brow);
+ if (!ch.blink) { lg.fillStyle = '#2a1a0e'; lg.beginPath(); lg.arc(G.eye.x - 1, G.eye.y + 1.5, 4, 0, Math.PI * 2); lg.fill(); }
+ // 刘海重新盖在脸上
+ lg.fillStyle = girlPal.hair; lg.fill(G.bangs); lg.strokeStyle = 'rgba(120,80,30,.6)'; lg.lineWidth = 2; G.hairLines.forEach(h => lg.stroke(h));
+ // 杯与手重新盖上(白瓷杯+青花一圈)
+ lg.fillStyle = '#e2b890'; lg.fill(G.hand);
+ RIG.drawCup(lg, G.cup, { body: '#e8e6de', rim: '#5a3a1c', hw: 6 });
+ lg.save(); lg.translate(G.cup.x, G.cup.y); lg.rotate(G.cup.tilt); lg.strokeStyle = '#3a4a8a'; lg.lineWidth = 3; lg.beginPath(); lg.moveTo(-G.cup.w * 0.46, G.cup.h * 0.45); lg.quadraticCurveTo(0, G.cup.h * 0.6, G.cup.w * 0.46, G.cup.h * 0.45); lg.stroke(); lg.restore();
+ lg.save(); lg.translate(G.cup.x, G.cup.y); lg.rotate(G.cup.tilt); lg.fillStyle = '#d9ad82';
+ for (let k = 0; k < 3; k++) { lg.beginPath(); lg.ellipse(G.cup.w * 0.42, G.cup.h * (0.3 + k * 0.22), 9, 5.5, 0.2, 0, 7); lg.fill(); } lg.restore();
+ lg.fillStyle = '#e2b890'; lg.beginPath(); lg.arc(G.thumb[0], G.thumb[1], 7, 0, Math.PI * 2); lg.fill();
+ // 「失边」:角色先糊一遍整层(暗侧会和背景融成一片),再叠 0.6 清晰层留住五官
+ sg.save(); sg.filter = 'blur(2.4px)'; sg.drawImage(L, 0, 0); sg.restore(); sg.globalAlpha = 0.62; sg.drawImage(L, 0, 0); sg.globalAlpha = 1;
+ // ④ 光照 multiply
+ P.applyLight(sg, lightMap(t, G, K));
+ // 窗玻璃本身是光源:再亮一点(screen)
+ sg.save(); sg.globalCompositeOperation = 'screen'; sg.globalAlpha = 0.35 + 0.08 * flick(t); sg.drawImage(stat(), 352, 122, 456, 436, 352, 122, 456, 436); sg.restore();
+ c.drawImage(S, 0, 0);
+ c.save(); c.beginPath(); c.rect(352, 122, 456, 436); c.clip();
+ const cx_ = 200 + ((t * 260) % 900); const cgr = c.createRadialGradient(cx_, 300, 20, cx_, 300, 260); cgr.addColorStop(0, 'rgba(60,40,20,.35)'); cgr.addColorStop(1, 'rgba(60,40,20,0)');
+ c.fillStyle = cgr; c.fillRect(352, 122, 456, 436); c.restore();
+ // ⑤ 厚涂高光(跟着锚点走)
+ const fh = G.A.forehead, hd = G.hand, cp = G.cup;
+ [[0, -14, 40, -26], [14, -2, 56, -12], [40, 6, 84, 2]].forEach(([a, b, c2, d]) => impasto(c, [[fh[0] + a, fh[1] + b], [fh[0] + (a + c2) / 2, fh[1] + (b + d) / 2 - 4], [fh[0] + c2, fh[1] + d]], 7, '#f0c870', 'rgba(255,240,190,.8)')); // 金发受光
+ impasto(c, [[G.cheek[0] - 22, G.cheek[1] - 10], [G.cheek[0] - 12, G.cheek[1] - 14]], 4, '#eecba0', 'rgba(255,240,210,.5)');
+ for (let k = 0; k < 6; k++) { const q = k / 5, x = lerp(n[0] - 26, ch_[0] - 12, q) + 6, y = lerp(n[1] + 6, ch_[1] - 6, q); impasto(c, [[x, y], [x + 9, y + 3]], 4.5, 'rgba(246,238,218,.9)', 'rgba(255,255,245,.45)'); } // 领口受光边:一串短厚笔
+ impasto(c, [[cp.x - cp.w * 0.28, cp.y + 6], [cp.x - cp.w * 0.3, cp.y + cp.h * 0.6]], 3.5, '#fbf8f0'); // 瓷杯反光
+ impasto(c, [[G.ear[0] - 3, G.ear[1] + 22], [G.ear[0] - 2, G.ear[1] + 23]], 3.5, '#ffffff'); // 珍珠
+ for (let k = 0; k < 9; k += 2) { const a = -2.2 + k * 0.32; const px = G.bunSpiral[0] + Math.cos(a) * 27, py = G.bunSpiral[1] + Math.sin(a) * 27; impasto(c, [[px - 1, py - 1], [px, py - 1.5]], 3, '#fff8e8'); }
+ const fur = U.rng(23); for (let k = 0; k < 9; k++) { const x = 572 + fur() * 40, y = 706 + k * 12; impasto(c, [[x, y], [x + 4, y + 8]], 4, '#ecdcba', 'rgba(255,248,226,.55)'); } // 猫白胸短毛
+ impasto(c, [[K.nose[0] - 28, K.nose[1] + 8], [K.nose[0] - 16, K.nose[1] + 12]], 4, '#efe0c0', 'rgba(255,248,226,.55)');
+ for (let k = 0; k < 5; k++) impasto(c, [[572 + k * 14, 590 - (k % 2) * 4], [580 + k * 14, 598]], 4, '#d88a40', 'rgba(255,214,150,.6)'); // 猫头顶橘毛
+ if (!ch.blink) K.eyes.forEach(e => { c.fillStyle = 'rgba(255,248,220,.95)'; c.beginPath(); c.arc(e.x - 2, e.y - 3, 2.6, 0, Math.PI * 2); c.fill(); });
+ impasto(c, [[1030, 610], [1060, 606]], 5, '#f6e8c0'); impasto(c, [[1114, 545], [1111, 588]], 4, '#a8a498', 'rgba(240,236,220,.6)'); // 书页、锡壶
+ // ⑥ 会动:烛焰(摇曳)、光柱浮尘、热气
+ const fc = flick(t * 1.7, 3), fx = 870 + 5 * P.noise(t * 5, 2), lean = 6 * P.noise(t * 3, 8);
+ c.save(); c.globalCompositeOperation = 'lighter';
+ pool(c, fx, 470, 70 + 12 * fc, '255,170,70', 0.45 + 0.2 * fc);
+ c.fillStyle = '#ffd890'; c.beginPath(); c.moveTo(fx - 8, 498); c.quadraticCurveTo(fx - 10, 478, fx + lean, 452 - 8 * fc); c.quadraticCurveTo(fx + 10, 478, fx + 8, 498); c.closePath(); c.fill();
+ c.fillStyle = '#fff6d8'; c.beginPath(); c.ellipse(fx + lean * 0.3, 488, 4, 9, 0, 0, Math.PI * 2); c.fill();
+ const dust = P.particles(70, 17, t * 0.35, { x0: 420, x1: 1300, y0: 980, y1: 160, speed: 40, drift: 26, life: 9 });
+ dust.forEach((d, i) => { const along = (d.x - 380) / 1000, inBeam = d.y > 130 + along * 520 - 120 && d.y < 560 + along * 520; if (!inBeam) return;
+ const tw = 0.5 + 0.5 * Math.sin(t * 4 + i * 2.1); c.fillStyle = `rgba(255,236,190,${0.25 + 0.5 * tw})`; c.beginPath(); c.arc(d.x, d.y, 1.4 + d.s * 1.6, 0, Math.PI * 2); c.fill(); });
+ c.restore();
+ P.steam(c, t, cp.x, cp.y - 6, { h: 60, n: 2, color: 'rgba(255,236,200,.5)', width: 3, spread: 12, wobble: 8 });
+ // ⑦ 罩层:金褐釉、龟裂、暗角、颗粒(缓存)
+ c.drawImage(P.cached('rb_over', W, H, (g) => {
+ const vg2 = g.createRadialGradient(900, 520, 300, 960, 540, 1150); vg2.addColorStop(0, 'rgba(10,5,0,0)'); vg2.addColorStop(1, 'rgba(8,4,0,.75)'); g.fillStyle = vg2; g.fillRect(0, 0, W, H);
+ g.globalAlpha = 0.28; g.drawImage(P.craquelure('rb', 0.28), 0, 0); g.globalAlpha = 1;
+ g.drawImage(P.grain('rbg', 0.05, [30, 15, 5], 0.12), 0, 0);
+ }), 0, 0);
+ c.save(); c.globalCompositeOperation = 'soft-light'; c.fillStyle = 'rgba(200,140,60,.35)'; c.fillRect(0, 0, W, H); c.restore();
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/33_rubberhose.js b/scripts/engine/scenes/33_rubberhose.js
new file mode 100644
index 0000000..b434105
--- /dev/null
+++ b/scripts/engine/scenes/33_rubberhose.js
@@ -0,0 +1,219 @@
+// 1930 橡皮管卡通(Fleischer / 早期迪士尼 / Cuphead 式)—— 纯代码。
+// 管线:①纸色单色底(墙纸竖纹、地板、窗外太阳脸)→ ②每个物体以自己的「着地点」为轴随 128BPM 节拍弹跳+挤压拉伸
+// → ③角色:骨架只取锚点,画法整个换成卡通(大头、派切眼、橡皮管手臂、白手套)→ ④胶片层:抖片、闪烁、划痕、灰尘、暗角
+// 时间:角色与母题都按 12fps「一拍二」步进(tq),只有胶片层按 24fps 变——这就是 30 年代赛璐珞的顿挫。
+SCENES['33_rubberhose'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, rng } = U, P = PAINT;
+ const INK = '#141210', PAPER = '#efe7d2', LT = '#d9d0b8', MID = '#a39a84', DK = '#5e574b', BEAT = 60 / 128;
+ const bnc = (tq, ph = 0) => Math.abs(Math.sin(Math.PI * (tq / BEAT + ph))); // 0 = 落地,1 = 最高
+ // 以着地点 (ax,ay) 为轴:上弹 amp 像素;落地时压扁、腾空时拉长
+ function boing(c, ax, ay, b, amp, fn, k = 1) {
+ c.save(); c.translate(ax, ay - b * amp); const sq = (1 - b) * 0.09 * k, st = b * 0.05 * k;
+ c.scale(1 + sq - st * 0.6, 1 - sq + st); c.translate(-ax, -ay); fn(); c.restore();
+ }
+ const ink = (c, w = 6) => { c.strokeStyle = INK; c.lineWidth = w; c.lineJoin = 'round'; c.lineCap = 'round'; };
+ const F = (c, p, col, w = 6) => { c.fillStyle = col; c.fill(p); ink(c, w); c.stroke(p); };
+ const circ = (x, y, r) => { const p = new Path2D(); p.arc(x, y, r, 0, Math.PI * 2); return p; };
+ const ell = (x, y, rx, ry, a = 0) => { const p = new Path2D(); p.ellipse(x, y, rx, ry, a, 0, Math.PI * 2); return p; };
+ // 派切眼:白眼眶+黑瞳,黑瞳上切掉一块楔形(30 年代的标志)
+ function pieEye(c, x, y, rx, ry, look, blink, lash) {
+ if (blink) { ink(c, 5); c.beginPath(); c.ellipse(x, y + ry * 0.2, rx, ry * 0.5, 0, 0.15, Math.PI - 0.15); c.stroke(); return; }
+ F(c, ell(x, y, rx, ry), '#fbf7ec', 4.5);
+ const px = x + look * rx * 0.35, py = y + ry * 0.25;
+ c.save(); c.clip(ell(x, y, rx, ry)); c.fillStyle = INK; c.beginPath(); c.ellipse(px, py, rx * 0.62, ry * 0.7, 0, 0, Math.PI * 2); c.fill();
+ c.fillStyle = '#fbf7ec'; c.beginPath(); c.moveTo(px + rx * 0.05, py - ry * 0.05); c.arc(px, py, ry, -1.45, -0.85); c.closePath(); c.fill(); c.restore();
+ if (lash) { ink(c, 4); for (let k = 0; k < 3; k++) { const a = -2.5 + k * 0.45; c.beginPath(); c.moveTo(x + Math.cos(a) * rx, y + Math.sin(a) * ry); c.lineTo(x + Math.cos(a) * (rx + 14), y + Math.sin(a) * (ry + 14)); c.stroke(); } }
+ }
+ // 橡皮管:没有肘的一根面条(二次贝塞尔),粗细恒定
+ function hose(c, A, B, bend, w, col) {
+ const mx = (A[0] + B[0]) / 2, my = (A[1] + B[1]) / 2, dx = B[0] - A[0], dy = B[1] - A[1], L = Math.hypot(dx, dy) || 1;
+ const C = [mx - dy / L * bend, my + dx / L * bend];
+ c.lineCap = 'round'; c.strokeStyle = INK; c.lineWidth = w + 10; c.beginPath(); c.moveTo(...A); c.quadraticCurveTo(...C, ...B); c.stroke();
+ c.strokeStyle = col; c.lineWidth = w; c.stroke();
+ }
+ // 白手套:四指卡通手,袖口外翻,手背三道线
+ function glove(c, x, y, ang, s = 1) {
+ c.save(); c.translate(x, y); c.rotate(ang); c.scale(s, s);
+ F(c, RIG.smooth([[-30, -14], [-8, -24], [16, -22], [30, -12], [34, 4], [24, 20], [4, 24], [-20, 18], [-32, 4]]), '#fbf7ec', 5);
+ [[22, -18], [30, -6], [30, 8]].forEach(([fx, fy]) => F(c, ell(fx + 6, fy, 11, 8, 0.2), '#fbf7ec', 5));
+ F(c, RIG.smooth([[-30, -20], [-46, -26], [-50, 0], [-46, 26], [-30, 20], [-26, 0]]), '#fbf7ec', 5);
+ ink(c, 3); [-6, 2, 10].forEach(xx => { c.beginPath(); c.moveTo(xx - 10, xx * 0.2 - 2); c.lineTo(xx + 2, xx * 0.2 - 4); c.stroke(); });
+ c.restore();
+ }
+
+ // ---------- 静态底(缓存) ----------
+ const bg = () => P.cached('rh_bg', W, H, (g) => {
+ g.fillStyle = PAPER; g.fillRect(0, 0, W, H);
+ // 墙纸:竖条+小菱点
+ for (let x = 0; x < W; x += 64) { g.fillStyle = '#e5dcc5'; g.fillRect(x, 0, 30, 700); }
+ g.fillStyle = '#cfc5ab'; for (let y = 30; y < 690; y += 70) for (let x = 47; x < W; x += 64) { g.beginPath(); g.moveTo(x, y - 7); g.lineTo(x + 6, y); g.lineTo(x, y + 7); g.lineTo(x - 6, y); g.fill(); }
+ // 地板
+ g.fillStyle = '#cdc3a8'; g.fillRect(0, 712, W, H - 712);
+ ink(g, 3); g.strokeStyle = '#8a816c'; for (let y = 760; y < H; y += 60) { g.beginPath(); g.moveTo(0, y); g.lineTo(W, y); g.stroke(); }
+ for (let k = 0; k < 40; k++) { const y = 712 + Math.floor(k / 8) * 60, x = (k % 8) * 260 + (Math.floor(k / 8) % 2) * 130; g.beginPath(); g.moveTo(x, y); g.lineTo(x, y + 60); g.stroke(); }
+ g.fillStyle = DK; g.fillRect(0, 690, W, 24); ink(g, 5); g.beginPath(); g.moveTo(0, 690); g.lineTo(W, 690); g.moveTo(0, 714); g.lineTo(W, 714); g.stroke();
+ // 水彩式明暗:角落压暗
+ const vg = g.createRadialGradient(900, 480, 300, 900, 520, 1200); vg.addColorStop(0, 'rgba(0,0,0,0)'); vg.addColorStop(1, 'rgba(60,50,35,.35)'); g.fillStyle = vg; g.fillRect(0, 0, W, H);
+ });
+
+ function windowAndSky(c, tq) {
+ // 窗洞里的天
+ c.save(); c.beginPath(); c.rect(360, 130, 440, 420); c.clip();
+ c.fillStyle = '#f6f0e0'; c.fillRect(360, 130, 440, 420);
+ // 远山与树(树随拍点弹)
+ c.fillStyle = LT; c.beginPath(); c.moveTo(360, 480); c.quadraticCurveTo(470, 410, 580, 470); c.quadraticCurveTo(690, 420, 800, 470); c.lineTo(800, 550); c.lineTo(360, 550); c.fill(); ink(c, 4); c.stroke();
+ boing(c, 450, 500, bnc(tq, 0.25), 14, () => { F(c, RIG.smooth([[442, 500], [446, 440], [458, 440], [462, 500]]), DK, 4); F(c, RIG.smooth([[400, 440], [420, 380], [452, 360], [490, 380], [505, 430], [470, 455], [430, 455]]), MID, 5); });
+ // 太阳脸:光芒旋转、脸跟拍点点头
+ const sx = 690, sy = 235, rot = tq * 1.6;
+ c.save(); c.translate(sx, sy); c.rotate(rot); c.fillStyle = '#fbf7ec';
+ for (let k = 0; k < 12; k++) { c.rotate(Math.PI / 6); c.beginPath(); c.moveTo(-12, -66); c.lineTo(0, -108 - (k % 2) * 16); c.lineTo(12, -66); c.closePath(); c.fill(); ink(c, 4); c.stroke(); }
+ c.restore();
+ boing(c, sx, sy + 58, bnc(tq), 8, () => {
+ F(c, circ(sx, sy, 60), '#fbf7ec', 5);
+ pieEye(c, sx - 20, sy - 10, 11, 16, -0.4, 0, false); pieEye(c, sx + 16, sy - 10, 11, 16, -0.4, 0, false);
+ ink(c, 5); c.beginPath(); c.arc(sx - 2, sy + 12, 26, 0.35, Math.PI - 0.35); c.stroke();
+ c.fillStyle = MID; c.beginPath(); c.arc(sx - 36, sy + 14, 9, 0, 7); c.arc(sx + 32, sy + 14, 9, 0, 7); c.fill();
+ });
+ // 云:两朵,随拍伸缩并慢慢飘
+ [[470 + tq * 30, 200, 0.1], [560 + tq * 22, 300, 0.6]].forEach(([x, y, ph]) => boing(c, x, y + 30, bnc(tq, ph), 10, () => {
+ F(c, RIG.smooth([[x - 60, y + 30], [x - 70, y + 6], [x - 40, y - 18], [x - 6, y - 30], [x + 30, y - 22], [x + 62, y - 4], [x + 66, y + 26]]), '#fbf7ec', 5); }));
+ c.restore();
+ // 窗框(白漆粗框+十字)
+ ink(c, 6); c.fillStyle = '#f4eedc';
+ [[350, 120, 460, 18], [350, 542, 460, 18], [350, 120, 18, 440], [792, 120, 18, 440], [571, 120, 18, 440], [350, 328, 460, 16]].forEach(r => { c.fillRect(...r); c.strokeRect(...r); });
+ c.fillStyle = '#f4eedc'; c.fillRect(320, 556, 520, 26); c.strokeRect(320, 556, 520, 26);
+ // 窗帘:圆点布,系起,下摆随拍甩
+ [[330, 1], [830, -1]].forEach(([x, sgn], k) => {
+ const sw = (bnc(tq, 0.5 + k * 0.5) - 0.5) * 18 * sgn;
+ const p = RIG.smooth([[x, 96], [x + sgn * 70, 96], [x + sgn * 54, 260], [x + sgn * 26, 330], [x + sgn * 70 + sw, 520], [x + sgn * 30 + sw, 600], [x - sgn * 4, 600]]);
+ c.fillStyle = MID; c.fill(p); c.save(); c.clip(p); c.fillStyle = '#efe7d2'; for (let yy = 100; yy < 620; yy += 34) for (let xx = x - 80; xx < x + 80; xx += 34) { c.beginPath(); c.arc(xx + (yy / 34 % 2) * 17, yy, 6, 0, 7); c.fill(); } c.restore();
+ ink(c, 5); c.stroke(p); c.fillStyle = INK; c.fillRect(x + sgn * 10 - 10, 318, 50, 14);
+ });
+ ink(c, 8); c.beginPath(); c.moveTo(300, 96); c.lineTo(860, 96); c.stroke();
+ }
+
+ function table(c, tq) {
+ // 桌:桌腿是弯的橡皮管,落拍压扁
+ boing(c, 1005, 905, bnc(tq, 0.5), 16, () => {
+ [[850, 1], [1160, -1]].forEach(([x, s]) => { ink(c, 26); c.beginPath(); c.moveTo(x, 640); c.quadraticCurveTo(x + s * 26, 770, x - s * 6, 900); c.stroke(); c.strokeStyle = '#8f8670'; c.lineWidth = 15; c.stroke(); });
+ F(c, RIG.smooth([[805, 620], [1000, 608], [1205, 620], [1210, 648], [1000, 660], [800, 648]]), '#bdb399', 6);
+ ink(c, 3); c.beginPath(); c.moveTo(830, 640); c.quadraticCurveTo(1000, 650, 1180, 640); c.stroke();
+ // 花瓶+跳舞的花(花有脸,叶子当手挥)
+ F(c, RIG.smooth([[858, 615], [846, 580], [868, 548], [902, 548], [920, 580], [906, 615]]), DK, 5);
+ c.fillStyle = PAPER; [[870, 575], [892, 590], [884, 565]].forEach(([x, y]) => { c.beginPath(); c.arc(x, y, 4, 0, 7); c.fill(); });
+ const sway = Math.sin(Math.PI * tq / BEAT) * 0.35, top = [884 + Math.sin(sway) * 120, 548 - Math.cos(sway) * 120];
+ ink(c, 12); c.beginPath(); c.moveTo(884, 550); c.quadraticCurveTo(884 - sway * 30, 490, top[0], top[1]); c.stroke(); c.strokeStyle = MID; c.lineWidth = 6; c.stroke();
+ const leaf = (s) => { c.save(); c.translate(884 - sway * 20, 500); c.rotate(s * (0.9 + sway * 1.4 * s)); F(c, ell(28 * s, 0, 30, 11), MID, 4.5); c.restore(); }; leaf(1); leaf(-1);
+ c.save(); c.translate(top[0], top[1]); c.rotate(sway);
+ for (let k = 0; k < 8; k++) { c.save(); c.rotate(k / 8 * Math.PI * 2 + tq * 2); F(c, ell(0, -36, 15, 24), '#fbf7ec', 4.5); c.restore(); }
+ F(c, circ(0, 0, 28), LT, 5); pieEye(c, -9, -5, 6, 9, 0.3, 0, false); pieEye(c, 9, -5, 6, 9, 0.3, 0, false);
+ ink(c, 4); c.beginPath(); c.arc(0, 6, 11, 0.3, Math.PI - 0.3); c.stroke(); c.restore();
+ });
+ }
+
+ function chair(c) {
+ ink(c, 6); c.fillStyle = '#8f8670';
+ [[1436, 1], [1496, -1]].forEach(([x, s]) => { ink(c, 22); c.beginPath(); c.moveTo(x, 460); c.quadraticCurveTo(x - s * 14, 700, x + s * 4, 905); c.stroke(); c.strokeStyle = '#8f8670'; c.lineWidth = 11; c.stroke(); });
+ const back = RIG.smooth([[1416, 470], [1440, 420], [1470, 404], [1500, 420], [1522, 470], [1500, 480], [1470, 466], [1440, 480]]);
+ c.fill(back); c.stroke(back); [500, 560].forEach(y => { c.fillStyle = '#8f8670'; c.fillRect(1436, y, 60, 14); c.strokeRect(1436, y, 60, 14); });
+ }
+
+ function girl(c, tq, lt, t) {
+ const ch = P.choreo(lt, t);
+ const cup = 0.5 - 0.5 * Math.cos(clamp(Math.floor(lt * 12) / 12 / 0.9) * Math.PI); // 端杯也按一拍二步进
+ const G = RIG.girl({ cup, sip: 0, dx: 0, dy: 0 });
+ const b = bnc(tq, 0.25);
+ boing(c, 1240, 930, b, 18, () => {
+ // 裙:深色波点长裙
+ F(c, G.skirt, DK, 6);
+ c.save(); c.clip(G.skirt); c.fillStyle = PAPER; for (let y = 640; y < 940; y += 40) for (let x = 1090; x < 1470; x += 40) { c.beginPath(); c.arc(x + (y / 40 % 2) * 20, y, 7, 0, 7); c.fill(); } c.restore();
+ ink(c, 6); c.stroke(G.skirt);
+ F(c, ell(1120, 924, 34, 15), INK, 4); F(c, ell(1170, 928, 30, 13), INK, 4); // 玛丽珍鞋
+ // 远手:搭桌上的橡皮管+手套
+ hose(c, [1340, 480], [1196, 612], -30, 14, '#f4eedc'); glove(c, 1180, 614, Math.PI, 0.9);
+ // 身体
+ F(c, G.torso, DK, 6);
+ c.save(); c.clip(G.torso); c.fillStyle = PAPER; for (let y = 440; y < 630; y += 40) for (let x = 1280; x < 1430; x += 40) { c.beginPath(); c.arc(x + (y / 40 % 2) * 20, y, 7, 0, 7); c.fill(); } c.restore(); ink(c, 6); c.stroke(G.torso);
+ // 头:大圆头,略比骨架大,朝左
+ const hc = [G.A.headC[0] - 14, G.A.headC[1] - 14], R0 = 82;
+ F(c, ell(G.A.neck[0], G.A.neck[1] - 6, 18, 26), '#f4eedc', 5);
+ F(c, RIG.smooth([[G.A.neck[0] - 44, G.A.neck[1] + 4], [G.A.neck[0] - 16, G.A.neck[1] + 28], [G.A.neck[0] + 6, G.A.neck[1] + 10], [G.A.neck[0] + 30, G.A.neck[1] + 28], [G.A.neck[0] + 54, G.A.neck[1] + 2], [G.A.neck[0], G.A.neck[1] - 6]]), '#fbf7ec', 5); // 小圆领
+ // 后脑卷发
+ F(c, RIG.smooth([[hc[0] + 10, hc[1] - 78], [hc[0] + 70, hc[1] - 62], [hc[0] + 100, hc[1] - 10], [hc[0] + 96, hc[1] + 50], [hc[0] + 66, hc[1] + 84], [hc[0] + 30, hc[1] + 60], [hc[0] + 10, hc[1]]]), '#ddd2ae', 6);
+ F(c, ell(hc[0], hc[1] + 4, R0 * 0.86, R0 * 0.9), '#f8f3e6', 6); // 脸
+ F(c, RIG.smooth([[hc[0] - 70, hc[1] - 30], [hc[0] - 50, hc[1] - 74], [hc[0] + 10, hc[1] - 88], [hc[0] + 70, hc[1] - 64], [hc[0] + 84, hc[1] - 6], [hc[0] + 40, hc[1] - 30], [hc[0] + 6, hc[1] - 46], [hc[0] - 36, hc[1] - 38]]), '#ddd2ae', 6); // 刘海
+ ink(c, 4); for (let k = 0; k < 3; k++) { c.beginPath(); c.arc(hc[0] + 70 + k * 6, hc[1] + 10 + k * 22, 10, 0.5, 5.5); c.stroke(); } // 卷
+ // 金发要读成头发不是软帽:发丝线+卡通高光(白月牙)
+ ink(c, 3.5); [[-40, -60, 20, -40], [-10, -74, 50, -50], [30, -78, 80, -40], [60, -50, 92, 10], [70, -10, 90, 50]].forEach(([a, b, c2, d]) => { c.beginPath(); c.moveTo(hc[0] + a, hc[1] + b); c.quadraticCurveTo(hc[0] + (a + c2) / 2 + 10, hc[1] + (b + d) / 2 - 12, hc[0] + c2, hc[1] + d); c.stroke(); });
+ c.fillStyle = '#fbf7ec'; c.beginPath(); c.ellipse(hc[0] + 40, hc[1] - 56, 22, 7, 0.5, 0, 7); c.fill();
+ // 头顶大蝴蝶结:比身体多晚半拍弹(跟随)
+ const bb = bnc(tq, 0.05) * 10;
+ c.save(); c.translate(hc[0] + 40, hc[1] - 84 - bb); c.rotate(0.3);
+ F(c, RIG.smooth([[0, 0], [-46, -30], [-52, 18]]), INK, 4); F(c, RIG.smooth([[0, 0], [46, -30], [52, 18]]), INK, 4); F(c, circ(0, 0, 12), INK, 4); c.restore();
+ const blink = ch.blink && !(cup > 0.85);
+ pieEye(c, hc[0] - 44, hc[1] - 4, 15, 23, -0.7, blink || cup > 0.85, true); pieEye(c, hc[0] - 8, hc[1] - 6, 17, 26, -0.7, blink || cup > 0.85, true);
+ c.fillStyle = INK; c.beginPath(); c.arc(hc[0] - 72, hc[1] + 20, 7, 0, 7); c.fill(); // 鼻头
+ c.fillStyle = MID; c.beginPath(); c.arc(hc[0] - 20, hc[1] + 34, 13, 0, 7); c.fill();
+ ink(c, 5); c.beginPath(); c.moveTo(hc[0] - 60, hc[1] + 46); c.quadraticCurveTo(hc[0] - 46, hc[1] + 56, hc[0] - 34, hc[1] + 44); c.stroke();
+ // 近手:橡皮管从肩到手,杯子在手前
+ const S = [G.A.shoulder[0] - 6, G.A.shoulder[1] + 4], Hd = G.A.hand;
+ F(c, ell(S[0], S[1], 34, 28), '#fbf7ec', 5); // 泡泡袖
+ hose(c, S, Hd, 40 - cup * 30, 14, '#f4eedc');
+ glove(c, Hd[0], Hd[1], -2.6 + cup * 0.8, 1);
+ const cp = G.cup; c.save(); c.translate(cp.x, cp.y); c.rotate(cp.tilt);
+ F(c, RIG.smooth([[-30, 0], [-26, 34], [0, 44], [26, 34], [30, 0]], true), '#fbf7ec', 5); ink(c, 5); c.beginPath(); c.arc(34, 18, 12, -1.3, 1.5); c.stroke();
+ c.fillStyle = MID; c.beginPath(); c.ellipse(0, 2, 28, 6, 0, 0, 7); c.fill(); c.stroke();
+ c.restore();
+ // 热气:卡通烟圈,一拍冒一个
+ for (let k = 0; k < 3; k++) { const q = ((tq / BEAT) + k / 3) % 1; ink(c, 4); c.beginPath(); c.ellipse(cp.x + Math.sin(q * 6) * 8, cp.y - 20 - q * 90, 10 + q * 10, 6 + q * 6, 0, 0, 7); c.globalAlpha = 1 - q; c.stroke(); c.globalAlpha = 1; }
+ }, 1.2);
+ }
+
+ function cat(c, tq, t) {
+ const K = RIG.cat({ tail: 0, blink: 0, breathe: 0 });
+ boing(c, 540, 905, bnc(tq, 0.75), 30, () => {
+ // 尾巴:一根波浪橡皮管
+ const base = [460, 880]; ink(c, 1); const pts = [];
+ for (let i = 0; i <= 20; i++) { const q = i / 20; pts.push([base[0] - q * 150, base[1] - q * 200 + Math.sin(q * 7 - tq * 9) * 26 * q]); }
+ c.lineCap = 'round'; c.strokeStyle = INK; c.lineWidth = 32; c.beginPath(); pts.forEach((p, i) => i ? c.lineTo(...p) : c.moveTo(...p)); c.stroke();
+ c.strokeStyle = MID; c.lineWidth = 20; c.stroke(); c.fillStyle = '#fbf7ec'; c.beginPath(); c.arc(...pts[20], 12, 0, 7); c.fill();
+ const body = RIG.smooth(K.bodyPts); // 骨架的身体是折线,卡通要圆:Catmull-Rom 一下
+ F(c, body, MID, 6);
+ c.save(); c.clip(body); c.fillStyle = '#fbf7ec'; c.fill(RIG.smooth([[566, 700], [612, 690], [642, 742], [636, 830], [596, 870], [560, 800]])); ink(c, 9); c.strokeStyle = DK; K.stripes.slice(3).forEach(s => { c.beginPath(); c.moveTo(...s[0]); c.lineTo(...s[1]); c.stroke(); }); c.restore();
+ ink(c, 6); c.stroke(body);
+ // 白爪(大圆手套脚)
+ F(c, ell(585, 892, 30, 18), '#fbf7ec', 5); F(c, ell(640, 892, 30, 18), '#fbf7ec', 5);
+ // 头:橘(中灰)头顶虎斑,白口鼻,派切大眼,咧嘴笑
+ const hb = bnc(tq, 0.95) * 8;
+ c.save(); c.translate(0, -hb);
+ F(c, K.head, MID, 6);
+ c.save(); c.clip(K.head); ink(c, 9); c.strokeStyle = DK; K.stripes.slice(0, 3).forEach(s => { c.beginPath(); c.moveTo(...s[0]); c.lineTo(...s[1]); c.stroke(); }); c.restore();
+ F(c, ell(630, 652, 40, 28), '#fbf7ec', 5);
+ pieEye(c, 610, 610, 15, 22, 0.6, 0, false); pieEye(c, 648, 607, 15, 22, 0.6, 0, false);
+ c.fillStyle = INK; c.beginPath(); c.ellipse(656, 636, 10, 7, 0, 0, 7); c.fill();
+ ink(c, 5); c.beginPath(); c.moveTo(612, 650); c.quadraticCurveTo(640, 676, 670, 646); c.stroke();
+ ink(c, 3); [[660, 640, 716, 626], [662, 648, 718, 650], [600, 646, 552, 634]].forEach(([a, b, c2, d]) => { c.beginPath(); c.moveTo(a, b); c.lineTo(c2, d); c.stroke(); });
+ c.restore();
+ }, 1.4);
+ }
+
+ // ---------- 胶片层:P.film(24fps 闪烁、跨格存活的划痕、灰尘毛发、颗粒抖动、圆角片门) ----------
+ const film = (c, t) => P.film(c, t, { grain: 'rhg' });
+
+ return {
+ draw(c, lt, t) {
+ const tq = U.stepTime(t, 12); // 一拍二:12 张/秒(步进帧率是这个风格的味道本身)
+ P.gateWeave(c, t, () => { // 抖片(gate weave,24fps)
+ c.drawImage(bg(), 0, 0);
+ windowAndSky(c, tq);
+ chair(c);
+ table(c, tq);
+ girl(c, tq, lt, t);
+ cat(c, tq, t);
+ });
+ // 胶片褪色成单色暖灰(防止任何残余彩色)
+ P.fade(c, { sat: 1, tint: '#f2e8d2' });
+ film(c, t);
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/34_shadowpuppet.js b/scripts/engine/scenes/34_shadowpuppet.js
new file mode 100644
index 0000000..02d9f91
--- /dev/null
+++ b/scripts/engine/scenes/34_shadowpuppet.js
@@ -0,0 +1,195 @@
+// 中国皮影戏 —— 纯代码。
+// 管线:①影窗(油灯在幕后的暖光斑+布纹,灯焰摇曳→光斑位置/亮度抖)→ ②每个「皮件」在离屏层上:填半透明彩色 → 镂空(destination-out 刻纹)
+// → 补皮边 → 整层 multiply 印到幕布上(皮子透光=幕布色×皮色,重叠处自然变深)+偏移软影(皮件没贴紧幕布时的虚影)
+// → ③铆钉、操纵杆(杆子在幕后,糊一点)→ ④布纹+木框
+// 动作:杆子操纵的僵直关节——每块皮件是刚体,只绕铆钉转;手腕是松的,会甩;整个人随主杆轻摆;节奏按 10fps 步进。
+SCENES['34_shadowpuppet'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, rng } = U, P = PAINT;
+ const RED = '#c0352a', GRN = '#2f7d4c', AMB = '#d99a2e', YEL = '#e2bd4a', EDGE = '#3a160a', BLU = '#2c5a8a', ORG = '#d9782a';
+ const step = (t, fps = 10) => U.stepTime(t, fps); // 杆操的「一顿一顿」:10fps 步进
+ // ---------- 刻纹(在 clip 内 destination-out) ----------
+ // 刻纹库 P.carve(鱼子/团花/云纹/方格/刻线);皮件 P.piece(填→刻→补皮边→描边);印到幕布 P.stamp(软影+multiply)
+ const K = P.carve;
+ const piece = (g, path, col, carve, edge = 5) => P.piece(g, path, col, carve, { edge, line: EDGE });
+ const rivet = (c, x, y, r = 7) => { c.fillStyle = '#2a1006'; c.beginPath(); c.arc(x, y, r, 0, 7); c.fill(); c.fillStyle = '#b07a3a'; c.beginPath(); c.arc(x - 1, y - 1, r * 0.42, 0, 7); c.fill(); };
+ const rod = (c, A, B) => { c.save(); c.filter = 'blur(1.2px)'; c.globalCompositeOperation = 'multiply'; c.strokeStyle = 'rgba(60,30,12,.85)'; c.lineWidth = 5; c.beginPath(); c.moveTo(...A); c.lineTo(...B); c.stroke(); c.restore(); };
+ const rot = (p, o, a) => { const c = Math.cos(a), s = Math.sin(a), x = p[0] - o[0], y = p[1] - o[1]; return [o[0] + x * c - y * s, o[1] + x * s + y * c]; };
+ const tr = (path, o, a) => { const m = new DOMMatrix().translate(o[0], o[1]).rotate(a * 180 / Math.PI).translate(-o[0], -o[1]); const p = new Path2D(); p.addPath(path, m); return p; };
+ const stamp = (c, layer, dx = 7, dy = 5) => P.stamp(c, layer, { dx, dy });
+
+ // ---------- 影窗 ----------
+ function screen(c, t) {
+ const ft = step(t, 15), fl = 0.5 * P.noise(ft * 3, 1) + 0.3 * P.noise(ft * 9, 4);
+ const cx = 960 + fl * 26, cy = 470 + P.noise(ft * 2, 7) * 18;
+ const g = c.createRadialGradient(cx, cy, 30, cx, cy + 40, 1150);
+ g.addColorStop(0, `rgb(${255},${246 + fl * 8},${214 + fl * 20})`); g.addColorStop(0.35, '#f2d7a0'); g.addColorStop(0.7, '#cf9a58'); g.addColorStop(1, '#7a4a20');
+ c.fillStyle = g; c.fillRect(0, 0, W, H);
+ // 灯芯热点:一小团更亮的光,随灯焰跳
+ c.save(); c.globalCompositeOperation = 'screen'; const hg = c.createRadialGradient(cx, cy - 10, 0, cx, cy - 10, 260 + fl * 40); hg.addColorStop(0, `rgba(255,236,190,${0.55 + fl * 0.25})`); hg.addColorStop(1, 'rgba(255,236,190,0)'); c.fillStyle = hg; c.fillRect(0, 0, W, H); c.restore();
+ // 布纹(缓存)
+ c.save(); c.globalCompositeOperation = 'multiply'; c.drawImage(P.cached('py_weave', W, H, (w) => {
+ w.fillStyle = '#fff'; w.fillRect(0, 0, W, H); w.strokeStyle = 'rgba(120,90,50,.08)'; w.lineWidth = 1;
+ for (let x = 0; x < W; x += 3) { w.beginPath(); w.moveTo(x, 0); w.lineTo(x, H); w.stroke(); } for (let y = 0; y < H; y += 3) { w.beginPath(); w.moveTo(0, y); w.lineTo(W, y); w.stroke(); }
+ w.drawImage(P.grain('pyg', 0.06, [120, 80, 40], 0.3), 0, 0);
+ }), 0, 0); c.restore();
+ return fl;
+ }
+
+ // ---------- 道具:窗(窗棂+梅枝)、桌(万字纹桌裙)、瓶花 ----------
+ const props = () => P.cached('py_props', W, H, (g) => {
+ // 窗:外框+冰裂/方格窗棂(大面积镂空)
+ const win = new Path2D(); win.rect(350, 120, 460, 440);
+ piece(g, win, '#8a4a22', (q) => {
+ q.fillRect(372, 142, 416, 396);
+ }, 4);
+ g.save(); g.beginPath(); g.rect(372, 142, 416, 396); g.clip();
+ g.strokeStyle = '#8a4a22'; g.lineWidth = 9; const r = rng(3);
+ for (let x = 372; x <= 788; x += 69) { g.beginPath(); g.moveTo(x, 142); g.lineTo(x, 538); g.stroke(); }
+ for (let y = 142; y <= 538; y += 66) { g.beginPath(); g.moveTo(372, y); g.lineTo(788, y); g.stroke(); }
+ g.strokeStyle = EDGE; g.lineWidth = 2; for (let x = 372; x <= 788; x += 69) { g.strokeRect(x - 4.5, 142, 9, 396); } for (let y = 142; y <= 538; y += 66) g.strokeRect(372, y - 4.5, 416, 9);
+ g.restore();
+ // 窗台
+ piece(g, (() => { const p = new Path2D(); p.rect(326, 556, 508, 26); return p; })(), '#8a4a22', (q) => K.dots(q, 336, 562, 830, 580, 14, 3), 3);
+ // 桌:桌面+桌裙(万字纹格镂空)+两条腿
+ const top = new Path2D(); top.rect(806, 612, 410, 30); piece(g, top, '#9a3a1c', (q) => K.dots(q, 816, 620, 1210, 640, 16, 3));
+ const apron = new Path2D(); apron.rect(826, 642, 370, 70); piece(g, apron, '#9a3a1c', (q) => K.lattice(q, 834, 648, 1190, 708, 30, 14));
+ [[836, 642], [1076, 642]].forEach(([x, y]) => { const l = new Path2D(); l.moveTo(x, y); l.lineTo(x + 28, y); l.lineTo(x + 24 + (x < 900 ? -6 : 6), 905); l.lineTo(x + 4 + (x < 900 ? -6 : 6), 905); l.closePath(); piece(g, l, '#9a3a1c', (q) => K.dots(q, x + 8, y + 90, x + 22, 890, 30, 4)); });
+ // 瓶+牡丹
+ const vase = RIG.smooth([[860, 612], [846, 578], [866, 548], [900, 548], [922, 578], [908, 612]]); piece(g, vase, BLU, (q) => K.clouds(q, 852, 560, 916, 608, 26));
+ g.strokeStyle = GRN; g.lineWidth = 7; [[878, 548, 850, 480], [890, 548, 920, 470]].forEach(([a, b, c2, d]) => { g.beginPath(); g.moveTo(a, b); g.lineTo(c2, d); g.stroke(); });
+ [[850, 474, 30, RED], [922, 462, 34, '#d0506a']].forEach(([x, y, rr, col]) => { const f = new Path2D(); for (let k = 0; k < 10; k++) { const a = k / 10 * Math.PI * 2; f.moveTo(x + Math.cos(a) * rr * 0.5, y + Math.sin(a) * rr * 0.5); f.ellipse(x + Math.cos(a) * rr * 0.6, y + Math.sin(a) * rr * 0.6, rr * 0.45, rr * 0.3, a, 0, 7); }
+ piece(g, f, col, (q) => { q.beginPath(); q.arc(x, y, rr * 0.22, 0, 7); q.fill(); K.dots(q, x - rr, y - rr, x + rr, y + rr, 12, 2); }, 3); });
+ // 椅:方背椅
+ const chair = new Path2D(); chair.rect(1430, 470, 64, 440); piece(g, chair, '#7a3a1a', (q) => K.lattice(q, 1436, 480, 1490, 900, 32, 18), 4);
+ });
+
+ return {
+ draw(c, lt, t) {
+ const fl = screen(c, t);
+ const ts = step(t), ls = step(lt);
+ stamp(c, props(), 6, 4);
+ // 窗外的皮影蝴蝶:翅膀按 12fps 扇(scaleX 翻面),杆子操纵着沿弧线飞
+ { const L = P.scratch('pyBf'), g = L.getContext('2d'); g.reset();
+ const q = step(lt, 12), bx = 520 + q * 150, by = 300 - Math.sin(q * 3) * 50, flap = Math.abs(Math.cos(q * 15));
+ g.save(); g.translate(bx, by); g.rotate(0.3);
+ [-1, 1].forEach(sd => { g.save(); g.scale(sd * (0.25 + flap * 0.75), 1);
+ piece(g, RIG.smooth([[0, -4], [40, -46], [74, -30], [62, 4], [30, 10]]), sd > 0 ? RED : GRN, (k) => K.dots(k, 10, -40, 70, 6, 14, 3.5), 3);
+ piece(g, RIG.smooth([[0, 4], [34, 14], [46, 44], [16, 40]]), YEL, (k) => K.dots(k, 8, 10, 44, 40, 12, 3), 3); g.restore(); });
+ piece(g, (() => { const p = new Path2D(); p.ellipse(0, 6, 7, 22, 0, 0, 7); return p; })(), EDGE, null, 2); g.restore();
+ stamp(c, L, 5, 4); rod(c, [bx + 4, by + 24], [780, 1080]); }
+ // ---------- 猫 ----------
+ const ch = P.choreo(lt, t);
+ const KT = RIG.cat({ breathe: 0 });
+ { const L = P.scratch('pyCat'), g = L.getContext('2d'); g.reset();
+ const sway = 0.02 * Math.sin(ts * 5);
+ g.save(); g.translate(540, 905); g.rotate(sway); g.translate(-540, -905);
+ // 尾巴:4 节皮件铰链,每节相对上一节转一个相位滞后的角度(鞭梢)
+ let o = [452, 884], ang = -3.0;
+ const segs = [];
+ for (let i = 0; i < 4; i++) { ang += 0.3 * Math.sin(ts * 7 - i * 0.9) + (i ? 0.38 : 0); const L_ = 64 - i * 6, e = [o[0] + Math.cos(ang) * L_, o[1] + Math.sin(ang) * L_];
+ const p = RIG.taper(o, e, 30 - i * 4, 26 - i * 4); segs.push([p, o, i]); o = e; }
+ segs.forEach(([p, oo, i]) => piece(g, p, i === 3 ? '#efe6cc' : ORG, i === 3 ? null : (k) => K.lines(k, [[[oo[0] - 6, oo[1] - 10], [oo[0] + 8, oo[1] + 10]]], 4), 3));
+ // 身体(橘皮,背上刻虎斑;白肚=镂空只留皮边)
+ const body = RIG.smooth(KT.bodyPts);
+ piece(g, body, ORG, (k) => {
+ k.fill(RIG.smooth([[566, 704], [612, 694], [640, 744], [632, 828], [596, 868], [562, 802]])); // 白胸肚:整块镂空
+ K.lines(k, [[[448, 742], [492, 752]], [[440, 782], [486, 792]], [[436, 824], [480, 832]], [[500, 692], [524, 718]], [[470, 860], [510, 866]]], 7);
+ K.dots(k, 470, 700, 540, 880, 22, 3);
+ }, 5);
+ g.strokeStyle = EDGE; g.lineWidth = 2.2; g.stroke(RIG.smooth([[566, 704], [612, 694], [640, 744], [632, 828], [596, 868], [562, 802]]));
+ // 前腿一件(白爪也是镂空)
+ [[588, 1], [636, 1]].forEach(([x]) => { const leg = RIG.taper([x, 750], [x, 892], 30, 34);
+ piece(g, leg, '#f0e4c4', (k) => { k.fillRect(x - 10, 770, 20, 104); }, 4); }); // 白腿白爪:几乎全镂空,只留皮边
+ g.strokeStyle = EDGE; g.lineWidth = 2; [[588], [636]].forEach(([x]) => { g.beginPath(); g.moveTo(x - 8, 892); g.lineTo(x - 8, 880); g.moveTo(x + 4, 892); g.lineTo(x + 4, 880); g.stroke(); });
+ g.restore();
+ // 头:单独一件,绕颈部铆钉点头(10fps 一顿一顿)
+ const nk = [588, 680], nod = 0.1 * Math.sin(ts * 6) + 0.05;
+ g.save(); g.translate(540, 905); g.rotate(sway); g.translate(-540, -905);
+ g.save(); g.translate(nk[0], nk[1]); g.rotate(nod); g.translate(-nk[0], -nk[1]);
+ piece(g, KT.head, ORG, (k) => {
+ k.beginPath(); k.ellipse(632, 650, 36, 24, 0, 0, 7); k.fill(); // 白口鼻镂空
+ K.lines(k, [[[585, 572], [590, 598]], [[605, 566], [607, 594]], [[625, 572], [622, 596]]], 6); // 头顶虎斑
+ k.beginPath(); k.moveTo(598, 612); k.quadraticCurveTo(612, 600, 626, 612); k.quadraticCurveTo(612, 620, 598, 612); k.fill(); // 眼:柳叶形镂空
+ k.beginPath(); k.moveTo(636, 610); k.quadraticCurveTo(650, 598, 664, 608); k.quadraticCurveTo(650, 618, 636, 610); k.fill();
+ K.clouds(k, 560, 620, 600, 680, 30);
+ }, 4);
+ g.strokeStyle = EDGE; g.lineWidth = 2; g.beginPath(); g.ellipse(632, 650, 36, 24, 0, 0, 7); g.stroke();
+ g.fillStyle = EDGE; g.beginPath(); g.arc(612, 610, 4, 0, 7); g.arc(650, 607, 4, 0, 7); g.fill(); g.beginPath(); g.arc(656, 640, 5, 0, 7); g.fill();
+ g.lineWidth = 1.8; [[660, 645, 712, 632], [660, 650, 715, 655]].forEach(([a, b, c2, d]) => { g.beginPath(); g.moveTo(a, b); g.lineTo(c2, d); g.stroke(); });
+ g.restore(); g.restore();
+ stamp(c, L, 7, 5);
+ const nk2 = rot(nk, [540, 905], sway); rivet(c, nk2[0], nk2[1]); segs.forEach(([, oo]) => { const q = rot(oo, [540, 905], sway); rivet(c, q[0], q[1], 5); });
+ rod(c, rot([520, 760], [540, 905], sway), [470, 1080]); rod(c, rot([600, 600], [540, 905], sway), [610, 1080]);
+ }
+ // ---------- 少女 ----------
+ { const L = P.scratch('pyGirl'), g = L.getContext('2d'); g.reset();
+ const cupJ = 0.5 - 0.5 * Math.cos(clamp(ls / 0.85) * Math.PI); // 杆子端杯:10fps 步进
+ const G = RIG.girl({ cup: cupJ, hair: 'bun' });
+ const pivot = [1260, 930], sway = 0.012 * Math.sin(ts * 4.4);
+ g.save(); g.translate(...pivot); g.rotate(sway); g.translate(-pivot[0], -pivot[1]);
+ // 远侧袖(绿)+手
+ piece(g, G.farSleeve, GRN, (k) => K.clouds(k, 1220, 470, 1360, 630, 34));
+ piece(g, G.farHand, '#efe2c4', null, 3);
+ // 裙:绿长裙,竖刻褶线+下摆鱼子纹边
+ piece(g, G.skirt, GRN, (k) => {
+ K.lines(k, [[[1170, 700], [1150, 900]], [[1210, 690], [1196, 910]], [[1250, 680], [1244, 910]], [[1290, 680], [1292, 900]], [[1330, 700], [1340, 790]]], 3.5);
+ K.dots(k, 1110, 880, 1360, 920, 14, 3.2); K.flowers(k, 1380, 640, 1450, 760, 40, 4.5);
+ });
+ // 上衣:红袄,刻团花;领口/襟边一条黄色宽边
+ piece(g, G.torso, RED, (k) => K.flowers(k, 1300, 470, 1420, 610, 44, 5));
+ piece(g, RIG.smooth([[1290, 436], [1318, 430], [1316, 470], [1306, 540], [1300, 610], [1286, 610], [1284, 520]]), YEL, (k) => K.dots(k, 1286, 446, 1318, 600, 12, 2.5), 3);
+ // 头:发(琥珀色皮=金发,刻云纹)→ 空脸(脸整个镂空,只留皮边与五官线)→ 头茬(花钿、簪、步摇珠串)
+ const nk = G.A.neck, hTilt = 0.06 * Math.sin(ts * 3); // 头绕颈部铆钉微转
+ g.save(); g.translate(...nk); g.rotate(hTilt); g.translate(-nk[0], -nk[1]);
+ piece(g, G.hairBack, AMB, (k) => K.clouds(k, 1290, 300, 1420, 440, 30));
+ piece(g, G.bun, AMB, (k) => K.clouds(k, 1360, 340, 1420, 404, 22));
+ g.save(); g.globalCompositeOperation = 'destination-out'; g.fill(G.face); g.restore();
+ g.strokeStyle = EDGE; g.lineWidth = 3; g.stroke(G.face);
+ g.strokeStyle = AMB; g.lineWidth = 7; g.save(); g.clip(G.face); g.stroke(G.face); g.restore();
+ piece(g, G.bangs, AMB, (k) => K.clouds(k, 1250, 296, 1340, 360, 24));
+ // 五官:凤眼(细长挑梢)、柳叶眉、点唇——都是皮上留的线
+ const e = G.eye; g.strokeStyle = EDGE; g.lineWidth = 2.6; g.beginPath(); g.moveTo(e.x - 12, e.y + 1); g.quadraticCurveTo(e.x, e.y - 6, e.x + 16, e.y - 4); g.stroke();
+ g.lineWidth = 2; g.beginPath(); g.moveTo(e.x - 10, e.y + 2); g.quadraticCurveTo(e.x, e.y + 4, e.x + 12, e.y - 1); g.stroke();
+ g.fillStyle = EDGE; g.beginPath(); g.arc(e.x - 2, e.y - 1, 2.6, 0, 7); g.fill();
+ g.lineWidth = 2.4; g.stroke(G.brow);
+ g.fillStyle = RED; g.beginPath(); g.arc(G.lips[1][0] - 1, G.lips[1][1] + 2, 4, 0, 7); g.fill();
+ // 头茬:发顶一朵大花+两根簪+垂下的步摇
+ const ht = G.A.headTop; const flw = new Path2D(); for (let k = 0; k < 6; k++) { const a = k / 6 * Math.PI * 2; flw.moveTo(ht[0] + 20 + Math.cos(a) * 26, ht[1] + 6 + Math.sin(a) * 26); flw.arc(ht[0] + 20 + Math.cos(a) * 18, ht[1] + 6 + Math.sin(a) * 18, 12, 0, 7); }
+ piece(g, flw, RED, (k) => { k.beginPath(); k.arc(ht[0] + 20, ht[1] + 6, 7, 0, 7); k.fill(); }, 3);
+ g.strokeStyle = BLU; g.lineWidth = 5; g.beginPath(); g.moveTo(ht[0] + 40, ht[1] + 30); g.lineTo(ht[0] + 110, ht[1] - 10); g.stroke(); g.strokeStyle = EDGE; g.lineWidth = 1.6; g.stroke();
+ const sw = 0.4 * Math.sin(ts * 9); // 步摇:串珠随头动甩
+ g.fillStyle = YEL; g.strokeStyle = EDGE; g.lineWidth = 1.5; for (let k = 0; k < 4; k++) { const bx = ht[0] + 108 + Math.sin(sw) * k * 11, by = ht[1] - 4 + Math.cos(sw) * k * 11; g.beginPath(); g.arc(bx, by, 5, 0, 7); g.fill(); g.stroke(); }
+ g.restore();
+ // 近侧手臂:上臂/前臂/手三件刚体,铆钉相连;手腕松,会甩
+ const S = G.A.shoulder, E = G.A.elbow, Hd = G.A.hand;
+ piece(g, RIG.taper(S, E, 50, 42), RED, (k) => K.clouds(k, Math.min(S[0], E[0]) - 30, Math.min(S[1], E[1]) - 30, Math.max(S[0], E[0]) + 30, Math.max(S[1], E[1]) + 30, 30));
+ const Wr = [lerp(E[0], Hd[0], 0.8), lerp(E[1], Hd[1], 0.8)];
+ piece(g, RIG.taper(E, Wr, 44, 50), RED, (k) => K.flowers(k, Math.min(E[0], Wr[0]) - 30, Math.min(E[1], Wr[1]) - 30, Math.max(E[0], Wr[0]) + 30, Math.max(E[1], Wr[1]) + 30, 36, 4));
+ piece(g, RIG.taper([lerp(E[0], Hd[0], 0.66), lerp(E[1], Hd[1], 0.66)], Wr, 52, 58), YEL, (k) => K.dots(k, Wr[0] - 40, Wr[1] - 40, Wr[0] + 40, Wr[1] + 40, 10, 2.2), 3);
+ const dangle = 0.35 * Math.sin(ls * 11) * (1 - cupJ * 0.6);
+ g.save(); g.translate(...Wr); g.rotate(dangle); g.translate(-Wr[0], -Wr[1]);
+ const hand = new Path2D(); hand.ellipse(Hd[0], Hd[1], 17, 13, Math.atan2(Hd[1] - E[1], Hd[0] - E[0]), 0, 7);
+ g.save(); g.globalCompositeOperation = 'destination-out'; g.fill(hand); g.restore(); g.strokeStyle = EDGE; g.lineWidth = 2.6; g.stroke(hand); // 手也是空的
+ const cp = G.cup, cup = RIG.smooth([[cp.x - 24, cp.y], [cp.x - 20, cp.y + 34], [cp.x, cp.y + 42], [cp.x + 20, cp.y + 34], [cp.x + 24, cp.y]]);
+ piece(g, tr(cup, [cp.x, cp.y], cp.tilt), BLU, (k) => K.flowers(k, cp.x - 30, cp.y, cp.x + 30, cp.y + 44, 24, 3.5), 3);
+ g.restore();
+ g.restore();
+ stamp(c, L, 8, 5);
+ // 铆钉与杆:颈、肩、肘、腕;主杆在颈,手杆在腕
+ const R = p => rot(p, pivot, sway);
+ [nk, S, E, Wr].forEach(p => { const q = R(p); rivet(c, q[0], q[1]); });
+ rod(c, R(nk), [1420, 1080]); rod(c, R(Wr), [1180, 1080]); rod(c, [1170, 615], [1060, 1080]);
+ // 热气:皮影里用一缕刻出来的云纹皮条表示,跟着杯子飘
+ const sx = G.cup.x, sy = G.cup.y - 20;
+ c.save(); c.globalCompositeOperation = 'multiply'; c.strokeStyle = 'rgba(160,110,60,.55)'; c.lineWidth = 5; c.lineCap = 'round';
+ for (let k = 0; k < 2; k++) { c.beginPath(); for (let i = 0; i <= 14; i++) { const q = i / 14; const x = sx + k * 14 + Math.sin(q * 6 - ts * 6 + k) * 8, y = sy - q * 60; i ? c.lineTo(x, y) : c.moveTo(x, y); } c.stroke(); } c.restore();
+ }
+ // 木框(影窗边)
+ c.drawImage(P.cached('py_frame', W, H, (g) => {
+ g.fillStyle = '#2a140a'; g.beginPath(); g.rect(0, 0, W, H); g.rect(28, 24, W - 56, H - 48); g.fill('evenodd');
+ g.strokeStyle = '#a8742e'; g.lineWidth = 3; g.strokeRect(34, 30, W - 68, H - 60);
+ const vg = g.createRadialGradient(960, 500, 500, 960, 540, 1150); vg.addColorStop(0, 'rgba(40,15,0,0)'); vg.addColorStop(1, 'rgba(40,15,0,.45)'); g.fillStyle = vg; g.fillRect(28, 24, W - 56, H - 48);
+ }), 0, 0);
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/35_shinkai.js b/scripts/engine/scenes/35_shinkai.js
new file mode 100644
index 0000000..8485c29
--- /dev/null
+++ b/scripts/engine/scenes/35_shinkai.js
@@ -0,0 +1,197 @@
+// 2016 新海诚光影 —— 纯代码。
+// 管线:①天空(极透明的蓝渐变+积雨云:逐团球体打光+暖色受光边,缓慢翻涌)+电线杆/电线/远处屋顶 + 飞机拉线
+// → ②写实背景(墙面冷暖渐变、木地板反光、桌椅盆栽)→ ③窗玻璃水珠(折射天空、高光、一颗慢慢滑下)
+// → ④赛璐珞角色:每个部件「底色 → 背光侧硬阴影 → 受光侧亮边 → 细描线」,阴影/亮边用「自身减去平移后的自身」算(evenodd 反选)
+// → ⑤丁达尔光柱+光尘 → ⑥镜头光晕(星芒、彩色光斑沿太阳-画心连线、横向拉丝)→ ⑦缩小糊化 screen 回叠=泛光
+SCENES['35_shinkai'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, rng } = U, P = PAINT;
+ const SUN = [712, 196], GL = [360, 132, 800, 548];
+ // ---------- 赛璐珞上色 ----------
+ const cel = P.cel; // 赛璐珞:底色 → 背光侧硬阴影带(自身减去平移后的自身)→ 受光侧亮边 → 细描线
+ // ---------- 天空与积雨云 ----------
+ const cloudBlobs = (() => { const r = rng(808), out = [];
+ // 主塔:底部宽、向上收、顶部铁砧略右偏;外加两团小云
+ for (let i = 0; i < 70; i++) { const h = Math.pow(r(), 0.8); const y = 540 - h * 360, w = h > 0.85 ? 300 : lerp(240, 110, h); out.push({ x: 590 + (r() - 0.5) * w * 1.5 + h * 50, y: y + (r() - 0.5) * 30, r: lerp(64, 34, h) * (0.7 + r() * 0.6), ph: r() * 6 }); }
+ for (let i = 0; i < 12; i++) out.push({ x: 410 + r() * 90, y: 290 + r() * 50, r: 22 + r() * 22, ph: r() * 6 });
+ return out.sort((a, b) => b.y - a.y); })();
+ function sky(c, t) {
+ c.save(); c.beginPath(); c.rect(GL[0], GL[1], GL[2] - GL[0], GL[3] - GL[1]); c.clip();
+ const sg = c.createLinearGradient(0, GL[1], 0, GL[3]); sg.addColorStop(0, '#1360d0'); sg.addColorStop(0.45, '#3f9bf0'); sg.addColorStop(0.85, '#a8dcff'); sg.addColorStop(1, '#e4f6ff');
+ c.fillStyle = sg; c.fillRect(GL[0], GL[1], 440, 416);
+ // 积雨云:离屏 → ①所有团块画蓝灰剪影(暗部)②每团一个偏向太阳的亮球(受光面)③整层糊 3px 再叠 55% 清晰层(软而不糊)
+ const drift = t * 10, CL = P.scratch('skCloud'), cg = CL.getContext('2d'); cg.reset();
+ const at = b => [b.x + drift, b.y - Math.sin(t * 0.8 + b.ph) * 3, b.r * (1 + 0.05 * Math.sin(t * 1.3 + b.ph))];
+ cloudBlobs.forEach(b => { const [x, y, r] = at(b); const g = cg.createLinearGradient(0, y - r, 0, y + r); g.addColorStop(0, '#b7c6e6'); g.addColorStop(1, '#8297c6'); cg.fillStyle = g; cg.beginPath(); cg.arc(x, y, r, 0, 7); cg.fill(); });
+ cloudBlobs.forEach(b => { const [x, y, r] = at(b); const ox = x + r * 0.22, oy = y - r * 0.3, rr = r * 0.82;
+ const g = cg.createRadialGradient(ox + rr * 0.3, oy - rr * 0.3, rr * 0.05, ox, oy, rr); g.addColorStop(0, '#ffffff'); g.addColorStop(0.6, '#f6f8ff'); g.addColorStop(0.9, '#e2e9fa'); g.addColorStop(1, 'rgba(226,233,250,0)');
+ cg.fillStyle = g; cg.beginPath(); cg.arc(ox, oy, rr, 0, 7); cg.fill(); });
+ c.save(); c.filter = 'blur(3px)'; c.drawImage(CL, 0, 0); c.restore(); c.globalAlpha = 0.55; c.drawImage(CL, 0, 0); c.globalAlpha = 1;
+ // 远处屋顶与电线杆(逆光、雾蓝)
+ c.fillStyle = '#7d9cc6'; c.beginPath(); c.moveTo(360, 548); [[360, 500], [420, 500], [420, 480], [470, 480], [480, 462], [540, 462], [545, 490], [610, 490], [615, 470], [690, 470], [700, 495], [760, 495], [760, 476], [800, 476], [800, 548]].forEach(p => c.lineTo(...p)); c.fill();
+ c.fillStyle = '#5f7fae'; c.fillRect(708, 300, 8, 250); c.fillRect(690, 318, 46, 6); c.fillRect(694, 338, 38, 5);
+ c.strokeStyle = 'rgba(50,70,110,.8)'; c.lineWidth = 1.6; [[318, 330], [338, 352], [321, 400]].forEach(([y0, y1], k) => { c.beginPath(); c.moveTo(360, y1 + 30 + k * 6); c.quadraticCurveTo(540, y1 + 60, 712, y0); c.quadraticCurveTo(760, y0 + 10, 800, y0 + 18 + k * 4); c.stroke(); });
+ // 飞机拉线:从左往右飞,线在身后变宽变淡
+ const px = 380 + (t * 140) % 520, py = 196 - (px - 380) * 0.05;
+ const ctg = c.createLinearGradient(px - 260, 0, px, 0); ctg.addColorStop(0, 'rgba(255,255,255,0)'); ctg.addColorStop(1, 'rgba(255,255,255,.9)');
+ c.strokeStyle = ctg; c.lineWidth = 3; c.beginPath(); c.moveTo(px - 260, py + 13); c.lineTo(px, py); c.stroke(); c.fillStyle = '#ffffff'; c.beginPath(); c.arc(px + 3, py, 2.5, 0, 7); c.fill();
+ // 鸟群:三只,翅膀 V 形扇动
+ for (let k = 0; k < 3; k++) { const bx = 470 + t * 90 + k * 34, by = 250 + k * 14 + Math.sin(t * 3 + k) * 6, f = Math.sin(t * 16 + k * 2) * 6; c.strokeStyle = '#3a4a6a'; c.lineWidth = 2; c.beginPath(); c.moveTo(bx - 9, by - f); c.lineTo(bx, by); c.lineTo(bx + 9, by - f); c.stroke(); }
+ c.restore();
+ }
+ // ---------- 静态室内(缓存) ----------
+ const room = () => P.cached('sk_room', W, H, (g) => {
+ const wg = g.createLinearGradient(0, 0, W, 0); wg.addColorStop(0, '#f2ece2'); wg.addColorStop(0.45, '#e9e4dc'); wg.addColorStop(1, '#bfc3d2'); g.fillStyle = wg; g.fillRect(0, 0, W, 720);
+ const vg = g.createLinearGradient(0, 0, 0, 720); vg.addColorStop(0, 'rgba(120,130,170,.25)'); vg.addColorStop(0.5, 'rgba(0,0,0,0)'); g.fillStyle = vg; g.fillRect(0, 0, W, 720);
+ // 踢脚线+木地板(透视板缝、反光)
+ g.fillStyle = '#d8d4cc'; g.fillRect(0, 700, W, 18);
+ const fg = g.createLinearGradient(0, 718, 0, H); fg.addColorStop(0, '#9a6a48'); fg.addColorStop(1, '#6a4430'); g.fillStyle = fg; g.fillRect(0, 718, W, H - 718);
+ g.strokeStyle = 'rgba(60,36,20,.45)'; g.lineWidth = 2; for (let i = -20; i <= 20; i++) { g.beginPath(); g.moveTo(960 + i * 70, 718); g.lineTo(960 + i * 190, H); g.stroke(); }
+ // 窗:铝框推拉窗(窗洞、框、中梃、窗台)
+ g.fillStyle = '#d4d2d4'; g.fillRect(330, 104, 500, 470); g.fillStyle = '#f6f6f8'; g.fillRect(342, 116, 476, 448);
+ g.fillStyle = '#b8bcc8'; g.fillRect(352, 124, 456, 432);
+ g.fillStyle = '#eef0f4'; g.fillRect(570, 124, 22, 432); g.fillStyle = '#c6cad4'; g.fillRect(588, 124, 4, 432);
+ g.fillStyle = '#fbfbfc'; g.fillRect(316, 562, 530, 22); g.fillStyle = '#c4c4cc'; g.fillRect(316, 584, 530, 8);
+ // 墙上:挂历和一张照片(写实的小细节)
+ g.fillStyle = '#ffffff'; g.fillRect(1580, 250, 150, 200); g.fillStyle = '#e2534a'; g.fillRect(1580, 250, 150, 40); g.fillStyle = '#9aa0b0'; for (let i = 0; i < 5; i++) for (let j = 0; j < 7; j++) g.fillRect(1592 + j * 19, 304 + i * 26, 12, 12);
+ // 桌:浅木书桌
+ g.fillStyle = '#7a5236'; g.fillRect(836, 650, 26, 255); g.fillRect(1160, 650, 26, 255);
+ g.fillStyle = '#c99a68'; g.fillRect(806, 612, 410, 30); g.fillStyle = '#f0cf9c'; g.fillRect(806, 612, 410, 6); g.fillStyle = '#8e623e'; g.fillRect(806, 638, 410, 14);
+ // 椅
+ g.fillStyle = '#8e623e'; g.fillRect(1430, 470, 18, 440); g.fillRect(1478, 480, 18, 430); g.fillRect(1426, 470, 74, 60);
+ g.fillStyle = '#b8865a'; g.fillRect(1426, 470, 74, 8);
+ // 桌上:书
+ g.fillStyle = '#3d5a8e'; g.fillRect(1040, 594, 110, 18); g.fillStyle = '#f2ecdc'; g.fillRect(1044, 590, 102, 6); g.fillStyle = '#c94f4a'; g.fillRect(1052, 578, 90, 14);
+ });
+ // ---------- 少女(逐部件赛璐珞) ----------
+ const SK = { b: '#ffe8dc', s: '#f2b6a8', r: '#fffaf4' }, HR = { b: '#f8d681', s: '#d8a050', r: '#fff6d6' }, WT = { b: '#fbfbfe', s: '#b9c3dc', r: '#ffffff' }, NV = { b: '#2c3a66', s: '#1b2446', r: '#5a6ea8' };
+ function girl(c, G, t, lt) {
+ const L = '#6a4632', o = { line: L };
+ cel(c, G.farSleeve, WT.b, WT.s, null, o); cel(c, G.farHand, SK.b, SK.s, null, o);
+ cel(c, G.skirt, NV.b, NV.s, NV.r, { ...o, sd: 30 });
+ c.save(); c.clip(G.skirt); c.strokeStyle = '#141a33'; c.lineWidth = 2.5; [[1170, 700, 1140, 925], [1210, 690, 1190, 930], [1250, 680, 1244, 930], [1290, 680, 1296, 925], [1330, 760, 1346, 925]].forEach(([a, b, c2, d]) => { c.beginPath(); c.moveTo(a, b); c.lineTo(c2, d); c.stroke(); }); c.restore();
+ cel(c, G.shoe, '#3a2a24', '#22160f', null, o);
+ cel(c, G.torso, WT.b, WT.s, WT.r, { ...o, sd: 26 });
+ // 水手领(背后的大方领,藏青+两道白线)
+ const nape = G.A.nape, bk = G.A.back, nk = G.A.neck;
+ const col = RIG.smooth([[nk[0] - 8, nk[1] - 6], [nape[0] + 10, nape[1] - 4], [bk[0] + 6, bk[1] - 20], [bk[0] - 4, bk[1] + 30], [nk[0] + 40, nk[1] + 70], [nk[0] + 6, nk[1] + 30]]);
+ cel(c, col, NV.b, NV.s, NV.r, { ...o, sd: 14 });
+ c.save(); c.clip(col); c.strokeStyle = '#f2f4fa'; c.lineWidth = 3; c.stroke(RIG.smooth([[nk[0] + 4, nk[1] + 6], [nape[0] + 12, nape[1] + 8], [bk[0] - 6, bk[1] - 14], [bk[0] - 14, bk[1] + 18], [nk[0] + 38, nk[1] + 58], [nk[0] + 12, nk[1] + 28]])); c.restore();
+ // 红领巾结
+ const ch = G.A.chest; const tie = RIG.smooth([[nk[0] - 8, nk[1] + 14], [nk[0] + 16, nk[1] + 18], [ch[0] + 10, ch[1] + 10], [ch[0] - 4, ch[1] + 50], [ch[0] - 16, ch[1] + 8]]);
+ cel(c, tie, '#e04454', '#a8243a', '#ff8a96', { ...o, sd: 10, rw: 4 });
+ cel(c, G.neck, SK.b, SK.s, null, { ...o, sd: 14 });
+ cel(c, G.hairBack, HR.b, HR.s, HR.r, { ...o, line: '#8a5a2a', sd: 26, rw: 9 }); cel(c, G.bun, HR.b, HR.s, HR.r, { ...o, line: '#8a5a2a', sd: 16 });
+ // 天使环:后脑一道亮带
+ c.save(); c.clip(G.hairBack); c.strokeStyle = 'rgba(255,250,226,.85)'; c.lineWidth = 9; c.beginPath(); c.arc(G.A.headC[0] + 10, G.A.headC[1] + 10, 64, -2.2, -0.6); c.stroke(); c.restore();
+ cel(c, G.face, SK.b, SK.s, null, { ...o, sd: 10 });
+ c.save(); c.clip(G.face); c.fillStyle = 'rgba(255,140,140,.35)'; c.beginPath(); c.ellipse(G.cheek[0] - 4, G.cheek[1], 16, 9, 0, 0, 7); c.fill(); c.restore();
+ c.fillStyle = SK.b; c.beginPath(); c.ellipse(G.ear[0], G.ear[1], 8, 12, 0.2, 0, 7); c.fill(); c.strokeStyle = L; c.lineWidth = 1.8; c.stroke();
+ cel(c, G.bangs, HR.b, HR.s, HR.r, { ...o, line: '#8a5a2a', sd: 12, rw: 6 });
+ c.strokeStyle = 'rgba(170,110,50,.7)'; c.lineWidth = 1.6; G.hairLines.forEach(h => c.stroke(h));
+ // 被窗口吹动的发丝
+ const wind = Math.sin(t * 3.2) * 6 + Math.sin(t * 7.1) * 2;
+ c.save(); c.translate(wind * 0.5, 0); G.locks.forEach(h => { c.strokeStyle = '#8a5a2a'; c.lineWidth = 8; c.stroke(h); c.strokeStyle = HR.b; c.lineWidth = 5.5; c.stroke(h); }); c.restore();
+ c.strokeStyle = HR.s; c.lineWidth = 3; for (let k = 0; k < 3; k++) { const s = G.A.nape; c.beginPath(); c.moveTo(s[0] + 10 + k * 8, s[1] - 10); c.quadraticCurveTo(s[0] + 26 + k * 8 + wind, s[1] + 30, s[0] + 18 + k * 10 + wind * 1.6, s[1] + 70); c.stroke(); }
+ // 动画眼:大、纵向渐变虹膜、两颗高光;眼睑粗
+ const e = G.eye, bl = P.choreo(lt, t).blink;
+ if (bl) { c.strokeStyle = '#3a2418'; c.lineWidth = 3.2; c.beginPath(); c.moveTo(e.x - 9, e.y + 3); c.quadraticCurveTo(e.x, e.y + 7, e.x + 9, e.y + 3); c.stroke(); }
+ else {
+ const ig = c.createLinearGradient(0, e.y - 12, 0, e.y + 12); ig.addColorStop(0, '#1f3f7a'); ig.addColorStop(0.6, '#3f7fd0'); ig.addColorStop(1, '#9fd4ff');
+ c.fillStyle = '#ffffff'; c.beginPath(); c.ellipse(e.x, e.y + 1, 8, 12, 0, 0, 7); c.fill();
+ c.fillStyle = ig; c.beginPath(); c.ellipse(e.x - 1.5, e.y + 2, 6.5, 11, 0, 0, 7); c.fill();
+ c.fillStyle = '#ffffff'; c.beginPath(); c.arc(e.x - 3.5, e.y - 3, 2.6, 0, 7); c.fill(); c.beginPath(); c.arc(e.x + 1, e.y + 7, 1.3, 0, 7); c.fill();
+ c.strokeStyle = '#3a2418'; c.lineWidth = 3.4; c.lineCap = 'round'; c.beginPath(); c.moveTo(e.x - 10, e.y - 7); c.quadraticCurveTo(e.x, e.y - 14, e.x + 9, e.y - 9); c.stroke();
+ c.lineWidth = 2; c.beginPath(); c.moveTo(e.x - 10, e.y - 7); c.lineTo(e.x - 15, e.y - 11); c.stroke();
+ }
+ c.strokeStyle = '#a07040'; c.lineWidth = 2; c.stroke(G.brow);
+ c.fillStyle = '#e07a78'; c.beginPath(); c.moveTo(...G.lips[0]); c.lineTo(...G.lips[1]); c.lineTo(...G.lips[2]); c.closePath(); c.fill();
+ // 近侧手臂(白短袖改长袖:17 岁端庄款)
+ cel(c, G.upperArm, WT.b, WT.s, WT.r, { ...o, sd: 16 }); cel(c, G.foreArm, WT.b, WT.s, WT.r, { ...o, sd: 12 }); cel(c, G.cuff, NV.b, NV.s, null, { ...o, sd: 8 });
+ cel(c, G.hand, SK.b, SK.s, SK.r, { ...o, sd: 8, rw: 3 });
+ const cp = G.cup; c.save(); c.translate(cp.x, cp.y); c.rotate(cp.tilt);
+ const cup = RIG.smooth([[-22, 0], [-19, 32], [0, 40], [19, 32], [22, 0]]); cel(c, cup, '#ffffff', '#c6d0e6', null, { ...o, sd: 10 });
+ c.strokeStyle = '#ffffff'; c.lineWidth = 6; c.beginPath(); c.arc(25, 15, 10, -1.3, 1.5); c.stroke(); c.strokeStyle = L; c.lineWidth = 1.6; c.stroke();
+ c.fillStyle = '#c98a4a'; c.beginPath(); c.ellipse(0, 1, 20, 4.5, 0, 0, 7); c.fill(); c.restore();
+ c.fillStyle = SK.b; c.beginPath(); c.arc(G.thumb[0], G.thumb[1], 7, 0, 7); c.fill(); c.strokeStyle = L; c.lineWidth = 1.8; c.stroke();
+ }
+ function cat(c, K, t) {
+ const o = { line: '#7a4a28', lw: 2.2 };
+ const OR = { b: '#f4a758', s: '#c8743a', r: '#fff0c8' }, WH = { b: '#fff8ee', s: '#c6cce2', r: '#ffffff' };
+ // 尾
+ c.save(); c.lineCap = 'round'; c.strokeStyle = o.line; c.lineWidth = K.tailW + 4; c.stroke(K.tail); c.strokeStyle = OR.b; c.lineWidth = K.tailW; c.stroke(K.tail);
+ c.strokeStyle = OR.s; c.lineWidth = K.tailW * 0.45; c.save(); c.translate(4, 5); c.stroke(K.tail); c.restore();
+ const tip = K.tailPts[K.tailPts.length - 1]; c.fillStyle = WH.b; c.beginPath(); c.arc(tip[0], tip[1], K.tailW / 2, 0, 7); c.fill(); c.restore();
+ const body = RIG.smooth(K.bodyPts);
+ cel(c, body, OR.b, OR.s, OR.r, { ...o, sd: 34, rw: 8, lx: 0.5, ly: 1 }); // 猫在窗下:背光,暗部在下侧
+ c.save(); c.clip(body); c.strokeStyle = '#d07a34'; c.lineWidth = 8; c.lineCap = 'round'; K.stripes.slice(3).forEach(s => { c.beginPath(); c.moveTo(...s[0]); c.lineTo(...s[1]); c.stroke(); });
+ cel(c, RIG.smooth([[566, 700], [612, 690], [642, 742], [636, 830], [596, 870], [560, 800]]), WH.b, WH.s, null, { ...o, lw: 0, sd: 18, lx: 0.5, ly: 1 }); c.restore();
+ c.strokeStyle = o.line; c.lineWidth = 2.2; c.stroke(body);
+ [[588, 812], [634, 814]].forEach(([x, y]) => cel(c, RIG.taper([x, y], [x, 890], 30, 30), WH.b, WH.s, null, { ...o, sd: 10, lx: 0.5, ly: 1 }));
+ cel(c, K.head, OR.b, OR.s, OR.r, { ...o, sd: 22, rw: 8, lx: 0.5, ly: 1 });
+ c.save(); c.clip(K.head); c.strokeStyle = '#d07a34'; c.lineWidth = 7; c.lineCap = 'round'; K.stripes.slice(0, 3).forEach(s => { c.beginPath(); c.moveTo(...s[0]); c.lineTo(...s[1]); c.stroke(); });
+ c.fillStyle = WH.b; c.beginPath(); c.ellipse(K.nose[0] - 24, K.nose[1] + 12, 36, 25, 0, 0, 7); c.fill(); c.restore();
+ c.fillStyle = '#f6b0b0'; K.earInner.forEach(e => { c.beginPath(); e.forEach((p, i) => i ? c.lineTo(...p) : c.moveTo(...p)); c.fill(); });
+ K.eyes.forEach(e => { if (K.blink) { c.strokeStyle = '#3a2418'; c.lineWidth = 3; c.beginPath(); c.arc(e.x, e.y, 9, 0.2, Math.PI - 0.2); c.stroke(); return; }
+ const g = c.createLinearGradient(0, e.y - 10, 0, e.y + 10); g.addColorStop(0, '#5a8a2a'); g.addColorStop(1, '#d8f080'); c.fillStyle = g; c.beginPath(); c.ellipse(e.x, e.y, 9, 11, 0, 0, 7); c.fill();
+ c.fillStyle = '#1a1a1a'; c.beginPath(); c.ellipse(e.x + 1.5, e.y, 3, 8, 0, 0, 7); c.fill(); c.fillStyle = '#fff'; c.beginPath(); c.arc(e.x - 2.5, e.y - 4, 2.4, 0, 7); c.fill(); c.strokeStyle = '#3a2418'; c.lineWidth = 2; c.beginPath(); c.ellipse(e.x, e.y, 9, 11, 0, 0, 7); c.stroke(); });
+ c.fillStyle = '#e88a8a'; c.beginPath(); c.arc(K.nose[0], K.nose[1], 5, 0, 7); c.fill();
+ c.strokeStyle = '#7a4a28'; c.lineWidth = 2; c.beginPath(); c.moveTo(...K.mouth[0]); c.quadraticCurveTo(...K.mouth[1], ...K.mouth[2]); c.stroke();
+ c.lineWidth = 1.2; c.strokeStyle = 'rgba(255,255,255,.9)'; K.whiskers.forEach(w => { c.beginPath(); c.moveTo(...w[0]); c.lineTo(...w[1]); c.stroke(); });
+ // 逆光:猫的头顶和背上沿一圈亮边(窗在它头顶)
+ c.save(); c.globalCompositeOperation = 'lighter'; c.strokeStyle = 'rgba(255,220,160,.55)'; c.lineWidth = 4; c.save(); c.clip(K.head); c.translate(0, 5); c.stroke(K.head); c.restore(); c.save(); c.clip(body); c.translate(4, 6); c.stroke(body); c.restore(); c.restore();
+ }
+
+ return {
+ draw(c, lt, t) {
+ const ch = P.choreo(lt, t);
+ c.drawImage(room(), 0, 0);
+ sky(c, t);
+ // 窗玻璃:水珠(折射一小块天空+下沿暗边+左上高光),一颗沿玻璃滑下
+ const dr = rng(64);
+ for (let i = 0; i < 20; i++) { let x = 366 + dr() * 428, y = 140 + dr() * 400, r = 2 + dr() * 3.5; if (i === 0) { r = 8; x = 470; y = 180 + clamp(lt - 0.2) * 220; }
+ if (x > 566 && x < 596) continue;
+ c.strokeStyle = 'rgba(30,60,120,.45)'; c.lineWidth = 1.4; c.beginPath(); c.arc(x, y, r, 0.3, Math.PI - 0.3); c.stroke();
+ c.fillStyle = 'rgba(220,240,255,.22)'; c.beginPath(); c.arc(x, y, r, 0, 7); c.fill();
+ c.fillStyle = '#ffffff'; c.beginPath(); c.arc(x - r * 0.35, y - r * 0.35, r * 0.28, 0, 7); c.fill();
+ if (i === 0) { c.strokeStyle = 'rgba(220,240,255,.45)'; c.lineWidth = 3; c.beginPath(); c.moveTo(x, y - 10); c.lineTo(x, 180); c.stroke(); } }
+ // 窗帘:右侧白纱,随风鼓起(贝塞尔边缘按时间摆)
+ const wv = Math.sin(t * 2.6) * 22 + Math.sin(t * 5.3) * 6;
+ const cur = new Path2D(); cur.moveTo(760, 108); cur.lineTo(840, 108); cur.bezierCurveTo(850, 260, 830 + wv * 0.3, 420, 846, 600); cur.lineTo(760 - wv, 600); cur.bezierCurveTo(720 - wv * 1.4, 430, 760 - wv * 0.6, 260, 760, 108); cur.closePath();
+ c.fillStyle = 'rgba(255,255,255,.55)'; c.fill(cur); c.strokeStyle = 'rgba(200,210,230,.6)'; c.lineWidth = 2; for (let k = 0; k < 4; k++) { c.beginPath(); c.moveTo(775 + k * 18, 110); c.bezierCurveTo(780 + k * 18, 300, 770 + k * 16 - wv * (0.4 + k * 0.1), 460, 770 + k * 20 - wv * (0.8 - k * 0.15), 598); c.stroke(); }
+ // 地板上的窗形光斑(暖,投影平行四边形)+桌面一角受光
+ c.save(); c.globalCompositeOperation = 'screen';
+ c.drawImage(P.cached('sk_floorlight', W, H, (g) => { g.filter = 'blur(14px)'; g.fillStyle = 'rgba(255,214,150,.6)'; g.beginPath(); g.moveTo(560, 740); g.lineTo(980, 740); g.lineTo(1240, 1040); g.lineTo(720, 1040); g.closePath(); g.fill();
+ g.fillStyle = 'rgba(80,60,40,1)'; g.globalCompositeOperation = 'destination-out'; g.beginPath(); g.moveTo(760, 740); g.lineTo(790, 740); g.lineTo(990, 1040); g.lineTo(950, 1040); g.closePath(); g.fill(); }), 0, 0);
+ c.fillStyle = 'rgba(255,214,150,.3)'; c.fillRect(806, 612, 300, 26);
+ // 墙上窗形光斑(右上→右下的平行四边形)+窗帘的影子在里面摆
+ const WL = P.scratch('skWallLight'), wlg = WL.getContext('2d'); wlg.reset(); wlg.filter = 'blur(10px)';
+ wlg.fillStyle = 'rgba(255,222,170,.55)'; wlg.beginPath(); wlg.moveTo(980, 150); wlg.lineTo(1330, 230); wlg.lineTo(1330, 600); wlg.lineTo(980, 560); wlg.closePath(); wlg.fill();
+ wlg.globalCompositeOperation = 'destination-out'; wlg.fillStyle = '#000'; wlg.beginPath(); wlg.moveTo(1140, 186); wlg.lineTo(1166, 192); wlg.lineTo(1166, 580); wlg.lineTo(1140, 578); wlg.fill();
+ const cs = Math.sin(t * 2.6) * 30 + Math.sin(t * 5.3) * 8; wlg.globalAlpha = 0.7; wlg.beginPath(); wlg.moveTo(1240 + cs * 0.3, 200); wlg.bezierCurveTo(1230 + cs, 330, 1250 - cs * 0.4, 460, 1220 + cs, 600); wlg.lineTo(1340, 600); wlg.lineTo(1340, 200); wlg.fill();
+ c.drawImage(WL, 0, 0);
+ c.restore();
+ // 盆栽(叶子随风摆)
+ const sway = Math.sin(t * 2.6) * 0.06;
+ c.fillStyle = '#e8e2d6'; c.fillRect(872, 566, 56, 46); c.fillStyle = '#c9c0b0'; c.fillRect(900, 566, 28, 46);
+ [[-0.8, 60], [-0.3, 74], [0.2, 70], [0.7, 58], [-1.2, 44], [1.1, 46]].forEach(([a, l], k) => { c.save(); c.translate(900, 566); c.rotate(a + sway * (1 + k * 0.3)); const leaf = new Path2D(); leaf.ellipse(0, -l * 0.6, 13, l * 0.55, 0, 0, 7); cel(c, leaf, '#5fae5a', '#2f7a42', '#b8f09a', { line: '#2a5a32', lw: 1.6, sd: 7, rw: 3 }); c.restore(); });
+ // 角色
+ const K = RIG.cat({ tail: ch.tail, blink: ch.blink, breathe: ch.breathe });
+ const G = RIG.girl({ cup: ch.cup, sip: ch.sip, breathe: ch.breathe, hair: 'bun' });
+ cat(c, K, t); girl(c, G, t, lt);
+ P.steam(c, t, G.cup.x, G.cup.y - 6, { h: 60, n: 2, color: 'rgba(255,255,255,.7)', width: 3, spread: 12, wobble: 8 });
+ // 丁达尔光柱(缓存的模糊楔形,按时间轻微闪动)+光尘
+ c.save(); c.globalCompositeOperation = 'screen';
+ const beams = P.cached('sk_beams', W, H, (g) => { g.filter = 'blur(18px)'; [[380, 130, 470, 130, 1060, 1000, 860, 1000, 0.32], [520, 130, 600, 130, 1220, 980, 1080, 1000, 0.22], [640, 130, 790, 130, 1450, 900, 1240, 1000, 0.26]].forEach(([a, b, c2, d, e, f, gx, h, al]) => {
+ const lg = g.createLinearGradient(a, b, e, f); lg.addColorStop(0, `rgba(255,240,205,${al})`); lg.addColorStop(1, 'rgba(255,240,205,0)'); g.fillStyle = lg; g.beginPath(); g.moveTo(a, b); g.lineTo(c2, d); g.lineTo(e, f); g.lineTo(gx, h); g.closePath(); g.fill(); }); });
+ c.globalAlpha = 0.75 + 0.25 * Math.sin(t * 3.4); c.drawImage(beams, 0, 0); c.globalAlpha = 1;
+ const motes = P.particles(60, 91, t * 0.5, { x0: 480, x1: 1300, y0: 980, y1: 140, speed: 30, drift: 30, life: 8 });
+ motes.forEach((m, i) => { const tw = 0.5 + 0.5 * Math.sin(t * 6 + i * 1.3); const rr = 1.5 + m.s * 3; const g2 = c.createRadialGradient(m.x, m.y, 0, m.x, m.y, rr * 2.5); g2.addColorStop(0, `rgba(255,250,230,${0.8 * tw})`); g2.addColorStop(1, 'rgba(255,250,230,0)'); c.fillStyle = g2; c.beginPath(); c.arc(m.x, m.y, rr * 2.5, 0, 7); c.fill(); });
+ c.restore();
+ // 镜头光晕(P.lensFlare:太阳核、慢转星芒、横向拉丝、沿太阳→画心的六边形光斑)+泛光(P.bloom:缩小糊化 screen 回叠)
+ P.lensFlare(c, SUN, t);
+ P.bloom(c, { key: 'skBloom' });
+ // 整体色调:高光偏暖、暗部偏蓝(新海诚的冷暖分离)
+ c.save(); c.globalCompositeOperation = 'soft-light'; const tg = c.createLinearGradient(0, 0, W, H); tg.addColorStop(0, 'rgba(255,220,170,.35)'); tg.addColorStop(1, 'rgba(80,120,220,.35)'); c.fillStyle = tg; c.fillRect(0, 0, W, H); c.restore();
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/36_picasso_blue.js b/scripts/engine/scenes/36_picasso_blue.js
new file mode 100644
index 0000000..5db471d
--- /dev/null
+++ b/scripts/engine/scenes/36_picasso_blue.js
@@ -0,0 +1,123 @@
+// 1903 毕加索蓝色时期 —— 纯代码。
+// 管线:①蓝单色平涂底稿(墙/地/窗外夜海)→ ②宽而干的笔触重画(区域蓝色板,墙竖刷、地横刷,不沸腾)
+// → ③角色:骨架整体拉长变瘦(El Greco 式:绕脚底 scale(0.88,1.09)),平涂+小笔触,披肩罩头 → ④普鲁士蓝粗轮廓(只取看得见的线)
+// → ⑤会动的:缓慢呼吸(幅度×2、频率×0.45)、窗外海浪横移、月光碎影闪、热气慢升 → ⑥画布纹+冷暗角
+SCENES['36_picasso_blue'] = (() => {
+ const W = 1920, H = 1080, { clamp, lerp, rng } = U, P = PAINT;
+ const C = { navy: '#132240', prus: '#1d3866', cob: '#2d5a94', cer: '#6b8fb6', pale: '#b6c8d8', teal: '#3b6878', ochre: '#8c7a54', line: '#0c1830' };
+ // 拉长变瘦(El Greco 式):RIG 原生非等比缩放,以脚底为轴——路径、锚点、杯子一起变,线宽不被压扁
+ const GSTR = { sx: 0.84, sy: 1.12, anchor: [1240, 932] }, CSTR = { sx: 0.82, sy: 1.14, anchor: [540, 905] };
+
+ function base(g) {
+ g.fillStyle = C.prus; g.fillRect(0, 0, W, 720);
+ const wg = g.createLinearGradient(0, 0, W, 0); wg.addColorStop(0, 'rgba(110,145,185,.35)'); wg.addColorStop(0.6, 'rgba(0,0,0,0)'); wg.addColorStop(1, 'rgba(5,10,25,.45)'); g.fillStyle = wg; g.fillRect(0, 0, W, 720);
+ g.fillStyle = '#4a6c94'; g.fillRect(0, 720, W, 360);
+ const fg = g.createLinearGradient(0, 720, 0, H); fg.addColorStop(0, 'rgba(10,20,40,.4)'); fg.addColorStop(1, 'rgba(150,175,200,.25)'); g.fillStyle = fg; g.fillRect(0, 720, W, 360);
+ // 窗:夜海+月
+ g.fillStyle = '#7d9cbc'; g.fillRect(340, 110, 480, 460);
+ const sk = g.createLinearGradient(0, 130, 0, 400); sk.addColorStop(0, '#1a2f58'); sk.addColorStop(1, '#4f74a4'); g.fillStyle = sk; g.fillRect(360, 130, 440, 270);
+ g.fillStyle = '#16284c'; g.fillRect(360, 400, 440, 150);
+ g.fillStyle = '#c9d6e2'; g.beginPath(); g.arc(670, 220, 30, 0, 7); g.fill();
+ g.fillStyle = '#7d9cbc'; g.fillRect(572, 130, 16, 420); g.fillRect(360, 330, 440, 12);
+ g.fillStyle = '#91aecb'; g.fillRect(320, 560, 520, 24);
+ }
+ function table(g) {
+ g.fillStyle = '#20406c'; g.fillRect(806, 614, 408, 34); g.fillStyle = '#16305a'; g.fillRect(826, 648, 368, 40); g.fillRect(842, 688, 22, 216); g.fillRect(1156, 688, 22, 216);
+ g.fillStyle = '#1a3460'; g.fillRect(1430, 470, 18, 440); g.fillRect(1478, 480, 18, 430); for (let k = 0; k < 3; k++) g.fillRect(1434, 520 + k * 70, 60, 12);
+ // 桌上:一只水罐和一块面包(蓝色时期静物的穷与静)
+ g.fillStyle = '#9fb6cc'; g.beginPath(); g.moveTo(880, 614); g.quadraticCurveTo(860, 560, 886, 530); g.lineTo(914, 530); g.quadraticCurveTo(940, 560, 920, 614); g.closePath(); g.fill();
+ g.fillStyle = '#6c7f8e'; g.beginPath(); g.ellipse(1040, 604, 50, 14, 0, 0, 7); g.fill();
+ }
+ const SW = {
+ wall: P.swatch(['#1d3866', '#24457a', '#163056', '#2e5a94', '#20406e', '#3b6878'], 0.8),
+ floor: P.swatch(['#4a6c94', '#587ca2', '#3e5f86', '#6b8fb6', '#456a8a'], 0.75),
+ win: P.swatch(['#7d9cbc', '#8eaac6', '#6f90b2'], 0.6),
+ };
+ // 第一版 cell16/len40/w14 满墙竖刷=「下雨/毛毯」,像印象派。蓝色时期是宽、长、低对比的刷面:cell34 len110 w34,色板混底 0.8,再糊 3px。
+ const stat = () => P.cached('bp_static', W, H, (g, cv) => {
+ const b = P.canvas(), bg = b.getContext('2d'); base(bg); g.drawImage(b, 0, 0);
+ P.strokes(g, b, { cell: 34, len: 110, width: 34, seed: 12, t: 0, boil: 0, outline: 0, jitterCol: 4,
+ angle: (x, y) => y > 720 ? 0.05 * P.noise(x * 0.01, y * 0.01) : -Math.PI / 2 + 0.5 * P.noise(x * 0.003, y * 0.003),
+ palette: (x, y, col, r) => (y > 720 ? SW.floor(col, r) : SW.wall(col, r)),
+ mask: (x, y) => !(x > 330 && x < 830 && y > 100 && y < 595) && Math.abs(y - 720) > 20 });
+ { const tmp = P.canvas(), tg = tmp.getContext('2d'); tg.filter = 'blur(7px)'; tg.drawImage(cv, 0, 0); g.globalAlpha = 0.8; g.drawImage(tmp, 0, 0); g.globalAlpha = 1; }
+ // 干刷:笔触末端露底的细丝(很淡)
+ const r = rng(9); g.globalAlpha = 0.07; g.strokeStyle = '#a8c0d6'; g.lineWidth = 1.2;
+ for (let i = 0; i < 900; i++) { const x = r() * W, y = r() * H; if (x > 330 && x < 830 && y > 100 && y < 595) continue; const a = y > 720 ? 0 : -Math.PI / 2, L = 30 + r() * 60; g.beginPath(); g.moveTo(x, y); g.lineTo(x + Math.cos(a) * L, y + Math.sin(a) * L); g.stroke(); }
+ g.globalAlpha = 1;
+ // 窗:保留清楚的框,只给框上小刷痕
+ g.drawImage(b, 320, 100, 520, 500, 320, 100, 520, 500);
+ g.save(); g.beginPath(); g.rect(320, 100, 520, 500); g.clip();
+ P.strokes(g, b, { cell: 9, len: 20, width: 8, seed: 13, t: 0, boil: 0, outline: 0, jitterCol: 8, angle: (x, y) => (x > 560 && x < 600) ? -Math.PI / 2 : 0.03,
+ palette: (x, y, col, r) => SW.win(col, r), mask: (x, y) => !(x > 362 && x < 798 && y > 132 && y < 548) || (x > 572 && x < 588) || (y > 330 && y < 342) });
+ g.restore();
+ // 桌:单独一层+小笔触
+ const tb = P.canvas(), tbg = tb.getContext('2d'); table(tbg); tbg.save(); tbg.globalCompositeOperation = 'source-atop';
+ P.strokes(tbg, tb, { cell: 9, len: 26, width: 9, seed: 14, t: 0, boil: 0, outline: 0, jitterCol: 10, alphaMask: true, angle: (x, y) => y > 690 ? -Math.PI / 2 : 0.02 }); tbg.restore(); g.drawImage(tb, 0, 0);
+ // 环境轮廓(普鲁士蓝粗线,不抖)
+ g.strokeStyle = C.line; g.lineWidth = 5; g.lineJoin = 'round';
+ [[340, 110, 480, 460], [360, 130, 440, 420], [806, 614, 408, 34], [826, 648, 368, 40], [842, 688, 22, 216], [1156, 688, 22, 216]].forEach(r_ => g.strokeRect(...r_));
+ g.beginPath(); g.moveTo(0, 720); g.lineTo(806, 720); g.moveTo(1214, 720); g.lineTo(W, 720); g.stroke();
+ g.beginPath(); g.moveTo(880, 614); g.quadraticCurveTo(860, 560, 886, 530); g.lineTo(914, 530); g.quadraticCurveTo(940, 560, 920, 614); g.stroke();
+ });
+
+ const girlPal = { skin: '#90a9be', hair: '#cbd8e0', hairLine: '#5f7896', dress: '#1e3a6a', sleeve: '#24457a', fold: '#10223f', cuff: '#24457a', cheek: null, lip: '#4a6a8c', iris: '#0c1830', line: C.line, lw: 5, cupBody: '#c6d4e0', cupRim: '#2d4a6e', shoe: '#0c1830', browC: '#2a3a52' };
+ const catPal = { orange: '#4f719a', white: '#b6c8d8', stripe: '#273f66', line: C.line, lw: 5, eye: '#c9d6e2', earInner: '#6b8fb6', noseC: '#4a6a8c', whisker: '#c9d6e2' };
+
+ return {
+ draw(c, lt, t) {
+ const br = Math.sin(t * 1.8) * 0.026; // 缓慢而深的呼吸
+ const cup = 0.5 - 0.5 * Math.cos(Math.min(1, lt / 1.25) * Math.PI); // 端杯也慢
+ const tail = Math.sin(t * 2.2) * 0.3;
+ c.drawImage(stat(), 0, 0);
+ // 窗外:海浪(横向短笔,左移)+月光碎影(闪)
+ c.save(); c.beginPath(); c.rect(360, 400, 440, 150); c.clip();
+ const wr = rng(5); c.lineCap = 'round';
+ for (let i = 0; i < 70; i++) { const y = 405 + wr() * 140, sp = 20 + (y - 400) * 0.25, x = 360 + ((wr() * 520 - t * sp) % 520 + 520) % 520 - 40;
+ c.strokeStyle = wr() < 0.5 ? 'rgba(90,125,170,.8)' : 'rgba(30,55,95,.9)'; c.lineWidth = 3 + (y - 400) * 0.04; c.beginPath(); c.moveTo(x, y); c.lineTo(x + 26 + (y - 400) * 0.2, y + 1); c.stroke(); }
+ for (let k = 0; k < 14; k++) { const y = 410 + k * 10, tw = 0.5 + 0.5 * Math.sin(t * 5 + k * 1.9), w = (10 + k * 4) * tw; c.fillStyle = `rgba(205,220,235,${0.35 + 0.5 * tw})`; c.fillRect(670 - w / 2 + Math.sin(t * 2 + k) * 6, y, w, 3); }
+ c.restore();
+ // 云:一条苍白的长云缓慢横过月亮
+ c.save(); c.beginPath(); c.rect(360, 130, 440, 270); c.clip(); c.fillStyle = 'rgba(150,175,205,.45)'; const cx = 400 + t * 45; c.beginPath(); c.ellipse(cx, 236, 130, 14, -0.04, 0, 7); c.fill(); c.beginPath(); c.ellipse(cx + 90, 250, 90, 9, 0, 0, 7); c.fill(); c.restore();
+ // 角色
+ const K = RIG.cat({ tail, blink: 0, breathe: br * 1.4, ...CSTR });
+ const G = RIG.girl({ cup, sip: 0, breathe: br, hair: 'down', ...GSTR });
+ const L = P.scratch('bpChars'), lg = L.getContext('2d'); lg.reset();
+ RIG.drawCat(lg, K, { ...catPal, lw: 0 });
+ lg.save();
+ RIG.drawGirl(lg, G, { ...girlPal, mode: 'fill' });
+ // 披肩:从头顶罩下,盖住后脑与肩背,落到腰
+ const ht = G.A.headTop, fh = G.A.forehead, np = G.A.nape, bk = G.A.back, wa = G.A.waist, sh = G.A.shoulder;
+ const shawl = RIG.smooth([[fh[0] + 14, fh[1] - 22], [ht[0] + 10, ht[1] - 26], [ht[0] + 80, ht[1] + 4], [np[0] + 50, np[1] + 10], [bk[0] + 24, bk[1] + 20], [wa[0] + 70, wa[1] - 10], [wa[0] + 20, wa[1] - 40], [sh[0] + 10, sh[1] + 30], [np[0] - 10, np[1] + 10], [ht[0] + 30, ht[1] + 40], [fh[0] + 30, fh[1] - 4]]);
+ lg.fillStyle = '#6b8fb6'; lg.fill(shawl);
+ // 端杯的手:长指(El Greco 式),手指绕杯
+ lg.fillStyle = girlPal.skin; const hd = G.A.hand; for (let k = 0; k < 3; k++) { lg.save(); lg.translate(hd[0], hd[1]); lg.rotate(-2.4 + k * 0.28); lg.beginPath(); lg.ellipse(18, 0, 22, 4.5, 0, 0, 7); lg.fill(); lg.restore(); }
+ lg.restore();
+ // 小笔触肌理(只在角色上)
+ lg.save(); lg.globalCompositeOperation = 'source-atop';
+ P.strokes(lg, L, { cell: 7, len: 18, width: 6, seed: 21, t: 0, boil: 0, outline: 0, jitterCol: 14, alphaMask: true,
+ angle: (x, y) => x < 760 ? -Math.PI / 2 + 0.6 * Math.sin(y * 0.02) : -Math.PI / 2 + 0.25 * Math.sin(x * 0.03) });
+ // 冷光:左上来的微弱亮、右下沉暗
+ let vg = lg.createLinearGradient(1150, 250, 1480, 900); vg.addColorStop(0, 'rgba(190,210,230,.18)'); vg.addColorStop(1, 'rgba(5,12,30,.45)'); lg.fillStyle = vg; lg.fillRect(1050, 150, 500, 820);
+ vg = lg.createLinearGradient(420, 560, 700, 920); vg.addColorStop(0, 'rgba(190,210,230,.12)'); vg.addColorStop(1, 'rgba(5,12,30,.4)'); lg.fillStyle = vg; lg.fillRect(360, 500, 380, 420);
+ lg.restore();
+ c.drawImage(L, 0, 0);
+ // 粗轮廓:只取看得见的线(猫、少女各自在拉长后的坐标里算)
+ c.drawImage(RIG.visibleLines('bpCat', (g, lc) => RIG.drawCat(g, K, { ...catPal, line: lc, whisker: lc }), C.line, [330, 480, 760, 940]), 0, 0);
+ c.drawImage(RIG.visibleLines('bpGirl', (g, lc) => { RIG.drawGirl(g, G, { ...girlPal, line: lc });
+ g.fillStyle = '#6b8fb6'; g.fill(shawl); g.strokeStyle = lc; g.lineWidth = 5; g.stroke(shawl); }, C.line, [1040, 150, 1540, 960]), 0, 0);
+ // 披肩褶:几道深蓝长线
+ c.save(); c.save(); c.clip(shawl); c.strokeStyle = 'rgba(20,40,80,.6)'; c.lineWidth = 4; c.lineCap = 'round';
+ [[0, 0], [24, 10], [48, 22]].forEach(([dx, dy]) => { c.beginPath(); c.moveTo(ht[0] + 30 + dx, ht[1] + dy); c.quadraticCurveTo(np[0] + 30 + dx, np[1] + 40, bk[0] + dx * 0.3, bk[1] + 60 + dy); c.stroke(); }); c.restore();
+ c.restore();
+ // 热气:慢
+ const cpp = [G.cup.x, G.cup.y];
+ P.steam(c, t * 0.5, cpp[0], cpp[1] - 8, { h: 70, n: 2, color: 'rgba(200,215,230,.55)', width: 3.5, spread: 12, wobble: 10 });
+ // 画布纹+冷暗角
+ c.drawImage(P.cached('bp_over', W, H, (g) => {
+ g.strokeStyle = 'rgba(10,20,40,.06)'; g.lineWidth = 1; for (let x = 0; x < W; x += 4) { g.beginPath(); g.moveTo(x, 0); g.lineTo(x, H); g.stroke(); } for (let y = 0; y < H; y += 4) { g.beginPath(); g.moveTo(0, y); g.lineTo(W, y); g.stroke(); }
+ const v = g.createRadialGradient(900, 520, 380, 960, 540, 1150); v.addColorStop(0, 'rgba(5,10,25,0)'); v.addColorStop(1, 'rgba(5,10,25,.6)'); g.fillStyle = v; g.fillRect(0, 0, W, H);
+ }), 0, 0);
+ },
+ };
+})();
diff --git a/scripts/engine/scenes/index.js b/scripts/engine/scenes/index.js
new file mode 100644
index 0000000..498c2b5
--- /dev/null
+++ b/scripts/engine/scenes/index.js
@@ -0,0 +1,28 @@
+// 按 id 加载 scenes/<id>.js;按 transition.type 自动加载 transitions/<type>.js(同步 XHR,保证 engine 启动前全部注册)。
+// 任何一个场景缺文件、语法错、没注册,或转场名在 TRANSITIONS 和 transitions/ 里都找不到 → 记进 window.__bootErrors,
+// 引擎拒绝启动,render.py/qa.py 直接报错退出。
+// (迁移测试 B 踩过:以前缺场景会画「待实现」占位照常渲,整段 1.2 秒灰底,靠帧差 0.0% 才发现;转场名写错会静默退成交叉淡化。)
+(() => {
+ window.SCENES = window.SCENES || {}; window.__bootErrors = [];
+ const load = (url) => { const x = new XMLHttpRequest(); x.open('GET', url, false); try { x.send(); } catch (err) { return { err: `请求失败 ${err}` }; }
+ if (x.status !== 200) return { err: `${url} 不存在 (HTTP ${x.status})` };
+ try { (0, eval)(x.responseText + `\n//# sourceURL=${url}`); } catch (err) { return { err: `${url} 执行出错 ${err && err.stack || err}` }; } return {}; };
+ // 片子可以先加载自己的共用脚本(window.SCENE_LIBS,按顺序),场景文件目录 window.SCENE_DIR(默认 scenes)。
+ // 共用脚本里已经注册了 SCENES[id] 的段落,不再找单独的场景文件(demos/ 的示范片就是这么组织的)。
+ for (const f of window.SCENE_LIBS || []) { const r = load(f); if (r.err) __bootErrors.push(`共用脚本 ${r.err}`); }
+ const dir = window.SCENE_DIR || 'scenes';
+ for (const e of ERAS) {
+ if (!e.draw) { // eras 里内联了 draw 的段落不需要文件
+ const r = SCENES[e.id] ? {} : load(`${dir}/${e.id}.js`);
+ if (r.err) { __bootErrors.push(`${e.id}: ${r.err}`); continue; }
+ const sc = SCENES[e.id];
+ if (!sc || typeof sc.draw !== 'function') { __bootErrors.push(`${e.id}: 文件里没有 SCENES['${e.id}'] = { draw(c, lt, t) }`); continue; }
+ e.draw = sc.draw; if (sc.init) e.init = sc.init;
+ }
+ const ty = e.transition && e.transition.type;
+ if (ty && !TRANSITIONS[ty]) { // 项目自己的转场:放 transitions/<type>.js,往 TRANSITIONS 上挂同名函数
+ const r = load(`transitions/${ty}.js`);
+ if (r.err || !TRANSITIONS[ty]) __bootErrors.push(`${e.id}: 转场「${ty}」不在 transitions.js 里,也没有 transitions/${ty}.js(${r.err || '文件里没注册 TRANSITIONS.' + ty})`);
+ }
+ }
+})();
diff --git a/scripts/engine/transitions.js b/scripts/engine/transitions.js
new file mode 100644
index 0000000..88a459a
--- /dev/null
+++ b/scripts/engine/transitions.js
@@ -0,0 +1,928 @@
+// 转场库:每个函数 (c, A, B, p, o) —— A=旧画面 canvas,B=新画面 canvas,p∈[0,1],
+// o: {W,H,lt,t,tmp,IMG, ...该转场在 eras.js 里的参数}。确定性:随机数一律 U.rng(种子)。
+// 每个转场都取「新时代」最有辨识度的形式元素(见 经验日志「转场」)。
+(() => {
+const W = 1920, H = 1080;
+const { clamp, lerp, ease, rng } = U, TAU = Math.PI * 2;
+const seg = (p, a, b) => clamp((p - a) / (b - a)); // 把 p 的 [a,b] 段拉成 0..1
+
+// 缓存:同一转场里不随时间变化的预计算(瓦片表、离屏画布…)。
+// 只缓存「和画面内容无关」的东西(几何表、scratch 画布)。依赖 A/B 画面内容的东西不要缓存:
+// 缓存的是第一次被调用那一帧,同名转场在片中用第二次会画出第一次的内容,乱序渲染时还依赖调用顺序(迁移测试 B ②-10)。
+// 确实要按段缓存时传 o:once(k, f, o) 的键带上进入段 id。
+const cache = {};
+const once = (k, f, o) => { const kk = o ? `${o.id}|${k}` : k; return cache[kk] || (cache[kk] = f()); };
+
+const mkc = (w = W, h = H) => { const c = document.createElement('canvas'); c.width = w; c.height = h; return c; };
+
+const T = window.TRANSITIONS = {
+ crossfade(c, A, B, p) { c.drawImage(A, 0, 0); c.globalAlpha = p; c.drawImage(B, 0, 0); c.globalAlpha = 1; },
+ cut(c, A, B, p) { c.drawImage(p < 0.5 ? A : B, 0, 0); },
+
+ // ① 洞穴→埃及:新画面拆成大小不一的石块,从左向右(带随机)拼进来,落位时从略大略偏处「砌」进去
+ tiles(c, A, B, p, o) {
+ const tiles = once('tiles', () => {
+ const r = rng(7), out = [];
+ // 三种块尺寸混排:先铺大块网格,再随机把一部分拆成小块
+ const bw = 240, bh = 180;
+ for (let y = 0; y < H; y += bh) for (let x = 0; x < W; x += bw) {
+ if (r() < 0.45) { for (let yy = 0; yy < 2; yy++) for (let xx = 0; xx < 2; xx++) out.push({ x: x + xx * bw / 2, y: y + yy * bh / 2, w: bw / 2, h: bh / 2 }); }
+ else out.push({ x, y, w: bw, h: bh });
+ }
+ out.forEach(t => { t.t = clamp((t.x + t.w / 2) / W * 0.62 + r() * 0.3); t.dx = (r() - 0.5) * 60; t.dy = -30 - r() * 50; t.rot = (r() - 0.5) * 0.12; });
+ return out;
+ });
+ c.drawImage(A, 0, 0);
+ for (const t of tiles) {
+ const q = clamp((p - t.t * 0.7) / 0.28); if (q <= 0) continue;
+ const e = ease.outBack(q);
+ c.save();
+ c.translate(t.x + t.w / 2 + t.dx * (1 - e), t.y + t.h / 2 + t.dy * (1 - e));
+ c.rotate(t.rot * (1 - e));
+ const s = 1.08 - 0.08 * e; c.scale(s, s);
+ if (q < 1) { c.shadowColor = 'rgba(30,15,5,.55)'; c.shadowBlur = 18 * (1 - q); c.shadowOffsetY = 10 * (1 - q); }
+ c.drawImage(B, t.x, t.y, t.w, t.h, -t.w / 2, -t.h / 2, t.w, t.h);
+ c.restore();
+ }
+ },
+
+ // ② 埃及→希腊:立方体绕竖轴转面(旧面向左转走,新面从右转入),面上有明暗
+ cube(c, A, B, p) {
+ const e = ease.inOut(p), th = e * Math.PI / 2;
+ c.fillStyle = '#0d0a08'; c.fillRect(0, 0, W, H);
+ const face = (img, ang, side) => {
+ // 正交近似透视:面宽 = W*cos(ang),远端边缩短 k
+ const w = W * Math.cos(ang); if (w < 2) return;
+ const N = 48, k = 0.18 * Math.sin(ang);
+ for (let i = 0; i < N; i++) {
+ const u0 = i / N, u1 = (i + 1) / N;
+ const far = side === 'left' ? 1 - u0 : u0; // 远端在转出去的那一侧
+ const sh = 1 - k * far, hh = H * sh;
+ const x = side === 'left' ? u0 * w : W - w + u0 * w;
+ c.drawImage(img, u0 * W, 0, W / N + 1, H, x, (H - hh) / 2, w / N + 1, hh);
+ }
+ c.fillStyle = `rgba(0,0,0,${0.55 * Math.sin(ang)})`;
+ c.fillRect(side === 'left' ? 0 : W - w, 0, w, H);
+ };
+ face(A, th, 'left');
+ face(B, Math.PI / 2 - th, 'right');
+ },
+
+ // ③ 希腊→罗马:马赛克小砖翻面——从猫的位置向外扩散,翻面瞬间露出深色砖背
+ mosaic(c, A, B, p, o) {
+ const tw = 18, th = 34, ox = W * 0.27, oy = H * 0.72;
+ const grid = once('mosaic', () => {
+ const r = rng(11), g = [], maxd = Math.hypot(W, H) * 0.8;
+ for (let y = 0; y < H; y += th) for (let x = 0; x < W; x += tw) {
+ const d = Math.hypot(x - ox, (y - oy) * 1.3) / maxd;
+ g.push({ x, y, t: clamp(d * 0.75 + r() * 0.25) });
+ }
+ return g;
+ });
+ c.drawImage(A, 0, 0);
+ for (const g of grid) {
+ const q = (p - g.t * 0.78) / 0.16;
+ if (q <= 0) continue;
+ if (q >= 1) { c.drawImage(B, g.x, g.y, tw, th, g.x, g.y, tw, th); continue; }
+ // 翻面:宽度按 |cos| 缩放,前半显示深色砖背,后半显示新砖
+ const sx = Math.abs(Math.cos(q * Math.PI));
+ c.fillStyle = '#17110d'; c.fillRect(g.x, g.y, tw, th);
+ const w = tw * sx;
+ if (q > 0.5) c.drawImage(B, g.x, g.y, tw, th, g.x + (tw - w) / 2, g.y, w, th);
+ else { c.fillStyle = '#2a1c14'; c.fillRect(g.x + (tw - w) / 2, g.y, w, th); }
+ }
+ },
+
+ // ④ 罗马→哥特:羊皮纸翻页,卷边从右向左扫过,背面是带淡淡旧画透印的羊皮纸
+ pageTurn(c, A, B, p) {
+ const e = ease.inOut(p);
+ const band = 260;
+ const x = lerp(W + band, -band * 1.4, e); // 卷边位置
+ c.drawImage(B, 0, 0);
+ // 旧页:卷边左侧
+ c.save(); c.beginPath(); c.rect(0, 0, Math.max(0, x - band * 0.15), H); c.clip(); c.drawImage(A, 0, 0); c.restore();
+ // 卷起的页背:羊皮纸色+旧画镜像透印+圆柱明暗
+ c.save();
+ c.beginPath(); c.rect(x - band * 0.15, 0, band, H); c.clip();
+ c.fillStyle = '#e9dcc0'; c.fillRect(x - band * 0.15, 0, band, H);
+ c.globalAlpha = 0.18; c.save(); c.translate(2 * x + band * 0.7, 0); c.scale(-1, 1); c.drawImage(A, 0, 0); c.restore(); c.globalAlpha = 1;
+ const g = c.createLinearGradient(x - band * 0.15, 0, x + band * 0.85, 0);
+ g.addColorStop(0, 'rgba(60,40,20,.45)'); g.addColorStop(0.18, 'rgba(255,248,230,.25)'); g.addColorStop(0.55, 'rgba(120,90,50,.12)'); g.addColorStop(1, 'rgba(40,25,10,.55)');
+ c.fillStyle = g; c.fillRect(x - band * 0.15, 0, band, H);
+ c.restore();
+ // 卷边投在新页上的影子
+ const sg = c.createLinearGradient(x + band * 0.85, 0, x + band * 0.85 + 90, 0);
+ sg.addColorStop(0, 'rgba(30,20,10,.35)'); sg.addColorStop(1, 'rgba(30,20,10,0)');
+ c.fillStyle = sg; c.fillRect(x + band * 0.85, 0, 90, H);
+ },
+
+ // ⑤ 哥特→文艺复兴:窗口迸出金色神光,光芒里旧画渐隐、新画浮现
+ godRays(c, A, B, p, o) {
+ const cx = o.cx || 440, cy = o.cy || 300;
+ c.drawImage(A, 0, 0);
+ c.globalAlpha = ease.out(seg(p, 0.05, 0.5)); c.drawImage(B, 0, 0); c.globalAlpha = 1;
+ // 光晕
+ const glow = Math.sin(Math.PI * Math.pow(seg(p, 0, 1), 0.6));
+ const rg = c.createRadialGradient(cx, cy, 0, cx, cy, 520);
+ rg.addColorStop(0, `rgba(255,246,210,${0.85 * glow})`); rg.addColorStop(0.35, `rgba(255,220,140,${0.35 * glow})`); rg.addColorStop(1, 'rgba(255,220,140,0)');
+ c.globalCompositeOperation = 'lighter'; c.fillStyle = rg; c.fillRect(0, 0, W, H);
+ // 光芒
+ const r = rng(5), n = 34, rot = p * 0.35;
+ for (let i = 0; i < n; i++) {
+ const a = i / n * Math.PI * 2 + rot + r() * 0.08, len = 2400, wd = 0.006 + r() * 0.01;
+ const al = glow * (0.25 + r() * 0.45);
+ c.fillStyle = `rgba(255,214,120,${al})`;
+ c.beginPath(); c.moveTo(cx, cy);
+ c.lineTo(cx + Math.cos(a - wd) * len, cy + Math.sin(a - wd) * len);
+ c.lineTo(cx + Math.cos(a + wd) * len, cy + Math.sin(a + wd) * len); c.fill();
+ }
+ c.globalCompositeOperation = 'source-over';
+ },
+
+ // ⑥ 文艺复兴→浮世绘:神奈川冲浪里的巨浪从左向右横扫,浪头白沫爪+飞溅浪花,浪后是新画面
+ wave(c, A, B, p) {
+ const e = ease.inOut(p);
+ const bw = 300; // 浪带宽
+ const x0 = lerp(-bw - 120, W + 260, e); // 浪带左缘
+ const edge = y => x0 + Math.sin(y / H * Math.PI * 1.6 + 0.6) * 70; // S 形
+ c.drawImage(A, 0, 0);
+ // 新画面:浪带左侧
+ c.save(); c.beginPath(); c.moveTo(-10, 0);
+ for (let y = 0; y <= H; y += 20) c.lineTo(edge(y) + 10, y);
+ c.lineTo(-10, H); c.closePath(); c.clip(); c.drawImage(B, 0, 0); c.restore();
+ // 浪带本体
+ c.save(); c.beginPath();
+ for (let y = 0; y <= H; y += 20) c.lineTo(edge(y), y);
+ for (let y = H; y >= 0; y -= 20) c.lineTo(edge(y) + bw, y);
+ c.closePath(); c.fillStyle = '#1f3f8a'; c.fill(); c.clip();
+ // 浪纹:几条平行的浅蓝曲线
+ c.strokeStyle = 'rgba(170,200,240,.75)'; c.lineWidth = 6;
+ for (let k = 1; k < 7; k++) {
+ c.beginPath();
+ for (let y = 0; y <= H; y += 20) c.lineTo(edge(y) + k * bw / 7 + Math.sin(y / 60 + k) * 6, y);
+ c.stroke();
+ }
+ c.restore();
+ // 浪头白沫爪(右缘锯齿)
+ c.fillStyle = '#fbf7ec'; c.strokeStyle = '#1b2a55'; c.lineWidth = 2;
+ for (let y = -20; y < H + 40; y += 54) {
+ const ex = edge(y) + bw;
+ c.beginPath(); c.moveTo(ex - 6, y);
+ c.quadraticCurveTo(ex + 40, y + 6, ex + 58, y + 22);
+ c.quadraticCurveTo(ex + 30, y + 26, ex + 22, y + 40);
+ c.quadraticCurveTo(ex + 10, y + 46, ex - 6, y + 54); c.closePath(); c.fill(); c.stroke();
+ }
+ // 飞沫
+ const r = rng(19);
+ for (let i = 0; i < 70; i++) {
+ const y = r() * H, ex = edge(y) + bw + 30 + r() * 170, rr = 3 + r() * 7;
+ c.globalAlpha = 0.9 * (1 - r() * 0.5);
+ c.beginPath(); c.arc(ex, y, rr, 0, Math.PI * 2); c.fill();
+ }
+ c.globalAlpha = 1;
+ },
+
+ // ⑦ 浮世绘→印象派:一笔笔短促的彩色笔触把新画面「画」上去
+ dabs(c, A, B, p) {
+ const D = once('dabs', () => {
+ const r = rng(23), out = [];
+ for (let i = 0; i < 2600; i++) out.push({ x: r() * W, y: r() * H, a: -0.9 + r() * 0.5, l: 34 + r() * 46, w: 10 + r() * 10, t: r() });
+ return out;
+ });
+ c.drawImage(A, 0, 0);
+ const q = ease.out(seg(p, 0, 0.7));
+ c.save(); c.beginPath();
+ let any = false;
+ for (const d of D) {
+ if (d.t > q) continue; any = true;
+ const s = clamp((q - d.t) / 0.12);
+ c.moveTo(d.x + Math.cos(d.a) * d.l * s / 2, d.y + Math.sin(d.a) * d.l * s / 2);
+ c.ellipse(d.x, d.y, d.l * s / 2, d.w / 2, d.a, 0, Math.PI * 2);
+ }
+ if (any) { c.clip(); c.drawImage(B, 0, 0); }
+ c.restore();
+ // 浮在上面的零星亮色笔触(印象派光斑)
+ const r = rng(29), al = Math.sin(Math.PI * p) * 0.8;
+ const cols = ['#f6e27a', '#f2a7c3', '#b9d9f2', '#c6e8a8', '#ffffff'];
+ for (let i = 0; i < 260; i++) {
+ const x = r() * W, y = r() * H, a = -0.8 + r() * 0.4, l = 20 + r() * 30, col = cols[(r() * cols.length) | 0];
+ if (r() > al) continue;
+ c.fillStyle = col; c.globalAlpha = 0.75; c.beginPath(); c.ellipse(x, y, l / 2, 4 + r() * 3, a, 0, Math.PI * 2); c.fill();
+ }
+ c.globalAlpha = 1;
+ if (p > 0.7) { c.globalAlpha = seg(p, 0.7, 1); c.drawImage(B, 0, 0); c.globalAlpha = 1; }
+ },
+
+ // ⑧ 印象派→梵高:星空漩涡——以窗户为中心的旋涡扭曲,新画面带着旋转卷进来、最后摆正
+ swirl(c, A, B, p, o) {
+ const cx = o.cx || 420, cy = o.cy || 300;
+ const S = 2; // 半分辨率做像素扭曲
+ const w = W / S, h = H / S;
+ const src = once('swirlSrc', () => ({ a: mkc(w, h), b: mkc(w, h), out: mkc(w, h) }));
+ const sa = src.a.getContext('2d'), sb = src.b.getContext('2d'), so = src.out.getContext('2d');
+ sa.drawImage(A, 0, 0, w, h); sb.drawImage(B, 0, 0, w, h);
+ const da = sa.getImageData(0, 0, w, h).data, db = sb.getImageData(0, 0, w, h).data;
+ const out = so.createImageData(w, h), d = out.data;
+ const e = ease.out(p);
+ const R = 1100 / S, ccx = cx / S, ccy = cy / S;
+ const twA = e * 5.0, twB = (1 - e) * 4.2, rotB = -(1 - e) * 0.9;
+ const mixR = e * 2.4; // 新画面从中心向外占领的半径(相对 R)
+ for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) {
+ const dx = x - ccx, dy = y - ccy, r = Math.hypot(dx, dy), ang = Math.atan2(dy, dx), f = Math.max(0, 1 - r / R);
+ const useB = r / R < mixR - 0.15 + Math.sin(ang * 3 + r / 40) * 0.08;
+ let a2, sd;
+ if (useB) { a2 = ang + twB * f * f + rotB * Math.min(1, f * 1.6); sd = db; } else { a2 = ang - twA * f * f; sd = da; }
+ let sx = (ccx + Math.cos(a2) * r) | 0, sy = (ccy + Math.sin(a2) * r) | 0;
+ sx = sx < 0 ? 0 : sx >= w ? w - 1 : sx; sy = sy < 0 ? 0 : sy >= h ? h - 1 : sy;
+ const i = (y * w + x) * 4, j = (sy * w + sx) * 4;
+ d[i] = sd[j]; d[i + 1] = sd[j + 1]; d[i + 2] = sd[j + 2]; d[i + 3] = 255;
+ }
+ so.putImageData(out, 0, 0);
+ c.imageSmoothingQuality = 'high'; c.drawImage(src.out, 0, 0, W, H);
+ if (p > 0.85) { c.globalAlpha = seg(p, 0.85, 1); c.drawImage(B, 0, 0); c.globalAlpha = 1; }
+ },
+
+ // ⑨ 梵高→新艺术:从人物头部长出一块带金边的有机形状(慕夏式曲线轮廓),向外生长吞没画面
+ organic(c, A, B, p, o) {
+ const cx = o.cx || 1500, cy = o.cy || 330;
+ const e = ease.out(p) * 0.7 + p * 0.3;
+ const R = e * 2300;
+ const path = () => {
+ c.beginPath();
+ for (let i = 0; i <= 120; i++) {
+ const a = i / 120 * Math.PI * 2;
+ const rr = R * (1 + 0.22 * Math.sin(a * 3 + 0.7) + 0.12 * Math.sin(a * 5 + 2.1) + 0.06 * Math.sin(a * 9 + p * 3));
+ const x = cx + Math.cos(a) * rr, y = cy + Math.sin(a) * rr * 0.92;
+ i ? c.lineTo(x, y) : c.moveTo(x, y);
+ }
+ c.closePath();
+ };
+ c.drawImage(A, 0, 0);
+ if (R < 1) return;
+ c.save(); path(); c.clip(); c.drawImage(B, 0, 0); c.restore();
+ path(); c.lineJoin = 'round';
+ c.strokeStyle = '#6b4a24'; c.lineWidth = 14; c.stroke();
+ c.strokeStyle = '#d9b25a'; c.lineWidth = 8; c.stroke();
+ },
+
+ // ⑩ 新艺术→立体主义:画面碎成几何碎片,碎片错位旋转,新画面的碎片拼合落位
+ shards(c, A, B, p) {
+ const tris = once('shards', () => {
+ const r = rng(31), nx = 9, ny = 6, pts = [];
+ for (let j = 0; j <= ny; j++) for (let i = 0; i <= nx; i++) {
+ const edge = i === 0 || j === 0 || i === nx || j === ny;
+ pts.push([i / nx * W + (edge ? 0 : (r() - 0.5) * W / nx * 0.8), j / ny * H + (edge ? 0 : (r() - 0.5) * H / ny * 0.8)]);
+ }
+ const out = [];
+ for (let j = 0; j < ny; j++) for (let i = 0; i < nx; i++) {
+ const a = pts[j * (nx + 1) + i], b = pts[j * (nx + 1) + i + 1], cc = pts[(j + 1) * (nx + 1) + i], d = pts[(j + 1) * (nx + 1) + i + 1];
+ const flip = r() < 0.5;
+ const t1 = flip ? [a, b, d] : [a, b, cc], t2 = flip ? [a, d, cc] : [b, d, cc];
+ for (const t of [t1, t2]) out.push({ p: t, cx: (t[0][0] + t[1][0] + t[2][0]) / 3, cy: (t[0][1] + t[1][1] + t[2][1]) / 3, t: r(), dx: (r() - 0.5) * 160, dy: (r() - 0.5) * 120, rot: (r() - 0.5) * 0.5, sh: 0.75 + r() * 0.5 });
+ }
+ return out;
+ });
+ const draw = (img, tr, q, out) => {
+ c.save(); c.beginPath(); tr.p.forEach((v, i) => i ? c.lineTo(v[0], v[1]) : c.moveTo(v[0], v[1])); c.closePath();
+ c.translate(tr.cx, tr.cy);
+ const k = out ? q : 1 - q; // 旧片:越来越偏;新片:越来越正
+ c.translate(tr.dx * k, tr.dy * k); c.rotate(tr.rot * k); c.translate(-tr.cx, -tr.cy);
+ c.clip(); c.drawImage(img, 0, 0);
+ c.fillStyle = `rgba(${out ? '60,45,30' : '255,250,235'},${0.12 * tr.sh * Math.sin(Math.PI * q)})`; c.fill();
+ c.strokeStyle = 'rgba(40,30,20,.35)'; c.lineWidth = 2; c.stroke();
+ c.restore();
+ };
+ c.fillStyle = '#cbbfa8'; c.fillRect(0, 0, W, H);
+ for (const tr of tris) {
+ const qo = ease.inOut(clamp((p - tr.t * 0.4) / 0.45)); // 旧片碎裂进度
+ const qi = ease.out(clamp((p - 0.25 - tr.t * 0.45) / 0.3)); // 新片落位进度
+ if (qi > 0) draw(B, tr, qi, false); else draw(A, tr, qo, true);
+ }
+ },
+
+ // ⑪ 立体→包豪斯:蓝方块+红圆+黄三角的构成旋转放大,中心的米白圆里是新画面,最后构成扫出画面
+ bauhaus(c, A, B, p, o) {
+ const cx = o.cx || 1010, cy = o.cy || 560;
+ c.drawImage(A, 0, 0);
+ const s = Math.pow(30, ease.out(seg(p, 0, 0.7))) * 0.35; // 指数放大
+ const rot = -0.5 + p * 0.9;
+ const shift = ease.in(seg(p, 0.4, 1)) * -1600; // 构成整体扫向左边
+ c.save(); c.translate(cx + shift, cy); c.rotate(rot); c.scale(s, s);
+ c.fillStyle = '#1d4fa3'; c.fillRect(-170, -170, 340, 340);
+ c.rotate(-rot * 0.6);
+ c.fillStyle = '#d0262b'; c.beginPath(); c.arc(0, 0, 150, 0, Math.PI * 2); c.fill();
+ c.fillStyle = '#f2c81c'; c.beginPath(); c.moveTo(0, -150); c.lineTo(130, 75); c.lineTo(-130, 75); c.closePath(); c.fill();
+ c.restore();
+ // 米白圆里是新画面(不跟随整体扫出,持续放大直到铺满)
+ const rr = Math.pow(40, ease.inOut(seg(p, 0.15, 0.85))) * 30;
+ c.save(); c.beginPath(); c.arc(cx, cy, rr, 0, Math.PI * 2); c.clip(); c.drawImage(B, 0, 0); c.restore();
+ },
+
+ // ⑫ 包豪斯→波普:黄色闪电劈开+本戴网点化,旧画面变网点、新画面从网点里显影
+ zigzag(c, A, B, p) {
+ const halftone = (img, amt, key) => {
+ const sc = 16;
+ const sm = once('ht_' + key, () => mkc(W / sc, H / sc));
+ const sg = sm.getContext('2d'); sg.drawImage(img, 0, 0, W / sc, H / sc);
+ const d = sg.getImageData(0, 0, W / sc, H / sc).data;
+ c.globalAlpha = 1; c.drawImage(img, 0, 0); c.fillStyle = 'rgba(244,236,216,.55)'; c.fillRect(0, 0, W, H);
+ for (let y = 0; y < H / sc; y++) for (let x = 0; x < W / sc; x++) {
+ const i = (y * W / sc + x) * 4, L = (d[i] * .3 + d[i + 1] * .59 + d[i + 2] * .11) / 255;
+ const r = sc * 0.62 * (0.35 + (1 - L) * 0.85) * amt + 1;
+ c.fillStyle = `rgb(${d[i]},${d[i + 1]},${d[i + 2]})`;
+ c.beginPath(); c.arc(x * sc + sc / 2 + (y % 2) * sc / 2, y * sc + sc / 2, r, 0, Math.PI * 2); c.fill();
+ }
+ };
+ if (p < 0.35) c.drawImage(A, 0, 0);
+ else if (p < 0.55) halftone(A, 1, 'a');
+ else if (p < 0.75) halftone(B, 1, 'b');
+ else { c.drawImage(B, 0, 0); c.globalAlpha = 1 - seg(p, 0.75, 1); halftone(B, 1, 'b'); c.globalAlpha = 1; }
+ // 闪电:黑边黄色锯齿带,从左上劈到右下
+ const q = seg(p, 0.05, 0.6); if (q <= 0 || q >= 1) return;
+ const pts = [], n = 9;
+ for (let i = 0; i <= n; i++) pts.push([lerp(780, 1450, i / n) + (i % 2 ? 90 : -90), lerp(-40, H + 40, i / n)]);
+ const k = Math.min(n, Math.floor(q * 2 * n) + 1);
+ c.save(); c.lineJoin = 'miter';
+ c.beginPath(); pts.slice(0, k + 1).forEach((v, i) => i ? c.lineTo(v[0], v[1]) : c.moveTo(v[0], v[1]));
+ c.strokeStyle = '#111'; c.lineWidth = 34; c.stroke(); c.strokeStyle = '#ffe02a'; c.lineWidth = 22; c.stroke();
+ c.restore();
+ // 起点星爆
+ if (q < 0.5) {
+ c.save(); c.translate(70, 990); c.fillStyle = '#ffe02a'; c.strokeStyle = '#111'; c.lineWidth = 4; c.beginPath();
+ for (let i = 0; i < 28; i++) { const a = i / 28 * Math.PI * 2, r = i % 2 ? 70 : 105; c.lineTo(Math.cos(a) * r, Math.sin(a) * r); }
+ c.closePath(); c.fill(); c.stroke(); c.restore();
+ }
+ },
+
+ // ⑬ 波普→8-bit:旧画面像素块越来越大,切到新画面后像素块由大变小直至清晰
+ pixelate(c, A, B, p) {
+ const img = p < 0.5 ? A : B;
+ const q = p < 0.5 ? p / 0.5 : 1 - (p - 0.5) / 0.5;
+ const bs = Math.max(1, Math.round(lerp(1, 72, ease.in(q))));
+ if (bs <= 1) { c.drawImage(img, 0, 0); return; }
+ const sm = once('px', () => mkc(W, H)), sg = sm.getContext('2d');
+ const w = Math.ceil(W / bs), h = Math.ceil(H / bs);
+ sg.imageSmoothingEnabled = true; sg.clearRect(0, 0, w, h); sg.drawImage(img, 0, 0, w, h);
+ c.imageSmoothingEnabled = false; c.drawImage(sm, 0, 0, w, h, 0, 0, w * bs, h * bs); c.imageSmoothingEnabled = true;
+ },
+
+ // ⑭ 8-bit→光追:黑底绿色霓虹线框(新画面的边缘+透视网格地面),扫描线自上而下把渲染结果「算」出来
+ wireframe(c, A, B, p) {
+ const edges = (() => { // 每帧从当前 B 重算(半分辨率 Sobel,约 10ms):缓存会串段、依赖渲染顺序
+ const s = 2, w = W / s, h = H / s, sm = once('edgesCanvas', () => mkc(w, h)), g = sm.getContext('2d', { willReadFrequently: true });
+ g.clearRect(0, 0, w, h); g.drawImage(B, 0, 0, w, h);
+ const d = g.getImageData(0, 0, w, h).data, out = g.createImageData(w, h), o = out.data;
+ const L = (x, y) => { const i = (y * w + x) * 4; return d[i] * .3 + d[i + 1] * .59 + d[i + 2] * .11; };
+ for (let y = 1; y < h - 1; y++) for (let x = 1; x < w - 1; x++) {
+ const gx = L(x + 1, y) - L(x - 1, y), gy = L(x, y + 1) - L(x, y - 1), m = Math.hypot(gx, gy);
+ const i = (y * w + x) * 4, v = m > 38 ? 255 : 0;
+ o[i] = 60; o[i + 1] = 255; o[i + 2] = 150; o[i + 3] = v;
+ }
+ g.putImageData(out, 0, 0); return sm;
+ })();
+ const wire = () => {
+ c.fillStyle = '#02060a'; c.fillRect(0, 0, W, H);
+ // 透视网格地面
+ c.strokeStyle = 'rgba(60,255,150,.8)'; c.lineWidth = 2;
+ const hy = 640, vx = W / 2;
+ for (let i = -24; i <= 24; i++) { c.beginPath(); c.moveTo(vx + i * 30, hy); c.lineTo(vx + i * 260, H); c.stroke(); }
+ for (let k = 0; k < 12; k++) { const y = hy + Math.pow(k / 12, 2) * (H - hy); c.beginPath(); c.moveTo(0, y); c.lineTo(W, y); c.stroke(); }
+ c.shadowColor = '#3cff96'; c.shadowBlur = 8; c.drawImage(edges, 0, 0, W, H); c.shadowBlur = 0;
+ };
+ if (p < 0.12) { c.drawImage(A, 0, 0); c.globalAlpha = p / 0.12; wire(); c.globalAlpha = 1; return; }
+ wire();
+ const q = ease.inOut(seg(p, 0.3, 1)), yy = q * H;
+ if (yy > 0) { c.save(); c.beginPath(); c.rect(0, 0, W, yy); c.clip(); c.drawImage(B, 0, 0); c.restore(); }
+ if (q > 0 && q < 1) { c.fillStyle = 'rgba(200,255,230,.9)'; c.fillRect(0, yy - 3, W, 6); }
+ },
+
+ // ⑮ 光追→2026:三色同心环从杯子(992,601)线性扩张,外径约 143px/帧,每环厚 137px,最内环里是新画面(分镜表 T15)
+ iris(c, A, B, p, o) {
+ const cx = o.cx || 992, cy = o.cy || 601;
+ const R = 19 + p * (1159 - 19 + 3 * 137 + 900); // 线性;到 p=1 时最内环也超出画面对角
+ c.drawImage(A, 0, 0);
+ const ring = (r, col) => { if (r <= 0) return; c.fillStyle = col; c.beginPath(); c.arc(cx, cy, r, 0, Math.PI * 2); c.fill(); };
+ ring(R, 'rgb(33,42,81)'); ring(R - 137, 'rgb(234,124,107)'); ring(R - 274, 'rgb(250,246,235)');
+ const ri = R - 411;
+ if (ri > 0) { c.save(); c.beginPath(); c.arc(cx, cy, ri, 0, Math.PI * 2); c.clip(); c.drawImage(B, 0, 0); c.restore(); }
+ },
+
+ // ===================== 迁移测试 A–D 收进来的转场(名字同 references/风格配方 里的配方卡) =====================
+ // 每个都长在「进入段」风格的签名语言上:先找新风格里会「出现/点亮/扫过」的物理过程,旧画先被它污染,新画从它的形状里露出来。
+ // ---- A:水墨 / 克里姆特 / 蒙克 / 敦煌 / 草间 ----
+ // 水墨 → 克里姆特:金箔一片片贴上来。从少女头部按螺旋次序落下方形金箔(带螺旋/眼形/同心圆压纹),
+ // 贴实后金色褪去露出新画面。q<0.5 贴金箔(从 1.3 倍、带旋转落位),0.5..1 金箔变透明露出 B。
+ goldLeaf(c, A, B, p, o) {
+ const ts = 72, cx = o.cx || 1300, cy = o.cy || 380;
+ const tiles = once('goldLeaf', () => { const r = rng(21), out = [], maxd = Math.hypot(W, H) * 0.8;
+ for (let y = 0; y < H; y += ts) for (let x = 0; x < W; x += ts) { const mx = x + ts / 2, my = y + ts / 2; const d = Math.hypot(mx - cx, my - cy) / maxd, a = (Math.atan2(my - cy, mx - cx) / (Math.PI * 2) + 1) % 1;
+ out.push({ x, y, key: d * 0.78 + a * 0.12 + r() * 0.08, rot: (r() - .5) * 0.8, m: (r() * 3) | 0 }); }
+ return out; });
+ c.drawImage(A, 0, 0);
+ for (const t of tiles) {
+ const q = clamp((p * 1.32 - t.key) / 0.32); if (q <= 0) continue;
+ if (q >= 1) { c.drawImage(B, t.x, t.y, ts, ts, t.x, t.y, ts, ts); continue; }
+ const mx = t.x + ts / 2, my = t.y + ts / 2;
+ if (q > 0.5) c.drawImage(B, t.x, t.y, ts, ts, t.x, t.y, ts, ts);
+ const u = q < 0.5 ? q / 0.5 : 1, fadeOut = q < 0.5 ? 1 : 1 - (q - 0.5) / 0.5;
+ c.save(); c.translate(mx, my); c.rotate(t.rot * (1 - ease.out(u))); const s = 1.3 - 0.3 * ease.out(u); c.scale(s, s);
+ c.globalAlpha = Math.min(1, u * 2.5) * fadeOut;
+ const g = c.createLinearGradient(-ts / 2, -ts / 2, ts / 2, ts / 2); const sh = clamp(u);
+ g.addColorStop(0, '#a8741e'); g.addColorStop(clamp(0.2 + sh * 0.5), '#fbe6a0'); g.addColorStop(1, '#c8962e');
+ c.fillStyle = g; c.fillRect(-ts / 2, -ts / 2, ts, ts);
+ c.strokeStyle = 'rgba(70,40,10,.75)'; c.lineWidth = 2.2; c.beginPath();
+ if (t.m === 0) { for (let a = 0; a < Math.PI * 5; a += 0.25) { const rr = 26 * a / (Math.PI * 5); a ? c.lineTo(Math.cos(a) * rr, Math.sin(a) * rr) : c.moveTo(0, 0); } }
+ else if (t.m === 1) { c.moveTo(-24, 0); c.quadraticCurveTo(0, -20, 24, 0); c.quadraticCurveTo(0, 20, -24, 0); c.moveTo(7, 0); c.arc(0, 0, 7, 0, Math.PI * 2); }
+ else { [8, 16, 24].forEach(rr => { c.moveTo(rr, 0); c.arc(0, 0, rr, 0, Math.PI * 2); }); }
+ c.stroke(); c.restore();
+ }
+ },
+ // 克里姆特 → 蒙克:《呐喊》的血色天空从上往下「流」过画面。旧画按行正弦扭曲、幅度越来越大;
+ // 波浪形前沿以上是新画面(扭曲幅度由大变小),前沿上压 4 道黄橙红色带。
+ screamWarp(c, A, B, p, o) {
+ const e = ease.inOut(p), ph = o.lt * 9;
+ const yF = x => lerp(-180, H + 220, e) + 80 * Math.sin(x * 0.0055 + p * 7);
+ c.fillStyle = '#3a1410'; c.fillRect(0, 0, W, H);
+ KIT.warpRows(c, A, y => 70 * e * Math.sin(y * 0.014 + ph) + 20 * e * Math.sin(y * 0.05 - ph), 6, 92 * e);
+ const tg = o.tmp.getContext('2d'); tg.reset(); tg.fillStyle = '#3a1410'; tg.fillRect(0, 0, W, H);
+ KIT.warpRows(tg, B, y => 60 * (1 - e) * Math.sin(y * 0.013 - ph), 6, 62 * (1 - e));
+ c.save(); c.beginPath(); c.moveTo(0, -10); for (let x = 0; x <= W; x += 24) c.lineTo(x, yF(x)); c.lineTo(W, -10); c.closePath(); c.clip(); c.drawImage(o.tmp, 0, 0); c.restore();
+ c.save(); c.lineCap = 'round';
+ ['#b82a1e', '#e2541c', '#f08a24', '#f4c03a'].forEach((col, k) => { c.strokeStyle = col; c.lineWidth = 26; c.beginPath(); for (let x = -20; x <= W + 20; x += 16) { const y = yF(x) - k * 22 + 10 * Math.sin(x * 0.02 + ph + k); x > -20 ? c.lineTo(x, y) : c.moveTo(x, y); } c.stroke(); });
+ c.restore();
+ },
+ // 蒙克 → 敦煌:飞天的飘带从右往左扫过,带后是壁画;前沿处旧画剥落成碎片掉下去。
+ apsara(c, A, B, p, o) {
+ const e = ease.inOut(p);
+ const xF = y => lerp(W + 260, -300, e) + 110 * Math.sin(y * 0.006 + p * 5);
+ c.drawImage(A, 0, 0);
+ c.save(); c.beginPath(); c.moveTo(W + 10, -10); for (let y = -10; y <= H + 10; y += 20) c.lineTo(xF(y), y); c.lineTo(W + 10, H + 10); c.closePath(); c.clip(); c.drawImage(B, 0, 0); c.restore();
+ // 剥落:前沿左侧旧画碎片(取 A 的像素)旋转落下
+ const fl = once('apsaraFlakes', () => { const r = rng(33), o2 = []; for (let i = 0; i < 70; i++) o2.push([r() * H, 20 + r() * 34, 10 + r() * 26, r() * 6.28, r()]); return o2; });
+ fl.forEach(([y0, s, dx, rot, k]) => { const born = clamp(1 - (xF(y0) + 40) / (W + 300)); const age = e - born * 0.9; if (age < 0) return;
+ const x = xF(y0) - dx + age * 120, y = y0 + age * age * 900; if (y > H + 40) return;
+ c.save(); c.translate(x, y); c.rotate(rot + age * 9); c.scale(1, Math.cos(age * 12 + k * 6)); c.drawImage(A, clamp(x, 0, W - s), clamp(y0, 0, H - s), s, s * 0.7, -s / 2, -s * 0.35, s, s * 0.7); c.restore(); });
+ // 三条飘带沿前沿翻卷(石绿、土红、石青),带白色描花
+ [['#6ab08e', 0, 44], ['#a5452f', 70, 38], ['#5a86b0', 140, 32]].forEach(([col, off, w], k) => {
+ const pts = []; for (let y = -60; y <= H + 60; y += 18) pts.push([xF(y) + off + 46 * Math.sin(y * 0.011 - p * 14 + k * 1.7), y]);
+ const path = KIT.ribbon(pts, q => w * (0.6 + 0.4 * Math.sin(q * 14 + p * 10 + k)));
+ c.fillStyle = col; c.fill(path); c.strokeStyle = '#5a2414'; c.lineWidth = 2.4; c.stroke(path);
+ c.strokeStyle = '#ecdfc4'; c.lineWidth = 2; c.setLineDash([4, 10]); c.beginPath(); pts.forEach((q, i) => i ? c.lineTo(q[0], q[1]) : c.moveTo(q[0], q[1])); c.stroke(); c.setLineDash([]);
+ });
+ },
+ // 敦煌 → 草间:波点从猫的位置一圈圈长出来,点里是新画面;点胀到彼此相接就整幅换完。
+ dotBloom(c, A, B, p, o) {
+ const sp = 58, cx = o.cx || 540, cy = o.cy || 760, maxd = Math.hypot(W, H);
+ c.drawImage(A, 0, 0);
+ const pts = once('dotBloom', () => { const r = rng(44), out = []; for (let y = 0, j = 0; y < H + sp; y += sp * 0.87, j++) for (let x = (j % 2) * sp / 2; x < W + sp; x += sp) out.push([x + (r() - .5) * 8, y + (r() - .5) * 8, Math.hypot(x - cx, y - cy) / maxd, r()]); return out; });
+ const path = new Path2D(), rims = [];
+ for (const [x, y, d, k] of pts) { const q = clamp((p * 1.55 - d * 1.1 - k * 0.08) / 0.42); if (q <= 0) continue; const r = ease.outBack(q) * sp * 0.74; path.moveTo(x + r, y); path.arc(x, y, r, 0, Math.PI * 2); if (q < 1) rims.push([x, y, r, q]); }
+ c.save(); c.clip(path); c.drawImage(B, 0, 0); c.restore();
+ c.lineWidth = 5; rims.forEach(([x, y, r, q]) => { c.strokeStyle = `rgba(251,246,238,${1 - q})`; c.beginPath(); c.arc(x, y, r, 0, Math.PI * 2); c.stroke(); });
+ },
+ // ---- C:Kirby / 莫奈 / 修拉 / 马蒂斯 / 哈林 ----
+ // ① Kirby → 莫奈:旧画面「落进水里」——逐行横向正弦错位(水面倒影的抖动)越来越强;
+ // 新画面从杯子位置以「横向短笔触」一圈圈荡开(涟漪由笔触组成),亮色水光短横线闪烁。
+ ripple(c, A, B, p, o) {
+ const cx = o.cx || 1000, cy = o.cy || 600, e = ease.inOut(p);
+ const amp = 46 * Math.sin(Math.PI * Math.min(1, p * 1.2)), rowH = 6;
+ for (let y = 0; y < H; y += rowH) { const d = Math.abs(y - cy) / H, dx = Math.sin(y * 0.045 - p * 26) * amp * (0.4 + d); c.drawImage(A, 0, y, W, rowH, dx, y, W, rowH); }
+ const S = once('rip', () => { const r = rng(41), out = []; for (let i = 0; i < 3600; i++) { const x = r() * W, y = r() * H; out.push({ x, y, l: 40 + r() * 70, h: 9 + r() * 8, d: Math.hypot(x - cx, (y - cy) * 1.9) / 1700 + r() * 0.06 }); } return out; });
+ const front = e * 1.15 - 0.05;
+ c.save(); c.beginPath(); let any = false;
+ for (const s of S) { if (s.d > front) continue; any = true; const k = clamp((front - s.d) / 0.06); c.ellipse(s.x, s.y, s.l * k / 2 + 1, s.h / 2, 0, 0, TAU); }
+ if (any) { c.clip(); c.drawImage(B, 0, 0); }
+ c.restore();
+ // 涟漪前沿:几圈浅色虚线椭圆+水光短横线
+ c.save(); c.lineCap = 'round';
+ for (let k = 0; k < 3; k++) { const R = front * 2300 - k * 70; if (R <= 0) continue; c.strokeStyle = `rgba(240,246,255,${0.7 - k * 0.2})`; c.lineWidth = 10 - k * 2; c.setLineDash([46, 22]); c.lineDashOffset = -p * 300; c.beginPath(); c.ellipse(cx, cy, R, R / 1.9, 0, 0, TAU); c.stroke(); }
+ c.setLineDash([]);
+ const r = rng(7 + Math.floor(p * 30)), al = Math.sin(Math.PI * p);
+ for (let i = 0; i < 140; i++) { const x = r() * W, y = r() * H; c.strokeStyle = ['#fffbe8', '#f8e0ec', '#e8f4ff'][i % 3]; c.globalAlpha = al * 0.8; c.lineWidth = 5; c.beginPath(); c.moveTo(x, y); c.lineTo(x + 18 + r() * 30, y); c.stroke(); }
+ c.restore();
+ if (p > 0.7) { c.globalAlpha = seg(p, 0.7, 0.95); c.drawImage(B, 0, 0); c.globalAlpha = 1; }
+ },
+
+ // ② 莫奈 → 修拉:画面「结晶」成一样大的圆点——先旧画面长出点(点长大、底下淡成纸色),
+ // 点按对角线波次逐个换成新画面的颜色,最后新画面在点下面显影、点收回去。
+ pointill(c, A, B, p, o) {
+ const pitch = 14, rowh = pitch * 0.866;
+ const sa = once('ptA', () => mkc(W, H)), sb = once('ptB', () => mkc(W, H));
+ const ga = sa.getContext('2d', { willReadFrequently: true }), gb = sb.getContext('2d', { willReadFrequently: true });
+ ga.drawImage(A, 0, 0); gb.drawImage(B, 0, 0);
+ const da = ga.getImageData(0, 0, W, H).data, db = gb.getImageData(0, 0, W, H).data;
+ // 底:旧画面 → 纸色 → 新画面
+ c.drawImage(A, 0, 0);
+ c.fillStyle = `rgba(246,238,220,${seg(p, 0.05, 0.4)})`; c.fillRect(0, 0, W, H);
+ if (p > 0.6) { c.globalAlpha = seg(p, 0.6, 0.95); c.drawImage(B, 0, 0); c.globalAlpha = 1; }
+ const grow = ease.out(seg(p, 0, 0.3)), shrink = 1 - ease.in(seg(p, 0.7, 1)), R = pitch * 0.46 * grow * shrink;
+ if (R < 0.4) return;
+ for (let j = 0, y = pitch / 2; y < H + pitch; j++, y += rowh) for (let x = (j % 2) * pitch / 2; x < W + pitch; x += pitch) {
+ const sw = clamp(((x / W) * 0.6 + (y / H) * 0.4) * 0.5 + U.hash(x | 0, y | 0) * 0.25 + 0.15); // 换色时刻:左上先、带随机
+ const useB = p > sw;
+ const i = (clamp(y | 0, 0, H - 1) * W + clamp(x | 0, 0, W - 1)) * 4, d = useB ? db : da;
+ // 换色瞬间点会「跳」一下(变大)
+ const pop = Math.abs(p - sw) < 0.04 ? 1.35 : 1;
+ c.fillStyle = `rgb(${d[i]},${d[i + 1]},${d[i + 2]})`; c.beginPath(); c.arc(x, y, R * pop, 0, TAU); c.fill();
+ }
+ },
+
+ // ③ 修拉 → 马蒂斯:一大张刷过水粉的钴蓝纸(剪刀边)从右往左扫过,纸上钉着白海藻、黄星、粉纸片(带投影);
+ // 纸经过的地方,后面换成了新画面。
+ cutouts(c, A, B, p, o) {
+ const e = ease.inOut(p), w = 1100; // 纸宽
+ const x0 = lerp(W + 40, -w - 360, e); // 纸左缘
+ const edge = (y, side) => { const r = Math.sin(y * 0.021 + side * 3) * 26 + Math.sin(y * 0.067 + side) * 12; return r; };
+ // 新画面在纸的右缘之后
+ c.drawImage(A, 0, 0);
+ c.save(); c.beginPath(); c.moveTo(W + 10, 0); for (let y = 0; y <= H; y += 18) c.lineTo(x0 + w + edge(y, 1), y); c.lineTo(W + 10, H); c.closePath(); c.clip(); c.drawImage(B, 0, 0); c.restore();
+ // 纸(带投影)
+ const sheet = new Path2D(); for (let y = 0; y <= H; y += 18) sheet.lineTo(x0 + edge(y, 0), y); for (let y = H; y >= 0; y -= 18) sheet.lineTo(x0 + w + edge(y, 1), y); sheet.closePath();
+ c.save(); c.shadowColor = 'rgba(10,20,40,.45)'; c.shadowOffsetX = 14; c.shadowOffsetY = 10; c.shadowBlur = 12; c.fillStyle = '#1d4fb8'; c.fill(sheet); c.restore();
+ c.save(); c.clip(sheet);
+ const r0 = rng(83); c.lineCap = 'round';
+ for (let i = 0; i < 260; i++) { const x = x0 + r0() * w, y = r0() * H; c.strokeStyle = r0() < 0.5 ? 'rgba(255,255,255,.08)' : 'rgba(0,0,0,.08)'; c.lineWidth = 8 + r0() * 14; c.beginPath(); c.moveTo(x, y); c.lineTo(x + 160, y - 40); c.stroke(); }
+ // 纸上的剪纸:海藻(茎+手指)、星、圆片;随纸移动并各自晃
+ const pin = (fn, col, x, y, rot) => { c.save(); c.translate(x, y); c.rotate(rot); c.shadowColor = 'rgba(10,20,40,.35)'; c.shadowOffsetX = 6; c.shadowOffsetY = 7; c.shadowBlur = 4; c.fillStyle = col; c.fill(fn); c.restore(); };
+ const algae = once('ctAlg', () => { const p2 = new Path2D(); p2.addPath(RIG.limb([0, 0], [0, -420], 50, 26));
+ for (let k = 0; k < 7; k++) { const u = 0.12 + k * 0.12, s = k % 2 ? 1 : -1, A0 = [0, -u * 420], th = s * (1.0 - 0.5 * u), L = 190 * (1 - 0.45 * u), d = [Math.sin(th), -Math.cos(th)];
+ p2.addPath(RIG.limb(A0, [A0[0] + d[0] * L, A0[1] + d[1] * L], 64 * (1 - 0.3 * u), 56 * (1 - 0.3 * u))); } return p2; });
+ const star = once('ctStar', () => KIT.star(0, 0, 120, 52, 6));
+ pin(algae, '#f7f3e8', x0 + 260, 900, Math.sin(p * 9) * 0.1);
+ pin(algae, '#f7d21e', x0 + 760, 1060, -0.2 + Math.sin(p * 11) * 0.1);
+ pin(star, '#f7d21e', x0 + 540, 260, p * 3);
+ pin(star, '#ef6f9a', x0 + 900, 520, -p * 2.5);
+ const blob = once('ctBlob', () => { const q = new Path2D(); q.ellipse(0, 0, 130, 90, 0, 0, TAU); return q; }); pin(blob, '#e2322a', x0 + 180, 300, 0.3);
+ c.restore();
+ },
+
+ // ④ 马蒂斯 → 哈林:一个粗黑轮廓的跳舞小人(双臂 V 字)从杯子处放大,身体里面是新画面,
+ // 周围一圈哈林式放射动作线;小人越长越大直到身体铺满整个画面。
+ radiant(c, A, B, p, o) {
+ const cx = o.cx || 1000, cy = o.cy || 600, s = 0.15 * Math.pow(320, ease.inOut(p));
+ const pose = { head: [0, -224], neck: [0, -182], hip: [0, -100], hl: [-84, -256], hr: [84, -256], kl: [-40, -54], kr: [40, -54], fl: [-60, -14], fr: [60, -14] };
+ const T = q => [cx + q[0] * s, cy + (q[1] + 130) * s];
+ const parts = [RIG.limb(T(pose.neck), T(pose.hip), 70 * s, 60 * s), RIG.limb(T(pose.neck), T(pose.hl), 36 * s, 32 * s), RIG.limb(T(pose.neck), T(pose.hr), 36 * s, 32 * s),
+ RIG.limb(T(pose.hip), T(pose.kl), 38 * s, 34 * s), RIG.limb(T(pose.kl), T(pose.fl), 34 * s, 32 * s), RIG.limb(T(pose.hip), T(pose.kr), 38 * s, 34 * s), RIG.limb(T(pose.kr), T(pose.fr), 34 * s, 32 * s)];
+ const hd = new Path2D(), hc = T(pose.head); hd.arc(hc[0], hc[1], 42 * s, 0, TAU); parts.push(hd);
+ c.drawImage(A, 0, 0);
+ // 黑色外轮廓(描粗+填黑)
+ c.save(); c.lineJoin = 'round'; c.strokeStyle = '#111'; c.lineWidth = 30; c.fillStyle = '#111'; parts.forEach(q => { c.stroke(q); c.fill(q); }); c.restore();
+ // 身体里是新画面:离屏做遮罩
+ const m = once('rdM', () => mkc()), mg = m.getContext('2d'); mg.globalCompositeOperation = 'source-over'; mg.clearRect(0, 0, W, H);
+ mg.fillStyle = '#fff'; parts.forEach(q => mg.fill(q)); mg.globalCompositeOperation = 'source-in'; mg.drawImage(B, 0, 0);
+ c.drawImage(m, 0, 0);
+ // 放射动作线(8fps 跳)
+ const st = Math.floor(o.t * 8), r = rng(300 + st); c.save(); c.strokeStyle = '#111'; c.lineCap = 'round'; c.lineWidth = 14;
+ const R0 = 300 * s + 30;
+ for (let i = 0; i < 16; i++) { const a = i / 16 * TAU + r() * 0.2, L = 50 + r() * 60; c.beginPath(); c.moveTo(cx + Math.cos(a) * R0, cy + Math.sin(a) * R0 * 0.9); c.lineTo(cx + Math.cos(a) * (R0 + L), cy + Math.sin(a) * (R0 + L) * 0.9); c.stroke(); }
+ c.restore();
+ if (p > 0.82) { c.globalAlpha = seg(p, 0.82, 1); c.drawImage(B, 0, 0); c.globalAlpha = 1; }
+ },
+ // ---- D:伦勃朗 / 橡皮管 / 皮影 / 新海诚 / 蓝色时期 ----
+ // 伦勃朗 → 橡皮管卡通:旧画先褪成棕褐老胶片(闪烁+划痕),黑色光圈收到少女杯口,再从同一点「弹」开(outBack 过冲)
+ irisFilm(c, A, B, p, o) {
+ const cx = o.cx || 960, cy = o.cy || 540, R0 = Math.hypot(Math.max(cx, W - cx), Math.max(cy, H - cy)) + 20;
+ const close = p < 0.5, q = close ? seg(p, 0, 0.5) : seg(p, 0.5, 1);
+ if (close) { c.save(); c.filter = `sepia(${q}) grayscale(${q * 0.7}) contrast(${1 + q * 0.3})`; c.drawImage(A, 0, 0); c.restore(); }
+ else c.drawImage(B, 0, 0);
+ const R = close ? R0 * (1 - ease.in(q)) : R0 * ease.outBack(q);
+ c.save(); c.fillStyle = '#0b0906'; c.beginPath(); c.rect(0, 0, W, H);
+ // 光圈边缘微微手抖(12fps 换形)
+ const wr = rng(Math.floor(o.t * 12) + 9); c.moveTo(cx + Math.max(0, R), cy);
+ for (let i = 1; i <= 48; i++) { const a = i / 48 * Math.PI * 2, rr = Math.max(0, R * (1 + (wr() - 0.5) * 0.015)); c.lineTo(cx + Math.cos(a) * rr, cy + Math.sin(a) * rr); }
+ c.fill('evenodd'); c.restore();
+ filmDirt(c, o.t, close ? q : 1 - q * 0.5);
+ },
+ // 橡皮管 → 皮影:旧片像灯灭一样压成暗褐剪影;幕后的油灯从中心点亮,暖光圈(边缘带灯焰抖动)向外推开,新画面在光里出现
+ lampGlow(c, A, B, p, o) {
+ const cx = o.cx || 960, cy = o.cy || 470;
+ c.drawImage(A, 0, 0);
+ c.save(); c.globalCompositeOperation = 'multiply'; c.fillStyle = `rgba(70,34,12,${Math.min(1, p * 2.2)})`; c.fillRect(0, 0, W, H); c.restore();
+ const fl = Math.sin(o.t * 37) * 0.04 + Math.sin(o.t * 23) * 0.03;
+ const R = 1500 * ease.inOut(seg(p, 0.12, 1)) * (1 + fl);
+ if (R > 1) {
+ const T = o.tmp, g = T.getContext('2d'); g.reset(); g.drawImage(B, 0, 0);
+ g.globalCompositeOperation = 'destination-in'; const m = g.createRadialGradient(cx, cy, R * 0.55, cx, cy, R); m.addColorStop(0, '#000'); m.addColorStop(1, 'rgba(0,0,0,0)'); g.fillStyle = m; g.fillRect(0, 0, W, H);
+ c.drawImage(T, 0, 0);
+ }
+ c.save(); c.globalCompositeOperation = 'lighter'; const gl = Math.sin(Math.PI * seg(p, 0.05, 1)), rg = c.createRadialGradient(cx, cy, 0, cx, cy, 300 + R * 0.4);
+ rg.addColorStop(0, `rgba(255,200,110,${0.7 * gl})`); rg.addColorStop(1, 'rgba(255,170,60,0)'); c.fillStyle = rg; c.fillRect(0, 0, W, H);
+ // 灯焰本身:一朵小火苗在光心跳
+ c.fillStyle = `rgba(255,240,190,${gl})`; c.beginPath(); c.ellipse(cx, cy, 14 * (1 + fl * 4), 34 * (1 + fl * 3), 0, 0, 7); c.fill(); c.restore();
+ },
+ // 皮影 → 新海诚:一道斜向的强光从左扫到右(漏光),光带身后是新画面;带横向拉丝、彩色光斑和飘起的光粒
+ flareSweep(c, A, B, p, o) {
+ const e = ease.inOut(p), X = lerp(-500, W + 700, e), k = 0.35;
+ c.drawImage(A, 0, 0);
+ c.save(); c.beginPath(); c.moveTo(-10, 0); c.lineTo(X, 0); c.lineTo(X - H * k, H); c.lineTo(-10, H); c.closePath(); c.clip(); c.drawImage(B, 0, 0); c.restore();
+ c.save(); c.globalCompositeOperation = 'lighter';
+ const band = (w, a, col) => { c.save(); c.translate(X - H * k / 2, H / 2); c.transform(1, 0, -k, 1, 0, 0); const g = c.createLinearGradient(-w, 0, w, 0); g.addColorStop(0, `rgba(${col},0)`); g.addColorStop(0.5, `rgba(${col},${a})`); g.addColorStop(1, `rgba(${col},0)`); c.fillStyle = g; c.fillRect(-w, -H, 2 * w, 2 * H); c.restore(); };
+ band(520, 0.55, '255,236,200'); band(160, 0.85, '255,255,250'); band(60, 0.6, '200,240,255');
+ const hz = c.createLinearGradient(0, 0, W, 0); hz.addColorStop(0, 'rgba(150,210,255,0)'); hz.addColorStop(clamp(X / W), `rgba(220,240,255,${0.7 * Math.sin(Math.PI * p)})`); hz.addColorStop(1, 'rgba(150,210,255,0)'); c.fillStyle = hz; c.fillRect(Math.max(0, X - 700), 300, 1400, 5);
+ const r = rng(77);
+ for (let i = 0; i < 40; i++) { const x = X - H * k * r() + (r() - 0.5) * 500, y = r() * H - p * 120 * r(), rr = 3 + r() * 14, a = (1 - Math.abs(x - X) / 700) * 0.6; if (a <= 0) continue;
+ const g = c.createRadialGradient(x, y, 0, x, y, rr); g.addColorStop(0, `rgba(255,252,235,${a})`); g.addColorStop(1, 'rgba(255,252,235,0)'); c.fillStyle = g; c.beginPath(); c.arc(x, y, rr, 0, 7); c.fill(); }
+ [[0.3, 40, '120,255,200'], [0.6, 24, '255,170,120'], [0.9, 60, '140,170,255']].forEach(([f, rr, col]) => { const x = lerp(X, W - X, f), y = lerp(300, 780, f); c.fillStyle = `rgba(${col},${0.18 * Math.sin(Math.PI * p)})`; c.beginPath(); for (let i = 0; i < 6; i++) { const a = i / 6 * Math.PI * 2; i ? c.lineTo(x + Math.cos(a) * rr, y + Math.sin(a) * rr) : c.moveTo(x + Math.cos(a) * rr, y + Math.sin(a) * rr); } c.fill(); });
+ c.restore();
+ },
+ // 新海诚 → 蓝色时期:先把旧画的颜色「抽走」只剩蓝(color 混合),再由 6 道宽大的干笔从左到右刷过,笔下就是新画;笔头带鬃毛拖痕
+ blueBrush(c, A, B, p, o) {
+ c.drawImage(A, 0, 0);
+ c.save(); c.globalCompositeOperation = 'color'; c.fillStyle = `rgba(45,90,148,${Math.min(1, p * 2.2)})`; c.fillRect(0, 0, W, H); c.restore();
+ c.save(); c.globalCompositeOperation = 'multiply'; c.fillStyle = `rgba(90,120,170,${Math.min(0.6, p * 1.5)})`; c.fillRect(0, 0, W, H); c.restore();
+ const N = 6, bh = H / N + 90, r = rng(21);
+ for (let k = 0; k < N; k++) {
+ const s = ease.inOut(seg(p, 0.12 + k * 0.07, 0.62 + k * 0.07)), x1 = lerp(-120, W + 260, s); if (s <= 0) continue;
+ const y0 = k * (H / N) - 20 + (k % 2 ? 10 : -10), tilt = (k % 2 ? 1 : -1) * 18;
+ const path = new Path2D(); path.moveTo(-20, y0 + tilt); const n = 24;
+ for (let i = 0; i <= n; i++) { const x = lerp(-20, x1, i / n); path.lineTo(x, y0 + tilt * (1 - i / n) + Math.sin(i * 1.7 + k) * 6); }
+ path.quadraticCurveTo(x1 + 70, y0 + bh / 2, x1, y0 + bh);
+ for (let i = n; i >= 0; i--) { const x = lerp(-20, x1, i / n); path.lineTo(x, y0 + bh + tilt * (1 - i / n) + Math.cos(i * 1.3 + k) * 7); }
+ path.closePath();
+ c.save(); c.clip(path); c.drawImage(B, 0, 0);
+ // 鬃毛拖痕:笔头后 260px 内的深浅细线(颜料还没刷匀)
+ for (let i = 0; i < 26; i++) { const y = y0 + 6 + r() * (bh - 12), L = 80 + r() * 200; const g = c.createLinearGradient(x1 - L, 0, x1, 0); g.addColorStop(0, 'rgba(15,30,60,0)'); g.addColorStop(1, `rgba(${r() < .5 ? '15,30,60' : '170,195,220'},.5)`);
+ c.strokeStyle = g; c.lineWidth = 1 + r() * 3; c.beginPath(); c.moveTo(x1 - L, y); c.lineTo(x1 + 10, y + (r() - 0.5) * 4); c.stroke(); }
+ c.restore();
+ }
+ },
+};
+
+// D 组转场共用:老胶片的闪烁、竖划痕、灰尘(24fps 换一次)
+const filmDirt = (c, t, amt = 1) => { // 24fps 换一次:闪烁、竖划痕、灰尘
+ const r = rng(Math.floor(t * 24) * 7919 + 3);
+ c.fillStyle = `rgba(255,248,230,${(0.03 + r() * 0.1) * amt})`; c.fillRect(0, 0, W, H);
+ for (let k = 0; k < 3; k++) { const x = r() * W; c.strokeStyle = `rgba(${r() < .5 ? '255,250,235' : '20,16,10'},${0.5 * amt})`; c.lineWidth = 1 + r() * 2; c.beginPath(); c.moveTo(x, 0); c.lineTo(x + (r() - .5) * 10, H); c.stroke(); }
+ for (let k = 0; k < 12; k++) { c.fillStyle = `rgba(20,16,10,${0.6 * amt})`; c.beginPath(); c.arc(r() * W, r() * H, 1 + r() * 3, 0, 7); c.fill(); }
+};
+
+// ---- B:构成主义 / 达利 / 霍珀 / 吉卜力 / 蒸汽波 ----
+// ① 构成主义 → 达利:新画面像颜料一样从上往下「流」下来——下缘 edge(x) 是整体下落线 + 一排圆头液滴
+// (剖面 (1-(dx/w)²)^0.3:长条+圆头,往下挂);旧画面被压着逐列下垂(融化);液面一道高光+一道暗边。
+T.melt = function (c, A, B, p) {
+ const r = rng(41), drips = [];
+ for (let i = 0; i < 26; i++) drips.push([r() * W, 10 + r() * 22, 60 + r() * 220, r() * 0.25]);
+ const e = ease.inOut(p), fall = lerp(-160, H + 40, e);
+ const edge = x => { let d = 0; for (const [dx, w, h, t0] of drips) { const u = (x - dx) / w; if (u > -1 && u < 1) d = Math.max(d, h * seg(p, t0, t0 + 0.5) * Math.pow(1 - u * u, 0.3)); } return fall + d + Math.sin(x * 0.005 + 1) * 24; };
+ // 旧画面逐列下垂(越靠近液面压得越多)
+ const sw = 4;
+ for (let x = 0; x < W; x += sw) { const ed = edge(x), sag = Math.max(0, ed) * 0.22 * e; c.drawImage(A, x, 0, sw, H, x, sag, sw, H + sag * 0.3); }
+ // 新画面:液面以上
+ c.save(); c.beginPath(); c.moveTo(0, -10); for (let x = 0; x <= W; x += 4) c.lineTo(x, edge(x)); c.lineTo(W, -10); c.closePath(); c.clip(); c.drawImage(B, 0, 0); c.restore();
+ // 液面:内侧暗边(厚度感)+高光
+ c.save(); c.beginPath(); for (let x = 0; x <= W; x += 4) { const y = edge(x); x ? c.lineTo(x, y) : c.moveTo(x, y); }
+ c.strokeStyle = 'rgba(40,20,10,.35)'; c.lineWidth = 9; c.filter = 'blur(3px)'; c.stroke(); c.filter = 'none';
+ c.translate(0, -5); c.strokeStyle = 'rgba(255,250,232,.7)'; c.lineWidth = 3; c.stroke(); c.restore();
+};
+
+// ② 达利 → 霍珀:一道硬边斜光块从左侧切进来——光块里是新画面(带暖光),光块外的旧画面逐渐沉进冷绿阴影;
+// 光块里有一根窗棂竖影跟着走。最后暖光褪去,只剩新画面。
+T.sunShaft = function (c, A, B, p) {
+ const e = ease.out(p) * 0.4 + ease.inOut(p) * 0.6, slant = 260;
+ const xR = lerp(-slant, W + slant + 60, e), xL = lerp(-slant - 20, -slant - 900, e) ; // 右缘扫过全屏,左缘留在左外
+ const band = () => { c.beginPath(); c.moveTo(xL, 0); c.lineTo(xR, 0); c.lineTo(xR - slant, H); c.lineTo(xL - slant, H); c.closePath(); };
+ c.drawImage(A, 0, 0);
+ c.save(); c.globalCompositeOperation = 'multiply'; c.fillStyle = `rgba(70,120,110,${0.7 * Math.min(1, p * 2)})`; c.fillRect(0, 0, W, H); c.restore();
+ c.save(); band(); c.clip(); c.drawImage(B, 0, 0);
+ const warm = 0.45 * (1 - seg(p, 0.6, 1));
+ c.globalCompositeOperation = 'screen'; c.fillStyle = `rgba(255,214,140,${warm})`; c.fillRect(0, 0, W, H);
+ c.globalCompositeOperation = 'multiply'; c.fillStyle = `rgba(80,120,110,${0.8 * (1 - seg(p, 0.7, 1))})`;
+ const mx = xR - 420; c.beginPath(); c.moveTo(mx, 0); c.lineTo(mx + 34, 0); c.lineTo(mx + 34 - slant, H); c.lineTo(mx - slant, H); c.closePath(); c.fill();
+ c.restore();
+ // 光块前缘一道亮边
+ c.save(); c.strokeStyle = `rgba(255,236,190,${0.8 * (1 - seg(p, 0.8, 1))})`; c.lineWidth = 6; c.beginPath(); c.moveTo(xR, 0); c.lineTo(xR - slant, H); c.stroke(); c.restore();
+};
+
+// ③ 霍珀 → 吉卜力:水彩在湿纸上晕开。几团色晕从窗口先后绽开、边界是噪声扰动的圆,
+// 边缘一圈颜料沉积的深色水痕+外侧一圈被水冲淡的亮晕;色晕里是新画面。
+// 水痕/亮晕的 α 跟着「这一团的扩张进度」淡出,否则长大后的水痕线会横穿新画面(第一版踩到)。
+T.bleed = function (c, A, B, p, o) {
+ const cx = o.cx || 580, cy = o.cy || 330;
+ const blobs = [[cx, cy, 0, 1.0], [1300, 420, 0.14, 0.75], [520, 880, 0.24, 0.6], [1650, 860, 0.3, 0.6], [1050, 100, 0.34, 0.55]];
+ const st = blobs.map(([x, y, t0, k]) => ({ x, y, q: ease.inOut(seg(p, t0, t0 + 0.66)), k }));
+ const one = (i) => { const b = st[i], R = b.q * 1400 * b.k; if (R <= 0) return;
+ for (let j = 0; j <= 90; j++) { const a = j / 90 * Math.PI * 2, n = PAINT.fbm(Math.cos(a) * 1.6 + i * 7, Math.sin(a) * 1.6 + p * 0.8, 3);
+ const rr = R * (1 + 0.28 * n + 0.05 * Math.sin(a * 9 + i)); const X = b.x + Math.cos(a) * rr, Y = b.y + Math.sin(a) * rr; j ? c.lineTo(X, Y) : c.moveTo(X, Y); }
+ c.closePath(); };
+ c.drawImage(A, 0, 0);
+ // 水痕只在刚绽开时有(q<0.55 内淡到 0)——审片抓到长大后的残圈横穿画面
+ st.forEach((b, i) => { if (b.q <= 0 || b.q >= 1) return; c.save(); c.beginPath(); one(i); c.strokeStyle = `rgba(255,250,236,${0.6 * (1 - b.q)})`; c.lineWidth = 70; c.filter = 'blur(18px)'; c.stroke(); c.restore(); });
+ c.save(); c.beginPath(); st.forEach((b, i) => one(i)); c.clip(); c.drawImage(B, 0, 0); c.restore();
+ st.forEach((b, i) => { if (b.q <= 0 || b.q >= 0.55) return; c.save(); c.beginPath(); one(i); c.globalCompositeOperation = 'multiply'; c.strokeStyle = `rgba(150,110,70,${0.6 * Math.pow(1 - b.q / 0.55, 2)})`; c.lineWidth = 5; c.filter = 'blur(1.2px)'; c.stroke(); c.restore(); });
+};
+
+// ④ 吉卜力 → 蒸汽波:VHS 磁带故障。前半旧画面被横向撕裂+RGB 分离,中段一下「场同步丢失」整幅上滚+黑条,
+// 后半新画面带着逐渐收敛的撕裂稳定下来。
+T.vhs = function (c, A, B, p) {
+ const f = Math.floor(p * 18), r = rng(900 + f), amp = Math.sin(Math.PI * p);
+ const src = p < 0.5 ? A : B;
+ const roll = p > 0.38 && p < 0.62 ? (seg(p, 0.38, 0.62) * H * 0.8) | 0 : 0;
+ c.fillStyle = '#000'; c.fillRect(0, 0, W, H);
+ if (roll) { c.drawImage(src, 0, roll); c.drawImage(src, 0, roll - H - 40); c.fillStyle = '#05010a'; c.fillRect(0, roll - 40, W, 40); }
+ else c.drawImage(src, 0, 0);
+ // 撕裂带(从 A 或 B 里取,横向错位)
+ let y = 0; while (y < H) { const h = 6 + r() * 48, use = r() < p ? B : A;
+ if (r() < 0.55 * amp + 0.08) { const dx = (r() - 0.5) * 260 * amp; c.drawImage(use, 0, y, W, h, dx, y, W, h); }
+ y += h; }
+ // RGB 分离:洋红/青两份半透明错位
+ c.save(); c.globalCompositeOperation = 'screen'; c.globalAlpha = 0.45 * amp;
+ const T2 = PAINT.scratch('vhsT'), tg = T2.getContext('2d');
+ [['#ff00ff', 14 * amp], ['#00ffff', -14 * amp]].forEach(([col, dx]) => { tg.globalCompositeOperation = 'source-over'; tg.clearRect(0, 0, W, H); tg.drawImage(src, 0, 0); tg.globalCompositeOperation = 'multiply'; tg.fillStyle = col; tg.fillRect(0, 0, W, H); c.drawImage(T2, dx, 0); });
+ c.restore();
+ // 雪花线
+ c.save(); c.globalAlpha = 0.7 * amp; for (let i = 0; i < 160; i++) { c.fillStyle = r() < 0.5 ? '#fff' : '#9a9a9a'; c.fillRect(r() * W, r() * H, 30 + r() * 200, 2); } c.restore();
+};
+
+
+// ---- 样片补的 4 个:A–D 每组第一段在片头没有进入转场,这里按「进入段的签名语言」补上 ----
+Object.assign(T, {
+ // 进入水墨:旧画先被「洗」成宣纸(去色、提亮、减对比),几团墨点从落笔处先后洇开,边缘带一圈墨晕,新画在墨里出现
+ inkBloom(c, A, B, p, o) {
+ const cx = o.cx || 560, cy = o.cy || 740;
+ c.save(); c.filter = `grayscale(${seg(p, 0, 0.5)}) brightness(${1 + 0.35 * seg(p, 0, 0.6)}) contrast(${1 - 0.3 * seg(p, 0, 0.6)})`; c.drawImage(A, 0, 0); c.restore();
+ const blobs = once('inkBloom', () => { const r = rng(17), out = [[cx, cy, 0, 1.0]]; for (let i = 0; i < 6; i++) out.push([200 + r() * 1520, 120 + r() * 840, 0.08 + r() * 0.3, 0.45 + r() * 0.4]); return out; });
+ const outline = (g, x, y, R) => { g.beginPath(); for (let j = 0; j <= 72; j++) { const a = j / 72 * TAU, n = PAINT.fbm(Math.cos(a) * 1.8 + x * 0.01, Math.sin(a) * 1.8 + y * 0.01, 3), rr = R * (1 + 0.35 * n); j ? g.lineTo(x + Math.cos(a) * rr, y + Math.sin(a) * rr) : g.moveTo(x + Math.cos(a) * rr, y + Math.sin(a) * rr); } g.closePath(); };
+ const st = blobs.map(([x, y, t0, k]) => { const q = ease.out(seg(p, t0, t0 + 0.7)); return [x, y, q, q * 1500 * k]; });
+ // 遮罩与墨边都在 1/4 分辨率上画再放大(边缘本来就是软的;全分辨率 blur 要 ~170ms)
+ const sm = once('inkBloomSm', () => [mkc(W / 4, H / 4), mkc(W / 4, H / 4)]), [mk, rim] = sm, mg = mk.getContext('2d'), rg = rim.getContext('2d');
+ mg.reset(); mg.scale(0.25, 0.25); mg.filter = 'blur(3px)'; mg.fillStyle = '#000';
+ st.forEach(([x, y, q, R]) => { if (q > 0) { outline(mg, x, y, R); mg.fill(); } });
+ rg.reset(); rg.scale(0.25, 0.25); rg.filter = 'blur(2.5px)'; rg.lineWidth = 34; // 墨晕边:刚洇开时浓,长大后淡出(否则残圈横穿新画面)
+ st.forEach(([x, y, q, R]) => { if (q <= 0 || q >= 1) return; rg.strokeStyle = `rgba(30,26,22,${0.55 * Math.pow(1 - q, 1.5)})`; outline(rg, x, y, R); rg.stroke(); });
+ c.save(); c.globalCompositeOperation = 'multiply'; c.drawImage(rim, 0, 0, W, H); c.restore();
+ const T2 = o.tmp, g = T2.getContext('2d'); g.reset(); g.drawImage(B, 0, 0); g.globalCompositeOperation = 'destination-in'; g.drawImage(mk, 0, 0, W, H);
+ c.drawImage(T2, 0, 0);
+ if (p > 0.8) { c.globalAlpha = seg(p, 0.8, 1); c.drawImage(B, 0, 0); c.globalAlpha = 1; }
+ },
+ // 进入构成主义:李西茨基「红楔打白圈」——一枚红楔从左下斜刺过画面,楔尖后面是新画面;三根黑排版条跟着楔子冲进来
+ redWedge(c, A, B, p, o) {
+ const e = ease.inOut(p), ang = -0.32, ca = Math.cos(ang), sa = Math.sin(ang);
+ const X = lerp(-700, W + 900, e); // 楔尖沿斜轴的位置
+ const tf = (u, v) => [960 + (u - 960) * ca - (v - 540) * sa, 540 + (u - 960) * sa + (v - 540) * ca];
+ c.drawImage(A, 0, 0);
+ c.save(); c.beginPath(); [tf(-2000, -2000), tf(X - 420, -2000), tf(X - 420, 3000), tf(-2000, 3000)].forEach((q, i) => i ? c.lineTo(...q) : c.moveTo(...q)); c.closePath(); c.clip(); c.drawImage(B, 0, 0); c.restore();
+ c.save(); c.fillStyle = '#c8231c'; c.beginPath(); [tf(X, 540), tf(X - 520, 540 - 330), tf(X - 520, 540 + 330)].forEach((q, i) => i ? c.lineTo(...q) : c.moveTo(...q)); c.closePath(); c.fill();
+ c.fillStyle = '#151311'; [[-150, 26, 0], [120, 18, 0.12], [260, 34, 0.2]].forEach(([dv, h, lag]) => { const x1 = lerp(-700, W + 900, ease.inOut(clamp(p - lag))) - 560;
+ c.beginPath(); [tf(-2000, 540 + dv), tf(x1, 540 + dv), tf(x1, 540 + dv + h), tf(-2000, 540 + dv + h)].forEach((q, i) => i ? c.lineTo(...q) : c.moveTo(...q)); c.closePath(); c.fill(); });
+ c.restore();
+ },
+ // 进入 Kirby 漫画:新画面按漫画分格一格格「砸」进来(从 1.18 倍落位、黑格线),没换到的旧画面先被盖上一层本戴网点
+ comicPanels(c, A, B, p, o) {
+ const cells = once('comicPanels', () => [[0, 0, 820, 520, 0], [820, 0, 1100, 520, 0.12], [0, 520, 640, 560, 0.24], [640, 520, 700, 560, 0.34], [1340, 520, 580, 560, 0.44]]);
+ c.drawImage(A, 0, 0);
+ c.save(); c.globalAlpha = Math.min(1, p * 2.5) * 0.85; c.fillStyle = PAINT.dotPattern(c, 'comicTr', 12, 3.4, '#e0287a', null, 75); c.fillRect(0, 0, W, H); c.restore();
+ for (const [x, y, w, h, t0] of cells) {
+ const q = seg(p, t0, t0 + 0.32); if (q <= 0) continue; const s = 1.18 - 0.18 * ease.outBack(q);
+ c.save(); c.beginPath(); c.rect(x, y, w, h); c.clip();
+ c.translate(x + w / 2, y + h / 2); c.scale(s, s); c.translate(-x - w / 2, -y - h / 2); c.drawImage(B, 0, 0); c.restore();
+ c.save(); c.strokeStyle = '#141212'; c.lineWidth = 14 * (1 - seg(p, 0.8, 1)); if (c.lineWidth > 0.5) c.strokeRect(x, y, w, h); c.restore();
+ }
+ },
+ // 进入伦勃朗:旧画沉进暗褐(暗角从四周合拢),然后一道从窗口斜下来的光柱把新画面照出来,最后暗部也慢慢显影
+ chiaroscuro(c, A, B, p, o) {
+ const sx = o.cx || 580, sy = o.cy || 300;
+ c.drawImage(A, 0, 0);
+ c.save(); c.globalCompositeOperation = 'multiply'; const d = seg(p, 0, 0.45);
+ const vg = c.createRadialGradient(960, 540, lerp(1100, 80, d), 960, 540, lerp(1400, 700, d)); vg.addColorStop(0, 'rgba(255,255,255,1)'); vg.addColorStop(1, `rgba(28,18,10,${0.9 * d + 0.1})`);
+ c.fillStyle = vg; c.fillRect(0, 0, W, H); c.fillStyle = `rgba(40,26,14,${0.85 * d})`; c.fillRect(0, 0, W, H); c.restore();
+ const q = ease.inOut(seg(p, 0.25, 0.9)); if (q <= 0) return;
+ const T2 = o.tmp, g = T2.getContext('2d'); g.reset(); g.drawImage(B, 0, 0); g.globalCompositeOperation = 'destination-in'; g.filter = 'blur(40px)'; g.fillStyle = '#000';
+ const spread = lerp(60, 1400, q); g.beginPath(); g.moveTo(sx - 180, sy - 200); g.lineTo(sx + 180, sy - 200); g.lineTo(sx + 500 + spread, sy + 900); g.lineTo(sx - 200 - spread * 0.6, sy + 900); g.closePath(); g.fill();
+ g.beginPath(); g.arc(sx + 420, sy + 260, lerp(40, 1500, q), 0, TAU); g.fill(); g.filter = 'none';
+ c.drawImage(T2, 0, 0);
+ c.save(); c.globalCompositeOperation = 'lighter'; c.globalAlpha = 0.35 * Math.sin(Math.PI * q); c.fillStyle = 'rgba(255,214,150,1)'; c.beginPath(); c.moveTo(sx - 140, sy - 160); c.lineTo(sx + 140, sy - 160); c.lineTo(sx + 420 + spread * 0.5, sy + 900); c.lineTo(sx - 120 - spread * 0.3, sy + 900); c.closePath(); c.filter = 'blur(30px)'; c.fill(); c.restore();
+ if (p > 0.8) { c.globalAlpha = seg(p, 0.8, 1); c.drawImage(B, 0, 0); c.globalAlpha = 1; }
+ },
+});
+
+// ================= YouTube 解说语法的转场(references/09-视频动画语法.md) =================
+// 解说片的转场原则和艺术速通相反:不抢戏、保持空间连续(观众知道「镜头去了哪」)——多数是相机运动和共享元素。
+// 相机运动在场景里按时间算好(CAM),转场只负责「A、B 怎么合」。这些段一般写 punch: 0 或片级 window.PUNCH = 0(关掉拍点冲击)。
+Object.assign(T, {
+ // 【同一世界】same:A、B 本来是同一幅画(同一世界画布、相机连续运动),直接用 B。Vox 桌面快摇、白板平移都走它。
+ same(c, A, B) { c.drawImage(B, 0, 0); },
+ // 【Kurzgesagt】lensReveal 钻进镜头:A 里相机正指数推进某个圆(眼睛/镜头),B 只露在这个圆里,圆随推进长大到盖满屏,圆边一圈光环。
+ // o.lens(t) → {x, y, r} 屏幕上的圆(由上一镜的相机算,必须和 A 的推进同步);o.ring 光环色。圆要盖满屏:推进倍数 ≥ CAM.coverZoom(r)。
+ lensReveal(c, A, B, p, o) {
+ const L = o.lens(o.t);
+ c.drawImage(A, 0, 0);
+ if (L.r < 1) return;
+ c.save(); c.beginPath(); c.arc(L.x, L.y, L.r, 0, TAU); c.clip(); c.drawImage(B, 0, 0); c.restore();
+ const ring = Math.max(3, L.r * 0.06), col = o.ring || [120, 240, 255], col2 = o.ring2 || [70, 230, 255];
+ c.save(); c.strokeStyle = `rgba(${col},.85)`; c.lineWidth = ring; c.beginPath(); c.arc(L.x, L.y, L.r + ring / 2, 0, TAU); c.stroke();
+ c.strokeStyle = `rgba(${col2},.25)`; c.lineWidth = ring * 3; c.beginPath(); c.arc(L.x, L.y, L.r + ring * 2, 0, TAU); c.stroke(); c.restore();
+ },
+ // 【Kurzgesagt】matchCut 填满再拉出:A 推进到某个色块满屏,B 从同色的东西里拉出;只在 o.at(默认中点)±o.width/2 内交叉溶解(±3 帧),两边颜色本来一样,剪点看不见。
+ matchCut(c, A, B, p, o) {
+ const w = o.width || 0.06, q = clamp((p - (o.at ?? 0.5) + w / 2) / w);
+ if (q <= 0) { c.drawImage(A, 0, 0); return; }
+ if (q >= 1) { c.drawImage(B, 0, 0); return; }
+ c.drawImage(A, 0, 0); c.globalAlpha = q; c.drawImage(B, 0, 0); c.globalAlpha = 1;
+ },
+ // 【storytime】whip 甩镜:旧画面加速甩出、新画面减速甩入,中段整屏横向运动模糊(采样 ≤8px 一张,少了读成残影)。o.dir=1 往左甩
+ whip(c, A, B, p, o) {
+ const e = MO.expoInOut(p), dir = o.dir || 1, off = e * W * dir;
+ const v = Math.max(0, 1 - Math.abs(p - 0.5) * 2.2);
+ const n = 1 + Math.round(v * 40), spread = v * 320;
+ for (let k = 0; k < n; k++) {
+ const d = n === 1 ? 0 : (k / (n - 1) - 0.5) * spread * dir;
+ c.globalAlpha = 1 / (k + 1) > 0.999 ? 1 : 1 / (k + 1);
+ c.drawImage(A, -off + d, 0); c.drawImage(B, W * dir - off + d, 0);
+ }
+ c.globalAlpha = 1;
+ },
+ // 【storytime】smash 砸镜:第一帧就是新画面,带 1.22 倍放大从猛到停(弹簧,夹在 ≥1 防黑边),首两帧白闪。反应特写用
+ smash(c, A, B, p, o) {
+ const lt = p * o.dur, s = Math.max(1, 1 + 0.22 * (1 - MO.springHz(lt, o.freq || 3, o.decay || 11)));
+ c.save(); c.translate(W / 2, H / 2); c.scale(s, s); c.translate(-W / 2, -H / 2); c.drawImage(B, 0, 0); c.restore();
+ if (lt < 2 / 60) { c.fillStyle = 'rgba(255,255,255,0.55)'; c.fillRect(0, 0, W, H); }
+ },
+ // 【动态文字】fillZoom 冲进色块:镜头冲进旧画面里某个形(o.cx,o.cy;形的颜色 o.fill = 新画面底色),冲满屏后新画面从 1.25 落回 1。
+ // 揭开点 = o.k(默认 .55):卡拍时段起点 = 小节线 − k×dur(MO.onBeat)。o.maxZoom 冲进倍数(指数缩放本身就是加速,别再套 expoIn)
+ fillZoom(c, A, B, p, o) {
+ const k = o.k || 0.55;
+ if (p < k) { const q = Math.pow(p / k, 2.2), s = Math.pow(o.maxZoom || 40, q);
+ c.save(); c.translate(o.cx, o.cy); c.scale(s, s); c.translate(-o.cx, -o.cy); c.drawImage(A, 0, 0); c.restore(); }
+ else { const q = MO.expoOut((p - k) / (1 - k)), s = lerp(1.25, 1, q);
+ c.fillStyle = o.fill || '#000'; c.fillRect(0, 0, W, H);
+ c.save(); c.globalAlpha = clamp(q * 3); c.translate(W / 2, H / 2); c.scale(s, s); c.translate(-W / 2, -H / 2); c.drawImage(B, 0, 0); c.restore(); }
+ },
+ // 【动态文字】bands 色带擦除:o.colors 几条斜切色带接力扫过(间隔 o.gap),最后一条后面是新画面。揭开点 ≈ .6
+ bands(c, A, B, p, o) {
+ const cols = o.colors || ['#FFD23F', '#FF5A36', '#14213D'], n = cols.length, sk = H * 0.35, gap = o.gap || 0.13;
+ const edge = q => lerp(-sk - 40, W + sk + 40, MO.expoInOut(clamp(q)));
+ c.drawImage(A, 0, 0);
+ const clipTo = x => { c.beginPath(); c.moveTo(-sk - 60, 0); c.lineTo(x + sk, 0); c.lineTo(x, H); c.lineTo(-sk - 60, H); c.closePath(); };
+ for (let i = 0; i < n; i++) { const x = edge((p - i * gap) / (1 - (n - 1) * gap)); c.save(); clipTo(x); c.clip(); c.fillStyle = cols[i]; c.fillRect(0, 0, W, H); c.restore(); }
+ const xb = edge((p - n * gap) / (1 - (n - 1) * gap));
+ c.save(); clipTo(xb); c.clip(); c.drawImage(B, 0, 0); c.restore();
+ },
+ // 【动态文字】push 推页:新旧一起平移(expoInOut),像镜头在长画布上滑到下一块。o.dir: 'left'(默认)| 'up'。到 90% 位移在 p≈.58
+ push(c, A, B, p, o) {
+ const e = MO.expoInOut(p);
+ if (o.dir === 'up') { c.drawImage(A, 0, -e * H); c.drawImage(B, 0, H - e * H); }
+ else { c.drawImage(A, -e * W, 0); c.drawImage(B, W - e * W, 0); }
+ },
+ // 【3b1b / 财经】zoomThrough 镜头穿越:相机推向 (cx,cy),新画面从该物体「里面」长出来。
+ // o: {cx, cy, zoom, r0=物体半径(圆形开口;0=不裁), live, bg, focus:[x,y] 新画面主体位置, bScale0, ease}
+ // live:true = 旧镜头自己在转场里继续推相机(矢量重画,线条不糊;推荐);否则把 A 当位图放大(10× 以上会糊)。
+ // 有 r0 时 zoom 要 ≥ CAM.coverZoom(r0, cx, cy)(≈1100/r0),否则开口到结束都盖不满屏,最后一帧会跳。
+ zoomThrough(c, A, B, p, o) {
+ const cx = o.cx, cy = o.cy, Z = o.zoom || 7, e = (o.ease || MO.smooth)(p);
+ const sA = Math.pow(Z, e);
+ c.fillStyle = o.bg || '#000'; c.fillRect(0, 0, W, H);
+ c.save(); if (!o.live) { c.translate(cx, cy); c.scale(sA, sA); c.translate(-cx, -cy); }
+ c.globalAlpha = 1 - (o.bScale0 ? seg(p, 0.5, 0.8) : o.r0 ? seg(p, 0.45, 0.8) : seg(p, 0.6, 0.95)); // 开口外的旧画面早点退,新镜头标题出来时不挂残影
+ c.drawImage(A, 0, 0); c.restore();
+ c.save();
+ if (o.r0) {
+ const R = o.r0 * sA; c.beginPath(); c.arc(cx, cy, R, 0, TAU); c.clip();
+ c.fillStyle = o.bg || '#000'; c.globalAlpha = seg(p, 0.18, 0.45); c.fillRect(0, 0, W, H); // 穿过物体表面:亮面渐暗成内部
+ }
+ // 新画面从「1/Z 大小、主体 focus 对准 (cx,cy)」走到原位全屏;没有圆形开口时用 bScale0(如 0.6)从较大尺寸起、晚一点溶进来,免得像浮着的小卡片
+ const [fx, fy] = o.focus || [W / 2, H / 2], sB = o.bScale0 ? Math.pow(o.bScale0, 1 - e) : Math.pow(Z, e - 1);
+ c.globalAlpha = o.r0 ? seg(p, 0.22, 0.55) : o.bScale0 ? seg(p, 0.45, 0.85) : seg(p, 0.25, 0.7);
+ const m = MO.smooth(seg(e, 0.55, 1)); // 开口没盖满屏前,主体一直待在开口正中;最后才归位
+ c.translate(lerp(cx, fx, m), lerp(cy, fy, m)); c.scale(sB, sB); c.translate(-fx, -fy); c.drawImage(B, 0, 0);
+ c.restore();
+ },
+ // 【发布会】blurPush 模糊推进:旧画面后退(0.92)+模糊+变暗,新画面从 1.06 带模糊落到 1.0 清晰;底下垫一张放大重模糊的旧画面防黑边
+ blurPush(c, A, B, p) {
+ const e = MO.appleOut(p);
+ c.save(); c.filter = 'blur(30px)'; c.translate(W / 2, H / 2); c.scale(1.08, 1.08); c.translate(-W / 2, -H / 2); c.drawImage(A, 0, 0); c.restore();
+ const draw = (img, s, blur, a) => { if (a <= 0) return; c.save(); c.globalAlpha = a; if (blur > 0.3) c.filter = `blur(${blur.toFixed(1)}px)`;
+ c.translate(W / 2, H / 2); c.scale(s, s); c.translate(-W / 2, -H / 2); c.drawImage(img, 0, 0); c.restore(); };
+ draw(A, lerp(1, 0.92, e), 24 * e, 1 - seg(p, 0.2, 0.75));
+ draw(B, lerp(1.06, 1, e), 24 * (1 - e), seg(p, 0.15, 0.7));
+ },
+ // 【发布会】expandRect 卡片展开成全屏(共享元素):o.rect={x,y,w,h} 是卡片在上一镜末帧的屏幕矩形、o.r 圆角;弹簧展开,里面装新画面,旧画面后退变暗。
+ // 新画面第一帧就不透明地装进卡片(卡内硬切被展开运动盖住):卡片半透明时任何溶接都会看到新旧两层字叠在一起。
+ expandRect(c, A, B, p, o) {
+ const e = MO.spring(p * (o.dur || 0.6), { duration: 0.55, bounce: 0 });
+ const R = o.rect, x = lerp(R.x, 0, e), y = lerp(R.y, 0, e), w = lerp(R.w, W, e), h = lerp(R.h, H, e), r = lerp(o.r || 28, 0, e);
+ c.save(); c.filter = 'blur(30px)'; c.translate(W / 2, H / 2); c.scale(1.08, 1.08); c.translate(-W / 2, -H / 2); c.drawImage(A, 0, 0); c.restore();
+ c.save(); c.globalAlpha = 1 - 0.6 * e;
+ const s = lerp(1, 0.94, e); c.translate(W / 2, H / 2); c.scale(s, s); c.translate(-W / 2, -H / 2); c.drawImage(A, 0, 0); c.restore();
+ c.save(); c.beginPath(); c.roundRect(x, y, w, h, r); c.clip();
+ const k = Math.max(w / W, h / H); c.translate(x + w / 2, y + h / 2); c.scale(k, k); c.translate(-W / 2, -H / 2);
+ c.drawImage(B, 0, 0); c.restore();
+ },
+ // 【财经】slidePush 面板横推:新面板从右推入、旧面板向左推出(bezier .7,0,.2,1),一道品牌色竖条 o.bar 领路
+ slidePush(c, A, B, p, o) {
+ const e = MO.bezier(0.7, 0, 0.2, 1)(p), dx = -W * e;
+ c.drawImage(A, dx, 0); c.drawImage(B, dx + W, 0);
+ if (o.bar) { c.fillStyle = o.bar; c.fillRect(dx + W - 14, 0, 14, H); }
+ },
+ // 【3b1b】fadeShift 淡出上移 / 淡入上移(manim FadeOut(shift=UP) + FadeIn(shift=UP)),o.shift 位移像素
+ fadeShift(c, A, B, p, o) {
+ const d = o.shift || 60, a = MO.smooth(seg(p, 0, 0.6)), b = MO.smooth(seg(p, 0.4, 1));
+ c.fillStyle = o.bg || '#000'; c.fillRect(0, 0, W, H);
+ c.save(); c.globalAlpha = 1 - a; c.drawImage(A, 0, -d * a); c.restore();
+ c.save(); c.globalAlpha = b; c.drawImage(B, 0, d * (1 - b)); c.restore();
+ },
+});
+
+// 项目自己的转场(transitions/<名>.js)可以复用这几个工具
+window.TR_UTIL = { once, seg, mkc };
+})();
diff --git "a/scripts/engine/\346\227\266\344\273\243\344\275\234\350\200\205\350\247\204\350\214\203.md" "b/scripts/engine/\346\227\266\344\273\243\344\275\234\350\200\205\350\247\204\350\214\203.md"
new file mode 100644
index 0000000..1585ded
--- /dev/null
+++ "b/scripts/engine/\346\227\266\344\273\243\344\275\234\350\200\205\350\247\204\350\214\203.md"
@@ -0,0 +1,47 @@
+# 时代作者规范(纯代码绘制)
+
+你负责的每个时代 = 一个文件 `scenes/<id>.js`,注册:
+
+```js
+SCENES['<id>'] = { draw(c, lt, t) { /* 画满 1920x1080 */ } };
+```
+
+- `c`:目标 2D context;`lt`:本段局部时间(秒,从该时代转场开始算,可略大于本段时长);`t`:全片时间。
+- **不要画年份牌**(右上角 1500–1890 × 40–210 由引擎画),这块留背景,别放重要元素。
+- **不要改 `lib/`、`engine.js`、`eras.js`、`transitions.js`、别人的 scene 文件**。需要的工具函数写在自己的文件里。
+
+## 可用的库(先读源码)
+- `lib/paint.js` → `PAINT`:噪声 noise/fbm、纹理 texture/grain/craquelure、手绘线 roughPath/boilSeed、
+ 风格渲染器 strokes(流场笔触,支持 palette 区域色板)/dabs/mosaic/halftone/pixelate/facets、`swatch` 色组、`choreo` 共享编舞、steam、particles、`scratch(key)` 离屏画布。
+- `lib/rig.js` → `RIG`:`RIG.girl(opt)` 少女骨架(侧身朝左坐,返回各部位 Path2D + 锚点 `G.A`),`RIG.drawGirl(c,G,pal)`(pal.mode 可为 fill/line),
+ `RIG.cat(opt)` 橘白猫骨架(朝右坐),`RIG.drawCat(c,K,pal)`,`RIG.drawCup`,`RIG.smooth(points)` 平滑曲线,`RIG.taper` 锥形肢体,`RIG.ik2`。
+- **标杆实现:`scenes/09_postimp.js`(梵高)**——看它的结构:平涂底稿 → 风格渲染器重画(区域色板)→ 角色平涂+细笔触 → 补线稿 → 会动的高光。
+
+## 硬要求
+1. **同一个场景骨架**:标准构图——窗(350,120)-(810,560)、猫坐地(390,610)-(690,905)、桌(810,620)-(1200,905)、人(1120,200)-(1500,910)。原片每个时代都对齐这套位置,转场也依赖它。
+2. **角色**:人物是 17 岁欧洲金发少女,穿**该时代的少女服装**(服装端庄);猫是**橘白猫**(头顶/背/尾橘色虎斑,口鼻/胸口/肚子/爪子白色)。
+ 必须基于 `RIG.girl` / `RIG.cat` 的骨架与编舞(同一副骨架、同一套动作),但画法要换成该时代的画法:可以只取 Path2D 自己填/描/剪影,可以在锚点上加服饰,也可以对骨架点做时代化变形(如埃及的正面眼、黑绘剪影)。
+3. **画里的东西要活**:主角动作用 `PAINT.choreo(lt,t)`(端杯 cup、甩尾 tail、眨眼 blink、呼吸 breathe),
+ 再加 2–4 个**取自该时代视觉母题的小循环**——清单见 `../拆解/分镜表.md` 各时代「镜内动作」(例:岩画动物两张姿态交替奔跑、圣甲虫推太阳球、回纹带滚动、维苏威冒烟、金箔高光扫过、扑翼机飞过、樱花飘落、光斑闪烁…)。
+ 该时代在片中只停留 0.25–1.4 秒,动作要在这个窗口里**看得出来**。
+4. **风格是代码做出来的**:用渲染器/纹理/线条把它画成那个时代的艺术品,而不是剪贴画。线条可用 8–12fps「沸腾」(boilSeed)增加手绘感。
+5. **性能**:每帧 ≤ 150ms(1920×1080)。静态部分用 `PAINT.cached` 缓存。所有随机都用种子,同一个 t 必须画出同一帧。
+
+## 参考
+- 参考片该时代帧:`../生图/ref/<id>.png`(构图、母题、配色、计数器以外的一切;由你从参考片自行抽帧,不随 skill 分发)
+- AI 设定稿(同构图,已换成金发少女+橘白猫):`../生图/plates/<id>.png` ——当作美术设定参考,**不许把图片贴进画面**,只能用代码画。
+- 镜内动作、转场原点:`../拆解/分镜表.md`
+- 参考片 60fps:`../原片/<参考片>.mp4`(自备)
+
+## 自检(每个时代至少 3 轮)
+```sh
+cd <你的项目目录> # 里面有 代码工程/(从 scripts/engine 复制)
+uv run --with playwright python 代码工程/render.py --solo <id> --stills 0,0.3,0.6,0.9 --out 渲染/<id>
+uv run --with playwright python 代码工程/render.py --solo <id> --from 0 --to 1.2 --out 渲染/<id>/clip.mp4
+```
+把你的帧和原片帧、设定稿并排拼图看(PIL),问自己:①一眼认得出是哪个时代/艺术家吗?②少女像 17 岁金发少女、猫是橘白猫吗?③在 1 秒里看得到画在动吗?④有没有穿帮(错位、断线、遮挡错误、空白)?
+有一项不过就改,直到满意。
+
+## 交付
+- `scenes/<id>.js`
+- `notes/<id>.md`:用了哪些手法(渲染器参数、色板、母题动画怎么做的、踩到的坑),**这是要沉淀进 skill 的经验**,写具体、写数字。
diff --git a/scripts/font_subset.py b/scripts/font_subset.py
new file mode 100644
index 0000000..33614ba
--- /dev/null
+++ b/scripts/font_subset.py
@@ -0,0 +1,122 @@
+#!/usr/bin/env python3
+# /// script
+# dependencies = ["fonttools"]
+# ///
+"""从一个中文字体里抽子集,写成 woff 放进 engine/lib/fonts/。缺字形会静默回退系统字体(换台机器就变样),
+所以画面里要用的中文字必须真的在子集里——引擎启动时 U.assertGlyphs 会查角标的字,缺了 console.error,qa 失败。
+
+ uv run scripts/font_subset.py # 重建预置的霞鹜文楷子集(扫 engine/ 下全部 .js 里的中文+内置常用字)
+ uv run scripts/font_subset.py --scan <代码工程目录> # 把另一个工程里用到的中文也并进来
+ uv run scripts/font_subset.py --text "皮影戏蓝色时期" # 追加指定文字
+ uv run scripts/font_subset.py --font path/to/XXX.ttf --out <工程>/lib/fonts/XXX-400.woff --text "..." # 别的字体
+ uv run scripts/font_subset.py --gb2312 ... # 再并进 GB2312 全部 6763 个汉字(解说片换题目不用每次补字;单字重约 1MB)
+ uv run scripts/font_subset.py --fix-widths engine/lib/fonts/PuHui-Medium.woff # 只修字宽为 0 的全角空格(普惠体 Medium/Bold 源字体的 bug)
+
+预置的解说片字体(YouTube 语法示范与新片都用,见 references/09)就是这么做的(开源版的中文黑体换成了思源黑体,--font 指向 Noto Sans SC 按字重实例化后的 ttf;普惠体许可不允许转换后再分发,只能自己本地生成):
+ uv run scripts/font_subset.py --gb2312 # 霞鹜文楷(白板)
+ for w in 65-Medium:Medium 85-Bold:Bold 105-Heavy:Heavy 115-Black:Black; do # 阿里巴巴普惠体 3.0 四个字重
+ uv run scripts/font_subset.py --gb2312 --font path/to/AlibabaPuHuiTi-3-${w%%:*}.ttf --out scripts/engine/lib/fonts/PuHui-${w##*:}.woff; done
+
+默认字体:霞鹜文楷 Medium(LXGW WenKai,SIL Open Font License 1.1,可商用、可再分发、可嵌入),
+没有源文件就从 https://github.com/lxgw/LxgwWenKai/releases 下 LXGWWenKai-Medium.ttf,用 --font 指过去。
+新字体加进 engine/lib/fonts.js 才会注册(family 名 = 文件名去扩展名)。
+"""
+import argparse, re, sys
+from pathlib import Path
+from fontTools import subset
+from fontTools.ttLib import TTFont
+
+HERE = Path(__file__).resolve().parent
+ENGINE = HERE / 'engine'
+# 预置字:数字、标点、年代/朝代、常见风格与画种用字。子集保持小(几十 KB),用到新字再跑一次本脚本。
+BASE = ('01234567890123456789 ,。、:;!?「」『』《》()·—…~'
+ '年代世纪公元前后约初中晚期朝唐宋元明清汉魏晋隋周秦商夏民国现当今古'
+ '水墨写意工笔山水花鸟人物画法风格派主义时期艺术家作品壁窟敦煌莫高佛飞天供养'
+ '浮世绘木版印刷版画剪纸皮影戏偶灯影窗花年画书法篆隶楷行草印章钤朱文白'
+ '油画素描水彩粉笔丙烯蛋彩湿壁金箔马赛克镶嵌玻璃彩窗手抄本插图漫画动画卡通'
+ '古典文艺复兴巴洛克洛可可新浪漫写实印象后点彩野兽表现立体未来达达超现实抽象波普极简构成包豪斯装饰'
+ '蓝色玫瑰红黄绿青紫黑灰橙金银光影明暗烛夜日月星云雨雪风天海河湖林竹梅兰菊松'
+ '少女猫茶杯桌椅窗门墙地屋室灯花瓶书纸笔'
+ '八大山人齐白石克里姆特蒙克呐喊草间弥生波点伦勃朗吉卜力宫崎骏新海诚毕加索修拉莫奈睡莲马蒂斯哈林达利霍珀凯斯杰克柯比'
+ '蒸汽波像素光追橡皮管一二三四五六七八九十百千万')
+
+
+# 解说片常用的全角标点与符号
+PUNCT = ',。、:;!?「」『』《》()【】·—–…~“”‘’%+-×÷→←↑↓▲▼≈±°¥€①②③④⑤⑥⑦⑧⑨⑩✓'
+
+
+def gb2312_l1():
+ """GB2312 全部 6763 个汉字(一级 3755 常用字+二级 3008 次常用字,如「渲」「浏」)"""
+ out = set()
+ for hi in range(0xB0, 0xF8):
+ for lo in range(0xA1, 0xFF):
+ try: out.add(bytes([hi, lo]).decode('gb2312'))
+ except UnicodeDecodeError: pass
+ return out
+
+
+def cjk(text):
+ return set(ch for ch in text if ord(ch) > 0x2E7F)
+
+
+STR = re.compile(r"'(?:[^'\\\n]|\\.)*'|\"(?:[^\"\\\n]|\\.)*\"|`(?:[^`\\]|\\.)*`")
+
+
+def scan(d):
+ """只收 JS 字符串字面量里的中文(注释里的中文不会画到画面上,算进来子集会胖 20 倍)"""
+ out = set()
+ for f in Path(d).rglob('*.js'):
+ try: src = f.read_text(encoding='utf-8')
+ except Exception: continue
+ src = '\n'.join(re.sub(r'^\s*//.*$', '', l) for l in src.splitlines())
+ for m in STR.finditer(src): out |= cjk(m.group(0))
+ return out
+
+
+def fix_blank_widths(font):
+ """全角空格 U+3000 在阿里巴巴普惠体 3.0 的 Medium/Bold 源字体里字宽是 0(Heavy/Black 正常 984/990),
+ 「月收盘价,美元 纵轴未从 0 开始」会粘成一串。把它设成和「一」同宽。返回修了几个。"""
+ cmap, hm, n = font.getBestCmap(), font['hmtx'], 0
+ ref = cmap.get(0x4E00)
+ for cp in (0x3000,):
+ g = cmap.get(cp)
+ if g and ref and hm[g][0] == 0:
+ hm[g] = (hm[ref][0], 0); n += 1
+ return n
+
+
+def main():
+ ap = argparse.ArgumentParser(description=__doc__.splitlines()[0])
+ ap.add_argument('--font', default=str(Path.home() / 'Library/Fonts/LXGWWenKai-Medium.ttf'))
+ ap.add_argument('--out', default=str(ENGINE / 'lib/fonts/LXGWWenKai-500.woff'))
+ ap.add_argument('--scan', action='append', default=[], help='额外扫描的目录(可多次)')
+ ap.add_argument('--text', default='', help='额外要的字')
+ ap.add_argument('--no-default-scan', action='store_true', help='不扫 skill 自己的 engine/')
+ ap.add_argument('--gb2312', action='store_true', help='并进 GB2312 全部汉字(6763 个)')
+ ap.add_argument('--fix-widths', nargs='+', metavar='WOFF', help='不抽子集,只修已有字体文件里字宽为 0 的全角空格')
+ a = ap.parse_args()
+ if a.fix_widths:
+ for f in a.fix_widths:
+ ft = TTFont(f); n = fix_blank_widths(ft); ft.flavor = 'woff'
+ if n: ft.save(f)
+ print(f'{f}:修了 {n} 个字宽')
+ return
+ if not Path(a.font).exists(): sys.exit(f'找不到字体 {a.font}(见脚本说明的下载地址)')
+ chars = set(BASE) | set(a.text)
+ if not a.no_default_scan: chars |= scan(ENGINE)
+ for d in a.scan: chars |= scan(d)
+ chars |= set(chr(c) for c in range(0x20, 0x7F)) # ASCII 全带上(年份、英文副标题)
+ if a.gb2312: chars |= gb2312_l1() | set(PUNCT)
+ font = TTFont(a.font)
+ cmap = font.getBestCmap()
+ miss = sorted(ch for ch in chars if ord(ch) not in cmap and not ch.isspace())
+ opts = subset.Options(); opts.flavor = 'woff'; opts.layout_features = ['*']; opts.name_IDs = ['*']; opts.notdef_outline = True
+ sub = subset.Subsetter(opts); sub.populate(text=''.join(sorted(chars))); sub.subset(font)
+ if fix_blank_widths(font): print('源字体全角空格字宽为 0,已设成和「一」同宽')
+ Path(a.out).parent.mkdir(parents=True, exist_ok=True)
+ font.flavor = 'woff'; font.save(a.out)
+ print(f'{a.out} {len(chars)} 字 {Path(a.out).stat().st_size // 1024} KB' + (f'\n源字体里也没有:{"".join(miss)}' if miss else ''))
+
+
+if __name__ == '__main__':
+ main()
diff --git a/scripts/key_green.py b/scripts/key_green.py
new file mode 100644
index 0000000..e2271d0
--- /dev/null
+++ b/scripts/key_green.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python3
+"""绿幕抠图且保留原画面坐标:输出裁到主体的 RGBA png + sprites.json 里记下它在 1920x1080 画面中的左上角。
+gpt-image 用原片帧当参考图、只画角色铺 #00FF00 时,角色已经站在原片坐标上——裁剪时丢掉坐标就白对齐了。
+用法:python3 key_green.py raw/*.png --out ../工程/sprites [--soft 40 --hard 110]"""
+import argparse, json
+from pathlib import Path
+import numpy as np
+from PIL import Image
+ap = argparse.ArgumentParser(); ap.add_argument('files', nargs='+'); ap.add_argument('--out', required=True)
+ap.add_argument('--soft', type=float, default=30); ap.add_argument('--hard', type=float, default=100); ap.add_argument('--pad', type=int, default=4)
+a = ap.parse_args()
+out = Path(a.out); out.mkdir(parents=True, exist_ok=True)
+meta_p = out / 'sprites.json'; meta = json.loads(meta_p.read_text()) if meta_p.exists() else {}
+for f in a.files:
+ im = np.asarray(Image.open(f).convert('RGB')).astype(np.float32)
+ r, g, b = im[..., 0], im[..., 1], im[..., 2]
+ spill = g - np.maximum(r, b) # 绿色占优程度
+ alpha = 1 - np.clip((spill - a.soft) / (a.hard - a.soft), 0, 1)
+ # 去绿溢:半透明及边缘像素的绿通道压到 max(r,b)
+ g2 = np.where(spill > 0, np.minimum(g, np.maximum(r, b) + 0.25 * np.clip(spill, 0, 30)), g)
+ rgba = np.dstack([r, g2, b, alpha * 255]).clip(0, 255).astype(np.uint8)
+ ys, xs = np.where(alpha > 0.05)
+ if len(xs) == 0: print('empty', f); continue
+ x0, y0 = max(0, xs.min() - a.pad), max(0, ys.min() - a.pad)
+ x1, y1 = min(im.shape[1], xs.max() + a.pad + 1), min(im.shape[0], ys.max() + a.pad + 1)
+ name = Path(f).stem
+ Image.fromarray(rgba[y0:y1, x0:x1]).save(out / f'{name}.png')
+ meta[name] = {'x': int(x0), 'y': int(y0), 'w': int(x1 - x0), 'h': int(y1 - y0)}
+ print(name, meta[name])
+meta_p.write_text(json.dumps(meta, indent=1))
diff --git a/scripts/key_split.py b/scripts/key_split.py
new file mode 100644
index 0000000..357a4f2
--- /dev/null
+++ b/scripts/key_split.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python3
+"""绿幕抠图+按列空隙切成单个姿势:python3 key_split.py 图.png --out 前缀 [--pick 0](只要第几个)"""
+import argparse
+import numpy as np
+from PIL import Image
+ap = argparse.ArgumentParser(); ap.add_argument('src'); ap.add_argument('--out', required=True); ap.add_argument('--pick', type=int); ap.add_argument('--white', action='store_true', help='白底线稿:不抠,只裁')
+a = ap.parse_args()
+im = np.asarray(Image.open(a.src).convert('RGB')).astype(np.float32); r, g, b = im[..., 0], im[..., 1], im[..., 2]
+if a.white:
+ alpha = 1 - np.clip((np.minimum(np.minimum(r, g), b) - 225) / 25, 0, 1); alpha = np.maximum(alpha, (np.max(im, 2) - np.min(im, 2) > 40))
+ rgba = np.dstack([r, g, b, np.full_like(r, 255)])
+ mask = alpha > 0.1
+else:
+ spill = g - np.maximum(r, b); al = 1 - np.clip((spill - 30) / 70, 0, 1)
+ g2 = np.where(spill > 0, np.minimum(g, np.maximum(r, b) + 0.25 * np.clip(spill, 0, 30)), g)
+ rgba = np.dstack([r, g2, b, al * 255]); mask = al > 0.05
+cols = mask.any(0); runs = []; x = 0; W = len(cols)
+while x < W:
+ if cols[x]:
+ x0 = x
+ while x < W and cols[x: x + 12].any(): x += 1
+ if x - x0 > 40: runs.append((x0, x))
+ x += 1
+for k, (x0, x1) in enumerate(runs):
+ if a.pick is not None and k != a.pick: continue
+ rows = mask[:, x0:x1].any(1); ys = np.where(rows)[0]; y0, y1 = ys.min(), ys.max() + 1
+ out = rgba[y0:y1, x0:x1].clip(0, 255).astype(np.uint8)
+ Image.fromarray(out, 'RGBA' if out.shape[2] == 4 else 'RGB').save(f'{a.out}{"" if a.pick is not None else "_" + str(k)}.png'); print(k, x0, x1, y0, y1)
diff --git a/scripts/qa.py b/scripts/qa.py
new file mode 100644
index 0000000..36131e7
--- /dev/null
+++ b/scripts/qa.py
@@ -0,0 +1,300 @@
+#!/usr/bin/env python3
+# /// script
+# dependencies = ["playwright", "numpy", "pillow"]
+# ///
+"""一条命令验收一个代码动画工程:稳定性、效率、动感、流畅,出数字+拼图。交付前必跑,数字写进交付说明。
+
+ uv run qa.py --project <代码工程目录> [--film gallery] [--ids 01_cave,09_postimp] [--fps 30] [--out <目录>]
+ uv run qa.py --spec <片段 clip.json> [--out <目录>] # 参数化片段(口播管线的动画段):整段当一段量,竖屏也行;不量转场
+
+逐段(eras.js 的每个 id)做四件事:
+ 1. 稳定:场景加载失败直接退出(引擎 __bootErrors);同一时刻冷渲+热渲两次逐像素比对(确定性)。
+ 2. 效率:每帧耗时——计时包含一次 getImageData(1×1) 强制 GPU 画完(只量 JS 同步时间会报出假的 1ms;迁移测试 B 踩过)。
+ 3. 动感:避开转场后 0.35s 镜头冲击,在本段静止区按 --fps 连续取帧,报运动面积(相邻帧变化 >12 的像素占比)均值,
+ 和「静止帧对」比例(相邻帧几乎不变 <0.05% —— 迁移测试 A 发现只看首尾差会漏掉一卡一卡)。
+ 4. 流畅:相邻帧差的峰值 / 中位数。>6 且峰值 >3% 记为「跳变」(整屏笔触按 8fps 重洗、某帧穿帮、闪烁都会冒出来)。
+另做「转场冒烟」:每个带转场的段在 p=.25/.5/.75 渲整帧(renderFrame),报错计入页面报错——段内取帧用 renderSolo,
+转场代码一次都不会执行,转场崩了也能全绿(全风格样片移植时踩到)。
+判据是经验阈值不是规则:运动 0.5–8% 之间多数段好看;静止帧对 >40% 读作卡;跳变 >0 先看帧再判断(有意的节拍闪不算错)。
+ 5. 框景:
+ 从页面加载起就记下每次 fillText/strokeText 在屏幕上的外框,取帧时持续 ≥0.3s 才报——
+ 半截字(字被画面边缘切掉一部分)、叠字(两串不同的字互相压住)、进字幕带(字落进字幕带,烧录字幕会盖住);
+ 另报「近空白」(整屏几乎没有内容:满屏闪白、黑场)。都是「去看这一帧」的线索,不是错误,不让 qa 失败。
+ 外框跟着画布走:画进离屏缓冲/精灵缓存(包括启动时预画的缓存)再 drawImage 上来的字,位图推镜后的字,都量得到。
+ 字幕带:整片默认 y>920/1080(--sub-band 改,0 关掉);--spec 片段读 spec 的 safe.bottom,没有就不查。
+ 盲区:①取帧从每段 max(--skip, 转场时长) 开始,段首和转场里的问题看不到;「段首空板」上只要留着笔或手(占比 >0.3%)也不算近空白。
+ ②画在 clip 里的字(滚动数字、按笔顺揭开)只查半截字和字幕带,不判叠字。③被非文字物件(照片、回形针、讲解员、后弹出的卡片)挡住的字查不到,
+ 两串都被盖住时还会误报叠字。④图形(火焰、飞船)进字幕带查不到,浅底风格用成片层的 scripts/subzone_gate.py。
+ ⑤逐字手写的字按单字报,去看帧才能定位;有意压在字幕带或画外的装饰大字(如 y5 的巨型水印数字)会被报出来,看过就放。
+
+产物:<out>/qa.json(全部数字)、<out>/qa.md(表)、<out>/<id>.jpg(4 帧拼图+运动热图)。
+"""
+import argparse, base64, functools, http.server, io, json, socketserver, threading, urllib.parse
+from pathlib import Path
+import numpy as np
+from PIL import Image, ImageDraw
+from playwright.sync_api import sync_playwright
+
+ap = argparse.ArgumentParser(description=__doc__.splitlines()[0])
+ap.add_argument('--project'); ap.add_argument('--spec', help='参数化片段 spec(走 clip.html,和 render.py --spec 同一套)'); ap.add_argument('--ids'); ap.add_argument('--fps', type=float, default=30)
+ap.add_argument('--out'); ap.add_argument('--film', default='', help='片子名:读 eras_<名>.js'); ap.add_argument('--skip', type=float, default=0.35, help='每段开头跳过的秒数(镜头冲击)')
+ap.add_argument('--sub-band', type=float, default=None, help='字幕带上沿(占画高比例);整片默认 0.852(920/1080),--spec 默认读 safe.bottom;写 0 关掉「进字幕带」检查')
+a = ap.parse_args()
+if not (a.project or a.spec): ap.error('--project 或 --spec 二选一')
+spec, ALLOWED = None, set()
+if a.spec: # 和 render.py 同一套:本地图片只服务 spec 里点名的文件
+ sp = Path(a.spec).resolve(); spec = json.loads(sp.read_text())
+ def ref(v):
+ if not v or v.startswith(('data:', 'http:', 'https:')): return v
+ f = (sp.parent / v).resolve()
+ if not f.exists(): raise SystemExit(f'spec 里的图片不存在:{v}')
+ ALLOWED.add(str(f)); return '/__file__/' + urllib.parse.quote(str(f))
+ for q in spec.get('cues', []):
+ if q.get('image'): q['image'] = ref(q['image'])
+ if (spec.get('data') or {}).get('image'): spec['data']['image'] = ref(spec['data']['image'])
+root = Path(a.project).resolve() if a.project else Path(__file__).resolve().parent / 'engine'
+out = Path(a.out) if a.out else (Path(a.spec).resolve().parent / 'qa' if a.spec else root.parent / 'qa'); out.mkdir(parents=True, exist_ok=True)
+VW, VH = (spec.get('width', 1920), spec.get('height', 1080)) if spec else (1920, 1080)
+if a.sub_band is None: # 片段给管线用:字幕让位写在 spec 的 safe.bottom 里,没写就当没有烧录字幕
+ sb = ((spec or {}).get('safe') or {}).get('bottom', 0) if spec else None
+ a.sub_band = 0.852 if sb is None else (1 - sb / VH if sb else 0)
+
+class Q(http.server.SimpleHTTPRequestHandler):
+ def log_message(self, *x): pass
+ def translate_path(self, path):
+ if path.startswith('/__file__/'):
+ f = urllib.parse.unquote(path[len('/__file__/'):].split('?')[0])
+ return f if f in ALLOWED else '/nonexistent'
+ return super().translate_path(path)
+srv = socketserver.TCPServer(('127.0.0.1', 0), functools.partial(Q, directory=str(root))); port = srv.server_address[1]
+threading.Thread(target=srv.serve_forever, daemon=True).start()
+
+# 框景检查:包一层 fillText/strokeText,记下画在「整屏大小的画布」上的字的屏幕外框(经过当前变换)
+TEXT_HOOK = '''(() => {
+ // 字的外框记在「它被画上的那张画布」上;这张画布被 drawImage 贴到别处时,外框跟着变换过去。
+ // 这样先画进离屏缓冲再整体推镜(讲解员片的位图推镜)、画进精灵缓存再贴上桌(Vox 的剪纸)的字也量得到。
+ const P = CanvasRenderingContext2D.prototype;
+ const sv = P.save, rs = P.restore, cl = P.clip, di = P.drawImage, cr = P.clearRect, fr = P.fillRect;
+ // 记住「当前有没有 clip」:滚动数字、按笔顺揭开的字都画在 clip 里,外框比看得见的大,不拿来判叠字
+ P.save = function () { (this.__cs || (this.__cs = [])).push(!!this.__clip); return sv.apply(this, arguments); };
+ P.restore = function () { if (this.__cs && this.__cs.length) this.__clip = this.__cs.pop(); return rs.apply(this, arguments); };
+ P.clip = function () { this.__clip = true; return cl.apply(this, arguments); };
+ // 「整张画布被盖掉」时清空这张画布的外框记录,不然缓存画布重画后,上一段的字还留在记录里(白板 s03 的「火箭」误报到 s04)
+ const full = (ctx, x, y, w, h) => { // 这个矩形经过当前变换后是否盖满整张画布(只认无旋转的变换)
+ const T = ctx.getTransform(); if (T.b !== 0 || T.c !== 0) return false;
+ const xs = [T.a * x + T.e, T.a * (x + w) + T.e], ys = [T.d * y + T.f, T.d * (y + h) + T.f];
+ return Math.min(...xs) <= 0 && Math.min(...ys) <= 0 && Math.max(...xs) >= ctx.canvas.width && Math.max(...ys) >= ctx.canvas.height;
+ };
+ const opaque = ctx => { const f = ctx.fillStyle; if (typeof f !== 'string') return false; const m = f.match(/^(rgba|hsla)\\(([^)]*)\\)/); return !m || +m[2].split(/[ ,\\/]+/).filter(Boolean)[3] >= 1; };
+ P.clearRect = function (x, y, w, h) { if (full(this, x, y, w, h)) this.canvas.__tb = []; return cr.apply(this, arguments); };
+ P.fillRect = function (x, y, w, h) { if (this.globalAlpha >= 1 && (this.globalCompositeOperation === 'copy' || (this.globalCompositeOperation === 'source-over' && opaque(this))) && full(this, x, y, w, h)) this.canvas.__tb = []; return fr.apply(this, arguments); };
+ if (P.reset) { const rz = P.reset; P.reset = function () { this.canvas.__tb = []; this.__cs = []; this.__clip = false; return rz.apply(this, arguments); }; }
+ const pid = P.putImageData;
+ P.putImageData = function (im, x, y) { if (x <= 0 && y <= 0 && x + im.width >= this.canvas.width && y + im.height >= this.canvas.height) this.canvas.__tb = []; return pid.apply(this, arguments); };
+ for (const k of ['width', 'height']) { // 改画布尺寸会清空画布,外框也清掉
+ const d = Object.getOwnPropertyDescriptor(HTMLCanvasElement.prototype, k);
+ Object.defineProperty(HTMLCanvasElement.prototype, k, { get: d.get, set(v) { this.__tb = []; d.set.call(this, v); }, configurable: true });
+ }
+ const push = (ctx, rec) => { const L = ctx.canvas.__tb || (ctx.canvas.__tb = []); L.push(rec); if (L.length > 6000) L.splice(0, 3000); }; // 只局部清、反复重画的画布会越记越多,留最近的
+ for (const fn of ['fillText', 'strokeText']) {
+ const orig = P[fn];
+ P[fn] = function (text, x, y, maxW) {
+ if (this.globalAlpha > 0.15 && String(text).trim()) { // 从加载起一直记:启动时预画进缓存的字(Vox 的 prewarm)也要有外框
+ const m = this.measureText(text), T = this.getTransform();
+ let x0 = x - m.actualBoundingBoxLeft, x1 = x + m.actualBoundingBoxRight;
+ if (maxW && x1 - x0 > maxW) x1 = x0 + maxW;
+ const y0 = y - m.actualBoundingBoxAscent, y1 = y + m.actualBoundingBoxDescent;
+ const xs = [], ys = [];
+ for (const [px, py] of [[x0, y0], [x1, y0], [x0, y1], [x1, y1]]) { xs.push(T.a * px + T.c * py + T.e); ys.push(T.b * px + T.d * py + T.f); }
+ push(this, [String(text).slice(0, 24), xs, ys, !!this.__clip]);
+ }
+ return orig.apply(this, arguments);
+ };
+ }
+ P.drawImage = function (src, ...a) {
+ if (this.globalCompositeOperation === 'copy') this.canvas.__tb = [];
+ const L = src && src.__tb;
+ if (L && L.length && src !== this.canvas && this.globalAlpha > 0.5) { // ≤0.5 多半是运动残影/拖尾叠层,不传(白板甩镜残影会叠出满屏假叠字)
+ let sx = 0, sy = 0, sw = src.width, sh = src.height, dx, dy, dw = sw, dh = sh;
+ if (a.length === 2) [dx, dy] = a; else if (a.length === 4) [dx, dy, dw, dh] = a; else [sx, sy, sw, sh, dx, dy, dw, dh] = a;
+ const T = this.getTransform(), kx = dw / sw, ky = dh / sh, clip = !!this.__clip || a.length === 8;
+ for (const [txt, xs, ys, c0] of L) {
+ if (Math.max(...xs) < sx || Math.min(...xs) > sx + sw || Math.max(...ys) < sy || Math.min(...ys) > sy + sh) continue;
+ const X = [], Y = [];
+ for (let k = 0; k < 4; k++) { const u = dx + (xs[k] - sx) * kx, v = dy + (ys[k] - sy) * ky; X.push(T.a * u + T.c * v + T.e); Y.push(T.b * u + T.d * v + T.f); }
+ push(this, [txt, X, Y, c0 || clip]);
+ }
+ }
+ return di.call(this, src, ...a);
+ };
+})();'''
+GRAB = '''async ([id, lt, full]) => {
+ window.__tb = true; window.__canvas.__tb = [];
+ const s = performance.now();
+ if (full) { await window.prepare(lt); window.renderFrame(lt); } else window.renderSolo(id, lt);
+ window.__canvas.getContext('2d').getImageData(0, 0, 1, 1); // 强制 GPU 画完再停表
+ const ms = performance.now() - s;
+ const M = window.__canvas, tb = (M.__tb || []).map(([t, xs, ys, c]) => [t, xs.map(v => v / M.width), ys.map(v => v / M.height), c]); window.__tb = null;
+ return [ms, window.__canvas.toDataURL('image/png').split(',')[1], tb];
+}'''
+
+def frame_issues(tb, band):
+ """一帧里的框景问题:[(类别, 文字)]。坐标都是占画面的比例。"""
+ out, vis = [], []
+ for txt, cxs, cys, clipped in tb:
+ x0, y0, x1, y1 = min(cxs), min(cys), max(cxs), max(cys)
+ ang = float(np.arctan2((cys[1] - cys[0]) * VH, (cxs[1] - cxs[0]) * VW))
+ w, h = x1 - x0, y1 - y0
+ if w <= 0 or h <= 0 or h < 0.008: continue # 太小的字(<9px)不管
+ ix0, iy0, ix1, iy1 = max(x0, 0), max(y0, 0), min(x1, 1), min(y1, 1)
+ if ix1 <= ix0 or iy1 <= iy0: continue # 整个在画外:镜头没拍到,不算
+ frac = (ix1 - ix0) * (iy1 - iy0) / (w * h)
+ if frac < 0.9 and frac > 0.1: out.append(('半截字', txt))
+ if band and iy1 > band + 0.004 and frac > 0.1: out.append(('进字幕带', txt))
+ if not clipped: vis.append((txt, ang, cxs, cys))
+ def box(v, ang): # 转到 ang 的坐标系里取外框:斜放标签的两行字不会因外接框变大而互相「重叠」
+ c, s_ = np.cos(-ang), np.sin(-ang)
+ u = [x * c - y * s_ * VH / VW for x, y in zip(v[2], v[3])]; w = [x * s_ * VW / VH + y * c for x, y in zip(v[2], v[3])]
+ return min(u), min(w), max(u), max(w)
+ for i in range(len(vis)):
+ for j in range(i + 1, len(vis)):
+ a, b = vis[i], vis[j]
+ if a[0] == b[0]: continue # 同一串字画两遍(描边+填色、投影)
+ same = abs(a[1] - b[1]) < 0.02; ang = a[1] if same else 0.0
+ A, B = box(a, ang), box(b, ang)
+ if not same: # 角度不同(手写字逐字抖动):外接框会胖一圈,各自内缩 12% 再比
+ A, B = [(r[0] + (r[2] - r[0]) * .12, r[1] + (r[3] - r[1]) * .12, r[2] - (r[2] - r[0]) * .12, r[3] - (r[3] - r[1]) * .12) for r in (A, B)]
+ ow = min(A[2], B[2]) - max(A[0], B[0]); oh = min(A[3], B[3]) - max(A[1], B[1])
+ if ow <= 0 or oh <= 0: continue
+ small = min((A[2] - A[0]) * (A[3] - A[1]), (B[2] - B[0]) * (B[3] - B[1]))
+ if ow * oh / small > 0.3: out.append(('叠字', a[0] + '|' + b[0]))
+ return out
+
+def persistent(ts, per_frame, min_s=0.3):
+ """同一个问题连续出现 ≥min_s 秒才报(镜头摇过去的那几帧半截字是正常的)。"""
+ runs, open_ = [], {}
+ for k, t in enumerate(ts):
+ cur = set(per_frame[k])
+ for key in list(open_):
+ if key not in cur:
+ t0, t1 = open_.pop(key)
+ if t1 - t0 >= min_s: runs.append((key, t0, t1))
+ for key in cur:
+ if key in open_: open_[key] = (open_[key][0], t)
+ else: open_[key] = (t, t)
+ runs += [(key, t0, t1) for key, (t0, t1) in open_.items() if t1 - t0 >= min_s]
+ return sorted(runs, key=lambda r: r[1])
+
+def merge_runs(runs):
+ """逐字打出来的字会一字一条:同类、时间相交的并成一条,字连起来。"""
+ out = []
+ for (kind, txt), t0, t1 in sorted(runs, key=lambda r: (r[0][0], r[1])):
+ if out and out[-1][0] == kind and t0 <= out[-1][3] + 0.05:
+ o = out[-1]; o[3] = max(o[3], t1)
+ if txt and txt not in o[1].split('、') and len(o[1]) < 60: o[1] = (o[1] + '、' + txt).strip('、')
+ else: out.append([kind, txt, t0, t1])
+ return sorted(out, key=lambda r: r[2])
+
+def near_blank(f):
+ """和画面主色差 >24 的像素占比 <0.3% 读作「几乎没有内容」。"""
+ med = np.median(f.reshape(-1, 3), axis=0)
+ return float((np.abs(f - med).max(axis=2) > 24).mean()) < 0.003
+def img(b64, w=480): return np.asarray(Image.open(io.BytesIO(base64.b64decode(b64))).convert('RGB').resize((w, round(w * VH / VW)))).astype(np.int16) # 按画幅缩,竖屏不压扁
+
+report = {'project': str(root), 'segments': []}
+errors = []
+with sync_playwright() as p:
+ br = p.chromium.launch(args=['--enable-gpu-rasterization', '--ignore-gpu-blocklist'])
+ pg = br.new_page(viewport={'width': VW, 'height': VH})
+ pg.on('pageerror', lambda e: errors.append(str(e)))
+ pg.on('console', lambda m: errors.append('console.error: ' + m.text) if m.type == 'error' else None) # 缺字形等由 console.error 报出
+ pg.add_init_script(TEXT_HOOK)
+ if spec:
+ pg.add_init_script('window.CLIP_SPEC = ' + json.dumps(spec, ensure_ascii=False) + ';')
+ pg.goto(f'http://127.0.0.1:{port}/clip.html?render=1')
+ else:
+ pg.goto(f'http://127.0.0.1:{port}/index.html?render=1' + (f'&film={a.film}' if a.film else ''))
+ pg.wait_for_function('window.__ready === true || !!window.__bootFailed', timeout=180000)
+ bf = pg.evaluate('window.__bootFailed || null')
+ if bf: raise SystemExit('❌ 场景加载失败:\n' + bf)
+ segs = [{'id': Path(a.spec).resolve().parent.name, 't0': 0, 't1': spec['duration'], 'tr': 0}] if spec else \
+ pg.evaluate('ERAS.map(e => ({id: e.id, t0: e.t0, t1: Math.min(e.t1, window.__total), tr: e.transition ? e.transition.dur + (e.transition.delay || 0) : 0}))')
+ want = set(a.ids.split(',')) if a.ids else None
+ for s in segs:
+ if want and s['id'] not in want: continue
+ dur = s['t1'] - s['t0']; lt0 = max(a.skip, s['tr']) if s['t0'] > 0 else 0.0
+ lt1 = max(lt0 + 0.2, dur - 0.02)
+ n = max(4, int((lt1 - lt0) * a.fps))
+ ts = [lt0 + (lt1 - lt0) * i / (n - 1) for i in range(n)]
+ full = bool(spec) # 片段没有 renderSolo,整帧渲
+ cold_ms, cold, _ = pg.evaluate(GRAB, [s['id'], ts[-1], full])
+ frames, ms, tbs = [], [], []
+ for t in ts:
+ m, b64, tb = pg.evaluate(GRAB, [s['id'], t, full]); ms.append(m); frames.append(img(b64)); tbs.append(tb or [])
+ _, again, _ = pg.evaluate(GRAB, [s['id'], ts[-1], full])
+ det = int(np.abs(img(again) - frames[-1]).max()); det_cold = int(np.abs(img(cold) - frames[-1]).max())
+ diffs = np.array([(np.abs(frames[i + 1] - frames[i]).max(axis=2) > 12).mean() * 100 for i in range(len(frames) - 1)])
+ med = float(np.median(diffs)) if len(diffs) else 0
+ if spec: # 片段多是「动一下、定住」:全段中位数≈0,连续的推镜/滑入会整串被记成跳变。片段只认孤立的跳:比前后各 3 对的中位数大 6 倍
+ loc = lambda i: float(np.median(np.r_[diffs[max(0, i - 3):i], diffs[i + 1:i + 4]])) if len(diffs) > 1 else 0
+ spikes = [round(ts[i + 1], 3) for i, d in enumerate(diffs) if d > 3 and d > 6 * max(loc(i), 0.05)]
+ else:
+ spikes = [round(ts[i + 1], 3) for i, d in enumerate(diffs) if d > 3 and d > 6 * max(med, 0.05)]
+ still = float((diffs < 0.05).mean() * 100)
+ heat = np.zeros(frames[0].shape[:2]); [heat.__iadd__((np.abs(frames[i + 1] - frames[i]).max(axis=2) > 12)) for i in range(len(frames) - 1)]
+ rec = {'id': s['id'], 'window_lt': [round(lt0, 3), round(lt1, 3)], 'frames': n,
+ 'ms_mean': round(float(np.mean(ms)), 1), 'ms_max': round(float(np.max(ms)), 1), 'ms_cold': round(cold_ms, 1),
+ 'deterministic': det == 0 and det_cold == 0, 'det_maxdiff': max(det, det_cold),
+ 'motion_pct': round(float(diffs.mean()), 2), 'motion_max': round(float(diffs.max()), 2), 'still_pairs_pct': round(still, 1),
+ 'spike_ratio': round(float(diffs.max() / max(med, 0.05)), 1), 'spikes_at_lt': spikes}
+ frame_runs = merge_runs(persistent(ts, [frame_issues(tb, a.sub_band) for tb in tbs]) +
+ persistent(ts, [[('近空白', '')] if near_blank(f) else [] for f in frames]))
+ rec['framing'] = [{'kind': k, 'text': txt, 'lt': [round(t0, 2), round(t1, 2)], 't': [round(s['t0'] + t0, 2), round(s['t0'] + t1, 2)]} for k, txt, t0, t1 in frame_runs]
+ rec['text_tracked'] = sum(map(len, tbs))
+ report['segments'].append(rec)
+ # 拼图:4 帧 + 热图
+ pick = [frames[int(k)] for k in np.linspace(0, n - 1, 4)]
+ H_, W_ = frames[0].shape[:2]; S = Image.new('RGB', (W_ * 5, H_ + 20), 'white'); dr = ImageDraw.Draw(S)
+ for k, f in enumerate(pick): S.paste(Image.fromarray(f.astype(np.uint8)), (k * W_, 20))
+ hm = np.clip(heat / max(1, heat.max()) * 255, 0, 255).astype(np.uint8)
+ base = Image.fromarray(pick[0].astype(np.uint8)).convert('L').convert('RGB'); red = np.zeros((H_, W_, 3), np.uint8); red[..., 0] = hm
+ S.paste(Image.blend(base, Image.fromarray(red), 0.6), (4 * W_, 20))
+ dr.text((4, 4), f"{s['id']} 运动 {rec['motion_pct']}% 静止帧对 {rec['still_pairs_pct']}% 跳变 {len(spikes)} {rec['ms_mean']}/{rec['ms_max']}ms 确定性 {'✓' if rec['deterministic'] else '✗'}", fill='black')
+ S.save(out / f"{s['id']}.jpg", quality=85)
+ print(f"{s['id']:<18} 运动 {rec['motion_pct']:>5}% 静止帧对 {rec['still_pairs_pct']:>5}% 跳变 {len(spikes)} {rec['ms_mean']:>6}/{rec['ms_max']:>6}ms 确定性 {'✓' if rec['deterministic'] else '✗ ' + str(rec['det_maxdiff'])} 框景 {len(rec['framing'])}")
+ for r in rec['framing']: print(f" {r['kind']} {r['t'][0]:.2f}–{r['t'][1]:.2f}s {r['text']}")
+ # 转场冒烟:只查能不能渲、耗时多少,不参与运动/流畅判据
+ report['transitions'] = []
+ for s in ([] if spec else pg.evaluate('ERAS.map(e => ({id: e.id, t0: e.t0, tr: e.transition ? {type: e.transition.type, dur: e.transition.dur, delay: e.transition.delay || 0} : null}))')):
+ if not s['tr'] or (want and s['id'] not in want): continue
+ ms_tr = []
+ for p in (0.25, 0.5, 0.75):
+ t = s['t0'] + s['tr']['delay'] + s['tr']['dur'] * p
+ try:
+ m, *_ = pg.evaluate(GRAB, [s['id'], t, True]); ms_tr.append(m)
+ except Exception as ex:
+ errors.append(f"转场 {s['tr']['type']}(进入 {s['id']})p={p}: {str(ex).splitlines()[0]}")
+ report['transitions'].append({'id': s['id'], 'type': s['tr']['type'], 'ms_max': round(max(ms_tr), 1) if ms_tr else None})
+ if report['transitions']: print('转场冒烟', len(report['transitions']), '个,最慢', max((r['ms_max'] or 0, r['type']) for r in report['transitions']))
+ br.close()
+srv.shutdown()
+report['page_errors'] = errors
+json.dump(report, open(out / 'qa.json', 'w'), ensure_ascii=False, indent=1)
+rows = ['| 段 | 运动% | 静止帧对% | 跳变 | 均/峰 ms | 冷启动 ms | 确定性 | 框景 |', '|---|---|---|---|---|---|---|---|']
+for r in report['segments']:
+ rows.append(f"| {r['id']} | {r['motion_pct']} | {r['still_pairs_pct']} | {len(r['spikes_at_lt'])} {r['spikes_at_lt'][:3]} | {r['ms_mean']}/{r['ms_max']} | {r['ms_cold']} | {'✓' if r['deterministic'] else '✗'} | {len(r['framing'])} |")
+fr = [(r['id'], x) for r in report['segments'] for x in r['framing']]
+if fr: rows += ['', '框景线索(全片秒,持续 ≥0.3s;去看这一帧再判断):'] + [f"- {x['kind']} {x['t'][0]:.2f}–{x['t'][1]:.2f}s({i}){x['text']}" for i, x in fr]
+if report.get('transitions'): rows += ['', '转场冒烟(整帧,峰值 ms):' + ','.join(f"{r['type']}→{r['id']} {r['ms_max']}" for r in report['transitions'])]
+(out / 'qa.md').write_text('\n'.join(rows) + ('\n\n页面报错:\n' + '\n'.join(errors) if errors else '') + '\n')
+print('->', out / 'qa.md')
+if not spec and root != Path(__file__).resolve().parent / 'engine': # 回流兜底(11 号第一节):qa 是交付前必跑的,在这里提醒,不让 qa 失败
+ import re, time
+ draft = next((d / '经验回流-草稿.md' for d in (root.parent, root.parent.parent) if (d / '经验回流-草稿.md').exists()), None)
+ if not draft: print(f'回流提醒:项目根({root.parent.name})还没有 经验回流-草稿.md。每轮改完追加几条,格式见 skill 的 references/11-进化协议.md 第四节。')
+ else:
+ txt = draft.read_text(); age = (time.time() - draft.stat().st_mtime) / 60
+ tail = txt.rsplit('> 水位线', 1)[-1] if '> 水位线' in txt else txt # 水位线以下=还没写回 skill 的
+ n = len(re.findall(r'^### \[', tail, re.M))
+ print(f'回流提醒:经验回流-草稿.md 最近一次写入在 {age:.0f} 分钟前;还没写回 skill 的有 {n} 条(收活时按 11 号归宿表整合,整合完在草稿末尾加一行「> 水位线 <时间>」)。')
+if errors: raise SystemExit('❌ 页面运行时报错 %d 条,见 qa.md' % len(errors))
diff --git a/scripts/subzone_gate.py b/scripts/subzone_gate.py
new file mode 100644
index 0000000..03add14
--- /dev/null
+++ b/scripts/subzone_gate.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python3
+"""字幕带门禁:扫「无字幕版」成片,字幕带里出现画面内容(字、描边、火箭、火焰)就报时间码。
+
+ python3 subzone_gate.py <无字幕版.mp4> [--band 920] [--fps 10] [--thresh 150]
+
+qa.py检查文字框;本脚本补充检查图形是否进入字幕带。
+数的是灰度 <95 的深色像素,只适合浅底干净的风格(白板、米白纸面、发布会浅色版)。
+纹理底(Vox 牛皮纸桌面)按字幕带主色差判断容易产生大量误报:这类风格靠 qa.py 的框景,
+或者像 Vox 版那样让文字 API 登记所属物件再查遮挡。
+阈值是那支片子的实测值(字幕带缩半成 960×80 后 >150 个像素),换风格先拿已知好/坏的两帧校一下。
+"""
+import argparse, subprocess, numpy as np
+ap = argparse.ArgumentParser(); ap.add_argument('video'); ap.add_argument('--band', type=int, default=920, help='字幕带上沿 y(1080 高)')
+ap.add_argument('--fps', type=float, default=10); ap.add_argument('--thresh', type=int, default=150)
+a = ap.parse_args()
+h = 1080 - a.band; W, H = 960, h // 2
+cmd = ['ffmpeg', '-v', 'error', '-i', a.video, '-vf', f'fps={a.fps},scale=1920:1080,crop=1920:{h}:0:{a.band},scale={W}:{H}', '-f', 'rawvideo', '-pix_fmt', 'gray', '-']
+raw = subprocess.run(cmd, capture_output=True, check=True).stdout
+fr = np.frombuffer(raw, np.uint8).reshape(-1, H, W)
+bad = []
+for i, f in enumerate(fr):
+ n = int((f < 95).sum())
+ if n > a.thresh: bad.append((i / a.fps, n))
+runs = []
+for t, n in bad:
+ if runs and t - runs[-1][1] <= 1.5 / a.fps: runs[-1][1] = t; runs[-1][2] = max(runs[-1][2], n)
+ else: runs.append([t, t, n])
+print(f'{len(fr)} 帧,命中 {len(bad)} 帧')
+for t0, t1, n in runs: print(f' {t0:7.2f}–{t1:7.2f}s 最多 {n} 个像素')