| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
| draw_path_instead = False | ||
| # Below two lines are only for testing/comparing | ||
| # and can be removed | ||
| with open('pure_svg_mode', 'r') as f: |
There was a problem hiding this comment.
If we were to merge this, we would have to provide an rcparam to control it (like we do with text in vector backends that let you pick "text + embed the fonts / hope they are available in the viewer" vs "draw text as paths")
Sorry, something went wrong.
There was a problem hiding this comment.
with open('pure_svg_mode', 'r') as f: is NOT for merging (release version). It's simply there to perform my comparison tests as mentioned in my Test Code Repository (link in issue description), i.e., to compare between the old method and the new method. It will be deleted.
Sorry, something went wrong.
| common_args = (gc, | ||
| base_transform, | ||
| draw_path_args[2]) # rgbFace | ||
| if isinstance(patch, (Polygon, RegularPolygon, |
There was a problem hiding this comment.
I believe that we now have a high enough minimum python we can use the match statement.
Sorry, something went wrong.
There was a problem hiding this comment.
Oh yes, I will make that change.
I was also wondering if instead of multiple conditions in this draw function, shouldn't they be called from within their respective classes itself? Or is this the right way forward?
Sorry, something went wrong.
| with open('pure_svg_mode', 'r') as f: | ||
| if f.read() == '1': | ||
| from matplotlib.backends.backend_mixed import MixedModeRenderer | ||
| if isinstance(renderer, MixedModeRenderer) and renderer.is_svg_renderer(): |
There was a problem hiding this comment.
Rather than pin to the svg renderer, if we are going to do this then we should duck-type and allow backends to opt-in to providing more specialized rendering calls.
Sorry, something went wrong.
There was a problem hiding this comment.
I agree, something to work on.
Sorry, something went wrong.
|
I'm mildly in favor of this conceptually, but I think the first thing to sort out is how we want to allow backends to provide additional methods that not all have. I think the path is to add "additional methods that backends may implement for specialization reasons" + an rcparam to globally turn trying to use them on/off. This is not perfectly clear (as say the users asks for specialization and the backend happens to have draw_circle, should that be prefferniatlly used by draw_marker when the marker is definitly a circle?) but I think is a good starting point. This has some (conceptual) overlap with the methods related to blitting. Unfortunately given that we require changes inside of draw, I don't see an easy way to do this in an extension module first (I can think of terrible ways that involve sub-classing and monkey-patching but that is a bit too messy to advocate for). |
Sorry, something went wrong.
|
I agree this will take time and a lot of revisions. I thought there was only one SVG backend. Are there others? I'm not well knowledgeable on the topic of specialisation that you're talking about. Extension modules for SVG implementation or backends? Wouldn't markers too internally be simplified into their basic shape classes? |
Sorry, something went wrong.
|
The cairo (internal) and mplcairo (third-party) backends can also render to svg. |
Sorry, something went wrong.
I'd like to bring backend versioning back to the table. #30559 While it doesn't solve all issues here, it would really help to formally specify variants of the backend API. |
Sorry, something went wrong.
|
I don't think we should really ever require (or suggest that it be required) that backends provide all these draw_foo methods. Something more reasonable may be to add a single pair of can_draw_patch(Patch) -> bool and draw_patch(Patch) methods (and if the backend says that it cannot natively draw the patch, then fall back to the standard Path representation. |
Sorry, something went wrong.
Similar happens for text; you can implement draw_text, but if not, then everything goes through draw_path (which is required). |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR summary
Currently all SVG elements are exported as path, which is currently the most viable solution, as other solutions have their pitfalls. But a concise and apt SVG could make things better and is something probably to work on.
This PR closes #17424. (well, not really, just wanted to link it to the issue as per the PR checklist)
It's not the final solution but it solves the problem. There are restrictions involved in this solution (reference):
I have performed relevant tests:
P.S.: It's not meant to pass any CI/CD tests, as the solution itself is assumed to be subject to changes.