Skip to content

wavy-cat/wavy-totem-lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TotemLib

aka 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 patterns (styles)

Installing

Using uv

uv add wavy-totem-lib

Using Poetry

poetry add wavy-totem-lib

Using pip

pip install wavy-totem-lib

Quick start

from wavy_totem_lib import TotemBuilder, Skin, Totem, TopLayer

builder = TotemBuilder(
    Skin('my_skin.png'),
    top_layers=[TopLayer.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

More examples

Generation and scaling
from wavy_totem_lib import TotemBuilder, Skin, Totem

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')

To scale up, use the built-in scale() method instead of resize() from Pillow, because it may blur the image.

Asynchronous generation
import asyncio
from io import BytesIO
from wavy_totem_lib import TotemBuilder, Skin, Totem, TopLayer
# To save a file asynchronously, install the aiofiles package
import aiofiles


async def main():
    builder = TotemBuilder(Skin('my_skin.png', slim=False),
                           top_layers=[TopLayer.HEAD, TopLayer.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 pattern
from wavy_totem_lib import TotemBuilder, Skin, Totem
from wavy_totem_lib.patterns import STT

# Wavy is default, STT available built-in
builder = TotemBuilder(Skin('my_skin.png'), pattern=STT)
totem: Totem = builder.build()
totem.image.save('totem.png')

The generate() method accepts **kwargs, which will be passed on to the pattern class. None of the built-in patterns support them.

Patterns

Note

You can create your own pattern by creating subclass from Abstract class and implementing the image method.

Wavy

This is the default pattern in TotemBuilder.

Notch (wide) WavyCat (slim) CyCeKu (wide)
Skin Skin Skin
from wavy_totem_lib import TotemBuilder
from wavy_totem_lib.patterns import Wavy

TotemBuilder(pattern=Wavy)
# You can also not specify the pattern at all, because WavyStyle – default pattern.

STT

The code is taken from the UnFamousSoul/STT repository.

Notch (wide) WavyCat (slim) CyCeKu (wide)
Skin Skin Skin
from wavy_totem_lib import TotemBuilder
from wavy_totem_lib.patterns import STT

TotemBuilder(pattern=STT)