@yorab/react-paint 0.16.2 → 0.16.3

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,7 +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
+ path: Path2D;
25
25
  } & {
26
26
  rotation?: number;
27
27
  toolId?: string;
@@ -44,7 +44,7 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
44
44
  center: Point;
45
45
  boundingBox: import("./../../common/types/Shapes").Rect;
46
46
  };
47
- path?: Path2D | undefined;
47
+ path: Path2D;
48
48
  } & {
49
49
  rotation?: number;
50
50
  toolId?: string;
@@ -72,7 +72,7 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
72
72
  center: Point;
73
73
  boundingBox: import("./../../common/types/Shapes").Rect;
74
74
  };
75
- path?: Path2D | undefined;
75
+ path: Path2D;
76
76
  } & {
77
77
  rotation?: number;
78
78
  toolId?: string;
@@ -100,7 +100,7 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
100
100
  center: Point;
101
101
  boundingBox: import("./../../common/types/Shapes").Rect;
102
102
  };
103
- path?: Path2D | undefined;
103
+ path: Path2D;
104
104
  } & {
105
105
  rotation?: number;
106
106
  toolId?: string;
@@ -122,7 +122,7 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
122
122
  center: Point;
123
123
  boundingBox: import("./../../common/types/Shapes").Rect;
124
124
  };
125
- path?: Path2D | undefined;
125
+ path: Path2D;
126
126
  } & {
127
127
  rotation?: number;
128
128
  toolId?: string;
@@ -144,7 +144,7 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
144
144
  center: Point;
145
145
  boundingBox: import("./../../common/types/Shapes").Rect;
146
146
  };
147
- path?: Path2D | undefined;
147
+ path: Path2D;
148
148
  } & {
149
149
  rotation?: number;
150
150
  toolId?: string;
@@ -166,7 +166,7 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
166
166
  center: Point;
167
167
  boundingBox: import("./../../common/types/Shapes").Rect;
168
168
  };
169
- path?: Path2D | undefined;
169
+ path: Path2D;
170
170
  } & {
171
171
  rotation?: number;
172
172
  toolId?: string;
@@ -188,7 +188,7 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
188
188
  center: Point;
189
189
  boundingBox: import("./../../common/types/Shapes").Rect;
190
190
  };
191
- path?: Path2D | undefined;
191
+ path: Path2D;
192
192
  } & {
193
193
  rotation?: number;
194
194
  toolId?: string;
@@ -210,7 +210,7 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
210
210
  center: Point;
211
211
  boundingBox: import("./../../common/types/Shapes").Rect;
212
212
  };
213
- path?: Path2D | undefined;
213
+ path: Path2D;
214
214
  } & {
215
215
  rotation?: number;
216
216
  toolId?: string;
@@ -232,7 +232,7 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
232
232
  center: Point;
233
233
  boundingBox: import("./../../common/types/Shapes").Rect;
234
234
  };
235
- path?: Path2D | undefined;
235
+ path: Path2D;
236
236
  } & {
237
237
  rotation?: number;
238
238
  toolId?: string;
@@ -256,7 +256,7 @@ export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[]
256
256
  center: Point;
257
257
  boundingBox: import("./../../common/types/Shapes").Rect;
258
258
  };
259
- path?: Path2D | undefined;
259
+ path: Path2D;
260
260
  } & {
261
261
  rotation?: number;
262
262
  toolId?: string;
@@ -11,7 +11,7 @@ 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: SelectionType, position: Point, settings: UtilsSettings, checkAnchors?: boolean, radius?: number) => false | HoverModeData;
14
+ export declare const checkSelectionIntersection: (ctx: CanvasRenderingContext2D, selection: SelectionType, position: Point, settings: UtilsSettings, checkAnchors?: boolean, radius?: number) => false | HoverModeData;
15
15
  export declare const checkPolygonLinesSelectionIntersection: (ctx: CanvasRenderingContext2D, shape: ShapeEntity<"polygon" | "curve">, position: Point, settings: UtilsSettings, radius?: number) => false | {
16
16
  lineIndex: number;
17
17
  };
