Skip to main content

A library for generating the texture of Minecraft's Totem of Undying

Project description

wavy-totem-lib

PyPI - Python Version GitHub License GitHub repo size

Python library to generate totems of undying for Minecraft.

Features

  • Support 64x32 skins
  • Zoning 2 layers and rounding the head
  • Lossless scaling image size
  • Asynchrony support
  • Supports PyPy
  • Supports different styles

Requirements

  • python >= 3.8
  • Pillow >= 10.0.0

Installing

  • Using poetry: poetry add wavy-totem-lib
  • Using pip: pip install wavy-totem-lib

Examples

  • Quick generation:
from wavy_totem_lib import TotemBuilder, Skin, Totem, TopLayers

builder = TotemBuilder(
    Skin('my_skin.png'),
    top_layers=[TopLayers.HEAD],  # the second layer will be applied only to the head
    round_head=True  # the head will be rounded at the corners
)

totem: Totem = builder.build()
totem.image.save('totem.png')  # .image is Pillow image
  • Generation and scaling:
from wavy_totem_lib import TotemBuilder, Skin, Totem, TopLayers

builder = TotemBuilder(Skin('my_skin.png', slim=True))

totem: Totem = builder.build()
scaled = totem.scale(factor=8)  # Scaling from 16×16 to 128×128
scaled.save('totem.png')

[!NOTE] To scale up, use the built-in scale method instead of raw.resize from Pillow, because it may blur the image.

  • Asynchronous generation:
import asyncio
import aiofiles  # This package must be installed
from io import BytesIO
from wavy_totem_lib import TotemBuilder, Skin, Totem, TopLayers


async def main():
    builder = TotemBuilder(Skin('my_skin.png', slim=False),
                           top_layers=[TopLayers.HEAD, TopLayers.HANDS],
                           round_head=True)
    totem: Totem = await builder.build_async()
    temp = BytesIO()
    totem.image.save(temp, format='png')

    async with aiofiles.open('totem.png', 'wb') as f:
        await f.write(temp.getvalue())


asyncio.run(main())
  • Specifying a style
from wavy_totem_lib import TotemBuilder, Skin, Totem, STTStyle

# WavyStyle (default), STTStyle available built-in
builder = TotemBuilder(Skin('my_skin.png'), style=STTStyle)
totem: Totem = builder.build()
totem.image.save('totem.png')

[!NOTE] The generate() method accepts **kwargs, which will be passed on to the style class. None of the built-in styles support them.

STTStyle taken from https://github.com/UnFamousSoul/STT

Styles

[!IMPORTANT] You can create your own styles by inheriting the AbstractStyle class and implementing the image property.

Wavy

Created by @wavy-cat. Class name: WavyStyle. This is the default style in TotemBuilder.

Basil Sylphiette PWGood
Image Image Image
from wavy_totem_lib import TotemBuilder, WavyStyle

TotemBuilder(style=WavyStyle)
# You can also not specify style at all, because WavyStyle - default style

STT

Created by @UnFamousSoul. The code is taken from the UnFamousSoul/STT repository. Class name: STTStyle.

Basil Sylphiette PWGood
Image Image Image
from wavy_totem_lib import TotemBuilder, STTStyle

TotemBuilder(style=STTStyle)

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

wavy_totem_lib-2.0.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

wavy_totem_lib-2.0.0-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file wavy_totem_lib-2.0.0.tar.gz.

File metadata

  • Download URL: wavy_totem_lib-2.0.0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for wavy_totem_lib-2.0.0.tar.gz
Algorithm Hash digest
SHA256 d571514e50cf9d380ae85549adb7f2e9d53c645d91818d17a87a53b6c2c2c43b
MD5 8655e2ff6f65b944446e07ea902139c9
BLAKE2b-256 a2aa19ff7aed71e7b3e0c0edc118fa9706501545b78a9fe8419d4c1d278d9a21

See more details on using hashes here.

File details

Details for the file wavy_totem_lib-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for wavy_totem_lib-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 651eecf3ca53a351763d637c44f6e5cb5ac0994d283898f3000d35c5b3fd40c5
MD5 203c7e5ebe003f266365acbe53585062
BLAKE2b-256 162f7b136a2c081a991014cf95d4ccc6122fa2d29d926ac7d9f3ce2d48be9839

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page