TsunagiGeometry型
リファレンスの説明と例は英語です。見出しと目次は日本語です。
The board dimensions, cell centres and playable-cell mapping used by SVG and pointer input.
インポート
import type { TsunagiGeometry } from "@johnmorrisdotca/tsunagi/draw";
定義
type TsunagiGeometry = {
size: number;
hex: boolean;
ring: number;
coordinates: boolean;
side: number;
paper: {
x: number;
y: number;
width: number;
height: number;
};
centre: (cell: number) => TsunagiPoint;
onBoard: (cell: number) => boolean;
};
メンバー
| 名前 | 型 | 説明 |
|---|---|---|
size | number | |
hex | boolean | |
ring | number | One ghost cell all round, on a board that wraps. |
coordinates | boolean | Whether the drawing has the board's coordinates down its sides. |
side | number | The drawing's width and height, the same, in its units. |
paper | { x: number; y: number; width: number; height: number; } | Where the playing surface starts and how far it goes, inside the frame and the coordinates. |
centre | (cell: number) => TsunagiPoint | The middle of a cell, in the drawing; for a hexagon, only of the cells on the board. |
onBoard | (cell: number) => boolean | Whether a cell is on the board: every one of a square, only the hexagon's own of a honeycomb. |
例
import { TSUNAGI_4 } from "@johnmorrisdotca/tsunagi/levels-4";
import { decodeLayout } from "@johnmorrisdotca/tsunagi";
import { tsunagiGeometry } from "@johnmorrisdotca/tsunagi/draw";
import type { TsunagiGeometry } from "@johnmorrisdotca/tsunagi/draw";
const givens = TSUNAGI_4[0][0];
const layout = decodeLayout(givens,4)!;
const geometry = tsunagiGeometry(layout);
const value: TsunagiGeometry = geometry;
console.log(value);{
size: 4,
hex: false,
ring: 0,
coordinates: false,
side: 428,
paper: { x: 14, y: 14, width: 400, height: 400 },
centre: [Function: centre],
onBoard: [Function: onBoard]
}出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。