Output of file : MANDEL.PAS contained in archive : MAND1.ZIP
{This is a program written to draw a mandelbrot graph.
Written By Dave Durant and Charles Sutton.}
program DCMandel;
uses crt, graph;

var
maxIters, x, y : longint;
minx, maxx, miny, maxy : single;
gd, gm : integer;
colorscale : single;
tdebug : single;

function scaley(y: integer): single;
begin scaley := (y*(maxy-miny)/(getmaxy))+miny; end;
function scalex(x: integer): single;
begin scalex := (1.5*x*(maxx-minx)/getmaxx)-maxx; end;

function iter (rC, iC: single; mIters : longint) : longint;
var
Iters : longint;
rTmp, iTmp, rCalc, iCalc : single;
begin
rTmp := 0;
iTmp := 0;
for Iters := 1 to mIters do
begin
rCalc := rTmp*rTmp - iTmp*iTmp; { function from here }
iCalc := 2*rTmp*iTmp;
rTmp := rCalc + rC;
iTmp := iCalc + iC; { to here }
tdebug := sqrt(rTmp*rTmp + iTmp*iTmp);
if sqrt(rTmp*rTmp + iTmp*iTmp) > 2 then begin
iter := Iters;
exit;
end;
end;
iter := 0;
end;

procedure do_graph;
var
stuff : longint;
{ x1, y1 : real;}
begin
initgraph(gd, gm, 'c:\tp\bgi');
colorscale := getmaxcolor/25;
for x := 0 to getmaxx do begin
for y := 0 to trunc(getmaxy/2) do begin
{ x1 := scalex(x); y1 := scaley(y)}
stuff := iter(scalex(x), scaley(y), maxiters);
putpixel(x, y, trunc((stuff*colorscale)+0.5));
putpixel(x, getmaxy-y, trunc((stuff*colorscale)+0.5));
end;
end;
closegraph;
end;

begin
closegraph;
write('Maximum iterations: ');
write('Min x, max x: ');