Skip to content

Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.

refactor(facing): video-canvas --facing and a lateral view's check read gen.facing.FACINGS, not a spelt copy and the handed sides

Soohong Kim91ec1d73d6d3
diff --git a/sprite_gen/gen/handedness.py b/sprite_gen/gen/handedness.py
index babcfa7..ff26a19 100644
--- a/sprite_gen/gen/handedness.py
+++ b/sprite_gen/gen/handedness.py
@@ -36,6 +36,8 @@ from __future__ import annotations
from dataclasses import dataclass
+from .facing import FACINGS
+
VIEWS = ("side", "front", "back", "front_diagonal", "back_diagonal")
# Views turned toward a side of the picture: each is drawn facing right or left.
LATERAL_VIEWS = frozenset({"side", "front_diagonal", "back_diagonal"})
@@ -94,7 +96,7 @@ def parse_all(specs: list[str] | None) -> list[Handed]:
def validate_view(view: str, facing: str | None) -> None:
if view not in VIEWS:
raise SystemExit(f"handedness: view must be one of {', '.join(VIEWS)}, got {view!r}")
- if view in LATERAL_VIEWS and facing not in SIDES:
+ if view in LATERAL_VIEWS and facing not in FACINGS:
raise SystemExit(f"handedness: the {view} view is turned right or left; say which (facing right|left)")
diff --git a/sprite_gen/video/canvas.py b/sprite_gen/video/canvas.py
index 324a7c0..4291d6a 100644
--- a/sprite_gen/video/canvas.py
+++ b/sprite_gen/video/canvas.py
@@ -49,6 +49,7 @@ from PIL import Image
from sprite_gen._deps import np
from sprite_gen.frames.cutout import KEY_TARGETS, extract_route
from sprite_gen.frames.extract import is_border_key_candidate
+from sprite_gen.gen.facing import FACINGS
from sprite_gen.gen.handedness import VIEWS
from sprite_gen.spec.runio import atomic_write_text
from sprite_gen.util.console import utf8_streams
@@ -467,7 +468,7 @@ def add_arguments(parser: argparse.ArgumentParser) -> None:
parser.add_argument("--out", required=True, type=Path, help="padded PNG to feed `sprite-gen video`")
parser.add_argument("--state", help="motion state name (jump/attack/projectile/... — selects the canvas row)")
parser.add_argument("--shape", choices=SHAPES, help="override the state's canvas shape")
- parser.add_argument("--facing", choices=("right", "left"), default="right", help="which way the subject faces (wide canvases add room in front)")
+ parser.add_argument("--facing", choices=FACINGS, default="right", help="which way the subject faces (wide canvases add room in front)")
parser.add_argument("--headroom", type=float, help="tall/wide: empty fraction of canvas height above the still (default from the profile)")
parser.add_argument("--lead", type=float, help="wide: empty fraction in front of the subject (default from the profile)")
parser.add_argument("--trail", type=float, help="wide: empty fraction behind the subject, for a weapon drawn back (default from the profile)")