.TH kaleidoscope "" "" "Command"
.PC "Electronic kaleidoscope"
\fBkaleidoscope [ \fIseed\fB ]\fR
.PP
The command
.B kaleidoscope
executes
an electronic kaleidoscope on your system's console.
It works only on a VGA system with a color monitor.
.PP
The optional
.I seed
controls the ``spread'' of the kaleidoscope; by default, it is set to 320.
To turn of the kaleidoscope, type
.BR <ctrl-C> .
.PP
The following gives the source code for
.BR kaleidoscope .
It requires the library
.B libvga.a
and the header files
.B <emulib.h>
and
.BR <vga.h> ,
which are part of the ``gift'' package included with \*(CO 4.2.
.DM
#include <emulib.h>
#include <vga.h>
#include <stdio.h>
#include <stdlib.h>
.DE
.DM
#define BACK  2
.DE
.DM
int x1, y1, x2, y2, xv1, yv1, xv2, yv2, hc;
int xa, ya, xb, yb;
int ch;
int m = 320; /* spread */
int cx = 320; /* the center of the screen*/
int cy = 240;
int nc = 16; /* number of colors */
int i, waste = 0;
.DE
.DM
main(argc,argv)
int argc; char **argv;
{
	if (argc == 2)
		m = atoi(argv[1]);
.DE
.DM
	puts("         K A L E I D O S C O P E\n");
	puts("              D. McClendon\n");
	puts("       translated from IBM PASCAL\n");
	puts("           EGA with 128K/256K\n");
	puts("             by tom wible\n");
	puts("translated from MYARC C99 to Turbo C 2.0\n");
	puts("        by Harry C. Pulley, IV\n");
	puts("translated from Turbo C 2.0 to Coherent cc and vgalib\n");
	puts("        by Harry C. Pulley, IV\n");
.DE
.DM
#if 0
	puts("          Press  P  to pause,\n");
	puts("          Press  Q  to exit,\n");
	puts("          Press  C  to clear,\n");
	puts("          Press  a number to delay,\n");
#endif
	puts("      Press enter to begin/resume: ");
.DE
.DM
	getchar();
	vga_setmode(G640x480x16);
	srand(time(NULL));
.DE
.DM
	while (1) {
		vga_clear();
		x1 = rand()*m/32767;
		x2 = rand()*m/32767;
		y1 = rand()*(x1+1)/32767;
		y2 = rand()*(x2+1)/32767;
.DE
.DM
		while (rand()*100/32767) {
			xv1 = rand()*11/32767 - 5;
			xv2 = rand()*11/32767 - 5;
			yv1 = rand()*11/32767 - 5;
			yv2 = rand()*11/32767 - 5;
			hc  = rand()*nc/32767 +1;
.DE
.DM
			while (rand()*10/32767) {
				vga_setcolor(hc);
				xa = x1*9 / 5;
				xb = x2*9 / 5;
				ya = y1*9 / 5;
				yb = y2*9 / 5;
.DE
.DM
				vga_drawline( (cx+xa), (cy-y1), (cx+xb), (cy-y2));
				vga_drawline( (cx-ya), (cy+x1), (cx-yb), (cy+x2));
				vga_drawline( (cx-xa), (cy-y1), (cx-xb), (cy-y2));
				vga_drawline( (cx-ya), (cy-x1), (cx-yb), (cy-x2));
				vga_drawline( (cx-xa), (cy+y1), (cx-xb), (cy+y2));
				vga_drawline( (cx+ya), (cy-x1), (cx+yb), (cy-x2));
				vga_drawline( (cx+xa), (cy+y1), (cx+xb), (cy+y2));
				vga_drawline( (cx+ya), (cy+x1), (cx+yb), (cy+x2));
.DE
.DM
				x1 = (x1 + xv1) % m;
				y1 = (y1 + yv1) % m;
				x2 = (x2 + xv2) % m;
				y2 = (y2 + yv2) % m;
.DE
.DM
				for (i = waste ; i-- ; )
					;
			}
		}
	}
}
.DE
.SH "See Also"
.B
commands,
libvga,
vgif
.R
.SH Notes
Because both
.B kaleidoscope
and the X Window System control the VGA card directly, you must
.I not
run
.B kaleidoscope
under X.
.PP
.II "McClendon, D."
.B kaleidoscope
was written by D. McClendon.
.II "Pulley, Harry"
It was ported to \*(CO by Harry C. Pulley, IV.
