@bockit/hex-coordinates
v0.0.1
Published
Hexagon grid coordinates
Downloads
4
Maintainers
Readme
Hex Round
Convert pixel coordinates to hex coordinates and vice versa. Supports flat and pointy topped hexagons.
Logic courtesy of redblobgames hex grid reference
Usage
import { pixelToHexPointy, pixelToHexFlat } from '@bockit/hex-coordinates'
import { hexToPixelPointy, hexToPixelFlat } from '@bockit/hex-coordinates'
pixelToHexPointy(100, 100, 20) // [ q, r ]
pixelToHexFlat(100, 100, 20) // [ q, r ]
hexToPixelPointy(1, 1, 20) // [ x, y ]
hexToPixelFlat(1, 1, 20) // [ x, y ]
Todo
- Tests