* Rectangle.cs (Intersect): Return a non-empty rectangle if the two
rectangles touch each other.
svn path=/trunk/mcs/; revision=48230
-2005-08-10 Konstantin Triger <kostat@mainsoft.com>
+2005-08-10 Zoltan Varga <vargaz@freemail.hu>
+
+ * Rectangle.cs (Intersect): Return a non-empty rectangle if the two
+ rectangles touch each other.
+
+2005-08-09 Konstantin Triger <kostat@mainsoft.com>
* Graphics.jvm.cs: Fixed DrawCurve.2005-08-10 Konstantin Triger <kostat@mainsoft.com>
public static Rectangle Intersect (Rectangle r1, Rectangle r2)
{
- if (!r1.IntersectsWith (r2))
+ // MS.NET returns a non-empty rectangle if the two rectangles
+ // touch each other
+ if (!r1.IntersectsWithInclusive (r2))
return Empty;
return Rectangle.FromLTRB (
(Top >= r.Bottom) || (Bottom <= r.Top));
}
+ private bool IntersectsWithInclusive (Rectangle r)
+ {
+ return !((Left > r.Right) || (Right < r.Left) ||
+ (Top > r.Bottom) || (Bottom < r.Top));
+ }
+
/// <summary>
/// Offset Method
/// </summary>