"""The demo's capsules: the game's own, with a DEMO badge under the logo (Steam wants a demo's art to say it is one). py -I demo_capsules.py reads ../capsules, writes capsules/ next to this script The library hero and the page background carry no text (Steam's rule for the hero), so they stay as they are. """ import os from PIL import Image, ImageDraw, ImageFont, ImageFilter HERE = os.path.dirname(os.path.abspath(__file__)) SRC = os.path.join(HERE, "..", "capsules") OUT = os.path.join(HERE, "capsules") FONT = os.path.join(HERE, "..", "..", "..", "Assets", "Fonts", "LilitaOne-Regular.ttf") GOLD, INK = (255, 197, 61), (59, 36, 18) # file: (badge centre x, centre y, height) in the file's own pixels SPOTS = { "header_capsule_920x430.png": (725, 246, 70), "library_header_920x430.png": (703, 246, 70), "main_capsule_1232x706.png": (957, 345, 96), "small_capsule_462x174.png": (392, 146, 36), "vertical_capsule_748x896.png": (374, 310, 96), "library_capsule_600x900.png": (300, 318, 84), } def badge(im, cx, cy, h, text="DEMO"): font = ImageFont.truetype(FONT, int(h * 0.72)) tw = font.getlength(text) w = int(tw + h * 0.9) box = (int(cx - w / 2), int(cy - h / 2), int(cx + w / 2), int(cy + h / 2)) shadow = Image.new("RGBA", im.size, (0, 0, 0, 0)) ImageDraw.Draw(shadow).rounded_rectangle((box[0] + 3, box[1] + 5, box[2] + 3, box[3] + 5), radius=h // 2, fill=(0, 0, 0, 120)) im.alpha_composite(shadow.filter(ImageFilter.GaussianBlur(max(2, h // 12)))) d = ImageDraw.Draw(im) d.rounded_rectangle(box, radius=h // 2, fill=GOLD, outline=INK, width=max(2, int(h * 0.09))) d.text((cx, cy + h * 0.03), text, font=font, fill=INK, anchor="mm") def main(): os.makedirs(OUT, exist_ok=True) for name, (cx, cy, h) in SPOTS.items(): im = Image.open(os.path.join(SRC, name)).convert("RGBA") badge(im, cx, cy, h) im.convert("RGB").save(os.path.join(OUT, name)) # the library logo sits on the hero with nothing else: the badge goes under it on a taller transparent canvas logo = Image.open(os.path.join(SRC, "library_logo_1280w.png")).convert("RGBA") tall = Image.new("RGBA", (logo.width, logo.height + 170), (0, 0, 0, 0)) tall.alpha_composite(logo, (0, 0)) badge(tall, logo.width // 2, logo.height + 80, 120) tall.save(os.path.join(OUT, "library_logo_1280w.png")) for name in ("library_hero_3840x1240.png", "page_background_1438x810.png", "app_icon_184x184.jpg", "shortcut_icon_256x256.png"): Image.open(os.path.join(SRC, name)).save(os.path.join(OUT, name)) print("done:", sorted(os.listdir(OUT))) if __name__ == "__main__": main()