Skip to content

Latest commit

 

History

History
12 lines (9 loc) · 861 Bytes

README.md

File metadata and controls

12 lines (9 loc) · 861 Bytes

spiral-hex-grid

A javacript concentric/spiral 2D hexagonal grid using single-coordinate IDs for each hexagon.

Represents a hexagonal grid using a 1D array with hexagon IDs (hexId) starting from a center position of 0 and "spiraling" outwards incremeniting each ID by 1. Technically, the grid is formed using concentric rings of hexagons that surround the previous layer rather than strictly spiraling.

Does not implent graphical rendering. An external graphics/game library can be used to draw the grid based on the coordinates generated by this class using the hexCenters array property. maxHexId and layers may be useful as well to determine the borders/edge of the grid. 2D coordinates increment going right (x) and down (y) for ease of use with many graphics libraries.

to-do

  • Rotation
  • Wrap around
  • Edge and Corner positions and IDs