/*********************************************** * JuliazoomGen2.c * * Generates a RAW format file of an image * of a Generalized Julia set (grayscale) * * C source file by Alberto Strumia * ************************************************/ #include /* definition of constants */ #define Radius 10 #define Cx 1.05 #define Cy 0.2109 #define Side 1.4 #define M 700 #define Num 512 /* alternative values x0 = 0, y0 = 0, Side 0.3, Num 1024; x0 = -0.15, y0 = 0.07, 0.1, Num 1024 */ /* main program */ main() { int p, q, n, w; double x, y, xx, yy, Incx, Incy; FILE *fp; fp = fopen("Julia.raw","w"); for (p = 1; p <= M; p++) { Incy = - Side + 2*Side/M*p; printf("%i %%\n", p*100/M); for (q = 1; q <= M; q++) { Incx = - Side + 2*Side/M*q; x = Incx; y = Incy; w = 200; for ( n = 1; n <= Num; ++n) { xx = (x*x - y*y)*(x*x - y*y) - 4*x*x*y*y - Cx; yy = 4*x*y*(x*x - y*y) - Cy; x = xx; y = yy; if ( x*x + y*y > Radius ) { w = n; n = Num; } } fprintf(fp, "%c", w/2 ); } } fclose(fp); } /* end of main program */