more examples & comments
authorClaus Gittinger <cg@exept.de>
Thu, 09 May 1996 01:09:18 +0200
changeset 289 c4a61914a9a0
parent 288 5d79dc613999
child 290 f4fbe0881e1b
more examples & comments
Circle.st
Curve.st
EllArc.st
EllipticalArc.st
Spline.st
--- a/Circle.st	Thu May 09 00:08:18 1996 +0200
+++ b/Circle.st	Thu May 09 01:09:18 1996 +0200
@@ -45,6 +45,108 @@
         EllipticalArc Spline Curve Polygon Rectangle
         GraphicsContext
 "
+!
+
+examples
+"
+  circle; filled and unfilled:
+                                                                        [exBegin]
+    |v c|
+
+    v := (View extent:200@100) openAndWait.
+
+    c := Circle boundingBox:(10@10 corner:90@90). 
+
+    v paint:Color blue.
+    c displayFilledOn:v.
+
+    c center:150@50.
+    v paint:Color red.
+    c displayStrokedOn:v.
+
+                                                                        [exEnd]
+  circle & rectangle; both filled:
+                                                                        [exBegin]
+    |v c|
+
+    v := (View extent:100@100) openAndWait.
+
+    c := Circle center:50@50 radius:40. 
+
+    v paint:Color red.
+    c asRectangle displayFilledOn:v.
+
+    v paint:Color blue.
+    c displayFilledOn:v.
+
+                                                                        [exEnd]
+  circles; filled & unfilled:
+                                                                        [exBegin]
+    |v c|
+
+    v := View new openAndWait.
+
+    c := Circle center:50@50 radius:40.
+
+    v paint:Color red.
+    c displayFilledOn:v.
+    50 to:1 by:-1 do:[:r |
+        c radius:r.
+        v paint:(Color grey:(r * 2)).
+        c displayStrokedOn:v.
+    ].
+    1 to:50 do:[:r |
+        c radius:r.
+        v paint:(Color grey:100-(r * 2)).
+        c displayStrokedOn:v.
+    ]
+
+                                                                        [exEnd]
+  more arcs; filled:
+                                                                        [exBegin]
+    |v ell|
+
+    v := View new openAndWait.
+
+    ell := EllipticalArc
+                boundingBox:(10@10 corner:90@90) 
+                startAngle:0
+                sweepAngle:0.
+
+    #(45 90 135 180 225 270 315 360) 
+    keysAndValuesReverseDo:[:index :angle |
+        index odd ifTrue:[
+            v paint:Color white
+        ] ifFalse:[
+            v paint:Color black
+        ].
+        ell sweepAngle:angle.
+        ell displayFilledOn:v.
+        Delay waitForSeconds:0.1.
+    ].
+
+                                                                        [exEnd]
+  more arcs; filled:
+                                                                        [exBegin]
+    |v ell|
+
+    v := View new openAndWait.
+
+    ell := EllipticalArc
+                boundingBox:(10@10 corner:90@90) 
+                startAngle:0
+                sweepAngle:45.
+
+    #(45 90 135 180 225 270 315 360) 
+    with:#( 0.125 0.25 0.375 0.5 0.625 0.75 0.875 1)
+    do:[:angle :grey |
+        ell startAngle:angle-45.
+        v paint:(ColorValue red:grey green:0 blue:0).
+        ell displayFilledOn:v.
+    ].
+
+                                                                        [exEnd]
+"
 ! !
 
 !Circle class methodsFor:'instance creation'!
@@ -170,5 +272,5 @@
 !Circle class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/Circle.st,v 1.9 1996-05-08 19:32:02 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/Circle.st,v 1.10 1996-05-08 23:09:18 cg Exp $'
 ! !
--- a/Curve.st	Thu May 09 00:08:18 1996 +0200
+++ b/Curve.st	Thu May 09 01:09:18 1996 +0200
@@ -146,28 +146,46 @@
     "Created: 8.5.1996 / 21:09:40 / cg"
 ! !
 
