@yorab/react-paint 0.13.1 → 0.15.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.
Files changed (63) hide show
  1. package/README.md +46 -283
  2. package/dist/canvas/components/Canvas.d.ts +15 -7
  3. package/dist/canvas/components/EditTextBox.d.ts +2 -2
  4. package/dist/canvas/constants/app.d.ts +2 -0
  5. package/dist/canvas/constants/keyboard.d.ts +24 -0
  6. package/dist/canvas/constants/shapes.d.ts +1 -1
  7. package/dist/canvas/hooks/useComponent.d.ts +3 -1
  8. package/dist/canvas/hooks/useDebounce.d.ts +2 -0
  9. package/dist/canvas/hooks/useDrawableCanvas.d.ts +12 -7
  10. package/dist/canvas/hooks/useKeyboard.d.ts +15 -8
  11. package/dist/canvas/hooks/useReactPaint.d.ts +1874 -25
  12. package/dist/canvas/hooks/useShapes.d.ts +1393 -13
  13. package/dist/canvas/hooks/useZoom.d.ts +1 -0
  14. package/dist/canvas/index.d.ts +3 -3
  15. package/dist/canvas/utils/canvas.d.ts +2 -0
  16. package/dist/canvas/utils/data.d.ts +2 -2
  17. package/dist/canvas/utils/file.d.ts +233 -4
  18. package/dist/canvas/utils/intersect.d.ts +6 -6
  19. package/dist/canvas/utils/selection/groupSelection.d.ts +3 -0
  20. package/dist/canvas/utils/selection/lineSelection.d.ts +9 -3
  21. package/dist/canvas/utils/selection/rectSelection.d.ts +10 -5
  22. package/dist/canvas/utils/selection.d.ts +11 -4
  23. package/dist/canvas/utils/shapes/brush.d.ts +14 -11
  24. package/dist/canvas/utils/shapes/circle.d.ts +13 -9
  25. package/dist/canvas/utils/shapes/curve.d.ts +15 -10
  26. package/dist/canvas/utils/shapes/ellipse.d.ts +13 -9
  27. package/dist/canvas/utils/shapes/index.d.ts +30 -16
  28. package/dist/canvas/utils/shapes/line.d.ts +13 -8
  29. package/dist/canvas/utils/shapes/path.d.ts +19 -3
  30. package/dist/canvas/utils/shapes/picture.d.ts +13 -9
  31. package/dist/canvas/utils/shapes/polygon.d.ts +15 -9
  32. package/dist/canvas/utils/shapes/rectangle.d.ts +56 -11
  33. package/dist/canvas/utils/shapes/text.d.ts +13 -8
  34. package/dist/canvas/utils/shapes/triangle.d.ts +4 -3
  35. package/dist/canvas/utils/transform.d.ts +4 -4
  36. package/dist/canvas/utils/trigo.d.ts +1 -1
  37. package/dist/common/types/Mode.d.ts +5 -4
  38. package/dist/common/types/Shapes.d.ts +70 -28
  39. package/dist/common/types/tools.d.ts +5 -1
  40. package/dist/common/types/utils.d.ts +1 -1
  41. package/dist/editor/components/common/Button.d.ts +6 -6
  42. package/dist/editor/components/common/FileInput.d.ts +13 -0
  43. package/dist/editor/components/common/Panel.d.ts +1 -1
  44. package/dist/editor/components/settings/ClosedPointsField.d.ts +1 -1
  45. package/dist/editor/components/settings/ColorField.d.ts +1 -1
  46. package/dist/editor/components/settings/DeleteButton.d.ts +3 -3
  47. package/dist/editor/components/settings/FontFamilyField.d.ts +1 -1
  48. package/dist/editor/components/settings/Layouts.d.ts +7 -7
  49. package/dist/editor/components/settings/LineArrowField.d.ts +1 -1
  50. package/dist/editor/components/settings/LineTypeField.d.ts +1 -1
  51. package/dist/editor/components/settings/RangeField.d.ts +1 -1
  52. package/dist/editor/components/settings/SettingsBar.d.ts +4 -4
  53. package/dist/editor/components/settings/ToggleField.d.ts +2 -2
  54. package/dist/editor/components/settings/ZoomButton.d.ts +2 -2
  55. package/dist/editor/constants/icons.d.ts +1 -0
  56. package/dist/editor/constants/tools.d.ts +2 -2
  57. package/dist/editor/hooks/useDrag.d.ts +1 -1
  58. package/dist/editor/index.d.ts +11 -11
  59. package/dist/editor/utils/style.d.ts +1 -1
  60. package/dist/react-paint.css +1 -1
  61. package/dist/react-paint.js +1361 -1188
  62. package/dist/react-paint.umd.cjs +1 -1
  63. package/package.json +19 -15
@@ -13,6 +13,7 @@ declare const useZoom: ({ canvasSize, size, zoomEnabled, canvasElt }: UseZoomPro
13
13
  }>>;
14
14
  setCanvasOffset: (newOffset: Point) => void;
15
15
  setCanvasZoom: (action: "unzoom" | "zoom" | "default") => void;
