Moved selection in element, refactor common

This commit is contained in:
Marcel Mraz 2025-03-19 15:26:05 +01:00
parent e7a0a7e0b7
commit dfd48c221c
No known key found for this signature in database
GPG key ID: 4EBD6E62DC830CD2
19 changed files with 67 additions and 110 deletions

View file

@ -4,6 +4,8 @@ import {
type LocalPoint,
} from "@excalidraw/math";
import type { NullableGridSize } from "@excalidraw/excalidraw/types";
export const getSizeFromPoints = (
points: readonly (GlobalPoint | LocalPoint)[],
) => {
@ -61,3 +63,18 @@ export const rescalePoints = <Point extends GlobalPoint | LocalPoint>(
return nextPoints;
};
// TODO: Rounding this point causes some shake when free drawing
export const getGridPoint = (
x: number,
y: number,
gridSize: NullableGridSize,
): [number, number] => {
if (gridSize) {
return [
Math.round(x / gridSize) * gridSize,
Math.round(y / gridSize) * gridSize,
];
}
return [x, y];
};