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): a walk's body is witnessed rising and falling of its own only where a band of its upper body that a zoom so far would move a pixel holds still on the beat, each band's give measured on the body as drawn, so a picture zoomed on the beat over a pointed head, ears or a hat is no witness

Soohong Kim2b9bb138412d
diff --git a/sprite_gen/video/legs.py b/sprite_gen/video/legs.py
index 35cd421..302d8f9 100644
--- a/sprite_gen/video/legs.py
+++ b/sprite_gen/video/legs.py
@@ -14,16 +14,23 @@ Both read the same per-frame signals (`strike_signals`) and choose between them
- `top`: the body's top line, for a body with no legs to read. It rises and falls once a step
whichever leg leads, so the step count reads it as the witness that a crossing interval, or a
cut, holds two steps (`local_cycle.bob_word`, `local_cycle.cut_word`) — against the lowest row,
- the lowest opaque row and the head's width, since the picture moving or zoomed with the body
- moves the line as well.
+ the lowest opaque row and the widths of the upper body, since the picture moving or zoomed with
+ the body moves the line as well.
- `gap`: the widest empty run between the foot band's two ends, of the frame's height — two feet
seen apart.
-The step count's witness reads two more (`body_signals`), recorded nowhere else:
-
-- `crown`: the head's width, the log of the mean width (in alpha) of the band CROWN of the clip's
- median body height below the first solid row. A picture zoomed in and out widens and narrows
- it as it lifts and lowers the top line; a body rising and falling on its legs leaves it.
+The step count's witness reads more (`body_signals`), recorded nowhere else:
+
+- `bands`: the upper body's widths, the mean width (in alpha, pixels) of each band of BANDS, each
+ at its own depth below the first solid row, of the clip's median body height: from the top of
+ the head down to the middle of the body. A body rising and falling on its legs carries them
+ whole and leaves their widths; a picture zoomed in and out widens and narrows each as the top
+ line lifts and lowers, as far as its outline lets it: a band whose sides run straight down by
+ the zoom's whole part, a band across a top that widens as it goes down (a pointed head, an
+ ear's tip, a hat's point) by less, the band under a point by none. How far is measured, not
+ assumed (`zoomed`, `band_widths`): `band_rows` are the bands' rows below the first solid row,
+ and `median_frame` is the alpha of the frame whose body height is the clip's median, to be
+ zoomed as far as the beat the witness reads.
- `sole`: the lowest row with a pixel drawn fully opaque (alpha OPAQUE), or the lowest solid row
where a frame has none. A shadow is drawn translucent under the feet, solid all the same, and
it need not move with them: one drawn on the screen stays while the picture moves, and the
@@ -57,7 +64,9 @@ FOOT_BAND = 0.08 # fraction of the frame's own height, measured up from its low
LOW_ALPHA = 128 # the legs are read off solid pixels only
OPAQUE = 255 # drawn fully opaque: the feet, not a shadow drawn translucent under them
BODY_RUN = 0.5 # the body's top line: the first row at least half as wide as the frame's widest
-CROWN = (0.02, 0.10) # the head's top band: from 2 % to 10 % of the body's median height below its first solid row
+# The upper body's bands, each from and to these fractions of the body's median height below its first solid row: the
+# head's top band first, then down to the middle of the body, where the legs part.
+BANDS = ((0.02, 0.10), (0.10, 0.18), (0.18, 0.26), (0.26, 0.34), (0.34, 0.42), (0.42, 0.50))
# A walk seen from the side or a diagonal opens its feet by a good part of its height each step;
# from the front or back its foot band hardly changes width, but the foot nearer the viewer is
# drawn lower by a few hundredths of it.
@@ -115,11 +124,46 @@ def strike_signals(frames: list[Image.Image]) -> dict[str, list[float]]:
return out
-def body_signals(frames: list[Image.Image]) -> dict[str, list[float]]:
- """Per frame, from the solid pixels, what the step count's witness reads besides `strike_signals`:
- `crown`, `sole` and `edge` (see the module). `crown` reads the same band of every frame, of the
- clip's median body height."""
- edge, sole, firsts, heights, widths = [], [], [], [], []
+def band_rows(median: float) -> list[tuple[int, int]]:
+ """The rows of each band of BANDS below the first solid row of a body `median` rows tall, from and to (not
+ including), each at least a row."""
+ rows = []
+ for a, b in BANDS:
+ a0 = max(1, math.ceil(a * median))
+ rows.append((a0, max(a0 + 1, math.ceil(b * median))))
+ return rows
+
+
+def _row_widths(alpha: np.ndarray) -> tuple[int, np.ndarray]:
+ """(the first solid row, each row's width in alpha, pixels) of `alpha`."""
+ solid = np.nonzero((alpha >= LOW_ALPHA).any(axis=1))[0]
+ if solid.size == 0:
+ raise ValueError("a loop frame has no solid body")
+ return int(solid[0]), alpha.sum(axis=1, dtype=np.float64) / 255.0
+
+
+def _bands_of(y0: int, width: np.ndarray, rows: list[tuple[int, int]]) -> list[float]:
+ return [float(width[y0 + a0 : y0 + a1].sum() / (a1 - a0)) for a0, a1 in rows]
+
+
+def band_widths(alpha: np.ndarray, rows: list[tuple[int, int]]) -> list[float]:
+ """The mean width (in alpha, pixels) of each band `rows` (`band_rows`) below the first solid row of `alpha`."""
+ return _bands_of(*_row_widths(alpha), rows)
+
+
+def zoomed(alpha: np.ndarray, scale: float) -> np.ndarray:
+ """`alpha` zoomed in by `scale` (bilinear) on a canvas grown to hold it."""
+ im = Image.fromarray(np.asarray(alpha, dtype=np.uint8))
+ size = (math.ceil(im.width * scale), math.ceil(im.height * scale))
+ return np.asarray(im.transform(size, Image.Transform.AFFINE, (1 / scale, 0, 0, 0, 1 / scale, 0),
+ resample=Image.Resampling.BILINEAR))
+
+
+def body_signals(frames: list[Image.Image]) -> dict[str, Any]:
+ """From the solid pixels, what the step count's witness reads besides `strike_signals` (see the module): per
+ frame `bands`, `sole` and `edge`; and `band_rows` and `median_frame`. `bands` reads the same rows of every frame,
+ of the clip's median body height."""
+ edge, sole, heights, read = [], [], [], []
for f in frames:
alpha = np.asarray(f.getchannel("A"))
rows = np.nonzero((alpha >= LOW_ALPHA).any(axis=1))[0]
@@ -129,13 +173,14 @@ def body_signals(frames: list[Image.Image]) -> dict[str, list[float]]:
opaque = np.nonzero((alpha >= OPAQUE).any(axis=1))[0]
sole.append(float(opaque[-1] if opaque.size else y1))
edge.append(float(y1 == alpha.shape[0] - 1))
- firsts.append(y0)
heights.append(y1 - y0 + 1)
- widths.append(alpha.sum(axis=1, dtype=np.float64) / 255.0)
+ read.append(_row_widths(alpha))
median = float(np.median(heights)) if frames else 0.0
- a0, a1 = max(1, math.ceil(CROWN[0] * median)), max(2, math.ceil(CROWN[1] * median))
- crown = [float(np.log(max(1e-6, w[y0 + a0 : y0 + a1].sum() / (a1 - a0)))) for y0, w in zip(firsts, widths)]
- return {"crown": crown, "sole": sole, "edge": edge}
+ rows = band_rows(median)
+ middle = (np.asarray(frames[int(np.argmin([abs(h - median) for h in heights]))].getchannel("A")) if frames
+ else np.zeros((1, 1), np.uint8))
+ return {"bands": [_bands_of(y0, width, rows) for y0, width in read], "band_rows": rows, "median_frame": middle,
+ "sole": sole, "edge": edge}
def swings(sig: dict[str, list[float]]) -> dict[str, float]:
diff --git a/sprite_gen/video/local_cycle.py b/sprite_gen/video/local_cycle.py
index 17f19cd..36aed0f 100644
--- a/sprite_gen/video/local_cycle.py
+++ b/sprite_gen/video/local_cycle.py
@@ -19,6 +19,7 @@ import math
from sprite_gen._deps import np
from sprite_gen.video import period as period_mod
from sprite_gen.video import crossings as crossings_mod
+from sprite_gen.video import legs as legs_mod
from sprite_gen.video.crossings import HIDE_SHARE
REFUSED_SHOWN = 12 # refused windows a failed search reports, as many as a found cycle's candidates
@@ -54,21 +55,33 @@ CUE_FLOOR = 0.5
# the ground under them, and the line over its feet takes in the two feet's heights by turns, where the screen line
# has none of them.
# The picture moving up and down moves the line as the body does, on any beat — shaken twice an interval it is pixel for
-# pixel a body carried up and down whole, feet and all — and the picture zoomed in and out lifts and lowers it too. So the
-# line's rise and fall twice an interval (`twice_an_interval`) is read against the body's own lowest row and head
-# (`own_beat`): less the lowest solid row's (`legs.strike_signals` `reach`, the planted foot, which a body rising on its
-# legs leaves on the ground and the picture carries along), and less that again of the head's width's
-# (`legs.body_signals` `crown`, scaled to the body's median height: a zoom widens the head as it lifts the line, a body
-# rising leaves it). What is left of the line's rise and fall either way is the body's own: at least BOB_OWN of it and
-# over the floor above, and the head's width taking it down to no less than BOB_SCALE of what is left against the lowest
-# row. Else the picture moves or zooms with the line, or the body does not rise and fall enough of its own to tell from
-# it, and nothing is witnessed. Where the lowest solid row is the frame's last row in any frame (`legs.body_signals`
-# `edge`) it is the frame's, not the feet's, and nothing is witnessed either.
+# pixel a body carried up and down whole, feet and all — and the picture zoomed in and out lifts and lowers it too. So
+# the line's rise and fall twice an interval (`twice_an_interval`) is read against the body's own lowest row and upper
+# body (`own_beat`): less the lowest solid row's (`legs.strike_signals` `reach`, the planted foot, which a body rising
+# on its legs leaves on the ground and the picture carries along), and less that again of the zoom each band of the
+# upper body reads (`legs.body_signals` `bands`: a body rising on its legs carries them whole and leaves their widths; a
+# zoom widens each as it lifts the line, as far as the band's outline lets it — one whose sides run straight down by the
+# zoom's whole part, one under a point, as of a pointed head, an ear or a hat, by none). How far a zoom moves each band
+# is measured on the body as it is drawn, not assumed of its outline: the frame of its median height zoomed in as far as
+# the line's rise and fall against the lowest row lengthens the body (`legs.zoomed`). A band such a zoom moves
+# BAND_FLOOR pixels or more is seen; under a pixel, how far a band's width moves is set as much by how its outline sits
+# on the pixel grid (its first solid row rounded, a point's edges blurred) as by the zoom — a pointed head's top band,
+# zoomed in once, may move most of a pixel and, zoomed so on the beat, a quarter of one — and one moved less reads none.
+# A body rising and falling so little that no band would move a pixel is not told from a zoom. A band seen holds still
+# on the beat where its width rises and falls twice an interval by no more than 1 - BOB_SCALE of what that zoom moves
+# it. The witness holds by default: where no band is seen, or none seen holds still, nothing tells the picture zooming
+# from the body's own, and nothing is witnessed — a band its parts swing across on the beat, as arms do, moves as much
+# as a zoom might. What is left of the line's rise and fall is the body's own where, against the lowest row, it is at
+# least BOB_OWN of it and over the floor above, and less the zoom each band seen reads, it is so again and no less than
+# BOB_SCALE of what is left against the lowest row. Else the picture moves or zooms with the line, or the body does not
+# rise and fall enough of its own to tell from it, and nothing is witnessed. Where the lowest solid row is the frame's
+# last row in any frame (`legs.body_signals` `edge`) it is the frame's, not the feet's, and nothing is witnessed either.
BOB_TWICE = 0.28
BOB_FLOOR = 0.005
BOB_ROWS = 2
BOB_OWN = 0.3
BOB_SCALE = 0.6
+BAND_FLOOR = 1.0 # pixels of a band's mean width a zoom moves: under it the pixel grid moves the band as much
BEAT_FRAMES = 8 # a rise and fall twice an interval is fitted (`twice_an_interval`) to no fewer frames
# The lines a walk's cut is read on (`cut_word`), and where each reads the body's top line: on the screen, and over its
# feet (`over_feet`). Each says its own word; the cut's is the first either says, in CUT_WORDS' order.
@@ -602,21 +615,40 @@ def twice_an_interval(values, interval):
def own_beat(signals, interval):
"""The body's own rise and fall twice an interval `interval` frames long (`bob_word`), read off `signals`
- (`legs.strike_signals` `top`, `reach` and `height`, `legs.body_signals` `crown` and `sole`) as `twice_an_interval`
- reads each: the top line's, less the lowest row's (the picture moving taken out) — the lowest solid row's or the
- lowest opaque row's, whichever leaves less: a shadow drawn translucent under the feet and fixed on the screen is the
- lowest solid row and does not move with the picture, the feet do — and less that again of the head's width's scaled
- to the body's median height (the picture zooming taken out). Returns, in rows up and down: `beat` (the top line's),
- `lowest`, `sole`, `head`, `less_lowest`, `less_head`, and `own`, the smaller of the last two. None where a line is
- not read."""
+ (`legs.strike_signals` `top`, `reach` and `height`, `legs.body_signals`) as `twice_an_interval` reads each: the top
+ line's, less the lowest row's (the picture moving taken out) — the lowest solid row's or the lowest opaque row's,
+ whichever leaves less: a shadow drawn translucent under the feet and fixed on the screen is the lowest solid row and
+ does not move with the picture, the feet do — and, band by band of the upper body (`legs.body_signals` `bands`),
+ less the zoom that band's width reads (the picture zooming taken out). A band reads a zoom as far as one moves it:
+ the frame of the body's median height (`median_frame`) zoomed in as far as the line's rise and fall left against
+ the lowest row lengthens the body (`legs.zoomed`) moves the band's width `zoom` pixels; a band it moves under
+ BAND_FLOOR pixels is not seen, and reads nothing. A band seen holds still on the beat where its width rises and
+ falls twice an interval no more than 1 - BOB_SCALE of `zoom`: whatever the turn of that, less it no less than
+ BOB_SCALE of the line's rise and fall is left. Returns, in rows up and down: `beat` (the top line's), `lowest`,
+ `sole`, `less_lowest`, `bands` (per band: its `rows` below the first solid row, its `width` in the median frame and
+ `zoom`, in pixels; `beat`, its width's rise and fall twice an interval, in pixels up and down; where it is seen,
+ `reads`, `beat` of `zoom` — the share of the zoom making the line's rise and fall it reads — and `less`, what is
+ left of the line's rise and fall less that zoom, else None), `less_bands`, the least `less` (None where no band is
+ seen), `still_bands`, the bands seen that hold still on the beat, and `own`, the smaller of `less_lowest` and
+ `less_bands`. None where a line is not read."""
height = float(np.median(signals['height']))
- top, lowest, sole, crown = (twice_an_interval(signals[k], interval) for k in ('top', 'reach', 'sole', 'crown'))
- if top is None or lowest is None or sole is None or crown is None:
+ top, lowest, sole = (twice_an_interval(signals[k], interval) for k in ('top', 'reach', 'sole'))
+ if top is None or lowest is None or sole is None:
return None
- less_lowest = min(top - lowest, top - sole, key=abs)
- less_head = less_lowest + height*crown
- return {'beat': 2*abs(top), 'lowest': 2*abs(lowest), 'sole': 2*abs(sole), 'head': 2*height*abs(crown),
- 'less_lowest': 2*abs(less_lowest), 'less_head': 2*abs(less_head), 'own': 2*min(abs(less_lowest), abs(less_head))}
+ left = min(top - lowest, top - sole, key=abs)
+ rows, still = signals['band_rows'], signals['median_frame']
+ widths = legs_mod.band_widths(still, rows)
+ zoom = [z - w for z, w in zip(legs_mod.band_widths(legs_mod.zoomed(still, 1 + 2*abs(left)/height), rows), widths)]
+ beats = [twice_an_interval([f[b] for f in signals['bands']], interval) for b in range(len(rows))]
+ seen = [abs(z) >= BAND_FLOOR for z in zoom]
+ less = [2*abs(left + beat*2*abs(left)/z) if s else None for z, beat, s in zip(zoom, beats, seen)]
+ reads = [2*abs(beat)/abs(z) if s else None for z, beat, s in zip(zoom, beats, seen)]
+ less_bands = min((v for v in less if v is not None), default=None)
+ return {'beat': 2*abs(top), 'lowest': 2*abs(lowest), 'sole': 2*abs(sole), 'less_lowest': 2*abs(left),
+ 'bands': {'rows': [list(r) for r in rows], 'width': widths, 'zoom': zoom, 'beat': [2*abs(b) for b in beats],
+ 'reads': reads, 'less': less},
+ 'less_bands': less_bands, 'still_bands': sum(1 for r in reads if r is not None and r <= 1 - BOB_SCALE),
+ 'own': 2*abs(left) if less_bands is None else min(2*abs(left), less_bands)}
def over_feet(signals, interval):
@@ -639,13 +671,17 @@ def bob_word(signals, interval, *, feet=False):
and -BOB_TWICE or under here): it rises and falls twice an interval. With `feet`, the line so read is the top line
over the lowest row (`over_feet`), the picture's moving taken out first (`cut_word`: the picture moving once a cut,
which `off_flow` leaves whole, would hide the rise and fall twice it). And that rise and fall is the body's own
- (`own_beat`): what is left of it against the lowest row (solid or opaque, whichever leaves less), and against the
- head's width as well, is at least BOB_OWN of it and over the floor, the head's width taking it down to no less than
- BOB_SCALE of what is left against the lowest row, and no frame's lowest row is its last (`edge`). Then `says`
- `cycles` — a step each rise, two steps an interval; None otherwise, with why. Returns the record: `swing` (the line
- left's range, of the body's height), `rows` (in rows), `floor`, `twice`, `over` (with `feet`: the row the line is
- read over), `half` and `quarter` (where read), `edge` (frames whose lowest row is their last), `body` (`own_beat`,
- in rows up and down, with `share`, `own` of `beat`, and `scale`, `less_head` of `less_lowest`; where read), `says`."""
+ (`own_beat`): what is left of it against the lowest row (solid or opaque, whichever leaves less) is at least BOB_OWN
+ of it and over the floor; a band of the upper body would show the picture zooming as far as that (seen, BAND_FLOOR
+ pixels or more), and less the zoom each band seen reads, as much is left again, and no less than BOB_SCALE of what
+ is left against the lowest row; a band seen holds still on the beat; and no frame's lowest row is its last (`edge`).
+ Held by default: where no band is seen, or none seen holds still (its parts swinging on the beat, as arms do, or the
+ picture zooming), the body's own is not told from a zoom, and nothing is witnessed. Then `says` `cycles` — a step
+ each rise, two steps an interval; None otherwise, with why. Returns the record: `swing` (the line left's range, of
+ the body's height), `rows` (in rows), `floor`, `twice`, `over` (with `feet`: the row the line is read over), `half`
+ and `quarter` (where read), `edge` (frames whose lowest row is their last), `body` (`own_beat`, in rows up and down,
+ with `share`, `own` of `beat`, and `scale`, `less_bands` of `less_lowest`, None where no band is seen; where read),
+ `says`."""
height = float(np.median(signals['height']))
line, what, extent = signals['top'], "its top line", "its top line's range"
word = {}
@@ -667,10 +703,14 @@ def bob_word(signals, interval, *, feet=False):
beat = own_beat(signals, interval)
word.update(half=None if half is None else round(half, 3), quarter=None if quarter is None else round(quarter, 3), edge=edge)
if beat is not None:
- word['body'] = {**{k: round(v, 2) for k, v in beat.items()},
+ bands = beat['bands']
+ word['body'] = {**{k: None if v is None else round(v, 2) for k, v in beat.items() if k != 'bands'},
+ 'bands': {'rows': bands['rows'], **{k: [None if v is None else round(v, 2) for v in bands[k]]
+ for k in ('width', 'zoom', 'beat', 'reads', 'less')}},
'share': round(beat['own']/beat['beat'], 3) if beat['beat'] else 0.0,
- 'scale': round(beat['less_head']/beat['less_lowest'], 3) if beat['less_lowest'] else 0.0,
- 'least': BOB_OWN, 'scale_least': BOB_SCALE}
+ 'scale': (None if beat['less_bands'] is None else
+ round(beat['less_bands']/beat['less_lowest'], 3) if beat['less_lowest'] else 0.0),
+ 'least': BOB_OWN, 'scale_least': BOB_SCALE, 'band_floor': BAND_FLOOR}
if half is None or quarter is None or half < BOB_TWICE or quarter > -BOB_TWICE:
return {**word, 'says': None, 'why': f"{what} less its flow does not rise and fall twice an interval "
f"({'not read' if half is None else f'{half:+.2f}'} half an interval on, "
@@ -681,20 +721,35 @@ def bob_word(signals, interval, *, feet=False):
"the feet may run off the frame, and the picture moving is not read off them"}
if beat is None:
return {**word, 'says': None, 'why': f"its top line's rise and fall twice an interval is not read against its lowest row "
- f"and head: under {BEAT_FRAMES} frames are left less the flow"}
+ f"and upper body: under {BEAT_FRAMES} frames are left less the flow"}
floor = max(BOB_ROWS, BOB_FLOOR*height)
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} "
"rows): the picture moves with the body, and the body's own is not told from it"}
- if beat['less_head'] < max(BOB_OWN*beat['beat'], floor, BOB_SCALE*beat['less_lowest']):
- return {**word, 'says': None, 'why': f"its head's width changes with it: less the head's scale too, its top line's rise "
- f"and fall twice an interval is {beat['less_head']:.1f} rows of {beat['beat']:.1f} "
- f"({beat['less_head']/beat['beat']:.0%}), {beat['less_head']/beat['less_lowest']:.2f} "
+ 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 "
+ f"its top line rises and falls twice an interval against its lowest row "
+ f"({beat['less_lowest']:.1f} rows of {height:.0f}), no band's width moves "
+ f"{BAND_FLOOR:g} px (at most {max(abs(z) for z in beat['bands']['zoom']):.2f}): "
+ "the picture zooming with the body is not told from the body's own"}
+ if beat['less_bands'] < max(BOB_OWN*beat['beat'], floor, BOB_SCALE*beat['less_lowest']):
+ a, b = legs_mod.BANDS[beat['bands']['less'].index(beat['less_bands'])]
+ return {**word, 'says': None, 'why': f"its upper body's width changes with it: less the zoom its band {a:.0%} to {b:.0%} "
+ f"of its height below its top reads, its top line's rise and fall twice an interval "
+ f"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"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 zooms with the body, "
"and the body's own is not told from it"}
+ if not beat['still_bands']:
+ r, i = min((r, i) for i, r in enumerate(beat['bands']['reads']) if r is not None)
+ a, b = legs_mod.BANDS[i]
+ return {**word, 'says': None, 'why': f"no band of its upper body holds still with it: each band a zoom so far would "
+ f"move {BAND_FLOOR:g} px or more rises and falls twice an interval by more than "
+ f"{1 - BOB_SCALE:.0%} of that (the least, its band {a:.0%} to {b:.0%} of its height "
+ f"below its top, {r:.0%}): the picture zooming is not told from the body's own"}
return {**word, 'says': 'cycles'}
@@ -712,11 +767,11 @@ def read_cycles(reading, distances, *, view=None, cue=None, cue_step=None, signa
cycles only where a witness that reads no leg says the interval holds two steps — the body's top line (`signals`,
`legs.strike_signals` with `legs.body_signals`) rising and falling twice an interval, less its flow and of its own
(`bob_word`: the picture drifting, swaying, shaking or zooming up and down as it pleases witnesses nothing, read
- against the lowest row and the head's width; a lowest row on the frame's edge holds the word). The view's foot cue
- (`cue`, per frame, drawn in steps of `cue_step`; `cue_word`) only refuses: where it turns over one interval on, the other leg leads
- there, a step. With no witness the crossings stay on steps, as from the side, and the record names it
- (`unwitnessed`): where the feet do meet once a cycle, each step counted is a cycle. Returns what was read, None
- where it is not asked."""
+ against the lowest row and the widths of the upper body; a lowest row on the frame's edge holds the word). The
+ view's foot cue (`cue`, per frame, drawn in steps of `cue_step`; `cue_word`) only refuses: where it turns over one
+ interval on, the other leg leads there, a step. With no witness the crossings stay on steps, as from the side, and
+ the record names it (`unwitnessed`): where the feet do meet once a cycle, each step counted is a cycle. Returns
+ what was read, None where it is not asked."""
if reading.mode != 'gap' or not reading.readable:
return None
overlap, hides = reading.overlap, reading.hides
@@ -747,7 +802,8 @@ def read_cycles(reading, distances, *, view=None, cue=None, cue_step=None, signa
said.update(cycles=True, why=f"{picture}, and the body's top line less its flow rises and falls twice an interval "
f"({bob['half']:+.2f} half an interval on, at least {BOB_TWICE:+g}; {bob['quarter']:+.2f} a "
f"quarter on, at most {-BOB_TWICE:+g}), the body's own ({bob['body']['own']:.1f} rows of "
- f"{bob['body']['beat']:.1f} left against its lowest row and head, {bob['body']['share']:.0%}; "
+ f"{bob['body']['beat']:.1f} left against its lowest row and upper body, "
+ f"{bob['body']['share']:.0%}; "
f"at least {BOB_OWN:.0%}): two steps an interval, the feet meet once a cycle")
else:
said.update(cycles=False, unwitnessed=True,
diff --git a/tests/video/test_walk_steps.py b/tests/video/test_walk_steps.py
index aeacc1a..f85959f 100644
--- a/tests/video/test_walk_steps.py
+++ b/tests/video/test_walk_steps.py
@@ -12,22 +12,22 @@ Each walker is drawn so the pixel search alone makes one of the faults a walk lo
- a slow front walk in a short clip, refused outright (no periodic cycle found);
- a walk that stalls, its cut playing the stalled step.
-Two whose feet meet on the screen once a cycle, read as cycles (`local_cycle.read_cycles`) and cut one cycle, their
-body rising and falling twice an interval between crossings on legs whose feet stay on the ground — the witness that
-reads no leg, read against the lowest row and the head's width: a walk seen from behind whose far foot passes hidden
+Two whose feet meet on the screen once a cycle, read as cycles (`local_cycle.read_cycles`) and cut one cycle, their body
+rising and falling twice an interval between crossings on legs whose feet stay on the ground — the witness that reads no
+leg, read against the lowest row and the widths of the upper body: a walk seen from behind whose far foot passes hidden
behind the near one, on ones, twos or threes, a cycle a whole number of frames or not, its legs drawn apart or alike
(the parent engine counted the cycle one step and cut two cycles, or kept the search's cut unwritten); and a walk on a
front diagonal whose near foot steps out toward the camera and passes the far one apart, read so where its view is
given. The guards: from the side, and where the view's foot cue says the other leg leads an interval on, the count
stands however alike a step on draws; and where nothing that reads no leg witnesses two steps an interval — legs drawn
alike from any view, alike and wide as a hidden pass is, alike and wide under a light fixed on the screen, the swing
-foot lifted under such a light, a far leg a few tones off with no view, a walk whose feet do meet once a cycle but
-whose body does not bob, the same walk carried up and down whole, feet and all (the picture moved on its beat), a body
-held still on a picture shaken twice an interval, and feet that run off the frame — the crossings stay on steps,
-named in a warning. Read off drawn frames, no walk that does not rise and fall twice an interval on its legs is
-witnessed however the whole picture moves or zooms, on any beat, nor a run whose feet leave the ground, nor a planted
-foot sliding down the screen. And one the count alone gets wrong, where the search's cut stands: a walk on threes whose
-tail closes on no cut of two steps.
+foot lifted under such a light, a far leg a few tones off with no view, a walk whose feet do meet once a cycle but whose
+body does not bob, the same walk carried up and down whole, feet and all (the picture moved on its beat), a body held
+still on a picture shaken twice an interval, and feet that run off the frame — the crossings stay on steps, named in a
+warning. Read off drawn frames, no walk that does not rise and fall twice an interval on its legs is witnessed however
+the whole picture moves or zooms, on any beat, whatever the top of its head (flat, round, a point, two ears' tips), nor
+a run whose feet leave the ground, nor a planted foot sliding down the screen. And one the count alone gets wrong, where
+the search's cut stands: a walk on threes whose tail closes on no cut of two steps.
A walk the search already cuts two steps long, joined at the walk's own point, is cut exactly as before; a body
whose feet cannot be read is cut as before. Synthetic frames only."""
@@ -95,13 +95,15 @@ def _front(k: float, *, cycle: float, phase: float = 0, tail_cycle: float = 1, t
return im
-def _behind(k: int, *, cycle: float, hold: int, alike: bool = False, bob: int = 3, whole: bool = False) -> Image.Image:
+def _behind(k: int, *, cycle: float, hold: int, alike: bool = False, bob: int = 3, whole: bool = False,
+ top: str = "flat") -> Image.Image:
"""A walker seen from behind on a diagonal, drawn on twos or threes (`hold`): the near leg swings ahead and back,
and the far one is seen beside it only while it is behind — ahead, it stands hidden behind the near leg. The feet
are seen apart once a cycle and together through the other step, its pass hidden among them: one crossing shows a
cycle. The body rises and falls `bob` px once a step on its legs, the feet on the ground (`whole`: carried up and
down with it, feet and all — the picture moved, not a walk); the far leg darker (`alike`: drawn as the near one);
- arms opposite, the far one darker; each repeat of a drawing redrawn a little (a pixel aside, a few tones)."""
+ arms opposite, the far one darker; each repeat of a drawing redrawn a little (a pixel aside, a few tones). Its head's
+ top is `top` (`_head`)."""
redraw = k % hold
ph = 2 * math.pi * (k - redraw) / cycle
im = Image.new("RGBA", (300, 220))
@@ -115,7 +117,7 @@ def _behind(k: int, *, cycle: float, hold: int, alike: bool = False, bob: int =
d.rectangle((far - 5, y + 80, far + 5, sole), fill=(70, 70, 80, 255) if alike else (50, 50, 60, 255))
d.rectangle((near - 5, y + 80, near + 5, sole), fill=(70, 70, 80, 255))
d.rectangle((x, y + 30, x + 28, y + 84), fill=(200 + 12 * redraw, 80, 80, 255))
- d.rectangle((x + 2, y, x + 26, y + 28), fill=(230, 200, 170, 255))
+ _head(d, x, y, top)
d.rectangle((x + 14 + sw - 4, y + 34, x + 14 + sw + 4, y + 72), fill=(225, 225, 225, 255))
return im
@@ -143,7 +145,7 @@ def _outward(k: float, *, cycle: float, bob: int = 3, whole: bool = False) -> Im
def _alike(k: float, *, cycle: float, phase: float = 0, tone: int = 1, lean: float = 0, leg_tone: int | None = None,
leg_half: int = 5, lift: int = 0, light: tuple[str, int] | None = None, bob: int = 3, whole: bool = False,
- air: int = 0, slide: int = 0, limp: int = 0) -> Image.Image:
+ air: int = 0, slide: int = 0, limp: int = 0, top: str = "flat") -> Image.Image:
"""A side walker whose two steps are the same silhouette: the far leg and arm `tone` tones lighter than the near
ones (the far leg `leg_tone`, where given: 0 draws the legs alike), the arms swinging `lean` px further back than
forward — nothing else tells a step from the next. Each leg is drawn `leg_half` px either side of its line: at 10
@@ -153,7 +155,7 @@ def _alike(k: float, *, cycle: float, phase: float = 0, tone: int = 1, lean: flo
it). A run lifts both soles up to `air` px off the ground while the body is high; a view from behind or a diagonal
draws each sole up to `slide` px lower the further back its foot is (the planted foot sliding down the screen
through its step). A limp sinks the body `limp` px either way once a cycle, low on one leg's step, high on the
- other's."""
+ other's. Its head's top is `top` (`_head`)."""
ph = 2 * math.pi * (k + phase) / cycle
im = Image.new("RGBA", (300, 220))
d = ImageDraw.Draw(im)
@@ -171,10 +173,34 @@ def _alike(k: float, *, cycle: float, phase: float = 0, tone: int = 1, lean: flo
ImageDraw.Draw(drawn).rectangle(box, fill=255)
d.rectangle((x, y + 30, x + 28, y + 84), fill=(200, 80, 80, 255))
ImageDraw.Draw(drawn).rectangle((x, y + 30, x + 28, y + 84), fill=0)
- d.rectangle((x + 2, y, x + 26, y + 28), fill=(230, 200, 170, 255))
+ _head(d, x, y, top)
return _lit(im, drawn, light)
+TOPS = ("flat", "round", "pointed", "ears")
+
+
+def _head(d: ImageDraw.ImageDraw, x: int, y: int, top: str = "flat") -> None:
+ """The head of a walker whose body's box starts at (x, y), its top `top` (TOPS): `flat`, the box every walker here
+ draws; `round`, an ellipse in that box; `pointed`, a triangle from a point over the box's middle down to a base
+ wider than the body; `ears`, the box from a third of the way down with an ear's tip over each corner. A zoom widens
+ a band across a flat top by its whole part, across a round one by part of it, and across a point or an ear's tip by
+ nothing."""
+ skin = (230, 200, 170, 255)
+ if top == "flat":
+ d.rectangle((x + 2, y, x + 26, y + 28), fill=skin)
+ elif top == "round":
+ d.ellipse((x + 2, y, x + 26, y + 28), fill=skin)
+ elif top == "pointed":
+ d.polygon(((x + 14, y), (x - 21, y + 28), (x + 49, y + 28)), fill=skin)
+ elif top == "ears":
+ d.rectangle((x + 2, y + 10, x + 26, y + 28), fill=skin)
+ d.polygon(((x + 4, y), (x + 2, y + 10), (x + 11, y + 10)), fill=skin)
+ d.polygon(((x + 24, y), (x + 17, y + 10), (x + 26, y + 10)), fill=skin)
+ else:
+ raise ValueError(top)
+
+
def _lit(im: Image.Image, legs_drawn: Image.Image, light: tuple[str, int] | None) -> Image.Image:
"""`im` under a light fixed on the screen, laid over the pixels drawn as legs (`legs_drawn`), both legs alike:
`("x", n)` up to n tones lighter to the right across the feet, `("y", n)` up to n tones lighter lower down the legs.
@@ -741,15 +767,27 @@ def _reading(run: int) -> crossings.Reading:
runs=[(c - run // 2, c + run // 2) for c in middles])
-def _body(top, *, lowest=None, crown=None, edge=None, sole=None) -> dict:
+def _column(outline: str = "straight") -> np.ndarray:
+ """The alpha of a body 100 rows tall from row 40: its sides running straight down 20 px apart (`straight`), or a
+ cone from a point at its top, 20 px wide at its middle (`cone`)."""
+ frame = np.zeros((200, 120), np.uint8)
+ for r in range(100):
+ half = 10 if outline == "straight" else max(1, round(r / 5))
+ frame[40 + r, 60 - half:60 + half] = 255
+ return frame
+
+
+def _body(top, *, lowest=None, width=None, edge=None, sole=None, outline="straight") -> dict:
"""Leg signals (`legs.strike_signals`, `legs.body_signals`) of a body 100 rows tall whose top line is `top` (per
frame), its lowest row `lowest` (140 throughout: the feet on the ground), its lowest opaque row `sole` (the lowest
- row's: nothing translucent under the feet) and its head `crown` wide (log; 20 px throughout), no lowest row on the
- frame's last row unless `edge` says where."""
+ row's: nothing translucent under the feet) and each band of its upper body `width` wide (px; 20 throughout), drawn
+ as `_column` draws its `outline`, no lowest row on the frame's last row unless `edge` says where."""
n = len(top)
reach = [140.0] * n if lowest is None else [float(v) for v in lowest]
+ rows = legs.band_rows(100)
+ widths = [20.0] * n if width is None else [float(v) for v in width]
return {"top": [float(v) for v in top], "reach": reach, "sole": list(reach) if sole is None else [float(v) for v in sole],
- "crown": [math.log(20)] * n if crown is None else [float(v) for v in crown],
+ "bands": [[w] * len(rows) for w in widths], "band_rows": rows, "median_frame": _column(outline),
"edge": [0.0] * n if edge is None else [float(v) for v in edge], "height": [100.0] * n}
@@ -991,20 +1029,57 @@ def test_a_rise_and_fall_the_lowest_row_shares_is_the_picture_moving(motion):
@pytest.mark.parametrize("about", ["feet", "middle"])
-def test_a_rise_and_fall_the_heads_width_shares_is_the_picture_zooming(about):
- """`bob_word` on an interval of 15 frames: a body 100 rows tall, zoomed in and out with the picture twice an interval
- about its feet (3 % either way: its top line rising and falling 3 rows, its lowest row still) or about its middle
- (6 %: the top line and the lowest row 3 rows either way, turned over from each other). Against the lowest row the top
- line rises and falls as a body on its legs would, but its head widens as the line lifts, as much as the body's
- height grows: less the head's scale nothing is left. The picture zooms; nothing is witnessed."""
+def test_a_rise_and_fall_the_upper_bodys_width_shares_is_the_picture_zooming(about):
+ """`bob_word` on an interval of 15 frames: a body 100 rows tall, its sides running straight down, zoomed in and out
+ with the picture twice an interval about its feet (3 % either way: its top line rising and falling 3 rows, its
+ lowest row still) or about its middle (6 %: the top line and the lowest row 3 rows either way, turned over from each
+ other). Against the lowest row the top line rises and falls as a body on its legs would, but every band of its upper
+ body widens as the line lifts, as much as a zoom so far would widen it: less the zoom each reads nothing is left.
+ The picture zooms; nothing is witnessed."""
t = np.arange(FRAMES)
f = 1 + (0.03 if about == "feet" else 0.06) * np.sin(2 * np.pi * t / 7.5)
at = 140 if about == "feet" else 90
top, lowest = np.round(at - (at - 40) * f), np.round(at + (140 - at) * f)
- word = local_cycle.bob_word({**_body(top, lowest=lowest, crown=np.log(20 * f)), "height": list(100 * f)}, 15)
+ word = local_cycle.bob_word({**_body(top, lowest=lowest, width=20 * f), "height": list(100 * f)}, 15)
assert word["half"] >= local_cycle.BOB_TWICE and word["quarter"] <= -local_cycle.BOB_TWICE
assert word["says"] is None and word["body"]["scale"] < local_cycle.BOB_SCALE
- assert "its head's width changes with it" in word["why"] and "the picture zooms with the body" in word["why"]
+ assert all(z >= local_cycle.BAND_FLOOR for z in word["body"]["bands"]["zoom"])
+ assert "its upper body's width changes with it" in word["why"] and "the picture zooms with the body" in word["why"]
+
+
+def test_a_body_no_band_of_which_would_show_a_zoom_is_never_witnessed():
+ """A top line rising and falling twice an interval on legs whose feet stay on the ground witnesses two steps an
+ interval on a body whose sides run straight down; on a cone from a point at its top, the same line does not: a zoom
+ as far as the line rises and falls would move no band of it a pixel (each band's width at its depth is the same
+ zoomed), so its width could not tell the picture zooming from the body's own. Held by default, the word says why."""
+ t = np.arange(FRAMES)
+ top = np.round(40 + 3 * np.cos(2 * np.pi * t / 7.5))
+ straight = local_cycle.bob_word(_body(top), 15)
+ assert straight["says"] == "cycles" and straight["body"]["scale"] == pytest.approx(1)
+ rows = legs.band_rows(100)
+ cone = local_cycle.bob_word({**_body(top, outline="cone"), "bands": [legs.band_widths(_column("cone"), rows)] * FRAMES}, 15)
+ assert cone["says"] is None and cone["body"]["less_bands"] is None and cone["body"]["scale"] is None
+ assert all(abs(z) < local_cycle.BAND_FLOOR for z in cone["body"]["bands"]["zoom"])
+ assert "no band of its upper body would show the picture zooming" in cone["why"]
+
+
+def test_a_body_no_band_of_which_holds_still_on_the_beat_is_never_witnessed():
+ """A top line rising and falling 3 rows either way twice an interval on legs whose feet stay on the ground, the
+ body's sides running straight down, every band of its upper body widening and narrowing 2 px either way twice an
+ interval a quarter of the beat on — as arms swinging across them do, or a zoom whose turn the line hides: more than
+ a zoom so far would move them, and at no turn that zoom takes the line's rise and fall down. Nothing holds still
+ to tell the body's own from a zoom: held by default, the word says why. With the band across its head's top
+ holding still, the rest swinging so, the body's own is told: two steps an interval."""
+ t = np.arange(FRAMES)
+ top = np.round(40 + 3 * np.cos(2 * np.pi * t / 7.5))
+ swing = list(20 + 2 * np.cos(2 * np.pi * t / 7.5 + np.pi / 2))
+ rows = legs.band_rows(100)
+ word = local_cycle.bob_word({**_body(top), "bands": [[w] * len(rows) for w in swing]}, 15)
+ assert word["says"] is None and word["body"]["still_bands"] == 0
+ assert word["body"]["scale"] >= local_cycle.BOB_SCALE and min(word["body"]["bands"]["reads"]) > 1 - local_cycle.BOB_SCALE
+ assert "no band of its upper body holds still with it" in word["why"]
+ one_still = local_cycle.bob_word({**_body(top), "bands": [[20.0] + [w] * (len(rows) - 1) for w in swing]}, 15)
+ assert one_still["says"] == "cycles" and one_still["body"]["still_bands"] == 1
def test_a_lowest_row_on_the_frames_last_row_holds_the_word():
@@ -1078,8 +1153,8 @@ def test_a_walk_moved_up_and_down_with_the_whole_picture_on_any_beat_is_never_wi
def test_a_walk_zoomed_in_and_out_with_the_whole_picture_on_any_beat_is_never_witnessed(walker, period):
"""The same walkers, held still or rising and falling on their legs once a step, zoomed in and out with the picture
0.5 to 4 % either way every d/4, d/2 or d frames about their feet, middle or head, at two phases (`_zoomed`): where
- the top line rises and falls twice an interval against the lowest row, the head widens with it, and less its scale
- nothing of the body's own is left. None is witnessed."""
+ the top line rises and falls twice an interval against the lowest row, the bands of the upper body widen with it,
+ and less the zoom they read nothing of the body's own is left. None is witnessed."""
d, draw = NOT_TWICE[walker]
frames = [draw(k) for k in range(FRAMES)]
for amount in (0.005, 0.01, 0.02, 0.04):
@@ -1090,6 +1165,72 @@ def test_a_walk_zoomed_in_and_out_with_the_whole_picture_on_any_beat_is_never_wi
assert word["says"] is None, (walker, period, amount, about, phase, word)
+# The walker zoomed with the picture whatever its head's top (`_head`): the wide walker with its legs drawn alike, no tone
+# between them, its feet together over half the interval at a pass (46 frames a cycle, its crossings its steps every
+# 23), held still or rising and falling on its legs once a step.
+_TOPPED = {"cycle": 46, "phase": 11, "tone": 0, "leg_half": 10}
+
+
+def _zoom_every(period: float, amount: float = 0.04):
+ return lambda k: 1 + amount * math.sin(2 * math.pi * k / period)
+
+
+def test_a_still_walk_with_a_pointed_head_zoomed_about_its_feet_twice_a_step_is_never_cut_half_a_cycle_unnamed(tmp_path):
+ """The wide walker held still on its legs, its head a triangle from a point down to a base wider than its body,
+ zoomed in and out 4 % either way about its feet twice a step (every 11.5 frames, `_zoomed`): against its lowest
+ row, which the zoom about the feet leaves where it is, its top line rises and falls twice an interval of a step,
+ and the band across its head's top widens with it by nothing — a zoom moves a band under a point not at all. The
+ step count's crossings count its steps, and the parent engine cut one of them, 23 frames, half a cycle, as two
+ steps, nothing named. The bands lower down its upper body, whose sides run straight down, widen with the zoom:
+ less the zoom they read, nothing of the line's rise and fall is left. Not witnessed half a cycle; held, named."""
+ draw = _zoomed(lambda k: _alike(k, **_TOPPED, bob=0, top="pointed"), _zoom_every(11.5), "feet")
+ report = _cut(tmp_path / "out", _keyed(tmp_path, draw))
+ _not_silent(report, 46)
+ word = _word_of(draw, 23)
+ assert word["half"] >= local_cycle.BOB_TWICE and word["quarter"] <= -local_cycle.BOB_TWICE
+ assert word["says"] is None and "its upper body's width changes with it" in word["why"]
+ bands = word["body"]["bands"]
+ assert abs(bands["zoom"][0]) < local_cycle.BAND_FLOOR and max(bands["zoom"]) >= local_cycle.BAND_FLOOR
+
+
[email protected]("about", ["feet", "middle", "head"])
[email protected]("top", TOPS)
+def test_a_walk_zoomed_with_the_picture_whatever_its_heads_top_is_never_witnessed_half_a_cycle_or_two(top, about):
+ """The wide walker (`_TOPPED`), its head's top flat, round, pointed or two ears' tips (`_head`), held still or rising
+ and falling on its legs once a step, zoomed in and out 4 % either way with the picture about its feet, middle or
+ head every quarter, half or whole cycle (11.5, 23 or 46 frames), 140 frames drawn. However far a zoom widens the
+ band across its head's top — wholly, in part or not at all — the bands lower down its upper body widen with it, and
+ where the zoom lifts the top line twice an interval nothing of it is left less the zoom they read. Never two steps
+ an interval of a step (23 frames), nor a cut of a step said to be a cycle or two, nor a cut of two cycles (92) said
+ to be one."""
+ for bob in (0, 3):
+ for period in (11.5, 23, 46):
+ draw = _zoomed(lambda k, b=bob: _alike(k, **_TOPPED, bob=b, top=top), _zoom_every(period), about)
+ frames = [draw(k) for k in range(140)]
+ signals = {**legs.strike_signals(frames), **legs.body_signals(frames)}
+ case = (top, about, bob, period)
+ assert local_cycle.bob_word(signals, 23)["says"] is None, case
+ assert local_cycle.cut_word(signals, 23)["says"] not in ("two steps", "four steps"), case
+ assert local_cycle.cut_word(signals, 92)["says"] != "two steps", case
+
+
[email protected]("bob", [0, 3])
[email protected]("about", ["feet", "middle", "head"])
[email protected]("top", ["pointed", "ears"])
+def test_a_walk_with_a_pointed_head_or_ears_zoomed_every_quarter_cycle_is_never_cut_half_a_cycle_unnamed(tmp_path, top, about,
+ bob):
+ """The wide walker (`_TOPPED`), its head a point or two ears' tips (`_head`), held still or rising and falling on its
+ legs once a step, zoomed in and out 4 % either way with the picture about its feet, middle or head every quarter
+ cycle (11.5 frames): twice an interval of a step. The parent engine read the band across the head's top alone,
+ which such a zoom widens by nothing, and handed some of these out cut one step, half a cycle, as two steps, nothing
+ named. Through the loop none is."""
+ draw = _zoomed(lambda k: _alike(k, **_TOPPED, bob=bob, top=top), _zoom_every(11.5), about)
+ _not_silent(_cut(tmp_path / "out", _keyed(tmp_path, draw)), 46)
+
+
# The picture moved up and down (of the interval d, px either way, phase), or held still (None).
SHAKES = [None, (0.5, 6, 0), (0.5, 6, math.pi / 2), (1, 6, 0)]
SLIDE_SHAKES = [None, (0.5, 3, 0), *((0.5, 6, f) for f in (0, math.pi / 2, math.pi, 3 * math.pi / 2)), (0.5, 12, 0), (1, 6, 0)]
@@ -1357,21 +1498,25 @@ def _leaning(draw, degrees: float):
@pytest.mark.slow
-def test_a_walk_leaning_further_on_its_feet_as_it_goes_is_witnessed_one_cycle(tmp_path):
+def test_a_walk_leaning_further_on_its_feet_as_it_goes_rising_too_little_to_tell_from_a_zoom_is_held(tmp_path):
"""The walker whose far foot passes hidden behind the near one, its legs drawn alike, its feet meeting once a cycle
- (17.5 frames), rising and falling on its legs once a step, turned 15 degrees about its feet over the clip: a lean
- changing slowly, on its feet. The search cuts a cycle. The lean tilts the ground under the feet, and the line over
- them takes in the two feet's heights by turns: it does not rise and fall twice the cut, nor four times, nor once —
- read there alone the cycle is held. On the screen the top line, less its flow, rises and falls of its own twice the
- cut: two steps, witnessed, nothing named."""
+ (17.5 frames), rising and falling 3 px on its legs once a step, turned 15 degrees about its feet over the clip: a
+ lean changing slowly, on its feet. The search cuts a cycle. The lean tilts the ground under the feet, and the line
+ over them takes in the two feet's heights by turns: it does not rise and fall twice the cut. On the screen the top
+ line, less its flow, rises and falls twice the cut, but by under 5 rows of the body's 127: a zoom lifting it as far
+ would widen the head under a pixel (BAND_FLOOR), as the pixel grid alone may, and the head's bands, still on the
+ beat, are not seen; the bands below swing with the arms on the beat. No band that would show the zoom holds still,
+ the body's own is not told from the picture zooming, and the cut is held as chosen, a cycle long, and named."""
report = _cut(tmp_path / "out", _keyed(tmp_path, _leaning(lambda k: _behind(k, cycle=17.5, hold=1, alike=True), -15)))
_not_silent(report, 17.5)
- c = report["cycle"]
- said = c["cut_witness"]
- assert report["status"] == "passed" and abs(c["length"] - 17.5) <= 1 and said["cut"] == [c["start"], c["length"]]
- assert said["says"] == "two steps" and said["by"] == ["screen"] and "held" not in said
- assert said["lines"]["feet"]["says"] is None and "does not rise and fall twice an interval" in said["lines"]["feet"]["why"]
- assert not local_cycle.unwitnessed(c) and not any(local_cycle.UNWITNESSED in w for w in report["jolt"]["warnings"])
+ said = _held(report)
+ assert abs(report["cycle"]["length"] - 17.5) <= 1 and said["says"] is None
+ assert "does not rise and fall twice an interval" in said["lines"]["feet"]["why"]
+ screen = said["lines"]["screen"]["bob"]
+ assert screen["half"] >= local_cycle.BOB_TWICE and screen["quarter"] <= -local_cycle.BOB_TWICE
+ assert "no band of its upper body holds still" in screen["why"]
+ bands = screen["body"]["bands"]
+ assert all(z < local_cycle.BAND_FLOOR and b <= 0.2 for z, b in zip(bands["zoom"][:2], bands["beat"][:2]))
@pytest.mark.parametrize("verdict, named", [("uncertain", True), ("two", False)])