Reference · Framing, geometry and quiz tools
placeCalloutsfunction
Places every circle in the open space around the map.
The hardest region chooses first: the one whose nearest room is furthest away has nothing else to take, and a coastal region that picked early would leave an inland one nowhere to go. Then the arrangement is walked downhill - each circle offered a better place, each crossing pair offered each other's - until nothing improves.
Import it
import { placeCallouts } from "@johnmorrisdotca/chizu";
Definition
function placeCallouts<T>(entries: ReadonlyArray<{ item: T; centroid: readonly [number, number]; }>, radius: number, box: MapBox, keepOut?: CalloutKeepOut, land?: readonly CalloutLand[], options?: { polish?: boolean; }): Array<HandleSpot & { item: T; }>
Parameters
| Name | Type | Description |
|---|---|---|
entries | readonly { item: T; centroid: readonly [number, number]; }[] | Native places to order or lay out. |
radius | number | The circle or label radius in native map units. |
box | MapBox | The window in native map units, or the inset destination specified by this signature. |
keepOut (optional) | CalloutKeepOut | The native frame areas reserved against callout placement. |
land (optional) | readonly CalloutLand[] | Native land geometry or land obstacles that labels must avoid. |
options (optional) | { polish?: boolean; } | The optional native drawing, matching, layout or quiz settings described by this signature. |
Returns
(HandleSpot & { item: T; })[]
Places every circle in the open space around the map.
Examples
import { placeCallouts } from "@johnmorrisdotca/chizu";
const spots = placeCallouts([{ item: "a", centroid: [40, 50] }, { item: "b", centroid: [60, 50] }], 4, { x: 0, y: 0, width: 100, height: 100 });
console.log(spots.map((spot) => spot.item).join(" "));
// a ba bWhat it prints (run when this page was built)