radial: When comparing t to mindr, use >= rather than >
authorSøren Sandmann Pedersen <ssp@redhat.com>
Sat, 8 Dec 2012 00:51:19 +0000 (19:51 -0500)
committerSøren Sandmann Pedersen <ssp@redhat.com>
Tue, 11 Dec 2012 14:05:38 +0000 (09:05 -0500)
Radial gradients are conceptually rendered as a sequence of circles
generated by linearly extrapolating from the two circles given by the
gradient specification. Any circles in that sequence that would end up
with a negative radius are not drawn, a condition that is enforced by
checking that t * dr is bigger than mindr:

     if (t * dr > mindr)

However, it is legitimate for a circle to have radius exactly 0, so
the test should use >= rather than >.

This gets rid of the dots in demos/radial-test except for when the c2
circle has radius 0 and a repeat mode of either NONE or NORMAL. Both
those dots correspond to a t value of 1.0, which is outside the
defined interval of [0.0, 1.0) and therefore subject to the repeat
algorithm. As a result, in the NONE case, a value of 1.0 turns into
transparent black. In the NORMAL case, 1.0 wraps around and becomes
0.0 which is red, unlike 0.99 which is blue.

Cc: ranma42@gmail.com
pixman/pixman-radial-gradient.c

index 8d562468d9a9db9b4dc4551de4e4c535597d8997..6a217963da18b397330fbc8bb0ab7e87ab48363e 100644 (file)
@@ -109,7 +109,7 @@ radial_compute_color (double                    a,
        }
        else
        {
-           if (t * dr > mindr)
+           if (t * dr >= mindr)
                return _pixman_gradient_walker_pixel (walker, t);
        }
 
@@ -145,9 +145,9 @@ radial_compute_color (double                    a,
        }
        else
        {
-           if (t0 * dr > mindr)
+           if (t0 * dr >= mindr)
                return _pixman_gradient_walker_pixel (walker, t0);
-           else if (t1 * dr > mindr)
+           else if (t1 * dr >= mindr)
                return _pixman_gradient_walker_pixel (walker, t1);
        }
     }