Fixes bounding box not being rounded to 64

This commit is contained in:
psychedelicious 2022-11-17 20:26:54 +11:00 committed by blessedcoolant
parent 74485411a8
commit c0005eb063
2 changed files with 13 additions and 1 deletions

View File

@ -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<Dimensions>) => {
state.boundingBoxDimensions = action.payload;
state.boundingBoxDimensions = roundDimensionsTo64(action.payload);
},
setBoundingBoxCoordinates: (state, action: PayloadAction<Vector2d>) => {
state.boundingBoxCoordinates = floorCoordinates(action.payload);

View File

@ -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;