# moderngl_window.timers

class moderngl_window.timers.base.BaseTimer

  A timer controls the time passed into the the render function. This can be used in creative ways to control the current time such as basing it on current location in an audio file.

  All methods must be implemented.

  property fps: float

    Get the current frames per second.

  property fps_average: float

    get the average fps since the timer was started

  property is_paused: bool

    The pause state of the timer

    Type:

      bool

  property is_running: bool

    Is the timer currently running?

    Type:

      bool

  next_frame() → tuple[float, float]

    Get timer information for the next frame.

    Returns:

      The frametime and current time

    Return type:

      tuple[float, float]

  pause() → None

    Pause the timer

  start() → None

    Start the timer initially or resume after pause

  stop() → tuple[float, float]

    Stop the timer. Should only be called once when stopping the timer.

    Returns:

      tuple[float, float]> Current position in the timer, actual running duration

  property time: float

    Get or set the current time. This can be used to jump around in the timeline.

    Returns:

      The current time in seconds

    Return type:

      float

  toggle_pause() → None

    Toggle pause state

class moderngl_window.timers.clock.Timer(**kwargs: Any)

  Bases: `BaseTimer`

  Timer based on python `time`.

  property fps: float

    Get the current frames per second.

  property fps_average: float

    The average fps since the timer was started

  property is_paused: bool

    The pause state of the timer

    Type:

      bool

  property is_running: bool

    Is the timer currently running?

    Type:

      bool

  next_frame() → tuple[float, float]

    Get the time and frametime for the next frame. This should only be called once per frame.

    Returns:

      current time and frametime

    Return type:

      tuple[float, float]

  pause() → None

    Pause the timer by setting the internal pause time using `time.time()`

  start() → None

    Start the timer by recoding the current `time.time()` preparing to report the number of seconds since this timestamp.

  stop() → tuple[float, float]

    Stop the timer. Should only be called once when stopping the timer.

    Returns:

      Current position in the timer, actual running duration

    Return type:

      tuple[float, float]

  property time: float

    Get or set the current time. This can be used to jump around in the timeline.

    Returns:

      The current time in seconds

  toggle_pause() → None

    Toggle the paused state