8000 Silently discard blits if bbox is outside canvas · matplotlib/matplotlib@32e0474 · GitHub
[go: up one dir, main page]

Skip to content

Commit 32e0474

Browse files
Silently discard blits if bbox is outside canvas
1 parent b22c1c9 commit 32e0474

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/matplotlib/backends/_backend_tk.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ def blit(photoimage, aggimage, offsets, bbox=None):
8080
8181
If *bbox* is passed, it defines the region that gets blitted. That region
8282
will be composed with the previous data according to the alpha channel.
83+
Blitting will be clipped to pixels inside the canvas, including silently
84+
doing nothing if the *bbox* region is entirely outside the canvas.
8385
8486
Tcl events must be dispatched to trigger a blit from a non-Tcl thread.
8587
"""
@@ -92,6 +94,8 @@ def blit(photoimage, aggimage, offsets, bbox=None):
9294
x2 = min(math.ceil(x2), width)
9395
y1 = max(math.floor(y1), 0)
9496
y2 = min(math.ceil(y2), height)
97+
if (x1 > x2) or (y1 > y2):
98+
return
9599
bboxptr = (x1, x2, y1, y2)
96100
comp_rule = TK_PHOTO_COMPOSITE_OVERLAY
97101
else:

0 commit comments

Comments
 (0)
0