diff options
Diffstat (limited to 'generic')
-rw-r--r-- | generic/Draw.c | 71 |
1 files changed, 40 insertions, 31 deletions
diff --git a/generic/Draw.c b/generic/Draw.c index f62d405..fcfbdae 100644 --- a/generic/Draw.c +++ b/generic/Draw.c @@ -455,12 +455,12 @@ DrawRectangleRelief(WidgetInfo *wi, static void DoPolygonRelief(ZnPoint *p, int num_points, - unsigned int line_width, + int line_width, int what_to_do, ...) { int i, j, processed_points, *result; - ZnPoint *p1, *p2; + ZnPoint *p1, *p11, *p2; ZnPoint pp1, pp2, new_pp1, new_pp2; ZnPoint perp, c, shift1, shift2; ZnPoint bevel_points[4]; @@ -510,7 +510,7 @@ DoPolygonRelief(ZnPoint *p, closed = True; num_points--; } - /*printf("num_points=%d(%s)\n\n", num_points, closed?"closed":"");*/ + /*printf("num_points=%d(%s)\n", num_points, closed?"closed":"");*/ /* * We loop on all vertices of the polygon. @@ -579,7 +579,6 @@ DoPolygonRelief(ZnPoint *p, if ((i == -1) || (i == num_points-1)) { p2 = p; } - /* * Skip over close vertices. */ @@ -603,8 +602,8 @@ DoPolygonRelief(ZnPoint *p, IntersectLines(p1, &perp, &new_pp1, &new_pp2, &bevel_points[2]); } else if ((processed_points == num_points-1) && !closed) { - perp.x = p1->x + ((p1-1)->y - p1->y); - perp.y = p1->y - ((p1-1)->x - p1->x); + perp.x = p1->x + (p11->y - p1->y); + perp.y = p1->y - (p11->x - p1->x); IntersectLines(p1, &perp, &pp1, &pp2, &bevel_points[2]); } else if (processed_points >= 1) { @@ -614,10 +613,10 @@ DoPolygonRelief(ZnPoint *p, * The dot product of the two faces tell if the are * folded or colinear. The */ - odx = (p1-1)->x - p1->x; - ody = (p1-1)->y - p1->y; + odx = p11->x - p1->x; + ody = p11->y - p1->y; dotp = odx*dx + ody*dy; - dist = LineToPointDist(p1-1, p2, p1); + dist = LineToPointDist(p11, p2, p1); if ((dist < 4.0) && (dotp <= 0)) { perp.x = p1->x + (p2->y - p1->y); perp.y = p1->y - (p2->x - p1->x); @@ -653,13 +652,13 @@ DoPolygonRelief(ZnPoint *p, } else if (what_to_do == POLYGON_RELIEF_IN_BBOX) { if (processed_points <= 2) { - *result = PolygonInBBox(bevel_points, 4, bbox); + *result = PolygonInBBox(bevel_points, 4, bbox, NULL); if (*result == 0) { return; } } else { - if (PolygonInBBox(bevel_points, 4, bbox) != *result) { + if (PolygonInBBox(bevel_points, 4, bbox, NULL) != *result) { *result = 0; return; } @@ -689,8 +688,7 @@ DoPolygonRelief(ZnPoint *p, toggle = !toggle; #endif gc_values.fill_style = FillSolid; - gc_values.line_width = 0; - XChangeGC(wi->dpy, wi->gc, GCLineWidth|GCFillStyle|GCForeground, &gc_values); + XChangeGC(wi->dpy, wi->gc, GCFillStyle|GCForeground, &gc_values); for (j = 0; j < 4; j++) { bevel_xpoints[j].x = REAL_TO_INT(bevel_points[j].x); @@ -702,12 +700,15 @@ DoPolygonRelief(ZnPoint *p, #endif #if 0 bevel_xpoints[4] = bevel_xpoints[0]; + gc_values.line_width = 0; + XChangeGC(wi->dpy, wi->gc, GCLineWidth, &gc_values); XDrawLines(wi->dpy, wi->draw_buffer, wi->gc, bevel_xpoints, 5, CoordModeOrigin); #endif } } + p11 = p1; p1 = p2; pp1 = new_pp1; pp2 = new_pp2; @@ -733,12 +734,12 @@ DoPolygonRelief(ZnPoint *p, ********************************************************************************** */ void -GetPolygonReliefBBox(ZnList points, - unsigned int line_width, - ZnBBox *bbox) +GetPolygonReliefBBox(ZnPoint *points, + int num_points, + int line_width, + ZnBBox *bbox) { - DoPolygonRelief(ZnListArray(points), ZnListSize(points), - line_width, POLYGON_RELIEF_BBOX, bbox); + DoPolygonRelief(points, num_points, line_width, POLYGON_RELIEF_BBOX, bbox); } @@ -752,14 +753,14 @@ GetPolygonReliefBBox(ZnList points, ********************************************************************************** */ int -PolygonReliefInBBox(ZnList points, - unsigned int line_width, - ZnBBox *area) +PolygonReliefInBBox(ZnPoint *points, + int num_points, + int line_width, + ZnBBox *area) { int result; - DoPolygonRelief(ZnListArray(points), ZnListSize(points), - line_width, POLYGON_RELIEF_IN_BBOX, area, &result); + DoPolygonRelief(points, num_points, line_width, POLYGON_RELIEF_IN_BBOX, area, &result); return result; } @@ -775,14 +776,14 @@ PolygonReliefInBBox(ZnList points, ********************************************************************************** */ double -PolygonReliefToPointDist(ZnList points, - unsigned int line_width, +PolygonReliefToPointDist(ZnPoint *points, + int num_points, + int line_width, ZnPoint *pp) { double dist; - DoPolygonRelief(ZnListArray(points), ZnListSize(points), - line_width, POLYGON_RELIEF_DIST, pp, &dist); + DoPolygonRelief(points, num_points, line_width, POLYGON_RELIEF_DIST, pp, &dist); return dist; } @@ -826,20 +827,28 @@ void DrawPolygonGradient(struct _WidgetInfo *wi, ZnGradientGeom grad_geom, ZnColorGradient grad_color, - ZnPoint *pts, - int num_pts, + ZnPoly *poly, ZnBBox *bbox) { ZnBBox lbbox; XRectangle r; + int i; + /* + * The polygon has to be reduced for this to give meaningful + * results. + */ if (!bbox) { ResetBBox(&lbbox); - AddPointsToBBox(&lbbox, pts, num_pts); + for (i = 0; i < poly->num_contours; i++) { + if (!poly->holes[i]) { + AddPointsToBBox(&lbbox, poly->contours[i].points, poly->contours[i].num_points); + } + } bbox = &lbbox; } BBox2XRect(bbox, &r); - ITEM_P.PushClip(wi, pts, num_pts, False, True); + ITEM_P.PushClip(wi, poly, False, True); DrawRectangleGradient(wi, grad_geom, grad_color, &r); ITEM_P.PopClip(wi, True); } |