aboutsummaryrefslogtreecommitdiffstats
path: root/packages/excalidraw/scene/normalize.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/excalidraw/scene/normalize.ts')
-rw-r--r--packages/excalidraw/scene/normalize.ts15
1 files changed, 15 insertions, 0 deletions
diff --git a/packages/excalidraw/scene/normalize.ts b/packages/excalidraw/scene/normalize.ts
new file mode 100644
index 0000000..2a025fc
--- /dev/null
+++ b/packages/excalidraw/scene/normalize.ts
@@ -0,0 +1,15 @@
+import { clamp, round } from "@excalidraw/math";
+import { MAX_ZOOM, MIN_ZOOM } from "../constants";
+import type { NormalizedZoomValue } from "../types";
+
+export const getNormalizedZoom = (zoom: number): NormalizedZoomValue => {
+ return clamp(round(zoom, 6), MIN_ZOOM, MAX_ZOOM) as NormalizedZoomValue;
+};
+
+export const getNormalizedGridSize = (gridStep: number) => {
+ return clamp(Math.round(gridStep), 1, 100);
+};
+
+export const getNormalizedGridStep = (gridStep: number) => {
+ return clamp(Math.round(gridStep), 1, 100);
+};