Journey: label mode badges with Z/B letters, not just color

Plain colored dots weren't self-explanatory. Each leg badge now shows
a "Z" (Zug) or "B" (Bus) in white inside the blue/green circle --
confirmed legible at actual render size via zoomed crop inspection.
This commit is contained in:
Honey committed 2026-07-23 10:08:51 +02:00
1 parent 080cb11501
commit 7354517b22
1 file changed
+19 -8
+19 -8
View File
@@ -350,13 +350,17 @@ class JourneyScreen(Screen):
draw.text((arrow_x + arrow_w + scale * 0.02, top_line_y), journey["arrival"], font=time_font, fill=BLACK) draw.text((arrow_x + arrow_w + scale * 0.02, top_line_y), journey["arrival"], font=time_font, fill=BLACK)
# Detail line: a colored dot per leg (blue = train, green = bus -- # Detail line: a small badge per leg -- colored circle (blue =
# pure panel colors, no dithering) followed by its line name, then # train, green = bus; pure panel colors, no dithering) with a
# transfer/platform/notice info. Drawn as manually-placed segments # "Z" (Zug) or "B" (Bus) letter in it, so the mode is legible at
# instead of one joined string so each leg can carry its own dot. # a glance rather than relying on color alone. Followed by the
# line name, then transfer/platform/notice info. Drawn as
# manually-placed segments instead of one joined string so each
# leg can carry its own badge.
detail_y = top_line_y + time_font.size * 1.25 detail_y = top_line_y + time_font.size * 1.25
right_edge = width - pad right_edge = width - pad
icon_d = detail_font.size * 0.55 icon_d = detail_font.size * 0.9
icon_font = load_font(size=max(8, int(icon_d * 0.62)), bold=True)
cursor_x = pad cursor_x = pad
def draw_segment(text, color=BLACK, avail=None): def draw_segment(text, color=BLACK, avail=None):
@@ -367,12 +371,19 @@ class JourneyScreen(Screen):
cursor_x += text_width(draw, text, detail_font) cursor_x += text_width(draw, text, detail_font)
return text return text
def draw_mode_icon(x, mode):
color = BLUE if mode == "train" else GREEN
letter = "Z" if mode == "train" else "B"
top = detail_y + (detail_font.size - icon_d) / 2
draw.ellipse((x, top, x + icon_d, top + icon_d), fill=color)
l, t, r, b = draw.textbbox((0, 0), letter, font=icon_font)
lw, lh = r - l, b - t
draw.text((x + (icon_d - lw) / 2 - l, top + (icon_d - lh) / 2 - t), letter, font=icon_font, fill=(255, 255, 255))
for idx, leg in enumerate(journey["legs"]): for idx, leg in enumerate(journey["legs"]):
if cursor_x >= right_edge - icon_d: if cursor_x >= right_edge - icon_d:
break break
dot_color = BLUE if leg["mode"] == "train" else GREEN draw_mode_icon(cursor_x, leg["mode"])
dot_top = detail_y + (detail_font.size - icon_d) / 2
draw.ellipse((cursor_x, dot_top, cursor_x + icon_d, dot_top + icon_d), fill=dot_color)
cursor_x += icon_d + scale * 0.01 cursor_x += icon_d + scale * 0.01
shown = draw_segment(leg["name"], avail=right_edge - cursor_x) shown = draw_segment(leg["name"], avail=right_edge - cursor_x)