| 123 | } |
| 124 | |
| 125 | public intersection(other: IRectangle, out?: Rectangle): Rectangle | null { |
| 126 | const x = Math.max(this.x, other.x); |
| 127 | const y = Math.max(this.y, other.y); |
| 128 | const right = Math.min(this.right, other.x + other.width); |
| 129 | const bottom = Math.min(this.bottom, other.y + other.height); |
| 130 | |
| 131 | if (right <= x || bottom <= y) { |
| 132 | return null; |
| 133 | } |
| 134 | |
| 135 | out = out || new Rectangle(); |
| 136 | return out.set(x, y, right - x, bottom - y); |
| 137 | } |
| 138 | |
| 139 | public union(other: IRectangle, out?: Rectangle): Rectangle { |
| 140 | const x = Math.min(this.x, other.x); |