diff options
Diffstat (limited to 'generic')
-rw-r--r-- | generic/Curve.c | 97 |
1 files changed, 58 insertions, 39 deletions
diff --git a/generic/Curve.c b/generic/Curve.c index 59f6dd6..0c6704d 100644 --- a/generic/Curve.c +++ b/generic/Curve.c @@ -36,7 +36,6 @@ #include "Color.h" #include <ctype.h> -#include <alloca.h> #include <malloc.h> @@ -77,15 +76,16 @@ typedef struct _CurveItemStruct { ZnList points; unsigned int flags; Pixmap marker; - LineEnd first_end; /* These two are considered only if relief is flat */ - LineEnd last_end; + ZnLineEnd first_end; /* These two are considered only if relief is flat */ + ZnLineEnd last_end; LineStyle line_style; /* This is considered only if relief is flat */ int cap_style; int join_style; ReliefStyle relief; int line_width; /* If 0 the path is not drawn, if <2 relief is flat */ Pixmap fill_pattern; - ZnColor fill_color; + ZnColorGradient fill_color; + ZnGradientGeom grad_geom; Pixmap line_pattern; ZnColor line_color; ZnColor marker_color; @@ -115,7 +115,7 @@ static ZnAttrConfig cv_attrs[] = { { ZN_CONFIG_BOOL, "-composescale", NULL, Tk_Offset(CurveItemStruct, header.flags), COMPOSE_SCALE_BIT, ZN_COORDS_FLAG, False }, - { ZN_CONFIG_COLOR, "-fillcolor", NULL, + { ZN_CONFIG_GRADIENT_COLOR, "-fillcolor", NULL, Tk_Offset(CurveItemStruct, fill_color), 0, ZN_DRAW_FLAG|ZN_BORDER_FLAG, False }, { ZN_CONFIG_PATTERN, "-fillpattern", NULL, @@ -124,6 +124,8 @@ static ZnAttrConfig cv_attrs[] = { Tk_Offset(CurveItemStruct, flags), FILLED_BIT, ZN_COORDS_FLAG, False }, { ZN_CONFIG_LINE_END, "-firstend", NULL, Tk_Offset(CurveItemStruct, first_end), 0, ZN_COORDS_FLAG, False }, + { ZN_CONFIG_GRADIENT_GEOM, "-gradient", NULL, + Tk_Offset(CurveItemStruct, grad_geom), 0, ZN_DRAW_FLAG, False }, { ZN_CONFIG_JOIN_STYLE, "-joinstyle", NULL, Tk_Offset(CurveItemStruct, join_style), 0, ZN_COORDS_FLAG, False }, @@ -283,9 +285,11 @@ Init(Item item, */ SET(cv->flags, MARKED_BIT); cv->marker = ZnUnspecifiedPattern; - cv->fill_color = ZnGetColorByValue(wi->win, wi->fore_color); + cv->fill_color = ZnGetColorGradient(wi->interp, wi->win, + ZnNameOfColor(wi->fore_color)); cv->line_color = ZnGetColorByValue(wi->win, wi->fore_color); cv->marker_color = ZnGetColorByValue(wi->win, wi->fore_color); + cv->grad_geom = NULL; return ZN_OK; } @@ -339,8 +343,11 @@ Clone(Item item) Tk_NameOfBitmap(wi->dpy, cv->marker)); } cv->line_color = ZnGetColorByValue(wi->win, cv->line_color); - cv->fill_color = ZnGetColorByValue(wi->win, cv->fill_color); + cv->fill_color = ZnGetColorGradientByValue(cv->fill_color); cv->marker_color = ZnGetColorByValue(wi->win, cv->marker_color); + if (cv->grad_geom) { + cv->grad_geom = GradientGeomDuplicate(cv->grad_geom); + } } @@ -388,9 +395,12 @@ Destroy(Item item) if (cv->marker != ZnUnspecifiedPattern) { Tk_FreeBitmap(wi->dpy, cv->marker); } - ZnFreeColor(cv->fill_color); + ZnFreeColorGradient(cv->fill_color); ZnFreeColor(cv->line_color); ZnFreeColor(cv->marker_color); + if (cv->grad_geom) { + GradientGeomDelete(cv->grad_geom); + } } @@ -464,7 +474,7 @@ Configure(Item item, } if ((cv->relief != RELIEF_FLAT) && !cv->gradient) { cv->gradient = ZnGetReliefGradient(wi->interp, wi->win, - ZnNameOfColor(cv->fill_color)); + ZnNameOfColor(ZnColorGradientMidColor(wi->win, cv->fill_color))); } if (ISSET(*flags, ZN_TILE_FLAG)) { Tk_Image tile; @@ -880,38 +890,45 @@ Draw(Item item) * Fill if requested. */ if (ISSET(cv->flags, FILLED_OK)) { - values.foreground = ZnPixel(cv->fill_color); - gc_mask = GCFillStyle; - if (cv->tile != ZnUnspecifiedImage) { /* Fill tiled */ - Pixmap pmap = GetImagePixmap(wi->win, cv->tile_name, cv->tile, NULL); - values.fill_style = FillTiled; - values.tile = pmap; - values.ts_x_origin = REAL_TO_INT(item->item_bounding_box.orig.x); - values.ts_y_origin = REAL_TO_INT(item->item_bounding_box.orig.y); - gc_mask |= GCTileStipXOrigin|GCTileStipYOrigin|GCTile; - } - else if (cv->fill_pattern != ZnUnspecifiedPattern) { /* Fill stippled */ - values.fill_style = FillStippled; - values.stipple = cv->fill_pattern; - values.ts_x_origin = REAL_TO_INT(item->item_bounding_box.orig.x); - values.ts_y_origin = REAL_TO_INT(item->item_bounding_box.orig.y); - gc_mask |= GCTileStipXOrigin|GCTileStipYOrigin|GCStipple|GCForeground; + if (cv->grad_geom) { + DrawPolygonGradient(wi, cv->grad_geom, cv->fill_color, points, num_points, + &item->item_bounding_box); } - else { /* Fill solid */ - values.fill_style = FillSolid; - gc_mask |= GCForeground; - } - XChangeGC(wi->dpy, wi->gc, gc_mask, &values); + else { + values.foreground = ZnPixel(ZnColorGradientMidColor(wi->win, cv->fill_color)); + gc_mask = GCFillStyle; + if (cv->tile != ZnUnspecifiedImage) { /* Fill tiled */ + Pixmap pmap = GetImagePixmap(wi->win, cv->tile_name, cv->tile, NULL); + values.fill_style = FillTiled; + values.tile = pmap; + values.ts_x_origin = REAL_TO_INT(item->item_bounding_box.orig.x); + values.ts_y_origin = REAL_TO_INT(item->item_bounding_box.orig.y); + gc_mask |= GCTileStipXOrigin|GCTileStipYOrigin|GCTile; + } + else if (cv->fill_pattern != ZnUnspecifiedPattern) { /* Fill stippled */ + values.fill_style = FillStippled; + values.stipple = cv->fill_pattern; + values.ts_x_origin = REAL_TO_INT(item->item_bounding_box.orig.x); + values.ts_y_origin = REAL_TO_INT(item->item_bounding_box.orig.y); + gc_mask |= GCTileStipXOrigin|GCTileStipYOrigin|GCStipple|GCForeground; + } + else { /* Fill solid */ + values.fill_style = FillSolid; + gc_mask |= GCForeground; + } + XChangeGC(wi->dpy, wi->gc, gc_mask, &values); - if (!xpoints) { - xpoints = (XPoint *) alloca(num_points*sizeof(XPoint)); - for (i = 0; i < num_points; i++) { - xpoints[i].x = REAL_TO_INT(points[i].x); - xpoints[i].y = REAL_TO_INT(points[i].y); + if (!xpoints) { + ZnListAssertSize(wi->work_xpts, num_points); + xpoints = (XPoint *) ZnListArray(wi->work_xpts); + for (i = 0; i < num_points; i++) { + xpoints[i].x = REAL_TO_INT(points[i].x); + xpoints[i].y = REAL_TO_INT(points[i].y); + } } + XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, + xpoints, num_points, Complex, CoordModeOrigin); } - XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, - xpoints, num_points, Complex, CoordModeOrigin); } /* @@ -947,7 +964,8 @@ Draw(Item item) &values); } if (!xpoints) { - xpoints = alloca(num_points*sizeof(XPoint)); + ZnListAssertSize(wi->work_xpts, num_points); + xpoints = (XPoint *) ZnListArray(wi->work_xpts); for (i = 0; i < num_points; i++) { xpoints[i].x = REAL_TO_INT(points[i].x); xpoints[i].y = REAL_TO_INT(points[i].y); @@ -1032,7 +1050,8 @@ Draw(Item item) XChangeGC(wi->dpy, wi->gc, GCForeground | GCFillStyle, &values); if (!xpoints) { - xpoints = alloca(num_points*sizeof(XPoint)); + ZnListAssertSize(wi->work_xpts, num_points); + xpoints = (XPoint *) ZnListArray(wi->work_xpts); for (i = 0; i < num_points; i++) { xpoints[i].x = points[i].x; xpoints[i].y = points[i].y; |