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(resample): a row frame, a sliced sheet and a scene layer are scaled with coverage and colour apart, as a loop's cells are

Soohong Kimb38c47f412c0
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1efc207..b2259df 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,10 @@
All notable public changes to `sprite-gen` are recorded here. Versions track the `version:` field in `SKILL.md` and `pyproject.toml`.
+## Unreleased - A keyed picture is scaled without a light rim or a green tint at the edge wherever the engine scales one: a row frame, a sliced sheet, a scene layer
+
+- **Every keyed picture the engine scales goes through the loop's resample** (`resize_cell`, now in `sprite_gen/util/resample.py`): a row frame shrunk into its cell (`extract`, `fit.resample: lanczos`, the default), the plain and original-quality twins beside a pixel-unfake frame (`.plain.png`, `orig/`), a sliced sheet's figures (`slice-sheet`) and a scene's layers (`scene-render`). Each used LANCZOS over premultiplied RGBA and drew the same lighter rim and key tint at the edge as the loop's strip did before 2.19.0. On the synthetic outlined figure (`tests/keyed_figure.py`), LANCZOS left 137 pixels at 0.2x, 543 at 0.5x, 978 at 0.75x and 7,315 at 2x with a colour none of the source pixels under them had; none are left at any of them. `fit.resample: lanczos` keeps its name and stays the smooth shrink (coverage is still LANCZOS); `nearest`, `kcentroid` and pixel-unfake frames are unchanged, and a picture at its own size is copied as it is. Colour is no longer sharpened, so a scaled scene layer with no transparency (a painted background) is a little softer than LANCZOS drew it. A tween's scale (`normalize_tween_scale`) is left on LANCZOS: it scales an opaque canvas before the key is removed, where there is no coverage to divide by. [docs/video-pipeline.md](docs/video-pipeline.md), [docs/pixel-unfake.md](docs/pixel-unfake.md), [docs/sheet-slicing.md](docs/sheet-slicing.md), [docs/scene.md](docs/scene.md).
+
## v2.19.0 - A loop's cells are scaled without a light rim or a green tint at the edge, and front and back stills keep their view
- **`video-loop` scales its cells with coverage and colour taken apart** (`resize_cell`, used by `build_strip`, so the strip, the GIF, the WebP and `video-cycle-align`'s rebuild all get it). The strip used LANCZOS over premultiplied RGBA, whose negative lobes weigh the colours across an edge against each other and then divide by the edge's low coverage; on a keyed frame, whose edge holds a light rim outside a dark outline and ink with a little of the key's green, a scaled cell drew a lighter rim and greener ink than the frame had. Coverage now keeps LANCZOS's edge, held between the least and the most coverage of the source pixels the colour mixes from (no halo outside the silhouette, no hole inside it); colour is a Hamming mix of premultiplied colour, which has no negative lobe, so every pixel's colour is a mix of the colours under it. On a synthetic outlined figure (`tests/video/test_strip_resample.py`), LANCZOS left 1,462 pixels at 0.97x and 1,750 at 1.03x with a colour none of the source pixels under them had, and none are left now; the strands, 0.5-1.4 px wide, keep LANCZOS's coverage. Colour is no longer sharpened, so a 1 px line inside the body is a little softer when a cell is enlarged. A cell at its own size is copied as it is, as before. [docs/video-pipeline.md](docs/video-pipeline.md).
diff --git a/docs/architecture.md b/docs/architecture.md
index 7c6770d..a86226c 100644
--- a/docs/architecture.md
+++ b/docs/architecture.md
@@ -297,7 +297,10 @@ flowchart TD
reported as `method: slots-explicit`.
5. `fit_to_cell()` — crop, aspect-preserving downscale (`resample`:
lanczos | nearest | kcentroid), `align_x`/`align_y` placement, into the
- cell. On `fit.pixel_unfake` runs this legacy path still runs once per
+ cell. `lanczos` is the smooth shrink: coverage by LANCZOS, colour mixed apart
+ from it (`sprite_gen.util.resample.resize_cell`, the resample every keyed
+ picture goes through), so the fitted frame has no rim or key tint at its edge
+ that the keyed frame did not have. On `fit.pixel_unfake` runs this legacy path still runs once per
frame to produce the `.plain.png` twin (§6.1); the canonical frame goes
through the pixel-unfake path instead.
6. `inspect_frames()` — per-frame QA: empty/sparse, edge bleed, chroma-adjacent
diff --git a/docs/pixel-unfake.md b/docs/pixel-unfake.md
index cf8f486..3ab17eb 100644
--- a/docs/pixel-unfake.md
+++ b/docs/pixel-unfake.md
@@ -20,7 +20,7 @@ Optional `fit` object (opt-in; absent means legacy behavior). For pixel-art targ
"fit": { "resample": "kcentroid", "align_x": "foot-centroid", "align_y": "bottom" }
```
-- `resample` — `lanczos` (default) | `nearest` | `kcentroid`. `kcentroid` (Astropulse-style dominant-cluster downscale) keeps 1px dark outlines readable when the generated art's implied pixel grid does not match the target cell; `nearest` is crisp but drops off-grid outline pixels; `lanczos` blurs pixel art.
+- `resample` — `lanczos` (default) | `nearest` | `kcentroid`. `kcentroid` (Astropulse-style dominant-cluster downscale) keeps 1px dark outlines readable when the generated art's implied pixel grid does not match the target cell; `nearest` is crisp but drops off-grid outline pixels; `lanczos` blurs pixel art. `lanczos` is the smooth shrink for painted art: the frame's coverage is scaled by LANCZOS and its colour is mixed apart from it (`resize_cell`, [video-pipeline.md](video-pipeline.md) "Cells"), because LANCZOS over the keyed RGBA itself drew a lighter rim and a key tint at the edge that the keyed frame did not have — on the synthetic outlined figure of `tests/keyed_figure.py`, 137 to 978 pixels at 0.2x to 0.75x with a colour none of the pixels under them had, and none now.
- `align_x` — `bbox-center` | `centroid` | `foot-centroid` (default) | `alpha-centroid`. Bbox-centering shifts the body left/right whenever a pose's content bbox width changes (extended arm/leg), which reads as per-frame horizontal jitter. `centroid` aligns the whole-alpha centroid; `foot-centroid` aligns the bottom-20% alpha (the legs), so trailing hair/capes do not pull the body off the cell axis — use it when the runtime mirrors the cell for left/right facing (flip pivots on the leg axis instead of teleporting the body). `alpha-centroid` (opt-in, perfectpixel-studio port — github.com/gykim80/perfectpixel-studio `internal/sprite/extract.go`, MIT) aligns the alpha-weighted centroid ignoring soft-matte fringe (α ≤ 10); crucially, in the `pixel_unfake` row path it is applied **per frame** instead of once per row union, so residual registration jitter from `register_row_frames` is cancelled (upstream measured σ 27.2px → 0.2px; jump arcs stay preserved via `ground_frames: false`).
- `align_y` — `center` (default) | `bottom`. Bottom pins feet to a shared baseline (`cell_height - safe_margin_y`).
diff --git a/docs/run-contract.md b/docs/run-contract.md
index 383b9fd..e6c3438 100644
--- a/docs/run-contract.md
+++ b/docs/run-contract.md
@@ -168,7 +168,8 @@ Rules the display depends on:
pixel-unfake off, so "off = original" is crisp instead of an upscaled cell blur.
S is **per-row native**: the ceil of the largest component-crop / final-content-bbox
ratio across the row's frames (bounded by `2048 // cell`), so the twin resample is a
- mild upscale — never a downscale. The old fixed ×4 cap squeezed high-pitch raws
+ mild upscale — never a downscale (and, like every keyed picture, through `resize_cell`:
+ coverage and colour scaled apart, no rim or key tint added at the edge). The old fixed ×4 cap squeezed high-pitch raws
(synthetic_fixture_b down rows, ~14px pitch) ~3.5× and the "original" view stopped being the
original (maintainer, 2026-07-23). The
view prefers `orig/`, falling back to `.plain.png` when no hi-res twin exists. Both
diff --git a/docs/scene.md b/docs/scene.md
index 88c552c..20993ea 100644
--- a/docs/scene.md
+++ b/docs/scene.md
@@ -60,7 +60,7 @@ Canvas origin is top left; positive x is right, positive y is down. Each layer h
| `loop` | Source loop flag, otherwise true; false holds the final frame after its end |
| `stride` | Optional verified motion report plus explicit direction; mutually exclusive with `velocity` |
-Screen anchor equals `at + (plane_velocity + layer_velocity) * time - (camera.at + camera.velocity * time) * parallax`. Raster dimensions are rounded from source dimensions and scale; the anchor follows the actual resized dimensions. For repeated strips, use the tile's measured period and inspect two or more copies for recognisable joins.
+Screen anchor equals `at + (plane_velocity + layer_velocity) * time - (camera.at + camera.velocity * time) * parallax`. Raster dimensions are rounded from source dimensions and scale; the anchor follows the actual resized dimensions. A layer is scaled with its coverage and its colour taken apart (`resize_cell`, the resample a loop's cells use: [video-pipeline.md](video-pipeline.md) "Cells"), so a keyed sprite gets no lighter rim and no key tint at its edge from being scaled; a layer at scale 1 is its frame, byte for byte. Colour is not sharpened, so a scaled layer with no transparency (a painted background) comes out a little softer than LANCZOS drew it. For repeated strips, use the tile's measured period and inspect two or more copies for recognisable joins.
## Applying measured stride
diff --git a/docs/sheet-slicing.md b/docs/sheet-slicing.md
index 1d9a5c4..2d8ff41 100644
--- a/docs/sheet-slicing.md
+++ b/docs/sheet-slicing.md
@@ -80,7 +80,11 @@ during the a cut-in overhaul (2026-07-09):
cell's main figure is scaled independently so every variant's body
height equals `--target-height`. Trade-off: a bowed pose (sleep) gets a
slightly larger body — runtime cut-in renderers assume one scale, so
- asset-side height consistency wins.
+ asset-side height consistency wins. The figure is scaled with its
+ coverage and its colour taken apart (`resize_cell`,
+ [video-pipeline.md](video-pipeline.md) "Cells"): a figure is usually
+ brought to the target by a few percent, the scale at which LANCZOS over
+ the keyed RGBA put the most key tint into the edge.
5. **Feet on the baseline.** The main figure's lowest pixel lands on
`--baseline-y`; effects above the head never shift the feet.
6. **Fail loud on empty cells.** A cell with no subject after extraction
diff --git a/docs/video-pipeline.md b/docs/video-pipeline.md
index 5a4b939..0c2bcaf 100644
--- a/docs/video-pipeline.md
+++ b/docs/video-pipeline.md
@@ -528,7 +528,10 @@ Outputs:
and 1,750 at 1.03x with a colour none of the source pixels under them had; the split leaves
none, and the strands keep LANCZOS's coverage. Colour is no longer sharpened, so a 1 px line
inside the body comes out a little softer than LANCZOS drew it when a cell is enlarged. The
- GIF and WebP are cut from these cells.
+ GIF and WebP are cut from these cells. The function lives in `sprite_gen/util/resample.py`
+ and is the one resample for a keyed picture: a row frame fitted to its cell and the twin
+ beside a pixel-unfake frame (`extract`), a sliced sheet's figures (`slice-sheet`) and a
+ scene's layers (`scene-render`) go through it too.
- `<name>.gif` — `n_out` frames evenly across the cycle, 1-bit alpha, disposal 2, `loop=0`.
`n_out` is a **playback density, not a fixed count**: `round(cycle_seconds × --gif-fps)`
(default 24 fps = the source rate, so every cycle frame is kept; floor 4, never more than
diff --git a/sprite_gen/_modules.py b/sprite_gen/_modules.py
index 89a008d..9147adc 100644
--- a/sprite_gen/_modules.py
+++ b/sprite_gen/_modules.py
@@ -55,6 +55,7 @@ MODULE_DOMAIN = {
'serve_curation': 'serve',
'serve_compose': 'serve',
'gif_utils': 'util',
+ 'resample': 'util',
}
diff --git a/sprite_gen/frames/extract.py b/sprite_gen/frames/extract.py
index ec126f6..48a2494 100644
--- a/sprite_gen/frames/extract.py
+++ b/sprite_gen/frames/extract.py
@@ -26,6 +26,7 @@ from sprite_gen.spec.runio import (REQUEST_FILENAME, acquire_run_dir_lock, atomi
release_run_dir_lock)
from sprite_gen.frames.segment import separate_fused_poses
from sprite_gen.spec.subject import SUBJECT_DEFAULT, default_min_used_pixels, sparse_frame_error, subject_kind
+from sprite_gen.util.resample import resize_cell
def color_distance(left: tuple[int, int, int], right: tuple[int, int, int]) -> float:
@@ -1297,11 +1298,13 @@ def fit_to_cell(
new_size = (max(1, round(sprite.width * scale)), max(1, round(sprite.height * scale)))
if resample_name == "kcentroid":
sprite = _kcentroid_downscale(sprite, new_size[0], new_size[1])
+ elif resample_name == "nearest":
+ sprite = sprite.resize(new_size, Image.Resampling.NEAREST)
else:
- sprite = sprite.resize(
- new_size,
- Image.Resampling.NEAREST if resample_name == "nearest" else Image.Resampling.LANCZOS,
- )
+ # "lanczos" names the smooth shrink: LANCZOS coverage, colour mixed apart from it
+ # (resize_cell). LANCZOS over the keyed RGBA itself drew a light rim and key tint
+ # at the edge that the frame did not have.
+ sprite = resize_cell(sprite, new_size)
cropped = sprite.getbbox()
if cropped is not None:
sprite = sprite.crop(cropped)
@@ -2508,7 +2511,7 @@ def fit_component_to_bbox(component: Image.Image, cell_width: int, cell_height:
box_w, box_h = max(1, x1 - x0), max(1, y1 - y0)
ratio = min(box_w / src.width, box_h / src.height)
tw, th = max(1, round(src.width * ratio)), max(1, round(src.height * ratio))
- resized = src.resize((tw, th), Image.Resampling.LANCZOS)
+ resized = resize_cell(src, (tw, th))
left = x0 + (box_w - tw) // 2
top = y1 - th
target.alpha_composite(resized, (left, top))
diff --git a/sprite_gen/frames/slice_sheet.py b/sprite_gen/frames/slice_sheet.py
index 6951aeb..b34701a 100644
--- a/sprite_gen/frames/slice_sheet.py
+++ b/sprite_gen/frames/slice_sheet.py
@@ -38,6 +38,7 @@ from pathlib import Path
from PIL import Image
from sprite_gen.frames.extract import remove_chroma_background
+from sprite_gen.util.resample import resize_cell
CHROMA_KEYS = {
"magenta": (255, 0, 255),
@@ -231,7 +232,7 @@ def slice_sheet(
x, y = index % width, index // width
piece_px[x - x0, y - y0] = pixels[x, y]
new_size = (max(1, round(piece.size[0] * scale)), max(1, round(piece.size[1] * scale)))
- piece = piece.resize(new_size, Image.LANCZOS)
+ piece = resize_cell(piece, new_size)
main_center_x = (min(main_xs) + max(main_xs)) / 2
out = Image.new("RGBA", canvas, (0, 0, 0, 0))
diff --git a/sprite_gen/scene/render.py b/sprite_gen/scene/render.py
index e80f27b..52e52ca 100644
--- a/sprite_gen/scene/render.py
+++ b/sprite_gen/scene/render.py
@@ -23,6 +23,7 @@ from PIL import Image
from sprite_gen.scene.model import Scene, load_scene
from sprite_gen.spec.assets import finite
from sprite_gen.spec.runio import LOCK_FILENAME, acquire_run_dir_lock, atomic_write_set, release_run_dir_lock
+from sprite_gen.util.resample import resize_cell
FORMATS = ("png", "mp4", "gif")
@@ -61,7 +62,7 @@ class Renderer:
anchor = tuple(a*new/old for a, new, old in zip(seq.anchor, size, seq.size))
frames = {}
for source in seq.frames:
- image = source.resize(size, Image.Resampling.LANCZOS)
+ image = resize_cell(source, size)
if layer.repeat_x:
image = image.crop((0, 0, round(layer.period*layer.scale), size[1]))
if layer.opacity != 1:
diff --git a/sprite_gen/util/resample.py b/sprite_gen/util/resample.py
new file mode 100644
index 0000000..ef67a8a
--- /dev/null
+++ b/sprite_gen/util/resample.py
@@ -0,0 +1,68 @@
+# SPDX-License-Identifier: Apache-2.0
+"""The one resample for an RGBA cutout: coverage and colour scaled apart.
+
+Every place the engine scales a keyed picture goes through `resize_cell`: a loop's cells
+(`video-loop`), a row frame fitted to its cell and the twins beside a
+pixel-unfake frame (`extract`), a sliced sheet's figures (`slice-sheet`) and a scene's layers
+(`scene`). docs/video-pipeline.md "Cells".
+"""
+from __future__ import annotations
+
+from PIL import Image
+
+from sprite_gen._deps import np
+
+
+def _support_bounds(n_src: int, n_out: int, support: float) -> tuple[np.ndarray, np.ndarray]:
+ """First and last source index Pillow's resample reads for each output index, for a filter
+ of `support` source pixels (`precompute_coeffs` in Pillow's Resample.c: the support widens
+ by the scale when shrinking)."""
+ scale = n_src / n_out
+ reach = support * max(1.0, scale)
+ centre = (np.arange(n_out) + 0.5) * scale
+ lo = np.clip(np.floor(centre - reach + 0.5).astype(int), 0, n_src - 1)
+ hi = np.clip(np.floor(centre + reach + 0.5).astype(int) - 1, 0, n_src - 1)
+ return lo, np.maximum(lo, hi)
+
+
+def _window_extrema(a: np.ndarray, rows: tuple[np.ndarray, np.ndarray], cols: tuple[np.ndarray, np.ndarray]) -> tuple[np.ndarray, np.ndarray]:
+ """Min and max of `a` over each output pixel's source window (separable, rows then columns)."""
+ def along(v: np.ndarray, lo: np.ndarray, hi: np.ndarray, axis: int) -> tuple[np.ndarray, np.ndarray]:
+ low = high = np.take(v, lo, axis=axis)
+ for d in range(1, int((hi - lo).max()) + 1):
+ step = np.take(v, np.minimum(lo + d, hi), axis=axis)
+ low, high = np.minimum(low, step), np.maximum(high, step)
+ return low, high
+
+ lo_c, hi_c = along(a, *cols, axis=1)
+ return along(lo_c, *rows, axis=0)[0], along(hi_c, *rows, axis=0)[1]
+
+
+def resize_cell(image: Image.Image, size: tuple[int, int]) -> Image.Image:
+ """Scale one RGBA cell with its coverage and its colour taken apart.
+
+ LANCZOS over premultiplied RGBA (Pillow's RGBa) rings: its negative lobes weigh the colours
+ across an edge against each other, and dividing by the low coverage at the edge throws the
+ result past every colour the source had there — a light rim around a dark outline, a key
+ tint where the ink was only a little green. So the two are resampled apart. Coverage keeps
+ LANCZOS's crisp edge, held to the range of the source coverage the colour mixes from (no
+ halo outside the silhouette, no hole inside it). Colour is a Hamming mix of premultiplied
+ colour, a filter with no negative lobe: every pixel's colour is a weighted mix of the
+ colours under it and never one they did not have. docs/video-pipeline.md "Cells"."""
+ if image.size == tuple(size):
+ return image.copy()
+ w, h = size
+ src = np.asarray(image.convert("RGBA"), dtype=np.float32)
+ alpha = src[..., 3]
+
+ def scaled(channel: np.ndarray, resample: Image.Resampling) -> np.ndarray:
+ return np.asarray(Image.fromarray(np.ascontiguousarray(channel)).resize(size, resample), dtype=np.float32)
+
+ mix_alpha = scaled(alpha, Image.Resampling.HAMMING)
+ mix = np.stack([scaled(src[..., c] * alpha, Image.Resampling.HAMMING) for c in range(3)], axis=-1)
+ low, high = _window_extrema(alpha, _support_bounds(image.height, h, 1.0), _support_bounds(image.width, w, 1.0))
+ cover = np.clip(scaled(alpha, Image.Resampling.LANCZOS), low, high)
+ cover = np.where(mix_alpha > 1e-3, np.round(cover), 0)
+ colour = np.where((cover > 0)[..., None], np.round(mix / np.maximum(mix_alpha, 1e-3)[..., None]), 0)
+ out = np.dstack([np.clip(colour, 0, 255), np.clip(cover, 0, 255)]).astype(np.uint8)
+ return Image.fromarray(out, "RGBA")
diff --git a/sprite_gen/video/loop.py b/sprite_gen/video/loop.py
index 7e3aaa1..3bc409b 100644
--- a/sprite_gen/video/loop.py
+++ b/sprite_gen/video/loop.py
@@ -40,6 +40,7 @@ from PIL import Image
from sprite_gen._deps import np
from sprite_gen.spec.runio import atomic_write_text
from sprite_gen.util.gif_utils import save_clean_gif
+from sprite_gen.util.resample import resize_cell
from sprite_gen.video import motion_anchor, auto_motion, local_cycle, gait_fallback
from sprite_gen.video import repair as repair_mod
from sprite_gen.video import rife as rife_mod
@@ -607,61 +608,6 @@ def first_frame_height(path: Path) -> int:
return box[3] - box[1]
-def _support_bounds(n_src: int, n_out: int, support: float) -> tuple[np.ndarray, np.ndarray]:
- """First and last source index Pillow's resample reads for each output index, for a filter
- of `support` source pixels (`precompute_coeffs` in Pillow's Resample.c: the support widens
- by the scale when shrinking)."""
- scale = n_src / n_out
- reach = support * max(1.0, scale)
- centre = (np.arange(n_out) + 0.5) * scale
- lo = np.clip(np.floor(centre - reach + 0.5).astype(int), 0, n_src - 1)
- hi = np.clip(np.floor(centre + reach + 0.5).astype(int) - 1, 0, n_src - 1)
- return lo, np.maximum(lo, hi)
-
-
-def _window_extrema(a: np.ndarray, rows: tuple[np.ndarray, np.ndarray], cols: tuple[np.ndarray, np.ndarray]) -> tuple[np.ndarray, np.ndarray]:
- """Min and max of `a` over each output pixel's source window (separable, rows then columns)."""
- def along(v: np.ndarray, lo: np.ndarray, hi: np.ndarray, axis: int) -> tuple[np.ndarray, np.ndarray]:
- low = high = np.take(v, lo, axis=axis)
- for d in range(1, int((hi - lo).max()) + 1):
- step = np.take(v, np.minimum(lo + d, hi), axis=axis)
- low, high = np.minimum(low, step), np.maximum(high, step)
- return low, high
-
- lo_c, hi_c = along(a, *cols, axis=1)
- return along(lo_c, *rows, axis=0)[0], along(hi_c, *rows, axis=0)[1]
-
-
-def resize_cell(image: Image.Image, size: tuple[int, int]) -> Image.Image:
- """Scale one RGBA cell with its coverage and its colour taken apart.
-
- LANCZOS over premultiplied RGBA (Pillow's RGBa) rings: its negative lobes weigh the colours
- across an edge against each other, and dividing by the low coverage at the edge throws the
- result past every colour the source had there — a light rim around a dark outline, a key
- tint where the ink was only a little green. So the two are resampled apart. Coverage keeps
- LANCZOS's crisp edge, held to the range of the source coverage the colour mixes from (no
- halo outside the silhouette, no hole inside it). Colour is a Hamming mix of premultiplied
- colour, a filter with no negative lobe: every pixel's colour is a weighted mix of the
- colours under it and never one they did not have. docs/video-pipeline.md "Cells"."""
- if image.size == tuple(size):
- return image.copy()
- w, h = size
- src = np.asarray(image.convert("RGBA"), dtype=np.float32)
- alpha = src[..., 3]
-
- def scaled(channel: np.ndarray, resample: Image.Resampling) -> np.ndarray:
- return np.asarray(Image.fromarray(np.ascontiguousarray(channel)).resize(size, resample), dtype=np.float32)
-
- mix_alpha = scaled(alpha, Image.Resampling.HAMMING)
- mix = np.stack([scaled(src[..., c] * alpha, Image.Resampling.HAMMING) for c in range(3)], axis=-1)
- low, high = _window_extrema(alpha, _support_bounds(image.height, h, 1.0), _support_bounds(image.width, w, 1.0))
- cover = np.clip(scaled(alpha, Image.Resampling.LANCZOS), low, high)
- cover = np.where(mix_alpha > 1e-3, np.round(cover), 0)
- colour = np.where((cover > 0)[..., None], np.round(mix / np.maximum(mix_alpha, 1e-3)[..., None]), 0)
- out = np.dstack([np.clip(colour, 0, 255), np.clip(cover, 0, 255)]).astype(np.uint8)
- return Image.fromarray(out, "RGBA")
-
-
def build_strip(frames: list[Image.Image], *, max_cells: int = STRIP_MAX_CELLS, max_height: int = STRIP_MAX_HEIGHT, max_width: int = STRIP_MAX_WIDTH, cycle_seconds: float, body_height: int | None = None, anchor: str = "none", kind: str = "periodic", standing_src: int | None = None) -> tuple[Image.Image, dict[str, Any]]:
"""Union-crop (no bottom pad so feet meet the floor), scale, bottom-align, tile horizontally.
diff --git a/tests/frames/test_keyed_resample.py b/tests/frames/test_keyed_resample.py
new file mode 100644
index 0000000..c085362
--- /dev/null
+++ b/tests/frames/test_keyed_resample.py
@@ -0,0 +1,102 @@
+# SPDX-License-Identifier: Apache-2.0
+"""A keyed picture is scaled without a ring wherever `extract` and `slice-sheet` scale one.
+
+`fit_to_cell` (a row frame shrunk into its cell, `fit.resample: lanczos`), `fit_component_to_bbox`
+(the original-quality twin beside a pixel-unfake frame) and `slice_sheet` (a sheet's figures
+brought to one height) used LANCZOS over premultiplied RGBA, which drew a lighter rim and a
+key tint at the edge that the keyed picture did not have. They scale through `resize_cell`
+(`tests/video/test_strip_resample.py` holds its own properties). Each test fails with LANCZOS
+put back.
+"""
+from __future__ import annotations
+
+from pathlib import Path
+
+import pytest
+from PIL import Image
+
+from keyed_figure import colour_outside, figure
+from sprite_gen.frames import extract, slice_sheet
+from sprite_gen.util.resample import resize_cell
+
+GREEN = (0, 255, 0)
+
+
+def _shrunk_into(cell: int, margin: int, sprite: Image.Image) -> tuple[int, int]:
+ scale = min((cell - 2 * margin) / sprite.width, (cell - 2 * margin) / sprite.height, 1.0)
+ return max(1, round(sprite.width * scale)), max(1, round(sprite.height * scale))
+
+
[email protected]("cell", (64, 96, 150))
+def test_a_frame_fitted_to_its_cell_carries_no_colour_the_frame_did_not_have(cell: int) -> None:
+ src = figure()
+ sprite = src.crop(src.getbbox())
+ size = _shrunk_into(cell, 4, sprite)
+ assert size != sprite.size
+ fitted = extract.fit_to_cell(src, cell, cell, 4, 4, {"align_x": "bbox-center"})
+ want = resize_cell(sprite, size)
+ assert colour_outside(sprite, want) == 0
+ assert fitted.crop(fitted.getbbox()).tobytes() == want.crop(want.getbbox()).tobytes()
+ # what the cell held before: colour nothing under it had, so not these bytes
+ old = sprite.resize(size, Image.Resampling.LANCZOS)
+ assert colour_outside(sprite, old) > 50
+ assert fitted.crop(fitted.getbbox()).tobytes() != old.crop(old.getbbox()).tobytes()
+
+
+def test_the_other_fit_filters_are_left_as_they_were(monkeypatch) -> None:
+ def never(*_args, **_kwargs):
+ raise AssertionError("nearest and kcentroid do not go through resize_cell")
+
+ monkeypatch.setattr(extract, "resize_cell", never)
+ src = figure()
+ sprite = src.crop(src.getbbox())
+ size = _shrunk_into(96, 4, sprite)
+ nearest = extract.fit_to_cell(src, 96, 96, 4, 4, {"resample": "nearest", "align_x": "bbox-center"})
+ want = sprite.resize(size, Image.Resampling.NEAREST)
+ assert nearest.crop(nearest.getbbox()).tobytes() == want.crop(want.getbbox()).tobytes()
+ assert extract.fit_to_cell(src, 96, 96, 4, 4, {"resample": "kcentroid"}).getbbox() is not None
+
+
[email protected]("box_height", (60, 172, 240)) # the twin shrinks, nearly keeps its size, grows
+def test_the_twin_beside_a_pixel_frame_carries_no_colour_the_component_did_not_have(box_height: int) -> None:
+ src = figure()
+ sprite = src.crop(src.getbbox())
+ cell = 256
+ bbox = (40, cell - 8 - box_height, 216, cell - 8)
+ twin, mapping = extract.fit_component_to_bbox(src, cell, cell, bbox)
+ ratio = min((bbox[2] - bbox[0]) / sprite.width, (bbox[3] - bbox[1]) / sprite.height)
+ size = (max(1, round(sprite.width * ratio)), max(1, round(sprite.height * ratio)))
+ assert size != sprite.size and mapping["ratio"] == ratio
+ left, top = int(mapping["left"]), int(mapping["top"])
+ placed = twin.crop((left, top, left + size[0], top + size[1]))
+ assert colour_outside(sprite, placed) == 0
+ assert placed.tobytes() == resize_cell(sprite, size).tobytes()
+ assert colour_outside(sprite, sprite.resize(size, Image.Resampling.LANCZOS)) > 50
+
+
+# the main component (the body) is 96-97 px tall on the sheet: the figures shrink, nearly keep their size, grow
[email protected]("target_height", (72.0, 99.0, 130.0))
+def test_a_sliced_figure_carries_no_colour_its_keyed_piece_did_not_have(tmp_path: Path, monkeypatch, target_height: float) -> None:
+ fig = figure()
+ sheet = Image.new("RGBA", (2 * fig.width, fig.height), GREEN + (255,))
+ sheet.alpha_composite(fig, (0, 0))
+ sheet.alpha_composite(figure(shift=0.5), (fig.width, 0))
+ sheet.convert("RGB").save(tmp_path / "sheet.png")
+ pieces: list[tuple[Image.Image, Image.Image]] = []
+
+ def spy(image: Image.Image, size: tuple[int, int]) -> Image.Image:
+ out = resize_cell(image, size)
+ pieces.append((image.copy(), out))
+ return out
+
+ monkeypatch.setattr(slice_sheet, "resize_cell", spy)
+ written = slice_sheet.slice_sheet(tmp_path / "sheet.png", tmp_path / "out", GREEN, grid=(2, 1), canvas=(256, 256),
+ baseline_y=240.0, target_height=target_height)
+ assert len(written) == len(pieces) == 2
+ for path, (piece, scaled) in zip(written, pieces):
+ assert scaled.size != piece.size
+ assert colour_outside(piece, scaled) == 0
+ cell = Image.open(path)
+ assert cell.crop(cell.getbbox()).tobytes() == scaled.crop(scaled.getbbox()).tobytes()
+ # the keyed piece under LANCZOS: colour nothing under it had
+ assert colour_outside(piece, piece.resize(scaled.size, Image.Resampling.LANCZOS)) > 50
diff --git a/tests/keyed_figure.py b/tests/keyed_figure.py
new file mode 100644
index 0000000..e0e8e2a
--- /dev/null
+++ b/tests/keyed_figure.py
@@ -0,0 +1,106 @@
+# SPDX-License-Identifier: Apache-2.0
+"""A synthetic keyed figure and the "no colour the source did not have" count.
+
+The figure is area-sampled: a dark-outlined body (a skin half and a white half), a light rim
+outside part of the outline, green-tinted ink along another part, a 1 px line across the body,
+a hair cap with strands 0.5-1.4 px wide — the edge a keyer leaves. Shared by the tests of every
+place the engine scales a keyed picture (`sprite_gen.util.resample.resize_cell`).
+"""
+from __future__ import annotations
+
+import math
+
+import numpy as np
+from PIL import Image
+
+SS = 4 # supersamples per pixel side
+OUTLINE = (28, 18, 16)
+INK_GREEN = (21, 27, 2)
+SKIN = (238, 206, 178)
+SHIRT = (245, 245, 240)
+HAIR = (170, 52, 36)
+RIM = (235, 228, 196)
+BODY = (80.0, 120.0, 46.0, 2.2) # centre x, centre y, radius, outline width
+CAP = (80.0, 58.0, 30.0, 1.6)
+STRANDS = [(-150, 0.5, 18), (-125, 0.7, 20), (-100, 1.0, 18), (-60, 1.4, 16), (-35, 0.8, 18)] # degrees, width, length
+
+
+def strand(deg: float) -> tuple[float, float, float, float]:
+ t = math.radians(deg)
+ return CAP[0] + (CAP[2] - 1) * math.cos(t), CAP[1] + (CAP[2] - 1) * math.sin(t), math.cos(t), math.sin(t)
+
+
+def figure(shift: float = 0.0, width: int = 160, height: int = 180) -> Image.Image:
+ ys, xs = np.mgrid[0 : height * SS, 0 : width * SS]
+ X = (xs + 0.5) / SS - shift
+ Y = (ys + 0.5) / SS - shift
+ rgb = np.zeros(X.shape + (3,))
+ a = np.zeros(X.shape)
+
+ def paint(mask: np.ndarray, colour: tuple[int, int, int]) -> None:
+ rgb[mask] = colour
+ a[mask] = 1.0
+
+ cx, cy, r, t = BODY
+ rb = np.hypot(X - cx, Y - cy)
+ ang = np.degrees(np.arctan2(Y - cy, X - cx))
+ paint((rb < r + t + 0.6) & (ang > -40) & (ang < 50), RIM)
+ paint(rb < r + t, OUTLINE)
+ paint((rb < r + t) & (ang > 100) & (ang < 170), INK_GREEN)
+ paint((rb < r) & (Y < cy), SKIN)
+ paint((rb < r) & (Y >= cy), SHIRT)
+ paint((rb < r) & (np.abs(Y - (cy + 18.3)) < 0.5), OUTLINE)
+ qx, qy, qr, qt = CAP
+ rc = np.hypot(X - qx, Y - qy)
+ paint((rc < qr + qt) & (Y < qy + 2), OUTLINE)
+ paint((rc < qr) & (Y < qy), HAIR)
+ for deg, thick, length in STRANDS:
+ x0, y0, dx, dy = strand(deg)
+ along = np.clip((X - x0) * dx + (Y - y0) * dy, 0, length)
+ paint(np.hypot(X - (x0 + along * dx), Y - (y0 + along * dy)) < thick / 2, HAIR)
+ A = a.reshape(height, SS, width, SS).mean(axis=(1, 3))
+ P = (rgb * a[..., None]).reshape(height, SS, width, SS, 3).mean(axis=(1, 3))
+ C = np.where(A[..., None] > 0, P / np.maximum(A[..., None], 1e-9), 0)
+ return Image.fromarray(np.dstack([C.round(), (A * 255).round()]).astype(np.uint8), "RGBA")
+
+
+def scaled_size(image: Image.Image, scale: float) -> tuple[int, int]:
+ return round(image.width * scale), round(image.height * scale)
+
+
+def _windows(n_src: int, n_out: int) -> list[range]:
+ """Source pixels whose centre lies within the Hamming filter's reach of each output pixel's centre."""
+ ratio = n_src / n_out
+ reach = max(1.0, ratio)
+ out = []
+ for k in range(n_out):
+ c = (k + 0.5) * ratio
+ out.append(range(max(0, math.ceil(c - reach - 0.5)), min(n_src - 1, math.floor(c + reach - 0.5)) + 1))
+ return out
+
+
+def neighbour_ranges(src: Image.Image, size: tuple[int, int]):
+ s = np.asarray(src).astype(int)
+ rows, cols = _windows(src.height, size[1]), _windows(src.width, size[0])
+ lo = np.full((size[1], size[0], 3), 256)
+ hi = np.full((size[1], size[0], 3), -1)
+ amin = np.full((size[1], size[0]), 255)
+ amax = np.zeros((size[1], size[0]), int)
+ for v, ry in enumerate(rows):
+ for u, rx in enumerate(cols):
+ block = s[ry.start : ry.stop, rx.start : rx.stop].reshape(-1, 4)
+ amin[v, u], amax[v, u] = block[:, 3].min(), block[:, 3].max()
+ seen = block[block[:, 3] > 0, :3]
+ if len(seen):
+ lo[v, u], hi[v, u] = seen.min(axis=0), seen.max(axis=0)
+ return lo, hi, amin, amax
+
+
+def colour_outside(src: Image.Image, out: Image.Image) -> int:
+ """Visible output pixels (alpha >= 38) whose colour is more than one level outside the range of
+ the visible source pixels under them."""
+ lo, hi, _, _ = neighbour_ranges(src, out.size)
+ o = np.asarray(out).astype(int)
+ seen = o[..., 3] >= 38
+ outside = ((o[..., :3] < lo - 1) | (o[..., :3] > hi + 1)).any(axis=-1)
+ return int(np.count_nonzero(seen & outside))
diff --git a/tests/scene/test_layer_resample.py b/tests/scene/test_layer_resample.py
new file mode 100644
index 0000000..2915e64
--- /dev/null
+++ b/tests/scene/test_layer_resample.py
@@ -0,0 +1,48 @@
+# SPDX-License-Identifier: Apache-2.0
+"""A scene layer is scaled without a ring at its edge.
+
+`Renderer` brings every frame of a layer to the layer's raster size. It used LANCZOS over
+premultiplied RGBA, which drew a lighter rim and a key tint around a keyed sprite that the
+sprite did not have; it scales through `resize_cell` (`tests/video/test_strip_resample.py`).
+The test fails with LANCZOS put back.
+"""
+from __future__ import annotations
+
+import json
+from pathlib import Path
+
+import pytest
+from PIL import Image
+
+from keyed_figure import colour_outside, figure
+from sprite_gen.scene.model import load_scene
+from sprite_gen.scene.render import Renderer
+from sprite_gen.util.resample import resize_cell
+
+
[email protected]("scale", (0.5, 0.75, 1.25, 2.0))
+def test_a_scaled_layer_carries_no_colour_its_frame_did_not_have(tmp_path: Path, scale: float) -> None:
+ src = figure()
+ src.save(tmp_path / "hero.png")
+ (tmp_path / "scene.json").write_text(json.dumps({
+ "kind": "sprite-gen-scene", "version": 1, "canvas": {"width": 400, "height": 400, "background": [16, 16, 16]},
+ "fps": 10, "duration": 0.5, "assets": {"hero": "hero.png"},
+ "layers": [{"id": "hero", "asset": "hero", "at": [200, 380], "scale": scale}]}))
+ scene = load_scene(tmp_path / "scene.json")
+ layer = scene.layers[0]
+ size = tuple(layer.raster_size)
+ assert size == (round(src.width * scale), round(src.height * scale))
+ (image, _anchor, _shadow, _bbox), = Renderer(scene).prepared["hero"].values()
+ assert colour_outside(src, image) == 0
+ assert image.tobytes() == resize_cell(src, size).tobytes()
+ assert colour_outside(src, src.resize(size, Image.Resampling.LANCZOS)) > 100
+
+
+def test_a_layer_at_its_own_size_is_the_frame_itself(tmp_path: Path) -> None:
+ src = figure()
+ src.save(tmp_path / "hero.png")
+ (tmp_path / "scene.json").write_text(json.dumps({
+ "kind": "sprite-gen-scene", "version": 1, "canvas": {"width": 200, "height": 200}, "fps": 10, "duration": 0.5,
+ "assets": {"hero": "hero.png"}, "layers": [{"id": "hero", "asset": "hero", "at": [100, 190]}]}))
+ (image, _anchor, _shadow, _bbox), = Renderer(load_scene(tmp_path / "scene.json")).prepared["hero"].values()
+ assert image.tobytes() == src.tobytes()
diff --git a/tests/video/test_strip_resample.py b/tests/video/test_strip_resample.py
index 9b68cde..71b48d1 100644
--- a/tests/video/test_strip_resample.py
+++ b/tests/video/test_strip_resample.py
@@ -19,117 +19,28 @@ import numpy as np
import pytest
from PIL import Image
+from keyed_figure import STRANDS, colour_outside, figure, neighbour_ranges, scaled_size, strand
+from sprite_gen.util import resample
from sprite_gen.video import loop
-SS = 4 # supersamples per pixel side
-OUTLINE = (28, 18, 16)
-INK_GREEN = (21, 27, 2)
-SKIN = (238, 206, 178)
-SHIRT = (245, 245, 240)
-HAIR = (170, 52, 36)
-RIM = (235, 228, 196)
-BODY = (80.0, 120.0, 46.0, 2.2) # centre x, centre y, radius, outline width
-CAP = (80.0, 58.0, 30.0, 1.6)
-STRANDS = [(-150, 0.5, 18), (-125, 0.7, 20), (-100, 1.0, 18), (-60, 1.4, 16), (-35, 0.8, 18)] # degrees, width, length
SCALES = (0.5, 0.9662, 1.0256, 1.5)
-def _strand(deg: float) -> tuple[float, float, float, float]:
- t = math.radians(deg)
- return CAP[0] + (CAP[2] - 1) * math.cos(t), CAP[1] + (CAP[2] - 1) * math.sin(t), math.cos(t), math.sin(t)
-
-
-def _figure(shift: float = 0.0, width: int = 160, height: int = 180) -> Image.Image:
- ys, xs = np.mgrid[0 : height * SS, 0 : width * SS]
- X = (xs + 0.5) / SS - shift
- Y = (ys + 0.5) / SS - shift
- rgb = np.zeros(X.shape + (3,))
- a = np.zeros(X.shape)
-
- def paint(mask: np.ndarray, colour: tuple[int, int, int]) -> None:
- rgb[mask] = colour
- a[mask] = 1.0
-
- cx, cy, r, t = BODY
- rb = np.hypot(X - cx, Y - cy)
- ang = np.degrees(np.arctan2(Y - cy, X - cx))
- paint((rb < r + t + 0.6) & (ang > -40) & (ang < 50), RIM)
- paint(rb < r + t, OUTLINE)
- paint((rb < r + t) & (ang > 100) & (ang < 170), INK_GREEN)
- paint((rb < r) & (Y < cy), SKIN)
- paint((rb < r) & (Y >= cy), SHIRT)
- paint((rb < r) & (np.abs(Y - (cy + 18.3)) < 0.5), OUTLINE)
- qx, qy, qr, qt = CAP
- rc = np.hypot(X - qx, Y - qy)
- paint((rc < qr + qt) & (Y < qy + 2), OUTLINE)
- paint((rc < qr) & (Y < qy), HAIR)
- for deg, thick, length in STRANDS:
- x0, y0, dx, dy = _strand(deg)
- along = np.clip((X - x0) * dx + (Y - y0) * dy, 0, length)
- paint(np.hypot(X - (x0 + along * dx), Y - (y0 + along * dy)) < thick / 2, HAIR)
- A = a.reshape(height, SS, width, SS).mean(axis=(1, 3))
- P = (rgb * a[..., None]).reshape(height, SS, width, SS, 3).mean(axis=(1, 3))
- C = np.where(A[..., None] > 0, P / np.maximum(A[..., None], 1e-9), 0)
- return Image.fromarray(np.dstack([C.round(), (A * 255).round()]).astype(np.uint8), "RGBA")
-
-
-def _size(image: Image.Image, scale: float) -> tuple[int, int]:
- return round(image.width * scale), round(image.height * scale)
-
-
-def _windows(n_src: int, n_out: int) -> list[range]:
- """Source pixels whose centre lies within the Hamming filter's reach of each output pixel's centre."""
- ratio = n_src / n_out
- reach = max(1.0, ratio)
- out = []
- for k in range(n_out):
- c = (k + 0.5) * ratio
- out.append(range(max(0, math.ceil(c - reach - 0.5)), min(n_src - 1, math.floor(c + reach - 0.5)) + 1))
- return out
-
-
-def _neighbour_ranges(src: Image.Image, size: tuple[int, int]):
- s = np.asarray(src).astype(int)
- rows, cols = _windows(src.height, size[1]), _windows(src.width, size[0])
- lo = np.full((size[1], size[0], 3), 256)
- hi = np.full((size[1], size[0], 3), -1)
- amin = np.full((size[1], size[0]), 255)
- amax = np.zeros((size[1], size[0]), int)
- for v, ry in enumerate(rows):
- for u, rx in enumerate(cols):
- block = s[ry.start : ry.stop, rx.start : rx.stop].reshape(-1, 4)
- amin[v, u], amax[v, u] = block[:, 3].min(), block[:, 3].max()
- seen = block[block[:, 3] > 0, :3]
- if len(seen):
- lo[v, u], hi[v, u] = seen.min(axis=0), seen.max(axis=0)
- return lo, hi, amin, amax
-
-
-def _colour_outside(src: Image.Image, out: Image.Image) -> int:
- """Visible output pixels (alpha >= 38) whose colour is more than one level outside the range of
- the visible source pixels under them."""
- lo, hi, _, _ = _neighbour_ranges(src, out.size)
- o = np.asarray(out).astype(int)
- seen = o[..., 3] >= 38
- outside = ((o[..., :3] < lo - 1) | (o[..., :3] > hi + 1)).any(axis=-1)
- return int(np.count_nonzero(seen & outside))
-
-
@pytest.mark.parametrize("scale", SCALES)
def test_cell_colour_is_always_a_mix_of_the_colours_under_it(scale: float) -> None:
- src = _figure()
- size = _size(src, scale)
- assert _colour_outside(src, loop.resize_cell(src, size)) == 0
+ src = figure()
+ size = scaled_size(src, scale)
+ assert colour_outside(src, resample.resize_cell(src, size)) == 0
# the filter it replaces put colour there that nothing under it had
- assert _colour_outside(src, src.resize(size, Image.Resampling.LANCZOS)) > 100
+ assert colour_outside(src, src.resize(size, Image.Resampling.LANCZOS)) > 100
@pytest.mark.parametrize("scale", SCALES)
def test_cell_coverage_has_no_halo_and_no_hole(scale: float) -> None:
- src = _figure(shift=0.37)
- size = _size(src, scale)
- _, _, amin, amax = _neighbour_ranges(src, size)
- a = np.asarray(loop.resize_cell(src, size))[..., 3].astype(int)
+ src = figure(shift=0.37)
+ size = scaled_size(src, scale)
+ _, _, amin, amax = neighbour_ranges(src, size)
+ a = np.asarray(resample.resize_cell(src, size))[..., 3].astype(int)
assert ((a >= amin) & (a <= amax)).all()
# LANCZOS dips inside the silhouette and spills past it
lz = np.asarray(src.resize(size, Image.Resampling.LANCZOS))[..., 3].astype(int)
@@ -141,7 +52,7 @@ def _strand_peaks(image: Image.Image, scale_xy: tuple[float, float], shift: floa
h, w = a.shape
peaks = []
for deg, _, length in STRANDS:
- x0, y0, dx, dy = _strand(deg)
+ x0, y0, dx, dy = strand(deg)
found = []
for t in np.arange(0.3 * length, 0.9 * length, 0.5):
px, py = (x0 + t * dx + shift) * scale_xy[0], (y0 + t * dy + shift) * scale_xy[1]
@@ -155,17 +66,17 @@ def _strand_peaks(image: Image.Image, scale_xy: tuple[float, float], shift: floa
@pytest.mark.parametrize("scale", SCALES)
def test_strands_keep_the_coverage_lanczos_gave_them(scale: float) -> None:
for shift in (0.0, 0.25, 0.5, 0.75):
- src = _figure(shift=shift)
- size = _size(src, scale)
+ src = figure(shift=shift)
+ size = scaled_size(src, scale)
sxy = (size[0] / src.width, size[1] / src.height)
- new = _strand_peaks(loop.resize_cell(src, size), sxy, shift)
+ new = _strand_peaks(resample.resize_cell(src, size), sxy, shift)
old = _strand_peaks(src.resize(size, Image.Resampling.LANCZOS), sxy, shift)
assert min(n - o for n, o in zip(new, old)) >= -0.03, (shift, new, old)
def test_a_cell_at_its_own_size_is_untouched() -> None:
- src = _figure()
- out = loop.resize_cell(src, src.size)
+ src = figure()
+ out = resample.resize_cell(src, src.size)
assert out is not src and out.tobytes() == src.tobytes()
@@ -173,7 +84,7 @@ def test_a_cell_at_its_own_size_is_untouched() -> None:
def test_coverage_clamp_reads_every_pixel_the_colour_filter_mixes(scale: float) -> None:
n_src = 41
n_out = round(n_src * scale)
- lo, hi = loop._support_bounds(n_src, n_out, 1.0)
+ lo, hi = resample._support_bounds(n_src, n_out, 1.0)
for x in range(n_src):
impulse = np.zeros((1, n_src), np.float32)
impulse[0, x] = 1.0
@@ -184,7 +95,7 @@ def test_coverage_clamp_reads_every_pixel_the_colour_filter_mixes(scale: float)
@pytest.mark.parametrize("anchor", ("none", "feet"))
def test_build_strip_scales_every_cell_this_way(monkeypatch, anchor: str) -> None:
- frames = [_figure(shift=k * 0.5) for k in range(4)]
+ frames = [figure(shift=k * 0.5) for k in range(4)]
calls: list[tuple[int, int]] = []
resize_cell = loop.resize_cell