JULIA2.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:02:00 BDB
Sender: "\"FRACTAL\" discussion list" 
Comments: @FPSP.FAPESP.BR - @FPSP.HEPNET - @BRFAPESP.BITNET - .BR gateway
From: BJ06@C53000.PETROBRAS.ANRJ.BR
Subject: JULIA2.CPP (C++ 3.1 source code)
Lines: 113
 
---Program JULIA2.CPP---Begin---CUT HERE-----------------------------
//+-----------------------------------------------------------------+
//+ Program JULIA2.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:                                                          +
//+      JULIA2        +
//+ Example:                                                        +
//       JULIA2 -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[])
{
      double xmin, xmax, ymin, ymax, fact=1.0;
      double ypy, x, y, x0, y0, xp, yp, const_scr=1.0;
      double deltax, deltay, p, q, ya, xkp1, ykp1, r;
      register int npix=1024, npiy=768, kcolor;
      register int k, np, nq, npy, 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);
      }
      ypy = (double)npiy - 0.5;
      deltax = (xmax-xmin)/(npix-1);
      deltay = (ymax-ymin)/(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 of Z = XKP1 ; Imaginary part of Z = 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 escape towards infinity.
//     Se R > M, o ponto escapa para o infinito.
 
           if (r >= kcolor) {
             ipen = k;
             xp = const_scr*(double)np;
             yp = (double)nq;
             putpixel(xp,yp,ipen);
           }
 
//      Converging points is 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.
//   Fechamento.
 
     getch();
     closegraph();
}
---Program JULIA2.CPP---End---CUT HERE--------------------------