Skip to content

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

Notifications You must be signed in to change notification settings

thecyborgcoder/spiral-hex-grid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 

Repository files navigation

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

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published