This commit is contained in:
Manav Rathi 2024-05-19 16:41:42 +05:30
parent d39cf15f26
commit d99c10c15e
No known key found for this signature in database

View file

@ -73,16 +73,15 @@ export class Box implements IRect {
}
}
export function enlargeBox(box: Box, factor: number = 1.5) {
export const enlargeBox = (box: Box, factor: number) => {
const center = new Point(box.x + box.width / 2, box.y + box.height / 2);
const newWidth = factor * box.width;
const newHeight = factor * box.height;
const size = new Point(box.width, box.height);
const newHalfSize = new Point((factor * size.x) / 2, (factor * size.y) / 2);
return boxFromBoundingBox({
left: center.x - newHalfSize.x,
top: center.y - newHalfSize.y,
right: center.x + newHalfSize.x,
bottom: center.y + newHalfSize.y,
return new Box({
x: center.x - newWidth / 2,
y: center.y - newHeight / 2,
width: newWidth,
height: newHeight,
});
}
};