RectGrid.tileAt

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

struct RectGrid(T)
ref
tileAt

Parameters

coord RowCol

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

Examples

auto grid = rectGrid([
  [ 00, 01, 02, 03, 04 ],
  [ 10, 11, 12, 13, 14 ],
  [ 20, 21, 22, 23, 24 ],
]);

assert(grid.tileAt(RowCol(0, 0)) == 00); // top left tile
assert(grid.tileAt(RowCol(2, 4)) == 24); // bottom right tile
assert(grid.tileAt(RowCol(1, 1)) == 11); // one down/right from the top left

// tileAt returns a reference:
grid.tileAt(RowCol(2,2)) = 99;
assert(grid.tileAt(RowCol(2,2)) == 99);

Meta