fabric 6.2.0 → 6.3.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/.prettierignore +1 -0
- package/CHANGELOG.md +12 -4
- package/README.md +1 -1
- package/dist/extensions/aligning_guidelines/constant.d.ts +3 -0
- package/dist/extensions/aligning_guidelines/constant.d.ts.map +1 -0
- package/dist/extensions/aligning_guidelines/index.d.ts +5 -0
- package/dist/extensions/aligning_guidelines/index.d.ts.map +1 -0
- package/dist/extensions/aligning_guidelines/typedefs.d.ts +33 -0
- package/dist/extensions/aligning_guidelines/typedefs.d.ts.map +1 -0
- package/dist/extensions/aligning_guidelines/util/basic.d.ts +4 -0
- package/dist/extensions/aligning_guidelines/util/basic.d.ts.map +1 -0
- package/dist/extensions/aligning_guidelines/util/collect-line.d.ts +13 -0
- package/dist/extensions/aligning_guidelines/util/collect-line.d.ts.map +1 -0
- package/dist/extensions/aligning_guidelines/util/collect-point.d.ts +20 -0
- package/dist/extensions/aligning_guidelines/util/collect-point.d.ts.map +1 -0
- package/dist/extensions/aligning_guidelines/util/draw.d.ts +6 -0
- package/dist/extensions/aligning_guidelines/util/draw.d.ts.map +1 -0
- package/dist/extensions/aligning_guidelines/util/get-objects-by-target.d.ts +3 -0
- package/dist/extensions/aligning_guidelines/util/get-objects-by-target.d.ts.map +1 -0
- package/dist/extensions/index.d.ts +2 -0
- package/dist/extensions/index.d.ts.map +1 -0
- package/dist/index.js +140 -108
- 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 +140 -108
- package/dist/index.mjs.map +1 -1
- package/dist/index.node.cjs +140 -108
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +140 -108
- package/dist/index.node.mjs.map +1 -1
- package/dist/package.json.min.mjs +1 -1
- package/dist/package.json.mjs +1 -1
- package/dist/src/ClassRegistry.min.mjs.map +1 -1
- package/dist/src/ClassRegistry.mjs.map +1 -1
- package/dist/src/Collection.min.mjs.map +1 -1
- package/dist/src/Collection.mjs.map +1 -1
- package/dist/src/Intersection.min.mjs.map +1 -1
- package/dist/src/Intersection.mjs.map +1 -1
- package/dist/src/LayoutManager/ActiveSelectionLayoutManager.min.mjs.map +1 -1
- package/dist/src/LayoutManager/ActiveSelectionLayoutManager.mjs.map +1 -1
- package/dist/src/LayoutManager/LayoutManager.d.ts +1 -1
- package/dist/src/LayoutManager/LayoutManager.d.ts.map +1 -1
- package/dist/src/LayoutManager/LayoutManager.min.mjs.map +1 -1
- package/dist/src/LayoutManager/LayoutManager.mjs +1 -1
- package/dist/src/LayoutManager/LayoutManager.mjs.map +1 -1
- package/dist/src/LayoutManager/LayoutStrategies/ClipPathLayout.min.mjs.map +1 -1
- package/dist/src/LayoutManager/LayoutStrategies/ClipPathLayout.mjs.map +1 -1
- package/dist/src/LayoutManager/LayoutStrategies/FixedLayout.min.mjs.map +1 -1
- package/dist/src/LayoutManager/LayoutStrategies/FixedLayout.mjs.map +1 -1
- package/dist/src/LayoutManager/LayoutStrategies/LayoutStrategy.min.mjs.map +1 -1
- package/dist/src/LayoutManager/LayoutStrategies/LayoutStrategy.mjs.map +1 -1
- package/dist/src/LayoutManager/LayoutStrategies/utils.min.mjs.map +1 -1
- package/dist/src/LayoutManager/LayoutStrategies/utils.mjs.map +1 -1
- package/dist/src/LayoutManager/types.d.ts.map +1 -1
- package/dist/src/Observable.min.mjs.map +1 -1
- package/dist/src/Observable.mjs.map +1 -1
- package/dist/src/Pattern/Pattern.d.ts +2 -2
- package/dist/src/Pattern/Pattern.d.ts.map +1 -1
- package/dist/src/Pattern/Pattern.min.mjs +1 -1
- package/dist/src/Pattern/Pattern.min.mjs.map +1 -1
- package/dist/src/Pattern/Pattern.mjs +14 -12
- package/dist/src/Pattern/Pattern.mjs.map +1 -1
- package/dist/src/Point.min.mjs.map +1 -1
- package/dist/src/Point.mjs.map +1 -1
- package/dist/src/Shadow.min.mjs.map +1 -1
- package/dist/src/Shadow.mjs.map +1 -1
- package/dist/src/brushes/CircleBrush.min.mjs.map +1 -1
- package/dist/src/brushes/CircleBrush.mjs.map +1 -1
- package/dist/src/brushes/PatternBrush.min.mjs.map +1 -1
- package/dist/src/brushes/PatternBrush.mjs.map +1 -1
- package/dist/src/brushes/PencilBrush.min.mjs.map +1 -1
- package/dist/src/brushes/PencilBrush.mjs.map +1 -1
- package/dist/src/brushes/SprayBrush.min.mjs.map +1 -1
- package/dist/src/brushes/SprayBrush.mjs.map +1 -1
- package/dist/src/canvas/Canvas.d.ts +1 -1
- package/dist/src/canvas/Canvas.d.ts.map +1 -1
- package/dist/src/canvas/Canvas.min.mjs.map +1 -1
- package/dist/src/canvas/Canvas.mjs +2 -1
- package/dist/src/canvas/Canvas.mjs.map +1 -1
- package/dist/src/canvas/DOMManagers/CanvasDOMManager.min.mjs.map +1 -1
- package/dist/src/canvas/DOMManagers/CanvasDOMManager.mjs.map +1 -1
- package/dist/src/canvas/DOMManagers/StaticCanvasDOMManager.min.mjs.map +1 -1
- package/dist/src/canvas/DOMManagers/StaticCanvasDOMManager.mjs.map +1 -1
- package/dist/src/canvas/DOMManagers/util.min.mjs.map +1 -1
- package/dist/src/canvas/DOMManagers/util.mjs.map +1 -1
- package/dist/src/canvas/SelectableCanvas.min.mjs.map +1 -1
- package/dist/src/canvas/SelectableCanvas.mjs.map +1 -1
- package/dist/src/canvas/StaticCanvas.d.ts +1 -1
- package/dist/src/canvas/StaticCanvas.d.ts.map +1 -1
- package/dist/src/canvas/StaticCanvas.min.mjs.map +1 -1
- package/dist/src/canvas/StaticCanvas.mjs +1 -1
- package/dist/src/canvas/StaticCanvas.mjs.map +1 -1
- package/dist/src/canvas/StaticCanvasOptions.d.ts.map +1 -1
- package/dist/src/canvas/StaticCanvasOptions.min.mjs.map +1 -1
- package/dist/src/canvas/StaticCanvasOptions.mjs.map +1 -1
- package/dist/src/canvas/TextEditingManager.min.mjs.map +1 -1
- package/dist/src/canvas/TextEditingManager.mjs.map +1 -1
- package/dist/src/color/Color.d.ts.map +1 -1
- package/dist/src/color/Color.min.mjs.map +1 -1
- package/dist/src/color/Color.mjs +1 -0
- package/dist/src/color/Color.mjs.map +1 -1
- package/dist/src/color/util.min.mjs.map +1 -1
- package/dist/src/color/util.mjs.map +1 -1
- package/dist/src/config.min.mjs.map +1 -1
- package/dist/src/config.mjs.map +1 -1
- package/dist/src/controls/Control.min.mjs.map +1 -1
- package/dist/src/controls/Control.mjs.map +1 -1
- package/dist/src/controls/changeWidth.min.mjs.map +1 -1
- package/dist/src/controls/changeWidth.mjs.map +1 -1
- package/dist/src/controls/controlRendering.min.mjs.map +1 -1
- package/dist/src/controls/controlRendering.mjs.map +1 -1
- package/dist/src/controls/drag.min.mjs.map +1 -1
- package/dist/src/controls/drag.mjs.map +1 -1
- package/dist/src/controls/fireEvent.min.mjs.map +1 -1
- package/dist/src/controls/fireEvent.mjs.map +1 -1
- package/dist/src/controls/pathControl.min.mjs.map +1 -1
- package/dist/src/controls/pathControl.mjs.map +1 -1
- package/dist/src/controls/polyControl.min.mjs.map +1 -1
- package/dist/src/controls/polyControl.mjs.map +1 -1
- package/dist/src/controls/rotate.min.mjs.map +1 -1
- package/dist/src/controls/rotate.mjs.map +1 -1
- package/dist/src/controls/scale.min.mjs.map +1 -1
- package/dist/src/controls/scale.mjs.map +1 -1
- package/dist/src/controls/scaleSkew.min.mjs.map +1 -1
- package/dist/src/controls/scaleSkew.mjs.map +1 -1
- package/dist/src/controls/skew.min.mjs.map +1 -1
- package/dist/src/controls/skew.mjs.map +1 -1
- package/dist/src/controls/util.min.mjs.map +1 -1
- package/dist/src/controls/util.mjs.map +1 -1
- package/dist/src/controls/wrapWithFireEvent.min.mjs.map +1 -1
- package/dist/src/controls/wrapWithFireEvent.mjs.map +1 -1
- package/dist/src/controls/wrapWithFixedAnchor.min.mjs.map +1 -1
- package/dist/src/controls/wrapWithFixedAnchor.mjs.map +1 -1
- package/dist/src/filters/BaseFilter.d.ts +5 -5
- package/dist/src/filters/BaseFilter.d.ts.map +1 -1
- package/dist/src/filters/BaseFilter.min.mjs.map +1 -1
- package/dist/src/filters/BaseFilter.mjs +5 -5
- package/dist/src/filters/BaseFilter.mjs.map +1 -1
- package/dist/src/filters/BlendColor.min.mjs.map +1 -1
- package/dist/src/filters/BlendColor.mjs.map +1 -1
- package/dist/src/filters/BlendImage.min.mjs.map +1 -1
- package/dist/src/filters/BlendImage.mjs.map +1 -1
- package/dist/src/filters/Blur.min.mjs.map +1 -1
- package/dist/src/filters/Blur.mjs.map +1 -1
- package/dist/src/filters/Brightness.min.mjs.map +1 -1
- package/dist/src/filters/Brightness.mjs.map +1 -1
- package/dist/src/filters/Canvas2dFilterBackend.min.mjs.map +1 -1
- package/dist/src/filters/Canvas2dFilterBackend.mjs.map +1 -1
- package/dist/src/filters/ColorMatrix.min.mjs.map +1 -1
- package/dist/src/filters/ColorMatrix.mjs.map +1 -1
- package/dist/src/filters/ColorMatrixFilters.min.mjs.map +1 -1
- package/dist/src/filters/ColorMatrixFilters.mjs.map +1 -1
- package/dist/src/filters/Composed.min.mjs.map +1 -1
- package/dist/src/filters/Composed.mjs.map +1 -1
- package/dist/src/filters/Contrast.min.mjs.map +1 -1
- package/dist/src/filters/Contrast.mjs.map +1 -1
- package/dist/src/filters/Convolute.min.mjs.map +1 -1
- package/dist/src/filters/Convolute.mjs.map +1 -1
- package/dist/src/filters/GLProbes/WebGLProbe.min.mjs.map +1 -1
- package/dist/src/filters/GLProbes/WebGLProbe.mjs.map +1 -1
- package/dist/src/filters/Gamma.min.mjs.map +1 -1
- package/dist/src/filters/Gamma.mjs.map +1 -1
- package/dist/src/filters/Grayscale.min.mjs.map +1 -1
- package/dist/src/filters/Grayscale.mjs.map +1 -1
- package/dist/src/filters/Invert.min.mjs.map +1 -1
- package/dist/src/filters/Invert.mjs.map +1 -1
- package/dist/src/filters/Noise.min.mjs.map +1 -1
- package/dist/src/filters/Noise.mjs.map +1 -1
- package/dist/src/filters/Pixelate.min.mjs.map +1 -1
- package/dist/src/filters/Pixelate.mjs.map +1 -1
- package/dist/src/filters/RemoveColor.min.mjs.map +1 -1
- package/dist/src/filters/RemoveColor.mjs.map +1 -1
- package/dist/src/filters/Resize.min.mjs.map +1 -1
- package/dist/src/filters/Resize.mjs.map +1 -1
- package/dist/src/filters/Saturation.min.mjs.map +1 -1
- package/dist/src/filters/Saturation.mjs.map +1 -1
- package/dist/src/filters/Vibrance.min.mjs.map +1 -1
- package/dist/src/filters/Vibrance.mjs.map +1 -1
- package/dist/src/filters/WebGLFilterBackend.min.mjs.map +1 -1
- package/dist/src/filters/WebGLFilterBackend.mjs.map +1 -1
- package/dist/src/filters/typedefs.d.ts +0 -1
- package/dist/src/filters/typedefs.d.ts.map +1 -1
- package/dist/src/filters/utils.min.mjs.map +1 -1
- package/dist/src/filters/utils.mjs.map +1 -1
- package/dist/src/gradient/Gradient.d.ts +7 -3
- package/dist/src/gradient/Gradient.d.ts.map +1 -1
- 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 +36 -24
- package/dist/src/gradient/Gradient.mjs.map +1 -1
- package/dist/src/gradient/parser/parseColorStops.min.mjs.map +1 -1
- package/dist/src/gradient/parser/parseColorStops.mjs.map +1 -1
- package/dist/src/gradient/parser/parseCoords.d.ts.map +1 -1
- package/dist/src/gradient/parser/parseCoords.min.mjs.map +1 -1
- package/dist/src/gradient/parser/parseCoords.mjs.map +1 -1
- package/dist/src/parser/applyViewboxTransform.min.mjs.map +1 -1
- package/dist/src/parser/applyViewboxTransform.mjs.map +1 -1
- package/dist/src/parser/constants.min.mjs.map +1 -1
- package/dist/src/parser/constants.mjs.map +1 -1
- package/dist/src/parser/elements_parser.min.mjs.map +1 -1
- package/dist/src/parser/elements_parser.mjs.map +1 -1
- package/dist/src/parser/getCSSRules.min.mjs.map +1 -1
- package/dist/src/parser/getCSSRules.mjs.map +1 -1
- package/dist/src/parser/getGlobalStylesForElement.min.mjs.map +1 -1
- package/dist/src/parser/getGlobalStylesForElement.mjs.map +1 -1
- package/dist/src/parser/getGradientDefs.min.mjs.map +1 -1
- package/dist/src/parser/getGradientDefs.mjs.map +1 -1
- package/dist/src/parser/getMultipleNodes.min.mjs.map +1 -1
- package/dist/src/parser/getMultipleNodes.mjs.map +1 -1
- package/dist/src/parser/loadSVGFromString.min.mjs.map +1 -1
- package/dist/src/parser/loadSVGFromString.mjs.map +1 -1
- package/dist/src/parser/loadSVGFromURL.min.mjs.map +1 -1
- package/dist/src/parser/loadSVGFromURL.mjs.map +1 -1
- package/dist/src/parser/normalizeAttr.min.mjs.map +1 -1
- package/dist/src/parser/normalizeAttr.mjs.map +1 -1
- package/dist/src/parser/normalizeValue.min.mjs.map +1 -1
- package/dist/src/parser/normalizeValue.mjs.map +1 -1
- package/dist/src/parser/parseAttributes.min.mjs.map +1 -1
- package/dist/src/parser/parseAttributes.mjs.map +1 -1
- package/dist/src/parser/parseFontDeclaration.min.mjs.map +1 -1
- package/dist/src/parser/parseFontDeclaration.mjs.map +1 -1
- package/dist/src/parser/parseSVGDocument.min.mjs.map +1 -1
- package/dist/src/parser/parseSVGDocument.mjs.map +1 -1
- package/dist/src/parser/parseStyleObject.min.mjs.map +1 -1
- package/dist/src/parser/parseStyleObject.mjs.map +1 -1
- package/dist/src/parser/parseStyleString.min.mjs.map +1 -1
- package/dist/src/parser/parseStyleString.mjs.map +1 -1
- package/dist/src/parser/parseTransformAttribute.min.mjs.map +1 -1
- package/dist/src/parser/parseTransformAttribute.mjs.map +1 -1
- package/dist/src/parser/parseUseDirectives.min.mjs.map +1 -1
- package/dist/src/parser/parseUseDirectives.mjs.map +1 -1
- package/dist/src/parser/percent.min.mjs.map +1 -1
- package/dist/src/parser/percent.mjs.map +1 -1
- package/dist/src/parser/recursivelyParseGradientsXlink.min.mjs.map +1 -1
- package/dist/src/parser/recursivelyParseGradientsXlink.mjs.map +1 -1
- package/dist/src/parser/setStrokeFillOpacity.min.mjs.map +1 -1
- package/dist/src/parser/setStrokeFillOpacity.mjs.map +1 -1
- package/dist/src/shapes/ActiveSelection.min.mjs.map +1 -1
- package/dist/src/shapes/ActiveSelection.mjs.map +1 -1
- package/dist/src/shapes/Circle.min.mjs.map +1 -1
- package/dist/src/shapes/Circle.mjs.map +1 -1
- package/dist/src/shapes/Ellipse.min.mjs.map +1 -1
- package/dist/src/shapes/Ellipse.mjs.map +1 -1
- package/dist/src/shapes/Group.d.ts +2 -2
- package/dist/src/shapes/Group.d.ts.map +1 -1
- package/dist/src/shapes/Group.min.mjs.map +1 -1
- package/dist/src/shapes/Group.mjs.map +1 -1
- package/dist/src/shapes/IText/DraggableTextDelegate.d.ts.map +1 -1
- package/dist/src/shapes/IText/DraggableTextDelegate.min.mjs +1 -1
- package/dist/src/shapes/IText/DraggableTextDelegate.min.mjs.map +1 -1
- package/dist/src/shapes/IText/DraggableTextDelegate.mjs +2 -2
- package/dist/src/shapes/IText/DraggableTextDelegate.mjs.map +1 -1
- package/dist/src/shapes/IText/IText.min.mjs.map +1 -1
- package/dist/src/shapes/IText/IText.mjs.map +1 -1
- package/dist/src/shapes/IText/ITextBehavior.min.mjs.map +1 -1
- package/dist/src/shapes/IText/ITextBehavior.mjs.map +1 -1
- package/dist/src/shapes/IText/ITextClickBehavior.min.mjs.map +1 -1
- package/dist/src/shapes/IText/ITextClickBehavior.mjs.map +1 -1
- package/dist/src/shapes/IText/ITextKeyBehavior.min.mjs.map +1 -1
- package/dist/src/shapes/IText/ITextKeyBehavior.mjs.map +1 -1
- package/dist/src/shapes/Image.min.mjs.map +1 -1
- package/dist/src/shapes/Image.mjs.map +1 -1
- package/dist/src/shapes/Line.min.mjs.map +1 -1
- package/dist/src/shapes/Line.mjs.map +1 -1
- package/dist/src/shapes/Object/AnimatableObject.d.ts.map +1 -1
- package/dist/src/shapes/Object/AnimatableObject.min.mjs.map +1 -1
- package/dist/src/shapes/Object/AnimatableObject.mjs.map +1 -1
- package/dist/src/shapes/Object/FabricObject.d.ts.map +1 -1
- package/dist/src/shapes/Object/FabricObject.min.mjs.map +1 -1
- package/dist/src/shapes/Object/FabricObject.mjs +2 -1
- package/dist/src/shapes/Object/FabricObject.mjs.map +1 -1
- package/dist/src/shapes/Object/FabricObjectSVGExportMixin.d.ts +1 -1
- package/dist/src/shapes/Object/FabricObjectSVGExportMixin.d.ts.map +1 -1
- package/dist/src/shapes/Object/FabricObjectSVGExportMixin.min.mjs.map +1 -1
- package/dist/src/shapes/Object/FabricObjectSVGExportMixin.mjs +1 -1
- package/dist/src/shapes/Object/FabricObjectSVGExportMixin.mjs.map +1 -1
- package/dist/src/shapes/Object/InteractiveObject.d.ts +13 -13
- package/dist/src/shapes/Object/InteractiveObject.d.ts.map +1 -1
- package/dist/src/shapes/Object/InteractiveObject.min.mjs.map +1 -1
- package/dist/src/shapes/Object/InteractiveObject.mjs +13 -13
- package/dist/src/shapes/Object/InteractiveObject.mjs.map +1 -1
- package/dist/src/shapes/Object/Object.d.ts +4 -4
- package/dist/src/shapes/Object/Object.d.ts.map +1 -1
- package/dist/src/shapes/Object/Object.min.mjs +1 -1
- package/dist/src/shapes/Object/Object.min.mjs.map +1 -1
- package/dist/src/shapes/Object/Object.mjs +10 -14
- package/dist/src/shapes/Object/Object.mjs.map +1 -1
- package/dist/src/shapes/Object/ObjectGeometry.d.ts +1 -1
- package/dist/src/shapes/Object/ObjectGeometry.min.mjs.map +1 -1
- package/dist/src/shapes/Object/ObjectGeometry.mjs +1 -1
- package/dist/src/shapes/Object/ObjectGeometry.mjs.map +1 -1
- package/dist/src/shapes/Object/ObjectOrigin.min.mjs.map +1 -1
- package/dist/src/shapes/Object/ObjectOrigin.mjs.map +1 -1
- package/dist/src/shapes/Object/StackedObject.d.ts.map +1 -1
- package/dist/src/shapes/Object/StackedObject.min.mjs.map +1 -1
- package/dist/src/shapes/Object/StackedObject.mjs.map +1 -1
- package/dist/src/shapes/Path.min.mjs.map +1 -1
- package/dist/src/shapes/Path.mjs.map +1 -1
- package/dist/src/shapes/Polyline.d.ts.map +1 -1
- package/dist/src/shapes/Polyline.min.mjs +1 -1
- package/dist/src/shapes/Polyline.min.mjs.map +1 -1
- package/dist/src/shapes/Polyline.mjs +10 -2
- package/dist/src/shapes/Polyline.mjs.map +1 -1
- package/dist/src/shapes/Rect.min.mjs.map +1 -1
- package/dist/src/shapes/Rect.mjs.map +1 -1
- package/dist/src/shapes/Text/StyledText.min.mjs.map +1 -1
- package/dist/src/shapes/Text/StyledText.mjs.map +1 -1
- package/dist/src/shapes/Text/Text.min.mjs.map +1 -1
- package/dist/src/shapes/Text/Text.mjs +1 -1
- package/dist/src/shapes/Text/Text.mjs.map +1 -1
- package/dist/src/shapes/Text/TextSVGExportMixin.min.mjs.map +1 -1
- package/dist/src/shapes/Text/TextSVGExportMixin.mjs.map +1 -1
- package/dist/src/shapes/Textbox.min.mjs.map +1 -1
- package/dist/src/shapes/Textbox.mjs.map +1 -1
- package/dist/src/shapes/Triangle.min.mjs.map +1 -1
- package/dist/src/shapes/Triangle.mjs.map +1 -1
- package/dist/src/util/animation/AnimationBase.min.mjs.map +1 -1
- package/dist/src/util/animation/AnimationBase.mjs.map +1 -1
- package/dist/src/util/animation/AnimationRegistry.min.mjs.map +1 -1
- package/dist/src/util/animation/AnimationRegistry.mjs.map +1 -1
- package/dist/src/util/animation/ArrayAnimation.min.mjs.map +1 -1
- package/dist/src/util/animation/ArrayAnimation.mjs.map +1 -1
- package/dist/src/util/animation/ColorAnimation.min.mjs.map +1 -1
- package/dist/src/util/animation/ColorAnimation.mjs.map +1 -1
- package/dist/src/util/animation/ValueAnimation.min.mjs.map +1 -1
- package/dist/src/util/animation/ValueAnimation.mjs.map +1 -1
- package/dist/src/util/animation/animate.d.ts.map +1 -1
- package/dist/src/util/animation/animate.min.mjs.map +1 -1
- package/dist/src/util/animation/animate.mjs.map +1 -1
- package/dist/src/util/animation/easing.min.mjs.map +1 -1
- package/dist/src/util/animation/easing.mjs.map +1 -1
- package/dist/src/util/animation/types.d.ts.map +1 -1
- package/dist/src/util/applyMixins.min.mjs.map +1 -1
- package/dist/src/util/applyMixins.mjs.map +1 -1
- package/dist/src/util/dom_style.min.mjs.map +1 -1
- package/dist/src/util/dom_style.mjs.map +1 -1
- package/dist/src/util/internals/cloneDeep.d.ts +6 -0
- package/dist/src/util/internals/cloneDeep.d.ts.map +1 -1
- package/dist/src/util/internals/cloneStyles.d.ts +3 -0
- package/dist/src/util/internals/cloneStyles.d.ts.map +1 -0
- package/dist/src/util/internals/cloneStyles.min.mjs +2 -0
- package/dist/src/util/internals/cloneStyles.min.mjs.map +1 -0
- package/dist/src/util/internals/cloneStyles.mjs +15 -0
- package/dist/src/util/internals/cloneStyles.mjs.map +1 -0
- package/dist/src/util/internals/findRight.min.mjs.map +1 -1
- package/dist/src/util/internals/findRight.mjs.map +1 -1
- package/dist/src/util/misc/boundingBoxFromPoints.min.mjs.map +1 -1
- package/dist/src/util/misc/boundingBoxFromPoints.mjs.map +1 -1
- package/dist/src/util/misc/dom.min.mjs.map +1 -1
- package/dist/src/util/misc/dom.mjs.map +1 -1
- package/dist/src/util/misc/findScaleTo.min.mjs.map +1 -1
- package/dist/src/util/misc/findScaleTo.mjs.map +1 -1
- package/dist/src/util/misc/groupSVGElements.min.mjs.map +1 -1
- package/dist/src/util/misc/groupSVGElements.mjs.map +1 -1
- package/dist/src/util/misc/isTransparent.min.mjs.map +1 -1
- package/dist/src/util/misc/isTransparent.mjs.map +1 -1
- package/dist/src/util/misc/matrix.min.mjs.map +1 -1
- package/dist/src/util/misc/matrix.mjs.map +1 -1
- package/dist/src/util/misc/objectEnlive.min.mjs.map +1 -1
- package/dist/src/util/misc/objectEnlive.mjs.map +1 -1
- package/dist/src/util/misc/objectTransforms.min.mjs.map +1 -1
- package/dist/src/util/misc/objectTransforms.mjs.map +1 -1
- package/dist/src/util/misc/pick.min.mjs.map +1 -1
- package/dist/src/util/misc/pick.mjs.map +1 -1
- package/dist/src/util/misc/planeChange.min.mjs.map +1 -1
- package/dist/src/util/misc/planeChange.mjs.map +1 -1
- package/dist/src/util/misc/projectStroke/StrokeLineCapProjections.min.mjs.map +1 -1
- package/dist/src/util/misc/projectStroke/StrokeLineCapProjections.mjs.map +1 -1
- package/dist/src/util/misc/projectStroke/StrokeLineJoinProjections.min.mjs.map +1 -1
- package/dist/src/util/misc/projectStroke/StrokeLineJoinProjections.mjs.map +1 -1
- package/dist/src/util/misc/projectStroke/StrokeProjectionsBase.min.mjs.map +1 -1
- package/dist/src/util/misc/projectStroke/StrokeProjectionsBase.mjs.map +1 -1
- package/dist/src/util/misc/projectStroke/index.min.mjs.map +1 -1
- package/dist/src/util/misc/projectStroke/index.mjs.map +1 -1
- package/dist/src/util/misc/resolveOrigin.min.mjs.map +1 -1
- package/dist/src/util/misc/resolveOrigin.mjs.map +1 -1
- package/dist/src/util/misc/rotatePoint.min.mjs.map +1 -1
- package/dist/src/util/misc/rotatePoint.mjs.map +1 -1
- package/dist/src/util/misc/svgParsing.min.mjs.map +1 -1
- package/dist/src/util/misc/svgParsing.mjs.map +1 -1
- package/dist/src/util/misc/textStyles.min.mjs +1 -1
- package/dist/src/util/misc/textStyles.min.mjs.map +1 -1
- package/dist/src/util/misc/textStyles.mjs +3 -3
- package/dist/src/util/misc/textStyles.mjs.map +1 -1
- package/dist/src/util/misc/vectors.min.mjs.map +1 -1
- package/dist/src/util/misc/vectors.mjs.map +1 -1
- package/dist/src/util/path/index.min.mjs.map +1 -1
- package/dist/src/util/path/index.mjs.map +1 -1
- package/dist/src/util/path/typedefs.d.ts.map +1 -1
- package/dist/src/util/transform_matrix_removal.min.mjs.map +1 -1
- package/dist/src/util/transform_matrix_removal.mjs.map +1 -1
- package/dist/src/util/typeAssertions.min.mjs.map +1 -1
- package/dist/src/util/typeAssertions.mjs.map +1 -1
- package/dist-extensions/aligning_guidelines/constant.mjs +11 -0
- package/dist-extensions/aligning_guidelines/constant.mjs.map +1 -0
- package/dist-extensions/aligning_guidelines/index.mjs +130 -0
- package/dist-extensions/aligning_guidelines/index.mjs.map +1 -0
- package/dist-extensions/aligning_guidelines/util/basic.mjs +11 -0
- package/dist-extensions/aligning_guidelines/util/basic.mjs.map +1 -0
- package/dist-extensions/aligning_guidelines/util/collect-line.mjs +193 -0
- package/dist-extensions/aligning_guidelines/util/collect-line.mjs.map +1 -0
- package/dist-extensions/aligning_guidelines/util/collect-point.mjs +102 -0
- package/dist-extensions/aligning_guidelines/util/collect-point.mjs.map +1 -0
- package/dist-extensions/aligning_guidelines/util/draw.mjs +75 -0
- package/dist-extensions/aligning_guidelines/util/draw.mjs.map +1 -0
- package/dist-extensions/aligning_guidelines/util/get-objects-by-target.mjs +42 -0
- package/dist-extensions/aligning_guidelines/util/get-objects-by-target.mjs.map +1 -0
- package/dist-extensions/extensions/aligning_guidelines/constant.d.ts +3 -0
- package/dist-extensions/extensions/aligning_guidelines/constant.d.ts.map +1 -0
- package/dist-extensions/extensions/aligning_guidelines/index.d.ts +5 -0
- package/dist-extensions/extensions/aligning_guidelines/index.d.ts.map +1 -0
- package/dist-extensions/extensions/aligning_guidelines/typedefs.d.ts +33 -0
- package/dist-extensions/extensions/aligning_guidelines/typedefs.d.ts.map +1 -0
- package/dist-extensions/extensions/aligning_guidelines/util/basic.d.ts +4 -0
- package/dist-extensions/extensions/aligning_guidelines/util/basic.d.ts.map +1 -0
- package/dist-extensions/extensions/aligning_guidelines/util/collect-line.d.ts +13 -0
- package/dist-extensions/extensions/aligning_guidelines/util/collect-line.d.ts.map +1 -0
- package/dist-extensions/extensions/aligning_guidelines/util/collect-point.d.ts +20 -0
- package/dist-extensions/extensions/aligning_guidelines/util/collect-point.d.ts.map +1 -0
- package/dist-extensions/extensions/aligning_guidelines/util/draw.d.ts +6 -0
- package/dist-extensions/extensions/aligning_guidelines/util/draw.d.ts.map +1 -0
- package/dist-extensions/extensions/aligning_guidelines/util/get-objects-by-target.d.ts +3 -0
- package/dist-extensions/extensions/aligning_guidelines/util/get-objects-by-target.d.ts.map +1 -0
- package/dist-extensions/extensions/index.d.ts +2 -0
- package/dist-extensions/extensions/index.d.ts.map +1 -0
- package/dist-extensions/fabric-extensions.min.js +2 -0
- package/dist-extensions/fabric-extensions.min.js.map +1 -0
- package/dist-extensions/fabric.d.ts +119 -0
- package/dist-extensions/fabric.d.ts.map +1 -0
- package/dist-extensions/index.d.ts +2 -0
- package/dist-extensions/index.d.ts.map +1 -0
- package/dist-extensions/index.mjs +2 -0
- package/dist-extensions/index.mjs.map +1 -0
- package/dist-extensions/src/ClassRegistry.d.ts +14 -0
- package/dist-extensions/src/ClassRegistry.d.ts.map +1 -0
- package/dist-extensions/src/Collection.d.ts +141 -0
- package/dist-extensions/src/Collection.d.ts.map +1 -0
- package/dist-extensions/src/CommonMethods.d.ts +32 -0
- package/dist-extensions/src/CommonMethods.d.ts.map +1 -0
- package/dist-extensions/src/EventTypeDefs.d.ts +286 -0
- package/dist-extensions/src/EventTypeDefs.d.ts.map +1 -0
- package/dist-extensions/src/Intersection.d.ts +120 -0
- package/dist-extensions/src/Intersection.d.ts.map +1 -0
- package/dist-extensions/src/LayoutManager/ActiveSelectionLayoutManager.d.ts +22 -0
- package/dist-extensions/src/LayoutManager/ActiveSelectionLayoutManager.d.ts.map +1 -0
- package/dist-extensions/src/LayoutManager/LayoutManager.d.ts +56 -0
- package/dist-extensions/src/LayoutManager/LayoutManager.d.ts.map +1 -0
- package/dist-extensions/src/LayoutManager/LayoutStrategies/ClipPathLayout.d.ts +13 -0
- package/dist-extensions/src/LayoutManager/LayoutStrategies/ClipPathLayout.d.ts.map +1 -0
- package/dist-extensions/src/LayoutManager/LayoutStrategies/FitContentLayout.d.ts +14 -0
- package/dist-extensions/src/LayoutManager/LayoutStrategies/FitContentLayout.d.ts.map +1 -0
- package/dist-extensions/src/LayoutManager/LayoutStrategies/FixedLayout.d.ts +14 -0
- package/dist-extensions/src/LayoutManager/LayoutStrategies/FixedLayout.d.ts.map +1 -0
- package/dist-extensions/src/LayoutManager/LayoutStrategies/LayoutStrategy.d.ts +30 -0
- package/dist-extensions/src/LayoutManager/LayoutStrategies/LayoutStrategy.d.ts.map +1 -0
- package/dist-extensions/src/LayoutManager/LayoutStrategies/utils.d.ts +10 -0
- package/dist-extensions/src/LayoutManager/LayoutStrategies/utils.d.ts.map +1 -0
- package/dist-extensions/src/LayoutManager/constants.d.ts +7 -0
- package/dist-extensions/src/LayoutManager/constants.d.ts.map +1 -0
- package/dist-extensions/src/LayoutManager/index.d.ts +7 -0
- package/dist-extensions/src/LayoutManager/index.d.ts.map +1 -0
- package/dist-extensions/src/LayoutManager/types.d.ts +106 -0
- package/dist-extensions/src/LayoutManager/types.d.ts.map +1 -0
- package/dist-extensions/src/Observable.d.ts +68 -0
- package/dist-extensions/src/Observable.d.ts.map +1 -0
- package/dist-extensions/src/Pattern/Pattern.d.ts +99 -0
- package/dist-extensions/src/Pattern/Pattern.d.ts.map +1 -0
- package/dist-extensions/src/Pattern/index.d.ts +3 -0
- package/dist-extensions/src/Pattern/index.d.ts.map +1 -0
- package/dist-extensions/src/Pattern/types.d.ts +12 -0
- package/dist-extensions/src/Pattern/types.d.ts.map +1 -0
- package/dist-extensions/src/Point.d.ts +233 -0
- package/dist-extensions/src/Point.d.ts.map +1 -0
- package/dist-extensions/src/Shadow.d.ts +95 -0
- package/dist-extensions/src/Shadow.d.ts.map +1 -0
- package/dist-extensions/src/brushes/BaseBrush.d.ts +101 -0
- package/dist-extensions/src/brushes/BaseBrush.d.ts.map +1 -0
- package/dist-extensions/src/brushes/CircleBrush.d.ts +44 -0
- package/dist-extensions/src/brushes/CircleBrush.d.ts.map +1 -0
- package/dist-extensions/src/brushes/PatternBrush.d.ts +23 -0
- package/dist-extensions/src/brushes/PatternBrush.d.ts.map +1 -0
- package/dist-extensions/src/brushes/PencilBrush.d.ts +92 -0
- package/dist-extensions/src/brushes/PencilBrush.d.ts.map +1 -0
- package/dist-extensions/src/brushes/SprayBrush.d.ts +74 -0
- package/dist-extensions/src/brushes/SprayBrush.d.ts.map +1 -0
- package/dist-extensions/src/brushes/typedefs.d.ts +18 -0
- package/dist-extensions/src/brushes/typedefs.d.ts.map +1 -0
- package/dist-extensions/src/cache.d.ts +47 -0
- package/dist-extensions/src/cache.d.ts.map +1 -0
- package/dist-extensions/src/canvas/Canvas.d.ts +339 -0
- package/dist-extensions/src/canvas/Canvas.d.ts.map +1 -0
- package/dist-extensions/src/canvas/CanvasOptions.d.ts +229 -0
- package/dist-extensions/src/canvas/CanvasOptions.d.ts.map +1 -0
- package/dist-extensions/src/canvas/DOMManagers/CanvasDOMManager.d.ts +29 -0
- package/dist-extensions/src/canvas/DOMManagers/CanvasDOMManager.d.ts.map +1 -0
- package/dist-extensions/src/canvas/DOMManagers/StaticCanvasDOMManager.d.ts +29 -0
- package/dist-extensions/src/canvas/DOMManagers/StaticCanvasDOMManager.d.ts.map +1 -0
- package/dist-extensions/src/canvas/DOMManagers/util.d.ts +24 -0
- package/dist-extensions/src/canvas/DOMManagers/util.d.ts.map +1 -0
- package/dist-extensions/src/canvas/SelectableCanvas.d.ts +534 -0
- package/dist-extensions/src/canvas/SelectableCanvas.d.ts.map +1 -0
- package/dist-extensions/src/canvas/StaticCanvas.d.ts +639 -0
- package/dist-extensions/src/canvas/StaticCanvas.d.ts.map +1 -0
- package/dist-extensions/src/canvas/StaticCanvasOptions.d.ts +153 -0
- package/dist-extensions/src/canvas/StaticCanvasOptions.d.ts.map +1 -0
- package/dist-extensions/src/canvas/TextEditingManager.d.ts +21 -0
- package/dist-extensions/src/canvas/TextEditingManager.d.ts.map +1 -0
- package/dist-extensions/src/color/Color.d.ts +162 -0
- package/dist-extensions/src/color/Color.d.ts.map +1 -0
- package/dist-extensions/src/color/color_map.d.ts +155 -0
- package/dist-extensions/src/color/color_map.d.ts.map +1 -0
- package/dist-extensions/src/color/constants.d.ts +111 -0
- package/dist-extensions/src/color/constants.d.ts.map +1 -0
- package/dist-extensions/src/color/typedefs.d.ts +16 -0
- package/dist-extensions/src/color/typedefs.d.ts.map +1 -0
- package/dist-extensions/src/color/util.d.ts +27 -0
- package/dist-extensions/src/color/util.d.ts.map +1 -0
- package/dist-extensions/src/config.d.ts +115 -0
- package/dist-extensions/src/config.d.ts.map +1 -0
- package/dist-extensions/src/constants.d.ts +35 -0
- package/dist-extensions/src/constants.d.ts.map +1 -0
- package/dist-extensions/src/controls/Control.d.ts +229 -0
- package/dist-extensions/src/controls/Control.d.ts.map +1 -0
- package/dist-extensions/src/controls/changeWidth.d.ts +13 -0
- package/dist-extensions/src/controls/changeWidth.d.ts.map +1 -0
- package/dist-extensions/src/controls/commonControls.d.ts +28 -0
- package/dist-extensions/src/controls/commonControls.d.ts.map +1 -0
- package/dist-extensions/src/controls/controlRendering.d.ts +29 -0
- package/dist-extensions/src/controls/controlRendering.d.ts.map +1 -0
- package/dist-extensions/src/controls/drag.d.ts +12 -0
- package/dist-extensions/src/controls/drag.d.ts.map +1 -0
- package/dist-extensions/src/controls/fireEvent.d.ts +3 -0
- package/dist-extensions/src/controls/fireEvent.d.ts.map +1 -0
- package/dist-extensions/src/controls/index.d.ts +14 -0
- package/dist-extensions/src/controls/index.d.ts.map +1 -0
- package/dist-extensions/src/controls/pathControl.d.ts +12 -0
- package/dist-extensions/src/controls/pathControl.d.ts.map +1 -0
- package/dist-extensions/src/controls/polyControl.d.ts +30 -0
- package/dist-extensions/src/controls/polyControl.d.ts.map +1 -0
- package/dist-extensions/src/controls/rotate.d.ts +12 -0
- package/dist-extensions/src/controls/rotate.d.ts.map +1 -0
- package/dist-extensions/src/controls/scale.d.ts +47 -0
- package/dist-extensions/src/controls/scale.d.ts.map +1 -0
- package/dist-extensions/src/controls/scaleSkew.d.ts +39 -0
- package/dist-extensions/src/controls/scaleSkew.d.ts.map +1 -0
- package/dist-extensions/src/controls/skew.d.ts +33 -0
- package/dist-extensions/src/controls/skew.d.ts.map +1 -0
- package/dist-extensions/src/controls/util.d.ts +41 -0
- package/dist-extensions/src/controls/util.d.ts.map +1 -0
- package/dist-extensions/src/controls/wrapWithFireEvent.d.ts +10 -0
- package/dist-extensions/src/controls/wrapWithFireEvent.d.ts.map +1 -0
- package/dist-extensions/src/controls/wrapWithFixedAnchor.d.ts +9 -0
- package/dist-extensions/src/controls/wrapWithFixedAnchor.d.ts.map +1 -0
- package/dist-extensions/src/env/browser.d.ts +3 -0
- package/dist-extensions/src/env/browser.d.ts.map +1 -0
- package/dist-extensions/src/env/index.d.ts +34 -0
- package/dist-extensions/src/env/index.d.ts.map +1 -0
- package/dist-extensions/src/env/types.d.ts +16 -0
- package/dist-extensions/src/env/types.d.ts.map +1 -0
- package/dist-extensions/src/filters/BaseFilter.d.ts +153 -0
- package/dist-extensions/src/filters/BaseFilter.d.ts.map +1 -0
- package/dist-extensions/src/filters/BlendColor.d.ts +68 -0
- package/dist-extensions/src/filters/BlendColor.d.ts.map +1 -0
- package/dist-extensions/src/filters/BlendImage.d.ts +99 -0
- package/dist-extensions/src/filters/BlendImage.d.ts.map +1 -0
- package/dist-extensions/src/filters/Blur.d.ts +50 -0
- package/dist-extensions/src/filters/Blur.d.ts.map +1 -0
- package/dist-extensions/src/filters/Brightness.d.ts +46 -0
- package/dist-extensions/src/filters/Brightness.d.ts.map +1 -0
- package/dist-extensions/src/filters/Canvas2dFilterBackend.d.ts +27 -0
- package/dist-extensions/src/filters/Canvas2dFilterBackend.d.ts.map +1 -0
- package/dist-extensions/src/filters/ColorMatrix.d.ts +66 -0
- package/dist-extensions/src/filters/ColorMatrix.d.ts.map +1 -0
- package/dist-extensions/src/filters/ColorMatrixFilters.d.ts +15 -0
- package/dist-extensions/src/filters/ColorMatrixFilters.d.ts.map +1 -0
- package/dist-extensions/src/filters/Composed.d.ts +47 -0
- package/dist-extensions/src/filters/Composed.d.ts.map +1 -0
- package/dist-extensions/src/filters/Contrast.d.ts +44 -0
- package/dist-extensions/src/filters/Contrast.d.ts.map +1 -0
- package/dist-extensions/src/filters/Convolute.d.ts +81 -0
- package/dist-extensions/src/filters/Convolute.d.ts.map +1 -0
- package/dist-extensions/src/filters/FilterBackend.d.ts +15 -0
- package/dist-extensions/src/filters/FilterBackend.d.ts.map +1 -0
- package/dist-extensions/src/filters/GLProbes/GLProbe.d.ts +7 -0
- package/dist-extensions/src/filters/GLProbes/GLProbe.d.ts.map +1 -0
- package/dist-extensions/src/filters/GLProbes/WebGLProbe.d.ts +20 -0
- package/dist-extensions/src/filters/GLProbes/WebGLProbe.d.ts.map +1 -0
- package/dist-extensions/src/filters/Gamma.d.ts +58 -0
- package/dist-extensions/src/filters/Gamma.d.ts.map +1 -0
- package/dist-extensions/src/filters/Grayscale.d.ts +44 -0
- package/dist-extensions/src/filters/Grayscale.d.ts.map +1 -0
- package/dist-extensions/src/filters/HueRotation.d.ts +31 -0
- package/dist-extensions/src/filters/HueRotation.d.ts.map +1 -0
- package/dist-extensions/src/filters/Invert.d.ts +53 -0
- package/dist-extensions/src/filters/Invert.d.ts.map +1 -0
- package/dist-extensions/src/filters/Noise.d.ts +44 -0
- package/dist-extensions/src/filters/Noise.d.ts.map +1 -0
- package/dist-extensions/src/filters/Pixelate.d.ts +41 -0
- package/dist-extensions/src/filters/Pixelate.d.ts.map +1 -0
- package/dist-extensions/src/filters/RemoveColor.d.ts +53 -0
- package/dist-extensions/src/filters/RemoveColor.d.ts.map +1 -0
- package/dist-extensions/src/filters/Resize.d.ts +137 -0
- package/dist-extensions/src/filters/Resize.d.ts.map +1 -0
- package/dist-extensions/src/filters/Saturation.d.ts +46 -0
- package/dist-extensions/src/filters/Saturation.d.ts.map +1 -0
- package/dist-extensions/src/filters/Vibrance.d.ts +46 -0
- package/dist-extensions/src/filters/Vibrance.d.ts.map +1 -0
- package/dist-extensions/src/filters/WebGLFilterBackend.d.ts +131 -0
- package/dist-extensions/src/filters/WebGLFilterBackend.d.ts.map +1 -0
- package/dist-extensions/src/filters/filters.d.ts +23 -0
- package/dist-extensions/src/filters/filters.d.ts.map +1 -0
- package/dist-extensions/src/filters/index.d.ts +7 -0
- package/dist-extensions/src/filters/index.d.ts.map +1 -0
- package/dist-extensions/src/filters/shaders/baseFilter.d.ts +4 -0
- package/dist-extensions/src/filters/shaders/baseFilter.d.ts.map +1 -0
- package/dist-extensions/src/filters/shaders/blendColor.d.ts +13 -0
- package/dist-extensions/src/filters/shaders/blendColor.d.ts.map +1 -0
- package/dist-extensions/src/filters/shaders/blendImage.d.ts +4 -0
- package/dist-extensions/src/filters/shaders/blendImage.d.ts.map +1 -0
- package/dist-extensions/src/filters/shaders/blur.d.ts +2 -0
- package/dist-extensions/src/filters/shaders/blur.d.ts.map +1 -0
- package/dist-extensions/src/filters/shaders/brightness.d.ts +2 -0
- package/dist-extensions/src/filters/shaders/brightness.d.ts.map +1 -0
- package/dist-extensions/src/filters/shaders/colorMatrix.d.ts +2 -0
- package/dist-extensions/src/filters/shaders/colorMatrix.d.ts.map +1 -0
- package/dist-extensions/src/filters/shaders/constrast.d.ts +2 -0
- package/dist-extensions/src/filters/shaders/constrast.d.ts.map +1 -0
- package/dist-extensions/src/filters/shaders/convolute.d.ts +11 -0
- package/dist-extensions/src/filters/shaders/convolute.d.ts.map +1 -0
- package/dist-extensions/src/filters/shaders/gamma.d.ts +2 -0
- package/dist-extensions/src/filters/shaders/gamma.d.ts.map +1 -0
- package/dist-extensions/src/filters/shaders/grayscale.d.ts +3 -0
- package/dist-extensions/src/filters/shaders/grayscale.d.ts.map +1 -0
- package/dist-extensions/src/filters/shaders/invert.d.ts +2 -0
- package/dist-extensions/src/filters/shaders/invert.d.ts.map +1 -0
- package/dist-extensions/src/filters/shaders/noise.d.ts +2 -0
- package/dist-extensions/src/filters/shaders/noise.d.ts.map +1 -0
- package/dist-extensions/src/filters/shaders/pixelate.d.ts +2 -0
- package/dist-extensions/src/filters/shaders/pixelate.d.ts.map +1 -0
- package/dist-extensions/src/filters/shaders/removeColor.d.ts +2 -0
- package/dist-extensions/src/filters/shaders/removeColor.d.ts.map +1 -0
- package/dist-extensions/src/filters/shaders/saturation.d.ts +2 -0
- package/dist-extensions/src/filters/shaders/saturation.d.ts.map +1 -0
- package/dist-extensions/src/filters/shaders/vibrance.d.ts +2 -0
- package/dist-extensions/src/filters/shaders/vibrance.d.ts.map +1 -0
- package/dist-extensions/src/filters/typedefs.d.ts +70 -0
- package/dist-extensions/src/filters/typedefs.d.ts.map +1 -0
- package/dist-extensions/src/filters/utils.d.ts +10 -0
- package/dist-extensions/src/filters/utils.d.ts.map +1 -0
- package/dist-extensions/src/gradient/Gradient.d.ts +156 -0
- package/dist-extensions/src/gradient/Gradient.d.ts.map +1 -0
- package/dist-extensions/src/gradient/constants.d.ts +15 -0
- package/dist-extensions/src/gradient/constants.d.ts.map +1 -0
- package/dist-extensions/src/gradient/index.d.ts +3 -0
- package/dist-extensions/src/gradient/index.d.ts.map +1 -0
- package/dist-extensions/src/gradient/parser/misc.d.ts +4 -0
- package/dist-extensions/src/gradient/parser/misc.d.ts.map +1 -0
- package/dist-extensions/src/gradient/parser/parseColorStops.d.ts +3 -0
- package/dist-extensions/src/gradient/parser/parseColorStops.d.ts.map +1 -0
- package/dist-extensions/src/gradient/parser/parseCoords.d.ts +17 -0
- package/dist-extensions/src/gradient/parser/parseCoords.d.ts.map +1 -0
- package/dist-extensions/src/gradient/typedefs.d.ts +93 -0
- package/dist-extensions/src/gradient/typedefs.d.ts.map +1 -0
- package/dist-extensions/src/parser/applyViewboxTransform.d.ts +13 -0
- package/dist-extensions/src/parser/applyViewboxTransform.d.ts.map +1 -0
- package/dist-extensions/src/parser/attributes.d.ts +6 -0
- package/dist-extensions/src/parser/attributes.d.ts.map +1 -0
- package/dist-extensions/src/parser/constants.d.ts +41 -0
- package/dist-extensions/src/parser/constants.d.ts.map +1 -0
- package/dist-extensions/src/parser/doesSomeParentMatch.d.ts +2 -0
- package/dist-extensions/src/parser/doesSomeParentMatch.d.ts.map +1 -0
- package/dist-extensions/src/parser/elementMatchesRule.d.ts +5 -0
- package/dist-extensions/src/parser/elementMatchesRule.d.ts.map +1 -0
- package/dist-extensions/src/parser/elements_parser.d.ts +33 -0
- package/dist-extensions/src/parser/elements_parser.d.ts.map +1 -0
- package/dist-extensions/src/parser/getCSSRules.d.ts +8 -0
- package/dist-extensions/src/parser/getCSSRules.d.ts.map +1 -0
- package/dist-extensions/src/parser/getGlobalStylesForElement.d.ts +6 -0
- package/dist-extensions/src/parser/getGlobalStylesForElement.d.ts.map +1 -0
- package/dist-extensions/src/parser/getGradientDefs.d.ts +7 -0
- package/dist-extensions/src/parser/getGradientDefs.d.ts.map +1 -0
- package/dist-extensions/src/parser/getMultipleNodes.d.ts +2 -0
- package/dist-extensions/src/parser/getMultipleNodes.d.ts.map +1 -0
- package/dist-extensions/src/parser/getSvgRegex.d.ts +2 -0
- package/dist-extensions/src/parser/getSvgRegex.d.ts.map +1 -0
- package/dist-extensions/src/parser/getTagName.d.ts +2 -0
- package/dist-extensions/src/parser/getTagName.d.ts.map +1 -0
- package/dist-extensions/src/parser/hasInvalidAncestor.d.ts +2 -0
- package/dist-extensions/src/parser/hasInvalidAncestor.d.ts.map +1 -0
- package/dist-extensions/src/parser/loadSVGFromString.d.ts +18 -0
- package/dist-extensions/src/parser/loadSVGFromString.d.ts.map +1 -0
- package/dist-extensions/src/parser/loadSVGFromURL.d.ts +19 -0
- package/dist-extensions/src/parser/loadSVGFromURL.d.ts.map +1 -0
- package/dist-extensions/src/parser/normalizeAttr.d.ts +3 -0
- package/dist-extensions/src/parser/normalizeAttr.d.ts.map +1 -0
- package/dist-extensions/src/parser/normalizeValue.d.ts +2 -0
- package/dist-extensions/src/parser/normalizeValue.d.ts.map +1 -0
- package/dist-extensions/src/parser/parseAttributes.d.ts +10 -0
- package/dist-extensions/src/parser/parseAttributes.d.ts.map +1 -0
- package/dist-extensions/src/parser/parseFontDeclaration.d.ts +10 -0
- package/dist-extensions/src/parser/parseFontDeclaration.d.ts.map +1 -0
- package/dist-extensions/src/parser/parsePointsAttribute.d.ts +10 -0
- package/dist-extensions/src/parser/parsePointsAttribute.d.ts.map +1 -0
- package/dist-extensions/src/parser/parseSVGDocument.d.ts +22 -0
- package/dist-extensions/src/parser/parseSVGDocument.d.ts.map +1 -0
- package/dist-extensions/src/parser/parseStyleAttribute.d.ts +9 -0
- package/dist-extensions/src/parser/parseStyleAttribute.d.ts.map +1 -0
- package/dist-extensions/src/parser/parseStyleObject.d.ts +8 -0
- package/dist-extensions/src/parser/parseStyleObject.d.ts.map +1 -0
- package/dist-extensions/src/parser/parseStyleString.d.ts +8 -0
- package/dist-extensions/src/parser/parseStyleString.d.ts.map +1 -0
- package/dist-extensions/src/parser/parseTransformAttribute.d.ts +11 -0
- package/dist-extensions/src/parser/parseTransformAttribute.d.ts.map +1 -0
- package/dist-extensions/src/parser/parseUseDirectives.d.ts +2 -0
- package/dist-extensions/src/parser/parseUseDirectives.d.ts.map +1 -0
- package/dist-extensions/src/parser/percent.d.ts +9 -0
- package/dist-extensions/src/parser/percent.d.ts.map +1 -0
- package/dist-extensions/src/parser/recursivelyParseGradientsXlink.d.ts +2 -0
- package/dist-extensions/src/parser/recursivelyParseGradientsXlink.d.ts.map +1 -0
- package/dist-extensions/src/parser/selectorMatches.d.ts +2 -0
- package/dist-extensions/src/parser/selectorMatches.d.ts.map +1 -0
- package/dist-extensions/src/parser/setStrokeFillOpacity.d.ts +6 -0
- package/dist-extensions/src/parser/setStrokeFillOpacity.d.ts.map +1 -0
- package/dist-extensions/src/parser/typedefs.d.ts +10 -0
- package/dist-extensions/src/parser/typedefs.d.ts.map +1 -0
- package/dist-extensions/src/shapes/ActiveSelection.d.ts +109 -0
- package/dist-extensions/src/shapes/ActiveSelection.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Circle.d.ts +111 -0
- package/dist-extensions/src/shapes/Circle.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Ellipse.d.ts +88 -0
- package/dist-extensions/src/shapes/Ellipse.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Group.d.ts +303 -0
- package/dist-extensions/src/shapes/Group.d.ts.map +1 -0
- package/dist-extensions/src/shapes/IText/DraggableTextDelegate.d.ts +78 -0
- package/dist-extensions/src/shapes/IText/DraggableTextDelegate.d.ts.map +1 -0
- package/dist-extensions/src/shapes/IText/IText.d.ts +314 -0
- package/dist-extensions/src/shapes/IText/IText.d.ts.map +1 -0
- package/dist-extensions/src/shapes/IText/ITextBehavior.d.ts +299 -0
- package/dist-extensions/src/shapes/IText/ITextBehavior.d.ts.map +1 -0
- package/dist-extensions/src/shapes/IText/ITextClickBehavior.d.ts +81 -0
- package/dist-extensions/src/shapes/IText/ITextClickBehavior.d.ts.map +1 -0
- package/dist-extensions/src/shapes/IText/ITextKeyBehavior.d.ts +198 -0
- package/dist-extensions/src/shapes/IText/ITextKeyBehavior.d.ts.map +1 -0
- package/dist-extensions/src/shapes/IText/constants.d.ts +13 -0
- package/dist-extensions/src/shapes/IText/constants.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Image.d.ts +312 -0
- package/dist-extensions/src/shapes/Image.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Line.d.ts +122 -0
- package/dist-extensions/src/shapes/Line.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Object/AnimatableObject.d.ts +33 -0
- package/dist-extensions/src/shapes/Object/AnimatableObject.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Object/FabricObject.d.ts +11 -0
- package/dist-extensions/src/shapes/Object/FabricObject.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Object/FabricObjectSVGExportMixin.d.ts +72 -0
- package/dist-extensions/src/shapes/Object/FabricObjectSVGExportMixin.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Object/InteractiveObject.d.ts +317 -0
- package/dist-extensions/src/shapes/Object/InteractiveObject.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Object/Object.d.ts +614 -0
- package/dist-extensions/src/shapes/Object/Object.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Object/ObjectGeometry.d.ts +237 -0
- package/dist-extensions/src/shapes/Object/ObjectGeometry.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Object/ObjectOrigin.d.ts +96 -0
- package/dist-extensions/src/shapes/Object/ObjectOrigin.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Object/StackedObject.d.ts +60 -0
- package/dist-extensions/src/shapes/Object/StackedObject.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Object/defaultValues.d.ts +8 -0
- package/dist-extensions/src/shapes/Object/defaultValues.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Object/types/BaseProps.d.ts +88 -0
- package/dist-extensions/src/shapes/Object/types/BaseProps.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Object/types/BorderProps.d.ts +37 -0
- package/dist-extensions/src/shapes/Object/types/BorderProps.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Object/types/ControlProps.d.ts +63 -0
- package/dist-extensions/src/shapes/Object/types/ControlProps.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Object/types/FabricObjectProps.d.ts +66 -0
- package/dist-extensions/src/shapes/Object/types/FabricObjectProps.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Object/types/FillStrokeProps.d.ts +80 -0
- package/dist-extensions/src/shapes/Object/types/FillStrokeProps.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Object/types/LockInteractionProps.d.ts +51 -0
- package/dist-extensions/src/shapes/Object/types/LockInteractionProps.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Object/types/ObjectProps.d.ts +43 -0
- package/dist-extensions/src/shapes/Object/types/ObjectProps.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Object/types/ObjectTransformProps.d.ts +34 -0
- package/dist-extensions/src/shapes/Object/types/ObjectTransformProps.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Object/types/SerializedObjectProps.d.ts +66 -0
- package/dist-extensions/src/shapes/Object/types/SerializedObjectProps.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Object/types/index.d.ts +6 -0
- package/dist-extensions/src/shapes/Object/types/index.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Path.d.ts +215 -0
- package/dist-extensions/src/shapes/Path.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Polygon.d.ts +7 -0
- package/dist-extensions/src/shapes/Polygon.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Polyline.d.ts +156 -0
- package/dist-extensions/src/shapes/Polyline.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Rect.d.ts +83 -0
- package/dist-extensions/src/shapes/Rect.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Text/StyledText.d.ts +128 -0
- package/dist-extensions/src/shapes/Text/StyledText.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Text/Text.d.ts +697 -0
- package/dist-extensions/src/shapes/Text/Text.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Text/TextSVGExportMixin.d.ts +47 -0
- package/dist-extensions/src/shapes/Text/TextSVGExportMixin.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Text/constants.d.ts +13 -0
- package/dist-extensions/src/shapes/Text/constants.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Textbox.d.ts +226 -0
- package/dist-extensions/src/shapes/Textbox.d.ts.map +1 -0
- package/dist-extensions/src/shapes/Triangle.d.ts +27 -0
- package/dist-extensions/src/shapes/Triangle.d.ts.map +1 -0
- package/dist-extensions/src/typedefs.d.ts +97 -0
- package/dist-extensions/src/typedefs.d.ts.map +1 -0
- package/dist-extensions/src/util/animation/AnimationBase.d.ts +54 -0
- package/dist-extensions/src/util/animation/AnimationBase.d.ts.map +1 -0
- package/dist-extensions/src/util/animation/AnimationFrameProvider.d.ts +3 -0
- package/dist-extensions/src/util/animation/AnimationFrameProvider.d.ts.map +1 -0
- package/dist-extensions/src/util/animation/AnimationRegistry.d.ts +29 -0
- package/dist-extensions/src/util/animation/AnimationRegistry.d.ts.map +1 -0
- package/dist-extensions/src/util/animation/ArrayAnimation.d.ts +10 -0
- package/dist-extensions/src/util/animation/ArrayAnimation.d.ts.map +1 -0
- package/dist-extensions/src/util/animation/ColorAnimation.d.ts +11 -0
- package/dist-extensions/src/util/animation/ColorAnimation.d.ts.map +1 -0
- package/dist-extensions/src/util/animation/ValueAnimation.d.ts +10 -0
- package/dist-extensions/src/util/animation/ValueAnimation.d.ts.map +1 -0
- package/dist-extensions/src/util/animation/animate.d.ts +37 -0
- package/dist-extensions/src/util/animation/animate.d.ts.map +1 -0
- package/dist-extensions/src/util/animation/easing.d.ts +130 -0
- package/dist-extensions/src/util/animation/easing.d.ts.map +1 -0
- package/dist-extensions/src/util/animation/index.d.ts +3 -0
- package/dist-extensions/src/util/animation/index.d.ts.map +1 -0
- package/dist-extensions/src/util/animation/types.d.ts +87 -0
- package/dist-extensions/src/util/animation/types.d.ts.map +1 -0
- package/dist-extensions/src/util/applyMixins.d.ts +8 -0
- package/dist-extensions/src/util/applyMixins.d.ts.map +1 -0
- package/dist-extensions/src/util/dom_event.d.ts +6 -0
- package/dist-extensions/src/util/dom_event.d.ts.map +1 -0
- package/dist-extensions/src/util/dom_misc.d.ts +12 -0
- package/dist-extensions/src/util/dom_misc.d.ts.map +1 -0
- package/dist-extensions/src/util/dom_style.d.ts +7 -0
- package/dist-extensions/src/util/dom_style.d.ts.map +1 -0
- package/dist-extensions/src/util/index.d.ts +37 -0
- package/dist-extensions/src/util/index.d.ts.map +1 -0
- package/dist-extensions/src/util/internals/cleanupSvgAttribute.d.ts +2 -0
- package/dist-extensions/src/util/internals/cleanupSvgAttribute.d.ts.map +1 -0
- package/dist-extensions/src/util/internals/cloneStyles.d.ts +3 -0
- package/dist-extensions/src/util/internals/cloneStyles.d.ts.map +1 -0
- package/dist-extensions/src/util/internals/console.d.ts +8 -0
- package/dist-extensions/src/util/internals/console.d.ts.map +1 -0
- package/dist-extensions/src/util/internals/dom_request.d.ts +16 -0
- package/dist-extensions/src/util/internals/dom_request.d.ts.map +1 -0
- package/dist-extensions/src/util/internals/findRight.d.ts +2 -0
- package/dist-extensions/src/util/internals/findRight.d.ts.map +1 -0
- package/dist-extensions/src/util/internals/getRandomInt.d.ts +8 -0
- package/dist-extensions/src/util/internals/getRandomInt.d.ts.map +1 -0
- package/dist-extensions/src/util/internals/ifNaN.d.ts +8 -0
- package/dist-extensions/src/util/internals/ifNaN.d.ts.map +1 -0
- package/dist-extensions/src/util/internals/removeFromArray.d.ts +9 -0
- package/dist-extensions/src/util/internals/removeFromArray.d.ts.map +1 -0
- package/dist-extensions/src/util/internals/uid.d.ts +2 -0
- package/dist-extensions/src/util/internals/uid.d.ts.map +1 -0
- package/dist-extensions/src/util/lang_string.d.ts +22 -0
- package/dist-extensions/src/util/lang_string.d.ts.map +1 -0
- package/dist-extensions/src/util/misc/boundingBoxFromPoints.d.ts +9 -0
- package/dist-extensions/src/util/misc/boundingBoxFromPoints.d.ts.map +1 -0
- package/dist-extensions/src/util/misc/capValue.d.ts +2 -0
- package/dist-extensions/src/util/misc/capValue.d.ts.map +1 -0
- package/dist-extensions/src/util/misc/cos.d.ts +10 -0
- package/dist-extensions/src/util/misc/cos.d.ts.map +1 -0
- package/dist-extensions/src/util/misc/dom.d.ts +28 -0
- package/dist-extensions/src/util/misc/dom.d.ts.map +1 -0
- package/dist-extensions/src/util/misc/findScaleTo.d.ts +20 -0
- package/dist-extensions/src/util/misc/findScaleTo.d.ts.map +1 -0
- package/dist-extensions/src/util/misc/groupSVGElements.d.ts +11 -0
- package/dist-extensions/src/util/misc/groupSVGElements.d.ts.map +1 -0
- package/dist-extensions/src/util/misc/isTransparent.d.ts +11 -0
- package/dist-extensions/src/util/misc/isTransparent.d.ts.map +1 -0
- package/dist-extensions/src/util/misc/matrix.d.ts +170 -0
- package/dist-extensions/src/util/misc/matrix.d.ts.map +1 -0
- package/dist-extensions/src/util/misc/mergeClipPaths.d.ts +23 -0
- package/dist-extensions/src/util/misc/mergeClipPaths.d.ts.map +1 -0
- package/dist-extensions/src/util/misc/objectEnlive.d.ts +45 -0
- package/dist-extensions/src/util/misc/objectEnlive.d.ts.map +1 -0
- package/dist-extensions/src/util/misc/objectTransforms.d.ts +62 -0
- package/dist-extensions/src/util/misc/objectTransforms.d.ts.map +1 -0
- package/dist-extensions/src/util/misc/pick.d.ts +9 -0
- package/dist-extensions/src/util/misc/pick.d.ts.map +1 -0
- package/dist-extensions/src/util/misc/planeChange.d.ts +64 -0
- package/dist-extensions/src/util/misc/planeChange.d.ts.map +1 -0
- package/dist-extensions/src/util/misc/projectStroke/StrokeLineCapProjections.d.ts +52 -0
- package/dist-extensions/src/util/misc/projectStroke/StrokeLineCapProjections.d.ts.map +1 -0
- package/dist-extensions/src/util/misc/projectStroke/StrokeLineJoinProjections.d.ts +90 -0
- package/dist-extensions/src/util/misc/projectStroke/StrokeLineJoinProjections.d.ts.map +1 -0
- package/dist-extensions/src/util/misc/projectStroke/StrokeProjectionsBase.d.ts +27 -0
- package/dist-extensions/src/util/misc/projectStroke/StrokeProjectionsBase.d.ts.map +1 -0
- package/dist-extensions/src/util/misc/projectStroke/index.d.ts +12 -0
- package/dist-extensions/src/util/misc/projectStroke/index.d.ts.map +1 -0
- package/dist-extensions/src/util/misc/projectStroke/types.d.ts +23 -0
- package/dist-extensions/src/util/misc/projectStroke/types.d.ts.map +1 -0
- package/dist-extensions/src/util/misc/radiansDegreesConversion.d.ts +14 -0
- package/dist-extensions/src/util/misc/radiansDegreesConversion.d.ts.map +1 -0
- package/dist-extensions/src/util/misc/resolveOrigin.d.ts +9 -0
- package/dist-extensions/src/util/misc/resolveOrigin.d.ts.map +1 -0
- package/dist-extensions/src/util/misc/rotatePoint.d.ts +12 -0
- package/dist-extensions/src/util/misc/rotatePoint.d.ts.map +1 -0
- package/dist-extensions/src/util/misc/sin.d.ts +10 -0
- package/dist-extensions/src/util/misc/sin.d.ts.map +1 -0
- package/dist-extensions/src/util/misc/svgParsing.d.ts +46 -0
- package/dist-extensions/src/util/misc/svgParsing.d.ts.map +1 -0
- package/dist-extensions/src/util/misc/textStyles.d.ts +32 -0
- package/dist-extensions/src/util/misc/textStyles.d.ts.map +1 -0
- package/dist-extensions/src/util/misc/toFixed.d.ts +8 -0
- package/dist-extensions/src/util/misc/toFixed.d.ts.map +1 -0
- package/dist-extensions/src/util/misc/vectors.d.ts +72 -0
- package/dist-extensions/src/util/misc/vectors.d.ts.map +1 -0
- package/dist-extensions/src/util/path/index.d.ts +95 -0
- package/dist-extensions/src/util/path/index.d.ts.map +1 -0
- package/dist-extensions/src/util/path/regex.d.ts +2 -0
- package/dist-extensions/src/util/path/regex.d.ts.map +1 -0
- package/dist-extensions/src/util/path/typedefs.d.ts +221 -0
- package/dist-extensions/src/util/path/typedefs.d.ts.map +1 -0
- package/dist-extensions/src/util/transform_matrix_removal.d.ts +14 -0
- package/dist-extensions/src/util/transform_matrix_removal.d.ts.map +1 -0
- package/dist-extensions/src/util/typeAssertions.d.ts +13 -0
- package/dist-extensions/src/util/typeAssertions.d.ts.map +1 -0
- package/eslint.config.mjs +108 -0
- package/extensions/README.MD +27 -0
- package/extensions/aligning_guidelines/README.MD +22 -0
- package/extensions/aligning_guidelines/constant.ts +10 -0
- package/extensions/aligning_guidelines/index.ts +166 -0
- package/extensions/aligning_guidelines/typedefs.ts +36 -0
- package/extensions/aligning_guidelines/util/basic.spec.ts +31 -0
- package/extensions/aligning_guidelines/util/basic.ts +20 -0
- package/extensions/aligning_guidelines/util/collect-line.ts +172 -0
- package/extensions/aligning_guidelines/util/collect-point.ts +83 -0
- package/extensions/aligning_guidelines/util/draw.ts +74 -0
- package/extensions/aligning_guidelines/util/get-objects-by-target.ts +45 -0
- package/extensions/index.ts +4 -0
- package/jest.config.js +1 -1
- package/jest.extend.ts +14 -15
- package/package.json +17 -12
- package/playwright.setup.ts +5 -5
- package/rollup.config.mjs +46 -4
- package/scripts/build.mjs +1 -1
- package/scripts/buildLock.mjs +5 -5
- package/scripts/buildStats.mjs +2 -2
- package/scripts/git.mjs +1 -1
- package/scripts/index.mjs +34 -32
- package/scripts/sandbox.mjs +15 -15
- package/src/ClassRegistry.spec.ts +1 -1
- package/src/ClassRegistry.ts +1 -1
- package/src/Collection.ts +9 -9
- package/src/EventTypeDefs.ts +2 -2
- package/src/Intersection.spec.ts +2 -2
- package/src/Intersection.ts +11 -11
- package/src/LayoutManager/ActiveSelectionLayoutManager.spec.ts +3 -3
- package/src/LayoutManager/ActiveSelectionLayoutManager.ts +2 -2
- package/src/LayoutManager/LayoutManager.spec.ts +17 -17
- package/src/LayoutManager/LayoutManager.ts +15 -15
- package/src/LayoutManager/LayoutStrategies/ClipPathLayout.ts +3 -3
- package/src/LayoutManager/LayoutStrategies/FixedLayout.ts +1 -1
- package/src/LayoutManager/LayoutStrategies/LayoutStrategy.ts +4 -4
- package/src/LayoutManager/LayoutStrategies/utils.ts +4 -4
- package/src/LayoutManager/types.ts +12 -13
- package/src/Observable.ts +7 -7
- package/src/Pattern/Pattern.ts +20 -10
- package/src/Point.ts +3 -3
- package/src/Shadow.ts +7 -7
- package/src/brushes/CircleBrush.ts +1 -1
- package/src/brushes/PatternBrush.ts +1 -1
- package/src/brushes/PencilBrush.ts +1 -1
- package/src/brushes/SprayBrush.ts +3 -3
- package/src/canvas/Canvas.ts +38 -35
- package/src/canvas/DOMManagers/CanvasDOMManager.ts +2 -2
- package/src/canvas/DOMManagers/StaticCanvasDOMManager.ts +1 -1
- package/src/canvas/DOMManagers/util.ts +2 -2
- package/src/canvas/SelectableCanvas.spec.ts +8 -8
- package/src/canvas/SelectableCanvas.ts +20 -20
- package/src/canvas/StaticCanvas.ts +44 -43
- package/src/canvas/StaticCanvasOptions.ts +0 -1
- package/src/canvas/TextEditingManager.ts +1 -1
- package/src/canvas/__tests__/eventData.test.ts +17 -17
- package/src/color/Color.ts +3 -2
- package/src/color/color.test.ts +2 -2
- package/src/color/typedefs.ts +1 -1
- package/src/color/util.ts +1 -1
- package/src/config.ts +1 -1
- package/src/controls/Control.spec.ts +8 -8
- package/src/controls/Control.ts +14 -14
- package/src/controls/changeWidth.test.ts +2 -2
- package/src/controls/changeWidth.ts +4 -4
- package/src/controls/controlRendering.ts +4 -4
- package/src/controls/drag.ts +1 -1
- package/src/controls/fireEvent.ts +1 -1
- package/src/controls/pathControl.spec.ts +9 -9
- package/src/controls/pathControl.ts +20 -20
- package/src/controls/polyControl.spec.ts +6 -6
- package/src/controls/polyControl.ts +11 -11
- package/src/controls/rotate.ts +4 -4
- package/src/controls/scale.test.ts +9 -9
- package/src/controls/scale.ts +13 -13
- package/src/controls/scaleSkew.ts +3 -3
- package/src/controls/skew.ts +8 -8
- package/src/controls/util.ts +6 -6
- package/src/controls/wrapWithFireEvent.ts +2 -2
- package/src/controls/wrapWithFixedAnchor.spec.ts +5 -5
- package/src/controls/wrapWithFixedAnchor.ts +2 -2
- package/src/env/node.ts +2 -2
- package/src/filters/BaseFilter.ts +27 -25
- package/src/filters/BlendColor.ts +1 -1
- package/src/filters/BlendImage.ts +4 -4
- package/src/filters/Blur.ts +1 -1
- package/src/filters/Boilerplate.ts +1 -1
- package/src/filters/Brightness.ts +1 -1
- package/src/filters/Canvas2dFilterBackend.ts +1 -1
- package/src/filters/ColorMatrix.ts +2 -2
- package/src/filters/ColorMatrixFilters.ts +7 -7
- package/src/filters/Composed.ts +5 -5
- package/src/filters/Contrast.ts +1 -1
- package/src/filters/Convolute.ts +1 -1
- package/src/filters/GLProbes/WebGLProbe.ts +2 -2
- package/src/filters/Gamma.ts +1 -1
- package/src/filters/Grayscale.ts +1 -1
- package/src/filters/Invert.ts +1 -1
- package/src/filters/Noise.ts +1 -1
- package/src/filters/Pixelate.ts +1 -1
- package/src/filters/RemoveColor.ts +1 -1
- package/src/filters/Resize.ts +9 -9
- package/src/filters/Saturation.ts +1 -1
- package/src/filters/Vibrance.ts +1 -1
- package/src/filters/WebGLFilterBackend.ts +10 -10
- package/src/filters/typedefs.ts +1 -3
- package/src/filters/utils.ts +3 -3
- package/src/gradient/Gradient.spec.ts +19 -19
- package/src/gradient/Gradient.ts +51 -50
- package/src/gradient/parser/parseColorStops.ts +3 -3
- package/src/gradient/parser/parseCoords.ts +28 -25
- package/src/mixins/eraser_brush.mixin.ts +21 -21
- package/src/parkinglot/straighten.ts +1 -1
- package/src/parser/applyViewboxTransform.ts +2 -2
- package/src/parser/constants.ts +2 -2
- package/src/parser/elements_parser.ts +13 -13
- package/src/parser/getCSSRules.ts +1 -1
- package/src/parser/getGlobalStylesForElement.ts +1 -1
- package/src/parser/getGradientDefs.ts +1 -1
- package/src/parser/getMultipleNodes.ts +2 -2
- package/src/parser/loadSVGFromString.test.ts +1 -4
- package/src/parser/loadSVGFromString.ts +1 -1
- package/src/parser/loadSVGFromURL.ts +1 -1
- package/src/parser/normalizeAttr.ts +1 -1
- package/src/parser/normalizeValue.ts +2 -2
- package/src/parser/parseAttributes.ts +3 -3
- package/src/parser/parseFontDeclaration.ts +1 -1
- package/src/parser/parseSVGDocument.ts +3 -3
- package/src/parser/parseStyleObject.ts +1 -1
- package/src/parser/parseStyleString.ts +1 -1
- package/src/parser/parseTransformAttribute.ts +1 -1
- package/src/parser/parseUseDirectives.ts +1 -1
- package/src/parser/percent.ts +4 -4
- package/src/parser/recursivelyParseGradientsXlink.ts +1 -1
- package/src/parser/setStrokeFillOpacity.ts +1 -1
- package/src/parser/typedefs.ts +1 -1
- package/src/shapes/ActiveSelection.spec.ts +1 -1
- package/src/shapes/ActiveSelection.ts +4 -4
- package/src/shapes/Circle.ts +5 -5
- package/src/shapes/Ellipse.ts +4 -4
- package/src/shapes/Group.spec.ts +5 -5
- package/src/shapes/Group.ts +19 -17
- package/src/shapes/IText/DraggableTextDelegate.ts +9 -10
- package/src/shapes/IText/IText.test.ts +1 -1
- package/src/shapes/IText/IText.ts +12 -12
- package/src/shapes/IText/ITextBehavior.test.ts +2 -2
- package/src/shapes/IText/ITextBehavior.ts +21 -21
- package/src/shapes/IText/ITextClickBehavior.ts +2 -2
- package/src/shapes/IText/ITextKeyBehavior.test.ts +2 -2
- package/src/shapes/IText/ITextKeyBehavior.ts +13 -13
- package/src/shapes/Image.ts +16 -16
- package/src/shapes/Line.ts +4 -4
- package/src/shapes/Object/AnimatableObject.ts +13 -10
- package/src/shapes/Object/FabricObject.ts +7 -3
- package/src/shapes/Object/FabricObjectSVGExportMixin.ts +9 -9
- package/src/shapes/Object/InteractiveObject.spec.ts +3 -3
- package/src/shapes/Object/InteractiveObject.ts +32 -32
- package/src/shapes/Object/Object.ts +33 -31
- package/src/shapes/Object/ObjectGeometry.ts +9 -9
- package/src/shapes/Object/ObjectOrigin.ts +11 -11
- package/src/shapes/Object/StackedObject.ts +3 -4
- package/src/shapes/Path.ts +14 -14
- package/src/shapes/Polyline.spec.ts +1 -1
- package/src/shapes/Polyline.ts +15 -16
- package/src/shapes/Rect.ts +6 -6
- package/src/shapes/Text/StyledText.spec.ts +2 -2
- package/src/shapes/Text/StyledText.ts +7 -7
- package/src/shapes/Text/Text.spec.ts +1 -1
- package/src/shapes/Text/Text.ts +33 -33
- package/src/shapes/Text/TextSVGExportMixin.spec.ts +1 -1
- package/src/shapes/Text/TextSVGExportMixin.ts +23 -23
- package/src/shapes/Textbox.ts +7 -7
- package/src/shapes/Triangle.ts +1 -1
- package/src/typedefs.ts +3 -3
- package/src/util/animation/AnimationBase.ts +2 -2
- package/src/util/animation/AnimationRegistry.ts +1 -1
- package/src/util/animation/ArrayAnimation.ts +2 -2
- package/src/util/animation/ColorAnimation.ts +5 -5
- package/src/util/animation/ValueAnimation.ts +1 -1
- package/src/util/animation/animate.ts +6 -6
- package/src/util/animation/animations.spec.ts +7 -7
- package/src/util/animation/easing.ts +1 -1
- package/src/util/animation/types.ts +5 -6
- package/src/util/applyMixins.ts +2 -2
- package/src/util/dom_style.ts +2 -2
- package/src/util/internals/cloneDeep.ts +6 -0
- package/src/util/internals/cloneStyles.spec.ts +46 -0
- package/src/util/internals/cloneStyles.ts +12 -0
- package/src/util/internals/findRight.ts +1 -1
- package/src/util/internals/getRandomInt.test.ts +1 -1
- package/src/util/misc/boundingBoxFromPoints.ts +1 -1
- package/src/util/misc/dom.ts +3 -3
- package/src/util/misc/findScaleTo.ts +2 -2
- package/src/util/misc/groupSVGElements.ts +1 -1
- package/src/util/misc/isTransparent.ts +1 -1
- package/src/util/misc/matrix.ts +6 -6
- package/src/util/misc/objectEnlive.ts +9 -9
- package/src/util/misc/objectTransforms.ts +5 -5
- package/src/util/misc/pick.ts +2 -2
- package/src/util/misc/planeChange.spec.ts +9 -9
- package/src/util/misc/planeChange.ts +5 -5
- package/src/util/misc/projectStroke/StrokeLineCapProjections.ts +7 -7
- package/src/util/misc/projectStroke/StrokeLineJoinProjections.ts +16 -16
- package/src/util/misc/projectStroke/StrokeProjectionsBase.ts +2 -2
- package/src/util/misc/projectStroke/index.ts +7 -7
- package/src/util/misc/resolveOrigin.ts +1 -1
- package/src/util/misc/rotatePoint.ts +1 -1
- package/src/util/misc/svgParsing.ts +5 -5
- package/src/util/misc/textStyles.ts +6 -6
- package/src/util/misc/vectors.ts +1 -1
- package/src/util/path/index.spec.ts +3 -3
- package/src/util/path/index.ts +30 -30
- package/src/util/path/typechecks.ts +22 -22
- package/src/util/path/typedefs.ts +14 -17
- package/src/util/transform_matrix_removal.ts +3 -3
- package/src/util/typeAssertions.ts +4 -4
- package/tsconfig-extensions.json +108 -0
- package/tsconfig.json +4 -3
- package/.eslintignore +0 -3
- package/.eslintrc.js +0 -60
- package/.eslintrc.json +0 -143
- package/.eslintrc_tests +0 -58
- package/dist/src/util/internals/cloneDeep.min.mjs +0 -2
- package/dist/src/util/internals/cloneDeep.min.mjs.map +0 -1
- package/dist/src/util/internals/cloneDeep.mjs +0 -4
- package/dist/src/util/internals/cloneDeep.mjs.map +0 -1
- package/dist/src/util/internals/index.d.ts +0 -5
- package/dist/src/util/internals/index.d.ts.map +0 -1
- package/src/benchmarks/README.md +0 -7
- package/src/benchmarks/calcCornerCoords.mjs +0 -117
- package/src/benchmarks/calcTransformMatrix.mjs +0 -104
- package/src/benchmarks/pathCloning.mjs +0 -111
- package/src/benchmarks/pathData.mjs +0 -5
- package/src/benchmarks/raycasting.mjs +0 -152
- package/src/benchmarks/transformMatrixKey.mjs +0 -97
- package/src/util/internals/index.ts +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Color.min.mjs","sources":["../../../src/color/Color.ts"],"sourcesContent":["import { radiansToDegrees } from '../util/misc/radiansDegreesConversion';\nimport { ColorNameMap } from './color_map';\nimport { reHSLa, reHex, reRGBa } from './constants';\nimport type { TRGBAColorSource, TColorArg } from './typedefs';\nimport {\n hue2rgb,\n hexify,\n rgb2Hsl,\n fromAlphaToFloat,\n greyAverage,\n} from './util';\n\n/**\n * @class Color common color operations\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2/#colors colors}\n */\nexport class Color {\n private declare _source: TRGBAColorSource;\n isUnrecognised = false;\n\n /**\n *\n * @param {string} [color] optional in hex or rgb(a) or hsl format or from known color list\n */\n constructor(color?: TColorArg) {\n if (!color) {\n // we default to black as canvas does\n this.setSource([0, 0, 0, 1]);\n } else if (color instanceof Color) {\n this.setSource([...color._source]);\n } else if (Array.isArray(color)) {\n const [r, g, b, a = 1] = color;\n this.setSource([r, g, b, a]);\n } else {\n this.setSource(this._tryParsingColor(color));\n }\n }\n\n /**\n * @private\n * @param {string} [color] Color value to parse\n * @returns {TRGBAColorSource}\n */\n protected _tryParsingColor(color: string) {\n if (color in ColorNameMap) {\n color = ColorNameMap[color as keyof typeof ColorNameMap];\n }\n return color === 'transparent'\n ? ([255, 255, 255, 0] as TRGBAColorSource)\n : Color.sourceFromHex(color) ||\n Color.sourceFromRgb(color) ||\n Color.sourceFromHsl(color) ||\n // color is not recognized\n // we default to black as canvas does\n ((this.isUnrecognised = true) && ([0, 0, 0, 1] as TRGBAColorSource));\n }\n\n /**\n * Returns source of this color (where source is an array representation; ex: [200, 200, 100, 1])\n * @return {TRGBAColorSource}\n */\n getSource() {\n return this._source;\n }\n\n /**\n * Sets source of this color (where source is an array representation; ex: [200, 200, 100, 1])\n * @param {TRGBAColorSource} source\n */\n setSource(source: TRGBAColorSource) {\n this._source = source;\n }\n\n /**\n * Returns color representation in RGB format\n * @return {String} ex: rgb(0-255,0-255,0-255)\n */\n toRgb() {\n const [r, g, b] = this.getSource();\n return `rgb(${r},${g},${b})`;\n }\n\n /**\n * Returns color representation in RGBA format\n * @return {String} ex: rgba(0-255,0-255,0-255,0-1)\n */\n toRgba() {\n return `rgba(${this.getSource().join(',')})`;\n }\n\n /**\n * Returns color representation in HSL format\n * @return {String} ex: hsl(0-360,0%-100%,0%-100%)\n */\n toHsl() {\n const [h, s, l] = rgb2Hsl(...this.getSource());\n return `hsl(${h},${s}%,${l}%)`;\n }\n\n /**\n * Returns color representation in HSLA format\n * @return {String} ex: hsla(0-360,0%-100%,0%-100%,0-1)\n */\n toHsla() {\n const [h, s, l, a] = rgb2Hsl(...this.getSource());\n return `hsla(${h},${s}%,${l}%,${a})`;\n }\n\n /**\n * Returns color representation in HEX format\n * @return {String} ex: FF5555\n */\n toHex() {\n const fullHex = this.toHexa();\n return fullHex.slice(0, 6);\n }\n\n /**\n * Returns color representation in HEXA format\n * @return {String} ex: FF5555CC\n */\n toHexa() {\n const [r, g, b, a] = this.getSource();\n return `${hexify(r)}${hexify(g)}${hexify(b)}${hexify(Math.round(a * 255))}`;\n }\n\n /**\n * Gets value of alpha channel for this color\n * @return {Number} 0-1\n */\n getAlpha() {\n return this.getSource()[3];\n }\n\n /**\n * Sets value of alpha channel for this color\n * @param {Number} alpha Alpha value 0-1\n * @return {Color} thisArg\n */\n setAlpha(alpha: number) {\n this._source[3] = alpha;\n return this;\n }\n\n /**\n * Transforms color to its grayscale representation\n * @return {Color} thisArg\n */\n toGrayscale() {\n this.setSource(greyAverage(this.getSource()));\n return this;\n }\n\n /**\n * Transforms color to its black and white representation\n * @param {Number} threshold\n * @return {Color} thisArg\n */\n toBlackWhite(threshold: number) {\n const [average, , , a] = greyAverage(this.getSource()),\n bOrW = average < (threshold || 127) ? 0 : 255;\n this.setSource([bOrW, bOrW, bOrW, a]);\n return this;\n }\n\n /**\n * Overlays color with another color\n * @param {String|Color} otherColor\n * @return {Color} thisArg\n */\n overlayWith(otherColor: string | Color) {\n if (!(otherColor instanceof Color)) {\n otherColor = new Color(otherColor);\n }\n\n const source = this.getSource(),\n otherAlpha = 0.5,\n otherSource = otherColor.getSource(),\n [R, G, B] = source.map((value, index) =>\n Math.round(value * (1 - otherAlpha) + otherSource[index] * otherAlpha)\n );\n\n this.setSource([R, G, B, source[3]]);\n return this;\n }\n\n /**\n * Returns new color object, when given a color in RGB format\n * @memberOf Color\n * @param {String} color Color value ex: rgb(0-255,0-255,0-255)\n * @return {Color}\n */\n static fromRgb(color: string): Color {\n return Color.fromRgba(color);\n }\n\n /**\n * Returns new color object, when given a color in RGBA format\n * @static\n * @function\n * @memberOf Color\n * @param {String} color\n * @return {Color}\n */\n static fromRgba(color: string): Color {\n return new Color(Color.sourceFromRgb(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in RGB or RGBA format\n * @memberOf Color\n * @param {String} color Color value ex: rgb(0-255,0-255,0-255), rgb(0%-100%,0%-100%,0%-100%)\n * @return {TRGBAColorSource | undefined} source\n */\n static sourceFromRgb(color: string): TRGBAColorSource | undefined {\n const match = color.match(reRGBa());\n if (match) {\n const [r, g, b] = match.slice(1, 4).map((value) => {\n const parsedValue = parseFloat(value);\n return value.endsWith('%')\n ? Math.round(parsedValue * 2.55)\n : parsedValue;\n });\n return [r, g, b, fromAlphaToFloat(match[4])];\n }\n }\n\n /**\n * Returns new color object, when given a color in HSL format\n * @param {String} color Color value ex: hsl(0-260,0%-100%,0%-100%)\n * @memberOf Color\n * @return {Color}\n */\n static fromHsl(color: string): Color {\n return Color.fromHsla(color);\n }\n\n /**\n * Returns new color object, when given a color in HSLA format\n * @static\n * @function\n * @memberOf Color\n * @param {String} color\n * @return {Color}\n */\n static fromHsla(color: string): Color {\n return new Color(Color.sourceFromHsl(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in HSL or HSLA format.\n * Adapted from <a href=\"https://rawgithub.com/mjijackson/mjijackson.github.com/master/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript.html\">https://github.com/mjijackson</a>\n * @memberOf Color\n * @param {String} color Color value ex: hsl(0-360,0%-100%,0%-100%) or hsla(0-360,0%-100%,0%-100%, 0-1)\n * @return {TRGBAColorSource | undefined} source\n * @see http://http://www.w3.org/TR/css3-color/#hsl-color\n */\n static sourceFromHsl(color: string): TRGBAColorSource | undefined {\n const match = color.match(reHSLa());\n if (!match) {\n return;\n }\n const match1degrees = Color.parseAngletoDegrees(match[1]);\n\n const h = (((match1degrees % 360) + 360) % 360) / 360,\n s = parseFloat(match[2]) / 100,\n l = parseFloat(match[3]) / 100;\n let r: number, g: number, b: number;\n\n if (s === 0) {\n r = g = b = l;\n } else {\n const q = l <= 0.5 ? l * (s + 1) : l + s - l * s,\n p = l * 2 - q;\n\n r = hue2rgb(p, q, h + 1 / 3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1 / 3);\n }\n\n return [\n Math.round(r * 255),\n Math.round(g * 255),\n Math.round(b * 255),\n fromAlphaToFloat(match[4]),\n ];\n }\n\n /**\n * Returns new color object, when given a color in HEX format\n * @static\n * @memberOf Color\n * @param {String} color Color value ex: FF5555\n * @return {Color}\n */\n static fromHex(color: string): Color {\n return new Color(Color.sourceFromHex(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in HEX format\n * @static\n * @memberOf Color\n * @param {String} color ex: FF5555 or FF5544CC (RGBa)\n * @return {TRGBAColorSource | undefined} source\n */\n static sourceFromHex(color: string): TRGBAColorSource | undefined {\n if (color.match(reHex())) {\n const value = color.slice(color.indexOf('#') + 1),\n isShortNotation = value.length <= 4;\n let expandedValue: string[];\n if (isShortNotation) {\n expandedValue = value.split('').map((hex) => hex + hex);\n } else {\n expandedValue = value.match(/.{2}/g)!;\n }\n const [r, g, b, a = 255] = expandedValue.map((hexCouple) =>\n parseInt(hexCouple, 16)\n );\n return [r, g, b, a / 255];\n }\n }\n\n /**\n * Converts a string that could be any angle notation (50deg, 0.5turn, 2rad)\n * into degrees without the 'deg' suffix\n * @static\n * @memberOf Color\n * @param {String} value ex: 0deg, 0.5turn, 2rad\n * @return {Number} number in degrees or NaN if inputs are invalid\n */\n static parseAngletoDegrees(value: string): number {\n const lowercase = value.toLowerCase();\n const numeric = parseFloat(lowercase);\n\n if (lowercase.includes('rad')) {\n return radiansToDegrees(numeric);\n }\n\n if (lowercase.includes('turn')) {\n return numeric * 360;\n }\n\n // Value is probably just a number already in degrees eg '50'\n return numeric;\n }\n}\n"],"names":["Color","constructor","color","_defineProperty","this","setSource","_source","Array","isArray","r","g","b","a","_tryParsingColor","ColorNameMap","sourceFromHex","sourceFromRgb","sourceFromHsl","isUnrecognised","getSource","source","toRgb","concat","toRgba","join","toHsl","h","s","l","rgb2Hsl","toHsla","toHex","toHexa","slice","hexify","Math","round","getAlpha","setAlpha","alpha","toGrayscale","greyAverage","toBlackWhite","threshold","average","bOrW","overlayWith","otherColor","otherSource","R","G","B","map","value","index","fromRgb","fromRgba","match","reRGBa","parsedValue","parseFloat","endsWith","fromAlphaToFloat","fromHsl","fromHsla","reHSLa","parseAngletoDegrees","q","p","hue2rgb","fromHex","reHex","indexOf","expandedValue","length","split","hex","hexCouple","parseInt","lowercase","toLowerCase","numeric","includes","radiansToDegrees"],"mappings":"mYAgBO,MAAMA,EAQXC,WAAAA,CAAYC,GACV,GAD6BC,yBANd,GAOVD,EAGE,GAAIA,aAAiBF,EAC1BI,KAAKC,UAAU,IAAIH,EAAMI,eACpB,GAAIC,MAAMC,QAAQN,GAAQ,CAC/B,MAAOO,EAAGC,EAAGC,EAAGC,EAAI,GAAKV,EACzBE,KAAKC,UAAU,CAACI,EAAGC,EAAGC,EAAGC,GAC3B,MACER,KAAKC,UAAUD,KAAKS,iBAAiBX,SAPrCE,KAAKC,UAAU,CAAC,EAAG,EAA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,SAAS,QACJ,IAAVD,EAIFA,CACT"}
|
|
1
|
+
{"version":3,"file":"Color.min.mjs","sources":["../../../src/color/Color.ts"],"sourcesContent":["import { radiansToDegrees } from '../util/misc/radiansDegreesConversion';\nimport { ColorNameMap } from './color_map';\nimport { reHSLa, reHex, reRGBa } from './constants';\nimport type { TRGBAColorSource, TColorArg } from './typedefs';\nimport {\n hue2rgb,\n hexify,\n rgb2Hsl,\n fromAlphaToFloat,\n greyAverage,\n} from './util';\n\n/**\n * @class Color common color operations\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2/#colors colors}\n */\nexport class Color {\n private declare _source: TRGBAColorSource;\n isUnrecognised = false;\n\n /**\n *\n * @param {string} [color] optional in hex or rgb(a) or hsl format or from known color list\n */\n constructor(color?: TColorArg) {\n if (!color) {\n // we default to black as canvas does\n this.setSource([0, 0, 0, 1]);\n } else if (color instanceof Color) {\n this.setSource([...color._source]);\n } else if (Array.isArray(color)) {\n const [r, g, b, a = 1] = color;\n this.setSource([r, g, b, a]);\n } else {\n this.setSource(this._tryParsingColor(color));\n }\n }\n\n /**\n * @private\n * @param {string} [color] Color value to parse\n * @returns {TRGBAColorSource}\n */\n protected _tryParsingColor(color: string) {\n if (color in ColorNameMap) {\n color = ColorNameMap[color as keyof typeof ColorNameMap];\n }\n return color === 'transparent'\n ? ([255, 255, 255, 0] as TRGBAColorSource)\n : Color.sourceFromHex(color) ||\n Color.sourceFromRgb(color) ||\n Color.sourceFromHsl(color) ||\n // color is not recognized\n // we default to black as canvas does\n // eslint-disable-next-line no-constant-binary-expression\n ((this.isUnrecognised = true) && ([0, 0, 0, 1] as TRGBAColorSource));\n }\n\n /**\n * Returns source of this color (where source is an array representation; ex: [200, 200, 100, 1])\n * @return {TRGBAColorSource}\n */\n getSource() {\n return this._source;\n }\n\n /**\n * Sets source of this color (where source is an array representation; ex: [200, 200, 100, 1])\n * @param {TRGBAColorSource} source\n */\n setSource(source: TRGBAColorSource) {\n this._source = source;\n }\n\n /**\n * Returns color representation in RGB format\n * @return {String} ex: rgb(0-255,0-255,0-255)\n */\n toRgb() {\n const [r, g, b] = this.getSource();\n return `rgb(${r},${g},${b})`;\n }\n\n /**\n * Returns color representation in RGBA format\n * @return {String} ex: rgba(0-255,0-255,0-255,0-1)\n */\n toRgba() {\n return `rgba(${this.getSource().join(',')})`;\n }\n\n /**\n * Returns color representation in HSL format\n * @return {String} ex: hsl(0-360,0%-100%,0%-100%)\n */\n toHsl() {\n const [h, s, l] = rgb2Hsl(...this.getSource());\n return `hsl(${h},${s}%,${l}%)`;\n }\n\n /**\n * Returns color representation in HSLA format\n * @return {String} ex: hsla(0-360,0%-100%,0%-100%,0-1)\n */\n toHsla() {\n const [h, s, l, a] = rgb2Hsl(...this.getSource());\n return `hsla(${h},${s}%,${l}%,${a})`;\n }\n\n /**\n * Returns color representation in HEX format\n * @return {String} ex: FF5555\n */\n toHex() {\n const fullHex = this.toHexa();\n return fullHex.slice(0, 6);\n }\n\n /**\n * Returns color representation in HEXA format\n * @return {String} ex: FF5555CC\n */\n toHexa() {\n const [r, g, b, a] = this.getSource();\n return `${hexify(r)}${hexify(g)}${hexify(b)}${hexify(Math.round(a * 255))}`;\n }\n\n /**\n * Gets value of alpha channel for this color\n * @return {Number} 0-1\n */\n getAlpha() {\n return this.getSource()[3];\n }\n\n /**\n * Sets value of alpha channel for this color\n * @param {Number} alpha Alpha value 0-1\n * @return {Color} thisArg\n */\n setAlpha(alpha: number) {\n this._source[3] = alpha;\n return this;\n }\n\n /**\n * Transforms color to its grayscale representation\n * @return {Color} thisArg\n */\n toGrayscale() {\n this.setSource(greyAverage(this.getSource()));\n return this;\n }\n\n /**\n * Transforms color to its black and white representation\n * @param {Number} threshold\n * @return {Color} thisArg\n */\n toBlackWhite(threshold: number) {\n const [average, , , a] = greyAverage(this.getSource()),\n bOrW = average < (threshold || 127) ? 0 : 255;\n this.setSource([bOrW, bOrW, bOrW, a]);\n return this;\n }\n\n /**\n * Overlays color with another color\n * @param {String|Color} otherColor\n * @return {Color} thisArg\n */\n overlayWith(otherColor: string | Color) {\n if (!(otherColor instanceof Color)) {\n otherColor = new Color(otherColor);\n }\n\n const source = this.getSource(),\n otherAlpha = 0.5,\n otherSource = otherColor.getSource(),\n [R, G, B] = source.map((value, index) =>\n Math.round(value * (1 - otherAlpha) + otherSource[index] * otherAlpha),\n );\n\n this.setSource([R, G, B, source[3]]);\n return this;\n }\n\n /**\n * Returns new color object, when given a color in RGB format\n * @memberOf Color\n * @param {String} color Color value ex: rgb(0-255,0-255,0-255)\n * @return {Color}\n */\n static fromRgb(color: string): Color {\n return Color.fromRgba(color);\n }\n\n /**\n * Returns new color object, when given a color in RGBA format\n * @static\n * @function\n * @memberOf Color\n * @param {String} color\n * @return {Color}\n */\n static fromRgba(color: string): Color {\n return new Color(Color.sourceFromRgb(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in RGB or RGBA format\n * @memberOf Color\n * @param {String} color Color value ex: rgb(0-255,0-255,0-255), rgb(0%-100%,0%-100%,0%-100%)\n * @return {TRGBAColorSource | undefined} source\n */\n static sourceFromRgb(color: string): TRGBAColorSource | undefined {\n const match = color.match(reRGBa());\n if (match) {\n const [r, g, b] = match.slice(1, 4).map((value) => {\n const parsedValue = parseFloat(value);\n return value.endsWith('%')\n ? Math.round(parsedValue * 2.55)\n : parsedValue;\n });\n return [r, g, b, fromAlphaToFloat(match[4])];\n }\n }\n\n /**\n * Returns new color object, when given a color in HSL format\n * @param {String} color Color value ex: hsl(0-260,0%-100%,0%-100%)\n * @memberOf Color\n * @return {Color}\n */\n static fromHsl(color: string): Color {\n return Color.fromHsla(color);\n }\n\n /**\n * Returns new color object, when given a color in HSLA format\n * @static\n * @function\n * @memberOf Color\n * @param {String} color\n * @return {Color}\n */\n static fromHsla(color: string): Color {\n return new Color(Color.sourceFromHsl(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in HSL or HSLA format.\n * Adapted from <a href=\"https://rawgithub.com/mjijackson/mjijackson.github.com/master/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript.html\">https://github.com/mjijackson</a>\n * @memberOf Color\n * @param {String} color Color value ex: hsl(0-360,0%-100%,0%-100%) or hsla(0-360,0%-100%,0%-100%, 0-1)\n * @return {TRGBAColorSource | undefined} source\n * @see http://http://www.w3.org/TR/css3-color/#hsl-color\n */\n static sourceFromHsl(color: string): TRGBAColorSource | undefined {\n const match = color.match(reHSLa());\n if (!match) {\n return;\n }\n const match1degrees = Color.parseAngletoDegrees(match[1]);\n\n const h = (((match1degrees % 360) + 360) % 360) / 360,\n s = parseFloat(match[2]) / 100,\n l = parseFloat(match[3]) / 100;\n let r: number, g: number, b: number;\n\n if (s === 0) {\n r = g = b = l;\n } else {\n const q = l <= 0.5 ? l * (s + 1) : l + s - l * s,\n p = l * 2 - q;\n\n r = hue2rgb(p, q, h + 1 / 3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1 / 3);\n }\n\n return [\n Math.round(r * 255),\n Math.round(g * 255),\n Math.round(b * 255),\n fromAlphaToFloat(match[4]),\n ];\n }\n\n /**\n * Returns new color object, when given a color in HEX format\n * @static\n * @memberOf Color\n * @param {String} color Color value ex: FF5555\n * @return {Color}\n */\n static fromHex(color: string): Color {\n return new Color(Color.sourceFromHex(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in HEX format\n * @static\n * @memberOf Color\n * @param {String} color ex: FF5555 or FF5544CC (RGBa)\n * @return {TRGBAColorSource | undefined} source\n */\n static sourceFromHex(color: string): TRGBAColorSource | undefined {\n if (color.match(reHex())) {\n const value = color.slice(color.indexOf('#') + 1),\n isShortNotation = value.length <= 4;\n let expandedValue: string[];\n if (isShortNotation) {\n expandedValue = value.split('').map((hex) => hex + hex);\n } else {\n expandedValue = value.match(/.{2}/g)!;\n }\n const [r, g, b, a = 255] = expandedValue.map((hexCouple) =>\n parseInt(hexCouple, 16),\n );\n return [r, g, b, a / 255];\n }\n }\n\n /**\n * Converts a string that could be any angle notation (50deg, 0.5turn, 2rad)\n * into degrees without the 'deg' suffix\n * @static\n * @memberOf Color\n * @param {String} value ex: 0deg, 0.5turn, 2rad\n * @return {Number} number in degrees or NaN if inputs are invalid\n */\n static parseAngletoDegrees(value: string): number {\n const lowercase = value.toLowerCase();\n const numeric = parseFloat(lowercase);\n\n if (lowercase.includes('rad')) {\n return radiansToDegrees(numeric);\n }\n\n if (lowercase.includes('turn')) {\n return numeric * 360;\n }\n\n // Value is probably just a number already in degrees eg '50'\n return numeric;\n }\n}\n"],"names":["Color","constructor","color","_defineProperty","this","setSource","_source","Array","isArray","r","g","b","a","_tryParsingColor","ColorNameMap","sourceFromHex","sourceFromRgb","sourceFromHsl","isUnrecognised","getSource","source","toRgb","concat","toRgba","join","toHsl","h","s","l","rgb2Hsl","toHsla","toHex","toHexa","slice","hexify","Math","round","getAlpha","setAlpha","alpha","toGrayscale","greyAverage","toBlackWhite","threshold","average","bOrW","overlayWith","otherColor","otherSource","R","G","B","map","value","index","fromRgb","fromRgba","match","reRGBa","parsedValue","parseFloat","endsWith","fromAlphaToFloat","fromHsl","fromHsla","reHSLa","parseAngletoDegrees","q","p","hue2rgb","fromHex","reHex","indexOf","expandedValue","length","split","hex","hexCouple","parseInt","lowercase","toLowerCase","numeric","includes","radiansToDegrees"],"mappings":"mYAgBO,MAAMA,EAQXC,WAAAA,CAAYC,GACV,GAD6BC,yBANd,GAOVD,EAGE,GAAIA,aAAiBF,EAC1BI,KAAKC,UAAU,IAAIH,EAAMI,eACpB,GAAIC,MAAMC,QAAQN,GAAQ,CAC/B,MAAOO,EAAGC,EAAGC,EAAGC,EAAI,GAAKV,EACzBE,KAAKC,UAAU,CAACI,EAAGC,EAAGC,EAAGC,GAC3B,MACER,KAAKC,UAAUD,KAAKS,iBAAiBX,SAPrCE,KAAKC,UAAU,CAAC,EAAG,EAAG,EAAG,GAS7B,CAOUQ,gBAAAA,CAAiBX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dist/src/color/Color.mjs
CHANGED
|
@@ -40,6 +40,7 @@ class Color {
|
|
|
40
40
|
return color === 'transparent' ? [255, 255, 255, 0] : Color.sourceFromHex(color) || Color.sourceFromRgb(color) || Color.sourceFromHsl(color) ||
|
|
41
41
|
// color is not recognized
|
|
42
42
|
// we default to black as canvas does
|
|
43
|
+
// eslint-disable-next-line no-constant-binary-expression
|
|
43
44
|
(this.isUnrecognised = true) && [0, 0, 0, 1];
|
|
44
45
|
}
|
|
45
46
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Color.mjs","sources":["../../../src/color/Color.ts"],"sourcesContent":["import { radiansToDegrees } from '../util/misc/radiansDegreesConversion';\nimport { ColorNameMap } from './color_map';\nimport { reHSLa, reHex, reRGBa } from './constants';\nimport type { TRGBAColorSource, TColorArg } from './typedefs';\nimport {\n hue2rgb,\n hexify,\n rgb2Hsl,\n fromAlphaToFloat,\n greyAverage,\n} from './util';\n\n/**\n * @class Color common color operations\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2/#colors colors}\n */\nexport class Color {\n private declare _source: TRGBAColorSource;\n isUnrecognised = false;\n\n /**\n *\n * @param {string} [color] optional in hex or rgb(a) or hsl format or from known color list\n */\n constructor(color?: TColorArg) {\n if (!color) {\n // we default to black as canvas does\n this.setSource([0, 0, 0, 1]);\n } else if (color instanceof Color) {\n this.setSource([...color._source]);\n } else if (Array.isArray(color)) {\n const [r, g, b, a = 1] = color;\n this.setSource([r, g, b, a]);\n } else {\n this.setSource(this._tryParsingColor(color));\n }\n }\n\n /**\n * @private\n * @param {string} [color] Color value to parse\n * @returns {TRGBAColorSource}\n */\n protected _tryParsingColor(color: string) {\n if (color in ColorNameMap) {\n color = ColorNameMap[color as keyof typeof ColorNameMap];\n }\n return color === 'transparent'\n ? ([255, 255, 255, 0] as TRGBAColorSource)\n : Color.sourceFromHex(color) ||\n Color.sourceFromRgb(color) ||\n Color.sourceFromHsl(color) ||\n // color is not recognized\n // we default to black as canvas does\n ((this.isUnrecognised = true) && ([0, 0, 0, 1] as TRGBAColorSource));\n }\n\n /**\n * Returns source of this color (where source is an array representation; ex: [200, 200, 100, 1])\n * @return {TRGBAColorSource}\n */\n getSource() {\n return this._source;\n }\n\n /**\n * Sets source of this color (where source is an array representation; ex: [200, 200, 100, 1])\n * @param {TRGBAColorSource} source\n */\n setSource(source: TRGBAColorSource) {\n this._source = source;\n }\n\n /**\n * Returns color representation in RGB format\n * @return {String} ex: rgb(0-255,0-255,0-255)\n */\n toRgb() {\n const [r, g, b] = this.getSource();\n return `rgb(${r},${g},${b})`;\n }\n\n /**\n * Returns color representation in RGBA format\n * @return {String} ex: rgba(0-255,0-255,0-255,0-1)\n */\n toRgba() {\n return `rgba(${this.getSource().join(',')})`;\n }\n\n /**\n * Returns color representation in HSL format\n * @return {String} ex: hsl(0-360,0%-100%,0%-100%)\n */\n toHsl() {\n const [h, s, l] = rgb2Hsl(...this.getSource());\n return `hsl(${h},${s}%,${l}%)`;\n }\n\n /**\n * Returns color representation in HSLA format\n * @return {String} ex: hsla(0-360,0%-100%,0%-100%,0-1)\n */\n toHsla() {\n const [h, s, l, a] = rgb2Hsl(...this.getSource());\n return `hsla(${h},${s}%,${l}%,${a})`;\n }\n\n /**\n * Returns color representation in HEX format\n * @return {String} ex: FF5555\n */\n toHex() {\n const fullHex = this.toHexa();\n return fullHex.slice(0, 6);\n }\n\n /**\n * Returns color representation in HEXA format\n * @return {String} ex: FF5555CC\n */\n toHexa() {\n const [r, g, b, a] = this.getSource();\n return `${hexify(r)}${hexify(g)}${hexify(b)}${hexify(Math.round(a * 255))}`;\n }\n\n /**\n * Gets value of alpha channel for this color\n * @return {Number} 0-1\n */\n getAlpha() {\n return this.getSource()[3];\n }\n\n /**\n * Sets value of alpha channel for this color\n * @param {Number} alpha Alpha value 0-1\n * @return {Color} thisArg\n */\n setAlpha(alpha: number) {\n this._source[3] = alpha;\n return this;\n }\n\n /**\n * Transforms color to its grayscale representation\n * @return {Color} thisArg\n */\n toGrayscale() {\n this.setSource(greyAverage(this.getSource()));\n return this;\n }\n\n /**\n * Transforms color to its black and white representation\n * @param {Number} threshold\n * @return {Color} thisArg\n */\n toBlackWhite(threshold: number) {\n const [average, , , a] = greyAverage(this.getSource()),\n bOrW = average < (threshold || 127) ? 0 : 255;\n this.setSource([bOrW, bOrW, bOrW, a]);\n return this;\n }\n\n /**\n * Overlays color with another color\n * @param {String|Color} otherColor\n * @return {Color} thisArg\n */\n overlayWith(otherColor: string | Color) {\n if (!(otherColor instanceof Color)) {\n otherColor = new Color(otherColor);\n }\n\n const source = this.getSource(),\n otherAlpha = 0.5,\n otherSource = otherColor.getSource(),\n [R, G, B] = source.map((value, index) =>\n Math.round(value * (1 - otherAlpha) + otherSource[index] * otherAlpha)\n );\n\n this.setSource([R, G, B, source[3]]);\n return this;\n }\n\n /**\n * Returns new color object, when given a color in RGB format\n * @memberOf Color\n * @param {String} color Color value ex: rgb(0-255,0-255,0-255)\n * @return {Color}\n */\n static fromRgb(color: string): Color {\n return Color.fromRgba(color);\n }\n\n /**\n * Returns new color object, when given a color in RGBA format\n * @static\n * @function\n * @memberOf Color\n * @param {String} color\n * @return {Color}\n */\n static fromRgba(color: string): Color {\n return new Color(Color.sourceFromRgb(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in RGB or RGBA format\n * @memberOf Color\n * @param {String} color Color value ex: rgb(0-255,0-255,0-255), rgb(0%-100%,0%-100%,0%-100%)\n * @return {TRGBAColorSource | undefined} source\n */\n static sourceFromRgb(color: string): TRGBAColorSource | undefined {\n const match = color.match(reRGBa());\n if (match) {\n const [r, g, b] = match.slice(1, 4).map((value) => {\n const parsedValue = parseFloat(value);\n return value.endsWith('%')\n ? Math.round(parsedValue * 2.55)\n : parsedValue;\n });\n return [r, g, b, fromAlphaToFloat(match[4])];\n }\n }\n\n /**\n * Returns new color object, when given a color in HSL format\n * @param {String} color Color value ex: hsl(0-260,0%-100%,0%-100%)\n * @memberOf Color\n * @return {Color}\n */\n static fromHsl(color: string): Color {\n return Color.fromHsla(color);\n }\n\n /**\n * Returns new color object, when given a color in HSLA format\n * @static\n * @function\n * @memberOf Color\n * @param {String} color\n * @return {Color}\n */\n static fromHsla(color: string): Color {\n return new Color(Color.sourceFromHsl(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in HSL or HSLA format.\n * Adapted from <a href=\"https://rawgithub.com/mjijackson/mjijackson.github.com/master/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript.html\">https://github.com/mjijackson</a>\n * @memberOf Color\n * @param {String} color Color value ex: hsl(0-360,0%-100%,0%-100%) or hsla(0-360,0%-100%,0%-100%, 0-1)\n * @return {TRGBAColorSource | undefined} source\n * @see http://http://www.w3.org/TR/css3-color/#hsl-color\n */\n static sourceFromHsl(color: string): TRGBAColorSource | undefined {\n const match = color.match(reHSLa());\n if (!match) {\n return;\n }\n const match1degrees = Color.parseAngletoDegrees(match[1]);\n\n const h = (((match1degrees % 360) + 360) % 360) / 360,\n s = parseFloat(match[2]) / 100,\n l = parseFloat(match[3]) / 100;\n let r: number, g: number, b: number;\n\n if (s === 0) {\n r = g = b = l;\n } else {\n const q = l <= 0.5 ? l * (s + 1) : l + s - l * s,\n p = l * 2 - q;\n\n r = hue2rgb(p, q, h + 1 / 3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1 / 3);\n }\n\n return [\n Math.round(r * 255),\n Math.round(g * 255),\n Math.round(b * 255),\n fromAlphaToFloat(match[4]),\n ];\n }\n\n /**\n * Returns new color object, when given a color in HEX format\n * @static\n * @memberOf Color\n * @param {String} color Color value ex: FF5555\n * @return {Color}\n */\n static fromHex(color: string): Color {\n return new Color(Color.sourceFromHex(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in HEX format\n * @static\n * @memberOf Color\n * @param {String} color ex: FF5555 or FF5544CC (RGBa)\n * @return {TRGBAColorSource | undefined} source\n */\n static sourceFromHex(color: string): TRGBAColorSource | undefined {\n if (color.match(reHex())) {\n const value = color.slice(color.indexOf('#') + 1),\n isShortNotation = value.length <= 4;\n let expandedValue: string[];\n if (isShortNotation) {\n expandedValue = value.split('').map((hex) => hex + hex);\n } else {\n expandedValue = value.match(/.{2}/g)!;\n }\n const [r, g, b, a = 255] = expandedValue.map((hexCouple) =>\n parseInt(hexCouple, 16)\n );\n return [r, g, b, a / 255];\n }\n }\n\n /**\n * Converts a string that could be any angle notation (50deg, 0.5turn, 2rad)\n * into degrees without the 'deg' suffix\n * @static\n * @memberOf Color\n * @param {String} value ex: 0deg, 0.5turn, 2rad\n * @return {Number} number in degrees or NaN if inputs are invalid\n */\n static parseAngletoDegrees(value: string): number {\n const lowercase = value.toLowerCase();\n const numeric = parseFloat(lowercase);\n\n if (lowercase.includes('rad')) {\n return radiansToDegrees(numeric);\n }\n\n if (lowercase.includes('turn')) {\n return numeric * 360;\n }\n\n // Value is probably just a number already in degrees eg '50'\n return numeric;\n }\n}\n"],"names":["Color","constructor","color","_defineProperty","setSource","_source","Array","isArray","r","g","b","a","_tryParsingColor","ColorNameMap","sourceFromHex","sourceFromRgb","sourceFromHsl","isUnrecognised","getSource","source","toRgb","concat","toRgba","join","toHsl","h","s","l","rgb2Hsl","toHsla","toHex","fullHex","toHexa","slice","hexify","Math","round","getAlpha","setAlpha","alpha","toGrayscale","greyAverage","toBlackWhite","threshold","average","bOrW","overlayWith","otherColor","otherAlpha","otherSource","R","G","B","map","value","index","fromRgb","fromRgba","match","reRGBa","parsedValue","parseFloat","endsWith","fromAlphaToFloat","fromHsl","fromHsla","reHSLa","match1degrees","parseAngletoDegrees","q","p","hue2rgb","fromHex","reHex","indexOf","isShortNotation","length","expandedValue","split","hex","hexCouple","parseInt","lowercase","toLowerCase","numeric","includes","radiansToDegrees"],"mappings":";;;;;;AAYA;AACA;AACA;AACA;AACO,MAAMA,KAAK,CAAC;AAIjB;AACF;AACA;AACA;EACEC,WAAW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AM;AACLF,QAAAA,aAAa,GAAGvB,KAAK,CAACI,KAAK,CAAC,OAAO,CAAE,CAAA;AACvC,OAAA;MACA,MAAM,CAAClD,CAAC,EAAEC,CAAC,EAAEC,CAAC,EAAEC,CAAC,GAAG,GAAG,CAAC,GAAGkE,aAAa,CAACxB,GAAG,CAAE2B,SAAS,IACrDC,QAAQ,CAACD,SAAS,EAAE,EAAE,CACxB,CAAC,CAAA;MACD,OAAO,CAACxE,CAAC,EAAEC,CAAC,EAAEC,CAAC,EAAEC,CAAC,GAAG,GAAG,CAAC,CAAA;AAC3B,KAAA;AACF,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE,OAAOyD,mBAAmBA,CAACd,KAAa,EAAU;AAChD,IAAA,MAAM4B,SAAS,GAAG5B,KAAK,CAAC6B,WAAW,EAAE,CAAA;AACrC,IAAA,MAAMC,OAAO,GAAGvB,UAAU,CAACqB,SAAS,CAAC,CAAA;AAErC,IAAA,IAAIA,SAAS,CAACG,QAAQ,CAAC,KAAK,CAAC,EAAE;MAC7B,OAAOC,gBAAgB,CAACF,OAAO,CAAC,CAAA;AAClC,KAAA;AAEA,IAAA,IAAIF,SAAS,CAACG,QAAQ,CAAC,MAAM,CAAC,EAAE;MAC9B,OAAOD,OAAO,GAAG,GAAG,CAAA;AACtB,KAAA;;AAEA;AACA,IAAA,OAAOA,OAAO,CAAA;AAChB,GAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"Color.mjs","sources":["../../../src/color/Color.ts"],"sourcesContent":["import { radiansToDegrees } from '../util/misc/radiansDegreesConversion';\nimport { ColorNameMap } from './color_map';\nimport { reHSLa, reHex, reRGBa } from './constants';\nimport type { TRGBAColorSource, TColorArg } from './typedefs';\nimport {\n hue2rgb,\n hexify,\n rgb2Hsl,\n fromAlphaToFloat,\n greyAverage,\n} from './util';\n\n/**\n * @class Color common color operations\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2/#colors colors}\n */\nexport class Color {\n private declare _source: TRGBAColorSource;\n isUnrecognised = false;\n\n /**\n *\n * @param {string} [color] optional in hex or rgb(a) or hsl format or from known color list\n */\n constructor(color?: TColorArg) {\n if (!color) {\n // we default to black as canvas does\n this.setSource([0, 0, 0, 1]);\n } else if (color instanceof Color) {\n this.setSource([...color._source]);\n } else if (Array.isArray(color)) {\n const [r, g, b, a = 1] = color;\n this.setSource([r, g, b, a]);\n } else {\n this.setSource(this._tryParsingColor(color));\n }\n }\n\n /**\n * @private\n * @param {string} [color] Color value to parse\n * @returns {TRGBAColorSource}\n */\n protected _tryParsingColor(color: string) {\n if (color in ColorNameMap) {\n color = ColorNameMap[color as keyof typeof ColorNameMap];\n }\n return color === 'transparent'\n ? ([255, 255, 255, 0] as TRGBAColorSource)\n : Color.sourceFromHex(color) ||\n Color.sourceFromRgb(color) ||\n Color.sourceFromHsl(color) ||\n // color is not recognized\n // we default to black as canvas does\n // eslint-disable-next-line no-constant-binary-expression\n ((this.isUnrecognised = true) && ([0, 0, 0, 1] as TRGBAColorSource));\n }\n\n /**\n * Returns source of this color (where source is an array representation; ex: [200, 200, 100, 1])\n * @return {TRGBAColorSource}\n */\n getSource() {\n return this._source;\n }\n\n /**\n * Sets source of this color (where source is an array representation; ex: [200, 200, 100, 1])\n * @param {TRGBAColorSource} source\n */\n setSource(source: TRGBAColorSource) {\n this._source = source;\n }\n\n /**\n * Returns color representation in RGB format\n * @return {String} ex: rgb(0-255,0-255,0-255)\n */\n toRgb() {\n const [r, g, b] = this.getSource();\n return `rgb(${r},${g},${b})`;\n }\n\n /**\n * Returns color representation in RGBA format\n * @return {String} ex: rgba(0-255,0-255,0-255,0-1)\n */\n toRgba() {\n return `rgba(${this.getSource().join(',')})`;\n }\n\n /**\n * Returns color representation in HSL format\n * @return {String} ex: hsl(0-360,0%-100%,0%-100%)\n */\n toHsl() {\n const [h, s, l] = rgb2Hsl(...this.getSource());\n return `hsl(${h},${s}%,${l}%)`;\n }\n\n /**\n * Returns color representation in HSLA format\n * @return {String} ex: hsla(0-360,0%-100%,0%-100%,0-1)\n */\n toHsla() {\n const [h, s, l, a] = rgb2Hsl(...this.getSource());\n return `hsla(${h},${s}%,${l}%,${a})`;\n }\n\n /**\n * Returns color representation in HEX format\n * @return {String} ex: FF5555\n */\n toHex() {\n const fullHex = this.toHexa();\n return fullHex.slice(0, 6);\n }\n\n /**\n * Returns color representation in HEXA format\n * @return {String} ex: FF5555CC\n */\n toHexa() {\n const [r, g, b, a] = this.getSource();\n return `${hexify(r)}${hexify(g)}${hexify(b)}${hexify(Math.round(a * 255))}`;\n }\n\n /**\n * Gets value of alpha channel for this color\n * @return {Number} 0-1\n */\n getAlpha() {\n return this.getSource()[3];\n }\n\n /**\n * Sets value of alpha channel for this color\n * @param {Number} alpha Alpha value 0-1\n * @return {Color} thisArg\n */\n setAlpha(alpha: number) {\n this._source[3] = alpha;\n return this;\n }\n\n /**\n * Transforms color to its grayscale representation\n * @return {Color} thisArg\n */\n toGrayscale() {\n this.setSource(greyAverage(this.getSource()));\n return this;\n }\n\n /**\n * Transforms color to its black and white representation\n * @param {Number} threshold\n * @return {Color} thisArg\n */\n toBlackWhite(threshold: number) {\n const [average, , , a] = greyAverage(this.getSource()),\n bOrW = average < (threshold || 127) ? 0 : 255;\n this.setSource([bOrW, bOrW, bOrW, a]);\n return this;\n }\n\n /**\n * Overlays color with another color\n * @param {String|Color} otherColor\n * @return {Color} thisArg\n */\n overlayWith(otherColor: string | Color) {\n if (!(otherColor instanceof Color)) {\n otherColor = new Color(otherColor);\n }\n\n const source = this.getSource(),\n otherAlpha = 0.5,\n otherSource = otherColor.getSource(),\n [R, G, B] = source.map((value, index) =>\n Math.round(value * (1 - otherAlpha) + otherSource[index] * otherAlpha),\n );\n\n this.setSource([R, G, B, source[3]]);\n return this;\n }\n\n /**\n * Returns new color object, when given a color in RGB format\n * @memberOf Color\n * @param {String} color Color value ex: rgb(0-255,0-255,0-255)\n * @return {Color}\n */\n static fromRgb(color: string): Color {\n return Color.fromRgba(color);\n }\n\n /**\n * Returns new color object, when given a color in RGBA format\n * @static\n * @function\n * @memberOf Color\n * @param {String} color\n * @return {Color}\n */\n static fromRgba(color: string): Color {\n return new Color(Color.sourceFromRgb(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in RGB or RGBA format\n * @memberOf Color\n * @param {String} color Color value ex: rgb(0-255,0-255,0-255), rgb(0%-100%,0%-100%,0%-100%)\n * @return {TRGBAColorSource | undefined} source\n */\n static sourceFromRgb(color: string): TRGBAColorSource | undefined {\n const match = color.match(reRGBa());\n if (match) {\n const [r, g, b] = match.slice(1, 4).map((value) => {\n const parsedValue = parseFloat(value);\n return value.endsWith('%')\n ? Math.round(parsedValue * 2.55)\n : parsedValue;\n });\n return [r, g, b, fromAlphaToFloat(match[4])];\n }\n }\n\n /**\n * Returns new color object, when given a color in HSL format\n * @param {String} color Color value ex: hsl(0-260,0%-100%,0%-100%)\n * @memberOf Color\n * @return {Color}\n */\n static fromHsl(color: string): Color {\n return Color.fromHsla(color);\n }\n\n /**\n * Returns new color object, when given a color in HSLA format\n * @static\n * @function\n * @memberOf Color\n * @param {String} color\n * @return {Color}\n */\n static fromHsla(color: string): Color {\n return new Color(Color.sourceFromHsl(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in HSL or HSLA format.\n * Adapted from <a href=\"https://rawgithub.com/mjijackson/mjijackson.github.com/master/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript.html\">https://github.com/mjijackson</a>\n * @memberOf Color\n * @param {String} color Color value ex: hsl(0-360,0%-100%,0%-100%) or hsla(0-360,0%-100%,0%-100%, 0-1)\n * @return {TRGBAColorSource | undefined} source\n * @see http://http://www.w3.org/TR/css3-color/#hsl-color\n */\n static sourceFromHsl(color: string): TRGBAColorSource | undefined {\n const match = color.match(reHSLa());\n if (!match) {\n return;\n }\n const match1degrees = Color.parseAngletoDegrees(match[1]);\n\n const h = (((match1degrees % 360) + 360) % 360) / 360,\n s = parseFloat(match[2]) / 100,\n l = parseFloat(match[3]) / 100;\n let r: number, g: number, b: number;\n\n if (s === 0) {\n r = g = b = l;\n } else {\n const q = l <= 0.5 ? l * (s + 1) : l + s - l * s,\n p = l * 2 - q;\n\n r = hue2rgb(p, q, h + 1 / 3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1 / 3);\n }\n\n return [\n Math.round(r * 255),\n Math.round(g * 255),\n Math.round(b * 255),\n fromAlphaToFloat(match[4]),\n ];\n }\n\n /**\n * Returns new color object, when given a color in HEX format\n * @static\n * @memberOf Color\n * @param {String} color Color value ex: FF5555\n * @return {Color}\n */\n static fromHex(color: string): Color {\n return new Color(Color.sourceFromHex(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in HEX format\n * @static\n * @memberOf Color\n * @param {String} color ex: FF5555 or FF5544CC (RGBa)\n * @return {TRGBAColorSource | undefined} source\n */\n static sourceFromHex(color: string): TRGBAColorSource | undefined {\n if (color.match(reHex())) {\n const value = color.slice(color.indexOf('#') + 1),\n isShortNotation = value.length <= 4;\n let expandedValue: string[];\n if (isShortNotation) {\n expandedValue = value.split('').map((hex) => hex + hex);\n } else {\n expandedValue = value.match(/.{2}/g)!;\n }\n const [r, g, b, a = 255] = expandedValue.map((hexCouple) =>\n parseInt(hexCouple, 16),\n );\n return [r, g, b, a / 255];\n }\n }\n\n /**\n * Converts a string that could be any angle notation (50deg, 0.5turn, 2rad)\n * into degrees without the 'deg' suffix\n * @static\n * @memberOf Color\n * @param {String} value ex: 0deg, 0.5turn, 2rad\n * @return {Number} number in degrees or NaN if inputs are invalid\n */\n static parseAngletoDegrees(value: string): number {\n const lowercase = value.toLowerCase();\n const numeric = parseFloat(lowercase);\n\n if (lowercase.includes('rad')) {\n return radiansToDegrees(numeric);\n }\n\n if (lowercase.includes('turn')) {\n return numeric * 360;\n }\n\n // Value is probably just a number already in degrees eg '50'\n return numeric;\n }\n}\n"],"names":["Color","constructor","color","_defineProperty","setSource","_source","Array","isArray","r","g","b","a","_tryParsingColor","ColorNameMap","sourceFromHex","sourceFromRgb","sourceFromHsl","isUnrecognised","getSource","source","toRgb","concat","toRgba","join","toHsl","h","s","l","rgb2Hsl","toHsla","toHex","fullHex","toHexa","slice","hexify","Math","round","getAlpha","setAlpha","alpha","toGrayscale","greyAverage","toBlackWhite","threshold","average","bOrW","overlayWith","otherColor","otherAlpha","otherSource","R","G","B","map","value","index","fromRgb","fromRgba","match","reRGBa","parsedValue","parseFloat","endsWith","fromAlphaToFloat","fromHsl","fromHsla","reHSLa","match1degrees","parseAngletoDegrees","q","p","hue2rgb","fromHex","reHex","indexOf","isShortNotation","length","expandedValue","split","hex","hexCouple","parseInt","lowercase","toLowerCase","numeric","includes","radiansToDegrees"],"mappings":";;;;;;AAYA;AACA;AACA;AACA;AACO,MAAMA,KAAK,CAAC;AAIjB;AACF;AACA;AACA;EACEC,WAAWA,CAACC,KAAiB,EAAE;AAAAC,IAAAA,eAAA,yBANd,KAAK,CAAA,CAAA;IAOpB,IAAI,CAACD,KAAK,EAAE;AACV;AACA,MAAA,IAAI,CAACE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AAC9B,KAAC,MAAM,IAAIF,KAAK,YAAYF,KAAK,EAAE;MACjC,IAAI,CAACI,SAAS,CAAC,CAAC,GAAGF,KAAK,CAACG,OAAO,CAAC,CAAC,CAAA;KACnC,MAAM,IAAIC,KAAK,CAACC,OAAO,CAACL,KAAK,CAAC,EAAE;AAC/B,MAAA,MAAM,CAACM,CAAC,EAAEC,CAAC,EAAEC,CAAC,EAAEC,CAAC,GAAG,CAAC,CAAC,GAAGT,KAAK,CAAA;AAC9B,MAAA,IAAI,CAACE,SAAS,CAAC,CAACI,CAAC,EAAEC,CAAC,EAAEC,CAAC,EAAEC,CAAC,CAAC,CAAC,CAAA;AAC9B,KAAC,MAAM;MACL,IAAI,CAAC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K,CAAC,EAAE;MAC7B,OAAOC,gBAAgB,CAACF,OAAO,CAAC,CAAA;AAClC,KAAA;AAEA,IAAA,IAAIF,SAAS,CAACG,QAAQ,CAAC,MAAM,CAAC,EAAE;MAC9B,OAAOD,OAAO,GAAG,GAAG,CAAA;AACtB,KAAA;;AAEA;AACA,IAAA,OAAOA,OAAO,CAAA;AAChB,GAAA;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.min.mjs","sources":["../../../src/color/util.ts"],"sourcesContent":["import type { TRGBAColorSource } from './typedefs';\n\n/**\n * @param {Number} p\n * @param {Number} q\n * @param {Number} t\n * @return {Number}\n */\nexport const hue2rgb = (p: number, q: number, t: number): number => {\n if (t < 0) {\n t += 1;\n }\n if (t > 1) {\n t -= 1;\n }\n if (t < 1 / 6) {\n return p + (q - p) * 6 * t;\n }\n if (t < 1 / 2) {\n return q;\n }\n if (t < 2 / 3) {\n return p + (q - p) * (2 / 3 - t) * 6;\n }\n return p;\n};\n\n/**\n * Adapted from {@link https://gist.github.com/mjackson/5311256 https://gist.github.com/mjackson}\n * @param {Number} r Red color value\n * @param {Number} g Green color value\n * @param {Number} b Blue color value\n * @param {Number} a Alpha color value pass through\n * @return {TRGBColorSource} Hsl color\n */\nexport const rgb2Hsl = (\n r: number,\n g: number,\n b: number,\n a: number
|
|
1
|
+
{"version":3,"file":"util.min.mjs","sources":["../../../src/color/util.ts"],"sourcesContent":["import type { TRGBAColorSource } from './typedefs';\n\n/**\n * @param {Number} p\n * @param {Number} q\n * @param {Number} t\n * @return {Number}\n */\nexport const hue2rgb = (p: number, q: number, t: number): number => {\n if (t < 0) {\n t += 1;\n }\n if (t > 1) {\n t -= 1;\n }\n if (t < 1 / 6) {\n return p + (q - p) * 6 * t;\n }\n if (t < 1 / 2) {\n return q;\n }\n if (t < 2 / 3) {\n return p + (q - p) * (2 / 3 - t) * 6;\n }\n return p;\n};\n\n/**\n * Adapted from {@link https://gist.github.com/mjackson/5311256 https://gist.github.com/mjackson}\n * @param {Number} r Red color value\n * @param {Number} g Green color value\n * @param {Number} b Blue color value\n * @param {Number} a Alpha color value pass through\n * @return {TRGBColorSource} Hsl color\n */\nexport const rgb2Hsl = (\n r: number,\n g: number,\n b: number,\n a: number,\n): TRGBAColorSource => {\n r /= 255;\n g /= 255;\n b /= 255;\n const maxValue = Math.max(r, g, b),\n minValue = Math.min(r, g, b);\n\n let h!: number, s: number;\n const l = (maxValue + minValue) / 2;\n\n if (maxValue === minValue) {\n h = s = 0; // achromatic\n } else {\n const d = maxValue - minValue;\n s = l > 0.5 ? d / (2 - maxValue - minValue) : d / (maxValue + minValue);\n switch (maxValue) {\n case r:\n h = (g - b) / d + (g < b ? 6 : 0);\n break;\n case g:\n h = (b - r) / d + 2;\n break;\n case b:\n h = (r - g) / d + 4;\n break;\n }\n h /= 6;\n }\n\n return [Math.round(h * 360), Math.round(s * 100), Math.round(l * 100), a];\n};\n\nexport const fromAlphaToFloat = (value = '1') =>\n parseFloat(value) / (value.endsWith('%') ? 100 : 1);\n\n/**\n * Convert a value in the inclusive range [0, 255] to hex\n */\nexport const hexify = (value: number) =>\n Math.min(Math.round(value), 255).toString(16).toUpperCase().padStart(2, '0');\n\n/**\n * Calculate the grey average value for rgb and pass through alpha\n */\nexport const greyAverage = ([\n r,\n g,\n b,\n a = 1,\n]: TRGBAColorSource): TRGBAColorSource => {\n const avg = Math.round(r * 0.3 + g * 0.59 + b * 0.11);\n return [avg, avg, avg, a];\n};\n"],"names":["hue2rgb","p","q","t","rgb2Hsl","r","g","b","a","maxValue","Math","max","minValue","min","h","s","l","d","round","fromAlphaToFloat","value","arguments","length","undefined","parseFloat","endsWith","hexify","toString","toUpperCase","padStart","greyAverage","_ref","avg"],"mappings":"AAQO,MAAMA,EAAUA,CAACC,EAAWC,EAAWC,KACxCA,EAAI,IACNA,GAAK,GAEHA,EAAI,IACNA,GAAK,GAEHA,EAAI,EAAI,EACHF,EAAc,GAATC,EAAID,GAASE,EA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
-
{"version":3,"file":"util.mjs","sources":["../../../src/color/util.ts"],"sourcesContent":["import type { TRGBAColorSource } from './typedefs';\n\n/**\n * @param {Number} p\n * @param {Number} q\n * @param {Number} t\n * @return {Number}\n */\nexport const hue2rgb = (p: number, q: number, t: number): number => {\n if (t < 0) {\n t += 1;\n }\n if (t > 1) {\n t -= 1;\n }\n if (t < 1 / 6) {\n return p + (q - p) * 6 * t;\n }\n if (t < 1 / 2) {\n return q;\n }\n if (t < 2 / 3) {\n return p + (q - p) * (2 / 3 - t) * 6;\n }\n return p;\n};\n\n/**\n * Adapted from {@link https://gist.github.com/mjackson/5311256 https://gist.github.com/mjackson}\n * @param {Number} r Red color value\n * @param {Number} g Green color value\n * @param {Number} b Blue color value\n * @param {Number} a Alpha color value pass through\n * @return {TRGBColorSource} Hsl color\n */\nexport const rgb2Hsl = (\n r: number,\n g: number,\n b: number,\n a: number
|
|
1
|
+
{"version":3,"file":"util.mjs","sources":["../../../src/color/util.ts"],"sourcesContent":["import type { TRGBAColorSource } from './typedefs';\n\n/**\n * @param {Number} p\n * @param {Number} q\n * @param {Number} t\n * @return {Number}\n */\nexport const hue2rgb = (p: number, q: number, t: number): number => {\n if (t < 0) {\n t += 1;\n }\n if (t > 1) {\n t -= 1;\n }\n if (t < 1 / 6) {\n return p + (q - p) * 6 * t;\n }\n if (t < 1 / 2) {\n return q;\n }\n if (t < 2 / 3) {\n return p + (q - p) * (2 / 3 - t) * 6;\n }\n return p;\n};\n\n/**\n * Adapted from {@link https://gist.github.com/mjackson/5311256 https://gist.github.com/mjackson}\n * @param {Number} r Red color value\n * @param {Number} g Green color value\n * @param {Number} b Blue color value\n * @param {Number} a Alpha color value pass through\n * @return {TRGBColorSource} Hsl color\n */\nexport const rgb2Hsl = (\n r: number,\n g: number,\n b: number,\n a: number,\n): TRGBAColorSource => {\n r /= 255;\n g /= 255;\n b /= 255;\n const maxValue = Math.max(r, g, b),\n minValue = Math.min(r, g, b);\n\n let h!: number, s: number;\n const l = (maxValue + minValue) / 2;\n\n if (maxValue === minValue) {\n h = s = 0; // achromatic\n } else {\n const d = maxValue - minValue;\n s = l > 0.5 ? d / (2 - maxValue - minValue) : d / (maxValue + minValue);\n switch (maxValue) {\n case r:\n h = (g - b) / d + (g < b ? 6 : 0);\n break;\n case g:\n h = (b - r) / d + 2;\n break;\n case b:\n h = (r - g) / d + 4;\n break;\n }\n h /= 6;\n }\n\n return [Math.round(h * 360), Math.round(s * 100), Math.round(l * 100), a];\n};\n\nexport const fromAlphaToFloat = (value = '1') =>\n parseFloat(value) / (value.endsWith('%') ? 100 : 1);\n\n/**\n * Convert a value in the inclusive range [0, 255] to hex\n */\nexport const hexify = (value: number) =>\n Math.min(Math.round(value), 255).toString(16).toUpperCase().padStart(2, '0');\n\n/**\n * Calculate the grey average value for rgb and pass through alpha\n */\nexport const greyAverage = ([\n r,\n g,\n b,\n a = 1,\n]: TRGBAColorSource): TRGBAColorSource => {\n const avg = Math.round(r * 0.3 + g * 0.59 + b * 0.11);\n return [avg, avg, avg, a];\n};\n"],"names":["hue2rgb","p","q","t","rgb2Hsl","r","g","b","a","maxValue","Math","max","minValue","min","h","s","l","d","round","fromAlphaToFloat","value","arguments","length","undefined","parseFloat","endsWith","hexify","toString","toUpperCase","padStart","greyAverage","_ref","avg"],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,OAAO,GAAGA,CAACC,CAAS,EAAEC,CAAS,EAAEC,CAAS,KAAa;EAClE,IAAIA,CAAC,GAAG,CAAC,EAAE;AACTA,IAAAA,CAAC,IAAI,CAAC,CAAA;AACR,GAAA;EACA,IAAIA,CAAC,GAAG,CAAC,EAAE;AACTA,IAAAA,CAAC,IAAI,CAAC,CAAA;AACR,GAAA;AACA,EAAA,IAAIA,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;IACb,OAAOF,CAAC,GAAG,CAACC,CAAC,GAAGD,CAAC,IAAI,CAAC,GAAGE,CAAC,CAAA;AAC5B,GAAA;AACA,EAA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ACaC,MAAAA,WAAW,GAAGC,IAAA,IAKe;AAAA,EAAA,IALd,CAC1B1B,CAAC,EACDC,CAAC,EACDC,CAAC,EACDC,CAAC,GAAG,CAAC,CACY,GAAAuB,IAAA,CAAA;AACjB,EAAA,MAAMC,GAAG,GAAGtB,IAAI,CAACQ,KAAK,CAACb,CAAC,GAAG,GAAG,GAAGC,CAAC,GAAG,IAAI,GAAGC,CAAC,GAAG,IAAI,CAAC,CAAA;EACrD,OAAO,CAACyB,GAAG,EAAEA,GAAG,EAAEA,GAAG,EAAExB,CAAC,CAAC,CAAA;AAC3B;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.min.mjs","sources":["../../src/config.ts"],"sourcesContent":["export type TConfiguration = Partial<BaseConfiguration>;\n\nclass BaseConfiguration {\n /**\n * Browser-specific constant to adjust CanvasRenderingContext2D.shadowBlur value,\n * which is unitless and not rendered equally across browsers.\n *\n * Values that work quite well (as of October 2017) are:\n * - Chrome: 1.5\n * - Edge: 1.75\n * - Firefox: 0.9\n * - Safari: 0.95\n *\n * @since 2.0.0\n * @type Number\n * @default 1\n */\n browserShadowBlurConstant = 1;\n\n /**\n * Pixel per Inch as a default value set to 96. Can be changed for more realistic conversion.\n */\n DPI = 96;\n\n /**\n * Device Pixel Ratio\n * @see https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/SettingUptheCanvas/SettingUptheCanvas.html\n */\n devicePixelRatio =\n typeof window !== 'undefined' ? window.devicePixelRatio : 1; // eslint-disable-line no-restricted-globals\n\n /**\n * Pixel limit for cache canvases. 1Mpx , 4Mpx should be fine.\n * @since 1.7.14\n * @type Number\n * @default\n */\n perfLimitSizeTotal = 2097152;\n\n /**\n * Pixel limit for cache canvases width or height. IE fixes the maximum at 5000\n * @since 1.7.14\n * @type Number\n * @default\n */\n maxCacheSideLimit = 4096;\n\n /**\n * Lowest pixel limit for cache canvases, set at 256PX\n * @since 1.7.14\n * @type Number\n * @default\n */\n minCacheSideLimit = 256;\n\n /**\n * When 'true', style information is not retained when copy/pasting text, making\n * pasted text use destination style.\n * Defaults to 'false'.\n * @type Boolean\n * @default\n * @deprecated\n */\n disableStyleCopyPaste = false;\n\n /**\n * Enable webgl for filtering picture is available\n * A filtering backend will be initialized, this will both take memory and\n * time since a default 2048x2048 canvas will be created for the gl context\n * @since 2.0.0\n * @type Boolean\n * @default\n */\n enableGLFiltering = true;\n\n /**\n * if webgl is enabled and available, textureSize will determine the size\n * of the canvas backend\n *\n * In order to support old hardware set to `2048` to avoid OOM\n *\n * @since 2.0.0\n * @type Number\n * @default\n */\n textureSize = 4096;\n\n /**\n * Skip performance testing of setupGLContext and force the use of putImageData that seems to be the one that works best on\n * Chrome + old hardware. if your users are experiencing empty images after filtering you may try to force this to true\n * this has to be set before instantiating the filtering backend ( before filtering the first image )\n * @type Boolean\n * @default false\n */\n forceGLPutImageData = false;\n\n /**\n * If disabled boundsOfCurveCache is not used. For apps that make heavy usage of pencil drawing probably disabling it is better\n * @default true\n */\n cachesBoundsOfCurve = true;\n\n /**\n * Map of font files\n * Map<fontFamily, pathToFile> of font files\n */\n fontPaths: Record</** fontFamily */ string, /** pathToFile */ string> = {};\n\n /**\n * Defines the number of fraction digits to use when serializing object values.\n * Used in exporting methods (`toObject`, `toJSON`, `toSVG`)\n * You can use it to increase/decrease precision of such values like left, top, scaleX, scaleY, etc.\n */\n NUM_FRACTION_DIGITS = 4;\n}\n\nexport class Configuration extends BaseConfiguration {\n constructor(config?: TConfiguration) {\n super();\n this.configure(config);\n }\n\n configure(config: TConfiguration = {}) {\n Object.assign(this, config);\n }\n\n /**\n * Map<fontFamily, pathToFile> of font files\n */\n addFonts(\n paths: Record</** fontFamily */ string, /** pathToFile */ string> = {}
|
|
1
|
+
{"version":3,"file":"config.min.mjs","sources":["../../src/config.ts"],"sourcesContent":["export type TConfiguration = Partial<BaseConfiguration>;\n\nclass BaseConfiguration {\n /**\n * Browser-specific constant to adjust CanvasRenderingContext2D.shadowBlur value,\n * which is unitless and not rendered equally across browsers.\n *\n * Values that work quite well (as of October 2017) are:\n * - Chrome: 1.5\n * - Edge: 1.75\n * - Firefox: 0.9\n * - Safari: 0.95\n *\n * @since 2.0.0\n * @type Number\n * @default 1\n */\n browserShadowBlurConstant = 1;\n\n /**\n * Pixel per Inch as a default value set to 96. Can be changed for more realistic conversion.\n */\n DPI = 96;\n\n /**\n * Device Pixel Ratio\n * @see https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/SettingUptheCanvas/SettingUptheCanvas.html\n */\n devicePixelRatio =\n typeof window !== 'undefined' ? window.devicePixelRatio : 1; // eslint-disable-line no-restricted-globals\n\n /**\n * Pixel limit for cache canvases. 1Mpx , 4Mpx should be fine.\n * @since 1.7.14\n * @type Number\n * @default\n */\n perfLimitSizeTotal = 2097152;\n\n /**\n * Pixel limit for cache canvases width or height. IE fixes the maximum at 5000\n * @since 1.7.14\n * @type Number\n * @default\n */\n maxCacheSideLimit = 4096;\n\n /**\n * Lowest pixel limit for cache canvases, set at 256PX\n * @since 1.7.14\n * @type Number\n * @default\n */\n minCacheSideLimit = 256;\n\n /**\n * When 'true', style information is not retained when copy/pasting text, making\n * pasted text use destination style.\n * Defaults to 'false'.\n * @type Boolean\n * @default\n * @deprecated\n */\n disableStyleCopyPaste = false;\n\n /**\n * Enable webgl for filtering picture is available\n * A filtering backend will be initialized, this will both take memory and\n * time since a default 2048x2048 canvas will be created for the gl context\n * @since 2.0.0\n * @type Boolean\n * @default\n */\n enableGLFiltering = true;\n\n /**\n * if webgl is enabled and available, textureSize will determine the size\n * of the canvas backend\n *\n * In order to support old hardware set to `2048` to avoid OOM\n *\n * @since 2.0.0\n * @type Number\n * @default\n */\n textureSize = 4096;\n\n /**\n * Skip performance testing of setupGLContext and force the use of putImageData that seems to be the one that works best on\n * Chrome + old hardware. if your users are experiencing empty images after filtering you may try to force this to true\n * this has to be set before instantiating the filtering backend ( before filtering the first image )\n * @type Boolean\n * @default false\n */\n forceGLPutImageData = false;\n\n /**\n * If disabled boundsOfCurveCache is not used. For apps that make heavy usage of pencil drawing probably disabling it is better\n * @default true\n */\n cachesBoundsOfCurve = true;\n\n /**\n * Map of font files\n * Map<fontFamily, pathToFile> of font files\n */\n fontPaths: Record</** fontFamily */ string, /** pathToFile */ string> = {};\n\n /**\n * Defines the number of fraction digits to use when serializing object values.\n * Used in exporting methods (`toObject`, `toJSON`, `toSVG`)\n * You can use it to increase/decrease precision of such values like left, top, scaleX, scaleY, etc.\n */\n NUM_FRACTION_DIGITS = 4;\n}\n\nexport class Configuration extends BaseConfiguration {\n constructor(config?: TConfiguration) {\n super();\n this.configure(config);\n }\n\n configure(config: TConfiguration = {}) {\n Object.assign(this, config);\n }\n\n /**\n * Map<fontFamily, pathToFile> of font files\n */\n addFonts(\n paths: Record</** fontFamily */ string, /** pathToFile */ string> = {},\n ) {\n this.fontPaths = {\n ...this.fontPaths,\n ...paths,\n };\n }\n\n removeFonts(fontFamilys: string[] = []) {\n fontFamilys.forEach((fontFamily) => {\n delete this.fontPaths[fontFamily];\n });\n }\n\n clearFonts() {\n this.fontPaths = {};\n }\n\n restoreDefaults<T extends BaseConfiguration>(keys?: (keyof T)[]) {\n const defaults = new BaseConfiguration() as T;\n const config =\n keys?.reduce((acc, key) => {\n acc[key] = defaults[key];\n return acc;\n }, {} as T) || defaults;\n this.configure(config);\n }\n}\n\nexport const config = new Configuration();\n"],"names":["BaseConfiguration","constructor","_defineProperty","this","window","devicePixelRatio","Configuration","config","super","configure","arguments","length","undefined","Object","assign","addFonts","paths","fontPaths","_objectSpread","removeFonts","forEach","fontFamily","clearFonts","restoreDefaults","keys","defaults","reduce","acc","key"],"mappings":"kGAEA,MAAMA,EAAkBC,WAAAA,GACtBC,mCAc4B,GAE5BA,aAGM,IAENA,EAAAC,KAAA,mBAKoB,oBAAXC,OAAyBA,OAAOC,iBAAmB,GAE5DH,4BAMqB,SAErBA,2BAMoB,MAEpBA,2BAMoB,KAEpBA,gCAQwB,GAExBA,4BAQoB,GAEpBA,qBAUc,MAEdA,8BAOsB,GAEtBA,8BAIsB,GAEtBA,EAAAC,KAAA,YAIwE,CAAA,GAExED,6BAKsB,EAAC,EAGlB,MAAMI,UAAsBN,EACjCC,WAAAA,CAAYM,GACVC,QACAL,KAAKM,UAAUF,EACjB,CAEAE,SAAAA,GAAuC,IAA7BF,EAAsBG,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,CAAA,EACjCG,OAAOC,OAAOX,KAAMI,EACtB,CAKAQ,QAAAA,GAEE,IADAC,EAAiEN,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,CAAA,EAEpEP,KAAKc,UAASC,EAAAA,EACT,CAAA,EAAAf,KAAKc,WACLD,EAEP,CAEAG,WAAAA,IAAiCT,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,IACtBU,SAASC,WACZlB,KAAKc,UAAUI,EAAW,GAErC,CAEAC,UAAAA,GACEnB,KAAKc,UAAY,EACnB,CAEAM,eAAAA,CAA6CC,GAC3C,MAAMC,EAAW,IAAIzB,EACfO,GACJiB,aAAI,EAAJA,EAAME,QAAO,CAACC,EAAKC,KACjBD,EAAIC,GAAOH,EAASG,GACbD,IACN,CAAA,KAAYF,EACjBtB,KAAKM,UAAUF,EACjB,QAGWA,EAAS,IAAID"}
|
package/dist/src/config.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.mjs","sources":["../../src/config.ts"],"sourcesContent":["export type TConfiguration = Partial<BaseConfiguration>;\n\nclass BaseConfiguration {\n /**\n * Browser-specific constant to adjust CanvasRenderingContext2D.shadowBlur value,\n * which is unitless and not rendered equally across browsers.\n *\n * Values that work quite well (as of October 2017) are:\n * - Chrome: 1.5\n * - Edge: 1.75\n * - Firefox: 0.9\n * - Safari: 0.95\n *\n * @since 2.0.0\n * @type Number\n * @default 1\n */\n browserShadowBlurConstant = 1;\n\n /**\n * Pixel per Inch as a default value set to 96. Can be changed for more realistic conversion.\n */\n DPI = 96;\n\n /**\n * Device Pixel Ratio\n * @see https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/SettingUptheCanvas/SettingUptheCanvas.html\n */\n devicePixelRatio =\n typeof window !== 'undefined' ? window.devicePixelRatio : 1; // eslint-disable-line no-restricted-globals\n\n /**\n * Pixel limit for cache canvases. 1Mpx , 4Mpx should be fine.\n * @since 1.7.14\n * @type Number\n * @default\n */\n perfLimitSizeTotal = 2097152;\n\n /**\n * Pixel limit for cache canvases width or height. IE fixes the maximum at 5000\n * @since 1.7.14\n * @type Number\n * @default\n */\n maxCacheSideLimit = 4096;\n\n /**\n * Lowest pixel limit for cache canvases, set at 256PX\n * @since 1.7.14\n * @type Number\n * @default\n */\n minCacheSideLimit = 256;\n\n /**\n * When 'true', style information is not retained when copy/pasting text, making\n * pasted text use destination style.\n * Defaults to 'false'.\n * @type Boolean\n * @default\n * @deprecated\n */\n disableStyleCopyPaste = false;\n\n /**\n * Enable webgl for filtering picture is available\n * A filtering backend will be initialized, this will both take memory and\n * time since a default 2048x2048 canvas will be created for the gl context\n * @since 2.0.0\n * @type Boolean\n * @default\n */\n enableGLFiltering = true;\n\n /**\n * if webgl is enabled and available, textureSize will determine the size\n * of the canvas backend\n *\n * In order to support old hardware set to `2048` to avoid OOM\n *\n * @since 2.0.0\n * @type Number\n * @default\n */\n textureSize = 4096;\n\n /**\n * Skip performance testing of setupGLContext and force the use of putImageData that seems to be the one that works best on\n * Chrome + old hardware. if your users are experiencing empty images after filtering you may try to force this to true\n * this has to be set before instantiating the filtering backend ( before filtering the first image )\n * @type Boolean\n * @default false\n */\n forceGLPutImageData = false;\n\n /**\n * If disabled boundsOfCurveCache is not used. For apps that make heavy usage of pencil drawing probably disabling it is better\n * @default true\n */\n cachesBoundsOfCurve = true;\n\n /**\n * Map of font files\n * Map<fontFamily, pathToFile> of font files\n */\n fontPaths: Record</** fontFamily */ string, /** pathToFile */ string> = {};\n\n /**\n * Defines the number of fraction digits to use when serializing object values.\n * Used in exporting methods (`toObject`, `toJSON`, `toSVG`)\n * You can use it to increase/decrease precision of such values like left, top, scaleX, scaleY, etc.\n */\n NUM_FRACTION_DIGITS = 4;\n}\n\nexport class Configuration extends BaseConfiguration {\n constructor(config?: TConfiguration) {\n super();\n this.configure(config);\n }\n\n configure(config: TConfiguration = {}) {\n Object.assign(this, config);\n }\n\n /**\n * Map<fontFamily, pathToFile> of font files\n */\n addFonts(\n paths: Record</** fontFamily */ string, /** pathToFile */ string> = {}
|
|
1
|
+
{"version":3,"file":"config.mjs","sources":["../../src/config.ts"],"sourcesContent":["export type TConfiguration = Partial<BaseConfiguration>;\n\nclass BaseConfiguration {\n /**\n * Browser-specific constant to adjust CanvasRenderingContext2D.shadowBlur value,\n * which is unitless and not rendered equally across browsers.\n *\n * Values that work quite well (as of October 2017) are:\n * - Chrome: 1.5\n * - Edge: 1.75\n * - Firefox: 0.9\n * - Safari: 0.95\n *\n * @since 2.0.0\n * @type Number\n * @default 1\n */\n browserShadowBlurConstant = 1;\n\n /**\n * Pixel per Inch as a default value set to 96. Can be changed for more realistic conversion.\n */\n DPI = 96;\n\n /**\n * Device Pixel Ratio\n * @see https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/SettingUptheCanvas/SettingUptheCanvas.html\n */\n devicePixelRatio =\n typeof window !== 'undefined' ? window.devicePixelRatio : 1; // eslint-disable-line no-restricted-globals\n\n /**\n * Pixel limit for cache canvases. 1Mpx , 4Mpx should be fine.\n * @since 1.7.14\n * @type Number\n * @default\n */\n perfLimitSizeTotal = 2097152;\n\n /**\n * Pixel limit for cache canvases width or height. IE fixes the maximum at 5000\n * @since 1.7.14\n * @type Number\n * @default\n */\n maxCacheSideLimit = 4096;\n\n /**\n * Lowest pixel limit for cache canvases, set at 256PX\n * @since 1.7.14\n * @type Number\n * @default\n */\n minCacheSideLimit = 256;\n\n /**\n * When 'true', style information is not retained when copy/pasting text, making\n * pasted text use destination style.\n * Defaults to 'false'.\n * @type Boolean\n * @default\n * @deprecated\n */\n disableStyleCopyPaste = false;\n\n /**\n * Enable webgl for filtering picture is available\n * A filtering backend will be initialized, this will both take memory and\n * time since a default 2048x2048 canvas will be created for the gl context\n * @since 2.0.0\n * @type Boolean\n * @default\n */\n enableGLFiltering = true;\n\n /**\n * if webgl is enabled and available, textureSize will determine the size\n * of the canvas backend\n *\n * In order to support old hardware set to `2048` to avoid OOM\n *\n * @since 2.0.0\n * @type Number\n * @default\n */\n textureSize = 4096;\n\n /**\n * Skip performance testing of setupGLContext and force the use of putImageData that seems to be the one that works best on\n * Chrome + old hardware. if your users are experiencing empty images after filtering you may try to force this to true\n * this has to be set before instantiating the filtering backend ( before filtering the first image )\n * @type Boolean\n * @default false\n */\n forceGLPutImageData = false;\n\n /**\n * If disabled boundsOfCurveCache is not used. For apps that make heavy usage of pencil drawing probably disabling it is better\n * @default true\n */\n cachesBoundsOfCurve = true;\n\n /**\n * Map of font files\n * Map<fontFamily, pathToFile> of font files\n */\n fontPaths: Record</** fontFamily */ string, /** pathToFile */ string> = {};\n\n /**\n * Defines the number of fraction digits to use when serializing object values.\n * Used in exporting methods (`toObject`, `toJSON`, `toSVG`)\n * You can use it to increase/decrease precision of such values like left, top, scaleX, scaleY, etc.\n */\n NUM_FRACTION_DIGITS = 4;\n}\n\nexport class Configuration extends BaseConfiguration {\n constructor(config?: TConfiguration) {\n super();\n this.configure(config);\n }\n\n configure(config: TConfiguration = {}) {\n Object.assign(this, config);\n }\n\n /**\n * Map<fontFamily, pathToFile> of font files\n */\n addFonts(\n paths: Record</** fontFamily */ string, /** pathToFile */ string> = {},\n ) {\n this.fontPaths = {\n ...this.fontPaths,\n ...paths,\n };\n }\n\n removeFonts(fontFamilys: string[] = []) {\n fontFamilys.forEach((fontFamily) => {\n delete this.fontPaths[fontFamily];\n });\n }\n\n clearFonts() {\n this.fontPaths = {};\n }\n\n restoreDefaults<T extends BaseConfiguration>(keys?: (keyof T)[]) {\n const defaults = new BaseConfiguration() as T;\n const config =\n keys?.reduce((acc, key) => {\n acc[key] = defaults[key];\n return acc;\n }, {} as T) || defaults;\n this.configure(config);\n }\n}\n\nexport const config = new Configuration();\n"],"names":["BaseConfiguration","constructor","_defineProperty","window","devicePixelRatio","Configuration","config","configure","arguments","length","undefined","Object","assign","addFonts","paths","fontPaths","_objectSpread","removeFonts","fontFamilys","forEach","fontFamily","clearFonts","restoreDefaults","keys","defaults","reduce","acc","key"],"mappings":";;AAEA,MAAMA,iBAAiB,CAAC;EAAAC,WAAA,GAAA;AACtB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAbEC,IAAAA,eAAA,oCAc4B,CAAC,CAAA,CAAA;AAE7B;AACF;AACA;AAFEA,IAAAA,eAAA,cAGM,EAAE,CAAA,CAAA;AAER;AACF;AACA;AACA;IAHEA,eAAA,CAAA,IAAA,EAAA,kBAAA,EAKE,OAAOC,MAAM,KAAK,WAAW,GAAGA,MAAM,CAACC,gBAAgB,GAAG,CAAC,CAAA,CAAA;AAAE;AAE/D;AACF;AACA;AACA;AACA;AACA;AALEF,IAAAA,eAAA,6BAMqB,OAAO,CAAA,CAAA;AAE5B;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,4BAMoB,IAAI,CAAA,CAAA;AAExB;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,4BAMoB,GAAG,CAAA,CAAA;AAEvB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AAPEA,IAAAA,eAAA,gCAQwB,KAAK,CAAA,CAAA;AAE7B;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AAPEA,IAAAA,eAAA,4BAQoB,IAAI,CAAA,CAAA;AAExB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AATEA,IAAAA,eAAA,sBAUc,IAAI,CAAA,CAAA;AAElB;AACF;A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GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,EAAE,CAAA;AACpCU,IAAAA,WAAW,CAACC,OAAO,CAAEC,UAAU,IAAK;AAClC,MAAA,OAAO,IAAI,CAACL,SAAS,CAACK,UAAU,CAAC,CAAA;AACnC,KAAC,CAAC,CAAA;AACJ,GAAA;AAEAC,EAAAA,UAAUA,GAAG;AACX,IAAA,IAAI,CAACN,SAAS,GAAG,EAAE,CAAA;AACrB,GAAA;EAEAO,eAAeA,CAA8BC,IAAkB,EAAE;AAC/D,IAAA,MAAMC,QAAQ,GAAG,IAAIxB,iBAAiB,EAAO,CAAA;AAC7C,IAAA,MAAMM,MAAM,GACV,CAAAiB,IAAI,aAAJA,IAAI,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAJA,IAAI,CAAEE,MAAM,CAAC,CAACC,GAAG,EAAEC,GAAG,KAAK;AACzBD,MAAAA,GAAG,CAACC,GAAG,CAAC,GAAGH,QAAQ,CAACG,GAAG,CAAC,CAAA;AACxB,MAAA,OAAOD,GAAG,CAAA;AACZ,KAAC,EAAE,EAAO,CAAC,KAAIF,QAAQ,CAAA;AACzB,IAAA,IAAI,CAACjB,SAAS,CAACD,MAAM,CAAC,CAAA;AACxB,GAAA;AACF,CAAA;MAEaA,MAAM,GAAG,IAAID,aAAa;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Control.min.mjs","sources":["../../../src/controls/Control.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport type {\n ControlActionHandler,\n TPointerEvent,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { Intersection } from '../Intersection';\nimport { Point } from '../Point';\nimport { SCALE } from '../constants';\nimport type { InteractiveFabricObject } from '../shapes/Object/InteractiveObject';\nimport type { TCornerPoint, TDegree, TMat2D } from '../typedefs';\nimport {\n createRotateMatrix,\n createScaleMatrix,\n createTranslateMatrix,\n multiplyTransformMatrixArray,\n} from '../util/misc/matrix';\nimport type { ControlRenderingStyleOverride } from './controlRendering';\nimport { renderCircleControl, renderSquareControl } from './controlRendering';\n\nexport class Control {\n /**\n * keep track of control visibility.\n * mainly for backward compatibility.\n * if you do not want to see a control, you can remove it\n * from the control set.\n * @type {Boolean}\n * @default true\n */\n visible = true;\n\n /**\n * Name of the action that the control will likely execute.\n * This is optional. FabricJS uses to identify what the user is doing for some\n * extra optimizations. If you are writing a custom control and you want to know\n * somewhere else in the code what is going on, you can use this string here.\n * you can also provide a custom getActionName if your control run multiple actions\n * depending on some external state.\n * default to scale since is the most common, used on 4 corners by default\n * @type {String}\n * @default 'scale'\n */\n actionName = SCALE;\n\n /**\n * Drawing angle of the control.\n * NOT used for now, but name marked as needed for internal logic\n * example: to reuse the same drawing function for different rotated controls\n * @type {Number}\n * @default 0\n */\n angle = 0;\n\n /**\n * Relative position of the control. X\n * 0,0 is the center of the Object, while -0.5 (left) or 0.5 (right) are the extremities\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n x = 0;\n\n /**\n * Relative position of the control. Y\n * 0,0 is the center of the Object, while -0.5 (top) or 0.5 (bottom) are the extremities\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n y = 0;\n\n /**\n * Horizontal offset of the control from the defined position. In pixels\n * Positive offset moves the control to the right, negative to the left.\n * It used when you want to have position of control that does not scale with\n * the bounding box. Example: rotation control is placed at x:0, y: 0.5 on\n * the boundind box, with an offset of 30 pixels vertically. Those 30 pixels will\n * stay 30 pixels no matter how the object is big. Another example is having 2\n * controls in the corner, that stay in the same position when the object scale.\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n offsetX = 0;\n\n /**\n * Vertical offset of the control from the defined position. In pixels\n * Positive offset moves the control to the bottom, negative to the top.\n * @type {Number}\n * @default 0\n */\n offsetY = 0;\n\n /**\n * Sets the length of the control. If null, defaults to object's cornerSize.\n * Expects both sizeX and sizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n sizeX = 0;\n\n /**\n * Sets the height of the control. If null, defaults to object's cornerSize.\n * Expects both sizeX and sizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n sizeY = 0;\n\n /**\n * Sets the length of the touch area of the control. If null, defaults to object's touchCornerSize.\n * Expects both touchSizeX and touchSizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n touchSizeX = 0;\n\n /**\n * Sets the height of the touch area of the control. If null, defaults to object's touchCornerSize.\n * Expects both touchSizeX and touchSizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n touchSizeY = 0;\n\n /**\n * Css cursor style to display when the control is hovered.\n * if the method `cursorStyleHandler` is provided, this property is ignored.\n * @type {String}\n * @default 'crosshair'\n */\n cursorStyle = 'crosshair';\n\n /**\n * If controls has an offsetY or offsetX, draw a line that connects\n * the control to the bounding box\n * @type {Boolean}\n * @default false\n */\n withConnection = false;\n\n constructor(options?: Partial<Control>) {\n Object.assign(this, options);\n }\n\n /**\n * The control actionHandler, provide one to handle action ( control being moved )\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare actionHandler: TransformActionHandler;\n\n /**\n * The control handler for mouse down, provide one to handle mouse down on control\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare mouseDownHandler?: ControlActionHandler;\n\n /**\n * The control mouseUpHandler, provide one to handle an effect on mouse up.\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare mouseUpHandler?: ControlActionHandler;\n\n shouldActivate(\n controlKey: string,\n fabricObject: InteractiveFabricObject,\n pointer: Point,\n { tl, tr, br, bl }: TCornerPoint\n ) {\n // TODO: locking logic can be handled here instead of in the control handler logic\n return (\n fabricObject.canvas?.getActiveObject() === fabricObject &&\n fabricObject.isControlVisible(controlKey) &&\n Intersection.isPointInPolygon(pointer, [tl, tr, br, bl])\n );\n }\n\n /**\n * Returns control actionHandler\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getActionHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control\n ): TransformActionHandler | undefined {\n return this.actionHandler;\n }\n\n /**\n * Returns control mouseDown handler\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getMouseDownHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control\n ): ControlActionHandler | undefined {\n return this.mouseDownHandler;\n }\n\n /**\n * Returns control mouseUp handler.\n * During actions the fabricObject or the control can be of different obj\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getMouseUpHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control\n ): ControlActionHandler | undefined {\n return this.mouseUpHandler;\n }\n\n /**\n * Returns control cursorStyle for css using cursorStyle. If you need a more elaborate\n * function you can pass one in the constructor\n * the cursorStyle property\n * @param {Event} eventData the native mouse event\n * @param {Control} control the current control ( likely this)\n * @param {FabricObject} object on which the control is displayed\n * @return {String}\n */\n cursorStyleHandler(\n eventData: TPointerEvent,\n control: Control,\n fabricObject: InteractiveFabricObject\n ) {\n return control.cursorStyle;\n }\n\n /**\n * Returns the action name. The basic implementation just return the actionName property.\n * @param {Event} eventData the native mouse event\n * @param {Control} control the current control ( likely this)\n * @param {FabricObject} object on which the control is displayed\n * @return {String}\n */\n getActionName(\n eventData: TPointerEvent,\n control: Control,\n fabricObject: InteractiveFabricObject\n ) {\n return control.actionName;\n }\n\n /**\n * Returns controls visibility\n * @param {FabricObject} object on which the control is displayed\n * @param {String} controlKey key where the control is memorized on the\n * @return {Boolean}\n */\n getVisibility(fabricObject: InteractiveFabricObject, controlKey: string) {\n return fabricObject._controlsVisibility?.[controlKey] ?? this.visible;\n }\n\n /**\n * Sets controls visibility\n * @param {Boolean} visibility for the object\n * @return {Void}\n */\n setVisibility(\n visibility: boolean,\n name: string,\n fabricObject: InteractiveFabricObject\n ) {\n this.visible = visibility;\n }\n\n positionHandler(\n dim: Point,\n finalMatrix: TMat2D,\n fabricObject: InteractiveFabricObject,\n currentControl: Control\n ) {\n return new Point(\n this.x * dim.x + this.offsetX,\n this.y * dim.y + this.offsetY\n ).transform(finalMatrix);\n }\n\n /**\n * Returns the coords for this control based on object values.\n * @param {Number} objectAngle angle from the fabric object holding the control\n * @param {Number} objectCornerSize cornerSize from the fabric object holding the control (or touchCornerSize if\n * isTouch is true)\n * @param {Number} centerX x coordinate where the control center should be\n * @param {Number} centerY y coordinate where the control center should be\n * @param {boolean} isTouch true if touch corner, false if normal corner\n */\n calcCornerCoords(\n angle: TDegree,\n objectCornerSize: number,\n centerX: number,\n centerY: number,\n isTouch: boolean,\n fabricObject: InteractiveFabricObject\n ) {\n const t = multiplyTransformMatrixArray([\n createTranslateMatrix(centerX, centerY),\n createRotateMatrix({ angle }),\n createScaleMatrix(\n (isTouch ? this.touchSizeX : this.sizeX) || objectCornerSize,\n (isTouch ? this.touchSizeY : this.sizeY) || objectCornerSize\n ),\n ]);\n return {\n tl: new Point(-0.5, -0.5).transform(t),\n tr: new Point(0.5, -0.5).transform(t),\n br: new Point(0.5, 0.5).transform(t),\n bl: new Point(-0.5, 0.5).transform(t),\n };\n }\n\n /**\n * Render function for the control.\n * When this function runs the context is unscaled. unrotate. Just retina scaled.\n * all the functions will have to translate to the point left,top before starting Drawing\n * if they want to draw a control where the position is detected.\n * left and top are the result of the positionHandler function\n * @param {RenderingContext2D} ctx the context where the control will be drawn\n * @param {Number} left position of the canvas where we are about to render the control.\n * @param {Number} top position of the canvas where we are about to render the control.\n * @param {Object} styleOverride\n * @param {FabricObject} fabricObject the object where the control is about to be rendered\n */\n render(\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride | undefined,\n fabricObject: InteractiveFabricObject\n ) {\n styleOverride = styleOverride || {};\n switch (styleOverride.cornerStyle || fabricObject.cornerStyle) {\n case 'circle':\n renderCircleControl.call(\n this,\n ctx,\n left,\n top,\n styleOverride,\n fabricObject\n );\n break;\n default:\n renderSquareControl.call(\n this,\n ctx,\n left,\n top,\n styleOverride,\n fabricObject\n );\n }\n }\n}\n"],"names":["Control","constructor","options","_defineProperty","SCALE","Object","assign","this","shouldActivate","controlKey","fabricObject","pointer","_ref","_fabricObject$canvas","tl","tr","br","bl","canvas","getActiveObject","isControlVisible","Intersection","isPointInPolygon","getActionHandler","eventData","control","actionHandler","getMouseDownHandler","mouseDownHandler","getMouseUpHandler","mouseUpHandler","cursorStyleHandler","cursorStyle","getActionName","actionName","getVisibility","_fabricObject$_contro","_fabricObject$_contro2","_controlsVisibility","visible","setVisibility","visibility","name","positionHandler","dim","finalMatrix","currentControl","Point","x","offsetX","y","offsetY","transform","calcCornerCoords","angle","objectCornerSize","centerX","centerY","isTouch","t","multiplyTransformMatrixArray","createTranslateMatrix","createRotateMatrix","createScaleMatrix","touchSizeX","sizeX","touchSizeY","sizeY","render","ctx","left","top","styleOverride","cornerStyle","renderCircleControl","call","renderSquareControl"],"mappings":"8cAoBO,MAAMA,EAyHXC,WAAAA,CAAYC,GAxHZC,kBAQU,GAEVA,oBAWaC,GAEbD,eAOQ,GAERA,WAOI,GAEJA,WAOI,GAEJA,iBAYU,GAEVA,iBAMU,GAEVA,eAMQ,GAERA,eAMQ,GAERA,oBAMa,GAEbA,oBAMa,GAEbA,qBAMc,aAEdA,yBAMiB,GAGfE,OAAOC,OAAOC,KAAML,EACtB,CAgCAM,cAAAA,CACEC,EACAC,EACAC,EAAcC,GAEd,IAAAC,EAAA,IADAC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KK,UAAUO,GACpC5C,GAAI,IAAIgC,EAAM,IAAM,IAAKK,UAAUO,GACnC3C,GAAI,IAAI+B,EAAM,GAAK,IAAKK,UAAUO,GAClC1C,GAAI,IAAI8B,GAAO,GAAK,IAAKK,UAAUO,GAEvC,CAcAS,MAAAA,CACEC,EACAC,EACAC,EACAC,EACA9D,GAGA,GACO,aAFP8D,EAAgBA,GAAiB,IACXC,aAAe/D,EAAa+D,aAE9CC,EAAoBC,KAClBpE,KACA8D,EACAC,EACAC,EACAC,EACA9D,QAIFkE,EAAoBD,KAClBpE,KACA8D,EACAC,EACAC,EACAC,EACA9D,EAGR"}
|
|
1
|
+
{"version":3,"file":"Control.min.mjs","sources":["../../../src/controls/Control.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport type {\n ControlActionHandler,\n TPointerEvent,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { Intersection } from '../Intersection';\nimport { Point } from '../Point';\nimport { SCALE } from '../constants';\nimport type { InteractiveFabricObject } from '../shapes/Object/InteractiveObject';\nimport type { TCornerPoint, TDegree, TMat2D } from '../typedefs';\nimport {\n createRotateMatrix,\n createScaleMatrix,\n createTranslateMatrix,\n multiplyTransformMatrixArray,\n} from '../util/misc/matrix';\nimport type { ControlRenderingStyleOverride } from './controlRendering';\nimport { renderCircleControl, renderSquareControl } from './controlRendering';\n\nexport class Control {\n /**\n * keep track of control visibility.\n * mainly for backward compatibility.\n * if you do not want to see a control, you can remove it\n * from the control set.\n * @type {Boolean}\n * @default true\n */\n visible = true;\n\n /**\n * Name of the action that the control will likely execute.\n * This is optional. FabricJS uses to identify what the user is doing for some\n * extra optimizations. If you are writing a custom control and you want to know\n * somewhere else in the code what is going on, you can use this string here.\n * you can also provide a custom getActionName if your control run multiple actions\n * depending on some external state.\n * default to scale since is the most common, used on 4 corners by default\n * @type {String}\n * @default 'scale'\n */\n actionName = SCALE;\n\n /**\n * Drawing angle of the control.\n * NOT used for now, but name marked as needed for internal logic\n * example: to reuse the same drawing function for different rotated controls\n * @type {Number}\n * @default 0\n */\n angle = 0;\n\n /**\n * Relative position of the control. X\n * 0,0 is the center of the Object, while -0.5 (left) or 0.5 (right) are the extremities\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n x = 0;\n\n /**\n * Relative position of the control. Y\n * 0,0 is the center of the Object, while -0.5 (top) or 0.5 (bottom) are the extremities\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n y = 0;\n\n /**\n * Horizontal offset of the control from the defined position. In pixels\n * Positive offset moves the control to the right, negative to the left.\n * It used when you want to have position of control that does not scale with\n * the bounding box. Example: rotation control is placed at x:0, y: 0.5 on\n * the boundind box, with an offset of 30 pixels vertically. Those 30 pixels will\n * stay 30 pixels no matter how the object is big. Another example is having 2\n * controls in the corner, that stay in the same position when the object scale.\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n offsetX = 0;\n\n /**\n * Vertical offset of the control from the defined position. In pixels\n * Positive offset moves the control to the bottom, negative to the top.\n * @type {Number}\n * @default 0\n */\n offsetY = 0;\n\n /**\n * Sets the length of the control. If null, defaults to object's cornerSize.\n * Expects both sizeX and sizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n sizeX = 0;\n\n /**\n * Sets the height of the control. If null, defaults to object's cornerSize.\n * Expects both sizeX and sizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n sizeY = 0;\n\n /**\n * Sets the length of the touch area of the control. If null, defaults to object's touchCornerSize.\n * Expects both touchSizeX and touchSizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n touchSizeX = 0;\n\n /**\n * Sets the height of the touch area of the control. If null, defaults to object's touchCornerSize.\n * Expects both touchSizeX and touchSizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n touchSizeY = 0;\n\n /**\n * Css cursor style to display when the control is hovered.\n * if the method `cursorStyleHandler` is provided, this property is ignored.\n * @type {String}\n * @default 'crosshair'\n */\n cursorStyle = 'crosshair';\n\n /**\n * If controls has an offsetY or offsetX, draw a line that connects\n * the control to the bounding box\n * @type {Boolean}\n * @default false\n */\n withConnection = false;\n\n constructor(options?: Partial<Control>) {\n Object.assign(this, options);\n }\n\n /**\n * The control actionHandler, provide one to handle action ( control being moved )\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare actionHandler: TransformActionHandler;\n\n /**\n * The control handler for mouse down, provide one to handle mouse down on control\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare mouseDownHandler?: ControlActionHandler;\n\n /**\n * The control mouseUpHandler, provide one to handle an effect on mouse up.\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare mouseUpHandler?: ControlActionHandler;\n\n shouldActivate(\n controlKey: string,\n fabricObject: InteractiveFabricObject,\n pointer: Point,\n { tl, tr, br, bl }: TCornerPoint,\n ) {\n // TODO: locking logic can be handled here instead of in the control handler logic\n return (\n fabricObject.canvas?.getActiveObject() === fabricObject &&\n fabricObject.isControlVisible(controlKey) &&\n Intersection.isPointInPolygon(pointer, [tl, tr, br, bl])\n );\n }\n\n /**\n * Returns control actionHandler\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getActionHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): TransformActionHandler | undefined {\n return this.actionHandler;\n }\n\n /**\n * Returns control mouseDown handler\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getMouseDownHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): ControlActionHandler | undefined {\n return this.mouseDownHandler;\n }\n\n /**\n * Returns control mouseUp handler.\n * During actions the fabricObject or the control can be of different obj\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getMouseUpHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): ControlActionHandler | undefined {\n return this.mouseUpHandler;\n }\n\n /**\n * Returns control cursorStyle for css using cursorStyle. If you need a more elaborate\n * function you can pass one in the constructor\n * the cursorStyle property\n * @param {Event} eventData the native mouse event\n * @param {Control} control the current control ( likely this)\n * @param {FabricObject} object on which the control is displayed\n * @return {String}\n */\n cursorStyleHandler(\n eventData: TPointerEvent,\n control: Control,\n fabricObject: InteractiveFabricObject,\n ) {\n return control.cursorStyle;\n }\n\n /**\n * Returns the action name. The basic implementation just return the actionName property.\n * @param {Event} eventData the native mouse event\n * @param {Control} control the current control ( likely this)\n * @param {FabricObject} object on which the control is displayed\n * @return {String}\n */\n getActionName(\n eventData: TPointerEvent,\n control: Control,\n fabricObject: InteractiveFabricObject,\n ) {\n return control.actionName;\n }\n\n /**\n * Returns controls visibility\n * @param {FabricObject} object on which the control is displayed\n * @param {String} controlKey key where the control is memorized on the\n * @return {Boolean}\n */\n getVisibility(fabricObject: InteractiveFabricObject, controlKey: string) {\n return fabricObject._controlsVisibility?.[controlKey] ?? this.visible;\n }\n\n /**\n * Sets controls visibility\n * @param {Boolean} visibility for the object\n * @return {Void}\n */\n setVisibility(\n visibility: boolean,\n name: string,\n fabricObject: InteractiveFabricObject,\n ) {\n this.visible = visibility;\n }\n\n positionHandler(\n dim: Point,\n finalMatrix: TMat2D,\n fabricObject: InteractiveFabricObject,\n currentControl: Control,\n ) {\n return new Point(\n this.x * dim.x + this.offsetX,\n this.y * dim.y + this.offsetY,\n ).transform(finalMatrix);\n }\n\n /**\n * Returns the coords for this control based on object values.\n * @param {Number} objectAngle angle from the fabric object holding the control\n * @param {Number} objectCornerSize cornerSize from the fabric object holding the control (or touchCornerSize if\n * isTouch is true)\n * @param {Number} centerX x coordinate where the control center should be\n * @param {Number} centerY y coordinate where the control center should be\n * @param {boolean} isTouch true if touch corner, false if normal corner\n */\n calcCornerCoords(\n angle: TDegree,\n objectCornerSize: number,\n centerX: number,\n centerY: number,\n isTouch: boolean,\n fabricObject: InteractiveFabricObject,\n ) {\n const t = multiplyTransformMatrixArray([\n createTranslateMatrix(centerX, centerY),\n createRotateMatrix({ angle }),\n createScaleMatrix(\n (isTouch ? this.touchSizeX : this.sizeX) || objectCornerSize,\n (isTouch ? this.touchSizeY : this.sizeY) || objectCornerSize,\n ),\n ]);\n return {\n tl: new Point(-0.5, -0.5).transform(t),\n tr: new Point(0.5, -0.5).transform(t),\n br: new Point(0.5, 0.5).transform(t),\n bl: new Point(-0.5, 0.5).transform(t),\n };\n }\n\n /**\n * Render function for the control.\n * When this function runs the context is unscaled. unrotate. Just retina scaled.\n * all the functions will have to translate to the point left,top before starting Drawing\n * if they want to draw a control where the position is detected.\n * left and top are the result of the positionHandler function\n * @param {RenderingContext2D} ctx the context where the control will be drawn\n * @param {Number} left position of the canvas where we are about to render the control.\n * @param {Number} top position of the canvas where we are about to render the control.\n * @param {Object} styleOverride\n * @param {FabricObject} fabricObject the object where the control is about to be rendered\n */\n render(\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride | undefined,\n fabricObject: InteractiveFabricObject,\n ) {\n styleOverride = styleOverride || {};\n switch (styleOverride.cornerStyle || fabricObject.cornerStyle) {\n case 'circle':\n renderCircleControl.call(\n this,\n ctx,\n left,\n top,\n styleOverride,\n fabricObject,\n );\n break;\n default:\n renderSquareControl.call(\n this,\n ctx,\n left,\n top,\n styleOverride,\n fabricObject,\n );\n }\n }\n}\n"],"names":["Control","constructor","options","_defineProperty","SCALE","Object","assign","this","shouldActivate","controlKey","fabricObject","pointer","_ref","_fabricObject$canvas","tl","tr","br","bl","canvas","getActiveObject","isControlVisible","Intersection","isPointInPolygon","getActionHandler","eventData","control","actionHandler","getMouseDownHandler","mouseDownHandler","getMouseUpHandler","mouseUpHandler","cursorStyleHandler","cursorStyle","getActionName","actionName","getVisibility","_fabricObject$_contro","_fabricObject$_contro2","_controlsVisibility","visible","setVisibility","visibility","name","positionHandler","dim","finalMatrix","currentControl","Point","x","offsetX","y","offsetY","transform","calcCornerCoords","angle","objectCornerSize","centerX","centerY","isTouch","t","multiplyTransformMatrixArray","createTranslateMatrix","createRotateMatrix","createScaleMatrix","touchSizeX","sizeX","touchSizeY","sizeY","render","ctx","left","top","styleOverride","cornerStyle","renderCircleControl","call","renderSquareControl"],"mappings":"8cAoBO,MAAMA,EAyHXC,WAAAA,CAAYC,GAxHZC,kBAQU,GAEVA,oBAWaC,GAEbD,eAOQ,GAERA,WAOI,GAEJA,WAOI,GAEJA,iBAYU,GAEVA,iBAMU,GAEVA,eAMQ,GAERA,eAMQ,GAERA,oBAMa,GAEbA,oBAMa,GAEbA,qBAMc,aAEdA,yBAMiB,GAGfE,OAAOC,OAAOC,KAAML,EACtB,CAgCAM,cAAAA,CACEC,EACAC,EACAC,EAAcC,GAEd,IAAAC,EAAA,IADAC,GAAEA,EAAEC,GAAEA,EAAEC,GAAEA,EAAEC,GAAEA,GAAkBL,EAGhC,OACqBC,QAAnBA,EAAAH,EAAaQ,cAAbL,IAAmBA,OAAnBA,EAAAA,EAAqBM,qBAAsBT,GAC3CA,EAAaU,iBAAiBX,IAC9BY,EAAaC,iBAAiBX,EAAS,CAACG,EAAIC,EAAIC,EAAIC,GAExD,CASAM,gBAAAA,CACEC,EACAd,EACAe,GAEA,OAAOlB,KAAKmB,aACd,CASAC,mBAAAA,CACEH,EACAd,EACAe,GAEA,OAAOlB,KAAKqB,gBACd,CAUAC,iBAAAA,CACEL,EACAd,EACAe,GAEA,OAAOlB,KAAKuB,cACd,CAWAC,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"version":3,"file":"Control.mjs","sources":["../../../src/controls/Control.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport type {\n ControlActionHandler,\n TPointerEvent,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { Intersection } from '../Intersection';\nimport { Point } from '../Point';\nimport { SCALE } from '../constants';\nimport type { InteractiveFabricObject } from '../shapes/Object/InteractiveObject';\nimport type { TCornerPoint, TDegree, TMat2D } from '../typedefs';\nimport {\n createRotateMatrix,\n createScaleMatrix,\n createTranslateMatrix,\n multiplyTransformMatrixArray,\n} from '../util/misc/matrix';\nimport type { ControlRenderingStyleOverride } from './controlRendering';\nimport { renderCircleControl, renderSquareControl } from './controlRendering';\n\nexport class Control {\n /**\n * keep track of control visibility.\n * mainly for backward compatibility.\n * if you do not want to see a control, you can remove it\n * from the control set.\n * @type {Boolean}\n * @default true\n */\n visible = true;\n\n /**\n * Name of the action that the control will likely execute.\n * This is optional. FabricJS uses to identify what the user is doing for some\n * extra optimizations. If you are writing a custom control and you want to know\n * somewhere else in the code what is going on, you can use this string here.\n * you can also provide a custom getActionName if your control run multiple actions\n * depending on some external state.\n * default to scale since is the most common, used on 4 corners by default\n * @type {String}\n * @default 'scale'\n */\n actionName = SCALE;\n\n /**\n * Drawing angle of the control.\n * NOT used for now, but name marked as needed for internal logic\n * example: to reuse the same drawing function for different rotated controls\n * @type {Number}\n * @default 0\n */\n angle = 0;\n\n /**\n * Relative position of the control. X\n * 0,0 is the center of the Object, while -0.5 (left) or 0.5 (right) are the extremities\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n x = 0;\n\n /**\n * Relative position of the control. Y\n * 0,0 is the center of the Object, while -0.5 (top) or 0.5 (bottom) are the extremities\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n y = 0;\n\n /**\n * Horizontal offset of the control from the defined position. In pixels\n * Positive offset moves the control to the right, negative to the left.\n * It used when you want to have position of control that does not scale with\n * the bounding box. Example: rotation control is placed at x:0, y: 0.5 on\n * the boundind box, with an offset of 30 pixels vertically. Those 30 pixels will\n * stay 30 pixels no matter how the object is big. Another example is having 2\n * controls in the corner, that stay in the same position when the object scale.\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n offsetX = 0;\n\n /**\n * Vertical offset of the control from the defined position. In pixels\n * Positive offset moves the control to the bottom, negative to the top.\n * @type {Number}\n * @default 0\n */\n offsetY = 0;\n\n /**\n * Sets the length of the control. If null, defaults to object's cornerSize.\n * Expects both sizeX and sizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n sizeX = 0;\n\n /**\n * Sets the height of the control. If null, defaults to object's cornerSize.\n * Expects both sizeX and sizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n sizeY = 0;\n\n /**\n * Sets the length of the touch area of the control. If null, defaults to object's touchCornerSize.\n * Expects both touchSizeX and touchSizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n touchSizeX = 0;\n\n /**\n * Sets the height of the touch area of the control. If null, defaults to object's touchCornerSize.\n * Expects both touchSizeX and touchSizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n touchSizeY = 0;\n\n /**\n * Css cursor style to display when the control is hovered.\n * if the method `cursorStyleHandler` is provided, this property is ignored.\n * @type {String}\n * @default 'crosshair'\n */\n cursorStyle = 'crosshair';\n\n /**\n * If controls has an offsetY or offsetX, draw a line that connects\n * the control to the bounding box\n * @type {Boolean}\n * @default false\n */\n withConnection = false;\n\n constructor(options?: Partial<Control>) {\n Object.assign(this, options);\n }\n\n /**\n * The control actionHandler, provide one to handle action ( control being moved )\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare actionHandler: TransformActionHandler;\n\n /**\n * The control handler for mouse down, provide one to handle mouse down on control\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare mouseDownHandler?: ControlActionHandler;\n\n /**\n * The control mouseUpHandler, provide one to handle an effect on mouse up.\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare mouseUpHandler?: ControlActionHandler;\n\n shouldActivate(\n controlKey: string,\n fabricObject: InteractiveFabricObject,\n pointer: Point,\n { tl, tr, br, bl }: TCornerPoint\n ) {\n // TODO: locking logic can be handled here instead of in the control handler logic\n return (\n fabricObject.canvas?.getActiveObject() === fabricObject &&\n fabricObject.isControlVisible(controlKey) &&\n Intersection.isPointInPolygon(pointer, [tl, tr, br, bl])\n );\n }\n\n /**\n * Returns control actionHandler\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getActionHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control\n ): TransformActionHandler | undefined {\n return this.actionHandler;\n }\n\n /**\n * Returns control mouseDown handler\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getMouseDownHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control\n ): ControlActionHandler | undefined {\n return this.mouseDownHandler;\n }\n\n /**\n * Returns control mouseUp handler.\n * During actions the fabricObject or the control can be of different obj\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getMouseUpHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control\n ): ControlActionHandler | undefined {\n return this.mouseUpHandler;\n }\n\n /**\n * Returns control cursorStyle for css using cursorStyle. If you need a more elaborate\n * function you can pass one in the constructor\n * the cursorStyle property\n * @param {Event} eventData the native mouse event\n * @param {Control} control the current control ( likely this)\n * @param {FabricObject} object on which the control is displayed\n * @return {String}\n */\n cursorStyleHandler(\n eventData: TPointerEvent,\n control: Control,\n fabricObject: InteractiveFabricObject\n ) {\n return control.cursorStyle;\n }\n\n /**\n * Returns the action name. The basic implementation just return the actionName property.\n * @param {Event} eventData the native mouse event\n * @param {Control} control the current control ( likely this)\n * @param {FabricObject} object on which the control is displayed\n * @return {String}\n */\n getActionName(\n eventData: TPointerEvent,\n control: Control,\n fabricObject: InteractiveFabricObject\n ) {\n return control.actionName;\n }\n\n /**\n * Returns controls visibility\n * @param {FabricObject} object on which the control is displayed\n * @param {String} controlKey key where the control is memorized on the\n * @return {Boolean}\n */\n getVisibility(fabricObject: InteractiveFabricObject, controlKey: string) {\n return fabricObject._controlsVisibility?.[controlKey] ?? this.visible;\n }\n\n /**\n * Sets controls visibility\n * @param {Boolean} visibility for the object\n * @return {Void}\n */\n setVisibility(\n visibility: boolean,\n name: string,\n fabricObject: InteractiveFabricObject\n ) {\n this.visible = visibility;\n }\n\n positionHandler(\n dim: Point,\n finalMatrix: TMat2D,\n fabricObject: InteractiveFabricObject,\n currentControl: Control\n ) {\n return new Point(\n this.x * dim.x + this.offsetX,\n this.y * dim.y + this.offsetY\n ).transform(finalMatrix);\n }\n\n /**\n * Returns the coords for this control based on object values.\n * @param {Number} objectAngle angle from the fabric object holding the control\n * @param {Number} objectCornerSize cornerSize from the fabric object holding the control (or touchCornerSize if\n * isTouch is true)\n * @param {Number} centerX x coordinate where the control center should be\n * @param {Number} centerY y coordinate where the control center should be\n * @param {boolean} isTouch true if touch corner, false if normal corner\n */\n calcCornerCoords(\n angle: TDegree,\n objectCornerSize: number,\n centerX: number,\n centerY: number,\n isTouch: boolean,\n fabricObject: InteractiveFabricObject\n ) {\n const t = multiplyTransformMatrixArray([\n createTranslateMatrix(centerX, centerY),\n createRotateMatrix({ angle }),\n createScaleMatrix(\n (isTouch ? this.touchSizeX : this.sizeX) || objectCornerSize,\n (isTouch ? this.touchSizeY : this.sizeY) || objectCornerSize\n ),\n ]);\n return {\n tl: new Point(-0.5, -0.5).transform(t),\n tr: new Point(0.5, -0.5).transform(t),\n br: new Point(0.5, 0.5).transform(t),\n bl: new Point(-0.5, 0.5).transform(t),\n };\n }\n\n /**\n * Render function for the control.\n * When this function runs the context is unscaled. unrotate. Just retina scaled.\n * all the functions will have to translate to the point left,top before starting Drawing\n * if they want to draw a control where the position is detected.\n * left and top are the result of the positionHandler function\n * @param {RenderingContext2D} ctx the context where the control will be drawn\n * @param {Number} left position of the canvas where we are about to render the control.\n * @param {Number} top position of the canvas where we are about to render the control.\n * @param {Object} styleOverride\n * @param {FabricObject} fabricObject the object where the control is about to be rendered\n */\n render(\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride | undefined,\n fabricObject: InteractiveFabricObject\n ) {\n styleOverride = styleOverride || {};\n switch (styleOverride.cornerStyle || fabricObject.cornerStyle) {\n case 'circle':\n renderCircleControl.call(\n this,\n ctx,\n left,\n top,\n styleOverride,\n fabricObject\n );\n break;\n default:\n renderSquareControl.call(\n this,\n ctx,\n left,\n top,\n styleOverride,\n fabricObject\n );\n }\n }\n}\n"],"names":["Control","constructor","options","_defineProperty","SCALE","Object","assign","shouldActivate","controlKey","fabricObject","pointer","_ref","_fabricObject$canvas","tl","tr","br","bl","canvas","getActiveObject","isControlVisible","Intersection","isPointInPolygon","getActionHandler","eventData","control","actionHandler","getMouseDownHandler","mouseDownHandler","getMouseUpHandler","mouseUpHandler","cursorStyleHandler","cursorStyle","getActionName","actionName","getVisibility","_fabricObject$_contro","_fabricObject$_contro2","_controlsVisibility","visible","setVisibility","visibility","name","positionHandler","dim","finalMatrix","currentControl","Point","x","offsetX","y","offsetY","transform","calcCornerCoords","angle","objectCornerSize","centerX","centerY","isTouch","t","multiplyTransformMatrixArray","createTranslateMatrix","createRotateMatrix","createScaleMatrix","touchSizeX","sizeX","touchSizeY","sizeY","render","ctx","left","top","styleOverride","cornerStyle","renderCircleControl","call","renderSquareControl"],"mappings":";;;;;;;AAoBO,MAAMA,OAAO,CAAC;EAyHnBC,WAAWA,CAACC,OAA0B,EAAE;AAxHxC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AAPEC,IAAAA,eAAA,kBAQU,IAAI,CAAA,CAAA;AAEd;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAVEA,IAAAA,eAAA,qBAWaC,KAAK,CAAA,CAAA;AAElB;AACF;AACA;AACA;AACA;AACA;AACA;AANED,IAAAA,eAAA,gBAOQ,CAAC,CAAA,CAAA;AAET;AACF;AACA;AACA;AACA;AACA;AACA;AANEA,IAAAA,eAAA,YAOI,CAAC,CAAA,CAAA;AAEL;AACF;AACA;AACA;AACA;AACA;AACA;AANEA,IAAAA,eAAA,YAOI,CAAC,CAAA,CAAA;AAEL;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAXEA,IAAAA,eAAA,kBAYU,CAAC,CAAA,CAAA;AAEX;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,kBAMU,CAAC,CAAA,CAAA;AAEX;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,gBAMQ,CAAC,CAAA,CAAA;AAET;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,gBAMQ,CAAC,CAAA,CAAA;AAET;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,qBAMa,CAAC,CAAA,CAAA;AAEd;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,qBAMa,CAAC,CAAA,CAAA;AAEd;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,sBAMc,WAAW,CAAA,CAAA;AAEzB;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,yBAMiB,KAAK,CAAA,CAAA;AAGpBE,IAAAA,MAAM,CAACC,MAAM,CAAC,IAAI,EAAEJ,OA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,IAAI,EACJC,GAAG,EACHC,aAAa,EACb9D,YACF,CAAC,CAAA;AACD,QAAA,MAAA;AACF,MAAA;AACEkE,QAAAA,mBAAmB,CAACD,IAAI,CACtB,IAAI,EACJN,GAAG,EACHC,IAAI,EACJC,GAAG,EACHC,aAAa,EACb9D,YACF,CAAC,CAAA;AACL,KAAA;AACF,GAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"Control.mjs","sources":["../../../src/controls/Control.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport type {\n ControlActionHandler,\n TPointerEvent,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { Intersection } from '../Intersection';\nimport { Point } from '../Point';\nimport { SCALE } from '../constants';\nimport type { InteractiveFabricObject } from '../shapes/Object/InteractiveObject';\nimport type { TCornerPoint, TDegree, TMat2D } from '../typedefs';\nimport {\n createRotateMatrix,\n createScaleMatrix,\n createTranslateMatrix,\n multiplyTransformMatrixArray,\n} from '../util/misc/matrix';\nimport type { ControlRenderingStyleOverride } from './controlRendering';\nimport { renderCircleControl, renderSquareControl } from './controlRendering';\n\nexport class Control {\n /**\n * keep track of control visibility.\n * mainly for backward compatibility.\n * if you do not want to see a control, you can remove it\n * from the control set.\n * @type {Boolean}\n * @default true\n */\n visible = true;\n\n /**\n * Name of the action that the control will likely execute.\n * This is optional. FabricJS uses to identify what the user is doing for some\n * extra optimizations. If you are writing a custom control and you want to know\n * somewhere else in the code what is going on, you can use this string here.\n * you can also provide a custom getActionName if your control run multiple actions\n * depending on some external state.\n * default to scale since is the most common, used on 4 corners by default\n * @type {String}\n * @default 'scale'\n */\n actionName = SCALE;\n\n /**\n * Drawing angle of the control.\n * NOT used for now, but name marked as needed for internal logic\n * example: to reuse the same drawing function for different rotated controls\n * @type {Number}\n * @default 0\n */\n angle = 0;\n\n /**\n * Relative position of the control. X\n * 0,0 is the center of the Object, while -0.5 (left) or 0.5 (right) are the extremities\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n x = 0;\n\n /**\n * Relative position of the control. Y\n * 0,0 is the center of the Object, while -0.5 (top) or 0.5 (bottom) are the extremities\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n y = 0;\n\n /**\n * Horizontal offset of the control from the defined position. In pixels\n * Positive offset moves the control to the right, negative to the left.\n * It used when you want to have position of control that does not scale with\n * the bounding box. Example: rotation control is placed at x:0, y: 0.5 on\n * the boundind box, with an offset of 30 pixels vertically. Those 30 pixels will\n * stay 30 pixels no matter how the object is big. Another example is having 2\n * controls in the corner, that stay in the same position when the object scale.\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n offsetX = 0;\n\n /**\n * Vertical offset of the control from the defined position. In pixels\n * Positive offset moves the control to the bottom, negative to the top.\n * @type {Number}\n * @default 0\n */\n offsetY = 0;\n\n /**\n * Sets the length of the control. If null, defaults to object's cornerSize.\n * Expects both sizeX and sizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n sizeX = 0;\n\n /**\n * Sets the height of the control. If null, defaults to object's cornerSize.\n * Expects both sizeX and sizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n sizeY = 0;\n\n /**\n * Sets the length of the touch area of the control. If null, defaults to object's touchCornerSize.\n * Expects both touchSizeX and touchSizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n touchSizeX = 0;\n\n /**\n * Sets the height of the touch area of the control. If null, defaults to object's touchCornerSize.\n * Expects both touchSizeX and touchSizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n touchSizeY = 0;\n\n /**\n * Css cursor style to display when the control is hovered.\n * if the method `cursorStyleHandler` is provided, this property is ignored.\n * @type {String}\n * @default 'crosshair'\n */\n cursorStyle = 'crosshair';\n\n /**\n * If controls has an offsetY or offsetX, draw a line that connects\n * the control to the bounding box\n * @type {Boolean}\n * @default false\n */\n withConnection = false;\n\n constructor(options?: Partial<Control>) {\n Object.assign(this, options);\n }\n\n /**\n * The control actionHandler, provide one to handle action ( control being moved )\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare actionHandler: TransformActionHandler;\n\n /**\n * The control handler for mouse down, provide one to handle mouse down on control\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare mouseDownHandler?: ControlActionHandler;\n\n /**\n * The control mouseUpHandler, provide one to handle an effect on mouse up.\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare mouseUpHandler?: ControlActionHandler;\n\n shouldActivate(\n controlKey: string,\n fabricObject: InteractiveFabricObject,\n pointer: Point,\n { tl, tr, br, bl }: TCornerPoint,\n ) {\n // TODO: locking logic can be handled here instead of in the control handler logic\n return (\n fabricObject.canvas?.getActiveObject() === fabricObject &&\n fabricObject.isControlVisible(controlKey) &&\n Intersection.isPointInPolygon(pointer, [tl, tr, br, bl])\n );\n }\n\n /**\n * Returns control actionHandler\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getActionHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): TransformActionHandler | undefined {\n return this.actionHandler;\n }\n\n /**\n * Returns control mouseDown handler\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getMouseDownHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): ControlActionHandler | undefined {\n return this.mouseDownHandler;\n }\n\n /**\n * Returns control mouseUp handler.\n * During actions the fabricObject or the control can be of different obj\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getMouseUpHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): ControlActionHandler | undefined {\n return this.mouseUpHandler;\n }\n\n /**\n * Returns control cursorStyle for css using cursorStyle. If you need a more elaborate\n * function you can pass one in the constructor\n * the cursorStyle property\n * @param {Event} eventData the native mouse event\n * @param {Control} control the current control ( likely this)\n * @param {FabricObject} object on which the control is displayed\n * @return {String}\n */\n cursorStyleHandler(\n eventData: TPointerEvent,\n control: Control,\n fabricObject: InteractiveFabricObject,\n ) {\n return control.cursorStyle;\n }\n\n /**\n * Returns the action name. The basic implementation just return the actionName property.\n * @param {Event} eventData the native mouse event\n * @param {Control} control the current control ( likely this)\n * @param {FabricObject} object on which the control is displayed\n * @return {String}\n */\n getActionName(\n eventData: TPointerEvent,\n control: Control,\n fabricObject: InteractiveFabricObject,\n ) {\n return control.actionName;\n }\n\n /**\n * Returns controls visibility\n * @param {FabricObject} object on which the control is displayed\n * @param {String} controlKey key where the control is memorized on the\n * @return {Boolean}\n */\n getVisibility(fabricObject: InteractiveFabricObject, controlKey: string) {\n return fabricObject._controlsVisibility?.[controlKey] ?? this.visible;\n }\n\n /**\n * Sets controls visibility\n * @param {Boolean} visibility for the object\n * @return {Void}\n */\n setVisibility(\n visibility: boolean,\n name: string,\n fabricObject: InteractiveFabricObject,\n ) {\n this.visible = visibility;\n }\n\n positionHandler(\n dim: Point,\n finalMatrix: TMat2D,\n fabricObject: InteractiveFabricObject,\n currentControl: Control,\n ) {\n return new Point(\n this.x * dim.x + this.offsetX,\n this.y * dim.y + this.offsetY,\n ).transform(finalMatrix);\n }\n\n /**\n * Returns the coords for this control based on object values.\n * @param {Number} objectAngle angle from the fabric object holding the control\n * @param {Number} objectCornerSize cornerSize from the fabric object holding the control (or touchCornerSize if\n * isTouch is true)\n * @param {Number} centerX x coordinate where the control center should be\n * @param {Number} centerY y coordinate where the control center should be\n * @param {boolean} isTouch true if touch corner, false if normal corner\n */\n calcCornerCoords(\n angle: TDegree,\n objectCornerSize: number,\n centerX: number,\n centerY: number,\n isTouch: boolean,\n fabricObject: InteractiveFabricObject,\n ) {\n const t = multiplyTransformMatrixArray([\n createTranslateMatrix(centerX, centerY),\n createRotateMatrix({ angle }),\n createScaleMatrix(\n (isTouch ? this.touchSizeX : this.sizeX) || objectCornerSize,\n (isTouch ? this.touchSizeY : this.sizeY) || objectCornerSize,\n ),\n ]);\n return {\n tl: new Point(-0.5, -0.5).transform(t),\n tr: new Point(0.5, -0.5).transform(t),\n br: new Point(0.5, 0.5).transform(t),\n bl: new Point(-0.5, 0.5).transform(t),\n };\n }\n\n /**\n * Render function for the control.\n * When this function runs the context is unscaled. unrotate. Just retina scaled.\n * all the functions will have to translate to the point left,top before starting Drawing\n * if they want to draw a control where the position is detected.\n * left and top are the result of the positionHandler function\n * @param {RenderingContext2D} ctx the context where the control will be drawn\n * @param {Number} left position of the canvas where we are about to render the control.\n * @param {Number} top position of the canvas where we are about to render the control.\n * @param {Object} styleOverride\n * @param {FabricObject} fabricObject the object where the control is about to be rendered\n */\n render(\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride | undefined,\n fabricObject: InteractiveFabricObject,\n ) {\n styleOverride = styleOverride || {};\n switch (styleOverride.cornerStyle || fabricObject.cornerStyle) {\n case 'circle':\n renderCircleControl.call(\n this,\n ctx,\n left,\n top,\n styleOverride,\n fabricObject,\n );\n break;\n default:\n renderSquareControl.call(\n this,\n ctx,\n left,\n top,\n styleOverride,\n fabricObject,\n );\n }\n }\n}\n"],"names":["Control","constructor","options","_defineProperty","SCALE","Object","assign","shouldActivate","controlKey","fabricObject","pointer","_ref","_fabricObject$canvas","tl","tr","br","bl","canvas","getActiveObject","isControlVisible","Intersection","isPointInPolygon","getActionHandler","eventData","control","actionHandler","getMouseDownHandler","mouseDownHandler","getMouseUpHandler","mouseUpHandler","cursorStyleHandler","cursorStyle","getActionName","actionName","getVisibility","_fabricObject$_contro","_fabricObject$_contro2","_controlsVisibility","visible","setVisibility","visibility","name","positionHandler","dim","finalMatrix","currentControl","Point","x","offsetX","y","offsetY","transform","calcCornerCoords","angle","objectCornerSize","centerX","centerY","isTouch","t","multiplyTransformMatrixArray","createTranslateMatrix","createRotateMatrix","createScaleMatrix","touchSizeX","sizeX","touchSizeY","sizeY","render","ctx","left","top","styleOverride","cornerStyle","renderCircleControl","call","renderSquareControl"],"mappings":";;;;;;;AAoBO,MAAMA,OAAO,CAAC;EAyHnBC,WAAWA,CAACC,OAA0B,EAAE;AAxHxC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AAPEC,IAAAA,eAAA,kBAQU,IAAI,CAAA,CAAA;AAEd;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAVEA,IAAAA,eAAA,qBAWaC,KAAK,CAAA,CAAA;AAElB;AACF;AACA;AACA;AACA;AACA;AACA;AANED,IAAAA,eAAA,gBAOQ,CAAC,CAAA,CAAA;AAET;AACF;AACA;AACA;AACA;AACA;AACA;AANEA,IAAAA,eAAA,YAOI,CAAC,CAAA,CAAA;AAEL;AACF;AACA;AACA;AACA;AACA;AACA;AANEA,IAAAA,eAAA,YAOI,CAAC,CAAA,CAAA;AAEL;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAXEA,IAAAA,eAAA,kBAYU,CAAC,CAAA,CAAA;AAEX;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,kBAMU,CAAC,CAAA,CAAA;AAEX;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,gBAMQ,CAAC,CAAA,CAAA;AAET;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,gBAMQ,CAAC,CAAA,CAAA;AAET;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,qBAMa,CAAC,CAAA,CAAA;AAEd;AACF;AACA;A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C7BC,IAAY,EACZC,GAAW,EACXC,aAAwD,EACxD9D,YAAqC,EACrC;AACA8D,IAAAA,aAAa,GAAGA,aAAa,IAAI,EAAE,CAAA;AACnC,IAAA,QAAQA,aAAa,CAACC,WAAW,IAAI/D,YAAY,CAAC+D,WAAW;AAC3D,MAAA,KAAK,QAAQ;AACXC,QAAAA,mBAAmB,CAACC,IAAI,CACtB,IAAI,EACJN,GAAG,EACHC,IAAI,EACJC,GAAG,EACHC,aAAa,EACb9D,YACF,CAAC,CAAA;AACD,QAAA,MAAA;AACF,MAAA;AACEkE,QAAAA,mBAAmB,CAACD,IAAI,CACtB,IAAI,EACJN,GAAG,EACHC,IAAI,EACJC,GAAG,EACHC,aAAa,EACb9D,YACF,CAAC,CAAA;AACL,KAAA;AACF,GAAA;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changeWidth.min.mjs","sources":["../../../src/controls/changeWidth.ts"],"sourcesContent":["import type { TransformActionHandler } from '../EventTypeDefs';\nimport { CENTER, LEFT, RESIZING, RIGHT } from '../constants';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { getLocalPoint, isTransformCentered } from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\n\n/**\n * Action handler to change object's width\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const changeObjectWidth: TransformActionHandler = (\n eventData,\n transform,\n x,\n y
|
|
1
|
+
{"version":3,"file":"changeWidth.min.mjs","sources":["../../../src/controls/changeWidth.ts"],"sourcesContent":["import type { TransformActionHandler } from '../EventTypeDefs';\nimport { CENTER, LEFT, RESIZING, RIGHT } from '../constants';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { getLocalPoint, isTransformCentered } from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\n\n/**\n * Action handler to change object's width\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const changeObjectWidth: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n const localPoint = getLocalPoint(\n transform,\n transform.originX,\n transform.originY,\n x,\n y,\n );\n // make sure the control changes width ONLY from it's side of target\n if (\n resolveOrigin(transform.originX) === resolveOrigin(CENTER) ||\n (resolveOrigin(transform.originX) === resolveOrigin(RIGHT) &&\n localPoint.x < 0) ||\n (resolveOrigin(transform.originX) === resolveOrigin(LEFT) &&\n localPoint.x > 0)\n ) {\n const { target } = transform,\n strokePadding =\n target.strokeWidth / (target.strokeUniform ? target.scaleX : 1),\n multiplier = isTransformCentered(transform) ? 2 : 1,\n oldWidth = target.width,\n newWidth = Math.ceil(\n Math.abs((localPoint.x * multiplier) / target.scaleX) - strokePadding,\n );\n target.set('width', Math.max(newWidth, 0));\n // check against actual target width in case `newWidth` was rejected\n return oldWidth !== target.width;\n }\n return false;\n};\n\nexport const changeWidth = wrapWithFireEvent(\n RESIZING,\n wrapWithFixedAnchor(changeObjectWidth),\n);\n"],"names":["changeObjectWidth","eventData","transform","x","y","localPoint","getLocalPoint","originX","originY","resolveOrigin","CENTER","RIGHT","LEFT","target","strokePadding","strokeWidth","strokeUniform","scaleX","multiplier","isTransformCentered","oldWidth","width","newWidth","Math","ceil","abs","set","max","changeWidth","wrapWithFireEvent","RESIZING","wrapWithFixedAnchor"],"mappings":"gWAgBO,MAAMA,EAA4CA,CACvDC,EACAC,EACAC,EACAC,KAEA,MAAMC,EAAaC,EACjBJ,EACAA,EAAUK,QACVL,EAAUM,QACVL,EACAC,GAGF,GACEK,EAAcP,EAAUK,WAAaE,EAAcC,IAClDD,EAAcP,EAAUK,WAAaE,EAAcE,IAClDN,EAAWF,EAAI,GAChBM,EAAcP,EAAUK,WAAaE,EAAcG,IAClDP,EAAWF,EAAI,EACjB,CACA,MAAMU,OAAEA,GAAWX,EACjBY,EACED,EAAOE,aAAeF,EAAOG,cAAgBH,EAAOI,OAAS,GAC/DC,EAAaC,EAAoBjB,GAAa,EAAI,EAClDkB,EAAWP,EAAOQ,MAClBC,EAAWC,KAAKC,KACdD,KAAKE,IAAKpB,EAAWF,EAAIe,EAAcL,EAAOI,QAAUH,GAI5D,OAFAD,EAAOa,IAAI,QAASH,KAAKI,IAAIL,EAAU,IAEhCF,IAAaP,EAAOQ,KAC7B,CACA,OAAO,CAAK,EAGDO,EAAcC,EACzBC,EACAC,EAAoB/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changeWidth.mjs","sources":["../../../src/controls/changeWidth.ts"],"sourcesContent":["import type { TransformActionHandler } from '../EventTypeDefs';\nimport { CENTER, LEFT, RESIZING, RIGHT } from '../constants';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { getLocalPoint, isTransformCentered } from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\n\n/**\n * Action handler to change object's width\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const changeObjectWidth: TransformActionHandler = (\n eventData,\n transform,\n x,\n y
|
|
1
|
+
{"version":3,"file":"changeWidth.mjs","sources":["../../../src/controls/changeWidth.ts"],"sourcesContent":["import type { TransformActionHandler } from '../EventTypeDefs';\nimport { CENTER, LEFT, RESIZING, RIGHT } from '../constants';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { getLocalPoint, isTransformCentered } from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\n\n/**\n * Action handler to change object's width\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const changeObjectWidth: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n const localPoint = getLocalPoint(\n transform,\n transform.originX,\n transform.originY,\n x,\n y,\n );\n // make sure the control changes width ONLY from it's side of target\n if (\n resolveOrigin(transform.originX) === resolveOrigin(CENTER) ||\n (resolveOrigin(transform.originX) === resolveOrigin(RIGHT) &&\n localPoint.x < 0) ||\n (resolveOrigin(transform.originX) === resolveOrigin(LEFT) &&\n localPoint.x > 0)\n ) {\n const { target } = transform,\n strokePadding =\n target.strokeWidth / (target.strokeUniform ? target.scaleX : 1),\n multiplier = isTransformCentered(transform) ? 2 : 1,\n oldWidth = target.width,\n newWidth = Math.ceil(\n Math.abs((localPoint.x * multiplier) / target.scaleX) - strokePadding,\n );\n target.set('width', Math.max(newWidth, 0));\n // check against actual target width in case `newWidth` was rejected\n return oldWidth !== target.width;\n }\n return false;\n};\n\nexport const changeWidth = wrapWithFireEvent(\n RESIZING,\n wrapWithFixedAnchor(changeObjectWidth),\n);\n"],"names":["changeObjectWidth","eventData","transform","x","y","localPoint","getLocalPoint","originX","originY","resolveOrigin","CENTER","RIGHT","LEFT","target","strokePadding","strokeWidth","strokeUniform","scaleX","multiplier","isTransformCentered","oldWidth","width","newWidth","Math","ceil","abs","set","max","changeWidth","wrapWithFireEvent","RESIZING","wrapWithFixedAnchor"],"mappings":";;;;;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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W,GAAGC,iBAAiB,CAC1CC,QAAQ,EACRC,mBAAmB,CAAC/B,iBAAiB,CACvC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controlRendering.min.mjs","sources":["../../../src/controls/controlRendering.ts"],"sourcesContent":["import { FILL, STROKE, twoMathPi } from '../constants';\nimport type { InteractiveFabricObject } from '../shapes/Object/InteractiveObject';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport type { Control } from './Control';\n\nexport type ControlRenderingStyleOverride = Partial<\n Pick<\n InteractiveFabricObject,\n | 'cornerStyle'\n | 'cornerSize'\n | 'cornerColor'\n | 'cornerStrokeColor'\n | 'cornerDashArray'\n | 'transparentCorners'\n >\n>;\n\nexport type ControlRenderer<\n O extends InteractiveFabricObject = InteractiveFabricObject
|
|
1
|
+
{"version":3,"file":"controlRendering.min.mjs","sources":["../../../src/controls/controlRendering.ts"],"sourcesContent":["import { FILL, STROKE, twoMathPi } from '../constants';\nimport type { InteractiveFabricObject } from '../shapes/Object/InteractiveObject';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport type { Control } from './Control';\n\nexport type ControlRenderingStyleOverride = Partial<\n Pick<\n InteractiveFabricObject,\n | 'cornerStyle'\n | 'cornerSize'\n | 'cornerColor'\n | 'cornerStrokeColor'\n | 'cornerDashArray'\n | 'transparentCorners'\n >\n>;\n\nexport type ControlRenderer<\n O extends InteractiveFabricObject = InteractiveFabricObject,\n> = (\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride,\n fabricObject: O,\n) => void;\n\n/**\n * Render a round control, as per fabric features.\n * This function is written to respect object properties like transparentCorners, cornerSize\n * cornerColor, cornerStrokeColor\n * plus the addition of offsetY and offsetX.\n * @param {CanvasRenderingContext2D} ctx context to render on\n * @param {Number} left x coordinate where the control center should be\n * @param {Number} top y coordinate where the control center should be\n * @param {Object} styleOverride override for FabricObject controls style\n * @param {FabricObject} fabricObject the fabric object for which we are rendering controls\n */\nexport function renderCircleControl(\n this: Control,\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride,\n fabricObject: InteractiveFabricObject,\n) {\n styleOverride = styleOverride || {};\n const xSize =\n this.sizeX || styleOverride.cornerSize || fabricObject.cornerSize,\n ySize = this.sizeY || styleOverride.cornerSize || fabricObject.cornerSize,\n transparentCorners =\n typeof styleOverride.transparentCorners !== 'undefined'\n ? styleOverride.transparentCorners\n : fabricObject.transparentCorners,\n methodName = transparentCorners ? STROKE : FILL,\n stroke =\n !transparentCorners &&\n (styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor);\n let myLeft = left,\n myTop = top,\n size;\n ctx.save();\n ctx.fillStyle = styleOverride.cornerColor || fabricObject.cornerColor || '';\n ctx.strokeStyle =\n styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor || '';\n // TODO: use proper ellipse code.\n if (xSize > ySize) {\n size = xSize;\n ctx.scale(1.0, ySize / xSize);\n myTop = (top * xSize) / ySize;\n } else if (ySize > xSize) {\n size = ySize;\n ctx.scale(xSize / ySize, 1.0);\n myLeft = (left * ySize) / xSize;\n } else {\n size = xSize;\n }\n // this is still wrong\n ctx.lineWidth = 1;\n ctx.beginPath();\n ctx.arc(myLeft, myTop, size / 2, 0, twoMathPi, false);\n ctx[methodName]();\n if (stroke) {\n ctx.stroke();\n }\n ctx.restore();\n}\n\n/**\n * Render a square control, as per fabric features.\n * This function is written to respect object properties like transparentCorners, cornerSize\n * cornerColor, cornerStrokeColor\n * plus the addition of offsetY and offsetX.\n * @param {CanvasRenderingContext2D} ctx context to render on\n * @param {Number} left x coordinate where the control center should be\n * @param {Number} top y coordinate where the control center should be\n * @param {Object} styleOverride override for FabricObject controls style\n * @param {FabricObject} fabricObject the fabric object for which we are rendering controls\n */\nexport function renderSquareControl(\n this: Control,\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride,\n fabricObject: InteractiveFabricObject,\n) {\n styleOverride = styleOverride || {};\n const xSize =\n this.sizeX || styleOverride.cornerSize || fabricObject.cornerSize,\n ySize = this.sizeY || styleOverride.cornerSize || fabricObject.cornerSize,\n transparentCorners =\n typeof styleOverride.transparentCorners !== 'undefined'\n ? styleOverride.transparentCorners\n : fabricObject.transparentCorners,\n methodName = transparentCorners ? STROKE : FILL,\n stroke =\n !transparentCorners &&\n (styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor),\n xSizeBy2 = xSize / 2,\n ySizeBy2 = ySize / 2;\n ctx.save();\n ctx.fillStyle = styleOverride.cornerColor || fabricObject.cornerColor || '';\n ctx.strokeStyle =\n styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor || '';\n // this is still wrong\n ctx.lineWidth = 1;\n ctx.translate(left, top);\n // angle is relative to canvas plane\n const angle = fabricObject.getTotalAngle();\n ctx.rotate(degreesToRadians(angle));\n // this does not work, and fixed with ( && ) does not make sense.\n // to have real transparent corners we need the controls on upperCanvas\n // transparentCorners || ctx.clearRect(-xSizeBy2, -ySizeBy2, xSize, ySize);\n ctx[`${methodName}Rect`](-xSizeBy2, -ySizeBy2, xSize, ySize);\n if (stroke) {\n ctx.strokeRect(-xSizeBy2, -ySizeBy2, xSize, ySize);\n }\n ctx.restore();\n}\n"],"names":["renderCircleControl","ctx","left","top","styleOverride","fabricObject","xSize","this","sizeX","cornerSize","ySize","sizeY","transparentCorners","methodName","STROKE","FILL","stroke","cornerStrokeColor","size","myLeft","myTop","save","fillStyle","cornerColor","strokeStyle","scale","lineWidth","beginPath","arc","twoMathPi","restore","renderSquareControl","xSizeBy2","ySizeBy2","translate","angle","getTotalAngle","rotate","degreesToRadians","concat","strokeRect"],"mappings":"wJAsCO,SAASA,EAEdC,EACAC,EACAC,EACAC,EACAC,GAEAD,EAAgBA,GAAiB,GACjC,MAAME,EACFC,KAAKC,OAASJ,EAAcK,YAAcJ,EAAaI,WACzDC,EAAQH,KAAKI,OAASP,EAAcK,YA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