Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.
docs(video): the loop repair notes and the changelog say the order the feet are drawn in leaves out a frame either of whose sides is drawn over no column anything in the clip stands on (off_ground), name the tail hanging over the columns the feet stand on as still read as a foot, say the body's witness reads its top line holding still where it gave no share, and describe the tests; text by the writing hand-off
Soohong Kim58b8dd8c34ec
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 0fb10ef..41df4a8 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -13,10 +13,10 @@ All notable public changes to `sprite-gen` are recorded here. Versions track the- **Changed: cycle alignment leaves out start-stop retake, cycle-unwitnessed and cycle-four-steps loops (`batch.align_gaits`, `video-set --align-cycles auto`, `local_cycle.four_steps`).** Takes flagged with `start-stop` retakes loop no two steps, loops whose cut nothing witnesses whole cycles (`cycle-unwitnessed`: crossings left on steps unwitnessed, or a cut the cut witness held) may hold half a cycle or two, and the warning says so, and loops whose cut witness says four steps (`cycle-four-steps`) hold two cycles where their strip counts two steps (`steps: 2`, which `video-cycle-align` reads as one cycle) and would play twice as fast if aligned as one cycle; all are excluded from gait cycle alignment, keeping their loops as cut while aligning the remaining directions. Excluded items are recorded under `left_out` (`{item: reasons}`, listing `["start-stop"]`, `["cycle-unwitnessed"]`, `["cycle-four-steps"]`, or `["start-stop", "cycle-unwitnessed"]`) with a stderr warning and a set warning; if fewer than two directions remain, alignment is skipped (`applied: false`, `why: "fewer than two directions left to align"`). A left-out loop whose step screen suspects one step is told in its warning what settles it (`video-loop --steps 1`), as `video-cycle-align` says when it stops on such a loop, and `batch.left_out_why` takes `one_step`.- **New: a walk's cut is held to its body's word before it is cut (`loop._witnessed`, `local_cycle.cut_word`, `local_cycle.unwitnessed`, `local_cycle.held_verdict`).** In `video-loop --anchor motion-auto` (`--cycle auto` or `periodic`), after `loop._by_steps` chooses the cut and before frames are cut, `loop._witnessed(cycle, frames=...)` holds the cut s/L to `local_cycle.cut_word(signals, length)`, which reads `local_cycle.bob_word` on two lines, `local_cycle.CUT_LINES` (`'screen'` on the screen, less its flow, and `'feet'` over its feet with `local_cycle.over_feet`, `feet=True`), at length L, L/2 and 2L (a picture swaying up and down once a cut or slower hides the body's rise and fall twice the cut on the screen, where the line over the feet reads it; a walk whose lean changes slowly on its feet tilts the ground under them, so the line over the feet takes in the two feet's heights by turns and reads no rise and fall, where the line on the screen reads it) and says the first either line says in `local_cycle.CUT_WORDS`: `"two steps"` (a cycle), `"four steps"` (two cycles), `"one step"` (once in the cut), or null. On two steps or four steps the cut stands (`{cut: [s, L], ...cut_word's record}`; where the cut stands and its lowest row rises and falls twice the cut more than its top line on the screen, the record carries `mark`; it holds nothing), and a cut of four steps (two cycles), its strip still counting two steps, makes `local_cycle.four_steps(cycle)` true, and `video-set` leaves the item out of cycle alignment (`left_out` `["cycle-four-steps"]`); anything else is held exactly as chosen (two clip crossing intervals where counted, else the search's cut), setting `cut_witness.held` to `"unwitnessed"`, warning `cycle-unwitnessed` (`local_cycle.held_verdict(cycle)` via `local_cycle.step_verdict`), and marking `local_cycle.unwitnessed(cycle)` true so `video-set` leaves the item out of cycle alignment (`left_out` `["cycle-unwitnessed"]`), while cuts the step count already held record `held: "step count"`. A reading of `"one step"` is held and never cut again two long because a body rising and falling once in the cut cannot be distinguished between half a cycle of legs drawn alike and a full cycle of a limp or bouncing legless body without reading legs, and the witness never lengthens or shortens a cut; walks whose body rises once a cycle, legless bodies bouncing once in the cut, and walks carried whole with no rise of their own are held and named even where a cut is a whole cycle.- **Changed: the body's own rise and fall is read against the lowest opaque row as well (`legs.body_signals` `sole`, `legs.OPAQUE`, `local_cycle.own_beat`).** `legs.body_signals(frames)` now returns `sole` per frame, taking the lowest row with an alpha of `legs.OPAQUE` (255) or the lowest solid row where none is opaque. `local_cycle.own_beat(signals, interval)` reads `sole` with `twice_an_interval` and takes `less_lowest` as the top line's rise and fall less the lowest solid row's or less the lowest opaque row's, whichever leaves less, returning `sole` as rows up and down. This prevents a translucent shadow drawn fixed on the screen under the feet from acting as the lowest solid row and registering picture shake twice an interval as the body's own rise against it, since opaque feet move with the picture.-- **New: the order the feet are drawn in witnesses a walk's steps (`legs.feet_order`, `legs.CONTACT`, `local_cycle.order_word`, `ORDER_ROWS`, `ORDER_TRAVEL`, `ORDER_SWAY`, `ORDER_REACH`, `ORDER_SLACK`, `ORDER_WORDS`).** `legs.feet_order` tracks which foot is drawn lower in each frame, and `local_cycle.order_word` gates side changes to witness one, two, or four steps across a span from non-side views. From the front, the back, or a diagonal, the foot nearer the viewer is drawn lower, and the nearer foot changes sides once a step, twice a cycle. The view's label is not taken for it, because a generated walk's label may be wrong: the clip must show that its two sides of feet are its two legs, or nothing is witnessed. `read_cycles` and `cut_word` read the foot drawing order when body cues do not witness crossings or cuts, and search cuts that failed to close are held unwitnessed rather than stood by foot order. A diagonal walk whose feet pass each other on the screen, one foot always drawn lower and the other passing it on either side, shows the same changes a side walk does, and the order does not witness it; a side walk is never read on the order.+- **New: the order the feet are drawn in witnesses a walk's steps (`legs.feet_order`, `legs.CONTACT`, `local_cycle.order_word`, `ORDER_ROWS`, `ORDER_TRAVEL`, `ORDER_SWAY`, `ORDER_REACH`, `ORDER_SLACK`, `ORDER_WORDS`).** `legs.feet_order` tracks which foot is drawn lower in each frame, and `local_cycle.order_word` gates side changes to witness one, two, or four steps across a span from non-side views. From the front, the back, or a diagonal, the foot nearer the viewer is drawn lower, and the nearer foot changes sides once a step, twice a cycle. The view's label is not taken for it, because a generated walk's label may be wrong: the clip must show that its two sides of feet are its two legs, or nothing is witnessed. `read_cycles` and `cut_word` read the foot drawing order when body cues do not witness crossings or cuts, and search cuts that failed to close are held unwitnessed rather than stood by foot order. A diagonal walk whose feet pass each other on the screen, one foot always drawn lower and the other passing it on either side, shows the same changes a side walk does, and the order does not witness it; a side walk is never read on the order. Before its gates, `local_cycle.order_word` leaves out frames whose contacts touch no column of anything standing on the lowest row in any frame, recorded in `off_ground`, so a dipping tail is not read as a foot and changing sides to count half a cycle as a whole, at the cost of leaving out feet lifted over columns where nothing ever stands. As a named limit, a tail hanging over the columns the feet stand on is still read as a foot, held only by the gates after the reading (the sliding check, the ground travelled, and the upper body's sway).- **Changed: standalone `video-cycle-align` stops on held or four-step cuts (`align.held_cut`).** `video-cycle-align` run on its own reads the cut report beside each loop through `align.held_cut(loop_dir, meta_path, meta)`. Where nothing witnessed the cut whole cycles (`cycle-unwitnessed`) or the cut spans four steps (`cycle-four-steps`), the loop is named under `held` and the aligner stops under `--multi-cycle fail` before rewriting any files, adding "and nothing witnessed some of the cuts whole cycles". Under `--multi-cycle warn` it aligns the loop with a warning, matching `video-set` instead of aligning held loops as one cycle without a word.- CLI: `video-loop --view front|back|side|front_diagonal|back_diagonal` (default none) sets the clip view for cycle detection and foot cue selection.-- Report fields: `cycle.step_count.cycles` (`{asked, interval, overlap, half, one, two, slack, cue, bob, cycles, unwitnessed, why}`, where `cue` and `bob` are recorded only where the picture passes, `cue: {range, floor, swapped, one, says, why}` only with a view, `one` absent where `says` is `"alike"`, `bob: {swing, rows, floor, twice, half, quarter, edge, body: {beat, lowest, sole, less_lowest, less_bands, still_bands, own, bands: {rows, width, zoom, beat, reads, less}, share, scale, least, scale_least, band_floor}, says, why}`, `half`, `quarter`, `edge` and `body` absent under the floors, `body` absent where under 8 frames are left, and `why` absent where it says `"cycles"`, and `unwitnessed` true only where nothing witnessed); the loop's warnings (`jolt.warnings`); `step_count.stands` and `step_count.run_limit`; `loop.retake` (`{reason: "start-stop", reasons, start_stop: {stands, run_limit, crossings, cut, verdict, code, why}, remedy: "retake"}`); the set report's item `loop.retake` (`{reason, reasons, remedy}`) and item `loop["cycle-unwitnessed"]` (`true`), and its state's `cycle_align.<state>.left_out` (`{item: reasons}`); the loop report's `cycle.cut_witness` (`{cut, says, by, lines, on, why, held, mark}`, `lines` (`{screen, feet}`, each `{says, bob, on, why}`), the feet line's `bob` and `on` with `over`, `by` only where it says a word, `on` with its `line` and `interval` only for four steps or one step, `why` only where `says` is null, `held` only where held, and `mark` only where marked); the printed summary's `cycle.cut_witness` (`{cut, says, by, held, mark}`, each where present). `cycle.step_count.cycles.order` and `cut_witness.order` record foot-order metrics (`apart`, `swing`, `floor`, `changes`, `slides`, `spacing`, `travel`, `sway`, `tilt`, `per`, `says`, `why`), and `video-cycle-align` reports held suspect loops under `held` with `{reason, report}`.+- Report fields: `cycle.step_count.cycles` (`{asked, interval, overlap, half, one, two, slack, cue, bob, cycles, unwitnessed, why}`, where `cue` and `bob` are recorded only where the picture passes, `cue: {range, floor, swapped, one, says, why}` only with a view, `one` absent where `says` is `"alike"`, `bob: {swing, rows, floor, twice, half, quarter, edge, body: {beat, lowest, sole, less_lowest, less_bands, still_bands, own, bands: {rows, width, zoom, beat, reads, less}, share, scale, least, scale_least, band_floor}, says, why}`, `half`, `quarter`, `edge` and `body` absent under the floors, `body` absent where under 8 frames are left, and `why` absent where it says `"cycles"`, and `unwitnessed` true only where nothing witnessed); the loop's warnings (`jolt.warnings`); `step_count.stands` and `step_count.run_limit`; `loop.retake` (`{reason: "start-stop", reasons, start_stop: {stands, run_limit, crossings, cut, verdict, code, why}, remedy: "retake"}`); the set report's item `loop.retake` (`{reason, reasons, remedy}`) and item `loop["cycle-unwitnessed"]` (`true`), and its state's `cycle_align.<state>.left_out` (`{item: reasons}`); the loop report's `cycle.cut_witness` (`{cut, says, by, lines, on, why, held, mark}`, `lines` (`{screen, feet}`, each `{says, bob, on, why}`), the feet line's `bob` and `on` with `over`, `by` only where it says a word, `on` with its `line` and `interval` only for four steps or one step, `why` only where `says` is null, `held` only where held, and `mark` only where marked); the printed summary's `cycle.cut_witness` (`{cut, says, by, held, mark}`, each where present). `cycle.step_count.cycles.order` and `cut_witness.order` record foot-order metrics (`apart`, `swing`, `floor`, `changes`, `slides`, `spacing`, `travel`, `sway`, `tilt`, `per`, `says`, `why`, `off_ground`), and `video-cycle-align` reports held suspect loops under `held` with `{reason, report}`.- Python callers: new `local_cycle.read_cycles(reading, distances, view=None, cue=None, cue_step=None, signals=None)`, `local_cycle.bob_word(signals, interval, feet=False)`, `local_cycle.twice_an_interval(values, interval)`, `local_cycle.own_beat(signals, interval)`, `local_cycle.cut_word(signals, length)`, `local_cycle.over_feet(signals, interval)`, `local_cycle.unwitnessed(cycle)`, `local_cycle.four_steps(cycle)`, `local_cycle.held_verdict(cycle)` (refuses with a `ValueError` a cut held on one step whose record names no line it was read on (no `by` or `lines`)), `legs.OPAQUE`, `local_cycle.BOB_OWN`, `local_cycle.BOB_SCALE`, `local_cycle.BEAT_FRAMES`, `legs.body_signals(frames)`, `legs.BANDS`, `legs.band_rows(median)`, `legs.band_widths(alpha, rows)`, `legs.zoomed(alpha, scale)`, `local_cycle.BAND_FLOOR`, `local_cycle.off_flow(values, interval)`, `local_cycle.cue_word(cue, interval, step=None)`, `local_cycle.BOB_TWICE`, `local_cycle.BOB_FLOOR`, `local_cycle.BOB_ROWS`, `local_cycle.CUT_LINES`, `local_cycle.CUT_WORDS`, `local_cycle.UNWITNESSED`, `local_cycle.FOUR_STEPS`, `local_cycle.CUE_FLOOR`, `legs.TONE`, `local_cycle.repeat_at(distances, span)`, `batch.anchor_for(state, cut, anchor)`, `batch.left_out_why(reasons, stands=False, one_step=False)`, `loop.stand_retake(cycle)`, `loop.retakes(*records)`, `loop.STAND_REASON`; `crossings._alternation` is now public `crossings.correlation_on(values, span)`; `align._feet`, `align._depth_cue`, `align._shade_cue`, and `align.SHADE_BAND` are moved to `legs.feet_halves`, `legs.depth_cue`, `legs.shade_cue`, and `legs.SHADE_BAND` (`align` keeps `_depth_cue` and `_shade_cue` aliases); `crossings.Reading` gains `interval`, `per`, `cycles`, `hides`, and `mark_cycles(said)`. `local_cycle.read_cycles` and `local_cycle.cut_word` take `order`, `cut_word` takes `declined`, and `align.held_cut` checks loop cut reports.- **Tests**: `tests/video/test_walk_steps.py` covers these synthetic walker cases (the walkers' bodies rise and fall on legs whose soles stay on the ground unless held still or drawn carried whole; the walkers whose body is witnessed (and those the cut's witness reads one step of) swing their arms within the body's sides, 8 px either way of its middle (`ARMS_IN`), the body's sides 28 px apart; the other walkers seen from the side, from behind or on a front diagonal swing them 16 px either way of the body's middle, past its sides; the walker seen from the front swings its arms up and down beside its body, and some walkers have no arms):- a walker seen from behind whose far foot hides behind the near one (feet together over half the interval) across cycles of 20 frames on twos, 24 on threes, and 17.5 and 18.5 on ones: its top line rises and falls twice an interval, cutting one cycle within a frame with `cycles` true, `steps: 2`, and no cue read with no view, its bob's `body.share` at least `0.3`, `body.scale` at least `0.6`, `edge` 0, every band seen holds still on the beat (`still_bands` equals the bands seen), and its `why` naming the body's own; the same walker with its far leg drawn as the near one (legs alike), with no view and with `--view back_diagonal`, is still cut to one cycle because the view's cue says `"alike"` (which no longer refuses) and the bob witnesses;@@ -65,6 +65,10 @@ All notable public changes to `sprite-gen` are recorded here. Versions track the- the walker from the side with legs drawn alike (46 frames, swinging leg lifted 6 px at pass) with no view and with `--view` front, front_diagonal, back, and back_diagonal: cut 46 frames, `steps` 2; crossing check has `cycles` false, `order.why` value stating a foot passes under the body; cut never stands on order.- the walker whose feet stay apart (cycle 30) tested across spans in `local_cycle.order_word`: spans of 30, 60, and 15 frames, `says` value "two steps", "four steps", and "one step", span 22 none, also checking that no foot slides and that the upper body's sway stays under `ORDER_SWAY` of the tilt; picture rocked 10 degrees either way about feet once a cycle, feet drawn level and still, `says` null, `why` value stating it may rock on its feet; the same walker drawn with its right foot sliding along the ground, planted, to meet the left as both stand level and back out, `says` null, `why` value stating a foot slides (the order is not read where a foot on the ground passes under the body toward the other side); lifted-foot side walker with legs 5 and 10 px either side of line, `says` null, `why` value stating a foot passes under the body; rear walker with soles on one row, `says` null, `why` value stating feet are drawn level.- the walker whose feet stay apart cut 20 frames, `--view front`, under `loop._witnessed`: cut stands on order, `by` `["order"]`; with step count `declined` record set: cut held, `cut_witness.held` "unwitnessed", `order.read` "two steps", `order.why` value stating order does not stand a length the closing refused.+ - the walker seen from the front whose feet stay apart (cycle 30 frames, body still), its feet meeting on the screen once a cycle, or once a step where `each_step` is set (the left foot swinging in to meet the right while drawn higher), drawn with a tail (`_dipping_tail`: from the hip to a tip 28 px to its left, rising and falling 8 px either way on a 17-frame beat of its own, dipping into the foot band about a third of the time, never as low as the feet nor over a column they stand on): `order_word` over 30 frames (meeting once a cycle) says "two steps", over 15 frames (once a cycle) and over 15 frames (once a step) "one step", what the same walker drawn without the tail says, never "two steps" where the walker holds one, with `off_ground` exactly the frames whose left side is the tail and no counted change falling on them (before: the tail's frames were read as feet, and over 30 frames the walker meeting once a cycle said nothing).+ - the 46-frame side walker lifting its swing foot 6 px, drawn with the tail 40 px behind: `off_ground` is the tail's frames, `says` is null and its why says a foot passes under the body (before: null as well, the tail's frames read as feet).+ - slow test of the walker meeting once a step with the tail, `--view front`: its crossings are never read as cycles, the cut witness stands a cut on the order (`by` `["order"]`) only where the cut is within 1.5 frames of the 30-frame cycle, and no cut under three quarters of the cycle is handed out without a warning naming it (before: `video-loop` stopped on the division by zero).+ - the walker meeting once a cycle (cycle 30, body still, no tail): `cut_word` returns on every cut length from 10 to 46 frames; on cuts of 25, 26, 34 and 35 frames it says null with a why containing "its top line holding still" (before: it stopped on cuts of 13, 17, 25, 26, 34 and 35 frames).- **Tests**: `tests/video/test_gait_guard_anchor_wide.py` and `tests/video/test_cycle_align.py` cover batch anchoring and cycle alignment:- `batch.anchor_for` assigns `motion-auto` to walk and run loops while assigning `none` to cheer, walk with `--anchor none`, and pinned idle items, propagating loop retakes to item records, warnings, and markdown tables;- `batch.align_gaits` excludes loops with a `start-stop` retake, a loop with `cycle-unwitnessed`, or a loop with both, names its reasons under `left_out` (`["start-stop"]`, `["cycle-unwitnessed"]`, `["start-stop", "cycle-unwitnessed"]`) and in the stderr warning, aligns remaining directions, and leaves the state unaligned when fewer than two directions remain.diff --git a/docs/loop-repair.md b/docs/loop-repair.mdindex b73c790..005ca21 100644--- a/docs/loop-repair.md+++ b/docs/loop-repair.md@@ -1389,7 +1389,12 @@ own". Where `less_bands` is under the largest of `BOB_OWN` (0.3) times `beat`, tless as much of the zoom as its band {a}% to {b}% of its height below its top reads, its top line'srise and fall twice an interval is {x} rows of {beat} ({percent}), {ratio} of the {less_lowest} leftagainst the lowest row (at least 30%, {floor} rows and 0.6): the picture may zoom with the body, and the-body's own is not told from it". Since every band's `less` is `less_lowest` times (1 - `reads`), this+body's own is not told from it". Where `beat` is zero, as for a body whose top line holds still on the+screen while only its lowest row rises and falls (a body that does not rise and fall whose foot drawn+nearer is drawn lower each step), `{percent}` now reads "its top line holding still"+(`local_cycle._share`). What the witness says is unchanged; before, `video-loop` stopped there on a+division by zero.+Since every band's `less` is `less_lowest` times (1 - `reads`), thishold catches every band seen that moves on the beat (its `reads` over 0.4): the body's own is witnessedonly where every band seen holds still on the beat and what is left is still at least 30% of `beat` andover the floor. Otherwise `says` `"cycles"`. A body rising and falling on its legs leaves its planted@@ -1588,7 +1593,16 @@ empty run the mean column of the upper half of the body lies. From the front, thnearer the viewer is drawn lower, and the nearer foot changes sides once a step, twice a cycle. Counted over acrossing interval or a cut, those changes say how many steps it holds. The view's label is not taken for it,because a generated walk's label may be wrong: the clip must show that its two sides of feet are its two legs, or-nothing is witnessed. `local_cycle.order_word(order, span)` tests the frames across a span through a sequence of+nothing is witnessed. Before its gates, `local_cycle.order_word(order, span)` leaves out+(`local_cycle._off_ground(order)`) every frame whose feet are read apart but either of whose two sides (its `left` or+`right` contact columns) shares or touches no column of anything standing on the lowest row (`ground`, the runs on+the lowest rows) in any frame of the clip, treating those frames as not seen apart. A foot is drawn over the ground+the walk stands on; a tail whose tip dips into the foot band beside the feet parts the band at its widest gap from+both feet and, read as a foot, puts the foot drawn lower on the side it is not and back again, changes of side that+no foot makes and that could count half a cycle as a whole where previously only subsequent gates held it by chance.+A foot lifted over columns where nothing ever stands is left out with those frames; the order then reads fewer+frames, never more.+`local_cycle.order_word(order, span)` tests the frames across a span through a sequence ofgates in order: the feet must be seen apart in at least `legs.FEET_APART_SHARE` (20 %) of the frames; the depth'sswing (10th to 90th percentile) must reach at least `ORDER_ROWS` (2) rows and `legs.REACH_MIN` (0.015) of theheight, or the feet are drawn level; each frame's lower side is read where one foot is at least an eighth of the@@ -1602,8 +1616,10 @@ swing times `ORDER_REACH`, 0.75, of the height, over the feet's distance apart),feet draws one foot lower and then the other. Then at least three changes are required, and their rate over thespan (the span over the mean distance between changes) must fall within `ORDER_SLACK` (0.2) of two, four, or one,with no two changes more than twice their mean apart (`ORDER_WORDS`), giving `"two steps"`, `"four steps"`, or-`"one step"`, or null with `why`. The record keeps `apart`, `swing`, `floor`, `changes`, `slides`, `spacing`,-`travel`, `sway`, `tilt`, `per`, `says`, and `why`. It is not read from the side (`--view side`,+`"one step"`, or null with `why`. The record keeps `apart` (the share of frames seen apart after leaving those frames+out), `swing`, `floor`, `changes`, `slides`, `spacing`, `travel`, `sway`, `tilt`, `per`, `says`, `why`, and+`off_ground` (the list of frames left out, present only where any frame is left out).+It is not read from the side (`--view side`,`local_cycle.SIDE_VIEW`), where the two sides of the feet are the front foot and the back foot rather than twolegs. In `local_cycle.read_cycles(..., order=None)`, `video-loop` passes `order=[legs.feet_order(f) for f inframes]`. After the foot cue's refusal and the body's word, where the body does not witness two steps an interval@@ -1616,6 +1632,8 @@ from the side). A diagonal walk whose feet pass each other on the screen, one foother passing it on either side, shows the same changes a side walk does (a planted foot sliding under the bodypast the other), and the order does not witness it: its crossings stay on steps or its cut is held, named. A sidewalk is never read on the order, and reading which foot passes in front of which on the screen is not done here.+As a named limit, a tail hanging over the columns the feet stand on is still read as a foot; the gates after the+reading (the sliding check, the ground travelled, the upper body's sway) are what hold it.**Choosing the cut.**