OrthoMap.tileAtPoint

Get the tile at a given pixel position on the map. Throws if out of bounds.

struct OrthoMap(Tile)
ref
Tile
tileAtPoint
(
T
)
(
T pos
)

Parameters

T

any pixel-positional point (see isPixelCoord).

pos T

pixel location in 2D space

Examples

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

auto map = OrthoMap!int(grid, 32, 32);

assert(map.tileAtPoint(PixelCoord(  0,  0)) == 00); // corner of top left tile
assert(map.tileAtPoint(PixelCoord( 16, 30)) == 00); // inside top left tile
assert(map.tileAtPoint(PixelCoord(149, 95)) == 24); // inside bottom right tile

Meta