Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4e5e624

Browse files
committed
Handle paths with a single moveto point
1 parent 1d52371 commit 4e5e624

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

lib/matplotlib/tests/test_simplification.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,16 @@ def test_clipping_full():
217217
simplified = list(p.iter_segments(clip=[0, 0, 100, 100]))
218218
assert simplified == []
219219

220+
p = path.Path([[50, 40], [75, 65]], [1, 2])
221+
simplified = list(p.iter_segments(clip=[0, 0, 100, 100]))
222+
assert ([(list(x), y) for x, y in simplified] ==
223+
[([50, 40], 1), ([75, 65], 2)])
224+
225+
p = path.Path([[50, 40]], [1])
226+
simplified = list(p.iter_segments(clip=[0, 0, 100, 100]))
227+
assert ([(list(x), y) for x, y in simplified] ==
228+
[([50, 40], 1)])
229+
220230

221231
if __name__=='__main__':
222232
import nose

src/path_converters.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,17 @@ class PathClipper : public EmbeddedQueue<2>
402402
return code;
403403
}
404404

405+
if (m_moveto &&
406+
m_lastX >= m_cliprect.x1 &&
407+
m_lastX <= m_cliprect.x2 &&
408+
m_lastY >= m_cliprect.y1 &&
409+
m_lastY <= m_cliprect.y2) {
410+
*x = m_lastX;
411+
*y = m_lastY;
412+
m_moveto = false;
413+
return agg::path_cmd_move_to;
414+
}
415+
405416
return agg::path_cmd_stop;
406417
} else {
407418
// If not doing any clipping, just pass along the vertices

0 commit comments

Comments
 (0)