smalltalk - 遍历圆变形的直径

我有一个 CircleMorph,我想扩大它的直径,可能是为了用它创建一个小动画。

b := CircleMorph new.
b color: Color transparent.
b borderWidth: 2.
b extent:100 @ 100.
b openInWorld.

如果我使用循环或 step 方法来执行此操作会好吗?如果您推荐 step 方法,那么我该怎么做?

最佳答案

您可以创建一个 CircleMorph 的子类,称为 GrowingCircleMorph。 然后执行step:

step
   self extent: (self extent) + 1.
   (self extent) > (200@200) ifTrue: [ self stopStepping ]

现在,如果您在世界中打开新的 GrowingCircleMorph 实例,它将开始增长到 201@201。

要更改速度,请实现 stepTime 并返回所需的步骤之间的时间(以毫秒为单位)。

更新:如果你想让中心保持不变,改变你的圆变形的边界,而不是范围:

step
   self bounds: ((self bounds) expandBy: 1).
   (self extent) > (200@200) ifTrue: [ self stopStepping ]

https://stackoverflow.com/questions/12184484/

相关文章:

c# - 向 XElement 添加空白行以保留其他格式

c# - 是否可以在 MS Access 中执行批量插入

web-applications - 在 Servlet 中获取 Web 应用程序名称

cassandra - 如何将两个 Cassandra 集群合并为一个?

c# - 哪个类需要实现 INotifyDataErrorInfo?

export-to-excel - SSIS导出到excel

php - 使用ghostscript输出文件目录

c# - XML Serializer 不序列化具有公共(public) getter 但没有 se

regex - 允许方括号的正则表达式

quartz-scheduler - 使用简单的xml来驱动Quartz Scheduler