Skip to content

Commit

Permalink
Merge remote-tracking branch 'matplotlib/v2.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
tacaswell committed Aug 30, 2016
2 parents a8555c9 + ba83035 commit 211984d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions lib/matplotlib/tests/test_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,3 +393,14 @@ def test_text_stale():
assert not ax1.stale
assert not ax2.stale
assert not fig.stale


@image_comparison(baseline_images=['agg_text_clip'],
extensions=['png'])
def test_agg_text_clip():
np.random.seed(1)
fig, (ax1, ax2) = plt.subplots(2)
for x, y in np.random.rand(10, 2):
ax1.text(x, y, "foo", clip_on=True)
ax2.text(x, y, "foo")
plt.show()
8 changes: 4 additions & 4 deletions src/_backend_agg.h
Original file line number Diff line number Diff line change
Expand Up @@ -738,14 +738,14 @@ inline void RendererAgg::draw_text_image(GCAgg &gc, ImageArray &image, int x, in
typedef agg::renderer_scanline_aa<renderer_base, color_span_alloc_type, span_gen_type>
renderer_type;

theRasterizer.reset_clipping();
rendererBase.reset_clipping(true);
if (angle != 0.0) {
agg::rendering_buffer srcbuf(
image.data(), (unsigned)image.dim(1),
(unsigned)image.dim(0), (unsigned)image.dim(1));
agg::pixfmt_gray8 pixf_img(srcbuf);

theRasterizer.reset_clipping();
rendererBase.reset_clipping(true);
set_clipbox(gc.cliprect, theRasterizer);

agg::trans_affine mtx;
Expand Down Expand Up @@ -786,9 +786,9 @@ inline void RendererAgg::draw_text_image(GCAgg &gc, ImageArray &image, int x, in
agg::rect_i clip;

clip.init(int(mpl_round(gc.cliprect.x1)),
int(mpl_round(gc.cliprect.y1)),
int(mpl_round(height - gc.cliprect.y2)),
int(mpl_round(gc.cliprect.x2)),
int(mpl_round(gc.cliprect.y2)));
int(mpl_round(height - gc.cliprect.y1)));
text.clip(clip);
}

Expand Down

0 comments on commit 211984d

Please sign in to comment.