Beispiel #1
0
 /// <summary>Expand the size of the data to allow writing to the specified area. Copies the data only if required.</summary>
 public Data2D <T> LazyCopyExpandToContain(Rectangle newBounds, T defaultData = default(T))
 {
     if (Bounds.ContainsIgnoreEmpty(newBounds))
     {
         return(this); // We're already the right size
     }
     newBounds = RectangleExtensions.UnionIgnoreEmpty(Bounds, newBounds);
     return(CopyWithNewBounds(newBounds, defaultData));
 }
Beispiel #2
0
 /// <summary>Expand the size of the data to allow writing to the specified area. Copies the data only if required.</summary>
 public MaskData LazyCopyExpandToContain(Rectangle newBounds)
 {
     if (Bounds.ContainsIgnoreEmpty(newBounds))
     {
         return(this); // We're already the right size
     }
     newBounds = RectangleExtensions.UnionIgnoreEmpty(Bounds, newBounds);
     return(CopyWithNewBounds(newBounds));
 }
Beispiel #3
0
        public Rectangle FindExtents()
        {
            Rectangle foundRegion = Rectangle.Empty;

            for (int y = StartY; y < EndY; y++)
            {
                for (int x = StartX; x < EndX; x++)
                {
                    if (this[x, y])
                    {
                        foundRegion = RectangleExtensions.UnionIgnoreEmpty(foundRegion, new Rectangle(x, y, 1, 1)); // TODO: PERF: This is horribly inefficient
                    }
                }
            }

            return(foundRegion);
        }