Function: pointInPolygon()
ts
function pointInPolygon(px, py, polygon): boolean;Experimental
Even-odd (crossing number) point-in-polygon test.
polygon is a flat [x0, y0, x1, y1, ...] ring; the closing edge is implicit. Even-odd is used (rather than non-zero winding) so self-intersecting lasso strokes behave predictably: regions wound an even number of times, e.g. the centre of a pentagram, are outside. Fewer than 3 vertices always returns false.
Parameters
| Parameter | Type |
|---|---|
px | number |
py | number |
polygon | ArrayLike<number> |
Returns
boolean