Rectangle.st
changeset 4864 3ff21a7f977d
parent 4863 9544c9e5c17e
child 4868 339707d6cc2a
--- a/Rectangle.st	Thu Oct 07 01:36:05 1999 +0200
+++ b/Rectangle.st	Thu Oct 07 01:45:37 1999 +0200
@@ -86,6 +86,25 @@
     "Created: / 28.1.1998 / 17:46:52 / cg"
 !
 
+encompassing:listOfPoints
+    "Return a rectangle, which encompasses all of the given points."
+
+    |topLeft bottomRight|
+
+    topLeft := bottomRight := nil.
+    listOfPoints do:[:p | 
+        topLeft == nil
+            ifTrue: [topLeft := bottomRight := p]
+            ifFalse: [topLeft := topLeft min: p.
+                      bottomRight := bottomRight max: p]
+    ].
+    ^ topLeft corner: bottomRight
+
+    "
+     Rectangle encompassing:(Array with:10@10 with:50@0 with:0@50)
+    "
+!
+
 fromUser
     "let user specify a rectangle on the screen, return it"
 
@@ -1161,6 +1180,15 @@
 "/    ^collect
 !
 
+encompass:aPoint 
+    "return a Rectangle that contains both the receiver and aPoint."
+
+    ^ Rectangle 
+        origin: (self origin min: aPoint)
+        corner: (self corner max: aPoint)
+
+!
+
 expandedBy:delta
     "return a new rectangle which is expanded in all directions
      by amount, a Point, Rectangle or Number"
@@ -1620,5 +1648,5 @@
 !Rectangle class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Rectangle.st,v 1.62 1999-10-06 23:36:05 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Rectangle.st,v 1.63 1999-10-06 23:45:37 cg Exp $'
 ! !