spritetagger/playback.py
2026-05-23 21:32:55 -04:00

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]