{ For all of you who are interested on fractals, here is a little program, taken from a source code in Modula-2, that will draw a Mandelbrot fractal. Just one problem: If your computer doesn't have a math coprocessor, the program will run "a bit" slow :). Try modifying all the constants, you'll get strange results :).} {$U+} { Supposed to be used for Breaking During Programs } Program Mandelbrot; {Using real numbers. For TP 6.0 and above } Type Filestr = String[14]; Const Colours=15; {Number of colors to be on the image. } Width=640; {Width of the image. } Height=400; {Height of the image. } Limit=8.0; {Until when we calculate. } XRMin=-2.0; {Left limit of the fractal. } XRMax=1.0; {Right limit of the fractal. } YRMin=-1.3; {Lower limit of the fractal. } YRMax=1.3; {Upper limit of the fractal. } Bufsize = 128; Var XPos,YPos:Integer; Coldata : array[0..16000] of byte absolute $4000; recsread : integer; source : file; Procedure Save(filename:Filestr); begin recsread:=125; assign(source,filename); rewrite(source); blockwrite(source,Coldata,recsread); close(source); end; Procedure mode(mo:byte); begin Inline($3A/mo/ $CD/$9B/$BE/ $0E/$BC); end; Procedure grapen(col:byte); begin Inline($3A/col/ $CD/$9B/$BE/ $DE/$BB); end; Procedure Plot(Xpos, Ypos : integer); begin Inline($2A/ypos/ $ED/$5B/xpos/ $CD/$9B/$BE/ $EA/$BB); end; { Calculates the color for each point. } Function ComputeColour(XPos,YPos:Integer):Byte; Var RealP,ImagP:Real; CurrX,CurrY:Real; a2,b2:Real; Counter:Byte; Begin CurrX:=XPos/Width*(XRMax-XRMin)+XRMin; CurrY:=YPos/Height*(YRMax-YRMin)+YRMin; RealP:=0; ImagP:=0; Counter:=0; Repeat a2:=Sqr(RealP); b2:=Sqr(ImagP); ImagP:=2*RealP*ImagP+CurrY; RealP:=a2-b2+CurrX; counter:=succ(counter); Until (Counter>=Colours) or (a2+b2>=Limit); ComputeColour:=Counter-1; End; Procedure Setup(xpos2, ypos2, count, stop : integer); begin repeat begin xpos2:=0; repeat begin Coldata[count]:=ComputeColour(xpos2,ypos2); xpos2:=xpos2+2; count:=succ(count); end; until (xpos2=width); ypos2:=ypos2-2; end; until (ypos2=stop); end; Begin mode(1); setup(0,400,0,298); save('mandel1.dat'); gotoxy(1,1); write('Mandel 1/4 Completed'); setup(0,298,0,198); save('mandel2.dat'); gotoxy(1,2); write('Mandel 2/4 Completed'); setup(0,198,0,098); save('mandel3.dat'); gotoxy(1,3); write('Mandel 3/4 Completed'); setup(0,098,0,0); save('mandel4.dat'); gotoxy(1,4); write('Mandel 4/4 Completed'); repeat until keypressed; mode(2); End.