Function · Desktop Services
floodFillDrawing
Applies a contiguous, four-connected flood fill and returns a rasterized document image.
@sharpts/gui · SharpTS 572a2e31be0eSignature
TypeScript
floodFillDrawing(document: DrawingDocument, options: DrawingFloodFillOptions): Promise<DrawingFloodFillResult>Parameters
| Name | Type | Description |
|---|---|---|
document | DrawingDocument | Bounded drawing document to composite before filling. |
options | DrawingFloodFillOptions | Seed 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);Related symbols
Source
src/SharpTS.Gui.Sdk/GuiPackage/runtime.ts:1592 at SharpTS revision 572a2e31be0e2a09be0138bc44501b34d6245b51.