Back: ReadWriteStream-positioning
Up: Class reference
Forward: Rectangle class-instance creation
 
Top: GNU Smalltalk User's Guide
Contents: Table of Contents
Index: Class index
About: About this document

6.120 Rectangle

Defined in namespace Smalltalk
Category: Language-Data types
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)

6.120.1 Rectangle class: instance creation  (class)
6.120.2 Rectangle: accessing  (instance)
6.120.3 Rectangle: copying  (instance)
6.120.4 Rectangle: printing  (instance)
6.120.5 Rectangle: rectangle functions  (instance)
6.120.6 Rectangle: testing  (instance)
6.120.7 Rectangle: transforming  (instance)
6.120.8 Rectangle: truncation and round off  (instance)


6.120.1 Rectangle class: instance creation

left: leftNumber right: rightNumber top: topNumber 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


6.120.2 Rectangle: accessing

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


6.120.3 Rectangle: copying

copy
Return a deep copy of the receiver for safety.


6.120.4 Rectangle: printing

printOn: aStream
Print a representation of the receiver on aStream

storeOn: aStream
Store Smalltalk code compiling to the receiver on aStream


6.120.5 Rectangle: rectangle functions

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
Returns the rectangle (if any) created by the overlap of rectangles A and B.

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.


6.120.6 Rectangle: testing

= 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


6.120.7 Rectangle: transforming

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


6.120.8 Rectangle: truncation and round off

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




This document was generated on May, 12 2002 using texi2html