Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.
fix(video): a body that is not one person stands square from behind and walks or runs from behind without turning
Soohong Kim430240c2d20f
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 836304e..33b16de 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -2,6 +2,11 @@All notable public changes to `sprite-gen` are recorded here. Versions track the `version:` field in `SKILL.md` and `pyproject.toml`.+## Unreleased (v2.38.0)++- **Output change: a body that is not one person stands square from behind, and walks or runs from behind without turning.** With `--body-plan` (a quadruped, a body without legs, a scene of several figures), the back still's view sentence (`STILL_VIEW_TEXT_ANY_BODY["back"]`, read by `still_view_text` and `gen --direction back`) now also says the body is square to the viewer and symmetric left to right: the back of the head centred above the body, neither side showing more than the other, any tail rising from the middle. A walk or run seen from behind says, after what the body stands on, that it stays level, square and straight the whole time, never turning or angling to either side so neither side comes into view, and does not sway from side to side, any tail held raised where it is with only its tip swaying (`BACK_GAIT_TEXT_ANY_BODY`; for a scene, every figure), in the built-in sentence and after a caller's `--motion` alike. A four-legged back still drawn from a three-quarter reference had come out turned, its head to one side and its tail to the other, and the walk filmed from it turned further until a flank showed and swayed; with both sentences the still was drawn straight behind and the walk held square. A person's prompts are unchanged, byte for byte; the front, side and diagonal views and every other state are unchanged.+- **`tests/video/test_body_plan.py`** holds the horse's back still and back walk as written, and checks that the square sentence comes after what the body stands on in a walk or run seen from behind, for a quadruped, a body without legs and a scene, with the built-in sentence and a caller's paragraph, and in no other view or state and in no person's prompt.+## v2.37.0 - A lead-in or a stray speck no longer costs a walk its loop; follow-through reads the body and moves each part on its own gain; a diagonal still turns its body; the same cut on every machinev2.36.0 was cut but not published on its own: its release was held for a cut that differed by machine, fixed here. This release is the first to carry its changes too — see `v2.36.0` in [CHANGELOG.md](https://github.com/aldegad/sprite-gen/blob/main/CHANGELOG.md).diff --git a/docs/prompt-assembly.md b/docs/prompt-assembly.mdindex c7ee0cb..0d099e3 100644--- a/docs/prompt-assembly.md+++ b/docs/prompt-assembly.md@@ -62,7 +62,8 @@ the head, a tail, the body, a leg, a shoulder — gets only where it is, and nobiped, nothing changes. A quadruped, a body without legs or a scene of several figures has the idle,the attack and its hold (`HOLD_TEXT`, after a caller's `--motion` too), the Lite walk sentences, themid-step redraw and the still's view sentence (`gen --direction --body-plan`) said without the parts it-lacks, and what it stands on said after the motion paragraph or at the end of the view sentence+lacks, and what it stands on said after the motion paragraph or at the end of the view sentence;+a walk or run seen from behind then says the body stays square and does not sway (`BACK_GAIT_TEXT_ANY_BODY`)([body plan](video-pipeline.md#a-body-that-is-not-a-person----body-plan)). The sheet rows `prepare--body-plan` writes take the same plan([sheet rows](video-pipeline.md#the-sheet-rows--prepare---body-plan)).diff --git a/docs/video-pipeline.md b/docs/video-pipeline.mdindex cef49be..9a330a7 100644--- a/docs/video-pipeline.md+++ b/docs/video-pipeline.md@@ -299,11 +299,12 @@ biped, keeps every prompt byte for byte. Any other body gets:| Sentence | for a body that is not one biped ||---|---|| after the motion sentence (or the caller's `--motion`) | what it stands on (`body_plan.text`): "It stays on all four legs, as in the image, and never rises onto its hind legs." / "It has no legs, as in the image, and never grows legs or feet." / "Each figure keeps the body it has in the image: the man on two legs; the horse on all four legs, never rising onto its hind legs." |+| a walk or run seen from behind | after what it stands on, `BACK_GAIT_TEXT_ANY_BODY`: "Its body stays level, square to the viewer and straight the whole time, never turning or angling to either side, so neither side of it comes into view, and it does not sway from side to side; any tail stays raised where it is in the image, only its tip swaying a little." (a scene: every figure). A four-legged back walk turned until a flank showed and swayed; with this and the still drawn square (below) it held square, and without the tail clause its tail swung on its own beat and the walk found no loop (2.38.0). A person's back walk is unchanged || idle | `IDLE_TEXT_ANY_BODY`: the same stillness, standing or resting as in the image, no feet counted, no chest, shoulders or arms || attack | `ATTACK_TEXT_ANY_BODY`: the same timed strike "with what it is already holding, or with its own body if it holds nothing", then `HOLD_TEXT_ANY_BODY["attack"]`: anything it holds stays held the same way, a part the strike does not use stays where it is drawn, no hand counted. Which part strikes (a bite, a head-butt, a forefoot) is not guessed: a caller who knows says it with `--motion`, which gets `HOLD_TEXT_ANY_BODY` after it || Lite walk calm | `LITE_WALK_TEXT_LEGGED` (no arm swing; never trotting or galloping) or, with a figure without legs, `LITE_WALK_TEXT_LEGLESS` (no steps or feet) || Lite back-diagonal head hold | `LITE_HEAD_TEXT_ANY_BODY`: what moves is what it moves on and its loose ends (a tail, a mane, hair) |-| the still's view sentence (`still_view_text`, `gen --direction`) | `STILL_VIEW_TEXT_ANY_BODY` for the front, back and diagonal views (where the body and head point; no feet, chest, hips, shoulders or shoes), the side view's `VIEW_TEXT` as it is, each ending in what it stands on (`body_plan.still_text`): ", standing on all four legs, not rearing onto its hind legs" / ", resting on its base without legs, never growing any" / ", each figure with the body it has: the man on two legs; the horse on all four legs, never rising onto its hind legs" |+| the still's view sentence (`still_view_text`, `gen --direction`) | `STILL_VIEW_TEXT_ANY_BODY` for the front, back and diagonal views (where the body and head point; no feet, chest, hips, shoulders or shoes; the back also square and symmetric left to right, the head centred, neither side showing more, any tail from the middle, 2.38.0), the side view's `VIEW_TEXT` as it is, each ending in what it stands on (`body_plan.still_text`): ", standing on all four legs, not rearing onto its hind legs" / ", resting on its base without legs, never growing any" / ", each figure with the body it has: the man on two legs; the horse on all four legs, never rising onto its hind legs" || front or back mid-step redraw | `WALK_START_TEXT_ANY_BODY`: one leg lifted, the others planted, then what it stands on; a body without legs has no step to catch and films from its base (`starts_mid_step` is false, `video-prompt` gives no `start_still`) |Only the biped sentences were measured on clips; the others say no part the body lacks and are notdiff --git a/sprite_gen/video/batch.py b/sprite_gen/video/batch.pyindex 03af5c4..ef12ebc 100644--- a/sprite_gen/video/batch.py+++ b/sprite_gen/video/batch.py@@ -123,7 +123,10 @@ STILL_VIEW_TEXT = {}# The same views for a body that is not one biped (`body_plan`): where the body and head point, with no feet# counted and no chest, hips, shoulders or shoes, so a horse's still is not drawn standing on two feet.-# `{body}` is the character's or every figure's; then what it stands on (`body_plan.still_text`). Not measured.+# `{body}` is the character's or every figure's; then what it stands on (`body_plan.still_text`). Not measured,+# but for the back: a four-legged back still drawn from a three-quarter reference came out turned, its head to one+# side and its tail to the other, and the clip filmed from it turned further and showed a flank; said square and+# symmetric left to right, it was drawn straight behind in every try (2.38.0).# The diagonals here keep their few words and take none of the person's middle-line and leg clauses, which count# a chest, shoulders and two feet.STILL_VIEW_TEXT_ANY_BODY = {@@ -133,8 +136,10 @@ STILL_VIEW_TEXT_ANY_BODY = {),"back": ("seen from directly behind: {body} turned fully away from the viewer, the back of the body and of the head "- "facing straight at the viewer, the face completely hidden and not turned toward either side or looking back, "- "even when a reference picture shows it from another angle"+ "facing straight at the viewer, square to the viewer and symmetric left to right, with the back of the head "+ "centred above the body, neither side of the body showing more than the other and any tail rising from the "+ "middle, the face completely hidden and not turned toward either side or looking back, even when a reference "+ "picture shows it from another angle"),"front_diagonal": ("seen from a three-quarter front angle: {body} turned about 45 degrees to the {facing}, halfway between facing "@@ -192,6 +197,24 @@ GAIT_HOLD_TEXT = {"angle of the image the whole time, its face hidden, never turning into a side view."),}+# A walk or run seen from behind, for a body that is not one biped (`body_plan`): said after what it stands on.+# A four-legged walk filmed from behind turned partway through the clip until a flank showed, and swayed from side+# to side; with this and the still drawn square (`STILL_VIEW_TEXT_ANY_BODY["back"]`) it held square (2.38.0). Said+# without the tail, the body held square but the tail swung from side to side on its own beat and the walk found no+# loop, so the tail is held too.+# A person's back walk is unchanged: it starts from a still redrawn mid-step with the body square (`WALK_START_TEXT`).+BACK_GAIT_TEXT_ANY_BODY = {+ "one": (+ "Its body stays level, square to the viewer and straight the whole time, never turning or angling to either "+ "side, so neither side of it comes into view, and it does not sway from side to side; any tail stays raised "+ "where it is in the image, only its tip swaying a little."+ ),+ "scene": (+ "Every figure stays level, square to the viewer and straight the whole time, never turning or angling to either "+ "side, so no figure's side comes into view, and none sways from side to side; any tail stays raised where it is "+ "in the image, only its tip swaying a little."+ ),+}MOTION_TEXT = {# A side-view full body asked for "a subtle weight sway" and an evenly paced loop steps in place# more often than not, so the feet are held and walking is named as what not to do.@@ -403,7 +426,8 @@ def clip_prompt_parts(direction: str, state: str, character: str | None, facing:None, or one biped, keeps the sentences measured on people; any other body gets them without a part itlacks (`IDLE_TEXT_ANY_BODY`, `ATTACK_TEXT_ANY_BODY` / `HOLD_TEXT_ANY_BODY`, `LITE_WALK_TEXT_LEGGED` / `_LEGLESS`,`LITE_HEAD_TEXT_ANY_BODY`) and, after the- motion sentence or the caller's paragraph, what it stands on (`body_plan.text`).+ motion sentence or the caller's paragraph, what it stands on (`body_plan.text`); a walk or run seen from behind+ then says it stays square and does not sway (`BACK_GAIT_TEXT_ANY_BODY`).Without `handed` or `body_plan` the prompt is 2.22.0's, to the byte (`tests/gen/test_prompt_freeze.py`). `handed` liststhe character's asymmetric items (`handedness.parse`): the prompt ends with where each one stays, anchored@@ -420,6 +444,8 @@ def clip_prompt_parts(direction: str, state: str, character: str | None, facing:template = COMMON_TEXTstands_on = body_mod.text(body_plan)stands_on = f" {stands_on}" if stands_on else ""+ if direction == "back" and state in GAIT_STATES and not body_mod.biped(body_plan):+ stands_on += f" {BACK_GAIT_TEXT_ANY_BODY['scene' if body_mod.scene(body_plan) else 'one']}"if motion is not None:motion = " ".join(motion.split())if not motion:diff --git a/tests/video/test_body_plan.py b/tests/video/test_body_plan.pyindex d16412d..5d25c7c 100644--- a/tests/video/test_body_plan.py+++ b/tests/video/test_body_plan.py@@ -98,6 +98,25 @@ SNAPSHOTS = {'looking straight out of the image, not turned toward either side even when a reference picture shows it ''from another angle, standing on all four legs, not rearing onto its hind legs'),+ 'horse/back/walk': (+ '2D game sprite animation. A brown horse walks naturally in place, facing away from the viewer, as if on a '+ 'treadmill, without moving any farther away. It stays on all four legs, as in the image, and never rises onto '+ 'its hind legs. Its body stays level, square to the viewer and straight the whole time, never turning or '+ 'angling to either side, so neither side of it comes into view, and it does not sway from side to side; any '+ 'tail stays raised where it is in the image, only its tip swaying a little. The character is '+ 'seen from directly behind, facing away from the viewer. Stays centered in the frame and does not move across '+ 'the screen; the body and hair always stay fully inside the frame with margin. Camera completely locked, no '+ 'zoom, no pan, no reframing. The background stays a perfectly flat, pure chroma-key fill for the whole clip — '+ 'no shadows, no ground line, no particles, no lighting changes, no effects. Keep the design, colors and '+ 'proportions exactly as in the image. Consistent, evenly paced motion so the animation loops.'+ ),+ 'horse/back/still': (+ 'seen from directly behind: the whole body and head turned fully away from the viewer, the back of the body '+ 'and of the head facing straight at the viewer, square to the viewer and symmetric left to right, with the back'+ ' of the head centred above the body, neither side of the body showing more than the other and any tail rising'+ ' from the middle, the face completely hidden and not turned toward either side or looking back, even when a '+ 'reference picture shows it from another angle, standing on all four legs, not rearing onto its hind legs'+ ),'scene/back_diagonal/still': ('seen from a three-quarter back angle: every figure\'s whole body and head turned about 45 degrees away from ''the viewer toward the upper right, halfway between facing away and facing right, the face hidden and not '@@ -209,6 +228,22 @@ def test_the_body_plan_says_what_it_stands_on_after_the_motion_and_before_the_viassert told.startswith(f"2D game sprite animation. It trots lightly. {bp.ONE_TEXT['quadruped']} It stays in place")[email protected]("body_plan, key", [(QUADRUPED, "one"), (LEGLESS, "one"), (SCENE, "scene")])+def test_only_a_walk_or_run_seen_from_behind_is_held_square(body_plan, key) -> None:+ """The back of a body that is not one person turned and swayed as it walked: a walk or run from behind says it+ stays square, after what it stands on, in the built-in sentence and after a caller's paragraph alike. No other+ view or state says it, and a person's prompts do not (`test_one_biped_or_none_keeps_every_prompt_byte_for_byte`)."""+ square = batch.BACK_GAIT_TEXT_ANY_BODY[key]+ stands_on = bp.text(body_plan)+ for view, state, motion in itertools.product(batch.VIEW_TEXT, (*STATES, "attack"), (None, "It ambles along.")):+ prompt = batch.build_prompt(view, state, "A brown horse", motion=motion, body_plan=body_plan)+ if view == "back" and state in batch.GAIT_STATES:+ assert f"{stands_on} {square} " in prompt+ else:+ assert square not in prompt+ assert all(square not in batch.build_prompt("back", state, "The knight") for state in batch.GAIT_STATES)++def test_a_body_without_legs_has_no_mid_step_redraw() -> None:assert batch.starts_mid_step("walk", "front", QUADRUPED) and batch.starts_mid_step("walk", "back", SCENE)assert not batch.starts_mid_step("walk", "front", LEGLESS)