#!/usr/bin/env python3 """Contact sheet of enemy concept drafts (rows = enemies, columns = seeds) for picking: Doc/Design/Character/Enemy/drafts_sheet.png""" from pathlib import Path from PIL import Image, ImageDraw, ImageFont ROOT = Path(__file__).resolve().parents[1] DESIGN = ROOT / "Doc/Design/Character/Enemy" ORDER = ["Hornlet", "Dashlet", "Shellhorn", "HornCaptain", "GreatHorn"] CELL, LABEL = 320, 28 rows = [(n, sorted((DESIGN / n / "drafts").glob("*.png"))) for n in ORDER if (DESIGN / n / "drafts").exists()] cols = max(len(f) for _, f in rows) sheet = Image.new("RGB", (cols * CELL, len(rows) * (CELL + LABEL)), "white") draw = ImageDraw.Draw(sheet) font = ImageFont.load_default() for r, (name, files) in enumerate(rows): for c, f in enumerate(files): im = Image.open(f).convert("RGB"); im.thumbnail((CELL, CELL)) x, y = c * CELL, r * (CELL + LABEL) sheet.paste(im, (x, y + LABEL)) draw.text((x + 6, y + 8), f"{name} #{c + 1} ({f.stem.split('_')[-1]})", fill="black", font=font) sheet.save(DESIGN / "drafts_sheet.png") print(DESIGN / "drafts_sheet.png")