Skip to content

Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.

docs: video-stop in the pipeline B reference (section 8), the index, SKILL routes, game-pack playback and CHANGELOG

Soohong Kimf7552f3c6563
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 449b243..fda1f44 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@ All notable public changes to `sprite-gen` are recorded here. Versions track the
## Unreleased
+- **New verb: `video-stop` cuts a walk or run that stops from the clip's own start played backwards.** Given the clip's keyed frames and a walk or run loop (`--frames-dir`, `--loop`), it writes a one-shot strip (`<name>.strip.png`), sidecar (`loop: false`, `hold_last: true`), GIF, WebP, and report (`<name>.stop.report.json`). The stop leaves the loop from the cell nearest the entry (`from_cell`), the first frame after the opening rest within `SAME_POSE` (0.35 steps) of a loop cell, and ends on the clip's first frame, the still as filmed. A seam past the jump line (1.4 steps, `--seam-max`) or a run-up between the rest and entry longer than 1.5 cycles (`--run-up-max`) is refused with exit code 1 and `status: "failed"` in the report. Drift is taken out by laying the entry on its cell and the first frame on the loop's ground and mean coverage, moving frames between by a straight share of the difference per step; a run leaning away moves the still a few pixels, and drift not straight leaves a little of itself. Strips wider than 32,000 px are refused, `--speed 2` plays every other frame (still kept last), `--max-frames N` spaces frames evenly, and frames shown pass the ghost screen (`interpolation_quality`) as filmed. The pose thumbnails (`gait_fallback.poses`, 48 px cut about the feet) are now public, as the verb reads poses with them ([video-pipeline](docs/video-pipeline.md#8-a-walk-or-run-that-stops--video-stop)).
- **New: `background-tile --axis xy` makes one tile seamless in both directions and measures both joins.** It quilts along x, then along y with a cyclic seam: the second seam's two ends, which meet across the x wrap, may differ by one step at most, so the second quilt cannot break the first one's join. The report measures the finished tile on both axes (`axes.x`, `axes.y`, each with its join, quilt seam, `status` and reasons); the top-level `status` is `needs-review` when either axis is, and each reason names its axis. Two separate one-axis runs had no such rule, and the second run's report measured only its own axis. `inspect_tile_xy(image)` measures both joins of any tile ([asset-tools](docs/asset-tools.md#both-axes-a-ground-tile)).
- **New: alpha haze cleanup for transparent sheets (`frames.alpha_floor.clear_haze`).** Pixels at or above a floor, and faint pixels within a few pixels of them (an object's anti-aliased edge), are kept byte for byte; every other faint pixel becomes fully transparent. The report measures the haze share before and after and counts the solid and edge pixels that changed (`0`). Used by `ui-kit` (on by default) and `slice-sheet --alpha-floor N` (off by default; writes `<prefix>alpha-cleanup.json`). `slice-sheet --chroma-key none` cuts a sheet that is already transparent on its own alpha ([sheet-slicing](docs/sheet-slicing.md#transparent-sheets)).
- **New verb: `ui-kit` splits a game UI kit sheet into nine-slice elements.** `gen --layout-guide ui-kit` attaches a fixed square layout (panel, button, pressed button, card frame, HP and XP bar frames, timer badge) and asks for each element in its box. `ui-kit --sheet uikit.png --out-dir ui/` clears the haze, assigns parts to boxes by centroid, and writes each element's PNG and `ui-kit.json` (or `--report PATH`, which must end in `.json`; each element's `file` is its PNG's path from the report's directory, so a report written outside `--out-dir` still finds its elements): its rectangle, its stretch (`xy`, `x` for the bars, `none` for the badge), nine-slice insets measured so that every corner ornament and end cap lies in a fixed slice, and the content padding (a bar frame's track, a panel's text area). An ornament in the middle of an edge, an empty box or a stray part is reported or refused ([ui-kit](docs/ui-kit.md)). `--layout-guide` alone is still the one-slot figure guide.
diff --git a/SKILL.md b/SKILL.md
index 2e998b6..062702f 100644
--- a/SKILL.md
+++ b/SKILL.md
@@ -105,6 +105,7 @@ hold the arms still, and check the loop with `handed-check --state walk`.
| A soft part of a walk loop follows the body (a chest, a belly): an ellipse in the first cell, after `video-cycle-align` — `--read-on <sha256>` where it was read on the cut the loop was aligned from; `--stretch-floor D` to keep a least area | `video-follow` | [video-pipeline](docs/video-pipeline.md#6-follow-through--video-follow) |
| Where that ellipse is carried in every other cell, and what the move changes there (an arm crossing a chest moves with it; the stretch, the bend and the seam): a record and boards of every cell, nothing moved | `video-follow-inspect` | [video-pipeline](docs/video-pipeline.md#inspecting-a-follow-through--video-follow-inspect) |
| A set's directions on one sheet, standing on one ground line (a 3×3 board, an engine import): rows in compass order S SW W NW N NE E SE from each loop's `--view`, one cell size, every row as cut, an optional centre picture (`--center`) at the rows' standing height; loops of different lengths are laid and said to differ (`same_length` false) — align the set first | `video-set-sheet` | [video-pipeline](docs/video-pipeline.md#7-one-sheet-for-a-set--video-set-sheet) |
+| A walk or run that stops, from the clip's own start played backwards: a one-shot strip (`loop: false`, `hold_last: true`), GIF, WebP and report beside the loop, ending on the still as filmed; leaves the loop from the cell nearest the entry (`from_cell`), drift taken out across the frames by a straight share; seam past 1.4 steps (`--seam-max`) or run-up over 1.5 cycles (`--run-up-max`) refused; ghost screen checked, cells placed and anchored to match the loop's pivot | `video-stop` | [video-pipeline](docs/video-pipeline.md#8-a-walk-or-run-that-stops--video-stop) |
| Compare the currently displayed loop with a final candidate, including after follow-through | `video-loop-compare` | [loop-comparison](docs/loop-comparison.md) |
| Restore post-processing damage in the current cut from its exact source times, preserving normal cells and playback | `video-source-manifest` → `video-loop-repair` → `video-loop-compare` | [source restoration](docs/loop-comparison.md#restoring-the-active-cut-from-source) |
| Video sprites from a clip your agent makes with a connected video MCP (ZCRE, 지크) | `video-canvas`, `video-prompt --no-last-frame`, the agent's own MCP tools (quote, user approval, generate, save the mp4), then `video-frames` and `video-loop` (a walk or run with `--anchor motion-auto`, which holds its size), and for a walk or run cut in two or more directions `video-cycle-align --view …` over their loop directories (a set it stops on a loop that may hold two cycles: look at that loop, count its strides, and pass `--cycles <loop>=<k>`; a loop the report lists under `unnamed_feet` — its view could not tell the feet apart, or only by too small a margin (`low-margin`): look at its first candidate frame, say which own foot lands there, and align again with `--foot <loop>=left|right`). `video-set` is not run on this route, so the set stage it runs by default (`--align-cycles auto`) is yours to run. sprite-gen never calls the MCP. Walk, run and jump only: ZCRE's `grok-imagine-video-1.5` has no end frame, so idle, attack and diagonal walks are refused unless `--unpinned` | [video-pipeline](docs/video-pipeline.md#a-clip-from-a-video-mcp-on-your-agent--zcre) |
diff --git a/docs/README.md b/docs/README.md
index 14ebe49..016433b 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -40,7 +40,7 @@ flowchart LR
| Pipeline / tool group / workflow | Entry doc | Verbs |
|---|---|---|
| **A · atlas rows** — one still becomes a runtime sprite sheet | [run-contract.md](run-contract.md) | `prepare` → `gen` / `gen-set` → `extract` → `compose-atlas`; optional `curation` and recompose |
-| **B · video → loop** — one still becomes transparent motion loops | [video-pipeline.md](video-pipeline.md) | `video-canvas` → `video` (or `video-prompt` and a video MCP on your agent) → `video-frames` → `video-loop`, `video-set`, `video-cycle-align`, `video-follow` (`video-follow-inspect` shows every cell of it and moves nothing), `video-set-sheet` (a set's directions on one sheet, on one ground line); `handed-check` for an item on one side |
+| **B · video → loop** — one still becomes transparent motion loops | [video-pipeline.md](video-pipeline.md) | `video-canvas` → `video` (or `video-prompt` and a video MCP on your agent) → `video-frames` → `video-loop`, `video-set`, `video-cycle-align`, `video-follow` (`video-follow-inspect` shows every cell of it and moves nothing), `video-set-sheet` (a set's directions on one sheet, on one ground line), `video-stop` (a walk or run that stops, from the clip's own start played backwards); `handed-check` for an item on one side |
| **C · utilities** — imported images in, clean cuts out | [sheet-slicing.md](sheet-slicing.md) | `cutout`, `slice-sheet`, `ui-kit`, `unpack-atlas` |
| **D · post-processing** — finished sheets, refined | [recolor.md](recolor.md) | `recolor`, `recolor-palette`, `compose-layers`, breathing (compose), `export-pngs`, `export-aseprite` |
| **E · asset tools** — independent background, shadow and motion tools | [asset-tools.md](asset-tools.md) | `background-tile`, `shadow`, `inspect-motion` |
@@ -83,7 +83,7 @@ grouping is derived from `sprite_gen/_modules.py`, the one taxonomy table.
| [pixel-draw.md](pixel-draw.md) | `sprite-gen pixel-draw` (experimental): Claude Opus draws 8–48 px pixel art as a pixel grid — the inputs, the safe area, the run folder and its report, gates G1–G8, the row repair and the one redraw, the pick between candidates, Message Batches and `--resume`, re-rendering an edited `grid.txt` |
| [prompt-assembly.md](prompt-assembly.md) | What the engine adds to a still or clip prompt and when: the pieces, the 2.22.0 freeze without `--handed`, what counts as already said, and the notes on the caller's own words |
| [video.md](video.md) | `sprite-gen video` / `video-extend` / `video-edit` / `video-resume`: stills and clips to mp4 through Grok Imagine (image-to-video, last-frame pin, references, extension, editing, asking again for an unfinished generation) with the user's own credential |
-| [video-pipeline.md](video-pipeline.md) | Pipeline B engine contract: state canvas, keyed frames, true-period and one-shot cycles, strip/GIF/WebP, the batch, a set's directions on one sheet |
+| [video-pipeline.md](video-pipeline.md) | Pipeline B engine contract: state canvas, keyed frames, true-period and one-shot cycles, strip/GIF/WebP, the batch, a set's directions on one sheet, a walk or run's stop |
| [loop-review.md](loop-review.md) | Automatic loop decisions, ambiguous gait review, visual evidence and explicit cut/alignment overrides |
| [loop-repair.md](loop-repair.md) | RIFE (where it runs, cost, licences, `sprite-gen rife install`, what runs without it), jump-frame repair, the jolt index and its gate, one cycle length per direction set |
| [frame-interpolation.md](frame-interpolation.md) | Generative in-betweens for sprite frames, recorded as a take |
diff --git a/docs/game-pack.md b/docs/game-pack.md
index 8b21336..415e400 100644
--- a/docs/game-pack.md
+++ b/docs/game-pack.md
@@ -87,6 +87,8 @@ Source policies and row anchors are preserved by the asset adapter. Optional ent
* `direction`: Direction override code or `null` (defaults to `null`). Allowed only if the entry resolves to one animation; the user can select one source `state` to override one animation. An entry expanding multiple states or directions must reject any `direction` field, including `null`, before publishing output.
* `events`: Array of `{"frame": <int>, "name": "<string>"}` triggers where `frame` is a zero-based playback position validated within frame count (defaults to `[]`).
+A `video-stop` strip sidecar is packed like a loop strip and carries `loop: false`, `hold_last: true` and an `anchor` that puts the loop's pivot where the stop's cells hold it, so the two animations drawn at their anchors stand in one place.
+
## Packing and layout
* Every frame receives 1-pixel edge extrusion on each side (+2 pixels to width and height). Maximum frame dimension plus 2 pixels must fit within `--page-size`.
diff --git a/docs/video-pipeline.md b/docs/video-pipeline.md
index 8ff1e0f..5c46498 100644
--- a/docs/video-pipeline.md
+++ b/docs/video-pipeline.md
@@ -1,6 +1,6 @@
# Video → sprite pipeline (engine SSoT)
-> Owns: Pipeline B engine contract: state canvas, keyed frames, true-period and one-shot cycles, strip/GIF/WebP, the batch, a set's sheet · Index: [docs/README.md](README.md)
+> Owns: Pipeline B engine contract: state canvas, keyed frames, true-period and one-shot cycles, strip/GIF/WebP, the batch, a set's sheet, a walk or run's stop · Index: [docs/README.md](README.md)
One still becomes a whole motion set: the still is padded into the canvas a state
needs, Grok Imagine animates it in place, the clip is keyed frame by frame, and one
@@ -27,6 +27,7 @@ still ──video-canvas──▶ canvas.png ──video──▶ clip.mp4 ─
| `sprite-gen video-follow` | `sprite_gen/video/follow.py` | a loop directory + an ellipse → the strip, GIF and WebP with that region following the body ([section 6](#6-follow-through--video-follow)) |
| `sprite-gen video-follow-inspect` | `sprite_gen/video/follow_inspect.py` | a loop directory + the ellipses `video-follow` takes → a record of where each is carried in every cell and what the move changes there, and two boards of every cell; the loop directory is only read ([section 6](#inspecting-a-follow-through--video-follow-inspect)) |
| `sprite-gen video-set-sheet` | `sprite_gen/video/set_sheet.py` | the loop directories of one set, each with its `--view` → one sheet: a row per direction in compass order, one cell size, one ground line, every row as cut, + a record and an optional centre picture; the loop directories are only read ([section 7](#7-one-sheet-for-a-set--video-set-sheet)) |
+| `sprite-gen video-stop` | `sprite_gen/video/stop.py` | keyed frames + a walk or run loop → one-shot stop strip (`loop: false`, `hold_last: true`), GIF, WebP, report ([section 8](#8-a-walk-or-run-that-stops--video-stop)) |
Wrappers: `scripts/video_canvas.py`, `scripts/video_frames.py`, `scripts/video_loop.py`,
`scripts/video_set.py`. Binaries: `ffmpeg`/`ffprobe` (frames), `img2webp` from libwebp
@@ -1425,6 +1426,26 @@ rows' codes), `columns`, `cell_w`, `cell_h`, `baseline_y`, `anchor` (`[cell_w /
was scaled to, the `scale` and its `box` in the cell. The loop directories are only read: no strip,
frame or frame time is changed.
+## 8. A walk or run that stops — `video-stop`
+
+A game character that stops running jumps from a running frame straight to its standing picture. Frames made between them (RIFE in-betweens) are the wrong tool: as [loop repair](loop-repair.md) notes, RIFE smears a changed appearance, and where two drawings are too far apart for the flow, legs come out as one shape of fill; a running frame and a separately drawn standing picture are both. Every walk or run clip filmed from a still (image to video) already holds a filmed "stand → set off" at its start: the body stands, sets off, and runs into the gait the loop is cut from. Played backwards from the frame where the clip reaches the loop, that start is the body running into the standing still — filmed frames, no frame made between two others, ending on the clip's first frame, the still as filmed. `video-stop` cuts this as a one-shot clip beside the loop: a strip, its sidecar (`loop: false`, `hold_last: true`), a GIF, a WebP and a report. Played backwards, motion runs backwards (a cape, a planted foot), which is a cost to look at. This example cuts a run's stop and plays it twice as fast:
+
+```bash
+sprite-gen video-stop --frames-dir run/frames/keyed --loop run/loop/run.strip.json --out-dir run/stop --speed 2
+```
+
+- **The rest.** The clip's opening run of frames within `SAME_POSE` (0.35 steps) of its first frame by engine pose distance (`gait_fallback.poses`: 48 px thumbnails cut about the feet). A step is the clip's median neighbouring-frame pose distance in the loop's window on the clip as filmed, whether cut or aligned. The stop ends on the first frame itself, the still as filmed.
+- **The entry and the cell left from.** The first frame after the rest within `SAME_POSE` of a loop cell, searched to the end of the loop's window (`source_cut`): where the clip reaches the loop. The stop leaves from the nearest cell (`from_cell`) — a player shows the loop through that cell, then the stop — and its first frame is the clip frame before the entry. The entry frame is laid on its cell within 12 % of the cell height (coverage difference, quarter-size search then to the pixel); the first frame is searched across a cell's width.
+- **The seam and its refusal.** Reported in steps from the leaving cell into the stop's first frame. Past the jump line (1.4 steps, `repair.JUMP_RATIO`, overridden by `--seam-max`), the stop is refused: "the clip reaches the loop by a jump".
+- **The run-up and its refusal.** The frames between the rest and the entry that the stop plays before the still. A body sets off within about a cycle; a run-up longer than `RUN_UP_MAX_CYCLES` (1.5 cycles, `source_cut.length` frames, overridden by `--run-up-max`) holds another motion or strides unlike the loop's, and is refused: "another motion, or strides unlike the loop's, that the stop would play backwards". Both seam and run-up refusals can be named in one message.
+- **Drift.** A body setting off may move across its frame, sliding into the still if played back as filmed. Two frames are laid where the loop stands: the entry on its cell (least coverage difference), and the first frame with its lowest body row on the loop's ground and across where it covers the loop best (mean coverage of the cells). Frames between are moved by a straight share of the difference per step of the stop, none at the entry and all on the first frame: drift is taken out without moving any frame by its own pose. Because a standing pose is laid on a running one by coverage, a run leaning or reaching away moves the still a few pixels — a straight glide over the stop, the same with drift or without it — and drift not straight over the frames shown leaves a little of itself.
+- **Speed and the frame cap.** `--speed 2` plays every other frame (still kept last); `--max-frames N` (at least 2) spaces N frames evenly from the first to the still. Each frame is shown one clip tick (`--fps` defaults to the loop's `source_cut` fps, else 24). Strips wider than 32,000 px are refused; pass `--max-frames` or `--speed 2`.
+- **The ghost screen.** Frames shown pass the ghost screen delivered on every loop path (`interpolation_quality`), read on them as filmed, as `video-loop` reads its cut. Any ghost is named in the report and warned on stderr by cell and clip frame, and kept as filmed.
+- **Cell placement and anchor.** Measured on one canvas in loop cell coordinates, the stop's cell holds every shown frame and the loop's cell, centred across on the loop's cell with the same bottom unless a frame reaches lower (`loop_cell_origin`). No frame is scaled (the loop's scale). The sidecar's `anchor` is the loop's pivot there (its declared `anchor`, else bottom centre), so drawing at the pivot stands where the loop stood.
+- **Refusals and source warnings.** Refuses loops that play once (`loop: false`), are not walks or runs, sidecars missing `source_cut` (source, start, length), frame folders shorter than the loop's window reaches, `--speed` other than 1 or 2, `--max-frames` under 2, or clips whose frames after the rest never reach a loop cell within `SAME_POSE` before the window ends ("these frames are not the loop's clip"). Each refusal exits non-zero with `status: "failed"` and the error in `<name>.stop.report.json`. Keyed frames not byte-for-byte identical to the loop's cut warn on stderr (the stop is still written; the entry is found by pose, so inspect the stop), as do ghosts or an unreadable ghost screen.
+
+The outputs are `<name>.strip.png`, `<name>.strip.json`, `<name>.gif` (plays once), `<name>.webp` (plays once), and `<name>.stop.report.json` (or `--report PATH`). The GIF and WebP are reopened and checked as `video-loop` checks its own. The sidecar records `frames`, `w`, `h`, `delay_ms` (1000 / fps), `kind: "stop"`, `state: "stop"`, `loop: false`, `hold_last: true`, `end_frame`, `events: []`, `anchor`, `loop_cell_origin`, `body_h`, `body_src_h`, `scale`, `cycle_frames`, `cycle_seconds`, `from_loop` (`strip_sha256`, `state`, `frames`, `w`, `h`, `from_cell`), `source_cut` (`source`, `frames`, `entry`, `rest_end`), `speed`, and `seam_steps`. The report records `status`, `error` (on refusal), `source` (`same_as_loop`), `loop_cut` (`start`, `length`, `cells`, `state`), `step`, `loop_cell_step` (which differs for an aligned loop), `same_pose`, `seam_max`, `run_up_max_cycles`, `rest` (`end`), `to_rest` and `to_loop` (each frame's distance in steps to the first frame and nearest cell), `entry` (`frame`, `match`, `from_cell`), `seam` (`steps`, `from_cell`, `into_frame`, `max`), `run_up` (`frames`, `cycles`, `max_cycles`), `played`, `shown`, `frames_shown`, `seconds`, `drift` (`leave`, `stand`, `clip_px`, `ground`, `ground_in_cell`, `ends_on_ground`), `ghost_screen` (`frame`, `clip_frame`), `strip`, `gif`, and `webp`.
+
## What the rules were measured on
Every threshold above (the 15 % period tolerance, the 2.0 seam gate, the 0.15