[comp.sources.x] v02i009: a colorful kaleidoscopic display, Part01/01

mikew@wyse.wyse.com (Mike Wexler) (11/10/88)

Submitted-by: Nathan K. Meyers <nathanm%hpcvxnkm@sde.hp.com>
Posting-number: Volume 2, Issue 9
Archive-name: kaleid/part01


Kaleid produces a colorful kaleidoscope display in an X11 window -- it
was ported from an MS-DOS program written for the EGA/VGA display.

For connoisseurs of window managers, this program does two interesting
things: 1) it creates and maintains a window icon, and 2) it observes
window manager sizing hints for its window icon.


#---------------------------------- cut here ----------------------------------
# This is a shell archive.  Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by Nathan K. Meyers <nathanm@hpcvxnkm> on Wed Nov  9 11:21:07 1988
#
# This archive contains:
#	README		Makefile	AUTHOR		patchlevel.h	
#	kaleid.c	kalicon.h	kaleid.1	
#
# Error checking via wc(1) will be performed.

unset LANG

echo x - README
cat >README <<'@EOF'
Kaleid produces a colorful kaleidoscope display in an X11 window -- it
was ported from an MS-DOS program written for the EGA/VGA display.

For connoisseurs of window managers, this program does two interesting
things: 1) it creates and maintains a window icon, and 2) it observes
window manager sizing hints for its window icon.

The program has run successfully on HP-UX series 300 and 800, and on a
Sun.  It relies on some Berkeleyisms (setitimer() and sigvec()) that
do not translate well to sysV.

Nathan Meyers
Hewlett-Packard
nathanm@hp-pcd.hp.com
@EOF
set `wc -lwc <README`
if test $1$2$3 != 1488554
then
	echo ERROR: wc results of README are $* should be 14 88 554
fi

chmod 444 README

echo x - Makefile
cat >Makefile <<'@EOF'
CFLAGS=-O

kaleid:	kaleid.o
	cc kaleid.o $(CFLAGS) -o kaleid -lX11

kaleid.o:	kaleid.c kalicon.h
	cc -c $(CFLAGS) kaleid.c
@EOF
set `wc -lwc <Makefile`
if test $1$2$3 != 716123
then
	echo ERROR: wc results of Makefile are $* should be 7 16 123
fi

chmod 444 Makefile

echo x - AUTHOR
cat >AUTHOR <<'@EOF'
Original MS-DOS kaleidoscope freeware program by Judson D. McClendon of
Sun Valley Systems (Birmingham, AL).  Permission granted to author to
port to X11 and publish.

X11 kaleid program by Nathan Meyers of Hewlett-Packard (internet mail
address nathanm@hp-pcd.hp.com).  Permission granted to freely copy and
distribute on a non-profit basis.
@EOF
set `wc -lwc <AUTHOR`
if test $1$2$3 != 748343
then
	echo ERROR: wc results of AUTHOR are $* should be 7 48 343
fi

chmod 444 AUTHOR

echo x - patchlevel.h
cat >patchlevel.h <<'@EOF'
#define PATCHLEVEL 0
@EOF
set `wc -lwc <patchlevel.h`
if test $1$2$3 != 1321
then
	echo ERROR: wc results of patchlevel.h are $* should be 1 3 21
fi

chmod 444 patchlevel.h

echo x - kaleid.c
cat >kaleid.c <<'@EOF'
#include <stdio.h>
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <signal.h>
#include "kalicon.h"

/*
  KALEIDOSCOPE (X11 Version)

  Original EGA/VGA version (for IBM PCs and compatibles) by:
    Judson D. McClendon
    Sun Valley Systems
    329 37th Court N.E.
    Birmingham, AL 35215
    Compuserve: [74415,1003]

  Ported to X11 by Nathan Meyers, nathanm@hp-pcd.hp.com.
*/

char *progname;


