Open anntzer opened 7 years ago
iirc the reason that we do not clip filled regions is to avoid having to do the computational geometry required.
https://en.wikipedia.org/wiki/Sutherland%E2%80%93Hodgman_algorithm doesn't look too bad to implement.
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
Would still be nice to have, I think.
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
The svg spec says that renderers should support values within the range of a C float (https://www.w3.org/TR/SVG/types.html#Precision). However, in practice, inkscape appears to be limited to overflow around 2**24, probably due to the fact that it relies on cairo (which has the same limitation) for rendering. Chromium's svg renderer also appears to hit an overflow somewhere (not sure about the exact value). Agg also has this limitation (see comment at the top of
_path_converters.h
:and it is explicitly tested that this is worked around for Agg (test_simplification.test_overflow).
Currently, the svg backend clips output paths to the actually drawn canvas, but does not clip filled areas. So, with
we get:
png:
svg, converted to png by inkscape (can't attach a svg in a gh comment) -- but chromium renders the same way:
(the red line is drawn accurately because it is clipped in the SVG output; the blue box disappears because it is not clipped and overflows inkscape's renderer)
There are similar overflow issues with pdf output (via ghostscript -- the relevant renderer, as we use it for the test suite), which are in fact the factor limiting the clip value in https://github.com/matplotlib/matplotlib/pull/9477 (that's how I found out about this issue), although I can't point to anything in the pdf spec right now.
Now one may argue that "this is the fault of the noncompliant renderer", but given that we are already clipping unfilled paths, and also fully working around this for raster output, I think it makes sense to clip filled paths as well in svg (and pdf). (Of course, this will still fail when someone tries to make a svg image with a dimension exceeding 2**24. Honestly I don't care about that case :-))
Related to #8901 (clipping in eps).