Skip to main content

A rendering library for Minecraft-style text and images

Project description

Minecraft-Style Text Rendering

This library provides utilities to render Minecraft-style text onto images with support for colors, alignment, and shadows. It also makes it easy to combine background and overlay images.

Currently, bold, italic, and bold italic formatting are not supported.

Features

  • Load and render background images.
  • Draw text with Minecraft color codes.
  • Draw multiple text entries with different positions/alignments.
  • Add overlay images on top of backgrounds.
  • Export the final result to a file or bytes.

Usage Examples

1. Draw Text onto a Background and Save

from mctextrender import BackgroundImageLoader, ImageRender

# Load the background image from file
bg = BackgroundImageLoader("path_to_your_img.png")

# Initialize an ImageRender instance with the loaded background 
img = ImageRender(bg.load_image())

# Draw text onto the image
img.text.draw(
    "&aHello &bMinecraft!",
    {
        "position": (50, 50), 
        "font_size": 24, 
        "shadow_offset": (2, 2)
    }
)

# Save the final image
img.save("path_to_save_img.png")

2. Draw Multiple Texts onto a Background and Save

from mctextrender import BackgroundImageLoader, ImageRender

# Load the background image from file
bg = BackgroundImageLoader("path_to_your_img.png")

# Initialize an ImageRender instance with the loaded background 
img = ImageRender(bg.load_image())

# Draw multiple texts
img.text.draw_many([
    ("&cRed Left", {"position": (20, 40), "align": "left", "font_size": 20}),
    ("&9Blue Centered", {"position": (200, 90), "align": "center", "font_size": 22}),
    ("&aGreen Right", {"position": (380, 140), "align": "right", "font_size": 20}),
],
    {"shadow_offset": (2, 2)}
)

# Save the final image
img.save("path_to_save_img.png")

3. Draw Text and Overlay an Image, then Save

from mctextrender import BackgroundImageLoader, ImageRender

# Load the background image from file
bg = BackgroundImageLoader("path_to_your_img.png")

# Initialize an ImageRender instance with the loaded background 
img = ImageRender(bg.load_image())

# Draw multiple texts
img.text.draw_many([
    ("&cRed Left", {"position": (20, 40), "align": "left", "font_size": 20}),
    ("&9Blue Centered", {"position": (200, 90), "align": "center", "font_size": 22}),
    ("&aGreen Right", {"position": (380, 140), "align": "right", "font_size": 20}),
],
    {"shadow_offset": (2, 2)}
)

# Overlay another image on top of the background
im.overlay_image(bg.load_image("path_to_your_overlay_img.png"))

# Save the final image
img.save("path_to_save_img.png")

Minecraft Color Codes

Code Name RGB Value HEX
&0 Black (0, 0, 0) #000000
&1 Dark Blue (0, 0, 170) #0000AA
&2 Dark Green (0, 170, 0) #00AA00
&3 Dark Aqua (0, 170, 170) #00AAAA
&4 Dark Red (170, 0, 0) #AA0000
&5 Dark Purple (170, 0, 170) #AA00AA
&6 Gold (255, 170, 0) #FFAA00
&7 Gray (170, 170, 170) #AAAAAA
&8 Dark Gray (85, 85, 85) #555555
&9 Blue (85, 85, 255) #5555FF
&a Green (85, 255, 85) #55FF55
&b Aqua (85, 255, 255) #55FFFF
&c Red (255, 85, 85) #FF5555
&d Light Purple (255, 85, 255) #FF55FF
&e Yellow (255, 255, 85) #FFFF55
&f White (255, 255, 255) #FFFFFF

Support

If you run into any issues, bugs, or have other questions, feel free to DM me on Discord @ventros. thanks!

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

mctextrender-9.9.9.tar.gz (2.9 MB view details)

Uploaded Source

Built Distribution

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

mctextrender-9.9.9-py3-none-any.whl (3.0 MB view details)

Uploaded Python 3

File details

Details for the file mctextrender-9.9.9.tar.gz.

File metadata

  • Download URL: mctextrender-9.9.9.tar.gz
  • Upload date:
  • Size: 2.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for mctextrender-9.9.9.tar.gz
Algorithm Hash digest
SHA256 94330d54259e4c8cb36fa6531bbafdab00b60ee6f1f0ac30aa30e5b5a17d8f8d
MD5 a75984dcacce15b0d4c1d05f46a0ce7d
BLAKE2b-256 76e499c86f8190d713f3a3b02dd363cd6730e3c5fe8170b3126cfa636fc50811

See more details on using hashes here.

File details

Details for the file mctextrender-9.9.9-py3-none-any.whl.

File metadata

  • Download URL: mctextrender-9.9.9-py3-none-any.whl
  • Upload date:
  • Size: 3.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for mctextrender-9.9.9-py3-none-any.whl
Algorithm Hash digest
SHA256 322fee7b50418f1a3f306a3e6eb942410a1de01dd00f07b3b9a02541499a1b20
MD5 84f76b78ba4e8f7679dabf8a04900c2d
BLAKE2b-256 f066ca8d03b6c917125b8d84bfdf46ba737025c0b71042a8d138d0f97bf45b93

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