@yorab/react-paint 0.7.6 → 0.9.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.
Files changed (153) hide show
  1. package/README.md +1 -11
  2. package/dist/components/App.d.ts +20 -0
  3. package/dist/components/Canvas.d.ts +38 -0
  4. package/dist/components/common/Button.d.ts +16 -0
  5. package/dist/components/common/Loading.d.ts +7 -0
  6. package/dist/components/common/Modal.d.ts +10 -0
  7. package/dist/components/common/Panel.d.ts +13 -0
  8. package/dist/components/common/Snackbar.d.ts +8 -0
  9. package/dist/components/settings/ColorField.d.ts +15 -0
  10. package/dist/components/settings/DeleteButton.d.ts +9 -0
  11. package/dist/components/settings/FontFamilyField.d.ts +12 -0
  12. package/dist/components/settings/LayoutButton.d.ts +8 -0
  13. package/dist/components/settings/Layouts.d.ts +19 -0
  14. package/dist/components/settings/LineArrowField.d.ts +12 -0
  15. package/dist/components/settings/LineTypeField.d.ts +16 -0
  16. package/dist/components/settings/PointsNumberField.d.ts +13 -0
  17. package/dist/components/settings/RangeField.d.ts +18 -0
  18. package/dist/components/settings/SelectField.d.ts +18 -0
  19. package/dist/components/settings/SettingsBar.d.ts +21 -0
  20. package/dist/components/settings/ToggleField.d.ts +12 -0
  21. package/dist/components/toolbox/EditTextBox.d.ts +14 -0
  22. package/dist/components/toolbox/LoadFileTool.d.ts +12 -0
  23. package/dist/components/toolbox/MenuGroup.d.ts +35 -0
  24. package/dist/components/toolbox/PictureUrlInput.d.ts +8 -0
  25. package/dist/components/toolbox/Tool.d.ts +12 -0
  26. package/dist/components/toolbox/Toolbar.d.ts +27 -0
  27. package/dist/components/toolbox/ToolbarGroup.d.ts +18 -0
  28. package/dist/constants/app.d.ts +41 -0
  29. package/dist/constants/icons.d.ts +41 -0
  30. package/dist/constants/loading.d.ts +1 -0
  31. package/dist/constants/picture.d.ts +1 -0
  32. package/dist/constants/shapes.d.ts +8 -0
  33. package/dist/constants/snackbar.d.ts +7 -0
  34. package/dist/constants/style.d.ts +17 -0
  35. package/dist/constants/tools.d.ts +32 -0
  36. package/dist/hooks/useComponent.d.ts +9 -0
  37. package/dist/hooks/useDoubleClick.d.ts +5 -0
  38. package/dist/hooks/useDrag.d.ts +15 -0
  39. package/dist/hooks/useDrawableCanvas.d.ts +37 -0
  40. package/dist/hooks/useKeyboard.d.ts +20 -0
  41. package/dist/hooks/useResizeObserver.d.ts +7 -0
  42. package/dist/hooks/useShapes.d.ts +26 -0
  43. package/dist/hooks/useSnackbar.d.ts +10 -0
  44. package/dist/react-paint.css +1 -0
  45. package/dist/react-paint.js +8887 -0
  46. package/dist/react-paint.umd.cjs +27 -0
  47. package/dist/types/Mode.d.ts +43 -0
  48. package/dist/types/Shapes.d.ts +128 -0
  49. package/dist/types/react.d.ts +7 -0
  50. package/dist/types/snackbar.d.ts +7 -0
  51. package/dist/types/tools.d.ts +125 -0
  52. package/dist/types/utils.d.ts +4 -0
  53. package/dist/utils/canvas.d.ts +10 -0
  54. package/dist/utils/data.d.ts +4 -0
  55. package/dist/utils/dom.d.ts +1 -0
  56. package/dist/utils/file.d.ts +10 -0
  57. package/dist/utils/grid.d.ts +3 -0
  58. package/dist/utils/intersect.d.ts +6 -0
  59. package/dist/utils/migration.d.ts +147 -0
  60. package/dist/utils/selection/lineSelection.d.ts +12 -0
  61. package/dist/utils/selection/rectSelection.d.ts +13 -0
  62. package/dist/utils/selection.d.ts +7 -0
  63. package/dist/utils/shapes/brush.d.ts +20 -0
  64. package/dist/utils/shapes/circle.d.ts +17 -0
  65. package/dist/utils/shapes/curve.d.ts +16 -0
  66. package/dist/utils/shapes/ellipse.d.ts +17 -0
  67. package/dist/utils/shapes/index.d.ts +29 -0
  68. package/dist/utils/shapes/line.d.ts +17 -0
  69. package/dist/utils/shapes/path.d.ts +9 -0
  70. package/dist/utils/shapes/picture.d.ts +12 -0
  71. package/dist/utils/shapes/polygon.d.ts +17 -0
  72. package/dist/utils/shapes/rectangle.d.ts +20 -0
  73. package/dist/utils/shapes/text.d.ts +19 -0
  74. package/dist/utils/shapes/triangle.d.ts +3 -0
  75. package/dist/utils/string.d.ts +3 -0
  76. package/dist/utils/style.d.ts +2 -0
  77. package/dist/utils/toolbar.d.ts +13 -0
  78. package/dist/utils/transform.d.ts +9 -0
  79. package/dist/utils/trigo.d.ts +16 -0
  80. package/package.json +52 -57
  81. package/dist/components/App.js +0 -496
  82. package/dist/components/Canvas.js +0 -194
  83. package/dist/components/common/Button.js +0 -88
  84. package/dist/components/common/Loading.js +0 -57
  85. package/dist/components/common/Modal.js +0 -46
  86. package/dist/components/common/Panel.js +0 -43
  87. package/dist/components/common/Snackbar.js +0 -68
  88. package/dist/components/settings/ColorField.js +0 -125
  89. package/dist/components/settings/DeleteButton.js +0 -37
  90. package/dist/components/settings/FontFamilyField.js +0 -67
  91. package/dist/components/settings/LayoutButton.js +0 -39
  92. package/dist/components/settings/Layouts.js +0 -214
  93. package/dist/components/settings/LineArrowField.js +0 -67
  94. package/dist/components/settings/LineTypeField.js +0 -65
  95. package/dist/components/settings/PointsNumberField.js +0 -45
  96. package/dist/components/settings/RangeField.js +0 -82
  97. package/dist/components/settings/SelectField.js +0 -81
  98. package/dist/components/settings/SettingsBar.js +0 -383
  99. package/dist/components/settings/ToggleField.js +0 -49
  100. package/dist/components/toolbox/EditTextBox.js +0 -138
  101. package/dist/components/toolbox/LoadFileTool.js +0 -58
  102. package/dist/components/toolbox/MenuGroup.js +0 -173
  103. package/dist/components/toolbox/PictureUrlInput.js +0 -68
  104. package/dist/components/toolbox/Tool.js +0 -41
  105. package/dist/components/toolbox/Toolbar.js +0 -203
  106. package/dist/components/toolbox/ToolbarGroup.js +0 -134
  107. package/dist/constants/app.js +0 -51
  108. package/dist/constants/icons.js +0 -88
  109. package/dist/constants/loading.js +0 -8
  110. package/dist/constants/picture.js +0 -8
  111. package/dist/constants/shapes.js +0 -20
  112. package/dist/constants/snackbar.js +0 -15
  113. package/dist/constants/style.js +0 -35
  114. package/dist/constants/tools.js +0 -424
  115. package/dist/hooks/useComponent.js +0 -47
  116. package/dist/hooks/useDoubleClick.js +0 -46
  117. package/dist/hooks/useDrag.js +0 -92
  118. package/dist/hooks/useDrawableCanvas.js +0 -230
  119. package/dist/hooks/useKeyboard.js +0 -142
  120. package/dist/hooks/useResizeObserver.js +0 -42
  121. package/dist/hooks/useShapes.js +0 -184
  122. package/dist/hooks/useSnackbar.js +0 -56
  123. package/dist/styles.css +0 -91
  124. package/dist/types/Mode.js +0 -5
  125. package/dist/types/Shapes.js +0 -5
  126. package/dist/types/snackbar.js +0 -5
  127. package/dist/types/tools.js +0 -5
  128. package/dist/types/utils.js +0 -5
  129. package/dist/utils/canvas.js +0 -49
  130. package/dist/utils/data.js +0 -49
  131. package/dist/utils/dom.js +0 -12
  132. package/dist/utils/file.js +0 -177
  133. package/dist/utils/intersect.js +0 -122
  134. package/dist/utils/migration.js +0 -59
  135. package/dist/utils/selection.js +0 -86
  136. package/dist/utils/shapes/brush.js +0 -135
  137. package/dist/utils/shapes/circle.js +0 -93
  138. package/dist/utils/shapes/curve.js +0 -55
  139. package/dist/utils/shapes/default.js +0 -73
  140. package/dist/utils/shapes/ellipse.js +0 -101
  141. package/dist/utils/shapes/grid.js +0 -36
  142. package/dist/utils/shapes/index.js +0 -341
  143. package/dist/utils/shapes/line.js +0 -179
  144. package/dist/utils/shapes/picture.js +0 -109
  145. package/dist/utils/shapes/polygon.js +0 -69
  146. package/dist/utils/shapes/rectangle.js +0 -100
  147. package/dist/utils/shapes/text.js +0 -128
  148. package/dist/utils/shapes/triangle.js +0 -24
  149. package/dist/utils/string.js +0 -36
  150. package/dist/utils/style.js +0 -46
  151. package/dist/utils/toolbar.js +0 -78
  152. package/dist/utils/transform.js +0 -109
  153. package/dist/utils/trigo.js +0 -42