+!Curve methodsFor:'converting'!
+
+asPointArray
+    "return an array containing my points."
+
+    ^ Array with:startPoint with:middlePoint with:endPoint
+
+    "Created: 9.5.1996 / 01:07:07 / cg"
+!
+
+asPolygon
+    "return a polygon, approximating the spline"
+
+    ^ Polygon vertices:(self computeLineSegments)
+
+    "Created: 9.5.1996 / 01:08:12 / cg"
+! !
+
 !Curve methodsFor:'displaying'!
 
 displayFilledOn:aGC
     "draw the receiver as a filled curve in a graphicsContext, aGC"
 
-    aGC fillPolygon:self computeLines
+    aGC fillPolygon:self computeLineSegments
 
     "Created: 8.5.1996 / 21:24:15 / cg"
-    "Modified: 8.5.1996 / 21:25:33 / cg"
+    "Modified: 9.5.1996 / 01:08:34 / cg"
 !
 
 displayStrokedOn:aGC
     "draw the receiver as a unfilled curve in a graphicsContext, aGC"
 
-    aGC displayPolygon:self computeLines
+    aGC displayPolygon:self computeLineSegments
 
-    "Modified: 8.5.1996 / 21:25:35 / cg"
+    "Modified: 9.5.1996 / 01:08:36 / cg"
 ! !
 
 !Curve methodsFor:'helpers'!
 
-computeLines
+computeLineSegments
     "compute the lines which approxiamte this curve"
 
     |lines pa pb 
@@ -192,7 +210,7 @@
 
     ^ lines
 
-    "Created: 8.5.1996 / 21:23:29 / cg"
+    "Created: 9.5.1996 / 01:08:21 / cg"
 ! !
 
 !Curve methodsFor:'queries'!
@@ -217,5 +235,5 @@
 !Curve class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/Curve.st,v 1.1 1996-05-08 19:33:53 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/Curve.st,v 1.2 1996-05-08 23:09:05 cg Exp $'
 ! !
--- a/EllArc.st	Thu May 09 00:08:18 1996 +0200
+++ b/EllArc.st	Thu May 09 01:09:18 1996 +0200
@@ -47,6 +47,91 @@
         GraphicsContext
         StrokingWrapper FillingWrapper
 "
+!
+
+examples
+"
+  ellipses; filled & unfilled:
+                                                                        [exBegin]
+    |v e|
+
+    v := (View extent:200@100) openAndWait.
+
+    e := EllipticalArc 
+            boundingBox:(10@10 corner:190@90)
+            startAngle:0
+            endAngle:360. 
+
+    v paint:Color blue.
+    e displayFilledOn:v.
+
+    v paint:Color red.
+    e displayStrokedOn:v.
+
+                                                                        [exEnd]
+  elliptical arcs; filled & unfilled:
+                                                                        [exBegin]
+    |v e|
+
+    v := (View extent:200@100) openAndWait.
+
+    e := EllipticalArc 
+            boundingBox:(10@10 corner:190@90)
+            startAngle:0
+            endAngle:270. 
+
+    v paint:Color blue.
+    e displayFilledOn:v.
+
+    v paint:Color red.
+    e displayStrokedOn:v.
+
+                                                                        [exEnd]
+  more arcs; filled:
+                                                                        [exBegin]
+    |v ell|
+
+    v := View new openAndWait.
+
+    ell := EllipticalArc
+                boundingBox:(10@10 corner:90@90) 
+                startAngle:0
+                sweepAngle:0.
+
+    #(45 90 135 180 225 270 315 360) 
+    keysAndValuesReverseDo:[:index :angle |
+        index odd ifTrue:[
+            v paint:Color white
+        ] ifFalse:[
+            v paint:Color black
+        ].
+        ell sweepAngle:angle.
+        ell displayFilledOn:v.
+        Delay waitForSeconds:0.1.
+    ].
+
+                                                                        [exEnd]
+  more arcs; filled:
+                                                                        [exBegin]
+    |v ell|
+
+    v := View new openAndWait.
+
+    ell := EllipticalArc
+                boundingBox:(10@10 corner:90@90) 
+                startAngle:0
+                sweepAngle:45.
+
+    #(45 90 135 180 225 270 315 360) 
+    with:#( 0.125 0.25 0.375 0.5 0.625 0.75 0.875 1)
+    do:[:angle :grey |
+        ell startAngle:angle-45.
+        v paint:(ColorValue red:grey green:0 blue:0).
+        ell displayFilledOn:v.
+    ].
+
+                                                                        [exEnd]
+"
 ! !
 
 !EllipticalArc class methodsFor:'instance creation'!
