ratp: Fake rers

This commit is contained in:
nemunaire 2024-05-13 07:37:17 +02:00
parent 8c9417a50e
commit 3449f1a828

View File

@ -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