Skip to content

Commit 1002995

Browse files
committed
Merged revisions 8636 via svnmerge from
https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v1_0_maint ........ r8636 | mdboom | 2010-08-16 15:56:27 -0400 (Mon, 16 Aug 2010) | 4 lines Add explicit "CLOSEPOLY" codes to unit_rectangle, unit_polygon, unit_star and unit_asterisk. Not doing so causes the strokes to have the wrong end cap at the beginning/end point. ........ svn path=/trunk/matplotlib/; revision=8637
1 parent e0d35e4 commit 1002995

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

lib/matplotlib/path.py

+15-4
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,8 @@ def unit_rectangle(cls):
384384
"""
385385
if cls._unit_rectangle is None:
386386
cls._unit_rectangle = \
387-
cls([[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0], [0.0, 0.0]])
387+
cls([[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0], [0.0, 0.0]],
388+
[cls.MOVETO, cls.LINETO, cls.LINETO, cls.LINETO, cls.CLOSEPOLY])
388389
return cls._unit_rectangle
389390

390391
_unit_regular_polygons = WeakValueDictionary()
@@ -407,8 +408,13 @@ def unit_regular_polygon(cls, numVertices):
407408
# "points-up"
408409
theta += np.pi / 2.0
409410
verts = np.concatenate((np.cos(theta), np.sin(theta)), 1)
410-
path = cls(verts)
411-
cls._unit_regular_polygons[numVertices] = path
411+
codes = np.empty((numVertices,))
412+
codes[0] = cls.MOVETO
413+
codes[1:-1] = cls.LINETO
414+
codes[-1] = cls.CLOSEPOLY
415+
path = cls(verts, codes)
416+
if numVertices <= 16:
417+
cls._unit_regular_polygons[numVertices] = path
412418
return path
413419

414420
_unit_regular_stars = WeakValueDictionary()
@@ -433,8 +439,13 @@ def unit_regular_star(cls, numVertices, innerCircle=0.5):
433439
r = np.ones(ns2 + 1)
434440
r[1::2] = innerCircle
435441
verts = np.vstack((r*np.cos(theta), r*np.sin(theta))).transpose()
442+
codes = np.empty((ns2,))
443+
codes[0] = cls.MOVETO
444+
codes[1:-1] = cls.LINETO
445+
codes[-1] = cls.CLOSEPOLY
436446
path = cls(verts)
437-
cls._unit_regular_polygons[(numVertices, innerCircle)] = path
447+
if numVertices <= 16:
448+
cls._unit_regular_polygons[(numVertices, innerCircle)] = path
438449
return path
439450

440451
@classmethod

0 commit comments

Comments
 (0)