@@ -179,5 +264,5 @@
 !EllipticalArc class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/Attic/EllArc.st,v 1.8 1996-05-08 22:08:18 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/Attic/EllArc.st,v 1.9 1996-05-08 23:09:14 cg Exp $'
 ! !
--- a/EllipticalArc.st	Thu May 09 00:08:18 1996 +0200
+++ b/EllipticalArc.st	Thu May 09 01:09:18 1996 +0200
@@ -47,6 +47,91 @@
         GraphicsContext
         StrokingWrapper FillingWrapper
 "
+!
+
+examples
+"
+  ellipses; filled & unfilled:
+                                                                        [exBegin]
+    |v e|
+
+    v := (View extent:200@100) openAndWait.
+
+    e := EllipticalArc 
+            boundingBox:(10@10 corner:190@90)
+            startAngle:0
+            endAngle:360. 
+
+    v paint:Color blue.
+    e displayFilledOn:v.
+
+    v paint:Color red.
+    e displayStrokedOn:v.
+
+                                                                        [exEnd]
+  elliptical arcs; filled & unfilled:
+                                                                        [exBegin]
+    |v e|
+
+    v := (View extent:200@100) openAndWait.
+
+    e := EllipticalArc 
+            boundingBox:(10@10 corner:190@90)
+            startAngle:0
+            endAngle:270. 
+
+    v paint:Color blue.
+    e displayFilledOn:v.
+
+    v paint:Color red.
+    e displayStrokedOn:v.
+
+                                                                        [exEnd]
+  more arcs; filled:
+                                                                        [exBegin]
+    |v ell|
+
+    v := View new openAndWait.
+
+    ell := EllipticalArc
+                boundingBox:(10@10 corner:90@90) 
+                startAngle:0
+                sweepAngle:0.
+
+    #(45 90 135 180 225 270 315 360) 
+    keysAndValuesReverseDo:[:index :angle |
+        index odd ifTrue:[
+            v paint:Color white
+        ] ifFalse:[
+            v paint:Color black
+        ].
+        ell sweepAngle:angle.
+        ell displayFilledOn:v.
+        Delay waitForSeconds:0.1.
+    ].
+
+                                                                        [exEnd]
+  more arcs; filled:
+                                                                        [exBegin]
+    |v ell|
+
+    v := View new openAndWait.
+
+    ell := EllipticalArc
+                boundingBox:(10@10 corner:90@90) 
+                startAngle:0
+                sweepAngle:45.
+
+    #(45 90 135 180 225 270 315 360) 
+    with:#( 0.125 0.25 0.375 0.5 0.625 0.75 0.875 1)
+    do:[:angle :grey |
+        ell startAngle:angle-45.
+        v paint:(ColorValue red:grey green:0 blue:0).
+        ell displayFilledOn:v.
+    ].
+
+                                                                        [exEnd]
+"
 ! !
 
 !EllipticalArc class methodsFor:'instance creation'!
@@ -179,5 +264,5 @@
 !EllipticalArc class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/EllipticalArc.st,v 1.8 1996-05-08 22:08:18 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/EllipticalArc.st,v 1.9 1996-05-08 23:09:14 cg Exp $'
 ! !
--- a/Spline.st	Thu May 09 00:08:18 1996 +0200
+++ b/Spline.st	Thu May 09 01:09:18 1996 +0200
@@ -67,7 +67,8 @@
     Both open and closed curves are possible.
 
     [see also:]
-        Polygon LineSegment Circle EllipticalArc Rectangle Curve
+        Polygon LineSegment Circle EllipticalArc 
+        Rectangle Curve
         GraphicsContext
 
     [author:]
@@ -514,5 +515,5 @@
 !Spline class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/Spline.st,v 1.6 1996-05-08 19:31:53 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/Spline.st,v 1.7 1996-05-08 23:09:10 cg Exp $'
 ! !