* merge this rectangle with another one * @param rect - other rectangle to union with * @returns the union(ed) rectangle
(rect: Rect)
| 190 | * @returns the union(ed) rectangle |
| 191 | */ |
| 192 | union(rect: Rect) { |
| 193 | const x1 = Math.min(this.left, rect.left); |
| 194 | const y1 = Math.min(this.top, rect.top); |
| 195 | |
| 196 | this.resize( |
| 197 | Math.max(this.right, rect.right) - x1, |
| 198 | Math.max(this.bottom, rect.bottom) - y1, |
| 199 | ); |
| 200 | |
| 201 | this.pos.set(x1, y1); |
| 202 | |
| 203 | return this; |
| 204 | } |
| 205 | |
| 206 | /** |
| 207 | * check if this rectangle is intersecting with the specified one |
no test coverage detected