Windows.Foundation.Rect.Intersect C# (CSharp) Метод

Intersect() публичный Метод

public Intersect ( Rect rect ) : void
rect Rect
Результат void
        public void Intersect(Rect rect)
        {
            if (!this.IntersectsWith(rect))
            {
                this = s_empty;
            }
            else
            {
                double left = Math.Max(X, rect.X);
                double top = Math.Max(Y, rect.Y);

                //  Max with 0 to prevent double weirdness from causing us to be (-epsilon..0)
                Width = Math.Max(Math.Min(X + Width, rect.X + rect.Width) - left, 0);
                Height = Math.Max(Math.Min(Y + Height, rect.Y + rect.Height) - top, 0);

                X = left;
                Y = top;
            }
        }

Usage Example

Пример #1
0
 private static bool RectsOverlap(Rect r1, Rect r2)
 {
     r1.Intersect(r2);
     if (r1.Width > 0 || r1.Height > 0)
         return true;
     return false;
 }
All Usage Examples Of Windows.Foundation.Rect::Intersect