@autoaiai/aicut 0.1.7 → 0.1.13

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 (306) hide show
  1. package/MANUAL.md +94 -84
  2. package/package.json +1 -1
  3. package/product.json +2 -1
  4. package/skills/aicut/SKILL.md +4 -4
  5. package/skills/aicut/references/commands.md +15 -15
  6. package/skills/aicut/references/film-format.md +1 -1
  7. package/skills/aicut/references/recipes.md +4 -4
  8. package/skills/aicut/references/troubleshooting.md +2 -2
  9. package/skills/aicut-motion/SKILL.md +75 -9
  10. package/skills/aicut-motion/THIRD_PARTY_NOTICES.md +14 -0
  11. package/skills/aicut-motion/assets/atlas/lib/harness.js +116 -0
  12. package/skills/aicut-motion/assets/atlas/lib/sound.js +274 -0
  13. package/skills/aicut-motion/assets/atlas/styles/001-flat-vector-science/code.js +937 -0
  14. package/skills/aicut-motion/assets/atlas/styles/001-flat-vector-science/poster.jpg +0 -0
  15. package/skills/aicut-motion/assets/atlas/styles/001-flat-vector-science/style.json +13 -0
  16. package/skills/aicut-motion/assets/atlas/styles/002-watercolor-wash/code.js +909 -0
  17. package/skills/aicut-motion/assets/atlas/styles/002-watercolor-wash/poster.jpg +0 -0
  18. package/skills/aicut-motion/assets/atlas/styles/002-watercolor-wash/style.json +13 -0
  19. package/skills/aicut-motion/assets/atlas/styles/003-shadow-puppet-theatre/code.js +881 -0
  20. package/skills/aicut-motion/assets/atlas/styles/003-shadow-puppet-theatre/poster.jpg +0 -0
  21. package/skills/aicut-motion/assets/atlas/styles/003-shadow-puppet-theatre/style.json +13 -0
  22. package/skills/aicut-motion/assets/atlas/styles/004-whiteboard-explainer/code.js +897 -0
  23. package/skills/aicut-motion/assets/atlas/styles/004-whiteboard-explainer/poster.jpg +0 -0
  24. package/skills/aicut-motion/assets/atlas/styles/004-whiteboard-explainer/style.json +13 -0
  25. package/skills/aicut-motion/assets/atlas/styles/005-psychedelic-poster/code.js +814 -0
  26. package/skills/aicut-motion/assets/atlas/styles/005-psychedelic-poster/poster.jpg +0 -0
  27. package/skills/aicut-motion/assets/atlas/styles/005-psychedelic-poster/style.json +13 -0
  28. package/skills/aicut-motion/assets/atlas/styles/006-tech-glow-explainer/code.js +990 -0
  29. package/skills/aicut-motion/assets/atlas/styles/006-tech-glow-explainer/poster.jpg +0 -0
  30. package/skills/aicut-motion/assets/atlas/styles/006-tech-glow-explainer/style.json +13 -0
  31. package/skills/aicut-motion/assets/atlas/styles/007-papercraft-models/code.js +994 -0
  32. package/skills/aicut-motion/assets/atlas/styles/007-papercraft-models/poster.jpg +0 -0
  33. package/skills/aicut-motion/assets/atlas/styles/007-papercraft-models/style.json +13 -0
  34. package/skills/aicut-motion/assets/atlas/styles/008-1940s-film-noir/code.js +792 -0
  35. package/skills/aicut-motion/assets/atlas/styles/008-1940s-film-noir/poster.jpg +0 -0
  36. package/skills/aicut-motion/assets/atlas/styles/008-1940s-film-noir/style.json +13 -0
  37. package/skills/aicut-motion/assets/atlas/styles/009-manim-style-math/code.js +840 -0
  38. package/skills/aicut-motion/assets/atlas/styles/009-manim-style-math/poster.jpg +0 -0
  39. package/skills/aicut-motion/assets/atlas/styles/009-manim-style-math/style.json +13 -0
  40. package/skills/aicut-motion/assets/atlas/styles/010-illuminated-manuscript/code.js +1126 -0
  41. package/skills/aicut-motion/assets/atlas/styles/010-illuminated-manuscript/poster.jpg +0 -0
  42. package/skills/aicut-motion/assets/atlas/styles/010-illuminated-manuscript/style.json +13 -0
  43. package/skills/aicut-motion/assets/atlas/styles/011-editorial-essay-collage/code.js +854 -0
  44. package/skills/aicut-motion/assets/atlas/styles/011-editorial-essay-collage/poster.jpg +0 -0
  45. package/skills/aicut-motion/assets/atlas/styles/011-editorial-essay-collage/style.json +13 -0
  46. package/skills/aicut-motion/assets/atlas/styles/012-bioluminescent-deep-sea/code.js +1124 -0
  47. package/skills/aicut-motion/assets/atlas/styles/012-bioluminescent-deep-sea/poster.jpg +0 -0
  48. package/skills/aicut-motion/assets/atlas/styles/012-bioluminescent-deep-sea/style.json +13 -0
  49. package/skills/aicut-motion/assets/atlas/styles/013-product-launch-reveal/code.js +728 -0
  50. package/skills/aicut-motion/assets/atlas/styles/013-product-launch-reveal/poster.jpg +0 -0
  51. package/skills/aicut-motion/assets/atlas/styles/013-product-launch-reveal/style.json +13 -0
  52. package/skills/aicut-motion/assets/atlas/styles/014-halftone-pop-panel/code.js +664 -0
  53. package/skills/aicut-motion/assets/atlas/styles/014-halftone-pop-panel/poster.jpg +0 -0
  54. package/skills/aicut-motion/assets/atlas/styles/014-halftone-pop-panel/style.json +13 -0
  55. package/skills/aicut-motion/assets/atlas/styles/015-isometric-pastel/code.js +991 -0
  56. package/skills/aicut-motion/assets/atlas/styles/015-isometric-pastel/poster.jpg +0 -0
  57. package/skills/aicut-motion/assets/atlas/styles/015-isometric-pastel/style.json +13 -0
  58. package/skills/aicut-motion/assets/atlas/styles/016-oscilloscope-vector-art/code.js +801 -0
  59. package/skills/aicut-motion/assets/atlas/styles/016-oscilloscope-vector-art/poster.jpg +0 -0
  60. package/skills/aicut-motion/assets/atlas/styles/016-oscilloscope-vector-art/style.json +13 -0
  61. package/skills/aicut-motion/assets/atlas/styles/017-risograph-zine/code.js +692 -0
  62. package/skills/aicut-motion/assets/atlas/styles/017-risograph-zine/poster.jpg +0 -0
  63. package/skills/aicut-motion/assets/atlas/styles/017-risograph-zine/style.json +13 -0
  64. package/skills/aicut-motion/assets/atlas/styles/018-claymation-set/code.js +756 -0
  65. package/skills/aicut-motion/assets/atlas/styles/018-claymation-set/poster.jpg +0 -0
  66. package/skills/aicut-motion/assets/atlas/styles/018-claymation-set/style.json +13 -0
  67. package/skills/aicut-motion/assets/atlas/styles/019-neon-sign-at-night/code.js +922 -0
  68. package/skills/aicut-motion/assets/atlas/styles/019-neon-sign-at-night/poster.jpg +0 -0
  69. package/skills/aicut-motion/assets/atlas/styles/019-neon-sign-at-night/style.json +13 -0
  70. package/skills/aicut-motion/assets/atlas/styles/020-kawaii-anime/code.js +852 -0
  71. package/skills/aicut-motion/assets/atlas/styles/020-kawaii-anime/poster.jpg +0 -0
  72. package/skills/aicut-motion/assets/atlas/styles/020-kawaii-anime/style.json +13 -0
  73. package/skills/aicut-motion/assets/atlas/styles/021-ukiyo-e-woodblock/code.js +724 -0
  74. package/skills/aicut-motion/assets/atlas/styles/021-ukiyo-e-woodblock/poster.jpg +0 -0
  75. package/skills/aicut-motion/assets/atlas/styles/021-ukiyo-e-woodblock/style.json +13 -0
  76. package/skills/aicut-motion/assets/atlas/styles/022-16-bit-pixel-odyssey/code.js +793 -0
  77. package/skills/aicut-motion/assets/atlas/styles/022-16-bit-pixel-odyssey/poster.jpg +0 -0
  78. package/skills/aicut-motion/assets/atlas/styles/022-16-bit-pixel-odyssey/style.json +13 -0
  79. package/skills/aicut-motion/assets/atlas/styles/023-chalkboard-lesson/code.js +846 -0
  80. package/skills/aicut-motion/assets/atlas/styles/023-chalkboard-lesson/poster.jpg +0 -0
  81. package/skills/aicut-motion/assets/atlas/styles/023-chalkboard-lesson/style.json +13 -0
  82. package/skills/aicut-motion/assets/atlas/styles/024-cut-paper-diorama/code.js +1008 -0
  83. package/skills/aicut-motion/assets/atlas/styles/024-cut-paper-diorama/poster.jpg +0 -0
  84. package/skills/aicut-motion/assets/atlas/styles/024-cut-paper-diorama/style.json +13 -0
  85. package/skills/aicut-motion/assets/atlas/styles/025-cathedral-glass/code.js +680 -0
  86. package/skills/aicut-motion/assets/atlas/styles/025-cathedral-glass/poster.jpg +0 -0
  87. package/skills/aicut-motion/assets/atlas/styles/025-cathedral-glass/style.json +13 -0
  88. package/skills/aicut-motion/assets/atlas/styles/026-editorial-chart/code.js +633 -0
  89. package/skills/aicut-motion/assets/atlas/styles/026-editorial-chart/poster.jpg +0 -0
  90. package/skills/aicut-motion/assets/atlas/styles/026-editorial-chart/style.json +13 -0
  91. package/skills/aicut-motion/assets/atlas/styles/027-synthwave-outrun/code.js +757 -0
  92. package/skills/aicut-motion/assets/atlas/styles/027-synthwave-outrun/poster.jpg +0 -0
  93. package/skills/aicut-motion/assets/atlas/styles/027-synthwave-outrun/style.json +13 -0
  94. package/skills/aicut-motion/assets/atlas/styles/028-origami-studio/code.js +828 -0
  95. package/skills/aicut-motion/assets/atlas/styles/028-origami-studio/poster.jpg +0 -0
  96. package/skills/aicut-motion/assets/atlas/styles/028-origami-studio/style.json +13 -0
  97. package/skills/aicut-motion/assets/atlas/styles/029-linocut-relief-print/code.js +697 -0
  98. package/skills/aicut-motion/assets/atlas/styles/029-linocut-relief-print/poster.jpg +0 -0
  99. package/skills/aicut-motion/assets/atlas/styles/029-linocut-relief-print/style.json +13 -0
  100. package/skills/aicut-motion/assets/atlas/styles/030-holographic-foil-card/code.js +687 -0
  101. package/skills/aicut-motion/assets/atlas/styles/030-holographic-foil-card/poster.jpg +0 -0
  102. package/skills/aicut-motion/assets/atlas/styles/030-holographic-foil-card/style.json +13 -0
  103. package/skills/aicut-motion/assets/atlas/styles/031-voxel-diorama/code.js +727 -0
  104. package/skills/aicut-motion/assets/atlas/styles/031-voxel-diorama/poster.jpg +0 -0
  105. package/skills/aicut-motion/assets/atlas/styles/031-voxel-diorama/style.json +13 -0
  106. package/skills/aicut-motion/assets/atlas/styles/032-sumi-e-ink-wash/code.js +903 -0
  107. package/skills/aicut-motion/assets/atlas/styles/032-sumi-e-ink-wash/poster.jpg +0 -0
  108. package/skills/aicut-motion/assets/atlas/styles/032-sumi-e-ink-wash/style.json +13 -0
  109. package/skills/aicut-motion/assets/atlas/styles/033-etch-a-sketch-toy/code.js +662 -0
  110. package/skills/aicut-motion/assets/atlas/styles/033-etch-a-sketch-toy/poster.jpg +0 -0
  111. package/skills/aicut-motion/assets/atlas/styles/033-etch-a-sketch-toy/style.json +13 -0
  112. package/skills/aicut-motion/assets/atlas/styles/034-cosmic-star-chart/code.js +951 -0
  113. package/skills/aicut-motion/assets/atlas/styles/034-cosmic-star-chart/poster.jpg +0 -0
  114. package/skills/aicut-motion/assets/atlas/styles/034-cosmic-star-chart/style.json +13 -0
  115. package/skills/aicut-motion/assets/atlas/styles/035-punk-zine-collage/code.js +759 -0
  116. package/skills/aicut-motion/assets/atlas/styles/035-punk-zine-collage/poster.jpg +0 -0
  117. package/skills/aicut-motion/assets/atlas/styles/035-punk-zine-collage/style.json +13 -0
  118. package/skills/aicut-motion/assets/atlas/styles/036-thermal-camera/code.js +738 -0
  119. package/skills/aicut-motion/assets/atlas/styles/036-thermal-camera/poster.jpg +0 -0
  120. package/skills/aicut-motion/assets/atlas/styles/036-thermal-camera/style.json +13 -0
  121. package/skills/aicut-motion/assets/atlas/styles/037-engineering-blueprint/code.js +793 -0
  122. package/skills/aicut-motion/assets/atlas/styles/037-engineering-blueprint/poster.jpg +0 -0
  123. package/skills/aicut-motion/assets/atlas/styles/037-engineering-blueprint/style.json +13 -0
  124. package/skills/aicut-motion/assets/atlas/styles/038-impasto-night/code.js +673 -0
  125. package/skills/aicut-motion/assets/atlas/styles/038-impasto-night/poster.jpg +0 -0
  126. package/skills/aicut-motion/assets/atlas/styles/038-impasto-night/style.json +13 -0
  127. package/skills/aicut-motion/assets/atlas/styles/039-win95-desktop/code.js +907 -0
  128. package/skills/aicut-motion/assets/atlas/styles/039-win95-desktop/poster.jpg +0 -0
  129. package/skills/aicut-motion/assets/atlas/styles/039-win95-desktop/style.json +13 -0
  130. package/skills/aicut-motion/assets/atlas/styles/040-low-poly-faceted/code.js +833 -0
  131. package/skills/aicut-motion/assets/atlas/styles/040-low-poly-faceted/poster.jpg +0 -0
  132. package/skills/aicut-motion/assets/atlas/styles/040-low-poly-faceted/style.json +13 -0
  133. package/skills/aicut-motion/assets/atlas/styles/041-manga-page/code.js +845 -0
  134. package/skills/aicut-motion/assets/atlas/styles/041-manga-page/poster.jpg +0 -0
  135. package/skills/aicut-motion/assets/atlas/styles/041-manga-page/style.json +13 -0
  136. package/skills/aicut-motion/assets/atlas/styles/042-wood-type-letterpress/code.js +496 -0
  137. package/skills/aicut-motion/assets/atlas/styles/042-wood-type-letterpress/poster.jpg +0 -0
  138. package/skills/aicut-motion/assets/atlas/styles/042-wood-type-letterpress/style.json +13 -0
  139. package/skills/aicut-motion/assets/atlas/styles/043-light-painting/code.js +635 -0
  140. package/skills/aicut-motion/assets/atlas/styles/043-light-painting/poster.jpg +0 -0
  141. package/skills/aicut-motion/assets/atlas/styles/043-light-painting/style.json +13 -0
  142. package/skills/aicut-motion/assets/atlas/styles/044-felt-patchwork/code.js +799 -0
  143. package/skills/aicut-motion/assets/atlas/styles/044-felt-patchwork/poster.jpg +0 -0
  144. package/skills/aicut-motion/assets/atlas/styles/044-felt-patchwork/style.json +13 -0
  145. package/skills/aicut-motion/assets/atlas/styles/045-phosphor-terminal/code.js +547 -0
  146. package/skills/aicut-motion/assets/atlas/styles/045-phosphor-terminal/poster.jpg +0 -0
  147. package/skills/aicut-motion/assets/atlas/styles/045-phosphor-terminal/style.json +13 -0
  148. package/skills/aicut-motion/assets/atlas/styles/046-glassmorphism-ui/code.js +592 -0
  149. package/skills/aicut-motion/assets/atlas/styles/046-glassmorphism-ui/poster.jpg +0 -0
  150. package/skills/aicut-motion/assets/atlas/styles/046-glassmorphism-ui/style.json +13 -0
  151. package/skills/aicut-motion/assets/atlas/styles/047-tarot-card/code.js +768 -0
  152. package/skills/aicut-motion/assets/atlas/styles/047-tarot-card/poster.jpg +0 -0
  153. package/skills/aicut-motion/assets/atlas/styles/047-tarot-card/style.json +13 -0
  154. package/skills/aicut-motion/assets/atlas/styles/048-transit-map/code.js +666 -0
  155. package/skills/aicut-motion/assets/atlas/styles/048-transit-map/poster.jpg +0 -0
  156. package/skills/aicut-motion/assets/atlas/styles/048-transit-map/style.json +13 -0
  157. package/skills/aicut-motion/assets/atlas/styles/049-gouache-travel-poster/code.js +559 -0
  158. package/skills/aicut-motion/assets/atlas/styles/049-gouache-travel-poster/poster.jpg +0 -0
  159. package/skills/aicut-motion/assets/atlas/styles/049-gouache-travel-poster/style.json +13 -0
  160. package/skills/aicut-motion/assets/atlas/styles/050-napkin-sketch/code.js +943 -0
  161. package/skills/aicut-motion/assets/atlas/styles/050-napkin-sketch/poster.jpg +0 -0
  162. package/skills/aicut-motion/assets/atlas/styles/050-napkin-sketch/style.json +13 -0
  163. package/skills/aicut-motion/assets/atlas/styles/051-art-deco-foil/code.js +606 -0
  164. package/skills/aicut-motion/assets/atlas/styles/051-art-deco-foil/poster.jpg +0 -0
  165. package/skills/aicut-motion/assets/atlas/styles/051-art-deco-foil/style.json +13 -0
  166. package/skills/aicut-motion/assets/atlas/styles/052-radiograph-on-lightbox/code.js +730 -0
  167. package/skills/aicut-motion/assets/atlas/styles/052-radiograph-on-lightbox/poster.jpg +0 -0
  168. package/skills/aicut-motion/assets/atlas/styles/052-radiograph-on-lightbox/style.json +13 -0
  169. package/skills/aicut-motion/assets/atlas/styles/053-vaporwave/code.js +782 -0
  170. package/skills/aicut-motion/assets/atlas/styles/053-vaporwave/poster.jpg +0 -0
  171. package/skills/aicut-motion/assets/atlas/styles/053-vaporwave/style.json +13 -0
  172. package/skills/aicut-motion/assets/atlas/styles/054-ebru-paper-marbling/code.js +504 -0
  173. package/skills/aicut-motion/assets/atlas/styles/054-ebru-paper-marbling/poster.jpg +0 -0
  174. package/skills/aicut-motion/assets/atlas/styles/054-ebru-paper-marbling/style.json +13 -0
  175. package/skills/aicut-motion/assets/atlas/styles/055-isotype-pictograms/code.js +517 -0
  176. package/skills/aicut-motion/assets/atlas/styles/055-isotype-pictograms/poster.jpg +0 -0
  177. package/skills/aicut-motion/assets/atlas/styles/055-isotype-pictograms/style.json +13 -0
  178. package/skills/aicut-motion/assets/atlas/styles/056-soft-3d-clay/code.js +713 -0
  179. package/skills/aicut-motion/assets/atlas/styles/056-soft-3d-clay/poster.jpg +0 -0
  180. package/skills/aicut-motion/assets/atlas/styles/056-soft-3d-clay/style.json +13 -0
  181. package/skills/aicut-motion/assets/atlas/styles/057-cross-stitch-sampler/code.js +717 -0
  182. package/skills/aicut-motion/assets/atlas/styles/057-cross-stitch-sampler/poster.jpg +0 -0
  183. package/skills/aicut-motion/assets/atlas/styles/057-cross-stitch-sampler/style.json +13 -0
  184. package/skills/aicut-motion/assets/atlas/styles/058-constructivist-propaganda/code.js +540 -0
  185. package/skills/aicut-motion/assets/atlas/styles/058-constructivist-propaganda/poster.jpg +0 -0
  186. package/skills/aicut-motion/assets/atlas/styles/058-constructivist-propaganda/style.json +13 -0
  187. package/skills/aicut-motion/assets/atlas/styles/059-pocket-monochrome/code.js +524 -0
  188. package/skills/aicut-motion/assets/atlas/styles/059-pocket-monochrome/poster.jpg +0 -0
  189. package/skills/aicut-motion/assets/atlas/styles/059-pocket-monochrome/style.json +13 -0
  190. package/skills/aicut-motion/assets/atlas/styles/060-botanical-plate/code.js +934 -0
  191. package/skills/aicut-motion/assets/atlas/styles/060-botanical-plate/poster.jpg +0 -0
  192. package/skills/aicut-motion/assets/atlas/styles/060-botanical-plate/style.json +13 -0
  193. package/skills/aicut-motion/assets/atlas/styles/061-kinetic-type/code.js +690 -0
  194. package/skills/aicut-motion/assets/atlas/styles/061-kinetic-type/poster.jpg +0 -0
  195. package/skills/aicut-motion/assets/atlas/styles/061-kinetic-type/style.json +13 -0
  196. package/skills/aicut-motion/assets/atlas/styles/062-byzantine-mosaic/code.js +612 -0
  197. package/skills/aicut-motion/assets/atlas/styles/062-byzantine-mosaic/poster.jpg +0 -0
  198. package/skills/aicut-motion/assets/atlas/styles/062-byzantine-mosaic/style.json +13 -0
  199. package/skills/aicut-motion/assets/atlas/styles/063-y2k-liquid-chrome/code.js +666 -0
  200. package/skills/aicut-motion/assets/atlas/styles/063-y2k-liquid-chrome/poster.jpg +0 -0
  201. package/skills/aicut-motion/assets/atlas/styles/063-y2k-liquid-chrome/style.json +13 -0
  202. package/skills/aicut-motion/assets/atlas/styles/064-sticky-note-wall/code.js +651 -0
  203. package/skills/aicut-motion/assets/atlas/styles/064-sticky-note-wall/poster.jpg +0 -0
  204. package/skills/aicut-motion/assets/atlas/styles/064-sticky-note-wall/style.json +13 -0
  205. package/skills/aicut-motion/assets/atlas/styles/065-vintage-newsprint/code.js +656 -0
  206. package/skills/aicut-motion/assets/atlas/styles/065-vintage-newsprint/poster.jpg +0 -0
  207. package/skills/aicut-motion/assets/atlas/styles/065-vintage-newsprint/style.json +13 -0
  208. package/skills/aicut-motion/assets/atlas/styles/066-hidden-line-wireframe/code.js +672 -0
  209. package/skills/aicut-motion/assets/atlas/styles/066-hidden-line-wireframe/poster.jpg +0 -0
  210. package/skills/aicut-motion/assets/atlas/styles/066-hidden-line-wireframe/style.json +13 -0
  211. package/skills/aicut-motion/assets/atlas/styles/067-memphis-group/code.js +548 -0
  212. package/skills/aicut-motion/assets/atlas/styles/067-memphis-group/poster.jpg +0 -0
  213. package/skills/aicut-motion/assets/atlas/styles/067-memphis-group/style.json +13 -0
  214. package/skills/aicut-motion/assets/atlas/styles/068-ballpoint-notebook/code.js +989 -0
  215. package/skills/aicut-motion/assets/atlas/styles/068-ballpoint-notebook/poster.jpg +0 -0
  216. package/skills/aicut-motion/assets/atlas/styles/068-ballpoint-notebook/style.json +13 -0
  217. package/skills/aicut-motion/assets/atlas/styles/069-op-art-sphere/code.js +440 -0
  218. package/skills/aicut-motion/assets/atlas/styles/069-op-art-sphere/poster.jpg +0 -0
  219. package/skills/aicut-motion/assets/atlas/styles/069-op-art-sphere/style.json +13 -0
  220. package/skills/aicut-motion/assets/atlas/styles/070-topographic-survey/code.js +895 -0
  221. package/skills/aicut-motion/assets/atlas/styles/070-topographic-survey/poster.jpg +0 -0
  222. package/skills/aicut-motion/assets/atlas/styles/070-topographic-survey/style.json +13 -0
  223. package/skills/aicut-motion/assets/atlas/styles/071-pointillist-afternoon/code.js +563 -0
  224. package/skills/aicut-motion/assets/atlas/styles/071-pointillist-afternoon/poster.jpg +0 -0
  225. package/skills/aicut-motion/assets/atlas/styles/071-pointillist-afternoon/style.json +13 -0
  226. package/skills/aicut-motion/assets/atlas/styles/072-vector-arcade-1980/code.js +627 -0
  227. package/skills/aicut-motion/assets/atlas/styles/072-vector-arcade-1980/poster.jpg +0 -0
  228. package/skills/aicut-motion/assets/atlas/styles/072-vector-arcade-1980/style.json +13 -0
  229. package/skills/aicut-motion/assets/atlas/styles/073-patent-drawing/code.js +1096 -0
  230. package/skills/aicut-motion/assets/atlas/styles/073-patent-drawing/poster.jpg +0 -0
  231. package/skills/aicut-motion/assets/atlas/styles/073-patent-drawing/style.json +13 -0
  232. package/skills/aicut-motion/assets/atlas/styles/074-bauhaus-poster/code.js +595 -0
  233. package/skills/aicut-motion/assets/atlas/styles/074-bauhaus-poster/poster.jpg +0 -0
  234. package/skills/aicut-motion/assets/atlas/styles/074-bauhaus-poster/style.json +13 -0
  235. package/skills/aicut-motion/assets/atlas/styles/075-bitmap-paint-doodle/code.js +665 -0
  236. package/skills/aicut-motion/assets/atlas/styles/075-bitmap-paint-doodle/poster.jpg +0 -0
  237. package/skills/aicut-motion/assets/atlas/styles/075-bitmap-paint-doodle/style.json +13 -0
  238. package/skills/aicut-motion/assets/atlas/styles/076-nail-thread-string-art/code.js +645 -0
  239. package/skills/aicut-motion/assets/atlas/styles/076-nail-thread-string-art/poster.jpg +0 -0
  240. package/skills/aicut-motion/assets/atlas/styles/076-nail-thread-string-art/style.json +13 -0
  241. package/skills/aicut-motion/assets/atlas/styles/077-ridgeline/code.js +436 -0
  242. package/skills/aicut-motion/assets/atlas/styles/077-ridgeline/poster.jpg +0 -0
  243. package/skills/aicut-motion/assets/atlas/styles/077-ridgeline/style.json +13 -0
  244. package/skills/aicut-motion/assets/atlas/styles/078-sketchbook-graphite/code.js +1237 -0
  245. package/skills/aicut-motion/assets/atlas/styles/078-sketchbook-graphite/poster.jpg +0 -0
  246. package/skills/aicut-motion/assets/atlas/styles/078-sketchbook-graphite/style.json +13 -0
  247. package/skills/aicut-motion/assets/atlas/styles/079-teletext-page/code.js +622 -0
  248. package/skills/aicut-motion/assets/atlas/styles/079-teletext-page/poster.jpg +0 -0
  249. package/skills/aicut-motion/assets/atlas/styles/079-teletext-page/style.json +13 -0
  250. package/skills/aicut-motion/assets/atlas/styles/080-silkscreen-grid/code.js +524 -0
  251. package/skills/aicut-motion/assets/atlas/styles/080-silkscreen-grid/poster.jpg +0 -0
  252. package/skills/aicut-motion/assets/atlas/styles/080-silkscreen-grid/style.json +13 -0
  253. package/skills/aicut-motion/assets/atlas/styles/081-guilloch-security-print/code.js +689 -0
  254. package/skills/aicut-motion/assets/atlas/styles/081-guilloch-security-print/poster.jpg +0 -0
  255. package/skills/aicut-motion/assets/atlas/styles/081-guilloch-security-print/style.json +13 -0
  256. package/skills/aicut-motion/assets/atlas/styles/082-ascii-demoscene/code.js +574 -0
  257. package/skills/aicut-motion/assets/atlas/styles/082-ascii-demoscene/poster.jpg +0 -0
  258. package/skills/aicut-motion/assets/atlas/styles/082-ascii-demoscene/style.json +13 -0
  259. package/skills/aicut-motion/assets/atlas/styles/083-international-typographic-style/code.js +469 -0
  260. package/skills/aicut-motion/assets/atlas/styles/083-international-typographic-style/poster.jpg +0 -0
  261. package/skills/aicut-motion/assets/atlas/styles/083-international-typographic-style/style.json +13 -0
  262. package/skills/aicut-motion/assets/atlas/styles/084-flow-field/code.js +531 -0
  263. package/skills/aicut-motion/assets/atlas/styles/084-flow-field/poster.jpg +0 -0
  264. package/skills/aicut-motion/assets/atlas/styles/084-flow-field/style.json +13 -0
  265. package/skills/aicut-motion/assets/atlas/styles/085-macpaint-1984/code.js +675 -0
  266. package/skills/aicut-motion/assets/atlas/styles/085-macpaint-1984/poster.jpg +0 -0
  267. package/skills/aicut-motion/assets/atlas/styles/085-macpaint-1984/style.json +13 -0
  268. package/skills/aicut-motion/assets/atlas/styles/086-multi-scale-truchet/code.js +609 -0
  269. package/skills/aicut-motion/assets/atlas/styles/086-multi-scale-truchet/poster.jpg +0 -0
  270. package/skills/aicut-motion/assets/atlas/styles/086-multi-scale-truchet/style.json +13 -0
  271. package/skills/aicut-motion/references/design-systems/README.md +1 -1
  272. package/skills/aicut-motion/references/motion-delivery.md +55 -0
  273. package/skills/aicut-motion/references/pages.md +1 -1
  274. package/skills/aicut-motion/references/style-index.json +690 -0
  275. package/skills/aicut-motion/references/style-research.md +73 -0
  276. package/skills/aicut-motion/references/style-selection.md +71 -0
  277. package/skills/aicut-motion/scripts/atlas-viewer.html +195 -0
  278. package/skills/aicut-motion/scripts/atlas.mjs +109 -0
  279. package/studio/client.mjs +3 -3
  280. package/studio/server/fetch-github.mjs +14 -3
  281. package/studio/server/server.mjs +71 -6
  282. package/studio/server/skill-summaries.mjs +60 -0
  283. package/studio/server/skills.mjs +121 -7
  284. package/studio/server/styles-store.mjs +235 -0
  285. package/studio/server/template-posters.mjs +2 -2
  286. package/studio/server/templates-page.mjs +93 -93
  287. package/studio/server/templates.mjs +32 -7
  288. package/studio/ui/dist/assets/ExportCenter-DasulhAv.js +1 -0
  289. package/studio/ui/dist/assets/SettingsModal-BZw0Hz2_.js +2 -0
  290. package/studio/ui/dist/assets/apple-touch-icon-ClxQ7j-O.png +0 -0
  291. package/studio/ui/dist/assets/es-C8XPZARI.js +1 -0
  292. package/studio/ui/dist/assets/favicon-Blwx8Trs.png +0 -0
  293. package/studio/ui/dist/assets/index-BjJVmBzB.js +1623 -0
  294. package/studio/ui/dist/assets/index-C3BfKZFO.css +1 -0
  295. package/studio/ui/dist/assets/ja-BeNkdaEj.js +1 -0
  296. package/studio/ui/dist/assets/ko-DcTVhdzK.js +1 -0
  297. package/studio/ui/dist/assets/zh-CN-Cg51ctbL.js +1 -0
  298. package/studio/ui/dist/index.html +4 -3
  299. package/studio/ui/dist/assets/ExportCenter-F-2vF-lQ.js +0 -1
  300. package/studio/ui/dist/assets/SettingsModal-BgVYguNu.js +0 -2
  301. package/studio/ui/dist/assets/es-BRUzvuoM.js +0 -1
  302. package/studio/ui/dist/assets/index-Bhg-9dA3.css +0 -1
  303. package/studio/ui/dist/assets/index-CWur1Iw9.js +0 -1625
  304. package/studio/ui/dist/assets/ja-Cth-uDcW.js +0 -1
  305. package/studio/ui/dist/assets/ko-upvw591D.js +0 -1
  306. package/studio/ui/dist/assets/zh-CN-BCfJFazB.js +0 -1
