class: WindowingTransformation
added:5 methods
changed:
#compose:
#noScale
--- a/WindowingTransformation.st Sun Dec 21 16:51:43 2014 +0100
+++ b/WindowingTransformation.st Sun Dec 21 22:24:21 2014 +0100
@@ -128,6 +128,31 @@
"Modified: 30.12.1996 / 16:59:27 / cg"
!
+scale:aScale
+ "returns a windowing transformation with a scale factor of aScale and no translation"
+
+ ^ self basicNew scale:aScale translation:0
+
+ "
+ |v|
+
+ v := View new realize.
+ (Delay forSeconds:3) wait.
+ v transformation:(WindowingTransformation scale:2 translation:0).
+ 'now, everything is magnfied by 2'.
+ v displayLineFrom:10@10 to:30@30
+ "
+ "
+ |v|
+
+ v := View new realize.
+ (Delay forSeconds:3) wait.
+ v transformation:(WindowingTransformation scale:0.5 translation:0).
+ 'now, everything is shrunk by 2'.
+ v displayLineFrom:10@10 to:30@30
+ "
+!
+
scale:aScale translation:aTranslation
"returns a windowing transformation with a scale factor of
aScale and a translation offset of aTranslation."
@@ -154,6 +179,31 @@
"
!
+translation:aTranslation
+ "returns a windowing transformation with no scaling and a translation offset of aTranslation."
+
+ ^ self basicNew scale:nil translation:aTranslation
+
+ "
+ |v|
+
+ v := View new openAndWait.
+ v displayLineFrom:10@10 to:30@30.
+ v transformation:(WindowingTransformation scale:2 translation:0).
+ 'now, everything is magnfied by 2'.
+ v displayLineFrom:10@10 to:30@30.
+ "
+ "
+ |v|
+
+ v := View new openAndWait.
+ v displayLineFrom:10@10 to:30@30.
+ v transformation:(WindowingTransformation translation:50).
+ 'now, everything is offset by 50 pixels'.
+ v displayLineFrom:10@10 to:30@30.
+ "
+!
+
unit:unitSymbol on:device
"returns a windowing transformation with scaling
for unitSymbol and no translation (0@0).
@@ -252,6 +302,10 @@
'now, we can think of drawing in 0..1/0..1 coordinates'.
v displayLineFrom:0.1@0.1 to:0.9@0.9
"
+!
+
+withAngle:angle
+ ^ MatrixTransform2x3 withAngle:angle
! !
!WindowingTransformation methodsFor:'accessing'!
@@ -494,24 +548,28 @@
aTransformationScale := aTransformation scale.
scale isNil ifTrue:[
- aTransformation noScale ifTrue:[
- newScale := nil
- ] ifFalse:[
- newScale := aTransformationScale
- ].
- newTranslation := translation + aTransformation translation
+ aTransformation isNoScale ifTrue:[
+ newScale := nil
+ ] ifFalse:[
+ newScale := aTransformationScale
+ ].
+ newTranslation := (translation ? 0) + aTransformation translation
] ifFalse:[
- aTransformation noScale ifTrue:[
- newScale := scale
- ] ifFalse:[
- newScale := scale * aTransformationScale
- ].
- newTranslation := translation
- + (scale * aTransformation translation)
+ aTransformation isNoScale ifTrue:[
+ newScale := scale
+ ] ifFalse:[
+ newScale := scale * aTransformationScale
+ ].
+ newTranslation := (translation ? 0)
+ + (scale * aTransformation translation)
].
^ (self class)
- scale:newScale
- translation:newTranslation
+ scale:newScale
+ translation:newTranslation
+!
+
+composedWithLocal: aTransformation
+ ^ self compose:aTransformation
!
transformPoint:p
@@ -586,9 +644,22 @@
and:[translation isNil or:[translation x = 0 and:[translation y = 0]]]
!
+isNoScale
+ "return true if the identity scale is in effect (i.e. saleFactor is 1);
+ return false, otherwise."
+
+ scale isNil ifTrue:[^ true].
+ ^ scale x = 1 and:[scale y = 1]
+
+ "Modified: 21.5.1996 / 21:15:21 / cg"
+!
+
noScale
- "return true if the identity scale is in effect;
- return false, otherwise."
+ <resource: #obsolete>
+
+ "return true if the identity scale is in effect (i.e. saleFactor is 1);
+ return false, otherwise.
+ Obsolete: use isNoScale"
scale isNil ifTrue:[^ true].
^ scale x = 1 and:[scale y = 1]
@@ -673,6 +744,6 @@
!WindowingTransformation class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/WindowingTransformation.st,v 1.24 2014-03-24 19:18:28 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/WindowingTransformation.st,v 1.25 2014-12-21 21:24:21 cg Exp $'
! !