@yorab/react-paint 0.16.0 → 0.16.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,6 +21,7 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
21
21
  center: Point;
22
22
  boundingBox: import("./../../common/types/Shapes").Rect;
23
23
  };
24
+ path?: Path2D | undefined;
24
25
  } & {
25
26
  rotation?: number;
26
27
  toolId?: string;
@@ -30,10 +31,11 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
30
31
  } & import("./../../common/types/Shapes").Line & {
31
32
  type: "line";
32
33
  } & {
34
+ type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
35
+ } & {
36
+ type: "line";
33
37
  selection?: import("./../../common/types/Shapes").SelectionLinesType | undefined;
34
- path?: Path2D | undefined;
35
38
  arrows?: import("./../../common/types/Shapes").TriangleEntity[];
36
- type: "line";
37
39
  }) | ({
38
40
  id: string;
39
41
  computed: {
@@ -42,6 +44,7 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
42
44
  center: Point;
43
45
  boundingBox: import("./../../common/types/Shapes").Rect;
44
46
  };
47
+ path?: Path2D | undefined;
45
48
  } & {
46
49
  rotation?: number;
47
50
  toolId?: string;
@@ -51,14 +54,16 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
51
54
  } & import("./../../common/types/Shapes").Rect & {
52
55
  src: string;
53
56
  } & {
57
+ type: "picture";
54
58
  img: HTMLImageElement;
55
59
  flipX?: boolean;
56
60
  flipY?: boolean;
57
- type: "picture";
61
+ ratio?: number;
58
62
  } & {
59
- img: HTMLImageElement;
63
+ type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
64
+ } & {
65
+ type: "text" | "picture" | "rect" | "square" | "circle" | "ellipse" | "group" | "brush";
60
66
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
61
- type: "picture";
62
67
  }) | ({
63
68
  id: string;
64
69
  computed: {
@@ -67,6 +72,7 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
67
72
  center: Point;
68
73
  boundingBox: import("./../../common/types/Shapes").Rect;
69
74
  };
75
+ path?: Path2D | undefined;
70
76
  } & {
71
77
  rotation?: number;
72
78
  toolId?: string;
@@ -77,12 +83,15 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
77
83
  value: string[];
78
84
  fontSize: number;
79
85
  } & {
86
+ type: "text";
80
87
  flipX?: boolean;
81
88
  flipY?: boolean;
82
- type: "text";
89
+ ratio?: number;
90
+ } & {
91
+ type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
83
92
  } & {
93
+ type: "text" | "picture" | "rect" | "square" | "circle" | "ellipse" | "group" | "brush";
84
94
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
85
- type: "text";
86
95
  }) | ({
87
96
  id: string;
88
97
  computed: {
@@ -91,6 +100,7 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
91
100
  center: Point;
92
101
  boundingBox: import("./../../common/types/Shapes").Rect;
93
102
  };
103
+ path?: Path2D | undefined;
94
104
  } & {
95
105
  rotation?: number;
96
106
  toolId?: string;
@@ -100,9 +110,10 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
100
110
  } & import("./../../common/types/Shapes").Rect & {
101
111
  type: "rect";
102
112
  } & {
113
+ type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
114
+ } & {
115
+ type: "text" | "picture" | "rect" | "square" | "circle" | "ellipse" | "group" | "brush";
103
116
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
104
- path?: Path2D | undefined;
105
- type: "rect";
106
117
  }) | ({
107
118
  id: string;
108
119
  computed: {
@@ -111,6 +122,7 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
111
122
  center: Point;
112
123
  boundingBox: import("./../../common/types/Shapes").Rect;
113
124
  };
125
+ path?: Path2D | undefined;
114
126
  } & {
115
127
  rotation?: number;
116
128
  toolId?: string;
@@ -120,9 +132,10 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
120
132
  } & import("./../../common/types/Shapes").Rect & {
121
133
  type: "square";
122
134
  } & {
135
+ type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
136
+ } & {
137
+ type: "text" | "picture" | "rect" | "square" | "circle" | "ellipse" | "group" | "brush";
123
138
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
124
- path?: Path2D | undefined;
125
- type: "square";
126
139
  }) | ({
127
140
  id: string;
128
141
  computed: {
@@ -131,6 +144,7 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
131
144
  center: Point;
132
145
  boundingBox: import("./../../common/types/Shapes").Rect;
133
146
  };
147
+ path?: Path2D | undefined;
134
148
  } & {
135
149
  rotation?: number;
136
150
  toolId?: string;
@@ -140,9 +154,10 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
140
154
  } & import("./../../common/types/Shapes").Circle & {
141
155
  type: "circle";
142
156
  } & {
157
+ type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
158
+ } & {
159
+ type: "text" | "picture" | "rect" | "square" | "circle" | "ellipse" | "group" | "brush";
143
160
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
144
- path?: Path2D | undefined;
145
- type: "circle";
146
161
  }) | ({
147
162
  id: string;
148
163
  computed: {
@@ -151,6 +166,7 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
151
166
  center: Point;
152
167
  boundingBox: import("./../../common/types/Shapes").Rect;
153
168
  };
169
+ path?: Path2D | undefined;
154
170
  } & {
155
171
  rotation?: number;
156
172
  toolId?: string;
@@ -160,9 +176,10 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
160
176
  } & import("./../../common/types/Shapes").Ellipse & {
161
177
  type: "ellipse";
162
178
  } & {
179
+ type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
180
+ } & {
181
+ type: "text" | "picture" | "rect" | "square" | "circle" | "ellipse" | "group" | "brush";
163
182
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
164
- path?: Path2D | undefined;
165
- type: "ellipse";
166
183
  }) | ({
167
184
  id: string;
168
185
  computed: {
@@ -171,6 +188,7 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
171
188
  center: Point;
172
189
  boundingBox: import("./../../common/types/Shapes").Rect;
173
190
  };
191
+ path?: Path2D | undefined;
174
192
  } & {
175
193
  rotation?: number;
176
194
  toolId?: string;
@@ -180,9 +198,10 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
180
198
  } & import("./../../common/types/Shapes").Polygon & {
181
199
  type: "polygon";
182
200
  } & {
201
+ type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
202
+ } & {
203
+ type: "polygon" | "curve";
183
204
  selection?: import("./../../common/types/Shapes").SelectionLinesType | undefined;
184
- path?: Path2D | undefined;
185
- type: "polygon";
186
205
  }) | ({
187
206
  id: string;
188
207
  computed: {
@@ -191,6 +210,7 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
191
210
  center: Point;
192
211
  boundingBox: import("./../../common/types/Shapes").Rect;
193
212
  };
213
+ path?: Path2D | undefined;
194
214
  } & {
195
215
  rotation?: number;
196
216
  toolId?: string;
@@ -200,9 +220,10 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
200
220
  } & import("./../../common/types/Shapes").Curve & {
201
221
  type: "curve";
202
222
  } & {
223
+ type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
224
+ } & {
225
+ type: "polygon" | "curve";
203
226
  selection?: import("./../../common/types/Shapes").SelectionLinesType | undefined;
204
- path?: Path2D | undefined;
205
- type: "curve";
206
227
  }) | ({
207
228
  id: string;
208
229
  computed: {
@@ -211,6 +232,7 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
211
232
  center: Point;
212
233
  boundingBox: import("./../../common/types/Shapes").Rect;
213
234
  };
235
+ path?: Path2D | undefined;
214
236
  } & {
215
237
  rotation?: number;
216
238
  toolId?: string;
@@ -222,9 +244,10 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
222
244
  scaleX?: number;
223
245
  scaleY?: number;
224
246
  } & {
247
+ type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
248
+ } & {
249
+ type: "text" | "picture" | "rect" | "square" | "circle" | "ellipse" | "group" | "brush";
225
250
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
226
- path?: Path2D | undefined;
227
- type: "brush";
228
251
  }) | ({
229
252
  id: string;
230
253
  computed: {
@@ -233,6 +256,7 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
233
256
  center: Point;
234
257
  boundingBox: import("./../../common/types/Shapes").Rect;
235
258
  };
259
+ path?: Path2D | undefined;
236
260
  } & {
237
261
  rotation?: number;
238
262
  toolId?: string;
@@ -240,10 +264,11 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
240
264
  locked?: boolean;
241
265
  style?: import("./../../common/types/Shapes").StyleShape | undefined;
242
266
  } & import("./../../common/types/Shapes").Rect & {
243
- shapes: ShapeEntity[];
244
267
  type: "group";
268
+ shapes: ShapeEntity[];
245
269
  } & {
270
+ type: "brush" | "rect" | "square" | "line" | "polygon" | "circle" | "curve" | "ellipse" | "picture" | "text" | "group";
271
+ } & {
272
+ type: "text" | "picture" | "rect" | "square" | "circle" | "ellipse" | "group" | "brush";
246
273
  selection?: import("./../../common/types/Shapes").SelectionDefaultType | undefined;
247
- path?: Path2D | undefined;
248
- type: "group";
249
274
  }))[]>;
