@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,663 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=1920, height=1080" />
6
+ <script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script>
7
+ <style>
8
+ * { margin: 0; padding: 0; box-sizing: border-box; }
9
+ html, body { width: 1920px; height: 1080px; overflow: hidden; background: #f2e8d5; }
10
+ #root { position: relative; width: 1920px; height: 1080px; }
11
+ #stage { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; display: block; }
12
+ </style>
13
+ </head>
14
+ <body>
15
+ <div id="root" data-composition-id="main" data-start="0" data-duration="14" data-width="1920" data-height="1080">
16
+ <canvas id="stage" class="clip" width="1920" height="1080" data-start="0" data-duration="14" data-track-index="0"></canvas>
17
+ </div>
18
+ <script>
19
+ /*
20
+ * Cut-paper world. 14 s, 1920x1080, one canvas drawn as a pure function of time.
21
+ * A pop-up landscape builds sheet by sheet, the day turns to dusk, the camera pushes in on a paper boat.
22
+ * Beat map (120 BPM, a hit every 0.5 s):
23
+ * 0.0 to 4.0 far range, hills, sun, meadow with river cut, banks, clouds land one per beat
24
+ * 4.0 paper boat bobs up, ripple ring, camera push starts
25
+ * 4.6 to 9.0 light shifts morning > golden > dusk; stars 7.0 to 8.5, rose pennant 7.85
26
+ * 10.4 to 14 slow close-in on the boat, ripple rings at 10.75, 11.0, 11.5
27
+ * Change colours in P (palette) below. All light keys are mixed from those six tones + the rose accent.
28
+ * No words on screen. Geometry is seeded, so changing a seed gives a new hand-cut edge.
29
+ */
30
+ (function () {
31
+ const W = 1920, H = 1080, DUR = 14;
32
+ const cv = document.getElementById('stage');
33
+ let ctx = cv.getContext('2d');
34
+
35
+ // ---------- deterministic helpers ----------
36
+ function rng(seed) { let a = seed >>> 0; return function () { 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; }; }
37
+ function noise1(seed) { const r = rng(seed), N = 1024, v = new Float32Array(N); for (let i = 0; i < N; i++) v[i] = r() * 2 - 1; return function (x) { const i = Math.floor(x), f = x - i, a = v[((i % N) + N) % N], b = v[(((i + 1) % N) + N) % N], s = f * f * (3 - 2 * f); return a + (b - a) * s; }; }
38
+ function hash2(x, y, s) { let h = (Math.imul(x, 374761393) + Math.imul(y, 668265263) + Math.imul(s, 1442695041)) | 0; h = Math.imul(h ^ (h >>> 13), 1274126177); return ((h ^ (h >>> 16)) >>> 0) / 4294967296; }
39
+ function vnoise(x, y, s, per) { const xi = Math.floor(x), yi = Math.floor(y), fx = x - xi, fy = y - yi; const ux = fx * fx * (3 - 2 * fx), uy = fy * fy * (3 - 2 * fy); const m = a => ((a % per) + per) % per; const a = hash2(m(xi), m(yi), s), b = hash2(m(xi + 1), m(yi), s), c = hash2(m(xi), m(yi + 1), s), d = hash2(m(xi + 1), m(yi + 1), s); return a + (b - a) * ux + (c - a) * uy + (a - b - c + d) * ux * uy; }
40
+ const clamp = (v, a, b) => Math.max(a, Math.min(b, v));
41
+ const g = (x, c, w) => Math.exp(-((x - c) / w) * ((x - c) / w));
42
+ const ss = v => { v = clamp(v, 0, 1); return v * v * (3 - 2 * v); };
43
+ const EC = {}; const ease = n => EC[n] || (EC[n] = gsap.parseEase(n));
44
+ function tw(t, s, d, e) { if (t <= s) return 0; if (t >= s + d) return 1; return ease(e || 'none')((t - s) / d); }
45
+
46
+ // ---------- colour: change these six paper tones + the rose accent ----------
47
+ const P = { cream: '#F2E8D5', sand: '#E3CBA8', sage: '#9CB49A', dsage: '#5E7F6A', teal: '#2F5D62', rose: '#D98C7A', ink: '#2B2B2B' };
48
+ for (const k in P) { const h = P[k]; P[k] = [parseInt(h.slice(1, 3), 16), parseInt(h.slice(3, 5), 16), parseInt(h.slice(5, 7), 16)]; }
49
+ const mix = (a, b, t) => [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t, a[2] + (b[2] - a[2]) * t];
50
+ const css = (c, a) => 'rgba(' + Math.round(c[0]) + ',' + Math.round(c[1]) + ',' + Math.round(c[2]) + ',' + (a === undefined ? 1 : a) + ')';
51
+ let LT = 0; // 0 morning, 1 golden, 2 dusk
52
+ const lit = k => LT <= 1 ? mix(k[0], k[1], LT) : mix(k[1], k[2], LT - 1);
53
+ const C = {
54
+ skyTop: [mix(P.cream, P.sage, 0.32), mix(P.rose, P.sand, 0.45), mix(P.rose, P.teal, 0.34)],
55
+ skyMid: [mix(P.cream, P.sage, 0.16), mix(P.sand, P.cream, 0.25), mix(P.rose, P.sand, 0.12)],
56
+ skyBot: [mix(P.cream, P.sage, 0.08), mix(P.cream, P.sand, 0.35), mix(P.cream, P.sand, 0.45)],
57
+ far: [mix(P.sage, P.cream, 0.6), mix(P.sand, P.rose, 0.3), mix(P.rose, P.sand, 0.15)],
58
+ back: [mix(P.sage, P.cream, 0.3), mix(P.sage, P.sand, 0.5), mix(P.rose, P.dsage, 0.5)],
59
+ mid: [mix(P.sage, P.dsage, 0.12), mix(mix(P.sage, P.dsage, 0.25), P.sand, 0.2), mix(P.dsage, P.rose, 0.22)],
60
+ floor: [mix(P.sage, P.dsage, 0.45), mix(P.dsage, P.sand, 0.2), mix(P.dsage, P.rose, 0.3)],
61
+ floorFar: [mix(P.sage, P.cream, 0.12), mix(P.sage, P.sand, 0.45), mix(mix(P.rose, P.sand, 0.35), P.dsage, 0.18)],
62
+ nearF: [mix(P.sage, P.dsage, 0.62), mix(P.dsage, P.sand, 0.12), mix(P.dsage, P.teal, 0.2)],
63
+ nearB: [mix(P.dsage, P.teal, 0.2), mix(P.dsage, P.teal, 0.35), mix(P.teal, P.dsage, 0.3)],
64
+ water: [mix(P.teal, P.sage, 0.3), P.teal, mix(P.teal, P.rose, 0.22)],
65
+ waterFar: [mix(P.sage, P.cream, 0.35), mix(P.sand, P.teal, 0.25), mix(P.rose, P.sand, 0.2)],
66
+ strip: [mix(P.cream, P.sage, 0.25), mix(P.cream, P.sand, 0.4), mix(P.rose, P.cream, 0.35)],
67
+ bank: [P.dsage, mix(P.dsage, P.teal, 0.35), mix(P.teal, P.ink, 0.35)],
68
+ fern: [P.teal, mix(P.teal, P.ink, 0.25), mix(P.teal, P.ink, 0.6)],
69
+ treeBack: [mix(P.sage, P.dsage, 0.45), mix(P.dsage, P.sand, 0.2), mix(P.dsage, P.rose, 0.3)],
70
+ treeMid: [P.dsage, mix(P.dsage, P.teal, 0.3), mix(P.teal, P.rose, 0.12)],
71
+ treeBank: [P.teal, mix(P.teal, P.dsage, 0.2), mix(P.teal, P.ink, 0.5)],
72
+ cloud: [P.cream, mix(P.cream, P.sand, 0.45), mix(P.rose, P.cream, 0.5)],
73
+ sun0: [P.sand, mix(P.sand, P.rose, 0.35), P.rose],
74
+ sun1: [mix(P.sand, P.cream, 0.5), P.sand, mix(P.rose, P.sand, 0.45)],
75
+ sun2: [P.cream, mix(P.cream, P.sand, 0.35), mix(P.cream, P.rose, 0.3)],
76
+ hullL: [P.cream, mix(P.cream, P.sand, 0.25), mix(P.cream, P.rose, 0.25)],
77
+ hullD: [P.sand, mix(P.sand, P.rose, 0.2), mix(P.rose, P.sand, 0.3)],
78
+ hullF: [mix(P.sand, P.dsage, 0.18), mix(P.sand, P.rose, 0.35), mix(P.rose, P.ink, 0.15)],
79
+ bird: [P.ink, P.ink, mix(P.ink, P.teal, 0.2)],
80
+ rimT: [P.cream, mix(P.cream, P.sand, 0.4), mix(P.rose, P.cream, 0.25)]
81
+ };
82
+ let RIMA = 0.4;
83
+
84
+ // ---------- grain tile (procedural paper) ----------
85
+ const GT = 768;
86
+ const grainC = document.createElement('canvas'); grainC.width = GT; grainC.height = GT;
87
+ (function () {
88
+ const x = grainC.getContext('2d'); const id = x.createImageData(GT, GT); const d = id.data;
89
+ for (let j = 0; j < GT; j++) for (let i = 0; i < GT; i++) {
90
+ let v = (hash2(i, j, 11) - 0.5) * 0.75 + (vnoise(i / 48, j / 48, 2, GT / 48) - 0.5) * 0.3 + (vnoise(i / 12, j / 12, 3, GT / 12) - 0.5) * 0.22 + (vnoise(i / 3, j / 3, 5, GT / 3) - 0.5) * 0.3;
91
+ const o = (j * GT + i) * 4, c = v > 0 ? 255 : 0;
92
+ d[o] = c; d[o + 1] = c; d[o + 2] = c; d[o + 3] = Math.min(255, Math.abs(v) * 78);
93
+ }
94
+ x.putImageData(id, 0, 0);
95
+ const r = rng(77);
96
+ for (let k = 0; k < 420; k++) {
97
+ const sx = 20 + r() * (GT - 40), sy = 20 + r() * (GT - 40), a = r() * 6.283, l = 6 + r() * 22;
98
+ x.strokeStyle = r() < 0.6 ? 'rgba(255,255,255,0.22)' : 'rgba(0,0,0,0.10)'; x.lineWidth = 0.6 + r() * 0.7;
99
+ x.beginPath(); x.moveTo(sx, sy); x.quadraticCurveTo(sx + Math.cos(a + 0.6) * l * 0.6, sy + Math.sin(a + 0.6) * l * 0.6, sx + Math.cos(a) * l, sy + Math.sin(a) * l); x.stroke();
100
+ }
101
+ })();
102
+ let grain = ctx.createPattern(grainC, 'repeat');
103
+
104
+ // ---------- hand-cut geometry ----------
105
+ function cut(pts, seed, step, amp, wob) {
106
+ step = step || 12; amp = amp === undefined ? 1.1 : amp; wob = wob === undefined ? 2.2 : wob;
107
+ const r = rng(seed), nz = noise1(seed + 7), n = pts.length, L = [0];
108
+ for (let i = 1; i <= n; i++) { const a = pts[i - 1], b = pts[i % n]; L.push(L[i - 1] + Math.hypot(b[0] - a[0], b[1] - a[1])); }
109
+ const tot = L[n], out = []; let s = 0, j = 0;
110
+ while (s < tot) {
111
+ while (L[j + 1] < s) j++;
112
+ const a = pts[j], b = pts[(j + 1) % n], f = (s - L[j]) / ((L[j + 1] - L[j]) || 1);
113
+ const dx = b[0] - a[0], dy = b[1] - a[1], dl = Math.hypot(dx, dy) || 1;
114
+ const d = nz(s / 70) * wob + (r() - 0.5) * amp * 2;
115
+ out.push([a[0] + dx * f - dy / dl * d, a[1] + dy * f + dx / dl * d]);
116
+ s += step * (0.5 + r());
117
+ }
118
+ return out;
119
+ }
120
+ function toPath(pts, p) { p = p || new Path2D(); p.moveTo(pts[0][0], pts[0][1]); for (let i = 1; i < pts.length; i++) p.lineTo(pts[i][0], pts[i][1]); p.closePath(); return p; }
121
+ function bbox(pts) { let a = 1e9, b = 1e9, c = -1e9, d = -1e9; for (const q of pts) { a = Math.min(a, q[0]); b = Math.min(b, q[1]); c = Math.max(c, q[0]); d = Math.max(d, q[1]); } return [a, b, c, d]; }
122
+ function ridge(fn, x0, x1, bot) { const p = []; for (let x = x0; x <= x1; x += 4) p.push([x, fn(x)]); p.push([x1, bot]); p.push([x0, bot]); return p; }
123
+ function circ(cx, cy, r, n) { const p = []; n = n || 120; for (let i = 0; i < n; i++) { const a = i / n * Math.PI * 2; p.push([cx + Math.cos(a) * r, cy + Math.sin(a) * r]); } return p; }
124
+ function shadowOf(path, bb, blur, rule) {
125
+ const S = 0.5, pad = blur * 3, w = bb[2] - bb[0] + pad * 2, h = bb[3] - bb[1] + pad * 2;
126
+ const c = document.createElement('canvas'); c.width = Math.ceil(w * S); c.height = Math.ceil(h * S);
127
+ const x = c.getContext('2d'); x.filter = 'blur(' + (blur * S) + 'px)';
128
+ x.setTransform(S, 0, 0, S, (pad - bb[0]) * S, (pad - bb[1]) * S); x.fillStyle = '#000'; x.fill(path, rule || 'nonzero');
129
+ return { c: c, x0: bb[0] - pad, y0: bb[1] - pad, w: w, h: h };
130
+ }
131
+
132
+ const X0 = -460, X1 = 2380, BOT = 1720;
133
+ const farFn = x => 440 + 22 * Math.sin(x / 210 + 1) - 120 * g(x, 520, 230) - 165 * g(x, 1180, 250) - 80 * g(x, 1760, 210) - 50 * g(x, -100, 200);
134
+ const backFn = x => 525 + 16 * Math.sin(x / 170) - 85 * g(x, 240, 290) - 55 * g(x, 960, 240) - 95 * g(x, 1620, 270);
135
+ const midFn = x => 594 + 10 * Math.sin(x / 130 + 2) - 58 * g(x, 560, 250) - 70 * g(x, 1380, 230) - 24 * g(x, 2000, 200);
136
+ const floorFn = x => 640 + 7 * Math.sin(x / 240) - 22 * g(x, 1720, 300) - 16 * g(x, 200, 260);
137
+ const leftFn = x => 800 - 70 * g(x, -150, 300) + 960 * Math.pow(ss((x - 180) / 820), 1.6);
138
+ const rightFn = x => 846 - 60 * g(x, 2160, 300) + 960 * Math.pow(ss((1840 - x) / 700), 1.6);
139
+
140
+ function sheetLayer(pts, seed, col, par, extra) {
141
+ const c = cut(pts, seed, 13, 1.2, 2.4); const p = toPath(c); const bb = bbox(c);
142
+ return Object.assign({ p: p, bb: bb, col: col, par: par, s1: shadowOf(p, bb, 22), s2: shadowOf(p, bb, 5), gx: seed * 37 % GT, gy: seed * 91 % GT }, extra || {});
143
+ }
144
+ const L = {};
145
+ L.far = sheetLayer(ridge(farFn, X0, X1, BOT), 101, C.far, 0.22);
146
+ L.back = sheetLayer(ridge(backFn, X0, X1, BOT), 202, C.back, 0.36);
147
+ L.mid = sheetLayer(ridge(midFn, X0, X1, BOT), 303, C.mid, 0.5);
148
+ L.left = sheetLayer(ridge(leftFn, X0, 1020, BOT), 505, C.bank, 0.92, { grad: [760, 1150] });
149
+ L.right = sheetLayer(ridge(rightFn, 1000, X1, BOT), 606, C.bank, 0.92, { grad: [780, 1150] });
150
+
151
+ // ---------- river ----------
152
+ const RC = [[905, 648], [938, 664], [902, 689], [822, 714], [778, 750], [826, 792], [956, 834], [1096, 878], [1168, 934], [1160, 1010], [1092, 1120], [1012, 1300], [960, 1500], [940, 1760]];
153
+ const CL = []; // dense centreline
154
+ for (let i = 0; i < RC.length - 1; i++) {
155
+ const p0 = RC[Math.max(0, i - 1)], p1 = RC[i], p2 = RC[i + 1], p3 = RC[Math.min(RC.length - 1, i + 2)];
156
+ for (let s = 0; s < 1; s += 1 / 40) {
157
+ const s2 = s * s, s3 = s2 * s;
158
+ const f = (a, b, c, d) => 0.5 * ((2 * b) + (-a + c) * s + (2 * a - 5 * b + 4 * c - d) * s2 + (-a + 3 * b - 3 * c + d) * s3);
159
+ CL.push([f(p0[0], p1[0], p2[0], p3[0]), f(p0[1], p1[1], p2[1], p3[1])]);
160
+ }
161
+ }
162
+ CL.push(RC[RC.length - 1]);
163
+ const CLs = [0]; for (let i = 1; i < CL.length; i++) CLs.push(CLs[i - 1] + Math.hypot(CL[i][0] - CL[i - 1][0], CL[i][1] - CL[i - 1][1]));
164
+ const CLT = CLs[CLs.length - 1];
165
+ const rw = y => Math.max(1, 0.72 * (y - 642));
166
+ function onRiver(s) { // s = arc length
167
+ s = clamp(s, 0, CLT - 0.01); let i = 0; while (CLs[i + 1] < s) i++;
168
+ const a = CL[i], b = CL[i + 1], f = (s - CLs[i]) / ((CLs[i + 1] - CLs[i]) || 1);
169
+ const dx = b[0] - a[0], dy = b[1] - a[1], dl = Math.hypot(dx, dy) || 1;
170
+ return { x: a[0] + dx * f, y: a[1] + dy * f, tx: dx / dl, ty: dy / dl };
171
+ }
172
+ function arcAtY(y) { for (let i = 0; i < CL.length; i++) if (CL[i][1] >= y && i > 20) return CLs[i]; return CLT; }
173
+ function riverOutline(extra) {
174
+ const Lp = [], Rp = [];
175
+ for (let s = 0; s < CLT; s += 6) {
176
+ const q = onRiver(s), w = rw(q.y) / 2 + extra * ss((q.y - 648) / 30);
177
+ const nx = -q.ty, ny = q.tx;
178
+ Lp.push([q.x + nx * w, q.y + ny * w * 0.42]); Rp.push([q.x - nx * w, q.y - ny * w * 0.42]);
179
+ }
180
+ return Lp.concat(Rp.reverse());
181
+ }
182
+ const riverPts = cut(riverOutline(0), 404, 10, 1.0, 2.0);
183
+ const waterPts = cut(riverOutline(16), 405, 14, 1.0, 2.0);
184
+ const floorPts = cut(ridge(floorFn, X0, X1, BOT), 406, 13, 1.2, 2.4);
185
+ const floorPath = toPath(floorPts); toPath(riverPts, floorPath);
186
+ L.floor = { p: floorPath, rule: 'evenodd', bb: bbox(floorPts), col: C.floor, par: 0.72, gx: 300, gy: 120 };
187
+ L.floor.s1 = shadowOf(floorPath, L.floor.bb, 22, 'evenodd'); L.floor.s2 = shadowOf(floorPath, L.floor.bb, 5, 'evenodd');
188
+ const nearFn = x => 806 + 16 * Math.sin(x / 260 + 1) - 46 * g(x, 360, 280) - 40 * g(x, 1560, 320) + 10 * g(x, 960, 200);
189
+ const nearPts = cut(ridge(nearFn, X0, X1, BOT), 407, 13, 1.2, 2.4);
190
+ const nearPath = new Path2D();
191
+ (function () { // two sheets that meet the river banks, so the hole never crosses the ridge
192
+ const Lp = [], Rp = [];
193
+ for (let s = 0; s < CLT; s += 6) { const q = onRiver(s), w = rw(q.y) / 2 - 2, nx = -q.ty, ny = q.tx; Lp.push([q.x + nx * w, q.y + ny * w * 0.42]); Rp.push([q.x - nx * w, q.y - ny * w * 0.42]); }
194
+ const iL = Lp.findIndex(p => p[1] > nearFn(p[0]) + 6), iR = Rp.findIndex(p => p[1] > nearFn(p[0]) + 6);
195
+ const left = []; for (let x = X0; x < Lp[iL][0]; x += 4) left.push([x, nearFn(x)]);
196
+ for (let i = iL; i < Lp.length; i++) left.push(Lp[i]); left.push([X0, BOT + 80]);
197
+ const right = []; for (let i = Rp.length - 1; i >= iR; i--) right.push(Rp[i]);
198
+ for (let x = Rp[iR][0] + 4; x <= X1; x += 4) right.push([x, nearFn(x)]); right.push([X1, BOT + 80]);
199
+ toPath(cut(left, 408, 13, 1.2, 2.4), nearPath); toPath(cut(right, 409, 13, 1.2, 2.4), nearPath);
200
+ })();
201
+ L.near = { p: nearPath, rule: 'nonzero', bb: bbox(nearPts), col: C.floor, par: 0.72, gx: 520, gy: 260 };
202
+ L.near.s1 = shadowOf(nearPath, L.near.bb, 22); L.near.s2 = shadowOf(nearPath, L.near.bb, 5);
203
+ const wp = toPath(waterPts);
204
+ L.water = { p: wp, bb: bbox(waterPts), col: C.water, par: 0.72, gx: 40, gy: 500 };
205
+
206
+ // ---------- trees ----------
207
+ function treeShape(type, h, seed) {
208
+ const p = new Path2D(); const r = rng(seed);
209
+ const tw_ = Math.max(3, h * 0.07);
210
+ toPath(cut([[-tw_ / 2, 4], [tw_ / 2, 4], [tw_ / 2, -h * 0.3], [-tw_ / 2, -h * 0.3]], seed, 6, 0.4, 0.6), p);
211
+ if (type === 0) { // pine
212
+ for (let i = 0; i < 3; i++) { const b = -h * (0.16 + 0.24 * i), a = b - h * 0.44, hw = h * (0.27 - 0.055 * i) * (0.9 + r() * 0.2); toPath(cut([[-hw, b], [hw, b], [r() * 2 - 1, a]], seed + i * 13, 7, 0.5, 0.8), p); }
213
+ } else if (type === 1) { // round
214
+ toPath(cut(circ(0, -h * 0.62, h * 0.33, 60), seed + 3, 7, 0.5, 1.0), p);
215
+ } else { // poplar
216
+ const e = []; for (let i = 0; i < 60; i++) { const a = i / 60 * Math.PI * 2; e.push([Math.cos(a) * h * 0.17, -h * 0.56 + Math.sin(a) * h * 0.42]); } toPath(cut(e, seed + 5, 7, 0.5, 0.9), p);
217
+ }
218
+ return p;
219
+ }
220
+ function makeTrees(list, fn, col, seed, sink) {
221
+ const r = rng(seed);
222
+ return list.map((d, i) => ({ x: d[0], h: d[1], y: fn(d[0]) + d[1] * sink, p: treeShape(d[2], d[1], seed + i * 31), col: col, delay: i * 0.045 + r() * 0.04 }));
223
+ }
224
+ const T = {};
225
+ T.back = makeTrees([[70, 44, 2], [130, 36, 0], [205, 50, 2], [890, 38, 1], [1000, 46, 0], [1060, 34, 2], [1540, 48, 0], [1610, 40, 2], [1690, 54, 0], [1800, 36, 1]], backFn, C.treeBack, 900, 0.14);
226
+ T.mid = makeTrees([[360, 70, 0], [430, 92, 0], [505, 64, 2], [640, 80, 1], [1230, 74, 2], [1300, 98, 0], [1372, 70, 0], [1500, 86, 1], [1620, 66, 2], [1880, 90, 0], [1950, 72, 0]], midFn, C.treeMid, 1200, 0.12);
227
+ T.left = makeTrees([[-90, 250, 0], [40, 300, 0], [170, 220, 2], [300, 170, 0]], leftFn, C.treeBank, 1500, 0.1);
228
+ T.right = makeTrees([[1650, 200, 2], [1760, 260, 0], [1880, 310, 0], [2020, 230, 2]], rightFn, C.treeBank, 1600, 0.1);
229
+
230
+ // ---------- clouds ----------
231
+ function cloudShape(cx, base, s, circles, seed) {
232
+ const cs = circles.map(c => [cx + c[0] * s, base - c[2] * s * 0.55 + c[1] * s, c[2] * s]);
233
+ let xa = 1e9, xb = -1e9; for (const c of cs) { xa = Math.min(xa, c[0] - c[2]); xb = Math.max(xb, c[0] + c[2]); }
234
+ const top = [], bot = [];
235
+ for (let x = xa + 1; x < xb - 1; x += 3) {
236
+ let ty = 1e9, by = -1e9;
237
+ for (const c of cs) { const dx = x - c[0]; if (Math.abs(dx) < c[2]) { const q = Math.sqrt(c[2] * c[2] - dx * dx); ty = Math.min(ty, c[1] - q); by = Math.max(by, c[1] + q); } }
238
+ if (ty < 1e9) { top.push([x, ty]); bot.push([x, Math.min(base, by)]); }
239
+ }
240
+ const pts = cut(top.concat(bot.reverse()), seed, 9, 0.8, 1.6);
241
+ return { p: toPath(pts), bb: bbox(pts) };
242
+ }
243
+ const CLOUDS = [
244
+ Object.assign(cloudShape(0, 0, 1.0, [[-130, 0, 58], [-55, -6, 88], [40, -2, 74], [118, 4, 52]], 700), { x: 380, y: 210, par: 0.2, from: -900, t0: 3.2, drift: 9 }),
245
+ Object.assign(cloudShape(0, 0, 0.8, [[-90, 0, 50], [-20, -8, 78], [70, 0, 58]], 710), { x: 1660, y: 150, par: 0.2, from: 900, t0: 3.35, drift: -7 }),
246
+ Object.assign(cloudShape(0, 0, 0.62, [[-80, 0, 46], [0, -6, 70], [80, 2, 50], [140, 6, 36]], 720), { x: 860, y: 330, par: 0.27, from: -1100, t0: 3.6, drift: 12 })
247
+ ];
248
+
249
+ // ---------- sun ----------
250
+ const SUN = [116, 88, 62].map((r, i) => { const pts = cut(circ(0, 0, r, 160), 800 + i, 9, 0.7, 1.4); return { p: toPath(pts), bb: bbox(pts) }; });
251
+
252
+ // ---------- ferns ----------
253
+ function fernCluster(x0, x1, n, seed, dir) {
254
+ const r = rng(seed), p = new Path2D();
255
+ for (let j = 0; j < n; j++) {
256
+ const bx = x0 + (x1 - x0) * (j + r() * 0.6) / n, hgt = 170 + r() * 230, lean = (r() - 0.5) * 160 + dir * 60, hw = 15 + r() * 12;
257
+ const Lp = [], Rp = [];
258
+ for (let k = 0; k <= 16; k++) { const s = k / 16; const cx = bx + lean * s * s, cy = 1160 - s * hgt; const w = hw * Math.pow(1 - s, 0.85); const tx = 2 * lean * s, ty = -hgt, tl = Math.hypot(tx, ty); Lp.push([cx - ty / tl * w, cy + tx / tl * w]); Rp.push([cx + ty / tl * w, cy - tx / tl * w]); }
259
+ toPath(cut(Lp.concat(Rp.reverse()), seed + j * 7, 8, 0.6, 1.0), p);
260
+ }
261
+ return p;
262
+ }
263
+ const FERN = [{ p: fernCluster(-60, 330, 11, 1900, 1), cx: 140, par: 1.12 }, { p: fernCluster(1600, 1990, 12, 1950, -1), cx: 1800, par: 1.12 }];
264
+
265
+ // ---------- boat (local, width 200, waterline y=0) ----------
266
+ const B = {
267
+ hull: toPath(cut([[-100, -58], [100, -58], [62, 8], [-62, 8]], 1001, 6, 0.4, 0.6)),
268
+ fold: toPath(cut([[-54, -58], [54, -58], [0, -12]], 1002, 6, 0.3, 0.5)),
269
+ sailL: toPath(cut([[-52, -57], [0, -57], [0, -170]], 1003, 6, 0.3, 0.5)),
270
+ sailR: toPath(cut([[0, -57], [52, -57], [0, -170]], 1004, 6, 0.3, 0.5)),
271
+ flag: toPath(cut([[0, -224], [40, -210], [0, -197]], 1005, 4, 0.3, 0.4))
272
+ };
273
+ const sAt0 = arcAtY(700), sAt1 = arcAtY(820);
274
+ const BEND = onRiver(sAt1);
275
+ const F = [BEND.x, BEND.y];
276
+ const TGT = [1015, 793];
277
+ const PARF = 0.72;
278
+ const V = [(TGT[0] - F[0]) / PARF, (TGT[1] - F[1]) / PARF];
279
+ const ZEND = 1.4;
280
+ const BWEND = 0.8 * rw(BEND.y);
281
+ function boatW(t) { // boat width on screen (px) for the slow final close-in, keyed from 8 s
282
+ const c = t - 8, K = [[0, 77], [1.5, 99], [3, 139], [4.5, 210], [6, 300]];
283
+ for (let i = 0; i < K.length - 1; i++) if (c <= K[i + 1][0]) { const f = clamp((c - K[i][0]) / (K[i + 1][0] - K[i][0]), 0, 1); return K[i][1] + (K[i + 1][1] - K[i][1]) * f; }
284
+ return 300;
285
+ }
286
+
287
+ // ---------- water strips ----------
288
+ const STRIPS = []; (function () { const r = rng(4242); for (let i = 0; i < 46; i++) STRIPS.push({ ph: r(), lat: (r() - 0.5) * 1.3, len: 0.12 + r() * 0.16, sp: 0.032 + r() * 0.02 }); })();
289
+
290
+ // ---------- birds ----------
291
+ const FLOCK = [
292
+ { t0: 4.4, t1: 10.6, x0: -160, x1: 2150, y: 300, par: 0.34, birds: [[0, 0, 22, 0], [-70, 26, 18, 1.3], [-120, -18, 16, 2.1], [-180, 34, 14, 0.7]] },
293
+ { t0: 7.3, t1: 12.6, x0: 2150, x1: -200, y: 190, par: 0.3, birds: [[0, 0, 19, 0.4], [60, 22, 15, 1.7], [110, -10, 13, 2.6]] }
294
+ ];
295
+
296
+ // ---------- drawing ----------
297
+ const SH = { dx: -3, dy: -3 };
298
+ let CAM = { Z: 1, u: 0 };
299
+ function setLayer(par, slide, rot) {
300
+ const k = 1 + (CAM.Z - 1) * par;
301
+ const tx = F[0] * (1 - k) + V[0] * CAM.u * par, ty = F[1] * (1 - k) + V[1] * CAM.u * par + (slide || 0);
302
+ ctx.setTransform(k, 0, 0, k, tx, ty);
303
+ if (rot) { ctx.translate(960, 900); ctx.rotate(rot); ctx.translate(-960, -900); }
304
+ return k;
305
+ }
306
+ function sheet(p, base, o) {
307
+ o = o || {};
308
+ const rule = o.rule || 'nonzero', rim = o.rim === undefined ? 2.4 : o.rim;
309
+ const rimc = mix(base, lit(C.rimT), o.rimAmt === undefined ? RIMA : o.rimAmt);
310
+ if (o.shadow) { ctx.shadowColor = css(P.ink, o.shadow); ctx.shadowBlur = o.blur || 12; ctx.shadowOffsetX = SH.dx * (o.so || 0.6); ctx.shadowOffsetY = SH.dy * (o.so || 0.6) + (o.sy || 0); }
311
+ ctx.fillStyle = css(rimc); ctx.fill(p, rule);
312
+ if (o.shadow) { ctx.shadowColor = 'rgba(0,0,0,0)'; ctx.shadowBlur = 0; ctx.shadowOffsetX = 0; ctx.shadowOffsetY = 0; }
313
+ ctx.save(); ctx.clip(p, rule);
314
+ ctx.translate(0, rim); ctx.fillStyle = o.fill || css(base); ctx.fill(p, rule); ctx.translate(0, -rim);
315
+ if (o.bb) { grain.setTransform(new DOMMatrix([1, 0, 0, 1, o.gx || 0, o.gy || 0])); ctx.globalAlpha = o.ga === undefined ? 1 : o.ga; ctx.fillStyle = grain; ctx.fillRect(o.bb[0] - 4, o.bb[1] - 4, o.bb[2] - o.bb[0] + 8, o.bb[3] - o.bb[1] + 8); ctx.globalAlpha = 1; }
316
+ ctx.restore();
317
+ }
318
+ function bigShadow(Ly, a, lift) {
319
+ lift = lift || 0; // a sheet still in the air throws a wider, softer shadow that tightens as it lands
320
+ ctx.globalAlpha = (0.4 + 0.2 * lift) * a; ctx.drawImage(Ly.s1.c, Ly.s1.x0 + SH.dx * 1.6 - lift * 30, Ly.s1.y0 + SH.dy * 1.6 + lift * 70, Ly.s1.w, Ly.s1.h);
321
+ ctx.globalAlpha = 0.26 * a; ctx.drawImage(Ly.s2.c, Ly.s2.x0 + SH.dx * 0.4, Ly.s2.y0 + SH.dy * 0.4, Ly.s2.w, Ly.s2.h);
322
+ ctx.globalAlpha = 1;
323
+ }
324
+ function bigLayer(Ly, t, land) {
325
+ const e = tw(t, land - 0.55, 0.55, 'back.out(0.7)');
326
+ if (e <= 0) return false;
327
+ const slide = (1 - e) * 820, rot = (1 - tw(t, land - 0.55, 0.75, 'back.out(1.4)')) * -0.014;
328
+ setLayer(Ly.par, slide, rot);
329
+ bigShadow(Ly, 1, clamp((1 - e) * 3, 0, 1));
330
+ let fill;
331
+ if (Ly.grad) { fill = ctx.createLinearGradient(0, Ly.grad[0], 0, Ly.grad[1]); fill.addColorStop(0, css(mix(lit(Ly.col), lit(C.rimT), 0.16))); fill.addColorStop(1, css(mix(lit(Ly.col), P.ink, 0.12))); }
332
+ sheet(Ly.p, lit(Ly.col), { rule: Ly.rule, bb: Ly.bb, gx: Ly.gx, gy: Ly.gy, fill: fill });
333
+ return true;
334
+ }
335
+ function drawTrees(list, t, start, par, slideOf) {
336
+ for (const tr of list) {
337
+ const e = tw(t, start + tr.delay, 0.42, 'back.out(1.5)');
338
+ if (e <= 0) continue;
339
+ setLayer(par, slideOf || 0);
340
+ ctx.translate(tr.x, tr.y + (1 - e) * tr.h * 1.15);
341
+ sheet(tr.p, lit(tr.col), { shadow: 0.28, blur: 10, rim: Math.max(1.4, tr.h * 0.012), bb: [-tr.h * 0.4, -tr.h * 1.05, tr.h * 0.4, 6], gx: tr.x, gy: tr.h });
342
+ }
343
+ }
344
+ function birdPath(s, flap) {
345
+ const wy = Math.sin(flap) * s * 0.55, p = new Path2D();
346
+ p.moveTo(-s, wy - s * 0.1);
347
+ p.quadraticCurveTo(-s * 0.5, -s * 0.28 + wy * 0.45, 0, s * 0.06);
348
+ p.quadraticCurveTo(s * 0.5, -s * 0.28 + wy * 0.45, s, wy - s * 0.1);
349
+ p.quadraticCurveTo(s * 0.5, -s * 0.06 + wy * 0.5, s * 0.06, s * 0.3);
350
+ p.lineTo(-s * 0.06, s * 0.3);
351
+ p.quadraticCurveTo(-s * 0.5, -s * 0.06 + wy * 0.5, -s, wy - s * 0.1);
352
+ return p;
353
+ }
354
+ function drawFlock(fl, t) {
355
+ if (t < fl.t0 || t > fl.t1) return;
356
+ const q = (t - fl.t0) / (fl.t1 - fl.t0);
357
+ for (const b of fl.birds) {
358
+ setLayer(fl.par, 0);
359
+ const x = fl.x0 + (fl.x1 - fl.x0) * q + b[0] * Math.sign(fl.x1 - fl.x0), y = fl.y + b[1] + Math.sin(t * 1.7 + b[3]) * 10;
360
+ ctx.translate(x, y); if (fl.x1 < fl.x0) ctx.scale(-1, 1);
361
+ ctx.rotate(Math.sin(t * 1.3 + b[3]) * 0.06);
362
+ const p = birdPath(b[2], t * 15 + b[3] * 2);
363
+ ctx.shadowColor = css(P.ink, 0.22); ctx.shadowBlur = 6; ctx.shadowOffsetX = SH.dx * 0.8; ctx.shadowOffsetY = 5;
364
+ ctx.fillStyle = css(lit(C.bird)); ctx.fill(p);
365
+ ctx.shadowColor = 'rgba(0,0,0,0)'; ctx.shadowBlur = 0; ctx.shadowOffsetX = 0; ctx.shadowOffsetY = 0;
366
+ }
367
+ }
368
+
369
+ // ---------- extra set dressing ----------
370
+ function capsule(cx, cy, w, h, seed) { const p = []; const r = h / 2; for (let i = 0; i <= 30; i++) { const a = -Math.PI / 2 + i / 30 * Math.PI; p.push([cx + w / 2 - r + Math.cos(a) * r, cy + Math.sin(a) * r]); } for (let i = 0; i <= 30; i++) { const a = Math.PI / 2 + i / 30 * Math.PI; p.push([cx - w / 2 + r + Math.cos(a) * r, cy + Math.sin(a) * r]); } const c = cut(p, seed, 10, 0.7, 1.3); return { p: toPath(c), bb: bbox(c) }; }
371
+ const STRIPC = [
372
+ Object.assign(capsule(0, 0, 760, 26, 1301), { x: 520, y: 238, par: 0.16, from: -1400, t0: 5.6, drift: 6 }),
373
+ Object.assign(capsule(0, 0, 520, 20, 1302), { x: 1560, y: 300, par: 0.17, from: 1300, t0: 6.1, drift: -5 }),
374
+ Object.assign(capsule(0, 0, 640, 22, 1303), { x: 980, y: 168, par: 0.15, from: -1500, t0: 6.6, drift: 7 })
375
+ ];
376
+ C.stripC = [mix(P.cream, P.sand, 0.25), mix(P.sand, P.cream, 0.3), mix(P.rose, P.cream, 0.3)];
377
+ C.field = [mix(P.sage, P.cream, 0.18), mix(P.sage, P.sand, 0.4), mix(P.sand, P.rose, 0.35)];
378
+ C.field2 = [mix(P.sage, P.dsage, 0.2), mix(P.dsage, P.sand, 0.35), mix(P.dsage, P.rose, 0.4)];
379
+ C.bush = [mix(P.dsage, P.teal, 0.4), mix(P.dsage, P.teal, 0.3), mix(P.teal, P.dsage, 0.3)];
380
+ C.reed = [mix(P.teal, P.dsage, 0.25), mix(P.teal, P.dsage, 0.3), mix(P.teal, P.ink, 0.25)];
381
+ C.pollen = [P.cream, mix(P.cream, P.sand, 0.3), mix(P.cream, P.rose, 0.35)];
382
+ // fields: perspective lens patches on the meadow, away from the river
383
+ function lens(cx, cy, w, h, seed) { const p = []; for (let i = 0; i < 70; i++) { const a = i / 70 * Math.PI * 2; p.push([cx + Math.cos(a) * w / 2, cy + Math.sin(a) * h / 2 * (Math.sin(a) < 0 ? 1 : 0.7)]); } const c = cut(p, seed, 9, 0.7, 1.4); return { p: toPath(c), bb: bbox(c) }; }
384
+ const FIELDS = [[520, 668, 360, 26, 0], [300, 700, 300, 34, 1], [1360, 664, 300, 22, 0], [1560, 690, 420, 30, 1], [640, 760, 240, 40, 1], [1440, 770, 380, 46, 0], [1700, 744, 220, 30, 1], [140, 772, 260, 40, 0]].map((f, i) => Object.assign(lens(f[0], f[1], f[2], f[3], 1400 + i), { alt: f[4], d: i * 0.05 }));
385
+ const FIELDS2 = [[260, 900, 520, 70], [1600, 880, 460, 60], [620, 840, 240, 34]].map((f, i) => Object.assign(lens(f[0], f[1], f[2], f[3], 1450 + i), { d: i * 0.06 }));
386
+ // bushes along the river banks
387
+ const BUSH = []; (function () { const r = rng(1500); for (let i = 0; i < 14; i++) { const y = 728 + i * 16 + r() * 8; const s = arcAtY(y); const q = onRiver(s); const w = rw(q.y); const side = i % 2 ? 1 : -1; const bx = q.x + side * (w * 0.55 + 6 + r() * w * 0.25); const rad = 4 + (y - 640) * 0.075 * (0.7 + r() * 0.5); const pts = cut(circ(0, 0, rad, 40), 1500 + i, 5, 0.4, 0.7); const pp = toPath(pts); const r2 = rad * (0.6 + r() * 0.2); toPath(cut(circ(rad * 0.75 * side, rad * 0.25, r2, 30), 1550 + i, 5, 0.4, 0.6), pp); BUSH.push({ x: bx, y: q.y - rad * 0.4, r: rad, p: pp, d: 0.03 * i }); } })();
388
+ // reeds at the near banks where the boat lands
389
+ function reedCluster(bx, by, n, seed, hmax) { const r = rng(seed), p = new Path2D(); for (let j = 0; j < n; j++) { const x = bx + (j - n / 2) * 9 + r() * 6, hgt = hmax * (0.55 + r() * 0.45), lean = (r() - 0.5) * 40, hw = 3.2 + r() * 2; const Lp = [], Rp = []; for (let k = 0; k <= 10; k++) { const s = k / 10, cx = x + lean * s * s, cy = by - s * hgt, w = hw * Math.pow(1 - s, 0.7); Lp.push([cx - w, cy]); Rp.push([cx + w, cy]); } toPath(cut(Lp.concat(Rp.reverse()), seed + j, 5, 0.3, 0.5), p); if (r() < 0.45) { toPath(cut([[x + lean - 4, by - hgt * 0.82], [x + lean + 4, by - hgt * 0.82], [x + lean + 4, by - hgt * 0.62], [x + lean - 4, by - hgt * 0.62]], seed + 50 + j, 4, 0.3, 0.4), p); } } return p; }
390
+ const REEDS = [{ p: reedCluster(1000, 990, 9, 1700, 120), x: 1000, y: 990 }, { p: reedCluster(1318, 915, 7, 1750, 96), x: 1318, y: 915 }, { p: reedCluster(790, 884, 6, 1800, 70), x: 790, y: 884 }];
391
+ const STARS = [[560, 200, 22, 7.0], [1180, 165, 17, 7.5], [300, 240, 15, 8.0], [1520, 215, 19, 8.5], [880, 130, 13, 8.25]];
392
+ const STARP = STARS.map((st, i) => { const p = []; for (let k = 0; k < 8; k++) { const a = k / 8 * Math.PI * 2 - Math.PI / 2, r = k % 2 ? st[2] * 0.36 : st[2]; p.push([Math.cos(a) * r, Math.sin(a) * r]); } return toPath(cut(p, 2100 + i, 3, 0.2, 0.3)); });
393
+ const POLLEN = []; (function () { const r = rng(1900); for (let i = 0; i < 46; i++) POLLEN.push({ x: r() * 1900 + 10, y: 380 + r() * 600, r: 1.2 + r() * 2.2, ph: r() * 6.28, sp: 6 + r() * 14 }); })();
394
+
395
+ // background buffer for depth of field
396
+ const bgC = document.createElement('canvas'); bgC.width = W; bgC.height = H;
397
+ const bgX = bgC.getContext('2d');
398
+ const grainMain = grain, grainBg = bgX.createPattern(grainC, 'repeat');
399
+ const mainX = ctx;
400
+ const fgC = document.createElement('canvas'); fgC.width = W; fgC.height = H;
401
+ const fgX = fgC.getContext('2d'); const grainFg = fgX.createPattern(grainC, 'repeat');
402
+ function useCtx(which) { if (which === 'bg') { ctx = bgX; grain = grainBg; } else if (which === 'fg') { ctx = fgX; grain = grainFg; } else { ctx = mainX; grain = grainMain; } }
403
+
404
+ let SUNPOS = [1420, 270];
405
+ function boatState(t) {
406
+ const ap = tw(t, 3.9, 0.55, 'back.out(1.4)');
407
+ if (ap <= 0) return null;
408
+ const tr = tw(t, 4.4, 6.0, 'sine.inOut');
409
+ const s = sAt0 + (sAt1 - sAt0) * tr;
410
+ const q = onRiver(s);
411
+ const bw = 0.8 * rw(q.y);
412
+ const vel = ss((t - 4.4) / 1.5); // keeps sailing: the wake never stops
413
+ return { x: q.x, y: q.y, tx: q.tx, ty: q.ty, s: s, bw: bw, ap: ap, o: Math.min(1, ap * 1.6), vel: vel };
414
+ }
415
+
416
+ function draw(t) {
417
+ LT = 2 * tw(t, 4.6, 4.4, 'sine.inOut');
418
+ const gl = LT / 2;
419
+ RIMA = 0.36 + 0.24 * gl;
420
+ SH.dx = -3 - 13 * gl; SH.dy = -3 + gl;
421
+ const pre = tw(t, 0, 4.2, 'sine.out'), push = tw(t, 4.0, 6.4, 'power2.inOut');
422
+ CAM.Z = 1.04 - 0.04 * pre + (ZEND - 1) * push;
423
+ // 10.4 s on: keep closing in on the boat so it grows smoothly to about 300 px wide by 14 s
424
+ if (t > 10.4) { const kE = 1 + (ZEND - 1) * PARF, kR = boatW(t) / BWEND, kf = kE + Math.log(1 + Math.exp((kR - kE) * 12)) / 12 - Math.log(2) / 12 * Math.exp(-(t - 10.4) * 6); CAM.Z = 1 + (kf - 1) / PARF; }
425
+ CAM.u = push;
426
+
427
+ // ======== background buffer: sky .. mid hills ========
428
+ useCtx('bg');
429
+ ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.globalCompositeOperation = 'source-over'; ctx.globalAlpha = 1;
430
+ setLayer(0.12, 0);
431
+ const sg = ctx.createLinearGradient(0, -260, 0, 620);
432
+ sg.addColorStop(0, css(lit(C.skyTop))); sg.addColorStop(0.55, css(lit(C.skyMid))); sg.addColorStop(1, css(lit(C.skyBot)));
433
+ ctx.fillStyle = sg; ctx.fillRect(-700, -700, 3300, 2000);
434
+ grain.setTransform(new DOMMatrix([1, 0, 0, 1, 0, 0])); ctx.globalAlpha = 0.85; ctx.fillStyle = grain; ctx.fillRect(-700, -700, 3300, 2000); ctx.globalAlpha = 1;
435
+
436
+ // sun
437
+ const sRise = tw(t, 1.0, 0.6, 'back.out(1.2)'), sSet = tw(t, 5.0, 6.5, 'sine.inOut');
438
+ if (sRise > 0) {
439
+ const sy = 640 - 370 * sRise + 105 * sSet, sx = 1420 + 30 * sSet;
440
+ const cols = [C.sun0, C.sun1, C.sun2];
441
+ for (let i = 0; i < 3; i++) {
442
+ const e = tw(t, 1.0 + i * 0.08, 0.6, 'back.out(1.3)');
443
+ setLayer(0.18, 0); ctx.translate(sx, sy + (1 - e) * 140); ctx.rotate(t * 0.02 * (i % 2 ? -1 : 1));
444
+ sheet(SUN[i].p, lit(cols[i]), { shadow: 0.2, blur: 18, so: 0.8, rim: 2, bb: SUN[0].bb, gx: i * 200 });
445
+ }
446
+ SUNPOS = [sx, sy];
447
+ }
448
+ // long sunset strip clouds
449
+ for (const c of STRIPC) {
450
+ const e = tw(t, c.t0, 0.8, 'power3.out'); if (e <= 0) continue;
451
+ setLayer(c.par, 0); ctx.translate(c.x + (1 - e) * c.from + c.drift * (t - c.t0), c.y);
452
+ sheet(c.p, lit(C.stripC), { shadow: 0.16, blur: 12, so: 1, sy: 4, rim: 1.6, bb: c.bb, gx: c.x });
453
+ }
454
+ for (const c of CLOUDS) {
455
+ const e = tw(t, c.t0, 0.75, 'power3.out'); if (e <= 0) continue;
456
+ setLayer(c.par, 0); ctx.translate(c.x + (1 - e) * c.from + c.drift * (t - c.t0), c.y + Math.sin(t * 0.7 + c.x) * 3);
457
+ sheet(c.p, lit(C.cloud), { shadow: 0.2, blur: 16, so: 1, sy: 4, rim: 2, bb: c.bb, gx: c.x });
458
+ }
459
+ for (let i = 0; i < STARS.length; i++) {
460
+ const st = STARS[i], e = tw(t, st[3], 0.5, 'back.out(2.4)'); if (e <= 0) continue;
461
+ setLayer(0.12, 0); ctx.translate(st[0], st[1]); ctx.rotate(0.3 * (1 - e) + Math.sin(t * 1.5 + i) * 0.05); ctx.scale(0.6 + 0.4 * e, 0.6 + 0.4 * e); ctx.globalAlpha = Math.min(1, e * 2);
462
+ sheet(STARP[i], lit(C.cloud), { shadow: 0.25, blur: 6, so: 0.4, rim: 1.2, bb: [-30, -30, 30, 30], gx: i * 50 });
463
+ ctx.globalAlpha = 1;
464
+ }
465
+ drawFlock(FLOCK[1], t);
466
+ bigLayer(L.far, t, 0.5);
467
+ drawTrees(T.back, t, 1.05, 0.36, 0);
468
+ bigLayer(L.back, t, 1.0);
469
+ drawTrees(T.mid, t, 2.0, 0.5, 0);
470
+ bigLayer(L.mid, t, 2.0);
471
+
472
+ // ======== composite background with depth of field ========
473
+ useCtx('main');
474
+ ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.globalAlpha = 1; ctx.globalCompositeOperation = 'source-over';
475
+ ctx.drawImage(bgC, 0, 0);
476
+ const dof = 2.4 * push + 2.2 * clamp((CAM.Z - ZEND) / 2, 0, 1);
477
+ if (dof > 0.15) { ctx.filter = 'blur(' + dof.toFixed(2) + 'px)'; ctx.drawImage(bgC, 0, 0); ctx.filter = 'none'; }
478
+ drawFlock(FLOCK[0], t);
479
+
480
+ // ======== water, meadow, boat ========
481
+ const fe = tw(t, 1.95, 0.55, 'back.out(0.7)');
482
+ const bs = boatState(t);
483
+ if (fe > 0) {
484
+ const slide = (1 - fe) * 820;
485
+ setLayer(PARF, slide);
486
+ const wg = ctx.createLinearGradient(0, 640, 0, 1150);
487
+ wg.addColorStop(0, css(lit(C.waterFar))); wg.addColorStop(0.4, css(lit(C.water))); wg.addColorStop(1, css(mix(lit(C.water), P.ink, 0.18)));
488
+ sheet(L.water.p, lit(C.water), { fill: wg, rim: 0, bb: L.water.bb, gx: 40, gy: 500, ga: 0.7 });
489
+ ctx.save(); ctx.clip(L.water.p);
490
+ ctx.lineCap = 'round';
491
+ const sc = lit(C.strip);
492
+ // sun glint column on the water at dusk
493
+ for (const st of STRIPS) {
494
+ const a = (st.ph + t * st.sp) % 1;
495
+ const s = Math.pow(a, 1.35) * CLT * 0.86;
496
+ const q = onRiver(s); const w = rw(q.y);
497
+ const nx = -q.ty, ny = q.tx;
498
+ const cx = q.x + nx * w * 0.5 * st.lat, cy = q.y + ny * w * 0.5 * st.lat * 0.42;
499
+ const hl = w * st.len, th = Math.max(1.2, w * 0.026);
500
+ ctx.globalAlpha = Math.sin(Math.PI * a) * 0.85;
501
+ ctx.strokeStyle = css(sc); ctx.lineWidth = th;
502
+ ctx.beginPath(); ctx.moveTo(cx - hl, cy); ctx.quadraticCurveTo(cx, cy - th * 1.2, cx + hl, cy); ctx.stroke();
503
+ }
504
+ ctx.globalAlpha = 1;
505
+ if (bs) {
506
+ // wake: two trailing paper strips behind the boat
507
+ for (let i = 1; i <= 6; i++) {
508
+ const q = onRiver(bs.s - i * bs.bw * 0.32 - ((t * 40) % (bs.bw * 0.32)));
509
+ const w = rw(q.y), nx = -q.ty, ny = q.tx, spread = bs.bw * (0.22 + i * 0.09);
510
+ ctx.globalAlpha = bs.vel * 0.75 * (1 - i / 7) * bs.o; ctx.strokeStyle = css(sc); ctx.lineWidth = Math.max(1.2, w * 0.022);
511
+ for (const sd of [-1, 1]) { const cx = q.x + nx * spread * sd, cy = q.y + ny * spread * sd * 0.42; ctx.beginPath(); ctx.moveTo(cx - w * 0.06, cy); ctx.lineTo(cx + w * 0.06, cy); ctx.stroke(); }
512
+ }
513
+ for (const rt of [4.05, 10.75, 11.0, 11.5]) {
514
+ if (t < rt || t > rt + 1.5) continue;
515
+ const q = (t - rt) / 1.5, e = ease('power2.out')(q);
516
+ const rx = bs.bw * (0.5 + 0.9 * e);
517
+ ctx.globalAlpha = (1 - q) * 0.9; ctx.strokeStyle = css(sc); ctx.lineWidth = Math.max(1.5, bs.bw * 0.022 * (1 - q * 0.6));
518
+ ctx.beginPath(); ctx.ellipse(bs.x, bs.y + bs.bw * 0.02, rx, rx * 0.26, 0, 0, Math.PI * 2); ctx.stroke();
519
+ }
520
+ ctx.globalAlpha = 0.34 * bs.o;
521
+ const rg = ctx.createRadialGradient(0, 0, 0, 0, 0, 1);
522
+ rg.addColorStop(0, css(P.ink, 0.9)); rg.addColorStop(1, css(P.ink, 0));
523
+ ctx.save(); ctx.translate(bs.x + SH.dx * 0.5, bs.y + bs.bw * 0.05); ctx.scale(bs.bw * 0.62, bs.bw * 0.11); ctx.fillStyle = rg; ctx.fillRect(-1, -1, 2, 2); ctx.restore();
524
+ ctx.globalAlpha = 1;
525
+ }
526
+ ctx.restore();
527
+ // meadow sheet with the river cut out
528
+ setLayer(PARF, slide, (1 - tw(t, 1.95, 0.75, 'back.out(1.4)')) * -0.014);
529
+ bigShadow(L.floor, 1, clamp((1 - fe) * 3, 0, 1));
530
+ const fg = ctx.createLinearGradient(0, 630, 0, 1080); fg.addColorStop(0, css(lit(C.floorFar))); fg.addColorStop(0.55, css(mix(lit(C.floorFar), lit(C.floor), 0.75))); fg.addColorStop(1, css(lit(C.floor)));
531
+ sheet(L.floor.p, lit(C.floor), { rule: 'evenodd', bb: L.floor.bb, gx: 300, gy: 120, fill: fg });
532
+ // fields + bushes placed onto the meadow
533
+ for (const f of FIELDS) {
534
+ const e = tw(t, 2.45 + f.d, 0.4, 'back.out(1.6)'); if (e <= 0) continue;
535
+ setLayer(PARF, slide); ctx.translate(0, (1 - e) * 30); ctx.globalAlpha = Math.min(1, e * 2);
536
+ sheet(f.p, lit(f.alt ? C.field2 : C.field), { shadow: 0.2, blur: 8, so: 0.5, rim: 1.6, bb: f.bb, gx: f.bb[0] });
537
+ { const fb = lit(f.alt ? C.field2 : C.field); ctx.save(); ctx.clip(f.p); const n = 9, fw = f.bb[2] - f.bb[0];
538
+ for (let i = -2; i <= n + 2; i++) { const x = f.bb[0] + fw * i / n, vx = 960 + (x - 960) * 0.1;
539
+ ctx.strokeStyle = css(mix(fb, P.ink, 0.22), 0.55); ctx.lineWidth = 1.6; ctx.beginPath(); ctx.moveTo(x, f.bb[3] + 4); ctx.lineTo(vx, 560); ctx.stroke();
540
+ ctx.strokeStyle = css(mix(fb, P.cream, 0.4), 0.5); ctx.lineWidth = 1; ctx.beginPath(); ctx.moveTo(x - 2, f.bb[3] + 4); ctx.lineTo(vx - 1, 560); ctx.stroke(); }
541
+ ctx.restore(); }
542
+ ctx.globalAlpha = 1;
543
+ }
544
+ const drawBush = (b) => {
545
+ const e = tw(t, 2.55 + b.d, 0.4, 'back.out(1.8)'); if (e <= 0) return;
546
+ setLayer(PARF, slide); ctx.translate(b.x, b.y + (1 - e) * b.r * 2);
547
+ sheet(b.p, lit(C.bush), { shadow: 0.25, blur: 6, so: 0.4, rim: Math.max(1, b.r * 0.08), bb: [-b.r * 2, -b.r * 1.5, b.r * 2, b.r * 1.5], gx: b.x });
548
+ };
549
+ for (const b of BUSH) if (b.y < nearFn(b.x) - 4) drawBush(b);
550
+ // second meadow terrace
551
+ { const ne = tw(t, 2.15, 0.55, 'back.out(0.7)');
552
+ if (ne > 0) {
553
+ setLayer(PARF, slide + (1 - ne) * 700, (1 - tw(t, 2.15, 0.75, 'back.out(1.4)')) * 0.012);
554
+ bigShadow(L.near, 1, clamp((1 - ne) * 3, 0, 1));
555
+ const ng = ctx.createLinearGradient(0, 760, 0, 1100); ng.addColorStop(0, css(lit(C.nearF))); ng.addColorStop(1, css(lit(C.nearB)));
556
+ sheet(L.near.p, lit(C.nearF), { rule: 'nonzero', bb: L.near.bb, gx: 520, gy: 260, fill: ng });
557
+ for (const f of FIELDS2) {
558
+ const e = tw(t, 2.7 + f.d, 0.4, 'back.out(1.6)'); if (e <= 0) continue;
559
+ ctx.save(); ctx.translate(0, (1 - e) * 40); ctx.globalAlpha = Math.min(1, e * 2);
560
+ sheet(f.p, lit(C.field2), { shadow: 0.22, blur: 8, so: 0.5, rim: 2, bb: f.bb, gx: f.bb[0] });
561
+ const fb = lit(C.field2); ctx.clip(f.p); const n = 10, fw = f.bb[2] - f.bb[0];
562
+ for (let i = -2; i <= n + 2; i++) { const x = f.bb[0] + fw * i / n, vx = 960 + (x - 960) * 0.1;
563
+ ctx.strokeStyle = css(mix(fb, P.ink, 0.22), 0.55); ctx.lineWidth = 2; ctx.beginPath(); ctx.moveTo(x, f.bb[3] + 4); ctx.lineTo(vx, 560); ctx.stroke();
564
+ ctx.strokeStyle = css(mix(fb, P.cream, 0.4), 0.5); ctx.lineWidth = 1.2; ctx.beginPath(); ctx.moveTo(x - 2.5, f.bb[3] + 4); ctx.lineTo(vx - 1, 560); ctx.stroke(); }
565
+ ctx.restore(); ctx.globalAlpha = 1;
566
+ }
567
+ }
568
+ }
569
+ for (const b of BUSH) if (b.y >= nearFn(b.x) - 4) drawBush(b);
570
+ if (bs) { setLayer(PARF, slide); drawBoat(t, bs); }
571
+ // reeds in front of the boat
572
+ for (let i = 0; i < REEDS.length; i++) {
573
+ const rd = REEDS[i]; const e = tw(t, 2.7 + i * 0.08, 0.45, 'back.out(1.6)'); if (e <= 0) continue;
574
+ setLayer(PARF, slide); ctx.translate(rd.x, rd.y + (1 - e) * 110); ctx.rotate(Math.sin(t * 1.6 + i * 1.7) * 0.03); ctx.translate(-rd.x, -rd.y);
575
+ sheet(rd.p, lit(C.reed), { shadow: 0.25, blur: 6, so: 0.5, rim: 1.2, bb: [rd.x - 80, rd.y - 130, rd.x + 80, rd.y + 4], gx: rd.x });
576
+ }
577
+ }
578
+
579
+ useCtx('fg'); ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.clearRect(0, 0, W, H);
580
+ drawTrees(T.left, t, 3.0, 0.92, 0);
581
+ drawTrees(T.right, t, 3.1, 0.92, 0);
582
+ bigLayer(L.left, t, 2.5);
583
+ bigLayer(L.right, t, 2.62);
584
+ useCtx('main'); ctx.setTransform(1, 0, 0, 1, 0, 0);
585
+ { const fd = 3.2 * push; if (fd > 0.15) ctx.filter = 'blur(' + fd.toFixed(2) + 'px)'; ctx.drawImage(fgC, 0, 0); ctx.filter = 'none'; }
586
+
587
+ // drifting pollen in the golden light
588
+ if (gl > 0.02) {
589
+ setLayer(0.85, 0);
590
+ ctx.fillStyle = css(lit(C.pollen));
591
+ for (const p of POLLEN) {
592
+ const x = p.x + Math.sin(t * 0.9 + p.ph) * 18 + t * p.sp * 0.6, y = p.y - t * p.sp + Math.sin(t * 1.3 + p.ph * 2) * 8;
593
+ ctx.globalAlpha = Math.min(1, gl * 2) * (0.45 + 0.4 * Math.sin(t * 2 + p.ph));
594
+ ctx.beginPath(); ctx.arc(x, y, p.r, 0, Math.PI * 2); ctx.fill();
595
+ }
596
+ ctx.globalAlpha = 1;
597
+ }
598
+
599
+ // foreground grass
600
+ for (let i = 0; i < 2; i++) {
601
+ const fz = FERN[i]; const e = tw(t, 3.0 + i * 0.1, 0.55, 'back.out(0.9)'); if (e <= 0) continue;
602
+ setLayer(fz.par, (1 - e) * 600 + tw(t, 5.0, 0.9, 'power2.in') * 900);
603
+ ctx.translate(fz.cx, 1160); ctx.rotate(Math.sin(t * 1.25 + i * 2) * 0.018 + (1 - e) * 0.05 * (i ? -1 : 1)); ctx.translate(-fz.cx, -1160);
604
+ sheet(fz.p, lit(C.fern), { shadow: 0.35, blur: 22, so: 1.2, rim: 2.2, bb: [fz.cx - 420, 720, fz.cx + 420, 1180], gx: 77 * i });
605
+ }
606
+
607
+ // light: dusk glow from the sun + vignette
608
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
609
+ const k = 1 + (CAM.Z - 1) * 0.18;
610
+ const sx = SUNPOS[0] * k + F[0] * (1 - k) + V[0] * CAM.u * 0.18, sy = SUNPOS[1] * k + F[1] * (1 - k) + V[1] * CAM.u * 0.18;
611
+ if (gl > 0.01) {
612
+ ctx.globalCompositeOperation = 'soft-light';
613
+ const rg = ctx.createRadialGradient(sx, sy, 0, sx, sy, 1400);
614
+ rg.addColorStop(0, css(P.rose, 0.8 * gl)); rg.addColorStop(0.45, css(P.sand, 0.35 * gl)); rg.addColorStop(1, css(P.teal, 0.25 * gl));
615
+ ctx.fillStyle = rg; ctx.fillRect(0, 0, W, H);
616
+ }
617
+ ctx.globalCompositeOperation = 'multiply';
618
+ const vg = ctx.createRadialGradient(W / 2, H * 0.5, H * 0.5, W / 2, H * 0.5, H * 1.15);
619
+ vg.addColorStop(0, 'rgba(255,255,255,1)'); vg.addColorStop(1, css(mix(mix(P.cream, P.rose, gl * 0.5), P.ink, 0.13 + 0.1 * gl)));
620
+ ctx.fillStyle = vg; ctx.fillRect(0, 0, W, H);
621
+ ctx.globalCompositeOperation = 'source-over';
622
+ }
623
+
624
+ function drawBoat(t, bs) {
625
+ const sc = bs.bw / 200;
626
+ ctx.save();
627
+ ctx.translate(bs.x, bs.y + (1 - bs.ap) * bs.bw * 0.35 + Math.sin(t * 2.6) * bs.bw * 0.012);
628
+ ctx.rotate(Math.sin(t * 2.1) * 0.035);
629
+ ctx.scale(sc * (0.8 + 0.2 * bs.ap), sc * (0.8 + 0.2 * bs.ap));
630
+ ctx.globalAlpha = bs.o;
631
+ const bb = [-110, -230, 110, 12];
632
+ sheet(B.hull, lit(C.hullL), { shadow: 0.3, blur: 10, rim: 2, bb: bb, gx: 10, rimAmt: 0.3 });
633
+ sheet(B.fold, lit(C.hullF), { rim: 1.6, bb: bb, gx: 30, rimAmt: 0.3 });
634
+ sheet(B.sailR, lit(C.hullD), { shadow: 0.25, blur: 8, so: 0.5, rim: 1.8, bb: bb, gx: 60 });
635
+ sheet(B.sailL, lit(C.hullL), { rim: 1.8, bb: bb, gx: 90, rimAmt: 0.5 });
636
+ const fp = tw(t, 7.85, 0.5, 'back.out(2.2)');
637
+ if (fp > 0) {
638
+ ctx.save(); ctx.translate(0, -168); ctx.scale(1, 0.6 + 0.4 * fp); ctx.globalAlpha = bs.o * Math.min(1, fp * 2.5);
639
+ ctx.strokeStyle = css(P.ink); ctx.lineWidth = 3; ctx.lineCap = 'round'; ctx.beginPath(); ctx.moveTo(0, 2); ctx.lineTo(0, -58); ctx.stroke();
640
+ ctx.translate(0, 168);
641
+ ctx.translate(0, -217); ctx.scale(1, 1 + Math.sin(t * 7) * 0.08); ctx.translate(0, 217);
642
+ sheet(B.flag, P.rose, { shadow: 0.25, blur: 6, rim: 1.4, bb: [-4, -230, 46, -190], gx: 5, rimAmt: 0.35 });
643
+ ctx.restore();
644
+ }
645
+ ctx.globalAlpha = bs.o;
646
+ ctx.save(); ctx.clip(B.hull);
647
+ ctx.fillStyle = css(lit(C.water), 0.85);
648
+ ctx.beginPath(); ctx.moveTo(-120, 2); for (let x = -120; x <= 120; x += 10) ctx.lineTo(x, -2 + Math.sin(x * 0.08 + t * 5) * 2.6); ctx.lineTo(120, 30); ctx.lineTo(-120, 30); ctx.closePath(); ctx.fill();
649
+ ctx.restore();
650
+ ctx.restore();
651
+ ctx.globalAlpha = 1;
652
+ }
653
+ const tl = gsap.timeline({ paused: true });
654
+ const pr = { t: 0 };
655
+ tl.to(pr, { t: DUR, duration: DUR, ease: 'none', onUpdate: () => draw(pr.t) }, 0);
656
+ window.__timelines = window.__timelines || {};
657
+ window.__timelines['main'] = tl;
658
+ draw(0);
659
+ tl.seek(0);
660
+ })();
661
+ </script>
662
+ </body>
663
+ </html>