Category: Language-Data types
Superclass: Object
Beginning of the Rectangle class for simple display manipulation. Rectangles require the Point class to be available. An extension to the Point class is made here that since it requires Rectangles to be defined (see converting)

Method category index

instance creation (class)
accessing (instance)
copying (instance)
printing (instance)
rectangle functions (instance)
testing (instance)
transforming (instance)
truncation and round off (instance)

instance creation (class)

left: leftNumber right: rightNumber top: topNumber bottom: bottomNumber
Answer a rectangle with the given coordinates

left: leftNumber top: topNumber right: rightNumber bottom: bottomNumber

Answer a rectangle with the given coordinates

new

Answer the (0 @ 0 corner: 0 @ 0) rectangle

origin: originPoint corner: cornerPoint

Answer a rectangle with the given corners

origin: originPoint extent: extentPoint

Answer a rectangle with the given origin and size

top


accessing (instance)

bottom
Answer the corner's y of the receiver

bottom: aNumber

Set the corner's y of the receiver

bottomCenter

Answer the center of the receiver's bottom side

bottomLeft

Answer the bottom-left corner of the receiver

bottomLeft: aPoint

Answer the receiver with the bottom-left changed to aPoint

bottomRight

Answer the bottom-right corner of the receiver

bottomRight: aPoint

Change the bottom-right corner of the receiver

center

Answer the center of the receiver

corner

Answer the corner of the receiver

corner: aPoint

Set the corner of the receiver

extent

Answer the extent of the receiver

extent: aPoint

Change the size of the receiver, keeping the origin the same

height

Answer the height of the receiver

height: aNumber

Set the height of the receiver

left

Answer the x of the left edge of the receiver

left: aValue

Set the x of the left edge of the receiver

left: l top: t right: r bottom: b

Change all four the coordinates of the receiver's corners

leftCenter

Answer the center of the receiver's left side

origin

Answer the top-left corner of the receiver

origin: aPoint

Change the top-left corner of the receiver to aPoint

origin: pnt1 corner: pnt2

Change both the origin (top-left corner) and the corner (bottom-right corner) of the receiver

origin: pnt1 extent: pnt2

Change the top-left corner and the size of the receiver

right

Answer the x of the bottom-right corner of the receiver

right: aNumber

Change the x of the bottom-right corner of the receiver

rightCenter

Answer the center of the receiver's right side

top

Answer the y of the receiver's top-left corner

top: aValue

Change the y of the receiver's top-left corner

topCenter

Answer the center of the receiver's top side

topLeft

Answer the receiver's top-left corner

topLeft: aPoint

Change the receiver's top-left corner's coordinates to aPoint

topRight

Answer the receiver's top-right corner

topRight: aPoint

Change the receiver's top-right corner to aPoint

width

Answer the receiver's width

width: aNumber

Change the receiver's width to aNumber

top


copying (instance)

copy
Return a deep copy of the receiver for safety.

top


printing (instance)

printOn: aStream
Print a representation of the receiver on aStream

storeOn: aStream

Store Smalltalk code compiling to the receiver on aStream

top


rectangle functions (instance)

amountToTranslateWithin: aRectangle
Answer a Point so that if aRectangle is translated by that point, its origin lies within the receiver's.

area

Answer the receiver's area. The area is the width times the height, so it is possible for it to be negative if the rectangle is not normalized.

areasOutside: aRectangle

Answer a collection of rectangles containing the parts of the receiver outside of aRectangle. For all points in the receiver, but outside aRectangle, exactly one rectangle in the collection will contain that point.

expandBy: delta

Answer a new rectangle that is the receiver expanded by aValue: if aValue is a rectangle, calculate origin=origin-aValue origin, corner=corner+aValue corner; else calculate origin=origin-aValue, corner=corner+aValue.

insetBy: delta

Answer a new rectangle that is the receiver inset by aValue: if aValue is a rectangle, calculate origin=origin+aValue origin, corner=corner-aValue corner; else calculate origin=origin+aValue, corner=corner-aValue.

insetOriginBy: originDelta corner: cornerDelta

Answer a new rectangle that is the receiver inset so that origin=origin+originDelta, corner=corner-cornerDelta. The deltas can be points or numbers

intersect: aRectangle

Answers the rectangle (if any) created by the overlap of rectangles A and B. Answers nil if the rectangles do not overlap

merge: aRectangle

Answer a new rectangle which is the smallest rectangle containing both the receiver and aRectangle.

translatedToBeWithin: aRectangle

Answer a copy of the receiver that does not extend beyond aRectangle.

top


testing (instance)

= aRectangle
Answer whether the receiver is equal to aRectangle

contains: aRectangle

Answer true if the receiver contains (see containsPoint:) both aRectangle's origin and aRectangle's corner

containsPoint: aPoint

Answer true if aPoint is equal to, or below and to the right of, the receiver's origin; and aPoint is above and to the left of the receiver's corner

hash

Answer an hash value for the receiver

intersects: aRectangle

Answer true if the receiver intersect aRectangle, i.e. if it contains (see containsPoint:) any of aRectangle corners or if aRectangle contains the receiver

top


transforming (instance)

moveBy: aPoint
Change the receiver so that the origin and corner are shifted by aPoint

moveTo: aPoint

Change the receiver so that the origin moves to aPoint and the size remains unchanged

scaleBy: scale

Answer a copy of the receiver in which the origin and corner are multiplied by scale

translateBy: factor

Answer a copy of the receiver in which the origin and corner are shifted by aPoint

top


truncation and round off (instance)

rounded
Answer a copy of the receiver with the coordinates rounded to the nearest integers

top