draw_chainset Subroutine

private subroutine draw_chainset(cs)

Stroke cached region outline of one type.

Emits only points on visible strip edges, plus one lead-in and lead-out point so cut chains run through window edge, where giza clips them.

Arguments

Type IntentOptional Attributes Name
type(chainset_t), intent(in) :: cs

Outline chains of one type.


Source Code

   subroutine draw_chainset(cs)
      !! Stroke cached region outline of one type.
      !!
      !! Emits only points on visible strip edges, plus one lead-in and lead-out point so cut chains
      !! run through window edge, where giza clips them.
      ! Arguments
      type(chainset_t), intent(in) :: cs
         !! Outline chains of one type.
      integer(int32) :: k, i, n
      do k = 1, cs%nc
         call ensure_scratch(cs%c(k)%n + 2)
         n = 0
         do i = 1, cs%c(k)%n
            if (cs%c(k)%ei(i) >= ivis0 .and. cs%c(k)%ei(i) <= ivis1 + 1) then
               if (n == 0 .and. i > 1) then
                  n = n + 1
                  epx(n) = clampx(xtrans(xedge(cs%c(k)%ei(i - 1))))
                  epy(n) = clampy(ytrans(cs%c(k)%y(i - 1)))
               end if
               n = n + 1
               epx(n) = clampx(xtrans(xedge(cs%c(k)%ei(i))))
               epy(n) = clampy(ytrans(cs%c(k)%y(i)))
            else if (n > 0) then
               ! one point beyond the window, then break the run
               n = n + 1
               epx(n) = clampx(xtrans(xedge(cs%c(k)%ei(i))))
               epy(n) = clampy(ytrans(cs%c(k)%y(i)))
               if (n >= 2) call giza_line(n, epx(1:n), epy(1:n))
               n = 0
            end if
         end do
         if (n >= 2) call giza_line(n, epx(1:n), epy(1:n))
      end do
   end subroutine draw_chainset