Reference · Framing, geometry and quiz tools
regionBoxfunction
A window tight on one region, for drawing it on its own.
Two things decide it, and getting either wrong draws a country instead of a shape. The room around the region is a
fraction of that side of it, not of its longest side. And the window takes the shape of the frame it will be drawn
in (aspect, how much wider than tall), because an SVG scaled to fit keeps its window's proportions and fills the
rest of the frame with whatever is next to it. With both right the region fills the side that limits it, and the
room left over falls on the other side, where it does what the room was for: the neighbours show in outline, so it
is a place rather than a blob. Framed where it is drawn, so a region in an inset is framed there.
Import it
import { regionBox } from "@johnmorrisdotca/chizu";
Definition
function regionBox(map: Frameable, code: string | number, aspect?: number): MapBox
Parameters
| Name | Type | Description |
|---|---|---|
map | Frameable | The native map or map fields required by this signature; coordinates and region codes belong to its canvas. |
code | string | number | The native region or country code; null clears a region selection where accepted. |
aspect (optional) | number | The desired window width divided by its height. |
Returns
MapBox
A window tight on one region, for drawing it on its own.
Examples
import WORLD from "@johnmorrisdotca/chizu/world";
import { boxToViewBox, regionBox } from "@johnmorrisdotca/chizu";
const box = regionBox(WORLD, "IT", 4 / 3);
console.log((box.width / box.height).toFixed(3));
// 1.3331.333What it prints (run when this page was built)