mirror of
https://github.com/mr0xb/spritetagger.git
synced 2026-08-27 20:44:56 -04:00
initial commit
This commit is contained in:
commit
a9412fe58b
7 changed files with 711 additions and 0 deletions
17
playback.py
Normal file
17
playback.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
"""Playback helpers — selecting and cycling through frames by label."""
|
||||
|
||||
|
||||
def frames_with_label(assignments: dict, label: str) -> list:
|
||||
"""Sorted frame indices assigned the given label."""
|
||||
return sorted(i for i, lbl in assignments.items() if lbl == label)
|
||||
|
||||
|
||||
def next_in_cycle(indices: list, current: int, delta: int) -> int:
|
||||
"""Next index in `indices` after `current`, wrapping around.
|
||||
|
||||
If `current` isn't in the set, returns the first index.
|
||||
"""
|
||||
if current in indices:
|
||||
pos = indices.index(current)
|
||||
return indices[(pos + delta) % len(indices)]
|
||||
return indices[0]
|
||||
Loading…
Reference in a new issue