Documentation
On this page

Function · Desktop Services

renderDrawingToImage

Renders a validated drawing document to a bounded PNG data URI, optionally applying effects.

@sharpts/gui · SharpTS 572a2e31be0e

Signature

TypeScript
renderDrawingToImage(document: DrawingDocument, options: RenderDrawingToImageOptions = {}): Promise<DrawingImage>

Parameters

NameTypeDescription
documentDrawingDocumentBounded drawing document to composite and encode.
optionsRenderDrawingToImageOptions
Default: {}
Ordered post-composition effects; omitted options apply no effects.

Returns

Promise<DrawingImage> — The encoded image, its PNG data URI, and pixel dimensions.

Remarks

Effects are applied in array order after all visible layers have been composited.

Throws

  • When the document, an image source, or an effect value is invalid or exceeds drawing safety limits.

Examples

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

const document = { width: 64, height: 64, layers: [] };
const preview = await renderDrawingToImage(document, {
    effects: [{ kind: "grayscale" }]
});
console.log(preview.source);

Source

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