Spaces:
Paused
Paused
v2:重绘参考视频主角——卷发蓝毛衣少年「阿飞」和他的黑色摩托,9 个场景改为以他为主角
Browse filesFiles changed (11)
- README.md+35-11
- public/mvfonts/black.woff2
- public/mvfonts/neon.woff2+2-2
- src/mv/MvApp.tsx+20-2
- src/mv/copy/platforms.ts+17-17
- src/mv/covers/covers.ts+25-3
- src/mv/engine/hero.tsAdded+959
- src/mv/engine/scenesA.ts+94-61
- src/mv/engine/scenesB.ts+194-130
- src/mv/engine/timeline.ts+10-10
- src/mv/export/exportMp4.ts+9-2
32 unmodified lines3334353637383939 unmodified lines79808182838485868788899091929394959697989910010110210314 unmodified lines11811912012112212367 unmodified lines19119219332 unmodified lines| 5 | 适配**手机竖屏** | 横屏 16:9 / 竖屏 9:16 两套构图;所有场景按画布宽高自适应排版;手机端默认竖屏 || 6 | 导出帧率 **24 / 30 / 60** 可选 | 在导出面板中单选;第 i 帧的时间 = i / fps,保证和音频严格对齐 || 7 | 可复制的**标题、描述、标签** | 小红书 / 抖音 / 微信视频号 / 哔哩哔哩 四套文案,带字数和话题数校验,一键复制 || 8 | **封面**:4:3、3:4、16:9,每种比例多张,可多选 | 用 MV 关键帧渲染并叠加封面排版,每种比例 4 款设计,可勾选多张批量下载 PNG |### 平台文案约束39 unmodified lines- 主色:墨黑 `#07080c`、藏青 `#0f1d2b`、钠灯橙 `#ffb35c`、霓虹红 `#ff2d55`、冷青 `#3de0ff`- 元素:雨丝、积水倒影、霓虹招牌(中文字)、楼宇剪影、卷帘门、电线杆、雾气、探照灯、车灯光轨- 主角:一个穿连帽衫的剪影「夜行者」,踩着节奏行走 / 奔跑- 质感:WebGL 后期 → 辉光 + RGB 色差 + 胶片颗粒 + 扫描线 + 暗角,加上底鼓触发的闪白、震屏、故障效果- 文字:原创动态字幕(不使用歌词原文),中文大字排版跟着节拍弹出---## 3. 分镜大纲(约 144 秒)| 时间 | 场景 | 内容 ||------|------|------|| 0 – 9s | **S1 开场·霓虹点亮** | 黑屏和雨 → 「黑街」霓虹灯管一笔一笔闪烁点亮 || 9 – 24s | **S2 雨夜长街** | 横向视差街景,夜行者走过,招牌闪烁,积水倒影 || 24 – 38.2s | **S3 蓄力·隧道** | 透视隧道灯条加速逼近,字幕倒数,能量上升 || 38.2 – 56s | **S4 Drop1·霓虹爆裂** | 快切:大字排版 + 频闪 + 城市天际线随低音跳动 || 56 – 73s | **S5 天台·红月** | 巨大红月、探照灯扫射、剪影站在天台边缘,鼓点震屏 || 73 – 92s | **S6 葱姜蒜夜市** | 暖色灯笼、蒸汽、摊位招牌,镜头缓推(呼吸段落) || 92 – 109.4s | **S7 暗场·心跳** | 近乎全黑,只剩一束光和红色心跳线,逐渐加速 || 109.4 – 128s | **S8 Drop2·飙车光轨** | 透视公路,车灯拉出光轨,楼体高速后退 || 128 – 144.4s | **S9 终章·黑街之王** | 霓虹光点汇聚成标题,片尾署名,硬切黑 |所有场景同时适配 16:9 和 9:16(按画布宽高比重新排版,不是简单裁切)。14 unmodified lines├── App.tsx # 页面:播放器 / 导出 / 文案 / 封面├── styles.css├── engine/│ ├── audioData.ts # 预计算的音频特征(60Hz)+ 节拍网格│ ├── timeline.ts # 分镜时间轴、场景切换、转场│ ├── scenes.ts # 各场景的绘制函数 draw(ctx, W, H, t, audio)67 unmodified linesnpm run dev # 开发npm run build && npm start # 生产(http://localhost:3000)```32 unmodified lines3334353637383939 unmodified lines79808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412514 unmodified lines14014114214314414514667 unmodified lines21421521621732 unmodified lines| 5 | 适配**手机竖屏** | 横屏 16:9 / 竖屏 9:16 两套构图;所有场景按画布宽高自适应排版;手机端默认竖屏 || 6 | 导出帧率 **24 / 30 / 60** 可选 | 在导出面板中单选;第 i 帧的时间 = i / fps,保证和音频严格对齐 || 7 | 可复制的**标题、描述、标签** | 小红书 / 抖音 / 微信视频号 / 哔哩哔哩 四套文案,带字数和话题数校验,一键复制 || 8 | **封面**:4:3、3:4、16:9,每种比例多张,可多选 | 用 MV 关键帧渲染并叠加封面排版,每种比例 8 款设计,可勾选多张批量下载 PNG |### 平台文案约束39 unmodified lines- 主色:墨黑 `#07080c`、藏青 `#0f1d2b`、钠灯橙 `#ffb35c`、霓虹红 `#ff2d55`、冷青 `#3de0ff`- 元素:雨丝、积水倒影、霓虹招牌(中文字)、楼宇剪影、卷帘门、电线杆、雾气、探照灯、车灯光轨- 主角:~~穿连帽衫的剪影「夜行者」~~ → v2 改为参考视频里的卷发少年「阿飞」和他的黑色摩托(见 2.5)- 质感:WebGL 后期 → 辉光 + RGB 色差 + 胶片颗粒 + 扫描线 + 暗角,加上底鼓触发的闪白、震屏、故障效果- 文字:原创动态字幕(不使用歌词原文),中文大字排版跟着节拍弹出### 2.5 主角重绘:卷发少年「阿飞」(v2 新增)参考视频(`41920891009-1-192.mp4`)里有一个贯穿全片的主角,新 MV 把他重新画出来作为主角。**怎么"看"出主角的:**1. 每 3 秒抽一帧(视频 A,54 张),每 10 秒抽一帧(视频 B,65 张,隔一张取一张)2. 用本地图像识别模型 Florence-2 逐帧生成详细描述;视频 A 中几十帧描述都指向同一个人:*年轻男生、黑色卷发、蓝色毛衣、黑/灰色裤子、骑一辆黑色摩托(圆形车头灯、两个圆形后视镜、红色尾灯)*,表情多为闭眼、忧伤3. 用「短语定位 + 分割」框出人物和头发,在人物轮廓内测量真实颜色:头发 `#101310`,皮肤 `#b0a088`–`#dbc39c`,毛衣 `#2e3b42`(夜景下);头发框占人物框高度的 35–45%(大头、蓬松卷发、Q 版比例)4. 参考里的典型桥段:雨夜砖墙小巷与路灯、推着摩托站在街上、篝火与啤酒、日落山路、夜间高速与大货车、读信后把信烧掉、星空大树下、夜里驶过的火车**重绘的角色设定(`src/mv/engine/hero.ts`,全部程序化绘制):**| 部位 | 设定 ||------|------|| 头发 | 黑色蓬松大卷发(几十个卷团 + 每个卷团上的高光弧线),风速越大越往后飘 || 脸 | 暖米色皮肤,常闭眼、粗眉、略带忧伤;特写可睁眼、浅笑、落泪 || 衣服 | 深蓝色长袖毛衣(罗纹领口和下摆),灰色长裤,黑色运动鞋白鞋底 || 摩托 | 黑色复古摩托:圆形车头灯(带光束)、两个圆后视镜、水滴油箱、镀铬排气管、辐条轮、红色尾灯 || 画法 | 侧面走路(可推车)、背影、侧面骑车、后视角骑车、坐地读信 / 烧信、正面特写,共 6 种画法 |**校验:** 把渲染出来的画面再交给同一个识别模型描述,得到例如 *"一个穿蓝色上衣、卷发的人骑着黑色摩托,背后是巨大的红色太阳"*、*"一个人坐在摩托旁,手里拿着火光"*、*"头发是蓬松卷发、闭着眼、表情忧伤"*,和参考视频主角的描述一致。---## 3. 分镜大纲(约 144 秒)| 时间 | 场景 | 内容 ||------|------|------|| 0 – 9s | **S1 开场·霓虹与摩托** | 雨夜路灯下停着他的黑色摩托 →「黑街」霓虹灯管逐笔点亮,摩托车头灯随之亮起 || 9 – 24s | **S2 雨夜·推车少年** | 阿飞推着摩托走过霓虹长街,积水倒影,招牌闪烁 || 24 – 38.2s | **S3 蓄力·隧道** | 阿飞骑车冲进隧道(后视角),卷发被风吹起,倒数 3·2·1 || 38.2 – 56s | **S4 Drop1·霓虹爆裂** | 海报大字 / 均衡器天际线 / 阿飞侧面飙车 / 霓虹格子,按小节快切 || 56 – 73s | **S5 山顶·红月** | 阿飞坐在摩托上望着巨大红月 → 脸部特写(睁眼、浅笑)→ 山下城市灯海 || 73 – 91s | **S6 葱姜蒜夜市** | 暖色灯笼、蒸汽、葱姜蒜摊位,阿飞从镜头前走过 || 91 – 109.4s | **S7 灯下·烧掉的信** | 路灯下,阿飞坐在摩托旁读信 → 闭眼落泪特写 → 把信烧掉,心跳加速 || 109.4 – 128s | **S8 Drop2·公路之王** | 夜间高速,大货车并行,阿飞后视角 / 侧面狂飙 || 128 – 144.4s | **S9 终章·星空与火车** | 大树、星空、弯月、远处驶过的红黄火车,阿飞坐在车上看着 → 光点汇聚成「黑街」 |所有场景同时适配 16:9 和 9:16(按画布宽高比重新排版,不是简单裁切)。14 unmodified lines├── App.tsx # 页面:播放器 / 导出 / 文案 / 封面├── styles.css├── engine/│ ├── hero.ts # 主角「阿飞」与他的摩托(6 种画法)│ ├── audioData.ts # 预计算的音频特征(60Hz)+ 节拍网格│ ├── timeline.ts # 分镜时间轴、场景切换、转场│ ├── scenes.ts # 各场景的绘制函数 draw(ctx, W, H, t, audio)67 unmodified linesnpm run dev # 开发npm run build && npm start # 生产(http://localhost:3000)```- **步骤 7(v2:主角重绘)** ✅ 按要求把参考视频里的主角画出来做新主角:用本地识别模型 Florence-2 描述 119 张截图、定位并分割人物、测量发色 / 肤色 / 衣服颜色和头身比例,新建 `hero.ts` 绘制卷发蓝毛衣少年「阿飞」和他的黑色复古摩托(6 种画法);9 个场景全部改成以他为主角的情节(雨夜推车、隧道骑行、红月山顶特写、灯下读信烧信、货车并行的公路、星空大树与火车);新增「阿飞特写」「灯下烧信」两款封面(每种比例 8 款,共 24 张);文案同步加入主角。再用识别模型回看渲染画面,确认能被描述为「蓝衣卷发少年骑黑色摩托」。全时间轴横竖屏逐 0.5 秒扫描无报错。
123version https://git-lfs.github.com/spec/v1oid sha256:895334bcaeee0efd157751e8c362450708a2acc4b62abe2191d0dcf813b6352fsize 101332123version https://git-lfs.github.com/spec/v1oid sha256:a3fa76be4b851fc0b7bd9e508e237a0b705ed8ed9325460e268591c745887db5size 104752
4 unmodified lines56789101157 unmodified lines697071727374751 unmodified line7778798081824 unmodified linesimport { Renderer } from './engine/renderer'import { SCENES, sceneAt } from './engine/timeline'import { AUDIO_URL, loadFonts } from './fonts'import { exportMp4, webCodecsSupported, type ExportResult } from './export/exportMp4'import { DESIGNS, RATIOS, RATIO_SIZE, renderCover, type CoverItem, type Ratio } from './covers/covers'import { PLATFORMS, countChars, formatTags } from './copy/platforms'57 unmodified lines// debug / QA hook: render a single frame offscreen;(window as unknown as { __mvSnap: unknown }).__mvSnap = async (t: number, w: number, h: number) => {await loadFonts()const r = new Renderer()r.setSize(w, h)const t0 = performance.now()r.render(t)1 unmodified linereturn { url: r.out.toDataURL('image/jpeg', 0.85), ms, webgl: r.webgl }};(window as unknown as { __mvExport: unknown }).__mvExport = exportMp4}, [])return (<div className="mv-root">4 unmodified lines56789101157 unmodified lines697071727374751 unmodified line77787980818283848586878889909192939495969798991004 unmodified linesimport { Renderer } from './engine/renderer'import { SCENES, sceneAt } from './engine/timeline'import { AUDIO_URL, loadFonts } from './fonts'import { exportMp4, exportRenderer, webCodecsSupported, type ExportResult } from './export/exportMp4'import { DESIGNS, RATIOS, RATIO_SIZE, renderCover, type CoverItem, type Ratio } from './covers/covers'import { PLATFORMS, countChars, formatTags } from './copy/platforms'57 unmodified lines// debug / QA hook: render a single frame offscreen;(window as unknown as { __mvSnap: unknown }).__mvSnap = async (t: number, w: number, h: number) => {await loadFonts()const r = exportRenderer()r.setSize(w, h)const t0 = performance.now()r.render(t)1 unmodified linereturn { url: r.out.toDataURL('image/jpeg', 0.85), ms, webgl: r.webgl }};(window as unknown as { __mvExport: unknown }).__mvExport = exportMp4;(window as unknown as { __mvSheet: unknown }).__mvSheet = async (which: string, w: number, h: number) => {const H = await import('./engine/hero')const c = document.createElement('canvas')c.width = wc.height = hconst g = c.getContext('2d')!g.fillStyle = '#8a96a6'g.fillRect(0, 0, w, h)const s = Math.min(w, h)if (which === 'walk') H.heroWalk(g, w / 2, h * 0.95, h * 0.9, 0.2, { t: 1 })if (which === 'back') H.heroBack(g, w / 2, h * 0.95, h * 0.9, 0, { t: 1 })if (which === 'bike') H.bike(g, w / 2, h * 0.9, s * 0.8, { t: 1 })if (which === 'ride') H.heroRide(g, w / 2, h * 0.92, s * 0.75, { t: 1, smile: true })if (which === 'rear') H.heroRideRear(g, w / 2, h * 0.98, h * 0.95, 0, 1)if (which === 'sit') H.heroSit(g, w / 2, h * 0.95, h * 0.9, 1, { fire: 1 })if (which === 'face') H.heroPortrait(g, w / 2, h * 0.42, h * 0.22, { t: 1, tear: 0.5 })return c.toDataURL('image/png')}}, [])return (<div className="mv-root">
20 unmodified lines212223242526272829307 unmodified lines3839404142434445463 unmodified lines50515253545556575859605 unmodified lines66676869707172737475767778798081828384858687888920 unmodified linestitleLimit: 20,tagLimit: 10,tagStyle: 'hash',titles: ['把《黑街》做成了雨夜霓虹MV🌃', '105BPM卡点|黑街雨夜动画', '听到Drop那一秒,整条街都亮了'],desc:'用代码一帧一帧画出来的《黑街》MV🎧\n' +'雨夜长街、红月天台、葱姜蒜夜市、飙车光轨……\n' +'两次 Drop 全程卡点,建议戴耳机、调大音量🔊\n\n' +'🎵 音乐:DJ鐘董《黑街(DJ葱姜蒜进行曲)》\n' +'你最喜欢哪一个镜头?评论区告诉我👇',7 unmodified linestitleLimit: 30,tagLimit: 5,tagStyle: 'hash',titles: ['凌晨两点的黑街,霓虹替我记住每一条路', '等到38秒,整条黑街一起炸开🔥', '《黑街》全程卡点,第二次Drop直接上头'],desc: '原创程序化动画 × DJ鐘董《黑街》\n雨夜、霓虹、红月、飙车,一条街走到尽头。\n戴上耳机,等那一声重低音。',tags: ['黑街', 'DJ葱姜蒜进行曲', '卡点', '霓虹夜景', '原创MV'],tip: '标题 ≤ 30 字,话题 ≤ 5 个',},{3 unmodified linestitleLimit: 16,tagLimit: null,tagStyle: 'hash',titles: ['雨夜黑街,霓虹不打烊', '这条街,从不问来处', '黑街:一首歌走完一座城'],desc:'用代码画出的一支 MV:雨夜长街、红月天台、葱姜蒜夜市、飙车光轨。\n' +'音乐来自 DJ鐘董《黑街(DJ葱姜蒜进行曲)》,建议戴耳机观看。',tags: ['黑街', 'DJ葱姜蒜进行曲', 'DJ鐘董', '原创MV', '音乐可视化', '霓虹', '夜景', '雨夜', '赛博朋克', '动画', '卡点', '氛围感', '城市夜色'],tip: '标题 ≤ 16 字,话题不限',},{5 unmodified linestagStyle: 'comma',titles: ['【原创MV】《黑街》DJ葱姜蒜进行曲|纯代码绘制的雨夜霓虹动画,两次Drop全程卡点,支持竖屏观看','【程序化动画】把《黑街》画成一座城:雨夜长街→红月天台→葱姜蒜夜市→飙车光轨','105.5BPM卡点!用浏览器实时渲染一支《黑街》MV,每一帧都是代码画的',],desc:'🎵 音乐:DJ鐘董《黑街(DJ葱姜蒜进行曲)》\n' +'🎨 画面:原创程序化动画,浏览器 Canvas + WebGL 实时渲染,没有任何实拍素材\n\n' +'⏱ 分镜\n' +'00:00 开场·霓虹点亮\n' +'00:09 雨夜长街\n' +'00:23 蓄力·隧道\n' +'00:38 Drop1·霓虹爆裂\n' +'00:56 天台·红月\n' +'01:12 葱姜蒜夜市\n' +'01:31 暗场·心跳\n' +'01:49 Drop2·飙车光轨\n' +'02:07 终章·黑街之王\n\n' +'喜欢的话一键三连,弹幕告诉我你最喜欢哪个镜头!',tags: ['黑街', 'DJ葱姜蒜进行曲', '原创MV', '音乐可视化', '程序化动画', '霓虹', '赛博朋克', '卡点', '动画短片', '创意视频'],tip: '标题 ≤ 80 字,标签 ≤ 10 个',},]20 unmodified lines212223242526272829307 unmodified lines3839404142434445463 unmodified lines50515253545556575859605 unmodified lines66676869707172737475767778798081828384858687888920 unmodified linestitleLimit: 20,tagLimit: 10,tagStyle: 'hash',titles: ['卷发少年的黑街摩托夜🏍️', '把《黑街》做成了雨夜霓虹MV🌃', '105BPM卡点|黑街雨夜动画', '听到Drop那一秒,整条街都亮了'],desc:'用代码一帧一帧画出来的《黑街》MV🎧\n' +'蓝毛衣卷发少年阿飞,和他的黑色摩托:雨夜推车、红月山顶、灯下烧信、公路狂飙……\n' +'两次 Drop 全程卡点,建议戴耳机、调大音量🔊\n\n' +'🎵 音乐:DJ鐘董《黑街(DJ葱姜蒜进行曲)》\n' +'你最喜欢哪一个镜头?评论区告诉我👇',7 unmodified linestitleLimit: 30,tagLimit: 5,tagStyle: 'hash',titles: ['卷发少年和他的黑摩托,开成了公路之王', '凌晨两点的黑街,霓虹替我记住每一条路', '等到38秒,整条黑街一起炸开🔥', '《黑街》全程卡点,第二次Drop直接上头'],desc: '原创程序化动画 × DJ鐘董《黑街》\n卷发少年阿飞和他的黑色摩托,雨夜、红月、烧掉的信、公路之王。\n戴上耳机,等那一声重低音。',tags: ['黑街', 'DJ葱姜蒜进行曲', '公路之王', '卡点', '原创MV'],tip: '标题 ≤ 30 字,话题 ≤ 5 个',},{3 unmodified linestitleLimit: 16,tagLimit: null,tagStyle: 'hash',titles: ['少年与摩托,雨夜黑街', '雨夜黑街,霓虹不打烊', '这条街,从不问来处', '黑街:一首歌走完一座城'],desc:'用代码画出的一支 MV:卷发少年阿飞骑着黑色摩托,穿过雨夜、红月山顶、葱姜蒜夜市,一路开成公路之王。\n' +'音乐来自 DJ鐘董《黑街(DJ葱姜蒜进行曲)》,建议戴耳机观看。',tags: ['黑街', 'DJ葱姜蒜进行曲', 'DJ鐘董', '原创MV', '音乐可视化', '霓虹', '夜景', '雨夜', '赛博朋克', '动画', '卡点', '氛围感', '城市夜色', '公路之王', '摩托少年'],tip: '标题 ≤ 16 字,话题不限',},{5 unmodified linestagStyle: 'comma',titles: ['【原创MV】《黑街》DJ葱姜蒜进行曲|纯代码绘制的雨夜霓虹动画,两次Drop全程卡点,支持竖屏观看','【程序化动画】卷发少年和他的摩托:雨夜推车→红月山顶→灯下烧信→公路之王','105.5BPM卡点!用浏览器实时渲染一支《黑街》MV,每一帧都是代码画的',],desc:'🎵 音乐:DJ鐘董《黑街(DJ葱姜蒜进行曲)》\n' +'🎨 画面:原创程序化动画,浏览器 Canvas + WebGL 实时渲染;主角「阿飞」按参考视频里的蓝毛衣卷发少年重新绘制\n\n' +'⏱ 分镜\n' +'00:00 开场·霓虹与摩托\n' +'00:09 雨夜·推车少年\n' +'00:23 蓄力·隧道\n' +'00:38 Drop1·霓虹爆裂\n' +'00:56 山顶·红月\n' +'01:12 葱姜蒜夜市\n' +'01:31 灯下·烧掉的信\n' +'01:49 Drop2·公路之王\n' +'02:07 终章·星空与火车\n\n' +'喜欢的话一键三连,弹幕告诉我你最喜欢哪个镜头!',tags: ['黑街', 'DJ葱姜蒜进行曲', '原创MV', '公路之王', '程序化动画', '摩托', '霓虹', '卡点', '动画短片', '音乐可视化'],tip: '标题 ≤ 80 字,标签 ≤ 10 个',},]
81 unmodified lines82838485868788899 unmodified lines991001011021031041054 unmodified lines11011111211311411581 unmodified lines},{id: 'street',name: '雨夜长街',t: 15.2,overlay(ctx, W, H) {const u = S(W, H)const P = H > W9 unmodified lines},{id: 'moon',name: '红月天台',t: 60.6,overlay(ctx, W, H) {const u = S(W, H)4 unmodified linestextBlock(ctx, '城市睡了,红月醒着', P ? W / 2 : W * 0.62, H - u * 110, u * 56, FONT.black, PALETTE.bone, { stroke: 'rgba(0,0,0,0.7)' })},},{id: 'market',name: '葱姜蒜夜市',81 unmodified lines82838485868788899 unmodified lines991001011021031041054 unmodified lines11011111211311411511611711811912012112212312412512612712812913013113213313413513613781 unmodified lines},{id: 'street',name: '雨夜推车',t: 13.2,overlay(ctx, W, H) {const u = S(W, H)const P = H > W9 unmodified lines},{id: 'moon',name: '红月山顶',t: 60.6,overlay(ctx, W, H) {const u = S(W, H)4 unmodified linestextBlock(ctx, '城市睡了,红月醒着', P ? W / 2 : W * 0.62, H - u * 110, u * 56, FONT.black, PALETTE.bone, { stroke: 'rgba(0,0,0,0.7)' })},},{id: 'hero',name: '阿飞特写',t: 65.6,overlay(ctx, W, H) {const u = S(W, H)const P = H > Wbadge(ctx, '主角 · 阿飞', u * 50, u * 50, u * 38, PALETTE.red, '#fff')textBlock(ctx, '黑街', P ? W / 2 : W * 0.8, P ? H * 0.12 : H * 0.3, P ? W * 0.2 : H * 0.2, FONT.black, '#fff', { shadow: PALETTE.red })textBlock(ctx, '卷发少年和他的黑摩托', P ? W / 2 : W * 0.8, P ? H * 0.9 : H * 0.48, u * 50, FONT.black, PALETTE.bone, { stroke: 'rgba(0,0,0,0.7)' })},},{id: 'letter',name: '灯下烧信',t: 104.2,overlay(ctx, W, H) {const u = S(W, H)textBlock(ctx, '烧掉它,再出发', W / 2, u * 120, u * 72, FONT.black, '#fff', { shadow: '#ff7a2e' })textBlock(ctx, '黑街 BLACK STREET', W / 2, H - u * 90, u * 44, FONT.black, PALETTE.bone)},},{id: 'market',name: '葱姜蒜夜市',
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959// 主角「阿飞」— redrawn from the protagonist of the reference footage:// a young man with a big mop of curly black hair, a deep-blue long-sleeve// sweater, grey trousers, and his black classic motorcycle (round headlight,// two round mirrors, red tail light). Mood: quiet, melancholic, eyes often closed.import { glowBlob, lightCone } from './draw'import { hash, rgba } from './util'
type C2D = CanvasRenderingContext2D
export const HERO = { skin: '#e6caa2', skinShade: '#b9997a', blush: '#e89a86', hair: '#121411', hairHi: '#41556b', sweater: '#2f4b66', sweaterShade: '#213649', sweaterHi: '#44698c', rib: '#273f57', pants: '#8c9196', pantsShade: '#646a70', shoe: '#1b1b1d', sole: '#dcd6cb', bike: '#121419', bikeHi: '#3a4250', chrome: '#c3cad2', seat: '#201b18', tire: '#09090a',}
// ------------------------------------------------------------------ hair/** Curly mop: a deterministic cluster of curls around the top/back of a head. */function curls(ctx: C2D, cx: number, cy: number, r: number, facing: number, wind: number, t: number, front = false) { const n = front ? 30 : 32 const pts: { x: number; y: number; r: number }[] = [] for (let i = 0; i < n; i++) { let a: number if (front) a = Math.PI * 0.9 + (i / (n - 1)) * Math.PI * 1.2 // left → over the top → right else a = -Math.PI / 2 - facing * (-0.85 + (i / (n - 1)) * 3.05) // forehead → crown → down to the nape const k = 1.02 + 0.14 * hash(i * 3.7) const wob = Math.sin(t * 9 + i * 1.7) * wind * 0.05 const back = -facing * wind * r * (0.2 + 0.4 * (1 - Math.abs(Math.sin(a)))) pts.push({ x: cx + Math.cos(a) * r * k + (front ? 0 : back) + wob * r, y: cy + Math.sin(a) * r * k * (front ? 0.95 : 1) + wob * r * 0.5, r: r * (0.34 + 0.16 * hash(i * 1.3)), }) } // a second, inner row of curls for volume const inner = front ? 12 : 10 for (let i = 0; i < inner; i++) { const a = front ? Math.PI * 1.05 + (i / (inner - 1)) * Math.PI * 0.9 : -Math.PI / 2 - facing * (-0.3 + (i / (inner - 1)) * 1.9) pts.push({ x: cx + Math.cos(a) * r * 0.62 - (front ? 0 : facing * wind * r * 0.2), y: cy + Math.sin(a) * r * 0.62 - r * 0.05, r: r * (0.3 + 0.12 * hash(i * 7.9)) }) } ctx.fillStyle = HERO.hair ctx.beginPath() for (const p of pts) { ctx.moveTo(p.x + p.r, p.y) ctx.arc(p.x, p.y, p.r, 0, Math.PI * 2) } // fill the crown (top & back only, the face stays visible) if (front) { ctx.moveTo(cx + r * 0.95, cy - r * 0.5) ctx.ellipse(cx, cy - r * 0.5, r * 0.95, r * 0.5, 0, 0, Math.PI * 2) } else { const ccx = cx - facing * r * (0.22 + wind * 0.12) ctx.moveTo(ccx + r * 0.8, cy - r * 0.3) ctx.ellipse(ccx, cy - r * 0.3, r * 0.8, r * 0.62, 0, 0, Math.PI * 2) // back of the skull, down to the nape const bx = cx - facing * r * (0.45 + wind * 0.15) ctx.moveTo(bx + r * 0.62, cy + r * 0.1) ctx.ellipse(bx, cy + r * 0.1, r * 0.62, r * 0.8, 0, 0, Math.PI * 2) } ctx.fill() // curl texture: a highlight crescent on every curl ctx.strokeStyle = HERO.hairHi ctx.lineWidth = Math.max(1, r * 0.075) ctx.lineCap = 'round' ctx.beginPath() for (const p of pts) { const rr = p.r * 0.62 ctx.moveTo(p.x + rr * Math.cos(-2.6), p.y + rr * Math.sin(-2.6)) ctx.arc(p.x, p.y, rr, -2.6, -0.5) } ctx.stroke()}
/** Side-view head with curly hair. facing 1 = looking right. */export function heroHead(ctx: C2D, cx: number, cy: number, r: number, facing: number, o: { wind?: number; t?: number; eyes?: 'closed' | 'open'; smile?: boolean; rim?: string } = {}) { const t = o.t ?? 0 const wind = o.wind ?? 0 // neck ctx.fillStyle = HERO.skinShade ctx.fillRect(cx - r * 0.22, cy + r * 0.7, r * 0.44, r * 0.5) // face / skull ctx.fillStyle = HERO.skin ctx.beginPath() ctx.ellipse(cx + facing * r * 0.06, cy + r * 0.05, r * 0.86, r * 0.92, 0, 0, Math.PI * 2) ctx.fill() // nose & chin profile ctx.beginPath() ctx.moveTo(cx + facing * r * 0.84, cy - r * 0.02) ctx.quadraticCurveTo(cx + facing * r * 1.04, cy + r * 0.16, cx + facing * r * 0.84, cy + r * 0.24) ctx.lineTo(cx + facing * r * 0.7, cy + r * 0.62) ctx.lineTo(cx + facing * r * 0.3, cy + r * 0.86) ctx.lineTo(cx, cy + r * 0.5) ctx.closePath() ctx.fill() // ear ctx.fillStyle = HERO.skinShade ctx.beginPath() ctx.ellipse(cx - facing * r * 0.12, cy + r * 0.12, r * 0.14, r * 0.2, 0, 0, Math.PI * 2) ctx.fill() // eye ctx.strokeStyle = '#2a1d17' ctx.lineWidth = Math.max(1, r * 0.07) ctx.lineCap = 'round' ctx.beginPath() const ex = cx + facing * r * 0.5 const ey = cy + r * 0.02 if ((o.eyes ?? 'closed') === 'closed') { ctx.arc(ex, ey - r * 0.05, r * 0.14, Math.PI * 0.15, Math.PI * 0.85) } else { ctx.moveTo(ex, ey) ctx.arc(ex, ey, r * 0.06, 0, Math.PI * 2) } ctx.stroke() // sad brow ctx.beginPath() ctx.moveTo(ex - facing * r * 0.16, ey - r * 0.2) ctx.lineTo(ex + facing * r * 0.14, ey - r * 0.26) ctx.stroke() // mouth ctx.beginPath() if (o.smile) ctx.arc(cx + facing * r * 0.62, cy + r * 0.44, r * 0.1, 0.2, Math.PI - 0.2) else { ctx.moveTo(cx + facing * r * 0.56, cy + r * 0.5) ctx.lineTo(cx + facing * r * 0.7, cy + r * 0.48) } ctx.stroke() // blush ctx.fillStyle = rgba(HERO.blush, 0.35) ctx.beginPath() ctx.ellipse(cx + facing * r * 0.4, cy + r * 0.3, r * 0.14, r * 0.08, 0, 0, Math.PI * 2) ctx.fill() curls(ctx, cx - facing * r * 0.05, cy - r * 0.12, r, facing, wind, t) if (o.rim) { ctx.strokeStyle = o.rim ctx.lineWidth = Math.max(1, r * 0.08) ctx.beginPath() ctx.arc(cx - facing * r * 0.05, cy - r * 0.2, r * 1.18, facing > 0 ? Math.PI * 1.05 : -0.45, facing > 0 ? Math.PI * 1.45 : -0.05) ctx.stroke() }}
// ------------------------------------------------------------------ walkingexport interface HeroWalkOpts { facing?: number run?: number rim?: string t?: number /** hand reaching forward (e.g. pushing the bike) */ reach?: number eyes?: 'closed' | 'open'}
/** Side-view walking hero. (x,y) = feet on ground, h = total height. */export function heroWalk(ctx: C2D, x: number, y: number, h: number, phase: number, o: HeroWalkOpts = {}) { const f = o.facing ?? 1 const run = o.run ?? 0 const t = o.t ?? 0 const P = Math.PI * 2 const bob = Math.abs(Math.sin(phase * P * 2)) * h * (0.012 + run * 0.02) const hipY = y - h * 0.4 - bob const lean = 0.04 + run * 0.22 const shX = x + Math.sin(lean) * h * 0.24 * f const shY = hipY - h * 0.25 const L1 = h * 0.2 const L2 = h * 0.19 ctx.lineCap = 'round' ctx.lineJoin = 'round' const leg = (ph: number, col: string, shoe: string) => { const s = Math.sin(ph * P) const th = s * (0.42 + run * 0.45) const knee = Math.max(0, Math.cos(ph * P)) * (0.35 + run * 1.1) + 0.06 const kx = x + Math.sin(th) * L1 * f const ky = hipY + Math.cos(th) * L1 const sa = th - knee const fx = kx + Math.sin(sa) * L2 * f const fy = ky + Math.cos(sa) * L2 ctx.strokeStyle = col ctx.lineWidth = h * 0.085 ctx.beginPath() ctx.moveTo(x, hipY) ctx.lineTo(kx, ky) ctx.lineTo(fx, fy) ctx.stroke() // sneaker ctx.fillStyle = shoe ctx.beginPath() ctx.ellipse(fx + h * 0.03 * f, fy + h * 0.005, h * 0.055, h * 0.026, 0, 0, Math.PI * 2) ctx.fill() ctx.fillStyle = HERO.sole ctx.fillRect(fx - h * 0.02, fy + h * 0.016, h * 0.1 * f, h * 0.012) } const arm = (ph: number, col: string, reach = 0) => { const s = Math.sin(ph * P) const a = reach > 0 ? 1.2 * reach : -s * (0.45 + run * 0.7) const elbow = reach > 0 ? 0.25 : 0.25 + run * 1.2 const ex = shX + Math.sin(a) * h * 0.14 * f const ey = shY + h * 0.02 + Math.cos(a) * h * 0.14 const hx = ex + Math.sin(a + elbow) * h * 0.13 * f const hy = ey + Math.cos(a + elbow) * h * 0.13 ctx.strokeStyle = col ctx.lineWidth = h * 0.07 ctx.beginPath() ctx.moveTo(shX, shY + h * 0.02) ctx.lineTo(ex, ey) ctx.lineTo(hx, hy) ctx.stroke() ctx.fillStyle = HERO.skin ctx.beginPath() ctx.arc(hx, hy, h * 0.028, 0, Math.PI * 2) ctx.fill() } leg(phase + 0.5, HERO.pantsShade, HERO.shoe) arm(phase, HERO.sweaterShade) // torso (sweater) ctx.fillStyle = HERO.sweater ctx.beginPath() const tw = h * 0.085 ctx.moveTo(x - tw * f, hipY + h * 0.03) ctx.quadraticCurveTo(x - tw * 1.25 * f, (hipY + shY) / 2, shX - tw * 1.3 * f, shY) ctx.lineTo(shX + tw * 1.15 * f, shY + h * 0.01) ctx.quadraticCurveTo(x + tw * 1.35 * f, (hipY + shY) / 2, x + tw * 1.0 * f, hipY + h * 0.035) ctx.closePath() ctx.fill() // ribbed hem ctx.fillStyle = HERO.rib ctx.fillRect(Math.min(x - tw * f, x + tw * 1.05 * f), hipY + h * 0.005, tw * 2.05, h * 0.03) // back shading ctx.fillStyle = rgba(HERO.sweaterShade, 0.8) ctx.beginPath() ctx.moveTo(x - tw * f, hipY + h * 0.03) ctx.quadraticCurveTo(x - tw * 1.2 * f, (hipY + shY) / 2, shX - tw * 1.05 * f, shY) ctx.lineTo(shX - tw * 0.6 * f, shY) ctx.quadraticCurveTo(x - tw * 0.7 * f, (hipY + shY) / 2, x - tw * 0.5 * f, hipY + h * 0.03) ctx.closePath() ctx.fill() leg(phase, HERO.pants, HERO.shoe) // head const r = h * 0.13 heroHead(ctx, shX + h * 0.015 * f, shY - r * 1.05, r, f, { t, wind: run * 0.6 + 0.1, eyes: o.eyes ?? 'closed', rim: o.rim }) arm(phase + 0.5, HERO.sweater, o.reach ?? 0)}
// ------------------------------------------------------------------ back viewexport function heroBack(ctx: C2D, x: number, y: number, h: number, sway = 0, o: { rim?: string; t?: number; wind?: number } = {}) { const sw = sway * h * 0.02 const t = o.t ?? 0 // legs ctx.fillStyle = HERO.pantsShade ctx.fillRect(x - h * 0.085, y - h * 0.4, h * 0.075, h * 0.4) ctx.fillRect(x + h * 0.01, y - h * 0.4, h * 0.075, h * 0.4) ctx.fillStyle = HERO.shoe ctx.fillRect(x - h * 0.095, y - h * 0.03, h * 0.09, h * 0.03) ctx.fillRect(x + h * 0.005, y - h * 0.03, h * 0.09, h * 0.03) // sweater ctx.fillStyle = HERO.sweater ctx.beginPath() ctx.moveTo(x - h * 0.14 + sw, y - h * 0.68) ctx.quadraticCurveTo(x - h * 0.17, y - h * 0.52, x - h * 0.13, y - h * 0.36) ctx.lineTo(x + h * 0.13, y - h * 0.36) ctx.quadraticCurveTo(x + h * 0.17, y - h * 0.52, x + h * 0.14 + sw, y - h * 0.68) ctx.closePath() ctx.fill() ctx.fillStyle = HERO.rib ctx.fillRect(x - h * 0.13, y - h * 0.39, h * 0.26, h * 0.035) // arms ctx.fillStyle = HERO.sweaterShade ctx.fillRect(x - h * 0.19 + sw, y - h * 0.66, h * 0.06, h * 0.3) ctx.fillRect(x + h * 0.13 + sw, y - h * 0.66, h * 0.06, h * 0.3) ctx.fillStyle = HERO.skin ctx.fillRect(x - h * 0.185 + sw, y - h * 0.37, h * 0.05, h * 0.04) ctx.fillRect(x + h * 0.135 + sw, y - h * 0.37, h * 0.05, h * 0.04) // neck + head from behind: mostly hair const r = h * 0.13 const hx = x + sw * 1.2 const hy = y - h * 0.68 - r * 0.95 ctx.fillStyle = HERO.skinShade ctx.fillRect(hx - r * 0.25, hy + r * 0.6, r * 0.5, r * 0.5) ctx.beginPath() ctx.ellipse(hx - r * 0.95, hy + r * 0.15, r * 0.14, r * 0.2, 0, 0, Math.PI * 2) ctx.ellipse(hx + r * 0.95, hy + r * 0.15, r * 0.14, r * 0.2, 0, 0, Math.PI * 2) ctx.fill() backCurls(ctx, hx, hy, r, o.wind ?? 0, t) if (o.rim) { ctx.strokeStyle = o.rim ctx.lineWidth = Math.max(1, h * 0.008) ctx.beginPath() ctx.arc(hx, hy - r * 0.1, r * 1.22, Math.PI * 1.1, Math.PI * 1.9) ctx.moveTo(x - h * 0.15, y - h * 0.66) ctx.lineTo(x - h * 0.17, y - h * 0.5) ctx.moveTo(x + h * 0.15, y - h * 0.66) ctx.lineTo(x + h * 0.17, y - h * 0.5) ctx.stroke() }}
function backCurls(ctx: C2D, hx: number, hy: number, r: number, wind: number, t: number) { const pts: { x: number; y: number; r: number }[] = [] for (let i = 0; i < 28; i++) { const a = (i / 28) * Math.PI * 2 if (Math.sin(a) > 0.8) continue // keep the nape a little open const wob = Math.sin(t * 8 + i) * wind * 0.06 pts.push({ x: hx + Math.cos(a) * r * (1.02 + 0.14 * hash(i)) + wob * r, y: hy - r * 0.05 + Math.sin(a) * r * 0.96 - wind * r * 0.18 * (1 - Math.sin(a)), r: r * (0.34 + 0.16 * hash(i * 2.3)), }) } for (let i = 0; i < 9; i++) { const a = (i / 9) * Math.PI * 2 pts.push({ x: hx + Math.cos(a) * r * 0.5, y: hy - r * 0.1 + Math.sin(a) * r * 0.5, r: r * 0.32 }) } ctx.fillStyle = HERO.hair ctx.beginPath() ctx.moveTo(hx + r, hy) ctx.ellipse(hx, hy - r * 0.05, r * 1.0, r * 0.95, 0, 0, Math.PI * 2) for (const p of pts) { ctx.moveTo(p.x + p.r, p.y) ctx.arc(p.x, p.y, p.r, 0, Math.PI * 2) } ctx.fill() ctx.strokeStyle = HERO.hairHi ctx.lineWidth = Math.max(1, r * 0.075) ctx.lineCap = 'round' ctx.beginPath() for (const p of pts) { const rr = p.r * 0.62 ctx.moveTo(p.x + rr * Math.cos(-2.6), p.y + rr * Math.sin(-2.6)) ctx.arc(p.x, p.y, rr, -2.6, -0.5) } ctx.stroke()}
// ------------------------------------------------------------------ the motorcycleexport interface BikeOpts { facing?: number light?: number spin?: number t?: number beam?: boolean}
/** Side-view black classic motorcycle. (x,y) = ground point under the middle, s = scale (≈ wheelbase). */export function bike(ctx: C2D, x: number, y: number, s: number, o: BikeOpts = {}) { const f = o.facing ?? 1 ctx.save() ctx.translate(x, y) ctx.scale(f, 1) bikeLocal(ctx, s, o) ctx.restore()}
/** bike drawn at origin facing +x (ground at y=0) */function bikeLocal(ctx: C2D, s: number, o: BikeOpts) { const R = s * 0.22 const rx = -s * 0.5 const fx = s * 0.5 const wy = -R const light = o.light ?? 1 const X = (dx: number) => dx * s const Y = (dy: number) => -dy * s if (o.beam && light > 0) lightCone(ctx, X(0.58), Y(0.6), s * 3, 0.16, -Math.PI / 2, '#fff1c8', 0.16 * light) for (const cx of [rx, fx]) { ctx.fillStyle = HERO.tire ctx.beginPath() ctx.arc(cx, wy, R, 0, Math.PI * 2) ctx.fill() ctx.fillStyle = '#1c1f24' ctx.beginPath() ctx.arc(cx, wy, R * 0.62, 0, Math.PI * 2) ctx.fill() // tyre tread highlight ctx.strokeStyle = 'rgba(120,130,145,0.35)' ctx.lineWidth = Math.max(1, s * 0.006) ctx.beginPath() ctx.arc(cx, wy, R * 0.94, Math.PI * 1.1, Math.PI * 1.6) ctx.stroke() ctx.strokeStyle = rgba(HERO.chrome, 0.8) ctx.lineWidth = Math.max(1, s * 0.006) ctx.beginPath() ctx.arc(cx, wy, R * 0.6, 0, Math.PI * 2) const sp = o.spin ?? 0 for (let k = 0; k < 12; k++) { const a = (k / 12) * Math.PI * 2 + sp ctx.moveTo(cx + Math.cos(a) * R * 0.12, wy + Math.sin(a) * R * 0.12) ctx.lineTo(cx + Math.cos(a + 0.3) * R * 0.6, wy + Math.sin(a + 0.3) * R * 0.6) } ctx.stroke() ctx.fillStyle = HERO.chrome ctx.beginPath() ctx.arc(cx, wy, R * 0.12, 0, Math.PI * 2) ctx.fill() } ctx.lineCap = 'round' ctx.lineJoin = 'round' // frame ctx.strokeStyle = HERO.bike ctx.lineWidth = s * 0.05 ctx.beginPath() ctx.moveTo(rx, wy) ctx.lineTo(X(-0.1), Y(0.28)) ctx.lineTo(X(0.32), Y(0.52)) ctx.moveTo(rx, wy) ctx.lineTo(X(-0.28), Y(0.5)) ctx.stroke() // front fork ctx.strokeStyle = HERO.chrome ctx.lineWidth = s * 0.034 ctx.beginPath() ctx.moveTo(fx, wy) ctx.lineTo(X(0.36), Y(0.66)) ctx.stroke() // fenders ctx.strokeStyle = HERO.bike ctx.lineWidth = s * 0.05 ctx.beginPath() ctx.arc(fx, wy, R * 1.12, Math.PI * 1.05, Math.PI * 1.75) ctx.stroke() ctx.beginPath() ctx.arc(rx, wy, R * 1.12, Math.PI * 1.2, Math.PI * 1.9) ctx.stroke() // engine block (big, chunky) + side cover under the seat ctx.fillStyle = '#16181d' ctx.beginPath() ctx.moveTo(X(-0.16), Y(0.46)) ctx.lineTo(X(0.22), Y(0.48)) ctx.lineTo(X(0.24), Y(0.2)) ctx.lineTo(X(-0.12), Y(0.17)) ctx.closePath() ctx.fill() ctx.fillStyle = HERO.bike ctx.fillRect(X(-0.36), Y(0.47), s * 0.2, s * 0.14) ctx.fillStyle = '#2a2f38' ctx.beginPath() ctx.arc(X(0.03), Y(0.27), s * 0.07, 0, Math.PI * 2) ctx.fill() ctx.strokeStyle = HERO.chrome ctx.lineWidth = Math.max(1, s * 0.01) ctx.beginPath() ctx.arc(X(0.03), Y(0.27), s * 0.07, 0, Math.PI * 2) ctx.stroke() ctx.strokeStyle = rgba(HERO.chrome, 0.7) ctx.lineWidth = Math.max(1, s * 0.008) ctx.beginPath() for (let k = 0; k < 5; k++) { ctx.moveTo(X(-0.1), Y(0.4 - k * 0.035)) ctx.lineTo(X(0.16), Y(0.4 - k * 0.035)) } ctx.stroke() // exhaust ctx.strokeStyle = HERO.chrome ctx.lineWidth = s * 0.045 ctx.beginPath() ctx.moveTo(X(0.1), Y(0.24)) ctx.quadraticCurveTo(X(-0.05), Y(0.13), X(-0.62), Y(0.2)) ctx.stroke() // tank (teardrop) ctx.fillStyle = HERO.bike ctx.beginPath() ctx.moveTo(X(-0.1), Y(0.5)) ctx.quadraticCurveTo(X(0.0), Y(0.71), X(0.22), Y(0.68)) ctx.quadraticCurveTo(X(0.4), Y(0.62), X(0.34), Y(0.48)) ctx.quadraticCurveTo(X(0.12), Y(0.42), X(-0.1), Y(0.5)) ctx.fill() ctx.strokeStyle = HERO.bikeHi ctx.lineWidth = Math.max(1, s * 0.012) ctx.beginPath() ctx.moveTo(X(0.0), Y(0.58)) ctx.quadraticCurveTo(X(0.12), Y(0.635), X(0.24), Y(0.6)) ctx.stroke() // seat ctx.fillStyle = HERO.seat ctx.beginPath() ctx.moveTo(X(-0.44), Y(0.5)) ctx.quadraticCurveTo(X(-0.3), Y(0.56), X(-0.06), Y(0.53)) ctx.lineTo(X(-0.06), Y(0.48)) ctx.lineTo(X(-0.44), Y(0.46)) ctx.closePath() ctx.fill() // rear fender & tail light ctx.fillStyle = HERO.bike ctx.beginPath() ctx.moveTo(X(-0.44), Y(0.47)) ctx.lineTo(X(-0.66), Y(0.44)) ctx.lineTo(X(-0.64), Y(0.4)) ctx.lineTo(X(-0.42), Y(0.42)) ctx.closePath() ctx.fill() ctx.fillStyle = '#ff3a5c' ctx.fillRect(X(-0.68), Y(0.455), s * 0.04, s * 0.03) glowBlob(ctx, X(-0.66), Y(0.44), s * 0.12, '#ff2d55', 0.8 * light) // handlebar, mirrors ctx.strokeStyle = HERO.chrome ctx.lineWidth = s * 0.016 ctx.beginPath() ctx.moveTo(X(0.36), Y(0.66)) ctx.lineTo(X(0.3), Y(0.74)) ctx.lineTo(X(0.22), Y(0.75)) ctx.moveTo(X(0.33), Y(0.7)) ctx.lineTo(X(0.3), Y(0.86)) ctx.stroke() ctx.fillStyle = HERO.chrome ctx.beginPath() ctx.ellipse(X(0.3), Y(0.89), s * 0.035, s * 0.028, 0, 0, Math.PI * 2) ctx.fill() ctx.fillStyle = '#5a6a7a' ctx.beginPath() ctx.ellipse(X(0.3), Y(0.89), s * 0.024, s * 0.018, 0, 0, Math.PI * 2) ctx.fill() // round headlight ctx.fillStyle = HERO.chrome ctx.beginPath() ctx.arc(X(0.44), Y(0.62), s * 0.065, 0, Math.PI * 2) ctx.fill() ctx.fillStyle = light > 0.1 ? '#fff6d8' : '#59606a' ctx.beginPath() ctx.arc(X(0.455), Y(0.62), s * 0.05, 0, Math.PI * 2) ctx.fill() if (light > 0.1) glowBlob(ctx, X(0.47), Y(0.62), s * 0.22, '#fff1c8', 0.9 * light)}
// ------------------------------------------------------------------ riding (side)export interface RideOpts { facing?: number wind?: number t?: number spin?: number light?: number beam?: boolean smile?: boolean eyes?: 'closed' | 'open' rim?: string}
/** Hero riding the bike, side view. (x,y) = ground under bike centre, s = bike scale. */export function heroRide(ctx: C2D, x: number, y: number, s: number, o: RideOpts = {}) { ctx.save() ctx.translate(x, y) ctx.scale(o.facing ?? 1, 1) rideLocal(ctx, s, o) ctx.restore()}
function rideLocal(ctx: C2D, s: number, o: RideOpts) { const f = 1 const t = o.t ?? 0 const x = 0 const y = 0 const X = (dx: number) => dx * s const Y = (dy: number) => -dy * s const bounce = Math.sin(t * 13) * s * 0.004 // far arm & leg (shade) ctx.lineCap = 'round' ctx.lineJoin = 'round' ctx.strokeStyle = HERO.pantsShade ctx.lineWidth = s * 0.075 ctx.beginPath() ctx.moveTo(X(-0.24), Y(0.55)) ctx.lineTo(X(0.04), Y(0.56)) ctx.lineTo(X(-0.02), Y(0.3)) ctx.stroke() bikeLocal(ctx, s, { light: o.light, spin: o.spin, beam: o.beam }) // near leg ctx.strokeStyle = HERO.pants ctx.lineWidth = s * 0.08 ctx.beginPath() ctx.moveTo(X(-0.26), Y(0.56) + bounce) ctx.lineTo(X(0.06), Y(0.58) + bounce) ctx.lineTo(X(0.0), Y(0.3)) ctx.stroke() ctx.fillStyle = HERO.shoe ctx.beginPath() ctx.ellipse(X(0.03), Y(0.28), s * 0.055, s * 0.026, 0, 0, Math.PI * 2) ctx.fill() // torso leaning forward const hip = { x: X(-0.24), y: Y(0.6) + bounce } const sh = { x: X(-0.06), y: Y(0.9) + bounce } ctx.fillStyle = HERO.sweater ctx.beginPath() ctx.moveTo(hip.x - s * 0.08 * f, hip.y + s * 0.03) ctx.quadraticCurveTo(hip.x - s * 0.12 * f, (hip.y + sh.y) / 2, sh.x - s * 0.08 * f, sh.y) ctx.lineTo(sh.x + s * 0.08 * f, sh.y + s * 0.02) ctx.quadraticCurveTo(hip.x + s * 0.14 * f, (hip.y + sh.y) / 2 + s * 0.05, hip.x + s * 0.1 * f, hip.y + s * 0.03) ctx.closePath() ctx.fill() ctx.fillStyle = HERO.rib ctx.beginPath() ctx.moveTo(hip.x - s * 0.08 * f, hip.y + s * 0.03) ctx.lineTo(hip.x + s * 0.1 * f, hip.y + s * 0.03) ctx.lineTo(hip.x + s * 0.1 * f, hip.y - s * 0.0) ctx.lineTo(hip.x - s * 0.085 * f, hip.y - s * 0.0) ctx.closePath() ctx.fill() // head const r = s * 0.13 heroHead(ctx, sh.x + s * 0.05 * f, sh.y - r * 1.05, r, f, { t, wind: o.wind ?? 0.6, smile: o.smile, eyes: o.eyes ?? 'open', rim: o.rim }) // near arm to handlebar ctx.strokeStyle = HERO.sweater ctx.lineWidth = s * 0.065 ctx.beginPath() ctx.moveTo(sh.x, sh.y + s * 0.03) ctx.lineTo(X(0.1), Y(0.76) + bounce) ctx.lineTo(X(0.24), Y(0.75)) ctx.stroke() ctx.fillStyle = HERO.skin ctx.beginPath() ctx.arc(X(0.25), Y(0.75), s * 0.028, 0, Math.PI * 2) ctx.fill()}
// ------------------------------------------------------------------ riding (rear view)export function heroRideRear(ctx: C2D, x: number, y: number, s: number, lean: number, t: number, wind = 0.8) { ctx.save() ctx.translate(x, y) ctx.rotate(lean) // tire ctx.fillStyle = HERO.tire ctx.beginPath() ctx.ellipse(0, -s * 0.09, s * 0.07, s * 0.17, 0, 0, Math.PI * 2) ctx.fill() // fender + tail ctx.fillStyle = HERO.bike ctx.beginPath() ctx.moveTo(-s * 0.1, -s * 0.24) ctx.lineTo(s * 0.1, -s * 0.24) ctx.lineTo(s * 0.08, -s * 0.36) ctx.lineTo(-s * 0.08, -s * 0.36) ctx.closePath() ctx.fill() glowBlob(ctx, 0, -s * 0.3, s * 0.14, '#ff2d55', 0.95) ctx.fillStyle = '#ff6a80' ctx.fillRect(-s * 0.055, -s * 0.31, s * 0.11, s * 0.03) ctx.fillStyle = '#e6e2d8' ctx.fillRect(-s * 0.05, -s * 0.27, s * 0.1, s * 0.035) // legs to pegs ctx.fillStyle = HERO.pantsShade ctx.beginPath() ctx.moveTo(-s * 0.16, -s * 0.42) ctx.lineTo(-s * 0.22, -s * 0.2) ctx.lineTo(-s * 0.15, -s * 0.18) ctx.lineTo(-s * 0.08, -s * 0.38) ctx.moveTo(s * 0.16, -s * 0.42) ctx.lineTo(s * 0.22, -s * 0.2) ctx.lineTo(s * 0.15, -s * 0.18) ctx.lineTo(s * 0.08, -s * 0.38) ctx.fill() // seat ctx.fillStyle = HERO.seat ctx.fillRect(-s * 0.12, -s * 0.42, s * 0.24, s * 0.06) // sweater torso ctx.fillStyle = HERO.sweater ctx.beginPath() ctx.moveTo(-s * 0.19, -s * 0.44) ctx.quadraticCurveTo(-s * 0.23, -s * 0.66, -s * 0.12, -s * 0.78) ctx.lineTo(s * 0.12, -s * 0.78) ctx.quadraticCurveTo(s * 0.23, -s * 0.66, s * 0.19, -s * 0.44) ctx.closePath() ctx.fill() ctx.fillStyle = HERO.rib ctx.fillRect(-s * 0.19, -s * 0.47, s * 0.38, s * 0.035) ctx.fillStyle = rgba(HERO.sweaterShade, 0.8) ctx.fillRect(-s * 0.02, -s * 0.76, s * 0.04, s * 0.3) // arms out to bars ctx.strokeStyle = HERO.sweaterShade ctx.lineCap = 'round' ctx.lineWidth = s * 0.055 ctx.beginPath() ctx.moveTo(-s * 0.16, -s * 0.72) ctx.lineTo(-s * 0.3, -s * 0.55) ctx.moveTo(s * 0.16, -s * 0.72) ctx.lineTo(s * 0.3, -s * 0.55) ctx.stroke() ctx.strokeStyle = HERO.chrome ctx.lineWidth = s * 0.014 ctx.beginPath() ctx.moveTo(-s * 0.34, -s * 0.56) ctx.lineTo(s * 0.34, -s * 0.56) ctx.moveTo(-s * 0.3, -s * 0.56) ctx.lineTo(-s * 0.33, -s * 0.66) ctx.moveTo(s * 0.3, -s * 0.56) ctx.lineTo(s * 0.33, -s * 0.66) ctx.stroke() ctx.fillStyle = HERO.chrome ctx.beginPath() ctx.ellipse(-s * 0.335, -s * 0.68, s * 0.03, s * 0.024, 0, 0, Math.PI * 2) ctx.ellipse(s * 0.335, -s * 0.68, s * 0.03, s * 0.024, 0, 0, Math.PI * 2) ctx.fill() // neck + hair mop (blown by the wind) const r = s * 0.11 ctx.fillStyle = HERO.skinShade ctx.fillRect(-r * 0.25, -s * 0.84, r * 0.5, s * 0.07) backCurls(ctx, 0, -s * 0.84 - r * 0.8, r, wind, t) ctx.restore()}
// ------------------------------------------------------------------ sitting with the letterexport function heroSit(ctx: C2D, x: number, y: number, h: number, t: number, o: { facing?: number; letter?: number; fire?: number } = {}) { const f = o.facing ?? 1 const X = (dx: number) => x + dx * h * f const Y = (dy: number) => y - dy * h ctx.lineCap = 'round' ctx.lineJoin = 'round' // legs: knees up ctx.strokeStyle = HERO.pantsShade ctx.lineWidth = h * 0.11 ctx.beginPath() ctx.moveTo(X(-0.05), Y(0.05)) ctx.lineTo(X(0.2), Y(0.3)) ctx.lineTo(X(0.3), Y(0.04)) ctx.stroke() ctx.strokeStyle = HERO.pants ctx.beginPath() ctx.moveTo(X(-0.02), Y(0.06)) ctx.lineTo(X(0.24), Y(0.32)) ctx.lineTo(X(0.36), Y(0.05)) ctx.stroke() ctx.fillStyle = HERO.shoe ctx.beginPath() ctx.ellipse(X(0.4), Y(0.03), h * 0.07, h * 0.035, 0, 0, Math.PI * 2) ctx.fill() // torso hunched ctx.fillStyle = HERO.sweater ctx.beginPath() ctx.moveTo(X(-0.14), Y(0.04)) ctx.quadraticCurveTo(X(-0.2), Y(0.3), X(-0.06), Y(0.5)) ctx.lineTo(X(0.1), Y(0.48)) ctx.quadraticCurveTo(X(0.08), Y(0.25), X(0.06), Y(0.06)) ctx.closePath() ctx.fill() // head bowed toward the letter const r = h * 0.15 heroHead(ctx, X(0.06), Y(0.62), r, f, { t, eyes: 'closed', wind: 0.05 }) // arms holding paper const px = X(0.34) const py = Y(0.42) ctx.strokeStyle = HERO.sweater ctx.lineWidth = h * 0.075 ctx.beginPath() ctx.moveTo(X(0.0), Y(0.45)) ctx.lineTo(X(0.18), Y(0.33)) ctx.lineTo(px - h * 0.03 * f, py + h * 0.03) ctx.stroke() const letter = o.letter ?? 1 if (letter > 0) { ctx.save() ctx.translate(px, py) ctx.rotate(-0.25 * f) ctx.globalAlpha = letter ctx.fillStyle = '#f1e6cf' const lw = h * 0.16 const lh = h * 0.2 * letter ctx.fillRect(-lw / 2, -lh, lw, lh) ctx.fillStyle = 'rgba(80,60,40,0.45)' for (let k = 0; k < 5; k++) ctx.fillRect(-lw * 0.38, -lh + lh * (0.18 + k * 0.15), lw * 0.76 * (k === 4 ? 0.5 : 1), Math.max(1, h * 0.006)) ctx.restore() } ctx.fillStyle = HERO.skin ctx.beginPath() ctx.arc(px - h * 0.02 * f, py + h * 0.02, h * 0.03, 0, Math.PI * 2) ctx.fill() const fire = o.fire ?? 0 if (fire > 0) flame(ctx, px, py - h * 0.2 * letter, h * 0.18 * fire, t)}
export function flame(ctx: C2D, x: number, y: number, size: number, t: number) { glowBlob(ctx, x, y - size * 0.3, size * 3.2, '#ff8a3d', 0.55) const layers: [string, number][] = [ ['#ff4a1c', 1], ['#ff9a2e', 0.72], ['#ffe08a', 0.42], ] for (const [c, k] of layers) { ctx.fillStyle = c ctx.beginPath() const w = size * 0.45 * k const hh = size * 1.3 * k * (0.9 + 0.15 * Math.sin(t * 17 + k * 5)) const sway = Math.sin(t * 11 + k * 3) * size * 0.12 ctx.moveTo(x - w, y) ctx.quadraticCurveTo(x - w * 1.1, y - hh * 0.5, x + sway, y - hh) ctx.quadraticCurveTo(x + w * 1.1, y - hh * 0.5, x + w, y) ctx.quadraticCurveTo(x, y + w * 0.6, x - w, y) ctx.fill() } // embers ctx.fillStyle = '#ffcf7a' for (let i = 0; i < 10; i++) { const life = (t * (0.6 + hash(i) * 0.5) + hash(i * 3.3)) % 1 ctx.globalAlpha = 1 - life ctx.fillRect(x + Math.sin(i * 2.1 + t * 3) * size * 0.6 * life, y - size * (0.6 + life * 2.4), Math.max(1, size * 0.05), Math.max(1, size * 0.05)) } ctx.globalAlpha = 1}
// ------------------------------------------------------------------ front portraitexport interface PortraitOpts { t: number eyes?: number // 0 closed .. 1 open tear?: number wind?: number rim?: string smile?: boolean}
/** Front-facing bust. (cx,cy) = face centre, size = face radius. */export function heroPortrait(ctx: C2D, cx: number, cy: number, size: number, o: PortraitOpts) { const r = size const t = o.t // shoulders / sweater ctx.fillStyle = HERO.sweater ctx.beginPath() ctx.moveTo(cx - r * 2.4, cy + r * 3.2) ctx.quadraticCurveTo(cx - r * 2.2, cy + r * 1.45, cx - r * 0.5, cy + r * 1.3) ctx.lineTo(cx + r * 0.5, cy + r * 1.3) ctx.quadraticCurveTo(cx + r * 2.2, cy + r * 1.45, cx + r * 2.4, cy + r * 3.2) ctx.closePath() ctx.fill() ctx.fillStyle = HERO.sweaterShade ctx.beginPath() ctx.moveTo(cx - r * 2.4, cy + r * 3.2) ctx.quadraticCurveTo(cx - r * 2.2, cy + r * 1.45, cx - r * 1.2, cy + r * 1.35) ctx.quadraticCurveTo(cx - r * 1.6, cy + r * 2.2, cx - r * 1.5, cy + r * 3.2) ctx.closePath() ctx.fill() // neck + ribbed collar ctx.fillStyle = HERO.skinShade ctx.fillRect(cx - r * 0.34, cy + r * 0.7, r * 0.68, r * 0.7) ctx.strokeStyle = HERO.rib ctx.lineWidth = r * 0.16 ctx.beginPath() ctx.ellipse(cx, cy + r * 1.34, r * 0.52, r * 0.16, 0, 0, Math.PI) ctx.stroke() // back hair volume ctx.fillStyle = HERO.hair ctx.beginPath() ctx.ellipse(cx, cy - r * 0.15, r * 1.3, r * 1.18, 0, 0, Math.PI * 2) ctx.fill() // face ctx.fillStyle = HERO.skin ctx.beginPath() ctx.moveTo(cx - r * 0.94, cy - r * 0.2) ctx.lineTo(cx - r * 0.9, cy + r * 0.5) ctx.quadraticCurveTo(cx - r * 0.6, cy + r * 0.95, cx, cy + r * 1.0) ctx.quadraticCurveTo(cx + r * 0.6, cy + r * 0.95, cx + r * 0.9, cy + r * 0.5) ctx.lineTo(cx + r * 0.94, cy - r * 0.2) ctx.quadraticCurveTo(cx, cy - r * 1.05, cx - r * 0.92, cy - r * 0.2) ctx.fill() // ears ctx.beginPath() ctx.ellipse(cx - r * 0.95, cy + r * 0.12, r * 0.15, r * 0.24, 0, 0, Math.PI * 2) ctx.ellipse(cx + r * 0.95, cy + r * 0.12, r * 0.15, r * 0.24, 0, 0, Math.PI * 2) ctx.fill() // cheek shade ctx.fillStyle = rgba(HERO.skinShade, 0.35) ctx.beginPath() ctx.ellipse(cx - r * 0.55, cy + r * 0.55, r * 0.35, r * 0.3, 0.4, 0, Math.PI * 2) ctx.fill() ctx.fillStyle = rgba(HERO.blush, 0.16) ctx.beginPath() ctx.ellipse(cx - r * 0.5, cy + r * 0.35, r * 0.2, r * 0.1, 0, 0, Math.PI * 2) ctx.ellipse(cx + r * 0.5, cy + r * 0.35, r * 0.2, r * 0.1, 0, 0, Math.PI * 2) ctx.fill() // eyes const open = o.eyes ?? 0 ctx.strokeStyle = '#2a1d17' ctx.fillStyle = '#2a1d17' ctx.lineCap = 'round' ctx.lineWidth = Math.max(1, r * 0.06) for (const sd of [-1, 1]) { const ex = cx + sd * r * 0.38 const ey = cy + r * 0.08 ctx.beginPath() if (open < 0.3) { ctx.arc(ex, ey - r * 0.06, r * 0.17, Math.PI * 0.15, Math.PI * 0.85) ctx.stroke() } else { ctx.ellipse(ex, ey, r * 0.1, r * 0.13 * open, 0, 0, Math.PI * 2) ctx.fill() ctx.fillStyle = '#ffffff' ctx.beginPath() ctx.arc(ex + r * 0.035, ey - r * 0.04, r * 0.03, 0, Math.PI * 2) ctx.fill() ctx.fillStyle = '#2a1d17' } // thick, slightly sad brows ctx.save() ctx.lineWidth = Math.max(1.5, r * 0.1) ctx.beginPath() ctx.moveTo(ex - sd * r * 0.18, ey - r * 0.3) ctx.lineTo(ex + sd * r * 0.17, ey - r * 0.25) ctx.stroke() ctx.restore() } // nose + mouth (slightly open) ctx.strokeStyle = rgba(HERO.skinShade, 0.9) ctx.beginPath() ctx.moveTo(cx + r * 0.02, cy + r * 0.25) ctx.lineTo(cx - r * 0.05, cy + r * 0.42) ctx.lineTo(cx + r * 0.04, cy + r * 0.44) ctx.stroke() ctx.fillStyle = '#7a3a34' ctx.beginPath() if (o.smile) { ctx.strokeStyle = '#7a3a34' ctx.arc(cx, cy + r * 0.56, r * 0.14, 0.25, Math.PI - 0.25) ctx.stroke() } else { ctx.strokeStyle = '#6a3530' ctx.lineWidth = Math.max(1, r * 0.05) ctx.moveTo(cx - r * 0.13, cy + r * 0.66) ctx.quadraticCurveTo(cx, cy + r * 0.6, cx + r * 0.13, cy + r * 0.66) ctx.stroke() } // tear const tear = o.tear ?? 0 if (tear > 0) { const ty = cy + r * 0.2 + tear * r * 0.55 ctx.fillStyle = 'rgba(190,230,255,0.9)' ctx.beginPath() ctx.ellipse(cx - r * 0.42, ty, r * 0.05, r * 0.08, 0, 0, Math.PI * 2) ctx.fill() ctx.strokeStyle = 'rgba(190,230,255,0.45)' ctx.lineWidth = Math.max(1, r * 0.03) ctx.beginPath() ctx.moveTo(cx - r * 0.42, cy + r * 0.18) ctx.lineTo(cx - r * 0.42, ty) ctx.stroke() } // curly fringe + crown on top curls(ctx, cx, cy - r * 0.38, r * 1.1, 1, o.wind ?? 0, t, true) ctx.fillStyle = HERO.hair ctx.beginPath() for (let i = 0; i < 7; i++) { const fx = cx + (i - 3) * r * 0.26 const fy = cy - r * 0.66 + Math.abs(i - 3) * r * 0.06 + Math.sin(t * 2 + i) * r * 0.01 ctx.moveTo(fx + r * 0.2, fy) ctx.arc(fx, fy, r * (0.2 + 0.05 * hash(i * 9.1)), 0, Math.PI * 2) } ctx.fill() if (o.rim) { ctx.strokeStyle = o.rim ctx.lineWidth = Math.max(1, r * 0.05) ctx.beginPath() ctx.arc(cx, cy - r * 0.2, r * 1.42, Math.PI * 1.08, Math.PI * 1.55) ctx.stroke() }}18 unmodified lines192021222324103 unmodified lines128129130131132133114 unmodified lines24824925025125225325425525690 unmodified lines347348349350351352353354163 unmodified lines51851952052152252352452552645 unmodified lines5725735745755765775782 unmodified lines5815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116 unmodified lines61861962062162262362462562611 unmodified lines6386396406416426436442 unmodified lines64764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970018 unmodified lineswetReflection,} from './draw'import { camera, resetCam, type SceneCtx } from './types'import {FONT,PALETTE,103 unmodified lines// dripping pipe on the left + small signctx.fillStyle = '#0b0c10'ctx.fillRect(W * 0.08, 0, u * 16, groundY)neonSign(ctx, W * (P ? 0.78 : 0.86), H * 0.18, u * 60, u * 170, '旅馆', PALETTE.cyan, lt > 3.8 ? flicker(t, 4, 6) : 0, true)// groundresetCam(s)114 unmodified linesctx.fillRect(x + nearCell * 0.7, top - u * 40, u * 50, u * 36)if (k % 3 === 0) streetLamp(ctx, x + nearCell * 0.05, groundY, u * 330, 0.85 + 0.15 * flicker(t, k + 99, 5))}// walkerconst phase = (s.a.beatPos / 2) % 1walker(ctx, wx, groundY + u * 2, wh, fract(phase), { rim: PALETTE.cyan, rimSide: -1, coat: 0.7 })// groundctx.fillStyle = '#05070a'ctx.fillRect(-ext, groundY, W + ext * 3, H)90 unmodified linesctx.stroke()speedLines(ctx, vx, vy, Math.max(W, H) * 0.8, t, 90, '#ffffff', 0.04 + p * p * 0.25, 0.25)// figureconst fh = P ? H * 0.26 : H * 0.42figureBack(ctx, W / 2, H * 1.02, fh, Math.sin(lt * 2.2), { rim: rgba(PALETTE.sodium, 0.8) })// countdown on the last beats before the dropconst bp = (t - DROP1) / BEATif (bp >= -3 && bp < 0) {163 unmodified linesconst x = fract(hash(i * 3.1) - t * (1.5 + hash(i))) * W * 1.4 - W * 0.2ctx.fillRect(x, gy + hash(i) * u * 40, u * (80 + hash(i * 2) * 200), Math.max(1, u * 3))}const h = P ? H * 0.42 : H * 0.66const facing = variant ? -1 : 1walker(ctx, cx, gy, h, fract(a.beatPos * 0.5), { run: 1, rim: variant ? PALETTE.red : PALETTE.cyan, rimSide: -facing, facing, coat: 1 })// vertical typeconst vs = P ? W * 0.11 : H * 0.12const word = variant ? '不回头' : '夜行者'45 unmodified lines}// =====================================================================// S5 — 天台·红月 (56.35 – 72.95s)// =====================================================================export function sRooftop(s: SceneCtx) {const { ctx, W, H, P, lt, u, t, a } = s2 unmodified lineslet zoom = 1let cx = W / 2let cy = H / 2const roofY = P ? H * 0.8 : H * 0.82const figX = P ? W * 0.5 : W * 0.36const figH = P ? H * 0.2 : H * 0.3if (!shotB && !shotC) {zoom = 1 + lt * 0.008} else if (shotB) {const k = lt - BAR * 3zoom = (P ? 1.9 : 2.1) + k * 0.03cx = figXcy = roofY - figH * 0.62} else {const k = (lt - BAR * 5) / (s.dur - BAR * 5)zoom = 1.15cx = W / 2 + lerp(-W * 0.15, W * 0.15, easeInOutCubic(k))cy = H / 2 + H * 0.1}cx += fbm(t * 0.6, 3) * u * 8 + (a.kick * (hash(a.beat) - 0.5) * u * 14)cy += fbm(t * 0.7, 4) * u * 6resetCam(s)vGradient(ctx, 0, 0, W, H, [[0, '#0a0307'],[0.5, '#22060c'],[1, '#4a0c16'],])camera(s, zoom, cx, cy)// starsctx.fillStyle = 'rgba(255,230,230,0.6)'6 unmodified lines}ctx.globalAlpha = 1// moonconst mx = P ? W * 0.5 : W * 0.63const my = P ? H * 0.32 : H * 0.38const R = Math.min(W, H) * (P ? 0.36 : 0.3) * (1 + a.kick * 0.03)glowBlob(ctx, mx, my, R * 2.6, '#ff3a2e', 0.4 + a.kick * 0.15)const mg = ctx.createRadialGradient(mx - R * 0.3, my - R * 0.3, R * 0.1, mx, my, R)mg.addColorStop(0, '#ffd7a8')11 unmodified linesctx.arc(mx + Math.cos(ang) * rr, my + Math.sin(ang) * rr, R * (0.05 + hash(i) * 0.12), 0, Math.PI * 2)ctx.fill()}// clouds across the moonctx.fillStyle = 'rgba(12,3,6,0.75)'for (let i = 0; i < 6; i++) {const y = my - R * 0.7 + i * R * 0.322 unmodified linesctx.ellipse(x, y, R * (0.6 + hash(i * 5) * 0.6), R * 0.05, 0, 0, Math.PI * 2)ctx.fill()}// searchlightsctx.save()ctx.globalCompositeOperation = 'lighter'for (let i = 0; i < 3; i++) {const bx = W * (0.15 + i * 0.35)const sw = Math.sin(lt * (0.5 + i * 0.13) + i * 2) * 0.5 + (a.drop ? Math.sin(a.beatPos * Math.PI * 0.5 + i) * 0.15 : 0)lightCone(ctx, bx, roofY + H * 0.05, H * 1.4, 0.05, Math.PI + sw, PALETTE.bone, 0.1 + a.mid * 0.06)}ctx.restore()// helicopterconst hx = fract(lt * 0.03 + 0.2) * W * 1.4 - W * 0.2const hy = H * 0.14 + Math.sin(lt) * u * 10ctx.fillStyle = '#050204'ctx.fillRect(hx - u * 20, hy - u * 6, u * 40, u * 12)glowBlob(ctx, hx + u * 22, hy, u * 18, PALETTE.red, fract(lt * 1.5) < 0.2 ? 1 : 0.1)// skyline belowskyline(ctx, { W: W * 1.6, seed: 77, baseY: roofY + H * 0.04, scroll: lt * u * 6 + W * 0.3, cell: u * 75, minH: H * 0.06, maxH: H * 0.26, color: '#080206', t, density: 0.22, winAlpha: 0.6, rimColor: rgba('#ff4a3c', 0.35) })fogBand(ctx, W * 1.6, roofY, H * 0.05, '#ff3a2e', 0.12)// rooftop slabctx.fillStyle = '#030203'ctx.fillRect(-W, roofY, W * 3, H)ctx.fillRect(-W, roofY - u * 14, W * 3, u * 14)// water tower + antennaconst tx = P ? W * 0.1 : W * 0.12ctx.fillRect(tx, roofY - H * 0.24, u * 120, H * 0.16)ctx.beginPath()ctx.moveTo(tx - u * 10, roofY - H * 0.24)ctx.lineTo(tx + u * 60, roofY - H * 0.3)ctx.lineTo(tx + u * 130, roofY - H * 0.24)ctx.fill()ctx.fillRect(tx + u * 10, roofY - H * 0.08, u * 8, H * 0.08)ctx.fillRect(tx + u * 100, roofY - H * 0.08, u * 8, H * 0.08)const ax = P ? W * 0.86 : W * 0.9ctx.fillRect(ax, roofY - H * 0.42, u * 6, H * 0.42)glowBlob(ctx, ax + u * 3, roofY - H * 0.42, u * 26, PALETTE.red, a.pulse > 0.6 || fract(lt) < 0.15 ? 1 : 0.15)// figure (back to camera, looking at the moon)figureBack(ctx, figX, roofY - u * 12, figH, Math.sin(lt * 1.6), { rim: rgba('#ff7a4a', 0.9) })// coat tail flutterctx.fillStyle = '#030405'ctx.beginPath()const fl = noise1(t * 3, 2)ctx.moveTo(figX + figH * 0.11, roofY - u * 12 - figH * 0.72)ctx.quadraticCurveTo(figX + figH * (0.3 + fl * 0.05), roofY - figH * 0.6, figX + figH * (0.38 + fl * 0.08), roofY - figH * 0.45)ctx.lineTo(figX + figH * 0.12, roofY - figH * 0.48)ctx.fill()resetCam(s)rain(ctx, W, H, t, { count: Math.floor(200 * area(s)) + 40, speed: H * 1.6, len: u * 50, slant: -0.12, color: '#ffb0b0', alpha: 0.16, width: Math.max(1, u * 1.2) })// strobe in shot Cif (shotC && a.beatPhase < 0.08 && a.beat % 2 === 0) {ctx.fillStyle = 'rgba(255,200,190,0.18)'ctx.fillRect(0, 0, W, H)18 unmodified lines19202122232425103 unmodified lines129130131132133134135136137138139114 unmodified lines25425525625725825926026126226326490 unmodified lines355356357358359360361362163 unmodified lines52652752852953053153253353445 unmodified lines5805815825835845855865872 unmodified lines5905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536 unmodified lines66066166266366466511 unmodified lines6776786796806816822 unmodified lines68568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273318 unmodified lineswetReflection,} from './draw'import { camera, resetCam, type SceneCtx } from './types'import { bike, heroPortrait, heroRide, heroRideRear, heroWalk } from './hero'import {FONT,PALETTE,103 unmodified lines// dripping pipe on the left + small signctx.fillStyle = '#0b0c10'ctx.fillRect(W * 0.08, 0, u * 16, groundY)streetLamp(ctx, W * (P ? 0.12 : 0.16), groundY, P ? H * 0.42 : H * 0.62, 0.8 + 0.2 * flicker(t, 31, 4))// his black motorcycle, parked in the rain — headlight wakes up with the titleconst bs = P ? W * 0.5 : H * 0.34const headOn = lt > 6.4 ? (lt < 7 ? flicker(lt, 12, 18) : 1) : 0bike(ctx, P ? W * 0.56 : W * 0.8, groundY, bs, { facing: -1, light: headOn, beam: headOn > 0.5 })neonSign(ctx, W * (P ? 0.78 : 0.86), H * 0.18, u * 60, u * 170, '旅馆', PALETTE.cyan, lt > 3.8 ? flicker(t, 4, 6) : 0, true)// groundresetCam(s)114 unmodified linesctx.fillRect(x + nearCell * 0.7, top - u * 40, u * 50, u * 36)if (k % 3 === 0) streetLamp(ctx, x + nearCell * 0.05, groundY, u * 330, 0.85 + 0.15 * flicker(t, k + 99, 5))}// 阿飞 pushing his motorcycle through the rainconst phase = (s.a.beatPos / 2) % 1const bs = wh * 1.05bike(ctx, wx + bs * 0.62, groundY + u * 2, bs, { facing: 1, light: 0.9, spin: scroll / (bs * 0.21), beam: true })heroWalk(ctx, wx, groundY + u * 2, wh, fract(phase), { reach: 1, t, rim: rgba(PALETTE.cyan, 0.8), eyes: 'closed' })// groundctx.fillStyle = '#05070a'ctx.fillRect(-ext, groundY, W + ext * 3, H)90 unmodified linesctx.stroke()speedLines(ctx, vx, vy, Math.max(W, H) * 0.8, t, 90, '#ffffff', 0.04 + p * p * 0.25, 0.25)// figureconst rs = P ? H * 0.3 : H * 0.52heroRideRear(ctx, W / 2 + Math.sin(lt * 0.55) * W * 0.02, H * 1.03, rs, Math.sin(lt * 0.55) * -0.06, t, 0.5 + p)// countdown on the last beats before the dropconst bp = (t - DROP1) / BEATif (bp >= -3 && bp < 0) {163 unmodified linesconst x = fract(hash(i * 3.1) - t * (1.5 + hash(i))) * W * 1.4 - W * 0.2ctx.fillRect(x, gy + hash(i) * u * 40, u * (80 + hash(i * 2) * 200), Math.max(1, u * 3))}const facing = variant ? -1 : 1const bsz = P ? W * 0.62 : H * 0.6heroRide(ctx, cx, gy + a.kick * u * 6, bsz, { facing, wind: 1, t, spin: t * 30, beam: true, eyes: 'open', rim: variant ? PALETTE.red : PALETTE.cyan })// vertical typeconst vs = P ? W * 0.11 : H * 0.12const word = variant ? '不回头' : '夜行者'45 unmodified lines}// =====================================================================// S5 — 山顶·红月 (56.35 – 72.95s) 阿飞 on his bike at the ridge,// a close-up of his face, then the city lights below// =====================================================================export function sRooftop(s: SceneCtx) {const { ctx, W, H, P, lt, u, t, a } = s2 unmodified lineslet zoom = 1let cx = W / 2let cy = H / 2const ridgeY = P ? H * 0.8 : H * 0.8const figX = P ? W * 0.5 : W * 0.34const bs = P ? W * 0.46 : H * 0.36if (!shotB && !shotC) {zoom = 1 + lt * 0.008} else if (shotC) {const k = (lt - BAR * 5) / (s.dur - BAR * 5)zoom = 1.12cx = W / 2 + lerp(-W * 0.12, W * 0.12, easeInOutCubic(k))cy = H / 2 + H * 0.06}cx += fbm(t * 0.6, 3) * u * 8 + a.kick * (hash(a.beat) - 0.5) * u * 14cy += fbm(t * 0.7, 4) * u * 6resetCam(s)vGradient(ctx, 0, 0, W, H, [[0, '#0a0307'],[0.45, '#2a0710'],[0.75, '#6a1a1c'],[1, '#2a0a10'],])const mx = P ? W * 0.5 : W * 0.64const my = P ? H * 0.3 : H * 0.36const R = Math.min(W, H) * (P ? 0.36 : 0.3) * (1 + a.kick * 0.03)if (shotB) {// ---- close-up: his face in front of the moon, wind in the curlsconst k = (lt - BAR * 3) / (BAR * 2)const MR = Math.max(W, H) * 0.42const mmx = W / 2 + (P ? 0 : W * 0.18)const mmy = H * (P ? 0.32 : 0.4)glowBlob(ctx, mmx, mmy, MR * 2, '#ff3a2e', 0.45)const mg = ctx.createRadialGradient(mmx - MR * 0.3, mmy - MR * 0.3, MR * 0.1, mmx, mmy, MR)mg.addColorStop(0, '#ffd7a8')mg.addColorStop(0.5, '#ff7a4a')mg.addColorStop(1, '#b3122a')ctx.fillStyle = mgctx.beginPath()ctx.arc(mmx, mmy, MR, 0, Math.PI * 2)ctx.fill()const fr = (P ? W * 0.2 : H * 0.2) * (1 + k * 0.05)const fx = P ? W / 2 : W * 0.38const fy = H * (P ? 0.5 : 0.52)const open = k < 0.45 ? 0 : clamp((k - 0.45) / 0.1)heroPortrait(ctx, fx, fy, fr, { t, eyes: open, wind: 0.6, rim: rgba('#ffb08a', 0.9), smile: k > 0.7 })// drifting embers / dust in the moonlightctx.fillStyle = '#ffd0a0'for (let i = 0; i < 50; i++) {const x = fract(hash(i * 1.7) + lt * (0.03 + hash(i) * 0.04)) * Wconst y = hash(i * 3.1) * Hctx.globalAlpha = 0.3 + 0.5 * hash(i * 9)ctx.fillRect(x, y, u * 3, u * 3)}ctx.globalAlpha = 1rain(ctx, W, H, t, { count: Math.floor(120 * area(s)) + 30, speed: H * 1.4, len: u * 40, slant: -0.3, color: '#ffb0b0', alpha: 0.14, width: Math.max(1, u * 1.2) })return}camera(s, zoom, cx, cy)// starsctx.fillStyle = 'rgba(255,230,230,0.6)'6 unmodified lines}ctx.globalAlpha = 1// moonglowBlob(ctx, mx, my, R * 2.6, '#ff3a2e', 0.4 + a.kick * 0.15)const mg = ctx.createRadialGradient(mx - R * 0.3, my - R * 0.3, R * 0.1, mx, my, R)mg.addColorStop(0, '#ffd7a8')11 unmodified linesctx.arc(mx + Math.cos(ang) * rr, my + Math.sin(ang) * rr, R * (0.05 + hash(i) * 0.12), 0, Math.PI * 2)ctx.fill()}ctx.fillStyle = 'rgba(12,3,6,0.75)'for (let i = 0; i < 6; i++) {const y = my - R * 0.7 + i * R * 0.322 unmodified linesctx.ellipse(x, y, R * (0.6 + hash(i * 5) * 0.6), R * 0.05, 0, 0, Math.PI * 2)ctx.fill()}// searchlights from the city belowctx.save()ctx.globalCompositeOperation = 'lighter'for (let i = 0; i < 3; i++) {const bx = W * (0.15 + i * 0.35)const sw = Math.sin(lt * (0.5 + i * 0.13) + i * 2) * 0.5 + (a.drop ? Math.sin(a.beatPos * Math.PI * 0.5 + i) * 0.15 : 0)lightCone(ctx, bx, ridgeY + H * 0.08, H * 1.4, 0.05, Math.PI + sw, PALETTE.bone, 0.09 + a.mid * 0.05)}ctx.restore()// far mountains + city in the valleyctx.fillStyle = '#16050a'ctx.beginPath()ctx.moveTo(-W, ridgeY)for (let i = 0; i <= 40; i++) {const x = -W * 0.5 + (i / 40) * W * 2ctx.lineTo(x, ridgeY - H * (0.12 + 0.1 * fbm(i * 0.35, 7)))}ctx.lineTo(W * 2, ridgeY)ctx.fill()skyline(ctx, { W: W * 1.6, seed: 77, baseY: ridgeY + H * 0.03, scroll: lt * u * 6 + W * 0.3, cell: u * 55, minH: H * 0.03, maxH: H * 0.12, color: '#0a0306', t, density: 0.4, winAlpha: 0.9, rimColor: rgba('#ff4a3c', 0.3) })fogBand(ctx, W * 1.6, ridgeY, H * 0.05, '#ff3a2e', 0.18)// the ridge road he stops onctx.fillStyle = '#060204'ctx.beginPath()ctx.moveTo(-W, ridgeY + H * 0.02)ctx.quadraticCurveTo(W * 0.5, ridgeY - H * 0.03, W * 2, ridgeY + H * 0.01)ctx.lineTo(W * 2, H * 2)ctx.lineTo(-W, H * 2)ctx.fill()// guard railctx.strokeStyle = '#2a1a1e'ctx.lineWidth = u * 5ctx.beginPath()ctx.moveTo(-W, ridgeY - u * 30)ctx.lineTo(W * 2, ridgeY - u * 36)ctx.stroke()ctx.fillStyle = '#2a1a1e'for (let i = -6; i < 30; i++) ctx.fillRect(i * u * 90 + u * 20, ridgeY - u * 36, u * 6, u * 40)// 阿飞 sitting on the parked bike, looking at the moonconst blink = fract(lt / 3.7) > 0.96 ? 'closed' : 'open'heroRide(ctx, figX, ridgeY + u * 4, bs, { facing: 1, wind: 0.35 + 0.15 * Math.sin(t), t, light: 0.6, smile: lt > 4, eyes: blink, rim: rgba('#ff7a4a', 0.9) })resetCam(s)rain(ctx, W, H, t, { count: Math.floor(200 * area(s)) + 40, speed: H * 1.6, len: u * 50, slant: -0.12, color: '#ffb0b0', alpha: 0.16, width: Math.max(1, u * 1.2) })if (shotC && a.beatPhase < 0.08 && a.beat % 2 === 0) {ctx.fillStyle = 'rgba(255,200,190,0.18)'ctx.fillRect(0, 0, W, H)
15 unmodified lines161718192021223 unmodified lines24524624724824925025183 unmodified lines335336337338339340341342343187 unmodified lines53153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758832 unmodified lines62162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669757 unmodified lines75575675775875976076176276376476576676776876977042 unmodified lines81381481581681781815 unmodified lineswetReflection,} from './draw'import { camera, resetCam, type SceneCtx } from './types'import { FONT, PALETTE, clamp, easeInOutCubic, easeOutCubic, easeOutExpo, fbm, fract, hash, hash2, lerp, rgba, smoothstep } from './util'const area = (s: SceneCtx) => (s.W * s.H) / (1920 * 1080)223 unmodified linesconst k = (lt - 8.5) / 7const x = lerp(-W * 0.25, W * 1.25, k)const h = P ? H * 0.75 : H * 1.05walker(ctx, x, H * (P ? 1.12 : 1.18), h, fract(s.a.beatPos / 2), { color: '#020101', rim: rgba(PALETTE.amber, 0.7), rimSide: -1 })}// warm sparks / embers driftingctx.fillStyle = '#ffb35c'83 unmodified linesctx.clip()rain(ctx, W, H, t, { count: Math.floor(260 * area(s)) + 60, speed: H * 1.5, len: u * 50, slant: 0.04, color: '#f3e2c4', alpha: 0.35 * on, width: Math.max(1, u * 1.4) })ctx.restore()// figureconst fh = P ? H * 0.26 : H * 0.36figureBack(ctx, lx, floorY, fh, Math.sin(lt * 0.9) * 0.5, { rim: rgba('#f3e2c4', 0.55 * on) })// heartbeat red pulse vignetteconst pulse = beatGlow * (0.15 + 0.35 * (lt / dur))if (pulse > 0.01) {187 unmodified linesctx.restore()resetCam(s)speedLines(ctx, W / 2, hy, Math.max(W, H) * 0.9, t, 100, '#ffffff', 0.05 + a.kick * 0.12, 0.3)// rider (rear view) at bottom centreconst rs = P ? W * 0.5 : H * 0.55const bx = W / 2const by = H * 1.0 + a.kick * u * 6ctx.save()ctx.translate(bx, by)ctx.rotate(-curve * 0.14)ctx.fillStyle = '#030305'// tirectx.beginPath()ctx.ellipse(0, -rs * 0.08, rs * 0.07, rs * 0.16, 0, 0, Math.PI * 2)ctx.fill()// body / seatctx.beginPath()ctx.moveTo(-rs * 0.17, -rs * 0.22)ctx.lineTo(rs * 0.17, -rs * 0.22)ctx.lineTo(rs * 0.12, -rs * 0.38)ctx.lineTo(-rs * 0.12, -rs * 0.38)ctx.closePath()ctx.fill()// rider torso & helmetctx.beginPath()ctx.moveTo(-rs * 0.2, -rs * 0.34)ctx.quadraticCurveTo(-rs * 0.24, -rs * 0.6, -rs * 0.1, -rs * 0.72)ctx.lineTo(rs * 0.1, -rs * 0.72)ctx.quadraticCurveTo(rs * 0.24, -rs * 0.6, rs * 0.2, -rs * 0.34)ctx.closePath()ctx.fill()ctx.beginPath()ctx.ellipse(0, -rs * 0.8, rs * 0.085, rs * 0.095, 0, 0, Math.PI * 2)ctx.fill()// arms to handlebarsctx.strokeStyle = '#030305'ctx.lineCap = 'round'ctx.lineWidth = rs * 0.05ctx.beginPath()ctx.moveTo(-rs * 0.17, -rs * 0.62)ctx.lineTo(-rs * 0.3, -rs * 0.46)ctx.moveTo(rs * 0.17, -rs * 0.62)ctx.lineTo(rs * 0.3, -rs * 0.46)ctx.stroke()// rim lightctx.strokeStyle = rgba(PALETTE.cyan, 0.6)ctx.lineWidth = Math.max(1, rs * 0.006)ctx.beginPath()ctx.ellipse(0, -rs * 0.8, rs * 0.085, rs * 0.095, 0, Math.PI * 1.1, Math.PI * 1.7)ctx.stroke()// tail lightglowBlob(ctx, 0, -rs * 0.25, rs * 0.12, PALETTE.red, 0.95)ctx.fillStyle = '#ff6a80'ctx.fillRect(-rs * 0.06, -rs * 0.265, rs * 0.12, rs * 0.025)ctx.restore()rain(ctx, W, H, t, { count: Math.floor(160 * area(s)) + 40, speed: H * 3, len: u * 120, slant: 0.0, color: '#d0e0ff', alpha: 0.14, width: Math.max(1, u * 1.2) })}32 unmodified linesctx.fillRect(x, gy + (H - gy) * 0.45, u * 200, u * 6)}wetReflection(ctx, s.scratch, W, H, gy, t, 0.35, u * 2)// bike side viewconst bx = W * 0.5 + Math.sin(lt * 1.3) * u * 20const bs = P ? W * 0.42 : H * 0.36const by = gy - bs * 0.03 + a.kick * u * 4const rw = bs * 0.2// tail light streakconst tg = ctx.createLinearGradient(bx - bs * 2.5, 0, bx - bs * 0.5, 0)tg.addColorStop(0, 'rgba(255,45,85,0)')tg.addColorStop(1, 'rgba(255,45,85,0.85)')ctx.fillStyle = tgctx.fillRect(bx - bs * 2.5, by - bs * 0.42, bs * 2, Math.max(2, bs * 0.03))// headlight beamlightCone(ctx, bx + bs * 0.55, by - bs * 0.45, W * 0.6, 0.12, -Math.PI / 2, '#eaf4ff', 0.18)ctx.fillStyle = '#030305'ctx.strokeStyle = '#030305'for (const wx of [bx - bs * 0.45, bx + bs * 0.45]) {ctx.lineWidth = rw * 0.35ctx.beginPath()ctx.arc(wx, by - rw, rw * 0.83, 0, Math.PI * 2)ctx.stroke()// spokes blurctx.save()ctx.strokeStyle = 'rgba(200,210,230,0.25)'ctx.lineWidth = Math.max(1, u * 1.5)ctx.beginPath()for (let k = 0; k < 6; k++) {const ang = k * (Math.PI / 3) + lt * 40ctx.moveTo(wx, by - rw)ctx.lineTo(wx + Math.cos(ang) * rw * 0.7, by - rw + Math.sin(ang) * rw * 0.7)}ctx.stroke()ctx.restore()}ctx.beginPath()ctx.moveTo(bx - bs * 0.55, by - rw * 1.6)ctx.lineTo(bx - bs * 0.2, by - bs * 0.5)ctx.lineTo(bx + bs * 0.3, by - bs * 0.52)ctx.lineTo(bx + bs * 0.55, by - bs * 0.42)ctx.lineTo(bx + bs * 0.45, by - rw)ctx.lineTo(bx - bs * 0.1, by - rw * 0.9)ctx.closePath()ctx.fill()// rider crouchedctx.beginPath()ctx.moveTo(bx - bs * 0.25, by - bs * 0.5)ctx.quadraticCurveTo(bx - bs * 0.05, by - bs * 0.92, bx + bs * 0.28, by - bs * 0.82)ctx.lineTo(bx + bs * 0.32, by - bs * 0.7)ctx.lineTo(bx + bs * 0.05, by - bs * 0.55)ctx.closePath()ctx.fill()ctx.beginPath()ctx.arc(bx + bs * 0.33, by - bs * 0.88, bs * 0.075, 0, Math.PI * 2)ctx.fill()ctx.lineWidth = bs * 0.05ctx.lineCap = 'round'ctx.beginPath()ctx.moveTo(bx + bs * 0.2, by - bs * 0.78)ctx.lineTo(bx + bs * 0.42, by - bs * 0.6)ctx.moveTo(bx - bs * 0.1, by - bs * 0.55)ctx.lineTo(bx + bs * 0.05, by - bs * 0.3)ctx.lineTo(bx + bs * 0.12, by - bs * 0.22)ctx.stroke()// rim light along the topctx.strokeStyle = rgba(PALETTE.cyan, 0.7)ctx.lineWidth = Math.max(1, u * 2)ctx.beginPath()ctx.moveTo(bx - bs * 0.25, by - bs * 0.52)ctx.quadraticCurveTo(bx - bs * 0.05, by - bs * 0.94, bx + bs * 0.28, by - bs * 0.84)ctx.stroke()glowBlob(ctx, bx - bs * 0.5, by - bs * 0.42, bs * 0.1, PALETTE.red, 1)glowBlob(ctx, bx + bs * 0.56, by - bs * 0.45, bs * 0.1, '#ffffff', 1)// horizontal speed linesctx.fillStyle = 'rgba(255,255,255,0.18)'for (let i = 0; i < 30; i++) {57 unmodified linesctx.fillRect(0, 0, W, H)return}// aerial cityvGradient(ctx, 0, 0, W, H, [[0, '#05081a'],[0.55, '#16234a'],[1, '#4a1a3a'],])const rise = easeInOutCubic(clamp(lt / 7))const baseY = H * (0.95 + 0.25 * rise)skyline(ctx, { W, seed: 5, baseY: baseY - H * 0.16, scroll: lt * u * 10, cell: u * 50, minH: H * 0.1, maxH: H * 0.35, color: '#070a14', t, density: 0.25, winAlpha: 0.5 })skyline(ctx, { W, seed: 6, baseY, scroll: lt * u * 24, cell: u * 90, minH: H * 0.15, maxH: H * 0.5, color: '#04050a', t, density: 0.3, winAlpha: 0.8, litMod: (_k, row, rows) => (1 - row / rows < a.kick * 0.8 ? 0.6 : 0) })// neon bursts on kicksctx.save()ctx.globalCompositeOperation = 'lighter'42 unmodified lines// solid neon titleconst titleOn = smoothstep(9.2, 10.2, lt)if (titleOn > 0) {const fl = a.drop && hash(a.beat * 3.1) > 0.8 && a.beatPhase < 0.1 ? 0.3 : 1glowBlob(ctx, W / 2, L.cy, L.size * 2.4, PALETTE.red, 0.3 * titleOn)for (const c of L.chars) neonText(ctx, c.c, c.x, c.y, L.size, PALETTE.red, titleOn * fl, { tube: true, blur: 0.45 })15 unmodified lines16171819202122223 unmodified lines24624724824925025125283 unmodified lines336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378187 unmodified lines56656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361432 unmodified lines64764864965065165265365465565665765865966066166257 unmodified lines72072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183242 unmodified lines87587687787887988088188215 unmodified lineswetReflection,} from './draw'import { camera, resetCam, type SceneCtx } from './types'import { HERO, bike, flame, heroPortrait, heroRide, heroRideRear, heroSit, heroWalk } from './hero'import { FONT, PALETTE, clamp, easeInOutCubic, easeOutCubic, easeOutExpo, fbm, fract, hash, hash2, lerp, rgba, smoothstep } from './util'const area = (s: SceneCtx) => (s.W * s.H) / (1920 * 1080)223 unmodified linesconst k = (lt - 8.5) / 7const x = lerp(-W * 0.25, W * 1.25, k)const h = P ? H * 0.75 : H * 1.05heroWalk(ctx, x, H * (P ? 1.08 : 1.12), h, fract(s.a.beatPos / 2), { t, eyes: 'open', rim: rgba(PALETTE.amber, 0.8) })}// warm sparks / embers driftingctx.fillStyle = '#ffb35c'83 unmodified linesctx.clip()rain(ctx, W, H, t, { count: Math.floor(260 * area(s)) + 60, speed: H * 1.5, len: u * 50, slant: 0.04, color: '#f3e2c4', alpha: 0.35 * on, width: Math.max(1, u * 1.4) })ctx.restore()// 阿飞 sits by his motorcycle under the lamp, reading a letter … then burns itconst fh = P ? H * 0.2 : H * 0.3bike(ctx, lx + fh * 0.95, floorY, fh * 1.25, { facing: -1, light: 0 })const burn = smoothstep(9.6, 10.4, lt)const letter = 1 - smoothstep(10.2, 14.5, lt)heroSit(ctx, lx - fh * 0.35, floorY, fh, t, { facing: 1, letter, fire: burn * (letter > 0.02 ? 1 : smoothstep(15.5, 14.5, lt)) })if (burn > 0) {// warm firelight on the floorctx.save()ctx.globalCompositeOperation = 'lighter'glowBlob(ctx, lx, floorY - fh * 0.4, fh * 1.6, '#ff7a2e', 0.25 * burn * (0.85 + 0.15 * Math.sin(t * 13)))ctx.restore()}if (lt > 5.0 && lt < 9.3) {const k = (lt - 5.0) / 4.3ctx.fillStyle = '#050406'ctx.fillRect(0, 0, W, H)lightCone(ctx, W / 2, 0, H, 0.5, 0, '#f3e2c4', 0.2 * on)const fr = P ? W * 0.24 : H * 0.24heroPortrait(ctx, W / 2, H * (P ? 0.46 : 0.48), fr * (1 + k * 0.06), { t, eyes: 0, tear: clamp(k * 1.3), rim: rgba('#f3e2c4', 0.6 * on) })ctx.save()ctx.strokeStyle = PALETTE.redctx.shadowColor = PALETTE.redctx.shadowBlur = u * 18ctx.lineWidth = Math.max(2, u * 4)ctx.globalAlpha = 0.7ctx.beginPath()for (let i = 0; i <= 160; i++) {const x = (i / 160) * Wconst tau = lt - (1 - i / 160) * spanconst y = H * 0.9 - ecg(fract(hbAt(tau))) * H * 0.08if (i === 0) ctx.moveTo(x, y)else ctx.lineTo(x, y)}ctx.stroke()ctx.restore()}// heartbeat red pulse vignetteconst pulse = beatGlow * (0.15 + 0.35 * (lt / dur))if (pulse > 0.01) {187 unmodified linesctx.restore()resetCam(s)speedLines(ctx, W / 2, hy, Math.max(W, H) * 0.9, t, 100, '#ffffff', 0.05 + a.kick * 0.12, 0.3)// a big truck thundering along in the right lane (as in the reference){const tz = 7 + 9 * (0.5 + 0.5 * Math.sin(lt * 0.35 + shot * 2))const TX0 = 2.9const TX1 = 6.2const TH = 4.3const back0 = proj(TX0, 0.6, camZ + tz)const back1 = proj(TX1, TH, camZ + tz)const side0 = proj(TX0, 0.6, camZ + tz + 14)const side1 = proj(TX0, TH, camZ + tz + 14)ctx.save()camera(s, 1 + a.kick * 0.02, W / 2, H / 2, lean)// side panelctx.fillStyle = '#2a2d33'ctx.beginPath()ctx.moveTo(back0.x, back0.y)ctx.lineTo(side0.x, side0.y)ctx.lineTo(side1.x, side1.y)ctx.lineTo(back0.x, back1.y)ctx.closePath()ctx.fill()// rear doorsctx.fillStyle = '#5a5e66'ctx.fillRect(back0.x, back1.y, back1.x - back0.x, back0.y - back1.y)ctx.strokeStyle = '#2a2d33'ctx.lineWidth = Math.max(1, (back1.x - back0.x) * 0.02)ctx.strokeRect(back0.x, back1.y, back1.x - back0.x, back0.y - back1.y)ctx.beginPath()ctx.moveTo((back0.x + back1.x) / 2, back1.y)ctx.lineTo((back0.x + back1.x) / 2, back0.y)ctx.stroke()const tw = back1.x - back0.xglowBlob(ctx, back0.x + tw * 0.08, back0.y - tw * 0.05, tw * 0.12, PALETTE.red, 1)glowBlob(ctx, back1.x - tw * 0.08, back0.y - tw * 0.05, tw * 0.12, PALETTE.red, 1)// wheelsctx.fillStyle = '#050507'ctx.fillRect(back0.x + tw * 0.05, back0.y, tw * 0.25, tw * 0.12)ctx.fillRect(back1.x - tw * 0.3, back0.y, tw * 0.25, tw * 0.12)ctx.restore()}// 阿飞 (rear view) at bottom centre — curls flying in the windconst rs = P ? W * 0.5 : H * 0.55heroRideRear(ctx, W / 2, H * 1.0 + a.kick * u * 6, rs * 1.15, -curve * 0.14, t, 1)rain(ctx, W, H, t, { count: Math.floor(160 * area(s)) + 40, speed: H * 3, len: u * 120, slant: 0.0, color: '#d0e0ff', alpha: 0.14, width: Math.max(1, u * 1.2) })}32 unmodified linesctx.fillRect(x, gy + (H - gy) * 0.45, u * 200, u * 6)}wetReflection(ctx, s.scratch, W, H, gy, t, 0.35, u * 2)// 阿飞 on his bike, side view, hair streaming backconst bx = W * 0.5 + Math.sin(lt * 1.3) * u * 20const bs = P ? W * 0.62 : H * 0.5const by = gy + a.kick * u * 4const tg = ctx.createLinearGradient(bx - bs * 2.6, 0, bx - bs * 0.6, 0)tg.addColorStop(0, 'rgba(255,45,85,0)')tg.addColorStop(1, 'rgba(255,45,85,0.85)')ctx.fillStyle = tgctx.fillRect(bx - bs * 2.6, by - bs * 0.46, bs * 2, Math.max(2, bs * 0.03))heroRide(ctx, bx, by, bs, { facing: 1, wind: 1, t, spin: lt * 40, beam: true, eyes: 'open', rim: rgba(PALETTE.cyan, 0.85) })// horizontal speed linesctx.fillStyle = 'rgba(255,255,255,0.18)'for (let i = 0; i < 30; i++) {57 unmodified linesctx.fillRect(0, 0, W, H)return}// night hill: a big tree, a crescent moon, a train passing in the distancevGradient(ctx, 0, 0, W, H, [[0, '#04071a'],[0.55, '#14204a'],[0.8, '#3a1d4a'],[1, '#120a18'],])// starsfor (let i = 0; i < 180; i++) {const x = hash(i * 1.37) * Wconst y = hash(i * 2.71) * H * 0.7const tw = 0.35 + 0.65 * Math.abs(Math.sin(t * (0.6 + hash(i) * 2) + i))ctx.fillStyle = i % 9 === 0 ? '#ffe6b0' : '#dfe8ff'ctx.globalAlpha = tw * (0.5 + 0.5 * hash(i * 5))const sz = u * (1.5 + 2 * hash(i * 7))ctx.fillRect(x, y, sz, sz)}ctx.globalAlpha = 1// crescent moon{const mx = P ? W * 0.76 : W * 0.82const my = H * 0.16const mr = Math.min(W, H) * 0.07glowBlob(ctx, mx, my, mr * 4, '#ffe6b0', 0.25)ctx.fillStyle = '#fff1c8'ctx.beginPath()ctx.arc(mx, my, mr, 0, Math.PI * 2)ctx.fill()ctx.fillStyle = '#0a1030'ctx.beginPath()ctx.arc(mx + mr * 0.45, my - mr * 0.2, mr * 0.92, 0, Math.PI * 2)ctx.fill()}const horizon = P ? H * 0.8 : H * 0.78// far hillsctx.fillStyle = '#0c0f24'ctx.beginPath()ctx.moveTo(0, horizon)for (let i = 0; i <= 30; i++) ctx.lineTo((i / 30) * W, horizon - H * (0.06 + 0.06 * fbm(i * 0.4, 11)))ctx.lineTo(W, H)ctx.lineTo(0, H)ctx.fill()// the train (red & yellow carriages, warm windows){const ty = horizon - H * 0.035const cw = u * (P ? 120 : 150)const chh = cw * 0.32const head = W * 1.15 - lt * W * 0.09for (let c = 0; c < 9; c++) {const x = head + c * cw * 1.04if (x > W + cw || x + cw < -cw) continuectx.fillStyle = c === 0 ? '#c4142f' : c % 2 ? '#d9a12a' : '#b8202c'ctx.fillRect(x, ty - chh, cw, chh)ctx.fillStyle = '#2a0a0a'ctx.fillRect(x, ty - chh * 0.25, cw, chh * 0.12)ctx.fillStyle = '#ffe6a0'for (let w = 0; w < 6; w++) ctx.fillRect(x + cw * (0.08 + w * 0.15), ty - chh * 0.78, cw * 0.09, chh * 0.32)if (c === 0) glowBlob(ctx, x, ty - chh * 0.5, cw * 0.5, '#fff1c8', 0.9)}ctx.fillStyle = '#05060f'ctx.fillRect(0, ty, W, u * 4)}// near hillctx.fillStyle = '#05060c'ctx.beginPath()ctx.moveTo(0, horizon + H * 0.02)ctx.quadraticCurveTo(W * 0.3, horizon - H * 0.06, W * 0.6, horizon + H * 0.01)ctx.quadraticCurveTo(W * 0.8, horizon + H * 0.04, W, horizon + H * 0.02)ctx.lineTo(W, H)ctx.lineTo(0, H)ctx.fill()// the big tree{const tx = P ? W * 0.2 : W * 0.17const base = horizon - H * 0.02const th = P ? H * 0.42 : H * 0.6ctx.fillStyle = '#04050a'ctx.beginPath()ctx.moveTo(tx - th * 0.05, base)ctx.quadraticCurveTo(tx - th * 0.02, base - th * 0.4, tx - th * 0.1, base - th * 0.62)ctx.lineTo(tx + th * 0.08, base - th * 0.62)ctx.quadraticCurveTo(tx + th * 0.03, base - th * 0.4, tx + th * 0.07, base)ctx.fill()ctx.fillStyle = '#060a12'ctx.beginPath()for (let i = 0; i < 16; i++) {const ang = (i / 16) * Math.PI * 2const rr = th * (0.26 + 0.1 * hash(i * 2.3))const px = tx + Math.cos(ang) * th * 0.32 * (0.7 + 0.3 * hash(i))const py = base - th * 0.78 + Math.sin(ang) * th * 0.18 + Math.sin(t * 0.8 + i) * u * 2ctx.moveTo(px + rr, py)ctx.arc(px, py, rr, 0, Math.PI * 2)}ctx.fill()// firefliesctx.fillStyle = '#d8ff9a'for (let i = 0; i < 18; i++) {const px = tx + Math.sin(t * 0.5 + i * 2.1) * th * 0.45const py = base - th * (0.25 + 0.5 * hash(i * 3.3)) + Math.cos(t * 0.7 + i) * u * 20ctx.globalAlpha = 0.4 + 0.6 * Math.abs(Math.sin(t * 2 + i))ctx.fillRect(px, py, u * 3, u * 3)}ctx.globalAlpha = 1// 阿飞 sitting on his bike under the tree, watching the trainconst bs = P ? W * 0.34 : H * 0.24heroRide(ctx, tx + th * (P ? 0.55 : 0.42), base + u * 2, bs, { facing: 1, wind: 0.25, t, light: 0.5, smile: true, eyes: 'open', rim: rgba('#9ab8ff', 0.6) })}// neon bursts on kicksctx.save()ctx.globalCompositeOperation = 'lighter'42 unmodified lines// solid neon titleconst titleOn = smoothstep(9.2, 10.2, lt)if (titleOn > 0) {ctx.fillStyle = `rgba(3,4,10,${0.35 * titleOn})`ctx.fillRect(0, 0, W, H)const fl = a.drop && hash(a.beat * 3.1) > 0.8 && a.beatPhase < 0.1 ? 0.3 : 1glowBlob(ctx, W / 2, L.cy, L.size * 2.4, PALETTE.red, 0.3 * titleOn)for (const c of L.chars) neonText(ctx, c.c, c.x, c.y, L.size, PALETTE.red, titleOn * fl, { tube: true, blur: 0.45 })
15 unmodified lines1617181920212223242526272829309 unmodified lines404142434445464748495051525354555657585915 unmodified linesconst b2 = (k: number) => DROP2 + k * BEATexport const SCENES: SceneDef[] = [{ id: 'ignite', name: '开场·霓虹点亮', start: 0, end: b1(-51), fn: sIgnite, color: '#ff2d55' },{ id: 'street', name: '雨夜长街', start: b1(-51), end: b1(-25), fn: sStreet, color: '#3de0ff' },{ id: 'tunnel', name: '蓄力·隧道', start: b1(-25), end: DROP1, fn: sTunnel, color: '#ffb35c' },{ id: 'drop1', name: 'Drop1·霓虹爆裂', start: DROP1, end: DROP1 + 8 * BAR, fn: sDrop1, color: '#ff2d55' },{ id: 'rooftop', name: '天台·红月', start: DROP1 + 8 * BAR, end: BREAK, fn: sRooftop, color: '#ff7a4a' },{ id: 'market', name: '葱姜蒜夜市', start: BREAK, end: b2(-32), fn: sMarket, color: '#ffb35c' },{ id: 'heart', name: '暗场·心跳', start: b2(-32), end: DROP2, fn: sHeartbeat, color: '#9b1530' },{ id: 'highway', name: 'Drop2·飙车光轨', start: DROP2, end: DROP2 + 8 * BAR, fn: sHighway, color: '#3de0ff' },{ id: 'finale', name: '终章·黑街之王', start: DROP2 + 8 * BAR, end: DURATION, fn: sFinale, color: '#ff2d55' },]export function sceneAt(t: number): SceneDef {9 unmodified lines// Original subtitle lines (not the song lyrics).export const CAPTIONS: Caption[] = [{ start: 10.4, end: 13.9, text: '凌晨两点,雨还没有停' },{ start: 14.4, end: 18.0, text: '霓虹替我记住每一条路' },{ start: 18.6, end: 23.2, text: '这条街,从不问你的来处' },{ start: 25.0, end: 28.6, text: '只问你——' },{ start: 29.0, end: 34.6, text: '敢不敢,走到尽头' },{ start: 57.0, end: 60.8, text: '城市睡了,红月醒着' },{ start: 61.5, end: 65.5, text: '风把影子吹得很长' },{ start: 66.0, end: 71.6, text: '灯海在脚下翻涌' },{ start: 74.5, end: 78.6, text: '穿过夜市的烟火' },{ start: 79.2, end: 83.4, text: '葱、姜、蒜,香气还热着' },{ start: 84.0, end: 89.5, text: '人间,就藏在这一碗里' },{ start: 92.4, end: 96.4, text: '灯,灭了' },{ start: 97.0, end: 101.0, text: '只剩心跳' },{ start: 101.6, end: 106.6, text: '听——它在加速' },]export function captionAt(t: number): Caption | null {15 unmodified lines1617181920212223242526272829309 unmodified lines404142434445464748495051525354555657585915 unmodified linesconst b2 = (k: number) => DROP2 + k * BEATexport const SCENES: SceneDef[] = [{ id: 'ignite', name: '开场·霓虹与摩托', start: 0, end: b1(-51), fn: sIgnite, color: '#ff2d55' },{ id: 'street', name: '雨夜·推车少年', start: b1(-51), end: b1(-25), fn: sStreet, color: '#3de0ff' },{ id: 'tunnel', name: '蓄力·隧道', start: b1(-25), end: DROP1, fn: sTunnel, color: '#ffb35c' },{ id: 'drop1', name: 'Drop1·霓虹爆裂', start: DROP1, end: DROP1 + 8 * BAR, fn: sDrop1, color: '#ff2d55' },{ id: 'rooftop', name: '山顶·红月', start: DROP1 + 8 * BAR, end: BREAK, fn: sRooftop, color: '#ff7a4a' },{ id: 'market', name: '葱姜蒜夜市', start: BREAK, end: b2(-32), fn: sMarket, color: '#ffb35c' },{ id: 'heart', name: '灯下·烧掉的信', start: b2(-32), end: DROP2, fn: sHeartbeat, color: '#9b1530' },{ id: 'highway', name: 'Drop2·公路之王', start: DROP2, end: DROP2 + 8 * BAR, fn: sHighway, color: '#3de0ff' },{ id: 'finale', name: '终章·星空与火车', start: DROP2 + 8 * BAR, end: DURATION, fn: sFinale, color: '#ff2d55' },]export function sceneAt(t: number): SceneDef {9 unmodified lines// Original subtitle lines (not the song lyrics).export const CAPTIONS: Caption[] = [{ start: 10.4, end: 13.9, text: '凌晨两点,他推着车走在雨里' },{ start: 14.4, end: 18.0, text: '霓虹替我记住每一条路' },{ start: 18.6, end: 23.2, text: '这条街,从不问你的来处' },{ start: 25.0, end: 28.6, text: '只问你——' },{ start: 29.0, end: 34.6, text: '敢不敢,走到尽头' },{ start: 57.0, end: 60.8, text: '城市睡了,红月醒着' },{ start: 61.5, end: 65.5, text: '风吹乱了他的卷发' },{ start: 66.0, end: 71.6, text: '灯海在脚下翻涌' },{ start: 74.5, end: 78.6, text: '穿过夜市的烟火' },{ start: 79.2, end: 83.4, text: '葱、姜、蒜,香气还热着' },{ start: 84.0, end: 89.5, text: '人间,就藏在这一碗里' },{ start: 92.4, end: 96.4, text: '那封信,他读了很多遍' },{ start: 97.0, end: 101.0, text: '只剩心跳' },{ start: 101.6, end: 106.6, text: '烧掉它,再出发' },]export function captionAt(t: number): Caption | null {
61 unmodified lines62636465666773 unmodified lines14114214314414514614731 unmodified lines17918018118218318418561 unmodified linesconst tick = () => new Promise<void>((r) => setTimeout(r, 0))export async function exportMp4(o: ExportOptions): Promise<ExportResult> {if (!webCodecsSupported()) return exportRealtime(o)const { width, height, fps, signal, onProgress } = o73 unmodified lineserror: (e) => (failure = e as Error),})ve.configure({ codec, width, height, bitrate, framerate: fps, latencyMode: 'quality', avc: { format: 'avc' } })const r = new Renderer()r.setSize(width, height)const total = Math.ceil(DURATION * fps)const t0 = performance.now()31 unmodified linesif (typeof MediaRecorder === 'undefined') throw new Error('当前浏览器不支持本地视频编码,请使用最新版 Chrome / Edge / Safari')const mimes = ['video/mp4;codecs=avc1.640028,mp4a.40.2', 'video/mp4;codecs=avc1,mp4a', 'video/mp4', 'video/webm;codecs=vp9,opus', 'video/webm']const mime = mimes.find((m) => MediaRecorder.isTypeSupported(m)) || ''const r = new Renderer()r.setSize(width, height)const AC: typeof AudioContext = window.AudioContext || (window as unknown as { webkitAudioContext: typeof AudioContext }).webkitAudioContextconst ac = new AC()61 unmodified lines6263646566676869707172737473 unmodified lines14814915015115215315431 unmodified lines18618718818919019119261 unmodified linesconst tick = () => new Promise<void>((r) => setTimeout(r, 0))// one WebGL context for all exports (browsers cap the number of live contexts)let sharedRenderer: Renderer | null = nullexport function exportRenderer(): Renderer {sharedRenderer ??= new Renderer()return sharedRenderer}export async function exportMp4(o: ExportOptions): Promise<ExportResult> {if (!webCodecsSupported()) return exportRealtime(o)const { width, height, fps, signal, onProgress } = o73 unmodified lineserror: (e) => (failure = e as Error),})ve.configure({ codec, width, height, bitrate, framerate: fps, latencyMode: 'quality', avc: { format: 'avc' } })const r = exportRenderer()r.setSize(width, height)const total = Math.ceil(DURATION * fps)const t0 = performance.now()31 unmodified linesif (typeof MediaRecorder === 'undefined') throw new Error('当前浏览器不支持本地视频编码,请使用最新版 Chrome / Edge / Safari')const mimes = ['video/mp4;codecs=avc1.640028,mp4a.40.2', 'video/mp4;codecs=avc1,mp4a', 'video/mp4', 'video/webm;codecs=vp9,opus', 'video/webm']const mime = mimes.find((m) => MediaRecorder.isTypeSupported(m)) || ''const r = exportRenderer()r.setSize(width, height)const AC: typeof AudioContext = window.AudioContext || (window as unknown as { webkitAudioContext: typeof AudioContext }).webkitAudioContextconst ac = new AC()
README.md+35-11
public/mvfonts/black.woff2
public/mvfonts/neon.woff2+2-2
src/mv/MvApp.tsx+20-2
src/mv/copy/platforms.ts+17-17
src/mv/covers/covers.ts+25-3
src/mv/engine/hero.tsAdded+959
src/mv/engine/scenesA.ts+94-61
src/mv/engine/scenesB.ts+194-130
src/mv/engine/timeline.ts+10-10
src/mv/export/exportMp4.ts+9-2