doku
authorClaus Gittinger <cg@exept.de>
Wed, 08 May 1996 20:17:08 +0200
changeset 280 126dfc9dc409
parent 279 cb9df1c2f620
child 281 344857a33c20
doku
Polygon.st
Spline.st
--- a/Polygon.st	Wed May 08 19:54:31 1996 +0200
+++ b/Polygon.st	Wed May 08 20:17:08 1996 +0200
@@ -44,30 +44,90 @@
         Claus Gittinger
 
     [see also:]
-        Point Polygon
+        Rectangle EllipticalArc Spline Point 
+"
+!
+
+examples
+"
+  simple polygon; filled & unfilled:
+                                                                        [exBegin]
+    |v p|
+
+    v := (View extent:200@200) openAndWait.
+
+    p := Polygon vertices:
+                (Array with:(10@10)
+                       with:(90@90)
+                       with:(10@90)).
+
+    v scale:2.
+    v paint:Color blue.
+    p displayFilledOn:v.
+
+    v paint:Color red.
+    p displayStrokedOn:v.
+
+    v scale:1; translation:100@0.
+    v paint:Color green.
+    p displayFilledOn:v.
+
+    v paint:Color black.
+    p displayStrokedOn:v.
+                                                                        [exEnd]
+
+  arbitrary polygon; filled & unfilled:
+                                                                        [exBegin]
+    |v p|
+
+    v := (View extent:200@200) openAndWait.
+    v scale:2.
+
+    p := Polygon vertices:
+                (Array with:(10@10)
+                       with:(90@90)
+                       with:(50@90)
+                       with:(90@10)
+                       with:(10@90)
+                                   ).
+
+    v paint:Color blue.
+    p displayFilledOn:v.
+
+    v paint:Color red.
+    p displayStrokedOn:v.
+                                                                        [exEnd]
 "
 ! !
 
 !Polygon class methodsFor:'instance creation'!
 
 fromRectangle:aRectangle
-    ^ self new vertices:(aRectangle asArrayOfPoints)
+    "return a new polygon, taking the rectangles vertices"
+
+    ^ self new vertices:(aRectangle asPointArray)
 
     "
      Polygon fromRectangle:(50@50 corner:100@100)
     "
+
+    "Modified: 8.5.1996 / 20:15:18 / cg"
 !
 
 vertices:anArrayOfPoints
+    "return a new polygon, given a collection of vertices"
+
     ^ self new vertices:anArrayOfPoints
 
     "
      Polygon vertices:(Array with:10@10
-			     with:20@20
-			     with:30@30)
+                             with:20@20
+                             with:30@30)
 
      Polygon vertices:(#(10 10  100 0  50 50) pairWiseCollect:[:x :y | x @ y])
     "
+
+    "Modified: 8.5.1996 / 20:11:31 / cg"
 ! !
 
 !Polygon methodsFor:'accessing'!
@@ -330,5 +390,5 @@
 !Polygon class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/Polygon.st,v 1.18 1996-05-08 12:46:09 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/Polygon.st,v 1.19 1996-05-08 18:17:03 cg Exp $'
 ! !
--- a/Spline.st	Wed May 08 19:54:31 1996 +0200
+++ b/Spline.st	Wed May 08 20:17:08 1996 +0200
@@ -63,7 +63,8 @@
 documentation
 "
     Spline defines a path that includes an arbitrary collection of points 
-    connected by a third order curve.
+    connected by a third order curve. The curve passes through all controlPoints.
+    Both open and closed curves are possible.
 
     [see also:]
         Polygon Circle EllipticalArc
@@ -76,6 +77,66 @@
 
 examples
 "
+  open spline; filled & unfilled:
+                                                                        [exBegin]
+    |v s|
+
+    v := (View extent:100@100) openAndWait.
+
+    s := Spline controlPoints:
+                (Array with:(20@20)
+                       with:(80@80)
+                       with:(20@80)).
+
+    v paint:Color blue.
+    s displayFilledOn:v.
+
+    v paint:Color red.
+    s displayStrokedOn:v.
+                                                                        [exEnd]
+
+  closed spline; filled & unfilled:
+                                                                        [exBegin]
+    |v s|
+
+    v := (View extent:100@100) openAndWait.
+
+    s := Spline controlPoints:
+                (Array with:(20@20)
+                       with:(80@80)
+                       with:(20@80)
+                       with:(20@20)).
+
+    v paint:Color blue.
+    s displayFilledOn:v.
+
+    v paint:Color red.
+    s displayStrokedOn:v.
+                                                                        [exEnd]
+
+  spiral:
+                                                                        [exBegin]
+    |v points s|
+
+    v := View extent:(200 @ 200).
+
+    v openAndWait.
+
+    points := OrderedCollection new.
+    90 to:10 by:-10 do:[:r |
+        0 to:330 by:30 do:[:angle |
+            |d|
+
+            d := (angle / 360) * 10.
+            points add:(Point r:r-d angle:angle) + (100@100)
+        ].
+    ].
+    s := Spline controlPoints:points.
+
+    v paint:Color red.
+    s displayStrokedOn:v.
+                                                                        [exEnd]
+  interactive example:
                                                                         [exBegin]
     |v points eventCatcher|
 
@@ -141,12 +202,21 @@
 
 !Spline methodsFor:'converting'!
 
-asPolyline
+asPolygon
     "return a polygon, approximating the spline"
 
     ^ Polygon vertices:(self computeLineSegments)
 
+    "Created: 8.5.1996 / 20:15:37 / cg"
+!
+
+asPolyline
+    "same as #asPolygon - for ST-80 compatibility"
+
+    ^ self asPolygon
+
     "Created: 8.5.1996 / 18:49:42 / cg"
+    "Modified: 8.5.1996 / 20:15:59 / cg"
 ! !
 
 !Spline methodsFor:'displaying'!
@@ -434,5 +504,5 @@
 !Spline class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/Spline.st,v 1.2 1996-05-08 17:54:31 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/Spline.st,v 1.3 1996-05-08 18:17:08 cg Exp $'
 ! !