Skip to content

FloodFill<TPixel>

Namespace Nfty.Core.Editing in assembly Nfty.Core.

public sealed class FloodFill<TPixel> : RegionEditCommand<TPixel>

4-connected flood fill of the region matching the seed pixel exactly.

Type parameters

  • TPixel - The pixel the target surface stores.

Remarks

The region's extent is defined by the seed's whole pixel, alpha included, so a fill spreads across an erased area without leaking into a painted one. The alpha it writes therefore depends on what the caller hands it rather than on a brush constant, which is exactly why the OpacityLock is enforced in the base and not in each command.

Constructors

FloodFill(int, int, TPixel, OpacityLock)

public FloodFill(int seedX, int seedY, TPixel fill, OpacityLock opacity = OpacityLock.Locked);

Fills the region matching the seed pixel.

Parameters

  • seedX (int) - Seed column.
  • seedY (int) - Seed row.
  • fill (TPixel) - The pixel to write.
  • opacity (OpacityLock) - Whether partial alpha is admitted; locked by default.

Methods

ComputePixels(IEditSurface<TPixel>)

protected override IReadOnlyList<(int, int, TPixel)> ComputePixels(IEditSurface<TPixel> surface);

Target pixels and their new values. Only in-bounds pixels, each coordinate at most once; computed before any mutation.

Parameters

  • surface (IEditSurface<TPixel>) - The surface being edited, for reading the pixels the edit depends on.

Returns. The pixels to write, before the opacity lock is applied to them.