@yorab/react-paint 0.12.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -8
- package/dist/canvas/components/Canvas.d.ts +2 -1
- package/dist/canvas/hooks/useDrawableCanvas.d.ts +3 -2
- package/dist/canvas/hooks/useKeyboard.d.ts +8 -2
- package/dist/canvas/utils/intersect.d.ts +7 -1
- 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 +3 -3
- package/dist/canvas/utils/shapes/line.d.ts +1 -1
- package/dist/canvas/utils/shapes/path.d.ts +4 -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 +2 -2
- package/dist/canvas/utils/shapes/text.d.ts +2 -2
- package/dist/canvas/utils/transform.d.ts +3 -2
- package/dist/common/types/Mode.d.ts +4 -1
- package/dist/common/types/Shapes.d.ts +3 -1
- package/dist/common/types/tools.d.ts +4 -7
- package/dist/editor/components/settings/ClosedPointsField.d.ts +10 -0
- package/dist/react-paint.js +1146 -1063
- package/dist/react-paint.umd.cjs +1 -1
- package/package.json +6 -6
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
|
}
|
|
@@ -306,11 +306,8 @@ type SettingsFont = {
|
|
|
306
306
|
}
|
|
307
307
|
}
|
|
308
308
|
|
|
309
|
-
type
|
|
310
|
-
|
|
311
|
-
min: number
|
|
312
|
-
max: number
|
|
313
|
-
step: number
|
|
309
|
+
type SettingsClosedPoints = {
|
|
310
|
+
closedPoints: {
|
|
314
311
|
default: number
|
|
315
312
|
hidden?: boolean
|
|
316
313
|
}
|
|
@@ -335,14 +332,14 @@ type ToolsPolygonSettings = SettingsOpacity &
|
|
|
335
332
|
SettingsFillColor &
|
|
336
333
|
SettingsLineWidth &
|
|
337
334
|
SettingsLineDash &
|
|
338
|
-
|
|
335
|
+
SettingsClosedPoints
|
|
339
336
|
|
|
340
337
|
type ToolsCurveSettings = SettingsOpacity &
|
|
341
338
|
SettingsStrokeColor &
|
|
342
339
|
SettingsFillColor &
|
|
343
340
|
SettingsLineWidth &
|
|
344
341
|
SettingsLineDash &
|
|
345
|
-
|
|
342
|
+
SettingsClosedPoints
|
|
346
343
|
|
|
347
344
|
type ToolsTriangleSettings = SettingsStrokeColor & SettingsFillColor & SettingsOpacity & SettingsLineWidth & SettingsLineDash
|
|
348
345
|
|
|
@@ -13,7 +13,7 @@ type DrawerType = {
|
|
|
13
13
|
shapes: ShapeEntity[];
|
|
14
14
|
saveShapes: () => void;
|
|
15
15
|
addShape: (newShape: ShapeEntity) => void;
|
|
16
|
-
updateSingleShape: (updatedShape: ShapeEntity) => void;
|
|
16
|
+
updateSingleShape: (updatedShape: ShapeEntity, withSave?: boolean) => void;
|
|
17
17
|
selectedShape: ShapeEntity | undefined;
|
|
18
18
|
setSelectedShape: React.Dispatch<React.SetStateAction<ShapeEntity | undefined>>;
|
|
19
19
|
setSelectionFrame: React.Dispatch<React.SetStateAction<[Point, Point] | undefined>>;
|
|
@@ -36,6 +36,7 @@ type DrawerType = {
|
|
|
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
|
};
|
|
@@ -7,7 +7,7 @@ type UseCanvasType = {
|
|
|
7
7
|
shapes: ShapeEntity[];
|
|
8
8
|
saveShapes: () => void;
|
|
9
9
|
addShape: (newShape: ShapeEntity) => void;
|
|
10
|
-
updateSingleShape: (updatedShape: ShapeEntity) => void;
|
|
10
|
+
updateSingleShape: (updatedShape: ShapeEntity, withSave?: boolean) => void;
|
|
11
11
|
selectedShape: ShapeEntity | undefined;
|
|
12
12
|
setSelectedShape: React.Dispatch<React.SetStateAction<ShapeEntity | undefined>>;
|
|
13
13
|
activeTool: ToolsType;
|
|
@@ -29,10 +29,11 @@ type UseCanvasType = {
|
|
|
29
29
|
setSelectionFrame: React.Dispatch<React.SetStateAction<[Point, Point] | undefined>>;
|
|
30
30
|
drawCanvasRef: React.RefObject<HTMLCanvasElement | null>;
|
|
31
31
|
isShiftPressed: boolean;
|
|
32
|
+
isAltPressed: boolean;
|
|
32
33
|
withFrameSelection: boolean;
|
|
33
34
|
settings: UtilsSettings;
|
|
34
35
|
};
|
|
35
|
-
declare const useDrawableCanvas: ({ addShape, drawCanvasRef, setActiveTool, refreshHoveredShape, shapes, selectionMode, activeTool, isInsideComponent, setCanvasOffset, selectedShape, canvasOffsetStartData, refreshSelectedShapes, setSelectedShape, setSelectionFrame, setCanvasOffsetStartData, updateSingleShape, saveShapes, setSelectionMode, settings, isShiftPressed, withFrameSelection }: UseCanvasType) => {
|
|
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) => {
|
|
36
37
|
hoverMode: HoverModeData;
|
|
37
38
|
};
|
|
38
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;
|
|
@@ -11,7 +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: (shape: DrawableShape, position: Point, settings: UtilsSettings, checkAnchors?: boolean, radius?: number) => false | HoverModeData;
|
|
14
|
+
export declare const checkSelectionIntersection: (ctx: CanvasRenderingContext2D, 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
|
+
};
|
|
18
|
+
export declare const checkCurveLinesSelectionIntersection: (ctx: CanvasRenderingContext2D, shape: DrawableShape<"curve">, position: Point, settings: UtilsSettings, radius?: number) => false | {
|
|
19
|
+
lineIndex: number;
|
|
20
|
+
};
|
|
15
21
|
export declare const checkPositionIntersection: (ctx: CanvasRenderingContext2D, shape: DrawableShape, position: Point, settings: UtilsSettings) => false | HoverModeData;
|
|
16
22
|
export declare function getRectIntersection(rect1: Rect, rect2: Rect): Rect | undefined;
|
|
17
23
|
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, cursorPosition: Point, 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">;
|
|
@@ -11,11 +11,11 @@ export declare const getShapeInfos: (shape: DrawableShape, settings: UtilsSettin
|
|
|
11
11
|
outerBorders: Rect;
|
|
12
12
|
center: Point;
|
|
13
13
|
};
|
|
14
|
-
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 & {
|
|
15
15
|
rotation: number;
|
|
16
16
|
};
|
|
17
|
-
export declare const resizeShape: <T extends DrawableShape>(ctx: CanvasRenderingContext2D, shape: T, cursorPosition: Point, originalShape: T, selectionMode: SelectionModeData<Point | number>, settings: UtilsSettings, isShiftPressed: boolean) => T;
|
|
18
|
-
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;
|
|
19
19
|
export declare const refreshShape: (shape: ShapeEntity, settings: UtilsSettings) => ShapeEntity;
|
|
20
20
|
export declare const drawShapeSelection: ({ ctx, shape, settings, selectionWidth, selectionColor, withAnchors }: {
|
|
21
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;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { UtilsSettings } from './../../../canvas/constants/app';
|
|
2
|
-
import type { Circle, DrawableShape, Line, Rect } from './../../../common/types/Shapes';
|
|
2
|
+
import type { Circle, DrawableShape, Line, Point, Rect } from './../../../common/types/Shapes';
|
|
3
3
|
export declare const createRecPath: (rect: Rect) => Path2D;
|
|
4
4
|
export declare const createCirclePath: (shape: Circle) => Path2D;
|
|
5
5
|
export declare const createEllipsePath: (ellipse: DrawableShape<"ellipse">) => Path2D;
|
|
6
6
|
export declare const createLinePath: (line: Line) => Path2D;
|
|
7
7
|
export declare const createBrushPath: (brush: DrawableShape<"brush">, { brushAlgo }: UtilsSettings) => Path2D | undefined;
|
|
8
|
+
export declare const getCatmullRomPoints: (curve: DrawableShape<"curve">, points: Point[]) => [number, number][];
|
|
9
|
+
export declare const catmullRomToBezier: (path: Path2D, p0: Point, p1: Point, p2: Point, p3: Point) => void;
|
|
8
10
|
export declare const createCurvePath: (curve: DrawableShape<"curve">) => Path2D | undefined;
|
|
9
|
-
export declare const createPolygonPath: (polygon: DrawableShape<"polygon">) => Path2D | undefined;
|
|
11
|
+
export declare const createPolygonPath: (polygon: DrawableShape<"polygon"> | DrawableShape<"curve">) => Path2D | undefined;
|
|
10
12
|
export declare const createTrianglePath: (triangle: DrawableShape<"triangle">) => Path2D;
|
|
@@ -5,8 +5,8 @@ export declare const refreshPicture: <T extends DrawableShape<"picture">>(shape:
|
|
|
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
7
|
export declare const getPictureBorder: (picture: Picture, settings: UtilsSettings) => Rect;
|
|
8
|
-
export declare const translatePicture: <U extends DrawableShape<"picture">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings) => U & {
|
|
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;
|
|
11
11
|
};
|
|
12
|
-
export declare const resizePicture: (cursorPosition: Point, originalShape: DrawableShape<"picture">, selectionMode: SelectionModeResize, settings: UtilsSettings) => DrawableShape<"picture">;
|
|
12
|
+
export declare const resizePicture: (cursorPosition: Point, originalShape: DrawableShape<"picture">, selectionMode: SelectionModeResize, settings: UtilsSettings, resizeFromCenter: boolean) => DrawableShape<"picture">;
|
|
@@ -10,8 +10,9 @@ export declare const createPolygon: (shape: {
|
|
|
10
10
|
}, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"polygon">;
|
|
11
11
|
export declare const drawPolygon: (ctx: CanvasRenderingContext2D, polygon: DrawableShape<"polygon">) => void;
|
|
12
12
|
export declare const getPolygonBorder: (polygon: Polygon, settings: UtilsSettings) => Rect;
|
|
13
|
-
export declare const translatePolygon: <U extends DrawableShape<"polygon">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings) => U & {
|
|
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
|
};
|
|
16
16
|
export declare const resizePolygon: (cursorPosition: Point, originalShape: DrawableShape<"polygon">, selectionMode: SelectionModeResize<number>, settings: UtilsSettings) => DrawableShape<"polygon">;
|
|
17
|
-
export declare const
|
|
17
|
+
export declare const addPolygonLine: <T extends DrawableShape<"polygon">>(shape: T, lineIndex: number, cursorPosition: Point, settings: UtilsSettings) => T;
|
|
18
|
+
export declare const addPolygonPoint: <T extends DrawableShape<"polygon">>(shape: T, cursorPosition: Point, settings: UtilsSettings, temporary?: boolean) => T;
|
|
@@ -12,9 +12,9 @@ export declare const createRectangle: <T extends "rect" | "square">(shape: {
|
|
|
12
12
|
export declare const drawRect: (ctx: CanvasRenderingContext2D, shape: DrawableShape<"rect" | "square">) => void;
|
|
13
13
|
export declare const getRectBorder: (rect: Rect, settings: UtilsSettings) => Rect;
|
|
14
14
|
export declare const getRectOppositeAnchorAbsolutePosition: <T extends DrawableShape & Rect>(anchor: Point, center: Point, shape: T, [negW, negH]?: [boolean, boolean]) => Point;
|
|
15
|
-
export declare const translateRect: <T extends "rect" | "square", U extends DrawableShape<T>>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings) => U & {
|
|
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;
|
|
17
17
|
y: number;
|
|
18
18
|
};
|
|
19
|
-
export declare const resizeRect: <T extends rectish>(cursorPosition: Point, originalShape: DrawableShape<T>, selectionMode: SelectionModeResize, settings: UtilsSettings, keepRatio?: boolean) => DrawableShape<T>;
|
|
19
|
+
export declare const resizeRect: <T extends rectish>(cursorPosition: Point, originalShape: DrawableShape<T>, selectionMode: SelectionModeResize, settings: UtilsSettings, keepRatio?: boolean, resizeFromCenter?: boolean) => DrawableShape<T>;
|
|
20
20
|
export {};
|
|
@@ -11,9 +11,9 @@ export declare const createText: (ctx: CanvasRenderingContext2D, shape: {
|
|
|
11
11
|
}, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"text">;
|
|
12
12
|
export declare const drawText: (ctx: CanvasRenderingContext2D, text: DrawableShape<"text">) => void;
|
|
13
13
|
export declare const getTextBorder: (text: Text, settings: UtilsSettings) => Rect;
|
|
14
|
-
export declare const translateText: <U extends DrawableShape<"text">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings) => U & {
|
|
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;
|
|
17
17
|
};
|
|
18
|
-
export declare const resizeText: (ctx: CanvasRenderingContext2D, cursorPosition: Point, originalShape: DrawableShape<"text">, selectionMode: SelectionModeResize, settings: UtilsSettings) => DrawableShape<"text">;
|
|
18
|
+
export declare const resizeText: (ctx: CanvasRenderingContext2D, cursorPosition: Point, originalShape: DrawableShape<"text">, selectionMode: SelectionModeResize, settings: UtilsSettings, resizeFromCenter: boolean) => DrawableShape<"text">;
|
|
19
19
|
export declare const resizeTextShapeWithNewContent: <U extends DrawableShape<"text">>(ctx: CanvasRenderingContext2D, shape: U, newValue: string[], settings: UtilsSettings) => U;
|
|
@@ -5,8 +5,9 @@ export declare const getNormalizedSize: (originalWidth: number, originalHeight:
|
|
|
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
|
-
export declare const roundRotationForGrid: (rotation: number, settings: UtilsSettings) => number;
|
|
9
|
-
export declare const
|
|
8
|
+
export declare const roundRotationForGrid: (rotation: number, settings: UtilsSettings, isShiftPressed: boolean) => number;
|
|
9
|
+
export declare const boundVectorToSingleAxis: (vector: Point, isShiftPressed: boolean) => number[];
|
|
10
|
+
export declare const transformShape: (ctx: CanvasRenderingContext2D, shape: ShapeEntity, cursorPosition: Point, selectionMode: SelectionModeData<Point | number>, settings: UtilsSettings, isShiftPressed: boolean, isAltPressed: boolean) => ShapeEntity;
|
|
10
11
|
export declare const fitContentInsideContainer: (contentWidth: number, contentHeight: number, containerWidth: number, containerHeight: number, shouldFillContainer?: boolean) => number[];
|
|
11
12
|
export declare const shortenLine: ({ line, size, direction }: {
|
|
12
13
|
line: DrawableShape<"line">;
|
|
@@ -8,6 +8,9 @@ export type SelectionModeSelectionFrame = {
|
|
|
8
8
|
export type SelectionModeBrush = {
|
|
9
9
|
mode: 'brush';
|
|
10
10
|
};
|
|
11
|
+
export type SelectionModePreview = {
|
|
12
|
+
mode: 'preview';
|
|
13
|
+
};
|
|
11
14
|
export type SelectionModeEditText = {
|
|
12
15
|
mode: 'textedition';
|
|
13
16
|
defaultValue: string[];
|
|
@@ -29,7 +32,7 @@ export type SelectionModeTranslate = {
|
|
|
29
32
|
cursorStartPosition: Point;
|
|
30
33
|
originalShape: ShapeEntity;
|
|
31
34
|
};
|
|
32
|
-
export type SelectionModeData<AnchorType extends Point | number> = SelectionModeDefault | SelectionModeSelectionFrame | SelectionModeBrush | SelectionModeResize<AnchorType> | SelectionModeRotate | SelectionModeTranslate | SelectionModeEditText;
|
|
35
|
+
export type SelectionModeData<AnchorType extends Point | number> = SelectionModeDefault | SelectionModeSelectionFrame | SelectionModeBrush | SelectionModeResize<AnchorType> | SelectionModeRotate | SelectionModeTranslate | SelectionModeEditText | SelectionModePreview;
|
|
33
36
|
export type HoverModeData = {
|
|
34
37
|
outOfView?: boolean;
|
|
35
38
|
} & ({
|
|
@@ -22,9 +22,11 @@ export type Triangle = {
|
|
|
22
22
|
};
|
|
23
23
|
export type Polygon = {
|
|
24
24
|
points: Point[];
|
|
25
|
+
tempPoint?: Point;
|
|
25
26
|
};
|
|
26
27
|
export type Curve = {
|
|
27
28
|
points: Point[];
|
|
29
|
+
tempPoint?: Point;
|
|
28
30
|
};
|
|
29
31
|
export type Brush = {
|
|
30
32
|
points: Point[][];
|
|
@@ -47,7 +49,7 @@ export type StyleShape = {
|
|
|
47
49
|
lineWidth?: number;
|
|
48
50
|
lineDash?: number;
|
|
49
51
|
lineArrow?: number;
|
|
50
|
-
|
|
52
|
+
closedPoints?: number;
|
|
51
53
|
fontFamily?: string;
|
|
52
54
|
fontItalic?: boolean;
|
|
53
55
|
fontBold?: boolean;
|
|
@@ -132,11 +132,8 @@ export type SettingsFont = {
|
|
|
132
132
|
hidden?: boolean;
|
|
133
133
|
};
|
|
134
134
|
};
|
|
135
|
-
export type
|
|
136
|
-
|
|
137
|
-
min: number;
|
|
138
|
-
max: number;
|
|
139
|
-
step: number;
|
|
135
|
+
export type SettingsClosedPoints = {
|
|
136
|
+
closedPoints: {
|
|
140
137
|
default: number;
|
|
141
138
|
hidden?: boolean;
|
|
142
139
|
};
|
|
@@ -148,8 +145,8 @@ export type ToolsEllipseSettings = SettingsStrokeColor & SettingsFillColor & Set
|
|
|
148
145
|
export type ToolsTextSettings = SettingsOpacity & SettingsStrokeColor & SettingsFont;
|
|
149
146
|
export type ToolsLineSettings = SettingsOpacity & SettingsStrokeColor & SettingsLineWidth & SettingsLineDash & SettingsLineArrow;
|
|
150
147
|
export type ToolsBrushSettings = SettingsOpacity & SettingsStrokeColor & SettingsLineWidth & SettingsLineDash;
|
|
151
|
-
export type ToolsPolygonSettings = SettingsOpacity & SettingsStrokeColor & SettingsFillColor & SettingsLineWidth & SettingsLineDash &
|
|
152
|
-
export type ToolsCurveSettings = SettingsOpacity & SettingsStrokeColor & SettingsFillColor & SettingsLineWidth & SettingsLineDash &
|
|
148
|
+
export type ToolsPolygonSettings = SettingsOpacity & SettingsStrokeColor & SettingsFillColor & SettingsLineWidth & SettingsLineDash & SettingsClosedPoints;
|
|
149
|
+
export type ToolsCurveSettings = SettingsOpacity & SettingsStrokeColor & SettingsFillColor & SettingsLineWidth & SettingsLineDash & SettingsClosedPoints;
|
|
153
150
|
export type ToolsTriangleSettings = SettingsStrokeColor & SettingsFillColor & SettingsOpacity & SettingsLineWidth & SettingsLineDash;
|
|
154
151
|
export type ToolsPictureSettings = SettingsOpacity;
|
|
155
152
|
export type ToolsSettingsType<T extends ShapeType> = T extends 'rect' ? ToolsRectSettings : T extends 'square' ? ToolsSquareSettings : T extends 'circle' ? ToolsCircleSettings : T extends 'ellipse' ? ToolsEllipseSettings : T extends 'text' ? ToolsTextSettings : T extends 'line' ? ToolsLineSettings : T extends 'brush' ? ToolsBrushSettings : T extends 'polygon' ? ToolsPolygonSettings : T extends 'curve' ? ToolsCurveSettings : T extends 'triangle' ? ToolsTriangleSettings : T extends 'picture' ? ToolsPictureSettings : never;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
type ClosedPointsType = {
|
|
3
|
+
selectedSettings: string | undefined;
|
|
4
|
+
setSelectedSettings: React.Dispatch<React.SetStateAction<string | undefined>>;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
defaultValue?: number | undefined;
|
|
7
|
+
valueChanged: (field: string, value: string | number) => void;
|
|
8
|
+
};
|
|
9
|
+
declare const ClosedPointsField: ({ selectedSettings, setSelectedSettings, disabled, defaultValue, valueChanged }: ClosedPointsType) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default ClosedPointsField;
|