@yorab/react-paint 0.13.1 → 0.14.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.
- package/README.md +1 -1
- package/dist/canvas/components/Canvas.d.ts +14 -7
- package/dist/canvas/constants/shapes.d.ts +1 -1
- package/dist/canvas/hooks/useDrawableCanvas.d.ts +11 -7
- package/dist/canvas/hooks/useKeyboard.d.ts +11 -8
- package/dist/canvas/hooks/useReactPaint.d.ts +32 -20
- package/dist/canvas/hooks/useShapes.d.ts +17 -11
- package/dist/canvas/hooks/useZoom.d.ts +1 -0
- package/dist/canvas/utils/canvas.d.ts +2 -0
- package/dist/canvas/utils/intersect.d.ts +3 -3
- package/dist/canvas/utils/selection/groupSelection.d.ts +3 -0
- package/dist/canvas/utils/selection/lineSelection.d.ts +3 -1
- package/dist/canvas/utils/selection/rectSelection.d.ts +2 -2
- package/dist/canvas/utils/selection.d.ts +11 -4
- package/dist/canvas/utils/shapes/brush.d.ts +1 -1
- package/dist/canvas/utils/shapes/circle.d.ts +1 -1
- package/dist/canvas/utils/shapes/curve.d.ts +1 -1
- package/dist/canvas/utils/shapes/ellipse.d.ts +1 -1
- package/dist/canvas/utils/shapes/index.d.ts +13 -8
- package/dist/canvas/utils/shapes/line.d.ts +1 -1
- package/dist/canvas/utils/shapes/path.d.ts +1 -1
- package/dist/canvas/utils/shapes/picture.d.ts +1 -1
- package/dist/canvas/utils/shapes/polygon.d.ts +1 -1
- package/dist/canvas/utils/shapes/rectangle.d.ts +3 -3
- package/dist/canvas/utils/shapes/text.d.ts +1 -1
- package/dist/canvas/utils/transform.d.ts +4 -4
- package/dist/common/types/Mode.d.ts +5 -4
- package/dist/common/types/Shapes.d.ts +20 -15
- package/dist/common/types/tools.d.ts +5 -1
- package/dist/editor/components/common/Button.d.ts +4 -4
- package/dist/editor/components/common/Panel.d.ts +1 -1
- package/dist/editor/components/settings/ClosedPointsField.d.ts +1 -1
- package/dist/editor/components/settings/ColorField.d.ts +1 -1
- package/dist/editor/components/settings/DeleteButton.d.ts +3 -3
- package/dist/editor/components/settings/FontFamilyField.d.ts +1 -1
- package/dist/editor/components/settings/Layouts.d.ts +7 -7
- package/dist/editor/components/settings/LineArrowField.d.ts +1 -1
- package/dist/editor/components/settings/LineTypeField.d.ts +1 -1
- package/dist/editor/components/settings/RangeField.d.ts +1 -1
- package/dist/editor/components/settings/SettingsBar.d.ts +4 -4
- package/dist/editor/components/settings/ToggleField.d.ts +2 -2
- package/dist/editor/components/settings/ZoomButton.d.ts +2 -2
- package/dist/editor/constants/icons.d.ts +1 -0
- package/dist/editor/constants/tools.d.ts +2 -2
- package/dist/editor/hooks/useDrag.d.ts +1 -1
- package/dist/editor/utils/style.d.ts +1 -1
- package/dist/react-paint.css +1 -1
- package/dist/react-paint.js +1260 -1129
- package/dist/react-paint.umd.cjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -144,7 +144,7 @@ you will find other usages in <a href="https://github.com/YoRab/react-paint-edit
|
|
|
144
144
|
| `withLoadAndSave` | `boolean` | *Optional*.Show button to manually save or load data | `true` |
|
|
145
145
|
| `withUploadPicture` | `boolean` | *Optional*. Show button to add picture shape stored in base64 | `true` |
|
|
146
146
|
| `withUrlPicture` | `boolean` | *Optional*.Show button to add picture shape with only the url stored. Need connectivity to be displayed | `false` |
|
|
147
|
-
| `withFrameSelection` | `boolean` | *Optional*.Enable frame selection
|
|
147
|
+
| `withFrameSelection` | `boolean` | *Optional*.Enable frame selection | `true` |
|
|
148
148
|
| `withSkeleton` | `boolean` | *Optional*. Display skeleton when hovering shape | `false` |
|
|
149
149
|
| `clearCallback` | `'empty' \| 'defaultShapes' \| (() => DrawableShape[])` | *Optional*. Set clear button behavior. `empty` clear all shapes, `defaultShapes` uses shapes given in props. It is also possible to set a function returning an array of shapes | `empty` |
|
|
150
150
|
| `brushAlgo` | `'simple' \| 'quadratic'` | *Optional*. Choose which algorithm to display brush shape. `simple` displays path as is, `quadratic` uses quadratic bézier curves | `simple` |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type UtilsSettings } from './../../canvas/constants/app';
|
|
2
2
|
import type { SelectionModeData } from './../../common/types/Mode';
|
|
3
|
-
import type { Point, ShapeEntity } from './../../common/types/Shapes';
|
|
3
|
+
import type { Point, SelectionType, ShapeEntity } from './../../common/types/Shapes';
|
|
4
4
|
import type { ToolsType } from './../../common/types/tools';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import './Canvas.css';
|
|
@@ -12,13 +12,19 @@ type DrawerType = {
|
|
|
12
12
|
isEditMode: boolean;
|
|
13
13
|
shapes: ShapeEntity[];
|
|
14
14
|
saveShapes: () => void;
|
|
15
|
-
|
|
16
|
-
updateSingleShape: (updatedShape: ShapeEntity, withSave?: boolean) => void;
|
|
17
|
-
selectedShape:
|
|
18
|
-
setSelectedShape: React.Dispatch<React.SetStateAction<
|
|
19
|
-
setSelectionFrame: React.Dispatch<React.SetStateAction<
|
|
15
|
+
addShapes: (newShape: ShapeEntity[]) => void;
|
|
16
|
+
updateSingleShape: (updatedShape: ShapeEntity[], withSave?: boolean) => void;
|
|
17
|
+
selectedShape: SelectionType | undefined;
|
|
18
|
+
setSelectedShape: React.Dispatch<React.SetStateAction<SelectionType | undefined>>;
|
|
19
|
+
setSelectionFrame: React.Dispatch<React.SetStateAction<{
|
|
20
|
+
oldSelection: SelectionType | undefined;
|
|
21
|
+
frame: [Point, Point];
|
|
22
|
+
} | undefined>>;
|
|
20
23
|
hoveredShape: ShapeEntity | undefined;
|
|
21
|
-
selectionFrame:
|
|
24
|
+
selectionFrame: {
|
|
25
|
+
oldSelection: SelectionType | undefined;
|
|
26
|
+
frame: [Point, Point];
|
|
27
|
+
} | undefined;
|
|
22
28
|
refreshHoveredShape: (e: MouseEvent | TouchEvent, ctx: CanvasRenderingContext2D, cursorPosition: Point, isInsideMask: boolean) => void;
|
|
23
29
|
refreshSelectedShapes: (ctx: CanvasRenderingContext2D, cursorPosition: Point, settings: UtilsSettings) => void;
|
|
24
30
|
activeTool: ToolsType;
|
|
@@ -39,6 +45,7 @@ type DrawerType = {
|
|
|
39
45
|
isAltPressed: boolean;
|
|
40
46
|
withFrameSelection: boolean;
|
|
41
47
|
withSkeleton: boolean;
|
|
48
|
+
setCanvasMoveAcceleration: React.Dispatch<React.SetStateAction<Point>>;
|
|
42
49
|
};
|
|
43
50
|
declare const Canvas: React.ForwardRefExoticComponent<DrawerType & React.RefAttributes<HTMLCanvasElement>>;
|
|
44
51
|
export default Canvas;
|
|
@@ -5,4 +5,4 @@ export declare const SELECTION_DEFAULT_COLOR = "blue";
|
|
|
5
5
|
export declare const SELECTION_ANCHOR_SIZE = 14;
|
|
6
6
|
export declare const SELECTION_ROTATED_ANCHOR_POSITION = 16;
|
|
7
7
|
export declare const SELECTION_RESIZE_ANCHOR_POSITIONS: Point[];
|
|
8
|
-
export declare const ShapeTypeArray: readonly ["brush", "rect", "square", "line", "polygon", "circle", "curve", "ellipse", "picture", "text", "triangle"];
|
|
8
|
+
export declare const ShapeTypeArray: readonly ["brush", "rect", "square", "line", "polygon", "circle", "curve", "ellipse", "picture", "text", "triangle", "group"];
|
|
@@ -1,15 +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';
|
|
3
|
+
import type { Point, SelectionType, ShapeEntity } from './../../common/types/Shapes';
|
|
4
4
|
import type { ToolsType } from './../../common/types/tools';
|
|
5
5
|
import type React from 'react';
|
|
6
6
|
type UseCanvasType = {
|
|
7
7
|
shapes: ShapeEntity[];
|
|
8
8
|
saveShapes: () => void;
|
|
9
|
-
|
|
10
|
-
updateSingleShape: (updatedShape: ShapeEntity, withSave?: boolean) => void;
|
|
11
|
-
selectedShape:
|
|
12
|
-
setSelectedShape: React.Dispatch<React.SetStateAction<
|
|
9
|
+
addShapes: (newShape: ShapeEntity[]) => void;
|
|
10
|
+
updateSingleShape: (updatedShape: ShapeEntity[], withSave?: boolean) => void;
|
|
11
|
+
selectedShape: SelectionType | undefined;
|
|
12
|
+
setSelectedShape: React.Dispatch<React.SetStateAction<SelectionType | undefined>>;
|
|
13
13
|
activeTool: ToolsType;
|
|
14
14
|
setActiveTool: React.Dispatch<React.SetStateAction<ToolsType>>;
|
|
15
15
|
refreshHoveredShape: (e: MouseEvent | TouchEvent, ctx: CanvasRenderingContext2D, cursorPosition: Point, isInsideMask: boolean) => void;
|
|
@@ -26,14 +26,18 @@ type UseCanvasType = {
|
|
|
26
26
|
isInsideComponent: boolean;
|
|
27
27
|
selectionMode: SelectionModeData<number | Point>;
|
|
28
28
|
setSelectionMode: React.Dispatch<React.SetStateAction<SelectionModeData<number | Point>>>;
|
|
29
|
-
setSelectionFrame: React.Dispatch<React.SetStateAction<
|
|
29
|
+
setSelectionFrame: React.Dispatch<React.SetStateAction<{
|
|
30
|
+
oldSelection: SelectionType | undefined;
|
|
31
|
+
frame: [Point, Point];
|
|
32
|
+
} | undefined>>;
|
|
33
|
+
setCanvasMoveAcceleration: React.Dispatch<React.SetStateAction<Point>>;
|
|
30
34
|
drawCanvasRef: React.RefObject<HTMLCanvasElement | null>;
|
|
31
35
|
isShiftPressed: boolean;
|
|
32
36
|
isAltPressed: boolean;
|
|
33
37
|
withFrameSelection: boolean;
|
|
34
38
|
settings: UtilsSettings;
|
|
35
39
|
};
|
|
36
|
-
declare const useDrawableCanvas: ({
|
|
40
|
+
declare const useDrawableCanvas: ({ addShapes, drawCanvasRef, setActiveTool, refreshHoveredShape, shapes, selectionMode, activeTool, isInsideComponent, setCanvasOffset, selectedShape, canvasOffsetStartData, refreshSelectedShapes, setSelectedShape, setSelectionFrame, setCanvasOffsetStartData, updateSingleShape, saveShapes, setSelectionMode, setCanvasMoveAcceleration, settings, isShiftPressed, isAltPressed, withFrameSelection }: UseCanvasType) => {
|
|
37
41
|
hoverMode: HoverModeData;
|
|
38
42
|
};
|
|
39
43
|
export default useDrawableCanvas;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { UtilsSettings } from './../../canvas/constants/app';
|
|
2
2
|
import type { SelectionModeData } from './../../common/types/Mode';
|
|
3
|
-
import type { Point, ShapeEntity } from './../../common/types/Shapes';
|
|
3
|
+
import type { Point, SelectionType, ShapeEntity } from './../../common/types/Shapes';
|
|
4
4
|
import type { ToolsType } from './../../common/types/tools';
|
|
5
5
|
type UseKeyboardType = {
|
|
6
6
|
isInsideComponent: boolean;
|
|
7
|
-
selectedShape:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
setSelectedShape: (value: React.SetStateAction<
|
|
11
|
-
removeShape: (shape: ShapeEntity) => void;
|
|
7
|
+
selectedShape: SelectionType | undefined;
|
|
8
|
+
pasteShapes: (shape: ShapeEntity[]) => void;
|
|
9
|
+
updateShapes: (shapes: ShapeEntity[]) => void;
|
|
10
|
+
setSelectedShape: (value: React.SetStateAction<SelectionType | undefined>) => void;
|
|
11
|
+
removeShape: (shape: ShapeEntity[]) => void;
|
|
12
12
|
backwardShape: () => void;
|
|
13
13
|
forwardShape: () => void;
|
|
14
14
|
setShiftPressed: (value: React.SetStateAction<boolean>) => void;
|
|
@@ -16,8 +16,11 @@ type UseKeyboardType = {
|
|
|
16
16
|
isEditingText: boolean;
|
|
17
17
|
setActiveTool: (tool: ToolsType) => void;
|
|
18
18
|
setSelectionMode: (mode: SelectionModeData<number | Point>) => void;
|
|
19
|
-
setSelectionFrame: (
|
|
19
|
+
setSelectionFrame: (args: {
|
|
20
|
+
oldSelection: SelectionType | undefined;
|
|
21
|
+
frame: [Point, Point];
|
|
22
|
+
} | undefined) => void;
|
|
20
23
|
settings: UtilsSettings;
|
|
21
24
|
};
|
|
22
|
-
declare const useKeyboard: ({ isInsideComponent, selectedShape, isEditingText, settings, setSelectedShape, setActiveTool, setSelectionMode, setSelectionFrame, removeShape,
|
|
25
|
+
declare const useKeyboard: ({ isInsideComponent, selectedShape, isEditingText, settings, setSelectedShape, setActiveTool, setSelectionMode, setSelectionFrame, removeShape, pasteShapes, updateShapes, backwardShape, forwardShape, setShiftPressed, setAltPressed }: UseKeyboardType) => {};
|
|
23
26
|
export default useKeyboard;
|
|
@@ -4,12 +4,12 @@ import type { SelectionModeData } from './../../common/types/Mode';
|
|
|
4
4
|
import type { ExportedDrawableShape, Point, ShapeEntity, StateData } from './../../common/types/Shapes';
|
|
5
5
|
import type { ToolsType } from './../../common/types/tools';
|
|
6
6
|
type UseReactPaintProps = {
|
|
7
|
-
width?: number;
|
|
8
|
-
height?: number;
|
|
9
|
-
shapes?: ExportedDrawableShape[];
|
|
10
|
-
mode?: 'editor' | 'viewer';
|
|
11
|
-
disabled?: boolean;
|
|
12
|
-
options?: OptionalOptions;
|
|
7
|
+
width?: number | undefined;
|
|
8
|
+
height?: number | undefined;
|
|
9
|
+
shapes?: ExportedDrawableShape[] | undefined;
|
|
10
|
+
mode?: 'editor' | 'viewer' | undefined;
|
|
11
|
+
disabled?: boolean | undefined;
|
|
12
|
+
options?: OptionalOptions | undefined;
|
|
13
13
|
};
|
|
14
14
|
declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disabled, options }?: UseReactPaintProps) => {
|
|
15
15
|
annotationsProps: {
|
|
@@ -29,14 +29,14 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
|
|
|
29
29
|
shapesRef: import("react").RefObject<ShapeEntity[]>;
|
|
30
30
|
addPictureShape: (fileOrUrl: File | string, maxWidth?: number, maxHeight?: number) => Promise<ShapeEntity<"picture">>;
|
|
31
31
|
moveShapes: (startPositionShapeId: string, endPositionShapeId: string) => void;
|
|
32
|
-
toggleShapeVisibility: (
|
|
33
|
-
toggleShapeLock: (
|
|
32
|
+
toggleShapeVisibility: (shapes: ShapeEntity[]) => void;
|
|
33
|
+
toggleShapeLock: (shapeGroup: ShapeEntity[]) => void;
|
|
34
34
|
canGoBackward: boolean;
|
|
35
35
|
canGoForward: boolean;
|
|
36
36
|
canClear: boolean;
|
|
37
|
-
selectedShape:
|
|
38
|
-
removeShape: (
|
|
39
|
-
updateShape: (
|
|
37
|
+
selectedShape: import("./../../common/types/Shapes").SelectionType | undefined;
|
|
38
|
+
removeShape: (shapes: ShapeEntity[]) => void;
|
|
39
|
+
updateShape: (updatedShapes: ShapeEntity[], withSave?: boolean) => void;
|
|
40
40
|
backwardShape: () => void;
|
|
41
41
|
forwardShape: () => void;
|
|
42
42
|
refs: {
|
|
@@ -47,7 +47,7 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
|
|
|
47
47
|
width: number;
|
|
48
48
|
height: number;
|
|
49
49
|
selectTool: (tool: ToolsType) => void;
|
|
50
|
-
|
|
50
|
+
selectShapes: (shapes: ShapeEntity[]) => void;
|
|
51
51
|
activeTool: ToolsType;
|
|
52
52
|
setActiveTool: import("react").Dispatch<import("react").SetStateAction<ToolsType>>;
|
|
53
53
|
setAvailableTools: import("react").Dispatch<import("react").SetStateAction<import("./../../common/types/tools").CustomTool[]>>;
|
|
@@ -73,16 +73,22 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
|
|
|
73
73
|
};
|
|
74
74
|
canvasProps: {
|
|
75
75
|
shapesRef: import("react").RefObject<ShapeEntity[]>;
|
|
76
|
-
selectedShape:
|
|
77
|
-
selectionFrame:
|
|
76
|
+
selectedShape: import("./../../common/types/Shapes").SelectionType | undefined;
|
|
77
|
+
selectionFrame: {
|
|
78
|
+
oldSelection: import("./../../common/types/Shapes").SelectionType | undefined;
|
|
79
|
+
frame: [Point, Point];
|
|
80
|
+
} | undefined;
|
|
78
81
|
hoveredShape: ShapeEntity | undefined;
|
|
79
|
-
addShape: (
|
|
80
|
-
setSelectedShape: import("react").Dispatch<import("react").SetStateAction<
|
|
81
|
-
setSelectionFrame: import("react").Dispatch<import("react").SetStateAction<
|
|
82
|
+
addShape: (newShapes: ShapeEntity[]) => void;
|
|
83
|
+
setSelectedShape: import("react").Dispatch<import("react").SetStateAction<import("./../../common/types/Shapes").SelectionType | undefined>>;
|
|
84
|
+
setSelectionFrame: import("react").Dispatch<import("react").SetStateAction<{
|
|
85
|
+
oldSelection: import("./../../common/types/Shapes").SelectionType | undefined;
|
|
86
|
+
frame: [Point, Point];
|
|
87
|
+
} | undefined>>;
|
|
82
88
|
refreshSelectedShapes: (ctx: CanvasRenderingContext2D, cursorPosition: Point) => void;
|
|
83
89
|
refreshHoveredShape: (e: MouseEvent | TouchEvent, ctx: CanvasRenderingContext2D, cursorPosition: Point, isInsideMask: boolean) => void;
|
|
84
|
-
removeShape: (
|
|
85
|
-
updateShape: (
|
|
90
|
+
removeShape: (shapes: ShapeEntity[]) => void;
|
|
91
|
+
updateShape: (updatedShapes: ShapeEntity[], withSave?: boolean) => void;
|
|
86
92
|
backwardShape: () => void;
|
|
87
93
|
forwardShape: () => void;
|
|
88
94
|
saveShapes: () => void;
|
|
@@ -97,7 +103,7 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
|
|
|
97
103
|
setCanvasSize: import("react").Dispatch<import("react").SetStateAction<CanvasSize>>;
|
|
98
104
|
setCanvasOffset: (newOffset: Point) => void;
|
|
99
105
|
setCanvasZoom: (action: "unzoom" | "zoom" | "default") => void;
|
|
100
|
-
|
|
106
|
+
selectShapes: (shapes: ShapeEntity[]) => void;
|
|
101
107
|
activeTool: ToolsType;
|
|
102
108
|
setActiveTool: import("react").Dispatch<import("react").SetStateAction<ToolsType>>;
|
|
103
109
|
isInsideComponent: boolean;
|
|
@@ -118,10 +124,16 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
|
|
|
118
124
|
} | undefined>>;
|
|
119
125
|
selectionMode: SelectionModeData<number | Point>;
|
|
120
126
|
setSelectionMode: import("react").Dispatch<import("react").SetStateAction<SelectionModeData<number | Point>>>;
|
|
127
|
+
setCanvasMoveAcceleration: import("react").Dispatch<import("react").SetStateAction<Point>>;
|
|
128
|
+
isShiftPressed: boolean;
|
|
129
|
+
isAltPressed: boolean;
|
|
130
|
+
setShiftPressed: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
131
|
+
setAltPressed: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
121
132
|
};
|
|
122
133
|
registerEvent: (event: "dataChanged", fn: (data: StateData, source: "user" | "remote") => void) => void;
|
|
123
134
|
unregisterEvent: (event: "dataChanged", fn?: (data: StateData, source: "user" | "remote") => void) => void;
|
|
124
135
|
resetCanvas: (json?: ExportedDrawableShape[], clearHistory?: boolean) => void;
|
|
136
|
+
resetZoom: () => void;
|
|
125
137
|
getCurrentImage: (view: "fitToShapes" | "defaultView" | "currentZoom") => string;
|
|
126
138
|
getCurrentData: () => StateData;
|
|
127
139
|
setCanvasOffset: (newOffset: Point) => void;
|
|
@@ -1,24 +1,30 @@
|
|
|
1
1
|
import { type UtilsSettings } from './../../canvas/constants/app';
|
|
2
|
-
import type { Point, ShapeEntity, StateData } from './../../common/types/Shapes';
|
|
3
|
-
declare const useShapes: (settings: UtilsSettings, width: number, height: number) => {
|
|
2
|
+
import type { Point, SelectionType, ShapeEntity, StateData } from './../../common/types/Shapes';
|
|
3
|
+
declare const useShapes: (settings: UtilsSettings, width: number, height: number, isShiftPressed: boolean) => {
|
|
4
4
|
registerEvent: (event: "dataChanged", fn: (data: StateData, source: "user" | "remote") => void) => void;
|
|
5
5
|
unregisterEvent: (event: "dataChanged", fn?: (data: StateData, source: "user" | "remote") => void) => void;
|
|
6
6
|
shapesRef: import("react").RefObject<ShapeEntity[]>;
|
|
7
|
-
selectedShape:
|
|
7
|
+
selectedShape: SelectionType | undefined;
|
|
8
8
|
hoveredShape: ShapeEntity | undefined;
|
|
9
|
-
selectionFrame:
|
|
10
|
-
|
|
9
|
+
selectionFrame: {
|
|
10
|
+
oldSelection: SelectionType | undefined;
|
|
11
|
+
frame: [Point, Point];
|
|
12
|
+
} | undefined;
|
|
13
|
+
setSelectionFrame: import("react").Dispatch<import("react").SetStateAction<{
|
|
14
|
+
oldSelection: SelectionType | undefined;
|
|
15
|
+
frame: [Point, Point];
|
|
16
|
+
} | undefined>>;
|
|
11
17
|
refreshSelectedShapes: (ctx: CanvasRenderingContext2D, cursorPosition: Point) => void;
|
|
12
|
-
|
|
18
|
+
addShapes: (newShapes: ShapeEntity[]) => void;
|
|
13
19
|
addPictureShape: (fileOrUrl: File | string, maxWidth?: number, maxHeight?: number) => Promise<ShapeEntity<"picture">>;
|
|
14
20
|
moveShapes: (startPositionShapeId: string, endPositionShapeId: string) => void;
|
|
15
21
|
saveShapes: () => void;
|
|
16
|
-
setSelectedShape: import("react").Dispatch<import("react").SetStateAction<
|
|
22
|
+
setSelectedShape: import("react").Dispatch<import("react").SetStateAction<SelectionType | undefined>>;
|
|
17
23
|
refreshHoveredShape: (e: MouseEvent | TouchEvent, ctx: CanvasRenderingContext2D, cursorPosition: Point, isInsideMask: boolean) => void;
|
|
18
|
-
toggleShapeVisibility: (
|
|
19
|
-
toggleShapeLock: (
|
|
20
|
-
removeShape: (
|
|
21
|
-
updateShape: (
|
|
24
|
+
toggleShapeVisibility: (shapes: ShapeEntity[]) => void;
|
|
25
|
+
toggleShapeLock: (shapeGroup: ShapeEntity[]) => void;
|
|
26
|
+
removeShape: (shapes: ShapeEntity[]) => void;
|
|
27
|
+
updateShape: (updatedShapes: ShapeEntity[], withSave?: boolean) => void;
|
|
22
28
|
backwardShape: () => void;
|
|
23
29
|
forwardShape: () => void;
|
|
24
30
|
clearShapes: (shapesToInit: ShapeEntity[], options: {
|
|
@@ -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;
|
|
@@ -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,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 { DrawableShape, Point, Rect, SelectionType } 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:
|
|
14
|
+
export declare const checkSelectionIntersection: (ctx: CanvasRenderingContext2D, shape: SelectionType, position: Point, settings: UtilsSettings, checkAnchors?: boolean, radius?: number) => false | HoverModeData;
|
|
15
15
|
export declare const checkPolygonLinesSelectionIntersection: (ctx: CanvasRenderingContext2D, shape: DrawableShape<"polygon" | "curve">, position: Point, settings: UtilsSettings, radius?: number) => false | {
|
|
16
16
|
lineIndex: number;
|
|
17
17
|
};
|
|
18
18
|
export declare const checkCurveLinesSelectionIntersection: (ctx: CanvasRenderingContext2D, shape: DrawableShape<"curve">, position: Point, settings: UtilsSettings, radius?: number) => false | {
|
|
19
19
|
lineIndex: number;
|
|
20
20
|
};
|
|
21
|
-
export declare const checkPositionIntersection: (ctx: CanvasRenderingContext2D, shape:
|
|
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
23
|
export declare const checkSelectionFrameCollision: (ctx: CanvasRenderingContext2D, shape: DrawableShape, selectionFrame: [Point, Point], settings: UtilsSettings) => boolean;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { UtilsSettings } from './../../../canvas/constants/app';
|
|
2
|
+
import type { DrawableShape } from './../../../common/types/Shapes';
|
|
3
|
+
export declare const drawSelectionGroup: (ctx: CanvasRenderingContext2D, shape: DrawableShape<"group">, selectionColor: string, selectionWidth: number, settings: UtilsSettings, withAnchors: boolean) => void;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import type { UtilsSettings } from './../../../canvas/constants/app';
|
|
2
|
+
import type { HoverModeData } from './../../../common/types/Mode';
|
|
2
3
|
import type { DrawableShape, Point, SelectionLinesType } from './../../../common/types/Shapes';
|
|
3
4
|
export declare const createLineSelectionPath: (path: Path2D | undefined, shape: DrawableShape<"line" | "polygon" | "curve"> & {
|
|
4
5
|
points: readonly Point[];
|
|
5
6
|
}, settings: UtilsSettings) => SelectionLinesType;
|
|
6
|
-
export declare const drawLineSelection: ({ ctx, shape, withAnchors, selectionWidth, selectionColor, settings }: {
|
|
7
|
+
export declare const drawLineSelection: ({ ctx, shape, withAnchors, selectionWidth, selectionColor, hoverMode, settings }: {
|
|
7
8
|
ctx: CanvasRenderingContext2D;
|
|
8
9
|
shape: DrawableShape<"line"> | DrawableShape<"polygon"> | DrawableShape<"curve">;
|
|
9
10
|
withAnchors: boolean;
|
|
10
11
|
selectionWidth: number;
|
|
11
12
|
selectionColor: string;
|
|
13
|
+
hoverMode: HoverModeData;
|
|
12
14
|
settings: UtilsSettings;
|
|
13
15
|
}) => void;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { UtilsSettings } from './../../../canvas/constants/app';
|
|
2
2
|
import type { SelectionModeResize } from './../../../common/types/Mode';
|
|
3
3
|
import type { DrawableShape, Point, SelectionDefaultType } from './../../../common/types/Shapes';
|
|
4
|
-
export declare const createRecSelectionPath: (path: Path2D | undefined, rect: DrawableShape, settings: UtilsSettings) => SelectionDefaultType;
|
|
4
|
+
export declare const createRecSelectionPath: (path: Path2D | undefined, rect: DrawableShape, settings: UtilsSettings, isGroup?: boolean) => SelectionDefaultType;
|
|
5
5
|
export declare const drawSelectionRect: (ctx: CanvasRenderingContext2D, shape: DrawableShape & {
|
|
6
|
-
selection?: SelectionDefaultType;
|
|
6
|
+
selection?: SelectionDefaultType | undefined;
|
|
7
7
|
}, selectionColor: string, selectionWidth: number, settings: UtilsSettings, withAnchors: boolean) => void;
|
|
8
8
|
export declare const resizeRectSelection: (cursorPosition: Point, originalShape: DrawableShape, selectionMode: SelectionModeResize, settings: UtilsSettings, keepRatio?: boolean, resizeFromCenter?: boolean) => {
|
|
9
9
|
borderX: 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
|
-
|
|
5
|
-
export declare const
|
|
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, settings: UtilsSettings) => 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:
|
|
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;
|
|
@@ -9,7 +9,7 @@ export declare const createBrush: (shape: {
|
|
|
9
9
|
settings: ToolsSettingsType<"brush">;
|
|
10
10
|
}, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"brush">;
|
|
11
11
|
export declare const drawBrush: (ctx: CanvasRenderingContext2D, shape: DrawableShape<"brush">) => void;
|
|
12
|
-
export declare const getBrushBorder: (brush: DrawableShape<"brush">, { selectionPadding }: UtilsSettings) => Rect;
|
|
12
|
+
export declare const getBrushBorder: (brush: DrawableShape<"brush">, { selectionPadding }: Pick<UtilsSettings, "selectionPadding">) => Rect;
|
|
13
13
|
export declare const translateBrush: <U extends DrawableShape<"brush">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings, singleAxis: boolean) => U & {
|
|
14
14
|
points: Point[][];
|
|
15
15
|
};
|
|
@@ -9,7 +9,7 @@ export declare const createCircle: (shape: {
|
|
|
9
9
|
settings: ToolsSettingsType<"circle">;
|
|
10
10
|
}, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"circle">;
|
|
11
11
|
export declare const drawCircle: (ctx: CanvasRenderingContext2D, circle: DrawableShape<"circle">) => void;
|
|
12
|
-
export declare const getCircleBorder: (circle: Circle, settings: UtilsSettings) => Rect;
|
|
12
|
+
export declare const getCircleBorder: (circle: Circle, settings: Pick<UtilsSettings, "selectionPadding">) => Rect;
|
|
13
13
|
export declare const translateCircle: <U extends DrawableShape<"circle">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings, singleAxis: boolean) => U & {
|
|
14
14
|
x: number;
|
|
15
15
|
y: number;
|
|
@@ -10,7 +10,7 @@ export declare const createCurve: (shape: {
|
|
|
10
10
|
}, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"curve">;
|
|
11
11
|
export declare const resizeCurve: (cursorPosition: Point, originalShape: DrawableShape<"curve">, selectionMode: SelectionModeResize<number>, settings: UtilsSettings) => DrawableShape<"curve">;
|
|
12
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;
|
|
13
|
+
export declare const getCurveBorder: (polygon: import("./../../../common/types/Shapes").Polygon, settings: Pick<UtilsSettings, "selectionPadding">) => import("./../../../common/types/Shapes").Rect;
|
|
14
14
|
export declare const translateCurve: <U extends DrawableShape<"curve">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings, singleAxis: boolean) => U & {
|
|
15
15
|
points: [number, number][];
|
|
16
16
|
};
|
|
@@ -9,7 +9,7 @@ export declare const createEllipse: (shape: {
|
|
|
9
9
|
settings: ToolsSettingsType<"ellipse">;
|
|
10
10
|
}, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"ellipse">;
|
|
11
11
|
export declare const drawEllipse: (ctx: CanvasRenderingContext2D, ellipse: DrawableShape<"ellipse">) => void;
|
|
12
|
-
export declare const getEllipseBorder: (ellipse: Ellipse, settings: UtilsSettings) => Rect;
|
|
12
|
+
export declare const getEllipseBorder: (ellipse: Ellipse, settings: Pick<UtilsSettings, "selectionPadding">) => Rect;
|
|
13
13
|
export declare const translateEllipse: <U extends DrawableShape<"ellipse">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings, singleAxis: boolean) => U & {
|
|
14
14
|
x: number;
|
|
15
15
|
y: number;
|
|
@@ -1,12 +1,12 @@
|
|
|
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, Rect, 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;
|
|
7
|
+
}>, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity | undefined;
|
|
8
8
|
export declare const drawShape: (ctx: CanvasRenderingContext2D, shape: DrawableShape, settings: UtilsSettings) => void;
|
|
9
|
-
export declare const getShapeInfos: (shape: DrawableShape, settings: UtilsSettings) => {
|
|
9
|
+
export declare const getShapeInfos: (shape: DrawableShape, settings: Pick<UtilsSettings, "selectionPadding">) => {
|
|
10
10
|
borders: Rect;
|
|
11
11
|
outerBorders: Rect;
|
|
12
12
|
center: Point;
|
|
@@ -16,18 +16,23 @@ export declare const rotateShape: <T extends DrawableShape>(shape: T, cursorPosi
|
|
|
16
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
18
|
export declare const translateShape: (cursorPosition: Point, originalShape: ShapeEntity, originalCursorPosition: Point, settings: UtilsSettings, isShiftPressed: boolean) => ShapeEntity;
|
|
19
|
+
export declare const translateShapes: (cursorPosition: Point, originalShape: SelectionType, originalCursorPosition: Point, settings: UtilsSettings, isShiftPressed: boolean) => ShapeEntity[];
|
|
19
20
|
export declare const refreshShape: (shape: ShapeEntity, settings: UtilsSettings) => ShapeEntity;
|
|
20
|
-
export declare const drawShapeSelection: ({ ctx, shape, settings, selectionWidth, selectionColor, withAnchors }: {
|
|
21
|
+
export declare const drawShapeSelection: ({ ctx, shape, settings, selectionWidth, selectionColor, hoverMode, withAnchors }: {
|
|
21
22
|
ctx: CanvasRenderingContext2D;
|
|
22
|
-
shape:
|
|
23
|
+
shape: SelectionType;
|
|
23
24
|
settings: UtilsSettings;
|
|
24
25
|
selectionWidth: number;
|
|
25
26
|
selectionColor: string;
|
|
27
|
+
hoverMode: HoverModeData;
|
|
26
28
|
withAnchors?: boolean;
|
|
27
29
|
}) => void;
|
|
28
30
|
export declare const drawSelectionFrame: ({ ctx, selectionFrame, settings }: {
|
|
29
31
|
ctx: CanvasRenderingContext2D;
|
|
30
|
-
selectionFrame:
|
|
32
|
+
selectionFrame: {
|
|
33
|
+
oldSelection: SelectionType | undefined;
|
|
34
|
+
frame: [Point, Point];
|
|
35
|
+
};
|
|
31
36
|
settings: UtilsSettings;
|
|
32
37
|
}) => void;
|
|
33
|
-
export declare const
|
|
38
|
+
export declare const copyShapes: (groupShape: SelectionType, settings: UtilsSettings) => ShapeEntity[];
|
|
@@ -10,7 +10,7 @@ export declare const createLine: (shape: {
|
|
|
10
10
|
}, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"line">;
|
|
11
11
|
export declare const buildTriangleOnLine: (center: Point, rotation: number, lineStyle: StyleShape) => Triangle;
|
|
12
12
|
export declare const drawLine: (ctx: CanvasRenderingContext2D, shape: DrawableShape<"line">) => void;
|
|
13
|
-
export declare const getLineBorder: (line: Line, settings: UtilsSettings) => Rect;
|
|
13
|
+
export declare const getLineBorder: (line: Line, settings: Pick<UtilsSettings, "selectionPadding">) => Rect;
|
|
14
14
|
export declare const translateLine: <U extends DrawableShape<"line">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings, singleAxis: boolean) => U & {
|
|
15
15
|
points: [Point, Point];
|
|
16
16
|
};
|
|
@@ -5,7 +5,7 @@ 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
|
-
export declare const getCatmullRomPoints: (curve: DrawableShape<"curve">, points: Point[]) => [
|
|
8
|
+
export declare const getCatmullRomPoints: (curve: DrawableShape<"curve">, points: Point[]) => Point[];
|
|
9
9
|
export declare const catmullRomToBezier: (path: Path2D, p0: Point, p1: Point, p2: Point, p3: Point) => void;
|
|
10
10
|
export declare const createCurvePath: (curve: DrawableShape<"curve">) => Path2D | undefined;
|
|
11
11
|
export declare const createPolygonPath: (polygon: DrawableShape<"polygon"> | DrawableShape<"curve">) => Path2D | undefined;
|
|
@@ -4,7 +4,7 @@ import type { DrawableShape, Picture, Point, Rect, ShapeEntity } from './../../.
|
|
|
4
4
|
export declare const refreshPicture: <T extends DrawableShape<"picture">>(shape: T, settings: UtilsSettings) => T;
|
|
5
5
|
export declare const createPicture: (fileOrUrl: File | string, maxPictureWidth: number, maxPictureHeight: number, settings: UtilsSettings) => Promise<ShapeEntity<"picture">>;
|
|
6
6
|
export declare const drawPicture: (ctx: CanvasRenderingContext2D, picture: DrawableShape<"picture">) => void;
|
|
7
|
-
export declare const getPictureBorder: (picture: Picture, settings: UtilsSettings) => Rect;
|
|
7
|
+
export declare const getPictureBorder: (picture: Picture, settings: Pick<UtilsSettings, "selectionPadding">) => Rect;
|
|
8
8
|
export declare const translatePicture: <U extends DrawableShape<"picture">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings, singleAxis: boolean) => U & {
|
|
9
9
|
x: number;
|
|
10
10
|
y: number;
|
|
@@ -9,7 +9,7 @@ export declare const createPolygon: (shape: {
|
|
|
9
9
|
settings: ToolsSettingsType<"polygon">;
|
|
10
10
|
}, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"polygon">;
|
|
11
11
|
export declare const drawPolygon: (ctx: CanvasRenderingContext2D, polygon: DrawableShape<"polygon">) => void;
|
|
12
|
-
export declare const getPolygonBorder: (polygon: Polygon, settings: UtilsSettings) => Rect;
|
|
12
|
+
export declare const getPolygonBorder: (polygon: Polygon, settings: Pick<UtilsSettings, "selectionPadding">) => Rect;
|
|
13
13
|
export declare const translatePolygon: <U extends DrawableShape<"polygon">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings, singleAxis: boolean) => U & {
|
|
14
14
|
points: [number, number][];
|
|
15
15
|
};
|
|
@@ -3,14 +3,14 @@ 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
5
|
type rectish = 'text' | 'rect' | 'square' | 'picture';
|
|
6
|
-
export declare const refreshRect: <T extends DrawableShape<rectish>>(rect: T, settings: UtilsSettings) => T;
|
|
6
|
+
export declare const refreshRect: <T extends DrawableShape<rectish>>(rect: T, settings: UtilsSettings, isGroup?: boolean) => T;
|
|
7
7
|
export declare const createRectangle: <T extends "rect" | "square">(shape: {
|
|
8
8
|
id: string;
|
|
9
9
|
type: T;
|
|
10
10
|
settings: ToolsSettingsType<T>;
|
|
11
|
-
}, cursorPosition: Point, settings: UtilsSettings, width?: number, height?: number) => ShapeEntity<T>;
|
|
11
|
+
}, cursorPosition: Point, settings: UtilsSettings, isGroup?: boolean, width?: number, height?: number) => ShapeEntity<T>;
|
|
12
12
|
export declare const drawRect: (ctx: CanvasRenderingContext2D, shape: DrawableShape<"rect" | "square">) => void;
|
|
13
|
-
export declare const getRectBorder: (rect: Rect, settings: UtilsSettings) => Rect;
|
|
13
|
+
export declare const getRectBorder: (rect: Rect, settings: Pick<UtilsSettings, "selectionPadding">) => Rect;
|
|
14
14
|
export declare const getRectOppositeAnchorAbsolutePosition: <T extends DrawableShape & Rect>(anchor: Point, center: Point, shape: T, [negW, negH]?: [boolean, boolean]) => Point;
|
|
15
15
|
export declare const translateRect: <T extends "rect" | "square", U extends DrawableShape<T>>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings, singleAxis: boolean) => U & {
|
|
16
16
|
x: number;
|
|
@@ -10,7 +10,7 @@ export declare const createText: (ctx: CanvasRenderingContext2D, shape: {
|
|
|
10
10
|
settings: ToolsSettingsType<"text">;
|
|
11
11
|
}, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"text">;
|
|
12
12
|
export declare const drawText: (ctx: CanvasRenderingContext2D, text: DrawableShape<"text">) => void;
|
|
13
|
-
export declare const getTextBorder: (text: Text, settings: UtilsSettings) => Rect;
|
|
13
|
+
export declare const getTextBorder: (text: Text, settings: Pick<UtilsSettings, "selectionPadding">) => Rect;
|
|
14
14
|
export declare const translateText: <U extends DrawableShape<"text">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings, singleAxis: boolean) => U & {
|
|
15
15
|
x: number;
|
|
16
16
|
y: number;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { UtilsSettings } from './../../canvas/constants/app';
|
|
2
2
|
import type { SelectionModeData } from './../../common/types/Mode';
|
|
3
|
-
import type { DrawableShape, Line, Point,
|
|
3
|
+
import type { DrawableShape, Line, Point, SelectionType } from './../../common/types/Shapes';
|
|
4
4
|
export declare const getNormalizedSize: (originalWidth: number, originalHeight: number, width: number, height: number) => number[];
|
|
5
5
|
export declare const roundValues: (prop: number, precision?: number) => number;
|
|
6
6
|
export declare const scalePoint: (point: Point, minX: number, minY: number, scaleX?: number, scaleY?: number) => Point;
|
|
7
7
|
export declare const roundForGrid: (value: number, settings: UtilsSettings, gridOffset?: number) => number;
|
|
8
8
|
export declare const roundRotationForGrid: (rotation: number, settings: UtilsSettings, isShiftPressed: boolean) => number;
|
|
9
|
-
export declare const boundVectorToSingleAxis: (vector: Point, isShiftPressed: boolean) =>
|
|
10
|
-
export declare const transformShape: (ctx: CanvasRenderingContext2D,
|
|
11
|
-
export declare const fitContentInsideContainer: (contentWidth: number, contentHeight: number, containerWidth: number, containerHeight: number, shouldFillContainer?: boolean) =>
|
|
9
|
+
export declare const boundVectorToSingleAxis: (vector: Point, isShiftPressed: boolean) => Point;
|
|
10
|
+
export declare const transformShape: (ctx: CanvasRenderingContext2D, selectedShape: SelectionType, cursorPosition: Point, selectionMode: SelectionModeData<Point | number>, settings: UtilsSettings, isShiftPressed: boolean, isAltPressed: boolean) => SelectionType;
|
|
11
|
+
export declare const fitContentInsideContainer: (contentWidth: number, contentHeight: number, containerWidth: number, containerHeight: number, shouldFillContainer?: boolean) => Point;
|
|
12
12
|
export declare const shortenLine: ({ line, size, direction }: {
|
|
13
13
|
line: DrawableShape<"line">;
|
|
14
14
|
size: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Point,
|
|
1
|
+
import type { Point, SelectionType } from './Shapes';
|
|
2
2
|
export type SelectionModeDefault = {
|
|
3
3
|
mode: 'default';
|
|
4
4
|
};
|
|
@@ -18,19 +18,20 @@ export type SelectionModeEditText = {
|
|
|
18
18
|
export type SelectionModeResize<AnchorType extends Point | number = Point> = {
|
|
19
19
|
mode: 'resize';
|
|
20
20
|
cursorStartPosition: Point;
|
|
21
|
-
originalShape:
|
|
21
|
+
originalShape: SelectionType;
|
|
22
22
|
anchor: AnchorType;
|
|
23
23
|
};
|
|
24
24
|
export type SelectionModeRotate = {
|
|
25
25
|
mode: 'rotate';
|
|
26
26
|
cursorStartPosition: Point;
|
|
27
|
-
originalShape:
|
|
27
|
+
originalShape: SelectionType;
|
|
28
28
|
center: Point;
|
|
29
29
|
};
|
|
30
30
|
export type SelectionModeTranslate = {
|
|
31
31
|
mode: 'translate';
|
|
32
32
|
cursorStartPosition: Point;
|
|
33
|
-
originalShape:
|
|
33
|
+
originalShape: SelectionType;
|
|
34
|
+
dateStart: number;
|
|
34
35
|
};
|
|
35
36
|
export type SelectionModeData<AnchorType extends Point | number> = SelectionModeDefault | SelectionModeSelectionFrame | SelectionModeBrush | SelectionModeResize<AnchorType> | SelectionModeRotate | SelectionModeTranslate | SelectionModeEditText | SelectionModePreview;
|
|
36
37
|
export type HoverModeData = {
|