艺术动画skill:35种艺术风格、9种解说语法,用代码让画动起来。
JavaScript agent-skillsanimationclaude-codeclaude-code-skillsclaude-skillscodexexplainer-videogenerative-arthuashu-skillsmotion-graphicsskillsvideo
feat: 一套画风、去掉蓝紫、角色要么到位要么不出脸(改动包E)
alchainc191de2293e8
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex a35bfbe..b09bc00 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -30,3 +30,4 @@- 2026-10-10 · 轨道档改成「先镜头表,再动手」(改动包A2):轨道档第 1 步照新增的 `references/镜头表模板.md` 写镜头表(时间段|物|做什么|镜头|屏上字|做法,附一份「为什么面包会发霉」完整示例),第 2 步过新增的 `scripts/storyboard_lint.py`(只用标准库:物不能是版面词、做什么不能只是出现/显示、屏上字 ≤8、首镜不能文字主导、文字主导 ≤30%、单镜 2–6 秒、连续三镜同一镜头报黄、同一参数化片段合计 >8 秒和做法少于 3 种报红;有红非零退出),红灯不许写代码;第 3 步逐镜做(片段或 scenes,单片段最多 8 秒,至少 3 种做法),第 4 步给出 ffmpeg concat 硬切拼接命令;之后照旧 qa → deliver.py。`render.py --spec` 在 duration > 8 秒时首尾各打印一次警告(不报错),09 号片段契约同步;开阔档建议先写镜头表、不强制 lint。门禁阈值、窄桥、五种做坏方式、引擎能力不变;`tests/test_storyboard_lint.py` 测示例绿灯、要点墙红灯。- 2026-10-10 · 盲评反复点名的残留问题改成机械检查(改动包D):`storyboard_lint.py` 新增 ⑧最后一镜不能是文字主导(居中金句卡/纯字卡)报红、①物列是空镜/空景/纯色/黑场/黑屏/全黑/渐变底报红(单独的改法)、⑨可选 `--script 文稿.txt` 时屏上阿拉伯数字(百分数、年份、带单位的数)在文稿里找不到报红(文稿里的中文数字也认,按文稿那个数的精度容差)、⑩可选「标签」列一镜超过 3 个报黄;`film_gate.py` 新增第二条门禁 `blank_run_s`:去掉首尾各 0.5 秒和转场窗口,梯度 >24 的像素不到 0.2% 的帧算空帧,连续 ≥0.3 秒红灯并给时间码,按边缘判不按颜色判、不受短片降级;标定数据 32 支(含 13 支表过态、9 支认可)全部不触发、快动帧占比与标定表逐位一致,快动门禁阈值不变;t3 片段新增 `theme`(light/paper/dark/对象,spec 级或 data 级),没写主题时跟 `safe.fill` 的底色走,默认白底逐帧不变;t2 的 number 新增 `data.over`(拉回整张截图、压暗、数字砸在截图上),`examples/t2_fullbleed_pulse.json` 改用它,去掉 5.5 秒前后的空光斑底;镜头表模板示例结尾改成小满把吐司塞进冷冻层;SKILL.md 五种做坏方式第 1、4 条并入结尾金句卡与空画面,09 号与 t2/t3 卡同步;新增 `tests/test_film_gate_blank.py`(ffmpeg 合成片)、`tests/test_clip_world.py`(渲染核对),`test_storyboard_lint.py` 补新规则。- 2026-10-10 · D2:窄桥「砸入」改为数字落在世界里的物上、不单独起纯色字卡;镜头表检查加⑪数字字卡(黄)。依据:里程碑一 Opus 与 Codex 冬天掉电片都插了一张纯色底「60%」字卡,被盲评判为插页 PPT。+- 2026-10-10 · 一套画风、去掉蓝紫、角色要么到位要么不出脸(改动包E)。依据:作者第一轮盲选 8 组只有 3 组选新版,输的两组都选了「整片一套配色、干净统一」的旧片,没选「每镜换一种画风」的拼贴;另有两组两支都不要,原话「颜色和人的风格形象都有些ai slop」,并追加「规避蓝、紫渐变的垃圾配色」「小人和机器人角色都太差了,要自己定义精细度和用力的要求」。改动:轨道档删掉「全片至少 3 种画面做法」(它逼出了拼贴),改成镜头表表前锁「画风/色板/角色」三行、所有片段写同一个 `theme`、最多 2 种片段语法;新增 `references/色板.md`(八套色板与蓝紫禁区)、`references/角色精细度.md`(三条路+帧库角色八条交付线+物不加脸);「五种做坏方式」加第六种「一眼 AI 味」。引擎:新增 `lib/palettes.js`,`spec.theme` 可写色板名或对象,8 个语法都按它上色、不画大面积渐变和霓虹;y1 默认天空从深紫渐变改为深墨平涂,y1/y4/t2 默认色里的紫、品红、紫蓝换掉;y4 只接受角色帧库,代码画的预设小人停用,样例改成占位帧库路径。检查:`storyboard_lint` 新增 ⑫画风锁(缺行红)、⑬色板(蓝紫色值红,写「允许蓝紫」降黄)、⑭角色(代码画小人/机器人/y4 无帧库红,给物长脸黄),删掉「做法少于 3 种」改为「片段语法超过 2 种」红;`film_gate` 新增第三条门禁「蓝紫底画面时长占比」(≥0.30 红、≥0.12 黄;88 支片标定,作者认可的最高 0.10,否掉的 0.46–1.00),`--allow-blue-purple "理由"` 降黄并写进交付说明事实段。t3 的 `"paper"` 主题现在指纸本色板(以前是 FT 粉)。diff --git a/SKILL.md b/SKILL.mdindex a60d025..ad8db47 100644--- a/SKILL.md+++ b/SKILL.md@@ -9,32 +9,33 @@ description: "艺术与视频动画:拆解复刻动画;代码画35种艺术- **开阔档**:你是 Claude Opus 5.5 或更强的模型。全文都适用:路由表、窄桥、开阔地;库可以自己组合,渲染器可以自己写;交付同样走 `scripts/deliver.py`,红灯不交付。开工前也建议先写一张镜头表(`references/镜头表模板.md`),lint 可跑可不跑。- **轨道档**:其它模型,或判断不出自己是谁。只走下面这一条路,先镜头表,再动手;只读这条路点名的文件,其余 reference 先不读:- 1. **写镜头表**:照 `references/镜头表模板.md` 写 `<项目>/镜头表.md`,每行一镜:时间段|画面里的物(名词)|它在做什么(动词)|镜头(停/快推/横移/砸入/切)|屏上字(≤8 字,可空)|做法。开头 3 秒是一个具体的小场景(一个人或一个物在做一件和题目有关的事),不是标题;全片用一个具体例子或一个角色贯穿;一镜 2–6 秒;文字主导的镜头 ≤30%;相邻两镜不用同一版式。+ 1. **写镜头表**:照 `references/镜头表模板.md` 写 `<项目>/镜头表.md`。表前先锁画风,三行:画风(一句话,全片只用这一种)、色板(`references/色板.md` 里的一套或 3–6 个色值,不落蓝紫)、角色(无/只出手和背影/帧库 <路径>,先读 `references/角色精细度.md`)。表里每行一镜:时间段|画面里的物(名词)|它在做什么(动词)|镜头(停/快推/横移/砸入/切)|屏上字(≤8 字,可空)|做法。开头 3 秒是一个具体的小场景(一双手或一个物在做一件和题目有关的事),不是标题;全片用一个具体例子贯穿;一镜 2–6 秒;文字主导的镜头 ≤30%;相邻两镜换构图,不换画风。2. **过 lint**:`uv run <skill>/scripts/storyboard_lint.py <项目>/镜头表.md`(有口播稿加 `--script <项目>/文稿.txt`,查屏上数字和口播是不是同一个数)。有红灯就改镜头表、重跑,红灯没清不许开始写代码。3. **按镜头表逐镜做**:`cp -R <skill>/scripts/engine <项目>/代码工程`,每一镜出一个 `镜NN.mp4`,所有镜同宽高、同 fps(默认 1920×1080@30)。- 参数化片段:读 `references/09-视频动画语法.md` 第二节选型表和用到的 `references/动画语法/<语法>.md`「起手必查」,从 `examples/<语法>.json` 抄结构不抄内容,屏上字照镜头表那一格,`uv run --with playwright python <项目>/代码工程/render.py --spec 镜NN.json --out 镜NN.mp4`。**单个参数化片段最多撑 8 秒**,超了拆成几镜。- scenes:艺术风格画面(梵高、像素……)或片段语法画不出的物,读 `references/风格配方/INDEX.md` 和一张风格卡,写 `scenes/<id>.js` 并登记进 `eras.js`,`render.py --solo <id> --from 0 --to <秒> --fps 30 --no-counter --out 镜NN.mp4`。- - 全片至少用 3 种不同的画面做法(不同语法的片段、scenes 代码画、真实素材满幅,各算一种)。每镜加 `--stills 0.5,2 --out 静帧/镜NN` 抽帧,对着镜头表看。+ - 全片一套画风:所有片段 spec 写同一个 `"theme"`(镜头表色板那一行,写法见 `references/色板.md`),最多 2 种片段语法;scenes 也只用这套色板。每镜加 `--stills 0.5,2 --out 静帧/镜NN` 抽帧,排成一排对着镜头表看:哪一镜像从别的片子里拿来的,就按画风重做。4. **拼接**:镜与镜硬切,在放 `镜NN.mp4` 的目录里:```shfor f in 镜*.mp4; do printf "file '%s'\n" "$f"; done > 镜头列表.txtffmpeg -y -f concat -safe 0 -i 镜头列表.txt -r 30 -c:v libx264 -crf 16 -pix_fmt yuv420p -an 成片.mp4```有口播再混音:`ffmpeg -i 成片.mp4 -i 口播.wav -map 0:v -map 1:a -c:v copy -c:a aac -shortest 成片_口播.mp4`。要转场就全用 scenes,把各镜按顺序写进 `eras.js` 段落表(段写 `dur` 秒、`transition`),整片模式 `render.py --out 成片.mp4` 一次出片。- 5. **qa**:每个片段 `uv run <skill>/scripts/qa.py --spec 镜NN.json --out <项目>/qa/镜NN`;有 scenes 再跑 `qa.py --project <项目>/代码工程 --ids <id,…> --out <项目>/qa/scenes`。再拿抽帧逐条对下面「五种做坏方式」。- 6. **交付**:`uv run <skill>/scripts/deliver.py 成片.mp4 --root <项目> --qa <项目>/qa/<跳变最多的那一镜> --out output/`。红灯不交付:脚本不复制成片,照它打印的修法改完重渲、重跑。绿灯、黄灯它复制成片并写 `output/交付说明.md`,时长、门禁、qa、有没有审片由脚本写;你只在「制作说明」段补用了哪些语法和做法、其余各镜的 qa 结论(每镜一行)、黄灯项逐条理由、五种做坏方式自查,事实段不许改。派了独立审片的,先让审片人把结论写进 `<项目>/审片/*.md` 再跑。+ 5. **qa**:每个片段 `uv run <skill>/scripts/qa.py --spec 镜NN.json --out <项目>/qa/镜NN`;有 scenes 再跑 `qa.py --project <项目>/代码工程 --ids <id,…> --out <项目>/qa/scenes`。再拿抽帧逐条对下面「六种做坏方式」。+ 6. **交付**:`uv run <skill>/scripts/deliver.py 成片.mp4 --root <项目> --qa <项目>/qa/<跳变最多的那一镜> --out output/`。红灯不交付:脚本不复制成片,照它打印的修法改完重渲、重跑。绿灯、黄灯它复制成片并写 `output/交付说明.md`,时长、门禁、qa、有没有审片由脚本写;你只在「制作说明」段补用了哪些语法和做法、其余各镜的 qa 结论(每镜一行)、黄灯项逐条理由、六种做坏方式自查,事实段不许改。派了独立审片的,先让审片人把结论写进 `<项目>/审片/*.md` 再跑。## 你是谁你同时是这支片子的导演、分镜师、原画师、动画师和剪辑师,画画用的是代码。你对成片的标准:观众看得懂每一镜在讲什么,愿意看下去;用艺术风格时一眼认得出是谁的画,画是活的,不是图片在切换。-## 最常见的五种做坏方式(开工前、交付前各对一遍)+## 最常见的六种做坏方式(开工前、交付前各对一遍)1. **翻页式 PPT**:固定页眉、页码,要点逐条淡入,每镜匀速慢推,结尾落回一张居中金句卡。→ 去掉页框,一镜一个画面事件,镜头按窄桥第一条的脉冲节奏动;结尾落在主角或主物的一个动作上(放进口袋、合上书、拉远看全貌),字可以写在画里的物上。storyboard_lint 查最后一镜是不是字卡;deliver.py 会量出来:整片几乎没有镜头内快动作就红灯,不出片。2. **照搬示范**:示范片、样例 spec、风格样片里的构图、角色、素材直接进了成片。→ 只学做法,构图和物按题材重新设计。3. **没有具体的物**:抽象概念只写成字和图标。→ 镜头表每行写出一个具体的物和它的动作,写不出物的那一行先别做。4. **死背景、空画面**:大面积纯色或星空底一直不变,只有中间一小块在动;或者整帧只剩纯色、黑场、空景,主角不在画里。→ 主体放大到占画面一半以上,背景跟着内容换,每一镜主角或主物都在画里;图表镜头的底和前后镜头同色系(t3 的 `theme`)。storyboard_lint 查物列是不是空镜、纯色、黑场;film_gate(deliver.py 先跑它)查成片中段连续 0.3 秒以上的空画面,红灯不出片。5. **有真实素材却用代码去画**。→ 截图、照片、录像、原文直接满幅放,代码只负责解释、标注和运镜。+6. **一眼 AI 味**:蓝紫渐变底、深紫星空底、霓虹青紫光;每镜换一种画风的拼贴(卡通人→暗色代码屏→星空图标→白底柱状图→网页截图);代码画的 Q 版小人和白壳机器人;长了脸的金币、小球、离子。→ 表前锁一种画风、一套色板(`references/色板.md`),所有片段写同一个 `theme`;角色要么 AI 生帧过交付线,要么只出手和背影(`references/角色精细度.md`)。storyboard_lint 查画风锁、色板色值和角色行;deliver.py 量蓝紫底,蓝紫帧占全片 30% 以上红灯,不出片。干净统一但略像幻灯片的片子,胜过花哨的拼贴。## 先判断任务@@ -44,7 +45,7 @@ description: "艺术与视频动画:拆解复刻动画;代码画35种艺术| 「做个 XX 风格的动画」「梵高/莫奈/包豪斯那种」 | 先为题材定构图 → 一帧先行 → 渲染器 → 让它活 | 03 → 04 → `风格配方/INDEX.md` 找最近的材料当起点 || 「用我的口播做一段艺术动画」 | 镜头表 → 定风格 → 世界画布+镜头 → 画面轨 | 06(草案)+ 04;口播的转录与时间轴交给你的视频管线 || 「配个乐」「卡节奏」 | BPM 网格、动机换乐器、结尾音效序列 | 05 |-| 画面里要出现人(用户本人、真人、拟人角色) | AI 生帧+代码合成(B/C 两法) | 10 |+| 画面里要出现人(用户本人、真人、拟人角色、吉祥物) | AI 生帧+代码合成(B/C 两法),过交付线;没有生图能力就只出手和背影 | 10 + `角色精细度.md` || 派 agent 画某个风格 / 自己写新风格 | 接口、两种起点、硬要求、自检交付 | 08 + `风格配方/INDEX.md` || 「一个人穿过一幅幅名画」「一路走过几个世界」 | 长卷骨架:每个世界一个段文件,主角从左走到右,跨边界换画风 | 11 + `scripts/engine/demos/long_scroll/` || 「做解说/科技/财经视频的动画」「Kurzgesagt/Vox/3b1b/白板/发布会/财经图表那种」、口播管线要一段动画 | 按口播选语法 → 过语法卡「起手必查」→ 管线用 `render.py --spec` 出时长精确的片段 | 09 + `动画语法/<语法>.md` |@@ -64,7 +65,8 @@ description: "艺术与视频动画:拆解复刻动画;代码画35种艺术## 窄桥:照字面做- **动在事件上。** 解说类片子用脉冲节奏:停住 → 快推、横移或砸入 → 停住。快推 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`;几何角色可以用代码画。+- **有真实素材就让它当主画面。** 截图、照片、录像、原文、产品本身的产出,满幅放,代码负责解释、标注和运镜(`MD.cover` 满幅+焦点推近、`MD.print` 冲印件、`MD.label` 黑底撕边标签;缺图直接报错)。「场景与风格用代码画」只适用于艺术风格画面。人用 AI 生帧、代码合成,见`references/10-角色.md`;代码不画人脸、不画机器人,也不给物加脸(`references/角色精细度.md`)。+- **一片一套画风、一套色板。** 表前锁定的画风和色板管到最后一帧;所有参数化片段写同一个 `theme`,scenes 也只用这几个色。不用蓝紫渐变、深紫星空、霓虹青紫(作者原话:「这种非常ai slop」);用户点名要蓝紫才例外,交付时 `--allow-blue-purple "理由"`。- **示范只用来理解做法。** 示范片、样例 spec、风格样片里的构图、角色和素材,不许原样放进成片。- **复刻是学机制,不是逐像素。** 提取场景、运动与转场规律,再用于新题材。- **三方向硬门**:新的角色诠释或风格方向,先出三个给用户挑,三个方向的构图要不同,不能只换调色。指定了风格也不豁免。diff --git "a/references/04-\347\272\257\344\273\243\347\240\201\347\273\230\345\210\266.md" "b/references/04-\347\272\257\344\273\243\347\240\201\347\273\230\345\210\266.md"index c99d2fc..832d59e 100644--- "a/references/04-\347\272\257\344\273\243\347\240\201\347\273\230\345\210\266.md"+++ "b/references/04-\347\272\257\344\273\243\347\240\201\347\273\230\345\210\266.md"@@ -1,6 +1,6 @@# 04 · 纯代码绘制:用 Canvas 把一幅有艺术感的画画出来并让它活-本页以纯代码绘制为主线:场景、几何角色和物件通过程序与风格渲染器实现;拟人角色的生成帧方案见10号。本页是第一次做完 16 种风格后的方法总结;每种风格的具体参数在 `风格配方/<id>.md`。+本页以纯代码绘制为主线:场景和物件通过程序与风格渲染器实现;人、拟人角色和机器人不用代码画进成片,生成帧方案见10号,交付线见`角色精细度.md`。本页是第一次做完 16 种风格后的方法总结;每种风格的具体参数在 `风格配方/<id>.md`。## 一、工程骨架(`scripts/engine/`,复制一份就能开新片)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 85e1c20..5c10581 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"@@ -84,7 +84,7 @@ uv run scripts/qa.py --project scripts/engine --film demos/y1_kurzgesagt --out <| `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`(剪纸白边) || `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` |+| `toon.js` | `TOON` | `flat`(双色分面)、`glow/vgrad/circle/ellipse`、`bean`(豆子角色,只用于示范片和白模预演,不进成片;参数化片段 y4 已不再调用)与 `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`。@@ -113,7 +113,8 @@ 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 不冻帧。-- **单个片段最多撑 8 秒。** `duration` 超过 8 秒时 render.py 在开头和结尾各打印一次醒目警告,不报错(口播管线里有合法的长片段)。一个片段撑太久会读成一页 PPT:一个版式到底、要点越堆越长、背景从头死到尾。一支片要拆成多镜,每镜一个 spec(或一段 scenes),镜与镜换语法或换做法,再拼接(SKILL.md 轨道档第 3–4 步、`references/镜头表模板.md`)。样例 spec 有 8.5–10 秒的,那是一段的写法示范,不是一支片的长度。+- **单个片段最多撑 8 秒。** `duration` 超过 8 秒时 render.py 在开头和结尾各打印一次醒目警告,不报错(口播管线里有合法的长片段)。一个片段撑太久会读成一页 PPT:一个版式到底、要点越堆越长、背景从头死到尾。一支片要拆成多镜,每镜一个 spec(或一段 scenes),镜与镜换构图、不换画风(同一个 theme,最多 2 种语法),再拼接(SKILL.md 轨道档第 3–4 步、`references/镜头表模板.md`)。样例 spec 有 8.5–10 秒的,那是一段的写法示范,不是一支片的长度。+- **全片一套色:`theme`。** 一支片的所有 spec 写同一个 `"theme"`:色板名 `paper`、`poster`、`ink`、`navy`、`bauhaus`、`snow`、`wood`、`chalk`(色值见 `references/色板.md`),或对象 `{"name": "wood", "accent": "#B8452A"}` 只改一两个键,或完整 6 键 `{bg, surface, ink, sub, accent, accent2}`。名字写错、对象缺键(又没写 name)、色值不是 #hex → 启动失败。写了 theme 的语法不画大面积渐变底和霓虹光,辅助色都从这 6 个色派生。不写 theme 时各语法用自己的默认(y1 默认深墨平涂,不再是深紫星空)。t3 另外认旧写法 `"light"`、`"dark"` 和它自己的主题对象;`"paper"` 现在指纸本色板。- 宽高和 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/` 下;整段当一段量确定性、运动、静止帧对、孤立跳变、耗时,竖屏按画幅缩;短于 0.35 秒的单调快推、横移、砸入记作镜头事件,不算跳变)。@@ -128,6 +129,7 @@ uv run --with playwright python engine/render.py --spec clip.json --stills 0.5,2"duration": 7, "fps": 30, "width": 1920, "height": 1080,"safe": { "top": 0, "bottom": 520 }, // 可选:让开的边(px),见下"alpha": false, // 可选:true = 不画背景(render.py --alpha 会自动设上)+ "theme": "wood", // 一支片所有 spec 写同一个:色板名或对象,见上「全片一套色」"data": { ... }, // 语法级参数,各语法认的字段见下面每节的「data」行;不认的字段直接忽略"cues": [ { "at": 1.2, "kind": "bar", "text": "...", "sub": "...", "data": { ... }, "image": "截图.png", "dur": 1.0 } ]}@@ -206,7 +208,7 @@ spec 级 data:`eyebrow`(标题上方小字)、`title`、`subtitle`、`acce#### t3_finance_chart(经济学人式数据图)-spec 级 data:`title`、`unit`(副标题:指标与单位;放不下先缩再折两行)、`source`(左下来源;同上,并让开右下角标)、`badge?`(只有写了才画右下角标,如「示意数据」;真实数据别写)、`chart: "bar"|"line"|"candle"`、`series: [{label, value, color?}]` 或 K 线 `[{label, o, h, l, c}]`、`decimals`(柱/点标签,默认 1)、`prefix`、`suffix`、`highlight: {index, text, sub}`、`colors: {main, accent, dim}`、`upDown: "cn"`(红涨绿跌,默认)`|"us"`、`xAxis: "category"|"time"`(柱默认按类目每根写名字,折线/K 线默认按时间抽稀)、`theme`(也可写在 spec 级 `theme`):`"light"`(白底,默认)`|"paper"`(FT 粉)`|"dark"`(深底浅字)或 `{bg, ink, sub, grid, bar, dim, red…}`;没写主题但 `safe.fill` 写了片子的底色时,图表底就用它,深色自动换深底浅字。+spec 级 data:`title`、`unit`(副标题:指标与单位;放不下先缩再折两行)、`source`(左下来源;同上,并让开右下角标)、`badge?`(只有写了才画右下角标,如「示意数据」;真实数据别写)、`chart: "bar"|"line"|"candle"`、`series: [{label, value, color?}]` 或 K 线 `[{label, o, h, l, c}]`、`decimals`(柱/点标签,默认 1)、`prefix`、`suffix`、`highlight: {index, text, sub}`、`colors: {main, accent, dim}`、`upDown: "cn"`(红涨绿跌,默认)`|"us"`、`xAxis: "category"|"time"`(柱默认按类目每根写名字,折线/K 线默认按时间抽稀)、`theme`(也可写在 spec 级 `theme`):`"light"`(白底,默认)`|"dark"`(深底浅字)、八套色板名(`"paper"` 现在是纸本色板)或 `{bg, ink, sub, grid, bar, dim, red…}`;没写主题但 `safe.fill` 写了片子的底色时,图表底就用它,深色自动换深底浅字。**图表镜头留在片子的世界里**:图表的底和前后镜头同色系(深色片用 `theme:"dark"` 或把片子底色写进 `safe.fill`),不要在夜景、深色片里突然切到一张白底报表;更好的是把图表画在片子世界里的物上——`--alpha` 出透明片段,贴到片子里的屏幕、黑板、一张纸上。@@ -285,7 +287,7 @@ spec 级 data:无。#### y4_storytime(豆子角色讲故事:气泡、反应特写、插入镜头)-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 只让字(气泡、插入镜头的大字);角色、桌子、反应特写的脸是图形,竖屏下会伸进字幕带——字幕压在身体上读得清,但别指望它们让开。+spec 级 data:`character`——**必须是你自己的帧库**(AI 生帧,见 `references/10-角色.md`,交付线见 `references/角色精细度.md`);代码画的预设(`neutral`/`bun`/`author`)和造型对象已停用,写了或不写都启动失败。没有生图能力就别用 y4,换 y2/y5 或 scenes 用手和物讲。帧库写一个目录(render.py 把文件名去扩展名当姿势名:`rest talk point shrug type stiff react back`,`<姿势>_open` 是张嘴帧),也可写 `{"frames": {"talk": "我/talk.png", …}}`;帧图透明底、脚底在图片底边中间,至少要有 rest 或 talk。镜头定住、角色不呼吸,变化靠快切、反应特写砸进来和插入镜头。有 `window.VO_ENV` 就按口播包络对口型,没有就按字数合成。safe 只让字(气泡、插入镜头的大字);角色、桌子、反应特写的脸是图形,竖屏下会伸进字幕带——字幕压在身体上读得清,但别指望它们让开。| kind | 字段 | 说明 | 示例 ||---|---|---|---|diff --git "a/references/10-\350\247\222\350\211\262.md" "b/references/10-\350\247\222\350\211\262.md"index 130a346..f6bd1a9 100644--- "a/references/10-\350\247\222\350\211\262.md"+++ "b/references/10-\350\247\222\350\211\262.md"@@ -5,11 +5,11 @@## 角色实现的选择同一角色可用三种方式实现(A、B的并排图见`assets/角色/花叔形象_对比.jpg`;C的效果见Kurzgesagt与白板示范片):-- **A 代码画**:几何角色与运动白模适用,复杂人脸的表现有限。+- **A 代码画**:只用于运动白模、预演和纯几何符号(方块、终端这类本来就是几何的东西)。人、拟人角色、机器人、长了脸的物不用代码画进成片,见`references/角色精细度.md`。- **B 已定帧库直接贴**:容易保持角色一致,但需要协调帧库与场景的画风。- **C 按该片画风生成动作帧再合成**:用参考图保持身份,绿幕抠图后交给代码控制动作与材质。-真人和拟人角色优先采用B或C,几何角色可以继续用代码画。风格卡里保留了各类角色的已知短板。+真人和拟人角色只用B或C,做完过`references/角色精细度.md`的交付线;没有生图能力就只出手和背影,或不出人。风格卡里保留了各类角色的已知短板。## B:贴已定帧库@@ -31,4 +31,4 @@## 什么时候还用代码画-几何角色(方块、终端、机器人、小鸟、猫)、剪影、极简符号人(哈林小人、白板火柴人)可以代码画。`lib/rig.js` 的少女/猫骨架与 `rig_huashu.js` 保留:用于运动参考(手在哪、脚在哪,给 AI 帧定锚点)、白模预演、几何风格。+成片里:剪影、背影、手(照所在画风画到位),以及本来就是几何体的东西(方块、终端窗口)。机器人、Q 版小人、火柴人演故事、给物加脸,这几样停用,理由和替代做法见`references/角色精细度.md`。`lib/rig.js` 的少女/猫骨架与 `rig_huashu.js`、`lib/toon.js` 保留:用于运动参考(手在哪、脚在哪,给 AI 帧定锚点)、白模预演,以及艺术史速通这类风格示范里已经定稿的角色。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 d3b18e2..b2f2482 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% 后停)。一张小卡漂在大片光斑上,就是第五种做坏方式「死背景」。参数化片段 t2 默认就是这样:截图满幅铺开(等比不裁,四周垫同图的压暗模糊版),highlight 那一刻快推过去,连着两张截图之间同倍率横移 0.30 秒;旧的玻璃卡要显式写 `data.frame: "glass"`。自己写镜头用 `CAM.track`(脉冲镜头)和 `MD.cover`(满幅+焦点+推近)。+2. **截图要大。** 有截图的镜头,截图宽度 ≥ 画宽 80%(竖屏 ≥ 90%),再推近到口播正在说的那一块(快推 0.28 秒推近 18–32% 后停)。一张小卡漂在大片光斑上,就是第四种做坏方式「死背景」。参数化片段 t2 默认就是这样:截图满幅铺开(等比不裁,四周垫同图的压暗模糊版),highlight 那一刻快推过去,连着两张截图之间同倍率横移 0.30 秒;旧的玻璃卡要显式写 `data.frame: "glass"`。自己写镜头用 `CAM.track`(脉冲镜头)和 `MD.cover`(满幅+焦点+推近)。3. **数版式。** 把分镜里每一屏的版式写出来(标题屏、三卡并排、大数字、截图卡),同一种连续出现 ≥2 屏就换一种:截图推近、数字砸入、前后对比。「标题 → 三张功能卡 → 大数字」整片循环,就是翻页 PPT。4. **落定后停住。** 不加卡片漂浮、不用匀速慢推填停顿;下一个动作放在口播说到名词或数字的那一刻。数字讲的是刚才那张截图里的事(两次计时之比、这一页的结论),number 写 `data.over: true`:镜头拉回整张截图、截图压暗、数字砸在上面,不切到光斑底单独一屏。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 1a2720b..6705636 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"@@ -39,6 +39,7 @@- 品红:`#BE3A95`、`#C83C7F`- 高光与白字:`#E7DFE1`、`#F9FCFB`- 规律:一个深底配 2–3 个高饱和强调色,强调色互为对比(橙黄对靛紫、青对品红)【实测+归纳】+ - **上面这套深紫底只是拆解记录,成片不要照抄。** 作者看过多支 AI 做的片子,原话是「我们需要规避下蓝、紫渐变的垃圾配色,这种非常ai slop」;深紫星空底正是这类片子最常见的一眼 AI 味,`deliver.py` 会量蓝紫底并红灯。要深色系就用 `references/色板.md` 的 `ink`(深墨)或 `navy`(海军蓝平涂),保留「一个深底配 2–3 个高饱和强调色」的规律;参数化片段 y1 写 `"theme"` 即可,不写时默认是深墨平涂。- **形状语言**:- 不描边。阴影用同色相深一档的色块,高光是白色椭圆或一条弧线【归纳】。- 圆角无处不在。生物是团状有机形,角色头是圆的,四肢是圆头管。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 4ab3602..c43f143 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,7 +106,7 @@- **复用 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, char, pose, expr, mouth, blink, look, squash, bob, tilt, lw})`:正面豆子角色,全部 Path2D 程序化,返回双手和头的坐标(给道具、符号定位)。`char` 默认 `'neutral'`(短发、蓝 T),另有 `'bun'`(丸子头),`'author'` 是示范片里作者本人的造型(白渔夫帽、圆眼镜),只在讲作者自己的故事时显式写;也可以传造型对象覆盖颜色、发型、帽子、眼镜(见 `TOON.LOOKS`)。参数化片段 y4 用 `data.character` 选,也接受自己的帧库目录。+ - `TOON.bean(c, {x, y, s, char, pose, expr, mouth, blink, look, squash, bob, tilt, lw})`:正面豆子角色,全部 Path2D 程序化,返回双手和头的坐标(给道具、符号定位)。这套代码画的豆子角色只留给示范片和白模预演:作者看过多个模型做的片子后,判代码画的小人是一眼 AI 味(原话「很多视频里用到的小人和机器人角色都太差了」)。参数化片段 y4 只接受你自己的帧库(`data.character.frames`,AI 生帧,见 10 号和 `references/角色精细度.md`),没有帧库启动就失败。- `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`。diff --git "a/references/\350\211\262\346\235\277.md" "b/references/\350\211\262\346\235\277.md"new file mode 100644index 0000000..78e7759--- /dev/null+++ "b/references/\350\211\262\346\235\277.md"@@ -0,0 +1,38 @@+# 色板:一支片一套色++镜头表表前的「色板」一行,从这里挑一套写名字,或者按文末的规则自己定 3–6 个色值。所有参数化片段的 spec 写同一个 `"theme"`,scenes 里也只用这几个色(加减明暗、透明度可以,别引入新色相)。++## 先说禁区++**蓝紫渐变底、深紫星空底、霓虹青紫光效、紫色毛玻璃**:作者原话「我们需要规避下蓝、紫渐变的垃圾配色,这种非常ai slop」。这几样是 AI 做动画最常落进去的默认色,观众一眼就读成「AI 做的」。++`deliver.py` 会量出来:一帧里 30% 以上是蓝紫(色相 225°–300°、饱和度 ≥0.30)就算蓝紫帧,蓝紫帧占全片 30% 以上红灯,不出片。题材本身就要蓝紫时(用户点名的赛博朋克紫、梵高星月夜这类风格画面),交付时加 `--allow-blue-purple "理由"`,降为黄灯,理由写进交付说明的事实段。++海军蓝平涂(色相约 210°,见下面 navy)不在禁区里:它是有意图的单一底色,不是渐变也不发光。++## 八套现成色板++每套 6 个键:`bg` 底、`surface` 卡片/纸/面板、`ink` 主字、`sub` 次字和细线、`accent` 主强调、`accent2` 副强调。片段 spec 里写 `"theme": "wood"`,或者写成对象 `{"name": "wood", "accent": "#B8452A"}` 只改其中一个键。++| 名字 | 适合 | bg | surface | ink | sub | accent | accent2 |+|---|---|---|---|---|---|---|---|+| `paper` 纸本 | 人文、历史、读书、解释一个道理 | #F3EDE2 | #FBF8F2 | #1B1A17 | #6B655B | #C8402F | #2F5D62 |+| `poster` 海报黄 | 观点、冲突、要一句话砸进去的科普 | #FFD23F | #FFF6D6 | #111111 | #4A4433 | #FF5A36 | #14213D |+| `ink` 深墨 | 科技、夜景、严肃话题 | #121417 | #1E2226 | #F2EFE8 | #A39E93 | #F2B33D | #5FB3A1 |+| `navy` 海军 | 产品、数据、手机与电子设备(平涂,不渐变) | #0D1B2A | #16293D | #EEF3F6 | #8FA3B3 | #5CC8E0 | #F2A93B |+| `bauhaus` 包豪斯 | 设计、结构、几何、流程 | #EFE9DD | #FFFFFF | #111111 | #555555 | #D62828 | #1D4E89 |+| `snow` 雪原 | 冬天、医疗、清洁、实验室 | #E9EEF0 | #FFFFFF | #1F2A30 | #5E6B72 | #D9482B | #3E7C8C |+| `wood` 暖木 | 生活、厨房、手作、家里的事 | #EDE3D1 | #F7F1E6 | #2B2622 | #7A6E62 | #C4552D | #3F5B4B |+| `chalk` 黑板 | 课堂、推导、公式、讲题 | #23302B | #2E3D37 | #F1EFE6 | #A9B3AA | #F4D35E | #E87D5A |++## 自己定一套++- 3–6 个色:一个底,一个面,一个主字,一个次字,一两个强调。强调色一镜里只用来指一个东西。+- 底色先定:亮底(纸、雪、木)还是暗底(墨、海军、黑板),全片不在亮暗之间来回跳。+- 色值避开蓝紫区:色相 225°–300° 且饱和度 ≥0.30 的色不当底、不大面积用。`storyboard_lint` 查色板里的色值,落在这一区红灯。+- 不用渐变底,不加霓虹外发光。要层次就用纸纹、颗粒、明暗两层平涂。+- 有真实素材(截图、照片)时,从素材里取一两个色当强调,底色仍然用这一套。++## 自检++交付前把抽帧排成一排看:底色是不是从头到尾同一个亮度区间,强调色是不是只有那一两个,有没有哪一镜突然冒出白底柱状图、紫色星空、霓虹边框这种「别的片子的颜色」。有,就把那一镜按色板重画。diff --git "a/references/\350\247\222\350\211\262\347\262\276\347\273\206\345\272\246.md" "b/references/\350\247\222\350\211\262\347\262\276\347\273\206\345\272\246.md"new file mode 100644index 0000000..f416f31--- /dev/null+++ "b/references/\350\247\222\350\211\262\347\262\276\347\273\206\345\272\246.md"@@ -0,0 +1,57 @@+# 角色精细度:要么画到位,要么不出脸++画面里只要出现人、拟人角色、吉祥物、机器人,或者长了脸的东西,开工前读这一页。作者看过多个模型做的片子,原话是:++- 「很多视频里用到的小人和机器人角色都太差了,我们应该自己来定义一部分的精细度和用力的要求」+- 「颜色和人的风格形象都有些ai slop」「金币和小人形象的界面有些ai slop」++**粗糙的角色比没有角色更差。** 观众看见一个圆头豆豆眼的小人,第一反应是「AI 做的」,后面讲得再好也被这一眼拖下去。++## 先选路:三条路,只有三条++镜头表表前的「角色」一行,写的就是这里选了哪条:++| 角色行写 | 什么时候走 | 怎么做 |+|---|---|---|+| `帧库 <路径>` | 有生图能力(当前会话有生图工具,或用户给了角色图) | 按 `references/10-角色.md` 的 B/C 法做 AI 生帧帧库,过下面的「交付线」 |+| `只出手和背影` | 没有生图能力,但故事需要一个人 | 只画手(握着物、指着物、把物放进口袋)、背影、剪影、过肩;脸不出画 |+| `无` | 故事可以只靠物讲 | 物本身做主角:一块电池、一袋面包、一本书,靠形状、颜色、动作讲,不给它加脸 |++**停用的**(代码画出来就是 AI 味,lint 和评审都会拦):++- 通用 Q 版小人:圆头、豆豆眼、腮红、没脖子、身体是一个圆角矩形。+- 白壳机器人:白色圆壳、蓝色面罩、一根天线,悬浮或喷火。+- 长了脸的东西:带笑脸的金币、会皱眉的锂离子、有眼睛的小球、表情包式的电池。+- 火柴人、哈林小人,用来演故事时(白板语法里画一个示意符号不算演故事)。++`y4` 片段只接受帧库(`data.character.frames`),没有帧库启动就失败。引擎里代码画的角色(`lib/toon.js` 的 neutral/bun/author)不再给成片用。++## 交付线:帧库角色要过这八条++做出来先截一张角色特写(放大到 2 倍),对着下面逐条打勾,写进交付说明。过不了的,回到生图那一步重做,或改走「只出手和背影」。++1. **剪影认得出**:把角色涂成纯黑,还认得出是谁、在做什么动作。圆+圆角矩形拼出来的人认不出。+2. **比例有骨架**:有脖子、肩膀、手肘、手腕;头身比按画风定,同一角色在全片里不变。+3. **手是手**:看得出手指或手套的形状,能真的握住物(物在手里,不是贴在手边)。+4. **至少两层明暗**:底色+阴影,再加高光或边缘光;光的方向和场景一致。+5. **至少三处材质细节**:衣褶、缝线、发丝分组、布料纹理、鞋带、表带……挑这个角色身上该有的。+6. **表演是具体的**:每次出场有一个和这一镜内容对得上的表情+姿势(皱眉看手机、松一口气把手机揣进兜里),不是只眨眼、只上下浮动。+7. **和画风同一套**:角色的线条、上色、色板和背景同一种画法,不是一张贴纸贴在别的画上。+8. **前后一致**:同一个角色每一镜的五官、发型、衣服、配色一致。++## 物不加脸:怎么让物「演」++把概念讲活不需要给它画脸。++- **用形状和动作**:锂离子在冷的时候挤成一团、走得慢;热起来散开、跑得快。电量条在冷风里一格一格缩下去。+- **用尺度**:一个东西从手心大小砸到铺满画面。+- **用对比**:同一个物左右两份,一份冻住、一份正常。+- **用真实的物**:真实的电池剖面、真实的冰霜纹理、真实的屏幕截图。++## 自检++交付前抽 6 帧有角色或物的画面并排看,问三个问题:++1. 有没有一眼像「AI 默认小人」或「白壳机器人」的东西?有,就换路。+2. 有没有给不该有脸的东西画了脸?有,就去掉脸,改用动作讲。+3. 角色和背景是不是同一种画法?不是,就按画风重做角色,或者让人只出手。diff --git "a/references/\351\225\234\345\244\264\350\241\250\346\250\241\346\235\277.md" "b/references/\351\225\234\345\244\264\350\241\250\346\250\241\346\235\277.md"index 0d89ad9..42684ea 100644--- "a/references/\351\225\234\345\244\264\350\241\250\346\250\241\346\235\277.md"+++ "b/references/\351\225\234\345\244\264\350\241\250\346\250\241\346\235\277.md"@@ -2,13 +2,17 @@轨道档的第 1 步。开阔档也建议先写一张,lint 可跑可不跑。-一张镜头表就是这支片子的分镜:每行一镜,写清楚这一镜画面里**有什么物、它在做什么、镜头怎么动、屏上有几个字、用什么做**。写得出这张表,片子就不会变成一页越堆越长的 PPT;写不出某一行,说明那一镜还没想清楚,先别写代码。+一张镜头表就是这支片子的分镜:先锁一套画风,再每行一镜,写清楚这一镜画面里**有什么物、它在做什么、镜头怎么动、屏上有几个字、用什么做**。写得出这张表,片子就不会变成一页越堆越长的 PPT,也不会变成每镜一种画风的拼贴;写不出某一行,说明那一镜还没想清楚,先别写代码。## 怎么写-复制下面这张空表到 `<项目>/镜头表.md`,一行一镜往下填:+复制下面这段到 `<项目>/镜头表.md`,先填表前三行,再一行一镜往下填:```markdown+画风:(一句话:一张风格卡或一种画法,全片只用这一种)+色板:(references/色板.md 里的名字,或 3–6 个 #色值)+角色:(无/只出手和背影/帧库 <路径>)+| 时间段 | 画面里的物 | 它在做什么 | 镜头 | 屏上字 | 做法 ||---|---|---|---|---|---|| 0–3 | (名词:一个人、一个东西) | (动词:它正在干什么) | 停/快推/横移/砸入/切 | (≤8 字,可空) | (y4 片段 镜01.json/scenes/xxx.js/素材 照片) |@@ -21,18 +25,24 @@| 它在做什么 | 动词,这个物自己的动作:飘进来、裂开、钻进去、被切掉 | 出现、显示、展示、淡入、逐条出现 || 镜头 | 这一镜的主动作,五选一:停/快推/横移/砸入/切 | 匀速慢推 || 屏上字 | 每镜 ≤8 字,可以空;口播原文交给字幕 | 整句口播、三行要点 |-| 做法 | 用什么做:哪个语法的参数化片段(写 spec 文件名)、`scenes/<id>.js` 代码画、真实素材满幅 | |+| 做法 | 用什么做:哪个语法的参数化片段(写 spec 文件名)、`scenes/<id>.js` 代码画、真实素材满幅 | 每镜换一种语法 || 标签(可选列) | 这一镜贴在物旁边的小标签,用顿号隔开 | 一镜超过 3 个;一排发光胶囊 |+表前三行(画风锁):++- **画风**:一句话写清全片用哪一种画法,例如「暖木色纸本插画,平涂加细铅笔线,厨房午后侧光」。换场景可以,换画风不行:卡通人、暗色代码屏、星空图标、白底柱状图、纸张、网页截图轮流出现,每一镜单看都不错,整片就是拼贴。+- **色板**:`references/色板.md` 里的一套,或 3–6 个色值。所有片段 spec 写同一个 `"theme"`,scenes 也只用这几个色。不用蓝紫渐变、深紫星空、霓虹青紫。用户点名要蓝紫(赛博朋克紫、梵高星月夜)才加一行「允许蓝紫:理由」。+- **角色**:画面里要出现人或拟人角色,先读 `references/角色精细度.md`。有生图能力就 AI 生帧,写「帧库 <路径>」;没有就写「只出手和背影」或「无」,用手、背影、剪影、物件讲故事。代码画的 Q 版小人、白壳机器人、长了脸的金币和小球已经停用。+五条要求,写完逐条对:1. **开头 3 秒是一个具体的小场景,结尾也落在主角或主物的一个动作上**:开头是一个人或一个物在做一件和题目有关的事,不是标题,不是「今天我们来讲」;结尾是放进口袋、合上书、拉远看全貌这类动作,字可以写在画里的物上,不收在居中金句卡上。-2. **全片一个例子或一个角色贯穿**:同一片面包、同一个人、同一台机器从头走到尾,各镜讲的是它身上发生的事。+2. **全片一个例子贯穿、一套画风到底**:同一片面包、同一双手、同一台机器从头走到尾,各镜讲的是它身上发生的事;每一镜都在画风锁那一行写的画风里。3. **一镜 2–6 秒**:个别镜可以到 8 秒。4. **文字主导的镜头 ≤30%**:物列是标题/字、屏上字 7 个以上、或用 y5 动态文字做的,都算文字主导。-5. **相邻两镜不用同一版式**:这一镜是满幅特写,下一镜就换成横移、换成图表、换成另一个物。+5. **相邻两镜不用同一构图**:这一镜是满幅特写,下一镜就换成横移、换成另一个物、换个景别。换的是构图和镜头,不是画风。-做法列的两条硬线(轨道档第 3 步也写着):**单个参数化片段最多撑 8 秒**(同一个 .json 在表里合计不超过 8 秒);**一支片至少用 3 种不同的画面做法**(不同语法的片段、scenes 代码画、真实素材满幅,各算一种)。+做法列的两条硬线(轨道档第 3 步也写着):**单个参数化片段最多撑 8 秒**(同一个 .json 在表里合计不超过 8 秒);**一支片最多用 2 种片段语法**,所有 spec 写同一个 `theme`,其余镜头用 scenes 按同一套色板画,或真实素材满幅。## 检查@@ -40,27 +50,31 @@uv run <skill>/scripts/storyboard_lint.py <项目>/镜头表.md --script <项目>/文稿.txt # 有口播稿就带上 --script```-逐镜给红黄绿和改法,有红灯非零退出。红灯就改镜头表、重跑,**红灯没清不许开始写代码**。黄灯可以做,交付说明里逐条写理由。lint 查的是:物列不能空、不能只是版面词、不能是空镜/纯色/黑场这类空画面;做什么列要有动作;屏上字 ≤8;第一镜和最后一镜都不能是文字主导;文字主导 ≤30%;给了 `--script` 时屏上字里的数字(百分数、年份、带单位的数)要在文稿里找得到(文稿写「百分之六十」也认);有「标签」列时一镜超过 3 个标签报黄;单镜 2–6 秒(6–8 秒黄、超过 8 秒红);连续三镜同一个镜头动作报黄;做法列里同一个片段合计超过 8 秒、全片做法少于 3 种报红。「一个例子贯穿」和「相邻版式不同」机器查不了,自己对。+逐镜给红黄绿和改法,有红灯非零退出。红灯就改镜头表、重跑,**红灯没清不许开始写代码**。黄灯可以做,交付说明里逐条写理由。lint 查的是:表前画风、色板、角色三行有没有写;色板里有没有蓝紫色值;角色行是不是代码画的小人,物列里有没有机器人、小人、火柴人而角色不是帧库,用了 y4 却没有帧库,有没有给金币、小球长脸;物列不能空、不能只是版面词、不能是空镜/纯色/黑场这类空画面;做什么列要有动作;屏上字 ≤8;第一镜和最后一镜都不能是文字主导;文字主导 ≤30%;给了 `--script` 时屏上字里的数字(百分数、年份、带单位的数)要在文稿里找得到(文稿写「百分之六十」也认);有「标签」列时一镜超过 3 个标签报黄;单镜 2–6 秒(6–8 秒黄、超过 8 秒红);连续三镜同一个镜头动作报黄;做法列里同一个片段合计超过 8 秒、片段语法超过 2 种报红。「一个例子贯穿」「每镜真的是同一种画风」「相邻构图不同」机器查不了,自己对。## 示例:为什么面包会发霉(54 秒,横屏)-这是写法示范:题材、物和镜头顺序不要搬进你的片子。贯穿全片的是同一袋吐司和它的主人小满。+这是写法示范:题材、物和镜头顺序不要搬进你的片子。贯穿全片的是同一袋吐司和主人小满的一双手,脸不出画。++画风:暖木色纸本插画,平涂加细铅笔线,所有镜头同一束厨房午后侧光+色板:wood+角色:只出手(小满的手,不出脸)| 时间段 | 画面里的物 | 它在做什么 | 镜头 | 屏上字 | 做法 ||---|---|---|---|---|---|-| 0–3 | 小满和一袋吐司 | 小满撕开面包袋,手指停在一块青绿色斑点上 | 停 | | y4 片段 镜01.json |+| 0–3 | 小满的手和一袋吐司 | 手撕开面包袋,指尖停在一块青绿色斑点上 | 停 | | scenes/kitchen.js || 3–6 | 那块绿斑 | 绿斑边缘一圈白毛,像地图一样往外扩 | 快推 | 三天前还没有 | 素材 霉面包照片满幅 || 6–10 | 一粒孢子 | 孢子从窗缝飘进来,翻着跟头落到面包上 | 横移 | 孢子 | scenes/spore.js || 10–14 | 那粒孢子 | 孢子壳裂开,伸出一根白丝扎进面包 | 快推 | | scenes/spore.js || 14–18 | 面包切面的气孔 | 白丝沿着气孔分叉,像树根一样往下钻 | 砸入 | 菌丝 | scenes/hyphae.js |-| 18–22 | 面包里的淀粉粒 | 菌丝尖端喷出酶,把淀粉粒剪成一颗颗糖 | 快推 | 淀粉→糖 | y1 片段 镜06.json |+| 18–22 | 面包里的淀粉粒 | 菌丝尖端喷出酶,把淀粉粒剪成一颗颗糖 | 快推 | 淀粉→糖 | scenes/hyphae.js || 22–26 | 厨房墙上的温湿度计 | 指针从 15°C 滑到 28°C,袋子内壁凝出水珠 | 切 | 28°C | scenes/kitchen.js || 26–31 | 两条霉斑面积曲线 | 台面那条一路往上冲,冰箱那条贴着底爬 | 快推 | 冰箱里慢得多 | t3 片段 镜08.json || 31–35 | 霉斑表面的小柱子 | 一根根小柱顶起黑色孢子球,孢子球砰地炸开 | 砸入 | | scenes/hyphae.js || 35–39 | 一团孢子云 | 孢子云飘过桌面,落向旁边那袋馒头 | 横移 | 下一站 | scenes/spore.js |-| 39–43 | 小满的手和面包刀 | 小满想把绿斑那一角切掉,剩下的接着吃 | 停 | 切掉就行? | y4 片段 镜11.json |+| 39–43 | 小满的手和面包刀 | 刀尖比着绿斑那一角,想切掉剩下的接着吃 | 停 | 切掉就行? | scenes/kitchen.js || 43–47 | 被切开的面包剖面 | 透视一层层剥开,看不见的菌丝早已爬满半片 | 快推 | 看不见的部分 | scenes/hyphae.js |-| 47–51 | 小满和垃圾桶 | 小满把整袋吐司丢进去,扣上盖子 | 切 | | y4 片段 镜13.json |-| 51–54 | 小满和一袋新吐司 | 小满把新吐司塞进冷冻层,门一关,霜慢慢爬上袋子 | 砸入 | 冷、干、密封 | scenes/kitchen.js |+| 47–51 | 小满的手和垃圾桶 | 手把整袋吐司丢进去,扣上盖子 | 切 | | scenes/kitchen.js |+| 51–54 | 小满的手和一袋新吐司 | 手把新吐司塞进冷冻层,门一关,霜慢慢爬上袋子 | 砸入 | 冷、干、密封 | scenes/kitchen.js |-为什么这张表能过:开头是小满撕开袋子看见霉斑,不是标题;结尾回到小满手上,她把新吐司塞进冷冻层,三个字写在画里,不是一张金句卡;同一袋吐司从头到尾;14 镜里没有一镜是文字主导;每个 spec 只管一镜(最长 5 秒),scenes 可以跨镜复用;做法有 y4、素材、scenes、y1、t3 五种;镜头动作没有连续三镜相同。第 8 镜的曲线是示意,成片里要标「示意数据」。+为什么这张表能过:表前锁了一种画风、一套色板,人只出手;开头是一双手撕开袋子看见霉斑,不是标题;结尾回到同一双手,把新吐司塞进冷冻层,三个字写在画里,不是一张金句卡;同一袋吐司从头到尾;14 镜里没有一镜是文字主导;唯一的参数化片段是第 8 镜的 t3 曲线,它的 spec 写 `"theme": "wood"`,和 scenes 同一套色;镜头动作没有连续三镜相同。第 8 镜的曲线是示意,成片里要标「示意数据」。diff --git a/release-manifest.json b/release-manifest.jsonindex 768207b..9a9e140 100644--- a/release-manifest.json+++ b/release-manifest.json@@ -3,11 +3,11 @@"files": {".github/workflows/tests.yml": "91b5797ea6f59b6e31e53de2a846194e33ab1dbe24b2efb8c0ed4367324f8fbe",".gitignore": "64ed0cc55105bb4b33ebd1baadd1eb18c74b604f6bbce0fbaa4c62b5eb425197",- "CHANGELOG.md": "6c7cf14cd6d0f64fc633902fe066b6ac9d0bf57de4e0807ce6c956e70d0db760",+ "CHANGELOG.md": "d364d22a49e51de670e52a90e44e59dc3886d67b9ba543b40512fca5983f68cb","CONTRIBUTING.md": "742a1a6071f6be25e82f0524a520fd6d09961be3f87d7a85940cd816ce7309a1","LICENSE": "6d6a2a9caf2e6d2b76974050427053b2892d8aa4c33fd168ce63a537fcee9d96","README.md": "27a0a515bcaac0f0a73ad0b6ff0786f608869d6b095f8b954644eca8c7c3a950",- "SKILL.md": "b55b4220554f2aa95df49e694bd423a8037ac205eaae04d45abc870d0806b0ab",+ "SKILL.md": "11108db088776f94725d352fe173229bbe7d935d9c85145ae317e18894dfbb11","assets/showcase/egypt.gif": "256b946e2543192153f276dc46e0af98837c934ddb9e2e2c0c9843f0557cd54b","assets/showcase/hero.png": "3b6b42bfb00f84925aebe2a10f85052dc6b4efb492e86f581f21f652b6686407","assets/showcase/mario-claude.gif": "f63f2f464c1d7b477578d07359d85712086a39b615669f1d3bb015290c54741f",@@ -31,13 +31,13 @@"references/01-拆解.md": "83dd492d5b1f616a6e45302b630a7fbcaa65a16120a8df443185df2ee615cb32","references/02-机制.md": "ce0646784363c54e7299b5817aa86953d37b4ae0a245bf1b30aebc5a621ec94b","references/03-一帧先行四条路线.md": "cfc167ff5c13ed29f03fa967be4e775494e2f2d0a1879dfb8473cf2ea432c2d7",- "references/04-纯代码绘制.md": "895b03574fe06d6d9f192f7392b444f317081b3bf17a04d44464c450c4d557a8",+ "references/04-纯代码绘制.md": "7d234b7fb904626cc99af0cb687d3bb7104263c089b3ee2cda59408dc5dfc0eb","references/05-节奏与配乐.md": "1086c15ea216548777d2fa5552cd5c874ff89df2da84f9ffa160737930e3d98f","references/06-口播驱动的艺术短片.md": "9275abd6451831515ed9aed24724062bf47dda5e5d2d804baa8313c137236bc8","references/07-正面经验.md": "fd5f63474f15e01119e10586a14a456f602cf4f6ee03b4359bcf77c084305f1b","references/08-风格作者规范.md": "30312801d2833b478bc80218a704d87971c08f50a7ee0e31f3c08eefe15f9b4e",- "references/09-视频动画语法.md": "57b7616b95562b40ec305edd8e6a0ce678c1dd4c8250b4ef149b1afa25c9e471",- "references/10-角色.md": "0c69bc849688069ee59bfe619eb7c44c48dbeee0324ee2bcc87bbe98d41af74b",+ "references/09-视频动画语法.md": "e3586436b685b818a12e81421dcceb13faacf74abb546fc1a039ac6cc52988df",+ "references/10-角色.md": "d0c90c6c82b9acba9a43b8f0f4231ae4aa2f316a39608af90e06e5462c736605","references/11-长卷穿越片.md": "42f2e441687116c8d2dd789b187ada572390e242976996727a209959163a6ad6","references/12-口播整片与经验回流.md": "b85f6e8b665c13a5d98ea461c10af340679a6949101ee31dd64eee7e88aed415","references/13-口播与语音复刻.md": "cb12d2002f9c7a8a41b9abd711bd44a99f9929bcd66351015232cea2eda024a6",@@ -45,16 +45,18 @@"references/compatibility.md": "c5665580fab722a3ed784a71f5cca725fc56cebf8c8c3ad66219b24b6b97bb0e","references/images.md": "313bee677064eb46ee13c88c74effeecdb536579d7e8a25e23ddf9a2a06357e3","references/动画语法/t1_3b1b.md": "d0f375ca054def2bd7cefd2c17d076d2a83b3a2ee452a0c81836623ded4ae785",- "references/动画语法/t2_keynote_ui.md": "bf5e37bd64b971309ac9b0d7f52e88991cd0a8271cc5b8a12db150c7efbad1ce",+ "references/动画语法/t2_keynote_ui.md": "f47fa0ec256f2c78cdcfbe9b708e42c217b2ae01229da332c2e699814ddf7d43","references/动画语法/t3_finance_chart.md": "e0fe398c8ce28072d696c3b584857052e8154e64e94b9f331a7461b6b99af7b2",- "references/动画语法/y1_kurzgesagt.md": "a0e33e2e69ce36ab784334bafa1efd5ac7f387ade495c2b2a30bdbbb5e2b8291",+ "references/动画语法/y1_kurzgesagt.md": "ad7b18459f1948b7120812919a628816a589a2d0afe1447519378991f8a52661","references/动画语法/y2_vox.md": "f697f34612b8de23720d78768505cd79333b07afd4226f2976b6b01cc099b986","references/动画语法/y3_whiteboard.md": "f2fda7768034d94928982193965f225a3c85a850eaf28f3f28459e85dbe0773d",- "references/动画语法/y4_storytime.md": "a8d48d9c0981cd3e92b22dff1091c99bc7a4130519dbbc81315ef259dbabfa36",+ "references/动画语法/y4_storytime.md": "b561ba51276a9c98bf217aeeeed812b0ecc666d2bd4c2c4d063ea98ff55ad71f","references/动画语法/y5_kinetic_type.md": "97b200e68231d71cd10cf3f1027b4db36e99ce9a06004891d644994883bb15e2","references/动画语法/y6_presenter_explainer.md": "405318fc5aac9ce03cbc374af9633ec7d652dc8206ad3810919abdb174eff273","references/口播API.md": "a9d2775fc97bf92f46cf0a6531f1921ccdcf195dd79475c575bf8f188ca5801e",- "references/镜头表模板.md": "a16065b942c0b6b5a18e8689dbdc1289d0e3c2effcc0be91e1b026b735e48b21",+ "references/色板.md": "3a1588ded19aba078131423b22f97fb8835f1656c1c5643afbba505ff8f6f8ae",+ "references/角色精细度.md": "0a047b3892d1417ee3f19951d4117263145a7067e9c2c847e3217325e4cc6492",+ "references/镜头表模板.md": "cfd1187fe4d00e44170640788408568c2d05fde28d9cb6ace7cdc70878628bc1","references/风格配方/01_cave.md": "ebdb5fc8f9a57d947ef3a325bfdaf275cbd906e36010945e05c7d2e7ef1f4d2c","references/风格配方/02_egypt.md": "a3097d1936d0e482a56a9745e31f3ba9a508aa2db50fbbefba4d97cc4d481ebb","references/风格配方/03_greek.md": "0caa761151cd76d1a31390f602dc6bc131dba745c6244a2b12ba037697077b50",@@ -98,17 +100,17 @@"scripts/audio/synth_艺术史速通.py": "6476605af684b477d47b7f47c3c987059277de36b97bff5d77d167c27efdb40d","scripts/capabilities.py": "43b1dd58d9f42efc638270cf67190ce85dda4e25fd591925c2f31e5bd6b4f63b","scripts/check_release.py": "508388bdcfe87d97d486de7d76fec87b893469779af14cc75e4b72b4c17ecc60",- "scripts/deliver.py": "cd09587548abb5d93277ae73a9f331d3f900541a6163dafc86abf6c5bc7b0c32",- "scripts/engine/clip.html": "dab49e34a45f0dfd8e49fb25444a6d6cd51425a7f53513d0001b0e215f15c343",- "scripts/engine/clip.js": "81c11d0261bd1913a384c25d30458c5dd4eabfda24e786858490d239c6b21191",- "scripts/engine/clips/t1_3b1b.js": "6e819bb9be76db0d8a7220e8aa5fedd83879b24ce6084579d7ac2641d85deaa2",- "scripts/engine/clips/t2_keynote_ui.js": "60d1c0d6ccf9bffa11906cc07e45bee9b8402e70e3c9c7410985a45e6670469f",- "scripts/engine/clips/t3_finance_chart.js": "542d857ccd72ca276ed96978c9875e8b6025949caa97a35c07936eb9473a0ce9",- "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": "b1ebe090c4806d508b0591dc2dd3cb8273cb32c4e3158a5c736132666b74cfed",- "scripts/engine/clips/y5_kinetic_type.js": "b034957c67e18599a753378edc7bebd68e3d651574e951376449eab09275b30f",+ "scripts/deliver.py": "0ce5bdea49243e458a7a7bd0a8b17dac248fd73b0dbb2d99164b22f9ffca693d",+ "scripts/engine/clip.html": "73db3956310c7798452057e4328e961c899507483ab0bb72e817ce0372893874",+ "scripts/engine/clip.js": "e991e5c4edc9f463900cfc42106f5e0eaa2b48a28d3ba30111a3c80a16cf0f44",+ "scripts/engine/clips/t1_3b1b.js": "84ed102301a066410aca1b0d06ba0459f7d5da09ae4831edf58a27f2152a6e7a",+ "scripts/engine/clips/t2_keynote_ui.js": "9f899ddce7a4a7620a4aa0f9c3f4679e6f1c944fb4ec50fd4a65e8fae12fcc31",+ "scripts/engine/clips/t3_finance_chart.js": "f175d45ea92e0a680fea9e08ce9270a59a63a5b4bb3d00db5a894848e2407b36",+ "scripts/engine/clips/y1_kurzgesagt.js": "55c87ccb685feba52b21393f36b06d76c1f43b225223d15c56cf55da7c4f9392",+ "scripts/engine/clips/y2_vox.js": "d332ef089ce1672d0f711cba231f9bda2748bd38781de540e0a4e08ad8628c85",+ "scripts/engine/clips/y3_whiteboard.js": "1536d7a276580edd44fab6199b69671aecbae30b39b5f89921d08e43a738ff2d",+ "scripts/engine/clips/y4_storytime.js": "2ba8c7a05296c489b948c1b2f050a479dcef5a7a19bb1550aca07478f97e25d6",+ "scripts/engine/clips/y5_kinetic_type.js": "80e6f52ae2a07ce4f7c4d15e87e7eddb3174c7770079805d97feaba1f254bd83","scripts/engine/compare.py": "7bf1d5ae2926de09f69431435e93ffa4c5357532b543217cd66bdc57e00256aa","scripts/engine/demos/_shared/hero.js": "96e9e520d1139aa617be7ad01901f6a9b6c31c7948f73b33ddd8d646c6cdf967","scripts/engine/demos/_shared/hero/c1_0.png": "827032c6aa741f9895895224a67f81538d70ef970b10da6c3ee93e8deece3018",@@ -220,15 +222,15 @@"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_fullbleed_pulse.json": "7b5916738df58e3e0377a61be30bd04eba0f65258c172b7dd6ca19d660c4b700",- "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/examples/t1_3b1b.json": "28fa6f76f6849698f30d3fc69918a00ea0a9e99225614905bea5c505b82673c6",+ "scripts/engine/examples/t2_fullbleed_pulse.json": "97d2a492cd3253e4ea0c0b1c499204357254814ce1130e7910bcfd1aaa239f25",+ "scripts/engine/examples/t2_keynote_ui.json": "9643bed1dd75dd4891efb2d364719b80435d55d162859336dba513332c2d81f3",+ "scripts/engine/examples/t3_finance_chart.json": "7537ef8c696349daf9005820c2eb02bd34c48482052bc8e30d21ee476b264efe",+ "scripts/engine/examples/y1_kurzgesagt.json": "4a28c3ff55fdd4a2b327701b062ff6dd3b571036d2a73ec4426bc050d2ddf34b",+ "scripts/engine/examples/y2_vox.json": "965ca7fc646ddbb6e7b81e356e12246c10694cd797b991a5baac14312641feea",+ "scripts/engine/examples/y3_whiteboard.json": "9d5b0b6d4fa447a2e28c1db7447874aeafa26b915960a9beed154f9252e72a14",+ "scripts/engine/examples/y4_storytime.json": "16a334ee71e47504ec74ca992b26b7f663960298bfa8864c11edd275d23b1d7f",+ "scripts/engine/examples/y5_kinetic_type.json": "a17d1f008e68822616560acfaf022304581db2b0fcd0cbc5a6d9c2818b6a9fdb","scripts/engine/index.html": "afc9c95a9ca1386b2f3513fe1fe21e595372c11a084be02b802b0ad254946d8e","scripts/engine/lib/brush.js": "e83db04e5fc9fef83237d984d2ceba3c1ec71c0c2a8f8a798ecc939fc8c3b2d4","scripts/engine/lib/camera.js": "0c155120b4ec80ac97b706e812a54e25fb8c795e76e18e4df2247ad8baa19e84",@@ -288,6 +290,7 @@"scripts/engine/lib/media.js": "a509bf201252636fdd880806f7074c65aaee665d145d54ca6ac3ed39a165ebcf","scripts/engine/lib/motion.js": "420482f3a6917c6b0d505b3d2e83be0df3f44f5966e6d38fc9bf7643900af0fa","scripts/engine/lib/paint.js": "95ccd1945a4a19b6e2d89a422d7ea7de96174acdbae1801090ca9ee48131f9a3",+ "scripts/engine/lib/palettes.js": "934acc426ebdada51f613d6e7b1cb693590d615a01d7a66d5461483bf79ff30a","scripts/engine/lib/post.js": "b63ce9e73929083b4e51cb1caa45f606c6556023b3024da45520386a3d5f6129","scripts/engine/lib/render.js": "d2855f044ddff579000d9f8b1abadc2b76f84875fc604bea79d10319e3fe92bf","scripts/engine/lib/rig.js": "62580706e14438c6b57289ce203d040c91d8a427e356f44084a65dfc53a13bbf",@@ -407,25 +410,28 @@"scripts/engine/scenes/35_shinkai.js": "8e7f5753a0ce49291ae35bc4f471b5ca62448eb9532403459395d88bc524a736","scripts/engine/scenes/36_picasso_blue.js": "10023147e1e31afc162e1cfe51356867ef83595b41bbd5cc824d55532297ce09","scripts/engine/scenes/index.js": "22da1210908a8083658eb53289656eeb578026b6deabc666928014d01ddae23e",- "scripts/engine/spec_assets.py": "0f32fb56eae66532c0bc644519afb1d9d71d36efcf9fe4c19539752387ef7e66",+ "scripts/engine/spec_assets.py": "d963a9fa80a7c71ed4ff20f4bf5ff692b17d53aa49e8b9b234c4a1a671f60d41","scripts/engine/transitions.js": "c4bd441cf765db346933e5d18270f532d4c9782c9303b0bcda1ba59a2124b618","scripts/engine/时代作者规范.md": "4e7661571b60fa0ed776fb5631462aff3a30235c5e6343aa06f9cd23973391fc",- "scripts/film_gate.py": "cb1d2b53c81f151be6b6633a5afdd55485a63bf16a1db499be9107cee140a2b1",+ "scripts/film_gate.py": "d7ec575c05abbaa454f2ca9319d0a5c1bd6d1aded23cc0fdcbdf117fcc3210fe","scripts/font_subset.py": "ed826dffb4b370741602aa79caefd69157fcf6d7f9abd90a9078d4f7208896e0","scripts/images.py": "a47a2663f251525bfbed5b46533e3d43415c9e10c8a2b8a9f754abf204529535","scripts/key_green.py": "11ac28bb2508d6b4a240eb37a55b342a0f556943fe29a17962bbc0f93f90d303","scripts/key_split.py": "889759cd6b5353b4d48d34faf3878682890e06ca79887c9ade9be401b7359f86","scripts/koubo.py": "7837507e6bf02b20f8aa63efdc881c8de0d5de775b4bf31a1040bd3824348494","scripts/qa.py": "a1457de52ee311659039207ef3304b6ade1531f538843a15bb509698e4b37da9",- "scripts/storyboard_lint.py": "f5cac0dc336451ea65fe89892747644ec29b377cf37008768690a658d4b665a9",+ "scripts/storyboard_lint.py": "dc94f349ba94cb519cb362a24ba54b527524db85e2979d359b0e99d4ac9ffbf9","scripts/subzone_gate.py": "8641a3b1b38ac28c1562e454a0e370f36a73d1a0c79cddf36175c7444a9c1598",+ "tests/fixtures/y4_storytime_test_frames.json": "97fe2a512d57afb456dfddd261eefba89731c25f7af0b38383ff70ad6adf8b61","tests/test_capabilities.py": "04ce548d5a72a11a87a3bd85c46a98e13f1aabafb096e3c59a6fc7a20bfdf4ad",- "tests/test_clip_world.py": "9d2393b7eb31787367ef8dd1dd4b28ae53b56941c60ebb4ebf996580be34dd9f",+ "tests/test_clip_theme.py": "efb0f2f6f5b7f180676af8d0929b2f19f4f94ef7af82e4b6f75d29fb8eeae9ad",+ "tests/test_clip_world.py": "95051d28d2c42c14007059211977822204f13210f6ee06c23b8a0b8a89077d1d","tests/test_film_gate.py": "0c138b23b2cc753baff5aac5aa49d4d479729cca21ccda19b3f5dd231342fe3c","tests/test_film_gate_blank.py": "83a74e62484590ee31b0b68950b67c548e57a13c817da18dca8e708b6ab68528",+ "tests/test_film_gate_color.py": "ad00c79f123575746f6fdf44267394bcfe62f53a4385d921ebc86c6f40502848","tests/test_images.py": "5fe7533ec25a2644e3685e1677186eaf1554ebbbcc390fcd56a45afbad872040","tests/test_local_server.py": "b775a60c86c4a0914d67c4cfb7cb37256a447db700bfdba146a2db3704ea83ff","tests/test_release.py": "a190d8825e23f6204263f3d00d6728bf709586bc178c980d53244a82ef198b41",- "tests/test_storyboard_lint.py": "ecbe82aa85188294eaef878036c86a24266facaec04450e181690a1ff9922e40"+ "tests/test_storyboard_lint.py": "a0452a45a0f7fc281227af577dee29e3d7e6ae6991ed9cc92eb46942db5cd24a"}}diff --git a/scripts/deliver.py b/scripts/deliver.pyindex 920fa42..743b6f7 100644--- a/scripts/deliver.py+++ b/scripts/deliver.py@@ -5,7 +5,7 @@"""deliver.py —— 一条命令交付:量门禁 → 红灯不出片;绿灯、黄灯复制成片并写交付说明,说明里的事实由脚本写。uv run deliver.py <成片.mp4> --out output/ [--spec 片段.json | --project <代码工程>] [--qa <qa 输出目录>] [--root <项目目录>]- [--sub-band 0.15] [--vertical auto|yes|no]+ [--sub-band 0.15] [--vertical auto|yes|no] [--allow-blue-purple "理由"]uv run deliver.py --verify output/交付说明.md # 核对事实段有没有被改过做三件事:@@ -14,7 +14,7 @@时长、分辨率、帧率、音轨、文件指纹;门禁各指标和灯;最差 30 秒窗口;qa 跑没跑过、结果如何(读 qa 输出目录里的 qa.json,没有就写「没跑」);有没有独立审片记录(<项目目录>/审片/*.md 在不在,列出文件名;没有就写「没派审片」)。- 3. 事实段末尾带指纹。制作者只在「制作说明」段补主观描述(用了哪个语法、黄灯项为什么可以这样、五种做坏方式自查),+ 3. 事实段末尾带指纹。制作者只在「制作说明」段补主观描述(用了哪个语法、黄灯项为什么可以这样、六种做坏方式自查),不改事实段;改了 --verify 会报出来。约定:@@ -120,6 +120,8 @@ def facts_block(src, dst, info, res, rows, qa_lines, rv_lines):"", "### 门禁(film_gate)", "",f"- 结论:{LIGHT_ZH[gl]}。快速运动帧占比 {res['fast_ratio']}(< 0.035 红灯,< 0.06 黄灯)",f"- 一句话:{ex['summary']}。" + (";".join(ex["why"]) + "。" if ex["why"] else "")]+ if res.get("allow_blue_purple"):+ L.append(f"- 制作者声明题材需要蓝紫(蓝紫门禁降为黄灯):{res['allow_blue_purple']};蓝紫底占 {res['blue_purple_share']:.0%}")if ex["worst_window"]:w = ex["worst_window"]L.append(f"- 最差 {w['end_s'] - w['start_s']:.0f} 秒窗口:{w['start_s']:.0f}–{w['end_s']:.0f}s,快动帧占比 {w['fast_ratio']}")@@ -140,7 +142,7 @@ def write_doc(out, dst, facts, res):look.insert(0, f"门禁黄灯:快速运动帧占比 {res['fast_ratio']}(黄线 0.06)")tail = ["## 制作说明(制作者填写;只写在这一段,事实段不要动)", "","- 用了哪个语法 / 风格:",- "- 「五种做坏方式」逐条自查:",+ "- 「六种做坏方式」逐条自查:","- 黄灯项逐条说明(时间码+为什么可以这样):" + ("" if look else "无黄灯项")]tail += [f" - {t}:" for t in look]doc = f"# 交付说明:{dst.name}\n\n{START}\n{facts}<!-- deliver.py 事实段:结束 sha256={h} -->\n\n" + "\n".join(tail) + "\n"@@ -171,6 +173,8 @@ def main():ap.add_argument("--sub-band", type=float, default=None, help="同 film_gate.py:屏蔽底部字幕带的比例")ap.add_argument("--vertical", default="auto", choices=["auto", "yes", "no"])ap.add_argument("--verify", metavar="交付说明.md", help="只核对事实段有没有被改过")+ ap.add_argument("--allow-blue-purple", metavar="理由", default=None,+ help="同 film_gate.py:题材本身要蓝紫时写理由,理由写进交付说明事实段")a = ap.parse_args()if a.verify:sys.exit(verify(a.verify))@@ -188,7 +192,7 @@ def main():try:info = probe(src)- res, rows = film_gate.measure(str(src), sub_band=a.sub_band, vertical=a.vertical)+ res, rows = film_gate.measure(str(src), sub_band=a.sub_band, vertical=a.vertical, allow_blue_purple=a.allow_blue_purple)except (subprocess.CalledProcessError, StopIteration, KeyError, RuntimeError, ValueError) as e:print(f"读不了这支片:{src}({e})", file=sys.stderr); sys.exit(1)print("\n".join(film_gate.report_lines(res, rows)))diff --git a/scripts/engine/clip.html b/scripts/engine/clip.htmlindex 8fb03b3..a2abb1d 100644--- a/scripts/engine/clip.html+++ b/scripts/engine/clip.html@@ -8,6 +8,7 @@<script src="lib/fonts.js"></script><script src="lib/util.js"></script><script src="lib/paint.js"></script>+<script src="lib/palettes.js"></script><script src="lib/kit.js"></script><script src="lib/motion.js"></script><script src="lib/camera.js"></script>diff --git a/scripts/engine/clip.js b/scripts/engine/clip.jsindex 39e2bc4..8aabc34 100644--- a/scripts/engine/clip.js+++ b/scripts/engine/clip.js@@ -2,6 +2,9 @@// 契约见 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?, frames?, fps?, dur?}] }+// spec.theme:全片共用的色板(lib/palettes.js)——名字(paper poster ink navy bauhaus snow wood chalk)、{name, 要覆盖的键}、或完整 6 键 {bg, surface, ink, sub, accent, accent2}。+// 解析成 ctx.pal(完整 6 键+name),各语法按它上色;名字写错 / 缺键 → 启动失败。不写 → ctx.pal = null,各语法用自己的默认配色。+// 语法可以声明 legacyTheme(theme) → true:这个 theme 是它自己的旧写法(t3 的 'light' / 'dark' / 旧主题对象),不当色板解析,语法照旧读 ctx.theme。// 素材路径(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 会告警) }。@@ -47,6 +50,9 @@ async function boot() {if (x.status !== 200) return fail(`没有这个语法:clips/${spec.grammar}.js(HTTP ${x.status})`);try { (0, eval)(x.responseText + `\n//# sourceURL=clips/${spec.grammar}.js`); } catch (e) { return fail(`clips/${spec.grammar}.js 执行出错 ${e.stack || e}`); }const G = CLIPS[spec.grammar]; if (!G || typeof G.draw !== 'function') return fail(`clips/${spec.grammar}.js 没注册 CLIPS['${spec.grammar}'] = { draw }`);+ // 主题色板:在加载素材之前核,写错就别白等图片+ let pal = null;+ if (!(G.legacyTheme && G.legacyTheme(spec.theme))) { try { pal = PAL.resolve(spec.theme); } catch (e) { return fail(e.message); } }// 图片const IMG = {}, urls = new Set();for (const q of (spec.cues || [])) {@@ -69,7 +75,7 @@ async function boot() {for (const q of cues) if (q.kind === 'number') { const cap = q.text ?? q.sub ?? (q.data && q.data.text); if (cap != null) { q.text = cap; q.sub = cap; } }const safe = { top: 0, bottom: 0, left: 0, right: 0, ...(spec.safe || {}) }; // 让开的边(px):管线烧录字幕、平台 UI 压在这里,带字的语法不往里排const box = { x: safe.left, y: safe.top, w: W - safe.left - safe.right, h: H - safe.top - safe.bottom }; // 让开之后的内容框,语法排版用它(ctx.box)- const ctx = { spec, data: spec.data || {}, theme: spec.theme || {}, cues, W, H, FPS, u: Math.min(W, H) / 1080, portrait: H > W, alpha: !!spec.alpha, IMG, dur: spec.duration, safe, box,+ const ctx = { spec, data: spec.data || {}, theme: spec.theme || {}, pal, 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),// 素材: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),diff --git a/scripts/engine/clips/t1_3b1b.js b/scripts/engine/clips/t1_3b1b.jsindex 5a41358..4bc656b 100644--- a/scripts/engine/clips/t1_3b1b.js+++ b/scripts/engine/clips/t1_3b1b.js@@ -11,10 +11,16 @@// 公式太宽就整体缩字号(所有公式同一字号,Transform 时不跳),竖屏长公式不出画。// 字形:CMU 斜体把 θ 画成 ϑ,θ 改用 EB Garamond 斜体(闭合的 θ);连续两个以上的字母(softmax、ReLU)按正体单词排,单个字母才是斜体变量。// alpha:透明底时字外面描一圈深色边,压在亮画面上也看得见。+// spec.theme(全片色板 ctx.pal):底 bg、字 ink、变灰的旧要点和坐标轴 sub、强调框与 Indicate accent、默认曲线色 accent2;+// cue 里写的 manim 色名也映射进色板(YELLOW/GOLD/ORANGE/RED/MAROON/PINK → accent,BLUE/TEAL/GREEN/PURPLE → accent2,GREY → sub,WHITE → ink),#hex 照写的用。CLIPS.t1_3b1b = (() => {const { clamp, lerp } = U;-let M, L;+let M, L, INK = '#fff';const col = v => !v ? null : M[v] || v;+// 全片色板时 manim 色名 → 色板里的色(只认 DG.MANIM 里有的名字;#hex 原样)+const palMap = p => { const m = { ...DG.MANIM };+ for (const k in m) m[k] = /^(YELLOW|GOLD|ORANGE|RED|MAROON|PINK)/.test(k) ? p.accent : /^(BLUE|TEAL|GREEN|PURPLE)/.test(k) ? p.accent2 : /^GRE[YA]_[AB]$/.test(k) ? PAL.mix(p.sub, p.ink, 0.4) : /^GRE[YA]/.test(k) ? p.sub : k === 'WHITE' ? p.ink : k === 'BLACK' ? p.bg : m[k];+ return m; };const isZh = ch => ch.codePointAt(0) >= 0x2E80;// 一段字 → token:汉字/全角走普惠体;连续 ≥2 个字母是单词(正体);单个字母斜体;其余(数字、符号、希腊字母)正体const toks = text => (String(text).match(/[A-Za-z]{2,}|./gu) || []).flatMap(s => s.length > 1 && !/[a-z]/.test(s) ? [...s] : [s]) // 全大写的一串(QK)是几个变量,拆开@@ -52,7 +58,7 @@ return {fonts: ['PuHui-Medium'],safe: true,init(ctx) {- M = DG.MANIM; DG.FONT.zh = 'PuHui-Medium'; // 任意中文:普惠体(思源宋子集只有示范片用到的字)+ M = ctx.pal ? palMap(ctx.pal) : DG.MANIM; INK = ctx.pal ? ctx.pal.ink : '#fff'; DG.FONT.zh = 'PuHui-Medium'; // 任意中文:普惠体(思源宋子集只有示范片用到的字)const { W, H, u, safe } = ctx, g = document.createElement('canvas').getContext('2d');const pad = (ctx.portrait ? 70 : 140) * u, yTop = safe.top, yBot = H - safe.bottom - (ctx.portrait ? 90 : 70) * u;const hasLine = ctx.of('line').length > 0, hasEq = ctx.of('equation').length > 0;@@ -99,13 +105,13 @@ return {draw(c0, t, ctx) {const { W, H, u } = ctx;const c = ctx.alpha ? (BUF = BUF || document.createElement('canvas'), BUF.width = W, BUF.height = H, BUF.getContext('2d')) : c0;- if (!ctx.alpha) { c.fillStyle = '#000'; c.fillRect(0, 0, W, H); }+ if (!ctx.alpha) { c.fillStyle = ctx.pal ? ctx.pal.bg : '#000'; c.fillRect(0, 0, W, H); }// ---- 标题(同一时间只有一个,换标题 = 旧的上移淡出、新的 Write) ----L.titles.forEach((z, i) => {const q = z.q, nx = L.titles[i + 1], out = nx ? MO.smooth(MO.seg(t, nx.q.at - 0.45, nx.q.at)) : 0; if (out >= 1 || ctx.lt(t, q.at) <= 0) return;const n = [...(q.text || '')].length, dur = q.dur || clamp(n / 14, 0.6, 1.6);c.save(); c.globalAlpha = 1 - out; c.translate(0, -50 * u * out);- z.lines.forEach((ln, k) => writeT(c, toks(ln), W / 2, L.titleY + k * z.size * 1.25, z.size, ctx.p(t, q.at + k * dur / z.lines.length, dur / z.lines.length), { col: col(q.data && q.data.color) || '#fff' }));+ z.lines.forEach((ln, k) => writeT(c, toks(ln), W / 2, L.titleY + k * z.size * 1.25, z.size, ctx.p(t, q.at + k * dur / z.lines.length, dur / z.lines.length), { col: col(q.data && q.data.color) || INK }));c.restore();});// ---- 公式:第一个 Write,之后每个从上一个 TransformMatchingTex 过来 ----@@ -115,15 +121,15 @@ return {let k = -1; eqCues.forEach((q, i) => { if (ctx.lt(t, q.at) > 0) k = i; });if (k >= 0) {const q = eqCues[k], tk = eqs[k], Ln = layoutT(c, tk, sz), tot = Ln.length ? Ln[Ln.length - 1].x + Ln[Ln.length - 1].w : 0, x0 = W / 2 - tot / 2;- if (k === 0) writeT(c, tk, W / 2, L.eqY, sz, ctx.p(t, q.at, q.dur || 1.2));+ if (k === 0) writeT(c, tk, W / 2, L.eqY, sz, ctx.p(t, q.at, q.dur || 1.2), { col: INK });else {const p = MO.smooth(ctx.p(t, q.at, q.dur || 1.5)), old = eqs[k - 1], Lo = layoutT(c, old, sz), toto = Lo.length ? Lo[Lo.length - 1].x + Lo[Lo.length - 1].w : 0, xo = W / 2 - toto / 2;const used = new Set(), from = tk.map(nt => { const j = old.findIndex((ot, jj) => !used.has(jj) && ot.s === nt.s && (ot.sub || '') === (nt.sub || '') && (ot.sup || '') === (nt.sup || '')); if (j >= 0) used.add(j); return j; });const one = (tok, x, a, cl) => { if (a <= 0) return; c.save(); c.globalAlpha *= a; withFont(tok, t2 => DG.math(c, [{ ...t2, col: cl }], x, L.eqY, sz, { p: 1, align: 'left' })); c.restore(); };- old.forEach((ot, j) => { if (!used.has(j)) { c.save(); c.translate(0, -30 * u * p); one(ot, xo + Lo[j].x, 1 - clamp(p * 1.6), ot.col || '#fff'); c.restore(); } }); // 对不上的旧符号:淡出上移+ old.forEach((ot, j) => { if (!used.has(j)) { c.save(); c.translate(0, -30 * u * p); one(ot, xo + Lo[j].x, 1 - clamp(p * 1.6), ot.col || INK); c.restore(); } }); // 对不上的旧符号:淡出上移tk.forEach((nt, i) => { const j = from[i];- if (j >= 0) one(nt, lerp(xo + Lo[j].x, x0 + Ln[i].x, p), 1, DG.mix(old[j].col || '#ffffff', nt.col || '#ffffff', p)); // 同名符号:移到新位置,颜色插值- else { c.save(); c.translate(0, 30 * u * (1 - p)); one(nt, x0 + Ln[i].x, clamp((p - 0.35) / 0.65), nt.col || '#fff'); c.restore(); } }); // 新符号:淡入+ if (j >= 0) one(nt, lerp(xo + Lo[j].x, x0 + Ln[i].x, p), 1, DG.mix(old[j].col || INK, nt.col || INK, p)); // 同名符号:移到新位置,颜色插值+ else { c.save(); c.translate(0, 30 * u * (1 - p)); one(nt, x0 + Ln[i].x, clamp((p - 0.35) / 0.65), nt.col || INK); c.restore(); } }); // 新符号:淡入}if (Ln.length) eqBox = { x: x0 - 20 * u, y: L.eqY - sz * 0.95, w: tot + 40 * u, h: sz * 1.35 };}@@ -143,7 +149,7 @@ return {if (j === 0) {const cp = MO.smooth(ctx.p(t, l.q.at + 0.5, l.q.dur || 1.4));if (cp > 0) { const cum = DG.cum(l.scr); c.strokeStyle = lc; const tip = DG.drawPartial(c, l.scr, cum, cum[cum.length - 1] * cp);- if (cp < 1) DG.neuron(c, tip[0], tip[1], 10 * u, 1, { fill: lc, stroke: '#fff', lw: 2 * u }); }+ if (cp < 1) DG.neuron(c, tip[0], tip[1], 10 * u, 1, { fill: lc, stroke: INK, lw: 2 * u }); }label(c, l, MO.smooth(MO.seg(cp, 0.8, 1)), lc, u);} else {const pv = L.lines[j - 1], p = MO.smooth(ctx.p(t, l.q.at, l.q.dur || 1.5)), pc = col(pv.d.color) || M.BLUE_C;@@ -168,7 +174,7 @@ return {// Indicate:放大 1.2、染黄、回来;之后这一条保持黄色(被强调的留住),其余变灰const ip = h && !hOther ? ctx.p(t, h.at, 0.8) : 0, ind = DG.indicate(ip), keep = h && !hOther ? MO.smooth(clamp(ip * 2)) : 0;const dim = keep > 0 ? 0 : dimN;- const base = DG.mixA(DG.mixA('#ffffff', M.GREY_C, dim), M.YELLOW, Math.max(keep, ind.k)), colr = DG.rgba(base);+ const base = DG.mixA(DG.mixA(INK, M.GREY_C, dim), M.YELLOW, Math.max(keep, ind.k)), colr = DG.rgba(base);const bx = L.text.x + 14 * u, by = it.y - size * 0.36;c.save(); c.translate(bx, by); c.scale(ind.s, ind.s); c.translate(-bx, -by);DG.neuron(c, bx, by, 12 * u, 1 - dim * 0.6, { lw: 2 * u, stroke: colr, fill: col(q.data && q.data.color) || M.BLUE_C, sa: MO.smooth(ctx.p(t, q.at, 0.3)) });@@ -189,9 +195,9 @@ function label(c, l, a, colr, u) { if (!l.q.text || a <= 0) return; const e = l.c.save(); c.globalAlpha *= a; c.font = `${40 * u}px "PuHui-Medium"`; c.fillStyle = colr; c.textAlign = 'right'; c.fillText(l.q.text, e[0], e[1] - 30 * u); c.restore(); }// 强调框:Circumscribe 先绕一圈(1s),同时 SurroundingRectangle 画出来并留住(末帧有焦点)function box(c, x, y, w, h, lt, u) {- if (lt <= 0) return; DG.circumscribe(c, x - 8 * u, y - 8 * u, w + 16 * u, h + 16 * u, MO.seg(lt, 0, 1.0), { lw: 4 * u });+ if (lt <= 0) return; DG.circumscribe(c, x - 8 * u, y - 8 * u, w + 16 * u, h + 16 * u, MO.seg(lt, 0, 1.0), { lw: 4 * u, col: M.YELLOW });const p = MO.smooth(MO.seg(lt, 0.3, 1.0)); if (p <= 0) return;- const pts = DG.rectPts(x + w / 2, y + h / 2, w, h, 120); c.save(); c.strokeStyle = DG.MANIM.YELLOW; c.lineWidth = 3 * u; c.lineJoin = 'round';+ const pts = DG.rectPts(x + w / 2, y + h / 2, w, h, 120); c.save(); c.strokeStyle = M.YELLOW; c.lineWidth = 3 * u; c.lineJoin = 'round';DG.drawPartial(c, [...pts, pts[0]], DG.cum([...pts, pts[0]]), DG.len([...pts, pts[0]]) * p); c.restore();}})();diff --git a/scripts/engine/clips/t2_keynote_ui.js b/scripts/engine/clips/t2_keynote_ui.jsindex 3a7354c..ca25846 100644--- a/scripts/engine/clips/t2_keynote_ui.js+++ b/scripts/engine/clips/t2_keynote_ui.js@@ -16,10 +16,20 @@// 说明是黑底撕边标签。数字讲的就是这张截图里的事(两次计时之比、这一页的结论)时用它;和截图无关的数字照旧单独一屏// 竖屏:第一张卡进来时标题缩成页眉留在顶上(不让上下大片空着);卡片按剩余高度放大。safe:版面只排在 top..H−bottom 之间。// alpha:不画光斑底;卡片垫一层深色、字带投影,压在亮画面上也看得清。+// 不写 theme:近黑底上琥珀/青绿/浅青/珊瑚四团慢飘的光斑(不再有蓝紫光斑)。+// spec.theme(全片色板 ctx.pal):平涂 bg 底(只有极轻的暗角,不画光斑、不画毛玻璃和扫光),卡片 surface 实色,标题与卡标题 ink、说明 sub,+// 强调色(步骤号、框、副标签)accent(data.accent 写了照用),框不发光;满幅截图四周的模糊底压一层 bg,撕边标签 ink 底 bg 字。CLIPS.t2_keynote_ui = (() => {const { clamp, lerp } = U;const SANS = '"Inter", "PuHui-Medium"', SANSB = '"Inter", "PuHui-Bold"', ZH = '"PuHui-Medium"', ZHB = '"PuHui-Bold"';-let BL, slides, scr = {}, G;+let BL, slides, scr = {}, G, T;+// 文字与小件的颜色:默认(深色光斑底上的白字)一套,全片色板时从 6 个键派生一套+const T0 = { title: '#f5f3ff', eyebrow: '#a7a7b4', subtitle: '#c9c9d4', head: '#f5f5f7', body: 'rgba(235,235,245,0.66)', body2: 'rgba(235,235,245,0.62)', tile: 'rgba(255,255,255,0.10)', icon: '#f2f2f7',+ num: '#fff', numLabel: 'rgba(235,235,245,0.6)', rule: 'rgba(255,255,255,0.12)', frame: 'rgba(255,255,255,0.22)', bigLabel: '#a7a7b4', bigCap: 'rgba(235,235,245,0.78)', fullBg: '#0b0b0f', accent: '#3d6bff' };+const fromPal = p => ({ pal: p, title: p.ink, eyebrow: p.sub, subtitle: p.sub, head: p.ink, body: p.sub, body2: p.sub, tile: PAL.alpha(p.ink, 0.07), icon: p.ink,+ num: p.ink, numLabel: p.sub, rule: PAL.alpha(p.ink, 0.14), frame: PAL.alpha(p.sub, 0.35), bigLabel: p.sub, bigCap: PAL.alpha(p.ink, 0.78), fullBg: p.bg, accent: p.accent,+ labBg: p.ink, labFg: p.bg, vig: PAL.dark(p) ? '0,0,0' : PAL.rgb(p.ink).join(',') });+const onAcc = acc => T.pal ? PAL.on(acc, [T.pal.surface, T.pal.ink, T.pal.bg]) : '#fff';const track = (c, size, em = -0.02) => { c.letterSpacing = (size * em).toFixed(2) + 'px'; };// 本语法自带的几个线性图标(UI.icon 只有 wave/memory/agent):单位框 ±0.5,圆头等线宽const ICON = {@@ -46,8 +56,9 @@ return {safe: true,init(ctx) {const { W, H, u, safe } = ctx;- BL = [{ x: .22 * W, y: .28 * H, r: .4 * Math.max(W, H), col: [150, 90, 238], a: .75, ax: .11 * W, ay: .11 * H, period: 11, ph: 0 },- { x: .79 * W, y: .24 * H, r: .37 * Math.max(W, H), col: [56, 104, 255], a: .7, ax: .1 * W, ay: .15 * H, period: 13, ph: 2.1 },+ T = ctx.pal ? fromPal(ctx.pal) : T0;+ BL = [{ x: .22 * W, y: .28 * H, r: .4 * Math.max(W, H), col: [214, 140, 52], a: .7, ax: .11 * W, ay: .11 * H, period: 11, ph: 0 },+ { x: .79 * W, y: .24 * H, r: .37 * Math.max(W, H), col: [38, 150, 136], a: .7, ax: .1 * W, ay: .15 * H, period: 13, ph: 2.1 },{ x: .69 * W, y: .86 * H, r: .3 * Math.max(W, H), col: [120, 214, 255], a: .5, ax: .13 * W, ay: .09 * H, period: 9.5, ph: 4 },{ x: .27 * W, y: .89 * H, r: .27 * Math.max(W, H), col: [255, 96, 84], a: .42, ax: .09 * W, ay: .08 * H, period: 12, ph: 1.3 }];const hasTitle = ctx.of('title').length > 0, hdr = ctx.portrait && hasTitle;@@ -104,11 +115,14 @@ return {}},draw(c, t, ctx) {- const { W, H, u, data: d } = ctx, acc = d.accent || '#3d6bff';+ const { W, H, u, data: d } = ctx, acc = d.accent || T.accent;// ---- 底:光斑(只依赖片段时间,连续) ----let bd = null;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) {+ if (!ctx.alpha && !covered && T.pal) { // 全片色板:平涂底+极轻暗角+ c.drawImage(PAINT.cached('clip_t2flat_' + T.pal.bg + W + 'x' + H, W, H, g => { g.fillStyle = T.pal.bg; g.fillRect(0, 0, W, H);+ const vg = g.createRadialGradient(W / 2, H / 2, Math.min(W, H) * 0.45, W / 2, H / 2, Math.max(W, H) * 0.7); vg.addColorStop(0, `rgba(${T.vig},0)`); vg.addColorStop(1, `rgba(${T.vig},0.08)`); g.fillStyle = vg; g.fillRect(0, 0, W, H); }), 0, 0);+ } else 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)');@@ -130,10 +144,10 @@ return {c.translate(W / 2, cy + ty); c.scale(sc, sc); c.translate(-W / 2, -cy);const aSide = 1 - out;if (!keep) { c.globalAlpha = 1 - out; if (out > 0) c.filter = `blur(${(20 * out * u).toFixed(1)}px)`; }- if (eb && aSide > 0) { c.save(); c.globalAlpha *= keep ? aSide : 1; c.font = `500 ${34 * u}px ${ZH}`; c.fillStyle = '#a7a7b4'; c.letterSpacing = `${6 * u}px`; TY.blurIn(c, eb, W / 2, cy - sz.size * 0.95, MO.appleOut(ctx.p(t, qt.at, 0.7)), { blur: 10 * u, dy: 16 * u }); c.restore(); }- c.font = `600 ${sz.size}px ${SANSB}`; track(c, sz.size); c.fillStyle = '#f5f3ff';+ if (eb && aSide > 0) { c.save(); c.globalAlpha *= keep ? aSide : 1; c.font = `500 ${34 * u}px ${ZH}`; c.fillStyle = T.eyebrow; c.letterSpacing = `${6 * u}px`; TY.blurIn(c, eb, W / 2, cy - sz.size * 0.95, MO.appleOut(ctx.p(t, qt.at, 0.7)), { blur: 10 * u, dy: 16 * u }); c.restore(); }+ c.font = `600 ${sz.size}px ${SANSB}`; track(c, sz.size); c.fillStyle = T.title;sz.lines.forEach((ln, i) => TY.blurIn(c, ln, W / 2, cy + i * sz.size * 1.1, MO.appleOut(ctx.p(t, qt.at + 0.15 + i * 0.12, 1.0)), { blur: 26 * u, dy: 40 * u }));- if (sub && aSide > 0) { c.save(); c.globalAlpha *= keep ? aSide : 1; c.letterSpacing = '0px'; c.font = `400 ${46 * u}px ${ZH}`; c.fillStyle = '#c9c9d4';+ if (sub && aSide > 0) { c.save(); c.globalAlpha *= keep ? aSide : 1; c.letterSpacing = '0px'; c.font = `400 ${46 * u}px ${ZH}`; c.fillStyle = T.subtitle;TY.wrap(c, sub, W * 0.84).forEach((ln, i) => TY.blurIn(c, ln, W / 2, cy + (sz.lines.length - 1) * sz.size * 1.1 + 110 * u + i * 62 * u, MO.appleOut(ctx.p(t, qt.at + 0.5, 0.9)), { blur: 12 * u, dy: 22 * u })); c.restore(); }c.restore();}@@ -166,9 +180,10 @@ function drawFull(c, s, t, ctx, acc) {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); }+ if (!ctx.alpha) { c.fillStyle = T.fullBg; 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'; });+ if (!ctx.alpha) { const bg = PAINT.cached('t2full_bg_' + slides.indexOf(s) + '_' + W + 'x' + H + (T.pal ? T.pal.bg : ''), W, H, gg => { gg.filter = T.pal ? 'blur(48px) saturate(0.5)' : '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';+ if (T.pal) { gg.fillStyle = PAL.alpha(T.pal.bg, 0.8); gg.fillRect(0, 0, W, H); } }); // 全片色板:模糊底上再压八成底色,四周和前后镜头同色、只透一点截图的影子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();@@ -179,8 +194,8 @@ function drawFull(c, s, t, ctx, acc) {// 标签:屏幕层,不跟镜头;压在内容框左下角(截图自己的标题多在上面,不挡它),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' });+ if (q.text) MD.label(c, q.text, lx, yMain, { t, at: q.at, size, bg: T.labBg, fg: T.labFg });+ 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: onAcc(acc) });for (const qn of s.nums || []) overNumber(c, qn, t, ctx);c.restore();}@@ -193,9 +208,9 @@ function overNumber(c, q, t, ctx) {const fw = c.measureText(fmtNum(nd, 1)).width; if (fw > bx.w * 0.86) size *= bx.w * 0.86 / fw;const cx = bx.x + bx.w / 2, cy = bx.y + bx.h / 2 + size * 0.3 - (cap ? 40 * u : 0), my = cy - size * 0.3, z = MO.slamK(ctx.lt(t, t0) / MO.PULSE.slam, 1.35, 0.96);c.save(); c.translate(cx, my); c.scale(z, z); c.translate(-cx, -my);- c.font = `600 ${size}px ${SANSB}`; track(c, size, -0.03); c.fillStyle = '#ffffff'; c.shadowColor = 'rgba(0,0,0,0.6)'; c.shadowBlur = 30 * u;+ c.font = `600 ${size}px ${SANSB}`; track(c, size, -0.03); c.fillStyle = T.pal ? (PAL.dark(T.pal) ? T.pal.ink : T.pal.surface) : '#ffffff'; c.shadowColor = 'rgba(0,0,0,0.6)'; c.shadowBlur = 30 * u;TY.tabular(c, fmtNum(nd, k), cx, cy, { align: 'center' }); c.restore();- if (cap) MD.label(c, cap, cx, cy + 110 * u, { t, at: t0 + 0.2, size: (ctx.portrait ? 54 : 48) * u, align: 'center' });+ if (cap) MD.label(c, cap, cx, cy + 110 * u, { t, at: t0 + 0.2, size: (ctx.portrait ? 54 : 48) * u, align: 'center', bg: T.labBg, fg: T.labFg });}// 截图上的 highlight:at 这一帧框开始弹出,其余压暗,一道光扫过框内;只认落在这一屏在屏期间的 highlightfunction hlOn(g, cd, f, t, ctx, acc, u, until) {@@ -205,11 +220,11 @@ function hlOn(g, cd, f, t, ctx, acc, u, until) {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.save(); g.strokeStyle = acc; g.lineWidth = 5 * u; if (!T.pal) { 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(); }+ 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 = onAcc(acc); g.textBaseline = 'middle'; g.fillText(qh.text, clamp(R.x, f.x, f.x + f.w - lw) + 18 * u, ly + 25 * u); g.restore(); }}}// 截图卡的屏幕几何@@ -224,53 +239,54 @@ function rowGeo(j, n, ctx, total) {// 一张卡:弹簧从下方升起+绕 Y 轴转正;内容画进离屏纹理(毛玻璃按卡片的屏幕位置取样),再伪 3D 贴回function drawCard(c, cd, i, t, leave, ctx, bd, geo, key) {const { u, data: d } = ctx, q = cd.q, lt = ctx.lt(t, q.at); if (lt <= 0) return;- const sp = MO.spring(lt, { duration: 0.7, bounce: 0.15 }), acc = d.accent || '#3d6bff';+ const sp = MO.spring(lt, { duration: 0.7, bounce: 0.15 }), acc = d.accent || T.accent;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;if (ctx.alpha) { g.fillStyle = 'rgba(12,12,22,0.62)'; g.beginPath(); g.roundRect(pad, pad, Bw, Bh, 34 * u); g.fill(); }- UI.glass(g, { x: pad, y: pad, w: Bw, h: Bh, r: 34 * u, bd, sample: { x: cx - sw / 2, y: cy - sh / 2, w: sw, h: sh }, tint: ctx.alpha ? 0.08 : 0.075, stroke: 0.22, light: 0.14, shadow: false });+ if (T.pal && !ctx.alpha) { g.fillStyle = T.pal.surface; g.beginPath(); g.roundRect(pad, pad, Bw, Bh, 34 * u); g.fill(); g.strokeStyle = PAL.alpha(T.pal.sub, 0.3); g.lineWidth = 1.5; g.stroke(); } // 全片色板:实色卡片,不是毛玻璃+ else UI.glass(g, { x: pad, y: pad, w: Bw, h: Bh, r: 34 * u, bd, sample: { x: cx - sw / 2, y: cy - sh / 2, w: sw, h: sh }, tint: ctx.alpha ? 0.08 : 0.075, stroke: 0.22, light: 0.14, shadow: false });g.save(); g.translate(pad, pad);if (cd.im) imgContent(g, cd, Bw, Bh, t, ctx, acc); else featContent(g, cd, Bw, Bh, lt, t, ctx, acc);- UI.sheen(g, UI.rrPath(0, 0, Bw, Bh, 34 * u), MO.seg(lt, 0.4, 1.2), { x0: 0, x1: Bw, width: 120 * u, angle: -0.35, alpha: 0.16 }); // 光扫过整张卡(入场后 0.4s)+ if (!T.pal) UI.sheen(g, UI.rrPath(0, 0, Bw, Bh, 34 * u), MO.seg(lt, 0.4, 1.2), { x0: 0, x1: Bw, width: 120 * u, angle: -0.35, alpha: 0.16 }); // 光扫过整张卡(入场后 0.4s)g.restore();c.save(); c.globalAlpha = a;- UI.shadow(c, cx - sw / 2 + 10 * u, cy - sh / 2 + 20 * u, sw - 20 * u, sh - 20 * u, 34 * u, { blur: 80 * u, oy: 40 * u, alpha: 0.55 });+ UI.shadow(c, cx - sw / 2 + 10 * u, cy - sh / 2 + 20 * u, sw - 20 * u, sh - 20 * u, 34 * u, { blur: 80 * u, oy: 40 * u, alpha: T.pal && !PAL.dark(T.pal) ? 0.16 : 0.55 });UI.persp(c, tex, { cx, cy, w: tex.width * sc, h: tex.height * sc, ry, persp: 1800 * u, strip: 3, shade: 0.35 });c.restore();}// 步骤号徽章function badge(g, x, y, s, n, acc, u) { g.fillStyle = acc; g.beginPath(); g.roundRect(x, y, s, s, s * 0.28); g.fill();- g.fillStyle = '#fff'; g.font = `700 ${s * 0.5}px ${SANSB}`; g.textAlign = 'center'; g.textBaseline = 'middle'; g.fillText(String(n).padStart(2, '0'), x + s / 2, y + s / 2 + 2 * u); g.textAlign = 'left'; g.textBaseline = 'alphabetic'; }+ g.fillStyle = onAcc(acc); g.font = `700 ${s * 0.5}px ${SANSB}`; g.textAlign = 'center'; g.textBaseline = 'middle'; g.fillText(String(n).padStart(2, '0'), x + s / 2, y + s / 2 + 2 * u); g.textAlign = 'left'; g.textBaseline = 'alphabetic'; }// 截图卡的内容:步骤号+标题+说明,截图 contain;highlight 框出一块function imgContent(g, cd, Bw, Bh, t, ctx, acc) {const { u } = ctx, q = cd.q, B = cd.box, I = B.img, hp = 40 * u, bs = 70 * u;badge(g, hp, hp, bs, cd.n, acc, u);if (B.side) { // 左字右图:标题、说明在左栏往下排const tw = B.side - hp, tl = fitB(g, q.text || '', tw, 58 * u, 'PuHui-Bold', { maxLines: 3, weight: '600 ' });- g.font = `600 ${tl.size}px ${ZHB}`; g.fillStyle = '#f5f5f7'; tl.lines.forEach((ln, k) => g.fillText(ln, hp, hp + bs + 70 * u + k * tl.size * 1.25));- if (q.sub) { const sl = fitB(g, q.sub, tw, 34 * u, 'PuHui-Medium', { maxLines: 5 }); g.font = `400 ${sl.size}px ${ZH}`; g.fillStyle = 'rgba(235,235,245,0.66)';+ g.font = `600 ${tl.size}px ${ZHB}`; g.fillStyle = T.head; tl.lines.forEach((ln, k) => g.fillText(ln, hp, hp + bs + 70 * u + k * tl.size * 1.25));+ if (q.sub) { const sl = fitB(g, q.sub, tw, 34 * u, 'PuHui-Medium', { maxLines: 5 }); g.font = `400 ${sl.size}px ${ZH}`; g.fillStyle = T.body;sl.lines.forEach((ln, k) => g.fillText(ln, hp, hp + bs + 70 * u + tl.lines.length * tl.size * 1.25 + 30 * u + k * sl.size * 1.4)); }} else {const tx = hp + bs + 26 * u, tw = Bw - tx - hp;if (ctx.portrait) { // 竖屏:卡头高一些,标题、说明字大一号- const tl = fitB(g, q.text || '', tw, 56 * u, 'PuHui-Bold', { maxLines: 2, weight: '600 ', min: 0.7 }); g.font = `600 ${tl.size}px ${ZHB}`; g.fillStyle = '#f5f5f7';+ const tl = fitB(g, q.text || '', tw, 56 * u, 'PuHui-Bold', { maxLines: 2, weight: '600 ', min: 0.7 }); g.font = `600 ${tl.size}px ${ZHB}`; g.fillStyle = T.head;tl.lines.forEach((ln, k) => g.fillText(ln, tx, hp + tl.size * 0.85 + k * tl.size * 1.2));// 标题占两行时说明只留一行,卡头放得下- if (q.sub) { const sl = fitB(g, q.sub, tw, 34 * u, 'PuHui-Medium', { maxLines: tl.lines.length > 1 ? 1 : 2, min: 0.75 }); g.font = `400 ${sl.size}px ${ZH}`; g.fillStyle = 'rgba(235,235,245,0.66)';+ if (q.sub) { const sl = fitB(g, q.sub, tw, 34 * u, 'PuHui-Medium', { maxLines: tl.lines.length > 1 ? 1 : 2, min: 0.75 }); g.font = `400 ${sl.size}px ${ZH}`; g.fillStyle = T.body;sl.lines.forEach((ln, k) => g.fillText(ln, tx, hp + tl.size * 0.85 + (tl.lines.length - 1) * tl.size * 1.2 + 24 * u + sl.size + k * sl.size * 1.35)); }} else {const tl = TY.fit(g, q.text || '', tw, 46 * u, 'PuHui-Bold', { maxLines: 1, weight: '600 ' });- g.font = `600 ${tl.size}px ${ZHB}`; g.fillStyle = '#f5f5f7'; g.fillText(tl.lines[0] || '', tx, hp + (q.sub ? 32 * u : 48 * u));- if (q.sub) { const sl = TY.fit(g, q.sub, tw, 28 * u, 'PuHui-Medium', { maxLines: 1 }); g.font = `400 ${sl.size}px ${ZH}`; g.fillStyle = 'rgba(235,235,245,0.62)'; g.fillText(sl.lines[0] || '', tx, hp + 74 * u); }+ g.font = `600 ${tl.size}px ${ZHB}`; g.fillStyle = T.head; g.fillText(tl.lines[0] || '', tx, hp + (q.sub ? 32 * u : 48 * u));+ if (q.sub) { const sl = TY.fit(g, q.sub, tw, 28 * u, 'PuHui-Medium', { maxLines: 1 }); g.font = `400 ${sl.size}px ${ZH}`; g.fillStyle = T.body2; g.fillText(sl.lines[0] || '', tx, hp + 74 * u); }}}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(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();+ g.strokeStyle = T.frame; 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();// 框出重点(和满幅模式同一套):只认落在这张卡在屏期间的 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; })();hlOn(g, cd, f, t, ctx, acc, u, nxAt);@@ -278,29 +294,29 @@ function imgContent(g, cd, Bw, Bh, t, ctx, acc) {// 无图功能卡的内容:图标(或步骤号)→ 大标题 → 说明 →(可选)大数字计数。横屏竖卡上下排,竖屏横卡左右排function featContent(g, cd, Bw, Bh, lt, t, ctx, acc) {const { u } = ctx, q = cd.q, dd = q.data || {}, hasNum = dd.value != null, pad = 48 * u, tile = (ctx.portrait ? 110 : 120) * u;- const drawTile = (x, y) => { g.fillStyle = 'rgba(255,255,255,0.10)'; g.beginPath(); g.roundRect(x, y, tile, tile, 26 * u); g.fill();- if (!dd.icon || icon(g, dd.icon, x + tile / 2, y + tile / 2, tile * 0.6, '#f2f2f7', t) === false) {- g.fillStyle = acc; g.beginPath(); g.roundRect(x, y, tile, tile, 26 * u); g.fill(); g.fillStyle = '#fff'; g.font = `700 ${tile * 0.46}px ${SANSB}`; g.textAlign = 'center'; g.textBaseline = 'middle';+ const drawTile = (x, y) => { g.fillStyle = T.tile; g.beginPath(); g.roundRect(x, y, tile, tile, 26 * u); g.fill();+ if (!dd.icon || icon(g, dd.icon, x + tile / 2, y + tile / 2, tile * 0.6, T.icon, t) === false) {+ g.fillStyle = acc; g.beginPath(); g.roundRect(x, y, tile, tile, 26 * u); g.fill(); g.fillStyle = onAcc(acc); g.font = `700 ${tile * 0.46}px ${SANSB}`; g.textAlign = 'center'; g.textBaseline = 'middle';g.fillText(String(cd.n).padStart(2, '0'), x + tile / 2, y + tile / 2 + 3 * u); g.textAlign = 'left'; g.textBaseline = 'alphabetic'; } };- const num = (x, y, size, align) => { const v = MO.expoOut(clamp((lt - 0.35) / 0.9)); g.save(); g.font = `600 ${size}px ${SANSB}`; track(g, size, -0.03); g.fillStyle = '#fff';- TY.tabular(g, fmtNum(dd, v), x, y, { align }); g.restore(); if (dd.label) { g.font = `400 ${28 * u}px ${ZH}`; g.fillStyle = 'rgba(235,235,245,0.6)'; g.textAlign = align; g.fillText(dd.label, x, y + 46 * u); g.textAlign = 'left'; } };+ const num = (x, y, size, align) => { const v = MO.expoOut(clamp((lt - 0.35) / 0.9)); g.save(); g.font = `600 ${size}px ${SANSB}`; track(g, size, -0.03); g.fillStyle = T.num;+ TY.tabular(g, fmtNum(dd, v), x, y, { align }); g.restore(); if (dd.label) { g.font = `400 ${28 * u}px ${ZH}`; g.fillStyle = T.numLabel; g.textAlign = align; g.fillText(dd.label, x, y + 46 * u); g.textAlign = 'left'; } };g.textAlign = 'left'; g.textBaseline = 'alphabetic';if (!ctx.portrait) {drawTile(pad, pad);const tl = fitB(g, q.text || '', Bw - 2 * pad, 64 * u, 'PuHui-Bold', { maxLines: 2, weight: '600 ', min: 0.6 });- let y = pad + tile + 40 * u + tl.size; g.font = `600 ${tl.size}px ${ZHB}`; g.fillStyle = '#f5f5f7'; tl.lines.forEach((ln, k) => g.fillText(ln, pad, y + k * tl.size * 1.2)); y += (tl.lines.length - 1) * tl.size * 1.2;- if (q.sub) { const sl = fitB(g, q.sub, Bw - 2 * pad, (hasNum ? 32 : 38) * u, 'PuHui-Medium', { maxLines: hasNum ? 2 : 4, min: 0.75 }); g.font = `400 ${sl.size}px ${ZH}`; g.fillStyle = 'rgba(235,235,245,0.66)';+ let y = pad + tile + 40 * u + tl.size; g.font = `600 ${tl.size}px ${ZHB}`; g.fillStyle = T.head; tl.lines.forEach((ln, k) => g.fillText(ln, pad, y + k * tl.size * 1.2)); y += (tl.lines.length - 1) * tl.size * 1.2;+ if (q.sub) { const sl = fitB(g, q.sub, Bw - 2 * pad, (hasNum ? 32 : 38) * u, 'PuHui-Medium', { maxLines: hasNum ? 2 : 4, min: 0.75 }); g.font = `400 ${sl.size}px ${ZH}`; g.fillStyle = T.body;sl.lines.forEach((ln, k) => g.fillText(ln, pad, y + 26 * u + sl.size + k * sl.size * 1.45)); }- if (hasNum) { g.fillStyle = 'rgba(255,255,255,0.12)'; g.fillRect(pad, Bh - pad - 200 * u, Bw - 2 * pad, 1.5); num(pad, Bh - pad - 66 * u, Math.min(128 * u, (Bw - 2 * pad) / Math.max(3, fmtNum(dd, 1).length) * 1.6), 'left'); }+ if (hasNum) { g.fillStyle = T.rule; g.fillRect(pad, Bh - pad - 200 * u, Bw - 2 * pad, 1.5); num(pad, Bh - pad - 66 * u, Math.min(128 * u, (Bw - 2 * pad) / Math.max(3, fmtNum(dd, 1).length) * 1.6), 'left'); }} else {drawTile(pad, (Bh - tile) / 2);const tx = pad + tile + 34 * u, nw = hasNum ? Math.min(340 * u, Bw * 0.36) : 0, tw = Bw - tx - pad - nw;const tl = fitB(g, q.text || '', tw, 62 * u, 'PuHui-Bold', { maxLines: 2, weight: '600 ', min: 0.6 }); // 标题放不下就折两行,不再截掉后半句const sl = q.sub ? fitB(g, q.sub, tw, 38 * u, 'PuHui-Medium', { maxLines: tl.lines.length > 1 ? 1 : 2, min: 0.75 }) : { lines: [], size: 0 };const tH = tl.size + (tl.lines.length - 1) * tl.size * 1.15, blk = tH + (sl.lines.length ? 22 * u + sl.lines.length * sl.size * 1.4 : 0), y0 = (Bh - blk) / 2 + tl.size * 0.85;- g.font = `600 ${tl.size}px ${ZHB}`; g.fillStyle = '#f5f5f7'; tl.lines.forEach((ln, k) => g.fillText(ln, tx, y0 + k * tl.size * 1.15));+ g.font = `600 ${tl.size}px ${ZHB}`; g.fillStyle = T.head; tl.lines.forEach((ln, k) => g.fillText(ln, tx, y0 + k * tl.size * 1.15));const ys = y0 + (tl.lines.length - 1) * tl.size * 1.15;- g.font = `400 ${sl.size}px ${ZH}`; g.fillStyle = 'rgba(235,235,245,0.66)'; sl.lines.forEach((ln, k) => g.fillText(ln, tx, ys + 22 * u + sl.size + k * sl.size * 1.4));+ g.font = `400 ${sl.size}px ${ZH}`; g.fillStyle = T.body; sl.lines.forEach((ln, k) => g.fillText(ln, tx, ys + 22 * u + sl.size + k * sl.size * 1.4));if (hasNum) num(Bw - pad, Bh / 2 + 20 * u, Math.min(96 * u, nw / Math.max(3, fmtNum(dd, 1).length) * 1.7), 'right');}}@@ -312,12 +328,12 @@ function drawNumber(c, s, t, leave, ctx, shadowText) {if (leave > 0) { c.filter = `blur(${(16 * leave * u).toFixed(1)}px)`; }const str = fmtNum(nd, k), full = fmtNum(nd, 1);c.font = `600 ${220 * u}px ${SANSB}`; track(c, 220 * u, -0.03); let size = 220 * u; const fw = c.measureText(full).width; if (fw > W * 0.88) size *= W * 0.88 / fw;- c.font = `600 ${size}px ${SANSB}`; track(c, size, -0.03); c.fillStyle = '#fff';+ c.font = `600 ${size}px ${SANSB}`; track(c, size, -0.03); c.fillStyle = T.num;const y = G.cy + size * 0.32 - (cap ? 30 * u : 0);TY.tabular(c, str, W / 2, y, { align: 'center' });c.letterSpacing = '0px';- if (nd.label) { c.font = `500 ${34 * u}px ${ZH}`; c.fillStyle = '#a7a7b4'; c.fillText(nd.label, W / 2, y - size * 0.85); }- if (cap) { c.font = `400 ${(ctx.portrait ? 46 : 44) * u}px ${ZH}`; c.fillStyle = 'rgba(235,235,245,0.78)'; TY.wrap(c, cap, W * 0.84).forEach((ln, i) => c.fillText(ln, W / 2, y + 100 * u + i * 60 * u)); }+ if (nd.label) { c.font = `500 ${34 * u}px ${ZH}`; c.fillStyle = T.bigLabel; c.fillText(nd.label, W / 2, y - size * 0.85); }+ if (cap) { c.font = `400 ${(ctx.portrait ? 46 : 44) * u}px ${ZH}`; c.fillStyle = T.bigCap; TY.wrap(c, cap, W * 0.84).forEach((ln, i) => c.fillText(ln, W / 2, y + 100 * u + i * 60 * u)); }c.restore();}})();diff --git a/scripts/engine/clips/t3_finance_chart.js b/scripts/engine/clips/t3_finance_chart.jsindex 3133f63..67a3786 100644--- a/scripts/engine/clips/t3_finance_chart.js+++ b/scripts/engine/clips/t3_finance_chart.js@@ -3,7 +3,10 @@// chart: 'bar'|'line'|'candle', series: [{label, value}] 或 K 线 [{label, o, h, l, c}], decimals=1, prefix='', suffix='',// highlight?: {index, text, sub}, colors?: {main, accent, dim}, upDown?: 'cn'(红涨绿跌,默认)|'us', theme? }// 主题(图表镜头要留在片子的世界里,底和前后镜头同色系):spec.theme 或 data.theme,-// 'light'(白底,默认)| 'paper'(FT 三文鱼粉)| 'dark'(深底浅字)| 对象 {bg, ink, sub, src, tick, xlab, grid, red, bar, dim}(写了 bg 按它的明暗选浅/深一套,再逐项覆盖)。+// 全片色板名(paper / poster / ink / navy / bauhaus / snow / wood / chalk,见 lib/palettes.js)→ 按 ctx.pal 上色:底 bg、字 ink、次要字和刻度 sub、+// 折线/标注/大数字 accent、柱子 accent2;K 线涨跌仍按 upDown 用红绿(语义色)。+// 旧写法照旧:'light'(白底,默认)| 'dark'(深底浅字)| 对象 {bg, ink, sub, src, tick, xlab, grid, red, bar, dim}(写了 bg 按它的明暗选浅/深一套,再逐项覆盖)。+// 'paper' 现在是全片色板「纸本」(以前是 FT 三文鱼粉)。// 没写主题但 spec.safe.fill 写了片子的底色:图表底就用它,深色底自动换深底浅字——不再在深色片里冒出一张白卡。// cues(at 秒):title(版式)· bar|line|candle(数据从 at 开始长出,dur 默认按根数;柱状图可写多个 bar cue,各带 data.index(数或数组)=这几根在这一刻才长,让每根柱子踩自己的那个词)// series 每项可写 color(柱子自己的颜色,和片里别处同一个量的配色对上)· highlight(at 这一帧标注圆点弹出;text/sub 覆盖 data.highlight,data.index 指定第几根)@@ -13,14 +16,20 @@ CLIPS.t3_finance_chart = (() => {const { clamp, lerp } = U;const THEMES = {light: { bg: '#FFFFFF', ink: '#0C0C0C', sub: '#4F5B61', src: '#7c868b', tick: '#5b666b', xlab: '#3a4246', grid: 'rgba(12,12,12,0.13)', red: '#E3120B', bar: '#006BA2', dim: '#C6D2D8' },- paper: { bg: '#FFF1E5', ink: '#0C0C0C', sub: '#4F5B61', src: '#7c868b', tick: '#5b666b', xlab: '#3a4246', grid: 'rgba(12,12,12,0.13)', red: '#E3120B', bar: '#0F5499', dim: '#D9CBBF' },dark: { bg: '#0E1116', ink: '#F2F4F5', sub: '#A7B2B8', src: '#848F95', tick: '#9AA5AB', xlab: '#C3CBD0', grid: 'rgba(255,255,255,0.14)', red: '#FF4B3E', bar: '#3EBCD2', dim: '#3A4650' },};const lum = col => { const m = String(col).trim().match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i); if (!m) return 1;const h = m[1].length === 3 ? [...m[1]].map(x => x + x).join('') : m[1], [r, g, b] = [0, 2, 4].map(i => parseInt(h.slice(i, i + 2), 16) / 255);return 0.2126 * r + 0.7152 * g + 0.0722 * b; };+// 旧主题写法('light' / 'dark' / 不带色板键的对象)不当全片色板解析(clip.js 认这个钩子)+const legacy = th => th === 'light' || th === 'dark' || (!!th && typeof th === 'object' && !Array.isArray(th) && th.name == null && !['surface', 'accent', 'accent2'].some(k => k in th));+// 全片色板 → 图表的一整套色:辅助色都从 6 个键派生+const fromPal = p => ({ bg: p.bg, ink: p.ink, sub: p.sub, src: PAL.mix(p.sub, p.bg, 0.2), tick: p.sub, xlab: PAL.mix(p.ink, p.sub, 0.45), grid: PAL.alpha(p.ink, 0.13),+ red: p.accent, bar: p.accent2, dim: PAL.mix(p.bg, p.sub, 0.3), dark: PAL.dark(p) });function palette(ctx) {+ if (ctx.pal) return fromPal(ctx.pal);const T = (typeof ctx.theme === 'string' || (ctx.theme && Object.keys(ctx.theme).length)) ? ctx.theme : ctx.data.theme;+ if (typeof T === 'string' && !legacy(T) && window.PALETTES[T]) return fromPal(PAL.resolve(T)); // data.theme 写了色板名if (typeof T === 'string') return { ...(THEMES[T] || THEMES.light) };const bg = (T && T.bg) || (ctx.safe && ctx.safe.fill) || null;const base = bg ? (lum(bg) < 0.45 ? THEMES.dark : THEMES.light) : THEMES.light;@@ -33,6 +42,7 @@ const fmtv = (d, v) => (d.prefix || '') + TY.fmt(v, d.decimals ?? 1) + (d.suffixreturn {fonts: ['PuHui-Medium', 'PuHui-Bold'],safe: true,+ legacyTheme: legacy,init(ctx) {P = palette(ctx); RED = P.red; INK = P.ink; SUB = P.sub; GRID = P.grid;const { W, H, u, data: d } = ctx, m = (ctx.portrait ? 70 : 90) * u, c = document.createElement('canvas').getContext('2d');@@ -77,7 +87,8 @@ return {every: category ? 1 : Math.max(1, Math.ceil(n / (ctx.portrait ? 6 : 10))) };const main = (d.colors && d.colors.main) || (kind === 'bar' ? P.bar : RED);L.col = { main, accent: (d.colors && d.colors.accent) || main, dim: (d.colors && d.colors.dim) || P.dim };- L.updown = d.upDown === 'us' ? ['#1B9E5A', RED] : [RED, '#1B9E5A'];+ const up = P.dark != null ? (P.dark ? '#FF4B3E' : '#E3120B') : RED; // 涨跌是语义色:用了全片色板(accent 未必是红)也照旧红绿+ L.updown = d.upDown === 'us' ? ['#1B9E5A', up] : [up, '#1B9E5A'];},draw(c0, t, ctx) {// alpha:字和线叠在别的画面上可能看不见。先画进缓冲,再带一圈主题底色的光晕合成(和 t1 同一招;默认白纸黑字=白光晕)@@ -97,7 +108,7 @@ return {c.globalAlpha = MO.seg(lt, 0.2, 0.6); c.font = `400 ${L.srcF.size}px ${CN}`; c.fillStyle = P.src;L.srcF.lines.forEach((ln, k, a) => c.fillText(ln, m, H - 40 * u - ctx.safe.bottom - (a.length - 1 - k) * L.srcF.size * 1.3));c.restore();- if (d.badge) { c.save(); c.globalAlpha = MO.seg(lt, 0.2, 0.6); CH.demoBadge(c, d.badge, { x: W - m, y: H - 50 * u - ctx.safe.bottom, font: `700 ${28 * u}px ${CN}`, col: RED, box: 'rgba(227,18,11,0.06)' }); c.restore(); }+ if (d.badge) { c.save(); c.globalAlpha = MO.seg(lt, 0.2, 0.6); CH.demoBadge(c, d.badge, { x: W - m, y: H - 50 * u - ctx.safe.bottom, font: `700 ${28 * u}px ${CN}`, col: RED, box: tint(RED, 0.06) }); c.restore(); }}// ---- 坐标系(版式之后 0.25s) ----const qd = ctx.of('bar', 'line', 'candle')[0] || { at: qt.at + 0.75 }, gStart = Math.min(qt.at + 0.25, qd.at - 0.4);diff --git a/scripts/engine/clips/y1_kurzgesagt.js b/scripts/engine/clips/y1_kurzgesagt.jsindex 9404f87..c6ca465 100644--- a/scripts/engine/clips/y1_kurzgesagt.js+++ b/scripts/engine/clips/y1_kurzgesagt.js@@ -1,4 +1,4 @@-// 片段 · Kurzgesagt 式扁平科普(y1):深靛紫夜空、发光的扁平中心物=要讲的那个概念;每个要点是一颗卫星节点,+// 片段 · Kurzgesagt 式扁平科普(y1):深墨色平涂底(不写 theme 时;不再是靛紫渐变夜空)、扁平中心物=要讲的那个概念;每个要点是一颗卫星节点,// 带标签胶囊弹出(过冲 108%)、信号沿连线流动。环境层(星闪、粒子、信号脉冲)一直轻轻动;中心物、节点、标签落定后停住,// 相机不慢推:只在 highlight 这一刻快推 0.28s(推近约 30%)、连着的 highlight 同倍率横移 0.30s,然后停住。// 招牌是尺度穿行:enter 让相机对数推进一颗卫星,推到它的颜色填满整屏,再从同色的新中心物里拉出来——「里面是什么」。@@ -11,12 +11,22 @@// 新一层(enter 钻进去的)中心物用那个节点的颜色,形状同样按名字生成;enter 的 data.style 可覆盖。// data.flow:true:节点按顺序串成一条链(中心→1→2→3),信号依次流过,节点带序号——讲「先后」时用。// 节点排法横竖屏一致:≤3 个排在上半圈(从左到右),≥4 个绕一整圈(从左边起顺时针)。safe:版面只排在 top..H−bottom 之间。+// spec.theme(全片色板 ctx.pal):底平涂 bg(不画渐变、不加发光),星点和微粒用 sub 低透明度,连线 sub、信号 accent2,+// 节点色 accent / accent2 及其明暗(data.color 照写的用),中心物默认 accent2,标签胶囊浅底色板 surface 底 ink 字、深底色板 ink 底 bg 字,标题 ink。CLIPS.y1_kurzgesagt = (() => {const { clamp, lerp, rng } = U;-const P = { sky: ['#05020F', '#0E0631', '#2a1a6e'], star: '#F9FCFB', line: 'rgba(125,211,220,.35)', pulse: '#32BAEE' };-const ACC = ['#32BAEE', '#FACC12', '#BE3A95', '#5CD0B3', '#FC6255', '#8A6CF0'];+// 默认(不写 theme):深墨色底,只有几乎看不出的同色相明暗;节点/中心物色里不放紫、品红、紫蓝+const P0 = { sky: ['#0F1114', '#121417', '#171A1E'], star: '#F2EFE8', line: 'rgba(125,211,220,.35)', pulse: '#32BAEE', pulseCore: '#e9fdff', mote: '#fff6d0', pill: '#ffffff', pillInk: '#1B1A17', title: '#fff', ring: 'rgba(255,230,190,.55)', arrow: 'rgba(125,211,220,.7)', shadow: 'rgba(20,40,20,.25)' };+const ACC0 = ['#32BAEE', '#FACC12', '#E07A3F', '#5CD0B3', '#FC6255', '#A3B84B'];// 中心物的中性样式:按名字哈希取色和形状(同名同样式),没有轨道环-const CPAL = ['#4F86C6', '#3FA796', '#8A6CF0', '#D9667A', '#5BA4CF', '#6FAF5A'], SHAPES = ['circle', 'rounded', 'hex'];+const CPAL0 = ['#4F86C6', '#3FA796', '#D99A3A', '#C8574A', '#5BA4CF', '#6FAF5A'], SHAPES = ['circle', 'rounded', 'hex'];+let P = P0, ACC = ACC0, CPAL = CPAL0, PL = null;+// 全片色板 → 本语法的一套色(只从 6 个键派生)+const fromPal = p => { const dk = PAL.dark(p), spot = dk ? p.ink : p.sub;+ return { P: { sky: [p.bg], star: spot, line: PAL.alpha(p.sub, 0.5), pulse: p.accent2, pulseCore: PAL.mix(p.accent2, p.surface, 0.6), mote: spot, pill: dk ? p.ink : p.surface, pillInk: dk ? p.bg : p.ink, title: p.ink,+ ring: PAL.alpha(p.ink, 0.4), arrow: PAL.alpha(p.sub, 0.85), shadow: PAL.alpha(dk ? '#000000' : p.ink, dk ? 0.3 : 0.14) },+ ACC: [p.accent, p.accent2, PAL.mix(p.accent, p.ink, 0.35), PAL.mix(p.accent2, p.ink, 0.35), PAL.mix(p.accent, p.bg, 0.3), PAL.mix(p.accent2, p.bg, 0.3)],+ CPAL: [p.accent2] }; };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();@@ -32,6 +42,7 @@ return {safe: true,init(ctx) {const { W, H, u, safe } = ctx, r = rng(11);+ PL = ctx.pal; if (PL) ({ P, ACC, CPAL } = fromPal(PL)); else { P = P0; ACC = ACC0; CPAL = CPAL0; }flow = !!ctx.data.flow;const y0 = safe.top + (ctx.of('title').length ? (ctx.portrait ? 300 : 210) * u : 60 * u), y1 = H - safe.bottom - 40 * u;const R = (ctx.portrait ? 160 : 140) * u, cx = W / 2, cy = (y0 + y1) / 2 + (ctx.portrait ? 0 : 30 * u);@@ -79,7 +90,7 @@ return {const qt = ctx.of('title')[0];if (qt) { const nx = ctx.of('highlight', 'enter')[0], out = nx ? 1 - MO.sineInOut(clamp((t - nx.at) / 0.5)) : 1;if (out > 0) { c.save(); c.globalAlpha = out; const fs = TY.fit(c, qt.text || '', W * 0.88, (ctx.portrait ? 84 : 76) * u, 'PuHui-Heavy', { maxLines: 2, balance: true });- fs.lines.forEach((ln, i) => TY.charsIn(c, ln, W / 2, ctx.safe.top + (ctx.portrait ? 200 : 130) * u + i * fs.size * 1.2, ctx.lt(t, qt.at) - i * 0.2, { font: `${fs.size}px "PuHui-Heavy"`, color: '#fff', dur: 0.5, stagger: 0.045, dy: 30 * u, align: 'center', shadow: { color: 'rgba(10,8,40,.6)', y: 6 * u, blur: ctx.alpha ? 14 * u : 0 } }));+ fs.lines.forEach((ln, i) => TY.charsIn(c, ln, W / 2, ctx.safe.top + (ctx.portrait ? 200 : 130) * u + i * fs.size * 1.2, ctx.lt(t, qt.at) - i * 0.2, { font: `${fs.size}px "PuHui-Heavy"`, color: P.title, dur: 0.5, stagger: 0.045, dy: 30 * u, align: 'center', shadow: PL && !ctx.alpha ? null : { color: 'rgba(0,0,0,.5)', y: 6 * u, blur: ctx.alpha ? 14 * u : 0 } }));c.restore(); } }},};@@ -100,8 +111,9 @@ function camAt(L, t, ctx) {function drawLevel(c, k, t, ctx) {const { W, H, u } = ctx, L = levels[k], cam = camAt(L, t, ctx), { cx, cy, R } = S;if (!ctx.alpha) {- c.fillStyle = TOON.vgrad(c, 0, H, P.sky); c.fillRect(0, 0, W, H);- CAM.layer(c, cam, 0.05, g => { for (const s of S.stars) { g.globalAlpha = 0.45 + 0.55 * (0.5 + 0.5 * Math.sin(t * s.sp + s.ph)); g.fillStyle = P.star; g.beginPath(); g.arc(s.x, s.y, s.r, 0, 7); g.fill(); } g.globalAlpha = 1; });+ c.fillStyle = P.sky.length > 1 ? TOON.vgrad(c, 0, H, P.sky) : P.sky[0]; c.fillRect(0, 0, W, H);+ const sa = PL ? 0.35 : 1; // 色板底上星点只是一层很淡的纹理+ CAM.layer(c, cam, 0.05, g => { for (const s of S.stars) { g.globalAlpha = sa * (0.45 + 0.55 * (0.5 + 0.5 * Math.sin(t * s.sp + s.ph))); g.fillStyle = P.star; g.beginPath(); g.arc(s.x, s.y, s.r, 0, 7); g.fill(); } g.globalAlpha = 1; });}// highlight 生效时:被推近的节点亮,其余节点和标签暗下去const hNow = [...L.hls].reverse().find(h => t >= h.at && h.node), dimK = hNow ? MO.smooth(clamp((t - hNow.at) / 0.6)) : 0;@@ -113,31 +125,31 @@ function drawLevel(c, k, t, ctx) {const from = flow && i > 0 ? L.nodes[i - 1] : { x: cx, y: cy }, p = MO.cubicOut(clamp(l / 0.4)), ex = lerp(from.x, nd.x, p), ey = lerp(from.y, nd.y, p);g.save(); g.globalAlpha = 1 - 0.6 * dimK * (hNow && hNow.node === nd ? 0 : 1);g.strokeStyle = P.line; g.lineWidth = 4 * u; g.beginPath(); g.moveTo(from.x, from.y); g.lineTo(ex, ey); g.stroke();- if (flow && l > 0.4) { const ax = lerp(from.x, nd.x, 0.55), ay = lerp(from.y, nd.y, 0.55), a = Math.atan2(nd.y - from.y, nd.x - from.x); g.fillStyle = 'rgba(125,211,220,.7)'; g.translate(ax, ay); g.rotate(a); g.beginPath(); g.moveTo(10 * u, 0); g.lineTo(-8 * u, -9 * u); g.lineTo(-8 * u, 9 * u); g.closePath(); g.fill(); }+ if (flow && l > 0.4) { const ax = lerp(from.x, nd.x, 0.55), ay = lerp(from.y, nd.y, 0.55), a = Math.atan2(nd.y - from.y, nd.x - from.x); g.fillStyle = P.arrow; g.translate(ax, ay); g.rotate(a); g.beginPath(); g.moveTo(10 * u, 0); g.lineTo(-8 * u, -9 * u); g.lineTo(-8 * u, 9 * u); g.closePath(); g.fill(); }g.restore();- for (let kk = 0; kk < 3; kk++) { if (l < 0.4) break; const q = flow ? ((t * 0.7 - i * 0.33 + kk / 3) % 1 + 1) % 1 : ((l * 0.8 + kk / 3) % 1); const x = lerp(from.x, nd.x, q), y = lerp(from.y, nd.y, q); TOON.glow(g, x, y, 20 * u, P.pulse, 0.6 * (1 - 0.7 * dimK)); g.fillStyle = '#e9fdff'; g.beginPath(); g.arc(x, y, 5 * u, 0, 7); g.fill(); }+ 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); if (!PL) TOON.glow(g, x, y, 20 * u, P.pulse, 0.6 * (1 - 0.7 * dimK)); g.fillStyle = PL ? P.pulse : P.pulseCore; g.beginPath(); g.arc(x, y, (PL ? 7 : 5) * u, 0, 7); g.fill(); }});// 中心物:双色分面+柔光(形状、颜色来自 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);+ if (!PL) 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 (st.ring) { g.save(); g.globalAlpha = pull; g.strokeStyle = P.ring; 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';+ g.save(); g.globalAlpha = pull; g.font = `${f.size}px "PuHui-Heavy"`; g.fillStyle = PL ? PAL.on(col, [PL.surface, PL.ink, PL.bg]) : '#fff'; g.textAlign = 'center'; g.textBaseline = 'middle';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(); }+ g.fillStyle = P.pill; g.beginPath(); g.roundRect(cx - bw / 2, by, bw, bh, bh / 2); g.fill(); g.fillStyle = P.pillInk; 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 = 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]);- if (flow) { g.font = `${30 * u * pop}px "PuHui-Heavy"`; g.fillStyle = '#1f1a3a'; g.textAlign = 'center'; g.textBaseline = 'middle'; g.fillText(String(nd.i + 1), nd.x, nd.y + fy + 2 * u); }+ if (!PL) 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), PL ? light(nd.col) : '#ffffff', [-8 * u, -8 * u], [-3 * u, -3 * u]);+ if (flow) { g.font = `${30 * u * pop}px "PuHui-Heavy"`; g.fillStyle = PL ? PAL.on(nd.col, [PL.surface, PL.ink, PL.bg]) : P.pillInk; g.textAlign = 'center'; g.textBaseline = 'middle'; g.fillText(String(nd.i + 1), nd.x, nd.y + fy + 2 * u); }const gone = L.exit ? 1 - clamp((t - L.exit.at) / 0.2) : 1; // 钻进去时:推进一开始这一层的标签全收掉(不然被放大成半屏白块,邻居的也会)const lp = MO.backOut(clamp((l - 0.15) / 0.5), 1.1) * gone; if (lp > 0) {const sc = lp * (on ? 1 + 0.18 * dimK : 1);@@ -147,15 +159,15 @@ function drawLevel(c, k, t, ctx) {const z = cam.z || 1, vx0 = cam.x - ctx.W / 2 / z, vx1 = cam.x + ctx.W / 2 / z, hw = bw * sc / 2 + 20 * u / z; // 当前镜头里看得见的世界范围(慢推会把边上的标签推出画)const lx = nd.x > vx0 && nd.x < vx1 ? (vx1 - vx0 > 2 * hw ? clamp(nd.x, vx0 + hw, vx1 - hw) : cam.x) : nd.x; // 节点在画里,标签就夹回画里g.translate(lx, ly); g.scale(sc, sc);- g.fillStyle = 'rgba(20,40,20,.25)'; g.beginPath(); g.roundRect(-bw / 2 + 6 * u, -bh / 2 + 8 * u, bw, bh, bh / 2); g.fill();- g.fillStyle = '#ffffff'; g.beginPath(); g.roundRect(-bw / 2, -bh / 2, bw, bh, bh / 2); g.fill();+ g.fillStyle = P.shadow; g.beginPath(); g.roundRect(-bw / 2 + 6 * u, -bh / 2 + 8 * u, bw, bh, bh / 2); g.fill();+ g.fillStyle = P.pill; g.beginPath(); g.roundRect(-bw / 2, -bh / 2, bw, bh, bh / 2); g.fill();if (on) { g.strokeStyle = nd.col; g.lineWidth = 5 * u * dimK; g.stroke(); }- g.fillStyle = '#1f1a3a'; g.textAlign = 'center'; g.textBaseline = 'middle'; g.fillText(nd.q.text || '', 0, 2 * u);+ g.fillStyle = P.pillInk; g.textAlign = 'center'; g.textBaseline = 'middle'; g.fillText(nd.q.text || '', 0, 2 * u);}g.restore();}// 萤火微粒- for (const m of S.motes) { const x = m.x + Math.sin(t * 0.8 + m.ph) * 30 * u, y = m.y - ((t * 22 * u + m.ph * 40 * u) % (120 * u)); g.globalAlpha = 0.4 + 0.4 * Math.sin(t * 2 + m.ph); g.fillStyle = '#fff6d0'; g.beginPath(); g.arc(x, y, m.s, 0, 7); g.fill(); }+ for (const m of S.motes) { const x = m.x + Math.sin(t * 0.8 + m.ph) * 30 * u, y = m.y - ((t * 22 * u + m.ph * 40 * u) % (120 * u)); g.globalAlpha = (PL ? 0.3 : 1) * (0.4 + 0.4 * Math.sin(t * 2 + m.ph)); g.fillStyle = P.mote; g.beginPath(); g.arc(x, y, m.s, 0, 7); g.fill(); }g.globalAlpha = 1;});}diff --git a/scripts/engine/clips/y2_vox.js b/scripts/engine/clips/y2_vox.jsindex 3abe6af..6796d8a 100644--- a/scripts/engine/clips/y2_vox.js+++ b/scripts/engine/clips/y2_vox.js@@ -6,9 +6,14 @@// highlight(当前这张图上 data.rect=[x,y,w,h](0..1,相对图片):at 起荧光笔扫过 → 红笔圈住 → 相机推近那一块)// 照片和截图是主角:镜头停在一张上时它占画面八九成(横屏宽 ≈90%、或高 ≈86%)。横屏素材左→右排、竖屏上→下排;// 镜头是脉冲:在下一件的 at 之前 0.30s 横移过去(红线先描出去、镜头再追),highlight 这一刻快推 0.28s 到那一块,其余时间停住,不慢推。+// spec.theme(全片色板 ctx.pal):桌面纸纹底色 bg,索引卡 surface、字 ink,标题条 ink 底 surface 字,红线/图钉/红圈 accent,+// 索引卡横线 accent2 淡色,荧光笔 accent 提亮;照片的冲印白边、胶带是实物,照旧。CLIPS.y2_vox = (() => {const { clamp, lerp, rng } = U;-const C = { desk: '#e4ddcf', ink: '#171716', red: '#b8433f', paper: '#eeedeb', card: '#f6f4ee' };+const C0 = { desk: '#e4ddcf', ink: '#171716', red: '#b8433f', paper: '#eeedeb', card: '#f6f4ee', fiber: [110, 95, 70], rule: 'rgba(80,140,200,.3)', margin: 'rgba(184,67,63,.5)', vig: '40,30,20', hi: undefined };+let C = C0;+const fromPal = p => ({ desk: p.bg, ink: p.ink, red: p.accent, paper: p.surface, card: p.surface, fiber: PAL.rgb(p.sub), rule: PAL.alpha(p.accent2, 0.3), margin: PAL.alpha(p.accent, 0.5),+ vig: PAL.rgb(PAL.dark(p) ? '#000000' : p.ink).join(','), hi: PAL.alpha(PAL.mix(p.accent, '#FFFFFF', 0.35), 0.85) });const BOLD = '"PuHui-Heavy"', TXT = '"PuHui-Bold"';let items, keys, strings;// 一拍二的片内时间:at 这一帧就 >0@@ -18,6 +23,7 @@ return {safe: true,init(ctx) {const { W, H, u, portrait } = ctx, r = rng(7), g = document.createElement('canvas').getContext('2d');+ C = ctx.pal ? fromPal(ctx.pal) : C0;items = []; let cur = 0, prev = null;for (const q of ctx.of('image', 'clip', 'title', 'point')) {let w, h, kind = q.kind === 'clip' ? 'image' : q.kind, lines = null, size = 0;@@ -87,7 +93,7 @@ return {const { W, H, u } = ctx, cam = CAM.at(keys, t);const buf = UI.scratch('clip_vox', W, H), g = buf.getContext('2d'); g.reset();g.save(); g.translate(0, (ctx.safe.top - ctx.safe.bottom) / 2); CAM.apply(g, cam);- if (!ctx.alpha) { g.fillStyle = g.createPattern(CL.paperTile('clipdesk', C.desk, { amt: 12, fibers: 320, fiberCol: [110, 95, 70] }), 'repeat'); const s = 4 / cam.z; g.fillRect(cam.x - W * s, cam.y - H * s, W * 2 * s, H * 2 * s); }+ if (!ctx.alpha) { g.fillStyle = g.createPattern(CL.paperTile('clipdesk' + (C === C0 ? '' : '_' + C.desk), C.desk, { amt: 12, fibers: 320, fiberCol: C.fiber }), 'repeat'); const s = 4 / cam.z; g.fillRect(cam.x - W * s, cam.y - H * s, W * 2 * s, H * 2 * s); }// 红线:跟着下一件的到场描出(12fps)for (const s of strings) { const q = MO.sineInOut(clamp(ls(t, s.at - 0.9) / 0.7)); if (t < s.at - 0.9) continue;CL.string(g, s.pts, s.cum, s.cum[s.cum.length - 1] * q, { col: C.red, lw: 5 * u }); CL.pin(g, s.a[0], s.a[1], C.red); if (q >= 1) CL.pin(g, s.b[0], s.b[1], C.red); }@@ -101,7 +107,7 @@ return {if (Math.hypot(vx, vy) >= 1.5) c.drawImage(buf, 0, 0); // 先垫一张不偏移的:motionBlur 第一张就是偏移的,画面四边会留一圈半透明(出片是灰边)CAM.motionBlur(c, buf, vx * 0.6, vy * 0.6, 7);if (!ctx.alpha) { // 暗角+静态颗粒(纸纹是贴死的,不逐帧抖)- const v = PAINT.cached('clip_vox_vig' + W + 'x' + H, W, H, gg => { const r = gg.createRadialGradient(W / 2, H / 2, Math.min(W, H) * 0.45, W / 2, H / 2, Math.max(W, H) * 0.62); r.addColorStop(0, 'rgba(40,30,20,0)'); r.addColorStop(1, 'rgba(40,30,20,.34)'); gg.fillStyle = r; gg.fillRect(0, 0, W, H); });+ const v = PAINT.cached('clip_vox_vig' + W + 'x' + H + C.vig, W, H, gg => { const r = gg.createRadialGradient(W / 2, H / 2, Math.min(W, H) * 0.45, W / 2, H / 2, Math.max(W, H) * 0.62); r.addColorStop(0, `rgba(${C.vig},0)`); r.addColorStop(1, `rgba(${C.vig},${C === C0 ? .34 : .18})`); gg.fillStyle = r; gg.fillRect(0, 0, W, H); });c.drawImage(v, 0, 0);}},@@ -122,7 +128,7 @@ function drawItem(g, it, t, ctx) {const own = ctx.of('image', 'clip').filter(z => z.at <= hq.at).pop(); if (own !== q) continue;const l = t - hq.at; if (l < -1e-6) continue;const R = hq.data.rect, x0 = -w / 2 + f.x + R[0] * f.w, y0 = -h / 2 + f.y + R[1] * f.h, rw = R[2] * f.w, rh = R[3] * f.h;- CL.highlight(g, x0 - 6 * u, y0 - 4 * u, rw + 12 * u, rh + 8 * u, MO.sineInOut(clamp(ls(t, hq.at) / 0.6)));+ CL.highlight(g, x0 - 6 * u, y0 - 4 * u, rw + 12 * u, rh + 8 * u, MO.sineInOut(clamp(ls(t, hq.at) / 0.6)), C.hi);const cq = MO.cubicOut(clamp((ls(t, hq.at) - 0.5) / 0.6));const newer = ctx.of('highlight').find(z => z.at > hq.at && z.at <= t + 1e-6 && z.data && z.data.rect && ctx.of('image', 'clip').filter(y => y.at <= z.at).pop() === q);const fa = newer ? 1 - 0.75 * clamp((t - newer.at) / 0.3) : 1; // 同一张图圈了下一处:旧红圈退成淡痕,免得两个圈叠着、旧圈出画@@ -132,8 +138,8 @@ function drawItem(g, it, t, ctx) {} else {const n = Math.ceil(ls(t, q.at) * (it.cps || 13)), title = it.kind === 'title';CL.shadowed(g, () => { g.fillStyle = title ? C.ink : C.card; g.save(); g.translate(-w / 2, -h / 2); CL.tornRect(g, w, h, it.seed, 3 * u); g.fill(); g.restore(); }, { blur: 10 * u, x: 3 * u, y: 6 * u });- if (!title) { g.strokeStyle = 'rgba(80,140,200,.3)'; g.lineWidth = 2 * u; for (let y = -h / 2 + 90 * u; y < h / 2; y += it.size * 1.45) { g.beginPath(); g.moveTo(-w / 2, y); g.lineTo(w / 2, y); g.stroke(); }- g.strokeStyle = 'rgba(184,67,63,.5)'; g.beginPath(); g.moveTo(-w / 2, -h / 2 + 56 * u); g.lineTo(w / 2, -h / 2 + 56 * u); g.stroke(); }+ if (!title) { g.strokeStyle = C.rule; g.lineWidth = 2 * u; for (let y = -h / 2 + 90 * u; y < h / 2; y += it.size * 1.45) { g.beginPath(); g.moveTo(-w / 2, y); g.lineTo(w / 2, y); g.stroke(); }+ g.strokeStyle = C.margin; g.beginPath(); g.moveTo(-w / 2, -h / 2 + 56 * u); g.lineTo(w / 2, -h / 2 + 56 * u); g.stroke(); }g.fillStyle = title ? C.paper : C.ink; g.font = `${it.size}px ${title ? BOLD : TXT}`; g.textBaseline = 'alphabetic';let k = 0; it.lines.forEach((ln, li) => { let x = -w / 2 + (title ? 40 : 55) * u; const y = -h / 2 + (title ? 25 * u : 70 * u) + (li + 1) * it.size * 1.3;for (const ch of ln) { if (k < n) g.fillText(ch, x, y); x += g.measureText(ch).width; k++; } });diff --git a/scripts/engine/clips/y3_whiteboard.js b/scripts/engine/clips/y3_whiteboard.jsindex cbf832f..a489f3a 100644--- a/scripts/engine/clips/y3_whiteboard.js+++ b/scripts/engine/clips/y3_whiteboard.js@@ -9,9 +9,11 @@// 每一笔都在 at 这一帧落下第一点;写字速度=max(基准速度, 字数 / 到下一个 cue 的间隔),说到下一句时这句已写完。// 笔:两笔之间空档 <0.6s 沿弧线滑过去;更长就 0.35s 退出右下屏外,下一笔前 0.3s 再进来;最后一笔画完一定退场,不留在字上。// safe(spec.safe):内容只排在 top..H−bottom 之间,收尾拉远也只拉进这一带。alpha:墨色外面描一圈白边,叠在深色画面上也看得见。+// spec.theme(全片色板 ctx.pal):板面就是片子的底色 bg(和前后镜头连成一片;深底色板就是一块黑板),字和线 ink,+// 项目符号、箭头、圈重点 accent,图标里的浅色铺底是 accent 的淡色。CLIPS.y3_whiteboard = (() => {const { clamp, lerp } = U;-const INK = '#0A0503', ORANGE = '#EF7226', WASH = 'rgba(239,114,38,.22)', BOARD = '#FBFBFB';+let INK = '#0A0503', ORANGE = '#EF7226', WASH = 'rgba(239,114,38,.22)', BOARD = '#FBFBFB';const FONT = 'LXGWWenKai-500';// ---------- 手绘图标:单位框 [-0.5,0.5]²(y 朝下)里的笔画;o:1 = 橙色强调,seg:1 = 快速直线(网络连线),fill = 铺浅橙 ----------const A = (cx, cy, rx, ry, a0, a1, n = 22) => DG.arcPts(cx, cy, rx, ry, a0, a1, n);@@ -158,7 +160,8 @@ return {fonts: [FONT],safe: true,init(ctx) {- const { W, H, u, safe } = ctx;+ const { W, H, u, safe } = ctx, p = ctx.pal;+ if (p) { INK = p.ink; ORANGE = p.accent; WASH = PAL.alpha(p.accent, 0.22); BOARD = p.bg; } else { INK = '#0A0503'; ORANGE = '#EF7226'; WASH = 'rgba(239,114,38,.22)'; BOARD = '#FBFBFB'; }band = { y0: safe.top, y1: H - safe.bottom }; band.h = band.y1 - band.y0;// 字号系数 f 从 1.2 往下试:内容少就放大撑满版面,内容多就缩(最小 0.72),还放不下才让相机往下走let L; for (let f = 1.2; f >= 0.7; f -= 0.04) { L = layout(ctx, f); if (L.bottom + 70 * u <= band.y1) break; } // 内容少就放大(最大 1.2)把版面撑满diff --git a/scripts/engine/clips/y4_storytime.js b/scripts/engine/clips/y4_storytime.jsindex 91fe9b7..4d30c1f 100644--- a/scripts/engine/clips/y4_storytime.js+++ b/scripts/engine/clips/y4_storytime.js@@ -1,37 +1,53 @@-// 片段 · 故事型简笔角色(y4,storytime):一个豆子角色在小房间里对镜头讲,姿势快切(0.1s)后定住,笑点靠反应特写和插入镜头。+// 片段 · 故事型角色(y4,storytime):一个角色(AI 生成的帧库)在小房间里对镜头讲,姿势快切(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: 路径}}+// data.character(必填):帧库——render.py 里写一个目录(文件名去扩展名 = 姿势名),或 {frames: {rest, talk, point, shrug, type, stiff, react, back, <姿势>_open: 路径}}。+// 代码画的小人('neutral' / 'bun' / 'author' / 造型对象)已停用:不给帧库就启动失败。// 至少要有 rest 或 talk;缺的姿势退到 talk → rest;<姿势>_open 是张嘴帧(说话时一拍二换);react 是反应特写,back 是插入镜头前景的后脑勺。-// 帧图要透明底、角色脚底在图片底边中间,画出来高 ≈ 3.15 个头半径。+// 帧图要透明底、角色脚底在图片底边中间,画出来高 ≈ 3.15 个头半径。没有 back 帧时插入镜头不画前景后脑勺。// cues:point | title(角色说一句:at 这一帧气泡弹出、开始张嘴;嘴按 text 的字数说 ≈6.5 字/秒;data.pose 指定姿势 talk/point/shrug/type)// 气泡里写什么:有 sub 就写 sub(≤12 字的短句最好),没有才写 text——口播原文交给管线的字幕,气泡别和字幕重复一遍// highlight(「?」「!」弹出+摊手担心:data.mark 默认「?」)-// react(反应镜头:at 这一帧跳到大特写,死鱼眼+汗滴,一言不发;dur 默认到下一个 cue)+// react(反应镜头:at 这一帧跳到大特写,贴 react 帧(没有就退到 talk / rest)+汗滴,一言不发;dur 默认到下一个 cue)// insert(插入镜头:at 这一帧切到桌上那台电脑的屏幕特写——sub = 角色打的那一行(打字、发送),之后 AI 的回复像代码墙一样越滚越快,// text = 砸出来的大字(如「3000行」),在 data.hit(绝对秒,默认 at+1.3,没有 sub 时 at+0.4)砸出、屏幕一震;// data.count + data.unit 让右上角计数器在砸出那一刻停在这个数;dur 默认到下一个 cue)// 房间里有桌上的电脑(插入镜头切进去的就是它的屏幕)、马克杯、墙上的书架和绿植,右边不再是空墙。// 没有口播包络时,口型由字数和时间合成(一拍二,0/1/2 三张嘴);有包络就把 window.VO_ENV 交给管线(TOON.mouth 自动读)。// safe:气泡、插入镜头的大字排在 top..H−bottom 之间。alpha:不画房间,角色和气泡照画(气泡本来就是白底黑字);插入镜头只画显示器和后脑勺,四周透明。+// spec.theme(全片色板 ctx.pal):墙 bg、地面和桌子是 bg 往 ink / sub 调的明暗,书、杯子、绿植 accent / accent2,气泡 surface 底 ink 字,+// 屏幕是深色(ink 或 bg 压暗),代码色块、计数器、砸出的大字只用 accent / accent2 和它们的明暗。CLIPS.y4_storytime = (() => {const { clamp, lerp, rng } = U;-const C = { wall: '#DCE9EC', wall2: '#CFE0E4', floor: '#E8DCC8', desk: '#E2C29B', deskSide: '#CDA97F', line: '#5B6470', sky: '#BFE3F5', screen: '#20222D' };-const COLS = ['#C792EA', '#82AAFF', '#C3E88D', '#F78C6C', '#89DDFF', '#FFCB6B', '#676E95'];-const LINES = (() => { const r = rng(42), out = []; let ind = 0;+// 代码墙色块(屏幕上的语法高亮):不放紫、紫蓝+const COLS = ['#E06C75', '#5FB3A1', '#C3E88D', '#F78C6C', '#89DDFF', '#FFCB6B', '#8A9199'];+const C0 = { wall: '#DCE9EC', floor: '#E8DCC8', desk: '#E2C29B', deskSide: '#CDA97F', line: '#5B6470', sky: '#BFE3F5', screen: '#20222D', cloud: '#fff', shelf: '#D9C3A0',+ books: ['#8FB3C9', '#E7A37B', '#B9C98F', '#C9B28F'], pot: '#E7A37B', leaf: '#8DBF8B', stand: '#9AA0AC', bezel: '#2B2D36', mug: '#F26B4F', codes: COLS,+ insertBg: '#15161C', gutter: '#4A4F66', bubble: '#2F3342', sent: '#3B82F6', sentInk: '#fff', bar: '#2A2D3A', dots: ['#FF5F57', '#FEBC2E', '#28C840'], appText: '#9AA3B8', hot: '#FFCB6B',+ slamDim: '10,10,16', fast: '32,34,45', sayBg: '#fff', sayInk: '#1B1B1F', type: '#fff' };+// 全片色板 → 房间和屏幕的一整套色(只从 6 个键派生)+const fromPal = p => { const dk = PAL.dark(p), light = dk ? p.ink : p.surface, screen = dk ? PAL.mix(p.bg, '#000000', 0.35) : PAL.mix(p.ink, p.bg, 0.08);+ return { wall: p.bg, floor: PAL.mix(p.bg, p.ink, 0.07), desk: PAL.mix(p.bg, p.sub, 0.25), deskSide: PAL.mix(p.bg, p.sub, 0.4), line: dk ? PAL.mix(p.sub, p.bg, 0.2) : p.sub,+ sky: PAL.mix(p.bg, p.accent2, 0.3), screen, cloud: PAL.mix(light, PAL.mix(p.bg, p.accent2, 0.3), 0.3), shelf: PAL.mix(p.bg, p.sub, 0.3),+ books: [p.accent, p.accent2, PAL.mix(p.accent, p.bg, 0.45), PAL.mix(p.accent2, p.bg, 0.45)], pot: p.accent, leaf: p.accent2, stand: PAL.mix(p.sub, p.bg, 0.3), bezel: PAL.mix(screen, light, 0.12), mug: p.accent,+ codes: [p.accent, PAL.mix(p.accent2, light, 0.4), PAL.mix(light, p.accent, 0.3), PAL.mix(p.accent2, light, 0.65), PAL.mix(light, screen, 0.45), PAL.mix(p.accent, light, 0.5), PAL.mix(light, screen, 0.65)], // 深屏上看得见:accent2 往亮色提+ insertBg: dk ? PAL.mix(p.bg, '#000000', 0.55) : PAL.mix(p.ink, '#000000', 0.25), gutter: PAL.mix(screen, light, 0.25), bubble: PAL.mix(screen, light, 0.15), sent: p.accent2,+ sentInk: PAL.on(p.accent2, [p.surface, p.ink, p.bg]), bar: PAL.mix(screen, light, 0.08), dots: [p.accent, PAL.mix(light, screen, 0.5), p.accent2], appText: PAL.mix(light, screen, 0.4), hot: p.accent,+ slamDim: PAL.rgb(screen).join(','), fast: PAL.rgb(screen).join(','), sayBg: p.surface, sayInk: p.ink, type: light }; };+const LINES = (() => { const r = rng(42), out = []; let ind = 0; // 色块存色号(第几个),画的时候按 C.codes 取色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, LOOK, FR;+ 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, (r() * COLS.length) | 0]); x += w + 14; } out.push(toks); } return out; })();+const NEED_FRAMES = 'y4 需要角色帧库 data.character.frames(AI 生帧,见 references/10-角色.md);代码画的小人已停用。没有生图能力就别用 y4:用 y2/y5 或 scenes 里用手、物件、背影讲故事。';+let keys, says, L, shots, FR, C = C0;return {fonts: ['PuHui-Bold', 'PuHui-Black'],safe: true,init(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);+ C = ctx.pal ? fromPal(ctx.pal) : C0;+ // 角色只认帧库(对象带 frames;帧图已由 clip.js 加载,缺图在启动时就失败)。没有帧库 / 写预设名 → 启动失败+ if (!ch || typeof ch !== 'object' || !ch.frames || typeof ch.frames !== 'object') throw new Error(NEED_FRAMES + (ch != null ? `(收到的 data.character = ${JSON.stringify(ch)})` : '(spec 里没写 data.character)'));+ FR = Object.fromEntries(Object.entries(ch.frames).map(([k, v]) => [k, ctx.IMG[v]]));+ if (!FR.rest && !FR.talk) throw new Error('y4 data.character.frames 至少要有 rest 或 talk 一张(现有:' + Object.keys(FR).join(' ') + ')');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、宽高)@@ -59,13 +75,11 @@ return {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]);- 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 });+ const info = frameChar(g, ts, st, inReact, mouth);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 + 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(); }+ 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, C === C0 ? undefined : ctx.pal.accent); g.restore(); }});// 对话气泡(屏幕空间,不跟镜头):at 这一帧弹出,说完 0.6s 后收起;特写切回来后,特写之前的那句不再出现if (!inReact) for (const s of says) {@@ -78,10 +92,10 @@ return {const bh = f.lines.length * f.size * 1.3 + 56 * u, bx = ctx.portrait ? (W - bw) / 2 : W * 0.5, by = ctx.safe.top + (ctx.portrait ? H * 0.06 : H * 0.09);const sc = MO.backOut(clamp(l / 0.25), 2.2) * (1 - out);c.save(); c.translate(bx + 60 * u, by + bh); c.scale(sc, sc); c.translate(-(bx + 60 * u), -(by + bh));- c.fillStyle = '#fff'; c.strokeStyle = '#1B1B1F'; c.lineWidth = 6 * u; c.lineJoin = 'round';+ c.fillStyle = C.sayBg; c.strokeStyle = C.sayInk; c.lineWidth = 6 * u; c.lineJoin = 'round';c.beginPath(); c.roundRect(bx, by, bw, bh, 40 * u); c.moveTo(bx + 70 * u, by + bh); c.lineTo(bx + (ctx.portrait ? 40 : 10) * u, by + bh + 60 * u); c.lineTo(bx + 130 * u, by + bh); c.fill(); c.stroke();- c.fillStyle = '#fff'; c.fillRect(bx + 76 * u, by + bh - 8 * u, 50 * u, 12 * u);- c.fillStyle = '#1B1B1F'; c.textBaseline = 'alphabetic';+ c.fillStyle = C.sayBg; c.fillRect(bx + 76 * u, by + bh - 8 * u, 50 * u, 12 * u);+ c.fillStyle = C.sayInk; c.textBaseline = 'alphabetic';f.lines.forEach((ln, i) => c.fillText(ln, bx + 40 * u, by + 26 * u + (i + 1) * f.size * 1.2));c.restore();}@@ -105,30 +119,30 @@ function room(g, t, ctx) {// 窗:天空+慢飘的云const wx = ctx.portrait ? W * 0.08 : W * 0.05, wy = ctx.portrait ? H * 0.2 : H * 0.12, ww = ctx.portrait ? W * 0.3 : W * 0.17, wh = ww * 0.7;g.save(); g.beginPath(); g.roundRect(wx, wy, ww, wh, 12 * u); g.clip(); g.fillStyle = C.sky; g.fillRect(wx, wy, ww, wh);- for (const [k, r, sp] of [[0.2, 46, 18], [0.7, 34, 12]]) { const x = wx - 60 * u + ((k * ww + t * sp * u) % (ww + 120 * u)), y = wy + wh * (0.35 + k * 0.3); g.fillStyle = '#fff'; g.beginPath(); g.arc(x, y, r * u, 0, 7); g.arc(x + r * 0.9 * u, y + 6 * u, r * 0.75 * u, 0, 7); g.arc(x - r * 0.9 * u, y + 8 * u, r * 0.65 * u, 0, 7); g.fill(); }+ for (const [k, r, sp] of [[0.2, 46, 18], [0.7, 34, 12]]) { const x = wx - 60 * u + ((k * ww + t * sp * u) % (ww + 120 * u)), y = wy + wh * (0.35 + k * 0.3); g.fillStyle = C.cloud; g.beginPath(); g.arc(x, y, r * u, 0, 7); g.arc(x + r * 0.9 * u, y + 6 * u, r * 0.75 * u, 0, 7); g.arc(x - r * 0.9 * u, y + 8 * u, r * 0.65 * u, 0, 7); g.fill(); }g.restore(); g.strokeStyle = C.line; g.beginPath(); g.roundRect(wx, wy, ww, wh, 12 * u); g.moveTo(wx + ww / 2, wy); g.lineTo(wx + ww / 2, wy + wh); g.moveTo(wx, wy + wh / 2); g.lineTo(wx + ww, wy + wh / 2); g.stroke();// 墙上:横屏右边一块书架;竖屏书架在窗下方右侧const r = rng(9), sx = ctx.portrait ? W * 0.62 : W * 0.68, sy = ctx.portrait ? H * 0.3 : H * 0.36, sw = ctx.portrait ? W * 0.3 : W * 0.22;- g.fillStyle = '#D9C3A0'; g.fillRect(sx, sy, sw, 16 * u); g.strokeRect(sx, sy, sw, 16 * u);- let x = sx + 16 * u; while (x < sx + sw * 0.7) { const w = (22 + r() * 22) * u, h = (70 + r() * 40) * u; g.fillStyle = ['#8FB3C9', '#E7A37B', '#B9C98F', '#C6A0C9'][(r() * 4) | 0]; g.fillRect(x, sy - h, w, h); g.strokeRect(x, sy - h, w, h); x += w + 5 * u; }- g.fillStyle = '#E7A37B'; const px = sx + sw * 0.83; g.beginPath(); g.moveTo(px - 30 * u, sy); g.lineTo(px - 38 * u, sy - 56 * u); g.lineTo(px + 38 * u, sy - 56 * u); g.lineTo(px + 30 * u, sy); g.closePath(); g.fill(); g.stroke();- g.fillStyle = '#8DBF8B'; for (const [dx, a] of [[-18, -0.5], [0, 0], [18, 0.5]]) { g.beginPath(); g.ellipse(px + dx * u, sy - 100 * u, 16 * u, 46 * u, a, 0, 7); g.fill(); g.stroke(); }+ g.fillStyle = C.shelf; g.fillRect(sx, sy, sw, 16 * u); g.strokeRect(sx, sy, sw, 16 * u);+ let x = sx + 16 * u; while (x < sx + sw * 0.7) { const w = (22 + r() * 22) * u, h = (70 + r() * 40) * u; g.fillStyle = C.books[(r() * 4) | 0]; g.fillRect(x, sy - h, w, h); g.strokeRect(x, sy - h, w, h); x += w + 5 * u; }+ g.fillStyle = C.pot; const px = sx + sw * 0.83; g.beginPath(); g.moveTo(px - 30 * u, sy); g.lineTo(px - 38 * u, sy - 56 * u); g.lineTo(px + 38 * u, sy - 56 * u); g.lineTo(px + 30 * u, sy); g.closePath(); g.fill(); g.stroke();+ g.fillStyle = C.leaf; for (const [dx, a] of [[-18, -0.5], [0, 0], [18, 0.5]]) { g.beginPath(); g.ellipse(px + dx * u, sy - 100 * u, 16 * u, 46 * u, a, 0, 7); g.fill(); g.stroke(); }}// 桌子挡在腰前(角色线最黑最粗,背景线细而灰);桌上的电脑、马克杯function desk(g, t, ctx) {const { W, H, u } = ctx, X0 = -W, dy = L.dy; g.lineWidth = 3 * u; g.strokeStyle = C.line;// 电脑:屏幕微微发光,上面是滚动的代码色块(插入镜头切进去就是它)const M = L.mon, mx = M.x, my = dy - M.h - 60 * u;- g.fillStyle = '#9AA0AC'; g.fillRect(mx + M.w / 2 - 18 * u, dy - 62 * u, 36 * u, 62 * u); g.strokeRect(mx + M.w / 2 - 18 * u, dy - 62 * u, 36 * u, 62 * u);+ g.fillStyle = C.stand; g.fillRect(mx + M.w / 2 - 18 * u, dy - 62 * u, 36 * u, 62 * u); g.strokeRect(mx + M.w / 2 - 18 * u, dy - 62 * u, 36 * u, 62 * u);g.beginPath(); g.ellipse(mx + M.w / 2, dy, 90 * u, 10 * u, 0, 0, 7); g.fill(); g.stroke();- g.fillStyle = '#2B2D36'; g.beginPath(); g.roundRect(mx, my, M.w, M.h, 16 * u); g.fill(); g.stroke();+ g.fillStyle = C.bezel; g.beginPath(); g.roundRect(mx, my, M.w, M.h, 16 * u); g.fill(); g.stroke();g.save(); g.beginPath(); g.roundRect(mx + 14 * u, my + 14 * u, M.w - 28 * u, M.h - 28 * u, 6 * u); g.clip(); g.fillStyle = C.screen; g.fillRect(mx, my, M.w, M.h);- const lh = 22 * u, off = (t * 30 * u) % lh; for (let i = 0; i < 20; i++) { const y = my + 30 * u + i * lh - off; for (const [x, w, col] of LINES[i % LINES.length]) { g.fillStyle = col; g.globalAlpha = 0.75; g.fillRect(mx + 26 * u + x * 0.3 * u, y, w * 0.3 * u, 8 * u); } }+ const lh = 22 * u, off = (t * 30 * u) % lh; for (let i = 0; i < 20; i++) { const y = my + 30 * u + i * lh - off; for (const [x, w, col] of LINES[i % LINES.length]) { g.fillStyle = C.codes[col % C.codes.length]; g.globalAlpha = 0.75; g.fillRect(mx + 26 * u + x * 0.3 * u, y, w * 0.3 * u, 8 * u); } }g.restore(); g.globalAlpha = 1;g.fillStyle = C.desk; g.fillRect(X0, dy, W * 3, 40 * u); g.strokeRect(X0, dy, W * 3, 40 * u);g.fillStyle = C.deskSide; g.fillRect(X0, dy + 40 * u, W * 3, H); g.strokeRect(X0, dy + 40 * u, W * 3, H);// 马克杯- const cx = ctx.portrait ? W * 0.1 : L.cx - L.R * 1.9; g.fillStyle = '#F26B4F'; g.beginPath(); g.roundRect(cx, dy - 92 * u, 70 * u, 92 * u, 10 * u); g.fill(); g.stroke();+ const cx = ctx.portrait ? W * 0.1 : L.cx - L.R * 1.9; g.fillStyle = C.mug; g.beginPath(); g.roundRect(cx, dy - 92 * u, 70 * u, 92 * u, 10 * u); g.fill(); g.stroke();g.beginPath(); g.arc(cx + 78 * u, dy - 52 * u, 22 * u, -1.2, 1.2); g.lineWidth = 9 * u; g.stroke(); g.lineWidth = 3 * u;}// 插入镜头:电脑屏幕特写(过肩),打字→发送→代码墙加速滚→大字砸出+屏幕一震(和示范片 s2_screen 同一套)@@ -138,10 +152,10 @@ function insert(c, t, ctx, shot) {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)) + (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); } // 透明模式:只留显示器和后脑勺,口播画面从四周透出来+ if (!ctx.alpha) { c.fillStyle = C.insertBg; c.fillRect(0, 0, W, H); } // 透明模式:只留显示器和后脑勺,口播画面从四周透出来const bx = W * 0.06, by = safe.top + H * 0.05, bw = W * 0.88, bh = H - safe.bottom - by - H * (ctx.portrait ? 0.2 : 0.06);CAM.with(c, { x: W / 2 + shake, y: H / 2 - shake * 0.5, z: zoom }, c => {- c.fillStyle = '#2B2D36'; c.beginPath(); c.roundRect(bx, by, bw, bh, 34 * u); c.fill();+ c.fillStyle = C.bezel; c.beginPath(); c.roundRect(bx, by, bw, bh, 34 * u); c.fill();const sx = bx + 40 * u, sy = by + 40 * u, sw = bw - 80 * u, sh = bh - 80 * u;c.save(); c.beginPath(); c.roundRect(sx, sy, sw, sh, 14 * u); c.clip(); c.fillStyle = C.screen; c.fillRect(sx, sy, sw, sh);const scr = scrollAt(t), top = sy + 64 * u;@@ -149,45 +163,32 @@ function insert(c, t, ctx, shot) {if (msg) { const bubY = top + 110 * u - Math.min(scr, 600 * u), p = clamp((t - t0 - 0.1) / Math.max(0.2, T_SEND - t0 - 0.2));const mf = TY.fit(c, msg, sw * 0.7 - 60 * u, (ctx.portrait ? 44 : 40) * u, 'PuHui-Bold', { maxLines: 3, min: 0.75, balance: true }), fs = mf.size, lh = fs * 1.3; // 长句折行(最多 3 行),气泡往下长const bwid = Math.max(...mf.lines.map(l => TY.width(c, l, fs, 'PuHui-Bold'))) + 60 * u, bht = 78 * u + (mf.lines.length - 1) * lh;- if (bubY > sy) { c.fillStyle = t >= T_SEND ? '#3B82F6' : '#2F3342'; c.beginPath(); c.roundRect(sx + sw - 30 * u - bwid, bubY - 52 * u, bwid, bht, 24 * u); c.fill();+ if (bubY > sy) { c.fillStyle = t >= T_SEND ? C.sent : C.bubble; c.beginPath(); c.roundRect(sx + sw - 30 * u - bwid, bubY - 52 * u, bwid, bht, 24 * u); c.fill();let left = Math.round(p * mf.lines.reduce((a, l) => a + [...l].length, 0)); // 逐行打出来,光标跟在最后打到的那一行const ns = mf.lines.map(ln => { const n = Math.min(left, [...ln].length); left -= n; return n; }), curK = Math.max(0, ns.findLastIndex(n => n > 0)), blink = t < T_SEND && Math.floor(t * 4) % 2;mf.lines.forEach((ln, k) => { if (k > curK) return;- TY.text(c, [...ln].slice(0, ns[k]).join('') + (blink && k === curK ? '|' : ''), sx + sw - 30 * u - bwid + 30 * u, bubY + 2 * u + k * lh, { size: fs, fam: 'PuHui-Bold', color: '#fff', align: 'left' }); }); } }+ TY.text(c, [...ln].slice(0, ns[k]).join('') + (blink && k === curK ? '|' : ''), sx + sw - 30 * u - bwid + 30 * u, bubY + 2 * u + k * lh, { size: fs, fam: 'PuHui-Bold', color: t >= T_SEND ? C.sentInk : C.type, align: 'left' }); }); } }// AI 的回复:代码墙,越滚越快if (t > T_SEND + 0.05) { const lh = 46 * u, y0 = top + (msg ? 220 : 40) * u - scr;for (let i = Math.max(0, Math.floor((top - y0) / lh)); ; i++) { const y = y0 + i * lh; if (y > sy + sh) break; if (y < top) continue;const shown = clamp((t - T_SEND - 0.05 - Math.min(i, 12) * 0.03) / 0.05); if (shown <= 0) continue;- c.fillStyle = '#4A4F66'; c.fillRect(sx + 30 * u, y - 12 * u, 44 * u, 16 * u);- for (const [x, w, col] of LINES[i % LINES.length]) { c.fillStyle = col; c.globalAlpha = 0.9; c.beginPath(); c.roundRect(sx + 110 * u + x * u, y - 14 * u, w * u * shown, 20 * u, 10 * u); c.fill(); } c.globalAlpha = 1; }- const v = (scrollAt(t + 1 / 60) - scr) * 60; if (v > 1500 * u) { c.fillStyle = `rgba(32,34,45,${clamp((v - 1500 * u) / (6000 * u)) * 0.5})`; c.fillRect(sx, top, sw, sh); } }+ c.fillStyle = C.gutter; c.fillRect(sx + 30 * u, y - 12 * u, 44 * u, 16 * u);+ for (const [x, w, col] of LINES[i % LINES.length]) { c.fillStyle = C.codes[col % C.codes.length]; c.globalAlpha = 0.9; c.beginPath(); c.roundRect(sx + 110 * u + x * u, y - 14 * u, w * u * shown, 20 * u, 10 * u); c.fill(); } c.globalAlpha = 1; }+ const v = (scrollAt(t + 1 / 60) - scr) * 60; if (v > 1500 * u) { c.fillStyle = `rgba(${C.fast},${clamp((v - 1500 * u) / (6000 * u)) * 0.5})`; c.fillRect(sx, top, sw, sh); } }// 顶栏:三个圆点、标题、计数器(砸出那一刻停在 data.count)- c.fillStyle = '#2A2D3A'; c.fillRect(sx, sy, sw, 64 * u);- ['#FF5F57', '#FEBC2E', '#28C840'].forEach((col, i) => { c.fillStyle = col; c.beginPath(); c.arc(sx + 42 * u + i * 34 * u, sy + 32 * u, 10 * u, 0, 7); c.fill(); });- TY.text(c, d.app || 'AI助手', sx + sw / 2, sy + 44 * u, { size: 30 * u, fam: 'PuHui-Bold', color: '#9AA3B8' });+ c.fillStyle = C.bar; c.fillRect(sx, sy, sw, 64 * u);+ C.dots.forEach((col, i) => { c.fillStyle = col; c.beginPath(); c.arc(sx + 42 * u + i * 34 * u, sy + 32 * u, 10 * u, 0, 7); c.fill(); });+ TY.text(c, d.app || 'AI助手', sx + sw / 2, sy + 44 * u, { size: 30 * u, fam: 'PuHui-Bold', color: C.appText });if (d.count != null && t > T_SEND + 0.1) { const N = +d.count, k = slam >= 0 ? N : Math.min(N - 1, Math.floor(Math.pow(clamp((t - T_SEND - 0.15) / Math.max(0.2, T_HIT - T_SEND - 0.15)), 2.4) * (N - 1)));- TY.text(c, `${k}${d.unit || ''}`, sx + sw - 30 * u, sy + 44 * u, { size: 32 * u, fam: 'PuHui-Bold', color: slam >= 0 ? '#FFCB6B' : '#9AA3B8', align: 'right' }); }+ TY.text(c, `${k}${d.unit || ''}`, sx + sw - 30 * u, sy + 44 * u, { size: 32 * u, fam: 'PuHui-Bold', color: slam >= 0 ? C.hot : C.appText, align: 'right' }); }// 大字砸出(backOut 过冲)+压暗- if (slam > 0 && q.text) { c.fillStyle = `rgba(10,10,16,${0.6 * MO.expoOut(clamp(slam / 0.15))})`; c.fillRect(sx, sy, sw, sh);+ if (slam > 0 && q.text) { c.fillStyle = `rgba(${C.slamDim},${0.6 * MO.expoOut(clamp(slam / 0.15))})`; c.fillRect(sx, sy, sw, sh);const fs = TY.fit(c, q.text, sw * 0.86, (ctx.portrait ? 200 : 230) * u, 'PuHui-Black', { maxLines: 2, min: 0.4, balance: true });- fs.lines.forEach((ln, i) => TY.pop(c, ln, sx + sw / 2, sy + sh / 2 + fs.size * 0.35 + (i - (fs.lines.length - 1) / 2) * fs.size * 1.1, clamp(slam / 0.24), { size: fs.size, fam: 'PuHui-Black', color: '#FFCB6B', over: 3.5, stroke: '#15161C', strokeW: 18 * u })); }+ 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: C.hot, over: 3.5, stroke: C.insertBg, strokeW: 18 * u })); }c.restore();});- // 前景:角色的后脑勺(过肩),定住;砸出时往后一缩。造型跟 data.character 走(帧库给了 back 就贴那张)+ // 前景:帧库给了 back 就贴角色的后脑勺(过肩),定住;砸出时往后一缩。没有 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 = 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(); }- 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();+ if (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); }}})();diff --git a/scripts/engine/clips/y5_kinetic_type.js b/scripts/engine/clips/y5_kinetic_type.jsindex 0a11fab..b3e28be 100644--- a/scripts/engine/clips/y5_kinetic_type.js+++ b/scripts/engine/clips/y5_kinetic_type.js@@ -6,17 +6,24 @@// sub 里的关键词:data.key 写辅句里的一个词,那个词用强调色(示范片「下一行」那样)// number 的说明写 text 或 sub 都行(clip.js 已统一);data.label 照样有// 两个以上的 point 页 = 一份清单:画进度轨(01/02/03,告诉观众第几个、一共几个;横屏右上、竖屏在下方)和背景巨型序号(低对比、斜向慢漂,data.num 可指定)。-// data.palette = [[底色, 字色], ...] 换配色。alpha 模式不画底,字白色带深色描边。safe:主词块在 top..H−bottom 之间居中,进度轨也在这一带里。+// data.palette = [[底色, 字色], ...] 换配色(写了就优先,盖过 spec.theme)。alpha 模式不画底,字白色带深色描边。safe:主词块在 top..H−bottom 之间居中,进度轨也在这一带里。+// spec.theme(全片色板 ctx.pal):页面轮换 [bg 底 ink 字] → [accent 底] → [ink 底 bg 字] → [accent2 底](强调色页的字取 surface/ink/bg 里最清楚的那个);+// 荧光笔、辅句关键词、换页色带都只从 bg / ink / accent / accent2 里挑和当前页底色不同的。CLIPS.y5_kinetic_type = (() => {const { clamp, lerp } = U;-const PAL = [['#FFD23F', '#111111'], ['#FF5A36', '#FFFFFF'], ['#14213D', '#FFD23F'], ['#F4EFE6', '#111111']];-let pages, LIST;-const accentOf = col => col[0] === '#FFD23F' || col[0] === '#F4EFE6' || col[1] === '#FFD23F' ? '#FF5A36' : '#FFD23F'; // 字本身是黄的(深蓝页)就用橙,不然着色看不出来+const PAGES0 = [['#FFD23F', '#111111'], ['#FF5A36', '#FFFFFF'], ['#14213D', '#FFD23F'], ['#F4EFE6', '#111111']];+let pages, LIST, TP = null; // TP:全片色板(没写 data.palette 时才用)+const same = (a, b) => String(a).toLowerCase() === String(b).toLowerCase();+// 在候选色里挑一个和页底、字色都不同、压在页底上最清楚的+const pick = (bg, fg, cands) => { const ok = cands.filter(x => !same(x, bg) && !same(x, fg)); return ok.length ? PAL.on(bg, ok) : cands[0]; };+const accentOf = col => TP ? pick(col[0], col[1], [TP.accent, TP.accent2]) : col[0] === '#FFD23F' || col[0] === '#F4EFE6' || col[1] === '#FFD23F' ? '#FF5A36' : '#FFD23F'; // 字本身是黄的(深蓝页)就用橙,不然着色看不出来+const fromPal = p => { const txt = bg => PAL.on(bg, [p.surface, p.ink, p.bg]); return [[p.bg, p.ink], [p.accent, txt(p.accent)], [p.ink, p.bg], [p.accent2, txt(p.accent2)]]; };return {fonts: ['PuHui-Black', 'PuHui-Heavy', 'PuHui-Bold'],safe: true,init(ctx) {- const { W, u } = ctx, pal = ctx.data.palette || PAL, g = document.createElement('canvas').getContext('2d');+ TP = ctx.data.palette ? null : ctx.pal;+ const { W, u } = ctx, pal = ctx.data.palette || (TP ? fromPal(TP) : PAGES0), g = document.createElement('canvas').getContext('2d');pages = ctx.of('title', 'point', 'number').map((q, i) => {const num = q.kind === 'number', nd = q.data || {};const text = num ? (nd.prefix || '') + TY.fmt(nd.value || 0, nd.decimals ?? 0) + (nd.suffix || '') : (q.text || '');@@ -52,7 +59,7 @@ return {const N = pages[k + 1];if (N && !ctx.alpha) {const p = (t - (N.show - 0.3)) / 0.36; if (p > 0 && p < 1) {- const mid = ['#FFD23F', '#FF5A36', '#14213D', '#3A86FF'].find(x => x !== P.col[0] && x !== N.col[0]), cols = [mid, N.col[0]], sk = H * 0.35; // 两条:一条和前后底色都不同的强调色+新底色(以前第一条是字色,白字页前会整屏闪一帧白)+ const mid = (TP ? [TP.accent, TP.accent2, TP.ink, TP.bg] : ['#FFD23F', '#FF5A36', '#14213D', '#3A86FF']).find(x => !same(x, P.col[0]) && !same(x, N.col[0])), cols = [mid, N.col[0]], sk = H * 0.35; // 两条:一条和前后底色都不同的强调色+新底色(以前第一条是字色,白字页前会整屏闪一帧白)const edge = q => lerp(-sk - 40, W + sk + 40, MO.expoInOut(clamp(q)));cols.forEach((col, i) => { const x = edge((p - i * 0.12) / 0.76); c.save(); c.beginPath(); c.moveTo(-sk - 60, 0); c.lineTo(x + sk, 0); c.lineTo(x, H); c.lineTo(-sk - 60, H); c.closePath(); c.clip(); c.fillStyle = col; c.fillRect(0, 0, W, H); c.restore(); });}@@ -79,7 +86,7 @@ function drawPage(c, P, t, ctx) {if (hl > 0) lines.forEach((ln, i) => {const word = wd || ln, at = ln.indexOf(word); if (at < 0) return;const wPre = TY.width(c, ln.slice(0, at), size), wW = TY.width(c, word, size), wl = TY.width(c, ln, size), x = W / 2 - wl / 2 + wPre, y = y0 + i * lh;- const mc = ctx.alpha ? '#FF5A36' : (P.col[0] === '#FFD23F' ? '#FF5A36' : '#FFD23F'), mr = [x - 12 * u, y - size * 0.86, wW + 24 * u, size * 1.0, MO.at(hl, 0, 0.3)];+ const mc = ctx.alpha ? (TP ? TP.accent : '#FF5A36') : TP ? (same(P.col[0], TP.accent) ? TP.accent2 : TP.accent) : (P.col[0] === '#FFD23F' ? '#FF5A36' : '#FFD23F'), mr = [x - 12 * u, y - size * 0.86, wW + 24 * u, size * 1.0, MO.at(hl, 0, 0.3)];TY.marker(c, ...mr, mc);if (mc.toLowerCase() === fg.toLowerCase()) (knock = knock || []).push({ i, mr }); // 荧光笔和字同色(深蓝页黄字):笔下面的字反白成底色,不然整个词被涂没});@@ -100,7 +107,7 @@ function drawPage(c, P, t, ctx) {const key = q.data && q.data.key, ki = key ? ln.indexOf(key) : -1, x0 = W / 2 - sw / 2;if (ki < 0) return TY.rise(c, ln, x0, sy, sp, so);const pre = ln.slice(0, ki), post = ln.slice(ki + key.length), wp = TY.width(c, pre, subSz, 'PuHui-Heavy'), wk = TY.width(c, key, subSz, 'PuHui-Heavy');- if (pre) TY.rise(c, pre, x0, sy, sp, so); TY.rise(c, key, x0 + wp, sy, sp, { ...so, color: ctx.alpha ? '#FFD23F' : accentOf(P.col) }); if (post) TY.rise(c, post, x0 + wp + wk, sy, sp, so);+ if (pre) TY.rise(c, pre, x0, sy, sp, so); TY.rise(c, key, x0 + wp, sy, sp, { ...so, color: ctx.alpha ? (TP ? TP.accent : '#FFD23F') : accentOf(P.col) }); if (post) TY.rise(c, post, x0 + wp + wk, sy, sp, so);});}// 背景巨型序号:清单页右下角(竖屏落在下半屏),低对比、弹簧落位后斜向慢漂;不和主词抢(字色 12% 透明度)diff --git a/scripts/engine/examples/t1_3b1b.json b/scripts/engine/examples/t1_3b1b.jsonindex 0b74e41..32ac81b 100644--- a/scripts/engine/examples/t1_3b1b.json+++ b/scripts/engine/examples/t1_3b1b.json@@ -4,6 +4,7 @@"fps": 30,"width": 1920,"height": 1080,+ "theme": "ink","cues": [{ "at": 0.0, "kind": "line", "text": "损失 L(θ)", "data": { "values": [9, 5.8, 3.4, 1.8, 1.0, 0.8, 1.0, 1.8, 3.4, 5.8, 9], "color": "BLUE_C" } },{ "at": 1.8, "kind": "equation", "data": { "tokens": [diff --git a/scripts/engine/examples/t2_fullbleed_pulse.json b/scripts/engine/examples/t2_fullbleed_pulse.jsonindex 7b532e8..7d4fd72 100644--- a/scripts/engine/examples/t2_fullbleed_pulse.json+++ b/scripts/engine/examples/t2_fullbleed_pulse.json@@ -4,6 +4,7 @@"fps": 30,"width": 1920,"height": 1080,+ "theme": "ink","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] } },diff --git a/scripts/engine/examples/t2_keynote_ui.json b/scripts/engine/examples/t2_keynote_ui.jsonindex 0f80645..c53acf6 100644--- a/scripts/engine/examples/t2_keynote_ui.json+++ b/scripts/engine/examples/t2_keynote_ui.json@@ -4,6 +4,7 @@"fps": 30,"width": 1920,"height": 1080,+ "theme": "navy","cues": [{ "at": 0.0, "kind": "card", "text": "一份 JSON 出的图", "sub": "数据:英伟达 10-K 年报", "image": "assets/财经图表_横屏.png" },{ "at": 1.8, "kind": "highlight", "data": { "rect": [0.648, 0.245, 0.104, 0.105] } },diff --git a/scripts/engine/examples/t3_finance_chart.json b/scripts/engine/examples/t3_finance_chart.jsonindex 63e4004..d4cdc44 100644--- a/scripts/engine/examples/t3_finance_chart.json+++ b/scripts/engine/examples/t3_finance_chart.json@@ -4,6 +4,7 @@"fps": 30,"width": 1920,"height": 1080,+ "theme": "paper","data": {"title": "英伟达营收涨到 7.8 倍","unit": "年营收,十亿美元(2021–2025 财年)",diff --git a/scripts/engine/examples/y1_kurzgesagt.json b/scripts/engine/examples/y1_kurzgesagt.jsonindex 2362d9e..f352ffc 100644--- a/scripts/engine/examples/y1_kurzgesagt.json+++ b/scripts/engine/examples/y1_kurzgesagt.json@@ -4,6 +4,7 @@"fps": 30,"width": 1920,"height": 1080,+ "theme": "navy","data": { "center": "一滴海水" },"cues": [{ "at": 0.3, "kind": "point", "text": "浮游生物" },diff --git a/scripts/engine/examples/y2_vox.json b/scripts/engine/examples/y2_vox.jsonindex 98c4671..10c2d65 100644--- a/scripts/engine/examples/y2_vox.json+++ b/scripts/engine/examples/y2_vox.json@@ -4,6 +4,7 @@"fps": 30,"width": 1920,"height": 1080,+ "theme": "wood","cues": [{ "at": 0.0, "kind": "image", "image": "assets/K线图_横屏.png", "text": "日 K 线·示意数据" },{ "at": 1.8, "kind": "highlight", "data": { "rect": [0.74, 0.22, 0.22, 0.11] } },diff --git a/scripts/engine/examples/y3_whiteboard.json b/scripts/engine/examples/y3_whiteboard.jsonindex 308ed7f..fd53cae 100644--- a/scripts/engine/examples/y3_whiteboard.json+++ b/scripts/engine/examples/y3_whiteboard.json@@ -4,6 +4,7 @@"fps": 30,"width": 1920,"height": 1080,+ "theme": "chalk","cues": [{ "at": 0.0, "kind": "draw", "text": "25 分钟", "data": { "icon": "clock" } },{ "at": 1.5, "kind": "point", "text": "这段时间只做一件事" },diff --git a/scripts/engine/examples/y4_storytime.json b/scripts/engine/examples/y4_storytime.jsonindex b973903..a448fc6 100644--- a/scripts/engine/examples/y4_storytime.json+++ b/scripts/engine/examples/y4_storytime.json@@ -1,13 +1,52 @@{- "grammar": "y4_storytime",- "duration": 8.5,- "fps": 30,- "width": 1920,- "height": 1080,- "cues": [- { "at": 0.1, "kind": "insert", "text": "3000行", "sub": "帮我做个网站", "data": { "hit": 1.6, "count": 3000, "unit": "行" } },- { "at": 2.8, "kind": "react" },- { "at": 4.1, "kind": "point", "text": "第一次让 AI 写代码,", "sub": "这些……贴哪儿?", "data": { "pose": "point" } },- { "at": 6.6, "kind": "highlight", "data": { "mark": "?" } }- ]+ "grammar": "y4_storytime",+ "duration": 8.5,+ "fps": 30,+ "width": 1920,+ "height": 1080,+ "theme": "snow",+ "data": {+ "character": {+ "frames": {+ "rest": "../../../角色帧库/<你的角色>/rest.png",+ "talk": "../../../角色帧库/<你的角色>/talk.png",+ "point": "../../../角色帧库/<你的角色>/point.png",+ "shrug": "../../../角色帧库/<你的角色>/shrug.png"+ }+ }+ },+ "cues": [+ {+ "at": 0.1,+ "kind": "insert",+ "text": "3000行",+ "sub": "帮我做个网站",+ "data": {+ "hit": 1.6,+ "count": 3000,+ "unit": "行"+ }+ },+ {+ "at": 2.8,+ "kind": "react"+ },+ {+ "at": 4.1,+ "kind": "point",+ "text": "第一次让 AI 写代码,",+ "sub": "这些……贴哪儿?",+ "data": {+ "pose": "point"+ }+ },+ {+ "at": 6.6,+ "kind": "highlight",+ "data": {+ "mark": "?"+ }+ }+ ],+ "_note": "y4 必须用你自己的角色帧库(AI 生帧,见 references/10-角色.md 与 角色精细度.md)。把 <你的角色> 换成你的帧库;没有生图能力就别用 y4。"}diff --git a/scripts/engine/examples/y5_kinetic_type.json b/scripts/engine/examples/y5_kinetic_type.jsonindex cd09960..d3a57a2 100644--- a/scripts/engine/examples/y5_kinetic_type.json+++ b/scripts/engine/examples/y5_kinetic_type.json@@ -4,6 +4,7 @@"fps": 30,"width": 1920,"height": 1080,+ "theme": "poster","cues": [{ "at": 0.7, "kind": "number", "text": "一句话换来的代码", "data": { "value": 3000, "suffix": " 行" } },{ "at": 2.6, "kind": "point", "text": "补全", "sub": "以前它补一行", "data": { "label": "从前", "key": "一行" } },diff --git a/scripts/engine/lib/palettes.js b/scripts/engine/lib/palettes.jsnew file mode 100644index 0000000..172b2a2--- /dev/null+++ b/scripts/engine/lib/palettes.js@@ -0,0 +1,57 @@+// 全片主题色板:spec.theme 写名字(或 {name, 覆盖的键} / 完整 6 键对象),clip.js 解析成 ctx.pal,8 个语法都按它上色——+// 一支片子由几种语法拼起来时,底色、字色、强调色是同一套,不再各带各的写死配色。+// 每套 6 个键:bg 底色 · surface 卡片/纸/面板 · ink 主文字 · sub 次要文字与线 · accent 强调 · accent2 第二强调。+// 其余辅助色一律从这 6 个派生(PAL.mix 调明暗、PAL.alpha 调透明度),不引入色板外的色相。+(() => {+window.PALETTES = {+ paper: { bg: '#F3EDE2', surface: '#FBF8F2', ink: '#1B1A17', sub: '#6B655B', accent: '#C8402F', accent2: '#2F5D62' }, // 纸本+ poster: { bg: '#FFD23F', surface: '#FFF6D6', ink: '#111111', sub: '#4A4433', accent: '#FF5A36', accent2: '#14213D' }, // 海报黄+ ink: { bg: '#121417', surface: '#1E2226', ink: '#F2EFE8', sub: '#A39E93', accent: '#F2B33D', accent2: '#5FB3A1' }, // 深墨+ navy: { bg: '#0D1B2A', surface: '#16293D', ink: '#EEF3F6', sub: '#8FA3B3', accent: '#5CC8E0', accent2: '#F2A93B' }, // 海军(平涂,不渐变)+ bauhaus: { bg: '#EFE9DD', surface: '#FFFFFF', ink: '#111111', sub: '#555555', accent: '#D62828', accent2: '#1D4E89' }, // 包豪斯+ snow: { bg: '#E9EEF0', surface: '#FFFFFF', ink: '#1F2A30', sub: '#5E6B72', accent: '#D9482B', accent2: '#3E7C8C' }, // 雪原+ wood: { bg: '#EDE3D1', surface: '#F7F1E6', ink: '#2B2622', sub: '#7A6E62', accent: '#C4552D', accent2: '#3F5B4B' }, // 暖木+ chalk: { bg: '#23302B', surface: '#2E3D37', ink: '#F1EFE6', sub: '#A9B3AA', accent: '#F4D35E', accent2: '#E87D5A' }, // 黑板+};+const KEYS = ['bg', 'surface', 'ink', 'sub', 'accent', 'accent2'];+const HEX = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;+const rgb = h => { h = String(h).trim().replace('#', ''); if (h.length === 3) h = [...h].map(x => x + x).join(''); const n = parseInt(h, 16); return [n >> 16 & 255, n >> 8 & 255, n & 255]; };+const hex = v => '#' + v.map(x => Math.round(Math.max(0, Math.min(255, x))).toString(16).padStart(2, '0')).join('');+const lin = x => { x /= 255; return x <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4); };+const PAL = window.PAL = {+ KEYS,+ names: () => Object.keys(window.PALETTES),+ rgb, hex,+ mix: (a, b, t) => { const x = rgb(a), y = rgb(b); return hex(x.map((v, i) => v + (y[i] - v) * t)); }, // a→b 走 t(0..1),返回 hex+ alpha: (c, a) => { const v = rgb(c); return `rgba(${v[0]},${v[1]},${v[2]},${a})`; },+ lum: c => { const [r, g, b] = rgb(c).map(lin); return 0.2126 * r + 0.7152 * g + 0.0722 * b; }, // WCAG 相对亮度+ contrast: (a, b) => { const x = PAL.lum(a), y = PAL.lum(b); return (Math.max(x, y) + 0.05) / (Math.min(x, y) + 0.05); },+ dark: p => PAL.lum(p.bg) < 0.2, // 深底色板(ink / navy / chalk)+ on: (bg, cands) => cands.reduce((best, c) => PAL.contrast(bg, c) > PAL.contrast(bg, best) ? c : best), // 压在 bg 上最清楚的那个字色+ // spec.theme → 完整 6 键(多一个 name)。null / {} → null(各语法用自己的默认)。写错 → 抛错,clip.js 拒绝启动+ resolve(theme) {+ if (theme == null || (typeof theme === 'object' && !Array.isArray(theme) && !Object.keys(theme).length)) return null;+ const avail = `可用:${PAL.names().join(' / ')}`;+ let out;+ if (typeof theme === 'string') {+ if (!window.PALETTES[theme]) throw new Error(`spec.theme「${theme}」不是色板名。${avail}`);+ out = { name: theme, ...window.PALETTES[theme] };+ } else if (typeof theme === 'object' && !Array.isArray(theme)) {+ const unknown = Object.keys(theme).filter(k => k !== 'name' && !KEYS.includes(k));+ if (unknown.length) throw new Error(`spec.theme 里有不认识的键:${unknown.join(' ')}(只认 name 和 ${KEYS.join(' ')})`);+ if (theme.name != null) {+ if (!window.PALETTES[theme.name]) throw new Error(`spec.theme.name「${theme.name}」不是色板名。${avail}`);+ out = { name: theme.name, ...window.PALETTES[theme.name], ...theme };+ } else {+ const miss = KEYS.filter(k => theme[k] == null);+ if (miss.length) throw new Error(`spec.theme 对象缺 ${miss.join(' ')}:写全 6 个键(${KEYS.join(' ')}),或加 name 用那套色板补缺的键。${avail}`);+ out = { name: 'custom', ...theme };+ }+ } else throw new Error(`spec.theme 要写色板名(字符串)或对象,收到的是 ${JSON.stringify(theme)}。${avail}`);+ const bad = KEYS.filter(k => !HEX.test(String(out[k])));+ if (bad.length) throw new Error(`spec.theme 的 ${bad.map(k => `${k}=${JSON.stringify(out[k])}`).join(' ')} 不是 #rgb / #rrggbb 色值`);+ for (const k of KEYS) out[k] = hex(rgb(out[k])).toUpperCase();+ return out;+ },+};+})();diff --git a/scripts/engine/spec_assets.py b/scripts/engine/spec_assets.pyindex 5b25fe7..2936dd1 100644--- a/scripts/engine/spec_assets.py+++ b/scripts/engine/spec_assets.py@@ -4,7 +4,7 @@cues[].image 一张图(截图、照片、录像的一帧)cues[].frames 帧序列:目录(按文件名排序取 .png/.jpg/.jpeg/.webp)或路径数组;配 cues[].fps(默认 30)data.image 语法级的一张图(y1 用作中心物的图)- data.character y4 角色:预设名(neutral / bun / author)原样放行;目录 → 帧库(文件名去扩展名 = 姿势名);+ data.character y4 角色:预设名(neutral / bun / author)原样放行(y4 已停用代码画的角色,启动时会报错要帧库);目录 → 帧库(文件名去扩展名 = 姿势名);对象 {frames: {姿势: 路径} | 目录} 同理文件不存在 → FileNotFoundError(调用方拒绝渲染,不出空白帧)。"""diff --git a/scripts/film_gate.py b/scripts/film_gate.pyindex 960d07f..f5ce42d 100644--- a/scripts/film_gate.py+++ b/scripts/film_gate.py@@ -23,6 +23,13 @@都是边缘,不会误伤;「画面 95% 是同一色」这种按颜色的判法在标定集里会把认可的白板片判成 3 秒空画面,所以不用。标定数据里的 32 支片(含作者表过态的 13 支、9 支认可)没有一支出现过连续 2 帧的空帧。短片降级不适用于这一条。+第三条门禁:蓝紫底画面时长占比(作者原话「我们需要规避下蓝、紫渐变的垃圾配色,这种非常ai slop」)。+2fps、160 宽 RGB,像素色相 225°–300°、饱和度 ≥0.30、亮度 0.06–0.90 算蓝紫;一帧里蓝紫像素 ≥30% 算蓝紫帧。+蓝紫帧占比 ≥0.30 红灯,≥0.12 黄灯。标定(2026-10-10):88 支片里作者认可的 9 支最高 0.10(花叔穿越名画),+大多为 0;他否掉或两支都不要的片子 0.46–1.00(深紫星空+白壳机器人那支 0.94)。海军蓝平涂(色相约 210°)不算。+题材本身要蓝紫(用户点名的赛博朋克紫、梵高星月夜这类风格画面)时,用 --allow-blue-purple "理由" 降为黄灯,+理由原样写进交付说明的事实段。+其余指标只报告(最多黄灯,不拦)。静止类指标(静止帧占比、最长连续静止、最长无事件间隔)会把「停住→猛动→停住」的好片判反,所以绝不能拿来当门禁;黄灯只是「去看这一段」。@@ -57,6 +64,7 @@ METRICS = {# key: (中文名, 方向, 黄线, 红线, 是否门禁, 单位)"fast_ratio": ("快速运动帧占比", "low_bad", 0.06, 0.035, True, ""),"blank_run_s": ("中段近乎纯色的空画面(最长连续)", "high_bad", None, 0.3, True, "秒"),+ "blue_purple_share": ("蓝紫底画面时长占比", "high_bad", 0.12, 0.30, True, ""),"fast_ratio_worst_window": ("最差30秒窗口的快动帧占比", "low_bad", 0.02, None, False, ""),"top10_share": ("运动集中度(前10%帧占运动量)", "info", None, None, False, ""),"drift_ratio": ("慢漂帧占比", "high_bad", 0.65, None, False, ""),@@ -535,11 +543,38 @@ def template_similarity(F, shots, template):return float(durs[sims >= 0.70].sum() / durs.sum()), float(sims.max())+BP_HUE, BP_SAT, BP_VAL, BP_FRAME = (225, 300), 0.30, (0.06, 0.90), 0.30+++def blue_purple(path, fps=SAMPLE_FPS, width=160):+ """蓝紫帧占比与蓝紫段时间码。色相 225°–300°、饱和度 ≥0.30、亮度 0.06–0.90 的像素占一帧 ≥30% 算蓝紫帧。"""+ w, h = probe(path)[:2]+ hh = max(2, int(round(h * width / w / 2)) * 2)+ raw = subprocess.run(["ffmpeg", "-v", "error", "-i", path, "-vf", f"fps={fps},scale={width}:{hh}",+ "-f", "rawvideo", "-pix_fmt", "rgb24", "-"], capture_output=True, check=True).stdout+ F = np.frombuffer(raw, np.uint8).reshape(-1, hh, width, 3).astype(np.float32) / 255+ if not len(F):+ return 0.0, []+ r, g, b = F[..., 0], F[..., 1], F[..., 2]+ mx, mn = F.max(-1), F.min(-1); d = mx - mn + 1e-6+ sat = d / (mx + 1e-6)+ hue = np.where(mx == r, ((g - b) / d) % 6, np.where(mx == g, (b - r) / d + 2, (r - g) / d + 4)) * 60+ m = (hue >= BP_HUE[0]) & (hue <= BP_HUE[1]) & (sat >= BP_SAT) & (mx >= BP_VAL[0]) & (mx <= BP_VAL[1])+ bad = m.reshape(len(F), -1).mean(1) >= BP_FRAME+ spans, start = [], None+ for i, x in enumerate(list(bad) + [False]):+ if x and start is None: start = i+ if not x and start is not None:+ if i - start >= 2: spans.append((round(start / fps, 1), round(i / fps, 1)))+ start = None+ return round(float(bad.mean()), 3), spans++# ---------------------------------------------------------------- 打灯SHORT_S = float(os.environ.get("FILM_GATE_MIN_S", 20)) # 标定集都是 45 秒以上的成片;短于这个时长的片段读数噪声大,红灯降为黄灯只提示-FACT_GATES = {"blank_run_s"} # 事实类门禁:片长再短也照样红灯+FACT_GATES = {"blank_run_s", "blue_purple_share"} # 片长再短也照样红灯(配色不随片长变)def grade(res):@@ -551,6 +586,8 @@ def grade(res):rows.append((k, name, v, "--", gate, unit)); continuebad = (lambda t: v >= t) if direc == "high_bad" else (lambda t: v <= t)lv = "red" if (gate and r is not None and bad(r)) else "yellow" if (y is not None and bad(y)) else "green"+ if lv == "red" and k == "blue_purple_share" and res.get("allow_blue_purple"):+ lv = "yellow"if lv == "red" and short and k not in FACT_GATES:lv = "yellow"; res["short_clip_note"] = f"片长 {res.get('duration_s')}s,短于 {SHORT_S}s,快动门禁只提示不拦(空画面照样拦);拼进成片后在成片上再跑一次"red |= lv == "red"@@ -569,6 +606,11 @@ BLANK_FIX = ("空画面这一段让主角或主物留在画里:要换气就让"转场不要经过纯色底(黑场、纯色闪、渐变底)停留 0.3 秒以上。白板、黑底片只要画面上有笔画、线条、字,就不算空。")+BP_FIX = ("换掉蓝紫底:片段 spec 写同一个 \"theme\"(references/色板.md 里的 paper、poster、ink、navy、bauhaus、snow、wood、chalk,"+ "或按它的规则自定),scenes 也用这套色板;不画深紫星空、蓝紫渐变、霓虹青紫光。"+ "题材本身就要蓝紫(用户点名的赛博朋克紫、梵高星月夜)才用 --allow-blue-purple \"理由\",理由会写进交付说明。")++# 只报告的黄灯项:一句「去看哪里」LOOK = {"fast_ratio_worst_window": lambda r: f"{r['worst_window_start_s']:.0f}–{r['worst_window_start_s'] + r['worst_window_len_s']:.0f}s 这段几乎没有快动作(前紧后松)",@@ -603,6 +645,13 @@ def explain(res):segs = "、".join(f"{a:.2f}–{b:.2f}s" for a, b in res["blank_runs_s"])head = (f"中段有 {len(res['blank_runs_s'])} 段近乎纯色的空画面({segs}),最长 {res['blank_run_s']:.2f}s,"f"整帧几乎没有边缘或纹理、主体不在画里") + (";另外" + head if lv != "green" else "")+ bp = res["lights"].get("blue_purple_share")+ if bp in ("red", "yellow") and not res.get("allow_blue_purple"):+ segs = "、".join(f"{a:.1f}–{b:.1f}s" for a, b in res["blue_purple_spans_s"][:6])+ msg = f"{res['blue_purple_share']:.0%} 的画面是蓝紫底({segs})"+ head = (msg + ",这是最典型的 AI 配色" + (";另外" + head if lv != "green" or blank_red else "")) if bp == "red" else head + ";" + msg+ elif res.get("allow_blue_purple") and res["blue_purple_share"] >= METRICS["blue_purple_share"][2]:+ head += f";蓝紫底占 {res['blue_purple_share']:.0%},已声明题材需要:{res['allow_blue_purple']}"why = []if lv != "green":if res["slow_zoom_share"] >= 0.3:@@ -618,15 +667,19 @@ def explain(res):if res.get("worst_window_start_s") is not None:a = res["worst_window_start_s"]ww = {"start_s": a, "end_s": round(a + res["worst_window_len_s"], 2), "fast_ratio": res["fast_ratio_worst_window"]}- fix = " ".join(x for x in (BLANK_FIX if blank_red else None, FIX if lv != "green" else None) if x) or None+ fix = " ".join(x for x in (BP_FIX if bp == "red" else None, BLANK_FIX if blank_red else None, FIX if lv != "green" else None) if x) or Nonereturn {"summary": head, "why": why, "fix": fix, "look": look, "worst_window": ww, "blank_runs": res["blank_runs_s"]}-def measure(path, sub_band=None, vertical="auto", template=DEFAULT_TEMPLATE):- """量一支成片,返回带 lights / gate_light / verdict / explain 的结果。deliver.py 也调它。"""+def measure(path, sub_band=None, vertical="auto", template=DEFAULT_TEMPLATE, allow_blue_purple=None):+ """量一支成片,返回带 lights / gate_light / verdict / explain 的结果。deliver.py 也调它。+ allow_blue_purple:题材本身要蓝紫时的理由(非空字符串),蓝紫门禁降为黄灯,理由进结果。"""tpl = template if template and os.path.exists(template) else Nonecv2.setNumThreads(max(1, (os.cpu_count() or 2) // 2))res = analyze(path, sub_band=sub_band, vertical=vertical, template=tpl)+ res["blue_purple_share"], res["blue_purple_spans_s"] = blue_purple(path)+ if allow_blue_purple and allow_blue_purple.strip():+ res["allow_blue_purple"] = allow_blue_purple.strip()rows, red = grade(res)res["lights"] = {k: lv for k, _, _, lv, _, _ in rows}res["gate_metrics"] = [k for k, _, _, _, gate, _ in rows if gate]@@ -650,6 +703,10 @@ def report_lines(res, rows):ex = res["explain"]if res.get("blank_runs_s"):L.append(" 空画面时间码:" + "、".join(f"{a:.2f}–{b:.2f}s" for a, b in res["blank_runs_s"]))+ if res.get("blue_purple_spans_s") and res["lights"].get("blue_purple_share") != "green":+ L.append(" 蓝紫底时间码:" + "、".join(f"{a:.1f}–{b:.1f}s" for a, b in res["blue_purple_spans_s"]))+ if res.get("allow_blue_purple"):+ L.append(f" 已声明题材需要蓝紫:{res['allow_blue_purple']}")if ex["worst_window"]:w = ex["worst_window"]L.append(f" 最差 {w['end_s'] - w['start_s']:.0f} 秒窗口:{w['start_s']:.0f}–{w['end_s']:.0f}s,快动帧占比 {w['fast_ratio']};"@@ -667,11 +724,14 @@ def main():help="屏蔽底部字幕带的比例;默认横屏 0.15、竖屏 0.18;0 表示不屏蔽")ap.add_argument("--template", default=DEFAULT_TEMPLATE, help="示范片(取前 12 秒比构图)")ap.add_argument("--no-template", action="store_true")+ ap.add_argument("--allow-blue-purple", metavar="理由", default=None,+ help="题材本身要蓝紫(用户点名的赛博朋克紫、梵高星月夜)时写理由,蓝紫门禁降为黄灯")a = ap.parse_args()if not shutil.which("ffmpeg") or not shutil.which("ffprobe"):print("需要 ffmpeg/ffprobe", file=sys.stderr); sys.exit(1)try:- res, rows = measure(a.mp4, sub_band=a.sub_band, vertical=a.vertical, template=None if a.no_template else a.template)+ res, rows = measure(a.mp4, sub_band=a.sub_band, vertical=a.vertical, template=None if a.no_template else a.template,+ allow_blue_purple=a.allow_blue_purple)except (subprocess.CalledProcessError, KeyError, IndexError, RuntimeError, ValueError) as e:print(f"读不了这支片:{a.mp4}({e})", file=sys.stderr); sys.exit(1)red = res["verdict"] == "red"@@ -689,7 +749,7 @@ def main():for _, t in ex["look"]:print(" - " + t)if not red:- print("提醒:门禁只拦「整片几乎没有快动作」和「中段空画面」两种硬伤;独立审片仍然要做。")+ print("提醒:门禁只拦「整片几乎没有快动作」「中段空画面」「蓝紫底」三种硬伤;独立审片仍然要做。")sys.exit(2 if red else 0)diff --git a/scripts/storyboard_lint.py b/scripts/storyboard_lint.pyindex 37998e6..415833b 100644--- a/scripts/storyboard_lint.py+++ b/scripts/storyboard_lint.py@@ -8,7 +8,12 @@用法:uv run storyboard_lint.py 镜头表.md [--script 文稿.txt] # 或 python3 storyboard_lint.py …-镜头表是一张 markdown 表(模板与示例见 references/镜头表模板.md),每行一镜,列:+镜头表开头先锁画风(表外三行,写在表前):+ 画风:一句话(一张风格卡或一种画法,全片只用这一种)+ 色板:色板名(paper/poster/ink/navy/bauhaus/snow/wood/chalk,或中文名)或 3–6 个色值+ 角色:无 / 只出手和背影 / 帧库 <路径>(AI 生帧)+ 允许蓝紫:<理由>(可选,只在用户点名要蓝紫时写)+然后是一张 markdown 表(模板与示例见 references/镜头表模板.md),每行一镜,列:时间段 | 画面里的物 | 它在做什么 | 镜头 | 屏上字 | 做法(可选,建议写)| 标签(可选)代码块(```)里的表不检查。文件里有多张表时只查第一张带「物」和「做什么」两列的表。@@ -27,7 +32,11 @@⑩ 有「标签」列时:一镜标签超过 3 个 → 黄整表检查:⑤ 文字主导的镜头占比 ≤ 30% → 红- 做法列(写了才查):同一个参数化片段(同一个 .json)合计超过 8 秒 → 红;20 秒以上的片子画面做法少于 3 种 → 红+ 做法列(写了才查):同一个参数化片段(同一个 .json)合计超过 8 秒 → 红;参数化片段语法超过 2 种(拼贴)→ 红+ ⑫ 画风锁:缺「画风」「色板」「角色」任一行 → 红+ ⑬ 色板:色值落在蓝紫区(色相 225°–300°、饱和度 ≥0.30)→ 红(写了「允许蓝紫」降黄);超过 6 色 → 黄+ ⑭ 角色:角色行写代码画/Q 版小人/机器人 → 红;物列有机器人、小人、火柴人、吉祥物、卡通人而角色不是帧库 → 红;+ 用了 y4 而角色不是帧库 → 红;物列给金币、小球、离子长脸 → 黄时间段前后接不上、整表没有一次快推/横移/砸入 → 黄退出码:有红灯 1;只有黄灯或全绿 0;读不了文件或找不到表 2。只用标准库。@@ -56,6 +65,38 @@ CAM_FAST = ("快推", "横移", "砸入", "推近", "甩")EMPTY_SCENE = re.compile(r"空镜|空景|空画面|空屏|黑场|黑屏|白屏|全黑|全白|暗场|留白|纯色|渐变|^背景$|^底色$|^[黑白]底$")EMPTY_CELL = {"", "-", "—", "–", "无", "空", "(空)", "(空)", "/", "/", "——"}GRAMMAR = re.compile(r"\b([ty][1-9])(?:_[a-z_]+)?\b", re.I)+# ⑫–⑭ 画风锁+LOCK = re.compile(r"^\s*[-*]?\s*(?:\*\*)?(画风|色板|角色|允许蓝紫)(?:\*\*)?\s*[::]\s*(.+?)\s*$")+PALETTES = {"paper", "poster", "ink", "navy", "bauhaus", "snow", "wood", "chalk",+ "纸本", "海报黄", "深墨", "海军", "包豪斯", "雪原", "暖木", "黑板"}+HEX = re.compile(r"#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})\b")+CHAR_BAD = re.compile(r"代码画|手写|svg|SVG|Q\s*版|q\s*版|小人|机器人|火柴人|卡通人")+CHAR_FRAMES = re.compile(r"帧库|frames|\.png|/")+CHAR_NONE = re.compile(r"无|没有|不出人|不出脸|只出手|手|背影|剪影")+OBJ_CHAR = re.compile(r"机器人|小人|火柴人|吉祥物|卡通人|Q\s*版|q\s*版")+OBJ_FACE = re.compile(r"(笑脸|表情|长脸|眼睛|五官).{0,6}(金币|硬币|小球|球|离子|电子|粒子|分子)|(金币|硬币|小球|离子|电子|粒子|分子).{0,6}(笑脸|表情|长脸|眼睛|五官)")+++def read_lock(text, table_line=None):+ """表外的画风锁:{画风, 色板, 角色, 允许蓝紫}。代码块里的不算;同一项写了几次,取表前离表最近的那一行(表前没有才看表后)。"""+ before, after, fence = {}, {}, False+ for i, ln in enumerate(text.splitlines(), 1):+ if ln.strip().startswith("```"):+ fence = not fence; continue+ m = None if fence else LOCK.match(ln)+ if not m: continue+ if table_line is None or i < table_line: before[m.group(1)] = m.group(2).strip()+ else: after.setdefault(m.group(1), m.group(2).strip())+ return {**after, **before}+++def blue_purple_hex(h):+ h = h if len(h) == 6 else "".join(c * 2 for c in h)+ r, g, b = (int(h[i:i + 2], 16) / 255 for i in (0, 2, 4))+ mx, mn = max(r, g, b), min(r, g, b); d = mx - mn+ if d == 0 or mx == 0: return False+ hue = (((g - b) / d) % 6 if mx == r else (b - r) / d + 2 if mx == g else (r - g) / d + 4) * 60+ return 225 <= hue <= 300 and d / mx >= 0.30 and 0.06 <= mx <= 0.90def strip_cells(line):@@ -347,15 +388,46 @@ def lint(text, script=None):if s > 8:table.append((RED, "做法", f"参数化片段 {c} 撑了 {s:g} 秒(第 {'、'.join(str(r['n']) for r in rs)} 镜)","单个参数化片段最多 8 秒,撑久了读成一页 PPT;拆成几个 spec,中间换别的做法"))- kinds = {how_kind(r["how"]) for r in rows} - {None}- if total >= 20 and len(kinds) < 3:- table.append((RED, "做法", f"全片只用了 {len(kinds)} 种画面做法({'、'.join(sorted(kinds)) or '没写'})",- "至少 3 种:不同语法的片段、scenes 代码画、真实素材满幅,各算一种"))+ grams = sorted({k for k in (how_kind(r["how"]) for r in rows) if k and GRAMMAR.fullmatch(k)})+ if len(grams) > 2:+ table.append((RED, "做法", f"用了 {len(grams)} 种片段语法({'、'.join(grams)}),拼起来是几种画风",+ "一支片最多 2 种片段语法,所有 spec 写同一个 theme;其余镜头用 scenes 按同一套色板画,或真实素材满幅"))empty_how = [r["n"] for r in rows if how_kind(r["how"]) is None]if empty_how:table.append((YELLOW, "做法", f"第 {'、'.join(map(str, empty_how))} 镜没写做法", "写上用哪个语法的片段(镜NN.json)、scenes/<id>.js 还是素材"))else:- table.append((YELLOW, "做法", "没有「做法」列,查不了单个片段撑多久、用了几种做法", "加一列:y4 片段 镜01.json/scenes/<id>.js/素材 照片"))+ table.append((YELLOW, "做法", "没有「做法」列,查不了单个片段撑多久、用了几种语法", "加一列:y2 片段 镜01.json/scenes/<id>.js/素材 照片"))++ # ⑫–⑭ 画风锁:整片一套视觉语言、配色不落蓝紫、角色要么精细要么不出脸+ lock = read_lock(text, raw[0][0] - 2 if raw else None)+ miss = [k for k in ("画风", "色板", "角色") if not lock.get(k)]+ if miss:+ table.append((RED, "⑫画风锁", f"表前缺「{'」「'.join(miss)}」", "表前写三行——画风:一句话,全片只用这一种;色板:色板名或 3–6 个色值(references/色板.md);"+ "角色:无/只出手和背影/帧库 <路径>(references/角色精细度.md)"))+ pal = lock.get("色板", "")+ if pal:+ hexes = HEX.findall(pal)+ named = any(n in pal for n in PALETTES)+ bp = [f"#{h}" for h in hexes if blue_purple_hex(h)]+ if bp:+ table.append((YELLOW if lock.get("允许蓝紫") else RED, "⑬色板", f"色板里有蓝紫:{'、'.join(bp)}" + ("(已写允许蓝紫的理由)" if lock.get("允许蓝紫") else ""),+ "换成 references/色板.md 里的一套,或把这几个色挪出色相 225°–300°;用户点名要蓝紫才写「允许蓝紫:理由」"))+ if len(hexes) > 6:+ table.append((YELLOW, "⑬色板", f"色板有 {len(hexes)} 个色", "一支片 3–6 个色:底、面、主字、次字、一两个强调色"))+ if not hexes and not named:+ table.append((YELLOW, "⑬色板", f"色板「{pal}」不是色板名也没写色值", "写 references/色板.md 里的名字,或 3–6 个 #色值"))+ ch = lock.get("角色", "")+ frames = bool(ch and CHAR_FRAMES.search(ch))+ if ch and CHAR_BAD.search(ch) and not frames:+ table.append((RED, "⑭角色", f"角色写的是「{ch}」:代码画的小人和机器人已停用", "有生图能力就 AI 生帧(references/10-角色.md),没有就只出手、背影、剪影,或干脆不出人"))+ for r in rows:+ if OBJ_CHAR.search(r["obj"]) and not frames:+ r["issues"].append((RED, "⑭角色", f"物列里有「{OBJ_CHAR.search(r['obj']).group(0)}」,角色却不是帧库",+ "这一镜换成手、背影或一个物;要出角色先按 references/角色精细度.md 做帧库"))+ if OBJ_FACE.search(r["obj"] + r["act"]):+ r["issues"].append((YELLOW, "⑭角色", "给金币、小球、离子这类东西长了脸", "物就画成物:靠形状、颜色、动作讲,不加表情"))+ if how_kind(r["how"]) == "y4" and not frames:+ r["issues"].append((RED, "⑭角色", "y4 要角色帧库,角色行不是帧库", "换 y2/y5 或 scenes 用手和物讲;有生图能力就先做帧库"))issues = [x for r in rows for x in r["issues"]] + tableverdict = RED if any(x[0] == RED for x in issues) else YELLOW if issues else GREEN@@ -383,7 +455,7 @@ def report(res):GREEN: "结论:绿灯。可以开始做。"}[res["verdict"]])if not res.get("script") and res.get("numbered"):L.append(f"第 {'、'.join(map(str, res['numbered']))} 镜屏上有数字:加 --script 文稿.txt 可以核对它们和口播是不是同一个数。")- L.append("机器查不了、要你自己对的:全片是不是一个具体例子或角色贯穿;相邻两镜的版式是不是不同;开头 3 秒是不是一个小场景而不是题目。")+ L.append("机器查不了、要你自己对的:全片是不是一个具体例子贯穿、是不是同一种画风;相邻两镜的构图是不是不同;开头 3 秒是不是一个小场景而不是题目。")return Ldiff --git a/tests/fixtures/y4_storytime_test_frames.json b/tests/fixtures/y4_storytime_test_frames.jsonnew file mode 100644index 0000000..f9d1ec4--- /dev/null+++ b/tests/fixtures/y4_storytime_test_frames.json@@ -0,0 +1,52 @@+{+ "grammar": "y4_storytime",+ "duration": 8.5,+ "fps": 30,+ "width": 1920,+ "height": 1080,+ "theme": "snow",+ "data": {+ "character": {+ "frames": {+ "rest": "../demos/_shared/hero/c1_1.png",+ "talk": "../demos/_shared/hero/c1_1.png",+ "point": "../demos/_shared/hero/c1_0.png",+ "shrug": "../demos/_shared/hero/c1_2.png"+ }+ }+ },+ "cues": [+ {+ "at": 0.1,+ "kind": "insert",+ "text": "3000行",+ "sub": "帮我做个网站",+ "data": {+ "hit": 1.6,+ "count": 3000,+ "unit": "行"+ }+ },+ {+ "at": 2.8,+ "kind": "react"+ },+ {+ "at": 4.1,+ "kind": "point",+ "text": "第一次让 AI 写代码,",+ "sub": "这些……贴哪儿?",+ "data": {+ "pose": "point"+ }+ },+ {+ "at": 6.6,+ "kind": "highlight",+ "data": {+ "mark": "?"+ }+ }+ ],+ "_note": "只给测试用:帧是作者本人的 AI 卡通形象(不随 MIT 授权,不许进别人的成片)。路径相对 scripts/engine/examples/。"+}diff --git a/tests/test_clip_theme.py b/tests/test_clip_theme.pynew file mode 100644index 0000000..450389d--- /dev/null+++ b/tests/test_clip_theme.py@@ -0,0 +1,205 @@+"""全片主题色板(spec.theme → ctx.pal)与 y4 停用代码画的小人:++ 色板名解析成完整 6 键;{name, 覆盖}用那套补缺的键;名字写错、对象缺键 → 启动失败,报错里列出可用名字 / 缺的键;+ 色板真的落到画面上(t3 的底色);不写 theme 时 y1 的底不再是靛紫渐变;+ y4 没有角色帧库(缺 data.character 或写预设名)→ 启动失败,报错说清楚;同一时刻渲两次逐像素一致。++需要 uv 和 Playwright Chromium(没装就跳过,和 test_clip_world 一样);像素只用 Pillow 读。+"""+import colorsys+import json+import shutil+import subprocess+import tempfile+import unittest+from pathlib import Path++ROOT = Path(__file__).resolve().parents[1]+ENGINE = ROOT / 'scripts' / 'engine'+EX = ENGINE / 'examples'+W = {}++# 在一张空页里加载 lib/palettes.js,逐个调用 PAL.resolve,结果(或报错信息)按 JSON 打出来+RESOLVE = r'''+import json, sys+from playwright.sync_api import sync_playwright+cases = json.loads(sys.argv[2])+with sync_playwright() as p:+ b = p.chromium.launch(); pg = b.new_page(); pg.set_content('<html></html>'); pg.add_script_tag(path=sys.argv[1])+ out = pg.evaluate("""cases => cases.map(th => { try { return { ok: PAL.resolve(th) }; } catch (e) { return { err: e.message }; } })""", cases)+ b.close()+print(json.dumps(out, ensure_ascii=False))+'''+CASES = ['paper', {'name': 'ink', 'accent': '#ABCDEF'}, {'bg': '#000', 'surface': '#111111', 'ink': '#ffffff', 'sub': '#888888', 'accent': '#ff0000', 'accent2': '#00ff00'},+ 'purple', {'bg': '#000000'}, {'name': 'nope'}, None, {}, {'name': 'snow', 'accent': 'red'}]+++def uv(args, timeout=600):+ r = subprocess.run(['uv', 'run', '--quiet', '--with', 'playwright', 'python', *args], capture_output=True, text=True, timeout=timeout)+ if r.returncode != 0 and 'Executable doesn' in (r.stdout + r.stderr):+ raise unittest.SkipTest('Playwright Chromium 没装:uv run --with playwright playwright install chromium')+ return r+++def render(spec, out, stills):+ """渲几张静帧;返回 (CompletedProcess, {t: png 路径})。spec 是 dict(写进临时目录,图片路径要是绝对路径)或现成的 json 路径。"""+ if isinstance(spec, dict):+ p = Path(W['tmp'].name) / (out.name + '.json'); p.write_text(json.dumps(spec, ensure_ascii=False), encoding='utf-8'); spec = p+ r = uv([str(ENGINE / 'render.py'), '--spec', str(spec), '--stills', ','.join(map(str, stills)), '--out', str(out)])+ return r, {t: out / f't{t:06.2f}.png' for t in stills}+++def absolutize(spec):+ """样例 spec 拷到临时目录渲:帧库、图片的相对路径改成绝对路径。"""+ spec = json.loads(json.dumps(spec))+ ch = (spec.get('data') or {}).get('character')+ if isinstance(ch, dict) and isinstance(ch.get('frames'), dict):+ ch['frames'] = {k: str((EX / v).resolve()) for k, v in ch['frames'].items()}+ for q in spec.get('cues', []):+ if q.get('image'):+ q['image'] = str((EX / q['image']).resolve())+ return spec+++def ex(name):+ if name == 'y4_storytime': # 样例里的帧库是占位路径;测试用作者本人的帧(只给测试用,见 fixtures 里的说明)+ return json.loads((ROOT / 'tests' / 'fixtures' / 'y4_storytime_test_frames.json').read_text(encoding='utf-8'))+ return json.loads((EX / f'{name}.json').read_text(encoding='utf-8'))+++def setUpModule():+ if not shutil.which('uv'):+ raise unittest.SkipTest('需要 uv')+ try:+ from PIL import Image # noqa: F401+ except ImportError:+ raise unittest.SkipTest('需要 Pillow')+ W['tmp'] = tempfile.TemporaryDirectory()+ tmp = Path(W['tmp'].name)+ r = uv(['-c', RESOLVE, str(ENGINE / 'lib' / 'palettes.js'), json.dumps(CASES)])+ assert r.returncode == 0, r.stdout + r.stderr+ W['resolve'] = json.loads(r.stdout.strip().splitlines()[-1])+ t3 = absolutize(ex('t3_finance_chart'))+ y4 = absolutize(ex('y4_storytime'))+ W['runs'] = {+ 't3_snow': render({**t3, 'theme': 'snow'}, tmp / 't3_snow', [6.5]),+ 't3_override': render({**t3, 'theme': {'name': 'snow', 'bg': '#102030'}}, tmp / 't3_override', [6.5]),+ 'y1_default': render({k: v for k, v in ex('y1_kurzgesagt').items() if k != 'theme'}, tmp / 'y1_default', [0.2]),+ 'bad_name': render({**t3, 'theme': 'purple'}, tmp / 'bad_name', [1]),+ 'bad_obj': render({**ex('y5_kinetic_type'), 'theme': {'bg': '#000000', 'ink': '#ffffff'}}, tmp / 'bad_obj', [1]), # t3 把这种对象当旧主题写法,换 y5 测+ 't3_legacy_obj': render({**t3, 'theme': {'bg': '#000000', 'ink': '#ffffff'}}, tmp / 't3_legacy_obj', [6.5]),+ 'y4_none': render({k: v for k, v in y4.items() if k != 'data'}, tmp / 'y4_none', [1]),+ 'y4_preset': render({**y4, 'data': {'character': 'neutral'}}, tmp / 'y4_preset', [1]),+ 'y4_a': render(y4, tmp / 'y4_a', [1.2, 4.6]),+ 'y4_b': render(y4, tmp / 'y4_b', [1.2, 4.6]),+ }+++def tearDownModule():+ if 'tmp' in W:+ W['tmp'].cleanup()+++def img(p):+ from PIL import Image+ return Image.open(p).convert('RGB')+++class Resolve(unittest.TestCase):+ def test_name_gives_all_six_keys(self):+ r = W['resolve'][0]['ok']+ self.assertEqual(r['name'], 'paper')+ self.assertEqual({k: r[k] for k in ('bg', 'surface', 'ink', 'sub', 'accent', 'accent2')},+ {'bg': '#F3EDE2', 'surface': '#FBF8F2', 'ink': '#1B1A17', 'sub': '#6B655B', 'accent': '#C8402F', 'accent2': '#2F5D62'})++ def test_name_plus_override_fills_from_that_palette(self):+ r = W['resolve'][1]['ok']+ self.assertEqual(r['accent'], '#ABCDEF')+ self.assertEqual(r['bg'], '#121417') # 其余键来自 ink 那套+ self.assertEqual(r['accent2'], '#5FB3A1')++ def test_full_object_without_name_is_accepted(self):+ r = W['resolve'][2]['ok']+ self.assertEqual(r['bg'], '#000000') # #rgb 规整成 #RRGGBB+ self.assertEqual(r['accent2'], '#00FF00')++ def test_unknown_name_lists_available(self):+ e = W['resolve'][3]['err']+ self.assertIn('purple', e)+ for n in ('paper', 'poster', 'ink', 'navy', 'bauhaus', 'snow', 'wood', 'chalk'):+ self.assertIn(n, e)+ self.assertIn('nope', W['resolve'][5]['err'])++ def test_object_without_name_names_missing_keys(self):+ e = W['resolve'][4]['err']+ for k in ('surface', 'ink', 'sub', 'accent', 'accent2'):+ self.assertIn(k, e)++ def test_no_theme_is_null(self):+ self.assertIsNone(W['resolve'][6]['ok'])+ self.assertIsNone(W['resolve'][7]['ok'])++ def test_non_hex_value_rejected(self):+ self.assertIn('accent', W['resolve'][8]['err'])+++class OnScreen(unittest.TestCase):+ def test_palette_reaches_the_frame(self):+ r, st = W['runs']['t3_snow']+ self.assertEqual(r.returncode, 0, r.stdout + r.stderr)+ px = img(st[6.5]).getpixel((20, 540))+ self.assertTrue(all(abs(a - b) <= 2 for a, b in zip(px, (0xE9, 0xEE, 0xF0))), px)++ def test_override_reaches_the_frame(self):+ r, st = W['runs']['t3_override']+ self.assertEqual(r.returncode, 0, r.stdout + r.stderr)+ px = img(st[6.5]).getpixel((20, 540))+ self.assertTrue(all(abs(a - b) <= 2 for a, b in zip(px, (0x10, 0x20, 0x30))), px)++ def test_y1_default_sky_is_not_blue_purple(self):+ r, st = W['runs']['y1_default']+ self.assertEqual(r.returncode, 0, r.stdout + r.stderr)+ im = img(st[0.2])+ for xy in ((10, 10), (im.width - 10, 10), (10, im.height - 10), (im.width // 2, im.height - 10)):+ h, l, s = colorsys.rgb_to_hls(*[v / 255 for v in im.getpixel(xy)])+ self.assertFalse(230 <= h * 360 <= 300 and s > 0.25, (xy, im.getpixel(xy)))+++class BootFails(unittest.TestCase):+ def check(self, key, *needles):+ r, _ = W['runs'][key]+ out = r.stdout + r.stderr+ self.assertNotEqual(r.returncode, 0, out)+ for n in needles:+ self.assertIn(n, out)++ def test_bad_theme_name(self):+ self.check('bad_name', '不是色板名', 'paper', 'chalk')++ def test_theme_object_missing_keys(self):+ self.check('bad_obj', '缺', 'surface', 'accent2')++ def test_t3_old_theme_object_still_works(self):+ r, st = W['runs']['t3_legacy_obj']+ self.assertEqual(r.returncode, 0, r.stdout + r.stderr)+ self.assertLess(sum(img(st[6.5]).getpixel((20, 540))), 30)++ def test_y4_without_character(self):+ self.check('y4_none', 'y4 需要角色帧库', '代码画的小人已停用')++ def test_y4_preset_name_no_longer_draws(self):+ self.check('y4_preset', 'y4 需要角色帧库', 'neutral')+++class Deterministic(unittest.TestCase):+ def test_same_time_twice_is_pixel_identical(self):+ from PIL import ImageChops+ (ra, a), (rb, b) = W['runs']['y4_a'], W['runs']['y4_b']+ self.assertEqual(ra.returncode, 0, ra.stdout + ra.stderr)+ self.assertEqual(rb.returncode, 0, rb.stdout + rb.stderr)+ for t in a:+ self.assertIsNone(ImageChops.difference(img(a[t]), img(b[t])).getbbox(), f'{t}s 两次渲染不一致')+++if __name__ == '__main__':+ unittest.main()diff --git a/tests/test_clip_world.py b/tests/test_clip_world.pyindex 5af9456..e926d10 100644--- a/tests/test_clip_world.py+++ b/tests/test_clip_world.py@@ -38,6 +38,7 @@ def setUpModule():W['tmp'] = tempfile.TemporaryDirectory()tmp = Path(W['tmp'].name)base = json.loads((EX / 't3_finance_chart.json').read_text(encoding='utf-8'))+ base.pop('theme', None) # 样例带了全片色板;这里量的是不写 theme 时的默认和旧写法specs = {'t3_default': base, 't3_dark': {**base, 'theme': 'dark'},'t3_fill': {**base, 'width': 1080, 'height': 1920, 'safe': {'top': 0, 'bottom': 520, 'fill': '#141a2b'}}}for k, spec in specs.items():diff --git a/tests/test_film_gate_color.py b/tests/test_film_gate_color.pynew file mode 100644index 0000000..f8cceeb--- /dev/null+++ b/tests/test_film_gate_color.py@@ -0,0 +1,73 @@+"""film_gate.py 的蓝紫底门禁:蓝紫帧占比 ≥0.30 红灯,--allow-blue-purple "理由" 降为黄灯。++只用 ffmpeg 的 lavfi 合成 6 秒小片(不需要引擎和 Playwright),每支都叠一层网格,免得被空画面门禁先拦:+ purple —— 深紫底(#2A1A6E)整片 → 红灯,报告给时间码+ navy —— 海军蓝平涂(#0D1B2A,色相约 210°)整片 → 不算蓝紫+ paper —— 纸色底(#F3EDE2)整片 → 不算+6 秒短于 20 秒,快动门禁只会黄灯;退出码 2 只可能来自蓝紫这一条(它不受短片降级)。+"""+import json+import os+import shutil+import subprocess+import tempfile+import unittest+from pathlib import Path++ROOT = Path(__file__).resolve().parents[1]+SCRIPTS = ROOT / 'scripts'+SIZE, FPS = '960x540', 30+GRID = 'drawgrid=w=96:h=96:t=2:[email protected]'+CLIPS = {+ 'purple': f'color=c=0x2A1A6E:s={SIZE}:r={FPS}:d=6,{GRID}',+ 'navy': f'color=c=0x0D1B2A:s={SIZE}:r={FPS}:d=6,{GRID}',+ 'paper': f'color=c=0xF3EDE2:s={SIZE}:r={FPS}:d=6,drawgrid=w=96:h=96:t=2:[email protected]',+}+W = {}+ENV = dict(os.environ, FILM_GATE_MIN_S='20')+++def setUpModule():+ if not all(shutil.which(x) for x in ('uv', 'ffmpeg', 'ffprobe')):+ raise unittest.SkipTest('需要 uv、ffmpeg、ffprobe')+ W['tmp'] = tempfile.TemporaryDirectory()+ for name, src in CLIPS.items():+ subprocess.run(['ffmpeg', '-v', 'error', '-y', '-f', 'lavfi', '-i', src, '-pix_fmt', 'yuv420p', '-c:v', 'libx264',+ '-crf', '18', str(Path(W['tmp'].name) / f'{name}.mp4')], check=True, capture_output=True)+++def tearDownModule():+ if 'tmp' in W:+ W['tmp'].cleanup()+++def gate(name, *extra):+ p = subprocess.run(['uv', 'run', '--quiet', str(SCRIPTS / 'film_gate.py'), str(Path(W['tmp'].name) / f'{name}.mp4'),+ '--no-template', '--json', *extra], capture_output=True, text=True, timeout=600, env=ENV)+ return p.returncode, json.loads(p.stdout)+++class BluePurpleGate(unittest.TestCase):+ def test_purple_is_red(self):+ code, r = gate('purple')+ self.assertEqual(code, 2)+ self.assertGreaterEqual(r['blue_purple_share'], 0.9)+ self.assertEqual(r['lights']['blue_purple_share'], 'red')+ self.assertTrue(r['blue_purple_spans_s'])+ self.assertIn('蓝紫', r['explain']['summary'])++ def test_navy_and_paper_pass(self):+ for name in ('navy', 'paper'):+ code, r = gate(name)+ self.assertEqual(r['lights']['blue_purple_share'], 'green', name)+ self.assertEqual(code, 0, name)++ def test_override_downgrades_to_yellow(self):+ code, r = gate('purple', '--allow-blue-purple', '用户点名要赛博朋克紫')+ self.assertEqual(code, 0)+ self.assertEqual(r['lights']['blue_purple_share'], 'yellow')+ self.assertEqual(r['allow_blue_purple'], '用户点名要赛博朋克紫')+++if __name__ == '__main__':+ unittest.main()diff --git a/tests/test_storyboard_lint.py b/tests/test_storyboard_lint.pyindex ee7cc3e..d29290c 100644--- a/tests/test_storyboard_lint.py+++ b/tests/test_storyboard_lint.py@@ -70,7 +70,7 @@ class BulletWall(unittest.TestCase):def test_one_clip_carrying_the_film(self):whats = [w for lv, t, w, _ in self.res["table"] if t == "做法"]self.assertTrue(any("白板.json" in w and "60" in w for w in whats), whats)- self.assertTrue(any("1 种画面做法" in w for w in whats), whats)+ self.assertIn("⑫画风锁", tags(self.res, SL.RED))def test_cli_exit_nonzero(self):with tempfile.TemporaryDirectory() as d:@@ -227,3 +227,54 @@ class NumberCardRule(unittest.TestCase):res = SL.lint(t)msgs = [i[1] for r in res["rows"] for i in r["issues"]]self.assertIn("⑪数字字卡", msgs)+++class StyleLock(unittest.TestCase):+ """⑫–⑭:表前锁一种画风、一套不落蓝紫的色板、角色要么帧库要么不出脸;片段语法最多 2 种。"""+ HEAD = "| 时间段 | 画面里的物 | 它在做什么 | 镜头 | 屏上字 | 做法 |\n|---|---|---|---|---|---|\n"+ LOCK = "画风:纸本插画\n色板:paper\n角色:只出手\n\n"+ ROWS = ["| 0–3 | 一只猫 | 跳上桌子 | 停 | | scenes/a.js |", "| 3–6 | 那只猫 | 打翻杯子 | 快推 | | scenes/a.js |"]++ def lint(self, lock, rows=None):+ return SL.lint(lock + self.HEAD + "\n".join(rows or self.ROWS) + "\n")++ def red(self, res):+ return {(t, w) for lv, t, w, _ in res["table"] if lv == SL.RED} | {(t, w) for r in res["rows"] for lv, t, w, _ in r["issues"] if lv == SL.RED}++ def test_lock_ok(self):+ res = self.lint(self.LOCK)+ self.assertNotIn("⑫画风锁", {t for t, _ in self.red(res)}, "\n".join(SL.report(res)))+ self.assertFalse([t for t, _ in self.red(res) if t.startswith(("⑫", "⑬", "⑭"))])++ def test_missing_lock_is_red(self):+ res = self.lint("画风:纸本插画\n\n")+ whats = [w for t, w in self.red(res) if t == "⑫画风锁"]+ self.assertTrue(whats and "色板" in whats[0] and "角色" in whats[0], whats)++ def test_blue_purple_palette(self):+ res = self.lint("画风:扁平插画\n色板:#0E0631 #2A1A6E #F9FCFB\n角色:无\n\n")+ self.assertIn("⑬色板", {t for t, _ in self.red(res)})+ res = self.lint("画风:赛博朋克\n色板:#2A1A6E #FF3EA5 #0B0B12\n角色:无\n允许蓝紫:用户点名要赛博朋克紫\n\n")+ self.assertNotIn("⑬色板", {t for t, _ in self.red(res)})+ res = self.lint("画风:海军蓝平涂\n色板:#0D1B2A #16293D #EEF3F6 #5CC8E0\n角色:无\n\n") # 海军蓝色相约 210°,不算+ self.assertNotIn("⑬色板", {t for t, _ in self.red(res)})++ def test_code_drawn_character(self):+ res = self.lint("画风:扁平插画\n色板:paper\n角色:代码画的Q版小人\n\n")+ self.assertIn("⑭角色", {t for t, _ in self.red(res)})+ rows = ["| 0–3 | 一个白壳机器人 | 挥手打招呼 | 停 | | scenes/a.js |", "| 3–6 | 那只猫 | 打翻杯子 | 快推 | | scenes/a.js |"]+ self.assertIn("⑭角色", {t for t, _ in self.red(self.lint(self.LOCK, rows))})+ self.assertNotIn("⑭角色", {t for t, _ in self.red(self.lint("画风:绘本\n色板:paper\n角色:帧库 角色/小满/\n\n", rows))})+ rows = ["| 0–3 | 小满 | 撕开面包袋 | 停 | | y4 片段 镜01.json |", "| 3–6 | 那只猫 | 打翻杯子 | 快推 | | scenes/a.js |"]+ self.assertIn("⑭角色", {t for t, _ in self.red(self.lint(self.LOCK, rows))})++ def test_faces_on_objects_warn(self):+ rows = ["| 0–3 | 带笑脸的金币 | 一枚枚跳进罐子 | 停 | | scenes/a.js |", "| 3–6 | 那只猫 | 打翻杯子 | 快推 | | scenes/a.js |"]+ res = self.lint(self.LOCK, rows)+ self.assertIn("⑭角色", {t for r in res["rows"] for lv, t, *_ in r["issues"] if lv == SL.YELLOW})++ def test_three_grammars_is_collage(self):+ rows = ["| 0–3 | 一只猫 | 跳上桌子 | 停 | | y2 片段 a.json |", "| 3–6 | 那只猫 | 打翻杯子 | 快推 | | y5 片段 b.json |",+ "| 6–9 | 杯子 | 摔成两半 | 砸入 | | t3 片段 c.json |"]+ self.assertTrue(any(t == "做法" and "3 种片段语法" in w for t, w in self.red(self.lint(self.LOCK, rows))))+ self.assertFalse(any(t == "做法" for t, _ in self.red(self.lint(self.LOCK, rows[:2]))))