home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / GFXFX2.ZIP / FRACTAL2.PAS < prev    next >
Pascal/Delphi Source File  |  1995-02-14  |  1KB  |  51 lines

  1.  
  2. {$g+,n+,e-}
  3.  
  4. { Reals   :       -1     -0.1      0.3   -1.139
  5.   Complex :        0      0.8     -0.5    0.238 }
  6.  
  7. program julia; { FRACTAL2.PAS }
  8. { Julia Fractal (uses SVGA256.BGI), by Bas van Gaalen }
  9. uses u_vga,graph,u_pal,u_kb; { VGA BEFORE GRAPH! }
  10. const speed=2; { ei: 1=slow and accurate; 5=fast and inaccurate }
  11. type real=double;
  12. var cx,cy,xo,yo,x1,y1,xdiv,ydiv:real; mx,my,a,b,i,orb:word;
  13.  
  14. procedure setvid;
  15. var grmd,grdr:integer;
  16. {$f+} function detectvga:integer; begin detectvga:=2; end; {$f-}
  17. begin
  18.   grdr:=installuserdriver('svga256',@detectvga); grdr := 0;
  19.   initgraph(grdr,grmd,'');
  20. end;
  21.  
  22. begin
  23.   write('Real part: '); readln(cx);
  24.   write('Imaginary part: '); readln(cy);
  25.   setvid;
  26.   for i:=1 to 64 do setrgb(i,15+i div 3,15+i div 3,15+round(i/1.306122449));
  27.   mx:=639; my:=479; xdiv:=mx/4; ydiv:=my/4;
  28.   a:=1;
  29.   while a<mx do begin
  30.     b:=1;
  31.     while b<my do begin
  32.       xo:=-2+a/xdiv; { X complex plane coordinate }
  33.       yo:=2-b/ydiv; { Y complex plane coordinate }
  34.       i:=0;
  35.       repeat
  36.         x1:=xo*xo-yo*yo+cx;
  37.         y1:=2*xo*yo+cy;
  38.         xo:=x1;
  39.         yo:=y1;
  40.         inc(i);
  41.       until (i=64) or (x1*x1+y1*y1>4) or (abs(x1)>2) or (abs(y1)>2);
  42.       if i<64 then orb:=i else orb:=63;
  43.       putpixel(a,b,orb); { Plot orbit }
  44.       inc(b,speed);
  45.     end;
  46.     inc(a,speed);
  47.   end;
  48.   while not keypressed do;
  49.   setvideo(u_lm);
  50. end.
  51.