主题:[原创]J集fP程序
uses crt,graph,math;
var th,tw,gd, gm, lo, hi, error,pattle: integer;
xi,xa,yi,ya,jx,jy:float;
found,pv:boolean;
a:char;
procedure makeup(cxmin,cxmax,cymin,cymax,jx,jy:float;big:boolean;nmax:integer);
const sx=640;sy=480;l=4;
lx=120; ly=90;
var cx,cy,x,y,xx,yy,dx,dy,z:float;
i,j,n,kx,ky,color:integer;
begin
if big then begin
kx:=sx;
ky:=sy end
else
begin kx:=lx;
ky:=ly
end;
dx:=(cxmax-cxmin)/kx;
dy:=(cymax-cymin)/ky;
FOR i:=0 to kx do begin
cx:=cxmin+i*dx;
FOR j:=0 to ky do begin
cy:=cymin+J*dy;
x:=cx;
y:=cy;
FOR n:=0 to nmax do begin
xx:=x*x-y*y+jx;
yy:=2*x*y+jy;
if sqrt(sqr(xx)+sqr(yy))>L then break;
x:=xx;
y:=yy;
end;
color:=n mod 32+32*(pattle+1);
if n=nmax then color:=16;
putpixel(i,j,color);
end;
end;
end;
begin
writeln('INPUT JULIA''S XMIN XMAX YMIN YMAX C''S X C''S Y');
readln(xi,xa,yi,ya,jx,jy);
pattle:=0;
{ We want an 8 bit mode }
gd := D8bit;
{ Get all available resolutions for this bitdepth }
getmoderange(gd,lo,hi);
{ If the highest available mode number is -1,
no resolutions are supported for this bitdepth }
if hi = -1 then
begin
writeln('no 8 bit modes supported!');
halt
end;
found := false;
{ Search all resolutions for 640x480 }
for gm := lo to hi do
begin
initgraph(gd,gm,'');
{ Make sure you always check graphresult! }
error := graphResult;
if (error = grOk) and
(getmaxx =639 ) and (getmaxy = 479) then
begin
found := true;
break;
end;
end;
if not found then
begin
writeln('640x480x256 is not supported!');
halt(1)
end;
{ We are now in 640x480x256 }
pv:=TRUE;
makeup(xi,xa,yi,ya,jx,jy,tRUE,500);
a:=readkey;
while a<>#27 do begin
case a of
'p':pv:=not pv;
#77:jx:=jx+0.01;
#75:jx:=jx-0.01;
#72:jy:=jy-0.01;
#80:jy:=jy+0.01;
#25:pattle:=(pattle+1)mod 5;
#13:makeup(xi,xa,yi,ya,jx,jy,TRUE,500);
end;
if pv then
makeup(xi,xa,yi,ya,jx,jy,FALSE,100);
a:=readkey;
end;
closegraph;
end.
var th,tw,gd, gm, lo, hi, error,pattle: integer;
xi,xa,yi,ya,jx,jy:float;
found,pv:boolean;
a:char;
procedure makeup(cxmin,cxmax,cymin,cymax,jx,jy:float;big:boolean;nmax:integer);
const sx=640;sy=480;l=4;
lx=120; ly=90;
var cx,cy,x,y,xx,yy,dx,dy,z:float;
i,j,n,kx,ky,color:integer;
begin
if big then begin
kx:=sx;
ky:=sy end
else
begin kx:=lx;
ky:=ly
end;
dx:=(cxmax-cxmin)/kx;
dy:=(cymax-cymin)/ky;
FOR i:=0 to kx do begin
cx:=cxmin+i*dx;
FOR j:=0 to ky do begin
cy:=cymin+J*dy;
x:=cx;
y:=cy;
FOR n:=0 to nmax do begin
xx:=x*x-y*y+jx;
yy:=2*x*y+jy;
if sqrt(sqr(xx)+sqr(yy))>L then break;
x:=xx;
y:=yy;
end;
color:=n mod 32+32*(pattle+1);
if n=nmax then color:=16;
putpixel(i,j,color);
end;
end;
end;
begin
writeln('INPUT JULIA''S XMIN XMAX YMIN YMAX C''S X C''S Y');
readln(xi,xa,yi,ya,jx,jy);
pattle:=0;
{ We want an 8 bit mode }
gd := D8bit;
{ Get all available resolutions for this bitdepth }
getmoderange(gd,lo,hi);
{ If the highest available mode number is -1,
no resolutions are supported for this bitdepth }
if hi = -1 then
begin
writeln('no 8 bit modes supported!');
halt
end;
found := false;
{ Search all resolutions for 640x480 }
for gm := lo to hi do
begin
initgraph(gd,gm,'');
{ Make sure you always check graphresult! }
error := graphResult;
if (error = grOk) and
(getmaxx =639 ) and (getmaxy = 479) then
begin
found := true;
break;
end;
end;
if not found then
begin
writeln('640x480x256 is not supported!');
halt(1)
end;
{ We are now in 640x480x256 }
pv:=TRUE;
makeup(xi,xa,yi,ya,jx,jy,tRUE,500);
a:=readkey;
while a<>#27 do begin
case a of
'p':pv:=not pv;
#77:jx:=jx+0.01;
#75:jx:=jx-0.01;
#72:jy:=jy-0.01;
#80:jy:=jy+0.01;
#25:pattle:=(pattle+1)mod 5;
#13:makeup(xi,xa,yi,ya,jx,jy,TRUE,500);
end;
if pv then
makeup(xi,xa,yi,ya,jx,jy,FALSE,100);
a:=readkey;
end;
closegraph;
end.