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.0.tar.gz (9.4 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.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: foxhole_hexes-1.0.0.tar.gz
  • Upload date:
  • Size: 9.4 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.0.tar.gz
Algorithm Hash digest
SHA256 c33131dcb1d93d7dfa9199b8145efb10a4e06537e8e5eef8970dad11ca2c8dbb
MD5 02fdbce76015434067718d4d68dbc953
BLAKE2b-256 ab69e095154f53ac33353548f781ddc64109815d431d2cecda1888f07cbadd80

See more details on using hashes here.

Provenance

The following attestation bundles were made for foxhole_hexes-1.0.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: foxhole_hexes-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.0 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fd27836760115f5fd28318daca4c5e6a9dc850cde6c0cb08a2ecb10ac14caf57
MD5 0356831858a1dc4c8ea8e0372bf7a560
BLAKE2b-256 d0bebe7305c64b2bc3dae36a3c8ce47e335ee6b17f53cf593eb6460538ceea62

See more details on using hashes here.

Provenance

The following attestation bundles were made for foxhole_hexes-1.0.0-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