Squeak Class Documentation category index | class index  
 
Rectangle
  category: Graphics-Primitives
  superclass: Object
  subclasses: CharacterBlock B3DViewport Quadrangle

I represent a rectangular area of the screen. Arithmetic functions take points as arguments and carry out scaling and translating operations to create new instances of me. Rectangle functions create new instances by determining intersections of rectangles with rectangles.

instance methods
  FMP
  deltaToEnsureInOrCentered:extra:

  accessing
  aboveCenter
area
bottom
bottom:
bottomCenter
bottomLeft
bottomRight
boundingBox
center
corner
corners
extent
height
innerCorners
left
left:
leftCenter
origin
right
right:
rightCenter
top
top:
topCenter
topLeft
topRight
width

  comparing
  =
hash
hashMappedBy:

  copying
 

  printing
  encodeForRemoteCanvas
encodeForRemoteCanvasB
encodePostscriptOn:
printOn:
propertyListOn:
storeOn:

  private
  setOrigin:corner:

  rectangle functions
  adjustTo:along:
amountToTranslateWithin:
areasOutside:
bordersOn:along:
encompass:
expandBy:
extendBy:
forPoint:closestSideDistLen:
insetBy:
insetOriginBy:cornerBy:
intersect:
merge:
outsetBy:
pointNearestTo:
quickMerge:
rectanglesAt:height:
sideNearestTo:
translatedToBeWithin:
withBottom:
withHeight:
withLeft:
withRight:
withSide:setTo:
withSideOrCorner:setToPoint:
withSideOrCorner:setToPoint:minExtent:
withSideOrCorner:setToPoint:minExtent:limit:
withTop:
withWidth:

  testing
  containsPoint:
containsRect:
hasPositiveExtent
intersects:
isTall
isWide
isZero

  transforming
  align:with:
centeredBeneath:
flipBy:centerAt:
newRectButtonPressedDo:
newRectFrom:
rotateBy:centerAt:
scaleBy:
scaleFrom:to:
squishedWithin:
translateBy:

  truncation and round off
  rounded
truncateTo:
truncated

class methods
  instance creation
  center:extent:
encompassing:
fromUser
fromUser:
left:right:top:bottom:
merging:
origin:corner:
origin:extent:
originFromUser:
originFromUser:grid:

instance methods
  FMP top  
 

deltaToEnsureInOrCentered:extra:


  accessing top  
 

aboveCenter

Answer the point slightly above the center of the receiver.


 

area

Answer the receiver's area, the product of width and height.


 

bottom

Answer the position of the receiver's bottom horizontal line.


 

bottom:


 

bottomCenter

Answer the point at the center of the bottom horizontal line of the
receiver.


 

bottomLeft

Answer the point at the left edge of the bottom horizontal line of the
receiver.


 

bottomRight

Answer the point at the right edge of the bottom horizontal line of the
receiver.


 

boundingBox


 

center

Answer the point at the center of the receiver.


 

corner

Answer the point at the bottom right corner of the receiver.


 

corners

Return an array of corner points in the order of a quadrilateral spec for WarpBlt.


 

extent

Answer with a rectangle with origin 0@0 and corner the receiver's
width @ the receiver's height.


 

height

Answer the height of the receiver.


 

innerCorners

Return an array of inner corner points,
ie, the most extreme pixels included,
in the order of a quadrilateral spec for WarpBlt


 

left

Answer the position of the receiver's left vertical line.


 

left:


 

leftCenter

Answer the point at the center of the receiver's left vertical line.


 

origin

Answer the point at the top left corner of the receiver.


 

right

Answer the position of the receiver's right vertical line.


 

right:


 

rightCenter

Answer the point at the center of the receiver's right vertical line.


 

top

Answer the position of the receiver's top horizontal line.


 

top:


 

topCenter

Answer the point at the center of the receiver's top horizontal line.


 

topLeft

Answer the point at the top left corner of the receiver's top horizontal line.


 

topRight

Answer the point at the top right corner of the receiver's top horizontal
line.


 

width

Answer the width of the receiver.


  comparing top  
 

=

Answer true if the receiver's species, origin and corner match aRectangle's.


 

hash

Hash is reimplemented because = is implemented.


 

hashMappedBy:

My hash is independent of my oop.


  copying top  

  printing top  
 

encodeForRemoteCanvas


 

encodeForRemoteCanvasB


 

encodePostscriptOn:


 

printOn:

Refer to the comment in Object|printOn:.


 

propertyListOn:

{x=a; y=b; width=c; height=d}


 

storeOn:

printed form is good for storing too


  private top  
 

setOrigin:corner:


  rectangle functions top  
 

adjustTo:along:

Return a copy adjusted to fit a neighbor that has changed size.


 

amountToTranslateWithin:

Answer a Point, delta, such that self + delta is forced within aRectangle.


 

areasOutside:

Answer an Array of Rectangles comprising the parts of the receiver not
intersecting aRectangle.


 

bordersOn:along:


 

encompass:

Answer a Rectangle that contains both the receiver and aPoint. 5/30/96 sw


 

expandBy:

Answer a Rectangle that is outset from the receiver by delta. delta is a
Rectangle, Point, or scalar.


 

