[Grace-core] Digital clock as animation, Dancing box animations.

Andrew P. Black black at cs.pdx.edu
Tue Sep 3 18:30:11 PDT 2013


This is the DigitalClock class, an example class that I wrote to show the
students how to use animation in Pharo:
======
TextMorph subclass: #DigitalClock
...

step
self newContents: Time now asString
=======
That's it.  TextMorph already has the capability to display a text string
on the screen as a "Morph", a graphical Object.  The step method, which is
called by the display loop once per second, simply sets the contents of the
text morph to be the current time.

Here is the step method for one student's homework solution to the dancing
boxes problem:

*step*
"implements what needs to be done during a dance step"
| danceMove |
super step.
enableDancing ifTrue: [
danceMove := danceRoutine nextMove.
danceMove do:self.
]

This homework has all sorts of choreography built in: static and dynamic
dances, and so on.  danceRoutine was pluggable, as was the dance partner.
 Still, all the step method does is ask the dance routine for the next
move, and do it.  There is also a danceStep object, use to build the
danceRoutines; each danceStep is either a translation or a rotation.

The message is that there is no real limit to the complexity of the
animations that can be built upon this simple "step" and "stepTime"
interface.

     Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailhost.cecs.pdx.edu/pipermail/grace-core/attachments/20130903/c4098af0/attachment.html>


More information about the Grace-core mailing list