aboutsummaryrefslogtreecommitdiff
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/Arc.c65
1 files changed, 38 insertions, 27 deletions
diff --git a/generic/Arc.c b/generic/Arc.c
index 6165c9e..89dd651 100644
--- a/generic/Arc.c
+++ b/generic/Arc.c
@@ -106,7 +106,7 @@ static ZnAttrConfig arc_attrs[] = {
{ ZN_CONFIG_ANGLE, "-extent", NULL,
Tk_Offset(ArcItemStruct, angle_extent), 0, ZN_COORDS_FLAG, False },
{ ZN_CONFIG_GRADIENT, "-fillcolor", NULL,
- Tk_Offset(ArcItemStruct, fill_color), 0, ZN_DRAW_FLAG, False },
+ Tk_Offset(ArcItemStruct, fill_color), 0, ZN_COORDS_FLAG, False },
{ ZN_CONFIG_BOOL, "-filled", NULL,
Tk_Offset(ArcItemStruct, flags), FILLED_BIT, ZN_COORDS_FLAG, False },
{ ZN_CONFIG_PATTERN, "-fillpattern", NULL,
@@ -491,7 +491,7 @@ ComputeCoordinates(Item item,
int num_p, i;
ZnPoint *p_list, p;
ZnPoint end_points[LINE_END_POINTS];
- ZnReal width_2, height_2, ox, oy;
+ ZnReal width, height, ox, oy;
ResetBBox(&item->item_bounding_box);
/*
@@ -501,13 +501,15 @@ ComputeCoordinates(Item item,
return;
}
+ ZnTransformPoint(wi->current_transfo, &arc->coords[0], &arc->orig);
+ ZnTransformPoint(wi->current_transfo, &arc->coords[1], &arc->corner);
/*
- * Special casing for ellipse rotation and gradient.
+ * Special case for ellipse rotation and gradient.
*/
ZnTransfoDecompose(wi->current_transfo, NULL, NULL, &angle, NULL);
- width_2 = (arc->coords[1].x - arc->coords[0].x)/2.0;
- height_2 = (arc->coords[1].y - arc->coords[0].y)/2.0;
- if (((angle >= PRECISION_LIMIT) && ((width_2 - height_2) > PRECISION_LIMIT)) ||
+ width = arc->coords[1].x - arc->coords[0].x;
+ height = arc->coords[1].y - arc->coords[0].y;
+ if (((angle >= PRECISION_LIMIT) && ((width - height) > PRECISION_LIMIT)) ||
!ZnGradientFlat(arc->fill_color) || wi->render) {
SET(arc->flags, USING_POLY_BIT);
if (!arc->render_shape) {
@@ -521,13 +523,14 @@ ComputeCoordinates(Item item,
&num_p,
arc->render_shape);
- ox = (arc->coords[1].x + arc->coords[0].x)/2.0;
- oy = (arc->coords[1].y + arc->coords[0].y)/2.0;
-
+ ox = (arc->corner.x + arc->orig.x)/2.0;
+ oy = (arc->corner.y + arc->orig.y)/2.0;
+ width = (arc->corner.x - arc->orig.x)/2.0;
+ height = (arc->corner.y - arc->orig.y)/2.0;
+
for (i = 0; i < num_p; i++, p_list++) {
- p.x = ox + p_list->x*width_2;
- p.y = oy + p_list->y*height_2;
- ZnTransformPoint(wi->current_transfo, &p, p_list);
+ p_list->x = ox + p_list->x*width;
+ p_list->y = oy + p_list->y*height;
AddPointToBBox(&item->item_bounding_box, p_list->x, p_list->y);
}
@@ -552,15 +555,15 @@ ComputeCoordinates(Item item,
}
if (!ZnGradientFlat(arc->fill_color)) {
- if (!arc->grad_geo) {
- arc->grad_geo = ZnMalloc(4*sizeof(ZnPoint));
- }
if (arc->fill_color->type == ZN_AXIAL_GRADIENT) {
int angle = arc->fill_color->g.angle;
ZnTransfo *transfo1, *transfo2;
ZnPoint p[4], p1[4];
ZnBBox bbox;
+ if (!arc->grad_geo) {
+ arc->grad_geo = ZnMalloc(4*sizeof(ZnPoint));
+ }
transfo1 = ZnTransfoNew();
transfo2 = ZnTransfoNew();
ZnRotateDeg(transfo1, angle);
@@ -587,23 +590,33 @@ ComputeCoordinates(Item item,
ZnTransfoFree(transfo2);
}
else if (arc->fill_color->type == ZN_RADIAL_GRADIENT) {
- ZnReal dist, new, x0, x, y0, y;
+ ZnReal dist, new, x, y, fact;
+ ZnPoint p1[2];
+ ZnBBox *bbox = &item->item_bounding_box;
+ ZnTransfo *transfo1;
+ if (!arc->grad_geo) {
+ arc->grad_geo = ZnMalloc(2*sizeof(ZnPoint));
+ }
ZnTransformPoint(wi->current_transfo, &arc->fill_color->g.p, &arc->grad_geo[0]);
- x0 = arc->grad_geo[0].x;
- y0 = arc->grad_geo[0].y;
+ transfo1 = ZnTransfoNew();
+ ZnTranslate(transfo1, -arc->grad_geo[0].x, -arc->grad_geo[0].y);
+ fact = (bbox->corner.x-bbox->orig.x)/(bbox->corner.y-bbox->orig.y);
+ ZnScale(transfo1, 1.0, fact);
+ ZnTransformPoint(transfo1, &arc->orig, &p1[0]);
+ ZnTransformPoint(transfo1, &arc->corner, &p1[1]);
dist = 0.0;
- p_list = ZnListArray(arc->render_shape);
- num_p = ZnListSize(arc->render_shape);
- for (i = 0; i < num_p; i++, p_list++) {
- x = p_list->x;
- y = p_list->y;
- new = (x-x0)*(x-x0) + (y-y0)*(y-y0);
+ for (i = 0; i < 2; i++) {
+ x = p1[i].x;
+ y = p1[i].y;
+ new = x*x+y*y;
if (new > dist) {
dist = new;
}
}
arc->grad_geo[1].x = sqrt(dist) + 2; /* Max radius plus a fuzz factor */
+ arc->grad_geo[1].y = arc->grad_geo[1].x / fact;
+ ZnTransfoFree(transfo1);
}
}
else {
@@ -622,8 +635,6 @@ ComputeCoordinates(Item item,
******* ******** **********
*/
CLEAR(arc->flags, USING_POLY_BIT);
- ZnTransformPoint(wi->current_transfo, &arc->coords[0], &arc->orig);
- ZnTransformPoint(wi->current_transfo, &arc->coords[1], &arc->corner);
if (arc->orig.x > arc->corner.x) {
tmp = arc->orig.x;
@@ -1264,7 +1275,7 @@ Render(Item item)
glPolygonStipple(GetBitmapMask(wi->dpy, arc->fill_pattern)->pixels);
}
color = ZnGetGradientColor(wi->win, arc->fill_color, 0.0, &alpha);
- alpha = arc->line_alpha*wi->alpha/100*65535/100;
+ alpha = alpha*wi->alpha/100*65535/100;
glColor4us(color->red, color->green, color->blue, alpha);
ArcRenderCB(arc);
glDisable(GL_POLYGON_STIPPLE);