Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.
refactor(logo): the logo matte's region value lettering-box and method value logo-unmix are named once in frames/logo_matte.py as LETTERING_BOX and UNMIX, which choose_key and matte write and gen/logo.py's key-choice wording and see-through refusal read
Soohong Kimcea669f35dfc
diff --git a/sprite_gen/frames/logo_matte.py b/sprite_gen/frames/logo_matte.pyindex 1050441..45cbabe 100644--- a/sprite_gen/frames/logo_matte.py+++ b/sprite_gen/frames/logo_matte.py@@ -69,6 +69,8 @@ from sprite_gen.frames.decontam import _box_sum, _ring_depth, learn_palettefrom sprite_gen.frames.extract import _grow_intoKEYS = KEY_TARGETS+LETTERING_BOX = "lettering-box" # `choose_key`'s region when it read the colours in the title's box+UNMIX = "logo-unmix" # `matte`'s method: the lettering cut off its key here (`native` keeps the image's own alpha)KEY_FAMILY_DIST = 64.0 # CbCr distance from the declared key that a background sample may sit atBORDER_FRACTION = 1 / 64 # the border band read for the key: this share of the short side, at least 4 pxMIN_BORDER_KEY_SHARE = 0.5 # share of that band that must be the key@@ -165,7 +167,7 @@ def choose_key(mood: Image.Image, box: list[float] | None = None,left, top, right, bottom = (int(round(v * n)) for v, n in zip(box, (width, height, width, height)))if right - left >= 8 and bottom - top >= 8:rgb = rgb[max(0, top):bottom, max(0, left):right]- region = "lettering-box"+ region = LETTERING_BOXscores = {}for key in KEYS:excess = key_excess(rgb, key)@@ -434,7 +436,7 @@ def matte(image: Image.Image, *, key: str) -> tuple[Image.Image, dict[str, Any]]out[shown, :3] = np.round(colour[shown]).astype(np.uint8)out[..., 3] = alpha8.astype(np.uint8)stats = {- "method": "logo-unmix",+ "method": UNMIX,"key": key,"background": background,"solid_px": int(solid.sum()),diff --git a/sprite_gen/gen/logo.py b/sprite_gen/gen/logo.pyindex efad1b1..e923eac 100644--- a/sprite_gen/gen/logo.py+++ b/sprite_gen/gen/logo.py@@ -274,7 +274,7 @@ def _reads(check: dict[str, Any]) -> str:def _in_hue(choice: dict[str, Any], *keys: str) -> str:"""Where the key was chosen and how much of it is in each key's hue, with the brief's words for it: "thetitle's box in the mood image is 8.0 % green-hued (the brief names mint)"."""- where = "the title's box in the mood image" if choice["region"] == "lettering-box" else "the mood image"+ where = "the title's box in the mood image" if choice["region"] == logo_matte.LETTERING_BOX else "the mood image"shares = []for key in keys:score = choice["scores"][key]@@ -515,7 +515,7 @@ def _cut(files: dict[str, Path], report: dict[str, Any], work: Path, backend, raf"are drawn in the {key} key's colour, run again with --chroma-key {other}")_publish(logo_matte.preview(logo), files["logo.preview.png"])report["files"]["preview"] = str(files["logo.preview.png"])- if inside["wide"] and stats["method"] == "logo-unmix":+ if inside["wide"] and stats["method"] == logo_matte.UNMIX:_publish(logo, files["logo.rejected.png"])report["files"]["rejected"] = str(files["logo.rejected.png"])again = f" --mood {files['mood.png']}" if files["mood.png"].is_file() else ""