16
+ resetZoom: () => void;
16
17
  canvasTransformation: {
17
18
  offset: Point;
18
19
  zoom: number;
@@ -6,9 +6,9 @@ type AppProps = {
6
6
  className?: string;
7
7
  style?: CSSProperties;
8
8
  options?: {
9
- canvasBackgroundColor?: string;
10
- canvasSelectionColor?: string;
11
- canvasSelectionWidth?: number;
9
+ canvasBackgroundColor?: string | undefined;
10
+ canvasSelectionColor?: string | undefined;
11
+ canvasSelectionWidth?: number | undefined;
12
12
  };
13
13
  };
14
14
  declare const App: ({ options, className, style, canvasProps }: AppProps) => import("react/jsx-runtime").JSX.Element;
@@ -8,5 +8,7 @@ export declare const updateCanvasContext: (ctx: CanvasRenderingContext2D, style?
8
8
  lineWidth?: number;
9
9
  lineDash?: number;
10
10
  lineCap?: CanvasLineCap;
11
+ shadowColor?: string;
12
+ shadowBlur?: number;
11
13
  }) => void;
12
14
  export declare const transformCanvas: (ctx: CanvasRenderingContext2D, settings: UtilsSettings, rotation?: number, translation?: Point) => void;
@@ -1,5 +1,5 @@
1
1
  import type { UtilsSettings } from './../../canvas/constants/app';
2
2
  import type { DrawableShape, ShapeEntity, StateData } from './../../common/types/Shapes';
3
- export declare const cleanShapesBeforeExport: (shapes: DrawableShape[]) => DrawableShape[];
4
- export declare const buildDataToExport: (shapes: DrawableShape[], width: number, height: number) => StateData;
3
+ export declare const cleanShapesBeforeExport: (shapes: ShapeEntity[]) => DrawableShape[];
4
+ export declare const buildDataToExport: (shapes: ShapeEntity[], width: number, height: number) => StateData;
5
5
  export declare const addDefaultAndTempShapeProps: (shape: DrawableShape, settings: UtilsSettings) => ShapeEntity;
@@ -1,5 +1,5 @@
1
1
  import type { UtilsSettings } from './../../canvas/constants/app';
2
- import type { DrawableShape, ExportedDrawableShape, ShapeEntity } from './../../common/types/Shapes';
2
+ import type { DrawableShape, ExportedDrawableShape, Point, ShapeEntity } from './../../common/types/Shapes';
3
3
  export declare const addSizeAndConvertSvgToObjectUrl: (svgFileContent: string) => string;
4
4
  export declare const isSvg: (fileOrUrl: File | string) => boolean;
5
5
  export declare const fetchAndStringify: (url: string) => Promise<string>;
@@ -7,10 +7,239 @@ export declare const downloadFile: (content: string, fileName: string) => void;
7
7
  export declare const getBase64Image: (img: HTMLImageElement) => string;
8
8
  export declare const getStringifiedImage: (shape: DrawableShape<"picture">) => string;
9
9
  export declare const getCanvasImage: ({ shapes, settings, view }: {
10
- shapes: DrawableShape[];
10
+ shapes: ShapeEntity[];
11
11
  settings: UtilsSettings;
12
12
  view: "fitToShapes" | "defaultView" | "currentZoom";
13
13
  }) => string;
14
- export declare const encodeShapesInString: (shapes: DrawableShape[], width: number, height: number) => string;
14
+ export declare const encodeShapesInString: (shapes: ShapeEntity[], width: number, height: number) => string;
15
15
  export declare const decodeJson: (file: File) => Promise<unknown>;
