More ints
authorEnrico Zini <enrico@enricozini.org>
Tue, 8 Dec 2009 22:45:09 +0000 (22:45 +0000)
committerEnrico Zini <enrico@enricozini.org>
Tue, 8 Dec 2009 22:45:09 +0000 (22:45 +0000)
src/fisheye.vala

index fd0e1c5c831f0e6d8b098cafca62cc9e6ba8037e..1fea58f725fbcda57d2b3aef28aa5b96c44e04d5 100644 (file)
@@ -134,11 +134,11 @@ public class FisheyeList : Gtk.DrawingArea
        protected int el_y(int idx)
        {
                // Undistorted Y
-               double undy = (double)idx * allocation.height / list.length;
+               int undy = idx * allocation.height / list.length;
                // Distorted position
-               double pos = fisheye(undy, focus_centre, distortion_factor, 0, allocation.height);
+               int pos = fisheye(undy, focus_centre, distortion_factor, 0, allocation.height);
                //stderr.printf("%d %f %f\n", idx, undy, pos);
-               return (int)Math.round(pos);
+               return pos;
        }
 
        protected void focus_layout()
@@ -242,7 +242,7 @@ public class FisheyeList : Gtk.DrawingArea
      * @param max the end of the display
      * @return the distorted coordinate
      */
-    private double fisheye(double x, int a, double d, int min, int max)
+    private int fisheye(int x, int a, double d, int min, int max)
     {
         if ( d != 0 ) {
             bool left = x<a;
@@ -251,7 +251,7 @@ public class FisheyeList : Gtk.DrawingArea
             if ( m == 0 ) m = max-min;
             v = Math.fabs(x - a) / m;
             v = (d+1)/(d+(1/v));
-            return (left?-1:1)*m*v + a;
+            return (int)Math.round((left?-1:1)*m*v + a);
         } else {
             return x;
         }