@@ -95,10 +95,10 @@ def __init__(self, vertices=[], fill_color='auto',
9595 stroke_color = 'auto' , stroke_weight = "auto" ,
9696 stroke_join = "auto" , stroke_cap = "auto" ,
9797 visible = False , attribs = 'closed' ,
98- children = None , contour = None ):
98+ children = None , contour = [] ):
9999 # basic properties of the shape
100100 self ._vertices = np .array ([])
101- self .contour = contour or np .array ([])
101+ self ._contour = np .array ([])
102102 self ._edges = None
103103 self ._outline = None
104104 self ._outline_vertices = None
@@ -129,6 +129,9 @@ def __init__(self, vertices=[], fill_color='auto',
129129 if len (vertices ) > 0 :
130130 self .vertices = vertices
131131
132+ if len (contour ) > 0 :
133+ self .contour = contour
134+
132135 self .fill = fill_color
133136 self .stroke = stroke_color
134137 self .stroke_weight = stroke_weight
@@ -271,6 +274,14 @@ def vertices(self, new_vertices):
271274 self ._tri_edges = None
272275 self ._tri_faces = None
273276
277+ @property
278+ def contour (self ):
279+ return self ._contour
280+
281+ @contour .setter
282+ def contour (self , contour_vertices ):
283+ self ._contour = np .array (contour_vertices )
284+
274285 def _compute_poly_edges (self ):
275286 n , _ = self ._vertices .shape
276287 return np .vstack ([np .arange (n ), (np .arange (n ) + 1 ) % n ]).transpose ()
@@ -324,13 +335,13 @@ def _retriangulate(self):
324335 self ._tri_vertices = self .vertices
325336 return
326337
327- if len (self .contour ) > 1 :
328- n , _ = self .contour .shape
338+ if len (self ._contour ) > 1 :
339+ n , _ = self ._contour .shape
329340 contour_edges = np .vstack ([np .arange (n ), (np .arange (n ) + 1 ) % n ]).transpose ()
330- triangulation_vertices = np .vstack ([self .vertices , self .contour ])
341+ triangulation_vertices = np .vstack ([self .vertices , self ._contour ])
331342 triangulation_segments = np .vstack ([self .edges , contour_edges + len (self .edges )])
332343 triangulate_parameters = dict (vertices = triangulation_vertices ,
333- segments = triangulation_segments , holes = self .get_interior_point (self .contour ))
344+ segments = triangulation_segments , holes = self .get_interior_point (self ._contour ))
334345
335346 self ._tri = tr .triangulate (triangulate_parameters , "p" )
336347 else :
0 commit comments