예제 #1
0
        public void Intersect(Rectangle rect1, Rectangle rect2)
        {
            if (rect1.Left.IsLess(rect2.Left))
            {
                Left = rect2.Left;
            }
            else
            {
                Left = rect1.Left;
            }

            if (rect1.Right.IsLess(rect2.Right))
            {
                Width = rect1.Right - Left;
            }
            else
            {
                Width = rect2.Right - Left;
            }

            if (rect1.Top.IsLess(rect2.Top))
            {
                Top = rect2.Top;
            }
            else
            {
                Top = rect1.Top;
            }

            if (rect1.Bottom.IsLess(rect2.Bottom))
            {
                Height = rect1.Bottom - Top;
            }
            else
            {
                Height = rect2.Bottom - Top;
            }

            if (Width.IsLess(0.0f))
            {
                Width = 0.0f;
            }
            if (Height.IsLess(0.0f))
            {
                Height = 0.0f;
            }
        }