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(video-loop): --facing takes gen.facing.FACINGS, the copy removed, read inside the two functions so importing the loop module still loads no gen

Soohong Kim4773690cb849
diff --git a/sprite_gen/video/loop.py b/sprite_gen/video/loop.py
index 0496b0c..7ec5656 100644
--- a/sprite_gen/video/loop.py
+++ b/sprite_gen/video/loop.py
@@ -147,7 +147,6 @@ OVERLAP_WRAP_OFF = "turned off (--overlap-wrap off)"
# warn: a warning line, the loop kept; refuse: the loop fails.
UNFIXED_MODES = ("warn", "refuse")
SIZE_HOLD_MODES = ("auto", "off")
-FACINGS = ("right", "left")
# Where `video-cycle-align` keeps the cut as filmed (sprite_gen/video/align.py). A new cut makes
# the kept one stale, so writing the cycle removes it: an alignment after a re-cut (say, once RIFE
# is installed and the jumps are repaired) reads the new cut, not the old one.
@@ -2334,6 +2333,7 @@ def _cut_loop(
raise SystemExit(f"video-loop: unknown --wrap-blend {wrap_blend!r}; expected one of {', '.join(wrap_blend_mod.MODES)}")
if unfixed not in UNFIXED_MODES:
raise SystemExit(f"video-loop: unknown --unfixed {unfixed!r}; expected one of {', '.join(UNFIXED_MODES)}")
+ from sprite_gen.gen.facing import FACINGS
if facing not in FACINGS:
raise SystemExit(f"video-loop: unknown --facing {facing!r}; expected one of {', '.join(FACINGS)}")
if seam_pop_max is not None and not (math.isfinite(seam_pop_max) and seam_pop_max > 0):
@@ -3265,6 +3265,7 @@ def _seam_pop_max(value: str) -> float | None:
def add_arguments(parser: argparse.ArgumentParser) -> None:
+ from sprite_gen.gen.facing import FACINGS
parser.add_argument("--frames-dir", required=True, type=Path, help="keyed RGBA frames from `sprite-gen video-frames` (…/keyed)")
parser.add_argument("--out-dir", required=True, type=Path)
parser.add_argument("--fps", type=float, default=24.0, help="frame rate of the keyed frames (from the frames report)")
diff --git a/sprite_gen/video/restoration.py b/sprite_gen/video/restoration.py
index 0e13676..bbb40b2 100644
--- a/sprite_gen/video/restoration.py
+++ b/sprite_gen/video/restoration.py
@@ -98,7 +98,7 @@ def key_weight(rgba: Any, key: str) -> Any:
def _jump_facing(origin: Loop) -> str | None:
"""The facing the jump repair read the origin's frames with, as its record says; None when it names none."""
- from sprite_gen.video.loop import FACINGS
+ from sprite_gen.gen.facing import FACINGS
facing = (origin.source_report.get("jump_repair") or {}).get("facing")
return facing if facing in FACINGS else None
diff --git a/tests/gen/test_facing.py b/tests/gen/test_facing.py
index b87f3bd..af8402a 100644
--- a/tests/gen/test_facing.py
+++ b/tests/gen/test_facing.py
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
"""Facing regression contracts; all generation and vision calls are offline."""
+import argparse
import json
import shutil
from pathlib import Path
@@ -47,6 +48,14 @@ def generate(tmp_path, monkeypatch, backend, **kwargs):
refs=[FIXTURES / "left.png"], **{"facing": "right", **kwargs})
+def test_video_loop_takes_the_facings_declared_here():
+ from sprite_gen.video import loop
+
+ parser = argparse.ArgumentParser()
+ loop.add_arguments(parser)
+ assert next(a for a in parser._actions if "--facing" in a.option_strings).choices is facing.FACINGS
+
+
@pytest.mark.parametrize("direction", ["left", "right", "front"])
def test_three_fixture_directions_only_opposite_is_mirrored(tmp_path, monkeypatch, direction):
backend = Backend(direction)