File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -330,6 +330,7 @@ def make_compound_path(cls, *args):
330330 if not args :
331331 return Path (np .empty ([0 , 2 ], dtype = np .float32 ))
332332
333+ # concatenate paths
333334 vertices = np .concatenate ([x .vertices for x in args ])
334335 codes = np .empty (len (vertices ), dtype = cls .code_type )
335336 i = 0
@@ -341,6 +342,16 @@ def make_compound_path(cls, *args):
341342 codes [i :i + len (path .codes )] = path .codes
342343 i += len (path .vertices )
343344
345+ # remove internal STOP's, replace kinal stop if present
346+ last_vert = None
347+ if codes .size > 0 and codes [- 1 ] == cls .STOP :
348+ last_vert = vertices [- 1 ]
349+ vertices = vertices [codes != cls .STOP , :]
350+ codes = codes [codes != cls .STOP ]
351+ if last_vert is not None :
352+ vertices = np .append (vertices , [last_vert ], axis = 0 )
353+ codes = np .append (codes , cls .STOP )
354+
344355 return cls (vertices , codes )
345356
346357 def __repr__ (self ):
Original file line number Diff line number Diff line change @@ -147,6 +147,13 @@ def test_make_compound_path_empty():
147147 assert r .vertices .shape == (0 , 2 )
148148
149149
150+ def test_make_compound_path_stops ():
151+ zero = [0 , 0 ]
152+ paths = 3 * [Path ([zero , zero ], [Path .MOVETO , Path .STOP ])]
153+ compound_path = Path .make_compound_path (* paths )
154+ assert np .sum (compound_path .codes == Path .STOP ) == 1
155+
156+
150157@image_comparison (['xkcd.png' ], remove_text = True )
151158def test_xkcd ():
152159 np .random .seed (0 )
You can’t perform that action at this time.
0 commit comments