Class RectGrid<TCell>
Represents a rectangular grid.
[Version(1, 0, 0)]
[Serializable]
public class RectGrid<TCell> : AbstractUniformGrid<TCell, RectPoint>, IEvenGrid<TCell, RectPoint, RectPoint>, IVectorGrid<TCell, RectPoint, RectPoint>, IGrid<TCell, RectPoint>, IGrid<RectPoint>, IGridSpace<RectPoint>, IEnumerable<RectPoint>, IEnumerable, ISupportsVertexGrid<RectPoint>, ISupportsEdgeGrid<DiamondPoint>
Type Parameters
TCell
- Inheritance
-
AbstractUniformGrid<TCell, RectPoint>RectGrid<TCell>
- Implements
- Inherited Members
- Extension Methods
Constructors
RectGrid(int, int)
Construct a new grid in the default shape with the given width and height. No transformations are applied to the grid.
Normally, the static factory methods or shape building methods should be used to create grids. These constructors are provided for advanced usage.
public RectGrid(int width, int height)
Parameters
RectGrid(int, int, Func<RectPoint, bool>)
Construct a new grid whose cells are determined by the given test function.
The test function should only return true for points within the bounds of the default shape.
No transformations are applied to the grid.
Normally, the static factory methods or shape building methods should be used to create grids. These constructors are provided for advanced usage.
public RectGrid(int width, int height, Func<RectPoint, bool> isInside)
Parameters
RectGrid(int, int, Func<RectPoint, bool>, RectPoint)
Construct a new grid whose cells are determined by the given test function.
The function should only return true for points within the bounds of the rectangle when the given transforms are applied to them.
Normally, the static factory methods or shape building methods should be used to create grids. These constructors are provided for advanced usage.
public RectGrid(int width, int height, Func<RectPoint, bool> isInside, RectPoint offset)
Parameters
RectGrid(int, int, Func<RectPoint, bool>, Func<RectPoint, RectPoint>, Func<RectPoint, RectPoint>)
public RectGrid(int width, int height, Func<RectPoint, bool> isInside, Func<RectPoint, RectPoint> gridPointTransform, Func<RectPoint, RectPoint> inverseGridPointTransform)
Parameters
width
intheight
intisInside
Func<RectPoint, bool>gridPointTransform
Func<RectPoint, RectPoint>inverseGridPointTransform
Func<RectPoint, RectPoint>
RectGrid(int, int, Func<RectPoint, bool>, Func<RectPoint, RectPoint>, Func<RectPoint, RectPoint>, IEnumerable<RectPoint>)
public RectGrid(int width, int height, Func<RectPoint, bool> isInside, Func<RectPoint, RectPoint> gridPointTransform, Func<RectPoint, RectPoint> inverseGridPointTransform, IEnumerable<RectPoint> neighborDirections)
Parameters
width
intheight
intisInside
Func<RectPoint, bool>gridPointTransform
Func<RectPoint, RectPoint>inverseGridPointTransform
Func<RectPoint, RectPoint>neighborDirections
IEnumerable<RectPoint>
Properties
GridOrigin
Gives the Zero point as transform by this grids transforms.
protected override RectPoint GridOrigin { get; }
Property Value
Height
public int Height { get; }
Property Value
Width
public int Width { get; }
Property Value
Methods
ArrayPointFromGridPoint(RectPoint)
public static ArrayPoint ArrayPointFromGridPoint(RectPoint point)
Parameters
point
RectPoint
Returns
ArrayPointFromPoint(RectPoint)
protected override ArrayPoint ArrayPointFromPoint(RectPoint point)
Parameters
point
RectPoint
Returns
ArrayPointFromPoint(int, int)
protected override ArrayPoint ArrayPointFromPoint(int x, int y)
Parameters
Returns
BeginShape()
Use this method to begin a shape building sequence.
public static RectOp<TCell> BeginShape()
Returns
- RectOp<TCell>
CalculateStorage(IEnumerable<RectPoint>)
public static IntRect CalculateStorage(IEnumerable<RectPoint> points)
Parameters
points
IEnumerable<RectPoint>
Returns
CheckerBoard(int, int)
public static RectGrid<TCell> CheckerBoard(int width, int height)
Parameters
Returns
- RectGrid<TCell>
CheckerBoard(int, int, bool)
public static RectGrid<TCell> CheckerBoard(int width, int height, bool includesOrigin)
Parameters
Returns
- RectGrid<TCell>
Circle(int)
public static RectGrid<TCell> Circle(int radius)
Parameters
radius
int
Returns
- RectGrid<TCell>
CloneStructure<TNewCellType>()
Returns a grid in the same shape, but with contents in the new type.
public override IGrid<TNewCellType, RectPoint> CloneStructure<TNewCellType>()
Returns
Type Parameters
TNewCellType
Default(int, int)
public static RectGrid<TCell> Default(int width, int height)
Parameters
Returns
- RectGrid<TCell>
DefaultContains(RectPoint, int, int)
public static bool DefaultContains(RectPoint point, int width, int height)
Parameters
Returns
FixedHeight(int, int)
public static RectGrid<TCell> FixedHeight(int height, int cellCount)
Parameters
Returns
- RectGrid<TCell>
FixedWidth(int, int)
public static RectGrid<TCell> FixedWidth(int width, int cellCount)
Parameters
Returns
- RectGrid<TCell>
GetPrincipleNeighborDirections()
Returns the neighbors so that no two are in the same line. For example, if East is among them, then West won't be.
public IEnumerable<RectPoint> GetPrincipleNeighborDirections()
Returns
GetSpiralIterator(RectPoint, int)
[Version(1, 8, 0)]
public IEnumerable<RectPoint> GetSpiralIterator(RectPoint origin, int ringCount)
Parameters
Returns
GetSpiralIterator(int)
[Version(1, 10, 0)]
public IEnumerable<RectPoint> GetSpiralIterator(int ringCount)
Parameters
ringCount
int
Returns
GridPointFromArrayPoint(ArrayPoint)
public static RectPoint GridPointFromArrayPoint(ArrayPoint point)
Parameters
point
ArrayPoint
Returns
HorizontallyWrappedParallelogram(int, int)
Returns a grid wrapped horizontally along a parallelogram.
Since version 1.7
public static WrappedGrid<TCell, RectPoint> HorizontallyWrappedParallelogram(int width, int height)
Parameters
Returns
- WrappedGrid<TCell, RectPoint>
MakeEdgeGrid<TNewCell>()
Makes an edge grid for this grid.
public IGrid<TNewCell, DiamondPoint> MakeEdgeGrid<TNewCell>()
Returns
- IGrid<TNewCell, DiamondPoint>
Type Parameters
TNewCell
MakeVertexGrid<TNewCell>()
Makes a grid that corresponds to the vertices of this grid.
If point is inside this grid, then all of point.GetVertices() are in the grid returned by this method.
public IGrid<TNewCell, RectPoint> MakeVertexGrid<TNewCell>()
Returns
Type Parameters
TNewCell
Parallelogram(int, int)
public static RectGrid<TCell> Parallelogram(int width, int height)
Parameters
Returns
- RectGrid<TCell>
PointFromArrayPoint(int, int)
protected override RectPoint PointFromArrayPoint(int x, int y)
Parameters
Returns
Rectangle(int, int)
public static RectGrid<TCell> Rectangle(int width, int height)
Parameters
Returns
- RectGrid<TCell>
SetNeighborsDiagonals()
public void SetNeighborsDiagonals()
SetNeighborsMain()
public void SetNeighborsMain()
SetNeighborsMainAndDiagonals()
public void SetNeighborsMainAndDiagonals()
Single()
public static RectGrid<TCell> Single()
Returns
- RectGrid<TCell>
ToString()
public override string ToString()
Returns
VerticallyWrappedParallelogram(int, int)
Returns a grid wrapped vertically along a parallelogram.
Since version 1.7
public static WrappedGrid<TCell, RectPoint> VerticallyWrappedParallelogram(int width, int height)
Parameters
Returns
- WrappedGrid<TCell, RectPoint>
WrappedParallelogram(int, int)
Returns a grid wrapped along a parallelogram.
Since version 1.7
public static WrappedGrid<TCell, RectPoint> WrappedParallelogram(int width, int height)
Parameters
Returns
- WrappedGrid<TCell, RectPoint>