[cairo-commit] goocanvas/demo demo.c, 1.32, 1.33 mv-demo.c, 1.14, 1.15

Damon Chaplin commit at pdx.freedesktop.org
Thu Mar 27 07:05:05 PDT 2008


Committed by: damon

Update of /cvs/cairo/goocanvas/demo
In directory kemper:/tmp/cvs-serv15281/demo

Modified Files:
	demo.c mv-demo.c 
Log Message:
2008-03-27  Damon Chaplin  <damon at gnome.org>

	    * src/goocanvasitem.c (goo_canvas_item_get_simple_transform): 
	    * src/goocanvasitemmodel.c (goo_canvas_item_model_get_simple_transform): 
	    new functions to do opposite of set_simple_transform().

	    * demo/mv-demo.c (test_simple_transforms): 
	    * demo/demo.c (test_simple_transforms): added some test code for above.




Index: demo.c
===================================================================
RCS file: /cvs/cairo/goocanvas/demo/demo.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- demo.c	23 Mar 2008 23:33:42 -0000	1.32
+++ demo.c	27 Mar 2008 14:08:54 -0000	1.33
@@ -1354,6 +1354,50 @@
 }
 
 static void
+test_simple_transforms (GooCanvasItem *root)
+{
+#if 0
+  GooCanvasItem *item;
+  int rotation, x, y;
+  double scale, x_out, y_out, scale_out, rotation_out, max_error = 0.0000001;
+
+  item = goo_canvas_rect_new (root, 20, 30, 50, 30,
+			      NULL);
+
+  for (rotation = 0; rotation < 360; rotation += 20)
+    {
+      scale = 0.1;
+      while (scale < 10)
+	{
+	  g_print ("Rotation: %i Scale: %g\n", rotation, scale);
+
+	  for (x = -100; x < 100; x += 10)
+	    {
+	      for (y = -100; y < 100; y += 10)
+		{
+		  goo_canvas_item_set_simple_transform (item, x, y, scale,
+							rotation);
+
+		  goo_canvas_item_get_simple_transform (item, &x_out, &y_out,
+							&scale_out,
+							&rotation_out);
+
+		  if (fabs (x_out - x) > max_error
+		      || fabs (y_out - y) > max_error
+		      || fabs (scale_out - scale) > max_error
+		      || fabs (rotation_out - rotation) > max_error)
+		    {
+		      g_print ("IN X:%i Y:%i Scale:%g Rotation:%i -> %g, %g, %g, %g\n", x, y, scale, rotation, x_out, y_out, scale_out, rotation_out);
+		    }
+		}
+	    }
+	  scale += 0.1;
+	}
+    }
+#endif
+}
+
+static void
 setup_canvas (GooCanvas *canvas)
 {
   GooCanvasItem *root;
@@ -1375,6 +1419,7 @@
 #endif
 
   test_color_properties (root);
+  test_simple_transforms (root);
 }
 
 

Index: mv-demo.c
===================================================================
RCS file: /cvs/cairo/goocanvas/demo/mv-demo.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- mv-demo.c	25 Feb 2008 14:35:02 -0000	1.14
+++ mv-demo.c	27 Mar 2008 14:08:54 -0000	1.15
@@ -1211,6 +1211,51 @@
 }
 
 
+static void
+test_simple_transforms (GooCanvasItemModel *root)
+{
+#if 0
+  GooCanvasItemModel *item;
+  int rotation, x, y;
+  double scale, x_out, y_out, scale_out, rotation_out, max_error = 0.0000001;
+
+  item = goo_canvas_rect_model_new (root, 20, 30, 50, 30,
+				    NULL);
+
+  for (rotation = 0; rotation < 360; rotation += 20)
+    {
+      scale = 0.1;
+      while (scale < 10)
+	{
+	  g_print ("Rotation: %i Scale: %g\n", rotation, scale);
+
+	  for (x = -100; x < 100; x += 10)
+	    {
+	      for (y = -100; y < 100; y += 10)
+		{
+		  goo_canvas_item_model_set_simple_transform (item, x, y, scale,
+							      rotation);
+
+		  goo_canvas_item_model_get_simple_transform (item, &x_out, &y_out,
+							      &scale_out,
+							      &rotation_out);
+
+		  if (fabs (x_out - x) > max_error
+		      || fabs (y_out - y) > max_error
+		      || fabs (scale_out - scale) > max_error
+		      || fabs (rotation_out - rotation) > max_error)
+		    {
+		      g_print ("IN X:%i Y:%i Scale:%g Rotation:%i -> %g, %g, %g, %g\n", x, y, scale, rotation, x_out, y_out, scale_out, rotation_out);
+		    }
+		}
+	    }
+	  scale += 0.1;
+	}
+    }
+#endif
+}
+
+
 static GooCanvasItemModel*
 create_model (void)
 {
@@ -1233,6 +1278,8 @@
   setup_widgets (root);
 #endif
 
+  test_simple_transforms (root);
+
   return root;
 }
 



More information about the cairo-commit mailing list