@@ -20,4 +20,4 @@ export declare const checkCurveLinesSelectionIntersection: (ctx: CanvasRendering
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: ShapeEntity, selectionFrame: [Point, Point], settings: UtilsSettings) => boolean;
23
+ export declare const checkSelectionFrameCollision: (ctx: CanvasRenderingContext2D, shape: ShapeEntity, selectionFrame: [Point, Point]) => boolean;
@@ -10,7 +10,7 @@ export declare const getComputedRect: (rect: DrawableShape<rectish>, settings: U
10
10
  center: Point;
11
11
  boundingBox: Rect;
12
12
  };
13
- export declare const refreshRect: <T extends rectish>(rect: DrawableShape<T> & {
13
+ export declare const refreshRect: <T extends rectish>(rect: DrawableShape<rectish> & {
14
14
  id: string;
15
15
  }, settings: UtilsSettings) => ShapeEntity<T>;
16
16
  export declare const createRectangle: <T extends rectish>(shape: {
@@ -49,6 +49,7 @@ export type StyleShape = {
49
49
  lineWidth?: number;
50
50
  lineDash?: number;
51
51
  lineArrow?: number;
52
+ lineCap?: CanvasLineCap;
52
53
  closedPoints?: number;
53
54
  fontFamily?: string;
54
55
  fontItalic?: boolean;
@@ -65,45 +66,50 @@ export type SelectionLinesType = {
65
66
  shapePath: Path2D | undefined;
66
67
  anchors: Path2D[];
67
68
  };
68
- export type DrawableShape<T extends ShapeType = ShapeType> = {
69
+ type GenericDrawableShape = {
69
70
  rotation?: number;
70
71
  toolId?: string;
71
72
  visible?: boolean;
72
73
  locked?: boolean;
73
74
  style?: StyleShape | undefined;
74
- } & (T extends 'line' ? Line & {
75
+ } & ((Line & {
75
76
  type: 'line';
76
- } : T extends 'picture' ? Picture & {
77
+ }) | (Picture & {
78
+ type: 'picture';
77
79
  img: HTMLImageElement;
78
80
  flipX?: boolean;
79
81
  flipY?: boolean;
80
- type: 'picture';
81
- } : T extends 'text' ? Text & {
82
+ ratio?: number;
83
+ }) | (Text & {
84
+ type: 'text';
82
85
  flipX?: boolean;
83
86
  flipY?: boolean;
84
- type: 'text';
85
- } : T extends 'rect' ? Rect & {
87
+ ratio?: number;
88
+ }) | (Rect & {
86
89
  type: 'rect';
87
- } : T extends 'square' ? Rect & {
90
+ }) | (Rect & {
88
91
  type: 'square';
89
- } : T extends 'circle' ? Circle & {
92
+ }) | (Circle & {
90
93
  type: 'circle';
91
- } : T extends 'ellipse' ? Ellipse & {
94
+ }) | (Ellipse & {
92
95
  type: 'ellipse';
93
- } : T extends 'triangle' ? Triangle & {
96
+ }) | (Triangle & {
94
97
  type: 'triangle';
95
- } : T extends 'polygon' ? Polygon & {
98
+ }) | (Polygon & {
96
99
  type: 'polygon';
97
- } : T extends 'curve' ? Curve & {
100
+ }) | (Curve & {
98
101
  type: 'curve';
99
- } : T extends 'brush' ? Brush & {
102
+ }) | (Brush & {
100
103
  type: 'brush';
101
104
  scaleX?: number;
102
105
  scaleY?: number;
103
- } : T extends 'group' ? Rect & {
104
- shapes: ShapeEntity[];
106
+ }) | (Rect & {
105
107
  type: 'group';
106
- } : never);
108
+ shapes: ShapeEntity[];
109
+ }));
110
+ export type DrawableShape<T extends ShapeType = ShapeType> = GenericDrawableShape & {
111
+ type: T;
112
+ };
107
113
  export type ExportedDrawableShape<T extends ShapeType = ShapeType> = T extends 'picture' ? Omit<DrawableShape<'picture'>, 'img'> : DrawableShape<T>;
108
114
  export type TriangleEntity = DrawableShape<'triangle'> & {
109
115
  path: Path2D;
@@ -122,51 +128,18 @@ export type ShapeEntity<T extends Exclude<ShapeType, 'triangle'> = Exclude<Shape
122
128
  center: Point;
123
129
  boundingBox: Rect;
124
130
  };
125
- } & DrawableShape<T> & (T extends 'line' ? {
126
- selection?: SelectionLinesType | undefined;
127
131
  path?: Path2D | undefined;
128
- arrows?: TriangleEntity[];
132
+ } & DrawableShape<T> & ({
129
133
  type: 'line';
130
- } : T extends 'picture' ? {
131
- img: HTMLImageElement;
132
- selection?: SelectionDefaultType | undefined;
133
- type: 'picture';
134
- } : T extends 'text' ? {
135
- selection?: SelectionDefaultType | undefined;
136
- type: 'text';
137
- } : T extends 'rect' ? {
138
- selection?: SelectionDefaultType | undefined;
139
- path?: Path2D | undefined;
140
- type: 'rect';
141
- } : T extends 'square' ? {
142
- selection?: SelectionDefaultType | undefined;
143
- path?: Path2D | undefined;
144
- type: 'square';
145
- } : T extends 'circle' ? {
146
- selection?: SelectionDefaultType | undefined;
147
- path?: Path2D | undefined;
148
- type: 'circle';
149
- } : T extends 'ellipse' ? {
150
- selection?: SelectionDefaultType | undefined;
151
- path?: Path2D | undefined;
152
- type: 'ellipse';
153
- } : T extends 'polygon' ? {
154
134
  selection?: SelectionLinesType | undefined;
155
- path?: Path2D | undefined;
156
- type: 'polygon';
157
- } : T extends 'curve' ? {
135
+ arrows?: TriangleEntity[];
136
+ } | {
137
+ type: 'polygon' | 'curve';
158
138
  selection?: SelectionLinesType | undefined;
159
- path?: Path2D | undefined;
160
- type: 'curve';
161
- } : T extends 'brush' ? {
139
+ } | {
140
+ type: 'text' | 'picture' | 'rect' | 'square' | 'circle' | 'ellipse' | 'group' | 'brush';
162
141
  selection?: SelectionDefaultType | undefined;
163
- path?: Path2D | undefined;
164
- type: 'brush';
165
- } : T extends 'group' ? {
166
- selection?: SelectionDefaultType | undefined;
167
- path?: Path2D | undefined;
168
- type: 'group';
169
- } : never);
142
+ });
170
143
  export type StateData = {
171
144
  shapes?: DrawableShape[];
172
145
  config?: {
@@ -175,3 +148,4 @@ export type StateData = {
175
148
  };
176
149
  };
177
150
  export type SelectionType = ShapeEntity;
151
+ export {};