vertical text generator into function
All checks were successful
Upload release / build (push) Successful in 7s

This commit is contained in:
Mylloon 2024-10-03 21:11:48 +02:00
parent a19353f869
commit 0a790e8a75
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

16
main.py
View file

@ -58,6 +58,17 @@ def get_sign_image(image: str):
return enhanced_image
def vertical_text(text: str, font: ImageFont.ImageFont | ImageFont.FreeTypeFont):
"""Image with vertical text"""
text_img = Image.new("RGBA", (135, 24), (255, 255, 255, 0))
text_draw = ImageDraw.Draw(text_img)
text_draw.text((0, 0), f"{text:^15}", font=font, fill="black")
text_draw = text_img.rotate(90, expand=True)
return text_draw
def create_horoscope_image(horoscope: dict[str, dict[str, str]]):
"""Generate horoscope images"""
img_width, img_height = 1200, 425
@ -75,10 +86,7 @@ def create_horoscope_image(horoscope: dict[str, dict[str, str]]):
image.paste(sign_image, (x + 20, y), sign_image)
# Sign text
text_img = Image.new("RGBA", (135, 24), (255, 255, 255, 0))
text_draw = ImageDraw.Draw(text_img)
text_draw.text((0, 0), f"{sign:^15}", font=font_sign, fill="black")
text_draw = text_img.rotate(90, expand=True)
text_draw = vertical_text(sign, font_sign)
image.paste(text_draw, (x - 10, y - 10), text_draw)
# Love prediction