@@ -1818,33 +1818,45 @@ def __init__(self, pad=0.3):
18181818 super (BoxStyle .Square , self ).__init__ ()
18191819
18201820 def transmute (self , x0 , y0 , width , height , mutation_size ):
1821-
1822- # padding
18231821 pad = mutation_size * self .pad
18241822
18251823 # width and height with padding added.
1826- width , height = width + 2. * pad , \
1827- height + 2. * pad ,
1824+ width , height = width + 2 * pad , height + 2 * pad
18281825
18291826 # boundary of the padded box
18301827 x0 , y0 = x0 - pad , y0 - pad ,
18311828 x1 , y1 = x0 + width , y0 + height
18321829
1833- cp = [(x0 , y0 ), (x1 , y0 ), (x1 , y1 ), (x0 , y1 ),
1834- (x0 , y0 ), (x0 , y0 )]
1830+ vertices = [(x0 , y0 ), (x1 , y0 ), (x1 , y1 ), (x0 , y1 ), (x0 , y0 )]
1831+ codes = [Path .MOVETO ] + [Path .LINETO ] * 3 + [Path .CLOSEPOLY ]
1832+ return Path (vertices , codes )
18351833
1836- com = [Path .MOVETO ,
1837- Path .LINETO ,
1838- Path .LINETO ,
1839- Path .LINETO ,
1840- Path .LINETO ,
1841- Path .CLOSEPOLY ]
1834+ _style_list ["square" ] = Square
18421835
1843- path = Path (cp , com )
18441836
1845- return path
1837+ class Circle (_Base ):
1838+ """A simple circle box."""
1839+ def __init__ (self , pad = 0.3 ):
1840+ """
1841+ Parameters
1842+ ----------
1843+ pad : float
1844+ The amount of padding around the original box.
1845+ """
1846+ self .pad = pad
1847+ super (BoxStyle .Circle , self ).__init__ ()
1848+
1849+ def transmute (self , x0 , y0 , width , height , mutation_size ):
1850+ pad = mutation_size * self .pad
1851+ width , height = width + 2 * pad , height + 2 * pad
1852+
1853+ # boundary of the padded box
1854+ x0 , y0 = x0 - pad , y0 - pad ,
1855+ return Path .circle ((x0 + width / 2. , y0 + height / 2. ),
1856+ (max ([width , height ]) / 2. ))
1857+
1858+ _style_list ["circle" ] = Circle
18461859
1847- _style_list ["square" ] = Square
18481860
18491861 class LArrow (_Base ):
18501862 """
@@ -2130,16 +2142,13 @@ def transmute(self, x0, y0, width, height, mutation_size):
21302142
21312143 saw_vertices = self ._get_sawtooth_vertices (x0 , y0 , width ,
21322144 height , mutation_size )
2133- path = Path (saw_vertices )
2145+ path = Path (saw_vertices , closed = True )
21342146 return path
21352147
21362148 _style_list ["sawtooth" ] = Sawtooth
21372149
21382150 class Roundtooth (Sawtooth ):
2139- """
2140- A roundtooth(?) box.
2141- """
2142-
2151+ """A rounded tooth box."""
21432152 def __init__ (self , pad = 0.3 , tooth_size = None ):
21442153 """
21452154 *pad*
@@ -2151,16 +2160,14 @@ def __init__(self, pad=0.3, tooth_size=None):
21512160 super (BoxStyle .Roundtooth , self ).__init__ (pad , tooth_size )
21522161
21532162 def transmute (self , x0 , y0 , width , height , mutation_size ):
2154-
21552163 saw_vertices = self ._get_sawtooth_vertices (x0 , y0 ,
21562164 width , height ,
21572165 mutation_size )
2158-
2159- cp = [Path .MOVETO ] + ([Path .CURVE3 , Path .CURVE3 ]
2160- * ((len (saw_vertices ) - 1 ) // 2 ))
2161- path = Path (saw_vertices , cp )
2162-
2163- return path
2166+ saw_vertices = np .concatenate ([np .array (saw_vertices ), [saw_vertices [0 ]]], axis = 0 )
2167+ cp = ([Path .MOVETO ] +
2168+ [Path .CURVE3 , Path .CURVE3 ] * ((len (saw_vertices ) - 1 ) // 2 ) +
2169+ [Path .CLOSEPOLY ])
2170+ return Path (saw_vertices , cp )
21642171
21652172 _style_list ["roundtooth" ] = Roundtooth
21662173
0 commit comments