seed r404 - trunk/modules/canvas



Author: racarr
Date: Sat Dec  6 04:13:56 2008
New Revision: 404
URL: http://svn.gnome.org/viewvc/seed?rev=404&view=rev

Log:
Another test. 


Added:
   trunk/modules/canvas/test16.js   (contents, props changed)
Modified:
   trunk/modules/canvas/Makefile.am

Modified: trunk/modules/canvas/Makefile.am
==============================================================================
--- trunk/modules/canvas/Makefile.am	(original)
+++ trunk/modules/canvas/Makefile.am	Sat Dec  6 04:13:56 2008
@@ -7,7 +7,7 @@
 libcanvas_la_LDFLAGS = \
 	`pkg-config --libs seed cairo`
 
-EXTRA_DIST=test1.js test2.js test3.js test4.js test5.js test6.js test7.js test8.js test9.js test10.js test11.js test12.js test13.js test14.js test15.js
+EXTRA_DIST=test1.js test2.js test3.js test4.js test5.js test6.js test7.js test8.js test9.js test10.js test11.js test12.js test13.js test14.js test15.js test16.js
 
 AM_CPPFLAGS = \
 	-I../../libseed/ \

Added: trunk/modules/canvas/test16.js
==============================================================================
--- (empty file)
+++ trunk/modules/canvas/test16.js	Sat Dec  6 04:13:56 2008
@@ -0,0 +1,97 @@
+#!/usr/local/bin/seed
+Seed.import_namespace("Gdk");
+Seed.import_namespace("Gtk");
+Seed.import_namespace("Canvas");
+
+
+Gtk.init(null, null);
+
+w = new Gtk.Window();
+d = new Gtk.DrawingArea();
+w.add(d);
+
+w.resize(300, 300);
+
+w.show_all();
+
+function drawSpirograph(ctx,R,r,O){
+		var x1 = R-O;
+		var y1 = 0;
+		var i  = 1;
+		ctx.beginPath();
+		ctx.moveTo(x1,y1);
+		do {
+				if (i>20000) break;
+				var x2 = 
+						(R+r)*Math.cos(i*Math.PI/72) - (r+O)*Math.cos(((R+r)/r)*(i*Math.PI/72))
+						var y2 = 
+						(R+r)*Math.sin(i*Math.PI/72) - (r+O)*Math.sin(((R+r)/r)*(i*Math.PI/72))
+						ctx.lineTo(x2,y2);
+				x1 = x2;
+				y1 = y2;
+				i++;
+		} while (x2 != R-O && y2 != 0 );
+		ctx.stroke();
+}
+
+d.signal.expose_event.connect(function(){
+				var cr = Gdk.cairo_create(d.window);
+				var ctx = new Canvas.CairoCanvas(cr);
+				ctx.strokeStyle = "#fc0";
+				ctx.lineWidth = 1.5;
+				ctx.fillRect(0,0,300,300);
+
+				// Uniform scaling
+				ctx.save()
+						ctx.translate(50,50);
+				drawSpirograph(ctx,22,6,5);
+
+				ctx.translate(100,0);
+				ctx.scale(0.75,0.75);
+				drawSpirograph(ctx,22,6,5);
+
+				ctx.translate(133.333,0);
+				ctx.scale(0.75,0.75);
+				drawSpirograph(ctx,22,6,5);
+				ctx.restore();
+
+				// Non uniform scaling (y direction)
+				ctx.strokeStyle = "#0cf";
+				ctx.save()
+						ctx.translate(50,150);
+				ctx.scale(1,0.75);
+				drawSpirograph(ctx,22,6,5);
+
+				ctx.translate(100,0);
+				ctx.scale(1,0.75);
+				drawSpirograph(ctx,22,6,5);
+
+				ctx.translate(100,0);
+				ctx.scale(1,0.75);
+				drawSpirograph(ctx,22,6,5);
+				ctx.restore();
+
+				// Non uniform scaling (x direction)
+				ctx.strokeStyle = "#cf0";
+				ctx.save()
+						ctx.translate(50,250);
+				ctx.scale(0.75,1);
+				drawSpirograph(ctx,22,6,5);
+
+				ctx.translate(133.333,0);
+				ctx.scale(0.75,1);
+				drawSpirograph(ctx,22,6,5);
+
+				ctx.translate(177.777,0);
+				ctx.scale(0.75,1);
+				drawSpirograph(ctx,22,6,5);
+				ctx.restore();
+
+
+				return true;
+		});
+Gtk.main();
+
+
+
+



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