0
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
72
|
3 |
All Rights Reserved
|
0
|
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 |
|
601
|
13 |
Object subclass:#WindowingTransformation
|
|
14 |
instanceVariableNames:'scale translation'
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Graphics-Support'
|
|
18 |
!
|
|
19 |
|
|
20 |
!WindowingTransformation class methodsFor:'instance creation'!
|
|
21 |
|
|
22 |
identity
|
|
23 |
"returns a windowing transformation with no scaling (1@1)
|
|
24 |
and no translation (0@0)."
|
|
25 |
|
|
26 |
^ self basicNew scale:nil translation:nil
|
|
27 |
!
|
|
28 |
|
|
29 |
scale:aScale translation:aTranslation
|
|
30 |
"returns a windowing transformation with a scale factor of
|
|
31 |
aScale and a translation offset of aTranslation."
|
|
32 |
|
|
33 |
^ self basicNew scale:aScale translation:aTranslation
|
|
34 |
|
|
35 |
"
|
|
36 |
|v|
|
|
37 |
|
|
38 |
v := View new realize.
|
|
39 |
(Delay forSeconds:3) wait.
|
|
40 |
v transformation:(WindowingTransformation scale:2 translation:0).
|
|
41 |
'now, everything is magnfied by 2'.
|
|
42 |
v displayLineFrom:10@10 to:30@30
|
|
43 |
"
|
|
44 |
"
|
|
45 |
|v|
|
|
46 |
|
|
47 |
v := View new realize.
|
|
48 |
(Delay forSeconds:3) wait.
|
|
49 |
v transformation:(WindowingTransformation scale:0.5 translation:0).
|
|
50 |
'now, everything is shrunk by 2'.
|
|
51 |
v displayLineFrom:10@10 to:30@30
|
|
52 |
"
|
|
53 |
!
|
|
54 |
|
|
55 |
unit:unitSymbol on:device
|
|
56 |
"returns a windowing transformation with scaling
|
|
57 |
for unitSymbol and no translation (0@0).
|
|
58 |
With such a transformation, you can draw in your preferred
|
|
59 |
units.
|
|
60 |
UnitSymbol may be #mm, #cm, #inch, #point, #twip or #pixel (default).
|
|
61 |
Twip is 1/20th of a point, point is 1/72th of an inch
|
|
62 |
(i.e. the print-unit which is also used for font sizes etc.)
|
|
63 |
- not to confuse with device pixels."
|
|
64 |
|
|
65 |
|pixelPerUnitV pixelPerUnitH|
|
72
|
66 |
|
601
|
67 |
unitSymbol == #mm ifTrue:[
|
|
68 |
pixelPerUnitV := device verticalPixelPerMillimeter.
|
|
69 |
pixelPerUnitH := device horizontalPixelPerMillimeter
|
|
70 |
] ifFalse:[
|
|
71 |
unitSymbol == #cm ifTrue:[
|
|
72 |
pixelPerUnitV := device verticalPixelPerMillimeter * 10.
|
|
73 |
pixelPerUnitH := device horizontalPixelPerMillimeter * 10
|
|
74 |
] ifFalse:[
|
|
75 |
unitSymbol == #twip ifTrue:[
|
|
76 |
pixelPerUnitV := device verticalPixelPerInch / 1440.
|
|
77 |
pixelPerUnitH := device horizontalPixelPerInch / 1440
|
|
78 |
] ifFalse:[
|
|
79 |
unitSymbol == #point ifTrue:[
|
|
80 |
pixelPerUnitV := device verticalPixelPerInch / 72.
|
|
81 |
pixelPerUnitH := device horizontalPixelPerInch / 72
|
|
82 |
] ifFalse:[
|
|
83 |
unitSymbol == #inch ifTrue:[
|
|
84 |
pixelPerUnitV := device verticalPixelPerInch.
|
|
85 |
pixelPerUnitH := device horizontalPixelPerInch
|
|
86 |
] ifFalse:[
|
|
87 |
"sorry: unknown unit is taken as pixel"
|
|
88 |
^ self new scale:nil translation:nil
|
|
89 |
]
|
|
90 |
]
|
|
91 |
]
|
|
92 |
]
|
|
93 |
].
|
|
94 |
^ self basicNew scale:(pixelPerUnitH @ pixelPerUnitV) translation:nil
|
|
95 |
|
|
96 |
"
|
|
97 |
|v|
|
|
98 |
|
|
99 |
v := View new realize.
|
|
100 |
(Delay forSeconds:3) wait.
|
|
101 |
v transformation:(WindowingTransformation unit:#inch on:Display).
|
|
102 |
'now, we can think of drawing in inches ...'.
|
|
103 |
v displayLineFrom:0.5@0.5 to:1@1
|
|
104 |
"
|
72
|
105 |
!
|
0
|
106 |
|
601
|
107 |
window:sourceRectangle viewport:destinationRectangle
|
|
108 |
"returns a windowing transformation with a scale and
|
|
109 |
translation computed from sourceRectangle and destinationRectangle.
|
|
110 |
The scale and transformation are computed such that sourceRectangle
|
|
111 |
is transformed to destinationRectangle. Typically sourceRectangle
|
|
112 |
represents the logical coordinateSpace while destinationRectangle
|
|
113 |
represents the device coordinateSpace."
|
|
114 |
|
|
115 |
|sX sY tX tY newScale newTranslation|
|
|
116 |
|
|
117 |
sX := destinationRectangle width / sourceRectangle width.
|
|
118 |
sY := destinationRectangle height / sourceRectangle height.
|
|
119 |
tX := destinationRectangle left - sourceRectangle left.
|
|
120 |
tY := destinationRectangle top - sourceRectangle top.
|
|
121 |
((tX = 1.0) and:[tY = 1.0]) ifTrue:[
|
|
122 |
newTranslation := nil
|
|
123 |
] ifFalse:[
|
|
124 |
newTranslation := tX @ tY
|
|
125 |
].
|
|
126 |
((sX = 1.0) and:[sY = 1.0]) ifTrue:[
|
|
127 |
newScale := nil
|
|
128 |
] ifFalse:[
|
|
129 |
newScale := sX @ sY
|
|
130 |
].
|
|
131 |
^ self basicNew scale:newScale translation:newTranslation
|
|
132 |
|
|
133 |
"
|
|
134 |
|v|
|
|
135 |
|
|
136 |
v := View new realize.
|
|
137 |
(Delay forSeconds:3) wait.
|
|
138 |
v transformation:(WindowingTransformation
|
|
139 |
window:(0@0 corner:1@1)
|
|
140 |
viewport:(0@0 corner:100@100)).
|
|
141 |
'now, we can think of drawing in 0..1/0..1 coordinates'.
|
|
142 |
v displayLineFrom:0.1@0.1 to:0.9@0.9
|
|
143 |
"
|
|
144 |
! !
|
|
145 |
|
78
|
146 |
!WindowingTransformation class methodsFor:'documentation '!
|
|
147 |
|
|
148 |
copyright
|
|
149 |
"
|
|
150 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
|
151 |
All Rights Reserved
|
|
152 |
|
|
153 |
This software is furnished under a license and may be used
|
|
154 |
only in accordance with the terms of that license and with the
|
|
155 |
inclusion of the above copyright notice. This software may not
|
|
156 |
be provided or otherwise made available to, or used by, any
|
|
157 |
other person. No title to or ownership of the software is
|
|
158 |
hereby transferred.
|
|
159 |
"
|
|
160 |
!
|
|
161 |
|
|
162 |
documentation
|
|
163 |
"
|
|
164 |
instances of WindowingTransformation can be used to scale, translate or
|
|
165 |
generally transform other objects in 2D space.
|
|
166 |
They can also be set as the translation in a graphic context,
|
|
167 |
which will then apply this to all of its drawing operations
|
|
168 |
(see GraphicContext>>transformation:).
|
|
169 |
|
|
170 |
All 2-D objects are supposed to be able to be transformed using
|
|
171 |
instances of me. Multiple instances of me can also be combined to form a
|
|
172 |
single composite transformation.
|
|
173 |
|
611
|
174 |
[Instance variables:]
|
|
175 |
scale <Number> or <Point> representing a linear scaling factor.
|
|
176 |
nil is interpreted as 1@1
|
|
177 |
|
|
178 |
translation <Number> or <Point> representing a translation in 2-D.
|
|
179 |
nil is interpreted as 0@0
|
78
|
180 |
|
|
181 |
|
611
|
182 |
[author:]
|
|
183 |
Claus Gittinger
|
81
|
184 |
"
|
611
|
185 |
|
|
186 |
"Modified: 25.4.1996 / 16:53:07 / cg"
|
81
|
187 |
!
|
78
|
188 |
|
81
|
189 |
examples
|
|
190 |
"
|
78
|
191 |
example (drawing in inches):
|
619
|
192 |
[exBegin]
|
78
|
193 |
|v|
|
|
194 |
|
|
195 |
v := View new realize.
|
|
196 |
(Delay forSeconds:3) wait.
|
|
197 |
v transformation:(WindowingTransformation unit:#inch on:Display).
|
|
198 |
'now, we can think of drawing in inches ...'.
|
|
199 |
v displayLineFrom:0.5@0.5 to:1@1
|
619
|
200 |
[exEnd]
|
78
|
201 |
|
|
202 |
|
|
203 |
example (drawing in millimeters):
|
619
|
204 |
[exBegin]
|
78
|
205 |
|v|
|
|
206 |
|
|
207 |
v := View new realize.
|
|
208 |
(Delay forSeconds:3) wait.
|
|
209 |
v transformation:(WindowingTransformation unit:#mm on:Display).
|
|
210 |
'now, we can think of drawing in millimeters ...'.
|
|
211 |
v displayLineFrom:5@5 to:20@5
|
619
|
212 |
[exEnd]
|
78
|
213 |
|
|
214 |
|
|
215 |
example (drawing magnified):
|
619
|
216 |
[exBegin]
|
78
|
217 |
|v|
|
|
218 |
|
|
219 |
v := View new realize.
|
|
220 |
(Delay forSeconds:3) wait.
|
|
221 |
v transformation:(WindowingTransformation scale:2 translation:0).
|
|
222 |
'now, everything is magnfied by 2'.
|
|
223 |
v displayLineFrom:10@10 to:30@30
|
619
|
224 |
[exEnd]
|
78
|
225 |
|
|
226 |
example (drawing shrunk):
|
619
|
227 |
[exBegin]
|
78
|
228 |
|v|
|
|
229 |
|
|
230 |
v := View new realize.
|
|
231 |
(Delay forSeconds:3) wait.
|
|
232 |
v transformation:(WindowingTransformation scale:0.5 translation:0).
|
|
233 |
'now, everything is shrunk by 2'.
|
|
234 |
v displayLineFrom:10@10 to:30@30
|
619
|
235 |
[exEnd]
|
|
236 |
"
|
78
|
237 |
|
619
|
238 |
"Modified: 27.4.1996 / 19:45:43 / cg"
|
601
|
239 |
!
|
|
240 |
|
|
241 |
version
|
619
|
242 |
^ '$Header: /cvs/stx/stx/libview/WindowingTransformation.st,v 1.13 1996-04-27 17:52:59 cg Exp $'
|
78
|
243 |
! !
|
|
244 |
|
601
|
245 |
!WindowingTransformation methodsFor:'accessing'!
|
|
246 |
|
|
247 |
scale
|
|
248 |
"return a copy of the Point that represents the
|
|
249 |
current scale of the receiver."
|
72
|
250 |
|
601
|
251 |
scale isNil ifTrue:[^ (1@1) copy].
|
|
252 |
^ scale copy
|
|
253 |
!
|
72
|
254 |
|
601
|
255 |
scale:aScale
|
|
256 |
"Set the receiver's scale to aScale, a Point or Number."
|
72
|
257 |
|
601
|
258 |
aScale isNil ifTrue:[
|
|
259 |
scale := aScale
|
72
|
260 |
] ifFalse:[
|
601
|
261 |
scale := aScale asPoint.
|
72
|
262 |
].
|
|
263 |
!
|
|
264 |
|
601
|
265 |
scale:aScale translation:aTranslation
|
|
266 |
"sets the scale to aScale and the translation to aTranslation."
|
78
|
267 |
|
601
|
268 |
aScale isNil ifTrue:[
|
|
269 |
scale := aScale
|
|
270 |
] ifFalse:[
|
|
271 |
scale := aScale asPoint.
|
|
272 |
].
|
|
273 |
aTranslation isNil ifTrue:[
|
|
274 |
translation := aTranslation
|
|
275 |
] ifFalse:[
|
|
276 |
translation := aTranslation asPoint
|
|
277 |
]
|
72
|
278 |
!
|
|
279 |
|
601
|
280 |
scaleOfOne
|
|
281 |
"Set the scale of the receiver to the identity scale"
|
72
|
282 |
|
601
|
283 |
scale := nil
|
72
|
284 |
!
|
|
285 |
|
601
|
286 |
translation
|
|
287 |
"return a copy of the receiver's translation."
|
|
288 |
|
|
289 |
translation isNil ifTrue:[^ (0@0) copy].
|
|
290 |
^ translation copy
|
|
291 |
!
|
72
|
292 |
|
601
|
293 |
translation:aTranslation
|
|
294 |
"Set the receiver's translation to aTranslation, a Point or Number."
|
|
295 |
|
|
296 |
aTranslation isNil ifTrue:[
|
|
297 |
translation := aTranslation
|
|
298 |
] ifFalse:[
|
|
299 |
translation := aTranslation asPoint
|
|
300 |
]
|
46
|
301 |
! !
|
0
|
302 |
|
72
|
303 |
!WindowingTransformation methodsFor:'applying transform'!
|
0
|
304 |
|
78
|
305 |
applyInverseScaleX:aNumber
|
|
306 |
"apply the scale only (if widths are to be transformed)"
|
|
307 |
|
|
308 |
scale isNil ifTrue:[^ aNumber].
|
|
309 |
^ aNumber / scale x
|
|
310 |
!
|
|
311 |
|
|
312 |
applyInverseScaleY:aNumber
|
|
313 |
"apply the scale only (if heights are to be transformed)"
|
|
314 |
|
|
315 |
scale isNil ifTrue:[^ aNumber].
|
|
316 |
^ aNumber / scale y
|
|
317 |
!
|
|
318 |
|
|
319 |
applyInverseTo:anObject
|
|
320 |
"Apply the inverse of the receiver to anObject
|
|
321 |
and return the result. This can be used to map back from logical
|
|
322 |
to physical coordinates, for example."
|
|
323 |
|
|
324 |
|transformedObject|
|
|
325 |
|
|
326 |
translation isNil ifTrue:[
|
|
327 |
scale isNil ifTrue:[
|
|
328 |
^ anObject
|
|
329 |
].
|
|
330 |
^ anObject scaledBy:self inverseScale
|
|
331 |
].
|
|
332 |
transformedObject := anObject translatedBy:(self inverseTranslation).
|
|
333 |
scale notNil ifTrue:[
|
|
334 |
transformedObject scaleBy:(self inverseScale).
|
|
335 |
].
|
|
336 |
^ transformedObject
|
|
337 |
!
|
|
338 |
|
601
|
339 |
applyInverseToX:aNumber
|
|
340 |
"Apply the receiver to a number representing an x-coordinate
|
|
341 |
and return the result."
|
|
342 |
|
|
343 |
|t s|
|
|
344 |
|
|
345 |
scale isNil ifTrue:[s := 1] ifFalse:[s := scale x].
|
|
346 |
translation isNil ifTrue:[t := 0] ifFalse:[t := translation x].
|
|
347 |
^ (aNumber - t) / s
|
|
348 |
!
|
|
349 |
|
|
350 |
applyInverseToY:aNumber
|
|
351 |
"Apply the receiver to a number representing an y-coordinate
|
|
352 |
and return the result."
|
|
353 |
|
|
354 |
|t s|
|
|
355 |
|
|
356 |
scale isNil ifTrue:[s := 1] ifFalse:[s := scale y].
|
|
357 |
translation isNil ifTrue:[t := 0] ifFalse:[t := translation y].
|
|
358 |
^ (aNumber - t) / s
|
|
359 |
!
|
|
360 |
|
|
361 |
applyScaleX:aNumber
|
|
362 |
"apply the scale only (if widths are to be transformed)"
|
|
363 |
|
|
364 |
scale isNil ifTrue:[^ aNumber].
|
|
365 |
^ aNumber * scale x
|
|
366 |
!
|
|
367 |
|
|
368 |
applyScaleY:aNumber
|
|
369 |
"apply the scale only (if heights are to be transformed)"
|
|
370 |
|
|
371 |
scale isNil ifTrue:[^ aNumber].
|
|
372 |
^ aNumber * scale y
|
|
373 |
!
|
|
374 |
|
|
375 |
applyTo:anObject
|
|
376 |
"Apply the receiver to anObject and return the result."
|
|
377 |
|
|
378 |
|transformedObject|
|
78
|
379 |
|
|
380 |
scale isNil ifTrue:[
|
|
381 |
translation isNil ifTrue:[
|
601
|
382 |
^ anObject
|
78
|
383 |
].
|
601
|
384 |
^ anObject translatedBy:translation
|
|
385 |
].
|
|
386 |
transformedObject := anObject scaledBy:scale.
|
|
387 |
translation notNil ifTrue:[
|
|
388 |
transformedObject translateBy:translation.
|
78
|
389 |
].
|
601
|
390 |
^ transformedObject
|
|
391 |
!
|
|
392 |
|
|
393 |
applyToX:aNumber
|
|
394 |
"Apply the receiver to a number representing an x-coordinate
|
|
395 |
and return the result."
|
|
396 |
|
|
397 |
|t s|
|
|
398 |
|
|
399 |
scale isNil ifTrue:[s := 1] ifFalse:[s := scale x].
|
|
400 |
translation isNil ifTrue:[t := 0] ifFalse:[t := translation x].
|
|
401 |
^ aNumber * s + t
|
|
402 |
!
|
|
403 |
|
|
404 |
applyToY:aNumber
|
|
405 |
"Apply the receiver to a number representing an y-coordinate
|
|
406 |
and return the result."
|
|
407 |
|
|
408 |
|t s|
|
|
409 |
|
|
410 |
scale isNil ifTrue:[s := 1] ifFalse:[s := scale y].
|
|
411 |
translation isNil ifTrue:[t := 0] ifFalse:[t := translation y].
|
|
412 |
^ aNumber * s + t
|
78
|
413 |
!
|
|
414 |
|
0
|
415 |
compose:aTransformation
|
|
416 |
"return a new WindowingTransformation that is the
|
|
417 |
composition of the receiver and aTransformation.
|
|
418 |
The effect of applying the resulting WindowingTransformation
|
|
419 |
to an object is the same as that of first applying
|
|
420 |
aTransformation to the object and then applying the
|
|
421 |
receiver to its result."
|
|
422 |
|
|
423 |
|aTransformationScale newScale newTranslation|
|
|
424 |
|
|
425 |
aTransformationScale := aTransformation scale.
|
78
|
426 |
scale isNil ifTrue:[
|
72
|
427 |
aTransformation noScale ifTrue:[
|
|
428 |
newScale := nil
|
|
429 |
] ifFalse:[
|
|
430 |
newScale := aTransformationScale
|
|
431 |
].
|
|
432 |
newTranslation := translation + aTransformation translation
|
0
|
433 |
] ifFalse:[
|
72
|
434 |
aTransformation noScale ifTrue:[
|
|
435 |
newScale := scale
|
|
436 |
] ifFalse:[
|
|
437 |
newScale := scale * aTransformationScale
|
|
438 |
].
|
|
439 |
newTranslation := translation
|
|
440 |
+ (scale * aTransformation translation)
|
0
|
441 |
].
|
72
|
442 |
^ (self class)
|
|
443 |
scale:newScale
|
|
444 |
translation:newTranslation
|
|
445 |
!
|
|
446 |
|
601
|
447 |
transformPoint:p
|
|
448 |
"Apply the receiver to a point.
|
|
449 |
This is destructive in that the point is being modified,
|
|
450 |
not a copy."
|
0
|
451 |
|
601
|
452 |
scale isNil ifTrue:[
|
|
453 |
translation isNil ifTrue:[
|
|
454 |
^ p
|
72
|
455 |
].
|
601
|
456 |
^ p + translation
|
|
457 |
].
|
|
458 |
translation isNil ifTrue:[
|
|
459 |
^ p * scale
|
0
|
460 |
].
|
601
|
461 |
^ (p * scale + translation)
|
|
462 |
! !
|
|
463 |
|
|
464 |
!WindowingTransformation methodsFor:'printing'!
|
0
|
465 |
|
601
|
466 |
printOn:aStream
|
|
467 |
aStream nextPutAll:self class name.
|
|
468 |
aStream nextPutAll:' scale: '.
|
|
469 |
scale printOn:aStream.
|
|
470 |
aStream nextPutAll:' translation: '.
|
|
471 |
translation printOn:aStream
|
0
|
472 |
! !
|
|
473 |
|
72
|
474 |
!WindowingTransformation methodsFor:'private'!
|
0
|
475 |
|
|
476 |
checkScale:aScale
|
|
477 |
"Converts aScale to the internal format of a floating-point Point."
|
|
478 |
|
|
479 |
|checkedScale|
|
|
480 |
|
|
481 |
checkedScale := aScale asPoint.
|
|
482 |
^ Point x:checkedScale x asFloat
|
72
|
483 |
y:checkedScale y asFloat
|
0
|
484 |
!
|
|
485 |
|
|
486 |
inverseScale
|
|
487 |
"return with a Point representing the inverse of my
|
|
488 |
scale."
|
|
489 |
|
|
490 |
|newScale|
|
|
491 |
|
|
492 |
newScale := self checkScale:scale.
|
|
493 |
^ Point x:(1.0 / newScale x)
|
72
|
494 |
y:(1.0 / newScale y)
|
0
|
495 |
!
|
|
496 |
|
|
497 |
inverseTranslation
|
|
498 |
"return with a Point representing the inverse of my
|
|
499 |
translation."
|
|
500 |
|
|
501 |
|trans|
|
|
502 |
|
|
503 |
trans := translation asPoint.
|
|
504 |
^ Point x:trans x negated
|
72
|
505 |
y:trans y negated
|
|
506 |
! !
|
|
507 |
|
|
508 |
!WindowingTransformation methodsFor:'testing'!
|
|
509 |
|
|
510 |
noScale
|
|
511 |
"return true if the identity scale is in effect;
|
|
512 |
return false, otherwise."
|
0
|
513 |
|
72
|
514 |
^ scale == nil
|
0
|
515 |
! !
|
72
|
516 |
|
601
|
517 |
!WindowingTransformation methodsFor:'transforming'!
|
|
518 |
|
|
519 |
scaleBy:aScale
|
|
520 |
"scale the receiver.
|
|
521 |
This is a destructive operation, modifying the transformation
|
|
522 |
represented by the receiver"
|
|
523 |
|
|
524 |
|newScale|
|
|
525 |
|
|
526 |
aScale isNil ifTrue:[^ self].
|
|
527 |
|
|
528 |
scale isNil ifTrue:[
|
|
529 |
newScale := aScale asPoint
|
|
530 |
] ifFalse:[
|
|
531 |
newScale := scale * aScale
|
|
532 |
].
|
|
533 |
translation notNil ifTrue:[
|
|
534 |
translation := translation * aScale.
|
|
535 |
].
|
|
536 |
scale := newScale.
|
|
537 |
!
|
|
538 |
|
|
539 |
scaledBy:aScale
|
|
540 |
"return a new WindowingTransformation with the scale and translation of
|
|
541 |
the receiver both scaled by aScale."
|
|
542 |
|
|
543 |
|checkedScale newScale newTranslation|
|
72
|
544 |
|
601
|
545 |
aScale isNil ifTrue:[
|
|
546 |
newScale := scale.
|
|
547 |
newTranslation := translation
|
|
548 |
] ifFalse:[
|
|
549 |
checkedScale := self checkScale:aScale.
|
|
550 |
scale isNil ifTrue:[
|
|
551 |
newScale := checkedScale
|
|
552 |
] ifFalse:[
|
|
553 |
newScale := scale * checkedScale
|
|
554 |
].
|
|
555 |
translation notNil ifTrue:[
|
|
556 |
newTranslation := checkedScale * translation
|
|
557 |
]
|
|
558 |
].
|
|
559 |
^ (self class)
|
|
560 |
scale:newScale
|
|
561 |
translation:newTranslation
|
|
562 |
!
|
|
563 |
|
|
564 |
translateBy:aTranslation
|
|
565 |
"translate the receiver.
|
|
566 |
This is a destructive operation, modifying the transformation
|
|
567 |
represented by the receiver"
|
|
568 |
|
|
569 |
aTranslation isNil ifTrue:[^ self].
|
|
570 |
|
|
571 |
translation isNil ifTrue:[
|
|
572 |
translation := 0@0
|
|
573 |
].
|
|
574 |
scale isNil ifTrue:[
|
|
575 |
translation := translation + aTranslation asPoint
|
|
576 |
] ifFalse:[
|
|
577 |
translation := translation + (scale * aTranslation)
|
|
578 |
].
|
|
579 |
!
|
|
580 |
|
|
581 |
translatedBy:aPoint
|
|
582 |
"return a new WindowingTransformation with the same scale and
|
|
583 |
rotations as the receiver and with a translation of the current
|
|
584 |
translation plus aPoint."
|
|
585 |
|
|
586 |
^ (self class)
|
|
587 |
scale:scale
|
|
588 |
translation:(translation + aPoint)
|
72
|
589 |
! !
|
|
590 |
|