RectGrid.tileAt

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

struct RectGrid(T)
ref
tileAt
if (
isArray2D!T
)

Parameters

coord
Type: RowCol

a row/column pair identifying a point in the tile grid.

Examples

1 auto grid = rectGrid([
2   [ 00, 01, 02, 03, 04 ],
3   [ 10, 11, 12, 13, 14 ],
4   [ 20, 21, 22, 23, 24 ],
5 ]);
6 
7 assert(grid.tileAt(RowCol(0, 0)) == 00); // top left tile
8 assert(grid.tileAt(RowCol(2, 4)) == 24); // bottom right tile
9 assert(grid.tileAt(RowCol(1, 1)) == 11); // one down/right from the top left
10 
11 // tileAt returns a reference:
12 grid.tileAt(RowCol(2,2)) = 99;
13 assert(grid.tileAt(RowCol(2,2)) == 99);

Meta