/*********************************************** * Mandzoom3.c * * Generates a RAW format file of an image * of Mandelbrot set (grayscale) * * C source file by Alberto Strumia * ************************************************/ #include /* definition of constants */ #define Radius 10 #define Cx 0.1620 #define Cy -1.035 #define Side 0.025 #define M 700 #define Num 1024 /* Alternative values Cx 0.1747, 0.1747 Cy -1.072,-1.072 Side 0.0015, 0.00015 Num 1024 */ /* main program */ main() { int p, q, n, w; double x, y, xx, yy, Incx, Incy; FILE *fp; fp = fopen("Mand.raw","w"); for (p = 1; p <= M; p++) { Incy = Cy - Side + 2*Side/M*p; printf("%i %%\n", p*100/M); for (q = 1; q <= M; q++) { Incx = Cx - Side + 2*Side/M*q; x = 0; y = 0; w = 200; for ( n = 1; n <= Num; ++n) { xx = x*x - y*y - Incx; yy = 2*x*y - Incy; x = xx; y = yy; if ( x*x + y*y > Radius ) { w = n; n = Num; } } fprintf(fp, "%c", w/4 ); } } fclose(fp); } /* end of main program */