Template OrthoMap.coordAtPoint
Get the grid
location corresponding to a given pixel coordinate.
If the point is out of map bounds, the returned coord will also be out of bounds.
Use the containsPoint
method to check if a point is in bounds.
Arguments
template coordAtPoint(T);
Functions
Function name | Description |
---|---|
coordAtPoint |
Example
// 5x3 map, rows from 0 to 4, cols from 0 to 2 auto tiles = [ [ 00, 01, 02, 03, 04, ], [ 10, 11, 12, 13, 14, ], [ 20, 21, 22, 23, 24, ], ]; auto map = OrthoMap!int(tiles, 32, 32); assert( map.contains(RowCol(0 , 0))); // top left assert( map.contains(RowCol(2 , 4))); // bottom right assert( map.contains(RowCol(1 , 3))); // center assert(!map.contains(RowCol(3 , 0))); // beyond bottom border assert(!map.contains(RowCol(0 , 5))); // beyond right border assert(!map.contains(RowCol(0 ,-1))); // beyond left border assert(!map.contains(RowCol(-1, 0))); // beyond top border
Authors
Copyright
Copyright © 2015, Ryan Roden-Corrent