fabric-vectr 6.7.16 → 6.7.17
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/dist/index.d.mts +13871 -0
- package/dist/dist/index.d.mts.map +1 -0
- package/dist/dist/index.mjs +26926 -0
- package/dist/dist/index.mjs.map +1 -0
- package/dist/dist/src/util/internals/cloneStyles.d.mts +2 -0
- package/dist/dist/src/util/internals/cloneStyles.d.mts.map +1 -0
- package/dist/dist/src/util/internals/cloneStyles.mjs +15 -0
- package/dist/dist/src/util/internals/cloneStyles.mjs.map +1 -0
- package/dist/extensions/aligning_guidelines/constant.js +9 -0
- package/dist/extensions/aligning_guidelines/constant.js.map +1 -0
- package/dist/extensions/aligning_guidelines/index.js +132 -0
- package/dist/extensions/aligning_guidelines/index.js.map +1 -0
- package/dist/extensions/aligning_guidelines/typedefs.js +2 -0
- package/dist/extensions/aligning_guidelines/typedefs.js.map +1 -0
- package/dist/extensions/aligning_guidelines/util/basic.js +12 -0
- package/dist/extensions/aligning_guidelines/util/basic.js.map +1 -0
- package/dist/extensions/aligning_guidelines/util/basic.spec.d.ts +2 -0
- package/dist/extensions/aligning_guidelines/util/basic.spec.d.ts.map +1 -0
- package/dist/extensions/aligning_guidelines/util/basic.spec.js +30 -0
- package/dist/extensions/aligning_guidelines/util/basic.spec.js.map +1 -0
- package/dist/extensions/aligning_guidelines/util/collect-line.js +129 -0
- package/dist/extensions/aligning_guidelines/util/collect-line.js.map +1 -0
- package/dist/extensions/aligning_guidelines/util/collect-point.js +78 -0
- package/dist/extensions/aligning_guidelines/util/collect-point.js.map +1 -0
- package/dist/extensions/aligning_guidelines/util/draw.js +67 -0
- package/dist/extensions/aligning_guidelines/util/draw.js.map +1 -0
- package/dist/extensions/aligning_guidelines/util/get-objects-by-target.js +44 -0
- package/dist/extensions/aligning_guidelines/util/get-objects-by-target.js.map +1 -0
- package/dist/extensions/data_updaters/origins/index.js +36 -0
- package/dist/extensions/data_updaters/origins/index.js.map +1 -0
- package/dist/extensions/data_updaters/origins/index.spec.d.ts +2 -0
- package/dist/extensions/data_updaters/origins/index.spec.d.ts.map +1 -0
- package/dist/extensions/data_updaters/origins/index.spec.js +94 -0
- package/dist/extensions/data_updaters/origins/index.spec.js.map +1 -0
- package/dist/extensions/index.js +3 -0
- package/dist/extensions/index.js.map +1 -0
- package/dist/fabric.js +101 -0
- package/dist/fabric.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.min.mjs +1 -1
- package/dist/index.min.mjs.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/index.node.cjs +2 -2
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +37 -0
- package/dist/index.node.js.map +1 -0
- package/dist/index.node.mjs +2 -2
- package/dist/index.node.mjs.map +1 -1
- package/dist/package.json +178 -0
- package/dist/package.json.min.mjs +1 -1
- package/dist/package.json.mjs +1 -1
- package/dist/src/ClassRegistry.js +49 -0
- package/dist/src/ClassRegistry.js.map +1 -0
- package/dist/src/Collection.js +295 -0
- package/dist/src/Collection.js.map +1 -0
- package/dist/src/CommonMethods.js +58 -0
- package/dist/src/CommonMethods.js.map +1 -0
- package/dist/src/EventTypeDefs.js +2 -0
- package/dist/src/EventTypeDefs.js.map +1 -0
- package/dist/src/Intersection.js +250 -0
- package/dist/src/Intersection.js.map +1 -0
- package/dist/src/LayoutManager/ActiveSelectionLayoutManager.js +47 -0
- package/dist/src/LayoutManager/ActiveSelectionLayoutManager.js.map +1 -0
- package/dist/src/LayoutManager/LayoutManager.js +238 -0
- package/dist/src/LayoutManager/LayoutManager.js.map +1 -0
- package/dist/src/LayoutManager/LayoutStrategies/ClipPathLayout.js +60 -0
- package/dist/src/LayoutManager/LayoutStrategies/ClipPathLayout.js.map +1 -0
- package/dist/src/LayoutManager/LayoutStrategies/FitContentLayout.js +18 -0
- package/dist/src/LayoutManager/LayoutStrategies/FitContentLayout.js.map +1 -0
- package/dist/src/LayoutManager/LayoutStrategies/FixedLayout.js +17 -0
- package/dist/src/LayoutManager/LayoutStrategies/FixedLayout.js.map +1 -0
- package/dist/src/LayoutManager/LayoutStrategies/LayoutStrategy.js +80 -0
- package/dist/src/LayoutManager/LayoutStrategies/LayoutStrategy.js.map +1 -0
- package/dist/src/LayoutManager/LayoutStrategies/utils.js +28 -0
- package/dist/src/LayoutManager/LayoutStrategies/utils.js.map +1 -0
- package/dist/src/LayoutManager/constants.js +7 -0
- package/dist/src/LayoutManager/constants.js.map +1 -0
- package/dist/src/LayoutManager/index.js +7 -0
- package/dist/src/LayoutManager/index.js.map +1 -0
- package/dist/src/LayoutManager/types.js +2 -0
- package/dist/src/LayoutManager/types.js.map +1 -0
- package/dist/src/Observable.js +107 -0
- package/dist/src/Observable.js.map +1 -0
- package/dist/src/Pattern/Pattern.js +152 -0
- package/dist/src/Pattern/Pattern.js.map +1 -0
- package/dist/src/Pattern/index.js +3 -0
- package/dist/src/Pattern/index.js.map +1 -0
- package/dist/src/Pattern/types.js +2 -0
- package/dist/src/Pattern/types.js.map +1 -0
- package/dist/src/Point.js +330 -0
- package/dist/src/Point.js.map +1 -0
- package/dist/src/Shadow.js +125 -0
- package/dist/src/Shadow.js.map +1 -0
- package/dist/src/benchmarks/boundingBoxFromPoint.d.mts +2 -0
- package/dist/src/benchmarks/boundingBoxFromPoint.d.mts.map +1 -0
- package/dist/src/benchmarks/boundingBoxFromPoint.mjs +54 -0
- package/dist/src/benchmarks/boundingBoxFromPoint.mjs.map +1 -0
- package/dist/src/benchmarks/calcCornerCoords.d.mts +2 -0
- package/dist/src/benchmarks/calcCornerCoords.d.mts.map +1 -0
- package/dist/src/benchmarks/calcCornerCoords.mjs +78 -0
- package/dist/src/benchmarks/calcCornerCoords.mjs.map +1 -0
- package/dist/src/benchmarks/calcTransformMatrix.d.mts +2 -0
- package/dist/src/benchmarks/calcTransformMatrix.d.mts.map +1 -0
- package/dist/src/benchmarks/calcTransformMatrix.mjs +71 -0
- package/dist/src/benchmarks/calcTransformMatrix.mjs.map +1 -0
- package/dist/src/benchmarks/cloneStyles.d.mts +2 -0
- package/dist/src/benchmarks/cloneStyles.d.mts.map +1 -0
- package/dist/src/benchmarks/cloneStyles.mjs +56 -0
- package/dist/src/benchmarks/cloneStyles.mjs.map +1 -0
- package/dist/src/benchmarks/pathCloning.d.mts +2 -0
- package/dist/src/benchmarks/pathCloning.d.mts.map +1 -0
- package/dist/src/benchmarks/pathCloning.mjs +94 -0
- package/dist/src/benchmarks/pathCloning.mjs.map +1 -0
- package/dist/src/benchmarks/pathData.d.mts +3 -0
- package/dist/src/benchmarks/pathData.d.mts.map +1 -0
- package/dist/src/benchmarks/pathData.mjs +3 -0
- package/dist/src/benchmarks/pathData.mjs.map +1 -0
- package/dist/src/benchmarks/raycasting.d.mts +2 -0
- package/dist/src/benchmarks/raycasting.d.mts.map +1 -0
- package/dist/src/benchmarks/raycasting.mjs +134 -0
- package/dist/src/benchmarks/raycasting.mjs.map +1 -0
- package/dist/src/benchmarks/transformMatrixKey.d.mts +2 -0
- package/dist/src/benchmarks/transformMatrixKey.d.mts.map +1 -0
- package/dist/src/benchmarks/transformMatrixKey.mjs +81 -0
- package/dist/src/benchmarks/transformMatrixKey.mjs.map +1 -0
- package/dist/src/brushes/BaseBrush.js +121 -0
- package/dist/src/brushes/BaseBrush.js.map +1 -0
- package/dist/src/brushes/CircleBrush.js +117 -0
- package/dist/src/brushes/CircleBrush.js.map +1 -0
- package/dist/src/brushes/PatternBrush.js +49 -0
- package/dist/src/brushes/PatternBrush.js.map +1 -0
- package/dist/src/brushes/PencilBrush.js +259 -0
- package/dist/src/brushes/PencilBrush.js.map +1 -0
- package/dist/src/brushes/SprayBrush.js +174 -0
- package/dist/src/brushes/SprayBrush.js.map +1 -0
- package/dist/src/brushes/typedefs.js +2 -0
- package/dist/src/brushes/typedefs.js.map +1 -0
- package/dist/src/cache.js +69 -0
- package/dist/src/cache.js.map +1 -0
- package/dist/src/canvas/Canvas.js +1366 -0
- package/dist/src/canvas/Canvas.js.map +1 -0
- package/dist/src/canvas/CanvasOptions.js +31 -0
- package/dist/src/canvas/CanvasOptions.js.map +1 -0
- package/dist/src/canvas/DOMManagers/CanvasDOMManager.js +97 -0
- package/dist/src/canvas/DOMManagers/CanvasDOMManager.js.map +1 -0
- package/dist/src/canvas/DOMManagers/StaticCanvasDOMManager.js +63 -0
- package/dist/src/canvas/DOMManagers/StaticCanvasDOMManager.js.map +1 -0
- package/dist/src/canvas/DOMManagers/util.js +56 -0
- package/dist/src/canvas/DOMManagers/util.js.map +1 -0
- package/dist/src/canvas/SelectableCanvas.js +1141 -0
- package/dist/src/canvas/SelectableCanvas.js.map +1 -0
- package/dist/src/canvas/StaticCanvas.js +1085 -0
- package/dist/src/canvas/StaticCanvas.js.map +1 -0
- package/dist/src/canvas/StaticCanvasOptions.js +23 -0
- package/dist/src/canvas/StaticCanvasOptions.js.map +1 -0
- package/dist/src/canvas/TextEditingManager.js +54 -0
- package/dist/src/canvas/TextEditingManager.js.map +1 -0
- package/dist/src/canvas/canvas_gestures.mixin.js +181 -0
- package/dist/src/canvas/canvas_gestures.mixin.js.map +1 -0
- package/dist/src/color/Color.js +301 -0
- package/dist/src/color/Color.js.map +1 -0
- package/dist/src/color/color_map.js +155 -0
- package/dist/src/color/color_map.js.map +1 -0
- package/dist/src/color/constants.js +111 -0
- package/dist/src/color/constants.js.map +1 -0
- package/dist/src/color/typedefs.js +2 -0
- package/dist/src/color/typedefs.js.map +1 -0
- package/dist/src/color/util.js +73 -0
- package/dist/src/color/util.js.map +1 -0
- package/dist/src/config.js +140 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/constants.js +38 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/controls/Control.js +241 -0
- package/dist/src/controls/Control.js.map +1 -0
- package/dist/src/controls/changeWidth.js +31 -0
- package/dist/src/controls/changeWidth.js.map +1 -0
- package/dist/src/controls/commonControls.js +91 -0
- package/dist/src/controls/commonControls.js.map +1 -0
- package/dist/src/controls/controlRendering.js +81 -0
- package/dist/src/controls/controlRendering.js.map +1 -0
- package/dist/src/controls/drag.js +22 -0
- package/dist/src/controls/drag.js.map +1 -0
- package/dist/src/controls/fireEvent.js +9 -0
- package/dist/src/controls/fireEvent.js.map +1 -0
- package/dist/src/controls/index.js +14 -0
- package/dist/src/controls/index.js.map +1 -0
- package/dist/src/controls/pathControl.js +137 -0
- package/dist/src/controls/pathControl.js.map +1 -0
- package/dist/src/controls/polyControl.js +66 -0
- package/dist/src/controls/polyControl.js.map +1 -0
- package/dist/src/controls/rotate.js +57 -0
- package/dist/src/controls/rotate.js.map +1 -0
- package/dist/src/controls/scale.js +190 -0
- package/dist/src/controls/scale.js.map +1 -0
- package/dist/src/controls/scaleSkew.js +66 -0
- package/dist/src/controls/scaleSkew.js.map +1 -0
- package/dist/src/controls/skew.js +147 -0
- package/dist/src/controls/skew.js.map +1 -0
- package/dist/src/controls/util.js +89 -0
- package/dist/src/controls/util.js.map +1 -0
- package/dist/src/controls/wrapWithFireEvent.js +22 -0
- package/dist/src/controls/wrapWithFireEvent.js.map +1 -0
- package/dist/src/controls/wrapWithFixedAnchor.js +16 -0
- package/dist/src/controls/wrapWithFixedAnchor.js.map +1 -0
- package/dist/src/env/browser.js +18 -0
- package/dist/src/env/browser.js.map +1 -0
- package/dist/src/env/index.js +37 -0
- package/dist/src/env/index.js.map +1 -0
- package/dist/src/env/node.js +37 -0
- package/dist/src/env/node.js.map +1 -0
- package/dist/src/env/types.js +2 -0
- package/dist/src/env/types.js.map +1 -0
- package/dist/src/filters/BaseFilter.js +304 -0
- package/dist/src/filters/BaseFilter.js.map +1 -0
- package/dist/src/filters/BlendColor.js +147 -0
- package/dist/src/filters/BlendColor.js.map +1 -0
- package/dist/src/filters/BlendImage.js +149 -0
- package/dist/src/filters/BlendImage.js.map +1 -0
- package/dist/src/filters/Blur.js +167 -0
- package/dist/src/filters/Blur.js.map +1 -0
- package/dist/src/filters/Boilerplate.js +61 -0
- package/dist/src/filters/Boilerplate.js.map +1 -0
- package/dist/src/filters/Brightness.js +51 -0
- package/dist/src/filters/Brightness.js.map +1 -0
- package/dist/src/filters/Canvas2dFilterBackend.js +51 -0
- package/dist/src/filters/Canvas2dFilterBackend.js.map +1 -0
- package/dist/src/filters/ColorMatrix.js +92 -0
- package/dist/src/filters/ColorMatrix.js.map +1 -0
- package/dist/src/filters/ColorMatrixFilters.js +45 -0
- package/dist/src/filters/ColorMatrixFilters.js.map +1 -0
- package/dist/src/filters/Composed.js +55 -0
- package/dist/src/filters/Composed.js.map +1 -0
- package/dist/src/filters/Contrast.js +51 -0
- package/dist/src/filters/Contrast.js.map +1 -0
- package/dist/src/filters/Convolute.js +132 -0
- package/dist/src/filters/Convolute.js.map +1 -0
- package/dist/src/filters/FilterBackend.js +34 -0
- package/dist/src/filters/FilterBackend.js.map +1 -0
- package/dist/src/filters/GLProbes/GLProbe.js +3 -0
- package/dist/src/filters/GLProbes/GLProbe.js.map +1 -0
- package/dist/src/filters/GLProbes/NodeGLProbe.js +15 -0
- package/dist/src/filters/GLProbes/NodeGLProbe.js.map +1 -0
- package/dist/src/filters/GLProbes/WebGLProbe.js +39 -0
- package/dist/src/filters/GLProbes/WebGLProbe.js.map +1 -0
- package/dist/src/filters/Gamma.js +80 -0
- package/dist/src/filters/Gamma.js.map +1 -0
- package/dist/src/filters/Grayscale.js +69 -0
- package/dist/src/filters/Grayscale.js.map +1 -0
- package/dist/src/filters/HueRotation.js +61 -0
- package/dist/src/filters/HueRotation.js.map +1 -0
- package/dist/src/filters/Invert.js +58 -0
- package/dist/src/filters/Invert.js.map +1 -0
- package/dist/src/filters/Noise.js +54 -0
- package/dist/src/filters/Noise.js.map +1 -0
- package/dist/src/filters/Pixelate.js +66 -0
- package/dist/src/filters/Pixelate.js.map +1 -0
- package/dist/src/filters/RemoveColor.js +74 -0
- package/dist/src/filters/RemoveColor.js.map +1 -0
- package/dist/src/filters/Resize.js +399 -0
- package/dist/src/filters/Resize.js.map +1 -0
- package/dist/src/filters/Saturation.js +55 -0
- package/dist/src/filters/Saturation.js.map +1 -0
- package/dist/src/filters/Vibrance.js +57 -0
- package/dist/src/filters/Vibrance.js.map +1 -0
- package/dist/src/filters/WebGLFilterBackend.js +269 -0
- package/dist/src/filters/WebGLFilterBackend.js.map +1 -0
- package/dist/src/filters/filters.js +21 -0
- package/dist/src/filters/filters.js.map +1 -0
- package/dist/src/filters/index.js +7 -0
- package/dist/src/filters/index.js.map +1 -0
- package/dist/src/filters/shaders/baseFilter.js +16 -0
- package/dist/src/filters/shaders/baseFilter.js.map +1 -0
- package/dist/src/filters/shaders/blendColor.js +32 -0
- package/dist/src/filters/shaders/blendColor.js.map +1 -0
- package/dist/src/filters/shaders/blendImage.js +42 -0
- package/dist/src/filters/shaders/blendImage.js.map +1 -0
- package/dist/src/filters/shaders/blur.js +31 -0
- package/dist/src/filters/shaders/blur.js.map +1 -0
- package/dist/src/filters/shaders/brightness.js +12 -0
- package/dist/src/filters/shaders/brightness.js.map +1 -0
- package/dist/src/filters/shaders/colorMatrix.js +13 -0
- package/dist/src/filters/shaders/colorMatrix.js.map +1 -0
- package/dist/src/filters/shaders/constrast.js +12 -0
- package/dist/src/filters/shaders/constrast.js.map +1 -0
- package/dist/src/filters/shaders/convolute.js +155 -0
- package/dist/src/filters/shaders/convolute.js.map +1 -0
- package/dist/src/filters/shaders/gamma.js +16 -0
- package/dist/src/filters/shaders/gamma.js.map +1 -0
- package/dist/src/filters/shaders/grayscale.js +35 -0
- package/dist/src/filters/shaders/grayscale.js.map +1 -0
- package/dist/src/filters/shaders/invert.js +20 -0
- package/dist/src/filters/shaders/invert.js.map +1 -0
- package/dist/src/filters/shaders/noise.js +17 -0
- package/dist/src/filters/shaders/noise.js.map +1 -0
- package/dist/src/filters/shaders/pixelate.js +20 -0
- package/dist/src/filters/shaders/pixelate.js.map +1 -0
- package/dist/src/filters/shaders/removeColor.js +14 -0
- package/dist/src/filters/shaders/removeColor.js.map +1 -0
- package/dist/src/filters/shaders/saturation.js +16 -0
- package/dist/src/filters/shaders/saturation.js.map +1 -0
- package/dist/src/filters/shaders/vibrance.js +17 -0
- package/dist/src/filters/shaders/vibrance.js.map +1 -0
- package/dist/src/filters/typedefs.js +2 -0
- package/dist/src/filters/typedefs.js.map +1 -0
- package/dist/src/filters/utils.js +36 -0
- package/dist/src/filters/utils.js.map +1 -0
- package/dist/src/gradient/Gradient.d.ts.map +1 -1
- package/dist/src/gradient/Gradient.js +244 -0
- package/dist/src/gradient/Gradient.js.map +1 -0
- package/dist/src/gradient/Gradient.min.mjs +1 -1
- package/dist/src/gradient/Gradient.min.mjs.map +1 -1
- package/dist/src/gradient/Gradient.mjs +2 -1
- package/dist/src/gradient/Gradient.mjs.map +1 -1
- package/dist/src/gradient/constants.js +12 -0
- package/dist/src/gradient/constants.js.map +1 -0
- package/dist/src/gradient/index.js +3 -0
- package/dist/src/gradient/index.js.map +1 -0
- package/dist/src/gradient/parser/misc.js +11 -0
- package/dist/src/gradient/parser/misc.js.map +1 -0
- package/dist/src/gradient/parser/parseColorStops.js +42 -0
- package/dist/src/gradient/parser/parseColorStops.js.map +1 -0
- package/dist/src/gradient/parser/parseCoords.js +60 -0
- package/dist/src/gradient/parser/parseCoords.js.map +1 -0
- package/dist/src/gradient/typedefs.js +2 -0
- package/dist/src/gradient/typedefs.js.map +1 -0
- package/dist/src/mixins/eraser_brush.mixin.js +732 -0
- package/dist/src/mixins/eraser_brush.mixin.js.map +1 -0
- package/dist/src/parkinglot/canvas_animation.mixin.js +102 -0
- package/dist/src/parkinglot/canvas_animation.mixin.js.map +1 -0
- package/dist/src/parkinglot/straighten.js +53 -0
- package/dist/src/parkinglot/straighten.js.map +1 -0
- package/dist/src/parser/applyViewboxTransform.js +146 -0
- package/dist/src/parser/applyViewboxTransform.js.map +1 -0
- package/dist/src/parser/attributes.js +27 -0
- package/dist/src/parser/attributes.js.map +1 -0
- package/dist/src/parser/constants.js +70 -0
- package/dist/src/parser/constants.js.map +1 -0
- package/dist/src/parser/doesSomeParentMatch.js +15 -0
- package/dist/src/parser/doesSomeParentMatch.js.map +1 -0
- package/dist/src/parser/elementMatchesRule.js +15 -0
- package/dist/src/parser/elementMatchesRule.js.map +1 -0
- package/dist/src/parser/elements_parser.js +164 -0
- package/dist/src/parser/elements_parser.js.map +1 -0
- package/dist/src/parser/getCSSRules.js +62 -0
- package/dist/src/parser/getCSSRules.js.map +1 -0
- package/dist/src/parser/getGlobalStylesForElement.js +17 -0
- package/dist/src/parser/getGlobalStylesForElement.js.map +1 -0
- package/dist/src/parser/getGradientDefs.js +30 -0
- package/dist/src/parser/getGradientDefs.js.map +1 -0
- package/dist/src/parser/getMultipleNodes.js +10 -0
- package/dist/src/parser/getMultipleNodes.js.map +1 -0
- package/dist/src/parser/getPatternDefs.js +70 -0
- package/dist/src/parser/getPatternDefs.js.map +1 -0
- package/dist/src/parser/getSvgRegex.js +4 -0
- package/dist/src/parser/getSvgRegex.js.map +1 -0
- package/dist/src/parser/getTagName.js +2 -0
- package/dist/src/parser/getTagName.js.map +1 -0
- package/dist/src/parser/hasInvalidAncestor.js +17 -0
- package/dist/src/parser/hasInvalidAncestor.js.map +1 -0
- package/dist/src/parser/loadSVGFromString.js +23 -0
- package/dist/src/parser/loadSVGFromString.js.map +1 -0
- package/dist/src/parser/loadSVGFromURL.js +39 -0
- package/dist/src/parser/loadSVGFromURL.js.map +1 -0
- package/dist/src/parser/normalizeAttr.js +3 -0
- package/dist/src/parser/normalizeAttr.js.map +1 -0
- package/dist/src/parser/normalizeValue.js +79 -0
- package/dist/src/parser/normalizeValue.js.map +1 -0
- package/dist/src/parser/parseAttributes.js +66 -0
- package/dist/src/parser/parseAttributes.js.map +1 -0
- package/dist/src/parser/parseFontDeclaration.js +38 -0
- package/dist/src/parser/parseFontDeclaration.js.map +1 -0
- package/dist/src/parser/parsePointsAttribute.js +28 -0
- package/dist/src/parser/parsePointsAttribute.js.map +1 -0
- package/dist/src/parser/parseSVGDocument.js +74 -0
- package/dist/src/parser/parseSVGDocument.js.map +1 -0
- package/dist/src/parser/parseStyleAttribute.js +23 -0
- package/dist/src/parser/parseStyleAttribute.js.map +1 -0
- package/dist/src/parser/parseStyleObject.js +15 -0
- package/dist/src/parser/parseStyleObject.js.map +1 -0
- package/dist/src/parser/parseStyleString.js +18 -0
- package/dist/src/parser/parseStyleString.js.map +1 -0
- package/dist/src/parser/parseTransformAttribute.js +76 -0
- package/dist/src/parser/parseTransformAttribute.js.map +1 -0
- package/dist/src/parser/parseUseDirectives.js +76 -0
- package/dist/src/parser/parseUseDirectives.js.map +1 -0
- package/dist/src/parser/percent.js +21 -0
- package/dist/src/parser/percent.js.map +1 -0
- package/dist/src/parser/recursivelyParseGradientsXlink.js +36 -0
- package/dist/src/parser/recursivelyParseGradientsXlink.js.map +1 -0
- package/dist/src/parser/selectorMatches.js +24 -0
- package/dist/src/parser/selectorMatches.js.map +1 -0
- package/dist/src/parser/setStrokeFillOpacity.js +35 -0
- package/dist/src/parser/setStrokeFillOpacity.js.map +1 -0
- package/dist/src/parser/typedefs.js +2 -0
- package/dist/src/parser/typedefs.js.map +1 -0
- package/dist/src/shapes/ActiveSelection.js +195 -0
- package/dist/src/shapes/ActiveSelection.js.map +1 -0
- package/dist/src/shapes/Circle.js +155 -0
- package/dist/src/shapes/Circle.js.map +1 -0
- package/dist/src/shapes/Ellipse.js +120 -0
- package/dist/src/shapes/Ellipse.js.map +1 -0
- package/dist/src/shapes/Group.js +549 -0
- package/dist/src/shapes/Group.js.map +1 -0
- package/dist/src/shapes/IText/DraggableTextDelegate.js +326 -0
- package/dist/src/shapes/IText/DraggableTextDelegate.js.map +1 -0
- package/dist/src/shapes/IText/IText.js +545 -0
- package/dist/src/shapes/IText/IText.js.map +1 -0
- package/dist/src/shapes/IText/ITextBehavior.js +848 -0
- package/dist/src/shapes/IText/ITextBehavior.js.map +1 -0
- package/dist/src/shapes/IText/ITextClickBehavior.js +196 -0
- package/dist/src/shapes/IText/ITextClickBehavior.js.map +1 -0
- package/dist/src/shapes/IText/ITextKeyBehavior.js +522 -0
- package/dist/src/shapes/IText/ITextKeyBehavior.js.map +1 -0
- package/dist/src/shapes/IText/constants.js +47 -0
- package/dist/src/shapes/IText/constants.js.map +1 -0
- package/dist/src/shapes/Image.js +589 -0
- package/dist/src/shapes/Image.js.map +1 -0
- package/dist/src/shapes/Line.js +195 -0
- package/dist/src/shapes/Line.js.map +1 -0
- package/dist/src/shapes/Object/FabricObject.js +12 -0
- package/dist/src/shapes/Object/FabricObject.js.map +1 -0
- package/dist/src/shapes/Object/FabricObjectSVGExportMixin.js +255 -0
- package/dist/src/shapes/Object/FabricObjectSVGExportMixin.js.map +1 -0
- package/dist/src/shapes/Object/InteractiveObject.js +478 -0
- package/dist/src/shapes/Object/InteractiveObject.js.map +1 -0
- package/dist/src/shapes/Object/Object.js +1392 -0
- package/dist/src/shapes/Object/Object.js.map +1 -0
- package/dist/src/shapes/Object/ObjectGeometry.js +537 -0
- package/dist/src/shapes/Object/ObjectGeometry.js.map +1 -0
- package/dist/src/shapes/Object/defaultValues.js +109 -0
- package/dist/src/shapes/Object/defaultValues.js.map +1 -0
- package/dist/src/shapes/Object/types/BaseProps.js +2 -0
- package/dist/src/shapes/Object/types/BaseProps.js.map +1 -0
- package/dist/src/shapes/Object/types/BorderProps.js +2 -0
- package/dist/src/shapes/Object/types/BorderProps.js.map +1 -0
- package/dist/src/shapes/Object/types/ControlProps.js +2 -0
- package/dist/src/shapes/Object/types/ControlProps.js.map +1 -0
- package/dist/src/shapes/Object/types/FabricObjectProps.js +2 -0
- package/dist/src/shapes/Object/types/FabricObjectProps.js.map +1 -0
- package/dist/src/shapes/Object/types/FillStrokeProps.js +2 -0
- package/dist/src/shapes/Object/types/FillStrokeProps.js.map +1 -0
- package/dist/src/shapes/Object/types/LockInteractionProps.js +2 -0
- package/dist/src/shapes/Object/types/LockInteractionProps.js.map +1 -0
- package/dist/src/shapes/Object/types/ObjectProps.js +2 -0
- package/dist/src/shapes/Object/types/ObjectProps.js.map +1 -0
- package/dist/src/shapes/Object/types/ObjectTransformProps.js +2 -0
- package/dist/src/shapes/Object/types/ObjectTransformProps.js.map +1 -0
- package/dist/src/shapes/Object/types/SerializedObjectProps.js +2 -0
- package/dist/src/shapes/Object/types/SerializedObjectProps.js.map +1 -0
- package/dist/src/shapes/Object/types/index.js +2 -0
- package/dist/src/shapes/Object/types/index.js.map +1 -0
- package/dist/src/shapes/Path.js +267 -0
- package/dist/src/shapes/Path.js.map +1 -0
- package/dist/src/shapes/Polygon.js +12 -0
- package/dist/src/shapes/Polygon.js.map +1 -0
- package/dist/src/shapes/Polyline.js +307 -0
- package/dist/src/shapes/Polyline.js.map +1 -0
- package/dist/src/shapes/Rect.js +131 -0
- package/dist/src/shapes/Rect.js.map +1 -0
- package/dist/src/shapes/Text/StyledText.js +261 -0
- package/dist/src/shapes/Text/StyledText.js.map +1 -0
- package/dist/src/shapes/Text/Text.js +1258 -0
- package/dist/src/shapes/Text/Text.js.map +1 -0
- package/dist/src/shapes/Text/TextSVGExportMixin.js +339 -0
- package/dist/src/shapes/Text/TextSVGExportMixin.js.map +1 -0
- package/dist/src/shapes/Text/constants.js +94 -0
- package/dist/src/shapes/Text/constants.js.map +1 -0
- package/dist/src/shapes/Textbox.js +910 -0
- package/dist/src/shapes/Textbox.js.map +1 -0
- package/dist/src/shapes/Triangle.js +47 -0
- package/dist/src/shapes/Triangle.js.map +1 -0
- package/dist/src/typedefs.js +2 -0
- package/dist/src/typedefs.js.map +1 -0
- package/dist/src/util/animation/AnimationBase.js +94 -0
- package/dist/src/util/animation/AnimationBase.js.map +1 -0
- package/dist/src/util/animation/AnimationFrameProvider.js +8 -0
- package/dist/src/util/animation/AnimationFrameProvider.js.map +1 -0
- package/dist/src/util/animation/AnimationRegistry.js +49 -0
- package/dist/src/util/animation/AnimationRegistry.js.map +1 -0
- package/dist/src/util/animation/ArrayAnimation.js +18 -0
- package/dist/src/util/animation/ArrayAnimation.js.map +1 -0
- package/dist/src/util/animation/ColorAnimation.js +43 -0
- package/dist/src/util/animation/ColorAnimation.js.map +1 -0
- package/dist/src/util/animation/ValueAnimation.js +18 -0
- package/dist/src/util/animation/ValueAnimation.js.map +1 -0
- package/dist/src/util/animation/animate.js +19 -0
- package/dist/src/util/animation/animate.js.map +1 -0
- package/dist/src/util/animation/easing.js +265 -0
- package/dist/src/util/animation/easing.js.map +1 -0
- package/dist/src/util/animation/index.js +3 -0
- package/dist/src/util/animation/index.js.map +1 -0
- package/dist/src/util/animation/types.js +2 -0
- package/dist/src/util/animation/types.js.map +1 -0
- package/dist/src/util/applyMixins.js +14 -0
- package/dist/src/util/applyMixins.js.map +1 -0
- package/dist/src/util/dom_event.js +21 -0
- package/dist/src/util/dom_event.js.map +1 -0
- package/dist/src/util/dom_misc.js +42 -0
- package/dist/src/util/dom_misc.js.map +1 -0
- package/dist/src/util/dom_style.js +19 -0
- package/dist/src/util/dom_style.js.map +1 -0
- package/dist/src/util/index.js +36 -0
- package/dist/src/util/index.js.map +1 -0
- package/dist/src/util/internals/applyCanvasTransform.js +15 -0
- package/dist/src/util/internals/applyCanvasTransform.js.map +1 -0
- package/dist/src/util/internals/cleanupSvgAttribute.js +8 -0
- package/dist/src/util/internals/cleanupSvgAttribute.js.map +1 -0
- package/dist/src/util/internals/cloneDeep.js +8 -0
- package/dist/src/util/internals/cloneDeep.js.map +1 -0
- package/dist/src/util/internals/cloneStyles.js +11 -0
- package/dist/src/util/internals/cloneStyles.js.map +1 -0
- package/dist/src/util/internals/console.js +14 -0
- package/dist/src/util/internals/console.js.map +1 -0
- package/dist/src/util/internals/dom_request.js +39 -0
- package/dist/src/util/internals/dom_request.js.map +1 -0
- package/dist/src/util/internals/findRight.js +9 -0
- package/dist/src/util/internals/findRight.js.map +1 -0
- package/dist/src/util/internals/getRandomInt.js +8 -0
- package/dist/src/util/internals/getRandomInt.js.map +1 -0
- package/dist/src/util/internals/ifNaN.js +10 -0
- package/dist/src/util/internals/ifNaN.js.map +1 -0
- package/dist/src/util/internals/removeFromArray.js +15 -0
- package/dist/src/util/internals/removeFromArray.js.map +1 -0
- package/dist/src/util/internals/uid.js +3 -0
- package/dist/src/util/internals/uid.js.map +1 -0
- package/dist/src/util/lang_string.js +93 -0
- package/dist/src/util/lang_string.js.map +1 -0
- package/dist/src/util/misc/boundingBoxFromPoints.js +26 -0
- package/dist/src/util/misc/boundingBoxFromPoints.js.map +1 -0
- package/dist/src/util/misc/capValue.js +2 -0
- package/dist/src/util/misc/capValue.js.map +1 -0
- package/dist/src/util/misc/cos.js +23 -0
- package/dist/src/util/misc/cos.js.map +1 -0
- package/dist/src/util/misc/dom.js +55 -0
- package/dist/src/util/misc/dom.js.map +1 -0
- package/dist/src/util/misc/findScaleTo.js +19 -0
- package/dist/src/util/misc/findScaleTo.js.map +1 -0
- package/dist/src/util/misc/groupSVGElements.js +15 -0
- package/dist/src/util/misc/groupSVGElements.js.map +1 -0
- package/dist/src/util/misc/isTransparent.js +23 -0
- package/dist/src/util/misc/isTransparent.js.map +1 -0
- package/dist/src/util/misc/matrix.js +238 -0
- package/dist/src/util/misc/matrix.js.map +1 -0
- package/dist/src/util/misc/mergeClipPaths.js +39 -0
- package/dist/src/util/misc/mergeClipPaths.js.map +1 -0
- package/dist/src/util/misc/objectEnlive.js +136 -0
- package/dist/src/util/misc/objectEnlive.js.map +1 -0
- package/dist/src/util/misc/objectTransforms.js +89 -0
- package/dist/src/util/misc/objectTransforms.js.map +1 -0
- package/dist/src/util/misc/pick.js +23 -0
- package/dist/src/util/misc/pick.js.map +1 -0
- package/dist/src/util/misc/planeChange.js +68 -0
- package/dist/src/util/misc/planeChange.js.map +1 -0
- package/dist/src/util/misc/projectStroke/StrokeLineCapProjections.js +105 -0
- package/dist/src/util/misc/projectStroke/StrokeLineCapProjections.js.map +1 -0
- package/dist/src/util/misc/projectStroke/StrokeLineJoinProjections.js +219 -0
- package/dist/src/util/misc/projectStroke/StrokeLineJoinProjections.js.map +1 -0
- package/dist/src/util/misc/projectStroke/StrokeProjectionsBase.js +42 -0
- package/dist/src/util/misc/projectStroke/StrokeProjectionsBase.js.map +1 -0
- package/dist/src/util/misc/projectStroke/index.js +61 -0
- package/dist/src/util/misc/projectStroke/index.js.map +1 -0
- package/dist/src/util/misc/projectStroke/types.js +2 -0
- package/dist/src/util/misc/projectStroke/types.js.map +1 -0
- package/dist/src/util/misc/radiansDegreesConversion.js +14 -0
- package/dist/src/util/misc/radiansDegreesConversion.js.map +1 -0
- package/dist/src/util/misc/resolveOrigin.js +17 -0
- package/dist/src/util/misc/resolveOrigin.js.map +1 -0
- package/dist/src/util/misc/rotatePoint.js +10 -0
- package/dist/src/util/misc/rotatePoint.js.map +1 -0
- package/dist/src/util/misc/sin.js +25 -0
- package/dist/src/util/misc/sin.js.map +1 -0
- package/dist/src/util/misc/svgExport.js +13 -0
- package/dist/src/util/misc/svgExport.js.map +1 -0
- package/dist/src/util/misc/svgParsing.js +129 -0
- package/dist/src/util/misc/svgParsing.js.map +1 -0
- package/dist/src/util/misc/textStyles.js +107 -0
- package/dist/src/util/misc/textStyles.js.map +1 -0
- package/dist/src/util/misc/toFixed.js +8 -0
- package/dist/src/util/misc/toFixed.js.map +1 -0
- package/dist/src/util/misc/vectors.js +77 -0
- package/dist/src/util/misc/vectors.js.map +1 -0
- package/dist/src/util/path/index.js +743 -0
- package/dist/src/util/path/index.js.map +1 -0
- package/dist/src/util/path/regex.js +33 -0
- package/dist/src/util/path/regex.js.map +1 -0
- package/dist/src/util/path/typechecks.js +67 -0
- package/dist/src/util/path/typechecks.js.map +1 -0
- package/dist/src/util/path/typedefs.js +2 -0
- package/dist/src/util/path/typedefs.js.map +1 -0
- package/dist/src/util/transform_matrix_removal.js +46 -0
- package/dist/src/util/transform_matrix_removal.js.map +1 -0
- package/dist/src/util/typeAssertions.js +21 -0
- package/dist/src/util/typeAssertions.js.map +1 -0
- package/dist-extensions/src/gradient/Gradient.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/gradient/Gradient.ts +5 -2
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removes value from an array.
|
|
3
|
+
* Presence of value (and its position in an array) is determined via `Array.prototype.indexOf`
|
|
4
|
+
* @param {Array} array
|
|
5
|
+
* @param {*} value
|
|
6
|
+
* @return {Array} original array
|
|
7
|
+
*/
|
|
8
|
+
export const removeFromArray = (array, value) => {
|
|
9
|
+
const idx = array.indexOf(value);
|
|
10
|
+
if (idx !== -1) {
|
|
11
|
+
array.splice(idx, 1);
|
|
12
|
+
}
|
|
13
|
+
return array;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=removeFromArray.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"removeFromArray.js","sourceRoot":"","sources":["../../../../src/util/internals/removeFromArray.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAI,KAAU,EAAE,KAAQ,EAAO,EAAE;IAC9D,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACjC,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC;QACf,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uid.js","sourceRoot":"","sources":["../../../../src/util/internals/uid.ts"],"names":[],"mappings":"AAAA,IAAI,EAAE,GAAG,CAAC,CAAC;AAEX,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { getFabricWindow } from '../env';
|
|
2
|
+
/**
|
|
3
|
+
* Capitalizes a string
|
|
4
|
+
* @param {String} string String to capitalize
|
|
5
|
+
* @param {Boolean} [firstLetterOnly] If true only first letter is capitalized
|
|
6
|
+
* and other letters stay untouched, if false first letter is capitalized
|
|
7
|
+
* and other letters are converted to lowercase.
|
|
8
|
+
* @return {String} Capitalized version of a string
|
|
9
|
+
*/
|
|
10
|
+
export const capitalize = (string, firstLetterOnly = false) => `${string.charAt(0).toUpperCase()}${firstLetterOnly ? string.slice(1) : string.slice(1).toLowerCase()}`;
|
|
11
|
+
/**
|
|
12
|
+
* Escapes XML in a string
|
|
13
|
+
* @param {String} string String to escape
|
|
14
|
+
* @return {String} Escaped version of a string
|
|
15
|
+
*/
|
|
16
|
+
export const escapeXml = (string) => string
|
|
17
|
+
.replace(/&/g, '&')
|
|
18
|
+
.replace(/"/g, '"')
|
|
19
|
+
.replace(/'/g, ''')
|
|
20
|
+
.replace(/</g, '<')
|
|
21
|
+
.replace(/>/g, '>');
|
|
22
|
+
let segmenter;
|
|
23
|
+
const getSegmenter = () => {
|
|
24
|
+
if (!segmenter) {
|
|
25
|
+
segmenter =
|
|
26
|
+
'Intl' in getFabricWindow() &&
|
|
27
|
+
'Segmenter' in Intl &&
|
|
28
|
+
new Intl.Segmenter(undefined, {
|
|
29
|
+
granularity: 'grapheme',
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return segmenter;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Divide a string in the user perceived single units
|
|
36
|
+
* @param {String} textstring String to escape
|
|
37
|
+
* @return {Array} array containing the graphemes
|
|
38
|
+
*/
|
|
39
|
+
export const graphemeSplit = (textstring) => {
|
|
40
|
+
segmenter || getSegmenter();
|
|
41
|
+
if (segmenter) {
|
|
42
|
+
const segments = segmenter.segment(textstring);
|
|
43
|
+
return Array.from(segments).map(({ segment }) => segment);
|
|
44
|
+
}
|
|
45
|
+
//Fallback
|
|
46
|
+
return graphemeSplitImpl(textstring);
|
|
47
|
+
};
|
|
48
|
+
const graphemeSplitImpl = (textstring) => {
|
|
49
|
+
const graphemes = [];
|
|
50
|
+
for (let i = 0, chr; i < textstring.length; i++) {
|
|
51
|
+
if ((chr = getWholeChar(textstring, i)) === false) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
graphemes.push(chr);
|
|
55
|
+
}
|
|
56
|
+
return graphemes;
|
|
57
|
+
};
|
|
58
|
+
// taken from mdn in the charAt doc page.
|
|
59
|
+
const getWholeChar = (str, i) => {
|
|
60
|
+
const code = str.charCodeAt(i);
|
|
61
|
+
if (isNaN(code)) {
|
|
62
|
+
return ''; // Position not found
|
|
63
|
+
}
|
|
64
|
+
if (code < 0xd800 || code > 0xdfff) {
|
|
65
|
+
return str.charAt(i);
|
|
66
|
+
}
|
|
67
|
+
// High surrogate (could change last hex to 0xDB7F to treat high private
|
|
68
|
+
// surrogates as single characters)
|
|
69
|
+
if (0xd800 <= code && code <= 0xdbff) {
|
|
70
|
+
if (str.length <= i + 1) {
|
|
71
|
+
throw 'High surrogate without following low surrogate';
|
|
72
|
+
}
|
|
73
|
+
const next = str.charCodeAt(i + 1);
|
|
74
|
+
if (0xdc00 > next || next > 0xdfff) {
|
|
75
|
+
throw 'High surrogate without following low surrogate';
|
|
76
|
+
}
|
|
77
|
+
return str.charAt(i) + str.charAt(i + 1);
|
|
78
|
+
}
|
|
79
|
+
// Low surrogate (0xDC00 <= code && code <= 0xDFFF)
|
|
80
|
+
if (i === 0) {
|
|
81
|
+
throw 'Low surrogate without preceding high surrogate';
|
|
82
|
+
}
|
|
83
|
+
const prev = str.charCodeAt(i - 1);
|
|
84
|
+
// (could change last hex to 0xDB7F to treat high private
|
|
85
|
+
// surrogates as single characters)
|
|
86
|
+
if (0xd800 > prev || prev > 0xdbff) {
|
|
87
|
+
throw 'Low surrogate without preceding high surrogate';
|
|
88
|
+
}
|
|
89
|
+
// We can pass over low surrogates now as the second component
|
|
90
|
+
// in a pair which we have already processed
|
|
91
|
+
return false;
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=lang_string.js.map
|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AE,CAAC;YACxB,MAAM,gDAAgD,CAAC;QACzD,CAAC;QACD,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACnC,IAAI,MAAM,GAAG,IAAI,IAAI,IAAI,GAAG,MAAM,EAAE,CAAC;YACnC,MAAM,gDAAgD,CAAC;QACzD,CAAC;QACD,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3C,CAAC;IACD,mDAAmD;IACnD,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACZ,MAAM,gDAAgD,CAAC;IACzD,CAAC;IACD,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAEnC,yDAAyD;IACzD,mCAAmC;IACnC,IAAI,MAAM,GAAG,IAAI,IAAI,IAAI,GAAG,MAAM,EAAE,CAAC;QACnC,MAAM,gDAAgD,CAAC;IACzD,CAAC;IACD,8DAA8D;IAC9D,4CAA4C;IAC5C,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates bounding box (left, top, width, height) from given `points`
|
|
3
|
+
* @param {XY[]} points
|
|
4
|
+
* @return {Object} Object with left, top, width, height properties
|
|
5
|
+
*/
|
|
6
|
+
export const makeBoundingBoxFromPoints = (points) => {
|
|
7
|
+
let left = 0, top = 0, width = 0, height = 0;
|
|
8
|
+
for (let i = 0, len = points.length; i < len; i++) {
|
|
9
|
+
const { x, y } = points[i];
|
|
10
|
+
if (x > width || !i)
|
|
11
|
+
width = x;
|
|
12
|
+
if (x < left || !i)
|
|
13
|
+
left = x;
|
|
14
|
+
if (y > height || !i)
|
|
15
|
+
height = y;
|
|
16
|
+
if (y < top || !i)
|
|
17
|
+
top = y;
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
left,
|
|
21
|
+
top,
|
|
22
|
+
width: width - left,
|
|
23
|
+
height: height - top,
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=boundingBoxFromPoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boundingBoxFromPoints.js","sourceRoot":"","sources":["../../../../src/util/misc/boundingBoxFromPoints.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,MAAY,EAAS,EAAE;IAC/D,IAAI,IAAI,GAAG,CAAC,EACV,GAAG,GAAG,CAAC,EACP,KAAK,GAAG,CAAC,EACT,MAAM,GAAG,CAAC,CAAC;IAEb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QAClD,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QAC3B,IAAI,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC;YAAE,KAAK,GAAG,CAAC,CAAC;QAC/B,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;YAAE,IAAI,GAAG,CAAC,CAAC;QAC7B,IAAI,CAAC,GAAG,MAAM,IAAI,CAAC,CAAC;YAAE,MAAM,GAAG,CAAC,CAAC;QACjC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;YAAE,GAAG,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED,OAAO;QACL,IAAI;QACJ,GAAG;QACH,KAAK,EAAE,KAAK,GAAG,IAAI;QACnB,MAAM,EAAE,MAAM,GAAG,GAAG;KACrB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capValue.js","sourceRoot":"","sources":["../../../../src/util/misc/capValue.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,KAAa,EAAE,GAAW,EAAE,EAAE,CAClE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { halfPI } from '../../constants';
|
|
2
|
+
/**
|
|
3
|
+
* Calculate the cos of an angle, avoiding returning floats for known results
|
|
4
|
+
* This function is here just to avoid getting 0.999999999999999 when dealing
|
|
5
|
+
* with numbers that are really 1 or 0.
|
|
6
|
+
* @param {TRadian} angle the angle
|
|
7
|
+
* @return {Number} the cosin value for angle.
|
|
8
|
+
*/
|
|
9
|
+
export const cos = (angle) => {
|
|
10
|
+
if (angle === 0) {
|
|
11
|
+
return 1;
|
|
12
|
+
}
|
|
13
|
+
const angleSlice = Math.abs(angle) / halfPI;
|
|
14
|
+
switch (angleSlice) {
|
|
15
|
+
case 1:
|
|
16
|
+
case 3:
|
|
17
|
+
return 0;
|
|
18
|
+
case 2:
|
|
19
|
+
return -1;
|
|
20
|
+
}
|
|
21
|
+
return Math.cos(angle);
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=cos.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cos.js","sourceRoot":"","sources":["../../../../src/util/misc/cos.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,KAAc,EAAU,EAAE;IAC5C,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;QAChB,OAAO,CAAC,CAAC;IACX,CAAC;IACD,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC;IAC5C,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,CAAC,CAAC;QACP,KAAK,CAAC;YACJ,OAAO,CAAC,CAAC;QACX,KAAK,CAAC;YACJ,OAAO,CAAC,CAAC,CAAC;IACd,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { getFabricDocument } from '../../env';
|
|
2
|
+
import { FabricError } from '../internals/console';
|
|
3
|
+
/**
|
|
4
|
+
* Creates canvas element
|
|
5
|
+
* @return {CanvasElement} initialized canvas element
|
|
6
|
+
*/
|
|
7
|
+
export const createCanvasElement = () => {
|
|
8
|
+
const element = getFabricDocument().createElement('canvas');
|
|
9
|
+
if (!element || typeof element.getContext === 'undefined') {
|
|
10
|
+
throw new FabricError('Failed to create `canvas` element');
|
|
11
|
+
}
|
|
12
|
+
return element;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Creates image element (works on client and node)
|
|
16
|
+
* @return {HTMLImageElement} HTML image element
|
|
17
|
+
*/
|
|
18
|
+
export const createImage = () => getFabricDocument().createElement('img');
|
|
19
|
+
/**
|
|
20
|
+
* Creates a canvas element that is a copy of another and is also painted
|
|
21
|
+
* @param {CanvasElement} canvas to copy size and content of
|
|
22
|
+
* @return {CanvasElement} initialized canvas element
|
|
23
|
+
*/
|
|
24
|
+
export const copyCanvasElement = (canvas) => {
|
|
25
|
+
const newCanvas = createCanvasElementFor(canvas);
|
|
26
|
+
newCanvas.getContext('2d')?.drawImage(canvas, 0, 0);
|
|
27
|
+
return newCanvas;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Creates a canvas element as big as another
|
|
31
|
+
* @param {CanvasElement} canvas to copy size and content of
|
|
32
|
+
* @return {CanvasElement} initialized canvas element
|
|
33
|
+
*/
|
|
34
|
+
export const createCanvasElementFor = (canvas) => {
|
|
35
|
+
const newCanvas = createCanvasElement();
|
|
36
|
+
newCanvas.width = canvas.width;
|
|
37
|
+
newCanvas.height = canvas.height;
|
|
38
|
+
return newCanvas;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* since 2.6.0 moved from canvas instance to utility.
|
|
42
|
+
* possibly useless
|
|
43
|
+
* @param {CanvasElement} canvasEl to copy size and content of
|
|
44
|
+
* @param {String} format 'jpeg' or 'png', in some browsers 'webp' is ok too
|
|
45
|
+
* @param {number} quality <= 1 and > 0
|
|
46
|
+
* @return {String} data url
|
|
47
|
+
*/
|
|
48
|
+
export const toDataURL = (canvasEl, format, quality) => canvasEl.toDataURL(`image/${format}`, quality);
|
|
49
|
+
export const isHTMLCanvas = (canvas) => {
|
|
50
|
+
return !!canvas && canvas.getContext !== undefined;
|
|
51
|
+
};
|
|
52
|
+
export const toBlob = (canvasEl, format, quality) => new Promise((resolve, _) => {
|
|
53
|
+
canvasEl.toBlob(resolve, `image/${format}`, quality);
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=dom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom.js","sourceRoot":"","sources":["../../../../src/util/misc/dom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAsB,EAAE;IACzD,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC5D,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,CAAC,UAAU,KAAK,WAAW,EAAE,CAAC;QAC1D,MAAM,IAAI,WAAW,CAAC,mCAAmC,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,GAAqB,EAAE,CAChD,iBAAiB,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AAE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
3
|
+
* keeping aspect ratio intact.
|
|
4
|
+
* respect the total allowed area for the cache.
|
|
5
|
+
* @param {TSize} source natural unscaled size of the object
|
|
6
|
+
* @param {TSize} destination natural unscaled size of the object
|
|
7
|
+
* @return {Number} scale factor to apply to source to fit into destination
|
|
8
|
+
*/
|
|
9
|
+
export const findScaleToFit = (source, destination) => Math.min(destination.width / source.width, destination.height / source.height);
|
|
10
|
+
/**
|
|
11
|
+
* Finds the scale for the object source to cover entirely the object destination,
|
|
12
|
+
* keeping aspect ratio intact.
|
|
13
|
+
* respect the total allowed area for the cache.
|
|
14
|
+
* @param {TSize} source natural unscaled size of the object
|
|
15
|
+
* @param {TSize} destination natural unscaled size of the object
|
|
16
|
+
* @return {Number} scale factor to apply to source to cover destination
|
|
17
|
+
*/
|
|
18
|
+
export const findScaleToCover = (source, destination) => Math.max(destination.width / source.width, destination.height / source.height);
|
|
19
|
+
//# sourceMappingURL=findScaleTo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findScaleTo.js","sourceRoot":"","sources":["../../../../src/util/misc/findScaleTo.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAa,EAAE,WAAkB,EAAE,EAAE,CAClE,IAAI,CAAC,GAAG,CACN,WAAW,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,EAChC,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CACnC,CAAC;AAEJ;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAa,EAAE,WAAkB,EAAE,EAAE,CACpE,IAAI,CAAC,GAAG,CACN,WAAW,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,EAChC,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CACnC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Group } from '../../shapes/Group';
|
|
2
|
+
/**
|
|
3
|
+
* TODO experiment with different layout manager and svg results ( fixed fit content )
|
|
4
|
+
* Groups SVG elements (usually those retrieved from SVG document)
|
|
5
|
+
* @static
|
|
6
|
+
* @param {FabricObject[]} elements FabricObject(s) parsed from svg, to group
|
|
7
|
+
* @return {FabricObject | Group}
|
|
8
|
+
*/
|
|
9
|
+
export const groupSVGElements = (elements, options) => {
|
|
10
|
+
if (elements && elements.length === 1) {
|
|
11
|
+
return elements[0];
|
|
12
|
+
}
|
|
13
|
+
return new Group(elements, options);
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=groupSVGElements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"groupSVGElements.js","sourceRoot":"","sources":["../../../../src/util/misc/groupSVGElements.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAG3C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,QAAwB,EACxB,OAA6B,EAC7B,EAAE;IACF,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AACtC,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true if context has transparent pixel
|
|
3
|
+
* at specified location (taking tolerance into account)
|
|
4
|
+
* @param {CanvasRenderingContext2D} ctx context
|
|
5
|
+
* @param {Number} x x coordinate in canvasElementCoordinate, not fabric space. integer
|
|
6
|
+
* @param {Number} y y coordinate in canvasElementCoordinate, not fabric space. integer
|
|
7
|
+
* @param {Number} tolerance Tolerance pixels around the point, not alpha tolerance, integer
|
|
8
|
+
* @return {boolean} true if transparent
|
|
9
|
+
*/
|
|
10
|
+
export const isTransparent = (ctx, x, y, tolerance) => {
|
|
11
|
+
tolerance = Math.round(tolerance);
|
|
12
|
+
const size = tolerance * 2 + 1;
|
|
13
|
+
const { data } = ctx.getImageData(x - tolerance, y - tolerance, size, size);
|
|
14
|
+
// Split image data - for tolerance > 1, pixelDataSize = 4;
|
|
15
|
+
for (let i = 3; i < data.length; i += 4) {
|
|
16
|
+
const alphaChannel = data[i];
|
|
17
|
+
if (alphaChannel > 0) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=isTransparent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isTransparent.js","sourceRoot":"","sources":["../../../../src/util/misc/isTransparent.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,GAA6B,EAC7B,CAAS,EACT,CAAS,EACT,SAAiB,EACR,EAAE;IACX,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,SAAS,GAAG,CAAC,GAAG,CAAC,CAAC;IAC/B,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC,GAAG,SAAS,EAAE,CAAC,GAAG,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAE5E,2DAA2D;IAC3D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,MAAM,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7B,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;YACrB,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { iMatrix } from '../../constants';
|
|
2
|
+
import { Point } from '../../Point';
|
|
3
|
+
import { cos } from './cos';
|
|
4
|
+
import { degreesToRadians, radiansToDegrees } from './radiansDegreesConversion';
|
|
5
|
+
import { sin } from './sin';
|
|
6
|
+
export const isIdentityMatrix = (mat) => mat.every((value, index) => value === iMatrix[index]);
|
|
7
|
+
/**
|
|
8
|
+
* Apply transform t to point p
|
|
9
|
+
* @deprecated use {@link Point#transform}
|
|
10
|
+
* @param {Point | XY} p The point to transform
|
|
11
|
+
* @param {Array} t The transform
|
|
12
|
+
* @param {Boolean} [ignoreOffset] Indicates that the offset should not be applied
|
|
13
|
+
* @return {Point} The transformed point
|
|
14
|
+
*/
|
|
15
|
+
export const transformPoint = (p, t, ignoreOffset) => new Point(p).transform(t, ignoreOffset);
|
|
16
|
+
/**
|
|
17
|
+
* Invert transformation t
|
|
18
|
+
* @param {Array} t The transform
|
|
19
|
+
* @return {Array} The inverted transform
|
|
20
|
+
*/
|
|
21
|
+
export const invertTransform = (t) => {
|
|
22
|
+
const a = 1 / (t[0] * t[3] - t[1] * t[2]), r = [a * t[3], -a * t[1], -a * t[2], a * t[0], 0, 0], { x, y } = new Point(t[4], t[5]).transform(r, true);
|
|
23
|
+
r[4] = -x;
|
|
24
|
+
r[5] = -y;
|
|
25
|
+
return r;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Multiply matrix A by matrix B to nest transformations
|
|
29
|
+
* @param {TMat2D} a First transformMatrix
|
|
30
|
+
* @param {TMat2D} b Second transformMatrix
|
|
31
|
+
* @param {Boolean} is2x2 flag to multiply matrices as 2x2 matrices
|
|
32
|
+
* @return {TMat2D} The product of the two transform matrices
|
|
33
|
+
*/
|
|
34
|
+
export const multiplyTransformMatrices = (a, b, is2x2) => [
|
|
35
|
+
a[0] * b[0] + a[2] * b[1],
|
|
36
|
+
a[1] * b[0] + a[3] * b[1],
|
|
37
|
+
a[0] * b[2] + a[2] * b[3],
|
|
38
|
+
a[1] * b[2] + a[3] * b[3],
|
|
39
|
+
is2x2 ? 0 : a[0] * b[4] + a[2] * b[5] + a[4],
|
|
40
|
+
is2x2 ? 0 : a[1] * b[4] + a[3] * b[5] + a[5],
|
|
41
|
+
];
|
|
42
|
+
/**
|
|
43
|
+
* Multiplies {@link TMat2D} such that a matrix defines the plane for the rest of the matrices **after** it
|
|
44
|
+
*
|
|
45
|
+
* `multiplyTransformMatrixArray([A, B, C, D])` is equivalent to `A(B(C(D)))`
|
|
46
|
+
*
|
|
47
|
+
* @param matrices an array of matrices
|
|
48
|
+
* @param [is2x2] flag to multiply matrices as 2x2 matrices
|
|
49
|
+
* @returns the multiplication product
|
|
50
|
+
*/
|
|
51
|
+
export const multiplyTransformMatrixArray = (matrices, is2x2) => matrices.reduceRight((product, curr) => curr && product
|
|
52
|
+
? multiplyTransformMatrices(curr, product, is2x2)
|
|
53
|
+
: curr || product, undefined) || iMatrix.concat();
|
|
54
|
+
export const calcPlaneRotation = ([a, b]) => Math.atan2(b, a);
|
|
55
|
+
/**
|
|
56
|
+
* Decomposes standard 2x3 matrix into transform components
|
|
57
|
+
* @param {TMat2D} a transformMatrix
|
|
58
|
+
* @return {Object} Components of transform
|
|
59
|
+
*/
|
|
60
|
+
export const qrDecompose = (a) => {
|
|
61
|
+
const angle = calcPlaneRotation(a), denom = Math.pow(a[0], 2) + Math.pow(a[1], 2), scaleX = Math.sqrt(denom), scaleY = (a[0] * a[3] - a[2] * a[1]) / scaleX, skewX = Math.atan2(a[0] * a[2] + a[1] * a[3], denom);
|
|
62
|
+
return {
|
|
63
|
+
angle: radiansToDegrees(angle),
|
|
64
|
+
scaleX,
|
|
65
|
+
scaleY,
|
|
66
|
+
skewX: radiansToDegrees(skewX),
|
|
67
|
+
skewY: 0,
|
|
68
|
+
translateX: a[4] || 0,
|
|
69
|
+
translateY: a[5] || 0,
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Generate a translation matrix
|
|
74
|
+
*
|
|
75
|
+
* A translation matrix in the form of
|
|
76
|
+
* [ 1 0 x ]
|
|
77
|
+
* [ 0 1 y ]
|
|
78
|
+
* [ 0 0 1 ]
|
|
79
|
+
*
|
|
80
|
+
* See @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#translate for more details
|
|
81
|
+
*
|
|
82
|
+
* @param {number} x translation on X axis
|
|
83
|
+
* @param {number} [y] translation on Y axis
|
|
84
|
+
* @returns {TMat2D} matrix
|
|
85
|
+
*/
|
|
86
|
+
export const createTranslateMatrix = (x, y = 0) => [
|
|
87
|
+
1,
|
|
88
|
+
0,
|
|
89
|
+
0,
|
|
90
|
+
1,
|
|
91
|
+
x,
|
|
92
|
+
y,
|
|
93
|
+
];
|
|
94
|
+
/**
|
|
95
|
+
* Generate a rotation matrix around around a point (x,y), defaulting to (0,0)
|
|
96
|
+
*
|
|
97
|
+
* A matrix in the form of
|
|
98
|
+
* [cos(a) -sin(a) -x*cos(a)+y*sin(a)+x]
|
|
99
|
+
* [sin(a) cos(a) -x*sin(a)-y*cos(a)+y]
|
|
100
|
+
* [0 0 1 ]
|
|
101
|
+
*
|
|
102
|
+
*
|
|
103
|
+
* @param {TDegree} angle rotation in degrees
|
|
104
|
+
* @param {XY} [pivotPoint] pivot point to rotate around
|
|
105
|
+
* @returns {TMat2D} matrix
|
|
106
|
+
*/
|
|
107
|
+
export function createRotateMatrix({ angle = 0 } = {}, { x = 0, y = 0 } = {}) {
|
|
108
|
+
const angleRadiant = degreesToRadians(angle), cosValue = cos(angleRadiant), sinValue = sin(angleRadiant);
|
|
109
|
+
return [
|
|
110
|
+
cosValue,
|
|
111
|
+
sinValue,
|
|
112
|
+
-sinValue,
|
|
113
|
+
cosValue,
|
|
114
|
+
x ? x - (cosValue * x - sinValue * y) : 0,
|
|
115
|
+
y ? y - (sinValue * x + cosValue * y) : 0,
|
|
116
|
+
];
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Generate a scale matrix around the point (0,0)
|
|
120
|
+
*
|
|
121
|
+
* A matrix in the form of
|
|
122
|
+
* [x 0 0]
|
|
123
|
+
* [0 y 0]
|
|
124
|
+
* [0 0 1]
|
|
125
|
+
*
|
|
126
|
+
* @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#scale
|
|
127
|
+
*
|
|
128
|
+
* @param {number} x scale on X axis
|
|
129
|
+
* @param {number} [y] scale on Y axis
|
|
130
|
+
* @returns {TMat2D} matrix
|
|
131
|
+
*/
|
|
132
|
+
export const createScaleMatrix = (x, y = x) => [
|
|
133
|
+
x,
|
|
134
|
+
0,
|
|
135
|
+
0,
|
|
136
|
+
y,
|
|
137
|
+
0,
|
|
138
|
+
0,
|
|
139
|
+
];
|
|
140
|
+
export const angleToSkew = (angle) => Math.tan(degreesToRadians(angle));
|
|
141
|
+
export const skewToAngle = (value) => radiansToDegrees(Math.atan(value));
|
|
142
|
+
/**
|
|
143
|
+
* Generate a skew matrix for the X axis
|
|
144
|
+
*
|
|
145
|
+
* A matrix in the form of
|
|
146
|
+
* [1 x 0]
|
|
147
|
+
* [0 1 0]
|
|
148
|
+
* [0 0 1]
|
|
149
|
+
*
|
|
150
|
+
* @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#skewx
|
|
151
|
+
*
|
|
152
|
+
* @param {TDegree} skewValue translation on X axis
|
|
153
|
+
* @returns {TMat2D} matrix
|
|
154
|
+
*/
|
|
155
|
+
export const createSkewXMatrix = (skewValue) => [
|
|
156
|
+
1,
|
|
157
|
+
0,
|
|
158
|
+
angleToSkew(skewValue),
|
|
159
|
+
1,
|
|
160
|
+
0,
|
|
161
|
+
0,
|
|
162
|
+
];
|
|
163
|
+
/**
|
|
164
|
+
* Generate a skew matrix for the Y axis
|
|
165
|
+
*
|
|
166
|
+
* A matrix in the form of
|
|
167
|
+
* [1 0 0]
|
|
168
|
+
* [y 1 0]
|
|
169
|
+
* [0 0 1]
|
|
170
|
+
*
|
|
171
|
+
* @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#skewy
|
|
172
|
+
*
|
|
173
|
+
* @param {TDegree} skewValue translation on Y axis
|
|
174
|
+
* @returns {TMat2D} matrix
|
|
175
|
+
*/
|
|
176
|
+
export const createSkewYMatrix = (skewValue) => [
|
|
177
|
+
1,
|
|
178
|
+
angleToSkew(skewValue),
|
|
179
|
+
0,
|
|
180
|
+
1,
|
|
181
|
+
0,
|
|
182
|
+
0,
|
|
183
|
+
];
|
|
184
|
+
/**
|
|
185
|
+
* Returns a transform matrix starting from an object of the same kind of
|
|
186
|
+
* the one returned from qrDecompose, useful also if you want to calculate some
|
|
187
|
+
* transformations from an object that is not enlived yet.
|
|
188
|
+
* is called DimensionsTransformMatrix because those properties are the one that influence
|
|
189
|
+
* the size of the resulting box of the object.
|
|
190
|
+
* @param {Object} options
|
|
191
|
+
* @param {Number} [options.scaleX]
|
|
192
|
+
* @param {Number} [options.scaleY]
|
|
193
|
+
* @param {Boolean} [options.flipX]
|
|
194
|
+
* @param {Boolean} [options.flipY]
|
|
195
|
+
* @param {Number} [options.skewX]
|
|
196
|
+
* @param {Number} [options.skewY]
|
|
197
|
+
* @return {Number[]} transform matrix
|
|
198
|
+
*/
|
|
199
|
+
export const calcDimensionsMatrix = ({ scaleX = 1, scaleY = 1, flipX = false, flipY = false, skewX = 0, skewY = 0, }) => {
|
|
200
|
+
let matrix = createScaleMatrix(flipX ? -scaleX : scaleX, flipY ? -scaleY : scaleY);
|
|
201
|
+
if (skewX) {
|
|
202
|
+
matrix = multiplyTransformMatrices(matrix, createSkewXMatrix(skewX), true);
|
|
203
|
+
}
|
|
204
|
+
if (skewY) {
|
|
205
|
+
matrix = multiplyTransformMatrices(matrix, createSkewYMatrix(skewY), true);
|
|
206
|
+
}
|
|
207
|
+
return matrix;
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* Returns a transform matrix starting from an object of the same kind of
|
|
211
|
+
* the one returned from qrDecompose, useful also if you want to calculate some
|
|
212
|
+
* transformations from an object that is not enlived yet
|
|
213
|
+
* Before changing this function look at: src/benchmarks/calcTransformMatrix.mjs
|
|
214
|
+
* @param {Object} options
|
|
215
|
+
* @param {Number} [options.angle]
|
|
216
|
+
* @param {Number} [options.scaleX]
|
|
217
|
+
* @param {Number} [options.scaleY]
|
|
218
|
+
* @param {Boolean} [options.flipX]
|
|
219
|
+
* @param {Boolean} [options.flipY]
|
|
220
|
+
* @param {Number} [options.skewX]
|
|
221
|
+
* @param {Number} [options.skewY]
|
|
222
|
+
* @param {Number} [options.translateX]
|
|
223
|
+
* @param {Number} [options.translateY]
|
|
224
|
+
* @return {Number[]} transform matrix
|
|
225
|
+
*/
|
|
226
|
+
export const composeMatrix = (options) => {
|
|
227
|
+
const { translateX = 0, translateY = 0, angle = 0 } = options;
|
|
228
|
+
let matrix = createTranslateMatrix(translateX, translateY);
|
|
229
|
+
if (angle) {
|
|
230
|
+
matrix = multiplyTransformMatrices(matrix, createRotateMatrix({ angle }));
|
|
231
|
+
}
|
|
232
|
+
const scaleMatrix = calcDimensionsMatrix(options);
|
|
233
|
+
if (!isIdentityMatrix(scaleMatrix)) {
|
|
234
|
+
matrix = multiplyTransformMatrices(matrix, scaleMatrix);
|
|
235
|
+
}
|
|
236
|
+
return matrix;
|
|
237
|
+
};
|
|
238
|
+
//# sourceMappingURL=matrix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matrix.js","sourceRoot":"","sources":["../../../../src/util/misc/matrix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AA4B5B,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAW,EAAE,EAAE,CAC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AAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAC3D,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,GAAG,yBAAyB,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAC5E,CAAC;IACD,MAAM,WAAW,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAClD,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,EAAE,CAAC;QACnC,MAAM,GAAG,yBAAyB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { sendObjectToPlane } from './planeChange';
|
|
2
|
+
import { Group } from '../../shapes/Group';
|
|
3
|
+
/**
|
|
4
|
+
* Merges 2 clip paths into one visually equal clip path
|
|
5
|
+
*
|
|
6
|
+
* **IMPORTANT**:\
|
|
7
|
+
* Does **NOT** clone the arguments, clone them proir if necessary.
|
|
8
|
+
*
|
|
9
|
+
* Creates a wrapper (group) that contains one clip path and is clipped by the other so content is kept where both overlap.
|
|
10
|
+
* Use this method if both the clip paths may have nested clip paths of their own, so assigning one to the other's clip path property is not possible.
|
|
11
|
+
*
|
|
12
|
+
* In order to handle the `inverted` property we follow logic described in the following cases:\
|
|
13
|
+
* **(1)** both clip paths are inverted - the clip paths pass the inverted prop to the wrapper and loose it themselves.\
|
|
14
|
+
* **(2)** one is inverted and the other isn't - the wrapper shouldn't become inverted and the inverted clip path must clip the non inverted one to produce an identical visual effect.\
|
|
15
|
+
* **(3)** both clip paths are not inverted - wrapper and clip paths remain unchanged.
|
|
16
|
+
*
|
|
17
|
+
* @memberOf fabric.util
|
|
18
|
+
* @param {fabric.Object} c1
|
|
19
|
+
* @param {fabric.Object} c2
|
|
20
|
+
* @returns {fabric.Object} merged clip path
|
|
21
|
+
*/
|
|
22
|
+
export const mergeClipPaths = (c1, c2) => {
|
|
23
|
+
let a = c1, b = c2;
|
|
24
|
+
if (a.inverted && !b.inverted) {
|
|
25
|
+
// case (2)
|
|
26
|
+
a = c2;
|
|
27
|
+
b = c1;
|
|
28
|
+
}
|
|
29
|
+
// `b` becomes `a`'s clip path so we transform `b` to `a` coordinate plane
|
|
30
|
+
sendObjectToPlane(b, b.group?.calcTransformMatrix(), a.calcTransformMatrix());
|
|
31
|
+
// assign the `inverted` prop to the wrapping group
|
|
32
|
+
const inverted = a.inverted && b.inverted;
|
|
33
|
+
if (inverted) {
|
|
34
|
+
// case (1)
|
|
35
|
+
a.inverted = b.inverted = false;
|
|
36
|
+
}
|
|
37
|
+
return new Group([a], { clipPath: b, inverted });
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=mergeClipPaths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeClipPaths.js","sourceRoot":"","sources":["../../../../src/util/misc/mergeClipPaths.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAAgB,EAAE,EAAgB,EAAE,EAAE;IACnE,IAAI,CAAC,GAAG,EAAE,EACR,CAAC,GAAG,EAAE,CAAC;IACT,IAAI,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC9B,YAAY;QACZ,CAAC,GAAG,EAAE,CAAC;QACP,CAAC,GAAG,EAAE,CAAC;IACT,CAAC;IACD,2EAA2E;IAC3E,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,mBAAmB,EAAE,EAAE,CAAC,CAAC,mBAAmB,EAAE,CAAC,CAAC;IAC9E,oDAAoD;IACpD,MAAM,QAAQ,GAAG,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,QAAQ,CAAC;IAC1C,IAAI,QAAQ,EAAE,CAAC;QACb,YAAY;QACZ,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,GAAG,KAAK,CAAC;IAClC,CAAC;IACD,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;AACnD,CAAC,CAAC"}
|