艺术动画skill:35种艺术风格、9种解说语法,用代码让画动起来。
JavaScript agent-skillsanimationclaude-codeclaude-code-skillsclaude-skillscodexexplainer-videogenerative-arthuashu-skillsmotion-graphicsskillsvideo
feat: 把认可过的做法做成引擎能力,改掉片段里的坏默认值(改动包B)
alchain723ba3c21a09
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 3b28181..92002fc 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -25,3 +25,4 @@- 2026-10-08 · P2/P3:增加现有图片与当前宿主工具桥接、需求计划/回执/透明背景/尺寸与SHA验收;旧配置保留,新增能力不自动授权;补充贡献与兼容性说明、CI及增量发布检查。三家安装重装通过,Codex在线验收通过,Claude/Kimi在线验收因账户条件待补。- 2026-10-09 · 换掉把模型往坏处带的默认值(只改文档与样例):SKILL.md 首屏加模型分档(开阔档/轨道档)、「五种做坏方式」、窄桥改成「动在事件上」的脉冲节奏并写明真实素材当主画面、示范不许原样进成片;各语法卡删掉「静止就加慢推」药方、补「起手必查」,t2 的光斑、毛玻璃、渐变字降为可选;风格 INDEX 拆成材料层/时代标本,写明 35 张样片同构图是速通机制;固定场景骨架限定为速通/穿越类;8 份样例 spec 改成画面事件开场、每条字 ≤14。+- 2026-10-10 · 把认可过的做法做成引擎能力(改动包B,改代码):新增 `CAM.track` 脉冲镜头(快推 0.28s/同倍率横移 0.30s/整帧砸入 0.17s/震镜/硬切)与 `MO.PULSE/slamK/slam/pulse`;新增 `lib/media.js`(`MD.cover` 满幅+焦点推近、`MD.print` 冲印件、`MD.label` 黑底撕边标签、`MD.frameAt` 帧序列),素材缺失一律报错;片段 spec 认 `cues[].frames` 录像帧与 y4 角色帧库(`engine/spec_assets.py`);t2 截图默认满幅+highlight 快推+两屏之间横移,玻璃卡改为 `data.frame:"glass"` 可选;y1 中心物由 `data.center_style`/`data.image` 指定,默认按名字生成中性样式、不再是橙色带轨道星球;y2 照片改冲印件、占画面八九成;y4 默认角色换成中性造型(`data.character`:neutral/bun/author/造型对象/帧库目录),作者形象需显式指定;去掉 y1/y2/y4/y5/t2 内置的匀速慢推、手持微漂、呼吸、漂浮;引擎和转场按当前画布算,`render.py --film --width 1080 --height 1920` 出竖屏整片;引擎视频帧改为等比铺满、缺帧拒绝渲染;新增样例 `examples/t2_fullbleed_pulse.json`(两张真实终端截图)。横屏示范片、原片与全风格样片逐像素不变。diff --git a/SKILL.md b/SKILL.mdindex 673369f..21605f8 100644--- a/SKILL.md+++ b/SKILL.md@@ -55,8 +55,8 @@ description: "艺术与视频动画:拆解复刻动画;代码画35种艺术## 窄桥:照字面做-- **动在事件上。** 解说类片子用脉冲节奏:停住 → 快推、横移或砸入 → 停住。快推 0.28 秒推近 18–32% 后停;同倍率横移 0.30 秒;砸入 0.17 秒(1.55→0.94→1.0);停多久按口播。不用匀速慢推、全员呼吸循环来凑运动。艺术风格画面仍要「画一直是活的」:每幕一个主动作+2 个母题循环,自检量帧差(避开转场后 0.35s 的镜头冲击)。-- **有真实素材就让它当主画面。** 截图、照片、录像、原文、产品本身的产出,满幅放,代码负责解释、标注和运镜。「场景与风格用代码画」只适用于艺术风格画面。人用 AI 生帧、代码合成,见`references/10-角色.md`;几何角色可以用代码画。+- **动在事件上。** 解说类片子用脉冲节奏:停住 → 快推、横移或砸入 → 停住。快推 0.28 秒推近 18–32% 后停;同倍率横移 0.30 秒;砸入 0.17 秒(1.55→0.94→1.0);停多久按口播。不用匀速慢推、全员呼吸循环来凑运动。引擎现成:`CAM.track`(镜头动作表)、`MO.slam`(砸入)。艺术风格画面仍要「画一直是活的」:每幕一个主动作+2 个母题循环,自检量帧差(避开转场后 0.35s 的镜头冲击)。+- **有真实素材就让它当主画面。** 截图、照片、录像、原文、产品本身的产出,满幅放,代码负责解释、标注和运镜(`MD.cover` 满幅+焦点推近、`MD.print` 冲印件、`MD.label` 黑底撕边标签;缺图直接报错)。「场景与风格用代码画」只适用于艺术风格画面。人用 AI 生帧、代码合成,见`references/10-角色.md`;几何角色可以用代码画。- **示范只用来理解做法。** 示范片、样例 spec、风格样片里的构图、角色和素材,不许原样放进成片。- **复刻是学机制,不是逐像素。** 提取场景、运动与转场规律,再用于新题材。- **三方向硬门**:新的角色诠释或风格方向,先出三个给用户挑,三个方向的构图要不同,不能只换调色。指定了风格也不豁免。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"index 0b9506a..17c2959 100644--- "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"@@ -63,12 +63,12 @@ uv run scripts/qa.py --project scripts/engine --film demos/y1_kurzgesagt --out <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. **动在事件上。** 解说类片子的运动是脉冲:停住 → 快推、横移或砸入 → 停住。快推 0.28 秒推近 18–32% 后停;同倍率横移 0.30 秒(同一面「墙」上从一件证据移到下一件);砸入 0.17 秒(1.55→0.94→1.0);停多久按口播。不用匀速慢推、全员浮动呼吸来凑运动:同一份分镜、同一批素材,每镜匀速推近 7.5% 的版本被判「像在放 PPT」,换成停住 → 0.28 秒快推 → 停住之后被认可,完全静止的帧反而从 16% 升到 72%。环境层(Kurzgesagt 的星闪、粒子)可以一直轻轻动;storytime 七成帧完全静止,生命在快切+定住。艺术风格速通是另一回事,画要一直活(见 04 号)。(y1 ③、⑧-1;y4 ⑧-1;t2 ③)+7. **动在事件上。** 解说类片子的运动是脉冲:停住 → 快推、横移或砸入 → 停住。快推 0.28 秒推近 18–32% 后停;同倍率横移 0.30 秒(同一面「墙」上从一件证据移到下一件);砸入 0.17 秒(1.55→0.94→1.0);停多久按口播。引擎里现成:`CAM.track`(镜头动作表)、`MO.slam`(元素砸入),时长常量在 `MO.PULSE`;8 个参数化片段都已按这个节奏动,没有内置的匀速慢推和呼吸。不用匀速慢推、全员浮动呼吸来凑运动:同一份分镜、同一批素材,每镜匀速推近 7.5% 的版本被判「像在放 PPT」,换成停住 → 0.28 秒快推 → 停住之后被认可,完全静止的帧反而从 16% 升到 72%。环境层(Kurzgesagt 的星闪、粒子)可以一直轻轻动;storytime 七成帧完全静止,生命在快切+定住。艺术风格速通是另一回事,画要一直活(见 04 号)。(y1 ③、⑧-1;y4 ⑧-1;t2 ③)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;片段契约)+12. **真实素材当主画面,保持原样。** 有截图、照片、录像、原文就让它满幅或接近满幅,推近到要讲的那块,代码只做解释、标注和运镜(`MD.cover` 满幅+焦点+推近,`MD.print` 冲印件,`MD.label` 黑底撕边标签;参数化片段 t2 的截图卡、y2 的照片默认就是满幅或占画面八九成);截图等比放、不裁关键 UI;数据只改「怎么出现」不改「是多少」;柱一律从 0 起,轴不从 0 起要写明;虚构数据每一镜标「示意数据」,真实数据不许出现这个角标。(t3 ②、⑧-1;片段契约)---@@ -76,18 +76,19 @@ uv run scripts/qa.py --project scripts/engine --film demos/y1_kurzgesagt --out <| 文件 | 命名空间 | 有什么 ||---|---|---|-| `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`(手持微漂) |+| `motion.js` | `MO` | 脉冲节奏 `PULSE`(时长常量)/`slamK/slam`(砸入 1.55→0.94→1.0)/`pulse`(快推、横移的进度)、`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` 在 `util.js` |+| `camera.js` | `CAM` | `apply/with`、`toScreen/toWorld`、`zlerp`(对数缩放)、`coverZoom`、`anchor`、`pushTo`(推进某点、该点平滑移到中心或原地放大)、`at`(关键帧,沿路径平移)、**`track`(脉冲镜头:`punch` 快推 / `pan` 同倍率横移 / `to` 推到指定相机 / `slam` 整帧砸入 / `shake` 震镜 / `cut` 硬切,相机只由 t 算)**、`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` |+| `media.js` | `MD` | 真实素材当主体:`cover`(满幅铺开,焦点 `fx/fy`、推近 `z`、裁切 `crop`,`fit:'contain'` 整张不裁)、`toScreen`(素材上的点/框 → 画面坐标)、`focusFor/zoomFor`(推近到某一块要几倍)、`print`(冲印件/拍立得:白边、旧纸色、投影、胶带)、`label`(黑底撕边标签,12fps 打字)、`frameAt`(帧序列取帧)、`size`。素材缺失一律报错,不画空白帧 |+| `toon.js` | `TOON` | `flat`(双色分面)、`glow/vgrad/circle/ellipse`、`bean`(豆子角色,`char` 选造型:默认 `neutral`,另有 `bun`、`author`)与 `LOOKS/look`、`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 就是这么组织的)。+引擎相关的小改动:竖屏整片 `render.py --film <名> --width 1080 --height 1920`(或在 eras.js 写 `window.FILM_SIZE = [1080, 1920]`),引擎、转场、相机和各库按当前画布算,35 种艺术风格场景仍只按横屏画过;段的 `clip`(视频帧序列)默认等比铺满,写 `clipDraw(c, frame, lt, t)` 自己摆(推近、焦点、冲印件),帧或图片缺失直接报错、拒绝渲染;段可写 `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 的镜头穿越撞名)。@@ -112,10 +113,10 @@ uv run --with playwright python engine/render.py --spec clip.json --stills 0.5,2```- 时长严格等于 `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 里点名的文件。+- 宽高和 fps 从 spec 读,默认 1920×1080@30;竖屏写 `width: 1080, height: 1920`(或命令行 `--width 1080 --height 1920` 覆盖 spec),每种语法都有竖屏排版。+- spec 里的素材路径相对 spec 文件(也可以写绝对路径);render.py 只服务 spec 里点名的文件。认这些字段:`cues[].image`、`cues[].frames`(录像帧序列:一个目录或路径数组)、`data.image`、`data.character`(y4 帧库目录)。路径怎么解析见 `engine/spec_assets.py`。- 量这一段:`uv run qa.py --spec <clip.json>`(在 `scripts/` 下;整段当一段量确定性、运动、静止帧对、孤立跳变、耗时,竖屏按画幅缩)。-- 页面报错(语法文件出错、图片不存在)→ 非零退出,不出片。spec 里有字库没有的汉字只告警(会回退系统字体,换台机器会变样),常用字都在子集里。+- 页面报错(语法文件出错、图片或视频帧不存在)→ 非零退出,不出片。`qa.py --spec` 目前只认 `cues[].image` 和 `data.image`,用了 `frames` 或角色帧库的 spec 先用 render.py 渲、抽帧核。spec 里有字库没有的汉字只告警(会回退系统字体,换台机器会变样),常用字都在子集里。### spec@@ -139,6 +140,7 @@ uv run --with playwright python engine/render.py --spec clip.json --stills 0.5,2| `text` | 主文字:标题、要点、标签、气泡原文、插入镜头的大字。 || `sub` | 辅文字:t2 卡片说明、y5 辅句、y4 气泡里实际显示的短句、y4 插入镜头里他打的那一行。 || `image` | 图片路径,相对 spec 文件(也可写绝对路径、`data:`、`http(s):`)。文件不存在 → 拒绝渲染。 |+| `frames` / `fps` / `loop` | 录像帧序列(t2 的截图卡、y2 的照片认):一个目录(按文件名排序取 png/jpg/webp)或路径数组;从 at 起按 `fps`(默认 30)播,播完停在最后一帧,`loop: true` 循环。版式按第一帧定。缺帧 → 拒绝渲染。 || `data` | 这个 cue 自己的参数(`index`、`rect`、`icon`……),见各节。 || `dur` | 只有少数 kind 读:t1 的 title/point/equation/line,t3 的 bar/line/candle,y1 的 enter,y4 的 react/insert。其它 kind 写了也不读。 |@@ -182,13 +184,13 @@ spec 级 data:无。#### t2_keynote_ui(发布会界面:功能卡、截图卡、大数字)-spec 级 data:`eyebrow`(标题上方小字)、`title`、`subtitle`、`accent`(强调色,默认 `#3d6bff`)。+spec 级 data:`eyebrow`(标题上方小字)、`title`、`subtitle`、`accent`(强调色,默认 `#3d6bff`)、`frame`(截图卡的包装:默认 `"full"` 满幅;`"glass"` 是旧版毛玻璃卡,可选、慎用)。| kind | 字段 | 说明 | 示例 ||---|---|---|---|| `title` | `text`/`sub` 覆盖 data.title/subtitle | at 起从模糊里浮出。不当开场用,先上截图或数字 | `{"at":5,"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]}}` |+| `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`(卡上计数) | 有图(默认 `frame:"full"`):一屏一张,截图满幅铺开(等比不裁;`data.fit:"cover"` 按 `data.focus:[fx,fy]` 裁满),四周垫同图的压暗模糊版;`text`/`sub` 是左下角黑底撕边标签;at 这一帧硬切进来(0.17s 轻砸),上一屏也是满幅截图时同倍率横移 0.30s 换过去。`data.frame:"glass"` 用旧玻璃卡。也认 `frames`(录屏帧)。无图:连着的最多 3 张并排一屏 | `{"at":2,"kind":"card","text":"一句话出图","sub":"不用写提示词","data":{"icon":"bolt"}}` |+| `highlight` | `data.rect=[x,y,w,h]`(相对截图 0..1),`text` 可选标签,`data.fill`(推近后框占画面的比例,默认 0.42) | 框出当前截图的一块并压暗其余;满幅模式下镜头同时快推 0.28s 过去(至少推近 18%,最多 2.6 倍),同一张图上的下一个 highlight 横移 0.30s 过去 | `{"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:@@ -198,7 +200,7 @@ spec 级 data:`eyebrow`(标题上方小字)、`title`、`subtitle`、`acce{"at":2.4,"kind":"card","text":"语音输入","sub":"说完就转成文字","data":{"icon":"wave"}},{"at":3.6,"kind":"card","text":"长期记忆","sub":"记得你上次说过什么","data":{"icon":"memory"}}]}```-这是没有截图时的写法。有产品截图就用截图卡打头(`{"at":0,"kind":"card","image":"截图.png","text":"…"}`,见 `examples/t2_keynote_ui.json`)。+这是没有截图时的写法。有产品截图就用截图卡打头(`{"at":0,"kind":"card","image":"截图.png","text":"…"}`,见 `examples/t2_keynote_ui.json`;两张真实截图满幅+快推+横移,见 `examples/t2_fullbleed_pulse.json`)。#### t3_finance_chart(经济学人式数据图)@@ -218,16 +220,16 @@ spec 级 data:`title`、`unit`(副标题:指标与单位;放不下先缩{"at":0.3,"kind":"bar"},{"at":3.5,"kind":"highlight","data":{"index":0},"text":"最多"}]}```-#### y1_kurzgesagt(扁平科普:星球+卫星节点+尺度穿行)+#### y1_kurzgesagt(扁平科普:中心物+卫星节点+尺度穿行)-spec 级 data:`center`(第一层中心星球的名字)、`flow: true`(节点串成一条链、信号依次流过、带序号,讲「先后」时用)。+spec 级 data:`center`(第一层中心物的名字)、`center_style: {color, shape: "circle"|"rounded"|"hex"|"diamond", ring: true}`(不写就按名字生成一个中性样式:颜色和形状由文字决定、同名同样式、没有轨道环)、`image`(把一张图片裁进中心物,名字移到下方胶囊里)、`flow: true`(节点串成一条链、信号依次流过、带序号,讲「先后」时用)。环境层(星闪、粒子、信号脉冲)一直轻轻动;中心物、节点、标签落定后停住,镜头不慢推。| kind | 字段 | 说明 | 示例 ||---|---|---|---|| `title` | `text` | 顶部标题逐字上浮;第一个 highlight 或 enter 的 at 起 0.5s 淡出。不当开场用,第一帧先出节点 | `{"at":1,"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":"分词器"}` |+| `highlight` | `data.index`(只数当前层的 point,从 0 起,默认最新) | 快推 0.28s 到那个节点(推近约 30%),其余变暗;已经推近时,下一个 highlight 同倍率横移 0.30s 过去 | `{"at":5,"kind":"highlight","data":{"index":1}}` |+| `enter` | `data.index`(钻进哪个节点,默认最新),`text`(新中心的名字,默认用节点名),`data.style`(新中心物的 center_style),`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@@ -243,10 +245,10 @@ spec 级 data:无。| kind | 字段 | 说明 | 示例 ||---|---|---|---|-| `image` / `clip`(同义) | `image`,`text`=下方黑底标签,`data.halftone: true` 转灰度网点 | at 起滑入桌面;等比放、不裁,加纸白边和胶带。横屏左→右排、竖屏上→下排,红线连起来 | `{"at":1,"kind":"image","image":"截图.png","text":"官网首页"}` |+| `image` / `clip`(同义) | `image` 或 `frames`(录像帧),`text`=压在左下角的黑底撕边标签(12fps 打字),`data.halftone: true` 转灰度网点,`data.fit:"cover"`+`data.focus`+`data.aspect` 按焦点裁满 | at 起滑入桌面;冲印件(白边、旧纸色、投影、胶带),默认等比不裁。镜头停在一张上时它占画面八九成。横屏左→右排、竖屏上→下排,红线先描出去,镜头在 at 前 0.30s 横移过去 | `{"at":1,"kind":"image","image":"截图.png","text":"官网首页"}` || `title` | `text`(空的或纯空格会告警并跳过) | 黑底白字标签条,打字 13 字/秒。适合收尾点题,不当开场 | `{"at":5,"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]}}` |+| `highlight` | `data.rect=[x,y,w,h]`(相对**当前这张图** 0..1;`fit:"cover"` 时相对裁后的画面) | 荧光笔扫过→红圈→镜头快推 0.28s 过去(框起点在画外时先推、at 前一帧到位)。rect 目测常偏 20–30%,先 `--stills` 核 | `{"at":2.5,"kind":"highlight","data":{"rect":[0.1,0.2,0.3,0.1]}}` |最小 spec(y2 要真实材料:没有截图、照片、原文可贴就别选 y2,见第二节):```json@@ -277,9 +279,9 @@ spec 级 data:无。{"at":4.6,"kind":"highlight","data":{"target":"draw","index":0}}]}```-#### y4_storytime(豆子花叔讲故事:气泡、反应特写、插入镜头)+#### y4_storytime(豆子角色讲故事:气泡、反应特写、插入镜头)-spec 级 data:无(有 `window.VO_ENV` 就按口播包络对口型,没有就按字数合成)。safe 只让字(气泡、插入镜头的大字);角色、桌子、反应特写的脸是图形,竖屏下会伸进字幕带——字幕压在身体上读得清,但别指望它们让开。+spec 级 data:`character`——`"neutral"`(默认:短发、蓝 T)、`"bun"`(丸子头)、`"author"`(本 skill 作者的卡通形象,只在讲作者自己的故事时显式写;作者形象不随 MIT 授权),或造型对象 `{base, skin, hair, shirt, pants, hairStyle, hat, glasses, watch}`,或你自己的帧库:写一个目录(render.py 把文件名去扩展名当姿势名:`rest talk point shrug type stiff react back`,`<姿势>_open` 是张嘴帧),也可写 `{"frames": {"talk": "我/talk.png", …}}`;帧图透明底、脚底在图片底边中间,至少要有 rest 或 talk。镜头定住、角色不呼吸,变化靠快切、反应特写砸进来和插入镜头。有 `window.VO_ENV` 就按口播包络对口型,没有就按字数合成。safe 只让字(气泡、插入镜头的大字);角色、桌子、反应特写的脸是图形,竖屏下会伸进字幕带——字幕压在身体上读得清,但别指望它们让开。| kind | 字段 | 说明 | 示例 ||---|---|---|---|@@ -323,7 +325,8 @@ uv run --with playwright python engine/render.py --spec engine/examples/t2_keynouv 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(数字砸入开场);样例素材在 examples/assets/,都是 t3 自己渲出的终帧(数字已落定、无播放条、无路径)+uv run --with playwright python engine/render.py --spec engine/examples/t2_fullbleed_pulse.json --out t2b.mp4 # 两张真实终端截图满幅:快推到计时、横移到第二张、数字收尾+# 另有 y1_kurzgesagt(一滴海水→钻进一只硅藻)/ y4_storytime(屏幕特写开场)/ y5_kinetic_type(数字砸入开场);任何一份加 --width 1080 --height 1920 出竖屏;样例素材在 examples/assets/:三张图表是 t3 自己渲出的终帧(数字已落定、无播放条、无路径),两张终端截图是真跑 python3 -m timeit 的输出截下来的# 样例是写法示范:题材、构图和素材不要原样搬进成片```@@ -345,6 +348,7 @@ uv run --with playwright python engine/render.py --spec engine/examples/y3_white| 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)无 🔴 |+| 2026-10-10 脉冲镜头、真实素材件、竖屏整片进引擎后 | 16 段原片、36 段全风格样片、8 支示范片、长卷示范,各取 18 个时刻,横屏改前改后逐像素一致(示范片 y4 显式用 `char: 'author'`);9 份样例横竖屏都渲过、qa 确定性 ✓;竖屏测试片的 push / bands / iris / comicPanels 转场按 1080×1920 算对 || 已知的跳变 | y1_s3(42 倍→1 倍拉出中段)、y2_s2/s3(快摇与推满照片)、t1_s3(穿进神经元)、y5 拍点重音——都是设计内的相机推拉或节拍闪,原片里就有 |---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"index 583eaf2..f8bb66d 100644--- "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"@@ -7,7 +7,7 @@## 起手必查1. **这一套最容易读成 AI 模板。** 光斑渐变底+毛玻璃卡+渐变字+居中从模糊里浮出+卡片漂浮,五样一起上,观众一眼认出是模板。开工前先问:有没有真实的产品截图、录屏、实物照片?有,就让它满幅当主画面并推近到要讲的那一块,光斑和玻璃卡不用;五样包装一支片子最多挑两样。-2. **截图要大。** 有截图的镜头,截图宽度 ≥ 画宽 80%(竖屏 ≥ 90%),再推近到口播正在说的那一块(快推 0.28 秒推近 18–32% 后停)。一张小卡漂在大片光斑上,就是第五种做坏方式「死背景」。参数化片段的截图卡宽度上限约 80%,要满幅推近就用 y2 片段的 highlight 或自己写镜头。+2. **截图要大。** 有截图的镜头,截图宽度 ≥ 画宽 80%(竖屏 ≥ 90%),再推近到口播正在说的那一块(快推 0.28 秒推近 18–32% 后停)。一张小卡漂在大片光斑上,就是第五种做坏方式「死背景」。参数化片段 t2 默认就是这样:截图满幅铺开(等比不裁,四周垫同图的压暗模糊版),highlight 那一刻快推过去,连着两张截图之间同倍率横移 0.30 秒;旧的玻璃卡要显式写 `data.frame: "glass"`。自己写镜头用 `CAM.track`(脉冲镜头)和 `MD.cover`(满幅+焦点+推近)。3. **数版式。** 把分镜里每一屏的版式写出来(标题屏、三卡并排、大数字、截图卡),同一种连续出现 ≥2 屏就换一种:截图推近、数字砸入、前后对比。「标题 → 三张功能卡 → 大数字」整片循环,就是翻页 PPT。4. **落定后停住。** 不加卡片漂浮、不用匀速慢推填停顿;下一个动作放在口播说到名词或数字的那一刻。5. **配色跟产品走。** 底色和强调色取产品自己的品牌色,不默认紫蓝青光斑;讲坏消息、严肃事件、非发布题材时不用这套深色发布会底。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"index 8f3593f..1a2720b 100644--- "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"@@ -8,7 +8,7 @@## 起手必查1. **先写这一段的视觉隐喻:抽象概念画成什么物**(细胞、齿轮、管道、城市、一滴水……)。写不出物的那一句,不要只放一颗发光的球加几个标签胶囊。-2. **示范片和样例里的橙色中心星球是一种画法,不是这个语法的签名。** 中心物按题材换形状和颜色。参数化片段 y1 只会画「中心星球+卫星节点」,适合「里面有什么」的分层讲法;题材不是这个结构,就自己写镜头(`demos/y1_kurzgesagt/` 和 `lib/` 的 `CAM`、`TOON`),或换语法。+2. **示范片和样例里的橙色中心星球是一种画法,不是这个语法的签名。** 中心物按题材换形状和颜色。参数化片段 y1 的中心物由 spec 定:`data.center_style`(颜色、形状、要不要轨道环)或 `data.image`(把一张真实图片裁进中心物),不写就按名字生成一个中性样式,不再是那颗橙色星球。它只会画「中心物+卫星节点」,适合「里面有什么」的分层讲法;题材不是这个结构,就自己写镜头(`demos/y1_kurzgesagt/` 和 `lib/` 的 `CAM`、`TOON`),或换语法。3. **每句旁白里至少一次状态变化**(弹出、形变、钻入、拉远)。逐句数一遍:连续两句画面没变,就补一个事件,不靠浮动和慢推凑。4. **主体落定后停住。** 环境层(星闪、粒子漂、远景云)可以一直轻轻动;主体和标签不加浮动、呼吸,不用匀速慢推填停顿。5. **钻进去之前先停一下。** 尺度转场前让要钻的那个物停 0.3 秒以上、亮起来,观众知道下一步进的是哪一个;缩放用对数插值(`CAM.zlerp`)。@@ -116,7 +116,7 @@- `PAINT.noise`- 引擎的段落表、转场接口、离屏 A/B 缓冲- 新写、现已统一进库(`lib/camera.js` / `motion.js` / `typo.js`):- - `CAM.at(keys, t)`:关键帧相机,缩放用对数插值。`CAM.zlerp` 让每帧放大同样的倍数,尺度转场才是匀速穿越。+ - `CAM.at(keys, t)`:关键帧相机,缩放用对数插值。`CAM.zlerp` 让每帧放大同样的倍数,尺度转场才是匀速穿越。新片的停顿和点名用 `CAM.track`(快推 0.28s、横移 0.30s、砸入 0.17s,其余时间停住),参数化片段 y1 的 highlight 就是这么推的。- `CAM.anchor`:缩放时让目标点平滑移到画面中心。- `MO.bezier(x1,y1,x2,y2)`:把 AE/CSS 的贝塞尔缓动搬进代码,牛顿法求解。- `MO.*`:sine、quint、expo、back、elastic 等。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"index e1a4c3b..9a36e4c 100644--- "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"@@ -127,6 +127,7 @@- `CL.tornEdge`:撕边。- `DG.hand / DG.drawPartial / DG.cum`:手画线,按长度描出。- `CAM.motionBlur`:沿速度方向叠帧。+ - 新片的真实素材件:`MD.print`(冲印件:白边、旧纸色、投影、胶带,可按焦点裁)、`MD.label`(黑底撕边标签,12fps 打字)、`MD.cover`(满幅铺开+焦点+推近,硬切到实拍时用);镜头用 `CAM.track` 的横移、快推。参数化片段 y2 已经换成这一套:照片占画面八九成,镜头 0.30 秒横移到下一件、highlight 快推 0.28 秒,不慢推。- `MO.bezier`:长尾缓动 `(.33,0,.2,1)`。- 示范片自己的(`demos/y2_vox/vox.js`;`slideIn / highlight / stringPts` 已进库为 `CL.slideIn / CL.highlight / CL.stringPts`):- `slideIn`:倾斜滑入放平。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"index 309ce3f..4ab3602 100644--- "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"@@ -106,10 +106,10 @@- **复用 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.bean(c, {x, y, s, char, pose, expr, mouth, blink, look, squash, bob, tilt, lw})`:正面豆子角色,全部 Path2D 程序化,返回双手和头的坐标(给道具、符号定位)。`char` 默认 `'neutral'`(短发、蓝 T),另有 `'bun'`(丸子头),`'author'` 是示范片里作者本人的造型(白渔夫帽、圆眼镜),只在讲作者自己的故事时显式写;也可以传造型对象覆盖颜色、发型、帽子、眼镜(见 `TOON.LOOKS`)。参数化片段 y4 用 `data.character` 选,也接受自己的帧库目录。- `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`。+ - `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 占位——**正式片换成真人口播后重新导出包络,口型自动跟上**。diff --git a/release-manifest.json b/release-manifest.jsonindex dc0382d..dcf44ad 100644--- a/release-manifest.json+++ b/release-manifest.json@@ -3,11 +3,11 @@"files": {".github/workflows/tests.yml": "91b5797ea6f59b6e31e53de2a846194e33ab1dbe24b2efb8c0ed4367324f8fbe",".gitignore": "64ed0cc55105bb4b33ebd1baadd1eb18c74b604f6bbce0fbaa4c62b5eb425197",- "CHANGELOG.md": "94cb92b60b88bcaef22a5cf76e8b5fc94048b0c2b2bb26b4f3112da0baf88d05",+ "CHANGELOG.md": "c13558423daafaeb95d7a4fc23a8e2b9613f7a8d8d81ee41ea6dcc1af438283b","CONTRIBUTING.md": "742a1a6071f6be25e82f0524a520fd6d09961be3f87d7a85940cd816ce7309a1","LICENSE": "6d6a2a9caf2e6d2b76974050427053b2892d8aa4c33fd168ce63a537fcee9d96","README.md": "b129107c5e219fbeb558beae103d6eb5dc2a7c18d09e1b3a1d4853a400b370bb",- "SKILL.md": "bed951bbe4dd018685aaba4ae3226c0c713ea9d8382772b936a6e375c490eee2",+ "SKILL.md": "7472042ca137ef984f28cde3208abf8caa589aaf142273788ccc8b5539d93c50","assets/showcase/egypt.gif": "256b946e2543192153f276dc46e0af98837c934ddb9e2e2c0c9843f0557cd54b","assets/showcase/hero.png": "3b6b42bfb00f84925aebe2a10f85052dc6b4efb492e86f581f21f652b6686407","assets/showcase/mario-claude.gif": "f63f2f464c1d7b477578d07359d85712086a39b615669f1d3bb015290c54741f",@@ -36,7 +36,7 @@"references/06-口播驱动的艺术短片.md": "9275abd6451831515ed9aed24724062bf47dda5e5d2d804baa8313c137236bc8","references/07-正面经验.md": "fd5f63474f15e01119e10586a14a456f602cf4f6ee03b4359bcf77c084305f1b","references/08-风格作者规范.md": "30312801d2833b478bc80218a704d87971c08f50a7ee0e31f3c08eefe15f9b4e",- "references/09-视频动画语法.md": "b016b34934ff7f1c1a3b30e1733fa2c7b5cf20e83ea5db30e72e35460117f6f6",+ "references/09-视频动画语法.md": "23498069c7bc2f791b0a8c4c0b4f408cad8d21f41675ec8032c23071edb88dd4","references/10-角色.md": "0c69bc849688069ee59bfe619eb7c44c48dbeee0324ee2bcc87bbe98d41af74b","references/11-长卷穿越片.md": "42f2e441687116c8d2dd789b187ada572390e242976996727a209959163a6ad6","references/12-口播整片与经验回流.md": "b85f6e8b665c13a5d98ea461c10af340679a6949101ee31dd64eee7e88aed415",@@ -45,12 +45,12 @@"references/compatibility.md": "c5665580fab722a3ed784a71f5cca725fc56cebf8c8c3ad66219b24b6b97bb0e","references/images.md": "313bee677064eb46ee13c88c74effeecdb536579d7e8a25e23ddf9a2a06357e3","references/动画语法/t1_3b1b.md": "d0f375ca054def2bd7cefd2c17d076d2a83b3a2ee452a0c81836623ded4ae785",- "references/动画语法/t2_keynote_ui.md": "75676f396004c7e6586cff8a66fe484defad399214648a53e92b2d3a4de3f43f",+ "references/动画语法/t2_keynote_ui.md": "a496a490e692184a25d0007ea7a1569ca9a18b06dbbde49add2efce92f9d2888","references/动画语法/t3_finance_chart.md": "b768c2031d791fb6e162f4f04aa62e66856297307b147c294c04b34b79a51cdf",- "references/动画语法/y1_kurzgesagt.md": "26fbf4b57492da29ff5f5fc6fdc40a4c6a60520f9c85d24c440f6798b7b661f7",- "references/动画语法/y2_vox.md": "c63767e5b4b0d64e008003e059baea176ca794008ccd02e4247b8e6de48f9b58",+ "references/动画语法/y1_kurzgesagt.md": "a0e33e2e69ce36ab784334bafa1efd5ac7f387ade495c2b2a30bdbbb5e2b8291",+ "references/动画语法/y2_vox.md": "f697f34612b8de23720d78768505cd79333b07afd4226f2976b6b01cc099b986","references/动画语法/y3_whiteboard.md": "f2fda7768034d94928982193965f225a3c85a850eaf28f3f28459e85dbe0773d",- "references/动画语法/y4_storytime.md": "ee3af52919003d618babc336201eebf6ce5f994b92cf48e45e67534017dacd70",+ "references/动画语法/y4_storytime.md": "a8d48d9c0981cd3e92b22dff1091c99bc7a4130519dbbc81315ef259dbabfa36","references/动画语法/y5_kinetic_type.md": "97b200e68231d71cd10cf3f1027b4db36e99ce9a06004891d644994883bb15e2","references/动画语法/y6_presenter_explainer.md": "405318fc5aac9ce03cbc374af9633ec7d652dc8206ad3810919abdb174eff273","references/口播API.md": "a9d2775fc97bf92f46cf0a6531f1921ccdcf195dd79475c575bf8f188ca5801e",@@ -97,16 +97,16 @@"scripts/audio/synth_艺术史速通.py": "6476605af684b477d47b7f47c3c987059277de36b97bff5d77d167c27efdb40d","scripts/capabilities.py": "43b1dd58d9f42efc638270cf67190ce85dda4e25fd591925c2f31e5bd6b4f63b","scripts/check_release.py": "508388bdcfe87d97d486de7d76fec87b893469779af14cc75e4b72b4c17ecc60",- "scripts/engine/clip.html": "9c9a1f2301c306e147ad53549aea986ac2943194d62b9a578a2a22d9dd7c735e",- "scripts/engine/clip.js": "561d71fefcdbce4c783ff42775ee7a10cea957ce2617273fa435f0cae69e59fd",+ "scripts/engine/clip.html": "dab49e34a45f0dfd8e49fb25444a6d6cd51425a7f53513d0001b0e215f15c343",+ "scripts/engine/clip.js": "81c11d0261bd1913a384c25d30458c5dd4eabfda24e786858490d239c6b21191","scripts/engine/clips/t1_3b1b.js": "6e819bb9be76db0d8a7220e8aa5fedd83879b24ce6084579d7ac2641d85deaa2",- "scripts/engine/clips/t2_keynote_ui.js": "bd96d0b6d4c55e86bf7b16852f90373b443f3eff8f6fd86ebdeec02f9d5f658a",+ "scripts/engine/clips/t2_keynote_ui.js": "b587e991855224d2f48b69a15aa2d657a7c5379ce6229dab4ba6ba86a37d6b80","scripts/engine/clips/t3_finance_chart.js": "db7e1b44993964add4125917e7a651adc4a143259570aa4e65d85a72aae0d44b",- "scripts/engine/clips/y1_kurzgesagt.js": "99c8656ac04dba5a218199ea272a71ad8ee34ad69125f906b22d6d1946745029",- "scripts/engine/clips/y2_vox.js": "250d7f793ad3c331bd351e43d70565144f73bbe5ae65e8588428811dfe45cf4d",+ "scripts/engine/clips/y1_kurzgesagt.js": "f6f64a56ba0d5a59024538180ceb375025405c829888fe0767c518cb9640a25d",+ "scripts/engine/clips/y2_vox.js": "103f4b261c649d85616fb378750a058aaf50c97f25c37c060d5c6a36f38f34ad","scripts/engine/clips/y3_whiteboard.js": "23ff417331708353de03289860bec28206aea12acfc45e40bc53b81c5a0e340c",- "scripts/engine/clips/y4_storytime.js": "88faca8e84364dcbf46cf28dcedc3cd488909d2d439c88d12ffdca26114a2ba8",- "scripts/engine/clips/y5_kinetic_type.js": "dac5d0f8da6ed8b0947235c2c2ad51234454cbc42a7da29c27826ee616716ded",+ "scripts/engine/clips/y4_storytime.js": "b1ebe090c4806d508b0591dc2dd3cb8273cb32c4e3158a5c736132666b74cfed",+ "scripts/engine/clips/y5_kinetic_type.js": "b034957c67e18599a753378edc7bebd68e3d651574e951376449eab09275b30f","scripts/engine/compare.py": "7bf1d5ae2926de09f69431435e93ffa4c5357532b543217cd66bdc57e00256aa","scripts/engine/demos/_shared/hero.js": "96e9e520d1139aa617be7ad01901f6a9b6c31c7948f73b33ddd8d646c6cdf967","scripts/engine/demos/_shared/hero/c1_0.png": "827032c6aa741f9895895224a67f81538d70ef970b10da6c3ee93e8deece3018",@@ -198,35 +198,38 @@"scripts/engine/demos/y4_storytime/eras.js": "c3cf9816bb94b08d6065f1b5c67d71bf9ad23b1f6b398345e27ecb0f40af396c","scripts/engine/demos/y4_storytime/s1_desk.js": "e687991b4127e99efd0c73339670a30a968708817a2ec32345b2931bf7105d45","scripts/engine/demos/y4_storytime/s2_screen.js": "414ebc1df2fa078fea7b0cb2dcc633d20a84ce9eda1f9fd331190b0ecd42c0da",- "scripts/engine/demos/y4_storytime/s3_react.js": "12616dec31481b2d2f2fa9a9f086d48e8b1a48ead7e18ebff989ec9bc1eae9de",+ "scripts/engine/demos/y4_storytime/s3_react.js": "16ff4d5b624f57c84eac0f4bfca95d318635588fc362e89024b098483b7951bb","scripts/engine/demos/y4_storytime/s4_wide.js": "a238d9accd8d789104be7f4d0984922698e371c38fb3780d457e907540c36602","scripts/engine/demos/y4_storytime/s5_close.js": "62323752eaf8c997d700e92f5900c2a8d86365d528534338e7a0ca8bf392eb19","scripts/engine/demos/y4_storytime/story.js": "945e7171975fbdfbd95c91cfca070e64f9c2a4f6ae8fc034468f1adcd9dec3e1","scripts/engine/demos/y4_storytime/vo_env.js": "04739a58e5bbce262ef1f2d3c1f7988d85d2fe07139a64bee7fc2318d50bd98d",- "scripts/engine/demos/y4_storytime/world.js": "45d9d78424c15b2d43471b5b1c211f95ef7d20fcee2c5fe510fe722eb1f31153",+ "scripts/engine/demos/y4_storytime/world.js": "36f387e9831723ad17249d0891e2c4974414d2061ee89bd696a87aa6c098b715","scripts/engine/demos/y5_kinetic_type/eras.js": "540e671b8d6e7e85684332c68c079c88da674fab8ba80bc3773a27badb5c4d50","scripts/engine/demos/y5_kinetic_type/k1_title.js": "b1c0d5ee07720e6f4df94dec9e6101bb5781a009e3bf7584d68dc48c413cd215","scripts/engine/demos/y5_kinetic_type/k2_complete.js": "3f2d6a463508cecc5ca2327f0a6ae3f7e5b30e90d8ffe48638113244baa25be9","scripts/engine/demos/y5_kinetic_type/k3_chat.js": "c810bb9c4462b7f60ff9e5eeeb8edd0e2a74d73fc42116c8a95a48210fb935a6","scripts/engine/demos/y5_kinetic_type/k4_agent.js": "368d734da08e17beff2a267b2d664a99f48fc28dd911da637c2e81e295b36e90","scripts/engine/demos/y5_kinetic_type/kinetic.js": "83b5ada7617db67f715203882eda22f54c846c7655418ab10744a373472a8c84",- "scripts/engine/engine.js": "2ecd3659912e5e2fed75cc62c8eab974c99dabf1bb773699967b822d2ac05259",+ "scripts/engine/engine.js": "04b64953037ced7016ffb211cb12891dc4f1c840378a366e35572db8098fd3cd","scripts/engine/eras.js": "2ccc90bed5e9ef337f8cf3444058705dc720743a78c9315a0e5ee814cd130fc9","scripts/engine/eras_gallery.js": "6e97dfe281b8360d400a657098a68dd224a1a081299b28b3137a1b1db1a8222a","scripts/engine/examples/assets/K线图_横屏.png": "04a61f9be80bc4895136cfb168ed102860d96af41edab1957e326d647993cb19",+ "scripts/engine/examples/assets/终端_for循环求和.png": "8871dce38e3ce0bc94a2aa22ab5479152df40837b67ced2b87de269a740badc3",+ "scripts/engine/examples/assets/终端_sum求和.png": "2af3cac8b7468c120163c0993d98c8666d75d4814c8f0fbeced8d21db07302bf","scripts/engine/examples/assets/营收图_竖屏.png": "5c3c9207a8ea289347463408547fdd8f19c63e68e1cbcbcdbc5de77b556b1648","scripts/engine/examples/assets/财经图表_横屏.png": "95c56c106f6eed633cf2c8b6bc46465ecf335aefe5abd9bb8e91563b48c572e1","scripts/engine/examples/t1_3b1b.json": "ba7f1bdacbdeba3c963584aa79c5f1c1e99ff9bd58cd373cef16a58b4975318b",- "scripts/engine/examples/t2_keynote_ui.json": "84ea56f4d60133d74814281bd46b71290b6352adb1700b26aeb72700febe28c3",+ "scripts/engine/examples/t2_fullbleed_pulse.json": "347c38eddf6bd35217fd037d9d047d530d422681a2ffe31e5091aa43f99e7f1d",+ "scripts/engine/examples/t2_keynote_ui.json": "995c974be98b35462b8b25b37f8feb1cdabf579cab6b27940d6be88457098665","scripts/engine/examples/t3_finance_chart.json": "54f39947a0d22bf3c558f3f4e4cbda39b641b38c03ab1d89c638769b204bb4c4","scripts/engine/examples/y1_kurzgesagt.json": "61f4919c61f636a838cfb7f8d178be43a069fab0f31629a66acfad8620a4b524","scripts/engine/examples/y2_vox.json": "27c7d6424580caa1e1161535137c7629af55e88b788db6641b01492cb0754e7e","scripts/engine/examples/y3_whiteboard.json": "f5394b8e759870a0d20329eb8d81c1e55f14e23b217cc39b706cb175d7623532","scripts/engine/examples/y4_storytime.json": "022916609dda78819ca3767541781580cb9c05839c6a30932dd7fcfddab34b3e","scripts/engine/examples/y5_kinetic_type.json": "fcd5f8aad9fc1a5fea5a3f4c9be356afe323a02472000aebcbaa9f6a8201a46b",- "scripts/engine/index.html": "e286a195ce3bf96c439a99fba77412eddd3498f4f3a141f9313b5388d07d798d",- "scripts/engine/lib/brush.js": "6e548a35b25ead20ac6e81042e8b841166d06f53cb0560326444fc125203ba64",- "scripts/engine/lib/camera.js": "cfacc134a963015cc1354621503e5821e971d709b714e0534f518a37a06d8d5a",+ "scripts/engine/index.html": "afc9c95a9ca1386b2f3513fe1fe21e595372c11a084be02b802b0ad254946d8e",+ "scripts/engine/lib/brush.js": "e83db04e5fc9fef83237d984d2ceba3c1ec71c0c2a8f8a798ecc939fc8c3b2d4",+ "scripts/engine/lib/camera.js": "0c155120b4ec80ac97b706e812a54e25fb8c795e76e18e4df2247ad8baa19e84","scripts/engine/lib/chart.js": "93d3605cba7d7cf0bdda2c2dd8f9797734dd06c1f64fa18ef7a492f8755a8d27","scripts/engine/lib/collage.js": "4dcd3d15f8895dc6e3d4f2e4d82766782a4e77876fb863ded9480320b8959d93","scripts/engine/lib/diagram.js": "98b15ba5f883dd95eca2ff52ba1d768c10a5bea7862bd13aee6d84b875e2b8c5",@@ -279,17 +282,18 @@"scripts/engine/lib/fonts/cmunrm.woff": "32115abbbfb231586813333bfa5a234f4dc7f28b27df7260f42f81146ccd9097","scripts/engine/lib/fonts/cmunti.woff": "d9a02b7b67874c62f47f9c9a0914c115972ab77d43e82a163baf0888eb5d4a2d","scripts/engine/lib/fonts/index.json": "a0870057845b502a11037acef99b6e9cbc3994fdb5149caf3aac036140dbfbb1",- "scripts/engine/lib/kit.js": "77821ce0ae8278c462b5669449bca473659c95317c3b62fc8b008e2bdf87209f",- "scripts/engine/lib/motion.js": "7e70b8ef328c7497fe1403d37700fcdfbb2cc9d2175f16ea46ae3e69b49dbe15",- "scripts/engine/lib/paint.js": "aa61a2cb14b0bbd96e072865fb8b24bdd118b4f62aca3ff2c320ca17593aca25",- "scripts/engine/lib/post.js": "c57ba51a2242e9505a1b35dbb2645c1e3541465069c99de704c3fba9066914a3",- "scripts/engine/lib/render.js": "5bcde2a2711759c934722d91a456f13eecb5cd6679f9b3b601df728e18c08432",- "scripts/engine/lib/rig.js": "88c4df6dc105cafdc7249a5f31c79928db6c05b372f04e2e0f14059e8620f17f",+ "scripts/engine/lib/kit.js": "a066c4d0d4dc7189dd9de7776938b4cbc6025a4bf4a38d2e181a6667744f3024",+ "scripts/engine/lib/media.js": "a509bf201252636fdd880806f7074c65aaee665d145d54ca6ac3ed39a165ebcf",+ "scripts/engine/lib/motion.js": "420482f3a6917c6b0d505b3d2e83be0df3f44f5966e6d38fc9bf7643900af0fa",+ "scripts/engine/lib/paint.js": "95ccd1945a4a19b6e2d89a422d7ea7de96174acdbae1801090ca9ee48131f9a3",+ "scripts/engine/lib/post.js": "b63ce9e73929083b4e51cb1caa45f606c6556023b3024da45520386a3d5f6129",+ "scripts/engine/lib/render.js": "d2855f044ddff579000d9f8b1abadc2b76f84875fc604bea79d10319e3fe92bf",+ "scripts/engine/lib/rig.js": "62580706e14438c6b57289ce203d040c91d8a427e356f44084a65dfc53a13bbf","scripts/engine/lib/rig_huashu.js": "6419306bb314f89848b0adf842db0c305c2f6bc931df34388eb5389f29c1d392",- "scripts/engine/lib/toon.js": "83a83f6562578646ea0430c25e4a83a98dad77f32d631c869a49bb34a4e0225e",+ "scripts/engine/lib/toon.js": "54778963a97767742257e5b68890e5b292f2b89ce3fd1a1f9711224573988d8b","scripts/engine/lib/typo.js": "30db0cc68145dca22532e487da01aeb3ec97155e8b2c3a0747a009ce6638be8f","scripts/engine/lib/ui.js": "2608da0a38bfd429a9fe41c1a93a5d080d54c5fcccea80e7fea764e6ca3a97bf",- "scripts/engine/lib/util.js": "86045b05656183cd7017e43fb891aa65d1a1e76477885c4dbee81635ee8b7a1d",+ "scripts/engine/lib/util.js": "a2092233bbca337a29b00ce261d81a5c7b6baa020c9e301916ebe4a997450b9d","scripts/engine/reference_films/spacex/README.md": "dd19ad3495bc4e6733290af13732a57adafb039ae6a799f3054bd17b520dc353","scripts/engine/reference_films/spacex/eras_lin.js": "6605819d67486729d65a36c7cde3c7bd1b631bdf4384473180ac61e01a38c2cf","scripts/engine/reference_films/spacex/eras_spacex.js": "0061954a4399c0b13896d7f482777ea2cc813ef7415c5a68c3ee56ae4a903c98",@@ -364,7 +368,7 @@"scripts/engine/reference_films/spacex/transitions/paperSlide.js": "14eb0b28a2e78a7feeaf158b81d3aef640f9776dd0bb578f21b7e6bfafe40e13","scripts/engine/reference_films/spacex/transitions/vox_pull.js": "79db9ef00e31a4a44872ef57f9ce9a5a89ed631c1a83d9b7e72129e4a7355959","scripts/engine/reference_films/spacex/transitions/vox_slap.js": "78f8fa308a434a33d7007b776c4e006d711fea61d4f4dab9426baeebc6c3d573",- "scripts/engine/render.py": "b7a8bf535f18b8e14e2e1da52a715dfb9923133a7e961499009a0c811f0739ff",+ "scripts/engine/render.py": "9f64eb5f7a50039dfd36b4e8bb780cdab5d5d30477469adaf92a72552d1736c3","scripts/engine/scenes/01_cave.js": "06ff3360279ecf778d78ef5e56fa6d5cd6354a18033079eed32cba6af48dd781","scripts/engine/scenes/02_egypt.js": "ce4acdce7f65f41686f7e5f04336fdf150bfd53a560a20f2a83a3db495a86353","scripts/engine/scenes/03_greek.js": "58e259062257ebf15d2fb141e10441119df0691e0cc2bd212922a8cffb3be184",@@ -401,7 +405,8 @@"scripts/engine/scenes/35_shinkai.js": "8e7f5753a0ce49291ae35bc4f471b5ca62448eb9532403459395d88bc524a736","scripts/engine/scenes/36_picasso_blue.js": "10023147e1e31afc162e1cfe51356867ef83595b41bbd5cc824d55532297ce09","scripts/engine/scenes/index.js": "22da1210908a8083658eb53289656eeb578026b6deabc666928014d01ddae23e",- "scripts/engine/transitions.js": "22dface64bccee924faf56a49bfa380c65c65258b462acd800fc59ca654e2c8d",+ "scripts/engine/spec_assets.py": "0f32fb56eae66532c0bc644519afb1d9d71d36efcf9fe4c19539752387ef7e66",+ "scripts/engine/transitions.js": "c4bd441cf765db346933e5d18270f532d4c9782c9303b0bcda1ba59a2124b618","scripts/engine/时代作者规范.md": "4e7661571b60fa0ed776fb5631462aff3a30235c5e6343aa06f9cd23973391fc","scripts/font_subset.py": "ed826dffb4b370741602aa79caefd69157fcf6d7f9abd90a9078d4f7208896e0","scripts/images.py": "a47a2663f251525bfbed5b46533e3d43415c9e10c8a2b8a9f754abf204529535",diff --git a/scripts/engine/clip.html b/scripts/engine/clip.htmlindex 72032e2..8fb03b3 100644--- a/scripts/engine/clip.html+++ b/scripts/engine/clip.html@@ -16,6 +16,7 @@<script src="lib/chart.js"></script><script src="lib/ui.js"></script><script src="lib/collage.js"></script>+<script src="lib/media.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.jsindex af5b946..39e2bc4 100644--- a/scripts/engine/clip.js+++ b/scripts/engine/clip.js@@ -1,7 +1,9 @@// 参数化片段运行时:一份 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?}] }+// 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?, frames?, fps?, dur?}] }+// 素材路径(render.py 用 spec_assets.py 核存在并改写):cue.image、cue.frames(帧序列:目录或路径数组)、data.image、data.character.frames(y4 帧库)。+// 任何一张加载失败 → 启动失败、拒绝渲染(不出空白帧)。语法里取素材:ctx.still(q) = 这条 cue 的静态图(有 frames 时是第一帧),ctx.frame(q, t) = t 时刻该画的那一帧。// 语法文件 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 帧起算。(() => {@@ -29,9 +31,10 @@ async function boot() {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); });+ const fix = p => p && !/^(data:|https?:|\/)/.test(p) ? base + p : p; // 预览模式:frames 要写成路径数组(浏览器列不了目录),帧库要写 {frames: {姿势: 路径}}+ (spec.cues || []).forEach(q => { if (q.image) q.image = fix(q.image); if (Array.isArray(q.frames)) q.frames = q.frames.map(fix); });if (spec.data && spec.data.image) spec.data.image = fix(spec.data.image);+ const ch = spec.data && spec.data.character; if (ch && typeof ch === 'object' && ch.frames && typeof ch.frames === 'object') for (const k in ch.frames) ch.frames[k] = fix(ch.frames[k]);}if (location.search.includes('render=1')) document.body.classList.add('render');const W = spec.width || 1920, H = spec.height || 1080, FPS = spec.fps || 30;@@ -46,7 +49,14 @@ async function boot() {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);+ for (const q of (spec.cues || [])) {+ if (q.image) urls.add(q.image);+ if (q.frames != null) { if (!Array.isArray(q.frames) || !q.frames.length) return fail(`cue ${q.kind} at=${q.at} 的 frames 要是非空的路径数组(render.py 会把目录展开成数组;预览模式只认数组)`); q.frames.forEach(f => urls.add(f)); }+ }+ if (spec.data && spec.data.image) urls.add(spec.data.image);+ const chr = spec.data && spec.data.character;+ if (chr && typeof chr === 'object') { if (!chr.frames || typeof chr.frames !== 'object' || Array.isArray(chr.frames)) return fail('data.character 写成对象时要有 frames: {姿势名: 图片路径}(或在 render.py 里给一个帧库目录)');+ Object.values(chr.frames).forEach(f => urls.add(f)); }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 里的字缺字形只警告:回退系统字体照样能渲,但换台机器会变样)@@ -60,7 +70,10 @@ async function boot() {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) };+ 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),+ // 素材:still = 定版式用的那张(image,或 frames 的第一帧);frame = t 时刻画哪一帧(frames 从 at 起按 q.fps(默认 30)播,播完停在最后一帧,q.loop 循环)+ still: q => q && (q.image ? IMG[q.image] : q.frames ? IMG[q.frames[0]] : null),+ frame: (q, t) => !q ? null : q.frames ? MD.frameAt(q.frames.map(f => IMG[f]), t - q.at, q.fps || 30, !!q.loop) : q.image ? IMG[q.image] : null };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)diff --git a/scripts/engine/clips/t2_keynote_ui.js b/scripts/engine/clips/t2_keynote_ui.jsindex 429158b..75d0e95 100644--- a/scripts/engine/clips/t2_keynote_ui.js+++ b/scripts/engine/clips/t2_keynote_ui.js@@ -1,12 +1,15 @@-// 片段 · 发布会式界面(t2),做教程、功能、参数最顺手:深色光斑底,一屏一件事;字从模糊里浮出,卡片是毛玻璃、轻回弹落位。-// data: { eyebrow?(标题上方小字), title?, subtitle?, accent?:'#3d6bff' }+// 片段 · 发布会式界面(t2),做教程、功能、参数最顺手:一屏一件事。有截图就让截图当主画面:满幅铺开,口播点到哪块就快推到哪块。+// data: { eyebrow?(标题上方小字), title?, subtitle?, accent?:'#3d6bff', frame?: 'full'(默认)| 'glass' }// cues:title(at 这一帧标题开始从模糊里浮出;text/sub 覆盖 data)-// card | step | image(一张卡:text 卡标题,sub 说明,image 截图路径;at 这一帧卡片开始弹入;步骤号按出现顺序 01、02…,data.step 可指定)-// · 有 image:一屏一张,截图等比放进卡里(contain,不裁)。横图横卡;竖图(手机截图)在横屏里是「左字右图」,图撑满高度+// card | step | image(一张卡:text 卡标题,sub 说明,image 截图路径(或 frames 录屏帧序列);at 这一帧出现;步骤号按出现顺序 01、02…,data.step 可指定)+// · 有 image,默认 frame 'full':截图满幅(等比放进内容框、不裁;data.fit:'cover' 才按焦点 data.focus=[fx,fy] 裁满),+// 四周垫一层同图的压暗模糊放大版,不留死背景;text / sub 是左下角的黑底撕边标签(12fps 打字)。at 这一帧硬切进来(0.17s 轻砸),+// 上一屏也是满幅截图时改成同倍率横移 0.30s 换过去。highlight 这一刻快推 0.28s 到那块(推到框占画面约 42%,至少推近 18%、最多 2.6 倍),连着的 highlight 横移过去。+// · data.frame:'glass'(或 spec 级 data.frame):旧版毛玻璃卡——截图等比放进卡里,横图横卡;竖图在横屏里是「左字右图」。光斑、玻璃是可选包装,慎用// · 没有 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 可选标签)+// highlight(框出当前截图里的一块:data.rect = [x, y, w, h],相对截图的 0..1;text 可选标签;满幅模式下镜头同时快推过去,data.fill 改推近后框占画面的比例)// number(大数字单独一屏:data {value, prefix, suffix, decimals, label?(数字上方小字)};at = 数字落定时刻,提前 0.9s 开始计数,// 上一屏这时开始退场,不叠在卡片上;说明写 text 或 sub 都认)// 竖屏:第一张卡进来时标题缩成页眉留在顶上(不让上下大片空着);卡片按剩余高度放大。safe:版面只排在 top..H−bottom 之间。@@ -52,17 +55,34 @@ return {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];+ const n = q.data && q.data.step != null ? q.data.step : ++k, im = ctx.still(q), cd = { q, n, im };+ const last = slides[slides.length - 1], full = im && ((q.data && q.data.frame) || ctx.data.frame || 'full') !== 'glass';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 slides.push({ type: im ? 'img' : 'cards', cards: [cd], start: q.at, full });} 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; });+ slides.forEach((s, i) => { s.next = slides[i + 1] ? slides[i + 1].start : 1e9; s.panIn = s.full && i > 0 && slides[i - 1].full; s.panOut = s.full && !!slides[i + 1] && slides[i + 1].full; });+ // 满幅截图:内容框(让开 safe,四边留一点)、截图的几何、这一屏的脉冲镜头(highlight 快推 / 横移)+ for (const s of slides) if (s.full) {+ const cd = s.cards[0], q = cd.q, m = 24 * u, bx = { x: ctx.box.x + m, y: ctx.box.y + m, w: ctx.box.w - 2 * m, h: ctx.box.h - 2 * m };+ const fit = (q.data && q.data.fit) === 'cover' ? 'cover' : 'contain', fo = (q.data && q.data.focus) || [0.5, 0.5];+ s.geo = { box: bx, fit, fx: fo[0], fy: fo[1] };+ const [iw, ih] = MD.size(cd.im), s0 = (fit === 'cover' ? Math.max : Math.min)(bx.w / iw, bx.h / ih), dw = iw * s0, dh = ih * s0;+ const ix = fit === 'cover' ? clamp(bx.x + bx.w * fo[0] - dw * fo[0], bx.x + bx.w - dw, bx.x) : bx.x + (bx.w - dw) / 2, iy = fit === 'cover' ? clamp(bx.y + bx.h * fo[1] - dh * fo[1], bx.y + bx.h - dh, bx.y) : bx.y + (bx.h - dh) / 2;+ s.f = { x: ix, y: iy, w: dw, h: dh };+ const bcx = bx.x + bx.w / 2, bcy = bx.y + bx.h / 2; s.base = { x: W / 2, y: H / 2, z: 1 }; s.events = []; let zoomed = false;+ for (const qh of ctx.of('highlight')) {+ if (qh.at < s.start || qh.at >= s.next || !qh.data || !qh.data.rect) continue;+ const R = CLIP.sub(qh.data.rect, s.f), fill = qh.data.fill || 0.42, z = clamp(Math.min(bx.w * fill / R.w, bx.h * fill / R.h), 1.18, 2.6); // 下限 18%;框太小时最多推到 2.6 倍+ const tx = R.x + R.w / 2 - (bcx - W / 2) / z, ty = R.y + R.h / 2 - (bcy - H / 2) / z; // 框中心落到内容框中心(让开 safe)+ s.events.push({ at: qh.at, kind: 'to', x: tx, y: ty, z, dur: zoomed ? MO.PULSE.pan : MO.PULSE.punch });+ zoomed = true;+ }+ }// 截图卡的版式:标题行 + 截图区;截图区按截图比例定。竖图在横屏里改成「左字右图」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;+ for (const s of slides) if (s.type === 'img' && !s.full) {+ const cd = s.cards[0], [iw0, ih0] = MD.size(cd.im), ar = iw0 / ih0;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 };@@ -77,7 +97,8 @@ return {const { W, H, u, data: d } = ctx, acc = d.accent || '#3d6bff';// ---- 底:光斑(只依赖片段时间,连续) ----let bd = null;- if (!ctx.alpha) {+ const covered = slides.some(s => s.full && t >= s.start + (s.panIn ? MO.PULSE.pan : 0) - 1e-6 && t < s.next - 1e-6); // 满幅截图整屏盖住时不画光斑底(省 2/3 的渲染时间)+ if (!ctx.alpha && !covered) {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)');@@ -111,6 +132,7 @@ return {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.full) return drawFull(c, s, t, ctx, acc);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 张时的位置;新卡进来时旧卡按弹簧挪到新位置@@ -122,6 +144,50 @@ return {});},};+// 满幅截图一屏:底是同图的压暗模糊放大版(缓存一次),截图等比铺满内容框,镜头按 s.events 脉冲;左上角黑底撕边标签。+// 进场:上一屏也是满幅截图 → 同倍率横移 0.30s(at 这一帧露出第一条边);否则硬切+0.17s 轻砸。离场:下一屏是满幅截图就让它横移盖过来,否则在下一屏开始时硬切掉+function drawFull(c, s, t, ctx, acc) {+ const { W, H, u } = ctx, cd = s.cards[0], q = cd.q;+ if (t < s.start - 1e-6) return;+ const nx = slides[slides.indexOf(s) + 1], P = MO.PULSE;+ if (nx && t >= s.next + (s.panOut ? P.pan : 0) - 1e-6) return;+ const panIn = s.panIn ? MO.pulse(ctx.lt(t, s.start), 0, P.pan) : 1, panOut = s.panOut ? MO.pulse(ctx.lt(t, s.next), 0, P.pan) : 0;+ const dx = (1 - panIn) * W - panOut * W;+ const slam = s.panIn ? 1 : MO.slamK(ctx.lt(t, s.start) / P.slam, 1.06, 0.985);+ const cam = CAM.track(s.base, s.events, t), im = ctx.frame(q, t);+ c.save(); c.translate(dx, 0);+ if (!ctx.alpha) { c.fillStyle = '#0b0b0f'; c.fillRect(0, 0, W, H); }+ CAM.with(c, { x: cam.x, y: cam.y, z: cam.z * slam }, g => {+ if (!ctx.alpha) { const bg = PAINT.cached('t2full_bg_' + slides.indexOf(s) + '_' + W + 'x' + H, W, H, gg => { gg.filter = 'blur(48px) brightness(0.42) saturate(0.8)'; MD.cover(gg, cd.im, { x: -80, y: -80, w: W + 160, h: H + 160, clip: false }); gg.filter = 'none'; });+ g.drawImage(bg, -W * 0.5, -H * 0.5, W * 2, H * 2); }+ const f = s.f;+ g.save(); g.shadowColor = 'rgba(0,0,0,.5)'; g.shadowBlur = 40 * u; g.shadowOffsetY = 14 * u; g.fillStyle = '#000'; g.fillRect(f.x, f.y, f.w, f.h); g.restore();+ if (s.geo.fit === 'cover') MD.cover(g, im, { ...s.geo.box, fx: s.geo.fx, fy: s.geo.fy });+ else g.drawImage(im, f.x, f.y, f.w, f.h);+ hlOn(g, cd, f, t, ctx, acc, u, s.next);+ });+ // 标签:屏幕层,不跟镜头;压在内容框左下角(截图自己的标题多在上面,不挡它),at 这一帧出现、12fps 打字+ const size = (ctx.portrait ? 54 : 46) * u, ss = size * 0.66, lx = ctx.box.x + 56 * u, yb = ctx.box.y + ctx.box.h - (ctx.portrait ? 110 : 60) * u;+ const ySub = yb - ss * 0.75, yMain = q.sub ? ySub - ss * 0.75 - 12 * u - size * 0.75 : yb - size * 0.75;+ if (q.text) MD.label(c, q.text, lx, yMain, { t, at: q.at, size });+ if (q.sub) MD.label(c, q.sub, lx, q.text ? ySub : yb - ss * 0.75, { t, at: q.at + (q.text ? 0.25 : 0), size: ss, fam: 'PuHui-Bold', bg: acc, fg: '#ffffff' });+ c.restore();+}+// 截图上的 highlight:at 这一帧框开始弹出,其余压暗,一道光扫过框内;只认落在这一屏在屏期间的 highlight+function hlOn(g, cd, f, t, ctx, acc, u, until) {+ const q = cd.q;+ for (const qh of ctx.of('highlight')) {+ if (qh.at < q.at || qh.at >= until || !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.85; 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 cardGeoImg(cd, ctx) { return { cx: ctx.W / 2, cy: G.cy, w: cd.box.w, h: cd.box.h, focus: 1 }; }// 无图卡:横屏排一行(1 张时宽一点),竖屏叠成一列;total = 这一屏最终有几张(排版按当前张数,但尺寸上限按最终张数,挪位时不忽大忽小)@@ -135,8 +201,8 @@ function rowGeo(j, n, ctx, total) {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 Bw = geo.w, Bh = geo.h, cx = geo.cx - leave * ctx.W * 0.35, cy = geo.cy + (1 - sp) * 170 * u; // 落定后停住:不漂浮、不摇+ const sc = (0.9 + 0.1 * sp) * (1 - 0.12 * leave) * lerp(0.97, 1, geo.focus), ry = (1 - sp) * -0.45 - 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;@@ -177,23 +243,13 @@ function imgContent(g, cd, Bw, Bh, t, ctx, acc) {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);+ const [iw, ih] = MD.size(cd.im), f = CLIP.fit(iw, ih, 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.save(); g.beginPath(); g.roundRect(f.x, f.y, f.w, f.h, 10 * u); g.clip(); g.drawImage(ctx.frame(q, t), 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)+ // 框出重点(和满幅模式同一套):只认落在这张卡在屏期间的 highlightconst 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(); }- }+ hlOn(g, cd, f, t, ctx, acc, u, nxAt);}// 无图功能卡的内容:图标(或步骤号)→ 大标题 → 说明 →(可选)大数字计数。横屏竖卡上下排,竖屏横卡左右排function featContent(g, cd, Bw, Bh, lt, t, ctx, acc) {diff --git a/scripts/engine/clips/y1_kurzgesagt.js b/scripts/engine/clips/y1_kurzgesagt.jsindex 9fab4ad..9404f87 100644--- a/scripts/engine/clips/y1_kurzgesagt.js+++ b/scripts/engine/clips/y1_kurzgesagt.js@@ -1,16 +1,30 @@-// 片段 · Kurzgesagt 式扁平科普(y1):深靛紫夜空、发光的扁平星球=要讲的那个概念;每个要点是一颗卫星节点,-// 带标签胶囊弹出(过冲 108%)、信号沿连线流动;画面永远有东西在轻轻动(星闪、浮动、光晕呼吸、相机慢推)。-// 招牌是尺度穿行:enter 让相机对数推进一颗卫星,推到它的颜色填满整屏,再从同色的新星球里拉出来——「里面是什么」。+// 片段 · Kurzgesagt 式扁平科普(y1):深靛紫夜空、发光的扁平中心物=要讲的那个概念;每个要点是一颗卫星节点,+// 带标签胶囊弹出(过冲 108%)、信号沿连线流动。环境层(星闪、粒子、信号脉冲)一直轻轻动;中心物、节点、标签落定后停住,+// 相机不慢推:只在 highlight 这一刻快推 0.28s(推近约 30%)、连着的 highlight 同倍率横移 0.30s,然后停住。+// 招牌是尺度穿行:enter 让相机对数推进一颗卫星,推到它的颜色填满整屏,再从同色的新中心物里拉出来——「里面是什么」。// cues:title(顶部标题逐字上浮;text)· point(当前这一层的一个卫星节点+标签:text;data.color 换强调色)// highlight(相机推近第 data.index 个节点(只数当前这一层的 point,从 0 起;默认最新),其余节点和标签变暗;1.2s 推完)-// enter(钻进第 data.index 个节点(默认最新):推进→满屏同色→从新的中心星球拉出;text = 新中心的名字(默认用那个节点的名字);+// enter(钻进第 data.index 个节点(默认最新):推进→满屏同色→从新的中心物拉出;text = 新中心的名字(默认用那个节点的名字);// 之后的 point 都是新这一层的卫星;dur 默认 1.6s,at 这一帧开始推)-// data.center:第一层中心星球的名字。data.flow:true:节点按顺序串成一条链(中心→1→2→3),信号依次流过,节点带序号——讲「先后」时用。+// data.center:第一层中心物的名字。data.center_style:{ color, shape: 'circle'|'rounded'|'hex'|'diamond', ring: true(加一道轨道环)},+// 不写就按名字生成一个中性样式(颜色、形状由文字决定,同名同样式;没有轨道环)。data.image:中心物里放一张图(截图、照片,按形状裁),名字改到下方胶囊里。+// 新一层(enter 钻进去的)中心物用那个节点的颜色,形状同样按名字生成;enter 的 data.style 可覆盖。+// 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 P = { sky: ['#05020F', '#0E0631', '#2a1a6e'], star: '#F9FCFB', line: 'rgba(125,211,220,.35)', pulse: '#32BAEE' };const ACC = ['#32BAEE', '#FACC12', '#BE3A95', '#5CD0B3', '#FC6255', '#8A6CF0'];+// 中心物的中性样式:按名字哈希取色和形状(同名同样式),没有轨道环+const CPAL = ['#4F86C6', '#3FA796', '#8A6CF0', '#D9667A', '#5BA4CF', '#6FAF5A'], SHAPES = ['circle', 'rounded', 'hex'];+const hashStr = s => { let h = 2166136261; for (const ch of String(s)) h = Math.imul(h ^ ch.codePointAt(0), 16777619); return h >>> 0; };+const styleFor = (name, over = {}, col) => { const h = hashStr(name || '·'); return { color: over.color || col || CPAL[h % CPAL.length], shape: over.shape || SHAPES[(h >>> 8) % SHAPES.length], ring: !!over.ring }; };+const shapePath = (kind, x, y, R) => { const p = new Path2D();+ if (kind === 'rounded') p.roundRect(x - R * 0.92, y - R * 0.92, R * 1.84, R * 1.84, R * 0.36);+ else if (kind === 'hex') for (let i = 0; i <= 6; i++) { const a = Math.PI / 6 + i * Math.PI / 3; i ? p.lineTo(x + Math.cos(a) * R * 1.06, y + Math.sin(a) * R * 1.06) : p.moveTo(x + Math.cos(a) * R * 1.06, y + Math.sin(a) * R * 1.06); }+ else if (kind === 'diamond') { p.moveTo(x, y - R * 1.2); p.lineTo(x + R * 1.2, y); p.lineTo(x, y + R * 1.2); p.lineTo(x - R * 1.2, y); p.closePath(); }+ else p.arc(x, y, R, 0, Math.PI * 2);+ return p; };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 {@@ -24,7 +38,8 @@ return {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: [] }];+ const cs0 = styleFor(ctx.data.center || '', ctx.data.center_style || {});+ levels = [{ start: 0, center: ctx.data.center || '', col: cs0.color, style: cs0, img: ctx.data.image ? ctx.IMG[ctx.data.image] : null, pts: [], hls: [] }];for (const q of ctx.cues) {const L = levels[levels.length - 1];if (q.kind === 'point') L.pts.push(q);@@ -40,17 +55,16 @@ return {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 }];+ 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) || '';+ N.style = styleFor(N.center, (L.exit.q.data && L.exit.q.data.style) || {}, N.col); N.col = N.style.color; }+ // 本层的镜头:停住;highlight 这一刻快推 0.28s 到节点(推近约 30%,目标点往中心物偏一点,中心不被裁掉太多),+ // 已经推近时下一次 highlight 同倍率横移 0.30s 到新节点;之后停住+ const Z = ctx.portrait ? 1.28 : 1.32; L.events = []; let zoomed = false;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;+ L.events.push(zoomed ? { at: h.at, kind: 'pan', x: lerp(nd.x, cx, 0.35), y: lerp(nd.y, cy, 0.35) } : { at: h.at, kind: 'to', x: lerp(nd.x, cx, 0.35), y: lerp(nd.y, cy, 0.35), z: Z });+ zoomed = true; 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) {@@ -69,19 +83,19 @@ return {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;+ 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 * 0.84) * 1.15; // 0.84:菱形、六边形的内切圆比 R 小,也要盖满屏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;+ const base = CAM.track({}, L.events, 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);+ return CAM.track({}, L.events, t);}function drawLevel(c, k, t, ctx) {const { W, H, u } = ctx, L = levels[k], cam = camAt(L, t, ctx), { cx, cy, R } = S;@@ -91,7 +105,7 @@ function drawLevel(c, k, t, ctx) {}// 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; // 刚钻进来:先是满屏纯色,名字和环在拉出后半段才出来+ const col = L.col, st = L.style, 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) => {@@ -103,18 +117,23 @@ function drawLevel(c, k, t, ctx) {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 }); // 名字放进星球里:先缩字号,再折两行+ // 中心物:双色分面+柔光(形状、颜色来自 data.center_style 或按名字生成);可选轨道环;有 data.image 就把图裁进形状里+ const shape = shapePath(st.shape, cx, cy, R);+ TOON.glow(g, cx, cy, R * 2.4, light(col), 0.28);+ TOON.flat(g, shape, col, dark(col), light(col), [-18 * u, 14 * u], [-6 * u, 5 * u]);+ if (L.img) { g.save(); g.clip(shapePath(st.shape, cx, cy, R * 0.9)); MD.cover(g, L.img, { x: cx - R, y: cy - R, w: 2 * R, h: 2 * R }); g.restore(); }+ if (st.ring) { 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 && !L.img) { 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(); }+ f.lines.forEach((ln, i) => g.fillText(ln, cx, cy + (i - (f.lines.length - 1) / 2) * f.size * 1.1)); g.restore(); }+ else if (L.center) { const f = TY.fit(g, L.center, R * 3, 44 * u, 'PuHui-Heavy', { maxLines: 1, min: 0.6 }); // 有图:名字放到下方白胶囊里+ g.save(); g.globalAlpha = pull; g.font = `${f.size}px "PuHui-Heavy"`; const tw = g.measureText(f.lines[0] || '').width, bw = tw + 56 * u, bh = f.size * 1.6, by = cy + R * 1.12;+ g.fillStyle = '#ffffff'; g.beginPath(); g.roundRect(cx - bw / 2, by, bw, bh, bh / 2); g.fill(); g.fillStyle = '#1f1a3a'; g.textAlign = 'center'; g.textBaseline = 'middle'; g.fillText(f.lines[0] || '', cx, by + bh / 2 + 2 * u); 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);+ const pop = MO.backOut(clamp(l / 0.5), 1.1), fy = 0, 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]);diff --git a/scripts/engine/clips/y2_vox.js b/scripts/engine/clips/y2_vox.jsindex 350eabd..3abe6af 100644--- a/scripts/engine/clips/y2_vox.js+++ b/scripts/engine/clips/y2_vox.js@@ -1,9 +1,11 @@// 片段 · Vox 式拼贴(y2):一张大桌面=世界,素材按出场顺序摆在桌上、红线连起来;相机 60fps 平滑追过去,// 桌上的东西(滑入、荧光笔、红圈、打字)按 12fps「一拍二」步进。-// cues:image | clip(截图/照片/剪报:image 路径;text 可选=贴在下方的黑底标签;data.halftone:true 转成灰度网点,默认保留原色;at 这一帧开始滑入)+// cues:image | clip(截图/照片/剪报:image 路径,或 frames 录像帧序列;冲印件(白边、旧纸色、胶带,MD.print);text 可选=压在左下角的黑底撕边标签(12fps 打字);+// data.halftone:true 转成灰度网点,默认保留原色;data.fit:'cover' 按 data.focus=[fx,fy] 裁成 data.aspect(默认 16:9 / 竖屏 4:5)满框,默认等比不裁;at 这一帧开始滑入)// title(Borders 式黑底白字标签条,打字 13 字/秒)· point(横线索引卡,打字)// highlight(当前这张图上 data.rect=[x,y,w,h](0..1,相对图片):at 起荧光笔扫过 → 红笔圈住 → 相机推近那一块)-// 截图等比放(不裁),只加纸白边和胶带;横屏素材左→右排、竖屏上→下排,相机沿红线追(长尾缓动+短运动模糊)。+// 照片和截图是主角:镜头停在一张上时它占画面八九成(横屏宽 ≈90%、或高 ≈86%)。横屏素材左→右排、竖屏上→下排;+// 镜头是脉冲:在下一件的 at 之前 0.30s 横移过去(红线先描出去、镜头再追),highlight 这一刻快推 0.28s 到那一块,其余时间停住,不慢推。CLIPS.y2_vox = (() => {const { clamp, lerp, rng } = U;const C = { desk: '#e4ddcf', ink: '#171716', red: '#b8433f', paper: '#eeedeb', card: '#f6f4ee' };@@ -20,9 +22,10 @@ return {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);+ const im = ctx.still(q); if (!im) continue;+ const [iw, ih] = MD.size(im), cov = q.data && q.data.fit === 'cover', ar = cov ? (q.data.aspect || (portrait ? 0.8 : 16 / 9)) : iw / ih;+ const bw = W * (portrait ? 0.86 : 0.78), bh = H * (portrait ? 0.5 : 0.76), f = CLIP.fit(ar, 1, 0, 0, bw, bh);+ w = f.w + 32 * u; h = f.h + 32 * u;} else {if (!String(q.text ?? '').trim()) { console.warn(`y2 ${q.kind} at=${q.at}:text 是空的,这张卡跳过`); continue; } // 空卡宽度是 −Infinity,撕边点列会死循环size = (kind === 'title' ? 64 : 48) * u;@@ -50,7 +53,7 @@ return {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);+ const zFor = it => it.kind === 'image' ? clamp(Math.min(W * 0.9 / it.w, Hs * 0.86 / it.h), 0.5, 2.4) : 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);@@ -59,11 +62,11 @@ return {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 }); }+ else { const P = MO.PULSE.pan, t0 = Math.max(last.t + 0.05, e.at - P - 1 / ctx.FPS), t1 = t0 + P; // 横移 0.30s,at 前一帧到位(上一个动作没走完就接着走)+ keys.push({ t: t0, x: last.x, y: last.y, z: last.z }); keys.push({ t: t1, ...tgt, ease: MO.cubicInOut }); }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 R = e.h.data.rect, ib = imgBox(curItem, 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 时手抖的圈和运动模糊仍会出画)@@ -72,13 +75,13 @@ return {// 框的起点(荧光笔从左缘扫起)在当前镜头里看得见:先画、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 });+ const P = MO.PULSE.punch, t0 = inView ? Math.max(last.t + 0.05, e.at + 0.2) : Math.max(last.t + 0.05, e.at - P - 1 / ctx.FPS), t1 = t0 + P; // 快推 0.28s+ keys.push({ t: t0, x: last.x, y: last.y, z: last.z }); keys.push({ t: t1, x: cx, y: cy, z, ease: MO.cubicInOut });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 慢推+ 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, ease: MO.linear }); // 最后一个动作之后停住},draw(c, t, ctx) {const { W, H, u } = ctx, cam = CAM.at(keys, t);@@ -103,18 +106,16 @@ return {}},};-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 imgBox(it, u) { return { x: 16 * u, y: 16 * u, w: it.w - 32 * u, h: it.h - 32 * u }; } // 冲印件里图片的矩形(相对冲印件左上角)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); }+ const f = imgBox(it, u), fr = ctx.frame(q, t), cov = q.data && q.data.fit === 'cover', fo = (q.data && q.data.focus) || [0.5, 0.5];+ let src = fr;+ if (q.data && q.data.halftone) { const hs = PAINT.canvas(Math.round(f.w), Math.round(f.h)); MD.cover(hs.getContext('2d'), fr, { x: 0, y: 0, w: hs.width, h: hs.height, fit: cov ? 'cover' : 'contain', fx: fo[0], fy: fo[1] }); src = CL.halftone('clipimg' + it.seed + (q.frames ? '_' + Math.floor((t - q.at) * (q.fps || 30)) : ''), hs, { cell: 5 * u, contrast: 1.25 }); }+ MD.print(g, src, f.w, f.h, { border: 16 * u, fx: fo[0], fy: fo[1], tape: true, key: q.frames ? null : 'y2print' + it.seed }); // 冲印件:白边、旧纸色、投影、胶带+ if (q.text) { const fs = TY.fit(g, q.text, w * 0.8, 40 * u, 'PuHui-Heavy', { maxLines: 1, min: 0.5 }); // 黑底撕边标签压在左下角,12fps 打字+ MD.label(g, q.text, -w / 2 - 14 * u, h / 2 - 34 * u, { t, at: q.at + 0.25, size: fs.size, r: -0.02, bg: C.ink, fg: C.paper }); }// 高亮:荧光笔(multiply,一拍二扫过)→ 红笔圈for (const hq of ctx.of('highlight')) {if (!hq.data || !hq.data.rect || hq.at < q.at) continue;diff --git a/scripts/engine/clips/y4_storytime.js b/scripts/engine/clips/y4_storytime.jsindex 4b8765f..91fe9b7 100644--- a/scripts/engine/clips/y4_storytime.js+++ b/scripts/engine/clips/y4_storytime.js@@ -1,9 +1,15 @@-// 片段 · 故事型简笔角色(y4,storytime):豆子花叔在小房间里对镜头讲,姿势快切(0.1s)后定住,笑点靠反应特写和插入镜头。-// cues:point | title(他说一句:at 这一帧气泡弹出、开始张嘴;嘴按 text 的字数说 ≈6.5 字/秒;data.pose 指定姿势 talk/point/shrug/type)+// 片段 · 故事型简笔角色(y4,storytime):一个豆子角色在小房间里对镜头讲,姿势快切(0.1s)后定住,笑点靠反应特写和插入镜头。+// 镜头不慢推、不手持漂、角色不呼吸:定住就是定住,变化靠快切、跳近(反应特写砸进来)和插入镜头。+// data.character:'neutral'(默认:短发、蓝 T)| 'bun'(丸子头)| 'author'(本 skill 作者的卡通形象,只在讲作者自己的故事时显式写)+// | 造型对象 {base, skin, hair, shirt, pants, hairStyle, hat, glasses, watch}(见 TOON.LOOKS)+// | 帧库:render.py 里写一个目录(文件名去扩展名 = 姿势名),或 {frames: {rest, talk, point, shrug, type, stiff, react, back, <姿势>_open: 路径}}+// 至少要有 rest 或 talk;缺的姿势退到 talk → rest;<姿势>_open 是张嘴帧(说话时一拍二换);react 是反应特写,back 是插入镜头前景的后脑勺。+// 帧图要透明底、角色脚底在图片底边中间,画出来高 ≈ 3.15 个头半径。+// 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 的回复像代码墙一样越滚越快,+// insert(插入镜头:at 这一帧切到桌上那台电脑的屏幕特写——sub = 角色打的那一行(打字、发送),之后 AI 的回复像代码墙一样越滚越快,// text = 砸出来的大字(如「3000行」),在 data.hit(绝对秒,默认 at+1.3,没有 sub 时 at+0.4)砸出、屏幕一震;// data.count + data.unit 让右上角计数器在砸出那一刻停在这个数;dur 默认到下一个 cue)// 房间里有桌上的电脑(插入镜头切进去的就是它的屏幕)、马克杯、墙上的书架和绿植,右边不再是空墙。@@ -16,12 +22,16 @@ const COLS = ['#C792EA', '#82AAFF', '#C3E88D', '#F78C6C', '#89DDFF', '#FFCB6B',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;+let keys, says, L, shots, LOOK, FR;return {fonts: ['PuHui-Bold', 'PuHui-Black'],safe: true,init(ctx) {- const { W, H, u } = ctx;+ const { W, H, u } = ctx, ch = ctx.data.character;+ // 角色:帧库(对象带 frames)或造型(预设名 / 造型对象)。帧图已由 clip.js 加载,缺图在启动时就失败+ FR = ch && typeof ch === 'object' && ch.frames ? Object.fromEntries(Object.entries(ch.frames).map(([k, v]) => [k, ctx.IMG[v]])) : null;+ if (FR && !FR.rest && !FR.talk) console.error('y4 data.character.frames 至少要有 rest 或 talk 一张');+ LOOK = FR ? TOON.look('neutral') : TOON.look(ch);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、宽高)@@ -41,21 +51,21 @@ return {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);+ // 镜头:中景定住;反应=同机位跳到 1.9 倍大特写(砸镜:前 0.3s 从 2.2 弹回,之后定住)+ let z = 1, 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))); cy = L.fy - L.R * 2.2; }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 => {+ CAM.with(c, { x: inReact ? L.cx : W / 2, y: inReact ? cy : H / 2, 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 });+ const blink = TOON.blinkAt(ts, [0.9, 3.4, 6.1, 8.8, 11.5]);+ const info = FR ? frameChar(g, ts, st, inReact, mouth)+ : TOON.bean(g, { char: LOOK, 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, bob: mouth * L.R * 0.015, tilt: st.expr === 'worry' ? -0.06 : 0, 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(); }+ g.save(); g.translate(info.head[0] + L.R * 1.35, info.head[1] - L.R * 0.6); g.rotate(0.14 + MO.settle(l, 0.12, 3, 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) {@@ -77,6 +87,15 @@ return {}},};+// 帧库角色:按当前姿势名取帧(缺的退到 talk → rest),说话时一拍二换 <姿势>_open;换姿势那一下沿用 poseAt 的挤压回弹+function frameChar(g, ts, st, inReact, mouth) {+ let name = 'rest'; for (const k of keys) if (ts >= k[0]) name = k[1];+ if (inReact) name = 'react';+ const pick = n => FR[n] || FR.talk || FR.rest;+ const im = (!inReact && mouth && FR[name + '_open']) || pick(name), [iw, ih] = MD.size(im), h = L.R * 3.15, w = iw * h / ih;+ g.save(); g.translate(L.cx, L.fy); g.scale(1 / Math.sqrt(st.squash), st.squash); g.drawImage(im, -w / 2, -h, w, h); g.restore();+ return { head: [L.cx, L.fy - h * 0.78], hl: [L.cx - w * 0.4, L.fy - h * 0.45], hr: [L.cx + w * 0.4, L.fy - h * 0.45] };+}// 房间:墙、地、窗(慢飘的云)、书架、画框。只画一次的东西不缓存——片段短,画得起function room(g, t, ctx) {const { W, H, u } = ctx, X0 = -W, Y0 = -H, fy = L.fy;@@ -118,7 +137,7 @@ function insert(c, t, ctx, shot) {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(像推过去的一下)+ const zoom = 1.06 - 0.06 * MO.expoOut(clamp(lt / 0.25)) + (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 => {@@ -154,15 +173,21 @@ function insert(c, t, ctx, shot) {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;+ // 前景:角色的后脑勺(过肩),定住;砸出时往后一缩。造型跟 data.character 走(帧库给了 back 就贴那张)+ const hx = W * (ctx.portrait ? 0.2 : 0.17), hy = by + bh - 60 * u + (slam > 0 ? -MO.settle(slam, 18 * u, 4, 7) : 0), s = (ctx.portrait ? 0.8 : 0.75) * u;+ if (FR && FR.back) { const [iw, ih] = MD.size(FR.back), h = 560 * s, w = iw * h / ih; c.drawImage(FR.back, hx - w / 2, hy + 500 * s - h, w, h); return; }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();+ c.fillStyle = LOOK.shirt; c.beginPath(); c.ellipse(0, 300, 330, 200, 0, Math.PI, 0); c.fill(); c.stroke();+ c.fillStyle = LOOK.skin; 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();+ if (LOOK.hat) {+ c.fillStyle = LOOK.hair; 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();+ } else { // 没帽子:整个后脑勺是头发(丸子头再加一个丸子)+ c.fillStyle = LOOK.hair; c.beginPath(); c.ellipse(0, 20, 196, 200, 0, 0, 7); c.fill(); c.stroke();+ if (LOOK.hairStyle === 'bun') { c.beginPath(); c.arc(0, -190, 70, 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.jsindex e18f941..0a11fab 100644--- a/scripts/engine/clips/y5_kinetic_type.js+++ b/scripts/engine/clips/y5_kinetic_type.js@@ -44,8 +44,8 @@ return {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); });+ // 镜头不漂不晃:落定就停,运动只在拍点上(上面的微冲、主词砸入、换页色带)+ CAM.with(c, { x: W / 2, y: H / 2, z: bump }, cc => { ghost(cc, P, t, ctx); page(P, cc); });track(c, P, t, ctx);}// 换页:两条色带从左扫到右,最后一条后面露出新页(露出那一帧=新页的 show 时刻)diff --git a/scripts/engine/demos/y4_storytime/s3_react.js b/scripts/engine/demos/y4_storytime/s3_react.jsindex 40c011e..db28572 100644--- a/scripts/engine/demos/y4_storytime/s3_react.js+++ b/scripts/engine/demos/y4_storytime/s3_react.js@@ -20,7 +20,7 @@ SCENES['s3_react'] = {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 });+ const info = TOON.bean(c, { char: 'author', 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) {diff --git a/scripts/engine/demos/y4_storytime/world.js b/scripts/engine/demos/y4_storytime/world.jsindex a279f1e..d51b39d 100644--- a/scripts/engine/demos/y4_storytime/world.js+++ b/scripts/engine/demos/y4_storytime/world.js@@ -53,7 +53,7 @@ S.world = (c, t, ch) => {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 });+ const info = TOON.bean(c, { x: 860, y: 760, s: 165, char: 'author', ...ch }); // 示范片讲的是作者自己的经历,显式用作者造型(TOON.bean 默认是中性角色)c.drawImage(front(), X0, Y0);// 笔记本(背面朝镜头、斜对着他),屏幕光打在桌上,光随代码滚动微闪c.save(); c.lineWidth = S.bgLW; c.strokeStyle = C.bgLine; c.lineJoin = 'round';diff --git a/scripts/engine/engine.js b/scripts/engine/engine.jsindex c5d09b4..ee2f9dc 100644--- a/scripts/engine/engine.js+++ b/scripts/engine/engine.js@@ -1,8 +1,13 @@// 引擎:时间 t(秒)→ 一帧画面。确定性:同一个 t 永远画出同一帧(随机数全部用种子)。// 时间轴由节拍网格驱动:128 BPM,每段占若干八分音符(见 eras.js 的 eighths)。(() => {-const W = 1920, H = 1080;+// 画布尺寸:?w=1080&h=1920(render.py --width/--height 传)> eras.js 里的 window.FILM_SIZE = [w, h] > 1920×1080。+// 一次性 U.setStage:转场、相机和各库都跟着换;竖屏整片的场景代码要按 window.STAGE(或 CAM/UI 等库)排版,35 种艺术风格场景只按横屏画过。+const qs = new URLSearchParams(location.search), qw = +qs.get('w'), qh = +qs.get('h');+const [W, H] = qw > 0 && qh > 0 ? [qw, qh] : Array.isArray(window.FILM_SIZE) ? window.FILM_SIZE.map(Number) : [1920, 1080];+window.U.setStage(W, H);const cv = document.getElementById('c');+cv.width = W; cv.height = H; window.__size = [W, H];const ctx = cv.getContext('2d');window.__canvas = cv;@@ -29,12 +34,14 @@ async function boot() {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); }));+ try { await Promise.all([...list].map(async s => { IMG[s] = await load(s); })); }+ catch (src) { window.__bootFailed = `图片加载失败:${src}(段的 assets / plate / window.EXTRA_ASSETS 里点名的文件不存在或不是图片)`; console.error('BOOT FAILED\n' + window.__bootFailed); return; }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();+ await window.prepare(0); // 第 0 帧的视频帧先加载(缺帧在这里就报错)window.__ready = true;renderFrame(0);}@@ -193,7 +200,9 @@ function clipFrameUrl(e, lt) {}async function need(url) {if (FRAMES.has(url)) return;- const im = new Image(); im.src = url; await im.decode(); FRAMES.set(url, im);+ const im = new Image(); im.src = url;+ try { await im.decode(); } catch (e) { const msg = `视频帧缺失或解不开:${url}(clip.dir / n / in 对不上帧序列)`; console.error(msg); throw new Error(msg); }+ FRAMES.set(url, im);if (FRAMES.size > 240) { const k = FRAMES.keys().next().value; FRAMES.delete(k); }}function layersAt(t) {@@ -219,7 +228,10 @@ function drawEra(c, e, t, prev, punchFrom, noCounter) {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); }+ // 视频帧:等比铺满(MD.cover,不拉伸);段里写 clipDraw(c, frame, lt, t) 自己摆(推近、焦点、冲印件)。帧没准备好不许静默空白——直接报错+ if (e.clip) { const url = clipFrameUrl(e, lt), im = FRAMES.get(url);+ if (!im) throw new Error(`视频帧没加载:${url}(渲染前要先 await window.prepare(t);render.py 已经这么做,自己写的脚本也要)`);+ if (e.clipDraw) e.clipDraw(c, im, lt, t); else MD.cover(c, im); }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();@@ -261,5 +273,5 @@ 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); });+boot().catch(err => { window.__bootFailed = String(err && err.stack || err); console.error('BOOT FAILED\n' + window.__bootFailed); });})();diff --git "a/scripts/engine/examples/assets/\347\273\210\347\253\257_for\345\276\252\347\216\257\346\261\202\345\222\214.png" "b/scripts/engine/examples/assets/\347\273\210\347\253\257_for\345\276\252\347\216\257\346\261\202\345\222\214.png"new file mode 100644index 0000000..b291958Binary files /dev/null and "b/scripts/engine/examples/assets/\347\273\210\347\253\257_for\345\276\252\347\216\257\346\261\202\345\222\214.png" differdiff --git "a/scripts/engine/examples/assets/\347\273\210\347\253\257_sum\346\261\202\345\222\214.png" "b/scripts/engine/examples/assets/\347\273\210\347\253\257_sum\346\261\202\345\222\214.png"new file mode 100644index 0000000..4e33931Binary files /dev/null and "b/scripts/engine/examples/assets/\347\273\210\347\253\257_sum\346\261\202\345\222\214.png" differdiff --git a/scripts/engine/examples/t2_fullbleed_pulse.json b/scripts/engine/examples/t2_fullbleed_pulse.jsonnew file mode 100644index 0000000..7e63833--- /dev/null+++ b/scripts/engine/examples/t2_fullbleed_pulse.json@@ -0,0 +1,14 @@+{+ "grammar": "t2_keynote_ui",+ "duration": 8,+ "fps": 30,+ "width": 1920,+ "height": 1080,+ "cues": [+ { "at": 0.0, "kind": "card", "text": "for 循环累加", "sub": "一百万个整数", "image": "assets/终端_for循环求和.png" },+ { "at": 1.4, "kind": "highlight", "text": "318 毫秒", "data": { "rect": [0.292, 0.212, 0.115, 0.07] } },+ { "at": 3.2, "kind": "card", "text": "换成 sum()", "image": "assets/终端_sum求和.png" },+ { "at": 4.3, "kind": "highlight", "text": "20.9 毫秒", "data": { "rect": [0.292, 0.153, 0.128, 0.07] } },+ { "at": 6.4, "kind": "number", "text": "同一件事快了", "data": { "value": 15.2, "decimals": 1, "suffix": " 倍" } }+ ]+}diff --git a/scripts/engine/examples/t2_keynote_ui.json b/scripts/engine/examples/t2_keynote_ui.jsonindex d0c05d7..0f80645 100644--- a/scripts/engine/examples/t2_keynote_ui.json+++ b/scripts/engine/examples/t2_keynote_ui.json@@ -9,6 +9,6 @@{ "at": 1.8, "kind": "highlight", "data": { "rect": [0.648, 0.245, 0.104, 0.105] } },{ "at": 4.0, "kind": "card", "text": "竖屏换一套排版", "sub": "同一份数据", "image": "assets/营收图_竖屏.png" },{ "at": 6.6, "kind": "number", "text": "可换的动画语法", "data": { "value": 8, "suffix": " 种" } },- { "at": 8.0, "kind": "card", "text": "时长精确到帧", "sub": "帧数=时长×帧率", "data": { "icon": "clock" } }+ { "at": 8.0, "kind": "card", "text": "时长精确到帧", "sub": "帧数 = 时长 × 帧率", "data": { "icon": "clock" } }]}diff --git a/scripts/engine/index.html b/scripts/engine/index.htmlindex 257ad2d..c80fabb 100644--- a/scripts/engine/index.html+++ b/scripts/engine/index.html@@ -26,6 +26,7 @@ body.render #ui{display:none}<script src="lib/chart.js"></script><script src="lib/ui.js"></script><script src="lib/collage.js"></script>+<script src="lib/media.js"></script><script src="lib/toon.js"></script><script>// 选片子:默认 eras.js;?film=<名> → eras_<名>.js(如 ?film=gallery = 35 种风格样片);?film=demos/<名> → demos/<名>/eras.js(8 种 YouTube 语法示范)。diff --git a/scripts/engine/lib/brush.js b/scripts/engine/lib/brush.jsindex 5c2eead..1b993a9 100644--- a/scripts/engine/lib/brush.js+++ b/scripts/engine/lib/brush.js@@ -9,7 +9,7 @@// P.impasto(c, pts, w, col, hi) 厚涂鬃毛笔:一笔=若干平行细鬃(伦勃朗高光、梵高厚涂补笔)// P.cut(pts, seed, step, amp) 剪刀折线:沿轮廓每 step px 取点+抖动、直线相连(马蒂斯剪纸、剪影、木刻)(() => {-const W = 1920, H = 1080;+let W = 1920, H = 1080; U.onStage((w, h) => { W = w; H = h; }); // 画布尺寸跟 U.setStage 走(默认 1920×1080)const P = window.PAINT;const { clamp, lerp, rng, ss } = U;diff --git a/scripts/engine/lib/camera.js b/scripts/engine/lib/camera.jsindex fed99d4..3a9e0af 100644--- a/scripts/engine/lib/camera.js+++ b/scripts/engine/lib/camera.js@@ -44,6 +44,38 @@ CAM.at = (keys, t) => {return { ...keys[keys.length - 1] };};+// ---------- 脉冲镜头(解说片默认用它,不用匀速慢推) ----------+// 节奏:停住 → 快推 / 横移 / 砸入 → 停住;停多久按口播。时长在 MO.PULSE(快推 0.28s、横移 0.30s、砸入 0.17s)。+// CAM.track(base, events, t) → cam:base 是起始相机 {x, y, z};events 是按时间排的镜头动作,相机只由 t 算出来(确定性,可跳帧)。+// 每个动作从「上一个动作结束时的相机」出发,到 at + dur 落定;两个动作挨太近(上一个没走完下一个就开始)时,下一个从上一个此刻的位置接着走。+// {at, kind: 'punch', k?, x?, y?, dur?} 快推:z 乘以 (1+k)(k 默认 0.25;横竖屏都写 0.18–0.32);给 x, y 就同时把这个世界点移到画面中心,+// 不给就绕当前画面中心推。k 可以写负数(快拉,回到上一档)。+// {at, kind: 'pan', x, y, dur?} 同倍率横移:缩放不变,画面中心移到世界点 (x, y)。同一面「墙」上从一件证据移到下一件。+// {at, kind: 'to', x?, y?, z?, dur?, ease?} 推到指定相机(推近截图上的一块:z 用 MD.zoomFor 算);dur 默认 0.28。+// {at, kind: 'slam', dur?, from?} 整帧砸入:z 额外乘 MO.slamK(1.55→0.94→1.0,0.17s)。镜头切到新画面那一帧用。+// {at, kind: 'shake', amp?, dur?} 震镜:dur(默认 4 帧 ≈ 0.13s)内上下抖 amp 像素(默认 14),和砸入、盖章同帧用,一支片子别超过两次。+// {at, kind: 'cut', x?, y?, z?} 硬切到这台相机(不过渡)。+// 返回的 cam 带 moving: true/false(这一刻是否在运动),给运动模糊、标签显隐用。+CAM.track = (base, events, t) => {+ let cam = { x: base.x ?? W / 2, y: base.y ?? H / 2, z: base.z ?? 1 }, zMul = 1, dy = 0, moving = false;+ const evs = [...events].sort((a, b) => a.at - b.at);+ for (const e of evs) {+ if (t < e.at) break;+ const P = MO.PULSE, kind = e.kind || 'punch';+ if (kind === 'cut') { cam = { x: e.x ?? cam.x, y: e.y ?? cam.y, z: e.z ?? cam.z }; continue; }+ if (kind === 'slam') { const d = e.dur || P.slam, k = (t - e.at) / d; if (k < 1) { zMul *= MO.slamK(k, e.from); moving = true; } continue; }+ if (kind === 'shake') { const d = e.dur || 4 / 30, k = (t - e.at) / d; if (k < 1) { dy += (e.amp ?? 14) * Math.sin(k * Math.PI * 4) * (1 - k) / cam.z; moving = true; } continue; }+ const d = e.dur || (kind === 'pan' ? P.pan : P.punch), p = (e.ease || MO.cubicInOut)(clamp((t - e.at) / d));+ let to;+ if (kind === 'pan') to = { x: e.x ?? cam.x, y: e.y ?? cam.y, z: cam.z };+ else if (kind === 'to') to = { x: e.x ?? cam.x, y: e.y ?? cam.y, z: e.z ?? cam.z };+ else to = { x: e.x ?? cam.x, y: e.y ?? cam.y, z: cam.z * (1 + (e.k ?? P.k)) };+ if (p < 1) moving = true;+ cam = { x: lerp(cam.x, to.x, p), y: lerp(cam.y, to.y, p), z: CAM.zlerp(cam.z, to.z, p) };+ }+ return { x: cam.x, y: cam.y + dy, z: cam.z * zMul, moving };+};+// ---------- 视差 ----------// 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(); };@@ -56,6 +88,6 @@ 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] 像素+// 手持感微漂:两路不同周期的正弦(连续时间,不闪),返回 [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/kit.js b/scripts/engine/lib/kit.jsindex c4de23b..e0790d7 100644--- a/scripts/engine/lib/kit.js+++ b/scripts/engine/lib/kit.js@@ -1,7 +1,7 @@// 跨场景共用的小工具:点列加密/等弧长重采样、可变线宽路径 ribbon、整幅行/列扭曲、手绘不规则圆、全片连续编舞、近侧手臂补盖、角标。// 渲染器在 lib/brush.js(笔与水)、lib/render.js(网点/点彩/赛璐珞/光影/皮影)、lib/post.js(VHS/胶片/泛光/纹理叠角色)。(() => {-const W = 1920, H = 1080;+let W = 1920, H = 1080; U.onStage((w, h) => { W = w; H = h; }); // 画布尺寸跟 U.setStage 走(默认 1920×1080)const { clamp, lerp, rng } = U;const K = window.KIT = {};diff --git a/scripts/engine/lib/media.js b/scripts/engine/lib/media.jsnew file mode 100644index 0000000..8f2766e--- /dev/null+++ b/scripts/engine/lib/media.js@@ -0,0 +1,109 @@+// 真实素材 MD:把截图、照片、录像帧放进画面当主体。解说片里有真实素材就让它满幅当主画面,代码负责解释、标注和运镜。+// 出处:两支被认可的片子——一支把照片满幅铺开再按口播节点快推(cover),一支把照片冲印成带白边的件摆在调查桌上、配黑底撕边标签。+// 约定:素材缺失一律报错(throw → render.py / qa.py 判失败),不静默画空白;所有参数由调用方用时间算好传进来,本库不读时钟。+//+// MD.size(src) 素材的像素尺寸 [w, h](图片 / 视频帧 / canvas 都行);缺失或没加载完 → throw+// MD.cover(c, src, o) → geo 满幅铺开:等比放大到盖满框(裁掉多出的边),按焦点裁、按 z 推近+// o = { x=0, y=0, w=画宽, h=画高(框), fx=.5, fy=.5(焦点,0..1 相对素材:裁切和推近都绕它), z=1(推近倍数,≥1),+// crop:[sx,sy,sw,sh](先取素材的这一块,0..1), fit:'cover'|'contain'(contain = 整张放进框里、不裁,留边), clip=true }+// 返回 geo = { x, y, w, h(素材在画面上的矩形), s(缩放), box },配 MD.toScreen 把素材上的点/框换算到画面+// MD.toScreen(geo, r) 素材上 0..1 的点 [u,v] 或框 [u,v,w,h] → 画面坐标([x,y] 或 {x,y,w,h})+// MD.focusFor(rect) → {fx, fy} 框 [u,v,w,h] 的中心当焦点+// MD.zoomFor(rect, iw, ih, bw, bh, fill=.6, fit='cover') → z 要让素材上的框 rect 占框宽/高的 fill,cover 之上还要推几倍(≥1)+// MD.print(c, src, w, h, o) 冲印件:白边+旧纸色+投影+胶带,原点在冲印件中心(调用方先 translate/rotate)+// o = { border=16·u, crop, fx, fy(按焦点 cover 进 w×h), tape=true, caption(白边下方小字), polaroid=false(底边加宽、caption 写在底边里),+// shadow=true, key(给了 key 且素材是静态图就缓存成位图)}+// MD.label(c, text, x, y, o) 黑底撕边标签:o = { size=48·u, fam='PuHui-Heavy', bg='#191817', fg='#f3efe6', align='left'|'center'|'right',+// t, at(at 这一帧出现:先 1.12 倍一拍再落定,字按 rate 字/秒、12fps 打出;不给 t 就直接画完整的), rate=14, r(旋转)}+// 返回 {w, h}+// MD.frameAt(frames, lt, fps=30, loop=false) 帧序列(图片数组)在片内时间 lt 的那一帧;缺帧 → throw+(() => {+let W = 1920, H = 1080; U.onStage((w, h) => { W = w; H = h; }); // 画布尺寸跟 U.setStage 走(默认 1920×1080)+const { clamp } = U;+const MD = window.MD = {};+const u0 = () => Math.min(W, H) / 1080;++MD.size = src => {+ if (!src) throw new Error('MD:素材缺失(图片没加载或路径写错)——不画空白帧');+ const w = src.videoWidth || src.naturalWidth || src.width, h = src.videoHeight || src.naturalHeight || src.height;+ if (!(w > 0 && h > 0)) throw new Error(`MD:素材尺寸是 0(还没加载完或解不开):${src.src || src.currentSrc || src}`);+ return [w, h];+};++MD.cover = (c, src, o = {}) => {+ const [iw0, ih0] = MD.size(src);+ const bx = o.x ?? 0, by = o.y ?? 0, bw = o.w ?? W, bh = o.h ?? H, fx = o.fx ?? 0.5, fy = o.fy ?? 0.5, z = Math.max(1e-3, o.z ?? 1);+ const cr = o.crop || [0, 0, 1, 1], sx = cr[0] * iw0, sy = cr[1] * ih0, iw = cr[2] * iw0, ih = cr[3] * ih0;+ const s0 = (o.fit === 'contain' ? Math.min : Math.max)(bw / iw, bh / ih), s = s0 * z, w = iw * s, h = ih * s;+ // 焦点:cover 时让焦点尽量落在框的同一相对位置(不露边);推近绕焦点+ const ax = bx + bw * fx, ay = by + bh * fy;+ let x = ax - w * fx, y = ay - h * fy;+ if (o.fit !== 'contain') { x = Math.min(bx, Math.max(bx + bw - w, x)); y = Math.min(by, Math.max(by + bh - h, y)); }+ else if (z <= 1) { x = bx + (bw - w) / 2; y = by + (bh - h) / 2; }+ c.save();+ if (o.clip !== false) { c.beginPath(); c.rect(bx, by, bw, bh); c.clip(); }+ c.drawImage(src, sx, sy, iw, ih, x, y, w, h);+ c.restore();+ return { x, y, w, h, s, box: { x: bx, y: by, w: bw, h: bh } };+};++MD.toScreen = (geo, r) => r.length === 2 ? [geo.x + r[0] * geo.w, geo.y + r[1] * geo.h]+ : { x: geo.x + r[0] * geo.w, y: geo.y + r[1] * geo.h, w: r[2] * geo.w, h: r[3] * geo.h };+MD.focusFor = r => ({ fx: r[0] + r[2] / 2, fy: r[1] + r[3] / 2 });+MD.zoomFor = (rect, iw, ih, bw = W, bh = H, fill = 0.6, fit = 'cover') => {+ const s0 = (fit === 'contain' ? Math.min : Math.max)(bw / iw, bh / ih), rw = rect[2] * iw * s0, rh = rect[3] * ih * s0;+ return Math.max(1, Math.min(bw * fill / rw, bh * fill / rh));+};++const printCache = {};+MD.print = (c, src, w, h, o = {}) => {+ const u = u0(), b = o.border ?? 16 * u, bot = o.polaroid ? Math.max(b * 4, h * 0.2) : b, PW = w + 2 * b, PH = h + b + bot;+ const paint = g => {+ g.fillStyle = '#f7f5ef'; g.fillRect(0, 0, PW, PH);+ const f = o.crop ? null : MD.focusFor([o.fx ?? 0.5, o.fy ?? 0.5, 0, 0]);+ MD.cover(g, src, { x: b, y: b, w, h, crop: o.crop, fx: f ? f.fx : 0.5, fy: f ? f.fy : 0.5 });+ g.save(); g.globalCompositeOperation = 'multiply'; g.fillStyle = 'rgba(214,205,185,.16)'; g.fillRect(0, 0, PW, PH); g.restore(); // 印在纸上:压一层旧纸色+ if (o.polaroid && o.caption) { g.save(); g.fillStyle = '#2b2925'; g.font = `${Math.min(bot * 0.42, 40 * u)}px "LXGWWenKai-500", "PuHui-Medium"`; g.textBaseline = 'middle'; g.fillText(o.caption, b * 1.2, b + h + bot / 2); g.restore(); }+ };+ MD.size(src);+ let sp;+ if (o.key && !(src instanceof HTMLVideoElement)) { const k = `${o.key}|${Math.round(PW)}x${Math.round(PH)}`; sp = printCache[k] || (printCache[k] = (() => { const cv = document.createElement('canvas'); cv.width = Math.ceil(PW); cv.height = Math.ceil(PH); paint(cv.getContext('2d')); return cv; })()); }+ c.save();+ if (o.shadow !== false) { c.shadowColor = 'rgba(30,22,10,.32)'; c.shadowBlur = 14 * u; c.shadowOffsetX = 3 * u; c.shadowOffsetY = 8 * u; }+ if (sp) c.drawImage(sp, -PW / 2, -PH / 2);+ else { c.translate(-PW / 2, -PH / 2); c.fillStyle = '#f7f5ef'; c.fillRect(0, 0, PW, PH); c.shadowColor = 'transparent'; paint(c); }+ c.restore();+ if (o.tape !== false && window.CL) { CL.tape(c, -w / 2 + 30 * u, -PH / 2 + 6 * u, -0.6, 110 * u); CL.tape(c, w / 2 - 30 * u, -PH / 2 + 6 * u, 0.55, 110 * u); }+ if (o.caption && !o.polaroid) { c.save(); c.font = `${22 * u}px "PuHui-Medium"`; c.fillStyle = 'rgba(40,36,30,.78)'; c.textBaseline = 'top'; c.fillText(o.caption, -PW / 2, PH / 2 + 10 * u); c.restore(); }+ return { w: PW, h: PH };+};++const labCache = {};+MD.label = (c, text, x, y, o = {}) => {+ text = String(text ?? ''); if (!text) return { w: 0, h: 0 };+ const u = u0(), size = o.size ?? 48 * u, fam = o.fam || 'PuHui-Heavy', bg = o.bg || '#191817', fg = o.fg || '#f3efe6';+ if (o.t != null && o.at != null && o.t < o.at) return { w: 0, h: 0 };+ c.save(); c.font = `${size}px "${fam}"`;+ const tw = c.measureText(text).width, padX = size * 0.42, w = Math.round(tw + padX * 2), h = Math.round(size * 1.5);+ const key = `${text}|${size}|${fam}|${bg}`;+ const sp = labCache[key] || (labCache[key] = (() => { const cv = document.createElement('canvas'); cv.width = w; cv.height = h; const g = cv.getContext('2d');+ if (window.CL) CL.tornRect(g, w, h, [...text].length * 7 + Math.round(size), 3 * u); else { g.beginPath(); g.rect(0, 0, w, h); }+ g.fillStyle = bg; g.fill(); return cv; })());+ const k = o.t != null && o.at != null ? MO.step(o.t - o.at + 1e-6, 12) : 1e9; // 一拍二:从 at 起算,at 这一帧就是第一帧+ const pop = k < 1 / 12 ? 1.12 : 1, ox = o.align === 'center' ? -w / 2 : o.align === 'right' ? -w : 0;+ c.translate(x, y); if (o.r) c.rotate(o.r); c.scale(pop, pop);+ c.drawImage(sp, ox, -h / 2);+ const n = o.t != null && o.at != null ? Math.ceil((k + 1 / 12) * (o.rate || 14)) : 1e9;+ c.fillStyle = fg; c.textBaseline = 'middle'; c.textAlign = 'left';+ c.fillText([...text].slice(0, n).join(''), ox + padX, size * 0.04);+ c.restore();+ return { w, h };+};++MD.frameAt = (frames, lt, fps = 30, loop = false) => {+ if (!frames || !frames.length) throw new Error('MD.frameAt:帧序列是空的');+ let i = Math.floor(Math.max(0, lt) * fps + 1e-6);+ i = loop ? i % frames.length : Math.min(frames.length - 1, i);+ const im = frames[i]; MD.size(im); return im;+};+})();diff --git a/scripts/engine/lib/motion.js b/scripts/engine/lib/motion.jsindex 55e4005..80d2ac8 100644--- a/scripts/engine/lib/motion.js+++ b/scripts/engine/lib/motion.js@@ -6,13 +6,7 @@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)); };+// 画布尺寸 U.setStage / U.onStage 在 util.js(比本文件先加载的 paint/brush/render/post 也要登记)。// ---------- 时间片 ----------MO.seg = (t, a, b) => clamp((t - a) / (b - a)); // [a,b] → 0..1@@ -89,7 +83,19 @@ MO.springHz = (t, freq = 2.5, decay = 9) => t <= 0 ? 0 : 1 - Math.exp(-decay * 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);+// ---------- 脉冲节奏(解说片的默认运动:停住 → 猛动 → 停住) ----------+// 出处:一支被判「像放 PPT」的片子(每镜匀速推近 7.5%)换成脉冲后被认可:快推 0.28s、同倍率横移 0.30s、砸入 0.17s,其余时间停住。+// 时长常量集中在这里,CAM.track / MD / 各片段都读它;要改节奏改这里,别在片段里另写一套。+MO.PULSE = { punch: 0.28, pan: 0.30, slam: 0.17, k: 0.25, kMin: 0.18, kMax: 0.32 };+// 砸入曲线:k = 0..1(砸入进度)→ 缩放。1.55 → 0.94(前 60%,3 帧砸下)→ 1.0(后 40%,2 帧回弹)。k≤0 返回 1.55(还没落下)。+MO.slamK = (k, from = 1.55, under = 0.94) => k <= 0 ? from : k < 0.6 ? from - (from - under) * (k / 0.6) : k < 1 ? under + (1 - under) * ((k - 0.6) / 0.4) : 1;+// 某个元素在 at 这一帧砸进来:返回它此刻的缩放(at 之前 = 0,元素还不该画)。o: {dur=0.17, from=1.55, under=0.94}+MO.slam = (t, at, o = {}) => t < at ? 0 : MO.slamK((t - at) / (o.dur || MO.PULSE.slam), o.from, o.under);+// 脉冲进度:at 起 dur 秒内按 cubicInOut 从 0 走到 1,之后停在 1(快推、横移都用它)+MO.pulse = (t, at, dur = MO.PULSE.punch, ease = MO.cubicInOut) => ease(clamp((t - at) / dur));+// ---------- 持续微动 ----------+// 只给环境层(星闪、粒子、远景云)和艺术风格画面用。解说片的主体、标签、卡片落定后停住,不加浮动、呼吸。// 漂浮:两频正弦叠加。周期避开 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));diff --git a/scripts/engine/lib/paint.js b/scripts/engine/lib/paint.jsindex 897661b..6fc5bed 100644--- a/scripts/engine/lib/paint.js+++ b/scripts/engine/lib/paint.js@@ -1,7 +1,7 @@// 纯代码绘画工具库:噪声、纹理、手绘线、风格渲染器(笔触/色点/马赛克/网点/像素/切面)、共享编舞。// 约定:所有随机都用种子;「抖动线条」按 boilFps 换种子(手绘动画的 boiling line),其余保持帧间稳定。(() => {-const W = 1920, H = 1080;+let W = 1920, H = 1080; U.onStage((w, h) => { W = w; H = h; }); // 画布尺寸跟 U.setStage 走(默认 1920×1080)const P = window.PAINT = {};const { clamp, lerp, ease, rng } = U;diff --git a/scripts/engine/lib/post.js b/scripts/engine/lib/post.jsindex b4a9803..63b4a2c 100644--- a/scripts/engine/lib/post.js+++ b/scripts/engine/lib/post.js@@ -11,7 +11,7 @@// P.fade(c, opt) 褪色/单色化:saturation 混合去色+multiply 染色(壁画褪色、胶片单色)// P.vignette(c, opt) 径向暗角(() => {-const W = 1920, H = 1080;+let W = 1920, H = 1080; U.onStage((w, h) => { W = w; H = h; }); // 画布尺寸跟 U.setStage 走(默认 1920×1080)const P = window.PAINT;const { rng } = U;diff --git a/scripts/engine/lib/render.js b/scripts/engine/lib/render.jsindex 6ae4a46..ae98ce0 100644--- a/scripts/engine/lib/render.js+++ b/scripts/engine/lib/render.js@@ -15,7 +15,8 @@// P.roughen(layer, box, opt) 整层低频像素位移:RIG 角色的边也像手剪的(马蒂斯)// P.glowStroke(c, col, w, blur) 霓虹灯管:对当前路径用 shadowBlur 描辉光(再描一道近白细芯线就是灯管)(() => {-const W = 1920, H = 1080, TAU = Math.PI * 2;+const TAU = Math.PI * 2;+let W = 1920, H = 1080; U.onStage((w, h) => { W = w; H = h; }); // 画布尺寸跟 U.setStage 走(默认 1920×1080)const P = window.PAINT;const { clamp, lerp, rng } = U;@@ -93,7 +94,7 @@ P.pointillism = (c, src, { pal, comp = {}, pitch = 10, rad = 4.5, posJitter = 2.};// ---------- 赛璐珞 / 漫画阴影 -----------const BIG = (() => { const p = new Path2D(); p.rect(-60, -60, W + 120, H + 120); return p; })();+let BIG; U.onStage((w, h) => { BIG = new Path2D(); BIG.rect(-60, -60, w + 120, h + 120); }); // 比画布四边各大 60px 的矩形,跟画布尺寸走// 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)→ 细描线。diff --git a/scripts/engine/lib/rig.js b/scripts/engine/lib/rig.jsindex c4ef9fb..01db155 100644--- a/scripts/engine/lib/rig.js+++ b/scripts/engine/lib/rig.js@@ -323,10 +323,10 @@ R.drawCatLines = (c, K, pal) => {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 mk = n => R._lc[key + n] || (R._lc[key + n] = (() => { const c = document.createElement('canvas'); c.width = window.STAGE.W; c.height = window.STAGE.H; 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);+ ga.clearRect(0, 0, ga.canvas.width, ga.canvas.height); gb.clearRect(0, 0, gb.canvas.width, gb.canvas.height); go.clearRect(0, 0, go.canvas.width, go.canvas.height);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) {diff --git a/scripts/engine/lib/toon.js b/scripts/engine/lib/toon.jsindex 606b828..b0eae65 100644--- a/scripts/engine/lib/toon.js+++ b/scripts/engine/lib/toon.js@@ -1,7 +1,7 @@-// 卡通与扁平插画 TOON:Kurzgesagt 式「无描边、双色分面」、柔光;故事型(storytime)极简角色「豆子花叔」、+// 卡通与扁平插画 TOON:Kurzgesagt 式「无描边、双色分面」、柔光;故事型(storytime)极简豆子角色(默认中性造型,可换预设),// pose-to-pose 换姿势(快切+身体挤压回弹)、眨眼时刻表、口型读口播包络(一拍二)、汗滴、漫画符号。(() => {-const W = 1920, H = 1080;+let W = 1920, H = 1080; U.onStage((w, h) => { W = w; H = h; }); // 画布尺寸跟 U.setStage 走(默认 1920×1080)const { clamp, lerp } = U;const TOON = window.TOON = {};@@ -26,12 +26,28 @@ TOON.ellipse = (x, y, rx, ry, a = 0) => { const p = new Path2D(); p.ellipse(x, yTOON.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],+// ---------- 豆子角色(故事型极简角色) ----------+// 正面、圆头、豆子身体、面条手臂。造型由 o.char 决定(预设名或对象),默认 'neutral':+// neutral 短发、蓝 T、深色裤子,不戴帽子和眼镜——给任何人的故事当主角+// bun 丸子头、芥黄 T、深色裤子+// author 本 skill 作者的卡通形象(纯白渔夫帽、圆框黑眼镜、白 T、卡其短裤、黑手表)。只在讲作者自己的故事时显式指定;+// 作者形象不随 MIT 授权(见 README)+// 对象:{ base: 预设名, skin, hair, shirt, pants, shoe, hairStyle: 'short'|'bun'|'none', hat: true/false, glasses: true/false, watch: true/false } 覆盖预设里的项+// o: { x, y(脚底), s(头半径 px), char, 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';+const LINE = '#1B1B1F', BAND = '#E4E4E8', HATC = '#FFFFFF';+TOON.LOOKS = {+ neutral: { skin: '#F3CDAE', hair: '#2A2420', hairStyle: 'short', shirt: '#6E9CCB', pants: '#3E4656', shoe: '#FAFAF6', hat: false, glasses: false, watch: false },+ bun: { skin: '#E9B994', hair: '#3B2A22', hairStyle: 'bun', shirt: '#E2B33C', pants: '#3E4656', shoe: '#FAFAF6', hat: false, glasses: false, watch: false },+ author: { skin: '#FFE2CC', hair: '#1B1B1F', hairStyle: 'none', shirt: '#FFFFFF', pants: '#CDBB97', shoe: '#FAFAF6', hat: true, glasses: true, watch: true },+};+// 预设名或对象 → 完整造型;不认识的预设名 console.error(qa / render 判失败),不悄悄换成别的+TOON.look = ch => {+ if (ch == null) return TOON.LOOKS.neutral;+ if (typeof ch === 'string') { if (TOON.LOOKS[ch]) return TOON.LOOKS[ch]; console.error(`TOON:没有这个角色预设「${ch}」(可选 ${Object.keys(TOON.LOOKS).join(' / ')},或传造型对象)`); return TOON.LOOKS.neutral; }+ return { ...(TOON.LOOKS[ch.base] || TOON.LOOKS.neutral), ...ch };+};TOON.POSES = {rest: { l: [-0.95, 1.05], r: [0.95, 1.05] },talk: { l: [-0.95, 1.05], r: [1.05, 0.55] }, // 一只手微抬,口播默认@@ -41,7 +57,8 @@ TOON.POSES = {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 R = o.s, x = o.x, y = o.y, lw = o.lw || Math.max(4, R * 0.05), sq = o.squash || 1, LK = TOON.look(o.char);+ const SK = LK.skin, SHIRT = LK.shirt, SHORTS = LK.pants, HAIR = LK.hair;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;@@ -49,7 +66,7 @@ TOON.bean = (c, o) => {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();+ c.fillStyle = LK.shoe; 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);@@ -70,7 +87,7 @@ TOON.bean = (c, o) => {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) { // 近侧(画右)手腕黑手表+ if (side > 0 && LK.watch) { // 近侧(画右)手腕黑手表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();}@@ -83,17 +100,27 @@ TOON.bean = (c, o) => {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(); }+ if (LK.hairStyle === 'bun') { c.fillStyle = HAIR; c.beginPath(); c.arc(0, -R * 0.98, R * 0.34, 0, Math.PI * 2); c.fill(); c.stroke(); } // 丸子(压在头后面)+ if (LK.hat) { 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();+ if (LK.hairStyle === 'short' || LK.hairStyle === 'bun') { // 头发:比头略大的一顶,前沿是一道带分缝的刘海,两侧盖到耳朵上沿+ const edge = new Path2D(); edge.moveTo(-R * 1.2, R * 0.05);+ for (let i = 0; i <= 24; i++) { const k = i / 24, xx = -R * 1.05 + k * R * 2.1, ax = Math.abs(xx) / R, side = U.ss(0.55, 0.98, ax);+ edge.lineTo(xx, -R * 0.42 + R * 0.06 * Math.cos(k * Math.PI * 3) * (1 - side) + side * R * (LK.hairStyle === 'bun' ? 0.32 : 0.45) + (xx > R * 0.15 && xx < R * 0.35 ? -R * 0.08 : 0)); }+ edge.lineTo(R * 1.2, R * 0.05); edge.lineTo(R * 1.2, -R * 1.4); edge.lineTo(-R * 1.2, -R * 1.4); edge.closePath();+ c.save(); c.clip(edge); c.fillStyle = HAIR; c.beginPath(); c.ellipse(0, -R * 0.05, R * 1.05, R * 0.99, 0, 0, Math.PI * 2); c.fill(); c.stroke(); c.restore();+ }+ if (LK.hat) {// 帽子:帽冠+帽带+往下斜的帽檐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.fillStyle = HATC; 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);+ c.fillStyle = HATC; 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];@@ -101,19 +128,19 @@ TOON.bean = (c, o) => {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 倍)+鼻梁;眼睛是黑点+ // 眼睛是黑点;戴眼镜的造型(author)加两只圆框(线比轮廓粗 1.5 倍)+鼻梁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;+ if (LK.glasses) { 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) * (LK.glasses ? 1 : 1.15);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();+ if (LK.glasses) { 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();+ if (LK.glasses) { 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(); }// 嘴diff --git a/scripts/engine/lib/util.js b/scripts/engine/lib/util.jsindex 3a78464..0b3db42 100644--- a/scripts/engine/lib/util.js+++ b/scripts/engine/lib/util.js@@ -26,6 +26,16 @@ window.U = {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; },};+// ---------- 画布尺寸 ----------+// 默认 1920×1080。竖屏片段(clip.html,spec.width/height)和竖屏整片(index.html?w=1080&h=1920,或 eras.js 里写 window.FILM_SIZE = [1080, 1920])+// 启动时调一次 U.setStage(w, h)。用到屏幕尺寸的库(PAINT / BRUSH / RENDER / POST / KIT / TOON / CAM / UI / CH / DG / CL / MD、transitions.js、engine.js)+// 用 U.onStage 登记,尺寸一改全部跟着改;登记时立刻按当前尺寸回调一次,后加载的库也拿得到。+// 35 种艺术风格场景(scenes/)是按 1920×1080 画的,竖屏只保证解说语法、转场和引擎本身。+const stageHooks = [];+window.STAGE = { W: 1920, H: 1080 };+U.onStage = f => { stageHooks.push(f); f(window.STAGE.W, window.STAGE.H); };+U.setStage = (w, h) => { w = Math.round(+w); h = Math.round(+h); if (!(w > 0 && h > 0)) throw new Error(`U.setStage:尺寸不对 ${w}×${h}`); window.STAGE = { W: w, H: h }; stageHooks.forEach(f => f(w, h)); };+// ---------- 字形检查 ----------// 字体文件缺某个字时浏览器会静默回退到系统字体:measureText 不报错、宽度也对,换台机器就变样(迁移测试 B、D:全角字母、▶、「戏」「蓝」都踩过)。// 做法:启动时(engine boot,字体加载完)把 FONT_FACES 里每个字体文件的 cmap 表读出来(WOFF1 用 DecompressionStream 解 zlib),查表判断有没有这个字。diff --git a/scripts/engine/render.py b/scripts/engine/render.pyindex ac5eb98..686ff76 100644--- a/scripts/engine/render.py+++ b/scripts/engine/render.py@@ -3,14 +3,17 @@→ 读 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]+ [--film gallery](读 eras_gallery.js)[--solo <id> --stills 0.2,0.6 --no-counter] [--width 1080 --height 1920](竖屏整片:传给 index.html?w=&h=,+ 引擎、转场、相机和各库按这个画布算;不写就用 eras.js 的 window.FILM_SIZE,再不写 1920×1080)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+import argparse, base64, http.server, json, socketserver, subprocess, sys, threading, functools, time, urllib.parsefrom pathlib import Path+sys.path.insert(0, str(Path(__file__).parent))+import spec_assetsfrom playwright.sync_api import sync_playwrightap = argparse.ArgumentParser()@@ -26,22 +29,18 @@ 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 带透明(背景不画)')+ap.add_argument('--width', type=int, help='整片模式的画布宽(竖屏 1080);--spec 时宽高从 spec 读,写了这个会覆盖 spec')+ap.add_argument('--height', type=int, help='整片模式的画布高(竖屏 1920)')a = ap.parse_args()root = Path(__file__).parent-spec = None+spec, ALLOWED = None, set()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'])+ try: spec_assets.localize(spec, sp.parent, ALLOWED) # image / frames / data.character 里的本地路径 → /__file__/<绝对路径>(只服务 spec 里点名的文件)+ except FileNotFoundError as e: raise SystemExit(str(e))if a.alpha: spec['alpha'] = True+ if a.width or a.height: spec['width'], spec['height'] = a.width or spec.get('width', 1920), a.height or spec.get('height', 1080)class Q(http.server.SimpleHTTPRequestHandler):def log_message(self, *x): passdef translate_path(self, path):@@ -72,7 +71,10 @@ with sync_playwright() as p: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 ''))+ if a.width or a.height:+ if not (a.width and a.height): raise SystemExit('--width 和 --height 要一起写')+ pg.set_viewport_size({'width': a.width, 'height': a.height})+ pg.goto(f'http://127.0.0.1:{port}/index.html?render=1' + (f'&film={a.film}' if a.film else '') + (f'&w={a.width}&h={a.height}' if a.width else ''))pg.wait_for_function('window.__ready === true || !!window.__bootFailed', timeout=120000)bf = pg.evaluate('window.__bootFailed || null')if bf: raise SystemExit('场景加载失败,拒绝渲染:\n' + bf)diff --git a/scripts/engine/spec_assets.py b/scripts/engine/spec_assets.pynew file mode 100644index 0000000..5b25fe7--- /dev/null+++ b/scripts/engine/spec_assets.py@@ -0,0 +1,76 @@+"""片段 spec 里的本地素材路径:找出来、核存在、改写成本地服务能取的 URL。render.py 用它(qa.py 可以照搬)。++认这些字段(路径相对 spec 文件,也可写绝对路径;data: / http(s): 原样放行):+ cues[].image 一张图(截图、照片、录像的一帧)+ cues[].frames 帧序列:目录(按文件名排序取 .png/.jpg/.jpeg/.webp)或路径数组;配 cues[].fps(默认 30)+ data.image 语法级的一张图(y1 用作中心物的图)+ data.character y4 角色:预设名(neutral / bun / author)原样放行;目录 → 帧库(文件名去扩展名 = 姿势名);+ 对象 {frames: {姿势: 路径} | 目录} 同理+文件不存在 → FileNotFoundError(调用方拒绝渲染,不出空白帧)。+"""+import urllib.parse+from pathlib import Path++FRAME_EXT = ('.png', '.jpg', '.jpeg', '.webp')+PRESETS = ('neutral', 'bun', 'author')+++def _url(f, allowed):+ allowed.add(str(f))+ return '/__file__/' + urllib.parse.quote(str(f))+++def _file(v, base, allowed, what):+ if not v or str(v).startswith(('data:', 'http:', 'https:')):+ return v+ f = (base / v).resolve()+ if not f.is_file():+ raise FileNotFoundError(f'spec 里的{what}不存在:{v}(相对 {base})')+ return _url(f, allowed)+++def _dir_frames(v, base, what):+ d = (base / v).resolve()+ if not d.is_dir():+ return None+ files = sorted(p for p in d.iterdir() if p.suffix.lower() in FRAME_EXT)+ if not files:+ raise FileNotFoundError(f'spec 里的{what}目录是空的(没有 {"/".join(FRAME_EXT)}):{v}')+ return files+++def localize(spec, base, allowed):+ """原地改写 spec。base = spec 所在目录;allowed 收集允许服务的绝对路径。"""+ base = Path(base)+ for q in spec.get('cues', []):+ if q.get('image'):+ q['image'] = _file(q['image'], base, allowed, '图片')+ fr = q.get('frames')+ if isinstance(fr, str):+ files = _dir_frames(fr, base, '帧序列')+ if files is None:+ raise FileNotFoundError(f'spec 里的帧序列目录不存在:{fr}(相对 {base})')+ q['frames'] = [_url(f, allowed) for f in files]+ elif isinstance(fr, list):+ if not fr:+ raise FileNotFoundError('spec 里的 frames 是空数组')+ q['frames'] = [_file(v, base, allowed, '视频帧') for v in fr]+ data = spec.get('data') or {}+ if data.get('image'):+ data['image'] = _file(data['image'], base, allowed, '图片')+ ch = data.get('character')+ if isinstance(ch, str) and ch not in PRESETS:+ files = _dir_frames(ch, base, '角色帧库')+ if files is None:+ raise FileNotFoundError(f'data.character 既不是预设({" / ".join(PRESETS)})也不是帧库目录:{ch}(相对 {base})')+ data['character'] = {'frames': {f.stem: _url(f, allowed) for f in files}}+ elif isinstance(ch, dict):+ fr = ch.get('frames')+ if isinstance(fr, str):+ files = _dir_frames(fr, base, '角色帧库')+ if files is None:+ raise FileNotFoundError(f'data.character.frames 目录不存在:{fr}(相对 {base})')+ ch['frames'] = {f.stem: _url(f, allowed) for f in files}+ elif isinstance(fr, dict):+ ch['frames'] = {k: _file(v, base, allowed, f'角色帧「{k}」') for k, v in fr.items()}+ return specdiff --git a/scripts/engine/transitions.js b/scripts/engine/transitions.jsindex 88a459a..b3b2520 100644--- a/scripts/engine/transitions.js+++ b/scripts/engine/transitions.js@@ -2,7 +2,8 @@// o: {W,H,lt,t,tmp,IMG, ...该转场在 eras.js 里的参数}。确定性:随机数一律 U.rng(种子)。// 每个转场都取「新时代」最有辨识度的形式元素(见 经验日志「转场」)。(() => {-const W = 1920, H = 1080;+let W = 1920, H = 1080; U.onStage((w, h) => { W = w; H = h; }); // 画布尺寸跟 U.setStage 走:竖屏整片(render.py --width 1080 --height 1920)的转场按当前画布算+const sx = x => x * W / 1920, sy = y => y * H / 1080; // 按 1920×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@@ -118,7 +119,7 @@ const T = window.TRANSITIONS = {// ⑤ 哥特→文艺复兴:窗口迸出金色神光,光芒里旧画渐隐、新画浮现godRays(c, A, B, p, o) {- const cx = o.cx || 440, cy = o.cy || 300;+ const cx = o.cx || sx(440), cy = o.cy || sy(300);c.drawImage(A, 0, 0);c.globalAlpha = ease.out(seg(p, 0.05, 0.5)); c.drawImage(B, 0, 0); c.globalAlpha = 1;// 光晕@@ -215,7 +216,7 @@ const T = window.TRANSITIONS = {// ⑧ 印象派→梵高:星空漩涡——以窗户为中心的旋涡扭曲,新画面带着旋转卷进来、最后摆正swirl(c, A, B, p, o) {- const cx = o.cx || 420, cy = o.cy || 300;+ const cx = o.cx || sx(420), cy = o.cy || sy(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) }));@@ -244,7 +245,7 @@ const T = window.TRANSITIONS = {// ⑨ 梵高→新艺术:从人物头部长出一块带金边的有机形状(慕夏式曲线轮廓),向外生长吞没画面organic(c, A, B, p, o) {- const cx = o.cx || 1500, cy = o.cy || 330;+ const cx = o.cx || sx(1500), cy = o.cy || sy(330);const e = ease.out(p) * 0.7 + p * 0.3;const R = e * 2300;const path = () => {@@ -302,7 +303,7 @@ const T = window.TRANSITIONS = {// ⑪ 立体→包豪斯:蓝方块+红圆+黄三角的构成旋转放大,中心的米白圆里是新画面,最后构成扫出画面bauhaus(c, A, B, p, o) {- const cx = o.cx || 1010, cy = o.cy || 560;+ const cx = o.cx || sx(1010), cy = o.cy || sy(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;@@ -398,7 +399,7 @@ const T = window.TRANSITIONS = {// ⑮ 光追→2026:三色同心环从杯子(992,601)线性扩张,外径约 143px/帧,每环厚 137px,最内环里是新画面(分镜表 T15)iris(c, A, B, p, o) {- const cx = o.cx || 992, cy = o.cy || 601;+ const cx = o.cx || sx(992), cy = o.cy || sy(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(); };@@ -413,7 +414,7 @@ const T = window.TRANSITIONS = {// 水墨 → 克里姆特:金箔一片片贴上来。从少女头部按螺旋次序落下方形金箔(带螺旋/眼形/同心圆压纹),// 贴实后金色褪去露出新画面。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 ts = 72, cx = o.cx || sx(1300), cy = o.cy || sy(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 }); }@@ -472,7 +473,7 @@ const T = window.TRANSITIONS = {},// 敦煌 → 草间:波点从猫的位置一圈圈长出来,点里是新画面;点胀到彼此相接就整幅换完。dotBloom(c, A, B, p, o) {- const sp = 58, cx = o.cx || 540, cy = o.cy || 760, maxd = Math.hypot(W, H);+ const sp = 58, cx = o.cx || sx(540), cy = o.cy || sy(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 = [];@@ -484,7 +485,7 @@ const T = window.TRANSITIONS = {// ① Kirby → 莫奈:旧画面「落进水里」——逐行横向正弦错位(水面倒影的抖动)越来越强;// 新画面从杯子位置以「横向短笔触」一圈圈荡开(涟漪由笔触组成),亮色水光短横线闪烁。ripple(c, A, B, p, o) {- const cx = o.cx || 1000, cy = o.cy || 600, e = ease.inOut(p);+ const cx = o.cx || sx(1000), cy = o.cy || sy(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; });@@ -559,7 +560,7 @@ const T = window.TRANSITIONS = {// ④ 马蒂斯 → 哈林:一个粗黑轮廓的跳舞小人(双臂 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 cx = o.cx || sx(1000), cy = o.cy || sy(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),@@ -582,7 +583,7 @@ const T = window.TRANSITIONS = {// ---- 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 cx = o.cx || W / 2, cy = o.cy || H / 2, 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);@@ -596,7 +597,7 @@ const T = window.TRANSITIONS = {},// 橡皮管 → 皮影:旧片像灯灭一样压成暗褐剪影;幕后的油灯从中心点亮,暖光圈(边缘带灯焰抖动)向外推开,新画面在光里出现lampGlow(c, A, B, p, o) {- const cx = o.cx || 960, cy = o.cy || 470;+ const cx = o.cx || W / 2, cy = o.cy || sy(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;@@ -698,7 +699,7 @@ T.sunShaft = function (c, A, B, p) {// 边缘一圈颜料沉积的深色水痕+外侧一圈被水冲淡的亮晕;色晕里是新画面。// 水痕/亮晕的 α 跟着「这一团的扩张进度」淡出,否则长大后的水痕线会横穿新画面(第一版踩到)。T.bleed = function (c, A, B, p, o) {- const cx = o.cx || 580, cy = o.cy || 330;+ const cx = o.cx || sx(580), cy = o.cy || sy(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;@@ -739,7 +740,7 @@ T.vhs = function (c, A, B, p) {Object.assign(T, {// 进入水墨:旧画先被「洗」成宣纸(去色、提亮、减对比),几团墨点从落笔处先后洇开,边缘带一圈墨晕,新画在墨里出现inkBloom(c, A, B, p, o) {- const cx = o.cx || 560, cy = o.cy || 740;+ const cx = o.cx || sx(560), cy = o.cy || sy(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(); };@@ -759,17 +760,17 @@ Object.assign(T, {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];+ const mx = W / 2, my = H / 2, tf = (u, v) => [mx + (u - mx) * ca - (v - my) * sa, my + (u - mx) * sa + (v - my) * 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.save(); c.beginPath(); [tf(-3000, -3000), tf(X - 420, -3000), tf(X - 420, 4000), tf(-3000, 4000)].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, my), tf(X - 520, my - 330), tf(X - 520, my + 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.beginPath(); [tf(-2000, my + dv), tf(x1, my + dv), tf(x1, my + dv + h), tf(-2000, my + 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]]);+ 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]].map(([x, y, w, h, t0]) => [sx(x), sy(y), sx(w), sy(h), t0]));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) {@@ -781,17 +782,17 @@ Object.assign(T, {},// 进入伦勃朗:旧画沉进暗褐(暗角从四周合拢),然后一道从窗口斜下来的光柱把新画面照出来,最后暗部也慢慢显影chiaroscuro(c, A, B, p, o) {- const sx = o.cx || 580, sy = o.cy || 300;+ const lx = o.cx || sx(580), ly = o.cy || sy(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})`);+ const vg = c.createRadialGradient(W / 2, H / 2, lerp(1100, 80, d), W / 2, H / 2, 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';+ const spread = lerp(60, 1400, q); g.beginPath(); g.moveTo(lx - 180, ly - 200); g.lineTo(lx + 180, ly - 200); g.lineTo(lx + 500 + spread, ly + 900); g.lineTo(lx - 200 - spread * 0.6, ly + 900); g.closePath(); g.fill();+ g.beginPath(); g.arc(lx + 420, ly + 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();+ 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(lx - 140, ly - 160); c.lineTo(lx + 140, ly - 160); c.lineTo(lx + 420 + spread * 0.5, ly + 900); c.lineTo(lx - 120 - spread * 0.3, ly + 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; }},});