From a5e1ab443922e9b08f84f6af061b7e92e0d8ae77 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Mon, 1 Feb 2016 16:22:28 -0500 Subject: [PATCH 1/2] Fix #5948: Don't clip closed paths --- src/_backend_agg.h | 4 ++-- src/_path.h | 6 +++--- src/path_cleanup.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/_backend_agg.h b/src/_backend_agg.h index 524bf38d2806..4816cd826f60 100644 --- a/src/_backend_agg.h +++ b/src/_backend_agg.h @@ -488,7 +488,7 @@ RendererAgg::draw_path(GCAgg &gc, PathIterator &path, agg::trans_affine &trans, transformed_path_t tpath(path, trans); nan_removed_t nan_removed(tpath, true, path.has_curves()); - clipped_t clipped(nan_removed, clip, width, height); + clipped_t clipped(nan_removed, clip && !path.has_curves(), width, height); snapped_t snapped(clipped, gc.snap_mode, path.total_vertices(), snapping_linewidth); simplify_t simplified(snapped, simplify, path.simplify_threshold()); curve_t curve(simplified); @@ -1014,7 +1014,7 @@ inline void RendererAgg::_draw_path_collection_generic(GCAgg &gc, transformed_path_t tpath(path, trans); nan_removed_t nan_removed(tpath, true, has_curves); - clipped_t clipped(nan_removed, do_clip, width, height); + clipped_t clipped(nan_removed, do_clip && !has_curves, width, height); snapped_t snapped( clipped, gc.snap_mode, path.total_vertices(), points_to_pixels(gc.linewidth)); if (has_curves) { diff --git a/src/_path.h b/src/_path.h index bfda0464d541..6b1b3d1f7053 100644 --- a/src/_path.h +++ b/src/_path.h @@ -885,7 +885,7 @@ void convert_path_to_polygons(PathIterator &path, transformed_path_t tpath(path, trans); nan_removal_t nan_removed(tpath, true, path.has_curves()); - clipped_t clipped(nan_removed, do_clip, width, height); + clipped_t clipped(nan_removed, do_clip && !path.has_curves(), width, height); simplify_t simplified(clipped, simplify, path.simplify_threshold()); curve_t curve(simplified); @@ -950,7 +950,7 @@ void cleanup_path(PathIterator &path, transformed_path_t tpath(path, trans); nan_removal_t nan_removed(tpath, remove_nans, path.has_curves()); - clipped_t clipped(nan_removed, do_clip, rect); + clipped_t clipped(nan_removed, do_clip && !path.has_curves(), rect); snapped_t snapped(clipped, snap_mode, path.total_vertices(), stroke_width); simplify_t simplified(snapped, do_simplify, path.simplify_threshold()); @@ -1156,7 +1156,7 @@ int convert_to_string(PathIterator &path, transformed_path_t tpath(path, trans); nan_removal_t nan_removed(tpath, true, path.has_curves()); - clipped_t clipped(nan_removed, do_clip, clip_rect); + clipped_t clipped(nan_removed, do_clip && !path.has_curves(), clip_rect); simplify_t simplified(clipped, simplify, path.simplify_threshold()); *buffersize = path.total_vertices() * (precision + 5) * 4; diff --git a/src/path_cleanup.cpp b/src/path_cleanup.cpp index 7951cfd9cef5..f9f2213b3d7f 100644 --- a/src/path_cleanup.cpp +++ b/src/path_cleanup.cpp @@ -43,7 +43,7 @@ class PathCleanupIterator : m_transform(trans), m_transformed(m_path_iter, m_transform), m_nan_removed(m_transformed, remove_nans, m_path_iter.has_curves()), - m_clipped(m_nan_removed, do_clip, rect), + m_clipped(m_nan_removed, do_clip && !m_path_iter.has_curves(), rect), m_snapped(m_clipped, snap_mode, m_path_iter.total_vertices(), stroke_width), m_simplify(m_snapped, do_simplify && m_path_iter.should_simplify(), From a3fbee6bab5017acbb7e910b29e2070fa7a02ecd Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Mon, 1 Feb 2016 18:10:10 -0500 Subject: [PATCH 2/2] Update test. --- lib/matplotlib/tests/test_transforms.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/matplotlib/tests/test_transforms.py b/lib/matplotlib/tests/test_transforms.py index 5190ddc873fe..92d4c4f36e87 100644 --- a/lib/matplotlib/tests/test_transforms.py +++ b/lib/matplotlib/tests/test_transforms.py @@ -208,10 +208,7 @@ def test_clipping_of_log(): simplify=False) tpoints, tcodes = list(zip(*result)) - # Because y coordinate -99 is outside the clip zone, the first - # line segment is effectively removed. That means that the closepoly - # operation must be replaced by a move to the first point. - assert np.allclose(tcodes, [M, M, L, L, L, C]) + assert np.allclose(tcodes, [M, L, L, L, C]) class NonAffineForTest(mtrans.Transform):