Skip to content

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

fix(video): the body's witness says why, never stops, where the top line it reads the body's own rise and fall on holds still on the screen

Soohong Kim796ed8bd6843
diff --git a/sprite_gen/video/local_cycle.py b/sprite_gen/video/local_cycle.py
index ca24fe1..ce1e4f6 100644
--- a/sprite_gen/video/local_cycle.py
+++ b/sprite_gen/video/local_cycle.py
@@ -695,6 +695,11 @@ def over_feet(signals, interval):
return lines[over], over
+def _share(rows, beat):
+ """`rows` as a share of the top line's rise and fall twice an interval (`beat`, `own_beat`), for a why: or, where
+ that is none, the top line holding still on the screen."""
+ return f"{rows/beat:.0%}" if beat else "its top line holding still"
+
def bob_word(signals, interval, *, feet=False):
"""Whether the body rises and falls twice an interval `interval` frames long (`read_cycles`), read off `signals`
(`legs.strike_signals` with `legs.body_signals`) without telling the legs apart. Its top line (`top`, in pixel rows)
@@ -758,7 +763,7 @@ def bob_word(signals, interval, *, feet=False):
if beat['less_lowest'] < max(BOB_OWN*beat['beat'], floor):
return {**word, 'says': None, 'why': f"its lowest row rises and falls with it: less the lowest row's, its top line's rise "
f"and fall twice an interval is {beat['less_lowest']:.1f} rows of {beat['beat']:.1f} "
- f"({beat['less_lowest']/beat['beat']:.0%}; at least {BOB_OWN:.0%} and {floor:.1f} "
+ f"({_share(beat['less_lowest'], beat['beat'])}; at least {BOB_OWN:.0%} and {floor:.1f} "
"rows): the picture moves with the body, and the body's own is not told from it"}
if beat['less_bands'] is None:
return {**word, 'says': None, 'why': f"no band of its upper body would show the picture zooming: zoomed in as far as "
@@ -771,7 +776,7 @@ def bob_word(signals, interval, *, feet=False):
return {**word, 'says': None, 'why': f"its upper body's width changes with it: less as much of the zoom as its band "
f"{a:.0%} to {b:.0%} of its height below its top reads, its top line's rise and fall "
f"twice an interval is {beat['less_bands']:.1f} rows of {beat['beat']:.1f} "
- f"({beat['less_bands']/beat['beat']:.0%}), {beat['less_bands']/beat['less_lowest']:.2f} "
+ f"({_share(beat['less_bands'], beat['beat'])}), {beat['less_bands']/beat['less_lowest']:.2f} "
f"of the {beat['less_lowest']:.1f} left against the lowest row (at least "
f"{BOB_OWN:.0%}, {floor:.1f} rows and {BOB_SCALE:g}): the picture may zoom with the "
"body, and the body's own is not told from it"}
diff --git a/tests/video/test_walk_steps.py b/tests/video/test_walk_steps.py
index fe18967..d75154b 100644
--- a/tests/video/test_walk_steps.py
+++ b/tests/video/test_walk_steps.py
@@ -1238,6 +1238,18 @@ def test_a_lowest_row_on_the_frames_last_row_holds_the_word():
assert word["says"] is None and word["edge"] == 1 and f"the frame's last row in 1 of {FRAMES} frames" in word["why"]
+def test_a_cut_of_a_body_whose_top_line_holds_still_says_why_whatever_its_length():
+ """The walker whose feet stay apart, its body still, a cycle 30 frames: its top line holds on the screen, and its
+ lowest row (the foot drawn nearer, lower) rises and falls once a step. Read over its feet on cuts of 10 to 46
+ frames, the line rises and falls as the lowest row does, and none of it is the top line's own: each cut says why
+ (the parent engine stopped there, dividing by that none, on cuts of 13, 17, 25, 26, 34 and 35 frames)."""
+ frames = [_apart(k, cycle=30) for k in range(FRAMES)]
+ signals = {**legs.strike_signals(frames), **legs.body_signals(frames)}
+ words = {length: local_cycle.cut_word(signals, length) for length in range(10, 47)}
+ still = [length for length, word in words.items() if "its top line holding still" in (word.get("why") or "")]
+ assert still == [25, 26, 34, 35] and all(words[length]["says"] is None for length in still)
+
+
# Walkers moved or zoomed with the whole picture, by their interval between crossings d: the side walker whose legs are
# drawn alike and wide, its crossings its steps (23 frames), and the walker seen from behind whose feet meet once a cycle
# (17.5); held still, carried up and down whole (feet and all, on the walk's beat), or rising and falling on its legs