From 07ff2dcf017c0f05204622dadf8859e9e0450309 Mon Sep 17 00:00:00 2001 From: hkc Date: Tue, 9 Jul 2024 01:39:46 +0300 Subject: [PATCH] Somebody once told me the world is gonna roll me --- async-bot.py | 30 ++++++++++++++++++-- creep2.ttf | Bin 0 -> 13128 bytes funnies/shrek.txt | 68 ++++++++++++++++++++++++++++++++++++++++++++++ settings.json | 10 ++++++- 4 files changed, 104 insertions(+), 4 deletions(-) create mode 100755 creep2.ttf create mode 100644 funnies/shrek.txt diff --git a/async-bot.py b/async-bot.py index da1c3eb..bd4e8c8 100644 --- a/async-bot.py +++ b/async-bot.py @@ -65,7 +65,13 @@ class AsyncBotManager: ) as im: draw = ImageDraw.Draw(im) draw.rectangle((0, 0, im.width, im.height), (0, 0, 0, 0)) - draw.text((left + 2, top + 2), text, font=font, fill=(255, 255, 255, 255), anchor="lt") + draw.text( + (left + 2, top + 2), + text, + font=font, + fill=(255, 255, 255, 255), + anchor="lt", + ) alpha = im.convert("L").filter(ImageFilter.MaxFilter(5)) im.putalpha(alpha) @@ -385,7 +391,7 @@ async def amain(conf_path: str = "settings.json", *_) -> None: elem.get("font", "default"), elem.get("size", 8) ) - def update() -> PixelMap: + def update_time() -> PixelMap: now = datetime.datetime.now(datetime.timezone.utc) txt = now.strftime(time_format) img = mgr.get_text_image(txt, font) @@ -393,7 +399,7 @@ async def amain(conf_path: str = "settings.json", *_) -> None: img.close() return pixmap - mgr.animation_functions.append(update) + mgr.animation_functions.append(update_time) elif elem["type"] == "tile": with Image.open(elem["path"]).convert("LA") as im: for oy in range(elem.get("h", im.height)): @@ -468,6 +474,24 @@ async def amain(conf_path: str = "settings.json", *_) -> None: mgr.put_bit(offset, bool((byte >> (7 - i)) & 1)) written += 1 offset += 1 + elif elem["type"] == "shrek": + with open(elem["path"], "r") as fp: + lyrics = list(map(str.strip, fp)) + + font = ImageFont.truetype(elem["font"], 11) + + def update_shrek() -> PixelMap: + with Image.new("LA", (325, 10), (0, 255)) as im: + draw = ImageDraw.Draw(im) + draw.rectangle((0, 0, 325, 10), fill=(0, 255)) + now = datetime.datetime.now(datetime.timezone.utc) + line = lyrics[ + int(now.timestamp() / elem["spf"]) % len(lyrics) + ] + draw.text((2, -1), line, font=font, fill=(255, 255)) + return mgr.get_image_diff(elem["x"], elem["y"], im) + + mgr.animation_functions.append(update_shrek) mgr.get_difference_image().save("result.png") mgr.get_avoid_image().save("avoid.png") diff --git a/creep2.ttf b/creep2.ttf new file mode 100755 index 0000000000000000000000000000000000000000..ec3d0f0e4ad6aa7c2fc2ad28b00adc4c215b7194 GIT binary patch literal 13128 zcmeHOdw5jUwO{MZWHQNwWF`a%PtODb1PIJbGI`jbWF`}m5R#At5VVF#GC+hpNG1we zY>KEUQj3*Ve1cS4#QH*QeO1xYDr&7ytcV!vqhPB>tGz0a+~0m=z+3PAKL5G*yI(zF z&Tl>TUVH7e*M6Lt12GXfakCNyN=nVgxAmPzG;=cqJ3@hy`ZT_HJ&_51*ojb}GMJY- z@?)aY`cdnKP@pdO!dt-r(fAvPjQY~j`uV-v_ZJZ5%z%E}+>%f!ji5B>djwxyH_KNv z?}c?l+zWnLQ){@RW=}>DQ5@`9OINI3w|r^w(QKk**r58Ak#KYJH3=b;+!}e$vX;=-RkLGzt6>)VHl}ZwhA}mRYKbytcy#QX%v!AvD{F{uH(2$ZkAi5q?~!&`6;? z9*5|XEkW7ZL3EeX=xbCQQO)vDGxZD(4*3Azp4w}pOO)Pt1ZWb&HsXXv;i2+U>A$^y z8-Z^l@NX3X3wkR)-sP5f1&?S ze_wyUSktg}?SL0aJceiUTwcV>xS88{z4qcN%RTVIY5L&B8D_QgVvGCv41yOoNiUKz zTQhHl7keg?^kTU5;)y8-rX0!|J$)Ix=;_`=p@a}O;%lzYhf`ia;7`TFgz&wst*;Ee|_JGkbxPhWfcwKxBK z>w(4t;RB`aY3}iEmpk6I%k@jwm9EQO=es&xZLSHfv92+$WHnNV#{cbQGZKXZNEVSV zr(PV}3y1c^Q?;kks-^|`6^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