Skip to content

Latest commit

 

History

History
16 lines (15 loc) · 520 Bytes

README.org

File metadata and controls

16 lines (15 loc) · 520 Bytes

HexGrid

Basics

Configurable hex grid on abstract surface.

Examples

import Morton
import HexGrid

let center = Point(x: 0.0, y: 0.0)
let size = Point(x: 20.0, y: 10.0)
let grid = Grid(orientation: OrientationFlat, origin: center, size: size, mort: try! Morton64(dimensions: 2, bits: 32))
let hex: Hex = grid.hexAt(Point(x: 50.0, y: 50.0))
let code: Int64 = try! grid.hexToCode(hex)
let restoredHex: Hex = grid.hexFromCode(code)
let neighbors: [Hex] = grid.hexNeighbors(hex, layers: 2)