|
Class: EllipticalArc
Object
|
+--Geometric
|
+--EllipticalArc
|
+--EllipticalPieSlice
- Package:
- stx:libbasic2
- Category:
- Graphics-Geometry-Objects
- Version:
- rev:
1.23
date: 2022/02/17 10:25:32
- user: cg
- file: EllipticalArc.st directory: libbasic2
- module: stx stc-classLibrary: libbasic2
This class implements an ellipse which is aligned to x and y axes
given a boundingBox, a startAngle and a sweepAngle.
Positive angles are taken clockwise, negative angles are counterclockwise.
If the boundingBox is a square, the result is a circular arc.
If it is rotated, the result will be aproximated as a polygon.
If drawn as outline, only the path along the circle is drawn;
if drawn filled, only the area between the circle and the line from start
to end are drawn.
copyrightCOPYRIGHT (c) 1995 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
instance creation
-
boundingBox: aRectangle
-
Return a new elliptical arc (circular, if boundingBox is square).
-
boundingBox: aRectangle startAngle: startAngle endAngle: endAngle
-
Return a new elliptical arc (circular, if boundingBox is square).
The angles may be floats or integer - they are given in degrees.
Positive angles are taken clockwise, negative angles are counterclockwise.
-
boundingBox: aRectangle startAngle: startAngle sweepAngle: sweepAngle
-
Return a new elliptical arc (circular, if boundingBox is square).
The angles may be floats or integer - they are given in degrees.
Positive angles are taken clockwise, negative angles are counterclockwise.
-
center: centerPoint radius: radius
-
Return a circlular arc.
-
center: centerPoint radius: radius startAngle: startAngle endAngle: endAngle
-
Return a new (circular) arc.
The angles may be floats or integer - they are given in degrees.
Positive angles are taken clockwise, negative angles are counterclockwise.
-
center: centerPoint radius: radius startAngle: startAngle sweepAngle: sweepAngle
-
Return a new (circular) arc.
The angles may be floats or integer - they are given in degrees.
Positive angles are taken clockwise, negative angles are counterclockwise.
-
center: centerPoint radiusX: radiusX radiusY: radiusY startAngle: startAngle endAngle: endAngle
-
Return a new (elliptical) arc.
The angles may be floats or integer - they are given in degrees.
Positive angles are taken clockwise, negative angles are counterclockwise.
-
center: centerPoint radiusX: radiusX radiusY: radiusY startAngle: startAngle sweepAngle: sweepAngle
-
Return a new elliptical arc.
The angles may be floats or integer - they are given in degrees.
Positive angles are taken clockwise, negative angles are counterclockwise.
accessing
-
boundingBox: aRectangle
-
setup the arc, given a bounding rectangle
-
boundingBox: aRectangle startAngle: start sweepAngle: sweep
-
setup the arc, given a bounding rectangle, start and endAngle.
The angles may be floats or integer - they are given in degrees.
Positive angles are taken clockwise, negative angles are counterclockwise.
-
center: centerPoint radius: radius
-
setup for a circular arc, given center and radius
-
center: centerPoint radiusX: radiusX radiusY: radiusY
-
setup for an elliptical arc, given center and radius in x and y direction
-
endAngle
-
return the endAngle.
The angles may be floats or integer - they are given in degrees.
Positive angles are taken clockwise, negative angles are counterclockwise.
-
startAngle
-
return the startAngle.
The angle may be float or integer - it is given in degrees.
Positive angles are taken clockwise, negative angles are counterclockwise.
-
startAngle: angle
-
set the startAngle.
The angle may be float or integer - it is given in degrees.
Positive angles are taken clockwise, negative angles are counterclockwise.
-
sweepAngle
-
return the sweepAngle.
The angle may be float or integer - it is given in degrees.
Positive angles are taken clockwise, negative angles are counterclockwise.
-
sweepAngle: angle
-
set the sweepAngle.
The angle may be float or integer - it is given in degrees.
Positive angles are taken clockwise, negative angles are counterclockwise.
converting
-
asEllipticalArc
-
convert the receiver into an ellipticalArc - that's the receiver itself
-
asPolygon
-
convert the receiver into a polygon which approximates the arc
-
computeVertices
-
compute vertices for drawing
displaying
-
displayFilledOn: aGC
-
(comment from inherited method)
display myself filled on a graphicsContext; the current graphics
attributes are used. Since we do not know how to do it, nothing is
drawn here.
-
displayStrokedOn: aGC
-
draw the receiver as a unfilled arc in a graphicsContext, aGC
-
vertices
-
queries
-
center
-
return the center
-
computeBounds
-
return the smallest enclosing rectangle
testing
-
canBeFilled
-
return true, if the receiver can be drawn as a filled geometric.
Always true here.
transforming
-
rotatedBy: angle about: rotationCenter
-
return a copy of the receiver, which is rotated around rotationCenter
by an angle (radians) around rotationCenter (which may be located outside);
the angle is interpreted as counter-clockwise (same as in Point >> rotatedBy:)
-
roundedToNearestIntegerPoint
-
return a copy of the receiver, where all points are rounded to ly on the nearest integer coordinate
-
transformedBy: aMatrix
-
return a copy of the receiver, which is transformed using aMatrix;
for any transformation which shears or rotates to non-axis aligned bounding box,
a polygon which approximates the arc is returned.
Usage example(s):
bbx := boundingBox transformedBy:aMatrix.
|
Usage example(s):
((Point r:1 theta:(360-startAngle) degreesToRadians) transformedBy:aMatrix) theta radiansToDegrees.
|
-
translatedBy: amount
-
return a copy of the receiver which is translated (i.e. moved)
by amount, aPoint or Number
ellipses; filled & unfilled:
|v e1 e2 p1 p2|
v := (View extent:400@300) openAndWaitUntilVisible.
v paint:Color red.
v translation:100@100.
v displayLineFrom:-100@0 to:100@0.
v displayLineFrom:0@-100 to:0@100.
e1 := EllipticalArc
center:0@0 radius:30
startAngle:0
endAngle:180.
v paint:Color blue.
e1 displayOn:v.
e2 := e1 rotatedBy:90 degreesToRadians about:0@0.
v paint:Color cyan.
e2 displayOn:v.
p1 := e1 asPolygon.
v paint:Color green darkened.
p1 displayOn:v.
p2 := p1 rotatedBy:90 degreesToRadians about:0@0.
v paint:Color red.
p2 displayOn:v.
e2 := e1 rotatedBy:-90 degreesToRadians about:e1 center.
v paint:Color green darkened.
e2 displayOn:v.
|
|v e1 e2 p1 p2|
v := (View extent:400@300) openAndWaitUntilVisible.
v paint:Color red.
v translation:100@100.
v displayLineFrom:-100@0 to:100@0.
v displayLineFrom:0@-100 to:0@100.
e1 := EllipticalArc
center:50@50 radius:30
startAngle:0
endAngle:180.
v paint:Color blue.
e1 displayOn:v.
p1 := e1 asPolygon.
p1 := p1 translatedBy:100@0.
p1 displayOn:v.
p2 := p1 rotatedBy:90 degreesToRadians about:150@50.
p2 := p2 translatedBy:100@0.
v paint:Color red.
p2 displayOn:v.
e2 := e1 rotatedBy:-90 degreesToRadians about:e1 center.
v paint:Color green darkened.
e2 displayOn:v.
|
|v e1 e2 e3 e4 e5|
v := (View extent:400@300) openAndWaitUntilVisible.
e1 := EllipticalArc
boundingBox:(10@50 corner:190@130)
startAngle:0
endAngle:360.
v paint:Color blue.
e1 displayFilledOn:v.
v paint:Color red.
e1 displayStrokedOn:v.
e2 := e1 translatedBy:(200@50).
v paint:Color darkGreen.
e2 displayStrokedOn:v.
e3 := e1 rotatedBy:90 degreesToRadians about:e1 bounds center.
v paint:Color darkRed.
e3 displayStrokedOn:v.
e4 := e1 rotatedBy:45 degreesToRadians about:e1 bounds center.
v paint:Color orange.
e4 displayStrokedOn:v.
e5 := e4 translatedBy:(0@150).
v paint:Color green darkened.
e5 displayFilledOn:v.
| elliptical arcs; filled & unfilled:
|v e e2 e3 e4|
v := (View extent:250@200) openAndWaitUntilVisible.
e := EllipticalArc
boundingBox:(10@10 corner:140@95)
startAngle:0
endAngle:270.
v paint:Color blue.
e displayFilledOn:v.
v paint:Color red.
e displayStrokedOn:v.
e2 := e rotatedBy:90 degreesToRadians about:e bounds center.
e2 := e2 translatedBy:50@50.
v paint:Color yellow.
e2 displayFilledOn:v.
v paint:Color orange.
e2 displayStrokedOn:v.
e3 := e rotatedBy:45 degreesToRadians about:e bounds center.
e3 := e3 translatedBy:00@100.
v paint:Color orange.
e3 displayFilledOn:v.
v paint:Color red darkened.
e3 displayStrokedOn:v.
e4 := e rotatedBy:-45 degreesToRadians about:e bounds center.
e4 := e4 translatedBy:100@75.
v paint:Color orange lightened.
e4 displayFilledOn:v.
v paint:Color blue.
e4 displayStrokedOn:v.
|
|v e e2 e3 e4|
v := (View extent:250@200) openAndWaitUntilVisible.
e := EllipticalArc
boundingBox:(10@10 corner:140@95)
startAngle:0
endAngle:90.
v paint:Color blue.
e displayFilledOn:v.
v paint:Color red.
e displayStrokedOn:v.
e2 := e rotatedBy:90 degreesToRadians about:e bounds center.
e2 := e2 translatedBy:50@50.
v paint:Color yellow.
e2 displayFilledOn:v.
v paint:Color orange.
e2 displayStrokedOn:v.
e3 := e rotatedBy:45 degreesToRadians about:e bounds center.
e3 := e3 translatedBy:00@100.
v paint:Color orange.
e3 displayFilledOn:v.
v paint:Color red darkened.
e3 displayStrokedOn:v.
e4 := e rotatedBy:-45 degreesToRadians about:e bounds center.
e4 := e4 translatedBy:100@75.
v paint:Color orange lightened.
e4 displayFilledOn:v.
v paint:Color blue.
e4 displayStrokedOn:v.
|
|v e e2 e3 e4|
v := (View extent:250@200) openAndWaitUntilVisible.
e := EllipticalArc
boundingBox:(10@10 corner:140@95)
startAngle:0
endAngle:180.
v paint:Color blue.
e displayFilledOn:v.
v paint:Color red.
e displayStrokedOn:v.
e2 := e rotatedBy:90 degreesToRadians about:e bounds center.
e2 := e2 translatedBy:50@50.
v paint:Color yellow.
e2 displayFilledOn:v.
v paint:Color orange.
e2 displayStrokedOn:v.
e3 := e rotatedBy:45 degreesToRadians about:e bounds center.
e3 := e3 translatedBy:00@100.
v paint:Color orange.
e3 displayFilledOn:v.
v paint:Color red darkened.
e3 displayStrokedOn:v.
e4 := e rotatedBy:-45 degreesToRadians about:e bounds center.
e4 := e4 translatedBy:100@75.
v paint:Color orange lightened.
e4 displayFilledOn:v.
v paint:Color blue.
e4 displayStrokedOn:v.
| more arcs; filled:
|v ell|
v := View new openAndWaitUntilVisible.
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.
].
| more arcs; filled:
|v ell|
v := View new openAndWaitUntilVisible.
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.
].
|
|v e e2 e3 e4 e5|
v := View new extent:400@400.
v transformation:(WindowingTransformation
scale:1
translation:(150@150)).
v openAndWaitUntilVisible.
v clear.
v paint:(Color red).
v displayLineFrom:(-200@0) to:(200@0).
v displayLineFrom:(0@-200) to:(0@200).
v displayLineFrom:(100@3) to:(100@-3).
v displayLineFrom:(3@100) to:(-3@100).
e := EllipticalArc
boundingBox:(10@10 corner:90@90)
startAngle:0
sweepAngle:90.
v paint:(Color darkGreen).
e displayOn:v.
e bounds displayOn:v.
v paint:(Color green).
e asPolygon displayOn:v.
e2 := e rotatedBy:90 degreesToRadians about:0@0.
e3 := e rotatedBy:180 degreesToRadians about:0@0.
e4 := e rotatedBy:270 degreesToRadians about:0@0.
v paint:(Color blue).
e2 displayOn:v.
e2 bounds displayOn:v.
v paint:(Color blue lightened).
e2 asPolygon displayOn:v.
v paint:(Color yellow slightlyDarkened).
e3 displayOn:v.
e3 bounds displayOn:v.
v paint:(Color yellow).
e3 asPolygon displayOn:v.
v paint:(Color cyan slightlyDarkened).
e4 displayOn:v.
e4 bounds displayOn:v.
v paint:(Color cyan).
e4 asPolygon displayOn:v.
e5 := e rotatedBy:45 degreesToRadians about:0@0.
v paint:(Color brown).
(e bounds rotatedBy:45 degreesToRadians about:0@0) displayOn:v.
e5 displayOn:v.
|
|v e|
v := View new extent:400@400.
v transformation:(WindowingTransformation
scale:1
translation:(150@150)).
v openAndWaitUntilVisible.
v clear.
v paint:(Color red).
v displayLineFrom:(-200@0) to:(200@0).
v displayLineFrom:(0@-200) to:(0@200).
v displayLineFrom:(100@3) to:(100@-3).
v displayLineFrom:(3@100) to:(-3@100).
e := EllipticalArc
boundingBox:(10@10 corner:90@90)
startAngle:0
sweepAngle:90.
0 to:359 by:20 do:[:angle |
(e rotatedBy:(angle degreesToRadians) about:0@0) displayOn:v
].
| |v e|
v := View new extent:400@400.
v transformation:(WindowingTransformation
scale:1
translation:(150@150)).
v openAndWaitUntilVisible.
v clear.
v paint:(Color red).
v displayLineFrom:(-200@0) to:(200@0).
v displayLineFrom:(0@-200) to:(0@200).
v displayLineFrom:(100@3) to:(100@-3).
v displayLineFrom:(3@100) to:(-3@100).
e := EllipticalArc
boundingBox:(10@10 corner:90@90)
startAngle:0
sweepAngle:90.
0 to:359 by:20 do:[:angle |
v paint:(Color hue:angle light:50 saturation:100).
(e rotatedBy:(angle degreesToRadians) about:0@0) displayFilledOn:v
].
|