jonth/my.c
#include <X11/Xlib.h>
#include <math.h>

XID m,e,o[2],W[2],G[2],R[2][3][3];
Display *V,*d[2];
char **h,k=25,b[2500],H=50,D,s,x,y,i;

T() {
float l;
XSetWindowAttributes c;
h+=!!*h;
V=d[D]=XOpenDisplay(*h);
s=XDefaultScreen(V);
e=XCreateWindow(V,RootWindow(V,s),0,0,152,152,2,0,1,0,0,0);
XStoreName(V,e,"II"+D );
G[D]=XCreatePixmapFromBitmapData(V,e,b,H,H,BlackPixel(V,s),WhitePixel(V,s),DefaultDepth(V,s));
memset(b,x=0,H*H);
c.event_mask=4;
for(;x<H;x++) for(i=4;i--;) {
 z(x-i,x);
 z(H-x+i,x);
 z(H-x-i,x);
 z(x+i,x); };
W[D]=XCreatePixmapFromBitmapData(V,e,b,H,H,BlackPixel(V,s),WhitePixel(V,s),DefaultDepth(V,s));
memset(b,0,H*H);
for(x=0;x<H;x++) for(l=k;l>20&&l>x;l-=.5) {
 y=sqrt(l*l-x*x)+k;
 z(x+k,y);
 z(k-x,y);
 z(y,x+k);  
 z(y,k-x);
 y=H-y;
 z(x+k,y);
 z(k-x,y);
 z(y,k-x);
 z(y,k+x); };
o[D]=XCreatePixmapFromBitmapData(V,e,b,H,H,BlackPixel(V,s),WhitePixel(V,s),DefaultDepth(V,s));
memset(b,0,H*H);
for(x=0;x<H;x++) XMapRaised(V,e);
for(x=3;x--;) for(y=3;y--;) {
 R[D][x][y]=XCreateWindow(V,e,H*x,H*y,H,H,1,0,1,0,2048,&c);
 XMapRaised(V,R[D][x][y]);
 r(G); }; }

XEvent J;
M(){
XFlush(d[!D]);
XNextEvent(V,&J);
for(x=3;x--;) for(y=3;y--;)
 if(J.xany.window==R[D][x][y]&&!b[x+k*y]++) {
 t(D);
 D^=1;
 t(!D); };
M(); }

z(x,y){
b[x/8+y*7]|=1<<x%8; }

t(p){
r(p?W:o);
XClearWindow(V,m); }

main(i,f)
 char**f; {
h=f;
T();
++D;
T();
M(); }

r(XID *z) {
V=d[D];
m=R[D][x][y];
XSetWindowBackgroundPixmap(V,m,z[D]); }