Skip to content

Fix #5948: Don't clip closed paths #5955

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions lib/matplotlib/tests/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions src/_backend_agg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we only want to skip this if the path has a close command, not just any code points.

snapped_t snapped(clipped, gc.snap_mode, path.total_vertices(), snapping_linewidth);
simplify_t simplified(snapped, simplify, path.simplify_threshold());
curve_t curve(simplified);
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions src/_path.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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());

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/path_cleanup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down