home *** CD-ROM | disk | FTP | other *** search
- {generates Pascal code for inclusion in fast circle/arc drawing program}
- {TITLE: Circle/Arc Animation}
-
- Program GenConst;
- type trigtable=array[0..90] of byte;
- const pi=3.14159265;
- var f:text;i,j,k:integer;
- function mycos(d:real):real;
- begin
- mycos:=cos(pi*d/180.0)
- end;
-
- function mysin(d:real):real;
- begin
- mysin:=sin(pi*d/180.0)
- end;
-
- procedure genarc(radius,start,last:integer);
- var y:array[-199..199] of array[0..1] of integer;
- px,fpx,py,fpy,i,j,k,l,m:integer;
- procedure jot(xx,yy:integer);
- var i:integer;
- begin
- if y[yy][0]=9999 then y[yy][0]:=xx else
- begin
- if y[yy][1]=9999 then y[yy][1]:=xx;
- if y[yy][0]>y[yy][1] then
- begin
- i:=y[yy][0];y[yy][0]:=y[yy][1];y[yy][1]:=i
- end;
- if xx<y[yy][0] then y[yy][0]:=xx else
- if xx>y[yy][1] then y[yy][1]:=xx
- end;
- end;
-
- begin
- fpx:=-1000;fpy:=-1000;
- for i:=-199 to 199 do begin y[i][0]:=9999;y[i][1]:=9999 end;
- for i:=4*start to 4*last do
- begin
- py:=-round(mysin(i/4.0)*radius);
- px:=round(mycos(i/4.0)*radius/0.44);
- jot(px,py);
- if fpx=-1000 then fpx:=px;
- if fpy=-1000 then fpy:=py;
- end;
- if fpy<=0 then for i:=fpy to 0 do
- if fpy=0 then jot(0,i) else
- jot(round(fpx*i/fpy),i)
- else
- for i:=0 to fpy do
- if fpy=0 then jot(0,i) else
- jot(round(fpx*i/fpy),i);
- if py<=0 then for i:=py to 0 do
- begin
- if py=0 then j:=0 else
- j:=round(px*i/py);
- jot(j,i);
- end
- else
- for i:=0 to py do
- begin
- if py=0 then j:=0 else
- j:=round(px*i/py);
- jot(j,i)
- end;
- j:=9999;
- for i:=-199 to 199 do
- if y[i][1]<>9999 then
- begin
- if j=9999 then j:=i;
- k:=i;
- end;
- writeln(f,'Type gdata=record x1,x2:integer end;');
- writeln(f,'Const sdata=',j,'; edata=',k,';');
- writeln(f,' data:array[sdata..edata] of gdata =');
- writeln(f,' (');
- for i:=j to k do
- begin
- write(f,' (x1:',y[i][0],';x2:',y[i][1],')');
- if i<>k then writeln(f,',') else writeln(f,');');
- end;
- end;
-
- begin
- assign(f,'fastarc.inc');
- rewrite(f);
- write('Enter 3 numbers for radius start end...');readln(i,j,k);
- genarc(i,j,k);
- close(f);
- end.
-