示例#1
0
 public static RectInt32 Union(RectInt32?rect1, RectInt32 rect2)
 {
     if (!rect1.HasValue)
     {
         return(rect2);
     }
     return(RectInt32.Union(rect1.Value, rect2));
 }
        public static RectInt32 Bounds(this RectInt32[] rects, int startIndex, int length)
        {
            Validate.Begin().IsNotNull <RectInt32[]>(rects, "rects").Check().IsRangeValid(rects.Length, startIndex, length, "rects").Check();
            if (length == 0)
            {
                return(RectInt32.Zero);
            }
            RectInt32 a = rects[startIndex];

            for (int i = startIndex + 1; i < (startIndex + length); i++)
            {
                a = RectInt32.Union(a, rects[i]);
            }
            return(a);
        }
示例#3
0
 public static RectInt32?Union(RectInt32?rect1, RectInt32?rect2)
 {
     if (!rect1.HasValue && !rect2.HasValue)
     {
         return(null);
     }
     if (rect1.HasValue && !rect2.HasValue)
     {
         return(new RectInt32?(rect1.Value));
     }
     if (!rect1.HasValue && rect2.HasValue)
     {
         return(new RectInt32?(rect2.Value));
     }
     return(new RectInt32?(RectInt32.Union(rect1.Value, rect2.Value)));
 }
        public static RectInt32 Bounds(this IEnumerable <RectInt32> rects)
        {
            RectInt32 zero = RectInt32.Zero;
            bool      flag = true;

            foreach (RectInt32 num2 in rects)
            {
                if (flag)
                {
                    zero = num2;
                    flag = false;
                }
                else
                {
                    zero = RectInt32.Union(zero, num2);
                }
            }
            if (flag)
            {
                return(RectInt32.Empty);
            }
            return(zero);
        }