Skip to main content

A zero dependency, lightweight and fast library to manipulate RPG images written in Rust.

Project description

rpg_map

PyPI version Documentation Status

A fast, zero-dependency Python library for visualizing exploration and movement across large pixel-based maps. Built in Rust for speed and efficiency, rpg_map is perfect for turn-based or real-time RPGs, strategy games, and D&D-style map reveals.

Key Features

  • Hides unexplored areas of the map

  • Reveals areas as they’re explored or passed through

  • Draws travel paths using A* pathfinding

  • Fast and lightweight with zero Python dependencies

  • Operates directly on pixel data

  • Customizable visual styles and highlight zones

  • Includes examples using static image processing and Pygame

Install

Install via pip:

pip install rpg-map

Documentation

Full documentation and examples available at: https://rpg-map.readthedocs.io/

How It Works

The library uses step-by-step image processing to reveal and annotate the map. Here’s an overview of the process:

Code:

This is the code which was used to generate the final result of the example steps below:

from rpg_map import Travel, Map, MapType, PathStyle, PathProgressDisplayType, PathDisplayType
from PIL import Image

LOCAL_DIR = "../test_assets/map.png"
BACKGROUND_DIR = "../test_assets/background.png"
GRID_SIZE = 20
START, END = (198, 390), (172, 223)
START_X, START_Y = START

image = Image.open(LOCAL_DIR).convert("RGBA")
# get image bytes
image_bytes = list(image.tobytes())
background = Image.open(BACKGROUND_DIR).convert("RGBA")
# get background bytes
background_bytes = list(background.tobytes())
map = Map(
   image_bytes,
   image.size[0],
   image.size[1],
   GRID_SIZE,
   MapType.Limited,
   obstacles=[[(160, 240), (134, 253), (234, 257), (208, 239)]],
)

travel = Travel(map, START, END)
path_bits =  Map.draw_background(
   map.with_dot(START_X, START_Y, (255, 0, 0, 255), 4).draw_path(
      travel,
      1.0,
      2,
      PathStyle.DottedWithOutline((255, 0, 0, 255), (255, 255, 255, 255)),
   ),
   background_bytes
)

# Display the image
image = Image.frombytes("RGBA", (image.width, image.height), path_bits)
image.show()

Steps:

  1. Draw Obstacles

    The Map class accepts an obstacles parameter which allows you to define N-sided polygons. These are rendered onto the map as solid barriers.

    https://github.com/Kile/rpg_map/blob/master/assets/1.png?raw=true
  2. Add Padding and Convert to Pathfinding Grid

    Obstacles and map edges are padded and the image is converted into a binary map (0 = path, 1 = obstacle) for pathfinding.

    https://github.com/Kile/rpg_map/blob/master/assets/2.png?raw=true
  3. Pathfinding with A*

    The library uses the A* algorithm to find the shortest path from point A to point B. The path is drawn on the map using a customizable style.

    https://github.com/Kile/rpg_map/blob/master/assets/3.png?raw=true
  4. Draw Dots

    Optional dots can be placed on the map (e.g., for points of interest, the player, markers).

    https://github.com/Kile/rpg_map/blob/master/assets/4.png?raw=true
  5. Divide into Grid Squares

    The image is divided into equal squares based on the grid_size parameter.

    https://github.com/Kile/rpg_map/blob/master/assets/5.png?raw=true
  6. Reveal Explored Areas

    A mask overlays the map. Areas near the travel path or manually unlocked via Map.unlock_point are revealed in circular zones.

    https://github.com/Kile/rpg_map/blob/master/assets/6.png?raw=true
  7. Fill Transparent Areas

    Any remaining transparent pixels are filled with a background layer.

    https://github.com/Kile/rpg_map/blob/master/assets/7.png?raw=true
  8. Final Map Output

    The completed map shows explored areas, paths, markers, and hidden regions yet to be discovered.

    https://github.com/Kile/rpg_map/blob/master/assets/8.png?raw=true

Advanced Features

  • You can define special grid points where the reveal radius is larger — perfect for cities or key landmarks.

  • The library supports tons of styles for different themes and usecases.

    https://github.com/Kile/rpg_map/blob/master/assets/9.png?raw=true https://github.com/Kile/rpg_map/blob/master/assets/10.png?raw=true https://github.com/Kile/rpg_map/blob/master/assets/11.png?raw=true https://github.com/Kile/rpg_map/blob/master/assets/12.png?raw=true

Examples

Check out these demos:

Contributing & Development

We welcome contributions and ideas! If you’d like to work on rpg_map locally, here’s how to get started.

