diff options
author | rsc <devnull@localhost> | 2003-09-30 17:47:42 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2003-09-30 17:47:42 +0000 |
commit | 76193d7cb0457807b2f0b95f909ab5de19480cd7 (patch) | |
tree | 97e538c7e38181431e90289a0fe8b6b7ce1f8f3c /src/libdraw/x11-fill.c | |
parent | ed7c8e8d02c02bdbff1e88a6d8d1419f39af48ad (diff) | |
download | plan9port-76193d7cb0457807b2f0b95f909ab5de19480cd7.tar.gz plan9port-76193d7cb0457807b2f0b95f909ab5de19480cd7.tar.bz2 plan9port-76193d7cb0457807b2f0b95f909ab5de19480cd7.zip |
Initial revision
Diffstat (limited to 'src/libdraw/x11-fill.c')
-rw-r--r-- | src/libdraw/x11-fill.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/libdraw/x11-fill.c b/src/libdraw/x11-fill.c new file mode 100644 index 00000000..ff0b2e86 --- /dev/null +++ b/src/libdraw/x11-fill.c @@ -0,0 +1,57 @@ +#include "x11-inc.h" + +#include <u.h> +#include <libc.h> +#include <draw.h> +#include <memdraw.h> +#include "x11-memdraw.h" + +void +memfillcolor(Memimage *m, u32int val) +{ + _memfillcolor(m, val); + if(m->X == nil) + return; + if((val & 0xFF) == 0xFF) /* full alpha */ + xfillcolor(m, m->r, _rgbatoimg(m, val)); + else + xputxdata(m, m->r); +} + +void +xfillcolor(Memimage *m, Rectangle r, u32int v) +{ + Point p; + Xmem *xm; + XGC gc; + + xm = m->X; + assert(xm != nil); + + /* + * Set up fill context appropriately. + */ + if(m->chan == GREY1){ + gc = _x.gcfill0; + if(_x.gcfill0color != v){ + XSetForeground(_x.display, gc, v); + _x.gcfill0color = v; + } + }else{ + if(m->chan == CMAP8 && _x.usetable) + v = _x.tox11[v]; + gc = _x.gcfill; + if(_x.gcfillcolor != v){ + XSetForeground(_x.display, gc, v); + _x.gcfillcolor = v; + } + } + + /* + * XFillRectangle takes coordinates relative to image rectangle. + */ + p = subpt(r.min, m->r.min); + XFillRectangle(_x.display, xm->pixmap, gc, p.x, p.y, Dx(r), Dy(r)); +} + + |