Files
LihonT/scripts/make_pet_cards.py
cheb0chik 5df4cddf7d LihonT 3 Luna pre-alpha: the streak pet becomes an animal
A pair of people can have a kitten, a puppy or a lion cub in place of TikTok's streak creature: it grows with the days of the
streak (cub, teen, adult, elder), goes grey while the streak is about to burn out, can be dragged in the chat and is also shown
on the big streak screen. An animal is given by a link (lihont.space/pet) that the friend accepts. The drawings are made by
scripts/make_pet_designs.py and served as strips of frames. Also here: the promo video scripts (make_pet_video.py on top of
make_store_video.py), a retry pause for strips that failed to load, stricter checks in the answer to a gift.

Work in progress: the gift service is not switched on for everyone yet and there is no public build with the animals.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 15:14:48 +03:00

115 lines
4.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Cards for the post "everything works again + animals of the Серийчик": 1080x1350 PNGs in work/promo/cards_pets/.
Needs work/pets/*.png (py scripts/make_pet_designs.py first).
usage (from the repository root): py -B scripts/make_pet_cards.py
"""
from __future__ import annotations
import sys
from pathlib import Path
from PIL import Image
sys.path.insert(0, str(Path(__file__).resolve().parent))
import make_lihont_promo as P # noqa: E402
import make_lihont_cards as C # noqa: E402
BRAND = "LihonT 3 · Luna pre-alpha · @lihont"
def footer(layer: Image.Image) -> None:
P.draw_text(layer, (C.CW / 2, C.CH - 44), BRAND, 32, P.MUTED + (255,), bold=False)
def soon(layer: Image.Image, y: int = 350) -> None:
P.chip(layer, C.CW / 2, y, "Скоро в LihonT 3", 1.0, size=34, fill=P.PRIMARY, fg=P.BG)
PETS = P.ROOT / "work" / "pets"
OUT_DIR = P.ROOT / "work" / "promo" / "cards_pets"
def pet(kind: str, stage: str, grey: bool = False) -> Image.Image:
return Image.open(PETS / ("%s_%s%s.png" % (kind, stage, "_grey" if grey else ""))).convert("RGBA")
def card_fixed() -> Image.Image:
img = C.backdrop(21)
layer = Image.new("RGBA", (C.CW, C.CH), (0, 0, 0, 0))
P.place(layer, P.ASSETS["blobs"][1], C.CW / 2, 450, 1.4)
P.place(layer, P.ASSETS["logo"], C.CW / 2, 450, 0.5)
P.draw_text(layer, (C.CW / 2, 800), "Всё снова работает", 96, P.ON + (255,))
P.draw_text(layer, (C.CW / 2, 910), "Сайт, магазин и сервера на новом адресе", 42, P.PRIMARY + (255,), bold=False)
P.chip(layer, C.CW / 2, 1030, "Обновлять ничего не нужно", 1.0, size=44, fill=P.PRIMARY, fg=P.BG)
P.chip(layer, C.CW / 2, 1140, "Всё само подхватится", 1.0, size=40)
footer(layer)
img.alpha_composite(layer)
return img
def card_animals() -> Image.Image:
img = C.backdrop(22)
layer = Image.new("RGBA", (C.CW, C.CH), (0, 0, 0, 0))
C.head(layer, "Серийчик теперь зверь", "Котёнок, щенок или львёнок")
soon(layer)
for x, kind, tilt in ((220, "cat", -5), (540, "dog", 3), (860, "lion", -3)):
P.place(layer, pet(kind, "teen"), x, 700, 0.9, tilt)
P.chip(layer, 220, 1000, "Кот", 1.0, size=40)
P.chip(layer, 540, 1000, "Пёс", 1.0, size=40)
P.chip(layer, 860, 1000, "Лев", 1.0, size=40)
P.chip(layer, C.CW / 2, 1150, "Машут хвостом, дёргают ушами, моргают", 1.0, size=34)
footer(layer)
img.alpha_composite(layer)
return img
def card_growth() -> Image.Image:
img = C.backdrop(23)
layer = Image.new("RGBA", (C.CW, C.CH), (0, 0, 0, 0))
C.head(layer, "Растёт вместе с серией", "От малыша до старичка")
soon(layer)
stages = (("cub", "0–6 дней"), ("teen", "7–29"), ("adult", "30–99"), ("elder", "100+"))
for i, (stage, label) in enumerate(stages):
x = 170 + i * 247
P.place(layer, pet("cat", stage), x, 640, 0.52)
P.chip(layer, x, 880, label, 1.0, size=30)
P.draw_text(layer, (C.CW / 2, 1010), "А если серия вот-вот сгорит,", 40, P.MUTED + (255,), bold=False)
P.draw_text(layer, (C.CW / 2, 1066), "зверь становится серым и грустным", 40, P.MUTED + (255,), bold=False)
P.place(layer, pet("cat", "adult", True), 540, 1200, 0.38)
footer(layer)
img.alpha_composite(layer)
return img
def card_gift() -> Image.Image:
img = C.backdrop(24)
layer = Image.new("RGBA", (C.CW, C.CH), (0, 0, 0, 0))
C.head(layer, "Подари зверя другу", "Ссылкой, в один тап")
soon(layer)
P.place(layer, P.ASSETS["blobs"][2], C.CW / 2, 640, 1.2)
P.place(layer, pet("cat", "cub"), C.CW / 2, 640, 0.75, -3)
P.chip(layer, C.CW / 2, 960, "1. «Серийчик» → выбираешь зверя", 1.0, size=36)
P.chip(layer, C.CW / 2, 1050, "2. Отправляешь другу ссылку", 1.0, size=36)
P.chip(layer, C.CW / 2, 1140, "3. Друг жмёт «Принять»", 1.0, size=36)
P.chip(layer, C.CW / 2, 1230, "Зверь живёт в вашем общем чате", 1.0, size=34, fill=P.PRIMARY, fg=P.BG)
footer(layer)
img.alpha_composite(layer)
return img
def main() -> None:
P.init_assets()
OUT_DIR.mkdir(parents=True, exist_ok=True)
for name, make in (("1_fixed", card_fixed), ("2_animals", card_animals), ("3_growth", card_growth), ("4_gift", card_gift)):
path = OUT_DIR / ("pet_%s.png" % name)
make().convert("RGB").save(path)
print(path)
if __name__ == "__main__":
main()