@@ -1098,17 +1098,14 @@ def _update_offset_func(self, renderer, fontsize=None):
10981098 """
10991099 if fontsize is None :
11001100 fontsize = renderer .points_to_pixels (
1101- self .prop .get_size_in_points ())
1101+ self .prop .get_size_in_points ())
11021102
1103- def _offset (w , h , xd , yd , renderer , fontsize = fontsize , self = self ):
1103+ def _offset (w , h , xd , yd , renderer ):
11041104 bbox = Bbox .from_bounds (0 , 0 , w , h )
11051105 borderpad = self .borderpad * fontsize
11061106 bbox_to_anchor = self .get_bbox_to_anchor ()
1107-
1108- x0 , y0 = self ._get_anchored_bbox (self .loc ,
1109- bbox ,
1110- bbox_to_anchor ,
1111- borderpad )
1107+ x0 , y0 = _get_anchored_bbox (
1108+ self .loc , bbox , bbox_to_anchor , borderpad )
11121109 return x0 + xd , y0 + yd
11131110
11141111 self .set_offset (_offset )
@@ -1139,31 +1136,18 @@ def draw(self, renderer):
11391136 self .get_child ().draw (renderer )
11401137 self .stale = False
11411138
1142- def _get_anchored_bbox (self , loc , bbox , parentbbox , borderpad ):
1143- """
1144- Return the position of the bbox anchored at the parentbbox
1145- with the loc code, with the borderpad.
1146- """
1147- assert loc in range (1 , 11 ) # called only internally
1148-
1149- BEST , UR , UL , LL , LR , R , CL , CR , LC , UC , C = range (11 )
11501139
1151- anchor_coefs = {UR : "NE" ,
1152- UL : "NW" ,
1153- LL : "SW" ,
1154- LR : "SE" ,
1155- R : "E" ,
1156- CL : "W" ,
1157- CR : "E" ,
1158- LC : "S" ,
1159- UC : "N" ,
1160- C : "C" }
1161-
1162- c = anchor_coefs [loc ]
1163-
1164- container = parentbbox .padded (- borderpad )
1165- anchored_box = bbox .anchored (c , container = container )
1166- return anchored_box .x0 , anchored_box .y0
1140+ def _get_anchored_bbox (loc , bbox , parentbbox , borderpad ):
1141+ """
1142+ Return the (x, y) position of the *bbox* anchored at the *parentbbox* with
1143+ the *loc* code with the *borderpad*.
1144+ """
1145+ # This is only called internally and *loc* should already have been
1146+ # validated. If 0 (None), we just let ``bbox.anchored`` raise.
1147+ c = [None , "NE" , "NW" , "SW" , "SE" , "E" , "W" , "E" , "S" , "N" , "C" ][loc ]
1148+ container = parentbbox .padded (- borderpad )
1149+ anchored_box = bbox .anchored (c , container = container )
1150+ return anchored_box .x0 , anchored_box .y0
11671151
11681152
11691153class AnchoredText (AnchoredOffsetbox ):
0 commit comments