\Fractals
JULIA.CPP
Path: unixg.ubc.ca!news.mic.ucla.edu!library.ucla.edu!europa.eng.gtefsd.com!paladin.american.edu!auvm!C53000.PETROBRAS.ANRJ.BR!BJ06 Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU Newsgroups: bit.listserv.frac-l Return-Path: <@AUVM.AMERICAN.EDU,@VTBIT.CC.VT.EDU:FRAC-L@GITVM1.BITNET> X-Envelope-to: FRAC-L@GITVM1.BITNET X-VMS-To: @FRACTAL References: ANSP network HEPnet SPAN Bitnet Internet gateway Message-ID:Date: Fri, 7 Jan 1994 11:00:00 BDB Sender: "\"FRACTAL\" discussion list" Comments: @FPSP.FAPESP.BR - @FPSP.HEPNET - @BRFAPESP.BITNET - .BR gateway From: BJ06@C53000.PETROBRAS.ANRJ.BR Subject: JULIA.CPP (C++ 3.1 source code) Lines: 112 ---Program JULIA.CPP---Begin---CUT HERE----------------------------- //+----------------------------------------------------------------+ //+ Program JULIA.CPP + //+ OBS: Needs SVGA256 package (SVGA256.H & SVGA256.BGI) and + //+ 1024 x 768 points, 256 colours screen + //+ By F.A.A. Barbuto, January 1994. + //+ Usage: + //+ JULIA + //+ Example: + // JULIA -0.74356 0.11135 -2.0 2.0 -2.0 2.0 256 + //+----------------------------------------------------------------+ #include #include #include #include #include #include "Svga256.h" //void far initgraph(int far *,int far *,char far *); int huge DetectVGA256() { int Vid=4; return Vid; } void main(int argc, char *argv[]) { register double xmin, xmax, ymin, ymax, fact=1.0; register double ypy, x, y, x0, y0, xp, yp, const_scr=1.0; register double deltax, deltay, p, q, ya, r, xkp1, ykp1; register int npix=1024, npiy=768, kcolor; register int k, np, nq, ipen; char *endptr; int graphdriver=DETECT; int graphmode; p = strtod(argv[1],&endptr); q = strtod(argv[2],&endptr); xmin = strtod(argv[3],&endptr); xmax = strtod(argv[4],&endptr); ymin = strtod(argv[5],&endptr); ymax = strtod(argv[6],&endptr); kcolor = atoi(argv[7]); if(kcolor == 0) kcolor = 256; installuserdriver("Svga256",DetectVGA256); initgraph(&graphdriver, &graphmode, "c:\\borlandc\\bgi"); if(fact>=1.0 || fact <=0.0) fact = 1.0; else { npix = (int)(npix*fact); npiy = (int)(npiy*fact); } deltax = (xmax-xmin)/(double)(npix-1); deltay = (ymax-ymin)/(double)(npiy-1); cleardevice(); for (np=0; np<=npix-1; np++) { x0 = xmin + (double)np*deltax; for (nq=0; nq<=npiy-1; nq++) { y0 = ymin + (double)nq*deltay; x = x0; y = y0; k = 0; // Real part: XKP1 ; Imaginary: YKP1 // Parte real: XKP1 ; Imaginaria: YKP1 do { xkp1 = (x+y)*(x-y) + p; ya = x*y; ykp1 = ya + ya + q; r = xkp1*xkp1 + ykp1*ykp1; k++; // If R > M the point escapes towards infinity. // Se R > M, o ponto escapa para o infinito. if (r >= kcolor) { ipen = 30 + k; xp = const_scr*(double)np; yp = (double)nq; putpixel(xp,yp,ipen); } // Converging points in blue colour. // Pontos que convergem para o atrator; coloracao azul. if (k == kcolor) { ipen = 1; xp = const_scr*(double)np; yp = (double)nq; putpixel(xp,yp,ipen); } // Returns if no convergence is achieved on either escape or atraction. // Retorna se nao houver convergencia na fuga ou atracao. x = xkp1; y = ykp1; } while (r <= kcolor && k<=kcolor); } if(kbhit()) break; } // Clean-up. // Fecha a parte grafica. getch(); closegraph(); } ---Program JULIA.CPP---End---CUT HERE--------------------------------