[seed] examples: Update clutter using examples to not require [GOject.TYPE_*...in animatev calls



commit a1750f5a1551fc5561cf4b3a61712b578ef298b5
Author: Robert Carr <racarr svn gnome org>
Date:   Wed May 13 23:55:27 2009 -0400

    examples: Update clutter using examples to not require [GOject.TYPE_*...in animatev calls
---
 examples/clutter-0.9.js     |   28 +++---
 examples/same-seed/light.js |  212 +++++++++++++++++++++---------------------
 examples/same-seed/score.js |   10 +-
 extensions/Clutter.js       |   32 +++---
 4 files changed, 142 insertions(+), 140 deletions(-)

diff --git a/examples/clutter-0.9.js b/examples/clutter-0.9.js
index 8101d75..2e115d3 100755
--- a/examples/clutter-0.9.js
+++ b/examples/clutter-0.9.js
@@ -41,11 +41,12 @@ function create_rectangles(rectangles, colors){
 
 function animate_rectangles(rectangles){
     for (var i in rectangles){
-	rectangles[i].anim = rectangles[i].animate(Clutter.AnimationMode.LINEAR, 5000,
-						   {
-						       x: [GObject.TYPE_INT, stage.width / 2],
-						       rotation_angle_z: [GObject.TYPE_DOUBLE, 500]
-						   });
+	rectangles[i].anim = 
+	    rectangles[i].animate(Clutter.AnimationMode.LINEAR, 5000,
+				  {
+				      x: stage.width / 2,
+				      rotation_angle_z: 500
+				  });
 	rectangles[i].anim.timeline.start();
     }
     rectangles[i].anim.timeline.signal.completed.connect(
@@ -64,20 +65,21 @@ function animate_rectangles(rectangles){
 	    text.y = -text.height;	// Off-stage
 	    stage.add_actor(text);
 	    text.show();
-	    text.anim = text.animate(Clutter.AnimationMode.EASE_OUT_BOUNCE, 3000,
-				     {
-					 y: [GObject.TYPE_INT, stage.height / 2]
-				     });
+	    text.anim = 
+		text.animate(Clutter.AnimationMode.EASE_OUT_BOUNCE, 3000,
+			     {
+				 y: stage.height / 2
+			     });
 	    text.anim.timeline.start();
 
 	    for (var i in rectangles){
 		rectangles[i].anim = 
 		    rectangles[i].animate(Clutter.AnimationMode.EASE_OUT_BOUNCE, 3000,
 					  {
-					      x: [GObject.TYPE_INT, Math.random() * stage.width],
-					      y: [GObject.TYPE_INT, Math.random() * stage.height / 2 + stage.height / 2],
-					      rotation_angle_z: [GObject.TYPE_DOUBLE, rectangles[i].rotation_angle_z],
-					      opacity: [GObject.TYPE_UCHAR, 0 ]
+					      x: Math.random() * stage.width,
+					      y: Math.random() * stage.height / 2 + stage.height / 2,
+					      rotation_angle_z: rectangles[i].rotation_angle_z,
+					      opacity: 0 
 					  });
 		//rotation_angle change makes it stop spinning. don't know why it's still
 		//spinning here, it really should have stopped when the timeline did. 
diff --git a/examples/same-seed/light.js b/examples/same-seed/light.js
index 79201fd..0b6d9bb 100644
--- a/examples/same-seed/light.js
+++ b/examples/same-seed/light.js
@@ -2,117 +2,117 @@ var tile_svg_size = 50;
 
 function load_svg(file)
 {
-	var tx = new Clutter.Texture({filename: file});
-	tx.filter_quality = Clutter.TextureQuality.HIGH;
-	return tx;
+    var tx = new Clutter.Texture({filename: file});
+    tx.filter_quality = Clutter.TextureQuality.HIGH;
+    return tx;
 }
 
 var colors = [load_svg("blue.svg"), load_svg("green.svg"),
-			  load_svg("red.svg"), load_svg("yellow.svg")];
+	      load_svg("red.svg"), load_svg("yellow.svg")];
 
 Light = new GType({
-	parent: Clutter.Group.type,
-	name: "Light",
-	init: function()
+    parent: Clutter.Group.type,
+    name: "Light",
+    init: function()
+    {
+	// Private
+	var closed = false;
+	var light_x, light_y;
+	var state = Math.floor(Math.random() * max_colors);
+	
+	// Public
+	this.visited = false;
+	
+	this.on = new Clutter.Clone({source: colors[state],
+				     reactive: true});
+	
+	this.get_state = function ()
 	{
-		// Private
-		var closed = false;
-		var light_x, light_y;
-		var state = Math.floor(Math.random() * max_colors);
-		
-		// Public
-		this.visited = false;
-		
-		this.on = new Clutter.Clone({source: colors[state],
-									 reactive: true});
-		
-		this.get_state = function ()
-		{
-			return state;
-		};
-		
-		this.animate_out = function (timeline)
-		{
-			this.on.anim = this.on.animate_with_timeline(Clutter.AnimationMode.LINEAR, timeline,
-			{
-				height: [GObject.TYPE_INT, tile_size * 2],
-				width: [GObject.TYPE_INT, tile_size * 2],
-				x: [GObject.TYPE_INT, -tile_size/2],
-				y: [GObject.TYPE_INT, -tile_size/2]
-			});
-			
-			this.anim = this.animate_with_timeline(Clutter.AnimationMode.LINEAR, timeline,
-			{
-				opacity: [GObject.TYPE_UCHAR, 0]
-			});
-			
-			timeline.signal.completed.connect(this.hide_light, this);
-			
-			GLib.main_context_iteration();
-		};
-		
-		this.animate_to = function (new_x, new_y, timeline)
-		{
-			this.anim = this.animate_with_timeline(Clutter.AnimationMode.EASE_OUT_BOUNCE, timeline,
-			{
-				x: [GObject.TYPE_INT, new_x],
-				y: [GObject.TYPE_INT, new_y]
-			});
-			
-			GLib.main_context_iteration();
-		};
-		
-		this.get_closed = function ()
-		{
-			return closed;
-		};
-		
-		this.close_tile = function (timeline)
-		{
-			closed = true;
-			this.animate_out(timeline);
-		};
-		
-		this.hide_light = function (timeline, light)
-		{
-			light.hide();
-			
-			delete on;
-			
-			if(light.anim)
-				delete light.anim;
-			
-			return false;
-		};
-		
-		this.set_light_x = function (new_x)
-		{
-			light_x = new_x;
-		};
-		
-		this.set_light_y = function (new_y)
-		{
-			light_y = new_y;
-		};
-		
-		this.get_light_x = function ()
-		{
-			return light_x;
-		};
-		
-		this.get_light_y = function ()
-		{
-			return light_y;
-		};
-		
-		// Implementation
-		this.on.set_size(tile_size, tile_size);
-		
-		this.opacity = 180;
-		
-		this.set_anchor_point(tile_size / 2, tile_size / 2);
-		
-		this.add_actor(this.on);
-	}
+	    return state;
+	};
+	
+	this.animate_out = function (timeline)
+	{
+	    this.on.anim = this.on.animate_with_timeline(Clutter.AnimationMode.LINEAR, timeline,
+							 {
+							     height: tile_size * 2,
+							     width: tile_size * 2,
+							     x: -tile_size/2,
+							     y: -tile_size/2
+							 });
+	    
+	    this.anim = this.animate_with_timeline(Clutter.AnimationMode.LINEAR, timeline,
+						   {
+						       opacity: 0
+						   });
+	    
+	    timeline.signal.completed.connect(this.hide_light, this);
+	    
+	    GLib.main_context_iteration();
+	};
+	
+	this.animate_to = function (new_x, new_y, timeline)
+	{
+	    this.anim = this.animate_with_timeline(Clutter.AnimationMode.EASE_OUT_BOUNCE, timeline,
+						   {
+						       x: new_x,
+						       y: new_y
+						   });
+	    
+	    GLib.main_context_iteration();
+	};
+	
+	this.get_closed = function ()
+	{
+	    return closed;
+	};
+	
+	this.close_tile = function (timeline)
+	{
+	    closed = true;
+	    this.animate_out(timeline);
+	};
+	
+	this.hide_light = function (timeline, light)
+	{
+	    light.hide();
+	    
+	    delete on;
+	    
+	    if(light.anim)
+		delete light.anim;
+	    
+	    return false;
+	};
+	
+	this.set_light_x = function (new_x)
+	{
+	    light_x = new_x;
+	};
+	
+	this.set_light_y = function (new_y)
+	{
+	    light_y = new_y;
+	};
+	
+	this.get_light_x = function ()
+	{
+	    return light_x;
+	};
+	
+	this.get_light_y = function ()
+	{
+	    return light_y;
+	};
+	
+	// Implementation
+	this.on.set_size(tile_size, tile_size);
+	
+	this.opacity = 180;
+	
+	this.set_anchor_point(tile_size / 2, tile_size / 2);
+	
+	this.add_actor(this.on);
+    }
 });
 
diff --git a/examples/same-seed/score.js b/examples/same-seed/score.js
index e7e30dc..39dcb4f 100644
--- a/examples/same-seed/score.js
+++ b/examples/same-seed/score.js
@@ -30,8 +30,8 @@ Score = new GType({
 			
 			this.anim = this.animate(Clutter.AnimationMode.EASE_OUT_SINE,400,
 			{
-				depth: [GObject.TYPE_INT, 500],
-				opacity: [GObject.TYPE_UCHAR, 0]
+			    depth:  500,
+			    opacity: 0,
 			});
 			this.anim.timeline.start();
 			
@@ -55,10 +55,10 @@ Score = new GType({
 			
 			this.anim = this.animate(Clutter.AnimationMode.EASE_OUT_ELASTIC,2000,
 			{
-				scale_x: [GObject.TYPE_DOUBLE, 1],
-				scale_y: [GObject.TYPE_DOUBLE, 1],
+			    scale_x: 1,
+			    scale_y: 1,
 				//y: [GObject.TYPE_INT, stage.width / 2],
-				opacity: [GObject.TYPE_UCHAR, 255]
+			    opacity: 255,
 			});
 			this.anim.timeline.start();
 			
diff --git a/extensions/Clutter.js b/extensions/Clutter.js
index 33565c7..20efdb3 100644
--- a/extensions/Clutter.js
+++ b/extensions/Clutter.js
@@ -2,26 +2,26 @@ Clutter = imports.gi.Clutter;
 
 Clutter.Actor.prototype.animate = function(mode, duration, json)
 {
-	var properties = new Array();
-	var endvalues = new Array();
-	for (var prop in json)	{
-	    properties.push(prop);
-	    endvalues.push([this.__property_type(prop), json[prop]]);
-	}
-	return this.animatev(mode, duration, properties.length, 
-			     properties, endvalues);
+    var properties = new Array();
+    var endvalues = new Array();
+    for (var prop in json)	{
+	properties.push(prop);
+	endvalues.push(new Array(this.__property_type(prop), json[prop]));
+    }
+    return this.animatev(mode, duration, properties.length, 
+			 properties, endvalues);
 
 }
 
 Clutter.Actor.prototype.animate_with_timeline = function(mode, timeline, json)
 {
-	var properties = new Array();
-	var endvalues = new Array();
-	for (var prop in json)	{
-		properties.push(prop);
-		endvalues.push(json[prop]);
-	}
-	return this.animate_with_timelinev(mode, timeline, properties.length, 
-			     properties, endvalues);
+    var properties = new Array();
+    var endvalues = new Array();
+    for (var prop in json)	{
+	properties.push(prop);
+	endvalues.push(new Array(this.__property_type(prop), json[prop]));
+    }
+    return this.animate_with_timelinev(mode, timeline, properties.length, 
+				       properties, endvalues);
 
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]