Files
LihonT/scripts/make_store_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

253 lines
12 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 Telegram post about LihonT 2 · Serena and LihonT Store: eight pictures of 1080x1920, each drawn on purpose as a card of its own
(not a frame cut from the video), in the same light style as scripts/make_store_video.py (white ground, rounded picture tiles with soft
shadows, one violet accent, glossy "candy" letters). Only our own material: avatars with frames from scripts/frame_render.py, pictures
drawn by the video script, invented names.
py -X utf8 -B scripts/make_store_cards.py # work/store-cards/card_1_hero.png ...
"""
from __future__ import annotations
import math
import random
import sys
from pathlib import Path
from PIL import Image, ImageDraw
sys.path.insert(0, str(Path(__file__).resolve().parent))
import make_store_video as V # noqa: E402
V.set_format(True)
W, H, CX = V.W, V.H, V.CX
OUT = V.ROOT / "work" / "store-cards"
VIOLET, INK, GREY, GOLD = V.VIOLET, V.INK, V.GREY, V.GOLD
LATE = 100.0 # a time long after the letters have popped in: the candy text stands still
def canvas() -> Image.Image:
return Image.new("RGBA", (W, H), (255, 255, 255, 255))
def petals(img, seed, n, box, avoid=(), colors=None):
"""A few flowers and dots lying about, so that the card is not bare (fixed positions, nothing moves); never over the `avoid` boxes."""
rng = random.Random(seed)
colors = colors or V.FLOWERS
x0, y0, x1, y1 = box
for i in range(n):
x, y, size = rng.uniform(x0, x1), rng.uniform(y0, y1), rng.randint(14, 26)
if any(a0 - 40 <= x <= a2 + 40 and b0 - 40 <= y <= b2 + 40 for a0, b0, a2, b2 in avoid):
continue
col = colors[i % len(colors)]
if i % 3 == 0:
for p in range(5):
a = p / 5 * math.tau + i
V.put_c(img, V.disc(size, col), x + math.cos(a) * size * 0.7, y + math.sin(a) * size * 0.7)
V.put_c(img, V.disc(size, (255, 235, 150)), x, y, 0.8)
else:
V.put_c(img, V.disc(size // 2 + 4, col), x, y)
def footer(img):
flower = Image.open(V.ROOT / "src" / "brand" / "logo_note_flower_gold_1024.png").convert("RGBA").resize((86, 86), Image.Resampling.LANCZOS)
V.put_c(img, flower, CX - 190, H - 96)
V.text(img, (CX - 130, H - 94), "LihonT 2 · Serena", 38, "semi", GREY, "lm")
def head(img, title, sub=None, y=230, size=88):
lines = title.split("\n")
for i, line in enumerate(lines):
V.text(img, (CX, y + i * (size + 10)), line, size, "semi", INK, "mm")
if sub:
V.text(img, (CX, y + len(lines) * (size + 10) + 20), sub, 42, "reg", GREY, "mm")
def tile_card(img, index, size, cx, cy, angle=0.0, cat=False):
V.put_c(img, V.card(size, size, int(size * 0.1), blur=30, dy=14, alpha=44), cx, cy, 1.0, 1.0, angle)
V.put_c(img, V.tile(index, size, cat), cx, cy, 1.0, 1.0, angle)
def segmented(img, cy, labels, active):
w = 280
total = w * len(labels)
V.put_c(img, V.rr(total + 12, 84, 42, (240, 240, 244)), CX, cy)
for i, label in enumerate(labels):
x = CX - total / 2 + w * (i + 0.5)
if i == active:
V.put_c(img, V.rr(w - 6, 72, 36, VIOLET), x, cy)
V.text(img, (x, cy - 1), label, 32, "semi", (255, 255, 255) if i == active else GREY, "mm")
def card_hero():
img = canvas()
petals(img, 1, 26, (60, 80, W - 60, H - 160))
flower = Image.open(V.ROOT / "src" / "brand" / "logo_note_flower_gold_1024.png").convert("RGBA").resize((560, 560), Image.Resampling.LANCZOS)
V.put_c(img, V.soft_shadow(300, 300, 150, blur=60, dy=40, alpha=40), CX, 640)
V.put_c(img, flower, CX, 620)
V.text(img, (CX, 1040), "LihonT 2", 170, "semi", INK, "mm")
V.candy_text(img, CX, 1230, "SERENA", 190, LATE, 0.0, 0.0)
V.text(img, (CX, 1450), "мод для TikTok с открытым кодом", 46, "reg", GREY, "mm")
V.pill(img, CX, 1580, "рамки · пузыри · каталог", VIOLET, (255, 255, 255), 36)
footer(img)
return img
def card_store():
img = canvas()
petals(img, 2, 22, (40, 60, W - 40, 640), avoid=[(250, 160, 830, 600)])
V.text(img, (CX, 230), "LihonT", 130, "semi", INK, "mm")
V.candy_text(img, CX, 400, "STORE", 170, LATE, 0.0, 0.0)
V.text(img, (CX, 560), "каталог рамок и пузырей от людей", 44, "reg", GREY, "mm")
segmented(img, 690, ["Рамки", "Пузыри чата"], 0)
for n, (i, x, y, a) in enumerate([(1, 300, 1010, -2), (3, 780, 1010, 2), (5, 300, 1470, 1.5), (9, 780, 1470, -1.5)]):
tile_card(img, i, 420, x, y, a)
V.pill(img, 300, 1190, "+ Добавить", (24, 24, 28), (255, 255, 255), 30)
V.pill(img, 780, 1650, "v Добавлено", VIOLET, (255, 255, 255), 30)
footer(img)
return img
def arrow(img, cx, cy, w=130):
layer = Image.new("RGBA", (w + 40, 120), (0, 0, 0, 0))
d = ImageDraw.Draw(layer)
d.line([(20, 60), (w + 5, 60)], fill=VIOLET + (255,), width=14)
d.line([(w - 30, 25), (w + 10, 60), (w - 30, 95)], fill=VIOLET + (255,), width=14, joint="curve")
V.put_c(img, layer, cx, cy)
def card_ring():
img = canvas()
head(img, "Любая картинка\nстанет рамкой", "фото само вырежется в кольцо вокруг аватарки")
petals(img, 3, 18, (40, 700, W - 40, 1500), avoid=[(60, 760, 1020, 1160), (60, 1290, 1020, 1430)])
pic = V.mask_round(V.sunset(330), 40)
V.put_c(img, V.soft_shadow(330, 330, 40, blur=50, dy=30, alpha=60), 290, 900)
V.put_c(img, pic, 290, 900, 1.0, 1.0, -4)
arrow(img, 540, 900)
V.put_c(img, V.soft_shadow(250, 250, 125, blur=40, dy=24, alpha=50), 805, 900)
V.put_c(img, V.avatar(250), 805, 900)
V.put_c(img, V.ring_of(325), 805, 900)
V.pill(img, 290, 1130, "ваше фото", (240, 240, 244), GREY, 30)
V.pill(img, 805, 1130, "рамка на аватарке", VIOLET, (255, 255, 255), 30)
V.text(img, (CX, 1330), "Выберите картинку: мод вырежет кольцо,", 42, "reg", GREY, "mm")
V.text(img, (CX, 1392), "а аватарка останется в середине.", 42, "reg", GREY, "mm")
for n, i in enumerate([0, 2, 4]):
tile_card(img, i, 230, 220 + n * 320, 1620, (n - 1) * 3)
footer(img)
return img
def card_shapes():
img = canvas()
head(img, "Рамка повторяет\nформу аватарки", "круг, цветочек, сердечко, шестиугольник")
names = ["Круг", "Цветочек", "Сердечко", "Шестиугольник", "Квадрат", "Треугольник"]
for n, (i, label) in enumerate(zip([0, 1, 3, 5, 7, 9], names)):
x, y = 300 + (n % 2) * 480, 800 + (n // 2) * 330
tile_card(img, i, 280, x, y, ((n % 3) - 1) * 2)
V.text(img, (x, y + 180), label, 30, "semi", GREY, "mm")
footer(img)
return img
def card_bubbles():
img = canvas()
head(img, "Пузыри чата\nс вашими картинками", "их видят и у вас, и у друга с модом")
cx, cy = CX, 1010
V.put_c(img, V.card(940, 1000, 52), cx, cy)
V.text(img, (cx, cy - 430), "Чат", 36, "semi", GREY, "mm")
V.put_c(img, V.rr(600, 104, 40, (238, 238, 242)), cx - 150, cy - 300)
V.text(img, (cx - 150, cy - 301), "Привет! Как тебе мой пузырь?", 30, "reg", INK, "mm")
for k, (idx, label, x, y, w) in enumerate([(0, "Он виден и у меня, и у тебя", cx + 110, cy - 130, 640), (1, "У меня тоже есть мод", cx - 140, cy + 60, 560),
(3, "Круто, поставлю себе!", cx + 110, cy + 230, 600)]):
V.put_c(img, V.mask_round(V.bubble_picture(idx, w, 112), 48), x, y)
V.text(img, (x, y + 2), label, 30, "bold", (0, 0, 0), "mm", alpha=0.22)
V.text(img, (x, y - 1), label, 30, "bold", (255, 255, 255), "mm")
V.pill(img, cx, cy + 400, "Пузырь «Закат» из магазина", (24, 24, 28), (255, 255, 255), 28)
petals(img, 5, 10, (40, 520, W - 40, 560))
footer(img)
return img
def card_publish():
img = canvas()
head(img, "Публикуй\nсвои работы", "рамки и пузыри, сначала проверка, потом каталог")
cx, cy = CX, 1000
V.put_c(img, V.card(940, 800, 48), cx, cy)
V.text(img, (cx - 400, cy - 340), "Новая рамка", 40, "bold", INK, "lm")
V.put_c(img, V.rr(820, 460, 34, (240, 234, 255), VIOLET, 3), cx, cy - 60)
V.put_c(img, V.disc(190, VIOLET), cx, cy - 110)
V.draw_check(img, cx, cy - 110, 90, 1.0, (255, 255, 255), 16)
V.text(img, (cx, cy + 40), "Готово", 44, "bold", INK, "mm")
V.put_c(img, V.rr(260, 80, 40, (240, 240, 244)), cx - 300, cy + 290)
V.text(img, (cx - 300, cy + 289), "Выбрать файл", 30, "semi", INK, "mm")
V.put_c(img, V.rr(300, 80, 40, VIOLET), cx + 290, cy + 290)
V.text(img, (cx + 290, cy + 289), "Опубликовать", 30, "semi", (255, 255, 255), "mm")
V.pill(img, cx, cy + 500, "v отправлено на проверку", VIOLET, (255, 255, 255), 32)
V.put_c(img, V.soft_shadow(200, 200, 30, blur=40, dy=24, alpha=50), 210, 1690)
V.put_c(img, V.mask_round(V.sunset(200), 30), 210, 1690, 1.0, 1.0, -6)
petals(img, 6, 14, (380, 1640, W - 40, 1790))
footer(img)
return img
def card_profile():
img = canvas()
V.text(img, (CX, 200), "Профили авторов", 80, "semi", INK, "mm")
V.text(img, (CX, 285), "нажмите на ник под карточкой и увидите все работы", 38, "reg", GREY, "mm")
V.put_c(img, V.soft_shadow(270, 270, 135, blur=40, dy=24, alpha=50), CX, 560)
V.put_c(img, V.avatar(270), CX, 560)
V.put_c(img, V.ring_of(351), CX, 560)
V.text(img, (CX, 800), "@your_nickname", 60, "bold", INK, "mm")
V.pill(img, CX - 300, 890, "12 рамок", (240, 240, 244), INK, 32)
V.pill(img, CX - 30, 890, "5 пузырей", (240, 240, 244), INK, 32)
V.pill(img, CX + 275, 890, "1 204 добавили", VIOLET, (255, 255, 255), 32)
segmented(img, 1030, ["Опубликовано", "Проверка", "Библиотека"], 0)
for i, x, y in [(0, 300, 1330), (4, 780, 1330), (6, 300, 1700), (8, 780, 1700)]:
tile_card(img, i, 340, x, y, 0)
petals(img, 7, 12, (40, 1100, W - 40, 1200))
return img
def card_install():
img = canvas()
head(img, "Как поставить", "мод и магазин ставятся отдельно")
steps = [("Нет мода: удалите TikTok", "у мода другая подпись, поверх не встанет"),
("Поставьте мод LihonT 2 · Serena", "кто уже с модом: просто поверх старой версии"),
("Поставьте LihonT Store", "и войдите через TikTok, пароль не нужен")]
for n, (a, b) in enumerate(steps):
y = 700 + n * 300
V.put_c(img, V.card(900, 230, 50, blur=26, dy=12, alpha=40), CX, y)
V.put_c(img, V.disc(110, VIOLET), 200, y)
V.text(img, (200, y - 3), str(n + 1), 66, "bold", (255, 255, 255), "mm")
V.text(img, (300, y - 32), a, 40, "bold", INK, "lm")
V.text(img, (300, y + 36), b, 30, "reg", GREY, "lm")
V.text(img, (CX, 1640), "git.lihont.space/lihont", 46, "semi", INK, "mm")
V.text(img, (CX, 1710), "t.me/lihont", 42, "reg", GREY, "mm")
petals(img, 8, 14, (40, 1560, W - 40, 1780), avoid=[(150, 1600, 930, 1750)])
footer(img)
return img
CARDS = [("1_hero", card_hero), ("2_store", card_store), ("3_ring", card_ring), ("4_shapes", card_shapes), ("5_bubbles", card_bubbles),
("6_publish", card_publish), ("7_profile", card_profile), ("8_install", card_install)]
def main() -> None:
OUT.mkdir(parents=True, exist_ok=True)
for name, make in CARDS:
path = OUT / ("card_%s.png" % name)
make().convert("RGB").save(path)
print(path)
# a contact sheet to look at all of them at once
sheet = Image.new("RGB", (4 * 360 + 10, 2 * 640 + 4), (190, 190, 195))
for i, (name, _) in enumerate(CARDS):
im = Image.open(OUT / ("card_%s.png" % name)).resize((360, 640), Image.Resampling.LANCZOS)
sheet.paste(im, ((i % 4) * 362, (i // 4) * 642))
sheet.save(OUT / "sheet.png")
if __name__ == "__main__":
main()