16
- export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[], settings: UtilsSettings) => Promise<ShapeEntity[]>;
16
+ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[], settings: UtilsSettings) => Promise<(({
17
+ id: string;
18
+ computed: {
19
+ borders: import("./../../common/types/Shapes").Rect;
20
+ outerBorders: import("./../../common/types/Shapes").Rect;
21
+ center: Point;
22
+ boundingBox: import("./../../common/types/Shapes").Rect;
23
+ };
24
+ } & {
25
+ rotation?: number;
26
+ toolId?: string;
27
+ visible?: boolean;
28
+ locked?: boolean;
29
+ style?: import("./../../common/types/Shapes").StyleShape | undefined;
30
+ } & import("./../../common/types/Shapes").Line & {
31
+ type: "line";
32
+ } & {
33
+ selection?: import("./../../common/types/Shapes").SelectionLinesType | undefined;
34
+ path?: Path2D | undefined;
35
+ arrows?: import("./../../common/types/Shapes").TriangleEntity[];
36
+ type: "line";
37
+ }) | ({
38
+ id: string;
39
+ computed: {
40
+ borders: import("./../../common/types/Shapes").Rect;
41
+ outerBorders: import("./../../common/types/Shapes").Rect;
42
+ center: Point;
43
+ boundingBox: import("./../../common/types/Shapes").Rect;
44
+ };
45
+ } & {
46
+ rotation?: number;
47
+ toolId?: string;
48
+ visible?: boolean;
49
+ locked?: boolean;
50
+ style?: import("./../../common/types/Shapes").StyleShape | undefined;
51
+ } & import("./../../common/types/Shapes").Rect & {
52
+ src: string;
53
+ } & {
54
+ img: HTMLImageElement;
55
+ type: "picture";
56
+ } & {
57
+ img: HTMLImageElement;
58
+ selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
59
+ type: "picture";
60
+ }) | ({
61
+ id: string;
62
+ computed: {
63
+ borders: import("./../../common/types/Shapes").Rect;
64
+ outerBorders: import("./../../common/types/Shapes").Rect;
65
+ center: Point;
66
+ boundingBox: import("./../../common/types/Shapes").Rect;
67
+ };
68
+ } & {
69
+ rotation?: number;
70
+ toolId?: string;
71
+ visible?: boolean;
72
+ locked?: boolean;
73
+ style?: import("./../../common/types/Shapes").StyleShape | undefined;
74
+ } & import("./../../common/types/Shapes").Rect & {
75
+ value: string[];
76
+ fontSize: number;
77
+ } & {
78
+ type: "text";
79
+ } & {
80
+ selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
81
+ type: "text";
82
+ }) | ({
83
+ id: string;
84
+ computed: {
85
+ borders: import("./../../common/types/Shapes").Rect;
86
+ outerBorders: import("./../../common/types/Shapes").Rect;
87
+ center: Point;
88
+ boundingBox: import("./../../common/types/Shapes").Rect;
89
+ };
90
+ } & {
91
+ rotation?: number;
92
+ toolId?: string;
93
+ visible?: boolean;
94
+ locked?: boolean;
95
+ style?: import("./../../common/types/Shapes").StyleShape | undefined;
96
+ } & import("./../../common/types/Shapes").Rect & {
97
+ type: "rect";
98
+ } & {
99
+ selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
100
+ path?: Path2D | undefined;
101
+ type: "rect";
102
+ }) | ({
103
+ id: string;
104
+ computed: {
105
+ borders: import("./../../common/types/Shapes").Rect;
106
+ outerBorders: import("./../../common/types/Shapes").Rect;
107
+ center: Point;
108
+ boundingBox: import("./../../common/types/Shapes").Rect;
109
+ };
110
+ } & {
111
+ rotation?: number;
112
+ toolId?: string;
113
+ visible?: boolean;
114
+ locked?: boolean;
115
+ style?: import("./../../common/types/Shapes").StyleShape | undefined;
116
+ } & import("./../../common/types/Shapes").Rect & {
117
+ type: "square";
118
+ } & {
119
+ selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
120
+ path?: Path2D | undefined;
121
+ type: "square";
122
+ }) | ({
123
+ id: string;
124
+ computed: {
125
+ borders: import("./../../common/types/Shapes").Rect;
126
+ outerBorders: import("./../../common/types/Shapes").Rect;
127
+ center: Point;
128
+ boundingBox: import("./../../common/types/Shapes").Rect;
129
+ };
130
+ } & {
131
+ rotation?: number;
132
+ toolId?: string;
133
+ visible?: boolean;
134
+ locked?: boolean;
135
+ style?: import("./../../common/types/Shapes").StyleShape | undefined;
136
+ } & import("./../../common/types/Shapes").Circle & {
137
+ type: "circle";
138
+ } & {
139
+ selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
140
+ path?: Path2D | undefined;
141
+ type: "circle";
142
+ }) | ({
143
+ id: string;
144
+ computed: {
145
+ borders: import("./../../common/types/Shapes").Rect;
146
+ outerBorders: import("./../../common/types/Shapes").Rect;
147
+ center: Point;
148
+ boundingBox: import("./../../common/types/Shapes").Rect;
149
+ };
150
+ } & {
151
+ rotation?: number;
152
+ toolId?: string;
153
+ visible?: boolean;
154
+ locked?: boolean;
155
+ style?: import("./../../common/types/Shapes").StyleShape | undefined;
156
+ } & import("./../../common/types/Shapes").Ellipse & {
157
+ type: "ellipse";
158
+ } & {
159
+ selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
160
+ path?: Path2D | undefined;
161
+ type: "ellipse";
162
+ }) | ({
163
+ id: string;
164
+ computed: {
165
+ borders: import("./../../common/types/Shapes").Rect;
166
+ outerBorders: import("./../../common/types/Shapes").Rect;
167
+ center: Point;
168
+ boundingBox: import("./../../common/types/Shapes").Rect;
169
+ };
170
+ } & {
171
+ rotation?: number;
172
+ toolId?: string;
173
+ visible?: boolean;
174
+ locked?: boolean;
175
+ style?: import("./../../common/types/Shapes").StyleShape | undefined;
176
+ } & import("./../../common/types/Shapes").Polygon & {
177
+ type: "polygon";
178
+ } & {
179
+ selection?: import("./../../common/types/Shapes").SelectionLinesType | undefined;
180
+ path?: Path2D | undefined;
181
+ type: "polygon";
182
+ }) | ({
183
+ id: string;
184
+ computed: {
185
+ borders: import("./../../common/types/Shapes").Rect;
186
+ outerBorders: import("./../../common/types/Shapes").Rect;
187
+ center: Point;
188
+ boundingBox: import("./../../common/types/Shapes").Rect;
189
+ };
190
+ } & {
191
+ rotation?: number;
192
+ toolId?: string;
193
+ visible?: boolean;
194
+ locked?: boolean;
195
+ style?: import("./../../common/types/Shapes").StyleShape | undefined;
196
+ } & import("./../../common/types/Shapes").Curve & {
197
+ type: "curve";
198
+ } & {
199
+ selection?: import("./../../common/types/Shapes").SelectionLinesType | undefined;
200
+ path?: Path2D | undefined;
201
+ type: "curve";
202
+ }) | ({
203
+ id: string;
204
+ computed: {
205
+ borders: import("./../../common/types/Shapes").Rect;
206
+ outerBorders: import("./../../common/types/Shapes").Rect;
207
+ center: Point;
208
+ boundingBox: import("./../../common/types/Shapes").Rect;
209
+ };
210
+ } & {
211
+ rotation?: number;
212
+ toolId?: string;
213
+ visible?: boolean;
214
+ locked?: boolean;
215
+ style?: import("./../../common/types/Shapes").StyleShape | undefined;
216
+ } & import("./../../common/types/Shapes").Brush & {
217
+ type: "brush";
218
+ scaleX?: number;
219
+ scaleY?: number;
220
+ } & {
221
+ selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
222
+ path?: Path2D | undefined;
223
+ type: "brush";
224
+ }) | ({
225
+ id: string;
226
+ computed: {
227
+ borders: import("./../../common/types/Shapes").Rect;
228
+ outerBorders: import("./../../common/types/Shapes").Rect;
229
+ center: Point;
230
+ boundingBox: import("./../../common/types/Shapes").Rect;
231
+ };
232
+ } & {
233
+ rotation?: number;
234
+ toolId?: string;
235
+ visible?: boolean;
236
+ locked?: boolean;
237
+ style?: import("./../../common/types/Shapes").StyleShape | undefined;
238
+ } & import("./../../common/types/Shapes").Rect & {
239
+ shapes: ShapeEntity[];
240
+ type: "group";
241
+ } & {
242
+ selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
243
+ path?: Path2D | undefined;
244
+ type: "group";
245
+ }))[]>;
@@ -1,7 +1,7 @@
1
1
  import type { UtilsSettings } from './../../canvas/constants/app';
