@@ -189,6 +189,31 @@ def onselect(epress, erelease):
189189 tool ._corner_handles .artist .get_markeredgecolor (), 'b' )
190190
191191
192+ def test_rectangle_rotate ():
193+ ax = get_ax ()
194+
195+ def onselect (epress , erelease ):
196+ pass
197+
198+ tool = widgets .RectangleSelector (ax , onselect = onselect , interactive = True )
199+ # Draw rectangle
200+ do_event (tool , 'press' , xdata = 100 , ydata = 100 )
201+ do_event (tool , 'onmove' , xdata = 130 , ydata = 140 )
202+ do_event (tool , 'release' , xdata = 130 , ydata = 140 )
203+ assert tool .extents == (100 , 130 , 100 , 140 )
204+
205+ # Rotate by 45 degrees anticlockwise
206+ do_event (tool , 'press' , xdata = 130 , ydata = 140 , key = 'r' )
207+ do_event (tool , 'onmove' , xdata = 100 , ydata = 150 , key = 'r' )
208+ do_event (tool , 'release' , xdata = 100 , ydata = 200 , key = 'r' )
209+ # Extents shouldn't change (as shape of rectangle hasn't changed)
210+ assert tool .extents == (100 , 130 , 100 , 140 )
211+ # Corners should move
212+ # The third corner is at (100, 150), as the diagonal of the rectangle has
213+ # length 50
214+ assert tool .corners == ((100 , 124 , 100 , 76 ), (100 , 118 , 150 , 132 ))
215+
216+
192217def check_span (* args , ** kwargs ):
193218 ax = get_ax ()
194219
0 commit comments