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
Type: T

grid to generate mask from

center
Type: RowCol

center position around which to generate mask

mask
Type: U

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

Examples

1 auto myGrid = rectGrid([
2     [ 00, 01, 02, 03, 04 ],
3     [ 10, 11, 12, 13, 14 ],
4     [ 20, 21, 22, 23, 24 ],
5 ]);
6 
7 uint[3][3] mask;
8 
9 myGrid.createMaskAround!(tile => tile > 10)(RowCol(1,1), mask);
10 
11 assert(mask == [
12     [0, 0, 0],
13     [0, 1, 1],
14     [1, 1, 1],
15 ]);
16 
17 myGrid.createMaskAround!(tile => tile < 24)(RowCol(2,4), mask);
18 
19 assert(mask == [
20     [1, 1, 0],
21     [1, 0, 0],
22     [0, 0, 0],
23 ]);

Meta