aboutsummaryrefslogtreecommitdiff
path: root/generic/Draw.c
diff options
context:
space:
mode:
authorlecoanet2002-12-20 13:54:28 +0000
committerlecoanet2002-12-20 13:54:28 +0000
commitc08d4b1480eb253c6407a98a2b58fd5294178709 (patch)
treef394ee94781c0aaef2770efb1e7648acb87dfe67 /generic/Draw.c
parent48c4bba162de211db0d8cd021a55bca31d74dd35 (diff)
downloadtkzinc-c08d4b1480eb253c6407a98a2b58fd5294178709.zip
tkzinc-c08d4b1480eb253c6407a98a2b58fd5294178709.tar.gz
tkzinc-c08d4b1480eb253c6407a98a2b58fd5294178709.tar.bz2
tkzinc-c08d4b1480eb253c6407a98a2b58fd5294178709.tar.xz
* (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
Diffstat (limited to 'generic/Draw.c')
-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);