On this page:
animations
set-animations!
8.2

2.1 animation

 (require qtops/qualities/animation) package: qtops

The animation quality provides a thing with a list of animations the ability to execute them on a schedule. Typically, animations are triggered by scheduling them within the thing’s universe.

NOTE: things with the animation quality are assumed to exist within a universe.

procedure

(animations t)  procedure?

  t : procedure?
(animations)  list?
Returns a procedure which follows the second form, where the list is of the format described in set-animations!.

procedure

(set-animations! t)  procedure?

  t : procedure?
(set-animations! A)  void
  A : list?
Returns a procedure for t which accepts one argument, a list. Each item on the list is expected to take the following format:

(list symbol integer integer)

Where the symbol is a procedure that t has, that will be called when t’s animate procedure is called, the first integer is the frequency (in moments, a concept from the time quality.), and the second integer is the % chance of the procedure actually being called.

Alternatively, either or both integers can be a procedure, as long as those procedures return integers.

Examples:
> (define cedar
   (create-thing "cedar"
                 (list >>make-animation-procedures)))
> (cedar 'set-procedure! 'sway
         (λ ()
           (printf
            (cedar 'prerender-string
                   `(,name " sways in the wind.")))))
> (cedar 'add-animation! '(sway 1 50))
> (cedar 'animate~~)
> (cedar 'animate~~)
> (cedar 'animate~~)