@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.
- package/CREDITS.md +62 -0
- package/LICENSE +21 -0
- package/README.md +142 -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,396 @@
|
|
|
1
|
+
// Pace: the rhythm of a resolved film, measured. Pure, like resolve: it reads the
|
|
2
|
+
// timeline (scenes, hand-overs, enters, exits and the cues primitives report) and
|
|
3
|
+
// says where the film rushes, drags or stumbles.
|
|
4
|
+
//
|
|
5
|
+
// What it checks, and why (docs/CRAFT.md, "Rhythm"):
|
|
6
|
+
// - A hand-over is a moment between sections, never a section of its own: at most a
|
|
7
|
+
// third of the shorter scene it joins, and each scene keeps time alone, free of any
|
|
8
|
+
// hand-over, at least twice as long as its hand-overs.
|
|
9
|
+
// - Like moves take like time: every hand-over one length, every change one length.
|
|
10
|
+
// A film whose swaps take 0.6 s here and 1 s there feels fast, then slow.
|
|
11
|
+
// - Rests between changes are even and long enough to see a picture (1 s or more).
|
|
12
|
+
// - Most of a film is held, not moving: about a third moving reads as calm and alive.
|
|
13
|
+
// - Drift (a slow push, a pan) keeps a held picture alive: it counts against a film
|
|
14
|
+
// that stalls, never towards one that is restless. A pan that crosses the screen
|
|
15
|
+
// in big steps strobes (judder).
|
|
16
|
+
// - Shots cut to the same length, one after another, tick like a metronome:
|
|
17
|
+
// alternate long and short.
|
|
18
|
+
// - With a tempo: a hand-over lands on the first beat of a bar, a plain cut on any
|
|
19
|
+
// beat, other moves on the beat or half-beat, and lengths are whole half-beats; a
|
|
20
|
+
// loop is whole bars.
|
|
21
|
+
import { beatLength, offGrid } from "./tempo.js";
|
|
22
|
+
/** The framing camera's frame, zoom (log) and tilt at a scene-local time, the eases taken as linear. */
|
|
23
|
+
function cameraAt(s, local) {
|
|
24
|
+
const keys = s.camera;
|
|
25
|
+
if (!keys?.length)
|
|
26
|
+
return { scene: s.id, zoom: 1, tilt: [0, 0] };
|
|
27
|
+
let i = keys.findIndex((k) => k.t >= local);
|
|
28
|
+
if (i < 0) {
|
|
29
|
+
const k = keys[keys.length - 1];
|
|
30
|
+
return { scene: s.id, frame: k.frame, zoom: k.zoom * (1 + k.drift * (local - k.t)), tilt: k.tilt };
|
|
31
|
+
}
|
|
32
|
+
if (i === 0)
|
|
33
|
+
return { scene: s.id, frame: keys[0].frame, zoom: keys[0].zoom, tilt: keys[0].tilt };
|
|
34
|
+
const a = keys[i - 1], b = keys[i], p = (local - a.t) / Math.max(1e-9, b.t - a.t);
|
|
35
|
+
return { scene: s.id, frame: p < 0.5 ? a.frame : b.frame, zoom: Math.exp(Math.log(a.zoom) + (Math.log(b.zoom) - Math.log(a.zoom)) * p), tilt: [a.tilt[0] + (b.tilt[0] - a.tilt[0]) * p, a.tilt[1] + (b.tilt[1] - a.tilt[1]) * p] };
|
|
36
|
+
}
|
|
37
|
+
/** The numbers the checks use. CRAFT.md "Rhythm" explains each. */
|
|
38
|
+
export const PACE = {
|
|
39
|
+
/** A hand-over is at most this share of the shorter scene it joins (a quarter reads best). */
|
|
40
|
+
handoverShare: 1 / 3,
|
|
41
|
+
handoverIdeal: 1 / 4,
|
|
42
|
+
/** A scene's time alone is at least this many times its longest hand-over. */
|
|
43
|
+
aloneTimes: 2,
|
|
44
|
+
/** Like moves may differ by at most this ratio, longest to shortest. */
|
|
45
|
+
spread: 1.35,
|
|
46
|
+
/** Rests between changes may differ by at most this ratio. */
|
|
47
|
+
restSpread: 1.6,
|
|
48
|
+
/** Shortest rest that lets a picture be seen, seconds. */
|
|
49
|
+
minRest: 1,
|
|
50
|
+
/** Share of the film in motion: below reads as stalled, above as restless. */
|
|
51
|
+
moving: [0.2, 0.6],
|
|
52
|
+
/** Inside a scene that changes pictures, a hand-over is at most this share of one picture's time (rest + change). */
|
|
53
|
+
shotShare: 1 / 2,
|
|
54
|
+
/** Changes per second may differ by at most this ratio from scene to scene. */
|
|
55
|
+
density: 2,
|
|
56
|
+
/** Fastest a picture may cross the stage, as a share of its shorter side per frame, before it strobes. */
|
|
57
|
+
judder: 1 / 40,
|
|
58
|
+
/** This many shots in a row cut to one length read as a metronome. */
|
|
59
|
+
evenCuts: 5,
|
|
60
|
+
};
|
|
61
|
+
const fmt = (s) => `${s.toFixed(2)} s`;
|
|
62
|
+
/** Merged length of a set of intervals, clipped to [a, b]. */
|
|
63
|
+
function covered(spans, a, b) {
|
|
64
|
+
const xs = spans.map(([s, e]) => [Math.max(a, s), Math.min(b, e)]).filter(([s, e]) => e > s).sort((p, q) => p[0] - q[0]);
|
|
65
|
+
let total = 0, cs = -Infinity, ce = -Infinity;
|
|
66
|
+
for (const [s, e] of xs) {
|
|
67
|
+
if (s > ce) {
|
|
68
|
+
if (ce > cs)
|
|
69
|
+
total += ce - cs;
|
|
70
|
+
cs = s;
|
|
71
|
+
ce = e;
|
|
72
|
+
}
|
|
73
|
+
else
|
|
74
|
+
ce = Math.max(ce, e);
|
|
75
|
+
}
|
|
76
|
+
if (ce > cs)
|
|
77
|
+
total += ce - cs;
|
|
78
|
+
return total;
|
|
79
|
+
}
|
|
80
|
+
export function movesOf(t) {
|
|
81
|
+
const out = [];
|
|
82
|
+
t.scenes.forEach((s, i) => {
|
|
83
|
+
const next = t.scenes[i + 1];
|
|
84
|
+
if (s.out && next && s.out.duration > 0)
|
|
85
|
+
out.push({ kind: 'hand-over', scene: s.id, use: s.out.use, start: next.start, length: s.out.duration });
|
|
86
|
+
// A scene is seen from the middle of the hand-over in to the middle of the one out:
|
|
87
|
+
// a change wholly outside that window is never on screen and does not count.
|
|
88
|
+
const prev = t.scenes[i - 1];
|
|
89
|
+
const from = s.start + (prev?.out ? prev.out.duration / 2 : 0);
|
|
90
|
+
const to = s.start + s.length - (s.out && next ? s.out.duration / 2 : 0);
|
|
91
|
+
const seen = (start, length) => start < to - 1e-6 && start + length > from + 1e-6;
|
|
92
|
+
for (const l of s.layers) {
|
|
93
|
+
const at = s.start + l.start;
|
|
94
|
+
if (l.enter && l.enter.duration > 0)
|
|
95
|
+
out.push({ kind: 'enter', scene: s.id, layer: l.id, use: l.use, start: s.start + l.enter.start, length: l.enter.duration });
|
|
96
|
+
if (l.exit && l.exit.duration > 0)
|
|
97
|
+
out.push({ kind: 'exit', scene: s.id, layer: l.id, use: l.use, start: s.start + l.exit.start, length: l.exit.duration });
|
|
98
|
+
if (l.cues && !l.cues.length) {
|
|
99
|
+
// Ambient drift (a slow push, a pan): alive, but never a move of its own.
|
|
100
|
+
if (l.duration > 0)
|
|
101
|
+
out.push({ kind: 'drift', scene: s.id, layer: l.id, use: l.use, start: at, length: Math.min(l.duration, s.length - l.start) });
|
|
102
|
+
}
|
|
103
|
+
else if (l.cues) {
|
|
104
|
+
for (const c of l.cues)
|
|
105
|
+
if (seen(at + c.at, c.length))
|
|
106
|
+
out.push({ kind: 'change', scene: s.id, layer: l.id, use: l.use, start: at + c.at, length: c.length, lane: `${s.id}/${l.id}/${c.lane ?? 0}`, ...(c.share !== undefined ? { share: c.share } : {}) });
|
|
107
|
+
}
|
|
108
|
+
else if (l.duration > 0)
|
|
109
|
+
out.push({ kind: 'run', scene: s.id, layer: l.id, use: l.use, start: at, length: Math.min(l.duration, s.length - l.start) });
|
|
110
|
+
}
|
|
111
|
+
// The framing camera: each move between keys is motion; a drift after the last key is alive, never a move.
|
|
112
|
+
const keys = s.camera ?? [];
|
|
113
|
+
keys.forEach((b, k) => {
|
|
114
|
+
const a = keys[k - 1];
|
|
115
|
+
if (a && b.t > a.t && (a.zoom !== b.zoom || JSON.stringify([a.frame, a.point, a.offset, a.anchor, a.tilt, a.rotate]) !== JSON.stringify([b.frame, b.point, b.offset, b.anchor, b.tilt, b.rotate])))
|
|
116
|
+
out.push({ kind: 'run', scene: s.id, use: 'scene.camera', start: s.start + a.t, length: b.t - a.t });
|
|
117
|
+
if (k === keys.length - 1 && b.drift && s.length > b.t)
|
|
118
|
+
out.push({ kind: 'drift', scene: s.id, use: 'scene.camera', start: s.start + b.t, length: s.length - b.t });
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
return out.sort((a, b) => a.start - b.start);
|
|
122
|
+
}
|
|
123
|
+
/** Rests between consecutive changes in each lane: [lane, rest, the change after it]. */
|
|
124
|
+
function restsOf(moves) {
|
|
125
|
+
const lanes = new Map();
|
|
126
|
+
for (const m of moves)
|
|
127
|
+
if (m.kind === 'change' && m.lane)
|
|
128
|
+
lanes.set(m.lane, [...(lanes.get(m.lane) ?? []), m]);
|
|
129
|
+
const out = [];
|
|
130
|
+
for (const [lane, ms] of lanes) {
|
|
131
|
+
ms.sort((a, b) => a.start - b.start);
|
|
132
|
+
for (let k = 1; k < ms.length; k++)
|
|
133
|
+
out.push({ lane, rest: ms[k].start - (ms[k - 1].start + ms[k - 1].length), after: ms[k] });
|
|
134
|
+
}
|
|
135
|
+
return out;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* The moves that count towards time in motion. Tiles of a wall that change on their
|
|
139
|
+
* own clocks read as one living surface, each tile resting in turn, so a layer with
|
|
140
|
+
* several lanes counts as its busiest lane only.
|
|
141
|
+
*/
|
|
142
|
+
function motionSpans(moves) {
|
|
143
|
+
const lanesOf = new Map();
|
|
144
|
+
for (const m of moves) {
|
|
145
|
+
if (m.kind !== 'change' || !m.lane)
|
|
146
|
+
continue;
|
|
147
|
+
const key = `${m.scene}/${m.layer}`, lanes = lanesOf.get(key) ?? new Map();
|
|
148
|
+
lanes.set(m.lane, (lanes.get(m.lane) ?? 0) + m.length);
|
|
149
|
+
lanesOf.set(key, lanes);
|
|
150
|
+
}
|
|
151
|
+
const keep = new Set([...lanesOf.values()].map((lanes) => [...lanes].sort((a, b) => b[1] - a[1])[0][0]));
|
|
152
|
+
return moves.filter((m) => m.kind !== 'change' || !m.lane || keep.has(m.lane)).map((m) => [m.start, m.start + m.length]);
|
|
153
|
+
}
|
|
154
|
+
const spreadOf = (xs) => (xs.length < 2 ? 1 : Math.max(...xs) / Math.max(1e-6, Math.min(...xs)));
|
|
155
|
+
/** Lengths grouped by what made them, for a message: "scene/bento-grid 0.60 s, scene/strip-cycle 1.03 s". */
|
|
156
|
+
function byUse(ms) {
|
|
157
|
+
const m = new Map();
|
|
158
|
+
for (const x of ms)
|
|
159
|
+
m.set(x.use, (m.get(x.use) ?? new Set()).add(x.length.toFixed(2)));
|
|
160
|
+
return [...m].map(([use, ls]) => `${use} ${[...ls].sort().join('/')} s`).join(', ');
|
|
161
|
+
}
|
|
162
|
+
export function pace(t) {
|
|
163
|
+
const issues = [];
|
|
164
|
+
const warn = (path, code, message, hint) => issues.push({ level: 'warning', code, path, message, ...(hint ? { hint } : {}) });
|
|
165
|
+
const all = movesOf(t);
|
|
166
|
+
// Drift is not a move: every check below reads the moves alone; only "stalled" counts drift.
|
|
167
|
+
const moves = all.filter((m) => m.kind !== 'drift');
|
|
168
|
+
const beat = t.tempo ? beatLength(t.tempo) : undefined;
|
|
169
|
+
const tempo = t.tempo && beat ? { ...t.tempo, beat, barLength: beat * t.tempo.bar } : undefined;
|
|
170
|
+
const inBeats = (s) => (beat ? ` (${+(s / beat).toFixed(2)} beats)` : '');
|
|
171
|
+
// ---- scenes, and hand-overs against the scenes they join -------------------------
|
|
172
|
+
const scenes = t.scenes.map((s, i) => {
|
|
173
|
+
const before = t.scenes[i - 1];
|
|
174
|
+
const inn = before?.out?.duration ?? 0, out = i < t.scenes.length - 1 ? s.out?.duration ?? 0 : 0;
|
|
175
|
+
const own = moves.filter((m) => m.scene === s.id || (m.kind === 'hand-over' && before && m.scene === before.id));
|
|
176
|
+
const rests = restsOf(own.filter((m) => m.kind === 'change' && m.scene === s.id)).map((r) => r.rest);
|
|
177
|
+
return {
|
|
178
|
+
id: s.id, start: s.start, end: s.end, length: s.length, in: inn, out, alone: Math.max(0, s.length - inn - out),
|
|
179
|
+
moving: s.length > 0 ? covered(motionSpans(own), s.start, s.end) / s.length : 0,
|
|
180
|
+
changes: own.filter((m) => m.kind === 'change' && m.scene === s.id).length,
|
|
181
|
+
rate: s.length > 0 ? own.filter((m) => m.kind === 'change' && m.scene === s.id).reduce((a, m) => a + (m.share ?? 1), 0) / s.length : 0,
|
|
182
|
+
...(rests.length ? { rest: [Math.min(...rests), Math.max(...rests)] } : {}),
|
|
183
|
+
};
|
|
184
|
+
});
|
|
185
|
+
t.scenes.forEach((s, i) => {
|
|
186
|
+
const next = t.scenes[i + 1];
|
|
187
|
+
if (!s.out || !next || s.out.duration <= 0)
|
|
188
|
+
return;
|
|
189
|
+
const d = s.out.duration, shorter = Math.min(s.length, next.length);
|
|
190
|
+
if (d > shorter * PACE.handoverShare + 1e-6) {
|
|
191
|
+
warn(`scenes.${s.id}.out.duration`, 'handover-long', `The hand-over from "${s.id}" to "${next.id}" takes ${fmt(d)}${inBeats(d)}, ${Math.round((d / shorter) * 100)}% of the shorter scene (${fmt(shorter)}). It reads as a section of its own.`, `Keep a hand-over within a quarter of the shorter scene (${fmt(shorter * PACE.handoverIdeal)} here), or give the scenes more time.`);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
for (const sc of scenes) {
|
|
195
|
+
const longest = Math.max(sc.in, sc.out);
|
|
196
|
+
if (longest > 0 && sc.alone < PACE.aloneTimes * longest - 1e-6) {
|
|
197
|
+
warn(`scenes.${sc.id}`, 'handover-crowds', `Scene "${sc.id}" is on screen alone for only ${fmt(sc.alone)}${inBeats(sc.alone)}: its hand-overs take ${fmt(sc.in)} in and ${fmt(sc.out)} out. The transitions outweigh the section.`, `Give it at least ${fmt(PACE.aloneTimes * longest)} alone (${fmt(PACE.aloneTimes * longest + sc.in + sc.out)} in all), or shorten its hand-overs.`);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
// A scene that changes pictures is felt picture by picture, not as a whole: a
|
|
201
|
+
// hand-over as long as one picture's time on screen reads as one more section.
|
|
202
|
+
const median = (xs) => { const v = [...xs].sort((a, b) => a - b); return v.length ? v[Math.floor((v.length - 1) / 2)] : 0; };
|
|
203
|
+
const shotOf = new Map();
|
|
204
|
+
for (const s of t.scenes) {
|
|
205
|
+
const own = moves.filter((m) => m.kind === 'change' && m.scene === s.id);
|
|
206
|
+
const rests = restsOf(own).map((r) => r.rest);
|
|
207
|
+
if (rests.length)
|
|
208
|
+
shotOf.set(s.id, median(rests) + median(own.map((m) => m.length)));
|
|
209
|
+
}
|
|
210
|
+
t.scenes.forEach((s, i) => {
|
|
211
|
+
const next = t.scenes[i + 1];
|
|
212
|
+
if (!s.out || !next || s.out.duration <= 0)
|
|
213
|
+
return;
|
|
214
|
+
const shots = [s.id, next.id].filter((id) => shotOf.has(id)).map((id) => [id, shotOf.get(id)]);
|
|
215
|
+
if (!shots.length)
|
|
216
|
+
return;
|
|
217
|
+
const [id, shot] = shots.sort((a, b) => a[1] - b[1])[0];
|
|
218
|
+
if (s.out.duration > shot * PACE.shotShare + 1e-6) {
|
|
219
|
+
warn(`scenes.${s.id}.out.duration`, 'handover-vs-picture', `The hand-over from "${s.id}" to "${next.id}" takes ${fmt(s.out.duration)}${inBeats(s.out.duration)}, as long as ${Math.round((s.out.duration / shot) * 100)}% of one picture's time in "${id}" (${fmt(shot)}, rest and change). It is felt as one more picture, not as a seam.`, `Keep it within half a picture's time (${fmt(shot * PACE.shotShare)}): one beat, where a picture is held for two or more.`);
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
const rates = scenes.filter((sc) => sc.changes > 0).map((sc) => [sc.id, sc.rate]);
|
|
223
|
+
if (rates.length > 1) {
|
|
224
|
+
const lo = rates.reduce((a, b) => (b[1] < a[1] ? b : a)), hi = rates.reduce((a, b) => (b[1] > a[1] ? b : a));
|
|
225
|
+
if (hi[1] > lo[1] * PACE.density) {
|
|
226
|
+
warn(`scenes.${hi[0]}`, 'uneven-density', `Scene "${hi[0]}" changes ${Math.round(hi[1] * 100)}% of the frame a second, "${lo[0]}" ${Math.round(lo[1] * 100)}%: the film lurches between busy and slow.`, 'Keep the rate of change within twice from scene to scene. A change counts by how much of the frame it changes: a tile a fifth of the frame counts a fifth. Swap fewer tiles at once, or rest the busier scene longer.');
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
// ---- like moves take like time -------------------------------------------------
|
|
230
|
+
const handovers = moves.filter((m) => m.kind === 'hand-over');
|
|
231
|
+
if (spreadOf(handovers.map((m) => m.length)) > PACE.spread) {
|
|
232
|
+
warn('scenes', 'uneven-handovers', `Hand-overs take different times: ${byUse(handovers)}. The film speeds up and slows down at its seams.`, 'Give every hand-over one length, one or two beats; save a longer one for a single turn of the story at most.');
|
|
233
|
+
}
|
|
234
|
+
const changes = moves.filter((m) => m.kind === 'change');
|
|
235
|
+
if (spreadOf(changes.map((m) => m.length)) > PACE.spread) {
|
|
236
|
+
warn('scenes', 'uneven-changes', `Changes inside scenes take different times: ${byUse(changes)}. Some feel rushed, others slow.`, 'Give every swap, turn and shift one length (a beat, or two), whichever primitive draws it.');
|
|
237
|
+
}
|
|
238
|
+
const rests = restsOf(moves);
|
|
239
|
+
const short = rests.filter((r) => r.rest < PACE.minRest - 1e-6);
|
|
240
|
+
if (short.length) {
|
|
241
|
+
const r = short[0];
|
|
242
|
+
warn(`scenes.${r.after.scene}.layers.${r.after.layer}`, 'short-rest', `A picture rests only ${fmt(r.rest)} between changes in "${r.after.layer}"${short.length > 1 ? ` (${short.length} times in the film)` : ''}: too short to be seen.`, `Rest at least ${fmt(PACE.minRest)} (two beats or more) between changes.`);
|
|
243
|
+
}
|
|
244
|
+
if (spreadOf(rests.map((r) => r.rest)) > PACE.restSpread) {
|
|
245
|
+
const xs = rests.map((r) => r.rest);
|
|
246
|
+
warn('scenes', 'uneven-rests', `Rests between changes run from ${fmt(Math.min(...xs))} to ${fmt(Math.max(...xs))}. The rhythm stumbles.`, 'Rest the same time between every change in the film; let only the opening and closing holds differ.');
|
|
247
|
+
}
|
|
248
|
+
const moving = t.duration > 0 ? covered(motionSpans(moves), 0, t.duration) / t.duration : 0;
|
|
249
|
+
const alive = t.duration > 0 ? covered(motionSpans(all), 0, t.duration) / t.duration : 0;
|
|
250
|
+
if (moves.length && moving > PACE.moving[1]) {
|
|
251
|
+
warn('scenes', 'restless', `Something moves ${Math.round(moving * 100)}% of the time. With so little held, nothing reads.`, 'Aim for about a third in motion: longer rests, fewer parts changing at once, or changes that share a moment instead of following each other.');
|
|
252
|
+
}
|
|
253
|
+
else if (moves.length && alive < PACE.moving[0]) {
|
|
254
|
+
warn('scenes', 'stalled', `Only ${Math.round(moving * 100)}% of the film is in motion; the rest waits.`, 'Shorten the holds, or keep a slow drift under them.');
|
|
255
|
+
}
|
|
256
|
+
// ---- judder: a picture crossing the stage in steps too big to read as motion ------
|
|
257
|
+
const stepMax = Math.min(...t.size) * PACE.judder;
|
|
258
|
+
for (const s of t.scenes) {
|
|
259
|
+
for (const l of s.layers) {
|
|
260
|
+
if (l.speed === undefined)
|
|
261
|
+
continue;
|
|
262
|
+
const step = l.speed / t.fps;
|
|
263
|
+
if (step > stepMax + 1e-6) {
|
|
264
|
+
warn(`scenes.${s.id}.layers.${l.id}`, 'judder', `"${l.id}" crosses the stage at up to ${Math.round(l.speed)} px a second, ${Math.round(step)} px a frame at ${t.fps} fps: it strobes instead of gliding.`, `Keep it under ${Math.round(stepMax)} px a frame (${Math.round(stepMax * t.fps)} px a second): travel less of the picture, or give it longer.`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
// ---- even cuts: a run of shots of one length ticks like a metronome --------------
|
|
269
|
+
const cutAt = (i) => {
|
|
270
|
+
const s = t.scenes[i], prev = t.scenes[i - 1];
|
|
271
|
+
return i === 0 ? 0 : s.start + (prev?.out?.duration ?? 0) / 2;
|
|
272
|
+
};
|
|
273
|
+
const shots = t.scenes.map((s, i) => ({ id: s.id, length: (i + 1 < t.scenes.length ? cutAt(i + 1) : t.duration) - cutAt(i) }));
|
|
274
|
+
for (let i = 0, run = 1; i < shots.length; i++) {
|
|
275
|
+
const same = i + 1 < shots.length && Math.abs(shots[i + 1].length - shots[i].length) < 1 / t.fps + 1e-6;
|
|
276
|
+
if (same) {
|
|
277
|
+
run++;
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
if (run >= PACE.evenCuts) {
|
|
281
|
+
const first = shots[i - run + 1];
|
|
282
|
+
warn(`scenes.${first.id}`, 'even-cuts', `${run} shots in a row, from "${first.id}" to "${shots[i].id}", each last ${fmt(shots[i].length)}${inBeats(shots[i].length)}: the cut ticks like a metronome.`, 'Alternate long and short: let a sweeping shot run twice as long as the quick ones around it, so the eye rests before each burst.');
|
|
283
|
+
}
|
|
284
|
+
run = 1;
|
|
285
|
+
}
|
|
286
|
+
// ---- the grid --------------------------------------------------------------------
|
|
287
|
+
if (tempo) {
|
|
288
|
+
const tol = 1 / t.fps + 1e-6, half = tempo.beat / 2;
|
|
289
|
+
const where = (s) => {
|
|
290
|
+
const b = s / tempo.beat;
|
|
291
|
+
return `bar ${Math.floor(b / tempo.bar) + 1}, beat ${+((b % tempo.bar) + 1).toFixed(2)}`;
|
|
292
|
+
};
|
|
293
|
+
t.scenes.forEach((s, i) => {
|
|
294
|
+
if (i === 0)
|
|
295
|
+
return;
|
|
296
|
+
const prev = t.scenes[i - 1];
|
|
297
|
+
const d = prev.out?.duration ?? 0, cut = s.start + d / 2;
|
|
298
|
+
// A hand-over is a turn of the film: it lands on a bar line. A plain cut is the
|
|
299
|
+
// edit's own pulse: any beat will do.
|
|
300
|
+
const unit = d > 0 ? tempo.barLength : tempo.beat;
|
|
301
|
+
if (offGrid(cut, unit) > tol) {
|
|
302
|
+
warn(prev.out ? `scenes.${prev.id}.out` : `scenes.${prev.id}`, 'off-grid', `The cut into "${s.id}" lands at ${fmt(cut)}, ${where(cut)}. ${d ? 'A hand-over lands on the first beat of a bar.' : 'A plain cut lands on a beat.'}`, d ? `The cut is the middle of the hand-over. Make "${prev.id}" a whole number of bars from the last cut.` : `Make "${prev.id}" a whole number of beats from the last cut.`);
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
const bySceneOff = new Map();
|
|
306
|
+
for (const m of moves) {
|
|
307
|
+
if (m.kind === 'hand-over') {
|
|
308
|
+
if (offGrid(m.length, half) > tol)
|
|
309
|
+
bySceneOff.set(m.scene, [...(bySceneOff.get(m.scene) ?? []), m]);
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
const off = offGrid(m.start, half) > tol || (m.kind !== 'run' && offGrid(m.length, half) > tol);
|
|
313
|
+
if (off)
|
|
314
|
+
bySceneOff.set(m.scene, [...(bySceneOff.get(m.scene) ?? []), m]);
|
|
315
|
+
}
|
|
316
|
+
for (const [scene, ms] of bySceneOff) {
|
|
317
|
+
const eg = ms.slice(0, 3).map((m) => `${m.layer ?? m.use} ${m.kind} at ${fmt(m.start)} for ${fmt(m.length)}`).join('; ');
|
|
318
|
+
warn(`scenes.${scene}`, 'off-beat', `${ms.length} move(s) in "${scene}" start or end off the half-beat (${fmt(half)}): ${eg}.`, 'Write their times and lengths in beats ("1b", "0.5b") so they land on the pulse.');
|
|
319
|
+
}
|
|
320
|
+
if (t.loop && offGrid(t.duration, tempo.barLength) > tol) {
|
|
321
|
+
warn('scenes', 'loop-bars', `The loop is ${fmt(t.duration)}, ${+(t.duration / tempo.barLength).toFixed(2)} bars: it restarts mid-bar, so the pulse jumps at the seam.`, `Make it a whole number of bars (${tempo.barLength.toFixed(2)} s each).`);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
// The framing camera at each plain cut, either side.
|
|
325
|
+
const cuts = t.scenes.slice(1).flatMap((s, i) => {
|
|
326
|
+
const before = t.scenes[i];
|
|
327
|
+
if (before.out || (!before.camera && !s.camera))
|
|
328
|
+
return [];
|
|
329
|
+
return [{ at: s.start, from: cameraAt(before, before.length), to: cameraAt(s, 0) }];
|
|
330
|
+
});
|
|
331
|
+
return { duration: t.duration, ...(tempo ? { tempo } : {}), moves: all, scenes, moving, drifting: alive, issues, cuts };
|
|
332
|
+
}
|
|
333
|
+
/** One row per scene, one cell per beat (or quarter second): ≈ hand-over, █ change, ▒ other move, ~ drift, · still. */
|
|
334
|
+
export function rhythmChart(t, p) {
|
|
335
|
+
const cell = p.tempo ? p.tempo.beat : 0.25, per = p.tempo ? p.tempo.bar : 4;
|
|
336
|
+
const cells = Math.ceil(t.duration / cell - 1e-6);
|
|
337
|
+
const width = Math.max(...t.scenes.map((s) => s.id.length), 5);
|
|
338
|
+
const row = (s, i) => {
|
|
339
|
+
const before = t.scenes[i - 1];
|
|
340
|
+
let out = '';
|
|
341
|
+
for (let c = 0; c < cells; c++) {
|
|
342
|
+
if (c % per === 0)
|
|
343
|
+
out += '|';
|
|
344
|
+
const mid = (c + 0.5) * cell;
|
|
345
|
+
const on = (m) => mid >= m.start && mid < m.start + m.length;
|
|
346
|
+
if (mid < s.start || mid >= s.end) {
|
|
347
|
+
out += ' ';
|
|
348
|
+
continue;
|
|
349
|
+
}
|
|
350
|
+
const ms = p.moves.filter(on);
|
|
351
|
+
if (ms.some((m) => m.kind === 'hand-over' && (m.scene === s.id || m.scene === before?.id)))
|
|
352
|
+
out += '≈';
|
|
353
|
+
else if (ms.some((m) => m.scene === s.id && m.kind === 'change'))
|
|
354
|
+
out += '█';
|
|
355
|
+
else if (ms.some((m) => m.scene === s.id && m.kind !== 'drift'))
|
|
356
|
+
out += '▒';
|
|
357
|
+
else if (ms.some((m) => m.scene === s.id))
|
|
358
|
+
out += '~';
|
|
359
|
+
else
|
|
360
|
+
out += '·';
|
|
361
|
+
}
|
|
362
|
+
return `${s.id.padEnd(width)} ${out}|`;
|
|
363
|
+
};
|
|
364
|
+
return t.scenes.map(row);
|
|
365
|
+
}
|
|
366
|
+
export function describePace(t, p) {
|
|
367
|
+
const lines = [];
|
|
368
|
+
const b = (s) => (p.tempo ? `${+(s / p.tempo.beat).toFixed(2)}b` : '');
|
|
369
|
+
if (p.tempo)
|
|
370
|
+
lines.push(`tempo ${p.tempo.bpm} bpm, ${p.tempo.bar} beats a bar: beat ${fmt(p.tempo.beat)}, bar ${fmt(p.tempo.barLength)}; film ${fmt(p.duration)} = ${+(p.duration / p.tempo.barLength).toFixed(2)} bars`);
|
|
371
|
+
else
|
|
372
|
+
lines.push(`no tempo: film ${fmt(p.duration)}. Add "tempo": {"bpm": …} to count it in beats.`);
|
|
373
|
+
lines.push(`moving ${Math.round(p.moving * 100)}% of the time, drifting or moving ${Math.round(p.drifting * 100)}%`, '');
|
|
374
|
+
lines.push(`${'scene'.padEnd(14)} ${'length'.padStart(8)} ${'in'.padStart(6)} ${'out'.padStart(6)} ${'alone'.padStart(7)} ${'moving'.padStart(7)} changes ${'frame/s'.padStart(7)} rests`);
|
|
375
|
+
for (const s of p.scenes) {
|
|
376
|
+
lines.push(`${s.id.padEnd(14)} ${s.length.toFixed(2).padStart(8)} ${s.in.toFixed(2).padStart(6)} ${s.out.toFixed(2).padStart(6)} ${s.alone.toFixed(2).padStart(7)} ${`${Math.round(s.moving * 100)}%`.padStart(7)} ${String(s.changes).padStart(7)} ${`${Math.round(s.rate * 100)}%`.padStart(7)} ${s.rest ? `${s.rest[0].toFixed(2)}–${s.rest[1].toFixed(2)} s` : ''}`);
|
|
377
|
+
}
|
|
378
|
+
const kinds = [['hand-over', 'hand-overs'], ['change', 'changes'], ['enter', 'enters'], ['exit', 'exits']];
|
|
379
|
+
lines.push('');
|
|
380
|
+
for (const [k, label] of kinds) {
|
|
381
|
+
const ms = p.moves.filter((m) => m.kind === k);
|
|
382
|
+
if (!ms.length)
|
|
383
|
+
continue;
|
|
384
|
+
const lens = [...new Set(ms.map((m) => `${m.length.toFixed(2)} s${p.tempo ? ` ${b(m.length)}` : ''}`))];
|
|
385
|
+
lines.push(`${label.padEnd(11)} ${ms.length} × ${lens.join(', ')}`);
|
|
386
|
+
}
|
|
387
|
+
lines.push('', `rhythm (one cell per ${p.tempo ? 'beat' : '0.25 s'}, | every ${p.tempo ? 'bar' : 'second'}; ≈ hand-over, █ change, ▒ other move, ~ drift, · still)`);
|
|
388
|
+
lines.push(...rhythmChart(t, p));
|
|
389
|
+
if (p.cuts.length) {
|
|
390
|
+
const cam = (c) => `${c.scene}${c.frame ? ` on ${typeof c.frame === 'string' ? c.frame : `${c.frame[0]}%,${c.frame[1]}%`}` : ''} ×${+c.zoom.toFixed(2)}${c.tilt[0] || c.tilt[1] ? ` tilt ${+c.tilt[0].toFixed(1)}°/${+c.tilt[1].toFixed(1)}°` : ''}`;
|
|
391
|
+
lines.push('', 'camera at the cuts (match size and tilt across a cut to make it a match cut):');
|
|
392
|
+
for (const c of p.cuts)
|
|
393
|
+
lines.push(` ${fmt(c.at)} ${cam(c.from)} → ${cam(c.to)}`);
|
|
394
|
+
}
|
|
395
|
+
return lines.join('\n');
|
|
396
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Tokens } from '../tokens.ts';
|
|
2
|
+
import { type Issue, type Timeline } from './types.ts';
|
|
3
|
+
export interface Resolution {
|
|
4
|
+
ok: boolean;
|
|
5
|
+
issues: Issue[];
|
|
6
|
+
tokens: Tokens;
|
|
7
|
+
/** Present when there are no errors. */
|
|
8
|
+
timeline?: Timeline;
|
|
9
|
+
}
|
|
10
|
+
/** Primitives whose instance has a tip a camera can follow. */
|
|
11
|
+
export declare const FOLLOWABLE: string[];
|
|
12
|
+
/** The closest known name, when one is close enough to be a likely typo. */
|
|
13
|
+
export declare function nearest(name: string, known: readonly string[]): string | undefined;
|
|
14
|
+
export declare function resolveFilm(input: unknown): Resolution;
|
|
15
|
+
/** A compact, readable account of the timeline: what an agent reads back after writing a film. */
|
|
16
|
+
export declare function describeTimeline(t: Timeline): string;
|