本文整理汇总了C#中System.Drawing.Rectangle.IntersectsWithInclusive方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.IntersectsWithInclusive方法的具体用法?C# Rectangle.IntersectsWithInclusive怎么用?C# Rectangle.IntersectsWithInclusive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Rectangle
的用法示例。
在下文中一共展示了Rectangle.IntersectsWithInclusive方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Intersect
/// <summary>
/// Intersect Shared Method
/// </summary>
///
/// <remarks>
/// Produces a new Rectangle by intersecting 2 existing
/// Rectangles. Returns null if there is no intersection.
/// </remarks>
public static Rectangle Intersect(Rectangle a, Rectangle b)
{
// MS.NET returns a non-empty rectangle if the two rectangles
// touch each other
if (!a.IntersectsWithInclusive (b))
return Empty;
return Rectangle.FromLTRB (
Math.Max (a.Left, b.Left),
Math.Max (a.Top, b.Top),
Math.Min (a.Right, b.Right),
Math.Min (a.Bottom, b.Bottom));
}
示例2: Intersect
public static Rectangle Intersect(Rectangle r1, Rectangle r2)
{
// MS.NET returns a non-empty rectangle if the two rectangles
// touch each other
if (!r1.IntersectsWithInclusive(r2)) {
return Empty;
}
return Rectangle.FromLTRB(
Math.Max(r1.x, r2.x),
Math.Max(r1.y, r2.y),
Math.Min(r1.Right, r2.Right),
Math.Min(r1.Bottom, r2.Bottom));
}