@yorab/react-paint 0.10.0 → 0.10.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.
@@ -1,10 +1,11 @@
1
1
  import type { HoverModeData } from '../types/Mode';
2
2
  import type { DrawableShape, Point, Rect } from '../types/Shapes';
3
- export declare const getCursorPosition: (e: MouseEvent | TouchEvent, canvas: HTMLCanvasElement | null, givenWidth: number, givenHeight: number, scaleRatio?: number) => Point;
3
+ import { UtilsSettings } from 'src/constants/app';
4
+ export declare const getCursorPosition: (e: MouseEvent | TouchEvent, canvas: HTMLCanvasElement | null, settings: UtilsSettings) => Point;
4
5
  export declare const isTouchGesture: (e: MouseEvent | TouchEvent) => e is TouchEvent;
5
6
  export declare const getPointPositionAfterCanvasTransformation: (point: Point, shapeRotation: number, [originX, originY]: Point, [canvasOffsetX, canvasOffsetY]: Point) => Point;
6
7
  export declare const getPointPositionBeforeCanvasTransformation: (point: Point, shapeRotation: number, [originX, originY]: Point, [canvasOffsetX, canvasOffsetY]: Point) => Point;
7
- export declare const checkSelectionIntersection: (shape: DrawableShape, position: Point, canvasOffset: Point, selectionPadding: number, currentScale: number, checkAnchors?: boolean, radius?: number) => false | HoverModeData;
8
- export declare const checkPositionIntersection: (ctx: CanvasRenderingContext2D, shape: DrawableShape, position: Point, canvasOffset: Point, selectionPadding: number, currentScale: number) => false | HoverModeData;
8
+ export declare const checkSelectionIntersection: (shape: DrawableShape, position: Point, settings: UtilsSettings, checkAnchors?: boolean, radius?: number) => false | HoverModeData;
9
+ export declare const checkPositionIntersection: (ctx: CanvasRenderingContext2D, shape: DrawableShape, position: Point, settings: UtilsSettings) => false | HoverModeData;
9
10
  export declare function getRectIntersection(rect1: Rect, rect2: Rect): Rect | undefined;
10
- export declare const checkSelectionFrameCollision: (ctx: CanvasRenderingContext2D, shape: DrawableShape, selectionFrame: [Point, Point], canvasOffset: Point, selectionPadding: number) => boolean;
11
+ export declare const checkSelectionFrameCollision: (ctx: CanvasRenderingContext2D, shape: DrawableShape, selectionFrame: [Point, Point], settings: UtilsSettings) => boolean;
@@ -1,12 +1,13 @@
1
+ import { UtilsSettings } from 'src/constants/app';
1
2
  import { DrawableShape, Point, SelectionLinesType } from 'src/types/Shapes';
2
3
  export declare const createLineSelectionPath: (path: Path2D | undefined, shape: DrawableShape<'line' | 'polygon' | 'curve'> & {
3
4
  points: readonly Point[];
4
- }, currentScale: number, selectionPadding: number, gravityAnchors?: boolean) => SelectionLinesType;
5
- export declare const drawLineSelection: ({ ctx, shape, withAnchors, selectionWidth, selectionColor, currentScale }: {
5
+ }, settings: UtilsSettings, gravityAnchors?: boolean) => SelectionLinesType;
6
+ export declare const drawLineSelection: ({ ctx, shape, withAnchors, selectionWidth, selectionColor, settings }: {
6
7
  ctx: CanvasRenderingContext2D;
7
8
  shape: DrawableShape<'line'> | DrawableShape<'polygon'> | DrawableShape<'curve'>;
8
9
  withAnchors: boolean;
9
10
  selectionWidth: number;
10
11
  selectionColor: string;
11
- currentScale?: number | undefined;
12
+ settings: UtilsSettings;
12
13
  }) => void;
@@ -1,11 +1,11 @@
1
- import type { GridFormatType } from '../../constants/app';
1
+ import type { UtilsSettings } from '../../constants/app';
2
2
  import type { SelectionModeResize } from '../../types/Mode';
3
3
  import type { DrawableShape, Point, SelectionDefaultType } from '../../types/Shapes';
