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

segmentCrossesBoxfunction

Whether a straight leader from a to b passes through this box.

Import it

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

Definition

function segmentCrossesBox(a: readonly [number, number], b: readonly [number, number], box: CalloutObstacle): boolean

Parameters

NameTypeDescription
areadonly [number, number]

The first point or segment endpoint, in native map units.

breadonly [number, number]

The second point or segment endpoint, in native map units.

boxCalloutObstacle

The window in native map units, or the inset destination specified by this signature.

Returns

boolean

Whether a straight leader from a to b passes through this box.

Examples

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

const box = { minX: 10, minY: 10, maxX: 20, maxY: 20 };
console.log(segmentCrossesBox([0, 15], [30, 15], box), segmentCrossesBox([0, 0], [30, 0], box));
// 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.