createMaskAround

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

void
createMaskAround
(
alias fn
T
U
)
if (
__traits(compiles, )
)

Parameters

fn

function that generates a mask entry from a tile

grid T

grid to generate mask from

center RowCol

center position around which to generate mask

mask U

rectangular array to populate with generated mask values. must match the size of the grid

Examples

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],
]);

Meta