/* Approximation of CGA/EGA/VGA colors -- (out of standard order) */
unsigned long colors[][3] = { { 0x0000, 0x0000, 0x0000 },    /* black */
			      { 0xffff, 0xffff, 0xffff },    /* bright white */
			      { 0x0000, 0x0000, 0xaaaa },    /* blue */
			      { 0x0000, 0xaaaa, 0x0000 },    /* green */
			      { 0x0000, 0xaaaa, 0xaaaa },    /* cyan */
			      { 0xaaaa, 0x0000, 0x0000 },    /* red */
			      { 0xaaaa, 0x0000, 0xaaaa },    /* magenta */
			      { 0xaaaa, 0x5555, 0x0000 },    /* brown */
			      { 0xaaaa, 0xaaaa, 0xaaaa },    /* white  */
			      { 0x5555, 0x5555, 0x5555 },    /* dark grey */
			      { 0x5555, 0x5555, 0xffff },    /* light blue */
			      { 0x5555, 0xffff, 0x5555 },    /* light green */
			      { 0x5555, 0xffff, 0xffff },    /* light cyan */
			      { 0xffff, 0x5555, 0x5555 },    /* light red */
			      { 0xffff, 0x5555, 0xffff },    /* light magenta */
			      { 0xffff, 0xffff, 0x5555 } };  /* yellow */

#define NCOLORS 16

static char *what = "@(#)kaleid.c $Revision: 1.43 $";

Display *display;
int screen;

void refreshrootquit()
{
  XClearWindow(display,RootWindow(display,screen));
  XSync(display,0);
  exit(0);
}

