From 3449f1a828c65588f821f52ae6c8bd5fd08acc50 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Mon, 13 May 2024 07:37:17 +0200 Subject: [PATCH] ratp: Fake rers --- modules/ratp.py | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/modules/ratp.py b/modules/ratp.py index e9d1cae..3c75ac9 100644 --- a/modules/ratp.py +++ b/modules/ratp.py @@ -225,24 +225,35 @@ class IDFMAPI: icon_mode = "RER" img_line = None - if mode != "buses": - if fill == "white": - img = Image.open(os.path.join(config.icons_dir, "ratp", "lignes", icon_mode + "_" + line + "_NB" + state + "_RVB.png")) - return img.resize((int(size), int(img.height * size / img.width))) - else: - img_line = Image.open(os.path.join(config.icons_dir, "ratp", "lignes", icon_mode + "_" + line + "_NB_RVB.png")) - img = Image.new(img_line.mode, (img_line.width, int(img_line.height * 1.4))) - img.paste(img_line, (0,0)) + if mode == "rers" and fill != "white": + img = Image.new('RGBA', (size * 2, int(size * 2 * 1.25)), '#fff0') + draw = ImageDraw.Draw(img) - else: + fnt_icon = ImageFont.truetype(os.path.join(config.fonts_dir, IDFMAPI.fnt_RB_path), size*2-9) + draw.rounded_rectangle((0, 0, size*2-1, size*2-1), 7, outline=fill, width=2) + draw.text((size, size), line, fill=fill, anchor="mm", font=fnt_icon) + + elif mode == "buses": width = int(size * 1.38) img = Image.new('RGBA', (width, width), '#fff0') draw = ImageDraw.Draw(img) fnt_icon = ImageFont.truetype(os.path.join(config.fonts_dir, IDFMAPI.fnt_RB_path), size-3) - draw.rectangle((0, 0, width, size), fill="#222") + draw.rectangle((0, 0, width, size), fill) draw.text((int(width / 2), int(size / 2)), line, fill="white", anchor="mm", font=fnt_icon) + elif fill == "white": + img = Image.open(os.path.join(config.icons_dir, "ratp", "lignes", icon_mode + "_" + line + "_NB" + state + "_RVB.png")) + return img.resize((int(size), int(img.height * size / img.width))) + + else: + img_line = Image.open(os.path.join(config.icons_dir, "ratp", "lignes", icon_mode + "_" + line + "_NB_RVB.png")) + img = Image.new(img_line.mode, (img_line.width, int(img_line.height * 1.4))) + if mode != "rers": + img.paste(Image.new("RGB", (img_line.width, img_line.height), fill), (0,0), img_line) + else: + img.paste(img_line, (0,0)) + if state != "": if state.endswith("petit"): coeff = 2.5