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(chroma): the key colours and key names come from cutout.KEY_TARGETS and its MAGENTA and GREEN beside it, gen's KEYS a view built from that table, the logo matte's KEYS that table itself and slice-sheet keying by it, cutout's own --key set named KEYS, video-set's --key read from canvas.KEYS and video-prompt's keys from the prompt sentence's table, with every key-name branch, default and default key record written from those names

Soohong Kim40be40228407
diff --git a/sprite_gen/frames/cutout.py b/sprite_gen/frames/cutout.py
index 4c611f1..83f0c57 100644
--- a/sprite_gen/frames/cutout.py
+++ b/sprite_gen/frames/cutout.py
@@ -51,12 +51,16 @@ ERODE_DEFAULT = 1.0 # soft-erode radius (fractional part shaves the last ring t
CHROMA_TOLERANCE = 26 # flood-fill background membership: max per-channel diff from the estimated bg colour
CORNER_MIN_BRIGHT = 225 # a corner pixel must be at least this bright (min channel) to seed the bg colour estimate
-# Key colours reused from the generation contract (chroma.py KEYS). The extract
-# engine keys these out; cutout only detects them and routes.
+# The key colours, the one table: gen's `chroma.KEYS` is built from it, and the logo matte and
+# slice-sheet key by it. The extract engine keys these out; cutout only detects them and routes.
+MAGENTA, GREEN = "magenta", "green"
KEY_TARGETS: dict[str, tuple[int, int, int]] = {
- "magenta": (255, 0, 255),
- "green": (0, 255, 0),
+ MAGENTA: (255, 0, 255),
+ GREEN: (0, 255, 0),
}
+# `--key`: auto reads the corners; white is the position matte; a key colour is the chroma engine;
+# measured is the measured matte.
+KEYS = ("auto", "white", *KEY_TARGETS, "measured")
# extract.remove_chroma_background params — the extract CLI defaults (SSoT: extract.py argparse).
_EXTRACT_KEY_THRESHOLD = 96.0
_EXTRACT_FRINGE_THRESHOLD = 180.0
@@ -433,7 +437,7 @@ def cutout(
located, nothing was made transparent, or any transparent pixel keeps non-zero RGB
(No Silent Fallback).
"""
- if key not in ("auto", "white", "magenta", "green", "measured"):
+ if key not in KEYS:
raise SystemExit(f"cutout: unknown key {key!r}; expected one of auto|white|magenta|green|measured")
if decontam not in ("off", "auto", "palette"):
raise SystemExit(f"cutout: unknown decontam {decontam!r}; expected off|auto|palette")
@@ -446,7 +450,7 @@ def cutout(
route = "measured"
if route == "measured":
result, route_stats = _measured_route(image, decontam, key)
- elif route in ("magenta", "green"):
+ elif route in KEY_TARGETS:
result, route_stats = extract_route(image, route, spill_max_fraction=spill_max_fraction,
spill_min_tint=spill_min_tint, spill_require_hue=spill_require_hue,
decontam=decontam, decontam_fit=decontam_fit,
@@ -514,7 +518,7 @@ def add_arguments(p: Any) -> None:
p.add_argument("--out", type=Path, help="output PNG (default: <input>_cutout.png)")
p.add_argument(
"--key",
- choices=["auto", "white", "magenta", "green", "measured"],
+ choices=KEYS,
default="auto",
help="background type; auto detects from corners (white→matte, magenta/green→extract engine, any other "
"colour→measured matte); a magenta/green background the engine does not recognise is measured too",
diff --git a/sprite_gen/frames/logo_matte.py b/sprite_gen/frames/logo_matte.py
index e5e833b..1050441 100644
--- a/sprite_gen/frames/logo_matte.py
+++ b/sprite_gen/frames/logo_matte.py
@@ -64,10 +64,11 @@ from typing import Any
from PIL import Image
from sprite_gen._deps import np
+from sprite_gen.frames.cutout import KEY_TARGETS, MAGENTA
from sprite_gen.frames.decontam import _box_sum, _ring_depth, learn_palette
from sprite_gen.frames.extract import _grow_into
-KEYS: dict[str, tuple[int, int, int]] = {"magenta": (255, 0, 255), "green": (0, 255, 0)}
+KEYS = KEY_TARGETS
KEY_FAMILY_DIST = 64.0 # CbCr distance from the declared key that a background sample may sit at
BORDER_FRACTION = 1 / 64 # the border band read for the key: this share of the short side, at least 4 px
MIN_BORDER_KEY_SHARE = 0.5 # share of that band that must be the key
@@ -125,7 +126,7 @@ def _cbcr(rgb: np.ndarray) -> tuple[np.ndarray, np.ndarray]:
def key_excess(rgb: np.ndarray, key: str) -> np.ndarray:
"""How much of the key's hue a colour carries (`extract._key_excess_field`)."""
- if key == "magenta":
+ if key == MAGENTA:
return np.minimum(rgb[..., 0], rgb[..., 2]) - rgb[..., 1]
return rgb[..., 1] - np.maximum(rgb[..., 0], rgb[..., 2])
@@ -178,7 +179,7 @@ def choose_key(mood: Image.Image, box: list[float] | None = None,
"score": round(float(hold.mean()) - CHOICE_HUED_WEIGHT * hued, 4), "named": words,
"clash_at_pct": clash_at, "clashes": hued * 100 >= clash_at}
left = [key for key in KEYS if not scores[key]["clashes"]]
- key = max(left, key=lambda k: (scores[k]["score"], k == "magenta")) if left else None
+ key = max(left, key=lambda k: (scores[k]["score"], k == MAGENTA)) if left else None
return {"key": key, "region": region, "scores": scores}
diff --git a/sprite_gen/frames/slice_sheet.py b/sprite_gen/frames/slice_sheet.py
index 5b3ad3c..3d6ff5e 100644
--- a/sprite_gen/frames/slice_sheet.py
+++ b/sprite_gen/frames/slice_sheet.py
@@ -49,17 +49,13 @@ from PIL import Image
from sprite_gen._deps import np
from sprite_gen.frames.alpha_floor import clear_haze
+from sprite_gen.frames.cutout import KEY_TARGETS
from sprite_gen.frames.extract import remove_chroma_background
from sprite_gen.spec.runio import atomic_write_text
from sprite_gen.util.hexcolor import parse_hex
from sprite_gen.util.resample import resize_cell
from sprite_gen.util.console import utf8_streams
-CHROMA_KEYS = {
- "magenta": (255, 0, 255),
- "green": (0, 255, 0),
-}
-
DEFAULT_KEY_THRESHOLD = 96.0
DEFAULT_FRINGE_KEY_THRESHOLD = 180.0
DEFAULT_FRINGE_DELTA = 18.0
@@ -84,8 +80,8 @@ def parse_chroma_key(value: str) -> tuple[int, int, int] | None:
name = value.strip().lower()
if name == "none":
return None
- if name in CHROMA_KEYS:
- return CHROMA_KEYS[name]
+ if name in KEY_TARGETS:
+ return KEY_TARGETS[name]
try:
return parse_hex(name)
except ValueError:
diff --git a/sprite_gen/frames/unpack_atlas.py b/sprite_gen/frames/unpack_atlas.py
index b4a038c..62cd61d 100644
--- a/sprite_gen/frames/unpack_atlas.py
+++ b/sprite_gen/frames/unpack_atlas.py
@@ -48,7 +48,9 @@ from sprite_gen.spec.runio import (
relative_posix,
)
from sprite_gen.frames.segment import mask_components
+from sprite_gen.frames.cutout import KEY_TARGETS, MAGENTA
from sprite_gen.util.console import utf8_streams
+from sprite_gen.util.hexcolor import format_hex
ALPHA_THRESHOLD = 16 # a pixel counts as content above this alpha
MIN_GUTTER = 1 # a fully-empty line of >= this many px separates frames
@@ -249,7 +251,7 @@ def write_run(
"engine": "component-row",
"character": {"id": run_dir.name, "description": f"unpacked from atlas ({layout_source})"},
"cell": {"shape": "rect" if cell_w != cell_h else "square", "width": cell_w, "height": cell_h, "size": cell_w, "safe_margin": 0},
- "chroma_key": provenance.get("chroma_key", {"name": "magenta", "hex": "#FF00FF", "rgb": [255, 0, 255]}),
+ "chroma_key": provenance.get("chroma_key", {"name": MAGENTA, "hex": format_hex(KEY_TARGETS[MAGENTA]), "rgb": list(KEY_TARGETS[MAGENTA])}),
"states": request_states,
}
atomic_write_text(out_dir / "sprite-request.json", json.dumps(request, ensure_ascii=False, indent=2) + "\n")
@@ -367,7 +369,7 @@ def import_png_groups(out_dir: Path, groups: list[dict[str, Any]], iso: dict[str
"engine": "component-row",
"character": {"id": run_dir.name, "description": f"imported PNG set from {first_dir}"},
"cell": {"shape": "square" if cell_w == cell_h else "rect", "width": cell_w, "height": cell_h, "size": cell_w, "safe_margin": 0},
- "chroma_key": {"name": "magenta", "hex": "#FF00FF", "rgb": [255, 0, 255]},
+ "chroma_key": {"name": MAGENTA, "hex": format_hex(KEY_TARGETS[MAGENTA]), "rgb": list(KEY_TARGETS[MAGENTA])},
"states": request_states,
}
if iso:
diff --git a/sprite_gen/gen/__init__.py b/sprite_gen/gen/__init__.py
index 1242a79..2bfc803 100644
--- a/sprite_gen/gen/__init__.py
+++ b/sprite_gen/gen/__init__.py
@@ -46,6 +46,7 @@ import tempfile
from pathlib import Path
from typing import Any, Callable
+from sprite_gen.frames.cutout import MAGENTA
from sprite_gen.spec.runio import atomic_write_text
from sprite_gen.util.cli_kwargs import namespace_from_kwargs
from sprite_gen.video import body_plan as body_mod
@@ -444,7 +445,7 @@ def generate_image(
resolution: str | None = None,
transparent: bool = False,
alpha_mode: str = ALPHA_MODE_AUTO,
- chroma_key: str = "magenta",
+ chroma_key: str = MAGENTA,
white_check: Path | None = None,
trim_alpha: bool = False,
keep_session: bool = False,
@@ -831,7 +832,7 @@ def add_arguments(parser: argparse.ArgumentParser) -> None:
"colours after the matte. off (default) publishes the matte as it is; auto runs it where it "
"applies (chroma strategy, a subject interior); palette demands it",
)
- parser.add_argument("--chroma-key", choices=sorted(chroma_mod.KEYS), default="magenta")
+ parser.add_argument("--chroma-key", choices=sorted(chroma_mod.KEYS), default=MAGENTA)
parser.add_argument("--facing", choices=(*facing_mod.FACINGS, "preserve"), default="preserve", help="with --ref: required direction; preserve (default) leaves prompt and pixels unchanged")
parser.add_argument("--facing-fix", choices=facing_mod.FIXES, default="none", help="with --ref and --facing: record only (none, default), or opt into mirror / one regen")
parser.add_argument("--direction", choices=handed_mod.VIEWS, help="draw the still at this sprite view: the engine's view sentence is added to the prompt (side and diagonal views also take --facing right|left)")
diff --git a/sprite_gen/gen/chroma.py b/sprite_gen/gen/chroma.py
index b0351dc..8a4ed3f 100644
--- a/sprite_gen/gen/chroma.py
+++ b/sprite_gen/gen/chroma.py
@@ -23,14 +23,12 @@ from typing import Any
from PIL import Image
from sprite_gen._deps import np
+from sprite_gen.frames.cutout import KEY_TARGETS, MAGENTA
from sprite_gen.frames.extract import remove_chroma_background_ycbcr
from sprite_gen.spec.runio import atomic_save_image
-KEYS: dict[str, dict[str, tuple[int, int, int]]] = {
- "magenta": {"target": (255, 0, 255)},
- "green": {"target": (0, 255, 0)},
-}
+KEYS: dict[str, dict[str, tuple[int, int, int]]] = {name: {"target": rgb} for name, rgb in KEY_TARGETS.items()}
# The sentence that asks a model for a key background, per key. A still redrawn from a
# reference for a clip (`video.batch.walk_start_prompt`) and a ref run whose transparency
@@ -193,7 +191,7 @@ def key_transparent(
input_path: Path,
out_path: Path,
*,
- key: str = "magenta",
+ key: str = MAGENTA,
white_check: Path | None = None,
decontam: str = "off",
) -> dict[str, Any]:
diff --git a/sprite_gen/gen/logo.py b/sprite_gen/gen/logo.py
index 43a4d19..efad1b1 100644
--- a/sprite_gen/gen/logo.py
+++ b/sprite_gen/gen/logo.py
@@ -40,6 +40,7 @@ from PIL import Image
import sprite_gen.gen as gen_pkg
from sprite_gen.frames import logo_matte
+from sprite_gen.frames.cutout import GREEN, MAGENTA
from sprite_gen.spec.runio import atomic_save_image, atomic_write_text, new_stage, refuse_overlap, same_folder
from sprite_gen.util.cli_kwargs import namespace_from_kwargs
@@ -107,7 +108,7 @@ def mood_prompt(text: str, *, subtitle: str | None = None, style: str | None = N
def lettering_prompt(text: str, *, subtitle: str | None = None, composition: str = "title-screen",
- language: str | None = None, key: str = "magenta") -> str:
+ language: str | None = None, key: str = MAGENTA) -> str:
"""Step 2: only the lettering of the attached mood image, as it is drawn there, on a flat key."""
picture = COMPOSITIONS[composition]["picture"]
words = _quoted(text) + (f" and the subtitle {_quoted(subtitle)}" if subtitle else "")
@@ -467,7 +468,7 @@ def _draw_lettering(provider: str, backend, report: dict[str, Any], files: dict[
report["steps"]["key"] = {**choice, "key": key, "source": "auto" if chroma_key == "auto" else "explicit"}
if key is None:
raise _Refusal("key", f"logo: the title's colours carry both keys' hues — "
- f"{_in_hue(choice, 'green', 'magenta')}; a letter in the key's hue comes out see-through on "
+ f"{_in_hue(choice, GREEN, MAGENTA)}; a letter in the key's hue comes out see-through on "
"it, and there is no third key. Restyle the title without one of them, or name the key to lose "
f"with --chroma-key (--mood {files['mood.png']} skips the mood image; the lettering was not "
"bought)")
@@ -508,7 +509,7 @@ def _cut(files: dict[str, Path], report: dict[str, Any], work: Path, backend, ra
inside = logo_matte.see_through_inside(logo)
report["logo"] = {"size": list(logo.size), "alpha": cover, "key_hue_left": logo_matte.key_hue_left(logo, key),
"see_through_inside": inside}
- other = "green" if key == "magenta" else "magenta"
+ other = GREEN if key == MAGENTA else MAGENTA
if cover["visible_opaque_share"] < logo_matte.SEE_THROUGH_WARN_SHARE:
warn(f"only {cover['visible_opaque_share'] * 100:.0f}% of the visible lettering is opaque; if the letters "
f"are drawn in the {key} key's colour, run again with --chroma-key {other}")
diff --git a/sprite_gen/gen/prepare.py b/sprite_gen/gen/prepare.py
index 129bca7..594370b 100644
--- a/sprite_gen/gen/prepare.py
+++ b/sprite_gen/gen/prepare.py
@@ -22,6 +22,7 @@ from PIL import Image, ImageDraw
from sprite_gen.util.cli_kwargs import namespace_from_kwargs
from sprite_gen.util.hexcolor import format_hex, parse_hex
from sprite_gen.curate.anchor import anchor_ref_rel
+from sprite_gen.frames.cutout import GREEN, KEY_TARGETS, MAGENTA
from sprite_gen.frames.extract import color_distance
from sprite_gen.spec.layout import TAXONOMY, guide_rel, prompt_rel, raw_rel
from sprite_gen.spec.subject import SUBJECTS
@@ -187,8 +188,8 @@ DEFAULT_ACTIONS_ANY_BODY = {
}
CHROMA_CANDIDATES = [
- ("magenta", "#FF00FF"),
- ("green", "#00FF00"),
+ (MAGENTA, format_hex(KEY_TARGETS[MAGENTA])),
+ (GREEN, format_hex(KEY_TARGETS[GREEN])),
("cyan", "#00FFFF"),
("blue", "#004DFF"),
]
@@ -417,7 +418,7 @@ def choose_chroma_key(reference: Path | None, requested: str) -> dict[str, Any]:
if background["mode"] == "heterogeneous":
print(f"WARNING: chroma_key auto: {background['note']}", file=sys.stderr)
if not pixels:
- rgb = parse_hex_color("#FF00FF")
+ rgb = KEY_TARGETS[MAGENTA]
reason = (
"no base reference to sample"
if background["mode"] == "absent"
@@ -426,8 +427,8 @@ def choose_chroma_key(reference: Path | None, requested: str) -> dict[str, Any]:
if background["mode"] != "absent":
print(f"WARNING: chroma_key auto: {reason}; defaulting to magenta", file=sys.stderr)
return {
- "name": "magenta",
- "hex": "#FF00FF",
+ "name": MAGENTA,
+ "hex": format_hex(rgb),
"rgb": list(rgb),
"selection": "fallback",
"background": background,
diff --git a/sprite_gen/serve/serve_curation.py b/sprite_gen/serve/serve_curation.py
index 2e30138..128d5b6 100644
--- a/sprite_gen/serve/serve_curation.py
+++ b/sprite_gen/serve/serve_curation.py
@@ -177,7 +177,8 @@ def _base_grid_response(run_dir: Path, base_path: Path) -> dict:
if cached is not None:
return cached
request = load_request(run_dir)
- chroma = tuple(request.get("chroma_key", {}).get("rgb") or (255, 0, 255))
+ from sprite_gen.frames.cutout import KEY_TARGETS, MAGENTA
+ chroma = tuple(request.get("chroma_key", {}).get("rgb") or KEY_TARGETS[MAGENTA])
from sprite_gen.frames.extract import (_grid_edges, detect_pixel_grid,
remove_chroma_background_ycbcr, solid_alpha_bbox)
with Image.open(base_path) as opened:
@@ -1399,7 +1400,8 @@ class CurationHandler(BaseHTTPRequestHandler):
self._send_json({"error": f"unknown ops space: {space}"}, 400)
return
request = load_request(self.run_dir)
- chroma = tuple(request.get("chroma_key", {}).get("rgb") or (255, 0, 255))
+ from sprite_gen.frames.cutout import KEY_TARGETS, MAGENTA
+ chroma = tuple(request.get("chroma_key", {}).get("rgb") or KEY_TARGETS[MAGENTA])
backup = base_path.with_name(base_path.name + ".orig")
if not backup.exists():
import shutil as _shutil
diff --git a/sprite_gen/video/batch.py b/sprite_gen/video/batch.py
index 5e040d9..cce600f 100644
--- a/sprite_gen/video/batch.py
+++ b/sprite_gen/video/batch.py
@@ -1301,7 +1301,7 @@ def add_arguments(parser: argparse.ArgumentParser) -> None:
parser.add_argument("--character", help="short subject phrase used in the prompts (e.g. 'The armored knight')")
parser.add_argument("--duration", type=int, default=None, help=f"seconds per clip for every state (default: {DEFAULT_DURATION_SECONDS}, attack {STATE_DURATION_SECONDS['attack']}); a repeating motion holds enough cycles at 3 s and a longer clip only costs more (2026-09-18)")
parser.add_argument("--resolution", default="720p")
- parser.add_argument("--key", choices=("auto", "green", "magenta", "white"), default="auto")
+ parser.add_argument("--key", choices=canvas_mod.KEYS, default="auto")
parser.add_argument("--concurrency", type=int, default=3, help="parallel clip generations (starts are staggered regardless)")
parser.add_argument("--start-gap", type=float, default=START_GAP_SECONDS, help="seconds between clip request starts")
parser.add_argument("--shape", choices=canvas_mod.SHAPES, help="force one canvas shape for every state (e.g. wide for a costume or arms that leave a 1:1 frame; square keeps a side walk or run square whatever room its still leaves)")
diff --git a/sprite_gen/video/clip_prompt.py b/sprite_gen/video/clip_prompt.py
index df55baf..c4408e5 100644
--- a/sprite_gen/video/clip_prompt.py
+++ b/sprite_gen/video/clip_prompt.py
@@ -25,6 +25,8 @@ import sys
from pathlib import Path
from typing import Any
+from sprite_gen.frames.cutout import GREEN
+from sprite_gen.gen.chroma import KEY_BACKGROUND_TEXT
from sprite_gen.gen.facing import FACINGS
from sprite_gen.gen import handedness as handed_mod
from sprite_gen.gen.handedness import Handed
@@ -35,12 +37,12 @@ from sprite_gen.video.body_plan import Body
from sprite_gen.util.console import utf8_streams
DEFAULT_MODEL = "grok-imagine-video-1.5"
-START_STILL_KEYS = ("green", "magenta")
+START_STILL_KEYS = tuple(KEY_BACKGROUND_TEXT)
def plan_prompt(*, direction: str, state: str, facing: str = "right", character: str | None = None,
motion: str | None = None, model: str = DEFAULT_MODEL, last_frame: bool = True,
- unpinned: bool = False, duration: int | None = None, key: str = "green",
+ unpinned: bool = False, duration: int | None = None, key: str = GREEN,
handed: list[Handed] | None = None, body_plan: list[Body] | None = None, end_frame: Path | None = None,
play: str | None = None) -> dict[str, Any]:
"""The prompt `video-set` would send for (direction, state), and how its clip is to be cut. `handed`
@@ -141,7 +143,7 @@ def add_arguments(parser: argparse.ArgumentParser) -> None:
parser.add_argument("--end-frame", type=Path, help="non-loop terminal-pose canvas to pin instead of returning to the starting image")
parser.add_argument("--no-last-frame", action="store_true", help="the clip source cannot pin an end frame (ZCRE's grok-imagine-video-1.5): states filmed pinned are refused")
parser.add_argument("--unpinned", action="store_true", help="with --no-last-frame: film a pinned state without the pin, with a warning, instead of refusing it")
- parser.add_argument("--key", choices=START_STILL_KEYS, default="green", help="the still's chroma key, for a front or back walk's mid-step redraw sentence (default green)")
+ parser.add_argument("--key", choices=START_STILL_KEYS, default=GREEN, help="the still's chroma key, for a front or back walk's mid-step redraw sentence (default green)")
parser.add_argument("--json", action="store_true", help="print the whole record (prompt, duration, end-frame pin, loop cut, commands) instead of the prompt alone")
@@ -152,7 +154,7 @@ def run(**kwargs: object) -> int:
character=kwargs.get("character"), motion=kwargs.get("motion"), # type: ignore[arg-type]
model=str(kwargs.get("model") or DEFAULT_MODEL), last_frame=not kwargs.get("no_last_frame"),
unpinned=bool(kwargs.get("unpinned")), duration=(int(kwargs["duration"]) if kwargs.get("duration") else None), # type: ignore[arg-type]
- key=str(kwargs.get("key") or "green"),
+ key=str(kwargs.get("key") or GREEN),
handed=handed_mod.parse_all(list(kwargs.get("handed") or [])) or None, # type: ignore[arg-type]
body_plan=body_mod.parse_all(list(kwargs.get("body_plan") or [])) or None, # type: ignore[arg-type]
)
diff --git a/sprite_gen/video/restoration.py b/sprite_gen/video/restoration.py
index 61e7b67..927c3b1 100644
--- a/sprite_gen/video/restoration.py
+++ b/sprite_gen/video/restoration.py
@@ -107,7 +107,7 @@ def _source_key(src: source.Source) -> str | None:
key = src.record["recipe"].get("key")
if key == "auto":
key = (src.record["recipe"].get("spill") or {}).get("key")
- return key if key in ("green", "magenta") else None
+ return key if key in KEY_TARGETS else None
def source_key_weight(cropped: Image.Image, size: tuple[int, int], key: str) -> Any:
diff --git a/tests/frames/test_cutout.py b/tests/frames/test_cutout.py
index 636a60c..3aa9889 100644
--- a/tests/frames/test_cutout.py
+++ b/tests/frames/test_cutout.py
@@ -120,3 +120,44 @@ def test_unknown_key_raises(tmp_path: Path) -> None:
_make_icon().save(src)
with pytest.raises(SystemExit):
cutout(src, tmp_path / "o.png", key="blue")
+
+
+# --- the key colours and key names: one declaration each ------------------------
+
+def _key_choices(verb: str) -> object:
+ import argparse
+
+ verbs = next(a for a in cli._build_parser()._actions if isinstance(a, argparse._SubParsersAction)).choices
+ return next(a for a in verbs[verb]._actions if "--key" in a.option_strings).choices
+
+
[email protected]("name", ["magenta", "green"])
+def test_every_key_table_is_the_one_table(name: str) -> None:
+ """The logo matte, slice-sheet and gen key a colour by `cutout.KEY_TARGETS`' own tuple, not a copy of it."""
+ from sprite_gen.frames import cutout as cutout_mod, logo_matte, slice_sheet
+ from sprite_gen.gen import chroma
+
+ assert logo_matte.KEYS is cutout_mod.KEY_TARGETS
+ assert slice_sheet.parse_chroma_key(name) is cutout_mod.KEY_TARGETS[name]
+ assert chroma.KEYS[name]["target"] is cutout_mod.KEY_TARGETS[name]
+
+
+def test_the_tables_kept_by_key_name_name_the_keys() -> None:
+ from sprite_gen.frames import cutout as cutout_mod
+ from sprite_gen.gen import chroma, logo
+
+ assert set(chroma.KEY_BACKGROUND_TEXT) == set(logo.KEY_COLOUR_WORDS) == set(cutout_mod.KEY_TARGETS)
+
+
+def test_every_video_key_flag_reads_its_declaration() -> None:
+ """video-canvas and video-set take `canvas.KEYS`, video-prompt the keys its redraw sentence is written for."""
+ from sprite_gen.video import canvas, clip_prompt
+
+ declared = {"video-canvas": canvas.KEYS, "video-set": canvas.KEYS, "video-prompt": clip_prompt.START_STILL_KEYS}
+ assert [verb for verb, keys in declared.items() if _key_choices(verb) is not keys] == []
+
+
+def test_the_cutout_key_flag_reads_cutout_keys() -> None:
+ from sprite_gen.frames import cutout as cutout_mod
+
+ assert _key_choices("cutout") is cutout_mod.KEYS