@bydiorama/motion 0.0.0-stage → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (354) hide show
  1. package/CREDITS.md +62 -0
  2. package/LICENSE +21 -0
  3. package/README.md +142 -2
  4. package/catalog.json +4697 -0
  5. package/dist/npm/brief/brief.d.ts +28 -0
  6. package/dist/npm/brief/brief.js +159 -0
  7. package/dist/npm/brief/types.d.ts +75 -0
  8. package/dist/npm/brief/types.js +2 -0
  9. package/dist/npm/browser/motion.js +1039 -0
  10. package/dist/npm/browser/page.js +4821 -0
  11. package/dist/npm/browser/wizard.js +1511 -0
  12. package/dist/npm/build/design.d.ts +54 -0
  13. package/dist/npm/build/design.js +91 -0
  14. package/dist/npm/build/index.d.ts +39 -0
  15. package/dist/npm/build/index.js +66 -0
  16. package/dist/npm/build/iso.d.ts +41 -0
  17. package/dist/npm/build/iso.js +71 -0
  18. package/dist/npm/catalog.d.ts +24 -0
  19. package/dist/npm/catalog.js +23 -0
  20. package/dist/npm/cli/browser.d.ts +26 -0
  21. package/dist/npm/cli/browser.js +66 -0
  22. package/dist/npm/cli/capture.d.ts +26 -0
  23. package/dist/npm/cli/capture.js +94 -0
  24. package/dist/npm/cli/files.d.ts +14 -0
  25. package/dist/npm/cli/files.js +87 -0
  26. package/dist/npm/cli/frames.d.ts +27 -0
  27. package/dist/npm/cli/frames.js +125 -0
  28. package/dist/npm/cli/guard.d.ts +23 -0
  29. package/dist/npm/cli/guard.js +158 -0
  30. package/dist/npm/cli/library.d.ts +2 -0
  31. package/dist/npm/cli/library.js +55 -0
  32. package/dist/npm/cli/main.d.ts +17 -0
  33. package/dist/npm/cli/main.js +964 -0
  34. package/dist/npm/cli/motion.d.ts +2 -0
  35. package/dist/npm/cli/motion.js +6 -0
  36. package/dist/npm/cli/record.d.ts +36 -0
  37. package/dist/npm/cli/record.js +142 -0
  38. package/dist/npm/cli/review.d.ts +45 -0
  39. package/dist/npm/cli/review.js +139 -0
  40. package/dist/npm/cli/schema.d.ts +852 -0
  41. package/dist/npm/cli/schema.js +120 -0
  42. package/dist/npm/cli/server.d.ts +17 -0
  43. package/dist/npm/cli/server.js +135 -0
  44. package/dist/npm/core/ease.d.ts +39 -0
  45. package/dist/npm/core/ease.js +176 -0
  46. package/dist/npm/core/frame.d.ts +52 -0
  47. package/dist/npm/core/frame.js +60 -0
  48. package/dist/npm/core/shapes.d.ts +8 -0
  49. package/dist/npm/core/shapes.js +88 -0
  50. package/dist/npm/core/stagger.d.ts +19 -0
  51. package/dist/npm/core/stagger.js +77 -0
  52. package/dist/npm/core/tap.d.ts +19 -0
  53. package/dist/npm/core/tap.js +42 -0
  54. package/dist/npm/core/track.d.ts +4 -0
  55. package/dist/npm/core/track.js +23 -0
  56. package/dist/npm/dom/mount.d.ts +127 -0
  57. package/dist/npm/dom/mount.js +950 -0
  58. package/dist/npm/dom/page.d.ts +37 -0
  59. package/dist/npm/dom/page.js +77 -0
  60. package/dist/npm/dom/soundtrack.d.ts +13 -0
  61. package/dist/npm/dom/soundtrack.js +37 -0
  62. package/dist/npm/dom/stage.css.d.ts +1 -0
  63. package/dist/npm/dom/stage.css.js +44 -0
  64. package/dist/npm/dom/tokens.d.ts +10 -0
  65. package/dist/npm/dom/tokens.js +38 -0
  66. package/dist/npm/dom/ui-themes.css.d.ts +8 -0
  67. package/dist/npm/dom/ui-themes.css.js +9 -0
  68. package/dist/npm/film/beats.d.ts +64 -0
  69. package/dist/npm/film/beats.js +282 -0
  70. package/dist/npm/film/pace.d.ts +94 -0
  71. package/dist/npm/film/pace.js +396 -0
  72. package/dist/npm/film/resolve.d.ts +16 -0
  73. package/dist/npm/film/resolve.js +997 -0
  74. package/dist/npm/film/tempo.d.ts +19 -0
  75. package/dist/npm/film/tempo.js +34 -0
  76. package/dist/npm/film/tune.d.ts +17 -0
  77. package/dist/npm/film/tune.js +68 -0
  78. package/dist/npm/film/types.d.ts +416 -0
  79. package/dist/npm/film/types.js +16 -0
  80. package/dist/npm/index.d.ts +18 -0
  81. package/dist/npm/index.js +11 -0
  82. package/dist/npm/primitives/blur.d.ts +14 -0
  83. package/dist/npm/primitives/blur.js +59 -0
  84. package/dist/npm/primitives/canvas.d.ts +5 -0
  85. package/dist/npm/primitives/canvas.js +13 -0
  86. package/dist/npm/primitives/el/box.d.ts +2 -0
  87. package/dist/npm/primitives/el/box.js +24 -0
  88. package/dist/npm/primitives/el/frames.d.ts +15 -0
  89. package/dist/npm/primitives/el/frames.js +71 -0
  90. package/dist/npm/primitives/el/html.d.ts +2 -0
  91. package/dist/npm/primitives/el/html.js +14 -0
  92. package/dist/npm/primitives/el/image.d.ts +2 -0
  93. package/dist/npm/primitives/el/image.js +43 -0
  94. package/dist/npm/primitives/el/slot.d.ts +2 -0
  95. package/dist/npm/primitives/el/slot.js +25 -0
  96. package/dist/npm/primitives/el/text.d.ts +2 -0
  97. package/dist/npm/primitives/el/text.js +13 -0
  98. package/dist/npm/primitives/el/video.d.ts +6 -0
  99. package/dist/npm/primitives/el/video.js +179 -0
  100. package/dist/npm/primitives/fx/counter-roll.d.ts +2 -0
  101. package/dist/npm/primitives/fx/counter-roll.js +32 -0
  102. package/dist/npm/primitives/fx/depth-drift.d.ts +2 -0
  103. package/dist/npm/primitives/fx/depth-drift.js +44 -0
  104. package/dist/npm/primitives/fx/grid-ripple.d.ts +2 -0
  105. package/dist/npm/primitives/fx/grid-ripple.js +59 -0
  106. package/dist/npm/primitives/fx/odometer.d.ts +2 -0
  107. package/dist/npm/primitives/fx/odometer.js +80 -0
  108. package/dist/npm/primitives/fx/pan-across.d.ts +17 -0
  109. package/dist/npm/primitives/fx/pan-across.js +76 -0
  110. package/dist/npm/primitives/fx/path-draw.d.ts +2 -0
  111. package/dist/npm/primitives/fx/path-draw.js +105 -0
  112. package/dist/npm/primitives/fx/pin-drop.d.ts +2 -0
  113. package/dist/npm/primitives/fx/pin-drop.js +92 -0
  114. package/dist/npm/primitives/fx/shape-morph.d.ts +2 -0
  115. package/dist/npm/primitives/fx/shape-morph.js +65 -0
  116. package/dist/npm/primitives/fx/slow-push.d.ts +13 -0
  117. package/dist/npm/primitives/fx/slow-push.js +56 -0
  118. package/dist/npm/primitives/fx/stagger-fill.d.ts +2 -0
  119. package/dist/npm/primitives/fx/stagger-fill.js +33 -0
  120. package/dist/npm/primitives/index.d.ts +4 -0
  121. package/dist/npm/primitives/index.js +78 -0
  122. package/dist/npm/primitives/rig/browser-window.d.ts +2 -0
  123. package/dist/npm/primitives/rig/browser-window.js +142 -0
  124. package/dist/npm/primitives/rig/camera.d.ts +36 -0
  125. package/dist/npm/primitives/rig/camera.js +81 -0
  126. package/dist/npm/primitives/rig/footage-plane.d.ts +27 -0
  127. package/dist/npm/primitives/rig/footage-plane.js +257 -0
  128. package/dist/npm/primitives/rig/layer-stack.d.ts +39 -0
  129. package/dist/npm/primitives/rig/layer-stack.js +276 -0
  130. package/dist/npm/primitives/rig/orbit-ring.d.ts +2 -0
  131. package/dist/npm/primitives/rig/orbit-ring.js +59 -0
  132. package/dist/npm/primitives/rig/tab-stack.d.ts +9 -0
  133. package/dist/npm/primitives/rig/tab-stack.js +143 -0
  134. package/dist/npm/primitives/scene/bar-chart.d.ts +2 -0
  135. package/dist/npm/primitives/scene/bar-chart.js +83 -0
  136. package/dist/npm/primitives/scene/bento-grid.d.ts +49 -0
  137. package/dist/npm/primitives/scene/bento-grid.js +293 -0
  138. package/dist/npm/primitives/scene/grid-wall.d.ts +18 -0
  139. package/dist/npm/primitives/scene/grid-wall.js +110 -0
  140. package/dist/npm/primitives/scene/line-chart.d.ts +2 -0
  141. package/dist/npm/primitives/scene/line-chart.js +121 -0
  142. package/dist/npm/primitives/scene/logo-reveal.d.ts +2 -0
  143. package/dist/npm/primitives/scene/logo-reveal.js +117 -0
  144. package/dist/npm/primitives/scene/marquee-wall.d.ts +2 -0
  145. package/dist/npm/primitives/scene/marquee-wall.js +82 -0
  146. package/dist/npm/primitives/scene/post-carousel.d.ts +16 -0
  147. package/dist/npm/primitives/scene/post-carousel.js +195 -0
  148. package/dist/npm/primitives/scene/strip-cycle.d.ts +49 -0
  149. package/dist/npm/primitives/scene/strip-cycle.js +237 -0
  150. package/dist/npm/primitives/split.d.ts +34 -0
  151. package/dist/npm/primitives/split.js +105 -0
  152. package/dist/npm/primitives/texture/beat-field.d.ts +13 -0
  153. package/dist/npm/primitives/texture/beat-field.js +113 -0
  154. package/dist/npm/primitives/texture/gradient-drift.d.ts +2 -0
  155. package/dist/npm/primitives/texture/gradient-drift.js +56 -0
  156. package/dist/npm/primitives/texture/grain.d.ts +2 -0
  157. package/dist/npm/primitives/texture/grain.js +54 -0
  158. package/dist/npm/primitives/texture/halftone-field.d.ts +2 -0
  159. package/dist/npm/primitives/texture/halftone-field.js +36 -0
  160. package/dist/npm/primitives/texture/signal-field.d.ts +4 -0
  161. package/dist/npm/primitives/texture/signal-field.js +107 -0
  162. package/dist/npm/primitives/texture/vignette.d.ts +2 -0
  163. package/dist/npm/primitives/texture/vignette.js +23 -0
  164. package/dist/npm/primitives/transition/band-sweep.d.ts +22 -0
  165. package/dist/npm/primitives/transition/band-sweep.js +111 -0
  166. package/dist/npm/primitives/transition/beat-cut.d.ts +2 -0
  167. package/dist/npm/primitives/transition/beat-cut.js +10 -0
  168. package/dist/npm/primitives/transition/blur-dissolve.d.ts +2 -0
  169. package/dist/npm/primitives/transition/blur-dissolve.js +28 -0
  170. package/dist/npm/primitives/transition/camera-travel.d.ts +2 -0
  171. package/dist/npm/primitives/transition/camera-travel.js +69 -0
  172. package/dist/npm/primitives/transition/cover-reveal.d.ts +2 -0
  173. package/dist/npm/primitives/transition/cover-reveal.js +52 -0
  174. package/dist/npm/primitives/transition/curtain.d.ts +2 -0
  175. package/dist/npm/primitives/transition/curtain.js +40 -0
  176. package/dist/npm/primitives/transition/dive-in.d.ts +2 -0
  177. package/dist/npm/primitives/transition/dive-in.js +52 -0
  178. package/dist/npm/primitives/transition/fly-past.d.ts +2 -0
  179. package/dist/npm/primitives/transition/fly-past.js +87 -0
  180. package/dist/npm/primitives/transition/iris.d.ts +2 -0
  181. package/dist/npm/primitives/transition/iris.js +38 -0
  182. package/dist/npm/primitives/transition/overlay.d.ts +4 -0
  183. package/dist/npm/primitives/transition/overlay.js +24 -0
  184. package/dist/npm/primitives/transition/push.d.ts +2 -0
  185. package/dist/npm/primitives/transition/push.js +35 -0
  186. package/dist/npm/primitives/transition/signal-wipe.d.ts +2 -0
  187. package/dist/npm/primitives/transition/signal-wipe.js +67 -0
  188. package/dist/npm/primitives/transition/slant-wipe.d.ts +2 -0
  189. package/dist/npm/primitives/transition/slant-wipe.js +30 -0
  190. package/dist/npm/primitives/transition/stack-over.d.ts +2 -0
  191. package/dist/npm/primitives/transition/stack-over.js +38 -0
  192. package/dist/npm/primitives/transition/step-wipe.d.ts +2 -0
  193. package/dist/npm/primitives/transition/step-wipe.js +29 -0
  194. package/dist/npm/primitives/transition/strip-wipe.d.ts +40 -0
  195. package/dist/npm/primitives/transition/strip-wipe.js +121 -0
  196. package/dist/npm/primitives/transition/whip-pan.d.ts +2 -0
  197. package/dist/npm/primitives/transition/whip-pan.js +45 -0
  198. package/dist/npm/primitives/type/block-reveal.d.ts +2 -0
  199. package/dist/npm/primitives/type/block-reveal.js +61 -0
  200. package/dist/npm/primitives/type/char-cascade.d.ts +2 -0
  201. package/dist/npm/primitives/type/char-cascade.js +45 -0
  202. package/dist/npm/primitives/type/echo.d.ts +2 -0
  203. package/dist/npm/primitives/type/echo.js +57 -0
  204. package/dist/npm/primitives/type/fill-text.d.ts +14 -0
  205. package/dist/npm/primitives/type/fill-text.js +82 -0
  206. package/dist/npm/primitives/type/mask-reveal.d.ts +2 -0
  207. package/dist/npm/primitives/type/mask-reveal.js +58 -0
  208. package/dist/npm/primitives/type/scramble.d.ts +2 -0
  209. package/dist/npm/primitives/type/scramble.js +34 -0
  210. package/dist/npm/primitives/type/scribble-highlight.d.ts +2 -0
  211. package/dist/npm/primitives/type/scribble-highlight.js +84 -0
  212. package/dist/npm/primitives/type/shimmer.d.ts +2 -0
  213. package/dist/npm/primitives/type/shimmer.js +35 -0
  214. package/dist/npm/primitives/type/tracking-in.d.ts +2 -0
  215. package/dist/npm/primitives/type/tracking-in.js +37 -0
  216. package/dist/npm/primitives/type/typed-title.d.ts +2 -0
  217. package/dist/npm/primitives/type/typed-title.js +33 -0
  218. package/dist/npm/primitives/type/word-build.d.ts +2 -0
  219. package/dist/npm/primitives/type/word-build.js +44 -0
  220. package/dist/npm/primitives/type/word-roller.d.ts +2 -0
  221. package/dist/npm/primitives/type/word-roller.js +80 -0
  222. package/dist/npm/primitives/types.d.ts +183 -0
  223. package/dist/npm/primitives/types.js +5 -0
  224. package/dist/npm/primitives/ui/cursor-click.d.ts +4 -0
  225. package/dist/npm/primitives/ui/cursor-click.js +68 -0
  226. package/dist/npm/primitives/ui/page-scroll.d.ts +17 -0
  227. package/dist/npm/primitives/ui/page-scroll.js +98 -0
  228. package/dist/npm/review/fft.d.ts +4 -0
  229. package/dist/npm/review/fft.js +71 -0
  230. package/dist/npm/review/measure.d.ts +170 -0
  231. package/dist/npm/review/measure.js +577 -0
  232. package/dist/npm/tokens.d.ts +50 -0
  233. package/dist/npm/tokens.js +49 -0
  234. package/dist/npm/version.d.ts +1 -0
  235. package/dist/npm/version.js +1 -0
  236. package/examples/builder.film.mjs +18 -0
  237. package/films/feature-announcement.film.json +70 -0
  238. package/library/narratives/app-demo.md +64 -0
  239. package/library/narratives/brand-identity.md +78 -0
  240. package/library/narratives/capability-through-type.md +53 -0
  241. package/library/narratives/data-story.md +59 -0
  242. package/library/narratives/explainer.md +64 -0
  243. package/library/narratives/feature-announcement.md +68 -0
  244. package/library/narratives/infinite-loop.md +28 -0
  245. package/library/narratives/platform-launch.md +81 -0
  246. package/library/narratives/social-teaser.md +45 -0
  247. package/library/narratives/title-sequence.md +55 -0
  248. package/library/narratives/website-launch.md +65 -0
  249. package/library/primitives/fx/card-arrangements.md +26 -0
  250. package/library/primitives/fx/counter-roll.md +27 -0
  251. package/library/primitives/fx/depth-drift.md +32 -0
  252. package/library/primitives/fx/grid-ripple.md +58 -0
  253. package/library/primitives/fx/letter-interleave.md +26 -0
  254. package/library/primitives/fx/marquee-highlight.md +27 -0
  255. package/library/primitives/fx/mosaic-fill.md +23 -0
  256. package/library/primitives/fx/odometer.md +44 -0
  257. package/library/primitives/fx/pan-across.md +63 -0
  258. package/library/primitives/fx/path-draw.md +54 -0
  259. package/library/primitives/fx/pin-drop.md +51 -0
  260. package/library/primitives/fx/radial-burst.md +33 -0
  261. package/library/primitives/fx/shape-morph.md +45 -0
  262. package/library/primitives/fx/slow-push.md +63 -0
  263. package/library/primitives/fx/stagger-fill.md +28 -0
  264. package/library/primitives/rig/browser-window.md +113 -0
  265. package/library/primitives/rig/flip-ticker.md +26 -0
  266. package/library/primitives/rig/footage-plane.md +90 -0
  267. package/library/primitives/rig/layer-stack.md +168 -0
  268. package/library/primitives/rig/orbit-ring.md +43 -0
  269. package/library/primitives/rig/rolodex.md +31 -0
  270. package/library/primitives/rig/tab-stack.md +116 -0
  271. package/library/primitives/rig/tumbling-object.md +27 -0
  272. package/library/primitives/scene/bar-chart.md +49 -0
  273. package/library/primitives/scene/bento-grid.md +74 -0
  274. package/library/primitives/scene/end-card.md +28 -0
  275. package/library/primitives/scene/grid-wall.md +61 -0
  276. package/library/primitives/scene/hero-object.md +33 -0
  277. package/library/primitives/scene/kinetic-headline.md +34 -0
  278. package/library/primitives/scene/line-chart.md +47 -0
  279. package/library/primitives/scene/logo-reveal.md +53 -0
  280. package/library/primitives/scene/marquee-wall.md +33 -0
  281. package/library/primitives/scene/mosaic.md +28 -0
  282. package/library/primitives/scene/post-carousel.md +68 -0
  283. package/library/primitives/scene/specimen-grid.md +28 -0
  284. package/library/primitives/scene/stat-with-evidence.md +34 -0
  285. package/library/primitives/scene/strip-cycle.md +122 -0
  286. package/library/primitives/scene/zoomed-ui.md +29 -0
  287. package/library/primitives/texture/ascii.md +22 -0
  288. package/library/primitives/texture/beat-field.md +85 -0
  289. package/library/primitives/texture/depth-fade.md +23 -0
  290. package/library/primitives/texture/dither.md +27 -0
  291. package/library/primitives/texture/gradient-drift.md +50 -0
  292. package/library/primitives/texture/grain.md +39 -0
  293. package/library/primitives/texture/halftone-field.md +26 -0
  294. package/library/primitives/texture/signal-field.md +61 -0
  295. package/library/primitives/texture/vignette.md +53 -0
  296. package/library/primitives/transition/band-sweep.md +63 -0
  297. package/library/primitives/transition/beat-cut.md +27 -0
  298. package/library/primitives/transition/blur-dissolve.md +36 -0
  299. package/library/primitives/transition/camera-travel.md +57 -0
  300. package/library/primitives/transition/collapse-to-anchor.md +27 -0
  301. package/library/primitives/transition/cover-reveal.md +47 -0
  302. package/library/primitives/transition/curtain.md +42 -0
  303. package/library/primitives/transition/dive-in.md +51 -0
  304. package/library/primitives/transition/fly-past.md +51 -0
  305. package/library/primitives/transition/iris.md +49 -0
  306. package/library/primitives/transition/layout-locked-swap.md +28 -0
  307. package/library/primitives/transition/light-dark-flip.md +27 -0
  308. package/library/primitives/transition/push.md +47 -0
  309. package/library/primitives/transition/signal-wipe.md +52 -0
  310. package/library/primitives/transition/slant-wipe.md +44 -0
  311. package/library/primitives/transition/stack-over.md +51 -0
  312. package/library/primitives/transition/step-wipe.md +32 -0
  313. package/library/primitives/transition/strip-wipe.md +80 -0
  314. package/library/primitives/transition/torn-edge.md +26 -0
  315. package/library/primitives/transition/whip-pan.md +47 -0
  316. package/library/primitives/transition/zoom-through-letter.md +27 -0
  317. package/library/primitives/type/accent-number.md +22 -0
  318. package/library/primitives/type/block-reveal.md +41 -0
  319. package/library/primitives/type/char-cascade.md +65 -0
  320. package/library/primitives/type/echo.md +44 -0
  321. package/library/primitives/type/fill-text.md +63 -0
  322. package/library/primitives/type/focus-blur.md +22 -0
  323. package/library/primitives/type/inline-chips.md +27 -0
  324. package/library/primitives/type/mask-reveal.md +65 -0
  325. package/library/primitives/type/parting.md +23 -0
  326. package/library/primitives/type/per-word-restyle.md +28 -0
  327. package/library/primitives/type/scramble.md +26 -0
  328. package/library/primitives/type/scribble-highlight.md +47 -0
  329. package/library/primitives/type/shimmer.md +39 -0
  330. package/library/primitives/type/split-flap.md +26 -0
  331. package/library/primitives/type/style-multiply.md +23 -0
  332. package/library/primitives/type/tracking-in.md +40 -0
  333. package/library/primitives/type/typed-title.md +27 -0
  334. package/library/primitives/type/word-build.md +37 -0
  335. package/library/primitives/type/word-roller.md +52 -0
  336. package/library/primitives/type/writing-ticker.md +27 -0
  337. package/library/primitives/ui/collab-cursors.md +27 -0
  338. package/library/primitives/ui/cursor-click.md +61 -0
  339. package/library/primitives/ui/page-scroll.md +58 -0
  340. package/library/primitives/ui/prompt-typing.md +29 -0
  341. package/library/primitives/ui/streamed-result.md +23 -0
  342. package/library/primitives/ui/tour-hold.md +27 -0
  343. package/library/styles/brand-system.md +49 -0
  344. package/library/styles/clean-explainer.md +42 -0
  345. package/library/styles/dark-showcase.md +48 -0
  346. package/library/styles/editorial-type.md +37 -0
  347. package/library/styles/kinetic-poster.md +54 -0
  348. package/library/styles/product-ui.md +44 -0
  349. package/library/styles/studio-loop.md +41 -0
  350. package/library.json +1467 -0
  351. package/package.json +64 -4
  352. package/schema/film.schema.json +1316 -0
  353. package/showcase/vendor/DIALKIT-LICENSE +21 -0
  354. package/src/studio/theme/fonts/OFL.txt +94 -0
