Emmanuele Bassi > Clutter-0.820 > xs/ClutterAlpha.xs


Annotate this POD


New  3
Open  2
View/Report Bugs
Source   Latest Release: Clutter-1.002


The Clutter::Alpha class binds together a Clutter::Timeline and a function. At each frame of the timeline, the Alpha object will call the given function, which will receive the value of the frame and must return a value between 0 and Clutter::Alpha::MAX_ALPHA.

This is an example of a simple alpha function that increments linearly:

  sub linear {
      my $alpha    = shift;
      my $timeline = $alpha->get_timeline();

      return int($timeline->get_progress() * Clutter::Alpha->MAX_ALPHA);

Alphas are used by Clutter::Behaviours to create implicit animations. By changing the alpha function inside a Clutter::Alpha object it's possible to change the speed of the animation.

Clutter provides some common alpha function, like ramps, sines, smoothsteps, exponential and square waves.


The function reference must have a signature like:

  sub alpha_function {
      my ($alpha, $data) = @_;

      # $alpha is the Clutter::Alpha instance
      # $data is the scalar passed

      return $integer;

Where integer is an unsigned integer between 0 and MAX_ALPHA.

syntax highlighting: