@auscera/cleoedits 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) hide show
  1. package/README.md +62 -2
  2. package/cli.mjs +149 -0
  3. package/lib/dependencies.mjs +384 -0
  4. package/lib/run.mjs +114 -0
  5. package/lib/workspace.mjs +167 -0
  6. package/package.json +240 -3
  7. package/workspace/.agents/skills/cleoedits/SKILL.md +29 -0
  8. package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/audiogram.json +41 -0
  9. package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/facebook.json +48 -0
  10. package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/linkedin.json +48 -0
  11. package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/podcast.json +23 -0
  12. package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/reels.json +48 -0
  13. package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/shorts.json +48 -0
  14. package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/tiktok.json +48 -0
  15. package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/x.json +48 -0
  16. package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/youtube-shorts.json +48 -0
  17. package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/youtube.json +48 -0
  18. package/workspace/.agents/skills/cleoedits/assets/reel_effects/assets/LICENSE-SimpleIcons +30 -0
  19. package/workspace/.agents/skills/cleoedits/assets/reel_effects/assets/logos.json +1 -0
  20. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/Anton-Regular.ttf +0 -0
  21. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/ArchivoBlack-Regular.ttf +0 -0
  22. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/InstrumentSerif-Italic.ttf +0 -0
  23. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/Inter.ttf +0 -0
  24. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/LICENSE-PermanentMarker.txt +202 -0
  25. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/Montserrat.ttf +0 -0
  26. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-Anton.txt +93 -0
  27. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-ArchivoBlack.txt +93 -0
  28. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-InstrumentSerif.txt +93 -0
  29. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-Inter.txt +93 -0
  30. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-Montserrat.txt +93 -0
  31. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-PlayfairDisplay.txt +93 -0
  32. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-Poppins.txt +93 -0
  33. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-SpaceMono.txt +93 -0
  34. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/PermanentMarker-Regular.ttf +0 -0
  35. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/PlayfairDisplay-Italic.ttf +0 -0
  36. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/PlayfairDisplay.ttf +0 -0
  37. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/Poppins-Black.ttf +0 -0
  38. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/Poppins-Bold.ttf +0 -0
  39. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/Poppins-ExtraBold.ttf +0 -0
  40. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/SpaceMono-Bold.ttf +0 -0
  41. package/workspace/.agents/skills/cleoedits/assets/reel_effects/models/LICENSE-MediaPipe +218 -0
  42. package/workspace/.agents/skills/cleoedits/assets/reel_effects/models/LICENSE-YuNet +21 -0
  43. package/workspace/.agents/skills/cleoedits/assets/reel_effects/models/NOTICE.md +4 -0
  44. package/workspace/.agents/skills/cleoedits/assets/reel_effects/models/selfie_segmenter.tflite +0 -0
  45. package/workspace/.agents/skills/cleoedits/assets/reel_effects/models/yunet.onnx +0 -0
  46. package/workspace/.agents/skills/cleoedits/assets/video_styles/LICENSE +21 -0
  47. package/workspace/.agents/skills/cleoedits/assets/video_styles/audio-app-ui/STYLE.md +65 -0
  48. package/workspace/.agents/skills/cleoedits/assets/video_styles/blueprint/STYLE.md +53 -0
  49. package/workspace/.agents/skills/cleoedits/assets/video_styles/blueprint/index.html +328 -0
  50. package/workspace/.agents/skills/cleoedits/assets/video_styles/blueprint/studio.js +57 -0
  51. package/workspace/.agents/skills/cleoedits/assets/video_styles/data-story/STYLE.md +65 -0
  52. package/workspace/.agents/skills/cleoedits/assets/video_styles/data-story/index.html +575 -0
  53. package/workspace/.agents/skills/cleoedits/assets/video_styles/design-app-ui/STYLE.md +68 -0
  54. package/workspace/.agents/skills/cleoedits/assets/video_styles/editor-ui/STYLE.md +73 -0
  55. package/workspace/.agents/skills/cleoedits/assets/video_styles/editorial-paper/STYLE.md +54 -0
  56. package/workspace/.agents/skills/cleoedits/assets/video_styles/editorial-paper/index.html +189 -0
  57. package/workspace/.agents/skills/cleoedits/assets/video_styles/editorial-paper/studio.js +57 -0
  58. package/workspace/.agents/skills/cleoedits/assets/video_styles/explainer-diagram/STYLE.md +64 -0
  59. package/workspace/.agents/skills/cleoedits/assets/video_styles/explainer-diagram/index.html +620 -0
  60. package/workspace/.agents/skills/cleoedits/assets/video_styles/graphite-ui/STYLE.md +55 -0
  61. package/workspace/.agents/skills/cleoedits/assets/video_styles/graphite-ui/index.html +238 -0
  62. package/workspace/.agents/skills/cleoedits/assets/video_styles/graphite-ui/studio.js +57 -0
  63. package/workspace/.agents/skills/cleoedits/assets/video_styles/growing-city/STYLE.md +66 -0
  64. package/workspace/.agents/skills/cleoedits/assets/video_styles/growing-city/index.html +602 -0
  65. package/workspace/.agents/skills/cleoedits/assets/video_styles/ink-line/STYLE.md +66 -0
  66. package/workspace/.agents/skills/cleoedits/assets/video_styles/ink-line/index.html +777 -0
  67. package/workspace/.agents/skills/cleoedits/assets/video_styles/midnight-grid/STYLE.md +56 -0
  68. package/workspace/.agents/skills/cleoedits/assets/video_styles/midnight-grid/index.html +186 -0
  69. package/workspace/.agents/skills/cleoedits/assets/video_styles/midnight-grid/studio.js +57 -0
  70. package/workspace/.agents/skills/cleoedits/assets/video_styles/motion-app-ui/STYLE.md +68 -0
  71. package/workspace/.agents/skills/cleoedits/assets/video_styles/paper-cut/STYLE.md +56 -0
  72. package/workspace/.agents/skills/cleoedits/assets/video_styles/paper-cut/index.html +244 -0
  73. package/workspace/.agents/skills/cleoedits/assets/video_styles/paper-cut/studio.js +57 -0
  74. package/workspace/.agents/skills/cleoedits/assets/video_styles/paper-world/STYLE.md +67 -0
  75. package/workspace/.agents/skills/cleoedits/assets/video_styles/paper-world/index.html +663 -0
  76. package/workspace/.agents/skills/cleoedits/assets/video_styles/particle-field/STYLE.md +59 -0
  77. package/workspace/.agents/skills/cleoedits/assets/video_styles/particle-field/index.html +395 -0
  78. package/workspace/.agents/skills/cleoedits/assets/video_styles/poster-pop/STYLE.md +52 -0
  79. package/workspace/.agents/skills/cleoedits/assets/video_styles/poster-pop/index.html +194 -0
  80. package/workspace/.agents/skills/cleoedits/assets/video_styles/poster-pop/studio.js +57 -0
  81. package/workspace/.agents/skills/cleoedits/assets/video_styles/risograph/STYLE.md +58 -0
  82. package/workspace/.agents/skills/cleoedits/assets/video_styles/risograph/index.html +242 -0
  83. package/workspace/.agents/skills/cleoedits/assets/video_styles/risograph/studio.js +57 -0
  84. package/workspace/.agents/skills/cleoedits/assets/video_styles/swiss-grid/STYLE.md +53 -0
  85. package/workspace/.agents/skills/cleoedits/assets/video_styles/swiss-grid/index.html +138 -0
  86. package/workspace/.agents/skills/cleoedits/assets/video_styles/swiss-grid/studio.js +57 -0
  87. package/workspace/.agents/skills/cleoedits/assets/video_styles/swiss-kinetic/STYLE.md +63 -0
  88. package/workspace/.agents/skills/cleoedits/assets/video_styles/swiss-kinetic/index.html +599 -0
  89. package/workspace/.agents/skills/cleoedits/assets/video_styles/time-travel/STYLE.md +65 -0
  90. package/workspace/.agents/skills/cleoedits/assets/video_styles/time-travel/index.html +1297 -0
  91. package/workspace/.agents/skills/cleoedits/assets/video_styles/weather-widget/STYLE.md +69 -0
  92. package/workspace/.agents/skills/cleoedits/assets/video_styles/weather-widget/index.html +674 -0
  93. package/workspace/.agents/skills/cleoedits/references/audio-clearervoice-elevenlabs.md +11 -0
  94. package/workspace/.agents/skills/cleoedits/references/ffmpeg-and-reels.md +15 -0
  95. package/workspace/.agents/skills/cleoedits/references/hyperframes-workflows.md +13 -0
  96. package/workspace/.agents/skills/cleoedits/references/kdenlive-cli-and-mcp.md +12 -0
  97. package/workspace/.agents/skills/cleoedits/references/motion-design-pipeline.md +7 -0
  98. package/workspace/.agents/skills/cleoedits/references/motion-taste-emil.md +5 -0
  99. package/workspace/.agents/skills/cleoedits/references/playwright-demo-capture.md +9 -0
  100. package/workspace/.agents/skills/cleoedits/references/remotion-workflows.md +13 -0
  101. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/LICENSE +21 -0
  102. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_ass_overlay.py +399 -0
  103. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/__init__.py +235 -0
  104. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/alpha.py +560 -0
  105. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/asr.py +1237 -0
  106. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/color.py +540 -0
  107. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/decision.py +2452 -0
  108. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/drawtext.py +290 -0
  109. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/emit.py +1309 -0
  110. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/emoji.py +518 -0
  111. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/fonts.py +875 -0
  112. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/pacing.py +263 -0
  113. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/pacing_edit.py +432 -0
  114. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/probe.py +1613 -0
  115. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/runner.py +3994 -0
  116. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/text.py +73 -0
  117. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/timeline.py +721 -0
  118. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/wrap.py +981 -0
  119. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_contract.py +2454 -0
  120. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_platforms.py +258 -0
  121. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_review.html +754 -0
  122. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_review.py +258 -0
  123. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_smartcut.py +450 -0
  124. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/audio.py +867 -0
  125. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/background.py +136 -0
  126. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/batch.py +1409 -0
  127. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/broll.py +282 -0
  128. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/caption.py +2207 -0
  129. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/check.py +815 -0
  130. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/color.py +695 -0
  131. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/crop.py +91 -0
  132. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/cropdetect.py +214 -0
  133. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/cut.py +2076 -0
  134. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/deinterlace.py +90 -0
  135. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/denoise.py +94 -0
  136. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/export.py +1033 -0
  137. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/fit.py +729 -0
  138. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/freeze.py +197 -0
  139. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/graphics.py +920 -0
  140. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/grid.py +235 -0
  141. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/insert.py +142 -0
  142. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/join.py +1083 -0
  143. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/look.py +475 -0
  144. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/loop.py +395 -0
  145. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/loudness.py +397 -0
  146. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/metadata.py +416 -0
  147. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/multicam.py +414 -0
  148. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/overlay.py +766 -0
  149. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/pad.py +121 -0
  150. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/probe.py +145 -0
  151. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/proxy.py +93 -0
  152. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/redact.py +162 -0
  153. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/render.py +2424 -0
  154. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/report.py +354 -0
  155. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/reverse.py +114 -0
  156. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/scenes.py +439 -0
  157. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/sequence.py +285 -0
  158. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/silence.py +945 -0
  159. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/speedramp.py +193 -0
  160. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/sphere.py +137 -0
  161. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/stabilize.py +141 -0
  162. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/straighten.py +120 -0
  163. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/sync.py +500 -0
  164. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/verify.py +411 -0
  165. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/waveform.py +502 -0
  166. package/workspace/.agents/skills/cleoedits/scripts/kdenlive_builder.py +284 -0
  167. package/workspace/.agents/skills/cleoedits/scripts/motion/LICENSE-claude-motion +21 -0
  168. package/workspace/.agents/skills/cleoedits/scripts/motion/LICENSE-motion-design +21 -0
  169. package/workspace/.agents/skills/cleoedits/scripts/motion/_media.py +43 -0
  170. package/workspace/.agents/skills/cleoedits/scripts/motion/pacing_check.py +90 -0
  171. package/workspace/.agents/skills/cleoedits/scripts/motion/storyboard.py +77 -0
  172. package/workspace/.agents/skills/cleoedits/scripts/reel_effects/LICENSE +26 -0
  173. package/workspace/.agents/skills/cleoedits/scripts/reel_effects/fx.py +2717 -0
  174. package/workspace/.agents/skills/cleoedits/scripts/reel_effects/logos.py +194 -0
  175. package/workspace/.agents/skills/cleoedits/scripts/reel_effects/sfx.py +105 -0
  176. package/workspace/.agents/skills/cleoedits/scripts/reel_effects/trim.py +99 -0
  177. package/workspace/.agents/skills/cleoedits/scripts/reel_effects/words.py +60 -0
  178. package/workspace/.claude/commands/blender-3d.md +12 -0
  179. package/workspace/.claude/commands/business-short-form-reels.md +12 -0
  180. package/workspace/.claude/commands/color-grade.md +12 -0
  181. package/workspace/.claude/commands/cutout-grid-reel.md +12 -0
  182. package/workspace/.claude/commands/depth-ui-reel.md +12 -0
  183. package/workspace/.claude/commands/explainer-panel-reel.md +12 -0
  184. package/workspace/.claude/commands/freeze-frame.md +12 -0
  185. package/workspace/.claude/commands/glass-graph.md +12 -0
  186. package/workspace/.claude/commands/over-the-shoulder.md +12 -0
  187. package/workspace/.claude/commands/personal-short-form-reels.md +12 -0
  188. package/workspace/.claude/commands/ranking-format.md +12 -0
  189. package/workspace/.claude/commands/relight.md +12 -0
  190. package/workspace/.claude/commands/reverse-engineer.md +12 -0
  191. package/workspace/.claude/commands/text-behind.md +12 -0
  192. package/workspace/.claude/commands/tier-list.md +12 -0
  193. package/workspace/.claude-plugin/plugin.json +8 -0
  194. package/workspace/.npmignore +15 -0
  195. package/workspace/AGENTS.md +30 -0
  196. package/workspace/README.md +63 -0
  197. package/workspace/assets/fonts/TikTokSans-OFL.txt +93 -0
  198. package/workspace/assets/fonts/TikTokSans-Variable.ttf +0 -0
  199. package/workspace/assets/luts/clean_warm.cube +4917 -0
  200. package/workspace/assets/luts/golden_hour.cube +4917 -0
  201. package/workspace/assets/luts/moody_dark.cube +4917 -0
  202. package/workspace/assets/luts/teal_orange.cube +4917 -0
  203. package/workspace/assets/sfx/NOTICE.txt +1 -0
  204. package/workspace/assets/sfx/click.wav +0 -0
  205. package/workspace/assets/sfx/pop.wav +0 -0
  206. package/workspace/assets/sfx/riser.wav +0 -0
  207. package/workspace/assets/sfx/whoosh.wav +0 -0
  208. package/workspace/generators/hyperframes/index.html +39 -0
  209. package/workspace/generators/hyperframes/package.json +15 -0
  210. package/workspace/generators/hyperframes/pnpm-lock.yaml +1181 -0
  211. package/workspace/generators/hyperframes/pnpm-workspace.yaml +10 -0
  212. package/workspace/generators/remotion/eslint.config.mjs +3 -0
  213. package/workspace/generators/remotion/package.json +36 -0
  214. package/workspace/generators/remotion/pnpm-lock.yaml +4179 -0
  215. package/workspace/generators/remotion/pnpm-workspace.yaml +10 -0
  216. package/workspace/generators/remotion/remotion.config.ts +13 -0
  217. package/workspace/generators/remotion/src/Root.tsx +52 -0
  218. package/workspace/generators/remotion/src/index.css +1 -0
  219. package/workspace/generators/remotion/src/index.ts +4 -0
  220. package/workspace/generators/remotion/tsconfig.json +15 -0
  221. package/workspace/pipeline/scripts/_codec.py +28 -0
  222. package/workspace/pipeline/scripts/ai_media_api.py +109 -0
  223. package/workspace/pipeline/scripts/blender_render.py +166 -0
  224. package/workspace/pipeline/scripts/composite.py +49 -0
  225. package/workspace/pipeline/scripts/melt.sh +68 -0
  226. package/workspace/pipeline/scripts/normalize_audio.py +39 -0
  227. package/workspace/pipeline/scripts/person_matte.py +216 -0
  228. package/workspace/pipeline/scripts/record_demo.py +69 -0
  229. package/workspace/pipeline/scripts/whisper_cut.py +98 -0
  230. package/workspace-manifest.json +908 -0
