rbbox

Purpose

Rubberband box for region selection.

Synopsis

rbbox(rect,xy)

Description

rbbox(rect,xy) initializes and tracks a rubberband box in the current figure. It initially displays a rubberband box described by rect, which has the form

rect = ([x1  y1  width  height])
where (x1,y1) is the lower-left corner of the rectangle and width and height define the rectangle size.

rbbox starts tracking at the point xy, where xy has the form

xy = ([xstart  ystart])
All measurements are in pixels, with the origin at the lower-left corner of the figure window.

The mouse button must be down when rbbox is called. The corner of the rectangle closest to the xy point follows the cursor when the user drags the mouse. The function returns when the mouse button is released.

To determine the extent of the rectangle, use the figure's CurrentPoint property. If p is the figure's CurrentPoint prior to calling rbbox, and q is the figure's CurrentPoint when rbbox returns, then

[min(p,q), abs(p-q)]
is the extent of the user-defined rectangle.

rbbox is useful in M-files, along with waitforbuttonpress, to control dynamic behavior. Typical uses for rbbox include:

  • Box resizing. In this case, rect defines the initial rectangle which the user must resize, and xy corresponds to one of the corners of the rectangle.
  • Box definition. In this case, rect is defined as
    [x y 0 0]
    
    where (x,y) is equal to the initial point xy.

    (c) Copyright 1994 by The MathWorks, Inc.