Next: , Previous: Implicit Animations, Up: Top


6 ClutterAlpha

A class for calculating a value as a function of time

6.1 Overview

<clutter-alpha> is a class for calculating an floating point value dependent only on the position of a <clutter-timeline>.

(code "<\"progress-mode\">") " property of " (code "<clutter-timeline>") ", or the\n" (code "clutter-timeline-set-progress-func") " function instead of " (code "<clutter-alpha>") ".\nThe " (code "<clutter-alpha>") " class will be deprecated in the future, and will not\nbe available any more in the next major version of Clutter.")

A <clutter-alpha> binds a <clutter-timeline> to a progress function which translates the time T into an adimensional factor alpha. The factor can then be used to drive a <clutter-behaviour>, which will translate the alpha value into something meaningful for a <clutter-actor>.

You should provide a <clutter-timeline> and bind it to the <clutter-alpha> instance using clutter-alpha-set-timeline. You should also set an "animation mode", either by using the <clutter-animation-mode> values that Clutter itself provides or by registering custom functions using clutter-alpha-register-func.

Instead of a <clutter-animation-mode> you may provide a function returning the alpha value depending on the progress of the timeline, using clutter-alpha-set-func or clutter-alpha-set-closure. The alpha function will be executed each time a new frame in the <clutter-timeline> is reached.

Since the alpha function is controlled by the timeline instance, you can pause, stop or resume the <clutter-alpha> from calling the alpha function by using the appropriate functions of the <clutter-timeline> object.

<clutter-alpha> is used to "drive" a <clutter-behaviour> instance, and it is internally used by the <clutter-animation> API.

(The missing figure, easing-modes

6.2 ClutterAlpha custom properties for <clutter-script>

<clutter-alpha> defines a custom "function" property for <clutter-script> which allows to reference a custom alpha function available in the source code. Setting the "function" property is equivalent to calling clutter-alpha-set-func with the specified function name. No user data or <g-destroy-notify> is available to be passed.

The following JSON fragment defines a <clutter-alpha> using a <clutter-timeline> with id "sine-timeline" and an alpha function called my-sine-alpha. The defined <clutter-alpha> instance can be reused in multiple <clutter-behaviour> definitions or for <clutter-animation> definitions.

     
     {
       "id" : "sine-alpha",
       "timeline" : {
         "id" : "sine-timeline",
         "duration" : 500,
         "loop" : true
       },
       "function" : "my_sine_alpha"
     }
     

For the way to define the <"mode"> property inside a ClutterScript fragment, see the corresponding section in <clutter-animation>.

6.3 Usage

— Function: clutter-alpha-new ⇒  (ret <clutter-alpha>)

Creates a new <clutter-alpha> instance. You must set a function to compute the alpha value using clutter-alpha-set-func and bind a <clutter-timeline> object to the <clutter-alpha> instance using clutter-alpha-set-timeline.

You should use the newly created <clutter-alpha> instance inside a <clutter-behaviour> object.

ret
the newly created empty <clutter-alpha> instance.

Since 0.2

— Function: clutter-alpha-set-timeline (self <clutter-alpha>) (timeline <clutter-timeline>)
— Method: set-timeline

Binds alpha to timeline.

alpha
A <clutter-alpha>
timeline
A <clutter-timeline>

Since 0.2

— Function: clutter-alpha-get-timeline (self <clutter-alpha>) ⇒  (ret <clutter-timeline>)
— Method: get-timeline

Gets the <clutter-timeline> bound to alpha.

alpha
A <clutter-alpha>
ret
a <clutter-timeline> instance.

Since 0.2

— Function: clutter-alpha-set-mode (self <clutter-alpha>) (mode <clutter-animation-mode>)
— Method: set-mode

Sets the progress function of alpha using the symbolic value of mode, as taken by the <clutter-animation-mode> enumeration or using the value returned by clutter-alpha-register-func.

alpha
a <clutter-alpha>
mode
a <clutter-animation-mode>

Since 1.0

— Function: clutter-alpha-get-mode (self <clutter-alpha>) ⇒  (ret <clutter-animation-mode>)
— Method: get-mode

Retrieves the <clutter-animation-mode> used by alpha.

alpha
a <clutter-alpha>
ret
the animation mode

Since 1.0

— Function: clutter-alpha-get-alpha (self <clutter-alpha>) ⇒  (ret double)
— Method: get-alpha

Query the current alpha value.

alpha
A <clutter-alpha>
ret
The current alpha value for the alpha

Since 0.2

— Function: clutter-alpha-set-closure (self <clutter-alpha>) (closure <gclosure>)
— Method: set-closure

Sets the <gclosure> used to compute the alpha value at each frame of the <clutter-timeline> bound to alpha.

alpha
A <clutter-alpha>
closure
A <gclosure>

Since 0.8

— Function: clutter-alpha-register-closure (closure <gclosure>) ⇒  (ret unsigned-long)

<gclosure> variant of clutter-alpha-register-func.

Registers a global alpha function and returns its logical id to be used by clutter-alpha-set-mode or by <clutter-animation>.

The logical id is always greater than ‘CLUTTER_ANIMATION_LAST’.

Rename to: clutter_alpha_register_func

closure
a <gclosure>
ret
the logical id of the alpha function

Since 1.0