The "Как сайт" look by default, also in TikTok's settings and all their sub-pages, where every item is its own rounded row. The bottom bar floats as an island, 9:16 videos reach under it, the seek bar is lifted, thicker and on by default, the comment input is an island too, and "only sound" downloads are saved as audio. The LihonT agent: a chat that makes cards and slides for a photo post, looks things up on the web, signs in with Telegram and has a daily limit on the server. Also the нейронка.рус landing page and the 3D-phone promo scripts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
143 lines
5.7 KiB
Python
143 lines
5.7 KiB
Python
"""Draws a demo agent chat screen and four cat-breed cards from scratch, in the mod's dark "site" look.
|
|
|
|
Nothing here comes from a real chat: the talk and the cards are invented for the promo.
|
|
"""
|
|
from PIL import Image, ImageDraw, ImageFont
|
|
|
|
W, H = 1080, 2412
|
|
SURFACE = (13, 13, 15)
|
|
USER = (38, 38, 43) # primaryContainer
|
|
AGENT = (28, 28, 32) # surfaceContainerHigh
|
|
INK = (245, 245, 247)
|
|
MUTED = (160, 160, 168)
|
|
OUTLINE = (85, 85, 93)
|
|
|
|
F = "C:/Windows/Fonts/"
|
|
|
|
|
|
def font(size, bold=False):
|
|
return ImageFont.truetype(F + ("segoeuib.ttf" if bold else "segoeui.ttf"), size)
|
|
|
|
|
|
EMOJI = ImageFont.truetype(F + "seguiemj.ttf", 109)
|
|
|
|
|
|
def wrap(draw, text, fnt, width):
|
|
lines, line = [], ""
|
|
for word in text.split():
|
|
test = (line + " " + word).strip()
|
|
if draw.textlength(test, font=fnt) <= width:
|
|
line = test
|
|
else:
|
|
lines.append(line)
|
|
line = word
|
|
if line:
|
|
lines.append(line)
|
|
return lines
|
|
|
|
|
|
def emoji(size, char):
|
|
"""A colour emoji drawn at 109 px (the font's own size) and scaled."""
|
|
tile = Image.new("RGBA", (140, 140), (0, 0, 0, 0))
|
|
ImageDraw.Draw(tile).text((10, 5), char, font=EMOJI, embedded_color=True)
|
|
return tile.resize((size, size), Image.LANCZOS)
|
|
|
|
|
|
CATS = [
|
|
("🦁", "Мейн-кун", "Один из самых крупных: до 9 кг, пушистый хвост и «кисточки» на ушах.", (194, 117, 58), (122, 63, 23)),
|
|
("🐈", "Сфинкс", "Почти без шерсти, тёплый на ощупь и очень ласковый.", (160, 122, 156), (78, 53, 80)),
|
|
("🐱", "Британская", "Плотная плюшевая шерсть, круглые щёки и спокойный нрав.", (111, 130, 150), (51, 65, 79)),
|
|
("😺", "Сиамская", "Голубые глаза, тёмная мордочка и громкий голос.", (201, 164, 106), (109, 82, 40)),
|
|
]
|
|
|
|
|
|
def card(i, w=1080, h=1920):
|
|
char, title, fact, top, bottom = CATS[i]
|
|
im = Image.new("RGB", (w, h))
|
|
px = im.load()
|
|
for y in range(h):
|
|
t = y / h
|
|
c = tuple(int(top[k] * (1 - t) + bottom[k] * t) for k in range(3))
|
|
for x in range(w):
|
|
px[x, y] = c
|
|
d = ImageDraw.Draw(im)
|
|
s = w / 1080
|
|
d.text((w - 70 * s, 70 * s), f"{i + 1}/4", font=font(int(40 * s)), fill=(255, 255, 255), anchor="ra")
|
|
im.paste(e := emoji(int(420 * s), char), (int(90 * s), int(300 * s)), e)
|
|
d.text((90 * s, h - 640 * s), title, font=font(int(120 * s), True), fill=(255, 255, 255))
|
|
y = h - 470 * s
|
|
for line in wrap(d, fact, font(int(58 * s)), w - 180 * s):
|
|
d.text((90 * s, y), line, font=font(int(58 * s)), fill=(255, 255, 255))
|
|
y += 78 * s
|
|
d.text((90 * s, h - 130 * s), "LihonT · агент", font=font(int(36 * s)), fill=(255, 255, 255, 180))
|
|
return im
|
|
|
|
|
|
def rounded(d, box, r, fill, outline=None):
|
|
d.rounded_rectangle(box, r, fill=fill, outline=outline, width=3 if outline else 0)
|
|
|
|
|
|
def chat():
|
|
im = Image.new("RGB", (W, H), SURFACE)
|
|
d = ImageDraw.Draw(im)
|
|
# header
|
|
d.text((60, 150), "Агент", font=font(76, True), fill=INK)
|
|
d.text((60, 248), "Осталось сегодня: 9 из 10", font=font(38), fill=MUTED)
|
|
d.text((W - 60, 175), "Закрыть", font=font(44, True), fill=INK, anchor="ra")
|
|
d.text((W - 300, 175), "Новый", font=font(44, True), fill=INK, anchor="ra")
|
|
|
|
y = 380
|
|
# the person's request
|
|
ask = "Сделай 4 карточки про породы кошек"
|
|
f = font(48, True)
|
|
lines = wrap(d, ask, f, 640)
|
|
bw = max(d.textlength(l, font=f) for l in lines) + 90
|
|
bh = len(lines) * 64 + 60
|
|
rounded(d, (W - 50 - bw, y, W - 50, y + bh), 48, USER)
|
|
for k, l in enumerate(lines):
|
|
d.text((W - 50 - bw + 45, y + 30 + k * 64), l, font=f, fill=INK)
|
|
y += bh + 40
|
|
|
|
# the agent's answer
|
|
answer = "Готово! Вот 4 карточки для фото-поста. Хотите, поменяю цвета, порядок или текст."
|
|
f = font(48, True)
|
|
lines = wrap(d, answer, f, 760)
|
|
bh = len(lines) * 64 + 60
|
|
rounded(d, (50, y, 50 + 860, y + bh), 48, AGENT)
|
|
for k, l in enumerate(lines):
|
|
d.text((95, y + 30 + k * 64), l, font=f, fill=INK)
|
|
y += bh + 36
|
|
|
|
# the four cards as previews, two by two
|
|
cw, ch, gap = 330, 587, 24
|
|
for i in range(4):
|
|
cx = 50 + (i % 2) * (cw + gap)
|
|
cy = y + (i // 2) * (ch + gap)
|
|
thumb = card(i, 540, 960).resize((cw, ch), Image.LANCZOS)
|
|
mask = Image.new("L", (cw, ch), 0)
|
|
ImageDraw.Draw(mask).rounded_rectangle((0, 0, cw, ch), 36, fill=255)
|
|
im.paste(thumb, (cx, cy), mask)
|
|
# the input bar
|
|
by = H - 250
|
|
rounded(d, (40, by, 180, by + 140), 50, USER)
|
|
d.text((110, by + 68), "+", font=font(80), fill=INK, anchor="mm")
|
|
rounded(d, (210, by, W - 200, by + 140), 70, SURFACE, OUTLINE)
|
|
d.text((265, by + 70), "Сообщение", font=font(48), fill=MUTED, anchor="lm")
|
|
d.ellipse((W - 170, by, W - 30, by + 140), fill=INK)
|
|
d.polygon([(W - 100, by + 38), (W - 135, by + 82), (W - 112, by + 82), (W - 112, by + 105),
|
|
(W - 88, by + 105), (W - 88, by + 82), (W - 65, by + 82)], fill=SURFACE)
|
|
tip = "ИИ может ошибаться. "
|
|
t1 = font(38)
|
|
tw = d.textlength(tip, font=t1) + d.textlength("Подробнее", font=font(38, True))
|
|
x0 = (W - tw) / 2
|
|
d.text((x0, by + 168), tip, font=t1, fill=MUTED)
|
|
d.text((x0 + d.textlength(tip, font=t1), by + 168), "Подробнее", font=font(38, True), fill=INK)
|
|
return im
|
|
|
|
|
|
if __name__ == "__main__":
|
|
chat().save("agent_clean.png")
|
|
for i in range(4):
|
|
card(i).save(f"cat_card_{i + 1}.png")
|
|
print("ok")
|