Function createMaskAround

Same as createMask, but specify the offset of the mask's center rather than the top-left corner.

Prototype

void createMaskAround(alias fn, T, U)(
  T grid,
  RowCol center,
  ref U mask
)
if (__traits(compiles, ()
{
mask[0][0] = fn(grid.tileAt(RowCol(0, 0)));
}
));

Parameters

NameDescription
fn function that generates a mask entry from a tile
grid grid to generate mask from
center center position around which to generate mask
mask rectangular array to populate with generated mask values. must match the size of the grid

Example

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

uint[3][3] mask;

myGrid.createMaskAround!(tile => tile > 10)(RowCol(1,1), mask);

assert(mask == [
    [0, 0, 0],
    [0, 1, 1],
    [1, 1, 1],
]);

myGrid.createMaskAround!(tile => tile < 24)(RowCol(2,4), mask);

assert(mask == [
    [1, 1, 0],
    [1, 0, 0],
    [0, 0, 0],
]);

Authors

rcorre

Copyright

Copyright © 2015, Ryan Roden-Corrent

License

MIT