aboutsummaryrefslogtreecommitdiff
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/Draw.c80
1 files changed, 64 insertions, 16 deletions
diff --git a/generic/Draw.c b/generic/Draw.c
index b8f315e..c77d59e 100644
--- a/generic/Draw.c
+++ b/generic/Draw.c
@@ -859,6 +859,7 @@ DrawRectangleGradient(struct _WidgetInfo *wi,
ZnColorGradient grad_color,
XRectangle *bbox)
{
+ static int s[] = { 0, 13, 11, 9, 7, 5, 3, 1 };
int steps = ZnColorGradientSpan(grad_color);
ZnReal d1, d2;
int angle = grad_geom->angle;
@@ -866,7 +867,7 @@ DrawRectangleGradient(struct _WidgetInfo *wi,
int *optr, *hptr;
short yorig, ycorner;
ZnBool dir;
-
+ XColor *col;
/*
* We can only hangle 0, 90, 180, 270.
@@ -893,12 +894,14 @@ DrawRectangleGradient(struct _WidgetInfo *wi,
d1 = grad_geom->d1*bbox->height/100.0;
d2 = bbox->height*(1.0-grad_geom->d2/100.0);
}
+ d1 = REAL_TO_INT(d1);
+ d2 = REAL_TO_INT(d2);
dir = True;
if ((angle == 180) || (angle == 270)) {
dir = False;
}
-#if 1
+#if 0
XSetFillStyle(wi->dpy, wi->gc, FillSolid);
c = ycorner;
for (i = 2, j = steps-1; i < steps; i += 2, j--) {
@@ -931,25 +934,70 @@ DrawRectangleGradient(struct _WidgetInfo *wi,
* Draw over with a 50% gray pattern to smooth the color
* waves.
*/
- XSetFillStyle(wi->dpy, wi->gc, FillStippled);
- XSetStipple(wi->dpy, wi->gc, wi->alpha_stipples[7]);
- c = REAL_TO_INT(ycorner - d2 / steps);
- for (i = 3, j = steps-2; i <= steps; i += 2, j--) {
- *optr = REAL_TO_INT(ycorner - (i * d2 / steps));
+#if 1
+ /*
+ * First draw the from the gradient end.
+ */
+ XSetTSOrigin(wi->dpy, wi->gc, bbox->x, bbox->y);
+ c = ycorner;
+ for (i = 0, j = steps-1; i < ((steps-1) * 4); i++) {
+ *optr = REAL_TO_INT(ycorner - ((i + 1) * d2 / (steps * 4)));
*hptr = c - *optr;
- XSetForeground(wi->dpy, wi->gc,
- ZnPixel(ZnColorGradientColor(wi->win, grad_color,
- dir?j:steps-1-j)));
+ XSetFillStyle(wi->dpy, wi->gc, FillSolid);
+ col = ZnColorGradientColor(wi->win, grad_color, dir?j:steps-1-j);
+ XSetForeground(wi->dpy, wi->gc, ZnPixel(col));
XFillRectangle(wi->dpy, wi->draw_buffer, wi->gc, x, y, w, h);
+ if (i % 8) {
+ XSetFillStyle(wi->dpy, wi->gc, FillStippled);
+ XSetStipple(wi->dpy, wi->gc, wi->alpha_stipples[s[i%8]]);
+ XSetForeground(wi->dpy, wi->gc,
+ ZnPixel(ZnColorGradientColor(wi->win, grad_color,
+ dir?j+1:steps-j)));
+ XFillRectangle(wi->dpy, wi->draw_buffer, wi->gc, x, y, w, h);
+ }
+ else {
+ /*printf("remplissage en %d %d %d (%d)\n",
+ col->red, col->green, col->blue, dir?j:steps-1-j);*/
+ j--;
+ }
c = *optr;
}
- *optr = REAL_TO_INT(yorig + d1 / steps);
- for (i = 3, j = 1; i <= steps; i += 2, j++) {
- c = REAL_TO_INT(yorig + (i * d1 / steps));
+ y_d2 = *optr;
+ /*
+ * Then draw from the gradient start.
+ */
+#if 1
+ *optr = yorig;
+ for (i = 0, j = 0; i < ((steps-1) * 4); i++) {
+ c = REAL_TO_INT(yorig + ((i + 1) * d1 / (steps * 4)));
*hptr = c - *optr;
- XSetForeground(wi->dpy, wi->gc,
- ZnPixel(ZnColorGradientColor(wi->win, grad_color, dir?j:steps-1-j)));
+ XSetFillStyle(wi->dpy, wi->gc, FillSolid);
+ col = ZnColorGradientColor(wi->win, grad_color, dir?j:steps-1-j);
+ XSetForeground(wi->dpy, wi->gc, ZnPixel(col));
XFillRectangle(wi->dpy, wi->draw_buffer, wi->gc, x, y, w, h);
+ if (i % 8) {
+ XSetFillStyle(wi->dpy, wi->gc, FillStippled);
+ XSetStipple(wi->dpy, wi->gc, wi->alpha_stipples[s[i%8]]);
+ XSetForeground(wi->dpy, wi->gc,
+ ZnPixel(ZnColorGradientColor(wi->win, grad_color,
+ dir?j-1:steps-2-j)));
+ XFillRectangle(wi->dpy, wi->draw_buffer, wi->gc, x, y, w, h);
+ }
+ else {
+ /*printf("remplissage en %d %d %d (%d)\n",
+ col->red, col->green, col->blue, dir?j:steps-1-j);*/
+ j++;
+ }
*optr = c;
- }
+ }
+#endif
+ /*
+ * Last draw the central part.
+ */
+ *hptr = y_d2 - *optr;
+ XSetFillStyle(wi->dpy, wi->gc, FillSolid);
+ XSetForeground(wi->dpy, wi->gc,
+ ZnPixel(ZnColorGradientMidColor(wi->win, grad_color)));
+ XFillRectangle(wi->dpy, wi->draw_buffer, wi->gc, x, y, w, h);
+#endif
}