RectGrid

A grid of rectangular tiles. Wraps a 2D array to provide grid-based access to tiles.

Constructors

this
this(T tiles)

Construct a grid from a 2D tile array. See rectGrid for a constructor with type inference.

Members

Aliases

TileType
alias TileType = typeof(_tiles[0][0])

The type used to represent a tile in this grid

Functions

adjacentTiles
auto adjacentTiles(RowCol coord, Diagonals diagonals)

Return all tiles adjacent to the tile at the given coord (not including the tile itself).

allCoords
auto allCoords()

Get a range that iterates through every coordinate in the grid.

allTiles
auto allTiles()

Get a range that iterates through every tile in the grid.

contains
bool contains(RowCol coord)

True if the grid coordinate is within the grid bounds.

maskCoords
auto maskCoords(RowCol offset, T mask)

Same as maskTiles, but return coords instead of tiles.

maskCoordsAround
auto maskCoordsAround(RowCol center, T mask)

Same as maskCoords, but centered.

maskTiles
auto maskTiles(RowCol offset, T mask)

Select specific tiles from this slice based on a mask.

maskTilesAround
auto maskTilesAround(RowCol center, T mask)

Same as maskTiles, but centered.

numCols
auto numCols()

Number of columns along a grid's x axis.

numRows
auto numRows()

Number of rows along a grid's y axis.

numTiles
auto numTiles()

The total number of tiles in a grid.

opApply
int opApply(int delegate(ref TileType) fn)

Foreach over every tile in the grid. Supports ref.

opApply
int opApply(int delegate(RowCol, ref TileType) fn)

Foreach over every (coord,tile) pair in the grid. Supports ref.

tileAt
auto ref tileAt(RowCol coord)

Get the tile at a given position in the grid. The coord must be in bounds.

tilesAt
auto ref tilesAt(R coords)

Access tiles via a range of coords. Tiles are returned by ref.

Meta