fabric 6.0.0 → 6.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +8 -18
- package/dist/fabric.d.ts +4 -0
- package/dist/fabric.d.ts.map +1 -1
- package/dist/fabric.min.mjs +1 -1
- package/dist/fabric.mjs +1 -0
- package/dist/fabric.mjs.map +1 -1
- package/dist/index.js +146 -107
- 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 +146 -108
- package/dist/index.mjs.map +1 -1
- package/dist/index.node.cjs +146 -107
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +146 -108
- package/dist/index.node.mjs.map +1 -1
- package/dist/package.json.min.mjs +1 -1
- package/dist/package.json.mjs +1 -1
- package/dist/src/EventTypeDefs.d.ts +2 -1
- package/dist/src/EventTypeDefs.d.ts.map +1 -1
- package/dist/src/LayoutManager/LayoutManager.d.ts.map +1 -1
- package/dist/src/LayoutManager/LayoutManager.min.mjs +1 -1
- package/dist/src/LayoutManager/LayoutManager.min.mjs.map +1 -1
- package/dist/src/LayoutManager/LayoutManager.mjs +13 -8
- package/dist/src/LayoutManager/LayoutManager.mjs.map +1 -1
- package/dist/src/LayoutManager/LayoutStrategies/ClipPathLayout.min.mjs +1 -1
- package/dist/src/LayoutManager/LayoutStrategies/ClipPathLayout.min.mjs.map +1 -1
- package/dist/src/LayoutManager/LayoutStrategies/ClipPathLayout.mjs +3 -3
- package/dist/src/LayoutManager/LayoutStrategies/ClipPathLayout.mjs.map +1 -1
- package/dist/src/LayoutManager/LayoutStrategies/LayoutStrategy.d.ts +1 -1
- package/dist/src/LayoutManager/LayoutStrategies/LayoutStrategy.d.ts.map +1 -1
- package/dist/src/LayoutManager/LayoutStrategies/LayoutStrategy.min.mjs +1 -1
- package/dist/src/LayoutManager/LayoutStrategies/LayoutStrategy.min.mjs.map +1 -1
- package/dist/src/LayoutManager/LayoutStrategies/LayoutStrategy.mjs +15 -9
- package/dist/src/LayoutManager/LayoutStrategies/LayoutStrategy.mjs.map +1 -1
- package/dist/src/Observable.d.ts +8 -0
- package/dist/src/Observable.d.ts.map +1 -1
- package/dist/src/Observable.min.mjs.map +1 -1
- package/dist/src/Observable.mjs +8 -0
- package/dist/src/Observable.mjs.map +1 -1
- 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 +5 -5
- package/dist/src/canvas/SelectableCanvas.mjs.map +1 -1
- package/dist/src/canvas/StaticCanvas.d.ts +1 -1
- package/dist/src/constants.d.ts +16 -0
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.min.mjs +1 -1
- package/dist/src/constants.min.mjs.map +1 -1
- package/dist/src/constants.mjs +17 -1
- package/dist/src/constants.mjs.map +1 -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 +2 -1
- package/dist/src/controls/Control.mjs.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 +2 -2
- package/dist/src/controls/changeWidth.mjs.map +1 -1
- package/dist/src/controls/commonControls.d.ts.map +1 -1
- package/dist/src/controls/commonControls.min.mjs +1 -1
- package/dist/src/controls/commonControls.min.mjs.map +1 -1
- package/dist/src/controls/commonControls.mjs +4 -3
- package/dist/src/controls/commonControls.mjs.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 +3 -3
- package/dist/src/controls/controlRendering.mjs.map +1 -1
- package/dist/src/controls/drag.min.mjs +1 -1
- package/dist/src/controls/drag.min.mjs.map +1 -1
- package/dist/src/controls/drag.mjs +2 -2
- package/dist/src/controls/drag.mjs.map +1 -1
- package/dist/src/controls/polyControl.d.ts.map +1 -1
- package/dist/src/controls/polyControl.min.mjs +1 -1
- package/dist/src/controls/polyControl.min.mjs.map +1 -1
- package/dist/src/controls/polyControl.mjs +2 -1
- package/dist/src/controls/polyControl.mjs.map +1 -1
- package/dist/src/controls/rotate.d.ts.map +1 -1
- package/dist/src/controls/rotate.min.mjs +1 -1
- package/dist/src/controls/rotate.min.mjs.map +1 -1
- package/dist/src/controls/rotate.mjs +2 -1
- package/dist/src/controls/rotate.mjs.map +1 -1
- package/dist/src/controls/scale.d.ts.map +1 -1
- package/dist/src/controls/scale.min.mjs +1 -1
- package/dist/src/controls/scale.min.mjs.map +1 -1
- package/dist/src/controls/scale.mjs +8 -7
- package/dist/src/controls/scale.mjs.map +1 -1
- package/dist/src/controls/scaleSkew.d.ts.map +1 -1
- package/dist/src/controls/scaleSkew.min.mjs +1 -1
- package/dist/src/controls/scaleSkew.min.mjs.map +1 -1
- package/dist/src/controls/scaleSkew.mjs +3 -2
- package/dist/src/controls/scaleSkew.mjs.map +1 -1
- package/dist/src/controls/skew.d.ts.map +1 -1
- package/dist/src/controls/skew.min.mjs +1 -1
- package/dist/src/controls/skew.min.mjs.map +1 -1
- package/dist/src/controls/skew.mjs +7 -7
- package/dist/src/controls/skew.mjs.map +1 -1
- package/dist/src/filters/Blur.min.mjs +1 -1
- package/dist/src/filters/Blur.min.mjs.map +1 -1
- package/dist/src/filters/Blur.mjs +1 -1
- package/dist/src/filters/Blur.mjs.map +1 -1
- package/dist/src/filters/Pixelate.min.mjs +1 -1
- package/dist/src/filters/Pixelate.min.mjs.map +1 -1
- package/dist/src/filters/Pixelate.mjs +1 -1
- package/dist/src/filters/Pixelate.mjs.map +1 -1
- package/dist/src/parser/attributes.d.ts.map +1 -1
- package/dist/src/parser/attributes.min.mjs +1 -1
- package/dist/src/parser/attributes.min.mjs.map +1 -1
- package/dist/src/parser/attributes.mjs +3 -1
- package/dist/src/parser/attributes.mjs.map +1 -1
- package/dist/src/parser/elements_parser.min.mjs +1 -1
- package/dist/src/parser/elements_parser.min.mjs.map +1 -1
- package/dist/src/parser/elements_parser.mjs +3 -3
- package/dist/src/parser/elements_parser.mjs.map +1 -1
- package/dist/src/parser/normalizeValue.min.mjs +1 -1
- package/dist/src/parser/normalizeValue.min.mjs.map +1 -1
- package/dist/src/parser/normalizeValue.mjs +7 -7
- package/dist/src/parser/normalizeValue.mjs.map +1 -1
- package/dist/src/parser/parseTransformAttribute.min.mjs +1 -1
- package/dist/src/parser/parseTransformAttribute.min.mjs.map +1 -1
- package/dist/src/parser/parseTransformAttribute.mjs +5 -5
- package/dist/src/parser/parseTransformAttribute.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 +3 -2
- package/dist/src/shapes/Circle.mjs.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 +3 -3
- package/dist/src/shapes/Ellipse.mjs.map +1 -1
- package/dist/src/shapes/IText/DraggableTextDelegate.min.mjs +1 -1
- package/dist/src/shapes/IText/DraggableTextDelegate.min.mjs.map +1 -1
- package/dist/src/shapes/IText/DraggableTextDelegate.mjs +3 -3
- package/dist/src/shapes/IText/DraggableTextDelegate.mjs.map +1 -1
- package/dist/src/shapes/IText/IText.min.mjs +1 -1
- package/dist/src/shapes/IText/IText.min.mjs.map +1 -1
- package/dist/src/shapes/IText/IText.mjs +3 -3
- package/dist/src/shapes/IText/IText.mjs.map +1 -1
- package/dist/src/shapes/IText/ITextBehavior.min.mjs +1 -1
- package/dist/src/shapes/IText/ITextBehavior.min.mjs.map +1 -1
- package/dist/src/shapes/IText/ITextBehavior.mjs +2 -2
- package/dist/src/shapes/IText/ITextBehavior.mjs.map +1 -1
- package/dist/src/shapes/IText/ITextKeyBehavior.min.mjs +1 -1
- package/dist/src/shapes/IText/ITextKeyBehavior.min.mjs.map +1 -1
- package/dist/src/shapes/IText/ITextKeyBehavior.mjs +2 -2
- package/dist/src/shapes/IText/ITextKeyBehavior.mjs.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 +2 -2
- package/dist/src/shapes/Image.mjs.map +1 -1
- package/dist/src/shapes/Object/AnimatableObject.d.ts.map +1 -1
- package/dist/src/shapes/Object/AnimatableObject.min.mjs +1 -1
- package/dist/src/shapes/Object/AnimatableObject.min.mjs.map +1 -1
- package/dist/src/shapes/Object/AnimatableObject.mjs +2 -1
- package/dist/src/shapes/Object/AnimatableObject.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 +4 -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 +1 -1
- package/dist/src/shapes/Object/InteractiveObject.min.mjs.map +1 -1
- package/dist/src/shapes/Object/InteractiveObject.mjs +2 -1
- package/dist/src/shapes/Object/InteractiveObject.mjs.map +1 -1
- package/dist/src/shapes/Object/Object.d.ts +9 -7
- 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 +14 -12
- 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 +3 -3
- package/dist/src/shapes/Object/ObjectGeometry.mjs.map +1 -1
- package/dist/src/shapes/Object/defaultValues.d.ts.map +1 -1
- package/dist/src/shapes/Object/defaultValues.min.mjs +1 -1
- package/dist/src/shapes/Object/defaultValues.min.mjs.map +1 -1
- package/dist/src/shapes/Object/defaultValues.mjs +4 -4
- package/dist/src/shapes/Object/defaultValues.mjs.map +1 -1
- package/dist/src/shapes/Object/types/ControlProps.d.ts +4 -3
- package/dist/src/shapes/Object/types/ControlProps.d.ts.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 +3 -3
- package/dist/src/shapes/Polyline.mjs.map +1 -1
- package/dist/src/shapes/Text/Text.d.ts +2 -2
- package/dist/src/shapes/Text/Text.d.ts.map +1 -1
- package/dist/src/shapes/Text/Text.min.mjs +1 -1
- package/dist/src/shapes/Text/Text.min.mjs.map +1 -1
- package/dist/src/shapes/Text/Text.mjs +5 -5
- 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 +2 -1
- package/dist/src/shapes/Text/TextSVGExportMixin.mjs.map +1 -1
- package/dist/src/shapes/Text/constants.min.mjs +1 -1
- package/dist/src/shapes/Text/constants.min.mjs.map +1 -1
- package/dist/src/shapes/Text/constants.mjs +2 -2
- package/dist/src/shapes/Text/constants.mjs.map +1 -1
- package/dist/src/util/misc/objectEnlive.d.ts +1 -0
- package/dist/src/util/misc/objectEnlive.d.ts.map +1 -1
- package/dist/src/util/misc/objectEnlive.min.mjs.map +1 -1
- package/dist/src/util/misc/objectEnlive.mjs +1 -0
- package/dist/src/util/misc/objectEnlive.mjs.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 -2
- package/dist/src/util/misc/svgParsing.mjs.map +1 -1
- package/dist/src/util/transform_matrix_removal.min.mjs +1 -1
- package/dist/src/util/transform_matrix_removal.min.mjs.map +1 -1
- package/dist/src/util/transform_matrix_removal.mjs +3 -3
- package/dist/src/util/transform_matrix_removal.mjs.map +1 -1
- package/fabric.ts +4 -0
- package/package.json +1 -1
- package/src/EventTypeDefs.ts +14 -6
- package/src/LayoutManager/LayoutManager.ts +28 -19
- package/src/LayoutManager/LayoutStrategies/ClipPathLayout.ts +2 -2
- package/src/LayoutManager/LayoutStrategies/LayoutStrategy.ts +7 -7
- package/src/Observable.ts +8 -0
- package/src/canvas/SelectableCanvas.ts +25 -11
- package/src/canvas/canvas_gestures.mixin.ts +6 -5
- package/src/constants.ts +17 -0
- package/src/controls/Control.ts +2 -1
- package/src/controls/changeWidth.ts +2 -2
- package/src/controls/commonControls.ts +4 -3
- package/src/controls/controlRendering.ts +3 -3
- package/src/controls/drag.ts +2 -2
- package/src/controls/polyControl.ts +2 -1
- package/src/controls/rotate.ts +2 -1
- package/src/controls/scale.ts +8 -7
- package/src/controls/scaleSkew.ts +3 -2
- package/src/controls/skew.ts +14 -7
- package/src/filters/Blur.ts +1 -1
- package/src/filters/Pixelate.ts +1 -1
- package/src/parser/attributes.ts +4 -2
- package/src/parser/elements_parser.ts +3 -3
- package/src/parser/normalizeValue.ts +7 -7
- package/src/parser/parseTransformAttribute.ts +5 -5
- package/src/shapes/Circle.ts +3 -2
- package/src/shapes/Ellipse.ts +3 -3
- package/src/shapes/IText/DraggableTextDelegate.ts +3 -3
- package/src/shapes/IText/IText.ts +3 -3
- package/src/shapes/IText/ITextBehavior.ts +2 -2
- package/src/shapes/IText/ITextKeyBehavior.ts +2 -2
- package/src/shapes/Image.ts +2 -2
- package/src/shapes/Object/AnimatableObject.ts +2 -1
- package/src/shapes/Object/FabricObjectSVGExportMixin.ts +4 -6
- package/src/shapes/Object/InteractiveObject.ts +2 -1
- package/src/shapes/Object/Object.ts +16 -11
- package/src/shapes/Object/ObjectGeometry.ts +3 -3
- package/src/shapes/Object/defaultValues.ts +17 -8
- package/src/shapes/Object/types/ControlProps.ts +4 -3
- package/src/shapes/Polyline.spec.ts +0 -1
- package/src/shapes/Polyline.ts +12 -4
- package/src/shapes/Text/Text.ts +7 -7
- package/src/shapes/Text/TextSVGExportMixin.ts +3 -2
- package/src/shapes/Text/constants.ts +3 -3
- package/src/util/misc/objectEnlive.ts +1 -0
- package/src/util/misc/svgParsing.ts +2 -2
- package/src/util/transform_matrix_removal.ts +3 -3
package/src/controls/scale.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
} from './util';
|
|
18
18
|
import { wrapWithFireEvent } from './wrapWithFireEvent';
|
|
19
19
|
import { wrapWithFixedAnchor } from './wrapWithFixedAnchor';
|
|
20
|
+
import { SCALE_X, SCALE_Y, SCALING } from '../constants';
|
|
20
21
|
|
|
21
22
|
type ScaleTransform = Transform & {
|
|
22
23
|
gestureScale?: number;
|
|
@@ -206,12 +207,12 @@ function scaleObject(
|
|
|
206
207
|
const oldScaleX = target.scaleX,
|
|
207
208
|
oldScaleY = target.scaleY;
|
|
208
209
|
if (!by) {
|
|
209
|
-
!isLocked(target, 'lockScalingX') && target.set(
|
|
210
|
-
!isLocked(target, 'lockScalingY') && target.set(
|
|
210
|
+
!isLocked(target, 'lockScalingX') && target.set(SCALE_X, scaleX);
|
|
211
|
+
!isLocked(target, 'lockScalingY') && target.set(SCALE_Y, scaleY);
|
|
211
212
|
} else {
|
|
212
213
|
// forbidden cases already handled on top here.
|
|
213
|
-
by === 'x' && target.set(
|
|
214
|
-
by === 'y' && target.set(
|
|
214
|
+
by === 'x' && target.set(SCALE_X, scaleX);
|
|
215
|
+
by === 'y' && target.set(SCALE_Y, scaleY);
|
|
215
216
|
}
|
|
216
217
|
return oldScaleX !== target.scaleX || oldScaleY !== target.scaleY;
|
|
217
218
|
}
|
|
@@ -271,16 +272,16 @@ const scaleObjectY: TransformActionHandler<ScaleTransform> = (
|
|
|
271
272
|
};
|
|
272
273
|
|
|
273
274
|
export const scalingEqually = wrapWithFireEvent(
|
|
274
|
-
|
|
275
|
+
SCALING,
|
|
275
276
|
wrapWithFixedAnchor(scaleObjectFromCorner)
|
|
276
277
|
);
|
|
277
278
|
|
|
278
279
|
export const scalingX = wrapWithFireEvent(
|
|
279
|
-
|
|
280
|
+
SCALING,
|
|
280
281
|
wrapWithFixedAnchor(scaleObjectX)
|
|
281
282
|
);
|
|
282
283
|
|
|
283
284
|
export const scalingY = wrapWithFireEvent(
|
|
284
|
-
|
|
285
|
+
SCALING,
|
|
285
286
|
wrapWithFixedAnchor(scaleObjectY)
|
|
286
287
|
);
|
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
TPointerEvent,
|
|
5
5
|
TransformActionHandler,
|
|
6
6
|
} from '../EventTypeDefs';
|
|
7
|
+
import { SCALE_X, SCALE_Y, SKEW_X, SKEW_Y } from '../constants';
|
|
7
8
|
import type { FabricObject } from '../shapes/Object/FabricObject';
|
|
8
9
|
import type { TAxisKey } from '../typedefs';
|
|
9
10
|
import { scaleCursorStyleHandler, scalingX, scalingY } from './scale';
|
|
@@ -26,11 +27,11 @@ export const scaleOrSkewActionName: ControlCallback<
|
|
|
26
27
|
const isAlternative = isAltAction(eventData, fabricObject);
|
|
27
28
|
if (control.x === 0) {
|
|
28
29
|
// then is scaleY or skewX
|
|
29
|
-
return isAlternative ?
|
|
30
|
+
return isAlternative ? SKEW_X : SCALE_Y;
|
|
30
31
|
}
|
|
31
32
|
if (control.y === 0) {
|
|
32
33
|
// then is scaleY or skewX
|
|
33
|
-
return isAlternative ?
|
|
34
|
+
return isAlternative ? SKEW_Y : SCALE_X;
|
|
34
35
|
}
|
|
35
36
|
return '';
|
|
36
37
|
};
|
package/src/controls/skew.ts
CHANGED
|
@@ -19,7 +19,14 @@ import {
|
|
|
19
19
|
} from './util';
|
|
20
20
|
import { wrapWithFireEvent } from './wrapWithFireEvent';
|
|
21
21
|
import { wrapWithFixedAnchor } from './wrapWithFixedAnchor';
|
|
22
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
CENTER,
|
|
24
|
+
SCALE_X,
|
|
25
|
+
SCALE_Y,
|
|
26
|
+
SKEWING,
|
|
27
|
+
SKEW_X,
|
|
28
|
+
SKEW_Y,
|
|
29
|
+
} from '../constants';
|
|
23
30
|
|
|
24
31
|
export type SkewTransform = Transform & { skewingSide: -1 | 1 };
|
|
25
32
|
|
|
@@ -36,16 +43,16 @@ const AXIS_KEYS: Record<
|
|
|
36
43
|
> = {
|
|
37
44
|
x: {
|
|
38
45
|
counterAxis: 'y',
|
|
39
|
-
scale:
|
|
40
|
-
skew:
|
|
46
|
+
scale: SCALE_X,
|
|
47
|
+
skew: SKEW_X,
|
|
41
48
|
lockSkewing: 'lockSkewingX',
|
|
42
49
|
origin: 'originX',
|
|
43
50
|
flip: 'flipX',
|
|
44
51
|
},
|
|
45
52
|
y: {
|
|
46
53
|
counterAxis: 'x',
|
|
47
|
-
scale:
|
|
48
|
-
skew:
|
|
54
|
+
scale: SCALE_Y,
|
|
55
|
+
skew: SKEW_Y,
|
|
49
56
|
lockSkewing: 'lockSkewingY',
|
|
50
57
|
origin: 'originY',
|
|
51
58
|
flip: 'flipY',
|
|
@@ -130,7 +137,7 @@ function skewObject(
|
|
|
130
137
|
dimAfter = target._getTransformedDimensions(),
|
|
131
138
|
compensationFactor = skewX !== 0 ? dimBefore.x / dimAfter.x : 1;
|
|
132
139
|
compensationFactor !== 1 &&
|
|
133
|
-
target.set(
|
|
140
|
+
target.set(SCALE_X, compensationFactor * scaleX);
|
|
134
141
|
}
|
|
135
142
|
|
|
136
143
|
return changed;
|
|
@@ -188,7 +195,7 @@ function skewHandler(
|
|
|
188
195
|
origin = -skewingDirection * 0.5 + 0.5;
|
|
189
196
|
|
|
190
197
|
const finalHandler = wrapWithFireEvent<SkewTransform>(
|
|
191
|
-
|
|
198
|
+
SKEWING,
|
|
192
199
|
wrapWithFixedAnchor((eventData, transform, x, y) =>
|
|
193
200
|
skewObject(axis, transform, new Point(x, y))
|
|
194
201
|
)
|
package/src/filters/Blur.ts
CHANGED
|
@@ -136,7 +136,7 @@ export class Blur extends BaseFilter<'Blur', BlurOwnProps> {
|
|
|
136
136
|
uniformLocations: TWebGLUniformLocationMap
|
|
137
137
|
) {
|
|
138
138
|
const delta = this.chooseRightDelta();
|
|
139
|
-
gl.uniform2fv(uniformLocations.
|
|
139
|
+
gl.uniform2fv(uniformLocations.uDelta, delta);
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
isNeutralState() {
|
package/src/filters/Pixelate.ts
CHANGED
|
@@ -27,7 +27,7 @@ export class Pixelate extends BaseFilter<'Pixelate', PixelateOwnProps> {
|
|
|
27
27
|
|
|
28
28
|
static defaults = pixelateDefaultValues;
|
|
29
29
|
|
|
30
|
-
static uniformLocations = ['
|
|
30
|
+
static uniformLocations = ['uBlocksize'];
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Apply the Pixelate operation to a Uint8ClampedArray representing the pixels of an image.
|
package/src/parser/attributes.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { FILL, STROKE } from '../constants';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Attributes parsed from all SVG elements
|
|
3
5
|
* @type array
|
|
@@ -5,11 +7,11 @@
|
|
|
5
7
|
export const SHARED_ATTRIBUTES = [
|
|
6
8
|
'display',
|
|
7
9
|
'transform',
|
|
8
|
-
|
|
10
|
+
FILL,
|
|
9
11
|
'fill-opacity',
|
|
10
12
|
'fill-rule',
|
|
11
13
|
'opacity',
|
|
12
|
-
|
|
14
|
+
STROKE,
|
|
13
15
|
'stroke-dasharray',
|
|
14
16
|
'stroke-linecap',
|
|
15
17
|
'stroke-dashoffset',
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import { removeTransformMatrixForSvgParsing } from '../util/transform_matrix_removal';
|
|
11
11
|
import type { FabricObject } from '../shapes/Object/FabricObject';
|
|
12
12
|
import { Point } from '../Point';
|
|
13
|
-
import { CENTER } from '../constants';
|
|
13
|
+
import { CENTER, FILL, STROKE } from '../constants';
|
|
14
14
|
import { getGradientDefs } from './getGradientDefs';
|
|
15
15
|
import { getCSSRules } from './getCSSRules';
|
|
16
16
|
import type { LoadImageOptions } from '../util';
|
|
@@ -77,8 +77,8 @@ export class ElementsParser {
|
|
|
77
77
|
this.options,
|
|
78
78
|
this.cssRules
|
|
79
79
|
);
|
|
80
|
-
this.resolveGradient(obj, el,
|
|
81
|
-
this.resolveGradient(obj, el,
|
|
80
|
+
this.resolveGradient(obj, el, FILL);
|
|
81
|
+
this.resolveGradient(obj, el, STROKE);
|
|
82
82
|
if (obj instanceof FabricImage && obj._originalElement) {
|
|
83
83
|
removeTransformMatrixForSvgParsing(
|
|
84
84
|
obj,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { multiplyTransformMatrices } from '../util/misc/matrix';
|
|
2
2
|
import { parseUnit } from '../util/misc/svgParsing';
|
|
3
3
|
import { parseTransformAttribute } from './parseTransformAttribute';
|
|
4
|
-
import { CENTER, LEFT, RIGHT, NONE } from '../constants';
|
|
4
|
+
import { CENTER, LEFT, RIGHT, NONE, FILL, STROKE } from '../constants';
|
|
5
5
|
|
|
6
6
|
export function normalizeValue(
|
|
7
7
|
attr: string,
|
|
@@ -12,7 +12,7 @@ export function normalizeValue(
|
|
|
12
12
|
const isArray = Array.isArray(value);
|
|
13
13
|
let parsed: number | number[];
|
|
14
14
|
let ouputValue: string | null | boolean | number[] | number = value;
|
|
15
|
-
if ((attr ===
|
|
15
|
+
if ((attr === FILL || attr === STROKE) && value === NONE) {
|
|
16
16
|
ouputValue = '';
|
|
17
17
|
} else if (attr === 'strokeUniform') {
|
|
18
18
|
return value === 'non-scaling-stroke';
|
|
@@ -48,13 +48,13 @@ export function normalizeValue(
|
|
|
48
48
|
// parseUnit returns px and we convert it to em
|
|
49
49
|
parsed = (parseUnit(value, fontSize) / fontSize) * 1000;
|
|
50
50
|
} else if (attr === 'paintFirst') {
|
|
51
|
-
const fillIndex = value.indexOf(
|
|
52
|
-
const strokeIndex = value.indexOf(
|
|
53
|
-
ouputValue =
|
|
51
|
+
const fillIndex = value.indexOf(FILL);
|
|
52
|
+
const strokeIndex = value.indexOf(STROKE);
|
|
53
|
+
ouputValue = FILL;
|
|
54
54
|
if (fillIndex > -1 && strokeIndex > -1 && strokeIndex < fillIndex) {
|
|
55
|
-
ouputValue =
|
|
55
|
+
ouputValue = STROKE;
|
|
56
56
|
} else if (fillIndex === -1 && strokeIndex > -1) {
|
|
57
|
-
ouputValue =
|
|
57
|
+
ouputValue = STROKE;
|
|
58
58
|
}
|
|
59
59
|
} else if (attr === 'href' || attr === 'xlink:href' || attr === 'font') {
|
|
60
60
|
return value;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { iMatrix } from '../constants';
|
|
1
|
+
import { ROTATE, SCALE, SKEW_X, SKEW_Y, iMatrix } from '../constants';
|
|
2
2
|
import { reNum } from './constants';
|
|
3
3
|
import type { TMat2D } from '../typedefs';
|
|
4
4
|
import { cleanupSvgAttribute } from '../util/internals/cleanupSvgAttribute';
|
|
@@ -70,16 +70,16 @@ export function parseTransformAttribute(attributeValue: string): TMat2D {
|
|
|
70
70
|
case 'translate':
|
|
71
71
|
matrix = createTranslateMatrix(arg0, arg1);
|
|
72
72
|
break;
|
|
73
|
-
case
|
|
73
|
+
case ROTATE:
|
|
74
74
|
matrix = createRotateMatrix({ angle: arg0 }, { x: arg1, y: arg2 });
|
|
75
75
|
break;
|
|
76
|
-
case
|
|
76
|
+
case SCALE:
|
|
77
77
|
matrix = createScaleMatrix(arg0, arg1);
|
|
78
78
|
break;
|
|
79
|
-
case
|
|
79
|
+
case SKEW_X:
|
|
80
80
|
matrix = createSkewXMatrix(arg0);
|
|
81
81
|
break;
|
|
82
|
-
case
|
|
82
|
+
case SKEW_Y:
|
|
83
83
|
matrix = createSkewYMatrix(arg0);
|
|
84
84
|
break;
|
|
85
85
|
case 'matrix':
|
package/src/shapes/Circle.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { FabricObject, cacheProperties } from './Object/FabricObject';
|
|
|
9
9
|
import type { Abortable, TClassProperties, TOptions } from '../typedefs';
|
|
10
10
|
import type { FabricObjectProps, SerializedObjectProps } from './Object/types';
|
|
11
11
|
import type { CSSRules } from '../parser/typedefs';
|
|
12
|
+
import { SCALE_X, SCALE_Y } from '../constants';
|
|
12
13
|
|
|
13
14
|
interface UniqueCircleProps {
|
|
14
15
|
/**
|
|
@@ -134,7 +135,7 @@ export class Circle<
|
|
|
134
135
|
* @return {Number}
|
|
135
136
|
*/
|
|
136
137
|
getRadiusX(): number {
|
|
137
|
-
return this.get('radius') * this.get(
|
|
138
|
+
return this.get('radius') * this.get(SCALE_X);
|
|
138
139
|
}
|
|
139
140
|
|
|
140
141
|
/**
|
|
@@ -142,7 +143,7 @@ export class Circle<
|
|
|
142
143
|
* @return {Number}
|
|
143
144
|
*/
|
|
144
145
|
getRadiusY(): number {
|
|
145
|
-
return this.get('radius') * this.get(
|
|
146
|
+
return this.get('radius') * this.get(SCALE_Y);
|
|
146
147
|
}
|
|
147
148
|
|
|
148
149
|
/**
|
package/src/shapes/Ellipse.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { twoMathPi } from '../constants';
|
|
1
|
+
import { SCALE_X, SCALE_Y, twoMathPi } from '../constants';
|
|
2
2
|
import { SHARED_ATTRIBUTES } from '../parser/attributes';
|
|
3
3
|
import { parseAttributes } from '../parser/parseAttributes';
|
|
4
4
|
import type { Abortable, TClassProperties, TOptions } from '../typedefs';
|
|
@@ -98,7 +98,7 @@ export class Ellipse<
|
|
|
98
98
|
* @return {Number}
|
|
99
99
|
*/
|
|
100
100
|
getRx() {
|
|
101
|
-
return this.get('rx') * this.get(
|
|
101
|
+
return this.get('rx') * this.get(SCALE_X);
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
/**
|
|
@@ -106,7 +106,7 @@ export class Ellipse<
|
|
|
106
106
|
* @return {Number}
|
|
107
107
|
*/
|
|
108
108
|
getRy() {
|
|
109
|
-
return this.get('ry') * this.get(
|
|
109
|
+
return this.get('ry') * this.get(SCALE_Y);
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
/**
|
|
@@ -10,7 +10,7 @@ import { setStyle } from '../../util/dom_style';
|
|
|
10
10
|
import { cloneDeep } from '../../util/internals/cloneDeep';
|
|
11
11
|
import type { TextStyleDeclaration } from '../Text/StyledText';
|
|
12
12
|
import { getDocumentFromElement } from '../../util/dom_misc';
|
|
13
|
-
import { NONE } from '../../constants';
|
|
13
|
+
import { CHANGED, NONE } from '../../constants';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* #### Dragging IText/Textbox Lifecycle
|
|
@@ -326,7 +326,7 @@ export class DraggableTextDelegate {
|
|
|
326
326
|
target.hiddenTextarea!.value = target.text;
|
|
327
327
|
target._updateTextarea();
|
|
328
328
|
target.hiddenTextarea!.focus();
|
|
329
|
-
target.fire(
|
|
329
|
+
target.fire(CHANGED, {
|
|
330
330
|
index: insertAt + selectionStartOffset,
|
|
331
331
|
action: 'drop',
|
|
332
332
|
});
|
|
@@ -364,7 +364,7 @@ export class DraggableTextDelegate {
|
|
|
364
364
|
target.hiddenTextarea &&
|
|
365
365
|
(target.hiddenTextarea.value = target.text);
|
|
366
366
|
target._updateTextarea();
|
|
367
|
-
target.fire(
|
|
367
|
+
target.fire(CHANGED, {
|
|
368
368
|
index: selectionStart,
|
|
369
369
|
action: 'dragend',
|
|
370
370
|
});
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
JUSTIFY_LEFT,
|
|
17
17
|
JUSTIFY_RIGHT,
|
|
18
18
|
} from '../Text/constants';
|
|
19
|
-
import { CENTER, LEFT, RIGHT } from '../../constants';
|
|
19
|
+
import { CENTER, FILL, LEFT, RIGHT } from '../../constants';
|
|
20
20
|
import type { ObjectToCanvasElementOptions } from '../Object/Object';
|
|
21
21
|
|
|
22
22
|
type CursorBoundaries = {
|
|
@@ -521,7 +521,7 @@ export class IText<
|
|
|
521
521
|
}
|
|
522
522
|
ctx.fillStyle =
|
|
523
523
|
this.cursorColor ||
|
|
524
|
-
(this.getValueOfPropertyAt(lineIndex, charIndex,
|
|
524
|
+
(this.getValueOfPropertyAt(lineIndex, charIndex, FILL) as string);
|
|
525
525
|
ctx.globalAlpha = this._currentCursorOpacity;
|
|
526
526
|
ctx.fillRect(
|
|
527
527
|
boundaries.left + boundaries.leftOffset - cursorWidth / 2,
|
|
@@ -677,7 +677,7 @@ export class IText<
|
|
|
677
677
|
*/
|
|
678
678
|
getCurrentCharColor(): string | TFiller | null {
|
|
679
679
|
const cp = this._getCurrentCharIndex();
|
|
680
|
-
return this.getValueOfPropertyAt(cp.l, cp.c,
|
|
680
|
+
return this.getValueOfPropertyAt(cp.l, cp.c, FILL);
|
|
681
681
|
}
|
|
682
682
|
|
|
683
683
|
/**
|
|
@@ -13,7 +13,7 @@ import type { TextStyleDeclaration } from '../Text/StyledText';
|
|
|
13
13
|
import type { SerializedTextProps, TextProps } from '../Text/Text';
|
|
14
14
|
import type { TOptions } from '../../typedefs';
|
|
15
15
|
import { getDocumentFromElement } from '../../util/dom_misc';
|
|
16
|
-
import { LEFT, RIGHT, reNewline } from '../../constants';
|
|
16
|
+
import { LEFT, MODIFIED, RIGHT, reNewline } from '../../constants';
|
|
17
17
|
import type { IText } from './IText';
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -696,7 +696,7 @@ export abstract class ITextBehavior<
|
|
|
696
696
|
this.setCoords();
|
|
697
697
|
}
|
|
698
698
|
this.fire('editing:exited');
|
|
699
|
-
isTextChanged && this.fire(
|
|
699
|
+
isTextChanged && this.fire(MODIFIED);
|
|
700
700
|
if (this.canvas) {
|
|
701
701
|
this.canvas.fire('text:editing:exited', {
|
|
702
702
|
target: this as unknown as IText,
|
|
@@ -7,7 +7,7 @@ import type { TKeyMapIText } from './constants';
|
|
|
7
7
|
import type { TOptions } from '../../typedefs';
|
|
8
8
|
import type { TextProps, SerializedTextProps } from '../Text/Text';
|
|
9
9
|
import { getDocumentFromElement } from '../../util/dom_misc';
|
|
10
|
-
import { LEFT, RIGHT } from '../../constants';
|
|
10
|
+
import { CHANGED, LEFT, RIGHT } from '../../constants';
|
|
11
11
|
import type { IText } from './IText';
|
|
12
12
|
import type { TextStyleDeclaration } from '../Text/StyledText';
|
|
13
13
|
|
|
@@ -173,7 +173,7 @@ export abstract class ITextKeyBehavior<
|
|
|
173
173
|
}
|
|
174
174
|
const updateAndFire = () => {
|
|
175
175
|
this.updateFromTextArea();
|
|
176
|
-
this.fire(
|
|
176
|
+
this.fire(CHANGED);
|
|
177
177
|
if (this.canvas) {
|
|
178
178
|
this.canvas.fire('text:changed', { target: this as unknown as IText });
|
|
179
179
|
this.canvas.requestRenderAll();
|
package/src/shapes/Image.ts
CHANGED
|
@@ -25,7 +25,7 @@ import { FabricObject, cacheProperties } from './Object/FabricObject';
|
|
|
25
25
|
import type { FabricObjectProps, SerializedObjectProps } from './Object/types';
|
|
26
26
|
import type { ObjectEvents } from '../EventTypeDefs';
|
|
27
27
|
import { WebGLFilterBackend } from '../filters/WebGLFilterBackend';
|
|
28
|
-
import { NONE } from '../constants';
|
|
28
|
+
import { FILL, NONE } from '../constants';
|
|
29
29
|
import { getDocumentFromElement } from '../util/dom_misc';
|
|
30
30
|
import type { CSSRules } from '../parser/typedefs';
|
|
31
31
|
import type { Resize } from '../filters/Resize';
|
|
@@ -419,7 +419,7 @@ export class FabricImage<
|
|
|
419
419
|
];
|
|
420
420
|
this.fill = origFill;
|
|
421
421
|
}
|
|
422
|
-
if (this.paintFirst !==
|
|
422
|
+
if (this.paintFirst !== FILL) {
|
|
423
423
|
svgString = svgString.concat(strokeSvg, imageMarkup);
|
|
424
424
|
} else {
|
|
425
425
|
svgString = svgString.concat(imageMarkup, strokeSvg);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TColorArg } from '../../color/typedefs';
|
|
2
|
+
import { FILL, STROKE } from '../../constants';
|
|
2
3
|
import type { ObjectEvents } from '../../EventTypeDefs';
|
|
3
4
|
import type { TAnimation } from '../../util/animation/animate';
|
|
4
5
|
import { animate, animateColor } from '../../util/animation/animate';
|
|
@@ -17,7 +18,7 @@ export abstract class AnimatableObject<
|
|
|
17
18
|
* List of properties to consider for animating colors.
|
|
18
19
|
* @type String[]
|
|
19
20
|
*/
|
|
20
|
-
static colorProperties: string[] = [
|
|
21
|
+
static colorProperties: string[] = [FILL, STROKE, 'backgroundColor'];
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* Animates object's properties
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { TSVGReviver } from '../../typedefs';
|
|
2
2
|
import { uid } from '../../util/internals/uid';
|
|
3
3
|
import { colorPropToSVG, matrixToSVG } from '../../util/misc/svgParsing';
|
|
4
|
-
import { NONE } from '../../constants';
|
|
4
|
+
import { FILL, NONE, STROKE } from '../../constants';
|
|
5
5
|
import type { FabricObject } from './FabricObject';
|
|
6
6
|
import { isFiller } from '../../util/typeAssertions';
|
|
7
7
|
|
|
@@ -34,8 +34,8 @@ export class FabricObjectSVGExportMixin {
|
|
|
34
34
|
opacity = typeof this.opacity !== 'undefined' ? this.opacity : '1',
|
|
35
35
|
visibility = this.visible ? '' : ' visibility: hidden;',
|
|
36
36
|
filter = skipShadow ? '' : this.getSvgFilter(),
|
|
37
|
-
fill = colorPropToSVG(
|
|
38
|
-
stroke = colorPropToSVG(
|
|
37
|
+
fill = colorPropToSVG(FILL, this.fill),
|
|
38
|
+
stroke = colorPropToSVG(STROKE, this.stroke);
|
|
39
39
|
|
|
40
40
|
return [
|
|
41
41
|
stroke,
|
|
@@ -247,8 +247,6 @@ export class FabricObjectSVGExportMixin {
|
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
addPaintOrder(this: FabricObjectSVGExportMixin & FabricObject) {
|
|
250
|
-
return this.paintFirst !== '
|
|
251
|
-
? ` paint-order="${this.paintFirst}" `
|
|
252
|
-
: '';
|
|
250
|
+
return this.paintFirst !== FILL ? ` paint-order="${this.paintFirst}" ` : '';
|
|
253
251
|
}
|
|
254
252
|
}
|
|
@@ -19,6 +19,7 @@ import type { FabricObjectProps } from './types/FabricObjectProps';
|
|
|
19
19
|
import type { TFabricObjectProps, SerializedObjectProps } from './types';
|
|
20
20
|
import { createObjectDefaultControls } from '../../controls/commonControls';
|
|
21
21
|
import { interactiveObjectDefaultValues } from './defaultValues';
|
|
22
|
+
import { SCALE } from '../../constants';
|
|
22
23
|
|
|
23
24
|
export type TOCoord = Point & {
|
|
24
25
|
corner: TCornerPoint;
|
|
@@ -182,7 +183,7 @@ export class InteractiveFabricObject<
|
|
|
182
183
|
if (
|
|
183
184
|
this === (target as unknown as this) &&
|
|
184
185
|
action &&
|
|
185
|
-
action.startsWith(
|
|
186
|
+
action.startsWith(SCALE)
|
|
186
187
|
) {
|
|
187
188
|
return false;
|
|
188
189
|
}
|
|
@@ -5,6 +5,9 @@ import {
|
|
|
5
5
|
CENTER,
|
|
6
6
|
iMatrix,
|
|
7
7
|
LEFT,
|
|
8
|
+
SCALE_X,
|
|
9
|
+
SCALE_Y,
|
|
10
|
+
STROKE,
|
|
8
11
|
TOP,
|
|
9
12
|
VERSION,
|
|
10
13
|
} from '../../constants';
|
|
@@ -282,19 +285,21 @@ export class FabricObject<
|
|
|
282
285
|
}
|
|
283
286
|
|
|
284
287
|
/**
|
|
285
|
-
* The class type.
|
|
286
|
-
* This is used for serialization purposes and internally it can be used
|
|
287
|
-
* to identify classes.
|
|
288
|
-
*
|
|
289
|
-
*
|
|
288
|
+
* The class type.
|
|
289
|
+
* This is used for serialization and deserialization purposes and internally it can be used
|
|
290
|
+
* to identify classes.
|
|
291
|
+
* When we transform a class in a plain JS object we need a way to recognize which class it was,
|
|
292
|
+
* and the type is the way we do that. It has no other purposes and you should not give one.
|
|
293
|
+
* Hard to reach on instances and please do not use to drive instance's logic (this.constructor.type).
|
|
294
|
+
* To idenfity a class use instanceof class ( instanceof Rect ).
|
|
295
|
+
* We do not do that in fabricJS code because we want to try to have code splitting possible.
|
|
290
296
|
*/
|
|
291
297
|
static type = 'FabricObject';
|
|
292
298
|
|
|
293
299
|
/**
|
|
294
300
|
* Legacy identifier of the class. Prefer using utils like isType or instanceOf
|
|
295
301
|
* Will be removed in fabric 7 or 8.
|
|
296
|
-
* The setter exists
|
|
297
|
-
* could be set in the instance
|
|
302
|
+
* The setter exists to avoid type errors in old code and possibly current deserialization code.
|
|
298
303
|
* @TODO add sustainable warning message
|
|
299
304
|
* @type string
|
|
300
305
|
* @deprecated
|
|
@@ -698,10 +703,10 @@ export class FabricObject<
|
|
|
698
703
|
* @param {*} value
|
|
699
704
|
*/
|
|
700
705
|
_set(key: string, value: any) {
|
|
701
|
-
if (key ===
|
|
706
|
+
if (key === SCALE_X || key === SCALE_Y) {
|
|
702
707
|
value = this._constrainScale(value);
|
|
703
708
|
}
|
|
704
|
-
if (key ===
|
|
709
|
+
if (key === SCALE_X && value < 0) {
|
|
705
710
|
this.flipX = !this.flipX;
|
|
706
711
|
value *= -1;
|
|
707
712
|
} else if (key === 'scaleY' && value < 0) {
|
|
@@ -847,7 +852,7 @@ export class FabricObject<
|
|
|
847
852
|
*/
|
|
848
853
|
needsItsOwnCache() {
|
|
849
854
|
if (
|
|
850
|
-
this.paintFirst ===
|
|
855
|
+
this.paintFirst === STROKE &&
|
|
851
856
|
this.hasFill() &&
|
|
852
857
|
this.hasStroke() &&
|
|
853
858
|
!!this.shadow
|
|
@@ -1181,7 +1186,7 @@ export class FabricObject<
|
|
|
1181
1186
|
* @param {CanvasRenderingContext2D} ctx Context to render on
|
|
1182
1187
|
*/
|
|
1183
1188
|
_renderPaintInOrder(ctx: CanvasRenderingContext2D) {
|
|
1184
|
-
if (this.paintFirst ===
|
|
1189
|
+
if (this.paintFirst === STROKE) {
|
|
1185
1190
|
this._renderStroke(ctx);
|
|
1186
1191
|
this._renderFill(ctx);
|
|
1187
1192
|
} else {
|
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
TOriginX,
|
|
7
7
|
TOriginY,
|
|
8
8
|
} from '../../typedefs';
|
|
9
|
-
import { iMatrix } from '../../constants';
|
|
9
|
+
import { SCALE_X, SCALE_Y, iMatrix } from '../../constants';
|
|
10
10
|
import { Intersection } from '../../Intersection';
|
|
11
11
|
import { Point } from '../../Point';
|
|
12
12
|
import { makeBoundingBoxFromPoints } from '../../util/misc/boundingBoxFromPoints';
|
|
@@ -356,8 +356,8 @@ export class ObjectGeometry<EventSpec extends ObjectEvents = ObjectEvents>
|
|
|
356
356
|
* @return {void}
|
|
357
357
|
*/
|
|
358
358
|
scale(value: number): void {
|
|
359
|
-
this._set(
|
|
360
|
-
this._set(
|
|
359
|
+
this._set(SCALE_X, value);
|
|
360
|
+
this._set(SCALE_Y, value);
|
|
361
361
|
this.setCoords();
|
|
362
362
|
}
|
|
363
363
|
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
TOP,
|
|
3
|
+
LEFT,
|
|
4
|
+
SCALE_Y,
|
|
5
|
+
SCALE_X,
|
|
6
|
+
SKEW_X,
|
|
7
|
+
SKEW_Y,
|
|
8
|
+
FILL,
|
|
9
|
+
STROKE,
|
|
10
|
+
} from '../../constants';
|
|
2
11
|
import type { TClassProperties } from '../../typedefs';
|
|
3
12
|
import type { InteractiveFabricObject } from './InteractiveObject';
|
|
4
13
|
import type { FabricObject } from './Object';
|
|
@@ -6,8 +15,8 @@ import type { FabricObject } from './Object';
|
|
|
6
15
|
export const stateProperties = [
|
|
7
16
|
TOP,
|
|
8
17
|
LEFT,
|
|
9
|
-
|
|
10
|
-
|
|
18
|
+
SCALE_X,
|
|
19
|
+
SCALE_Y,
|
|
11
20
|
'flipX',
|
|
12
21
|
'flipY',
|
|
13
22
|
'originX',
|
|
@@ -17,13 +26,13 @@ export const stateProperties = [
|
|
|
17
26
|
'globalCompositeOperation',
|
|
18
27
|
'shadow',
|
|
19
28
|
'visible',
|
|
20
|
-
|
|
21
|
-
|
|
29
|
+
SKEW_X,
|
|
30
|
+
SKEW_Y,
|
|
22
31
|
];
|
|
23
32
|
|
|
24
33
|
export const cacheProperties = [
|
|
25
|
-
|
|
26
|
-
|
|
34
|
+
FILL,
|
|
35
|
+
STROKE,
|
|
27
36
|
'strokeWidth',
|
|
28
37
|
'strokeDashArray',
|
|
29
38
|
'width',
|
|
@@ -60,7 +69,7 @@ export const fabricObjectDefaultValues: Partial<
|
|
|
60
69
|
strokeUniform: false,
|
|
61
70
|
padding: 0,
|
|
62
71
|
opacity: 1,
|
|
63
|
-
paintFirst:
|
|
72
|
+
paintFirst: FILL,
|
|
64
73
|
fill: 'rgb(0,0,0)',
|
|
65
74
|
fillRule: 'nonzero',
|
|
66
75
|
stroke: null,
|
|
@@ -31,7 +31,7 @@ export interface ControlProps {
|
|
|
31
31
|
* Color of controlling corners of an object (when it's active and transparentCorners false)
|
|
32
32
|
* @since 1.6.2
|
|
33
33
|
* @type String
|
|
34
|
-
* @default
|
|
34
|
+
* @default ''
|
|
35
35
|
*/
|
|
36
36
|
cornerStrokeColor: string;
|
|
37
37
|
|
|
@@ -41,7 +41,7 @@ export interface ControlProps {
|
|
|
41
41
|
* And you can swap it with one of the alternative proposed with the control api
|
|
42
42
|
* @since 1.6.2
|
|
43
43
|
* @type 'rect' | 'circle'
|
|
44
|
-
* @default rect
|
|
44
|
+
* @default 'rect'
|
|
45
45
|
* @deprecated
|
|
46
46
|
*/
|
|
47
47
|
cornerStyle: 'rect' | 'circle';
|
|
@@ -50,6 +50,7 @@ export interface ControlProps {
|
|
|
50
50
|
* Array specifying dash pattern of an object's control (hasBorder must be true)
|
|
51
51
|
* @since 1.6.2
|
|
52
52
|
* @type Array | null
|
|
53
|
+
* @default null
|
|
53
54
|
*/
|
|
54
55
|
cornerDashArray: number[] | null;
|
|
55
56
|
|
|
@@ -63,7 +64,7 @@ export interface ControlProps {
|
|
|
63
64
|
/**
|
|
64
65
|
* When set to `false`, object's controls are not displayed and can not be used to manipulate object
|
|
65
66
|
* @type Boolean
|
|
66
|
-
* @default
|
|
67
|
+
* @default true
|
|
67
68
|
*/
|
|
68
69
|
hasControls: boolean;
|
|
69
70
|
}
|