@@ -3,7 +3,7 @@ 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
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
+ export declare const selectShape: (ctx: CanvasRenderingContext2D, shapes: ShapeEntity[], cursorPosition: Point, settings: UtilsSettings, selectedShape: SelectionType | undefined, isTouchGesture: boolean, withFrameSelection: boolean, behavior?: "add" | "remove" | "replace") => {
7
7
  mode: SelectionModeData<Point | number>;
8
8
  shape: SelectionType | undefined;
9
9
  };
@@ -4,7 +4,7 @@ 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
- export declare const createBrushPath: (brush: DrawableShape<"brush">, { brushAlgo }: UtilsSettings) => Path2D | undefined;
7
+ export declare const createBrushPath: (brush: DrawableShape<"brush">, { brushAlgo }: UtilsSettings) => Path2D;
8
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
9
  export declare const getCubicBezierBounds: (p0: Point, p1: Point, p2: Point, p3: Point) => {
10
10
  minX: number;
@@ -17,8 +17,8 @@ export declare const catmullRomToBezier: (p0: Point, p1: Point, p2: Point, p3: P
17
17
  cp1: Point;
18
18
  cp2: Point;
19
19
  };
20
- export declare const createCurvePath: (curve: DrawableShape<"curve">) => Path2D | undefined;
21
- export declare const createPolygonPath: (polygon: DrawableShape<"polygon"> | DrawableShape<"curve">) => Path2D | undefined;
20
+ export declare const createCurvePath: (curve: DrawableShape<"curve">) => Path2D;
21
+ export declare const createPolygonPath: (polygon: DrawableShape<"polygon"> | DrawableShape<"curve">) => Path2D;
22
22
  export declare const createTrianglePath: (triangle: DrawableShape<"triangle">) => Path2D;
23
23
  export declare const getComputedShapeInfos: <T extends DrawableShape, U extends Pick<UtilsSettings, "selectionPadding">>(shape: T, getBorder: (shape: T, settings: U) => Rect, settings: U, getOuterBorder?: (shape: T, borders: Rect, settings: U) => Rect) => {
24
24
  borders: Rect;
@@ -19,18 +19,21 @@ export type SelectionModeResize<AnchorType extends Point | number = Point> = {
19
19
  mode: 'resize';
20
20
  cursorStartPosition: Point;
21
21
  originalShape: SelectionType;
22
+ selectedShapesLengthAtMouseDown: number;
22
23
  anchor: AnchorType;
23
24
  };
24
25
  export type SelectionModeRotate = {
25
26
  mode: 'rotate';
26
27
  cursorStartPosition: Point;
27
28
  originalShape: SelectionType;
29
+ selectedShapesLengthAtMouseDown: number;
28
30
  center: Point;
29
31
  };
30
32
  export type SelectionModeTranslate = {
31
33
  mode: 'translate';
32
34
  cursorStartPosition: Point;
33
35
  originalShape: SelectionType;
36
+ selectedShapesLengthAtMouseDown: number;
34
37
  hasBeenDuplicated: boolean;
35
38
  dateStart: number;
36
39
  };
@@ -56,12 +56,14 @@ export type StyleShape = {
56
56
  fontBold?: boolean;
57
57
  };
58
58
  export type SelectionDefaultType = {
59
+ type: 'rect';
59
60
  border: Path2D;
60
61
  line: Path2D | undefined;
61
62
  shapePath: Path2D | undefined;
62
63
  anchors: Path2D[];
63
64
  };
64
65
  export type SelectionLinesType = {
66
+ type: 'line';
65
67
  border: Path2D;
66
68
  shapePath: Path2D | undefined;
67
69
  anchors: Path2D[];
@@ -128,7 +130,7 @@ export type ShapeEntity<T extends Exclude<ShapeType, 'triangle'> = Exclude<Shape
128
130
  center: Point;
129
131
  boundingBox: Rect;
130
132
  };
131
- path?: Path2D | undefined;
133
+ path: Path2D;
132
134
  } & DrawableShape<T> & ({
133
135
  type: 'line';
134
136
  selection?: SelectionLinesType | undefined;