main(argc,argv)
int argc;
char *argv[];
{
  unsigned long bgcolor, bdcolor;
  int bwidth = 2;
  int i;
  XSizeHints size_hints;
  XIconSize icon_size_hints, *icon_size_list;
  int numsizes, currsize;
  XWMHints wm_hints;
  char *displayname = NULL, *background = NULL, *border = NULL;
  char *geomstring = NULL;
  unsigned long palette[NCOLORS];
  GC color_gcs[NCOLORS];
  XColor screen_in_out, visual_def_return, exact_def_return;
  Window mywindow, iconwindow=NULL;
  int o_argc = argc;
  char **o_argv = argv;
  XEvent event;
  int CX, CY, M;
  int w_CX, w_CY, w_M;
  int i_CX, i_CY, i_M;
  long time();
  int doroot = 0;
  int delayvalue = -1, icondelay=100;
  int iconic=0;
  int monochrome=0, numcolors=NCOLORS;

  progname = argv[0];

  while (--argc>0) {
    char *option = (*++argv);
    if (!strcmp(option,"-display")) {
      if (--argc==0) usage();
      displayname = (*++argv);
    }
    else if (strchr(option,':')) {
      displayname = option;
    }
    else if (!strcmp(option,"-bg")) {
      if (--argc==0) usage();
      background = (*++argv);
    }
    else if (!strcmp(option,"-bd")) {
      if (--argc==0) usage();
      border = (*++argv);
    }
    else if (!strcmp(option,"-bw")) {
      if (--argc==0) usage();
      bwidth = atoi(*++argv);
      if (bwidth<0) bwidth = 0;
    }
    else if (!strcmp(option,"-delay")) {
      if (--argc==0) usage();
      delayvalue = atoi(*++argv);
      if (delayvalue<0) delayvalue = 0;
    }
    else if (!strcmp(option,"-icondelay")) {
      if (--argc==0) usage();
      icondelay = atoi(*++argv);
      if (icondelay<0) icondelay = 0;
    }
    else if (!strcmp(option,"-iconic")) {
      iconic = 1;
    }
    else if (!strcmp(option,"-geometry")) {
      if (--argc==0) usage();
      geomstring = (*++argv);
    }
    else if (*option=='=') {
      geomstring = option;
    }
    else if (!strcmp(option,"-mono")) {
      monochrome=1;
    }
    else if (!strcmp(option,"-r")) {
      doroot = 1;
    }
    else usage();
  }

  if (delayvalue == -1) delayvalue = doroot ? 100 : 10;

  display = XOpenDisplay(displayname);
  if (display==NULL) {
    fprintf(stderr,
	    (displayname==NULL) ?
	    "%s: Failed to open display.\n" :
	    "%s: Failed to open display %s.\n",
	    progname,displayname);
    exit(1);
  }
  screen = DefaultScreen(display);

  if (background == NULL ||
      XAllocNamedColor(display,
		       DefaultColormap(display,screen),
		       background,
		       &visual_def_return,
		       &exact_def_return)==False)
    bgcolor = BlackPixel(display,screen);
  else bgcolor = exact_def_return.pixel;

  if (border==NULL ||
      XAllocNamedColor(display,
		       DefaultColormap(display,screen),
		       border,
		       &visual_def_return,
		       &exact_def_return)==False)
   bdcolor = WhitePixel(display,screen);
  else bdcolor = exact_def_return.pixel;

  if (!monochrome && DisplayCells(display,screen) > 2) {
    for (numcolors=0; numcolors<NCOLORS; numcolors++) {
      screen_in_out.flags = DoRed | DoGreen | DoBlue;
      screen_in_out.red = colors[numcolors][0];
      screen_in_out.green = colors[numcolors][1];
      screen_in_out.blue = colors[numcolors][2];
      if (XAllocColor(display, DefaultColormap(display,screen),
		      &screen_in_out)==False) {
	if (numcolors < 2) fatalerror("Cannot allocate colors",NULL);
	break;
      }
      palette[numcolors] = screen_in_out.pixel;
    }
  }
  else {
    numcolors=2;
    palette[0] = WhitePixel(display,screen);
    palette[1] = BlackPixel(display,screen);
  }

  size_hints.x = 0;
  size_hints.y = 0;
  size_hints.width = 300;
  size_hints.height = 300;

  size_hints.flags = PPosition | PSize;
  if (geomstring!=NULL) {
    int result;
    result = XParseGeometry(geomstring,&size_hints.x,&size_hints.y,
		            &size_hints.width,&size_hints.height);
    if (result & XNegative)
      size_hints.x += DisplayWidth(display,screen)
		    - size_hints.width
		    - bwidth*2;
    if (result & YNegative)
      size_hints.y += DisplayHeight(display,screen)
		    - size_hints.height
		    - bwidth*2;
    if (result & XValue || result & YValue) {
      size_hints.flags |= USPosition;
      size_hints.flags &= ~PPosition;
    }
    if (result & WidthValue || result & HeightValue) {
      size_hints.flags |= USSize;
      size_hints.flags &= ~PSize;
    }
  }

  if (doroot) {
    mywindow = RootWindow(display,screen);
  }
  else {
    Pixmap bitmapicon;
    mywindow = XCreateSimpleWindow(display,RootWindow(display,screen),
				 size_hints.x,size_hints.y,
				 size_hints.width,size_hints.height,
				 bwidth,bdcolor,bgcolor);

    icon_size_hints.max_width=64;
    icon_size_hints.max_height=64;
    currsize=0;
    if (XGetIconSizes(display,RootWindow(display,screen),
		      &icon_size_list,&numsizes)) {
      int i=1;
      while (i<numsizes) { /* Look for largest allowable icon size */
	if (icon_size_list[i].max_width >= icon_size_list[currsize].max_width &&
	    icon_size_list[i].max_height >= icon_size_list[currsize].max_height)
	  currsize=i;
      }
      if (icon_size_list[currsize].max_width <= 0 ||
	  icon_size_list[currsize].max_height <= 0 ) {
	XFree(icon_size_list);
        icon_size_list = &icon_size_hints;
      }
    }
    else
      icon_size_list = &icon_size_hints;

    iconwindow = XCreateSimpleWindow(display,RootWindow(display,screen),
				   0,0,
				   icon_size_list[currsize].max_width,
				   icon_size_list[currsize].max_height,
				   2,BlackPixel(display,screen),
				   WhitePixel(display,screen));

    i_CX = icon_size_list[currsize].max_width >> 1;
    i_CY = icon_size_list[currsize].max_height >> 1;
    i_M = (i_CX>i_CY) ? i_CX : i_CY;

    if (icon_size_list != &icon_size_hints) XFree(icon_size_list);

    XSetStandardProperties(display,mywindow,"Kaleidoscope","Kaleidoscope",
			   None,o_argv,o_argc,&size_hints);

    /* Create bitmap icon for wm's that don't support window icons */
    bitmapicon=XCreateBitmapFromData(display,RootWindow(display,screen),
				     icon_bits, icon_width, icon_height);

    /* Use window icon for window managers that support one */
    wm_hints.icon_pixmap = bitmapicon;
    wm_hints.icon_window = iconwindow;
    wm_hints.flags = IconPixmapHint | IconWindowHint;
    if (iconic) {
      wm_hints.initial_state = IconicState;
      wm_hints.flags |= StateHint;
    }
    XSetWMHints(display,mywindow,&wm_hints);

    XSelectInput(display,mywindow,ExposureMask|StructureNotifyMask);
    XSelectInput(display,iconwindow,ExposureMask|StructureNotifyMask);

    XMapWindow(display,mywindow);
  }

  for (i = 0; i<numcolors; i++) {
    XGCValues values;
    values.foreground = palette[i];
    color_gcs[i] = XCreateGC(display,mywindow,GCForeground,&values);
  }

  w_CX = size_hints.width/2;
  w_CY = size_hints.height/2;
  w_M = (w_CX>w_CY) ? w_CX : w_CY;

  srand48(time((long *)NULL));

  for (;;) {
    Window cwindow;
    if (doroot) {
      int dontcare;
      Window wdontcare;
      struct sigvec vec;
      cwindow = RootWindow(display,screen);
      XGetGeometry(display,cwindow,&wdontcare,&dontcare,&dontcare,
		   &CX, &CY, &dontcare, &dontcare);
      CX >>= 1;
      CY >>= 1;
      M = (CX>CY) ? CX : CY;
      M = M ? M : 1;
      vec.sv_handler = refreshrootquit;
      vec.sv_mask = 0x0;
      vec.sv_flags = 0;
      sigvec(SIGINT, &vec, NULL);
      sigvec(SIGQUIT, &vec, NULL);
      sigvec(SIGTERM, &vec, NULL);
    }
    else {
      XNextEvent(display,&event);
      if (event.type==ConfigureNotify) {
	if (event.xconfigure.window==mywindow) {
	  w_CX = event.xconfigure.width/2;
	  w_CY = event.xconfigure.height/2;
	  w_M = (w_CX>w_CY) ? w_CX : w_CY;
	}
	else {
	  i_CX = event.xconfigure.width/2;
	  i_CY = event.xconfigure.height/2;
	  i_M = (i_CX>i_CY) ? i_CX : i_CY;
	}
      }
      else if (event.type==MapNotify) {
	if ((cwindow = event.xmap.window)==mywindow) {
	  CX = w_CX;
	  CY = w_CY;
	  M = w_M;
	}
	else {
	  CX = i_CX;
	  CY = i_CY;
	  M = i_M;
	}
	CX = CX ? CX : 1;
	CY = CY ? CY : 1;
	M = M ? M : 1;
      }
      else if (event.type==Expose) {
	if ((cwindow = event.xexpose.window)==mywindow) {
	  CX = w_CX;
	  CY = w_CY;
	  M = w_M;
	}
	else {
	  CX = i_CX;
	  CY = i_CY;
	  M = i_M;
	}
	CX = CX ? CX : 1;
	CY = CY ? CY : 1;
	M = M ? M : 1;
      }
    }
    if (doroot || event.type==Expose || event.type==MapNotify) {
      int X1, Y1, X2, Y2, XV1, YV1, XV2, YV2, HC;
      int XA, YA, XB, YB, XC, YC, XD, YD;
      int mapped = 1;
      X1 = rndm(M) + 1;
      X2 = rndm(M) + 1;
      Y1 = rndm(X1);
      Y2 = rndm(X2);
      while (mapped) {
	while (rndm(100) > 1 && mapped) {
	  XV1 = rndm(7)-3;
	  XV2 = rndm(7)-3;
	  YV1 = rndm(7)-3;
	  YV2 = rndm(7)-3;
	  HC = rndm(numcolors);
	  while (rndm(20)>1 && mapped) {
	    if (CX<CY) {
	      XA = (long)X1*(long)CX/(long)CY;
	      YA = (long)Y1*(long)CX/(long)CY;
	      XB = X1;
	      YB = Y1;
	      XC = (long)X2*(long)CX/(long)CY;
	      YC = (long)Y2*(long)CX/(long)CY;
	      XD = X2;
	      YD = Y2;
	    }
	    else {
	      XA = X1;
	      YA = Y1;
	      XB = (long)X1*(long)CY/(long)CX;
	      YB = (long)Y1*(long)CY/(long)CX;
	      XC = X2;
	      YC = Y2;
	      XD = (long)X2*(long)CY/(long)CX;
	      YD = (long)Y2*(long)CY/(long)CX;
	    }
	    XDrawLine(display,cwindow,color_gcs[HC],CX+XA,CY-YB,CX+XC,CY-YD);
	    XDrawLine(display,cwindow,color_gcs[HC],CX-YA,CY+XB,CX-YC,CY+XD);
	    XDrawLine(display,cwindow,color_gcs[HC],CX-XA,CY-YB,CX-XC,CY-YD);
	    XDrawLine(display,cwindow,color_gcs[HC],CX-YA,CY-XB,CX-YC,CY-XD);
	    XDrawLine(display,cwindow,color_gcs[HC],CX-XA,CY+YB,CX-XC,CY+YD);
	    XDrawLine(display,cwindow,color_gcs[HC],CX+YA,CY-XB,CX+YC,CY-XD);
	    XDrawLine(display,cwindow,color_gcs[HC],CX+XA,CY+YB,CX+XC,CY+YD);
	    XDrawLine(display,cwindow,color_gcs[HC],CX+YA,CY+XB,CX+YC,CY+XD);
	    XFlush(display);
	    if (cwindow==iconwindow) {
	      if (icondelay>0) sleepms(icondelay);
	    }
	    else if (delayvalue>0) sleepms(delayvalue);
	    if (!doroot) {
	      if (XCheckMaskEvent(display,(long)ExposureMask,&event)==True &&
	          event.xexpose.window != cwindow) {
		XPutBackEvent(display,&event);
		mapped=0;
	      }
	      else if (XCheckMaskEvent(display,(long)StructureNotifyMask,
				  &event)==True) {
		if (event.type==UnmapNotify && event.xunmap.window==cwindow)
		  mapped = 0;
		else if (event.type==MapNotify && event.xmap.window!=cwindow) {
		  XPutBackEvent(display,&event);
		  mapped = 0;
		}
		else if (event.type==ConfigureNotify) {
		  if (event.xconfigure.window==mywindow) {
	  	    w_CX = event.xconfigure.width/2;
	  	    w_CY = event.xconfigure.height/2;
	  	    w_M = (w_CX>w_CY) ? w_CX : w_CY;
		    if (cwindow==mywindow) {
		      if (CX!=w_CX || CY!=w_CY) XClearWindow(display,cwindow);
		      CX = w_CX ? w_CX : 1;
		      CY = w_CY ? w_CY : 1;
		      M = w_M ? w_M : 1;
		    }
		  }
		  else {
	  	    i_CX = event.xconfigure.width/2;
	  	    i_CY = event.xconfigure.height/2;
	  	    i_M = (i_CX>i_CY) ? i_CX : i_CY;
		    if (cwindow==iconwindow) {
		      if (CX!=i_CX || CY!=i_CY) XClearWindow(display,cwindow);
		      CX = i_CX ? i_CX : 1;
		      CY = i_CY ? i_CY : 1;
		      M = i_M ? i_M : 1;
		    }
		  }
		}
	      }
	    }
	    X1= (X1 + XV1) % M;
	    Y1= (Y1 + YV1) % M;
	    X2= (X2 + XV2) % M;
	    Y2= (Y2 + YV2) % M;
	  }
	}
	XClearWindow(display,cwindow);
      }
    }
  }
}

