floodFill

Implements a flood fill algorithm, like the bucket tool in MS Paint.

@safe
void
floodFill
(
T
)
(
T[] what
,
int width
,
int height
,,,
int x
,
int y
,
bool delegate(
int x
,
int y
) @safe
additionalCheck
)

Parameters

what
Type: T[]

the canvas to work with, arranged as top to bottom, left to right elements

width
Type: int

the width of the canvas

height
Type: int

the height of the canvas

target
Type: T

the type to replace. You may pass the existing value if you want to do what Paint does

replacement
Type: T

the replacement value

x
Type: int

the x-coordinate to start the fill (think of where the user clicked in Paint)

y
Type: int

the y-coordinate to start the fill

additionalCheck
Type: bool delegate(
int x
,
int y
) @safe

A custom additional check to perform on each square before continuing. Returning true means keep flooding, returning false means stop.

Meta