@@ -0,0 +1,49 @@
1
+ import { type Primitive } from '../types.ts';
2
+ export declare const SWAPS: readonly ["slide-up", "slide-left", "flip", "stack", "fade"];
3
+ export type Swap = (typeof SWAPS)[number];
4
+ export interface Tile {
5
+ name: string;
6
+ col: number;
7
+ row: number;
8
+ cols: number;
9
+ rows: number;
10
+ }
11
+ /** "a b c / d b e" (rows split by `/`, `|` or a new line) into rows of names. */
12
+ export declare const parseAreas: (s: string) => string[][];
13
+ /**
14
+ * The tiles of a named-area grid, in order of first appearance (reading order).
15
+ * Each name must cover one rectangle, and every row must be as long as the first.
16
+ */
17
+ export declare function tilesOf(areas: string): {
18
+ tiles: Tile[];
19
+ cols: number;
20
+ rows: number;
21
+ problem?: string;
22
+ };
23
+ /**
24
+ * Which items of each tile, as indices into `items`. With `counts`, tile i takes
25
+ * the next counts[i] items. Without, items are dealt in turn: item k to tile k mod n.
26
+ */
27
+ export declare function dealItems(nItems: number, nTiles: number, counts: readonly number[]): number[][];
28
+ /** The share of a `W`×`H` stage each tile covers, in tile order. */
29
+ export declare function tileShares(areas: string, width: number, gap: number, [W, H]: [number, number]): number[];
30
+ /**
31
+ * When the first swap of each cycling tile starts, in seconds: inside the first
32
+ * hold, a phase of `offset` apart in reading order, the last tile at the end of
33
+ * the hold. Keeping every first swap inside the hold is what lets the grid loop.
34
+ */
35
+ export declare function firstSwaps(cycling: number, start: number, hold: number, offset: number): number[];
36
+ export interface SwapState {
37
+ /** Item leaving, and item arriving; equal when the tile is at rest. */
38
+ from: number;
39
+ to: number;
40
+ /** Raw progress of the swap, 1 at rest. */
41
+ k: number;
42
+ /** Seconds since the item on top began to arrive: drives the slow push of pictures. */
43
+ age: number;
44
+ }
45
+ /** The state of a tile of `n` items whose first swap starts at `a`. Swaps repeat every hold + swap. */
46
+ export declare function swapAt(t: number, a: number, n: number, hold: number, swap: number): SwapState;
47
+ /** Fills an item: a picture path becomes a covering image, anything else is markup. */
48
+ export declare function fillItem(host: HTMLElement, item: string): HTMLImageElement | undefined;
49
+ export declare const bentoGrid: Primitive;
@@ -0,0 +1,293 @@
1
+ // scene/bento-grid. See library/primitives/scene/bento-grid.md.
2
+ //
3
+ // A bento: tiles of different sizes on one grid, laid out by named areas. Each
4
+ // tile is a small screen of its own that cycles through its items on its own
5
+ // clock: every tile swaps once a period, a phase apart from its neighbours, so
6
+ // the grid is never still and never moves all at once. A tile with one item
7
+ // holds (a wordmark, a title). Each tile has its own swap move: slide, flip,
8
+ // stack or fade.
9
+ //
10
+ // Swaps repeat with one period and every tile's first swap falls inside the
11
+ // first hold, so a scene as long as `duration` ends on the frame it began on
12
+ // (with no entrance, `stagger` 0, and counts that divide the largest).
13
+ import { clamp, progress } from "../../core/ease.js";
14
+ import { list, num, nums, str } from "../types.js";
15
+ import { wallDelays } from "./grid-wall.js";
16
+ export const SWAPS = ['slide-up', 'slide-left', 'flip', 'stack', 'fade'];
17
+ /** What `mixed` gives tile 1, 2, 3…: neighbours never share a move. */
18
+ const MIXED = ['slide-up', 'flip', 'slide-left', 'stack', 'fade'];
19
+ /** "a b c / d b e" (rows split by `/`, `|` or a new line) into rows of names. */
20
+ export const parseAreas = (s) => s.split(/[/|\n]/).map((r) => r.trim().split(/\s+/).filter(Boolean)).filter((r) => r.length > 0);
21
+ /**
22
+ * The tiles of a named-area grid, in order of first appearance (reading order).
23
+ * Each name must cover one rectangle, and every row must be as long as the first.
24
+ */
25
+ export function tilesOf(areas) {
26
+ const grid = parseAreas(areas);
27
+ const rows = grid.length, cols = grid[0]?.length ?? 0;
28
+ if (!rows)
29
+ return { tiles: [], cols: 0, rows: 0, problem: 'areas is empty.' };
30
+ const short = grid.findIndex((r) => r.length !== cols);
31
+ if (short >= 0)
32
+ return { tiles: [], cols, rows, problem: `Row ${short + 1} has ${grid[short].length} cells; the first has ${cols}.` };
33
+ const tiles = [];
34
+ const seen = new Map();
35
+ grid.forEach((r, y) => r.forEach((name, x) => {
36
+ const t = seen.get(name);
37
+ if (!t) {
38
+ const n = { name, col: x, row: y, cols: 1, rows: 1 };
39
+ seen.set(name, n);
40
+ tiles.push(n);
41
+ return;
42
+ }
43
+ const right = Math.max(t.col + t.cols, x + 1), bottom = Math.max(t.row + t.rows, y + 1);
44
+ t.col = Math.min(t.col, x);
45
+ t.cols = right - t.col;
46
+ t.rows = bottom - t.row;
47
+ }));
48
+ for (const t of tiles) {
49
+ let cells = 0;
50
+ grid.forEach((r, y) => r.forEach((name, x) => { if (name === t.name)
51
+ cells++;
52
+ else if (x >= t.col && x < t.col + t.cols && y >= t.row && y < t.row + t.rows)
53
+ cells = -Infinity; }));
54
+ if (cells !== t.cols * t.rows)
55
+ return { tiles: [], cols, rows, problem: `Tile "${t.name}" does not cover one rectangle.` };
56
+ }
57
+ return { tiles, cols, rows };
58
+ }
59
+ /**
60
+ * Which items of each tile, as indices into `items`. With `counts`, tile i takes
61
+ * the next counts[i] items. Without, items are dealt in turn: item k to tile k mod n.
62
+ */
63
+ export function dealItems(nItems, nTiles, counts) {
64
+ const out = Array.from({ length: nTiles }, () => []);
65
+ if (counts.length) {
66
+ let k = 0;
67
+ counts.forEach((c, i) => { if (i < nTiles)
68
+ for (let j = 0; j < Math.max(0, Math.round(c)) && k < nItems; j++)
69
+ out[i].push(k++); });
70
+ }
71
+ else
72
+ for (let k = 0; k < nItems; k++)
73
+ out[k % Math.max(1, nTiles)].push(k);
74
+ return out;
75
+ }
76
+ /** The share of a `W`×`H` stage each tile covers, in tile order. */
77
+ export function tileShares(areas, width, gap, [W, H]) {
78
+ const { tiles, cols, rows } = tilesOf(areas);
79
+ const gw = (width / 100) * W, gh = Math.max(H * 0.1, H - (W - gw));
80
+ const cw = (gw - gap * (cols - 1)) / Math.max(1, cols), ch = (gh - gap * (rows - 1)) / Math.max(1, rows);
81
+ return tiles.map((t) => ((t.cols * cw + (t.cols - 1) * gap) * (t.rows * ch + (t.rows - 1) * gap)) / (W * H));
82
+ }
83
+ /**
84
+ * When the first swap of each cycling tile starts, in seconds: inside the first
85
+ * hold, a phase of `offset` apart in reading order, the last tile at the end of
86
+ * the hold. Keeping every first swap inside the hold is what lets the grid loop.
87
+ */
88
+ export function firstSwaps(cycling, start, hold, offset) {
89
+ const h = Math.max(1e-6, hold);
90
+ return Array.from({ length: cycling }, (_, r) => start + h - ((((offset * (cycling - 1 - r)) % h) + h) % h));
91
+ }
92
+ /** The state of a tile of `n` items whose first swap starts at `a`. Swaps repeat every hold + swap. */
93
+ export function swapAt(t, a, n, hold, swap) {
94
+ const P = hold + swap;
95
+ // A tile that never swaps holds its picture still, so it matches itself across a loop.
96
+ if (n < 2)
97
+ return { from: 0, to: 0, k: 1, age: 0 };
98
+ if (t < a)
99
+ return { from: 0, to: 0, k: 1, age: Math.max(0, t - a + P) };
100
+ const m = Math.floor((t - a) / P), r = t - a - m * P;
101
+ if (r < swap)
102
+ return { from: m % n, to: (m + 1) % n, k: r / swap, age: r };
103
+ return { from: (m + 1) % n, to: (m + 1) % n, k: 1, age: r };
104
+ }
105
+ const PICTURE = /^(data:image\/|[^<\s]+\.(png|jpe?g|webp|gif|avif|svg)(\?\S*)?$)/i;
106
+ /** Fills an item: a picture path becomes a covering image, anything else is markup. */
107
+ export function fillItem(host, item) {
108
+ if (PICTURE.test(item.trim())) {
109
+ const img = host.ownerDocument.createElement('img');
110
+ img.src = item.trim();
111
+ img.alt = '';
112
+ img.decoding = 'sync';
113
+ img.style.cssText = 'position:absolute;inset:0;width:100%;height:100%;display:block;object-fit:cover';
114
+ host.appendChild(img);
115
+ return img;
116
+ }
117
+ host.innerHTML = item;
118
+ return undefined;
119
+ }
120
+ /** Draws one swap move: `a` leaving, `b` arriving, at eased progress k. */
121
+ function drawSwap(move, a, b, k) {
122
+ b.style.zIndex = '2';
123
+ a.style.zIndex = '1';
124
+ switch (move) {
125
+ case 'slide-up':
126
+ a.style.transform = `translateY(${(-100 * k).toFixed(3)}%)`;
127
+ b.style.transform = `translateY(${(100 * (1 - k)).toFixed(3)}%)`;
128
+ break;
129
+ case 'slide-left':
130
+ a.style.transform = `translateX(${(-100 * k).toFixed(3)}%)`;
131
+ b.style.transform = `translateX(${(100 * (1 - k)).toFixed(3)}%)`;
132
+ break;
133
+ case 'flip': {
134
+ // A card turning in its slot: it shrinks a little while edge-on, so its corners stay inside.
135
+ const s = 1 - 0.08 * Math.sin(Math.PI * k);
136
+ a.style.transform = `scale(${s.toFixed(4)}) rotateY(${(180 * k).toFixed(3)}deg)`;
137
+ b.style.transform = `scale(${s.toFixed(4)}) rotateY(${(180 * k - 180).toFixed(3)}deg)`;
138
+ break;
139
+ }
140
+ case 'stack':
141
+ // The new item comes down over the old one, which sinks back and dims beneath it.
142
+ a.style.transform = `translateY(${(6 * k).toFixed(3)}%) scale(${(1 - 0.1 * k).toFixed(4)})`;
143
+ a.style.opacity = (1 - 0.6 * k).toFixed(4);
144
+ b.style.transform = `translateY(${(-100 * (1 - k)).toFixed(3)}%)`;
145
+ break;
146
+ case 'fade':
147
+ // A dissolve straight from one to the other: the old item stays whole beneath.
148
+ b.style.opacity = k.toFixed(4);
149
+ b.style.transform = `scale(${(1.04 - 0.04 * k).toFixed(4)})`;
150
+ break;
151
+ }
152
+ }
153
+ const PUSH = 0.06;
154
+ export const bentoGrid = {
155
+ slug: 'scene/bento-grid',
156
+ summary: 'Tiles of different sizes on one grid, each cycling its own content on its own clock.',
157
+ props: {
158
+ areas: { type: 'string', required: true, label: 'The grid as named areas, rows split by "/": "a b c / d b e". A name over several cells is one larger tile' },
159
+ items: { type: 'string[]', required: true, label: 'What the tiles show: markup or a picture path each. Dealt to tiles in turn, or by counts' },
160
+ counts: { type: 'number[]', default: [], label: 'How many items each tile cycles, in tile order (reading order of first appearance). 1 holds still' },
161
+ swaps: { type: 'string[]', default: [], label: 'Swap move per tile: slide-up, slide-left, flip, stack or fade. Left out, the swap param decides' },
162
+ },
163
+ params: {
164
+ width: { type: 'number', default: 92, min: 30, max: 100, step: 1, unit: '% of stage width', label: 'Width of the grid; the margin is the same all round' },
165
+ gap: { type: 'number', default: 14, min: 0, max: 60, step: 1, unit: 'px', label: 'Space between tiles (corners are ¾ of it, or --m-card-radius)' },
166
+ hold: { type: 'number', default: 1.6, min: 0.4, max: 6, step: 0.05, unit: 's', label: 'How long each item rests before its tile swaps again' },
167
+ swap: { type: 'choice', default: 'mixed', options: ['mixed', ...SWAPS], label: 'Swap move for tiles without their own: mixed gives neighbours different moves' },
168
+ swap_time: { type: 'number', default: 0.7, min: 0.2, max: 2, step: 0.05, unit: 's', label: 'Length of one swap' },
169
+ offset: { type: 'number', default: 0.3, min: 0, max: 2, step: 0.05, unit: 's', label: 'Phase between one tile’s swap and the next, in reading order' },
170
+ stagger: { type: 'number', default: 0.06, min: 0, max: 0.2, step: 0.005, unit: 's', label: 'Delay between tiles opening from the centre; 0: the grid is there from the first frame (for loops)' },
171
+ },
172
+ duration(props, p, ctx) {
173
+ const { tiles } = tilesOf(str(props.areas));
174
+ const dealt = dealItems(list(props.items).length, tiles.length, nums(props.counts));
175
+ const stagger = num(p.stagger), enter = stagger > 0 ? Math.max(0, tiles.length - 1) * stagger + ctx.tokens.duration.slow : 0;
176
+ const most = Math.max(0, ...dealt.map((d) => d.length));
177
+ return enter + (most > 1 ? most * (num(p.hold) + num(p.swap_time)) : num(p.hold));
178
+ },
179
+ cycles: true,
180
+ cues(props, p, ctx) {
181
+ const { tiles } = tilesOf(str(props.areas));
182
+ const dealt = dealItems(list(props.items).length, tiles.length, nums(props.counts));
183
+ const hold = num(p.hold), swap = num(p.swap_time), P = hold + swap, stagger = num(p.stagger);
184
+ const enter = stagger > 0 ? Math.max(0, tiles.length - 1) * stagger + ctx.tokens.duration.slow : 0;
185
+ const most = Math.max(0, ...dealt.map((d) => d.length));
186
+ if (most < 2)
187
+ return [];
188
+ const total = enter + most * P;
189
+ const order = dealt.map((d, i) => (d.length > 1 ? i : -1)).filter((i) => i >= 0);
190
+ // A tile swapping changes only its own part of the frame.
191
+ const shares = tileShares(str(props.areas), num(p.width), num(p.gap), ctx.size);
192
+ return firstSwaps(order.length, enter, hold, num(p.offset)).flatMap((a, lane) => {
193
+ const out = [];
194
+ const share = +shares[order[lane]].toFixed(4);
195
+ for (let t = a; t + swap <= total + 1e-6; t += P)
196
+ out.push({ at: t, length: swap, lane, share });
197
+ return out;
198
+ });
199
+ },
200
+ check(props) {
201
+ const issues = [];
202
+ const { tiles, problem } = tilesOf(str(props.areas));
203
+ if (problem)
204
+ return [{ path: 'props.areas', message: problem, hint: 'Write rows of equal length, split by "/", and let each name cover one rectangle: "a a b / c d b".' }];
205
+ const n = list(props.items).length, counts = nums(props.counts);
206
+ if (counts.length && counts.length !== tiles.length) {
207
+ issues.push({ path: 'props.counts', message: `counts has ${counts.length} values for ${tiles.length} tiles (${tiles.map((t) => t.name).join(', ')}).`, hint: 'Give one count per tile, in reading order.' });
208
+ }
209
+ else if (counts.length && counts.reduce((a, b) => a + b, 0) !== n) {
210
+ issues.push({ path: 'props.counts', message: `counts add up to ${counts.reduce((a, b) => a + b, 0)}, but there are ${n} items.`, hint: 'Make the counts add up to the number of items.' });
211
+ }
212
+ if (counts.some((c) => !(c >= 1) || c !== Math.round(c)))
213
+ issues.push({ path: 'props.counts', message: 'Each count is a whole number, 1 or more.' });
214
+ if (!counts.length && n < tiles.length)
215
+ issues.push({ path: 'props.items', message: `${n} items for ${tiles.length} tiles: some tiles would be empty.`, hint: 'Give at least one item per tile.' });
216
+ const dealt = dealItems(n, tiles.length, counts);
217
+ const cycling = dealt.map((d) => d.length).filter((c) => c > 1), most = Math.max(0, ...cycling);
218
+ const odd = cycling.filter((c) => most % c !== 0);
219
+ if (odd.length)
220
+ issues.push({ path: 'props.counts', message: `Tiles cycle ${[...new Set(cycling)].join(', ')} items: at the end, the tiles with ${[...new Set(odd)].join(', ')} are not back on their first item, so a loop would jump.`, hint: `For a loop, give each tile a count that divides ${most}.` });
221
+ list(props.swaps).forEach((s, i) => {
222
+ if (!SWAPS.includes(s))
223
+ issues.push({ path: `props.swaps[${i}]`, message: `"${s}" is not a swap move.`, hint: `Use one of ${SWAPS.join(', ')}.` });
224
+ });
225
+ return issues;
226
+ },
227
+ build(el, props, p, ctx) {
228
+ const doc = el.ownerDocument;
229
+ const [W, H] = ctx.size;
230
+ const { tiles, cols, rows } = tilesOf(str(props.areas));
231
+ const items = list(props.items), dealt = dealItems(items.length, tiles.length, nums(props.counts)), own = list(props.swaps);
232
+ const gw = (num(p.width) / 100) * W, margin = (W - gw) / 2, gh = Math.max(H * 0.1, H - 2 * margin);
233
+ const gap = num(p.gap), cw = (gw - gap * (cols - 1)) / Math.max(1, cols), ch = (gh - gap * (rows - 1)) / Math.max(1, rows);
234
+ const hold = num(p.hold), swap = Math.max(0.01, num(p.swap_time)), stagger = num(p.stagger);
235
+ const P = hold + swap, u = W / 1080;
236
+ const enterEase = ctx.ease(ctx.tokens.ease_enter), moveEase = ctx.ease(ctx.tokens.ease_move);
237
+ const each = ctx.tokens.duration.slow;
238
+ const cards = tiles.map((t) => ({ x: t.col * (cw + gap), y: t.row * (ch + gap), w: t.cols * cw + (t.cols - 1) * gap, h: t.rows * ch + (t.rows - 1) * gap }));
239
+ const delays = stagger > 0 ? wallDelays(cards, [gw / 2, gh / 2], stagger) : cards.map(() => 0);
240
+ const enter = stagger > 0 ? Math.max(0, tiles.length - 1) * stagger + each : 0;
241
+ const order = dealt.map((d, i) => (d.length > 1 ? i : -1)).filter((i) => i >= 0);
242
+ const starts = firstSwaps(order.length, enter, hold, num(p.offset));
243
+ const radius = `var(--m-card-radius, ${Math.max(4, Math.round(gap * 0.75))}px)`;
244
+ const grid = doc.createElement('div');
245
+ grid.style.cssText = `position:relative;width:${gw}px;height:${gh}px`;
246
+ const built = tiles.map((t, i) => {
247
+ const c = cards[i];
248
+ const tile = doc.createElement('div');
249
+ tile.style.cssText = `position:absolute;left:${c.x}px;top:${c.y}px;width:${c.w}px;height:${c.h}px;overflow:hidden;border-radius:${radius};`
250
+ + `background:var(--m-bg-sunken);perspective:${(2.5 * Math.max(c.w, c.h)).toFixed(0)}px;isolation:isolate`;
251
+ const rank = order.indexOf(i);
252
+ const move = SWAPS.includes(own[i] ?? '') ? own[i]
253
+ : str(p.swap) === 'mixed' || !SWAPS.includes(str(p.swap)) ? MIXED[Math.max(0, rank) % MIXED.length] : str(p.swap);
254
+ const faces = dealt[i].map((k) => {
255
+ const face = doc.createElement('div');
256
+ face.style.cssText = `position:absolute;inset:0;overflow:hidden;border-radius:inherit;background:var(--m-bg-surface);`
257
+ + `display:grid;place-items:center;visibility:hidden;backface-visibility:hidden;font-size:${(28 * u).toFixed(2)}px`;
258
+ const img = fillItem(face, items[k] ?? '');
259
+ tile.appendChild(face);
260
+ return { face, img };
261
+ });
262
+ grid.appendChild(tile);
263
+ return { tile, faces, move, start: rank >= 0 ? starts[rank] : Infinity, top: c.y };
264
+ });
265
+ el.appendChild(grid);
266
+ return {
267
+ seek(t) {
268
+ built.forEach((b, i) => {
269
+ // Opening: each tile rises and fades in, nearest the centre first. The rise
270
+ // moves the tile by layout, not a transform (see scene/grid-wall).
271
+ const e = stagger > 0 ? progress(t, delays[i], each, enterEase) : 1;
272
+ b.tile.style.opacity = e < 1 ? e.toFixed(4) : '';
273
+ b.tile.style.top = `${(b.top + (1 - e) * 24 * u).toFixed(2)}px`;
274
+ const s = swapAt(t, b.start, b.faces.length, hold, swap);
275
+ b.faces.forEach(({ face, img }, j) => {
276
+ const on = j === s.from || j === s.to;
277
+ face.style.visibility = on ? 'inherit' : 'hidden';
278
+ face.style.transform = '';
279
+ face.style.opacity = '';
280
+ face.style.zIndex = '';
281
+ if (img) {
282
+ // A picture drifts in its tile while it can be seen: in from its arrival to its exit.
283
+ const age = j === s.to ? s.age : s.age + P;
284
+ img.style.transform = on ? `scale(${(1 + PUSH * (1 - clamp(age / (P + swap)))).toFixed(4)})` : '';
285
+ }
286
+ });
287
+ if (s.from !== s.to)
288
+ drawSwap(b.move, b.faces[s.from].face, b.faces[s.to].face, moveEase(s.k));
289
+ });
290
+ },
291
+ };
292
+ },
293
+ };
@@ -0,0 +1,18 @@
1
+ import { type Primitive } from '../types.ts';
2
+ export interface Card {
3
+ x: number;
4
+ y: number;
5
+ w: number;
6
+ h: number;
7
+ }
8
+ /**
9
+ * Masonry: each card, in order, goes to the shortest column. `ratios` are
10
+ * width / height; the wall is `width` px wide. Returns the cards and the height.
11
+ */
12
+ export declare function masonry(ratios: readonly number[], columns: number, width: number, gap: number): {
13
+ cards: Card[];
14
+ height: number;
15
+ };
16
+ /** Delays, nearest the focus first, spread so the last card always starts at (n − 1) × stagger. */
17
+ export declare function wallDelays(cards: readonly Card[], focus: [number, number], stagger: number): number[];
18
+ export declare const gridWall: Primitive;
@@ -0,0 +1,110 @@
1
+ // scene/grid-wall. See library/primitives/scene/grid-wall.md.
2
+ //
3
+ // A wall of pictures in columns: each goes under the shortest column, so
4
+ // pictures of different proportions pack as masonry and equal ones make a
5
+ // regular grid. Cards open nearest the focus point first, then the whole wall
6
+ // drifts up at a constant speed.
7
+ import { progress } from "../../core/ease.js";
8
+ import { staggerByDistance } from "../../core/stagger.js";
9
+ import { list, nums, num } from "../types.js";
10
+ /**
11
+ * Masonry: each card, in order, goes to the shortest column. `ratios` are
12
+ * width / height; the wall is `width` px wide. Returns the cards and the height.
13
+ */
14
+ export function masonry(ratios, columns, width, gap) {
15
+ const cols = Math.max(1, Math.round(columns));
16
+ const w = (width - gap * (cols - 1)) / cols;
17
+ const heights = new Array(cols).fill(0);
18
+ const cards = ratios.map((r) => {
19
+ let c = 0;
20
+ for (let i = 1; i < cols; i++)
21
+ if (heights[i] < heights[c] - 0.5)
22
+ c = i;
23
+ const h = w / (r > 0 ? r : 1);
24
+ const card = { x: c * (w + gap), y: heights[c], w, h };
25
+ heights[c] = heights[c] + h + gap;
26
+ return card;
27
+ });
28
+ return { cards, height: Math.max(0, Math.max(...heights) - gap) };
29
+ }
30
+ /** Delays, nearest the focus first, spread so the last card always starts at (n − 1) × stagger. */
31
+ export function wallDelays(cards, focus, stagger) {
32
+ const steps = staggerByDistance(cards.map((c) => [c.x + c.w / 2, c.y + c.h / 2]), focus);
33
+ const max = Math.max(0, ...steps), span = Math.max(0, cards.length - 1) * stagger;
34
+ return steps.map((s) => (max > 0 ? (s / max) * span : 0));
35
+ }
36
+ export const gridWall = {
37
+ slug: 'scene/grid-wall',
38
+ summary: 'A masonry or regular grid of media.',
39
+ props: {
40
+ images: { type: 'string[]', required: true, label: 'Pictures, in order: each goes under the shortest column' },
41
+ ratios: { type: 'number[]', default: [], label: 'Width ÷ height of each picture. Left out, read from the files once they load' },
42
+ },
43
+ params: {
44
+ columns: { type: 'number', default: 4, min: 2, max: 8, step: 1, unit: 'cols', label: 'Columns' },
45
+ width: { type: 'number', default: 90, min: 20, max: 200, step: 1, unit: '% of stage width', label: 'Width of the wall' },
46
+ gap: { type: 'number', default: 16, min: 0, max: 80, step: 1, unit: 'px', label: 'Space between pictures (corners are ¾ of it, or --m-card-radius)' },
47
+ stagger: { type: 'number', default: 0.05, min: 0.01, max: 0.15, step: 0.005, unit: 's', label: 'Delay between pictures' },
48
+ focus_x: { type: 'number', default: 50, min: 0, max: 100, step: 1, unit: '% of the wall', label: 'Where the opening starts, across', pad: { name: 'focus', axis: 'x' } },
49
+ focus_y: { type: 'number', default: 50, min: 0, max: 100, step: 1, unit: '% of the wall', label: 'Where the opening starts, down', pad: { name: 'focus', axis: 'y' } },
50
+ drift_speed: { type: 'number', default: 20, min: 0, max: 40, step: 1, unit: 'px/s', label: 'Upward drift of the whole wall; 0 holds it still' },
51
+ },
52
+ duration: (props, p, ctx) => Math.max(0, list(props.images).length - 1) * num(p.stagger) + ctx.tokens.duration.slow,
53
+ check(props) {
54
+ const n = list(props.images).length, r = nums(props.ratios);
55
+ if (r.length && r.length !== n)
56
+ return [{ path: 'props.ratios', message: `ratios has ${r.length} values for ${n} pictures.`, hint: 'Give one per picture, or leave ratios out.' }];
57
+ if (r.some((v) => !(v > 0)))
58
+ return [{ path: 'props.ratios', message: 'Each ratio is width ÷ height, above zero.' }];
59
+ return [];
60
+ },
61
+ build(el, props, p, ctx) {
62
+ const doc = el.ownerDocument;
63
+ const srcs = list(props.images), given = nums(props.ratios);
64
+ const width = (num(p.width) / 100) * ctx.size[0], gap = num(p.gap), cols = num(p.columns);
65
+ const stagger = num(p.stagger), each = ctx.tokens.duration.slow, drift = num(p.drift_speed);
66
+ const ease = ctx.ease(ctx.tokens.ease_enter);
67
+ const wall = doc.createElement('div');
68
+ wall.style.cssText = `position:relative;width:${width}px`;
69
+ const imgs = srcs.map((src) => {
70
+ const img = doc.createElement('img');
71
+ img.src = src;
72
+ img.alt = '';
73
+ img.decoding = 'sync';
74
+ img.style.cssText = `position:absolute;display:block;object-fit:cover;border-radius:var(--m-card-radius, ${Math.round(gap * 0.75)}px)`;
75
+ wall.appendChild(img);
76
+ return img;
77
+ });
78
+ el.appendChild(wall);
79
+ // Proportions come from the film, or from the files once decoded: the layout
80
+ // is redone when they change, and is final by the time a render starts.
81
+ let key = '', delays = [], tops = [];
82
+ const layout = () => {
83
+ const ratios = imgs.map((img, i) => given[i] ?? (img.naturalWidth > 0 ? img.naturalWidth / img.naturalHeight : 1));
84
+ const next = ratios.map((r) => r.toFixed(4)).join();
85
+ if (next === key)
86
+ return;
87
+ key = next;
88
+ const { cards, height } = masonry(ratios, cols, width, gap);
89
+ wall.style.height = `${height}px`;
90
+ cards.forEach((c, i) => Object.assign(imgs[i].style, { left: `${c.x}px`, top: `${c.y}px`, width: `${c.w}px`, height: `${c.h}px` }));
91
+ tops = cards.map((c) => c.y);
92
+ delays = wallDelays(cards, [(num(p.focus_x) / 100) * width, (num(p.focus_y) / 100) * height], stagger);
93
+ };
94
+ layout();
95
+ return {
96
+ seek(t) {
97
+ layout();
98
+ imgs.forEach((img, i) => {
99
+ const k = progress(t, delays[i], each, ease);
100
+ img.style.opacity = k.toFixed(4);
101
+ // The rise moves the tile by layout, not a transform: in Chromium a picture
102
+ // rising by transform came out differently depending on the frame drawn
103
+ // before it, so `check` could not get the same frame twice.
104
+ img.style.top = `${(tops[i] + (1 - k) * 24).toFixed(2)}px`;
105
+ });
106
+ wall.style.transform = drift > 0 ? `translateY(${(-drift * Math.max(0, t)).toFixed(2)}px)` : '';
107
+ },
108
+ };
109
+ },
110
+ };
@@ -0,0 +1,2 @@
1
+ import { type Primitive } from '../types.ts';
2
+ export declare const lineChart: Primitive;
@@ -0,0 +1,121 @@
1
+ // scene/line-chart. See library/primitives/scene/line-chart.md.
2
+ import { progress } from "../../core/ease.js";
3
+ import { list, num, nums, str } from "../types.js";
4
+ const SVG = 'http://www.w3.org/2000/svg';
5
+ export const lineChart = {
6
+ slug: 'scene/line-chart',
7
+ summary: 'A line draws left to right behind a leading dot, the area fills, the last value lands.',
8
+ props: {
9
+ values: { type: 'number[]', required: true, label: 'Values, left to right' },
10
+ labels: { type: 'string[]', default: [], label: 'Labels under the first and last points (two items), or one per point' },
11
+ suffix: { type: 'string', default: '', label: 'Text after the end value' },
12
+ decimals: { type: 'number', default: 0, label: 'Decimal places of the end value' },
13
+ },
14
+ params: {
15
+ draw: { type: 'number', default: 2, min: 1.2, max: 3.5, step: 0.1, unit: 's', label: 'Time to draw the line' },
16
+ width: { type: 'number', default: 70, min: 30, max: 90, step: 1, unit: '% of stage width', label: 'Chart width' },
17
+ height: { type: 'number', default: 44, min: 20, max: 75, step: 1, unit: '% of stage height', label: 'Chart height' },
18
+ area: { type: 'boolean', default: true, label: 'Fill under the line' },
19
+ grid: { type: 'number', default: 4, min: 0, max: 8, step: 1, unit: 'lines', label: 'Guide lines' },
20
+ },
21
+ // Guides (0.5 s), then the line, then the area and the end value (0.5 s).
22
+ duration: (_props, p) => 0.4 + num(p.draw) + 0.6,
23
+ build(el, props, p, ctx) {
24
+ const doc = el.ownerDocument;
25
+ const values = nums(props.values), labels = list(props.labels);
26
+ const [W, H] = ctx.size, cw = (num(p.width) / 100) * W, ch = (num(p.height) / 100) * H;
27
+ const lo = Math.min(...values, 0), hi = Math.max(...values, 1e-9);
28
+ const pad = ch * 0.08;
29
+ const pts = values.map((v, i) => [values.length > 1 ? (i / (values.length - 1)) * cw : cw / 2, pad + (1 - (v - lo) / (hi - lo || 1)) * (ch - pad * 2)]);
30
+ el.style.cssText += `;position:relative;width:${cw}px;height:${ch}px`;
31
+ const svg = doc.createElementNS(SVG, 'svg');
32
+ svg.setAttribute('width', String(cw));
33
+ svg.setAttribute('height', String(ch));
34
+ svg.style.cssText = 'position:absolute;inset:0;overflow:visible';
35
+ const gridCount = Math.round(num(p.grid));
36
+ const guides = Array.from({ length: gridCount }, (_, i) => {
37
+ const g = doc.createElementNS(SVG, 'line');
38
+ const y = (ch * (i + 1)) / (gridCount + 1);
39
+ g.setAttribute('x1', '0');
40
+ g.setAttribute('x2', String(cw));
41
+ g.setAttribute('y1', String(y));
42
+ g.setAttribute('y2', String(y));
43
+ g.setAttribute('stroke', 'var(--m-border)');
44
+ g.setAttribute('stroke-width', '1.5');
45
+ g.setAttribute('stroke-dasharray', '4 8');
46
+ svg.appendChild(g);
47
+ return g;
48
+ });
49
+ const d = pts.map(([x, y], i) => `${i ? 'L' : 'M'}${x.toFixed(2)},${y.toFixed(2)}`).join('');
50
+ const area = doc.createElementNS(SVG, 'path');
51
+ area.setAttribute('d', `${d}L${cw},${ch}L0,${ch}Z`);
52
+ area.setAttribute('fill', 'color-mix(in srgb, var(--m-bg-accent) 16%, transparent)');
53
+ const line = doc.createElementNS(SVG, 'path');
54
+ line.setAttribute('d', d);
55
+ line.setAttribute('fill', 'none');
56
+ line.setAttribute('stroke', 'var(--m-bg-accent)');
57
+ line.setAttribute('stroke-width', String(Math.max(3, W * 0.0028)));
58
+ line.setAttribute('stroke-linejoin', 'round');
59
+ line.setAttribute('stroke-linecap', 'round');
60
+ const dot = doc.createElementNS(SVG, 'circle');
61
+ dot.setAttribute('r', String(W * 0.0055));
62
+ dot.setAttribute('fill', 'var(--m-bg-accent)');
63
+ const halo = doc.createElementNS(SVG, 'circle');
64
+ halo.setAttribute('fill', 'color-mix(in srgb, var(--m-bg-accent) 25%, transparent)');
65
+ if (p.area !== false)
66
+ svg.appendChild(area);
67
+ svg.append(line, halo, dot);
68
+ el.appendChild(svg);
69
+ const end = doc.createElement('div');
70
+ const last = pts[pts.length - 1] ?? [0, 0];
71
+ end.textContent = `${(values[values.length - 1] ?? 0).toFixed(Math.max(0, Math.round(num(props.decimals))))}${str(props.suffix)}`;
72
+ end.style.cssText = `position:absolute;left:${last[0]}px;top:${last[1]}px;transform:translate(-50%, -150%);font-weight:650;color:var(--m-accent);white-space:nowrap;font-variant-numeric:tabular-nums`;
73
+ el.appendChild(end);
74
+ const labelEls = labels.map((text, i) => {
75
+ const l = doc.createElement('div');
76
+ const x = labels.length === 2 && values.length > 2 ? (i === 0 ? 0 : cw) : pts[i]?.[0] ?? 0;
77
+ l.textContent = text;
78
+ l.style.cssText = `position:absolute;top:calc(100% + 0.6em);left:${x}px;transform:translateX(-50%);font-size:0.5em;color:var(--m-text-muted);white-space:nowrap`;
79
+ el.appendChild(l);
80
+ return { l, x };
81
+ });
82
+ // The reveal advances at a steady speed in x, so the line reads as time passing.
83
+ const xs = pts.map((q) => q[0]);
84
+ const at = (x) => {
85
+ if (pts.length < 2)
86
+ return pts[0] ?? [0, 0];
87
+ let i = 1;
88
+ while (i < pts.length - 1 && xs[i] < x)
89
+ i++;
90
+ const a = pts[i - 1], b = pts[i], k = b[0] === a[0] ? 1 : Math.min(1, Math.max(0, (x - a[0]) / (b[0] - a[0])));
91
+ return [a[0] + (b[0] - a[0]) * k, a[1] + (b[1] - a[1]) * k];
92
+ };
93
+ const drawT = num(p.draw), ease = ctx.ease('sine.inOut'), out = ctx.ease('expressive.out');
94
+ return {
95
+ seek(t) {
96
+ guides.forEach((g, i) => g.setAttribute('opacity', progress(t, i * 0.05, 0.4, out).toFixed(3)));
97
+ const k = progress(t, 0.4, drawT, ease), x = k * cw;
98
+ line.style.clipPath = k >= 1 ? '' : `inset(-20px ${(cw - x).toFixed(2)}px -20px -20px)`;
99
+ const [px, py] = at(x);
100
+ const live = t >= 0.4;
101
+ dot.setAttribute('cx', px.toFixed(2));
102
+ dot.setAttribute('cy', py.toFixed(2));
103
+ dot.setAttribute('opacity', live ? '1' : '0');
104
+ // A soft halo pulses once as the dot lands.
105
+ const pulse = progress(t, 0.4 + drawT, 0.6, out);
106
+ halo.setAttribute('cx', px.toFixed(2));
107
+ halo.setAttribute('cy', py.toFixed(2));
108
+ halo.setAttribute('r', (W * 0.0055 * (1 + 2.6 * pulse)).toFixed(2));
109
+ halo.setAttribute('opacity', (pulse > 0 ? 1 - pulse : 0).toFixed(3));
110
+ const a = progress(t, 0.4 + drawT * 0.6, 0.6 + drawT * 0.4, out);
111
+ area.setAttribute('opacity', a.toFixed(3));
112
+ area.style.clipPath = `inset(0 ${(cw - x).toFixed(2)}px 0 0)`;
113
+ const e = progress(t, 0.4 + drawT - 0.1, 0.5, out);
114
+ end.style.opacity = e.toFixed(3);
115
+ end.style.transform = `translate(-50%, ${(-150 + (1 - e) * 40).toFixed(2)}%)`;
116
+ for (const { l, x: lx } of labelEls)
117
+ l.style.opacity = Math.min(1, Math.max(0, (x - lx + cw * 0.08) / (cw * 0.08))).toFixed(3);
118
+ },
119
+ };
120
+ },
121
+ };
@@ -0,0 +1,2 @@
1
+ import { type Primitive } from '../types.ts';
2
+ export declare const logoReveal: Primitive;