Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 18x 18x 31x 31x 31x 31x 2x 4x 7x 2x | import { Vector2 } from "three"
export default class Rectangle {
topLeft: Vector2
width: number
height: number
protected bottomRight: Vector2
constructor(topLeft: Vector2, width: number, height: number) {
this.topLeft = topLeft
this.bottomRight = topLeft.clone().add(new Vector2(width, height))
this.width = width
this.height = height
}
// TODO rename
shorterSide(): number {
return this.width > this.height ? this.height : this.width
}
isVertical(): boolean {
return this.height > this.width
}
area(): number {
return this.width * this.height
}
getBottomRight(): Vector2 {
return this.bottomRight
}
}
|