TsunagiGeometrytype
The board dimensions, cell centres and playable-cell mapping used by SVG and pointer input.
Import it
import type { TsunagiGeometry } from "@johnmorrisdotca/tsunagi/draw";
Definition
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;
};
Members
| Name | Type | Description |
|---|---|---|
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. |
Examples
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]
}What it prints (run when this page was built)