#include #include #include main(int argc, char *argv[]) { int itermax = 100; /* maximum iters to do */ double breakout=64.; /* z^2 greater than this is a breakout */ double magnify=0.75; /* 10 is standard magnification */ double cr,ci; double x0=.09950; double y0=-.00062; int hxres = 500; /* horizontal resolution */ int hyres = 500; /* vertical resolution */ double x,xx,y,xl,yl,zsq,zm,rb; int iter,hx,hy; int red,green,blue; FILE *ofp; rb=sqrt(breakout); ofp=fopen("julia.ppm","w"); if (argc>1) sscanf(argv[1],"%lf",&magnify); if (argc>2) sscanf(argv[2],"%d",&itermax); if (argc>3) sscanf(argv[3],"%lf",&cr); if (argc>4) sscanf(argv[4],"%lf",&ci); if (argc>5) sscanf(argv[5],"%lf",&x0); if (argc>6) sscanf(argv[6],"%lf",&y0); /* header for PPM output */ fprintf(ofp,"P6\n# magnify=%lf itermax=%d\n",magnify,itermax); fprintf(ofp,"%d %d\n255\n",hyres,hxres); for (hy=1;hy<=hyres;hy++) { for (hx=1;hx<=hxres;hx++) { ci = 4*((hyres+1-hy-.5)/hyres-0.5)/magnify+y0; cr = 4*((hx-.5)/hxres-0.5)/magnify+x0; x=0; y=0; zm=0; for (iter=1;iter zm) zm=zsq; if (zsq>breakout) break; } if (iter>=itermax){ red=0; green=255.*zm/breakout; blue=255.*zm/breakout; } else{ red=255*iter/10; /* CHANGED */ green=0; blue=.5*255*iter/10; /* CHANGED */ } fputc((char)red,ofp); fputc((char)green,ofp); fputc((char)blue,ofp); } } fclose(ofp); system("xv julia.ppm"); }