|  | 
| Edited by bhgv at 2016-5-28 07:20 
 how to make frame by frame animation. example:
 ```python
 from gi.repository import Clutter
 
 Clutter.init(None)
 
 stage = Clutter.Stage()
 # ^^ import lib, initialise, create a stage to draw
 
 rect = Clutter.Rectangle()
 
 rect.set_size(200, 300)
 rect.set_position(250, 300)
 
 red = Clutter.Color.get_static(Clutter.StaticColor.RED)
 rect.set_color(red)
 
 stage.add_actor(rect)
 # ^^ create shape/object, set its size and position, set its color and add it to stage. looks as flash as3, yes?
 
 ### VV animation itself
 rotation_angle = 0
 color_change_count = 0
 cc_d = 1
 ax_m = 0
 axs = [Clutter.RotateAxis.X_AXIS, Clutter.RotateAxis.Y_AXIS, Clutter.RotateAxis.Z_AXIS]
 # ^^ just variables for animation
 
 # callback for redrawing of frame. it is called on each frame
 def on_timeline_new_frame(timeline, frame_num, rect):  # format: foo(timeline, frame_num, parameter)
 global rotation_angle, ax_m, axs
 rotation_angle += 1
 if rotation_angle >= 360:
 rotation_angle = 0
 
 #    print frame_num
 rect.set_rotation_angle(axs[ax_m], rotation_angle)  # set new angle of rotation and from time to time new axis of rotation
 
 # Change the color and alpha
 global color_change_count, cc_d
 color_change_count += cc_d
 if color_change_count >= 255 or color_change_count <= 0:
 cc_d = -cc_d
 if color_change_count == 0:
 ax_m += 1
 if ax_m >= 3:
 ax_m = 0
 
 rect_color = Clutter.Color().new(255, 0, 0, color_change_count)  # here changed only alpha
 rect.set_color(rect_color)  # and set new color to animated object
 
 
 tl = Clutter.Timeline()  # create timeline for animation
 tl.set_duration( 4000 )  # length of timeline
 
 #tl.add_marker_at_time("keyframe_1", 2000) # milliseconds # < it is keyframe for keyframed animation. not used here
 
 tl.connect('new-frame', on_timeline_new_frame, rect)  # connect callback for frame by frame animation
 
 #tl.connect('marker-reached', on_timeline_marker_reached)  # < callback for keyframed animation. not used here
 
 tl.set_loop(True)  # set looping mode of this timeline
 tl.start()  # start animation
 ### AA animation itself
 
 
 ### VV quit this program callback
 def clutter_quit(*args):
 Clutter.main_quit()
 
 # quit when the window gets closed
 stage.connect('destroy', clutter_quit)
 ### AA quit this program callback
 
 
 # --VV show stage & main loop
 stage.show()
 Clutter.main()
 ```
 
 easy as flash as for me. + it works with 3d.
 
 // hmm, where is colorisation of code? how to enable it?
 
 | 
 |