Fill all visible bands of one type as single keyholed polygon.
Band loops linked by "bridges" between anchors (first point of each loop), each walked out and back along one line, so enclosing no area under cairo's winding fill. One polygon is one giza fill, so hatch is computed once and stays aligned across bands.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(bandset_t), | intent(in) | :: | bs |
Bands of one type. |
subroutine fill_bandset_linked(bs) !! Fill all visible bands of one type as single keyholed polygon. !! !! Band loops linked by "bridges" between anchors (first point of each loop), each walked out !! and back along one line, so enclosing no area under cairo's winding fill. One polygon is !! one giza fill, so hatch is computed once and stays aligned across bands. ! Arguments type(bandset_t), intent(in) :: bs !! Bands of one type. integer(int32) :: k, i, n, o, j0, j1, need, nvis real(real64), allocatable :: ax(:), ay(:) need = 0; nvis = 0 do k = 1, bs%nb j0 = max(bs%b(k)%i0, ivis0); j1 = min(bs%b(k)%i1, ivis1) if (j0 > j1) cycle if (.not. band_y_visible(bs%b(k), j0, j1)) cycle nvis = nvis + 1 need = need + 4*(j1 - j0 + 1) + 2 end do if (nvis == 0) return call ensure_scratch(need + nvis) allocate (ax(nvis), ay(nvis)) n = 0; nvis = 0 do k = 1, bs%nb j0 = max(bs%b(k)%i0, ivis0); j1 = min(bs%b(k)%i1, ivis1) if (j0 > j1) cycle if (.not. band_y_visible(bs%b(k), j0, j1)) cycle o = 1 - bs%b(k)%i0 nvis = nvis + 1 ax(nvis) = clampx(xtrans(xedge(j0))); ay(nvis) = clampy(ytrans(bs%b(k)%ylo(j0 + o))) ! the jump from the previous band's anchor to this first point ! is the bridge out do i = j0, j1 n = n + 1; epx(n) = clampx(xtrans(xedge(i))); epy(n) = clampy(ytrans(bs%b(k)%ylo(i + o))) n = n + 1; epx(n) = clampx(xtrans(xedge(i + 1))); epy(n) = epy(n - 1) end do do i = j1, j0, -1 n = n + 1; epx(n) = clampx(xtrans(xedge(i + 1))); epy(n) = clampy(ytrans(bs%b(k)%yhi(i + o))) n = n + 1; epx(n) = clampx(xtrans(xedge(i))); epy(n) = epy(n - 1) end do ! close the loop back at this band's anchor n = n + 1; epx(n) = ax(nvis); epy(n) = ay(nvis) end do ! retrace the bridges so each is walked out and back do k = nvis - 1, 1, -1 n = n + 1; epx(n) = ax(k); epy(n) = ay(k) end do call giza_polygon(n, epx(1:n), epy(1:n)) deallocate (ax, ay) end subroutine fill_bandset_linked