aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--generic/Draw.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/generic/Draw.c b/generic/Draw.c
index 6ddad6a..9a5fa87 100644
--- a/generic/Draw.c
+++ b/generic/Draw.c
@@ -1394,7 +1394,13 @@ ZnComputeRadialGradient(WidgetInfo *wi,
/*
* Find the gradient focal point in the item space.
+ * The excursion of the focal point outside the item
+ * bbox is clamped to avoid distorsions that take
+ * place due to the rather simple algorithm used to
+ * compute the maximum radius of the gradient.
*/
+ focal_pp->x = fmod(focal_pp->x, 500.0);
+ focal_pp->y = fmod(focal_pp->y, 500.0);
offset.x = focal_pp->x * (bbox.corner.x-bbox.orig.x)/100.0;
offset.y = focal_pp->y * (bbox.corner.y-bbox.orig.y)/100.0;
focal_point.x = (bbox.corner.x+bbox.orig.x)/2 + offset.x;
@@ -1403,7 +1409,7 @@ ZnComputeRadialGradient(WidgetInfo *wi,
/*
* Find the max distance from the focal point.
*/
- if (oval) {
+ if (1/*oval*/) {
/*
* radius.x and radius.y are the shape radiuses.
* ff is the distance from the bbox center to
@@ -1415,14 +1421,20 @@ ZnComputeRadialGradient(WidgetInfo *wi,
/*
* Compute the farthest point from the focal point
* on a unit circle, then map it to the oval and
- * compute the distance between both points.
+ * compute the distance between the two points.
*/
- x = offset.x/ff;
- y = offset.y/ff;
- x *= radius.x;
- y *= radius.y;
- x = x + offset.x;
- y = y + offset.y;
+ if (ff > PRECISION_LIMIT) {
+ x = offset.x/ff;
+ y = offset.y/ff;
+ x *= radius.x;
+ y *= radius.y;
+ x = x + offset.x;
+ y = y + offset.y;
+ }
+ else {
+ x = 0;
+ y = MAX(radius.x, radius.y);
+ }
dist = x*x + y*y;
}
else {
@@ -1626,7 +1638,7 @@ ZnRenderGradient(WidgetInfo *wi,
ZnTransformPoints((ZnTransfo *) quad, genarc, tarc, num_p);
p.x = p.y = 0;
ZnTransformPoint((ZnTransfo *) quad, &p, &focalp);
-
+
position = 0.0;
color = gradient->colors[0].rgb;
alpha = ZnComposeAlpha(gradient->colors[0].alpha, wi->alpha);