
#include <X11/Xlib.h>
#include "../wraster.h"
#include <stdio.h>

Display *dpy;
Window win;
RContext *ctx;
RImage *img, *tile, *new, *mini;
Pixmap pix;

void main()
{
    RContextAttributes attr;
    RColor from={0x0,0x0,30}, to={0x40,0x40,0x80};
    int i;

    dpy = XOpenDisplay("");
    if (!dpy) {
	puts("cant open display");
	exit(1);
    }
    win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10, 100, 100,
			      0, 0, 0);
    XMapRaised(dpy, win);
    XFlush(dpy);    
    attr.flags = RC_RenderMode | RC_ColorsPerChannel;

    attr.render_mode = RM_DITHER;
    attr.colors_per_channel = 4;
    ctx = RCreateContext(dpy, DefaultScreen(dpy), &attr);
    for (i=0; i<100; i++) {
    new = RRenderGradient(100,20,&from,&to, WGRD_HORIZONTAL);

    RConvertImage(ctx, new, &pix);
    RDestroyImage(new);
    }
    XCopyArea(dpy, pix, win, ctx->copy_gc, 0, 0, new->width, new->height, 
	      0, 0);

    XFlush(dpy);

	getchar();
}
