@yorab/react-paint 0.15.0 → 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.
@@ -11,6 +11,7 @@ type DrawerType = {
11
11
  settings: UtilsSettings;
12
12
  isEditMode: boolean;
13
13
  shapes: ShapeEntity[];
14
+ duplicateShapes: (shapesToDuplicate: ShapeEntity[]) => void;
14
15
  saveShapes: () => void;
15
16
  addShapes: (newShape: ShapeEntity[]) => void;
16
17
  updateSingleShape: (updatedShape: ShapeEntity[], withSave?: boolean) => void;
@@ -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[];
@@ -14,6 +14,7 @@ type UseCanvasType = {
14
14
  setActiveTool: React.Dispatch<React.SetStateAction<ToolsType>>;
15
15
  refreshHoveredShape: (e: MouseEvent | TouchEvent, ctx: CanvasRenderingContext2D, cursorPosition: Point, isInsideMask: boolean) => void;
16
16
  refreshSelectedShapes: (ctx: CanvasRenderingContext2D, cursorPosition: Point, settings: UtilsSettings) => void;
17
+ duplicateShapes: (shapesToDuplicate: ShapeEntity[]) => void;
17
18
  canvasOffsetStartData: {
18
19
  start: Point;
19
20
  originalOffset: Point;
@@ -38,7 +39,7 @@ type UseCanvasType = {
38
39
  settings: UtilsSettings;
39
40
  isSpacePressed: boolean;
40
41
  };
41
- declare const useDrawableCanvas: ({ addShapes, drawCanvasRef, setActiveTool, refreshHoveredShape, shapes, selectionMode, activeTool, isInsideComponent, setCanvasOffset, selectedShape, canvasOffsetStartData, refreshSelectedShapes, setSelectedShape, setSelectionFrame, setCanvasOffsetStartData, updateSingleShape, saveShapes, setSelectionMode, setCanvasMoveAcceleration, settings, isShiftPressed, isAltPressed, withFrameSelection, isSpacePressed }: UseCanvasType) => {
42
+ declare const useDrawableCanvas: ({ addShapes, drawCanvasRef, setActiveTool, refreshHoveredShape, shapes, selectionMode, activeTool, isInsideComponent, setCanvasOffset, selectedShape, canvasOffsetStartData, refreshSelectedShapes, setSelectedShape, setSelectionFrame, setCanvasOffsetStartData, updateSingleShape, duplicateShapes, saveShapes, setSelectionMode, setCanvasMoveAcceleration, settings, isShiftPressed, isAltPressed, withFrameSelection, isSpacePressed }: UseCanvasType) => {
42
43
  hoverMode: HoverModeData;
43
44
  };
44
45
  export default useDrawableCanvas;
@@ -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;
@@ -493,6 +501,7 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
493
501
  path?: Path2D | undefined;
494
502
  type: "group";
495
503
  }) | undefined;
504
+ saveShapes: () => void;
496
505
  removeShape: (shapes: ShapeEntity[]) => void;
497
506
  updateShape: (updatedShapes: ShapeEntity[], withSave?: boolean) => void;
498
507
  backwardShape: () => void;
@@ -570,6 +579,8 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
570
579
  src: string;
571
580
  } & {
572
581
  img: HTMLImageElement;
582
+ flipX?: boolean;
583
+ flipY?: boolean;
573
584
  type: "picture";
574
585
  } & {
575
586
  img: HTMLImageElement;
@@ -593,6 +604,8 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
593
604
  value: string[];
594
605
  fontSize: number;
595
606
  } & {
607
+ flipX?: boolean;
608
+ flipY?: boolean;
596
609
  type: "text";
597
610
  } & {
598
611
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
@@ -800,6 +813,8 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
800
813
  src: string;
801
814
  } & {
802
815
  img: HTMLImageElement;
816
+ flipX?: boolean;
817
+ flipY?: boolean;
803
818
  type: "picture";
804
819
  } & {
805
820
  img: HTMLImageElement;
@@ -823,6 +838,8 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
823
838
  value: string[];
824
839
  fontSize: number;
825
840
  } & {
841
+ flipX?: boolean;
842
+ flipY?: boolean;
826
843
  type: "text";
827
844
  } & {
828
845
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
@@ -1034,6 +1051,8 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
1034
1051
  src: string;
1035
1052
  } & {
1036
1053
  img: HTMLImageElement;
1054
+ flipX?: boolean;
1055
+ flipY?: boolean;
1037
1056
  type: "picture";
1038
1057
  } & {
1039
1058
  img: HTMLImageElement;
@@ -1057,6 +1076,8 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
1057
1076
  value: string[];
1058
1077
  fontSize: number;
1059
1078
  } & {
1079
+ flipX?: boolean;
1080
+ flipY?: boolean;
1060
1081
  type: "text";
1061
1082
  } & {
1062
1083
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
@@ -1265,6 +1286,8 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
1265
1286
  src: string;
1266
1287
  } & {
1267
1288
  img: HTMLImageElement;
1289
+ flipX?: boolean;
1290
+ flipY?: boolean;
1268
1291
  type: "picture";
1269
1292
  } & {
1270
1293
  img: HTMLImageElement;
@@ -1288,6 +1311,8 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
1288
1311
  value: string[];
1289
1312
  fontSize: number;
1290
1313
  } & {
1314
+ flipX?: boolean;
1315
+ flipY?: boolean;
1291
1316
  type: "text";
1292
1317
  } & {
1293
1318
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
@@ -1494,6 +1519,8 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
1494
1519
  src: string;
1495
1520
  } & {
1496
1521
  img: HTMLImageElement;
1522
+ flipX?: boolean;
1523
+ flipY?: boolean;
1497
1524
  type: "picture";
1498
1525
  } & {
1499
1526
  img: HTMLImageElement;
@@ -1517,6 +1544,8 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
1517
1544
  value: string[];
1518
1545
  fontSize: number;
1519
1546
  } & {
1547
+ flipX?: boolean;
1548
+ flipY?: boolean;
1520
1549
  type: "text";
1521
1550
  } & {
1522
1551
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
@@ -1723,6 +1752,8 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
1723
1752
  src: string;
1724
1753
  } & {
1725
1754
  img: HTMLImageElement;
1755
+ flipX?: boolean;
1756
+ flipY?: boolean;
1726
1757
  type: "picture";
1727
1758
  } & {
1728
1759
  img: HTMLImageElement;
@@ -1746,6 +1777,8 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
1746
1777
  value: string[];
1747
1778
  fontSize: number;
1748
1779
  } & {
1780
+ flipX?: boolean;
1781
+ flipY?: boolean;
1749
1782
  type: "text";
1750
1783
  } & {
1751
1784
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
@@ -1922,6 +1955,7 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
1922
1955
  refreshHoveredShape: (e: MouseEvent | TouchEvent, ctx: CanvasRenderingContext2D, cursorPosition: Point, isInsideMask: boolean) => void;
1923
1956
  removeShape: (shapes: ShapeEntity[]) => void;
1924
1957
  updateShape: (updatedShapes: ShapeEntity[], withSave?: boolean) => void;
1958
+ duplicateShapes: (shapesToDuplicate: ShapeEntity[]) => void;
1925
1959
  backwardShape: () => void;
1926
1960
  forwardShape: () => void;
1927
1961
  saveShapes: () => void;
@@ -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;
@@ -703,6 +715,7 @@ declare const useShapes: (settings: UtilsSettings, width: number, height: number
703
715
  } | undefined>>;
704
716
  refreshSelectedShapes: (ctx: CanvasRenderingContext2D, cursorPosition: Point) => void;
705
717
  addShapes: (newShapes: ShapeEntity[]) => void;
718
+ duplicateShapes: (shapesToDuplicate: ShapeEntity[]) => void;
706
719
  addPictureShape: (fileOrUrl: File | string, maxWidth?: number, maxHeight?: number) => Promise<ShapeEntity<"picture">>;
707
720
  moveShapes: (startPositionShapeId: string, endPositionShapeId: string) => void;
708
721
  saveShapes: () => void;
@@ -745,6 +758,8 @@ declare const useShapes: (settings: UtilsSettings, width: number, height: number
745
758
  src: string;
746
759
  } & {
747
760
  img: HTMLImageElement;
761
+ flipX?: boolean;
762
+ flipY?: boolean;
748
763
  type: "picture";
749
764
  } & {
750
765
  img: HTMLImageElement;
@@ -768,6 +783,8 @@ declare const useShapes: (settings: UtilsSettings, width: number, height: number
768
783
  value: string[];
769
784
  fontSize: number;
770
785
  } & {
786
+ flipX?: boolean;
787
+ flipY?: boolean;
771
788
  type: "text";
772
789
  } & {
773
790
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
@@ -974,6 +991,8 @@ declare const useShapes: (settings: UtilsSettings, width: number, height: number
974
991
  src: string;
975
992
  } & {
976
993
  img: HTMLImageElement;
994
+ flipX?: boolean;
995
+ flipY?: boolean;
977
996
  type: "picture";
978
997
  } & {
979
998
  img: HTMLImageElement;
@@ -997,6 +1016,8 @@ declare const useShapes: (settings: UtilsSettings, width: number, height: number
997
1016
  value: string[];
998
1017
  fontSize: number;
999
1018
  } & {
1019
+ flipX?: boolean;
1020
+ flipY?: boolean;
1000
1021
  type: "text";
1001
1022
  } & {
1002
1023
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
@@ -1203,6 +1224,8 @@ declare const useShapes: (settings: UtilsSettings, width: number, height: number
1203
1224
  src: string;
1204
1225
  } & {
1205
1226
  img: HTMLImageElement;
1227
+ flipX?: boolean;
1228
+ flipY?: boolean;
1206
1229
  type: "picture";
1207
1230
  } & {
1208
1231
  img: HTMLImageElement;
@@ -1226,6 +1249,8 @@ declare const useShapes: (settings: UtilsSettings, width: number, height: number
1226
1249
  value: string[];
1227
1250
  fontSize: number;
1228
1251
  } & {
1252
+ flipX?: boolean;
1253
+ flipY?: boolean;
1229
1254
  type: "text";
1230
1255
  } & {
1231
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 {};