@@ -0,0 +1,1297 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=1920, height=1080" />
6
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bodoni+Moda:wght@400&family=JetBrains+Mono:wght@400&family=Jost:wght@500&family=Libre+Baskerville&family=Playfair+Display:ital,wght@1,400&family=Tenor+Sans&display=swap" />
7
+ <script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script>
8
+ <style>
9
+ * { margin: 0; padding: 0; box-sizing: border-box; }
10
+ html, body { width: 1920px; height: 1080px; overflow: hidden; background: #15120F; }
11
+ #root { position: relative; width: 1920px; height: 1080px; }
12
+ #fl { position:absolute; left:-9999px; top:0; }
13
+ #c { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; z-index: 1; }
14
+ #fg { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; z-index: 3; }
15
+ </style>
16
+ </head>
17
+ <body>
18
+ <div id="root" data-composition-id="main" data-start="0" data-duration="17" data-width="1920" data-height="1080">
19
+ <div id="fl"><span style="font-family:'Libre Baskerville'">a</span><span style="font-family:'Tenor Sans'">a</span><span style="font-family:'Bodoni Moda'">a</span><span style="font-family:'Playfair Display';font-style:italic">a</span><span style="font-family:'Jost';font-weight:500">a</span><span style="font-family:'JetBrains Mono'">a</span></div>
20
+ <canvas id="c" class="clip" width="1920" height="1080" data-start="0" data-duration="17" data-track-index="0"></canvas>
21
+ <canvas id="fg" class="clip" width="1920" height="1080" data-start="0" data-duration="17" data-track-index="2"></canvas>
22
+ </div>
23
+ <script>
24
+ /*
25
+ 30,000 years in 15 seconds. 17 s, 1920x1080, does not loop.
26
+ One camera rides one endless timeline. Every era is drawn by code in its own period style,
27
+ and one runner (one skeleton, one phase clock) is the hero of every era. Only its rendering changes.
28
+ Beat map (each era cut lands on a 0.5 s beat and is matched on shape):
29
+ 0.0 cave wall, hand stencils, bison | 2.5 black-figure vase | 4.5 zoetrope drum
30
+ 6.5 film strip, then projected screen | 8.5 CRT test card | 10.5 8-bit world
31
+ 12.5 cursor types draw(frame + 1); 13.4 the code draws the runner as one ivory line
32
+ 13.7 - 16.0 the line runner turns to camera and runs full frame
33
+ 16.0 - 17.0 pull back: all seven runners line up on the tilted timeline, running in step
34
+ Change the words: ERAS (year labels, fonts, start times) and CODE (the typed line).
35
+ Change the colours: INK and IVORY below, PAL (8-bit world), and the per-era colours inside each scene function.
36
+ Deterministic: seeded rng() and hash2() noise; every frame is a pure function of time.
37
+ */
38
+ (() => {
39
+ const W = 1920, H = 1080, DUR = 17;
40
+ const TAU = Math.PI * 2;
41
+ const INK = [21, 18, 15], IVORY = [243, 238, 228];
42
+ const cv = document.getElementById('c');
43
+ let ctx = cv.getContext('2d');
44
+ const BG = ctx, FG = document.getElementById('fg').getContext('2d');
45
+
46
+ const STATE = {};
47
+
48
+ // ---------------------------------------------------------------- utils
49
+ const clamp = (x, a = 0, b = 1) => (x < a ? a : x > b ? b : x);
50
+ const lerp = (a, b, t) => a + (b - a) * t;
51
+ const seg = (t, a, b) => clamp((t - a) / (b - a));
52
+ const sstep = (a, b, x) => { const t = seg(x, a, b); return t * t * (3 - 2 * t); };
53
+ const o3 = t => 1 - Math.pow(1 - t, 3);
54
+ const i3 = t => t * t * t;
55
+ const io3 = t => (t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2);
56
+ const oExpo = t => (t >= 1 ? 1 : 1 - Math.pow(2, -10 * t));
57
+ const io4 = t => (t < 0.5 ? 8 * t ** 4 : 1 - Math.pow(-2 * t + 2, 4) / 2);
58
+ const oBack = t => { const c1 = 1.5, c3 = c1 + 1; return 1 + c3 * Math.pow(t - 1, 3) + c1 * Math.pow(t - 1, 2); };
59
+ const mixc = (a, b, t) => [lerp(a[0], b[0], t), lerp(a[1], b[1], t), lerp(a[2], b[2], t)];
60
+ const rgba = (c, a = 1) => `rgba(${c[0] | 0},${c[1] | 0},${c[2] | 0},${a})`;
61
+ const hex = h => [parseInt(h.slice(1, 3), 16), parseInt(h.slice(3, 5), 16), parseInt(h.slice(5, 7), 16)];
62
+ function mk(w, h) { const c = document.createElement('canvas'); c.width = w; c.height = h; return c; }
63
+ function rng(seed) { let a = seed >>> 0; return () => { a = (a + 0x6D2B79F5) >>> 0; let t = a; t = Math.imul(t ^ (t >>> 15), t | 1); t ^= t + Math.imul(t ^ (t >>> 7), t | 61); return ((t ^ (t >>> 14)) >>> 0) / 4294967296; }; }
64
+ function hash2(x, y, s) { let h = Math.imul(x | 0, 374761393) ^ Math.imul(y | 0, 668265263) ^ Math.imul(s | 0, 1442695041); h = Math.imul(h ^ (h >>> 13), 1274126177); h ^= h >>> 16; return (h >>> 0) / 4294967296; }
65
+ function vnoise(x, y, s) {
66
+ const xi = Math.floor(x), yi = Math.floor(y), xf = x - xi, yf = y - yi;
67
+ const u = xf * xf * (3 - 2 * xf), v = yf * yf * (3 - 2 * yf);
68
+ const a = hash2(xi, yi, s), b = hash2(xi + 1, yi, s), c = hash2(xi, yi + 1, s), d = hash2(xi + 1, yi + 1, s);
69
+ return a + (b - a) * u + (c - a) * v + (a - b - c + d) * u * v;
70
+ }
71
+ function fbm(x, y, s, o) { let f = 0, amp = 0.5, fr = 1, n = 0; for (let i = 0; i < o; i++) { f += amp * vnoise(x * fr, y * fr, s + i * 17); n += amp; fr *= 2.03; amp *= 0.5; } return f / n; }
72
+
73
+ // ---------------------------------------------------------------- textures (built once, seeded)
74
+ const ROCK = (() => {
75
+ const w = 1500, h = 846, c = mk(w, h), x = c.getContext('2d'), im = x.createImageData(w, h), d = im.data;
76
+ const dk = [40, 26, 18], md = [112, 78, 52], lt = [190, 148, 104], oc = [150, 64, 36];
77
+ const NN = new Float32Array(w * h);
78
+ for (let j = 0; j < h; j++) for (let i = 0; i < w; i++) NN[j * w + i] = fbm(i / 190, j / 190, 3, 5);
79
+ for (let j = 0; j < h; j++) for (let i = 0; i < w; i++) {
80
+ const n = NN[j * w + i];
81
+ const nx = NN[j * w + Math.min(w - 1, i + 2)] - NN[j * w + Math.max(0, i - 2)], ny = NN[Math.min(h - 1, j + 2) * w + i] - NN[Math.max(0, j - 2) * w + i];
82
+ const fr2 = (vnoise((i + 1.5) / 11, j / 11, 21) - vnoise((i - 1.5) / 11, j / 11, 21)) - (vnoise(i / 11, (j + 1.5) / 11, 21) - vnoise(i / 11, (j - 1.5) / 11, 21));
83
+ const relief = clamp(1 + (-nx * 0.7 + ny * 0.7) * 12 - fr2 * 0.9, 0.5, 1.5);
84
+ const m = vnoise(i / 9, j / 9, 8) * 0.5 + vnoise(i / 3.2, j / 3.2, 9) * 0.3 + vnoise(i / 1.4, j / 1.4, 10) * 0.2;
85
+ const r = 1 - Math.abs(2 * fbm(i / 285 + 7, j / 285, 5, 3) - 1);
86
+ const st = sstep(0.56, 0.74, fbm(i / 400, j / 400 + 3, 11, 3));
87
+ const k = clamp(n * 1.35 - 0.2 + (m - 0.5) * 0.26);
88
+ let R, G, B;
89
+ if (k < 0.5) { const q = k / 0.5; R = lerp(dk[0], md[0], q); G = lerp(dk[1], md[1], q); B = lerp(dk[2], md[2], q); }
90
+ else { const q = (k - 0.5) / 0.5; R = lerp(md[0], lt[0], q); G = lerp(md[1], lt[1], q); B = lerp(md[2], lt[2], q); }
91
+ R = lerp(R, oc[0], st * 0.4); G = lerp(G, oc[1], st * 0.4); B = lerp(B, oc[2], st * 0.4);
92
+ const cr = (1 - 0.12 * sstep(0.97, 0.998, r)) * relief;
93
+ const p = (j * w + i) * 4; d[p] = R * cr; d[p + 1] = G * cr; d[p + 2] = B * cr; d[p + 3] = 255;
94
+ }
95
+ x.putImageData(im, 0, 0); return c;
96
+ })();
97
+
98
+ const GRAIN = [0, 1, 2, 3].map(k => {
99
+ const w = 960, h = 540, c = mk(w, h), x = c.getContext('2d'), im = x.createImageData(w, h), d = im.data, r = rng(1000 + k);
100
+ for (let i = 0; i < w * h; i++) { const v = 128 + (r() + r() - 1) * 120; d[i * 4] = d[i * 4 + 1] = d[i * 4 + 2] = v; d[i * 4 + 3] = 255; }
101
+ x.putImageData(im, 0, 0); return c;
102
+ });
103
+
104
+ // engraving hatch for 1834
105
+ const HATCH = (() => {
106
+ const c = mk(W, H), x = c.getContext('2d'); x.lineWidth = 1.1; x.strokeStyle = '#0a0604';
107
+ for (let k = -H; k < W + H; k += 7) {
108
+ for (let s = 0; s < 1500; s += 14) {
109
+ const px = k + s * 0.866, py = s * 0.5 - 60;
110
+ if (px < -20 || px > W + 20 || py < -20 || py > H + 20) continue;
111
+ const n = fbm(px / 420, py / 420, 41, 3);
112
+ const dist = Math.hypot((px - 760) / W, (py - 420) / H);
113
+ const a = clamp((dist * 1.1 + (n - 0.5) * 0.5) * 0.55, 0, 0.5);
114
+ x.globalAlpha = a; x.beginPath(); x.moveTo(px, py); x.lineTo(px + 14 * 0.866, py + 7); x.stroke();
115
+ }
116
+ }
117
+ return c;
118
+ })();
119
+
120
+ const SHADE = (() => {
121
+ const c = mk(512, 2), x = c.getContext('2d'), g = x.createLinearGradient(0, 0, 512, 0);
122
+ g.addColorStop(0, 'rgba(0,0,0,0.85)'); g.addColorStop(0.16, 'rgba(0,0,0,0.3)'); g.addColorStop(0.3, 'rgba(255,236,210,0.2)'); g.addColorStop(0.34, 'rgba(255,240,220,0.3)');
123
+ g.addColorStop(0.4, 'rgba(255,236,210,0.06)'); g.addColorStop(0.62, 'rgba(0,0,0,0.06)'); g.addColorStop(0.86, 'rgba(0,0,0,0.5)'); g.addColorStop(1, 'rgba(0,0,0,0.9)');
124
+ x.fillStyle = g; x.fillRect(0, 0, 512, 2); return c;
125
+ })();
126
+ const SHC = mk(W, H), shx = SHC.getContext('2d');
127
+ // walnut grain for the 1951 cabinet
128
+ const WOOD = (() => {
129
+ const w = 700, h = 450, c = mk(w, h), x = c.getContext('2d'), im = x.createImageData(w, h), d = im.data;
130
+ for (let j = 0; j < h; j++) for (let i = 0; i < w; i++) {
131
+ const n = fbm(i / 260, j / 26, 51, 4);
132
+ const g = 0.5 + 0.5 * Math.sin((j / 9 + n * 9));
133
+ const v = 0.55 + 0.25 * g + 0.2 * vnoise(i / 3, j / 1.5, 52);
134
+ const p = (j * w + i) * 4; d[p] = 92 * v; d[p + 1] = 54 * v; d[p + 2] = 32 * v; d[p + 3] = 255;
135
+ }
136
+ x.putImageData(im, 0, 0); return c;
137
+ })();
138
+
139
+ // hand stencils (negative, sprayed ochre)
140
+ function makeHand(seed, left) {
141
+ const s = 380, c = mk(s, s), x = c.getContext('2d'), r = rng(seed);
142
+ const cx = s / 2, cy = s / 2 + 20;
143
+ const g = x.createRadialGradient(cx, cy - 20, 20, cx, cy - 20, 175);
144
+ g.addColorStop(0, 'rgba(196,72,38,1)'); g.addColorStop(0.5, 'rgba(184,66,34,0.85)'); g.addColorStop(1, 'rgba(170,58,30,0)');
145
+ x.fillStyle = g; x.fillRect(0, 0, s, s);
146
+ for (let i = 0; i < 2600; i++) { const a = r() * TAU, rr = Math.pow(r(), 0.6) * 185; x.fillStyle = `rgba(140,44,24,${r() * 0.5})`; x.beginPath(); x.arc(cx + Math.cos(a) * rr, cy - 20 + Math.sin(a) * rr, r() * 2.4 + 0.4, 0, TAU); x.fill(); }
147
+ x.globalCompositeOperation = 'destination-out'; x.fillStyle = '#000';
148
+ x.beginPath(); x.ellipse(cx, cy + 30, 52, 62, 0, 0, TAU); x.fill();
149
+ x.fillRect(cx - 34, cy + 60, 66, 90);
150
+ const fingers = [[-40, -10, 0.5, 70], [-22, -40, 0.12, 92], [0, -48, 0, 100], [22, -42, -0.1, 92], [40, -20, -0.25, 74]];
151
+ x.lineCap = 'round'; x.strokeStyle = '#000';
152
+ fingers.forEach(([fx, fy, a, l], i) => {
153
+ const sx = left ? -fx : fx, aa = left ? -a : a;
154
+ const w = i === 0 ? 26 : 22;
155
+ x.lineWidth = w; x.beginPath();
156
+ const bx = cx + sx * 1.0, by = cy + 10 + fy * 0.3;
157
+ if (i === 0) { const tx = cx + (left ? 1 : -1) * 92, ty = cy + 6; x.moveTo(cx + (left ? 1 : -1) * 36, cy + 50); x.lineTo(tx, ty); }
158
+ else { x.moveTo(bx, by + 20); x.lineTo(bx - Math.sin(aa) * l, by - Math.cos(aa) * l); }
159
+ x.stroke();
160
+ });
161
+ x.globalCompositeOperation = 'source-over';
162
+ return c;
163
+ }
164
+ const HANDS = [makeHand(71, false), makeHand(72, true), makeHand(73, false)];
165
+
166
+ // ---------------------------------------------------------------- the one motif: a run cycle
167
+ const PHI = t => 1.5 * t; // cycles
168
+ function runPose(ph) {
169
+ const P = ph * TAU, lean = 0.2;
170
+ const bob = 0.022 * Math.cos(2 * P);
171
+ const hip = [0, -bob];
172
+ const sx = Math.sin(lean), sy = -Math.cos(lean);
173
+ const sh = [hip[0] + 0.29 * sx, hip[1] + 0.29 * sy];
174
+ const neck = [hip[0] + 0.335 * sx, hip[1] + 0.335 * sy];
175
+ const head = [hip[0] + 0.405 * sx + 0.01, hip[1] + 0.405 * sy];
176
+ const legs = [], arms = [];
177
+ for (let i = 0; i < 2; i++) {
178
+ const q = P + i * Math.PI;
179
+ const th = 0.16 + 0.64 * Math.sin(q);
180
+ const kn = 0.16 + 1.5 * Math.pow(Math.max(0, Math.cos(q - 0.45)), 1.3);
181
+ const knee = [hip[0] + 0.245 * Math.sin(th), hip[1] + 0.245 * Math.cos(th)];
182
+ const sa = th - kn;
183
+ const ank = [knee[0] + 0.245 * Math.sin(sa), knee[1] + 0.245 * Math.cos(sa)];
184
+ const fa = sa + Math.PI / 2 - 0.1;
185
+ const toe = [ank[0] + 0.07 * Math.sin(fa), ank[1] + 0.07 * Math.cos(fa)];
186
+ legs.push({ knee, ank, toe });
187
+ const qa = q + Math.PI;
188
+ const ua = -0.05 + 0.85 * Math.sin(qa);
189
+ const elb = [sh[0] + 0.16 * Math.sin(ua), sh[1] + 0.16 * Math.cos(ua)];
190
+ const f2 = ua + 1.6 + 0.25 * Math.sin(qa);
191
+ const hand = [elb[0] + 0.145 * Math.sin(f2), elb[1] + 0.145 * Math.cos(f2)];
192
+ arms.push({ elb, hand });
193
+ }
194
+ return { hip, sh, neck, head, legs, arms };
195
+ }
196
+ const GROUND = 0.475; // hip-to-ground in body heights
197
+
198
+ function bones(P) {
199
+ const b = [];
200
+ for (const i of [1, 0]) { const L = P.legs[i]; b.push([P.hip, L.knee, 0.085, i], [L.knee, L.ank, 0.058, i], [L.ank, L.toe, 0.034, i]); }
201
+ b.push([P.hip, P.sh, 0.11, 2], [P.sh, P.neck, 0.05, 2]);
202
+ for (const i of [1, 0]) { const A = P.arms[i]; b.push([P.sh, A.elb, 0.05, i], [A.elb, A.hand, 0.04, i]); }
203
+ return b;
204
+ }
205
+
206
+ function capsule(c, A, B, wa, wb) {
207
+ const dx = B[0] - A[0], dy = B[1] - A[1], l = Math.hypot(dx, dy) || 1e-3, nx = -dy / l, ny = dx / l;
208
+ c.beginPath(); c.moveTo(A[0] + nx * wa / 2, A[1] + ny * wa / 2); c.lineTo(B[0] + nx * wb / 2, B[1] + ny * wb / 2);
209
+ c.lineTo(B[0] - nx * wb / 2, B[1] - ny * wb / 2); c.lineTo(A[0] - nx * wa / 2, A[1] - ny * wa / 2); c.closePath(); c.fill();
210
+ c.beginPath(); c.arc(A[0], A[1], wa / 2, 0, TAU); c.fill(); c.beginPath(); c.arc(B[0], B[1], wb / 2, 0, TAU); c.fill();
211
+ }
212
+ // solid silhouette. X,Y = hip position, h = body height, sx = horizontal squash
213
+ function drawSil(c, P, X, Y, h, sx, col, wm = 1) {
214
+ const pt = p => [X + p[0] * h * sx, Y + p[1] * h];
215
+ c.fillStyle = col; const k = h * wm;
216
+ for (const i of [1, 0]) {
217
+ const L = P.legs[i];
218
+ capsule(c, pt(P.hip), pt(L.knee), 0.112 * k, 0.062 * k);
219
+ const mid = [lerp(L.knee[0], L.ank[0], 0.3), lerp(L.knee[1], L.ank[1], 0.3)];
220
+ capsule(c, pt(L.knee), pt(mid), 0.062 * k, 0.07 * k); capsule(c, pt(mid), pt(L.ank), 0.07 * k, 0.036 * k);
221
+ capsule(c, pt(L.ank), pt(L.toe), 0.042 * k, 0.026 * k);
222
+ }
223
+ const ch = [lerp(P.hip[0], P.sh[0], 0.62) + 0.012, lerp(P.hip[1], P.sh[1], 0.62)];
224
+ capsule(c, pt([P.hip[0] - 0.005, P.hip[1]]), pt(ch), 0.12 * k, 0.15 * k);
225
+ capsule(c, pt(ch), pt(P.sh), 0.15 * k, 0.11 * k);
226
+ capsule(c, pt(P.sh), pt(P.head), 0.05 * k, 0.045 * k);
227
+ for (const i of [1, 0]) { const A = P.arms[i]; capsule(c, pt(P.sh), pt(A.elb), 0.06 * k, 0.045 * k); capsule(c, pt(A.elb), pt(A.hand), 0.045 * k, 0.03 * k); }
228
+ const Hd = pt(P.head);
229
+ c.beginPath(); c.ellipse(Hd[0], Hd[1], Math.max(0.5, 0.056 * h * wm * Math.abs(sx)), 0.062 * h * wm, 0, 0, TAU); c.fill();
230
+ }
231
+ // black-figure incisions
232
+ function drawIncise(c, P, X, Y, h, sx, col) {
233
+ const pt = p => [X + p[0] * h * sx, Y + p[1] * h];
234
+ c.strokeStyle = col; c.lineWidth = Math.max(1, 0.008 * h); c.lineCap = 'round';
235
+ const L = P.legs[0], A = P.arms[0];
236
+ const line = (a, b, off) => { const A0 = pt(a), B0 = pt(b); const dx = B0[0] - A0[0], dy = B0[1] - A0[1], l = Math.hypot(dx, dy) || 1; const nx = -dy / l * off * h, ny = dx / l * off * h; c.beginPath(); c.moveTo(A0[0] + nx + dx * 0.15, A0[1] + ny + dy * 0.15); c.lineTo(B0[0] + nx - dx * 0.1, B0[1] + ny - dy * 0.1); c.stroke(); };
237
+ line(P.hip, L.knee, 0.018); line(L.knee, L.ank, 0.012); line(P.sh, A.elb, 0.01);
238
+ const K = pt(L.knee); c.beginPath(); c.arc(K[0], K[1], 0.018 * h, 0, TAU); c.stroke();
239
+ const S = pt([P.sh[0] + 0.01, P.sh[1] + 0.05]); c.beginPath(); c.arc(S[0], S[1], 0.04 * h, -0.4, 1.6); c.stroke();
240
+ const Hd = pt(P.head); c.beginPath(); c.arc(Hd[0], Hd[1] - 0.004 * h, 0.05 * h, Math.PI * 0.95, Math.PI * 2.05); c.stroke();
241
+ c.fillStyle = col; c.beginPath(); c.arc(Hd[0] + 0.025 * h * sx, Hd[1] - 0.008 * h, 0.009 * h, 0, TAU); c.fill();
242
+ }
243
+
244
+ // ---------------------------------------------------------------- bison (cave)
245
+ function crSample(P, closed, n) {
246
+ const out = [], N = P.length, cnt = closed ? N : N - 1;
247
+ const g = i => (closed ? P[(i + N) % N] : P[clamp(i, 0, N - 1)]);
248
+ for (let i = 0; i < cnt; i++) {
249
+ const p0 = g(i - 1), p1 = g(i), p2 = g(i + 1), p3 = g(i + 2);
250
+ for (let k = 0; k < n; k++) {
251
+ const s = k / n, s2 = s * s, s3 = s2 * s;
252
+ out.push([0, 1].map(d => 0.5 * ((2 * p1[d]) + (-p0[d] + p2[d]) * s + (2 * p0[d] - 5 * p1[d] + 4 * p2[d] - p3[d]) * s2 + (-p0[d] + 3 * p1[d] - 3 * p2[d] + p3[d]) * s3)));
253
+ }
254
+ }
255
+ out.push(closed ? out[0] : P[N - 1]);
256
+ return out;
257
+ }
258
+ const BISON_OUT = crSample([[-0.5, -0.03], [-0.47, -0.14], [-0.34, -0.19], [-0.15, -0.21], [0.0, -0.3], [0.12, -0.405], [0.24, -0.375], [0.33, -0.27], [0.4, -0.17], [0.47, -0.09], [0.55, 0.02], [0.575, 0.11], [0.545, 0.165], [0.48, 0.18], [0.45, 0.285], [0.39, 0.31], [0.34, 0.22], [0.22, 0.2], [0.05, 0.175], [-0.15, 0.15], [-0.32, 0.13], [-0.45, 0.1]], true, 10);
259
+ const BISON_HORN = crSample([[0.42, -0.13], [0.45, -0.21], [0.5, -0.25], [0.54, -0.23]], false, 8);
260
+ const BISON_TAILBASE = [-0.49, -0.06];
261
+ function bisonLegs(ph) {
262
+ const defs = [[-0.36, 0.08, 0.0, 1], [-0.29, 0.09, 0.09, 1], [0.24, 0.13, 0.42, 0], [0.31, 0.13, 0.52, 0]];
263
+ return defs.map(([hx, hy, off, hind]) => {
264
+ const q = (ph + off) * TAU;
265
+ let a1, a2;
266
+ if (hind) { a1 = -0.2 + 0.5 * Math.sin(q); a2 = a1 + 0.45 + 0.55 * Math.max(0, Math.cos(q + 0.4)); }
267
+ else { a1 = 0.08 + 0.55 * Math.sin(q); a2 = a1 - 1.25 * Math.pow(Math.max(0, Math.cos(q - 0.3)), 1.4); }
268
+ const l1 = hind ? 0.17 : 0.16, l2 = hind ? 0.19 : 0.18;
269
+ const k = [hx + l1 * Math.sin(a1), hy + l1 * Math.cos(a1)];
270
+ const f = [k[0] + l2 * Math.sin(a2), k[1] + l2 * Math.cos(a2)];
271
+ return { h: [hx, hy], k, f, hind };
272
+ });
273
+ }
274
+ function polyCum(pts) { const L = [0]; for (let i = 1; i < pts.length; i++) L.push(L[i - 1] + Math.hypot(pts[i][0] - pts[i - 1][0], pts[i][1] - pts[i - 1][1])); return L; }
275
+ function strokePartial(c, pts, frac) {
276
+ if (frac <= 0) return;
277
+ const cum = polyCum(pts), tgt = cum[cum.length - 1] * frac;
278
+ c.beginPath(); c.moveTo(pts[0][0], pts[0][1]);
279
+ for (let i = 1; i < pts.length; i++) {
280
+ if (cum[i] <= tgt) c.lineTo(pts[i][0], pts[i][1]);
281
+ else { const k = (tgt - cum[i - 1]) / (cum[i] - cum[i - 1]); c.lineTo(lerp(pts[i - 1][0], pts[i][0], k), lerp(pts[i - 1][1], pts[i][1], k)); break; }
282
+ }
283
+ c.stroke();
284
+ }
285
+ function charcoal(c, pts, frac, w, col, seed) {
286
+ for (let p = 0; p < 3; p++) {
287
+ const jit = pts.map((q, i) => [q[0] + (hash2(i, p, seed) - 0.5) * w * 0.5, q[1] + (hash2(i, p + 7, seed) - 0.5) * w * 0.5]);
288
+ c.lineWidth = w * [1, 0.6, 0.35][p]; c.globalAlpha = [0.55, 0.45, 0.6][p]; c.strokeStyle = col;
289
+ strokePartial(c, jit, frac);
290
+ }
291
+ c.globalAlpha = 1;
292
+ }
293
+ function bisonPath(BX, BY, L, bob) { const p = new Path2D(); BISON_OUT.forEach((q, i) => { const x = BX + q[0] * L, y = BY + q[1] * L + bob; i ? p.lineTo(x, y) : p.moveTo(x, y); }); p.closePath(); return p; }
294
+
295
+ // cave style bison; mode 'cave' (multiply on rock) or 'ink' (on dark, finale)
296
+ function drawBison(c, BX, BY, L, ph, run, rv, mode) {
297
+ const bob = -0.018 * L * Math.sin(2 * ph * TAU) * run;
298
+ const T = q => [BX + q[0] * L, BY + q[1] * L + bob];
299
+ const pOut = rv.out, pLeg = rv.leg, pFill = rv.fill, pDet = rv.det;
300
+ const cave = mode === 'cave';
301
+ const charc = cave ? '#140c07' : '#5a2a17';
302
+ c.save();
303
+ if (cave) c.globalCompositeOperation = 'multiply';
304
+ // legs (with ghost legs: the painters' eight-legged motion)
305
+ const legSet = (phase, alpha) => {
306
+ bisonLegs(phase).forEach(l => {
307
+ const A = T([l.h[0], l.h[1] + 0.03]), K = T(l.k), F = T(l.f);
308
+ c.globalAlpha = alpha * pLeg; c.fillStyle = cave ? '#1a110b' : '#c46a3c';
309
+ capsule(c, A, K, 0.06 * L, 0.03 * L);
310
+ capsule(c, K, F, 0.03 * L, 0.018 * L);
311
+ c.beginPath(); c.moveTo(F[0] - 0.018 * L, F[1] - 0.02 * L); c.lineTo(F[0] + 0.03 * L, F[1] + 0.012 * L); c.lineTo(F[0] - 0.022 * L, F[1] + 0.014 * L); c.closePath(); c.fill();
312
+ });
313
+ };
314
+ const path0 = bisonPath(BX, BY, L, bob);
315
+ if (run > 0) { c.save(); const o = new Path2D(); o.rect(BX - 2 * L, BY - 2 * L, 4 * L, 4 * L); o.addPath(path0); c.clip(o, 'evenodd'); legSet(ph - 0.1, 0.22 * run); legSet(ph - 0.2, 0.1 * run); c.restore(); }
316
+ c.globalAlpha = 1;
317
+ // fill
318
+ const path = bisonPath(BX, BY, L, bob);
319
+ if (pFill > 0) {
320
+ c.save(); c.clip(path); if (cave) { c.globalCompositeOperation = 'source-over'; c.globalAlpha = 0.82; }
321
+ const g = c.createLinearGradient(BX - 0.5 * L, BY - 0.38 * L, BX + 0.3 * L, BY + 0.2 * L);
322
+ if (cave) { g.addColorStop(0, `rgba(176,76,40,${pFill})`); g.addColorStop(0.45, `rgba(214,142,70,${pFill})`); g.addColorStop(1, `rgba(146,48,28,${pFill})`); }
323
+ else { g.addColorStop(0, `rgba(198,104,58,${pFill})`); g.addColorStop(0.5, `rgba(214,140,74,${pFill})`); g.addColorStop(1, `rgba(160,62,36,${pFill})`); }
324
+ c.fillStyle = g; c.fillRect(BX - 0.7 * L, BY - 0.6 * L, 1.4 * L, 1.1 * L);
325
+ // charcoal head + belly shading
326
+ const hg = c.createRadialGradient(BX + 0.5 * L, BY + 0.05 * L + bob, 0, BX + 0.5 * L, BY + 0.05 * L + bob, 0.28 * L);
327
+ hg.addColorStop(0, `rgba(20,12,8,${0.7 * pFill})`); hg.addColorStop(1, 'rgba(20,12,8,0)');
328
+ c.fillStyle = hg; c.fillRect(BX + 0.1 * L, BY - 0.4 * L, 0.6 * L, 0.8 * L);
329
+ const fq = c.createLinearGradient(BX + 0.05 * L, 0, BX + 0.5 * L, 0);
330
+ fq.addColorStop(0, 'rgba(20,12,8,0)'); fq.addColorStop(1, `rgba(20,12,8,${0.55 * pFill})`);
331
+ c.fillStyle = fq; c.fillRect(BX, BY - 0.5 * L, 0.7 * L, 1.0 * L);
332
+ const bg = c.createLinearGradient(0, BY + 0.05 * L, 0, BY + 0.22 * L);
333
+ bg.addColorStop(0, 'rgba(30,16,10,0)'); bg.addColorStop(1, `rgba(30,16,10,${0.55 * pFill})`);
334
+ c.fillStyle = bg; c.fillRect(BX - 0.6 * L, BY, 1.2 * L, 0.3 * L);
335
+ if (cave) {
336
+ c.globalAlpha = 0.5 * pFill; c.globalCompositeOperation = 'multiply'; c.drawImage(ROCK, BX - 1.1 * L, BY - 0.9 * L, 2.6 * L, 1.5 * L);
337
+ c.globalCompositeOperation = 'source-over'; c.globalAlpha = 0.35 * pFill; c.strokeStyle = '#2a140a'; c.lineWidth = 0.09 * L; c.filter = `blur(${0.03 * L}px)`; c.stroke(path); c.filter = 'none';
338
+ }
339
+ c.restore();
340
+ }
341
+ if (cave) c.globalCompositeOperation = 'multiply';
342
+ { c.save(); const outside = new Path2D(); outside.rect(BX - 2 * L, BY - 2 * L, 4 * L, 4 * L); outside.addPath(path); c.clip(outside, 'evenodd'); legSet(ph, 1); c.restore(); }
343
+ c.globalAlpha = 1;
344
+ // outline
345
+ const outPts = BISON_OUT.map(T);
346
+ charcoal(c, outPts, pOut, 0.026 * L, charc, 5);
347
+ // details
348
+ if (pDet > 0) {
349
+ charcoal(c, BISON_HORN.map(T), pDet, 0.03 * L, charc, 9);
350
+ charcoal(c, crSample([[-0.44, 0.04], [-0.3, 0.07], [-0.12, 0.05], [0.05, 0.09], [0.22, 0.1]], false, 6).map(T), pDet, 0.012 * L, charc, 13);
351
+ // tail
352
+ const sw = Math.sin(ph * TAU * 2) * 0.03 * run;
353
+ const tail = crSample([BISON_TAILBASE, [-0.55, 0.0 + sw], [-0.58, 0.1 + sw * 1.5], [-0.56, 0.17 + sw]], false, 6).map(T);
354
+ charcoal(c, tail, pDet, 0.016 * L, charc, 11);
355
+ // hump hair
356
+ c.globalAlpha = pDet * 0.8; c.strokeStyle = charc; c.lineWidth = 0.009 * L;
357
+ for (let i = 0; i < 9; i++) { const a = T([0.0 + i * 0.035, -0.29 - 0.08 * Math.sin(i / 8 * Math.PI)]); c.beginPath(); c.moveTo(a[0], a[1]); c.lineTo(a[0] + 0.015 * L, a[1] - 0.05 * L); c.stroke(); }
358
+ const E = T([0.47, -0.03]); c.fillStyle = cave ? '#0d0805' : '#2a120a'; c.beginPath(); c.arc(E[0], E[1], 0.012 * L, 0, TAU); c.fill();
359
+ c.globalAlpha = 1;
360
+ }
361
+ c.restore();
362
+ }
363
+
364
+ // ---------------------------------------------------------------- rotation clock (vase -> zoetrope -> film)
365
+ const OMEGA = t => 0.55 + 6.95 * sstep(4.0, 4.8, t) - 6.9 * sstep(5.85, 6.6, t);
366
+ const ROT = (() => { const dt = 1 / 480, arr = new Float32Array(Math.ceil(DUR * 480) + 2); let r = 0; for (let i = 0; i < arr.length; i++) { arr[i] = r; const t = 2.5 + i * dt; r += OMEGA(t) * dt; } return arr; })();
367
+ const rot = t => { if (t <= 2.5) return 0; const f = (t - 2.5) * 480, i = Math.floor(f); return lerp(ROT[i], ROT[i + 1], f - i); };
368
+
369
+ // ---------------------------------------------------------------- vessel (amphora -> zoetrope drum)
370
+ const VCX = 960, VCY = 490, VH = 820, TILT = 0.13;
371
+ const VASE_K = crSample([[-0.5, 0.165], [-0.475, 0.16], [-0.445, 0.122], [-0.3, 0.118], [-0.21, 0.22], [-0.11, 0.335], [0.0, 0.375], [0.12, 0.35], [0.24, 0.27], [0.34, 0.17], [0.405, 0.105], [0.445, 0.11], [0.468, 0.17], [0.5, 0.17]], false, 8);
372
+ function tableInterp(tab, y) { if (y <= tab[0][0]) return tab[0][1]; for (let i = 1; i < tab.length; i++) if (tab[i][0] >= y) { const a = tab[i - 1], b = tab[i]; return lerp(a[1], b[1], (y - a[0]) / ((b[0] - a[0]) || 1)); } return tab[tab.length - 1][1]; }
373
+ const DRUM_K = [[-0.5, 0.4], [-0.3, 0.4], [0.08, 0.4], [0.0802, 0.03], [0.19, 0.03], [0.2, 0.2], [0.26, 0.2], [0.2601, 0.0], [0.5, 0.0]];
374
+ const rVase = y => tableInterp(VASE_K, y), rDrum = y => tableInterp(DRUM_K, y);
375
+
376
+ function cyl(R, a, y) { return [VCX + R * Math.sin(a), y + R * TILT * Math.cos(a), Math.cos(a)]; }
377
+
378
+ function drawRunnerOnCyl(c, R, ang, gy, h, ph, col, inc) {
379
+ const ca = Math.cos(ang); if (ca < 0.06) return;
380
+ const x = VCX + R * Math.sin(ang), y = gy + R * TILT * ca;
381
+ const P = runPose(ph);
382
+ drawSil(c, P, x, y - GROUND * h, h, ca, col);
383
+ if (inc) drawIncise(c, P, x, y - GROUND * h, h, ca, inc);
384
+ }
385
+
386
+ function bandPath(R1, R2, y1, y2) {
387
+ const p = new Path2D(); const n = 36;
388
+ for (let i = 0; i <= n; i++) { const a = -Math.PI / 2 + Math.PI * i / n; const q = cyl(R1 * 1.04, a, y1); i ? p.lineTo(q[0], q[1]) : p.moveTo(q[0], q[1]); }
389
+ for (let i = n; i >= 0; i--) { const a = -Math.PI / 2 + Math.PI * i / n; const q = cyl(R2 * 1.04, a, y2); p.lineTo(q[0], q[1]); }
390
+ p.closePath(); return p;
391
+ }
392
+ function ringLine(c, R, y, w, col) { c.strokeStyle = col; c.lineWidth = w; c.beginPath(); for (let i = 0; i <= 40; i++) { const a = -Math.PI / 2 + Math.PI * i / 40; const q = cyl(R, a, y); i ? c.lineTo(q[0], q[1]) : c.moveTo(q[0], q[1]); } c.stroke(); }
393
+
394
+ const TERRA = hex('#B95F35'), TERRA_HI = hex('#D88B5C'), GLAZE = hex('#17110E'), WALNUT = hex('#4A2B18'), BRASS = hex('#C9A15A');
395
+
396
+ function drawVessel(c, t, u, R0) {
397
+ const ytop = lerp(-0.5, -0.3, u), ybot = lerp(0.5, 0.26, u);
398
+ const rr = y => lerp(rVase(y), rDrum(y), u) * VH;
399
+ const Y = yn => VCY + yn * VH;
400
+ // silhouette = union of discs
401
+ const sil = new Path2D(); const N = 120;
402
+ for (let i = 0; i <= N; i++) { const yn = lerp(ytop, ybot, i / N); const r = rr(yn); if (r < 0.5) continue; sil.moveTo(VCX + r, Y(yn)); sil.ellipse(VCX, Y(yn), r, r * TILT + 0.5, 0, 0, TAU); sil.closePath(); }
403
+ // floor shadow
404
+ c.save(); const fs = c.createRadialGradient(VCX, Y(ybot) + 6, 10, VCX, Y(ybot) + 6, 380);
405
+ fs.addColorStop(0, 'rgba(0,0,0,0.6)'); fs.addColorStop(1, 'rgba(0,0,0,0)'); c.fillStyle = fs; c.beginPath(); c.ellipse(VCX, Y(ybot) + 8, 380, 60, 0, 0, TAU); c.fill(); c.restore();
406
+
407
+ c.save(); c.clip(sil);
408
+ const base = mixc(GLAZE, WALNUT, u);
409
+ c.fillStyle = rgba(base); c.fillRect(0, 0, W, H);
410
+ const decoA = 1 - u;
411
+ const RB = rr(0.03); // frieze radius
412
+ if (decoA > 0.01) {
413
+ c.globalAlpha = decoA;
414
+ const terra = rgba(TERRA);
415
+ c.fillStyle = terra;
416
+ c.fill(bandPath(rr(-0.24), rr(-0.105), Y(-0.24), Y(-0.105)));
417
+ c.fill(bandPath(rr(-0.085), rr(0.155), Y(-0.085), Y(0.155)));
418
+ c.fill(bandPath(rr(0.175), rr(0.345), Y(0.175), Y(0.345)));
419
+ const rot0 = R0;
420
+ // tongues on shoulder
421
+ c.fillStyle = rgba(GLAZE);
422
+ for (let k = 0; k < 36; k++) {
423
+ const a = k / 36 * TAU - rot0; if (Math.cos(a) < 0.03) continue;
424
+ const yA = -0.235, yB = -0.135; const R = rr(-0.19);
425
+ const p1 = cyl(rr(yA), a, Y(yA)), p2 = cyl(R, a, Y(yB));
426
+ c.beginPath(); c.ellipse((p1[0] + p2[0]) / 2, (p1[1] + p2[1]) / 2, Math.max(0.5, 0.055 * R * Math.cos(a)), (p2[1] - p1[1]) / 2, 0, 0, TAU); c.fill();
427
+ }
428
+ ringLine(c, rr(-0.12), Y(-0.12), 4, rgba(GLAZE));
429
+ // meander band
430
+ const yM = 0.19, hM = 0.05, Rm = rr(0.21), unit = 0.075;
431
+ c.strokeStyle = rgba(GLAZE); c.lineWidth = 4.5; c.lineJoin = 'miter';
432
+ const key = [[0, 1], [0, 0], [0.8, 0], [0.8, 0.75], [0.3, 0.75], [0.3, 0.3], [0.55, 0.3], [0.55, 0.52]];
433
+ const nU = Math.round(TAU / unit);
434
+ for (let k = 0; k < nU; k++) {
435
+ const a0 = k * TAU / nU - rot0;
436
+ if (Math.cos(a0) < -0.05) continue;
437
+ c.beginPath();
438
+ key.forEach((q, i) => { const a = a0 + q[0] * TAU / nU; const p = cyl(Rm, a, Y(yM + q[1] * hM)); i ? c.lineTo(p[0], p[1]) : c.moveTo(p[0], p[1]); });
439
+ c.stroke();
440
+ c.beginPath(); { const p = cyl(Rm, a0, Y(yM + hM)), p2 = cyl(Rm, a0 + TAU / nU, Y(yM + hM)); c.moveTo(p[0], p[1]); c.lineTo(p2[0], p2[1]); } c.stroke();
441
+ }
442
+ // rays
443
+ c.fillStyle = rgba(GLAZE);
444
+ for (let k = 0; k < 28; k++) {
445
+ const a = k / 28 * TAU - rot0; if (Math.cos(a) < 0.0) continue;
446
+ const w = 0.09; const yb = 0.34, ya = 0.255;
447
+ const b1 = cyl(rr(yb), a - w, Y(yb)), b2 = cyl(rr(yb), a + w, Y(yb)), ap = cyl(rr(ya), a, Y(ya));
448
+ c.beginPath(); c.moveTo(b1[0], b1[1]); c.lineTo(ap[0], ap[1]); c.lineTo(b2[0], b2[1]); c.closePath(); c.fill();
449
+ }
450
+ ringLine(c, rr(-0.085), Y(-0.08), 4, rgba(GLAZE));
451
+ ringLine(c, rr(0.155), Y(0.152), 5, rgba(GLAZE));
452
+ // frieze runners
453
+ for (let k = 0; k < 6; k++) drawRunnerOnCyl(c, RB, k * TAU / 6 - rot0, Y(0.148), 0.205 * VH, PHI(t) + k * 0.19, rgba(GLAZE), rgba(TERRA));
454
+ c.globalAlpha = 1;
455
+ }
456
+ // drum furniture: brass rims
457
+ if (u > 0.01) {
458
+ c.globalAlpha = u;
459
+ const Rd = rr(-0.1);
460
+ c.fillStyle = rgba(BRASS);
461
+ c.fill(bandPath(Rd, Rd, Y(-0.3), Y(-0.284)));
462
+ c.fill(bandPath(Rd, Rd, Y(0.062), Y(0.082)));
463
+ c.globalAlpha = 1;
464
+ }
465
+ // per-row cylindrical shading
466
+ {
467
+ const yA = Math.floor(Y(ytop) - 0.5 * VH * TILT), yB = Math.ceil(Y(ybot) + 0.45 * VH * TILT);
468
+ shx.setTransform(1, 0, 0, 1, 0, 0); shx.clearRect(0, 0, W, H);
469
+ for (let y = yA; y < yB; y += 2) {
470
+ // radius of the widest disc whose front arc covers this row
471
+ let yn = (y - VCY) / VH; let r = 0;
472
+ for (let d = 0; d <= 0.06; d += 0.006) { const yy = yn - d; if (yy < ytop || yy > ybot) continue; r = Math.max(r, rr(yy)); }
473
+ if (r < 2) continue;
474
+ shx.drawImage(SHADE, VCX - r - 1, y, 2 * r + 2, 2);
475
+ }
476
+ c.drawImage(SHC, 0, 0);
477
+ }
478
+ c.restore();
479
+ // lip / opening
480
+ const rt = rr(ytop);
481
+ c.fillStyle = rgba(mixc([12, 8, 6], [18, 11, 7], u)); c.beginPath(); c.ellipse(VCX, Y(ytop), rt * 0.93, rt * TILT * 0.93, 0, 0, TAU); c.fill();
482
+ c.strokeStyle = rgba(mixc([60, 40, 30], BRASS, u), 0.9); c.lineWidth = lerp(3, 7, u); c.beginPath(); c.ellipse(VCX, Y(ytop), rt * 0.965, rt * TILT * 0.965, 0, 0, TAU); c.stroke();
483
+ // handles (vase only)
484
+ if (u < 0.99) {
485
+ c.globalAlpha = 1 - u; c.strokeStyle = rgba(GLAZE); c.lineCap = 'round'; c.lineWidth = 20;
486
+ for (const s of [-1, 1]) { c.beginPath(); c.moveTo(VCX + s * rr(-0.4) * 0.95, Y(-0.4)); c.bezierCurveTo(VCX + s * 0.27 * VH, Y(-0.44), VCX + s * 0.31 * VH, Y(-0.32), VCX + s * rr(-0.2) * 0.98, Y(-0.2)); c.stroke(); }
487
+ c.globalAlpha = 1;
488
+ }
489
+ }
490
+
491
+ // ---------------------------------------------------------------- slits -> film strip
492
+ const NS = 14, SLIT_W = 0.15, BAND_A = -0.282, BAND_B = 0.058;
493
+ function filmFrame(c, x, y, w, h, ph, look, seed) {
494
+ // look 0 = zoetrope interior (cream paper, sepia figure); 1 = film positive (Muybridge grid)
495
+ c.save(); c.beginPath(); c.rect(x, y, w, h); c.clip();
496
+ const bg = mixc([234, 218, 186], [34, 33, 31], look);
497
+ c.fillStyle = rgba(bg); c.fillRect(x, y, w, h);
498
+ if (look > 0.01) {
499
+ c.globalAlpha = look * 0.5; c.strokeStyle = '#d8d4c8'; c.lineWidth = Math.max(1, w / 260);
500
+ const step = w / 9; for (let i = 1; i < 9; i++) { c.beginPath(); c.moveTo(x + i * step, y); c.lineTo(x + i * step, y + h * 0.78); c.stroke(); }
501
+ c.beginPath(); c.moveTo(x, y + h * 0.4); c.lineTo(x + w, y + h * 0.4); c.stroke();
502
+ c.globalAlpha = look; c.fillStyle = '#4d4a45'; c.fillRect(x, y + h * 0.8, w, h * 0.2);
503
+ c.globalAlpha = 1;
504
+ }
505
+ const fh = h * 0.78, P = runPose(ph);
506
+ if (!STATE.noFig) drawSil(c, P, x + w * 0.5, y + h * 0.8 - GROUND * fh, fh, 1, rgba(mixc([54, 33, 20], [228, 224, 214], look)));
507
+ c.restore();
508
+ }
509
+
510
+ // ---------------------------------------------------------------- scenes
511
+ function camera(c, F, z) { c.translate(960, 540); c.scale(z, z); c.translate(-F[0], -F[1]); }
512
+
513
+ function sceneCave(t) {
514
+ const light = lerp(0.45, 1, sstep(0, 0.5, t));
515
+ const push = i3(seg(t, 2.0, 2.5));
516
+ const drift = -64 * t;
517
+ const L = 830, BX = 1000 + drift, BY = 470;
518
+ const legF = [BX - 0.02 * L, BY + 0.36 * L];
519
+ const z = (1.0 + 0.03 * t) * lerp(1, 1.9, push);
520
+ const F = [lerp(960, legF[0], push), lerp(540, legF[1], push)];
521
+ ctx.save(); camera(ctx, F, z);
522
+ ctx.drawImage(ROCK, -80 + drift, -90, 2200, 1240);
523
+ // hand stencils
524
+ const hands = [[400, 310, -0.35, 1.25, -1], [1540, 270, 0.3, 1.1, 0.5], [1600, 760, -0.1, 1.0, 1.0]];
525
+ ctx.save();
526
+ hands.forEach(([hx, hy, a, s, ts], i) => {
527
+ const p = seg(t, ts, ts + 0.22); if (p <= 0) return;
528
+ const e = o3(p); ctx.save(); ctx.globalAlpha = e * 0.88; ctx.translate(hx + drift, hy); ctx.rotate(a); const sc = s * lerp(1.12, 1, e); ctx.scale(sc, sc); ctx.drawImage(HANDS[i], -190, -190); ctx.restore();
529
+ });
530
+ ctx.restore();
531
+ // bison
532
+ const g = t < 1.35 ? 0 : t < 1.65 ? (t - 1.35) ** 2 / 0.6 : (t - 1.65) + 0.15;
533
+ const ph = 0.15 + 1.5 * g;
534
+ const rv = { out: o3(seg(t, 0.72, 1.4)), leg: o3(seg(t, 1.05, 1.4)), fill: o3(seg(t, 1.25, 1.7)), det: o3(seg(t, 1.2, 1.5)) };
535
+ drawBison(ctx, BX, BY, L, ph, sstep(1.35, 1.7, t), rv, 'cave');
536
+ ctx.restore();
537
+ // firelight
538
+ const fl = 0.86 + 0.07 * Math.sin(t * 13.1) + 0.05 * Math.sin(t * 23.7 + 1) + 0.04 * Math.sin(t * 7.3 + 2);
539
+ ctx.save(); ctx.globalCompositeOperation = 'multiply';
540
+ const lg = ctx.createRadialGradient(820, 1060, 60, 900, 760, 1450 * fl);
541
+ lg.addColorStop(0, 'rgb(255,230,190)'); lg.addColorStop(0.45, 'rgb(236,184,132)'); lg.addColorStop(0.78, 'rgb(130,84,54)'); lg.addColorStop(1, 'rgb(40,26,18)');
542
+ ctx.fillStyle = lg; ctx.fillRect(0, 0, W, H);
543
+ ctx.globalCompositeOperation = 'screen';
544
+ const sg = ctx.createRadialGradient(480, 1100, 0, 480, 1100, 700);
545
+ sg.addColorStop(0, `rgba(255,150,60,${0.22 * fl})`); sg.addColorStop(1, 'rgba(255,150,60,0)');
546
+ ctx.fillStyle = sg; ctx.fillRect(0, 0, W, H);
547
+ // terracotta warming before the cut
548
+ if (push > 0) { ctx.globalCompositeOperation = 'multiply'; ctx.fillStyle = `rgba(214,120,72,${0.6 * push})`; ctx.fillRect(0, 0, W, H); }
549
+ ctx.restore();
550
+ if (light < 1) { ctx.fillStyle = rgba(INK, 1 - light); ctx.fillRect(0, 0, W, H); }
551
+ }
552
+
553
+ function museumBg(c, warm, cool) {
554
+ c.fillStyle = rgba(INK); c.fillRect(0, 0, W, H);
555
+ const g = c.createRadialGradient(900, 420, 40, 960, 520, 1100);
556
+ g.addColorStop(0, rgba(warm)); g.addColorStop(0.55, rgba(mixc(warm, INK, 0.65))); g.addColorStop(1, rgba(cool));
557
+ c.fillStyle = g; c.fillRect(0, 0, W, H);
558
+ }
559
+
560
+ function sceneVessel(t) {
561
+ // 2.5 .. 7.6 : amphora -> zoetrope -> film strip
562
+ const u = io3(seg(t, 4.35, 4.75)); // vase -> drum
563
+ const v = io3(seg(t, 6.05, 6.65)); // drum -> flat film
564
+ const R0 = rot(t);
565
+ const reveal = oExpo(seg(t, 2.5, 3.35));
566
+ const runnerH = 0.205 * VH, frontGy = VCY + 0.148 * VH + 0.37 * VH * TILT;
567
+ const closeF = [VCX + 0.03 * runnerH, frontGy - 0.32 * runnerH];
568
+ let z = lerp(3.1, 1.04, reveal) * (1 + 0.075 * sstep(3.2, 4.4, t));
569
+ let F = [lerp(closeF[0], 960 + 30 * sstep(3.2, 4.4, t), reveal), lerp(closeF[1], 470, reveal)];
570
+ const zz = io3(seg(t, 4.3, 5.0)); z = lerp(z, 1.42, zz); F = [F[0], lerp(F[1], 410, zz)];
571
+ const zf = io3(seg(t, 5.85, 6.65)); z = lerp(z, 2.35, zf); F = [F[0], lerp(F[1], VCY + (BAND_A + BAND_B) / 2 * VH, zf)];
572
+ // background: museum -> lamplit engraving -> dark theatre
573
+ const zoeA = sstep(4.4, 4.9, t), filmA = sstep(6.2, 6.7, t);
574
+ museumBg(ctx, mixc([74, 50, 36], [92, 66, 40], zoeA), [14, 11, 9]);
575
+ if (zoeA > 0) { ctx.globalAlpha = zoeA * 0.9 * (1 - filmA); ctx.drawImage(HATCH, 0, 0); ctx.globalAlpha = 1; }
576
+ // gallery spotlight + drifting dust
577
+ const spot = 1 - filmA;
578
+ if (spot > 0) {
579
+ ctx.save(); ctx.globalCompositeOperation = 'screen';
580
+ const sg = ctx.createLinearGradient(0, 0, 0, 900);
581
+ sg.addColorStop(0, `rgba(255,226,186,${0.1 * spot})`); sg.addColorStop(1, 'rgba(255,226,186,0)');
582
+ ctx.fillStyle = sg; ctx.beginPath(); ctx.moveTo(760, -10); ctx.lineTo(1160, -10); ctx.lineTo(1500, 960); ctx.lineTo(420, 960); ctx.closePath(); ctx.fill();
583
+ for (let k = 0; k < 70; k++) {
584
+ const bx = 520 + hash2(k, 1, 41) * 880, by = ((hash2(k, 2, 41) * 960 - t * (14 + 26 * hash2(k, 3, 41))) % 960 + 960) % 960;
585
+ const xx = bx + Math.sin(t * 0.9 + k) * 14 + (by / 960 - 0.5) * (bx - 960) * 0.4;
586
+ ctx.fillStyle = `rgba(255,236,206,${spot * (0.15 + 0.4 * hash2(k, 4, 41))})`;
587
+ ctx.beginPath(); ctx.arc(xx, by, 0.8 + 1.6 * hash2(k, 5, 41), 0, TAU); ctx.fill();
588
+ }
589
+ ctx.restore();
590
+ }
591
+ if (filmA > 0) { ctx.fillStyle = rgba([12, 11, 10], filmA); ctx.fillRect(0, 0, W, H); }
592
+ ctx.save(); camera(ctx, F, z);
593
+ if (v < 1) { ctx.save(); ctx.globalAlpha = 1 - v; drawVessel(ctx, t, u, R0); ctx.restore(); }
594
+ // windows (slits -> frames)
595
+ if (u > 0.01) {
596
+ const R = 0.4 * VH, Y = yn => VCY + yn * VH;
597
+ const ve = v;
598
+ const pitch = TAU * R / NS;
599
+ const stripH = lerp((BAND_B - BAND_A) * VH, 470 / 2.35, ve), stripC = lerp(Y((BAND_A + BAND_B) / 2), F[1], ve);
600
+ const frameH = lerp((BAND_B - BAND_A) * VH * 0.98, stripH * 0.66, ve);
601
+ if (ve > 0) {
602
+ ctx.fillStyle = rgba([10, 10, 10], ve); ctx.fillRect(F[0] - 1200 / z * 1.2, stripC - stripH / 2, 2400 / z * 1.2, stripH);
603
+ ctx.fillStyle = rgba([60, 58, 55], ve * 0.6); ctx.fillRect(F[0] - 1200, stripC - stripH / 2, 2400, 2); ctx.fillRect(F[0] - 1200, stripC + stripH / 2 - 2, 2400, 2);
604
+ }
605
+ const strobe = Math.floor(R0 / (TAU / NS)) / NS; // zoetrope frame stepping
606
+ const wins = [];
607
+ for (let j = 0; j < NS * 3; j++) {
608
+ const jj = j - NS; // allow wrap copies in flat mode
609
+ let a = (jj * TAU / NS) - R0; a = Math.atan2(Math.sin(a), Math.cos(a)) + Math.round(jj / NS) * 0; // wrapped
610
+ if (j !== NS + ((j - NS) % NS + NS) % NS - 0) { }
611
+ const ca = Math.cos(a);
612
+ if (j < NS || j >= 2 * NS) {
613
+ // extra copies only used in flat mode to tile the screen
614
+ if (ve < 0.02) continue;
615
+ a = a + (j < NS ? -TAU : TAU);
616
+ }
617
+ const xc = lerp(VCX + R * Math.sin(a), VCX + a * R, ve);
618
+ const vis = ve > 0.02 ? 1 : (ca > 0.05 ? 1 : 0);
619
+ if (!vis) continue;
620
+ const wsl = lerp(R * SLIT_W * Math.max(0, ca) * sstep(0.45, 1, u), pitch * 0.86, ve);
621
+ const yc = lerp(Y((BAND_A + BAND_B) / 2) + R * TILT * Math.max(0, ca), stripC, ve);
622
+ if (Math.abs(xc - F[0]) > 1100 / z + 400) continue;
623
+ wins.push({ xc, yc, w: wsl, h: frameH, a, j: ((jj % NS) + NS) % NS, ca });
624
+ }
625
+ for (const wn of wins) {
626
+ const look = ve;
627
+ const contentX = lerp(VCX, wn.xc, ve);
628
+ const ph = lerp(strobe * 1 + 0.1, wn.j / NS + 0.1, ve);
629
+ ctx.save(); ctx.beginPath(); ctx.rect(wn.xc - wn.w / 2, wn.yc - wn.h / 2, wn.w, wn.h); ctx.clip();
630
+ const fw = lerp(0.62 * VH, wn.w, ve), fx = contentX - fw / 2;
631
+ filmFrame(ctx, fx, wn.yc - wn.h / 2, fw, wn.h, ph, look, wn.j);
632
+ // interior shading inside drum
633
+ if (ve < 1) { ctx.fillStyle = `rgba(30,18,10,${(1 - ve) * (1 - Math.max(0, wn.ca)) * 0.7})`; ctx.fillRect(wn.xc - wn.w / 2, wn.yc - wn.h / 2, wn.w, wn.h); }
634
+ ctx.restore();
635
+ // sprocket holes
636
+ if (ve > 0.02) {
637
+ for (let k = 0; k < 4; k++) {
638
+ const hx = wn.xc - pitch / 2 + (k + 0.5) * pitch / 4, hw = pitch / 4 * 0.42 * ve, hh = stripH * 0.075 * ve;
639
+ for (const sy of [-1, 1]) {
640
+ const hy = stripC + sy * (stripH / 2 - stripH * 0.085);
641
+ ctx.fillStyle = rgba([250, 238, 214], ve); ctx.beginPath(); ctx.roundRect(hx - hw / 2, hy - hh / 2, hw, hh, hw * 0.25); ctx.fill();
642
+ }
643
+ }
644
+ }
645
+ }
646
+ // persistence-of-vision ghost over the spinning drum
647
+ const ghost = u * (1 - ve) * sstep(4.7, 5.2, t);
648
+ if (ghost > 0) {
649
+ const fh = frameH * 0.78;
650
+ layer(ctx, 0.26 * ghost, b => drawSil(b, runPose(strobe + 0.1), VCX, Y(BAND_B) - 0.02 * fh - GROUND * fh + R * TILT * 0.5, fh, 1, '#F3E3C0'), 'screen');
651
+ }
652
+ }
653
+ ctx.restore();
654
+ return { z, F };
655
+ }
656
+
657
+ // projected screen geometry
658
+ const PROJ = { x: 413, y: 84, w: 1094, h: 820 };
659
+ const CRT = { x: 360, y: 150, w: 940, h: 704 };
660
+
661
+ function muybridge(c, r, ph, t, look) {
662
+ // r: rect, look: 0 film, 1 phosphor test card
663
+ const fr = Math.floor(t * 30);
664
+ const flick = 0.9 + 0.1 * hash2(fr, 3, 7);
665
+ const wx = (hash2(fr, 1, 9) - 0.5) * 3, wy = (hash2(fr, 2, 9) - 0.5) * 3;
666
+ c.save(); c.beginPath(); c.rect(r.x, r.y, r.w, r.h); c.clip();
667
+ c.translate(wx, wy);
668
+ filmFrame(c, r.x - 4, r.y - 4, r.w + 8, r.h + 8, ph, 1, 0);
669
+ // scratches + dust
670
+ c.strokeStyle = 'rgba(240,236,226,0.35)'; c.lineWidth = 1.2;
671
+ for (let k = 0; k < 3; k++) { if (hash2(fr, k, 13) < 0.5) continue; const sx = r.x + hash2(fr, k, 14) * r.w; c.beginPath(); c.moveTo(sx, r.y); c.lineTo(sx + 4, r.y + r.h); c.stroke(); }
672
+ c.fillStyle = 'rgba(10,10,10,0.7)';
673
+ for (let k = 0; k < 6; k++) { const dx = r.x + hash2(fr, k, 15) * r.w, dy = r.y + hash2(fr, k, 16) * r.h; c.beginPath(); c.arc(dx, dy, 1 + hash2(fr, k, 17) * 3, 0, TAU); c.fill(); }
674
+ // vignette + flicker
675
+ const vg = c.createRadialGradient(r.x + r.w / 2, r.y + r.h / 2, r.h * 0.3, r.x + r.w / 2, r.y + r.h / 2, r.w * 0.75);
676
+ vg.addColorStop(0, 'rgba(0,0,0,0)'); vg.addColorStop(1, 'rgba(0,0,0,0.75)'); c.fillStyle = vg; c.fillRect(r.x, r.y, r.w, r.h);
677
+ c.fillStyle = `rgba(255,244,222,${(flick - 0.9) * 0.9})`; c.fillRect(r.x, r.y, r.w, r.h);
678
+ c.restore();
679
+ }
680
+
681
+ function sceneFilm(t, vesselCam) {
682
+ // 7.0 .. 8.85 : one frame becomes the projected screen
683
+ const p = io3(seg(t, 7.0, 7.55));
684
+ const z = vesselCam ? vesselCam.z : 2.35;
685
+ const fw = TAU * 0.4 * VH / NS * 0.86 * z, fh = (470 / 2.35) * 0.66 * z;
686
+ const from = { x: 960 - fw / 2, y: 540 - fh / 2, w: fw, h: fh };
687
+ const pz = 1 + 0.04 * seg(t, 7.55, 8.4);
688
+ const r0 = { x: lerp(from.x, PROJ.x, p), y: lerp(from.y, PROJ.y, p), w: lerp(from.w, PROJ.w, p), h: lerp(from.h, PROJ.h, p) };
689
+ const r = { x: r0.x + r0.w / 2 - r0.w * pz / 2, y: r0.y + r0.h / 2 - r0.h * pz / 2, w: r0.w * pz, h: r0.h * pz };
690
+ STATE.film = r;
691
+ // beam
692
+ const beam = sstep(7.1, 7.6, t) * (1 - sstep(8.4, 8.75, t));
693
+ if (beam > 0) {
694
+ ctx.save(); ctx.globalCompositeOperation = 'screen';
695
+ const src = [960, -520];
696
+ for (let k = 0; k < 7; k++) {
697
+ const a = (k / 6);
698
+ const tx0 = r.x + r.w * (a * 0.9), tx1 = tx0 + r.w * 0.16;
699
+ const g = ctx.createLinearGradient(0, -100, 0, r.y + r.h);
700
+ g.addColorStop(0, 'rgba(255,240,214,0)'); g.addColorStop(0.5, `rgba(255,240,214,${0.09 * beam})`); g.addColorStop(1, `rgba(255,240,214,${0.17 * beam})`);
701
+ ctx.fillStyle = g; ctx.beginPath(); ctx.moveTo(src[0] - 8, src[1]); ctx.lineTo(src[0] + 8, src[1]); ctx.lineTo(tx1, r.y + r.h); ctx.lineTo(tx0, r.y + r.h); ctx.closePath(); ctx.fill();
702
+ }
703
+ // dust motes in the beam
704
+ for (let k = 0; k < 90; k++) {
705
+ const bx = hash2(k, 1, 31), by = (hash2(k, 2, 31) + t * (0.03 + 0.05 * hash2(k, 3, 31))) % 1;
706
+ const yy = lerp(0, r.y + r.h, by), spread = lerp(0.05, 1, (yy + 520) / (r.y + r.h + 520));
707
+ const xx = 960 + (bx - 0.5) * r.w * spread + Math.sin(t * 1.3 + k) * 6;
708
+ ctx.fillStyle = `rgba(255,244,226,${beam * (0.25 + 0.5 * hash2(k, 4, 31))})`;
709
+ ctx.beginPath(); ctx.arc(xx, yy, 0.8 + 1.8 * hash2(k, 5, 31), 0, TAU); ctx.fill();
710
+ }
711
+ ctx.restore();
712
+ }
713
+ const cur = p * (1 - sstep(8.3, 8.7, t));
714
+ if (cur > 0) curtains(r, cur);
715
+ const ph = lerp(0.1 + 0.25, Math.floor(t * 16) / 16 * 1.5, p);
716
+ muybridge(ctx, r, ph, t, 0);
717
+ // screen glow onto the room
718
+ if (p > 0) {
719
+ ctx.save(); ctx.globalCompositeOperation = 'screen';
720
+ const g = ctx.createRadialGradient(r.x + r.w / 2, r.y + r.h / 2, r.h * 0.4, r.x + r.w / 2, r.y + r.h / 2, r.w * 0.95);
721
+ g.addColorStop(0, `rgba(200,196,186,${0.1 * p})`); g.addColorStop(1, 'rgba(200,196,186,0)'); ctx.fillStyle = g; ctx.fillRect(0, 0, W, H);
722
+ ctx.restore();
723
+ }
724
+ return r;
725
+ }
726
+
727
+ function curtains(r, a) {
728
+ ctx.save(); ctx.globalAlpha = a;
729
+ const sides = [[0, r.x - 26], [r.x + r.w + 26, W]];
730
+ for (const [x0, x1] of sides) {
731
+ const w = x1 - x0; if (w <= 0) continue;
732
+ const g = ctx.createLinearGradient(x0, 0, x1, 0);
733
+ const n = Math.max(3, Math.round(w / 70));
734
+ for (let i = 0; i <= n; i++) { const k = i / n, fold = 0.5 + 0.5 * Math.cos(k * n * Math.PI); g.addColorStop(k, rgba(mixc([46, 8, 14], [150, 34, 44], fold * 0.85))); }
735
+ ctx.fillStyle = g; ctx.fillRect(x0, 0, w, H);
736
+ const near = x0 === 0 ? x1 : x0;
737
+ const lg = ctx.createLinearGradient(near, 0, x0 === 0 ? 0 : W, 0);
738
+ lg.addColorStop(0, 'rgba(255,220,200,0.18)'); lg.addColorStop(0.5, 'rgba(0,0,0,0.3)'); lg.addColorStop(1, 'rgba(0,0,0,0.8)');
739
+ ctx.fillStyle = lg; ctx.fillRect(x0, 0, w, H);
740
+ }
741
+ // valance
742
+ const vg = ctx.createLinearGradient(0, 0, 0, r.y - 10);
743
+ vg.addColorStop(0, 'rgb(40,7,12)'); vg.addColorStop(1, 'rgb(120,26,36)');
744
+ ctx.fillStyle = vg; ctx.fillRect(0, 0, W, Math.max(0, r.y - 14));
745
+ ctx.fillStyle = 'rgba(201,161,90,0.7)'; ctx.fillRect(0, Math.max(0, r.y - 18), W, 4);
746
+ ctx.restore();
747
+ }
748
+ // ---- TV
749
+ const BUF = mk(W, H), bctx = BUF.getContext('2d');
750
+ const BUF2 = mk(W, H), b2 = BUF2.getContext('2d');
751
+ const BUF3 = mk(W, H), b3 = BUF3.getContext('2d');
752
+ function layer(c, alpha, fn, comp) { b3.setTransform(1, 0, 0, 1, 0, 0); b3.globalAlpha = 1; b3.globalCompositeOperation = 'source-over'; b3.filter = 'none'; b3.clearRect(0, 0, W, H); b3.setTransform(c.getTransform()); fn(b3); b3.setTransform(1, 0, 0, 1, 0, 0); c.save(); c.setTransform(1, 0, 0, 1, 0, 0); c.globalAlpha *= alpha; if (comp) c.globalCompositeOperation = comp; c.drawImage(BUF3, 0, 0); c.restore(); }
753
+ function testCard(c, r, t) {
754
+ const cx = r.x + r.w / 2, cy = r.y + r.h / 2;
755
+ const g = c.createRadialGradient(cx, cy, 0, cx, cy, r.w * 0.6);
756
+ g.addColorStop(0, '#5d6a70'); g.addColorStop(1, '#2a3236'); c.fillStyle = g; c.fillRect(r.x, r.y, r.w, r.h);
757
+ const fg = 'rgba(214,236,244,0.9)';
758
+ c.strokeStyle = fg; c.fillStyle = fg;
759
+ // grid
760
+ c.globalAlpha = 0.25; c.lineWidth = 2;
761
+ for (let i = 1; i < 12; i++) { const x = r.x + i * r.w / 12; c.beginPath(); c.moveTo(x, r.y); c.lineTo(x, r.y + r.h); c.stroke(); }
762
+ for (let i = 1; i < 9; i++) { const y = r.y + i * r.h / 9; c.beginPath(); c.moveTo(r.x, y); c.lineTo(r.x + r.w, y); c.stroke(); }
763
+ c.globalAlpha = 1;
764
+ // resolution wedges
765
+ c.lineWidth = 1.5;
766
+ for (const [dx, dy] of [[1, 0], [-1, 0], [0, 1], [0, -1]]) {
767
+ for (let k = -6; k <= 6; k++) {
768
+ const a0 = [cx + dx * r.h * 0.2 + dy * k * 3, cy + dy * r.h * 0.2 + dx * k * 3];
769
+ const a1 = [cx + dx * r.h * 0.47 + dy * k * 9, cy + dy * r.h * 0.47 + dx * k * 9];
770
+ c.beginPath(); c.moveTo(a0[0], a0[1]); c.lineTo(a1[0], a1[1]); c.stroke();
771
+ }
772
+ }
773
+ c.lineWidth = 6; c.beginPath(); c.arc(cx, cy, r.h * 0.43, 0, TAU); c.stroke();
774
+ c.lineWidth = 3; c.beginPath(); c.arc(cx, cy, r.h * 0.33, 0, TAU); c.stroke();
775
+ c.fillStyle = 'rgba(20,26,30,0.85)'; c.beginPath(); c.arc(cx, cy, r.h * 0.31, 0, TAU); c.fill();
776
+ // corner circles
777
+ for (const [sx, sy] of [[-1, -1], [1, -1], [-1, 1], [1, 1]]) { c.lineWidth = 3; c.beginPath(); c.arc(cx + sx * r.w * 0.39, cy + sy * r.h * 0.36, r.h * 0.085, 0, TAU); c.stroke(); }
778
+ // grey steps
779
+ for (let i = 0; i < 6; i++) { const v = 40 + i * 40; c.fillStyle = `rgb(${v},${v + 8},${v + 12})`; c.fillRect(cx - r.w * 0.3 + i * r.w * 0.1, r.y + r.h * 0.86, r.w * 0.1, r.h * 0.06); }
780
+ c.strokeStyle = fg; c.lineWidth = 2; c.beginPath(); c.moveTo(cx - 24, cy); c.lineTo(cx + 24, cy); c.moveTo(cx, cy - 24); c.lineTo(cx, cy + 24); c.stroke();
781
+ }
782
+ function colourBars(c, r) {
783
+ const cols = ['#C0C0C0', '#C0C000', '#00C0C0', '#00C000', '#C000C0', '#C00000', '#0000C0'];
784
+ cols.forEach((cl, i) => { c.fillStyle = cl; c.fillRect(r.x + i * r.w / 7, r.y, r.w / 7 + 1, r.h * 0.72); });
785
+ const cols2 = ['#0000C0', '#131313', '#C000C0', '#131313', '#00C0C0', '#131313', '#C0C0C0'];
786
+ cols2.forEach((cl, i) => { c.fillStyle = cl; c.fillRect(r.x + i * r.w / 7, r.y + r.h * 0.72, r.w / 7 + 1, r.h * 0.08); });
787
+ c.fillStyle = '#0d1a40'; c.fillRect(r.x, r.y + r.h * 0.8, r.w * 0.2, r.h * 0.2);
788
+ c.fillStyle = '#ebebeb'; c.fillRect(r.x + r.w * 0.2, r.y + r.h * 0.8, r.w * 0.18, r.h * 0.2);
789
+ c.fillStyle = '#2a0b4a'; c.fillRect(r.x + r.w * 0.38, r.y + r.h * 0.8, r.w * 0.2, r.h * 0.2);
790
+ c.fillStyle = '#131313'; c.fillRect(r.x + r.w * 0.58, r.y + r.h * 0.8, r.w * 0.42, r.h * 0.2);
791
+ }
792
+
793
+ function tvContent(c, r, t, filmRect) {
794
+ // draws image content (no bezel) in rect r
795
+ const cardA = sstep(8.45, 8.6, t);
796
+ if (cardA < 1) muybridge(c, r, Math.floor(t * 16) / 16 * 1.5, t, 0);
797
+ if (cardA > 0) {
798
+ c.save(); c.beginPath(); c.rect(r.x, r.y, r.w, r.h); c.clip();
799
+ // v-roll
800
+ const roll = io3(seg(t, 9.95, 10.25)) * r.h;
801
+ c.globalAlpha = cardA;
802
+ c.translate(0, roll); testCard(c, r, t); c.translate(0, -r.h); testCard(c, r, t); c.translate(0, r.h - roll);
803
+ if (t > 10.1) { const cb = { x: r.x, y: r.y + roll - r.h, w: r.w, h: r.h }; colourBars(c, cb); }
804
+ // runner scans in (phosphor white)
805
+ const scan = seg(t, 8.95, 9.3);
806
+ if (scan > 0) {
807
+ const h = r.h * 0.62, X = r.x + r.w / 2, Yg = r.y + r.h * 0.5 + 0.43 * h;
808
+ c.save(); c.beginPath(); c.rect(r.x, r.y, r.w, r.h * (0.12 + 0.88 * scan) + (t > 10.1 ? r.h : 0)); c.clip();
809
+ const rollY = t > 9.95 ? roll - (t > 10.1 ? r.h : 0) : 0;
810
+ if (t > 10.1) { drawSil(c, runPose(PHI(t)), X, Yg - GROUND * h + roll - r.h, h, 1, '#141414', 1.18); }
811
+ drawSil(c, runPose(PHI(t)), X, Yg - GROUND * h + rollY, h, 1, t > 10.1 ? '#F3EEE4' : '#EAF6FA');
812
+ c.restore();
813
+ if (scan < 1) { c.fillStyle = 'rgba(240,250,255,0.8)'; c.fillRect(r.x, r.y + r.h * (0.12 + 0.88 * scan) - 3, r.w, 6); }
814
+ }
815
+ c.globalAlpha = 1;
816
+ c.restore();
817
+ }
818
+ }
819
+
820
+ function tvPushM(t) {
821
+ const z = io3(seg(t, 10.05, 10.5)), drift = 0.035 * seg(t, 8.8, 10.05);
822
+ if (z <= 0 && drift <= 0) return [1, 0, 0];
823
+ const cx = CRT.x + CRT.w / 2, cy = CRT.y + CRT.h / 2, sc = lerp(1 + drift, 2.2, z);
824
+ return [sc, lerp(cx, 960, z) - cx * sc, lerp(cy, 560, z) - cy * sc];
825
+ }
826
+ function tvPush(t) {
827
+ const z = io3(seg(t, 10.05, 10.5)), drift = 0.035 * seg(t, 8.8, 10.05);
828
+ if (z <= 0 && drift <= 0) return;
829
+ const cx = CRT.x + CRT.w / 2, cy = CRT.y + CRT.h / 2, sc = lerp(1 + drift, 2.2, z);
830
+ ctx.translate(lerp(cx, 960, z), lerp(cy, 560, z)); ctx.scale(sc, sc); ctx.translate(-cx, -cy);
831
+ }
832
+ function sceneTV(t) {
833
+ // 8.3 .. 10.75
834
+ const q = io3(seg(t, 8.3, 8.8));
835
+ const r = { x: lerp(PROJ.x, CRT.x, q), y: lerp(PROJ.y, CRT.y, q), w: lerp(PROJ.w, CRT.w, q), h: lerp(PROJ.h, CRT.h, q) };
836
+ const rad = lerp(0, 90, q);
837
+ STATE.tv = r; STATE.tvRad = rad; STATE.tvQ = q;
838
+ // cabinet
839
+ const cabA = q;
840
+ if (cabA > 0) {
841
+ ctx.save(); ctx.globalAlpha = cabA;
842
+ const sc = lerp(1.1, 1, o3(q));
843
+ ctx.translate(960, 520); ctx.scale(sc, sc); ctx.translate(-960, -520);
844
+ const cab = { x: 250, y: 70, w: 1420, h: 870 };
845
+ ctx.save(); ctx.beginPath(); ctx.roundRect(cab.x, cab.y, cab.w, cab.h, 46); ctx.clip();
846
+ ctx.drawImage(WOOD, cab.x, cab.y, cab.w, cab.h);
847
+ const sh = ctx.createLinearGradient(cab.x, 0, cab.x + cab.w, 0); sh.addColorStop(0, 'rgba(0,0,0,0.55)'); sh.addColorStop(0.35, 'rgba(255,220,180,0.06)'); sh.addColorStop(1, 'rgba(0,0,0,0.6)');
848
+ ctx.fillStyle = sh; ctx.fillRect(cab.x, cab.y, cab.w, cab.h);
849
+ // speaker grille + knobs
850
+ ctx.fillStyle = '#20140c'; ctx.beginPath(); ctx.roundRect(1350, 170, 250, 420, 22); ctx.fill();
851
+ ctx.fillStyle = 'rgba(201,161,90,0.55)'; for (let i = 0; i < 12; i++) ctx.fillRect(1372 + i * 19, 192, 6, 376);
852
+ for (const ky of [690, 820]) {
853
+ const kg = ctx.createRadialGradient(1462, ky - 14, 6, 1475, ky, 56); kg.addColorStop(0, '#f1d9a0'); kg.addColorStop(0.5, '#b88a48'); kg.addColorStop(1, '#4a3016');
854
+ ctx.fillStyle = kg; ctx.beginPath(); ctx.arc(1475, ky, 50, 0, TAU); ctx.fill();
855
+ ctx.strokeStyle = '#2a1a0c'; ctx.lineWidth = 5; ctx.beginPath(); ctx.moveTo(1475, ky); ctx.lineTo(1475 + 34 * Math.cos(-1.2 + (ky === 690 ? 0.4 : -0.6)), ky + 34 * Math.sin(-1.2 + (ky === 690 ? 0.4 : -0.6))); ctx.stroke();
856
+ }
857
+ ctx.restore();
858
+ // bezel
859
+ ctx.fillStyle = '#0c0a09'; ctx.beginPath(); ctx.roundRect(CRT.x - 34, CRT.y - 34, CRT.w + 68, CRT.h + 68, 120); ctx.fill();
860
+ ctx.strokeStyle = 'rgba(201,161,90,0.6)'; ctx.lineWidth = 4; ctx.beginPath(); ctx.roundRect(CRT.x - 40, CRT.y - 40, CRT.w + 80, CRT.h + 80, 124); ctx.stroke();
861
+ ctx.restore();
862
+ }
863
+ // screen content -> buffer for glow
864
+ bctx.setTransform(1, 0, 0, 1, 0, 0); bctx.clearRect(0, 0, W, H);
865
+ bctx.save(); bctx.beginPath(); bctx.roundRect(r.x, r.y, r.w, r.h, rad); bctx.clip();
866
+ tvContent(bctx, r, t);
867
+ // scanlines
868
+ if (q > 0) { bctx.fillStyle = `rgba(0,0,0,${0.32 * q})`; for (let y = r.y; y < r.y + r.h; y += 4) bctx.fillRect(r.x, y, r.w, 1.6); }
869
+ // crt vignette + glass
870
+ if (q > 0) {
871
+ const vg = bctx.createRadialGradient(r.x + r.w / 2, r.y + r.h / 2, r.h * 0.35, r.x + r.w / 2, r.y + r.h / 2, r.w * 0.7);
872
+ vg.addColorStop(0, 'rgba(0,0,0,0)'); vg.addColorStop(1, `rgba(0,0,0,${0.7 * q})`); bctx.fillStyle = vg; bctx.fillRect(r.x, r.y, r.w, r.h);
873
+ const gl = bctx.createLinearGradient(r.x, r.y, r.x + r.w * 0.5, r.y + r.h * 0.6);
874
+ gl.addColorStop(0, `rgba(255,255,255,${0.1 * q})`); gl.addColorStop(0.5, 'rgba(255,255,255,0)'); bctx.fillStyle = gl; bctx.fillRect(r.x, r.y, r.w, r.h);
875
+ }
876
+ bctx.restore();
877
+ ctx.drawImage(BUF, 0, 0);
878
+ if (q > 0) { ctx.save(); ctx.globalCompositeOperation = 'screen'; ctx.globalAlpha = 0.45 * q; ctx.filter = 'blur(18px)'; ctx.drawImage(BUF, 0, 0); ctx.restore(); }
879
+ return r;
880
+ }
881
+
882
+ // ---- pixel world (20 px cells)
883
+ const CELL = 16, GW = 120, GH = 68;
884
+ const PXC = mk(GW, GH), px = PXC.getContext('2d');
885
+ const SPR = mk(64, 64), spx = SPR.getContext('2d', { willReadFrequently: true });
886
+ function spriteCells(ph, hCells) {
887
+ const S = 64, OX = 30, OY = 56;
888
+ spx.setTransform(1, 0, 0, 1, 0, 0); spx.clearRect(0, 0, S, S);
889
+ const P = runPose(ph), hy = OY - GROUND * hCells;
890
+ drawSil(spx, P, OX, hy, hCells, 1, '#fff', 0.95);
891
+ spx.beginPath(); spx.arc(OX + P.head[0] * hCells + 0.3, hy + P.head[1] * hCells - 0.3, 0.085 * hCells, 0, TAU); spx.fill();
892
+ const d = spx.getImageData(0, 0, S, S).data; const on = new Uint8Array(S * S);
893
+ for (let i = 0; i < S * S; i++) on[i] = d[i * 4 + 3] > 110 ? 1 : 0;
894
+ const cells = [];
895
+ for (let y = 0; y < S; y++) for (let x = 0; x < S; x++) {
896
+ if (on[y * S + x]) cells.push([x - OX, y - OY, 1]);
897
+ else { let n = 0; for (const [dx, dy] of [[1, 0], [-1, 0], [0, 1], [0, -1]]) { const xx = x + dx, yy = y + dy; if (xx >= 0 && yy >= 0 && xx < S && yy < S && on[yy * S + xx]) n++; } if (n) cells.push([x - OX, y - OY, 0]); }
898
+ }
899
+ return cells;
900
+ }
901
+ const PAL = { sky0: '#0E0B24', sky1: '#191343', sky2: '#2A1D5C', sky3: '#40276F', mtn1: '#2C2A6B', mtn2: '#3D4A98', grass: '#5BBF5A', grass2: '#2E7D3A', brick: '#B4532A', mortar: '#5E2412', ivory: '#F3EEE4', star: '#F2E3B3', gold: '#F2C14E', gold2: '#A86A1C', out: '#0E0B24' };
902
+ const SPR_COL = 58, GROUND_ROW = 50, SPR_H = 20;
903
+ function pixelWorld(t) {
904
+ const c = px; c.setTransform(1, 0, 0, 1, 0, 0);
905
+ const bands = [[0, 19, PAL.sky0], [19, 32, PAL.sky1], [32, 42, PAL.sky2], [42, 50, PAL.sky3]];
906
+ for (const [a, b, col] of bands) { c.fillStyle = col; c.fillRect(0, a, GW, b - a); }
907
+ // dither band edges
908
+ for (let k = 1; k < bands.length; k++) { c.fillStyle = bands[k][2]; const y = bands[k][0] - 1; for (let x = (y & 1); x < GW; x += 2) c.fillRect(x, y, 1, 1); }
909
+ // stars
910
+ const st = Math.floor(t * 2);
911
+ for (let k = 0; k < 64; k++) { const sx = Math.floor(hash2(k, 1, 61) * GW), sy = Math.floor(hash2(k, 2, 61) * 38); if (hash2(k, st, 62) < 0.2) continue; c.fillStyle = hash2(k, 3, 61) < 0.3 ? PAL.gold : PAL.star; c.fillRect(sx, sy, 1, 1); }
912
+ // moon
913
+ c.fillStyle = PAL.star; for (let y = -6; y <= 6; y++) for (let x = -6; x <= 6; x++) if (x * x + y * y <= 38) c.fillRect(100 + x, 12 + y, 1, 1);
914
+ c.fillStyle = '#D6C48E'; c.fillRect(97, 9, 2, 2); c.fillRect(102, 14, 2, 1); c.fillRect(101, 8, 1, 1); c.fillRect(98, 15, 1, 1);
915
+ const s1 = (t - 10.3) * 4, s2 = (t - 10.3) * 8, s3 = (t - 10.3) * 15;
916
+ for (let x = 0; x < GW; x++) {
917
+ const h1 = Math.floor(9 + 13 * fbm((x + s1) / 20, 0.5, 71, 3)); c.fillStyle = PAL.mtn1; c.fillRect(x, 50 - h1, 1, h1);
918
+ const h2 = Math.floor(2 + 9 * fbm((x + s2) / 12, 3.5, 72, 3)); c.fillStyle = PAL.mtn2; c.fillRect(x, 50 - h2, 1, h2);
919
+ }
920
+ // ground
921
+ c.fillStyle = PAL.grass; c.fillRect(0, 50, GW, 1); c.fillStyle = PAL.grass2; c.fillRect(0, 51, GW, 1);
922
+ c.fillStyle = PAL.mortar; c.fillRect(0, 52, GW, GH - 52);
923
+ c.fillStyle = PAL.brick;
924
+ const off = Math.floor(s3);
925
+ for (let row = 0; row < 8; row++) { const y = 52 + row * 2; const shift = (row & 1) * 2; for (let bx = -8; bx < GW + 8; bx += 4) { const x = bx - ((off + shift) % 4); c.fillRect(x, y, 3, 1); } }
926
+ // grass tufts
927
+ c.fillStyle = PAL.grass; for (let k = 0; k < 9; k++) { const x = ((k * 17 - off) % 136 + 136) % 136 - 8; c.fillRect(x, 49, 3, 1); c.fillRect(x + 1, 48, 1, 1); }
928
+ // ? block (scrolls with ground)
929
+ const bxw = Math.round(SPR_COL - 2 + 15 * (11.55 - t));
930
+ const hit = t >= 11.55;
931
+ const bump = hit ? Math.round(Math.sin(seg(t, 11.55, 11.75) * Math.PI) * -1) : 0;
932
+ c.fillStyle = PAL.out; c.fillRect(bxw - 1, 15 + bump, 7, 7);
933
+ c.fillStyle = hit ? PAL.gold2 : PAL.gold; c.fillRect(bxw, 16 + bump, 5, 5);
934
+ if (!hit) { c.fillStyle = PAL.out; c.fillRect(bxw + 1, 16, 3, 1); c.fillRect(bxw + 4, 17, 1, 1); c.fillRect(bxw + 2, 18, 2, 1); c.fillRect(bxw + 2, 20, 1, 1); }
935
+ else { c.fillStyle = PAL.out; c.fillRect(bxw, 16 + bump, 1, 1); c.fillRect(bxw + 4, 16 + bump, 1, 1); c.fillRect(bxw, 20 + bump, 1, 1); c.fillRect(bxw + 4, 20 + bump, 1, 1); }
936
+ // coin
937
+ if (t > 11.55 && t < 12.05) {
938
+ const k = seg(t, 11.55, 12.05); const cy = Math.round(13 - 9 * Math.sin(k * Math.PI * 0.9));
939
+ const wide = Math.floor(t * 16) % 2 === 0; c.fillStyle = PAL.gold; c.fillRect(bxw + (wide ? 1 : 2), cy - 3, wide ? 3 : 1, 4);
940
+ }
941
+ return { bxw };
942
+ }
943
+ function spriteY(t) { const k = seg(t, 11.3, 11.8); return -Math.round(Math.sin(k * Math.PI) * 7.4); }
944
+
945
+ function pixelFont(c, str, x, y, cell, col) {
946
+ const G = { '1': ['..#..', '.##..', '..#..', '..#..', '..#..', '..#..', '.###.'], '9': ['.###.', '#...#', '#...#', '.####', '....#', '...#.', '.##..'], '8': ['.###.', '#...#', '#...#', '.###.', '#...#', '#...#', '.###.'], '0': ['.###.', '#...#', '#..##', '#.#.#', '##..#', '#...#', '.###.'] };
947
+ c.fillStyle = col; let cx = x;
948
+ for (const ch of str) { const g = G[ch]; if (g) g.forEach((row, j) => { for (let i = 0; i < 5; i++) if (row[i] === '#') c.fillRect(cx + i * cell, y + j * cell, cell, cell); }); cx += 6 * cell; }
949
+ }
950
+
951
+ function scenePixel(t) {
952
+ pixelWorld(t);
953
+ ctx.save(); ctx.imageSmoothingEnabled = false; ctx.drawImage(PXC, 0, 0, GW * CELL, GH * CELL); ctx.restore();
954
+ // sprite
955
+ const ph = Math.floor(PHI(t) * 8) / 8;
956
+ const cells = spriteCells(ph, SPR_H);
957
+ const jy = spriteY(t);
958
+ for (const [x, y, on] of cells) { ctx.fillStyle = on ? PAL.ivory : PAL.out; ctx.fillRect((SPR_COL + x) * CELL, (GROUND_ROW + y + jy) * CELL, CELL, CELL); }
959
+ return cells;
960
+ }
961
+
962
+ // ---- code
963
+ const CODE = 'draw(frame + 1)';
964
+ const CODE_FONT = '400 58px "JetBrains Mono", monospace';
965
+ function codeLayout(t) {
966
+ ctx.save(); ctx.font = CODE_FONT; const w = ctx.measureText(CODE).width; ctx.restore();
967
+ const m = io3(seg(t, 13.26, 13.44)), f = io3(seg(t, 16.0, 16.45));
968
+ const sc = lerp(1.5, 1, m), base = lerp(lerp(600, 880, m), 960, f);
969
+ return { x0: 960 - w * sc / 2, base, w: w * sc, s: sc };
970
+ }
971
+
972
+ function vectorRunner(c, P, X, Y, h, alpha, prog) {
973
+ const pt = p => [X + p[0] * h, Y + p[1] * h];
974
+ const B = bones(P);
975
+ c.save(); c.globalAlpha = alpha; c.strokeStyle = rgba(IVORY); c.lineCap = 'round'; c.lineWidth = Math.max(2.5, h * 0.011); c.shadowColor = 'rgba(243,238,228,0.45)'; c.shadowBlur = h * 0.03;
976
+ const n = B.length;
977
+ B.forEach(([a, b, w, side], i) => {
978
+ const pr = clamp(prog * (n + 2) - i * 0.85); if (pr <= 0) return;
979
+ const A = pt(a), Bp = pt(b); c.globalAlpha = alpha * (side === 1 ? 0.55 : 1);
980
+ c.beginPath(); c.moveTo(A[0], A[1]); c.lineTo(lerp(A[0], Bp[0], pr), lerp(A[1], Bp[1], pr)); c.stroke();
981
+ if (pr >= 1) { c.fillStyle = rgba(IVORY); c.beginPath(); c.arc(Bp[0], Bp[1], h * 0.017, 0, TAU); c.fill(); }
982
+ });
983
+ const hp = clamp(prog * (n + 2) - n * 0.85);
984
+ if (hp > 0) { const Hd = pt(P.head); c.globalAlpha = alpha; c.beginPath(); c.arc(Hd[0], Hd[1], h * 0.064, -Math.PI / 2, -Math.PI / 2 + TAU * hp); c.stroke(); }
985
+ const Hp = pt(P.hip); c.fillStyle = rgba(IVORY); c.globalAlpha = alpha; c.beginPath(); c.arc(Hp[0], Hp[1], h * 0.016 * clamp(prog * 4), 0, TAU); c.fill();
986
+ c.restore();
987
+ }
988
+
989
+ function vectorRunner3D(c, P, X, Y, h, yaw, alpha, prog) {
990
+ const z0 = 0.055, zs = 0.1, L = P.legs, A = P.arms;
991
+ const J = {
992
+ hipN: [P.hip[0], P.hip[1], z0], hipF: [P.hip[0], P.hip[1], -z0], hip: [P.hip[0], P.hip[1], 0],
993
+ sh: [P.sh[0], P.sh[1], 0], shN: [P.sh[0], P.sh[1], zs], shF: [P.sh[0], P.sh[1], -zs], neck: [P.neck[0], P.neck[1], 0], head: [P.head[0], P.head[1], 0],
994
+ kN: [L[0].knee[0], L[0].knee[1], z0 * 1.1], aN: [L[0].ank[0], L[0].ank[1], z0], tN: [L[0].toe[0], L[0].toe[1], z0],
995
+ kF: [L[1].knee[0], L[1].knee[1], -z0 * 1.1], aF: [L[1].ank[0], L[1].ank[1], -z0], tF: [L[1].toe[0], L[1].toe[1], -z0],
996
+ eN: [A[0].elb[0], A[0].elb[1], zs * 1.15], hN: [A[0].hand[0], A[0].hand[1], zs * 0.75], eF: [A[1].elb[0], A[1].elb[1], -zs * 1.15], hF: [A[1].hand[0], A[1].hand[1], -zs * 0.75],
997
+ };
998
+ const cy = Math.cos(yaw), sy = Math.sin(yaw);
999
+ const pr = q => { const d = q[0] * sy; const s = 1 + d * 0.45; return [X + (q[0] * cy + q[2] * sy) * h * s, Y + q[1] * h * s]; };
1000
+ const B = [['hipF', 'kF', 1], ['kF', 'aF', 1], ['aF', 'tF', 1], ['shF', 'eF', 1], ['eF', 'hF', 1], ['hipF', 'hipN', 2], ['hip', 'sh', 2], ['shF', 'shN', 2], ['sh', 'neck', 2],
1001
+ ['hipN', 'kN', 0], ['kN', 'aN', 0], ['aN', 'tN', 0], ['shN', 'eN', 0], ['eN', 'hN', 0]];
1002
+ c.save(); c.strokeStyle = rgba(IVORY); c.lineCap = 'round'; c.lineWidth = Math.max(2.5, h * 0.011); c.shadowColor = 'rgba(243,238,228,0.45)'; c.shadowBlur = h * 0.03;
1003
+ const n = B.length;
1004
+ B.forEach(([a, b, side], i) => {
1005
+ const p = clamp(prog * (n + 2) - i * 0.85); if (p <= 0) return;
1006
+ const A0 = pr(J[a]), B0 = pr(J[b]); c.globalAlpha = alpha * (side === 1 ? 0.55 : 1);
1007
+ c.beginPath(); c.moveTo(A0[0], A0[1]); c.lineTo(lerp(A0[0], B0[0], p), lerp(A0[1], B0[1], p)); c.stroke();
1008
+ if (p >= 1) { c.fillStyle = rgba(IVORY); c.beginPath(); c.arc(B0[0], B0[1], h * 0.017, 0, TAU); c.fill(); }
1009
+ });
1010
+ const hp = clamp(prog * (n + 2) - n * 0.85);
1011
+ if (hp > 0) { const Hd = pr(J.head); c.globalAlpha = alpha; c.beginPath(); c.arc(Hd[0], Hd[1], h * 0.064, -Math.PI / 2, -Math.PI / 2 + TAU * hp); c.stroke(); }
1012
+ c.restore();
1013
+ }
1014
+ // finale lineup: 7 eras on one tilted timeline
1015
+ const LINE_Y = x => 575 + 0.186 * (x - 266);
1016
+ const SLOTS = [[236, 170], [444, 195], [617, 225], [814, 262], [1040, 310], [1300, 360], [1660, 480]];
1017
+
1018
+ function eraFigure(c0, i, X, gy, h, ph, a, t) {
1019
+ if (a <= 0) return;
1020
+ if (i === 4) return eraFigure4(c0, X, gy, h, ph, a);
1021
+ layer(c0, a, c => eraFigureRaw(c, i, X, gy, h, ph, t));
1022
+ }
1023
+ function eraFigure4(c, X, gy, h, ph, a) {
1024
+ const hipY = gy - GROUND * h;
1025
+ b2.setTransform(1, 0, 0, 1, 0, 0); b2.globalCompositeOperation = 'source-over'; b2.clearRect(0, 0, W, H);
1026
+ drawSil(b2, runPose(ph), X, hipY, h, 1, '#A9DCF2');
1027
+ b2.globalCompositeOperation = 'destination-out'; b2.fillStyle = 'rgba(0,0,0,0.6)';
1028
+ for (let y = Math.floor(gy - h * 1.2); y < gy + 4; y += 4) b2.fillRect(X - h, y, h * 2, 1.6);
1029
+ b2.globalCompositeOperation = 'source-over';
1030
+ c.save(); c.globalAlpha = a; c.drawImage(BUF2, 0, 0);
1031
+ c.globalCompositeOperation = 'screen'; c.filter = 'blur(10px)'; c.globalAlpha = a * 0.6; c.drawImage(BUF2, 0, 0); c.restore();
1032
+ }
1033
+ function eraFigureRaw(c, i, X, gy, h, ph, t) {
1034
+ c.save();
1035
+ const hipY = gy - GROUND * h;
1036
+ if (i === 0) {
1037
+ const L = h * 1.12;
1038
+ drawBison(c, X, gy - 0.5 * L, L, ph, 1, { out: 1, leg: 1, fill: 1, det: 1 }, 'ink');
1039
+ } else if (i === 1) {
1040
+ const P = runPose(ph); drawSil(c, P, X, hipY, h, 1, rgba(TERRA)); drawIncise(c, P, X, hipY, h, 1, rgba(GLAZE));
1041
+ } else if (i === 2) {
1042
+ drawSil(c, runPose(Math.floor(ph * 12) / 12), X, hipY, h, 1, '#E2CDA0');
1043
+ } else if (i === 3) {
1044
+ c.filter = 'blur(1.2px)'; drawSil(c, runPose(Math.floor(ph * 10.7) / 10.7), X, hipY, h, 1, `rgba(200,202,198,${0.86 + 0.14 * hash2(Math.floor(t * 30), 1, 3)})`); c.filter = 'none';
1045
+ } else if (i === 4) {
1046
+ b2.setTransform(1, 0, 0, 1, 0, 0); b2.clearRect(X - h, gy - h * 1.2, h * 2, h * 1.3);
1047
+ drawSil(b2, runPose(ph), X, hipY, h, 1, '#A9DCF2');
1048
+ b2.globalCompositeOperation = 'destination-out'; b2.fillStyle = 'rgba(0,0,0,0.6)';
1049
+ for (let y = Math.floor(gy - h * 1.2); y < gy + 4; y += 4) b2.fillRect(X - h, y, h * 2, 1.6);
1050
+ b2.globalCompositeOperation = 'source-over';
1051
+ c.drawImage(BUF2, 0, 0);
1052
+ c.globalCompositeOperation = 'screen'; c.filter = 'blur(10px)'; c.globalAlpha = a * 0.6; c.drawImage(BUF2, 0, 0); c.filter = 'none'; c.globalCompositeOperation = 'source-over';
1053
+ } else if (i === 5) {
1054
+ const cell = Math.max(4, Math.round(h / SPR_H));
1055
+ const cells = spriteCells(Math.floor(ph * 8) / 8, SPR_H);
1056
+ c.fillStyle = '#5B4FC4';
1057
+ for (const [x, y, on] of cells) { if (on) c.fillRect(Math.round(X + (x + 1) * cell - cell / 2), Math.round(gy + (y + 1) * cell), cell, cell); }
1058
+ c.fillStyle = PAL.ivory;
1059
+ for (const [x, y, on] of cells) { if (on) c.fillRect(Math.round(X + x * cell - cell / 2), Math.round(gy + y * cell), cell, cell); }
1060
+ } else {
1061
+ vectorRunner(c, runPose(ph), X, hipY, h, 1, 1);
1062
+ }
1063
+ c.restore();
1064
+ }
1065
+
1066
+ function sceneCode(t, pixCells) {
1067
+ ctx.fillStyle = rgba(INK); ctx.fillRect(0, 0, W, H);
1068
+ const lay = codeLayout(t);
1069
+ const fin = io3(seg(t, 16.0, 16.45));
1070
+ const hz = ctx.createRadialGradient(960, 760, 50, 960, 760, 1100);
1071
+ hz.addColorStop(0, 'rgba(70,52,38,0.55)'); hz.addColorStop(1, 'rgba(21,18,15,0)'); ctx.fillStyle = hz; ctx.fillRect(0, 0, W, H);
1072
+ // typed code (hidden while the runner turns, back for the finale)
1073
+ const codeA = t < 14 ? 1 - sstep(13.7, 13.86, t) : sstep(16.2, 16.45, t);
1074
+ if (codeA > 0) {
1075
+ const typed = Math.floor(clamp((t - 12.66) / 0.04, 0, CODE.length));
1076
+ ctx.save(); ctx.font = CODE_FONT; ctx.textBaseline = 'alphabetic'; ctx.globalAlpha = codeA;
1077
+ ctx.translate(lay.x0, lay.base); ctx.scale(lay.s, lay.s);
1078
+ ctx.fillStyle = rgba(IVORY); ctx.fillText(CODE.slice(0, typed), 0, 0);
1079
+ const cx = ctx.measureText(CODE.slice(0, typed)).width + 4;
1080
+ const blinkOn = t < 13.3 || Math.floor((t - 13.3) * 4) % 2 === 0;
1081
+ if (t >= 12.62 && blinkOn && t < 13.7) { ctx.fillStyle = rgba(IVORY, 0.9); ctx.fillRect(cx, -48, 34, 60); }
1082
+ ctx.restore();
1083
+ }
1084
+ // the code draws the next frame, then the drawing turns to face camera
1085
+ const drawP = seg(t, 13.42, 13.72);
1086
+ if (drawP > 0) {
1087
+ const turn = io3(seg(t, 13.7, 14.0)), back = io3(seg(t, 16.0, 16.45)), grow = 1 + 0.06 * seg(t, 14.0, 16.0);
1088
+ const RX = 1670, RH = 480;
1089
+ let h = lerp(540, 862, turn) * grow, X = 960, hipY = lerp(740 - GROUND * 540, 540, turn) - (grow - 1) * 862 * 0.0;
1090
+ h = lerp(h, RH, back); X = lerp(X, RX, back); hipY = lerp(hipY, LINE_Y(RX) - GROUND * RH, back);
1091
+ const yaw = (turn - back) * Math.PI / 2;
1092
+ const ph = PHI(t);
1093
+ if (t < 13.62 && t > 13.38) {
1094
+ const sp = seg(t, 13.38, 13.48);
1095
+ const a = [lay.x0 + lay.w + 20, lay.base - 60 * lay.s], b = [X, hipY + GROUND * h];
1096
+ const k1 = o3(sp), k0 = sstep(13.48, 13.62, t);
1097
+ ctx.strokeStyle = rgba(IVORY, 0.9); ctx.lineWidth = 3; ctx.beginPath(); ctx.moveTo(lerp(a[0], b[0], k0), lerp(a[1], b[1], k0)); ctx.lineTo(lerp(a[0], b[0], k1), lerp(a[1], b[1], k1)); ctx.stroke();
1098
+ }
1099
+ if (drawP >= 1 && turn < 0.5) { vectorRunner3D(ctx, runPose(ph - 0.09), X, hipY, h, yaw, 0.16 * (1 - 2 * turn), 1); vectorRunner3D(ctx, runPose(ph - 0.045), X, hipY, h, yaw, 0.3 * (1 - 2 * turn), 1); }
1100
+ vectorRunner3D(ctx, runPose(ph), X, hipY, h, yaw, 1, o3(drawP));
1101
+ }
1102
+ // finale: six ancestors on the timeline, the 2026 line runner is the seventh
1103
+ if (fin > 0) {
1104
+ const vg = ctx.createRadialGradient(200, 540, 0, 200, 540, 1000);
1105
+ vg.addColorStop(0, `rgba(214,150,96,${0.3 * fin})`); vg.addColorStop(1, 'rgba(214,150,96,0)');
1106
+ ctx.fillStyle = vg; ctx.fillRect(0, 0, W, H);
1107
+ // warm pool under the 2026 runner
1108
+ const jx = 1670, jy = LINE_Y(1670);
1109
+ const jg = ctx.createRadialGradient(jx, jy, 0, jx, jy, 300);
1110
+ jg.addColorStop(0, `rgba(240,176,96,${0.3 * fin})`); jg.addColorStop(1, 'rgba(240,176,96,0)');
1111
+ ctx.fillStyle = jg; ctx.beginPath(); ctx.ellipse(jx, jy, 300, 70, 0, 0, TAU); ctx.fill();
1112
+ for (let i = 0; i < 6; i++) {
1113
+ const k = oExpo(seg(t, 16.08 + (5 - i) * 0.035, 16.48 + (5 - i) * 0.035));
1114
+ const [sx, sh] = SLOTS[i];
1115
+ const X = lerp(sx - 240, sx, k);
1116
+ const gy = LINE_Y(X);
1117
+ const glowCol = [[200, 110, 60], [185, 95, 53], [201, 161, 90], [200, 200, 196], [120, 200, 240], [91, 79, 196]][i];
1118
+ const gg = ctx.createRadialGradient(X, gy, 0, X, gy, sh * 0.9);
1119
+ gg.addColorStop(0, rgba(glowCol, 0.22 * k)); gg.addColorStop(1, rgba(glowCol, 0));
1120
+ ctx.fillStyle = gg; ctx.beginPath(); ctx.ellipse(X, gy, sh * 0.9, sh * 0.22, 0, 0, TAU); ctx.fill();
1121
+ eraFigure(ctx, i, X, gy, sh * lerp(0.9, 1, k), PHI(t), k * (0.84 + 0.16 * i / 5), t);
1122
+ }
1123
+ }
1124
+ }
1125
+
1126
+ // ---------------------------------------------------------------- timeline + year labels
1127
+ const ERAS = [
1128
+ { y: '30,000 BC', f: '400 38px "Libre Baskerville", serif', ls: '2px', s: 0 },
1129
+ { y: '500 BC', f: '400 40px "Tenor Sans", sans-serif', ls: '6px', s: 2.5 },
1130
+ { y: '1834', f: '400 44px "Bodoni Moda", serif', ls: '3px', s: 4.5 },
1131
+ { y: '1895', f: 'italic 400 44px "Playfair Display", serif', ls: '2px', s: 6.5 },
1132
+ { y: '1951', f: '500 40px Jost, sans-serif', ls: '4px', s: 8.5 },
1133
+ { y: '1980', f: 'pixel', ls: '0px', s: 10.5 }, // drawn by pixelFont(), digits 0, 1, 8, 9 only
1134
+ { y: '2026', f: '400 38px "JetBrains Mono", monospace', ls: '2px', s: 12.5 },
1135
+ ];
1136
+ const BOUNDS = [2.5, 4.5, 6.5, 8.5, 10.5, 12.5];
1137
+ const SPAN = 2100;
1138
+ const travel = t => BOUNDS.reduce((s, b) => s + io4(seg(t, b - 0.24, b + 0.26)), 0);
1139
+ function labelX(i, t) { return 136 + SPAN * (i - travel(t)) - 14 * (t - ERAS[i].s); }
1140
+
1141
+ function drawTimeline(t) {
1142
+ const fin = io3(seg(t, 16.0, 16.45));
1143
+ const yL = lerp(996, LINE_Y(80), fin), yR = lerp(996, LINE_Y(1840), fin);
1144
+ const xL = lerp(0, 80, fin), xR = lerp(W, 1840, fin);
1145
+ const ly = x => lerp(yL, yR, (x - xL) / (xR - xL));
1146
+ const dt = 1 / 60, vel = Math.abs(travel(t) - travel(t - dt)) * SPAN / dt;
1147
+ const blur = clamp(vel / 2500);
1148
+ ctx.save();
1149
+ ctx.strokeStyle = rgba(IVORY, 0.55); ctx.lineWidth = 1.5; ctx.beginPath(); ctx.moveTo(xL, yL); ctx.lineTo(xR, yR); ctx.stroke();
1150
+ // ticks
1151
+ const pos = travel(t) * SPAN + 14 * t + (fin > 0 ? 0 : 0);
1152
+ const sp = 24;
1153
+ const ang = Math.atan2(yR - yL, xR - xL);
1154
+ ctx.strokeStyle = rgba(IVORY, 0.4 * (1 - 0.8 * blur)); ctx.lineWidth = 1.5;
1155
+ for (let k = -2; k < W / sp + 4; k++) {
1156
+ const wx = k * sp - (pos % sp) + (pos < 0 ? 0 : 0);
1157
+ const x = lerp(wx, xL + (wx / W) * (xR - xL), fin);
1158
+ if (x < xL || x > xR) continue;
1159
+ const idx = Math.round((wx + pos) / sp);
1160
+ const len = idx % 5 === 0 ? 14 : 7;
1161
+ const y = ly(x);
1162
+ ctx.beginPath(); ctx.moveTo(x, y); ctx.lineTo(x - Math.sin(ang) * len * 0, y + len); ctx.stroke();
1163
+ }
1164
+ // labels
1165
+ ERAS.forEach((e, i) => {
1166
+ let x = labelX(i, t);
1167
+ let la = 1;
1168
+ if (i === 6) { const out = sstep(15.85, 15.98, t), back = sstep(16.3, 16.5, t); la = out > 0 && back < 1 ? Math.max(1 - out, back) : 1; if (out >= 1 || t > 15.98) x = 1612; }
1169
+ if (x < -420 || x > W + 60) return;
1170
+ const vxs = (labelX(i, t) - labelX(i, t - dt)) / dt;
1171
+ const fl = i === 6 && t > 15.98 ? 1 : 0;
1172
+ const yb = fl ? 960 + 12 * (1 - sstep(16.3, 16.55, t)) : 964;
1173
+ const yLine = fl ? ly(x - 22) : 996;
1174
+ // anchor tick
1175
+ ctx.globalAlpha = la; ctx.strokeStyle = rgba(IVORY, 0.95); ctx.lineWidth = 2;
1176
+ ctx.beginPath(); ctx.moveTo(x - 22, yLine - (fl ? -4 : 26)); ctx.lineTo(x - 22, fl ? yb - 30 : yLine + 14); ctx.stroke();
1177
+ ctx.fillStyle = rgba(IVORY); ctx.beginPath(); ctx.arc(x - 22, yLine, 4.5, 0, TAU); ctx.fill();
1178
+ const ghosts = Math.abs(vxs) > 300 ? 3 : 0;
1179
+ for (let g = ghosts; g >= 0; g--) {
1180
+ const gx = x + vxs * g * 0.006;
1181
+ ctx.globalAlpha = la * (g === 0 ? 1 : 0.1 / (g * g));
1182
+ if (e.f === 'pixel') pixelFont(ctx, e.y, gx, yb - 35, 5, rgba(IVORY));
1183
+ else { ctx.font = e.f; try { ctx.letterSpacing = e.ls; } catch (_) { } ctx.fillStyle = rgba(IVORY); ctx.textBaseline = 'alphabetic'; ctx.fillText(e.y, gx, yb); }
1184
+ }
1185
+ ctx.globalAlpha = 1; try { ctx.letterSpacing = '0px'; } catch (_) { }
1186
+ });
1187
+ ctx.restore();
1188
+ }
1189
+
1190
+ // ---------------------------------------------------------------- frame
1191
+ const FGRAIN = [0, 1, 2, 3].map(k => {
1192
+ const w = 960, h = 540, c = mk(w, h), x = c.getContext('2d'), im = x.createImageData(w, h), d = im.data, r = rng(2000 + k);
1193
+ for (let i = 0; i < w * h; i++) { const v = r() + r() - 1; const on = v > 0 ? 255 : 0; d[i * 4] = d[i * 4 + 1] = d[i * 4 + 2] = on; d[i * 4 + 3] = Math.abs(v) * 200; }
1194
+ x.putImageData(im, 0, 0); return c;
1195
+ });
1196
+ function grainAndVignette(t, amt) {
1197
+ const fr = Math.floor(t * 30);
1198
+ ctx.save(); ctx.globalAlpha = amt * 0.75;
1199
+ const gi = FGRAIN[fr % 4]; const ox = (hash2(fr, 0, 5) * 200) | 0, oy = (hash2(fr, 1, 5) * 120) | 0;
1200
+ ctx.drawImage(gi, -ox, -oy, W * 1.25, H * 1.25);
1201
+ ctx.restore();
1202
+ const vg = ctx.createRadialGradient(960, 540, 420, 960, 560, 1250);
1203
+ vg.addColorStop(0, 'rgba(10,8,6,0)'); vg.addColorStop(1, 'rgba(10,8,6,0.72)');
1204
+ ctx.fillStyle = vg; ctx.fillRect(0, 0, W, H);
1205
+ }
1206
+
1207
+ let lastPix = null;
1208
+ function draw(t) {
1209
+ t = clamp(t, 0, DUR - 1e-4);
1210
+ ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.globalAlpha = 1; ctx.globalCompositeOperation = 'source-over'; ctx.filter = 'none';
1211
+ ctx.fillStyle = rgba(INK); ctx.fillRect(0, 0, W, H);
1212
+ let grain = 0.14;
1213
+ for (const k in STATE) delete STATE[k];
1214
+ STATE.noFig = false;
1215
+ if (t < 2.5) { sceneCave(t); grain = 0.16; }
1216
+ else if (t < 7.6) {
1217
+ const cam = sceneVessel(t);
1218
+ if (t >= 7.0) {
1219
+ const k = sstep(7.0, 7.45, t);
1220
+ ctx.fillStyle = rgba([10, 9, 8], k); ctx.fillRect(0, 0, W, H);
1221
+ sceneFilm(t, cam);
1222
+ }
1223
+ grain = t > 6.5 ? 0.2 : 0.12;
1224
+ }
1225
+ else if (t < 8.3) { ctx.fillStyle = 'rgb(10,9,8)'; ctx.fillRect(0, 0, W, H); sceneFilm(t, null); grain = 0.22; }
1226
+ else if (t < 10.25) {
1227
+ ctx.fillStyle = 'rgb(10,9,8)'; ctx.fillRect(0, 0, W, H);
1228
+ if (t < 8.75) sceneFilm(t, null);
1229
+ tvPush(t); sceneTV(t); ctx.setTransform(1, 0, 0, 1, 0, 0); grain = 0.14;
1230
+ }
1231
+ else if (t < 12.25) {
1232
+ // pixelate the TV, then the 8-bit world
1233
+ const k = seg(t, 10.25, 10.5);
1234
+ if (k < 1) {
1235
+ b2.setTransform(1, 0, 0, 1, 0, 0); b2.fillStyle = 'rgb(10,9,8)'; b2.fillRect(0, 0, W, H);
1236
+ const save = ctx; // render TV into BUF2 through a temporary swap
1237
+ ctx.save(); ctx.fillStyle = 'rgb(10,9,8)'; ctx.fillRect(0, 0, W, H); tvPush(t); sceneTV(t); ctx.restore();
1238
+ const b = Math.min(CELL, Math.pow(2, Math.floor(k * 4.999)));
1239
+ const sw = Math.ceil(W / b), sh = Math.ceil(H / b);
1240
+ b2.imageSmoothingEnabled = true; b2.drawImage(cv, 0, 0, sw, sh);
1241
+ ctx.save(); ctx.imageSmoothingEnabled = false; ctx.drawImage(BUF2, 0, 0, sw, sh, 0, 0, sw * b, sh * b); ctx.restore();
1242
+ const wa = t >= 10.5 ? 1 : 0;
1243
+ if (wa > 0) { ctx.save(); ctx.globalAlpha = wa; scenePixel(t); ctx.restore(); }
1244
+ } else { lastPix = scenePixel(t); }
1245
+ grain = 0.08;
1246
+ }
1247
+ else {
1248
+ // pixel world dissolves to ink, sprite flies into the cursor
1249
+ const cells0 = spriteCells(Math.floor(PHI(12.25) * 8) / 8, SPR_H);
1250
+ if (t < 12.65) {
1251
+ pixelWorld(t);
1252
+ const k = seg(t, 12.22, 12.6);
1253
+ px.fillStyle = rgba(INK);
1254
+ for (let y = 0; y < GH; y++) for (let x = 0; x < GW; x++) if (hash2(x, y, 91) < k * 1.05) px.fillRect(x, y, 1, 1);
1255
+ ctx.save(); ctx.imageSmoothingEnabled = false; ctx.drawImage(PXC, 0, 0, GW * CELL, GH * CELL); ctx.restore();
1256
+ ctx.fillStyle = rgba(INK, sstep(12.45, 12.65, t)); ctx.fillRect(0, 0, W, H);
1257
+ sceneCodeOverlay(t, cells0);
1258
+ } else sceneCode(t, null);
1259
+ grain = 0.1;
1260
+ }
1261
+
1262
+ ctx = FG; ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.globalAlpha = 1; ctx.globalCompositeOperation = 'source-over'; ctx.filter = 'none'; ctx.clearRect(0, 0, W, H);
1263
+ let punch = 0;
1264
+ for (const b of BOUNDS.concat([14.0])) { const d = t - b; if (d >= 0 && d < 0.35) punch = Math.max(punch, 1 - d / 0.35); }
1265
+ if (punch > 0) { ctx.save(); ctx.fillStyle = `rgba(255,236,210,${0.07 * punch * punch})`; ctx.fillRect(0, 0, W, H); ctx.restore(); }
1266
+ grainAndVignette(t, grain);
1267
+ drawTimeline(t);
1268
+ ctx = BG;
1269
+ }
1270
+ function sceneCodeOverlay(t, cells) {
1271
+ const lay = codeLayout(t);
1272
+ const k = seg(t, 12.25, 12.62);
1273
+ cells.forEach(([x, y, on], i) => {
1274
+ if (!on) return;
1275
+ const sx = (SPR_COL + x) * CELL, sy = (GROUND_ROW + y) * CELL;
1276
+ const d = clamp(k * 1.5 - hash2(i, 0, 81) * 0.5);
1277
+ const e = i3(d);
1278
+ const tx = lay.x0 + 4 * lay.s, ty = lay.base - 48 * lay.s;
1279
+ const s = lerp(CELL, 14, e);
1280
+ ctx.fillStyle = rgba(IVORY, 1);
1281
+ ctx.fillRect(lerp(sx, tx + 18, e), lerp(sy, ty + 38, e), s, s);
1282
+ });
1283
+ if (t > 12.58) { ctx.fillStyle = rgba(IVORY, 0.9); ctx.fillRect(lay.x0 + 4 * lay.s, lay.base - 48 * lay.s, 34 * lay.s, 60 * lay.s); }
1284
+ }
1285
+
1286
+ // ---------------------------------------------------------------- timeline
1287
+ const tl = gsap.timeline({ paused: true });
1288
+ const proxy = { t: 0 };
1289
+ tl.to(proxy, { t: DUR, duration: DUR, ease: 'none', onUpdate: () => draw(proxy.t) }, 0);
1290
+ window.__timelines = window.__timelines || {};
1291
+ window.__timelines['main'] = tl;
1292
+ ['400 40px "Libre Baskerville"', '400 40px "Tenor Sans"', '400 40px "Bodoni Moda"', 'italic 400 40px "Playfair Display"', '500 40px Jost', '400 40px "JetBrains Mono"'].forEach(f => { try { document.fonts.load(f); } catch (_) {} });
1293
+ draw(0);
1294
+ })();
1295
+ </script>
1296
+ </body>
1297
+ </html>