new font + small layout changes + cleanup

This commit is contained in:
barry committed 2025-01-11 00:28:20 +01:00
1 parent e95d25ca01
commit 083990cd77
9 files changed
+25 -24

No files matched your search

BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+25 -24
View File
@@ -28,32 +28,31 @@ def display_loop(api: Api, cfg: Dict):
bg = Image.new("RGB", (d.height, d.width), (0, 0, 0)) bg = Image.new("RGB", (d.height, d.width), (0, 0, 0))
d.ShowImage(bg) d.ShowImage(bg)
#Font0 = ImageFont.truetype("Font/Font00.ttf", 14) Font0 = ImageFont.truetype("Font/GothamMedium.ttf", 13)
#Font1 = ImageFont.truetype("Font/Font00.ttf", 18) Font1 = ImageFont.truetype("Font/GothamMedium.ttf", 18)
#Font2 = ImageFont.truetype("Font/Font00.ttf", 36) Font1b = ImageFont.truetype("Font/GothamBold.ttf", 19)
Font2 = ImageFont.truetype("Font/GothamMedium.ttf", 20)
Font0 = ImageFont.truetype("Font/GothamLight.ttf", 14) Font3 = ImageFont.truetype("Font/GothamMedium.ttf", 36)
Font1 = ImageFont.truetype("Font/GothamLight.ttf", 18)
Font2 = ImageFont.truetype("Font/GothamLight.ttf", 36)
unavailable_img = Image.open("imgs/unavailable.jpg") unavailable_img = Image.open("imgs/unavailable.jpg")
error_img = Image.new("RGB", (240, 320), color=(255, 0, 0)) error_img = Image.new("RGB", (240, 320), color=(255, 0, 0))
draw = ImageDraw.Draw(error_img) draw = ImageDraw.Draw(error_img)
draw.text((150, 150), "Error", font=Font1, fill=cfg["color_theme"]["text"]) draw.text((150, 150), "Error :(", font=Font1, fill=cfg["color_theme"]["text"])
del draw del draw
spoti_logo = Image.open("imgs/logo128.jpg") spoti_logo = Image.open("imgs/logo64.jpg")
qr = Image.open("imgs/qr.jpg") qr = Image.open("imgs/qr.jpg")
spoti_logo = spoti_logo.resize((128, 128)) spoti_logo = spoti_logo.resize((64, 64))
not_playing_img = Image.new("RGB", (320, 240), (0, 0, 0)) not_playing_img = Image.new("RGB", (320, 240), (0, 0, 0))
not_playing_img.paste(spoti_logo, (0, 10)) not_playing_img.paste(spoti_logo, (25, 40))
not_playing_img.paste(qr, (120, 40)) not_playing_img.paste(qr, (120, 40))
draw = ImageDraw.Draw(not_playing_img) draw = ImageDraw.Draw(not_playing_img)
draw.text( draw.text(
(124, 10), (112, 15),
"Connect to speakers", "Connect to speakers",
font=Font1, font=Font2,
fill=cfg["color_theme"]["text"], fill=(255, 255, 255),
# fill=cfg["color_theme"]["text"],
) )
del spoti_logo, qr, draw del spoti_logo, qr, draw
@@ -82,11 +81,13 @@ def display_loop(api: Api, cfg: Dict):
draw = ImageDraw.Draw(not_playing_img) draw = ImageDraw.Draw(not_playing_img)
current_time = datetime.now().time() current_time = datetime.now().time()
draw.rectangle([(00, 120), (119, 170)], fill=(0, 0, 0)) draw.rectangle([(00, 120), (119, 170)], fill=(0, 0, 0))
offset = 10 if current_time.hour < 9 else 0
draw.text( draw.text(
(20, 120), (10 + offset, 120),
f"{current_time.hour}:{current_time.minute:02d}", f"{current_time.hour}:{current_time.minute:02d}",
font=Font2, font=Font3,
angle=0, fill=(255, 255, 255),
# fill=cfg["color_theme"]["text"],
) )
if current_mode != 0: if current_mode != 0:
current_mode = 0 current_mode = 0
@@ -117,20 +118,20 @@ def display_loop(api: Api, cfg: Dict):
bg.paste(img, (10, 30)) bg.paste(img, (10, 30))
draw = ImageDraw.Draw(bg) draw = ImageDraw.Draw(bg)
draw.text( draw.text(
(150, 28), (145, 33),
"\n".join(textwrap.wrap(", ".join(data["artists"]), width=16)), "\n".join(textwrap.wrap(", ".join(data["artists"]), width=16)),
font=Font1, font=Font1,
fill=cfg["color_theme"]["text"], fill=cfg["color_theme"]["text"],
) )
draw.text( draw.text(
(10, 160), (11, 164),
"\n".join(textwrap.wrap(data["track"], width=32)), "\n".join(textwrap.wrap(data["track"], width=28)),
font=Font1, font=Font1b,
fill=cfg["color_theme"]["text"], fill=cfg["color_theme"]["text"],
) )
w, h = bg.size w, h = bg.size
w -= 92 w -= 95
progress_time = data["progress_ms"] + int( progress_time = data["progress_ms"] + int(
(time.time() - last_api_call) * 1000 (time.time() - last_api_call) * 1000
) )
@@ -154,10 +155,10 @@ def display_loop(api: Api, cfg: Dict):
*divmod(data["duration_ms"] // 1000, 60) *divmod(data["duration_ms"] // 1000, 60)
) )
draw.rectangle( draw.rectangle(
[(234, 215), (310, 235)], fill=cfg["color_theme"]["background"] [(231, 215), (320, 235)], fill=cfg["color_theme"]["background"]
) )
draw.text( draw.text(
(235, 215), (232, 220),
f"{f_current_time}/{f_total_time}", f"{f_current_time}/{f_total_time}",
font=Font0, font=Font0,
fill=cfg["color_theme"]["text"], fill=cfg["color_theme"]["text"],