4
- export declare const createRecSelectionPath: (path: Path2D | undefined, rect: DrawableShape, currentScale: number, selectionPadding: number) => SelectionDefaultType;
4
+ export declare const createRecSelectionPath: (path: Path2D | undefined, rect: DrawableShape, settings: UtilsSettings) => SelectionDefaultType;
5
5
  export declare const drawSelectionRect: (ctx: CanvasRenderingContext2D, shape: DrawableShape & {
6
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) => {
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) => {
9
9
  borderX: number;
10
10
  borderHeight: number;
11
11
  borderY: number;
@@ -1,2 +1,3 @@
1
+ import { UtilsSettings } from 'src/constants/app';
1
2
  import type { Point } from '../../types/Shapes';
2
- export declare const drawFrame: (ctx: CanvasRenderingContext2D, selectionFrame: [Point, Point], currentScale: number) => void;
3
+ export declare const drawFrame: (ctx: CanvasRenderingContext2D, selectionFrame: [Point, Point], settings: UtilsSettings) => void;
@@ -1,7 +1,8 @@
1
+ import { UtilsSettings } from 'src/constants/app';
1
2
  import type { HoverModeData, SelectionModeData } from '../types/Mode';
2
3
  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: (ctx: CanvasRenderingContext2D, shapes: ShapeEntity[], cursorPosition: Point, currentScale: number, canvasOffset: Point, selectedShape: ShapeEntity | undefined, selectionPadding: number, isTouchGesture: boolean, withFrameSelection: boolean) => {
4
+ export declare const getNewSelectionData: (hoverMode: HoverModeData, selectedShape: ShapeEntity, cursorPosition: Point, settings: UtilsSettings) => SelectionModeData<Point | number> | undefined;
5
+ export declare const selectShape: (ctx: CanvasRenderingContext2D, shapes: ShapeEntity[], cursorPosition: Point, settings: UtilsSettings, selectedShape: ShapeEntity | undefined, isTouchGesture: boolean, withFrameSelection: boolean) => {
5
6
  mode: SelectionModeData<Point | number>;
6
7
  shape: ShapeEntity | undefined;
7
8
  };
@@ -1,20 +1,20 @@
1
- import { GridFormatType } from '../../constants/app';
1
+ import { UtilsSettings } from '../../constants/app';
2
2
  import { SelectionModeResize } from '../../types/Mode';
3
3
  import type { DrawableShape, Point, Rect, ShapeEntity } from '../../types/Shapes';
4
4
  import type { ToolsSettingsType } from '../../types/tools';
5
- export declare const refreshBrush: <T extends DrawableShape<"brush">>(brush: T, currentScale: number, selectionPadding: number) => T;
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
8
  type: 'brush';
9
9
  settings: ToolsSettingsType<'brush'>;
10
- }, cursorPosition: Point, currentScale: number, selectionPadding: number) => ShapeEntity<'brush'>;
10
+ }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<'brush'>;
11
11
  export declare const drawBrush: (ctx: CanvasRenderingContext2D, shape: DrawableShape<'brush'>) => void;
12
- export declare const getBrushBorder: (brush: DrawableShape<'brush'>, selectionPadding: number) => Rect;
13
- export declare const translateBrush: <U extends DrawableShape<"brush">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, gridFormat: GridFormatType, currentScale: number, selectionPadding: number) => U & {
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 & {
14
14
  points: Point[][];
15
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 & {
16
+ export declare const resizeBrush: (cursorPosition: Point, originalShape: DrawableShape<'brush'>, selectionMode: SelectionModeResize, settings: UtilsSettings, keepRatio: boolean) => DrawableShape<'brush'>;
17
+ export declare const addNewPointToShape: <T extends DrawableShape<"brush">>(shape: T, cursorPosition: Point, settings: UtilsSettings) => T & {
18
18
  points: Point[][];
19
19
  };
20
- export declare const addNewPointGroupToShape: <T extends DrawableShape<"brush">>(shape: T, cursorPosition: Point, currentScale: number, selectionPadding: number) => T;
20
+ export declare const addNewPointGroupToShape: <T extends DrawableShape<"brush">>(shape: T, cursorPosition: Point, settings: UtilsSettings) => T;
@@ -1,17 +1,17 @@
1
- import { GridFormatType } from '../../constants/app';
1
+ import { UtilsSettings } from '../../constants/app';
2
2
  import { SelectionModeResize } from '../../types/Mode';
3
3
  import type { Circle, DrawableShape, Point, Rect, ShapeEntity } from '../../types/Shapes';
4
4
  import type { ToolsSettingsType } from '../../types/tools';
5
- export declare const refreshCircle: <T extends DrawableShape<"circle">>(shape: T, currentScale: number, selectionPadding: number) => T;
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
8
  type: 'circle';
9
9
  settings: ToolsSettingsType<'circle'>;
10
- }, cursorPosition: Point, currentScale: number, selectionPadding: number) => ShapeEntity<'circle'>;
10
+ }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<'circle'>;
11
11
  export declare const drawCircle: (ctx: CanvasRenderingContext2D, circle: DrawableShape<'circle'>) => void;
