Clip device-space polygons to a rectangle before they are filled. The polygon counterpart of fortplot_segment_clip: backends call this so that vertices far outside the visible area (e.g. y ~ 1e21 under a small ylim) neither overflow integer pixel conversion nor reach the PDF stream, and the fill covers exactly the visible part.
Output size that always holds the clip of an n-vertex polygon: one half-plane stage turns k vertices into at most 3k/2, so four stages give at most (3/2)**4 n < 6 n.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | n |
Sutherland-Hodgman clip of the closed polygon (px, py) to [lo(1),hi(1)] x [lo(2),hi(2)]. Non-finite vertices are dropped first. On return (cx(1:m), cy(1:m)) is the clipped polygon; m = 0 when fewer than three vertices remain. cx, cy need clip_polygon_capacity(size(px)) elements. A vertex created on an edge lies exactly on it.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in) | :: | px(:) | |||
| real(kind=wp), | intent(in) | :: | py(:) | |||
| real(kind=wp), | intent(in) | :: | lo(2) | |||
| real(kind=wp), | intent(in) | :: | hi(2) | |||
| real(kind=wp), | intent(out) | :: | cx(:) | |||
| real(kind=wp), | intent(out) | :: | cy(:) | |||
| integer, | intent(out) | :: | m |