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

segmentMeetsRingfunction

Whether a straight line from one point to another passes over the land inside a ring.

Import it

import { segmentMeetsRing } from "@johnmorrisdotca/chizu";

Definition

function segmentMeetsRing(ax: number, ay: number, bx: number, by: number, ring: MapRing): boolean

Parameters

NameTypeDescription
axnumber

The first segment endpoint’s horizontal map coordinate.

aynumber

The first segment endpoint’s vertical map coordinate.

bxnumber

The second segment endpoint’s horizontal map coordinate.

bynumber

The second segment endpoint’s vertical map coordinate.

ringMapRing

A closed outline ring in native map units.

Returns

boolean

Whether a straight line from one point to another passes over the land inside a ring.

Examples

import { parseMapRings, segmentMeetsRing } from "@johnmorrisdotca/chizu";

const [square] = parseMapRings("M0,0L10,0L10,10L0,10Z");
console.log(segmentMeetsRing(-5, 5, 15, 5, square!), segmentMeetsRing(-5, 20, 15, 20, square!));
// true false
true false

What it prints (run when this page was built)

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