Skip to main content

Function: floodFill()

floodFill(getter, seed, options): FloodFillResult

floodFill.js - Taken from MIT OSS lib - https://github.com/tuzz/n-dimensional-flood-fill Refactored to ES6. Fixed the bounds/visits checks to use integer keys, restricting the total search spacing to +/- 32k in each dimension, but resulting in about a hundred time performance gain for larger regions since JavaScript does not have a hash map to allow the map to work on keys.

Parameters

getter: FloodFillGetter

The getter to the elements of your data structure, e.g. getter(x,y) for a 2D interpretation of your structure.

seed: Point3 | Point2

The seed for your fill. The dimensionality is inferred by the number of dimensions of the seed.

options: FloodFillOptions = {}

Returns

FloodFillResult

Flood fill results

Defined in

tools/src/utilities/segmentation/floodFill.ts:34