57 lines
2.1 KiB
Python
57 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Build four one-effect battle previews at a 1024x576 review size."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
from pathlib import Path
|
|
|
|
from PIL import Image, ImageDraw
|
|
|
|
|
|
CASES = (
|
|
("THREAT / imminent", "threat_imminent@2x.png", (1265, 805), 150),
|
|
("DAMAGE / heavy", "damage_heavy@2x.png", (1050, 728), 196),
|
|
("PROTECT / intercept", "protect_intercept@2x.png", (955, 800), 160),
|
|
("TEMPEST PHASE / imminent", "tempest_phase_imminent@2x.png", (1832, 485), 220),
|
|
)
|
|
|
|
|
|
def parse_args() -> argparse.Namespace:
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("--background", type=Path, required=True)
|
|
parser.add_argument("--assets", type=Path, required=True)
|
|
parser.add_argument("--output", type=Path, required=True)
|
|
return parser.parse_args()
|
|
|
|
|
|
def main() -> None:
|
|
args = parse_args()
|
|
background = Image.open(args.background).convert("RGBA")
|
|
if background.size != (2048, 1152):
|
|
raise SystemExit(f"expected 2048x1152 background, found {background.size}")
|
|
|
|
panel_size = (1024, 620)
|
|
sheet = Image.new("RGB", (2048, 1240), (21, 26, 35))
|
|
draw = ImageDraw.Draw(sheet)
|
|
for index, (label, filename, center, size) in enumerate(CASES):
|
|
frame = background.copy()
|
|
effect = Image.open(args.assets / filename).convert("RGBA")
|
|
effect = effect.resize((size, size), Image.Resampling.LANCZOS)
|
|
position = (center[0] - size // 2, center[1] - size // 2)
|
|
frame.alpha_composite(effect, position)
|
|
frame = frame.resize((1024, 576), Image.Resampling.LANCZOS).convert("RGB")
|
|
x = (index % 2) * panel_size[0]
|
|
y = (index // 2) * panel_size[1]
|
|
sheet.paste(frame, (x, y))
|
|
draw.rectangle((x, y + 576, x + 1023, y + 619), fill=(21, 26, 35))
|
|
draw.text((x + 18, y + 590), label, fill=(244, 240, 224))
|
|
|
|
args.output.parent.mkdir(parents=True, exist_ok=True)
|
|
sheet.save(args.output, optimize=True)
|
|
print(f"VFX_PLAY_SIZE_PREVIEW_OK cases={len(CASES)} output={args.output}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|