Set Up the Development Environment

  1. Compile the Rust Extension Locally

    Use maturin to build and install the Rust extension module in your local Python environment:

    maturin develop --features "extension-module"
  2. Generate Python Typings ( .pyi )

    The library includes a binary that auto-generates Python type stubs. Run it with:

    cargo run --bin stub_gen --features stubgen
  3. Build the Documentation

    The documentation uses Sphinx and can be built locally as follows:

    python3 -venv env && source env/bin/activate
    cd docs
    pip3 install -r requirements.txt
    sphinx-apidoc -o source/ ../ -f
    make html

    The output will be available in the docs/build/html/ directory.

Additional Notes

  • The Rust project uses pyo3 to create Python bindings — see Cargo.toml for feature flags and build options.

  • Type hints are manually generated via the stub_gen tool, ensuring compatibility with type checkers and IDEs. Interestingly sphinx uses the docs defined in the Rust code though, the pyi file is only for IDE type hinting when using the library.

License

MIT

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

rpg_map-0.0.3.tar.gz (23.5 MB view details)

Uploaded Source

Built Distributions

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

rpg_map-0.0.3-cp39-abi3-win_amd64.whl (197.9 kB view details)

Uploaded CPython 3.9+Windows x86-64

rpg_map-0.0.3-cp39-abi3-win32.whl (186.3 kB view details)

Uploaded CPython 3.9+Windows x86

