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.1.0.tar.gz (22.9 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.1.0-cp39-abi3-win_amd64.whl (198.3 kB view details)

Uploaded CPython 3.9+Windows x86-64

rpg_map-0.1.0-cp39-abi3-win32.whl (186.5 kB view details)

Uploaded CPython 3.9+Windows x86

rpg_map-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl (515.7 kB view details)

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

rpg_map-0.1.0-cp39-abi3-musllinux_1_2_i686.whl (543.1 kB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ i686

rpg_map-0.1.0-cp39-abi3-musllinux_1_2_armv7l.whl (607.7 kB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARMv7l

rpg_map-0.1.0-cp39-abi3-musllinux_1_2_aarch64.whl (518.9 kB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARM64

rpg_map-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (344.9 kB view details)

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

rpg_map-0.1.0-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (372.1 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ s390x

rpg_map-0.1.0-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (478.7 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ppc64le

rpg_map-0.1.0-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (346.6 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARMv7l

rpg_map-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (340.2 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

rpg_map-0.1.0-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl (367.5 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.5+ i686

rpg_map-0.1.0-cp39-abi3-macosx_11_0_arm64.whl (311.4 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

rpg_map-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl (323.4 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for rpg_map-0.1.0.tar.gz
Algorithm Hash digest
SHA256 df48bf155e0f0d21a1d5fdcd1780611c49cb10c51a5e1d5eae60491bc45d945c
MD5 4ddf70e9f182c0f21d862a5cf77576c1
BLAKE2b-256 1854480ff1b27994c8a9c9054274a2c79e7ed8a3ad67a41b0d1387810885fcbc

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for rpg_map-0.1.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 cc8cd72528e9a1bfa6664a91e937180f14d7c92649d084c943185607a5093fbc
MD5 c7c3847060d0bc9b3a57205e18c977bc
BLAKE2b-256 ec0eba2c84f33db985bff0eb33e5b05cd97421dd8394b4995be5df6841333a09

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for rpg_map-0.1.0-cp39-abi3-win32.whl
Algorithm Hash digest
SHA256 a5d0ef2aac00506898b9e43970f3be8ca3562b780588535af245d0c632a84449
MD5 6c49fa41bbb9035b62d9400ae44c0072
BLAKE2b-256 2d64b8d64f48cc62f0be80371ab1dadb9e1e71c4bd3a16e0e38b0d899d16b837

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rpg_map-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 029e2f84376b693bed963d7eaff277654eeec6d219b286958d53854b4fd9ca47
MD5 96e8d15dbdbd13db206c82e670393bd9
BLAKE2b-256 21d6631e3fafc92fc5d769e407b32300390b9971120a74629c3737674be89a4f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rpg_map-0.1.0-cp39-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 09e68c5736c9e72d185186a813640b07912aea626d16a37885ae364e4de20470
MD5 0b65e77083d11bce305d741aa77dbcad
BLAKE2b-256 e5c9714fe346b775d55284f400ea21659b64833cf49d15ebb8938d6641d9ff06

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rpg_map-0.1.0-cp39-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 829c0b962cbcb65a69eb0f58f7daf2bf20968d42b498a7d2510e388cee103f55
MD5 407587387ef027b746ed504da300ed9a
BLAKE2b-256 1ea76ec133e671d0956054d4f1da878621d42dcd30117cc6e686ef7cd7498f7c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rpg_map-0.1.0-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 e12604d717b298ae292c5711eee67f36a46068852cf1ab258a5868c94dc5d809
MD5 7f7990b0eb09db65d57e69b6cfd01deb
BLAKE2b-256 d9f8f025ea2ceba3a50aad9241c63efe5f58d112374995018b0984b819cdbfd2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rpg_map-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0bfb3bdeb7410db793fee4b4714b00f09207be1c8a41fa8d70941a72dfda140e
MD5 d0ce6be517b62ba3b608be74cfa2003a
BLAKE2b-256 b5e172d6991da2328c6a3528dd5b4de124a605d3483b79fcdf0069619204ac62

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rpg_map-0.1.0-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 ded51b4473000739ed71501d8dd88e617ddb4d81c3126926e6e87b4763907993
MD5 128c6250202c37db881c84a981438b81
BLAKE2b-256 5b72a698a3312e17dfbd1006c4d683130dff34024477e0f8b0c09b7828b19056

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rpg_map-0.1.0-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 52367bb6e8e8a1e12db6cf6239e55edfb92db07042410aa3cf237aa44767bcc7
MD5 3ac2ff403953ae479c0d0ca306ab05c4
BLAKE2b-256 b8e84a88860a9bd8e02db96489143dcaaea5bbc0888c5f27943a4cff6006dfb5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rpg_map-0.1.0-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 664ab55b6ca8bba591d8f27773764a01c10c73f879b7b6a451b3cecf7af56d6b
MD5 5794e0a2774b5e660547b776ebce2af3
BLAKE2b-256 b0c981919e51d6da33ac06becaecfa2948a08f52ac8dd01816f3497a05097fd1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rpg_map-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 55ec79d8d6ebd392dfdd8823370de36cd6440e9cbdaf3d7d504d08c01885e827
MD5 542923810b726273c052b053999a87e4
BLAKE2b-256 c9ebfcedc7c5305aa289720889e401d6827bdd9d5a928c8ae599a7740acd6f64

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rpg_map-0.1.0-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 6de5bfc26514e5d36163833d3e9c0d206d6298173712d0859663a3d3abbd1088
MD5 06dc53fdcb0116b4a251457702e35132
BLAKE2b-256 44241cf3051713b7fdebaccadf2c5e6cd702d840279c09a2ecc89c90f5207b27

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rpg_map-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 003d08afdc5cda0aa83f9db21950e585b5c9bee8e5d8a864abf6991bbea3c647
MD5 065e2e1a89053d510195596b702ee825
BLAKE2b-256 d7c046a1b51d83d43a9e5142df3c4aec9da2b5379a5fdb1cf8ecddf9409a5132

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rpg_map-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 64e1c0d2a9e978c6512824a58bf5035e026a1dfc8eaab4207a082419a0415eca
MD5 605e66e5acb8fa07b2fa327a8784e9f4
BLAKE2b-256 11dad2a99417be67d1e5bd65e7a9b39d05bacfd5a8cd6a839a91155865436fd6

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