Coverage for paintmaskanimator/time_display.py: 100%

9 statements  

« prev     ^ index     » next       coverage.py v7.17.0, created at 2026-11-02 04:50 +0000

1"""User-facing frame-position formatting shared by the whole application.""" 

2 

3from . import preferences 

4from .i18n import tr 

5 

6 

7def frame_position(frame_index: int, fps: int = 24) -> str: 

8 """Format a zero-based frame index using the user's display preference.""" 

9 index = max(0, int(frame_index)) 

10 if preferences.time_display_mode() == preferences.TIME_DISPLAY_SECONDS_FRAMES: 

11 rate = max(1, int(fps)) 

12 seconds, frame = divmod(index + 1, rate) 

13 return f"{seconds}+{frame}" 

14 return tr("{frame}コマ目").format(frame=index + 1) 

15