12
- export declare const getCircleBorder: (circle: Circle, 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 & {
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 & {
14
14
  x: number;
15
15
  y: number;
16
16
  };
17
- export declare const resizeCircle: (cursorPosition: Point, originalShape: DrawableShape<'circle'>, selectionMode: SelectionModeResize, gridFormat: GridFormatType, selectionPadding: number, currentScale: number) => DrawableShape<'circle'>;
17
+ export declare const resizeCircle: (cursorPosition: Point, originalShape: DrawableShape<'circle'>, selectionMode: SelectionModeResize, settings: UtilsSettings) => DrawableShape<'circle'>;
@@ -1,17 +1,17 @@
1
- import { GridFormatType } from '../../constants/app';
1
+ import { UtilsSettings } from '../../constants/app';
2
2
  import { SelectionModeResize } from '../../types/Mode';
3
3
  import type { DrawableShape, Point, ShapeEntity } from '../../types/Shapes';
4
4
  import type { ToolsSettingsType } from '../../types/tools';
5
- export declare const refreshCurve: <T extends DrawableShape<"curve">>(shape: T, currentScale: number, selectionPadding: number) => T;
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
8
  type: 'curve';
9
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'>;
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
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 & {
13
+ export declare const getCurveBorder: (polygon: import("../../types/Shapes").Polygon, settings: UtilsSettings) => import("../../types/Shapes").Rect;
14
+ export declare const translateCurve: <U extends DrawableShape<"curve">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, settings: UtilsSettings) => U & {
15
15
  points: [number, number][];
16
16
  };
17
- export declare const updateCurveLinesCount: <T extends DrawableShape<"curve">>(shape: T, newPointsCount: number, currentScale: number, selectionPadding: number) => T;
17
+ export declare const updateCurveLinesCount: <T extends DrawableShape<"curve">>(shape: T, newPointsCount: number, settings: UtilsSettings) => T;
@@ -1,17 +1,17 @@
1
- import { GridFormatType } from '../../constants/app';
1
+ import { UtilsSettings } from '../../constants/app';
2
2
  import { SelectionModeResize } from '../../types/Mode';
3
3
  import type { DrawableShape, Ellipse, Point, Rect, ShapeEntity } from '../../types/Shapes';
4
4
  import type { ToolsSettingsType } from '../../types/tools';
5
- export declare const refreshEllipse: <T extends DrawableShape<"ellipse">>(shape: T, currentScale: number, selectionPadding: number) => T;
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
8
  type: 'ellipse';
9
9
  settings: ToolsSettingsType<'ellipse'>;
10
- }, cursorPosition: Point, currentScale: number, selectionPadding: number) => ShapeEntity<'ellipse'>;
10
+ }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<'ellipse'>;
11
11
  export declare const drawEllipse: (ctx: CanvasRenderingContext2D, ellipse: DrawableShape<'ellipse'>) => void;
