mirror of
https://github.com/mr0xb/spritetagger.git
synced 2026-08-27 20:44:56 -04:00
17 lines
608 B
Python
17 lines
608 B
Python
"""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]
|