@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,1126 @@
1
+ {
2
+ // =====================================================================================================
3
+ // Illuminated Manuscript: a late-medieval Book of Hours folio. Warm vellum with mottling, follicle specks
4
+ // and show-through; drypoint ruling and pricking; Grenze Gotisch textura in iron-gall ink with vermilion
5
+ // rubrics; raised, burnished gold leaf on red bole that catches a moving glint; lapis, vermilion, rose and
6
+ // malachite pigments with white-lead filigree; ivy-leaf rinceaux borders with gold bezants; drolleries.
7
+ // =====================================================================================================
8
+ const C = {
9
+ vel: [234, 217, 180],
10
+ ink: '#2b1a0f', inkWet: '#100906',
11
+ verm: '#c63b1c', vermD: '#8c2210',
12
+ lapis: '#233f8f', lapisD: '#14265c', lapisL: '#4d6fc2',
13
+ rose: '#b45a6c', roseD: '#7a2c3e',
14
+ mal: '#2f7d55', malD: '#1b4f35', malL: '#5ea67a',
15
+ ochre: '#c8994f', ochreD: '#8e6230', cream: '#efe3c6', white: '#f8f1e2',
16
+ };
17
+ const TAU = Math.PI * 2;
18
+ const cl = (v, a = 0, b = 1) => (v < a ? a : v > b ? b : v);
19
+ const win = (t, a, b) => cl((t - a) / (b - a));
20
+ const ez = (u) => H.ease.inOut(cl(u));
21
+ const eo = (u) => H.ease.out(cl(u));
22
+ const lerp = (a, b, u) => a + (b - a) * u;
23
+ const FONT = {
24
+ bl: (px) => `400 ${px}px "Grenze Gotisch"`, blb: (px) => `700 ${px}px "Grenze Gotisch"`,
25
+ fell: (px) => `400 ${px}px "IM Fell English"`, felli: (px) => `italic 400 ${px}px "IM Fell English"`,
26
+ frak: (px) => `400 ${px}px "UnifrakturMaguntia"`,
27
+ };
28
+
29
+ // ---------------------------------------------------------------- cached textures
30
+ let VEL = null, GT = null, PT = null;
31
+ function vellum() {
32
+ if (VEL) return VEL;
33
+ const W = 1280, Hh = 720, w = 640, h = 360;
34
+ const sm = H.layer(w, h), sc = sm.getContext('2d'), img = sc.createImageData(w, h), d = img.data;
35
+ const nz = H.makeNoise(41), nz2 = H.makeNoise(97);
36
+ for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) {
37
+ const m = nz.fbm2(x * 0.006, y * 0.009, 4);
38
+ const f = nz2.fbm2(x * 0.035, y * 0.06, 3);
39
+ const ex = Math.min(x, w - x) / w, ey = Math.min(y, h - y) / h, edge = Math.pow(1 - cl(Math.min(ex * 7, ey * 6)), 2);
40
+ const cock = Math.sin(x * 0.014 + nz.n2(x * 0.004, y * 0.005) * 3) * Math.sin(y * 0.01 + 1.3);
41
+ const st = cl(nz2.fbm2(x * 0.005 + 9, y * 0.006, 3) * 1.8, -1, 1);
42
+ const L = 1 + m * 0.075 + f * 0.03 + cock * 0.018 - edge * 0.13;
43
+ const o = (y * w + x) * 4;
44
+ d[o] = C.vel[0] * L + st * 5; d[o + 1] = C.vel[1] * L + st * 1; d[o + 2] = C.vel[2] * L - st * 9 - edge * 14; d[o + 3] = 255;
45
+ }
46
+ sc.putImageData(img, 0, 0);
47
+ const c = H.layer(W, Hh), x = c.getContext('2d');
48
+ x.imageSmoothingQuality = 'high'; x.drawImage(sm, 0, 0, W, Hh);
49
+ const r = H.rng(5);
50
+ for (let i = 0; i < 3200; i++) { x.fillStyle = `rgba(${95 + r() * 40 | 0},${62 + r() * 30 | 0},36,${0.04 + r() * 0.16})`; x.fillRect(r() * W, r() * Hh, 0.6 + r() * 1.3, 0.6 + r() * 1.1); }
51
+ for (let i = 0; i < 90; i++) { // hair follicles, in little triads
52
+ const cx = r() * W, cy = r() * Hh; x.fillStyle = 'rgba(85,58,34,0.25)';
53
+ for (let j = 0; j < 3; j++) { x.beginPath(); x.arc(cx + r() * 4, cy + r() * 4, 0.7 + r() * 0.4, 0, TAU); x.fill(); }
54
+ }
55
+ for (let i = 0; i < 26; i++) { // abraded / scraped patches
56
+ const cx = r() * W, cy = r() * Hh, rr = 20 + r() * 60, g = x.createRadialGradient(cx, cy, 0, cx, cy, rr);
57
+ const lighter = r() < 0.5; g.addColorStop(0, lighter ? 'rgba(250,240,215,0.18)' : 'rgba(150,110,60,0.07)'); g.addColorStop(1, 'rgba(0,0,0,0)');
58
+ x.fillStyle = g; x.fillRect(cx - rr, cy - rr, rr * 2, rr * 2);
59
+ }
60
+ // show-through of the text on the other side of the leaf (mirrored ghost)
61
+ x.save(); x.translate(W, 0); x.scale(-1, 1); x.filter = 'blur(1.2px)'; x.fillStyle = 'rgba(70,44,24,0.02)'; x.font = FONT.frak(30);
62
+ const ghost = 'Domine labia mea aperies et os meum annuntiabit laudem tuam deus in adiutorium meum intende domine ad adiuvandum me festina gloria patri et filio';
63
+ for (let i = 0; i < 13; i++) x.fillText(ghost.slice((i * 11) % 40), 150, 128 + i * 44);
64
+ x.restore();
65
+ VEL = c; return c;
66
+ }
67
+ function textures() {
68
+ if (GT) return;
69
+ const r = H.rng(77), nz = H.makeNoise(78);
70
+ GT = H.layer(160, 160); let g = GT.getContext('2d');
71
+ const im = g.createImageData(160, 160);
72
+ for (let y = 0; y < 160; y++) for (let x = 0; x < 160; x++) {
73
+ const v = 228 + nz.fbm2(x * 0.06, y * 0.06, 3) * 40 + (r() - 0.5) * 22, o = (y * 160 + x) * 4;
74
+ im.data[o] = v; im.data[o + 1] = v * 0.96; im.data[o + 2] = v * 0.88; im.data[o + 3] = 255;
75
+ }
76
+ g.putImageData(im, 0, 0);
77
+ g.strokeStyle = 'rgba(110,70,25,0.45)'; g.lineWidth = 0.7;
78
+ for (let k = 0; k < 9; k++) { let px = r() * 160, py = r() * 160, a = r() * TAU; g.beginPath(); g.moveTo(px, py); for (let i = 0; i < 12; i++) { a += (r() - 0.5) * 1.2; px += Math.cos(a) * 5; py += Math.sin(a) * 5; g.lineTo(px, py); } g.stroke(); }
79
+ PT = H.layer(128, 128); g = PT.getContext('2d');
80
+ const im2 = g.createImageData(128, 128);
81
+ for (let y = 0; y < 128; y++) for (let x = 0; x < 128; x++) {
82
+ const v = 236 + nz.fbm2(x * 0.09 + 5, y * 0.09, 3) * 26 + (r() < 0.06 ? -60 * r() : (r() - 0.5) * 16), o = (y * 128 + x) * 4;
83
+ im2.data[o] = v; im2.data[o + 1] = v; im2.data[o + 2] = v; im2.data[o + 3] = 255;
84
+ }
85
+ g.putImageData(im2, 0, 0);
86
+ }
87
+ const pat = (ctx, k) => { textures(); const key = '__ill' + k; if (!ctx[key]) ctx[key] = ctx.createPattern(k === 'g' ? GT : PT, 'repeat'); return ctx[key]; };
88
+
89
+ // ---------------------------------------------------------------- gold: one diagonal gradient per frame, with a burnish glint
90
+ // Burnished leaf has strong specular contrast: deep brown-gold reflections next to near-white highlights.
91
+ // The ramp is sampled along a short, irregular period so that every gilt object crosses at least one bright band.
92
+ const GRAMP = [[0, [104, 64, 16]], [0.3, [162, 108, 32]], [0.56, [208, 154, 52]], [0.8, [238, 198, 98]], [1, [253, 230, 152]]];
93
+ const ramp = (v) => { v = cl(v); for (let i = 1; i < GRAMP.length; i++) if (v <= GRAMP[i][0]) { const a = GRAMP[i - 1], b = GRAMP[i]; return H.mix(a[1], b[1], (v - a[0]) / (b[0] - a[0])); } return GRAMP[GRAMP.length - 1][1]; };
94
+ const baseGold = (u) => ramp(0.52 + 0.3 * Math.sin(u * TAU * 8.6 + 0.5) + 0.16 * Math.sin(u * TAU * 21.3 + 2.1) + 0.06 * Math.sin(u * TAU * 47 + 0.7));
95
+ const GPRE = []; for (let i = 0; i <= 56; i++) GPRE.push([i / 56, baseGold(i / 56)]);
96
+ function setGold(ctx, p, boost) {
97
+ const g = ctx.createLinearGradient(0, 0, 1280, 720), us = GPRE.map((q) => q[0]);
98
+ for (const o of [-0.05, -0.032, -0.02, -0.012, -0.006, 0, 0.006, 0.012, 0.02, 0.032, 0.05]) { const u = p + o; if (u > 0 && u < 1) us.push(u); }
99
+ us.sort((a, b) => a - b);
100
+ for (const u of us) { const b = Math.exp(-Math.pow((u - p) / 0.015, 2)) * boost * 1.3 + Math.exp(-Math.pow((u - p) / 0.05, 2)) * boost * 0.25, m = H.mix(baseGold(u), [255, 250, 222], cl(b)); g.addColorStop(u, `rgb(${m[0] | 0},${m[1] | 0},${m[2] | 0})`); }
101
+ ctx.__gold = g;
102
+ }
103
+ // bounding box of a path function (in the caller's user space), by replaying it into a tiny recorder
104
+ function pathBox(path) {
105
+ let m = [1, 0, 0, 1, 0, 0], x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity; const st = [];
106
+ const P = (x, y) => { const X = m[0] * x + m[2] * y + m[4], Y = m[1] * x + m[3] * y + m[5]; if (X < x0) x0 = X; if (X > x1) x1 = X; if (Y < y0) y0 = Y; if (Y > y1) y1 = Y; };
107
+ const arcPts = (x, y, rx, ry, rot, a0, a1, ccw) => {
108
+ let span = ccw ? -((((a0 - a1) % TAU) + TAU) % TAU) : ((((a1 - a0) % TAU) + TAU) % TAU);
109
+ if (Math.abs(a1 - a0) >= TAU - 1e-9) span = ccw ? -TAU : TAU;
110
+ const cr = Math.cos(rot), sr = Math.sin(rot);
111
+ for (let i = 0; i <= 16; i++) { const a = a0 + span * i / 16, ex = Math.cos(a) * rx, ey = Math.sin(a) * ry; P(x + ex * cr - ey * sr, y + ex * sr + ey * cr); }
112
+ };
113
+ const R = {
114
+ moveTo: P, lineTo: P, quadraticCurveTo(a, b, x, y) { P(a, b); P(x, y); }, bezierCurveTo(a, b, c, d, x, y) { P(a, b); P(c, d); P(x, y); },
115
+ rect(x, y, w, h) { P(x, y); P(x + w, y + h); P(x + w, y); P(x, y + h); },
116
+ arc(x, y, r, a0, a1, ccw) { arcPts(x, y, r, r, 0, a0, a1, ccw); }, ellipse(x, y, rx, ry, rot, a0, a1, ccw) { arcPts(x, y, rx, ry, rot, a0, a1, ccw); },
117
+ save() { st.push(m.slice()); }, restore() { m = st.pop() || m; },
118
+ translate(x, y) { m = [m[0], m[1], m[2], m[3], m[4] + m[0] * x + m[2] * y, m[5] + m[1] * x + m[3] * y]; },
119
+ rotate(a) { const c = Math.cos(a), s = Math.sin(a); m = [m[0] * c + m[2] * s, m[1] * c + m[3] * s, -m[0] * s + m[2] * c, -m[1] * s + m[3] * c, m[4], m[5]]; },
120
+ scale(sx, sy) { m = [m[0] * sx, m[1] * sx, m[2] * sy, m[3] * sy, m[4], m[5]]; },
121
+ };
122
+ const noop = () => {};
123
+ path(new Proxy(R, { get: (o, k) => (k in o ? o[k] : noop), set: () => true }));
124
+ return x1 >= x0 ? [x0, y0, x1 - x0, y1 - y0] : null;
125
+ }
126
+ // raised gesso under the leaf: the gilt piece is a cushion lit from the upper-left. Expects the clip set to the shape.
127
+ function gessoDome(ctx, path, o) {
128
+ const bb = pathBox(path); if (!bb) return;
129
+ const [bx, by, bw, bh] = bb; if (Math.max(bw, bh) < 9) return; // tiny bosses already carry their own highlight dot
130
+ ctx.save();
131
+ ctx.globalCompositeOperation = 'screen';
132
+ if (o.ring) { // an annular rim: a torus-like cushion, brightest along its crest and on the upper-left
133
+ const [rcx, rcy, ri, ro] = o.ring, g = ctx.createRadialGradient(rcx, rcy, ri, rcx, rcy, ro);
134
+ g.addColorStop(0, 'rgba(255,236,170,0)'); g.addColorStop(0.42, 'rgba(255,236,170,0.38)'); g.addColorStop(1, 'rgba(255,236,170,0)');
135
+ ctx.fillStyle = g; ctx.fillRect(bx - 2, by - 2, bw + 4, bh + 4);
136
+ const d = ctx.createLinearGradient(rcx - ro, rcy - ro, rcx + ro, rcy + ro);
137
+ d.addColorStop(0, 'rgba(255,238,180,0.34)'); d.addColorStop(0.45, 'rgba(255,238,180,0)');
138
+ ctx.fillStyle = d; ctx.fillRect(bx - 2, by - 2, bw + 4, bh + 4);
139
+ ctx.globalCompositeOperation = 'multiply';
140
+ const s2 = ctx.createLinearGradient(rcx - ro, rcy - ro, rcx + ro, rcy + ro);
141
+ s2.addColorStop(0.55, 'rgba(255,255,255,0)'); s2.addColorStop(1, 'rgba(110,58,14,0.55)');
142
+ ctx.fillStyle = s2; ctx.fillRect(bx - 2, by - 2, bw + 4, bh + 4);
143
+ } else if (bw > bh * 2.4 || bh > bw * 2.4) { // a long bar: rounded cross-section, light on its upper/left flank
144
+ const v = bh > bw, g = v ? ctx.createLinearGradient(bx, 0, bx + bw, 0) : ctx.createLinearGradient(0, by, 0, by + bh);
145
+ g.addColorStop(0, 'rgba(255,236,170,0.12)'); g.addColorStop(0.3, 'rgba(255,238,175,0.5)'); g.addColorStop(0.62, 'rgba(255,236,170,0)');
146
+ ctx.fillStyle = g; ctx.fillRect(bx - 1, by - 1, bw + 2, bh + 2);
147
+ ctx.globalCompositeOperation = 'multiply';
148
+ const d = v ? ctx.createLinearGradient(bx, 0, bx + bw, 0) : ctx.createLinearGradient(0, by, 0, by + bh);
149
+ d.addColorStop(0.6, 'rgba(255,255,255,0)'); d.addColorStop(1, 'rgba(110,58,14,0.6)');
150
+ ctx.fillStyle = d; ctx.fillRect(bx - 1, by - 1, bw + 2, bh + 2);
151
+ } else { // a domed boss
152
+ const cx = bx + bw / 2, cy = by + bh / 2;
153
+ ctx.translate(cx, cy); ctx.scale(bw / 2, bh / 2);
154
+ const g = ctx.createRadialGradient(-0.38, -0.42, 0, -0.2, -0.22, 1.25);
155
+ g.addColorStop(0, 'rgba(255,240,185,0.55)'); g.addColorStop(0.45, 'rgba(255,236,170,0.15)'); g.addColorStop(1, 'rgba(255,236,170,0)');
156
+ ctx.fillStyle = g; ctx.fillRect(-1.1, -1.1, 2.2, 2.2);
157
+ ctx.globalCompositeOperation = 'multiply';
158
+ const d = ctx.createRadialGradient(-0.3, -0.34, 0.5, -0.15, -0.18, 1.45);
159
+ d.addColorStop(0, 'rgba(255,255,255,0)'); d.addColorStop(1, 'rgba(110,58,14,0.6)');
160
+ ctx.fillStyle = d; ctx.fillRect(-1.1, -1.1, 2.2, 2.2);
161
+ }
162
+ ctx.restore();
163
+ // inner dark rim where the leaf turns down over the gesso edge
164
+ path(ctx); ctx.globalCompositeOperation = 'source-over'; ctx.lineWidth = Math.min(3, Math.max(1.2, Math.min(bw, bh) * 0.22)); ctx.strokeStyle = 'rgba(80,40,10,0.35)'; ctx.stroke();
165
+ }
166
+ // raised gilding: bole and cast shadow, gold, burnish texture, gesso dome, black outline
167
+ function gilt(ctx, path, o = {}) {
168
+ ctx.save();
169
+ path(ctx);
170
+ ctx.shadowColor = 'rgba(60,28,6,0.55)'; ctx.shadowOffsetX = o.sh == null ? 1.3 : o.sh; ctx.shadowOffsetY = o.sh == null ? 1.9 : o.sh * 1.4; ctx.shadowBlur = 2;
171
+ ctx.fillStyle = '#7c3818'; ctx.fill();
172
+ ctx.shadowColor = 'transparent';
173
+ ctx.fillStyle = ctx.__gold; ctx.fill();
174
+ ctx.save(); ctx.clip();
175
+ if (o.tex !== false) { ctx.save(); ctx.globalCompositeOperation = 'multiply'; ctx.globalAlpha = 0.45; ctx.fillStyle = pat(ctx, 'g'); ctx.fill(); ctx.restore(); }
176
+ if (o.dome !== false) gessoDome(ctx, path, o);
177
+ ctx.restore();
178
+ if (o.line !== false) { path(ctx); ctx.lineWidth = o.lw || 1; ctx.strokeStyle = 'rgba(38,22,8,0.9)'; ctx.stroke(); }
179
+ ctx.restore();
180
+ }
181
+ // gold lettering on raised gesso: the glyphs themselves mask a top-lit sheen, a shaded foot and a bevel
182
+ function goldText(ctx, str, x0, y, px, lw) {
183
+ ctx.fillStyle = ctx.__gold; ctx.fillText(str, x0, y);
184
+ ctx.save();
185
+ ctx.globalCompositeOperation = 'overlay'; ctx.fillStyle = 'rgba(236,168,40,0.5)'; ctx.fillText(str, x0, y); // keep it rich, not khaki
186
+ ctx.globalCompositeOperation = 'screen';
187
+ const sh = ctx.createLinearGradient(0, y - px * 0.78, 0, y - px * 0.18);
188
+ sh.addColorStop(0, 'rgba(255,238,175,0.5)'); sh.addColorStop(0.45, 'rgba(255,236,170,0.12)'); sh.addColorStop(1, 'rgba(255,236,170,0)');
189
+ ctx.fillStyle = sh; ctx.fillText(str, x0, y);
190
+ ctx.globalCompositeOperation = 'multiply';
191
+ const ft = ctx.createLinearGradient(0, y - px * 0.3, 0, y + px * 0.08);
192
+ ft.addColorStop(0, 'rgba(255,255,255,0)'); ft.addColorStop(1, 'rgba(150,80,14,0.45)');
193
+ ctx.fillStyle = ft; ctx.fillText(str, x0, y);
194
+ const d = Math.max(0.8, px * 0.012);
195
+ ctx.fillStyle = 'rgba(140,80,22,0.4)'; ctx.fillText(str, x0 + d, y + d);
196
+ ctx.globalCompositeOperation = 'screen'; ctx.fillStyle = 'rgba(255,238,180,0.4)'; ctx.fillText(str, x0 - d, y - d);
197
+ ctx.restore();
198
+ ctx.lineWidth = lw; ctx.strokeStyle = 'rgba(36,20,8,0.95)'; ctx.strokeText(str, x0, y);
199
+ }
200
+ // pigment: flat body colour, granulation, darker pooled edge, ink outline
201
+ function paint(ctx, path, color, o = {}) {
202
+ ctx.save(); path(ctx);
203
+ ctx.fillStyle = color; ctx.fill();
204
+ ctx.clip();
205
+ ctx.globalCompositeOperation = 'multiply'; ctx.globalAlpha = o.tex == null ? 0.6 : o.tex; ctx.fillStyle = pat(ctx, 'p'); ctx.fill();
206
+ ctx.globalAlpha = 0.3; ctx.strokeStyle = 'rgba(30,15,10,1)'; ctx.lineWidth = o.edgeW || 4; ctx.stroke();
207
+ ctx.restore();
208
+ if (o.ink) { ctx.save(); path(ctx); ctx.lineWidth = o.lw || 1.3; ctx.strokeStyle = C.ink; ctx.stroke(); ctx.restore(); }
209
+ }
210
+ function floodClip(ctx, x, y, r, seed = 1) {
211
+ ctx.beginPath();
212
+ for (let i = 0; i <= 40; i++) { const a = i / 40 * TAU, rr = Math.max(0.1, r * (1 + 0.09 * Math.sin(a * 3 + seed) + 0.05 * Math.sin(a * 7 + seed * 2.3))); i ? ctx.lineTo(x + Math.cos(a) * rr, y + Math.sin(a) * rr) : ctx.moveTo(x + Math.cos(a) * rr, y + Math.sin(a) * rr); }
213
+ ctx.closePath(); ctx.clip();
214
+ }
215
+ function sectorClip(ctx, x, y, r, a0, p) { ctx.beginPath(); ctx.moveTo(x, y); ctx.arc(x, y, r, a0, a0 + p * TAU); ctx.closePath(); ctx.clip(); }
216
+
217
+ // ---------------------------------------------------------------- the scribe's writing (and where the quill nib is)
218
+ let NIB = null, BASE = null;
219
+ function write(ctx, str, x, y, font, color, prog, align = 'left', o = {}) {
220
+ if (prog <= 0) return 0;
221
+ ctx.save(); ctx.font = font; ctx.textAlign = 'left'; ctx.textBaseline = 'alphabetic';
222
+ const w = ctx.measureText(str).width, x0 = align === 'center' ? x - w / 2 : align === 'right' ? x - w : x;
223
+ const px = parseFloat(/(\d+(?:\.\d+)?)px/.exec(font)[1]);
224
+ let rx = x0 + w;
225
+ if (prog < 1) {
226
+ const n = str.length * prog, k = Math.floor(n);
227
+ const a = ctx.measureText(str.slice(0, k)).width, b = ctx.measureText(str.slice(0, k + 1)).width;
228
+ rx = x0 + a + (b - a) * (n - k);
229
+ ctx.beginPath(); ctx.rect(x0 - px, y - px * 1.4, rx - x0 + px, px * 2.1); ctx.clip();
230
+ if (BASE && !o.noNib) { const m = BASE.inverse().multiply(ctx.getTransform()), q = m.transformPoint(new DOMPoint(rx, y - px * 0.28)); NIB = { x: q.x, y: q.y }; }
231
+ }
232
+ if (o.gold) {
233
+ ctx.fillStyle = '#6a3014'; ctx.fillText(str, x0 + 1.6, y + 2.2);
234
+ goldText(ctx, str, x0, y, px, o.lw || 1.3);
235
+ } else {
236
+ ctx.fillStyle = color; ctx.fillText(str, x0, y);
237
+ ctx.globalAlpha = 0.22; ctx.fillStyle = '#000'; ctx.fillText(str, x0 + 0.5, y + 0.4); // ink pooling on the down-strokes
238
+ if (prog < 1) { // the freshest letters are still wet: darker and glossier
239
+ ctx.globalAlpha = 0.55; ctx.beginPath(); ctx.rect(rx - px * 1.2, y - px * 1.4, px * 1.2, px * 2.1); ctx.clip();
240
+ ctx.fillStyle = C.inkWet; ctx.fillText(str, x0, y);
241
+ }
242
+ }
243
+ ctx.restore();
244
+ return w;
245
+ }
246
+ // a goose-quill held by the scribe, nib on the vellum
247
+ function quill(ctx, x, y, t) {
248
+ const a = -0.98 + Math.sin(t * 13) * 0.04, wob = Math.sin(t * 23) * 1.5;
249
+ const shape = (c) => {
250
+ c.beginPath(); c.moveTo(0, 0); c.lineTo(16, -2.2); c.lineTo(70, -4.2);
251
+ c.bezierCurveTo(130, -26, 230, -30, 330, -8); c.bezierCurveTo(250, 4, 150, 14, 70, 4.2); c.lineTo(16, 2.2); c.closePath();
252
+ };
253
+ ctx.save(); ctx.translate(x + wob, y);
254
+ ctx.save(); ctx.translate(18, 26); ctx.rotate(a); ctx.fillStyle = 'rgba(60,35,15,0.16)'; shape(ctx); ctx.fill(); ctx.restore();
255
+ ctx.rotate(a);
256
+ const g = ctx.createLinearGradient(0, -30, 0, 14); g.addColorStop(0, '#fbf7ee'); g.addColorStop(0.6, '#e6dccb'); g.addColorStop(1, '#b9ab93');
257
+ ctx.fillStyle = g; shape(ctx); ctx.fill(); ctx.strokeStyle = 'rgba(60,40,20,0.7)'; ctx.lineWidth = 1; ctx.stroke();
258
+ ctx.strokeStyle = 'rgba(120,100,80,0.45)'; ctx.lineWidth = 0.7;
259
+ for (let i = 80; i < 320; i += 7) { ctx.beginPath(); ctx.moveTo(i, -1); ctx.lineTo(i + 16, -18 * Math.sin((i - 70) / 260 * Math.PI) - 3); ctx.stroke(); ctx.beginPath(); ctx.moveTo(i, 1); ctx.lineTo(i + 12, 9 * Math.sin((i - 70) / 260 * Math.PI) + 2); ctx.stroke(); }
260
+ ctx.strokeStyle = '#a8916a'; ctx.lineWidth = 2; ctx.beginPath(); ctx.moveTo(10, 0); ctx.lineTo(320, -7); ctx.stroke();
261
+ ctx.fillStyle = '#1a0f08'; ctx.beginPath(); ctx.moveTo(0, 0); ctx.lineTo(15, -2.3); ctx.lineTo(15, 2.3); ctx.closePath(); ctx.fill();
262
+ ctx.restore();
263
+ }
264
+
265
+ // ---------------------------------------------------------------- ivy-leaf rinceaux, bezants
266
+ function leafPath(c, x, y, a, L) {
267
+ c.save(); c.translate(x, y); c.rotate(a);
268
+ c.beginPath(); c.moveTo(0, 0); c.bezierCurveTo(-0.2 * L, -0.62 * L, 0.5 * L, -0.62 * L, L, 0); c.bezierCurveTo(0.5 * L, 0.62 * L, -0.2 * L, 0.62 * L, 0, 0);
269
+ c.restore();
270
+ }
271
+ function bezant(ctx, x, y, r, s = 1) {
272
+ if (s <= 0) return;
273
+ gilt(ctx, (c) => { c.beginPath(); c.arc(x, y, r * s, 0, TAU); }, { tex: false, lw: 0.9 });
274
+ ctx.fillStyle = 'rgba(255,250,225,0.85)'; ctx.beginPath(); ctx.arc(x - r * 0.35 * s, y - r * 0.35 * s, r * 0.28 * s, 0, TAU); ctx.fill();
275
+ }
276
+ function leaf(ctx, x, y, a, L, col, s = 1) {
277
+ if (s <= 0) return;
278
+ const p = (c) => leafPath(c, x, y, a, L * s);
279
+ if (col === 'gold') gilt(ctx, p, { tex: false, lw: 0.9 });
280
+ else {
281
+ paint(ctx, p, col, { edgeW: 2.5, ink: true, lw: 0.9 });
282
+ ctx.save(); ctx.strokeStyle = 'rgba(250,245,230,0.8)'; ctx.lineWidth = 0.8; ctx.beginPath(); ctx.moveTo(x + Math.cos(a) * L * s * 0.15, y + Math.sin(a) * L * s * 0.15); ctx.lineTo(x + Math.cos(a) * L * s * 0.75, y + Math.sin(a) * L * s * 0.75); ctx.stroke(); ctx.restore();
283
+ }
284
+ }
285
+ function tendril(r, x, y, ang, len, curl) {
286
+ const pts = [[x, y]], n = Math.max(4, Math.round(len / 2.4)); let a = ang, px = x, py = y;
287
+ for (let i = 1; i <= n; i++) { const u = i / n; a += curl * (0.015 + 0.2 * u * u); px += Math.cos(a) * 2.4 * (1 - u * 0.45); py += Math.sin(a) * 2.4 * (1 - u * 0.45); pts.push([px, py]); }
288
+ const end = r() < 0.55 ? { k: 'b', r: 3.6 + r() * 1.4 } : { k: 'l', col: r.pick(['gold', 'gold', C.lapis, C.verm, C.mal, C.rose]), L: 11 + r() * 5 };
289
+ end.x = px; end.y = py; end.a = a + curl * 0.6;
290
+ return { pts, end };
291
+ }
292
+ const BORD = {};
293
+ function buildBorder(seed) {
294
+ if (BORD[seed]) return BORD[seed];
295
+ const r = H.rng(seed), stems = [], T = [];
296
+ const corner = []; for (let i = 0; i <= 30; i++) { const u = i / 30, a = Math.PI + u * 1.9; corner.push([60 + 30 + Math.cos(a) * 30 * (1 - u * 0.3) + u * 20, 44 + Math.sin(a) * 26 * (1 - u * 0.3) - 6]); }
297
+ const bot = []; for (let x = 60; x <= 1205; x += 4) bot.push([x, 688 + Math.sin(x * 0.03 + 1) * 5]);
298
+ stems.push({ pts: corner, s: 0 }, { pts: bot, s: 0.5 });
299
+ for (let y = 70, i = 0; y < 664; y += 26, i++) {
300
+ const left = i % 2 === 0, tilt = (r() - 0.5) * 0.9;
301
+ const t = tendril(r, left ? 54 : 66, y, left ? Math.PI + tilt : tilt, left ? 26 + r() * 14 : 22 + r() * 12, (r() < 0.5 ? 1 : -1));
302
+ t.s = (y - 44) / 632 * 0.5; T.push(t);
303
+ }
304
+ for (let x = 96, i = 0; x < 1195; x += 30, i++) {
305
+ const up = i % 2 === 0, y = 688 + Math.sin(x * 0.03 + 1) * 5;
306
+ const t = tendril(r, x, y, (up ? -Math.PI / 2 : Math.PI / 2) + (r() - 0.5) * 0.8, up ? 20 + r() * 8 : 12 + r() * 6, r() < 0.5 ? 1 : -1);
307
+ t.s = 0.5 + (x - 60) / 1140 * 0.48; T.push(t);
308
+ }
309
+ for (let k = 0; k < 4; k++) { const t = tendril(r, 70 + k * 14, 28 + k * 3, -0.4 + k * 0.5, 22, k % 2 ? 1 : -1); t.s = 0.02; T.push(t); }
310
+ return (BORD[seed] = { stems, T });
311
+ }
312
+ function polyPart(ctx, pts, p) {
313
+ const n = Math.floor((pts.length - 1) * p); if (n < 1) return;
314
+ ctx.beginPath(); ctx.moveTo(pts[0][0], pts[0][1]); for (let i = 1; i <= n; i++) ctx.lineTo(pts[i][0], pts[i][1]); ctx.stroke();
315
+ }
316
+ function bar(ctx, p) {
317
+ if (p <= 0) return;
318
+ const y0 = 44, y1 = 44 + 632 * eo(p);
319
+ gilt(ctx, (c) => { c.beginPath(); c.rect(53, y0, 14, y1 - y0); }, { lw: 0.9 });
320
+ for (let y = y0 + 4, i = 0; y < y1 - 6; y += 54, i++) {
321
+ const h = Math.min(46, y1 - 6 - y);
322
+ paint(ctx, (c) => { c.beginPath(); c.rect(56, y, 8, h); }, i % 2 ? C.rose : C.lapis, { edgeW: 2 });
323
+ ctx.strokeStyle = 'rgba(250,245,232,0.85)'; ctx.lineWidth = 0.8; ctx.beginPath();
324
+ for (let k = 0; k < h - 4; k += 6) { ctx.moveTo(57.5, y + k + 2); ctx.lineTo(62.5, y + k + 5); }
325
+ ctx.stroke();
326
+ }
327
+ if (p >= 1) { bezant(ctx, 60, 40, 6); bezant(ctx, 60, 680, 6); }
328
+ }
329
+ function border(ctx, seed, p) {
330
+ const B = buildBorder(seed);
331
+ bar(ctx, win(p, 0, 0.4));
332
+ ctx.save(); ctx.strokeStyle = C.ink; ctx.lineCap = 'round';
333
+ ctx.lineWidth = 1.2; for (const s of B.stems) polyPart(ctx, s.pts, win(p, s.s, s.s + 0.45));
334
+ ctx.lineWidth = 0.95; for (const t of B.T) polyPart(ctx, t.pts, win(p, t.s, t.s + 0.07));
335
+ ctx.restore();
336
+ for (const t of B.T) {
337
+ const s = eo(win(p, t.s + 0.06, t.s + 0.11)); if (s <= 0) continue;
338
+ const e = t.end;
339
+ if (e.k === 'b') {
340
+ bezant(ctx, e.x, e.y, e.r, s);
341
+ ctx.save(); ctx.strokeStyle = C.ink; ctx.lineWidth = 0.6; ctx.globalAlpha = s; // hairline whiskers
342
+ for (let k = 0; k < 3; k++) { const a = e.a + (k - 1) * 0.7, r0 = e.r + 1.5; ctx.beginPath(); ctx.moveTo(e.x + Math.cos(a) * r0, e.y + Math.sin(a) * r0); ctx.quadraticCurveTo(e.x + Math.cos(a + 0.3) * (r0 + 5), e.y + Math.sin(a + 0.3) * (r0 + 5), e.x + Math.cos(a) * (r0 + 9), e.y + Math.sin(a) * (r0 + 9)); ctx.stroke(); }
343
+ ctx.restore();
344
+ } else leaf(ctx, e.x, e.y, e.a, e.L, e.col, s);
345
+ }
346
+ }
347
+ // a small burst of tendrils around a point (an initial blooming into the margin)
348
+ const SPR = {};
349
+ function spray(ctx, x, y, p, seed, dirs) {
350
+ if (p <= 0) return;
351
+ const key = seed + ':' + dirs.join(',');
352
+ if (!SPR[key]) { const r = H.rng(seed); SPR[key] = dirs.map((a, i) => tendril(r, 0, 0, a, 30 + r() * 16, i % 2 ? 1 : -1)); }
353
+ ctx.save(); ctx.translate(x, y); ctx.strokeStyle = C.ink; ctx.lineWidth = 0.95; ctx.lineCap = 'round';
354
+ for (const t of SPR[key]) polyPart(ctx, t.pts, win(p, 0, 0.7));
355
+ for (const t of SPR[key]) { const s = eo(win(p, 0.6, 1)); const e = t.end; if (e.k === 'b') bezant(ctx, e.x, e.y, e.r, s); else leaf(ctx, e.x, e.y, e.a, e.L, e.col, s); }
356
+ ctx.restore();
357
+ }
358
+
359
+ // ---------------------------------------------------------------- the page: vellum, ruling, pricking, border
360
+ function pageBase(ctx, verso, ruleA, borderP, seed) {
361
+ ctx.save(); if (verso) { ctx.translate(1280, 0); ctx.scale(-1, 1); } ctx.drawImage(vellum(), 0, 0); ctx.restore();
362
+ if (ruleA > 0) {
363
+ ctx.save(); ctx.globalAlpha = ruleA; ctx.strokeStyle = 'rgba(150,108,72,0.2)'; ctx.lineWidth = 1;
364
+ ctx.beginPath();
365
+ for (let y = 132; y < 650; y += 44) { ctx.moveTo(108, y + 0.5); ctx.lineTo(1226, y + 0.5); }
366
+ for (const x of [104, 110, 1224, 1230]) { ctx.moveTo(x + 0.5, 18); ctx.lineTo(x + 0.5, 664); }
367
+ ctx.stroke();
368
+ for (let y = 132; y < 650; y += 44) { // pricking holes in the outer margin
369
+ ctx.fillStyle = 'rgba(70,45,25,0.55)'; ctx.beginPath(); ctx.ellipse(1254, y, 1.4, 1.1, 0.4, 0, TAU); ctx.fill();
370
+ ctx.fillStyle = 'rgba(255,248,228,0.5)'; ctx.beginPath(); ctx.arc(1254.6, y + 1.3, 1, 0, TAU); ctx.fill();
371
+ }
372
+ ctx.restore();
373
+ }
374
+ border(ctx, seed, borderP);
375
+ }
376
+
377
+ // ---------------------------------------------------------------- champ initial: gold letter on parted lapis/rose ground, white filigree
378
+ const FIL = {};
379
+ function champ(ctx, letter, x, y, s, t, t0, seed = 3) {
380
+ const gP = win(t, t0, t0 + 0.32), lP = win(t, t0 + 0.2, t0 + 0.5), fP = win(t, t0 + 0.32, t0 + 0.62);
381
+ if (gP <= 0) return;
382
+ const cx = x + s / 2, cy = y + s / 2;
383
+ ctx.save();
384
+ if (gP < 1) floodClip(ctx, cx, cy, s * 0.78 * eo(gP), seed);
385
+ paint(ctx, (c) => { c.beginPath(); c.moveTo(x, y); c.lineTo(x + s, y); c.lineTo(x + s, y + s); c.closePath(); }, C.lapis, { edgeW: s * 0.03 });
386
+ paint(ctx, (c) => { c.beginPath(); c.moveTo(x, y); c.lineTo(x, y + s); c.lineTo(x + s, y + s); c.closePath(); }, C.rose, { edgeW: s * 0.03 });
387
+ ctx.restore();
388
+ if (fP > 0) { // white-lead filigree: inset line, curls and dot triads
389
+ if (!FIL[seed]) { const r = H.rng(seed + 100), m = []; for (let i = 0; i < 26; i++) m.push([0.1 + r() * 0.8, 0.1 + r() * 0.8, r() * TAU, r() < 0.5]); FIL[seed] = m; }
390
+ ctx.save(); ctx.globalAlpha = fP; ctx.strokeStyle = 'rgba(252,248,236,0.9)'; ctx.fillStyle = 'rgba(252,248,236,0.9)'; ctx.lineWidth = Math.max(0.7, s * 0.006);
391
+ ctx.strokeRect(x + s * 0.04, y + s * 0.04, s * 0.92, s * 0.92);
392
+ for (const [u, v, a, curl] of FIL[seed]) {
393
+ const px = x + u * s, py = y + v * s, k = s * 0.035;
394
+ if (curl) { ctx.beginPath(); ctx.arc(px, py, k, a, a + 4.2); ctx.stroke(); }
395
+ else for (let j = 0; j < 3; j++) { ctx.beginPath(); ctx.arc(px + Math.cos(a + j * 2.1) * k * 0.6, py + Math.sin(a + j * 2.1) * k * 0.6, Math.max(0.8, s * 0.006), 0, TAU); ctx.fill(); }
396
+ }
397
+ ctx.restore();
398
+ }
399
+ ctx.save(); ctx.strokeStyle = C.ink; ctx.lineWidth = Math.max(1, s * 0.008); ctx.strokeRect(x, y, s, s); ctx.restore();
400
+ if (lP > 0) {
401
+ ctx.save(); ctx.globalAlpha = lP; ctx.font = FONT.fell(s * 0.84); ctx.textAlign = 'center'; ctx.textBaseline = 'alphabetic';
402
+ const by = y + s * 0.8;
403
+ ctx.fillStyle = '#5e2a10'; ctx.fillText(letter, cx + s * 0.012, by + s * 0.016);
404
+ ctx.textAlign = 'left'; const lx = cx - ctx.measureText(letter).width / 2;
405
+ goldText(ctx, letter, lx, by, s * 0.84, Math.max(1, s * 0.007));
406
+ ctx.restore();
407
+ }
408
+ }
409
+
410
+ // ---------------------------------------------------------------- figures: cat, dog, brazen head, hare-grotesque, snail
411
+ const lw = (u) => Math.max(1, u * 0.022);
412
+ const E = (c, x, y, rx, ry, a = 0) => { c.ellipse(x, y, rx, ry, a, 0, TAU); };
413
+ const FIG = {
414
+ cat(u) {
415
+ return {
416
+ fills: [
417
+ [(c) => { c.beginPath(); c.moveTo(-0.47 * u, -0.08 * u); c.quadraticCurveTo(-0.52 * u, -0.5 * u, -0.38 * u, -0.68 * u); c.quadraticCurveTo(-0.22 * u, -0.48 * u, -0.1 * u, -0.38 * u); c.closePath(); c.moveTo(0.47 * u, -0.08 * u); c.quadraticCurveTo(0.52 * u, -0.5 * u, 0.38 * u, -0.68 * u); c.quadraticCurveTo(0.22 * u, -0.48 * u, 0.1 * u, -0.38 * u); c.closePath(); }, C.ochre],
418
+ [(c) => { c.beginPath(); E(c, 0, 0.06 * u, 0.5 * u, 0.44 * u); }, C.ochre],
419
+ [(c) => { c.beginPath(); c.moveTo(-0.4 * u, -0.2 * u); c.lineTo(-0.37 * u, -0.55 * u); c.lineTo(-0.2 * u, -0.38 * u); c.closePath(); c.moveTo(0.4 * u, -0.2 * u); c.lineTo(0.37 * u, -0.55 * u); c.lineTo(0.2 * u, -0.38 * u); c.closePath(); }, C.rose],
420
+ [(c) => { c.beginPath(); E(c, -0.1 * u, 0.24 * u, 0.15 * u, 0.12 * u); E(c, 0.1 * u, 0.24 * u, 0.15 * u, 0.12 * u); }, C.cream],
421
+ [(c) => { c.beginPath(); for (const s of [-1, 1]) { c.moveTo(s * 0.32 * u, 0); c.quadraticCurveTo(s * 0.2 * u, -0.1 * u, s * 0.08 * u, 0); c.quadraticCurveTo(s * 0.2 * u, 0.07 * u, s * 0.32 * u, 0); } }, '#a9ad3c'],
422
+ [(c) => { c.beginPath(); c.moveTo(-0.06 * u, 0.12 * u); c.lineTo(0.06 * u, 0.12 * u); c.lineTo(0, 0.19 * u); c.closePath(); }, C.rose],
423
+ ],
424
+ ink(c) {
425
+ c.fillStyle = C.ink; c.beginPath(); E(c, -0.2 * u, -0.01 * u, 0.018 * u, 0.06 * u); E(c, 0.2 * u, -0.01 * u, 0.018 * u, 0.06 * u); c.fill();
426
+ c.beginPath();
427
+ for (const s of [-1, 1]) for (let k = 0; k < 3; k++) { c.moveTo(s * 0.18 * u, (0.22 + k * 0.05) * u); c.lineTo(s * (0.62 + k * 0.03) * u, (0.14 + k * 0.1) * u); }
428
+ for (let k = -1; k <= 1; k++) { c.moveTo(k * 0.09 * u, -0.36 * u); c.lineTo(k * 0.07 * u, -0.2 * u); }
429
+ for (const s of [-1, 1]) { c.moveTo(s * 0.48 * u, 0.02 * u); c.lineTo(s * 0.36 * u, 0.06 * u); c.moveTo(s * 0.48 * u, 0.12 * u); c.lineTo(s * 0.36 * u, 0.13 * u); }
430
+ c.moveTo(0, 0.19 * u); c.lineTo(0, 0.26 * u); c.moveTo(-0.1 * u, 0.3 * u); c.quadraticCurveTo(-0.04 * u, 0.32 * u, 0, 0.26 * u); c.quadraticCurveTo(0.04 * u, 0.32 * u, 0.1 * u, 0.3 * u);
431
+ c.stroke();
432
+ },
433
+ };
434
+ },
435
+ dog(u) {
436
+ return {
437
+ fills: [
438
+ [(c) => { c.beginPath(); E(c, -0.42 * u, 0.08 * u, 0.14 * u, 0.36 * u, 0.25); E(c, 0.42 * u, 0.08 * u, 0.14 * u, 0.36 * u, -0.25); }, '#7b4a28'],
439
+ [(c) => { c.beginPath(); E(c, 0, -0.06 * u, 0.38 * u, 0.4 * u); }, C.cream],
440
+ [(c) => { c.beginPath(); E(c, 0.16 * u, -0.1 * u, 0.14 * u, 0.13 * u, 0.4); }, '#9a6236'],
441
+ [(c) => { c.beginPath(); E(c, 0, 0.22 * u, 0.24 * u, 0.19 * u); }, '#f6eedc'],
442
+ [(c) => { c.beginPath(); E(c, 0.02 * u, 0.36 * u, 0.06 * u, 0.06 * u); }, C.rose],
443
+ ],
444
+ ink(c) {
445
+ c.fillStyle = C.ink;
446
+ c.beginPath(); E(c, 0, 0.13 * u, 0.09 * u, 0.06 * u); c.fill();
447
+ c.beginPath(); c.arc(-0.15 * u, -0.1 * u, 0.04 * u, 0, TAU); c.arc(0.16 * u, -0.1 * u, 0.04 * u, 0, TAU); c.fill();
448
+ c.fillStyle = '#fff'; c.beginPath(); c.arc(-0.16 * u, -0.115 * u, 0.012 * u, 0, TAU); c.arc(0.15 * u, -0.115 * u, 0.012 * u, 0, TAU); c.fill();
449
+ c.beginPath(); c.moveTo(0, 0.19 * u); c.lineTo(0, 0.27 * u); c.moveTo(-0.13 * u, 0.29 * u); c.quadraticCurveTo(0, 0.36 * u, 0.13 * u, 0.29 * u);
450
+ c.moveTo(-0.24 * u, -0.22 * u); c.lineTo(-0.08 * u, -0.2 * u); c.moveTo(0.24 * u, -0.22 * u); c.lineTo(0.08 * u, -0.2 * u);
451
+ for (let k = 0; k < 4; k++) { c.moveTo(-0.3 * u + k * 0.02 * u, 0.06 * u + k * 0.05 * u); c.lineTo(-0.2 * u + k * 0.02 * u, 0.04 * u + k * 0.05 * u); }
452
+ c.stroke();
453
+ },
454
+ };
455
+ },
456
+ // the model: a Brazen Head, the talking brass automaton of legend, with clockwork in its breast
457
+ head(u, o) {
458
+ const mo = (o.mouth || 0) * 0.07 * u, lx = (o.look || 0) * 0.03 * u, bl = o.blink || 0, ga = o.gear || 0;
459
+ const headP = (c) => { c.beginPath(); c.moveTo(-0.36 * u, 0.02 * u); c.bezierCurveTo(-0.42 * u, -0.58 * u, 0.42 * u, -0.58 * u, 0.36 * u, 0.02 * u); c.bezierCurveTo(0.33 * u, 0.3 * u, 0.15 * u, 0.38 * u, 0, 0.38 * u); c.bezierCurveTo(-0.15 * u, 0.38 * u, -0.33 * u, 0.3 * u, -0.36 * u, 0.02 * u); };
460
+ const gear = (gx, gy, r, n, a) => (c) => { c.beginPath(); for (let i = 0; i < n * 4; i++) { const aa = a + i * TAU / (n * 4), rr = (i % 4 < 2) ? r : r * 0.78; i ? c.lineTo(gx + Math.cos(aa) * rr, gy + Math.sin(aa) * rr) : c.moveTo(gx + Math.cos(aa) * rr, gy + Math.sin(aa) * rr); } c.closePath(); };
461
+ return {
462
+ fills: [
463
+ [(c) => { c.beginPath(); c.moveTo(-0.95 * u, 1.05 * u); c.quadraticCurveTo(-0.85 * u, 0.48 * u, -0.25 * u, 0.44 * u); c.lineTo(0.25 * u, 0.44 * u); c.quadraticCurveTo(0.85 * u, 0.48 * u, 0.95 * u, 1.05 * u); c.closePath(); }, C.verm],
464
+ [(c) => { c.beginPath(); c.rect(-0.16 * u, 0.26 * u, 0.32 * u, 0.22 * u); }, 'gold'],
465
+ [(c) => { c.beginPath(); c.moveTo(-0.3 * u, 0.46 * u); c.quadraticCurveTo(0, 0.6 * u, 0.3 * u, 0.46 * u); c.lineTo(0.27 * u, 0.53 * u); c.quadraticCurveTo(0, 0.67 * u, -0.27 * u, 0.53 * u); c.closePath(); }, 'gold'],
466
+ [gear(-0.2 * u, 0.8 * u, 0.15 * u, 10, ga), C.lapis],
467
+ [gear(0.09 * u, 0.76 * u, 0.11 * u, 8, -ga * 1.36 + 0.2), C.mal],
468
+ [(c) => { c.beginPath(); c.arc(-0.38 * u, -0.02 * u, 0.075 * u, 0, TAU); c.moveTo(0.455 * u, -0.02 * u); c.arc(0.38 * u, -0.02 * u, 0.075 * u, 0, TAU); }, 'gold'],
469
+ [(c) => { c.beginPath(); c.rect(-0.03 * u, -0.56 * u, 0.06 * u, 0.16 * u); c.moveTo(0.065 * u, -0.6 * u); c.arc(0, -0.6 * u, 0.065 * u, 0, TAU); }, 'gold'],
470
+ [headP, 'gold'],
471
+ [(c) => { c.beginPath(); for (const s of [-1, 1]) { c.moveTo(s * 0.24 * u, -0.06 * u); c.quadraticCurveTo(s * 0.14 * u, -0.06 * u - 0.06 * u * (1 - bl), s * 0.05 * u, -0.06 * u); c.quadraticCurveTo(s * 0.14 * u, -0.06 * u + 0.04 * u * (1 - bl), s * 0.24 * u, -0.06 * u); } }, C.white],
472
+ [(c) => { c.beginPath(); c.rect(-0.11 * u, 0.17 * u, 0.22 * u, 0.025 * u + mo); }, '#2a120a'],
473
+ ],
474
+ shade(c) { // volume on the brass: darker away from the light
475
+ c.save(); headP(c); c.clip(); const g = c.createRadialGradient(-0.15 * u, -0.25 * u, 0.05 * u, 0, 0, 0.6 * u);
476
+ g.addColorStop(0, 'rgba(255,250,220,0.35)'); g.addColorStop(0.5, 'rgba(0,0,0,0)'); g.addColorStop(1, 'rgba(70,35,5,0.45)'); c.fillStyle = g; c.fillRect(-u, -u, 2 * u, 2 * u); c.restore();
477
+ c.save(); c.strokeStyle = 'rgba(250,245,232,0.85)'; c.lineWidth = Math.max(0.8, u * 0.008); c.beginPath(); // white folds on the robe
478
+ for (const s of [-1, 1]) { c.moveTo(s * 0.5 * u, 0.55 * u); c.quadraticCurveTo(s * 0.6 * u, 0.75 * u, s * 0.58 * u, 1.0 * u); c.moveTo(s * 0.68 * u, 0.62 * u); c.quadraticCurveTo(s * 0.78 * u, 0.82 * u, s * 0.76 * u, 1.0 * u); }
479
+ c.stroke(); c.restore();
480
+ },
481
+ ink(c) {
482
+ if (bl < 0.9) { c.fillStyle = C.lapisD; c.beginPath(); c.arc(-0.145 * u + lx, -0.06 * u, 0.03 * u, 0, TAU); c.arc(0.145 * u + lx, -0.06 * u, 0.03 * u, 0, TAU); c.fill(); }
483
+ c.beginPath();
484
+ for (const s of [-1, 1]) { c.moveTo(s * 0.26 * u, -0.14 * u); c.quadraticCurveTo(s * 0.15 * u, -0.2 * u, s * 0.05 * u, -0.15 * u); }
485
+ c.moveTo(-0.02 * u, -0.1 * u); c.quadraticCurveTo(-0.01 * u, 0.06 * u, 0.04 * u, 0.1 * u); c.lineTo(-0.03 * u, 0.11 * u);
486
+ c.moveTo(-0.34 * u, -0.26 * u); c.quadraticCurveTo(0, -0.33 * u, 0.34 * u, -0.26 * u);
487
+ for (const s of [-1, 1]) { c.moveTo(s * 0.14 * u, 0.15 * u); c.lineTo(s * 0.13 * u, 0.33 * u); }
488
+ for (const s of [-1, 1]) for (let k = 0; k < 4; k++) { const a = k * Math.PI / 2 + 0.3; c.moveTo(s * 0.38 * u, -0.02 * u); c.lineTo(s * 0.38 * u + Math.cos(a) * 0.06 * u, -0.02 * u + Math.sin(a) * 0.06 * u); }
489
+ c.stroke();
490
+ c.fillStyle = C.ink; for (let k = -3; k <= 3; k++) { c.beginPath(); c.arc(k * 0.09 * u, -0.29 * u + Math.abs(k) * 0.012 * u, 0.012 * u, 0, TAU); c.fill(); }
491
+ c.beginPath(); c.arc(-0.2 * u, 0.8 * u, 0.035 * u, 0, TAU); c.arc(0.09 * u, 0.76 * u, 0.03 * u, 0, TAU); c.fill();
492
+ },
493
+ };
494
+ },
495
+ // marginal drollery: a hare-headed beast with a foliate dragon's tail, pointing
496
+ hare(u, o) {
497
+ const arm = o.arm == null ? 0.9 : o.arm, ear = (o.ear || 0) * 0.08;
498
+ const rod = o.rod || 0, sx = -0.24 * u, sy = -0.76 * u, ax = sx + Math.cos(arm) * 0.5 * u, ay = sy + Math.sin(arm) * 0.5 * u, nx = -Math.sin(arm) * 0.045 * u, ny = Math.cos(arm) * 0.045 * u;
499
+ return {
500
+ fills: [
501
+ [(c) => { c.beginPath(); c.moveTo(0.22 * u, -0.45 * u); c.bezierCurveTo(0.75 * u, -0.5 * u, 0.85 * u, 0.05 * u, 0.5 * u, 0.1 * u); c.bezierCurveTo(0.3 * u, 0.12 * u, 0.32 * u, -0.15 * u, 0.48 * u, -0.12 * u); c.bezierCurveTo(0.58 * u, -0.15 * u, 0.6 * u, -0.32 * u, 0.22 * u, -0.3 * u); c.closePath(); }, C.mal],
502
+ [(c) => { c.beginPath(); E(c, 0.16 * u, -1.4 * u, 0.065 * u, 0.27 * u, 0.32 + ear); E(c, 0.27 * u, -1.34 * u, 0.06 * u, 0.24 * u, 0.62 + ear * 0.7); }, C.ochre],
503
+ [(c) => { c.beginPath(); E(c, 0.165 * u, -1.4 * u, 0.025 * u, 0.19 * u, 0.32 + ear); }, C.rose],
504
+ [(c) => { c.beginPath(); E(c, 0, -0.58 * u, 0.28 * u, 0.4 * u, 0.1); }, C.mal],
505
+ [(c) => { c.beginPath(); E(c, -0.06 * u, -0.55 * u, 0.13 * u, 0.28 * u, 0.1); }, C.cream],
506
+ [(c) => { c.beginPath(); E(c, 0.02 * u, -1.07 * u, 0.22 * u, 0.15 * u, -0.18); }, C.ochre],
507
+ [(c) => { c.beginPath(); c.moveTo(sx + nx, sy + ny); c.lineTo(ax + nx * 0.8, ay + ny * 0.8); c.lineTo(ax - nx * 0.8, ay - ny * 0.8); c.lineTo(sx - nx, sy - ny); c.closePath(); }, C.verm],
508
+ [(c) => { c.beginPath(); c.arc(ax, ay, 0.065 * u, 0, TAU); }, C.cream],
509
+ ],
510
+ ink(c) {
511
+ c.fillStyle = C.ink; c.beginPath(); c.arc(-0.05 * u, -1.12 * u, 0.03 * u, 0, TAU); c.arc(-0.195 * u, -1.02 * u, 0.022 * u, 0, TAU); c.fill();
512
+ c.beginPath();
513
+ c.moveTo(-0.16 * u, -1.0 * u); c.lineTo(-0.3 * u, -1.04 * u); c.moveTo(-0.16 * u, -0.98 * u); c.lineTo(-0.29 * u, -0.95 * u); c.moveTo(-0.18 * u, -0.97 * u); c.quadraticCurveTo(-0.14 * u, -0.94 * u, -0.1 * u, -0.97 * u);
514
+ c.moveTo(-0.12 * u, -0.22 * u); c.lineTo(-0.16 * u, 0); c.lineTo(-0.26 * u, 0.02 * u); c.moveTo(-0.16 * u, 0); c.lineTo(-0.06 * u, 0.02 * u);
515
+ c.moveTo(0.1 * u, -0.22 * u); c.lineTo(0.12 * u, 0); c.lineTo(0.02 * u, 0.02 * u); c.moveTo(0.12 * u, 0); c.lineTo(0.22 * u, 0.02 * u);
516
+ for (let k = 0; k < 4; k++) { c.moveTo(0.08 * u, (-0.8 + k * 0.1) * u); c.lineTo(0.2 * u, (-0.78 + k * 0.1) * u); }
517
+ c.stroke();
518
+ c.save(); c.lineWidth = Math.max(2, u * 0.03); c.lineCap = 'round'; c.beginPath(); c.moveTo(ax + Math.cos(arm) * 0.04 * u, ay + Math.sin(arm) * 0.04 * u); c.lineTo(ax + Math.cos(arm) * 0.17 * u, ay + Math.sin(arm) * 0.17 * u); c.stroke(); c.restore();
519
+ if (rod > 0) { // a long pointer staff, held out at the error
520
+ const bx = ax - Math.cos(arm) * 0.12 * u, by = ay - Math.sin(arm) * 0.12 * u, ex = ax + Math.cos(arm) * rod, ey = ay + Math.sin(arm) * rod;
521
+ c.save(); c.lineCap = 'round'; c.lineWidth = Math.max(3, u * 0.03); c.strokeStyle = '#5a3418'; c.beginPath(); c.moveTo(bx, by); c.lineTo(ex, ey); c.stroke();
522
+ c.lineWidth = 1; c.strokeStyle = C.ink; c.beginPath(); c.moveTo(ex, ey); c.lineTo(ex + Math.cos(arm) * 12, ey + Math.sin(arm) * 12); c.stroke(); c.restore();
523
+ bezant(c, ex, ey, 5); bezant(c, bx, by, 4);
524
+ }
525
+ },
526
+ after(ctx) { leaf(ctx, 0.47 * u, -0.08 * u, 2.6, 0.24 * u, 'gold'); },
527
+ };
528
+ },
529
+ snail(u, o) {
530
+ const ant = Math.sin(o.wig || 0) * 0.06 * u;
531
+ return {
532
+ fills: [
533
+ [(c) => { c.beginPath(); c.moveTo(-0.9 * u, 0); c.quadraticCurveTo(-0.95 * u, -0.38 * u, -0.7 * u, -0.42 * u); c.quadraticCurveTo(-0.55 * u, -0.2 * u, 0.6 * u, -0.06 * u); c.lineTo(0.65 * u, 0); c.closePath(); }, '#9aa98a'],
534
+ [(c) => { c.beginPath(); c.arc(0.05 * u, -0.42 * u, 0.42 * u, 0, TAU); }, C.ochre],
535
+ ],
536
+ ink(c) {
537
+ c.beginPath(); let a = 0, r = 0.36 * u; c.moveTo(0.05 * u + r, -0.42 * u); for (let i = 0; i < 60; i++) { a += 0.2; r *= 0.975; c.lineTo(0.05 * u + Math.cos(a) * r, -0.42 * u + Math.sin(a) * r); }
538
+ c.moveTo(-0.75 * u, -0.4 * u); c.lineTo(-0.82 * u + ant, -0.72 * u); c.moveTo(-0.7 * u, -0.4 * u); c.lineTo(-0.62 * u - ant, -0.72 * u);
539
+ c.stroke(); c.fillStyle = C.ink; c.beginPath(); c.arc(-0.82 * u + ant, -0.74 * u, 0.04 * u, 0, TAU); c.arc(-0.62 * u - ant, -0.74 * u, 0.04 * u, 0, TAU); c.fill();
540
+ },
541
+ };
542
+ },
543
+ };
544
+ // a figure: ink underdrawing (pen goes round), then pigments flood into the outlines
545
+ function figure(ctx, kind, cx, cy, u, inkP, colP, o = {}) {
546
+ if (inkP <= 0 && colP <= 0) return;
547
+ const P = FIG[kind](u, o);
548
+ ctx.save(); ctx.translate(cx, cy);
549
+ if (colP > 0) {
550
+ ctx.save(); if (colP < 1) floodClip(ctx, 0, kind === 'hare' ? -0.7 * u : 0, colP * u * (kind === 'hare' ? 1.6 : 1.25), 7);
551
+ for (const [p, col] of P.fills) col === 'gold' ? gilt(ctx, p, { line: false, sh: 0.6 }) : paint(ctx, p, col, { edgeW: Math.max(2, u * 0.04) });
552
+ if (P.shade) P.shade(ctx);
553
+ if (P.after) P.after(ctx);
554
+ ctx.restore();
555
+ }
556
+ if (inkP > 0) {
557
+ ctx.save(); if (inkP < 1) sectorClip(ctx, 0, kind === 'hare' ? -0.7 * u : 0, u * 2, -Math.PI / 2, inkP);
558
+ ctx.strokeStyle = C.ink; ctx.lineWidth = lw(u); ctx.lineJoin = 'round'; ctx.lineCap = 'round';
559
+ for (const [p] of P.fills) { p(ctx); ctx.stroke(); }
560
+ P.ink(ctx);
561
+ ctx.restore();
562
+ }
563
+ ctx.restore();
564
+ }
565
+ // roundel miniature: gilt ring laid round, lapis ground with white stars, figure inside
566
+ function roundel(ctx, cx, cy, r, kind, p, o = {}) {
567
+ if (p <= 0) return;
568
+ const ringP = eo(win(p, 0, 0.4)), gP = win(p, 0.12, 0.45), iP = win(p, 0.25, 0.65), cP = win(p, 0.45, 0.95), ri = r * 0.86;
569
+ if (gP > 0) {
570
+ ctx.save(); ctx.beginPath(); ctx.arc(cx, cy, ri, 0, TAU); ctx.clip();
571
+ if (gP < 1) floodClip(ctx, cx, cy, ri * 1.2 * eo(gP), 11);
572
+ paint(ctx, (c) => { c.beginPath(); c.arc(cx, cy, ri + 1, 0, TAU); }, o.ground || C.lapis, { edgeW: r * 0.08 });
573
+ ctx.fillStyle = 'rgba(250,246,234,0.75)';
574
+ const R = H.rng(Math.round(cx * 7 + cy));
575
+ for (let i = 0; i < 16; i++) { const a = R() * TAU, d = Math.sqrt(R()) * ri * 0.92, x = cx + Math.cos(a) * d, y = cy + Math.sin(a) * d; for (let j = 0; j < 4; j++) { ctx.beginPath(); ctx.arc(x + Math.cos(j * 1.57) * r * 0.035, y + Math.sin(j * 1.57) * r * 0.035, Math.max(0.7, r * 0.012), 0, TAU); ctx.fill(); } }
576
+ figure(ctx, kind, cx, cy + (o.dy || 0) * r, r * (o.scale || 0.95), iP, cP, o);
577
+ ctx.restore();
578
+ }
579
+ if (ringP > 0) {
580
+ const a0 = -Math.PI / 2, a1 = a0 + ringP * TAU;
581
+ gilt(ctx, (c) => { c.beginPath(); c.arc(cx, cy, r, a0, a1); c.arc(cx, cy, ri, a1, a0, true); c.closePath(); }, { lw: 1, ring: [cx, cy, ri, r] });
582
+ if (ringP >= 1) { ctx.save(); ctx.strokeStyle = 'rgba(40,22,8,0.6)'; ctx.setLineDash([1.5, 4]); ctx.lineWidth = 1.2; ctx.beginPath(); ctx.arc(cx, cy, (r + ri) / 2, 0, TAU); ctx.stroke(); ctx.restore(); }
583
+ }
584
+ }
585
+
586
+ // ---------------------------------------------------------------- penwork: arrows, rings, scroll
587
+ const bez = (P, u) => { const v = 1 - u; return [v * v * v * P[0][0] + 3 * v * v * u * P[1][0] + 3 * v * u * u * P[2][0] + u * u * u * P[3][0], v * v * v * P[0][1] + 3 * v * v * u * P[1][1] + 3 * v * u * u * P[2][1] + u * u * u * P[3][1]]; };
588
+ function arrowHead(ctx, x, y, a, s, col) {
589
+ ctx.save(); ctx.translate(x, y); ctx.rotate(a);
590
+ ctx.beginPath(); ctx.moveTo(0, 0); ctx.quadraticCurveTo(-s * 0.6, -s * 0.15, -s * 1.1, -s * 0.6); ctx.lineTo(-s * 0.75, 0); ctx.lineTo(-s * 1.1, s * 0.6); ctx.quadraticCurveTo(-s * 0.6, s * 0.15, 0, 0); ctx.closePath();
591
+ ctx.fillStyle = col; ctx.fill(); ctx.strokeStyle = C.ink; ctx.lineWidth = 1; ctx.stroke();
592
+ ctx.restore();
593
+ }
594
+ function penBez(ctx, P, p, col, w = 3) {
595
+ if (p <= 0) return;
596
+ const N = 48, n = Math.max(1, Math.round(N * p)), pts = []; for (let i = 0; i <= n; i++) pts.push(bez(P, i / N * (p * N / n)));
597
+ ctx.save(); ctx.lineCap = 'round'; ctx.lineJoin = 'round';
598
+ ctx.strokeStyle = col; ctx.lineWidth = w; ctx.beginPath(); pts.forEach((q, i) => (i ? ctx.lineTo(q[0], q[1]) : ctx.moveTo(q[0], q[1]))); ctx.stroke();
599
+ ctx.strokeStyle = C.ink; ctx.lineWidth = 0.8; // penwork cadels along the shaft
600
+ for (let i = 3; i < pts.length - 4; i += 4) { const a = Math.atan2(pts[i + 1][1] - pts[i][1], pts[i + 1][0] - pts[i][0]) + Math.PI / 2, s = (i / 4) % 2 ? 7 : -7; ctx.beginPath(); ctx.moveTo(pts[i][0], pts[i][1]); ctx.quadraticCurveTo(pts[i][0] + Math.cos(a) * s, pts[i][1] + Math.sin(a) * s, pts[i + 2][0] + Math.cos(a) * s * 0.4, pts[i + 2][1] + Math.sin(a) * s * 0.4); ctx.stroke(); }
601
+ ctx.restore();
602
+ if (p >= 1) { const a = bez(P, 0.97), b = P[3]; arrowHead(ctx, b[0], b[1], Math.atan2(b[1] - a[1], b[0] - a[0]), 18, col); }
603
+ }
604
+ function penArc(ctx, cx, cy, R, a0, a1, p, col, w = 3) {
605
+ if (p <= 0) return;
606
+ const ae = a0 + (a1 - a0) * p;
607
+ ctx.save(); ctx.lineCap = 'round'; ctx.strokeStyle = col; ctx.lineWidth = w; ctx.beginPath(); ctx.arc(cx, cy, R, a0, ae); ctx.stroke();
608
+ ctx.strokeStyle = C.ink; ctx.lineWidth = 0.8;
609
+ for (let a = a0 + 0.12, i = 0; a < ae - 0.08; a += 0.13, i++) { const s = i % 2 ? 7 : -7; ctx.beginPath(); ctx.moveTo(cx + Math.cos(a) * R, cy + Math.sin(a) * R); ctx.quadraticCurveTo(cx + Math.cos(a + 0.03) * (R + s), cy + Math.sin(a + 0.03) * (R + s), cx + Math.cos(a + 0.07) * (R + s * 0.4), cy + Math.sin(a + 0.07) * (R + s * 0.4)); ctx.stroke(); }
610
+ ctx.restore();
611
+ if (p >= 1) arrowHead(ctx, cx + Math.cos(a1) * R, cy + Math.sin(a1) * R, a1 + Math.PI / 2, 18, col);
612
+ }
613
+ // banderole: a speech scroll with rolled ends
614
+ function scroll(ctx, x, y, w, h, p) {
615
+ if (p <= 0) return;
616
+ const ww = w * eo(p), top = (u) => y + Math.sin(u * 5.5) * 4, bot = (u) => y + h + Math.sin(u * 5.5) * 4;
617
+ ctx.save();
618
+ ctx.beginPath(); ctx.moveTo(x, top(0)); for (let i = 1; i <= 20; i++) ctx.lineTo(x + ww * i / 20, top(ww * i / 20 / w));
619
+ for (let i = 20; i >= 0; i--) ctx.lineTo(x + ww * i / 20, bot(ww * i / 20 / w)); ctx.closePath();
620
+ ctx.fillStyle = '#f5ecd6'; ctx.fill(); ctx.save(); ctx.clip(); ctx.globalCompositeOperation = 'multiply'; ctx.globalAlpha = 0.4; ctx.fillStyle = pat(ctx, 'p'); ctx.fill();
621
+ ctx.globalAlpha = 0.22; ctx.fillStyle = '#7a5a30'; ctx.fillRect(x, bot(0) - 10, w, 14); ctx.restore();
622
+ ctx.strokeStyle = C.ink; ctx.lineWidth = 1.4; ctx.stroke();
623
+ for (const [ex, flip] of [[x, -1], [x + ww, 1]]) { // rolled ends
624
+ const yy = (top(ex === x ? 0 : ww / w) + bot(ex === x ? 0 : ww / w)) / 2;
625
+ ctx.beginPath(); ctx.ellipse(ex + flip * 6, yy, 9, h * 0.5, 0, 0, TAU); ctx.fillStyle = '#d9c9a4'; ctx.fill(); ctx.stroke();
626
+ ctx.beginPath(); ctx.ellipse(ex + flip * 6, yy + h * 0.15, 4, h * 0.22, 0, 0, TAU); ctx.fillStyle = '#a58c62'; ctx.fill(); ctx.stroke();
627
+ }
628
+ ctx.restore();
629
+ }
630
+ function cartouche(ctx, x, y, w, h, p) {
631
+ if (p <= 0) return;
632
+ ctx.save(); ctx.globalAlpha = eo(p);
633
+ ctx.fillStyle = 'rgba(248,238,214,0.55)'; ctx.fillRect(x, y, w, h);
634
+ ctx.strokeStyle = C.verm; ctx.lineWidth = 3; ctx.strokeRect(x, y, w, h);
635
+ ctx.lineWidth = 1.2; ctx.strokeRect(x + 6, y + 6, w - 12, h - 12);
636
+ ctx.restore();
637
+ const s = eo(win(p, 0.5, 1)); for (const [bx, by] of [[x, y], [x + w, y], [x, y + h], [x + w, y + h]]) bezant(ctx, bx, by, 6, s);
638
+ }
639
+ function fmt(n) { return Math.round(n).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); }
640
+
641
+ // =====================================================================================================
642
+ // STILL + CLIP: "Of the Learning Machine", a folio with a historiated O (the Brazen Head reads its book)
643
+ // =====================================================================================================
644
+ const LATIN = [
645
+ ['Machina discit ex exemplis multis. Primo videt mille milia imaginum, cattos et canes, et nomen cuiusque discit.', 0],
646
+ ['Deinde novam imaginem conspicit et coniecturam facit:', 1], ['canis?', 2], ['Errat. Magister errorem ostendit, et machina rotulas suas paulum vertit. Iterum conatur:', 0], ['cattus!', 2],
647
+ ['Sic per multas vices paulatim sapientior fit, donec fere semper recte respondeat.', 1], ['Plura exempla, meliores coniecturae.', 4],
648
+ ];
649
+ let WRAP = null;
650
+ function wrapBody(ctx) {
651
+ if (WRAP) return WRAP;
652
+ ctx.save(); ctx.font = FONT.bl(34);
653
+ const lines = [{ x: 488, w: 712, y: 352, items: [] }, { x: 488, w: 712, y: 396, items: [] }, { x: 488, w: 712, y: 440, items: [] }, { x: 128, w: 1072, y: 484, items: [] }, { x: 128, w: 1072, y: 528, items: [] }, { x: 128, w: 1072, y: 572, items: [] }];
654
+ const sp = ctx.measureText(' ').width; let li = 0, cx = 0;
655
+ for (const [txt, kind] of LATIN) {
656
+ if (kind === 1 || kind === 4) { lines[li].items.push({ s: '¶', x: cx, w: 20, k: 3 }); cx += ctx.measureText('¶ ').width; }
657
+ for (const word of txt.split(' ')) {
658
+ const ww = ctx.measureText(word).width;
659
+ if (cx + ww > lines[li].w) { li++; cx = 0; if (li >= lines.length) break; }
660
+ lines[li].items.push({ s: word, x: cx, w: ww, k: kind === 2 || kind === 4 ? 2 : 0 }); cx += ww + sp;
661
+ }
662
+ if (li >= lines.length) break;
663
+ }
664
+ ctx.restore();
665
+ lines.forEach((L) => { L.end = L.items.length ? L.items[L.items.length - 1].x + L.items[L.items.length - 1].w : 0; });
666
+ return (WRAP = lines.slice(0, li + 1));
667
+ }
668
+ function historiatedO(ctx, x, y, s, t, T) {
669
+ // gold leaf ground laid in squares, punched dots, lapis O with white filigree, a diapered counter with the Brazen Head
670
+ const cx = x + s / 2, cy = y + s / 2, n = 4, q = s / n, laid = [];
671
+ for (let j = 0; j < n; j++) for (let i = 0; i < n; i++) {
672
+ const k = (i + j) / (2 * n - 2), sp = eo(win(t, T.gold + k * 0.5, T.gold + k * 0.5 + 0.18)); if (sp <= 0) continue;
673
+ const qx = x + i * q, qy = y + j * q;
674
+ const sq = [qx + q / 2 - q / 2 * sp - (i ? 0.6 : 0), qy + q / 2 - q / 2 * sp - (j ? 0.6 : 0), q * sp + 1.2, q * sp + 1.2];
675
+ gilt(ctx, (c) => { c.beginPath(); c.rect(...sq); }, { line: false, sh: 0.4, dome: false });
676
+ laid.push(sq);
677
+ }
678
+ if (laid.length) { // the whole ground is one raised, burnished panel: a broad sheen and a shaded lower-right edge
679
+ ctx.save(); ctx.beginPath(); for (const r of laid) ctx.rect(...r); ctx.clip();
680
+ ctx.globalCompositeOperation = 'screen';
681
+ const g = ctx.createRadialGradient(x + s * 0.28, y + s * 0.24, 0, x + s * 0.4, y + s * 0.38, s * 0.85);
682
+ g.addColorStop(0, 'rgba(255,238,178,0.45)'); g.addColorStop(0.5, 'rgba(255,236,170,0.1)'); g.addColorStop(1, 'rgba(255,236,170,0)');
683
+ ctx.fillStyle = g; ctx.fillRect(x, y, s, s);
684
+ ctx.globalCompositeOperation = 'multiply';
685
+ const d = ctx.createLinearGradient(x, y, x + s, y + s);
686
+ d.addColorStop(0.55, 'rgba(255,255,255,0)'); d.addColorStop(1, 'rgba(110,58,14,0.5)');
687
+ ctx.fillStyle = d; ctx.fillRect(x, y, s, s);
688
+ ctx.restore();
689
+ }
690
+ if (t > T.gold + 0.7) { ctx.save(); ctx.strokeStyle = 'rgba(40,22,8,0.9)'; ctx.lineWidth = 1.3; ctx.strokeRect(x, y, s, s); ctx.fillStyle = 'rgba(90,55,15,0.5)'; for (let k = 8; k < s - 4; k += 9) for (const [px, py] of [[x + k, y + 7], [x + k, y + s - 7], [x + 7, y + k], [x + s - 7, y + k]]) { ctx.beginPath(); ctx.arc(px, py, 1.3, 0, TAU); ctx.fill(); } ctx.restore(); }
691
+ const oP = win(t, T.o, T.o + 0.6), Rx = s * 0.42, Ry = s * 0.44, rx = s * 0.29, ry = s * 0.335;
692
+ const counter = (c) => { c.beginPath(); c.ellipse(cx + s * 0.01, cy + s * 0.005, rx, ry, 0, 0, TAU); };
693
+ // counter: vermilion diaper with gold dots, the head inside
694
+ const dP = win(t, T.o + 0.2, T.o + 0.8);
695
+ if (dP > 0) {
696
+ ctx.save(); counter(ctx); ctx.clip(); if (dP < 1) floodClip(ctx, cx, cy, ry * 1.3 * eo(dP), 5);
697
+ paint(ctx, counter, C.verm, { edgeW: 6 });
698
+ ctx.strokeStyle = 'rgba(120,20,8,0.7)'; ctx.lineWidth = 1; ctx.beginPath();
699
+ for (let k = -8; k <= 8; k++) { ctx.moveTo(cx + k * 22 - 200, cy - 200); ctx.lineTo(cx + k * 22 + 200, cy + 200); ctx.moveTo(cx + k * 22 + 200, cy - 200); ctx.lineTo(cx + k * 22 - 200, cy + 200); }
700
+ ctx.stroke();
701
+ for (let a = -8; a <= 8; a++) for (let b = -8; b <= 8; b++) { const px = cx + (a + b) * 11, py = cy + (b - a) * 11; if (Math.abs(px - cx) < rx && Math.abs(py - cy) < ry) bezant(ctx, px, py, 1.8); }
702
+ ctx.restore();
703
+ }
704
+ ctx.save(); counter(ctx); ctx.clip();
705
+ figure(ctx, 'head', cx, cy - s * 0.02, s * 0.27, win(t, T.head, T.head + 0.5), win(t, T.head + 0.35, T.head + 1.0), { look: Math.sin(t * 0.9) * 0.6 + 0.4, blink: win(t, 5.0, 5.06) - win(t, 5.12, 5.2), gear: t * 0.6 });
706
+ if (t > T.head + 0.6) { // the open book on its lectern
707
+ const bp = eo(win(t, T.head + 0.6, T.head + 1.0)), bx = cx, by = cy + s * 0.2;
708
+ ctx.save(); ctx.globalAlpha = bp;
709
+ for (const side of [-1, 1]) { ctx.beginPath(); ctx.moveTo(bx, by); ctx.quadraticCurveTo(bx + side * 30, by - 10, bx + side * 58, by - 4); ctx.lineTo(bx + side * 56, by + 26); ctx.quadraticCurveTo(bx + side * 30, by + 20, bx, by + 30); ctx.closePath(); ctx.fillStyle = '#f6efdd'; ctx.fill(); ctx.strokeStyle = C.ink; ctx.lineWidth = 1.2; ctx.stroke();
710
+ ctx.lineWidth = 0.8; for (let k = 0; k < 4; k++) { ctx.beginPath(); ctx.moveTo(bx + side * 8, by + 5 + k * 5); ctx.lineTo(bx + side * 48, by + 3 + k * 5); ctx.strokeStyle = k === 0 ? C.verm : C.ink; ctx.stroke(); } }
711
+ paint(ctx, (c) => { c.beginPath(); c.rect(bx - 50, by + 28, 100, 40); }, '#6b4426', { edgeW: 3, ink: true });
712
+ ctx.restore();
713
+ }
714
+ ctx.restore();
715
+ if (oP > 0) { // the O itself
716
+ const ring = (c) => { c.beginPath(); c.ellipse(cx, cy, Rx, Ry, 0, 0, TAU); c.moveTo(cx + s * 0.01 + rx, cy + s * 0.005); c.ellipse(cx + s * 0.01, cy + s * 0.005, rx, ry, 0, TAU, 0, true); };
717
+ ctx.save(); if (oP < 1) floodClip(ctx, cx - Rx, cy, s * 1.1 * eo(oP), 2);
718
+ paint(ctx, ring, C.lapis, { edgeW: 8 });
719
+ ctx.save(); ring(ctx); ctx.clip(); const g = ctx.createLinearGradient(cx - Rx, cy - Ry, cx + Rx, cy + Ry); g.addColorStop(0, 'rgba(120,150,230,0.35)'); g.addColorStop(0.5, 'rgba(0,0,0,0)'); g.addColorStop(1, 'rgba(5,10,40,0.4)'); ctx.fillStyle = g; ctx.fillRect(x, y, s, s); ctx.restore();
720
+ ctx.restore();
721
+ const fP = win(t, T.fil, T.fil + 0.6);
722
+ if (fP > 0) { // white-lead tracery following the bow
723
+ ctx.save(); ring(ctx); ctx.clip(); ctx.strokeStyle = 'rgba(250,247,238,0.9)'; ctx.fillStyle = 'rgba(250,247,238,0.9)'; ctx.lineWidth = 1.1;
724
+ const mr = (k) => [lerp(rx, Rx, k), lerp(ry, Ry, k)];
725
+ const [a1, b1] = mr(0.5); ctx.beginPath(); ctx.ellipse(cx + 1.5, cy, a1, b1, 0, -Math.PI / 2, -Math.PI / 2 + fP * TAU); ctx.stroke();
726
+ for (let i = 0; i < 28 * fP; i++) { const a = -Math.PI / 2 + i / 28 * TAU, [ea, eb] = mr(0.5), px = cx + 1.5 + Math.cos(a) * ea, py = cy + Math.sin(a) * eb; ctx.beginPath(); ctx.arc(px + Math.cos(a) * 7, py + Math.sin(a) * 7, 3.5, a, a + 3.4); ctx.stroke(); ctx.beginPath(); ctx.arc(px - Math.cos(a) * 7, py - Math.sin(a) * 7, 1.4, 0, TAU); ctx.fill(); }
727
+ ctx.restore();
728
+ }
729
+ ctx.save(); ctx.strokeStyle = C.ink; ctx.lineWidth = 1.6; ring(ctx); ctx.stroke(); ctx.restore();
730
+ }
731
+ }
732
+ function lineFiller(ctx, x0, x1, y, p) {
733
+ if (p <= 0) return; const xe = lerp(x0, x1, eo(p));
734
+ paint(ctx, (c) => { c.beginPath(); c.rect(x0, y - 16, xe - x0, 12); }, C.lapis, { edgeW: 2, ink: true, lw: 0.9 });
735
+ ctx.fillStyle = 'rgba(250,245,232,0.9)'; for (let x = x0 + 6; x < xe - 4; x += 10) { ctx.beginPath(); ctx.arc(x, y - 10, 1.4, 0, TAU); ctx.fill(); }
736
+ if (p >= 1) bezant(ctx, x1 + 6, y - 10, 5);
737
+ }
738
+ function drawStill(ctx, t) {
739
+ BASE = ctx.getTransform(); NIB = null;
740
+ const sweep = win(t, 4.3, 5.4), amb = ((((t - 5.8) * 0.25 + 0.52) % 1.6) + 1.6) % 1.6 - 0.3;
741
+ setGold(ctx, sweep > 0 && sweep < 1 ? lerp(-0.08, 1.08, sweep) : amb, sweep > 0 && sweep < 1 ? 1 : 0.55);
742
+ pageBase(ctx, false, win(t, 0, 0.5), win(t, 0.7, 2.7), 21);
743
+ historiatedO(ctx, 124, 104, 342, t, { gold: 0.12, o: 0.95, head: 1.3, fil: 3.7 });
744
+ spray(ctx, 124, 104, win(t, 2.4, 3.1), 9, [-2.6, -2.0, -1.3]);
745
+ spray(ctx, 466, 104, win(t, 2.6, 3.3), 10, [-1.0, -0.4, -1.6]);
746
+ // title, rubricated
747
+ write(ctx, 'f the Learning', 488, 202, FONT.blb(84), C.verm, win(t, 1.9, 2.6));
748
+ write(ctx, 'Machine', 488, 292, FONT.blb(84), C.ink, win(t, 2.6, 3.0));
749
+ // the text block, written line by line
750
+ const L = wrapBody(ctx);
751
+ L.forEach((ln, i) => {
752
+ const a = 3.0 + i * 0.26, p = win(t, a, a + 0.26); if (p <= 0) return;
753
+ ctx.save(); ctx.font = FONT.bl(34); const reach = ln.end * p;
754
+ ctx.beginPath(); ctx.rect(ln.x - 30, ln.y - 40, reach + 34, 56); ctx.clip();
755
+ for (const it of ln.items) {
756
+ if (it.k === 3) { ctx.font = FONT.blb(34); ctx.fillStyle = (i % 2) ? C.lapis : C.verm; ctx.fillText('¶', ln.x + it.x, ln.y); ctx.font = FONT.bl(34); continue; }
757
+ ctx.fillStyle = it.k === 2 ? C.verm : C.ink; ctx.fillText(it.s, ln.x + it.x, ln.y);
758
+ }
759
+ ctx.restore();
760
+ if (p < 1) NIB = { x: ln.x + reach, y: ln.y - 9 };
761
+ });
762
+ const last = L[L.length - 1]; if (last) lineFiller(ctx, last.x + last.end + 16, Math.min(1196, last.x + last.end + 260), last.y, win(t, 4.6, 4.9));
763
+ // bas-de-page: a snail confronts the hare-beast
764
+ const snx = 880 + t * 2.2;
765
+ figure(ctx, 'snail', snx, 680, 60, win(t, 2.2, 2.7), win(t, 2.6, 3.2), { wig: t * 3 });
766
+ const pointing = ez(win(t, 4.3, 4.9)), arm = lerp(2.4, Math.atan2(650 - 619, snx - 50 - 1102), pointing);
767
+ figure(ctx, 'hare', 1120, 680, 80, win(t, 2.4, 2.9), win(t, 2.8, 3.4), { arm: arm + Math.sin(t * 2) * 0.02, ear: Math.sin(t * 2.6), rod: pointing * Math.max(0, 1102 + Math.cos(arm) * 40 - (snx - 30)) });
768
+ if (NIB) quill(ctx, NIB.x, NIB.y, t);
769
+ H.vignette(ctx, 1280, 720, 0.28, '60,35,10');
770
+ }
771
+
772
+ // =====================================================================================================
773
+ // EXPLAINER: three folios. Folio 1 the question and the bestiary of examples; the leaf turns; folio 2 the
774
+ // wheel of Guess, Check, Adjust (the drollery points out the error, the scribe corrects it in red); the leaf
775
+ // turns; folio 3 a gilded chart of rounds and the accuracy figure, gilt at 97%, and the rubric takeaway.
776
+ // =====================================================================================================
777
+ const EX = {
778
+ D: 15,
779
+ hookW: [0.55, 1.55], hookShrink: [2.0, 2.6],
780
+ gridT0: 2.3, gridStep: 0.17, headR: [2.35, 3.15], model: [3.1, 3.45], arrow1: [3.7, 4.15], fly: [4.15, 5.95], count: [4.25, 5.9],
781
+ turn1: [6.1, 6.9],
782
+ cat2: 6.85, arrow2: [7.25, 7.5], guess: 7.45, segA: [7.4, 7.7], scroll: [7.75, 8.05], dog: [8.0, 8.25], segB: [8.25, 8.55], check: 8.45,
783
+ point: [8.6, 8.85], strike: [8.85, 9.0], ring: [8.98, 9.3], segC: [9.25, 9.7], adjust: 9.4, drop: [9.25, 9.95], gears: [9.6, 10.15], cat: [9.75, 10.05], tick: [10.05, 10.2], segD: [10.0, 10.3],
784
+ turn2: [10.75, 11.5],
785
+ acc: 11.05, bar0: 11.45, barStep: 0.24, barRise: 0.26, flare: 12.91, circle: [13.0, 13.35], take: [13.35, 14.05], flourish: [14.05, 14.3],
786
+ };
787
+ const VALS = [61, 70, 79, 86, 92, 97];
788
+ const HB = { s: 220, tx: 235, ty: 190, px: 100 };
789
+ const HOOK = [{ s: 'ow does ', f: FONT.blb(100), c: C.ink }, { s: 'AI', f: FONT.fell(112), c: C.verm }, { s: ' learn?', f: FONT.blb(100), c: C.ink }];
790
+ function writeRich(ctx, segs, x, y, prog, measureOnly) {
791
+ let total = 0; for (const sg of segs) total += sg.s.length;
792
+ let cx = x, before = 0;
793
+ for (const sg of segs) {
794
+ ctx.save(); ctx.font = sg.f; const w = ctx.measureText(sg.s).width; ctx.restore();
795
+ if (!measureOnly) write(ctx, sg.s, cx, y, sg.f, sg.c, cl((prog * total - before) / sg.s.length));
796
+ cx += w; before += sg.s.length;
797
+ }
798
+ return cx - x;
799
+ }
800
+ function hookBlock(ctx, t) {
801
+ champ(ctx, 'H', 0, 0, HB.s, t, 0.0, 4);
802
+ spray(ctx, 0, 0, win(t, 0.3, 0.95), 31, [-2.5, -1.9, -3.0]);
803
+ spray(ctx, 0, HB.s, win(t, 0.35, 1.0), 32, [2.4, 1.9, 3.0]);
804
+ writeRich(ctx, HOOK, HB.tx, HB.ty, win(t, EX.hookW[0], EX.hookW[1]));
805
+ }
806
+ function header(ctx, t) { ctx.save(); ctx.translate(120, 22); ctx.scale(0.4, 0.4); hookBlock(ctx, 99); ctx.restore(); }
807
+ function glintAt(t, sweeps) {
808
+ for (const [a, b, boost] of sweeps) { const u = win(t, a, b); if (u > 0 && u < 1) return [lerp(-0.1, 1.1, u), boost]; }
809
+ return [((t * 0.2 + 0.3) % 1.7) - 0.35, 0.5];
810
+ }
811
+ // --- folio 1
812
+ function folio1(ctx, t) {
813
+ BASE = ctx.getTransform(); NIB = null;
814
+ const [gp, gb] = glintAt(t, [[1.45, 2.25, 1.1], [5.95, 6.6, 0.8]]); setGold(ctx, gp, gb);
815
+ pageBase(ctx, false, 1, 0.25 + 0.75 * win(t, 0, 2.2), 11);
816
+ // the question, then it shrinks into the running title
817
+ const bw = HB.tx + writeRich(ctx, HOOK, 0, 0, 1, true);
818
+ const sh = ez(win(t, EX.hookShrink[0], EX.hookShrink[1]));
819
+ ctx.save(); ctx.translate(lerp((1280 - bw) / 2, 120, sh), lerp(240, 22, sh)); const sc = lerp(1, 0.4, sh); ctx.scale(sc, sc); hookBlock(ctx, t); ctx.restore();
820
+ // the bestiary
821
+ const kinds = ['cat', 'dog', 'cat', 'dog', 'cat', 'dog'], GX = [188, 338, 488], GY = [242, 420];
822
+ kinds.forEach((k, i) => {
823
+ const cx = GX[i % 3], cy = GY[(i / 3) | 0], a = EX.gridT0 + i * EX.gridStep;
824
+ roundel(ctx, cx, cy, 58, k, win(t, a, a + 0.55), { dy: 0.05 });
825
+ write(ctx, k, cx, cy + 96, FONT.blb(36), C.verm, win(t, a + 0.4, a + 0.6), 'center', { noNib: true });
826
+ });
827
+ // the model
828
+ const hx = 1010, hy = 298, hr = 140, flying = win(t, EX.fly[0], EX.fly[1]);
829
+ roundel(ctx, hx, hy, hr, 'head', win(t, EX.headR[0], EX.headR[1]), { dy: -0.02, scale: 0.92, look: flying > 0 ? -1 : 0, gear: t * (flying > 0 && flying < 1 ? 3 : 0.4), blink: win(t, 3.9, 3.95) - win(t, 4.0, 4.06), mouth: 0 });
830
+ write(ctx, 'the Model', hx, hy + hr + 56, FONT.blb(50), C.verm, win(t, EX.model[0], EX.model[1]), 'center');
831
+ // arrow, examples flowing in
832
+ const AP = [[560, 330], [650, 225], [770, 215], [852, 285]];
833
+ penBez(ctx, AP, win(t, EX.arrow1[0], EX.arrow1[1]), C.verm, 3.2);
834
+ for (let i = 0; i < 9; i++) {
835
+ const u = (t - EX.fly[0] - i * 0.18) / 0.62; if (u <= 0 || u >= 1.25) continue;
836
+ const v = cl(u), q = u <= 1 ? bez(AP, ez(v)) : [lerp(852, hx - 30, (u - 1) * 4), lerp(285, hy, (u - 1) * 4)], s = u <= 1 ? 1 : cl(1 - (u - 1) * 4);
837
+ ctx.save(); ctx.globalAlpha = cl(s * 1.5); roundel(ctx, q[0], q[1] - 22, 25 * (0.6 + 0.4 * s), i % 2 ? 'dog' : 'cat', 1); ctx.restore();
838
+ }
839
+ // the tally of examples
840
+ const cp = win(t, EX.count[0], EX.count[1]);
841
+ cartouche(ctx, 560, 548, 560, 96, win(t, EX.count[0] - 0.25, EX.count[0]));
842
+ if (cp > 0) {
843
+ const n = cp >= 1 ? 1e6 : Math.round((Math.pow(10, 4 * ez(cp)) - 1) / (1e4 - 1) * 1e6 / 7) * 7;
844
+ ctx.save(); ctx.font = FONT.fell(80); ctx.fillStyle = C.ink; ctx.textAlign = 'right'; ctx.fillText(fmt(Math.min(1e6, n)), 900, 622); ctx.restore();
845
+ write(ctx, 'examples', 916, 618, FONT.blb(42), C.verm, 1, 'left', { noNib: true });
846
+ }
847
+ if (NIB) quill(ctx, NIB.x, NIB.y, t);
848
+ }
849
+ // --- folio 2
850
+ const F2 = { hx: 620, hy: 392, hr: 122, R: 216 };
851
+ function f2label(ctx, word, ax, t, t0) {
852
+ const x = F2.hx + Math.cos(ax) * F2.R, y = F2.hy + Math.sin(ax) * F2.R, s = 56;
853
+ ctx.save(); ctx.font = FONT.blb(46); const w = s + 6 + ctx.measureText(word.slice(1)).width; ctx.restore();
854
+ const x0 = x - w / 2;
855
+ champ(ctx, word[0], x0, y - s / 2 - 4, s, t, t0, word.length);
856
+ write(ctx, word.slice(1), x0 + s + 6, y + 18, FONT.blb(46), C.ink, win(t, t0 + 0.18, t0 + 0.42));
857
+ }
858
+ function folio2(ctx, t) {
859
+ BASE = ctx.getTransform(); NIB = null;
860
+ const [gp, gb] = glintAt(t, [[9.6, 10.3, 0.9]]); setGold(ctx, gp, gb);
861
+ pageBase(ctx, true, 1, 1, 12);
862
+ header(ctx, t);
863
+ const { hx, hy, hr, R } = F2, D2 = Math.PI / 180;
864
+ // compass-ruled circle, pricked at its centre, before the penwork goes over it
865
+ ctx.save(); ctx.strokeStyle = 'rgba(140,100,66,0.35)'; ctx.lineWidth = 1; ctx.beginPath(); ctx.arc(hx, hy, R, 0, TAU); ctx.stroke(); ctx.restore();
866
+ const err = win(t, EX.strike[0], EX.strike[1]) > 0;
867
+ const adj = win(t, EX.gears[0], EX.gears[1]);
868
+ roundel(ctx, hx, hy, hr, 'head', 1, { dy: -0.02, scale: 0.92, mouth: win(t, 7.85, 7.95) - win(t, 8.3, 8.45), look: t > EX.arrow2[0] && t < 7.9 ? -1 : t > EX.point[0] && t < 9.6 ? 0.9 : 0, gear: 0.3 + ez(adj) * 2.4, blink: win(t, 10.35, 10.4) - win(t, 10.45, 10.5) });
869
+ // the new picture
870
+ roundel(ctx, 200, 236, 80, 'cat', win(t, EX.cat2, EX.cat2 + 0.45), { dy: 0.05 });
871
+ penBez(ctx, [[288, 262], [370, 250], [440, 290], [500, 336]], win(t, EX.arrow2[0], EX.arrow2[1]), C.ink, 2.6);
872
+ // the wheel
873
+ penArc(ctx, hx, hy, R, 174 * D2, 243 * D2, win(t, EX.segA[0], EX.segA[1]), C.ink, 3);
874
+ penArc(ctx, hx, hy, R, -63 * D2, 8 * D2, win(t, EX.segB[0], EX.segB[1]), C.ink, 3);
875
+ penArc(ctx, hx, hy, R, 52 * D2, 126 * D2, win(t, EX.segC[0], EX.segC[1]), C.verm, 3.4);
876
+ f2label(ctx, 'Guess', -Math.PI / 2, t, EX.guess);
877
+ f2label(ctx, 'Check', 30 * D2, t, EX.check);
878
+ f2label(ctx, 'Adjust', 150 * D2, t, EX.adjust);
879
+ // the guess, on a banderole from the head's mouth
880
+ const sx = 862, sy = 222, sw = 230, shh = 74, scP = win(t, EX.scroll[0], EX.scroll[1]);
881
+ if (scP > 0) { ctx.save(); ctx.strokeStyle = C.ink; ctx.lineWidth = 1.3; const r0x = hx + Math.cos(-0.5) * hr, r0y = hy + Math.sin(-0.5) * hr; ctx.beginPath(); ctx.moveTo(r0x, r0y); ctx.quadraticCurveTo(800, 300, lerp(r0x, sx + 14, eo(scP)), lerp(r0y, sy + shh - 4, eo(scP))); ctx.stroke(); ctx.beginPath(); ctx.moveTo(r0x, r0y + 7); ctx.quadraticCurveTo(806, 312, lerp(r0x, sx + 14, eo(scP)), lerp(r0y + 7, sy + shh + 6, eo(scP))); ctx.stroke(); ctx.restore(); }
882
+ scroll(ctx, sx, sy, sw, shh, scP);
883
+ write(ctx, 'dog?', sx + sw / 2, sy + 54, FONT.blb(58), C.ink, win(t, EX.dog[0], EX.dog[1]), 'center');
884
+ // the scribe strikes it through in red, rings it, and writes the right word above
885
+ const stP = win(t, EX.strike[0], EX.strike[1]);
886
+ if (stP > 0) { ctx.save(); ctx.strokeStyle = C.verm; ctx.lineWidth = 4.5; ctx.lineCap = 'round'; ctx.beginPath(); ctx.moveTo(sx + 60, sy + 40); ctx.lineTo(lerp(sx + 60, sx + sw - 56, stP), sy + 40 - 6 * stP); ctx.stroke(); ctx.restore(); }
887
+ const rgP = win(t, EX.ring[0], EX.ring[1]);
888
+ if (rgP > 0) { ctx.save(); ctx.strokeStyle = C.verm; ctx.lineWidth = 3.4; ctx.lineCap = 'round'; ctx.beginPath(); ctx.ellipse(sx + sw / 2, sy + shh / 2 + 2, sw * 0.66, shh * 0.95, -0.05, -2.6, -2.6 + rgP * 6.9); ctx.stroke(); ctx.restore(); }
889
+ write(ctx, 'cat', sx + sw / 2 - 12, sy - 22, FONT.blb(58), C.verm, win(t, EX.cat[0], EX.cat[1]), 'center');
890
+ const tk = win(t, EX.tick[0], EX.tick[1]);
891
+ if (tk > 0) { ctx.save(); ctx.strokeStyle = C.mal; ctx.lineWidth = 6; ctx.lineCap = 'round'; ctx.lineJoin = 'round'; ctx.beginPath(); const p1 = [sx + sw / 2 + 50, sy - 44], p2 = [sx + sw / 2 + 62, sy - 30], p3 = [sx + sw / 2 + 92, sy - 74]; ctx.moveTo(...p1); if (tk < 0.4) ctx.lineTo(lerp(p1[0], p2[0], tk / 0.4), lerp(p1[1], p2[1], tk / 0.4)); else { ctx.lineTo(...p2); ctx.lineTo(lerp(p2[0], p3[0], (tk - 0.4) / 0.6), lerp(p2[1], p3[1], (tk - 0.4) / 0.6)); } ctx.stroke(); ctx.restore(); }
892
+ // the error runs back round the wheel to the clockwork
893
+ const dp = win(t, EX.drop[0], EX.drop[1]);
894
+ if (dp > 0 && dp < 1) {
895
+ for (let k = 0; k < 7; k++) {
896
+ const u = dp - k * 0.025; if (u < 0) continue;
897
+ const pos = u < 0.75 ? (() => { const a = (40 + 110 * (u / 0.75)) * D2; return [hx + Math.cos(a) * R, hy + Math.sin(a) * R]; })() : (() => { const a = 150 * D2, v = (u - 0.75) / 0.25; return [hx + Math.cos(a) * lerp(R, hr * 0.5, v), hy + Math.sin(a) * lerp(R, hr * 0.5, v)]; })();
898
+ ctx.fillStyle = H.rgba(C.verm, 1 - k * 0.13); ctx.beginPath(); ctx.arc(pos[0], pos[1], 9 - k, 0, TAU); ctx.fill();
899
+ if (!k) { ctx.strokeStyle = C.ink; ctx.lineWidth = 1; ctx.stroke(); }
900
+ }
901
+ }
902
+ // the drollery in the margin, pointing out the error
903
+ const pt = ez(win(t, EX.point[0], EX.point[1])) - ez(win(t, 10.1, 10.4)) * 0.5;
904
+ const tgt = Math.atan2(sy + shh + 4 - (648 - 0.76 * 150), sx + sw - 70 - (1120 - 0.24 * 150)) + TAU, armA = lerp(2.6, tgt, pt), hx2 = 1120 - 0.24 * 150 + Math.cos(armA) * 75, hy2 = 648 - 0.76 * 150 + Math.sin(armA) * 75;
905
+ const rodL = Math.max(0, Math.hypot(sx + sw - 70 - hx2, sy + shh + 4 - hy2) - 18) * eo(win(t, EX.point[0] + 0.1, EX.point[1] + 0.05)) * (1 - win(t, 10.1, 10.4));
906
+ figure(ctx, 'hare', 1120, 648, 150, 1, 1, { arm: armA + Math.sin(t * 7) * 0.02 * pt, ear: Math.sin(t * 3), rod: rodL });
907
+ if (NIB) quill(ctx, NIB.x, NIB.y, t);
908
+ }
909
+ // --- folio 3
910
+ function folio3(ctx, t) {
911
+ BASE = ctx.getTransform(); NIB = null;
912
+ const [gp, gb] = glintAt(t, [[EX.flare, EX.flare + 0.6, 1.4], [EX.bar0, EX.bar0 + 1.4, 0.5]]); setGold(ctx, gp, gb);
913
+ pageBase(ctx, false, 1, 1, 13);
914
+ header(ctx, t);
915
+ // the heading: a new champ initial blooms
916
+ champ(ctx, 'A', 780, 118, 104, t, EX.acc, 8);
917
+ spray(ctx, 780, 118, win(t, EX.acc + 0.3, EX.acc + 0.9), 33, [-2.4, -1.8, -3.0]);
918
+ write(ctx, 'ccuracy', 892, 206, FONT.blb(76), C.ink, win(t, EX.acc + 0.25, EX.acc + 0.7));
919
+ // the ruled chart
920
+ const fx = 120, fy = 150, fw = 590, fh = 316, base = fy + fh - 12;
921
+ ctx.save(); ctx.strokeStyle = C.verm; ctx.lineWidth = 3; ctx.strokeRect(fx, fy, fw, fh); ctx.lineWidth = 1.1; ctx.strokeRect(fx + 6, fy + 6, fw - 12, fh - 12);
922
+ ctx.strokeStyle = 'rgba(140,100,66,0.35)'; ctx.lineWidth = 1; ctx.beginPath(); for (let k = 1; k < 4; k++) { const y = base - k * 70; ctx.moveTo(fx + 8, y); ctx.lineTo(fx + fw - 8, y); } ctx.stroke(); ctx.restore();
923
+ const romans = ['I', 'II', 'III', 'IV', 'V', 'VI'];
924
+ let shown = 0, tops = [];
925
+ VALS.forEach((v, i) => {
926
+ const bx = fx + 52 + i * 92, a = EX.bar0 + i * EX.barStep, g = eo(win(t, a, a + EX.barRise)), hgt = v / 100 * 280 * g;
927
+ tops.push([bx + 25, base - v / 100 * 280]);
928
+ write(ctx, romans[i], bx + 25, base + 44, FONT.blb(36), C.verm, 1, 'center', { noNib: true });
929
+ if (g <= 0) return;
930
+ gilt(ctx, (c) => { c.beginPath(); c.rect(bx, base - hgt, 50, hgt); }, { lw: 1.1 });
931
+ paint(ctx, (c) => { c.beginPath(); c.rect(bx + 8, base - hgt + 8, 34, Math.max(0, hgt - 16)); }, i % 2 ? C.rose : C.lapis, { edgeW: 2 });
932
+ ctx.fillStyle = 'rgba(250,245,232,0.85)'; for (let y = base - hgt + 18; y < base - 12; y += 16) { ctx.beginPath(); ctx.arc(bx + 25, y, 1.6, 0, TAU); ctx.fill(); }
933
+ bezant(ctx, bx + 25, base - hgt - 8, 7, g);
934
+ shown = i ? lerp(VALS[i - 1], v, g) : v;
935
+ });
936
+ write(ctx, 'rounds of training', fx + fw / 2, base + 86, FONT.felli(36), C.ink, win(t, EX.bar0, EX.bar0 + 0.5), 'center', { noNib: true });
937
+ // the line of progress over the tops
938
+ const lp = win(t, EX.bar0 + 1.25, EX.bar0 + 1.6);
939
+ if (lp > 0) { ctx.save(); ctx.strokeStyle = C.ink; ctx.lineWidth = 2; ctx.setLineDash([]); ctx.beginPath(); const n = (tops.length - 1) * lp; tops.forEach((q, i) => { if (i > Math.ceil(n)) return; const qq = i <= n ? [q[0], q[1] - 24] : [lerp(tops[i - 1][0], q[0], n - i + 1), lerp(tops[i - 1][1], q[1], n - i + 1) - 24]; i ? ctx.lineTo(qq[0], qq[1]) : ctx.moveTo(qq[0], qq[1]); }); ctx.stroke(); ctx.restore(); if (lp >= 1) { const q = tops[5], q0 = tops[4]; arrowHead(ctx, q[0] + 6, q[1] - 26, Math.atan2(q[1] - q0[1], q[0] - q0[0]), 16, C.ink); } }
940
+ // the figure, which becomes gold at 97
941
+ const fl = win(t, EX.flare, EX.flare + 0.5), nx = 1000, ny = 448;
942
+ if (fl > 0) { // rays of glory
943
+ ctx.save(); ctx.translate(nx, ny - 60);
944
+ for (let k = 0; k < 24; k++) { const a = k / 24 * TAU + 0.07, r0 = 150, r1 = r0 + 70 * eo(fl) * (k % 2 ? 0.6 : 1);
945
+ if (k % 2) { ctx.strokeStyle = C.ink; ctx.lineWidth = 1; ctx.beginPath(); for (let s = 0; s <= 10; s++) { const rr = lerp(r0, r1, s / 10), w = Math.sin(s * 1.6) * 3; ctx.lineTo(Math.cos(a) * rr - Math.sin(a) * w, Math.sin(a) * rr * 0.72 + Math.cos(a) * w); } ctx.stroke(); }
946
+ else gilt(ctx, (c) => { c.beginPath(); c.moveTo(Math.cos(a - 0.05) * r0, Math.sin(a - 0.05) * r0 * 0.72); c.lineTo(Math.cos(a) * r1, Math.sin(a) * r1 * 0.72); c.lineTo(Math.cos(a + 0.05) * r0, Math.sin(a + 0.05) * r0 * 0.72); c.closePath(); }, { tex: false, lw: 0.8 }); }
947
+ ctx.restore();
948
+ }
949
+ if (t > EX.bar0) {
950
+ const txt = Math.round(shown) + '%';
951
+ ctx.save(); ctx.font = FONT.fell(184); ctx.textAlign = 'center';
952
+ if (fl > 0) { write(ctx, txt, nx, ny, FONT.fell(184), C.ink, 1, 'center', { gold: true, lw: 2 }); ctx.globalAlpha = 1 - eo(fl); ctx.fillStyle = C.ink; ctx.fillText(txt, nx, ny); }
953
+ else { ctx.fillStyle = C.ink; ctx.fillText(txt, nx, ny); ctx.globalAlpha = 0.2; ctx.fillStyle = '#000'; ctx.fillText(txt, nx + 0.8, ny + 0.6); }
954
+ ctx.restore();
955
+ }
956
+ const cP = win(t, EX.circle[0], EX.circle[1]);
957
+ if (cP > 0) { ctx.save(); ctx.strokeStyle = C.verm; ctx.lineWidth = 4; ctx.lineCap = 'round'; ctx.beginPath(); ctx.ellipse(nx, ny - 60, 190, 112, -0.04, -2.2, -2.2 + cP * 6.75); ctx.stroke(); ctx.lineWidth = 1.5; ctx.beginPath(); ctx.ellipse(nx + 2, ny - 58, 202, 122, -0.03, -2.0, -2.0 + cP * 6.6); ctx.stroke(); ctx.restore(); }
958
+ // burst of light off the burnished gold
959
+ const bl = win(t, EX.flare, EX.flare + 0.12) * (1 - win(t, EX.flare + 0.12, EX.flare + 0.7));
960
+ if (bl > 0) { ctx.save(); ctx.globalCompositeOperation = 'lighter'; const g = ctx.createRadialGradient(nx, ny - 60, 10, nx, ny - 60, 320); g.addColorStop(0, `rgba(255,220,130,${0.5 * bl})`); g.addColorStop(1, 'rgba(255,200,100,0)'); ctx.fillStyle = g; ctx.fillRect(nx - 340, ny - 400, 680, 680); ctx.restore(); }
961
+ // the takeaway, rubricated
962
+ const tw = write(ctx, 'More examples → better guesses', 668, 626, FONT.blb(58), C.verm, win(t, EX.take[0], EX.take[1]), 'center');
963
+ if (t > EX.take[0]) { ctx.save(); ctx.font = FONT.blb(62); ctx.fillStyle = C.lapis; ctx.textAlign = 'right'; ctx.globalAlpha = eo(win(t, EX.take[0], EX.take[0] + 0.15)); ctx.fillText('¶', 668 - tw / 2 - 12, 626); ctx.restore(); }
964
+ const flo = win(t, EX.flourish[0], EX.flourish[1]);
965
+ if (flo > 0) { ctx.save(); ctx.strokeStyle = C.ink; ctx.lineWidth = 1.6; ctx.beginPath(); const x0 = 668 - tw / 2, x1 = x0 + tw * eo(flo); for (let x = x0; x <= x1; x += 4) { const y = 646 + Math.sin((x - x0) * 0.05) * 3; x === x0 ? ctx.moveTo(x, y) : ctx.lineTo(x, y); } ctx.stroke(); ctx.restore(); if (flo >= 1) bezant(ctx, 668 + tw / 2 + 14, 646, 6); }
966
+ if (NIB) quill(ctx, NIB.x, NIB.y, t);
967
+ }
968
+ // --- the leaf turns: a tilted fold sweeps right to left; the lifted part flips over, showing its verso
969
+ let LA = null, LB = null;
970
+ function turnPage(ctx, drawOver, drawUnder, t, p) {
971
+ if (!LA) { LA = H.layer(1280, 720); LB = H.layer(1280, 720); }
972
+ const a = LA.getContext('2d'), b = LB.getContext('2d');
973
+ a.setTransform(1, 0, 0, 1, 0, 0); b.setTransform(1, 0, 0, 1, 0, 0);
974
+ drawOver(a, t); drawUnder(b, t);
975
+ const th = 0.32, nx = Math.cos(th), ny = Math.sin(th), u = H.ease.inOut(p);
976
+ const fxp = lerp(1280 + 380, -420, u), fyp = 360; // a point on the fold
977
+ const half = (c, side) => { // clip to one side of the fold (side 1: right / lifted)
978
+ const L = 3000, tx = -ny, ty = nx; c.beginPath();
979
+ c.moveTo(fxp + tx * L, fyp + ty * L); c.lineTo(fxp - tx * L, fyp - ty * L); c.lineTo(fxp - tx * L + side * nx * L, fyp - ty * L + side * ny * L); c.lineTo(fxp + tx * L + side * nx * L, fyp + ty * L + side * ny * L); c.closePath(); c.clip();
980
+ };
981
+ ctx.save(); half(ctx, -1); ctx.drawImage(LA, 0, 0); ctx.restore();
982
+ ctx.save(); half(ctx, 1); ctx.drawImage(LB, 0, 0);
983
+ const sg = ctx.createLinearGradient(fxp, fyp, fxp + nx * 140, fyp + ny * 140); sg.addColorStop(0, 'rgba(50,28,10,0.45)'); sg.addColorStop(1, 'rgba(50,28,10,0)'); ctx.fillStyle = sg; ctx.fillRect(0, 0, 1280, 720);
984
+ ctx.restore();
985
+ // the flap: page reflected about the fold
986
+ const d = fxp * nx + fyp * ny, m = [1 - 2 * nx * nx, -2 * nx * ny, -2 * nx * ny, 1 - 2 * ny * ny, 2 * d * nx, 2 * d * ny];
987
+ ctx.save(); half(ctx, -1);
988
+ ctx.save(); ctx.transform(...m);
989
+ ctx.shadowColor = 'rgba(40,20,5,0.45)'; ctx.shadowBlur = 30; ctx.shadowOffsetX = 0; ctx.shadowOffsetY = 0;
990
+ ctx.beginPath(); ctx.rect(0, 0, 1280, 720); ctx.fillStyle = 'rgb(226,208,170)'; ctx.fill(); ctx.shadowColor = 'transparent';
991
+ ctx.clip(); ctx.globalAlpha = 0.9; ctx.drawImage(vellum(), 0, 0); ctx.globalAlpha = 0.1; ctx.drawImage(LA, 0, 0); ctx.globalAlpha = 1;
992
+ ctx.restore();
993
+ const hg = ctx.createLinearGradient(fxp, fyp, fxp - nx * 260, fyp - ny * 260); hg.addColorStop(0, 'rgba(255,248,225,0.35)'); hg.addColorStop(0.15, 'rgba(255,248,225,0.12)'); hg.addColorStop(1, 'rgba(60,35,10,0.18)');
994
+ ctx.fillStyle = hg; ctx.save(); ctx.transform(...m); ctx.beginPath(); ctx.rect(0, 0, 1280, 720); ctx.restore(); ctx.fill();
995
+ ctx.restore();
996
+ }
997
+ function explainer(ctx, W, H_, t) {
998
+ const [a1, b1] = EX.turn1, [a2, b2] = EX.turn2;
999
+ if (t < a1) folio1(ctx, t);
1000
+ else if (t < b1) turnPage(ctx, folio1, folio2, t, win(t, a1, b1));
1001
+ else if (t < a2) folio2(ctx, t);
1002
+ else if (t < b2) turnPage(ctx, folio2, folio3, t, win(t, a2, b2));
1003
+ else folio3(ctx, t);
1004
+ H.vignette(ctx, W, H_, 0.26, '60,35,10');
1005
+ }
1006
+
1007
+
1008
+ // =====================================================================================================
1009
+ // SOUND: a quiet scriptorium. Quill on vellum while the scribe writes, soft burnishing for gold, the leaf
1010
+ // turning between folios, a low chant-like drone, and a warm church bell for 97% and the takeaway.
1011
+ // All times come from EX (the explainer's timeline).
1012
+ // =====================================================================================================
1013
+ function explainerSound(k) {
1014
+ const quill = (a, b, gain = 1, minor = true, pan = 0) => { // goose quill on vellum: a dry scratch with a soft body
1015
+ const d = Math.max(0.05, b - a);
1016
+ k.noise(a, { dur: 0.02, filter: 'bandpass', f: 2100, q: 1.2, gain: 0.12 * gain, a: 0.002, pan, minor }); // nib touches down
1017
+ k.play('stroke', a, { material: 'pen', dur: d, gain: 2.1 * gain, pan, minor });
1018
+ k.noise(a, { dur: d + 0.03, color: 'pink', filter: 'bandpass', f: 1500, q: 0.8, gain: 0.05 * gain, a: Math.min(0.02, d * 0.3), pan, minor });
1019
+ };
1020
+ const writeS = (str, a, b, gain = 1, minor = true, pan = 0) => { // one quill stroke per word, timed like write()
1021
+ const n = str.length, re = /\S+/g; let m;
1022
+ while ((m = re.exec(str))) quill(a + (b - a) * m.index / n, a + (b - a) * (m.index + m[0].length) / n, gain, minor, pan);
1023
+ };
1024
+ const shimmer = (t, dur, gain = 1, minor = false, pan = 0) => { // agate burnisher on gold: a soft rub with a low glow
1025
+ k.noise(t, { dur, color: 'pink', filter: 'bandpass', f: [[0, 650], [dur, 1300]], q: 1.6, gain: 0.09 * gain, a: dur * 0.4, verb: 0.3, pan, minor });
1026
+ k.tone(t, { f: 'A4', dur: dur + 0.7, gain: 0.022 * gain, a: dur * 0.5, verb: 0.4, pan, minor });
1027
+ k.tone(t + 0.05, { f: 'E5', dur: dur + 0.5, gain: 0.014 * gain, a: dur * 0.5, verb: 0.4, pan, minor });
1028
+ };
1029
+ const dab = (t, gain = 1, pan = 0) => k.play('stroke', t, { material: 'brush', dur: 0.16, gain: 1.3 * gain, pan, minor: true }); // pigment laid in
1030
+ const bell = (t, root, gain = 1) => { // church bell partials: hum, prime, tierce, quint, nominal
1031
+ const f = k.hz(root);
1032
+ [[0.5, 0.11, 3.2], [1, 0.15, 2.6], [1.2, 0.07, 1.8], [1.5, 0.05, 1.5], [2, 0.08, 1.4]].forEach(([r, g, d]) => k.tone(t, { f: f * r, dur: d, gain: g * gain, a: 0.004, verb: 0.45 }));
1033
+ k.noise(t, { dur: 0.03, filter: 'bandpass', f: 1400, q: 1.5, gain: 0.1 * gain });
1034
+ };
1035
+ const turn = (a, b) => { // the leaf lifts, sweeps over and settles
1036
+ const d = b - a;
1037
+ k.play('paper', a, { dur: d * 0.9, gain: 0.6 });
1038
+ k.noise(a, { dur: d, color: 'pink', filter: 'lowpass', f: [[0, 350], [d * 0.6, 1100], [d, 450]], gain: 0.14, a: d * 0.5 });
1039
+ k.play('slap', b - 0.06, { gain: 0.22 });
1040
+ };
1041
+
1042
+ k.bed('room', 0, EX.D, { gain: 0.45 });
1043
+ k.music('pad', 0, EX.D, { bpm: 48, gain: 0.3, chords: [['D3', 'A3', 'D4', 'F4'], ['C3', 'G3', 'C4', 'E4'], ['D3', 'A3', 'D4', 'A4']] });
1044
+
1045
+ // ---- folio 1: the question
1046
+ dab(0.0, 1.1); shimmer(0.2, 0.4, 0.9); // H: ground floods, gold letter laid
1047
+ writeS(HOOK.map((x) => x.s).join(''), EX.hookW[0], EX.hookW[1], 1.5, false);
1048
+ shimmer(1.6, 0.5, 1.0); // the burnish glint crosses the H
1049
+ k.noise(EX.hookShrink[0], { dur: 0.6, color: 'brown', filter: 'lowpass', f: 480, gain: 0.12, a: 0.25, minor: true }); // slides into the running title
1050
+ // the bestiary: each roundel is laid in, its label written
1051
+ for (let i = 0; i < 6; i++) { const a = EX.gridT0 + i * EX.gridStep; dab(a + 0.05, 0.9, -0.4 + (i % 3) * 0.1); writeS(i % 2 ? 'dog' : 'cat', a + 0.4, a + 0.6, 0.8, true, -0.3); }
1052
+ shimmer(EX.headR[0], 0.4, 0.8, true, 0.3); // gold ring round the Brazen Head
1053
+ writeS('the Model', EX.model[0], EX.model[1], 1.0, false, 0.3);
1054
+ quill(EX.arrow1[0], EX.arrow1[1], 1.1);
1055
+ quill(EX.count[0] - 0.25, EX.count[0], 0.8); // cartouche ruled
1056
+ for (let i = 0; i < 9; i++) k.play('tock', EX.fly[0] + i * 0.18 + 0.62, { f: 420 + (i % 3) * 40, gain: 0.3, pan: 0.35, minor: true }); // examples drop into the head
1057
+ for (let f = Math.ceil(EX.count[0] * 10); f < EX.count[1] * 10 - 1; f++) k.play('tick', f / 10, { f: 2500, gain: 1.2, pan: 0.1, minor: true });
1058
+ k.play('tock', EX.count[1], { f: 330, gain: 0.45 }); k.play('thud', EX.count[1], { f: 110, gain: 0.2 }); // 1,000,000 lands
1059
+
1060
+ turn(...EX.turn1);
1061
+
1062
+ // ---- folio 2: guess, check, adjust
1063
+ dab(EX.cat2 + 0.05, 1.0, -0.5); shimmer(EX.cat2, 0.3, 0.6, true, -0.5);
1064
+ quill(EX.arrow2[0], EX.arrow2[1], 0.9, true, -0.3);
1065
+ quill(EX.segA[0], EX.segA[1], 0.9, true, -0.2);
1066
+ shimmer(EX.guess + 0.15, 0.3, 0.6, true); writeS('uess', EX.guess + 0.18, EX.guess + 0.42, 0.9);
1067
+ k.play('paper', EX.scroll[0], { dur: 0.3, gain: 0.45 }); // the banderole unrolls
1068
+ k.play('buzz', EX.dog[0] - 0.08, { f: 98, dur: 0.38, gain: 0.45 }); // the brazen head speaks
1069
+ writeS('dog?', EX.dog[0], EX.dog[1], 1.1, false, 0.4);
1070
+ quill(EX.segB[0], EX.segB[1], 0.9, true, 0.2);
1071
+ shimmer(EX.check + 0.15, 0.3, 0.6, true, 0.3); writeS('heck', EX.check + 0.18, EX.check + 0.42, 0.9, true, 0.3);
1072
+ k.noise(EX.point[0], { dur: 0.3, color: 'pink', filter: 'bandpass', f: [[0, 380], [0.3, 900]], q: 1, gain: 0.14, a: 0.12, pan: 0.6 }); // the beast swings its staff up
1073
+ k.play('tock', EX.point[1] + 0.03, { f: 520, gain: 0.4, pan: 0.5 });
1074
+ // the wrong guess: a hard red slash, a low dull "no"
1075
+ k.play('stroke', EX.strike[0], { material: 'pen', dur: EX.strike[1] - EX.strike[0], gain: 2.4, pan: 0.4 });
1076
+ k.play('thud', EX.strike[0], { f: 120, gain: 0.38 });
1077
+ k.tone(EX.strike[0], { f: 'D3', dur: 0.45, gain: 0.12, a: 0.01, filter: 'lowpass', f2: 900, type: 'triangle' });
1078
+ k.tone(EX.strike[0], { f: 'G#3', dur: 0.45, gain: 0.1, a: 0.01, filter: 'lowpass', f2: 900, type: 'triangle' });
1079
+ quill(EX.ring[0], EX.ring[1], 1.4, false, 0.4); // ringed in red
1080
+ // the error runs back round the wheel to the clockwork
1081
+ quill(EX.segC[0], EX.segC[1], 1.0, true, 0);
1082
+ k.tone(EX.drop[0], { f: [[0, 330], [EX.drop[1] - EX.drop[0], 140]], type: 'triangle', dur: EX.drop[1] - EX.drop[0], gain: 0.07, a: 0.1, filter: 'lowpass', f2: 800 });
1083
+ shimmer(EX.adjust + 0.15, 0.3, 0.6, true, -0.3); writeS('djust', EX.adjust + 0.18, EX.adjust + 0.42, 0.9, true, -0.3);
1084
+ for (let i = 0, x = EX.gears[0]; x < EX.gears[1]; i++, x += 0.065 + i * 0.004) { k.play('click', x, { f: 900, gain: 0.45, minor: true }); if (i % 3 === 0) k.play('tock', x, { f: 260, gain: 0.25, minor: true }); }
1085
+ writeS('cat', EX.cat[0], EX.cat[1], 1.3, false, 0.4); // the correction, in red
1086
+ quill(EX.tick[0], EX.tick[1], 1.2, false, 0.5);
1087
+ k.play('success', EX.tick[1], { f: 'D5', gain: 0.4, pan: 0.3 });
1088
+
1089
+ turn(...EX.turn2);
1090
+
1091
+ // ---- folio 3: the gilded chart
1092
+ shimmer(EX.acc + 0.15, 0.35, 0.8, false, 0.4); writeS('ccuracy', EX.acc + 0.25, EX.acc + 0.7, 0.9, true, 0.4);
1093
+ writeS('rounds of training', EX.bar0, EX.bar0 + 0.5, 0.6, true, -0.4);
1094
+ for (let i = 0; i < 6; i++) { const a = EX.bar0 + i * EX.barStep; shimmer(a, EX.barRise, 0.45, true, -0.4 + i * 0.08); k.play('tock', a + EX.barRise, { f: 300 + i * 45, gain: 0.35, pan: -0.4 + i * 0.08, minor: true }); }
1095
+ { let last = -1; for (let f = Math.ceil(EX.bar0 * 10); f < EX.flare * 10 - 1; f++) { // the figure counts up (throttled)
1096
+ const t = f / 10, i = Math.min(5, Math.floor((t - EX.bar0) / EX.barStep)), g = cl((t - EX.bar0 - i * EX.barStep) / EX.barRise), v = Math.round(i ? lerp(VALS[i - 1], VALS[i], g) : VALS[0]);
1097
+ if (v !== last) { k.play('tick', t, { f: 2100 + v * 4, gain: 1.2, pan: 0.4, minor: true }); last = v; } } }
1098
+ quill(EX.bar0 + 1.25, EX.bar0 + 1.6, 0.8, true, -0.3);
1099
+ // 97%: the gold flares, the biggest moment
1100
+ k.play('thud', EX.flare, { f: 85, gain: 0.75, pan: 0.3 });
1101
+ bell(EX.flare, 'D4', 1.35);
1102
+ shimmer(EX.flare, 0.6, 1.6, false, 0.3);
1103
+ quill(EX.circle[0], EX.circle[1], 1.3, false, 0.35);
1104
+ // the takeaway, rubricated, then the closing bell
1105
+ writeS('More examples → better guesses', EX.take[0], EX.take[1], 1.4, false);
1106
+ bell(EX.take[1] + 0.02, 'G3', 0.85);
1107
+ quill(EX.flourish[0], EX.flourish[1], 0.9, true);
1108
+ }
1109
+
1110
+ registerStyle({
1111
+ id: 'illuminated',
1112
+ name: 'Illuminated Manuscript',
1113
+ category: 'Illustration',
1114
+ description: 'A Book of Hours folio: mottled vellum with ruling and pricking, textura in iron-gall ink with vermilion rubrics, a historiated initial on raised burnished gold, lapis, rose and malachite with white-lead filigree, ivy-leaf rinceaux with gold bezants, and drolleries in the margins.',
1115
+ motion: 'The scribe works the page: gold leaf is laid square by square and burnished to a travelling glint, pigments flood into the pen outlines, and the quill writes the text line by line.',
1116
+ fonts: ['400 31px "Grenze Gotisch"', '700 84px "Grenze Gotisch"', '400 30px "UnifrakturMaguntia"', '400 80px "IM Fell English"', 'italic 400 32px "IM Fell English"'],
1117
+ frameT: 5.8,
1118
+ duration: 6,
1119
+ readsPixels: false,
1120
+ draw(ctx, W, H_, t) { drawStill(ctx, t); },
1121
+ explainerDuration: EX.D,
1122
+ explainerNote: 'Three folios of a manuscript, the leaf turning between them: champ initials bloom in gold, the examples are bestiary roundels flowing along a penwork arrow into a Brazen Head, the learning loop is a wheel of Guess, Check and Adjust where a marginal beast points out the error and the scribe corrects it in red, and accuracy rises as gilded bars until 97% turns to burnished gold.',
1123
+ explainer,
1124
+ explainerSound,
1125
+ });
1126
+ }