diff --git a/frontend/src/features/canvas/store/canvasSlice.ts b/frontend/src/features/canvas/store/canvasSlice.ts index ccaf9df5ee..7a9d913444 100644 --- a/frontend/src/features/canvas/store/canvasSlice.ts +++ b/frontend/src/features/canvas/store/canvasSlice.ts @@ -23,6 +23,7 @@ import { isCanvasBaseImage, isCanvasMaskLine, } from './canvasTypes'; +import roundDimensionsTo64 from '../util/roundDimensionsTo64'; export const initialLayerState: CanvasLayerState = { objects: [], @@ -180,7 +181,7 @@ export const canvasSlice = createSlice({ }; }, setBoundingBoxDimensions: (state, action: PayloadAction) => { - state.boundingBoxDimensions = action.payload; + state.boundingBoxDimensions = roundDimensionsTo64(action.payload); }, setBoundingBoxCoordinates: (state, action: PayloadAction) => { state.boundingBoxCoordinates = floorCoordinates(action.payload); diff --git a/frontend/src/features/canvas/util/roundDimensionsTo64.ts b/frontend/src/features/canvas/util/roundDimensionsTo64.ts new file mode 100644 index 0000000000..992d343fc9 --- /dev/null +++ b/frontend/src/features/canvas/util/roundDimensionsTo64.ts @@ -0,0 +1,11 @@ +import { roundToMultiple } from 'common/util/roundDownToMultiple'; +import { Dimensions } from '../store/canvasTypes'; + +const roundDimensionsTo64 = (dimensions: Dimensions): Dimensions => { + return { + width: roundToMultiple(dimensions.width, 64), + height: roundToMultiple(dimensions.height, 64), + }; +}; + +export default roundDimensionsTo64;