@yorab/react-paint 0.14.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -283
- package/dist/canvas/components/Canvas.d.ts +2 -0
- package/dist/canvas/components/EditTextBox.d.ts +2 -2
- package/dist/canvas/constants/app.d.ts +2 -0
- package/dist/canvas/constants/keyboard.d.ts +24 -0
- package/dist/canvas/hooks/useComponent.d.ts +3 -1
- package/dist/canvas/hooks/useDebounce.d.ts +2 -0
- package/dist/canvas/hooks/useDrawableCanvas.d.ts +3 -1
- package/dist/canvas/hooks/useKeyboard.d.ts +5 -1
- package/dist/canvas/hooks/useReactPaint.d.ts +1847 -8
- package/dist/canvas/hooks/useShapes.d.ts +1379 -4
- package/dist/canvas/index.d.ts +3 -3
- package/dist/canvas/utils/data.d.ts +2 -2
- package/dist/canvas/utils/file.d.ts +233 -4
- package/dist/canvas/utils/intersect.d.ts +4 -4
- package/dist/canvas/utils/selection/groupSelection.d.ts +2 -2
- package/dist/canvas/utils/selection/lineSelection.d.ts +6 -2
- package/dist/canvas/utils/selection/rectSelection.d.ts +9 -4
- package/dist/canvas/utils/selection.d.ts +1 -1
- package/dist/canvas/utils/shapes/brush.d.ts +14 -11
- package/dist/canvas/utils/shapes/circle.d.ts +13 -9
- package/dist/canvas/utils/shapes/curve.d.ts +15 -10
- package/dist/canvas/utils/shapes/ellipse.d.ts +13 -9
- package/dist/canvas/utils/shapes/index.d.ts +19 -10
- package/dist/canvas/utils/shapes/line.d.ts +13 -8
- package/dist/canvas/utils/shapes/path.d.ts +18 -2
- package/dist/canvas/utils/shapes/picture.d.ts +13 -9
- package/dist/canvas/utils/shapes/polygon.d.ts +14 -8
- package/dist/canvas/utils/shapes/rectangle.d.ts +54 -9
- package/dist/canvas/utils/shapes/text.d.ts +12 -7
- package/dist/canvas/utils/shapes/triangle.d.ts +4 -3
- package/dist/canvas/utils/trigo.d.ts +1 -1
- package/dist/common/types/Mode.d.ts +1 -0
- package/dist/common/types/Shapes.d.ts +63 -26
- package/dist/common/types/utils.d.ts +1 -1
- package/dist/editor/components/common/Button.d.ts +2 -2
- package/dist/editor/components/common/FileInput.d.ts +13 -0
- package/dist/editor/components/settings/RangeField.d.ts +2 -1
- package/dist/editor/components/settings/SettingsBar.d.ts +2 -1
- package/dist/editor/index.d.ts +11 -11
- package/dist/react-paint.css +1 -1
- package/dist/react-paint.js +1362 -1312
- package/dist/react-paint.umd.cjs +1 -1
- package/package.json +19 -15
package/dist/canvas/index.d.ts
CHANGED
|
@@ -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;
|
|
@@ -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:
|
|
4
|
-
export declare const buildDataToExport: (shapes:
|
|
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:
|
|
10
|
+
shapes: ShapeEntity[];
|
|
11
11
|
settings: UtilsSettings;
|
|
12
12
|
view: "fitToShapes" | "defaultView" | "currentZoom";
|
|
13
13
|
}) => string;
|
|
14
|
-
export declare const encodeShapesInString: (shapes:
|
|
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<
|
|
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 {
|
|
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;
|
|
@@ -12,12 +12,12 @@ export declare const isTouchGesture: (e: MouseEvent | TouchEvent) => e is TouchE
|
|
|
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
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:
|
|
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:
|
|
18
|
+
export declare const checkCurveLinesSelectionIntersection: (ctx: CanvasRenderingContext2D, shape: ShapeEntity<"curve">, position: Point, settings: UtilsSettings, radius?: number) => false | {
|
|
19
19
|
lineIndex: number;
|
|
20
20
|
};
|
|
21
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:
|
|
23
|
+
export declare const checkSelectionFrameCollision: (ctx: CanvasRenderingContext2D, shape: ShapeEntity, selectionFrame: [Point, Point], settings: UtilsSettings) => boolean;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { UtilsSettings } from './../../../canvas/constants/app';
|
|
2
|
-
import type {
|
|
3
|
-
export declare const drawSelectionGroup: (ctx: CanvasRenderingContext2D, shape:
|
|
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,12 +1,16 @@
|
|
|
1
1
|
import type { UtilsSettings } from './../../../canvas/constants/app';
|
|
2
2
|
import type { HoverModeData } from './../../../common/types/Mode';
|
|
3
|
-
import type { DrawableShape, Point, SelectionLinesType } from './../../../common/types/Shapes';
|
|
3
|
+
import type { DrawableShape, Point, Rect, SelectionLinesType, ShapeEntity } from './../../../common/types/Shapes';
|
|
4
4
|
export declare const createLineSelectionPath: (path: Path2D | undefined, shape: DrawableShape<"line" | "polygon" | "curve"> & {
|
|
5
5
|
points: readonly Point[];
|
|
6
|
+
}, computed: {
|
|
7
|
+
borders: Rect;
|
|
8
|
+
outerBorders: Rect;
|
|
9
|
+
center: Point;
|
|
6
10
|
}, settings: UtilsSettings) => SelectionLinesType;
|
|
7
11
|
export declare const drawLineSelection: ({ ctx, shape, withAnchors, selectionWidth, selectionColor, hoverMode, settings }: {
|
|
8
12
|
ctx: CanvasRenderingContext2D;
|
|
9
|
-
shape:
|
|
13
|
+
shape: ShapeEntity<"line"> | ShapeEntity<"polygon"> | ShapeEntity<"curve">;
|
|
10
14
|
withAnchors: boolean;
|
|
11
15
|
selectionWidth: number;
|
|
12
16
|
selectionColor: string;
|
|
@@ -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 {
|
|
4
|
-
export declare const createRecSelectionPath: (path: Path2D | undefined,
|
|
5
|
-
|
|
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 & {
|
|
6
11
|
selection?: SelectionDefaultType | undefined;
|
|
7
12
|
}, selectionColor: string, selectionWidth: number, settings: UtilsSettings, withAnchors: boolean) => void;
|
|
8
|
-
export declare const resizeRectSelection: (cursorPosition: Point, originalShape:
|
|
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;
|
|
@@ -2,7 +2,7 @@ import type { UtilsSettings } from './../../canvas/constants/app';
|
|
|
2
2
|
import type { HoverModeData, SelectionModeData } from './../../common/types/Mode';
|
|
3
3
|
import type { Point, SelectionType, ShapeEntity } from './../../common/types/Shapes';
|
|
4
4
|
import type { CustomTool } from './../../common/types/tools';
|
|
5
|
-
export declare const getNewSelectionData: (hoverMode: HoverModeData, selectedShape: SelectionType, cursorPosition: Point
|
|
5
|
+
export declare const getNewSelectionData: (hoverMode: HoverModeData, selectedShape: SelectionType, cursorPosition: Point) => SelectionModeData<Point | number> | undefined;
|
|
6
6
|
export declare const selectShape: (ctx: CanvasRenderingContext2D, shapes: ShapeEntity[], cursorPosition: Point, settings: UtilsSettings, selectedShape: SelectionType | undefined, isTouchGesture: boolean, withFrameSelection: boolean, isGroupMode: boolean) => {
|
|
7
7
|
mode: SelectionModeData<Point | number>;
|
|
8
8
|
shape: SelectionType | 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
|
|
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:
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const
|
|
14
|
-
|
|
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 {
|
|
3
|
+
import type { DrawableShape, Point, Rect, ShapeEntity } from './../../../common/types/Shapes';
|
|
4
4
|
import type { ToolsSettingsType } from './../../../common/types/tools';
|
|
5
|
-
export declare const
|
|
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:
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const
|
|
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
|
|
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:
|
|
12
|
-
export declare const drawCurve: (ctx: CanvasRenderingContext2D, curve:
|
|
13
|
-
export declare const
|
|
14
|
-
export declare const
|
|
15
|
-
|
|
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,
|
|
3
|
+
import type { DrawableShape, Point, Rect, ShapeEntity } from './../../../common/types/Shapes';
|
|
4
4
|
import type { ToolsSettingsType } from './../../../common/types/tools';
|
|
5
|
-
export declare const
|
|
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:
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const
|
|
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,23 +1,32 @@
|
|
|
1
1
|
import type { UtilsSettings } from './../../../canvas/constants/app';
|
|
2
2
|
import type { HoverModeData, SelectionModeData } from './../../../common/types/Mode';
|
|
3
|
-
import type { DrawableShape, Point,
|
|
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
7
|
}>, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity | undefined;
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const
|
|
10
|
-
borders: Rect;
|
|
11
|
-
outerBorders: Rect;
|
|
12
|
-
center: Point;
|
|
13
|
-
};
|
|
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
|
-
|
|
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
|
|
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
20
|
export declare const translateShapes: (cursorPosition: Point, originalShape: SelectionType, originalCursorPosition: Point, settings: UtilsSettings, isShiftPressed: boolean) => ShapeEntity[];
|
|
20
|
-
export declare const refreshShape: (shape:
|
|
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;
|
|
21
30
|
export declare const drawShapeSelection: ({ ctx, shape, settings, selectionWidth, selectionColor, hoverMode, withAnchors }: {
|
|
22
31
|
ctx: CanvasRenderingContext2D;
|
|
23
32
|
shape: SelectionType;
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import type { UtilsSettings } from './../../../canvas/constants/app';
|
|
2
2
|
import type { SelectionModeResize } from './../../../common/types/Mode';
|
|
3
|
-
import type { DrawableShape,
|
|
3
|
+
import type { DrawableShape, Point, Rect, ShapeEntity, StyleShape, Triangle } from './../../../common/types/Shapes';
|
|
4
4
|
import type { ToolsSettingsType } from './../../../common/types/tools';
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const getComputedLine: (line: DrawableShape<"line">, settings: UtilsSettings) => {
|
|
6
|
+
borders: Rect;
|
|
7
|
+
outerBorders: Rect;
|
|
8
|
+
center: Point;
|
|
9
|
+
boundingBox: Rect;
|
|
10
|
+
};
|
|
11
|
+
export declare const refreshLine: <T extends DrawableShape<"line">>(line: T & {
|
|
12
|
+
id: string;
|
|
13
|
+
}, settings: UtilsSettings) => ShapeEntity<"line">;
|
|
6
14
|
export declare const createLine: (shape: {
|
|
7
15
|
id: string;
|
|
8
16
|
type: "line";
|
|
9
17
|
settings: ToolsSettingsType<"line">;
|
|
10
18
|
}, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"line">;
|
|
11
19
|
export declare const buildTriangleOnLine: (center: Point, rotation: number, lineStyle: StyleShape) => Triangle;
|
|
12
|
-
export declare const drawLine: (ctx: CanvasRenderingContext2D, shape:
|
|
13
|
-
export declare const
|
|
14
|
-
export declare const
|
|
15
|
-
points: [Point, Point];
|
|
16
|
-
};
|
|
17
|
-
export declare const resizeLine: <U extends DrawableShape<"line">>(cursorPosition: Point, originalShape: U, selectionMode: SelectionModeResize<number>, settings: UtilsSettings) => U;
|
|
20
|
+
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
|
+
export declare const resizeLine: (cursorPosition: Point, originalShape: ShapeEntity<"line">, selectionMode: SelectionModeResize<number>, settings: UtilsSettings) => ShapeEntity<"line">;
|
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
import type { UtilsSettings } from './../../../canvas/constants/app';
|
|
2
|
-
import type { Circle, DrawableShape, Line, Point, Rect } from './../../../common/types/Shapes';
|
|
2
|
+
import type { Circle, DrawableShape, Line, Point, Rect, StyleShape } 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;
|
|
6
6
|
export declare const createLinePath: (line: Line) => Path2D;
|
|
7
7
|
export declare const createBrushPath: (brush: DrawableShape<"brush">, { brushAlgo }: UtilsSettings) => Path2D | undefined;
|
|
8
|
+
/** Bounding box of a cubic Bezier segment B(t) = (1-t)³P0 + 3(1-t)²t P1 + 3(1-t)t² P2 + t³ P3 */
|
|
9
|
+
export declare const getCubicBezierBounds: (p0: Point, p1: Point, p2: Point, p3: Point) => {
|
|
10
|
+
minX: number;
|
|
11
|
+
maxX: number;
|
|
12
|
+
minY: number;
|
|
13
|
+
maxY: number;
|
|
14
|
+
};
|
|
8
15
|
export declare const getCatmullRomPoints: (curve: DrawableShape<"curve">, points: Point[]) => Point[];
|
|
9
|
-
export declare const catmullRomToBezier: (
|
|
16
|
+
export declare const catmullRomToBezier: (p0: Point, p1: Point, p2: Point, p3: Point) => {
|
|
17
|
+
cp1: Point;
|
|
18
|
+
cp2: Point;
|
|
19
|
+
};
|
|
10
20
|
export declare const createCurvePath: (curve: DrawableShape<"curve">) => Path2D | undefined;
|
|
11
21
|
export declare const createPolygonPath: (polygon: DrawableShape<"polygon"> | DrawableShape<"curve">) => Path2D | undefined;
|
|
12
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) => {
|
|
24
|
+
borders: Rect;
|
|
25
|
+
outerBorders: Rect;
|
|
26
|
+
center: Point;
|
|
27
|
+
boundingBox: Rect;
|
|
28
|
+
};
|