fabric 7.0.0 → 7.2.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/.husky/pre-commit +1 -0
- package/CHANGELOG.md +21 -0
- package/dist/extensions/cropping_controls/croppingControls.d.ts +16 -0
- package/dist/extensions/cropping_controls/croppingControls.d.ts.map +1 -0
- package/dist/extensions/cropping_controls/croppingHandlers.d.ts +39 -0
- package/dist/extensions/cropping_controls/croppingHandlers.d.ts.map +1 -0
- package/dist/extensions/cropping_controls/enterCropMode.d.ts +7 -0
- package/dist/extensions/cropping_controls/enterCropMode.d.ts.map +1 -0
- package/dist/extensions/cropping_controls/renderCornerControl.d.ts +14 -0
- package/dist/extensions/cropping_controls/renderCornerControl.d.ts.map +1 -0
- package/dist/extensions/index.d.ts +3 -0
- package/dist/extensions/index.d.ts.map +1 -1
- package/dist/fabric.d.ts +1 -0
- package/dist/fabric.d.ts.map +1 -1
- package/dist/index.js +628 -537
- 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 +628 -537
- package/dist/index.mjs.map +1 -1
- package/dist/index.node.cjs +628 -537
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +628 -537
- 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/EventTypeDefs.d.ts +5 -0
- package/dist/src/EventTypeDefs.d.ts.map +1 -1
- 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 +2 -1
- package/dist/src/Pattern/Pattern.mjs.map +1 -1
- package/dist/src/Shadow.d.ts +1 -1
- package/dist/src/Shadow.d.ts.map +1 -1
- package/dist/src/Shadow.min.mjs +1 -1
- package/dist/src/Shadow.min.mjs.map +1 -1
- package/dist/src/Shadow.mjs +5 -4
- package/dist/src/Shadow.mjs.map +1 -1
- package/dist/src/canvas/CanvasOptions.d.ts.map +1 -1
- package/dist/src/canvas/CanvasOptions.min.mjs.map +1 -1
- package/dist/src/canvas/CanvasOptions.mjs.map +1 -1
- package/dist/src/canvas/SelectableCanvas.d.ts +2 -0
- package/dist/src/canvas/SelectableCanvas.d.ts.map +1 -1
- package/dist/src/canvas/SelectableCanvas.min.mjs +1 -1
- package/dist/src/canvas/SelectableCanvas.min.mjs.map +1 -1
- package/dist/src/canvas/SelectableCanvas.mjs +33 -13
- package/dist/src/canvas/SelectableCanvas.mjs.map +1 -1
- package/dist/src/canvas/StaticCanvas.d.ts.map +1 -1
- package/dist/src/canvas/StaticCanvas.min.mjs +1 -1
- package/dist/src/canvas/StaticCanvas.min.mjs.map +1 -1
- package/dist/src/canvas/StaticCanvas.mjs +3 -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/constants.d.ts +1 -0
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.min.mjs.map +1 -1
- package/dist/src/constants.mjs.map +1 -1
- package/dist/src/controls/Control.d.ts +22 -1
- package/dist/src/controls/Control.d.ts.map +1 -1
- package/dist/src/controls/Control.min.mjs +1 -1
- package/dist/src/controls/Control.min.mjs.map +1 -1
- package/dist/src/controls/Control.mjs +45 -1
- package/dist/src/controls/Control.mjs.map +1 -1
- package/dist/src/controls/changeWidth.d.ts +22 -0
- package/dist/src/controls/changeWidth.d.ts.map +1 -1
- package/dist/src/controls/changeWidth.min.mjs +1 -1
- package/dist/src/controls/changeWidth.min.mjs.map +1 -1
- package/dist/src/controls/changeWidth.mjs +46 -18
- package/dist/src/controls/changeWidth.mjs.map +1 -1
- package/dist/src/controls/controlRendering.d.ts.map +1 -1
- package/dist/src/controls/controlRendering.min.mjs +1 -1
- package/dist/src/controls/controlRendering.min.mjs.map +1 -1
- package/dist/src/controls/controlRendering.mjs +18 -34
- package/dist/src/controls/controlRendering.mjs.map +1 -1
- package/dist/src/controls/index.d.ts +2 -1
- package/dist/src/controls/index.d.ts.map +1 -1
- package/dist/src/controls/index.min.mjs +1 -1
- package/dist/src/controls/index.mjs +1 -1
- 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 +19 -6
- package/dist/src/gradient/Gradient.mjs.map +1 -1
- package/dist/src/shapes/Circle.d.ts.map +1 -1
- package/dist/src/shapes/Circle.min.mjs +1 -1
- package/dist/src/shapes/Circle.min.mjs.map +1 -1
- package/dist/src/shapes/Circle.mjs +10 -7
- package/dist/src/shapes/Circle.mjs.map +1 -1
- package/dist/src/shapes/Ellipse.d.ts.map +1 -1
- package/dist/src/shapes/Ellipse.min.mjs +1 -1
- package/dist/src/shapes/Ellipse.min.mjs.map +1 -1
- package/dist/src/shapes/Ellipse.mjs +2 -1
- package/dist/src/shapes/Ellipse.mjs.map +1 -1
- package/dist/src/shapes/Group.d.ts.map +1 -1
- package/dist/src/shapes/Group.min.mjs +1 -1
- package/dist/src/shapes/Group.min.mjs.map +1 -1
- package/dist/src/shapes/Group.mjs +2 -1
- package/dist/src/shapes/Group.mjs.map +1 -1
- package/dist/src/shapes/IText/IText.d.ts.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/Image.d.ts +1 -1
- package/dist/src/shapes/Image.d.ts.map +1 -1
- package/dist/src/shapes/Image.min.mjs +1 -1
- package/dist/src/shapes/Image.min.mjs.map +1 -1
- package/dist/src/shapes/Image.mjs +4 -3
- package/dist/src/shapes/Image.mjs.map +1 -1
- package/dist/src/shapes/Line.d.ts.map +1 -1
- package/dist/src/shapes/Line.min.mjs +1 -1
- package/dist/src/shapes/Line.min.mjs.map +1 -1
- package/dist/src/shapes/Line.mjs +6 -10
- package/dist/src/shapes/Line.mjs.map +1 -1
- package/dist/src/shapes/Object/FabricObjectSVGExportMixin.d.ts.map +1 -1
- package/dist/src/shapes/Object/FabricObjectSVGExportMixin.min.mjs +1 -1
- package/dist/src/shapes/Object/FabricObjectSVGExportMixin.min.mjs.map +1 -1
- package/dist/src/shapes/Object/FabricObjectSVGExportMixin.mjs +5 -4
- package/dist/src/shapes/Object/FabricObjectSVGExportMixin.mjs.map +1 -1
- 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.map +1 -1
- 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 +3 -0
- package/dist/src/shapes/Object/Object.mjs.map +1 -1
- package/dist/src/shapes/Object/ObjectGeometry.min.mjs +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/types/FabricObjectProps.d.ts.map +1 -1
- package/dist/src/shapes/Object/types/ObjectProps.d.ts.map +1 -1
- package/dist/src/shapes/Path.d.ts.map +1 -1
- package/dist/src/shapes/Path.min.mjs.map +1 -1
- package/dist/src/shapes/Path.mjs +1 -2
- 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 -6
- package/dist/src/shapes/Polyline.mjs.map +1 -1
- package/dist/src/shapes/Rect.d.ts.map +1 -1
- package/dist/src/shapes/Rect.min.mjs +1 -1
- package/dist/src/shapes/Rect.min.mjs.map +1 -1
- package/dist/src/shapes/Rect.mjs +2 -1
- package/dist/src/shapes/Rect.mjs.map +1 -1
- package/dist/src/shapes/Text/StyledText.d.ts.map +1 -1
- package/dist/src/shapes/Text/StyledText.min.mjs.map +1 -1
- package/dist/src/shapes/Text/StyledText.mjs +0 -3
- package/dist/src/shapes/Text/StyledText.mjs.map +1 -1
- package/dist/src/shapes/Text/Text.d.ts.map +1 -1
- package/dist/src/shapes/Text/Text.min.mjs.map +1 -1
- package/dist/src/shapes/Text/Text.mjs.map +1 -1
- package/dist/src/shapes/Text/TextSVGExportMixin.d.ts.map +1 -1
- package/dist/src/shapes/Text/TextSVGExportMixin.min.mjs +1 -1
- package/dist/src/shapes/Text/TextSVGExportMixin.min.mjs.map +1 -1
- package/dist/src/shapes/Text/TextSVGExportMixin.mjs +5 -6
- package/dist/src/shapes/Text/TextSVGExportMixin.mjs.map +1 -1
- package/dist/src/shapes/Textbox.d.ts.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.d.ts.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/lang_string.d.ts +1 -1
- package/dist/src/util/lang_string.d.ts.map +1 -1
- package/dist/src/util/lang_string.min.mjs +1 -1
- package/dist/src/util/lang_string.min.mjs.map +1 -1
- package/dist/src/util/lang_string.mjs +1 -1
- package/dist/src/util/lang_string.mjs.map +1 -1
- package/dist/src/util/misc/svgParsing.d.ts.map +1 -1
- package/dist/src/util/misc/svgParsing.min.mjs +1 -1
- package/dist/src/util/misc/svgParsing.min.mjs.map +1 -1
- package/dist/src/util/misc/svgParsing.mjs +2 -1
- package/dist/src/util/misc/svgParsing.mjs.map +1 -1
- package/dist-extensions/cropping_controls/croppingControls.mjs +140 -0
- package/dist-extensions/cropping_controls/croppingControls.mjs.map +1 -0
- package/dist-extensions/cropping_controls/croppingHandlers.mjs +228 -0
- package/dist-extensions/cropping_controls/croppingHandlers.mjs.map +1 -0
- package/dist-extensions/cropping_controls/enterCropMode.mjs +38 -0
- package/dist-extensions/cropping_controls/enterCropMode.mjs.map +1 -0
- package/dist-extensions/cropping_controls/renderCornerControl.mjs +45 -0
- package/dist-extensions/cropping_controls/renderCornerControl.mjs.map +1 -0
- package/dist-extensions/extensions/cropping_controls/croppingControls.d.ts +16 -0
- package/dist-extensions/extensions/cropping_controls/croppingControls.d.ts.map +1 -0
- package/dist-extensions/extensions/cropping_controls/croppingHandlers.d.ts +39 -0
- package/dist-extensions/extensions/cropping_controls/croppingHandlers.d.ts.map +1 -0
- package/dist-extensions/extensions/cropping_controls/enterCropMode.d.ts +7 -0
- package/dist-extensions/extensions/cropping_controls/enterCropMode.d.ts.map +1 -0
- package/dist-extensions/extensions/cropping_controls/renderCornerControl.d.ts +14 -0
- package/dist-extensions/extensions/cropping_controls/renderCornerControl.d.ts.map +1 -0
- package/dist-extensions/extensions/index.d.ts +3 -0
- package/dist-extensions/extensions/index.d.ts.map +1 -1
- package/dist-extensions/fabric-extensions.min.js +1 -1
- package/dist-extensions/fabric-extensions.min.js.map +1 -1
- package/dist-extensions/fabric.d.ts +1 -0
- package/dist-extensions/fabric.d.ts.map +1 -1
- package/dist-extensions/index.mjs +3 -0
- package/dist-extensions/index.mjs.map +1 -1
- package/dist-extensions/src/EventTypeDefs.d.ts +5 -0
- package/dist-extensions/src/EventTypeDefs.d.ts.map +1 -1
- package/dist-extensions/src/Pattern/Pattern.d.ts.map +1 -1
- package/dist-extensions/src/Shadow.d.ts +1 -1
- package/dist-extensions/src/Shadow.d.ts.map +1 -1
- package/dist-extensions/src/canvas/CanvasOptions.d.ts.map +1 -1
- package/dist-extensions/src/canvas/SelectableCanvas.d.ts +2 -0
- package/dist-extensions/src/canvas/SelectableCanvas.d.ts.map +1 -1
- package/dist-extensions/src/canvas/StaticCanvas.d.ts.map +1 -1
- package/dist-extensions/src/canvas/StaticCanvasOptions.d.ts.map +1 -1
- package/dist-extensions/src/constants.d.ts +1 -0
- package/dist-extensions/src/constants.d.ts.map +1 -1
- package/dist-extensions/src/controls/Control.d.ts +22 -1
- package/dist-extensions/src/controls/Control.d.ts.map +1 -1
- package/dist-extensions/src/controls/changeWidth.d.ts +22 -0
- package/dist-extensions/src/controls/changeWidth.d.ts.map +1 -1
- package/dist-extensions/src/controls/controlRendering.d.ts.map +1 -1
- package/dist-extensions/src/controls/index.d.ts +2 -1
- package/dist-extensions/src/controls/index.d.ts.map +1 -1
- package/dist-extensions/src/gradient/Gradient.d.ts.map +1 -1
- package/dist-extensions/src/shapes/Circle.d.ts.map +1 -1
- package/dist-extensions/src/shapes/Ellipse.d.ts.map +1 -1
- package/dist-extensions/src/shapes/Group.d.ts.map +1 -1
- package/dist-extensions/src/shapes/IText/IText.d.ts.map +1 -1
- package/dist-extensions/src/shapes/Image.d.ts.map +1 -1
- package/dist-extensions/src/shapes/Line.d.ts.map +1 -1
- package/dist-extensions/src/shapes/Object/FabricObjectSVGExportMixin.d.ts.map +1 -1
- package/dist-extensions/src/shapes/Object/InteractiveObject.d.ts.map +1 -1
- package/dist-extensions/src/shapes/Object/Object.d.ts.map +1 -1
- package/dist-extensions/src/shapes/Object/types/FabricObjectProps.d.ts.map +1 -1
- package/dist-extensions/src/shapes/Object/types/ObjectProps.d.ts.map +1 -1
- package/dist-extensions/src/shapes/Path.d.ts +1 -1
- package/dist-extensions/src/shapes/Path.d.ts.map +1 -1
- package/dist-extensions/src/shapes/Polyline.d.ts.map +1 -1
- package/dist-extensions/src/shapes/Rect.d.ts.map +1 -1
- package/dist-extensions/src/shapes/Text/StyledText.d.ts.map +1 -1
- package/dist-extensions/src/shapes/Text/Text.d.ts.map +1 -1
- package/dist-extensions/src/shapes/Text/TextSVGExportMixin.d.ts.map +1 -1
- package/dist-extensions/src/shapes/Textbox.d.ts.map +1 -1
- package/dist-extensions/src/shapes/Triangle.d.ts.map +1 -1
- package/dist-extensions/src/util/lang_string.d.ts +1 -1
- package/dist-extensions/src/util/lang_string.d.ts.map +1 -1
- package/dist-extensions/src/util/misc/svgParsing.d.ts.map +1 -1
- package/eslint.config.mjs +2 -0
- package/extensions/cropping_controls/croppingControls.spec.ts +115 -0
- package/extensions/cropping_controls/croppingControls.ts +150 -0
- package/extensions/cropping_controls/croppingHandlers.spec.ts +579 -0
- package/extensions/cropping_controls/croppingHandlers.ts +285 -0
- package/extensions/cropping_controls/enterCropMode.ts +30 -0
- package/extensions/cropping_controls/renderCornerControl.ts +53 -0
- package/extensions/index.ts +9 -0
- package/fabric.ts +1 -0
- package/package.json +17 -8
- package/src/ClassRegistry.spec.ts +18 -19
- package/src/EventTypeDefs.ts +15 -11
- package/src/Pattern/Pattern.spec.ts +12 -0
- package/src/Pattern/Pattern.ts +3 -2
- package/src/Shadow.ts +9 -8
- package/src/brushes/PencilBrush.spec.ts +11 -11
- package/src/canvas/Canvas-dispose.spec.ts +8 -7
- package/src/canvas/Canvas.spec.ts +27 -29
- package/src/canvas/CanvasOptions.ts +2 -1
- package/src/canvas/SelectableCanvas.ts +38 -15
- package/src/canvas/StaticCanvas.spec.ts +20 -0
- package/src/canvas/StaticCanvas.ts +7 -4
- package/src/canvas/StaticCanvasOptions.ts +1 -3
- package/src/constants.ts +1 -0
- package/src/controls/Control.spec.ts +102 -0
- package/src/controls/Control.ts +71 -2
- package/src/controls/changeHeight.spec.ts +147 -0
- package/src/controls/changeWidth.ts +68 -35
- package/src/controls/controlRendering.ts +20 -48
- package/src/controls/index.ts +7 -1
- package/src/gradient/Gradient.spec.ts +101 -46
- package/src/gradient/Gradient.ts +27 -14
- package/src/shapes/Circle.spec.ts +10 -39
- package/src/shapes/Circle.ts +11 -11
- package/src/shapes/Ellipse.spec.ts +8 -37
- package/src/shapes/Ellipse.ts +7 -7
- package/src/shapes/Group.ts +3 -3
- package/src/shapes/IText/IText-click-behavior.spec.ts +36 -49
- package/src/shapes/IText/IText.ts +5 -6
- package/src/shapes/IText/ITextKeyBehavior.test.ts +0 -1
- package/src/shapes/IText/__snapshots__/ITextBehavior.test.ts.snap +6 -6
- package/src/shapes/Image.spec.ts +17 -33
- package/src/shapes/Image.ts +15 -11
- package/src/shapes/Line.spec.ts +4 -30
- package/src/shapes/Line.ts +11 -16
- package/src/shapes/Object/FabricObjectSVGExportMixin.ts +11 -4
- package/src/shapes/Object/InteractiveObject.ts +4 -4
- package/src/shapes/Object/Object.ts +6 -5
- package/src/shapes/Object/ObjectGeometry.spec.ts +15 -0
- package/src/shapes/Object/ObjectGeometry.ts +1 -1
- package/src/shapes/Object/objectSvgExport.spec.ts +112 -0
- package/src/shapes/Object/types/FabricObjectProps.ts +1 -4
- package/src/shapes/Object/types/ObjectProps.ts +1 -3
- package/src/shapes/Path.spec.ts +4 -27
- package/src/shapes/Path.ts +2 -4
- package/src/shapes/Polygon.spec.ts +4 -31
- package/src/shapes/Polyline.spec.ts +4 -31
- package/src/shapes/Polyline.ts +11 -12
- package/src/shapes/Rect.spec.ts +25 -33
- package/src/shapes/Rect.ts +7 -7
- package/src/shapes/Text/StyledText.ts +0 -3
- package/src/shapes/Text/Text.spec.ts +3 -32
- package/src/shapes/Text/Text.ts +5 -6
- package/src/shapes/Text/TextSVGExportMixin.spec.ts +9 -0
- package/src/shapes/Text/TextSVGExportMixin.ts +14 -16
- package/src/shapes/Text/__snapshots__/Text.spec.ts.snap +1 -1
- package/src/shapes/Text/__snapshots__/TextSVGExportMixin.spec.ts.snap +1 -1
- package/src/shapes/Textbox.spec.ts +5 -5
- package/src/shapes/Textbox.ts +6 -5
- package/src/shapes/Triangle.ts +4 -4
- package/src/shapes/__snapshots__/Image.spec.ts.snap +4 -4
- package/src/shapes/__snapshots__/Textbox.spec.ts.snap +5 -5
- package/src/util/lang_string.ts +3 -2
- package/src/util/misc/svgParsing.ts +2 -1
- package/tsconfig.spec.json +1 -0
- package/vitest.config.ts +12 -2
- package/vitest.extend.ts +6 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var r="7.
|
|
1
|
+
var r="7.2.0";export{r as version};
|
|
2
2
|
//# sourceMappingURL=package.json.min.mjs.map
|
package/dist/package.json.mjs
CHANGED
|
@@ -55,6 +55,8 @@ export type Transform = {
|
|
|
55
55
|
original: ReturnType<typeof saveObjectTransform> & {
|
|
56
56
|
originX: TOriginX;
|
|
57
57
|
originY: TOriginY;
|
|
58
|
+
cropX?: number;
|
|
59
|
+
cropY?: number;
|
|
58
60
|
};
|
|
59
61
|
actionPerformed: boolean;
|
|
60
62
|
};
|
|
@@ -221,6 +223,9 @@ export interface ObjectEvents extends ObjectPointerEvents, DnDEvents, MiscEvents
|
|
|
221
223
|
'erasing:end': {
|
|
222
224
|
path: FabricObject;
|
|
223
225
|
};
|
|
226
|
+
'before:render': {
|
|
227
|
+
ctx: CanvasRenderingContext2D;
|
|
228
|
+
};
|
|
224
229
|
}
|
|
225
230
|
export interface StaticCanvasEvents extends CollectionEvents {
|
|
226
231
|
'canvas:cleared': never;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventTypeDefs.d.ts","sourceRoot":"","sources":["../../src/EventTypeDefs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA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MAAM,CAAC,MAAM,EAAE;IAAE,eAAe,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pattern.d.ts","sourceRoot":"","sources":["../../../src/Pattern/Pattern.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAO1E,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,wBAAwB,EACzB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"Pattern.d.ts","sourceRoot":"","sources":["../../../src/Pattern/Pattern.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAO1E,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAIjB;;;GAGG;AACH,qBAAa,OAAO;IAClB,MAAM,CAAC,IAAI,SAAa;IAExB;;;;;;;OAOG;IACH,IAAI,IAAI,WAEP;IAED,IAAI,IAAI,CAAC,KAAK,QAAA,EAEb;IAED;;;OAGG;IACH,MAAM,EAAE,aAAa,CAAY;IAEjC;;;OAGG;IACH,OAAO,SAAK;IAEZ;;;OAGG;IACH,OAAO,SAAK;IAEZ;;OAEG;IACH,WAAW,EAAE,YAAY,CAAM;IAE/B;;;;OAIG;IACK,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAElC;;OAEG;IACK,MAAM,EAAE,iBAAiB,CAAC;IAElC;;;OAGG;IACK,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAEpC;;;OAGG;IACH,SAAiB,EAAE,EAAE,MAAM,CAAC;IAE5B;;;;OAIG;gBACS,OAAO,EAAE,cAAc;IAKnC;;OAEG;IACH,aAAa,IAAI,IAAI,IAAI;QAAE,MAAM,EAAE,gBAAgB,CAAA;KAAE;IAMrD;;OAEG;IACH,cAAc,IAAI,IAAI,IAAI;QAAE,MAAM,EAAE,iBAAiB,CAAA;KAAE;IAIvD,cAAc,IAAI,MAAM;IAQxB;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,wBAAwB,GAAG,aAAa,GAAG,IAAI;IAgB3D;;;;OAIG;IACH,QAAQ,CAAC,mBAAmB,GAAE,MAAM,EAAO,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAiBjE;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,KAAK,GAAG,MAAM;WA0B1B,UAAU,CACrB,EACE,IAAI,EACJ,MAAM,EACN,gBAAgB,EAChB,GAAG,YAAY,EAChB,EAAE,wBAAwB,EAC3B,OAAO,CAAC,EAAE,SAAS,GAClB,OAAO,CAAC,OAAO,CAAC;CAYpB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{defineProperty as t}from"../../_virtual/_rollupPluginBabelHelpers.min.mjs";import{config as
|
|
1
|
+
import{defineProperty as t}from"../../_virtual/_rollupPluginBabelHelpers.min.mjs";import{config as s}from"../config.min.mjs";import{ifNaN as e}from"../util/internals/ifNaN.min.mjs";import{uid as r}from"../util/internals/uid.min.mjs";import{loadImage as i}from"../util/misc/objectEnlive.min.mjs";import{pick as o}from"../util/misc/pick.min.mjs";import{toFixed as n}from"../util/misc/toFixed.min.mjs";import{classRegistry as a}from"../ClassRegistry.min.mjs";import{log as h}from"../util/internals/console.min.mjs";import{escapeXml as m}from"../util/lang_string.min.mjs";class c{get type(){return"pattern"}set type(t){h("warn","Setting type has no effect",t)}constructor(s){t(this,"repeat","repeat"),t(this,"offsetX",0),t(this,"offsetY",0),t(this,"crossOrigin",""),this.id=r(),Object.assign(this,s)}isImageSource(){return!!this.source&&"string"==typeof this.source.src}isCanvasSource(){return!!this.source&&!!this.source.toDataURL}sourceToString(){return this.isImageSource()?this.source.src:this.isCanvasSource()?this.source.toDataURL():""}toLive(t){return this.source&&(!this.isImageSource()||this.source.complete&&0!==this.source.naturalWidth&&0!==this.source.naturalHeight)?t.createPattern(this.source,this.repeat):null}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const{repeat:e,crossOrigin:r}=this;return{...o(this,t),type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:r,offsetX:n(this.offsetX,s.NUM_FRACTION_DIGITS),offsetY:n(this.offsetY,s.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null}}toSVG(t){let{width:s,height:r}=t;const{source:i,repeat:o,id:n}=this,a=e(this.offsetX/s,0),h=e(this.offsetY/r,0),c="repeat-y"===o||"no-repeat"===o?1+Math.abs(a||0):e(i.width/s,0),u="repeat-x"===o||"no-repeat"===o?1+Math.abs(h||0):e(i.height/r,0);return[`<pattern id="SVGID_${m(n)}" x="${a}" y="${h}" width="${c}" height="${u}">`,`<image x="0" y="0" width="${i.width}" height="${i.height}" xlink:href="${m(this.sourceToString())}"></image>`,"</pattern>",""].join("\n")}static async fromObject(t,s){let{type:e,source:r,patternTransform:o,...n}=t;const a=await i(r,{...s,crossOrigin:n.crossOrigin});return new this({...n,patternTransform:o&&o.slice(0),source:a})}}t(c,"type","Pattern"),a.setClass(c),a.setClass(c,"pattern");export{c as Pattern};
|
|
2
2
|
//# sourceMappingURL=Pattern.min.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pattern.min.mjs","sources":["../../../src/Pattern/Pattern.ts"],"sourcesContent":["import { config } from '../config';\nimport type { Abortable, TCrossOrigin, TMat2D, TSize } from '../typedefs';\nimport { ifNaN } from '../util/internals/ifNaN';\nimport { uid } from '../util/internals/uid';\nimport { loadImage } from '../util/misc/objectEnlive';\nimport { pick } from '../util/misc/pick';\nimport { toFixed } from '../util/misc/toFixed';\nimport { classRegistry } from '../ClassRegistry';\nimport type {\n PatternRepeat,\n PatternOptions,\n SerializedPatternOptions,\n} from './types';\nimport { log } from '../util/internals/console';\n\n/**\n * @see {@link http://fabric5.fabricjs.com/patterns demo}\n * @see {@link http://fabric5.fabricjs.com/dynamic-patterns demo}\n */\nexport class Pattern {\n static type = 'Pattern';\n\n /**\n * Legacy identifier of the class. Prefer using this.constructor.type 'Pattern'\n * or utils like isPattern, or instance of to indentify a pattern in your code.\n * Will be removed in future versiones\n * @TODO add sustainable warning message\n * @type string\n * @deprecated\n */\n get type() {\n return 'pattern';\n }\n\n set type(value) {\n log('warn', 'Setting type has no effect', value);\n }\n\n /**\n * @type PatternRepeat\n * @defaults\n */\n repeat: PatternRepeat = 'repeat';\n\n /**\n * Pattern horizontal offset from object's left/top corner\n * @type Number\n */\n offsetX = 0;\n\n /**\n * Pattern vertical offset from object's left/top corner\n * @type Number\n */\n offsetY = 0;\n\n /**\n * @type TCrossOrigin\n */\n crossOrigin: TCrossOrigin = '';\n\n /**\n * transform matrix to change the pattern, imported from svgs.\n * @todo verify if using the identity matrix as default makes the rest of the code more easy\n * @type Array\n */\n declare patternTransform?: TMat2D;\n\n /**\n * The actual pixel source of the pattern\n */\n declare source: CanvasImageSource;\n\n /**\n * If true, this object will not be exported during the serialization of a canvas\n * @type boolean\n */\n declare excludeFromExport?: boolean;\n\n /**\n * ID used for SVG export functionalities\n * @type number\n */\n declare readonly id: number;\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n * @param {option.source} [source] the pattern source, eventually empty or a drawable\n */\n constructor(options: PatternOptions) {\n this.id = uid();\n Object.assign(this, options);\n }\n\n /**\n * @returns true if {@link source} is an <img> element\n */\n isImageSource(): this is { source: HTMLImageElement } {\n return (\n !!this.source && typeof (this.source as HTMLImageElement).src === 'string'\n );\n }\n\n /**\n * @returns true if {@link source} is a <canvas> element\n */\n isCanvasSource(): this is { source: HTMLCanvasElement } {\n return !!this.source && !!(this.source as HTMLCanvasElement).toDataURL;\n }\n\n sourceToString(): string {\n return this.isImageSource()\n ? this.source.src\n : this.isCanvasSource()\n ? this.source.toDataURL()\n : '';\n }\n\n /**\n * Returns an instance of CanvasPattern\n * @param {CanvasRenderingContext2D} ctx Context to create pattern\n * @return {CanvasPattern}\n */\n toLive(ctx: CanvasRenderingContext2D): CanvasPattern | null {\n if (\n // if the image failed to load, return, and allow rest to continue loading\n !this.source ||\n // if an image\n (this.isImageSource() &&\n (!this.source.complete ||\n this.source.naturalWidth === 0 ||\n this.source.naturalHeight === 0))\n ) {\n return null;\n }\n\n return ctx.createPattern(this.source, this.repeat)!;\n }\n\n /**\n * Returns object representation of a pattern\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {object} Object representation of a pattern instance\n */\n toObject(propertiesToInclude: string[] = []): Record<string, any> {\n const { repeat, crossOrigin } = this;\n return {\n ...pick(this, propertiesToInclude as (keyof this)[]),\n type: 'pattern',\n source: this.sourceToString(),\n repeat,\n crossOrigin,\n offsetX: toFixed(this.offsetX, config.NUM_FRACTION_DIGITS),\n offsetY: toFixed(this.offsetY, config.NUM_FRACTION_DIGITS),\n patternTransform: this.patternTransform\n ? [...this.patternTransform]\n : null,\n };\n }\n\n /* _TO_SVG_START_ */\n /**\n * Returns SVG representation of a pattern\n */\n toSVG({ width, height }: TSize): string {\n const { source: patternSource, repeat, id } = this,\n patternOffsetX = ifNaN(this.offsetX / width, 0),\n patternOffsetY = ifNaN(this.offsetY / height, 0),\n patternWidth =\n repeat === 'repeat-y' || repeat === 'no-repeat'\n ? 1 + Math.abs(patternOffsetX || 0)\n : ifNaN((patternSource as HTMLImageElement).width / width, 0),\n patternHeight =\n repeat === 'repeat-x' || repeat === 'no-repeat'\n ? 1 + Math.abs(patternOffsetY || 0)\n : ifNaN((patternSource as HTMLImageElement).height / height, 0);\n\n return [\n `<pattern id=\"SVGID_${id}\" x=\"${patternOffsetX}\" y=\"${patternOffsetY}\" width=\"${patternWidth}\" height=\"${patternHeight}\">`,\n `<image x=\"0\" y=\"0\" width=\"${\n (patternSource as HTMLImageElement).width\n }\" height=\"${\n (patternSource as HTMLImageElement).height\n }\" xlink:href=\"${this.sourceToString()}\"></image>`,\n `</pattern>`,\n '',\n ].join('\\n');\n }\n /* _TO_SVG_END_ */\n\n static async fromObject(\n {\n type,\n source,\n patternTransform,\n ...otherOptions\n }: SerializedPatternOptions,\n options?: Abortable,\n ): Promise<Pattern> {\n const img = await loadImage(source, {\n ...options,\n crossOrigin: otherOptions.crossOrigin,\n });\n return new this({\n ...otherOptions,\n patternTransform:\n patternTransform && (patternTransform.slice(0) as TMat2D),\n source: img,\n });\n }\n}\n\nclassRegistry.setClass(Pattern);\n// kept for compatibility reason\nclassRegistry.setClass(Pattern, 'pattern');\n"],"names":["Pattern","type","value","log","constructor","options","_defineProperty","this","id","uid","Object","assign","isImageSource","source","src","isCanvasSource","toDataURL","sourceToString","toLive","ctx","complete","naturalWidth","naturalHeight","createPattern","repeat","toObject","propertiesToInclude","arguments","length","undefined","crossOrigin","pick","offsetX","toFixed","config","NUM_FRACTION_DIGITS","offsetY","patternTransform","toSVG","_ref","width","height","patternSource","patternOffsetX","ifNaN","patternOffsetY","Math","abs","join","fromObject","_ref2","otherOptions","img","loadImage","slice","classRegistry","setClass"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Pattern.min.mjs","sources":["../../../src/Pattern/Pattern.ts"],"sourcesContent":["import { config } from '../config';\nimport type { Abortable, TCrossOrigin, TMat2D, TSize } from '../typedefs';\nimport { ifNaN } from '../util/internals/ifNaN';\nimport { uid } from '../util/internals/uid';\nimport { loadImage } from '../util/misc/objectEnlive';\nimport { pick } from '../util/misc/pick';\nimport { toFixed } from '../util/misc/toFixed';\nimport { classRegistry } from '../ClassRegistry';\nimport type {\n PatternRepeat,\n PatternOptions,\n SerializedPatternOptions,\n} from './types';\nimport { log } from '../util/internals/console';\nimport { escapeXml } from '../util/lang_string';\n\n/**\n * @see {@link http://fabric5.fabricjs.com/patterns demo}\n * @see {@link http://fabric5.fabricjs.com/dynamic-patterns demo}\n */\nexport class Pattern {\n static type = 'Pattern';\n\n /**\n * Legacy identifier of the class. Prefer using this.constructor.type 'Pattern'\n * or utils like isPattern, or instance of to indentify a pattern in your code.\n * Will be removed in future versiones\n * @TODO add sustainable warning message\n * @type string\n * @deprecated\n */\n get type() {\n return 'pattern';\n }\n\n set type(value) {\n log('warn', 'Setting type has no effect', value);\n }\n\n /**\n * @type PatternRepeat\n * @defaults\n */\n repeat: PatternRepeat = 'repeat';\n\n /**\n * Pattern horizontal offset from object's left/top corner\n * @type Number\n */\n offsetX = 0;\n\n /**\n * Pattern vertical offset from object's left/top corner\n * @type Number\n */\n offsetY = 0;\n\n /**\n * @type TCrossOrigin\n */\n crossOrigin: TCrossOrigin = '';\n\n /**\n * transform matrix to change the pattern, imported from svgs.\n * @todo verify if using the identity matrix as default makes the rest of the code more easy\n * @type Array\n */\n declare patternTransform?: TMat2D;\n\n /**\n * The actual pixel source of the pattern\n */\n declare source: CanvasImageSource;\n\n /**\n * If true, this object will not be exported during the serialization of a canvas\n * @type boolean\n */\n declare excludeFromExport?: boolean;\n\n /**\n * ID used for SVG export functionalities\n * @type number\n */\n declare readonly id: number;\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n * @param {option.source} [source] the pattern source, eventually empty or a drawable\n */\n constructor(options: PatternOptions) {\n this.id = uid();\n Object.assign(this, options);\n }\n\n /**\n * @returns true if {@link source} is an <img> element\n */\n isImageSource(): this is { source: HTMLImageElement } {\n return (\n !!this.source && typeof (this.source as HTMLImageElement).src === 'string'\n );\n }\n\n /**\n * @returns true if {@link source} is a <canvas> element\n */\n isCanvasSource(): this is { source: HTMLCanvasElement } {\n return !!this.source && !!(this.source as HTMLCanvasElement).toDataURL;\n }\n\n sourceToString(): string {\n return this.isImageSource()\n ? this.source.src\n : this.isCanvasSource()\n ? this.source.toDataURL()\n : '';\n }\n\n /**\n * Returns an instance of CanvasPattern\n * @param {CanvasRenderingContext2D} ctx Context to create pattern\n * @return {CanvasPattern}\n */\n toLive(ctx: CanvasRenderingContext2D): CanvasPattern | null {\n if (\n // if the image failed to load, return, and allow rest to continue loading\n !this.source ||\n // if an image\n (this.isImageSource() &&\n (!this.source.complete ||\n this.source.naturalWidth === 0 ||\n this.source.naturalHeight === 0))\n ) {\n return null;\n }\n\n return ctx.createPattern(this.source, this.repeat)!;\n }\n\n /**\n * Returns object representation of a pattern\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {object} Object representation of a pattern instance\n */\n toObject(propertiesToInclude: string[] = []): Record<string, any> {\n const { repeat, crossOrigin } = this;\n return {\n ...pick(this, propertiesToInclude as (keyof this)[]),\n type: 'pattern',\n source: this.sourceToString(),\n repeat,\n crossOrigin,\n offsetX: toFixed(this.offsetX, config.NUM_FRACTION_DIGITS),\n offsetY: toFixed(this.offsetY, config.NUM_FRACTION_DIGITS),\n patternTransform: this.patternTransform\n ? [...this.patternTransform]\n : null,\n };\n }\n\n /* _TO_SVG_START_ */\n /**\n * Returns SVG representation of a pattern\n */\n toSVG({ width, height }: TSize): string {\n const { source: patternSource, repeat, id } = this,\n patternOffsetX = ifNaN(this.offsetX / width, 0),\n patternOffsetY = ifNaN(this.offsetY / height, 0),\n patternWidth =\n repeat === 'repeat-y' || repeat === 'no-repeat'\n ? 1 + Math.abs(patternOffsetX || 0)\n : ifNaN((patternSource as HTMLImageElement).width / width, 0),\n patternHeight =\n repeat === 'repeat-x' || repeat === 'no-repeat'\n ? 1 + Math.abs(patternOffsetY || 0)\n : ifNaN((patternSource as HTMLImageElement).height / height, 0);\n\n return [\n `<pattern id=\"SVGID_${escapeXml(id)}\" x=\"${patternOffsetX}\" y=\"${patternOffsetY}\" width=\"${patternWidth}\" height=\"${patternHeight}\">`,\n `<image x=\"0\" y=\"0\" width=\"${\n (patternSource as HTMLImageElement).width\n }\" height=\"${\n (patternSource as HTMLImageElement).height\n }\" xlink:href=\"${escapeXml(this.sourceToString())}\"></image>`,\n `</pattern>`,\n '',\n ].join('\\n');\n }\n /* _TO_SVG_END_ */\n\n static async fromObject(\n {\n type,\n source,\n patternTransform,\n ...otherOptions\n }: SerializedPatternOptions,\n options?: Abortable,\n ): Promise<Pattern> {\n const img = await loadImage(source, {\n ...options,\n crossOrigin: otherOptions.crossOrigin,\n });\n return new this({\n ...otherOptions,\n patternTransform:\n patternTransform && (patternTransform.slice(0) as TMat2D),\n source: img,\n });\n }\n}\n\nclassRegistry.setClass(Pattern);\n// kept for compatibility reason\nclassRegistry.setClass(Pattern, 'pattern');\n"],"names":["Pattern","type","value","log","constructor","options","_defineProperty","this","id","uid","Object","assign","isImageSource","source","src","isCanvasSource","toDataURL","sourceToString","toLive","ctx","complete","naturalWidth","naturalHeight","createPattern","repeat","toObject","propertiesToInclude","arguments","length","undefined","crossOrigin","pick","offsetX","toFixed","config","NUM_FRACTION_DIGITS","offsetY","patternTransform","toSVG","_ref","width","height","patternSource","patternOffsetX","ifNaN","patternOffsetY","patternWidth","Math","abs","patternHeight","escapeXml","join","fromObject","_ref2","otherOptions","img","loadImage","slice","classRegistry","setClass"],"mappings":"wjBAoBO,MAAMA,EAWX,QAAIC,GACF,MAAO,SACT,CAEA,QAAIA,CAAKC,GACPC,EAAI,OAAQ,6BAA8BD,EAC5C,CAsDAE,WAAAA,CAAYC,GAAyBC,gBAhDb,UAExBA,iBAIU,GAEVA,iBAIU,GAEVA,qBAG4B,IAgC1BC,KAAKC,GAAKC,IACVC,OAAOC,OAAOJ,KAAMF,EACtB,CAKAO,aAAAA,GACE,QACIL,KAAKM,QAA2D,iBAAzCN,KAAKM,OAA4BC,GAE9D,CAKAC,cAAAA,GACE,QAASR,KAAKM,UAAaN,KAAKM,OAA6BG,SAC/D,CAEAC,cAAAA,GACE,OAAOV,KAAKK,gBACRL,KAAKM,OAAOC,IACZP,KAAKQ,iBACHR,KAAKM,OAAOG,YACZ,EACR,CAOAE,MAAAA,CAAOC,GACL,OAEGZ,KAAKM,UAELN,KAAKK,iBACFL,KAAKM,OAAOO,UACiB,IAA7Bb,KAAKM,OAAOQ,cACkB,IAA9Bd,KAAKM,OAAOS,eAKXH,EAAII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BACEA,GAAqBA,EAAiBoB,MAAM,GAC9C5C,OAAQ0C,GAEZ,EACDjD,EAhMYN,EAAO,OACJ,WAiMhB0D,EAAcC,SAAS3D,GAEvB0D,EAAcC,SAAS3D,EAAS"}
|
|
@@ -7,6 +7,7 @@ import { pick } from '../util/misc/pick.mjs';
|
|
|
7
7
|
import { toFixed } from '../util/misc/toFixed.mjs';
|
|
8
8
|
import { classRegistry } from '../ClassRegistry.mjs';
|
|
9
9
|
import { log } from '../util/internals/console.mjs';
|
|
10
|
+
import { escapeXml } from '../util/lang_string.mjs';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* @see {@link http://fabric5.fabricjs.com/patterns demo}
|
|
@@ -152,7 +153,7 @@ class Pattern {
|
|
|
152
153
|
patternOffsetY = ifNaN(this.offsetY / height, 0),
|
|
153
154
|
patternWidth = repeat === 'repeat-y' || repeat === 'no-repeat' ? 1 + Math.abs(patternOffsetX || 0) : ifNaN(patternSource.width / width, 0),
|
|
154
155
|
patternHeight = repeat === 'repeat-x' || repeat === 'no-repeat' ? 1 + Math.abs(patternOffsetY || 0) : ifNaN(patternSource.height / height, 0);
|
|
155
|
-
return [`<pattern id="SVGID_${id}" x="${patternOffsetX}" y="${patternOffsetY}" width="${patternWidth}" height="${patternHeight}">`, `<image x="0" y="0" width="${patternSource.width}" height="${patternSource.height}" xlink:href="${this.sourceToString()}"></image>`, `</pattern>`, ''].join('\n');
|
|
156
|
+
return [`<pattern id="SVGID_${escapeXml(id)}" x="${patternOffsetX}" y="${patternOffsetY}" width="${patternWidth}" height="${patternHeight}">`, `<image x="0" y="0" width="${patternSource.width}" height="${patternSource.height}" xlink:href="${escapeXml(this.sourceToString())}"></image>`, `</pattern>`, ''].join('\n');
|
|
156
157
|
}
|
|
157
158
|
/* _TO_SVG_END_ */
|
|
158
159
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pattern.mjs","sources":["../../../src/Pattern/Pattern.ts"],"sourcesContent":["import { config } from '../config';\nimport type { Abortable, TCrossOrigin, TMat2D, TSize } from '../typedefs';\nimport { ifNaN } from '../util/internals/ifNaN';\nimport { uid } from '../util/internals/uid';\nimport { loadImage } from '../util/misc/objectEnlive';\nimport { pick } from '../util/misc/pick';\nimport { toFixed } from '../util/misc/toFixed';\nimport { classRegistry } from '../ClassRegistry';\nimport type {\n PatternRepeat,\n PatternOptions,\n SerializedPatternOptions,\n} from './types';\nimport { log } from '../util/internals/console';\n\n/**\n * @see {@link http://fabric5.fabricjs.com/patterns demo}\n * @see {@link http://fabric5.fabricjs.com/dynamic-patterns demo}\n */\nexport class Pattern {\n static type = 'Pattern';\n\n /**\n * Legacy identifier of the class. Prefer using this.constructor.type 'Pattern'\n * or utils like isPattern, or instance of to indentify a pattern in your code.\n * Will be removed in future versiones\n * @TODO add sustainable warning message\n * @type string\n * @deprecated\n */\n get type() {\n return 'pattern';\n }\n\n set type(value) {\n log('warn', 'Setting type has no effect', value);\n }\n\n /**\n * @type PatternRepeat\n * @defaults\n */\n repeat: PatternRepeat = 'repeat';\n\n /**\n * Pattern horizontal offset from object's left/top corner\n * @type Number\n */\n offsetX = 0;\n\n /**\n * Pattern vertical offset from object's left/top corner\n * @type Number\n */\n offsetY = 0;\n\n /**\n * @type TCrossOrigin\n */\n crossOrigin: TCrossOrigin = '';\n\n /**\n * transform matrix to change the pattern, imported from svgs.\n * @todo verify if using the identity matrix as default makes the rest of the code more easy\n * @type Array\n */\n declare patternTransform?: TMat2D;\n\n /**\n * The actual pixel source of the pattern\n */\n declare source: CanvasImageSource;\n\n /**\n * If true, this object will not be exported during the serialization of a canvas\n * @type boolean\n */\n declare excludeFromExport?: boolean;\n\n /**\n * ID used for SVG export functionalities\n * @type number\n */\n declare readonly id: number;\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n * @param {option.source} [source] the pattern source, eventually empty or a drawable\n */\n constructor(options: PatternOptions) {\n this.id = uid();\n Object.assign(this, options);\n }\n\n /**\n * @returns true if {@link source} is an <img> element\n */\n isImageSource(): this is { source: HTMLImageElement } {\n return (\n !!this.source && typeof (this.source as HTMLImageElement).src === 'string'\n );\n }\n\n /**\n * @returns true if {@link source} is a <canvas> element\n */\n isCanvasSource(): this is { source: HTMLCanvasElement } {\n return !!this.source && !!(this.source as HTMLCanvasElement).toDataURL;\n }\n\n sourceToString(): string {\n return this.isImageSource()\n ? this.source.src\n : this.isCanvasSource()\n ? this.source.toDataURL()\n : '';\n }\n\n /**\n * Returns an instance of CanvasPattern\n * @param {CanvasRenderingContext2D} ctx Context to create pattern\n * @return {CanvasPattern}\n */\n toLive(ctx: CanvasRenderingContext2D): CanvasPattern | null {\n if (\n // if the image failed to load, return, and allow rest to continue loading\n !this.source ||\n // if an image\n (this.isImageSource() &&\n (!this.source.complete ||\n this.source.naturalWidth === 0 ||\n this.source.naturalHeight === 0))\n ) {\n return null;\n }\n\n return ctx.createPattern(this.source, this.repeat)!;\n }\n\n /**\n * Returns object representation of a pattern\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {object} Object representation of a pattern instance\n */\n toObject(propertiesToInclude: string[] = []): Record<string, any> {\n const { repeat, crossOrigin } = this;\n return {\n ...pick(this, propertiesToInclude as (keyof this)[]),\n type: 'pattern',\n source: this.sourceToString(),\n repeat,\n crossOrigin,\n offsetX: toFixed(this.offsetX, config.NUM_FRACTION_DIGITS),\n offsetY: toFixed(this.offsetY, config.NUM_FRACTION_DIGITS),\n patternTransform: this.patternTransform\n ? [...this.patternTransform]\n : null,\n };\n }\n\n /* _TO_SVG_START_ */\n /**\n * Returns SVG representation of a pattern\n */\n toSVG({ width, height }: TSize): string {\n const { source: patternSource, repeat, id } = this,\n patternOffsetX = ifNaN(this.offsetX / width, 0),\n patternOffsetY = ifNaN(this.offsetY / height, 0),\n patternWidth =\n repeat === 'repeat-y' || repeat === 'no-repeat'\n ? 1 + Math.abs(patternOffsetX || 0)\n : ifNaN((patternSource as HTMLImageElement).width / width, 0),\n patternHeight =\n repeat === 'repeat-x' || repeat === 'no-repeat'\n ? 1 + Math.abs(patternOffsetY || 0)\n : ifNaN((patternSource as HTMLImageElement).height / height, 0);\n\n return [\n `<pattern id=\"SVGID_${id}\" x=\"${patternOffsetX}\" y=\"${patternOffsetY}\" width=\"${patternWidth}\" height=\"${patternHeight}\">`,\n `<image x=\"0\" y=\"0\" width=\"${\n (patternSource as HTMLImageElement).width\n }\" height=\"${\n (patternSource as HTMLImageElement).height\n }\" xlink:href=\"${this.sourceToString()}\"></image>`,\n `</pattern>`,\n '',\n ].join('\\n');\n }\n /* _TO_SVG_END_ */\n\n static async fromObject(\n {\n type,\n source,\n patternTransform,\n ...otherOptions\n }: SerializedPatternOptions,\n options?: Abortable,\n ): Promise<Pattern> {\n const img = await loadImage(source, {\n ...options,\n crossOrigin: otherOptions.crossOrigin,\n });\n return new this({\n ...otherOptions,\n patternTransform:\n patternTransform && (patternTransform.slice(0) as TMat2D),\n source: img,\n });\n }\n}\n\nclassRegistry.setClass(Pattern);\n// kept for compatibility reason\nclassRegistry.setClass(Pattern, 'pattern');\n"],"names":["Pattern","type","value","log","constructor","options","_defineProperty","id","uid","Object","assign","isImageSource","source","src","isCanvasSource","toDataURL","sourceToString","toLive","ctx","complete","naturalWidth","naturalHeight","createPattern","repeat","toObject","propertiesToInclude","arguments","length","undefined","crossOrigin","pick","offsetX","toFixed","config","NUM_FRACTION_DIGITS","offsetY","patternTransform","toSVG","_ref","width","height","patternSource","patternOffsetX","ifNaN","patternOffsetY","patternWidth","Math","abs","patternHeight","join","fromObject","_ref2","otherOptions","img","loadImage","slice","classRegistry","setClass"],"mappings":";;;;;;;;;;AAeA;AACA;AACA;AACA;AACO,MAAMA,OAAO,CAAC;AAGnB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE,IAAIC,IAAIA,GAAG;AACT,IAAA,OAAO,SAAS;AAClB,EAAA;EAEA,IAAIA,IAAIA,CAACC,KAAK,EAAE;AACdC,IAAAA,GAAG,CAAC,MAAM,EAAE,4BA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WAAW,EAAEuB,YAAY,CAACvB;AAC5B,KAAC,CAAC;IACF,OAAO,IAAI,IAAI,CAAC;AACd,MAAA,GAAGuB,YAAY;MACfhB,gBAAgB,EACdA,gBAAgB,IAAKA,gBAAgB,CAACmB,KAAK,CAAC,CAAC,CAAY;AAC3D3C,MAAAA,MAAM,EAAEyC;AACV,KAAC,CAAC;AACJ,EAAA;AACF;AAAC/C,eAAA,CAhMYN,OAAO,EAAA,MAAA,EACJ,SAAS,CAAA;AAiMzBwD,aAAa,CAACC,QAAQ,CAACzD,OAAO,CAAC;AAC/B;AACAwD,aAAa,CAACC,QAAQ,CAACzD,OAAO,EAAE,SAAS,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"Pattern.mjs","sources":["../../../src/Pattern/Pattern.ts"],"sourcesContent":["import { config } from '../config';\nimport type { Abortable, TCrossOrigin, TMat2D, TSize } from '../typedefs';\nimport { ifNaN } from '../util/internals/ifNaN';\nimport { uid } from '../util/internals/uid';\nimport { loadImage } from '../util/misc/objectEnlive';\nimport { pick } from '../util/misc/pick';\nimport { toFixed } from '../util/misc/toFixed';\nimport { classRegistry } from '../ClassRegistry';\nimport type {\n PatternRepeat,\n PatternOptions,\n SerializedPatternOptions,\n} from './types';\nimport { log } from '../util/internals/console';\nimport { escapeXml } from '../util/lang_string';\n\n/**\n * @see {@link http://fabric5.fabricjs.com/patterns demo}\n * @see {@link http://fabric5.fabricjs.com/dynamic-patterns demo}\n */\nexport class Pattern {\n static type = 'Pattern';\n\n /**\n * Legacy identifier of the class. Prefer using this.constructor.type 'Pattern'\n * or utils like isPattern, or instance of to indentify a pattern in your code.\n * Will be removed in future versiones\n * @TODO add sustainable warning message\n * @type string\n * @deprecated\n */\n get type() {\n return 'pattern';\n }\n\n set type(value) {\n log('warn', 'Setting type has no effect', value);\n }\n\n /**\n * @type PatternRepeat\n * @defaults\n */\n repeat: PatternRepeat = 'repeat';\n\n /**\n * Pattern horizontal offset from object's left/top corner\n * @type Number\n */\n offsetX = 0;\n\n /**\n * Pattern vertical offset from object's left/top corner\n * @type Number\n */\n offsetY = 0;\n\n /**\n * @type TCrossOrigin\n */\n crossOrigin: TCrossOrigin = '';\n\n /**\n * transform matrix to change the pattern, imported from svgs.\n * @todo verify if using the identity matrix as default makes the rest of the code more easy\n * @type Array\n */\n declare patternTransform?: TMat2D;\n\n /**\n * The actual pixel source of the pattern\n */\n declare source: CanvasImageSource;\n\n /**\n * If true, this object will not be exported during the serialization of a canvas\n * @type boolean\n */\n declare excludeFromExport?: boolean;\n\n /**\n * ID used for SVG export functionalities\n * @type number\n */\n declare readonly id: number;\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n * @param {option.source} [source] the pattern source, eventually empty or a drawable\n */\n constructor(options: PatternOptions) {\n this.id = uid();\n Object.assign(this, options);\n }\n\n /**\n * @returns true if {@link source} is an <img> element\n */\n isImageSource(): this is { source: HTMLImageElement } {\n return (\n !!this.source && typeof (this.source as HTMLImageElement).src === 'string'\n );\n }\n\n /**\n * @returns true if {@link source} is a <canvas> element\n */\n isCanvasSource(): this is { source: HTMLCanvasElement } {\n return !!this.source && !!(this.source as HTMLCanvasElement).toDataURL;\n }\n\n sourceToString(): string {\n return this.isImageSource()\n ? this.source.src\n : this.isCanvasSource()\n ? this.source.toDataURL()\n : '';\n }\n\n /**\n * Returns an instance of CanvasPattern\n * @param {CanvasRenderingContext2D} ctx Context to create pattern\n * @return {CanvasPattern}\n */\n toLive(ctx: CanvasRenderingContext2D): CanvasPattern | null {\n if (\n // if the image failed to load, return, and allow rest to continue loading\n !this.source ||\n // if an image\n (this.isImageSource() &&\n (!this.source.complete ||\n this.source.naturalWidth === 0 ||\n this.source.naturalHeight === 0))\n ) {\n return null;\n }\n\n return ctx.createPattern(this.source, this.repeat)!;\n }\n\n /**\n * Returns object representation of a pattern\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {object} Object representation of a pattern instance\n */\n toObject(propertiesToInclude: string[] = []): Record<string, any> {\n const { repeat, crossOrigin } = this;\n return {\n ...pick(this, propertiesToInclude as (keyof this)[]),\n type: 'pattern',\n source: this.sourceToString(),\n repeat,\n crossOrigin,\n offsetX: toFixed(this.offsetX, config.NUM_FRACTION_DIGITS),\n offsetY: toFixed(this.offsetY, config.NUM_FRACTION_DIGITS),\n patternTransform: this.patternTransform\n ? [...this.patternTransform]\n : null,\n };\n }\n\n /* _TO_SVG_START_ */\n /**\n * Returns SVG representation of a pattern\n */\n toSVG({ width, height }: TSize): string {\n const { source: patternSource, repeat, id } = this,\n patternOffsetX = ifNaN(this.offsetX / width, 0),\n patternOffsetY = ifNaN(this.offsetY / height, 0),\n patternWidth =\n repeat === 'repeat-y' || repeat === 'no-repeat'\n ? 1 + Math.abs(patternOffsetX || 0)\n : ifNaN((patternSource as HTMLImageElement).width / width, 0),\n patternHeight =\n repeat === 'repeat-x' || repeat === 'no-repeat'\n ? 1 + Math.abs(patternOffsetY || 0)\n : ifNaN((patternSource as HTMLImageElement).height / height, 0);\n\n return [\n `<pattern id=\"SVGID_${escapeXml(id)}\" x=\"${patternOffsetX}\" y=\"${patternOffsetY}\" width=\"${patternWidth}\" height=\"${patternHeight}\">`,\n `<image x=\"0\" y=\"0\" width=\"${\n (patternSource as HTMLImageElement).width\n }\" height=\"${\n (patternSource as HTMLImageElement).height\n }\" xlink:href=\"${escapeXml(this.sourceToString())}\"></image>`,\n `</pattern>`,\n '',\n ].join('\\n');\n }\n /* _TO_SVG_END_ */\n\n static async fromObject(\n {\n type,\n source,\n patternTransform,\n ...otherOptions\n }: SerializedPatternOptions,\n options?: Abortable,\n ): Promise<Pattern> {\n const img = await loadImage(source, {\n ...options,\n crossOrigin: otherOptions.crossOrigin,\n });\n return new this({\n ...otherOptions,\n patternTransform:\n patternTransform && (patternTransform.slice(0) as TMat2D),\n source: img,\n });\n }\n}\n\nclassRegistry.setClass(Pattern);\n// kept for compatibility reason\nclassRegistry.setClass(Pattern, 'pattern');\n"],"names":["Pattern","type","value","log","constructor","options","_defineProperty","id","uid","Object","assign","isImageSource","source","src","isCanvasSource","toDataURL","sourceToString","toLive","ctx","complete","naturalWidth","naturalHeight","createPattern","repeat","toObject","propertiesToInclude","arguments","length","undefined","crossOrigin","pick","offsetX","toFixed","config","NUM_FRACTION_DIGITS","offsetY","patternTransform","toSVG","_ref","width","height","patternSource","patternOffsetX","ifNaN","patternOffsetY","patternWidth","Math","abs","patternHeight","escapeXml","join","fromObject","_ref2","otherOptions","img","loadImage","slice","classRegistry","setClass"],"mappings":";;;;;;;;;;;AAgBA;AACA;AACA;AACA;AACO,MAAMA,OAAO,CAAC;AAGnB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE,IAAIC,IAAIA,GAAG;AACT,IAAA,OAAO,SAAS;AAClB,EAAA;EAEA,IAAIA,IAAIA,CAACC,KAAK,EAAE;AACdC,IAAAA,GAAG,CAAC,MAAM,EAAE,4BAA4B,EAAED,KAAK,CAAC;AAClD,EAAA;;AAEA;AACF;AACA;AACA;;AAoBE;AACF;AACA;AACA;AACA;;AAGE;AACF;AACA;;AAGE;AACF;AACA;AACA;;AAGE;AACF;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;EACEE,WAAWA,CAACC,OAAuB,EAAE;AAAAC,IAAAA,eAAA,iBAhDb,QAAQ,CAAA;AAEhC;AACF;AACA;AACA;AAHEA,IAAAA,eAAA,kBAIU,CAAC,CAAA;AAEX;AACF;AACA;AACA;AAHEA,IAAAA,eAAA,kBAIU,CAAC,CAAA;AAEX;AACF;AACA;AAFEA,IAAAA,eAAA,sBAG4B,EAAE,CAAA;AAgC5B,IAAA,IAAI,CAACC,EAAE,GAAGC,GAAG,EAAE;AACfC,IAAAA,MAAM,CAACC,MAAM,CAAC,IAAI,EAAEL,OAAO,CAAC;AAC9B,EAAA;;AAEA;AACF;AACA;AACEM,EAAAA,aAAaA,GAAyC;AACpD,IAAA,OACE,CAAC,CAAC,IAAI,CAACC,MAAM,IAAI,OAAQ,IAAI,CAACA,MAAM,CAAsB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AAQE,cAAc,CAAA,SAAA,EAAYC,YAAY,aAAaG,aAAa,CAAA,EAAA,CAAI,EACrI,CAAA,0BAAA,EACGP,aAAa,CAAsBF,KAAK,CAAA,UAAA,EAExCE,aAAa,CAAsBD,MAAM,iBAC3BS,SAAS,CAAC,IAAI,CAACjC,cAAc,EAAE,CAAC,YAAY,EAC7D,CAAA,UAAA,CAAY,EACZ,EAAE,CACH,CAACkC,IAAI,CAAC,IAAI,CAAC;AACd,EAAA;AACA;;AAEA,EAAA,aAAaC,UAAUA,CAAAC,KAAA,EAOrB/C,OAAmB,EACD;IAAA,IAPlB;MACEJ,IAAI;MACJW,MAAM;MACNwB,gBAAgB;MAChB,GAAGiB;AACqB,KAAC,GAAAD,KAAA;AAG3B,IAAA,MAAME,GAAG,GAAG,MAAMC,SAAS,CAAC3C,MAAM,EAAE;AAClC,MAAA,GAAGP,OAAO;MACVwB,WAAW,EAAEwB,YAAY,CAACxB;AAC5B,KAAC,CAAC;IACF,OAAO,IAAI,IAAI,CAAC;AACd,MAAA,GAAGwB,YAAY;MACfjB,gBAAgB,EACdA,gBAAgB,IAAKA,gBAAgB,CAACoB,KAAK,CAAC,CAAC,CAAY;AAC3D5C,MAAAA,MAAM,EAAE0C;AACV,KAAC,CAAC;AACJ,EAAA;AACF;AAAChD,eAAA,CAhMYN,OAAO,EAAA,MAAA,EACJ,SAAS,CAAA;AAiMzByD,aAAa,CAACC,QAAQ,CAAC1D,OAAO,CAAC;AAC/B;AACAyD,aAAa,CAACC,QAAQ,CAAC1D,OAAO,EAAE,SAAS,CAAC;;;;"}
|
package/dist/src/Shadow.d.ts
CHANGED
package/dist/src/Shadow.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Shadow.d.ts","sourceRoot":"","sources":["../../src/Shadow.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAA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AAM,CAAC;CACd,CAAC;AAEF,qBAAa,MAAM;IACjB;;;OAGG;IACK,KAAK,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACK,IAAI,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACK,OAAO,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACK,OAAO,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACK,YAAY,EAAE,OAAO,CAAC;IAE9B;;;OAGG;IACK,oBAAoB,EAAE,OAAO,CAAC;IAEtC;;;;;OAKG;IACK,UAAU,EAAE,OAAO,CAAC;IAEpB,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IAE5B,MAAM,CAAC,WAAW,oCAAuB;IAEzC,MAAM,CAAC,IAAI,SAAY;IAEvB;;;OAGG;gBACS,OAAO,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;gBAC3C,YAAY,EAAE,MAAM;IAQhC;;;OAGG;IACH,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM;;;;;;IAehC;;;;OAIG;IACH,QAAQ;IAIR;;;;OAIG;IACH,KAAK,CAAC,MAAM,EAAE,YAAY;IAoD1B;;;OAGG;IACH,QAAQ;WAgBK,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;CAGnE"}
|
package/dist/src/Shadow.min.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{defineProperty as t}from"../_virtual/_rollupPluginBabelHelpers.min.mjs";import{classRegistry as
|
|
1
|
+
import{defineProperty as t}from"../_virtual/_rollupPluginBabelHelpers.min.mjs";import{classRegistry as o}from"./ClassRegistry.min.mjs";import{Color as e}from"./color/Color.min.mjs";import{config as i}from"./config.min.mjs";import{reNum as s}from"./parser/constants.min.mjs";import{Point as r}from"./Point.min.mjs";import{uid as n}from"./util/internals/uid.min.mjs";import{escapeXml as f}from"./util/lang_string.min.mjs";import{pickBy as l}from"./util/misc/pick.min.mjs";import{degreesToRadians as m}from"./util/misc/radiansDegreesConversion.min.mjs";import{toFixed as a}from"./util/misc/toFixed.min.mjs";import{rotateVector as c}from"./util/misc/vectors.min.mjs";const u="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",h=new RegExp("(?:\\s|^)"+u+u+"("+s+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)"),p={color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1};class d{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const o="string"==typeof t?d.parseShadow(t):t;Object.assign(this,d.ownDefaults,o),this.id=n()}static parseShadow(t){const o=t.trim(),[,e=0,i=0,s=0]=(h.exec(o)||[]).map(t=>parseFloat(t)||0);return{color:(o.replace(h,"")||"rgb(0,0,0)").trim(),offsetX:e,offsetY:i,blur:s}}toString(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")}toSVG(t){const o=c(new r(this.offsetX,this.offsetY),m(-t.angle)),s=i.NUM_FRACTION_DIGITS,n=new e(this.color);let l=40,u=40;return t.width&&t.height&&(l=100*a((Math.abs(o.x)+this.blur)/t.width,s)+20,u=100*a((Math.abs(o.y)+this.blur)/t.height,s)+20),t.flipX&&(o.x*=-1),t.flipY&&(o.y*=-1),`<filter id="SVGID_${f(this.id)}" y="-${u}%" height="${100+2*u}%" x="-${l}%" width="${100+2*l}%" >\n\t<feGaussianBlur in="SourceAlpha" stdDeviation="${a(this.blur?this.blur/2:0,s)}"></feGaussianBlur>\n\t<feOffset dx="${a(o.x,s)}" dy="${a(o.y,s)}" result="oBlur" ></feOffset>\n\t<feFlood flood-color="${n.toRgb()}" flood-opacity="${n.getAlpha()}"/>\n\t<feComposite in2="oBlur" operator="in" />\n\t<feMerge>\n\t\t<feMergeNode></feMergeNode>\n\t\t<feMergeNode in="SourceGraphic"></feMergeNode>\n\t</feMerge>\n</filter>\n`}toObject(){const t={color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling,type:this.constructor.type},o=d.ownDefaults;return this.includeDefaultValues?t:l(t,(t,e)=>t!==o[e])}static async fromObject(t){return new this(t)}}t(d,"ownDefaults",p),t(d,"type","shadow"),o.setClass(d,"shadow");export{d as Shadow,p as shadowDefaultValues};
|
|
2
2
|
//# sourceMappingURL=Shadow.min.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Shadow.min.mjs","sources":["../../src/Shadow.ts"],"sourcesContent":["import { classRegistry } from './ClassRegistry';\nimport { Color } from './color/Color';\nimport { config } from './config';\nimport { reNum } from './parser/constants';\nimport { Point } from './Point';\nimport type { FabricObject } from './shapes/Object/FabricObject';\nimport type { TClassProperties } from './typedefs';\nimport { uid } from './util/internals/uid';\nimport { pickBy } from './util/misc/pick';\nimport { degreesToRadians } from './util/misc/radiansDegreesConversion';\nimport { toFixed } from './util/misc/toFixed';\nimport { rotateVector } from './util/misc/vectors';\n\n/**\n * Regex matching shadow offsetX, offsetY and blur (ex: \"2px 2px 10px rgba(0,0,0,0.2)\", \"rgb(0,255,0) 2px 2px\")\n * - (?:\\s|^): This part captures either a whitespace character (\\s) or the beginning of a line (^). It's non-capturing (due to (?:...)), meaning it doesn't create a capturing group.\n * - (-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?: This captures the first component of the shadow, which is the horizontal offset. Breaking it down:\n * - (-?\\d+): Captures an optional minus sign followed by one or more digits (integer part of the number).\n * - (?:\\.\\d*)?: Optionally captures a decimal point followed by zero or more digits (decimal part of the number).\n * - (?:px)?: Optionally captures the \"px\" unit.\n * - (?:\\s?|$): Captures either an optional whitespace or the end of the line. This whole part is wrapped in a non-capturing group and marked as optional with ?.\n * - (-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?: Similar to the previous step, this captures the vertical offset.\n\n(\\d+(?:\\.\\d*)?(?:px)?)?: This captures the blur radius. It's similar to the horizontal offset but without the optional minus sign.\n\n(?:\\s+(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?){0,1}: This captures an optional part for the color. It allows for whitespace followed by a component with an optional minus sign, digits, decimal point, and \"px\" unit.\n\n(?:$|\\s): This captures either the end of the line or a whitespace character. It ensures that the match ends either at the end of the string or with a whitespace character.\n */\n// eslint-disable-next-line max-len\n\nconst shadowOffsetRegex = '(-?\\\\d+(?:\\\\.\\\\d*)?(?:px)?(?:\\\\s?|$))?';\n\nconst reOffsetsAndBlur = new RegExp(\n '(?:\\\\s|^)' +\n shadowOffsetRegex +\n shadowOffsetRegex +\n '(' +\n reNum +\n '?(?:px)?)?(?:\\\\s?|$)(?:$|\\\\s)',\n);\n\nexport const shadowDefaultValues: Partial<TClassProperties<Shadow>> = {\n color: 'rgb(0,0,0)',\n blur: 0,\n offsetX: 0,\n offsetY: 0,\n affectStroke: false,\n includeDefaultValues: true,\n nonScaling: false,\n};\n\nexport type SerializedShadowOptions = {\n color: string;\n blur: number;\n offsetX: number;\n offsetY: number;\n affectStroke: boolean;\n nonScaling: boolean;\n type: string;\n};\n\nexport class Shadow {\n /**\n * Shadow color\n * @type String\n */\n declare color: string;\n\n /**\n * Shadow blur\n * @type Number\n */\n declare blur: number;\n\n /**\n * Shadow horizontal offset\n * @type Number\n */\n declare offsetX: number;\n\n /**\n * Shadow vertical offset\n * @type Number\n */\n declare offsetY: number;\n\n /**\n * Whether the shadow should affect stroke operations\n * @type Boolean\n */\n declare affectStroke: boolean;\n\n /**\n * Indicates whether toObject should include default values\n * @type Boolean\n */\n declare includeDefaultValues: boolean;\n\n /**\n * When `false`, the shadow will scale with the object.\n * When `true`, the shadow's offsetX, offsetY, and blur will not be affected by the object's scale.\n * default to false\n * @type Boolean\n */\n declare nonScaling: boolean;\n\n declare id: number;\n\n static ownDefaults = shadowDefaultValues;\n\n static type = 'shadow';\n\n /**\n * @see {@link http://fabric5.fabricjs.com/shadows|Shadow demo}\n * @param {Object|String} [options] Options object with any of color, blur, offsetX, offsetY properties or string (e.g. \"rgba(0,0,0,0.2) 2px 2px 10px\")\n */\n constructor(options?: Partial<TClassProperties<Shadow>>);\n constructor(svgAttribute: string);\n constructor(arg0: string | Partial<TClassProperties<Shadow>> = {}) {\n const options: Partial<TClassProperties<Shadow>> =\n typeof arg0 === 'string' ? Shadow.parseShadow(arg0) : arg0;\n Object.assign(this, Shadow.ownDefaults, options);\n this.id = uid();\n }\n\n /**\n * @param {String} value Shadow value to parse\n * @return {Object} Shadow object with color, offsetX, offsetY and blur\n */\n static parseShadow(value: string) {\n const shadowStr = value.trim(),\n [, offsetX = 0, offsetY = 0, blur = 0] = (\n reOffsetsAndBlur.exec(shadowStr) || []\n ).map((value) => parseFloat(value) || 0),\n color = (shadowStr.replace(reOffsetsAndBlur, '') || 'rgb(0,0,0)').trim();\n\n return {\n color,\n offsetX,\n offsetY,\n blur,\n };\n }\n\n /**\n * Returns a string representation of an instance\n * @see http://www.w3.org/TR/css-text-decor-3/#text-shadow\n * @return {String} Returns CSS3 text-shadow declaration\n */\n toString() {\n return [this.offsetX, this.offsetY, this.blur, this.color].join('px ');\n }\n\n /**\n * Returns SVG representation of a shadow\n * @param {FabricObject} object\n * @return {String} SVG representation of a shadow\n */\n toSVG(object: FabricObject) {\n const offset = rotateVector(\n new Point(this.offsetX, this.offsetY),\n degreesToRadians(-object.angle),\n ),\n BLUR_BOX = 20,\n color = new Color(this.color);\n let fBoxX = 40,\n fBoxY = 40;\n\n if (object.width && object.height) {\n //http://www.w3.org/TR/SVG/filters.html#FilterEffectsRegion\n // we add some extra space to filter box to contain the blur ( 20 )\n fBoxX =\n toFixed(\n (Math.abs(offset.x) + this.blur) / object.width,\n config.NUM_FRACTION_DIGITS,\n ) *\n 100 +\n BLUR_BOX;\n fBoxY =\n toFixed(\n (Math.abs(offset.y) + this.blur) / object.height,\n config.NUM_FRACTION_DIGITS,\n ) *\n 100 +\n BLUR_BOX;\n }\n if (object.flipX) {\n offset.x *= -1;\n }\n if (object.flipY) {\n offset.y *= -1;\n }\n\n return `<filter id=\"SVGID_${this.id}\" y=\"-${fBoxY}%\" height=\"${\n 100 + 2 * fBoxY\n }%\" x=\"-${fBoxX}%\" width=\"${\n 100 + 2 * fBoxX\n }%\" >\\n\\t<feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"${toFixed(\n this.blur ? this.blur / 2 : 0,\n config.NUM_FRACTION_DIGITS,\n )}\"></feGaussianBlur>\\n\\t<feOffset dx=\"${toFixed(\n offset.x,\n config.NUM_FRACTION_DIGITS,\n )}\" dy=\"${toFixed(\n offset.y,\n config.NUM_FRACTION_DIGITS,\n )}\" result=\"oBlur\" ></feOffset>\\n\\t<feFlood flood-color=\"${color.toRgb()}\" flood-opacity=\"${color.getAlpha()}\"/>\\n\\t<feComposite in2=\"oBlur\" operator=\"in\" />\\n\\t<feMerge>\\n\\t\\t<feMergeNode></feMergeNode>\\n\\t\\t<feMergeNode in=\"SourceGraphic\"></feMergeNode>\\n\\t</feMerge>\\n</filter>\\n`;\n }\n\n /**\n * Returns object representation of a shadow\n * @return {Object} Object representation of a shadow instance\n */\n toObject() {\n const data: SerializedShadowOptions = {\n color: this.color,\n blur: this.blur,\n offsetX: this.offsetX,\n offsetY: this.offsetY,\n affectStroke: this.affectStroke,\n nonScaling: this.nonScaling,\n type: (this.constructor as typeof Shadow).type,\n };\n const defaults = Shadow.ownDefaults as SerializedShadowOptions;\n return !this.includeDefaultValues\n ? pickBy(data, (value, key) => value !== defaults[key])\n : data;\n }\n\n static async fromObject(options: Partial<TClassProperties<Shadow>>) {\n return new this(options);\n }\n}\n\nclassRegistry.setClass(Shadow, 'shadow');\n"],"names":["shadowOffsetRegex","reOffsetsAndBlur","RegExp","reNum","shadowDefaultValues","color","blur","offsetX","offsetY","affectStroke","includeDefaultValues","nonScaling","Shadow","constructor","arg0","arguments","length","undefined","options","parseShadow","Object","assign","this","ownDefaults","id","uid","value","shadowStr","trim","exec","map","parseFloat","replace","toString","join","toSVG","object","offset","rotateVector","Point","degreesToRadians","angle","Color","fBoxX","fBoxY","width","height","toFixed","Math","abs","x","config","NUM_FRACTION_DIGITS","y","flipX","flipY","toRgb","getAlpha","toObject","data","type","defaults","pickBy","key","fromObject","_defineProperty","classRegistry","setClass"],"mappings":"gmBA+BA,MAAMA,EAAoB,yCAEpBC,EAAmB,IAAIC,OAC3B,YACEF,EACAA,EACA,IACAG,EACA,iCAGSC,EAAyD,CACpEC,MAAO,aACPC,KAAM,EACNC,QAAS,EACTC,QAAS,EACTC,cAAc,EACdC,sBAAsB,EACtBC,YAAY,GAaP,MAAMC,EAyDXC,WAAAA,GAAmE,IAAvDC,EAAgDC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,CAAA,EAC7D,MAAMG,EACY,iBAATJ,EAAoBF,EAAOO,YAAYL,GAAQA,EACxDM,OAAOC,OAAOC,KAAMV,EAAOW,YAAaL,GACxCI,KAAKE,GAAKC,GACZ,CAMA,kBAAON,CAAYO,GACjB,MAAMC,EAAYD,EAAME,QACtB,CAAGrB,EAAU,EAAGC,EAAU,EAAGF,EAAO,IAClCL,EAAiB4B,KAAKF,IAAc,IACpCG,IAAKJ,GAAUK,WAAWL,IAAU,GAGxC,MAAO,CACLrB,OAHSsB,EAAUK,QAAQ/B,EAAkB,KAAO,cAAc2B,OAIlErB,UACAC,UACAF,OAEJ,CAOA2B,QAAAA,GACE,MAAO,CAACX,KAAKf,QAASe,KAAKd,QAASc,KAAKhB,KAAMgB,KAAKjB,OAAO6B,KAAK,MAClE,CAOAC,KAAAA,CAAMC,GACJ,MAAMC,EAASC,EACX,IAAIC,EAAMjB,KAAKf,QAASe,KAAKd,SAC7BgC,GAAkBJ,EAAOK,QAG3BpC,EAAQ,IAAIqC,EAAMpB,KAAKjB,OACzB,IAAIsC,EAAQ,GACVC,EAAQ,GA2BV,OAzBIR,EAAOS,OAAST,EAAOU,SAGzBH,EAKI,IAJFI,GACGC,KAAKC,IAAIZ,EAAOa,GAAK5B,KAAKhB,MAAQ8B,EAAOS,MAC1CM,EAAOC,qBAXA,GAeXR,EAKI,IAJFG,GACGC,KAAKC,IAAIZ,EAAOgB,GAAK/B,KAAKhB,MAAQ8B,EAAOU,OAC1CK,EAAOC,qBAlBA,IAuBThB,EAAOkB,QACTjB,EAAOa,IAAK,GAEVd,EAAOmB,QACTlB,EAAOgB,IAAK,GAGP,qBAAqB/B,KAAKE,WAAWoB,eAC1C,IAAM,EAAIA,WACFD,cACR,IAAM,EAAIA,2DAC8CI,EACxDzB,KAAKhB,KAAOgB,KAAKhB,KAAO,EAAI,EAC5B6C,EAAOC,4DACgCL,EACvCV,EAAOa,EACPC,EAAOC,6BACCL,EACRV,EAAOgB,EACPF,EAAOC,8EACkD/C,EAAMmD,2BAA2BnD,EAAMoD,yLACpG,CAMAC,QAAAA,GACE,MAAMC,EAAgC,CACpCtD,MAAOiB,KAAKjB,MACZC,KAAMgB,KAAKhB,KACXC,QAASe,KAAKf,QACdC,QAASc,KAAKd,QACdC,aAAca,KAAKb,aACnBE,WAAYW,KAAKX,WACjBiD,KAAOtC,KAAKT,YAA8B+C,MAEtCC,EAAWjD,EAAOW,YACxB,OAAQD,KAAKZ,qBAETiD,EADAG,EAAOH,EAAM,CAACjC,EAAOqC,IAAQrC,IAAUmC,EAASE,GAEtD,CAEA,uBAAaC,CAAW9C,GACtB,OAAO,IAAII,KAAKJ,EAClB,EArIA+C,EArCWrD,EAAM,cA+CIR,GAAmB6D,EA/C7BrD,EAAM,OAiDH,UA4HhBsD,EAAcC,SAASvD,EAAQ"}
|
|
1
|
+
{"version":3,"file":"Shadow.min.mjs","sources":["../../src/Shadow.ts"],"sourcesContent":["import { classRegistry } from './ClassRegistry';\nimport { Color } from './color/Color';\nimport { config } from './config';\nimport { reNum } from './parser/constants';\nimport { Point } from './Point';\nimport type { FabricObject } from './shapes/Object/FabricObject';\nimport type { TClassProperties } from './typedefs';\nimport { uid } from './util/internals/uid';\nimport { escapeXml } from './util/lang_string';\nimport { pickBy } from './util/misc/pick';\nimport { degreesToRadians } from './util/misc/radiansDegreesConversion';\nimport { toFixed } from './util/misc/toFixed';\nimport { rotateVector } from './util/misc/vectors';\n\n/**\n * Regex matching shadow offsetX, offsetY and blur (ex: \"2px 2px 10px rgba(0,0,0,0.2)\", \"rgb(0,255,0) 2px 2px\")\n * - (?:\\s|^): This part captures either a whitespace character (\\s) or the beginning of a line (^). It's non-capturing (due to (?:...)), meaning it doesn't create a capturing group.\n * - (-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?: This captures the first component of the shadow, which is the horizontal offset. Breaking it down:\n * - (-?\\d+): Captures an optional minus sign followed by one or more digits (integer part of the number).\n * - (?:\\.\\d*)?: Optionally captures a decimal point followed by zero or more digits (decimal part of the number).\n * - (?:px)?: Optionally captures the \"px\" unit.\n * - (?:\\s?|$): Captures either an optional whitespace or the end of the line. This whole part is wrapped in a non-capturing group and marked as optional with ?.\n * - (-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?: Similar to the previous step, this captures the vertical offset.\n\n(\\d+(?:\\.\\d*)?(?:px)?)?: This captures the blur radius. It's similar to the horizontal offset but without the optional minus sign.\n\n(?:\\s+(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?){0,1}: This captures an optional part for the color. It allows for whitespace followed by a component with an optional minus sign, digits, decimal point, and \"px\" unit.\n\n(?:$|\\s): This captures either the end of the line or a whitespace character. It ensures that the match ends either at the end of the string or with a whitespace character.\n */\n\nconst shadowOffsetRegex = '(-?\\\\d+(?:\\\\.\\\\d*)?(?:px)?(?:\\\\s?|$))?';\n\nconst reOffsetsAndBlur = new RegExp(\n '(?:\\\\s|^)' +\n shadowOffsetRegex +\n shadowOffsetRegex +\n '(' +\n reNum +\n '?(?:px)?)?(?:\\\\s?|$)(?:$|\\\\s)',\n);\n\nexport const shadowDefaultValues: Partial<TClassProperties<Shadow>> = {\n color: 'rgb(0,0,0)',\n blur: 0,\n offsetX: 0,\n offsetY: 0,\n affectStroke: false,\n includeDefaultValues: true,\n nonScaling: false,\n};\n\nexport type SerializedShadowOptions = {\n color: string;\n blur: number;\n offsetX: number;\n offsetY: number;\n affectStroke: boolean;\n nonScaling: boolean;\n type: string;\n};\n\nexport class Shadow {\n /**\n * Shadow color\n * @type String\n */\n declare color: string;\n\n /**\n * Shadow blur\n * @type Number\n */\n declare blur: number;\n\n /**\n * Shadow horizontal offset\n * @type Number\n */\n declare offsetX: number;\n\n /**\n * Shadow vertical offset\n * @type Number\n */\n declare offsetY: number;\n\n /**\n * Whether the shadow should affect stroke operations\n * @type Boolean\n */\n declare affectStroke: boolean;\n\n /**\n * Indicates whether toObject should include default values\n * @type Boolean\n */\n declare includeDefaultValues: boolean;\n\n /**\n * When `false`, the shadow will scale with the object.\n * When `true`, the shadow's offsetX, offsetY, and blur will not be affected by the object's scale.\n * default to false\n * @type Boolean\n */\n declare nonScaling: boolean;\n\n declare id: number | string;\n\n static ownDefaults = shadowDefaultValues;\n\n static type = 'shadow';\n\n /**\n * @see {@link http://fabric5.fabricjs.com/shadows|Shadow demo}\n * @param {Object|String} [options] Options object with any of color, blur, offsetX, offsetY properties or string (e.g. \"rgba(0,0,0,0.2) 2px 2px 10px\")\n */\n constructor(options?: Partial<TClassProperties<Shadow>>);\n constructor(svgAttribute: string);\n constructor(arg0: string | Partial<TClassProperties<Shadow>> = {}) {\n const options: Partial<TClassProperties<Shadow>> =\n typeof arg0 === 'string' ? Shadow.parseShadow(arg0) : arg0;\n Object.assign(this, Shadow.ownDefaults, options);\n this.id = uid();\n }\n\n /**\n * @param {String} value Shadow value to parse\n * @return {Object} Shadow object with color, offsetX, offsetY and blur\n */\n static parseShadow(value: string) {\n const shadowStr = value.trim(),\n [, offsetX = 0, offsetY = 0, blur = 0] = (\n reOffsetsAndBlur.exec(shadowStr) || []\n ).map((value) => parseFloat(value) || 0),\n color = (shadowStr.replace(reOffsetsAndBlur, '') || 'rgb(0,0,0)').trim();\n\n return {\n color,\n offsetX,\n offsetY,\n blur,\n };\n }\n\n /**\n * Returns a string representation of an instance\n * @see http://www.w3.org/TR/css-text-decor-3/#text-shadow\n * @return {String} Returns CSS3 text-shadow declaration\n */\n toString() {\n return [this.offsetX, this.offsetY, this.blur, this.color].join('px ');\n }\n\n /**\n * Returns SVG representation of a shadow\n * @param {FabricObject} object\n * @return {String} SVG representation of a shadow\n */\n toSVG(object: FabricObject) {\n const offset = rotateVector(\n new Point(this.offsetX, this.offsetY),\n degreesToRadians(-object.angle),\n ),\n BLUR_BOX = 20,\n NUM_FRACTION_DIGITS = config.NUM_FRACTION_DIGITS,\n color = new Color(this.color);\n let fBoxX = 40,\n fBoxY = 40;\n\n if (object.width && object.height) {\n //http://www.w3.org/TR/SVG/filters.html#FilterEffectsRegion\n // we add some extra space to filter box to contain the blur ( 20 )\n fBoxX =\n toFixed(\n (Math.abs(offset.x) + this.blur) / object.width,\n NUM_FRACTION_DIGITS,\n ) *\n 100 +\n BLUR_BOX;\n fBoxY =\n toFixed(\n (Math.abs(offset.y) + this.blur) / object.height,\n NUM_FRACTION_DIGITS,\n ) *\n 100 +\n BLUR_BOX;\n }\n if (object.flipX) {\n offset.x *= -1;\n }\n if (object.flipY) {\n offset.y *= -1;\n }\n\n return `<filter id=\"SVGID_${escapeXml(this.id)}\" y=\"-${fBoxY}%\" height=\"${\n 100 + 2 * fBoxY\n }%\" x=\"-${fBoxX}%\" width=\"${\n 100 + 2 * fBoxX\n }%\" >\\n\\t<feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"${toFixed(\n this.blur ? this.blur / 2 : 0,\n NUM_FRACTION_DIGITS,\n )}\"></feGaussianBlur>\\n\\t<feOffset dx=\"${toFixed(\n offset.x,\n NUM_FRACTION_DIGITS,\n )}\" dy=\"${toFixed(\n offset.y,\n NUM_FRACTION_DIGITS,\n )}\" result=\"oBlur\" ></feOffset>\\n\\t<feFlood flood-color=\"${color.toRgb()}\" flood-opacity=\"${color.getAlpha()}\"/>\\n\\t<feComposite in2=\"oBlur\" operator=\"in\" />\\n\\t<feMerge>\\n\\t\\t<feMergeNode></feMergeNode>\\n\\t\\t<feMergeNode in=\"SourceGraphic\"></feMergeNode>\\n\\t</feMerge>\\n</filter>\\n`;\n }\n\n /**\n * Returns object representation of a shadow\n * @return {Object} Object representation of a shadow instance\n */\n toObject() {\n const data: SerializedShadowOptions = {\n color: this.color,\n blur: this.blur,\n offsetX: this.offsetX,\n offsetY: this.offsetY,\n affectStroke: this.affectStroke,\n nonScaling: this.nonScaling,\n type: (this.constructor as typeof Shadow).type,\n };\n const defaults = Shadow.ownDefaults as SerializedShadowOptions;\n return !this.includeDefaultValues\n ? pickBy(data, (value, key) => value !== defaults[key])\n : data;\n }\n\n static async fromObject(options: Partial<TClassProperties<Shadow>>) {\n return new this(options);\n }\n}\n\nclassRegistry.setClass(Shadow, 'shadow');\n"],"names":["shadowOffsetRegex","reOffsetsAndBlur","RegExp","reNum","shadowDefaultValues","color","blur","offsetX","offsetY","affectStroke","includeDefaultValues","nonScaling","Shadow","constructor","arg0","arguments","length","undefined","options","parseShadow","Object","assign","this","ownDefaults","id","uid","value","shadowStr","trim","exec","map","parseFloat","replace","toString","join","toSVG","object","offset","rotateVector","Point","degreesToRadians","angle","NUM_FRACTION_DIGITS","config","Color","fBoxX","fBoxY","width","height","toFixed","Math","abs","x","y","flipX","flipY","escapeXml","toRgb","getAlpha","toObject","data","type","defaults","pickBy","key","fromObject","_defineProperty","classRegistry","setClass"],"mappings":"upBA+BA,MAAMA,EAAoB,yCAEpBC,EAAmB,IAAIC,OAC3B,YACEF,EACAA,EACA,IACAG,EACA,iCAGSC,EAAyD,CACpEC,MAAO,aACPC,KAAM,EACNC,QAAS,EACTC,QAAS,EACTC,cAAc,EACdC,sBAAsB,EACtBC,YAAY,GAaP,MAAMC,EAyDXC,WAAAA,GAAmE,IAAvDC,EAAgDC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,CAAA,EAC7D,MAAMG,EACY,iBAATJ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AMAC,QAAAA,GACE,MAAMC,EAAgC,CACpCvD,MAAOiB,KAAKjB,MACZC,KAAMgB,KAAKhB,KACXC,QAASe,KAAKf,QACdC,QAASc,KAAKd,QACdC,aAAca,KAAKb,aACnBE,WAAYW,KAAKX,WACjBkD,KAAOvC,KAAKT,YAA8BgD,MAEtCC,EAAWlD,EAAOW,YACxB,OAAQD,KAAKZ,qBAETkD,EADAG,EAAOH,EAAM,CAAClC,EAAOsC,IAAQtC,IAAUoC,EAASE,GAEtD,CAEA,uBAAaC,CAAW/C,GACtB,OAAO,IAAII,KAAKJ,EAClB,EAtIAgD,EArCWtD,EAAM,cA+CIR,GAAmB8D,EA/C7BtD,EAAM,OAiDH,UA6HhBuD,EAAcC,SAASxD,EAAQ"}
|
package/dist/src/Shadow.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { config } from './config.mjs';
|
|
|
5
5
|
import { reNum } from './parser/constants.mjs';
|
|
6
6
|
import { Point } from './Point.mjs';
|
|
7
7
|
import { uid } from './util/internals/uid.mjs';
|
|
8
|
+
import { escapeXml } from './util/lang_string.mjs';
|
|
8
9
|
import { pickBy } from './util/misc/pick.mjs';
|
|
9
10
|
import { degreesToRadians } from './util/misc/radiansDegreesConversion.mjs';
|
|
10
11
|
import { toFixed } from './util/misc/toFixed.mjs';
|
|
@@ -26,7 +27,6 @@ import { rotateVector } from './util/misc/vectors.mjs';
|
|
|
26
27
|
|
|
27
28
|
(?:$|\s): This captures either the end of the line or a whitespace character. It ensures that the match ends either at the end of the string or with a whitespace character.
|
|
28
29
|
*/
|
|
29
|
-
// eslint-disable-next-line max-len
|
|
30
30
|
|
|
31
31
|
const shadowOffsetRegex = '(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?';
|
|
32
32
|
const reOffsetsAndBlur = new RegExp('(?:\\s|^)' + shadowOffsetRegex + shadowOffsetRegex + '(' + reNum + '?(?:px)?)?(?:\\s?|$)(?:$|\\s)');
|
|
@@ -85,14 +85,15 @@ class Shadow {
|
|
|
85
85
|
toSVG(object) {
|
|
86
86
|
const offset = rotateVector(new Point(this.offsetX, this.offsetY), degreesToRadians(-object.angle)),
|
|
87
87
|
BLUR_BOX = 20,
|
|
88
|
+
NUM_FRACTION_DIGITS = config.NUM_FRACTION_DIGITS,
|
|
88
89
|
color = new Color(this.color);
|
|
89
90
|
let fBoxX = 40,
|
|
90
91
|
fBoxY = 40;
|
|
91
92
|
if (object.width && object.height) {
|
|
92
93
|
//http://www.w3.org/TR/SVG/filters.html#FilterEffectsRegion
|
|
93
94
|
// we add some extra space to filter box to contain the blur ( 20 )
|
|
94
|
-
fBoxX = toFixed((Math.abs(offset.x) + this.blur) / object.width,
|
|
95
|
-
fBoxY = toFixed((Math.abs(offset.y) + this.blur) / object.height,
|
|
95
|
+
fBoxX = toFixed((Math.abs(offset.x) + this.blur) / object.width, NUM_FRACTION_DIGITS) * 100 + BLUR_BOX;
|
|
96
|
+
fBoxY = toFixed((Math.abs(offset.y) + this.blur) / object.height, NUM_FRACTION_DIGITS) * 100 + BLUR_BOX;
|
|
96
97
|
}
|
|
97
98
|
if (object.flipX) {
|
|
98
99
|
offset.x *= -1;
|
|
@@ -100,7 +101,7 @@ class Shadow {
|
|
|
100
101
|
if (object.flipY) {
|
|
101
102
|
offset.y *= -1;
|
|
102
103
|
}
|
|
103
|
-
return `<filter id="SVGID_${this.id}" y="-${fBoxY}%" height="${100 + 2 * fBoxY}%" x="-${fBoxX}%" width="${100 + 2 * fBoxX}%" >\n\t<feGaussianBlur in="SourceAlpha" stdDeviation="${toFixed(this.blur ? this.blur / 2 : 0,
|
|
104
|
+
return `<filter id="SVGID_${escapeXml(this.id)}" y="-${fBoxY}%" height="${100 + 2 * fBoxY}%" x="-${fBoxX}%" width="${100 + 2 * fBoxX}%" >\n\t<feGaussianBlur in="SourceAlpha" stdDeviation="${toFixed(this.blur ? this.blur / 2 : 0, NUM_FRACTION_DIGITS)}"></feGaussianBlur>\n\t<feOffset dx="${toFixed(offset.x, NUM_FRACTION_DIGITS)}" dy="${toFixed(offset.y, NUM_FRACTION_DIGITS)}" result="oBlur" ></feOffset>\n\t<feFlood flood-color="${color.toRgb()}" flood-opacity="${color.getAlpha()}"/>\n\t<feComposite in2="oBlur" operator="in" />\n\t<feMerge>\n\t\t<feMergeNode></feMergeNode>\n\t\t<feMergeNode in="SourceGraphic"></feMergeNode>\n\t</feMerge>\n</filter>\n`;
|
|
104
105
|
}
|
|
105
106
|
|
|
106
107
|
/**
|
package/dist/src/Shadow.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Shadow.mjs","sources":["../../src/Shadow.ts"],"sourcesContent":["import { classRegistry } from './ClassRegistry';\nimport { Color } from './color/Color';\nimport { config } from './config';\nimport { reNum } from './parser/constants';\nimport { Point } from './Point';\nimport type { FabricObject } from './shapes/Object/FabricObject';\nimport type { TClassProperties } from './typedefs';\nimport { uid } from './util/internals/uid';\nimport { pickBy } from './util/misc/pick';\nimport { degreesToRadians } from './util/misc/radiansDegreesConversion';\nimport { toFixed } from './util/misc/toFixed';\nimport { rotateVector } from './util/misc/vectors';\n\n/**\n * Regex matching shadow offsetX, offsetY and blur (ex: \"2px 2px 10px rgba(0,0,0,0.2)\", \"rgb(0,255,0) 2px 2px\")\n * - (?:\\s|^): This part captures either a whitespace character (\\s) or the beginning of a line (^). It's non-capturing (due to (?:...)), meaning it doesn't create a capturing group.\n * - (-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?: This captures the first component of the shadow, which is the horizontal offset. Breaking it down:\n * - (-?\\d+): Captures an optional minus sign followed by one or more digits (integer part of the number).\n * - (?:\\.\\d*)?: Optionally captures a decimal point followed by zero or more digits (decimal part of the number).\n * - (?:px)?: Optionally captures the \"px\" unit.\n * - (?:\\s?|$): Captures either an optional whitespace or the end of the line. This whole part is wrapped in a non-capturing group and marked as optional with ?.\n * - (-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?: Similar to the previous step, this captures the vertical offset.\n\n(\\d+(?:\\.\\d*)?(?:px)?)?: This captures the blur radius. It's similar to the horizontal offset but without the optional minus sign.\n\n(?:\\s+(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?){0,1}: This captures an optional part for the color. It allows for whitespace followed by a component with an optional minus sign, digits, decimal point, and \"px\" unit.\n\n(?:$|\\s): This captures either the end of the line or a whitespace character. It ensures that the match ends either at the end of the string or with a whitespace character.\n */\n// eslint-disable-next-line max-len\n\nconst shadowOffsetRegex = '(-?\\\\d+(?:\\\\.\\\\d*)?(?:px)?(?:\\\\s?|$))?';\n\nconst reOffsetsAndBlur = new RegExp(\n '(?:\\\\s|^)' +\n shadowOffsetRegex +\n shadowOffsetRegex +\n '(' +\n reNum +\n '?(?:px)?)?(?:\\\\s?|$)(?:$|\\\\s)',\n);\n\nexport const shadowDefaultValues: Partial<TClassProperties<Shadow>> = {\n color: 'rgb(0,0,0)',\n blur: 0,\n offsetX: 0,\n offsetY: 0,\n affectStroke: false,\n includeDefaultValues: true,\n nonScaling: false,\n};\n\nexport type SerializedShadowOptions = {\n color: string;\n blur: number;\n offsetX: number;\n offsetY: number;\n affectStroke: boolean;\n nonScaling: boolean;\n type: string;\n};\n\nexport class Shadow {\n /**\n * Shadow color\n * @type String\n */\n declare color: string;\n\n /**\n * Shadow blur\n * @type Number\n */\n declare blur: number;\n\n /**\n * Shadow horizontal offset\n * @type Number\n */\n declare offsetX: number;\n\n /**\n * Shadow vertical offset\n * @type Number\n */\n declare offsetY: number;\n\n /**\n * Whether the shadow should affect stroke operations\n * @type Boolean\n */\n declare affectStroke: boolean;\n\n /**\n * Indicates whether toObject should include default values\n * @type Boolean\n */\n declare includeDefaultValues: boolean;\n\n /**\n * When `false`, the shadow will scale with the object.\n * When `true`, the shadow's offsetX, offsetY, and blur will not be affected by the object's scale.\n * default to false\n * @type Boolean\n */\n declare nonScaling: boolean;\n\n declare id: number;\n\n static ownDefaults = shadowDefaultValues;\n\n static type = 'shadow';\n\n /**\n * @see {@link http://fabric5.fabricjs.com/shadows|Shadow demo}\n * @param {Object|String} [options] Options object with any of color, blur, offsetX, offsetY properties or string (e.g. \"rgba(0,0,0,0.2) 2px 2px 10px\")\n */\n constructor(options?: Partial<TClassProperties<Shadow>>);\n constructor(svgAttribute: string);\n constructor(arg0: string | Partial<TClassProperties<Shadow>> = {}) {\n const options: Partial<TClassProperties<Shadow>> =\n typeof arg0 === 'string' ? Shadow.parseShadow(arg0) : arg0;\n Object.assign(this, Shadow.ownDefaults, options);\n this.id = uid();\n }\n\n /**\n * @param {String} value Shadow value to parse\n * @return {Object} Shadow object with color, offsetX, offsetY and blur\n */\n static parseShadow(value: string) {\n const shadowStr = value.trim(),\n [, offsetX = 0, offsetY = 0, blur = 0] = (\n reOffsetsAndBlur.exec(shadowStr) || []\n ).map((value) => parseFloat(value) || 0),\n color = (shadowStr.replace(reOffsetsAndBlur, '') || 'rgb(0,0,0)').trim();\n\n return {\n color,\n offsetX,\n offsetY,\n blur,\n };\n }\n\n /**\n * Returns a string representation of an instance\n * @see http://www.w3.org/TR/css-text-decor-3/#text-shadow\n * @return {String} Returns CSS3 text-shadow declaration\n */\n toString() {\n return [this.offsetX, this.offsetY, this.blur, this.color].join('px ');\n }\n\n /**\n * Returns SVG representation of a shadow\n * @param {FabricObject} object\n * @return {String} SVG representation of a shadow\n */\n toSVG(object: FabricObject) {\n const offset = rotateVector(\n new Point(this.offsetX, this.offsetY),\n degreesToRadians(-object.angle),\n ),\n BLUR_BOX = 20,\n color = new Color(this.color);\n let fBoxX = 40,\n fBoxY = 40;\n\n if (object.width && object.height) {\n //http://www.w3.org/TR/SVG/filters.html#FilterEffectsRegion\n // we add some extra space to filter box to contain the blur ( 20 )\n fBoxX =\n toFixed(\n (Math.abs(offset.x) + this.blur) / object.width,\n config.NUM_FRACTION_DIGITS,\n ) *\n 100 +\n BLUR_BOX;\n fBoxY =\n toFixed(\n (Math.abs(offset.y) + this.blur) / object.height,\n config.NUM_FRACTION_DIGITS,\n ) *\n 100 +\n BLUR_BOX;\n }\n if (object.flipX) {\n offset.x *= -1;\n }\n if (object.flipY) {\n offset.y *= -1;\n }\n\n return `<filter id=\"SVGID_${this.id}\" y=\"-${fBoxY}%\" height=\"${\n 100 + 2 * fBoxY\n }%\" x=\"-${fBoxX}%\" width=\"${\n 100 + 2 * fBoxX\n }%\" >\\n\\t<feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"${toFixed(\n this.blur ? this.blur / 2 : 0,\n config.NUM_FRACTION_DIGITS,\n )}\"></feGaussianBlur>\\n\\t<feOffset dx=\"${toFixed(\n offset.x,\n config.NUM_FRACTION_DIGITS,\n )}\" dy=\"${toFixed(\n offset.y,\n config.NUM_FRACTION_DIGITS,\n )}\" result=\"oBlur\" ></feOffset>\\n\\t<feFlood flood-color=\"${color.toRgb()}\" flood-opacity=\"${color.getAlpha()}\"/>\\n\\t<feComposite in2=\"oBlur\" operator=\"in\" />\\n\\t<feMerge>\\n\\t\\t<feMergeNode></feMergeNode>\\n\\t\\t<feMergeNode in=\"SourceGraphic\"></feMergeNode>\\n\\t</feMerge>\\n</filter>\\n`;\n }\n\n /**\n * Returns object representation of a shadow\n * @return {Object} Object representation of a shadow instance\n */\n toObject() {\n const data: SerializedShadowOptions = {\n color: this.color,\n blur: this.blur,\n offsetX: this.offsetX,\n offsetY: this.offsetY,\n affectStroke: this.affectStroke,\n nonScaling: this.nonScaling,\n type: (this.constructor as typeof Shadow).type,\n };\n const defaults = Shadow.ownDefaults as SerializedShadowOptions;\n return !this.includeDefaultValues\n ? pickBy(data, (value, key) => value !== defaults[key])\n : data;\n }\n\n static async fromObject(options: Partial<TClassProperties<Shadow>>) {\n return new this(options);\n }\n}\n\nclassRegistry.setClass(Shadow, 'shadow');\n"],"names":["shadowOffsetRegex","reOffsetsAndBlur","RegExp","reNum","shadowDefaultValues","color","blur","offsetX","offsetY","affectStroke","includeDefaultValues","nonScaling","Shadow","constructor","arg0","arguments","length","undefined","options","parseShadow","Object","assign","ownDefaults","id","uid","value","shadowStr","trim","exec","map","parseFloat","replace","toString","join","toSVG","object","offset","rotateVector","Point","degreesToRadians","angle","BLUR_BOX","Color","fBoxX","fBoxY","width","height","toFixed","Math","abs","x","config","NUM_FRACTION_DIGITS","y","flipX","flipY","toRgb","getAlpha","toObject","data","type","defaults","pickBy","key","fromObject","_defineProperty","classRegistry","setClass"],"mappings":";;;;;;;;;;;;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;;AAEA,MAAMA,iBAAiB,GAAG,wCAAwC;AAElE,MAAMC,gBAAgB,GAAG,IAAIC,MAAM,CACjC,WAAW,GACTF,iBAAiB,GACjBA,iBAAiB,GACjB,GAAG,GACHG,KAAK,GACL,+BACJ,CAAC;AAEM,MAAMC,mBAAsD,GAAG;AACpEC,EAAAA,KAAK,EAAE,YAAY;AACnBC,EAAAA,IAAI,EAAE,CAAC;AACPC,EAAAA,OAAO,EAAE,CAAC;AACVC,EAAAA,OAAO,EAAE,CAAC;AACVC,EAAAA,YAAY,EAAE,KAAK;AACnBC,EAAAA,oBAAoB,EAAE,IAAI;AAC1BC,EAAAA,UAAU,EAAE;AACd;AAYO,MAAMC,MAAM,CAAC;AAmDlB;AACF;AACA;AACA;;AAGEC,EAAAA,WAAWA,GAAwD;AAAA,IAAA,IAAvDC,IAAgD,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,EAAE;AAC/D,IAAA,MAAMG,OAA0C,GAC9C,OAAOJ,IAAI,KAAK,QAAQ,GAAGF,MAAM,CAACO,WAAW,CAACL,IAAI,CAAC,GAAGA,IAAI;IAC5DM,MAAM,CAACC,MAAM,CAAC,IAAI,EAAET,MAAM,CAACU,WAAW,EAAEJ,OAAO,CAAC;AAChD,IAAA,IAAI,CAACK,EAAE,GAAGC,GAAG,EAAE;AACjB,E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F;AACA;AACA;AACEC,EAAAA,QAAQA,GAAG;AACT,IAAA,MAAMC,IAA6B,GAAG;MACpCtD,KAAK,EAAE,IAAI,CAACA,KAAK;MACjBC,IAAI,EAAE,IAAI,CAACA,IAAI;MACfC,OAAO,EAAE,IAAI,CAACA,OAAO;MACrBC,OAAO,EAAE,IAAI,CAACA,OAAO;MACrBC,YAAY,EAAE,IAAI,CAACA,YAAY;MAC/BE,UAAU,EAAE,IAAI,CAACA,UAAU;AAC3BiD,MAAAA,IAAI,EAAG,IAAI,CAAC/C,WAAW,CAAmB+C;KAC3C;AACD,IAAA,MAAMC,QAAQ,GAAGjD,MAAM,CAACU,WAAsC;IAC9D,OAAO,CAAC,IAAI,CAACZ,oBAAoB,GAC7BoD,MAAM,CAACH,IAAI,EAAE,CAAClC,KAAK,EAAEsC,GAAG,KAAKtC,KAAK,KAAKoC,QAAQ,CAACE,GAAG,CAAC,CAAC,GACrDJ,IAAI;AACV,EAAA;EAEA,aAAaK,UAAUA,CAAC9C,OAA0C,EAAE;AAClE,IAAA,OAAO,IAAI,IAAI,CAACA,OAAO,CAAC;AAC1B,EAAA;AACF;AA1KE;AACF;AACA;AACA;AAGE;AACF;AACA;AACA;AAGE;AACF;AACA;AACA;AAGE;AACF;AACA;AACA;AAGE;AACF;AACA;AACA;AAGE;AACF;AACA;AACA;AAGE;AACF;AACA;AACA;AACA;AACA;AALE+C,eAAA,CArCWrD,MAAM,EAAA,aAAA,EA+CIR,mBAAmB,CAAA;AAAA6D,eAAA,CA/C7BrD,MAAM,EAAA,MAAA,EAiDH,QAAQ,CAAA;AA4HxBsD,aAAa,CAACC,QAAQ,CAACvD,MAAM,EAAE,QAAQ,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"Shadow.mjs","sources":["../../src/Shadow.ts"],"sourcesContent":["import { classRegistry } from './ClassRegistry';\nimport { Color } from './color/Color';\nimport { config } from './config';\nimport { reNum } from './parser/constants';\nimport { Point } from './Point';\nimport type { FabricObject } from './shapes/Object/FabricObject';\nimport type { TClassProperties } from './typedefs';\nimport { uid } from './util/internals/uid';\nimport { escapeXml } from './util/lang_string';\nimport { pickBy } from './util/misc/pick';\nimport { degreesToRadians } from './util/misc/radiansDegreesConversion';\nimport { toFixed } from './util/misc/toFixed';\nimport { rotateVector } from './util/misc/vectors';\n\n/**\n * Regex matching shadow offsetX, offsetY and blur (ex: \"2px 2px 10px rgba(0,0,0,0.2)\", \"rgb(0,255,0) 2px 2px\")\n * - (?:\\s|^): This part captures either a whitespace character (\\s) or the beginning of a line (^). It's non-capturing (due to (?:...)), meaning it doesn't create a capturing group.\n * - (-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?: This captures the first component of the shadow, which is the horizontal offset. Breaking it down:\n * - (-?\\d+): Captures an optional minus sign followed by one or more digits (integer part of the number).\n * - (?:\\.\\d*)?: Optionally captures a decimal point followed by zero or more digits (decimal part of the number).\n * - (?:px)?: Optionally captures the \"px\" unit.\n * - (?:\\s?|$): Captures either an optional whitespace or the end of the line. This whole part is wrapped in a non-capturing group and marked as optional with ?.\n * - (-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?: Similar to the previous step, this captures the vertical offset.\n\n(\\d+(?:\\.\\d*)?(?:px)?)?: This captures the blur radius. It's similar to the horizontal offset but without the optional minus sign.\n\n(?:\\s+(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?){0,1}: This captures an optional part for the color. It allows for whitespace followed by a component with an optional minus sign, digits, decimal point, and \"px\" unit.\n\n(?:$|\\s): This captures either the end of the line or a whitespace character. It ensures that the match ends either at the end of the string or with a whitespace character.\n */\n\nconst shadowOffsetRegex = '(-?\\\\d+(?:\\\\.\\\\d*)?(?:px)?(?:\\\\s?|$))?';\n\nconst reOffsetsAndBlur = new RegExp(\n '(?:\\\\s|^)' +\n shadowOffsetRegex +\n shadowOffsetRegex +\n '(' +\n reNum +\n '?(?:px)?)?(?:\\\\s?|$)(?:$|\\\\s)',\n);\n\nexport const shadowDefaultValues: Partial<TClassProperties<Shadow>> = {\n color: 'rgb(0,0,0)',\n blur: 0,\n offsetX: 0,\n offsetY: 0,\n affectStroke: false,\n includeDefaultValues: true,\n nonScaling: false,\n};\n\nexport type SerializedShadowOptions = {\n color: string;\n blur: number;\n offsetX: number;\n offsetY: number;\n affectStroke: boolean;\n nonScaling: boolean;\n type: string;\n};\n\nexport class Shadow {\n /**\n * Shadow color\n * @type String\n */\n declare color: string;\n\n /**\n * Shadow blur\n * @type Number\n */\n declare blur: number;\n\n /**\n * Shadow horizontal offset\n * @type Number\n */\n declare offsetX: number;\n\n /**\n * Shadow vertical offset\n * @type Number\n */\n declare offsetY: number;\n\n /**\n * Whether the shadow should affect stroke operations\n * @type Boolean\n */\n declare affectStroke: boolean;\n\n /**\n * Indicates whether toObject should include default values\n * @type Boolean\n */\n declare includeDefaultValues: boolean;\n\n /**\n * When `false`, the shadow will scale with the object.\n * When `true`, the shadow's offsetX, offsetY, and blur will not be affected by the object's scale.\n * default to false\n * @type Boolean\n */\n declare nonScaling: boolean;\n\n declare id: number | string;\n\n static ownDefaults = shadowDefaultValues;\n\n static type = 'shadow';\n\n /**\n * @see {@link http://fabric5.fabricjs.com/shadows|Shadow demo}\n * @param {Object|String} [options] Options object with any of color, blur, offsetX, offsetY properties or string (e.g. \"rgba(0,0,0,0.2) 2px 2px 10px\")\n */\n constructor(options?: Partial<TClassProperties<Shadow>>);\n constructor(svgAttribute: string);\n constructor(arg0: string | Partial<TClassProperties<Shadow>> = {}) {\n const options: Partial<TClassProperties<Shadow>> =\n typeof arg0 === 'string' ? Shadow.parseShadow(arg0) : arg0;\n Object.assign(this, Shadow.ownDefaults, options);\n this.id = uid();\n }\n\n /**\n * @param {String} value Shadow value to parse\n * @return {Object} Shadow object with color, offsetX, offsetY and blur\n */\n static parseShadow(value: string) {\n const shadowStr = value.trim(),\n [, offsetX = 0, offsetY = 0, blur = 0] = (\n reOffsetsAndBlur.exec(shadowStr) || []\n ).map((value) => parseFloat(value) || 0),\n color = (shadowStr.replace(reOffsetsAndBlur, '') || 'rgb(0,0,0)').trim();\n\n return {\n color,\n offsetX,\n offsetY,\n blur,\n };\n }\n\n /**\n * Returns a string representation of an instance\n * @see http://www.w3.org/TR/css-text-decor-3/#text-shadow\n * @return {String} Returns CSS3 text-shadow declaration\n */\n toString() {\n return [this.offsetX, this.offsetY, this.blur, this.color].join('px ');\n }\n\n /**\n * Returns SVG representation of a shadow\n * @param {FabricObject} object\n * @return {String} SVG representation of a shadow\n */\n toSVG(object: FabricObject) {\n const offset = rotateVector(\n new Point(this.offsetX, this.offsetY),\n degreesToRadians(-object.angle),\n ),\n BLUR_BOX = 20,\n NUM_FRACTION_DIGITS = config.NUM_FRACTION_DIGITS,\n color = new Color(this.color);\n let fBoxX = 40,\n fBoxY = 40;\n\n if (object.width && object.height) {\n //http://www.w3.org/TR/SVG/filters.html#FilterEffectsRegion\n // we add some extra space to filter box to contain the blur ( 20 )\n fBoxX =\n toFixed(\n (Math.abs(offset.x) + this.blur) / object.width,\n NUM_FRACTION_DIGITS,\n ) *\n 100 +\n BLUR_BOX;\n fBoxY =\n toFixed(\n (Math.abs(offset.y) + this.blur) / object.height,\n NUM_FRACTION_DIGITS,\n ) *\n 100 +\n BLUR_BOX;\n }\n if (object.flipX) {\n offset.x *= -1;\n }\n if (object.flipY) {\n offset.y *= -1;\n }\n\n return `<filter id=\"SVGID_${escapeXml(this.id)}\" y=\"-${fBoxY}%\" height=\"${\n 100 + 2 * fBoxY\n }%\" x=\"-${fBoxX}%\" width=\"${\n 100 + 2 * fBoxX\n }%\" >\\n\\t<feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"${toFixed(\n this.blur ? this.blur / 2 : 0,\n NUM_FRACTION_DIGITS,\n )}\"></feGaussianBlur>\\n\\t<feOffset dx=\"${toFixed(\n offset.x,\n NUM_FRACTION_DIGITS,\n )}\" dy=\"${toFixed(\n offset.y,\n NUM_FRACTION_DIGITS,\n )}\" result=\"oBlur\" ></feOffset>\\n\\t<feFlood flood-color=\"${color.toRgb()}\" flood-opacity=\"${color.getAlpha()}\"/>\\n\\t<feComposite in2=\"oBlur\" operator=\"in\" />\\n\\t<feMerge>\\n\\t\\t<feMergeNode></feMergeNode>\\n\\t\\t<feMergeNode in=\"SourceGraphic\"></feMergeNode>\\n\\t</feMerge>\\n</filter>\\n`;\n }\n\n /**\n * Returns object representation of a shadow\n * @return {Object} Object representation of a shadow instance\n */\n toObject() {\n const data: SerializedShadowOptions = {\n color: this.color,\n blur: this.blur,\n offsetX: this.offsetX,\n offsetY: this.offsetY,\n affectStroke: this.affectStroke,\n nonScaling: this.nonScaling,\n type: (this.constructor as typeof Shadow).type,\n };\n const defaults = Shadow.ownDefaults as SerializedShadowOptions;\n return !this.includeDefaultValues\n ? pickBy(data, (value, key) => value !== defaults[key])\n : data;\n }\n\n static async fromObject(options: Partial<TClassProperties<Shadow>>) {\n return new this(options);\n }\n}\n\nclassRegistry.setClass(Shadow, 'shadow');\n"],"names":["shadowOffsetRegex","reOffsetsAndBlur","RegExp","reNum","shadowDefaultValues","color","blur","offsetX","offsetY","affectStroke","includeDefaultValues","nonScaling","Shadow","constructor","arg0","arguments","length","undefined","options","parseShadow","Object","assign","ownDefaults","id","uid","value","shadowStr","trim","exec","map","parseFloat","replace","toString","join","toSVG","object","offset","rotateVector","Point","degreesToRadians","angle","BLUR_BOX","NUM_FRACTION_DIGITS","config","Color","fBoxX","fBoxY","width","height","toFixed","Math","abs","x","y","flipX","flipY","escapeXml","toRgb","getAlpha","toObject","data","type","defaults","pickBy","key","fromObject","_defineProperty","classRegistry","setClass"],"mappings":";;;;;;;;;;;;;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA,MAAMA,iBAAiB,GAAG,wCAAwC;AAElE,MAAMC,gBAAgB,GAAG,IAAIC,MAAM,CACjC,WAAW,GACTF,iBAAiB,GACjBA,iBAAiB,GACjB,GAAG,GACHG,KAAK,GACL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GAC7BqD,MAAM,CAACH,IAAI,EAAE,CAACnC,KAAK,EAAEuC,GAAG,KAAKvC,KAAK,KAAKqC,QAAQ,CAACE,GAAG,CAAC,CAAC,GACrDJ,IAAI;AACV,EAAA;EAEA,aAAaK,UAAUA,CAAC/C,OAA0C,EAAE;AAClE,IAAA,OAAO,IAAI,IAAI,CAACA,OAAO,CAAC;AAC1B,EAAA;AACF;AA3KE;AACF;AACA;AACA;AAGE;AACF;AACA;AACA;AAGE;AACF;AACA;AACA;AAGE;AACF;AACA;AACA;AAGE;AACF;AACA;AACA;AAGE;AACF;AACA;AACA;AAGE;AACF;AACA;AACA;AACA;AACA;AALEgD,eAAA,CArCWtD,MAAM,EAAA,aAAA,EA+CIR,mBAAmB,CAAA;AAAA8D,eAAA,CA/C7BtD,MAAM,EAAA,MAAA,EAiDH,QAAQ,CAAA;AA6HxBuD,aAAa,CAACC,QAAQ,CAACxD,MAAM,EAAE,QAAQ,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CanvasOptions.d.ts","sourceRoot":"","sources":["../../../src/canvas/CanvasOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,MAAM,WAAW,sBAAsB;IACrC;;;;;OAKG;IACH,cAAc,EAAE,OAAO,CAAC;IAExB;;;;;;;;;;OAUG;IACH,WAAW,EAAE,oBAAoB,CAAC;IAElC;;;;;OAKG;IACH,eAAe,EAAE,OAAO,CAAC;IAEzB;;;;;OAKG;IACH,gBAAgB,EAAE,OAAO,CAAC;IAE1B;;;;;;;OAOG;IACH,WAAW,EAAE,oBAAoB,CAAC;IAElC;;;;;;;OAOG;IACH,YAAY,EAAE,oBAAoB,CAAC;CACpC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AIG;IACH,aAAa,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAE7C;;;;OAIG;IACH,iBAAiB,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAEjD;;;;;OAKG;IACH,gBAAgB,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;CACjD;AAED,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,kBAAkB,EAAE,OAAO,CAAC;IAE5B;;;OAGG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAE5B;;;;;;;OAOG;IACH,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,mBAAmB;IAClC;;;;;;;OAOG;IACH,eAAe,EAAE,OAAO,CAAC;IAEzB;;;;;;;OAOG;IACH,cAAc,EAAE,OAAO,CAAC;IAExB;;;;;;;OAOG;IACH,eAAe,EAAE,OAAO,CAAC;IAEzB;;;OAGG;IACH,mBAAmB,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,WAAW,aACf,SACE,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB;IACrB;;;;OAIG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;;;;OAKG;IACH,sBAAsB,EAAE,OAAO,CAAC;CACjC;AAED,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC;AAErD,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,aAAa,CAiClD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CanvasOptions.min.mjs","sources":["../../../src/canvas/CanvasOptions.ts"],"sourcesContent":["import type { ModifierKey, TOptionalModifierKey } from '../EventTypeDefs';\nimport type { TOptions } from '../typedefs';\nimport type { StaticCanvasOptions } from './StaticCanvasOptions';\n\nexport interface CanvasTransformOptions {\n /**\n * When true, objects can be transformed by one side (unproportionately)\n * when dragged on the corners that normally would not do that.\n * @type Boolean\n * @since fabric 4.0 // changed name and default value\n */\n uniformScaling: boolean;\n\n /**\n * Indicates which key switches uniform scaling.\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled.\n * totally wrong named. this sounds like `uniform scaling`\n * if Canvas.uniformScaling is true, pressing this will set it to false\n * and viceversa.\n * @since 1.6.2\n * @type ModifierKey\n */\n uniScaleKey: TOptionalModifierKey;\n\n /**\n * When true, objects use center point as the origin of scale transformation.\n * <b>Backwards incompatibility note:</b> This property replaces \"centerTransform\" (Boolean).\n * @since 1.3.4\n * @type Boolean\n */\n centeredScaling: boolean;\n\n /**\n * When true, objects use center point as the origin of rotate transformation.\n * <b>Backwards incompatibility note:</b> This property replaces \"centerTransform\" (Boolean).\n * @since 1.3.4\n * @type Boolean\n */\n centeredRotation: boolean;\n\n /**\n * Indicates which key enable centered Transform\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled feature disabled.\n * @since 1.6.2\n * @type ModifierKey\n */\n centeredKey: TOptionalModifierKey;\n\n /**\n * Indicates which key enable alternate action on corner\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled feature disabled.\n * @since 1.6.2\n * @type ModifierKey\n */\n altActionKey: TOptionalModifierKey;\n}\n\nexport interface CanvasSelectionOptions {\n /**\n * Indicates whether group selection should be enabled\n * @type Boolean\n */\n selection: boolean;\n\n /**\n * Indicates which key or keys enable multiple click selection\n * Pass value as a string or array of strings\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or empty or containing any other string that is not a modifier key\n * feature is disabled.\n * @since 1.6.2\n * @type ModifierKey|ModifierKey[]\n */\n selectionKey: TOptionalModifierKey | ModifierKey[];\n\n /**\n * Indicates which key enable alternative selection\n * in case of a target overlapping with active object and we don't want to loose the\n * active selection, we can press this modifier key and continue selecting the current\n * selected object also when is covered by another or many valid targets for selection.\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * For a series of reason that come from the general expectations on how\n * things should work, this feature works only for preserveObjectStacking true.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled.\n * @since 1.6.5\n * @type null|ModifierKey\n */\n altSelectionKey: TOptionalModifierKey;\n\n /**\n * Color of selection\n * @type String\n */\n selectionColor: string;\n\n /**\n * Default dash array pattern\n * If not empty the selection border is dashed\n * @type Array\n */\n selectionDashArray: number[];\n\n /**\n * Color of the border of selection (usually slightly darker than color of selection itself)\n * @type String\n */\n selectionBorderColor: string;\n\n /**\n * Width of a line used in object/group selection\n * @type Number\n */\n selectionLineWidth: number;\n\n /**\n * Select only shapes that are fully contained in the dragged selection rectangle.\n * @type Boolean\n */\n selectionFullyContained: boolean;\n}\n\nexport interface CanvasCursorOptions {\n /**\n * Default cursor value used when hovering over an object on canvas\n * @type CSSStyleDeclaration['cursor']\n * @default move\n */\n hoverCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Default cursor value used when moving an object on canvas\n * @type CSSStyleDeclaration['cursor']\n * @default move\n */\n moveCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Default cursor value used for the entire canvas\n * @type String\n * @default default\n */\n defaultCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Cursor value used during free drawing\n * @type String\n * @default crosshair\n */\n freeDrawingCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Cursor value used for disabled elements ( corners with disabled action )\n * @type String\n * @since 2.0.0\n * @default not-allowed\n */\n notAllowedCursor: CSSStyleDeclaration['cursor'];\n}\n\nexport interface TargetFindOptions {\n /**\n * When true, object detection happens on per-pixel basis rather than on per-bounding-box\n * @type Boolean\n */\n perPixelTargetFind: boolean;\n\n /**\n * Number of pixels around target pixel to tolerate (consider active) during object detection\n * @type Number\n */\n targetFindTolerance: number;\n\n /**\n * When true, target detection is skipped. Target detection will return always undefined.\n * click selection won't work anymore, events will fire with no targets.\n * if something is selected before setting it to true, it will be deselected at the first click.\n * area selection will still work. check the `selection` property too.\n * if you deactivate both, you should look into staticCanvas.\n * @type Boolean\n */\n skipTargetFind: boolean;\n}\n\nexport interface CanvasEventsOptions {\n /**\n * Indicates if the right click on canvas can output the context menu or not\n * The default value changed from false to true in Fabric 7.0\n * @see https://fabricjs.com/docs/upgrading/upgrading-to-fabric-70/\n * @deprecated since 7.0, Will be removed in Fabric 8.0\n * @type Boolean\n * @since 1.6.5\n */\n stopContextMenu: boolean;\n\n /**\n * Indicates if the canvas can fire right click events\n * The default value changed from false to true in Fabric 7.0\n * @see https://fabricjs.com/docs/upgrading/upgrading-to-fabric-70/\n * @deprecated since 7.0, Will be removed in Fabric 8.0\n * @type Boolean\n * @since 1.6.5\n */\n fireRightClick: boolean;\n\n /**\n * Indicates if the canvas can fire middle click events\n * The default value changed from false to true in Fabric 7.0\n * @see https://fabricjs.com/docs/upgrading/upgrading-to-fabric-70/\n * @deprecated since 7.0, Will be removed in Fabric 8.0\n * @type Boolean\n * @since 1.7.8\n */\n fireMiddleClick: boolean;\n\n /**\n * When the option is enabled, PointerEvent is used instead of TPointerEvent.\n * @type Boolean\n */\n enablePointerEvents: boolean;\n}\n\nexport interface CanvasOptions\n extends
|
|
1
|
+
{"version":3,"file":"CanvasOptions.min.mjs","sources":["../../../src/canvas/CanvasOptions.ts"],"sourcesContent":["import type { ModifierKey, TOptionalModifierKey } from '../EventTypeDefs';\nimport type { TOptions } from '../typedefs';\nimport type { StaticCanvasOptions } from './StaticCanvasOptions';\n\nexport interface CanvasTransformOptions {\n /**\n * When true, objects can be transformed by one side (unproportionately)\n * when dragged on the corners that normally would not do that.\n * @type Boolean\n * @since fabric 4.0 // changed name and default value\n */\n uniformScaling: boolean;\n\n /**\n * Indicates which key switches uniform scaling.\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled.\n * totally wrong named. this sounds like `uniform scaling`\n * if Canvas.uniformScaling is true, pressing this will set it to false\n * and viceversa.\n * @since 1.6.2\n * @type ModifierKey\n */\n uniScaleKey: TOptionalModifierKey;\n\n /**\n * When true, objects use center point as the origin of scale transformation.\n * <b>Backwards incompatibility note:</b> This property replaces \"centerTransform\" (Boolean).\n * @since 1.3.4\n * @type Boolean\n */\n centeredScaling: boolean;\n\n /**\n * When true, objects use center point as the origin of rotate transformation.\n * <b>Backwards incompatibility note:</b> This property replaces \"centerTransform\" (Boolean).\n * @since 1.3.4\n * @type Boolean\n */\n centeredRotation: boolean;\n\n /**\n * Indicates which key enable centered Transform\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled feature disabled.\n * @since 1.6.2\n * @type ModifierKey\n */\n centeredKey: TOptionalModifierKey;\n\n /**\n * Indicates which key enable alternate action on corner\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled feature disabled.\n * @since 1.6.2\n * @type ModifierKey\n */\n altActionKey: TOptionalModifierKey;\n}\n\nexport interface CanvasSelectionOptions {\n /**\n * Indicates whether group selection should be enabled\n * @type Boolean\n */\n selection: boolean;\n\n /**\n * Indicates which key or keys enable multiple click selection\n * Pass value as a string or array of strings\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or empty or containing any other string that is not a modifier key\n * feature is disabled.\n * @since 1.6.2\n * @type ModifierKey|ModifierKey[]\n */\n selectionKey: TOptionalModifierKey | ModifierKey[];\n\n /**\n * Indicates which key enable alternative selection\n * in case of a target overlapping with active object and we don't want to loose the\n * active selection, we can press this modifier key and continue selecting the current\n * selected object also when is covered by another or many valid targets for selection.\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * For a series of reason that come from the general expectations on how\n * things should work, this feature works only for preserveObjectStacking true.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled.\n * @since 1.6.5\n * @type null|ModifierKey\n */\n altSelectionKey: TOptionalModifierKey;\n\n /**\n * Color of selection\n * @type String\n */\n selectionColor: string;\n\n /**\n * Default dash array pattern\n * If not empty the selection border is dashed\n * @type Array\n */\n selectionDashArray: number[];\n\n /**\n * Color of the border of selection (usually slightly darker than color of selection itself)\n * @type String\n */\n selectionBorderColor: string;\n\n /**\n * Width of a line used in object/group selection\n * @type Number\n */\n selectionLineWidth: number;\n\n /**\n * Select only shapes that are fully contained in the dragged selection rectangle.\n * @type Boolean\n */\n selectionFullyContained: boolean;\n}\n\nexport interface CanvasCursorOptions {\n /**\n * Default cursor value used when hovering over an object on canvas\n * @type CSSStyleDeclaration['cursor']\n * @default move\n */\n hoverCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Default cursor value used when moving an object on canvas\n * @type CSSStyleDeclaration['cursor']\n * @default move\n */\n moveCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Default cursor value used for the entire canvas\n * @type String\n * @default default\n */\n defaultCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Cursor value used during free drawing\n * @type String\n * @default crosshair\n */\n freeDrawingCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Cursor value used for disabled elements ( corners with disabled action )\n * @type String\n * @since 2.0.0\n * @default not-allowed\n */\n notAllowedCursor: CSSStyleDeclaration['cursor'];\n}\n\nexport interface TargetFindOptions {\n /**\n * When true, object detection happens on per-pixel basis rather than on per-bounding-box\n * @type Boolean\n */\n perPixelTargetFind: boolean;\n\n /**\n * Number of pixels around target pixel to tolerate (consider active) during object detection\n * @type Number\n */\n targetFindTolerance: number;\n\n /**\n * When true, target detection is skipped. Target detection will return always undefined.\n * click selection won't work anymore, events will fire with no targets.\n * if something is selected before setting it to true, it will be deselected at the first click.\n * area selection will still work. check the `selection` property too.\n * if you deactivate both, you should look into staticCanvas.\n * @type Boolean\n */\n skipTargetFind: boolean;\n}\n\nexport interface CanvasEventsOptions {\n /**\n * Indicates if the right click on canvas can output the context menu or not\n * The default value changed from false to true in Fabric 7.0\n * @see https://fabricjs.com/docs/upgrading/upgrading-to-fabric-70/\n * @deprecated since 7.0, Will be removed in Fabric 8.0\n * @type Boolean\n * @since 1.6.5\n */\n stopContextMenu: boolean;\n\n /**\n * Indicates if the canvas can fire right click events\n * The default value changed from false to true in Fabric 7.0\n * @see https://fabricjs.com/docs/upgrading/upgrading-to-fabric-70/\n * @deprecated since 7.0, Will be removed in Fabric 8.0\n * @type Boolean\n * @since 1.6.5\n */\n fireRightClick: boolean;\n\n /**\n * Indicates if the canvas can fire middle click events\n * The default value changed from false to true in Fabric 7.0\n * @see https://fabricjs.com/docs/upgrading/upgrading-to-fabric-70/\n * @deprecated since 7.0, Will be removed in Fabric 8.0\n * @type Boolean\n * @since 1.7.8\n */\n fireMiddleClick: boolean;\n\n /**\n * When the option is enabled, PointerEvent is used instead of TPointerEvent.\n * @type Boolean\n */\n enablePointerEvents: boolean;\n}\n\nexport interface CanvasOptions\n extends\n StaticCanvasOptions,\n CanvasTransformOptions,\n CanvasSelectionOptions,\n CanvasCursorOptions,\n TargetFindOptions,\n CanvasEventsOptions {\n /**\n * Default element class that's given to wrapper (div) element of canvas\n * @type String\n * @deprecated customize {@link CanvasDOMManager} instead or access {@link elements} directly\n */\n containerClass: string;\n\n /**\n * Indicates whether objects should remain in current stack position when selected.\n * When false objects are brought to top and rendered as part of the selection group\n * @type Boolean\n * @default true\n */\n preserveObjectStacking: boolean;\n}\n\nexport type TCanvasOptions = TOptions<CanvasOptions>;\n\nexport const canvasDefaults: TOptions<CanvasOptions> = {\n uniformScaling: true,\n uniScaleKey: 'shiftKey',\n centeredScaling: false,\n centeredRotation: false,\n centeredKey: 'altKey',\n altActionKey: 'shiftKey',\n\n selection: true,\n selectionKey: 'shiftKey',\n selectionColor: 'rgba(100, 100, 255, 0.3)',\n selectionDashArray: [],\n selectionBorderColor: 'rgba(255, 255, 255, 0.3)',\n selectionLineWidth: 1,\n selectionFullyContained: false,\n\n hoverCursor: 'move',\n moveCursor: 'move',\n defaultCursor: 'default',\n freeDrawingCursor: 'crosshair',\n notAllowedCursor: 'not-allowed',\n\n perPixelTargetFind: false,\n targetFindTolerance: 0,\n skipTargetFind: false,\n\n stopContextMenu: true,\n fireRightClick: true,\n fireMiddleClick: true,\n enablePointerEvents: false,\n\n containerClass: 'canvas-container',\n preserveObjectStacking: true,\n};\n"],"names":["canvasDefaults","uniformScaling","uniScaleKey","centeredScaling","centeredRotation","centeredKey","altActionKey","selection","selectionKey","selectionColor","selectionDashArray","selectionBorderColor","selectionLineWidth","selectionFullyContained","hoverCursor","moveCursor","defaultCursor","freeDrawingCursor","notAllowedCursor","perPixelTargetFind","targetFindTolerance","skipTargetFind","stopContextMenu","fireRightClick","fireMiddleClick","enablePointerEvents","containerClass","preserveObjectStacking"],"mappings":"AA8PO,MAAMA,EAA0C,CACrDC,gBAAgB,EAChBC,YAAa,WACbC,iBAAiB,EACjBC,kBAAkB,EAClBC,YAAa,SACbC,aAAc,WAEdC,WAAW,EACXC,aAAc,WACdC,eAAgB,2BAChBC,mBAAoB,GACpBC,qBAAsB,2BACtBC,mBAAoB,EACpBC,yBAAyB,EAEzBC,YAAa,OACbC,WAAY,OACZC,cAAe,UACfC,kBAAmB,YACnBC,iBAAkB,cAElBC,oBAAoB,EACpBC,oBAAqB,EACrBC,gBAAgB,EAEhBC,iBAAiB,EACjBC,gBAAgB,EAChBC,iBAAiB,EACjBC,qBAAqB,EAErBC,eAAgB,mBAChBC,wBAAwB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CanvasOptions.mjs","sources":["../../../src/canvas/CanvasOptions.ts"],"sourcesContent":["import type { ModifierKey, TOptionalModifierKey } from '../EventTypeDefs';\nimport type { TOptions } from '../typedefs';\nimport type { StaticCanvasOptions } from './StaticCanvasOptions';\n\nexport interface CanvasTransformOptions {\n /**\n * When true, objects can be transformed by one side (unproportionately)\n * when dragged on the corners that normally would not do that.\n * @type Boolean\n * @since fabric 4.0 // changed name and default value\n */\n uniformScaling: boolean;\n\n /**\n * Indicates which key switches uniform scaling.\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled.\n * totally wrong named. this sounds like `uniform scaling`\n * if Canvas.uniformScaling is true, pressing this will set it to false\n * and viceversa.\n * @since 1.6.2\n * @type ModifierKey\n */\n uniScaleKey: TOptionalModifierKey;\n\n /**\n * When true, objects use center point as the origin of scale transformation.\n * <b>Backwards incompatibility note:</b> This property replaces \"centerTransform\" (Boolean).\n * @since 1.3.4\n * @type Boolean\n */\n centeredScaling: boolean;\n\n /**\n * When true, objects use center point as the origin of rotate transformation.\n * <b>Backwards incompatibility note:</b> This property replaces \"centerTransform\" (Boolean).\n * @since 1.3.4\n * @type Boolean\n */\n centeredRotation: boolean;\n\n /**\n * Indicates which key enable centered Transform\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled feature disabled.\n * @since 1.6.2\n * @type ModifierKey\n */\n centeredKey: TOptionalModifierKey;\n\n /**\n * Indicates which key enable alternate action on corner\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled feature disabled.\n * @since 1.6.2\n * @type ModifierKey\n */\n altActionKey: TOptionalModifierKey;\n}\n\nexport interface CanvasSelectionOptions {\n /**\n * Indicates whether group selection should be enabled\n * @type Boolean\n */\n selection: boolean;\n\n /**\n * Indicates which key or keys enable multiple click selection\n * Pass value as a string or array of strings\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or empty or containing any other string that is not a modifier key\n * feature is disabled.\n * @since 1.6.2\n * @type ModifierKey|ModifierKey[]\n */\n selectionKey: TOptionalModifierKey | ModifierKey[];\n\n /**\n * Indicates which key enable alternative selection\n * in case of a target overlapping with active object and we don't want to loose the\n * active selection, we can press this modifier key and continue selecting the current\n * selected object also when is covered by another or many valid targets for selection.\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * For a series of reason that come from the general expectations on how\n * things should work, this feature works only for preserveObjectStacking true.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled.\n * @since 1.6.5\n * @type null|ModifierKey\n */\n altSelectionKey: TOptionalModifierKey;\n\n /**\n * Color of selection\n * @type String\n */\n selectionColor: string;\n\n /**\n * Default dash array pattern\n * If not empty the selection border is dashed\n * @type Array\n */\n selectionDashArray: number[];\n\n /**\n * Color of the border of selection (usually slightly darker than color of selection itself)\n * @type String\n */\n selectionBorderColor: string;\n\n /**\n * Width of a line used in object/group selection\n * @type Number\n */\n selectionLineWidth: number;\n\n /**\n * Select only shapes that are fully contained in the dragged selection rectangle.\n * @type Boolean\n */\n selectionFullyContained: boolean;\n}\n\nexport interface CanvasCursorOptions {\n /**\n * Default cursor value used when hovering over an object on canvas\n * @type CSSStyleDeclaration['cursor']\n * @default move\n */\n hoverCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Default cursor value used when moving an object on canvas\n * @type CSSStyleDeclaration['cursor']\n * @default move\n */\n moveCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Default cursor value used for the entire canvas\n * @type String\n * @default default\n */\n defaultCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Cursor value used during free drawing\n * @type String\n * @default crosshair\n */\n freeDrawingCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Cursor value used for disabled elements ( corners with disabled action )\n * @type String\n * @since 2.0.0\n * @default not-allowed\n */\n notAllowedCursor: CSSStyleDeclaration['cursor'];\n}\n\nexport interface TargetFindOptions {\n /**\n * When true, object detection happens on per-pixel basis rather than on per-bounding-box\n * @type Boolean\n */\n perPixelTargetFind: boolean;\n\n /**\n * Number of pixels around target pixel to tolerate (consider active) during object detection\n * @type Number\n */\n targetFindTolerance: number;\n\n /**\n * When true, target detection is skipped. Target detection will return always undefined.\n * click selection won't work anymore, events will fire with no targets.\n * if something is selected before setting it to true, it will be deselected at the first click.\n * area selection will still work. check the `selection` property too.\n * if you deactivate both, you should look into staticCanvas.\n * @type Boolean\n */\n skipTargetFind: boolean;\n}\n\nexport interface CanvasEventsOptions {\n /**\n * Indicates if the right click on canvas can output the context menu or not\n * The default value changed from false to true in Fabric 7.0\n * @see https://fabricjs.com/docs/upgrading/upgrading-to-fabric-70/\n * @deprecated since 7.0, Will be removed in Fabric 8.0\n * @type Boolean\n * @since 1.6.5\n */\n stopContextMenu: boolean;\n\n /**\n * Indicates if the canvas can fire right click events\n * The default value changed from false to true in Fabric 7.0\n * @see https://fabricjs.com/docs/upgrading/upgrading-to-fabric-70/\n * @deprecated since 7.0, Will be removed in Fabric 8.0\n * @type Boolean\n * @since 1.6.5\n */\n fireRightClick: boolean;\n\n /**\n * Indicates if the canvas can fire middle click events\n * The default value changed from false to true in Fabric 7.0\n * @see https://fabricjs.com/docs/upgrading/upgrading-to-fabric-70/\n * @deprecated since 7.0, Will be removed in Fabric 8.0\n * @type Boolean\n * @since 1.7.8\n */\n fireMiddleClick: boolean;\n\n /**\n * When the option is enabled, PointerEvent is used instead of TPointerEvent.\n * @type Boolean\n */\n enablePointerEvents: boolean;\n}\n\nexport interface CanvasOptions\n extends StaticCanvasOptions,\n CanvasTransformOptions,\n CanvasSelectionOptions,\n CanvasCursorOptions,\n TargetFindOptions,\n CanvasEventsOptions {\n /**\n * Default element class that's given to wrapper (div) element of canvas\n * @type String\n * @deprecated customize {@link CanvasDOMManager} instead or access {@link elements} directly\n */\n containerClass: string;\n\n /**\n * Indicates whether objects should remain in current stack position when selected.\n * When false objects are brought to top and rendered as part of the selection group\n * @type Boolean\n * @default true\n */\n preserveObjectStacking: boolean;\n}\n\nexport type TCanvasOptions = TOptions<CanvasOptions>;\n\nexport const canvasDefaults: TOptions<CanvasOptions> = {\n uniformScaling: true,\n uniScaleKey: 'shiftKey',\n centeredScaling: false,\n centeredRotation: false,\n centeredKey: 'altKey',\n altActionKey: 'shiftKey',\n\n selection: true,\n selectionKey: 'shiftKey',\n selectionColor: 'rgba(100, 100, 255, 0.3)',\n selectionDashArray: [],\n selectionBorderColor: 'rgba(255, 255, 255, 0.3)',\n selectionLineWidth: 1,\n selectionFullyContained: false,\n\n hoverCursor: 'move',\n moveCursor: 'move',\n defaultCursor: 'default',\n freeDrawingCursor: 'crosshair',\n notAllowedCursor: 'not-allowed',\n\n perPixelTargetFind: false,\n targetFindTolerance: 0,\n skipTargetFind: false,\n\n stopContextMenu: true,\n fireRightClick: true,\n fireMiddleClick: true,\n enablePointerEvents: false,\n\n containerClass: 'canvas-container',\n preserveObjectStacking: true,\n};\n"],"names":["canvasDefaults","uniformScaling","uniScaleKey","centeredScaling","centeredRotation","centeredKey","altActionKey","selection","selectionKey","selectionColor","selectionDashArray","selectionBorderColor","selectionLineWidth","selectionFullyContained","hoverCursor","moveCursor","defaultCursor","freeDrawingCursor","notAllowedCursor","perPixelTargetFind","targetFindTolerance","skipTargetFind","stopContextMenu","fireRightClick","fireMiddleClick","enablePointerEvents","containerClass","preserveObjectStacking"],"mappings":"AA6PO,MAAMA,cAAuC,GAAG;AACrDC,EAAAA,cAAc,EAAE,IAAI;AACpBC,EAAAA,WAAW,EAAE,UAAU;AACvBC,EAAAA,eAAe,EAAE,KAAK;AACtBC,EAAAA,gBAAgB,EAAE,KAAK;AACvBC,EAAAA,WAAW,EAAE,QAAQ;AACrBC,EAAAA,YAAY,EAAE,UAAU;AAExBC,EAAAA,SAAS,EAAE,IAAI;AACfC,EAAAA,YAAY,EAAE,UAAU;AACxBC,EAAAA,cAAc,EAAE,0BAA0B;AAC1CC,EAAAA,kBAAkB,EAAE,EAAE;AACtBC,EAAAA,oBAAoB,EAAE,0BAA0B;AAChDC,EAAAA,kBAAkB,EAAE,CAAC;AACrBC,EAAAA,uBAAuB,EAAE,KAAK;AAE9BC,EAAAA,WAAW,EAAE,MAAM;AACnBC,EAAAA,UAAU,EAAE,MAAM;AAClBC,EAAAA,aAAa,EAAE,SAAS;AACxBC,EAAAA,iBAAiB,EAAE,WAAW;AAC9BC,EAAAA,gBAAgB,EAAE,aAAa;AAE/BC,EAAAA,kBAAkB,EAAE,KAAK;AACzBC,EAAAA,mBAAmB,EAAE,CAAC;AACtBC,EAAAA,cAAc,EAAE,KAAK;AAErBC,EAAAA,eAAe,EAAE,IAAI;AACrBC,EAAAA,cAAc,EAAE,IAAI;AACpBC,EAAAA,eAAe,EAAE,IAAI;AACrBC,EAAAA,mBAAmB,EAAE,KAAK;AAE1BC,EAAAA,cAAc,EAAE,kBAAkB;AAClCC,EAAAA,sBAAsB,EAAE;AAC1B;;;;"}
|
|
1
|
+
{"version":3,"file":"CanvasOptions.mjs","sources":["../../../src/canvas/CanvasOptions.ts"],"sourcesContent":["import type { ModifierKey, TOptionalModifierKey } from '../EventTypeDefs';\nimport type { TOptions } from '../typedefs';\nimport type { StaticCanvasOptions } from './StaticCanvasOptions';\n\nexport interface CanvasTransformOptions {\n /**\n * When true, objects can be transformed by one side (unproportionately)\n * when dragged on the corners that normally would not do that.\n * @type Boolean\n * @since fabric 4.0 // changed name and default value\n */\n uniformScaling: boolean;\n\n /**\n * Indicates which key switches uniform scaling.\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled.\n * totally wrong named. this sounds like `uniform scaling`\n * if Canvas.uniformScaling is true, pressing this will set it to false\n * and viceversa.\n * @since 1.6.2\n * @type ModifierKey\n */\n uniScaleKey: TOptionalModifierKey;\n\n /**\n * When true, objects use center point as the origin of scale transformation.\n * <b>Backwards incompatibility note:</b> This property replaces \"centerTransform\" (Boolean).\n * @since 1.3.4\n * @type Boolean\n */\n centeredScaling: boolean;\n\n /**\n * When true, objects use center point as the origin of rotate transformation.\n * <b>Backwards incompatibility note:</b> This property replaces \"centerTransform\" (Boolean).\n * @since 1.3.4\n * @type Boolean\n */\n centeredRotation: boolean;\n\n /**\n * Indicates which key enable centered Transform\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled feature disabled.\n * @since 1.6.2\n * @type ModifierKey\n */\n centeredKey: TOptionalModifierKey;\n\n /**\n * Indicates which key enable alternate action on corner\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled feature disabled.\n * @since 1.6.2\n * @type ModifierKey\n */\n altActionKey: TOptionalModifierKey;\n}\n\nexport interface CanvasSelectionOptions {\n /**\n * Indicates whether group selection should be enabled\n * @type Boolean\n */\n selection: boolean;\n\n /**\n * Indicates which key or keys enable multiple click selection\n * Pass value as a string or array of strings\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or empty or containing any other string that is not a modifier key\n * feature is disabled.\n * @since 1.6.2\n * @type ModifierKey|ModifierKey[]\n */\n selectionKey: TOptionalModifierKey | ModifierKey[];\n\n /**\n * Indicates which key enable alternative selection\n * in case of a target overlapping with active object and we don't want to loose the\n * active selection, we can press this modifier key and continue selecting the current\n * selected object also when is covered by another or many valid targets for selection.\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * For a series of reason that come from the general expectations on how\n * things should work, this feature works only for preserveObjectStacking true.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled.\n * @since 1.6.5\n * @type null|ModifierKey\n */\n altSelectionKey: TOptionalModifierKey;\n\n /**\n * Color of selection\n * @type String\n */\n selectionColor: string;\n\n /**\n * Default dash array pattern\n * If not empty the selection border is dashed\n * @type Array\n */\n selectionDashArray: number[];\n\n /**\n * Color of the border of selection (usually slightly darker than color of selection itself)\n * @type String\n */\n selectionBorderColor: string;\n\n /**\n * Width of a line used in object/group selection\n * @type Number\n */\n selectionLineWidth: number;\n\n /**\n * Select only shapes that are fully contained in the dragged selection rectangle.\n * @type Boolean\n */\n selectionFullyContained: boolean;\n}\n\nexport interface CanvasCursorOptions {\n /**\n * Default cursor value used when hovering over an object on canvas\n * @type CSSStyleDeclaration['cursor']\n * @default move\n */\n hoverCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Default cursor value used when moving an object on canvas\n * @type CSSStyleDeclaration['cursor']\n * @default move\n */\n moveCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Default cursor value used for the entire canvas\n * @type String\n * @default default\n */\n defaultCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Cursor value used during free drawing\n * @type String\n * @default crosshair\n */\n freeDrawingCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Cursor value used for disabled elements ( corners with disabled action )\n * @type String\n * @since 2.0.0\n * @default not-allowed\n */\n notAllowedCursor: CSSStyleDeclaration['cursor'];\n}\n\nexport interface TargetFindOptions {\n /**\n * When true, object detection happens on per-pixel basis rather than on per-bounding-box\n * @type Boolean\n */\n perPixelTargetFind: boolean;\n\n /**\n * Number of pixels around target pixel to tolerate (consider active) during object detection\n * @type Number\n */\n targetFindTolerance: number;\n\n /**\n * When true, target detection is skipped. Target detection will return always undefined.\n * click selection won't work anymore, events will fire with no targets.\n * if something is selected before setting it to true, it will be deselected at the first click.\n * area selection will still work. check the `selection` property too.\n * if you deactivate both, you should look into staticCanvas.\n * @type Boolean\n */\n skipTargetFind: boolean;\n}\n\nexport interface CanvasEventsOptions {\n /**\n * Indicates if the right click on canvas can output the context menu or not\n * The default value changed from false to true in Fabric 7.0\n * @see https://fabricjs.com/docs/upgrading/upgrading-to-fabric-70/\n * @deprecated since 7.0, Will be removed in Fabric 8.0\n * @type Boolean\n * @since 1.6.5\n */\n stopContextMenu: boolean;\n\n /**\n * Indicates if the canvas can fire right click events\n * The default value changed from false to true in Fabric 7.0\n * @see https://fabricjs.com/docs/upgrading/upgrading-to-fabric-70/\n * @deprecated since 7.0, Will be removed in Fabric 8.0\n * @type Boolean\n * @since 1.6.5\n */\n fireRightClick: boolean;\n\n /**\n * Indicates if the canvas can fire middle click events\n * The default value changed from false to true in Fabric 7.0\n * @see https://fabricjs.com/docs/upgrading/upgrading-to-fabric-70/\n * @deprecated since 7.0, Will be removed in Fabric 8.0\n * @type Boolean\n * @since 1.7.8\n */\n fireMiddleClick: boolean;\n\n /**\n * When the option is enabled, PointerEvent is used instead of TPointerEvent.\n * @type Boolean\n */\n enablePointerEvents: boolean;\n}\n\nexport interface CanvasOptions\n extends\n StaticCanvasOptions,\n CanvasTransformOptions,\n CanvasSelectionOptions,\n CanvasCursorOptions,\n TargetFindOptions,\n CanvasEventsOptions {\n /**\n * Default element class that's given to wrapper (div) element of canvas\n * @type String\n * @deprecated customize {@link CanvasDOMManager} instead or access {@link elements} directly\n */\n containerClass: string;\n\n /**\n * Indicates whether objects should remain in current stack position when selected.\n * When false objects are brought to top and rendered as part of the selection group\n * @type Boolean\n * @default true\n */\n preserveObjectStacking: boolean;\n}\n\nexport type TCanvasOptions = TOptions<CanvasOptions>;\n\nexport const canvasDefaults: TOptions<CanvasOptions> = {\n uniformScaling: true,\n uniScaleKey: 'shiftKey',\n centeredScaling: false,\n centeredRotation: false,\n centeredKey: 'altKey',\n altActionKey: 'shiftKey',\n\n selection: true,\n selectionKey: 'shiftKey',\n selectionColor: 'rgba(100, 100, 255, 0.3)',\n selectionDashArray: [],\n selectionBorderColor: 'rgba(255, 255, 255, 0.3)',\n selectionLineWidth: 1,\n selectionFullyContained: false,\n\n hoverCursor: 'move',\n moveCursor: 'move',\n defaultCursor: 'default',\n freeDrawingCursor: 'crosshair',\n notAllowedCursor: 'not-allowed',\n\n perPixelTargetFind: false,\n targetFindTolerance: 0,\n skipTargetFind: false,\n\n stopContextMenu: true,\n fireRightClick: true,\n fireMiddleClick: true,\n enablePointerEvents: false,\n\n containerClass: 'canvas-container',\n preserveObjectStacking: true,\n};\n"],"names":["canvasDefaults","uniformScaling","uniScaleKey","centeredScaling","centeredRotation","centeredKey","altActionKey","selection","selectionKey","selectionColor","selectionDashArray","selectionBorderColor","selectionLineWidth","selectionFullyContained","hoverCursor","moveCursor","defaultCursor","freeDrawingCursor","notAllowedCursor","perPixelTargetFind","targetFindTolerance","skipTargetFind","stopContextMenu","fireRightClick","fireMiddleClick","enablePointerEvents","containerClass","preserveObjectStacking"],"mappings":"AA8PO,MAAMA,cAAuC,GAAG;AACrDC,EAAAA,cAAc,EAAE,IAAI;AACpBC,EAAAA,WAAW,EAAE,UAAU;AACvBC,EAAAA,eAAe,EAAE,KAAK;AACtBC,EAAAA,gBAAgB,EAAE,KAAK;AACvBC,EAAAA,WAAW,EAAE,QAAQ;AACrBC,EAAAA,YAAY,EAAE,UAAU;AAExBC,EAAAA,SAAS,EAAE,IAAI;AACfC,EAAAA,YAAY,EAAE,UAAU;AACxBC,EAAAA,cAAc,EAAE,0BAA0B;AAC1CC,EAAAA,kBAAkB,EAAE,EAAE;AACtBC,EAAAA,oBAAoB,EAAE,0BAA0B;AAChDC,EAAAA,kBAAkB,EAAE,CAAC;AACrBC,EAAAA,uBAAuB,EAAE,KAAK;AAE9BC,EAAAA,WAAW,EAAE,MAAM;AACnBC,EAAAA,UAAU,EAAE,MAAM;AAClBC,EAAAA,aAAa,EAAE,SAAS;AACxBC,EAAAA,iBAAiB,EAAE,WAAW;AAC9BC,EAAAA,gBAAgB,EAAE,aAAa;AAE/BC,EAAAA,kBAAkB,EAAE,KAAK;AACzBC,EAAAA,mBAAmB,EAAE,CAAC;AACtBC,EAAAA,cAAc,EAAE,KAAK;AAErBC,EAAAA,eAAe,EAAE,IAAI;AACrBC,EAAAA,cAAc,EAAE,IAAI;AACpBC,EAAAA,eAAe,EAAE,IAAI;AACrBC,EAAAA,mBAAmB,EAAE,KAAK;AAE1BC,EAAAA,cAAc,EAAE,kBAAkB;AAClCC,EAAAA,sBAAsB,EAAE;AAC1B;;;;"}
|
|
@@ -310,6 +310,8 @@ export declare class SelectableCanvas<EventSpec extends CanvasEvents = CanvasEve
|
|
|
310
310
|
* Given the control clicked, determine the origin of the transform.
|
|
311
311
|
* This is bad because controls can totally have custom names
|
|
312
312
|
* should disappear before release 4.0
|
|
313
|
+
* Fabric 7.1, jan 2026 we are still using this.
|
|
314
|
+
* Needs to go.
|
|
313
315
|
* @private
|
|
314
316
|
* @deprecated
|
|
315
317
|
*/
|