orderByPosition関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
The choices in the order they run across the map, west to east.
Handles numbered by the option's place in a shuffled list read 3 2 4 1 from left to right, and the number keys
pointed at nothing you could see. Numbering by position makes the handles a row to read and makes 1 mean the
leftmost one.
It gives nothing away. Where a place sits is the entire question being asked, so ordering the choices by it tells
the player only what the map already shows them. Ties break north to south, and anything with no centre keeps its
order at the end rather than disappearing. centreOf says where an option is: (option) => region.centroid.
インポート
import { orderByPosition } from "@johnmorrisdotca/chizu";
定義
function orderByPosition<T>(options: readonly T[], centreOf: (option: T) => readonly [number, number] | null | undefined): T[]
引数
| 名前 | 型 | 説明 |
|---|---|---|
options | readonly T[] | The optional native drawing, matching, layout or quiz settings described by this signature. |
centreOf | (option: T) => readonly [number, number] | null | undefined | The function that reads an entry’s native centre. |
戻り値
T[]
The choices in the order they run across the map, west to east.
例
import { orderByPosition } from "@johnmorrisdotca/chizu";
const places = [{ name: "east", at: [90, 10] as const }, { name: "west", at: [10, 10] as const }, { name: "middle", at: [50, 10] as const }];
console.log(orderByPosition(places, (place) => place.at).map((place) => place.name).join(" "));
// west middle eastwest middle east出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。