我可以在Morphic中旋转TextMorph,但找不到旋转它的方法。我想在初始化时使用它。
发布于 2018-04-19 03:01:35
试试这个:
aTextMorph addFlexShell rotationDegrees: 45.0#addFlexShell将TextMorph包装在可用于应用转换的TransformationMorph中。通过变形的光晕应用旋转时,还会添加TransformationMorph。您可能希望将其存储在一个变量中,以便以后再次访问它:
flexShell := aTextMorph addFlexShell.
flexShell rotationDegrees: 45.0.
"..."如果您在方法中编写此代码,并且在方法结束后需要flex shell (用于转换目的),请向您的类添加一个实例变量,并将flex shell保存在其中:
Object subclassNamed: #MyClass
instanceVariableNames: 'transformationOfMyMorph myMorph'
classVariableNames: ''
poolDictionaries: ''
category: 'MyPackage'
myMethod
myMorph := TextMorph new contents: 'rotated text'.
transformationOfMyMorph := myMorph addFlexShell.
rotateFurther
transformationOfMyMorph rotationDegrees: transformationOfMyMorph rotationDegrees + 5.0.如果在一种方法中只需要flex shell,请使用临时(本地)变量:
myMethod
| flexShell |
myMorph := TextMorph new. "..."
flexShell := myMorph addFlexShell.
"..."https://stackoverflow.com/questions/49903062
复制相似问题