Skip to main content

HexGrid

Project description

Basics

Configurable hex grid on abstract surface.

Example

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

hexgrid-py-1.1.tar.gz (5.8 kB view hashes)

Uploaded Source

hexgrid-py-1.0.tar.gz (5.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page