12
- export declare const getEllipseBorder: (ellipse: Ellipse, 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 & {
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 & {
14
14
  x: number;
15
15
  y: number;
16
16
  };
17
- export declare const resizeEllipse: (cursorPosition: Point, originalShape: DrawableShape<'ellipse'>, selectionMode: SelectionModeResize, gridFormat: GridFormatType, selectionPadding: number, currentScale: number, keepRatio?: boolean) => DrawableShape<'ellipse'>;
17
+ export declare const resizeEllipse: (cursorPosition: Point, originalShape: DrawableShape<'ellipse'>, selectionMode: SelectionModeResize, settings: UtilsSettings, keepRatio?: boolean) => DrawableShape<'ellipse'>;
@@ -1,35 +1,32 @@
1
- import type { GridFormatType } from '../../constants/app';
1
+ import type { UtilsSettings } from '../../constants/app';
2
2
  import { SelectionModeData } from '../../types/Mode';
3
3
  import type { DrawableShape, Point, Rect, ShapeEntity } from '../../types/Shapes';
4
4
  import type { CustomTool } from '../../types/tools';
5
5
  export declare const createShape: (ctx: CanvasRenderingContext2D, shape: Exclude<CustomTool, {
6
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) => {
7
+ }>, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity;
8
+ export declare const drawShape: (ctx: CanvasRenderingContext2D, shape: DrawableShape, settings: UtilsSettings) => void;
9
+ export declare const getShapeInfos: (shape: DrawableShape, settings: UtilsSettings) => {
10
10
  borders: Rect;
11
11
  center: Point;
12
12
  };
13
- export declare const rotateShape: <T extends DrawableShape>(shape: T, cursorPosition: Point, originalShape: T, originalCursorPosition: Point, shapeCenter: Point, gridFormat: GridFormatType) => T & {
13
+ export declare const rotateShape: <T extends DrawableShape>(shape: T, cursorPosition: Point, originalShape: T, originalCursorPosition: Point, shapeCenter: Point, settings: UtilsSettings) => T & {
14
14
  rotation: number;
15
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 }: {
16
+ export declare const resizeShape: <T extends DrawableShape>(ctx: CanvasRenderingContext2D, shape: T, cursorPosition: Point, originalShape: T, selectionMode: SelectionModeData<Point | number>, settings: UtilsSettings, isShiftPressed: boolean) => T;
17
+ export declare const translateShape: (cursorPosition: Point, originalShape: ShapeEntity, originalCursorPosition: Point, settings: UtilsSettings) => ShapeEntity;
18
+ export declare const refreshShape: (shape: ShapeEntity, settings: UtilsSettings) => ShapeEntity;
19
+ export declare const drawShapeSelection: ({ ctx, shape, settings, selectionWidth, selectionColor, withAnchors }: {
20
20
  ctx: CanvasRenderingContext2D;
21
21
  shape: DrawableShape;
22
- currentScale: number;
23
- canvasOffset: Point;
24
- selectionPadding: number;
22
+ settings: UtilsSettings;
25
23
  selectionWidth: number;
26
24
  selectionColor: string;
27
25
  withAnchors?: boolean | undefined;
28
26
  }) => void;
29
- export declare const drawSelectionFrame: ({ ctx, selectionFrame, currentScale, canvasOffset }: {
27
+ export declare const drawSelectionFrame: ({ ctx, selectionFrame, settings }: {
30
28
  ctx: CanvasRenderingContext2D;
31
29
  selectionFrame: [Point, Point];
32
- currentScale: number;
33
- canvasOffset: Point;
30
+ settings: UtilsSettings;
34
31
  }) => void;
35
- export declare const copyShape: (shape: ShapeEntity, gridFormat: GridFormatType, currentScale: number, selectionPadding: number) => ShapeEntity;
32
+ export declare const copyShape: (shape: ShapeEntity, settings: UtilsSettings) => ShapeEntity;
@@ -1,17 +1,17 @@
1
- import { GridFormatType } from '../../constants/app';
1
+ import { UtilsSettings } from '../../constants/app';
2
2
  import { SelectionModeResize } from '../../types/Mode';
3
3
  import type { DrawableShape, Line, Point, Rect, ShapeEntity, StyleShape, Triangle } from '../../types/Shapes';
4
4
  import type { ToolsSettingsType } from '../../types/tools';
5
- export declare const refreshLine: <T extends DrawableShape<"line">>(line: T, currentScale: number, selectionPadding: number) => T;
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
8
  type: 'line';
9
9
  settings: ToolsSettingsType<'line'>;
10
- }, cursorPosition: Point, currentScale: number, selectionPadding: number) => ShapeEntity<'line'>;
10
+ }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<'line'>;
11
11
  export declare const buildTriangleOnLine: (center: Point, rotation: number, lineStyle: StyleShape) => Triangle;
12
12
  export declare const drawLine: (ctx: CanvasRenderingContext2D, shape: DrawableShape<'line'>) => void;
13
- export declare const getLineBorder: (line: Line, 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 & {
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 & {
15
15
  points: [Point, Point];
16
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;
17
+ export declare const resizeLine: <U extends DrawableShape<"line">>(cursorPosition: Point, originalShape: U, selectionMode: SelectionModeResize<number>, settings: UtilsSettings) => U;
@@ -1,9 +1,10 @@
1
+ import { UtilsSettings } from 'src/constants/app';
1
2
  import { Circle, DrawableShape, Line, Rect } from '../../types/Shapes';
2
3
  export declare const createRecPath: (rect: Rect) => Path2D;
3
4
  export declare const createCirclePath: (shape: Circle) => Path2D;
4
5
  export declare const createEllipsePath: (ellipse: DrawableShape<'ellipse'>) => Path2D;
5
6
  export declare const createLinePath: (line: Line) => Path2D;
6
- export declare const createBrushPath: (brush: DrawableShape<'brush'>, selectionPadding: number) => Path2D | undefined;
7
+ export declare const createBrushPath: (brush: DrawableShape<'brush'>, settings: UtilsSettings) => Path2D | undefined;
7
8
  export declare const createCurvePath: (curve: DrawableShape<'curve'>) => Path2D | undefined;
8
9
  export declare const createPolygonPath: (polygon: DrawableShape<'polygon'>) => Path2D | undefined;
9
10
  export declare const createTrianglePath: (triangle: DrawableShape<'triangle'>) => Path2D;
@@ -1,12 +1,12 @@
1
- import { GridFormatType } from '../../constants/app';
1
+ import { UtilsSettings } from '../../constants/app';
2
2
  import { SelectionModeResize } from '../../types/Mode';
3
3
  import type { DrawableShape, Picture, Point, Rect, ShapeEntity } from '../../types/Shapes';
4
- export declare const refreshPicture: <T extends DrawableShape<"picture">>(shape: T, currentScale: number, selectionPadding: number) => T;
5
- export declare const createPicture: (fileOrUrl: File | string, maxPictureWidth: number, maxPictureHeight: number, currentScale: number, selectionPadding: number) => Promise<ShapeEntity<"picture">>;
4
+ export declare const refreshPicture: <T extends DrawableShape<"picture">>(shape: T, settings: UtilsSettings) => T;
5
+ export declare const createPicture: (fileOrUrl: File | string, maxPictureWidth: number, maxPictureHeight: number, settings: UtilsSettings) => Promise<ShapeEntity<"picture">>;
6
6
  export declare const drawPicture: (ctx: CanvasRenderingContext2D, picture: DrawableShape<'picture'>) => void;
7
- export declare const getPictureBorder: (picture: Picture, selectionPadding: number) => Rect;
8
- export declare const translatePicture: <U extends DrawableShape<"picture">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, gridFormat: GridFormatType, currentScale: number, selectionPadding: number) => U & {
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 & {
9
9
  x: number;
10
10
  y: number;
11
11
  };
12
- export declare const resizePicture: (cursorPosition: Point, originalShape: DrawableShape<'picture'>, selectionMode: SelectionModeResize, gridFormat: GridFormatType, selectionPadding: number, currentScale: number, keepRatio: boolean) => DrawableShape<'picture'>;
12
+ export declare const resizePicture: (cursorPosition: Point, originalShape: DrawableShape<'picture'>, selectionMode: SelectionModeResize, settings: UtilsSettings, keepRatio: boolean) => DrawableShape<'picture'>;
@@ -1,17 +1,17 @@
1
- import { GridFormatType } from '../../constants/app';
1
+ import { UtilsSettings } from '../../constants/app';
2
2
  import { SelectionModeResize } from '../../types/Mode';
3
3
  import type { DrawableShape, Point, Polygon, Rect, ShapeEntity } from '../../types/Shapes';
4
4
  import type { ToolsSettingsType } from '../../types/tools';
5
- export declare const refreshPolygon: <T extends DrawableShape<"polygon">>(shape: T, currentScale: number, selectionPadding: number) => T;
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
8
  type: 'polygon';
9
9
  settings: ToolsSettingsType<'polygon'>;
10
- }, cursorPosition: Point, currentScale: number, selectionPadding: number) => ShapeEntity<'polygon'>;
10
+ }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<'polygon'>;
11
11
  export declare const drawPolygon: (ctx: CanvasRenderingContext2D, polygon: DrawableShape<'polygon'>) => void;
12
- export declare const getPolygonBorder: (polygon: Polygon, selectionPadding: number) => Rect;
13
- export declare const translatePolygon: <U extends DrawableShape<"polygon">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, gridFormat: GridFormatType, currentScale: number, selectionPadding: number) => U & {
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 & {
14
14
  points: [number, number][];
15
15
  };
16
- export declare const resizePolygon: (cursorPosition: Point, canvasOffset: Point, originalShape: DrawableShape<'polygon'>, selectionMode: SelectionModeResize<number>, gridFormat: GridFormatType, selectionPadding: number, currentScale: number) => DrawableShape<'polygon'>;
17
- export declare const updatePolygonLinesCount: <T extends DrawableShape<"polygon">>(shape: T, newPointsCount: number, currentScale: number, selectionPadding: number) => T;
16
+ export declare const resizePolygon: (cursorPosition: Point, originalShape: DrawableShape<'polygon'>, selectionMode: SelectionModeResize<number>, settings: UtilsSettings) => DrawableShape<'polygon'>;
17
+ export declare const updatePolygonLinesCount: <T extends DrawableShape<"polygon">>(shape: T, newPointsCount: number, settings: UtilsSettings) => T;
@@ -1,20 +1,20 @@
1
- import type { GridFormatType } from '../../constants/app';
1
+ import type { UtilsSettings } from '../../constants/app';
2
2
  import type { SelectionModeResize } from '../../types/Mode';
3
3
  import type { DrawableShape, Point, Rect, ShapeEntity } from '../../types/Shapes';
4
4
  import type { ToolsSettingsType } from '../../types/tools';
5
5
  type rectish = 'text' | 'rect' | 'square' | 'picture';
6
- export declare const refreshRect: <T extends DrawableShape<rectish>>(rect: T, currentScale: number, selectionPadding: number) => T;
6
+ export declare const refreshRect: <T extends DrawableShape<rectish>>(rect: T, settings: UtilsSettings) => T;
7
7
  export declare const createRectangle: <T extends "rect" | "square">(shape: {
8
8
  id: string;
9
9
  type: T;
10
10
  settings: ToolsSettingsType<T>;
11
- }, cursorPosition: Point, currentScale: number, selectionPadding: number, width?: number, height?: number) => ShapeEntity<T>;
11
+ }, cursorPosition: Point, settings: UtilsSettings, width?: number, height?: number) => ShapeEntity<T>;
12
12
  export declare const drawRect: (ctx: CanvasRenderingContext2D, shape: DrawableShape<'rect' | 'square'>) => void;
13
- export declare const getRectBorder: (rect: Rect, selectionPadding: number) => Rect;
14
- export declare const getRectOppositeAnchorAbsolutePosition: <T extends DrawableShape & Rect>(anchor: Point, center: Point, shape: T, canvasOffset: Point, [negW, negH]?: [boolean, boolean]) => Point;
15
- export declare const translateRect: <T extends "rect" | "square", U extends DrawableShape<T>>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, gridFormat: GridFormatType, currentScale: number, selectionPadding: number) => U & {
13
+ export declare const getRectBorder: (rect: Rect, settings: UtilsSettings) => Rect;
14
+ export declare const getRectOppositeAnchorAbsolutePosition: <T extends DrawableShape & Rect>(anchor: Point, center: Point, shape: T, settings: UtilsSettings, [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 & {
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, gridFormat: GridFormatType, selectionPadding: number, currentScale: number, keepRatio?: boolean) => DrawableShape<T>;
19
+ export declare const resizeRect: <T extends rectish>(cursorPosition: Point, originalShape: DrawableShape<T>, selectionMode: SelectionModeResize, settings: UtilsSettings, keepRatio?: boolean) => DrawableShape<T>;
20
20
  export {};
@@ -1,19 +1,19 @@
1
- import { GridFormatType } from '../../constants/app';
1
+ import { UtilsSettings } from '../../constants/app';
2
2
  import { SelectionModeResize } from '../../types/Mode';
3
3
  import type { DrawableShape, Point, Rect, ShapeEntity, Text } from '../../types/Shapes';
4
4
  import type { ToolsSettingsType } from '../../types/tools';
5
- export declare const refreshText: <T extends DrawableShape<"text">>(shape: T, currentScale: number, selectionPadding: number) => T;
5
+ export declare const refreshText: <T extends DrawableShape<"text">>(shape: T, settings: UtilsSettings) => T;
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
9
  type: 'text';
10
10
  settings: ToolsSettingsType<'text'>;
11
- }, cursorPosition: Point, currentScale: number, selectionPadding: number) => ShapeEntity<'text'>;
11
+ }, cursorPosition: Point, settings: UtilsSettings) => ShapeEntity<'text'>;
12
12
  export declare const drawText: (ctx: CanvasRenderingContext2D, text: DrawableShape<'text'>) => void;
