@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,39 @@
|
|
|
1
|
+
import { type Primitive } from '../types.ts';
|
|
2
|
+
import { type CameraPose } from './camera.ts';
|
|
3
|
+
export declare const ORDERS: readonly ["close", "open", "open-close"];
|
|
4
|
+
export declare const LOOKS: readonly ["solid", "wire"];
|
|
5
|
+
/** The lay at which a square lying flat is drawn isometric: its diagonals in the ratio 1 to √3. */
|
|
6
|
+
export declare const ISOMETRIC_LAY = 54.7356;
|
|
7
|
+
export type Order = (typeof ORDERS)[number];
|
|
8
|
+
export interface StackTiming {
|
|
9
|
+
order: Order;
|
|
10
|
+
start: number;
|
|
11
|
+
travel: number;
|
|
12
|
+
stagger: number;
|
|
13
|
+
apart: number;
|
|
14
|
+
}
|
|
15
|
+
/** When the last plane has landed (or, for `open`, lifted), in seconds. */
|
|
16
|
+
export declare function stackEnd(n: number, s: StackTiming): number;
|
|
17
|
+
/**
|
|
18
|
+
* How far each of `n` planes is lifted off the base at time t: 0 lying on it,
|
|
19
|
+
* 1 at its full height. Plane 0 is the base and never moves. Closing, the
|
|
20
|
+
* lowest plane lands first; opening, the top one lifts first. A higher plane
|
|
21
|
+
* is never less open than the one below it, so planes cannot pass each other.
|
|
22
|
+
*/
|
|
23
|
+
export declare function lifts(n: number, t: number, s: StackTiming, ease?: (x: number) => number): number[];
|
|
24
|
+
export interface View {
|
|
25
|
+
lay: number;
|
|
26
|
+
turn: number;
|
|
27
|
+
cam: CameraPose;
|
|
28
|
+
P: number;
|
|
29
|
+
w: number;
|
|
30
|
+
h: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Where a point of the stack is seen, in px from the middle of the rig. The point
|
|
34
|
+
* is given from the middle of a plane, z along the planes' normal. It follows the
|
|
35
|
+
* same chain the browser applies: the planes' turn and lay, then the camera's pan,
|
|
36
|
+
* roll, tilt, pitch and distance, then the lens.
|
|
37
|
+
*/
|
|
38
|
+
export declare function project([x, y, z]: readonly [number, number, number], v: View): [number, number];
|
|
39
|
+
export declare const layerStack: Primitive;
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
// rig/layer-stack. See library/primitives/rig/layer-stack.md.
|
|
2
|
+
//
|
|
3
|
+
// Named planes lie flat and float one above the other, seen from above at an
|
|
4
|
+
// angle, each with a label that always faces the camera. They close onto the
|
|
5
|
+
// lowest plane one after another (or open from it), so several things are seen
|
|
6
|
+
// to become one. The base never moves: the stack grows upward from it and comes
|
|
7
|
+
// back down to it, which leaves the closed layer low in the rig, ready for
|
|
8
|
+
// whatever the next scene stands on it. Seen by the rigs' shared camera
|
|
9
|
+
// (./camera.ts), on top of the stack's own lay and turn.
|
|
10
|
+
import { clamp } from "../../core/ease.js";
|
|
11
|
+
import { list, num, str } from "../types.js";
|
|
12
|
+
import { cameraAt, cameraEnd, cameraParams, cameraTransform } from "./camera.js";
|
|
13
|
+
const hairline = (pct) => `color-mix(in srgb, var(--m-text-primary) ${pct}%, transparent)`;
|
|
14
|
+
const smooth = (x) => { const k = clamp(x); return k * k * (3 - 2 * k); };
|
|
15
|
+
const rad = (deg) => (deg * Math.PI) / 180;
|
|
16
|
+
export const ORDERS = ['close', 'open', 'open-close'];
|
|
17
|
+
export const LOOKS = ['solid', 'wire'];
|
|
18
|
+
/** The lay at which a square lying flat is drawn isometric: its diagonals in the ratio 1 to √3. */
|
|
19
|
+
export const ISOMETRIC_LAY = 54.7356;
|
|
20
|
+
/** When the last plane has landed (or, for `open`, lifted), in seconds. */
|
|
21
|
+
export function stackEnd(n, s) {
|
|
22
|
+
const one = s.travel + Math.max(0, n - 2) * s.stagger;
|
|
23
|
+
return s.start + (s.order === 'open-close' ? 2 * one + s.apart : one);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* How far each of `n` planes is lifted off the base at time t: 0 lying on it,
|
|
27
|
+
* 1 at its full height. Plane 0 is the base and never moves. Closing, the
|
|
28
|
+
* lowest plane lands first; opening, the top one lifts first. A higher plane
|
|
29
|
+
* is never less open than the one below it, so planes cannot pass each other.
|
|
30
|
+
*/
|
|
31
|
+
export function lifts(n, t, s, ease = (x) => x) {
|
|
32
|
+
const travel = Math.max(0.01, s.travel);
|
|
33
|
+
const opening = (from) => Array.from({ length: n }, (_, i) => (i === 0 ? 0 : ease(clamp((t - from - (n - 1 - i) * s.stagger) / travel))));
|
|
34
|
+
const closing = (from) => Array.from({ length: n }, (_, i) => (i === 0 ? 0 : 1 - ease(clamp((t - from - (i - 1) * s.stagger) / travel))));
|
|
35
|
+
if (s.order === 'open')
|
|
36
|
+
return opening(s.start);
|
|
37
|
+
if (s.order === 'close')
|
|
38
|
+
return closing(s.start);
|
|
39
|
+
const shut = s.start + travel + Math.max(0, n - 2) * s.stagger + s.apart;
|
|
40
|
+
return t < shut ? opening(s.start) : closing(shut);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Where a point of the stack is seen, in px from the middle of the rig. The point
|
|
44
|
+
* is given from the middle of a plane, z along the planes' normal. It follows the
|
|
45
|
+
* same chain the browser applies: the planes' turn and lay, then the camera's pan,
|
|
46
|
+
* roll, tilt, pitch and distance, then the lens.
|
|
47
|
+
*/
|
|
48
|
+
export function project([x, y, z], v) {
|
|
49
|
+
const rot = (a, b, deg) => {
|
|
50
|
+
const r = rad(deg), c = Math.cos(r), s = Math.sin(r);
|
|
51
|
+
return [a * c - b * s, a * s + b * c];
|
|
52
|
+
};
|
|
53
|
+
[x, y] = rot(x, y, v.turn);
|
|
54
|
+
[y, z] = rot(y, z, v.lay);
|
|
55
|
+
x -= v.cam.x * v.w;
|
|
56
|
+
y -= v.cam.y * v.h;
|
|
57
|
+
[x, y] = rot(x, y, v.cam.rz);
|
|
58
|
+
[z, x] = rot(z, x, v.cam.ry);
|
|
59
|
+
[y, z] = rot(y, z, v.cam.rx);
|
|
60
|
+
// Zoom is a distance, so a parallel lens has none.
|
|
61
|
+
if (v.P > 0)
|
|
62
|
+
z += v.P * (1 - 1 / Math.max(0.05, v.cam.zoom));
|
|
63
|
+
// P 0 is a parallel lens: depth changes nothing.
|
|
64
|
+
const k = v.P > 0 ? v.P / Math.max(1, v.P - z) : 1;
|
|
65
|
+
return [x * k, y * k];
|
|
66
|
+
}
|
|
67
|
+
const timing = (p) => ({
|
|
68
|
+
order: ORDERS.includes(str(p.order)) ? str(p.order) : 'close',
|
|
69
|
+
start: num(p.start), travel: num(p.travel), stagger: num(p.stagger), apart: num(p.apart),
|
|
70
|
+
});
|
|
71
|
+
export const layerStack = {
|
|
72
|
+
slug: 'rig/layer-stack',
|
|
73
|
+
summary: 'Named planes float one above the other, then close onto the lowest and become one layer.',
|
|
74
|
+
props: {
|
|
75
|
+
items: { type: 'string[]', required: true, label: 'Plane names, from the base up' },
|
|
76
|
+
faces: { type: 'string[]', default: [], label: 'A picture for each plane, in the same order (paths relative to the film)' },
|
|
77
|
+
name: { type: 'string', default: '', label: 'What the closed stack is called' },
|
|
78
|
+
},
|
|
79
|
+
params: {
|
|
80
|
+
width: { type: 'number', default: 42, min: 15, max: 90, step: 1, unit: '% of stage width', label: 'Width of a plane' },
|
|
81
|
+
aspect: { type: 'number', default: 1, min: 0.4, max: 1.6, step: 0.01, unit: 'depth ÷ width', label: 'Proportions of a plane' },
|
|
82
|
+
gap: { type: 'number', default: 120, min: 20, max: 320, step: 1, unit: 'px', label: 'Space between planes when apart' },
|
|
83
|
+
lay: { type: 'number', default: 60, min: 0, max: 80, step: 1, unit: 'deg', label: 'How far the planes lie back (0 faces the camera)' },
|
|
84
|
+
turn: { type: 'number', default: -45, min: -90, max: 90, step: 1, unit: 'deg', label: 'Turn of the planes about their own axis' },
|
|
85
|
+
spin: { type: 'number', default: 1.2, min: -8, max: 8, step: 0.1, unit: 'deg/s', label: 'Slow turn that never stops' },
|
|
86
|
+
order: { type: 'choice', default: 'close', options: ORDERS, label: 'Close starts apart and ends as one, open the reverse, open-close does both' },
|
|
87
|
+
start: { type: 'number', default: 1.4, min: 0, max: 10, step: 0.05, unit: 's', label: 'When the planes start to move' },
|
|
88
|
+
travel: { type: 'number', default: 0.9, min: 0.3, max: 3, step: 0.05, unit: 's', label: 'Time one plane takes to land or lift' },
|
|
89
|
+
stagger: { type: 'number', default: 0.14, min: 0, max: 0.6, step: 0.01, unit: 's', label: 'Delay between one plane and the next' },
|
|
90
|
+
apart: { type: 'number', default: 1.2, min: 0, max: 6, step: 0.05, unit: 's', label: 'For open-close: time held apart' },
|
|
91
|
+
radius: { type: 'number', default: 28, min: 0, max: 120, step: 1, unit: 'px', label: 'Corner radius of a plane' },
|
|
92
|
+
lens: { type: 'number', default: 4, min: 0, max: 12, step: 0.5, unit: '× the rig', label: 'Length of the lens; 0 is parallel, as in an isometric drawing' },
|
|
93
|
+
look: { type: 'choice', default: 'solid', options: LOOKS, label: 'Solid surfaces with shadows, or a wire drawing with guides and numbered labels' },
|
|
94
|
+
...cameraParams({ path: 'hold', tilt: 0, pitch: 0, roll: 0, zoom: 1, move: 1.6 }),
|
|
95
|
+
},
|
|
96
|
+
duration: (props, p) => {
|
|
97
|
+
const n = list(props.items).length, s = timing(p);
|
|
98
|
+
// The ring that marks the planes becoming one runs on for 0.9 s after the last landing.
|
|
99
|
+
return Math.max(cameraEnd(p), stackEnd(n, s) + (s.order === 'open' ? 0 : 0.9));
|
|
100
|
+
},
|
|
101
|
+
check(props) {
|
|
102
|
+
const n = list(props.items).length, f = list(props.faces).length;
|
|
103
|
+
const issues = [];
|
|
104
|
+
if (n < 2)
|
|
105
|
+
issues.push({ path: 'props.items', message: 'A stack needs at least two planes.', hint: 'Name two to seven planes, from the base up.' });
|
|
106
|
+
if (f > 0 && f !== n)
|
|
107
|
+
issues.push({ path: 'props.faces', message: `There are ${f} faces for ${n} planes.`, hint: 'Give one picture per plane, or none.' });
|
|
108
|
+
return issues;
|
|
109
|
+
},
|
|
110
|
+
build(el, props, p, ctx) {
|
|
111
|
+
const doc = el.ownerDocument;
|
|
112
|
+
const [W] = ctx.size, u = W / 1080;
|
|
113
|
+
const items = list(props.items), faces = list(props.faces), n = items.length;
|
|
114
|
+
const s = timing(p);
|
|
115
|
+
const w = (num(p.width) / 100) * W, h = w * num(p.aspect), gap = num(p.gap) * u, R = num(p.radius) * u;
|
|
116
|
+
const lay = num(p.lay), turn0 = num(p.turn), spin = num(p.spin);
|
|
117
|
+
// The box the layer takes on stage: the planes' footprint as seen, plus the height of the open stack.
|
|
118
|
+
const a0 = rad(turn0), cl = Math.cos(rad(lay)), sl = Math.sin(rad(lay));
|
|
119
|
+
const bw = Math.abs(w * Math.cos(a0)) + Math.abs(h * Math.sin(a0));
|
|
120
|
+
const bh = (Math.abs(w * Math.sin(a0)) + Math.abs(h * Math.cos(a0))) * cl + (n - 1) * gap * sl;
|
|
121
|
+
// A long lens keeps planes near parallel, so the stack reads as a diagram, not a room; at 0 they are parallel.
|
|
122
|
+
const P = Math.max(bw, bh) * num(p.lens);
|
|
123
|
+
const wire = str(p.look) === 'wire';
|
|
124
|
+
const z0 = -((n - 1) * gap) / 2;
|
|
125
|
+
const wrap = doc.createElement('div');
|
|
126
|
+
wrap.style.cssText = `position:relative;width:${bw}px;height:${bh}px;perspective:${P > 0 ? `${P}px` : 'none'}`;
|
|
127
|
+
const world = doc.createElement('div');
|
|
128
|
+
world.style.cssText = `position:absolute;left:${(bw - w) / 2}px;top:${(bh - h) / 2}px;width:${w}px;height:${h}px;transform-style:preserve-3d;transform-origin:50% 50%`;
|
|
129
|
+
const turner = doc.createElement('div');
|
|
130
|
+
turner.style.cssText = 'position:absolute;inset:0;transform-style:preserve-3d;transform-origin:50% 50%';
|
|
131
|
+
world.appendChild(turner);
|
|
132
|
+
// Labels are not in the 3D world: a quad that faces the camera cuts through the plane
|
|
133
|
+
// it marks and loses half of itself to it. They sit on a flat sheet over the rig, at
|
|
134
|
+
// the point where their corner is seen.
|
|
135
|
+
const overlay = doc.createElement('div');
|
|
136
|
+
overlay.style.cssText = 'position:absolute;inset:0';
|
|
137
|
+
const font = 'var(--m-font-body)';
|
|
138
|
+
const label = (text, color, mark, index = '') => {
|
|
139
|
+
const l = doc.createElement('div');
|
|
140
|
+
l.style.cssText = `position:absolute;left:0;top:0;transform-origin:0 0;display:flex;align-items:center;gap:${12 * u}px;white-space:nowrap;`
|
|
141
|
+
+ (wire ? `font:500 ${21 * u}px/1 var(--m-font-mono);letter-spacing:0.06em;text-transform:uppercase;color:${color}`
|
|
142
|
+
: `font:500 ${27 * u}px/1 ${font};letter-spacing:-0.01em;color:${color}`);
|
|
143
|
+
const dot = doc.createElement('i');
|
|
144
|
+
dot.style.cssText = `display:block;flex:none;width:${9 * u}px;height:${9 * u}px;border-radius:50%;background:${mark};margin-left:${-4.5 * u}px`;
|
|
145
|
+
const stem = doc.createElement('i');
|
|
146
|
+
stem.style.cssText = wire
|
|
147
|
+
? `display:block;flex:none;width:${44 * u}px;height:0;border-top:${1.5 * u}px dotted ${hairline(45)}`
|
|
148
|
+
: `display:block;flex:none;width:${34 * u}px;height:${1.5 * u}px;background:${hairline(22)}`;
|
|
149
|
+
const span = doc.createElement('span');
|
|
150
|
+
span.textContent = text;
|
|
151
|
+
l.append(dot, stem);
|
|
152
|
+
if (index) {
|
|
153
|
+
const no = doc.createElement('span');
|
|
154
|
+
no.textContent = index;
|
|
155
|
+
no.style.color = hairline(45);
|
|
156
|
+
l.appendChild(no);
|
|
157
|
+
}
|
|
158
|
+
l.appendChild(span);
|
|
159
|
+
// Centre the row on the corner it marks.
|
|
160
|
+
const inner = doc.createElement('div');
|
|
161
|
+
inner.style.cssText = 'position:absolute;left:0;top:0;transform-origin:0 0';
|
|
162
|
+
l.style.transform = 'translateY(-50%)';
|
|
163
|
+
inner.appendChild(l);
|
|
164
|
+
overlay.appendChild(inner);
|
|
165
|
+
return inner;
|
|
166
|
+
};
|
|
167
|
+
// The ring that leaves the base when the planes have become one.
|
|
168
|
+
const ring = doc.createElement('div');
|
|
169
|
+
ring.style.cssText = `position:absolute;inset:0;border-radius:${R}px;box-shadow:0 0 0 ${2 * u}px var(--m-accent);visibility:hidden`;
|
|
170
|
+
turner.appendChild(ring);
|
|
171
|
+
const planes = items.map((title, i) => {
|
|
172
|
+
const plane = doc.createElement('div');
|
|
173
|
+
plane.style.cssText = `position:absolute;inset:0;border-radius:${R}px;overflow:hidden;`
|
|
174
|
+
+ `background:color-mix(in srgb, var(${wire ? '--m-bg-base' : '--m-bg-surface'}) ${wire ? 86 : 92}%, transparent)`;
|
|
175
|
+
if (faces[i]) {
|
|
176
|
+
const img = doc.createElement('img');
|
|
177
|
+
img.src = faces[i];
|
|
178
|
+
img.alt = title;
|
|
179
|
+
img.decoding = 'sync';
|
|
180
|
+
img.style.cssText = 'position:absolute;inset:0;width:100%;height:100%;object-fit:cover;display:block';
|
|
181
|
+
plane.appendChild(img);
|
|
182
|
+
}
|
|
183
|
+
// The look the top plane takes once everything lies on the base: the accent, lit.
|
|
184
|
+
const lit = doc.createElement('div');
|
|
185
|
+
lit.style.cssText = `position:absolute;inset:0;border-radius:inherit;background:color-mix(in srgb, var(--m-accent) ${wire ? 20 : 16}%, transparent);`
|
|
186
|
+
+ `box-shadow:inset 0 0 0 ${2 * u}px var(--m-accent)${wire ? '' : `, inset 0 0 ${90 * u}px color-mix(in srgb, var(--m-accent) 30%, transparent)`};opacity:0`;
|
|
187
|
+
plane.appendChild(lit);
|
|
188
|
+
turner.appendChild(plane);
|
|
189
|
+
return { plane, lit, tag: label(title, 'var(--m-text-secondary)', hairline(wire ? 80 : 55), wire ? String(i + 1).padStart(2, '0') : '') };
|
|
190
|
+
});
|
|
191
|
+
const nameTag = str(props.name) ? label(str(props.name), 'var(--m-text-primary)', 'var(--m-accent)') : null;
|
|
192
|
+
if (nameTag)
|
|
193
|
+
nameTag.firstElementChild.style.fontWeight = '600';
|
|
194
|
+
// Wire look: dotted guides join the corners of the base to the corners of the top plane.
|
|
195
|
+
const NS = 'http://www.w3.org/2000/svg';
|
|
196
|
+
const guides = wire ? [0, 1, 2].map(() => {
|
|
197
|
+
const svg = overlay.querySelector('svg') ?? overlay.insertBefore(doc.createElementNS(NS, 'svg'), overlay.firstChild);
|
|
198
|
+
svg.setAttribute('width', String(bw));
|
|
199
|
+
svg.setAttribute('height', String(bh));
|
|
200
|
+
svg.style.cssText = 'position:absolute;left:0;top:0;overflow:visible';
|
|
201
|
+
const line = doc.createElementNS(NS, 'line');
|
|
202
|
+
line.setAttribute('stroke', hairline(55));
|
|
203
|
+
line.setAttribute('stroke-width', String(1.5 * u));
|
|
204
|
+
line.setAttribute('stroke-dasharray', `${1.5 * u} ${7 * u}`);
|
|
205
|
+
line.setAttribute('stroke-linecap', 'round');
|
|
206
|
+
svg.appendChild(line);
|
|
207
|
+
return line;
|
|
208
|
+
}) : [];
|
|
209
|
+
wrap.append(world, overlay);
|
|
210
|
+
el.appendChild(wrap);
|
|
211
|
+
const camEase = ctx.ease(p.ease), move = ctx.ease('quint.inOut'), out = ctx.ease('expo.out');
|
|
212
|
+
const landed = stackEnd(n, s);
|
|
213
|
+
return {
|
|
214
|
+
seek(t) {
|
|
215
|
+
const cam = cameraAt(t, p, camEase);
|
|
216
|
+
world.style.transform = cameraTransform(cam, P, w, h);
|
|
217
|
+
const turn = turn0 + spin * t;
|
|
218
|
+
turner.style.transform = `rotateX(${lay.toFixed(3)}deg) rotateZ(${turn.toFixed(3)}deg)`;
|
|
219
|
+
const at = (x, y, z) => {
|
|
220
|
+
const [sx, sy] = project([x - w / 2, y - h / 2, z], { lay, turn, cam, P, w, h });
|
|
221
|
+
return [bw / 2 + sx, bh / 2 + sy];
|
|
222
|
+
};
|
|
223
|
+
const seen = (x, y, z) => { const [sx, sy] = at(x, y, z); return `translate(${sx.toFixed(2)}px, ${sy.toFixed(2)}px)`; };
|
|
224
|
+
// They hang on the corner that is furthest right on screen.
|
|
225
|
+
const a = rad(turn), c = Math.cos(a), sn = Math.sin(a);
|
|
226
|
+
let cx = w, cy = h, best = -Infinity;
|
|
227
|
+
for (const [x, y] of [[0, 0], [w, 0], [w, h], [0, h]]) {
|
|
228
|
+
const sx = (x - w / 2) * c - (y - h / 2) * sn;
|
|
229
|
+
if (sx > best) {
|
|
230
|
+
best = sx;
|
|
231
|
+
cx = x;
|
|
232
|
+
cy = y;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
const lift = lifts(n, t, s, move);
|
|
236
|
+
const top = lift[n - 1] ?? 0, closed = 1 - top;
|
|
237
|
+
planes.forEach((pl, i) => {
|
|
238
|
+
const k = lift[i], z = z0 + i * gap * k;
|
|
239
|
+
pl.plane.style.transform = `translateZ(${z.toFixed(2)}px)`;
|
|
240
|
+
// A plane's shadow grows with its height above the one below; lying flush it casts nothing.
|
|
241
|
+
const above = i === 0 ? 1 : clamp((k * i - (lift[i - 1] ?? 0) * (i - 1)));
|
|
242
|
+
pl.plane.style.boxShadow = wire
|
|
243
|
+
? `inset 0 0 0 ${1.5 * u}px ${hairline(i === 0 ? 85 : 62)}`
|
|
244
|
+
: `0 0 0 ${1.5 * u}px ${hairline(i === 0 ? 14 : 10 + 8 * above)},0 0 ${70 * u * above}px rgba(0,0,0,${(0.38 * above).toFixed(3)})`;
|
|
245
|
+
// A plane lying on another is that plane: it is gone by the time it lands.
|
|
246
|
+
pl.plane.style.opacity = i === 0 || i === n - 1 ? '1' : smooth(k / 0.25).toFixed(3);
|
|
247
|
+
pl.lit.style.opacity = i === n - 1 ? smooth((closed - 0.55) / 0.45).toFixed(3) : '0';
|
|
248
|
+
pl.tag.style.transform = seen(cx, cy, z);
|
|
249
|
+
pl.tag.style.opacity = (i === 0 ? smooth(top / 0.3) : smooth((k - 0.15) / 0.35)).toFixed(3);
|
|
250
|
+
});
|
|
251
|
+
if (nameTag) {
|
|
252
|
+
nameTag.style.transform = seen(cx, cy, z0);
|
|
253
|
+
nameTag.style.opacity = smooth((closed - 0.7) / 0.3).toFixed(3);
|
|
254
|
+
}
|
|
255
|
+
if (guides.length) {
|
|
256
|
+
// Every corner but the furthest one, which the planes hide.
|
|
257
|
+
const corners = [[0, 0], [w, 0], [w, h], [0, h]].map(([x, y]) => ({ a: at(x, y, z0), b: at(x, y, z0 + (n - 1) * gap * top) }));
|
|
258
|
+
const back = corners.reduce((m, c, i) => (c.a[1] < corners[m].a[1] ? i : m), 0);
|
|
259
|
+
corners.filter((_, i) => i !== back).forEach((c, i) => {
|
|
260
|
+
const g = guides[i];
|
|
261
|
+
g.setAttribute('x1', c.a[0].toFixed(2));
|
|
262
|
+
g.setAttribute('y1', c.a[1].toFixed(2));
|
|
263
|
+
g.setAttribute('x2', c.b[0].toFixed(2));
|
|
264
|
+
g.setAttribute('y2', c.b[1].toFixed(2));
|
|
265
|
+
g.setAttribute('opacity', smooth(top / 0.3).toFixed(3));
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
// One ring, once, from the base outward.
|
|
269
|
+
const r = s.order === 'open' ? 0 : clamp((t - landed + 0.12) / 0.9);
|
|
270
|
+
ring.style.visibility = r > 0 && r < 1 ? 'inherit' : 'hidden';
|
|
271
|
+
ring.style.transform = `translateZ(${z0.toFixed(2)}px) scale(${(1 + 0.32 * out(r)).toFixed(4)})`;
|
|
272
|
+
ring.style.opacity = ((1 - r) * (1 - r) * 0.9).toFixed(3);
|
|
273
|
+
},
|
|
274
|
+
};
|
|
275
|
+
},
|
|
276
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// rig/orbit-ring, combined with texture/depth-fade as its entry asks.
|
|
2
|
+
// See library/primitives/rig/orbit-ring.md and texture/depth-fade.md.
|
|
3
|
+
import { list, num } from "../types.js";
|
|
4
|
+
const LOOKS = ['inverse', 'plain', 'accent', 'tint'];
|
|
5
|
+
export const orbitRing = {
|
|
6
|
+
slug: 'rig/orbit-ring',
|
|
7
|
+
summary: 'Tiles on a tilted ring that rotates forever.',
|
|
8
|
+
props: { items: { type: 'string[]', default: [], label: 'Tile labels. Repeated to fill the ring; empty tiles when left out.' } },
|
|
9
|
+
params: {
|
|
10
|
+
tiles: { type: 'number', default: 12, min: 8, max: 16, step: 1, unit: 'tiles', label: 'Tiles' },
|
|
11
|
+
tilt_x: { type: 'number', default: 25, min: 15, max: 35, step: 1, unit: 'deg', label: 'Pitch', pad: { name: 'tilt', axis: 'y' } },
|
|
12
|
+
tilt_z: { type: 'number', default: -20, min: -30, max: -10, step: 1, unit: 'deg', label: 'Roll', pad: { name: 'tilt', axis: 'x' } },
|
|
13
|
+
period: { type: 'number', default: 15, min: 12, max: 18, step: 0.5, unit: 's', label: 'Time for one turn' },
|
|
14
|
+
min_opacity: { type: 'number', default: 0.4, min: 0.3, max: 0.6, step: 0.01, unit: 'ratio', label: 'Opacity of tiles facing away', from: 'texture/depth-fade' },
|
|
15
|
+
radius: { type: 'number', default: 24, min: 14, max: 34, step: 0.5, unit: '% of stage width', label: 'Ring radius' },
|
|
16
|
+
tile: { type: 'number', default: 11, min: 6, max: 16, step: 0.5, unit: '% of stage width', label: 'Tile size' },
|
|
17
|
+
},
|
|
18
|
+
// Ambient: it turns for as long as its scene. A scene `period` seconds long loops without a seam.
|
|
19
|
+
duration: () => 0,
|
|
20
|
+
build(el, props, p, ctx) {
|
|
21
|
+
const [W] = ctx.size, u = W / 100;
|
|
22
|
+
const count = Math.max(1, Math.round(num(p.tiles))), labels = list(props.items);
|
|
23
|
+
const radius = num(p.radius) * u, size = num(p.tile) * u, floor = num(p.min_opacity);
|
|
24
|
+
const period = Math.max(0.1, num(p.period));
|
|
25
|
+
// The layer is a full-stage camera; the ring hangs in the middle of it.
|
|
26
|
+
el.style.cssText += `;position:absolute;inset:0;max-width:none;perspective:${120 * u}px;perspective-origin:50% 42%`;
|
|
27
|
+
const ring = document.createElement('div');
|
|
28
|
+
ring.style.cssText = `position:absolute;left:50%;top:47%;width:0;height:0;transform-style:preserve-3d;transform:rotateX(${-num(p.tilt_x)}deg) rotateZ(${num(p.tilt_z)}deg)`;
|
|
29
|
+
const tiles = Array.from({ length: count }, (_, i) => {
|
|
30
|
+
const t = document.createElement('div');
|
|
31
|
+
const label = labels.length ? labels[i % labels.length] : '';
|
|
32
|
+
const look = LOOKS[i % LOOKS.length];
|
|
33
|
+
const long = [...label].length > 3;
|
|
34
|
+
const colours = look === 'inverse' ? 'background:var(--m-bg-inverse);color:var(--m-text-inverse)'
|
|
35
|
+
: look === 'accent' ? 'background:var(--m-bg-accent);color:var(--m-text-on-accent)'
|
|
36
|
+
: look === 'tint' ? 'background:color-mix(in srgb, var(--m-bg-accent) 24%, var(--m-bg-base));color:var(--m-accent)'
|
|
37
|
+
: 'background:var(--m-bg-surface);color:var(--m-text-primary)';
|
|
38
|
+
t.textContent = label;
|
|
39
|
+
t.style.cssText = `position:absolute;left:${-size / 2}px;top:${-size / 2}px;width:${size}px;height:${size}px;border-radius:${size * 0.12}px;display:grid;place-items:center;overflow:hidden;` +
|
|
40
|
+
`font:${long ? `500 ${size * 0.14}px var(--m-font-mono)` : `600 ${size * 0.4}px var(--m-font-display)`};letter-spacing:${long ? '0' : '-0.03em'};${colours}`;
|
|
41
|
+
ring.appendChild(t);
|
|
42
|
+
return t;
|
|
43
|
+
});
|
|
44
|
+
el.appendChild(ring);
|
|
45
|
+
return {
|
|
46
|
+
seek(t) {
|
|
47
|
+
const turn = (t / period) * 360;
|
|
48
|
+
tiles.forEach((tile, i) => {
|
|
49
|
+
const angle = (i * 360) / count + turn;
|
|
50
|
+
// 1 when the tile faces the camera, 0 when it faces away.
|
|
51
|
+
const facing = (Math.cos((angle * Math.PI) / 180) + 1) / 2;
|
|
52
|
+
tile.style.transform = `rotateY(${angle}deg) translateZ(${radius}px)`;
|
|
53
|
+
tile.style.opacity = String(floor + (1 - floor) * facing);
|
|
54
|
+
tile.style.filter = facing < 0.999 ? `saturate(${0.35 + 0.65 * facing})` : '';
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Primitive } from '../types.ts';
|
|
2
|
+
/** Tab indices (0-based) open at the start and at the end. `to` 0 means the last tab. */
|
|
3
|
+
export declare function openRange(props: Record<string, unknown>): [number, number];
|
|
4
|
+
/**
|
|
5
|
+
* How open each of `n` tabs is (0–1) when the slide is at position `c`
|
|
6
|
+
* (0 = the first tab fully open). The shares always add up to one.
|
|
7
|
+
*/
|
|
8
|
+
export declare function openness(n: number, c: number): number[];
|
|
9
|
+
export declare const tabStack: Primitive;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
// rig/tab-stack. See library/primitives/rig/tab-stack.md.
|
|
2
|
+
//
|
|
3
|
+
// A list of tabs, stacked as stairs in depth: each tab stands a step nearer the
|
|
4
|
+
// camera than the one before it. The open state slides through the list as one
|
|
5
|
+
// continuous move: each tab's openness is its distance from the slide's
|
|
6
|
+
// position, so exactly one tab's worth of height is shared between neighbours
|
|
7
|
+
// at any instant and the list keeps its length. Each tab cross-fades between its
|
|
8
|
+
// closed and open look instead of switching in one frame. The tab that ends open
|
|
9
|
+
// pops a step further forward. Seen by the rigs' shared camera (./camera.ts).
|
|
10
|
+
import { clamp, lerp } from "../../core/ease.js";
|
|
11
|
+
import { list, num } from "../types.js";
|
|
12
|
+
import { cameraAt, cameraEnd, cameraParams, cameraTransform } from "./camera.js";
|
|
13
|
+
const hairline = (pct) => `color-mix(in srgb, var(--m-text-primary) ${pct}%, transparent)`;
|
|
14
|
+
const sine = (x) => (1 - Math.cos(Math.PI * clamp(x))) / 2;
|
|
15
|
+
/** Tab indices (0-based) open at the start and at the end. `to` 0 means the last tab. */
|
|
16
|
+
export function openRange(props) {
|
|
17
|
+
const n = list(props.items).length, last = Math.max(0, n - 1);
|
|
18
|
+
const pick = (v, fallback) => (typeof v === 'number' && v >= 1 ? Math.min(last, Math.round(v) - 1) : fallback);
|
|
19
|
+
return [pick(props.from, 0), pick(props.to, last)];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* How open each of `n` tabs is (0–1) when the slide is at position `c`
|
|
23
|
+
* (0 = the first tab fully open). The shares always add up to one.
|
|
24
|
+
*/
|
|
25
|
+
export function openness(n, c) {
|
|
26
|
+
return Array.from({ length: n }, (_, i) => Math.max(0, 1 - Math.abs(c - i)));
|
|
27
|
+
}
|
|
28
|
+
export const tabStack = {
|
|
29
|
+
slug: 'rig/tab-stack',
|
|
30
|
+
summary: 'Tabs stacked as stairs in depth; the open tab slides through them, then pops forward.',
|
|
31
|
+
props: {
|
|
32
|
+
items: { type: 'string[]', required: true, label: 'Tab titles, in order' },
|
|
33
|
+
details: { type: 'string[]', default: [], label: 'What each tab shows when open, in the same order' },
|
|
34
|
+
from: { type: 'number', default: 1, label: 'Tab open at the start (1 is the first)' },
|
|
35
|
+
to: { type: 'number', default: 0, label: 'Tab open at the end (0 is the last)' },
|
|
36
|
+
},
|
|
37
|
+
params: {
|
|
38
|
+
width: { type: 'number', default: 64, min: 30, max: 100, step: 1, unit: '% of stage width', label: 'Width of the stack' },
|
|
39
|
+
stack: { type: 'number', default: 34, min: 0, max: 90, step: 1, unit: 'px', label: 'Height of each step towards the camera' },
|
|
40
|
+
slide_at: { type: 'number', default: 0.9, min: 0, max: 6, step: 0.05, unit: 's', label: 'When the open tab starts to slide' },
|
|
41
|
+
slide: { type: 'number', default: 1.6, min: 0.3, max: 5, step: 0.05, unit: 's', label: 'Time for the open tab to slide from first to last' },
|
|
42
|
+
pop: { type: 'number', default: 46, min: 0, max: 140, step: 1, unit: 'px', label: 'How far the tab that ends open pops forward' },
|
|
43
|
+
...cameraParams({ path: 'out', tilt: -19, pitch: 13, roll: -1.5, zoom: 0.9, move: 1.6 }),
|
|
44
|
+
},
|
|
45
|
+
duration: (props, p) => {
|
|
46
|
+
const [a, b] = openRange(props);
|
|
47
|
+
return Math.max(cameraEnd(p), a === b ? 0 : num(p.slide_at) + num(p.slide) + (num(p.pop) > 0 ? 0.7 : 0));
|
|
48
|
+
},
|
|
49
|
+
build(el, props, p, ctx) {
|
|
50
|
+
const doc = el.ownerDocument;
|
|
51
|
+
const [W] = ctx.size, u = W / 1080;
|
|
52
|
+
const items = list(props.items), details = list(props.details), n = items.length;
|
|
53
|
+
const [from, to] = openRange(props);
|
|
54
|
+
const w = (num(p.width) / 100) * W, pad = 18 * u, gap = 12 * u;
|
|
55
|
+
const Hc = 78 * u, Ho = Hc + 118 * u, R = 14 * u;
|
|
56
|
+
const H = n * Hc + (n > 0 ? Ho - Hc : 0) + Math.max(0, n - 1) * gap + 2 * pad;
|
|
57
|
+
const P = Math.max(w, H) * 2.4;
|
|
58
|
+
const wrap = doc.createElement('div');
|
|
59
|
+
wrap.style.cssText = `position:relative;width:${w}px;height:${H}px;perspective:${P}px;text-align:left`;
|
|
60
|
+
const world = doc.createElement('div');
|
|
61
|
+
world.style.cssText = 'position:absolute;inset:0;transform-style:preserve-3d;transform-origin:50% 50%';
|
|
62
|
+
// The ground the stairs stand on.
|
|
63
|
+
const ground = doc.createElement('div');
|
|
64
|
+
ground.style.cssText = `position:absolute;inset:0;border-radius:${R + pad}px;background:var(--m-bg-sunken);`
|
|
65
|
+
+ `box-shadow:0 0 0 1px ${hairline(9)},0 ${60 * u}px ${120 * u}px rgba(0,0,0,.55)`;
|
|
66
|
+
world.appendChild(ground);
|
|
67
|
+
const font = 'var(--m-font-body)';
|
|
68
|
+
const tabs = items.map((title, i) => {
|
|
69
|
+
const card = doc.createElement('div');
|
|
70
|
+
card.style.cssText = `position:absolute;left:${pad}px;width:${w - 2 * pad}px;overflow:hidden;border-radius:${R}px;background:var(--m-bg-surface)`;
|
|
71
|
+
// Both looks share one title row, so a cross-fade only changes colour and detail, never position.
|
|
72
|
+
const row = (color, mark) => {
|
|
73
|
+
const r = doc.createElement('div');
|
|
74
|
+
r.style.cssText = `position:absolute;left:0;right:0;top:0;height:${Hc}px;display:flex;align-items:center;gap:${12 * u}px;padding:0 ${24 * u}px;`
|
|
75
|
+
+ `font:500 ${26 * u}px/1.2 ${font};color:${color};white-space:nowrap`;
|
|
76
|
+
const dot = doc.createElement('i');
|
|
77
|
+
dot.style.cssText = `display:block;flex:none;width:${10 * u}px;height:${10 * u}px;border-radius:50%;background:${mark}`;
|
|
78
|
+
const label = doc.createElement('span');
|
|
79
|
+
label.textContent = title;
|
|
80
|
+
label.style.flex = '1';
|
|
81
|
+
r.append(dot, label);
|
|
82
|
+
return r;
|
|
83
|
+
};
|
|
84
|
+
// Closed look: the title, quiet, with a plus.
|
|
85
|
+
const shut = row('var(--m-text-muted)', hairline(22));
|
|
86
|
+
const plus = doc.createElement('span');
|
|
87
|
+
plus.textContent = '+';
|
|
88
|
+
plus.style.cssText = `font-size:${28 * u}px;color:${hairline(40)}`;
|
|
89
|
+
shut.appendChild(plus);
|
|
90
|
+
// Open look: a tinted card, the accent mark, the detail, and a bar that fills while it is open.
|
|
91
|
+
const open = doc.createElement('div');
|
|
92
|
+
open.style.cssText = `position:absolute;inset:0;background:color-mix(in srgb, var(--m-accent) 9%, var(--m-bg-surface));`
|
|
93
|
+
+ `box-shadow:inset 0 0 0 1px color-mix(in srgb, var(--m-accent) 28%, transparent);border-radius:inherit`;
|
|
94
|
+
const head = row('var(--m-text-primary)', 'var(--m-accent)');
|
|
95
|
+
head.firstElementChild.style.boxShadow = `0 0 ${10 * u}px color-mix(in srgb, var(--m-accent) 60%, transparent)`;
|
|
96
|
+
const body = doc.createElement('p');
|
|
97
|
+
body.textContent = details[i] ?? '';
|
|
98
|
+
body.style.cssText = `position:absolute;left:${46 * u}px;right:${40 * u}px;top:${Hc - 14 * u}px;margin:0;font:400 ${21 * u}px/1.42 ${font};color:var(--m-text-secondary)`;
|
|
99
|
+
const bar = doc.createElement('div');
|
|
100
|
+
bar.style.cssText = `position:absolute;left:${24 * u}px;right:${24 * u}px;bottom:${16 * u}px;height:${2 * u}px;border-radius:9px;background:${hairline(10)};overflow:hidden`;
|
|
101
|
+
const fill = doc.createElement('div');
|
|
102
|
+
fill.style.cssText = 'height:100%;width:100%;background:var(--m-accent);transform-origin:0 50%';
|
|
103
|
+
bar.appendChild(fill);
|
|
104
|
+
open.append(head, body, bar);
|
|
105
|
+
card.append(shut, open);
|
|
106
|
+
world.appendChild(card);
|
|
107
|
+
return { card, open, fill };
|
|
108
|
+
});
|
|
109
|
+
wrap.appendChild(world);
|
|
110
|
+
el.appendChild(wrap);
|
|
111
|
+
const ease = ctx.ease(p.ease), pop = ctx.ease('expo.out');
|
|
112
|
+
const stack = num(p.stack) * u, popZ = num(p.pop) * u, slideAt = num(p.slide_at), slide = Math.max(0.01, num(p.slide));
|
|
113
|
+
return {
|
|
114
|
+
seek(t) {
|
|
115
|
+
world.style.transform = cameraTransform(cameraAt(t, p, ease), P, w, H);
|
|
116
|
+
// A sine ease: its top speed is 1.57× the average, so the middle tabs are not rushed.
|
|
117
|
+
const s = sine((t - slideAt) / slide);
|
|
118
|
+
const c = from === to ? from : lerp(from, to, s);
|
|
119
|
+
const open = openness(n, c);
|
|
120
|
+
const popped = from === to ? 0 : pop(clamp((t - slideAt - slide) / 0.7));
|
|
121
|
+
let y = pad;
|
|
122
|
+
tabs.forEach((tab, i) => {
|
|
123
|
+
const a = open[i];
|
|
124
|
+
const h = lerp(Hc, Ho, a);
|
|
125
|
+
// Stairs: each tab a step nearer than the one before; the last open one pops.
|
|
126
|
+
const z = stack * (i + 1) + (i === to ? popZ * popped : 0);
|
|
127
|
+
tab.card.style.top = `${y.toFixed(2)}px`;
|
|
128
|
+
tab.card.style.height = `${h.toFixed(2)}px`;
|
|
129
|
+
tab.card.style.transform = `translateZ(${z.toFixed(2)}px)`;
|
|
130
|
+
// Its shadow grows with its height above the step below.
|
|
131
|
+
const sh = clamp((stack + (i === to ? popZ * popped : 0)) / (60 * u));
|
|
132
|
+
tab.card.style.boxShadow = `0 0 0 1px ${hairline(8)},0 ${18 * u * sh}px ${40 * u * sh}px rgba(0,0,0,${(0.45 * sh).toFixed(3)})`;
|
|
133
|
+
// Never a switch in one frame: the open look fades in over the first fifth of the opening.
|
|
134
|
+
const mix = clamp(a / 0.2);
|
|
135
|
+
tab.open.style.opacity = (mix * mix * (3 - 2 * mix)).toFixed(3);
|
|
136
|
+
tab.open.style.visibility = a > 0 ? 'inherit' : 'hidden';
|
|
137
|
+
tab.fill.style.transform = `scaleX(${a.toFixed(4)})`;
|
|
138
|
+
y += h + gap;
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
},
|
|
143
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// scene/bar-chart. See library/primitives/scene/bar-chart.md.
|
|
2
|
+
import { progress } from "../../core/ease.js";
|
|
3
|
+
import { staggerDelays } from "../../core/stagger.js";
|
|
4
|
+
import { list, num, nums, str } from "../types.js";
|
|
5
|
+
const fmt = (v, decimals) => v.toFixed(decimals);
|
|
6
|
+
export const barChart = {
|
|
7
|
+
slug: 'scene/bar-chart',
|
|
8
|
+
summary: 'Bars grow from the baseline one after another, each value counting up with it.',
|
|
9
|
+
props: {
|
|
10
|
+
values: { type: 'number[]', required: true, label: 'Bar values' },
|
|
11
|
+
labels: { type: 'string[]', default: [], label: 'Bar labels, in the same order' },
|
|
12
|
+
highlight: { type: 'string', default: '', label: 'Label of the one bar set in the accent' },
|
|
13
|
+
suffix: { type: 'string', default: '', label: 'Text after each value, e.g. %' },
|
|
14
|
+
decimals: { type: 'number', default: 0, label: 'Decimal places' },
|
|
15
|
+
},
|
|
16
|
+
params: {
|
|
17
|
+
grow: { type: 'number', default: 0.9, min: 0.5, max: 1.4, step: 0.05, unit: 's', label: 'Time for one bar to grow' },
|
|
18
|
+
stagger: { type: 'number', default: 0.07, min: 0.03, max: 0.15, step: 0.005, unit: 's', label: 'Delay between bars' },
|
|
19
|
+
orientation: { type: 'choice', default: 'vertical', options: ['vertical', 'horizontal'], label: 'Bars stand or lie' },
|
|
20
|
+
width: { type: 'number', default: 64, min: 30, max: 90, step: 1, unit: '% of stage width', label: 'Chart width' },
|
|
21
|
+
height: { type: 'number', default: 46, min: 20, max: 75, step: 1, unit: '% of stage height', label: 'Chart height' },
|
|
22
|
+
},
|
|
23
|
+
// The baseline draws first (0.4 s), then the bars.
|
|
24
|
+
duration: (props, p) => 0.4 + Math.max(0, nums(props.values).length - 1) * num(p.stagger) + num(p.grow),
|
|
25
|
+
build(el, props, p, ctx) {
|
|
26
|
+
const doc = el.ownerDocument;
|
|
27
|
+
const values = nums(props.values), labels = list(props.labels), hi = str(props.highlight);
|
|
28
|
+
const decimals = Math.max(0, Math.round(num(props.decimals))), suffix = str(props.suffix);
|
|
29
|
+
const [W, H] = ctx.size, cw = (num(p.width) / 100) * W, ch = (num(p.height) / 100) * H;
|
|
30
|
+
const horizontal = p.orientation === 'horizontal';
|
|
31
|
+
const max = Math.max(...values.map(Math.abs), 1e-9);
|
|
32
|
+
const n = values.length, gapShare = 0.32;
|
|
33
|
+
el.style.cssText += `;position:relative;width:${cw}px;height:${ch}px;font-variant-numeric:tabular-nums`;
|
|
34
|
+
const base = doc.createElement('div');
|
|
35
|
+
base.style.cssText = `position:absolute;background:var(--m-border);${horizontal ? `left:0;top:0;bottom:0;width:2px;transform-origin:50% 0` : `left:0;right:0;bottom:0;height:2px;transform-origin:0 50%`}`;
|
|
36
|
+
el.appendChild(base);
|
|
37
|
+
const bars = values.map((v, i) => {
|
|
38
|
+
const slot = (horizontal ? ch : cw) / n, thick = slot * (1 - gapShare), pos = i * slot + (slot * gapShare) / 2;
|
|
39
|
+
const isHi = hi !== '' && labels[i] === hi;
|
|
40
|
+
const bar = doc.createElement('div');
|
|
41
|
+
const colour = hi === '' || isHi ? 'var(--m-bg-accent)' : 'color-mix(in srgb, var(--m-text-primary) 18%, var(--m-bg-base))';
|
|
42
|
+
bar.style.cssText = horizontal
|
|
43
|
+
? `position:absolute;left:2px;top:${pos}px;height:${thick}px;width:${(Math.abs(v) / max) * (cw - 160)}px;transform-origin:0 50%;border-radius:0 ${thick * 0.12}px ${thick * 0.12}px 0;background:${colour}`
|
|
44
|
+
: `position:absolute;bottom:2px;left:${pos}px;width:${thick}px;height:${(Math.abs(v) / max) * (ch - 70)}px;transform-origin:50% 100%;border-radius:${thick * 0.1}px ${thick * 0.1}px 0 0;background:${colour}`;
|
|
45
|
+
const value = doc.createElement('div');
|
|
46
|
+
value.style.cssText = horizontal
|
|
47
|
+
? `position:absolute;top:${pos + thick / 2}px;transform:translateY(-50%);font-size:0.62em;font-weight:600;white-space:nowrap`
|
|
48
|
+
: `position:absolute;left:${pos + thick / 2}px;width:${slot}px;margin-left:${-slot / 2}px;text-align:center;font-size:0.62em;font-weight:600;white-space:nowrap`;
|
|
49
|
+
if (isHi)
|
|
50
|
+
value.style.color = 'var(--m-accent)';
|
|
51
|
+
const label = doc.createElement('div');
|
|
52
|
+
label.textContent = labels[i] ?? '';
|
|
53
|
+
label.style.cssText = horizontal
|
|
54
|
+
? `position:absolute;right:calc(100% + 0.8em);top:${pos + thick / 2}px;transform:translateY(-50%);font-size:0.5em;color:var(--m-text-muted);white-space:nowrap`
|
|
55
|
+
: `position:absolute;top:calc(100% + 0.7em);left:${pos}px;width:${thick}px;text-align:center;font-size:0.5em;color:var(--m-text-muted);white-space:nowrap`;
|
|
56
|
+
el.append(bar, value, label);
|
|
57
|
+
const full = horizontal ? parseFloat(bar.style.width) : parseFloat(bar.style.height);
|
|
58
|
+
return { bar, value, label, v, full };
|
|
59
|
+
});
|
|
60
|
+
const delays = staggerDelays(n, num(p.stagger));
|
|
61
|
+
const grow = num(p.grow), ease = ctx.ease('quint.out'), line = ctx.ease('quart.inOut');
|
|
62
|
+
return {
|
|
63
|
+
seek(t) {
|
|
64
|
+
const b = progress(t, 0, 0.5, line);
|
|
65
|
+
base.style.transform = horizontal ? `scaleY(${b})` : `scaleX(${b})`;
|
|
66
|
+
bars.forEach((x, i) => {
|
|
67
|
+
const k = progress(t, 0.4 + delays[i], grow, ease);
|
|
68
|
+
x.bar.style.transform = horizontal ? `scaleX(${k})` : `scaleY(${k})`;
|
|
69
|
+
// The value rides the top of its bar, on the same curve, and lands exactly.
|
|
70
|
+
const shown = t >= 0.4 + delays[i] + grow ? x.v : x.v * k;
|
|
71
|
+
x.value.textContent = `${fmt(shown, decimals)}${suffix}`;
|
|
72
|
+
const fade = Math.min(1, Math.max(0, (t - 0.4 - delays[i]) / 0.25));
|
|
73
|
+
x.value.style.opacity = fade.toFixed(3);
|
|
74
|
+
if (horizontal)
|
|
75
|
+
x.value.style.left = `${2 + x.full * k + 12}px`;
|
|
76
|
+
else
|
|
77
|
+
x.value.style.bottom = `${2 + x.full * k + 10}px`;
|
|
78
|
+
x.label.style.opacity = Math.min(1, Math.max(0, (t - delays[i] * 0.5) / 0.4)).toFixed(3);
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
};
|