Class: Grid<T>
Type parameters
Name | Type |
---|---|
T | extends Hex |
Implements
Table of contents
Constructors
Accessors
Methods
- [iterator]
- createHex
- distance
- filter
- forEach
- fromIterable
- fromJSON
- getHex
- hasHex
- map
- neighborOf
- pointToHex
- reduce
- setHexes
- toArray
- toJSON
- toString
- traverse
Constructors
constructor
new Grid<T
>(hexClass
)
Type parameters
Name | Type |
---|---|
T | extends Hex |
Parameters
Name | Type |
---|---|
hexClass | HexConstructor <T > |
Defined in
new Grid<T
>(hexClass
, traversers
)
Type parameters
Name | Type |
---|---|
T | extends Hex |
Parameters
Name | Type |
---|---|
hexClass | HexConstructor <T > |
traversers | Traverser <T > | Traverser <T >[] |
Defined in
new Grid<T
>(hexClass
, hexes
)
Type parameters
Name | Type |
---|---|
T | extends Hex |
Parameters
Name | Type |
---|---|
hexClass | HexConstructor <T > |
hexes | Iterable <HexCoordinates | T > |
Defined in
new Grid<T
>(grid
)
Type parameters
Name | Type |
---|---|
T | extends Hex |
Parameters
Name | Type |
---|---|
grid | Grid <T > |
Defined in
Accessors
hexPrototype
get
hexPrototype(): T
Returns
T
Defined in
pixelHeight
get
pixelHeight(): number
Returns
number
Defined in
pixelWidth
get
pixelWidth(): number
Returns
number
Defined in
size
get
size(): number
Returns
number
Implementation of
Defined in
Methods
[iterator]
[iterator](): IterableIterator
<T
>
Returns
IterableIterator
<T
>
Implementation of
Defined in
createHex
createHex(coordinates?
): T
Parameters
Name | Type |
---|---|
coordinates? | HexCoordinates |
Returns
T
Implementation of
Defined in
distance
distance(from
, to
, options?
): number
Parameters
Name | Type |
---|---|
from | HexCoordinates |
to | HexCoordinates |
options? | Object |
options.allowOutside | true |
Returns
number
Defined in
distance(from
, to
, options
): undefined
| number
Parameters
Name | Type |
---|---|
from | HexCoordinates |
to | HexCoordinates |
options | Object |
options.allowOutside | false |
Returns
undefined
| number
Defined in
filter
filter(predicate
): Grid
<T
>
Parameters
Name | Type |
---|---|
predicate | (hex : T ) => boolean |
Returns
Grid
<T
>
Implementation of
Defined in
forEach
forEach(fn
): Grid
<T
>
Parameters
Name | Type |
---|---|
fn | (hex : T ) => void |
Returns
Grid
<T
>
Implementation of
Defined in
fromIterable
Static
fromIterable<T
>(hexes
): Grid
<T
>
Type parameters
Name | Type |
---|---|
T | extends Hex |
Parameters
Name | Type |
---|---|
hexes | Iterable <T > |
Returns
Grid
<T
>
Defined in
fromJSON
Static
fromJSON<T
, R
>(«destructured»
, hexFactory?
): Grid
<R
>
Type parameters
Name | Type |
---|---|
T | extends AxialCoordinates |
R | extends Hex |
Parameters
Name | Type |
---|---|
«destructured» | GridAsJSON <T > |
hexFactory? | (coordinates : T , index : number , allCoordinates : T []) => R |
Returns
Grid
<R
>
Defined in
getHex
getHex(coordinates
): undefined
| T
Parameters
Name | Type |
---|---|
coordinates | HexCoordinates |
Returns
undefined
| T
Implementation of
Defined in
hasHex
hasHex(hex
): boolean
Parameters
Name | Type |
---|---|
hex | T |
Returns
boolean
Implementation of
Defined in
map
map(fn
): Grid
<T
>
Parameters
Name | Type |
---|---|
fn | (hex : T ) => T |
Returns
Grid
<T
>
Implementation of
Defined in
neighborOf
neighborOf(coordinates
, direction
, options?
): T
Parameters
Name | Type |
---|---|
coordinates | HexCoordinates |
direction | Direction |
options? | Object |
options.allowOutside | true |
Returns
T
Defined in
neighborOf(coordinates
, direction
, options
): undefined
| T
Parameters
Name | Type |
---|---|
coordinates | HexCoordinates |
direction | Direction |
options | Object |
options.allowOutside | false |
Returns
undefined
| T
Defined in
pointToHex
pointToHex(point
, options?
): T
Parameters
Name | Type |
---|---|
point | Point |
options? | Object |
options.allowOutside | true |
Returns
T
Defined in
pointToHex(point
, options
): undefined
| T
Parameters
Name | Type |
---|---|
point | Point |
options | Object |
options.allowOutside | false |
Returns
undefined
| T
Defined in
reduce
reduce(reducer
): T
Parameters
Name | Type |
---|---|
reducer | (previousHex : T , currentHex : T ) => T |
Returns
T
Implementation of
Defined in
reduce(reducer
, initialValue
): T
Parameters
Name | Type |
---|---|
reducer | (previousHex : T , currentHex : T ) => T |
initialValue | T |
Returns
T
Implementation of
Defined in
reduce<R
>(reducer
, initialValue
): R
Type parameters
Name |
---|
R |
Parameters
Name | Type |
---|---|
reducer | (result : R , hex : T ) => R |
initialValue | R |
Returns
R
Implementation of
Defined in
setHexes
setHexes(hexesOrCoordinates
): Grid
<T
>
Parameters
Name | Type |
---|---|
hexesOrCoordinates | Iterable <HexCoordinates | T > |
Returns
Grid
<T
>
Implementation of
Defined in
toArray
toArray(): T
[]
Returns
T
[]
Implementation of
Defined in
toJSON
toJSON(): GridAsJSON
<T
>
Returns
GridAsJSON
<T
>
Defined in
toString
toString(): string
Returns
string
Defined in
traverse
traverse(traversers
, options?
): Grid
<T
>
Parameters
Name | Type |
---|---|
traversers | Traverser <T > | Traverser <T >[] |
options? | Object |
options.bail? | boolean |
Returns
Grid
<T
>
Implementation of
Defined in
traverse(hexes
, options?
): Grid
<T
>
Parameters
Name | Type |
---|---|
hexes | Iterable <HexCoordinates | T > |
options? | Object |
options.bail? | boolean |
Returns
Grid
<T
>
Implementation of
Defined in
traverse(grid
, options?
): Grid
<T
>
Parameters
Name | Type |
---|---|
grid | Grid <T > |
options? | Object |
options.bail? | boolean |
Returns
Grid
<T
>