Skip to content

Commit 1c690ee

Browse files
committed
Merge pull request #5955 from mdboom/fix-path-line
Fix #5948: Don't clip closed paths
2 parents 9dca4d8 + a3fbee6 commit 1c690ee

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

lib/matplotlib/tests/test_transforms.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,7 @@ def test_clipping_of_log():
208208
simplify=False)
209209

210210
tpoints, tcodes = list(zip(*result))
211-
# Because y coordinate -99 is outside the clip zone, the first
212-
# line segment is effectively removed. That means that the closepoly
213-
# operation must be replaced by a move to the first point.
214-
assert np.allclose(tcodes, [M, M, L, L, L, C])
211+
assert np.allclose(tcodes, [M, L, L, L, C])
215212

216213

217214
class NonAffineForTest(mtrans.Transform):

src/_backend_agg.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ RendererAgg::draw_path(GCAgg &gc, PathIterator &path, agg::trans_affine &trans,
488488

489489
transformed_path_t tpath(path, trans);
490490
nan_removed_t nan_removed(tpath, true, path.has_curves());
491-
clipped_t clipped(nan_removed, clip, width, height);
491+
clipped_t clipped(nan_removed, clip && !path.has_curves(), width, height);
492492
snapped_t snapped(clipped, gc.snap_mode, path.total_vertices(), snapping_linewidth);
493493
simplify_t simplified(snapped, simplify, path.simplify_threshold());
494494
curve_t curve(simplified);
@@ -1014,7 +1014,7 @@ inline void RendererAgg::_draw_path_collection_generic(GCAgg &gc,
10141014

10151015
transformed_path_t tpath(path, trans);
10161016
nan_removed_t nan_removed(tpath, true, has_curves);
1017-
clipped_t clipped(nan_removed, do_clip, width, height);
1017+
clipped_t clipped(nan_removed, do_clip && !has_curves, width, height);
10181018
snapped_t snapped(
10191019
clipped, gc.snap_mode, path.total_vertices(), points_to_pixels(gc.linewidth));
10201020
if (has_curves) {

src/_path.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ void convert_path_to_polygons(PathIterator &path,
885885

886886
transformed_path_t tpath(path, trans);
887887
nan_removal_t nan_removed(tpath, true, path.has_curves());
888-
clipped_t clipped(nan_removed, do_clip, width, height);
888+
clipped_t clipped(nan_removed, do_clip && !path.has_curves(), width, height);
889889
simplify_t simplified(clipped, simplify, path.simplify_threshold());
890890
curve_t curve(simplified);
891891

@@ -950,7 +950,7 @@ void cleanup_path(PathIterator &path,
950950

951951
transformed_path_t tpath(path, trans);
952952
nan_removal_t nan_removed(tpath, remove_nans, path.has_curves());
953-
clipped_t clipped(nan_removed, do_clip, rect);
953+
clipped_t clipped(nan_removed, do_clip && !path.has_curves(), rect);
954954
snapped_t snapped(clipped, snap_mode, path.total_vertices(), stroke_width);
955955
simplify_t simplified(snapped, do_simplify, path.simplify_threshold());
956956

@@ -1156,7 +1156,7 @@ int convert_to_string(PathIterator &path,
11561156

11571157
transformed_path_t tpath(path, trans);
11581158
nan_removal_t nan_removed(tpath, true, path.has_curves());
1159-
clipped_t clipped(nan_removed, do_clip, clip_rect);
1159+
clipped_t clipped(nan_removed, do_clip && !path.has_curves(), clip_rect);
11601160
simplify_t simplified(clipped, simplify, path.simplify_threshold());
11611161

11621162
*buffersize = path.total_vertices() * (precision + 5) * 4;

src/path_cleanup.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class PathCleanupIterator
4343
: m_transform(trans),
4444
m_transformed(m_path_iter, m_transform),
4545
m_nan_removed(m_transformed, remove_nans, m_path_iter.has_curves()),
46-
m_clipped(m_nan_removed, do_clip, rect),
46+
m_clipped(m_nan_removed, do_clip && !m_path_iter.has_curves(), rect),
4747
m_snapped(m_clipped, snap_mode, m_path_iter.total_vertices(), stroke_width),
4848
m_simplify(m_snapped,
4949
do_simplify && m_path_iter.should_simplify(),

0 commit comments

Comments
 (0)