* Returns the intersection of this Rect with another. * If the rectangles do not intersect, an all zero Rect is returned.
(other: Rect)
| 170 | * If the rectangles do not intersect, an all zero Rect is returned. |
| 171 | */ |
| 172 | intersection(other: Rect): Rect { |
| 173 | if (!this.intersects(other)) { |
| 174 | return new Rect(0, 0, 0, 0); |
| 175 | } |
| 176 | |
| 177 | let x = Math.max(this.x, other.x); |
| 178 | let y = Math.max(this.y, other.y); |
| 179 | return new Rect(x, y, Math.min(this.maxX, other.maxX) - x, Math.min(this.maxY, other.maxY) - y); |
| 180 | } |
| 181 | |
| 182 | /** |
| 183 | * Returns a copy of this rectangle. |
no test coverage detected