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

path = "path_to_your_img.png"

# Load the background image from file
bg = BackgroundImageLoader(path)

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

# 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

path = "path_to_your_img.png"

# Load the background image from file
bg = BackgroundImageLoader(path)

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

# 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

path = "path_to_your_img.png"

# Load the background image from file
bg = BackgroundImageLoader(path)

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

# 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-10.0.0.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-10.0.0-py3-none-any.whl (3.0 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mctextrender-10.0.0.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-10.0.0.tar.gz
Algorithm Hash digest
SHA256 348c6fe182b6b6056120f00a2daf10204547aaf85001ab5d5394313b7b4e741a
MD5 ddaeaeb49b766981ada611d91d04261f
BLAKE2b-256 a6978cba9b8c1e88c12391c6f406da3f35454bbecc77749984634fdf9104779c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mctextrender-10.0.0-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-10.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4238619d1b89b070cfd5cbc2dbf204f54077d9a50f0e69b3abcb14ae3d7ed84b
MD5 bcd72836cf410dc6615bc5967118e03b
BLAKE2b-256 3037ddd159c8b276d5ffc2e0f010872900ef8f1ce20dd64358ee8e65cc436130

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