/*
	This  is  a  very  tiny program to demonstrate just how simple it is to
generate  a  Mandelbrot  set.   This  68  line program calculates the outer
Mandelbrot  set  and  displays  it  in ASCII characters on a console.  This
program does not allow you to zoom.  Copyright © 1996 CygnusSoftware.
	*/

#include "stdio.h"

#define MaxIters    60

#define	XSIZE		70
#define	YSIZE		22

#define	BLACK		-1

#define	LEFT	-2.0

#define	RIGHT	1.0

#define	TOP		1.0

#define	BOTTOM	-1.0

main(int argc, char *argv[])
 {
 short   x, y, counter;
 long double zr, zi, cr, ci, rsquared, isquared;

 for (y = 0; y < YSIZE; y++)
	{
	for (x = 0; x < XSIZE; x++)
		{
		zr = 0.0;
		zi = 0.0;
		cr = LEFT + x * (RIGHT - LEFT) / XSIZE;
		ci = TOP + y * (BOTTOM - TOP) / YSIZE;
		rsquared = zr * zr;
		isquared = zi * zi;



		/* The next eleven lines actually do all of the work. */
		for (counter = 0; rsquared + isquared <= 4.0 &&
					counter < MaxIters; counter++)
			{
			zi = zr * zi * 2;
			zi += ci;

			zr = rsquared - isquared;
			zr += cr;

			rsquared = zr * zr;
			isquared = zi * zi;
			}



		if (rsquared + isquared <= 4.0)
			putchar('*');	/* In the set. */
		else
			putchar(' ');	/* Not in the set. */
		}
	putchar('\n');
	}
 puts("SimpleMand: Copyright © 1996 Cygnus Software.\nThat's it.");
 return 0;
 }