@@ -0,0 +1,840 @@
1
+ // Manim-Style Math: the math-explainer look popularised by 3Blue1Brown's open-source Manim library. Pure black
2
+ // background, crisp anti-aliased vectors, a restrained Manim palette (blue, teal, yellow, red, green, white), math
3
+ // typeset in a LaTeX-like serif with italic variables, axes with tick marks, curves, arrows and braces. Motion uses
4
+ // Manim's own vocabulary: Write (glyph outlines trace on, then fill), Create, Transform, Indicate, FadeIn-shift,
5
+ // ShowPassingFlash and SurroundingRectangle, all on the sigmoid `smooth` rate function. No characters, no branding.
6
+ {
7
+ const cl = H.clamp, lerp = H.lerp;
8
+ const sig = (x) => 1 / (1 + Math.exp(-x));
9
+ const SE = sig(-5);
10
+ // Manim's `smooth` rate function (inflection 10)
11
+ const SM = (x) => { x = cl(x); return cl((sig(10 * (x - 0.5)) - SE) / (1 - 2 * SE)); };
12
+ const seg = (a, b, t) => cl((t - a) / (b - a));
13
+ const sm = (a, b, t) => SM(seg(a, b, t));
14
+ // there_and_back
15
+ const tab = (a, b, t) => { const x = seg(a, b, t); return x <= 0 || x >= 1 ? 0 : SM(x < 0.5 ? 2 * x : 2 - 2 * x); };
16
+ const C = {
17
+ bg: '#000000', blue: '#58C4DD', blueE: '#236B8E', teal: '#5CD0B3', yellow: '#FFFF00', gold: '#F7D96F',
18
+ red: '#FC6255', green: '#83C167', white: '#FFFFFF', grey: '#888888', greyL: '#BBBBBB', greyD: '#444444',
19
+ };
20
+ const mixc = (a, b, t) => '#' + H.mix(a, b, cl(t)).map((v) => Math.round(v).toString(16).padStart(2, '0')).join('');
21
+ const FAM = '"STIX Two Text", "STIXGeneral", "Times New Roman", serif';
22
+ const fnt = (sz, it, w) => `${it ? 'italic ' : ''}${w || 400} ${sz}px ${FAM}`;
23
+ const TAU = Math.PI * 2;
24
+
25
+ // ------------------------------------------------------------------ typesetting (a tiny MathTex)
26
+ // token: { s, it (italic), c (colour), w (weight), sz (relative size), dy (baseline shift in em), k (match key), gap (em), kern (em) }
27
+ const T = (s, o) => Object.assign({ s }, o || {});
28
+ function layout(ctx, toks, size, x, y, align) {
29
+ const gl = []; let cx = 0;
30
+ for (const tk of toks) {
31
+ if (tk.gap) { cx += tk.gap * size; continue; }
32
+ const sz = size * (tk.sz || 1), font = fnt(sz, tk.it, tk.w);
33
+ ctx.font = font;
34
+ const s = tk.s;
35
+ for (let i = 0; i < s.length; i++) {
36
+ if (s[i] === ' ') continue;
37
+ const off = i ? ctx.measureText(s.slice(0, i)).width : 0;
38
+ gl.push({ ch: s[i], x: cx + off, y: (tk.dy || 0) * size, font, sz, c: tk.c || C.white, k: tk.k || s, ki: i, tag: tk.tag });
39
+ }
40
+ cx += ctx.measureText(s).width + (tk.kern || 0) * size;
41
+ }
42
+ const w = cx, x0 = align === 'center' ? x - w / 2 : align === 'right' ? x - w : x;
43
+ for (const g of gl) { g.x += x0; g.y += y; }
44
+ return { gl, w, x0, x1: x0 + w, y, size, cx: x0 + w / 2 };
45
+ }
46
+ // one glyph, Write-style: outline traces on (dash per contour), then the fill comes up as the outline fades
47
+ function glyph(ctx, g, a, alpha, col, x, y, s) {
48
+ if (a <= 0 || alpha <= 0.003) return;
49
+ x = x == null ? g.x : x; y = y == null ? g.y : y; s = s || 1;
50
+ ctx.save();
51
+ ctx.translate(x, y); if (s !== 1) ctx.scale(s, s);
52
+ ctx.font = g.font;
53
+ if (a >= 1) { ctx.globalAlpha = alpha; ctx.fillStyle = col; ctx.fillText(g.ch, 0, 0); ctx.restore(); return; }
54
+ const d = SM(a * 2), f = SM(a * 2 - 1), Lm = g.sz * 4;
55
+ if (f < 1) { ctx.globalAlpha = alpha * (1 - f); ctx.strokeStyle = col; ctx.lineWidth = Math.max(1, g.sz * 0.028); ctx.setLineDash([d * Lm + 0.01, Lm * 30]); ctx.strokeText(g.ch, 0, 0); }
56
+ if (f > 0) { ctx.setLineDash([]); ctx.globalAlpha = alpha * f; ctx.fillStyle = col; ctx.fillText(g.ch, 0, 0); }
57
+ ctx.restore();
58
+ }
59
+ // Write(p): glyph sub-animations with Manim's lag ratio min(4/n, 0.2)
60
+ function writeA(n, p, i) {
61
+ if (p >= 1) return 1;
62
+ const r = Math.min(4 / Math.max(1, n), 0.2), Ld = 1 / (1 + (n - 1) * r);
63
+ return cl((p - i * r * Ld) / Ld);
64
+ }
65
+ function drawTex(ctx, L, o) {
66
+ o = o || {};
67
+ const p = o.p == null ? 1 : o.p, alpha = o.alpha == null ? 1 : o.alpha, n = L.gl.length;
68
+ const dx = o.dx || 0, dy = o.dy || 0;
69
+ L.gl.forEach((g, i) => {
70
+ const col = o.col ? (typeof o.col === 'function' ? o.col(g, i) : o.col) : g.c;
71
+ let s = 1, x = g.x + dx, y = g.y + dy;
72
+ if (o.scale && o.scale !== 1) { const ox = o.ox == null ? L.cx : o.ox, oy = o.oy == null ? L.y - L.size * 0.33 : o.oy; x = ox + (x - ox) * o.scale; y = oy + (y - oy) * o.scale; s = o.scale; }
73
+ glyph(ctx, g, writeA(n, p, i), alpha, col, x, y, s);
74
+ });
75
+ }
76
+ // Transform / TransformMatchingTex: glyphs with the same key fly to their new places (resizing, recolouring);
77
+ // the rest fade out / in while shifting with the group (FadeTransform).
78
+ function morphTex(ctx, A, B, q, o) {
79
+ o = o || {};
80
+ const alpha = o.alpha == null ? 1 : o.alpha, used = new Set();
81
+ const dx = B.cx - A.cx, dy = B.y - A.y, sc = B.size / A.size;
82
+ const colA = (g) => (o.colA ? o.colA(g) : g.c), colB = (g) => (o.colB ? o.colB(g) : g.c);
83
+ for (const g of A.gl) {
84
+ const j = B.gl.findIndex((h, jj) => !used.has(jj) && h.k === g.k && h.ki === g.ki);
85
+ if (j >= 0) {
86
+ used.add(j); const h = B.gl[j];
87
+ glyph(ctx, g, 1, alpha, mixc(colA(g), colB(h), q), lerp(g.x, h.x, q), lerp(g.y, h.y, q), lerp(1, h.sz / g.sz, q));
88
+ } else {
89
+ glyph(ctx, g, 1, alpha * (1 - q), colA(g), A.cx + (g.x - A.cx) * lerp(1, sc, q) + dx * q, A.y + (g.y - A.y) * lerp(1, sc, q) + dy * q, lerp(1, sc, q));
90
+ }
91
+ }
92
+ B.gl.forEach((h, j) => {
93
+ if (used.has(j)) return;
94
+ glyph(ctx, h, 1, alpha * q, colB(h), B.cx + (h.x - B.cx) * lerp(1 / sc, 1, q) - dx * (1 - q), B.y + (h.y - B.y) * lerp(1 / sc, 1, q) - dy * (1 - q), lerp(1 / sc, 1, q));
95
+ });
96
+ }
97
+ // DecimalNumber / Integer with commas
98
+ const commas = (n) => String(Math.round(n)).replace(/\B(?=(\d{3})+(?!\d))/g, ',');
99
+
100
+ // ------------------------------------------------------------------ vector primitives
101
+ function cumLen(pts) { const c = [0]; for (let i = 1; i < pts.length; i++) c.push(c[i - 1] + Math.hypot(pts[i][0] - pts[i - 1][0], pts[i][1] - pts[i - 1][1])); return c; }
102
+ function pathPart(ctx, pts, a, b, cum) {
103
+ cum = cum || cumLen(pts);
104
+ const L = cum[cum.length - 1], A = a * L, B = b * L;
105
+ if (B <= A) return false;
106
+ const at = (d) => { let i = 1; while (i < cum.length - 1 && cum[i] < d) i++; const u = (d - cum[i - 1]) / Math.max(1e-6, cum[i] - cum[i - 1]); return [lerp(pts[i - 1][0], pts[i][0], u), lerp(pts[i - 1][1], pts[i][1], u), i]; };
107
+ const s = at(A), e = at(B);
108
+ ctx.beginPath(); ctx.moveTo(s[0], s[1]);
109
+ for (let i = s[2]; i < e[2]; i++) ctx.lineTo(pts[i][0], pts[i][1]);
110
+ ctx.lineTo(e[0], e[1]);
111
+ return true;
112
+ }
113
+ function strokePts(ctx, pts, col, lw, a, b, alpha, cum) {
114
+ if (alpha != null && alpha <= 0.003) return;
115
+ ctx.save(); ctx.globalAlpha = alpha == null ? 1 : alpha;
116
+ if (pathPart(ctx, pts, a == null ? 0 : a, b == null ? 1 : b, cum)) { ctx.strokeStyle = col; ctx.lineWidth = lw; ctx.lineCap = 'round'; ctx.lineJoin = 'round'; ctx.stroke(); }
117
+ ctx.restore();
118
+ }
119
+ // ShowPassingFlash: a bright piece of the path travelling along it (time width w)
120
+ function flash(ctx, pts, u, col, lw, w, alpha, cum) {
121
+ w = w || 0.3; const b = lerp(0, 1 + w, u), a = b - w;
122
+ strokePts(ctx, pts, col, lw, Math.max(0, a), Math.min(1, b), alpha, cum);
123
+ }
124
+ function tip(ctx, x, y, ang, len, col, alpha) {
125
+ ctx.save(); ctx.globalAlpha = alpha == null ? 1 : alpha; ctx.fillStyle = col;
126
+ ctx.translate(x, y); ctx.rotate(ang);
127
+ ctx.beginPath(); ctx.moveTo(0, 0); ctx.lineTo(-len, -len * 0.5); ctx.lineTo(-len, len * 0.5); ctx.closePath(); ctx.fill();
128
+ ctx.restore();
129
+ }
130
+ // Arrow with GrowArrow progress p
131
+ function arrow(ctx, x1, y1, x2, y2, col, lw, p, tl, alpha) {
132
+ p = p == null ? 1 : p; if (p <= 0) return;
133
+ tl = (tl || 18) * Math.min(1, p * 1.5);
134
+ const ex = lerp(x1, x2, p), ey = lerp(y1, y2, p), ang = Math.atan2(y2 - y1, x2 - x1);
135
+ const sx = ex - Math.cos(ang) * tl * 0.9, sy = ey - Math.sin(ang) * tl * 0.9;
136
+ strokePts(ctx, [[x1, y1], [sx, sy]], col, lw, 0, 1, alpha);
137
+ tip(ctx, ex, ey, ang, tl, col, alpha);
138
+ }
139
+ // CurvedArrow along an arc from (x1,y1) to (x2,y2) bulging by `bend` (fraction of length, + = left of travel)
140
+ function arcPts(x1, y1, x2, y2, bend, n) {
141
+ const mx = (x1 + x2) / 2, my = (y1 + y2) / 2, dx = x2 - x1, dy = y2 - y1, L = Math.hypot(dx, dy);
142
+ const cx = mx - dy / L * bend * L, cy = my + dx / L * bend * L, pts = [];
143
+ for (let i = 0; i <= (n || 24); i++) { const u = i / (n || 24); pts.push([(1 - u) * (1 - u) * x1 + 2 * u * (1 - u) * cx + u * u * x2, (1 - u) * (1 - u) * y1 + 2 * u * (1 - u) * cy + u * u * y2]); }
144
+ return pts;
145
+ }
146
+ function curvedArrow(ctx, pts, col, lw, p, tl, alpha) {
147
+ if (p <= 0) return;
148
+ const cum = cumLen(pts), L = cum[cum.length - 1];
149
+ tl = tl || 16;
150
+ const end = p * L, k = cum.findIndex((c) => c >= end - tl * 0.85);
151
+ strokePts(ctx, pts, col, lw, 0, Math.max(0, (end - tl * 0.85) / L), alpha, cum);
152
+ // tip at the current end, aligned to the path there
153
+ let i = 1; while (i < cum.length - 1 && cum[i] < end) i++;
154
+ const u = (end - cum[i - 1]) / Math.max(1e-6, cum[i] - cum[i - 1]);
155
+ const ex = lerp(pts[i - 1][0], pts[i][0], u), ey = lerp(pts[i - 1][1], pts[i][1], u);
156
+ const j = Math.max(0, k);
157
+ tip(ctx, ex, ey, Math.atan2(ey - pts[j][1], ex - pts[j][0]), tl * Math.min(1, p * 2), col, alpha);
158
+ }
159
+ // SurroundingRectangle drawn with Create (Manim polygon order: UR -> UL -> DL -> DR -> UR)
160
+ function rectPts(x0, y0, x1, y1) { return [[x1, y0], [x0, y0], [x0, y1], [x1, y1], [x1, y0]]; }
161
+ // Brace (horizontal, opening up), GrowFromCenter with progress p
162
+ function brace(ctx, x0, x1, y, p, col, alpha) {
163
+ if (p <= 0) return;
164
+ const m = (x0 + x1) / 2, hw = (x1 - x0) / 2 * p, d = 16, a = m - hw, b = m + hw;
165
+ ctx.save(); ctx.globalAlpha = alpha == null ? 1 : alpha; ctx.fillStyle = col;
166
+ // filled tapered brace: outer edge then inner edge
167
+ const k = Math.min(d * 0.9, hw * 0.45);
168
+ ctx.beginPath();
169
+ ctx.moveTo(a, y);
170
+ ctx.quadraticCurveTo(a + 1, y + d * 0.55, a + k, y + d * 0.55);
171
+ ctx.lineTo(m - k, y + d * 0.55); ctx.quadraticCurveTo(m - 2, y + d * 0.55, m, y + d * 1.15);
172
+ ctx.quadraticCurveTo(m + 2, y + d * 0.55, m + k, y + d * 0.55);
173
+ ctx.lineTo(b - k, y + d * 0.55); ctx.quadraticCurveTo(b - 1, y + d * 0.55, b, y);
174
+ ctx.quadraticCurveTo(b - 1.5, y + d * 0.3, b - k, y + d * 0.32);
175
+ ctx.lineTo(m + k, y + d * 0.32); ctx.quadraticCurveTo(m + 1, y + d * 0.32, m, y + d * 0.62);
176
+ ctx.quadraticCurveTo(m - 1, y + d * 0.32, m - k, y + d * 0.32);
177
+ ctx.lineTo(a + k, y + d * 0.32); ctx.quadraticCurveTo(a + 1.5, y + d * 0.3, a, y);
178
+ ctx.fill();
179
+ ctx.restore();
180
+ }
181
+ // ghost of a previous position: a thin ring with a faint fill, so it stays gold over the blue curve
182
+ function ghost(ctx, x, y, r, col, alpha) {
183
+ if (alpha <= 0.003) return;
184
+ ctx.save(); ctx.globalAlpha = alpha * 0.2; ctx.fillStyle = C.bg; ctx.beginPath(); ctx.arc(x, y, r, 0, TAU); ctx.fill();
185
+ ctx.globalAlpha = alpha * 0.22; ctx.fillStyle = col; ctx.fill();
186
+ ctx.globalAlpha = alpha; ctx.strokeStyle = col; ctx.lineWidth = 2; ctx.stroke(); ctx.restore();
187
+ }
188
+ function dot(ctx, x, y, r, col, alpha) { if (r <= 0) return; ctx.save(); ctx.globalAlpha = alpha == null ? 1 : alpha; ctx.fillStyle = col; ctx.beginPath(); ctx.arc(x, y, r, 0, TAU); ctx.fill(); ctx.restore(); }
189
+ // Circle with Create (stroke runs counter-clockwise from the right) and fill opacity `fill`
190
+ function circle(ctx, x, y, r, p, stroke, lw, fillCol, fill, alpha) {
191
+ alpha = alpha == null ? 1 : alpha; if (p <= 0 || alpha <= 0.003) return;
192
+ ctx.save();
193
+ if (fill > 0.002) { ctx.globalAlpha = alpha * fill * Math.min(1, p * 1.2); ctx.fillStyle = fillCol; ctx.beginPath(); ctx.arc(x, y, r, 0, TAU); ctx.fill(); }
194
+ ctx.globalAlpha = alpha; ctx.strokeStyle = stroke; ctx.lineWidth = lw;
195
+ ctx.beginPath(); ctx.arc(x, y, r, 0, -TAU * Math.min(1, p), true); ctx.stroke();
196
+ ctx.restore();
197
+ }
198
+ function checkPts(x, y, s) { return [[x - 0.5 * s, y], [x - 0.15 * s, y + 0.38 * s], [x + 0.55 * s, y - 0.45 * s]]; }
199
+
200
+ // Axes: origin (ox,oy), unit px, x 0..xn, y 0..yn; Create progress p, tick-label progress pl
201
+ function axes(ctx, A, p, o) {
202
+ o = o || {}; const alpha = o.alpha == null ? 1 : o.alpha, col = o.col || C.white, lw = o.lw || 2.5;
203
+ if (p <= 0 || alpha <= 0.003) return;
204
+ const xe = A.ox + (A.xn + 0.35) * A.ux, ye = A.oy - (A.yn + 0.35) * A.uy;
205
+ arrow(ctx, A.ox, A.oy, xe, A.oy, col, lw, SM(p), 14, alpha);
206
+ arrow(ctx, A.ox, A.oy, A.ox, ye, col, lw, SM(p), 14, alpha);
207
+ ctx.save(); ctx.globalAlpha = alpha; ctx.strokeStyle = col; ctx.lineWidth = 2;
208
+ for (let i = 1; i <= A.xn; i++) { const s = SM(seg(i / (A.xn + 1) * 0.8, i / (A.xn + 1) * 0.8 + 0.25, p)); if (s > 0) { const x = A.ox + i * A.ux; ctx.beginPath(); ctx.moveTo(x, A.oy - 7 * s); ctx.lineTo(x, A.oy + 7 * s); ctx.stroke(); } }
209
+ for (let i = 1; i <= A.yn; i++) { const s = SM(seg(i / (A.yn + 1) * 0.8, i / (A.yn + 1) * 0.8 + 0.25, p)); if (s > 0) { const y = A.oy - i * A.uy; ctx.beginPath(); ctx.moveTo(A.ox - 7 * s, y); ctx.lineTo(A.ox + 7 * s, y); ctx.stroke(); } }
210
+ ctx.restore();
211
+ }
212
+ const ax2s = (A, x, y) => [A.ox + x * A.ux, A.oy - y * A.uy];
213
+ function graphPts(A, f, x0, x1, n) { const pts = []; for (let i = 0; i <= n; i++) { const x = lerp(x0, x1, i / n); pts.push(ax2s(A, x, f(x))); } return pts; }
214
+
215
+ // =====================================================================================================
216
+ // STILL + CLIP: gradient descent on a loss curve, with the update rule typeset beside it
217
+ // =====================================================================================================
218
+ const fS = (x) => 0.16 * (x - 4.4) * (x - 4.4) + 0.45 + 0.16 * Math.sin(2.2 * x + 0.3);
219
+ const dfS = (x) => (fS(x + 1e-3) - fS(x - 1e-3)) / 2e-3;
220
+ const AS = { ox: 110, oy: 612, ux: 104, uy: 100, xn: 6, yn: 4 };
221
+ const STEPS = [0.7, 2.05, 3.2];
222
+ const CLIP = {
223
+ title: [0.05, 1.0], under: [0.55, 1.2], axes: [0.45, 1.55], nums: [1.2, 1.7], curve: [1.35, 2.45], curveLbl: [2.05, 2.6],
224
+ dot: [2.35, 2.7], tan: [2.55, 3.0], eq: [2.6, 3.7], lossLine: [3.2, 3.8],
225
+ hop: [[3.85, 4.45], [4.6, 5.2]], rect: [5.25, 5.7], ind: [5.3, 5.85], brace: [5.55, 5.95], slope: [5.7, 6.2], pflash: [6.1, 6.75],
226
+ };
227
+ function drawStill(ctx, W, Hh, t) {
228
+ const K = CLIP;
229
+ ctx.fillStyle = C.bg; ctx.fillRect(0, 0, W, Hh);
230
+ // ---- Title (Manim Title: centred text + underline across the frame)
231
+ const title = layout(ctx, [T('Gradient '), T('descent')], 52, 640, 78, 'center');
232
+ drawTex(ctx, title, { p: seg(K.title[0], K.title[1], t) });
233
+ const u = sm(K.under[0], K.under[1], t);
234
+ if (u > 0) strokePts(ctx, [[640 - 560 * u, 104], [640 + 560 * u, 104]], C.white, 2);
235
+
236
+ // ---- axes with ticks and numbers
237
+ axes(ctx, AS, seg(K.axes[0], K.axes[1], t));
238
+ const na = sm(K.nums[0], K.nums[1], t);
239
+ if (na > 0) {
240
+ ctx.save(); ctx.font = fnt(26); ctx.fillStyle = C.white; ctx.textAlign = 'center';
241
+ for (let i = 1; i <= 6; i++) { ctx.globalAlpha = na; ctx.fillText(String(i), AS.ox + i * AS.ux, AS.oy + 38 - 10 * (1 - na)); }
242
+ ctx.textAlign = 'right';
243
+ for (let i = 1; i <= 4; i++) { ctx.globalAlpha = na; ctx.fillText(String(i), AS.ox - 16 - 10 * (1 - na), AS.oy - i * AS.uy + 9); }
244
+ ctx.restore();
245
+ const wl = layout(ctx, [T('w', { it: true })], 36, AS.ox + 6.55 * AS.ux, AS.oy + 10);
246
+ drawTex(ctx, wl, { alpha: na });
247
+ }
248
+ // ---- loss curve (Create)
249
+ const curve = graphPts(AS, fS, 0.35, 6.0, 160), ccum = cumLen(curve);
250
+ const cp = sm(K.curve[0], K.curve[1], t);
251
+ if (cp > 0) strokePts(ctx, curve, C.blue, 4, 0, cp, 1, ccum);
252
+ // ShowPassingFlash along the curve at the end of the clip
253
+ const pf = seg(K.pflash[0], K.pflash[1], t);
254
+ if (pf > 0 && pf < 1) flash(ctx, curve, SM(pf), C.yellow, 6, 0.25, 0.9, ccum);
255
+ const cl1 = layout(ctx, [T('L', { it: true, c: C.blue }), T('(', { c: C.blue }), T('w', { it: true, c: C.blue }), T(')', { c: C.blue })], 38, AS.ox + 5.45 * AS.ux + 25, AS.oy - fS(5.45) * AS.uy - 63);
256
+ drawTex(ctx, cl1, { p: seg(K.curveLbl[0], K.curveLbl[1], t) });
257
+
258
+ // ---- gradient-descent hops
259
+ const h1 = sm(K.hop[0][0], K.hop[0][1], t), h2 = sm(K.hop[1][0], K.hop[1][1], t);
260
+ const wNow = h2 > 0 ? lerp(STEPS[1], STEPS[2], h2) : lerp(STEPS[0], STEPS[1], h1);
261
+ const dotA = sm(K.dot[0], K.dot[1], t);
262
+ // ghost dots + curved arrows between steps
263
+ const hopArrow = (i, p) => {
264
+ const [x1, y1] = ax2s(AS, STEPS[i], fS(STEPS[i])), [x2, y2] = ax2s(AS, STEPS[i + 1], fS(STEPS[i + 1]));
265
+ const pts = arcPts(x1 + 6, y1 - 10, x2 - 4, y2 - 14, -0.32, 30);
266
+ curvedArrow(ctx, pts, C.gold, 3, p, 15);
267
+ };
268
+ if (h1 > 0) { const [x, y] = ax2s(AS, STEPS[0], fS(STEPS[0])); ghost(ctx, x, y, 8, C.gold, h1); hopArrow(0, h1); }
269
+ if (h2 > 0) { const [x, y] = ax2s(AS, STEPS[1], fS(STEPS[1])); ghost(ctx, x, y, 8, C.gold, h2); hopArrow(1, h2); }
270
+ if (dotA > 0) {
271
+ const [x, y] = ax2s(AS, wNow, fS(wNow));
272
+ // dashed drop line to the axis
273
+ ctx.save(); ctx.setLineDash([9, 8]); ctx.globalAlpha = 0.7 * dotA; ctx.strokeStyle = C.white; ctx.lineWidth = 2;
274
+ ctx.beginPath(); ctx.moveTo(x, y + 12); ctx.lineTo(x, lerp(y + 12, AS.oy, dotA)); ctx.stroke(); ctx.restore();
275
+ // tangent line (Create from centre)
276
+ const tp = sm(K.tan[0], K.tan[1], t);
277
+ if (tp > 0) {
278
+ const m = dfS(wNow) * AS.uy / AS.ux, ang = Math.atan(-m), hl = 150 * tp;
279
+ strokePts(ctx, [[x - Math.cos(ang) * hl, y - Math.sin(ang) * hl], [x + Math.cos(ang) * hl, y + Math.sin(ang) * hl]], C.green, 3.5);
280
+ }
281
+ dot(ctx, x, y, 10 * SM(dotA * 1.3) + 0.01, C.yellow);
282
+ // w subscript label under the axis at the dot
283
+ const idx = h2 > 0.5 ? '2' : h1 > 0.5 ? '1' : '0';
284
+ const wl2 = layout(ctx, [T('w', { it: true, c: C.yellow }), T(idx, { sz: 0.62, dy: 0.22, c: C.yellow })], 34, x - 12, AS.oy + 74);
285
+ if (na > 0) drawTex(ctx, wl2, { alpha: dotA });
286
+ }
287
+
288
+ // ---- the update rule (right): w_{n+1} = w_n − η ∇L(w_n)
289
+ const eqT = [
290
+ T('w', { it: true, k: 'w1' }), T('n', { it: true, sz: 0.62, dy: 0.22, k: 'n1' }), T('+1', { sz: 0.62, dy: 0.22, k: 'p1' }), T(' = '),
291
+ T('w', { it: true, k: 'w2' }), T('n', { it: true, sz: 0.62, dy: 0.22, k: 'n2' }), T(' − '), T('η', { it: true, c: C.teal }), T('', { gap: 0.32 }),
292
+ T('∇', { c: C.yellow, tag: 'g' }), T('L', { it: true, c: C.yellow, tag: 'g', kern: 0.02 }), T('(', { c: C.yellow, tag: 'g' }), T('w', { it: true, c: C.yellow, tag: 'g', k: 'w3' }), T('n', { it: true, sz: 0.62, dy: 0.22, c: C.yellow, tag: 'g', k: 'n3' }), T(')', { c: C.yellow, tag: 'g' }),
293
+ ];
294
+ const eq = layout(ctx, eqT, 52, 985, 320, 'center');
295
+ const ind = tab(K.ind[0], K.ind[1], t);
296
+ const gl = eq.gl.filter((g) => g.tag === 'g');
297
+ const gx0 = Math.min(...gl.map((g) => g.x)) - 6, gx1 = eq.x1 + 6;
298
+ const gcx = (gx0 + gx1) / 2;
299
+ const ep = seg(K.eq[0], K.eq[1], t);
300
+ eq.gl.forEach((g, i) => {
301
+ let x = g.x, y = g.y, s = 1, col = g.c;
302
+ if (g.tag === 'g' && ind > 0) { s = 1 + 0.2 * ind; x = gcx + (g.x - gcx) * s; y = 302 + (g.y - 302) * s; col = mixc(g.c, C.yellow, ind); }
303
+ glyph(ctx, g, writeA(eq.gl.length, ep, i), 1, col, x, y, s);
304
+ });
305
+ // SurroundingRectangle around ∇L(w_n)
306
+ const rp = sm(K.rect[0], K.rect[1], t);
307
+ if (rp > 0) strokePts(ctx, rectPts(gx0 - 8, 320 - 50, gx1 + 8, 320 + 24), C.yellow, 3, 0, rp);
308
+ brace(ctx, gx0 - 4, gx1 + 4, 356, sm(K.brace[0], K.brace[1], t), C.white);
309
+ const sl = layout(ctx, [T('slope')], 36, gcx, 420, 'center');
310
+ drawTex(ctx, sl, { p: seg(K.slope[0], K.slope[1], t) });
311
+ // step-size note under η
312
+ // live loss value: L(w) = 0.61 (DecimalNumber)
313
+ const lp = seg(K.lossLine[0], K.lossLine[1], t);
314
+ if (lp > 0) {
315
+ const lab = layout(ctx, [T('L', { it: true, c: C.blue }), T('(', { c: C.blue }), T('w', { it: true, c: C.blue }), T(')', { c: C.blue }), T(' = ')], 46, 815, 520);
316
+ drawTex(ctx, lab, { p: lp });
317
+ ctx.save(); ctx.font = fnt(46); ctx.fillStyle = C.white; ctx.globalAlpha = SM(lp * 1.6 - 0.6);
318
+ ctx.fillText(fS(wNow).toFixed(2), lab.x1 + 4, 520); ctx.restore();
319
+ }
320
+ }
321
+
322
+ // =====================================================================================================
323
+ // EXPLAINER: "How does AI learn?" as one continuous Manim scene (MovingCameraScene)
324
+ // =====================================================================================================
325
+ const X = {
326
+ D: 16,
327
+ title: [0.1, 1.15], toHeader: [1.3, 1.95],
328
+ net: [1.55, 2.6], edges: [1.9, 2.85], outLbl: [2.4, 2.85],
329
+ q0: 2.15, fly: [3.0, 3.35, 3.7, 4.0, 4.3, 4.55, 4.8, 5.05], flyDur: 0.5,
330
+ count: [3.05, 5.0], counterIn: [2.95, 3.3], dataOut: [5.35, 5.75],
331
+ loop: [5.8, 6.4], test: [5.7, 6.1], testTag: [5.95, 6.25], testFly: [6.2, 6.65],
332
+ pass1: 6.6, layerDur: 0.27, guessQ: [7.4, 7.7], check: 7.8, tagMorph: [7.8, 8.15], rect: [7.85, 8.2], cross: [8.1, 8.35],
333
+ adjust: 8.5, back: 8.5, pan: [8.4, 9.1], lossAxes: [8.6, 9.2], lossCurve: [8.8, 9.35], lossVal: [9.0, 9.35], lossDot: [9.15, 9.35],
334
+ steps: [[9.35, 9.8], [9.85, 10.3]], reweight: [9.35, 10.3], loopFlash: [10.0, 10.4],
335
+ pass2: 10.3, layerDur2: 0.12, fix: [10.62, 10.95], tick: [10.75, 11.0],
336
+ out: [11.6, 12.0], cam2: [11.6, 12.25], relabel: [11.8, 12.3], acc: [12.25, 13.3], hero: [13.3, 13.7], ind: [13.7, 14.15],
337
+ heroRect: [14.05, 14.4], accFlash: [13.6, 14.1], chartOut: [14.45, 14.85], heroUp: [14.45, 14.95], take: [14.65, 15.3], sub: [15.1, 15.55],
338
+ };
339
+ // network geometry (world coordinates; camera starts at (640,360) zoom 1 so world = screen there)
340
+ const LX = [470, 630, 790, 950];
341
+ const LAY = [
342
+ [0, 1, 2, 3, 4, 5].map((i) => 195 + i * 62),
343
+ [0, 1, 2, 3, 4].map((i) => 220 + i * 65),
344
+ [0, 1, 2, 3, 4].map((i) => 220 + i * 65),
345
+ [290, 410],
346
+ ];
347
+ const NR = [19, 20, 20, 24];
348
+ const NEUR = LAY.map((ys, l) => ys.map((y) => [LX[l], y]));
349
+ const EDGES = [];
350
+ {
351
+ const r = H.rng(808);
352
+ for (let l = 0; l < 3; l++) for (let i = 0; i < NEUR[l].length; i++) for (let j = 0; j < NEUR[l + 1].length; j++) {
353
+ const [x1, y1] = NEUR[l][i], [x2, y2] = NEUR[l + 1][j], ang = Math.atan2(y2 - y1, x2 - x1);
354
+ const a = [x1 + Math.cos(ang) * NR[l], y1 + Math.sin(ang) * NR[l]], b = [x2 - Math.cos(ang) * NR[l + 1], y2 - Math.sin(ang) * NR[l + 1]];
355
+ const w0 = r.range(-1, 1) * (0.35 + 0.65 * r());
356
+ const w1 = r.chance(0.45) ? -w0 * r.range(0.6, 1.2) + r.range(-0.3, 0.3) : w0 + r.range(-0.25, 0.25);
357
+ EDGES.push({ l, i, j, pts: [a, b], w0, w1: cl(w1, -1, 1), d: r() });
358
+ }
359
+ }
360
+ const ACT = (() => {
361
+ const r = H.rng(41), A1 = [], A2 = [];
362
+ for (const l of [1, 2]) { A1[l] = NEUR[l].map(() => r.range(0.05, 0.95)); A2[l] = NEUR[l].map(() => r.range(0.05, 0.95)); }
363
+ A1[3] = [0.88, 0.16]; A2[3] = [0.1, 0.94];
364
+ return { A1, A2 };
365
+ })();
366
+ // 12x12 greyscale "pixel" pictures (like 3b1b's MNIST grids): cat / dog
367
+ function pix(kind) {
368
+ const N = 12, out = new Float32Array(N * N);
369
+ const E = (x, y, cx, cy, rx, ry, rot) => { const c = Math.cos(rot || 0), s = Math.sin(rot || 0), dx = x - cx, dy = y - cy, u = dx * c + dy * s, v = -dx * s + dy * c; return (u / rx) ** 2 + (v / ry) ** 2 <= 1; };
370
+ const Tri = (x, y, a, b, c) => { const d = (p, q, r) => (p[0] - r[0]) * (q[1] - r[1]) - (q[0] - r[0]) * (p[1] - r[1]); const P = [x, y], d1 = d(P, a, b), d2 = d(P, b, c), d3 = d(P, c, a); return !((d1 < 0 || d2 < 0 || d3 < 0) && (d1 > 0 || d2 > 0 || d3 > 0)); };
371
+ const shade = (x, y) => {
372
+ if (kind === 'cat') {
373
+ const head = E(x, y, 6, 7.4, 4.5, 3.7), ears = Tri(x, y, [1.6, 5.6], [2.4, 0.7], [5.4, 4.0]) || Tri(x, y, [10.4, 5.6], [9.6, 0.7], [6.6, 4.0]);
374
+ if (!head && !ears) return 0;
375
+ if (E(x, y, 4.2, 6.9, 0.75, 1.0) || E(x, y, 7.8, 6.9, 0.75, 1.0)) return 0.08;
376
+ if (Tri(x, y, [5.2, 8.7], [6.8, 8.7], [6, 9.6])) return 0.2;
377
+ if (ears && !head && (Tri(x, y, [2.4, 5.0], [2.7, 2.2], [4.5, 4.2]) || Tri(x, y, [9.6, 5.0], [9.3, 2.2], [7.5, 4.2]))) return 0.55;
378
+ return 0.95 - 0.3 * (y / 12);
379
+ }
380
+ const head = E(x, y, 6, 6.0, 3.3, 3.9), snout = E(x, y, 6, 8.9, 2.3, 1.9), earL = E(x, y, 2.5, 6.6, 1.3, 3.2, 0.32), earR = E(x, y, 9.5, 6.6, 1.3, 3.2, -0.32);
381
+ if (!head && !snout && !earL && !earR) return 0;
382
+ if (E(x, y, 6, 8.0, 0.95, 0.65)) return 0.06;
383
+ if (E(x, y, 4.6, 5.4, 0.6, 0.75) || E(x, y, 7.4, 5.4, 0.6, 0.75)) return 0.08;
384
+ if ((earL || earR) && !head) return 0.42;
385
+ if (snout && !head) return 0.82;
386
+ return 0.97 - 0.25 * (y / 12);
387
+ };
388
+ for (let j = 0; j < N; j++) for (let i = 0; i < N; i++) {
389
+ let s = 0; for (let a = 0; a < 4; a++) for (let b = 0; b < 4; b++) s += shade(i + (a + 0.5) / 4, j + (b + 0.5) / 4);
390
+ out[j * N + i] = s / 16;
391
+ }
392
+ return out;
393
+ }
394
+ const IMG = { cat: pix('cat'), dog: pix('dog') };
395
+ function drawPix(ctx, img, x, y, cell, alpha, border) {
396
+ if (alpha <= 0.003) return;
397
+ const N = 12;
398
+ ctx.save(); ctx.globalAlpha = alpha;
399
+ for (let j = 0; j < N; j++) for (let i = 0; i < N; i++) {
400
+ const v = img[j * N + i];
401
+ if (v > 0.01) { ctx.fillStyle = H.rgba('#ffffff', v); ctx.fillRect(x + i * cell, y + j * cell, cell, cell); }
402
+ }
403
+ ctx.strokeStyle = 'rgba(255,255,255,0.16)'; ctx.lineWidth = 1; ctx.beginPath();
404
+ for (let k = 1; k < N; k++) { ctx.moveTo(x + k * cell, y); ctx.lineTo(x + k * cell, y + N * cell); ctx.moveTo(x, y + k * cell); ctx.lineTo(x + N * cell, y + k * cell); }
405
+ ctx.stroke();
406
+ ctx.strokeStyle = border || C.white; ctx.lineWidth = 2; ctx.strokeRect(x, y, N * cell, N * cell);
407
+ ctx.restore();
408
+ }
409
+ // which input neuron each pixel feeds (6 neurons + the ⋮ slot)
410
+ const pixTarget = (k) => (k * 5 + ((k / 12) | 0)) % 7;
411
+ function inputActs(img) { const s = new Array(7).fill(0), n = new Array(7).fill(0); for (let k = 0; k < 144; k++) { const j = pixTarget(k); s[j] += img[k]; n[j]++; } return s.map((v, j) => cl(v / n[j] * 1.8)); }
412
+ const IA = { cat: inputActs(IMG.cat), dog: inputActs(IMG.dog) };
413
+ const targetPos = (j) => (j < 6 ? NEUR[0][j] : [LX[0], 552]);
414
+ // pixels flying from a picture into the input column (Transform with lag)
415
+ function drawFlight(ctx, img, x, y, cell, u) {
416
+ if (u <= 0 || u >= 1) return;
417
+ ctx.save();
418
+ for (let k = 0; k < 144; k++) {
419
+ const v = img[k]; if (v < 0.12) continue;
420
+ const d = (k / 144) * 0.45, a = SM((u - d) / 0.55); if (a <= 0 || a >= 1) continue;
421
+ const sx = x + (k % 12) * cell + cell / 2, sy = y + ((k / 12) | 0) * cell + cell / 2, [tx, ty] = targetPos(pixTarget(k));
422
+ const px = lerp(sx, tx, a), py = lerp(sy, ty, a), s = lerp(cell, 5, a);
423
+ ctx.globalAlpha = v * (a > 0.75 ? (1 - a) / 0.25 : 1);
424
+ ctx.fillStyle = '#fff'; ctx.fillRect(px - s / 2, py - s / 2, s, s);
425
+ }
426
+ ctx.restore();
427
+ }
428
+ // camera
429
+ function cam(t) {
430
+ const a = sm(X.pan[0], X.pan[1], t), b = sm(X.cam2[0], X.cam2[1], t);
431
+ let x = lerp(640, 1065, a), y = 360, z = Math.exp(lerp(0, Math.log(0.84), a));
432
+ x = lerp(x, 1560, b); z = Math.exp(lerp(Math.log(z), Math.log(1.1), b));
433
+ return { x, y, z };
434
+ }
435
+ const w2s = (c, x, y) => [(x - c.x) * c.z + 640, (y - c.y) * c.z + 360];
436
+ // loss / accuracy panel (world)
437
+ const AL = { ox: 1160, oy: 525, ux: 100, uy: 100, xn: 5, yn: 3 };
438
+ const fL = (w) => 0.22 * (w - 3.6) * (w - 3.6) + 0.25 + 0.1 * Math.sin(3 * w);
439
+ const dfL = (w) => (fL(w + 1e-3) - fL(w - 1e-3)) / 2e-3;
440
+ const LSTEP = [0.55, 1.95, 3.35];
441
+ const ACC = (r) => 61 + 36 * (1 - Math.exp(-0.7 * r)) / (1 - Math.exp(-0.7 * 5)) + 1.6 * Math.sin(r * 5.3) * Math.exp(-0.5 * r) * Math.min(1, r * 2);
442
+ const accY = (v) => (v - 40) / 20; // 40%..100% over 3 units
443
+
444
+ function explainer(ctx, W, Hh, t) {
445
+ ctx.fillStyle = C.bg; ctx.fillRect(0, 0, W, Hh);
446
+ const cm = cam(t);
447
+ const outA = 1 - sm(X.out[0], X.out[1], t), outDx = -70 * sm(X.out[0], X.out[1], t);
448
+
449
+ // ======================= WORLD =======================
450
+ ctx.save();
451
+ ctx.translate(640, 360); ctx.scale(cm.z, cm.z); ctx.translate(-cm.x, -cm.y);
452
+
453
+ // ---------------- network
454
+ if (outA > 0.003) {
455
+ ctx.save(); ctx.translate(outDx, 0);
456
+ const rw = sm(X.reweight[0], X.reweight[1], t);
457
+ // edges: colour by sign of weight, thickness by magnitude; Create with lag
458
+ for (const e of EDGES) {
459
+ const cp = sm(X.edges[0] + e.l * 0.22 + e.d * 0.25, X.edges[0] + e.l * 0.22 + e.d * 0.25 + 0.45, t);
460
+ if (cp <= 0) continue;
461
+ const w = lerp(e.w0, e.w1, rw), m = Math.abs(w);
462
+ strokePts(ctx, e.pts, w >= 0 ? C.blue : C.red, 0.6 + 3.6 * m, 0, cp, outA * (0.25 + 0.75 * m));
463
+ }
464
+ // passing flashes
465
+ const pass = (P, dur, col, rev, alpha) => {
466
+ for (const e of EDGES) {
467
+ const st = rev ? P + (2 - e.l) * dur * 0.85 : P + e.l * dur * 0.85, u = seg(st, st + dur, t);
468
+ if (u > 0 && u < 1) flash(ctx, rev ? [e.pts[1], e.pts[0]] : e.pts, SM(u), col, 3, 0.4, alpha * outA);
469
+ }
470
+ };
471
+ // little flashes for the streamed examples (beat 2)
472
+ X.fly.forEach((f, i) => { if (i > 0) pass(f + X.flyDur * 0.9, 0.22, C.yellow, false, 0.35); });
473
+ pass(X.pass1, X.layerDur, C.yellow, false, 0.95);
474
+ pass(X.back, 0.27, C.red, true, 1);
475
+ pass(X.pass2, X.layerDur2, C.yellow, false, 0.95);
476
+
477
+ // neuron activations
478
+ const inAct = (j) => {
479
+ let v = 0;
480
+ X.fly.forEach((f, i) => { const k = i % 2 ? 'dog' : 'cat'; const on = sm(f + X.flyDur * 0.6, f + X.flyDur, t); if (on > 0) v = lerp(v, IA[k][j] * 0.75, on); });
481
+ v *= 1 - sm(X.dataOut[0], X.dataOut[1], t);
482
+ const tin = sm(X.testFly[0] + 0.3, X.testFly[1], t); if (tin > 0) v = lerp(v, IA.cat[j], tin);
483
+ return v;
484
+ };
485
+ const layerAct = (l, i) => {
486
+ if (l === 0) return inAct(i);
487
+ let v = 0;
488
+ // faint flicker while data streams
489
+ X.fly.forEach((f, k) => { if (k > 0) { const st = f + X.flyDur * 0.9 + (l - 0.5) * 0.19; v = Math.max(v, 0.3 * tab(st, st + 0.35, t) * ((i * 7 + k * 3 + l) % 5) / 4); } });
490
+ const on1 = sm(X.pass1 + l * X.layerDur * 0.85 + X.layerDur * 0.6, X.pass1 + l * X.layerDur * 0.85 + X.layerDur * 1.1, t);
491
+ const on2 = sm(X.pass2 + l * X.layerDur2 * 0.85 + X.layerDur2 * 0.6, X.pass2 + l * X.layerDur2 * 0.85 + X.layerDur2 * 1.4, t);
492
+ if (on1 > 0) v = lerp(v, ACT.A1[l][i], on1);
493
+ if (on2 > 0) v = lerp(v, ACT.A2[l][i], on2);
494
+ return v;
495
+ };
496
+ for (let l = 0; l < 4; l++) NEUR[l].forEach(([x, y], i) => {
497
+ const p = sm(X.net[0] + l * 0.18 + i * 0.03, X.net[0] + l * 0.18 + i * 0.03 + 0.5, t);
498
+ circle(ctx, x, y, NR[l], p, C.white, 2.2, C.white, layerAct(l, i), outA);
499
+ });
500
+ // ⋮ under the input column
501
+ const dp = sm(X.net[0] + 0.3, X.net[0] + 0.7, t);
502
+ for (let k = 0; k < 3; k++) dot(ctx, LX[0], 540 + k * 13, 3.2, C.white, dp * outA);
503
+
504
+ // output labels: dog / cat, the guess "dog?", check marks
505
+ const lblIn = seg(X.outLbl[0], X.outLbl[1], t);
506
+ const dogL = layout(ctx, [T('dog', { k: 'dog' })], 38, 990, 302);
507
+ const dogQ = layout(ctx, [T('dog', { k: 'dog' }), T('?', { k: 'q' })], 38, 990, 302);
508
+ const catL = layout(ctx, [T('cat', { k: 'cat' })], 38, 990, 422);
509
+ const gq = sm(X.guessQ[0], X.guessQ[1], t), fix = sm(X.fix[0], X.fix[1], t);
510
+ const redA = sm(X.check, X.check + 0.25, t);
511
+ const dogCol = mixc(mixc(C.white, C.yellow, gq), C.red, redA);
512
+ if (gq <= 0) drawTex(ctx, dogL, { p: lblIn, alpha: outA });
513
+ else if (fix <= 0) morphTex(ctx, dogL, dogQ, gq, { alpha: outA, colB: () => dogCol });
514
+ else morphTex(ctx, dogQ, dogL, fix, { alpha: outA, colA: () => dogCol, colB: () => mixc(C.red, C.greyL, fix) });
515
+ drawTex(ctx, catL, { p: lblIn, alpha: outA, col: mixc(C.white, C.green, fix) });
516
+ // ✗ next to dog?
517
+ const crossP = sm(X.cross[0], X.cross[1], t) * (1 - fix);
518
+ if (crossP > 0) {
519
+ const cx = dogQ.x1 + 28, cy = 290, s = 15;
520
+ strokePts(ctx, [[cx - s, cy - s], [cx + s, cy + s]], C.red, 5, 0, SM(crossP * 2), outA);
521
+ strokePts(ctx, [[cx + s, cy - s], [cx - s, cy + s]], C.red, 5, 0, SM(crossP * 2 - 1), outA);
522
+ }
523
+ // ✓ next to cat
524
+ const tk = sm(X.tick[0], X.tick[1], t);
525
+ if (tk > 0) strokePts(ctx, checkPts(catL.x1 + 34, 410, 32), C.green, 5, 0, tk, outA);
526
+ // SurroundingRectangle: red round the wrong guess, then Transform to green round the right answer
527
+ const rp = sm(X.rect[0], X.rect[1], t);
528
+ if (rp > 0) {
529
+ const r0 = [950 - 34, 290 - 38, dogQ.x1 + 56, 290 + 36], r1 = [950 - 34, 410 - 38, catL.x1 + 64, 410 + 36];
530
+ const q = fix, R = r0.map((v, i) => lerp(v, r1[i], q));
531
+ strokePts(ctx, rectPts(R[0], R[1], R[2], R[3]), mixc(C.red, C.green, q), 3.5, 0, rp, outA);
532
+ }
533
+ ctx.restore();
534
+ }
535
+
536
+ // ---------------- data queue (beat 2)
537
+ const dataOutA = sm(X.dataOut[0], X.dataOut[1], t);
538
+ const qA = 1 - dataOutA, qDx = -80 * dataOutA;
539
+ if (qA > 0.003) {
540
+ const SLOTS = [206, 349, 492], N = X.fly.length, later = [];
541
+ for (let i = 0; i < N; i++) {
542
+ const kind = i % 2 ? 'dog' : 'cat', fl = X.fly[i];
543
+ const appear = i < 3 ? X.q0 + i * 0.15 : X.fly[i - 3];
544
+ if (t < appear) continue;
545
+ // slot position: index in queue = i - (# flown before t), animated smoothly
546
+ let slot = i; for (let k = 0; k < i; k++) slot -= sm(X.fly[k], X.fly[k] + 0.32, t);
547
+ slot = Math.min(slot, 2);
548
+ const y = lerp(SLOTS[0], SLOTS[2], slot / 2) + 40 * (1 - sm(appear, appear + 0.35, t));
549
+ const fin = sm(appear, appear + 0.35, t);
550
+ const flyU = seg(fl, fl + X.flyDur, t);
551
+ const cell = 10, x0 = 172 + qDx, y0 = y - 60;
552
+ const imgA = (flyU > 0 ? 1 - SM(flyU * 2.5) : 1) * fin * qA;
553
+ // cards are stacked back to front: each one knocks out what is beneath it (plus a 3px black gap)
554
+ if (imgA > 0.003) { ctx.save(); ctx.globalAlpha = Math.min(1, imgA * 1.6); ctx.fillStyle = C.bg; ctx.fillRect(x0 - 4, y0 - 4, 12 * cell + 8, 12 * cell + 8); ctx.restore(); }
555
+ drawPix(ctx, IMG[kind], x0, y0, cell, imgA);
556
+ later.push([kind, x0, y0, cell, flyU, y, appear, imgA * fin]);
557
+ }
558
+ // labels, then the flying pixels on top of everything in the queue
559
+ for (const [kind, x0, , , , y, appear, a] of later) {
560
+ const tag = layout(ctx, [T(kind)], 32, x0 + 132, y + 11);
561
+ drawTex(ctx, tag, { p: seg(appear + 0.1, appear + 0.5, t), alpha: a, col: kind === 'cat' ? C.gold : C.teal });
562
+ }
563
+ for (const [kind, x0, y0, cell, flyU] of later) drawFlight(ctx, IMG[kind], x0, y0, cell, flyU);
564
+ // counter: Integer + "examples"
565
+ const ci = sm(X.counterIn[0], X.counterIn[1], t);
566
+ if (ci > 0) {
567
+ const n = 1e6 * Math.pow(seg(X.count[0], X.count[1], t), 2.4);
568
+ ctx.save(); ctx.globalAlpha = ci * qA; ctx.font = fnt(70); ctx.fillStyle = C.white;
569
+ const s = commas(n); ctx.fillText(s, 58 + qDx, 650 + 24 * (1 - ci));
570
+ const wN = ctx.measureText(s).width; ctx.restore();
571
+ const ex = layout(ctx, [T('examples', { it: false })], 34, 58 + qDx + Math.max(wN, 270) + 16, 650 + 24 * (1 - ci));
572
+ drawTex(ctx, ex, { alpha: ci * qA, col: C.greyL });
573
+ }
574
+ }
575
+
576
+ // ---------------- test picture (beat 3)
577
+ const testIn = sm(X.test[0], X.test[1], t);
578
+ if (testIn > 0) {
579
+ const fade = 1 - sm(X.pan[0], X.pan[0] + 0.4, t);
580
+ const cell = 15, x0 = 140, y0 = 250 + 30 * (1 - testIn);
581
+ const flyU = seg(X.testFly[0], X.testFly[1], t);
582
+ drawPix(ctx, IMG.cat, x0, y0, cell, testIn * fade, C.white);
583
+ drawFlight(ctx, IMG.cat, x0, y0, cell, flyU);
584
+ const q = layout(ctx, [T('?', { k: 'q' })], 44, 230, 490, 'center');
585
+ const cat = layout(ctx, [T('cat', { k: 'cat' })], 44, 230, 490, 'center');
586
+ const tm = sm(X.tagMorph[0], X.tagMorph[1], t);
587
+ if (tm <= 0) drawTex(ctx, q, { p: seg(X.testTag[0], X.testTag[1], t), alpha: fade });
588
+ else morphTex(ctx, q, cat, tm, { alpha: fade, colA: () => C.white, colB: () => C.green });
589
+ // "answer" note
590
+ const an = layout(ctx, [T('answer:')], 30, 230, 452, 'center');
591
+ drawTex(ctx, an, { alpha: fade * tm, col: C.greyL, dy: -8 * (1 - tm) });
592
+ }
593
+
594
+ // ---------------- loss panel → accuracy panel
595
+ const la = seg(X.lossAxes[0], X.lossAxes[1], t);
596
+ const chartA = 1 - sm(X.chartOut[0], X.chartOut[1], t), chartDx = -80 * sm(X.chartOut[0], X.chartOut[1], t);
597
+ if (la > 0 && chartA > 0.003) {
598
+ ctx.save(); ctx.translate(chartDx, 0);
599
+ axes(ctx, AL, la, { alpha: chartA });
600
+ const rl = sm(X.relabel[0], X.relabel[1], t);
601
+ // y tick labels: 1 2 3 → 60% 80% 100%
602
+ const nA = SM(la * 1.4 - 0.4) * chartA;
603
+ ctx.save(); ctx.font = fnt(28); ctx.textAlign = 'right'; ctx.fillStyle = C.white;
604
+ for (let i = 1; i <= 3; i++) {
605
+ const y = AL.oy - i * AL.uy + 10;
606
+ ctx.globalAlpha = nA * (1 - rl); ctx.fillText(String(i), AL.ox - 16, y - 14 * rl);
607
+ ctx.globalAlpha = nA * rl; ctx.fillText((40 + i * 20) + '%', AL.ox - 16, y + 14 * (1 - rl));
608
+ }
609
+ ctx.restore();
610
+ // axis labels: loss → accuracy (y), w → training rounds (x)
611
+ const yl0 = layout(ctx, [T('loss', { k: 'l' })], 34, AL.ox + 22, AL.oy - 3.3 * AL.uy + 10);
612
+ const yl1 = layout(ctx, [T('accuracy', { k: 'a' })], 34, AL.ox + 22, AL.oy - 3.3 * AL.uy + 10);
613
+ const xl0 = layout(ctx, [T('w', { it: true })], 38, AL.ox + 5.45 * AL.ux, AL.oy + 12);
614
+ const xl1 = layout(ctx, [T('rounds')], 32, AL.ox + 5.0 * AL.ux - 30, AL.oy + 48);
615
+ if (rl <= 0) { drawTex(ctx, yl0, { p: seg(X.lossAxes[0] + 0.3, X.lossAxes[1] + 0.2, t), alpha: chartA }); drawTex(ctx, xl0, { p: seg(X.lossAxes[0] + 0.3, X.lossAxes[1] + 0.2, t), alpha: chartA }); }
616
+ else { morphTex(ctx, yl0, yl1, rl, { alpha: chartA }); morphTex(ctx, xl0, xl1, rl, { alpha: chartA }); }
617
+
618
+ // loss curve + rolling dot + tangent, fading out on the relabel
619
+ const lossA = (1 - sm(X.out[0], X.out[0] + 0.35, t)) * chartA;
620
+ if (lossA > 0.003) {
621
+ const lc = graphPts(AL, fL, 0.2, 5.0, 120);
622
+ strokePts(ctx, lc, C.blue, 4, 0, sm(X.lossCurve[0], X.lossCurve[1], t), lossA);
623
+ const s1 = sm(X.steps[0][0], X.steps[0][1], t), s2 = sm(X.steps[1][0], X.steps[1][1], t);
624
+ const w = s2 > 0 ? lerp(LSTEP[1], LSTEP[2], s2) : lerp(LSTEP[0], LSTEP[1], s1);
625
+ const dA = sm(X.lossDot[0], X.lossDot[1], t);
626
+ const [dx, dy] = ax2s(AL, w, fL(w));
627
+ if (dA > 0) {
628
+ if (s1 > 0) { const [gx, gy] = ax2s(AL, LSTEP[0], fL(LSTEP[0])); ghost(ctx, gx, gy, 7, C.gold, s1 * lossA); curvedArrow(ctx, arcPts(gx + 6, gy - 10, ...ax2s(AL, LSTEP[1], fL(LSTEP[1]) + 0.14), -0.3, 24), C.gold, 3, s1, 14, lossA); }
629
+ if (s2 > 0) { const [gx, gy] = ax2s(AL, LSTEP[1], fL(LSTEP[1])); ghost(ctx, gx, gy, 7, C.gold, s2 * lossA); curvedArrow(ctx, arcPts(gx + 6, gy - 10, ...ax2s(AL, LSTEP[2], fL(LSTEP[2]) + 0.14), -0.3, 24), C.gold, 3, s2, 14, lossA); }
630
+ const m = dfL(w), ang = Math.atan(-m), hl = 95 * dA;
631
+ strokePts(ctx, [[dx - Math.cos(ang) * hl, dy - Math.sin(ang) * hl], [dx + Math.cos(ang) * hl, dy + Math.sin(ang) * hl]], C.green, 3, 0, 1, lossA);
632
+ dot(ctx, dx, dy, 11 * dA, C.yellow, lossA);
633
+ }
634
+ // L(w) = value (DecimalNumber)
635
+ const lv = seg(X.lossVal[0], X.lossVal[1], t);
636
+ if (lv > 0) {
637
+ const lab = layout(ctx, [T('L', { it: true, c: C.blue }), T('(', { c: C.blue }), T('w', { it: true, c: C.blue }), T(')', { c: C.blue }), T(' = ')], 46, 1385, 215);
638
+ drawTex(ctx, lab, { p: lv, alpha: lossA });
639
+ ctx.save(); ctx.font = fnt(46); ctx.fillStyle = C.white; ctx.globalAlpha = SM(lv * 1.6 - 0.6) * lossA;
640
+ ctx.fillText(fL(w).toFixed(2), lab.x1 + 4, 215); ctx.restore();
641
+ }
642
+ }
643
+ // accuracy curve (Create) with the tip dot
644
+ const ap = sm(X.acc[0], X.acc[1], t);
645
+ if (ap > 0) {
646
+ const ac = graphPts(AL, (r) => accY(ACC(r)), 0, 5, 140), acum = cumLen(ac);
647
+ strokePts(ctx, ac, C.green, 4, 0, ap, chartA, acum);
648
+ const af = seg(X.accFlash[0], X.accFlash[1], t);
649
+ if (af > 0 && af < 1) flash(ctx, ac, SM(af), C.yellow, 6, 0.3, chartA, acum);
650
+ const r = 5 * ap, [tx, ty] = ax2s(AL, r, accY(ACC(r)));
651
+ dot(ctx, tx, ty, 9, C.white, chartA * (1 - sm(X.hero[0], X.hero[1], t) * 0.0));
652
+ // dashed 97% guide once complete
653
+ const g = sm(X.acc[1] - 0.1, X.acc[1] + 0.3, t);
654
+ if (g > 0) { ctx.save(); ctx.setLineDash([8, 8]); ctx.globalAlpha = 0.5 * g * chartA; ctx.strokeStyle = C.green; ctx.lineWidth = 2; ctx.beginPath(); ctx.moveTo(AL.ox, ty); ctx.lineTo(lerp(AL.ox, tx, g), ty); ctx.stroke(); ctx.restore(); }
655
+ }
656
+ ctx.restore();
657
+ }
658
+ ctx.restore();
659
+
660
+ // ======================= SCREEN (fixed in frame) =======================
661
+ // accuracy number: rides the curve tip, then Transforms into the hero 97%, Indicate, SurroundingRectangle
662
+ const ap = sm(X.acc[0], X.acc[1], t);
663
+ if (ap > 0) {
664
+ const r = 5 * ap, v = Math.round(ACC(r));
665
+ const [wx, wy] = ax2s(AL, r, accY(ACC(r)));
666
+ const [sx, sy] = w2s(cm, wx, wy);
667
+ const hp = sm(X.hero[0], X.hero[1], t), up = sm(X.heroUp[0], X.heroUp[1], t);
668
+ const ind = tab(X.ind[0], X.ind[1], t);
669
+ const smallS = 66, heroS = 136, finS = 104;
670
+ let size = lerp(smallS, heroS, hp), cx = lerp(sx + 16, 1010, hp), cy = lerp(sy - 24, 430, hp);
671
+ size = lerp(size, finS, up); cx = lerp(cx, 640, up); cy = lerp(cy, 300, up);
672
+ const s = size * (1 + 0.2 * ind);
673
+ const txt = v + '%';
674
+ ctx.save();
675
+ ctx.font = fnt(s, false, 600);
676
+ const w = ctx.measureText(txt).width;
677
+ const align = lerp(0, 0.5, hp); // left-aligned just above the tip, centred as hero
678
+ const x0 = cx - w * align;
679
+ ctx.fillStyle = mixc(C.white, C.yellow, ind);
680
+ ctx.globalAlpha = sm(X.acc[0], X.acc[0] + 0.2, t);
681
+ ctx.fillText(txt, x0, cy);
682
+ ctx.restore();
683
+ // "accuracy" caption above the hero number
684
+ if (hp > 0) {
685
+ const cap = layout(ctx, [T('accuracy')], 38, cx, cy - size * 0.82 - 50 * hp, 'center');
686
+ drawTex(ctx, cap, { alpha: hp * (1 - up), col: C.greyL });
687
+ }
688
+ const rr = sm(X.heroRect[0], X.heroRect[1], t);
689
+ if (rr > 0) { ctx.font = fnt(heroS, false, 600); const bw = ctx.measureText(txt).width, bh = heroS * 0.8; const R = [cx - bw / 2 - 24, cy - bh - 16, cx + bw / 2 + 24, cy + 24]; const k = lerp(1, finS / heroS, up); strokePts(ctx, rectPts(cx - (cx - R[0]) * k, cy - (cy - R[1]) * k, cx + (R[2] - cx) * k, cy + (R[3] - cy) * k), C.yellow, 3.5, 0, rr); }
690
+ }
691
+
692
+ // header: "How does AI learn?" written centre, then Transform to the top-left header
693
+ const big = layout(ctx, [T('How does '), T('AI', { c: C.yellow }), T(' '), T('learn', { c: C.blue }), T('?')], 76, 640, 380, 'center');
694
+ const hdr = layout(ctx, [T('How does '), T('AI', { c: C.yellow }), T(' '), T('learn', { c: C.blue }), T('?')], 44, 40, 68);
695
+ const hq = sm(X.toHeader[0], X.toHeader[1], t);
696
+ if (hq <= 0) drawTex(ctx, big, { p: seg(X.title[0], X.title[1], t) });
697
+ else morphTex(ctx, big, hdr, hq);
698
+
699
+ // Guess → Check → Adjust loop row (bottom), active stage in yellow, curved arrow back
700
+ const lp = seg(X.loop[0], X.loop[1], t), loopA = 1 - sm(X.out[0], X.out[1], t);
701
+ if (lp > 0 && loopA > 0.003) {
702
+ ctx.save(); ctx.translate(0, 40 * sm(X.out[0], X.out[1], t));
703
+ const words = ['Guess', 'Check', 'Adjust'], gap = 92;
704
+ ctx.font = fnt(36); const ws = words.map((w) => ctx.measureText(w).width);
705
+ const total = ws.reduce((a, b) => a + b, 0) + gap * 2;
706
+ let x = 640 - total / 2; const by = 662;
707
+ const act = (i) => {
708
+ if (i === 0) return Math.max(tab(X.pass1 - 0.1, X.check + 0.05, t) > 0 ? sm(X.pass1 - 0.1, X.pass1 + 0.15, t) * (1 - sm(X.check - 0.1, X.check + 0.1, t)) : 0, sm(X.pass2 - 0.1, X.pass2 + 0.1, t) * (1 - sm(X.fix[0], X.fix[0] + 0.2, t)));
709
+ if (i === 1) return Math.max(sm(X.check - 0.1, X.check + 0.1, t) * (1 - sm(X.adjust - 0.1, X.adjust + 0.1, t)), sm(X.fix[0], X.fix[0] + 0.2, t));
710
+ return sm(X.adjust - 0.1, X.adjust + 0.1, t) * (1 - sm(X.pass2 - 0.1, X.pass2 + 0.1, t));
711
+ };
712
+ const pos = [];
713
+ words.forEach((wd, i) => {
714
+ const L = layout(ctx, [T(wd)], 36, x, by);
715
+ const a = act(i), dim = sm(X.loop[1], X.loop[1] + 0.3, t);
716
+ const col = mixc(mixc(C.white, C.grey, dim), C.yellow, a);
717
+ drawTex(ctx, L, { p: cl(lp * 1.4 - i * 0.2), alpha: loopA, col, scale: 1 + 0.08 * a, ox: L.cx, oy: by - 12 });
718
+ pos.push([x, x + ws[i]]);
719
+ x += ws[i] + gap;
720
+ });
721
+ for (let i = 0; i < 2; i++) arrow(ctx, pos[i][1] + 16, by - 12, pos[i + 1][0] - 16, by - 12, C.white, 2.5, sm(X.loop[0] + 0.15 + i * 0.15, X.loop[0] + 0.45 + i * 0.15, t), 13, loopA * 0.85);
722
+ // loop-back arc under the row: Adjust → Guess
723
+ const arc = arcPts(pos[2][0] + ws[2] / 2, by + 14, pos[0][0] + ws[0] / 2, by + 14, -0.09, 40);
724
+ const ap2 = sm(X.loop[1] - 0.1, X.loop[1] + 0.35, t);
725
+ curvedArrow(ctx, arc, C.grey, 2.5, ap2, 13, loopA);
726
+ const lf = seg(X.loopFlash[0], X.loopFlash[1], t);
727
+ if (lf > 0 && lf < 1) flash(ctx, arc, SM(lf), C.yellow, 4, 0.35, loopA);
728
+ ctx.restore();
729
+ }
730
+
731
+ // takeaway: More examples → better guesses
732
+ const tp = seg(X.take[0], X.take[1], t);
733
+ if (tp > 0) {
734
+ ctx.font = fnt(56);
735
+ const a = layout(ctx, [T('More '), T('examples', { c: C.blue })], 56, 0, 0), b = layout(ctx, [T('better guesses', { c: C.green })], 56, 0, 0);
736
+ const gap = 110, total = a.w + gap + b.w, x0 = 640 - total / 2, y = 470;
737
+ const A2 = layout(ctx, [T('More '), T('examples', { c: C.blue })], 56, x0, y), B2 = layout(ctx, [T('better guesses', { c: C.green })], 56, x0 + a.w + gap, y);
738
+ drawTex(ctx, A2, { p: cl(tp * 1.8) });
739
+ arrow(ctx, A2.x1 + 18, y - 18, B2.x0 - 18, y - 18, C.white, 3.5, sm(0.35, 0.6, tp), 20);
740
+ drawTex(ctx, B2, { p: cl(tp * 1.8 - 0.8) });
741
+ // tiny equation underneath
742
+ const sub = layout(ctx, [T('examples', { it: true, c: C.blue }), T(' ↑ ⟹ '), T('L', { it: true }), T('('), T('w', { it: true }), T(')'), T(' ↓ ⟹ '), T('accuracy', { it: true, c: C.green }), T(' ↑')], 38, 640, 565, 'center');
743
+ drawTex(ctx, sub, { p: seg(X.sub[0], X.sub[1], t), col: (g) => (g.c === C.white ? C.greyL : g.c) });
744
+ }
745
+ }
746
+
747
+ // =====================================================================================================
748
+ // SOUND: gentle, warm and sparse, like the soft score under a math explainer. Timings come from X.
749
+ // =====================================================================================================
750
+ function explainerSound(k) {
751
+ const D = X.D;
752
+ // muted pluck: a soft triangle with a quick low-passed decay, tuned low
753
+ const pluck = (t, f, g = 1, o = {}) => {
754
+ k.tone(t, { f, type: 'triangle', dur: 0.55, gain: 0.1 * g, a: 0.004, filter: 'lowpass', f2: 1300, verb: 0.3, pan: o.pan || 0, minor: o.minor });
755
+ k.tone(t, { f: k.hz(f) * 2, dur: 0.22, gain: 0.025 * g, a: 0.003, verb: 0.25, pan: o.pan || 0, minor: o.minor });
756
+ };
757
+ // soft tick for glyph writing / counters (low band-passed noise, no ping)
758
+ const tick = (t, g = 1, f = 1300, pan = 0) => k.noise(t, { dur: 0.02, filter: 'bandpass', f, q: 2.2, gain: 0.16 * g, a: 0.002, pan, minor: true });
759
+ // pencil-soft write: a few ticks across the write duration
760
+ const write = (t0, t1, n, g = 1, pan = 0) => k.withMinor(() => { for (let i = 0; i < n; i++) tick(t0 + (t1 - t0) * (i + 0.3) / n, g * (0.7 + 0.3 * ((i * 7) % 3) / 2), 1100 + ((i * 5) % 4) * 90, pan); });
761
+ // airy swish for Transforms: band-passed pink noise, slow attack, low top
762
+ const swish = (t, dur, g = 1, pan = 0, minor) => k.noise(t, { dur, color: 'pink', filter: 'bandpass', f: [[0, 300], [dur * 0.55, 1300], [dur, 500]], q: 0.7, gain: 0.13 * g, a: dur * 0.5, verb: 0.25, pan, minor });
763
+ const counter = (val, a, b, gap, g, f) => { let last = -1, prev = val(a); for (let t = a; t <= b; t += 0.002) { const v = val(t); if (v !== prev && t - last >= gap) { tick(t, g, f, -0.3); last = t; } prev = v; } };
764
+
765
+ // ---- quiet warm pad underneath (D major-ish, resolving to D under the takeaway)
766
+ k.music('pad', 0, 14.4, { bpm: 60, gain: 0.45, chords: [['D3', 'A3', 'C#4', 'F#4'], ['B2', 'F#3', 'A3', 'D4'], ['G2', 'D3', 'F#3', 'B3'], ['A2', 'E3', 'G3', 'C#4']] });
767
+ k.music('pad', 14.4, D, { bpm: 60, gain: 0.45, chords: [['D3', 'A3', 'D4', 'F#4']] });
768
+
769
+ // ---- beat 1: title written, then glides to the header
770
+ pluck(X.title[0] + 0.02, 'D4', 0.9);
771
+ write(X.title[0], X.title[1], 6, 0.9);
772
+ swish(X.toHeader[0], X.toHeader[1] - X.toHeader[0] + 0.1, 1.0);
773
+
774
+ // ---- beat 2: network created, examples stream in, counter
775
+ k.withMinor(() => [0, 1, 2, 3].forEach((l) => pluck(X.net[0] + l * 0.18 + 0.15, ['A3', 'D4', 'E4', 'F#4'][l], 0.55, { pan: -0.4 + l * 0.25 })));
776
+ k.noise(X.edges[0], { dur: X.edges[1] - X.edges[0], color: 'pink', filter: 'bandpass', f: [[0, 500], [0.9, 900]], q: 0.8, gain: 0.05, a: 0.3, minor: true });
777
+ write(X.outLbl[0], X.outLbl[1], 3, 0.8, 0.5);
778
+ X.fly.forEach((f, i) => { if (i < 3) pluck(X.q0 + i * 0.15 + 0.05, ['F#3', 'A3', 'D4'][i], 0.45, { pan: -0.6, minor: true }); swish(f, X.flyDur, 0.45, -0.3, true); });
779
+ counter((t) => Math.round(1e6 * Math.pow(seg(X.count[0], X.count[1], t), 2.4) / 4000), X.count[0] + 0.05, X.count[1], 0.09, 0.9, 1250);
780
+ pluck(X.count[1], 'A4', 0.8, { pan: -0.4 });
781
+
782
+ // ---- beat 3: guess, check, adjust
783
+ swish(X.dataOut[0], 0.4, 0.6, -0.5, true);
784
+ write(X.loop[0], X.loop[1], 4, 0.8);
785
+ pluck(X.test[0] + 0.1, 'D4', 0.6, { pan: -0.5, minor: true });
786
+ swish(X.testFly[0], X.testFly[1] - X.testFly[0], 0.6, -0.4);
787
+ // forward pass: a soft rising three-note figure as each layer lights
788
+ ['D4', 'F#4', 'A4'].forEach((n, i) => pluck(X.pass1 + i * X.layerDur * 0.85 + X.layerDur * 0.7, n, 0.6, { pan: -0.2 + i * 0.2, minor: true }));
789
+ pluck(X.guessQ[0] + 0.05, 'B4', 0.8, { pan: 0.4 }); // "dog?"
790
+ // wrong: a low, soft minor fall (no buzzer)
791
+ k.tone(X.check, { f: 'F3', type: 'triangle', dur: 0.5, gain: 0.14, a: 0.01, filter: 'lowpass', f2: 900, verb: 0.3, pan: 0.4 });
792
+ k.tone(X.check + 0.16, { f: 'C#3', type: 'triangle', dur: 0.8, gain: 0.14, a: 0.01, filter: 'lowpass', f2: 800, verb: 0.35, pan: 0.4 });
793
+ k.noise(X.rect[0], { dur: X.rect[1] - X.rect[0], filter: 'bandpass', f: [[0, 600], [0.35, 1100]], q: 1.2, gain: 0.05, a: 0.1, pan: 0.4, minor: true });
794
+ swish(X.tagMorph[0], 0.4, 0.6, -0.5); // "?" → "cat"
795
+ // error flowing back + camera pan
796
+ k.tone(X.back, { f: [[0, 520], [0.75, 190]], type: 'sine', dur: 0.85, gain: 0.07, a: 0.2, hold: 0.2, filter: 'lowpass', f2: 900, verb: 0.3 });
797
+ swish(X.pan[0], X.pan[1] - X.pan[0], 0.9, 0.3);
798
+ write(X.lossAxes[0] + 0.3, X.lossVal[1], 3, 0.7, 0.4);
799
+ // gradient steps: two soft descending plucks
800
+ pluck(X.steps[0][1] - 0.05, 'A3', 0.7, { pan: 0.4 }); pluck(X.steps[1][1] - 0.05, 'F#3', 0.7, { pan: 0.4 });
801
+ k.noise(X.reweight[0], { dur: X.reweight[1] - X.reweight[0], color: 'pink', filter: 'bandpass', f: [[0, 400], [0.9, 750]], q: 1, gain: 0.05, a: 0.4, minor: true });
802
+ // second pass + correct: warm rising major third pair
803
+ ['D4', 'F#4', 'A4'].forEach((n, i) => pluck(X.pass2 + i * X.layerDur2 * 0.85 + 0.05, n, 0.45, { minor: true }));
804
+ pluck(X.fix[0] + 0.05, 'D4', 0.9, { pan: 0.4 }); pluck(X.fix[0] + 0.15, 'F#4', 0.85, { pan: 0.4 }); pluck(X.tick[0] + 0.1, 'A4', 0.8, { pan: 0.4 });
805
+
806
+ // ---- beat 4: camera move, relabel, accuracy climbs, the 97% moment
807
+ swish(X.cam2[0], X.cam2[1] - X.cam2[0], 1.0);
808
+ swish(X.relabel[0], 0.45, 0.5, 0.2, true);
809
+ counter((t) => Math.round(ACC(5 * sm(X.acc[0], X.acc[1], t))), X.acc[0] + 0.05, X.acc[1], 0.085, 0.85, 1200);
810
+ swish(X.hero[0], X.hero[1] - X.hero[0] + 0.05, 0.9, 0.3);
811
+ // 97%: low warm tone + gentle chord
812
+ k.tone(X.ind[0], { f: 'D2', type: 'sine', dur: 2.0, gain: 0.3, a: 0.02, verb: 0.2 });
813
+ k.tone(X.ind[0], { f: 'D3', type: 'triangle', dur: 1.6, gain: 0.08, a: 0.02, filter: 'lowpass', f2: 700, verb: 0.3 });
814
+ ['A3', 'D4', 'F#4', 'A4'].forEach((n, i) => k.tone(X.ind[0] + 0.02 + i * 0.05, { f: n, type: 'triangle', dur: 1.8, gain: 0.07, a: 0.02, filter: 'lowpass', f2: 1500, verb: 0.45, pan: (i - 1.5) * 0.3 }));
815
+ k.noise(X.accFlash[0], { dur: 0.5, color: 'pink', filter: 'bandpass', f: [[0, 500], [0.5, 1200]], q: 1, gain: 0.04, a: 0.2, minor: true });
816
+
817
+ // ---- beat 5: chart clears, 97% moves up, takeaway written, resolving chord
818
+ swish(X.chartOut[0], 0.5, 0.7, -0.3);
819
+ write(X.take[0], X.take[1], 6, 0.8);
820
+ ['D3', 'A3', 'D4', 'F#4', 'A4'].forEach((n, i) => k.tone(X.take[0] + 0.25 + i * 0.06, { f: n, type: i ? 'sine' : 'triangle', dur: 2.2, gain: 0.075, a: 0.03, verb: 0.5, pan: (i - 2) * 0.22 }));
821
+ k.tone(X.take[0] + 0.25, { f: 'D2', dur: 2.2, gain: 0.16, a: 0.04 });
822
+ }
823
+
824
+ registerStyle({
825
+ id: 'math-anim',
826
+ name: 'Manim-Style Math',
827
+ category: 'Popular Explainer Looks',
828
+ description: 'The math-explainer look of Manim, the open-source library behind 3Blue1Brown: pure black, crisp anti-aliased vector lines, a restrained palette of Manim blue, teal, yellow, red and green, LaTeX-like serif math with italic variables, axes with tick marks, curves, arrows, braces and surrounding rectangles.',
829
+ motion: 'Manim\'s own vocabulary on a smooth sigmoid ease: equations Write on (glyph outlines trace, then fill), axes and curves Create, a dot slides down the graph in gradient-descent hops, then a SurroundingRectangle draws round the key term and it Indicates with a yellow pulse.',
830
+ duration: 6.8,
831
+ frameT: 6.75,
832
+ fonts: ['400 52px "STIX Two Text"', 'italic 400 52px "STIX Two Text"', '600 52px "STIX Two Text"'],
833
+ readsPixels: false,
834
+ draw: drawStill,
835
+ explainerDuration: X.D,
836
+ explainerNote: 'One MovingCameraScene: the question Writes on and Transforms into the header, a neural net Creates (edges blue/red by weight sign), pixel pictures fly into the input neurons as a counter climbs, a forward pass runs as ShowPassingFlash, the wrong "dog?" gets a red SurroundingRectangle, the camera pans to a loss curve where a dot descends while edges re-colour, then the axes relabel to accuracy, the curve climbs and the number Transforms into a 97% that Indicates.',
837
+ explainer,
838
+ explainerSound,
839
+ });
840
+ }