@yorab/react-paint 0.11.0 → 0.11.2

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 CHANGED
@@ -1,4 +1,4 @@
1
- # React Paint V0.11.0
1
+ # React Paint V0.11.2
2
2
 
3
3
  An open-source canvas-based library for React used for image annotation or as a digital whiteboard
4
4
 
@@ -82,7 +82,7 @@ const AdvancedUsage = () => {
82
82
  }
83
83
 
84
84
  useEffect(() => {
85
- const onDataChanged = (data: StateData) => {
85
+ const onDataChanged = (data: StateData, source: 'user' | 'remote') => {
86
86
  setShapes(data.shapes)
87
87
  }
88
88
  registerEvent('dataChanged', onDataChanged)
@@ -126,12 +126,35 @@ you will find other usages in <a href="https://github.com/YoRab/react-paint-edit
126
126
  | :--- | :--- | :--- |
127
127
  | `canvasProps` | `object` | Set of properties to forward to Canvas component |
128
128
  | `editorProps` | `object` | Set of properties to forward to Editor component |
129
- | `registerEvent` | `(event: "dataChanged", listener: (data: StateData) => void) => void` | registerEvent is used to register a listener for special events triggered by react-paint. The only currently available event is `dataChanged` |
130
- | `unregisterEvent` | `(event: "dataChanged", listener?: ((data: StateData) => 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 |
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
+ | `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
132
  | `getCurrentImage` | `() => string \| undefined` | Returns a data URL containing the content of the current canvas as a PNG image, or undefined if an error occured |
133
133
  | `getCurrentData` | `() => StateData` | Returns the current state of the canvas |
134
134
 
135
+ #### `OptionalOptions`
136
+
137
+ | Parameter | Type | Description | Default value |
138
+ | :--- | :--- | :--- | :--- |
139
+ | `layersManipulation` | `boolean` | *Optional*. Show panel to manipulate layers | `true` |
140
+ | `grid` | `number` | *Optional*. Size in px for grid cells. Set to 0 to hide grid | `0` |
141
+ | `canGrow` | `boolean` | *Optional*. Allow canvas to upscale and grow to fit container | `false` |
142
+ | `canShrink` | `boolean` | *Optional*. Allow canvas to downscale and shrink to fit container | `true` |
143
+ | `withExport` | `boolean` | *Optional*. Show button to manually export to PNG | `true` |
144
+ | `withLoadAndSave` | `boolean` | *Optional*.Show button to manually save or load data | `true` |
145
+ | `withUploadPicture` | `boolean` | *Optional*. Show button to add picture shape stored in base64 | `true` |
146
+ | `withUrlPicture` | `boolean` | *Optional*.Show button to add picture shape with only the url stored. Need connectivity to be displayed | `false` |
147
+ | `withFrameSelection` | `boolean` | *Optional*.Enable frame selection. **Currently, does not support multi shapes selection** | `false` |
148
+ | `withSkeleton` | `boolean` | *Optional*. Display skeleton when hovering shape | `false` |
149
+ | `clearCallback` | `'empty' \| 'defaultShapes' \| (() => DrawableShape[])` | *Optional*. Set clear button behavior. `empty` clear all shapes, `defaultShapes` uses shapes given in props. It is also possible to set a function returning an array of shapes | `empty` |
150
+ | `brushAlgo` | `'simple' \| 'quadratic'` | *Optional*. Choose which algorithm to display brush shape. `simple` displays path as is, `quadratic` uses quadratic bézier curves | `simple` |
151
+ | `isBrushShapeDoneOnMouseUp` | `boolean` | *Optional*. Choose whether drawing brush shape after releasing mouse should create a new shape or not | `true` |
152
+ | `canvasSelectionPadding` | `boolean` | *Optional*. Padding between shape and selection frame | `0` |
153
+ | `availableTools` | `CustomToolInput[]` | *Optional*. List of available tools. See CustomTool for more details | `` |
154
+
155
+
156
+
157
+
135
158
  #### Canvas
136
159
 
137
160
  ##### Parameters
@@ -141,7 +164,7 @@ you will find other usages in <a href="https://github.com/YoRab/react-paint-edit
141
164
  | `canvasProps` | `object` | **Required**. Set of properties coming from useReactPaint | |
142
165
  | `className` | `string` | *Optional*. Classname for canvas parent node | `undefined` |
143
166
  | `style` | `CSSProperties` | *Optional*. css properties to inject to canvas parent node | `undefined` |
144
- | `options` | `{canvasBackgroundColor?: string}` | *Optional*. Set of properties to use to customize canvas style | `{canvasBackgroundColor: 'white'}` |
167
+ | `options` | `{canvasBackgroundColor?: string; canvasSelectionColor?: string; canvasSelectionWidth?: number}` | *Optional*. Set of properties to use to customize canvas style | `{canvasBackgroundColor: 'white'; canvasSelectionColor: 'blue'; canvasSelectionWidth: 2}` |
145
168
 
146
169
 
147
170
  #### Editor
@@ -160,8 +183,194 @@ you will find other usages in <a href="https://github.com/YoRab/react-paint-edit
160
183
 
161
184
  #### `DrawableShape`
162
185
  #### `StateData`
163
- #### `OptionalOptions`
164
186
 
187
+ #### `CustomTool`
188
+
189
+ ```
190
+ type CustomTool = {
191
+ id: string
192
+ icon: string
193
+ label: string
194
+ } & (
195
+ | {
196
+ type: 'brush'
197
+ settings: ToolsSettingsType<'brush'>
198
+ }
199
+ | {
200
+ type: 'circle'
201
+ settings: ToolsSettingsType<'circle'>
202
+ }
203
+ | {
204
+ type: 'ellipse'
205
+ settings: ToolsSettingsType<'ellipse'>
206
+ }
207
+ | {
208
+ type: 'rect'
209
+ settings: ToolsSettingsType<'rect'>
210
+ }
211
+ | {
212
+ type: 'square'
213
+ settings: ToolsSettingsType<'square'>
214
+ }
215
+ | {
216
+ type: 'line'
217
+ settings: ToolsSettingsType<'line'>
218
+ }
219
+ | {
220
+ type: 'polygon'
221
+ settings: ToolsSettingsType<'polygon'>
222
+ }
223
+ | {
224
+ type: 'curve'
225
+ settings: ToolsSettingsType<'curve'>
226
+ }
227
+ | {
228
+ type: 'text'
229
+ settings: ToolsSettingsType<'text'>
230
+ }
231
+ | {
232
+ type: 'picture'
233
+ settings: ToolsSettingsType<'picture'>
234
+ }
235
+ )
236
+
237
+ type SettingsOpacity = {
238
+ opacity: {
239
+ min: number
240
+ max: number
241
+ step: number
242
+ default: number
243
+ hidden?: boolean
244
+ }
245
+ }
246
+
247
+ type SettingsStrokeColor = {
248
+ strokeColor: {
249
+ values: string[]
250
+ default: string
251
+ hidden?: boolean
252
+ }
253
+ }
254
+
255
+ type SettingsFillColor = {
256
+ fillColor: {
257
+ values: string[]
258
+ default: string
259
+ hidden?: boolean
260
+ }
261
+ }
262
+
263
+ type SettingsLineWidth = {
264
+ lineWidth: {
265
+ min: number
266
+ max: number
267
+ step: number
268
+ default: number
269
+ hidden?: boolean
270
+ }
271
+ }
272
+
273
+ type SettingsLineDash = {
274
+ lineDash: {
275
+ values: number[]
276
+ default: number
277
+ hidden?: boolean
278
+ }
279
+ }
280
+
281
+ type SettingsLineArrow = {
282
+ lineArrow: {
283
+ values: number[]
284
+ default: number
285
+ hidden?: boolean
286
+ }
287
+ }
288
+
289
+ type SettingsFont = {
290
+ fontFamily: {
291
+ values: string[]
292
+ default: string
293
+ hidden?: boolean
294
+ }
295
+ fontBold: {
296
+ values: boolean[]
297
+ default: boolean
298
+ hidden?: boolean
299
+ }
300
+ fontItalic: {
301
+ values: boolean[]
302
+ default: boolean
303
+ hidden?: boolean
304
+ }
305
+ }
306
+
307
+ type SettingsPointsCount = {
308
+ pointsCount: {
309
+ min: number
310
+ max: number
311
+ step: number
312
+ default: number
313
+ hidden?: boolean
314
+ }
315
+ }
316
+
317
+ type ToolsRectSettings = SettingsStrokeColor & SettingsFillColor & SettingsOpacity & SettingsLineWidth & SettingsLineDash
318
+
319
+ type ToolsSquareSettings = SettingsStrokeColor & SettingsFillColor & SettingsOpacity & SettingsLineWidth & SettingsLineDash
320
+
321
+ type ToolsCircleSettings = SettingsStrokeColor & SettingsFillColor & SettingsOpacity & SettingsLineWidth & SettingsLineDash
322
+
323
+ type ToolsEllipseSettings = SettingsStrokeColor & SettingsFillColor & SettingsOpacity & SettingsLineWidth & SettingsLineDash
324
+
325
+ type ToolsTextSettings = SettingsOpacity & SettingsStrokeColor & SettingsFont
326
+
327
+ type ToolsLineSettings = SettingsOpacity & SettingsStrokeColor & SettingsLineWidth & SettingsLineDash & SettingsLineArrow
328
+
329
+ type ToolsBrushSettings = SettingsOpacity & SettingsStrokeColor & SettingsLineWidth & SettingsLineDash
330
+
331
+ type ToolsPolygonSettings = SettingsOpacity &
332
+ SettingsStrokeColor &
333
+ SettingsFillColor &
334
+ SettingsLineWidth &
335
+ SettingsLineDash &
336
+ SettingsPointsCount
337
+
338
+ type ToolsCurveSettings = SettingsOpacity &
339
+ SettingsStrokeColor &
340
+ SettingsFillColor &
341
+ SettingsLineWidth &
342
+ SettingsLineDash &
343
+ SettingsPointsCount
344
+
345
+ type ToolsTriangleSettings = SettingsStrokeColor & SettingsFillColor & SettingsOpacity & SettingsLineWidth & SettingsLineDash
346
+
347
+ type ToolsPictureSettings = SettingsOpacity
348
+
349
+ type ToolsSettingsType<T extends ShapeType> = T extends 'rect'
350
+ ? ToolsRectSettings
351
+ : T extends 'square'
352
+ ? ToolsSquareSettings
353
+ : T extends 'circle'
354
+ ? ToolsCircleSettings
355
+ : T extends 'ellipse'
356
+ ? ToolsEllipseSettings
357
+ : T extends 'text'
358
+ ? ToolsTextSettings
359
+ : T extends 'line'
360
+ ? ToolsLineSettings
361
+ : T extends 'brush'
362
+ ? ToolsBrushSettings
363
+ : T extends 'polygon'
364
+ ? ToolsPolygonSettings
365
+ : T extends 'curve'
366
+ ? ToolsCurveSettings
367
+ : T extends 'triangle'
368
+ ? ToolsTriangleSettings
369
+ : T extends 'picture'
370
+ ? ToolsPictureSettings
371
+ : never
372
+
373
+ ```
165
374
 
166
375
  ## Changelog
167
376
  https://github.com/YoRab/react-paint-editor/blob/main/Changelog.md
@@ -7,6 +7,7 @@ export declare const SELECTIONCANVAS_CLASSNAME = "react-paint-canvas-selectionca
7
7
  export type BrushAlgo = 'simple' | 'quadratic';
8
8
  export type UtilsSettings = {
9
9
  brushAlgo: BrushAlgo;
10
+ isBrushShapeDoneOnMouseUp: boolean;
10
11
  gridGap: number;
11
12
  canvasOffset: Point;
12
13
  canvasSize: {
@@ -30,15 +31,14 @@ type AppOptionsType = {
30
31
  withSkeleton: boolean;
31
32
  clearCallback: 'empty' | 'defaultShapes' | (() => DrawableShape[]);
32
33
  brushAlgo: BrushAlgo;
33
- selection: {
34
- canvasSelectionColor: string;
35
- canvasSelectionWidth: number;
36
- canvasSelectionPadding: number;
37
- };
34
+ isBrushShapeDoneOnMouseUp: boolean;
35
+ canvasSelectionPadding: number;
38
36
  };
39
37
  export type OptionalOptions = RecursivePartial<AppOptionsType>;
40
38
  export declare const DEFAULT_OPTIONS: AppOptionsType;
41
39
  export declare const DEFAULT_CANVAS_OPTIONS: {
42
40
  canvasBackgroundColor: string;
41
+ canvasSelectionColor: string;
42
+ canvasSelectionWidth: number;
43
43
  };
44
44
  export {};
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { UtilsSettings } from './../../canvas/constants/app';
3
2
  import type { ShapeEntity } from './../../common/types/Shapes';
4
3
  type UseKeyboardType = {
@@ -1,6 +1,5 @@
1
- /// <reference types="react" />
2
1
  import { type OptionalOptions, type UtilsSettings } from './../../canvas/constants/app';
3
- import type { DrawableShape, StateData, Point, ShapeEntity } from './../../common/types/Shapes';
2
+ import type { DrawableShape, Point, ShapeEntity, StateData } from './../../common/types/Shapes';
4
3
  import type { ToolsType } from './../../common/types/tools';
5
4
  type UseReactPaintProps = {
6
5
  width?: number;
@@ -10,10 +9,10 @@ type UseReactPaintProps = {
10
9
  disabled?: boolean;
11
10
  options?: OptionalOptions;
12
11
  };
13
- declare const useReactPaint: ({ width, height, shapes: shapesFromProps, mode, disabled, options }: UseReactPaintProps) => {
12
+ declare const useReactPaint: ({ width, height, shapes: defaultShapes, mode, disabled, options }: UseReactPaintProps) => {
14
13
  editorProps: {
15
14
  shapesRef: import("react").MutableRefObject<ShapeEntity[]>;
16
- addPictureShape: (fileOrUrl: string | File, maxWidth?: number, maxHeight?: number) => Promise<ShapeEntity<"picture">>;
15
+ addPictureShape: (fileOrUrl: File | string, maxWidth?: number, maxHeight?: number) => Promise<ShapeEntity<"picture">>;
17
16
  moveShapes: (firstShapeId: string, lastShapeId: string) => void;
18
17
  toggleShapeVisibility: (shape: ShapeEntity) => void;
19
18
  toggleShapeLock: (shape: ShapeEntity) => void;
@@ -53,13 +52,6 @@ declare const useReactPaint: ({ width, height, shapes: shapesFromProps, mode, di
53
52
  clearCanvas: () => void;
54
53
  settings: UtilsSettings;
55
54
  canvas: {
56
- selection: {
57
- canvasSelectionColor: string;
58
- canvasSelectionWidth: number;
59
- canvasSelectionPadding: number;
60
- };
61
- withSkeleton: boolean;
62
- withFrameSelection: boolean;
63
55
  canGrow: boolean;
64
56
  canShrink: boolean;
65
57
  layersManipulation: boolean;
@@ -67,7 +59,6 @@ declare const useReactPaint: ({ width, height, shapes: shapesFromProps, mode, di
67
59
  withLoadAndSave: boolean;
68
60
  withUploadPicture: boolean;
69
61
  withUrlPicture: boolean;
70
- clearCallback: "empty" | "defaultShapes" | (() => DrawableShape[]);
71
62
  };
72
63
  };
73
64
  canvasProps: {
@@ -111,19 +102,15 @@ declare const useReactPaint: ({ width, height, shapes: shapesFromProps, mode, di
111
102
  isEditMode: boolean;
112
103
  isDisabled: boolean;
113
104
  canvas: {
114
- selection: {
115
- canvasSelectionColor: string;
116
- canvasSelectionWidth: number;
117
- };
118
105
  withSkeleton: boolean;
119
106
  withFrameSelection: boolean;
120
107
  canGrow: boolean;
121
108
  canShrink: boolean;
122
109
  };
123
110
  };
124
- registerEvent: (event: "dataChanged", fn: (data: StateData) => void) => void;
125
- unregisterEvent: (event: "dataChanged", fn?: ((data: StateData) => void) | undefined) => void;
126
- resetCanvas: (json: DrawableShape[], clearHistory?: boolean) => Promise<void>;
111
+ registerEvent: (event: "dataChanged", fn: (data: StateData, source: "user" | "remote") => void) => void;
112
+ unregisterEvent: (event: "dataChanged", fn?: (data: StateData, source: "user" | "remote") => void) => void;
113
+ resetCanvas: (json?: DrawableShape[], clearHistory?: boolean) => void;
127
114
  getCurrentImage: () => string | undefined;
128
115
  getCurrentData: () => StateData;
129
116
  };
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  type UseResizeObserverType = {
3
2
  element: React.RefObject<HTMLElement>;
4
3
  onResized: (width: number, height: number) => unknown;
@@ -1,9 +1,8 @@
1
- /// <reference types="react" />
2
1
  import { type UtilsSettings } from './../../canvas/constants/app';
3
- import type { StateData, Point, ShapeEntity } from './../../common/types/Shapes';
2
+ import type { Point, ShapeEntity, StateData } from './../../common/types/Shapes';
4
3
  declare const useShapes: (settings: UtilsSettings) => {
5
- registerEvent: (event: 'dataChanged', fn: (data: StateData) => void) => void;
6
- unregisterEvent: (event: 'dataChanged', fn?: (data: StateData) => void) => void;
4
+ registerEvent: (event: "dataChanged", fn: (data: StateData, source: "user" | "remote") => void) => void;
5
+ unregisterEvent: (event: "dataChanged", fn?: (data: StateData, source: "user" | "remote") => void) => void;
7
6
  shapesRef: import("react").MutableRefObject<ShapeEntity[]>;
8
7
  selectedShape: ShapeEntity | undefined;
9
8
  hoveredShape: ShapeEntity | undefined;
@@ -22,7 +21,10 @@ declare const useShapes: (settings: UtilsSettings) => {
22
21
  updateShape: (updatedShape: ShapeEntity, withSave?: boolean) => void;
23
22
  backwardShape: () => void;
24
23
  forwardShape: () => void;
25
- clearShapes: (shapesToInit?: ShapeEntity[], clearHistory?: boolean) => void;
24
+ clearShapes: (shapesToInit: ShapeEntity[], options: {
25
+ clearHistory: boolean;
26
+ source: "user" | "remote";
27
+ }) => void;
26
28
  canGoBackward: boolean;
27
29
  canGoForward: boolean;
28
30
  canClear: boolean;
@@ -7,6 +7,8 @@ type AppProps = {
7
7
  style?: CSSProperties;
8
8
  options?: {
9
9
  canvasBackgroundColor?: string;
10
+ canvasSelectionColor?: string;
11
+ canvasSelectionWidth?: number;
10
12
  };
11
13
  };
12
14
  declare const App: ({ options, className, style, canvasProps }: AppProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import type { UtilsSettings } from './../../canvas/constants/app';
2
- import type { DrawableShape, StateData, ShapeEntity } from './../../common/types/Shapes';
2
+ import type { DrawableShape, ShapeEntity, StateData } from './../../common/types/Shapes';
3
3
  export declare const cleanShapesBeforeExport: (shapes: DrawableShape[]) => DrawableShape[];
4
4
  export declare const buildDataToExport: (shapes: DrawableShape[], width: number, height: number) => StateData;
5
5
  export declare const addDefaultAndTempShapeProps: (shape: DrawableShape, settings: UtilsSettings) => ShapeEntity;
@@ -5,6 +5,7 @@ export declare const isSvg: (fileOrUrl: File | string) => boolean;
5
5
  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
+ export declare const getStringifiedImage: (shape: DrawableShape<"picture">) => string;
8
9
  export declare const getCanvasImage: (shapes: DrawableShape[], width: number, height: number, settings: UtilsSettings) => string;
9
10
  export declare const encodeShapesInString: (shapes: DrawableShape[], width: number, height: number) => string;
10
11
  export declare const decodeJson: (file: File) => Promise<unknown>;
@@ -1,11 +1,11 @@
1
1
  import type { UtilsSettings } from './../../../canvas/constants/app';
2
2
  import type { DrawableShape, Point, SelectionLinesType } from './../../../common/types/Shapes';
3
- export declare const createLineSelectionPath: (path: Path2D | undefined, shape: DrawableShape<'line' | 'polygon' | 'curve'> & {
3
+ export declare const createLineSelectionPath: (path: Path2D | undefined, shape: DrawableShape<"line" | "polygon" | "curve"> & {
4
4
  points: readonly Point[];
5
5
  }, settings: UtilsSettings, gravityAnchors?: boolean) => SelectionLinesType;
6
6
  export declare const drawLineSelection: ({ ctx, shape, withAnchors, selectionWidth, selectionColor, settings }: {
7
7
  ctx: CanvasRenderingContext2D;
8
- shape: DrawableShape<'line'> | DrawableShape<'polygon'> | DrawableShape<'curve'>;
8
+ shape: DrawableShape<"line"> | DrawableShape<"polygon"> | DrawableShape<"curve">;
9
9
  withAnchors: boolean;
10
10
  selectionWidth: number;
11
11
  selectionColor: string;
@@ -5,15 +5,15 @@ import type { ToolsSettingsType } from './../../../common/types/tools';
5
5
  export declare const refreshBrush: <T extends DrawableShape<"brush">>(brush: T, settings: UtilsSettings) => T;
6
6
  export declare const createBrush: (shape: {
7
7
  id: string;
8
- type: 'brush';
9
- settings: ToolsSettingsType<'brush'>;
10
- }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<'brush'>;
11
- export declare const drawBrush: (ctx: CanvasRenderingContext2D, shape: DrawableShape<'brush'>) => void;
12
- export declare const getBrushBorder: (brush: DrawableShape<'brush'>, { selectionPadding }: UtilsSettings) => Rect;
8
+ type: "brush";
9
+ settings: ToolsSettingsType<"brush">;
10
+ }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"brush">;
11
+ export declare const drawBrush: (ctx: CanvasRenderingContext2D, shape: DrawableShape<"brush">) => void;
12
+ export declare const getBrushBorder: (brush: DrawableShape<"brush">, { selectionPadding }: UtilsSettings) => Rect;
13
13
  export declare const translateBrush: <U extends DrawableShape<"brush">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings) => 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) => 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
  };
@@ -5,13 +5,13 @@ import type { ToolsSettingsType } from './../../../common/types/tools';
5
5
  export declare const refreshCircle: <T extends DrawableShape<"circle">>(shape: T, settings: UtilsSettings) => T;
6
6
  export declare const createCircle: (shape: {
7
7
  id: string;
8
- type: 'circle';
9
- settings: ToolsSettingsType<'circle'>;
10
- }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<'circle'>;
11
- export declare const drawCircle: (ctx: CanvasRenderingContext2D, circle: DrawableShape<'circle'>) => void;
8
+ type: "circle";
9
+ settings: ToolsSettingsType<"circle">;
10
+ }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"circle">;
11
+ export declare const drawCircle: (ctx: CanvasRenderingContext2D, circle: DrawableShape<"circle">) => void;
12
12
  export declare const getCircleBorder: (circle: Circle, settings: UtilsSettings) => Rect;
13
13
  export declare const translateCircle: <U extends DrawableShape<"circle">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings) => 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) => DrawableShape<"circle">;
@@ -5,11 +5,11 @@ import type { ToolsSettingsType } from './../../../common/types/tools';
5
5
  export declare const refreshCurve: <T extends DrawableShape<"curve">>(shape: T, settings: UtilsSettings) => T;
6
6
  export declare const createCurve: (shape: {
7
7
  id: string;
8
- type: 'curve';
9
- settings: ToolsSettingsType<'curve'>;
10
- }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<'curve'>;
11
- export declare const resizeCurve: (cursorPosition: Point, originalShape: DrawableShape<'curve'>, selectionMode: SelectionModeResize<number>, settings: UtilsSettings) => DrawableShape<'curve'>;
12
- export declare const drawCurve: (ctx: CanvasRenderingContext2D, curve: DrawableShape<'curve'>) => void;
8
+ type: "curve";
9
+ settings: ToolsSettingsType<"curve">;
10
+ }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"curve">;
11
+ export declare const resizeCurve: (cursorPosition: Point, originalShape: DrawableShape<"curve">, selectionMode: SelectionModeResize<number>, settings: UtilsSettings) => DrawableShape<"curve">;
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
14
  export declare const translateCurve: <U extends DrawableShape<"curve">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings) => U & {
15
15
  points: [number, number][];
@@ -5,13 +5,13 @@ import type { ToolsSettingsType } from './../../../common/types/tools';
5
5
  export declare const refreshEllipse: <T extends DrawableShape<"ellipse">>(shape: T, settings: UtilsSettings) => T;
6
6
  export declare const createEllipse: (shape: {
7
7
  id: string;
8
- type: 'ellipse';
9
- settings: ToolsSettingsType<'ellipse'>;
10
- }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<'ellipse'>;
11
- export declare const drawEllipse: (ctx: CanvasRenderingContext2D, ellipse: DrawableShape<'ellipse'>) => void;
8
+ type: "ellipse";
9
+ settings: ToolsSettingsType<"ellipse">;
10
+ }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"ellipse">;
11
+ export declare const drawEllipse: (ctx: CanvasRenderingContext2D, ellipse: DrawableShape<"ellipse">) => void;
12
12
  export declare const getEllipseBorder: (ellipse: Ellipse, settings: UtilsSettings) => Rect;
13
13
  export declare const translateEllipse: <U extends DrawableShape<"ellipse">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings) => 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) => DrawableShape<"ellipse">;
@@ -3,7 +3,7 @@ import type { SelectionModeData } from './../../../common/types/Mode';
3
3
  import type { DrawableShape, Point, Rect, ShapeEntity } from './../../../common/types/Shapes';
4
4
  import type { CustomTool } from './../../../common/types/tools';
5
5
  export declare const createShape: (ctx: CanvasRenderingContext2D, shape: Exclude<CustomTool, {
6
- type: 'picture';
6
+ type: "picture";
7
7
  }>, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity;
8
8
  export declare const drawShape: (ctx: CanvasRenderingContext2D, shape: DrawableShape, settings: UtilsSettings) => void;
9
9
  export declare const getShapeInfos: (shape: DrawableShape, settings: UtilsSettings) => {
@@ -5,11 +5,11 @@ import type { ToolsSettingsType } from './../../../common/types/tools';
5
5
  export declare const refreshLine: <T extends DrawableShape<"line">>(line: T, settings: UtilsSettings) => T;
6
6
  export declare const createLine: (shape: {
7
7
  id: string;
8
- type: 'line';
9
- settings: ToolsSettingsType<'line'>;
10
- }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<'line'>;
8
+ type: "line";
9
+ settings: ToolsSettingsType<"line">;
10
+ }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"line">;
11
11
  export declare const buildTriangleOnLine: (center: Point, rotation: number, lineStyle: StyleShape) => Triangle;
12
- export declare const drawLine: (ctx: CanvasRenderingContext2D, shape: DrawableShape<'line'>) => void;
12
+ export declare const drawLine: (ctx: CanvasRenderingContext2D, shape: DrawableShape<"line">) => void;
13
13
  export declare const getLineBorder: (line: Line, settings: UtilsSettings) => Rect;
14
14
  export declare const translateLine: <U extends DrawableShape<"line">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings) => U & {
15
15
  points: [Point, Point];
@@ -2,9 +2,9 @@ import type { UtilsSettings } from './../../../canvas/constants/app';
2
2
  import type { Circle, DrawableShape, Line, Rect } from './../../../common/types/Shapes';
3
3
  export declare const createRecPath: (rect: Rect) => Path2D;
4
4
  export declare const createCirclePath: (shape: Circle) => Path2D;
5
- export declare const createEllipsePath: (ellipse: DrawableShape<'ellipse'>) => Path2D;
5
+ export declare const createEllipsePath: (ellipse: DrawableShape<"ellipse">) => Path2D;
6
6
  export declare const createLinePath: (line: Line) => Path2D;
7
- export declare const createBrushPath: (brush: DrawableShape<'brush'>, settings: UtilsSettings) => Path2D | undefined;
8
- export declare const createCurvePath: (curve: DrawableShape<'curve'>) => Path2D | undefined;
9
- export declare const createPolygonPath: (polygon: DrawableShape<'polygon'>) => Path2D | undefined;
10
- export declare const createTrianglePath: (triangle: DrawableShape<'triangle'>) => Path2D;
7
+ export declare const createBrushPath: (brush: DrawableShape<"brush">, settings: UtilsSettings) => Path2D | undefined;
8
+ export declare const createCurvePath: (curve: DrawableShape<"curve">) => Path2D | undefined;
9
+ export declare const createPolygonPath: (polygon: DrawableShape<"polygon">) => Path2D | undefined;
10
+ export declare const createTrianglePath: (triangle: DrawableShape<"triangle">) => Path2D;
@@ -3,10 +3,10 @@ import type { SelectionModeResize } from './../../../common/types/Mode';
3
3
  import type { DrawableShape, Picture, Point, Rect, ShapeEntity } from './../../../common/types/Shapes';
4
4
  export declare const refreshPicture: <T extends DrawableShape<"picture">>(shape: T, settings: UtilsSettings) => T;
5
5
  export declare const createPicture: (fileOrUrl: File | string, maxPictureWidth: number, maxPictureHeight: number, settings: UtilsSettings) => Promise<ShapeEntity<"picture">>;
6
- export declare const drawPicture: (ctx: CanvasRenderingContext2D, picture: DrawableShape<'picture'>) => void;
6
+ export declare const drawPicture: (ctx: CanvasRenderingContext2D, picture: DrawableShape<"picture">) => void;
7
7
  export declare const getPictureBorder: (picture: Picture, settings: UtilsSettings) => Rect;
8
8
  export declare const translatePicture: <U extends DrawableShape<"picture">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings) => 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, keepRatio: boolean) => DrawableShape<'picture'>;
12
+ export declare const resizePicture: (cursorPosition: Point, originalShape: DrawableShape<"picture">, selectionMode: SelectionModeResize, settings: UtilsSettings, keepRatio: boolean) => DrawableShape<"picture">;
@@ -5,13 +5,13 @@ import type { ToolsSettingsType } from './../../../common/types/tools';
5
5
  export declare const refreshPolygon: <T extends DrawableShape<"polygon">>(shape: T, settings: UtilsSettings) => T;
6
6
  export declare const createPolygon: (shape: {
7
7
  id: string;
8
- type: 'polygon';
9
- settings: ToolsSettingsType<'polygon'>;
10
- }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<'polygon'>;
11
- export declare const drawPolygon: (ctx: CanvasRenderingContext2D, polygon: DrawableShape<'polygon'>) => void;
8
+ type: "polygon";
9
+ settings: ToolsSettingsType<"polygon">;
10
+ }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"polygon">;
11
+ export declare const drawPolygon: (ctx: CanvasRenderingContext2D, polygon: DrawableShape<"polygon">) => void;
12
12
  export declare const getPolygonBorder: (polygon: Polygon, settings: UtilsSettings) => Rect;
13
13
  export declare const translatePolygon: <U extends DrawableShape<"polygon">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings) => U & {
14
14
  points: [number, number][];
15
15
  };
16
- export declare const resizePolygon: (cursorPosition: Point, originalShape: DrawableShape<'polygon'>, selectionMode: SelectionModeResize<number>, settings: UtilsSettings) => DrawableShape<'polygon'>;
16
+ export declare const resizePolygon: (cursorPosition: Point, originalShape: DrawableShape<"polygon">, selectionMode: SelectionModeResize<number>, settings: UtilsSettings) => DrawableShape<"polygon">;
17
17
  export declare const updatePolygonLinesCount: <T extends DrawableShape<"polygon">>(shape: T, newPointsCount: number, settings: UtilsSettings) => T;
@@ -9,7 +9,7 @@ export declare const createRectangle: <T extends "rect" | "square">(shape: {
9
9
  type: T;
10
10
  settings: ToolsSettingsType<T>;
11
11
  }, cursorPosition: Point, settings: UtilsSettings, width?: number, height?: number) => ShapeEntity<T>;
12
- export declare const drawRect: (ctx: CanvasRenderingContext2D, shape: DrawableShape<'rect' | 'square'>) => void;
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, settings: UtilsSettings, [negW, negH]?: [boolean, boolean]) => Point;
15
15
  export declare const translateRect: <T extends "rect" | "square", U extends DrawableShape<T>>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings) => U & {
@@ -6,14 +6,14 @@ export declare const refreshText: <T extends DrawableShape<"text">>(shape: T, se
6
6
  export declare const calculateTextFontSize: (ctx: CanvasRenderingContext2D, text: string[], maxWidth: number, fontBold: boolean, fontItalic: boolean, fontFamily?: string | undefined) => number;
7
7
  export declare const createText: (ctx: CanvasRenderingContext2D, shape: {
8
8
  id: string;
9
- type: 'text';
10
- settings: ToolsSettingsType<'text'>;
11
- }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<'text'>;
12
- export declare const drawText: (ctx: CanvasRenderingContext2D, text: DrawableShape<'text'>) => void;
9
+ type: "text";
10
+ settings: ToolsSettingsType<"text">;
11
+ }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<"text">;
12
+ export declare const drawText: (ctx: CanvasRenderingContext2D, text: DrawableShape<"text">) => void;
13
13
  export declare const getTextBorder: (text: Text, settings: UtilsSettings) => Rect;
14
14
  export declare const translateText: <U extends DrawableShape<"text">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings) => 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) => DrawableShape<"text">;
19
19
  export declare const resizeTextShapeWithNewContent: <U extends DrawableShape<"text">>(ctx: CanvasRenderingContext2D, shape: U, newValue: string[], settings: UtilsSettings) => U;