aboutsummaryrefslogtreecommitdiffstats
path: root/packages/excalidraw/scene/normalize.ts
blob: 2a025fc27c834c68ac097ccf5a7e5f33c9ab323d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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);
};