[gbrainy] Do round decimals when dividing coordinates



commit 090040ba27adf857305ac4534c0fd4eabf0671a3
Author: Jordi Mas <jmas softcatala org>
Date:   Wed Jul 13 10:54:24 2011 +0200

    Do round decimals when dividing coordinates

 .../Classical/Dialogs/PlayerHistoryDialog.cs       |    4 ++--
 src/Clients/Classical/Widgets/GameDrawingArea.cs   |    8 ++++----
 src/Core/Libraries/CairoContext.cs                 |    2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/src/Clients/Classical/Dialogs/PlayerHistoryDialog.cs b/src/Clients/Classical/Dialogs/PlayerHistoryDialog.cs
index 36dfd1e..e01cb10 100644
--- a/src/Clients/Classical/Dialogs/PlayerHistoryDialog.cs
+++ b/src/Clients/Classical/Dialogs/PlayerHistoryDialog.cs
@@ -130,11 +130,11 @@ namespace gbrainy.Clients.Classical.Dialogs
 				nh = nw = Math.Min (w, h);
 
 				if (nw < w) {
-					x = (w - nw) / 2;
+					x = (w - nw) / 2d;
 				}
 
 				if (nh < h) {
-					y = (h - nh) / 2;
+					y = (h - nh) / 2d;
 				}
 
 				cr.Translate (x, y);
diff --git a/src/Clients/Classical/Widgets/GameDrawingArea.cs b/src/Clients/Classical/Widgets/GameDrawingArea.cs
index c31c900..fda6f99 100644
--- a/src/Clients/Classical/Widgets/GameDrawingArea.cs
+++ b/src/Clients/Classical/Widgets/GameDrawingArea.cs
@@ -44,8 +44,8 @@ namespace gbrainy.Clients.Classical.Widgets
 		public string Question { get; set; }
 		public string Solution { get; set; }
 		public int DrawingSquare { get; private set; }
-		public int OffsetX { get; private set; }
-		public int OffsetY { get; private set; }
+		public double OffsetX { get; private set; }
+		public double OffsetY { get; private set; }
 		public bool UseSolutionArea { get; set; }
 		public SolutionType SolutionIcon { get; set; }
 
@@ -103,12 +103,12 @@ namespace gbrainy.Clients.Classical.Widgets
 			DrawingSquare = Math.Min (w, h);
 
 			if (DrawingSquare < w)
-				OffsetX = (w - DrawingSquare) / 2;
+				OffsetX = (w - DrawingSquare) / 2d;
 			else
 				OffsetX = 0;
 
 			if (DrawingSquare < h)
-				OffsetY = (h - DrawingSquare) / 2;
+				OffsetY = (h - DrawingSquare) / 2d;
 			else
 				OffsetY = 0;
 
diff --git a/src/Core/Libraries/CairoContext.cs b/src/Core/Libraries/CairoContext.cs
index 13a1497..7ce7b54 100644
--- a/src/Core/Libraries/CairoContext.cs
+++ b/src/Core/Libraries/CairoContext.cs
@@ -200,7 +200,7 @@ namespace gbrainy.Core.Libraries
 			layout.SingleParagraphMode = true;
 			layout.Width = -1;
 			layout.GetPixelSize (out w, out h);
-			MoveTo ((old.X0 + x * old.Xx) - w / 2, old.Y0 + (y * old.Yy) - h / 2);
+			MoveTo ((old.X0 + x * old.Xx) - w / 2d, old.Y0 + (y * old.Yy) - h / 2d);
 			Pango.CairoHelper.ShowLayout (this, layout);
 			Matrix = old;
 		}



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