@pairdraw/core 0.21.1 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/boolean.d.ts +6 -1
- package/dist/canvas/boolean.d.ts.map +1 -1
- package/dist/canvas/boolean.js +10 -2
- package/dist/canvas/boolean.js.map +1 -1
- package/dist/canvas/color-space.d.ts +45 -0
- package/dist/canvas/color-space.d.ts.map +1 -0
- package/dist/canvas/color-space.js +39 -0
- package/dist/canvas/color-space.js.map +1 -0
- package/dist/canvas/fills.d.ts +10 -10
- package/dist/canvas/fills.d.ts.map +1 -1
- package/dist/canvas/fills.js +116 -62
- package/dist/canvas/fills.js.map +1 -1
- package/dist/canvas/flatten.d.ts +11 -3
- package/dist/canvas/flatten.d.ts.map +1 -1
- package/dist/canvas/flatten.js +62 -4
- package/dist/canvas/flatten.js.map +1 -1
- package/dist/canvas/index.d.ts +2 -1
- package/dist/canvas/index.js +2 -1
- package/dist/canvas/layout-grids.d.ts +5 -2
- package/dist/canvas/layout-grids.d.ts.map +1 -1
- package/dist/canvas/layout-grids.js +7 -2
- package/dist/canvas/layout-grids.js.map +1 -1
- package/dist/canvas/noise/render.d.ts +17 -4
- package/dist/canvas/noise/render.d.ts.map +1 -1
- package/dist/canvas/noise/render.js +21 -6
- package/dist/canvas/noise/render.js.map +1 -1
- package/dist/canvas/noise/shader.d.ts +4 -4
- package/dist/canvas/noise/shader.d.ts.map +1 -1
- package/dist/canvas/noise/shader.js +5 -6
- package/dist/canvas/noise/shader.js.map +1 -1
- package/dist/canvas/overlays/annotations.d.ts +19 -0
- package/dist/canvas/overlays/annotations.d.ts.map +1 -0
- package/dist/canvas/overlays/annotations.js +110 -0
- package/dist/canvas/overlays/annotations.js.map +1 -0
- package/dist/canvas/overlays/auto-layout-hover.d.ts +11 -1
- package/dist/canvas/overlays/auto-layout-hover.d.ts.map +1 -1
- package/dist/canvas/overlays/auto-layout-hover.js +25 -1
- package/dist/canvas/overlays/auto-layout-hover.js.map +1 -1
- package/dist/canvas/overlays/feedback.js +1 -1
- package/dist/canvas/overlays/feedback.js.map +1 -1
- package/dist/canvas/overlays/index.d.ts +2 -2
- package/dist/canvas/overlays/index.js +2 -2
- package/dist/canvas/overlays/measurement.d.ts +7 -1
- package/dist/canvas/overlays/measurement.d.ts.map +1 -1
- package/dist/canvas/overlays/measurement.js +42 -4
- package/dist/canvas/overlays/measurement.js.map +1 -1
- package/dist/canvas/overlays/presence.d.ts.map +1 -1
- package/dist/canvas/overlays/presence.js +21 -24
- package/dist/canvas/overlays/presence.js.map +1 -1
- package/dist/canvas/renderer/colors.d.ts +7 -1
- package/dist/canvas/renderer/colors.d.ts.map +1 -1
- package/dist/canvas/renderer/colors.js +9 -1
- package/dist/canvas/renderer/colors.js.map +1 -1
- package/dist/canvas/renderer/document-surface.d.ts +15 -6
- package/dist/canvas/renderer/document-surface.d.ts.map +1 -1
- package/dist/canvas/renderer/document-surface.js +1 -0
- package/dist/canvas/renderer/document-surface.js.map +1 -1
- package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
- package/dist/canvas/renderer/lifecycle.js +2 -2
- package/dist/canvas/renderer/lifecycle.js.map +1 -1
- package/dist/canvas/renderer/methods.d.ts +1 -0
- package/dist/canvas/renderer/methods.d.ts.map +1 -1
- package/dist/canvas/renderer/methods.js +4 -1
- package/dist/canvas/renderer/methods.js.map +1 -1
- package/dist/canvas/renderer/overlay-pass.d.ts.map +1 -1
- package/dist/canvas/renderer/overlay-pass.js +6 -1
- package/dist/canvas/renderer/overlay-pass.js.map +1 -1
- package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
- package/dist/canvas/renderer/pipeline.js +7 -0
- package/dist/canvas/renderer/pipeline.js.map +1 -1
- package/dist/canvas/renderer/types.d.ts +10 -0
- package/dist/canvas/renderer/types.d.ts.map +1 -1
- package/dist/canvas/renderer.d.ts +10 -2
- package/dist/canvas/renderer.d.ts.map +1 -1
- package/dist/canvas/renderer.js +15 -3
- package/dist/canvas/renderer.js.map +1 -1
- package/dist/canvas/scene.d.ts.map +1 -1
- package/dist/canvas/scene.js +9 -9
- package/dist/canvas/scene.js.map +1 -1
- package/dist/clipboard/pairdraw.d.ts.map +1 -1
- package/dist/clipboard/pairdraw.js +1 -0
- package/dist/clipboard/pairdraw.js.map +1 -1
- package/dist/editor/bridges/clipboard.d.ts +2 -0
- package/dist/editor/bridges/clipboard.d.ts.map +1 -1
- package/dist/editor/bridges/clipboard.js +1 -0
- package/dist/editor/bridges/clipboard.js.map +1 -1
- package/dist/editor/bridges/components.d.ts +14 -7
- package/dist/editor/bridges/components.d.ts.map +1 -1
- package/dist/editor/bridges/components.js +6 -0
- package/dist/editor/bridges/components.js.map +1 -1
- package/dist/editor/bridges/structure.d.ts +1 -1
- package/dist/editor/bridges/structure.d.ts.map +1 -1
- package/dist/editor/clipboard/code.d.ts +32 -0
- package/dist/editor/clipboard/code.d.ts.map +1 -0
- package/dist/editor/clipboard/code.js +30 -0
- package/dist/editor/clipboard/code.js.map +1 -0
- package/dist/editor/clipboard/paste/dependencies.d.ts +14 -0
- package/dist/editor/clipboard/paste/dependencies.d.ts.map +1 -0
- package/dist/editor/clipboard/paste/dependencies.js +0 -0
- package/dist/editor/clipboard/paste/run.d.ts +14 -0
- package/dist/editor/clipboard/paste/run.d.ts.map +1 -0
- package/dist/editor/clipboard/paste/run.js +47 -0
- package/dist/editor/clipboard/paste/run.js.map +1 -0
- package/dist/editor/clipboard/styled.d.ts +2 -8
- package/dist/editor/clipboard/styled.d.ts.map +1 -1
- package/dist/editor/clipboard/styled.js +2 -32
- package/dist/editor/clipboard/styled.js.map +1 -1
- package/dist/editor/clipboard.d.ts +2 -0
- package/dist/editor/clipboard.d.ts.map +1 -1
- package/dist/editor/clipboard.js +34 -0
- package/dist/editor/clipboard.js.map +1 -1
- package/dist/editor/components/instances.d.ts +5 -0
- package/dist/editor/components/instances.d.ts.map +1 -1
- package/dist/editor/components/instances.js +69 -4
- package/dist/editor/components/instances.js.map +1 -1
- package/dist/editor/components/slots/index.d.ts.map +1 -1
- package/dist/editor/components/slots/index.js +7 -0
- package/dist/editor/components/slots/index.js.map +1 -1
- package/dist/editor/components.d.ts +6 -0
- package/dist/editor/components.d.ts.map +1 -1
- package/dist/editor/components.js +14 -2
- package/dist/editor/components.js.map +1 -1
- package/dist/editor/create.d.ts +29 -2
- package/dist/editor/create.d.ts.map +1 -1
- package/dist/editor/create.js +11 -2
- package/dist/editor/create.js.map +1 -1
- package/dist/editor/design-tokens.d.ts +1 -1
- package/dist/editor/design-tokens.d.ts.map +1 -1
- package/dist/editor/design-tokens.js +4 -18
- package/dist/editor/design-tokens.js.map +1 -1
- package/dist/editor/image-edit.d.ts.map +1 -1
- package/dist/editor/image-edit.js +1 -2
- package/dist/editor/image-edit.js.map +1 -1
- package/dist/editor/index.d.ts +4 -4
- package/dist/editor/index.js +1 -1
- package/dist/editor/layout-mode.d.ts +3 -1
- package/dist/editor/layout-mode.d.ts.map +1 -1
- package/dist/editor/layout-mode.js +97 -2
- package/dist/editor/layout-mode.js.map +1 -1
- package/dist/editor/nodes.d.ts +2 -0
- package/dist/editor/nodes.d.ts.map +1 -1
- package/dist/editor/nodes.js +22 -7
- package/dist/editor/nodes.js.map +1 -1
- package/dist/editor/read-only/actions.js +6 -0
- package/dist/editor/read-only/actions.js.map +1 -1
- package/dist/editor/selection/overlays.d.ts +1 -0
- package/dist/editor/selection/overlays.d.ts.map +1 -1
- package/dist/editor/selection/overlays.js +7 -0
- package/dist/editor/selection/overlays.js.map +1 -1
- package/dist/editor/selection/read.d.ts +8 -0
- package/dist/editor/selection.d.ts +9 -0
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/state/shared.js +1 -0
- package/dist/editor/state/shared.js.map +1 -1
- package/dist/editor/state/view.d.ts.map +1 -1
- package/dist/editor/state/view.js +2 -0
- package/dist/editor/state/view.js.map +1 -1
- package/dist/editor/structure/boolean.d.ts +1 -1
- package/dist/editor/structure/boolean.d.ts.map +1 -1
- package/dist/editor/structure/boolean.js +20 -1
- package/dist/editor/structure/boolean.js.map +1 -1
- package/dist/editor/structure/container-wrap.d.ts +8 -2
- package/dist/editor/structure/container-wrap.d.ts.map +1 -1
- package/dist/editor/structure/container-wrap.js +17 -5
- package/dist/editor/structure/container-wrap.js.map +1 -1
- package/dist/editor/structure/flatten.d.ts.map +1 -1
- package/dist/editor/structure/flatten.js +8 -7
- package/dist/editor/structure/flatten.js.map +1 -1
- package/dist/editor/structure/group/ungroup.d.ts.map +1 -1
- package/dist/editor/structure/group/ungroup.js +2 -0
- package/dist/editor/structure/group/ungroup.js.map +1 -1
- package/dist/editor/structure/outline-stroke.d.ts.map +1 -1
- package/dist/editor/structure/outline-stroke.js +5 -0
- package/dist/editor/structure/outline-stroke.js.map +1 -1
- package/dist/editor/structure.d.ts +1 -1
- package/dist/editor/structure.d.ts.map +1 -1
- package/dist/editor/styles.d.ts +26 -0
- package/dist/editor/styles.d.ts.map +1 -0
- package/dist/editor/styles.js +127 -0
- package/dist/editor/styles.js.map +1 -0
- package/dist/editor/text/selection-style.d.ts +1 -0
- package/dist/editor/text/selection-style.d.ts.map +1 -1
- package/dist/editor/text/selection-style.js +10 -2
- package/dist/editor/text/selection-style.js.map +1 -1
- package/dist/editor/tool-registry.d.ts.map +1 -1
- package/dist/editor/tool-registry.js +6 -0
- package/dist/editor/tool-registry.js.map +1 -1
- package/dist/editor/types.d.ts +14 -2
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/editor/variable-bindings.d.ts.map +1 -1
- package/dist/editor/variable-bindings.js +6 -1
- package/dist/editor/variable-bindings.js.map +1 -1
- package/dist/figma-api/accessors/basic.d.ts.map +1 -1
- package/dist/figma-api/accessors/basic.js +22 -1
- package/dist/figma-api/accessors/basic.js.map +1 -1
- package/dist/figma-api/accessors/shape.js +1 -1
- package/dist/figma-api/accessors/text/index.js +1 -1
- package/dist/figma-api/accessors/text/ranges.js +1 -1
- package/dist/figma-api/accessors/text/references.js +1 -1
- package/dist/figma-api/accessors/variables.js +1 -1
- package/dist/figma-api/accessors/vector.d.ts.map +1 -1
- package/dist/figma-api/accessors/vector.js +8 -22
- package/dist/figma-api/accessors/vector.js.map +1 -1
- package/dist/figma-api/accessors/visual.js +1 -1
- package/dist/figma-api/compatibility.d.ts +1 -1
- package/dist/figma-api/compatibility.d.ts.map +1 -1
- package/dist/figma-api/component-scope.d.ts +14 -0
- package/dist/figma-api/component-scope.d.ts.map +1 -0
- package/dist/figma-api/component-scope.js +28 -0
- package/dist/figma-api/component-scope.js.map +1 -0
- package/dist/figma-api/components.d.ts.map +1 -1
- package/dist/figma-api/components.js +26 -2
- package/dist/figma-api/components.js.map +1 -1
- package/dist/figma-api/flatten.js +3 -3
- package/dist/figma-api/flatten.js.map +1 -1
- package/dist/figma-api/index.d.ts +77 -6
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +188 -2
- package/dist/figma-api/index.js.map +1 -1
- package/dist/figma-api/node-types.d.ts +2 -1
- package/dist/figma-api/node-types.d.ts.map +1 -1
- package/dist/figma-api/overrides.d.ts +26 -1
- package/dist/figma-api/overrides.d.ts.map +1 -1
- package/dist/figma-api/overrides.js +157 -10
- package/dist/figma-api/overrides.js.map +1 -1
- package/dist/figma-api/proxy.d.ts +2 -0
- package/dist/figma-api/proxy.d.ts.map +1 -1
- package/dist/figma-api/proxy.js +10 -2
- package/dist/figma-api/proxy.js.map +1 -1
- package/dist/figma-api/reactions.d.ts +61 -5
- package/dist/figma-api/reactions.d.ts.map +1 -1
- package/dist/figma-api/reactions.js +144 -11
- package/dist/figma-api/reactions.js.map +1 -1
- package/dist/figma-api/shape-with-text.js +1 -1
- package/dist/figma-api/slots.d.ts +3 -1
- package/dist/figma-api/slots.d.ts.map +1 -1
- package/dist/figma-api/slots.js +9 -8
- package/dist/figma-api/slots.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/io/formats/code/detect.d.ts +23 -0
- package/dist/io/formats/code/detect.d.ts.map +1 -0
- package/dist/io/formats/code/detect.js +46 -0
- package/dist/io/formats/code/detect.js.map +1 -0
- package/dist/io/formats/code/index.d.ts +5 -0
- package/dist/io/formats/code/index.js +5 -0
- package/dist/io/formats/code/read.d.ts +45 -0
- package/dist/io/formats/code/read.d.ts.map +1 -0
- package/dist/io/formats/code/read.js +86 -0
- package/dist/io/formats/code/read.js.map +1 -0
- package/dist/io/formats/code/stylesheet.d.ts +13 -0
- package/dist/io/formats/code/stylesheet.d.ts.map +1 -0
- package/dist/io/formats/code/stylesheet.js +21 -0
- package/dist/io/formats/code/stylesheet.js.map +1 -0
- package/dist/io/formats/code/tokens.d.ts +18 -0
- package/dist/io/formats/code/tokens.d.ts.map +1 -0
- package/dist/io/formats/code/tokens.js +135 -0
- package/dist/io/formats/code/tokens.js.map +1 -0
- package/dist/io/formats/design-tokens/apply.d.ts +7 -3
- package/dist/io/formats/design-tokens/apply.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/apply.js.map +1 -1
- package/dist/io/formats/fig/export/patch/fields.js +5 -0
- package/dist/io/formats/fig/export/patch/fields.js.map +1 -1
- package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
- package/dist/io/formats/fig/export/patch/index.js +20 -20
- package/dist/io/formats/fig/export/patch/index.js.map +1 -1
- package/dist/io/formats/fig/export/setup.d.ts.map +1 -1
- package/dist/io/formats/fig/export/setup.js +5 -1
- package/dist/io/formats/fig/export/setup.js.map +1 -1
- package/dist/io/formats/fig/index.d.ts +3 -2
- package/dist/io/formats/fig/index.js +2 -2
- package/dist/io/formats/fig/read.d.ts.map +1 -1
- package/dist/io/formats/fig/read.js +5 -2
- package/dist/io/formats/fig/read.js.map +1 -1
- package/dist/io/formats/html/layers.d.ts +3 -1
- package/dist/io/formats/html/layers.d.ts.map +1 -1
- package/dist/io/formats/html/layers.js +6 -1
- package/dist/io/formats/html/layers.js.map +1 -1
- package/dist/io/formats/pdf/export.d.ts.map +1 -1
- package/dist/io/formats/pdf/export.js +7 -3
- package/dist/io/formats/pdf/export.js.map +1 -1
- package/dist/io/formats/pdf/plan.d.ts +3 -0
- package/dist/io/formats/pdf/plan.d.ts.map +1 -1
- package/dist/io/formats/pdf/plan.js +60 -36
- package/dist/io/formats/pdf/plan.js.map +1 -1
- package/dist/io/formats/raster/headless.d.ts.map +1 -1
- package/dist/io/formats/raster/headless.js +3 -2
- package/dist/io/formats/raster/headless.js.map +1 -1
- package/dist/io/formats/raster/index.d.ts +2 -2
- package/dist/io/formats/raster/index.js +2 -2
- package/dist/io/formats/raster/render.d.ts +10 -2
- package/dist/io/formats/raster/render.d.ts.map +1 -1
- package/dist/io/formats/raster/render.js +35 -9
- package/dist/io/formats/raster/render.js.map +1 -1
- package/dist/io/formats/svg/defs.d.ts.map +1 -1
- package/dist/io/formats/svg/defs.js +19 -1
- package/dist/io/formats/svg/defs.js.map +1 -1
- package/dist/io/formats/svg/export.d.ts +5 -2
- package/dist/io/formats/svg/export.d.ts.map +1 -1
- package/dist/io/formats/svg/export.js +59 -10
- package/dist/io/formats/svg/export.js.map +1 -1
- package/dist/io/formats/svg/index.d.ts +2 -2
- package/dist/io/formats/svg/index.js +2 -2
- package/dist/io/formats/svg/text/layout.d.ts.map +1 -1
- package/dist/io/formats/svg/text/layout.js +4 -2
- package/dist/io/formats/svg/text/layout.js.map +1 -1
- package/dist/io/formats/video/record.d.ts.map +1 -1
- package/dist/io/formats/video/record.js +24 -9
- package/dist/io/formats/video/record.js.map +1 -1
- package/dist/io/formats.d.ts.map +1 -1
- package/dist/io/formats.js +20 -13
- package/dist/io/formats.js.map +1 -1
- package/dist/kiwi/fig/population/client.d.ts.map +1 -1
- package/dist/kiwi/fig/population/client.js +2 -1
- package/dist/kiwi/fig/population/client.js.map +1 -1
- package/dist/kiwi/fig/session/document-state.d.ts +46 -2
- package/dist/kiwi/fig/session/document-state.d.ts.map +1 -1
- package/dist/kiwi/fig/session/document-state.js +113 -5
- package/dist/kiwi/fig/session/document-state.js.map +1 -1
- package/dist/kiwi/fig/session/options.d.ts +4 -0
- package/dist/kiwi/fig/session/options.d.ts.map +1 -1
- package/dist/kiwi/fig/session/options.js.map +1 -1
- package/dist/layout/apply.d.ts.map +1 -1
- package/dist/layout/apply.js +8 -4
- package/dist/layout/apply.js.map +1 -1
- package/dist/layout/auto-layout-handles.js +1 -1
- package/dist/layout/auto-layout-handles.js.map +1 -1
- package/dist/layout/axis-sizing.d.ts.map +1 -1
- package/dist/layout/axis-sizing.js +1 -1
- package/dist/layout/axis-sizing.js.map +1 -1
- package/dist/layout/derived.d.ts.map +1 -1
- package/dist/layout/derived.js +1 -1
- package/dist/layout/derived.js.map +1 -1
- package/dist/layout/effective-generated-text.js +1 -1
- package/dist/layout/effective-generated-text.js.map +1 -1
- package/dist/layout/grid.d.ts +3 -1
- package/dist/layout/grid.d.ts.map +1 -1
- package/dist/layout/grid.js +57 -16
- package/dist/layout/grid.js.map +1 -1
- package/dist/layout.d.ts +1 -1
- package/dist/layout.js +6 -5
- package/dist/layout.js.map +1 -1
- package/dist/node/fs.d.ts.map +1 -1
- package/dist/node/fs.js +28 -7
- package/dist/node/fs.js.map +1 -1
- package/dist/prototype/easing.d.ts +13 -5
- package/dist/prototype/easing.d.ts.map +1 -1
- package/dist/prototype/easing.js +46 -6
- package/dist/prototype/easing.js.map +1 -1
- package/dist/prototype/scenes.d.ts +31 -0
- package/dist/prototype/scenes.d.ts.map +1 -1
- package/dist/prototype/scenes.js +220 -31
- package/dist/prototype/scenes.js.map +1 -1
- package/dist/prototype/session.d.ts.map +1 -1
- package/dist/prototype/session.js +1 -0
- package/dist/prototype/session.js.map +1 -1
- package/dist/prototype/smart-animate/animation.d.ts +2 -1
- package/dist/prototype/smart-animate/animation.d.ts.map +1 -1
- package/dist/prototype/smart-animate/animation.js +2 -2
- package/dist/prototype/smart-animate/animation.js.map +1 -1
- package/dist/prototype/timeline.d.ts +10 -1
- package/dist/prototype/timeline.d.ts.map +1 -1
- package/dist/prototype/timeline.js +69 -23
- package/dist/prototype/timeline.js.map +1 -1
- package/dist/prototype/variables.d.ts +23 -0
- package/dist/prototype/variables.d.ts.map +1 -0
- package/dist/prototype/variables.js +237 -0
- package/dist/prototype/variables.js.map +1 -0
- package/dist/rpc/read-commands.d.ts +5 -0
- package/dist/rpc/read-commands.d.ts.map +1 -1
- package/dist/rpc/read-commands.js +4 -1
- package/dist/rpc/read-commands.js.map +1 -1
- package/dist/text/character-style.d.ts +8 -1
- package/dist/text/character-style.d.ts.map +1 -1
- package/dist/text/character-style.js +39 -1
- package/dist/text/character-style.js.map +1 -1
- package/dist/text/index.d.ts +2 -2
- package/dist/text/index.js +2 -2
- package/dist/tools/create/basic.js +3 -4
- package/dist/tools/create/basic.js.map +1 -1
- package/dist/tools/create/behaviours.js +1 -1
- package/dist/tools/create/code.d.ts +6 -0
- package/dist/tools/create/code.d.ts.map +1 -0
- package/dist/tools/create/code.js +68 -0
- package/dist/tools/create/code.js.map +1 -0
- package/dist/tools/create/html.d.ts.map +1 -1
- package/dist/tools/create/html.js +9 -57
- package/dist/tools/create/html.js.map +1 -1
- package/dist/tools/create/icons.js +1 -1
- package/dist/tools/create/inputs.d.ts +11 -0
- package/dist/tools/create/inputs.d.ts.map +1 -0
- package/dist/tools/create/inputs.js +15 -0
- package/dist/tools/create/inputs.js.map +1 -0
- package/dist/tools/create/mermaid.d.ts.map +1 -1
- package/dist/tools/create/mermaid.js +5 -6
- package/dist/tools/create/mermaid.js.map +1 -1
- package/dist/tools/create/place.d.ts +30 -0
- package/dist/tools/create/place.d.ts.map +1 -0
- package/dist/tools/create/place.js +70 -0
- package/dist/tools/create/place.js.map +1 -0
- package/dist/tools/create/render.js +1 -1
- package/dist/tools/create/svg.js +1 -1
- package/dist/tools/create/vector.js +1 -1
- package/dist/tools/create.d.ts +2 -1
- package/dist/tools/create.js +2 -1
- package/dist/tools/css/gradient.d.ts +28 -0
- package/dist/tools/css/gradient.d.ts.map +1 -0
- package/dist/tools/css/gradient.js +118 -0
- package/dist/tools/css/gradient.js.map +1 -0
- package/dist/tools/image-ai/generate.js +1 -1
- package/dist/tools/modify/geometry.js +5 -5
- package/dist/tools/modify/geometry.js.map +1 -1
- package/dist/tools/modify/layout.d.ts.map +1 -1
- package/dist/tools/modify/layout.js +7 -1
- package/dist/tools/modify/layout.js.map +1 -1
- package/dist/tools/modify/matching.js +1 -1
- package/dist/tools/modify/overrides.d.ts +6 -0
- package/dist/tools/modify/overrides.d.ts.map +1 -0
- package/dist/tools/modify/overrides.js +27 -0
- package/dist/tools/modify/overrides.js.map +1 -0
- package/dist/tools/modify/paint.d.ts.map +1 -1
- package/dist/tools/modify/paint.js +84 -39
- package/dist/tools/modify/paint.js.map +1 -1
- package/dist/tools/modify/text.d.ts +2 -1
- package/dist/tools/modify/text.d.ts.map +1 -1
- package/dist/tools/modify/text.js +79 -8
- package/dist/tools/modify/text.js.map +1 -1
- package/dist/tools/modify/update.d.ts.map +1 -1
- package/dist/tools/modify/update.js +18 -2
- package/dist/tools/modify/update.js.map +1 -1
- package/dist/tools/modify.d.ts +3 -2
- package/dist/tools/modify.js +3 -2
- package/dist/tools/read/css.d.ts.map +1 -1
- package/dist/tools/read/css.js +29 -12
- package/dist/tools/read/css.js.map +1 -1
- package/dist/tools/read/libraries.js +1 -1
- package/dist/tools/read/nodes.d.ts.map +1 -1
- package/dist/tools/read/nodes.js +19 -5
- package/dist/tools/read/nodes.js.map +1 -1
- package/dist/tools/registry/extended.d.ts.map +1 -1
- package/dist/tools/registry/extended.js +6 -1
- package/dist/tools/registry/extended.js.map +1 -1
- package/dist/tools/text-range.d.ts +11 -0
- package/dist/tools/text-range.d.ts.map +1 -0
- package/dist/tools/text-range.js +26 -0
- package/dist/tools/text-range.js.map +1 -0
- package/dist/tools/variables/bindings.js +1 -1
- package/dist/tools/variables/bindings.js.map +1 -1
- package/dist/tools/variables/unbind.js +1 -1
- package/dist/tools/variables/unbind.js.map +1 -1
- package/dist/tools/vector/path.d.ts.map +1 -1
- package/dist/tools/vector/path.js +7 -21
- package/dist/tools/vector/path.js.map +1 -1
- package/dist/vector/rebase.d.ts +17 -0
- package/dist/vector/rebase.d.ts.map +1 -0
- package/dist/vector/rebase.js +32 -0
- package/dist/vector/rebase.js.map +1 -0
- package/package.json +14 -9
- package/src/canvas/boolean.ts +12 -1
- package/src/canvas/color-space.ts +73 -0
- package/src/canvas/fills.ts +130 -83
- package/src/canvas/flatten.ts +92 -7
- package/src/canvas/index.ts +9 -0
- package/src/canvas/layout-grids.ts +15 -2
- package/src/canvas/noise/render.ts +35 -7
- package/src/canvas/noise/shader.ts +8 -10
- package/src/canvas/overlays/annotations.ts +117 -0
- package/src/canvas/overlays/auto-layout-hover.ts +41 -1
- package/src/canvas/overlays/feedback.ts +7 -2
- package/src/canvas/overlays/index.ts +1 -1
- package/src/canvas/overlays/measurement.ts +49 -3
- package/src/canvas/overlays/presence.ts +35 -32
- package/src/canvas/renderer/colors.ts +14 -0
- package/src/canvas/renderer/document-surface.ts +16 -6
- package/src/canvas/renderer/lifecycle.ts +2 -2
- package/src/canvas/renderer/methods.ts +4 -0
- package/src/canvas/renderer/overlay-pass.ts +4 -0
- package/src/canvas/renderer/pipeline.ts +8 -0
- package/src/canvas/renderer/types.ts +8 -0
- package/src/canvas/renderer.ts +21 -2
- package/src/canvas/scene.ts +15 -7
- package/src/clipboard/pairdraw.ts +1 -0
- package/src/editor/bridges/clipboard.ts +1 -0
- package/src/editor/bridges/components.ts +10 -0
- package/src/editor/clipboard/code.ts +50 -0
- package/src/editor/clipboard/paste/dependencies.ts +18 -0
- package/src/editor/clipboard/paste/run.ts +64 -0
- package/src/editor/clipboard/styled.ts +4 -52
- package/src/editor/clipboard.ts +40 -0
- package/src/editor/components/instances.ts +92 -4
- package/src/editor/components/slots/index.ts +7 -0
- package/src/editor/components.ts +16 -2
- package/src/editor/create.ts +15 -1
- package/src/editor/design-tokens.ts +3 -23
- package/src/editor/image-edit.ts +5 -2
- package/src/editor/index.ts +1 -0
- package/src/editor/layout-mode.ts +131 -3
- package/src/editor/nodes.ts +30 -5
- package/src/editor/read-only/actions.ts +6 -0
- package/src/editor/selection/overlays.ts +8 -0
- package/src/editor/state/shared.ts +1 -0
- package/src/editor/state/view.ts +2 -0
- package/src/editor/structure/boolean.ts +29 -1
- package/src/editor/structure/container-wrap.ts +20 -4
- package/src/editor/structure/flatten.ts +15 -8
- package/src/editor/structure/group/ungroup.ts +2 -0
- package/src/editor/structure/outline-stroke.ts +5 -0
- package/src/editor/styles.ts +203 -0
- package/src/editor/text/selection-style.ts +18 -1
- package/src/editor/tool-registry.ts +2 -0
- package/src/editor/types.ts +14 -0
- package/src/editor/variable-bindings.ts +11 -0
- package/src/figma-api/accessors/basic.ts +33 -1
- package/src/figma-api/accessors/vector.ts +6 -13
- package/src/figma-api/compatibility.ts +1 -0
- package/src/figma-api/component-scope.ts +36 -0
- package/src/figma-api/components.ts +24 -0
- package/src/figma-api/flatten.ts +7 -3
- package/src/figma-api/index.ts +302 -6
- package/src/figma-api/node-types.ts +1 -0
- package/src/figma-api/overrides.ts +192 -5
- package/src/figma-api/proxy.ts +16 -1
- package/src/figma-api/reactions.ts +163 -12
- package/src/figma-api/slots.ts +10 -9
- package/src/io/formats/code/detect.ts +67 -0
- package/src/io/formats/code/index.ts +17 -0
- package/src/io/formats/code/read.ts +143 -0
- package/src/io/formats/code/stylesheet.ts +24 -0
- package/src/io/formats/code/tokens.ts +159 -0
- package/src/io/formats/design-tokens/apply.ts +3 -2
- package/src/io/formats/fig/export/patch/fields.ts +11 -0
- package/src/io/formats/fig/export/patch/index.ts +23 -19
- package/src/io/formats/fig/export/setup.ts +8 -1
- package/src/io/formats/fig/index.ts +6 -0
- package/src/io/formats/fig/read.ts +11 -2
- package/src/io/formats/html/layers.ts +7 -0
- package/src/io/formats/pdf/export.ts +19 -7
- package/src/io/formats/pdf/plan.ts +71 -32
- package/src/io/formats/raster/headless.ts +3 -1
- package/src/io/formats/raster/index.ts +2 -0
- package/src/io/formats/raster/render.ts +49 -9
- package/src/io/formats/svg/defs.ts +27 -1
- package/src/io/formats/svg/export.ts +75 -13
- package/src/io/formats/svg/index.ts +1 -0
- package/src/io/formats/svg/text/layout.ts +5 -3
- package/src/io/formats/video/record.ts +33 -9
- package/src/io/formats.ts +35 -15
- package/src/kiwi/fig/population/client.ts +6 -1
- package/src/kiwi/fig/session/document-state.ts +195 -5
- package/src/kiwi/fig/session/options.ts +2 -0
- package/src/layout/apply.ts +12 -4
- package/src/layout/auto-layout-handles.ts +1 -1
- package/src/layout/axis-sizing.ts +3 -1
- package/src/layout/derived.ts +3 -1
- package/src/layout/effective-generated-text.ts +1 -1
- package/src/layout/grid.ts +91 -21
- package/src/layout.ts +16 -3
- package/src/node/fs.ts +32 -7
- package/src/prototype/easing.ts +79 -7
- package/src/prototype/scenes.ts +244 -15
- package/src/prototype/session.ts +1 -0
- package/src/prototype/smart-animate/animation.ts +4 -3
- package/src/prototype/timeline.ts +118 -26
- package/src/prototype/variables.ts +189 -0
- package/src/rpc/read-commands.ts +19 -1
- package/src/text/character-style.ts +47 -0
- package/src/text/index.ts +1 -1
- package/src/tools/create/basic.ts +2 -3
- package/src/tools/create/code.ts +85 -0
- package/src/tools/create/html.ts +9 -46
- package/src/tools/create/inputs.ts +12 -0
- package/src/tools/create/mermaid.ts +6 -6
- package/src/tools/create/place.ts +80 -0
- package/src/tools/create.ts +1 -0
- package/src/tools/css/gradient.ts +147 -0
- package/src/tools/modify/geometry.ts +5 -5
- package/src/tools/modify/layout.ts +19 -0
- package/src/tools/modify/overrides.ts +35 -0
- package/src/tools/modify/paint.ts +124 -54
- package/src/tools/modify/text.ts +91 -7
- package/src/tools/modify/update.ts +23 -2
- package/src/tools/modify.ts +9 -1
- package/src/tools/read/css.ts +46 -12
- package/src/tools/read/nodes.ts +26 -4
- package/src/tools/registry/extended.ts +6 -0
- package/src/tools/text-range.ts +29 -0
- package/src/tools/variables/bindings.ts +4 -1
- package/src/tools/variables/unbind.ts +4 -1
- package/src/tools/vector/path.ts +11 -13
- package/src/vector/rebase.ts +33 -0
package/src/canvas/fills.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Canvas, Image, Paint, Shader } from 'canvaskit-wasm'
|
|
2
2
|
|
|
3
|
-
import type { SceneNode, SceneGraph, Fill } from '@pairdraw/scene-graph'
|
|
3
|
+
import type { SceneNode, SceneGraph, Fill, NoiseEffect, NoiseType } from '@pairdraw/scene-graph'
|
|
4
4
|
import { invertGradientTransform, isMeshFill } from '@pairdraw/scene-graph/gradient'
|
|
5
|
-
import
|
|
5
|
+
import { makeImageFillLocalMatrix } from '@pairdraw/scene-graph/images'
|
|
6
6
|
import type { Color, Rect, Vector } from '@pairdraw/scene-graph/primitives'
|
|
7
7
|
|
|
8
8
|
import { setPaintBlendMode } from './blend'
|
|
@@ -10,6 +10,7 @@ import { makeDiamondGradient } from './gradients/diamond'
|
|
|
10
10
|
import { adjustedImageShader, hasImageAdjustments } from './images/adjustments'
|
|
11
11
|
import { previewEdge } from './images/previews'
|
|
12
12
|
import { drawOffOutputGrid, landsOnOutputPixels, makeImageShader } from './images/sampling'
|
|
13
|
+
import { renderFigmaNoiseEffects } from './noise/render'
|
|
13
14
|
import type { SkiaRenderer } from './renderer'
|
|
14
15
|
import { drawUserShaderFill } from './shaders/draw'
|
|
15
16
|
import { drawOutline, withNodeOutline } from './shapes'
|
|
@@ -17,6 +18,46 @@ import { drawOutline, withNodeOutline } from './shapes'
|
|
|
17
18
|
interface PaintFillsOptions {
|
|
18
19
|
readonly bindToNodeFills?: boolean
|
|
19
20
|
readonly patternStack?: Set<string>
|
|
21
|
+
/** The canvas a noise fill grains; without it the fill stays its own colour. */
|
|
22
|
+
readonly canvas?: Canvas
|
|
23
|
+
/** Clips a noise fill's grain: the layer's shape unless the fill covers only one of its paths. */
|
|
24
|
+
readonly clip?: (canvas: Canvas) => void
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** A noise paint as the grain shader reads it; a paint carries no seed, so grains repeat. */
|
|
28
|
+
function noiseEffectOf(fill: Fill, color: Color): NoiseEffect {
|
|
29
|
+
const noiseType: NoiseType = fill.noiseType ?? 'MONOTONE'
|
|
30
|
+
const noise: NoiseEffect['noise'] = {
|
|
31
|
+
noiseType,
|
|
32
|
+
noiseSize: fill.noiseSize ?? { x: 0.5, y: 0.5 },
|
|
33
|
+
density: fill.density ?? 0.4
|
|
34
|
+
}
|
|
35
|
+
if (noiseType === 'MULTITONE') noise.opacity = 1
|
|
36
|
+
// A paint carries one colour; a duotone's opposite tone shows as white.
|
|
37
|
+
if (noiseType === 'DUOTONE') noise.secondaryColor = { r: 1, g: 1, b: 1, a: 1 }
|
|
38
|
+
return { type: 'NOISE', color, visible: true, noise }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Draws a noise paint as its grain and reports whether it did. The flat colour is not drawn
|
|
43
|
+
* under it: a monotone grain is its own colour at varying alpha, so a solid base of that colour
|
|
44
|
+
* would leave nothing to see. Text draws glyphs and a line draws no fill, so both keep their flat
|
|
45
|
+
* colour; a runtime without the shader falls back to it too.
|
|
46
|
+
*/
|
|
47
|
+
function drawNoiseFillGrain(
|
|
48
|
+
r: SkiaRenderer,
|
|
49
|
+
fill: Fill,
|
|
50
|
+
color: Color,
|
|
51
|
+
node: SceneNode,
|
|
52
|
+
options: PaintFillsOptions
|
|
53
|
+
): boolean {
|
|
54
|
+
if (fill.type !== 'NOISE' || !options.canvas) return false
|
|
55
|
+
if (node.type === 'TEXT' || node.type === 'LINE') return false
|
|
56
|
+
const clip = options.clip ?? ((target: Canvas) => r.clipNodeShape(target, node))
|
|
57
|
+
return renderFigmaNoiseEffects(r, options.canvas, node, clip, [noiseEffectOf(fill, color)], {
|
|
58
|
+
opacity: fill.opacity,
|
|
59
|
+
blendMode: fill.blendMode
|
|
60
|
+
})
|
|
20
61
|
}
|
|
21
62
|
|
|
22
63
|
export function paintFills(
|
|
@@ -31,13 +72,38 @@ export function paintFills(
|
|
|
31
72
|
const fill = fills[index]
|
|
32
73
|
if (!fill.visible) continue
|
|
33
74
|
const fillIndex = options.bindToNodeFills === false ? -1 : index
|
|
75
|
+
// A noise paint's only flat use is the fallback below, so resolve its document-space colour
|
|
76
|
+
// once here and hand it to the grain; the drawn-space colour is resolved only if the shader
|
|
77
|
+
// cannot draw. `applyFill` would resolve the paint again just to set that fallback colour.
|
|
78
|
+
if (fill.type === 'NOISE') {
|
|
79
|
+
const canGrain = options.canvas !== undefined && node.type !== 'TEXT' && node.type !== 'LINE'
|
|
80
|
+
if (canGrain) {
|
|
81
|
+
const color = r.resolveFillColorInDocumentSpace(fill, fillIndex, node, graph)
|
|
82
|
+
if (drawNoiseFillGrain(r, fill, color, node, options)) {
|
|
83
|
+
r.fillPaint.setShader(null)
|
|
84
|
+
r.fillPaint.setBlendMode(r.ck.BlendMode.SrcOver)
|
|
85
|
+
continue
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const drawn = r.resolveFillColor(fill, fillIndex, node, graph)
|
|
89
|
+
r.fillPaint.setShader(null)
|
|
90
|
+
r.fillPaint.setColor(r.ck.Color4f(drawn.r, drawn.g, drawn.b, drawn.a))
|
|
91
|
+
r.fillPaint.setAlphaf(fill.opacity)
|
|
92
|
+
setPaintBlendMode(r, r.fillPaint, fill.blendMode)
|
|
93
|
+
draw(fill)
|
|
94
|
+
r.fillPaint.setShader(null)
|
|
95
|
+
r.fillPaint.setBlendMode(r.ck.BlendMode.SrcOver)
|
|
96
|
+
continue
|
|
97
|
+
}
|
|
34
98
|
const applied = options.patternStack
|
|
35
99
|
? applyFill(r, fill, node, graph, fillIndex, options.patternStack)
|
|
36
100
|
: r.applyFill(fill, node, graph, fillIndex)
|
|
37
101
|
if (!applied) continue
|
|
38
|
-
r
|
|
39
|
-
|
|
40
|
-
|
|
102
|
+
if (!drawNoiseFillGrain(r, fill, fill.color, node, options)) {
|
|
103
|
+
r.fillPaint.setAlphaf(fill.opacity)
|
|
104
|
+
setPaintBlendMode(r, r.fillPaint, fill.blendMode)
|
|
105
|
+
draw(fill)
|
|
106
|
+
}
|
|
41
107
|
r.fillPaint.setShader(null)
|
|
42
108
|
r.fillPaint.setBlendMode(r.ck.BlendMode.SrcOver)
|
|
43
109
|
}
|
|
@@ -66,7 +132,12 @@ export function drawVectorMultiStyleFills(
|
|
|
66
132
|
node,
|
|
67
133
|
graph,
|
|
68
134
|
() => canvas.drawPath(path, r.fillPaint),
|
|
69
|
-
{
|
|
135
|
+
{
|
|
136
|
+
bindToNodeFills: !usesPathFills,
|
|
137
|
+
patternStack,
|
|
138
|
+
canvas,
|
|
139
|
+
clip: (target) => target.clipPath(path, r.ck.ClipOp.Intersect, true)
|
|
140
|
+
}
|
|
70
141
|
)
|
|
71
142
|
}
|
|
72
143
|
return true
|
|
@@ -118,19 +189,27 @@ export function applyFill(
|
|
|
118
189
|
}
|
|
119
190
|
|
|
120
191
|
interface PatternTileLayout {
|
|
192
|
+
/**
|
|
193
|
+
* The tile in the layer's space. Its own offset carries the alignment: a picture's content is
|
|
194
|
+
* clipped to the picture's bounds, so shifting the content instead would cut it away.
|
|
195
|
+
*/
|
|
121
196
|
rect: Rect
|
|
122
197
|
scale: number
|
|
198
|
+
/** Copies of the source inside one tile, for a hexagonal tile that needs two. */
|
|
123
199
|
positions: Vector[]
|
|
124
200
|
}
|
|
125
201
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
202
|
+
/**
|
|
203
|
+
* Where the tile grid starts on one axis: the alignment anchors it in the layer, so CENTER pulls
|
|
204
|
+
* it back half a tile and END a whole one. A whole tile is a period of the repeat, which puts END
|
|
205
|
+
* and START on the same phase. The alignment oracle in
|
|
206
|
+
* `tests/fixtures/figma-oracles/pattern-noise-custom-paints.json` measures that anchoring against
|
|
207
|
+
* Figma: START rows align (delta 0), CENTER sits half a row period off (3 px), END a whole one
|
|
208
|
+
* (6.67 px).
|
|
209
|
+
*/
|
|
210
|
+
function patternAlignmentOffset(alignment: Fill['horizontalAlignment'], tile: number): number {
|
|
211
|
+
if (alignment === 'CENTER') return -tile / 2
|
|
212
|
+
if (alignment === 'END') return -tile
|
|
134
213
|
return 0
|
|
135
214
|
}
|
|
136
215
|
|
|
@@ -143,17 +222,17 @@ export function patternTileLayout(source: SceneNode, fill: Fill): PatternTileLay
|
|
|
143
222
|
const gapY = scaledHeight * spacing.y
|
|
144
223
|
const width = scaledWidth + gapX
|
|
145
224
|
const height = scaledHeight + gapY
|
|
146
|
-
const x = patternAlignmentOffset(fill.horizontalAlignment,
|
|
147
|
-
const y = patternAlignmentOffset(fill.verticalAlignment,
|
|
148
|
-
const positions = [{ x, y }]
|
|
225
|
+
const x = patternAlignmentOffset(fill.horizontalAlignment, width)
|
|
226
|
+
const y = patternAlignmentOffset(fill.verticalAlignment, height)
|
|
227
|
+
const positions = [{ x: 0, y: 0 }]
|
|
149
228
|
|
|
150
229
|
if (fill.patternTileType === 'HORIZONTAL_HEXAGONAL') {
|
|
151
|
-
positions.push({ x:
|
|
230
|
+
positions.push({ x: width / 2, y: height / 2 })
|
|
152
231
|
} else if (fill.patternTileType === 'VERTICAL_HEXAGONAL') {
|
|
153
|
-
positions.push({ x:
|
|
232
|
+
positions.push({ x: width / 2, y: -height / 2 })
|
|
154
233
|
}
|
|
155
234
|
|
|
156
|
-
return { rect: { x
|
|
235
|
+
return { rect: { x, y, width, height }, scale, positions }
|
|
157
236
|
}
|
|
158
237
|
|
|
159
238
|
function recordPatternSource(
|
|
@@ -163,25 +242,41 @@ function recordPatternSource(
|
|
|
163
242
|
layout: PatternTileLayout,
|
|
164
243
|
patternStack: Set<string>
|
|
165
244
|
) {
|
|
166
|
-
const
|
|
245
|
+
const width = layout.rect.width
|
|
246
|
+
const height = layout.rect.height
|
|
247
|
+
const bounds = r.ck.LTRBRect(0, 0, width, height)
|
|
167
248
|
const recorder = new r.ck.PictureRecorder()
|
|
168
249
|
const canvas = recorder.beginRecording(bounds)
|
|
250
|
+
// A picture clips what it records, so the tile's own offset is spent by moving the source inside
|
|
251
|
+
// the tile and drawing the copies that wrap across its edges.
|
|
252
|
+
const wrap = (value: number, size: number) => ((value % size) + size) % size
|
|
253
|
+
const originX = wrap(layout.rect.x, width)
|
|
254
|
+
const originY = wrap(layout.rect.y, height)
|
|
255
|
+
const sourceWidth = source.width * layout.scale
|
|
256
|
+
const sourceHeight = source.height * layout.scale
|
|
169
257
|
|
|
170
258
|
for (const position of layout.positions) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
graph,
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
259
|
+
for (const turnX of [-1, 0, 1]) {
|
|
260
|
+
for (const turnY of [-1, 0, 1]) {
|
|
261
|
+
const x = originX + position.x + turnX * width
|
|
262
|
+
const y = originY + position.y + turnY * height
|
|
263
|
+
if (x + sourceWidth <= 0 || x >= width || y + sourceHeight <= 0 || y >= height) continue
|
|
264
|
+
canvas.save()
|
|
265
|
+
canvas.translate(x, y)
|
|
266
|
+
canvas.scale(layout.scale, layout.scale)
|
|
267
|
+
if (!drawVectorMultiStyleFills(r, canvas, source, graph, patternStack)) {
|
|
268
|
+
paintFills(
|
|
269
|
+
r,
|
|
270
|
+
source.fills,
|
|
271
|
+
source,
|
|
272
|
+
graph,
|
|
273
|
+
(sourceFill) => drawNodeFill(r, canvas, source, sourceFill),
|
|
274
|
+
{ patternStack, canvas }
|
|
275
|
+
)
|
|
276
|
+
}
|
|
277
|
+
canvas.restore()
|
|
278
|
+
}
|
|
183
279
|
}
|
|
184
|
-
canvas.restore()
|
|
185
280
|
}
|
|
186
281
|
|
|
187
282
|
const picture = recorder.finishRecordingAsPicture()
|
|
@@ -299,7 +394,7 @@ function applyPatternFill(
|
|
|
299
394
|
patternStack.delete(source.id)
|
|
300
395
|
}
|
|
301
396
|
const tile = layout.rect
|
|
302
|
-
const tileRect = r.ck.LTRBRect(
|
|
397
|
+
const tileRect = r.ck.LTRBRect(0, 0, tile.width, tile.height)
|
|
303
398
|
const shader = picture.makeShader(
|
|
304
399
|
r.ck.TileMode.Repeat,
|
|
305
400
|
r.ck.TileMode.Repeat,
|
|
@@ -424,54 +519,6 @@ export function applyGradientFill(
|
|
|
424
519
|
return false
|
|
425
520
|
}
|
|
426
521
|
|
|
427
|
-
/**
|
|
428
|
-
* Maps `img`'s pixels onto `node` as `fill` places them. `size` is the image's own size when `img`
|
|
429
|
-
* is a downscaled preview, so a tile keeps its size. A crop places the image by its transform;
|
|
430
|
-
* Fill, Fit and Tile ignore it, as Figma does, and turn the image by `imageRotation` first.
|
|
431
|
-
*/
|
|
432
|
-
export function makeImageFillLocalMatrix(
|
|
433
|
-
fill: Fill,
|
|
434
|
-
node: SceneNode,
|
|
435
|
-
imgW: number,
|
|
436
|
-
imgH: number,
|
|
437
|
-
size: { width: number; height: number } = { width: imgW, height: imgH }
|
|
438
|
-
) {
|
|
439
|
-
const scaleMode = fill.imageScaleMode ?? 'FILL'
|
|
440
|
-
if (scaleMode === 'CROP' && fill.imageTransform) {
|
|
441
|
-
const t = fill.imageTransform
|
|
442
|
-
const inverse = Matrix.invert([t.m00, t.m01, t.m02, t.m10, t.m11, t.m12, 0, 0, 1])
|
|
443
|
-
if (inverse)
|
|
444
|
-
return Matrix.multiply(
|
|
445
|
-
Matrix.scaled(node.width, node.height),
|
|
446
|
-
inverse,
|
|
447
|
-
Matrix.scaled(1 / imgW, 1 / imgH)
|
|
448
|
-
)
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
const radians = ((fill.imageRotation ?? 0) * Math.PI) / 180
|
|
452
|
-
const cos = Math.abs(Math.cos(radians))
|
|
453
|
-
const sin = Math.abs(Math.sin(radians))
|
|
454
|
-
const turnedW = size.width * cos + size.height * sin
|
|
455
|
-
const turnedH = size.width * sin + size.height * cos
|
|
456
|
-
const turned = Matrix.multiply(
|
|
457
|
-
Matrix.translated(turnedW / 2, turnedH / 2),
|
|
458
|
-
Matrix.rotated(radians),
|
|
459
|
-
Matrix.translated(-size.width / 2, -size.height / 2),
|
|
460
|
-
Matrix.scaled(size.width / imgW, size.height / imgH)
|
|
461
|
-
)
|
|
462
|
-
if (scaleMode === 'TILE') {
|
|
463
|
-
const scale = fill.scale && fill.scale > 0 ? fill.scale : 1
|
|
464
|
-
return Matrix.multiply(Matrix.scaled(scale, scale), turned)
|
|
465
|
-
}
|
|
466
|
-
const fit = scaleMode === 'FIT'
|
|
467
|
-
const scale = (fit ? Math.min : Math.max)(node.width / turnedW, node.height / turnedH)
|
|
468
|
-
return Matrix.multiply(
|
|
469
|
-
Matrix.translated((node.width - turnedW * scale) / 2, (node.height - turnedH * scale) / 2),
|
|
470
|
-
Matrix.scaled(scale, scale),
|
|
471
|
-
turned
|
|
472
|
-
)
|
|
473
|
-
}
|
|
474
|
-
|
|
475
522
|
/**
|
|
476
523
|
* Sets `paint`'s shader to `img` laid out as `fill` places it on `node`; `preview`, when `img`
|
|
477
524
|
* is a downscaled preview, keeps a tiled image at its original size.
|
package/src/canvas/flatten.ts
CHANGED
|
@@ -2,19 +2,41 @@ import type { Path } from 'canvaskit-wasm'
|
|
|
2
2
|
|
|
3
3
|
import type { SceneGraph, SceneNode, VectorNetwork } from '@pairdraw/scene-graph'
|
|
4
4
|
import { getNodeLocalMatrix } from '@pairdraw/scene-graph/coordinate'
|
|
5
|
-
import { copyFills } from '@pairdraw/scene-graph/copy'
|
|
5
|
+
import { copyEffects, copyFills, copyStrokes } from '@pairdraw/scene-graph/copy'
|
|
6
6
|
import { parseSVGPath } from '@pairdraw/scene-graph/parse-path'
|
|
7
7
|
import type { Rect, Vector } from '@pairdraw/scene-graph/primitives'
|
|
8
8
|
import { mergeVectorNetworks } from '@pairdraw/scene-graph/vector-network'
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
canContainFlattenableChildren,
|
|
12
|
+
makeBooleanSourcePath,
|
|
13
|
+
makeFlattenPath,
|
|
14
|
+
placedPath,
|
|
15
|
+
windingRuleOf
|
|
16
|
+
} from './boolean'
|
|
11
17
|
import type { SkiaRenderer } from './renderer'
|
|
12
18
|
|
|
13
|
-
|
|
19
|
+
/** The vector a silhouette keeps: its geometry and the topmost layer's fills, no stroke of its own. */
|
|
20
|
+
export type VectorGeometryProps = Pick<
|
|
14
21
|
SceneNode,
|
|
15
|
-
'name' | 'x' | 'y' | 'width' | 'height' | 'fills' | 'vectorNetwork'
|
|
22
|
+
'name' | 'x' | 'y' | 'width' | 'height' | 'fills' | 'strokes' | 'vectorNetwork'
|
|
16
23
|
>
|
|
17
24
|
|
|
25
|
+
/** A vector a single layer flattens to, keeping that layer's whole appearance. */
|
|
26
|
+
export type VectorFlattenProps = VectorGeometryProps &
|
|
27
|
+
Pick<
|
|
28
|
+
SceneNode,
|
|
29
|
+
| 'strokes'
|
|
30
|
+
| 'strokeWeight'
|
|
31
|
+
| 'strokeAlign'
|
|
32
|
+
| 'strokeJoin'
|
|
33
|
+
| 'strokeMiterLimit'
|
|
34
|
+
| 'dashPattern'
|
|
35
|
+
| 'effects'
|
|
36
|
+
| 'opacity'
|
|
37
|
+
| 'blendMode'
|
|
38
|
+
>
|
|
39
|
+
|
|
18
40
|
type NodePathFactory = (
|
|
19
41
|
renderer: SkiaRenderer,
|
|
20
42
|
graph: SceneGraph,
|
|
@@ -26,7 +48,7 @@ function nodesToVectorProps(
|
|
|
26
48
|
graph: SceneGraph,
|
|
27
49
|
nodes: SceneNode[],
|
|
28
50
|
makeNodePath: NodePathFactory
|
|
29
|
-
):
|
|
51
|
+
): VectorGeometryProps | null {
|
|
30
52
|
const placed: Path[] = []
|
|
31
53
|
try {
|
|
32
54
|
for (const node of nodes) {
|
|
@@ -41,7 +63,9 @@ function nodesToVectorProps(
|
|
|
41
63
|
return {
|
|
42
64
|
name: 'Flatten',
|
|
43
65
|
...box,
|
|
44
|
-
fills: copyFills(nodes[0].fills),
|
|
66
|
+
fills: copyFills(topmostPaintNode(nodes[0], graph).fills),
|
|
67
|
+
// Several layers become their painted silhouette; the outline carries no stroke of its own.
|
|
68
|
+
strokes: [],
|
|
45
69
|
vectorNetwork: mergeVectorNetworks(drawn.map((path) => networkIn(renderer, path, box)))
|
|
46
70
|
}
|
|
47
71
|
} finally {
|
|
@@ -49,6 +73,20 @@ function nodesToVectorProps(
|
|
|
49
73
|
}
|
|
50
74
|
}
|
|
51
75
|
|
|
76
|
+
/**
|
|
77
|
+
* The layer whose paint a silhouette keeps: the topmost visible layer, entering a container to
|
|
78
|
+
* the topmost layer it draws. A container paints no area of its own, and a mask shapes what is
|
|
79
|
+
* drawn rather than painting it, so it does not supply the paint either.
|
|
80
|
+
*/
|
|
81
|
+
function topmostPaintNode(node: SceneNode, graph: SceneGraph): SceneNode {
|
|
82
|
+
if (!canContainFlattenableChildren(node)) return node
|
|
83
|
+
for (let index = node.childIds.length - 1; index >= 0; index--) {
|
|
84
|
+
const child = graph.getNode(node.childIds[index])
|
|
85
|
+
if (child?.visible && !child.isMask) return topmostPaintNode(child, graph)
|
|
86
|
+
}
|
|
87
|
+
return node
|
|
88
|
+
}
|
|
89
|
+
|
|
52
90
|
function boundsOf(paths: Path[]): Rect | null {
|
|
53
91
|
if (paths.length === 0) return null
|
|
54
92
|
const all = paths.map((path) => path.getBounds())
|
|
@@ -67,11 +105,58 @@ function networkIn(renderer: SkiaRenderer, path: Path, box: Vector): VectorNetwo
|
|
|
67
105
|
return network
|
|
68
106
|
}
|
|
69
107
|
|
|
108
|
+
/** The paint one layer keeps when it flattens: Figma turns the layer into a vector, not a silhouette. */
|
|
109
|
+
function appearanceOf(
|
|
110
|
+
node: SceneNode
|
|
111
|
+
): Omit<VectorFlattenProps, 'name' | 'x' | 'y' | 'width' | 'height' | 'vectorNetwork'> {
|
|
112
|
+
return {
|
|
113
|
+
fills: copyFills(node.fills),
|
|
114
|
+
strokes: copyStrokes(node.strokes),
|
|
115
|
+
strokeWeight: node.strokeWeight,
|
|
116
|
+
strokeAlign: node.strokeAlign,
|
|
117
|
+
strokeJoin: node.strokeJoin,
|
|
118
|
+
strokeMiterLimit: node.strokeMiterLimit,
|
|
119
|
+
dashPattern: [...node.dashPattern],
|
|
120
|
+
effects: copyEffects(node.effects),
|
|
121
|
+
opacity: node.opacity,
|
|
122
|
+
blendMode: node.blendMode
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Flattening one layer leaves it a vector of the same appearance, as Figma's does: the shape's
|
|
128
|
+
* own outline, with the layer's fills, strokes, effects, opacity and blend mode carried over.
|
|
129
|
+
*/
|
|
130
|
+
export function flattenLayerToVectorProps(
|
|
131
|
+
renderer: SkiaRenderer,
|
|
132
|
+
graph: SceneGraph,
|
|
133
|
+
node: SceneNode
|
|
134
|
+
): VectorFlattenProps | null {
|
|
135
|
+
const path = makeFlattenPath(renderer, node, graph)
|
|
136
|
+
if (!path) return null
|
|
137
|
+
const placed = placedPath(renderer, path, getNodeLocalMatrix(node))
|
|
138
|
+
path.delete()
|
|
139
|
+
try {
|
|
140
|
+
if (placed.isEmpty()) return null
|
|
141
|
+
const [left, top, right, bottom] = placed.getBounds()
|
|
142
|
+
if (right <= left || bottom <= top) return null
|
|
143
|
+
const box = { x: left, y: top, width: right - left, height: bottom - top }
|
|
144
|
+
return {
|
|
145
|
+
name: 'Flatten',
|
|
146
|
+
...box,
|
|
147
|
+
...appearanceOf(node),
|
|
148
|
+
vectorNetwork: networkIn(renderer, placed, box)
|
|
149
|
+
}
|
|
150
|
+
} finally {
|
|
151
|
+
placed.delete()
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
70
155
|
export function flattenNodesToVectorProps(
|
|
71
156
|
renderer: SkiaRenderer,
|
|
72
157
|
graph: SceneGraph,
|
|
73
158
|
nodes: SceneNode[]
|
|
74
|
-
):
|
|
159
|
+
): VectorGeometryProps | null {
|
|
75
160
|
return nodesToVectorProps(renderer, graph, nodes, (r, g, node) =>
|
|
76
161
|
makeBooleanSourcePath(r, node, g)
|
|
77
162
|
)
|
package/src/canvas/index.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
export {
|
|
2
|
+
hasFloatRenderTarget,
|
|
3
|
+
isHardwareRenderer,
|
|
4
|
+
isSoftwareRenderer,
|
|
5
|
+
rendererName,
|
|
6
|
+
supportsFloatRenderTarget,
|
|
7
|
+
type ColorSpaceContext,
|
|
8
|
+
type FloatTargetContext
|
|
9
|
+
} from './color-space'
|
|
1
10
|
export { canMakeBooleanSourceNode, canMakeBooleanSourcePath, nodeHasVisibleStroke } from './boolean'
|
|
2
11
|
export { flattenNodesToVectorProps, type VectorFlattenProps } from './flatten'
|
|
3
12
|
export {
|
|
@@ -7,7 +7,7 @@ import type { Color } from '@pairdraw/scene-graph/primitives'
|
|
|
7
7
|
|
|
8
8
|
import { SELECTION_COLOR } from '#core/constants'
|
|
9
9
|
|
|
10
|
-
import type { SkiaRenderer } from './renderer'
|
|
10
|
+
import type { SkiaRenderer, RenderOverlays } from './renderer'
|
|
11
11
|
|
|
12
12
|
type RawLayoutGrid = SceneNode['layoutGrids'][number] & {
|
|
13
13
|
visible?: boolean
|
|
@@ -107,7 +107,20 @@ function drawSquareGrid(
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
/** Figma's View › Layout grids: a view switch that hides every guide without editing frames. */
|
|
111
|
+
export function layoutGridsVisible(
|
|
112
|
+
overlays: Pick<RenderOverlays, 'showLayoutGrids'> = {}
|
|
113
|
+
): boolean {
|
|
114
|
+
return overlays.showLayoutGrids !== false
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export function drawLayoutGrids(
|
|
118
|
+
r: SkiaRenderer,
|
|
119
|
+
canvas: Canvas,
|
|
120
|
+
node: SceneNode,
|
|
121
|
+
overlays: RenderOverlays = {}
|
|
122
|
+
): void {
|
|
123
|
+
if (!layoutGridsVisible(overlays)) return
|
|
111
124
|
for (const rawGrid of rawLayoutGrids(node)) {
|
|
112
125
|
const grid = gridGeometry(rawGrid)
|
|
113
126
|
if (!grid) continue
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { Canvas, Image, Shader } from 'canvaskit-wasm'
|
|
1
|
+
import type { Canvas, CanvasKit, Image, RuntimeEffect, Shader } from 'canvaskit-wasm'
|
|
2
2
|
|
|
3
|
-
import type { NoiseEffect } from '@pairdraw/scene-graph'
|
|
3
|
+
import type { BlendMode, NoiseEffect } from '@pairdraw/scene-graph'
|
|
4
4
|
|
|
5
|
+
import { setPaintBlendMode } from '#core/canvas/blend'
|
|
5
6
|
import type { SkiaRenderer } from '#core/canvas/renderer'
|
|
6
7
|
|
|
7
8
|
import {
|
|
@@ -15,6 +16,32 @@ import { noiseColorTile, noiseLevelTile } from './tile'
|
|
|
15
16
|
/** Catmull-Rom as Skia's cubic resampler: B 0, C 0.5, the blend Figma's grains were fitted to. */
|
|
16
17
|
const CATMULL_ROM = { B: 0, C: 0.5 }
|
|
17
18
|
|
|
19
|
+
/** How a paint's grain sits on what it covers: the paint's own opacity and blend mode. */
|
|
20
|
+
export interface NoiseGrainStyle {
|
|
21
|
+
readonly opacity?: number
|
|
22
|
+
readonly blendMode?: BlendMode
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** The CanvasKit surface the grain shader cache needs; a test can provide only `Make`. */
|
|
26
|
+
export type NoiseGrainCanvasKit = { RuntimeEffect: Pick<CanvasKit['RuntimeEffect'], 'Make'> }
|
|
27
|
+
|
|
28
|
+
/** Compiled grain shaders per CanvasKit; a null entry is a failed compile, not a retry. */
|
|
29
|
+
const grainEffects = new WeakMap<NoiseGrainCanvasKit, RuntimeEffect | null>()
|
|
30
|
+
|
|
31
|
+
/** The grain shader, compiled once per CanvasKit; a failed compile stays failed. */
|
|
32
|
+
export function noiseGrainEffect(ck: NoiseGrainCanvasKit): RuntimeEffect | null {
|
|
33
|
+
if (grainEffects.has(ck)) return grainEffects.get(ck) ?? null
|
|
34
|
+
const effect = ck.RuntimeEffect.Make(NOISE_GRAIN_SOURCE)
|
|
35
|
+
grainEffects.set(ck, effect)
|
|
36
|
+
return effect
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Frees the grain shader a CanvasKit holds, as its renderer is destroyed. */
|
|
40
|
+
export function releaseNoiseGrainEffect(ck: NoiseGrainCanvasKit): void {
|
|
41
|
+
grainEffects.get(ck)?.delete()
|
|
42
|
+
grainEffects.delete(ck)
|
|
43
|
+
}
|
|
44
|
+
|
|
18
45
|
/**
|
|
19
46
|
* `tile` as a repeating shader in cell units, blended between cells or one value per cell.
|
|
20
47
|
*/
|
|
@@ -34,11 +61,11 @@ export function renderFigmaNoiseEffects(
|
|
|
34
61
|
canvas: Canvas,
|
|
35
62
|
node: { width: number; height: number },
|
|
36
63
|
shape: (canvas: Canvas) => void,
|
|
37
|
-
noises: readonly NoiseEffect[]
|
|
64
|
+
noises: readonly NoiseEffect[],
|
|
65
|
+
style: NoiseGrainStyle = {}
|
|
38
66
|
): boolean {
|
|
39
67
|
if (noises.length === 0) return true
|
|
40
|
-
|
|
41
|
-
const effect = r.noiseGrainEffect
|
|
68
|
+
const effect = noiseGrainEffect(r.ck)
|
|
42
69
|
if (!effect) return false
|
|
43
70
|
|
|
44
71
|
canvas.save()
|
|
@@ -46,7 +73,8 @@ export function renderFigmaNoiseEffects(
|
|
|
46
73
|
const paint = new r.ck.Paint()
|
|
47
74
|
try {
|
|
48
75
|
paint.setAntiAlias(false)
|
|
49
|
-
|
|
76
|
+
setPaintBlendMode(r, paint, style.blendMode)
|
|
77
|
+
if (style.opacity !== undefined) paint.setAlphaf(style.opacity)
|
|
50
78
|
const box = r.ck.LTRBRect(0, 0, node.width, node.height)
|
|
51
79
|
for (const noise of noises) {
|
|
52
80
|
const { shares, seed, blend } = noiseTileInputs(noise)
|
|
@@ -57,7 +85,7 @@ export function renderFigmaNoiseEffects(
|
|
|
57
85
|
const levels = tileShader(r, levelTile, blend)
|
|
58
86
|
const colors = tileShader(r, colorTile, false)
|
|
59
87
|
const shader = effect.makeShaderWithChildren(
|
|
60
|
-
packNoiseUniforms(effect, noiseUniformValues(noise
|
|
88
|
+
packNoiseUniforms(effect, noiseUniformValues(noise)),
|
|
61
89
|
[levels, colors]
|
|
62
90
|
)
|
|
63
91
|
paint.setShader(shader)
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { RuntimeEffect } from 'canvaskit-wasm'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
4
|
-
import { toExtendedSRGB } from '@pairdraw/scene-graph/color'
|
|
3
|
+
import type { NoiseEffect, NoiseEffectParams } from '@pairdraw/scene-graph'
|
|
5
4
|
|
|
6
5
|
import { noiseLevelShares, noiseMeanLevel } from './table'
|
|
7
6
|
|
|
@@ -122,17 +121,16 @@ export function noiseTileInputs(effect: NoiseEffect) {
|
|
|
122
121
|
}
|
|
123
122
|
|
|
124
123
|
/**
|
|
125
|
-
* A uniform's values under the name the shader declares it, in declaration order. Colors
|
|
126
|
-
* document's
|
|
124
|
+
* A uniform's values under the name the shader declares it, in declaration order. Colors stay in
|
|
125
|
+
* the document's profile: a runtime-effect shader writes into the destination's own profile.
|
|
127
126
|
*/
|
|
128
|
-
export function noiseUniformValues(
|
|
129
|
-
effect: NoiseEffect,
|
|
130
|
-
profile: ColorProfile = 'srgb'
|
|
131
|
-
): Record<string, number[]> {
|
|
127
|
+
export function noiseUniformValues(effect: NoiseEffect): Record<string, number[]> {
|
|
132
128
|
const grain = effect.noise
|
|
133
129
|
const size = Math.max(grain.noiseSize.x, grain.noiseSize.y)
|
|
134
|
-
|
|
135
|
-
|
|
130
|
+
// A runtime-effect shader writes in the destination's profile, so these stay in document
|
|
131
|
+
// space; converting them (as a paint colour is) would apply the document profile twice.
|
|
132
|
+
const primary = effect.color
|
|
133
|
+
const secondary = grain.secondaryColor ?? effect.color
|
|
136
134
|
return {
|
|
137
135
|
cell: [noiseCell(grain.noiseSize.x), noiseCell(grain.noiseSize.y)],
|
|
138
136
|
contrast: [noiseContrast(size)],
|