Python library to generate totems of undying for Minecraft.
- Support 64x32 skins
- Zoning 2 layers and rounding the head
- Lossless scaling image size
- Asynchrony support
- Supports PyPy
- Supports different styles
- python >= 3.8
- Pillow >= 10.0.0
- Using poetry:
poetry add wavy-totem-lib
- Using pip:
pip install wavy-totem-lib
- 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 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, TopLayers
# To save a file asynchronously, install the aiofiles package
import aiofiles
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.
Important
You can create your own styles by inheriting the AbstractStyle
class and implementing the image
property.
Created by @wavy-cat.
Class name: WavyStyle
.
This is the default style in TotemBuilder.
Basil | Sylphiette | PWGood |
---|---|---|
from wavy_totem_lib import TotemBuilder, WavyStyle
TotemBuilder(style=WavyStyle)
# You can also not specify style at all, because WavyStyle - default style
Created by @UnFamousSoul.
The code is taken from the UnFamousSoul/STT repository.
Class name: STTStyle
.
Basil | Sylphiette | PWGood |
---|---|---|
from wavy_totem_lib import TotemBuilder, STTStyle
TotemBuilder(style=STTStyle)
2024. Made with 💚 by WavyCat on Earth.