aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlecoanet2002-02-18 16:03:54 +0000
committerlecoanet2002-02-18 16:03:54 +0000
commit6b36f92065f054abd810d956169a87180677d4f7 (patch)
treed2d16c8be93c67d15670eccce326dba5276acda1
parent67dd05047282a179b5fac88564bb3494a69ecd23 (diff)
downloadtkzinc-6b36f92065f054abd810d956169a87180677d4f7.zip
tkzinc-6b36f92065f054abd810d956169a87180677d4f7.tar.gz
tkzinc-6b36f92065f054abd810d956169a87180677d4f7.tar.bz2
tkzinc-6b36f92065f054abd810d956169a87180677d4f7.tar.xz
Passage des couleurs en gradients pour uniformiser
-rw-r--r--Bezier.c23
-rw-r--r--debian/changelog9
-rw-r--r--generic/Arc.c29
-rw-r--r--generic/Color.c266
-rw-r--r--generic/Color.h14
-rw-r--r--generic/Curve.c47
-rw-r--r--generic/Draw.c91
-rw-r--r--generic/Draw.h4
-rw-r--r--generic/Icon.c22
-rw-r--r--generic/Item.c223
-rw-r--r--generic/Map.c29
-rw-r--r--generic/Rectangle.c36
-rw-r--r--generic/Reticle.c59
-rw-r--r--generic/Text.c23
-rw-r--r--generic/Track.c180
-rw-r--r--generic/Triangles.c86
-rw-r--r--generic/Types.h60
-rw-r--r--generic/WidgetInfo.h3
-rw-r--r--generic/tkZinc.c18
-rw-r--r--sandbox/local.pl24
20 files changed, 595 insertions, 651 deletions
diff --git a/Bezier.c b/Bezier.c
index 2789366..0c0bf3d 100644
--- a/Bezier.c
+++ b/Bezier.c
@@ -77,7 +77,7 @@ typedef struct _BezierItemStruct {
Pixmap fill_pattern;
ZnGradient *fill_color;
Pixmap line_pattern;
- ZnColor line_color;
+ ZnGradient *line_color;
char *tile_name;
/* Private data */
@@ -108,7 +108,7 @@ static ZnAttrConfig bz_attrs[] = {
Tk_Offset(BezierItemStruct, first_end), 0, ZN_COORDS_FLAG, False },
{ ZN_CONFIG_LINE_END, "-lastend", NULL,
Tk_Offset(BezierItemStruct, last_end), 0, ZN_COORDS_FLAG, False },
- { ZN_CONFIG_COLOR, "-linecolor", NULL,
+ { ZN_CONFIG_GRADIENT, "-linecolor", NULL,
Tk_Offset(BezierItemStruct, line_color), 0,
ZN_DRAW_FLAG, False },
{ ZN_CONFIG_PATTERN, "-linepattern", NULL,
@@ -228,9 +228,8 @@ Init(Item item,
bz->line_pattern = ZnUnspecifiedPattern;
bz->cap_style = CapRound;
- bz->fill_color = ZnGetGradient(wi->interp, wi->win,
- ZnNameOfColor(wi->fore_color));
- bz->line_color = ZnGetColorByValue(wi->win, wi->fore_color);
+ bz->fill_color = ZnGetGradientByValue(wi->fore_gradient);
+ bz->line_color = ZnGetGradientByValue(wi->fore_gradient);
return ZN_OK;
}
@@ -279,7 +278,7 @@ Clone(Item item)
bz->fill_pattern = Tk_GetBitmap(wi->interp, wi->win,
Tk_NameOfBitmap(wi->dpy, bz->fill_pattern));
}
- bz->line_color = ZnGetColorByValue(wi->win, bz->line_color);
+ bz->line_color = ZnGetGradientByValue(bz->line_color);
bz->fill_color = ZnGetGradientByValue(bz->fill_color);
}
@@ -326,7 +325,7 @@ Destroy(Item item)
Tk_FreeBitmap(wi->dpy, bz->fill_pattern);
}
ZnFreeGradient(bz->fill_color);
- ZnFreeColor(bz->line_color);
+ ZnFreeGradient(bz->line_color);
}
@@ -386,8 +385,7 @@ Configure(Item item,
}
if ((bz->relief != RELIEF_FLAT) && !bz->gradient) {
bz->gradient = ZnGetReliefGradient(wi->interp, wi->win,
- ZnNameOfColor(ZnGetGradientColor(wi->win,
- bz->fill_color,
+ ZnNameOfColor(ZnGetGradientColor(bz->fill_color,
50.0, NULL)));
if (bz->gradient == NULL) {
status = ZN_ERROR;
@@ -692,7 +690,7 @@ Draw(Item item)
* Fill if requested.
*/
if (ISSET(bz->flags, FILLED_OK)) {
- values.foreground = ZnPixel(ZnGetGradientColor(wi->win, bz->fill_color, 0.0, NULL));
+ values.foreground = ZnPixel(ZnGetGradientColor(bz->fill_color, 0.0, NULL));
gc_mask = GCFillStyle;
if (bz->tile != ZnUnspecifiedImage) { /* Fill tiled */
Pixmap pmap = GetImagePixmap(wi->win, bz->tile_name, bz->tile, NULL);
@@ -743,7 +741,7 @@ Draw(Item item)
}
else {
SetLineStyle(wi, bz->line_style);
- values.foreground = ZnPixel(bz->line_color);
+ values.foreground = ZnPixel(ZnGetGradientColor(bz->line_color, 0, NULL));
values.line_width = (lw == 1) ? 0 : lw;
values.join_style = JoinRound;
values.cap_style = bz->cap_style;
@@ -946,9 +944,10 @@ static ZnBool
GetClipVertices(Item item,
ZnTriStrip *tristrip)
{
+#ifdef GPC_TODO
BezierItem bz = (BezierItem) item;
WidgetInfo *wi = item->wi;
-#ifndef GPC_TODO
+#else
ZnPoint *points;
#endif
diff --git a/debian/changelog b/debian/changelog
index 83af862..326bb29 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+zinc-tk (3.2.3d) unstable; urgency=low
+
+ * Suppression des attributs alpha. Toutes les couleurs
+ sont des gradients et comportent un alpha. Les gradients
+ ont été totalement purgés du code développé pour le
+ rendu sous X (shades).
+
+ -- Patrick Lecoanet <lecoanet@ath.cena.fr> Mon, 18 Feb 2002 17:03:05 +0100
+
zinc-tk (3.2.3c) unstable; urgency=low
* Correction d'un bug de recalcul de la géométrie des
diff --git a/generic/Arc.c b/generic/Arc.c
index f370057..c65a4f1 100644
--- a/generic/Arc.c
+++ b/generic/Arc.c
@@ -74,12 +74,11 @@ typedef struct _ArcItemStruct {
Pixmap line_pattern;
Pixmap fill_pattern;
ZnGradient *fill_color;
- ZnColor line_color;
+ ZnGradient *line_color;
ZnDim line_width;
LineStyle line_style;
ZnLineEnd first_end;
ZnLineEnd last_end;
- int line_alpha;
char *tile_name;
unsigned char flags;
@@ -115,9 +114,7 @@ static ZnAttrConfig arc_attrs[] = {
Tk_Offset(ArcItemStruct, first_end), 0, ZN_COORDS_FLAG, False },
{ ZN_CONFIG_LINE_END, "-lastend", NULL,
Tk_Offset(ArcItemStruct, last_end), 0, ZN_COORDS_FLAG, False },
- { ZN_CONFIG_ALPHA, "-linealpha", NULL,
- Tk_Offset(ArcItemStruct, line_alpha), 0, ZN_DRAW_FLAG, False },
- { ZN_CONFIG_COLOR, "-linecolor", NULL,
+ { ZN_CONFIG_GRADIENT, "-linecolor", NULL,
Tk_Offset(ArcItemStruct, line_color), 0,
ZN_DRAW_FLAG|ZN_BORDER_FLAG, False },
{ ZN_CONFIG_PATTERN, "-linepattern", NULL,
@@ -228,10 +225,8 @@ Init(Item item,
(*args)++;
(*argc)--;
- arc->fill_color = ZnGetGradient(wi->interp, wi->win,
- ZnNameOfColor(wi->fore_color));
- arc->line_alpha = 100;
- arc->line_color = ZnGetColorByValue(wi->win, wi->fore_color);
+ arc->fill_color = ZnGetGradientByValue(wi->fore_gradient);
+ arc->line_color = ZnGetGradientByValue(wi->fore_gradient);
return ZN_OK;
}
@@ -273,7 +268,7 @@ Clone(Item item)
arc->fill_pattern = Tk_GetBitmap(wi->interp, wi->win,
Tk_NameOfBitmap(wi->dpy, arc->fill_pattern));
}
- arc->line_color = ZnGetColorByValue(wi->win, arc->line_color);
+ arc->line_color = ZnGetGradientByValue(arc->line_color);
arc->fill_color = ZnGetGradientByValue(arc->fill_color);
arc->render_shape = NULL;
}
@@ -318,7 +313,7 @@ Destroy(Item item)
ZnFree(arc->grad_geo);
}
ZnFreeGradient(arc->fill_color);
- ZnFreeColor(arc->line_color);
+ ZnFreeGradient(arc->line_color);
}
@@ -1073,9 +1068,7 @@ Draw(Item item)
/* Fill if requested */
if (ISSET(arc->flags, FILLED_BIT)) {
- values.foreground = ZnPixel(ZnGetGradientColor(wi->win,
- arc->fill_color,
- 0.0, NULL));
+ values.foreground = ZnPixel(ZnGetGradientColor(arc->fill_color, 0.0, NULL));
values.arc_mode = ISSET(arc->flags, PIE_SLICE_BIT) ? ArcPieSlice : ArcChord;
if (arc->tile != ZnUnspecifiedImage) { /* Fill Tiled */
Pixmap pmap = GetImagePixmap(wi->win, arc->tile_name, arc->tile, NULL);
@@ -1120,7 +1113,7 @@ Draw(Item item)
ZnPoint tang;
SetLineStyle(wi, arc->line_style);
- values.foreground = ZnPixel(arc->line_color);
+ values.foreground = ZnPixel(ZnGetGradientColor(arc->line_color, 0, NULL));
values.line_width = (arc->line_width == 1) ? 0 : arc->line_width;
values.cap_style = CapRound;
values.join_style = JoinRound;
@@ -1286,8 +1279,8 @@ Render(Item item)
glEnable(GL_POLYGON_STIPPLE);
glPolygonStipple(GetBitmapMask(wi->dpy, arc->fill_pattern)->pixels);
}
- color = ZnGetGradientColor(wi->win, arc->fill_color, 0.0, &alpha);
- alpha = alpha*wi->alpha/100*65535/100;
+ color = ZnGetGradientColor(arc->fill_color, 0.0, &alpha);
+ alpha = ZnComposeAlpha(alpha, wi->alpha);
glColor4us(color->red, color->green, color->blue, alpha);
ArcRenderCB(arc);
glDisable(GL_POLYGON_STIPPLE);
@@ -1314,7 +1307,7 @@ Render(Item item)
}
RenderPolyline(wi, p, num_points, arc->line_width, False,
arc->line_style, CapRound, JoinRound, first, last,
- arc->line_color, arc->line_alpha*wi->alpha/100*65535/100);
+ arc->line_color);
}
#endif
}
diff --git a/generic/Color.c b/generic/Color.c
index 33708c7..f60722a 100644
--- a/generic/Color.c
+++ b/generic/Color.c
@@ -143,11 +143,11 @@ typedef struct {
/*
* Maximum size of a color name including the \0.
*/
-#define COLOR_NAME_SIZE 128
+#define COLOR_NAME_SIZE 32
/*
* Maximum size of a gradient name including the \0.
*/
-#define GRADIENT_NAME_SIZE 512
+#define GRADIENT_NAME_SIZE 1024
/*
* Maximum intensity for a color.
@@ -854,34 +854,32 @@ HsvToRgb(ZnReal h,
*----------------------------------------------------------------------
*/
XColor *
-ZnGetGradientColor(Tk_Window tkwin,
- ZnGradient *grad,
+ZnGetGradientColor(ZnGradient *grad,
ZnReal position,
int *alpha)
{
int index, min, max;
- ZnGradientColor *color, *next_color;
XColor *shade=NULL;
- ZnReal tt;
- if ((grad->num_colors == 1) || (position < 0.0)) {
+ if ((grad->num_colors == 1) || (position <= 0.0)) {
if (alpha) {
- *alpha = grad->colors[0]->alpha;
+ *alpha = grad->colors[0].alpha;
}
- return grad->colors[0]->shades[0];
+ return grad->colors[0].rgb;
}
if (position >= 100.0) {
if (alpha) {
- *alpha = grad->colors[grad->num_colors-1]->alpha;
+ *alpha = grad->colors[grad->num_colors-1].alpha;
}
- shade = grad->colors[grad->num_colors-1]->shades[0];
+ shade = grad->colors[grad->num_colors-1].rgb;
}
else {
min = 0;
max = grad->num_colors-1;
index = (max + min) / 2;
while (max - min != 1) {
- if (grad->colors[index]->position < position) {
+ /*printf("color index %d, min: %d, max: %d\n", index, min, max);*/
+ if (grad->colors[index].position < position) {
min = index;
}
else {
@@ -889,17 +887,9 @@ ZnGetGradientColor(Tk_Window tkwin,
}
index = (max + min) / 2;
}
- /*printf("color index %d ", index);*/
- color = grad->colors[index];
- next_color = grad->colors[index+1];
- tt = (grad->num_shades * (position - (ZnReal) color->position) /
- (ZnReal) (next_color->position - color->position));
- index = (int) tt;
- /*printf("shade index %d %g\n", index, tt);*/
- shade = color->shades[index];
+ shade = grad->colors[index].rgb;
if (alpha) {
- *alpha = ((next_color->alpha-color->alpha) * (position - (ZnReal) color->position) /
- (ZnReal) (next_color->position - color->position));
+ *alpha = grad->colors[index].alpha;
}
}
@@ -938,11 +928,7 @@ ZnGradientFlat(ZnGradient *grad)
* Results:
* The return value is a token for a data structure
* describing a gradient. This token may be passed
- * to the drawing routines. This function allocate
- * the base color and the two end colors in an attempt
- * to use only actually needed resources. The function
- * ZnGetGradientColor asserts that all the colors
- * get allocated when needed.
+ * to the drawing routines.
* If an error prevented the gradient from being created
* then NULL is returned and an error message will be
* left in interp.
@@ -959,9 +945,11 @@ ZnGetReliefGradient(Tcl_Interp *interp,
Tk_Window tkwin,
Tk_Uid name)
{
- XColor *base, light_color, dark_color;
+ XColor *base, light_color, dark_color, color;
char color_name[COLOR_NAME_SIZE];
- int tmp1, tmp2;
+ char buffer[GRADIENT_NAME_SIZE];
+ int j, tmp1, tmp2;
+ int red_range, green_range, blue_range;
base = ZnGetColor(interp, tkwin, name);
/*
@@ -1013,59 +1001,45 @@ ZnGetReliefGradient(Tcl_Interp *interp,
tmp2 = (MAX_INTENSITY + (int) base->blue)/2;
light_color.blue = MAX(tmp1, tmp2);
- sprintf(color_name, "#%02x%02x%02x|#%02x%02x%02x 50|#%02x%02x%02x%%%d",
- dark_color.red/256, dark_color.green/256, dark_color.blue/256,
- base->red/256, base->green/256, base->blue/256,
- light_color.red/256, light_color.green/256, light_color.blue/256,
- RELIEF_STEPS);
+ buffer[0] = 0;
+ sprintf(color_name, "#%02x%02x%02x|",
+ dark_color.red/256, dark_color.green/256, dark_color.blue/256);
+ red_range = (int) base->red - (int) dark_color.red;
+ green_range = (int) base->green - (int) dark_color.green;
+ blue_range = (int) base->blue - (int) dark_color.blue;
+ strcat(buffer, color_name);
+ for (j = 1; j < RELIEF_STEPS; j++) {
+ color.red =(int) dark_color.red + red_range * j/RELIEF_STEPS;
+ color.green = (int) dark_color.green + green_range * j/RELIEF_STEPS;
+ color.blue = (int) dark_color.blue + blue_range * j/RELIEF_STEPS;
+ sprintf(color_name, "#%02x%02x%02x %d|",
+ color.red/256, color.green/256, color.blue/256, 50/RELIEF_STEPS*j);
+ strcat(buffer, color_name);
+ }
+ sprintf(color_name, "#%02x%02x%02x 50|",
+ base->red/256, base->green/256, base->blue/256);
+ strcat(buffer, color_name);
+ red_range = (int) light_color.red - (int) base->red;
+ green_range = (int) light_color.green - (int) base->green;
+ blue_range = (int) light_color.blue - (int) base->blue;
+ for (j = 1; j < RELIEF_STEPS; j++) {
+ color.red =(int) base->red + red_range * j/RELIEF_STEPS;
+ color.green = (int) base->green + green_range * j/RELIEF_STEPS;
+ color.blue = (int) base->blue + blue_range * j/RELIEF_STEPS;
+ sprintf(color_name, "#%02x%02x%02x %d|",
+ color.red/256, color.green/256, color.blue/256, 50+50/RELIEF_STEPS*j);
+ strcat(buffer, color_name);
+ }
+ sprintf(color_name, "#%02x%02x%02x",
+ light_color.red/256, light_color.green/256, light_color.blue/256);
+ strcat(buffer, color_name);
- return ZnGetGradient(interp, tkwin, color_name);
+ /*printf("gradient relief: %s \n", buffer);*/
+ return ZnGetGradient(interp, tkwin, buffer);
}
/*
- *----------------------------------------------------------------------
- *
- * RealizeGradient --
- *
- * This procedure allocate the shades still unallocated in
- * a gradient. The milestone colors are always allocated
- * during the gradient's creation.
- *
- *----------------------------------------------------------------------
- */
-static void
-RealizeGradient(ZnGradient *grad,
- Tk_Window tkwin)
-{
- int i, j, num_colors, num_shades;
- int red_range, green_range, blue_range;
- ZnGradientColor *first, *last;
- XColor color;
-
- /*printf("realizing gradient with %d(%d) colors\n",
- grad->num_colors, BORDER_STEPS);*/
- num_colors = grad->num_colors;
- num_shades = grad->num_shades;
- for (i = 0; i < grad->num_colors-1; i++) {
- first = grad->colors[i];
- last = grad->colors[i+1];
- /*printf("first color : %d %d %d, last color : %d %d %d\n",
- first->shades[0]->red, first->shades[0]->green, first->shades[0]->blue,
- last->shades[0]->red, last->shades[0]->green, last->shades[0]->blue);*/
- red_range = (int) last->shades[0]->red - (int) first->shades[0]->red;
- green_range = (int) last->shades[0]->green - (int) first->shades[0]->green;
- blue_range = (int) last->shades[0]->blue - (int) first->shades[0]->blue;
- for (j = 1; j < num_shades; j++) {
- color.red =(int) first->shades[0]->red + red_range * j/num_shades;
- color.green = (int) first->shades[0]->green + green_range * j/num_shades;
- color.blue = (int) first->shades[0]->blue + blue_range * j/num_shades;
- first->shades[j] = ZnGetColorByValue(tkwin, &color);
- }
- }
-}
-
-/*
*--------------------------------------------------------------
*
* ZnNameGradient
@@ -1130,11 +1104,7 @@ ZnDeleteGradientName(char *name)
* Results:
* The return value is a token for a data structure
* describing a gradient. This token may be passed
- * to the drawing routines. This function allocate
- * the milestone colors in an attempt to use only
- * actually needed resources. The function
- * ZnGetGradientColor asserts that all the colors
- * get allocated when needed.
+ * to the drawing routines.
* If an error prevented the gradient from being created
* then NULL is returned and an error message will be
* left in interp.
@@ -1161,12 +1131,15 @@ ZnGetGradient(Tcl_Interp *interp,
{
Tcl_HashEntry *hash;
ZnGradient *grad;
- int i, j, new, num_colors, num_shades;
+ int i, j, new, num_colors;
char type, *scan_ptr;
int num_tok, angle, position, control;
double x, y;
char *color_ptr, color_name[COLOR_NAME_SIZE];
char buffer[GRADIENT_NAME_SIZE];
+ ZnGradientColor *first, *last;
+ XColor color;
+ int red_range, green_range, blue_range;
if (!name || !*name) {
return NULL;
@@ -1190,31 +1163,12 @@ ZnGetGradient(Tcl_Interp *interp,
/*
* No satisfactory gradient exists yet. Initialize a new one.
*/
- if ((name[0] == '%') || (name[0] == '/') || (name[0] == '(')) {
+ if ((name[0] == '/') || (name[0] == '(') || (name[0] == '[')) {
goto grad_err2;
}
strcpy(buffer, name);
/*
- * Try to obtain how many shades sould be drawn.
- */
- num_shades = 2; /* Minimum needed to have the start and mid range color */
- if ((scan_ptr = strchr(buffer, '%'))) {
- sscanf(scan_ptr, "%%%d", &num_shades);
- /*printf("num shades = %d\n", num_shades);*/
- *scan_ptr = '\0';
- }
- if (num_shades < 2) {
- num_shades = 2;
- }
- else {
- /*
- * Keep num_shades even.
- */
- num_shades /= 2;
- num_shades *= 2;
- }
- /*
* Then look at the gradient type.
*/
type = ZN_AXIAL_GRADIENT;
@@ -1263,9 +1217,8 @@ ZnGetGradient(Tcl_Interp *interp,
* Create the gradient structure.
*/
grad = (ZnGradient *) ZnMalloc(sizeof(ZnGradient) +
- sizeof(ZnGradientColor *)*(num_colors-1));
+ sizeof(ZnGradientColor)*(num_colors-1));
grad->ref_count = 1;
- grad->num_shades = num_shades;
grad->num_colors = num_colors;
grad->type = type;
if (type == ZN_AXIAL_GRADIENT) {
@@ -1280,30 +1233,23 @@ ZnGetGradient(Tcl_Interp *interp,
scan_ptr = strtok(buffer, "|");
for (i = 0; i < num_colors; i++) {
- if (i != num_colors - 1) {
- grad->colors[i] = (ZnGradientColor *) ZnMalloc(sizeof(ZnGradientColor) +
- sizeof(XColor *)*(num_shades-1));
- }
- else {
- grad->colors[i] = (ZnGradientColor *) ZnMalloc(sizeof(ZnGradientColor));
- }
- grad->colors[i]->position = 0;
- grad->colors[i]->control = 50;
- grad->colors[i]->alpha = 100;
+ grad->colors[i].position = 0;
+ grad->colors[i].control = 50;
+ grad->colors[i].alpha = 100;
num_tok = sscanf(scan_ptr, "%s %d %d", color_name, &position, &control);
if (num_tok > 1) {
- grad->colors[i]->position = position;
+ grad->colors[i].position = position;
}
if (num_tok > 2) {
- grad->colors[i]->control = control;
+ grad->colors[i].control = control;
}
if (num_tok == 0) {
Tcl_AppendResult(interp, "incorrect gradient format \"",
name, "\",", NULL);
grad_err:
Tcl_DeleteHashEntry(hash);
- for (j = i; j >= 0; j--) {
- ZnFree(grad->colors[j]);
+ for (j = 0; j < i; j++) {
+ ZnFreeColor(grad->colors[j].rgb);
}
ZnFree(grad);
return NULL;
@@ -1312,47 +1258,59 @@ ZnGetGradient(Tcl_Interp *interp,
if (color_ptr) {
*color_ptr = 0;
}
- grad->colors[i]->shades[0] = ZnGetColor(interp, tkwin, Tk_GetUid(color_name));
+ grad->colors[i].rgb = ZnGetColor(interp, tkwin, Tk_GetUid(color_name));
if (color_ptr) {
*color_ptr = ':';
}
- if (grad->colors[i]->shades[0] == NULL) {
+ if (grad->colors[i].rgb == NULL) {
Tcl_AppendResult(interp, " in gradient,", NULL);
goto grad_err;
}
if (color_ptr) {
- grad->colors[i]->alpha = atoi(color_ptr+1);
- }
- if (i != num_colors - 1) {
- for (j = 1; j < num_shades-1; j++) {
- grad->colors[i]->shades[j] = NULL;
- }
+ grad->colors[i].alpha = atoi(color_ptr+1);
}
if (i == 0) {
- grad->colors[i]->position = 0;
+ grad->colors[i].position = 0;
}
else if (i == num_colors - 1) {
- grad->colors[i]->position = 100;
+ grad->colors[i].position = 100;
}
if ((num_tok > 2) && (i > 0)) {
- if ((grad->colors[i]->position > 100) ||
- (grad->colors[i]->position < grad->colors[i-1]->position)) {
+ if ((grad->colors[i].position > 100) ||
+ (grad->colors[i].position < grad->colors[i-1].position)) {
Tcl_AppendResult(interp, "incorrect color position in gradient \"",
name, "\",", NULL);
goto grad_err;
}
}
- if (grad->colors[i]->control > 100) {
- grad->colors[i]->control = 100;
+ if (grad->colors[i].control > 100) {
+ grad->colors[i].control = 100;
}
- if (grad->colors[i]->alpha > 100) {
- grad->colors[i]->alpha = 100;
+ if (grad->colors[i].alpha > 100) {
+ grad->colors[i].alpha = 100;
}
scan_ptr = strtok(NULL, "|");
}
}
-
- RealizeGradient(grad, tkwin);
+
+ /*
+ * Compute the mid alpha and mid color values. These will be
+ * used by the gradient rendering primitives when a control
+ * is not at mid range. The last color has no mid_* values.
+ */
+ for (i = 0; i < grad->num_colors-1; i++) {
+ first = &grad->colors[i];
+ last = &grad->colors[i+1];
+ red_range = (int) last->rgb->red - (int) first->rgb->red;
+ green_range = (int) last->rgb->green - (int) first->rgb->green;
+ blue_range = (int) last->rgb->blue - (int) first->rgb->blue;
+ color.red =(int) first->rgb->red + red_range*first->control/100;
+ color.green = (int) first->rgb->green + green_range*first->control/100;
+ color.blue = (int) first->rgb->blue + blue_range*first->control/100;
+ first->mid_rgb = ZnGetColorByValue(tkwin, &color);
+ first->mid_alpha = first->alpha + (last->alpha-first->alpha)*first->control/100;
+ }
+ grad->colors[grad->num_colors-1].mid_rgb = NULL;
return grad;
}
@@ -1361,7 +1319,7 @@ ZnGetGradient(Tcl_Interp *interp,
/*
*--------------------------------------------------------------
*
- * ZnNameOfColorGradient --
+ * ZnNameOfGradient --
*
* Given a gradient, return a textual string identifying
* the gradient.
@@ -1403,21 +1361,35 @@ ZnNameOfGradient(ZnGradient *grad)
void
ZnFreeGradient(ZnGradient *grad)
{
- int i, j;
+ int i;
grad->ref_count--;
if (grad->ref_count == 0) {
Tcl_DeleteHashEntry(grad->hash);
- for (i = 0; i < grad->num_colors-1; i++) {
- for (j = 0; j < grad->num_shades; j++) {
- if (grad->colors[i]->shades[j] != NULL) {
- ZnFreeColor(grad->colors[i]->shades[j]);
- }
+ for (i = 0; i < grad->num_colors; i++) {
+ ZnFreeColor(grad->colors[i].rgb);
+ if (grad->colors[i].mid_rgb) {
+ ZnFreeColor(grad->colors[i].mid_rgb);
}
- ZnFree(grad->colors[i]);
}
- ZnFreeColor(grad->colors[grad->num_colors-1]->shades[0]);
- ZnFree(grad->colors[grad->num_colors-1]);
ZnFree(grad);
}
}
+
+
+/*
+ *--------------------------------------------------------------
+ *
+ * ZnComposeAlpha --
+ *
+ * This procedure takes two alpha values in percent and
+ * returns the composite value between 0 and 65535.
+ *
+ *--------------------------------------------------------------
+ */
+int
+ZnComposeAlpha(int alpha1,
+ int alpha2)
+{
+ return (alpha1*alpha2/100)*65535/100;
+}
diff --git a/generic/Color.h b/generic/Color.h
index efbd2b7..bf23af3 100644
--- a/generic/Color.h
+++ b/generic/Color.h
@@ -39,10 +39,10 @@ typedef struct _GradientColor {
* This is in percent of the gradient total size. */
unsigned char control; /* Middle-shade position in percent of this color
* size along the gradient axis. */
- unsigned char alpha;
- XColor *shades[1]; /* The real shades used to draw this color segment.
- * The number of shades is constant for all the colors
- * of a given gradient and is setup in num_shades. */
+ unsigned char alpha; /* The color alpha channel in percent */
+ unsigned char mid_alpha;
+ XColor *rgb; /* The actual color description */
+ XColor *mid_rgb;
} ZnGradientColor;
typedef struct _Gradient {
@@ -54,9 +54,8 @@ typedef struct _Gradient {
int angle; /* Angle spec for an axial gradient (Degrees). */
ZnPoint p; /* Center for a radial gradiant. */
} g;
- int num_shades; /* Number of shades used for each color */
int num_colors; /* Number of colors in gradient spec. */
- ZnGradientColor *colors[1];
+ ZnGradientColor colors[1];
} ZnGradient;
@@ -71,12 +70,13 @@ ZnGradient *ZnGetGradientByValue(ZnGradient *gradient);
ZnGradient *ZnGetReliefGradient(Tcl_Interp *interp, Tk_Window tkwin,
Tk_Uid name);
ZnBool ZnGradientFlat(ZnGradient *grad);
-XColor *ZnGetGradientColor(Tk_Window tkwin, ZnGradient *gradient,
+XColor *ZnGetGradientColor(ZnGradient *gradient,
ZnReal position, int *alpha);
char *ZnNameOfGradient(ZnGradient *gradient);
void ZnFreeGradient(ZnGradient *gradient);
void ZnDeleteGradientName(char *name);
ZnBool ZnNameGradient(Tcl_Interp *interp, Tk_Window tkwin,
char *grad_descr, char *name);
+int ZnComposeAlpha(int alpha1, int alpha2);
#endif /* _Color_h */
diff --git a/generic/Curve.c b/generic/Curve.c
index 4183d27..abec56e 100644
--- a/generic/Curve.c
+++ b/generic/Curve.c
@@ -85,10 +85,9 @@ typedef struct _CurveItemStruct {
Pixmap fill_pattern;
ZnGradient *fill_color;
Pixmap line_pattern;
- ZnColor line_color;
- ZnColor marker_color;
- int line_alpha;
- char *tile_name;
+ ZnGradient *line_color;
+ ZnGradient *marker_color;
+ char *tile_name;
/* Private data */
ZnImage tile;
@@ -124,9 +123,7 @@ static ZnAttrConfig cv_attrs[] = {
ZN_COORDS_FLAG, False },
{ ZN_CONFIG_LINE_END, "-lastend", NULL,
Tk_Offset(CurveItemStruct, last_end), 0, ZN_COORDS_FLAG, False },
- { ZN_CONFIG_ALPHA, "-linealpha", NULL,
- Tk_Offset(CurveItemStruct, line_alpha), 0, ZN_DRAW_FLAG, False },
- { ZN_CONFIG_COLOR, "-linecolor", NULL,
+ { ZN_CONFIG_GRADIENT, "-linecolor", NULL,
Tk_Offset(CurveItemStruct, line_color), 0,
ZN_DRAW_FLAG, False },
{ ZN_CONFIG_PATTERN, "-linepattern", NULL,
@@ -140,7 +137,7 @@ static ZnAttrConfig cv_attrs[] = {
ZN_DRAW_FLAG|ZN_REPICK_FLAG, False },
{ ZN_CONFIG_PATTERN, "-marker", NULL,
Tk_Offset(CurveItemStruct, marker), 0, ZN_COORDS_FLAG, False },
- { ZN_CONFIG_COLOR, "-markercolor", NULL,
+ { ZN_CONFIG_GRADIENT, "-markercolor", NULL,
Tk_Offset(CurveItemStruct, marker_color), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_RELIEF, "-relief", NULL, Tk_Offset(CurveItemStruct, relief), 0,
ZN_COORDS_FLAG, False },
@@ -269,11 +266,9 @@ Init(Item item,
*/
SET(cv->flags, MARKED_BIT);
cv->marker = ZnUnspecifiedPattern;
- cv->fill_color = ZnGetGradient(wi->interp, wi->win,
- ZnNameOfColor(wi->fore_color));
- cv->line_alpha = 100;
- cv->line_color = ZnGetColorByValue(wi->win, wi->fore_color);
- cv->marker_color = ZnGetColorByValue(wi->win, wi->fore_color);
+ cv->fill_color = ZnGetGradientByValue(wi->fore_gradient);
+ cv->line_color = ZnGetGradientByValue(wi->fore_gradient);
+ cv->marker_color = ZnGetGradientByValue(wi->fore_gradient);
return ZN_OK;
}
@@ -347,9 +342,9 @@ Clone(Item item)
cv->marker = Tk_GetBitmap(wi->interp, wi->win,
Tk_NameOfBitmap(wi->dpy, cv->marker));
}
- cv->line_color = ZnGetColorByValue(wi->win, cv->line_color);
+ cv->line_color = ZnGetGradientByValue(cv->line_color);
cv->fill_color = ZnGetGradientByValue(cv->fill_color);
- cv->marker_color = ZnGetColorByValue(wi->win, cv->marker_color);
+ cv->marker_color = ZnGetGradientByValue(cv->marker_color);
cv->tristrip.num_strips = 0;
}
@@ -400,8 +395,8 @@ Destroy(Item item)
Tk_FreeBitmap(wi->dpy, cv->marker);
}
ZnFreeGradient(cv->fill_color);
- ZnFreeColor(cv->line_color);
- ZnFreeColor(cv->marker_color);
+ ZnFreeGradient(cv->line_color);
+ ZnFreeGradient(cv->marker_color);
if (cv->tristrip.num_strips) {
TRI_FREE(&cv->tristrip);
@@ -473,8 +468,7 @@ Configure(Item item,
}
if ((cv->relief != RELIEF_FLAT) && !cv->gradient) {
cv->gradient = ZnGetReliefGradient(wi->interp, wi->win,
- ZnNameOfColor(ZnGetGradientColor(wi->win,
- cv->fill_color,
+ ZnNameOfColor(ZnGetGradientColor(cv->fill_color,
50.0, NULL)));
if (cv->gradient == NULL) {
status = ZN_ERROR;
@@ -1000,7 +994,7 @@ Draw(Item item)
* Fill if requested.
*/
if (ISSET(cv->flags, FILLED_OK)) {
- values.foreground = ZnPixel(ZnGetGradientColor(wi->win, cv->fill_color, 0.0, NULL));
+ values.foreground = ZnPixel(ZnGetGradientColor(cv->fill_color, 0.0, NULL));
gc_mask = GCFillStyle;
if (cv->tile != ZnUnspecifiedImage) { /* Fill tiled */
Pixmap pmap = GetImagePixmap(wi->win, cv->tile_name, cv->tile, NULL);
@@ -1098,7 +1092,7 @@ Draw(Item item)
}
else {
SetLineStyle(wi, cv->line_style);
- values.foreground = ZnPixel(cv->line_color);
+ values.foreground = ZnPixel(ZnGetGradientColor(cv->line_color, 0, NULL));
values.line_width = (cv->line_width == 1) ? 0 : cv->line_width;
values.join_style = cv->join_style;
values.cap_style = cv->cap_style;
@@ -1165,7 +1159,7 @@ Draw(Item item)
h_height = (height+1)/2;
values.fill_style = FillStippled;
values.stipple = cv->marker;
- values.foreground = ZnPixel(cv->marker_color);
+ values.foreground = ZnPixel(ZnGetGradientColor(cv->marker_color, 0, NULL));
XChangeGC(wi->dpy, wi->gc, GCFillStyle|GCStipple|GCForeground, &values);
for (j = 0; j < cv->dev_shape.num_contours; j++) {
num_points = cv->dev_shape.contours[j].num_points;
@@ -1273,8 +1267,8 @@ Render(Item item)
glEnable(GL_POLYGON_STIPPLE);
glPolygonStipple(GetBitmapMask(wi->dpy, cv->fill_pattern)->pixels);
}
- color = ZnGetGradientColor(wi->win, cv->fill_color, 0.0, &alpha);
- alpha = alpha*wi->alpha/100*65535/100;
+ color = ZnGetGradientColor(cv->fill_color, 0.0, &alpha);
+ alpha = ZnComposeAlpha(alpha, wi->alpha);
glColor4us(color->red, color->green, color->blue, alpha);
CurveRenderCB(cv);
glDisable(GL_POLYGON_STIPPLE);
@@ -1288,7 +1282,8 @@ Render(Item item)
/*
* Drawing with relief disables: ends, line style and line pattern.
*/
- alpha = cv->line_alpha*wi->alpha/100*65535/100;
+ ZnGetGradientColor(cv->line_color, 0, &alpha);
+ alpha = ZnComposeAlpha(alpha, wi->alpha);
if (ISSET(cv->flags, RELIEF_OK)) {
relief = cv->relief;
for (j = 0; j < cv->dev_shape.num_contours; j++) {
@@ -1331,7 +1326,7 @@ Render(Item item)
cv->dev_shape.contours[j].num_points,
cv->line_width, closed,
cv->line_style, cv->cap_style, cv->join_style,
- first, last, cv->line_color, alpha);
+ first, last, cv->line_color);
}
}
}
diff --git a/generic/Draw.c b/generic/Draw.c
index b0032b3..b019bb7 100644
--- a/generic/Draw.c
+++ b/generic/Draw.c
@@ -381,7 +381,7 @@ ReliefColorOfSegment(ZnReal x1,
angle,
RadianToDegrees(origin));*/
- return ZnGetGradientColor(wi->win, gradient, position, NULL);
+ return ZnGetGradientColor(gradient, position, NULL);
}
@@ -921,7 +921,7 @@ RenderPolygonRelief(WidgetInfo *wi,
pd.wi = wi;
pd.gradient = gradient;
- pd.alpha = alpha*wi->alpha/100*65535/100;
+ pd.alpha = ZnComposeAlpha(alpha, wi->alpha);
pd.smooth = smooth;
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
@@ -952,15 +952,16 @@ RenderPolyline(WidgetInfo *wi,
int join_style,
ZnLineEnd first_end,
ZnLineEnd last_end,
- XColor *color,
- int alpha)
+ ZnGradient *gradient)
{
int num_clips = ZnListSize(wi->clip_stack);
ZnPoint end_points[LINE_END_POINTS];
ZnBool need_rcaps, thin;
int pass, i, k, m;
ZnPoint c1, c2;
-
+ XColor *color;
+ int alpha;
+
/*
* The code below draws curves thiner than the min
* of GL_ALIASED_LINE_WIDTH_RANGE and GL_ALIASED_POINT_SIZE_RANGE
@@ -971,6 +972,8 @@ RenderPolyline(WidgetInfo *wi,
*/
thin = ((line_width <= wi->max_line_width) &&
(line_width <= wi->max_point_width));
+ color = ZnGetGradientColor(gradient, 0, &alpha);
+ alpha = ZnComposeAlpha(alpha, wi->alpha);
glColor4us(color->red, color->green, color->blue, alpha);
SetLineStyle(wi, line_style);
glLineWidth(line_width);
@@ -1068,22 +1071,25 @@ RenderPolyline(WidgetInfo *wi,
void
-RenderImage(struct _WidgetInfo *wi,
- ImageBits *image, /* ImageBits or BitmapBits */
- XColor *color,
- int alpha,
- ZnPoint *origin)
+RenderImage(WidgetInfo *wi,
+ ImageBits *image, /* ImageBits or BitmapBits */
+ ZnGradient *gradient,
+ ZnPoint *origin,
+ ZnBool modulate)
{
ZnReal nx, ny;
+ XColor *color;
+ int alpha;
- alpha = alpha*wi->alpha/100*65535/100;
+ color = ZnGetGradientColor(gradient, 0, &alpha);
+ alpha = ZnComposeAlpha(alpha, wi->alpha);
nx = origin->x + image->width;
ny = origin->y + image->height;
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, image->texture);
- if (color) {
+ if (modulate) {
glColor4us(color->red, color->green, color->blue, alpha);
}
else {
@@ -1114,11 +1120,11 @@ RenderTile(struct _WidgetInfo *wi,
int alpha, num_clips = ZnListSize(wi->clip_stack);
if (gradient) {
- ZnGetGradientColor(wi->win, gradient, 0.0, &alpha);
- alpha = alpha*wi->alpha/100*65535/100;
+ ZnGetGradientColor(gradient, 0.0, &alpha);
+ alpha = ZnComposeAlpha(alpha, wi->alpha);
}
else {
- alpha = 65535*wi->alpha/100;
+ alpha = ZnComposeAlpha(100, wi->alpha);
}
if (cb) {
@@ -1283,7 +1289,6 @@ RenderGradient(struct _WidgetInfo *wi,
{
int alpha, angle, i, j;
int type = gradient->type;
- int num_shades = gradient->num_shades;
XColor *color;
ZnPoint p;
ZnPoint dposa, dposb, dposc, dposd;
@@ -1342,12 +1347,12 @@ RenderGradient(struct _WidgetInfo *wi,
*/
glBegin(GL_QUAD_STRIP);
for (i = 0; i < gradient->num_colors; i++) {
- color = gradient->colors[i]->shades[0];
- alpha = gradient->colors[i]->alpha*wi->alpha/100*65535/100;
+ color = gradient->colors[i].rgb;
+ alpha = ZnComposeAlpha(gradient->colors[i].alpha, wi->alpha);
glColor4us(color->red, color->green, color->blue, alpha);
- pos = gradient->colors[i]->position;
- control = gradient->colors[i]->control;
+ pos = gradient->colors[i].position;
+ control = gradient->colors[i].control;
dposa.x = (quad[1].x - quad[0].x)*pos/100.0;
dposa.y = (quad[1].y - quad[0].y)*pos/100.0;
p.x = quad[0].x + dposa.x;
@@ -1361,11 +1366,11 @@ RenderGradient(struct _WidgetInfo *wi,
glVertex2f(p.x, p.y);
if ((control != 50.0) && (i != gradient->num_colors-1)) {
- color = gradient->colors[i]->shades[num_shades/2];
- alpha = gradient->colors[i]->alpha*wi->alpha/100*65535/100;
+ color = gradient->colors[i].mid_rgb;
+ alpha = ZnComposeAlpha(gradient->colors[i].mid_alpha, wi->alpha);
glColor4us(color->red, color->green, color->blue, alpha);
- npos = gradient->colors[i+1]->position;
+ npos = gradient->colors[i+1].position;
dposc.x = (quad[1].x - quad[0].x)*npos/100.0;
dposc.y = (quad[1].y - quad[0].y)*npos/100.0;
dcontrol.x = (dposc.x - dposa.x)*control/100.0;
@@ -1396,16 +1401,16 @@ RenderGradient(struct _WidgetInfo *wi,
genarc = GetCirclePoints(3, ZN_CIRCLE_FINE, 0, 360, &num_p, NULL);
radiusx = 0;
radiusy = 0;
- color = gradient->colors[0]->shades[0];
- alpha = gradient->colors[0]->alpha*wi->alpha/100*65535/100;
- control = gradient->colors[0]->control;
+ color = gradient->colors[0].rgb;
+ alpha = ZnComposeAlpha(gradient->colors[0].alpha, wi->alpha);
+ control = gradient->colors[0].control;
for (j = 1; j < gradient->num_colors; j++) {
- radius2x = quad[1].x*gradient->colors[j]->position/100.0;
- radius2y = quad[1].y*gradient->colors[j]->position/100.0;
+ radius2x = quad[1].x*gradient->colors[j].position/100.0;
+ radius2y = quad[1].y*gradient->colors[j].position/100.0;
if ((control != 50) && (j != gradient->num_colors-1)) {
glBegin(GL_QUAD_STRIP);
- color2 = gradient->colors[j-1]->shades[num_shades/2];
- alpha2 = gradient->colors[j-1]->alpha*wi->alpha/100*65535/100;
+ color2 = gradient->colors[j-1].mid_rgb;
+ alpha2 = ZnComposeAlpha(gradient->colors[j-1].mid_alpha, wi->alpha);
radius3x = radiusx + (radius2x-radiusx)*control/100.0;
radius3y = radiusy + (radius2y-radiusy)*control/100.0;
for (i = 0; i < num_p; i++) {
@@ -1425,8 +1430,8 @@ RenderGradient(struct _WidgetInfo *wi,
glEnd();
}
glBegin(GL_QUAD_STRIP);
- color2 = gradient->colors[j]->shades[0];
- alpha2 = gradient->colors[j]->alpha*wi->alpha/100*65535/100;
+ color2 = gradient->colors[j].rgb;
+ alpha2 = ZnComposeAlpha(gradient->colors[j].alpha, wi->alpha);
for (i = 0; i < num_p; i++) {
x = quad[0].x+genarc[i].x*radiusx;
y = quad[0].y+genarc[i].y*radiusy;
@@ -1442,7 +1447,7 @@ RenderGradient(struct _WidgetInfo *wi,
radiusy = radius2y;
color = color2;
alpha = alpha2;
- control = gradient->colors[j]->control;
+ control = gradient->colors[j].control;
}
}
else if (type == ZN_PATH_GRADIENT) {
@@ -1468,22 +1473,22 @@ RenderGradient(struct _WidgetInfo *wi,
glBegin(GL_QUAD_STRIP);
p.x = p.y = pp.x = pp.y = 0;
- control = gradient->colors[0]->control;
- position = gradient->colors[0]->position;
- alpha = gradient->colors[0]->alpha*wi->alpha/100*65535/100;
- color = gradient->colors[0]->shades[0];
+ control = gradient->colors[0].control;
+ position = gradient->colors[0].position;
+ alpha = ZnComposeAlpha(gradient->colors[0].alpha, wi->alpha);
+ color = gradient->colors[0].rgb;
glColor4us(color->red, color->green, color->blue, alpha);
glVertex2f(quad[0].x+p.x, quad[0].y+p.y);
glVertex2f(quad[0].x+pp.x, quad[0].y+pp.y);
for (j = 0; j < gradient->num_colors-1; j++) {
- position = gradient->colors[j+1]->position;
+ position = gradient->colors[j+1].position;
p2.x = (points[i].x-quad[0].x)*position/100.0;
p2.y = (points[i].y-quad[0].y)*position/100.0;
pp2.x = (points[ii].x-quad[0].x)*position/100.0;
pp2.y = (points[ii].y-quad[0].y)*position/100.0;
if (control != 50) {
- color = gradient->colors[j]->shades[num_shades/2];
- alpha = gradient->colors[j]->alpha*wi->alpha/100*65535/100;
+ color = gradient->colors[j].mid_rgb;
+ alpha = ZnComposeAlpha(gradient->colors[j].mid_alpha, wi->alpha);
p3.x = p.x+(p2.x-p.x)*control/100.0;
p3.y = p.y+(p2.y-p.y)*control/100.0;
pp3.x = pp.x+(pp2.x-pp.x)*control/100.0;
@@ -1492,9 +1497,9 @@ RenderGradient(struct _WidgetInfo *wi,
glVertex2f(quad[0].x+p3.x, quad[0].y+p3.y);
glVertex2f(quad[0].x+pp3.x, quad[0].y+pp3.y);
}
- control = gradient->colors[j+1]->control;
- alpha = gradient->colors[j+1]->alpha*wi->alpha/100*65535/100;
- color = gradient->colors[j+1]->shades[0];
+ control = gradient->colors[j+1].control;
+ alpha = ZnComposeAlpha(gradient->colors[j+1].alpha, wi->alpha);
+ color = gradient->colors[j+1].rgb;
p = p2;
pp = pp2;
glColor4us(color->red, color->green, color->blue, alpha);
diff --git a/generic/Draw.h b/generic/Draw.h
index 4524c05..e4632ee 100644
--- a/generic/Draw.h
+++ b/generic/Draw.h
@@ -108,7 +108,7 @@ void RenderPolygonRelief(struct _WidgetInfo *wi, ReliefStyle relief,
void RenderPolyline(struct _WidgetInfo *wi, ZnPoint *points, int num_points,
int line_width, ZnBool closed, LineStyle line_style,
int cap_style, int join_style, ZnLineEnd first_end,
- ZnLineEnd last_end, XColor *color, int alpha);
+ ZnLineEnd last_end, ZnGradient *gradient);
void ComputeAxialGradient(struct _WidgetInfo *wi, ZnPoly *shape, int angle,
ZnPoint *grad_geo);
void ComputeRadialGradient(struct _WidgetInfo *wi, ZnPoly *shape, ZnBBox *bbox,
@@ -120,7 +120,7 @@ void RenderTile(struct _WidgetInfo *wi, struct _ImageBits *tile,
ZnGradient *gradient, void cb(void *), void *closure,
ZnPoint *quad);
void RenderImage(struct _WidgetInfo *wi, struct _ImageBits *image,
- XColor *color, int alpha, ZnPoint *origin);
+ ZnGradient *gradient, ZnPoint *origin, ZnBool modulate);
void RenderHollowDot(struct _WidgetInfo *wi, ZnPoint *p, ZnReal size);
#endif
diff --git a/generic/Icon.c b/generic/Icon.c
index 94e7bec..d824c0c 100644
--- a/generic/Icon.c
+++ b/generic/Icon.c
@@ -55,8 +55,8 @@ typedef struct _IconItemStruct {
ZnAnchor anchor;
ZnAnchor connection_anchor;
Pixmap mask; /* Used only if the image is *NOT* specified */
- ZnColor color; /* Used only with the mask in GLX */
- int alpha; /* Used only with the image in GLX */
+ ZnGradient *color; /* Used only with the mask in GLX (alpha part
+ * is always meaningful). */
/* Private data */
ZnPoint pos_dev;
@@ -65,11 +65,9 @@ typedef struct _IconItemStruct {
static ZnAttrConfig icon_attrs[] = {
- { ZN_CONFIG_ALPHA, "-alpha", NULL,
- Tk_Offset(IconItemStruct, alpha), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_ANCHOR, "-anchor", NULL,
Tk_Offset(IconItemStruct, anchor), 0, ZN_COORDS_FLAG, False },
- { ZN_CONFIG_COLOR, "-color", NULL,
+ { ZN_CONFIG_GRADIENT, "-color", NULL,
Tk_Offset(IconItemStruct, color), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_BOOL, "-composerotation", NULL,
Tk_Offset(IconItemStruct, header.flags), COMPOSE_ROTATION_BIT,
@@ -156,8 +154,7 @@ Init(Item item,
icon->anchor = ZnAnchorNW;
icon->connection_anchor = ZnAnchorSW;
icon->mask = ZnUnspecifiedPattern;
- icon->color = ZnGetColorByValue(wi->win, wi->fore_color);
- icon->alpha = 100;
+ icon->color = ZnGetGradientByValue(wi->fore_gradient);
return ZN_OK;
}
@@ -188,7 +185,7 @@ Clone(Item item)
icon->mask = Tk_GetBitmap(wi->interp, wi->win,
Tk_NameOfBitmap(wi->dpy, icon->mask));
}
- icon->color = ZnGetColorByValue(wi->win, icon->color);
+ icon->color = ZnGetGradientByValue(icon->color);
}
@@ -216,7 +213,7 @@ Destroy(Item item)
Tk_FreeBitmap(wi->dpy, icon->mask);
icon->mask = ZnUnspecifiedPattern;
}
- ZnFreeColor(icon->color);
+ ZnFreeGradient(icon->color);
}
@@ -517,7 +514,7 @@ Draw(Item item)
values.stipple = icon->mask;
values.ts_x_origin = icon->pos_dev.x;
values.ts_y_origin = icon->pos_dev.y;
- values.foreground = ZnPixel(icon->color);
+ values.foreground = ZnPixel(ZnGetGradientColor(icon->color, 0, NULL));
gc_mask |= GCFillStyle | GCStipple | GCTileStipXOrigin | GCTileStipYOrigin | GCForeground;
XChangeGC(wi->dpy, wi->gc, gc_mask, &values);
XFillRectangle(wi->dpy, wi->draw_buffer, wi->gc,
@@ -541,14 +538,13 @@ Render(Item item)
WidgetInfo *wi = item->wi;
IconItem icon = (IconItem) item;
-
if (icon->image != ZnUnspecifiedImage) {
RenderImage(wi, GetImageTexture(wi->win, icon->image_name, icon->image),
- NULL, icon->alpha, &icon->pos_dev);
+ icon->color, &icon->pos_dev, False);
}
else if (icon->mask != ZnUnspecifiedPattern) {
RenderImage(wi, (ImageBits *) GetBitmapTexture(wi->dpy, icon->mask),
- icon->color, icon->alpha, &icon->pos_dev);
+ icon->color, &icon->pos_dev, True);
}
#endif
}
diff --git a/generic/Item.c b/generic/Item.c
index 2ac02b0..067754a 100644
--- a/generic/Item.c
+++ b/generic/Item.c
@@ -70,10 +70,10 @@ static ZnList item_stack = NULL;
*/
typedef struct _FieldStruct {
/* Public data */
- ZnColor color;
+ ZnGradient *color;
ZnGradient *fill_color;
Pixmap fill_pattern;
- ZnColor border_color;
+ ZnGradient *border_color;
char *text;
char *image_name;
char *tile_name;
@@ -116,9 +116,9 @@ ZnAttrConfig field_attrs[] = {
ZN_DRAW_FLAG|ZN_BORDER_FLAG, False },
{ ZN_CONFIG_BORDER, "-border", NULL,
Tk_Offset(FieldStruct, border_edges), 0, ZN_DRAW_FLAG, False },
- { ZN_CONFIG_COLOR, "-bordercolor", NULL,
+ { ZN_CONFIG_GRADIENT, "-bordercolor", NULL,
Tk_Offset(FieldStruct, border_color), 0, ZN_DRAW_FLAG, False },
- { ZN_CONFIG_COLOR, "-color", NULL,
+ { ZN_CONFIG_GRADIENT, "-color", NULL,
Tk_Offset(FieldStruct, color), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_BOOL, "-filled", NULL,
Tk_Offset(FieldStruct, flags), FILLED_BIT, ZN_COORDS_FLAG, False },
@@ -155,7 +155,6 @@ ZnAttrConfig field_attrs[] = {
static char *attribute_type_strings[] = {
"",
"color",
- "colors",
"boolean",
"pattern",
"patterns",
@@ -185,6 +184,7 @@ static char *attribute_type_strings[] = {
"joinstyle",
"capstyle",
"gradient",
+ "gradients",
"window",
"alpha",
};
@@ -400,112 +400,91 @@ ConfigureAttributes(char *record,
}
break;
}
- case ZN_CONFIG_COLORS:
+ case ZN_CONFIG_GRADIENT:
{
- ZnList new_color_list = NULL;
- ZnGradientColor *colors;
- int num_colors, j, k;
- Tcl_Obj **elems;
- char *color_ptr;
+ ZnGradient *g;
+ Tk_Uid new_name = Tk_GetUid(Tcl_GetString(args[i+1]));
+ char *name = NULL;
+ if (*((ZnGradient **) valp)) {
+ name = ZnNameOfGradient(*((ZnGradient **) valp));
+ }
+ if (name != new_name) {
+ g = ZnGetGradient(wi->interp, wi->win, new_name);
+ if (!g) {
+ Tcl_AppendResult(wi->interp,
+ " gradient expected for attribute \"",
+ Tcl_GetString(args[i]), "\"", NULL);
+ return ZN_ERROR;
+ }
+ if (*((ZnGradient **) valp)) {
+ ZnFreeGradient(*((ZnGradient **) valp));
+ }
+ *((ZnGradient **) valp) = g;
+ *flags |= desc->flags;
+ }
+ break;
+ }
+ case ZN_CONFIG_GRADIENTS:
+ {
+ ZnList new_grad_list = NULL;
+ ZnGradient **grads;
+ int num_grads, j, k;
+ Tcl_Obj **elems;
if (Tcl_ListObjGetElements(wi->interp, args[i+1],
- &num_colors, &elems) == ZN_ERROR) {
+ &num_grads, &elems) == ZN_ERROR) {
Tcl_AppendResult(wi->interp,
- " color list expected for attribute \"",
+ " gradient list expected for attribute \"",
Tcl_GetString(args[i]), "\"", NULL);
return ZN_ERROR;
}
- if (num_colors) {
- new_color_list = ZnListNew(num_colors, sizeof(ZnGradientColor));
- ZnListAssertSize(new_color_list, num_colors);
- colors = ZnListArray(new_color_list);
- for (j = 0; j < num_colors; j++) {
+ if (num_grads) {
+ new_grad_list = ZnListNew(num_grads, sizeof(ZnGradient *));
+ ZnListAssertSize(new_grad_list, num_grads);
+ grads = ZnListArray(new_grad_list);
+ for (j = 0; j < num_grads; j++) {
str = Tcl_GetString(elems[j]);
- if (strlen(str) != 0) {
- color_ptr = strchr(str, ':');
- if (color_ptr) {
- *color_ptr = 0;
- }
- colors[j].shades[0] = ZnGetColor(wi->interp, wi->win, Tk_GetUid(str));
- if (color_ptr) {
- *color_ptr = ':';
- }
- if (!colors[j].shades[0]) {
- Tcl_AppendResult(wi->interp, " unknown color \"", str,
- "\" in color list", NULL);
- colors_err:
- for (k = 0; k < j; k++) {
- ZnFreeColor(colors[k].shades[0]);
- }
- ZnListFree(new_color_list);
- return ZN_ERROR;
- }
- if (color_ptr) {
- colors[j].alpha = atoi(color_ptr+1);
- if (colors[j].alpha > 100) {
- colors[j].alpha = 100;
- }
- }
- else {
- colors[j].alpha = 100;
+ if (!*str) {
+ if (j == 0) {
+ goto grads_err;
}
+ grads[j] = grads[j-1];
}
else {
- if (j == 0) {
- Tcl_AppendResult(wi->interp, " first color must not be void", NULL);
- goto colors_err;
- }
- else {
- colors[j].alpha = colors[j-1].alpha;
- colors[j].shades[0] = ZnGetColorByValue(wi->win, colors[j-1].shades[0]);
+ grads[j] = ZnGetGradient(wi->interp, wi->win, str);
+ }
+ if (!grads[j]) {
+ grads_err:
+ Tcl_AppendResult(wi->interp, " invalid gradient \"", str,
+ "\" in gradient list", NULL);
+ for (k = 0; k < j; k++) {
+ ZnFreeGradient(grads[k]);
}
+ ZnListFree(new_grad_list);
+ return ZN_ERROR;
}
}
}
if (*((ZnList *) valp)) {
- num_colors = ZnListSize(*((ZnList *) valp));
- colors = ZnListArray(*((ZnList *) valp));
- for (j = 0; j < num_colors; j++) {
- if (colors[j].shades[0]) {
- ZnFreeColor(colors[j].shades[0]);
+ num_grads = ZnListSize(*((ZnList *) valp));
+ grads = ZnListArray(*((ZnList *) valp));
+ for (j = 0; j < num_grads; j++) {
+ if (grads[j]) {
+ ZnFreeGradient(grads[j]);
}
}
ZnListFree(*((ZnList *) valp));
- *((ZnList *) valp) = new_color_list;
+ *((ZnList *) valp) = new_grad_list;
*flags |= desc->flags;
}
else {
- if (new_color_list) {
- *((ZnList *) valp) = new_color_list;
+ if (new_grad_list) {
+ *((ZnList *) valp) = new_grad_list;
*flags |= desc->flags;
}
}
break;
}
- case ZN_CONFIG_GRADIENT:
- {
- ZnGradient *g;
- Tk_Uid new_name = Tk_GetUid(Tcl_GetString(args[i+1]));
- char *name = NULL;
- if (*((ZnGradient **) valp)) {
- name = ZnNameOfGradient(*((ZnGradient **) valp));
- }
- if (name != new_name) {
- g = ZnGetGradient(wi->interp, wi->win, new_name);
- if (!g) {
- Tcl_AppendResult(wi->interp,
- " gradient expected for attribute \"",
- Tcl_GetString(args[i]), "\"", NULL);
- return ZN_ERROR;
- }
- if (*((ZnGradient **) valp)) {
- ZnFreeGradient(*((ZnGradient **) valp));
- }
- *((ZnGradient **) valp) = g;
- *flags |= desc->flags;
- }
- break;
- }
case ZN_CONFIG_BOOL:
{
int b;
@@ -1282,36 +1261,28 @@ AttributeToObj(WidgetInfo *wi,
Tcl_SetStringObj(result, str, strlen(str));
}
break;
- case ZN_CONFIG_COLORS:
+ case ZN_CONFIG_GRADIENT:
+ if (*((ZnGradient **) valp)) {
+ str = ZnNameOfGradient(*((ZnGradient **) valp));
+ Tcl_SetStringObj(result, str, strlen(str));
+ }
+ break;
+ case ZN_CONFIG_GRADIENTS:
{
- int num_colors;
- ZnGradientColor *colors;
+ int num_grads;
+ ZnGradient **grads;
if (*((ZnList *) valp)) {
- colors = ZnListArray(*((ZnList *) valp));
- num_colors = ZnListSize(*((ZnList *) valp));
+ grads = ZnListArray(*((ZnList *) valp));
+ num_grads = ZnListSize(*((ZnList *) valp));
- for (i = 0; i < num_colors; i++) {
- if (colors[i].alpha != 100) {
- sprintf(buffer, "%s:%d",
- ZnNameOfColor(colors[i].shades[0]),
- colors[i].alpha);
- o = NewStringObj(buffer);
- }
- else {
- o = NewStringObj(ZnNameOfColor(colors[i].shades[0]));
- }
+ for (i = 0; i < num_grads; i++) {
+ o = NewStringObj(ZnNameOfGradient(grads[i]));
Tcl_ListObjAppendElement(wi->interp, result, o);
}
}
}
break;
- case ZN_CONFIG_GRADIENT:
- if (*((ZnGradient **) valp)) {
- str = ZnNameOfGradient(*((ZnGradient **) valp));
- Tcl_SetStringObj(result, str, strlen(str));
- }
- break;
case ZN_CONFIG_BOOL:
Tcl_SetBooleanObj(result, ISSET(*((char *) valp), desc->bool_bit)?1:0);
break;
@@ -3853,9 +3824,9 @@ InitFields(FieldSet field_set)
field = &field_set->fields[i];
field->field_set = field_set;
- field->color = ZnGetColorByValue(wi->win, wi->fore_color);
+ field->color = ZnGetGradientByValue(wi->fore_gradient);
field->fill_color = ZnGetGradient(wi->interp, wi->win, ZnNameOfColor(wi->back_color));
- field->border_color = ZnGetColorByValue(wi->win, wi->fore_color);
+ field->border_color = ZnGetGradientByValue(wi->fore_gradient);
SET(field->flags, FIELD_VISIBLE_BIT);
SET(field->flags, FIELD_SENSITIVE_BIT);
CLEAR(field->flags, FILLED_BIT);
@@ -3938,9 +3909,9 @@ CloneFields(FieldSet field_set)
Tk_NameOfBitmap(wi->dpy, field->fill_pattern));
}
field->font = Tk_GetFont(wi->interp, wi->win, Tk_NameOfFont(field->font));
- field->color = ZnGetColorByValue(wi->win, field->color);
+ field->color = ZnGetGradientByValue(field->color);
field->fill_color = ZnGetGradientByValue(field->fill_color);
- field->border_color = ZnGetColorByValue(wi->win, field->border_color);
+ field->border_color = ZnGetGradientByValue(field->border_color);
if (strlen(field->text) != 0) {
text = (char *) ZnMalloc((strlen(field->text) + 1) * sizeof(char));
@@ -3994,8 +3965,7 @@ ConfigureField(FieldSet field_set,
}
if ((field_ptr->relief != RELIEF_FLAT) && !field_ptr->gradient) {
field_ptr->gradient = ZnGetReliefGradient(wi->interp, wi->win,
- ZnNameOfColor(ZnGetGradientColor(wi->win,
- field_ptr->fill_color,
+ ZnNameOfColor(ZnGetGradientColor(field_ptr->fill_color,
50.0, NULL)));
if (field_ptr->gradient == NULL) {
return ZN_ERROR;
@@ -4142,9 +4112,9 @@ FreeFields(FieldSet field_set)
}
/*printf("freeing a font\n");*/
Tk_FreeFont(field->font);
- ZnFreeColor(field->color);
+ ZnFreeGradient(field->color);
ZnFreeGradient(field->fill_color);
- ZnFreeColor(field->border_color);
+ ZnFreeGradient(field->border_color);
}
if (num_fields) {
ZnFree(field_set->fields);
@@ -4333,7 +4303,7 @@ DrawField(WidgetInfo *wi,
* Draw the background.
*/
if (ISSET(field_ptr->flags, FILLED_BIT)) {
- values.foreground = ZnPixel(ZnGetGradientColor(wi->win, field_ptr->fill_color, 0.0, NULL));
+ values.foreground = ZnPixel(ZnGetGradientColor(field_ptr->fill_color, 0.0, NULL));
if (field_ptr->tile != ZnUnspecifiedImage) { /* Fill tiled */
Pixmap pmap = GetImagePixmap(wi->win, field_ptr->tile_name,
@@ -4388,7 +4358,7 @@ DrawField(WidgetInfo *wi,
* Draw the text.
*/
if (field_ptr->text && strlen(field_ptr->text)) {
- values.foreground = ZnPixel(field_ptr->color);
+ values.foreground = ZnPixel(ZnGetGradientColor(field_ptr->color, 0, NULL));
values.fill_style = FillSolid;
values.font = ZnFontId(field_ptr->font);
XChangeGC(wi->dpy, wi->gc, GCForeground | GCFillStyle | GCFont, &values);
@@ -4412,7 +4382,7 @@ DrawField(WidgetInfo *wi,
* Draw the border line.
*/
if (field_ptr->border_edges != NO_BORDER) {
- values.foreground = ZnPixel(field_ptr->border_color);
+ values.foreground = ZnPixel(ZnGetGradientColor(field_ptr->border_color, 0, NULL));
values.line_width = 0;
values.line_style = LineSolid;
values.fill_style = FillSolid;
@@ -4489,18 +4459,18 @@ RenderField(WidgetInfo *wi,
#ifdef GLX
int j;
XColor *color;
- int alpha, alpha2;
+ int alpha;
- alpha2 = 100*wi->alpha*65535/100;
/*
* Draw the background.
*/
if (ISSET(field_ptr->flags, FILLED_BIT)) {
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
if (!ZnGradientFlat(field_ptr->fill_color)) {
+#if 0
int type = field_ptr->fill_color->type;
ZnBool fast = (type == ZN_AXIAL_GRADIENT) && !field_ptr->grad_geo;
-#if 0
+
RenderGradient(wi, field_ptr->fill_color,
fast ? NULL : FieldRenderCB,
bbox, fast ? (ZnPoint *) bbox : field_ptr->grad_geo);
@@ -4519,8 +4489,8 @@ RenderField(WidgetInfo *wi,
glEnable(GL_POLYGON_STIPPLE);
glPolygonStipple(GetBitmapMask(wi->dpy, field_ptr->fill_pattern)->pixels);
}
- color = ZnGetGradientColor(wi->win, field_ptr->fill_color, 0.0, &alpha);
- alpha = alpha*wi->alpha/100*65535/100;
+ color = ZnGetGradientColor(field_ptr->fill_color, 0.0, &alpha);
+ alpha = ZnComposeAlpha(alpha, wi->alpha);
glColor4us(color->red, color->green, color->blue, alpha);
FieldRenderCB(clip_bbox);
glDisable(GL_POLYGON_STIPPLE);
@@ -4540,7 +4510,7 @@ RenderField(WidgetInfo *wi,
*/
if (field_ptr->image != ZnUnspecifiedImage) {
RenderImage(wi, GetImageTexture(wi->win, field_ptr->image_name, field_ptr->image),
- NULL, 100, &(pm_bbox->orig));
+ field_ptr->fill_color, &(pm_bbox->orig), False);
}
}
else {
@@ -4555,8 +4525,9 @@ RenderField(WidgetInfo *wi,
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- color = field_ptr->color;
- glColor4us(color->red, color->green, color->blue, alpha2);
+ color = ZnGetGradientColor(field_ptr->color, 0, &alpha);
+ alpha = ZnComposeAlpha(alpha, wi->alpha);
+ glColor4us(color->red, color->green, color->blue, alpha);
glBindTexture(GL_TEXTURE_2D, field_ptr->txf->texobj);
glPushMatrix();
glTranslatef(text_pos->x, text_pos->y, 0.0);
@@ -4591,8 +4562,8 @@ RenderField(WidgetInfo *wi,
* Draw the border line.
*/
if (field_ptr->border_edges != NO_BORDER) {
- color = field_ptr->border_color;
- glColor4us(color->red, color->green, color->blue, alpha2);
+ color = ZnGetGradientColor(field_ptr->border_color, 0, &alpha);
+ glColor4us(color->red, color->green, color->blue, alpha);
glLineWidth(1);
SetLineStyle(wi, LINE_SIMPLE);
glBegin(GL_LINES);
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);
}
}
}
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);
}
}
}
diff --git a/generic/Reticle.c b/generic/Reticle.c
index 1224e05..469bf9b 100644
--- a/generic/Reticle.c
+++ b/generic/Reticle.c
@@ -52,25 +52,25 @@ typedef struct _ReticleItemStruct {
ItemStruct header;
/* Public data */
- ZnPoint pos; /* Origin world coordinates */
- ZnColor line_color; /* circle color */
- ZnColor bright_line_color; /* intermediate circle color */
- ZnDim first_radius; /* first world radius */
- ZnDim step_size; /* step world size */
- int period; /* bright circle period */
- int num_circles; /* num cercles max */
- LineStyle line_style; /* circles lines styles */
- LineStyle bright_line_style;
+ ZnPoint pos; /* Origin world coordinates */
+ ZnGradient *line_color; /* circle color */
+ ZnGradient *bright_line_color; /* intermediate circle color */
+ ZnDim first_radius; /* first world radius */
+ ZnDim step_size; /* step world size */
+ int period; /* bright circle period */
+ int num_circles; /* num cercles max */
+ LineStyle line_style; /* circles lines styles */
+ LineStyle bright_line_style;
/* Private data */
- ZnPoint dev; /* item device coordinate */
- ZnDim first_radius_dev; /* first device radius */
- ZnDim step_size_dev; /* steps device size */
+ ZnPoint dev; /* item device coordinate */
+ ZnDim first_radius_dev; /* first device radius */
+ ZnDim step_size_dev; /* steps device size */
} ReticleItemStruct, *ReticleItem;
static ZnAttrConfig reticle_attrs[] = {
- { ZN_CONFIG_COLOR, "-brightlinecolor", NULL,
+ { ZN_CONFIG_GRADIENT, "-brightlinecolor", NULL,
Tk_Offset(ReticleItemStruct, bright_line_color), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_LINE_STYLE, "-brightlinestyle", NULL,
Tk_Offset(ReticleItemStruct, bright_line_style), 0, ZN_DRAW_FLAG, False },
@@ -86,7 +86,7 @@ static ZnAttrConfig reticle_attrs[] = {
{ ZN_CONFIG_DIM, "-firstradius", NULL,
Tk_Offset(ReticleItemStruct, first_radius), 0,
ZN_COORDS_FLAG, False },
- { ZN_CONFIG_COLOR, "-linecolor", NULL,
+ { ZN_CONFIG_GRADIENT, "-linecolor", NULL,
Tk_Offset(ReticleItemStruct, line_color), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_LINE_STYLE, "-linestyle", NULL,
Tk_Offset(ReticleItemStruct, line_style), 0, ZN_DRAW_FLAG, False },
@@ -135,8 +135,8 @@ Init(Item item,
SET(item->flags, COMPOSE_SCALE_BIT);
item->priority = DEFAULT_RETICLE_PRIORITY;
item->part_sensitive = 0;
- reticle->line_color = ZnGetColorByValue(wi->win, wi->fore_color);
- reticle->bright_line_color = ZnGetColorByValue(wi->win, wi->fore_color);
+ reticle->line_color = ZnGetGradientByValue(wi->fore_gradient);
+ reticle->bright_line_color = ZnGetGradientByValue(wi->fore_gradient);
reticle->first_radius = DEFAULT_RETICLE_STEP_SIZE;
reticle->step_size = DEFAULT_RETICLE_STEP_SIZE;
reticle->period = DEFAULT_RETICLE_PERIOD;
@@ -167,9 +167,8 @@ Clone(Item item)
WidgetInfo *wi = item->wi;
ReticleItem reticle = (ReticleItem) item;
- reticle->line_color = ZnGetColorByValue(wi->win, reticle->line_color);
- reticle->bright_line_color = ZnGetColorByValue(wi->win,
- reticle->bright_line_color);
+ reticle->line_color = ZnGetGradientByValue(reticle->line_color);
+ reticle->bright_line_color = ZnGetGradientByValue(reticle->bright_line_color);
}
@@ -185,8 +184,8 @@ Destroy(Item item)
{
ReticleItem reticle = (ReticleItem) item;
- ZnFreeColor(reticle->line_color);
- ZnFreeColor(reticle->bright_line_color);
+ ZnFreeGradient(reticle->line_color);
+ ZnFreeGradient(reticle->bright_line_color);
}
@@ -338,7 +337,7 @@ Draw(Item item)
while (radius <= radius_max_dev) {
SetLineStyle(wi, reticle->line_style);
- values.foreground = ZnPixel(reticle->line_color);
+ values.foreground = ZnPixel(ZnGetGradientColor(reticle->line_color, 0, NULL));
values.line_width = 0;
values.fill_style = FillSolid;
XChangeGC(wi->dpy, wi->gc, GCForeground | GCLineWidth | GCFillStyle, &values);
@@ -361,7 +360,7 @@ Draw(Item item)
(reticle->dev.y >= wi->damaged_area.orig.y - radius) &&
(reticle->dev.y <= wi->damaged_area.corner.y + radius)) {
SetLineStyle(wi, reticle->bright_line_style);
- values.foreground = ZnPixel(reticle->bright_line_color);
+ values.foreground = ZnPixel(ZnGetGradientColor(reticle->bright_line_color, 0, NULL));
values.line_width = 0;
values.fill_style = FillSolid;
XChangeGC(wi->dpy, wi->gc, GCForeground | GCLineWidth | GCFillStyle, &values);
@@ -394,7 +393,8 @@ Render(Item item)
unsigned int i, j;
ZnPoint *genarc;
int num_p, alpha;
-
+ XColor *color;
+
xo = reticle->dev.x;
yo = reticle->dev.y;
/* Compute radius max */
@@ -430,13 +430,13 @@ Render(Item item)
(reticle->num_circles - 1) * reticle->step_size_dev);
}
- alpha = 65535*wi->alpha/100;
genarc = GetCirclePoints(3, ZN_CIRCLE_FINEST, 0, 360, &num_p, NULL);
glLineWidth(1);
while (radius <= radius_max_dev) {
SetLineStyle(wi, reticle->line_style);
- glColor4us(reticle->line_color->red, reticle->line_color->green,
- reticle->line_color->blue, alpha);
+ color = ZnGetGradientColor(reticle->line_color, 0, &alpha);
+ alpha = ZnComposeAlpha(alpha, wi->alpha);
+ glColor4us(color->red, color->green, color->blue, alpha);
for (i = 1; (radius <= radius_max_dev && i < reticle->period); i++) {
if ((xo >= wi->damaged_area.orig.x - radius) &&
(xo <= wi->damaged_area.corner.x + radius) &&
@@ -458,8 +458,9 @@ Render(Item item)
(yo >= wi->damaged_area.orig.y - radius) &&
(yo <= wi->damaged_area.corner.y + radius)) {
SetLineStyle(wi, reticle->bright_line_style);
- glColor4us(reticle->bright_line_color->red, reticle->bright_line_color->green,
- reticle->bright_line_color->blue, alpha);
+ color = ZnGetGradientColor(reticle->bright_line_color, 0, &alpha);
+ alpha = ZnComposeAlpha(alpha, wi->alpha);
+ glColor4us(color->red, color->green, color->blue, alpha);
glBegin(GL_LINE_LOOP);
for (j = 0; j < num_p; j++) {
x = xo + genarc[j].x * radius;
diff --git a/generic/Text.c b/generic/Text.c
index f341de5..e506794 100644
--- a/generic/Text.c
+++ b/generic/Text.c
@@ -82,8 +82,7 @@ typedef struct _TextItemStruct {
ZnPoint pos;
ZnAnchor anchor;
ZnAnchor connection_anchor;
- ZnColor color;
- int alpha;
+ ZnGradient *color;
char *text;
Pixmap fill_pattern;
ZnFont font;
@@ -108,11 +107,9 @@ static ZnAttrConfig text_attrs[] = {
{ ZN_CONFIG_JUSTIFY, "-alignment", NULL,
Tk_Offset(TextItemStruct, alignment), 0,
ZN_COORDS_FLAG|ZN_LAYOUT_FLAG, False },
- { ZN_CONFIG_ALPHA, "-alpha", NULL,
- Tk_Offset(TextItemStruct, alpha), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_ANCHOR, "-anchor", NULL,
Tk_Offset(TextItemStruct, anchor), 0, ZN_COORDS_FLAG, False },
- { ZN_CONFIG_COLOR, "-color", NULL,
+ { ZN_CONFIG_GRADIENT, "-color", NULL,
Tk_Offset(TextItemStruct, color), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_BOOL, "-composerotation", NULL,
Tk_Offset(TextItemStruct, header.flags), COMPOSE_ROTATION_BIT,
@@ -191,8 +188,7 @@ Init(Item item,
text->fill_pattern = ZnUnspecifiedPattern;
text->anchor = ZnAnchorNW;
text->connection_anchor = ZnAnchorSW;
- text->color = ZnGetColorByValue(wi->win, wi->fore_color);
- text->alpha = 100;
+ text->color = ZnGetGradientByValue(wi->fore_gradient);
text->alignment = ZnJustifyLeft;
text->font = Tk_GetFont(wi->interp, wi->win, Tk_NameOfFont(wi->font));
text->width = 0;
@@ -231,7 +227,7 @@ Clone(Item item)
text->fill_pattern = Tk_GetBitmap(wi->interp, wi->win,
Tk_NameOfBitmap(wi->dpy, text->fill_pattern));
}
- text->color = ZnGetColorByValue(wi->win, text->color);
+ text->color = ZnGetGradientByValue(text->color);
text->font = Tk_GetFont(wi->interp, wi->win, Tk_NameOfFont(text->font));
if (text->text_info) {
@@ -267,7 +263,7 @@ Destroy(Item item)
Tk_FreeBitmap(wi->dpy, text->fill_pattern);
text->fill_pattern = ZnUnspecifiedPattern;
}
- ZnFreeColor(text->color);
+ ZnFreeGradient(text->color);
Tk_FreeFont(text->font);
if (text->text_info) {
@@ -708,7 +704,7 @@ Draw(Item item)
* Setup the gc to render the text and draw it.
*/
values.font = ZnFontId(text->font);
- values.foreground = ZnPixel(text->color);
+ values.foreground = ZnPixel(ZnGetGradientColor(text->color, 0, NULL));
gc_mask = GCFont | GCForeground;
if (text->fill_pattern != ZnUnspecifiedPattern) {
values.fill_style = FillStippled;
@@ -771,6 +767,8 @@ Render(Item item)
TextItem text = (TextItem) item;
TextLineInfo lines, lines_ptr;
int i, num_lines, num_chars;
+ XColor *color;
+ int alpha;
if (!text->text_info) {
return;
@@ -784,8 +782,9 @@ Render(Item item)
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- glColor4us(text->color->red, text->color->green,
- text->color->blue, text->alpha*wi->alpha/100*65535/100);
+ color = ZnGetGradientColor(text->color, 0, &alpha);
+ alpha = ZnComposeAlpha(alpha, wi->alpha);
+ glColor4us(color->red, color->green, color->blue, alpha);
glBindTexture(GL_TEXTURE_2D, text->txf->texobj);
lines = (TextLineInfo) ZnListArray(text->text_info);
diff --git a/generic/Track.c b/generic/Track.c
index 4053cf6..74339d0 100644
--- a/generic/Track.c
+++ b/generic/Track.c
@@ -80,43 +80,42 @@ typedef struct _TrackItemStruct {
ItemStruct header;
/* Public data */
- unsigned char flags;
- Pixmap symbol; /* item symbol */
- ZnColor symbol_color;
- int label_angle; /* Label angle from track. */
- ZnDim label_distance; /* Label distance from track. */
- ZnDim label_dx; /* Label dx/dy from track. */
- ZnDim label_dy;
- ZnAnchor label_anchor;
- LeaderAnchors leader_anchors; /* Spec of the leader attachment */
- ZnColor leader_color; /* leader color */
- LineStyle leader_style;
- LineShape leader_shape;
- ZnLineEnd leader_first_end;
- ZnLineEnd leader_last_end;
- ZnDim leader_width;
- ZnDim marker_size; /* world size of error circle */
- ZnColor marker_color; /* error circle color */
- LineStyle marker_style; /* error circle style */
- Pixmap marker_fill_pattern; /* error circle fill pattern */
- ZnColor connection_color; /* connection color */
- LineStyle connection_style;
- ZnDim connection_width;
- ZnColor speed_vector_color; /* s. v. color */
- int speed_vector_alpha;
- int visible_history_size; /* Number of visible positions */
- ZnPoint pos; /* item world coordinates */
- ZnPoint speed_vector; /* s. v. slope in world coord */
- ZnDim speed_vector_width;
- ZnColor history_color;
+ unsigned char flags;
+ Pixmap symbol; /* item symbol */
+ ZnGradient *symbol_color;
+ int label_angle; /* Label angle from track. */
+ ZnDim label_distance; /* Label distance from track. */
+ ZnDim label_dx; /* Label dx/dy from track. */
+ ZnDim label_dy;
+ ZnAnchor label_anchor;
+ LeaderAnchors leader_anchors; /* Spec of the leader attachment */
+ ZnGradient *leader_color; /* leader color */
+ LineStyle leader_style;
+ LineShape leader_shape;
+ ZnLineEnd leader_first_end;
+ ZnLineEnd leader_last_end;
+ ZnDim leader_width;
+ ZnDim marker_size; /* world size of error circle */
+ ZnGradient *marker_color; /* error circle color */
+ LineStyle marker_style; /* error circle style */
+ Pixmap marker_fill_pattern; /* error circle fill pattern */
+ ZnGradient *connection_color; /* connection color */
+ LineStyle connection_style;
+ ZnDim connection_width;
+ ZnGradient *speed_vector_color; /* s. v. color */
+ int visible_history_size; /* Number of visible positions */
+ ZnPoint pos; /* item world coordinates */
+ ZnPoint speed_vector; /* s. v. slope in world coord */
+ ZnDim speed_vector_width;
+ ZnGradient *history_color;
/* Private data */
- FieldSetStruct field_set;
- ZnPoint dev; /* device coords of current pos */
- ZnPoint speed_vector_dev; /* s. v. end in device coord */
- ZnDim marker_size_dev; /* dev size of error circle */
- ZnList history; /* pos list */
- ZnList leader_points;
+ FieldSetStruct field_set;
+ ZnPoint dev; /* device coords of current pos */
+ ZnPoint speed_vector_dev; /* s. v. end in device coord */
+ ZnDim marker_size_dev; /* dev size of error circle */
+ ZnList history; /* pos list */
+ ZnList leader_points;
} TrackItemStruct, *TrackItem;
@@ -132,7 +131,7 @@ static ZnAttrConfig track_attrs[] = {
{ ZN_CONFIG_ITEM, "-connecteditem", NULL,
Tk_Offset(TrackItemStruct, header.connected_item), 0,
ZN_COORDS_FLAG|ZN_ITEM_FLAG, False },
- { ZN_CONFIG_COLOR, "-connectioncolor", NULL,
+ { ZN_CONFIG_GRADIENT, "-connectioncolor", NULL,
Tk_Offset(TrackItemStruct, connection_color), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_BOOL, "-connectionsensitive", NULL,
Tk_Offset(TrackItemStruct, header.part_sensitive), PART_NUMBER_TO_BIT(CONNECTION),
@@ -147,7 +146,7 @@ static ZnAttrConfig track_attrs[] = {
Tk_Offset(TrackItemStruct, flags), MARKER_FILLED_BIT, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_BOOL, "-frozenlabel", NULL,
Tk_Offset(TrackItemStruct, flags), FROZEN_LABEL_BIT, ZN_COORDS_FLAG, False },
- { ZN_CONFIG_COLOR, "-historycolor", NULL,
+ { ZN_CONFIG_GRADIENT, "-historycolor", NULL,
Tk_Offset(TrackItemStruct, history_color), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_ANCHOR, "-labelanchor", NULL,
Tk_Offset(TrackItemStruct, label_anchor), 0, ZN_COORDS_FLAG, False },
@@ -170,7 +169,7 @@ static ZnAttrConfig track_attrs[] = {
Tk_Offset(TrackItemStruct, flags), LAST_AS_FIRST_BIT, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_LEADER_ANCHORS, "-leaderanchors", NULL,
Tk_Offset(TrackItemStruct, leader_anchors), 0, ZN_COORDS_FLAG, False },
- { ZN_CONFIG_COLOR, "-leadercolor", NULL,
+ { ZN_CONFIG_GRADIENT, "-leadercolor", NULL,
Tk_Offset(TrackItemStruct, leader_color), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_LINE_END, "-leaderfirstend", NULL,
Tk_Offset(TrackItemStruct, leader_first_end), 0, ZN_COORDS_FLAG, False },
@@ -185,7 +184,7 @@ static ZnAttrConfig track_attrs[] = {
Tk_Offset(TrackItemStruct, leader_shape), 0, ZN_COORDS_FLAG, False },
{ ZN_CONFIG_DIM, "-leaderwidth", NULL,
Tk_Offset(TrackItemStruct, leader_width), 0, ZN_COORDS_FLAG, False },
- { ZN_CONFIG_COLOR, "-markercolor", NULL,
+ { ZN_CONFIG_GRADIENT, "-markercolor", NULL,
Tk_Offset(TrackItemStruct, marker_color), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_PATTERN, "-markerfillpattern", NULL,
Tk_Offset(TrackItemStruct, marker_fill_pattern), 0, ZN_DRAW_FLAG, False },
@@ -206,9 +205,7 @@ static ZnAttrConfig track_attrs[] = {
Tk_Offset(TrackItemStruct, header.flags), SENSITIVE_BIT, ZN_REPICK_FLAG, False },
{ ZN_CONFIG_POINT, "-speedvector", NULL, Tk_Offset(TrackItemStruct, speed_vector), 0,
ZN_COORDS_FLAG, False },
- { ZN_CONFIG_COLOR, "-speedvectoralpha", NULL,
- Tk_Offset(TrackItemStruct, speed_vector_alpha), 0, ZN_DRAW_FLAG, False },
- { ZN_CONFIG_COLOR, "-speedvectorcolor", NULL,
+ { ZN_CONFIG_GRADIENT, "-speedvectorcolor", NULL,
Tk_Offset(TrackItemStruct, speed_vector_color), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_BOOL, "-speedvectormark", NULL,
Tk_Offset(TrackItemStruct, flags), SV_MARK_BIT, ZN_COORDS_FLAG, False },
@@ -221,7 +218,7 @@ static ZnAttrConfig track_attrs[] = {
Tk_Offset(TrackItemStruct, speed_vector_width), 0, ZN_COORDS_FLAG, False },
{ ZN_CONFIG_PATTERN, "-symbol", NULL,
Tk_Offset(TrackItemStruct, symbol), 0, ZN_COORDS_FLAG, False },
- { ZN_CONFIG_COLOR, "-symbolcolor", NULL,
+ { ZN_CONFIG_GRADIENT, "-symbolcolor", NULL,
Tk_Offset(TrackItemStruct, symbol_color), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_BOOL, "-symbolsensitive", NULL,
Tk_Offset(TrackItemStruct, header.part_sensitive), PART_NUMBER_TO_BIT(CURRENT_POSITION),
@@ -247,7 +244,7 @@ static ZnAttrConfig wp_attrs[] = {
{ ZN_CONFIG_ITEM, "-connecteditem", NULL,
Tk_Offset(TrackItemStruct, header.connected_item), 0,
ZN_COORDS_FLAG|ZN_ITEM_FLAG, False },
- { ZN_CONFIG_COLOR, "-connectioncolor", NULL,
+ { ZN_CONFIG_GRADIENT, "-connectioncolor", NULL,
Tk_Offset(TrackItemStruct, connection_color), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_BOOL, "-connectionsensitive", NULL,
Tk_Offset(TrackItemStruct, header.part_sensitive), PART_NUMBER_TO_BIT(CONNECTION),
@@ -277,7 +274,7 @@ static ZnAttrConfig wp_attrs[] = {
ZN_COORDS_FLAG|ZN_CLFC_FLAG, False },
{ ZN_CONFIG_LEADER_ANCHORS, "-leaderanchors", NULL,
Tk_Offset(TrackItemStruct, leader_anchors), 0, ZN_COORDS_FLAG, False },
- { ZN_CONFIG_COLOR, "-leadercolor", NULL,
+ { ZN_CONFIG_GRADIENT, "-leadercolor", NULL,
Tk_Offset(TrackItemStruct, leader_color), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_LINE_END, "-leaderfirstend", NULL,
Tk_Offset(TrackItemStruct, leader_first_end), 0, ZN_COORDS_FLAG, False },
@@ -292,7 +289,7 @@ static ZnAttrConfig wp_attrs[] = {
Tk_Offset(TrackItemStruct, leader_style), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_DIM, "-leaderwidth", NULL,
Tk_Offset(TrackItemStruct, leader_width), 0, ZN_COORDS_FLAG, False },
- { ZN_CONFIG_COLOR, "-markercolor", NULL,
+ { ZN_CONFIG_GRADIENT, "-markercolor", NULL,
Tk_Offset(TrackItemStruct, marker_color), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_PATTERN, "-markerfillpattern", NULL,
Tk_Offset(TrackItemStruct, marker_fill_pattern), 0, ZN_DRAW_FLAG, False },
@@ -311,7 +308,7 @@ static ZnAttrConfig wp_attrs[] = {
Tk_Offset(TrackItemStruct, header.flags), SENSITIVE_BIT, ZN_REPICK_FLAG, False },
{ ZN_CONFIG_PATTERN, "-symbol", NULL,
Tk_Offset(TrackItemStruct, symbol), 0, ZN_COORDS_FLAG, False },
- { ZN_CONFIG_COLOR, "-symbolcolor", NULL,
+ { ZN_CONFIG_GRADIENT, "-symbolcolor", NULL,
Tk_Offset(TrackItemStruct, symbol_color), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_BOOL, "-symbolsensitive", NULL,
Tk_Offset(TrackItemStruct, header.part_sensitive), PART_NUMBER_TO_BIT(CURRENT_POSITION),
@@ -353,7 +350,7 @@ Init(Item item,
SET(item->part_sensitive, PART_NUMBER_TO_BIT(LEADER));
SET(item->part_sensitive, PART_NUMBER_TO_BIT(CONNECTION));
SET(item->part_sensitive, PART_NUMBER_TO_BIT(SPEED_VECTOR));
- track->symbol_color = ZnGetColorByValue(wi->win, wi->fore_color);
+ track->symbol_color = ZnGetGradientByValue(wi->fore_gradient);
track->symbol = Tk_GetBitmap(wi->interp, wi->win, Tk_GetUid("AtcSymbol15"));
track->label_anchor = ZnAnchorCenter;
track->label_angle = DEFAULT_LABEL_ANGLE;
@@ -361,19 +358,18 @@ Init(Item item,
SET(track->flags, POLAR_BIT);
CLEAR(track->flags, FROZEN_LABEL_BIT);
track->leader_anchors = NULL;
- track->leader_color = ZnGetColorByValue(wi->win, wi->fore_color);
+ track->leader_color = ZnGetGradientByValue(wi->fore_gradient);
track->leader_style = LINE_SIMPLE;
track->leader_shape = LINE_STRAIGHT;
track->leader_width = DEFAULT_LINE_WIDTH;
- track->connection_color = ZnGetColorByValue(wi->win, wi->fore_color);
+ track->connection_color = ZnGetGradientByValue(wi->fore_gradient);
track->connection_style = LINE_SIMPLE;
track->connection_width = DEFAULT_LINE_WIDTH;
- track->marker_color = ZnGetColorByValue(wi->win, wi->fore_color);
+ track->marker_color = ZnGetGradientByValue(wi->fore_gradient);
track->marker_style = LINE_SIMPLE;
track->marker_fill_pattern = ZnUnspecifiedPattern;
- track->speed_vector_color = ZnGetColorByValue(wi->win, wi->fore_color);
- track->speed_vector_alpha = 100;
- track->history_color = ZnGetColorByValue(wi->win, wi->fore_color);
+ track->speed_vector_color = ZnGetGradientByValue(wi->fore_gradient);
+ track->history_color = ZnGetGradientByValue(wi->fore_gradient);
CLEAR(track->flags, MARKER_FILLED_BIT);
CLEAR(track->flags, SV_MARK_BIT);
SET(track->flags, FILLED_HISTORY_BIT);
@@ -467,12 +463,12 @@ Clone(Item item)
/*
* We get all shared resources, colors bitmaps.
*/
- track->symbol_color = ZnGetColorByValue(wi->win, track->symbol_color);
- track->leader_color = ZnGetColorByValue(wi->win, track->leader_color);
- track->connection_color = ZnGetColorByValue(wi->win, track->connection_color);
- track->marker_color = ZnGetColorByValue(wi->win, track->marker_color);
- track->speed_vector_color = ZnGetColorByValue(wi->win, track->speed_vector_color);
- track->history_color = ZnGetColorByValue(wi->win, track->history_color);
+ track->symbol_color = ZnGetGradientByValue(track->symbol_color);
+ track->leader_color = ZnGetGradientByValue(track->leader_color);
+ track->connection_color = ZnGetGradientByValue(track->connection_color);
+ track->marker_color = ZnGetGradientByValue(track->marker_color);
+ track->speed_vector_color = ZnGetGradientByValue(track->speed_vector_color);
+ track->history_color = ZnGetGradientByValue(track->history_color);
if (track->symbol != ZnUnspecifiedPattern) {
track->symbol = Tk_GetBitmap(wi->interp, wi->win,
Tk_NameOfBitmap(wi->dpy, track->symbol));
@@ -514,12 +510,12 @@ Destroy(Item item)
/*
* Release shared resources.
*/
- ZnFreeColor(track->symbol_color);
- ZnFreeColor(track->leader_color);
- ZnFreeColor(track->connection_color);
- ZnFreeColor(track->marker_color);
- ZnFreeColor(track->speed_vector_color);
- ZnFreeColor(track->history_color);
+ ZnFreeGradient(track->symbol_color);
+ ZnFreeGradient(track->leader_color);
+ ZnFreeGradient(track->connection_color);
+ ZnFreeGradient(track->marker_color);
+ ZnFreeGradient(track->speed_vector_color);
+ ZnFreeGradient(track->history_color);
if (track->symbol != ZnUnspecifiedPattern) {
Tk_FreeBitmap(wi->dpy, track->symbol);
}
@@ -1068,7 +1064,7 @@ Draw(Item item)
/* Draw the marker */
if (track->marker_size_dev != 0) {
SetLineStyle(wi, track->marker_style);
- values.foreground = ZnPixel(track->marker_color);
+ values.foreground = ZnPixel(ZnGetGradientColor(track->marker_color, 0, NULL));
values.line_width = 0;
if (ISSET(track->flags, MARKER_FILLED_BIT)) {
if (track->marker_fill_pattern == ZnUnspecifiedPattern) {
@@ -1109,7 +1105,8 @@ Draw(Item item)
pts[0] = track->dev;
pts[1] = ((TrackItem) item->connected_item)->dev;
- DrawLineShape(wi, pts, 2, track->connection_style, track->connection_color,
+ DrawLineShape(wi, pts, 2, track->connection_style,
+ ZnGetGradientColor(track->connection_color, 0, NULL),
track->connection_width, LINE_STRAIGHT);
}
@@ -1117,7 +1114,7 @@ Draw(Item item)
* Draw the speed vector.
*/
if ((item->class == ZnTrack) && (track->speed_vector_width > 0)) {
- values.foreground = ZnPixel(track->speed_vector_color);
+ values.foreground = ZnPixel(ZnGetGradientColor(track->speed_vector_color, 0, NULL));
values.line_width = track->speed_vector_width > 1 ? track->speed_vector_width : 0;
values.line_style = LineSolid;
values.fill_style = FillSolid;
@@ -1138,8 +1135,8 @@ Draw(Item item)
points = (ZnPoint *) ZnListArray(track->leader_points);
num_points = ZnListSize(track->leader_points);
- DrawLineShape(wi, points, num_points,
- track->leader_style, track->leader_color,
+ DrawLineShape(wi, points, num_points, track->leader_style,
+ ZnGetGradientColor(track->leader_color, 0, NULL),
track->leader_width, track->leader_shape);
if (track->leader_first_end != NULL) {
GetLineEnd(&points[0], &points[1], track->leader_width,
@@ -1172,7 +1169,7 @@ Draw(Item item)
* Draw the history, current pos excepted.
*/
if ((item->class == ZnTrack) && track->history) {
- values.foreground = ZnPixel(track->history_color);
+ values.foreground = ZnPixel(ZnGetGradientColor(track->history_color, 0, NULL));
values.fill_style = FillSolid;
XChangeGC(wi->dpy, wi->gc, GCForeground|GCFillStyle, &values);
if (ISCLEAR(track->flags, FILLED_HISTORY_BIT)) {
@@ -1186,7 +1183,7 @@ Draw(Item item)
for (i = 0, nb_hist = 0; i < num_acc_pos; i++) {
if (ISSET(track->flags, LAST_AS_FIRST_BIT) &&
(i == track->visible_history_size-1)) {
- values.foreground = ZnPixel(track->symbol_color);
+ values.foreground = ZnPixel(ZnGetGradientColor(track->symbol_color, 0, NULL));
XChangeGC(wi->dpy, wi->gc, GCForeground, &values);
}
side_size--;
@@ -1232,7 +1229,7 @@ Draw(Item item)
if (track->symbol != ZnUnspecifiedPattern) {
int x = track->dev.x - (width+1)/2;
int y = track->dev.y - (height+1)/2;
- values.foreground = ZnPixel(track->symbol_color);
+ values.foreground = ZnPixel(ZnGetGradientColor(track->symbol_color, 0, NULL));
values.fill_style = FillStippled;
values.stipple = track->symbol;
values.ts_x_origin = x;
@@ -1267,7 +1264,7 @@ Render(Item item)
char tmp_str[] = ".";
History hist;
int h_side_size, side_size, width=0, height=0;
- int i, j, nb_hist, num_acc_pos;
+ int i, j, nb_hist, num_acc_pos, alpha;
XColor *color;
ZnPoint *points;
int num_points;
@@ -1279,8 +1276,9 @@ Render(Item item)
x0 = track->dev.x;
y0 = track->dev.y;
size = track->marker_size_dev;
- color = track->connection_color;
- glColor4us(color->red, color->green, color->blue, 65535);
+ color = ZnGetGradientColor(track->marker_color, 0, &alpha);
+ alpha = ZnComposeAlpha(alpha, wi->alpha);
+ glColor4us(color->red, color->green, color->blue, alpha);
if (ISSET(track->flags, MARKER_FILLED_BIT)) {
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
if (track->marker_fill_pattern != ZnUnspecifiedPattern) { /* Fill stippled */
@@ -1313,8 +1311,9 @@ Render(Item item)
*/
c_item = (TrackItem) item->connected_item;
if ((c_item != ZN_NO_ITEM) && (track->connection_width > 0)) {
- color = track->connection_color;
- glColor4us(color->red, color->green, color->blue, 65535);
+ color = ZnGetGradientColor(track->connection_color, 0, &alpha);
+ alpha = ZnComposeAlpha(alpha, wi->alpha);
+ glColor4us(color->red, color->green, color->blue, alpha);
glLineWidth(track->connection_width);
glBegin(GL_LINES);
glVertex2f(track->dev.x, track->dev.y);
@@ -1330,9 +1329,9 @@ Render(Item item)
int num_clips, svlength, ticksize;
ZnReal svxstep, svystep;
- color = track->speed_vector_color;
- glColor4us(color->red, color->green, color->blue,
- track->speed_vector_alpha*wi->alpha/100*65535/100);
+ color = ZnGetGradientColor(track->speed_vector_color, 0, &alpha);
+ alpha = ZnComposeAlpha(alpha, wi->alpha);
+ glColor4us(color->red, color->green, color->blue, alpha);
glLineWidth(track->speed_vector_width);
/*
@@ -1394,12 +1393,11 @@ Render(Item item)
if (track->field_set.label_format && (track->leader_width > 0)) {
points = ZnListArray(track->leader_points);
num_points = ZnListSize(track->leader_points);
- color = track->leader_color;
RenderPolyline(wi,
points, num_points, track->leader_width, False,
track->leader_style, CapRound, JoinRound,
track->leader_first_end, track->leader_last_end,
- track->leader_color, 65535);
+ track->leader_color);
}
tmp_str[0] = track->symbol;
@@ -1412,8 +1410,9 @@ Render(Item item)
*/
if ((item->class == ZnTrack) && track->history) {
points = GetCirclePoints(3, ZN_CIRCLE_COARSE, 0, 360, &num_points, NULL);
- color = track->history_color;
- glColor4us(color->red, color->green, color->blue, 65535);
+ color = ZnGetGradientColor(track->history_color, 0, &alpha);
+ alpha = ZnComposeAlpha(alpha, wi->alpha);
+ glColor4us(color->red, color->green, color->blue, alpha);
glLineWidth(1);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
num_acc_pos = MIN(track->visible_history_size, ZnListSize(track->history));
@@ -1429,8 +1428,9 @@ Render(Item item)
for (i = 0, nb_hist = 0; i < num_acc_pos; i++) {
if (ISSET(track->flags, LAST_AS_FIRST_BIT) &&
(i == track->visible_history_size-1)) {
- color = track->symbol_color;
- glColor4us(color->red, color->green, color->blue, 65535);
+ color = ZnGetGradientColor(track->symbol_color, 0, &alpha);
+ alpha = ZnComposeAlpha(alpha, wi->alpha);
+ glColor4us(color->red, color->green, color->blue, alpha);
}
side_size--;
side_size = MAX(1, side_size);
@@ -1492,7 +1492,7 @@ Render(Item item)
}
/*
- * Draw the current position using a pattern for Tk.
+ * Draw the current position using a pattern.
*/
if (track->symbol != ZnUnspecifiedPattern) {
ZnPoint p;
@@ -1500,7 +1500,7 @@ Render(Item item)
p.x = track->dev.x - (width+1)/2;
p.y = track->dev.y - (height+1)/2;
RenderImage(wi, (ImageBits *) GetBitmapTexture(wi->dpy, track->symbol),
- track->symbol_color, 100, &p);
+ track->symbol_color, &p, True);
}
/*
diff --git a/generic/Triangles.c b/generic/Triangles.c
index 183146d..d8596b4 100644
--- a/generic/Triangles.c
+++ b/generic/Triangles.c
@@ -70,7 +70,7 @@ typedef struct _TrianglesItemStruct {
static ZnAttrConfig tr_attrs[] = {
- { ZN_CONFIG_COLORS, "-colors", NULL,
+ { ZN_CONFIG_GRADIENTS, "-colors", NULL,
Tk_Offset(TrianglesItemStruct, colors), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_BOOL, "-composerotation", NULL,
Tk_Offset(TrianglesItemStruct, header.flags), COMPOSE_ROTATION_BIT,
@@ -108,12 +108,12 @@ Init(Item item,
int *argc,
Tcl_Obj *CONST *args[])
{
- WidgetInfo *wi = item->wi;
- TrianglesItem tr = (TrianglesItem) item;
- Tcl_Obj **elems;
- int i, num_elems;
- ZnPoint p;
- ZnGradientColor *colors;
+ WidgetInfo *wi = item->wi;
+ TrianglesItem tr = (TrianglesItem) item;
+ Tcl_Obj **elems;
+ int i, num_elems;
+ ZnPoint p;
+ ZnGradient **grads;
tr->dev_points.num_strips = 0;
@@ -152,11 +152,10 @@ Init(Item item,
(*argc)--;
CLEAR(tr->flags, FAN_BIT);
- tr->colors = ZnListNew(1, sizeof(ZnGradientColor));
+ tr->colors = ZnListNew(1, sizeof(ZnGradient *));
ZnListAssertSize(tr->colors, 1);
- colors = ZnListArray(tr->colors);
- colors->alpha = 100;
- colors->shades[0] = ZnGetColorByValue(wi->win, wi->fore_color);
+ grads = ZnListArray(tr->colors);
+ *grads = ZnGetGradientByValue(wi->fore_gradient);
return ZN_OK;
}
@@ -172,18 +171,17 @@ Init(Item item,
static void
Clone(Item item)
{
- WidgetInfo *wi = item->wi;
TrianglesItem tr = (TrianglesItem) item;
if (tr->colors) {
- int i, num_colors;
- ZnGradientColor *colors;
+ int i, num_grads;
+ ZnGradient **grads;
tr->colors = ZnListDuplicate(tr->colors);
- num_colors = ZnListSize(tr->colors);
- colors = ZnListArray(tr->colors);
- for (i = 0; i < num_colors; i++, colors++) {
- colors->shades[0] = ZnGetColorByValue(wi->win, colors->shades[0]);
+ num_grads = ZnListSize(tr->colors);
+ grads = ZnListArray(tr->colors);
+ for (i = 0; i < num_grads; i++, grads++) {
+ *grads = ZnGetGradientByValue(*grads);
}
}
@@ -214,13 +212,13 @@ Destroy(Item item)
ZnFree(tr->dev_points.strips->points);
}
if (tr->colors) {
- int i, num_colors;
- ZnGradientColor *colors;
+ int i, num_grads;
+ ZnGradient **grads;
- num_colors = ZnListSize(tr->colors);
- colors = ZnListArray(tr->colors);
- for (i = 0; i < num_colors; i++, colors++) {
- ZnFreeColor(colors->shades[0]);
+ num_grads = ZnListSize(tr->colors);
+ grads = ZnListArray(tr->colors);
+ for (i = 0; i < num_grads; i++, grads++) {
+ ZnFreeGradient(*grads);
}
ZnListFree(tr->colors);
}
@@ -405,11 +403,11 @@ ToArea(Item item,
static void
Draw(Item item)
{
- WidgetInfo *wi = item->wi;
- TrianglesItem tr = (TrianglesItem) item;
- int i, num_points, last_color_index;
- ZnPoint *points;
- ZnGradientColor *colors;
+ WidgetInfo *wi = item->wi;
+ TrianglesItem tr = (TrianglesItem) item;
+ int i, num_points, last_color_index;
+ ZnPoint *points;
+ ZnGradient **grads;
if (tr->dev_points.num_strips == 0) {
return;
@@ -418,7 +416,7 @@ Draw(Item item)
points = tr->dev_points.strips->points;
num_points = tr->dev_points.strips->num_points;
- colors = ZnListArray(tr->colors);
+ grads = ZnListArray(tr->colors);
last_color_index = ZnListSize(tr->colors)-1;
XSetFillStyle(wi->dpy, wi->gc, FillSolid);
@@ -432,7 +430,8 @@ Draw(Item item)
}
for (i = 0; i < num_points-2; i++, xpoints++) {
if (i <= last_color_index) {
- XSetForeground(wi->dpy, wi->gc, ZnPixel(colors[i].shades[0]));
+ XSetForeground(wi->dpy, wi->gc,
+ ZnPixel(ZnGetGradientColor(grads[i], 0, NULL)));
}
XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc,
xpoints, 3, Convex, CoordModeOrigin);
@@ -450,7 +449,8 @@ Draw(Item item)
points += 3;
for (i = 0; i < num_points-2; i++, points++) {
if (i <= last_color_index) {
- XSetForeground(wi->dpy, wi->gc, ZnPixel(colors[i].shades[0]));
+ XSetForeground(wi->dpy, wi->gc,
+ ZnPixel(ZnGetGradientColor(grads[i], 0.0, NULL)));
}
XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc,
tri, 3, Convex, CoordModeOrigin);
@@ -472,13 +472,14 @@ Draw(Item item)
static void
Render(Item item)
{
- WidgetInfo *wi = item->wi;
- TrianglesItem tr = (TrianglesItem) item;
- int i, num_points, last_color_index;
- ZnPoint *points;
- ZnGradientColor *colors;
- int alpha;
-
+ WidgetInfo *wi = item->wi;
+ TrianglesItem tr = (TrianglesItem) item;
+ int i, num_points, last_color_index;
+ ZnPoint *points;
+ ZnGradient **grads;
+ int alpha;
+ XColor *color;
+
if (tr->dev_points.num_strips == 0) {
return;
}
@@ -486,7 +487,7 @@ Render(Item item)
points = tr->dev_points.strips->points;
num_points = tr->dev_points.strips->num_points;
- colors = ZnListArray(tr->colors);
+ grads = ZnListArray(tr->colors);
last_color_index = ZnListSize(tr->colors)-1;
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
@@ -499,8 +500,9 @@ Render(Item item)
for (i = 0; i < num_points; i++, points++) {
if (i <= last_color_index) {
- alpha = (colors[i].alpha*wi->alpha/100)*65535/100;
- glColor4us(colors[i].shades[0]->red, colors[i].shades[0]->green, colors[i].shades[0]->blue, alpha);
+ color = ZnGetGradientColor(grads[i], 0.0, &alpha);
+ alpha = ZnComposeAlpha(alpha, wi->alpha);
+ glColor4us(color->red, color->green, color->blue, alpha);
}
glVertex2f(points->x, points->y);
}
diff --git a/generic/Types.h b/generic/Types.h
index 0878351..130cd95 100644
--- a/generic/Types.h
+++ b/generic/Types.h
@@ -151,36 +151,36 @@ typedef struct {
*/
#define ZN_CONFIG_END 0
#define ZN_CONFIG_COLOR 1
-#define ZN_CONFIG_COLORS 2
-#define ZN_CONFIG_BOOL 3
-#define ZN_CONFIG_PATTERN 4
-#define ZN_CONFIG_PATTERNS 5
-#define ZN_CONFIG_TEXT 6
-#define ZN_CONFIG_FONT 7
-#define ZN_CONFIG_BORDER 8
-#define ZN_CONFIG_RELIEF 9
-#define ZN_CONFIG_DIM 10
-#define ZN_CONFIG_PRI 11
-#define ZN_CONFIG_JUSTIFY 12
-#define ZN_CONFIG_AUTO_JUSTIFY 13
-#define ZN_CONFIG_LINE_END 14
-#define ZN_CONFIG_LABEL_FORMAT 15
-#define ZN_CONFIG_LINE_STYLE 16
-#define ZN_CONFIG_LINE_SHAPE 17
-#define ZN_CONFIG_ITEM 18
-#define ZN_CONFIG_ANGLE 19
-#define ZN_CONFIG_INT 20
-#define ZN_CONFIG_UINT 21
-#define ZN_CONFIG_POINT 22
-#define ZN_CONFIG_RECT 23
-#define ZN_CONFIG_ANCHOR 24
-#define ZN_CONFIG_TAGS 25
-#define ZN_CONFIG_MAP_INFO 26
-#define ZN_CONFIG_IMAGE 27
-#define ZN_CONFIG_LEADER_ANCHORS 28
-#define ZN_CONFIG_JOIN_STYLE 29
-#define ZN_CONFIG_CAP_STYLE 30
-#define ZN_CONFIG_GRADIENT 31
+#define ZN_CONFIG_BOOL 2
+#define ZN_CONFIG_PATTERN 3
+#define ZN_CONFIG_PATTERNS 4
+#define ZN_CONFIG_TEXT 5
+#define ZN_CONFIG_FONT 6
+#define ZN_CONFIG_BORDER 7
+#define ZN_CONFIG_RELIEF 8
+#define ZN_CONFIG_DIM 9
+#define ZN_CONFIG_PRI 10
+#define ZN_CONFIG_JUSTIFY 11
+#define ZN_CONFIG_AUTO_JUSTIFY 12
+#define ZN_CONFIG_LINE_END 13
+#define ZN_CONFIG_LABEL_FORMAT 14
+#define ZN_CONFIG_LINE_STYLE 15
+#define ZN_CONFIG_LINE_SHAPE 16
+#define ZN_CONFIG_ITEM 17
+#define ZN_CONFIG_ANGLE 18
+#define ZN_CONFIG_INT 19
+#define ZN_CONFIG_UINT 20
+#define ZN_CONFIG_POINT 21
+#define ZN_CONFIG_RECT 22
+#define ZN_CONFIG_ANCHOR 23
+#define ZN_CONFIG_TAGS 24
+#define ZN_CONFIG_MAP_INFO 25
+#define ZN_CONFIG_IMAGE 26
+#define ZN_CONFIG_LEADER_ANCHORS 27
+#define ZN_CONFIG_JOIN_STYLE 28
+#define ZN_CONFIG_CAP_STYLE 29
+#define ZN_CONFIG_GRADIENT 30
+#define ZN_CONFIG_GRADIENTS 31
#define ZN_CONFIG_WINDOW 32
#define ZN_CONFIG_ALPHA 33
diff --git a/generic/WidgetInfo.h b/generic/WidgetInfo.h
index 819ed6e..3d4517a 100644
--- a/generic/WidgetInfo.h
+++ b/generic/WidgetInfo.h
@@ -41,7 +41,7 @@
#include "Transfo.h"
#include "Types.h"
#include "perfos.h"
-
+#include "Color.h"
#ifndef NUM_ALPHA_STEPS
#define NUM_ALPHA_STEPS 16
@@ -154,6 +154,7 @@ typedef struct _WidgetInfo {
/* Others */
ZnColor fore_color; /* Default foreground used in new items */
+ ZnGradient *fore_gradient; /* Default gradient used in new items */
ZnColor back_color; /* Color of the widget background. */
ZnColor bbox_color; /* Color used to draw bboxes (debug). */
Cursor cursor; /* Cursor displayed in zinc window. */
diff --git a/generic/tkZinc.c b/generic/tkZinc.c
index b754a7b..f4c1394 100644
--- a/generic/tkZinc.c
+++ b/generic/tkZinc.c
@@ -428,6 +428,7 @@ ZincObjCmd(ClientData client_data, /* Main window associated with
wi->realized = False;
wi->update_pending = 0;
wi->fore_color = NULL;
+ wi->fore_gradient = NULL;
wi->back_color = NULL;
wi->relief_grad = NULL;
wi->bbox_color = NULL;
@@ -4219,7 +4220,16 @@ Configure(Tcl_Interp *interp,/* Used for error reporting. */
if (wi->pick_aperture < 0) {
wi->pick_aperture = 0;
}
-
+ if (CONFIG_PROBE(FORE_COLOR_SPEC) || !wi->fore_gradient) {
+ /*
+ * Update the default gradient.
+ */
+ if (wi->fore_gradient) {
+ ZnFreeGradient(wi->fore_gradient);
+ }
+ wi->fore_gradient = ZnGetGradient(wi->interp, wi->win,
+ ZnNameOfColor(wi->fore_color));
+ }
if (CONFIG_PROBE(BACK_COLOR_SPEC) || !wi->relief_grad) {
Tk_SetWindowBackground(wi->win, ZnPixel(wi->back_color));
if (wi->relief_grad) {
@@ -5355,7 +5365,11 @@ Destroy(char *mem_ptr) /* Info about the widget. */
XFree(wi->gl_visual);
}
#endif
-
+
+ if (wi->fore_gradient) {
+ ZnFreeGradient(wi->fore_gradient);
+ }
+
Tcl_DeleteTimerHandler(wi->blink_handler);
Tk_FreeOptions(config_specs, (char *) wi, wi->dpy, 0);
diff --git a/sandbox/local.pl b/sandbox/local.pl
index 14a8914..5f96fc2 100644
--- a/sandbox/local.pl
+++ b/sandbox/local.pl
@@ -58,7 +58,7 @@ $rect2 = $zinc->add('rectangle', $view, [150, 50, 300, 300],
$rect = $zinc->add('rectangle', $view, [100, 100, 200, 200],
-visible => 1,
-linewidth => 4,
- -linealpha => 100,
+ -linecolor => 'black:100',
# -fillcolor => 'pink:50',
-fillcolor => 'tan',
-relief => 'sunken',
@@ -68,15 +68,14 @@ $rect = $zinc->add('rectangle', $view, [100, 100, 200, 200],
$mp = $zinc->add('curve', $view, [50, 150, 100, 250, 270, 170,
220, 100, 200, 100, 180, 0,
140, 140, 70, 0],
- -visible => 1,
+ -visible => 0,
-composescale => 1,
-composerotation => 1,
-linewidth => 4,
-relief => 'sunken',
-closed => 1,
-joinstyle => 'round',
- -linecolor => 'black',
- -linealpha => 50,
+ -linecolor => 'black:50',
-filled => 1,
-fillcolor => 'white|black[100 100',
# -fillcolor => 'white',
@@ -93,8 +92,7 @@ $mp2 = $zinc->add('curve', $view, [0, 320, 80, 470, 200, 470],
-joinstyle => 'round',
-capstyle => 'round',
-linestyle => 'mixed',
- -linecolor => 'red',
- -linealpha => 50,
+ -linecolor => 'red:50',
-filled => 0,
# -fillcolor => 'white|black(10 10',
-fillcolor => 'wheat',
@@ -110,9 +108,8 @@ $mp3 = $zinc->add('curve', $view, [20, 280, 100, 430, 200, 430],
-firstend => [3, 12, 8],
-lastend => [12, 12, 8],
-capstyle => 'round',
- -linecolor => 'red',
- -filled => 1,
- -linealpha => 100);
+ -linecolor => 'red:100',
+ -filled => 1);
$zinc->add('reticle', $view,
-visible => 1,
@@ -134,21 +131,20 @@ for ($i = 0; $i < 100; $i++) {
-visible => 1,
-text => "BlaBla et tout et tout, bref...",
-position => [$x, $y], -anchor => 'nw',
- -color => 'red', -alpha => 30);
+ -color => 'red:30');
}
$peng = $zinc->add('icon', $view,
-visible => 1,
-image => $penguin, -position => [300, 300],
-anchor => 'center',
- -alpha => 50);
+ -color => 'black:50');
$fvwm = $zinc->add('icon', $top,
-visible => 1,
-mask => '@fvwm.xbm',
-position => [50, 20],
-anchor => 'center',
- -color => 'orange',
- -alpha => 100);
+ -color => 'orange:100');
#$zinc->gname('white 0 80|black[0 0', 'cone');
$zinc->gname('white:50 0 80|black 50|white 100(0 0', 'oeil');
@@ -173,7 +169,7 @@ $zinc->add('rectangle', $view, [100, 100, 200, 200],
-fillcolor => 'cyl',
-linewidth => 1,
-filled => 1,
- -visible => 1
+ -visible => 0
);
$zinc->translate($arc, 125, 300);