author | Claus Gittinger <cg@exept.de> |
Thu, 09 Jun 2016 12:30:05 +0200 | |
changeset 3886 | b4fe47975cce |
parent 2157 | b8368addde0d |
child 4088 | d43c1faedb32 |
permissions | -rw-r--r-- |
78 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
1303 | 12 |
"{ Package: 'stx:libbasic2' }" |
13 |
||
275
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
14 |
Geometric subclass:#EllipticalArc |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
15 |
instanceVariableNames:'boundingBox startAngle sweepAngle' |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
16 |
classVariableNames:'' |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
17 |
poolDictionaries:'' |
1303 | 18 |
category:'Graphics-Geometry-Objects' |
78 | 19 |
! |
20 |
||
275
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
21 |
!EllipticalArc class methodsFor:'documentation'! |
78 | 22 |
|
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
37 |
documentation |
|
38 |
" |
|
39 |
This class implements an ellipse which is aligned to x and y axes |
|
40 |
given a boundingBox, a startAngle and a sweepAngle. |
|
41 |
Positive angles are taken clockwise, negative angles are counterclockwise. |
|
281 | 42 |
|
43 |
[author:] |
|
44 |
Claus Gittinger |
|
45 |
||
46 |
[see also:] |
|
331 | 47 |
Circle Spline Curve LineSegment Polygon Rectangle Arrow |
48 |
ArrowedSpline |
|
281 | 49 |
GraphicsContext |
288 | 50 |
StrokingWrapper FillingWrapper |
78 | 51 |
" |
289 | 52 |
! |
53 |
||
54 |
examples |
|
55 |
" |
|
56 |
ellipses; filled & unfilled: |
|
57 |
[exBegin] |
|
58 |
|v e| |
|
59 |
||
60 |
v := (View extent:200@100) openAndWait. |
|
61 |
||
62 |
e := EllipticalArc |
|
63 |
boundingBox:(10@10 corner:190@90) |
|
64 |
startAngle:0 |
|
65 |
endAngle:360. |
|
66 |
||
67 |
v paint:Color blue. |
|
68 |
e displayFilledOn:v. |
|
69 |
||
70 |
v paint:Color red. |
|
71 |
e displayStrokedOn:v. |
|
72 |
||
73 |
[exEnd] |
|
74 |
elliptical arcs; filled & unfilled: |
|
75 |
[exBegin] |
|
76 |
|v e| |
|
77 |
||
78 |
v := (View extent:200@100) openAndWait. |
|
79 |
||
80 |
e := EllipticalArc |
|
81 |
boundingBox:(10@10 corner:190@90) |
|
82 |
startAngle:0 |
|
83 |
endAngle:270. |
|
84 |
||
85 |
v paint:Color blue. |
|
86 |
e displayFilledOn:v. |
|
87 |
||
88 |
v paint:Color red. |
|
89 |
e displayStrokedOn:v. |
|
90 |
||
91 |
[exEnd] |
|
92 |
more arcs; filled: |
|
93 |
[exBegin] |
|
94 |
|v ell| |
|
95 |
||
96 |
v := View new openAndWait. |
|
97 |
||
98 |
ell := EllipticalArc |
|
99 |
boundingBox:(10@10 corner:90@90) |
|
100 |
startAngle:0 |
|
101 |
sweepAngle:0. |
|
102 |
||
103 |
#(45 90 135 180 225 270 315 360) |
|
104 |
keysAndValuesReverseDo:[:index :angle | |
|
105 |
index odd ifTrue:[ |
|
106 |
v paint:Color white |
|
107 |
] ifFalse:[ |
|
108 |
v paint:Color black |
|
109 |
]. |
|
110 |
ell sweepAngle:angle. |
|
111 |
ell displayFilledOn:v. |
|
112 |
Delay waitForSeconds:0.1. |
|
113 |
]. |
|
114 |
||
115 |
[exEnd] |
|
116 |
more arcs; filled: |
|
117 |
[exBegin] |
|
118 |
|v ell| |
|
119 |
||
120 |
v := View new openAndWait. |
|
121 |
||
122 |
ell := EllipticalArc |
|
123 |
boundingBox:(10@10 corner:90@90) |
|
124 |
startAngle:0 |
|
125 |
sweepAngle:45. |
|
126 |
||
127 |
#(45 90 135 180 225 270 315 360) |
|
128 |
with:#( 0.125 0.25 0.375 0.5 0.625 0.75 0.875 1) |
|
129 |
do:[:angle :grey | |
|
130 |
ell startAngle:angle-45. |
|
131 |
v paint:(ColorValue red:grey green:0 blue:0). |
|
132 |
ell displayFilledOn:v. |
|
133 |
]. |
|
134 |
||
135 |
[exEnd] |
|
136 |
" |
|
78 | 137 |
! ! |
138 |
||
139 |
!EllipticalArc class methodsFor:'instance creation'! |
|
140 |
||
141 |
boundingBox:aRectangle |
|
142 |
"Return a new EllipticalArc." |
|
143 |
||
144 |
^ self new boundingBox:aRectangle |
|
145 |
! |
|
146 |
||
275
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
147 |
boundingBox:aRectangle startAngle:startAngle endAngle:endAngle |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
148 |
"Return a new EllipticalArc." |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
149 |
|
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
150 |
^ self boundingBox:aRectangle startAngle:startAngle sweepAngle:(endAngle - startAngle) |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
151 |
! |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
152 |
|
78 | 153 |
boundingBox:aRectangle startAngle:startAngle sweepAngle:sweepAngle |
154 |
"Return a new EllipticalArc." |
|
155 |
||
156 |
^ self new boundingBox:aRectangle startAngle:startAngle sweepAngle:sweepAngle |
|
157 |
! |
|
158 |
||
159 |
center:centerPoint radius:radius |
|
160 |
"Return a new Circle." |
|
161 |
||
162 |
^ self new center:centerPoint radius:radius |
|
346 | 163 |
! |
164 |
||
165 |
center:centerPoint radius:radius startAngle:startAngle endAngle:endAngle |
|
166 |
"Return a new (circular) Arc." |
|
167 |
||
168 |
^ (self new center:centerPoint radius:radius) |
|
169 |
startAngle:startAngle; sweepAngle:(endAngle - startAngle) |
|
170 |
||
171 |
"Created: 17.5.1996 / 09:58:36 / cg" |
|
172 |
"Modified: 17.5.1996 / 09:59:16 / cg" |
|
173 |
! |
|
174 |
||
175 |
center:centerPoint radius:radius startAngle:startAngle sweepAngle:sweepAngle |
|
176 |
"Return a new (circular) Arc." |
|
177 |
||
178 |
^ (self new center:centerPoint radius:radius) |
|
179 |
startAngle:startAngle; sweepAngle:sweepAngle |
|
180 |
||
181 |
"Created: 17.5.1996 / 09:59:08 / cg" |
|
78 | 182 |
! ! |
183 |
||
275
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
184 |
!EllipticalArc methodsFor:'accessing'! |
78 | 185 |
|
275
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
186 |
boundingBox:aRectangle |
346 | 187 |
"setup the arc, given a bounding rectangle" |
78 | 188 |
|
275
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
189 |
boundingBox := aRectangle. |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
190 |
startAngle := 0. |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
191 |
sweepAngle := 360 |
346 | 192 |
|
193 |
"Modified: 17.5.1996 / 10:05:06 / cg" |
|
78 | 194 |
! |
195 |
||
196 |
boundingBox:aRectangle startAngle:start sweepAngle:sweep |
|
346 | 197 |
"setup the arc, given a bounding rectangle, start and endAngle" |
78 | 198 |
|
199 |
boundingBox := aRectangle. |
|
200 |
startAngle := start. |
|
201 |
sweepAngle := sweep |
|
346 | 202 |
|
203 |
"Modified: 17.5.1996 / 10:05:27 / cg" |
|
204 |
! |
|
205 |
||
206 |
center:centerPoint radius:radius |
|
207 |
"setup for a circular arc, given center and radius" |
|
208 |
||
209 |
boundingBox := Rectangle |
|
210 |
left:(centerPoint x - radius) |
|
211 |
top:(centerPoint y - radius) |
|
212 |
width:(radius * 2) |
|
213 |
height:(radius * 2). |
|
214 |
startAngle := 0. |
|
215 |
sweepAngle := 360. |
|
216 |
||
217 |
"Created: 17.5.1996 / 10:07:35 / cg" |
|
78 | 218 |
! |
219 |
||
275
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
220 |
endAngle |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
221 |
"return the endAngle." |
78 | 222 |
|
275
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
223 |
^ startAngle + sweepAngle |
78 | 224 |
! |
225 |
||
226 |
startAngle |
|
227 |
"return the startAngle." |
|
228 |
||
229 |
^ startAngle |
|
275
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
230 |
! |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
231 |
|
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
232 |
startAngle:angle |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
233 |
"set the startAngle." |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
234 |
|
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
235 |
startAngle := angle |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
236 |
! |
78 | 237 |
|
238 |
sweepAngle |
|
239 |
"return the sweepAngle." |
|
240 |
||
241 |
^ sweepAngle |
|
242 |
! |
|
243 |
||
275
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
244 |
sweepAngle:angle |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
245 |
"set the sweepAngle." |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
246 |
|
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
247 |
sweepAngle := angle |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
248 |
! ! |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
249 |
|
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
250 |
!EllipticalArc methodsFor:'converting'! |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
251 |
|
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
252 |
asEllipticalArc |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
253 |
"convert the receiver into an ellipticalArc - thats the receiver itself" |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
254 |
|
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
255 |
^ self |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
256 |
! ! |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
257 |
|
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
258 |
!EllipticalArc methodsFor:'displaying'! |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
259 |
|
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
260 |
displayFilledOn:aGC |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
261 |
"draw the receiver as a filled arc in a graphicsContext, aGC" |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
262 |
|
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
263 |
aGC fillArcX:boundingBox left |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
264 |
y:boundingBox top |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
265 |
width:boundingBox width |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
266 |
height:boundingBox height |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
267 |
from:startAngle |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
268 |
to:(startAngle+sweepAngle) |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
269 |
! |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
270 |
|
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
271 |
displayStrokedOn:aGC |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
272 |
"draw the receiver as a unfilled arc in a graphicsContext, aGC" |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
273 |
|
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
274 |
aGC displayArcX:boundingBox left |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
275 |
y:boundingBox top |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
276 |
width:boundingBox width |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
277 |
height:boundingBox height |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
278 |
from:startAngle |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
279 |
angle:sweepAngle |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
280 |
! ! |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
281 |
|
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
282 |
!EllipticalArc methodsFor:'queries'! |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
283 |
|
78 | 284 |
center |
275
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
285 |
"return the center" |
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
286 |
|
78 | 287 |
^ boundingBox center |
490
ef43c7a69346
added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
288 |
! |
ef43c7a69346
added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
289 |
|
ef43c7a69346
added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
290 |
computeBounds |
ef43c7a69346
added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
291 |
"return the smallest enclosing rectangle" |
ef43c7a69346
added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
292 |
|
ef43c7a69346
added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
293 |
^ boundingBox |
ef43c7a69346
added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
294 |
|
ef43c7a69346
added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents:
346
diff
changeset
|
295 |
"Created: 12.2.1997 / 11:43:00 / cg" |
78 | 296 |
! ! |
297 |
||
2157 | 298 |
!EllipticalArc methodsFor:'testing'! |
299 |
||
300 |
canBeFilled |
|
301 |
"return true, if the receiver can be drawn as a filled geometric. |
|
302 |
Always true here." |
|
303 |
||
304 |
^ true |
|
305 |
! ! |
|
306 |
||
275
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
307 |
!EllipticalArc class methodsFor:'documentation'! |
78 | 308 |
|
275
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
309 |
version |
2157 | 310 |
^ '$Header: /cvs/stx/stx/libbasic2/EllipticalArc.st,v 1.14 2009-06-06 10:12:23 cg Exp $' |
275
4a9fed506144
doku, comments & more functionality
Claus Gittinger <cg@exept.de>
parents:
112
diff
changeset
|
311 |
! ! |