@motionscript/core 0.1.0-alpha.5 → 0.1.0-alpha.7
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/CHANGELOG.md +55 -0
- package/README.md +2 -4
- package/dist/assets/errors.js +4 -5
- package/dist/assets/errors.js.map +1 -1
- package/dist/assets/scope.d.ts +1 -1
- package/dist/assets/scope.d.ts.map +1 -1
- package/dist/assets/scope.js +1 -1
- package/dist/assets/scope.js.map +1 -1
- package/dist/attributes/audio/schedule.d.ts +3 -18
- package/dist/attributes/audio/schedule.d.ts.map +1 -1
- package/dist/attributes/audio/schedule.js.map +1 -1
- package/dist/attributes/index.d.ts +3 -5
- package/dist/attributes/index.d.ts.map +1 -1
- package/dist/attributes/index.js +2 -2
- package/dist/attributes/index.js.map +1 -1
- package/dist/attributes/layout/insets.d.ts +1 -1
- package/dist/attributes/layout/insets.js.map +1 -1
- package/dist/attributes/layout/size.d.ts +1 -1
- package/dist/attributes/layout/size.js +1 -1
- package/dist/attributes/layout/size.js.map +1 -1
- package/dist/attributes/properties/decorator.d.ts +44 -11
- package/dist/attributes/properties/decorator.d.ts.map +1 -1
- package/dist/attributes/properties/decorator.js +37 -9
- package/dist/attributes/properties/decorator.js.map +1 -1
- package/dist/attributes/properties/inputs.d.ts +1 -1
- package/dist/attributes/properties/inputs.js +1 -1
- package/dist/attributes/properties/inputs.js.map +1 -1
- package/dist/attributes/properties/typed.d.ts +19 -140
- package/dist/attributes/properties/typed.d.ts.map +1 -1
- package/dist/attributes/properties/typed.js +12 -108
- package/dist/attributes/properties/typed.js.map +1 -1
- package/dist/attributes/shape/corners/corner-radius.d.ts +1 -1
- package/dist/attributes/shape/corners/corner-radius.js +1 -1
- package/dist/attributes/shape/corners/corner-radius.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/drop-shadow.d.ts +1 -1
- package/dist/attributes/shape/effects/implementations/drop-shadow.js.map +1 -1
- package/dist/attributes/shape/fill/color/parser.d.ts +1 -1
- package/dist/attributes/shape/fill/color/parser.js +1 -1
- package/dist/attributes/shape/fill/color/parser.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/canvas3d.d.ts +2 -2
- package/dist/attributes/shape/fill/implementations/canvas3d.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/shader.d.ts +2 -2
- package/dist/attributes/shape/fill/implementations/shader.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/video.d.ts +1 -1
- package/dist/attributes/shape/fill/implementations/video.js +1 -1
- package/dist/attributes/shape/fill/implementations/video.js.map +1 -1
- package/dist/attributes/shape/fill/lerp.d.ts +1 -1
- package/dist/attributes/shape/fill/lerp.js.map +1 -1
- package/dist/attributes/shape/filters/chain.d.ts +1 -1
- package/dist/attributes/shape/filters/chain.js +1 -1
- package/dist/attributes/shape/filters/chain.js.map +1 -1
- package/dist/attributes/shape/filters/union.d.ts +4 -3
- package/dist/attributes/shape/filters/union.d.ts.map +1 -1
- package/dist/attributes/shape/filters/union.js.map +1 -1
- package/dist/attributes/shape/path/ops.d.ts +1 -2
- package/dist/attributes/shape/path/ops.d.ts.map +1 -1
- package/dist/attributes/shape/path/ops.js.map +1 -1
- package/dist/attributes/shared/operators.d.ts +2 -2
- package/dist/attributes/shared/operators.js.map +1 -1
- package/dist/attributes/text/types.d.ts +2 -3
- package/dist/attributes/text/types.d.ts.map +1 -1
- package/dist/attributes/text/types.js.map +1 -1
- package/dist/browser/chunks/chunk-D4FSTPML.js +14 -0
- package/dist/browser/chunks/chunk-D4FSTPML.js.map +7 -0
- package/dist/browser/chunks/chunk-LKUYVFU3.js +2 -0
- package/dist/browser/chunks/chunk-LKUYVFU3.js.map +7 -0
- package/dist/browser/chunks/chunk-RTNATFWX.js +5 -0
- package/dist/browser/chunks/chunk-RTNATFWX.js.map +7 -0
- package/dist/browser/chunks/chunk-ZRPZPWZU.js +3 -0
- package/dist/browser/chunks/chunk-ZRPZPWZU.js.map +7 -0
- package/dist/browser/component.js +1 -1
- package/dist/browser/component.js.map +4 -4
- package/dist/browser/experimental.js +2 -0
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +4 -4
- package/dist/browser/manifest.json +3 -4
- package/dist/browser/sdk.js +1 -1
- package/dist/component/api.d.ts +508 -0
- package/dist/component/api.d.ts.map +1 -0
- package/dist/component/api.js +4 -0
- package/dist/component/api.js.map +1 -0
- package/dist/component/builtins/audio.d.ts +26 -0
- package/dist/component/builtins/audio.d.ts.map +1 -0
- package/dist/component/builtins/audio.js +41 -0
- package/dist/component/builtins/audio.js.map +1 -0
- package/dist/component/builtins/canvas3d.d.ts +98 -0
- package/dist/component/builtins/canvas3d.d.ts.map +1 -0
- package/dist/component/builtins/canvas3d.js +21 -0
- package/dist/component/builtins/canvas3d.js.map +1 -0
- package/dist/component/builtins/composite.d.ts +56 -0
- package/dist/component/builtins/composite.d.ts.map +1 -0
- package/dist/component/builtins/composite.js +25 -0
- package/dist/component/builtins/composite.js.map +1 -0
- package/dist/component/builtins/geometry.d.ts +505 -0
- package/dist/component/builtins/geometry.d.ts.map +1 -0
- package/dist/component/builtins/geometry.js +107 -0
- package/dist/component/builtins/geometry.js.map +1 -0
- package/dist/component/builtins/layout.d.ts +88 -0
- package/dist/component/builtins/layout.d.ts.map +1 -0
- package/dist/component/builtins/layout.js +84 -0
- package/dist/component/builtins/layout.js.map +1 -0
- package/dist/component/builtins/media.d.ts +95 -0
- package/dist/component/builtins/media.d.ts.map +1 -0
- package/dist/component/builtins/media.js +149 -0
- package/dist/component/builtins/media.js.map +1 -0
- package/dist/component/builtins/providers.d.ts +23 -0
- package/dist/component/builtins/providers.d.ts.map +1 -0
- package/dist/component/builtins/providers.js +30 -0
- package/dist/component/builtins/providers.js.map +1 -0
- package/dist/component/builtins/text.d.ts +193 -0
- package/dist/component/builtins/text.d.ts.map +1 -0
- package/dist/component/builtins/text.js +113 -0
- package/dist/component/builtins/text.js.map +1 -0
- package/dist/component/builtins/three.d.ts +1085 -0
- package/dist/component/builtins/three.d.ts.map +1 -0
- package/dist/component/builtins/three.js +265 -0
- package/dist/component/builtins/three.js.map +1 -0
- package/dist/component/clip-of.d.ts +5 -0
- package/dist/component/clip-of.d.ts.map +1 -0
- package/dist/component/clip-of.js +33 -0
- package/dist/component/clip-of.js.map +1 -0
- package/dist/component/commands-for.d.ts +19 -0
- package/dist/component/commands-for.d.ts.map +1 -0
- package/dist/component/commands-for.js +5 -0
- package/dist/component/commands-for.js.map +1 -0
- package/dist/component/component-audio.d.ts +9 -0
- package/dist/component/component-audio.d.ts.map +1 -0
- package/dist/component/component-audio.js +18 -0
- package/dist/component/component-audio.js.map +1 -0
- package/dist/component/component2d.d.ts +9 -0
- package/dist/component/component2d.d.ts.map +1 -0
- package/dist/component/component2d.js +239 -0
- package/dist/component/component2d.js.map +1 -0
- package/dist/component/component3d.d.ts +9 -0
- package/dist/component/component3d.d.ts.map +1 -0
- package/dist/component/component3d.js +99 -0
- package/dist/component/component3d.js.map +1 -0
- package/dist/component/factory.d.ts +63 -0
- package/dist/component/factory.d.ts.map +1 -0
- package/dist/component/factory.js +313 -0
- package/dist/component/factory.js.map +1 -0
- package/dist/component/modules/aim.d.ts +30 -0
- package/dist/component/modules/aim.d.ts.map +1 -0
- package/dist/component/modules/aim.js +39 -0
- package/dist/component/modules/aim.js.map +1 -0
- package/dist/component/modules/corners.d.ts +13 -0
- package/dist/component/modules/corners.d.ts.map +1 -0
- package/dist/component/modules/corners.js +12 -0
- package/dist/component/modules/corners.js.map +1 -0
- package/dist/component/modules/flow.d.ts +26 -0
- package/dist/component/modules/flow.d.ts.map +1 -0
- package/dist/component/modules/flow.js +55 -0
- package/dist/component/modules/flow.js.map +1 -0
- package/dist/component/modules/material.d.ts +40 -0
- package/dist/component/modules/material.d.ts.map +1 -0
- package/dist/component/modules/material.js +75 -0
- package/dist/component/modules/material.js.map +1 -0
- package/dist/component/modules/paint.d.ts +71 -0
- package/dist/component/modules/paint.d.ts.map +1 -0
- package/dist/component/modules/paint.js +106 -0
- package/dist/component/modules/paint.js.map +1 -0
- package/dist/component/modules/shapes.d.ts +31 -0
- package/dist/component/modules/shapes.d.ts.map +1 -0
- package/dist/component/modules/shapes.js +43 -0
- package/dist/component/modules/shapes.js.map +1 -0
- package/dist/component/modules/text-layout.d.ts +26 -0
- package/dist/component/modules/text-layout.d.ts.map +1 -0
- package/dist/component/modules/text-layout.js +57 -0
- package/dist/component/modules/text-layout.js.map +1 -0
- package/dist/component/modules/text-style.d.ts +48 -0
- package/dist/component/modules/text-style.d.ts.map +1 -0
- package/dist/component/modules/text-style.js +63 -0
- package/dist/component/modules/text-style.js.map +1 -0
- package/dist/component/modules/three-entries.d.ts +23 -0
- package/dist/component/modules/three-entries.d.ts.map +1 -0
- package/dist/component/modules/three-entries.js +41 -0
- package/dist/component/modules/three-entries.js.map +1 -0
- package/dist/component/modules/view3d.d.ts +55 -0
- package/dist/component/modules/view3d.d.ts.map +1 -0
- package/dist/component/modules/view3d.js +160 -0
- package/dist/component/modules/view3d.js.map +1 -0
- package/dist/component/timeline.d.ts +22 -0
- package/dist/component/timeline.d.ts.map +1 -0
- package/dist/component/timeline.js +128 -0
- package/dist/component/timeline.js.map +1 -0
- package/dist/component/type-def.d.ts +26 -0
- package/dist/component/type-def.d.ts.map +1 -0
- package/dist/component/type-def.js +16 -0
- package/dist/component/type-def.js.map +1 -0
- package/dist/component/types.d.ts +91 -0
- package/dist/component/types.d.ts.map +1 -0
- package/dist/component/types.js +88 -0
- package/dist/component/types.js.map +1 -0
- package/dist/component/views.d.ts +121 -0
- package/dist/component/views.d.ts.map +1 -0
- package/dist/component/views.js +413 -0
- package/dist/component/views.js.map +1 -0
- package/dist/component.d.ts +10 -19
- package/dist/component.d.ts.map +1 -1
- package/dist/component.js +10 -19
- package/dist/component.js.map +1 -1
- package/dist/components/builtins/audio/audio.d.ts +53 -0
- package/dist/components/builtins/audio/audio.d.ts.map +1 -0
- package/dist/components/builtins/audio/audio.js +41 -0
- package/dist/components/builtins/audio/audio.js.map +1 -0
- package/dist/components/builtins/geometry/composite.d.ts +93 -0
- package/dist/components/builtins/geometry/composite.d.ts.map +1 -0
- package/dist/components/builtins/geometry/composite.js +25 -0
- package/dist/components/builtins/geometry/composite.js.map +1 -0
- package/dist/components/builtins/geometry/geometry.d.ts +921 -0
- package/dist/components/builtins/geometry/geometry.d.ts.map +1 -0
- package/dist/components/builtins/geometry/geometry.js +107 -0
- package/dist/components/builtins/geometry/geometry.js.map +1 -0
- package/dist/components/builtins/geometry/shape-outline.d.ts +93 -0
- package/dist/components/builtins/geometry/shape-outline.d.ts.map +1 -0
- package/dist/components/builtins/geometry/shape-outline.js +470 -0
- package/dist/components/builtins/geometry/shape-outline.js.map +1 -0
- package/dist/components/builtins/layout/layout.d.ts +186 -0
- package/dist/components/builtins/layout/layout.d.ts.map +1 -0
- package/dist/components/builtins/layout/layout.js +84 -0
- package/dist/components/builtins/layout/layout.js.map +1 -0
- package/dist/components/builtins/media/media.d.ts +240 -0
- package/dist/components/builtins/media/media.d.ts.map +1 -0
- package/dist/components/builtins/media/media.js +149 -0
- package/dist/components/builtins/media/media.js.map +1 -0
- package/dist/components/builtins/providers/providers.d.ts +47 -0
- package/dist/components/builtins/providers/providers.d.ts.map +1 -0
- package/dist/components/builtins/providers/providers.js +30 -0
- package/dist/components/builtins/providers/providers.js.map +1 -0
- package/dist/components/builtins/text/number-format.d.ts +66 -0
- package/dist/components/builtins/text/number-format.d.ts.map +1 -0
- package/dist/components/builtins/text/number-format.js +227 -0
- package/dist/components/builtins/text/number-format.js.map +1 -0
- package/dist/components/builtins/text/number-pattern.d.ts +51 -0
- package/dist/components/builtins/text/number-pattern.d.ts.map +1 -0
- package/dist/components/builtins/text/number-pattern.js +77 -0
- package/dist/components/builtins/text/number-pattern.js.map +1 -0
- package/dist/components/builtins/text/text-defaults.d.ts +32 -0
- package/dist/components/builtins/text/text-defaults.d.ts.map +1 -0
- package/dist/components/builtins/text/text-defaults.js +37 -0
- package/dist/components/builtins/text/text-defaults.js.map +1 -0
- package/dist/components/builtins/text/text-layout.d.ts +82 -0
- package/dist/components/builtins/text/text-layout.d.ts.map +1 -0
- package/dist/components/builtins/text/text-layout.js +331 -0
- package/dist/components/builtins/text/text-layout.js.map +1 -0
- package/dist/components/builtins/text/text.d.ts +409 -0
- package/dist/components/builtins/text/text.d.ts.map +1 -0
- package/dist/components/builtins/text/text.js +113 -0
- package/dist/components/builtins/text/text.js.map +1 -0
- package/dist/components/builtins/three/canvas3d.d.ts +245 -0
- package/dist/components/builtins/three/canvas3d.d.ts.map +1 -0
- package/dist/components/builtins/three/canvas3d.js +21 -0
- package/dist/components/builtins/three/canvas3d.js.map +1 -0
- package/dist/components/builtins/three/grid-geometry3d.d.ts +62 -0
- package/dist/components/builtins/three/grid-geometry3d.d.ts.map +1 -0
- package/dist/components/builtins/three/grid-geometry3d.js +114 -0
- package/dist/components/builtins/three/grid-geometry3d.js.map +1 -0
- package/dist/components/builtins/three/three.d.ts +1889 -0
- package/dist/components/builtins/three/three.d.ts.map +1 -0
- package/dist/components/builtins/three/three.js +305 -0
- package/dist/components/builtins/three/three.js.map +1 -0
- package/dist/components/factory/api.d.ts +516 -0
- package/dist/components/factory/api.d.ts.map +1 -0
- package/dist/components/factory/api.js +4 -0
- package/dist/components/factory/api.js.map +1 -0
- package/dist/components/factory/clip-of.d.ts +5 -0
- package/dist/components/factory/clip-of.d.ts.map +1 -0
- package/dist/components/factory/clip-of.js +33 -0
- package/dist/components/factory/clip-of.js.map +1 -0
- package/dist/components/factory/commands-for.d.ts +19 -0
- package/dist/components/factory/commands-for.d.ts.map +1 -0
- package/dist/components/factory/commands-for.js +5 -0
- package/dist/components/factory/commands-for.js.map +1 -0
- package/dist/components/factory/component-audio.d.ts +9 -0
- package/dist/components/factory/component-audio.d.ts.map +1 -0
- package/dist/components/factory/component-audio.js +18 -0
- package/dist/components/factory/component-audio.js.map +1 -0
- package/dist/components/factory/component2d.d.ts +8 -0
- package/dist/components/factory/component2d.d.ts.map +1 -0
- package/dist/components/factory/component2d.js +240 -0
- package/dist/components/factory/component2d.js.map +1 -0
- package/dist/components/factory/component3d.d.ts +9 -0
- package/dist/components/factory/component3d.d.ts.map +1 -0
- package/dist/components/factory/component3d.js +99 -0
- package/dist/components/factory/component3d.js.map +1 -0
- package/dist/components/factory/factory.d.ts +63 -0
- package/dist/components/factory/factory.d.ts.map +1 -0
- package/dist/components/factory/factory.js +313 -0
- package/dist/components/factory/factory.js.map +1 -0
- package/dist/components/factory/timeline.d.ts +22 -0
- package/dist/components/factory/timeline.d.ts.map +1 -0
- package/dist/components/factory/timeline.js +128 -0
- package/dist/components/factory/timeline.js.map +1 -0
- package/dist/components/factory/type-def.d.ts +26 -0
- package/dist/components/factory/type-def.d.ts.map +1 -0
- package/dist/components/factory/type-def.js +16 -0
- package/dist/components/factory/type-def.js.map +1 -0
- package/dist/components/factory/types.d.ts +91 -0
- package/dist/components/factory/types.d.ts.map +1 -0
- package/dist/components/factory/types.js +88 -0
- package/dist/components/factory/types.js.map +1 -0
- package/dist/components/factory/views.d.ts +121 -0
- package/dist/components/factory/views.d.ts.map +1 -0
- package/dist/components/factory/views.js +413 -0
- package/dist/components/factory/views.js.map +1 -0
- package/dist/components/modules/aim.d.ts +30 -0
- package/dist/components/modules/aim.d.ts.map +1 -0
- package/dist/components/modules/aim.js +39 -0
- package/dist/components/modules/aim.js.map +1 -0
- package/dist/components/modules/corners.d.ts +13 -0
- package/dist/components/modules/corners.d.ts.map +1 -0
- package/dist/components/modules/corners.js +12 -0
- package/dist/components/modules/corners.js.map +1 -0
- package/dist/components/modules/flow.d.ts +26 -0
- package/dist/components/modules/flow.d.ts.map +1 -0
- package/dist/components/modules/flow.js +57 -0
- package/dist/components/modules/flow.js.map +1 -0
- package/dist/components/modules/material.d.ts +40 -0
- package/dist/components/modules/material.d.ts.map +1 -0
- package/dist/components/modules/material.js +75 -0
- package/dist/components/modules/material.js.map +1 -0
- package/dist/components/modules/paint.d.ts +71 -0
- package/dist/components/modules/paint.d.ts.map +1 -0
- package/dist/components/modules/paint.js +106 -0
- package/dist/components/modules/paint.js.map +1 -0
- package/dist/components/modules/shapes.d.ts +31 -0
- package/dist/components/modules/shapes.d.ts.map +1 -0
- package/dist/components/modules/shapes.js +43 -0
- package/dist/components/modules/shapes.js.map +1 -0
- package/dist/components/modules/text-layout.d.ts +26 -0
- package/dist/components/modules/text-layout.d.ts.map +1 -0
- package/dist/components/modules/text-layout.js +57 -0
- package/dist/components/modules/text-layout.js.map +1 -0
- package/dist/components/modules/text-style.d.ts +48 -0
- package/dist/components/modules/text-style.d.ts.map +1 -0
- package/dist/components/modules/text-style.js +63 -0
- package/dist/components/modules/text-style.js.map +1 -0
- package/dist/components/modules/three-entries.d.ts +23 -0
- package/dist/components/modules/three-entries.d.ts.map +1 -0
- package/dist/components/modules/three-entries.js +41 -0
- package/dist/components/modules/three-entries.js.map +1 -0
- package/dist/components/modules/view3d.d.ts +59 -0
- package/dist/components/modules/view3d.d.ts.map +1 -0
- package/dist/components/modules/view3d.js +171 -0
- package/dist/components/modules/view3d.js.map +1 -0
- package/dist/components/trees/2d/group-bounds.d.ts +56 -0
- package/dist/components/trees/2d/group-bounds.d.ts.map +1 -0
- package/dist/components/trees/2d/group-bounds.js +87 -0
- package/dist/components/trees/2d/group-bounds.js.map +1 -0
- package/dist/components/trees/2d/node-lifecycle.d.ts +46 -0
- package/dist/components/trees/2d/node-lifecycle.d.ts.map +1 -0
- package/dist/components/trees/2d/node-lifecycle.js +264 -0
- package/dist/components/trees/2d/node-lifecycle.js.map +1 -0
- package/dist/components/trees/2d/node-motion.d.ts +56 -0
- package/dist/components/trees/2d/node-motion.d.ts.map +1 -0
- package/dist/components/trees/2d/node-motion.js +86 -0
- package/dist/components/trees/2d/node-motion.js.map +1 -0
- package/dist/components/trees/2d/node-render.d.ts +36 -0
- package/dist/components/trees/2d/node-render.d.ts.map +1 -0
- package/dist/components/trees/2d/node-render.js +67 -0
- package/dist/components/trees/2d/node-render.js.map +1 -0
- package/dist/components/trees/2d/node-space.d.ts +63 -0
- package/dist/components/trees/2d/node-space.d.ts.map +1 -0
- package/dist/components/trees/2d/node-space.js +131 -0
- package/dist/components/trees/2d/node-space.js.map +1 -0
- package/dist/components/trees/2d/node-transform.d.ts +55 -0
- package/dist/components/trees/2d/node-transform.d.ts.map +1 -0
- package/dist/components/trees/2d/node-transform.js +73 -0
- package/dist/components/trees/2d/node-transform.js.map +1 -0
- package/dist/components/trees/2d/node2d.d.ts +1020 -0
- package/dist/components/trees/2d/node2d.d.ts.map +1 -0
- package/dist/components/trees/2d/node2d.js +1481 -0
- package/dist/components/trees/2d/node2d.js.map +1 -0
- package/dist/components/trees/audio/index.d.ts +2 -0
- package/dist/components/trees/audio/index.d.ts.map +1 -0
- package/dist/components/trees/audio/index.js +2 -0
- package/dist/components/trees/audio/index.js.map +1 -0
- package/dist/components/trees/audio/node-audio.d.ts +109 -0
- package/dist/components/trees/audio/node-audio.d.ts.map +1 -0
- package/dist/components/trees/audio/node-audio.js +167 -0
- package/dist/components/trees/audio/node-audio.js.map +1 -0
- package/dist/components/trees/index.d.ts +10 -0
- package/dist/components/trees/index.d.ts.map +1 -0
- package/dist/components/trees/index.js +14 -0
- package/dist/components/trees/index.js.map +1 -0
- package/dist/components/trees/node/node-editor-state.d.ts +53 -0
- package/dist/components/trees/node/node-editor-state.d.ts.map +1 -0
- package/dist/components/trees/node/node-editor-state.js +23 -0
- package/dist/components/trees/node/node-editor-state.js.map +1 -0
- package/dist/components/trees/node/node-reactive.d.ts +89 -0
- package/dist/components/trees/node/node-reactive.d.ts.map +1 -0
- package/dist/components/trees/node/node-reactive.js +135 -0
- package/dist/components/trees/node/node-reactive.js.map +1 -0
- package/dist/components/trees/node/node-time.d.ts +39 -0
- package/dist/components/trees/node/node-time.d.ts.map +1 -0
- package/dist/components/trees/node/node-time.js +14 -0
- package/dist/components/trees/node/node-time.js.map +1 -0
- package/dist/components/trees/node/node-walk.d.ts +46 -0
- package/dist/components/trees/node/node-walk.d.ts.map +1 -0
- package/dist/components/trees/node/node-walk.js +74 -0
- package/dist/components/trees/node/node-walk.js.map +1 -0
- package/dist/components/trees/node/node.d.ts +401 -0
- package/dist/components/trees/node/node.d.ts.map +1 -0
- package/dist/components/trees/node/node.js +680 -0
- package/dist/components/trees/node/node.js.map +1 -0
- package/dist/components/trees/root/canvas2d-node.d.ts +163 -0
- package/dist/components/trees/root/canvas2d-node.d.ts.map +1 -0
- package/dist/components/trees/root/canvas2d-node.js +216 -0
- package/dist/components/trees/root/canvas2d-node.js.map +1 -0
- package/dist/components/trees/three/node3d.d.ts +222 -0
- package/dist/components/trees/three/node3d.d.ts.map +1 -0
- package/dist/components/trees/three/node3d.js +289 -0
- package/dist/components/trees/three/node3d.js.map +1 -0
- package/dist/document/audio.d.ts +9 -1
- package/dist/document/audio.d.ts.map +1 -1
- package/dist/document/audio.js +41 -0
- package/dist/document/audio.js.map +1 -1
- package/dist/document/builtins.d.ts.map +1 -1
- package/dist/document/builtins.js +13 -31
- package/dist/document/builtins.js.map +1 -1
- package/dist/document/command-traits.d.ts +2 -2
- package/dist/document/command-traits.js +4 -1
- package/dist/document/command-traits.js.map +1 -1
- package/dist/document/deny-globals.d.ts +2 -2
- package/dist/document/deny-globals.js +2 -2
- package/dist/document/deny-globals.js.map +1 -1
- package/dist/document/diff.d.ts.map +1 -1
- package/dist/document/diff.js +3 -3
- package/dist/document/diff.js.map +1 -1
- package/dist/document/doc-index.d.ts.map +1 -1
- package/dist/document/doc-index.js +3 -3
- package/dist/document/doc-index.js.map +1 -1
- package/dist/document/expression/index.d.ts +1 -1
- package/dist/document/expression/index.js +1 -1
- package/dist/document/expression/index.js.map +1 -1
- package/dist/document/expression/ops.js +1 -1
- package/dist/document/expression/ops.js.map +1 -1
- package/dist/document/index.d.ts +1 -2
- package/dist/document/index.d.ts.map +1 -1
- package/dist/document/index.js +1 -2
- package/dist/document/index.js.map +1 -1
- package/dist/document/node-decorator.d.ts +14 -10
- package/dist/document/node-decorator.d.ts.map +1 -1
- package/dist/document/node-decorator.js +14 -10
- package/dist/document/node-decorator.js.map +1 -1
- package/dist/document/node-descriptor.d.ts +9 -3
- package/dist/document/node-descriptor.d.ts.map +1 -1
- package/dist/document/node-descriptor.js.map +1 -1
- package/dist/document/placement.js +2 -2
- package/dist/document/placement.js.map +1 -1
- package/dist/document/registry.d.ts +29 -36
- package/dist/document/registry.d.ts.map +1 -1
- package/dist/document/registry.js +29 -35
- package/dist/document/registry.js.map +1 -1
- package/dist/document/settled-index.d.ts +49 -0
- package/dist/document/settled-index.d.ts.map +1 -0
- package/dist/document/settled-index.js +247 -0
- package/dist/document/settled-index.js.map +1 -0
- package/dist/document/timeline.d.ts +29 -3
- package/dist/document/timeline.d.ts.map +1 -1
- package/dist/document/timeline.js +99 -3
- package/dist/document/timeline.js.map +1 -1
- package/dist/document/types.d.ts +4 -4
- package/dist/document/types.js.map +1 -1
- package/dist/document/validate.d.ts +1 -1
- package/dist/document/validate.js.map +1 -1
- package/dist/experimental.d.ts +22 -0
- package/dist/experimental.d.ts.map +1 -0
- package/dist/experimental.js +20 -0
- package/dist/experimental.js.map +1 -0
- package/dist/index.d.ts +10 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/dist/layout/types.d.ts +1 -1
- package/dist/layout/types.js.map +1 -1
- package/dist/nodes/audio/index.d.ts +2 -2
- package/dist/nodes/audio/index.d.ts.map +1 -1
- package/dist/nodes/audio/index.js +0 -2
- package/dist/nodes/audio/index.js.map +1 -1
- package/dist/nodes/audio/sound-node.d.ts +2 -1
- package/dist/nodes/audio/sound-node.d.ts.map +1 -1
- package/dist/nodes/audio/sound-node.js +3 -0
- package/dist/nodes/audio/sound-node.js.map +1 -1
- package/dist/nodes/index.d.ts +39 -27
- package/dist/nodes/index.d.ts.map +1 -1
- package/dist/nodes/index.js +16 -30
- package/dist/nodes/index.js.map +1 -1
- package/dist/nodes/node/node.d.ts +7 -1
- package/dist/nodes/node/node.d.ts.map +1 -1
- package/dist/nodes/node/node.js +23 -8
- package/dist/nodes/node/node.js.map +1 -1
- package/dist/nodes/root/canvas2d-node.d.ts +2 -1
- package/dist/nodes/root/canvas2d-node.d.ts.map +1 -1
- package/dist/nodes/root/canvas2d-node.js +3 -0
- package/dist/nodes/root/canvas2d-node.js.map +1 -1
- package/dist/nodes/text/richtext-node.d.ts +0 -5
- package/dist/nodes/text/richtext-node.d.ts.map +1 -1
- package/dist/nodes/text/richtext-node.js +5 -71
- package/dist/nodes/text/richtext-node.js.map +1 -1
- package/dist/nodes/text/text-base.d.ts +5 -22
- package/dist/nodes/text/text-base.d.ts.map +1 -1
- package/dist/nodes/text/text-base.js +12 -363
- package/dist/nodes/text/text-base.js.map +1 -1
- package/dist/nodes/text/text-layout.d.ts +87 -0
- package/dist/nodes/text/text-layout.d.ts.map +1 -0
- package/dist/nodes/text/text-layout.js +368 -0
- package/dist/nodes/text/text-layout.js.map +1 -0
- package/dist/nodes/three/canvas3d-node.d.ts +3 -1
- package/dist/nodes/three/canvas3d-node.d.ts.map +1 -1
- package/dist/nodes/three/canvas3d-node.js +6 -0
- package/dist/nodes/three/canvas3d-node.js.map +1 -1
- package/dist/props/host.d.ts +1 -1
- package/dist/props/host.js.map +1 -1
- package/dist/props/slot.d.ts +1 -1
- package/dist/props/slot.js +1 -1
- package/dist/props/slot.js.map +1 -1
- package/dist/render/clip.d.ts +1 -1
- package/dist/render/clip.js +1 -1
- package/dist/render/clip.js.map +1 -1
- package/dist/render/descriptors/rect.js.map +1 -1
- package/dist/render/descriptors/text.d.ts +11 -5
- package/dist/render/descriptors/text.d.ts.map +1 -1
- package/dist/render/descriptors/text.js +7 -1
- package/dist/render/descriptors/text.js.map +1 -1
- package/dist/render/render-context2d.d.ts +2 -2
- package/dist/render/render-context2d.js.map +1 -1
- package/dist/render3d/builders.d.ts +1 -1
- package/dist/render3d/builders.js +1 -1
- package/dist/render3d/builders.js.map +1 -1
- package/dist/render3d/graphics3d.d.ts +13 -19
- package/dist/render3d/graphics3d.d.ts.map +1 -1
- package/dist/render3d/graphics3d.js +13 -19
- package/dist/render3d/graphics3d.js.map +1 -1
- package/dist/render3d/scene3d.d.ts +1 -1
- package/dist/render3d/scene3d.js +1 -1
- package/dist/render3d/scene3d.js.map +1 -1
- package/dist/render3d/texture.d.ts +2 -2
- package/dist/render3d/texture.d.ts.map +1 -1
- package/dist/render3d/texture.js.map +1 -1
- package/dist/render3d/vector3.d.ts +2 -2
- package/dist/render3d/vector3.js +2 -2
- package/dist/render3d/vector3.js.map +1 -1
- package/dist/runtime/asset-refine.d.ts +1 -1
- package/dist/runtime/asset-refine.d.ts.map +1 -1
- package/dist/runtime/asset-refine.js +1 -1
- package/dist/runtime/asset-refine.js.map +1 -1
- package/dist/runtime/asset-update.js +1 -1
- package/dist/runtime/asset-update.js.map +1 -1
- package/dist/runtime/audio-index.d.ts +0 -11
- package/dist/runtime/audio-index.d.ts.map +1 -1
- package/dist/runtime/audio-index.js +0 -25
- package/dist/runtime/audio-index.js.map +1 -1
- package/dist/runtime/clip-instance.d.ts +7 -4
- package/dist/runtime/clip-instance.d.ts.map +1 -1
- package/dist/runtime/clip-instance.js +21 -7
- package/dist/runtime/clip-instance.js.map +1 -1
- package/dist/runtime/clip-store.d.ts +11 -3
- package/dist/runtime/clip-store.d.ts.map +1 -1
- package/dist/runtime/clip-store.js +83 -23
- package/dist/runtime/clip-store.js.map +1 -1
- package/dist/runtime/engine.d.ts +3 -3
- package/dist/runtime/engine.js +2 -2
- package/dist/runtime/engine.js.map +1 -1
- package/dist/runtime/node-picking.d.ts +2 -2
- package/dist/runtime/node-picking.d.ts.map +1 -1
- package/dist/runtime/node-picking.js +9 -10
- package/dist/runtime/node-picking.js.map +1 -1
- package/dist/runtime/node-picking3d.d.ts +12 -5
- package/dist/runtime/node-picking3d.d.ts.map +1 -1
- package/dist/runtime/node-picking3d.js +6 -1
- package/dist/runtime/node-picking3d.js.map +1 -1
- package/dist/runtime/playback-controller.d.ts +2 -2
- package/dist/runtime/playback-controller.d.ts.map +1 -1
- package/dist/runtime/playback-controller.js +1 -1
- package/dist/runtime/playback-controller.js.map +1 -1
- package/dist/runtime/state-evaluator.d.ts +2 -2
- package/dist/runtime/state-evaluator.d.ts.map +1 -1
- package/dist/runtime/state-evaluator.js.map +1 -1
- package/dist/runtime/text-geometry.d.ts +1 -1
- package/dist/runtime/text-geometry.d.ts.map +1 -1
- package/dist/runtime/text-geometry.js +6 -3
- package/dist/runtime/text-geometry.js.map +1 -1
- package/dist/sdk/index.d.ts +46 -21
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/index.js +47 -43
- package/dist/sdk/index.js.map +1 -1
- package/dist/tween/command-decorator.d.ts +7 -9
- package/dist/tween/command-decorator.d.ts.map +1 -1
- package/dist/tween/command-decorator.js +2 -2
- package/dist/tween/command-decorator.js.map +1 -1
- package/dist/tween/command.d.ts +13 -1
- package/dist/tween/command.d.ts.map +1 -1
- package/dist/tween/command.js +14 -0
- package/dist/tween/command.js.map +1 -1
- package/dist/tween/index.d.ts +2 -1
- package/dist/tween/index.d.ts.map +1 -1
- package/dist/tween/index.js +1 -1
- package/dist/tween/index.js.map +1 -1
- package/dist/tween/loop.d.ts +1 -1
- package/dist/tween/loop.js +1 -1
- package/dist/tween/loop.js.map +1 -1
- package/dist/util/reference.d.ts +6 -6
- package/dist/util/reference.js.map +1 -1
- package/package.json +7 -10
- package/dist/browser/chunks/chunk-FUZVFT3W.js +0 -18
- package/dist/browser/chunks/chunk-FUZVFT3W.js.map +0 -7
- package/dist/browser/chunks/chunk-QG6C23IJ.js +0 -3
- package/dist/browser/chunks/chunk-QG6C23IJ.js.map +0 -7
- package/dist/browser/chunks/chunk-SFNJRPBV.js +0 -2
- package/dist/browser/chunks/chunk-SFNJRPBV.js.map +0 -7
- package/dist/browser/jsx-jsx-dev-runtime.js +0 -2
- package/dist/browser/jsx-jsx-runtime.js +0 -2
- package/dist/browser/jsx-jsx-runtime.js.map +0 -7
- /package/dist/browser/{jsx-jsx-dev-runtime.js.map → experimental.js.map} +0 -0
|
@@ -10,7 +10,7 @@ export type CornerRadiusResolved = Corners<number>;
|
|
|
10
10
|
*/
|
|
11
11
|
export type RectCornerRadius = CornersInput<number> | CornerRadiusResolved;
|
|
12
12
|
/**
|
|
13
|
-
* The corner-radius attribute's op set: `resolve`/`lerp` for
|
|
13
|
+
* The corner-radius attribute's op set: `resolve`/`lerp` for `Shapes.corners`,
|
|
14
14
|
* plus the uniform/zero checks a renderer needs to pick a cheap draw path (see
|
|
15
15
|
* `RectShape.computeGeometry` in `@motionscript/skia-render`).
|
|
16
16
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { lerpNumber } from "../../../tween/lerp.js";
|
|
2
2
|
import { resolveCorners, lerpCorners, isUniformCorners } from "./corners.js";
|
|
3
3
|
/**
|
|
4
|
-
* The corner-radius attribute's op set: `resolve`/`lerp` for
|
|
4
|
+
* The corner-radius attribute's op set: `resolve`/`lerp` for `Shapes.corners`,
|
|
5
5
|
* plus the uniform/zero checks a renderer needs to pick a cheap draw path (see
|
|
6
6
|
* `RectShape.computeGeometry` in `@motionscript/skia-render`).
|
|
7
7
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"corner-radius.js","sourceRoot":"","sources":["../../../../src/attributes/shape/corners/corner-radius.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAyB,cAAc,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAajG;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAoB;IAC5C,6EAA6E;IAC7E,qEAAqE;IACrE,OAAO,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,cAAc,CAAC,KAA6B,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC;IACnI,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE,UAAU,CAAC;IAC3D,cAAc,EAAE,CAAC,KAAK,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ;IACrE,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC;IAC7C,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,KAAK,CAAC,IAAI,KAAK,CAAC,UAAU,KAAK,CAAC,IAAI,KAAK,CAAC,WAAW,KAAK,CAAC;CACtH,CAAC","sourcesContent":["import { lerpNumber } from \"@/tween/lerp\";\r\nimport type { CornerRadiusOps } from \"@/attributes/shared/operators\";\r\nimport { Corners, CornersInput, resolveCorners, lerpCorners, isUniformCorners } from \"./corners\";\r\n\r\n/** Per-corner border radius values, all fully resolved to numbers. */\r\nexport type CornerRadiusResolved = Corners<number>;\r\n\r\n/**\r\n * Accepted corner radius input for a Rect: a single number applies uniformly to\r\n * all corners; an object overrides corners individually (`{ topLeft, … }`) or by\r\n * axis (`{ top, bottom }` / `{ left, right }`). An already-resolved value passes\r\n * through. Unspecified corners fall back to a previous value or 0 when resolved.\r\n */\r\nexport type RectCornerRadius = CornersInput<number> | CornerRadiusResolved;\r\n\r\n/**\r\n * The corner-radius attribute's op set: `resolve`/`lerp` for
|
|
1
|
+
{"version":3,"file":"corner-radius.js","sourceRoot":"","sources":["../../../../src/attributes/shape/corners/corner-radius.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAyB,cAAc,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAajG;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAoB;IAC5C,6EAA6E;IAC7E,qEAAqE;IACrE,OAAO,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,cAAc,CAAC,KAA6B,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC;IACnI,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE,UAAU,CAAC;IAC3D,cAAc,EAAE,CAAC,KAAK,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ;IACrE,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC;IAC7C,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,KAAK,CAAC,IAAI,KAAK,CAAC,UAAU,KAAK,CAAC,IAAI,KAAK,CAAC,WAAW,KAAK,CAAC;CACtH,CAAC","sourcesContent":["import { lerpNumber } from \"@/tween/lerp\";\r\nimport type { CornerRadiusOps } from \"@/attributes/shared/operators\";\r\nimport { Corners, CornersInput, resolveCorners, lerpCorners, isUniformCorners } from \"./corners\";\r\n\r\n/** Per-corner border radius values, all fully resolved to numbers. */\r\nexport type CornerRadiusResolved = Corners<number>;\r\n\r\n/**\r\n * Accepted corner radius input for a Rect: a single number applies uniformly to\r\n * all corners; an object overrides corners individually (`{ topLeft, … }`) or by\r\n * axis (`{ top, bottom }` / `{ left, right }`). An already-resolved value passes\r\n * through. Unspecified corners fall back to a previous value or 0 when resolved.\r\n */\r\nexport type RectCornerRadius = CornersInput<number> | CornerRadiusResolved;\r\n\r\n/**\r\n * The corner-radius attribute's op set: `resolve`/`lerp` for `Shapes.corners`,\r\n * plus the uniform/zero checks a renderer needs to pick a cheap draw path (see\r\n * `RectShape.computeGeometry` in `@motionscript/skia-render`).\r\n */\r\nexport const cornerRadiusOps: CornerRadiusOps = {\r\n // A resolved value is structurally a full per-corner `CornersInput<number>`,\r\n // so pin T=number and let resolveCorners re-resolve it idempotently.\r\n resolve: (value, previous) => resolveCorners(value as CornersInput<number>, 0, previous, (v): v is number => typeof v === \"number\"),\r\n lerp: (from, to, t) => lerpCorners(from, to, t, lerpNumber),\r\n isUniformInput: (value): value is number => typeof value === \"number\",\r\n isUniform: (value) => isUniformCorners(value),\r\n isZero: (value) => value.topLeft === 0 && value.topRight === 0 && value.bottomLeft === 0 && value.bottomRight === 0,\r\n};\r\n"]}
|
|
@@ -5,7 +5,7 @@ import type { ModedEffect, EffectData } from "../effect-data.js";
|
|
|
5
5
|
* geometry — the drop shadow that a `shadow` prop can't give you when the shape
|
|
6
6
|
* on screen isn't the shape of the path.
|
|
7
7
|
*
|
|
8
|
-
* `
|
|
8
|
+
* A shape's `shadow` fills the node's own outline with the shadow colour and
|
|
9
9
|
* blurs it, which is exactly right for a rect, an ellipse or a star. It is
|
|
10
10
|
* exactly wrong for anything whose visible form comes from *pixels*: a cut-out
|
|
11
11
|
* PNG, a video with an alpha channel, a line of text, a whole subtree. All of
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drop-shadow.js","sourceRoot":"","sources":["../../../../../src/attributes/shape/effects/implementations/drop-shadow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAGzD,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAuCrE,MAAM,CAAC,MAAM,gBAAgB,GAAiC;IAC1D,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QACpB,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QAChD,OAAO,EAAE,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QAChD,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;QACvC,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;QAC7C,KAAK,EAAE,SAAS,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,kBAAkB,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACjF,IAAI,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI;KACtC,CAAC;IACF,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACb,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO;QACvB,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO;QACvB,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI;QACjB,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;QACrB,eAAe,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC;QACjC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI;IACrB;;;;;;;;OAQG;IACH,OAAO,EAAE,QAAQ;CACpB,CAAC","sourcesContent":["import { lerpNumber } from \"@/tween/lerp\";\r\nimport { lerpColor } from \"@/attributes/shape/fill/lerp\";\r\nimport type { Color } from \"@/attributes/shape/fill/color/parser\";\r\nimport type { ModedEffect, EffectData } from \"../effect-data\";\r\nimport { resolveEffectColor, sameEffectColor } from \"../effect-data\";\r\n\r\n/**\r\n * A shadow cast from the node's **alpha silhouette** rather than from its\r\n * geometry — the drop shadow that a `shadow` prop can't give you when the shape\r\n * on screen isn't the shape of the path.\r\n *\r\n * `
|
|
1
|
+
{"version":3,"file":"drop-shadow.js","sourceRoot":"","sources":["../../../../../src/attributes/shape/effects/implementations/drop-shadow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAGzD,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAuCrE,MAAM,CAAC,MAAM,gBAAgB,GAAiC;IAC1D,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QACpB,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QAChD,OAAO,EAAE,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QAChD,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;QACvC,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;QAC7C,KAAK,EAAE,SAAS,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,kBAAkB,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACjF,IAAI,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI;KACtC,CAAC;IACF,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACb,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO;QACvB,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO;QACvB,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI;QACjB,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;QACrB,eAAe,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC;QACjC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI;IACrB;;;;;;;;OAQG;IACH,OAAO,EAAE,QAAQ;CACpB,CAAC","sourcesContent":["import { lerpNumber } from \"@/tween/lerp\";\r\nimport { lerpColor } from \"@/attributes/shape/fill/lerp\";\r\nimport type { Color } from \"@/attributes/shape/fill/color/parser\";\r\nimport type { ModedEffect, EffectData } from \"../effect-data\";\r\nimport { resolveEffectColor, sameEffectColor } from \"../effect-data\";\r\n\r\n/**\r\n * A shadow cast from the node's **alpha silhouette** rather than from its\r\n * geometry — the drop shadow that a `shadow` prop can't give you when the shape\r\n * on screen isn't the shape of the path.\r\n *\r\n * A shape's `shadow` fills the node's own outline with the shadow colour and\r\n * blurs it, which is exactly right for a rect, an ellipse or a star. It is\r\n * exactly wrong for anything whose visible form comes from *pixels*: a cut-out\r\n * PNG, a video with an alpha channel, a line of text, a whole subtree. All of\r\n * those cast a blurred **rectangle**, because the rectangle is what their path\r\n * is — and on a cut-out subject that reads as a bug rather than as a shadow.\r\n *\r\n * So this one is computed from what the node actually drew. Same relationship\r\n * to `shadow` that {@link OutlineEffect} has to `stroke`: the geometry version\r\n * is cheaper and sharper where the path *is* the picture, and this one is the\r\n * answer everywhere else.\r\n *\r\n * Offsets are in the scene's own axes — a positive `y` lifts the shadow upward,\r\n * matching `ShadowProp.offset` rather than the y-down device space the shader\r\n * runs in, so the two kinds of shadow move the same way under the same numbers.\r\n */\r\nexport interface DropShadowEffect extends ModedEffect {\r\n type: \"dropShadow\";\r\n /** How far the shadow is displaced, in px. */\r\n offsetX: number;\r\n offsetY: number;\r\n /** Softness in px, on the same scale a `blur` effect's radius uses. 0 = hard. */\r\n blur: number;\r\n /**\r\n * Grows (or, negative, shrinks) the silhouette before blurring, in px —\r\n * `box-shadow`'s third length and Figma's \"spread\".\r\n */\r\n spread: number;\r\n /** Shadow colour — any CSS colour, theme alias, or RGBA tuple. */\r\n color: Color;\r\n}\r\n\r\nexport const dropShadowEffect: EffectData<DropShadowEffect> = {\r\n lerp: (from, to, t) => ({\r\n type: \"dropShadow\",\r\n offsetX: lerpNumber(from.offsetX, to.offsetX, t),\r\n offsetY: lerpNumber(from.offsetY, to.offsetY, t),\r\n blur: lerpNumber(from.blur, to.blur, t),\r\n spread: lerpNumber(from.spread, to.spread, t),\r\n color: lerpColor(resolveEffectColor(from.color), resolveEffectColor(to.color), t),\r\n mode: t < 0.5 ? from.mode : to.mode,\r\n }),\r\n equals: (a, b) =>\r\n a.offsetX === b.offsetX &&\r\n a.offsetY === b.offsetY &&\r\n a.blur === b.blur &&\r\n a.spread === b.spread &&\r\n sameEffectColor(a.color, b.color) &&\r\n a.mode === b.mode,\r\n /**\r\n * A shader rather than Skia's own `MakeDropShadow`, and the reason is the\r\n * same one {@link outlineEffect} gives for not using `MakeDilate`: the\r\n * ImageFilter path's layer is bounded to the node rect (see `transform()` in\r\n * the render context, which sets that bound deliberately so scaling filters\r\n * can't overrun the clip). A shadow's whole job is to fall *outside* the\r\n * node, so on that path an offset one would be sliced off at the edge of the\r\n * box. A shader scope has no such bound.\r\n */\r\n surface: \"shader\",\r\n};\r\n"]}
|
|
@@ -48,7 +48,7 @@ interface ThemeInput {
|
|
|
48
48
|
* header: { fontSize: 96, fontWeight: 700 },
|
|
49
49
|
* },
|
|
50
50
|
* });
|
|
51
|
-
* // Later: fill
|
|
51
|
+
* // Later: fill: "brand", fill: "accent-500", Text({ variant: "header" })
|
|
52
52
|
*/
|
|
53
53
|
export declare function setTheme(input?: ThemeInput | null): void;
|
|
54
54
|
/** Looks up a registered typography preset by variant name (case-insensitive);
|
|
@@ -139,7 +139,7 @@ function flattenColors(tokens, prefix, out) {
|
|
|
139
139
|
* header: { fontSize: 96, fontWeight: 700 },
|
|
140
140
|
* },
|
|
141
141
|
* });
|
|
142
|
-
* // Later: fill
|
|
142
|
+
* // Later: fill: "brand", fill: "accent-500", Text({ variant: "header" })
|
|
143
143
|
*/
|
|
144
144
|
export function setTheme(input = {}) {
|
|
145
145
|
const theme = input ?? {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../../../src/attributes/shape/fill/color/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAQ5C,iFAAiF;AAEjF,qEAAqE;AACrE,SAAS,WAAW,CAAC,CAAS;IAC1B,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAChC,OAAO,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC;AAC7E,CAAC;AAED,iEAAiE;AACjE,SAAS,YAAY,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS;IAC5D,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED,2EAA2E;AAC3E,SAAS,kBAAkB,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS;IACvD,OAAO;QACH,SAAS,GAAG,CAAC,GAAG,SAAS,GAAG,CAAC,GAAG,SAAS,GAAG,CAAC;QAC7C,CAAC,SAAS,GAAG,CAAC,GAAG,SAAS,GAAG,CAAC,GAAG,SAAS,GAAG,CAAC;QAC9C,SAAS,GAAG,CAAC,GAAG,SAAS,GAAG,CAAC,GA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AC,CAAC;IACnI,2EAA2E;IAC3E,IAAI,OAAO,KAAK,CAAC;QAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC;IACjF,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["/**\r\n * CSS color string parser → normalized [R, G, B, A] float tuple.\r\n *\r\n * Supported formats:\r\n * - Named colors (CSS Level 4, 148 entries) and theme aliases via {@link setTheme}\r\n * - Hex: `#RGB`, `#RGBA`, `#RRGGBB`, `#RRGGBBAA`\r\n * - `rgb()` / `rgba()` — legacy comma and modern space/slash syntax\r\n * - `hsl()` / `hsla()`\r\n * - `lab()`, `lch()`\r\n * - `oklab()`, `oklch()`\r\n * - Tailwind-style opacity suffix: `\"white/10\"`, `\"primary/90\"` (percent 0–100)\r\n *\r\n * All output values are in the linear 0–1 range suitable for WebGL uniforms.\r\n * Named-color lookup is O(1); all other formats are parsed with lightweight\r\n * regex — no DOM, no `getComputedStyle`.\r\n */\r\n\r\nimport { CSS_COLOR_MAP } from './constants';\r\n\r\n/** Normalized RGBA color: `[red, green, blue, alpha]` each in the 0–1 range. */\r\nexport type NormalizedColor = [number, number, number, number];\r\n\r\n/** Loose color input accepted by prop interfaces — CSS string or pre-normalized tuple. */\r\nexport type Color = string | NormalizedColor;\r\n\r\n// ── Color space helpers ───────────────────────────────────────────────────────\r\n\r\n/** Applies the sRGB gamma curve to a single linear-light channel. */\r\nfunction gammaEncode(c: number): number {\r\n c = Math.max(0, Math.min(1, c));\r\n return c <= 0.0031308 ? 12.92 * c : 1.055 * Math.pow(c, 1 / 2.4) - 0.055;\r\n}\r\n\r\n/** Converts a linear-light sRGB triple to gamma-encoded sRGB. */\r\nfunction linearToSrgb(r: number, g: number, b: number, a: number): NormalizedColor {\r\n return [gammaEncode(r), gammaEncode(g), gammaEncode(b), a];\r\n}\r\n\r\n/** Bradford-adapted XYZ D65 → linear-light sRGB matrix (IEC 61966-2-1). */\r\nfunction xyzD65ToLinearSrgb(X: number, Y: number, Z: number): [number, number, number] {\r\n return [\r\n 3.2404542 * X - 1.5371385 * Y - 0.4985314 * Z,\r\n -0.9692660 * X + 1.8760108 * Y + 0.0415560 * Z,\r\n 0.0556434 * X - 0.2040259 * Y + 1.0572252 * Z,\r\n ];\r\n}\r\n\r\n// ── Argument parser ───────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Splits the inner content of a CSS color function into exactly three channel\r\n * tokens and an alpha value. Handles the slash-alpha syntax used by modern\r\n * `rgb()` / `hsl()` as well as the legacy comma-alpha form used by `rgba()` /\r\n * `hsla()`; both go through {@link readAlpha}, so a percentage alpha means the\r\n * same in either. Returns `null` for the wrong number of arguments or an alpha\r\n * that is not a number, which {@link parseColor} reports as an unsupported\r\n * format.\r\n */\r\nfunction parseArgs(inner: string): { tokens: string[]; alpha: number } | null {\r\n const slashIdx = inner.lastIndexOf('/');\r\n let alphaToken: string | undefined;\r\n let colorPart = inner;\r\n if (slashIdx !== -1) {\r\n alphaToken = inner.slice(slashIdx + 1).trim();\r\n colorPart = inner.slice(0, slashIdx);\r\n }\r\n const tokens = colorPart.trim().split(/[\\s,]+/).filter(Boolean);\r\n if (tokens.length === 4 && alphaToken === undefined) alphaToken = tokens.pop();\r\n if (tokens.length !== 3) return null;\r\n const alpha = alphaToken === undefined ? 1 : readAlpha(alphaToken);\r\n if (!Number.isFinite(alpha)) return null;\r\n return { tokens, alpha };\r\n}\r\n\r\n/** Reads an alpha token: a number, or a percentage (`50%` is 0.5). `NaN` if neither. */\r\nfunction readAlpha(token: string): number {\r\n return token.endsWith('%') ? Number(token.slice(0, -1)) / 100 : Number(token);\r\n}\r\n\r\n/** Reads a channel token as a number, scaling a percentage to `percentScale` and a bare number by `1 / numberScale`. `NaN` if it is not a number. */\r\nfunction readChannel(token: string, percentScale: number, numberScale = 1): number {\r\n return token.endsWith('%') ? (Number(token.slice(0, -1)) / 100) * percentScale : Number(token) / numberScale;\r\n}\r\n\r\n/** Degrees per CSS angle unit (`deg`, `grad`, `rad`, `turn`). */\r\nconst ANGLE_UNIT_DEGREES: Record<string, number> = { deg: 1, grad: 0.9, rad: 180 / Math.PI, turn: 360 };\r\n\r\n/** Reads a CSS hue/angle token to degrees. A bare number is degrees; an unknown unit or a non-number is `NaN`. */\r\nfunction readHue(token: string): number {\r\n const m = token.match(/^([+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:e[+-]?\\d+)?)(deg|grad|rad|turn)?$/);\r\n if (!m) return NaN;\r\n return Number(m[1]) * ANGLE_UNIT_DEGREES[m[2] ?? 'deg'];\r\n}\r\n\r\n/** Returns `color` when every component is finite, otherwise `null` (unsupported format). */\r\nfunction finiteColor(color: NormalizedColor): NormalizedColor | null {\r\n return color.every(Number.isFinite) ? color : null;\r\n}\r\n\r\n// ── Per-format parsers ────────────────────────────────────────────────────────\r\n\r\n// Use a globalThis key so multiple bundled copies of this module (e.g. the\r\n// prebuilt player bundle and the Vite-compiled user code) share one map.\r\nconst _g = globalThis as Record<string, unknown>;\r\nif (!_g.__msThemeMap) _g.__msThemeMap = new Map<string, NormalizedColor>();\r\nconst THEME_COLOR_MAP = _g.__msThemeMap as Map<string, NormalizedColor>;\r\n\r\n// Typography presets ride the same shared-global pattern as the color map, so\r\n// the prebuilt player bundle and the user's Vite-compiled code read one registry\r\n// — `setTheme` (called once per build at the player/headless entry points)\r\n// populates both before any scene generator runs.\r\nif (!_g.__msTypographyMap) _g.__msTypographyMap = new Map<string, Record<string, unknown>>();\r\nconst TYPOGRAPHY_MAP = _g.__msTypographyMap as Map<string, Record<string, unknown>>;\r\n\r\n// Structural mirror of `@/project/config`'s `Theme` (and its color token shape),\r\n// declared locally so this module stays a leaf — `config.ts` imports `Color`\r\n// from here, so importing `Theme` back would be a cycle. The project's `Theme`\r\n// is structurally compatible, so `setTheme(config.theme)` just works.\r\n// `typography` presets are stored opaquely (the parser never reads their fields),\r\n// so the value type is the loose `object` — this stays assignable from `Theme`'s\r\n// `TypographyPreset` (a `TextStyle` interface, which lacks an implicit string\r\n// index signature and so is not a `Record<string, unknown>`).\r\ntype ColorTokenInput = Color | { [key: string]: ColorTokenInput };\r\ninterface ThemeInput {\r\n colors?: Record<string, ColorTokenInput>;\r\n typography?: Record<string, object>;\r\n}\r\n\r\n/**\r\n * Recursively flatten nested color groups into dash-joined, lowercased keys\r\n * (`{ brand: { 500: '#…' } }` → `brand-500`), parsing each leaf to a normalized\r\n * color. Arrays are leaves (a pre-normalized `[R,G,B,A]` tuple); strings are\r\n * leaves; only plain objects recurse.\r\n */\r\nfunction flattenColors(\r\n tokens: Record<string, ColorTokenInput> | undefined,\r\n prefix: string,\r\n out: Map<string, NormalizedColor>,\r\n): void {\r\n if (!tokens) return;\r\n for (const [name, token] of Object.entries(tokens)) {\r\n const key = prefix ? `${prefix}-${name}` : name;\r\n if (token != null && !Array.isArray(token) && typeof token === 'object') {\r\n flattenColors(token as Record<string, ColorTokenInput>, key, out);\r\n } else {\r\n const color = token as Color;\r\n out.set(key.toLowerCase(), Array.isArray(color) ? (color as NormalizedColor) : parseColor(color));\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Registers a project theme: named colors (referenceable by name in any color\r\n * string) and typography presets (selected via a `Text`/`RichText` `variant`).\r\n *\r\n * Color entries take precedence over CSS named colors; nested color groups are\r\n * flattened to dash-joined names (`{ brand: { 500: … } }` → `brand-500`). Call\r\n * with no argument, `null`, or an empty object to clear both registries — a\r\n * document's own `theme` is optional, and a host reading one out of storage\r\n * (a database column, a JSON file) typically gets that absence back as `null`\r\n * rather than `undefined`.\r\n *\r\n * The `default` typography key is reserved: it's read directly by\r\n * {@link applyTextDefaults} (not just via `variant`) and applied to every\r\n * `Text`/`RichText` as a project-wide base style.\r\n *\r\n * @example\r\n * setTheme({\r\n * colors: { brand: \"#ff6b35\", accent: { 500: \"oklch(70% 0.2 145)\" } },\r\n * typography: {\r\n * default: { fontFamily: \"Inter\", fontSize: 32 },\r\n * header: { fontSize: 96, fontWeight: 700 },\r\n * },\r\n * });\r\n * // Later: fill=\"brand\", fill=\"accent-500\", <Text variant=\"header\" />\r\n */\r\nexport function setTheme(input: ThemeInput | null = {}): void {\r\n const theme = input ?? {};\r\n THEME_COLOR_MAP.clear();\r\n TYPOGRAPHY_MAP.clear();\r\n flattenColors(theme.colors, '', THEME_COLOR_MAP);\r\n if (theme.typography) {\r\n for (const [name, preset] of Object.entries(theme.typography)) {\r\n // Stored opaquely; `applyTextDefaults` reads fields by key. The `object`\r\n // preset is widened to the readable record shape at this boundary only.\r\n TYPOGRAPHY_MAP.set(name.toLowerCase(), preset as Record<string, unknown>);\r\n }\r\n }\r\n}\r\n\r\n/** Looks up a registered typography preset by variant name (case-insensitive);\r\n * `undefined` if none is registered. */\r\nexport function getTypographyPreset(name: string): Record<string, unknown> | undefined {\r\n return TYPOGRAPHY_MAP.get(name.toLowerCase());\r\n}\r\n\r\n/** Looks up a color name in the theme map first, then the CSS named-color table. */\r\nfunction parseNamedColor(str: string): NormalizedColor | null {\r\n return THEME_COLOR_MAP.get(str) ?? CSS_COLOR_MAP.get(str) ?? null;\r\n}\r\n\r\n/** Parses `#RGB`, `#RGBA`, `#RRGGBB`, `#RRGGBBAA` hex strings. */\r\nfunction parseHex(str: string): NormalizedColor | null {\r\n if (!str.startsWith('#')) return null;\r\n let hex = str.slice(1);\r\n if (!/^[0-9a-f]+$/.test(hex)) return null;\r\n // Expand shorthand: #RGB → #RRGGBB, #RGBA → #RRGGBBAA\r\n if (hex.length === 3 || hex.length === 4)\r\n hex = hex.split('').map(c => c + c).join('');\r\n const int = parseInt(hex, 16);\r\n if (hex.length === 6)\r\n return [(int >> 16 & 255) / 255, (int >> 8 & 255) / 255, (int & 255) / 255, 1];\r\n if (hex.length === 8)\r\n return [(int >>> 24) / 255, (int >> 16 & 255) / 255, (int >> 8 & 255) / 255, (int & 255) / 255];\r\n return null;\r\n}\r\n\r\n/** Parses `rgb()` / `rgba()` — both percentage and 0-255 channel forms. */\r\nfunction parseRgb(str: string): NormalizedColor | null {\r\n const m = str.match(/^rgba?\\s*\\((.+)\\)/);\r\n if (!m) return null;\r\n const args = parseArgs(m[1]);\r\n if (!args) return null;\r\n const [r, g, b] = args.tokens.map(t => readChannel(t, 1, 255));\r\n return finiteColor([r, g, b, args.alpha]);\r\n}\r\n\r\n/** Parses `hsl()` / `hsla()`. The hue takes `deg`, `grad`, `rad` or `turn` (a bare number is degrees). */\r\nfunction parseHsl(str: string): NormalizedColor | null {\r\n const m = str.match(/^hsla?\\s*\\((.+)\\)/);\r\n if (!m) return null;\r\n const args = parseArgs(m[1]);\r\n if (!args) return null;\r\n const h = readHue(args.tokens[0]);\r\n const s = parseFloat(args.tokens[1]) / 100;\r\n const l = parseFloat(args.tokens[2]) / 100;\r\n const k = (n: number) => (((n + h / 30) % 12) + 12) % 12;\r\n const chroma = s * Math.min(l, 1 - l);\r\n const f = (n: number) => l - chroma * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));\r\n return finiteColor([f(0), f(8), f(4), args.alpha]);\r\n}\r\n\r\n/** Parses `lab(L a b)` (CIE L*a*b*, D50 white point). */\r\nfunction parseLab(str: string): NormalizedColor | null {\r\n const m = str.match(/^lab\\s*\\((.+)\\)/);\r\n if (!m) return null;\r\n const args = parseArgs(m[1]);\r\n if (!args) return null;\r\n const L = parseFloat(args.tokens[0]);\r\n const a = parseFloat(args.tokens[1]);\r\n const b = parseFloat(args.tokens[2]);\r\n return finiteColor(labToNormalized(L, a, b, args.alpha));\r\n}\r\n\r\n/** Parses `lch(L C H)` (CIE L*C*h°, polar form of Lab). */\r\nfunction parseLch(str: string): NormalizedColor | null {\r\n const m = str.match(/^lch\\s*\\((.+)\\)/);\r\n if (!m) return null;\r\n const args = parseArgs(m[1]);\r\n if (!args) return null;\r\n const L = parseFloat(args.tokens[0]);\r\n const C = parseFloat(args.tokens[1]);\r\n const rad = readHue(args.tokens[2]) * (Math.PI / 180);\r\n return finiteColor(labToNormalized(L, C * Math.cos(rad), C * Math.sin(rad), args.alpha));\r\n}\r\n\r\n/** Parses `oklab(L a b)` (Oklab perceptually uniform color space). */\r\nfunction parseOklab(str: string): NormalizedColor | null {\r\n const m = str.match(/^oklab\\s*\\((.+)\\)/);\r\n if (!m) return null;\r\n const args = parseArgs(m[1]);\r\n if (!args) return null;\r\n // L: 0–1 as number, or 0%–100% (100% = 1); a, b: 100% = 0.4 per CSS Color 4.\r\n const [L, a, b] = [readChannel(args.tokens[0], 1), readChannel(args.tokens[1], 0.4), readChannel(args.tokens[2], 0.4)];\r\n return finiteColor(oklabToNormalized(L, a, b, args.alpha));\r\n}\r\n\r\n/** Parses `oklch(L C H)` (polar form of Oklab). */\r\nfunction parseOklch(str: string): NormalizedColor | null {\r\n const m = str.match(/^oklch\\s*\\((.+)\\)/);\r\n if (!m) return null;\r\n const args = parseArgs(m[1]);\r\n if (!args) return null;\r\n // L: 0–1 or percentage; C: 0–0.4 or percentage (100% = 0.4).\r\n const L = readChannel(args.tokens[0], 1);\r\n const C = readChannel(args.tokens[1], 0.4);\r\n const rad = readHue(args.tokens[2]) * (Math.PI / 180);\r\n return finiteColor(oklabToNormalized(L, C * Math.cos(rad), C * Math.sin(rad), args.alpha));\r\n}\r\n\r\n// ── CIE conversion helpers ────────────────────────────────────────────────────\r\n\r\n/** Converts CIE L*a*b* (D50) to a normalized sRGB color. */\r\nfunction labToNormalized(L: number, a: number, b: number, alpha: number): NormalizedColor {\r\n const e = 0.008856, k = 903.3;\r\n const fy = (L + 16) / 116;\r\n const fx = a / 500 + fy;\r\n const fz = fy - b / 200;\r\n const X = (fx ** 3 > e ? fx ** 3 : (116 * fx - 16) / k) * 0.95047;\r\n const Y = L > k * e ? ((L + 16) / 116) ** 3 : L / k;\r\n const Z = (fz ** 3 > e ? fz ** 3 : (116 * fz - 16) / k) * 1.08883;\r\n const [lr, lg, lb] = xyzD65ToLinearSrgb(X, Y, Z);\r\n return linearToSrgb(lr, lg, lb, alpha);\r\n}\r\n\r\n/** Converts Oklab to a normalized sRGB color using the standard Björn Ottosson matrix. */\r\nfunction oklabToNormalized(L: number, a: number, b: number, alpha: number): NormalizedColor {\r\n const l_ = L + 0.3963377774 * a + 0.2158037573 * b;\r\n const m_ = L - 0.1055613458 * a - 0.0638541728 * b;\r\n const s_ = L - 0.0894841775 * a - 1.2914855480 * b;\r\n const l = l_ ** 3, m = m_ ** 3, s = s_ ** 3;\r\n return linearToSrgb(\r\n 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,\r\n -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,\r\n -0.0041960863 * l - 0.7034186147 * m + 1.6956065236 * s,\r\n alpha,\r\n );\r\n}\r\n\r\n// ── Opacity suffix ─────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Splits a Tailwind-style opacity suffix (`\"white/10\"`, `\"primary/90\"`) off the\r\n * end of a color string. The suffix is a slash followed by a number (optionally\r\n * with a `%`) interpreted as a percentage 0–100.\r\n *\r\n * Only a trailing slash that sits *outside* any parentheses is treated as an\r\n * opacity modifier, so the internal slash-alpha syntax of `rgb()` / `hsl()`\r\n * (e.g. `rgb(0 0 255 / 0.25)`) is left untouched.\r\n *\r\n * @returns the bare color string and the opacity fraction (1 when absent).\r\n */\r\nfunction splitOpacitySuffix(str: string): { color: string; opacity: number } {\r\n if (str.includes('(')) return { color: str, opacity: 1 };\r\n const m = str.match(/^(.*[^/])\\/\\s*([\\d.]+)%?$/);\r\n if (!m) return { color: str, opacity: 1 };\r\n const pct = parseFloat(m[2]);\r\n if (!Number.isFinite(pct)) return { color: str, opacity: 1 };\r\n return { color: m[1].trim(), opacity: Math.max(0, Math.min(1, pct / 100)) };\r\n}\r\n\r\n// ── Main entry point ──────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Parses a CSS color string into a normalized `[R, G, B, A]` array (0.0–1.0).\r\n *\r\n * Supported formats: named colors (CSS + theme), hex, rgb/rgba, hsl/hsla,\r\n * lab, lch, oklab, oklch, plus a Tailwind-style opacity suffix (`\"white/10\"`).\r\n * Falls back to opaque black and logs a warning for unrecognised input.\r\n */\r\nexport function parseColor(cssStr: string): NormalizedColor {\r\n const { color: str, opacity } = splitOpacitySuffix(cssStr.trim().toLowerCase());\r\n const parsed =\r\n parseNamedColor(str) ??\r\n parseHex(str) ??\r\n parseRgb(str) ??\r\n parseHsl(str) ??\r\n parseLab(str) ??\r\n parseLch(str) ??\r\n parseOklab(str) ??\r\n parseOklch(str) ??\r\n (console.warn(`[Motion Engine] Unsupported color format: \"${cssStr}\". Defaulting to black.`), [0, 0, 0, 1] as NormalizedColor);\r\n // Clone before applying opacity: named/theme lookups return cached tuples.\r\n if (opacity !== 1) return [parsed[0], parsed[1], parsed[2], parsed[3] * opacity];\r\n return parsed;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../../../src/attributes/shape/fill/color/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAQ5C,iFAAiF;AAEjF,qEAAqE;AACrE,SAAS,WAAW,CAAC,CAAS;IAC1B,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAChC,OAAO,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC;AAC7E,CAAC;AAED,iEAAiE;AACjE,SAAS,YAAY,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS;IAC5D,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE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AAG,CAAC;QACpB,QAAQ,CAAC,GAAG,CAAC;QACb,QAAQ,CAAC,GAAG,CAAC;QACb,QAAQ,CAAC,GAAG,CAAC;QACb,QAAQ,CAAC,GAAG,CAAC;QACb,QAAQ,CAAC,GAAG,CAAC;QACb,UAAU,CAAC,GAAG,CAAC;QACf,UAAU,CAAC,GAAG,CAAC;QACf,CAAC,OAAO,CAAC,IAAI,CAAC,8CAA8C,MAAM,yBAAyB,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAoB,CAAC,CAAC;IACnI,2EAA2E;IAC3E,IAAI,OAAO,KAAK,CAAC;QAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC;IACjF,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["/**\r\n * CSS color string parser → normalized [R, G, B, A] float tuple.\r\n *\r\n * Supported formats:\r\n * - Named colors (CSS Level 4, 148 entries) and theme aliases via {@link setTheme}\r\n * - Hex: `#RGB`, `#RGBA`, `#RRGGBB`, `#RRGGBBAA`\r\n * - `rgb()` / `rgba()` — legacy comma and modern space/slash syntax\r\n * - `hsl()` / `hsla()`\r\n * - `lab()`, `lch()`\r\n * - `oklab()`, `oklch()`\r\n * - Tailwind-style opacity suffix: `\"white/10\"`, `\"primary/90\"` (percent 0–100)\r\n *\r\n * All output values are in the linear 0–1 range suitable for WebGL uniforms.\r\n * Named-color lookup is O(1); all other formats are parsed with lightweight\r\n * regex — no DOM, no `getComputedStyle`.\r\n */\r\n\r\nimport { CSS_COLOR_MAP } from './constants';\r\n\r\n/** Normalized RGBA color: `[red, green, blue, alpha]` each in the 0–1 range. */\r\nexport type NormalizedColor = [number, number, number, number];\r\n\r\n/** Loose color input accepted by prop interfaces — CSS string or pre-normalized tuple. */\r\nexport type Color = string | NormalizedColor;\r\n\r\n// ── Color space helpers ───────────────────────────────────────────────────────\r\n\r\n/** Applies the sRGB gamma curve to a single linear-light channel. */\r\nfunction gammaEncode(c: number): number {\r\n c = Math.max(0, Math.min(1, c));\r\n return c <= 0.0031308 ? 12.92 * c : 1.055 * Math.pow(c, 1 / 2.4) - 0.055;\r\n}\r\n\r\n/** Converts a linear-light sRGB triple to gamma-encoded sRGB. */\r\nfunction linearToSrgb(r: number, g: number, b: number, a: number): NormalizedColor {\r\n return [gammaEncode(r), gammaEncode(g), gammaEncode(b), a];\r\n}\r\n\r\n/** Bradford-adapted XYZ D65 → linear-light sRGB matrix (IEC 61966-2-1). */\r\nfunction xyzD65ToLinearSrgb(X: number, Y: number, Z: number): [number, number, number] {\r\n return [\r\n 3.2404542 * X - 1.5371385 * Y - 0.4985314 * Z,\r\n -0.9692660 * X + 1.8760108 * Y + 0.0415560 * Z,\r\n 0.0556434 * X - 0.2040259 * Y + 1.0572252 * Z,\r\n ];\r\n}\r\n\r\n// ── Argument parser ───────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Splits the inner content of a CSS color function into exactly three channel\r\n * tokens and an alpha value. Handles the slash-alpha syntax used by modern\r\n * `rgb()` / `hsl()` as well as the legacy comma-alpha form used by `rgba()` /\r\n * `hsla()`; both go through {@link readAlpha}, so a percentage alpha means the\r\n * same in either. Returns `null` for the wrong number of arguments or an alpha\r\n * that is not a number, which {@link parseColor} reports as an unsupported\r\n * format.\r\n */\r\nfunction parseArgs(inner: string): { tokens: string[]; alpha: number } | null {\r\n const slashIdx = inner.lastIndexOf('/');\r\n let alphaToken: string | undefined;\r\n let colorPart = inner;\r\n if (slashIdx !== -1) {\r\n alphaToken = inner.slice(slashIdx + 1).trim();\r\n colorPart = inner.slice(0, slashIdx);\r\n }\r\n const tokens = colorPart.trim().split(/[\\s,]+/).filter(Boolean);\r\n if (tokens.length === 4 && alphaToken === undefined) alphaToken = tokens.pop();\r\n if (tokens.length !== 3) return null;\r\n const alpha = alphaToken === undefined ? 1 : readAlpha(alphaToken);\r\n if (!Number.isFinite(alpha)) return null;\r\n return { tokens, alpha };\r\n}\r\n\r\n/** Reads an alpha token: a number, or a percentage (`50%` is 0.5). `NaN` if neither. */\r\nfunction readAlpha(token: string): number {\r\n return token.endsWith('%') ? Number(token.slice(0, -1)) / 100 : Number(token);\r\n}\r\n\r\n/** Reads a channel token as a number, scaling a percentage to `percentScale` and a bare number by `1 / numberScale`. `NaN` if it is not a number. */\r\nfunction readChannel(token: string, percentScale: number, numberScale = 1): number {\r\n return token.endsWith('%') ? (Number(token.slice(0, -1)) / 100) * percentScale : Number(token) / numberScale;\r\n}\r\n\r\n/** Degrees per CSS angle unit (`deg`, `grad`, `rad`, `turn`). */\r\nconst ANGLE_UNIT_DEGREES: Record<string, number> = { deg: 1, grad: 0.9, rad: 180 / Math.PI, turn: 360 };\r\n\r\n/** Reads a CSS hue/angle token to degrees. A bare number is degrees; an unknown unit or a non-number is `NaN`. */\r\nfunction readHue(token: string): number {\r\n const m = token.match(/^([+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:e[+-]?\\d+)?)(deg|grad|rad|turn)?$/);\r\n if (!m) return NaN;\r\n return Number(m[1]) * ANGLE_UNIT_DEGREES[m[2] ?? 'deg'];\r\n}\r\n\r\n/** Returns `color` when every component is finite, otherwise `null` (unsupported format). */\r\nfunction finiteColor(color: NormalizedColor): NormalizedColor | null {\r\n return color.every(Number.isFinite) ? color : null;\r\n}\r\n\r\n// ── Per-format parsers ────────────────────────────────────────────────────────\r\n\r\n// Use a globalThis key so multiple bundled copies of this module (e.g. the\r\n// prebuilt player bundle and the Vite-compiled user code) share one map.\r\nconst _g = globalThis as Record<string, unknown>;\r\nif (!_g.__msThemeMap) _g.__msThemeMap = new Map<string, NormalizedColor>();\r\nconst THEME_COLOR_MAP = _g.__msThemeMap as Map<string, NormalizedColor>;\r\n\r\n// Typography presets ride the same shared-global pattern as the color map, so\r\n// the prebuilt player bundle and the user's Vite-compiled code read one registry\r\n// — `setTheme` (called once per build at the player/headless entry points)\r\n// populates both before any scene generator runs.\r\nif (!_g.__msTypographyMap) _g.__msTypographyMap = new Map<string, Record<string, unknown>>();\r\nconst TYPOGRAPHY_MAP = _g.__msTypographyMap as Map<string, Record<string, unknown>>;\r\n\r\n// Structural mirror of `@/project/config`'s `Theme` (and its color token shape),\r\n// declared locally so this module stays a leaf — `config.ts` imports `Color`\r\n// from here, so importing `Theme` back would be a cycle. The project's `Theme`\r\n// is structurally compatible, so `setTheme(config.theme)` just works.\r\n// `typography` presets are stored opaquely (the parser never reads their fields),\r\n// so the value type is the loose `object` — this stays assignable from `Theme`'s\r\n// `TypographyPreset` (a `TextStyle` interface, which lacks an implicit string\r\n// index signature and so is not a `Record<string, unknown>`).\r\ntype ColorTokenInput = Color | { [key: string]: ColorTokenInput };\r\ninterface ThemeInput {\r\n colors?: Record<string, ColorTokenInput>;\r\n typography?: Record<string, object>;\r\n}\r\n\r\n/**\r\n * Recursively flatten nested color groups into dash-joined, lowercased keys\r\n * (`{ brand: { 500: '#…' } }` → `brand-500`), parsing each leaf to a normalized\r\n * color. Arrays are leaves (a pre-normalized `[R,G,B,A]` tuple); strings are\r\n * leaves; only plain objects recurse.\r\n */\r\nfunction flattenColors(\r\n tokens: Record<string, ColorTokenInput> | undefined,\r\n prefix: string,\r\n out: Map<string, NormalizedColor>,\r\n): void {\r\n if (!tokens) return;\r\n for (const [name, token] of Object.entries(tokens)) {\r\n const key = prefix ? `${prefix}-${name}` : name;\r\n if (token != null && !Array.isArray(token) && typeof token === 'object') {\r\n flattenColors(token as Record<string, ColorTokenInput>, key, out);\r\n } else {\r\n const color = token as Color;\r\n out.set(key.toLowerCase(), Array.isArray(color) ? (color as NormalizedColor) : parseColor(color));\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Registers a project theme: named colors (referenceable by name in any color\r\n * string) and typography presets (selected via a `Text`/`RichText` `variant`).\r\n *\r\n * Color entries take precedence over CSS named colors; nested color groups are\r\n * flattened to dash-joined names (`{ brand: { 500: … } }` → `brand-500`). Call\r\n * with no argument, `null`, or an empty object to clear both registries — a\r\n * document's own `theme` is optional, and a host reading one out of storage\r\n * (a database column, a JSON file) typically gets that absence back as `null`\r\n * rather than `undefined`.\r\n *\r\n * The `default` typography key is reserved: it's read directly by\r\n * {@link applyTextDefaults} (not just via `variant`) and applied to every\r\n * `Text`/`RichText` as a project-wide base style.\r\n *\r\n * @example\r\n * setTheme({\r\n * colors: { brand: \"#ff6b35\", accent: { 500: \"oklch(70% 0.2 145)\" } },\r\n * typography: {\r\n * default: { fontFamily: \"Inter\", fontSize: 32 },\r\n * header: { fontSize: 96, fontWeight: 700 },\r\n * },\r\n * });\r\n * // Later: fill: \"brand\", fill: \"accent-500\", Text({ variant: \"header\" })\r\n */\r\nexport function setTheme(input: ThemeInput | null = {}): void {\r\n const theme = input ?? {};\r\n THEME_COLOR_MAP.clear();\r\n TYPOGRAPHY_MAP.clear();\r\n flattenColors(theme.colors, '', THEME_COLOR_MAP);\r\n if (theme.typography) {\r\n for (const [name, preset] of Object.entries(theme.typography)) {\r\n // Stored opaquely; `applyTextDefaults` reads fields by key. The `object`\r\n // preset is widened to the readable record shape at this boundary only.\r\n TYPOGRAPHY_MAP.set(name.toLowerCase(), preset as Record<string, unknown>);\r\n }\r\n }\r\n}\r\n\r\n/** Looks up a registered typography preset by variant name (case-insensitive);\r\n * `undefined` if none is registered. */\r\nexport function getTypographyPreset(name: string): Record<string, unknown> | undefined {\r\n return TYPOGRAPHY_MAP.get(name.toLowerCase());\r\n}\r\n\r\n/** Looks up a color name in the theme map first, then the CSS named-color table. */\r\nfunction parseNamedColor(str: string): NormalizedColor | null {\r\n return THEME_COLOR_MAP.get(str) ?? CSS_COLOR_MAP.get(str) ?? null;\r\n}\r\n\r\n/** Parses `#RGB`, `#RGBA`, `#RRGGBB`, `#RRGGBBAA` hex strings. */\r\nfunction parseHex(str: string): NormalizedColor | null {\r\n if (!str.startsWith('#')) return null;\r\n let hex = str.slice(1);\r\n if (!/^[0-9a-f]+$/.test(hex)) return null;\r\n // Expand shorthand: #RGB → #RRGGBB, #RGBA → #RRGGBBAA\r\n if (hex.length === 3 || hex.length === 4)\r\n hex = hex.split('').map(c => c + c).join('');\r\n const int = parseInt(hex, 16);\r\n if (hex.length === 6)\r\n return [(int >> 16 & 255) / 255, (int >> 8 & 255) / 255, (int & 255) / 255, 1];\r\n if (hex.length === 8)\r\n return [(int >>> 24) / 255, (int >> 16 & 255) / 255, (int >> 8 & 255) / 255, (int & 255) / 255];\r\n return null;\r\n}\r\n\r\n/** Parses `rgb()` / `rgba()` — both percentage and 0-255 channel forms. */\r\nfunction parseRgb(str: string): NormalizedColor | null {\r\n const m = str.match(/^rgba?\\s*\\((.+)\\)/);\r\n if (!m) return null;\r\n const args = parseArgs(m[1]);\r\n if (!args) return null;\r\n const [r, g, b] = args.tokens.map(t => readChannel(t, 1, 255));\r\n return finiteColor([r, g, b, args.alpha]);\r\n}\r\n\r\n/** Parses `hsl()` / `hsla()`. The hue takes `deg`, `grad`, `rad` or `turn` (a bare number is degrees). */\r\nfunction parseHsl(str: string): NormalizedColor | null {\r\n const m = str.match(/^hsla?\\s*\\((.+)\\)/);\r\n if (!m) return null;\r\n const args = parseArgs(m[1]);\r\n if (!args) return null;\r\n const h = readHue(args.tokens[0]);\r\n const s = parseFloat(args.tokens[1]) / 100;\r\n const l = parseFloat(args.tokens[2]) / 100;\r\n const k = (n: number) => (((n + h / 30) % 12) + 12) % 12;\r\n const chroma = s * Math.min(l, 1 - l);\r\n const f = (n: number) => l - chroma * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));\r\n return finiteColor([f(0), f(8), f(4), args.alpha]);\r\n}\r\n\r\n/** Parses `lab(L a b)` (CIE L*a*b*, D50 white point). */\r\nfunction parseLab(str: string): NormalizedColor | null {\r\n const m = str.match(/^lab\\s*\\((.+)\\)/);\r\n if (!m) return null;\r\n const args = parseArgs(m[1]);\r\n if (!args) return null;\r\n const L = parseFloat(args.tokens[0]);\r\n const a = parseFloat(args.tokens[1]);\r\n const b = parseFloat(args.tokens[2]);\r\n return finiteColor(labToNormalized(L, a, b, args.alpha));\r\n}\r\n\r\n/** Parses `lch(L C H)` (CIE L*C*h°, polar form of Lab). */\r\nfunction parseLch(str: string): NormalizedColor | null {\r\n const m = str.match(/^lch\\s*\\((.+)\\)/);\r\n if (!m) return null;\r\n const args = parseArgs(m[1]);\r\n if (!args) return null;\r\n const L = parseFloat(args.tokens[0]);\r\n const C = parseFloat(args.tokens[1]);\r\n const rad = readHue(args.tokens[2]) * (Math.PI / 180);\r\n return finiteColor(labToNormalized(L, C * Math.cos(rad), C * Math.sin(rad), args.alpha));\r\n}\r\n\r\n/** Parses `oklab(L a b)` (Oklab perceptually uniform color space). */\r\nfunction parseOklab(str: string): NormalizedColor | null {\r\n const m = str.match(/^oklab\\s*\\((.+)\\)/);\r\n if (!m) return null;\r\n const args = parseArgs(m[1]);\r\n if (!args) return null;\r\n // L: 0–1 as number, or 0%–100% (100% = 1); a, b: 100% = 0.4 per CSS Color 4.\r\n const [L, a, b] = [readChannel(args.tokens[0], 1), readChannel(args.tokens[1], 0.4), readChannel(args.tokens[2], 0.4)];\r\n return finiteColor(oklabToNormalized(L, a, b, args.alpha));\r\n}\r\n\r\n/** Parses `oklch(L C H)` (polar form of Oklab). */\r\nfunction parseOklch(str: string): NormalizedColor | null {\r\n const m = str.match(/^oklch\\s*\\((.+)\\)/);\r\n if (!m) return null;\r\n const args = parseArgs(m[1]);\r\n if (!args) return null;\r\n // L: 0–1 or percentage; C: 0–0.4 or percentage (100% = 0.4).\r\n const L = readChannel(args.tokens[0], 1);\r\n const C = readChannel(args.tokens[1], 0.4);\r\n const rad = readHue(args.tokens[2]) * (Math.PI / 180);\r\n return finiteColor(oklabToNormalized(L, C * Math.cos(rad), C * Math.sin(rad), args.alpha));\r\n}\r\n\r\n// ── CIE conversion helpers ────────────────────────────────────────────────────\r\n\r\n/** Converts CIE L*a*b* (D50) to a normalized sRGB color. */\r\nfunction labToNormalized(L: number, a: number, b: number, alpha: number): NormalizedColor {\r\n const e = 0.008856, k = 903.3;\r\n const fy = (L + 16) / 116;\r\n const fx = a / 500 + fy;\r\n const fz = fy - b / 200;\r\n const X = (fx ** 3 > e ? fx ** 3 : (116 * fx - 16) / k) * 0.95047;\r\n const Y = L > k * e ? ((L + 16) / 116) ** 3 : L / k;\r\n const Z = (fz ** 3 > e ? fz ** 3 : (116 * fz - 16) / k) * 1.08883;\r\n const [lr, lg, lb] = xyzD65ToLinearSrgb(X, Y, Z);\r\n return linearToSrgb(lr, lg, lb, alpha);\r\n}\r\n\r\n/** Converts Oklab to a normalized sRGB color using the standard Björn Ottosson matrix. */\r\nfunction oklabToNormalized(L: number, a: number, b: number, alpha: number): NormalizedColor {\r\n const l_ = L + 0.3963377774 * a + 0.2158037573 * b;\r\n const m_ = L - 0.1055613458 * a - 0.0638541728 * b;\r\n const s_ = L - 0.0894841775 * a - 1.2914855480 * b;\r\n const l = l_ ** 3, m = m_ ** 3, s = s_ ** 3;\r\n return linearToSrgb(\r\n 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,\r\n -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,\r\n -0.0041960863 * l - 0.7034186147 * m + 1.6956065236 * s,\r\n alpha,\r\n );\r\n}\r\n\r\n// ── Opacity suffix ─────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Splits a Tailwind-style opacity suffix (`\"white/10\"`, `\"primary/90\"`) off the\r\n * end of a color string. The suffix is a slash followed by a number (optionally\r\n * with a `%`) interpreted as a percentage 0–100.\r\n *\r\n * Only a trailing slash that sits *outside* any parentheses is treated as an\r\n * opacity modifier, so the internal slash-alpha syntax of `rgb()` / `hsl()`\r\n * (e.g. `rgb(0 0 255 / 0.25)`) is left untouched.\r\n *\r\n * @returns the bare color string and the opacity fraction (1 when absent).\r\n */\r\nfunction splitOpacitySuffix(str: string): { color: string; opacity: number } {\r\n if (str.includes('(')) return { color: str, opacity: 1 };\r\n const m = str.match(/^(.*[^/])\\/\\s*([\\d.]+)%?$/);\r\n if (!m) return { color: str, opacity: 1 };\r\n const pct = parseFloat(m[2]);\r\n if (!Number.isFinite(pct)) return { color: str, opacity: 1 };\r\n return { color: m[1].trim(), opacity: Math.max(0, Math.min(1, pct / 100)) };\r\n}\r\n\r\n// ── Main entry point ──────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Parses a CSS color string into a normalized `[R, G, B, A]` array (0.0–1.0).\r\n *\r\n * Supported formats: named colors (CSS + theme), hex, rgb/rgba, hsl/hsla,\r\n * lab, lch, oklab, oklch, plus a Tailwind-style opacity suffix (`\"white/10\"`).\r\n * Falls back to opaque black and logs a warning for unrecognised input.\r\n */\r\nexport function parseColor(cssStr: string): NormalizedColor {\r\n const { color: str, opacity } = splitOpacitySuffix(cssStr.trim().toLowerCase());\r\n const parsed =\r\n parseNamedColor(str) ??\r\n parseHex(str) ??\r\n parseRgb(str) ??\r\n parseHsl(str) ??\r\n parseLab(str) ??\r\n parseLch(str) ??\r\n parseOklab(str) ??\r\n parseOklch(str) ??\r\n (console.warn(`[Motion Engine] Unsupported color format: \"${cssStr}\". Defaulting to black.`), [0, 0, 0, 1] as NormalizedColor);\r\n // Clone before applying opacity: named/theme lookups return cached tuples.\r\n if (opacity !== 1) return [parsed[0], parsed[1], parsed[2], parsed[3] * opacity];\r\n return parsed;\r\n}\r\n"]}
|
|
@@ -9,8 +9,8 @@ import type { Scene3D } from '../../../../render3d/scene3d.js';
|
|
|
9
9
|
* `Ellipse`, a `Path`, a run of `Text` — stacks with the other fills in the
|
|
10
10
|
* array, and inherits the fill layer's `opacity`/`blend`/`space` like any other.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* Ellipse({ fill: Fills.canvas3D(scene) })
|
|
13
|
+
* Rect({ fill: ["#0b0d12", scene, Fills.linearGradient(["transparent", "#000/60"])] })
|
|
14
14
|
*
|
|
15
15
|
* The payload is a **built** {@link Scene3D}, never a builder callback. Per-frame
|
|
16
16
|
* freshness comes from where the value is produced — a `renderSelf` runs every
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas3d.js","sourceRoot":"","sources":["../../../../../src/attributes/shape/fill/implementations/canvas3d.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AA6CzD,MAAM,CAAC,MAAM,YAAY,GAAmC;IACxD,8EAA8E;IAC9E,qEAAqE;IACrE,OAAO,EAAE,CAAC,IAAsB,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC;IAElD,8EAA8E;IAC9E,8EAA8E;IAC9E,+EAA+E;IAC/E,+EAA+E;IAC/E,8EAA8E;IAC9E,2DAA2D;IAC3D,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAChB,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK;QAClC,aAAa,EAAE,CAAC,CAAC,aAAa,IAAI,CAAC,CAAC,aAAa;QACjD,SAAS,EAAE,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,SAAS;QACrC,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;KACxE,CAAC;IAEF,2EAA2E;IAC3E,8EAA8E;IAC9E,wDAAwD;IACxD,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK;IAErC,2EAA2E;IAC3E,qCAAqC;IACrC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;QACtB,kBAAkB,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC;CACJ,CAAC","sourcesContent":["import type { BlendMode } from '../blend';\r\nimport type { FillData } from '../registry';\r\nimport type { Scene3D } from '@/render3d/scene3d';\r\nimport { declare3DResources } from '@/render3d/tracking';\r\n\r\n/**\r\n * A 3D scene, painted as a fill.\r\n *\r\n * 3D is paint, not structure: the renderer draws the scene to a texture and\r\n * shades the shape's own path with it. So it clips to whatever painted it — an\r\n * `Ellipse`, a `Path`, a run of `Text` — stacks with the other fills in the\r\n * array, and inherits the fill layer's `opacity`/`blend`/`space` like any other.\r\n *\r\n *
|
|
1
|
+
{"version":3,"file":"canvas3d.js","sourceRoot":"","sources":["../../../../../src/attributes/shape/fill/implementations/canvas3d.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AA6CzD,MAAM,CAAC,MAAM,YAAY,GAAmC;IACxD,8EAA8E;IAC9E,qEAAqE;IACrE,OAAO,EAAE,CAAC,IAAsB,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC;IAElD,8EAA8E;IAC9E,8EAA8E;IAC9E,+EAA+E;IAC/E,+EAA+E;IAC/E,8EAA8E;IAC9E,2DAA2D;IAC3D,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAChB,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK;QAClC,aAAa,EAAE,CAAC,CAAC,aAAa,IAAI,CAAC,CAAC,aAAa;QACjD,SAAS,EAAE,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,SAAS;QACrC,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;KACxE,CAAC;IAEF,2EAA2E;IAC3E,8EAA8E;IAC9E,wDAAwD;IACxD,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK;IAErC,2EAA2E;IAC3E,qCAAqC;IACrC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;QACtB,kBAAkB,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC;CACJ,CAAC","sourcesContent":["import type { BlendMode } from '../blend';\r\nimport type { FillData } from '../registry';\r\nimport type { Scene3D } from '@/render3d/scene3d';\r\nimport { declare3DResources } from '@/render3d/tracking';\r\n\r\n/**\r\n * A 3D scene, painted as a fill.\r\n *\r\n * 3D is paint, not structure: the renderer draws the scene to a texture and\r\n * shades the shape's own path with it. So it clips to whatever painted it — an\r\n * `Ellipse`, a `Path`, a run of `Text` — stacks with the other fills in the\r\n * array, and inherits the fill layer's `opacity`/`blend`/`space` like any other.\r\n *\r\n * Ellipse({ fill: Fills.canvas3D(scene) })\r\n * Rect({ fill: [\"#0b0d12\", scene, Fills.linearGradient([\"transparent\", \"#000/60\"])] })\r\n *\r\n * The payload is a **built** {@link Scene3D}, never a builder callback. Per-frame\r\n * freshness comes from where the value is produced — a `renderSelf` runs every\r\n * frame, and a `() => …` prop is an ordinary reactive binding — which is exactly\r\n * how every other fill behaves.\r\n */\r\nexport interface Canvas3DFillProp {\r\n type: 'canvas3D';\r\n /** The scene to draw. Rebuilt by its producer each frame; never a callback. */\r\n scene: Scene3D;\r\n /**\r\n * Ceiling on the 3D buffer's device-pixel ratio. Default 2.\r\n *\r\n * Exists so a high-scale export doesn't allocate a quadratically larger\r\n * render buffer than the scene needs — a 4× export of a 1080p shape would\r\n * otherwise ask for a 16× buffer.\r\n */\r\n maxPixelRatio?: number;\r\n /** Multisample the 3D pass. Default true. */\r\n antialias?: boolean;\r\n opacity?: number;\r\n blend?: BlendMode;\r\n}\r\n\r\nexport interface Canvas3DFillResolved {\r\n type: 'canvas3D';\r\n scene: Scene3D;\r\n maxPixelRatio?: number;\r\n antialias?: boolean;\r\n opacity?: number;\r\n blend?: BlendMode;\r\n}\r\n\r\nexport const canvas3DFill: FillData<Canvas3DFillResolved> = {\r\n // Nothing to normalise — the defaults for maxPixelRatio/antialias are applied\r\n // at render time so the resolved shape stays minimal and comparable.\r\n resolve: (prop: Canvas3DFillProp) => ({ ...prop }),\r\n\r\n // A scene is a command list: there is no meaningful value halfway between two\r\n // of them, so it snaps, exactly as an image fill's `src` does. Only `opacity`\r\n // interpolates. Deliberately returns neither `type` nor `blend` — `FillResult`\r\n // omits both and `lerpFill` reassembles via `{ ...a, ...lerp(...) }`, which is\r\n // also what makes the ragged-array self-pair (a fill fading against a copy of\r\n // itself, when the two fill arrays differ in length) work.\r\n lerp: (a, b, t) => ({\r\n scene: t < 0.5 ? a.scene : b.scene,\r\n maxPixelRatio: a.maxPixelRatio ?? b.maxPixelRatio,\r\n antialias: a.antialias ?? b.antialias,\r\n opacity: (a.opacity ?? 1) + ((b.opacity ?? 1) - (a.opacity ?? 1)) * t,\r\n }),\r\n\r\n // Reference identity is the only comparison a Scene3D supports — it has no\r\n // structural hash and `ops()` returns its live array. Nothing in the codebase\r\n // calls this today; it exists to satisfy the interface.\r\n equals: (a, b) => a.scene === b.scene,\r\n\r\n // Runs off the same descriptors the renderer consumes, so what gets loaded\r\n // cannot drift from what gets drawn.\r\n declare: (fill, assets) => {\r\n declare3DResources(fill.scene, assets);\r\n },\r\n};\r\n"]}
|
|
@@ -19,8 +19,8 @@ export interface ShaderTexture {
|
|
|
19
19
|
* `Path`, a run of `Text` — stacks as one layer in the fill array, and inherits
|
|
20
20
|
* the layer's `opacity`/`blend`/`space` like every other kind.
|
|
21
21
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
22
|
+
* Rect({ fill: Fills.shader(src, { uniforms: { u_amount: 0.4 } }) })
|
|
23
|
+
* Text({ text: "DEPTH", fontSize: 320, fill: Fills.shader(src) })
|
|
24
24
|
*
|
|
25
25
|
* The contract on the source is `vec4 main(vec2 fragCoord)` returning
|
|
26
26
|
* **premultiplied** rgba. It must *not* fold `opacity` in: the fill layer's
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader.js","sourceRoot":"","sources":["../../../../../src/attributes/shape/fill/implementations/shader.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,GAItB,MAAM,qBAAqB,CAAC;AAI7B;;;;GAIG;AACH,MAAM,YAAY,GAAG,CAAC,CAAC;AAuFvB,gFAAgF;AAChF,SAAS,eAAe,CAAC,QAA8C;IACnE,IAAI,CAAC,QAAQ,EAAE,MAAM;QAAE,OAAO,SAAS,CAAC;IACxC,MAAM,GAAG,GAAoB,EAAE,CAAC;IAChC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC7B,IAAI,CAAC,OAAO,EAAE,IAAI,IAAI,CAAC,OAAO,EAAE,GAAG;YAAE,SAAS;QAC9C,IAAI,GAAG,CAAC,MAAM,IAAI,YAAY,EAAE,CAAC;YAC7B,OAAO,CAAC,IAAI,CAAC,2CAA2C,YAAY,kCAAkC,CAAC,CAAC;YACxG,MAAM;QACV,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;AACxC,CAAC;AAED,SAAS,aAAa,CAAC,CAA8B,EAAE,CAA8B;IACjF,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACzB,IAA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AC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM;QACrC,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QACtD,MAAM,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM;QACrC,QAAQ,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ;QAC3C,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;KACxE,CAAC;IAEF,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACb,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;QACrB,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;QACrB,mBAAmB,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC;QAC3C,aAAa,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC;IAEzC,8EAA8E;IAC9E,gCAAgC;IAChC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;QACtB,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,IAAI,EAAE;YAAE,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACzE,CAAC;CACJ,CAAC","sourcesContent":["import type { BlendMode } from '../blend';\r\nimport type { FillData } from '../registry';\r\nimport {\r\n lerpUniformRecord,\r\n normalizeUniforms,\r\n uniformRecordsEqual,\r\n type ShaderFillCoords,\r\n type SkSLUniform,\r\n type SkSLUniformRecord,\r\n} from '../../sksl-uniforms';\r\n\r\nexport type { ShaderFillCoords };\r\n\r\n/**\r\n * Ceiling on bound samplers. Skia has no hard limit here, but a fill wanting more\r\n * than a handful of textures is really a 3D scene, and the cap keeps a typo in a\r\n * generated list from exhausting texture units.\r\n */\r\nconst MAX_TEXTURES = 4;\r\n\r\n/** An image bound to one of the shader's `uniform shader` declarations. */\r\nexport interface ShaderTexture {\r\n /** The `uniform shader` name in the source this image binds to. */\r\n name: string;\r\n /** Asset path, resolved like any other image fill's `src`. */\r\n src: string;\r\n}\r\n\r\n/**\r\n * A custom SkSL shader, painted as a fill.\r\n *\r\n * The escape hatch at the end of the procedural spectrum: where\r\n * {@link NoiseFillProp} and {@link FractalNoiseFillProp} expose a fixed set of\r\n * knobs over a fixed field, this hands the whole fragment function to the author.\r\n * It is still a fill, so it paints inside the shape's own path — an `Ellipse`, a\r\n * `Path`, a run of `Text` — stacks as one layer in the fill array, and inherits\r\n * the layer's `opacity`/`blend`/`space` like every other kind.\r\n *\r\n * <Rect fill={Fills.shader(src, { uniforms: { u_amount: 0.4 } })} />\r\n * <Text text=\"DEPTH\" fontSize={320} fill={Fills.shader(src)} />\r\n *\r\n * The contract on the source is `vec4 main(vec2 fragCoord)` returning\r\n * **premultiplied** rgba. It must *not* fold `opacity` in: the fill layer's\r\n * opacity is already on the paint as an alpha the shader's output is modulated\r\n * by, so a shader applying it again renders at the square of what was asked for.\r\n * That is also why no `u_alpha` built-in is offered.\r\n *\r\n * Uniforms are supplied **by name**, not by position, and marshalled by\r\n * reflecting the compiled program. So declaration order doesn't matter, a\r\n * declared-but-unsupplied uniform reads as zero with a warning instead of\r\n * silently refusing to paint, and the renderer can fill in built-ins\r\n * (`u_size`, `u_origin`, `u_resolution`, `u_aspect`, `u_time`, `u_scale`) for\r\n * whichever of them the source happens to declare.\r\n *\r\n * `source` is the compile-cache key, so it **snaps** at a tween's midpoint rather\r\n * than interpolating — tweening it would compile a program per frame. Keep the\r\n * source constant (hoist it to module scope) and put everything that changes in a\r\n * uniform, which costs nothing: uniform values are an in-place write.\r\n */\r\nexport interface ShaderFillProp {\r\n type: 'shader';\r\n /** SkSL source declaring `vec4 main(vec2 fragCoord)`. Hoist it; don't rebuild it per frame. */\r\n source: string;\r\n /**\r\n * The shader pack this was built from, when it was built from one.\r\n *\r\n * **Reserved, and carried rather than read.** A pack resolves to a plain\r\n * uniform record before it reaches here, so nothing in the render path needs\r\n * it — the frame is identical with or without it. What it exists for is the\r\n * trip back: a document stores resolved uniforms, and without a reference to\r\n * the pack a host reopening a saved scene has a set of numbers and no way to\r\n * know which of them were `twist` and `ink`, so the property panel it drew\r\n * when the shader was applied cannot be drawn again.\r\n *\r\n * An id naming a pack that is not registered is **not** an error: the shader\r\n * still renders, because the uniforms it needs are already in the document.\r\n * The host simply cannot offer the panel.\r\n */\r\n shaderId?: string;\r\n /**\r\n * Uniform values keyed by their declared name. The `sksl` effect's positional\r\n * `[{name, value}]` array is accepted too, so a shader can move between an\r\n * effect and a fill unchanged.\r\n */\r\n uniforms?: SkSLUniformRecord | readonly SkSLUniform[];\r\n /** What `fragCoord` means. Default `'normalized'`. See {@link ShaderFillCoords}. */\r\n coords?: ShaderFillCoords;\r\n /** Images bound to the source's `uniform shader` declarations, matched by name. */\r\n textures?: readonly ShaderTexture[];\r\n opacity?: number;\r\n blend?: BlendMode;\r\n}\r\n\r\nexport interface ShaderFillResolved {\r\n type: 'shader';\r\n source: string;\r\n /** See {@link ShaderFillProp.shaderId}. */\r\n shaderId?: string;\r\n uniforms: SkSLUniformRecord;\r\n coords: ShaderFillCoords;\r\n textures?: ShaderTexture[];\r\n opacity?: number;\r\n blend?: BlendMode;\r\n}\r\n\r\n/** Copy the texture list, dropping malformed entries and capping the length. */\r\nfunction resolveTextures(textures: readonly ShaderTexture[] | undefined): ShaderTexture[] | undefined {\r\n if (!textures?.length) return undefined;\r\n const out: ShaderTexture[] = [];\r\n for (const texture of textures) {\r\n if (!texture?.name || !texture?.src) continue;\r\n if (out.length >= MAX_TEXTURES) {\r\n console.warn(`[SkSL] A shader fill declares more than ${MAX_TEXTURES} textures; the rest are ignored.`);\r\n break;\r\n }\r\n out.push({ name: texture.name, src: texture.src });\r\n }\r\n return out.length ? out : undefined;\r\n}\r\n\r\nfunction texturesEqual(a: ShaderTexture[] | undefined, b: ShaderTexture[] | undefined): boolean {\r\n if (a === b) return true;\r\n if (!a || !b || a.length !== b.length) return false;\r\n return a.every((t, i) => t.name === b[i].name && t.src === b[i].src);\r\n}\r\n\r\nexport const shaderFill: FillData<ShaderFillResolved> = {\r\n resolve: (prop: ShaderFillProp) => ({\r\n type: 'shader',\r\n source: prop.source ?? '',\r\n // Carried, never read: see `ShaderFillProp.shaderId`. Omitted when absent\r\n // so `equals` compares like with like for a fill that never had one.\r\n ...(prop.shaderId !== undefined ? { shaderId: prop.shaderId } : {}),\r\n // Normalised (and key-sorted) here rather than at paint time so `equals`\r\n // and any structural diff see the same canonical record the renderer\r\n // marshals, whichever authoring shape it came in as.\r\n uniforms: normalizeUniforms(prop.uniforms),\r\n coords: prop.coords ?? 'normalized',\r\n textures: resolveTextures(prop.textures),\r\n opacity: prop.opacity,\r\n blend: prop.blend,\r\n }),\r\n\r\n // `source`, `coords` and `textures` snap; only the uniform values and\r\n // `opacity` interpolate. The source is `getOrCompileSkSL`'s cache key, so\r\n // there is nothing halfway between two programs to cross to — the same reason\r\n // an image fill's `src` and a 3D fill's scene snap. `coords` is a discrete\r\n // matrix and a texture list is a discrete set of bindings.\r\n //\r\n // Deliberately returns neither `type` nor `blend`: `FillResult` omits both and\r\n // `lerpFill` reassembles via `{ ...a, ...lerp(...) }`, which is also what makes\r\n // the ragged-array self-pair (a fill fading against a copy of itself, when two\r\n // fill arrays differ in length) work.\r\n lerp: (a, b, t) => ({\r\n source: t < 0.5 ? a.source : b.source,\r\n uniforms: lerpUniformRecord(a.uniforms, b.uniforms, t),\r\n coords: t < 0.5 ? a.coords : b.coords,\r\n textures: t < 0.5 ? a.textures : b.textures,\r\n opacity: (a.opacity ?? 1) + ((b.opacity ?? 1) - (a.opacity ?? 1)) * t,\r\n }),\r\n\r\n equals: (a, b) =>\r\n a.source === b.source &&\r\n a.coords === b.coords &&\r\n uniformRecordsEqual(a.uniforms, b.uniforms) &&\r\n texturesEqual(a.textures, b.textures),\r\n\r\n // Runs off the same descriptors the renderer binds, so what gets loaded can't\r\n // drift from what gets sampled.\r\n declare: (fill, assets) => {\r\n for (const texture of fill.textures ?? []) assets.image(texture.src);\r\n },\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"shader.js","sourceRoot":"","sources":["../../../../../src/attributes/shape/fill/implementations/shader.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,GAItB,MAAM,qBAAqB,CAAC;AAI7B;;;;GAIG;AACH,MAAM,YAAY,GAAG,CAAC,CAAC;AAuFvB,gFAAgF;AAChF,SAAS,eAAe,CAAC,QAA8C;IACnE,IAAI,CAAC,QAAQ,EAAE,MAAM;QAAE,OAAO,SAAS,CAAC;IACxC,MAAM,GAAG,GAAoB,EAAE,CAAC;IAChC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC7B,IAAI,CAAC,OAAO,EAAE,IAAI,IAAI,CAAC,OAAO,EAAE,GAAG;YAAE,SAAS;QAC9C,IAAI,GAAG,CAAC,MAAM,IAAI,YAAY,EAAE,CAAC;YAC7B,OAAO,CAAC,IAAI,CAAC,2CAA2C,YAAY,kCAAkC,CAAC,CAAC;YACxG,MAAM;QACV,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;AACxC,CAAC;AAED,SAAS,aAA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../registry';\r\nimport {\r\n lerpUniformRecord,\r\n normalizeUniforms,\r\n uniformRecordsEqual,\r\n type ShaderFillCoords,\r\n type SkSLUniform,\r\n type SkSLUniformRecord,\r\n} from '../../sksl-uniforms';\r\n\r\nexport type { ShaderFillCoords };\r\n\r\n/**\r\n * Ceiling on bound samplers. Skia has no hard limit here, but a fill wanting more\r\n * than a handful of textures is really a 3D scene, and the cap keeps a typo in a\r\n * generated list from exhausting texture units.\r\n */\r\nconst MAX_TEXTURES = 4;\r\n\r\n/** An image bound to one of the shader's `uniform shader` declarations. */\r\nexport interface ShaderTexture {\r\n /** The `uniform shader` name in the source this image binds to. */\r\n name: string;\r\n /** Asset path, resolved like any other image fill's `src`. */\r\n src: string;\r\n}\r\n\r\n/**\r\n * A custom SkSL shader, painted as a fill.\r\n *\r\n * The escape hatch at the end of the procedural spectrum: where\r\n * {@link NoiseFillProp} and {@link FractalNoiseFillProp} expose a fixed set of\r\n * knobs over a fixed field, this hands the whole fragment function to the author.\r\n * It is still a fill, so it paints inside the shape's own path — an `Ellipse`, a\r\n * `Path`, a run of `Text` — stacks as one layer in the fill array, and inherits\r\n * the layer's `opacity`/`blend`/`space` like every other kind.\r\n *\r\n * Rect({ fill: Fills.shader(src, { uniforms: { u_amount: 0.4 } }) })\r\n * Text({ text: \"DEPTH\", fontSize: 320, fill: Fills.shader(src) })\r\n *\r\n * The contract on the source is `vec4 main(vec2 fragCoord)` returning\r\n * **premultiplied** rgba. It must *not* fold `opacity` in: the fill layer's\r\n * opacity is already on the paint as an alpha the shader's output is modulated\r\n * by, so a shader applying it again renders at the square of what was asked for.\r\n * That is also why no `u_alpha` built-in is offered.\r\n *\r\n * Uniforms are supplied **by name**, not by position, and marshalled by\r\n * reflecting the compiled program. So declaration order doesn't matter, a\r\n * declared-but-unsupplied uniform reads as zero with a warning instead of\r\n * silently refusing to paint, and the renderer can fill in built-ins\r\n * (`u_size`, `u_origin`, `u_resolution`, `u_aspect`, `u_time`, `u_scale`) for\r\n * whichever of them the source happens to declare.\r\n *\r\n * `source` is the compile-cache key, so it **snaps** at a tween's midpoint rather\r\n * than interpolating — tweening it would compile a program per frame. Keep the\r\n * source constant (hoist it to module scope) and put everything that changes in a\r\n * uniform, which costs nothing: uniform values are an in-place write.\r\n */\r\nexport interface ShaderFillProp {\r\n type: 'shader';\r\n /** SkSL source declaring `vec4 main(vec2 fragCoord)`. Hoist it; don't rebuild it per frame. */\r\n source: string;\r\n /**\r\n * The shader pack this was built from, when it was built from one.\r\n *\r\n * **Reserved, and carried rather than read.** A pack resolves to a plain\r\n * uniform record before it reaches here, so nothing in the render path needs\r\n * it — the frame is identical with or without it. What it exists for is the\r\n * trip back: a document stores resolved uniforms, and without a reference to\r\n * the pack a host reopening a saved scene has a set of numbers and no way to\r\n * know which of them were `twist` and `ink`, so the property panel it drew\r\n * when the shader was applied cannot be drawn again.\r\n *\r\n * An id naming a pack that is not registered is **not** an error: the shader\r\n * still renders, because the uniforms it needs are already in the document.\r\n * The host simply cannot offer the panel.\r\n */\r\n shaderId?: string;\r\n /**\r\n * Uniform values keyed by their declared name. The `sksl` effect's positional\r\n * `[{name, value}]` array is accepted too, so a shader can move between an\r\n * effect and a fill unchanged.\r\n */\r\n uniforms?: SkSLUniformRecord | readonly SkSLUniform[];\r\n /** What `fragCoord` means. Default `'normalized'`. See {@link ShaderFillCoords}. */\r\n coords?: ShaderFillCoords;\r\n /** Images bound to the source's `uniform shader` declarations, matched by name. */\r\n textures?: readonly ShaderTexture[];\r\n opacity?: number;\r\n blend?: BlendMode;\r\n}\r\n\r\nexport interface ShaderFillResolved {\r\n type: 'shader';\r\n source: string;\r\n /** See {@link ShaderFillProp.shaderId}. */\r\n shaderId?: string;\r\n uniforms: SkSLUniformRecord;\r\n coords: ShaderFillCoords;\r\n textures?: ShaderTexture[];\r\n opacity?: number;\r\n blend?: BlendMode;\r\n}\r\n\r\n/** Copy the texture list, dropping malformed entries and capping the length. */\r\nfunction resolveTextures(textures: readonly ShaderTexture[] | undefined): ShaderTexture[] | undefined {\r\n if (!textures?.length) return undefined;\r\n const out: ShaderTexture[] = [];\r\n for (const texture of textures) {\r\n if (!texture?.name || !texture?.src) continue;\r\n if (out.length >= MAX_TEXTURES) {\r\n console.warn(`[SkSL] A shader fill declares more than ${MAX_TEXTURES} textures; the rest are ignored.`);\r\n break;\r\n }\r\n out.push({ name: texture.name, src: texture.src });\r\n }\r\n return out.length ? out : undefined;\r\n}\r\n\r\nfunction texturesEqual(a: ShaderTexture[] | undefined, b: ShaderTexture[] | undefined): boolean {\r\n if (a === b) return true;\r\n if (!a || !b || a.length !== b.length) return false;\r\n return a.every((t, i) => t.name === b[i].name && t.src === b[i].src);\r\n}\r\n\r\nexport const shaderFill: FillData<ShaderFillResolved> = {\r\n resolve: (prop: ShaderFillProp) => ({\r\n type: 'shader',\r\n source: prop.source ?? '',\r\n // Carried, never read: see `ShaderFillProp.shaderId`. Omitted when absent\r\n // so `equals` compares like with like for a fill that never had one.\r\n ...(prop.shaderId !== undefined ? { shaderId: prop.shaderId } : {}),\r\n // Normalised (and key-sorted) here rather than at paint time so `equals`\r\n // and any structural diff see the same canonical record the renderer\r\n // marshals, whichever authoring shape it came in as.\r\n uniforms: normalizeUniforms(prop.uniforms),\r\n coords: prop.coords ?? 'normalized',\r\n textures: resolveTextures(prop.textures),\r\n opacity: prop.opacity,\r\n blend: prop.blend,\r\n }),\r\n\r\n // `source`, `coords` and `textures` snap; only the uniform values and\r\n // `opacity` interpolate. The source is `getOrCompileSkSL`'s cache key, so\r\n // there is nothing halfway between two programs to cross to — the same reason\r\n // an image fill's `src` and a 3D fill's scene snap. `coords` is a discrete\r\n // matrix and a texture list is a discrete set of bindings.\r\n //\r\n // Deliberately returns neither `type` nor `blend`: `FillResult` omits both and\r\n // `lerpFill` reassembles via `{ ...a, ...lerp(...) }`, which is also what makes\r\n // the ragged-array self-pair (a fill fading against a copy of itself, when two\r\n // fill arrays differ in length) work.\r\n lerp: (a, b, t) => ({\r\n source: t < 0.5 ? a.source : b.source,\r\n uniforms: lerpUniformRecord(a.uniforms, b.uniforms, t),\r\n coords: t < 0.5 ? a.coords : b.coords,\r\n textures: t < 0.5 ? a.textures : b.textures,\r\n opacity: (a.opacity ?? 1) + ((b.opacity ?? 1) - (a.opacity ?? 1)) * t,\r\n }),\r\n\r\n equals: (a, b) =>\r\n a.source === b.source &&\r\n a.coords === b.coords &&\r\n uniformRecordsEqual(a.uniforms, b.uniforms) &&\r\n texturesEqual(a.textures, b.textures),\r\n\r\n // Runs off the same descriptors the renderer binds, so what gets loaded can't\r\n // drift from what gets sampled.\r\n declare: (fill, assets) => {\r\n for (const texture of fill.textures ?? []) assets.image(texture.src);\r\n },\r\n};\r\n"]}
|
|
@@ -89,7 +89,7 @@ export interface VideoFillResolved {
|
|
|
89
89
|
* the same way a motion blur is resolved against the node's sampled velocity.
|
|
90
90
|
* Deriving it at draw time (rather than advancing a stored timestamp each tick)
|
|
91
91
|
* is what lets a video fill play anywhere paint is accepted — stroke, shadow,
|
|
92
|
-
* text
|
|
92
|
+
* a text run, a component's raw `Graphics2D` — instead of only on the two
|
|
93
93
|
* nodes that remembered to update it. It also makes frame *N* identical however
|
|
94
94
|
* the playhead reached it, so scrubbing and export agree with playback.
|
|
95
95
|
*
|
|
@@ -9,7 +9,7 @@ import { declareMediaPreset, lerpMediaPreset, resolveMediaPreset, } from '../med
|
|
|
9
9
|
* the same way a motion blur is resolved against the node's sampled velocity.
|
|
10
10
|
* Deriving it at draw time (rather than advancing a stored timestamp each tick)
|
|
11
11
|
* is what lets a video fill play anywhere paint is accepted — stroke, shadow,
|
|
12
|
-
* text
|
|
12
|
+
* a text run, a component's raw `Graphics2D` — instead of only on the two
|
|
13
13
|
* nodes that remembered to update it. It also makes frame *N* identical however
|
|
14
14
|
* the playhead reached it, so scrubbing and export agree with playback.
|
|
15
15
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"video.js","sourceRoot":"","sources":["../../../../../src/attributes/shape/fill/impl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AoD;QACpD,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;KACjD,CAAC;IACF,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG;IACjC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;QACtB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;QAC1E,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,CAAC;CACJ,CAAC","sourcesContent":["import type { BlendMode } from '../blend';\r\nimport type { MediaAdjustment, VideoOnlyAdjustment } from '../../filters/union';\r\nimport type { PosterizeTimeFilter } from '../../filters/implementations/posterize-time';\r\nimport type { FillData } from '../registry';\r\nimport type { ImageCrop, ImageFit, ImageMatrix } from './image';\r\nimport { lerpImagePlacement, resolveImagePlacement } from './image';\r\nimport type { Alignment } from '@/attributes/layout/alignment';\r\nimport type { InsetsResolved } from '@/attributes/layout/insets';\r\nimport type { Vector2 } from '@/attributes/layout/vector2';\r\nimport { lerpNumber } from '@/tween/lerp';\r\nimport type { VideoAdjustment } from '../../filters/chain';\r\nimport {\r\n declareMediaPreset,\r\n lerpMediaPreset,\r\n resolveMediaPreset,\r\n type MediaPresetResolved,\r\n type VideoPresetProp,\r\n} from '../media-preset';\r\n\r\n/** Adjustments a video fill carries — the pixel ones plus the video-only ones. */\r\ntype VideoFillFilter = MediaAdjustment | VideoOnlyAdjustment;\r\n\r\nexport interface VideoFillProp {\r\n type: 'video';\r\n src: string;\r\n /** How the (cropped) frame is scaled into the node's bounds. Defaults to `'fill'`. */\r\n fit?: ImageFit;\r\n /** Window onto the source frame, applied before `fit`. See {@link ImageCrop}. */\r\n crop?: ImageCrop;\r\n /** Magnification on top of the fitted scale. See {@link ImageFillProp.zoom}. */\r\n zoom?: number;\r\n /** The point held fixed as `zoom` scales. See {@link ImageFillProp.anchor}. */\r\n anchor?: Alignment;\r\n /** Raw frame→shape matrix; wins over everything above. See {@link ImageFillProp.matrix}. */\r\n matrix?: ImageMatrix;\r\n /**\r\n * Source time to paint, in seconds — an **explicit override**. Omit it (the\r\n * default) and the timestamp is derived at draw time from how long the node\r\n * painting the fill has existed, so a video fill plays on its own wherever\r\n * it is used (fill, overlay, stroke, shadow, a raw `Graphics2D` in a custom\r\n * node) with nothing to wire up. Set it to drive the playhead yourself —\r\n * e.g. tween it to scrub the clip.\r\n *\r\n * Pass `null` to hand the playhead back to the clock: `Node2D.set` skips\r\n * `undefined` values (it merges a partial), so `null` is what un-does an\r\n * override that is already live.\r\n */\r\n timestamp?: number | null;\r\n /** Whether the derived timestamp advances with the node's clock. Default `true`. */\r\n playing?: boolean;\r\n trimStart?: number;\r\n trimEnd?: number;\r\n /**\r\n * Seconds after the painting node appears before playback begins (default\r\n * `0`). Use it when the fill joins a node that already existed — a video\r\n * cross-faded in at 4s into a node's life would otherwise open 4s into the\r\n * clip. Negative values start the clip already in progress.\r\n */\r\n playStart?: number;\r\n speed?: number;\r\n /** The grade laid over this footage — see {@link VideoPresetProp}. */\r\n preset?: VideoPresetProp;\r\n /**\r\n * @deprecated Moved to `preset.adjustments`. Still read and folded into the\r\n * preset on resolve. Removed in the next major.\r\n */\r\n filters?: VideoAdjustment;\r\n loop?: 'forward' | 'reverse' | 'none';\r\n duration?: number;\r\n opacity?: number;\r\n blend?: BlendMode;\r\n}\r\n\r\nexport interface VideoFillResolved {\r\n type: 'video';\r\n src: string;\r\n fit?: ImageFit;\r\n crop?: InsetsResolved;\r\n zoom?: number;\r\n anchor?: Vector2;\r\n matrix?: ImageMatrix;\r\n /** Explicit source time, or `undefined`/`null` to derive it — see {@link VideoFillProp.timestamp}. */\r\n timestamp?: number | null;\r\n playing: boolean;\r\n trimStart?: number;\r\n trimEnd?: number;\r\n playStart?: number;\r\n speed?: number;\r\n /** Absent when the fill is ungraded — see {@link resolveMediaPreset}. */\r\n preset?: MediaPresetResolved<VideoFillFilter>;\r\n loop?: 'forward' | 'reverse' | 'none';\r\n duration?: number;\r\n opacity?: number;\r\n blend?: BlendMode;\r\n}\r\n\r\n/**\r\n * The source time a video fill paints at, given `elapsed` — how long the node\r\n * painting it has existed (`NodeRenderState.elapsed`).\r\n *\r\n * A pure function of the fill and the clock, called by the backend as it paints,\r\n * the same way a motion blur is resolved against the node's sampled velocity.\r\n * Deriving it at draw time (rather than advancing a stored timestamp each tick)\r\n * is what lets a video fill play anywhere paint is accepted — stroke, shadow,\r\n * text selection, a custom node's raw `Graphics2D` — instead of only on the two\r\n * nodes that remembered to update it. It also makes frame *N* identical however\r\n * the playhead reached it, so scrubbing and export agree with playback.\r\n *\r\n * `sourceDuration` is the clip's real length in seconds, used to resolve the\r\n * `trimEnd` default and the loop cycle. Pass `undefined` (or a non-positive\r\n * value) when it isn't known yet — playback then runs linearly and unlooped,\r\n * which is what a decoder that hasn't opened the container can honour anyway.\r\n */\r\nexport function resolveVideoTimestamp(\r\n fill: VideoFillResolved,\r\n elapsed: number,\r\n sourceDuration?: number,\r\n): number {\r\n const start = fill.trimStart ?? 0;\r\n return posterizeTimestamp(fill, start, rawTimestamp(fill, elapsed, sourceDuration, start));\r\n}\r\n\r\n/** {@link resolveVideoTimestamp} before the posterize-time quantization. */\r\nfunction rawTimestamp(\r\n fill: VideoFillResolved,\r\n elapsed: number,\r\n sourceDuration: number | undefined,\r\n start: number,\r\n): number {\r\n // An authored timestamp wins outright: the author is driving the playhead.\r\n if (fill.timestamp != null) return fill.timestamp;\r\n // Paused with no authored time: hold the clip's first frame.\r\n if (!fill.playing) return start;\r\n\r\n const played = Math.max(0, elapsed - (fill.playStart ?? 0)) * (fill.speed ?? 1);\r\n return sourceTimeFor(played, start, trimEndFor(fill, sourceDuration), fill.loop, fill.duration);\r\n}\r\n\r\n/**\r\n * The clip's out point: what the fill states, or the source's own length once\r\n * the container has been opened, or unbounded while it has not.\r\n *\r\n * `Infinity` is the unbounded sentinel here, as it is throughout the audio side\r\n * (`Sound.trimEnd`, `AudioRequest.endAt`) — a decoder that has not read the\r\n * container cannot answer \"how long\", and running linearly and unlooped is what\r\n * it can honour in the meantime.\r\n */\r\nexport function trimEndFor(\r\n fill: Pick<VideoFillResolved, 'trimEnd'>,\r\n sourceDuration: number | undefined,\r\n): number {\r\n const hasDuration = sourceDuration !== undefined && Number.isFinite(sourceDuration) && sourceDuration > 0;\r\n return fill.trimEnd ?? (hasDuration ? sourceDuration : Infinity);\r\n}\r\n\r\n/**\r\n * Where `played` seconds of *consumed source* land inside the trimmed window,\r\n * once looping and clamping are applied.\r\n *\r\n * Split out of {@link rawTimestamp} because two callers now need it and only one\r\n * of them derives `played` the same way. The fill computes it linearly from the\r\n * clock; a {@link Video} node driven by a `segments` schedule computes it by\r\n * walking that schedule, since a paused stretch consumes no source at all. What\r\n * \"and then it wraps\" or \"and then it stops\" means is the same for both, and\r\n * this is the one place that says so.\r\n */\r\nexport function sourceTimeFor(\r\n /** Seconds of source consumed so far — already scaled by playback rate. */\r\n played: number,\r\n /** The trim-in point, which every result is measured from. */\r\n start: number,\r\n /** The trim-out point, or `Infinity` while the source's length is unknown. */\r\n end: number,\r\n loop: 'forward' | 'reverse' | 'none' | undefined,\r\n /** An explicit loop-cycle length; defaults to the trimmed clip's own. */\r\n cycleLength?: number,\r\n): number {\r\n const rawLoopDuration = cycleLength ?? (end !== Infinity ? end - start : undefined);\r\n const loopDuration = rawLoopDuration !== undefined && rawLoopDuration > 0 ? rawLoopDuration : undefined;\r\n if ((loop ?? 'none') !== 'none' && loopDuration !== undefined) {\r\n const cycle = played % loopDuration;\r\n if (loop === 'reverse') {\r\n const ping = Math.floor(played / loopDuration) % 2 === 0;\r\n return start + (ping ? cycle : loopDuration - cycle);\r\n }\r\n return start + cycle;\r\n }\r\n const linear = start + played;\r\n return end !== Infinity ? Math.min(linear, end) : linear;\r\n}\r\n\r\n/**\r\n * Posterize Time: snap the resolved source timestamp to a coarser grid so each\r\n * frame is held for a full 1/fps interval (the stop-motion look). Done after\r\n * trim/speed/loop so the quantization lives in source-time space and lines up\r\n * with the adapter's decoded-frame grid. `floor` (not round) holds a frame for\r\n * its whole interval, matching After Effects.\r\n */\r\nfunction posterizeTimestamp(fill: VideoFillResolved, start: number, timestamp: number): number {\r\n const posterize = fill.preset?.adjustments.find(\r\n (f): f is PosterizeTimeFilter => f.type === 'posterizeTime',\r\n );\r\n if (!posterize || posterize.fps <= 0) return timestamp;\r\n const grid = 1 / posterize.fps;\r\n return start + Math.floor((timestamp - start) / grid) * grid;\r\n}\r\n\r\nexport const videoFill: FillData<VideoFillResolved> = {\r\n // See `imageFill.resolve` for why `crop`/`anchor` are destructured out.\r\n resolve: ({ crop, anchor, preset, filters, ...prop }: VideoFillProp): VideoFillResolved => ({\r\n ...prop,\r\n ...resolveImagePlacement({ crop, anchor }),\r\n preset: resolveMediaPreset(preset, filters) as\r\n | MediaPresetResolved<VideoFillFilter>\r\n | undefined,\r\n playing: prop.playing ?? true,\r\n }),\r\n lerp: (a, b, t) => ({\r\n src: t < 0.5 ? a.src : b.src,\r\n fit: t < 0.5 ? a.fit : b.fit,\r\n ...lerpImagePlacement(a, b, t),\r\n loop: t < 0.5 ? a.loop : b.loop,\r\n duration: t < 0.5 ? a.duration : b.duration,\r\n trimStart: t < 0.5 ? a.trimStart : b.trimStart,\r\n trimEnd: t < 0.5 ? a.trimEnd : b.trimEnd,\r\n playStart: t < 0.5 ? a.playStart : b.playStart,\r\n playing: t < 0.5 ? a.playing : b.playing,\r\n opacity: (a.opacity ?? 1) + ((b.opacity ?? 1) - (a.opacity ?? 1)) * t,\r\n // Both derived (the common case) stays derived — lerping `?? 0` here\r\n // would pin the tween's result to an explicit timestamp and freeze the\r\n // clip for as long as the tween's output is live.\r\n timestamp: a.timestamp == null && b.timestamp == null\r\n ? undefined\r\n : lerpNumber(a.timestamp ?? 0, b.timestamp ?? 0, t),\r\n speed: lerpNumber(a.speed ?? 1, b.speed ?? 1, t),\r\n // See the note on `imageFill.lerp` — without this the *from* fill's\r\n // grade rides the whole tween and snaps at the end.\r\n preset: lerpMediaPreset(a.preset, b.preset, t),\r\n }),\r\n equals: (a, b) => a.src === b.src,\r\n declare: (fill, assets) => {\r\n assets.video(fill.src, { start: fill.trimStart ?? 0, end: fill.trimEnd });\r\n declareMediaPreset(fill.preset, assets);\r\n },\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"video.js","sourceRoot":"","sources":["../../../../../src/attributes/shape/fill/implementations/video.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAIpE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EACH,kBAAkB,EAClB,eAAe,EACf,kBAAkB,GAGrB,MAAM,iBAAiB,CAAC;AA+EzB;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,qBAAqB,CACjC,IAAuB,EACvB,OAAe,EACf,cAAuB;IAEvB,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC;IAClC,OAAO,kBAAkB,CAAC,IAAI,EAAE,KAAK,EAAE,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC,CAAC;AAC/F,CAAC;AAED,4EAA4E;AAC5E,SAAS,YAAY,CACjB,IAAuB,EACvB,OAAe,EACf,cAAkC,EAClC,KAAa;IAEb,2EAA2E;IAC3E,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC,SAAS,CAAC;IAClD,6DAA6D;IAC7D,IAAI,CAAC,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAEhC,MAAM,MAAM,GAAG,IAAI,CA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I,CAAC,CAAC,CAAC,GAAG,CAAC;QACrE,qEAAqE;QACrE,uEAAuE;QACvE,kDAAkD;QAClD,SAAS,EAAE,CAAC,CAAC,SAAS,IAAI,IAAI,IAAI,CAAC,CAAC,SAAS,IAAI,IAAI;YACjD,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,IAAI,CAAC,EAAE,CAAC,CAAC,SAAS,IAAI,CAAC,EAAE,CAAC,CAAC;QACvD,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC,CAAC;QAChD,oEAAoE;QACpE,oDAAoD;QACpD,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;KACjD,CAAC;IACF,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG;IACjC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;QACtB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;QAC1E,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,CAAC;CACJ,CAAC","sourcesContent":["import type { BlendMode } from '../blend';\r\nimport type { MediaAdjustment, VideoOnlyAdjustment } from '../../filters/union';\r\nimport type { PosterizeTimeFilter } from '../../filters/implementations/posterize-time';\r\nimport type { FillData } from '../registry';\r\nimport type { ImageCrop, ImageFit, ImageMatrix } from './image';\r\nimport { lerpImagePlacement, resolveImagePlacement } from './image';\r\nimport type { Alignment } from '@/attributes/layout/alignment';\r\nimport type { InsetsResolved } from '@/attributes/layout/insets';\r\nimport type { Vector2 } from '@/attributes/layout/vector2';\r\nimport { lerpNumber } from '@/tween/lerp';\r\nimport type { VideoAdjustment } from '../../filters/chain';\r\nimport {\r\n declareMediaPreset,\r\n lerpMediaPreset,\r\n resolveMediaPreset,\r\n type MediaPresetResolved,\r\n type VideoPresetProp,\r\n} from '../media-preset';\r\n\r\n/** Adjustments a video fill carries — the pixel ones plus the video-only ones. */\r\ntype VideoFillFilter = MediaAdjustment | VideoOnlyAdjustment;\r\n\r\nexport interface VideoFillProp {\r\n type: 'video';\r\n src: string;\r\n /** How the (cropped) frame is scaled into the node's bounds. Defaults to `'fill'`. */\r\n fit?: ImageFit;\r\n /** Window onto the source frame, applied before `fit`. See {@link ImageCrop}. */\r\n crop?: ImageCrop;\r\n /** Magnification on top of the fitted scale. See {@link ImageFillProp.zoom}. */\r\n zoom?: number;\r\n /** The point held fixed as `zoom` scales. See {@link ImageFillProp.anchor}. */\r\n anchor?: Alignment;\r\n /** Raw frame→shape matrix; wins over everything above. See {@link ImageFillProp.matrix}. */\r\n matrix?: ImageMatrix;\r\n /**\r\n * Source time to paint, in seconds — an **explicit override**. Omit it (the\r\n * default) and the timestamp is derived at draw time from how long the node\r\n * painting the fill has existed, so a video fill plays on its own wherever\r\n * it is used (fill, overlay, stroke, shadow, a raw `Graphics2D` in a custom\r\n * node) with nothing to wire up. Set it to drive the playhead yourself —\r\n * e.g. tween it to scrub the clip.\r\n *\r\n * Pass `null` to hand the playhead back to the clock: `Node2D.set` skips\r\n * `undefined` values (it merges a partial), so `null` is what un-does an\r\n * override that is already live.\r\n */\r\n timestamp?: number | null;\r\n /** Whether the derived timestamp advances with the node's clock. Default `true`. */\r\n playing?: boolean;\r\n trimStart?: number;\r\n trimEnd?: number;\r\n /**\r\n * Seconds after the painting node appears before playback begins (default\r\n * `0`). Use it when the fill joins a node that already existed — a video\r\n * cross-faded in at 4s into a node's life would otherwise open 4s into the\r\n * clip. Negative values start the clip already in progress.\r\n */\r\n playStart?: number;\r\n speed?: number;\r\n /** The grade laid over this footage — see {@link VideoPresetProp}. */\r\n preset?: VideoPresetProp;\r\n /**\r\n * @deprecated Moved to `preset.adjustments`. Still read and folded into the\r\n * preset on resolve. Removed in the next major.\r\n */\r\n filters?: VideoAdjustment;\r\n loop?: 'forward' | 'reverse' | 'none';\r\n duration?: number;\r\n opacity?: number;\r\n blend?: BlendMode;\r\n}\r\n\r\nexport interface VideoFillResolved {\r\n type: 'video';\r\n src: string;\r\n fit?: ImageFit;\r\n crop?: InsetsResolved;\r\n zoom?: number;\r\n anchor?: Vector2;\r\n matrix?: ImageMatrix;\r\n /** Explicit source time, or `undefined`/`null` to derive it — see {@link VideoFillProp.timestamp}. */\r\n timestamp?: number | null;\r\n playing: boolean;\r\n trimStart?: number;\r\n trimEnd?: number;\r\n playStart?: number;\r\n speed?: number;\r\n /** Absent when the fill is ungraded — see {@link resolveMediaPreset}. */\r\n preset?: MediaPresetResolved<VideoFillFilter>;\r\n loop?: 'forward' | 'reverse' | 'none';\r\n duration?: number;\r\n opacity?: number;\r\n blend?: BlendMode;\r\n}\r\n\r\n/**\r\n * The source time a video fill paints at, given `elapsed` — how long the node\r\n * painting it has existed (`NodeRenderState.elapsed`).\r\n *\r\n * A pure function of the fill and the clock, called by the backend as it paints,\r\n * the same way a motion blur is resolved against the node's sampled velocity.\r\n * Deriving it at draw time (rather than advancing a stored timestamp each tick)\r\n * is what lets a video fill play anywhere paint is accepted — stroke, shadow,\r\n * a text run, a component's raw `Graphics2D` — instead of only on the two\r\n * nodes that remembered to update it. It also makes frame *N* identical however\r\n * the playhead reached it, so scrubbing and export agree with playback.\r\n *\r\n * `sourceDuration` is the clip's real length in seconds, used to resolve the\r\n * `trimEnd` default and the loop cycle. Pass `undefined` (or a non-positive\r\n * value) when it isn't known yet — playback then runs linearly and unlooped,\r\n * which is what a decoder that hasn't opened the container can honour anyway.\r\n */\r\nexport function resolveVideoTimestamp(\r\n fill: VideoFillResolved,\r\n elapsed: number,\r\n sourceDuration?: number,\r\n): number {\r\n const start = fill.trimStart ?? 0;\r\n return posterizeTimestamp(fill, start, rawTimestamp(fill, elapsed, sourceDuration, start));\r\n}\r\n\r\n/** {@link resolveVideoTimestamp} before the posterize-time quantization. */\r\nfunction rawTimestamp(\r\n fill: VideoFillResolved,\r\n elapsed: number,\r\n sourceDuration: number | undefined,\r\n start: number,\r\n): number {\r\n // An authored timestamp wins outright: the author is driving the playhead.\r\n if (fill.timestamp != null) return fill.timestamp;\r\n // Paused with no authored time: hold the clip's first frame.\r\n if (!fill.playing) return start;\r\n\r\n const played = Math.max(0, elapsed - (fill.playStart ?? 0)) * (fill.speed ?? 1);\r\n return sourceTimeFor(played, start, trimEndFor(fill, sourceDuration), fill.loop, fill.duration);\r\n}\r\n\r\n/**\r\n * The clip's out point: what the fill states, or the source's own length once\r\n * the container has been opened, or unbounded while it has not.\r\n *\r\n * `Infinity` is the unbounded sentinel here, as it is throughout the audio side\r\n * (`Sound.trimEnd`, `AudioRequest.endAt`) — a decoder that has not read the\r\n * container cannot answer \"how long\", and running linearly and unlooped is what\r\n * it can honour in the meantime.\r\n */\r\nexport function trimEndFor(\r\n fill: Pick<VideoFillResolved, 'trimEnd'>,\r\n sourceDuration: number | undefined,\r\n): number {\r\n const hasDuration = sourceDuration !== undefined && Number.isFinite(sourceDuration) && sourceDuration > 0;\r\n return fill.trimEnd ?? (hasDuration ? sourceDuration : Infinity);\r\n}\r\n\r\n/**\r\n * Where `played` seconds of *consumed source* land inside the trimmed window,\r\n * once looping and clamping are applied.\r\n *\r\n * Split out of {@link rawTimestamp} because two callers now need it and only one\r\n * of them derives `played` the same way. The fill computes it linearly from the\r\n * clock; a {@link Video} node driven by a `segments` schedule computes it by\r\n * walking that schedule, since a paused stretch consumes no source at all. What\r\n * \"and then it wraps\" or \"and then it stops\" means is the same for both, and\r\n * this is the one place that says so.\r\n */\r\nexport function sourceTimeFor(\r\n /** Seconds of source consumed so far — already scaled by playback rate. */\r\n played: number,\r\n /** The trim-in point, which every result is measured from. */\r\n start: number,\r\n /** The trim-out point, or `Infinity` while the source's length is unknown. */\r\n end: number,\r\n loop: 'forward' | 'reverse' | 'none' | undefined,\r\n /** An explicit loop-cycle length; defaults to the trimmed clip's own. */\r\n cycleLength?: number,\r\n): number {\r\n const rawLoopDuration = cycleLength ?? (end !== Infinity ? end - start : undefined);\r\n const loopDuration = rawLoopDuration !== undefined && rawLoopDuration > 0 ? rawLoopDuration : undefined;\r\n if ((loop ?? 'none') !== 'none' && loopDuration !== undefined) {\r\n const cycle = played % loopDuration;\r\n if (loop === 'reverse') {\r\n const ping = Math.floor(played / loopDuration) % 2 === 0;\r\n return start + (ping ? cycle : loopDuration - cycle);\r\n }\r\n return start + cycle;\r\n }\r\n const linear = start + played;\r\n return end !== Infinity ? Math.min(linear, end) : linear;\r\n}\r\n\r\n/**\r\n * Posterize Time: snap the resolved source timestamp to a coarser grid so each\r\n * frame is held for a full 1/fps interval (the stop-motion look). Done after\r\n * trim/speed/loop so the quantization lives in source-time space and lines up\r\n * with the adapter's decoded-frame grid. `floor` (not round) holds a frame for\r\n * its whole interval, matching After Effects.\r\n */\r\nfunction posterizeTimestamp(fill: VideoFillResolved, start: number, timestamp: number): number {\r\n const posterize = fill.preset?.adjustments.find(\r\n (f): f is PosterizeTimeFilter => f.type === 'posterizeTime',\r\n );\r\n if (!posterize || posterize.fps <= 0) return timestamp;\r\n const grid = 1 / posterize.fps;\r\n return start + Math.floor((timestamp - start) / grid) * grid;\r\n}\r\n\r\nexport const videoFill: FillData<VideoFillResolved> = {\r\n // See `imageFill.resolve` for why `crop`/`anchor` are destructured out.\r\n resolve: ({ crop, anchor, preset, filters, ...prop }: VideoFillProp): VideoFillResolved => ({\r\n ...prop,\r\n ...resolveImagePlacement({ crop, anchor }),\r\n preset: resolveMediaPreset(preset, filters) as\r\n | MediaPresetResolved<VideoFillFilter>\r\n | undefined,\r\n playing: prop.playing ?? true,\r\n }),\r\n lerp: (a, b, t) => ({\r\n src: t < 0.5 ? a.src : b.src,\r\n fit: t < 0.5 ? a.fit : b.fit,\r\n ...lerpImagePlacement(a, b, t),\r\n loop: t < 0.5 ? a.loop : b.loop,\r\n duration: t < 0.5 ? a.duration : b.duration,\r\n trimStart: t < 0.5 ? a.trimStart : b.trimStart,\r\n trimEnd: t < 0.5 ? a.trimEnd : b.trimEnd,\r\n playStart: t < 0.5 ? a.playStart : b.playStart,\r\n playing: t < 0.5 ? a.playing : b.playing,\r\n opacity: (a.opacity ?? 1) + ((b.opacity ?? 1) - (a.opacity ?? 1)) * t,\r\n // Both derived (the common case) stays derived — lerping `?? 0` here\r\n // would pin the tween's result to an explicit timestamp and freeze the\r\n // clip for as long as the tween's output is live.\r\n timestamp: a.timestamp == null && b.timestamp == null\r\n ? undefined\r\n : lerpNumber(a.timestamp ?? 0, b.timestamp ?? 0, t),\r\n speed: lerpNumber(a.speed ?? 1, b.speed ?? 1, t),\r\n // See the note on `imageFill.lerp` — without this the *from* fill's\r\n // grade rides the whole tween and snaps at the end.\r\n preset: lerpMediaPreset(a.preset, b.preset, t),\r\n }),\r\n equals: (a, b) => a.src === b.src,\r\n declare: (fill, assets) => {\r\n assets.video(fill.src, { start: fill.trimStart ?? 0, end: fill.trimEnd });\r\n declareMediaPreset(fill.preset, assets);\r\n },\r\n};\r\n"]}
|
|
@@ -13,7 +13,7 @@ export declare function lerpColor(from: NormalizedColor, to: NormalizedColor, t:
|
|
|
13
13
|
export interface ColorOps {
|
|
14
14
|
/**
|
|
15
15
|
* `#rrggbb`, or `#rrggbbaa` when not opaque — for a consumer that takes a
|
|
16
|
-
* colour as a string, such as a resolved
|
|
16
|
+
* colour as a string, such as a resolved `Types.color` entry read back.
|
|
17
17
|
*/
|
|
18
18
|
hex(value: Color): string;
|
|
19
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lerp.js","sourceRoot":"","sources":["../../../../src/attributes/shape/fill/lerp.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,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CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,IAAI,CAAC,OAAe;IACzB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC7F,CAAC","sourcesContent":["/**\r\n * Low-level color interpolation utilities.\r\n *\r\n * These helpers operate on {@link NormalizedColor} tuples (linear [R, G, B, A]\r\n * in the 0–1 range) and are used by fill implementations that need per-channel\r\n * lerp without pulling in the full fill-registry machinery.\r\n */\r\n\r\nimport { Color, NormalizedColor, parseColor } from \"./color/parser\";\r\nimport type { AttributeOps } from \"@/attributes/shared/operators\";\r\n\r\n/** Linearly interpolates two normalized RGBA colors channel-by-channel. */\r\nexport function lerpColor(from: NormalizedColor, to: NormalizedColor, t: number): NormalizedColor {\r\n return [\r\n from[0] + (to[0] - from[0]) * t,\r\n from[1] + (to[1] - from[1]) * t,\r\n from[2] + (to[2] - from[2]) * t,\r\n from[3] + (to[3] - from[3]) * t,\r\n ];\r\n}\r\n\r\n/** Helpers the colour attribute carries beyond its mapper and lerp. */\r\nexport interface ColorOps {\r\n /**\r\n * `#rrggbb`, or `#rrggbbaa` when not opaque — for a consumer that takes a\r\n * colour as a string, such as a resolved
|
|
1
|
+
{"version":3,"file":"lerp.js","sourceRoot":"","sources":["../../../../src/attributes/shape/fill/lerp.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAA0B,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGpE,2EAA2E;AAC3E,MAAM,UAAU,SAAS,CAAC,IAAqB,EAAE,EAAmB,EAAE,CAAS;IAC3E,OAAO;QACH,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CA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EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC7F,CAAC","sourcesContent":["/**\r\n * Low-level color interpolation utilities.\r\n *\r\n * These helpers operate on {@link NormalizedColor} tuples (linear [R, G, B, A]\r\n * in the 0–1 range) and are used by fill implementations that need per-channel\r\n * lerp without pulling in the full fill-registry machinery.\r\n */\r\n\r\nimport { Color, NormalizedColor, parseColor } from \"./color/parser\";\r\nimport type { AttributeOps } from \"@/attributes/shared/operators\";\r\n\r\n/** Linearly interpolates two normalized RGBA colors channel-by-channel. */\r\nexport function lerpColor(from: NormalizedColor, to: NormalizedColor, t: number): NormalizedColor {\r\n return [\r\n from[0] + (to[0] - from[0]) * t,\r\n from[1] + (to[1] - from[1]) * t,\r\n from[2] + (to[2] - from[2]) * t,\r\n from[3] + (to[3] - from[3]) * t,\r\n ];\r\n}\r\n\r\n/** Helpers the colour attribute carries beyond its mapper and lerp. */\r\nexport interface ColorOps {\r\n /**\r\n * `#rrggbb`, or `#rrggbbaa` when not opaque — for a consumer that takes a\r\n * colour as a string, such as a resolved `Types.color` entry read back.\r\n */\r\n hex(value: Color): string;\r\n}\r\n\r\n/** The colour attribute's op set: parses a CSS string (or passes an already-normalized\r\n * tuple through) and interpolates in normalized space. */\r\nexport const colorOps: AttributeOps<Color, NormalizedColor> & ColorOps = {\r\n resolve,\r\n lerp: lerpColor,\r\n hex(value) {\r\n const [r, g, b, a] = resolve(value);\r\n const alpha = byte(a);\r\n return `#${byte(r)}${byte(g)}${byte(b)}${alpha === \"ff\" ? \"\" : alpha}`;\r\n },\r\n};\r\n\r\nfunction resolve(value: Color): NormalizedColor {\r\n return Array.isArray(value) ? value : parseColor(value);\r\n}\r\n\r\nfunction byte(channel: number): string {\r\n return Math.round(Math.min(1, Math.max(0, channel)) * 255).toString(16).padStart(2, \"0\");\r\n}\r\n\r\n"]}
|
|
@@ -253,7 +253,7 @@ export type VideoAdjustment = (MediaAdjustment | VideoOnlyAdjustment) | (MediaAd
|
|
|
253
253
|
*
|
|
254
254
|
* @example
|
|
255
255
|
* node.filters = Adjustments.blur(8).grayscale(1);
|
|
256
|
-
*
|
|
256
|
+
* Rect({ fill: Fills.image('bg.jpg', { filters: Adjustments.oilPaint(4) }) })
|
|
257
257
|
*/
|
|
258
258
|
export declare const Adjustments: AdjustmentChain;
|
|
259
259
|
/**
|
|
@@ -256,7 +256,7 @@ export class VideoAdjustmentChain extends AdjustmentChain {
|
|
|
256
256
|
*
|
|
257
257
|
* @example
|
|
258
258
|
* node.filters = Adjustments.blur(8).grayscale(1);
|
|
259
|
-
*
|
|
259
|
+
* Rect({ fill: Fills.image('bg.jpg', { filters: Adjustments.oilPaint(4) }) })
|
|
260
260
|
*/
|
|
261
261
|
export const Adjustments = new AdjustmentChain();
|
|
262
262
|
/**
|