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