Continued the full-art goal (owner: H01 fidelity, my call on priority). Proved the end-to-end path from a single accepted AI portrait to a runtime 4-frame atlas, and produced H07 at H01 fidelity. - H07 base portrait generated with gpt-image-2.5 using H01 as identity/style anchor (base-source.png, 1254x1254, clean magenta). Download succeeded after diagnosing the real blocker: macOS system proxy 127.0.0.1:7897 corrupts the ZexAPI CDN; --proxy '' --noproxy '*' + --compressed + PIL-full-decode retry loop (tools/patient_download.sh) gets complete files reliably. - idle strip repeatedly failed to download (random CDN truncation), so derived a 4-frame breathing loop from the accepted H01-fidelity portrait via tools/derive_idle_frames.py, packed with pack_animation_strip.py into a 384x96 runtime atlas + manifest with provenance. H07 now loads and advances frames in runtime (BREATHING_PASS 15 stages). - Reusable tools: ai_sprite_to_runtime.py (strip->runtime, verified against H02 raw), derive_idle_frames.py, cdn_download.py, patient_download.sh, pxl_to_runtime.py (code-art fallback). Documented in PRODUCTION/50. - breathing_test now asserts H07 idle too. Honest note: the portrait is H01 hand-painted fidelity; the idle animation is procedural micro-motion (not AI pose-generated) because the strip download was unreliable. Full-game coverage: heroes H01-H07, R1 enemies, B01 done; R2-R5 enemies + H08-H54 + B02-B20 remain. All gates pass; P2_CHECKS_PASS. prototype/ untracked.
80 lines
3.1 KiB
Python
80 lines
3.1 KiB
Python
#!/usr/bin/env python3
|
|
"""End-to-end: a magenta-backed horizontal AI strip -> runtime game atlas.
|
|
|
|
Deterministic, no network. Uses slice_grid.py's chroma-key to cut the 1xN
|
|
strip into transparent frames, then pack_animation_strip.py for one shared
|
|
scale + foot line + fixed-cell atlas (no per-frame jitter).
|
|
|
|
Runtime params mirror accepted H01/H02 art: cell 96, fit 0.86, key FF00FF.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
TOOLS = ROOT / "tools"
|
|
|
|
|
|
def run(cmd: list[str]) -> None:
|
|
r = subprocess.run(cmd, capture_output=True, text=True)
|
|
if r.returncode != 0:
|
|
raise SystemExit(f"FAILED: {' '.join(cmd)}\n{r.stdout}\n{r.stderr}")
|
|
tail = (r.stdout or r.stderr).strip().splitlines()
|
|
if tail:
|
|
print(" " + tail[-1][:160])
|
|
|
|
|
|
def main() -> int:
|
|
ap = argparse.ArgumentParser(description=__doc__)
|
|
ap.add_argument("--strip", required=True, type=Path)
|
|
ap.add_argument("--character", required=True)
|
|
ap.add_argument("--state", default="idle")
|
|
ap.add_argument("--frames", type=int, default=4)
|
|
ap.add_argument("--work", required=True, type=Path)
|
|
ap.add_argument("--output-dir", required=True, type=Path)
|
|
ap.add_argument("--fps", type=int, default=8)
|
|
ap.add_argument("--loop", action="store_true", default=True)
|
|
ap.add_argument("--tolerance", type=int, default=60)
|
|
ap.add_argument("--task-id", default="")
|
|
ap.add_argument("--identity-anchor", default="")
|
|
ap.add_argument("--prompt-file", default="")
|
|
args = ap.parse_args()
|
|
|
|
frames_dir = args.work / "frames" / args.state
|
|
frames_dir.mkdir(parents=True, exist_ok=True)
|
|
|
|
# 1. cut the strip into transparent frames (chroma key inline)
|
|
slice_script = Path.home() / ".claude/skills/image-gen/scripts/slice_grid.py"
|
|
run([sys.executable, str(slice_script), str(args.strip),
|
|
"--rows", "1", "--cols", str(args.frames),
|
|
"--names", ",".join(f"frame-{i}" for i in range(args.frames)),
|
|
"--output-dir", str(frames_dir),
|
|
"--chroma-key", "FF00FF", "--tolerance", str(args.tolerance)])
|
|
|
|
# 2. pack frames into a foot-aligned runtime atlas + manifest
|
|
run([sys.executable, str(TOOLS / "pack_animation_strip.py"),
|
|
"--character", args.character, "--state", args.state,
|
|
"--frames", str(frames_dir), "--output-dir", str(args.output_dir),
|
|
"--canvas", "96", "--fit", "0.86", "--fps", str(args.fps),
|
|
"--resample", "nearest"] + (["--loop"] if args.loop else []))
|
|
|
|
mf = args.output_dir / f"{args.character}_{args.state}_anim.manifest.json"
|
|
data = json.loads(mf.read_text(encoding="utf-8"))
|
|
data["provenance"] = {
|
|
"generator": "image-gen gpt-image-2.5", "task_id": args.task_id,
|
|
"strip": str(args.strip), "identity_anchor": args.identity_anchor,
|
|
"prompt": args.prompt_file,
|
|
"pipeline": "slice_grid.py(--chroma-key) -> pack_animation_strip.py",
|
|
}
|
|
mf.write_text(json.dumps(data, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
|
|
print(f"OK {mf}")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|