]> icculus.org git repositories - dana/openbox.git/blob - render2/color.c
lots of API additions that I didn't forsee until putting it into use.
[dana/openbox.git] / render2 / color.c
1 #include "render.h"
2 #include "instance.h"
3 #include "debug.h"
4 #include <X11/Xlib.h>
5
6 int RrColorParse(struct RrInstance *inst, const char *colorname,
7                  struct RrColor *ret)
8 {
9     XColor xcol;
10
11     if (!XParseColor(RrDisplay(inst), RrColormap(inst), colorname, &xcol)) {
12         RrDebug("unable to parse color '%s'", colorname);
13         ret->r = 0.0;
14         ret->g = 0.0;
15         ret->b = 0.0;
16         ret->a = 0.0;
17         return 0;
18     }
19     ret->r = (xcol.red >> 8) / 255.0;
20     ret->g = (xcol.green >> 8) / 255.0;
21     ret->b = (xcol.blue >> 8) / 255.0;
22     ret->a = 0.0;
23     return 1;
24 }