new HexGrid( [options])
Hexagonal grids
Parameters:
Name | Type | Argument | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Properties
|
Extends
- ol.Object
Members
-
layout
-
Grid layout
Methods
-
coord2hex(coord)
-
Convert coord to hex
Parameters:
Name Type Description coord
ol.Coordinate Returns:
- Type
- ol.hex
-
cube2hex(c)
-
Convert cube to axial coords
Parameters:
Name Type Description c
ol.Coordinate cube coordinate
Returns:
axial coordinate
- Type
- ol.Coordinate
-
cube2offset(c)
-
Convert offset to cube coords
Parameters:
Name Type Description c
ol.Coordinate cube coordinate
Returns:
offset coordinate
- Type
- ol.Coordinate
-
cube_distance(a, a)
-
Calculate distance between to hexagon (number of cube)
Parameters:
Name Type Description a
ol.Coordinate first cube coord
a
ol.Coordinate second cube coord
Returns:
distance
- Type
- number
-
cube_line(a, b)
-
Calculate line between to hexagon
Parameters:
Name Type Description a
ol.Coordinate first cube coord
b
ol.Coordinate second cube coord
Returns:
array of cube coordinates
- Type
- Array.<ol.Coordinate>
-
cube_neighbors(c, direction)
-
Get the neighbors for an hexagon
Parameters:
Name Type Description c
ol.Coordinate cube coord
direction
number Returns:
neighbor || array of neighbors
- Type
- ol.Coordinate | Array.<ol.Coordinate>
-
cube_round(h)
-
Round cube coords
Parameters:
Name Type Description h
ol.Coordinate cube coordinate
Returns:
rounded cube coordinate
- Type
- ol.Coordinate
-
getHexagon(hex)
-
Get hexagon coordinates at hex
Parameters:
Name Type Description hex
ol.Coordinate Returns:
- Type
- Arrary.<ol.Coordinate>
-
getHexagonAtCoord(coord)
-
Get hexagon coordinates at a coordinate
Parameters:
Name Type Description coord
ol.Coordinate Returns:
- Type
- Arrary.<ol.Coordinate>
-
getLayout()
-
Get layout
Returns:
layout name
- Type
- HexagonLayout
-
getOrigin()
-
Get hexagon origin
Returns:
coord origin
- Type
- ol.Coordinate
-
getSize()
-
Get hexagon size
Returns:
hexagon size
- Type
- number
-
hex2coord(hex)
-
Convert hex to coord
Parameters:
Name Type Description hex
ol.hex Returns:
- Type
- ol.Coordinate
-
hex2cube(h)
-
Convert axial to cube coords
Parameters:
Name Type Description h
ol.Coordinate axial coordinate
Returns:
cube coordinate
- Type
- ol.Coordinate
-
hex2offset(h)
-
Convert offset to axial coords
Parameters:
Name Type Description h
ol.Coordinate axial coordinate
Returns:
offset coordinate
- Type
- ol.Coordinate
-
hex_corner()
-
Get hexagon corners
-
hex_neighbors(h, direction)
-
Get the neighbors for an hexagon
Parameters:
Name Type Description h
ol.Coordinate axial coord
direction
number Returns:
neighbor || array of neighbors
- Type
- ol.Coordinate | Array.<ol.Coordinate>
-
hex_round(h)
-
Round axial coords
Parameters:
Name Type Description h
ol.Coordinate axial coordinate
Returns:
rounded axial coordinate
- Type
- ol.Coordinate
-
offset2cube(o)
-
Convert cube to offset coords
Parameters:
Name Type Description o
ol.Coordinate offset coordinate
Returns:
cube coordinate
- Type
- ol.Coordinate
-
offset2hex(o)
-
Convert axial to offset coords
Parameters:
Name Type Description o
ol.Coordinate offset coordinate
Returns:
axial coordinate
- Type
- ol.Coordinate
-
setLayout(layout)
-
Set layout
Parameters:
Name Type Description layout
HexagonLayout | undefined name, default pointy
-
setOrigin(coord)
-
Set hexagon origin
Parameters:
Name Type Description coord
ol.Coordinate origin
-
setSize(hexagon)
-
Set hexagon size
Parameters:
Name Type Description hexagon
number size