ChizuPlace型
リファレンスの説明と例は英語です。見出しと目次は日本語です。
The part of a region the engine reads, so a map of your own regions needs no more than these.
インポート
import type { ChizuPlace } from "@johnmorrisdotca/chizu";
定義
type ChizuPlace = Pick<ChizuRegion, "code" | "path" | "bbox" | "centroid" | "neighbors" | "group">;
メンバー
| 名前 | 型 | 説明 |
|---|---|---|
code | string | Its code within its map: an ISO 3166-1 alpha-2 code on the world ( |
path | string | Its outline, |
bbox | [number, number, number, number] | The box round all of it. |
centroid | [number, number] | The middle of it, which falls in the sea when the place is a chain or a crescent: |
neighbors | string[] | The codes of the regions that share a border point with it, in order. |
group | string | What kind of region it sits among, for choosing look-alikes: a continent on the world, a larger part of the country on a country's map. |
例
import { findQuestion, seededRandom, type ChizuPlace } from "@johnmorrisdotca/chizu";
// Three places of your own, drawn on a canvas 100 wide: the engine needs no more than these fields.
const square = (code: string, x: number): ChizuPlace => ({
code,
path: `M${x},0L${x + 30},0L${x + 30},30L${x},30Z`,
bbox: [x, 0, x + 30, 30],
centroid: [x + 15, 15],
neighbors: [],
group: "squares",
});
const places = [square("a", 0), square("b", 35), square("c", 70)];
console.log(findQuestion({ width: 100, height: 30, regions: places.map((place) => ({ ...place, name: place.code })) }, "b", seededRandom(1), { count: 2 })?.choices.length);
// 33出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。