2
2
  import type { CanvasSize } from './../../common/types/Canvas';
3
3
  import type { HoverModeData } from './../../common/types/Mode';
4
- import type { DrawableShape, Point, Rect } from './../../common/types/Shapes';
4
+ import type { Point, Rect, SelectionType, ShapeEntity } from './../../common/types/Shapes';
5
5
  export declare const getCursorPosition: (e: MouseEvent | TouchEvent) => {
6
6
  clientX: number;
7
7
  clientY: number;
@@ -11,13 +11,13 @@ export declare const getCursorPositionInTransformedCanvas: (e: MouseEvent | Touc
11
11
  export declare const isTouchGesture: (e: MouseEvent | TouchEvent) => e is TouchEvent;
12
12
  export declare const getPointPositionAfterCanvasTransformation: (point: Point, shapeRotation: number, [originX, originY]: Point) => Point;
13
13
  export declare const getPointPositionBeforeCanvasTransformation: (point: Point, shapeRotation: number, [originX, originY]: Point) => Point;
14
- export declare const checkSelectionIntersection: (ctx: CanvasRenderingContext2D, shape: DrawableShape, position: Point, settings: UtilsSettings, checkAnchors?: boolean, radius?: number) => false | HoverModeData;
15
- export declare const checkPolygonLinesSelectionIntersection: (ctx: CanvasRenderingContext2D, shape: DrawableShape<"polygon" | "curve">, position: Point, settings: UtilsSettings, radius?: number) => false | {
14
+ export declare const checkSelectionIntersection: (ctx: CanvasRenderingContext2D, shape: SelectionType, position: Point, settings: UtilsSettings, checkAnchors?: boolean, radius?: number) => false | HoverModeData;
15
+ export declare const checkPolygonLinesSelectionIntersection: (ctx: CanvasRenderingContext2D, shape: ShapeEntity<"polygon" | "curve">, position: Point, settings: UtilsSettings, radius?: number) => false | {
16
16
  lineIndex: number;
17
17
  };
18
- export declare const checkCurveLinesSelectionIntersection: (ctx: CanvasRenderingContext2D, shape: DrawableShape<"curve">, position: Point, settings: UtilsSettings, radius?: number) => false | {
18
+ export declare const checkCurveLinesSelectionIntersection: (ctx: CanvasRenderingContext2D, shape: ShapeEntity<"curve">, position: Point, settings: UtilsSettings, radius?: number) => false | {
19
19
  lineIndex: number;
20
20
  };
21
- export declare const checkPositionIntersection: (ctx: CanvasRenderingContext2D, shape: DrawableShape, position: Point, settings: UtilsSettings) => false | HoverModeData;
21
+ export declare const checkPositionIntersection: (ctx: CanvasRenderingContext2D, shape: SelectionType, position: Point, settings: UtilsSettings) => false | HoverModeData;
22
22
  export declare function getRectIntersection(rect1: Rect, rect2: Rect): Rect | undefined;
23
- export declare const checkSelectionFrameCollision: (ctx: CanvasRenderingContext2D, shape: DrawableShape, selectionFrame: [Point, Point], settings: UtilsSettings) => boolean;
23
+ export declare const checkSelectionFrameCollision: (ctx: CanvasRenderingContext2D, shape: ShapeEntity, selectionFrame: [Point, Point], settings: UtilsSettings) => boolean;
@@ -0,0 +1,3 @@
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;
@@ -1,13 +1,19 @@
1
1
  import type { UtilsSettings } from './../../../canvas/constants/app';
2
- import type { DrawableShape, Point, SelectionLinesType } from './../../../common/types/Shapes';
2
+ import type { HoverModeData } from './../../../common/types/Mode';
3
+ import type { DrawableShape, Point, Rect, SelectionLinesType, ShapeEntity } from './../../../common/types/Shapes';
3
4
  export declare const createLineSelectionPath: (path: Path2D | undefined, shape: DrawableShape<"line" | "polygon" | "curve"> & {
4
5
  points: readonly Point[];
6
+ }, computed: {
7
+ borders: Rect;
8
+ outerBorders: Rect;
9
+ center: Point;
5
10
  }, settings: UtilsSettings) => SelectionLinesType;
6
- export declare const drawLineSelection: ({ ctx, shape, withAnchors, selectionWidth, selectionColor, settings }: {
11
+ export declare const drawLineSelection: ({ ctx, shape, withAnchors, selectionWidth, selectionColor, hoverMode, settings }: {
7
12
  ctx: CanvasRenderingContext2D;
8
- shape: DrawableShape<"line"> | DrawableShape<"polygon"> | DrawableShape<"curve">;
13
+ shape: ShapeEntity<"line"> | ShapeEntity<"polygon"> | ShapeEntity<"curve">;
9
14
  withAnchors: boolean;
10
15
  selectionWidth: number;
11
16
  selectionColor: string;
17
+ hoverMode: HoverModeData;
12
18
  settings: UtilsSettings;
13
19
  }) => void;
@@ -1,11 +1,16 @@
1
1
  import type { UtilsSettings } from './../../../canvas/constants/app';
2
2
  import type { SelectionModeResize } from './../../../common/types/Mode';
3
- import type { DrawableShape, Point, SelectionDefaultType } from './../../../common/types/Shapes';
4
- export declare const createRecSelectionPath: (path: Path2D | undefined, rect: DrawableShape, settings: UtilsSettings) => SelectionDefaultType;
5
- export declare const drawSelectionRect: (ctx: CanvasRenderingContext2D, shape: DrawableShape & {
6
- selection?: SelectionDefaultType;
3
+ import type { Point, Rect, SelectionDefaultType, SelectionType, ShapeEntity } from './../../../common/types/Shapes';
4
+ export declare const createRecSelectionPath: (path: Path2D | undefined, computed: {
5
+ borders: Rect;
6
+ outerBorders: Rect;
7
+ center: Point;
8
+ }, settings: UtilsSettings, isGroup?: boolean) => SelectionDefaultType;
9
+ export declare const drawBoundingBox: (ctx: CanvasRenderingContext2D, shape: SelectionType, selectionWidth: number, settings: UtilsSettings) => void;
10
+ export declare const drawSelectionRect: (ctx: CanvasRenderingContext2D, shape: ShapeEntity & {
11
+ selection?: SelectionDefaultType | undefined;
7
12
  }, selectionColor: string, selectionWidth: number, settings: UtilsSettings, withAnchors: boolean) => void;
8
- export declare const resizeRectSelection: (cursorPosition: Point, originalShape: DrawableShape, selectionMode: SelectionModeResize, settings: UtilsSettings, keepRatio?: boolean, resizeFromCenter?: boolean) => {
13
+ export declare const resizeRectSelection: (cursorPosition: Point, originalShape: ShapeEntity, selectionMode: SelectionModeResize, settings: UtilsSettings, keepRatio?: boolean, resizeFromCenter?: boolean) => {
9
14
  borderX: number;
10
15
  borderHeight: number;
11
16
  borderY: number;
@@ -1,8 +1,15 @@
1
1
  import type { UtilsSettings } from './../../canvas/constants/app';
2
2
  import type { HoverModeData, SelectionModeData } from './../../common/types/Mode';
3
- import type { Point, ShapeEntity } from './../../common/types/Shapes';
4
- export declare const getNewSelectionData: (hoverMode: HoverModeData, selectedShape: ShapeEntity, cursorPosition: Point, settings: UtilsSettings) => SelectionModeData<Point | number> | undefined;
5
- export declare const selectShape: (ctx: CanvasRenderingContext2D, shapes: ShapeEntity[], cursorPosition: Point, settings: UtilsSettings, selectedShape: ShapeEntity | undefined, isTouchGesture: boolean, withFrameSelection: boolean) => {
3
+ import type { Point, SelectionType, ShapeEntity } from './../../common/types/Shapes';
4
+ import type { CustomTool } from './../../common/types/tools';
5
+ export declare const getNewSelectionData: (hoverMode: HoverModeData, selectedShape: SelectionType, cursorPosition: Point) => SelectionModeData<Point | number> | undefined;
6
+ export declare const selectShape: (ctx: CanvasRenderingContext2D, shapes: ShapeEntity[], cursorPosition: Point, settings: UtilsSettings, selectedShape: SelectionType | undefined, isTouchGesture: boolean, withFrameSelection: boolean, isGroupMode: boolean) => {
6
7
  mode: SelectionModeData<Point | number>;
7
- shape: ShapeEntity | undefined;
8
+ shape: SelectionType | undefined;
8
9
  };
10
+ export declare const buildShapesGroup: (shapes: ShapeEntity[], settings: UtilsSettings) => SelectionType | undefined;
11
+ export declare const applyToSelectedShape: (applyToShape: (shape: ShapeEntity, settings: UtilsSettings) => ShapeEntity, settings: UtilsSettings) => (selection: SelectionType | undefined) => SelectionType | undefined;
12
+ export declare const getSelectedShapes: (selection: SelectionType | undefined) => ShapeEntity[];
13
+ export declare const addToSelectedShapes: (selection: SelectionType | undefined, shapes: ShapeEntity[]) => ShapeEntity[];
14
+ export declare const omitFromSelectedShapes: (selection: SelectionType | undefined, shape: ShapeEntity) => ShapeEntity[];
15
+ export declare const getSelectedShapesTools: (selection: SelectionType | undefined, availableTools: CustomTool[]) => CustomTool | undefined;
@@ -2,19 +2,22 @@ import type { UtilsSettings } from './../../../canvas/constants/app';
2
2
  import type { SelectionModeResize } from './../../../common/types/Mode';
3
3
  import type { DrawableShape, Point, Rect, ShapeEntity } from './../../../common/types/Shapes';
4
4
  import type { ToolsSettingsType } from './../../../common/types/tools';
5
- export declare const refreshBrush: <T extends DrawableShape<"brush">>(brush: T, settings: UtilsSettings) => T;
5
+ export declare const getComputedBrush: (brush: DrawableShape<"brush">, settings: UtilsSettings) => {
6
+ borders: Rect;
7
+ outerBorders: Rect;
8
+ center: Point;
9
+ boundingBox: Rect;
10
+ };
11
+ export declare const refreshBrush: <T extends DrawableShape<"brush">>(brush: T & {
12
+ id: string;
13
+ }, settings: UtilsSettings) => ShapeEntity<"brush">;
6
14
  export declare const createBrush: (shape: {
7
15
  id: string;
8
16
  type: "brush";
9
17
  settings: ToolsSettingsType<"brush">;
10
18
  }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"brush">;
11
- export declare const drawBrush: (ctx: CanvasRenderingContext2D, shape: DrawableShape<"brush">) => void;
12
- export declare const getBrushBorder: (brush: DrawableShape<"brush">, { selectionPadding }: UtilsSettings) => Rect;
13
- export declare const translateBrush: <U extends DrawableShape<"brush">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings, singleAxis: boolean) => U & {
14
- points: Point[][];
15
- };
16
- export declare const resizeBrush: (cursorPosition: Point, originalShape: DrawableShape<"brush">, selectionMode: SelectionModeResize, settings: UtilsSettings, keepRatio: boolean, resizeFromCenter: boolean) => DrawableShape<"brush">;
17
- export declare const addNewPointToShape: <T extends DrawableShape<"brush">>(shape: T, cursorPosition: Point, settings: UtilsSettings) => T & {
18
- points: Point[][];
19
- };
20
- export declare const addNewPointGroupToShape: <T extends DrawableShape<"brush">>(shape: T, cursorPosition: Point, settings: UtilsSettings) => T;
19
+ 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
+ export declare const resizeBrush: (cursorPosition: Point, originalShape: ShapeEntity<"brush">, selectionMode: SelectionModeResize, settings: UtilsSettings, keepRatio: boolean, resizeFromCenter: boolean) => ShapeEntity<"brush">;
22
+ export declare const addNewPointToShape: (shape: ShapeEntity<"brush">, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"brush">;
23
+ export declare const addNewPointGroupToShape: (shape: ShapeEntity<"brush">, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"brush">;
@@ -1,17 +1,21 @@
1
1
  import type { UtilsSettings } from './../../../canvas/constants/app';
2
2
  import type { SelectionModeResize } from './../../../common/types/Mode';
3
- import type { Circle, DrawableShape, Point, Rect, ShapeEntity } from './../../../common/types/Shapes';
3
+ import type { DrawableShape, Point, Rect, ShapeEntity } from './../../../common/types/Shapes';
4
4
  import type { ToolsSettingsType } from './../../../common/types/tools';
5
- export declare const refreshCircle: <T extends DrawableShape<"circle">>(shape: T, settings: UtilsSettings) => T;
5
+ export declare const getComputedCircle: (circle: DrawableShape<"circle">, settings: UtilsSettings) => {
6
+ borders: Rect;
7
+ outerBorders: Rect;
8
+ center: Point;
9
+ boundingBox: Rect;
10
+ };
11
+ export declare const refreshCircle: <T extends DrawableShape<"circle">>(shape: T & {
12
+ id: string;
13
+ }, settings: UtilsSettings) => ShapeEntity<"circle">;
6
14
  export declare const createCircle: (shape: {
7
15
  id: string;
8
16
  type: "circle";
9
17
  settings: ToolsSettingsType<"circle">;
10
18
  }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"circle">;
11
- export declare const drawCircle: (ctx: CanvasRenderingContext2D, circle: DrawableShape<"circle">) => void;
12
- export declare const getCircleBorder: (circle: Circle, settings: UtilsSettings) => Rect;
13
- export declare const translateCircle: <U extends DrawableShape<"circle">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings, singleAxis: boolean) => U & {
14
- x: number;
15
- y: number;
16
- };
17
- export declare const resizeCircle: (cursorPosition: Point, originalShape: DrawableShape<"circle">, selectionMode: SelectionModeResize, settings: UtilsSettings, resizeFromCenter: boolean) => DrawableShape<"circle">;
19
+ 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
+ export declare const resizeCircle: (cursorPosition: Point, originalShape: ShapeEntity<"circle">, selectionMode: SelectionModeResize, settings: UtilsSettings, resizeFromCenter: boolean) => ShapeEntity<"circle">;
@@ -1,18 +1,23 @@
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, Rect, ShapeEntity } from './../../../common/types/Shapes';
4
4
  import type { ToolsSettingsType } from './../../../common/types/tools';
5
- export declare const refreshCurve: <T extends DrawableShape<"curve">>(shape: T, settings: UtilsSettings) => T;
5
+ export declare const getComputedCurve: (curve: DrawableShape<"curve">, settings: UtilsSettings) => {
6
+ borders: Rect;
7
+ outerBorders: Rect;
8
+ center: Point;
9
+ boundingBox: Rect;
10
+ };
11
+ export declare const refreshCurve: <T extends DrawableShape<"curve">>(shape: T & {
12
+ id: string;
13
+ }, settings: UtilsSettings) => ShapeEntity<"curve">;
6
14
  export declare const createCurve: (shape: {
7
15
  id: string;
8
16
  type: "curve";
9
17
  settings: ToolsSettingsType<"curve">;
10
18
  }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"curve">;
11
- export declare const resizeCurve: (cursorPosition: Point, originalShape: DrawableShape<"curve">, selectionMode: SelectionModeResize<number>, settings: UtilsSettings) => DrawableShape<"curve">;
12
- export declare const drawCurve: (ctx: CanvasRenderingContext2D, curve: DrawableShape<"curve">) => void;
13
- export declare const getCurveBorder: (polygon: import("./../../../common/types/Shapes").Polygon, settings: UtilsSettings) => import("./../../../common/types/Shapes").Rect;
14
- export declare const translateCurve: <U extends DrawableShape<"curve">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings, singleAxis: boolean) => U & {
15
- points: [number, number][];
16
- };
17
- export declare const addCurveLine: <T extends DrawableShape<"curve">>(shape: T, lineIndex: number, cursorPosition: Point, settings: UtilsSettings) => T;
18
- export declare const addCurvePoint: <T extends DrawableShape<"curve">>(shape: T, cursorPosition: Point, settings: UtilsSettings, temporary?: boolean) => T;
19
+ export declare const resizeCurve: (cursorPosition: Point, originalShape: ShapeEntity<"curve">, selectionMode: SelectionModeResize<number>, settings: UtilsSettings) => ShapeEntity<"curve">;
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
+ export declare const addCurveLine: (shape: ShapeEntity<"curve">, lineIndex: number, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"curve">;
23
+ export declare const addCurvePoint: (shape: ShapeEntity<"curve">, cursorPosition: Point, settings: UtilsSettings, temporary?: boolean) => ShapeEntity<"curve">;
@@ -1,17 +1,21 @@
1
1
  import type { UtilsSettings } from './../../../canvas/constants/app';
2
2
  import type { SelectionModeResize } from './../../../common/types/Mode';
3
- import type { DrawableShape, Ellipse, Point, Rect, ShapeEntity } from './../../../common/types/Shapes';
3
+ import type { DrawableShape, Point, Rect, ShapeEntity } from './../../../common/types/Shapes';
4
4
  import type { ToolsSettingsType } from './../../../common/types/tools';
5
- export declare const refreshEllipse: <T extends DrawableShape<"ellipse">>(shape: T, settings: UtilsSettings) => T;
5
+ export declare const getComputedEllipse: (ellipse: DrawableShape<"ellipse">, settings: UtilsSettings) => {
6
+ borders: Rect;
7
+ outerBorders: Rect;
8
+ center: Point;
9
+ boundingBox: Rect;
10
+ };
11
+ export declare const refreshEllipse: <T extends DrawableShape<"ellipse">>(shape: T & {
12
+ id: string;
13
+ }, settings: UtilsSettings) => ShapeEntity<"ellipse">;
6
14
  export declare const createEllipse: (shape: {
7
15
  id: string;
8
16
  type: "ellipse";
9
17
  settings: ToolsSettingsType<"ellipse">;
10
18
  }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"ellipse">;
11
- export declare const drawEllipse: (ctx: CanvasRenderingContext2D, ellipse: DrawableShape<"ellipse">) => void;
12
- export declare const getEllipseBorder: (ellipse: Ellipse, settings: UtilsSettings) => Rect;
13
- export declare const translateEllipse: <U extends DrawableShape<"ellipse">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings, singleAxis: boolean) => U & {
14
- x: number;
15
- y: number;
16
- };
17
- export declare const resizeEllipse: (cursorPosition: Point, originalShape: DrawableShape<"ellipse">, selectionMode: SelectionModeResize, settings: UtilsSettings, keepRatio?: boolean, resizeFromCenter?: boolean) => DrawableShape<"ellipse">;
19
+ 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
+ export declare const resizeEllipse: (cursorPosition: Point, originalShape: ShapeEntity<"ellipse">, selectionMode: SelectionModeResize, settings: UtilsSettings, keepRatio?: boolean, resizeFromCenter?: boolean) => ShapeEntity<"ellipse">;
@@ -1,33 +1,47 @@
1
1
  import type { UtilsSettings } from './../../../canvas/constants/app';
2
- import type { SelectionModeData } from './../../../common/types/Mode';
3
- import type { DrawableShape, Point, Rect, ShapeEntity } from './../../../common/types/Shapes';
2
+ import type { HoverModeData, SelectionModeData } from './../../../common/types/Mode';
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, {
6
6
  type: "picture";
7
- }>, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity;
8
- export declare const drawShape: (ctx: CanvasRenderingContext2D, shape: DrawableShape, settings: UtilsSettings) => void;
9
- export declare const getShapeInfos: (shape: DrawableShape, settings: UtilsSettings) => {
10
- borders: Rect;
11
- outerBorders: Rect;
12
- center: Point;
13
- };
7
+ }>, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity | undefined;
8
+ export declare const isInView: (shape: ShapeEntity, settings: UtilsSettings) => boolean;
9
+ export declare const drawShape: (ctx: CanvasRenderingContext2D, shape: ShapeEntity, settings: UtilsSettings) => void;
14
10
  export declare const rotateShape: <T extends DrawableShape>(shape: T, cursorPosition: Point, originalShape: T, originalCursorPosition: Point, shapeCenter: Point, settings: UtilsSettings, isShiftPressed: boolean) => T & {
15
- rotation: number;
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;
16
17
  };
17
- export declare const resizeShape: <T extends DrawableShape>(ctx: CanvasRenderingContext2D, shape: T, cursorPosition: Point, originalShape: T, selectionMode: SelectionModeData<Point | number>, settings: UtilsSettings, isShiftPressed: boolean, isAltPressed: boolean) => T;
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;
18
19
  export declare const translateShape: (cursorPosition: Point, originalShape: ShapeEntity, originalCursorPosition: Point, settings: UtilsSettings, isShiftPressed: boolean) => ShapeEntity;
19
- export declare const refreshShape: (shape: ShapeEntity, settings: UtilsSettings) => ShapeEntity;
20
- export declare const drawShapeSelection: ({ ctx, shape, settings, selectionWidth, selectionColor, withAnchors }: {
20
+ export declare const translateShapes: (cursorPosition: Point, originalShape: SelectionType, originalCursorPosition: Point, settings: UtilsSettings, isShiftPressed: boolean) => ShapeEntity[];
21
+ export declare const refreshShape: (shape: DrawableShape & {
22
+ id: string;
23
+ }, settings: UtilsSettings) => ShapeEntity;
24
+ export declare const getShapeComputedData: (shape: DrawableShape, settings: UtilsSettings) => {
25
+ borders: import("./../../../common/types/Shapes").Rect;
26
+ outerBorders: import("./../../../common/types/Shapes").Rect;
27
+ center: Point;
28
+ boundingBox: import("./../../../common/types/Shapes").Rect;
29
+ } | undefined;
30
+ export declare const drawShapeSelection: ({ ctx, shape, settings, selectionWidth, selectionColor, hoverMode, withAnchors }: {
21
31
  ctx: CanvasRenderingContext2D;
22
- shape: DrawableShape;
32
+ shape: SelectionType;
23
33
  settings: UtilsSettings;
24
34
  selectionWidth: number;
25
35
  selectionColor: string;
36
+ hoverMode: HoverModeData;
26
37
  withAnchors?: boolean;
27
38
  }) => void;
28
39
  export declare const drawSelectionFrame: ({ ctx, selectionFrame, settings }: {
29
40
  ctx: CanvasRenderingContext2D;
30
- selectionFrame: [Point, Point];
41
+ selectionFrame: {
42
+ oldSelection: SelectionType | undefined;
43
+ frame: [Point, Point];
44
+ };
31
45
  settings: UtilsSettings;
32
46
  }) => void;
33
- export declare const copyShape: (shape: ShapeEntity, settings: UtilsSettings) => ShapeEntity;
47
+ export declare const copyShapes: (groupShape: SelectionType, settings: UtilsSettings) => ShapeEntity[];