Reference · Rules, generation and deductions
GRID_SPECSconstant
Neighbour offsets and edge behaviour for each topology. Hex coordinates are axial: each row is displaced half a cell to the right.
Import it
import { GRID_SPECS } from "@johnmorrisdotca/jirai";
Definition
const GRID_SPECS: Record<Grid, { offsets: readonly (readonly [number, number])[]; wrap: boolean; }> = {
square: { offsets: [[-1, -1], [0, -1], [1, -1], [-1, 0], [1, 0], [-1, 1], [0, 1], [1, 1]], wrap: false },
orthogonal: { offsets: [[0, -1], [-1, 0], [1, 0], [0, 1]], wrap: false },
hex: { offsets: [[-1, 0], [1, 0], [0, -1], [1, -1], [-1, 1], [0, 1]], wrap: false },
wrap: { offsets: [[-1, -1], [0, -1], [1, -1], [-1, 0], [1, 0], [-1, 1], [0, 1], [1, 1]], wrap: true },
}
Members
| Name | Type | Description |
|---|---|---|
orthogonal | { offsets: readonly (readonly [number, number])[]; wrap: boolean; } | |
square | { offsets: readonly (readonly [number, number])[]; wrap: boolean; } | |
hex | { offsets: readonly (readonly [number, number])[]; wrap: boolean; } | |
wrap | { offsets: readonly (readonly [number, number])[]; wrap: boolean; } |
Examples
import { GRID_SPECS } from "@johnmorrisdotca/jirai";
console.log(GRID_SPECS);{
square: {
offsets: [
[Array], [Array],
[Array], [Array],
[Array], [Array],
[Array], [Array]
],
wrap: false
},
orthogonal: { offsets: [ [Array], [Array], [Array], [Array] ], wrap: false },
hex: {
offsets: [ [Array], [Array], [Array], [Array], [Array], [Array] ],
wrap: false
},
wrap: {
offsets: [
[Array], [Array],
[Array], [Array],
[Array], [Array],
[Array], [Array]
],
wrap: true
}
}What it prints (run when this page was built)