@@ -251,22 +251,19 @@ def __handle_curve(
251
251
return curve_points [:, 0 ], curve_points [:, 1 ], center
252
252
253
253
def __get_essential_info (self , shape , width , color , trans ):
254
- if width is None :
255
- width = self .__get_width (shape )
256
- if color is None :
257
- color = self .__get_color (shape )
258
- color = np .clip (color , 0 , 1 )
259
- if trans is None :
260
- trans = self .__get_transparency (shape )
261
- return width , color , trans
254
+ w = self .__get_width (shape , width )
255
+ c = self .__get_color (shape , color )
256
+ c = np .clip (c , 0 , 1 )
257
+ t = self .__get_transparency (shape , trans )
258
+ return w , c , t
262
259
263
- def __get_width (self , shape ):
260
+ def __get_width (self , shape , width : float ):
264
261
try :
265
262
return shape ["width" ]
266
263
except Exception :
267
- return 1.8
264
+ return 1.8 if width is None else width
268
265
269
- def __get_color (self , shape ):
266
+ def __get_color (self , shape , color ):
270
267
try :
271
268
return shape ["color" ]
272
269
except Exception :
@@ -276,19 +273,22 @@ def __get_color(self, shape):
276
273
else :
277
274
return (1 , 1 , 1 , 1 )
278
275
except Exception :
279
- return (random .random (), random .random (), random .random ())
276
+ return (random .random (), random .random (), random .random ()) if color is None else color
280
277
281
- def __get_transparency (self , shape ):
278
+ def __get_transparency (self , shape , trans ):
282
279
try :
283
280
if shape ["fill_mode" ] == "no" :
284
- trans = (0 , 0 , 0 , 0 )
281
+ return (0 , 0 , 0 , 0 )
285
282
elif shape ["fill_mode" ] == "white" :
286
- trans = (1 , 1 , 1 , 1 )
283
+ return (1 , 1 , 1 , 1 )
287
284
elif shape ["fill_mode" ] == "black" :
288
- trans = (0 , 0 , 0 , 1 )
285
+ return (0 , 0 , 0 , 1 )
286
+ elif shape ["fill_mode" ] == "border" :
287
+ return (0 , 0 , 0 , 0 )
288
+ else :
289
+ raise Exception ("Invalid fill_mode arg" )
289
290
except Exception :
290
- trans = (0 , 0 , 0 , 0 ) # no
291
- return trans
291
+ return trans if trans is not None else (0 , 0 , 0 , 0 )
292
292
293
293
def transfer_to_cv2_wrapper (self ):
294
294
buf2 = BytesIO ()
0 commit comments