Skip to the content

Chizu地図

Draw SVG maps, frame regions, place numbered callouts and build geography quizzes with English and Japanese names.

Chizu is the Japanese word 地図 for map. About the name

Contents

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

NameTypeDescription
xnumber

The horizontal native map coordinate.

ynumber

The vertical native map coordinate.

ringMapRing

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 5
3 5

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/chizu 1.5.0.