| 11 | */ |
| 12 | |
| 13 | export class Size { |
| 14 | width: number; |
| 15 | height: number; |
| 16 | |
| 17 | constructor(width = 0, height = 0) { |
| 18 | this.width = Math.max(width, 0); |
| 19 | this.height = Math.max(height, 0); |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * Returns a copy of this size. |
| 24 | */ |
| 25 | copy(): Size { |
| 26 | return new Size(this.width, this.height); |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Returns whether this size is equal to another one. |
| 31 | */ |
| 32 | equals(other: Size): boolean { |
| 33 | return this.width === other.width && this.height === other.height; |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * The total area of the Size. |
| 38 | */ |
| 39 | get area(): number { |
| 40 | return this.width * this.height; |
| 41 | } |
| 42 | } |
nothing calls this directly
no outgoing calls
no test coverage detected