PixelFarm.Drawing.RectangleF.Intersect C# (CSharp) Method

Intersect() public static method

Intersect Shared Method
Produces a new RectangleF by intersecting 2 existing RectangleFs. Returns null if there is no intersection.
public static Intersect ( RectangleF a, RectangleF b ) : RectangleF
a RectangleF
b RectangleF
return RectangleF
        public static RectangleF Intersect(RectangleF a,
                            RectangleF b)
        {
            // MS.NET returns a non-empty rectangle if the two rectangles
            // touch each other
            if (!a.IntersectsWithInclusive(b))
                return Empty;
            return 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));
        }

Same methods

RectangleF::Intersect ( RectangleF rect ) : void

Usage Example

Example #1
0
        /// <summary>
        ///	Intersect Method
        /// </summary>
        ///
        /// <remarks>
        ///	Replaces the RectangleF with the intersection of itself
        ///	and another RectangleF.
        /// </remarks>

        public void Intersect(RectangleF rect)
        {
            this = RectangleF.Intersect(this, rect);
        }