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: gait floor, one-shot length, --anchor feet, wide raised-limb canvas, --trim-alpha

Soohong Kim60c482818a6d
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b48e7eb..5bc7be6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,14 @@
All notable public changes to `sprite-gen` are recorded here. Versions track the `version:` field in `SKILL.md` and `pyproject.toml`.
+## Unreleased
+
+- `video-loop` gait half-period guard: a `walk`/`run` period shorter than the state's floor (`LoopProfile.min_seconds`: 0.6 s / 0.35 s) is treated as one step of a two-step gait and doubled when the doubled period repeats within 25 % of it — the case where a costume hides the legs and the half period dips as deep as the full one, which the depth rule alone returned as a one-legged loop. The report carries `cycle.half_period_guard` (`applied`, `from`, `to`, depth ratio, or `below_floor` + why it was left alone). `--min-len` still overrides.
+- `video-loop` one-shot detection no longer refuses an excursion shorter than the periodic window's lower edge; only a cut under 4 frames or longer than the clip is refused. Short performed actions (a set-down, a nod) come back as the frames they are.
+- `video-loop --anchor feet` (also `video-set --anchor`): re-centre every strip cell on that frame's own foot line so a subject the model walked across an "in-place" canvas stops sliding once per cycle. Strip meta gains `foot_anchor`, `drift_px` and `foot_x`, and declares the spec loader's `anchor` as `[foot_x, h]` so scenes stand the sprite on its feet; the video-set table row carries `drift_px`. Default `none` keeps existing output byte-identical.
+- `video-canvas` / `video-set`: `cheer`, `wave` and `celebrate` now take the wide canvas (raised limbs leave a 1:1 frame at the top corners), `video-set --shape` forces one shape for a whole batch (wide costumes), and `video-set` carries `cheer` / `wave` motion templates that name no limbs.
+- `gen --trim-alpha` (with `--transparent`): crop the published PNG to its opaque bbox so the bottom edge is the foot line; the report records `extra.trim_alpha` (`bbox`, `before`, `after`, `margin_px`). The `.raw.png` is untouched.
+
## v2.2.0 - Independent asset tools and optional scenes
- Added standalone `background-tile`, `shadow` and `inspect-motion` commands. They accept existing artwork and report tile joins, anchor-preserving shadow projections, repeated poses and explicit foot-contact measurements without changing source animation.
diff --git a/docs/gen.md b/docs/gen.md
index 0e03335..99b8fc9 100644
--- a/docs/gen.md
+++ b/docs/gen.md
@@ -205,3 +205,16 @@ for tighter prompt adherence.
## Related
- [docs/README.md](README.md) — documentation index
+
+## `--trim-alpha` — the bottom edge is the foot line
+
+A generated transparent still carries an unpredictable band of empty alpha under the
+feet and around the sides; two stills placed on the same floor line then stand at
+different heights, and a still swapped for a strip cell (whose feet sit on the cell
+bottom) jumps. `--trim-alpha` (only with `--transparent`) crops the published PNG to the
+bbox of its opaque pixels (alpha ≥ 8) after the transparency step, so the image's bottom
+edge *is* the ground-contact line. The subject is never cut — only fully transparent
+margin goes — and the report records `extra.trim_alpha` with the `bbox`, `before` /
+`after` sizes and the `margin_px` removed on each side. The `.raw.png` beside the output
+is untouched.
+
diff --git a/docs/video-pipeline.md b/docs/video-pipeline.md
index aceb886..6d24c6b 100644
--- a/docs/video-pipeline.md
+++ b/docs/video-pipeline.md
@@ -126,7 +126,17 @@ touches the edge (a key-tinted blend pixel with low alpha), so a "framed too tig
message with a small residual count is still a framing problem, not a key problem.
`--allow-edge-contact` accepts the clipping on purpose.
-## 4. Loop — period first, seam second
+## 3b. Canvas shape for raised limbs and wide costumes
+
+`video-set` picks the canvas from the state row alone. Two things that are not a jump or
+an attack still leave a 1:1 frame: limbs raised in a celebration, and a costume that is
+wider than the body (a skirt, a veil, a held object). Both fail `video-frames`'s
+edge-contact check — the clip was made, the frames were cut, and the run stops at the
+gate. The state table now routes `cheer`, `wave` and `celebrate` to the wide canvas, and
+`video-set --shape wide` forces it for every state of a batch when the costume is the
+reason. The same `--shape` is what `video-canvas` already took for a single still.
+
+## 4. Loop — period first, seam second, then the gait floor
The 2026-09-08 lesson: a single-start "most similar later frame" search lands on the
**1.5-cycle look-alike** of a gait (legs swapped) and produces a loop that hitches at
@@ -225,3 +235,27 @@ the synthetic fixtures under `tests/video/` pin every rule named here.
## Related
- [docs/README.md](README.md) — documentation index
+
+### One-shot length is the clip's own fact
+
+The periodic window (`LoopProfile.min_frac` / `max_frac`) bounds *repeats*. A one-shot
+(`--cycle one-shot`, or the `auto` failover for action states) has no repeat to bound:
+the excursion is as long as the model performed it. `detect_one_shot` therefore no longer
+refuses an excursion shorter than the periodic window's lower edge — only a degenerate
+cut under `ONE_SHOT_MIN_LEN` (4 frames) or one longer than the clip is refused. A short
+set-down, a nod, a flinch come back as the frames they are.
+
+### `--anchor feet` — undo in-canvas drift
+
+"Stays centered in the frame" is a request, not a guarantee: the model may walk the
+subject across an in-place canvas, and the union crop that `build_strip` uses keeps that
+drift inside every cell, so a runtime that places the strip by its cell box sees the body
+slide back and forth once per cycle. `--anchor feet` (on `video-loop` and `video-set`)
+measures each cycle frame's foot line — the mean x of the opaque pixels in the lowest
+`FOOT_BAND` (8 %) of that frame's own bbox — and re-centres every cell on it. The strip
+meta gains `foot_anchor`, `drift_px` (how far the foot line wandered across the cycle, in
+source pixels, before alignment) and `foot_x` (the foot column inside every cell), plus the spec loader's `anchor`
+as `[foot_x, h]` so a scene stands the sprite on its foot line; `video-set`'s table row
+carries `drift_px`. The default stays `none`: existing strips do
+not change, and `drift_px` is 0 when it was not measured.
+