Skip to main content

Function: traceOutline()

traceOutline(alpha, width, height, __namedParameters?): OutlineSegment[]

Defined in: src/lib/rendering/outline/index.ts:24

Trace the outline of a shape from its alpha values (marching squares). Pixels at or above the threshold are inside. Returns line segments in coordinates from 0 to 1 (so the outline can be drawn at any size), or in pixels. Outline points lie halfway between pixel centres, so in pixels they are always whole or half numbers.

Parameters​

alpha​

ArrayLike<number>

one alpha value (0–255) per pixel, row by row

width​

number

height​

number

__namedParameters?​

TraceOptions = {}

Returns​

OutlineSegment[]

Example​

traceOutline(new Uint8ClampedArray([0, 0, 0, 0, 255, 0, 0, 0, 0]), 3, 3); // segments around the centre pixel