[indent=4] /* Requires Vala >= 0.7.9 valac --pkg clutter-1.0 yourfile.gs */ uses Clutter class ClutterDemo animations : array of Animation stage : Stage rectangles : array of Rectangle const colors : array of string = { "blanched almond", "OldLace", "MistyRose", "White", "LavenderBlush", "CornflowerBlue", "chartreuse", "chocolate", "light coral", "medium violet red", "LemonChiffon2", "RosyBrown3" } construct () stage = Stage.get_default () rectangles = new array of Rectangle[colors.length] stage.hide.connect (Clutter.main_quit) create_rectangles () stage.color = Clutter.Color () { alpha = 255 } stage.show_all () def private create_rectangles () i : int = 0 while i < colors.length var r = new Rectangle r.width = r.height = stage.height / colors.length r.color = Color.from_string (colors[i]) r.anchor_gravity = Gravity.CENTER r.y = i * r.height + r.height / 2 stage.add_actor (r) rectangles[i] = r i++ def start () animations = new array of Animation[rectangles.length] i : int = 0 while i < rectangles.length animations[i] = rectangles[i].animate (AnimationMode.LINEAR, 5000, "x", stage.width / 2, "rotation-angle-z", 500.0) animations[i].timeline.start () i++ animations[animations.length - 1].timeline.completed.connect(animate_with_text) def private animate_with_text () j : int = 0 var mytext = new Text.full ("Bitstream Vera Sans 25", "Clutter say hello to Genie !", Color.from_string ("white")) mytext.set_anchor_point_from_gravity (Gravity.CENTER) mytext.x = stage.width / 2 mytext.y = -mytext.height stage.add_actor (mytext) mytext.show () var text_anim = mytext.animate (AnimationMode.EASE_OUT_BOUNCE, 3000, "y", stage.height / 2) text_anim.timeline.start () while j < rectangles.length animations[j] = rectangles[j].animate (AnimationMode.EASE_OUT_BOUNCE, 3000, "x", Random.next_double () * stage.width, "y", Random.next_double () * stage.height / 2 + stage.height / 2, "rotation-angle-z", rectangles[j].rotation_angle_z, "opacity", 0) animations[j].timeline.start () j++ init Clutter.init (ref args) var demo = new ClutterDemo () demo.start () Clutter.main ()