Exemplo n.º 1
0
 /// <summary>Adds a <see cref="FloodFillRange"/> to the end of the queue.</summary>
 public void Enqueue( ref FloodFillRange r )
 {
     if( Count + _head == _array.Length ) {
     var newArray = new FloodFillRange[ 2 * _array.Length ];
     Array.Copy( _array, _head, newArray, 0, Count );
     _array = newArray;
     _head = 0;
       }
       _array[ _head + ( Count++ ) ] = r;
 }
Exemplo n.º 2
0
 /// <summary>Removes and returns the <see cref="FloodFillRange"/> at the beginning of the queue.</summary>
 public FloodFillRange Dequeue()
 {
     var range = new FloodFillRange();
       if( Count > 0 ) {
     range = _array[ _head ];
     _array[ _head ] = new FloodFillRange();
     _head++;//advance head position
     Count--;//update size to exclude dequeued item
       }
       return range;
 }
Exemplo n.º 3
0
        void LinearFill( int x, int y )
        {
            var point = new Point( x, y );
              var leftMost = Blocks.LeftmostWhere( point, b => !b );
              var rightMost = Blocks.RightmostWhere( point, b => !b );
              var count = ( rightMost - leftMost ) + 1;
              Enumerable.Range( leftMost, count ).ToList().ForEach(
            i =>
              _flooded[ y * Blocks.Height + i ] = true
              );

              var range = new FloodFillRange( leftMost, rightMost, y );
              _ranges.Enqueue( ref range );
        }