MegaMan.Common.Geometry.RectangleF.Intersect C# (CSharp) Method

Intersect() public static method

public static Intersect ( RectangleF a, RectangleF b ) : RectangleF
a RectangleF
b RectangleF
return RectangleF
        public static RectangleF Intersect(RectangleF a, RectangleF b)
        {
            float num = Math.Max(a.X, b.X);
            float num2 = Math.Min(a.X + a.Width, b.X + b.Width);
            float num3 = Math.Max(a.Y, b.Y);
            float num4 = Math.Min(a.Y + a.Height, b.Y + b.Height);
            if (num2 >= num && num4 >= num3)
            {
                return new RectangleF(num, num3, num2 - num, num4 - num3);
            }
            return RectangleF.Empty;
        }

Same methods

RectangleF::Intersect ( RectangleF rect ) : void

Usage Example

Esempio n. 1
0
        public void Intersect(RectangleF rect)
        {
            RectangleF rectangleF = RectangleF.Intersect(rect, this);

            this.X      = rectangleF.X;
            this.Y      = rectangleF.Y;
            this.Width  = rectangleF.Width;
            this.Height = rectangleF.Height;
        }