%                           LOOPS(1).TEX
% DRAWS LOOPS FOR FEYNMAN(32+).TEX:  GLUON LOOPS ONLY
\global\newcount\loopfrontx    \global\newcount\loopfronty
\global\newcount\loopbackx    \global\newcount\loopbacky
\global\newcount\loopmidx    \global\newcount\loopmidy
\global\newdimen\CENTRALLOOP
\gdef\drawloop#1[#2#3](#4,#5){
\global\CENTRALLOOP=0pt  % non-central is default
\global\LINETYPE=#1  
\ifnum\LTYPE=\gluon\relax\else\UNIMPERROR\LTYPE=1\message{Reverting to Gluons}
\fi
\global\LINEDIRECTION=#2  %initial loop direction
\global\fourthlineadjx=#3 %number of eighths of loop
\ifnum\fourthlineadjx=0 % (x,y) now midpoint.
  \global\CENTRALLOOP=1pt  % non-central is default
  \global\fourthlineadjx=8
  \global\LDIR=0
\fi   
\global\fourthlineadjy=\fourthlineadjx  % a conveniently unused variable.
\global\advance\fourthlineadjy by -4
\global\loopfrontx=#4   \global\loopfronty=#5
\ifdim\CENTRALLOOP=1pt
  \global\advance\loopfrontx by -2413  \global\advance\loopfronty by -425
\fi                          % diameter of gluonloop is 4825 to 4830 cpt.
\global\unitboxnumber=1  % default; \gluoncase
\ifnum\LINETYPE=\photon \unitboxnumber=2 \fi
\checkdir
\drawline\LINETYPE[\LDIR\LCONFIG](\loopfrontx,\loopfronty)[\unitboxnumber]
\DRAWLOOP
\ifnum\fourthlineadjy>-1 % at least 1/2 a loop
\global\loopmidx=\loopfrontx   \global\loopmidy=\loopfronty
\global\advance\loopmidx by \loopbackx  \global\advance\loopmidy by \loopbacky
\divide\loopmidx  by 2 \divide\loopmidy by 2  % midpoints of loop
\ifdim\CENTRALLOOP=1pt
  \global\advance\loopfrontx by 200    \global\advance\loopfronty by 425
  \global\advance\loopbackx by -200    \global\advance\loopbacky by -425
\fi
\fi % end of \ifnum\fourthlineadjy>-1 
}
\gdef\DRAWLOOP{
\global\advance\fourthlineadjx by -1
\ifnum\fourthlineadjx=0\relax  % finished!
\else
\ifnum\fourthlineadjx=\fourthlineadjy % opposite side of loop
   \global\loopbackx=\pbackx   \global\loopbacky=\pbacky
\fi
\global\advance\LDIR by 1
\moduloeight\LDIR
\checkdir
\drawline\LINETYPE[\LDIR\LCONFIG](\pbackx,\pbacky)[\unitboxnumber]
\fi % end \ifnum\fourthlineadjx
\ifnum\fourthlineadjx>1 \DRAWLOOP  \fi  % recursive
}
\gdef\checkdir{
\ifnum\LTYPE=\gluon
\ifodd\LDIR \global\LCONFIG=0 \else \global\LCONFIG=2 \fi
\fi %end of \gluon
}
