Point.st
changeset 5006 8a211e38846d
parent 4984 e20cd6bdc182
child 5322 411b6c0f7250
--- a/Point.st	Thu Nov 18 21:11:11 1999 +0100
+++ b/Point.st	Thu Nov 18 21:19:39 1999 +0100
@@ -224,6 +224,15 @@
 
 !Point methodsFor:'Compatibility - Squeak'!
 
+adhereTo: aRectangle
+    "If the receiver lies outside aRectangle, return the nearest point on the boundary of the rectangle, otherwise return self."
+
+    (aRectangle containsPoint: self) ifTrue: [^ self].
+    ^ ((x max: aRectangle left) min: aRectangle right)
+      @
+      ((y max: aRectangle top) min: aRectangle bottom)
+!
+
 asFloatPoint
     "Squeak mimicri return the receiver as Point - this is the receiver"
 
@@ -1052,6 +1061,6 @@
 !Point class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Point.st,v 1.52 1999-11-13 11:12:12 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Point.st,v 1.53 1999-11-18 20:19:39 cg Exp $'
 ! !
 Point initialize!