cookbook: Added a second example to show "overlapping" transitions
authorElliot Smith <elliot.smith@intel.com>
Fri, 3 Sep 2010 10:56:33 +0000 (11:56 +0100)
committerElliot Smith <elliot.smith@intel.com>
Fri, 3 Sep 2010 13:19:51 +0000 (14:19 +0100)
Added another JSON example to show how transitions can
be easily overlapped when using ClutterAnimator (two
sequences of 5 transitions, simultaneous with two
sequences of 1 transition).

Modified the C JSON loader program so it can be used with
this example as well.

doc/cookbook/examples/animations-complex-overlapping.json [new file with mode: 0644]
doc/cookbook/examples/animations-complex.c

diff --git a/doc/cookbook/examples/animations-complex-overlapping.json b/doc/cookbook/examples/animations-complex-overlapping.json
new file mode 100644 (file)
index 0000000..cae2a96
--- /dev/null
@@ -0,0 +1,80 @@
+[
+  {
+    "type" : "ClutterStage",
+    "id" : "stage",
+    "width" : 550,
+    "height" : 350,
+    "color" : "#333355ff",
+
+    "signals" : [
+      { "name" : "destroy", "handler" : "clutter_main_quit" },
+      { "name" : "key-press-event", "handler" : "foo_key_pressed_cb" }
+    ],
+
+    "children" : [
+      {
+        "type" : "ClutterRectangle",
+        "id" : "rectangle",
+        "color" : "red",
+        "width" : 50,
+        "height" : 50,
+        "x" : 0,
+        "y" : 0,
+        "scale-gravity" : "center"
+      }
+    ]
+  },
+
+  {
+    "type" : "ClutterAnimator",
+    "id" : "animator",
+    "duration" : 4000,
+
+    "properties" : [
+      {
+        "object" : "rectangle",
+        "name" : "x",
+        "ease-in" : true,
+        "keys" : [
+          [ 0.0, "linear", 0.0 ],
+          [ 0.1, "easeInCubic", 50.0 ],
+          [ 0.2, "easeInCubic", 200.0 ],
+          [ 0.4, "easeInCubic", 75.0 ],
+          [ 0.5, "easeOutCubic", 300.0 ],
+          [ 1.0, "easeInCubic", 400.0 ]
+        ]
+      },
+      {
+        "object" : "rectangle",
+        "name" : "y",
+        "ease-in" : true,
+        "keys" : [
+          [ 0.0, "linear", 0.0 ],
+          [ 0.1, "easeInCubic", 50.0 ],
+          [ 0.2, "easeInCubic", 200.0 ],
+          [ 0.4, "easeInCubic", 75.0 ],
+          [ 0.5, "easeOutCubic", 150.0 ],
+          [ 1.0, "easeInCubic", 200.0 ]
+        ]
+      },
+      {
+        "object" : "rectangle",
+        "name" : "scale-x",
+        "ease-in" : true,
+        "keys" : [
+          [ 0.0, "linear", 1.0 ],
+          [ 1.0, "linear", 4.0 ]
+        ]
+      },
+      {
+        "object" : "rectangle",
+        "name" : "scale-y",
+        "ease-in" : true,
+        "keys" : [
+          [ 0.0, "linear", 1.0 ],
+          [ 1.0, "linear", 4.0 ]
+        ]
+      }
+    ]
+  }
+]
index 3121ef5..62542e4 100644 (file)
@@ -30,19 +30,24 @@ foo_key_pressed_cb (ClutterActor *actor,
 int
 main (int argc, char *argv[])
 {
+  gchar *filename = UI_FILE;
+
   ClutterScript *script;
   ClutterActor *stage;
 
   GError *error = NULL;
 
+  if (argc > 1)
+    filename = argv[1];
+
   clutter_init (&argc, &argv);
 
   script = clutter_script_new ();
-  clutter_script_load_from_file (script, UI_FILE, &error);
+  clutter_script_load_from_file (script, filename, &error);
 
   if (error != NULL)
    {
-     g_critical ("Error loading ClutterScript file %s\n%s", UI_FILE, error->message);
+     g_critical ("Error loading ClutterScript file %s\n%s", filename, error->message);
      g_error_free (error);
      exit (EXIT_FAILURE);
    }