added containspoint
authorclaus
Mon, 21 Nov 1994 17:39:12 +0100
changeset 208 43741b9068a0
parent 207 f23d19288832
child 209 ecc004f196e6
added containspoint
Rectangle.st
--- a/Rectangle.st	Mon Nov 21 17:39:04 1994 +0100
+++ b/Rectangle.st	Mon Nov 21 17:39:12 1994 +0100
@@ -21,7 +21,7 @@
 COPYRIGHT (c) 1989 by Claus Gittinger
 	      All Rights Reserved
 
-$Header: /cvs/stx/stx/libbasic/Rectangle.st,v 1.11 1994-10-28 01:29:04 claus Exp $
+$Header: /cvs/stx/stx/libbasic/Rectangle.st,v 1.12 1994-11-21 16:39:12 claus Exp $
 '!
 
 !Rectangle class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libbasic/Rectangle.st,v 1.11 1994-10-28 01:29:04 claus Exp $
+$Header: /cvs/stx/stx/libbasic/Rectangle.st,v 1.12 1994-11-21 16:39:12 claus Exp $
 "
 !
 
@@ -469,6 +469,19 @@
     ^ true
 !
 
+containsPointX:x y:y
+    "return true, if the point defined by x@y is contained in the receiver.
+     This is the same as containsPoint:, but can be used if the coordinates
+     are already available as separate numbers to avoid useless creation of a
+     temporary point."
+
+    (x < left)           ifTrue:[^ false].
+    (x > (left + width)) ifTrue:[^ false].
+    (y < top)            ifTrue:[^ false].
+    (y > (top + height)) ifTrue:[^ false].
+    ^ true
+!
+
 intersects:aRectangle
     "return true, if the intersection between the argument, aRectangle
      and the receiver is not empty"
@@ -612,6 +625,14 @@
 	       right:((left + width) min:(aRectangle right))
 		 top:(top max:(aRectangle top))
 	      bottom:((top + height) min:(aRectangle bottom))
+
+    "
+     |r1 r2|
+
+     r1 := Rectangle origin:10@10 corner:100@100.
+     r2 := Rectangle origin:50@50 corner:150@75.
+     r1 intersect:r2
+    "
 !
 
 merge:aRectangle