rpg_map-0.0.3-cp39-abi3-musllinux_1_2_x86_64.whl (518.1 kB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ x86-64

rpg_map-0.0.3-cp39-abi3-musllinux_1_2_i686.whl (545.3 kB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ i686

rpg_map-0.0.3-cp39-abi3-musllinux_1_2_armv7l.whl (612.3 kB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARMv7l

rpg_map-0.0.3-cp39-abi3-musllinux_1_2_aarch64.whl (524.8 kB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARM64

rpg_map-0.0.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (347.3 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

rpg_map-0.0.3-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (389.2 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ s390x

rpg_map-0.0.3-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (412.6 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ppc64le

rpg_map-0.0.3-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (350.5 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARMv7l

rpg_map-0.0.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (346.0 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

rpg_map-0.0.3-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl (369.6 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.5+ i686

rpg_map-0.0.3-cp39-abi3-macosx_11_0_arm64.whl (310.3 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

rpg_map-0.0.3-cp39-abi3-macosx_10_12_x86_64.whl (324.8 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file rpg_map-0.0.3.tar.gz.

File metadata

  • Download URL: rpg_map-0.0.3.tar.gz
  • Upload date:
  • Size: 23.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.8.3

File hashes

Hashes for rpg_map-0.0.3.tar.gz
Algorithm Hash digest
SHA256 14963085ad000cab1ee54d393aab973f0470cdf0ba4a2d0f38e8f02920b0a680
MD5 0d7c4fa8646111d1d181da2f19426981
BLAKE2b-256 2c1a8a16be5e03d362c75603d5bbd9eb8d32dad3983c276c7ebef703350619e6

See more details on using hashes here.

File details

Details for the file rpg_map-0.0.3-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: rpg_map-0.0.3-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 197.9 kB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.8.3

File hashes

Hashes for rpg_map-0.0.3-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 63de9292b97e57efbff45fcc1cff1effbe21f0aa864ccd1fec8c9916f5bf4e25
MD5 2153048cf475074cfa5f76ef125a5769
BLAKE2b-256 802e1766a7a8af31b43380bbe020633074aa889f35de574d0b564c89a046d48c

See more details on using hashes here.

File details

Details for the file rpg_map-0.0.3-cp39-abi3-win32.whl.

File metadata

  • Download URL: rpg_map-0.0.3-cp39-abi3-win32.whl
  • Upload date:
  • Size: 186.3 kB
  • Tags: CPython 3.9+, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.8.3

File hashes

Hashes for rpg_map-0.0.3-cp39-abi3-win32.whl
Algorithm Hash digest
SHA256 26ab7dbe06c1af1786789d13428d807c8b9a61e41e9b27c65e786351e99b2ac7
MD5 ae070c5190343cc7c5490ead035a9ab6
BLAKE2b-256 6ca3dfeefe33133e4d3cef3cff256dce68e674cb0268ea23612e8e4e5d4473e4

See more details on using hashes here.

File details

Details for the file rpg_map-0.0.3-cp39-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for rpg_map-0.0.3-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b9963cf81be59957e6f874e85dd99319c6bc63e25271c15256d0f804a1dfe1e3
MD5 27c7b350138e1de12590b59c6995a367
BLAKE2b-256 96841d9edd577f91fa972befeac0b41b660c11794c42c81b196d055f618e68f0

See more details on using hashes here.

File details

Details for the file rpg_map-0.0.3-cp39-abi3-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for rpg_map-0.0.3-cp39-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 4fb892f3b29e281592b1805c2ef067cd271a3e97a7fdd01050554ef85d832001
MD5 d6b99ffb15363504c786044ebc21114a
BLAKE2b-256 3dc1d27eddb343cbe6f924f7209c968d274ebec6893a70ec6f08f388b8ee2b9a

See more details on using hashes here.

File details

Details for the file rpg_map-0.0.3-cp39-abi3-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for rpg_map-0.0.3-cp39-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 a1923947ddd77b2ad451523fa9b2ed873a6dcfddf3c4065ab60cfbb72308c063
MD5 c55b0725d354fc20eb480c297a244715
BLAKE2b-256 b28be490739595d91b074b01b80f9a35b8469e4f993ca51e399d1a2c49fba01a

See more details on using hashes here.

File details

Details for the file rpg_map-0.0.3-cp39-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for rpg_map-0.0.3-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 ffe74306ae5c4ceb9ba563141fcc6c9ff63b4e7c0de3cff1fcf1b1bb11b03d56
MD5 99fe42391dc0f6e594fc1a77f524083a
BLAKE2b-256 5f3f6e66edceeaca256a447ab8707b9fbd29d728d36e42c0c03904630546e43b

See more details on using hashes here.

File details

Details for the file rpg_map-0.0.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rpg_map-0.0.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1a1a0508dce8652ebaca467983e5366734d86134f74e44c0a2c17e94bfa38106
MD5 2a19b26455d58dbfbf6b4bf870695351
BLAKE2b-256 3017c5f588baf23b5347911891224514e3bec6b47424288da056605c16e81493

See more details on using hashes here.

File details

Details for the file rpg_map-0.0.3-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for rpg_map-0.0.3-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 760d9a8266861564cede2229247f90ed53e985ed916005f89d2c3a6450fca463
MD5 727cd4b2d7bd47ce50b2c13f05b3e56c
BLAKE2b-256 fb20942836f8a633fb9cc2eee0eaf0a4f5bb420b11d60d64322333369bd51054

See more details on using hashes here.

File details

Details for the file rpg_map-0.0.3-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for rpg_map-0.0.3-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 6d7156320a24c84dd452cf432e183108dd4cdee0585709fc19f981d9f72cfcaa
MD5 c5b52e1c784a2d352f1ce653d123268b
BLAKE2b-256 c629408c34f366c4cc38e13e7e3ac7a1435603caa33673c1631b7f5098e7c51b

See more details on using hashes here.

File details

Details for the file rpg_map-0.0.3-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for rpg_map-0.0.3-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 14b866230f8430c1dc6e5e07c8d8c1efbca9224a9e77b1d115f76b77c1740098
MD5 e7da1c30db3ddd7d37387c735da7a8ec
BLAKE2b-256 919e536328e80577a17e53d8d1cf515b41b0fb5bdf350b2a4abbdb7887f6bfc7

See more details on using hashes here.

File details

Details for the file rpg_map-0.0.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for rpg_map-0.0.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c581678887b09f17d7e79da9348e9b7f85698ddb24f06775867abd49d085de9d
MD5 11cc8ba66e20cc78edeb6b490a746af3
BLAKE2b-256 75a5e6e8309dd423f02c38ae086f13aecb1dec00d1301582d544b1c3c8b14108

See more details on using hashes here.

File details

Details for the file rpg_map-0.0.3-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for rpg_map-0.0.3-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 1ff969623381bbf99aa8e934e4858c89d5be5baf73ed5641e0c3ae0e405da816
MD5 0ba0f60b82d5a3001feefcdd792b08c6
BLAKE2b-256 d5a7f92ba686f6797df7185898db184b2fec38e7d9aef590453af76050889921

See more details on using hashes here.

File details

Details for the file rpg_map-0.0.3-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rpg_map-0.0.3-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8c9c4ab96500ddbb5c80cf8319b47c839225d98b4ad015353353ae712bb77236
MD5 22c7c58851169a7f0138a4e02fac6f2d
BLAKE2b-256 a12be2ff85fe738288525d92d38a0680ec016fe7184a964d8935d56d50cf7efa

See more details on using hashes here.

File details

Details for the file rpg_map-0.0.3-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for rpg_map-0.0.3-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7c2508bf71fd0c2a7099f5a81df092c90f99a58a51b52516a06ad2b8b617f1d5
MD5 e1e1946570f3367574fc836595ecf2f6
BLAKE2b-256 df5f3db066d7f900014be7d5cba5eed4136ffae3d3bc251880c541cf0be21580

See more details on using hashes here.

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