Reference · Framing, geometry and quiz tools
pointInRingfunction
Whether a point is inside a ring, by the crossing rule.
Import it
import { pointInRing } from "@johnmorrisdotca/chizu";
Definition
function pointInRing(x: number, y: number, ring: MapRing): boolean
Parameters
| Name | Type | Description |
|---|---|---|
x | number | The horizontal native map coordinate. |
y | number | The vertical native map coordinate. |
ring | MapRing | A closed outline ring in native map units. |
Returns
boolean
Whether a point is inside a ring, by the crossing rule.
Examples
import { parseMapRings, pointInRing } from "@johnmorrisdotca/chizu";
const [square] = parseMapRings("M0,0L10,0L10,10L0,10Z");
console.log(pointInRing(5, 5, square!), pointInRing(15, 5, square!));
// true falsetrue falseWhat it prints (run when this page was built)