13
- export declare const getTextBorder: (text: Text, selectionPadding: number) => Rect;
14
- export declare const translateText: <U extends DrawableShape<"text">>(cursorPosition: Point, originalShape: U, originalCursorPosition: Point, gridFormat: GridFormatType, currentScale: number, selectionPadding: number) => U & {
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 & {
15
15
  x: number;
16
16
  y: number;
17
17
  };
18
- export declare const resizeText: (ctx: CanvasRenderingContext2D, cursorPosition: Point, originalShape: DrawableShape<'text'>, selectionMode: SelectionModeResize, gridFormat: GridFormatType, selectionPadding: number, currentScale: number) => DrawableShape<'text'>;
19
- export declare const resizeTextShapeWithNewContent: <U extends DrawableShape<"text">>(ctx: CanvasRenderingContext2D, shape: U, newValue: string[], selectionPadding: number, canvasOffset: Point) => U;
18
+ export declare const resizeText: (ctx: CanvasRenderingContext2D, cursorPosition: Point, originalShape: DrawableShape<'text'>, selectionMode: SelectionModeResize, settings: UtilsSettings) => DrawableShape<'text'>;
19
+ export declare const resizeTextShapeWithNewContent: <U extends DrawableShape<"text">>(ctx: CanvasRenderingContext2D, shape: U, newValue: string[], settings: UtilsSettings) => U;
@@ -1,12 +1,12 @@
1
- import type { GridFormatType } from '../constants/app';
1
+ import type { UtilsSettings } from '../constants/app';
2
2
  import type { SelectionModeData } from '../types/Mode';
3
3
  import type { DrawableShape, Line, Point, ShapeEntity } from '../types/Shapes';
4
4
  export declare const getNormalizedSize: (originalWidth: number, originalHeight: number, width: number, height: number) => number[];
5
5
  export declare const roundValues: (prop: number, precision?: number) => number;
6
6
  export declare const scalePoint: (point: Point, minX: number, minY: number, scaleX?: number, scaleY?: number) => Point;
7
- export declare const roundForGrid: (value: number, gridFormat: GridFormatType, gridOffset?: number) => number;
8
- export declare const roundRotationForGrid: (rotation: number, gridFormat: GridFormatType, gridOffset?: number) => number;
9
- export declare const transformShape: (ctx: CanvasRenderingContext2D, shape: ShapeEntity, cursorPosition: Point, gridFormat: GridFormatType, canvasOffset: Point, selectionMode: SelectionModeData<Point | number>, selectionPadding: number, isShiftPressed: boolean, currentScale: number) => ShapeEntity;
7
+ export declare const roundForGrid: (value: number, settings: UtilsSettings, gridOffset?: number) => number;
8
+ export declare const roundRotationForGrid: (rotation: number, settings: UtilsSettings, gridOffset?: number) => number;
9
+ export declare const transformShape: (ctx: CanvasRenderingContext2D, shape: ShapeEntity, cursorPosition: Point, selectionMode: SelectionModeData<Point | number>, settings: UtilsSettings, isShiftPressed: boolean) => ShapeEntity;
10
10
  export declare const fitContentInsideContainer: (contentWidth: number, contentHeight: number, containerWidth: number, containerHeight: number, shouldFillContainer?: boolean) => number[];
11
11
  export declare const shortenLine: ({ line, size, direction }: {
12
12
  line: DrawableShape<'line'>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yorab/react-paint",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "type": "module",
5
5
  "keywords": [],
6
6
  "author": "Yohann Rabatel",
@@ -37,7 +37,7 @@
37
37
  "react-dom": "18.2.0",
38
38
  "storybook": "7.6.3",
39
39
  "typescript": "5.3.2",
40
- "vite": "5.0.12",
40
+ "vite": "5.0.13",
41
41
  "vite-tsconfig-paths": "4.2.0"
42
42
  },
43
43
  "peerDependencies": {