4 releases
0.1.3 | Aug 21, 2022 |
---|---|
0.1.2 | Aug 14, 2022 |
0.1.1 | Aug 14, 2022 |
0.1.0 | Aug 13, 2022 |
#23 in #cube
55KB
1K
SLoC
hex-coordinates
A library for handling hex coordinates.
Massive credit to Hexagonal Grids from Red Blob Games.
Offset | Doubled | Axial | Cube | |
---|---|---|---|---|
Pointy Rotation | evenr, oddr | doublewidth | axial | cube |
Flat Rotation | evenq, oddq | doubleheight | ||
Other Rotations | no | yes | ||
Vector operations (add, subtract, scale) | no | yes | yes | yes |
Array storage | rectangular | no* | rhombus* | no* |
Hash storage | any shape | any shape | ||
Hexagonal symmetry | no | no | no | yes |
Easy algorithms | few | some | most | most |
The article notes:
My recommendation: if you are only going to use non-rotated rectangular maps, consider the doubled or offset system that matches your map orientation. For maps with Rotation, or non-rectangularly shaped maps, use axial/cube. Either choose to store the s coordinate (cube), or calculate it when needed as -q-r (axial).