Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.
fix(face): a lay leaves a pixel the sprite does not cover as it was — its colour under no coverage too; the comments name the flap, not where it came from
Soohong Kim5d9d0506f01b
diff --git a/sprite_gen/video/face_layer.py b/sprite_gen/video/face_layer.pyindex 101f077..242428c 100644--- a/sprite_gen/video/face_layer.py+++ b/sprite_gen/video/face_layer.py@@ -55,7 +55,7 @@ SKIN_LUMA = 175 # skin is opaque and lighter than thisRAMP = 14 # the weight rises from 0 at the top edge to 1 this far below itMARGIN, FEATHER = 6, 10 # the union grown by MARGIN px is flat; the weight falls to 0 over FEATHER px outside itEYE_GROW = 6-REACH = 12 # a frame's lower face counts this far past the reference's own (a talking jaw drops ~7 px)+REACH = 12 # a frame's lower face counts this far past the reference's own: a dropped jaw, not a handBAND = 30 # the anchor band: this far outside the flat part, above band_bottom, less the eyesSEARCH = 48 # px each way the place is searched; a best on the rim is searched again at twice thisFINE = 3 # px each way the place is read again at each size and tilt@@ -632,15 +632,17 @@ def keep_overlay(body: np.ndarray, keep: np.ndarray) -> tuple[Image.Image, tupledef over(dst: np.ndarray, src: np.ndarray, at: tuple[int, int] = (0, 0)) -> np.ndarray:- """Source-over (straight alpha) of `src` on `dst` with its corner at `at`; float RGBA 0..255, in place."""+ """Source-over (straight alpha) of `src` on `dst` with its corner at `at`; float RGBA 0..255, in place. Where+ `src` is clear, `dst` is left as it is, its colour under no coverage included."""x0, y0 = ath, w = src.shape[:2]d = dst[y0:y0 + h, x0:x0 + w]sa, da = src[..., 3:4] / 255, d[..., 3:4] / 255a = sa + da * (1 - sa)rgb = np.where(a > 0, (src[..., :3] * sa + d[..., :3] * da * (1 - sa)) / np.maximum(a, 1e-6), 0)- d[..., :3] = rgb- d[..., 3:4] = a * 255+ covered = sa > 0+ d[..., :3] = np.where(covered, rgb, d[..., :3])+ d[..., 3:4] = np.where(covered, a * 255, d[..., 3:4])return dstdiff --git a/sprite_gen/video/face_pack.py b/sprite_gen/video/face_pack.pyindex e0e5bf3..ab06bae 100644--- a/sprite_gen/video/face_pack.py+++ b/sprite_gen/video/face_pack.py@@ -54,7 +54,7 @@ VERSION = 1PLAYER_PATH = Path(__file__).with_name("sprite-gen-face-v1.mjs")LIFT_TIE = 0.5 # px: rests this near the nearest lift are told apart by their switch-# The voice -> mouth level rule the player runs (sprite-gen-face-v1.mjs `mouthTrack`): the broadcast mouth's numbers,+# The voice -> mouth level rule the player runs (sprite-gen-face-v1.mjs `mouthTrack`): the flap's numbers,# docs/face-parts.md "The line".MOUTH_RULES = {"closed_under": 0.12, "prominence": 0.05, "min_gap_s": 1 / 12, "open_lo_hi": [2, 5], "surprise_at": 0.85,"lead_frames": 1, "max_step": 3, "normal_top": 6, "surprise_top": 6, "wide_from": 4,diff --git a/sprite_gen/video/sprite-gen-face-v1.mjs b/sprite_gen/video/sprite-gen-face-v1.mjsindex e6a9bdd..fdc75e5 100644--- a/sprite_gen/video/sprite-gen-face-v1.mjs+++ b/sprite_gen/video/sprite-gen-face-v1.mjs@@ -17,9 +17,9 @@ function roundEven(x) {return f % 2 === 0 ? f : f + 1;}-// The broadcast mouth's syllable rule: loudness over 1/48 s windows every 1/96 s, lightly smoothed, against the-// line's loudest; a syllable is a peak over closed_under standing prominence above the lower of its neighbouring-// dips, min_gap_s apart (the louder stays). Each opens open_lo_hi by its loudness (a surprise line's loudest to+// The flap: a mouth opens on every syllable and closes between them. Loudness over 1/48 s windows every 1/96 s,+// lightly smoothed, against the line's loudest; a syllable is a peak over closed_under standing prominence above the+// lower of its neighbouring dips, min_gap_s apart (the louder stays). Each opens open_lo_hi by its loudness (a surprise line's loudest to// surprise_top) on the frame lead_frames ahead of it, half of it the frame before, two fifths the frame after, closed// otherwise; no frame moves more than max_step levels, and a level over normal_top is entered from wide_from.export function mouthTrack(samples, sampleRate, rules, { fps = 24, tags = [] } = {}) {