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

insetTransformfunction

What to do to a region's own geometry to seat it in its box: shrink it to fit if it is too big, centre it in the frame, and leave it at its own size unless the box says it may be magnified.

Import it

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

Definition

function insetTransform(bbox: readonly [number, number, number, number], box: MapBox, magnify?: boolean): InsetTransform

Parameters

NameTypeDescription
bboxreadonly [number, number, number, number]

The native left, top, right and bottom bounds of the geometry.

boxMapBox

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

magnify (optional)boolean

Whether the inset may enlarge its geometry instead of only shrinking it.

Returns

InsetTransform

What to do to a region's own geometry to seat it in its box: shrink it to fit if it is too big, centre it in the frame, and leave it at its own size unless the box says it may be magnified.

Examples

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

// A region 400 wide seated in a box 200 wide is halved and centred.
console.log(insetTransform([0, 0, 400, 100], { x: 10, y: 10, width: 200, height: 100 }));
// { scale: 0.5, x: 10, y: 35 }
{ scale: 0.5, x: 10, y: 35 }

What it prints (run when this page was built)

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