| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -648,7 +648,67 @@ | |
| renderer = PathEffectRenderer(self.get_path_effects(), renderer) | ||
|
|
||
| for draw_path_args in draw_path_args_list: | ||
| renderer.draw_path(gc, *draw_path_args) | ||
| draw_path_instead = False | ||
| # Below two lines are only for testing/comparing | ||
| # and can be removed | ||
| 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(): | ||
|
Check warning on line 657 in lib/matplotlib/patches.py
|
||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityRather 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.
All reactions
Copy link
Copy Markdown
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI agree, something to work on.
Sorry, something went wrong.
All reactions
|
||
| patch = self | ||
| base_transform = artist.Artist.get_transform(patch).get_affine() | ||
| if isinstance(patch, Shadow): | ||
| # base_transform += patch._shadow_transform | ||
| # is incorrect as order matters over here. | ||
| base_transform = patch._shadow_transform + base_transform | ||
| patch = patch.patch | ||
| common_args = (gc, | ||
| base_transform, | ||
| draw_path_args[2]) # rgbFace | ||
| if isinstance(patch, (Polygon, RegularPolygon, | ||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI believe that we now have a high enough minimum python we can use the match statement.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityOh yes, I will make that change.
Sorry, something went wrong.
All reactions
|
||
| CirclePolygon, Arrow, FancyArrow) | ||
| ): | ||
| renderer.draw_polygon(gc, *draw_path_args) | ||
| elif isinstance(patch, Circle): | ||
| renderer.draw_circle(*common_args, | ||
| patch.get_center(), patch.get_radius()) | ||
| elif isinstance(patch, Arc): | ||
| renderer.draw_arc(*common_args, patch.get_center(), | ||
| patch.get_width()/2, patch.get_height()/2, | ||
| patch.get_angle(), patch.theta1, patch.theta2) | ||
| elif isinstance(patch, Ellipse): | ||
| renderer.draw_ellipse(*common_args, | ||
| patch.get_center(), patch.get_width()/2, | ||
| patch.get_height()/2, patch.get_angle()) | ||
| elif isinstance(patch, Annulus): | ||
| renderer.draw_annulus(*common_args, | ||
| patch.get_center(), *patch.get_radii(), | ||
| patch.get_width(), patch.get_angle()) | ||
| elif isinstance(patch, Rectangle): | ||
| renderer.draw_rectangle(*common_args, | ||
| patch.get_xy(), patch.get_center(), | ||
| patch.get_width(), patch.get_height(), | ||
| patch.get_angle(), | ||
| patch._get_computed_rotation_point()) | ||
| elif isinstance(patch, Wedge): | ||
| renderer.draw_wedge(*common_args, | ||
| patch.center, patch.r, patch.theta1, | ||
| patch.theta2, patch.width) | ||
| elif isinstance(patch, StepPatch): | ||
| renderer.draw_steppatch(gc, | ||
| self.fill or (self._baseline is not None and \ | ||
| self._baseline.ndim == 1), | ||
| *draw_path_args) | ||
| else: | ||
| draw_path_instead = True | ||
| else: | ||
| draw_path_instead = True | ||
| # Below two lines are only for testing/comparing | ||
| # and can be removed | ||
| else: | ||
| draw_path_instead = True | ||
| if draw_path_instead: | ||
| renderer.draw_path(gc, *draw_path_args) | ||
|
|
||
| gc.restore() | ||
| renderer.close_group('patch') | ||
| Expand Down Expand Up | @@ -827,13 +887,7 @@ | |
| # important to call the accessor method and not directly access the | ||
| # transformation member variable. | ||
| bbox = self.get_bbox() | ||
| if self.rotation_point == 'center': | ||
| width, height = bbox.x1 - bbox.x0, bbox.y1 - bbox.y0 | ||
| rotation_point = bbox.x0 + width / 2., bbox.y0 + height / 2. | ||
| elif self.rotation_point == 'xy': | ||
| rotation_point = bbox.x0, bbox.y0 | ||
| else: | ||
| rotation_point = self.rotation_point | ||
| rotation_point = self._get_computed_rotation_point() | ||
| return transforms.BboxTransformTo(bbox) \ | ||
| + transforms.Affine2D() \ | ||
| .translate(-rotation_point[0], -rotation_point[1]) \ | ||
| Expand All | @@ -842,6 +896,16 @@ | |
| .scale(1, 1 / self._aspect_ratio_correction) \ | ||
| .translate(*rotation_point) | ||
|
|
||
| def _get_computed_rotation_point(self): | ||
| bbox = self.get_bbox() | ||
| if self.rotation_point == 'center': | ||
| width, height = bbox.x1 - bbox.x0, bbox.y1 - bbox.y0 | ||
| return bbox.x0 + width / 2., bbox.y0 + height / 2. | ||
| elif self.rotation_point == 'xy': | ||
| return bbox.x0, bbox.y0 | ||
| else: | ||
| return self.rotation_point | ||
|
|
||
| @property | ||
| def rotation_point(self): | ||
| """The rotation point of the patch.""" | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIf 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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualitywith 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.
Uh oh!
There was an error while loading. Please reload this page.