[seed] Clutter-Cogl: Beginnings of a 0.9 port.



commit 5e4af4250c36c4505b0e3f14082b5918ae4b10a1
Author: Tim Horton <hortont svn gnome org>
Date:   Tue May 12 04:16:38 2009 -0400

    Clutter-Cogl: Beginnings of a 0.9 port.
    
    Unfortunately, we don't seem to have cogl_set_source_color*, so it doesn't work yet.
---
 examples/{clutter-cogl.js => clutter-cogl-0.8.js} |    0
 examples/clutter-cogl-0.9.js                      |  109 +++++++++++++++++++++
 2 files changed, 109 insertions(+), 0 deletions(-)

diff --git a/examples/clutter-cogl.js b/examples/clutter-cogl-0.8.js
similarity index 100%
rename from examples/clutter-cogl.js
rename to examples/clutter-cogl-0.8.js
diff --git a/examples/clutter-cogl-0.9.js b/examples/clutter-cogl-0.9.js
new file mode 100755
index 0000000..6f7fe6f
--- /dev/null
+++ b/examples/clutter-cogl-0.9.js
@@ -0,0 +1,109 @@
+#!/usr/bin/env seed
+
+imports.gi.versions.Clutter = "0.9";
+
+Clutter = imports.gi.Clutter;
+GLib = imports.gi.GLib;
+GObject = imports.gi.GObject;
+
+const RIPPLE_S = 2000;
+const RIPPLE_W = 8;
+const RIPPLE_G = 2;
+const RIPPLE_N = 3;
+const RIPPLE_MIND = 450;
+const RIPPLE_MAXD = 2000;
+const RIPPLE_WX = RIPPLE_W;
+
+const SCREEN_W = 640;
+const SCREEN_H = 480;
+
+function deg_to_rad(x){
+    return (((x) * 1024.0) / 360.0);
+}
+
+Clutter.init(Seed.argv);
+
+function destroy_actor(actor){
+    actor.destroy();
+}
+
+function circle_paint (actor){
+    var radius = actor.width/2;
+    
+    actor.fill_color.alpha = actor.opacity;
+    
+    Clutter.cogl_set_source_color(actor.fill_color);
+    Clutter.cogl_path_move_to(radius, radius);
+    Clutter.cogl_path_arc(radius, radius, radius, radius,
+			  deg_to_rad(0),
+			  deg_to_rad(360));
+    Clutter.cogl_path_line_to(radius - RIPPLE_WX/2, radius);
+    Clutter.cogl_path_arc(radius, radius, 
+			  radius-RIPPLE_WX/2, radius-RIPPLE_WX/2,
+			  deg_to_rad(0),
+			  deg_to_rad(360));
+    Clutter.cogl_path_close();
+    Clutter.cogl_path_fill();	
+}
+
+function ripple(stage, x, y){
+    var transp = new Clutter.Color();
+    
+    var n = parseInt(Math.random()*RIPPLE_N , 10) + 1;
+    
+    for (i = 0; i < n; i++)
+    {
+		var actor = new Clutter.Rectangle({color: transp});
+	
+		actor.fill_color = new Clutter.Color({red: 0xff,
+							  green: 0xff,
+							  blue: 0xff});
+	
+		var size = ((RIPPLE_W * 2) * (i+1)) + (RIPPLE_G * i);
+	
+		actor.width = actor.height = size;
+		actor.set_anchor_point_from_gravity(Clutter.Gravity.CENTER);
+		actor.x = x;
+		actor.y = y;
+		actor.opacity = 0x80;
+	
+		stage.add_actor(actor);
+	
+		actor.signal["paint"].connect(circle_paint);
+	
+		actor.anim = actor.animate(Clutter.AnimationMode.EASE_OUT_BOUNCE, RIPPLE_S,
+		{
+			width: [GObject.TYPE_INT, SCREEN_W / RIPPLE_W],
+			height: [GObject.TYPE_INT, SCREEN_W / RIPPLE_W],
+			opacity: [GObject.TYPE_UCHAR, 0]
+		});
+	
+		actor.anim.timeline.start();
+	}
+}
+
+var stage = new Clutter.Stage();
+
+stage.width = SCREEN_W;
+stage.height = SCREEN_H;
+stage.color = {};
+
+stage.signal["button_press_event"].connect(
+    function(stage, event){
+	ripple(stage, event.button.x, event.button.y);
+	
+	return true;
+    });
+
+stage.show();
+
+function random_ripple(){
+    ripple(stage, Math.random()*SCREEN_W, Math.random()*SCREEN_H);
+    GLib.timeout_add(0, Math.random()*RIPPLE_MAXD+RIPPLE_MIND, random_ripple);
+    
+    return false;
+}
+
+random_ripple();
+Clutter.main();
+



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