@yorab/react-paint 0.11.21 → 0.13.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 +8 -9
- package/dist/canvas/components/Canvas.d.ts +12 -11
- package/dist/canvas/components/EditTextBox.d.ts +1 -2
- package/dist/canvas/constants/app.d.ts +12 -0
- package/dist/canvas/constants/zoom.d.ts +5 -0
- package/dist/canvas/hooks/useComponent.d.ts +4 -3
- package/dist/canvas/hooks/useDrawableCanvas.d.ts +14 -9
- package/dist/canvas/hooks/useKeyboard.d.ts +8 -2
- package/dist/canvas/hooks/usePinchZoomAndMove.d.ts +17 -0
- package/dist/canvas/hooks/useReactPaint.d.ts +40 -27
- package/dist/canvas/hooks/useResizeObserver.d.ts +1 -1
- package/dist/canvas/hooks/useShapes.d.ts +2 -2
- package/dist/canvas/hooks/useZoom.d.ts +21 -0
- package/dist/canvas/utils/file.d.ts +5 -1
- package/dist/canvas/utils/grid.d.ts +1 -1
- package/dist/canvas/utils/intersect.d.ts +12 -3
- package/dist/canvas/utils/selection/lineSelection.d.ts +1 -1
- package/dist/canvas/utils/selection/rectSelection.d.ts +1 -1
- package/dist/canvas/utils/shapes/brush.d.ts +2 -2
- package/dist/canvas/utils/shapes/circle.d.ts +2 -2
- package/dist/canvas/utils/shapes/curve.d.ts +3 -2
- package/dist/canvas/utils/shapes/ellipse.d.ts +2 -2
- package/dist/canvas/utils/shapes/index.d.ts +4 -3
- package/dist/canvas/utils/shapes/line.d.ts +1 -1
- package/dist/canvas/utils/shapes/path.d.ts +2 -2
- package/dist/canvas/utils/shapes/picture.d.ts +2 -2
- package/dist/canvas/utils/shapes/polygon.d.ts +3 -2
- package/dist/canvas/utils/shapes/rectangle.d.ts +3 -3
- package/dist/canvas/utils/shapes/text.d.ts +2 -2
- package/dist/canvas/utils/transform.d.ts +3 -2
- package/dist/canvas/utils/trigo.d.ts +2 -0
- package/dist/canvas/utils/zoom.d.ts +58 -0
- package/dist/common/types/Canvas.d.ts +8 -0
- package/dist/common/types/Mode.d.ts +8 -2
- package/dist/common/types/Shapes.d.ts +3 -1
- package/dist/common/types/tools.d.ts +4 -7
- package/dist/common/utils/util.d.ts +2 -0
- package/dist/editor/components/common/Modal.d.ts +3 -2
- package/dist/editor/components/common/Panel.d.ts +3 -1
- package/dist/editor/components/settings/ClosedPointsField.d.ts +10 -0
- package/dist/editor/components/settings/Layouts.d.ts +3 -2
- package/dist/editor/components/settings/SettingsBar.d.ts +6 -3
- package/dist/editor/components/settings/ZoomButton.d.ts +8 -0
- package/dist/editor/components/toolbox/ExportModal.d.ts +7 -0
- package/dist/editor/components/toolbox/MenuGroup.d.ts +3 -3
- package/dist/editor/components/toolbox/Toolbar.d.ts +5 -5
- package/dist/editor/constants/icons.d.ts +4 -4
- package/dist/editor/hooks/useDrag.d.ts +2 -2
- package/dist/react-paint.css +1 -1
- package/dist/react-paint.js +1249 -1038
- package/dist/react-paint.umd.cjs +1 -1
- package/package.json +18 -23
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ const SHAPES_INIT = [
|
|
|
51
51
|
lineWidth: 1,
|
|
52
52
|
lineDash: 0,
|
|
53
53
|
lineArrow: 0,
|
|
54
|
-
|
|
54
|
+
closedPoints: 1,
|
|
55
55
|
fontFamily: 'serif'
|
|
56
56
|
}
|
|
57
57
|
}
|
|
@@ -129,7 +129,7 @@ you will find other usages in <a href="https://github.com/YoRab/react-paint-edit
|
|
|
129
129
|
| `registerEvent` | `(event: "dataChanged", listener: (data: StateData, source: 'user' \| 'remote') => void) => void` | registerEvent is used to register a listener for special events triggered by react-paint. The only currently available event is `dataChanged`. `source` indicates the origin of the state update |
|
|
130
130
|
| `unregisterEvent` | `(event: "dataChanged", listener?: ((data: StateData, source: 'user' \| 'remote') => void) \| undefined) => void` | unregisterEvent is used to unregister a listener previously registered. Omitting listener will result in unregistering every listeners for the the given event |
|
|
131
131
|
| `resetCanvas` | `(shapes: DrawableShape[], clearHistory?: boolean) => Promise<void>` | reset canvas with the given shapes. use `[]` or `undefined` to clear the canvas. Set `false` to `clearHistory` to prevent history stack to be cleared |
|
|
132
|
-
| `getCurrentImage` | `() => string
|
|
132
|
+
| `getCurrentImage` | `(view: 'defaultView' \| 'currentZoom' \| 'fitToShapes') => string` | Returns a data URL containing the content of the current canvas as a PNG image. `defaultView` will export a picture with dimensions based on canvas and no zoom. `currentZoom` will export a picture with dimensions based on canvas and current zoom and offset. `fitToShapes` will export a picture containing all drawn shapes. |
|
|
133
133
|
| `getCurrentData` | `() => StateData` | Returns the current state of the canvas |
|
|
134
134
|
|
|
135
135
|
#### `OptionalOptions`
|
|
@@ -151,6 +151,8 @@ you will find other usages in <a href="https://github.com/YoRab/react-paint-edit
|
|
|
151
151
|
| `isBrushShapeDoneOnMouseUp` | `boolean` | *Optional*. Choose whether drawing brush shape after releasing mouse should create a new shape or not | `true` |
|
|
152
152
|
| `canvasSelectionPadding` | `boolean` | *Optional*. Padding between shape and selection frame | `0` |
|
|
153
153
|
| `availableTools` | `CustomToolInput[]` | *Optional*. List of available tools. See CustomTool for more details | `` |
|
|
154
|
+
| `size` | `'fixed' \| 'infinite'` | *Optional*. Choose canvas size mode. `fixed` canvas is bound within its width and height, `infinite` canvas has no bound | `fixed` |
|
|
155
|
+
| `canZoom` | `'never' \| 'always'` | *Optional*. Choose wether zoom is available `never` zoom is not available, `always` zoom is available | `never` |
|
|
154
156
|
|
|
155
157
|
|
|
156
158
|
|
|
@@ -304,11 +306,8 @@ type SettingsFont = {
|
|
|
304
306
|
}
|
|
305
307
|
}
|
|
306
308
|
|
|
307
|
-
type
|
|
308
|
-
|
|
309
|
-
min: number
|
|
310
|
-
max: number
|
|
311
|
-
step: number
|
|
309
|
+
type SettingsClosedPoints = {
|
|
310
|
+
closedPoints: {
|
|
312
311
|
default: number
|
|
313
312
|
hidden?: boolean
|
|
314
313
|
}
|
|
@@ -333,14 +332,14 @@ type ToolsPolygonSettings = SettingsOpacity &
|
|
|
333
332
|
SettingsFillColor &
|
|
334
333
|
SettingsLineWidth &
|
|
335
334
|
SettingsLineDash &
|
|
336
|
-
|
|
335
|
+
SettingsClosedPoints
|
|
337
336
|
|
|
338
337
|
type ToolsCurveSettings = SettingsOpacity &
|
|
339
338
|
SettingsStrokeColor &
|
|
340
339
|
SettingsFillColor &
|
|
341
340
|
SettingsLineWidth &
|
|
342
341
|
SettingsLineDash &
|
|
343
|
-
|
|
342
|
+
SettingsClosedPoints
|
|
344
343
|
|
|
345
344
|
type ToolsTriangleSettings = SettingsStrokeColor & SettingsFillColor & SettingsOpacity & SettingsLineWidth & SettingsLineDash
|
|
346
345
|
|
|
@@ -5,13 +5,7 @@ import type { ToolsType } from './../../common/types/tools';
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import './Canvas.css';
|
|
7
7
|
type DrawerType = {
|
|
8
|
-
disabled?: boolean;
|
|
9
8
|
canGrow?: boolean;
|
|
10
|
-
canvasSize: {
|
|
11
|
-
width: number;
|
|
12
|
-
height: number;
|
|
13
|
-
scaleRatio: number;
|
|
14
|
-
};
|
|
15
9
|
selectionColor: string;
|
|
16
10
|
selectionWidth: number;
|
|
17
11
|
settings: UtilsSettings;
|
|
@@ -19,23 +13,30 @@ type DrawerType = {
|
|
|
19
13
|
shapes: ShapeEntity[];
|
|
20
14
|
saveShapes: () => void;
|
|
21
15
|
addShape: (newShape: ShapeEntity) => void;
|
|
22
|
-
updateSingleShape: (updatedShape: ShapeEntity) => void;
|
|
16
|
+
updateSingleShape: (updatedShape: ShapeEntity, withSave?: boolean) => void;
|
|
23
17
|
selectedShape: ShapeEntity | undefined;
|
|
24
18
|
setSelectedShape: React.Dispatch<React.SetStateAction<ShapeEntity | undefined>>;
|
|
25
19
|
setSelectionFrame: React.Dispatch<React.SetStateAction<[Point, Point] | undefined>>;
|
|
26
20
|
hoveredShape: ShapeEntity | undefined;
|
|
27
21
|
selectionFrame: [Point, Point] | undefined;
|
|
28
|
-
refreshHoveredShape: (e: MouseEvent | TouchEvent, ctx: CanvasRenderingContext2D, cursorPosition: Point,
|
|
22
|
+
refreshHoveredShape: (e: MouseEvent | TouchEvent, ctx: CanvasRenderingContext2D, cursorPosition: Point, isInsideMask: boolean) => void;
|
|
29
23
|
refreshSelectedShapes: (ctx: CanvasRenderingContext2D, cursorPosition: Point, settings: UtilsSettings) => void;
|
|
30
24
|
activeTool: ToolsType;
|
|
31
25
|
setActiveTool: React.Dispatch<React.SetStateAction<ToolsType>>;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
canvasOffsetStartData: {
|
|
27
|
+
start: Point;
|
|
28
|
+
originalOffset: Point;
|
|
29
|
+
} | undefined;
|
|
30
|
+
setCanvasOffsetStartData: React.Dispatch<React.SetStateAction<{
|
|
31
|
+
start: Point;
|
|
32
|
+
originalOffset: Point;
|
|
33
|
+
} | undefined>>;
|
|
34
|
+
setCanvasOffset: (offset: Point) => void;
|
|
35
35
|
isInsideComponent: boolean;
|
|
36
36
|
selectionMode: SelectionModeData<number | Point>;
|
|
37
37
|
setSelectionMode: React.Dispatch<React.SetStateAction<SelectionModeData<number | Point>>>;
|
|
38
38
|
isShiftPressed: boolean;
|
|
39
|
+
isAltPressed: boolean;
|
|
39
40
|
withFrameSelection: boolean;
|
|
40
41
|
withSkeleton: boolean;
|
|
41
42
|
};
|
|
@@ -2,7 +2,6 @@ import type { UtilsSettings } from './../../canvas/constants/app';
|
|
|
2
2
|
import type { DrawableShape } from './../../common/types/Shapes';
|
|
3
3
|
import './EditTextBox.css';
|
|
4
4
|
type EditTextBoxType = {
|
|
5
|
-
scaleRatio: number;
|
|
6
5
|
disabled?: boolean;
|
|
7
6
|
shape: DrawableShape<'text'>;
|
|
8
7
|
defaultValue: string[];
|
|
@@ -10,5 +9,5 @@ type EditTextBoxType = {
|
|
|
10
9
|
updateValue: (newValue: string[]) => void;
|
|
11
10
|
saveShapes: () => void;
|
|
12
11
|
};
|
|
13
|
-
declare const EditTextBox: ({ disabled,
|
|
12
|
+
declare const EditTextBox: ({ disabled, shape, defaultValue, updateValue, saveShapes, settings }: EditTextBoxType) => import("react/jsx-runtime").JSX.Element;
|
|
14
13
|
export default EditTextBox;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Size } from './../../common/types/Canvas';
|
|
1
2
|
import type { ExportedDrawableShape, Point } from './../../common/types/Shapes';
|
|
2
3
|
import type { CustomToolInput } from './../../common/types/tools';
|
|
3
4
|
import type { RecursivePartial } from './../../common/types/utils';
|
|
@@ -10,12 +11,21 @@ export type UtilsSettings = {
|
|
|
10
11
|
isBrushShapeDoneOnMouseUp: boolean;
|
|
11
12
|
gridGap: number;
|
|
12
13
|
canvasOffset: Point;
|
|
14
|
+
canvasZoom: number;
|
|
13
15
|
canvasSize: {
|
|
16
|
+
realWidth: number;
|
|
17
|
+
realHeight: number;
|
|
14
18
|
width: number;
|
|
15
19
|
height: number;
|
|
16
20
|
scaleRatio: number;
|
|
21
|
+
scaleRatioWithNoZoom: number;
|
|
17
22
|
};
|
|
18
23
|
selectionPadding: number;
|
|
24
|
+
size: 'infinite' | 'fixed';
|
|
25
|
+
features: {
|
|
26
|
+
zoom: boolean;
|
|
27
|
+
edition: boolean;
|
|
28
|
+
};
|
|
19
29
|
};
|
|
20
30
|
type AppOptionsType = {
|
|
21
31
|
layersManipulation: boolean;
|
|
@@ -33,6 +43,8 @@ type AppOptionsType = {
|
|
|
33
43
|
brushAlgo: BrushAlgo;
|
|
34
44
|
isBrushShapeDoneOnMouseUp: boolean;
|
|
35
45
|
canvasSelectionPadding: number;
|
|
46
|
+
size: Size;
|
|
47
|
+
canZoom: 'never' | 'always';
|
|
36
48
|
};
|
|
37
49
|
export type OptionalOptions = RecursivePartial<AppOptionsType>;
|
|
38
50
|
export declare const DEFAULT_OPTIONS: AppOptionsType;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import type { UtilsSettings } from './../../canvas/constants/app';
|
|
1
2
|
import { type RefObject } from 'react';
|
|
2
3
|
type UseComponentType = {
|
|
3
|
-
|
|
4
|
-
componentRef: RefObject<HTMLElement>;
|
|
4
|
+
settings: UtilsSettings;
|
|
5
|
+
componentRef: RefObject<HTMLElement | null>;
|
|
5
6
|
};
|
|
6
|
-
declare const useComponent: ({
|
|
7
|
+
declare const useComponent: ({ settings, componentRef }: UseComponentType) => {
|
|
7
8
|
isInsideComponent: boolean;
|
|
8
9
|
};
|
|
9
10
|
export default useComponent;
|
|
@@ -4,31 +4,36 @@ import type { Point, 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
|
-
disabled?: boolean;
|
|
8
7
|
shapes: ShapeEntity[];
|
|
9
8
|
saveShapes: () => void;
|
|
10
9
|
addShape: (newShape: ShapeEntity) => void;
|
|
11
|
-
updateSingleShape: (updatedShape: ShapeEntity) => void;
|
|
10
|
+
updateSingleShape: (updatedShape: ShapeEntity, withSave?: boolean) => void;
|
|
12
11
|
selectedShape: ShapeEntity | undefined;
|
|
13
12
|
setSelectedShape: React.Dispatch<React.SetStateAction<ShapeEntity | undefined>>;
|
|
14
13
|
activeTool: ToolsType;
|
|
15
14
|
setActiveTool: React.Dispatch<React.SetStateAction<ToolsType>>;
|
|
16
|
-
refreshHoveredShape: (e: MouseEvent | TouchEvent, ctx: CanvasRenderingContext2D, cursorPosition: Point,
|
|
15
|
+
refreshHoveredShape: (e: MouseEvent | TouchEvent, ctx: CanvasRenderingContext2D, cursorPosition: Point, isInsideMask: boolean) => void;
|
|
17
16
|
refreshSelectedShapes: (ctx: CanvasRenderingContext2D, cursorPosition: Point, settings: UtilsSettings) => void;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
canvasOffsetStartData: {
|
|
18
|
+
start: Point;
|
|
19
|
+
originalOffset: Point;
|
|
20
|
+
} | undefined;
|
|
21
|
+
setCanvasOffsetStartData: React.Dispatch<React.SetStateAction<{
|
|
22
|
+
start: Point;
|
|
23
|
+
originalOffset: Point;
|
|
24
|
+
} | undefined>>;
|
|
25
|
+
setCanvasOffset: (offset: Point) => void;
|
|
21
26
|
isInsideComponent: boolean;
|
|
22
27
|
selectionMode: SelectionModeData<number | Point>;
|
|
23
28
|
setSelectionMode: React.Dispatch<React.SetStateAction<SelectionModeData<number | Point>>>;
|
|
24
29
|
setSelectionFrame: React.Dispatch<React.SetStateAction<[Point, Point] | undefined>>;
|
|
25
|
-
drawCanvasRef: React.
|
|
26
|
-
selectionCanvasRef: React.MutableRefObject<HTMLCanvasElement | null>;
|
|
30
|
+
drawCanvasRef: React.RefObject<HTMLCanvasElement | null>;
|
|
27
31
|
isShiftPressed: boolean;
|
|
32
|
+
isAltPressed: boolean;
|
|
28
33
|
withFrameSelection: boolean;
|
|
29
34
|
settings: UtilsSettings;
|
|
30
35
|
};
|
|
31
|
-
declare const useDrawableCanvas: ({
|
|
36
|
+
declare const useDrawableCanvas: ({ addShape, drawCanvasRef, setActiveTool, refreshHoveredShape, shapes, selectionMode, activeTool, isInsideComponent, setCanvasOffset, selectedShape, canvasOffsetStartData, refreshSelectedShapes, setSelectedShape, setSelectionFrame, setCanvasOffsetStartData, updateSingleShape, saveShapes, setSelectionMode, settings, isShiftPressed, isAltPressed, withFrameSelection }: UseCanvasType) => {
|
|
32
37
|
hoverMode: HoverModeData;
|
|
33
38
|
};
|
|
34
39
|
export default useDrawableCanvas;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { UtilsSettings } from './../../canvas/constants/app';
|
|
2
|
-
import type {
|
|
2
|
+
import type { SelectionModeData } from './../../common/types/Mode';
|
|
3
|
+
import type { Point, ShapeEntity } from './../../common/types/Shapes';
|
|
4
|
+
import type { ToolsType } from './../../common/types/tools';
|
|
3
5
|
type UseKeyboardType = {
|
|
4
6
|
isInsideComponent: boolean;
|
|
5
7
|
selectedShape: ShapeEntity | undefined;
|
|
@@ -10,8 +12,12 @@ type UseKeyboardType = {
|
|
|
10
12
|
backwardShape: () => void;
|
|
11
13
|
forwardShape: () => void;
|
|
12
14
|
setShiftPressed: (value: React.SetStateAction<boolean>) => void;
|
|
15
|
+
setAltPressed: (value: React.SetStateAction<boolean>) => void;
|
|
13
16
|
isEditingText: boolean;
|
|
17
|
+
setActiveTool: (tool: ToolsType) => void;
|
|
18
|
+
setSelectionMode: (mode: SelectionModeData<number | Point>) => void;
|
|
19
|
+
setSelectionFrame: (frame: [Point, Point] | undefined) => void;
|
|
14
20
|
settings: UtilsSettings;
|
|
15
21
|
};
|
|
16
|
-
declare const useKeyboard: ({ isInsideComponent, selectedShape, isEditingText, settings, setSelectedShape, removeShape, pasteShape, updateShape, backwardShape, forwardShape, setShiftPressed }: UseKeyboardType) => {};
|
|
22
|
+
declare const useKeyboard: ({ isInsideComponent, selectedShape, isEditingText, settings, setSelectedShape, setActiveTool, setSelectionMode, setSelectionFrame, removeShape, pasteShape, updateShape, backwardShape, forwardShape, setShiftPressed, setAltPressed }: UseKeyboardType) => {};
|
|
17
23
|
export default useKeyboard;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CanvasSize, Size } from './../../common/types/Canvas';
|
|
2
|
+
import type { Point } from './../../common/types/Shapes';
|
|
3
|
+
type UsePinchZoomProps = {
|
|
4
|
+
canvasElt: HTMLElement | null;
|
|
5
|
+
canvasTransformation: {
|
|
6
|
+
offset: Point;
|
|
7
|
+
zoom: number;
|
|
8
|
+
};
|
|
9
|
+
canvasSize: CanvasSize;
|
|
10
|
+
size: Size;
|
|
11
|
+
setCanvasTransformation: (transformation: {
|
|
12
|
+
offset: Point;
|
|
13
|
+
zoom: number;
|
|
14
|
+
}) => void;
|
|
15
|
+
};
|
|
16
|
+
declare const usePinchZoomAndMove: ({ canvasElt, canvasTransformation, canvasSize, size, setCanvasTransformation }: UsePinchZoomProps) => void;
|
|
17
|
+
export default usePinchZoomAndMove;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type OptionalOptions, type UtilsSettings } from './../../canvas/constants/app';
|
|
2
|
+
import type { CanvasSize } from './../../common/types/Canvas';
|
|
3
|
+
import type { SelectionModeData } from './../../common/types/Mode';
|
|
2
4
|
import type { ExportedDrawableShape, Point, ShapeEntity, StateData } from './../../common/types/Shapes';
|
|
3
5
|
import type { ToolsType } from './../../common/types/tools';
|
|
4
6
|
type UseReactPaintProps = {
|
|
@@ -10,8 +12,21 @@ type UseReactPaintProps = {
|
|
|
10
12
|
options?: OptionalOptions;
|
|
11
13
|
};
|
|
12
14
|
declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disabled, options }?: UseReactPaintProps) => {
|
|
15
|
+
annotationsProps: {
|
|
16
|
+
style: {
|
|
17
|
+
'user-select': string;
|
|
18
|
+
'touch-action': string;
|
|
19
|
+
transformOrigin: string;
|
|
20
|
+
transform: string;
|
|
21
|
+
'--react-paint-canvas-zoom': number;
|
|
22
|
+
'--react-paint-canvas-offset-x': number;
|
|
23
|
+
'--react-paint-canvas-offset-y': number;
|
|
24
|
+
'--react-paint-app-canvaswidth': number;
|
|
25
|
+
'--react-paint-app-canvasheight': number;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
13
28
|
editorProps: {
|
|
14
|
-
shapesRef: import("react").
|
|
29
|
+
shapesRef: import("react").RefObject<ShapeEntity[]>;
|
|
15
30
|
addPictureShape: (fileOrUrl: File | string, maxWidth?: number, maxHeight?: number) => Promise<ShapeEntity<"picture">>;
|
|
16
31
|
moveShapes: (startPositionShapeId: string, endPositionShapeId: string) => void;
|
|
17
32
|
toggleShapeVisibility: (shape: ShapeEntity) => void;
|
|
@@ -25,32 +40,27 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
|
|
|
25
40
|
backwardShape: () => void;
|
|
26
41
|
forwardShape: () => void;
|
|
27
42
|
refs: {
|
|
28
|
-
canvas: import("react").RefObject<HTMLCanvasElement>;
|
|
29
|
-
editor: import("react").
|
|
43
|
+
canvas: import("react").RefObject<HTMLCanvasElement | null>;
|
|
44
|
+
editor: import("react").RefObject<HTMLElement | null>;
|
|
30
45
|
setEditor: (node: HTMLElement | null) => void;
|
|
31
46
|
};
|
|
32
47
|
width: number;
|
|
33
48
|
height: number;
|
|
34
|
-
canvasSize: {
|
|
35
|
-
width: number;
|
|
36
|
-
height: number;
|
|
37
|
-
scaleRatio: number;
|
|
38
|
-
};
|
|
39
49
|
selectTool: (tool: ToolsType) => void;
|
|
40
50
|
selectShape: (shape: ShapeEntity) => void;
|
|
41
51
|
activeTool: ToolsType;
|
|
42
52
|
setActiveTool: import("react").Dispatch<import("react").SetStateAction<ToolsType>>;
|
|
43
53
|
setAvailableTools: import("react").Dispatch<import("react").SetStateAction<import("./../../common/types/tools").CustomTool[]>>;
|
|
44
54
|
isEditMode: boolean;
|
|
45
|
-
isDisabled: boolean;
|
|
46
55
|
availableTools: import("./../../common/types/tools").CustomTool[];
|
|
47
56
|
gridGap: number;
|
|
48
57
|
setGridGap: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
49
58
|
loadFile: (file: File) => Promise<void>;
|
|
50
|
-
exportPicture: () => void;
|
|
59
|
+
exportPicture: (view: "fitToShapes" | "defaultView" | "currentZoom") => void;
|
|
51
60
|
exportData: () => void;
|
|
52
61
|
clearCanvas: () => void;
|
|
53
62
|
settings: UtilsSettings;
|
|
63
|
+
setCanvasZoom: (action: "unzoom" | "zoom" | "default") => void;
|
|
54
64
|
canvas: {
|
|
55
65
|
canGrow: boolean;
|
|
56
66
|
canShrink: boolean;
|
|
@@ -62,7 +72,7 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
|
|
|
62
72
|
};
|
|
63
73
|
};
|
|
64
74
|
canvasProps: {
|
|
65
|
-
shapesRef: import("react").
|
|
75
|
+
shapesRef: import("react").RefObject<ShapeEntity[]>;
|
|
66
76
|
selectedShape: ShapeEntity | undefined;
|
|
67
77
|
selectionFrame: [Point, Point] | undefined;
|
|
68
78
|
hoveredShape: ShapeEntity | undefined;
|
|
@@ -70,49 +80,52 @@ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disa
|
|
|
70
80
|
setSelectedShape: import("react").Dispatch<import("react").SetStateAction<ShapeEntity | undefined>>;
|
|
71
81
|
setSelectionFrame: import("react").Dispatch<import("react").SetStateAction<[Point, Point] | undefined>>;
|
|
72
82
|
refreshSelectedShapes: (ctx: CanvasRenderingContext2D, cursorPosition: Point) => void;
|
|
73
|
-
refreshHoveredShape: (e: MouseEvent | TouchEvent, ctx: CanvasRenderingContext2D, cursorPosition: Point) => void;
|
|
83
|
+
refreshHoveredShape: (e: MouseEvent | TouchEvent, ctx: CanvasRenderingContext2D, cursorPosition: Point, isInsideMask: boolean) => void;
|
|
74
84
|
removeShape: (shape: ShapeEntity) => void;
|
|
75
85
|
updateShape: (updatedShape: ShapeEntity, withSave?: boolean) => void;
|
|
76
86
|
backwardShape: () => void;
|
|
77
87
|
forwardShape: () => void;
|
|
78
88
|
saveShapes: () => void;
|
|
79
89
|
refs: {
|
|
80
|
-
canvas: import("react").RefObject<HTMLCanvasElement>;
|
|
81
|
-
editor: import("react").
|
|
90
|
+
canvas: import("react").RefObject<HTMLCanvasElement | null>;
|
|
91
|
+
editor: import("react").RefObject<HTMLElement | null>;
|
|
82
92
|
setEditor: (node: HTMLElement | null) => void;
|
|
83
93
|
};
|
|
84
94
|
width: number;
|
|
85
95
|
height: number;
|
|
86
96
|
settings: UtilsSettings;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
scaleRatio: number;
|
|
91
|
-
};
|
|
92
|
-
setCanvasSize: import("react").Dispatch<import("react").SetStateAction<{
|
|
93
|
-
width: number;
|
|
94
|
-
height: number;
|
|
95
|
-
scaleRatio: number;
|
|
96
|
-
}>>;
|
|
97
|
-
setCanvasOffset: import("react").Dispatch<import("react").SetStateAction<Point>>;
|
|
97
|
+
setCanvasSize: import("react").Dispatch<import("react").SetStateAction<CanvasSize>>;
|
|
98
|
+
setCanvasOffset: (newOffset: Point) => void;
|
|
99
|
+
setCanvasZoom: (action: "unzoom" | "zoom" | "default") => void;
|
|
98
100
|
selectShape: (shape: ShapeEntity) => void;
|
|
99
101
|
activeTool: ToolsType;
|
|
100
102
|
setActiveTool: import("react").Dispatch<import("react").SetStateAction<ToolsType>>;
|
|
101
103
|
isInsideComponent: boolean;
|
|
102
104
|
isEditMode: boolean;
|
|
103
|
-
isDisabled: boolean;
|
|
104
105
|
canvas: {
|
|
105
106
|
withSkeleton: boolean;
|
|
106
107
|
withFrameSelection: boolean;
|
|
107
108
|
canGrow: boolean;
|
|
108
109
|
canShrink: boolean;
|
|
109
110
|
};
|
|
111
|
+
canvasOffsetStartData: {
|
|
112
|
+
start: Point;
|
|
113
|
+
originalOffset: Point;
|
|
114
|
+
} | undefined;
|
|
115
|
+
setCanvasOffsetStartData: import("react").Dispatch<import("react").SetStateAction<{
|
|
116
|
+
start: Point;
|
|
117
|
+
originalOffset: Point;
|
|
118
|
+
} | undefined>>;
|
|
119
|
+
selectionMode: SelectionModeData<number | Point>;
|
|
120
|
+
setSelectionMode: import("react").Dispatch<import("react").SetStateAction<SelectionModeData<number | Point>>>;
|
|
110
121
|
};
|
|
111
122
|
registerEvent: (event: "dataChanged", fn: (data: StateData, source: "user" | "remote") => void) => void;
|
|
112
123
|
unregisterEvent: (event: "dataChanged", fn?: (data: StateData, source: "user" | "remote") => void) => void;
|
|
113
124
|
resetCanvas: (json?: ExportedDrawableShape[], clearHistory?: boolean) => void;
|
|
114
|
-
getCurrentImage: () => string
|
|
125
|
+
getCurrentImage: (view: "fitToShapes" | "defaultView" | "currentZoom") => string;
|
|
115
126
|
getCurrentData: () => StateData;
|
|
127
|
+
setCanvasOffset: (newOffset: Point) => void;
|
|
128
|
+
setCanvasZoom: (action: "unzoom" | "zoom" | "default") => void;
|
|
116
129
|
};
|
|
117
130
|
export type UseReactPaintReturnType = ReturnType<typeof useReactPaint>;
|
|
118
131
|
export default useReactPaint;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
type UseResizeObserverType = {
|
|
2
|
-
element: React.RefObject<HTMLElement>;
|
|
2
|
+
element: React.RefObject<HTMLElement | null>;
|
|
3
3
|
onResized: (width: number, height: number) => unknown;
|
|
4
4
|
};
|
|
5
5
|
declare const useResizeObserver: ({ onResized, element }: UseResizeObserverType) => void;
|
|
@@ -3,7 +3,7 @@ import type { Point, ShapeEntity, StateData } from './../../common/types/Shapes'
|
|
|
3
3
|
declare const useShapes: (settings: UtilsSettings, width: number, height: number) => {
|
|
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
|
-
shapesRef: import("react").
|
|
6
|
+
shapesRef: import("react").RefObject<ShapeEntity[]>;
|
|
7
7
|
selectedShape: ShapeEntity | undefined;
|
|
8
8
|
hoveredShape: ShapeEntity | undefined;
|
|
9
9
|
selectionFrame: [Point, Point] | undefined;
|
|
@@ -14,7 +14,7 @@ declare const useShapes: (settings: UtilsSettings, width: number, height: number
|
|
|
14
14
|
moveShapes: (startPositionShapeId: string, endPositionShapeId: string) => void;
|
|
15
15
|
saveShapes: () => void;
|
|
16
16
|
setSelectedShape: import("react").Dispatch<import("react").SetStateAction<ShapeEntity | undefined>>;
|
|
17
|
-
refreshHoveredShape: (e: MouseEvent | TouchEvent, ctx: CanvasRenderingContext2D, cursorPosition: Point) => void;
|
|
17
|
+
refreshHoveredShape: (e: MouseEvent | TouchEvent, ctx: CanvasRenderingContext2D, cursorPosition: Point, isInsideMask: boolean) => void;
|
|
18
18
|
toggleShapeVisibility: (shape: ShapeEntity) => void;
|
|
19
19
|
toggleShapeLock: (shape: ShapeEntity) => void;
|
|
20
20
|
removeShape: (shape: ShapeEntity) => void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CanvasSize, Size } from './../../common/types/Canvas';
|
|
2
|
+
import type { Point } from './../../common/types/Shapes';
|
|
3
|
+
type UseZoomProps = {
|
|
4
|
+
canvasSize: CanvasSize;
|
|
5
|
+
size: Size;
|
|
6
|
+
canvasElt: HTMLCanvasElement | null;
|
|
7
|
+
zoomEnabled: boolean;
|
|
8
|
+
};
|
|
9
|
+
declare const useZoom: ({ canvasSize, size, zoomEnabled, canvasElt }: UseZoomProps) => {
|
|
10
|
+
setCanvasTransformation: import("react").Dispatch<import("react").SetStateAction<{
|
|
11
|
+
offset: Point;
|
|
12
|
+
zoom: number;
|
|
13
|
+
}>>;
|
|
14
|
+
setCanvasOffset: (newOffset: Point) => void;
|
|
15
|
+
setCanvasZoom: (action: "unzoom" | "zoom" | "default") => void;
|
|
16
|
+
canvasTransformation: {
|
|
17
|
+
offset: Point;
|
|
18
|
+
zoom: number;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export default useZoom;
|
|
@@ -6,7 +6,11 @@ export declare const fetchAndStringify: (url: string) => Promise<string>;
|
|
|
6
6
|
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
|
-
export declare const getCanvasImage: (shapes
|
|
9
|
+
export declare const getCanvasImage: ({ shapes, settings, view }: {
|
|
10
|
+
shapes: DrawableShape[];
|
|
11
|
+
settings: UtilsSettings;
|
|
12
|
+
view: "fitToShapes" | "defaultView" | "currentZoom";
|
|
13
|
+
}) => string;
|
|
10
14
|
export declare const encodeShapesInString: (shapes: DrawableShape[], width: number, height: number) => string;
|
|
11
15
|
export declare const decodeJson: (file: File) => Promise<unknown>;
|
|
12
16
|
export declare const decodeImportedData: (shapesForJson: ExportedDrawableShape[], settings: UtilsSettings) => Promise<ShapeEntity[]>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { UtilsSettings } from './../../canvas/constants/app';
|
|
2
|
-
export declare const drawGrid: (ctx: CanvasRenderingContext2D,
|
|
2
|
+
export declare const drawGrid: (ctx: CanvasRenderingContext2D, settings: UtilsSettings) => void;
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import type { UtilsSettings } from './../../canvas/constants/app';
|
|
2
|
+
import type { CanvasSize } from './../../common/types/Canvas';
|
|
2
3
|
import type { HoverModeData } from './../../common/types/Mode';
|
|
3
4
|
import type { DrawableShape, Point, Rect } from './../../common/types/Shapes';
|
|
4
|
-
export declare const getCursorPosition: (e: MouseEvent | TouchEvent
|
|
5
|
+
export declare const getCursorPosition: (e: MouseEvent | TouchEvent) => {
|
|
6
|
+
clientX: number;
|
|
7
|
+
clientY: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const getCursorPositionInElement: (e: MouseEvent | TouchEvent, element: HTMLElement, canvasSize: CanvasSize) => Point;
|
|
10
|
+
export declare const getCursorPositionInTransformedCanvas: (e: MouseEvent | TouchEvent, canvas: HTMLElement | null, settings: UtilsSettings) => Point;
|
|
5
11
|
export declare const isTouchGesture: (e: MouseEvent | TouchEvent) => e is TouchEvent;
|
|
6
|
-
export declare const getPointPositionAfterCanvasTransformation: (point: Point, shapeRotation: number, [originX, originY]: Point
|
|
7
|
-
export declare const getPointPositionBeforeCanvasTransformation: (point: Point, shapeRotation: number, [originX, originY]: Point
|
|
12
|
+
export declare const getPointPositionAfterCanvasTransformation: (point: Point, shapeRotation: number, [originX, originY]: Point) => Point;
|
|
13
|
+
export declare const getPointPositionBeforeCanvasTransformation: (point: Point, shapeRotation: number, [originX, originY]: Point) => Point;
|
|
8
14
|
export declare const checkSelectionIntersection: (shape: DrawableShape, position: Point, settings: UtilsSettings, checkAnchors?: boolean, radius?: number) => false | HoverModeData;
|
|
15
|
+
export declare const checkPolygonLinesSelectionIntersection: (ctx: CanvasRenderingContext2D, shape: DrawableShape<"polygon" | "curve">, position: Point, settings: UtilsSettings, radius?: number) => false | {
|
|
16
|
+
lineIndex: number;
|
|
17
|
+
};
|
|
9
18
|
export declare const checkPositionIntersection: (ctx: CanvasRenderingContext2D, shape: DrawableShape, position: Point, settings: UtilsSettings) => false | HoverModeData;
|
|
10
19
|
export declare function getRectIntersection(rect1: Rect, rect2: Rect): Rect | undefined;
|
|
11
20
|
export declare const checkSelectionFrameCollision: (ctx: CanvasRenderingContext2D, shape: DrawableShape, selectionFrame: [Point, Point], settings: UtilsSettings) => boolean;
|
|
@@ -2,7 +2,7 @@ import type { UtilsSettings } from './../../../canvas/constants/app';
|
|
|
2
2
|
import type { DrawableShape, Point, SelectionLinesType } from './../../../common/types/Shapes';
|
|
3
3
|
export declare const createLineSelectionPath: (path: Path2D | undefined, shape: DrawableShape<"line" | "polygon" | "curve"> & {
|
|
4
4
|
points: readonly Point[];
|
|
5
|
-
}, settings: UtilsSettings
|
|
5
|
+
}, settings: UtilsSettings) => SelectionLinesType;
|
|
6
6
|
export declare const drawLineSelection: ({ ctx, shape, withAnchors, selectionWidth, selectionColor, settings }: {
|
|
7
7
|
ctx: CanvasRenderingContext2D;
|
|
8
8
|
shape: DrawableShape<"line"> | DrawableShape<"polygon"> | DrawableShape<"curve">;
|
|
@@ -5,7 +5,7 @@ export declare const createRecSelectionPath: (path: Path2D | undefined, rect: Dr
|
|
|
5
5
|
export declare const drawSelectionRect: (ctx: CanvasRenderingContext2D, shape: DrawableShape & {
|
|
6
6
|
selection?: SelectionDefaultType;
|
|
7
7
|
}, selectionColor: string, selectionWidth: number, settings: UtilsSettings, withAnchors: boolean) => void;
|
|
8
|
-
export declare const resizeRectSelection: (cursorPosition: Point, originalShape: DrawableShape, selectionMode: SelectionModeResize, settings: UtilsSettings, keepRatio?: boolean) => {
|
|
8
|
+
export declare const resizeRectSelection: (cursorPosition: Point, originalShape: DrawableShape, selectionMode: SelectionModeResize, settings: UtilsSettings, keepRatio?: boolean, resizeFromCenter?: boolean) => {
|
|
9
9
|
borderX: number;
|
|
10
10
|
borderHeight: number;
|
|
11
11
|
borderY: number;
|
|
@@ -10,10 +10,10 @@ export declare const createBrush: (shape: {
|
|
|
10
10
|
}, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"brush">;
|
|
11
11
|
export declare const drawBrush: (ctx: CanvasRenderingContext2D, shape: DrawableShape<"brush">) => void;
|
|
12
12
|
export declare const getBrushBorder: (brush: DrawableShape<"brush">, { selectionPadding }: UtilsSettings) => Rect;
|
|
13
|
-
export declare const translateBrush: <U extends DrawableShape<"brush">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings) => U & {
|
|
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
|
};
|
|
16
|
-
export declare const resizeBrush: (cursorPosition: Point, originalShape: DrawableShape<"brush">, selectionMode: SelectionModeResize, settings: UtilsSettings, keepRatio: boolean) => DrawableShape<"brush">;
|
|
16
|
+
export declare const resizeBrush: (cursorPosition: Point, originalShape: DrawableShape<"brush">, selectionMode: SelectionModeResize, settings: UtilsSettings, keepRatio: boolean, resizeFromCenter: boolean) => DrawableShape<"brush">;
|
|
17
17
|
export declare const addNewPointToShape: <T extends DrawableShape<"brush">>(shape: T, cursorPosition: Point, settings: UtilsSettings) => T & {
|
|
18
18
|
points: Point[][];
|
|
19
19
|
};
|
|
@@ -10,8 +10,8 @@ export declare const createCircle: (shape: {
|
|
|
10
10
|
}, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"circle">;
|
|
11
11
|
export declare const drawCircle: (ctx: CanvasRenderingContext2D, circle: DrawableShape<"circle">) => void;
|
|
12
12
|
export declare const getCircleBorder: (circle: Circle, settings: UtilsSettings) => Rect;
|
|
13
|
-
export declare const translateCircle: <U extends DrawableShape<"circle">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings) => U & {
|
|
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;
|
|
16
16
|
};
|
|
17
|
-
export declare const resizeCircle: (cursorPosition: Point, originalShape: DrawableShape<"circle">, selectionMode: SelectionModeResize, settings: UtilsSettings) => DrawableShape<"circle">;
|
|
17
|
+
export declare const resizeCircle: (cursorPosition: Point, originalShape: DrawableShape<"circle">, selectionMode: SelectionModeResize, settings: UtilsSettings, resizeFromCenter: boolean) => DrawableShape<"circle">;
|
|
@@ -11,7 +11,8 @@ export declare const createCurve: (shape: {
|
|
|
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
13
|
export declare const getCurveBorder: (polygon: import("./../../../common/types/Shapes").Polygon, settings: UtilsSettings) => import("./../../../common/types/Shapes").Rect;
|
|
14
|
-
export declare const translateCurve: <U extends DrawableShape<"curve">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings) => U & {
|
|
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
|
};
|
|
17
|
-
export declare const
|
|
17
|
+
export declare const addCurveLine: <T extends DrawableShape<"curve">>(shape: T, lineIndex: number, settings: UtilsSettings) => T;
|
|
18
|
+
export declare const addCurvePoint: <T extends DrawableShape<"curve">>(shape: T, cursorPosition: Point, settings: UtilsSettings, temporary?: boolean) => T;
|
|
@@ -10,8 +10,8 @@ export declare const createEllipse: (shape: {
|
|
|
10
10
|
}, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"ellipse">;
|
|
11
11
|
export declare const drawEllipse: (ctx: CanvasRenderingContext2D, ellipse: DrawableShape<"ellipse">) => void;
|
|
12
12
|
export declare const getEllipseBorder: (ellipse: Ellipse, settings: UtilsSettings) => Rect;
|
|
13
|
-
export declare const translateEllipse: <U extends DrawableShape<"ellipse">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings) => U & {
|
|
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;
|
|
16
16
|
};
|
|
17
|
-
export declare const resizeEllipse: (cursorPosition: Point, originalShape: DrawableShape<"ellipse">, selectionMode: SelectionModeResize, settings: UtilsSettings, keepRatio?: boolean) => DrawableShape<"ellipse">;
|
|
17
|
+
export declare const resizeEllipse: (cursorPosition: Point, originalShape: DrawableShape<"ellipse">, selectionMode: SelectionModeResize, settings: UtilsSettings, keepRatio?: boolean, resizeFromCenter?: boolean) => DrawableShape<"ellipse">;
|
|
@@ -8,13 +8,14 @@ export declare const createShape: (ctx: CanvasRenderingContext2D, shape: Exclude
|
|
|
8
8
|
export declare const drawShape: (ctx: CanvasRenderingContext2D, shape: DrawableShape, settings: UtilsSettings) => void;
|
|
9
9
|
export declare const getShapeInfos: (shape: DrawableShape, settings: UtilsSettings) => {
|
|
10
10
|
borders: Rect;
|
|
11
|
+
outerBorders: Rect;
|
|
11
12
|
center: Point;
|
|
12
13
|
};
|
|
13
|
-
export declare const rotateShape: <T extends DrawableShape>(shape: T, cursorPosition: Point, originalShape: T, originalCursorPosition: Point, shapeCenter: Point, settings: UtilsSettings) => T & {
|
|
14
|
+
export declare const rotateShape: <T extends DrawableShape>(shape: T, cursorPosition: Point, originalShape: T, originalCursorPosition: Point, shapeCenter: Point, settings: UtilsSettings, isShiftPressed: boolean) => T & {
|
|
14
15
|
rotation: number;
|
|
15
16
|
};
|
|
16
|
-
export declare const resizeShape: <T extends DrawableShape>(ctx: CanvasRenderingContext2D, shape: T, cursorPosition: Point, originalShape: T, selectionMode: SelectionModeData<Point | number>, settings: UtilsSettings, isShiftPressed: boolean) => T;
|
|
17
|
-
export declare const translateShape: (cursorPosition: Point, originalShape: ShapeEntity, originalCursorPosition: Point, settings: UtilsSettings) => ShapeEntity;
|
|
17
|
+
export declare const resizeShape: <T extends DrawableShape>(ctx: CanvasRenderingContext2D, shape: T, cursorPosition: Point, originalShape: T, selectionMode: SelectionModeData<Point | number>, settings: UtilsSettings, isShiftPressed: boolean, isAltPressed: boolean) => T;
|
|
18
|
+
export declare const translateShape: (cursorPosition: Point, originalShape: ShapeEntity, originalCursorPosition: Point, settings: UtilsSettings, isShiftPressed: boolean) => ShapeEntity;
|
|
18
19
|
export declare const refreshShape: (shape: ShapeEntity, settings: UtilsSettings) => ShapeEntity;
|
|
19
20
|
export declare const drawShapeSelection: ({ ctx, shape, settings, selectionWidth, selectionColor, withAnchors }: {
|
|
20
21
|
ctx: CanvasRenderingContext2D;
|
|
@@ -11,7 +11,7 @@ export declare const createLine: (shape: {
|
|
|
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
13
|
export declare const getLineBorder: (line: Line, settings: UtilsSettings) => Rect;
|
|
14
|
-
export declare const translateLine: <U extends DrawableShape<"line">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings) => U & {
|
|
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
|
};
|
|
17
17
|
export declare const resizeLine: <U extends DrawableShape<"line">>(cursorPosition: Point, originalShape: U, selectionMode: SelectionModeResize<number>, settings: UtilsSettings) => U;
|