aboutsummaryrefslogtreecommitdiff
path: root/spectrogram.c
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2013-06-26 22:06:14 +0000
committerDimitri Sokolyuk <demon@dim13.org>2013-06-26 22:06:14 +0000
commit02646ed9486b3c1725723c21ffcffb060aab4fa5 (patch)
treed3df96e8c8f1a35653e615c345dd14d1e214170d /spectrogram.c
parent26df3acb8cb1cc95b7d5ba8c10530e9e48ba6fe7 (diff)
change shadow algorithm
Diffstat (limited to 'spectrogram.c')
-rw-r--r--spectrogram.c42
1 files changed, 18 insertions, 24 deletions
diff --git a/spectrogram.c b/spectrogram.c
index 1e09d47..280f0a3 100644
--- a/spectrogram.c
+++ b/spectrogram.c
@@ -34,12 +34,6 @@
#include "fft.h"
#include "hsv2rgb.h"
-#if defined(__linux__)
-#ifndef __dead
-#define __dead __attribute__((noreturn))
-#endif
-#endif
-
#define GAP 4
extern char *__progname;
int die = 0;
@@ -61,7 +55,6 @@ struct panel {
int mirror;
double *data;
- int *shadow;
int maxval;
unsigned long *palette;
@@ -159,10 +152,10 @@ draw_panel(Display *d, struct panel *p)
XFillRectangle(d, p->mask, p->mgc,
0, 0, p->s.width, p->s.height);
- /* clear shadow mask */
- XSetForeground(d, p->sgc, 0);
- XFillRectangle(d, p->smask, p->sgc,
- 0, 0, p->s.width, p->s.height);
+ /* blit shadow mask */
+ XCopyArea(d, p->smask, p->smask, p->sgc,
+ 0, 0, p->s.width, p->s.height - 1,
+ 0, 1);
for (i = 0; i < p->p.width; i++) {
/* limit maxval */
@@ -179,18 +172,14 @@ draw_panel(Display *d, struct panel *p)
XDrawLine(d, p->mask, p->mgc,
x, p->s.height - v,
x, p->s.height);
-
- /* draw schadow */
- if (p->shadow[i] < v)
- p->shadow[i] = v;
- else if (p->shadow[i] > 0) {
- XSetForeground(d, p->sgc, 1);
- XDrawLine(d, p->smask, p->sgc,
- x, p->s.height - p->shadow[i]--,
- x, p->s.height);
- }
}
+ /* copy mask to shadow mask */
+ XSetClipMask(d, p->sgc, p->mask);
+ XCopyArea(d, p->mask, p->smask, p->sgc,
+ 0, 0, p->s.width, p->s.height, 0, 0);
+ XSetClipMask(d, p->sgc, None);
+
/* apply mask */
XSetClipOrigin(d, p->pgc, p->s.x, p->s.y);
@@ -241,10 +230,9 @@ init_panel(Display *d, Window win, int w, int h, int mirror)
p->s.height = h * 0.25;
p->data = calloc(w, sizeof(double));
- p->shadow = calloc(w, sizeof(int));
p->maxval = p->s.height;
- if (!p->data || !p->shadow)
+ if (!p->data)
errx(1, "malloc failed");
p->pix = XCreatePixmap(d, win, w, h, planes);
@@ -270,9 +258,16 @@ init_panel(Display *d, Window win, int w, int h, int mirror)
/* clear all */
XSetForeground(d, p->pgc, p->palette[0]);
+ XSetBackground(d, p->pgc, p->palette[0]);
XFillRectangle(d, p->pix, p->pgc,
p->p.x, p->p.y, p->p.width, p->p.height);
+ /* clear shadow mask */
+ XSetForeground(d, p->sgc, 0);
+ XSetBackground(d, p->sgc, 0);
+ XFillRectangle(d, p->smask, p->sgc,
+ 0, 0, p->s.width, p->s.height);
+
free(bgpalette);
free(shpalette);
@@ -288,7 +283,6 @@ del_panel(Display *d, struct panel *p)
XFreeGC(d, p->pgc);
XFreeGC(d, p->mgc);
free(p->data);
- free(p->shadow);
free(p->palette);
free(p);
}