usage()
{
  int i;
  fprintf(stderr,"Usage: %s [-display <displayname>] [-bg <background>]",
	  progname);
  fprintf(stderr," [-bd <border>]\n");
  for (i = 0; i<(strlen(progname)+8); i++) putc(' ',stderr);
  fprintf(stderr,"[-bw <borderwidth>] [-geometry <geometry>]");
  fprintf(stderr," [-delay <msec>]\n");
  for (i = 0; i<(strlen(progname)+8); i++) putc(' ',stderr);
  fprintf(stderr,"[-icondelay <msec>] [-iconic] [-mono] -r\n");
  exit(1);
}

fatalerror(s1,s2)
char *s1,*s2;
{
  fprintf(stderr,"%s: ",progname);
  fprintf(stderr,s1,s2);
  putc('\n',stderr);
  exit(1);
}

#include <sys/time.h>

rndm(maxval)
int maxval;
{
  long lrand48();
  return ((lrand48() >> 15) * maxval) >> 16;
}

void alarmhandler()
{
}

sleepms(msec)
int msec;
{
  struct itimerval value,ovalue;
  struct sigvec vec;
  long savemask, sigblock(), sigpause();

  vec.sv_handler = alarmhandler;
  vec.sv_mask = 0x0;
  vec.sv_flags = 0;
  sigvec(SIGALRM, &vec, &vec);		/* Set up alarmhandler for SIGALRM */
  savemask = sigblock((long)(1L << (SIGALRM - 1)));

  value.it_interval.tv_sec = 0;
  value.it_interval.tv_usec = 0;
  value.it_value.tv_sec = msec/1000;
  value.it_value.tv_usec = (msec%1000)*1000;
  setitimer(ITIMER_REAL,&value,&ovalue);

  (void)sigpause(0L);
  (void)sigsetmask(savemask);

  sigvec(SIGALRM, &vec, NULL);		/* Restore previous signal handler */
}
@EOF
set `wc -lwc <kaleid.c`
if test $1$2$3 != 521151614325
then
	echo ERROR: wc results of kaleid.c are $* should be 521 1516 14325
