00001 00002 c 00003 c Copyright (c) 1986,1987,1988,1989,1990,1991,1992,1993, 00004 c by Steve McMillan, Drexel University, Philadelphia, PA. 00005 c 00006 c All rights reserved. 00007 c 00008 c Redistribution and use in source and binary forms are permitted 00009 c provided that the above copyright notice and this paragraph are 00010 c duplicated in all such forms and that any documentation, 00011 c advertising materials, and other materials related to such 00012 c distribution and use acknowledge that the software was developed 00013 c by the author named above. 00014 c 00015 c THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 00016 c IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 00017 c WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00018 c 00019 00020 subroutine ngon(rcall,scall,h,n,thoff) 00021 save 00022 c 00023 c Draws |n|-sided polygons (n = 0 ==> "." 00024 c 1 "+" 00025 c 2 "x". 00026 c or "stars" (for n < 0) 00027 c 00028 real*4 rr,ss,r,s,h,thoff 00029 integer*4 n 00030 common /findex/ index 00031 dimension rpoly(0:100),spoly(0:100),cth1(0:100),sth1(0:100) 00032 c 00033 data n1/0/ 00034 c 00035 r=rcall 00036 s=scall 00037 go to 1 00038 c 00039 entry ungon(rcall,scall,h,n,thoff) 00040 entry userngon(rcall,scall,h,n,thoff) 00041 call fr inches(rcall,scall,r,s) 00042 c 00043 1 if(h.lt.0..and.n.ne.0)then 00044 hh=-h 00045 rr=r+.7071*hh 00046 ss=s+.7071*hh 00047 else 00048 hh=h 00049 rr=r 00050 ss=s 00051 end if 00052 c 00053 if(n.eq.0.or.h.eq.0.)then 00054 call point(rr,ss) 00055 else if(abs(n).eq.1)then 00056 call plot(rr-hh,ss,3) 00057 call plot(rr+hh,ss,2) 00058 call plot(rr,ss-hh,3) 00059 call plot(rr,ss+hh,2) 00060 else if(abs(n).eq.2)then 00061 hh=.7071*hh 00062 call plot(rr-hh,ss-hh,3) 00063 call plot(rr+hh,ss+hh,2) 00064 call plot(rr-hh,ss+hh,3) 00065 call plot(rr+hh,ss-hh,2) 00066 else 00067 nn=abs(n) 00068 nn1=nn 00069 if(n.lt.0)then 00070 nn2=nn/2 00071 ieven=0 00072 if(2*nn2.eq.nn)ieven=1 00073 if(ieven.eq.1)nn1=nn2 00074 end if 00075 th0=thoff 00076 dth=360./float(nn) 00077 th0=th0-90.-.5*dth 00078 th0=.017453*th0 00079 dth=.017453*dth 00080 th=th0-dth 00081 ipen=3 00082 do 100 i=0,nn1 00083 if(nn.ne.n1)then 00084 th=th+dth 00085 cth1(i)=cos(th) 00086 sth1(i)=sin(th) 00087 end if 00088 hc=hh*cth1(i) 00089 hs=hh*sth1(i) 00090 r1=rr+hc 00091 s1=ss+hs 00092 if(n.gt.0)then 00093 if(index.lt.0)then 00094 call plot(r1,s1,ipen) 00095 ipen=2 00096 else 00097 rpoly(i)=r1 00098 spoly(i)=s1 00099 end if 00100 else 00101 if(ieven.eq.0)then 00102 call plot(rr,ss,3) 00103 else 00104 call plot(rr-hc,ss-hs,3) 00105 end if 00106 call plot(r1,s1,2) 00107 end if 00108 100 continue 00109 if(index.ge.0.and.n.gt.0)call polyfill(rpoly,spoly,n+1) 00110 n1=nn 00111 end if 00112 c 00113 end