Documentation
On this page

Function · Desktop Services

sampleDrawingPixel

Samples one pixel from the fully composited drawing document.

@sharpts/gui · SharpTS 572a2e31be0e

Signature

TypeScript
sampleDrawingPixel(document: DrawingDocument, point: DrawingPoint): Promise<DrawingPixel>

Parameters

NameTypeDescription
documentDrawingDocumentBounded drawing document to composite before sampling.
pointDrawingPointPixel coordinate to sample from the composited image.

Returns

Promise<DrawingPixel> — The sampled red, green, blue, alpha, and normalized color values.

Remarks

Coordinates are floored to integer pixels after validation and are measured from the document's top-left corner.

Throws

  • When the document is invalid or the point is outside its pixel bounds.

Examples

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

const document = { width: 16, height: 16, background: "#336699", layers: [] };
const pixel = await sampleDrawingPixel(document, { x: 0, y: 0 });
console.log(pixel.color);

Source

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