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/Map.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'generic/Map.c') diff --git a/generic/Map.c b/generic/Map.c index d7aee0a..e7af2ce 100644 --- a/generic/Map.c +++ b/generic/Map.c @@ -58,9 +58,8 @@ typedef struct _MapItemStruct { /* Public data */ ZnBool filled; - int alpha; Pixmap fill_pattern; - ZnColor color; + ZnGradient *color; ZnFont text_font; /* null value -> use zn_map_text_font */ char *map_info_name; ZnList symbol_patterns; @@ -85,9 +84,7 @@ typedef struct _MapItemStruct { static ZnAttrConfig map_attrs[] = { - { ZN_CONFIG_ALPHA, "-alpha", NULL, - Tk_Offset(MapItemStruct, alpha), 1, ZN_DRAW_FLAG, False }, - { ZN_CONFIG_COLOR, "-color", NULL, + { ZN_CONFIG_GRADIENT, "-color", NULL, Tk_Offset(MapItemStruct, color), 0, ZN_DRAW_FLAG, False }, { ZN_CONFIG_BOOL, "-composerotation", NULL, Tk_Offset(MapItemStruct, header.flags), COMPOSE_ROTATION_BIT, @@ -209,10 +206,9 @@ Init(Item item, item->part_sensitive = 0; item->priority = DEFAULT_MAP_PRIORITY; map->filled = False; - map->alpha = 100; map->fill_pattern = ZnUnspecifiedPattern; map->symbol_patterns = NULL; - map->color = ZnGetColorByValue(wi->win, wi->fore_color); + map->color = ZnGetGradientByValue(wi->fore_gradient); map->text_font = Tk_GetFont(wi->interp, wi->win, Tk_NameOfFont(wi->map_text_font)); map->map_info_name = ""; map->map_info = NULL; @@ -297,7 +293,7 @@ Clone(Item item) UpdateMapInfo, (ClientData) map); } - map->color = ZnGetColorByValue(wi->win, map->color); + map->color = ZnGetGradientByValue(map->color); map->text_font = Tk_GetFont(wi->interp, wi->win, Tk_NameOfFont(map->text_font)); if (map->fill_pattern != ZnUnspecifiedPattern) { map->fill_pattern = Tk_GetBitmap(wi->interp, wi->win, @@ -333,7 +329,7 @@ Destroy(Item item) MapItem map = (MapItem) item; FreeLists(map); - ZnFreeColor(map->color); + ZnFreeGradient(map->color); Tk_FreeFont(map->text_font); if (map->fill_pattern != ZnUnspecifiedPattern) { Tk_FreeBitmap(item->wi->dpy, map->fill_pattern); @@ -994,7 +990,7 @@ Draw(Item item) map_info = map->map_info; - values.foreground = ZnPixel(map->color); + values.foreground = ZnPixel(ZnGetGradientColor(map->color, 0, NULL)); if (map->filled) { if (ZnListSize(map->vectors) || ZnListSize(map->arcs)) { @@ -1281,15 +1277,15 @@ Render(Item item) unsigned int i, cnt; int line_width, new_width; XColor *color; - unsigned char alpha; + int alpha; if (map->map_info == NULL) { return; } map_info = map->map_info; - color = map->color; - alpha = map->alpha*wi->alpha*65535/100; + color = ZnGetGradientColor(map->color, 0, &alpha); + alpha = ZnComposeAlpha(alpha, wi->alpha); glColor4us(color->red, color->green, color->blue, alpha); if (map->filled) { if (ZnListSize(map->vectors) || ZnListSize(map->arcs)) { @@ -1455,13 +1451,14 @@ Render(Item item) p.x = points[i].x-(w+1.0)/2.0; p.y = points[i].y-(h+1.0)/2.0; RenderImage(wi, (ImageBits *) GetBitmapTexture(wi->dpy, sym), - color, alpha, &p); + map->color, &p, True); } } } if (wi->map_distance_symbol != ZnUnspecifiedPattern) { - ImageBits *im_bits = (ImageBits *) GetBitmapTexture(wi->dpy, wi->map_distance_symbol); + ImageBits *im_bits = (ImageBits *) GetBitmapTexture(wi->dpy, + wi->map_distance_symbol); int w, h; Tk_SizeOfBitmap(wi->dpy, wi->map_distance_symbol, &w, &h); @@ -1470,7 +1467,7 @@ Render(Item item) for (i = 0; i < cnt; i++, points++) { p.x = points->x-(w+1)/2; p.y = points->y-(h+1)/2; - RenderImage(wi, im_bits, color, alpha, &p); + RenderImage(wi, im_bits, map->color, &p, True); } } } -- cgit v1.1