Juliaset.cpp
//Julia Sets in C++
//by James Rankin

#include 
#include 
#include 
#include 
#include 
#include 

void runfractal(void);
int propercolor(double);
int huge detectvga256(void);

double cx, cy;
const int steppingratio = 256 / 4;

void main() {
	clrscr();
	cout << "Julia Sets on C++\n";
	cout << "by James Rankin\n";
	cout << "\n";
	cout << "Input the CX value.\n";
	cin >> cx;
	cout << "\nInput the CY value.\n";
	cin >> cy;
	cout << "\nGenerating fractal...";
	delay(900);
	int graphdriver = installuserdriver("SVGA256", detectvga256);
	graphdriver = DETECT;
	int graphmode;
	initgraph(&graphdriver, &graphmode, "");
//	settextstyle(TRIPLEX_FONT,HORIZ_DIR,5);

	runfractal();
	closegraph();
}

void runfractal(void) {
double a, b, x0, x1, y0, y1;
int hey, col;
	for(int aa = 0; aa <= 512; aa++) {
		a = aa / 10.24;
		for (int bb = 0; bb <= 768; bb++) {
			b = bb / 7.68;
			x0 = -2 + a / 25;
			y0 = 2 - b / 25;
			for (int i = 0; i <= 20; i++) {
				x1 = x0 * x0 - y0 * y0 + cx;
				y1 = 2 * x0 * y0 + cy;
				if (x1*x1 + y1*y1 > 4) {
					hey = 0;
					i = 21;
				} else {
					hey = 1;
					x0 = x1;
					y0 = y1;
				}//of if
			}//of for
			if (hey==1) {
				col = propercolor(x1*x1 + y1*y1);
				putpixel((int)aa,(int)bb,col);
				if (aa != 512) putpixel(1024-(int)aa,768-(int)bb,col);
			}//of if
		}//of for
	}//of for
	sound(440);
	delay(30);
	nosound();
	getch();
}//of method

int propercolor(double frac) {
	return((int)frac * steppingratio + 1);
}//of method

int huge detectvga256(void) {
	return 4;
}//of method