@bockit/hex-coordinates

0.0.1 • Public • Published

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

/@bockit/hex-coordinates/

    Package Sidebar

    Install

    npm i @bockit/hex-coordinates

    Weekly Downloads

    2

    Version

    0.0.1

    License

    BSD-3-Clause

    Last publish

    Collaborators

    • bockit