@bydiorama/motion 0.0.0-stage → 0.4.1
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.
- package/CREDITS.md +53 -0
- package/LICENSE +21 -0
- package/README.md +137 -2
- package/catalog.json +4697 -0
- package/dist/npm/brief/brief.d.ts +28 -0
- package/dist/npm/brief/brief.js +159 -0
- package/dist/npm/brief/types.d.ts +75 -0
- package/dist/npm/brief/types.js +2 -0
- package/dist/npm/browser/motion.js +1039 -0
- package/dist/npm/browser/page.js +4821 -0
- package/dist/npm/browser/wizard.js +1511 -0
- package/dist/npm/build/design.d.ts +54 -0
- package/dist/npm/build/design.js +91 -0
- package/dist/npm/build/index.d.ts +39 -0
- package/dist/npm/build/index.js +66 -0
- package/dist/npm/build/iso.d.ts +41 -0
- package/dist/npm/build/iso.js +71 -0
- package/dist/npm/catalog.d.ts +24 -0
- package/dist/npm/catalog.js +23 -0
- package/dist/npm/cli/browser.d.ts +26 -0
- package/dist/npm/cli/browser.js +66 -0
- package/dist/npm/cli/capture.d.ts +26 -0
- package/dist/npm/cli/capture.js +94 -0
- package/dist/npm/cli/files.d.ts +14 -0
- package/dist/npm/cli/files.js +87 -0
- package/dist/npm/cli/frames.d.ts +27 -0
- package/dist/npm/cli/frames.js +125 -0
- package/dist/npm/cli/guard.d.ts +23 -0
- package/dist/npm/cli/guard.js +158 -0
- package/dist/npm/cli/library.d.ts +2 -0
- package/dist/npm/cli/library.js +55 -0
- package/dist/npm/cli/main.d.ts +17 -0
- package/dist/npm/cli/main.js +964 -0
- package/dist/npm/cli/motion.d.ts +2 -0
- package/dist/npm/cli/motion.js +6 -0
- package/dist/npm/cli/record.d.ts +36 -0
- package/dist/npm/cli/record.js +142 -0
- package/dist/npm/cli/review.d.ts +45 -0
- package/dist/npm/cli/review.js +139 -0
- package/dist/npm/cli/schema.d.ts +852 -0
- package/dist/npm/cli/schema.js +120 -0
- package/dist/npm/cli/server.d.ts +17 -0
- package/dist/npm/cli/server.js +135 -0
- package/dist/npm/core/ease.d.ts +39 -0
- package/dist/npm/core/ease.js +176 -0
- package/dist/npm/core/frame.d.ts +52 -0
- package/dist/npm/core/frame.js +60 -0
- package/dist/npm/core/shapes.d.ts +8 -0
- package/dist/npm/core/shapes.js +88 -0
- package/dist/npm/core/stagger.d.ts +19 -0
- package/dist/npm/core/stagger.js +77 -0
- package/dist/npm/core/tap.d.ts +19 -0
- package/dist/npm/core/tap.js +42 -0
- package/dist/npm/core/track.d.ts +4 -0
- package/dist/npm/core/track.js +23 -0
- package/dist/npm/dom/mount.d.ts +127 -0
- package/dist/npm/dom/mount.js +950 -0
- package/dist/npm/dom/page.d.ts +37 -0
- package/dist/npm/dom/page.js +77 -0
- package/dist/npm/dom/soundtrack.d.ts +13 -0
- package/dist/npm/dom/soundtrack.js +37 -0
- package/dist/npm/dom/stage.css.d.ts +1 -0
- package/dist/npm/dom/stage.css.js +44 -0
- package/dist/npm/dom/tokens.d.ts +10 -0
- package/dist/npm/dom/tokens.js +38 -0
- package/dist/npm/dom/ui-themes.css.d.ts +8 -0
- package/dist/npm/dom/ui-themes.css.js +9 -0
- package/dist/npm/film/beats.d.ts +64 -0
- package/dist/npm/film/beats.js +282 -0
- package/dist/npm/film/pace.d.ts +94 -0
- package/dist/npm/film/pace.js +396 -0
- package/dist/npm/film/resolve.d.ts +16 -0
- package/dist/npm/film/resolve.js +997 -0
- package/dist/npm/film/tempo.d.ts +19 -0
- package/dist/npm/film/tempo.js +34 -0
- package/dist/npm/film/tune.d.ts +17 -0
- package/dist/npm/film/tune.js +68 -0
- package/dist/npm/film/types.d.ts +416 -0
- package/dist/npm/film/types.js +16 -0
- package/dist/npm/index.d.ts +18 -0
- package/dist/npm/index.js +11 -0
- package/dist/npm/primitives/blur.d.ts +14 -0
- package/dist/npm/primitives/blur.js +59 -0
- package/dist/npm/primitives/canvas.d.ts +5 -0
- package/dist/npm/primitives/canvas.js +13 -0
- package/dist/npm/primitives/el/box.d.ts +2 -0
- package/dist/npm/primitives/el/box.js +24 -0
- package/dist/npm/primitives/el/frames.d.ts +15 -0
- package/dist/npm/primitives/el/frames.js +71 -0
- package/dist/npm/primitives/el/html.d.ts +2 -0
- package/dist/npm/primitives/el/html.js +14 -0
- package/dist/npm/primitives/el/image.d.ts +2 -0
- package/dist/npm/primitives/el/image.js +43 -0
- package/dist/npm/primitives/el/slot.d.ts +2 -0
- package/dist/npm/primitives/el/slot.js +25 -0
- package/dist/npm/primitives/el/text.d.ts +2 -0
- package/dist/npm/primitives/el/text.js +13 -0
- package/dist/npm/primitives/el/video.d.ts +6 -0
- package/dist/npm/primitives/el/video.js +179 -0
- package/dist/npm/primitives/fx/counter-roll.d.ts +2 -0
- package/dist/npm/primitives/fx/counter-roll.js +32 -0
- package/dist/npm/primitives/fx/depth-drift.d.ts +2 -0
- package/dist/npm/primitives/fx/depth-drift.js +44 -0
- package/dist/npm/primitives/fx/grid-ripple.d.ts +2 -0
- package/dist/npm/primitives/fx/grid-ripple.js +59 -0
- package/dist/npm/primitives/fx/odometer.d.ts +2 -0
- package/dist/npm/primitives/fx/odometer.js +80 -0
- package/dist/npm/primitives/fx/pan-across.d.ts +17 -0
- package/dist/npm/primitives/fx/pan-across.js +76 -0
- package/dist/npm/primitives/fx/path-draw.d.ts +2 -0
- package/dist/npm/primitives/fx/path-draw.js +105 -0
- package/dist/npm/primitives/fx/pin-drop.d.ts +2 -0
- package/dist/npm/primitives/fx/pin-drop.js +92 -0
- package/dist/npm/primitives/fx/shape-morph.d.ts +2 -0
- package/dist/npm/primitives/fx/shape-morph.js +65 -0
- package/dist/npm/primitives/fx/slow-push.d.ts +13 -0
- package/dist/npm/primitives/fx/slow-push.js +56 -0
- package/dist/npm/primitives/fx/stagger-fill.d.ts +2 -0
- package/dist/npm/primitives/fx/stagger-fill.js +33 -0
- package/dist/npm/primitives/index.d.ts +4 -0
- package/dist/npm/primitives/index.js +78 -0
- package/dist/npm/primitives/rig/browser-window.d.ts +2 -0
- package/dist/npm/primitives/rig/browser-window.js +142 -0
- package/dist/npm/primitives/rig/camera.d.ts +36 -0
- package/dist/npm/primitives/rig/camera.js +81 -0
- package/dist/npm/primitives/rig/footage-plane.d.ts +27 -0
- package/dist/npm/primitives/rig/footage-plane.js +257 -0
- package/dist/npm/primitives/rig/layer-stack.d.ts +39 -0
- package/dist/npm/primitives/rig/layer-stack.js +276 -0
- package/dist/npm/primitives/rig/orbit-ring.d.ts +2 -0
- package/dist/npm/primitives/rig/orbit-ring.js +59 -0
- package/dist/npm/primitives/rig/tab-stack.d.ts +9 -0
- package/dist/npm/primitives/rig/tab-stack.js +143 -0
- package/dist/npm/primitives/scene/bar-chart.d.ts +2 -0
- package/dist/npm/primitives/scene/bar-chart.js +83 -0
- package/dist/npm/primitives/scene/bento-grid.d.ts +49 -0
- package/dist/npm/primitives/scene/bento-grid.js +293 -0
- package/dist/npm/primitives/scene/grid-wall.d.ts +18 -0
- package/dist/npm/primitives/scene/grid-wall.js +110 -0
- package/dist/npm/primitives/scene/line-chart.d.ts +2 -0
- package/dist/npm/primitives/scene/line-chart.js +121 -0
- package/dist/npm/primitives/scene/logo-reveal.d.ts +2 -0
- package/dist/npm/primitives/scene/logo-reveal.js +117 -0
- package/dist/npm/primitives/scene/marquee-wall.d.ts +2 -0
- package/dist/npm/primitives/scene/marquee-wall.js +82 -0
- package/dist/npm/primitives/scene/post-carousel.d.ts +16 -0
- package/dist/npm/primitives/scene/post-carousel.js +195 -0
- package/dist/npm/primitives/scene/strip-cycle.d.ts +49 -0
- package/dist/npm/primitives/scene/strip-cycle.js +237 -0
- package/dist/npm/primitives/split.d.ts +34 -0
- package/dist/npm/primitives/split.js +105 -0
- package/dist/npm/primitives/texture/beat-field.d.ts +13 -0
- package/dist/npm/primitives/texture/beat-field.js +113 -0
- package/dist/npm/primitives/texture/gradient-drift.d.ts +2 -0
- package/dist/npm/primitives/texture/gradient-drift.js +56 -0
- package/dist/npm/primitives/texture/grain.d.ts +2 -0
- package/dist/npm/primitives/texture/grain.js +54 -0
- package/dist/npm/primitives/texture/halftone-field.d.ts +2 -0
- package/dist/npm/primitives/texture/halftone-field.js +36 -0
- package/dist/npm/primitives/texture/signal-field.d.ts +4 -0
- package/dist/npm/primitives/texture/signal-field.js +107 -0
- package/dist/npm/primitives/texture/vignette.d.ts +2 -0
- package/dist/npm/primitives/texture/vignette.js +23 -0
- package/dist/npm/primitives/transition/band-sweep.d.ts +22 -0
- package/dist/npm/primitives/transition/band-sweep.js +111 -0
- package/dist/npm/primitives/transition/beat-cut.d.ts +2 -0
- package/dist/npm/primitives/transition/beat-cut.js +10 -0
- package/dist/npm/primitives/transition/blur-dissolve.d.ts +2 -0
- package/dist/npm/primitives/transition/blur-dissolve.js +28 -0
- package/dist/npm/primitives/transition/camera-travel.d.ts +2 -0
- package/dist/npm/primitives/transition/camera-travel.js +69 -0
- package/dist/npm/primitives/transition/cover-reveal.d.ts +2 -0
- package/dist/npm/primitives/transition/cover-reveal.js +52 -0
- package/dist/npm/primitives/transition/curtain.d.ts +2 -0
- package/dist/npm/primitives/transition/curtain.js +40 -0
- package/dist/npm/primitives/transition/dive-in.d.ts +2 -0
- package/dist/npm/primitives/transition/dive-in.js +52 -0
- package/dist/npm/primitives/transition/fly-past.d.ts +2 -0
- package/dist/npm/primitives/transition/fly-past.js +87 -0
- package/dist/npm/primitives/transition/iris.d.ts +2 -0
- package/dist/npm/primitives/transition/iris.js +38 -0
- package/dist/npm/primitives/transition/overlay.d.ts +4 -0
- package/dist/npm/primitives/transition/overlay.js +24 -0
- package/dist/npm/primitives/transition/push.d.ts +2 -0
- package/dist/npm/primitives/transition/push.js +35 -0
- package/dist/npm/primitives/transition/signal-wipe.d.ts +2 -0
- package/dist/npm/primitives/transition/signal-wipe.js +67 -0
- package/dist/npm/primitives/transition/slant-wipe.d.ts +2 -0
- package/dist/npm/primitives/transition/slant-wipe.js +30 -0
- package/dist/npm/primitives/transition/stack-over.d.ts +2 -0
- package/dist/npm/primitives/transition/stack-over.js +38 -0
- package/dist/npm/primitives/transition/step-wipe.d.ts +2 -0
- package/dist/npm/primitives/transition/step-wipe.js +29 -0
- package/dist/npm/primitives/transition/strip-wipe.d.ts +40 -0
- package/dist/npm/primitives/transition/strip-wipe.js +121 -0
- package/dist/npm/primitives/transition/whip-pan.d.ts +2 -0
- package/dist/npm/primitives/transition/whip-pan.js +45 -0
- package/dist/npm/primitives/type/block-reveal.d.ts +2 -0
- package/dist/npm/primitives/type/block-reveal.js +61 -0
- package/dist/npm/primitives/type/char-cascade.d.ts +2 -0
- package/dist/npm/primitives/type/char-cascade.js +45 -0
- package/dist/npm/primitives/type/echo.d.ts +2 -0
- package/dist/npm/primitives/type/echo.js +57 -0
- package/dist/npm/primitives/type/fill-text.d.ts +14 -0
- package/dist/npm/primitives/type/fill-text.js +82 -0
- package/dist/npm/primitives/type/mask-reveal.d.ts +2 -0
- package/dist/npm/primitives/type/mask-reveal.js +58 -0
- package/dist/npm/primitives/type/scramble.d.ts +2 -0
- package/dist/npm/primitives/type/scramble.js +34 -0
- package/dist/npm/primitives/type/scribble-highlight.d.ts +2 -0
- package/dist/npm/primitives/type/scribble-highlight.js +84 -0
- package/dist/npm/primitives/type/shimmer.d.ts +2 -0
- package/dist/npm/primitives/type/shimmer.js +35 -0
- package/dist/npm/primitives/type/tracking-in.d.ts +2 -0
- package/dist/npm/primitives/type/tracking-in.js +37 -0
- package/dist/npm/primitives/type/typed-title.d.ts +2 -0
- package/dist/npm/primitives/type/typed-title.js +33 -0
- package/dist/npm/primitives/type/word-build.d.ts +2 -0
- package/dist/npm/primitives/type/word-build.js +44 -0
- package/dist/npm/primitives/type/word-roller.d.ts +2 -0
- package/dist/npm/primitives/type/word-roller.js +80 -0
- package/dist/npm/primitives/types.d.ts +183 -0
- package/dist/npm/primitives/types.js +5 -0
- package/dist/npm/primitives/ui/cursor-click.d.ts +4 -0
- package/dist/npm/primitives/ui/cursor-click.js +68 -0
- package/dist/npm/primitives/ui/page-scroll.d.ts +17 -0
- package/dist/npm/primitives/ui/page-scroll.js +98 -0
- package/dist/npm/review/fft.d.ts +4 -0
- package/dist/npm/review/fft.js +71 -0
- package/dist/npm/review/measure.d.ts +170 -0
- package/dist/npm/review/measure.js +577 -0
- package/dist/npm/tokens.d.ts +50 -0
- package/dist/npm/tokens.js +49 -0
- package/dist/npm/version.d.ts +1 -0
- package/dist/npm/version.js +1 -0
- package/examples/builder.film.mjs +18 -0
- package/films/feature-announcement.film.json +70 -0
- package/library/narratives/app-demo.md +64 -0
- package/library/narratives/brand-identity.md +78 -0
- package/library/narratives/capability-through-type.md +53 -0
- package/library/narratives/data-story.md +59 -0
- package/library/narratives/explainer.md +64 -0
- package/library/narratives/feature-announcement.md +68 -0
- package/library/narratives/infinite-loop.md +28 -0
- package/library/narratives/platform-launch.md +81 -0
- package/library/narratives/social-teaser.md +45 -0
- package/library/narratives/title-sequence.md +55 -0
- package/library/narratives/website-launch.md +65 -0
- package/library/primitives/fx/card-arrangements.md +26 -0
- package/library/primitives/fx/counter-roll.md +27 -0
- package/library/primitives/fx/depth-drift.md +32 -0
- package/library/primitives/fx/grid-ripple.md +58 -0
- package/library/primitives/fx/letter-interleave.md +26 -0
- package/library/primitives/fx/marquee-highlight.md +27 -0
- package/library/primitives/fx/mosaic-fill.md +23 -0
- package/library/primitives/fx/odometer.md +44 -0
- package/library/primitives/fx/pan-across.md +63 -0
- package/library/primitives/fx/path-draw.md +54 -0
- package/library/primitives/fx/pin-drop.md +51 -0
- package/library/primitives/fx/radial-burst.md +33 -0
- package/library/primitives/fx/shape-morph.md +45 -0
- package/library/primitives/fx/slow-push.md +63 -0
- package/library/primitives/fx/stagger-fill.md +28 -0
- package/library/primitives/rig/browser-window.md +113 -0
- package/library/primitives/rig/flip-ticker.md +26 -0
- package/library/primitives/rig/footage-plane.md +90 -0
- package/library/primitives/rig/layer-stack.md +168 -0
- package/library/primitives/rig/orbit-ring.md +43 -0
- package/library/primitives/rig/rolodex.md +31 -0
- package/library/primitives/rig/tab-stack.md +116 -0
- package/library/primitives/rig/tumbling-object.md +27 -0
- package/library/primitives/scene/bar-chart.md +49 -0
- package/library/primitives/scene/bento-grid.md +74 -0
- package/library/primitives/scene/end-card.md +28 -0
- package/library/primitives/scene/grid-wall.md +61 -0
- package/library/primitives/scene/hero-object.md +33 -0
- package/library/primitives/scene/kinetic-headline.md +34 -0
- package/library/primitives/scene/line-chart.md +47 -0
- package/library/primitives/scene/logo-reveal.md +53 -0
- package/library/primitives/scene/marquee-wall.md +33 -0
- package/library/primitives/scene/mosaic.md +28 -0
- package/library/primitives/scene/post-carousel.md +68 -0
- package/library/primitives/scene/specimen-grid.md +28 -0
- package/library/primitives/scene/stat-with-evidence.md +34 -0
- package/library/primitives/scene/strip-cycle.md +122 -0
- package/library/primitives/scene/zoomed-ui.md +29 -0
- package/library/primitives/texture/ascii.md +22 -0
- package/library/primitives/texture/beat-field.md +85 -0
- package/library/primitives/texture/depth-fade.md +23 -0
- package/library/primitives/texture/dither.md +27 -0
- package/library/primitives/texture/gradient-drift.md +50 -0
- package/library/primitives/texture/grain.md +39 -0
- package/library/primitives/texture/halftone-field.md +26 -0
- package/library/primitives/texture/signal-field.md +61 -0
- package/library/primitives/texture/vignette.md +53 -0
- package/library/primitives/transition/band-sweep.md +63 -0
- package/library/primitives/transition/beat-cut.md +27 -0
- package/library/primitives/transition/blur-dissolve.md +36 -0
- package/library/primitives/transition/camera-travel.md +57 -0
- package/library/primitives/transition/collapse-to-anchor.md +27 -0
- package/library/primitives/transition/cover-reveal.md +47 -0
- package/library/primitives/transition/curtain.md +42 -0
- package/library/primitives/transition/dive-in.md +51 -0
- package/library/primitives/transition/fly-past.md +51 -0
- package/library/primitives/transition/iris.md +49 -0
- package/library/primitives/transition/layout-locked-swap.md +28 -0
- package/library/primitives/transition/light-dark-flip.md +27 -0
- package/library/primitives/transition/push.md +47 -0
- package/library/primitives/transition/signal-wipe.md +52 -0
- package/library/primitives/transition/slant-wipe.md +44 -0
- package/library/primitives/transition/stack-over.md +51 -0
- package/library/primitives/transition/step-wipe.md +32 -0
- package/library/primitives/transition/strip-wipe.md +80 -0
- package/library/primitives/transition/torn-edge.md +26 -0
- package/library/primitives/transition/whip-pan.md +47 -0
- package/library/primitives/transition/zoom-through-letter.md +27 -0
- package/library/primitives/type/accent-number.md +22 -0
- package/library/primitives/type/block-reveal.md +41 -0
- package/library/primitives/type/char-cascade.md +65 -0
- package/library/primitives/type/echo.md +44 -0
- package/library/primitives/type/fill-text.md +63 -0
- package/library/primitives/type/focus-blur.md +22 -0
- package/library/primitives/type/inline-chips.md +27 -0
- package/library/primitives/type/mask-reveal.md +65 -0
- package/library/primitives/type/parting.md +23 -0
- package/library/primitives/type/per-word-restyle.md +28 -0
- package/library/primitives/type/scramble.md +26 -0
- package/library/primitives/type/scribble-highlight.md +47 -0
- package/library/primitives/type/shimmer.md +39 -0
- package/library/primitives/type/split-flap.md +26 -0
- package/library/primitives/type/style-multiply.md +23 -0
- package/library/primitives/type/tracking-in.md +40 -0
- package/library/primitives/type/typed-title.md +27 -0
- package/library/primitives/type/word-build.md +37 -0
- package/library/primitives/type/word-roller.md +52 -0
- package/library/primitives/type/writing-ticker.md +27 -0
- package/library/primitives/ui/collab-cursors.md +27 -0
- package/library/primitives/ui/cursor-click.md +61 -0
- package/library/primitives/ui/page-scroll.md +58 -0
- package/library/primitives/ui/prompt-typing.md +29 -0
- package/library/primitives/ui/streamed-result.md +23 -0
- package/library/primitives/ui/tour-hold.md +27 -0
- package/library/styles/brand-system.md +49 -0
- package/library/styles/clean-explainer.md +42 -0
- package/library/styles/dark-showcase.md +48 -0
- package/library/styles/editorial-type.md +37 -0
- package/library/styles/kinetic-poster.md +54 -0
- package/library/styles/product-ui.md +44 -0
- package/library/styles/studio-loop.md +41 -0
- package/library.json +1467 -0
- package/package.json +64 -4
- package/schema/film.schema.json +1316 -0
- package/showcase/vendor/DIALKIT-LICENSE +21 -0
- package/src/studio/theme/fonts/OFL.txt +94 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// transition/fly-past. See library/primitives/transition/fly-past.md.
|
|
2
|
+
//
|
|
3
|
+
// The outgoing scene comes apart: each of its layers flies towards the camera
|
|
4
|
+
// and past it, front layer first, tumbling away from the centre of the frame and
|
|
5
|
+
// going out of focus as it nears the lens. The next scene is already beneath
|
|
6
|
+
// them and settles from a touch closer as they clear.
|
|
7
|
+
//
|
|
8
|
+
// It moves the outgoing scene's layers, not the scene: the engine writes every
|
|
9
|
+
// layer's own pose earlier in the same frame, and this adds the flight in front
|
|
10
|
+
// of it. Nothing is left behind, because the engine writes the pose afresh on
|
|
11
|
+
// every frame.
|
|
12
|
+
import { clamp } from "../../core/ease.js";
|
|
13
|
+
import { num } from "../types.js";
|
|
14
|
+
/** What the hand-over changes on the outgoing scene, to put back afterwards. */
|
|
15
|
+
const saved = new WeakMap();
|
|
16
|
+
export const flyPast = {
|
|
17
|
+
slug: 'transition/fly-past',
|
|
18
|
+
summary: 'The layers of a scene fly out past the camera, front first, revealing the next beneath.',
|
|
19
|
+
duration: 1.1,
|
|
20
|
+
calm: { spread: 0.15, tumble: 15, defocus: 2 },
|
|
21
|
+
params: {
|
|
22
|
+
duration: { type: 'number', default: 1.1, min: 0.6, max: 1.8, step: 0.05, unit: 's', label: 'Length of the hand-over' },
|
|
23
|
+
spread: { type: 'number', default: 0.35, min: 0, max: 0.6, step: 0.01, unit: 'ratio', label: 'Share of the time between the first layer leaving and the last' },
|
|
24
|
+
tumble: { type: 'number', default: 50, min: 0, max: 80, step: 1, unit: 'deg', label: 'How far each layer turns away as it passes' },
|
|
25
|
+
defocus: { type: 'number', default: 4, min: 0, max: 10, step: 0.5, unit: 'px', label: 'Blur as a layer reaches the lens' },
|
|
26
|
+
settle: { type: 'number', default: 0.05, min: 0, max: 0.12, step: 0.005, unit: 'ratio', label: 'How much closer the next scene starts' },
|
|
27
|
+
},
|
|
28
|
+
apply(from, to, k, p, ctx) {
|
|
29
|
+
const [W, H] = ctx.size, P = Math.max(W, H) * 1.6;
|
|
30
|
+
const frame = from.getBoundingClientRect();
|
|
31
|
+
const unit = frame.width > 0 ? frame.width / W : 1;
|
|
32
|
+
const layers = [...from.querySelectorAll(':scope > .m-cam > .m-layer')].filter((l) => l.style.visibility !== 'hidden');
|
|
33
|
+
const n = layers.length, spread = num(p.spread), each = 1 - spread;
|
|
34
|
+
layers.forEach((layer, idx) => {
|
|
35
|
+
// Front first: the last layer drawn is nearest the camera.
|
|
36
|
+
const order = n - 1 - idx;
|
|
37
|
+
const t0 = n > 1 ? (order / (n - 1)) * spread : 0;
|
|
38
|
+
const f = clamp((k - t0) / each), e = f ** 2.3;
|
|
39
|
+
if (f <= 0)
|
|
40
|
+
return;
|
|
41
|
+
// Away from the centre of the frame, through the layer's own centre.
|
|
42
|
+
const r = layer.getBoundingClientRect();
|
|
43
|
+
let ex = ((r.left + r.width / 2 - frame.left) / unit - W / 2) / (W / 2);
|
|
44
|
+
let ey = ((r.top + r.height / 2 - frame.top) / unit - H / 2) / (H / 2);
|
|
45
|
+
const len = Math.hypot(ex, ey);
|
|
46
|
+
// A layer dead centre leaves upwards and slightly across, so it still clears the frame.
|
|
47
|
+
if (len < 0.15) {
|
|
48
|
+
ex = 0.12;
|
|
49
|
+
ey = -1;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
ex /= len;
|
|
53
|
+
ey /= len;
|
|
54
|
+
}
|
|
55
|
+
const travel = Math.max(W, H) * 0.9 * e, z = P * 0.82 * e, tumble = num(p.tumble);
|
|
56
|
+
const fly = `perspective(${P}px) translate3d(${(ex * travel).toFixed(2)}px, ${(ey * travel).toFixed(2)}px, ${z.toFixed(2)}px) `
|
|
57
|
+
+ `rotateX(${(-ey * tumble * e).toFixed(3)}deg) rotateY(${(ex * tumble * e).toFixed(3)}deg) rotate(${((idx % 2 ? 12 : -12) * e).toFixed(3)}deg)`;
|
|
58
|
+
layer.style.transform = `${fly} ${layer.style.transform}`;
|
|
59
|
+
layer.style.opacity = String((Number(layer.style.opacity || 1)) * (1 - ctx.ease('smooth')(clamp((f - 0.7) / 0.3))));
|
|
60
|
+
const blur = num(p.defocus) * e * e;
|
|
61
|
+
if (blur > 0.05)
|
|
62
|
+
layer.style.filter = `${layer.style.filter} blur(${blur.toFixed(2)}px)`.trim();
|
|
63
|
+
});
|
|
64
|
+
// Beneath: in quickly, settling from a touch closer as the layers clear.
|
|
65
|
+
const s = ctx.ease('expo.out')(clamp(k / 0.85));
|
|
66
|
+
to.style.transformOrigin = '50% 50%';
|
|
67
|
+
to.style.transform = `scale(${(1 + num(p.settle) * (1 - s)).toFixed(4)})`;
|
|
68
|
+
// The outgoing scene is lifted over the next one and its own ground dissolves, so its layers fly
|
|
69
|
+
// over the next scene while it shows through between them. The next scene is whole beneath from
|
|
70
|
+
// the first frame: the gaps go straight from one ground to the other, never through the stage's.
|
|
71
|
+
if (!saved.has(from))
|
|
72
|
+
saved.set(from, { zIndex: from.style.zIndex, background: from.style.background, ground: getComputedStyle(from).backgroundColor });
|
|
73
|
+
from.style.zIndex = String((Number(to.style.zIndex) || 0) + 1);
|
|
74
|
+
const left = 1 - ctx.ease('smooth')(clamp(k / 0.45));
|
|
75
|
+
from.style.background = left > 0.001 ? `color-mix(in srgb, ${saved.get(from).ground} ${(left * 100).toFixed(2)}%, transparent)` : 'transparent';
|
|
76
|
+
},
|
|
77
|
+
clear(el) {
|
|
78
|
+
el.style.transform = '';
|
|
79
|
+
el.style.transformOrigin = '';
|
|
80
|
+
const was = saved.get(el);
|
|
81
|
+
if (was) {
|
|
82
|
+
el.style.zIndex = was.zIndex;
|
|
83
|
+
el.style.background = was.background;
|
|
84
|
+
saved.delete(el);
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// transition/iris. See library/primitives/transition/iris.md.
|
|
2
|
+
import { num, str } from "../types.js";
|
|
3
|
+
export const iris = {
|
|
4
|
+
slug: 'transition/iris',
|
|
5
|
+
summary: 'The next scene opens from a point in a growing circle.',
|
|
6
|
+
duration: 0.8,
|
|
7
|
+
calm: { push_in: 0.02 },
|
|
8
|
+
params: {
|
|
9
|
+
duration: { type: 'number', default: 0.8, min: 0.4, max: 1.4, step: 0.05, unit: 's', label: 'Length of the hand-over' },
|
|
10
|
+
x: { type: 'number', default: 50, min: 0, max: 100, step: 1, unit: '% of width', label: 'Centre, across', pad: { name: 'centre', axis: 'x' } },
|
|
11
|
+
y: { type: 'number', default: 50, min: 0, max: 100, step: 1, unit: '% of height', label: 'Centre, down', pad: { name: 'centre', axis: 'y' } },
|
|
12
|
+
shape: { type: 'choice', default: 'circle', options: ['circle', 'rounded'], label: 'Opening shape' },
|
|
13
|
+
push_in: { type: 'number', default: 0.06, min: 0, max: 0.2, step: 0.01, unit: 'ratio', label: 'How much the outgoing scene pushes in' },
|
|
14
|
+
},
|
|
15
|
+
apply(from, to, k, p, ctx) {
|
|
16
|
+
const ease = ctx.ease('expressive.inOut');
|
|
17
|
+
const [W, H] = ctx.size, cx = (num(p.x) / 100) * W, cy = (num(p.y) / 100) * H;
|
|
18
|
+
const e = ease(k);
|
|
19
|
+
// Large enough to reach the farthest corner from the centre.
|
|
20
|
+
const reach = Math.max(Math.hypot(cx, cy), Math.hypot(W - cx, cy), Math.hypot(cx, H - cy), Math.hypot(W - cx, H - cy));
|
|
21
|
+
const r = e * reach * 1.02;
|
|
22
|
+
if (str(p.shape) === 'rounded') {
|
|
23
|
+
const hw = r * 0.9, hh = r * 0.9;
|
|
24
|
+
to.style.clipPath = `inset(${(cy - hh).toFixed(1)}px ${(W - cx - hw).toFixed(1)}px ${(H - cy - hh).toFixed(1)}px ${(cx - hw).toFixed(1)}px round ${(r * 0.25).toFixed(1)}px)`;
|
|
25
|
+
}
|
|
26
|
+
else
|
|
27
|
+
to.style.clipPath = `circle(${r.toFixed(2)}px at ${cx.toFixed(1)}px ${cy.toFixed(1)}px)`;
|
|
28
|
+
to.style.transform = `scale(${(1.08 - 0.08 * e).toFixed(4)})`;
|
|
29
|
+
to.style.transformOrigin = `${cx}px ${cy}px`;
|
|
30
|
+
from.style.transform = `scale(${(1 + num(p.push_in) * e).toFixed(4)})`;
|
|
31
|
+
from.style.transformOrigin = `${cx}px ${cy}px`;
|
|
32
|
+
},
|
|
33
|
+
clear(el) {
|
|
34
|
+
el.style.clipPath = '';
|
|
35
|
+
el.style.transform = '';
|
|
36
|
+
el.style.transformOrigin = '';
|
|
37
|
+
},
|
|
38
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function overlay(scene: HTMLElement, key: string, count?: number): HTMLElement[];
|
|
2
|
+
export declare function clearOverlays(scene: HTMLElement, key: string): void;
|
|
3
|
+
/** A surface name or a CSS colour, as a background. */
|
|
4
|
+
export declare const fillOf: (v: string) => string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Panels a transition draws over both scenes, such as a colour that covers the cut.
|
|
2
|
+
// They live in the stage, are created on first use and removed by `clearOverlays`.
|
|
3
|
+
export function overlay(scene, key, count = 1) {
|
|
4
|
+
const stage = scene.parentElement;
|
|
5
|
+
if (!stage)
|
|
6
|
+
return [];
|
|
7
|
+
const out = [];
|
|
8
|
+
for (let i = 0; i < count; i++) {
|
|
9
|
+
let el = stage.querySelector(`:scope > [data-m-overlay="${key}-${i}"]`);
|
|
10
|
+
if (!el) {
|
|
11
|
+
el = scene.ownerDocument.createElement('div');
|
|
12
|
+
el.dataset.mOverlay = `${key}-${i}`;
|
|
13
|
+
el.style.cssText = `position:absolute;inset:0;z-index:${1000 + i};pointer-events:none;will-change:transform,clip-path`;
|
|
14
|
+
stage.appendChild(el);
|
|
15
|
+
}
|
|
16
|
+
out.push(el);
|
|
17
|
+
}
|
|
18
|
+
return out;
|
|
19
|
+
}
|
|
20
|
+
export function clearOverlays(scene, key) {
|
|
21
|
+
scene.parentElement?.querySelectorAll(`:scope > [data-m-overlay^="${key}-"]`).forEach((el) => el.remove());
|
|
22
|
+
}
|
|
23
|
+
/** A surface name or a CSS colour, as a background. */
|
|
24
|
+
export const fillOf = (v) => ['base', 'surface', 'sunken', 'accent', 'inverse'].includes(v) ? `var(--m-bg-${v})` : v;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// transition/push. See library/primitives/transition/push.md.
|
|
2
|
+
import { directionalBlur, streak } from "../blur.js";
|
|
3
|
+
import { num, str } from "../types.js";
|
|
4
|
+
const DIRS = { left: [-1, 0], right: [1, 0], up: [0, -1], down: [0, 1] };
|
|
5
|
+
export const push = {
|
|
6
|
+
slug: 'transition/push',
|
|
7
|
+
summary: 'The next scene pushes the current one out of frame, with parallax and motion blur.',
|
|
8
|
+
duration: 0.7,
|
|
9
|
+
calm: { parallax: 0.15, blur: 0.25 },
|
|
10
|
+
params: {
|
|
11
|
+
duration: { type: 'number', default: 0.7, min: 0.3, max: 1.2, step: 0.05, unit: 's', label: 'Length of the hand-over' },
|
|
12
|
+
direction: { type: 'choice', default: 'left', options: ['left', 'right', 'up', 'down'], label: 'Which way the frame travels' },
|
|
13
|
+
parallax: { type: 'number', default: 0.35, min: 0, max: 1, step: 0.05, unit: 'ratio', label: 'How much less the outgoing scene travels' },
|
|
14
|
+
blur: { type: 'number', default: 0.5, min: 0, max: 1, step: 0.05, unit: 'ratio', label: 'Shutter: share of a frame the motion smears over (0.5 = film)' },
|
|
15
|
+
},
|
|
16
|
+
apply(from, to, k, p, ctx) {
|
|
17
|
+
const ease = ctx.ease('quint.inOut');
|
|
18
|
+
const [W, H] = ctx.size, [dx, dy] = DIRS[str(p.direction)] ?? DIRS.left;
|
|
19
|
+
const e = ease(k), span = dx ? W : H;
|
|
20
|
+
// Speed in px per frame from the curve's slope; blur follows it along the motion only.
|
|
21
|
+
const fps = ctx.fps || 30, dt = 1 / 120;
|
|
22
|
+
const speed = ((ease(Math.min(1, k + dt)) - ease(Math.max(0, k - dt))) / (2 * dt)) * span / (num(p.duration) * fps);
|
|
23
|
+
// The smear is along the push only: a sideways push never softens verticals' tops.
|
|
24
|
+
const outTravel = 1 - num(p.parallax), shutter = num(p.blur);
|
|
25
|
+
const sIn = streak(speed, shutter), sOut = streak(speed * outTravel, shutter);
|
|
26
|
+
to.style.transform = `translate(${(-dx * (1 - e) * W).toFixed(2)}px, ${(-dy * (1 - e) * H).toFixed(2)}px)`;
|
|
27
|
+
from.style.transform = `translate(${(dx * e * W * outTravel).toFixed(2)}px, ${(dy * e * H * outTravel).toFixed(2)}px)`;
|
|
28
|
+
from.style.filter = [directionalBlur(from, dx ? sOut : 0, dy ? sOut : 0), `brightness(${(1 - 0.35 * e).toFixed(3)})`].filter(Boolean).join(' ');
|
|
29
|
+
to.style.filter = directionalBlur(to, dx ? sIn : 0, dy ? sIn : 0);
|
|
30
|
+
},
|
|
31
|
+
clear(el) {
|
|
32
|
+
el.style.transform = '';
|
|
33
|
+
el.style.filter = '';
|
|
34
|
+
},
|
|
35
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// transition/signal-wipe. See library/primitives/transition/signal-wipe.md.
|
|
2
|
+
//
|
|
3
|
+
// A line of accent light crosses the frame and leaves the next scene behind it,
|
|
4
|
+
// with a soft wash of the same light trailing on the revealed side. The content
|
|
5
|
+
// on both sides stays still; only the edge moves, so it reads as a cut drawn by
|
|
6
|
+
// light. The line exists only while it crosses.
|
|
7
|
+
import { clamp } from "../../core/ease.js";
|
|
8
|
+
import { num, str } from "../types.js";
|
|
9
|
+
const lines = new WeakMap();
|
|
10
|
+
export const signalWipe = {
|
|
11
|
+
slug: 'transition/signal-wipe',
|
|
12
|
+
summary: 'A glowing accent line sweeps across and leaves the next scene behind it.',
|
|
13
|
+
duration: 0.55,
|
|
14
|
+
calm: { glow: 0.5, push: 0.01 },
|
|
15
|
+
params: {
|
|
16
|
+
duration: { type: 'number', default: 0.55, min: 0.35, max: 1.2, step: 0.05, unit: 's', label: 'Length of the hand-over' },
|
|
17
|
+
direction: { type: 'choice', default: 'down', options: ['down', 'up', 'right', 'left'], label: 'Which way the line travels' },
|
|
18
|
+
glow: { type: 'number', default: 1, min: 0, max: 2, step: 0.05, unit: 'ratio', label: 'Strength of the glow and its trailing wash' },
|
|
19
|
+
trail: { type: 'number', default: 0.16, min: 0, max: 0.4, step: 0.01, unit: 'of the frame', label: 'Length of the wash behind the line' },
|
|
20
|
+
push: { type: 'number', default: 0.04, min: 0, max: 0.1, step: 0.005, unit: 'ratio', label: 'How much the outgoing scene grows as it is covered' },
|
|
21
|
+
},
|
|
22
|
+
apply(from, to, k, p, ctx) {
|
|
23
|
+
const [W, H] = ctx.size, dir = (str(p.direction) || 'down');
|
|
24
|
+
const e = ctx.ease('quint.inOut')(clamp(k));
|
|
25
|
+
const vertical = dir === 'down' || dir === 'up';
|
|
26
|
+
const span = vertical ? H : W;
|
|
27
|
+
// The edge starts and ends just outside the frame, so the glow is never cut at rest.
|
|
28
|
+
const pad = 30, pos = -pad + e * (span + 2 * pad);
|
|
29
|
+
const covered = clamp(pos, 0, span);
|
|
30
|
+
const inset = { down: `0 0 ${span - covered}px 0`, up: `${span - covered}px 0 0 0`, right: `0 ${span - covered}px 0 0`, left: `0 0 0 ${span - covered}px` }[dir];
|
|
31
|
+
to.style.clipPath = covered >= span ? '' : `inset(${inset})`;
|
|
32
|
+
from.style.transformOrigin = '50% 50%';
|
|
33
|
+
from.style.transform = `scale(${(1 + num(p.push) * e).toFixed(4)})`;
|
|
34
|
+
// The line and its wash sit over both scenes, in the stage.
|
|
35
|
+
const stage = to.parentElement;
|
|
36
|
+
if (!stage)
|
|
37
|
+
return;
|
|
38
|
+
let line = lines.get(to);
|
|
39
|
+
if (!line) {
|
|
40
|
+
line = to.ownerDocument.createElement('div');
|
|
41
|
+
line.className = 'm-signal-line';
|
|
42
|
+
const wash = to.ownerDocument.createElement('div');
|
|
43
|
+
line.appendChild(wash);
|
|
44
|
+
stage.appendChild(line);
|
|
45
|
+
lines.set(to, line);
|
|
46
|
+
}
|
|
47
|
+
const g = num(p.glow), trail = num(p.trail) * span;
|
|
48
|
+
const along = (dir === 'down' || dir === 'right') ? pos : span - pos;
|
|
49
|
+
// The wash lies on the side already revealed: behind the line's travel.
|
|
50
|
+
const towards = { down: 'to top', up: 'to bottom', right: 'to left', left: 'to right' }[dir];
|
|
51
|
+
const wash = line.firstElementChild;
|
|
52
|
+
line.style.cssText = `position:absolute;z-index:999;pointer-events:none;background:color-mix(in srgb, var(--m-accent) 70%, white);`
|
|
53
|
+
+ (vertical ? `left:0;right:0;height:2px;top:${(along - 1).toFixed(2)}px;` : `top:0;bottom:0;width:2px;left:${(along - 1).toFixed(2)}px;`)
|
|
54
|
+
+ `box-shadow:0 0 ${22 * g}px ${5 * g}px color-mix(in srgb, var(--m-accent) ${Math.round(55 * Math.min(1, g))}%, transparent),0 0 4px 1px color-mix(in srgb, var(--m-accent) 40%, white);`
|
|
55
|
+
+ `opacity:${k <= 0 || k >= 1 ? 0 : 1}`;
|
|
56
|
+
wash.style.cssText = `position:absolute;${vertical ? `left:0;right:0;height:${trail}px;` : `top:0;bottom:0;width:${trail}px;`}`
|
|
57
|
+
+ ({ down: 'bottom:2px;', up: 'top:2px;', right: 'right:2px;', left: 'left:2px;' }[dir])
|
|
58
|
+
+ `background:linear-gradient(${towards}, color-mix(in srgb, var(--m-accent) ${Math.round(16 * g)}%, transparent), transparent)`;
|
|
59
|
+
},
|
|
60
|
+
clear(el) {
|
|
61
|
+
el.style.clipPath = '';
|
|
62
|
+
el.style.transform = '';
|
|
63
|
+
el.style.transformOrigin = '';
|
|
64
|
+
lines.get(el)?.remove();
|
|
65
|
+
lines.delete(el);
|
|
66
|
+
},
|
|
67
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// transition/slant-wipe. See library/primitives/transition/slant-wipe.md.
|
|
2
|
+
import { num, str } from "../types.js";
|
|
3
|
+
export const slantWipe = {
|
|
4
|
+
slug: 'transition/slant-wipe',
|
|
5
|
+
summary: 'A slanted edge cuts across the frame, uncovering the next scene; the old one drifts back.',
|
|
6
|
+
duration: 0.6,
|
|
7
|
+
calm: { slant: 10, drift: 3 },
|
|
8
|
+
params: {
|
|
9
|
+
duration: { type: 'number', default: 0.6, min: 0.4, max: 0.9, step: 0.05, unit: 's', label: 'Length of the hand-over' },
|
|
10
|
+
slant: { type: 'number', default: 20, min: 0, max: 40, step: 1, unit: '% of width', label: 'Slant of the edge' },
|
|
11
|
+
direction: { type: 'choice', default: 'left', options: ['left', 'right'], label: 'Which way the edge travels' },
|
|
12
|
+
drift: { type: 'number', default: 8, min: 0, max: 15, step: 1, unit: '% of width', label: 'How far the old scene drifts' },
|
|
13
|
+
},
|
|
14
|
+
apply(from, to, k, p, ctx) {
|
|
15
|
+
const ease = ctx.ease([0.77, 0, 0.175, 1]);
|
|
16
|
+
const e = ease(k), s = num(p.slant), left = str(p.direction) !== 'right';
|
|
17
|
+
// The edge starts past one side and ends past the other, so no corner lingers.
|
|
18
|
+
const travel = 100 + s;
|
|
19
|
+
const top = left ? 100 - e * travel : e * travel - s, bottom = top + s;
|
|
20
|
+
to.style.clipPath = left
|
|
21
|
+
? `polygon(${top}% 0, 100% 0, 100% 100%, ${bottom}% 100%)`
|
|
22
|
+
: `polygon(0 0, ${top + s}% 0, ${bottom - s}% 100%, 0 100%)`;
|
|
23
|
+
from.style.transform = `translateX(${((left ? -1 : 1) * num(p.drift) * e).toFixed(3)}%)`;
|
|
24
|
+
void ctx;
|
|
25
|
+
},
|
|
26
|
+
clear(el) {
|
|
27
|
+
el.style.clipPath = '';
|
|
28
|
+
el.style.transform = '';
|
|
29
|
+
},
|
|
30
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// transition/stack-over. See library/primitives/transition/stack-over.md.
|
|
2
|
+
import { num, str } from "../types.js";
|
|
3
|
+
const DIRS = { up: [0, 1], down: [0, -1], left: [1, 0], right: [-1, 0] };
|
|
4
|
+
export const stackOver = {
|
|
5
|
+
slug: 'transition/stack-over',
|
|
6
|
+
summary: 'The next scene slides over the current one, which recedes and dims beneath it.',
|
|
7
|
+
duration: 0.7,
|
|
8
|
+
calm: { recede: 0.97, dim: 0.4 },
|
|
9
|
+
params: {
|
|
10
|
+
duration: { type: 'number', default: 0.7, min: 0.4, max: 1.2, step: 0.05, unit: 's', label: 'Length of the hand-over' },
|
|
11
|
+
direction: { type: 'choice', default: 'up', options: ['up', 'down', 'left', 'right'], label: 'Which way the new scene travels' },
|
|
12
|
+
recede: { type: 'number', default: 0.94, min: 0.88, max: 0.98, step: 0.01, unit: 'x', label: 'Scale the old scene shrinks to' },
|
|
13
|
+
dim: { type: 'number', default: 0.7, min: 0.2, max: 0.8, step: 0.05, unit: 'ratio', label: 'Brightness the old scene dims to' },
|
|
14
|
+
radius: { type: 'number', default: 2, min: 0, max: 6, step: 0.5, unit: '% of width', label: 'Corner radius while moving' },
|
|
15
|
+
},
|
|
16
|
+
apply(from, to, k, p, ctx) {
|
|
17
|
+
const ease = ctx.ease([0.4, 0, 0.1, 1]);
|
|
18
|
+
const e = ease(k), [W, H] = ctx.size, [dx, dy] = DIRS[str(p.direction)] ?? DIRS.up;
|
|
19
|
+
// Corners stay round while the card travels and square off only as it lands.
|
|
20
|
+
const R = (num(p.radius) / 100) * W, land = Math.min(1, Math.max(0, (k - 0.75) / 0.25));
|
|
21
|
+
const r = R * (1 - land * land * (3 - 2 * land));
|
|
22
|
+
to.style.transform = `translate(${(dx * (1 - e) * W).toFixed(2)}px, ${(dy * (1 - e) * H).toFixed(2)}px)`;
|
|
23
|
+
// Radius by border-radius, not clip-path, so the card's shadow is not clipped away.
|
|
24
|
+
to.style.borderRadius = r > 0.5 ? `${r.toFixed(1)}px` : '';
|
|
25
|
+
const shade = 0.3 * Math.min(1, (1 - e) * 4);
|
|
26
|
+
to.style.boxShadow = shade > 0.002 ? `${(-dx * 24).toFixed(0)}px ${(-dy * 24).toFixed(0)}px 90px rgba(0,0,0,${shade.toFixed(3)})` : '';
|
|
27
|
+
from.style.transform = `scale(${(1 - (1 - num(p.recede)) * e).toFixed(4)})`;
|
|
28
|
+
from.style.filter = `brightness(${(1 - (1 - num(p.dim)) * e).toFixed(3)}) blur(${(e * 2).toFixed(2)}px)`;
|
|
29
|
+
from.style.clipPath = `inset(0 round ${((num(p.radius) / 100) * W * e).toFixed(1)}px)`;
|
|
30
|
+
},
|
|
31
|
+
clear(el) {
|
|
32
|
+
el.style.transform = '';
|
|
33
|
+
el.style.clipPath = '';
|
|
34
|
+
el.style.boxShadow = '';
|
|
35
|
+
el.style.filter = '';
|
|
36
|
+
el.style.borderRadius = '';
|
|
37
|
+
},
|
|
38
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// transition/step-wipe. See library/primitives/transition/step-wipe.md.
|
|
2
|
+
import { clamp } from "../../core/ease.js";
|
|
3
|
+
import { num } from "../types.js";
|
|
4
|
+
export const stepWipe = {
|
|
5
|
+
slug: 'transition/step-wipe',
|
|
6
|
+
summary: 'Stepped bars sweep across the frame.',
|
|
7
|
+
duration: 0.5,
|
|
8
|
+
params: {
|
|
9
|
+
duration: { type: 'number', default: 0.5, min: 0.4, max: 0.7, step: 0.05, unit: 's', label: 'Length of the hand-over' },
|
|
10
|
+
steps: { type: 'number', default: 6, min: 4, max: 10, step: 1, unit: 'bars', label: 'Number of bars' },
|
|
11
|
+
},
|
|
12
|
+
apply(_from, to, k, p, ctx) {
|
|
13
|
+
const ease = ctx.ease(ctx.tokens.ease_move);
|
|
14
|
+
const steps = Math.max(1, Math.round(num(p.steps)));
|
|
15
|
+
const [w, h] = ctx.size;
|
|
16
|
+
const lag = 0.5 / steps; // each bar starts a little after the one above it
|
|
17
|
+
const bars = [];
|
|
18
|
+
for (let i = 0; i < steps; i++) {
|
|
19
|
+
const x = ease(clamp((k - i * lag) / (1 - (steps - 1) * lag))) * w;
|
|
20
|
+
// +1 px of overlap closes the hairline between neighbouring bars.
|
|
21
|
+
const y0 = (i * h) / steps, y1 = ((i + 1) * h) / steps + (i < steps - 1 ? 1 : 0);
|
|
22
|
+
bars.push(`M0 ${y0}H${x}V${y1}H0Z`);
|
|
23
|
+
}
|
|
24
|
+
to.style.clipPath = `path('${bars.join('')}')`;
|
|
25
|
+
},
|
|
26
|
+
clear(el) {
|
|
27
|
+
el.style.clipPath = '';
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type TransitionPrimitive } from '../types.ts';
|
|
2
|
+
/** A band of the identity's palette (`--m-band-1` … `--m-band-6`) or a surface of the stage. */
|
|
3
|
+
export declare const stripColour: (v: string) => string;
|
|
4
|
+
/** How far each row trails the one before, as a share of the hand-over: the stagger, capped so the last row still travels for half of it. */
|
|
5
|
+
export declare const rowLag: (rows: number, stagger: number) => number;
|
|
6
|
+
/**
|
|
7
|
+
* How far row i has run at progress k, 0 to 1. Rows start a lag apart in `order`
|
|
8
|
+
* and all finish at k = 1, so the hand-over takes exactly its duration.
|
|
9
|
+
*/
|
|
10
|
+
export declare function rowAt(k: number, i: number, rows: number, lag: number, order: string, ease: (x: number) => number): number;
|
|
11
|
+
/**
|
|
12
|
+
* The span of a row at run r, in px along the travel from the side it enters: the
|
|
13
|
+
* colour field lies over [front, front + field] and the next scene behind it, over
|
|
14
|
+
* [front + field, length]. The field enters first and leaves last.
|
|
15
|
+
*/
|
|
16
|
+
export declare function rowSpan(r: number, length: number, field: number): {
|
|
17
|
+
front: number;
|
|
18
|
+
back: number;
|
|
19
|
+
};
|
|
20
|
+
export interface RowLayout {
|
|
21
|
+
/** The colour field, [from, to] in px, measured from the edge the row leaves by. */
|
|
22
|
+
field: [number, number];
|
|
23
|
+
/** Where the next scene shows, [from, to] in px, or null while it is hidden. */
|
|
24
|
+
shown: [number, number] | null;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Row i at progress k, in px across a row `length` long, as if it entered from the far
|
|
28
|
+
* edge (positions grow towards it). `lead`: a field `field` px long runs across with the
|
|
29
|
+
* next scene behind it. `cover`: the rows first cover the old scene with colour, every
|
|
30
|
+
* row whole at k = 0.5, then run on and uncover the next scene: a held beat of colour
|
|
31
|
+
* on the cut.
|
|
32
|
+
*/
|
|
33
|
+
export declare function rowLayout(k: number, i: number, rows: number, length: number, o: {
|
|
34
|
+
mode: string;
|
|
35
|
+
field: number;
|
|
36
|
+
lag: number;
|
|
37
|
+
order: string;
|
|
38
|
+
ease: (x: number) => number;
|
|
39
|
+
}): RowLayout;
|
|
40
|
+
export declare const stripWipe: TransitionPrimitive;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// transition/strip-wipe. See library/primitives/transition/strip-wipe.md.
|
|
2
|
+
//
|
|
3
|
+
// The frame is cut into horizontal strips, the rows of a ruled grid. The next
|
|
4
|
+
// scene arrives strip by strip, one row a step after the last, each row led by a
|
|
5
|
+
// field of colour that runs across ahead of it: a staircase of colour that wipes
|
|
6
|
+
// the old scene away. It is the change of scene/strip-cycle, made into a
|
|
7
|
+
// hand-over between scenes. In `cover` mode the rows first close over the old scene,
|
|
8
|
+
// hold the frame in colour for an instant on the cut, then open on the next.
|
|
9
|
+
import { clamp } from "../../core/ease.js";
|
|
10
|
+
import { num, str } from "../types.js";
|
|
11
|
+
import { bandColour } from "./band-sweep.js";
|
|
12
|
+
import { clearOverlays, fillOf, overlay } from "./overlay.js";
|
|
13
|
+
const KEY = 'strips';
|
|
14
|
+
const COLOURS = ['band-1', 'band-2', 'band-3', 'band-4', 'band-5', 'band-6', 'accent', 'inverse', 'surface', 'sunken'];
|
|
15
|
+
/** A band of the identity's palette (`--m-band-1` … `--m-band-6`) or a surface of the stage. */
|
|
16
|
+
export const stripColour = (v) => (/^band-[1-6]$/.test(v) ? bandColour(Number(v.slice(5)) - 1) : fillOf(v));
|
|
17
|
+
/** How far each row trails the one before, as a share of the hand-over: the stagger, capped so the last row still travels for half of it. */
|
|
18
|
+
export const rowLag = (rows, stagger) => Math.min(Math.max(0, stagger), 0.5 / Math.max(1, rows - 1));
|
|
19
|
+
/**
|
|
20
|
+
* How far row i has run at progress k, 0 to 1. Rows start a lag apart in `order`
|
|
21
|
+
* and all finish at k = 1, so the hand-over takes exactly its duration.
|
|
22
|
+
*/
|
|
23
|
+
export function rowAt(k, i, rows, lag, order, ease) {
|
|
24
|
+
const rank = order === 'up' ? rows - 1 - i : order === 'centre' ? Math.abs(i - (rows - 1) / 2) * 2 : i;
|
|
25
|
+
const win = Math.max(0.05, 1 - (rows - 1) * lag);
|
|
26
|
+
return ease(clamp((k - rank * lag) / win));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The span of a row at run r, in px along the travel from the side it enters: the
|
|
30
|
+
* colour field lies over [front, front + field] and the next scene behind it, over
|
|
31
|
+
* [front + field, length]. The field enters first and leaves last.
|
|
32
|
+
*/
|
|
33
|
+
export function rowSpan(r, length, field) {
|
|
34
|
+
const front = length - r * (length + field);
|
|
35
|
+
return { front, back: front + field };
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Row i at progress k, in px across a row `length` long, as if it entered from the far
|
|
39
|
+
* edge (positions grow towards it). `lead`: a field `field` px long runs across with the
|
|
40
|
+
* next scene behind it. `cover`: the rows first cover the old scene with colour, every
|
|
41
|
+
* row whole at k = 0.5, then run on and uncover the next scene: a held beat of colour
|
|
42
|
+
* on the cut.
|
|
43
|
+
*/
|
|
44
|
+
export function rowLayout(k, i, rows, length, o) {
|
|
45
|
+
if (o.mode === 'cover') {
|
|
46
|
+
if (k < 0.5) {
|
|
47
|
+
const p = rowAt(k * 2, i, rows, o.lag, o.order, o.ease);
|
|
48
|
+
return { field: [length - p * length, length], shown: null };
|
|
49
|
+
}
|
|
50
|
+
const p = rowAt(k * 2 - 1, i, rows, o.lag, o.order, o.ease);
|
|
51
|
+
const edge = length - p * length;
|
|
52
|
+
return { field: [0, edge], shown: edge < length ? [edge, length] : null };
|
|
53
|
+
}
|
|
54
|
+
const { front, back } = rowSpan(rowAt(k, i, rows, o.lag, o.order, o.ease), length, o.field);
|
|
55
|
+
return { field: [front, back], shown: back < length ? [Math.max(0, back), length] : null };
|
|
56
|
+
}
|
|
57
|
+
export const stripWipe = {
|
|
58
|
+
slug: 'transition/strip-wipe',
|
|
59
|
+
summary: 'The next scene arrives row by row, each row led by a field of colour.',
|
|
60
|
+
duration: 1,
|
|
61
|
+
params: {
|
|
62
|
+
duration: { type: 'number', default: 1, min: 0.5, max: 2, step: 0.05, unit: 's', label: 'Length of the hand-over' },
|
|
63
|
+
mode: { type: 'choice', default: 'lead', options: ['lead', 'cover'], label: 'lead: a field of colour runs ahead of the next scene; cover: colour covers the frame, then uncovers the next scene' },
|
|
64
|
+
direction: { type: 'choice', default: 'left', options: ['left', 'right'], label: 'Which way the strips run: left enters from the right' },
|
|
65
|
+
alternate: { type: 'boolean', default: false, label: 'Every other row runs the other way, like strands woven across' },
|
|
66
|
+
rows: { type: 'number', default: 8, min: 2, max: 16, step: 1, unit: 'rows', label: 'Strips across the frame: the rows of the grid' },
|
|
67
|
+
order: { type: 'choice', default: 'down', options: ['down', 'up', 'centre'], label: 'Which row goes first' },
|
|
68
|
+
stagger: { type: 'number', default: 0.04, min: 0, max: 0.1, step: 0.005, unit: 'ratio', label: 'How far each row trails the one before, as a share of the hand-over' },
|
|
69
|
+
lead: { type: 'number', default: 0.35, min: 0.05, max: 1, step: 0.01, unit: '× frame width', label: 'Length of the colour field ahead of the next scene' },
|
|
70
|
+
colour: { type: 'choice', default: 'band-1', options: COLOURS, label: 'Colour of the field: a band of the palette (--m-band-1 …) or a surface' },
|
|
71
|
+
},
|
|
72
|
+
apply(from, to, k, p, ctx) {
|
|
73
|
+
const [W, H] = ctx.size;
|
|
74
|
+
const n = Math.max(2, Math.round(num(p.rows, 8)));
|
|
75
|
+
const o = {
|
|
76
|
+
mode: str(p.mode, 'lead'),
|
|
77
|
+
field: Math.ceil(num(p.lead, 0.35) * W),
|
|
78
|
+
lag: rowLag(n, num(p.stagger, 0.04)),
|
|
79
|
+
order: str(p.order, 'down'),
|
|
80
|
+
ease: ctx.ease(str(p.mode, 'lead') === 'cover' ? 'cubic.inOut' : 'quart.inOut'),
|
|
81
|
+
};
|
|
82
|
+
const leftward = str(p.direction, 'left') !== 'right', alternate = p.alternate === true;
|
|
83
|
+
const colour = stripColour(str(p.colour, 'band-1'));
|
|
84
|
+
const fields = overlay(from, KEY, n);
|
|
85
|
+
const shown = [];
|
|
86
|
+
for (let i = 0; i < n; i++) {
|
|
87
|
+
// Rows on whole pixels, overlapping by one, so no seam shows between them.
|
|
88
|
+
const top = Math.floor((i / n) * H), bottom = Math.min(H, Math.ceil(((i + 1) / n) * H) + 1);
|
|
89
|
+
const row = rowLayout(k, i, n, W, o);
|
|
90
|
+
// Leftward, positions run from the left edge as laid out; rightward, mirrored.
|
|
91
|
+
const flip = alternate && i % 2 === 1 ? leftward : !leftward;
|
|
92
|
+
const span = ([u, v]) => (flip ? [W - v, W - u] : [u, v]);
|
|
93
|
+
const [f0, f1] = span(row.field);
|
|
94
|
+
const el = fields[i];
|
|
95
|
+
const a = Math.max(0, f0), b = Math.min(W, f1);
|
|
96
|
+
el.style.inset = 'auto';
|
|
97
|
+
el.style.left = `${a.toFixed(2)}px`;
|
|
98
|
+
el.style.top = `${top}px`;
|
|
99
|
+
el.style.width = `${Math.max(0, b - a).toFixed(2)}px`;
|
|
100
|
+
el.style.height = `${bottom - top}px`;
|
|
101
|
+
el.style.background = colour;
|
|
102
|
+
el.style.visibility = b > a ? 'visible' : 'hidden';
|
|
103
|
+
if (row.shown) {
|
|
104
|
+
const [s0, s1] = span(row.shown);
|
|
105
|
+
if (s1 > s0)
|
|
106
|
+
shown.push(`M${Math.max(0, s0).toFixed(2)} ${top}H${Math.min(W, s1).toFixed(2)}V${bottom}H${Math.max(0, s0).toFixed(2)}Z`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
from.style.opacity = '1';
|
|
110
|
+
to.style.opacity = shown.length ? '1' : '0';
|
|
111
|
+
to.style.zIndex = '2';
|
|
112
|
+
from.style.zIndex = '1';
|
|
113
|
+
to.style.clipPath = k >= 1 ? '' : shown.length ? `path('${shown.join(' ')}')` : '';
|
|
114
|
+
},
|
|
115
|
+
clear(el) {
|
|
116
|
+
clearOverlays(el, KEY);
|
|
117
|
+
el.style.clipPath = '';
|
|
118
|
+
el.style.zIndex = '';
|
|
119
|
+
el.style.opacity = '';
|
|
120
|
+
},
|
|
121
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// transition/whip-pan. See library/primitives/transition/whip-pan.md.
|
|
2
|
+
//
|
|
3
|
+
// A camera whip: the frame gathers for an instant, then tears away with a smear
|
|
4
|
+
// along the pan only, and brakes hard on the next scene. Peak speed is at the
|
|
5
|
+
// seam between the two, so the seam is never seen.
|
|
6
|
+
import { clamp } from "../../core/ease.js";
|
|
7
|
+
import { directionalBlur, streak } from "../blur.js";
|
|
8
|
+
import { num, str } from "../types.js";
|
|
9
|
+
const DIRS = { left: [-1, 0], right: [1, 0], up: [0, -1], down: [0, 1] };
|
|
10
|
+
export const whipPan = {
|
|
11
|
+
slug: 'transition/whip-pan',
|
|
12
|
+
summary: 'The camera whips to the next scene with a streak along the pan only, then brakes.',
|
|
13
|
+
duration: 0.5,
|
|
14
|
+
calm: { anticipation: 0, shutter: 0.3 },
|
|
15
|
+
params: {
|
|
16
|
+
duration: { type: 'number', default: 0.5, min: 0.3, max: 0.9, step: 0.05, unit: 's', label: 'Length of the hand-over' },
|
|
17
|
+
direction: { type: 'choice', default: 'left', options: ['left', 'right', 'up', 'down'], label: 'Which way the frame travels' },
|
|
18
|
+
anticipation: { type: 'number', default: 0.03, min: 0, max: 0.08, step: 0.005, unit: 'of the frame', label: 'How far it pulls back before it goes' },
|
|
19
|
+
shutter: { type: 'number', default: 0.5, min: 0, max: 1, step: 0.05, unit: 'ratio', label: 'Motion blur: share of a frame the whip smears over' },
|
|
20
|
+
},
|
|
21
|
+
apply(from, to, k, p, ctx) {
|
|
22
|
+
const [W, H] = ctx.size, [dx, dy] = DIRS[str(p.direction)] ?? DIRS.left;
|
|
23
|
+
const span = dx ? W : H;
|
|
24
|
+
const back = num(p.anticipation) * span;
|
|
25
|
+
// One camera: the two scenes lie side by side and the frame pans from one to
|
|
26
|
+
// the other, so there is never a gap between them. It gathers first (a sine
|
|
27
|
+
// bump against the pan), then whips on a sharp in-out: nearly all the travel
|
|
28
|
+
// happens in the middle third, at a speed the eye cannot follow.
|
|
29
|
+
const whip = ctx.ease('expo.inOut');
|
|
30
|
+
const camAt = (q) => (q < 0.3 ? -back * Math.sin(Math.PI * clamp(q / 0.3)) : 0) + span * whip(clamp((q - 0.12) / 0.88));
|
|
31
|
+
// Speed in px per frame, from the positions half a frame either side.
|
|
32
|
+
const h = 0.5 / (ctx.fps || 30) / num(p.duration);
|
|
33
|
+
const v = camAt(clamp(k + h)) - camAt(clamp(k - h));
|
|
34
|
+
const c = camAt(k);
|
|
35
|
+
from.style.transform = `translate(${(dx * c).toFixed(2)}px, ${(dy * c).toFixed(2)}px)`;
|
|
36
|
+
to.style.transform = `translate(${(dx * (c - span)).toFixed(2)}px, ${(dy * (c - span)).toFixed(2)}px)`;
|
|
37
|
+
const sOut = streak(v, num(p.shutter)), sIn = sOut;
|
|
38
|
+
from.style.filter = directionalBlur(from, dx ? sOut : 0, dy ? sOut : 0, 90);
|
|
39
|
+
to.style.filter = directionalBlur(to, dx ? sIn : 0, dy ? sIn : 0, 90);
|
|
40
|
+
},
|
|
41
|
+
clear(el) {
|
|
42
|
+
el.style.transform = '';
|
|
43
|
+
el.style.filter = '';
|
|
44
|
+
},
|
|
45
|
+
};
|