@yorab/react-paint 0.15.1 → 0.16.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.
@@ -6,3 +6,5 @@ export declare const SELECTION_ANCHOR_SIZE = 14;
6
6
  export declare const SELECTION_ROTATED_ANCHOR_POSITION = 16;
7
7
  export declare const SELECTION_RESIZE_ANCHOR_POSITIONS: Point[];
8
8
  export declare const ShapeTypeArray: readonly ["brush", "rect", "square", "line", "polygon", "circle", "curve", "ellipse", "picture", "text", "triangle", "group"];
9
+ export declare const SHAPES_WITH_ROTATION: string[];
10
+ export declare const SHAPES_KEEPING_RATIO: string[];
@@ -65,6 +65,8 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
65
65
  src: string;
66
66
  } & {
67
67
  img: HTMLImageElement;
68
+ flipX?: boolean;
69
+ flipY?: boolean;
68
70
  type: "picture";
69
71
  } & {
70
72
  img: HTMLImageElement;
@@ -88,6 +90,8 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
88
90
  value: string[];
89
91
  fontSize: number;
90
92
  } & {
93
+ flipX?: boolean;
94
+ flipY?: boolean;
91
95
  type: "text";
92
96
  } & {
93
97
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
@@ -302,6 +306,8 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
302
306
  src: string;
303
307
  } & {
304
308
  img: HTMLImageElement;
309
+ flipX?: boolean;
310
+ flipY?: boolean;
305
311
  type: "picture";
306
312
  } & {
307
313
  img: HTMLImageElement;
@@ -325,6 +331,8 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
325
331
  value: string[];
326
332
  fontSize: number;
327
333
  } & {
334
+ flipX?: boolean;
335
+ flipY?: boolean;
328
336
  type: "text";
329
337
  } & {
330
338
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
@@ -571,6 +579,8 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
571
579
  src: string;
572
580
  } & {
573
581
  img: HTMLImageElement;
582
+ flipX?: boolean;
583
+ flipY?: boolean;
574
584
  type: "picture";
575
585
  } & {
576
586
  img: HTMLImageElement;
@@ -594,6 +604,8 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
594
604
  value: string[];
595
605
  fontSize: number;
596
606
  } & {
607
+ flipX?: boolean;
608
+ flipY?: boolean;
597
609
  type: "text";
598
610
  } & {
599
611
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
@@ -801,6 +813,8 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
801
813
  src: string;
802
814
  } & {
803
815
  img: HTMLImageElement;
816
+ flipX?: boolean;
817
+ flipY?: boolean;
804
818
  type: "picture";
805
819
  } & {
806
820
  img: HTMLImageElement;
@@ -824,6 +838,8 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
824
838
  value: string[];
825
839
  fontSize: number;
826
840
  } & {
841
+ flipX?: boolean;
842
+ flipY?: boolean;
827
843
  type: "text";
828
844
  } & {
829
845
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
@@ -1035,6 +1051,8 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
1035
1051
  src: string;
1036
1052
  } & {
1037
1053
  img: HTMLImageElement;
1054
+ flipX?: boolean;
1055
+ flipY?: boolean;
1038
1056
  type: "picture";
1039
1057
  } & {
1040
1058
  img: HTMLImageElement;
@@ -1058,6 +1076,8 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
1058
1076
  value: string[];
1059
1077
  fontSize: number;
1060
1078
  } & {
1079
+ flipX?: boolean;
1080
+ flipY?: boolean;
1061
1081
  type: "text";
1062
1082
  } & {
1063
1083
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
@@ -1266,6 +1286,8 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
1266
1286
  src: string;
1267
1287
  } & {
1268
1288
  img: HTMLImageElement;
1289
+ flipX?: boolean;
1290
+ flipY?: boolean;
1269
1291
  type: "picture";
1270
1292
  } & {
1271
1293
  img: HTMLImageElement;
@@ -1289,6 +1311,8 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
1289
1311
  value: string[];
1290
1312
  fontSize: number;
1291
1313
  } & {
1314
+ flipX?: boolean;
1315
+ flipY?: boolean;
1292
1316
  type: "text";
1293
1317
  } & {
1294
1318
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
@@ -1495,6 +1519,8 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
1495
1519
  src: string;
1496
1520
  } & {
1497
1521
  img: HTMLImageElement;
1522
+ flipX?: boolean;
1523
+ flipY?: boolean;
1498
1524
  type: "picture";
1499
1525
  } & {
1500
1526
  img: HTMLImageElement;
@@ -1518,6 +1544,8 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
1518
1544
  value: string[];
1519
1545
  fontSize: number;
1520
1546
  } & {
1547
+ flipX?: boolean;
1548
+ flipY?: boolean;
1521
1549
  type: "text";
1522
1550
  } & {
1523
1551
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
@@ -1724,6 +1752,8 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
1724
1752
  src: string;
1725
1753
  } & {
1726
1754
  img: HTMLImageElement;
1755
+ flipX?: boolean;
1756
+ flipY?: boolean;
1727
1757
  type: "picture";
1728
1758
  } & {
1729
1759
  img: HTMLImageElement;
@@ -1747,6 +1777,8 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
1747
1777
  value: string[];
1748
1778
  fontSize: number;
1749
1779
  } & {
1780
+ flipX?: boolean;
1781
+ flipY?: boolean;
1750
1782
  type: "text";
1751
1783
  } & {
1752
1784
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
@@ -42,6 +42,8 @@ declare const useShapes: (settings: UtilsSettings, width: number, height: number
42
42
  src: string;
43
43
  } & {
44
44
  img: HTMLImageElement;
45
+ flipX?: boolean;
46
+ flipY?: boolean;
45
47
  type: "picture";
46
48
  } & {
47
49
  img: HTMLImageElement;
@@ -65,6 +67,8 @@ declare const useShapes: (settings: UtilsSettings, width: number, height: number
65
67
  value: string[];
66
68
  fontSize: number;
67
69
  } & {
70
+ flipX?: boolean;
71
+ flipY?: boolean;
68
72
  type: "text";
69
73
  } & {
70
74
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
@@ -272,6 +276,8 @@ declare const useShapes: (settings: UtilsSettings, width: number, height: number
272
276
  src: string;
273
277
  } & {
274
278
  img: HTMLImageElement;
279
+ flipX?: boolean;
280
+ flipY?: boolean;
275
281
  type: "picture";
276
282
  } & {
277
283
  img: HTMLImageElement;
@@ -295,6 +301,8 @@ declare const useShapes: (settings: UtilsSettings, width: number, height: number
295
301
  value: string[];
296
302
  fontSize: number;
297
303
  } & {
304
+ flipX?: boolean;
305
+ flipY?: boolean;
298
306
  type: "text";
299
307
  } & {
300
308
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
@@ -502,6 +510,8 @@ declare const useShapes: (settings: UtilsSettings, width: number, height: number
502
510
  src: string;
503
511
  } & {
504
512
  img: HTMLImageElement;
513
+ flipX?: boolean;
514
+ flipY?: boolean;
505
515
  type: "picture";
506
516
  } & {
507
517
  img: HTMLImageElement;
@@ -525,6 +535,8 @@ declare const useShapes: (settings: UtilsSettings, width: number, height: number
525
535
  value: string[];
526
536
  fontSize: number;
527
537
  } & {
538
+ flipX?: boolean;
539
+ flipY?: boolean;
528
540
  type: "text";
529
541
  } & {
530
542
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
@@ -746,6 +758,8 @@ declare const useShapes: (settings: UtilsSettings, width: number, height: number
746
758
  src: string;
747
759
  } & {
748
760
  img: HTMLImageElement;
761
+ flipX?: boolean;
762
+ flipY?: boolean;
749
763
  type: "picture";
750
764
  } & {
751
765
  img: HTMLImageElement;
@@ -769,6 +783,8 @@ declare const useShapes: (settings: UtilsSettings, width: number, height: number
769
783
  value: string[];
770
784
  fontSize: number;
771
785
  } & {
786
+ flipX?: boolean;
787
+ flipY?: boolean;
772
788
  type: "text";
773
789
  } & {
774
790
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
@@ -975,6 +991,8 @@ declare const useShapes: (settings: UtilsSettings, width: number, height: number
975
991
  src: string;
976
992
  } & {
977
993
  img: HTMLImageElement;
994
+ flipX?: boolean;
995
+ flipY?: boolean;
978
996
  type: "picture";
979
997
  } & {
980
998
  img: HTMLImageElement;
@@ -998,6 +1016,8 @@ declare const useShapes: (settings: UtilsSettings, width: number, height: number
998
1016
  value: string[];
999
1017
  fontSize: number;
1000
1018
  } & {
1019
+ flipX?: boolean;
1020
+ flipY?: boolean;
1001
1021
  type: "text";
1002
1022
  } & {
1003
1023
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
@@ -1204,6 +1224,8 @@ declare const useShapes: (settings: UtilsSettings, width: number, height: number
1204
1224
  src: string;
1205
1225
  } & {
1206
1226
  img: HTMLImageElement;
1227
+ flipX?: boolean;
1228
+ flipY?: boolean;
1207
1229
  type: "picture";
1208
1230
  } & {
1209
1231
  img: HTMLImageElement;
@@ -1227,6 +1249,8 @@ declare const useShapes: (settings: UtilsSettings, width: number, height: number
1227
1249
  value: string[];
1228
1250
  fontSize: number;
1229
1251
  } & {
1252
+ flipX?: boolean;
1253
+ flipY?: boolean;
1230
1254
  type: "text";
1231
1255
  } & {
1232
1256
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
@@ -52,6 +52,8 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
52
52
  src: string;
53
53
  } & {
54
54
  img: HTMLImageElement;
55
+ flipX?: boolean;
56
+ flipY?: boolean;
55
57
  type: "picture";
56
58
  } & {
57
59
  img: HTMLImageElement;
@@ -75,6 +77,8 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
75
77
  value: string[];
76
78
  fontSize: number;
77
79
  } & {
80
+ flipX?: boolean;
81
+ flipY?: boolean;
78
82
  type: "text";
79
83
  } & {
80
84
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
@@ -1,3 +1,4 @@
1
1
  import type { UtilsSettings } from './../../../canvas/constants/app';
2
- import type { ShapeEntity } from './../../../common/types/Shapes';
3
- export declare const drawSelectionGroup: (ctx: CanvasRenderingContext2D, shape: ShapeEntity<"group">, selectionColor: string, selectionWidth: number, settings: UtilsSettings, withAnchors: boolean) => void;
2
+ import type { SelectionModeData } from './../../../common/types/Mode';
3
+ import type { Point, ShapeEntity } from './../../../common/types/Shapes';
4
+ export declare const drawSelectionGroup: (ctx: CanvasRenderingContext2D, shape: ShapeEntity<"group">, selectionColor: string, selectionWidth: number, selectionMode: SelectionModeData<number | Point>, settings: UtilsSettings, withAnchors: boolean) => void;
@@ -5,7 +5,7 @@ export declare const createRecSelectionPath: (path: Path2D | undefined, computed
5
5
  borders: Rect;
6
6
  outerBorders: Rect;
7
7
  center: Point;
8
- }, settings: UtilsSettings, isGroup?: boolean) => SelectionDefaultType;
8
+ }, settings: UtilsSettings) => SelectionDefaultType;
9
9
  export declare const drawBoundingBox: (ctx: CanvasRenderingContext2D, shape: SelectionType, selectionWidth: number, settings: UtilsSettings) => void;
10
10
  export declare const drawSelectionRect: (ctx: CanvasRenderingContext2D, shape: ShapeEntity & {
11
11
  selection?: SelectionDefaultType | undefined;
@@ -15,4 +15,6 @@ export declare const resizeRectSelection: (cursorPosition: Point, originalShape:
15
15
  borderHeight: number;
16
16
  borderY: number;
17
17
  borderWidth: number;
18
+ isXinverted: boolean;
19
+ isYinverted: boolean;
18
20
  };
@@ -1,7 +1,9 @@
1
1
  import type { UtilsSettings } from './../../../canvas/constants/app';
2
2
  import type { SelectionModeResize } from './../../../common/types/Mode';
3
- import type { DrawableShape, Point, Rect, ShapeEntity } from './../../../common/types/Shapes';
3
+ import type { DrawableShape, Point, Rect, SelectionType, ShapeEntity } from './../../../common/types/Shapes';
4
4
  import type { ToolsSettingsType } from './../../../common/types/tools';
5
+ import { type GroupResizeContext } from './group';
6
+ export declare const getBrushBorder: (brush: DrawableShape<"brush">, { selectionPadding }: Pick<UtilsSettings, "selectionPadding">) => Rect;
5
7
  export declare const getComputedBrush: (brush: DrawableShape<"brush">, settings: UtilsSettings) => {
6
8
  borders: Rect;
7
9
  outerBorders: Rect;
@@ -17,7 +19,9 @@ export declare const createBrush: (shape: {
17
19
  settings: ToolsSettingsType<"brush">;
18
20
  }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"brush">;
19
21
  export declare const drawBrush: (ctx: CanvasRenderingContext2D, shape: ShapeEntity<"brush">) => void;
20
- export declare const translateBrush: (cursorPosition: Point, originalShape: ShapeEntity<"brush">, originalCursorPosition: Point, settings: UtilsSettings, singleAxis: boolean) => ShapeEntity<"brush">;
21
22
  export declare const resizeBrush: (cursorPosition: Point, originalShape: ShapeEntity<"brush">, selectionMode: SelectionModeResize, settings: UtilsSettings, keepRatio: boolean, resizeFromCenter: boolean) => ShapeEntity<"brush">;
23
+ export declare const resizeBrushInGroup: (shape: ShapeEntity<"brush">, group: SelectionType & {
24
+ type: "group";
25
+ }, groupCtx: GroupResizeContext) => ShapeEntity<"brush">;
22
26
  export declare const addNewPointToShape: (shape: ShapeEntity<"brush">, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"brush">;
23
27
  export declare const addNewPointGroupToShape: (shape: ShapeEntity<"brush">, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"brush">;
@@ -1,7 +1,8 @@
1
1
  import type { UtilsSettings } from './../../../canvas/constants/app';
2
2
  import type { SelectionModeResize } from './../../../common/types/Mode';
3
- import type { DrawableShape, Point, Rect, ShapeEntity } from './../../../common/types/Shapes';
3
+ import type { DrawableShape, Point, Rect, SelectionType, ShapeEntity } from './../../../common/types/Shapes';
4
4
  import type { ToolsSettingsType } from './../../../common/types/tools';
5
+ import { type GroupResizeContext } from './group';
5
6
  export declare const getComputedCircle: (circle: DrawableShape<"circle">, settings: UtilsSettings) => {
6
7
  borders: Rect;
7
8
  outerBorders: Rect;
@@ -17,5 +18,7 @@ export declare const createCircle: (shape: {
17
18
  settings: ToolsSettingsType<"circle">;
18
19
  }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"circle">;
19
20
  export declare const drawCircle: (ctx: CanvasRenderingContext2D, circle: ShapeEntity<"circle">) => void;
20
- export declare const translateCircle: (cursorPosition: Point, originalShape: ShapeEntity<"circle">, originalCursorPosition: Point, settings: UtilsSettings, singleAxis: boolean) => ShapeEntity<"circle">;
21
21
  export declare const resizeCircle: (cursorPosition: Point, originalShape: ShapeEntity<"circle">, selectionMode: SelectionModeResize, settings: UtilsSettings, resizeFromCenter: boolean) => ShapeEntity<"circle">;
22
+ export declare const resizeCircleInGroup: (shape: ShapeEntity<"circle">, group: SelectionType & {
23
+ type: "group";
24
+ }, groupCtx: GroupResizeContext) => ShapeEntity<"circle">;
@@ -18,6 +18,5 @@ export declare const createCurve: (shape: {
18
18
  }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"curve">;
19
19
  export declare const resizeCurve: (cursorPosition: Point, originalShape: ShapeEntity<"curve">, selectionMode: SelectionModeResize<number>, settings: UtilsSettings) => ShapeEntity<"curve">;
20
20
  export declare const drawCurve: (ctx: CanvasRenderingContext2D, curve: ShapeEntity<"curve">) => void;
21
- export declare const translateCurve: (cursorPosition: Point, originalShape: ShapeEntity<"curve">, originalCursorPosition: Point, settings: UtilsSettings, singleAxis: boolean) => ShapeEntity<"curve">;
22
21
  export declare const addCurveLine: (shape: ShapeEntity<"curve">, lineIndex: number, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"curve">;
23
22
  export declare const addCurvePoint: (shape: ShapeEntity<"curve">, cursorPosition: Point, settings: UtilsSettings, temporary?: boolean) => ShapeEntity<"curve">;
@@ -1,7 +1,8 @@
1
1
  import type { UtilsSettings } from './../../../canvas/constants/app';
2
2
  import type { SelectionModeResize } from './../../../common/types/Mode';
3
- import type { DrawableShape, Point, Rect, ShapeEntity } from './../../../common/types/Shapes';
3
+ import type { DrawableShape, Point, Rect, SelectionType, ShapeEntity } from './../../../common/types/Shapes';
4
4
  import type { ToolsSettingsType } from './../../../common/types/tools';
5
+ import { type GroupResizeContext } from './group';
5
6
  export declare const getComputedEllipse: (ellipse: DrawableShape<"ellipse">, settings: UtilsSettings) => {
6
7
  borders: Rect;
7
8
  outerBorders: Rect;
@@ -17,5 +18,7 @@ export declare const createEllipse: (shape: {
17
18
  settings: ToolsSettingsType<"ellipse">;
18
19
  }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"ellipse">;
19
20
  export declare const drawEllipse: (ctx: CanvasRenderingContext2D, ellipse: ShapeEntity<"ellipse">) => void;
20
- export declare const translateEllipse: (cursorPosition: Point, originalShape: ShapeEntity<"ellipse">, originalCursorPosition: Point, settings: UtilsSettings, singleAxis: boolean) => ShapeEntity<"ellipse">;
21
21
  export declare const resizeEllipse: (cursorPosition: Point, originalShape: ShapeEntity<"ellipse">, selectionMode: SelectionModeResize, settings: UtilsSettings, keepRatio?: boolean, resizeFromCenter?: boolean) => ShapeEntity<"ellipse">;
22
+ export declare const resizeEllipseInGroup: (shape: ShapeEntity<"ellipse">, group: SelectionType & {
23
+ type: "group";
24
+ }, groupCtx: GroupResizeContext) => ShapeEntity<"ellipse">;
@@ -0,0 +1,33 @@
1
+ import type { UtilsSettings } from './../../../canvas/constants/app';
2
+ import type { SelectionModeResize } from './../../../common/types/Mode';
3
+ import type { Point, SelectionType, ShapeEntity } from './../../../common/types/Shapes';
4
+ /** Shared context when resizing shapes inside a group */
5
+ export type GroupResizeContext = {
6
+ newBorderX: number;
7
+ newBorderY: number;
8
+ newBorderWidth: number;
9
+ newBorderHeight: number;
10
+ widthMultiplier: number;
11
+ heightMultiplier: number;
12
+ isXinverted: boolean;
13
+ isYinverted: boolean;
14
+ groupCenter: Point;
15
+ rotation: number;
16
+ settings: UtilsSettings;
17
+ originalBorders: {
18
+ x: number;
19
+ y: number;
20
+ width: number;
21
+ height: number;
22
+ };
23
+ };
24
+ export declare const getGroupResizeContext: (cursorPosition: Point, group: SelectionType & {
25
+ type: "group";
26
+ }, selectionMode: SelectionModeResize, settings: UtilsSettings, keepRatio: boolean, isAltPressed: boolean) => GroupResizeContext;
27
+ export declare const getShapePositionInNewBorder: (shape: ShapeEntity, group: SelectionType & {
28
+ type: "group";
29
+ }, ctx: GroupResizeContext) => {
30
+ x: number;
31
+ y: number;
32
+ };
33
+ export declare const getPositionWithoutGroupRotation: (ctx: GroupResizeContext, positionInBorderX: number, positionInBorderY: number, sizeInBorderW: number, sizeInBorderH: number) => Point;
@@ -1,5 +1,5 @@
1
1
  import type { UtilsSettings } from './../../../canvas/constants/app';
2
- import type { HoverModeData, SelectionModeData } from './../../../common/types/Mode';
2
+ import type { HoverModeData, SelectionModeData, SelectionModeResize } from './../../../common/types/Mode';
3
3
  import type { DrawableShape, Point, SelectionType, ShapeEntity } from './../../../common/types/Shapes';
4
4
  import type { CustomTool } from './../../../common/types/tools';
5
5
  export declare const createShape: (ctx: CanvasRenderingContext2D, shape: Exclude<CustomTool, {
@@ -7,16 +7,9 @@ export declare const createShape: (ctx: CanvasRenderingContext2D, shape: Exclude
7
7
  }>, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity | undefined;
8
8
  export declare const isInView: (shape: ShapeEntity, settings: UtilsSettings) => boolean;
9
9
  export declare const drawShape: (ctx: CanvasRenderingContext2D, shape: ShapeEntity, settings: UtilsSettings) => void;
10
- export declare const rotateShape: <T extends DrawableShape>(shape: T, cursorPosition: Point, originalShape: T, originalCursorPosition: Point, shapeCenter: Point, settings: UtilsSettings, isShiftPressed: boolean) => T & {
11
- computed: {
12
- borders: import("./../../../common/types/Shapes").Rect;
13
- outerBorders: import("./../../../common/types/Shapes").Rect;
14
- center: Point;
15
- boundingBox: import("./../../../common/types/Shapes").Rect;
16
- } | undefined;
17
- };
18
- export declare const resizeShape: <T extends ShapeEntity>(ctx: CanvasRenderingContext2D, shape: T, cursorPosition: Point, originalShape: T, selectionMode: SelectionModeData<Point | number>, settings: UtilsSettings, isShiftPressed: boolean, isAltPressed: boolean) => T;
19
- export declare const translateShape: (cursorPosition: Point, originalShape: ShapeEntity, originalCursorPosition: Point, settings: UtilsSettings, isShiftPressed: boolean) => ShapeEntity;
10
+ export declare const rotateShape: <T extends ShapeEntity>(shape: T, rotationToApply: number, selectionCenter: Point) => T;
11
+ export declare const resizeShape: <T extends ShapeEntity>(ctx: CanvasRenderingContext2D, cursorPosition: Point, originalShape: T, selectionMode: SelectionModeData<Point | number>, settings: UtilsSettings, isShiftPressed: boolean, isAltPressed: boolean) => T;
12
+ export declare const resizeShapes: (ctx: CanvasRenderingContext2D, cursorPosition: Point, originalShape: SelectionType, selectionMode: SelectionModeResize<Point | number>, settings: UtilsSettings, isShiftPressed: boolean, isAltPressed: boolean) => ShapeEntity[];
20
13
  export declare const translateShapes: (cursorPosition: Point, originalShape: SelectionType, originalCursorPosition: Point, settings: UtilsSettings, isShiftPressed: boolean) => ShapeEntity[];
21
14
  export declare const refreshShape: (shape: DrawableShape & {
22
15
  id: string;
@@ -27,13 +20,14 @@ export declare const getShapeComputedData: (shape: DrawableShape, settings: Util
27
20
  center: Point;
28
21
  boundingBox: import("./../../../common/types/Shapes").Rect;
29
22
  } | undefined;
30
- export declare const drawShapeSelection: ({ ctx, shape, settings, selectionWidth, selectionColor, hoverMode, withAnchors }: {
23
+ export declare const drawShapeSelection: ({ ctx, shape, settings, selectionWidth, selectionColor, hoverMode, selectionMode, withAnchors }: {
31
24
  ctx: CanvasRenderingContext2D;
32
25
  shape: SelectionType;
33
26
  settings: UtilsSettings;
34
27
  selectionWidth: number;
35
28
  selectionColor: string;
36
29
  hoverMode: HoverModeData;
30
+ selectionMode: SelectionModeData<number | Point>;
37
31
  withAnchors?: boolean;
38
32
  }) => void;
39
33
  export declare const drawSelectionFrame: ({ ctx, selectionFrame, settings }: {
@@ -1,7 +1,8 @@
1
1
  import type { UtilsSettings } from './../../../canvas/constants/app';
2
2
  import type { SelectionModeResize } from './../../../common/types/Mode';
3
- import type { DrawableShape, Point, Rect, ShapeEntity, StyleShape, Triangle } from './../../../common/types/Shapes';
3
+ import type { DrawableShape, Point, Rect, SelectionType, ShapeEntity, StyleShape, Triangle } from './../../../common/types/Shapes';
4
4
  import type { ToolsSettingsType } from './../../../common/types/tools';
5
+ import { type GroupResizeContext } from './group';
5
6
  export declare const getComputedLine: (line: DrawableShape<"line">, settings: UtilsSettings) => {
6
7
  borders: Rect;
7
8
  outerBorders: Rect;
@@ -18,5 +19,7 @@ export declare const createLine: (shape: {
18
19
  }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"line">;
19
20
  export declare const buildTriangleOnLine: (center: Point, rotation: number, lineStyle: StyleShape) => Triangle;
20
21
  export declare const drawLine: (ctx: CanvasRenderingContext2D, shape: ShapeEntity<"line">) => void;
21
- export declare const translateLine: (cursorPosition: Point, originalShape: ShapeEntity<"line">, originalCursorPosition: Point, settings: UtilsSettings, singleAxis: boolean) => ShapeEntity<"line">;
22
22
  export declare const resizeLine: (cursorPosition: Point, originalShape: ShapeEntity<"line">, selectionMode: SelectionModeResize<number>, settings: UtilsSettings) => ShapeEntity<"line">;
23
+ export declare const resizeLinePolygonCurveInGroup: (shape: ShapeEntity<"line" | "polygon" | "curve">, group: SelectionType & {
24
+ type: "group";
25
+ }, groupCtx: GroupResizeContext) => ShapeEntity<"line" | "polygon" | "curve">;
@@ -1,5 +1,5 @@
1
1
  import type { UtilsSettings } from './../../../canvas/constants/app';
2
- import type { Circle, DrawableShape, Line, Point, Rect, StyleShape } from './../../../common/types/Shapes';
2
+ import type { Circle, DrawableShape, Line, Point, Rect } from './../../../common/types/Shapes';
3
3
  export declare const createRecPath: (rect: Rect) => Path2D;
4
4
  export declare const createCirclePath: (shape: Circle) => Path2D;
5
5
  export declare const createEllipsePath: (ellipse: DrawableShape<"ellipse">) => Path2D;
@@ -20,7 +20,7 @@ export declare const catmullRomToBezier: (p0: Point, p1: Point, p2: Point, p3: P
20
20
  export declare const createCurvePath: (curve: DrawableShape<"curve">) => Path2D | undefined;
21
21
  export declare const createPolygonPath: (polygon: DrawableShape<"polygon"> | DrawableShape<"curve">) => Path2D | undefined;
22
22
  export declare const createTrianglePath: (triangle: DrawableShape<"triangle">) => Path2D;
23
- export declare const getComputedShapeInfos: <T extends DrawableShape, U extends Pick<UtilsSettings, "selectionPadding">>(shape: T, getBorder: (shape: T, settings: U) => Rect, settings: U, getOuterBorder?: (border: Rect, style: StyleShape | undefined) => Rect) => {
23
+ export declare const getComputedShapeInfos: <T extends DrawableShape, U extends Pick<UtilsSettings, "selectionPadding">>(shape: T, getBorder: (shape: T, settings: U) => Rect, settings: U, getOuterBorder?: (shape: T, borders: Rect, settings: U) => Rect) => {
24
24
  borders: Rect;
25
25
  outerBorders: Rect;
26
26
  center: Point;
@@ -1,6 +1,7 @@
1
1
  import type { UtilsSettings } from './../../../canvas/constants/app';
2
2
  import type { SelectionModeResize } from './../../../common/types/Mode';
3
- import type { DrawableShape, Point, ShapeEntity } from './../../../common/types/Shapes';
3
+ import type { DrawableShape, Point, SelectionType, ShapeEntity } from './../../../common/types/Shapes';
4
+ import { type GroupResizeContext } from './group';
4
5
  export declare const getComputedPicture: (picture: DrawableShape<"picture">, settings: UtilsSettings) => {
5
6
  borders: import("./../../../common/types/Shapes").Rect;
6
7
  outerBorders: import("./../../../common/types/Shapes").Rect;
@@ -12,5 +13,7 @@ export declare const refreshPicture: <T extends DrawableShape<"picture">>(shape:
12
13
  }, settings: UtilsSettings) => ShapeEntity<"picture">;
13
14
  export declare const createPicture: (fileOrUrl: File | string, maxPictureWidth: number, maxPictureHeight: number, settings: UtilsSettings) => Promise<ShapeEntity<"picture">>;
14
15
  export declare const drawPicture: (ctx: CanvasRenderingContext2D, picture: ShapeEntity<"picture">) => void;
15
- export declare const translatePicture: (cursorPosition: Point, originalShape: ShapeEntity<"picture">, originalCursorPosition: Point, settings: UtilsSettings, singleAxis: boolean) => ShapeEntity<"picture">;
16
16
  export declare const resizePicture: (cursorPosition: Point, originalShape: ShapeEntity<"picture">, selectionMode: SelectionModeResize, settings: UtilsSettings, resizeFromCenter: boolean) => ShapeEntity<"picture">;
17
+ export declare const resizePictureInGroup: (shape: ShapeEntity<"picture">, group: SelectionType & {
18
+ type: "group";
19
+ }, groupCtx: GroupResizeContext) => ShapeEntity<"picture">;
@@ -18,7 +18,6 @@ export declare const createPolygon: (shape: {
18
18
  }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"polygon">;
19
19
  export declare const drawPolygon: (ctx: CanvasRenderingContext2D, polygon: ShapeEntity<"polygon">) => void;
20
20
  export declare const getPolygonBorder: (polygon: Polygon, settings: Pick<UtilsSettings, "selectionPadding">) => Rect;
21
- export declare const translatePolygon: (cursorPosition: Point, originalShape: ShapeEntity<"polygon">, originalCursorPosition: Point, settings: UtilsSettings, singleAxis: boolean) => ShapeEntity<"polygon">;
22
21
  export declare const resizePolygon: (cursorPosition: Point, originalShape: ShapeEntity<"polygon">, selectionMode: SelectionModeResize<number>, settings: UtilsSettings) => ShapeEntity<"polygon">;
23
22
  export declare const addPolygonLine: (shape: ShapeEntity<"polygon">, lineIndex: number, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"polygon">;
24
23
  export declare const addPolygonPoint: (shape: ShapeEntity<"polygon">, cursorPosition: Point, settings: UtilsSettings, temporary?: boolean) => ShapeEntity<"polygon">;
@@ -1,7 +1,8 @@
1
1
  import type { UtilsSettings } from './../../../canvas/constants/app';
2
2
  import type { SelectionModeResize } from './../../../common/types/Mode';
3
- import type { DrawableShape, Point, Rect, ShapeEntity } from './../../../common/types/Shapes';
3
+ import type { DrawableShape, Point, Rect, SelectionType, ShapeEntity } from './../../../common/types/Shapes';
4
4
  import type { ToolsSettingsType } from './../../../common/types/tools';
5
+ import { type GroupResizeContext } from './group';
5
6
  type rectish = 'rect' | 'square';
6
7
  export declare const getComputedRect: (rect: DrawableShape<rectish>, settings: UtilsSettings) => {
7
8
  borders: Rect;
@@ -11,55 +12,17 @@ export declare const getComputedRect: (rect: DrawableShape<rectish>, settings: U
11
12
  };
12
13
  export declare const refreshRect: <T extends rectish>(rect: DrawableShape<T> & {
13
14
  id: string;
14
- }, settings: UtilsSettings, isGroup?: boolean) => ShapeEntity<T>;
15
+ }, settings: UtilsSettings) => ShapeEntity<T>;
15
16
  export declare const createRectangle: <T extends rectish>(shape: {
16
17
  id: string;
17
18
  type: T;
18
19
  settings: ToolsSettingsType<T>;
19
- }, cursorPosition: Point, settings: UtilsSettings, isGroup?: boolean, width?: number, height?: number) => ShapeEntity<T>;
20
+ }, cursorPosition: Point, settings: UtilsSettings, width?: number, height?: number) => ShapeEntity<T>;
20
21
  export declare const drawRect: (ctx: CanvasRenderingContext2D, shape: ShapeEntity<rectish>) => void;
21
22
  export declare const getRectBorder: (rect: Rect, settings: Pick<UtilsSettings, "selectionPadding">) => Rect;
22
23
  export declare const getRectOppositeAnchorAbsolutePosition: <T extends DrawableShape & Rect>(anchor: Point, center: Point, shape: T, [negW, negH]?: [boolean, boolean]) => Point;
23
- export declare const translateRect: <T extends rectish>(cursorPosition: Point, originalShape: ShapeEntity<T>, originalCursorPosition: Point, settings: UtilsSettings, singleAxis: boolean) => ({
24
- id: string;
25
- computed: {
26
- borders: Rect;
27
- outerBorders: Rect;
28
- center: Point;
29
- boundingBox: Rect;
30
- };
31
- } & {
32
- rotation?: number;
33
- toolId?: string;
34
- visible?: boolean;
35
- locked?: boolean;
36
- style?: import("./../../../common/types/Shapes").StyleShape | undefined;
37
- } & Rect & {
38
- type: "rect";
39
- } & {
40
- selection?: import("./../../../common/types/Shapes").SelectionDefaultType | undefined;
41
- path?: Path2D | undefined;
42
- type: "rect";
43
- }) | ({
44
- id: string;
45
- computed: {
46
- borders: Rect;
47
- outerBorders: Rect;
48
- center: Point;
49
- boundingBox: Rect;
50
- };
51
- } & {
52
- rotation?: number;
53
- toolId?: string;
54
- visible?: boolean;
55
- locked?: boolean;
56
- style?: import("./../../../common/types/Shapes").StyleShape | undefined;
57
- } & Rect & {
58
- type: "square";
59
- } & {
60
- selection?: import("./../../../common/types/Shapes").SelectionDefaultType | undefined;
61
- path?: Path2D | undefined;
62
- type: "square";
63
- });
64
24
  export declare const resizeRect: <T extends rectish>(cursorPosition: Point, originalShape: ShapeEntity<T>, selectionMode: SelectionModeResize, settings: UtilsSettings, keepRatio?: boolean, resizeFromCenter?: boolean) => ShapeEntity<T>;
25
+ export declare const resizeRectInGroup: (shape: ShapeEntity<rectish>, group: SelectionType & {
26
+ type: "group";
27
+ }, groupCtx: GroupResizeContext) => ShapeEntity<rectish>;
65
28
  export {};
@@ -1,7 +1,8 @@
1
1
  import type { UtilsSettings } from './../../../canvas/constants/app';
2
2
  import type { SelectionModeResize } from './../../../common/types/Mode';
3
- import type { DrawableShape, Point, Rect, ShapeEntity, Text } from './../../../common/types/Shapes';
3
+ import type { DrawableShape, Point, Rect, SelectionType, ShapeEntity, Text } from './../../../common/types/Shapes';
4
4
  import type { ToolsSettingsType } from './../../../common/types/tools';
5
+ import { type GroupResizeContext } from './group';
5
6
  export declare const getComputedText: (text: DrawableShape<"text">, settings: UtilsSettings) => {
6
7
  borders: Rect;
7
8
  outerBorders: Rect;
@@ -19,6 +20,8 @@ export declare const createText: (ctx: CanvasRenderingContext2D, shape: {
19
20
  }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"text">;
20
21
  export declare const drawText: (ctx: CanvasRenderingContext2D, text: DrawableShape<"text">) => void;
21
22
  export declare const getTextBorder: (text: Text, settings: Pick<UtilsSettings, "selectionPadding">) => Rect;
22
- export declare const translateText: (cursorPosition: Point, originalShape: ShapeEntity<"text">, originalCursorPosition: Point, settings: UtilsSettings, singleAxis: boolean) => ShapeEntity<"text">;
23
23
  export declare const resizeText: (ctx: CanvasRenderingContext2D, cursorPosition: Point, originalShape: ShapeEntity<"text">, selectionMode: SelectionModeResize, settings: UtilsSettings, resizeFromCenter: boolean) => ShapeEntity<"text">;
24
+ export declare const resizeTextInGroup: (canvasCtx: CanvasRenderingContext2D, shape: ShapeEntity<"text">, group: SelectionType & {
25
+ type: "group";
26
+ }, groupCtx: GroupResizeContext) => ShapeEntity<"text">;
24
27
  export declare const resizeTextShapeWithNewContent: (ctx: CanvasRenderingContext2D, shape: ShapeEntity<"text">, newValue: string[], settings: UtilsSettings) => ShapeEntity<"text">;
@@ -75,8 +75,12 @@ export type DrawableShape<T extends ShapeType = ShapeType> = {
75
75
  type: 'line';
76
76
  } : T extends 'picture' ? Picture & {
77
77
  img: HTMLImageElement;
78
+ flipX?: boolean;
79
+ flipY?: boolean;
78
80
  type: 'picture';
79
81
  } : T extends 'text' ? Text & {
82
+ flipX?: boolean;
83
+ flipY?: boolean;
80
84
  type: 'text';
81
85
  } : T extends 'rect' ? Rect & {
82
86
  type: 'rect';
@@ -1,4 +1,4 @@
1
- export declare const omit: <T extends Record<string, unknown>>(keys: string[], obj: T) => T;
1
+ export declare const omit: <T extends Record<string, unknown>>(keys: (string | [string, unknown[]])[], obj: T) => T;
2
2
  export declare const set: <T extends Record<string, any> | unknown[]>(path: string | number | (string | number)[], value: unknown, obj: T) => T;
3
3
  export declare const mergeWith: (customMergeFn: (objValue: unknown, srcValue: unknown, key: string) => unknown, target: unknown, source: unknown) => unknown;
4
4
  export declare const isEqual: (a: unknown, b: unknown) => boolean;