gbrainy r446 - trunk/src



Author: jmas
Date: Fri Aug 29 17:22:26 2008
New Revision: 446
URL: http://svn.gnome.org/viewvc/gbrainy?rev=446&view=rev

Log:
2008-08-29 Jordi Mas <jmas softcatala org>

	* GameDrawingArea.cs: Use SVG graphics in the Welcome screen



Modified:
   trunk/src/ChangeLog
   trunk/src/GameDrawingArea.cs

Modified: trunk/src/GameDrawingArea.cs
==============================================================================
--- trunk/src/GameDrawingArea.cs	(original)
+++ trunk/src/GameDrawingArea.cs	Fri Aug 29 17:22:26 2008
@@ -86,6 +86,20 @@
 		countdown.EndDrawCountDown ();
 	}
 
+	private void DrawImage (CairoContextEx gr, double x, double y, string img)
+	{
+		SVGImage image = new SVGImage (img);
+		if (image == null)
+			return;
+
+		gr.Save ();
+		gr.Translate (x, y);
+		gr.Scale (0.15 / image.Width, 0.15 / image.Height);
+		image.RenderToCairo (gr.Handle);
+		gr.Restore ();
+		image.Dispose ();
+	}
+
 	private void DrawWelcome (CairoContextEx gr, int area_width, int area_height)
 	{
 		double y = 0.05;
@@ -103,46 +117,21 @@
 		gr.DrawStringWithWrapping (0.05, y + 0.07, Catalog.GetString ("gbrainy is a brain teaser game and trainer to have fun and to keep your brain trained. It includes:"));
 
 		y = 0.25;
-		image = new ImageSurface (Defines.DATA_DIR + "logic-games-80.png");
-		if (image.Width > 0) {
-			gr.Save ();
-			gr.Translate (rtl ? 0.75 : 0.05, y);
-			gr.Scale (0.8 / area_width, 0.8 / area_height);
-			gr.SetSourceSurface (image, 0, 0);
-			gr.Paint ();
-			gr.Restore ();
-			image.Destroy ();
-		}
+
+		DrawImage (gr, rtl ? 0.75 : 0.05, y, Defines.DATA_DIR + "logic-games.svg");
 		gr.DrawStringWithWrapping (rtl ? 0.05 : 0.23, y + 0.01, 
 			Catalog.GetString ("Logic puzzles. Designed to challenge your reasoning and thinking skills."), 
 			rtl ? 0.65 : -1);
 
 		y += space;
-		image = new ImageSurface (Defines.DATA_DIR + "math-games-80.png");
-		if (image.Width > 0) {
-			gr.Save ();
-			gr.Translate (rtl ? 0.75 : 0.05, y);
-			gr.Scale (0.8 / area_width, 0.8 / area_height);
-			gr.SetSourceSurface (image, 0, 0);
-			gr.Paint ();
-			gr.Restore ();
-			image.Destroy ();
-		}
+
+		DrawImage (gr, rtl ? 0.75 : 0.05, y, Defines.DATA_DIR + "math-games.svg");
 		gr.DrawStringWithWrapping (rtl ? 0.05 : 0.23, y + 0.01, 
 			Catalog.GetString ("Mental calculation. Based on arithmetical operations that test your mental calculation abilities."),
 			rtl ? 0.65 : -1);
 
 		y += space;
-		image = new ImageSurface (Defines.DATA_DIR + "memory-games-80.png");
-		if (image.Width > 0) {
-			gr.Save ();
-			gr.Translate (rtl ? 0.75 : 0.05, y);
-			gr.Scale (0.8 / area_width, 0.8 / area_height);
-			gr.SetSourceSurface (image, 0, 0);
-			gr.Paint ();
-			gr.Restore ();
-			image.Destroy ();
-		}
+		DrawImage (gr, rtl ? 0.75 : 0.05, y, Defines.DATA_DIR + "memory-games.svg");
 		gr.DrawStringWithWrapping (rtl ? 0.05 : 0.23, y + 0.01, 
 			Catalog.GetString ("Memory trainers. To prove and enhance your short term memory."),
 			rtl ? 0.65 : -1);



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