Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Iterating through Diameter of a Circle Morph

I have a CircleMorph and I want to extend its diameter, possibly to create a small animation with it.

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

Would it be good if I used a loop or the step method to do this? If you recommend the step method, then how do I do that?

like image 515
Irfan Avatar asked Jan 22 '26 07:01

Irfan


1 Answers

You might make a subclass of CircleMorph called GrowingCircleMorph. Then implement step:

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

Now if you open an instance of your new GrowingCircleMorph in the World it will start growing up to 201@201.

To change the speed, implement stepTime and return the desired time between steps in milliseconds.

update: if you want the center to stay the same, change the bounds of your circle morph, not the extent:

step
   self bounds: ((self bounds) expandBy: 1).
   (self extent) > (200@200) ifTrue: [ self stopStepping ]
like image 64
Helene Bilbo Avatar answered Jan 23 '26 19:01

Helene Bilbo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!