@@ -1835,7 +1835,7 @@ def __init__(self, ax, onselect, useblit=False, button=None,
18351835 eventpress = _api .deprecate_privatize_attribute ("3.5" )
18361836 eventrelease = _api .deprecate_privatize_attribute ("3.5" )
18371837 state = _api .deprecate_privatize_attribute ("3.5" )
1838- state_modifier_keys = _api .deprecate_privatize_attribute ("3.5 " )
1838+ state_modifier_keys = _api .deprecate_privatize_attribute ("3.6 " )
18391839
18401840 def set_active (self , active ):
18411841 super ().set_active (active )
@@ -2803,7 +2803,8 @@ def onselect(eclick: MouseEvent, erelease: MouseEvent)
28032803 - "clear": Clear the current shape, default: "escape".
28042804 - "square": Make the shape square, default: "shift".
28052805 - "center": change the shape around its center, default: "ctrl".
2806- - "rotate": Rotate the shape around its center, default: "r".
2806+ - "rotate": Rotate the shape around its center between -45° and 45°,
2807+ default: "r".
28072808
28082809 "square" and "center" can be combined. The square shape can be defined
28092810 in data or figure coordinates as determined by the
@@ -3061,7 +3062,8 @@ def _onmove(self, event):
30613062 eventpress = self ._eventpress
30623063 # The calculations are done for rotation at zero: we apply inverse
30633064 # transformation to events except when we rotate and move
3064- if not (self ._active_handle == 'C' or rotate ):
3065+ move = self ._active_handle == 'C'
3066+ if not move and not rotate :
30653067 inv_tr = self ._get_rotation_transform ().inverted ()
30663068 event .xdata , event .ydata = inv_tr .transform (
30673069 [event .xdata , event .ydata ])
@@ -3078,8 +3080,8 @@ def _onmove(self, event):
30783080 refx , refy = dx , dy
30793081 else :
30803082 # Add 1e-6 to avoid divided by zero error
3081- refx = event .xdata / (eventpress .xdata + 1e -6 )
3082- refy = event .ydata / (eventpress .ydata + 1e -6 )
3083+ refx = event .xdata / (eventpress .xdata or 1E -6 )
3084+ refy = event .ydata / (eventpress .ydata or 1E -6 )
30833085
30843086 x0 , x1 , y0 , y1 = self ._extents_on_press
30853087 # rotate an existing shape
@@ -3099,6 +3101,7 @@ def _onmove(self, event):
30993101
31003102 # Keeping the center fixed
31013103 if 'center' in state :
3104+ # hh, hw are half-height and half-width
31023105 if 'square' in state :
31033106 # when using a corner, find which reference to use
31043107 if self ._active_handle in self ._corner_order :
@@ -3277,14 +3280,17 @@ def extents(self, extents):
32773280
32783281 @property
32793282 def rotation (self ):
3280- """Rotation in degree in interval [0, 45]."""
3283+ """
3284+ Rotation in degree in interval [-45°, 45°]. The rotation is limited in
3285+ range to keep the implementation simple.
3286+ """
32813287 return np .rad2deg (self ._rotation )
32823288
32833289 @rotation .setter
32843290 def rotation (self , value ):
3285- # Restrict to a limited range of rotation [0 , 45] to avoid changing
3291+ # Restrict to a limited range of rotation [-45° , 45° ] to avoid changing
32863292 # order of handles
3287- if 0 <= value and value <= 45 :
3293+ if - 45 <= value and value <= 45 :
32883294 self ._rotation = np .deg2rad (value )
32893295 # call extents setter to draw shape and update handles positions
32903296 self .extents = self .extents
0 commit comments