Conversation
cf_sprite_get_slice returned the first key at or after the current frame, so a slice keyed at frames 0 and 4 answered frame 2 with frame 4's box, and a slice keyed only at frame 0 wasn't found on any later frame. Aseprite holds a key until the next one, as CF_SpriteSlice's docs say and as the pivot and 9-slice tables already fill forward; the lookup now takes the latest key at or before the frame. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XG4ehbJvpCcNb3HdTURcc9
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The behavior change is narrowly scoped, aligns with existing CF_SpriteSlice semantics, and is covered by a focused regression test.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
This PR fixes cf_sprite_get_slice so slice keys behave like Aseprite: a slice key is held from its keyed frame until the next key for that slice, instead of jumping ahead to the next key at/after the current frame. It also updates the public docs to match, and adds a regression test with an embedded minimal .ase to lock in the behavior.
Changes:
- Fix slice lookup in
cf_sprite_get_sliceto return the latest key at or before the current (animation-offset) frame. - Update
cf_sprite_get_sliceAPI docs to describe the “held key” behavior and not-found semantics. - Add a new regression test (
test_sprite_slice_keys) with embedded Aseprite data covering hold-forward and animation frame-offset behavior.
| File | Description |
|---|---|
| test/test_sprite.cpp | Adds a regression test validating slice key “hold until next key” behavior and frame-offset semantics. |
| test/slice_keys.h | Adds an embedded minimal .ase fixture used by the new slice-key test. |
| src/cute_sprite.cpp | Changes cf_sprite_get_slice to select the latest slice key at/before the current frame (Aseprite-like behavior). |
| include/cute_sprite.h | Updates the public API documentation to reflect the corrected slice lookup semantics. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // Embedded slice_keys.ase: 4 blank 2x2 frames, tag "all" over frames 0-3 and tag | ||
| // "late" over frames 2-3. Slice "a" is keyed at frame 0 (x 0, y 0, 1x1) and at | ||
| // frame 2 (x 1, y 1, 1x1). Slice "b" is keyed only at frame 1 (x 0, y 1, 2x1). | ||
| static int slice_keys_sz = 355; |
|
PR got opened without my approval. |

cf_sprite_get_slicereturned the first key at or after the current frame. Aseprite holds a key until the slice's next one, and so doCF_SpriteSlice's docs and the pivot and 9-slice tables, which fill forward. So a slice keyed at frames 0 and 4 gave frame 2 the frame-4 box, and a slice keyed only at frame 0 was missing on every later frame. Sprites that key their slice on every frame, like thepivotsample, behave the same as before.The new test embeds a 355-byte .ase (four blank frames, two tags, two slices), and it fails on the old lookup.
🤖 Generated with Claude Code
https://claude.ai/code/session_01XG4ehbJvpCcNb3HdTURcc9