From 997d2ae917a04baf77f99349ed00ea5df8892cfc Mon Sep 17 00:00:00 2001 From: "Somhairle H. Marisol" Date: Mon, 28 Sep 2026 19:46:21 +0800 Subject: p45: 角色动画帧升级 — 四向x(走4+待机2)原创点阵内嵌图集, 行走/停止/idle 接入渲染 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/make-p45-char-crop.py | 52 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 scripts/make-p45-char-crop.py (limited to 'scripts/make-p45-char-crop.py') diff --git a/scripts/make-p45-char-crop.py b/scripts/make-p45-char-crop.py new file mode 100644 index 0000000..430bc72 --- /dev/null +++ b/scripts/make-p45-char-crop.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python3 +"""P45 evidence: crop the avatar cell from the real LV_P45_SHOT frames and upscale 4x. + +Reads the shot log for the character destination rect printed by the game +(`dest=x,y,w,h`), crops that region (plus a small margin) from the full 1280x720 +screenshot and upscales exactly 4x with NEAREST. Pure function of real frames. + +Usage: + python3 scripts/make-p45-char-crop.py +""" + +import re +import sys +from pathlib import Path + +from PIL import Image + +MARGIN = 8 +SCALE = 4 +DEST_RE = re.compile(r"p45-shot=(\S+) tick=(\d+) facing=(\S+) moving=(\w+) dest=(\d+),(\d+),(\d+),(\d+) frame=(.+)") + + +def main(argv): + if len(argv) != 4: + sys.stderr.write(__doc__) + return 2 + record_dir = Path(argv[1]) + log_text = Path(argv[2]).read_text(encoding="utf-8") + out_dir = Path(argv[3]) + out_dir.mkdir(parents=True, exist_ok=True) + count = 0 + for line in log_text.splitlines(): + m = DEST_RE.search(line) + if not m: + continue + name = m.group(1) + x, y, w, h = (int(m.group(i)) for i in range(5, 9)) + box = (x - MARGIN, y - MARGIN, x + w + MARGIN, y + h + MARGIN) + source = Image.open(record_dir / f"{name}.png").convert("RGBA") + crop = source.crop(box) + doubled = crop.resize((crop.width * SCALE, crop.height * SCALE), Image.NEAREST) + doubled.save(out_dir / f"{name}.png") + print(f"ok {name}.png {doubled.width}x{doubled.height} from {box} (facing={m.group(3)} moving={m.group(4)} frame={m.group(9)})") + count += 1 + if count == 0: + sys.stderr.write("no p45-shot dest lines found\n") + return 1 + return 0 + + +if __name__ == "__main__": + raise SystemExit(main(sys.argv)) -- cgit v1.2.3