8000 Revert "Don't disable path clipping on paths with codes." · matplotlib/matplotlib@b43fb0d · GitHub
[go: up one dir, main page]

Skip to content

Commit b43fb0d

Browse files
committed
Revert "Don't disable path clipping on paths with codes."
When paths are closed, if we emit a closing code, Agg will attempt to actually close the path, if it was split due to clipping. We do not want that to occur, since that would make phantom lines appear on any paths that are larger than the figure. Omitting the close code is also not possible, as then Agg will not join the beginning and the end with the correct join style, but treat them as ends with caps. For now, it is simpler to revert the previous change. This reverts commit 81aa223.
1 parent a35d2e5 commit b43fb0d

File tree

4 files changed

+6
-30
lines changed

4 files changed

+6
-30
lines changed

lib/matplotlib/tests/test_patheffects.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ def test_collection():
136136
'edgecolor': 'blue'})
137137

138138

139-
@image_comparison(['tickedstroke'], remove_text=True, extensions=['png'],
140-
tol=0.22) # Increased tolerance due to fixed clipping.
139+
@image_comparison(['tickedstroke'], remove_text=True, extensions=['png'])
141140
def test_tickedstroke():
142141
fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(12, 4))
143142
path = Path.unit_circle()

lib/matplotlib/tests/test_simplification.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,29 +47,6 @@ def test_diamond():
4747
ax.set_ylim(-0.6, 0.6)
4848

4949

50-
def test_clipping_out_of_bounds():
51-
# Should work on a Path *without 8000 * codes.
52-
path = Path([(0, 0), (1, 2), (2, 1)])
53-
simplified = path.cleaned(clip=(10, 10, 20, 20))
54-
assert_array_equal(simplified.vertices, [(0, 0)])
55-
assert simplified.codes == [Path.STOP]
56-
57-
# Should work on a Path *with* codes, and no curves.
58-
path = Path([(0, 0), (1, 2), (2, 1)],
59-
[Path.MOVETO, Path.LINETO, Path.LINETO])
60-
simplified = path.cleaned(clip=(10, 10, 20, 20))
61-
assert_array_equal(simplified.vertices, [(0, 0)])
62-
assert simplified.codes == [Path.STOP]
63-
64-
# A Path with curves does not do any clipping yet.
65-
path = Path([(0, 0), (1, 2), (2, 3)],
66-
[Path.MOVETO, Path.CURVE3, Path.CURVE3])
67-
simplified = path.cleaned()
68-
simplified_clipped = path.cleaned(clip=(10, 10, 20, 20))
69-
assert_array_equal(simplified.vertices, simplified_clipped.vertices)
70-
assert_array_equal(simplified.codes, simplified_clipped.codes)
71-
72-
7350
def test_noise():
7451
np.random.seed(0)
7552
x = np.random.uniform(size=50000) * 50

src/_backend_agg.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ RendererAgg::draw_path(GCAgg &gc, PathIterator &path, agg::trans_affine &trans,
470470

471471
trans *= agg::trans_affine_scaling(1.0, -1.0);
472472
trans *= agg::trans_affine_translation(0.0, (double)height);
473-
bool clip = !face.first && !gc.has_hatchpath();
473+
bool clip = !face.first && !gc.has_hatchpath() && !path.has_curves();
474474
bool simplify = path.should_simplify() && clip;
475475
double snapping_linewidth = points_to_pixels(gc.linewidth);
476476
if (gc.color.a == 0.0) {
@@ -992,7 +992,7 @@ inline void RendererAgg::_draw_path_collection_generic(GCAgg &gc,
992992
}
993993
}
994994

995-
bool do_clip = !face.first && !gc.has_hatchpath();
995+
bool do_clip = !face.first && !gc.has_hatchpath() && !has_curves;
996996

997997
if (check_snap) {
998998
gc.isaa = antialiaseds(i % Naa);

src/_path.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ void convert_path_to_polygons(PathIterator &path,
999999

10001000
transformed_path_t tpath(path, trans);
10011001
nan_removal_t nan_removed(tpath, true, path.has_curves());
1002-
clipped_t clipped(nan_removed, do_clip, width, height);
1002+
clipped_t clipped(nan_removed, do_clip && !path.has_curves(), width, height);
10031003
simplify_t simplified(clipped, simplify, path.simplify_threshold());
10041004
curve_t curve(simplified);
10051005

@@ -1064,7 +1064,7 @@ void cleanup_path(PathIterator &path,
10641064

10651065
transformed_path_t tpath(path, trans);
10661066
nan_removal_t nan_removed(tpath, remove_nans, path.has_curves());
1067-
clipped_t clipped(nan_removed, do_clip, rect);
1067+
clipped_t clipped(nan_removed, do_clip && !path.has_curves(), rect);
10681068
snapped_t snapped(clipped, snap_mode, path.total_vertices(), stroke_width);
10691069
simplify_t simplified(snapped, do_simplify, path.simplify_threshold());
10701070

@@ -1223,7 +1223,7 @@ bool convert_to_string(PathIterator &path,
12231223

12241224
transformed_path_t tpath(path, trans);
12251225
nan_removal_t nan_removed(tpath, true, path.has_curves());
1226-
clipped_t clipped(nan_removed, do_clip, clip_rect);
1226+
clipped_t clipped(nan_removed, do_clip && !path.has_curves(), clip_rect);
12271227
simplify_t simplified(clipped, simplify, path.simplify_threshold());
12281228

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

0 commit comments

Comments
 (0)
0