@@ -2552,7 +2552,7 @@ def _get_sawtooth_vertices(self, x0, y0, width, height, mutation_size):
25522552 else :
25532553 tooth_size = self .tooth_size * mutation_size
25542554
2555- tooth_size2 = tooth_size / 2
2555+ hsz = tooth_size / 2
25562556 width = width + 2 * pad - tooth_size
25572557 height = height + 2 * pad - tooth_size
25582558
@@ -2563,57 +2563,23 @@ def _get_sawtooth_vertices(self, x0, y0, width, height, mutation_size):
25632563 dsy_n = round ((height - tooth_size ) / (tooth_size * 2 )) * 2
25642564 dsy = (height - tooth_size ) / dsy_n
25652565
2566- x0 , y0 = x0 - pad + tooth_size2 , y0 - pad + tooth_size2
2566+ x0 , y0 = x0 - pad + hsz , y0 - pad + hsz
25672567 x1 , y1 = x0 + width , y0 + height
25682568
2569- bottom_saw_x = [
2570- x0 ,
2571- * (x0 + tooth_size2 + dsx * .5 * np .arange (dsx_n * 2 )),
2572- x1 - tooth_size2 ,
2569+ xs = [
2570+ x0 , * np .linspace (x0 + hsz , x1 - hsz , 2 * dsx_n + 1 ), # bottom
2571+ * ([x1 , x1 + hsz , x1 , x1 - hsz ] * dsy_n )[:2 * dsy_n + 2 ], # right
2572+ x1 , * np .linspace (x1 - hsz , x0 + hsz , 2 * dsx_n + 1 ), # top
2573+ * ([x0 , x0 - hsz , x0 , x0 + hsz ] * dsy_n )[:2 * dsy_n + 2 ], # left
25732574 ]
2574- bottom_saw_y = [
2575- y0 ,
2576- * ([y0 - tooth_size2 , y0 , y0 + tooth_size2 , y0 ] * dsx_n ),
2577- y0 - tooth_size2 ,
2575+ ys = [
2576+ * ([y0 , y0 - hsz , y0 , y0 + hsz ] * dsx_n )[:2 * dsx_n + 2 ], # bottom
2577+ y0 , * np .linspace (y0 + hsz , y1 - hsz , 2 * dsy_n + 1 ), # right
2578+ * ([y1 , y1 + hsz , y1 , y1 - hsz ] * dsx_n )[:2 * dsx_n + 2 ], # top
2579+ y1 , * np .linspace (y1 - hsz , y0 + hsz , 2 * dsy_n + 1 ), # left
25782580 ]
2579- right_saw_x = [
2580- x1 ,
2581- * ([x1 + tooth_size2 , x1 , x1 - tooth_size2 , x1 ] * dsx_n ),
2582- x1 + tooth_size2 ,
2583- ]
2584- right_saw_y = [
2585- y0 ,
2586- * (y0 + tooth_size2 + dsy * .5 * np .arange (dsy_n * 2 )),
2587- y1 - tooth_size2 ,
2588- ]
2589- top_saw_x = [
2590- x1 ,
2591- * (x1 - tooth_size2 - dsx * .5 * np .arange (dsx_n * 2 )),
2592- x0 + tooth_size2 ,
2593- ]
2594- top_saw_y = [
2595- y1 ,
2596- * ([y1 + tooth_size2 , y1 , y1 - tooth_size2 , y1 ] * dsx_n ),
2597- y1 + tooth_size2 ,
2598- ]
2599- left_saw_x = [
2600- x0 ,
2601- * ([x0 - tooth_size2 , x0 , x0 + tooth_size2 , x0 ] * dsy_n ),
2602- x0 - tooth_size2 ,
2603- ]
2604- left_saw_y = [
2605- y1 ,
2606- * (y1 - tooth_size2 - dsy * .5 * np .arange (dsy_n * 2 )),
2607- y0 + tooth_size2 ,
2608- ]
2609-
2610- saw_vertices = [* zip (bottom_saw_x , bottom_saw_y ),
2611- * zip (right_saw_x , right_saw_y ),
2612- * zip (top_saw_x , top_saw_y ),
2613- * zip (left_saw_x , left_saw_y ),
2614- (bottom_saw_x [0 ], bottom_saw_y [0 ])]
26152581
2616- return saw_vertices
2582+ return [ * zip ( xs , ys ), ( xs [ 0 ], ys [ 0 ])]
26172583
26182584 def __call__ (self , x0 , y0 , width , height , mutation_size ):
26192585 saw_vertices = self ._get_sawtooth_vertices (x0 , y0 , width ,
0 commit comments