Documentation
On this page

Function · Desktop Services

floodFillDrawing

Applies a contiguous, four-connected flood fill and returns a rasterized document image.

@sharpts/gui · SharpTS 572a2e31be0e

Signature

TypeScript
floodFillDrawing(document: DrawingDocument, options: DrawingFloodFillOptions): Promise<DrawingFloodFillResult>

Parameters

NameTypeDescription
documentDrawingDocumentBounded drawing document to composite before filling.
optionsDrawingFloodFillOptionsSeed coordinate, replacement color, and optional channel tolerance.

Returns

Promise<DrawingFloodFillResult> — Whether pixels changed and, when they did, the resulting rasterized image.

Remarks

The fill compares normalized color-channel differences and visits four-connected neighboring pixels. The source document is not mutated.

Throws

  • When the document, seed coordinate, replacement color, or tolerance is invalid or exceeds drawing safety limits.

Examples

TypeScript
import { floodFillDrawing } from "@sharpts/gui";

const document = { width: 16, height: 16, background: "#ffffff", layers: [] };
const result = await floodFillDrawing(document, { x: 0, y: 0, color: "#0066cc" });
if (result.changed) console.log(result.image.source);

Source

src/SharpTS.Gui.Sdk/GuiPackage/runtime.ts:1592 at SharpTS revision 572a2e31be0e2a09be0138bc44501b34d6245b51.