示例#1
0
        public ArrayGrid <T> ExtractBlock(Rectangle block)
        {
            float top    = (float)block.Top;
            float left   = (float)block.Left;
            float right  = (float)block.Right;
            float bottom = (float)block.Bottom;

            top    = Math.Max(0, top);
            left   = Math.Max(0, left);
            right  = Math.Min((int)Size.X, right);
            bottom = Math.Min((int)Size.Y, bottom);

            var ret = new ArrayGrid <T>(new Vector2(right - left, bottom - top));

            foreach (var cell in ret.Points)
            {
                var src = GetFromPoint(cell.Translate(left, top));
                ret.Set(cell, src);
            }

            return(ret);
        }
示例#2
0
 public void Set(T value)
 {
     Grid.Set(Position, value);
 }