intersect method
- Rect other
Returns an intersection of this rectangle and other
.
If the rectangles do not intersect, an empty rectangle is returned.
Implementation
Rect intersect(Rect other) {
final x1 = math.max(x, other.x);
final y1 = math.max(y, other.y);
final x2 = math.min(right, other.right);
final y2 = math.min(bottom, other.bottom);
return Rect.fromLTWH(x1, y1, math.max(0, x2 - x1), math.max(0, y2 - y1));
}