extendBy:

Answer a Rectangle with the same origin as the receiver, but whose corner is offset by delta. delta is a
Rectangle, Point, or scalar.


 

forPoint:closestSideDistLen:

Evaluate the block with my side (symbol) closest to aPoint,
the approx distance of aPoint from that side, and
the length of the side (or 0 if aPoint is beyond the side)


 

insetBy:

Answer a Rectangle that is inset from the receiver by delta. delta is a
Rectangle, Point, or scalar.


 

insetOriginBy:cornerBy:

Answer a Rectangle that is inset from the receiver by a given amount in
the origin and corner.


 

intersect:

Answer a Rectangle that is the area in which the receiver overlaps with
aRectangle. Optimized for speed; old code read:
^Rectangle
origin: (origin max: aRectangle origin)
corner: (corner min: aRectangle corner)


 

merge:

Answer a Rectangle that contains both the receiver and aRectangle.


 

outsetBy:

Answer a Rectangle that is outset from the receiver by delta. delta is a
Rectangle, Point, or scalar.


 

pointNearestTo:

Return the point on my border closest to aPoint


 

quickMerge:

Answer the receiver if it encloses the given rectangle or the merge of the two rectangles if it doesn't. THis method is an optimization to reduce extra rectangle creations.


 

rectanglesAt:height:


 

sideNearestTo:


 

translatedToBeWithin:

Answer a copy of the receiver that does not extend beyond aRectangle. 7/8/96 sw


 

withBottom:

Return a copy of me with a different bottom y


 

withHeight:

Return a copy of me with a different height


 

withLeft:

Return a copy of me with a different left x


 

withRight:

Return a copy of me with a different right x


 

withSide:setTo:

return a copy with side set to value


 

withSideOrCorner:setToPoint:

Return a copy with side set to newPoint


 

withSideOrCorner:setToPoint:minExtent:

Return a copy with side set to newPoint


 

withSideOrCorner:setToPoint:minExtent:limit:

Return a copy with side set to newPoint


 

withTop:

Return a copy of me with a different top y


 

withWidth:

Return a copy of me with a different width


  testing top  
 

containsPoint:

Answer whether aPoint is within the receiver.


 

containsRect:

Answer whether aRect is within the receiver (OK to coincide).


 

hasPositiveExtent


 

intersects:

Answer whether aRectangle intersects the receiver anywhere.


 

isTall


 

isWide


 

isZero


  transforming top  
 

align:with:

Answer a Rectangle that is a translated by aPoint2 - aPoint1.


 

centeredBeneath:

Move the reciever so that its top center point coincides with the bottom center point of aRectangle. 5/20/96 sw:


 

flipBy:centerAt:

Return a copy flipped #vertical or #horizontal, about aPoint.


 

newRectButtonPressedDo:

Track the outline of a new rectangle until mouse button changes. newFrameBlock produces each new rectangle from the previous. Only tracks while mouse is down.


 

newRectFrom:

Track the outline of a new rectangle until mouse button changes.
newFrameBlock produces each new rectangle from the previous


 

rotateBy:centerAt:

Return a copy rotated #right, #left, or #pi about aPoint


 

scaleBy:

Answer a Rectangle scaled by scale, a Point or a scalar.


 

scaleFrom:to:

Produce a rectangle stretched according to the stretch from rect1 to rect2


 

squishedWithin:

Return an adjustment of the receiver that fits within aRectangle by reducing its size, not by changing its origin.


 

translateBy:

Answer a Rectangle translated by factor, a Point or a scalar.


  truncation and round off top  
 

rounded

Answer a Rectangle whose origin and corner are rounded.


 

truncateTo:

Answer a Rectangle whose origin and corner are truncated to grid x and grid y.


 

truncated

Answer a Rectangle whose origin and corner have any fractional parts removed. Answer the receiver if its coordinates are already integral.


class methods
  instance creation top  
 

center:extent:

Answer an instance of me whose center is centerPoint and width
by height is extentPoint.


 

encompassing:

A number of callers of encompass: should use this method.


 

fromUser

Answer an instance of me that is determined by having the user
designate the top left and bottom right corners. The gridding for user
selection is 1@1.


 

fromUser:

Answer a Rectangle that is determined by having the user
designate the top left and bottom right corners.
The cursor reamins linked with the sensor, but
the outline is kept gridded.


 

left:right:top:bottom:

Answer an instance of me whose left, right, top, and bottom coordinates
are determined by the arguments.


 

merging:

A number of callers of merge: should use this method.


 

origin:corner:

Answer an instance of me whose corners (top left and bottom right) are
determined by the arguments.


 

origin:extent:

Answer an instance of me whose top left corner is originPoint and width
by height is extentPoint.


 

originFromUser:

Answer an instance of me that is determined by having the user
designate the top left corner. The width and height are determined by
extentPoint. The gridding for user selection is 1@1.


 

originFromUser:grid:

Answer an instance of me that is determined by having the user
designate the top left corner. The width and height are determined by
extentPoint. The gridding for user selection is scaleFactor. Assumes that
the sender has determined an extent that is a proper multiple of
scaleFactor.