https://github.com/gojuno/hexgrid-py
Configurable hex grid on abstract surface
https://github.com/gojuno/hexgrid-py
Last synced: 8 months ago
JSON representation
Configurable hex grid on abstract surface
- Host: GitHub
- URL: https://github.com/gojuno/hexgrid-py
- Owner: gojuno
- License: bsd-3-clause
- Created: 2016-10-20T22:26:34.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2019-02-19T14:07:48.000Z (over 7 years ago)
- Last Synced: 2025-06-23T15:54:11.716Z (about 1 year ago)
- Language: Python
- Size: 8.79 KB
- Stars: 13
- Watchers: 6
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
HexGrid
=======
Basics
------
Configurable hex grid on abstract surface.
Example
-------
.. code-block:: python
import hexgrid
import morton
center = hexgrid.Point(0, 0)
size = hexgrid.Point(20, 10)
grid = hexgrid.Grid(hexgrid.OrientationFlat, center, size, morton.Morton(2, 32))
hex = grid.hex_at(hexgrid.Point(50, 50))
code = grid.hex_to_code(hex)
restored_hex = grid.hex_from_code(code)
neighbors = grid.hex_neighbors(hex, 2)
points = [
hexgrid.Point(0, 0), hexgrid.Point(0, 10),
hexgrid.Point(10, 10), hexgrid.Point(10, 0)
]
region = grid.make_region(points)
hexes_in_region = region.hexes
Setup
-------
pip install hexgrid-py