@@ -0,0 +1,128 @@
1
+ import { ShapeTypeArray } from '../constants/shapes';
2
+ export type ShapeType = typeof ShapeTypeArray[number];
3
+ export type Point = [number, number];
4
+ export type Rect = {
5
+ x: number;
6
+ y: number;
7
+ width: number;
8
+ height: number;
9
+ };
10
+ export type Picture = Rect & {
11
+ src: string;
12
+ };
13
+ export type Text = Rect & {
14
+ value: string[];
15
+ fontSize: number;
16
+ };
17
+ export type Line = {
18
+ points: readonly [Point, Point];
19
+ };
20
+ export type Triangle = {
21
+ points: [Point, Point, Point];
22
+ };
23
+ export type Polygon = {
24
+ points: Point[];
25
+ };
26
+ export type Curve = {
27
+ points: Point[];
28
+ };
29
+ export type Brush = {
30
+ points: Point[][];
31
+ };
32
+ export type Circle = {
33
+ x: number;
34
+ y: number;
35
+ radius: number;
36
+ };
37
+ export type Ellipse = {
38
+ x: number;
39
+ y: number;
40
+ radiusX: number;
41
+ radiusY: number;
42
+ };
43
+ export type StyleShape = {
44
+ fillColor?: string;
45
+ globalAlpha?: number;
46
+ strokeColor?: string;
47
+ lineWidth?: number;
48
+ lineDash?: number;
49
+ lineArrow?: number;
50
+ pointsCount?: number;
51
+ fontFamily?: string;
52
+ fontItalic?: boolean;
53
+ fontBold?: boolean;
54
+ };
55
+ export type SelectionDefaultType = {
56
+ border: Path2D;
57
+ line: Path2D;
58
+ anchors: Path2D[];
59
+ };
60
+ export type SelectionLinesType = {
61
+ border: Path2D;
62
+ anchors: Path2D[];
63
+ };
64
+ export type DrawableShape<T extends ShapeType = ShapeType> = {
65
+ visible?: boolean;
66
+ locked?: boolean;
67
+ rotation: number;
68
+ style?: StyleShape;
69
+ } & (T extends 'line' ? Line & {
70
+ type: 'line';
71
+ selection?: SelectionLinesType;
72
+ path?: Path2D;
73
+ arrows?: DrawableShape<'triangle'>[];
74
+ } : T extends 'picture' ? Picture & {
75
+ type: 'picture';
76
+ img: HTMLImageElement;
77
+ selection?: SelectionDefaultType;
78
+ } : T extends 'text' ? Text & {
79
+ type: 'text';
80
+ selection?: SelectionDefaultType;
81
+ } : T extends 'rect' ? Rect & {
82
+ type: 'rect';
83
+ selection?: SelectionDefaultType;
84
+ path?: Path2D;
85
+ } : T extends 'square' ? Rect & {
86
+ type: 'square';
87
+ selection?: SelectionDefaultType;
88
+ path?: Path2D;
89
+ } : T extends 'circle' ? Circle & {
90
+ type: 'circle';
91
+ selection?: SelectionDefaultType;
92
+ path?: Path2D;
93
+ } : T extends 'ellipse' ? Ellipse & {
94
+ type: 'ellipse';
95
+ selection?: SelectionDefaultType;
96
+ path?: Path2D;
97
+ } : T extends 'triangle' ? Triangle & {
98
+ type: 'triangle';
99
+ path?: Path2D;
100
+ } : T extends 'polygon' ? Polygon & {
101
+ type: 'polygon';
102
+ selection?: SelectionLinesType;
103
+ path?: Path2D;
104
+ } : T extends 'curve' ? Curve & {
105
+ type: 'curve';
106
+ selection?: SelectionLinesType;
107
+ path?: Path2D;
108
+ } : T extends 'brush' ? Brush & {
109
+ type: 'brush';
110
+ selection?: SelectionDefaultType;
111
+ path?: Path2D;
112
+ scaleX?: number;
113
+ scaleY?: number;
114
+ } : never);
115
+ export type DrawableShapeJson<T extends ShapeType = ShapeType> = DrawableShape<T> & {
116
+ translation?: Point;
117
+ };
118
+ export type ShapeEntity<T extends Exclude<ShapeType, 'triangle'> = Exclude<ShapeType, 'triangle'>> = {
119
+ id: string;
120
+ toolId?: string;
121
+ } & DrawableShape<T>;
122
+ export type ExportDataType = {
123
+ shapes: DrawableShapeJson[];
124
+ config?: {
125
+ width: number;
126
+ height: number;
127
+ };
128
+ };
@@ -0,0 +1,7 @@
1
+ import 'react';
2
+ declare module 'react' {
3
+ interface CSSProperties {
4
+ [key: `--${string}`]: string | number;
5
+ }
6
+ }
7
+ export {};
@@ -0,0 +1,7 @@
1
+ export type SnackbarTypeType = 'infos' | 'error' | 'success';
2
+ export type SnackBarType = {
3
+ id: string;
4
+ type: SnackbarTypeType;
5
+ text: string;
6
+ duration: number;
7
+ };
@@ -0,0 +1,125 @@
1
+ import type { ShapeType } from './Shapes';
2
+ export type CustomToolInput = {
3
+ id: string;
4
+ type: ShapeType;
5
+ icon?: string;
6
+ label?: string;
7
+ settings?: ToolsSettingsType<ShapeType>;
8
+ };
9
+ export type CustomTool = {
10
+ id: string;
11
+ icon: string;
12
+ label: string;
13
+ } & ({
14
+ type: 'brush';
15
+ settings: ToolsSettingsType<'brush'>;
16
+ } | {
17
+ type: 'circle';
18
+ settings: ToolsSettingsType<'circle'>;
19
+ } | {
20
+ type: 'ellipse';
21
+ settings: ToolsSettingsType<'ellipse'>;
22
+ } | {
23
+ type: 'rect';
24
+ settings: ToolsSettingsType<'rect'>;
25
+ } | {
26
+ type: 'square';
27
+ settings: ToolsSettingsType<'square'>;
28
+ } | {
29
+ type: 'line';
30
+ settings: ToolsSettingsType<'line'>;
31
+ } | {
32
+ type: 'polygon';
33
+ settings: ToolsSettingsType<'polygon'>;
34
+ } | {
35
+ type: 'curve';
36
+ settings: ToolsSettingsType<'curve'>;
37
+ } | {
38
+ type: 'text';
39
+ settings: ToolsSettingsType<'text'>;
40
+ } | {
41
+ type: 'picture';
42
+ settings: ToolsSettingsType<'picture'>;
43
+ });
44
+ export type SettingsOpacity = {
45
+ opacity: {
46
+ min: number;
47
+ max: number;
48
+ step: number;
49
+ default: number;
50
+ };
51
+ };
52
+ export type SettingsStrokeColor = {
53
+ strokeColor: {
54
+ values: string[];
55
+ default: string;
56
+ };
57
+ };
58
+ export type SettingsFillColor = {
59
+ fillColor: {
60
+ values: string[];
61
+ default: string;
62
+ };
63
+ };
64
+ export type SettingsLineWidth = {
65
+ lineWidth: {
66
+ min: number;
67
+ max: number;
68
+ step: number;
69
+ default: number;
70
+ };
71
+ };
72
+ export type SettingsLineDash = {
73
+ lineDash: {
74
+ values: number[];
75
+ default: number;
76
+ };
77
+ };
78
+ export type SettingsLineArrow = {
79
+ lineArrow: {
80
+ values: number[];
81
+ default: number;
82
+ };
83
+ };
84
+ export type SettingsFont = {
85
+ fontFamily: {
86
+ values: string[];
87
+ default: string;
88
+ };
89
+ fontBold: {
90
+ values: boolean[];
91
+ default: boolean;
92
+ };
93
+ fontItalic: {
94
+ values: boolean[];
95
+ default: boolean;
96
+ };
97
+ };
98
+ export type SettingsPointsCount = {
99
+ pointsCount: {
100
+ min: number;
101
+ max: number;
102
+ step: number;
103
+ default: number;
104
+ };
105
+ };
106
+ export type ToolsRectSettings = SettingsStrokeColor & SettingsFillColor & SettingsOpacity & SettingsLineWidth & SettingsLineDash;
107
+ export type ToolsSquareSettings = SettingsStrokeColor & SettingsFillColor & SettingsOpacity & SettingsLineWidth & SettingsLineDash;
108
+ export type ToolsCircleSettings = SettingsStrokeColor & SettingsFillColor & SettingsOpacity & SettingsLineWidth & SettingsLineDash;
109
+ export type ToolsEllipseSettings = SettingsStrokeColor & SettingsFillColor & SettingsOpacity & SettingsLineWidth & SettingsLineDash;
110
+ export type ToolsTextSettings = SettingsOpacity & SettingsStrokeColor & SettingsFont;
111
+ export type ToolsLineSettings = SettingsOpacity & SettingsStrokeColor & SettingsLineWidth & SettingsLineDash & SettingsLineArrow;
112
+ export type ToolsBrushSettings = SettingsOpacity & SettingsStrokeColor & SettingsLineWidth & SettingsLineDash;
113
+ export type ToolsPolygonSettings = SettingsOpacity & SettingsStrokeColor & SettingsFillColor & SettingsLineWidth & SettingsLineDash & SettingsPointsCount;
114
+ export type ToolsCurveSettings = SettingsOpacity & SettingsStrokeColor & SettingsFillColor & SettingsLineWidth & SettingsLineDash & SettingsPointsCount;
115
+ export type ToolsTriangleSettings = SettingsStrokeColor & SettingsFillColor & SettingsOpacity & SettingsLineWidth & SettingsLineDash;
116
+ export type ToolsPictureSettings = SettingsOpacity;
117
+ 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 : unknown;
118
+ export type ActionsType = 'selection' | 'undo' | 'redo' | 'clear' | 'export' | 'loadfile' | 'savefile' | 'move' | 'uploadpicture' | 'addurlpicture';
119
+ export type ActionsTool = {
120
+ id: string;
121
+ type: ActionsType;
122
+ icon: string;
123
+ label: string;
124
+ };
125
+ export type ToolsType = CustomTool | ActionsTool;
@@ -0,0 +1,4 @@
1
+ export type RecursivePartial<T> = {
2
+ [P in keyof T]?: T[P] extends (infer U)[] ? RecursivePartial<U>[] : T[P] extends object ? RecursivePartial<T[P]> : T[P];
3
+ };
4
+ export type ValueOf<T> = T[keyof T];
@@ -0,0 +1,10 @@
1
+ import type { Point } from '../types/Shapes';
2
+ export declare const initCanvasContext: (ctx: CanvasRenderingContext2D) => void;
3
+ export declare const updateCanvasContext: (ctx: CanvasRenderingContext2D, style?: {
4
+ fillColor?: string;
5
+ globalAlpha?: number;
6
+ strokeColor?: string;
7
+ lineWidth?: number;
8
+ lineDash?: number;
9
+ }) => void;
10
+ export declare const transformCanvas: (ctx: CanvasRenderingContext2D, responsiveScale: number, canvasOffset: Point, rotation: number, translation: Point) => void;
@@ -0,0 +1,4 @@
1
+ import type { DrawableShape, DrawableShapeJson, ExportDataType, ShapeEntity } from '../types/Shapes';
2
+ export declare const cleanShapesBeforeExport: (shapes: DrawableShape[]) => DrawableShapeJson[];
3
+ export declare const buildDataToExport: (shapes: DrawableShape[], width: number, height: number) => ExportDataType;
4
+ export declare const addDefaultAndTempShapeProps: (shape: DrawableShape, currentScale: number, selectionPadding: number) => ShapeEntity;
@@ -0,0 +1 @@
1
+ export declare const isEventInsideNode: (event: MouseEvent | TouchEvent, node: HTMLElement | null) => boolean;
@@ -0,0 +1,10 @@
1
+ import type { DrawableShape, ExportDataType, Point, ShapeEntity } from '../types/Shapes';
2
+ export declare const addSizeAndConvertSvgToObjectUrl: (svgFileContent: string) => string;
3
+ export declare const isSvg: (fileOrUrl: File | string) => boolean;
4
+ export declare const fetchAndStringify: (url: string) => Promise<string>;
5
+ export declare const downloadFile: (content: string, fileName: string) => void;
6
+ export declare const getBase64Image: (img: HTMLImageElement) => string;
7
+ export declare const getCanvasImage: (shapes: DrawableShape[], canvasOffset: Point, width: number, height: number, selectionPadding: number) => string;
8
+ export declare const encodeShapesInString: (shapes: DrawableShape[], width: number, height: number) => string;
9
+ export declare const decodeJson: (file: File) => Promise<unknown>;
10
+ export declare const decodeImportedData: (shapesForJson: ExportDataType, currentScale: number, selectionPadding: number) => Promise<ShapeEntity[]>;
@@ -0,0 +1,3 @@
1
+ import { GridFormatType } from '../constants/app';
2
+ import type { Point } from '../types/Shapes';
3
+ export declare const drawGrid: (ctx: CanvasRenderingContext2D, width: number, height: number, responsiveScale: number, canvasOffset: Point, gridFormat: GridFormatType) => void;
@@ -0,0 +1,6 @@
1
+ import type { HoverModeData } from '../types/Mode';
2
+ import type { Point, DrawableShape } from '../types/Shapes';
3
+ export declare const getCursorPosition: (e: MouseEvent | TouchEvent, canvas: HTMLCanvasElement | null, givenWidth: number, givenHeight: number, scaleRatio?: number) => Point;
4
+ export declare const getPointPositionAfterCanvasTransformation: (point: Point, shapeRotation: number, [originX, originY]: Point, [canvasOffsetX, canvasOffsetY]: Point) => Point;
5
+ export declare const getPointPositionBeforeCanvasTransformation: (point: Point, shapeRotation: number, [originX, originY]: Point, [canvasOffsetX, canvasOffsetY]: Point) => Point;
6
+ export declare const checkPositionIntersection: (shape: DrawableShape, position: Point, canvasOffset: Point, selectionPadding: number, currentScale?: number, checkAnchors?: boolean) => false | HoverModeData;
@@ -0,0 +1,147 @@
1
+ import { DrawableShapeJson, Point } from '../types/Shapes';
2
+ export declare const migrateShapesV065: (shapes: DrawableShapeJson[]) => (({
3
+ visible?: boolean | undefined;
4
+ locked?: boolean | undefined;
5
+ rotation: number;
6
+ style?: import("../types/Shapes").StyleShape | undefined;
7
+ } & import("../types/Shapes").Triangle & {
8
+ type: "triangle";
9
+ path?: Path2D | undefined;
10
+ } & {
11
+ translation?: Point | undefined;
12
+ }) | ({
13
+ visible?: boolean | undefined;
14
+ locked?: boolean | undefined;
15
+ rotation: number;
16
+ style?: import("../types/Shapes").StyleShape | undefined;
17
+ } & import("../types/Shapes").Line & {
18
+ type: "line";
19
+ selection?: import("../types/Shapes").SelectionLinesType | undefined;
20
+ path?: Path2D | undefined;
21
+ arrows?: import("../types/Shapes").DrawableShape<"triangle">[] | undefined;
22
+ } & {
23
+ translation?: Point | undefined;
24
+ }) | ({
25
+ visible?: boolean | undefined;
26
+ locked?: boolean | undefined;
27
+ rotation: number;
28
+ style?: import("../types/Shapes").StyleShape | undefined;
29
+ } & import("../types/Shapes").Rect & {
30
+ src: string;
31
+ } & {
32
+ type: "picture";
33
+ img: HTMLImageElement;
34
+ selection?: import("../types/Shapes").SelectionDefaultType | undefined;
35
+ } & {
36
+ translation?: Point | undefined;
37
+ }) | ({
38
+ visible?: boolean | undefined;
39
+ locked?: boolean | undefined;
40
+ rotation: number;
41
+ style?: import("../types/Shapes").StyleShape | undefined;
42
+ } & import("../types/Shapes").Rect & {
43
+ value: string[];
44
+ fontSize: number;
45
+ } & {
46
+ type: "text";
47
+ selection?: import("../types/Shapes").SelectionDefaultType | undefined;
48
+ } & {
49
+ translation?: Point | undefined;
50
+ }) | ({
51
+ visible?: boolean | undefined;
52
+ locked?: boolean | undefined;
53
+ rotation: number;
54
+ style?: import("../types/Shapes").StyleShape | undefined;
55
+ } & import("../types/Shapes").Rect & {
56
+ type: "rect";
57
+ selection?: import("../types/Shapes").SelectionDefaultType | undefined;
58
+ path?: Path2D | undefined;
59
+ } & {
60
+ translation?: Point | undefined;
61
+ }) | ({
62
+ visible?: boolean | undefined;
63
+ locked?: boolean | undefined;
64
+ rotation: number;
65
+ style?: import("../types/Shapes").StyleShape | undefined;
66
+ } & import("../types/Shapes").Rect & {
67
+ type: "square";
68
+ selection?: import("../types/Shapes").SelectionDefaultType | undefined;
69
+ path?: Path2D | undefined;
70
+ } & {
71
+ translation?: Point | undefined;
72
+ }) | ({
73
+ visible?: boolean | undefined;
74
+ locked?: boolean | undefined;
75
+ rotation: number;
76
+ style?: import("../types/Shapes").StyleShape | undefined;
77
+ } & import("../types/Shapes").Circle & {
78
+ type: "circle";
79
+ selection?: import("../types/Shapes").SelectionDefaultType | undefined;
80
+ path?: Path2D | undefined;
81
+ } & {
82
+ translation?: Point | undefined;
83
+ }) | ({
84
+ visible?: boolean | undefined;
85
+ locked?: boolean | undefined;
86
+ rotation: number;
87
+ style?: import("../types/Shapes").StyleShape | undefined;
88
+ } & import("../types/Shapes").Ellipse & {
89
+ type: "ellipse";
90
+ selection?: import("../types/Shapes").SelectionDefaultType | undefined;
91
+ path?: Path2D | undefined;
92
+ } & {
93
+ translation?: Point | undefined;
94
+ }) | ({
95
+ visible?: boolean | undefined;
96
+ locked?: boolean | undefined;
97
+ rotation: number;
98
+ style?: import("../types/Shapes").StyleShape | undefined;
99
+ } & import("../types/Shapes").Polygon & {
100
+ type: "polygon";
101
+ selection?: import("../types/Shapes").SelectionLinesType | undefined;
102
+ path?: Path2D | undefined;
103
+ } & {
104
+ translation?: Point | undefined;
105
+ }) | ({
106
+ visible?: boolean | undefined;
107
+ locked?: boolean | undefined;
108
+ rotation: number;
109
+ style?: import("../types/Shapes").StyleShape | undefined;
110
+ } & import("../types/Shapes").Curve & {
111
+ type: "curve";
112
+ selection?: import("../types/Shapes").SelectionLinesType | undefined;
113
+ path?: Path2D | undefined;
114
+ } & {
115
+ translation?: Point | undefined;
116
+ }) | ({
117
+ visible?: boolean | undefined;
118
+ locked?: boolean | undefined;
119
+ rotation: number;
120
+ style?: import("../types/Shapes").StyleShape | undefined;
121
+ } & import("../types/Shapes").Brush & {
122
+ type: "brush";
123
+ selection?: import("../types/Shapes").SelectionDefaultType | undefined;
124
+ path?: Path2D | undefined;
125
+ scaleX?: number | undefined;
126
+ scaleY?: number | undefined;
127
+ } & {
128
+ translation?: Point | undefined;
129
+ }) | {
130
+ x: number;
131
+ y: number;
132
+ selection?: import("../types/Shapes").SelectionDefaultType | undefined;
133
+ style?: import("../types/Shapes").StyleShape | undefined;
134
+ type: "rect" | "square" | "circle" | "ellipse" | "picture";
135
+ rotation: number;
136
+ visible?: boolean | undefined;
137
+ locked?: boolean | undefined;
138
+ } | {
139
+ points: Point[];
140
+ selection?: import("../types/Shapes").SelectionLinesType | undefined;
141
+ style?: import("../types/Shapes").StyleShape | undefined;
142
+ type: "polygon" | "curve";
143
+ rotation: number;
144
+ path?: Path2D | undefined;
145
+ visible?: boolean | undefined;
146
+ locked?: boolean | undefined;
147
+ } | undefined)[];
@@ -0,0 +1,12 @@
1
+ import { DrawableShape, Point, SelectionLinesType } from "src/types/Shapes";
2
+ export declare const createLineSelectionPath: (shape: DrawableShape & {
3
+ points: readonly Point[];
4
+ }, currentScale: number, selectionPadding: number, gravityAnchors?: boolean) => SelectionLinesType;
5
+ export declare const drawLineSelection: ({ ctx, shape, withAnchors, selectionWidth, selectionColor, currentScale }: {
6
+ ctx: CanvasRenderingContext2D;
7
+ shape: DrawableShape<'line'> | DrawableShape<'polygon'> | DrawableShape<'curve'>;
8
+ withAnchors: boolean;
9
+ selectionWidth: number;
10
+ selectionColor: string;
11
+ currentScale?: number | undefined;
12
+ }) => void;
@@ -0,0 +1,13 @@
1
+ import type { Point, DrawableShape, SelectionDefaultType } from '../../types/Shapes';
2
+ import type { SelectionModeResize } from '../../types/Mode';
3
+ import type { GridFormatType } from '../../constants/app';
4
+ export declare const createRecSelectionPath: (rect: DrawableShape, currentScale: number, selectionPadding: number) => SelectionDefaultType;
5
+ export declare const drawSelectionRect: (ctx: CanvasRenderingContext2D, shape: DrawableShape & {
6
+ selection?: SelectionDefaultType;
7
+ }, selectionColor: string, selectionWidth: number, currentScale: number, withAnchors: boolean) => void;
8
+ export declare const resizeRectSelection: (cursorPosition: Point, originalShape: DrawableShape, selectionMode: SelectionModeResize, gridFormat: GridFormatType, selectionPadding: number, keepRatio?: boolean) => {
9
+ borderX: number;
10
+ borderHeight: number;
11
+ borderY: number;
12
+ borderWidth: number;
13
+ };
@@ -0,0 +1,7 @@
1
+ import type { HoverModeData, SelectionModeData } from '../types/Mode';
2
+ import type { Point, ShapeEntity } from '../types/Shapes';
3
+ export declare const getNewSelectionData: (hoverMode: HoverModeData, selectedShape: ShapeEntity, cursorPosition: Point, selectionPadding: number) => SelectionModeData<Point | number> | undefined;
4
+ export declare const selectShape: (shapes: ShapeEntity[], cursorPosition: Point, currentScale: number, canvasOffset: Point, selectedShape: ShapeEntity | undefined, selectionPadding: number) => {
5
+ mode: SelectionModeData<Point | number>;
6
+ shape: ShapeEntity | undefined;
7
+ };
@@ -0,0 +1,20 @@
1
+ import { GridFormatType } from '../../constants/app';
2
+ import { SelectionModeResize } from '../../types/Mode';
3
+ import type { Point, Rect, DrawableShape, ShapeEntity } from '../../types/Shapes';
4
+ import type { ToolsSettingsType } from '../../types/tools';
5
+ export declare const refreshBrush: <T extends DrawableShape<"brush">>(brush: T, currentScale: number, selectionPadding: number) => T;
6
+ export declare const createBrush: (shape: {
7
+ id: string;
8
+ type: 'brush';
9
+ settings: ToolsSettingsType<'brush'>;
10
+ }, cursorPosition: Point, currentScale: number, selectionPadding: number) => ShapeEntity<'brush'>;
11
+ export declare const drawBrush: (ctx: CanvasRenderingContext2D, shape: DrawableShape<'brush'>) => void;
12
+ export declare const getBrushBorder: (brush: DrawableShape<'brush'>, selectionPadding: number) => Rect;
13
+ export declare const translateBrush: <U extends DrawableShape<"brush">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, gridFormat: GridFormatType, currentScale: number, selectionPadding: number) => U & {
14
+ points: Point[][];
15
+ };
16
+ export declare const resizeBrush: (cursorPosition: Point, originalShape: DrawableShape<'brush'>, selectionMode: SelectionModeResize, gridFormat: GridFormatType, selectionPadding: number, currentScale: number, keepRatio: boolean) => DrawableShape<'brush'>;
17
+ export declare const addNewPointToShape: <T extends DrawableShape<"brush">>(shape: T, cursorPosition: Point, currentScale: number, selectionPadding: number) => T & {
18
+ points: Point[][];
19
+ };
20
+ export declare const addNewPointGroupToShape: <T extends DrawableShape<"brush">>(shape: T, cursorPosition: Point, currentScale: number, selectionPadding: number) => T;
@@ -0,0 +1,17 @@
1
+ import { GridFormatType } from '../../constants/app';
2
+ import { SelectionModeResize } from '../../types/Mode';
3
+ import type { Point, Circle, Rect, DrawableShape, ShapeEntity } from '../../types/Shapes';
4
+ import type { ToolsSettingsType } from '../../types/tools';
5
+ export declare const refreshCircle: <T extends DrawableShape<"circle">>(shape: T, currentScale: number, selectionPadding: number) => T;
6
+ export declare const createCircle: (shape: {
7
+ id: string;
8
+ type: 'circle';
9
+ settings: ToolsSettingsType<'circle'>;
10
+ }, cursorPosition: Point, currentScale: number, selectionPadding: number) => ShapeEntity<'circle'>;
11
+ export declare const drawCircle: (ctx: CanvasRenderingContext2D, circle: DrawableShape<'circle'>) => void;
12
+ export declare const getCircleBorder: (circle: Circle, selectionPadding: number) => Rect;
13
+ export declare const translateCircle: <U extends DrawableShape<"circle">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, gridFormat: GridFormatType, currentScale: number, selectionPadding: number) => U & {
14
+ x: number;
15
+ y: number;
16
+ };
17
+ export declare const resizeCircle: (cursorPosition: Point, originalShape: DrawableShape<'circle'>, selectionMode: SelectionModeResize, gridFormat: GridFormatType, selectionPadding: number, currentScale: number) => DrawableShape<'circle'>;
@@ -0,0 +1,16 @@
1
+ import { GridFormatType } from '../../constants/app';
2
+ import { SelectionModeResize } from '../../types/Mode';
3
+ import type { Point, DrawableShape, ShapeEntity } from '../../types/Shapes';
4
+ import type { ToolsSettingsType } from '../../types/tools';
5
+ export declare const refreshCurve: <T extends DrawableShape<"curve">>(shape: T, currentScale: number, selectionPadding: number) => T;
6
+ export declare const createCurve: (shape: {
7
+ id: string;
8
+ type: 'curve';
9
+ settings: ToolsSettingsType<'curve'>;
10
+ }, cursorPosition: Point, currentScale: number, selectionPadding: number) => ShapeEntity<'curve'>;
11
+ export declare const resizeCurve: (cursorPosition: Point, canvasOffset: Point, originalShape: DrawableShape<'curve'>, selectionMode: SelectionModeResize<number>, gridFormat: GridFormatType, selectionPadding: number, currentScale: number) => DrawableShape<'curve'>;
12
+ export declare const drawCurve: (ctx: CanvasRenderingContext2D, curve: DrawableShape<'curve'>) => void;
13
+ export declare const getCurveBorder: (polygon: import("../../types/Shapes").Polygon, selectionPadding: number) => import("../../types/Shapes").Rect;
14
+ export declare const translateCurve: <U extends DrawableShape<"curve">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, gridFormat: GridFormatType, currentScale: number, selectionPadding: number) => U & {
15
+ points: [number, number][];
16
+ };
@@ -0,0 +1,17 @@
1
+ import { GridFormatType } from '../../constants/app';
2
+ import { SelectionModeResize } from '../../types/Mode';
3
+ import type { Point, Ellipse, Rect, DrawableShape, ShapeEntity } from '../../types/Shapes';
4
+ import type { ToolsSettingsType } from '../../types/tools';
5
+ export declare const refreshEllipse: <T extends DrawableShape<"ellipse">>(shape: T, currentScale: number, selectionPadding: number) => T;
6
+ export declare const createEllipse: (shape: {
7
+ id: string;
8
+ type: 'ellipse';
9
+ settings: ToolsSettingsType<'ellipse'>;
10
+ }, cursorPosition: Point, currentScale: number, selectionPadding: number) => ShapeEntity<'ellipse'>;
11
+ export declare const drawEllipse: (ctx: CanvasRenderingContext2D, ellipse: DrawableShape<'ellipse'>) => void;
12
+ export declare const getEllipseBorder: (ellipse: Ellipse, selectionPadding: number) => Rect;
13
+ export declare const translateEllipse: <U extends DrawableShape<"ellipse">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, gridFormat: GridFormatType, currentScale: number, selectionPadding: number) => U & {
14
+ x: number;
15
+ y: number;
16
+ };
17
+ export declare const resizeEllipse: (cursorPosition: Point, originalShape: DrawableShape<'ellipse'>, selectionMode: SelectionModeResize, gridFormat: GridFormatType, selectionPadding: number, currentScale: number, keepRatio?: boolean) => DrawableShape<'ellipse'>;
@@ -0,0 +1,29 @@
1
+ import type { Point, DrawableShape, Rect, ShapeEntity } from '../../types/Shapes';
2
+ import type { CustomTool } from '../../types/tools';
3
+ import type { GridFormatType } from '../../constants/app';
4
+ import { SelectionModeData } from '../../types/Mode';
5
+ export declare const createShape: (ctx: CanvasRenderingContext2D, shape: Exclude<CustomTool, {
6
+ type: 'picture';
7
+ }>, cursorPosition: Point, gridFormat: GridFormatType, currentScale: number, selectionPadding: number) => ShapeEntity;
8
+ export declare const drawShape: (ctx: CanvasRenderingContext2D, shape: DrawableShape, responsiveScale: number, canvasOffset: Point, selectionPadding: number) => void;
9
+ export declare const getShapeInfos: (shape: DrawableShape, selectionPadding: number) => {
10
+ borders: Rect;
11
+ center: Point;
12
+ };
13
+ export declare const rotateShape: <T extends DrawableShape>(shape: T, cursorPosition: Point, originalShape: T, originalCursorPosition: Point, shapeCenter: Point, gridFormat: GridFormatType) => T & {
14
+ rotation: number;
15
+ };
16
+ export declare const resizeShape: <T extends DrawableShape>(ctx: CanvasRenderingContext2D, shape: T, cursorPosition: Point, canvasOffset: Point, originalShape: T, selectionMode: SelectionModeData<Point | number>, gridFormat: GridFormatType, selectionPadding: number, isShiftPressed: boolean, currentScale: number) => T;
17
+ export declare const translateShape: (cursorPosition: Point, originalShape: ShapeEntity, originalCursorPosition: Point, gridFormat: GridFormatType, currentScale: number, selectionPadding: number) => ShapeEntity;
18
+ export declare const refreshShape: (shape: ShapeEntity, currentScale: number, selectionPadding: number) => ShapeEntity;
19
+ export declare const drawShapeSelection: ({ ctx, shape, currentScale, canvasOffset, selectionPadding, selectionWidth, selectionColor, withAnchors }: {
20
+ ctx: CanvasRenderingContext2D;
21
+ shape: DrawableShape;
22
+ currentScale: number;
23
+ canvasOffset: Point;
24
+ selectionPadding: number;
25
+ selectionWidth: number;
26
+ selectionColor: string;
27
+ withAnchors?: boolean | undefined;
28
+ }) => void;
29
+ export declare const copyShape: (shape: ShapeEntity, gridFormat: GridFormatType, currentScale: number, selectionPadding: number) => ShapeEntity;
@@ -0,0 +1,17 @@
1
+ import { GridFormatType } from '../../constants/app';
2
+ import { SelectionModeResize } from '../../types/Mode';
3
+ import type { Point, DrawableShape, Line, Triangle, ShapeEntity, Rect, StyleShape } from '../../types/Shapes';
4
+ import type { ToolsSettingsType } from '../../types/tools';
5
+ export declare const refreshLine: <T extends DrawableShape<"line">>(line: T, currentScale: number, selectionPadding: number) => T;
6
+ export declare const createLine: (shape: {
7
+ id: string;
8
+ type: 'line';
9
+ settings: ToolsSettingsType<'line'>;
10
+ }, cursorPosition: Point, currentScale: number, selectionPadding: number) => ShapeEntity<'line'>;
11
+ export declare const buildTriangleOnLine: (center: Point, rotation: number, lineStyle: StyleShape) => Triangle;
12
+ export declare const drawLine: (ctx: CanvasRenderingContext2D, shape: DrawableShape<'line'>) => void;
13
+ export declare const getLineBorder: (line: Line, selectionPadding: number) => Rect;
14
+ export declare const translateLine: <U extends DrawableShape<"line">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, gridFormat: GridFormatType, currentScale: number, selectionPadding: number) => U & {
15
+ points: [Point, Point];
16
+ };
17
+ export declare const resizeLine: <U extends DrawableShape<"line">>(cursorPosition: Point, canvasOffset: Point, originalShape: U, selectionMode: SelectionModeResize<number>, gridFormat: GridFormatType, selectionPadding: number, currentScale: number) => U;
@@ -0,0 +1,9 @@
1
+ import { Circle, DrawableShape, Line, Rect } from "../../types/Shapes";
2
+ export declare const createRecPath: (rect: Rect) => Path2D;
3
+ export declare const createCirclePath: (shape: Circle) => Path2D;
4
+ export declare const createEllipsePath: (ellipse: DrawableShape<'ellipse'>) => Path2D;
5
+ export declare const createLinePath: (line: Line) => Path2D;
6
+ export declare const createBrushPath: (brush: DrawableShape<'brush'>, selectionPadding: number) => Path2D | undefined;
7
+ export declare const createCurvePath: (curve: DrawableShape<'curve'>) => Path2D | undefined;
8
+ export declare const createPolygonPath: (polygon: DrawableShape<'polygon'>) => Path2D | undefined;
9
+ export declare const createTrianglePath: (triangle: DrawableShape<'triangle'>) => Path2D;