fi

chmod 444 kaleid.c

echo x - kalicon.h
cat >kalicon.h <<'@EOF'
/* Kaleidoscope icon -- for window managers that do not support window
   icons. */

#define icon_width 64
#define icon_height 64
static char icon_bits[] = {
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff,
   0xff, 0xf3, 0xff, 0xbb, 0xbb, 0xff, 0x9f, 0xff, 0xff, 0xcf, 0xff, 0x77,
   0xdd, 0xff, 0xe7, 0xff, 0xff, 0x33, 0xff, 0x6f, 0xed, 0xff, 0x99, 0xff,
   0xff, 0xcf, 0xfc, 0xeb, 0xae, 0x7f, 0xe6, 0xff, 0xff, 0x3f, 0xf3, 0x57,
   0xd4, 0x9f, 0xf9, 0xff, 0xff, 0xcf, 0xc8, 0x37, 0xd9, 0x27, 0xe6, 0xff,
   0xfb, 0x3f, 0x27, 0x2b, 0xa9, 0xc9, 0xf9, 0xbf, 0xd7, 0xff, 0x9c, 0x94,
   0x52, 0x72, 0xfe, 0xd7, 0xd7, 0xbf, 0x73, 0x90, 0x12, 0x9c, 0xf9, 0xd7,
   0xaf, 0x7e, 0xce, 0x03, 0x81, 0x67, 0xfe, 0xea, 0xaf, 0xfe, 0x39, 0x07,
   0x81, 0x99, 0xff, 0xea, 0x5f, 0xf5, 0xe6, 0x00, 0x00, 0xe6, 0x5e, 0xf5,
   0x5f, 0xed, 0x99, 0x03, 0x80, 0x39, 0x5f, 0xf5, 0xbf, 0xaa, 0x67, 0x06,
   0x41, 0xce, 0xab, 0xfa, 0xbf, 0x5a, 0x9b, 0x11, 0x88, 0xb3, 0xad, 0xfa,
   0x7f, 0x56, 0x65, 0x02, 0x81, 0x4c, 0xd5, 0xfc, 0x7f, 0xb5, 0x9a, 0x01,
   0x00, 0xb3, 0x56, 0xfd, 0xff, 0xac, 0x6a, 0x20, 0x08, 0xac, 0x6a, 0xfe,
   0xff, 0x6a, 0x95, 0x08, 0x01, 0x52, 0xab, 0xfe, 0xff, 0x59, 0x55, 0x22,
   0x81, 0x54, 0x35, 0xff, 0xff, 0xd5, 0xaa, 0x28, 0x08, 0xaa, 0x55, 0xff,
   0xff, 0xb3, 0x0a, 0x98, 0x32, 0xa0, 0x9a, 0xff, 0xff, 0xb3, 0x45, 0x64,
   0x4c, 0xc4, 0x9a, 0xff, 0xb7, 0x25, 0x01, 0x4a, 0xa4, 0x00, 0x41, 0xdb,
   0x6f, 0x02, 0x00, 0x05, 0x41, 0x0b, 0x80, 0xec, 0x9f, 0x0d, 0x02, 0x21,
   0x08, 0x01, 0x60, 0xf3, 0x7f, 0x03, 0x90, 0x12, 0x91, 0x96, 0x80, 0xfd,
   0xf7, 0x00, 0x00, 0xc6, 0xc7, 0x00, 0x00, 0xde, 0x4f, 0x0c, 0x00, 0xc1,
   0x07, 0x01, 0x60, 0xe4, 0xbf, 0x33, 0x65, 0xe8, 0x2f, 0x4c, 0x99, 0xf9,
   0x4f, 0x0c, 0x00, 0xc1, 0x07, 0x01, 0x60, 0xe4, 0xf7, 0x00, 0x00, 0xc6,
   0xc7, 0x00, 0x00, 0xde, 0x7f, 0x03, 0x90, 0x12, 0x91, 0x96, 0x80, 0xfd,
   0x9f, 0x0d, 0x02, 0x21, 0x08, 0x01, 0x60, 0xf3, 0x6f, 0x02, 0x00, 0x05,
   0x41, 0x0b, 0x80, 0xec, 0xb7, 0x25, 0x01, 0x4a, 0xa4, 0x00, 0x41, 0xdb,
   0xff, 0xb3, 0x45, 0x64, 0x4c, 0xc4, 0x9a, 0xff, 0xff, 0xb3, 0x0a, 0x98,
   0x32, 0xa0, 0x9a, 0xff, 0xff, 0xd5, 0xaa, 0x28, 0x08, 0xaa, 0x55, 0xff,
   0xff, 0x59, 0x55, 0x22, 0x81, 0x54, 0x35, 0xff, 0xff, 0x6a, 0x95, 0x08,
   0x01, 0x52, 0xab, 0xfe, 0xff, 0xac, 0x6a, 0x20, 0x08, 0xac, 0x6a, 0xfe,
   0x7f, 0xb5, 0x9a, 0x01, 0x00, 0xb3, 0x56, 0xfd, 0x7f, 0x56, 0x65, 0x02,
   0x81, 0x4c, 0xd5, 0xfc, 0xbf, 0x5a, 0x9b, 0x11, 0x88, 0xb3, 0xad, 0xfa,
   0xbf, 0xaa, 0x67, 0x06, 0x41, 0xce, 0xab, 0xfa, 0x5f, 0xed, 0x99, 0x03,
   0x80, 0x39, 0x5f, 0xf5, 0x5f, 0xf5, 0xe6, 0x00, 0x00, 0xe6, 0x5e, 0xf5,
   0xaf, 0xfe, 0x39, 0x07, 0x81, 0x99, 0xff, 0xea, 0xaf, 0x7e, 0xce, 0x03,
   0x81, 0x67, 0xfe, 0xea, 0xd7, 0xbf, 0x73, 0x90, 0x12, 0x9c, 0xf9, 0xd7,
   0xd7, 0xff, 0x9c, 0x94, 0x52, 0x72, 0xfe, 0xd7, 0xfb, 0x3f, 0x27, 0x2b,
   0xa9, 0xc9, 0xf9, 0xbf, 0xff, 0xcf, 0xc8, 0x37, 0xd9, 0x27, 0xe6, 0xff,
   0xff, 0x3f, 0xf3, 0x57, 0xd4, 0x9f, 0xf9, 0xff, 0xff, 0xcf, 0xfc, 0xeb,
   0xae, 0x7f, 0xe6, 0xff, 0xff, 0x33, 0xff, 0x6f, 0xed, 0xff, 0x99, 0xff,
   0xff, 0xcf, 0xff, 0x77, 0xdd, 0xff, 0xe7, 0xff, 0xff, 0xf3, 0xff, 0xbb,
   0xbb, 0xff, 0x9f, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
@EOF
set `wc -lwc <kalicon.h`
if test $1$2$3 != 495373360
then
	echo ERROR: wc results of kalicon.h are $* should be 49 537 3360
fi

chmod 444 kalicon.h

echo x - kaleid.1
cat >kaleid.1 <<'@EOF'
.TH KALEID 1
.PD
.ad b
.SH NAME
kaleid \- X11 Kaleidoscope Display
.SH SYNOPSIS
.TP \w'\fBkaleid\fR 'u
\fBkaleid\fR
[\|\fB-display\fR displayname\|] [\|\fB-bg\fR background\|]
[\|\fB-bd\fR border\|] [\|\fB-bw\fR borderwidth\|]
[\|\fB-geometry\fR geometry\|] [\|\fB-delay\fR msec\|]
[\|\fB-icondelay\fR msec\|] [\|\fB-iconic\fR\|] [\|\fB-mono\fR\|]
[\|\fB-r\fR\|]
.SH HP-UX COMPATIBILITY
.TP 10
Origin:
User Contributed
.SH DESCRIPTION
.I Kaleid
is an X11 port of Judson McClendon's EGA/VGA Kaleidoscope program from
the PC community.  \fIKaleid\fR runs a colorful kaleidoscope display in
an X11 window.  The 16-color palette is chosen to approximate the
default palette found on EGA and VGA displays.
.PP
With window managers that support icon windows (such as \fIuwm\fR), the
\fIkaleid\fR icon is a small kaleidoscope window that runs a slow
kaleidoscope display (see \fB-icondelay\fR option, below).
.PP
Options:
.TP .5i
.B -display
Specify display on which to run; defaults to contents of DISPLAY
environment variable.
.TP
.B -bg
Specify background color; defaults to black.
.TP
.B -bd
Specify border color; defaults to white.
.TP
.B -bw
Specify border width in pixels; defaults to 2.
.TP
.B -geometry
Specify window geometry; defaults to =300x300+0+0.
.TP
.B -delay
Specify a delay (in msec) to be performed between drawing each set of
lines \(em can be used to avoid swamping the X11 server.  Defaults to 10
(100 when \fB-r\fR option, below, is used).
.TP
.B -icondelay
Specify the delay to be used when drawing to the \fIkaleid\fR icon.
Defaults to 100 msec.
.TP
.B -iconic
Cause \fIkaleid\fR to come up in the iconic state.
.TP
.B -mono
Force \fIkaleid\fR to run in monochrome mode (default behavior on
a monochrome display).
.TP
.B -r
Run \fIkaleid\fR in the root window.  This option causes \fIkaleid\fR
to ignore all other options except \fB-delay\fR and \fB-mono\fR.
.SH NOTE
Specifying a delay (icondelay) value of 0 will cause kaleid to draw into
its window (icon) at top speed, bogging down your server and, if
\fIkaleid\fR is run remotely, your network.  Depending on your CPU speed
and network congestion, the default delay values might not be long enough.
.PP
If \fIkaleid\fR and the server are running on the same CPU, running
\fIkaleid\fR with a higher nice (nice(1)) value will usually produce
good results without 1) swamping the server, and 2) requiring you to
impose an unpleasantly long delay.
.SH AUTHORSHIP
The original kaleidoscope program for IBM PCs and compatibles was
written by Judson D. McClendon, Sun Valley Systems, 329 37th Court
N.E., Birmingham, AL, 35215 (CompuServe address [74415,1003]).  The port
to X11 was performed by Nathan Meyers of Hewlett-Packard
(nathanm@hp-pcd.hp.com).
.SH WINDOW MANAGER INTERACTIONS
Some window managers do not appear to cope very well with window icons,
resulting in strange icon behavior.  \fIUwm\fR does not suffer from this
problem, although problems can occur when changing window managers
(to or from \fIuwm\fR) during execution of \fIkaleid\fR.
.PP
With many window managers, including \fIuwm\fR, iconifying to a window
icon (which has an initial location) may behave differently from
iconifying to a pixmap icon (which usually does not have an initial
location).
.PP
On window managers that support window icons and that specify icon
sizing hints, \fIkaleid\fR will respect the icon sizing hints, creating
the largest permissible icon.  Without icon sizing hints, the default
icon size is 60x60.
@EOF
set `wc -lwc <kaleid.1`
if test $1$2$3 != 965273474
then
	echo ERROR: wc results of kaleid.1 are $* should be 96 527 3474
fi

chmod 444 kaleid.1

exit 0
-- 
Mike Wexler(wyse!mikew)    Phone: (408)433-1000 x1330
Moderator of comp.sources.x