base.BaseTimer

moderngl_window.timers.base.BaseTimer[source]

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.

Methods

BaseTimer.__init__()

Initialize self. See help(type(self)) for accurate signature.

BaseTimer.next_frame() → Tuple[float, float][source]

Get timer information for the next frame.

Returns

The frametime and current time

Return type

Tuple[float, float]

BaseTimer.start()[source]

Start the timer initially or resume after pause

BaseTimer.pause()[source]

Pause the timer

BaseTimer.toggle_pause()[source]

Toggle pause state

BaseTimer.stop() → Tuple[float, float][source]

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

Returns

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

Attributes

BaseTimer.is_paused

The pause state of the timer

Type

bool

BaseTimer.is_running

Is the timer currently running?

Type

bool

BaseTimer.time

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