@@ -95,10 +95,10 @@ def __init__(self, vertices=[], fill_color='auto',
95
95
stroke_color = 'auto' , stroke_weight = "auto" ,
96
96
stroke_join = "auto" , stroke_cap = "auto" ,
97
97
visible = False , attribs = 'closed' ,
98
- children = None , contour = None ):
98
+ children = None , contour = [] ):
99
99
# basic properties of the shape
100
100
self ._vertices = np .array ([])
101
- self .contour = contour or np .array ([])
101
+ self ._contour = np .array ([])
102
102
self ._edges = None
103
103
self ._outline = None
104
104
self ._outline_vertices = None
@@ -129,6 +129,9 @@ def __init__(self, vertices=[], fill_color='auto',
129
129
if len (vertices ) > 0 :
130
130
self .vertices = vertices
131
131
132
+ if len (contour ) > 0 :
133
+ self .contour = contour
134
+
132
135
self .fill = fill_color
133
136
self .stroke = stroke_color
134
137
self .stroke_weight = stroke_weight
@@ -271,6 +274,14 @@ def vertices(self, new_vertices):
271
274
self ._tri_edges = None
272
275
self ._tri_faces = None
273
276
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
+
274
285
def _compute_poly_edges (self ):
275
286
n , _ = self ._vertices .shape
276
287
return np .vstack ([np .arange (n ), (np .arange (n ) + 1 ) % n ]).transpose ()
@@ -324,13 +335,13 @@ def _retriangulate(self):
324
335
self ._tri_vertices = self .vertices
325
336
return
326
337
327
- if len (self .contour ) > 1 :
328
- n , _ = self .contour .shape
338
+ if len (self ._contour ) > 1 :
339
+ n , _ = self ._contour .shape
329
340
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 ])
331
342
triangulation_segments = np .vstack ([self .edges , contour_edges + len (self .edges )])
332
343
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 ))
334
345
335
346
self ._tri = tr .triangulate (triangulate_parameters , "p" )
336
347
else :
0 commit comments