From 6b36f92065f054abd810d956169a87180677d4f7 Mon Sep 17 00:00:00 2001 From: lecoanet Date: Mon, 18 Feb 2002 16:03:54 +0000 Subject: Passage des couleurs en gradients pour uniformiser --- generic/Rectangle.c | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) (limited to 'generic/Rectangle.c') diff --git a/generic/Rectangle.c b/generic/Rectangle.c index a340a45..8d083a3 100644 --- a/generic/Rectangle.c +++ b/generic/Rectangle.c @@ -65,11 +65,10 @@ typedef struct _RectangleItemStruct { ReliefStyle relief; LineStyle line_style; ZnDim line_width; - ZnColor line_color; + ZnGradient *line_color; Pixmap fill_pattern; Pixmap line_pattern; ZnGradient *fill_color; - int line_alpha; char *tile_name; /* Private data */ @@ -94,9 +93,7 @@ static ZnAttrConfig rect_attrs[] = { Tk_Offset(RectangleItemStruct, flags), FILLED_BIT, ZN_COORDS_FLAG, False }, { ZN_CONFIG_PATTERN, "-fillpattern", NULL, Tk_Offset(RectangleItemStruct, fill_pattern), 0, ZN_DRAW_FLAG, False }, - { ZN_CONFIG_ALPHA, "-linealpha", NULL, - Tk_Offset(RectangleItemStruct, line_alpha), 0, ZN_DRAW_FLAG, False }, - { ZN_CONFIG_COLOR, "-linecolor", NULL, + { ZN_CONFIG_GRADIENT, "-linecolor", NULL, Tk_Offset(RectangleItemStruct, line_color), 0, ZN_DRAW_FLAG, False }, { ZN_CONFIG_PATTERN, "-linepattern", NULL, @@ -200,10 +197,8 @@ Init(Item item, rect->tile_name = ""; rect->tile = ZnUnspecifiedImage; rect->fill_pattern = ZnUnspecifiedPattern; - rect->line_color = ZnGetColorByValue(wi->win, wi->fore_color); - rect->line_alpha = 100; - rect->fill_color = ZnGetGradient(wi->interp, wi->win, - ZnNameOfColor(wi->fore_color)); + rect->line_color = ZnGetGradientByValue(wi->fore_gradient); + rect->fill_color = ZnGetGradientByValue(wi->fore_gradient); return ZN_OK; } @@ -242,7 +237,7 @@ Clone(Item item) rect->fill_pattern = Tk_GetBitmap(wi->interp, wi->win, Tk_NameOfBitmap(wi->dpy, rect->fill_pattern)); } - rect->line_color = ZnGetColorByValue(wi->win, rect->line_color); + rect->line_color = ZnGetGradientByValue(rect->line_color); rect->fill_color = ZnGetGradientByValue(rect->fill_color); } @@ -280,7 +275,7 @@ Destroy(Item item) ZnFree(rect->grad_geo); } ZnFreeGradient(rect->fill_color); - ZnFreeColor(rect->line_color); + ZnFreeGradient(rect->line_color); } @@ -310,8 +305,7 @@ Configure(Item item, } if ((rect->relief != RELIEF_FLAT) && !rect->gradient) { rect->gradient = ZnGetReliefGradient(wi->interp, wi->win, - ZnNameOfColor(ZnGetGradientColor(wi->win, - rect->fill_color, + ZnNameOfColor(ZnGetGradientColor(rect->fill_color, 50.0, NULL))); if (rect->gradient == NULL) { @@ -559,7 +553,7 @@ Draw(Item item) * Fill if requested. */ if (ISSET(rect->flags, FILLED_BIT)) { - values.foreground = ZnPixel(ZnGetGradientColor(wi->win, rect->fill_color, 0.0, NULL)); + values.foreground = ZnPixel(ZnGetGradientColor(rect->fill_color, 0.0, NULL)); if (rect->tile != ZnUnspecifiedImage) { /* Fill tiled */ Pixmap pmap = GetImagePixmap(wi->win, rect->tile_name, rect->tile, NULL); values.fill_style = FillTiled; @@ -624,7 +618,7 @@ Draw(Item item) else { SetLineStyle(wi, rect->line_style); gc_mask = GCFillStyle|GCLineWidth|GCForeground|GCJoinStyle; - values.foreground = ZnPixel(rect->line_color); + values.foreground = ZnPixel(ZnGetGradientColor(rect->line_color, 0, NULL)); values.line_width = (rect->line_width == 1) ? 0 : rect->line_width; values.join_style = JoinMiter; if (ISCLEAR(rect->flags, ALIGNED_BIT)) { @@ -709,8 +703,8 @@ Render(Item item) glEnable(GL_POLYGON_STIPPLE); glPolygonStipple(GetBitmapMask(wi->dpy, rect->fill_pattern)->pixels); } - color = ZnGetGradientColor(wi->win, rect->fill_color, 0.0, &alpha); - alpha = (alpha*wi->alpha/100)*65535/100; + color = ZnGetGradientColor(rect->fill_color, 0.0, &alpha); + alpha = ZnComposeAlpha(alpha, wi->alpha); glColor4us(color->red, color->green, color->blue, alpha); RectRenderCB(rect); glDisable(GL_POLYGON_STIPPLE); @@ -719,6 +713,8 @@ Render(Item item) } if (rect->line_width) { + color = ZnGetGradientColor(rect->line_color, 0, &alpha); + alpha = ZnComposeAlpha(alpha, wi->alpha); if (rect->relief != RELIEF_FLAT) { ZnPoint p[5]; for (i = 0; i < 4; i++) { @@ -727,11 +723,9 @@ Render(Item item) } p[0] = p[4]; RenderPolygonRelief(wi, rect->relief, rect->gradient, - rect->line_alpha, 0, p, 5, rect->line_width); + alpha, 0, p, 5, rect->line_width); } else { - color = rect->line_color; - alpha = rect->line_alpha*wi->alpha/100*65535/100; if ((rect->line_width <= wi->max_line_width) && (rect->line_width <= wi->max_point_width)) { glColor4us(color->red, color->green, color->blue, alpha); @@ -747,7 +741,7 @@ Render(Item item) RenderPolyline(wi, rect->dev, 4, rect->line_width, True, rect->line_style, CapButt, JoinMiter, - NULL, NULL, color, alpha); + NULL, NULL, rect->line_color); } } } -- cgit v1.1