Skip to main content

Tool to stitch Foxhole hex maps and generate map tiles.

Project description

Foxhole Hexes

Tool to help stitch and tile the Foxhole game map. Assemble all the individual hex maps into one master map, and then cut the map up into tiles that can be rendered on a map like Leaflet

Install

From PyPI:

pip install foxhole-hexes

From source:

pip install -e .

How to run

hex2tile

Usage: hex2tile [OPTIONS]

Options:
  --hexes FILE         Path to config JSON with format: {<hex_id>: { 'name':
                       <hex_name>, 'file': <hex_png>, 'q': <q>, 'p': <p> } } q
                       and r are axial hexagon coordinates (legacy key 'p' is
                       still accepted)  [required]
  --out DIRECTORY      Output directory for tiles (creates z/x/y.png).
  --max-zoom INTEGER   Max zoom level (master resolution uses ppu =
                       2^maxZoom).  [default: 5]
  --min-zoom INTEGER   Min zoom level  [default: 0]
  --tile-size INTEGER  Tile size in pixels (typically 256).  [default: 256]
  --hex-size INTEGER   Width of the hex map (corner to corner) in pixels.
                       [default: 1024]
  --write-master FILE  Optional path to write the assembled master PNG for
                       debugging.
  -v, --verbose        More logging.
  --help               Show this message and exit.

Example:

hex2tile --hexes hexes.json --out tiles --max-zoom 5 --min-zoom 2 --write-master master.png

Module form:

python -m foxhole_hexes.hex2tile --hexes hexes.json --out tiles --max-zoom 5 --min-zoom 2 --write-master master.png

tga2png

Usage: tga2png [OPTIONS]

  Convert TGA icons to PNG using Pillow.

Options:
  --from DIRECTORY              Source directory containing .tga files.
                                [required]
  --to DIRECTORY                Destination directory for .png files (created
                                if missing).  [required]
  --recursive / --no-recursive  Search for .tga files recursively under the
                                source directory.  [default: no-recursive]
  --overwrite / --no-overwrite  Overwrite existing .png files in the
                                destination directory.  [default: no-
                                overwrite]
  -h, --help                    Show this message and exit.

Example

tga2png --from ../warapi/Images/Maps --to png/

Module form:

python -m foxhole_hexes.tga2png --from ../warapi/Images/Maps --to png/

Hexes

The map layout is configured in a json file.

{
    "TempestIslandHex": { 
        "name": "Tempest Island", "file": "pngs/MapTempestIslandHex.png", "q": -2, "p": 4 
    },
    "GreatMarchHex": { 
        "name": "Great March", "file": "pngs/MapGreatMarchHex.png", "q": 2, "p": 0 
    },
    "DeadLandsHex": { 
        "name": "DeadLandsHex", "file": "pngs/MapDeadLandsHex.png", "q": 0, "p": 0 
    },
    ...

The position of each hex is defined by the q,p coordinates. This axial coordinate system is based on this diagram.

Learn more about hexagon math here:

I may have gotten some of the theory and conventions wrong in the code, but the results seem to work.

Project details


Download files

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

Source Distribution

foxhole_hexes-1.0.2.tar.gz (712.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

foxhole_hexes-1.0.2-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file foxhole_hexes-1.0.2.tar.gz.

File metadata

  • Download URL: foxhole_hexes-1.0.2.tar.gz
  • Upload date:
  • Size: 712.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for foxhole_hexes-1.0.2.tar.gz
Algorithm Hash digest
SHA256 ee3e9e11c59a4dceb65a711859d6b23fa477986393f0e3e4c8a1cbc5bb913d8d
MD5 5d2f88b19e335ad0b5bf38b18a7cfc47
BLAKE2b-256 099c35642146bbe6a91978a75ccb0b1722edfbb77376e3f28379729e4c271d2a

See more details on using hashes here.

Provenance

The following attestation bundles were made for foxhole_hexes-1.0.2.tar.gz:

Publisher: publish.yml on notbadjon/foxhole-hexes

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file foxhole_hexes-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: foxhole_hexes-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for foxhole_hexes-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 aee57f92eb80a36c55fa291c37713a1f13edf9eb0fd12aadd80287a705c6c578
MD5 417e656c7da6eb6c26db1f9bfdeeb137
BLAKE2b-256 41b8d83e760e92f29096f28f2c77893fd5ee10ad0fa67b06a807e7f2acb5545a

See more details on using hashes here.

Provenance

The following attestation bundles were made for foxhole_hexes-1.0.2-py3-none-any.whl:

Publisher: publish.yml on notbadjon/foxhole-hexes

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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