[gegl] removed arbitrary constants and reversed offset direction



commit 76cb7e30934883229b97b8b599919aae6a61bba6
Author: Andy Gill <andyggill gmail com>
Date:   Thu Jan 13 21:47:47 2011 +0000

    removed arbitrary constants and reversed offset direction

 operations/common/checkerboard.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/operations/common/checkerboard.c b/operations/common/checkerboard.c
index fefc5fc..0896d0e 100644
--- a/operations/common/checkerboard.c
+++ b/operations/common/checkerboard.c
@@ -50,8 +50,7 @@ prepare (GeglOperation *operation)
 static GeglRectangle
 get_bounding_box (GeglOperation *operation)
 {
-  GeglRectangle result = {-10000000, -10000000, 20000000, 20000000};
-  return result;
+  return gegl_rectangle_infinite_plane ();
 }
 
 static gboolean
@@ -74,8 +73,11 @@ process (GeglOperation       *operation,
     {
       gint nx,ny;
 
-      nx = ((x + o->x_offset + 100000 * o->x)/o->x) ;
-      ny = ((y + o->y_offset + 100000 * o->y)/o->y) ;
+      nx = (x - o->x_offset)/o->x;
+      ny = (y - o->y_offset)/o->y;
+      /* shift negative cell indices, because / rounds towards zero. */
+      nx -= (x - o->x_offset) < 0 ? 1 : 0;
+      ny -= (y - o->y_offset) < 0 ? 1 : 0;
 
       if ( (nx+ny) % 2 == 0)
         {



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