mirror of
https://github.com/0intro/wmii
synced 2024-11-25 07:09:38 +03:00
Fix some RGBA color bugs.
This commit is contained in:
parent
683b3ed895
commit
262778dccc
@ -486,10 +486,6 @@ class Button(object):
|
|||||||
self._label = label
|
self._label = label
|
||||||
if colors is not None:
|
if colors is not None:
|
||||||
self._colors = colors
|
self._colors = colors
|
||||||
try:
|
|
||||||
unicode(self._label)
|
|
||||||
except:
|
|
||||||
print repr(self._label)
|
|
||||||
return ' '.join([Color(c).hex for c in self._colors or self.colors] + [unicode(self._label or '')])
|
return ' '.join([Color(c).hex for c in self._colors or self.colors] + [unicode(self._label or '')])
|
||||||
|
|
||||||
colors = property(
|
colors = property(
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
ulong
|
ulong
|
||||||
pixelvalue(Window *w, Color *c) {
|
pixelvalue(Window *w, Color *c) {
|
||||||
XColor xc;
|
XColor xc;
|
||||||
ulong pixel;
|
|
||||||
|
|
||||||
if(w->visual->class != TrueColor) {
|
if(w->visual->class != TrueColor) {
|
||||||
if(c->pixel != ~0UL)
|
if(c->pixel != ~0UL)
|
||||||
@ -17,13 +16,15 @@ pixelvalue(Window *w, Color *c) {
|
|||||||
XAllocColor(display, w->colormap, &xc);
|
XAllocColor(display, w->colormap, &xc);
|
||||||
return c->pixel = xc.pixel;
|
return c->pixel = xc.pixel;
|
||||||
}
|
}
|
||||||
pixel = ((ulong)(c->alpha&0xff00) << 16)
|
if(w->depth == 32 || c->alpha == 0)
|
||||||
| ((ulong)(c->red&0xff00) << 8)
|
return (((ulong)c->alpha & 0xff00) << 16)
|
||||||
| ((ulong)(c->green&0xff00) << 0)
|
| (((ulong)c->red & 0xff00) << 8)
|
||||||
| ((ulong)(c->blue&0xff00) >> 8);
|
| (((ulong)c->green & 0xff00) << 0)
|
||||||
if(w->depth < 32)
|
| (((ulong)c->blue & 0xff00) >> 8);
|
||||||
pixel |= 0xffUL << 24;
|
else
|
||||||
return pixel;
|
return ((ulong)c->red * 0xffff / c->alpha & 0xff00) << 8
|
||||||
|
| ((ulong)c->green * 0xffff / c->alpha & 0xff00) << 0
|
||||||
|
| ((ulong)c->blue * 0xffff / c->alpha & 0xff00) >> 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -22,10 +22,12 @@ static int
|
|||||||
Lfmt(Fmt *f) {
|
Lfmt(Fmt *f) {
|
||||||
Color c;
|
Color c;
|
||||||
|
|
||||||
|
#define fix(c, m) (ushort)((c.alpha ? ((ulong)c.m * 0xffff) / c.alpha : 0) >> 8)
|
||||||
c = va_arg(f->args, Color);
|
c = va_arg(f->args, Color);
|
||||||
return fmtprint(f, c.alpha < 0xff00 ? "rgba:%02uhx/%02uhx/%02uhx/%02uhx"
|
return fmtprint(f, c.alpha < 0xff00 ? "rgba:%02uhx/%02uhx/%02uhx/%02uhx"
|
||||||
: "#%02uhx%02uhx%02uhx",
|
: "#%02uhx%02uhx%02uhx",
|
||||||
c.red >> 8, c.green >> 8, c.blue >> 8, c.alpha >> 8);
|
fix(c, red), fix(c, green), fix(c, blue), c.alpha >> 8);
|
||||||
|
#undef fix
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
Reference in New Issue
Block a user