From 720bda36e8b657c86b43fbae25c9a720246775e2 Mon Sep 17 00:00:00 2001 From: Hixie Date: Fri, 8 Jan 2016 16:50:57 -0800 Subject: [PATCH] Better Rect.intersect documentation. --- sky/engine/core/painting/Rect.dart | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sky/engine/core/painting/Rect.dart b/sky/engine/core/painting/Rect.dart index 01ace79ab68..c13026ef533 100644 --- a/sky/engine/core/painting/Rect.dart +++ b/sky/engine/core/painting/Rect.dart @@ -58,13 +58,17 @@ class Rect { /// Returns a new rectangle with edges moved inwards by the given delta. Rect deflate(double delta) => inflate(-delta); - /// Returns a new rectangle that is the intersection of the given rectangle and this rectangle. + /// Returns a new rectangle that is the intersection of the given + /// rectangle and this rectangle. The two rectangles must overlap + /// for this to be meaningful. If the two rectangles do not overlap, + /// then the resulting Rect will have a negative width or height. Rect intersect(Rect other) { return new Rect.fromLTRB( math.max(left, other.left), math.max(top, other.top), math.min(right, other.right), - math.min(bottom, other.bottom)); + math.min(bottom, other.bottom) + ); } /// The distance between the left and right edges of this rectangle.