fix: add roundDownToMultiple

This commit is contained in:
symant233 2024-04-04 19:54:56 +08:00 committed by psychedelicious
parent 90686c7f9c
commit d32e557e50
2 changed files with 9 additions and 4 deletions

View File

@ -583,8 +583,7 @@
"next": "下一张",
"accept": "接受",
"discardAll": "放弃所有",
"antialiasing": "抗锯齿",
"initialFitImageSize": "初始适应图片大小",
"antialiasing": "抗锯齿",
"showResultsOn": "显示结果 (开)",
"showResultsOff": "显示结果 (关)",
"saveMask": "保存 $t(unifiedCanvas.mask)"

View File

@ -148,10 +148,16 @@ export const canvasSlice = createSlice({
const { stageDimensions, shouldFitImageSize } = state;
const newBoundingBoxDimensions = shouldFitImageSize
? { width, height }
? {
width: roundDownToMultiple(width, CANVAS_GRID_SIZE_FINE),
height: roundDownToMultiple(height, CANVAS_GRID_SIZE_FINE),
}
: {
width: roundDownToMultiple(clamp(width, CANVAS_GRID_SIZE_FINE, optimalDimension), CANVAS_GRID_SIZE_FINE),
height: roundDownToMultiple(clamp(height, CANVAS_GRID_SIZE_FINE, optimalDimension), CANVAS_GRID_SIZE_FINE),
height: roundDownToMultiple(
clamp(height, CANVAS_GRID_SIZE_FINE, optimalDimension),
CANVAS_GRID_SIZE_FINE
),
};
const newBoundingBoxCoordinates = {