seed r76 - trunk/examples



Author: racarr
Date: Mon Nov  3 07:05:33 2008
New Revision: 76
URL: http://svn.gnome.org/viewvc/seed?rev=76&view=rev

Log:
Shader example got moved into shader/*. Change this example to be a 
generic clutter example. Granted not a very good one.


Modified:
   trunk/examples/clutter.js

Modified: trunk/examples/clutter.js
==============================================================================
--- trunk/examples/clutter.js	(original)
+++ trunk/examples/clutter.js	Mon Nov  3 07:05:33 2008
@@ -3,42 +3,59 @@
 
 Clutter.init(null, null);
 
-var stage = new Clutter.Stage();
-var texture = new Clutter.Texture({filename:"bob.jpg"});
-var reflection = new Clutter.CloneTexture({parent_texture:texture});
-var black = Clutter.Color._new();
+colors = [ "blanched almond", 
+	   "OldLace", 
+	   "MistyRose", 
+	   "White", 
+	   "LavenderBlush",
+	   "CornflowerBlue",
+	   "chartreuse",
+	   "chocolate",
+	   "light coral",
+	   "medium violet red",
+	   "LemonChiffon2",
+	   "RosyBrown3"];
 
+stage = new Clutter.Stage();
+timeline = new Clutter.Timeline({fps:60, num_frames:600});
+stage.show_all();
+
+rheight = stage.height/(colors.length);
+width = stage.width;
+rectangles = new Array(colors.length);
+
+black = Clutter.Color._new();
 Clutter.color_parse("Black", black);
 
+stage.color = black;
 
-stage.set_color(black);
-stage.add_actor(texture);
-stage.add_actor(reflection);
-
-reflection.width = reflection.height = 
-   texture.height = texture.width = .55*stage.height;
-texture.x = stage.width/2;
-texture.y = stage.height/2;
-reflection.x = texture.x
-reflection.y = texture.y+texture.height;
-reflection.rotation_angle_z = 180;
-
-reflection.opacity = 80;
-
-reflection.anchor_x = texture.anchor_x = texture.width/2;
-reflection.anchor_y = texture.anchor_y = texture.height/2;
-
-reflection.rotation_angle_y=330;
-texture.rotation_angle_y=30;
-timeline = new Clutter.Timeline({fps:30, num_frames: 60});
-timeline.signal_new_frame.connect(function(timeline, frame_num)
-			  {
-			      texture.rotation_angle_y+=3;
-			      reflection.rotation_angle_y-=3;
-			  });
+for (var i = 0; i < colors.length; i++)
+{
+	c = Clutter.Color._new();
+	Clutter.color_parse(colors[i],c);
+	
+	r = new Clutter.Rectangle();
+	r.width = r.height = rheight;
+	r.color = c;
+	r.y = i * r.height+r.height/2;
+	
+	r.anchor_x = r.height/2;
+	r.anchor_y = r.height/2;
+	
+	stage.add_actor(r);
+	rectangles[i] = r;
+}
+
+timeline.signal_new_frame.connect(
+	function(frame_num)
+	{
+		for (var i = 0; i < colors.length; i++)
+		{
+			rectangles[i].x += width/600;
+			rectangles[i].rotation_angle_z += 1;
+		}
+	});
 timeline.start();
 
-
-stage.show_all();
 Clutter.main();
-
+	   
\ No newline at end of file



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