Skip to content

Documentation / @ripl/terminal / isPointInContours

Function: isPointInContours() ​

isPointInContours(contours, x, y, fillRule?): boolean

Defined in: terminal/src/hit.ts:39

Tests whether a point falls inside one or more closed contours.

Crossings are counted with a half-open edge test, so a vertex shared by two edges is counted once. evenodd alternates inside and outside on every crossing; nonzero accumulates the winding direction, so nested contours wound the same way stay filled.

Parameters ​

ParameterTypeDefault valueDescription
contoursVertex[][]undefinedThe contours to test against, implicitly closed.
xnumberundefinedX coordinate of the point.
ynumberundefinedY coordinate of the point.
fillRuleFillRule'nonzero'The fill rule to apply. Defaults to nonzero, as canvas does.

Returns ​

boolean

true when the point is inside.