@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,59 @@
1
+ // fx/grid-ripple. See library/primitives/fx/grid-ripple.md.
2
+ import { progress } from "../../core/ease.js";
3
+ import { STAGGER_FROM, staggerDelays, staggerSpan } from "../../core/stagger.js";
4
+ import { num, str } from "../types.js";
5
+ const grid = (p, size) => {
6
+ const cols = Math.max(2, Math.round(num(p.cols)));
7
+ return [cols, Math.max(2, Math.round((cols * size[1]) / size[0]))];
8
+ };
9
+ export const gridRipple = {
10
+ slug: 'fx/grid-ripple',
11
+ summary: 'A field of dots or tiles appears in a wave from one point, then keeps breathing.',
12
+ props: { cell: { type: 'string', default: 'dot', label: 'dot, square or plus' } },
13
+ params: {
14
+ cols: { type: 'number', default: 24, min: 8, max: 48, step: 1, unit: 'columns', label: 'Columns (rows follow the frame)' },
15
+ stagger: { type: 'number', default: 0.05, min: 0.02, max: 0.1, step: 0.005, unit: 's', label: 'Delay per cell of distance' },
16
+ from: { type: 'choice', default: 'center', options: STAGGER_FROM, label: 'Where the wave starts' },
17
+ size: { type: 'number', default: 0.22, min: 0.05, max: 0.9, step: 0.01, unit: 'ratio of cell', label: 'Mark size' },
18
+ pulse: { type: 'number', default: 0.35, min: 0, max: 1, step: 0.05, unit: 'ratio', label: 'How much the field keeps breathing afterwards' },
19
+ opacity: { type: 'number', default: 0.5, min: 0.1, max: 1, step: 0.05, unit: 'ratio', label: 'Opacity' },
20
+ },
21
+ duration: (_props, p, ctx) => staggerSpan(grid(p, ctx.size)[0] * grid(p, ctx.size)[1], str(p.from), ctx.seed, grid(p, ctx.size)) * num(p.stagger) + 0.6,
22
+ build(el, props, p, ctx) {
23
+ const doc = el.ownerDocument;
24
+ const [W, H] = ctx.size, [cols, rows] = grid(p, ctx.size);
25
+ const cw = W / cols, chh = H / rows, n = cols * rows;
26
+ const kind = str(props.cell, 'dot'), mark = num(p.size) * Math.min(cw, chh);
27
+ const delays = staggerDelays(n, num(p.stagger), str(p.from), ctx.seed, [cols, rows]);
28
+ const span = Math.max(...delays, 0.001);
29
+ // Drawn on a child: the layer's own opacity belongs to its enter, exit and tracks.
30
+ el.style.cssText += ';position:absolute;inset:0;max-width:none;pointer-events:none';
31
+ const field = doc.createElement('div');
32
+ field.style.cssText = `position:absolute;inset:0;opacity:${num(p.opacity)}`;
33
+ el.appendChild(field);
34
+ const cells = Array.from({ length: n }, (_, i) => {
35
+ const c = doc.createElement('div');
36
+ const x = (i % cols) * cw + cw / 2, y = Math.floor(i / cols) * chh + chh / 2;
37
+ const shape = kind === 'square' ? `border-radius:${mark * 0.12}px;background:currentColor`
38
+ : kind === 'plus' ? `background:linear-gradient(currentColor,currentColor) center/100% 18% no-repeat,linear-gradient(currentColor,currentColor) center/18% 100% no-repeat`
39
+ : 'border-radius:50%;background:currentColor';
40
+ c.style.cssText = `position:absolute;left:${x - mark / 2}px;top:${y - mark / 2}px;width:${mark}px;height:${mark}px;${shape}`;
41
+ field.appendChild(c);
42
+ return c;
43
+ });
44
+ const pop = ctx.ease({ spring: { duration: 0.45, bounce: 0.25 } });
45
+ const pulse = num(p.pulse), period = Math.max(1.2, span * 1.6);
46
+ return {
47
+ seek(t) {
48
+ cells.forEach((c, i) => {
49
+ const k = progress(t, delays[i], 0.6, pop);
50
+ // After it lands, the same wave keeps travelling outward as a slow swell.
51
+ const swell = t > delays[i] + 0.6 ? Math.sin(((t - delays[i]) / period) * Math.PI * 2) * 0.5 * pulse : 0;
52
+ const s = Math.max(0, k * (1 + swell * 0.6));
53
+ c.style.transform = `scale(${s.toFixed(4)})`;
54
+ c.style.opacity = Math.min(1, Math.max(0, (t - delays[i]) / 0.2) * (1 - pulse * 0.3 + swell * 0.6)).toFixed(3);
55
+ });
56
+ },
57
+ };
58
+ },
59
+ };
@@ -0,0 +1,2 @@
1
+ import { type Primitive } from '../types.ts';
2
+ export declare const odometer: Primitive;
@@ -0,0 +1,80 @@
1
+ // fx/odometer. See library/primitives/fx/odometer.md.
2
+ import { clamp, progress } from "../../core/ease.js";
3
+ import { num, str } from "../types.js";
4
+ /** The digits of a value as written, with separators kept as fixed characters. */
5
+ function glyphs(value, decimals, group) {
6
+ const fixed = Math.abs(value).toFixed(decimals);
7
+ const [int, frac] = fixed.split('.');
8
+ const withSep = group ? int.replace(/\B(?=(\d{3})+(?!\d))/g, ',') : int;
9
+ return [...(value < 0 ? '-' : ''), ...withSep, ...(frac ? ['.', ...frac] : [])];
10
+ }
11
+ export const odometer = {
12
+ slug: 'fx/odometer',
13
+ summary: 'Each digit rolls in its own column and lands on the value.',
14
+ props: {
15
+ value: { type: 'number', required: true, label: 'The number to land on' },
16
+ decimals: { type: 'number', default: 0, label: 'Decimal places' },
17
+ prefix: { type: 'string', default: '', label: 'Text before the number' },
18
+ suffix: { type: 'string', default: '', label: 'Text after the number' },
19
+ },
20
+ params: {
21
+ duration: { type: 'number', default: 1.6, min: 0.8, max: 3, step: 0.05, unit: 's', label: 'Time for the last column to land' },
22
+ stagger: { type: 'number', default: 0.08, min: 0, max: 0.2, step: 0.01, unit: 's', label: 'Delay between columns, right to left' },
23
+ spins: { type: 'number', default: 1, min: 0, max: 3, step: 1, unit: 'turns', label: 'Extra turns per column to its right' },
24
+ group: { type: 'boolean', default: true, label: 'Thousands separators' },
25
+ },
26
+ duration: (props, p) => {
27
+ const cols = glyphs(num(props.value), Math.max(0, Math.round(num(props.decimals))), p.group !== false).filter((g) => /\d/.test(g)).length;
28
+ return Math.max(0, cols - 1) * num(p.stagger) + num(p.duration);
29
+ },
30
+ build(el, props, p, ctx) {
31
+ const doc = el.ownerDocument;
32
+ const chars = glyphs(num(props.value), Math.max(0, Math.round(num(props.decimals))), p.group !== false);
33
+ const dur = num(p.duration), stagger = num(p.stagger), spins = Math.round(num(p.spins));
34
+ const ease = ctx.ease('expressive.out');
35
+ el.style.cssText += ';display:inline-flex;align-items:baseline;font-variant-numeric:tabular-nums;white-space:pre';
36
+ const affix = (text) => { if (!text)
37
+ return; const s = doc.createElement('span'); s.textContent = text; el.appendChild(s); };
38
+ affix(str(props.prefix));
39
+ const digitCount = chars.filter((c) => /\d/.test(c)).length;
40
+ let fromRight = digitCount;
41
+ const cols = [];
42
+ for (const c of chars) {
43
+ if (!/\d/.test(c)) {
44
+ affix(c);
45
+ continue;
46
+ }
47
+ fromRight--;
48
+ const d = Number(c);
49
+ // Columns further right turn more: the motion reads as one number counting up.
50
+ const travel = d + 10 * spins * fromRight;
51
+ const mask = doc.createElement('span');
52
+ mask.style.cssText = 'display:inline-block;overflow:hidden;height:1.1em;line-height:1.1em;vertical-align:bottom;padding:0 0.01em';
53
+ const strip = doc.createElement('span');
54
+ strip.style.cssText = 'display:flex;flex-direction:column;will-change:transform';
55
+ for (let i = 0; i <= travel; i++) {
56
+ const g = doc.createElement('span');
57
+ g.textContent = String(i % 10);
58
+ g.style.cssText = 'display:block;height:1.1em;text-align:center';
59
+ strip.appendChild(g);
60
+ }
61
+ mask.appendChild(strip);
62
+ el.appendChild(mask);
63
+ cols.push({ strip, travel, delay: fromRight * stagger });
64
+ }
65
+ affix(str(props.suffix));
66
+ return {
67
+ seek(t) {
68
+ for (const c of cols) {
69
+ const k = progress(t, c.delay, dur, ease);
70
+ const pos = c.travel * k;
71
+ c.strip.style.transform = `translateY(${(-pos * 1.1).toFixed(4)}em)`;
72
+ // Fast columns smear a little, as they would on film.
73
+ const speed = c.travel * (progress(t + 1 / 60, c.delay, dur, ease) - k) * 60;
74
+ const blur = clamp(Math.abs(speed) * 0.012, 0, 0.06);
75
+ c.strip.style.filter = blur > 0.004 ? `blur(${blur.toFixed(3)}em)` : '';
76
+ }
77
+ },
78
+ };
79
+ },
80
+ };
@@ -0,0 +1,17 @@
1
+ import { type Primitive } from '../types.ts';
2
+ export interface PanGeometry {
3
+ /** Which way the picture travels. */
4
+ axis: 'x' | 'y';
5
+ /** Picture size on stage, px. */
6
+ w: number;
7
+ h: number;
8
+ /** How much of the picture lies outside the frame along the travel, px. */
9
+ spare: number;
10
+ }
11
+ /** The picture fills the frame across the travel and runs past it along it. */
12
+ export declare function panGeometry(frame: [number, number], aspect: number, scale?: number): PanGeometry;
13
+ /** Steepest slope of an ease, 1 for linear, π/2 for sine.inOut. */
14
+ export declare function peakSlope(ease: (x: number) => number, samples?: number): number;
15
+ /** Fastest the picture moves on stage, px a second. */
16
+ export declare function panSpeed(geo: PanGeometry, from: number, to: number, duration: number, ease: (x: number) => number): number;
17
+ export declare const panAcross: Primitive;
@@ -0,0 +1,76 @@
1
+ // fx/pan-across. See library/primitives/fx/pan-across.md.
2
+ //
3
+ // A picture far wider (or taller) than its frame fills the frame the other way and
4
+ // the camera travels along it: a 16:9 billboard read across a 9:16 phone. The
5
+ // primitive knows the picture's ratio, so the pace check can tell how fast the
6
+ // picture crosses the screen at its fastest, and warn before it strobes.
7
+ import { clamp, resolveEase } from "../../core/ease.js";
8
+ import { num, str } from "../types.js";
9
+ /** The picture fills the frame across the travel and runs past it along it. */
10
+ export function panGeometry(frame, aspect, scale = 1) {
11
+ const [fw, fh] = frame, a = Math.max(0.01, aspect), s = Math.max(1, scale);
12
+ if (a >= fw / fh) {
13
+ const h = fh * s, w = h * a;
14
+ return { axis: 'x', w, h, spare: Math.max(0, w - fw) };
15
+ }
16
+ const w = fw * s, h = w / a;
17
+ return { axis: 'y', w, h, spare: Math.max(0, h - fh) };
18
+ }
19
+ /** Steepest slope of an ease, 1 for linear, π/2 for sine.inOut. */
20
+ export function peakSlope(ease, samples = 200) {
21
+ let peak = 0;
22
+ for (let i = 0; i < samples; i++)
23
+ peak = Math.max(peak, Math.abs(ease((i + 1) / samples) - ease(i / samples)) * samples);
24
+ return peak;
25
+ }
26
+ /** Fastest the picture moves on stage, px a second. */
27
+ export function panSpeed(geo, from, to, duration, ease) {
28
+ return ((Math.abs(to - from) / 100) * geo.spare * peakSlope(ease)) / Math.max(0.01, duration);
29
+ }
30
+ const frameOf = (p, size) => [num(p.width) || size[0], num(p.height) || size[1]];
31
+ export const panAcross = {
32
+ slug: 'fx/pan-across',
33
+ summary: 'The camera travels along a picture wider or taller than its frame.',
34
+ props: {
35
+ src: { type: 'string', required: true, label: 'Image path or URL' },
36
+ alt: { type: 'string', default: '', label: 'Description of the picture' },
37
+ },
38
+ params: {
39
+ width: { type: 'number', default: 0, min: 0, max: 4000, step: 1, unit: 'px', label: 'Frame width; 0 is the stage' },
40
+ height: { type: 'number', default: 0, min: 0, max: 4000, step: 1, unit: 'px', label: 'Frame height; 0 is the stage' },
41
+ aspect: { type: 'number', default: 1.78, min: 0.2, max: 6, step: 0.01, unit: 'w ÷ h', label: "The picture's width over its height" },
42
+ from: { type: 'number', default: 20, min: 0, max: 100, step: 1, unit: '% of travel', label: 'Where the view starts: 0 one end of the picture, 100 the other' },
43
+ to: { type: 'number', default: 80, min: 0, max: 100, step: 1, unit: '% of travel', label: 'Where the view ends' },
44
+ scale: { type: 'number', default: 1, min: 1, max: 1.3, step: 0.01, unit: '×', label: 'Extra size, to leave room across the travel' },
45
+ duration: { type: 'number', default: 4, min: 0.5, max: 30, step: 0.1, unit: 's', label: 'Length of the travel' },
46
+ ease: { type: 'ease', default: 'sine.inOut', label: 'Curve of the travel: sine.inOut starts and settles like a camera' },
47
+ },
48
+ // Camera drift, not a change of picture: the pace check reads it as drift.
49
+ cues: () => [],
50
+ duration: (_props, p) => num(p.duration, 4),
51
+ speed(_props, p, ctx) {
52
+ const geo = panGeometry(frameOf(p, ctx.size), num(p.aspect, 1.78), num(p.scale, 1));
53
+ return panSpeed(geo, num(p.from, 20), num(p.to, 80), num(p.duration, 4), resolveEase(p.ease ?? 'sine.inOut'));
54
+ },
55
+ build(el, props, p, ctx) {
56
+ const [fw, fh] = frameOf(p, ctx.size);
57
+ const geo = panGeometry([fw, fh], num(p.aspect, 1.78), num(p.scale, 1));
58
+ const img = el.ownerDocument.createElement('img');
59
+ img.src = str(props.src);
60
+ img.alt = str(props.alt);
61
+ img.decoding = 'sync';
62
+ el.style.cssText += `;position:relative;width:${fw}px;height:${fh}px;overflow:hidden`;
63
+ // Centred across the travel; along it, placed by seek.
64
+ const across = geo.axis === 'x' ? (fh - geo.h) / 2 : (fw - geo.w) / 2;
65
+ img.style.cssText = `position:absolute;left:0;top:0;display:block;width:${geo.w}px;height:${geo.h}px;object-fit:cover;max-width:none;will-change:transform`;
66
+ el.appendChild(img);
67
+ const ease = ctx.ease(p.ease), d = num(p.duration, 4), from = num(p.from, 20), to = num(p.to, 80);
68
+ return {
69
+ seek(t) {
70
+ const along = -geo.spare * ((from + (to - from) * ease(clamp(t / d))) / 100);
71
+ const [x, y] = geo.axis === 'x' ? [along, across] : [across, along];
72
+ img.style.transform = `translate3d(${x.toFixed(3)}px, ${y.toFixed(3)}px, 0)`;
73
+ },
74
+ };
75
+ },
76
+ };
@@ -0,0 +1,2 @@
1
+ import { type Primitive } from '../types.ts';
2
+ export declare const pathDraw: Primitive;
@@ -0,0 +1,105 @@
1
+ // fx/path-draw. See library/primitives/fx/path-draw.md.
2
+ import { progress } from "../../core/ease.js";
3
+ import { staggerDelays } from "../../core/stagger.js";
4
+ import { list, num, str } from "../types.js";
5
+ const SVG = 'http://www.w3.org/2000/svg';
6
+ export const pathDraw = {
7
+ slug: 'fx/path-draw',
8
+ summary: 'Lines draw themselves along their paths, then the shapes fill.',
9
+ props: {
10
+ paths: { type: 'string[]', required: true, label: 'SVG path data, one path per item, drawn in order' },
11
+ viewbox: { type: 'string', default: '0 0 100 100', label: 'SVG viewBox the paths are drawn in' },
12
+ fill: { type: 'string', default: 'none', label: 'Fill once drawn: none, accent, primary or a CSS colour' },
13
+ },
14
+ params: {
15
+ draw: { type: 'number', default: 1, min: 0.4, max: 2.5, step: 0.05, unit: 's', label: 'Time to draw one path' },
16
+ stagger: { type: 'number', default: 0.12, min: 0, max: 0.5, step: 0.01, unit: 's', label: 'Delay between paths' },
17
+ width: { type: 'number', default: 30, min: 4, max: 100, step: 1, unit: '% of stage width', label: 'Drawing width' },
18
+ stroke: { type: 'number', default: 2, min: 0.5, max: 12, step: 0.25, unit: 'px', label: 'Stroke weight' },
19
+ fill_time: { type: 'number', default: 0.4, min: 0.1, max: 1, step: 0.05, unit: 's', label: 'Time for the fill to arrive' },
20
+ ease: { type: 'ease', default: 'quart.inOut', label: 'Curve of each stroke; a camera that follows the tip moves with it' },
21
+ },
22
+ duration: (props, p) => {
23
+ const n = list(props.paths).length, fill = str(props.fill, 'none') !== 'none';
24
+ return Math.max(0, n - 1) * num(p.stagger) + num(p.draw) + (fill ? num(p.fill_time) * 0.8 : 0);
25
+ },
26
+ build(el, props, p, ctx) {
27
+ const doc = el.ownerDocument;
28
+ const fillName = str(props.fill, 'none');
29
+ const fill = fillName === 'accent' ? 'var(--m-bg-accent)' : fillName === 'primary' ? 'var(--m-text-primary)' : fillName;
30
+ const vb = str(props.viewbox, '0 0 100 100').split(/[\s,]+/).map(Number);
31
+ const vw = vb[2] || 100, vh = vb[3] || 100;
32
+ const w = (num(p.width) / 100) * ctx.size[0];
33
+ const svg = doc.createElementNS(SVG, 'svg');
34
+ svg.setAttribute('viewBox', str(props.viewbox, '0 0 100 100'));
35
+ svg.setAttribute('width', String(w));
36
+ svg.setAttribute('height', String((w * vh) / vw));
37
+ svg.style.cssText = 'display:block;overflow:visible';
38
+ // Stroke weight is in stage px whatever the viewBox scale.
39
+ const stroke = num(p.stroke) * (vw / w);
40
+ const paths = list(props.paths).map((d) => {
41
+ const path = doc.createElementNS(SVG, 'path');
42
+ path.setAttribute('d', d);
43
+ path.setAttribute('pathLength', '1');
44
+ path.setAttribute('stroke-dasharray', '1 1');
45
+ path.setAttribute('stroke', 'currentColor');
46
+ path.setAttribute('stroke-width', String(stroke));
47
+ path.setAttribute('stroke-linecap', 'round');
48
+ path.setAttribute('stroke-linejoin', 'round');
49
+ path.setAttribute('fill', fillName === 'none' ? 'none' : fill);
50
+ svg.appendChild(path);
51
+ return path;
52
+ });
53
+ el.appendChild(svg);
54
+ const delays = staggerDelays(paths.length, num(p.stagger));
55
+ const draw = num(p.draw), fillT = num(p.fill_time);
56
+ const ease = ctx.ease(p.ease ?? 'quart.inOut'), soft = ctx.ease('cubic.out');
57
+ // Points along each path, sampled once while the scene is laid out, in layer px.
58
+ // The dash runs on pathLength 1, so a share of the length is a share of the draw.
59
+ const k = w / vw, SAMPLES = 256;
60
+ const tables = paths.map((path) => {
61
+ let total = 0;
62
+ try {
63
+ total = path.getTotalLength();
64
+ }
65
+ catch {
66
+ return [];
67
+ }
68
+ return Array.from({ length: SAMPLES + 1 }, (_, i) => {
69
+ const pt = path.getPointAtLength((total * i) / SAMPLES);
70
+ return [(pt.x - (vb[0] ?? 0)) * k, (pt.y - (vb[1] ?? 0)) * k];
71
+ });
72
+ });
73
+ const along = (i, share) => {
74
+ const table = tables[i];
75
+ if (!table?.length)
76
+ return undefined;
77
+ const x = Math.min(1, Math.max(0, share)) * SAMPLES, a = Math.floor(x), b = Math.min(SAMPLES, a + 1), f = x - a;
78
+ const [ax, ay] = table[a], [bx, by] = table[b];
79
+ return [ax + (bx - ax) * f, ay + (by - ay) * f];
80
+ };
81
+ return {
82
+ // The tip of the path being drawn: the last one to have started.
83
+ tip(t) {
84
+ let i = 0;
85
+ for (let j = 0; j < paths.length; j++)
86
+ if (t >= delays[j])
87
+ i = j;
88
+ return along(i, progress(t, delays[i], draw, ease));
89
+ },
90
+ seek(t) {
91
+ paths.forEach((path, i) => {
92
+ const k = progress(t, delays[i], draw, ease);
93
+ path.setAttribute('stroke-dashoffset', (1 - k).toFixed(4));
94
+ path.style.visibility = t < delays[i] ? 'hidden' : 'inherit';
95
+ if (fillName !== 'none') {
96
+ // The fill arrives over the last fifth of the draw, then the line steps back.
97
+ const f = progress(t, delays[i] + draw * 0.8, fillT, soft);
98
+ path.setAttribute('fill-opacity', f.toFixed(3));
99
+ path.setAttribute('stroke-opacity', (1 - f).toFixed(3));
100
+ }
101
+ });
102
+ },
103
+ };
104
+ },
105
+ };
@@ -0,0 +1,2 @@
1
+ import { type Primitive } from '../types.ts';
2
+ export declare const pinDrop: Primitive;
@@ -0,0 +1,92 @@
1
+ // fx/pin-drop. See library/primitives/fx/pin-drop.md.
2
+ //
3
+ // Places light up one after another: a marker lands on each with a little
4
+ // overshoot over a soft glow, a ripple spreads from it, then a stem grows out of
5
+ // the marker and carries its label up into a card. All ripples share one phase,
6
+ // so they are the same size at every instant and pulse together, however many
7
+ // there are; markers are drawn at one size, never scaled by where they sit.
8
+ import { clamp, lerp } from "../../core/ease.js";
9
+ import { list, nums, num } from "../types.js";
10
+ const backOut = (p) => 1 + 2.4 * (p - 1) ** 3 + 1.4 * (p - 1) ** 2;
11
+ const count = (props) => Math.floor(nums(props.points).length / 2);
12
+ export const pinDrop = {
13
+ slug: 'fx/pin-drop',
14
+ summary: 'Markers land on places one by one, ripple together, and raise their labels on stems.',
15
+ props: {
16
+ points: { type: 'number[]', required: true, label: 'Places as x, y pairs in % of the stage: [x1, y1, x2, y2, …]' },
17
+ labels: { type: 'string[]', default: [], label: 'A short label for each place, in the same order. Left out, no card' },
18
+ },
19
+ params: {
20
+ stagger: { type: 'number', default: 0.28, min: 0.1, max: 0.6, step: 0.01, unit: 's', label: 'Delay between places' },
21
+ stem: { type: 'number', default: 120, min: 0, max: 260, step: 5, unit: 'px', label: 'How high each card stands over its marker' },
22
+ size: { type: 'number', default: 16, min: 8, max: 32, step: 1, unit: 'px', label: 'Marker size' },
23
+ ripple: { type: 'number', default: 1.3, min: 0.8, max: 2.4, step: 0.05, unit: 's', label: 'Time between ripples' },
24
+ glow: { type: 'number', default: 1, min: 0, max: 2, step: 0.05, unit: 'ratio', label: 'Strength of the glow under each marker' },
25
+ },
26
+ duration: (props, p) => Math.max(0, count(props) - 1) * num(p.stagger) + 0.95,
27
+ build(el, props, p, ctx) {
28
+ const doc = el.ownerDocument;
29
+ const [W, H] = ctx.size, u = W / 1080;
30
+ el.style.cssText += ';position:absolute;inset:0;max-width:none;pointer-events:none';
31
+ const pts = nums(props.points), labels = list(props.labels);
32
+ const size = num(p.size) * u, glow = num(p.glow), stemH = num(p.stem) * u;
33
+ const add = (parent, css) => { const d = doc.createElement('div'); d.style.cssText = css; parent.appendChild(d); return d; };
34
+ const marks = Array.from({ length: count(props) }, (_, i) => {
35
+ const x = (pts[i * 2] / 100) * W, y = (pts[i * 2 + 1] / 100) * H;
36
+ const at = `position:absolute;left:${x}px;top:${y}px;`;
37
+ const halo = add(el, `${at}width:${size * 6}px;height:${size * 6}px;translate:-50% -50%;border-radius:50%;`
38
+ + `background:radial-gradient(closest-side,color-mix(in srgb,var(--m-accent) ${Math.round(42 * Math.min(1, glow))}%,transparent),color-mix(in srgb,var(--m-accent) ${Math.round(12 * glow)}%,transparent) 45%,transparent)`);
39
+ const ring = add(el, `${at}width:${size * 2.5}px;height:${size * 2.5}px;translate:-50% -50%;border-radius:50%;border:${1.5 * u}px solid var(--m-accent);`
40
+ + `box-shadow:0 0 ${12 * u}px color-mix(in srgb,var(--m-accent) 45%,transparent)`);
41
+ const stem = add(el, `${at}width:${1.5 * u}px;translate:-50% 0;transform-origin:50% 100%;background:linear-gradient(color-mix(in srgb,var(--m-accent) 95%,transparent),color-mix(in srgb,var(--m-accent) 25%,transparent))`);
42
+ // The marker: an accent dot ringed in the ground colour, so it reads on any map.
43
+ const dot = add(el, `${at}width:${size}px;height:${size}px;translate:-50% -50%;border-radius:50%;background:var(--m-accent);`
44
+ + `box-shadow:0 0 0 ${3 * u}px var(--m-bg-base),0 0 ${6 * u}px ${2 * u}px rgba(0,0,0,.5)`);
45
+ const text = labels[i] ?? '';
46
+ const card = text ? add(el, `${at}translate:-50% -100%;transform-origin:50% 100%;display:flex;align-items:center;gap:${10 * u}px;white-space:nowrap;`
47
+ + `padding:${12 * u}px ${16 * u}px;border-radius:${10 * u}px;background:color-mix(in srgb,var(--m-bg-surface) 82%,transparent);`
48
+ + `box-shadow:0 0 0 1px color-mix(in srgb,var(--m-text-primary) 9%,transparent),0 ${30 * u}px ${60 * u}px rgba(0,0,0,.45);`
49
+ + `font:var(--ui-weight-medium,500) calc(var(--m-u)*1.6)/1.25 var(--m-font-body);color:var(--m-text-primary)`) : undefined;
50
+ if (card) {
51
+ add(card, `flex:none;width:${size * 0.7}px;height:${size * 0.7}px;border-radius:50%;background:var(--m-accent)`);
52
+ const label = doc.createElement('span');
53
+ label.textContent = text;
54
+ card.appendChild(label);
55
+ }
56
+ return { y, halo, ring, stem, dot, card };
57
+ });
58
+ const stagger = num(p.stagger), period = num(p.ripple), expo = ctx.ease('expo.out'), smooth = ctx.ease('smooth');
59
+ return {
60
+ seek(t) {
61
+ // One phase for every ripple.
62
+ const phase = (Math.max(0, t) / period) % 1;
63
+ marks.forEach((m, i) => {
64
+ const t0 = i * stagger;
65
+ const land = clamp((t - t0) / 0.42);
66
+ const on = clamp((t - t0) / 0.14);
67
+ const grow = expo(clamp((t - t0 - 0.14) / 0.81));
68
+ m.dot.style.opacity = on.toFixed(3);
69
+ m.dot.style.scale = String(Math.max(0, land < 1 ? backOut(land) : 1).toFixed(4));
70
+ m.halo.style.opacity = on.toFixed(3);
71
+ m.halo.style.scale = lerp(0.5, 1, expo(land)).toFixed(4);
72
+ m.ring.style.opacity = ((1 - phase) ** 1.4 * clamp((t - t0 - 0.1) / 0.3)).toFixed(3);
73
+ m.ring.style.scale = (0.3 + phase * 1.25).toFixed(4);
74
+ if (!m.card) {
75
+ m.stem.style.height = '0px';
76
+ return;
77
+ }
78
+ // The stem grows from just above the marker to the card's lower edge.
79
+ const lift = stemH * lerp(0.3, 1, grow), gapBelow = size * 0.5 + 5 * u;
80
+ const len = Math.max(0, lift - gapBelow);
81
+ m.stem.style.top = `${m.y - lift}px`;
82
+ m.stem.style.height = `${len}px`;
83
+ const a = smooth(clamp((t - t0 - 0.2) / 0.35));
84
+ m.stem.style.opacity = a.toFixed(3);
85
+ m.card.style.top = `${m.y - lift}px`;
86
+ m.card.style.scale = lerp(0.84, 1, grow).toFixed(4);
87
+ m.card.style.opacity = a.toFixed(3);
88
+ });
89
+ },
90
+ };
91
+ },
92
+ };
@@ -0,0 +1,2 @@
1
+ import { type Primitive } from '../types.ts';
2
+ export declare const shapeMorph: Primitive;
@@ -0,0 +1,65 @@
1
+ // fx/shape-morph. See library/primitives/fx/shape-morph.md.
2
+ import { progress } from "../../core/ease.js";
3
+ import { lerpPoints, pointsPath, shapePoints, SHAPES } from "../../core/shapes.js";
4
+ import { list, num, str } from "../types.js";
5
+ const SVG = 'http://www.w3.org/2000/svg';
6
+ const FILL = { accent: 'var(--m-bg-accent)', primary: 'var(--m-text-primary)', surface: 'var(--m-bg-surface)', inverse: 'var(--m-bg-inverse)' };
7
+ export const shapeMorph = {
8
+ slug: 'fx/shape-morph',
9
+ summary: 'One shape grows in, then turns into the next, and the next.',
10
+ props: {
11
+ shapes: { type: 'string[]', default: ['circle', 'squircle', 'star'], label: `Shapes in order: ${SHAPES.join(', ')}` },
12
+ fill: { type: 'string', default: 'accent', label: 'accent, primary, surface, inverse, outline or a CSS colour' },
13
+ },
14
+ params: {
15
+ hold: { type: 'number', default: 0.6, min: 0.2, max: 2, step: 0.05, unit: 's', label: 'Time each shape holds' },
16
+ morph: { type: 'number', default: 0.7, min: 0.4, max: 1.2, step: 0.05, unit: 's', label: 'Time to turn into the next' },
17
+ size: { type: 'number', default: 22, min: 6, max: 60, step: 0.5, unit: '% of stage width', label: 'Size' },
18
+ turn: { type: 'number', default: 90, min: 0, max: 180, step: 5, unit: 'deg', label: 'Rotation per morph' },
19
+ },
20
+ duration: (props, p) => {
21
+ const n = Math.max(1, list(props.shapes).length);
22
+ return 0.6 + (n - 1) * (num(p.hold) + num(p.morph));
23
+ },
24
+ build(el, props, p, ctx) {
25
+ const doc = el.ownerDocument;
26
+ const names = list(props.shapes).length ? list(props.shapes) : ['circle'];
27
+ const shapes = names.map((n) => shapePoints(n, 160, ctx.seed));
28
+ const W = ctx.size[0], size = (num(p.size) / 100) * W, r = size / 2;
29
+ const hold = num(p.hold), morph = num(p.morph), turn = num(p.turn);
30
+ const fill = str(props.fill, 'accent');
31
+ const svg = doc.createElementNS(SVG, 'svg');
32
+ svg.setAttribute('width', String(size * 1.3));
33
+ svg.setAttribute('height', String(size * 1.3));
34
+ svg.setAttribute('viewBox', `${-size * 0.65} ${-size * 0.65} ${size * 1.3} ${size * 1.3}`);
35
+ svg.style.cssText = 'display:block;overflow:visible';
36
+ const path = doc.createElementNS(SVG, 'path');
37
+ if (fill === 'outline') {
38
+ path.setAttribute('fill', 'none');
39
+ path.setAttribute('stroke', 'currentColor');
40
+ path.setAttribute('stroke-width', String(Math.max(2, size * 0.02)));
41
+ }
42
+ else
43
+ path.setAttribute('fill', FILL[fill] ?? fill);
44
+ svg.appendChild(path);
45
+ el.appendChild(svg);
46
+ const grow = ctx.ease({ spring: { duration: 0.6, bounce: 0.3 } }), move = ctx.ease('quint.inOut');
47
+ return {
48
+ seek(t) {
49
+ // Grow in over 0.6 s, then alternate: hold, morph.
50
+ const g = progress(t, 0, 0.6, grow);
51
+ const after = Math.max(0, t - 0.6), cycle = hold + morph;
52
+ let i = Math.min(names.length - 1, Math.floor(after / cycle));
53
+ let k = 0;
54
+ if (i < names.length - 1)
55
+ k = progress(after - i * cycle, hold, morph, move);
56
+ else
57
+ i = names.length - 1;
58
+ const next = Math.min(names.length - 1, i + 1);
59
+ const pts = lerpPoints(shapes[i], shapes[next], k);
60
+ path.setAttribute('d', pointsPath(pts, 0, 0, r * Math.max(0, g)));
61
+ path.setAttribute('transform', `rotate(${((i + k) * turn).toFixed(3)})`);
62
+ },
63
+ };
64
+ },
65
+ };
@@ -0,0 +1,13 @@
1
+ import { type Primitive } from '../types.ts';
2
+ /** Scale and offset (share of the frame) of the picture at progress k. The picture always covers its frame. */
3
+ export declare function pushAt(k: number, p: {
4
+ from: number;
5
+ to: number;
6
+ pan_x: number;
7
+ pan_y: number;
8
+ }): {
9
+ scale: number;
10
+ x: number;
11
+ y: number;
12
+ };
13
+ export declare const slowPush: Primitive;
@@ -0,0 +1,56 @@
1
+ // fx/slow-push. See library/primitives/fx/slow-push.md.
2
+ import { clamp } from "../../core/ease.js";
3
+ import { num, str } from "../types.js";
4
+ /** Scale and offset (share of the frame) of the picture at progress k. The picture always covers its frame. */
5
+ export function pushAt(k, p) {
6
+ const u = clamp(k);
7
+ const scale = Math.max(1, p.from + (p.to - p.from) * u);
8
+ // The pan runs from one side of centre to the other, and never past what the scale leaves spare.
9
+ const spare = (scale - 1) / 2;
10
+ const shift = (pan) => clamp((pan / 100) * (u - 0.5), -spare, spare);
11
+ return { scale, x: shift(p.pan_x), y: shift(p.pan_y) };
12
+ }
13
+ export const slowPush = {
14
+ slug: 'fx/slow-push',
15
+ summary: 'A still picture in a fixed frame slowly pushes in, pulls out or pans while it is held.',
16
+ props: {
17
+ src: { type: 'string', required: true, label: 'Image path or URL' },
18
+ alt: { type: 'string', default: '', label: 'Description of the picture' },
19
+ },
20
+ params: {
21
+ width: { type: 'number', default: 640, min: 1, max: 4000, step: 1, unit: 'px', label: 'Frame width' },
22
+ height: { type: 'number', default: 800, min: 1, max: 4000, step: 1, unit: 'px', label: 'Frame height' },
23
+ radius: { type: 'number', default: 16, min: 0, max: 400, step: 1, unit: 'px', label: 'Corner radius' },
24
+ from: { type: 'number', default: 1.08, min: 1, max: 1.6, step: 0.01, unit: '×', label: 'Scale at the start' },
25
+ to: { type: 'number', default: 1, min: 1, max: 1.6, step: 0.01, unit: '×', label: 'Scale at the end' },
26
+ pan_x: { type: 'number', default: 0, min: -30, max: 30, step: 0.5, unit: '% of frame', label: 'Sideways travel over the move', pad: { name: 'pan', axis: 'x' } },
27
+ pan_y: { type: 'number', default: 0, min: -30, max: 30, step: 0.5, unit: '% of frame', label: 'Vertical travel over the move', pad: { name: 'pan', axis: 'y' } },
28
+ focus_x: { type: 'number', default: 50, min: 0, max: 100, step: 1, unit: '% of picture', label: 'Point of the picture to keep in frame, across', pad: { name: 'focus', axis: 'x' } },
29
+ focus_y: { type: 'number', default: 50, min: 0, max: 100, step: 1, unit: '% of picture', label: 'Point of the picture to keep in frame, down', pad: { name: 'focus', axis: 'y' } },
30
+ duration: { type: 'number', default: 4, min: 0.5, max: 30, step: 0.1, unit: 's', label: 'Length of the move' },
31
+ ease: { type: 'ease', default: 'linear', label: 'Curve of the move; linear reads as drift, sine.inOut as a camera that starts and settles' },
32
+ },
33
+ // Footage and ambient drift are not moves: the pace check skips them.
34
+ cues: () => [],
35
+ duration: (_props, p) => num(p.duration, 4),
36
+ build(el, props, p, ctx) {
37
+ const img = el.ownerDocument.createElement('img');
38
+ img.src = str(props.src);
39
+ img.alt = str(props.alt);
40
+ img.decoding = 'sync';
41
+ el.style.cssText += `;width:${num(p.width)}px;height:${num(p.height)}px;border-radius:${num(p.radius)}px;overflow:hidden`;
42
+ // The focus is where the crop is taken from and where the push grows from, so a
43
+ // subject off centre stays in frame as the picture fills a narrower frame.
44
+ const focus = `${num(p.focus_x, 50)}% ${num(p.focus_y, 50)}%`;
45
+ img.style.cssText = `display:block;width:100%;height:100%;object-fit:cover;object-position:${focus};transform-origin:${focus};will-change:transform`;
46
+ el.appendChild(img);
47
+ const ease = ctx.ease(p.ease), d = num(p.duration, 4);
48
+ const q = { from: num(p.from, 1.08), to: num(p.to, 1), pan_x: num(p.pan_x), pan_y: num(p.pan_y) };
49
+ return {
50
+ seek(t) {
51
+ const s = pushAt(ease(clamp(t / d)), q);
52
+ img.style.transform = `translate(${(s.x * 100).toFixed(4)}%, ${(s.y * 100).toFixed(4)}%) scale(${s.scale.toFixed(5)})`;
53
+ },
54
+ };
55
+ },
56
+ };
@@ -0,0 +1,2 @@
1
+ import { type Primitive } from '../types.ts';
2
+ export declare const staggerFill: Primitive;
@@ -0,0 +1,33 @@
1
+ // fx/stagger-fill. See library/primitives/fx/stagger-fill.md.
2
+ import { progress } from "../../core/ease.js";
3
+ import { list, num } from "../types.js";
4
+ export const staggerFill = {
5
+ slug: 'fx/stagger-fill',
6
+ summary: 'Items appear one after another.',
7
+ props: { items: { type: 'string[]', required: true, label: 'The items, in reading order' } },
8
+ params: {
9
+ stagger: { type: 'number', default: 0.04, min: 0.02, max: 0.06, step: 0.005, unit: 's', label: 'Delay between items' },
10
+ },
11
+ duration: (props, p, ctx) => Math.max(0, list(props.items).length - 1) * num(p.stagger) + ctx.tokens.duration.base,
12
+ build(el, props, p, ctx) {
13
+ const ease = ctx.ease(ctx.tokens.ease_enter);
14
+ const each = ctx.tokens.duration.base, stagger = num(p.stagger);
15
+ el.style.cssText += ';display:flex;flex-wrap:wrap;justify-content:center;gap:0.5em';
16
+ const chips = list(props.items).map((label) => {
17
+ const c = document.createElement('span');
18
+ c.textContent = label;
19
+ c.style.cssText = 'padding:0.45em 0.9em;border-radius:999px;background:var(--m-bg-surface);white-space:nowrap;will-change:transform,opacity';
20
+ el.appendChild(c);
21
+ return c;
22
+ });
23
+ return {
24
+ seek(t) {
25
+ chips.forEach((c, i) => {
26
+ const k = progress(t, i * stagger, each, ease);
27
+ c.style.opacity = String(k);
28
+ c.style.transform = `scale(${0.9 + 0.1 * k})`;
29
+ });
30
+ },
31
+ };
32
+ },
33
+ };
@@ -0,0 +1,4 @@
1
+ import type { Primitive, TransitionPrimitive } from './types.ts';
2
+ export declare const PRIMITIVES: Record<string, Primitive>;
3
+ export declare const TRANSITIONS: Record<string, TransitionPrimitive>;
4
+ export type { Ctx, ParamSpec, Primitive, PropSpec, TransitionPrimitive } from './types.ts';