Reference · Framing, geometry and quiz tools
distanceToRingfunction
How far a point is from a ring's outline, ignoring which side of it the point is on.
Import it
import { distanceToRing } from "@johnmorrisdotca/chizu";
Definition
function distanceToRing(x: number, y: number, ring: MapRing): number
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
number
How far a point is from a ring's outline, ignoring which side of it the point is on.
Examples
import { distanceToRing, parseMapRings } from "@johnmorrisdotca/chizu";
const [square] = parseMapRings("M0,0L10,0L10,10L0,10Z");
console.log(distanceToRing(13, 5, square!), distanceToRing(5, 5, square!));
// 3 53 5What it prints (run when this page was built)