0.0.1 • Published 10 years ago

@bockit/hex-coordinates v0.0.1

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
10 years ago

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