aboutsummaryrefslogtreecommitdiff
path: root/generic/Curve.c
diff options
context:
space:
mode:
authorlecoanet2002-02-18 16:03:54 +0000
committerlecoanet2002-02-18 16:03:54 +0000
commit6b36f92065f054abd810d956169a87180677d4f7 (patch)
treed2d16c8be93c67d15670eccce326dba5276acda1 /generic/Curve.c
parent67dd05047282a179b5fac88564bb3494a69ecd23 (diff)
downloadtkzinc-6b36f92065f054abd810d956169a87180677d4f7.zip
tkzinc-6b36f92065f054abd810d956169a87180677d4f7.tar.gz
tkzinc-6b36f92065f054abd810d956169a87180677d4f7.tar.bz2
tkzinc-6b36f92065f054abd810d956169a87180677d4f7.tar.xz
Passage des couleurs en gradients pour uniformiser
Diffstat (limited to 'generic/Curve.c')
-rw-r--r--generic/Curve.c47
1 files changed, 21 insertions, 26 deletions
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);
}
}
}