Add overlaps method to Rect (#4150)

* Add overlaps method to Rect

* review comment
This commit is contained in:
Michael Goderbauer 2017-09-27 17:42:44 -07:00 committed by GitHub
parent a0313d1019
commit bdfedcc26f

View File

@ -653,6 +653,15 @@ class Rect {
);
}
/// Whether `other` has a nonzero area of overlap with this rectangle.
bool overlaps(Rect other) {
if (right <= other.left || other.right <= left)
return false;
if (bottom <= other.top || other.bottom <= top)
return false;
return true;
}
/// The lesser of the magnitudes of the width and the height of this
/// rectangle.
double get shortestSide {