#include #include #include #include /* Test of X11 line drawing 12/17/2015 delaglio@nmrscience.com */ int main( int argc, char **argv ) { Display *dpy; Window w; GC gc; int screen; XSizeHints winInfo; unsigned int borderWidth; unsigned long fg, bg, ultmp, white, black; int i, ix, iy; dpy = XOpenDisplay( (char *)NULL ); screen = DefaultScreen( dpy ); white = WhitePixel( dpy, screen ); black = BlackPixel( dpy, screen ); winInfo.x = 32; winInfo.y = 32; winInfo.width = 800; winInfo.height = 800; winInfo.flags = PPosition | PSize; borderWidth = 1; bg = black; fg = white; w = XCreateSimpleWindow( dpy, DefaultRootWindow( dpy ), winInfo.x, winInfo.y, winInfo.width, winInfo.height, borderWidth, fg, bg ); (void) XSetStandardProperties( dpy, w, argv[0], argv[0], None, argv, argc, &winInfo ); gc = XCreateGC( dpy, w, (unsigned long)0, (XGCValues *)NULL ); (void) XSetBackground( dpy, gc, bg ); (void) XSetForeground( dpy, gc, fg ); (void) XMapRaised( dpy, w ); for( i = 0; i < 32; i++ ) { for( iy = 1; iy < winInfo.height; iy++ ) { for( ix = 1; ix < winInfo.width; ix++ ) { (void) XDrawLine( dpy, w, gc, 1, 1, ix, iy ); } } ultmp = fg; fg = bg; bg = ultmp; (void) XSetBackground( dpy, gc, bg ); (void) XSetForeground( dpy, gc, fg ); } (void) XFreeGC( dpy, gc ); (void) XDestroyWindow( dpy, w ); (void) XCloseDisplay( dpy ); exit( 0 ); }