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