Chapter 5. Timelines

Table of Contents

Using Timelines

A clutter.Timeline can be used to change the position or appearance of an actor over time. These can be used directly as described in this chapter, or together with an animation or behaviour, as you will see in the following chapters.

The timeline object emits its new-frame signal for each frame that should be drawn, for as many frames per second as appropriate. In your signal handler you can set the actor's properties. For instance, the actor might be moved and rotated over time, and its color might change while this is happening. You could even change the properties of several actors to animate the entire stage.

The clutter.Timeline() constructor function takes a duration in milliseconds. The actual number of frames per second requested by the timeline will depend on the behaviour of your entire program, the performance of your hardware, and your monitor's refresh rate. It may even vary over time as conditions change. At best, the new-frame signal will be emitted at your monitor's refresh rate. At worst it will be called once at the start and once at the end of your timeline's duration.

PyClutter will not attempt to redraw the scene if the new frame has no change compared to the previous frame, so you don't need to do your own optimization to prevent unnecessary redraws.

You may also use timeline.set_loop() to cause the timeline to repeat for ever, or until you call timeline.stop(). The timeline does not start until you call timeline.start().

Reference