@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,2 @@
1
+ import { type Primitive } from '../types.ts';
2
+ export declare const wordRoller: Primitive;
@@ -0,0 +1,80 @@
1
+ // type/word-roller. See library/primitives/type/word-roller.md.
2
+ import { progress } from "../../core/ease.js";
3
+ import { list, num, str } from "../types.js";
4
+ export const wordRoller = {
5
+ slug: 'type/word-roller',
6
+ summary: 'Words roll vertically in a slot.',
7
+ props: {
8
+ before: { type: 'string', default: '', label: 'Text before the slot' },
9
+ words: { type: 'string[]', required: true, label: 'Words that take turns in the slot; the last one stays' },
10
+ after: { type: 'string', default: '', label: 'Text after the slot' },
11
+ },
12
+ params: {
13
+ per_word: { type: 'number', default: 0.9, min: 0.5, max: 1.6, step: 0.05, unit: 's', label: 'Time each word stays' },
14
+ roll: { type: 'number', default: 0.5, min: 0.3, max: 0.7, step: 0.05, unit: 's', label: 'Time to roll to the next' },
15
+ direction: { type: 'choice', default: 'up', options: ['up', 'down'], label: 'Roll direction' },
16
+ style: { type: 'choice', default: 'roll', options: ['roll', 'lift'], label: 'Roll through a clipped slot, or lift: the word lifts away out of focus, a beat, the next settles in (a status line)' },
17
+ gap: { type: 'number', default: 0.05, min: 0, max: 0.2, step: 0.01, unit: 's', label: 'For lift: the empty beat between the words' },
18
+ },
19
+ duration: (props, p) => Math.max(0, list(props.words).length - 1) * num(p.per_word) + num(p.roll),
20
+ build(el, props, p, ctx) {
21
+ const doc = el.ownerDocument;
22
+ const words = list(props.words);
23
+ const per = num(p.per_word), roll = num(p.roll), dir = p.direction === 'down' ? -1 : 1;
24
+ const ease = ctx.ease('quint.inOut'), lift = p.style === 'lift', swap = ctx.ease('cubic.inOut');
25
+ // A lift: out over half of what is left after the gap, the gap, then the mirror in.
26
+ const gap = Math.min(num(p.gap), roll * 0.5), half = (roll - gap) / 2;
27
+ el.style.whiteSpace = 'nowrap';
28
+ const before = doc.createElement('span'), after = doc.createElement('span');
29
+ before.textContent = str(props.before) ? `${str(props.before)} ` : '';
30
+ after.textContent = str(props.after) ? ` ${str(props.after)}` : '';
31
+ // The slot clips the rolling words and eases its width to the word inside it,
32
+ // so the sentence closes up around a short word instead of leaving a gap.
33
+ const slot = doc.createElement('span');
34
+ slot.style.cssText = `display:inline-block;position:relative;overflow:${lift ? 'visible' : 'hidden'};vertical-align:bottom;padding:0.14em 0;margin:-0.14em 0;color:var(--m-accent)`;
35
+ const cells = words.map((w) => {
36
+ const c = doc.createElement('span');
37
+ c.textContent = w;
38
+ c.style.cssText = 'position:absolute;left:0;top:0.14em;white-space:pre';
39
+ slot.appendChild(c);
40
+ return c;
41
+ });
42
+ const probe = doc.createElement('span');
43
+ probe.style.cssText = 'visibility:hidden;white-space:pre';
44
+ probe.textContent = words.reduce((a, b) => (b.length > a.length ? b : a), '');
45
+ slot.appendChild(probe);
46
+ el.append(before, slot, after);
47
+ const widths = cells.map((c) => c.offsetWidth);
48
+ probe.style.display = 'inline-block';
49
+ probe.style.width = '0px';
50
+ return {
51
+ seek(t) {
52
+ // Word i rolls in over [i * per, i * per + roll] while word i - 1 rolls out.
53
+ const i = Math.max(0, Math.min(words.length - 1, Math.floor(t / per + 1e-9)));
54
+ const k = i === 0 ? 1 : progress(t - i * per, 0, roll, ease);
55
+ if (lift) {
56
+ // Out: up 8 px, into a 2 px blur, fading. In: the mirror, from below.
57
+ const lt = t - i * per, out = i === 0 ? 1 : progress(lt, 0, half, swap), inn = i === 0 ? 1 : progress(lt, half + gap, half, swap);
58
+ cells.forEach((c, j) => {
59
+ const v = j === i ? 1 - inn : j === i - 1 ? -out : 1;
60
+ const shown = j === i ? inn : j === i - 1 ? 1 - out : 0;
61
+ c.style.visibility = shown <= 0 ? 'hidden' : 'inherit';
62
+ c.style.opacity = shown >= 1 ? '' : shown.toFixed(4);
63
+ c.style.transform = v === 0 ? '' : `translateY(${(dir * v * 8).toFixed(3)}px)`;
64
+ c.style.filter = v === 0 ? '' : `blur(${(Math.abs(v) * 2).toFixed(3)}px)`;
65
+ });
66
+ const w = i === 0 ? widths[0] : widths[i - 1] + (widths[i] - widths[i - 1]) * k;
67
+ slot.style.width = `${w.toFixed(2)}px`;
68
+ return;
69
+ }
70
+ cells.forEach((c, j) => {
71
+ const y = j === i ? 1 - k : j === i - 1 ? -k : 1;
72
+ c.style.transform = y === 0 ? '' : `translateY(${(dir * y * 110).toFixed(3)}%)`;
73
+ c.style.visibility = Math.abs(y) >= 1 ? 'hidden' : 'inherit';
74
+ });
75
+ const w = i === 0 ? widths[0] : widths[i - 1] + (widths[i] - widths[i - 1]) * k;
76
+ slot.style.width = `${w.toFixed(2)}px`;
77
+ },
78
+ };
79
+ },
80
+ };
@@ -0,0 +1,183 @@
1
+ import type { Bezier, EaseSpec } from '../core/ease.ts';
2
+ import type { Tokens } from '../tokens.ts';
3
+ export interface ParamSpec {
4
+ type: 'number' | 'ease' | 'boolean' | 'choice';
5
+ default: unknown;
6
+ min?: number;
7
+ max?: number;
8
+ step?: number;
9
+ unit?: string;
10
+ options?: readonly string[];
11
+ label: string;
12
+ /** Two number params that share a pad name are tuned together on one 2D pad. */
13
+ pad?: {
14
+ name: string;
15
+ axis: 'x' | 'y';
16
+ };
17
+ /** The library entry this param belongs to, when it is not the primitive's own. */
18
+ from?: string;
19
+ }
20
+ export interface PropSpec {
21
+ type: 'string' | 'number' | 'string[]' | 'number[]' | 'html';
22
+ required?: boolean;
23
+ default?: unknown;
24
+ label: string;
25
+ }
26
+ export interface Ctx {
27
+ tokens: Tokens;
28
+ seed: number;
29
+ size: [number, number];
30
+ /** Frames per second of the film being drawn: speeds in px per frame need it. */
31
+ fps: number;
32
+ /** Resolves an ease with the page theme's curves applied. */
33
+ ease(spec: EaseSpec | undefined): (x: number) => number;
34
+ easeOverrides: Record<string, Bezier>;
35
+ /** Host-provided content for `el/slot` layers, by slot name. */
36
+ slots: Record<string, (el: HTMLElement) => void>;
37
+ /**
38
+ * Still frames pulled from this layer's footage, when drawing for a render.
39
+ * Set per layer by the CLI (render, check, stills); left out in the studio,
40
+ * where footage plays from a video element.
41
+ */
42
+ frames?: FrameSequence;
43
+ /** Seconds per beat, when the film has a tempo. Light that pulses on the beat reads it. */
44
+ beat?: number;
45
+ /** The film time this layer starts at, so a phase can come from the film's clock, not the layer's. */
46
+ filmStart?: number;
47
+ /**
48
+ * The scale the camera shows this layer's scene at in the frame being drawn: 2 when it is
49
+ * twice as big. A canvas sizes its bitmap to it, so it stays sharp in a close-up. It is the
50
+ * frame's own camera, read after the camera is placed, so it never lags a frame.
51
+ */
52
+ cameraScale?: () => number;
53
+ /**
54
+ * Where another layer of the same scene sits, laid out and unmoved, in the camera's px (the
55
+ * stage's px at rest): for a field that keeps clear of the marks on it. Undefined for an id
56
+ * the scene does not have. Measure in seek, not build: later layers are not built yet then.
57
+ */
58
+ boxOf?: (id: string) => {
59
+ x: number;
60
+ y: number;
61
+ w: number;
62
+ h: number;
63
+ } | undefined;
64
+ /** The camera of this layer's scene in the frame being drawn: its scale and its tilt in degrees. */
65
+ cameraPose?: () => {
66
+ scale: number;
67
+ rotateX: number;
68
+ rotateY: number;
69
+ };
70
+ /**
71
+ * Smaller copies of this layer's footage (½, ¼, …), largest first, for a picture shown much
72
+ * smaller than it was pulled: drawing each size from the copy nearest it keeps fine detail from
73
+ * shimmering as the camera pulls out.
74
+ */
75
+ mips?: FrameSequence[];
76
+ }
77
+ /** Frames of a video, extracted to numbered images so every film frame is exact. */
78
+ export interface FrameSequence {
79
+ /** URL prefix; frame n (0-based) is `${base}${String(n + 1).padStart(5, '0')}.${ext}`. */
80
+ base: string;
81
+ ext: string;
82
+ count: number;
83
+ /** Source time of frame 0, in seconds. */
84
+ start: number;
85
+ /** Extracted frames per second of source time. */
86
+ rate: number;
87
+ /** The source's own size in px. */
88
+ width: number;
89
+ height: number;
90
+ /** Boxes of elements recorded with the footage (`motion record --marks`), in the source's px. */
91
+ marks?: {
92
+ fps: number;
93
+ size: [number, number];
94
+ marks: Record<string, ([number, number, number, number] | null)[]>;
95
+ };
96
+ }
97
+ export declare const frameUrl: (f: FrameSequence, n: number) => string;
98
+ /** What `duration` may use: everything except the page. */
99
+ export type PureCtx = Pick<Ctx, 'tokens' | 'seed' | 'size'>;
100
+ export interface Instance {
101
+ seek(t: number): void;
102
+ /**
103
+ * Resolves when what the last seek asked for is on screen. Only for content
104
+ * that loads after a seek, such as the next frame of footage; the page awaits
105
+ * it before a frame is captured.
106
+ */
107
+ pending?(): Promise<void>;
108
+ /**
109
+ * Where the primitive's moving point is at t, in px from the layer's top-left:
110
+ * the tip of a line being drawn. A scene's camera can follow it.
111
+ */
112
+ tip?(t: number): [number, number] | undefined;
113
+ /**
114
+ * Where a named mark in the primitive's picture is at t, as [x, y, width, height] in px from
115
+ * the layer's top-left, unmoved: the button a camera key frames, or a tap's ring goes round.
116
+ */
117
+ markAt?(name: string, t: number): [number, number, number, number] | undefined;
118
+ }
119
+ /**
120
+ * A change inside a primitive's own run: a picture swap, a slide turning, a strip
121
+ * shift. Seconds from the layer start. The pace check reads these to see whether a
122
+ * film's changes share one length and land on its beat.
123
+ */
124
+ export interface Cue {
125
+ at: number;
126
+ length: number;
127
+ /** Which part changes (a tile, a row), when several change on their own clocks. Rests are measured per lane. */
128
+ lane?: number;
129
+ /** Share of the frame that changes, 0–1: a tile a quarter of the frame is 0.25. Left out, the whole frame. */
130
+ share?: number;
131
+ }
132
+ /** A problem a primitive finds in its own props and params, beyond their types and ranges. */
133
+ export interface PrimitiveIssue {
134
+ /** Relative to the layer, e.g. `props.to`. */
135
+ path: string;
136
+ message: string;
137
+ hint?: string;
138
+ }
139
+ export interface Primitive {
140
+ slug: string;
141
+ summary: string;
142
+ props: Record<string, PropSpec>;
143
+ params: Record<string, ParamSpec>;
144
+ duration(props: Record<string, unknown>, params: Record<string, unknown>, ctx: PureCtx): number;
145
+ /** Optional checks that need more than one value at a time. Pure, like duration. */
146
+ check?(props: Record<string, unknown>, params: Record<string, unknown>, ctx: PureCtx): PrimitiveIssue[];
147
+ build(el: HTMLElement, props: Record<string, unknown>, params: Record<string, unknown>, ctx: Ctx): Instance;
148
+ /**
149
+ * Optional, pure: the changes inside the run, for primitives that hold and change
150
+ * on their own clock. Return [] for ambient motion (drift, grain, marquees) that
151
+ * never reads as a move. Left out, the whole run counts as one move.
152
+ */
153
+ cues?(props: Record<string, unknown>, params: Record<string, unknown>, ctx: PureCtx): Cue[];
154
+ /**
155
+ * The layer runs in rounds with no natural end (a living wall): its duration is
156
+ * one full round, and a scene may end it on any rest between changes. A scene
157
+ * that ends it in the middle of a change is still reported.
158
+ */
159
+ cycles?: boolean;
160
+ /**
161
+ * Optional, pure: the fastest the layer's picture travels across the stage, in px a
162
+ * second (a pan along a wide picture). The pace check warns when a frame-to-frame
163
+ * step is large enough to strobe.
164
+ */
165
+ speed?(props: Record<string, unknown>, params: Record<string, unknown>, ctx: PureCtx): number;
166
+ }
167
+ export interface TransitionPrimitive {
168
+ slug: string;
169
+ summary: string;
170
+ params: Record<string, ParamSpec>;
171
+ /** Default overlap in seconds. */
172
+ duration: number | string;
173
+ /** Quieter defaults, used when the film's `transitions` token is `calm`. Each must sit inside its param's range. */
174
+ calm?: Record<string, number | string | boolean>;
175
+ /** Draws the hand-over at progress k (0 = only the outgoing scene, 1 = only the incoming). */
176
+ apply(from: HTMLElement, to: HTMLElement, k: number, params: Record<string, unknown>, ctx: Ctx): void;
177
+ /** Removes whatever `apply` set, once the hand-over is not on screen. */
178
+ clear(el: HTMLElement): void;
179
+ }
180
+ export declare const num: (v: unknown, fallback?: number) => number;
181
+ export declare const str: (v: unknown, fallback?: string) => string;
182
+ export declare const list: (v: unknown) => string[];
183
+ export declare const nums: (v: unknown) => number[];
@@ -0,0 +1,5 @@
1
+ export const frameUrl = (f, n) => `${f.base}${String(Math.min(f.count - 1, Math.max(0, n)) + 1).padStart(5, '0')}.${f.ext}`;
2
+ export const num = (v, fallback = 0) => (typeof v === 'number' && Number.isFinite(v) ? v : fallback);
3
+ export const str = (v, fallback = '') => (typeof v === 'string' ? v : v == null ? fallback : String(v));
4
+ export const list = (v) => (Array.isArray(v) ? v.map((x) => String(x)) : []);
5
+ export const nums = (v) => (Array.isArray(v) ? v.map((x) => num(x)) : []);
@@ -0,0 +1,4 @@
1
+ import { type Primitive } from '../types.ts';
2
+ /** Seconds from the layer's start to the moment the click is fully down. */
3
+ export declare const clickAt: (p: Record<string, unknown>) => number;
4
+ export declare const cursorClick: Primitive;
@@ -0,0 +1,68 @@
1
+ // ui/cursor-click. See library/primitives/ui/cursor-click.md.
2
+ import { progress } from "../../core/ease.js";
3
+ import { num, str } from "../types.js";
4
+ const ARROW = 'M2 1.5 L2 20.5 L7.2 15.6 L10.6 23.2 L14 21.7 L10.7 14.2 L17.6 14.2 Z';
5
+ /** Seconds from the layer's start to the moment the click is fully down. */
6
+ export const clickAt = (p) => timing(p).at + timing(p).press;
7
+ function timing(p) {
8
+ const travel = num(p.travel), press = 0.08;
9
+ return { travel, press, at: travel + 0.06, end: travel + 0.06 + press * 2 + 0.55 };
10
+ }
11
+ export const cursorClick = {
12
+ slug: 'ui/cursor-click',
13
+ summary: 'A drawn cursor moves to a target and clicks.',
14
+ props: {
15
+ label: { type: 'string', default: '', label: 'A name tag beside the cursor, for a collaborator' },
16
+ target: { type: 'string', default: '', label: 'The id of the layer it clicks: that layer presses, and the ring leaves it in its own shape' },
17
+ },
18
+ params: {
19
+ from_x: { type: 'number', default: 78, min: 0, max: 100, step: 0.5, unit: '% of width', label: 'Start, across', pad: { name: 'start', axis: 'x' } },
20
+ from_y: { type: 'number', default: 82, min: 0, max: 100, step: 0.5, unit: '% of height', label: 'Start, down', pad: { name: 'start', axis: 'y' } },
21
+ to_x: { type: 'number', default: 50, min: 0, max: 100, step: 0.5, unit: '% of width', label: 'Target, across', pad: { name: 'target', axis: 'x' } },
22
+ to_y: { type: 'number', default: 50, min: 0, max: 100, step: 0.5, unit: '% of height', label: 'Target, down', pad: { name: 'target', axis: 'y' } },
23
+ travel: { type: 'number', default: 0.7, min: 0.3, max: 1.8, step: 0.05, unit: 's', label: 'Time to reach the target' },
24
+ arc: { type: 'number', default: 0.06, min: 0, max: 0.2, step: 0.01, unit: 'ratio', label: 'Bow of the path' },
25
+ size: { type: 'number', default: 2.4, min: 1.5, max: 4, step: 0.1, unit: '% of width', label: 'Cursor size' },
26
+ },
27
+ duration: (_props, p) => timing(p).end,
28
+ build(el, props, p, ctx) {
29
+ const doc = el.ownerDocument;
30
+ const [W, H] = ctx.size, T = timing(p);
31
+ const x0 = (num(p.from_x) / 100) * W, y0 = (num(p.from_y) / 100) * H, x1 = (num(p.to_x) / 100) * W, y1 = (num(p.to_y) / 100) * H;
32
+ // The path bows to one side, as a hand does; the bow is a share of the distance.
33
+ const len = Math.hypot(x1 - x0, y1 - y0), bow = num(p.arc) * len;
34
+ const mx = (x0 + x1) / 2 - ((y1 - y0) / (len || 1)) * bow, my = (y0 + y1) / 2 + ((x1 - x0) / (len || 1)) * bow;
35
+ const size = (num(p.size) / 100) * W;
36
+ el.style.cssText += ';position:absolute;inset:0;max-width:none;pointer-events:none;z-index:40';
37
+ const ring = doc.createElement('div');
38
+ ring.style.cssText = `position:absolute;left:${x1}px;top:${y1}px;width:${size * 1.6}px;height:${size * 1.6}px;margin:${-size * 0.8}px 0 0 ${-size * 0.8}px;border-radius:50%;border:${size * 0.08}px solid var(--m-accent);opacity:0`;
39
+ const cursor = doc.createElement('div');
40
+ cursor.style.cssText = `position:absolute;left:0;top:0;width:${size}px;height:${size}px;transform-origin:8% 6%;filter:drop-shadow(0 ${size * 0.06}px ${size * 0.12}px rgba(0,0,0,0.28))`;
41
+ cursor.innerHTML = `<svg viewBox="0 0 24 24" width="${size}" height="${size}" style="display:block;overflow:visible"><path d="${ARROW}" fill="var(--m-text-primary)" stroke="var(--m-bg-base)" stroke-width="1.5" stroke-linejoin="round"/></svg>`;
42
+ if (str(props.label)) {
43
+ const tag = doc.createElement('span');
44
+ tag.textContent = str(props.label);
45
+ tag.style.cssText = `position:absolute;left:${size * 0.7}px;top:${size * 0.9}px;padding:${size * 0.12}px ${size * 0.3}px;border-radius:${size * 0.3}px;background:var(--m-bg-accent);color:var(--m-text-on-accent);font:600 ${size * 0.42}px var(--m-font-body);white-space:nowrap`;
46
+ cursor.appendChild(tag);
47
+ }
48
+ // A click on a layer draws its ring around that layer (a tap), not round the tip.
49
+ const own = !str(props.target);
50
+ el.append(...(own ? [ring] : []), cursor);
51
+ const move = ctx.ease([0.45, 0, 0.15, 1]), out = ctx.ease('expressive.out');
52
+ return {
53
+ seek(t) {
54
+ const k = progress(t, 0, T.travel, move);
55
+ const x = (1 - k) * (1 - k) * x0 + 2 * (1 - k) * k * mx + k * k * x1;
56
+ const y = (1 - k) * (1 - k) * y0 + 2 * (1 - k) * k * my + k * k * y1;
57
+ // Press: a quick squeeze down and back, then a ring spreads from the tip.
58
+ const down = progress(t, T.at, T.press, (v) => v), up = progress(t, T.at + T.press, T.press * 1.5, out);
59
+ const s = 1 - 0.14 * (down - up);
60
+ cursor.style.transform = `translate(${(x - size * 0.08).toFixed(2)}px, ${(y - size * 0.06).toFixed(2)}px) scale(${s.toFixed(4)})`;
61
+ cursor.style.opacity = Math.min(1, t / 0.15).toFixed(3);
62
+ const r = progress(t, T.at + T.press, 0.55, out);
63
+ ring.style.opacity = r > 0 ? (0.9 * (1 - r)).toFixed(3) : '0';
64
+ ring.style.transform = `scale(${(0.3 + r * 1.1).toFixed(4)})`;
65
+ },
66
+ };
67
+ },
68
+ };
@@ -0,0 +1,17 @@
1
+ import { type Primitive } from '../types.ts';
2
+ export interface ScrollPlan {
3
+ from: number;
4
+ to: number;
5
+ stops: number[];
6
+ duration: number;
7
+ rest: number;
8
+ delay: number;
9
+ }
10
+ /**
11
+ * How the scroll's travelling time is shared between its legs. A leg four times as long takes twice
12
+ * as long: a long leg is faster, as a hand scrolls, but never a flash next to a short one.
13
+ */
14
+ export declare function legTimes(marks: number[], travel: number): number[];
15
+ /** Share of the scrollable height (0–100) the page has travelled t seconds in. Eased leg by leg, resting at each stop. */
16
+ export declare function scrollAt(t: number, p: ScrollPlan, ease: (x: number) => number): number;
17
+ export declare const pageScroll: Primitive;
@@ -0,0 +1,98 @@
1
+ // ui/page-scroll. See library/primitives/ui/page-scroll.md.
2
+ //
3
+ // A page seen through a window, scrolled the way a person reads it: it travels,
4
+ // rests on a section, travels again. The page is one tall capture or its
5
+ // sections stacked. It smears along the scroll only, by its speed.
6
+ import { clamp } from "../../core/ease.js";
7
+ import { directionalBlur, streak } from "../blur.js";
8
+ import { list, num, nums, str } from "../types.js";
9
+ /**
10
+ * How the scroll's travelling time is shared between its legs. A leg four times as long takes twice
11
+ * as long: a long leg is faster, as a hand scrolls, but never a flash next to a short one.
12
+ */
13
+ export function legTimes(marks, travel) {
14
+ const weights = marks.slice(1).map((m, i) => Math.sqrt(Math.abs(m - marks[i])));
15
+ const sum = weights.reduce((a, b) => a + b, 0);
16
+ return weights.map((w) => (sum > 0 ? (travel * w) / sum : travel / weights.length));
17
+ }
18
+ /** Share of the scrollable height (0–100) the page has travelled t seconds in. Eased leg by leg, resting at each stop. */
19
+ export function scrollAt(t, p, ease) {
20
+ const marks = [p.from, ...p.stops, p.to];
21
+ const legs = marks.length - 1;
22
+ const rest = legs > 1 ? Math.min(p.rest, (p.duration * 0.5) / (legs - 1)) : 0;
23
+ const times = legTimes(marks, p.duration - rest * (legs - 1));
24
+ let u = t - p.delay;
25
+ if (u <= 0)
26
+ return marks[0];
27
+ for (let i = 0; i < legs; i++) {
28
+ const leg = times[i];
29
+ if (u < leg)
30
+ return marks[i] + (marks[i + 1] - marks[i]) * ease(clamp(u / leg));
31
+ u -= leg;
32
+ if (i < legs - 1) {
33
+ if (u < rest)
34
+ return marks[i + 1];
35
+ u -= rest;
36
+ }
37
+ }
38
+ return marks[legs];
39
+ }
40
+ const plan = (props, p) => ({
41
+ from: num(p.from), to: num(p.to, 100), stops: nums(props.stops), duration: num(p.duration, 3), rest: num(p.rest, 0.4), delay: num(p.delay),
42
+ });
43
+ /** Room above and below the window for the smear to fall off in, out of sight. */
44
+ const MARGIN = 150;
45
+ export const pageScroll = {
46
+ slug: 'ui/page-scroll',
47
+ summary: 'A page scrolls inside a window, resting on its sections, blurred only by its own speed.',
48
+ props: {
49
+ srcs: { type: 'string[]', required: true, label: 'The page: one tall capture, or its sections from top to bottom' },
50
+ alt: { type: 'string', default: '', label: 'Description of the page' },
51
+ stops: { type: 'number[]', default: [], label: 'Where the scroll rests on the way, in % of the scrollable height' },
52
+ },
53
+ params: {
54
+ width: { type: 'number', default: 640, min: 1, max: 4000, step: 1, unit: 'px', label: 'Window width' },
55
+ height: { type: 'number', default: 800, min: 1, max: 4000, step: 1, unit: 'px', label: 'Window height' },
56
+ radius: { type: 'number', default: 16, min: 0, max: 400, step: 1, unit: 'px', label: 'Corner radius' },
57
+ from: { type: 'number', default: 0, min: 0, max: 100, step: 0.5, unit: '% of scroll', label: 'Where the scroll starts' },
58
+ to: { type: 'number', default: 100, min: 0, max: 100, step: 0.5, unit: '% of scroll', label: 'Where the scroll ends' },
59
+ duration: { type: 'number', default: 3, min: 0.4, max: 30, step: 0.05, unit: 's', label: 'Length of the scroll, rests included' },
60
+ rest: { type: 'number', default: 0.4, min: 0, max: 3, step: 0.05, unit: 's', label: 'Time resting at each stop' },
61
+ delay: { type: 'number', default: 0, min: 0, max: 30, step: 0.05, unit: 's', label: 'Time held at the start before it scrolls' },
62
+ ease: { type: 'ease', default: 'sine.inOut', label: 'Curve of each leg' },
63
+ shutter: { type: 'number', default: 0.5, min: 0, max: 1, step: 0.05, unit: 'ratio', label: 'Motion blur: share of a frame the scroll smears over' },
64
+ },
65
+ duration: (props, p) => { const s = plan(props, p); return s.delay + s.duration; },
66
+ build(el, props, p, ctx) {
67
+ const doc = el.ownerDocument, w = num(p.width), h = num(p.height);
68
+ // The engine places `el`, so the window that positions the page is a child of it.
69
+ el.style.cssText += `;width:${w}px;height:${h}px;border-radius:${num(p.radius)}px;overflow:hidden`;
70
+ const win = doc.createElement('div');
71
+ win.style.cssText = `position:relative;width:${w}px;height:${h}px`;
72
+ // The smear is drawn on a taller pane behind the window, so its soft ends are cut off by the window.
73
+ const pane = doc.createElement('div');
74
+ pane.style.cssText = `position:absolute;left:0;top:${-MARGIN}px;width:${w}px;height:${h + 2 * MARGIN}px;overflow:hidden`;
75
+ const page = doc.createElement('div');
76
+ page.style.cssText = `position:absolute;left:0;top:${MARGIN}px;width:${w}px;will-change:transform`;
77
+ list(props.srcs).forEach((src, i) => {
78
+ const img = doc.createElement('img');
79
+ img.src = src;
80
+ img.alt = i === 0 ? str(props.alt) : '';
81
+ img.decoding = 'sync';
82
+ img.style.cssText = 'display:block;width:100%;height:auto';
83
+ page.appendChild(img);
84
+ });
85
+ pane.appendChild(page);
86
+ win.appendChild(pane);
87
+ el.appendChild(win);
88
+ const s = plan(props, p), ease = ctx.ease(p.ease), shutter = num(p.shutter, 0.5), half = 0.5 / ctx.fps;
89
+ return {
90
+ seek(t) {
91
+ const range = Math.max(0, page.offsetHeight - h);
92
+ const y = (at) => (scrollAt(at, s, ease) / 100) * range;
93
+ page.style.transform = `translateY(${(-y(t)).toFixed(2)}px)`;
94
+ pane.style.filter = directionalBlur(pane, 0, streak(y(t + half) - y(t - half), shutter));
95
+ },
96
+ };
97
+ },
98
+ };
@@ -0,0 +1,4 @@
1
+ /** One transform of length re.length (a power of two); `inverse` scales by 1/n. */
2
+ export declare function fft(re: Float64Array, im: Float64Array, inverse?: boolean): void;
3
+ /** A 2D transform of an n × n grid stored row by row. */
4
+ export declare function fft2(re: Float64Array, im: Float64Array, n: number, inverse?: boolean): void;
@@ -0,0 +1,71 @@
1
+ // A small radix-2 FFT, in place, for the review's phase correlation. Sizes are
2
+ // powers of two. Real and imaginary parts live in separate arrays.
3
+ /** One transform of length re.length (a power of two); `inverse` scales by 1/n. */
4
+ export function fft(re, im, inverse = false) {
5
+ const n = re.length;
6
+ if (n & (n - 1))
7
+ throw new Error(`fft: length ${n} is not a power of two`);
8
+ for (let i = 1, j = 0; i < n; i++) {
9
+ let bit = n >> 1;
10
+ for (; j & bit; bit >>= 1)
11
+ j ^= bit;
12
+ j ^= bit;
13
+ if (i < j) {
14
+ let t = re[i];
15
+ re[i] = re[j];
16
+ re[j] = t;
17
+ t = im[i];
18
+ im[i] = im[j];
19
+ im[j] = t;
20
+ }
21
+ }
22
+ for (let len = 2; len <= n; len <<= 1) {
23
+ const ang = ((inverse ? 2 : -2) * Math.PI) / len, wr = Math.cos(ang), wi = Math.sin(ang);
24
+ for (let i = 0; i < n; i += len) {
25
+ let cr = 1, ci = 0;
26
+ for (let k = 0; k < len / 2; k++) {
27
+ const a = i + k, b = a + len / 2;
28
+ const xr = re[b] * cr - im[b] * ci, xi = re[b] * ci + im[b] * cr;
29
+ re[b] = re[a] - xr;
30
+ im[b] = im[a] - xi;
31
+ re[a] = re[a] + xr;
32
+ im[a] = im[a] + xi;
33
+ const t = cr * wr - ci * wi;
34
+ ci = cr * wi + ci * wr;
35
+ cr = t;
36
+ }
37
+ }
38
+ }
39
+ if (inverse)
40
+ for (let i = 0; i < n; i++) {
41
+ re[i] = re[i] / n;
42
+ im[i] = im[i] / n;
43
+ }
44
+ }
45
+ /** A 2D transform of an n × n grid stored row by row. */
46
+ export function fft2(re, im, n, inverse = false) {
47
+ const r = new Float64Array(n), i = new Float64Array(n);
48
+ for (let y = 0; y < n; y++) {
49
+ const o = y * n;
50
+ for (let x = 0; x < n; x++) {
51
+ r[x] = re[o + x];
52
+ i[x] = im[o + x];
53
+ }
54
+ fft(r, i, inverse);
55
+ for (let x = 0; x < n; x++) {
56
+ re[o + x] = r[x];
57
+ im[o + x] = i[x];
58
+ }
59
+ }
60
+ for (let x = 0; x < n; x++) {
61
+ for (let y = 0; y < n; y++) {
62
+ r[y] = re[y * n + x];
63
+ i[y] = im[y * n + x];
64
+ }
65
+ fft(r, i, inverse);
66
+ for (let y = 0; y < n; y++) {
67
+ re[y * n + x] = r[y];
68
+ im[y * n + x] = i[y];
69
+ }
70
+ }
71
+ }