Reference · SVG boards and notation
BoardLayoutclass
The layout of a board, a function of its options: where each point, the bar, each tray, the rail and the dice sit, all in landscape units.
Import it
import { BoardLayout } from "@johnmorrisdotca/sugoroku/draw";
Definition
class BoardLayout
new BoardLayout(options: BoardOptions): BoardLayout
Parameters
| Name | Type | Description |
|---|---|---|
options | BoardOptions | Cube rail, viewing side, home direction and board orientation. |
Members
| Name | Type | Description |
|---|---|---|
width | number | |
height | number | |
fieldTop | number | |
options | BoardOptions | |
mx | (x: number, w?: number): number | An x, for something |
fieldLeft | number | The x the field of points starts at, before mirroring. |
fieldHeight | number | |
barLeft | number | |
trayLeft | number | |
slotOf | (point: number): { top: boolean; col: number; } | Which slot of the drawing a point of the board is in: its row (the top row or the bottom) and its column from the left, 0 to 11. The board's points are counted the way white counts: 1 to 12 along the bottom from the right, and 13 to 24 along the top from the left. Seen from black's side the rows change places. |
columnLeft | (col: number): number | The x of the left edge of column |
pointBox | (point: number): Box & { top: boolean; } | The box of a point, as a base on its edge of the field and its length. |
trayBox | (side: Side): Box & { top: boolean; } | The tray of a side: the bottom one is white's when seen from white's side. |
barBox | (side: Side): Box & { top: boolean; } | The half of the bar a side's checkers wait in: the nearer half to the side's own tray. |
cubeBox | (owner: Side | null): Box | Where the cube rests: the middle of the rail, or the end of it nearer its owner. |
diceCentre | (side: Side): { x: number; y: number; } | The middle of the row of dice, on the half of the board a side plays from: its own home half for white, the other for black. |
Examples
import { BoardLayout } from "@johnmorrisdotca/sugoroku/draw";
const layout = new BoardLayout({cube:true,view:"white",home:"right",orientation:"landscape"});
console.log(layout);BoardLayout {
width: 976,
height: 552,
fieldTop: 32,
options: {
cube: true,
view: 'white',
home: 'right',
orientation: 'landscape'
}
}What it prints (run when this page was built)