Table of Contents
Cluttermm provides several effects methods that can be used together with a timeline to
change the properties of a single actor over time, using a simple numeric calculation. In many cases
this is an easier way to implement animation. For instance,
Clutter::EffectTemplate::fade() gradually changes the opacity of an actor or
Clutter::EffectTemplate::rotate() gradually changes the rotation of an actor,
calculating the opacity or rotation by calling the supplied alpha_func
slot.
To use a clutter effect, you should first create a
Clutter::EffectTemplate, specifying your timeline object and an
alpha_func function slot. This function will need to call
Clutter::Alpha::get_timeline() so it can return a value based on the timeline's
current frame number and total number of frames, using
Clutter::Timeline::get_current_frame() and
Clutter::Timeline::get_n_frames(). The result should be between
0 and Clutter::Alpha::MAX_ALPHA, with the meaning of the
result depending on the effect used. For instance, Clutter::Alpha::MAX_ALPHA
would be 100% opacity when using Clutter::EffectTemplate::fade(). Several
built-in callbacks, such as Clutter::Alpha::sine_func(), allow you to easily
specify natural movement.
You should then use one of the effect methods of this
Clutter::EffectTemplate, and pass along the actor and any extra parameters
required by that method.
To make it easier to use different timelines with different effects, you can use
Clutter::EffectTemplate::set_timeline_clone() to cause the effect to clone
(copy instead of just referencing) the timeline, allowing you to change the original timeline and
supply it to a second effect, without influencing the first effect.
The effects API is actually a simplified API that wraps the
Clutter::Behaviour objects. However, the effect methods can only control one
actor at a time and do not allow you to change the effects while the timeline is running. To do this
you can use the behaviours directly, as described in the Behaviours section.