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

  1.  
  2. {$g+,n+,e-} { <-- Sorry about that, it's slow anyway }
  3.  
  4. { Reals   :       -1     -0.1      0.3   -1.139
  5.   Complex :        0      0.8     -0.5    0.238 }
  6.  
  7. program julia; { FRACTAL1.PAS }
  8. { Julia Fractal, uses hardcoded ET4000 SVGA mode! By Bas van Gaalen }
  9. uses u_vga,u_pal,u_kb;
  10. const vseg:word=$a000; 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 putpixel(xp,yp:word; col:byte); assembler; asm
  15.   mov es,vseg; mov ax,yp; mov dx,640; mul dx; add ax,xp; adc dx,0; mov di,ax
  16.   mov al,dl; mov dx,03cdh; out dx,al; mov al,col; mov [es:di],al; end;
  17.  
  18. begin
  19.   write('Real part: '); readln(cx);
  20.   write('Imaginary part: '); readln(cy);
  21.   setvideo($2e);
  22.   for i:=1 to 64 do setrgb(i,15+i div 3,15+i div 3,15+round(i/1.306122449));
  23.   mx:=639; my:=479; xdiv:=mx/4; ydiv:=my/4;
  24.   a:=1;
  25.   while a<mx do begin
  26.     b:=1;
  27.     while b<my do begin
  28.       xo:=-2+a/xdiv; { X complex plane coordinate }
  29.       yo:=2-b/ydiv; { Y complex plane coordinate }
  30.       i:=0;
  31.       repeat
  32.         x1:=xo*xo-yo*yo+cx;
  33.         y1:=2*xo*yo+cy;
  34.         xo:=x1;
  35.         yo:=y1;
  36.         inc(i);
  37.       until (i=64) or (x1*x1+y1*y1>4) or (abs(x1)>2) or (abs(y1)>2);
  38.       if i<64 then orb:=i else orb:=63;
  39.       putpixel(a,b,orb); { Plot orbit }
  40.       inc(b,speed);
  41.     end;
  42.     inc(a,speed);
  43.   end;
  44.   while not keypressed do;
  45.   setvideo(u_lm);
  46. end.
  47.