This commit is contained in:
Manav Rathi
2024-04-11 12:38:22 +05:30
parent 6091ad9cfd
commit d0ffb83d90
2 changed files with 11 additions and 4 deletions

View File

@@ -1,4 +1,3 @@
import { isDimensions, isValidNumber } from '../utils';
import { IBoundingBox } from './BoundingBox';
import { IDimensions } from './Dimensions';
import { Point } from './Point';
@@ -172,4 +171,12 @@ export class Box<BoxType = any> implements IBoundingBox, IRect {
bottom: this.bottom + (region.bottom * this.height)
}).toSquare().round()
}
}
}
export function isValidNumber(num: any) {
return !!num && num !== Infinity && num !== -Infinity && !isNaN(num) || num === 0
}
export function isDimensions(obj: any): boolean {
return obj && obj.width && obj.height
}

View File

@@ -1,4 +1,4 @@
import { isValidNumber } from '../utils';
import { isValidNumber } from './Box';
export interface IDimensions {
width: number
@@ -25,4 +25,4 @@ export class Dimensions implements IDimensions {
public reverse(): Dimensions {
return new Dimensions(1 / this.width, 1 / this.height)
}
}
}