예제 #1
0
        public static Rect2D Union(this Rect2D rect, Route route)
        {
            if (route == null)
            {
                throw new ArgumentNullException(nameof(route));
            }

            var result = rect;

            foreach (var point in route)
            {
                result = result.Union(point);
            }

            return(result);
        }
예제 #2
0
        public static Rect2D Intersect(Rect2D rect1, Rect2D rect2)
        {
            if (rect1.IsUndefined() || rect2.IsUndefined())
            {
                return(Undefined);
            }

            var left = Math.Max(rect1.Left, rect2.Left);
            var top  = Math.Max(rect1.Top, rect2.Top);

            var right  = Math.Min(rect1.Right, rect2.Right);
            var bottom = Math.Min(rect1.Bottom, rect2.Bottom);

            return(left >= right || top >= bottom
                ? Undefined
                : new Rect2D(new Point2D(left, top), new Point2D(right, bottom)));
        }
예제 #3
0
        public static Rect2D Union(Rect2D rect1, Rect2D rect2)
        {
            if (rect1.IsUndefined())
            {
                return(rect2);
            }

            if (rect2.IsUndefined())
            {
                return(rect1);
            }

            var left = Math.Min(rect1.Left, rect2.Left);
            var top  = Math.Min(rect1.Top, rect2.Top);

            var right  = Math.Max(rect1.Right, rect2.Right);
            var bottom = Math.Max(rect1.Bottom, rect2.Bottom);

            return(new Rect2D(new Point2D(left, top), new Point2D(right, bottom)));
        }
예제 #4
0
 public bool Equals(Rect2D other)
 {
     return(TopLeft.Equals(other.TopLeft) && Size.Equals(other.Size));
 }
예제 #5
0
 public bool Equals(Rect2D other)
 {
     return(Size.Equals(other.Size) && Center.Equals(other.Center));
 }
예제 #6
0
 public static bool IsUndefined(this Rect2D rect)
 {
     return(double.IsNaN(rect.Left) || double.IsNaN(rect.Top) || double.IsNaN(rect.Width) || double.IsNaN(rect.Height));
 }
예제 #7
0
 public static Rect2D Intersect(this Rect2D rect1, Rect2D rect2)
 {
     return(Rect2D.Intersect(rect1, rect2));
 }
예제 #8
0
 public static Rect2D Union(this Rect2D rect, Point2D point)
 {
     return(Union(rect, new Rect2D(point, point)));
 }
예제 #9
0
 public static Rect2D Union(this Rect2D rect1, Rect2D rect2)
 {
     return(Rect2D.Union(rect1, rect2));
 }
예제 #10
0
 public static bool IsDefined(this Rect2D rect) => !rect.IsUndefined();