Code

Fix for gradient code I committed recently (which accidentally used unsigned ints...
authorjaspervdg <jaspervdg@users.sourceforge.net>
Wed, 1 Apr 2009 19:00:07 +0000 (19:00 +0000)
committerjaspervdg <jaspervdg@users.sourceforge.net>
Wed, 1 Apr 2009 19:00:07 +0000 (19:00 +0000)
src/sp-gradient.cpp

index 3abb91690c9f08512c59f6348ee60cd7d64d661a..09c2bd65f2164650af927f5e44222f93fee0f9e6 100644 (file)
@@ -1100,10 +1100,10 @@ sp_gradient_ensure_colors(SPGradient *gr)
         gint o1 = (gint) floor(gr->vector.stops[i + 1].offset * (NCOLORS - 0.001));
         if (o1 > o0) {
             for (int j = o0; j < o1 + 1; j++) {
-                gr->color[4 * j + 0] = r0 + DIV_ROUND((j-o0)*(r1-r0),(o1-o0));
-                gr->color[4 * j + 1] = g0 + DIV_ROUND((j-o0)*(g1-g0),(o1-o0));
-                gr->color[4 * j + 2] = b0 + DIV_ROUND((j-o0)*(b1-b0),(o1-o0));
-                gr->color[4 * j + 3] = a0 + DIV_ROUND((j-o0)*(a1-a0),(o1-o0));
+                gr->color[4 * j + 0] = r0 + ((j-o0)*(r1-r0) + (o1-o0)/2)/(o1-o0);
+                gr->color[4 * j + 1] = g0 + ((j-o0)*(g1-g0) + (o1-o0)/2)/(o1-o0);
+                gr->color[4 * j + 2] = b0 + ((j-o0)*(b1-b0) + (o1-o0)/2)/(o1-o0);
+                gr->color[4 * j + 3] = a0 + ((j-o0)*(a1-a0) + (o1-o0)/2)/(o1-o0);
             }
         }
     }