c arc - draw an arc of an circle from the ixpen,iypen to ixp,iyp
      subroutine arc(ixp,iyp,ixpen,iypen,iarc)
      pi=3.14159
      ixdif=ixp-ixpen
      iydif=iyp-iypen
      dx=float(iabs(ixdif))
      dy=float(iabs(iydif))
      dxy=sqrt(dx*dx+dy*dy)
      ixret=ixpen
      iyret=iypen
      if(.not.(dxy.eq.0.))goto 23000
         call draw(ixp,iyp)
         return
23000 continue
      angnxt=atan2(float(iydif),float(ixdif))
      if(.not.( iarc .ge. 360 .or. iarc .le. -360))goto 23002
c circle
         radius=dxy/2.
         cenang=angnxt+pi
         angarc=2.*pi
         goto 23003
c     else
23002    continue
         angarc=iarc*pi/180.
         sinang=sin(abs(angarc/2.))
         if(.not.(sinang.lt..01))goto 23004
            call draw(ixp,iyp)
            return
23004    continue
         radius=amin1((dxy/2.)/sinang,4096.)
         if(.not.(iarc .gt. 0 .and. iarc .le. 180))goto 23006
            cenang=(3.*pi-angarc)/2.+angnxt
            goto 23007
c        else
23006       continue
            if(.not.(iarc .gt. 180 .and. iarc .lt. 360))goto 23008
               cenang=(-pi-angarc)/2.+angnxt
               goto 23009
c           else
23008          continue
               if(.not.(iarc .lt. 0 .and. iarc .ge. -180))goto 23010
                  cenang=(-3.*pi-angarc)/2.+angnxt
                  goto 23011
c              else
23010             continue
                  if(.not.(iarc .lt. -180 .and. iarc .gt. -360))goto 230
     &             12
                     cenang=(pi-angarc)/2.+angnxt
23012             continue
23011          continue
23009       continue
23007    continue
23003 continue
      steps=amin1(128.,amax1(8.,radius))
      units=2.*pi/steps
      cosnxt=cos(cenang)
      sinnxt=sin(cenang)
      sgn=sign(1.,angarc)
      absarc=abs(angarc)
c     for
      ang=units
23014 if(.not.(ang.lt.absarc))goto 23016
         rca=radius*cos(ang)-radius
         rsa=radius*sin(ang)*sgn
         ixx=rca*cosnxt-rsa*sinnxt+ixret
         iyy=rca*sinnxt+rsa*cosnxt+iyret
         call draw(ixx,iyy)
         ang=ang+units
         goto 23014
c     endfor
23016 continue
      if(.not.( angarc .ge. 2.*pi ))goto 23017
         call draw(ixret,iyret)
         goto 23018
c     else
23017    continue
         call draw(ixp,iyp)
23018 continue
      return
      end
