From c08d4b1480eb253c6407a98a2b58fd5294178709 Mon Sep 17 00:00:00 2001 From: lecoanet Date: Fri, 20 Dec 2002 13:54:28 +0000 Subject: * (ZnComputeRadialGradient): Clamping des pourcentages d�finissant le centre du gradient afin d'�viter des d�fauts de couverture par calcul erron� du cercle englobant. Il faudrait trouver un meilleur algo pour calculer ce dernier. * (ZnComputeRadialGradient): Correction d'une erreur lorsque le centre d'un gradient radial est au centre d'un arc elliptique --- generic/Draw.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'generic/Draw.c') 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); -- cgit v1.1