Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.
docs(face): a body frame's place read again on the ring of skin round its closed mouth (face-parts Anchors, the pack's ring and ring_read, the report's ring_read and ring_move), the CHANGELOG v3.1.0 anchor bullet and Tests line (the head that turns); the module docstring; the writing delegation's wording
Soohong Kim77b5021912be
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 222fb72..427aa5d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -13,14 +13,14 @@ All notable public changes to `sprite-gen` are recorded here. Versions track the- Face request kind `sprite-gen-face-request`, version 1, records face geometry, clip placement, a rest loop, and optional own-mouth spans or timelines.- Face pack kind `sprite-gen-face-pack`, version 1, carries sprites, body cells, anchors, keeps, rules, a report, a copied player, and SHA-256 digests.- The lower-face layer covers the mouth, jaw line, cheeks, and chin. The body's own dark grey and black that reach in from the layer's boundary, such as a headset boom or a choker, the body's own lines in the layer's feather, and a hand that reaches over the face from outside the layer stay above it.-- Each body frame receives a place, size, and tilt anchor. The pack records anchor residuals and corrects outlying readings against neighbouring frames.+- Each body frame receives a place, size, and tilt anchor. The pack records anchor residuals and corrects outlying readings against neighbouring frames. A body frame whose own mouth is closed has its place read again on a ring of skin round the mouth, because a head that turns moves its hair, headset, and cheeks further than its mouth, and a frame whose mouth is open takes the move of the read frames round it. The pack records each frame's move and the frames read on the ring.- Talking frames are assigned to smile or neutral sets by closed-mouth lift. Entry chooses a matching set and rest.- The player `sprite-gen-face-v1.mjs` contains the voice flap, face pick, scene plan, and live canvas playback rules.- A clip's own mouth and sound finish before a requested line starts. The voice and layer then wait together for the first frame whose switch to the chosen rest is within the 1.4 jump line. Layer exit also uses that jump line.- The live player keeps one queue of every `play` and `say` request, in the order the calls are made, and starts each request on the frame after the one before it has ended, so two voices never overlap. A line placed right after a clip with its own mouth is planned together with that clip, the plan `planScene` makes and `face-bake --play` bakes, and its voice and layer start at the plan's `line_start` after the own-mouth span. The queue has no length limit and drops nothing: a request whose sound does not load or decode, or whose line `planScene` refuses, rejects its promise when its turn comes, and the next request goes on.- Bakes check pack digests, changed pixels outside the weight, and composite jumps. Refused bakes retain their frames for inspection.- See [docs/face-parts.md](docs/face-parts.md) for the request, pack, player, commands, and limits.-- **Tests**: `tests/video/test_face_layer.py` uses `tests/talking_face.py` to check smile and neutral sets; clip entry set and rest; own-mouth timelines, including a close during voiced sound and refusal of a missing or never-closing timeline; a head 60 px from its place and tilted 3 degrees; hand, headset boom, and choker keeps; a tongue in the body's own open mouth, joined to a hand by a finger at its corner, covered by the layer; unchanged pixels outside the weight; synthetic cells keeping the key's colour under no coverage; digests and new-folder pack writes; the player flap against its original numpy rule and the pick against the draft Viterbi over every frame; a line waiting for a clip's own mouth and for a frame its layer can come on at; the live player run by node on a fake audio clock, with two lines requested during a greeting's own mouth, three lines requested on the loop, one line requested during the own mouth and one after it, a line whose voice loads late, a line requested right after a clip whose sound loads late, a line whose voice loads only after the greeting's own mouth has ended or only after the greeting has ended, which waits for the greeting to end while the greeting plays to its end with the layer off, a line that plays on the loop when requested right after a clip whose sound fails to load, and a request that fails; loop and post-greeting bakes with greeting frames unchanged byte for byte; and refusal of a changed pack.+- **Tests**: `tests/video/test_face_layer.py` uses `tests/talking_face.py` to check smile and neutral sets; clip entry set and rest; own-mouth timelines, including a close during voiced sound and refusal of a missing or never-closing timeline; a head 60 px from its place and tilted 3 degrees; a head that turns, tilting up to 5 degrees about its mouth while its hair, headset, and cheeks move up to 12 px sideways and its mouth stays where it is, with two of its eleven frames open, whose anchor place is within 1 px of the mouth on closed frames and within 2 px on the two open frames and whose tilt is the band's, below minus 2.5 degrees where the turn is fullest; hand, headset boom, and choker keeps; a tongue in the body's own open mouth, joined to a hand by a finger at its corner, covered by the layer; unchanged pixels outside the weight; synthetic cells keeping the key's colour under no coverage; digests and new-folder pack writes; the player flap against its original numpy rule and the pick against the draft Viterbi over every frame; a line waiting for a clip's own mouth and for a frame its layer can come on at; the live player run by node on a fake audio clock, with two lines requested during a greeting's own mouth, three lines requested on the loop, one line requested during the own mouth and one after it, a line whose voice loads late, a line requested right after a clip whose sound loads late, a line whose voice loads only after the greeting's own mouth has ended or only after the greeting has ended, which waits for the greeting to end while the greeting plays to its end with the layer off, a line that plays on the loop when requested right after a clip whose sound fails to load, and a request that fails; loop and post-greeting bakes with greeting frames unchanged byte for byte; and refusal of a changed pack.## v3.0.0 - Remove rig layer compositiondiff --git a/docs/face-parts.md b/docs/face-parts.mdindex 63159df..3d9915f 100644--- a/docs/face-parts.md+++ b/docs/face-parts.md@@ -99,7 +99,13 @@ The first place match uses masked normalised cross-correlation within 48 px. IfA best match on the grid rim is read again on a grid twice as wide: size 0.92 to 1.08 and tilt -8 to 8 degrees. The place required by a size and tilt can be more than 3 px from the first reading. A 3 by 3 grid is therefore read again around the place, size, and tilt it found until the place stays, for at most 4 passes.-Each anchor number is checked against the median of 5 surrounding frames, wrapping around a loop. A reading farther than three scaled MADs and farther than 0.5 px in place, 0.01 in size, or 0.3 degrees in tilt is replaced by the window medians. Anchors depend only on the reference and the frame. Naming other clips in the request does not change them. `--jobs` runs anchor reading in processes.+Each anchor number is checked against the median of 5 surrounding frames, wrapping around a loop. A reading farther than three scaled MADs and farther than 0.5 px in place, 0.01 in size, or 0.3 degrees in tilt is replaced by the window medians. Anchors depend only on the reference and the clip's own frames. Naming other clips in the request does not change them. `--jobs` runs anchor reading in processes.++The band lies round the reference's own lower face: hair edge, headset, cheeks, and nose. A head that turns moves its hair, headset, and cheeks further than its mouth, so the band's place carries the layer off the mouth. A body frame's place is therefore read again on a ring of skin round the mouth. This applies to body clips only. The talking clip keeps its band anchors, because its jaw moves as it talks and the layer is cut from it.++The ring is the reference's own lower face, its weight, between two ellipses centred on `face.mouth`, with inner half axes 30 by 14 px and outer half axes 60 by 42 px, where the reference is at least 200/255 opaque. The mouth inside the inner ellipse is left out, because a body's closed mouth can smile more or less than the reference's. A body frame is read on the ring when its own mouth, read through its band anchor, is closed. The mouth reading is the one used for talking frames: a mouth 5 px tall or less is closed. Size and tilt stay the band's. Only the place is read again. The frame laid through its band anchor is matched to the ring with masked normalised cross-correlation within 16 px. If the best match sits on the search rim, the search extends to 32 px.++Each read frame's move, ring place less band place, is checked against the moves read among the 5 frames round it, wrapping on a loop, when three or more of them were read. A move farther from their median than three scaled MADs and farther than 0.5 px is a misreading and takes their median. A frame whose mouth is not read closed takes the move of the read frames round it, because an open mouth moves the jaw and the skin round it: linear between the nearest read frame on each side, wrapping on a loop, and before the first or after the last read frame, the nearest one's move. A body clip with no closed frame keeps the band's places.### 2. Weight@@ -153,14 +159,14 @@ The pack has kind `sprite-gen-face-pack` and version `1`. `face-bake` checks eve| Path | What ||---|---|-| `face-pack.json` | FPS, size, rules, requested face geometry, and every talking frame's set, open area, mouth reading, sprite file, and map to the reference. It also contains the two sets and their closed frames, the step matrix, body cells, anchors as maps from the reference, keeps, `own_mouth`, entry and switch tables, own sounds, player, and every file's SHA-256 digest. |+| `face-pack.json` | FPS, size, rules, requested face geometry, and every talking frame's set, open area, mouth reading, sprite file, and map to the reference. It also contains the two sets and their closed frames, the step matrix, body cells, anchors as maps from the reference, each body row's `ring`, every frame's move in px as x and y, and `ring_read`, the frames read on the ring, keeps, `own_mouth`, entry and switch tables, own sounds, player, and every file's SHA-256 digest. || `sprite-gen-face-v1.mjs` | Player copied from the package. || `face/frame-NNNNN.png` | Sprites indexed by talking frame. || `body/<name>/frame-NNNNN.png` | Body cells. || `body/<name>/keep-NNNNN.png` | Parts of a body cell that stay on top, where present. || `body/<name>/sound.wav` | A clip's own sound. || `weight.npy` | Layer weight in reference coordinates. |-| `report.json` | Per clip anchor ranges; band residual median, p90, and maximum with anchor, place only, and no alignment; misread frames; frames using the wide grid or wide search; and hand frames. It also records expression sets, each body's entry, and how many frames can switch on for each rest. |+| `report.json` | Per clip anchor ranges; band residual median, p90, and maximum with anchor, place only, and no alignment; misread frames; frames using the wide grid or wide search; per body clip, `ring_read`, how many frames were read on the ring, and `ring_move`, the median, p90, and maximum length of the move; and hand frames. It also records expression sets, each body's entry, and how many frames can switch on for each rest. |## The playerdiff --git a/sprite_gen/video/face_layer.py b/sprite_gen/video/face_layer.pyindex f56a6b5..fa70390 100644--- a/sprite_gen/video/face_layer.py+++ b/sprite_gen/video/face_layer.py@@ -15,7 +15,10 @@ grown from (`Geometry`).and again within twice that where the best sits on the search's rim; every size and tilt of a grid is then laidthrough it and the place read again near it, the least cost wins, a parabola through its neighbours refines size,tilt and place, and a best on the grid's rim is read again on a grid twice as wide. A reading further from its- window's median than three scaled MADs is a misreading and takes that median (`hampel`).+ window's median than three scaled MADs is a misreading and takes that median (`hampel`). A body frame whose own+ mouth is closed has its place read again on the ring of skin round the mouth (`Band.ring`, `place_on`), its size and+ tilt the band's: a head that turns moves its hair, headset and cheeks further than its mouth. A frame whose mouth is+ open takes the moves of the read frames round it (`on_ring`).- **Weight** (`weight`): the lower faces of the reference and of every frame of every clip, read into the referencethrough their anchors, joined (`union`; a frame adds nothing past `REACH` px of the reference's own lower face, so ahand or sleeve the skin grows into stays out), and holes filled; flat 1 over it grown by `MARGIN`, a cos² feather