! Point methodsFor: #VSE2S8Geometry-arithmetic !
abs
"Answer a Point with coordinates that are the absolute
value of the x and y coordinates of the receiver."
^x abs @ y abs! !
! Point methodsFor: #VSE2S8Geometry-arithmetic !
between: aPoint and: bPoint
"Answer true if the receiver is greater than or equal to
aPoint and less than or equal to aPoint, else
answer false."
^aPoint <= self
and: [self <= bPoint]! !
! Point methodsFor: #VSE2S8Geometry-converting !
corner: aPoint
"Answer a Rectangle with origin equal to the receiver
and corner equal to aPoint."
^Rectangle origin: self corner: aPoint! !
! Point methodsFor: #VSE2S8Geometry-converting !
extentFromLeftBottom: aNumber
"Answer a Rectangle whose origin is the receiver
at the bottom-left corner and extent is aPoint."
^Rectangle
leftTop: (self x @ (self y up: aPoint y))
rightBottom: ((self x right: aPoint x) @ self y)! !
! Number methodsFor: #VSE2S8Geometry-arithmetic !
up: aNumber
"Answer the location up aNumber of positions from
the receiver."
^self - aNumber! !
! Point methodsFor: #VSE2S8Geometry-converting !
extentFromLeftTop: aPoint
"Answer a Rectangle with left top corner equal to the receiver
and extent equal to aPoint."
^Rectangle
leftTop: self
rightBottom: (self rightAndDown: aPoint)! !
! Point methodsFor: #VSE2S8Geometry-testing !
isPoint
"Answer true if receiver is a kind of Point."
^true! !
! Object methodsFor: #VSE2S8Geometry-testing !
isPoint
"Answer true if receiver is a kind of Point."
^false! !
! Point methodsFor: #VSE2S8Geometry-arithmetic !
negated
"Answer a Point with the x and y coordinates of
the receiver negated."
^x negated @ y negated ! !
! Point methodsFor: #VSE2S8Geometry-converting !
rightTop: aPoint
"Answer a Rectangle with left bottom equal to the receiver
and right top equal to aPoint."
^Rectangle leftBottom: self rightTop: aPoint! !
! Rectangle class methodsFor: #VSE2S8Geometry-instantiation !
leftBottom: leftBottomPoint rightTop: rightTopPoint
"Answer a Rectangle with leftBottom and rightTop points
described by leftBottomPoint and rightTopPoint."
^self new leftBottom: leftBottomPoint rightTop: rightTopPoint! !
! Rectangle class methodsFor: #VSE2S8Geometry-instantiation !
origin: originPoint corner: cornerPoint
"Answer a Rectangle with origin and corner points
described by originPoint and cornerPoint."
^self new origin: originPoint corner: cornerPoint ! !
! Rectangle methodsFor: #VSE2S8Geometry-accesing !
leftBottom: leftBottomPoint rightTop: rightTopPoint
"Change the receiver to match leftBottomPoint
and rightTopPoint."
leftTop := leftBottomPoint x @ rightTopPoint y.
rightBottom := rightTopPoint x @ leftBottomPoint y! !
! Rectangle methodsFor: #VSE2S8Geometry-accessing !
leftTop: leftTop extent: extent
"Change the receiver's top left corner to
leftTopPoint and its extent to extentPoint."
^self leftTop: leftTop rightBottom: leftTop + extent! !
! Rectangle methodsFor: #VSE2S8Geometry-accesing !
origin: originPoint corner: cornerPoint
"Change the receiver's top left corner to
originPoint and its bottom right corner to
cornerPoint."
self leftTop: originPoint rightBottom: cornerPoint ! !