Every bounded region has a derived bounding rectangle, which is a rectangular region whose sides are parallel to the coordinate axes. Therefore, every bounded region participates in the bounding rectangle protocol. The bounding rectangle for a region is the smallest rectangle that contains every point in the region. However, the bounding rectangle may contain additional points as well. Unbounded regions do not have a bounding rectangle and do not participate in the bounding rectangle protocol. Other objects besides bounded regions participate in the bounding rectangle protocol, such as sheets and output records. [annotate]
[bounding rectangle, Concept← A Glossary]
[bounding rectangle, Concept← 4.1 Bounding Rectangles, bounding-rectangle-p]
The coordinate system in which the bounding rectangle is maintained depends on the context. For example, the coordinates of the bounding rectangle of a sheet are expressed in the sheet's parent's coordinate system. For output records, the coordinates of the bounding rectangle are maintained in the coordinate system of the stream with which the output record is associated. [annotate]
Note that the bounding rectangle of a transformed region is not in general the same as the result of transforming the bounding rectangle of a region, as shown in Figure 4.1. For transformations that satisfy rectilinear-transformation-p, the following equality holds. For all other transformations, it does not hold. [annotate]
(region-equal (transform-region transformation (bounding-rectangle region)) (bounding-rectangle (transform-region transformation region)))
CLIM uses bounding rectangles for a variety of purposes. For example, repainting of windows is driven from the bounding rectangle of the window's viewport, intersected with a "damage" region. The formatting engines used by formatting-table and formatting-graph operate on the bounding rectangles of the output records in the output. Bounding rectangles are also used internally by CLIM to achieve greater efficiency. For instance, when performing hit detection to see if the pointer is within the region of an output record, CLIM first checks to see if the pointer is within the bounding rectangle of the output record. [annotate]
Note that the bounding rectangle for an output record may have a different size depending on the medium on which the output record is rendered. Consider the case of rendering text on different output devices; the font chosen for a particular text style may vary considerably in size from one device to another. [annotate]
The protocol class that represents a bounding rectangle. If you want to create a new class that behaves like a bounding rectangle, it should be a subclass of bounding-rectangle. All instantiable subclasses of bounding-rectangle must obey the bounding rectangle protocol. [annotate] Note that bounding rectangles are not a subclass of rectangle, nor even a subclass of region. This is because, in general, bounding rectangles do not obey the region protocols. However, all bounded regions and sheets that obey the bounding rectangle protocol are subclasses of bounding-rectangle. [annotate] Bounding rectangles are immutable, but since they reflect the live state of such mutable objects as sheets and output records, bounding rectangles are volatile. Therefore, programmers must not depend on the bounding rectangle associated with a mutable object remaining constant. [annotate] [← A Glossary] [← 16.2 Output Records, displayed-output-record] [← 16.2 Output Records, output-record] [← 4.1.2 Bounding Rectangle Convenience Functions] [← 4.1 Bounding Rectangles, standard-bounding-rectangle] [← 3.2.1 Points, point] [← 3.1.2 Region Composition Protocol, region-set] [← 3.1 General Regions, coordinate] [← 3.1 General Regions, area] [← 3.1 General Regions, path] |
Returns true if object is a bounding rectangle (that is, supports the bounding rectangle protocol), otherwise returns false. [annotate] |
An instantiable class that implements a bounding rectangle. This is a subclass of both bounding-rectangle and rectangle, that is, standard bounding rectangles obey the rectangle protocol. [annotate] make-bounding-rectangle returns an object of this class. [annotate] The representation of bounding rectangles in CLIM is chosen to be efficient. CLIM will probably represent such rectangles by storing the coordinates of two opposing corners of the rectangle, namely, the "min point" and the "max point". Because this representation is not sufficient to represent the result of arbitrary transformations of arbitrary rectangles, CLIM is allowed to return a polygon as the result of such a transformation. (The most general class of transformations that is guaranteed to always turn a rectangle into another rectangle is the class of transformations that satisfy rectilinear-transformation-p.) [annotate] |
Returns an object of the class standard-bounding-rectangle with the edges specified by x1, y1, x2, and y2, which must be real numbers. [annotate] x1, y1, x2, and y2 are "canonicalized" in the following way. The min point of the rectangle has an x coordinate that is the smaller of x1 and x2 and a y coordinate that is the smaller of y1 and y2. The max point of the rectangle has an x coordinate that is the larger of x1 and x2 and a y coordinate that is the larger of y1 and y2. (Therefore, in a right-handed coordinate system the canonicalized values of x1, y1, x2, and y2 correspond to the left, top, right, and bottom edges of the rectangle, respectively.) [annotate] This function returns fresh objects that may be modified. [annotate] |
The following generic function comprises the bounding rectangle protocol. All classes that participate in this protocol (including all subclasses of region that are bounded regions) must implement a method for bounding-rectangle*. [annotate]
Returns the bounding rectangle of region as four real numbers specifying the x and y coordinates of the min point and the x and y coordinates of the max point of the rectangle. The argument region must be either a bounded region (such as a line or an ellipse) or some other object that obeys the bounding rectangle protocol, such as a sheet or an output record. [annotate] The four returned values min-x, min-y, max-x, and max-y will satisfy the inequalities
[← 16.2.1 The Basic Output Record Protocol, output-record-hit-detection-rectangle*] [← 4.1.2 Bounding Rectangle Convenience Functions, with-bounding-rectangle*] [← 4.1.2 Bounding Rectangle Convenience Functions] [← 4.1.1 The Bounding Rectangle Protocol, bounding-rectangle] [← 4.1.1 The Bounding Rectangle Protocol] |
Returns the bounding rectangle of region as an object that is a subclass of rectangle (described in Section 3.2.4). The argument region must be either a bounded region (such as a line or an ellipse) or some other object that obeys the bounding rectangle protocol, such as a sheet or an output record. [annotate] It is unspecified whether bounding-rectangle will or will not create a new object each time it is called. Many CLIM implementations will cache the bounding rectangle for sheets and output records. The implication of this is that, since bounding rectangles are volatile, programmers should depend on the object returned by bounding-rectangle remaining constant. [annotate] Note: is there a missing "not" here? "... programmers should not depend on the object returned by bounding-rectangle remaining constant." [edit]-- Christophe Rhodes 2006-02-27 10:52Z bounding-rectangle is part of the bounding rectangle API, but not part of the bounding rectangle protocol. CLIM will supply a default method for bounding-rectangle on the protocol class bounding-rectangle that is implemented by calling bounding-rectangle*. [annotate] [← A Glossary] [← 16.2 Output Records, displayed-output-record] [← 16.2 Output Records, output-record] [← 4.1.2 Bounding Rectangle Convenience Functions] [← 4.1 Bounding Rectangles, standard-bounding-rectangle] [← 3.2.1 Points, point] [← 3.1.2 Region Composition Protocol, region-set] [← 3.1 General Regions, coordinate] [← 3.1 General Regions, area] [← 3.1 General Regions, path] |
The functions described below are part of the bounding rectangle API, but are not part of the bounding rectangle protocol. They are provided as a convenience to programmers who wish to specialize classes that participate in the bounding rectangle protocol, but do not complicate the task of those programmers who define their own types (such as sheet classes) that participate in this protocol. [annotate]
CLIM will supply default methods for all of these generic functions on the protocol class bounding-rectangle that are implemented by calling bounding-rectangle*. [annotate]
Binds min-x, min-y, max-x, and max-y to the edges of the bounding rectangle of region, and then executes body in that context. The argument region must be either a bounded region (such as a line or an ellipse) or some other object that obeys the bounding rectangle protocol, such as a sheet or an output record. [annotate] The arguments min-x, min-y, max-x, and max-y are not evaluated. body may have zero or more declarations as its first forms. [annotate] with-bounding-rectangle* must be implemented by calling bounding-rectangle*. [annotate] |
Returns the position of the bounding rectangle of region. The position of a bounding rectangle is specified by its min point. [annotate] |
bounding-rectangle-min-x | region | [Generic Function] |
bounding-rectangle-min-y | region | [Generic Function] |
bounding-rectangle-max-x | region | [Generic Function] |
bounding-rectangle-max-y | region | [Generic Function] |
Returns (respectively) the x and y coordinates of the min point and the x and y coordinate of the max point of the bounding rectangle of region. The argument region must be either a bounded region or some other object that obeys the bounding rectangle protocol. [annotate] |
bounding-rectangle-width | region | [Generic Function] |
bounding-rectangle-height | region | [Generic Function] |
bounding-rectangle-size | region | [Generic Function] |
Returns the width, height, or size (as two values, the width and height) of the bounding rectangle of region, respectively. The argument region must be either a bounded region or some other object that obeys the bounding rectangle protocol. [annotate] The width of a bounding rectangle is the difference between its maximum x coordinate and its minimum x coordinate. The height is the difference between the maximum y coordinate and its minimum y coordinate. [annotate] |