// ................................................................... #include
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <X11/Xlib.h>

#include <corso.h>

main()
{
	int i,j;
	int screen_num;
	char *display_name;
	XColor color;
	XEvent ev;
	Display *display;
	Window root_window;
	Window win;
	Colormap colormap;
	GC gc;

	display_name=getenv("DISPLAY");
	display=XOpenDisplay(display_name);
	screen_num=DefaultScreen(display);
	root_window=RootWindow(display,screen_num);
	win=XCreateSimpleWindow(display,root_window,10,10,750,200,2,
													BlackPixel(display,screen_num),
													WhitePixel(display,screen_num));
	XMapWindow(display,win);
	XFlush(display);
	unsigned long valuemask = 0;
	XGCValues values;//                   initial values for the GC.
	values.line_width = 1;	//             line width for the GC.
	values.line_style = LineSolid;//      style for lines drawing and
	values.cap_style = CapButt;//         style of the line's edje and
	values.join_style = JoinBevel;//      joined lines.
	gc=XCreateGC(display,win,valuemask,&values);
	
	colormap=DefaultColormap(display,DefaultScreen(display));
	for (i=0;i<750;i++)
	{
		j=i%250;
		if (i<250)
		{
			color.red=65535;
			color.green=(j*65535)/250;
			color.blue=0;
		}
		else if (i<500)
		{
			color.red=65535-(65535*j)/250;
			color.green=65535;
			color.blue=(j*65535)/250;
		}
		else
		{
			color.red=0;
			color.green=65535-(65535*j)/250;
			color.blue=65535;
			if (j>125) color.red=(65535*(j-125)*2)/250;
		}
		XAllocColor(display,colormap,&color);
		XSetForeground(display,gc,color.pixel);
		XDrawLine(display,win,gc,i,0,i,200);
	}
	XSelectInput(display,win,KeyPressMask|ButtonPressMask);
	XSync(display,FALSE);
	for (;;)
	{
		XNextEvent(display,&ev);
		if (ev.type==KeyPress) break;
		else if (ev.type==ButtonPress) break;
	}
}

// ---------------------------------------------------------------------------






