Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a5d6753

Browse filesBrowse files
backend_cairo: Clip drawn paths to context.clip_extents()
+ Fixes #4054
1 parent be305a3 commit a5d6753
Copy full SHA for a5d6753

File tree

Expand file treeCollapse file tree

1 file changed

+10
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-3
lines changed

‎lib/matplotlib/backends/backend_cairo.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_cairo.py
+10-3Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ def _fill_and_stroke (self, ctx, fill_c, alpha, alpha_overrides):
133133
ctx.stroke()
134134

135135
@staticmethod
136-
def convert_path(ctx, path, transform):
137-
for points, code in path.iter_segments(transform):
136+
def convert_path(ctx, path, transform, clip=None):
137+
for points, code in path.iter_segments(transform, clip=clip):
138138
if code == Path.MOVETO:
139139
ctx.move_to(*points)
140140
elif code == Path.CLOSEPOLY:
@@ -152,11 +152,18 @@ def convert_path(ctx, path, transform):
152152
def draw_path(self, gc, path, transform, rgbFace=None):
153153
ctx = gc.ctx
154154

155+
# We'll clip the path to the actual rendering extents
156+
# if the path isn't filled.
157+
if rgbFace is None and gc.get_hatch() is None:
158+
clip = ctx.clip_extents()
159+
else:
160+
clip = None
161+
155162
transform = transform + \
156163
Affine2D().scale(1.0, -1.0).translate(0, self.height)
157164

158165
ctx.new_path()
159-
self.convert_path(ctx, path, transform)
166+
self.convert_path(ctx, path, transform, clip)
160167

161168
self._fill_and_stroke(ctx, rgbFace, gc.get_alpha(), gc.get_forced_alpha())
162169

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.