//#region src/components/pisellFloorMapLayout/utils/snap.ts
/**
* 吸附：将坐标或尺寸按 snapStep 取整；snapStep 为 0 不吸附
*/
function snapValue(value, snapStep) {
	if (!snapStep || snapStep <= 0) return value;
	return Math.round(value / snapStep) * snapStep;
}
function snapRect(x, y, width, height, snapStep) {
	if (!snapStep || snapStep <= 0) return {
		x,
		y,
		width,
		height
	};
	return {
		x: snapValue(x, snapStep),
		y: snapValue(y, snapStep),
		width: Math.max(snapStep, snapValue(width, snapStep)),
		height: Math.max(snapStep, snapValue(height, snapStep))
	};
}
//#endregion
exports.snapRect = snapRect;
