On this page:
8.1 Pict Interoplations
fade-pict
fade-around-pict
slide-pict
8.2 Merging Animations
sequence-animations
reverse-animations
8.3 Stretching and Squashing Time
fast-start
fast-end
fast-edges
fast-middle
split-phase

8 Animation Helpers

These functions are designed to work with the slide constructors in slideshow/play.

8.1 Pict Interoplations

procedure

(fade-pict n p1 p2 [#:combine combine])  pict?

  n : (real-in 0.0 1.0)
  p1 : pict?
  p2 : pict?
  combine : (pict? pict? . -> . pict?) = cc-superimpose
Interpolates p1 and p2, where the result with n as 0.0 is p1, and the result with n as 1.0 is p2. For intermediate points, p1 fades out while p2 fades in as n changes from 0.0 to 1.0. At the same time, the width and height of the generated pict are intermediate between p1 and p2, and the relative baselines and last pict correspondingly morph within the bounding box.

The combine argument determines how p1 and p2 are aligned for morphing. For example, if p1 and p2 both contain multiple lines of text with the same line height but different number of lines, then using ctl-superimpose would keep the ascent line in a fixed location relative to the top of the resulting pict as the rest of the shape morphs around it.

procedure

(fade-around-pict n p1 make-p2)  pict?

  n : (real-in 0.0 1.0)
  p1 : pict?
  make-p2 : (pict? . -> . pict?)
Similar to fade-pict, but the target is not a fixed p2, but instead a function make-p2 that takes a laundered ghost of p1 and places it into a larger scene. Also, p1 does not fade out as n increases; instead, p1 is placed wherever its ghost appears in the result of make-p2.

For example,

(lambda (n)
  (fade-around-pict n
                    (code x)
                    (lambda (g) (code (+ #,x 1)))))

animates the wrapping of x with a (+ .... 1) form.

procedure

(slide-pict base p p-from p-to n)  pict?

  base : pict?
  p : pict?
  p-from : pict?
  p-to : pict?
  n : (real-in 0.0 1.0)
Pins p onto base, sliding from p-from to p-to (which are picts within base) as n goes from 0.0 to 1.0. The top-left locations of p-from and p-to determine the placement of the top-left of p.

The p-from and p-to picts are typically laundered ghosts of p within base, but they can be any picts within base.

8.2 Merging Animations

procedure

(sequence-animations gen ...)  (-> (real-in 0.0 1.0) pict?)

  gen : (-> (real-in 0.0 1.0) pict?)
Converts a list of gen functions into a single function that uses each gen in sequence.

procedure

(reverse-animations gen ...)  (-> (real-in 0.0 1.0) pict?)

  gen : (-> (real-in 0.0 1.0) pict?)
Converts a list of gen functions into a single function that run (sequence-animations gen ...) in reverse.

8.3 Stretching and Squashing Time

procedure

(fast-start n)  (real-in 0.0 1.0)

  n : (real-in 0.0 1.0)

procedure

(fast-end n)  (real-in 0.0 1.0)

  n : (real-in 0.0 1.0)

procedure

(fast-edges n)  (real-in 0.0 1.0)

  n : (real-in 0.0 1.0)

procedure

(fast-middle n)  (real-in 0.0 1.0)

  n : (real-in 0.0 1.0)
Monotonically but non-uniformly maps n with fixed points at 0.0 and 1.0.

The fast-start mapping is convex, so that

(slide-pict base p p1 p2 (fast-start n))

appears to move quickly away from p1 and then slowly as it approaches p2, assuming that n increases uniformly.

The fast-end mapping is concave, so that

(slide-pict base p p1 p2 (fast-end n))

appears to move slowly away from p1 and then quicly as it approaches p2, assuming that n increases uniformly.

The fast-edges mapping is convex at first and concave at the end, so that

(slide-pict base p p1 p2 (fast-edges n))

appears to move quickly away from p1, then more slowly, and then quickly again near p2, assuming that n increases uniformly.

The fast-middle mapping is concave at first and convex at the end, so that

(slide-pict base p p1 p2 (fast-middle n))

appears to move slowly away from p1, then more quickly, and then slowly again near p2, assuming that n increases uniformly.

procedure

(split-phase n)  
(real-in 0.0 1.0) (real-in 0.0 1.0)
  n : (real-in 0.0 1.0)
Splits the progression of n from 0.0 to 1.0 into a progression from (values 0.0 0.0) to (values 1.0 0.0) and then (values 1.0 0.0) to (values 1.0 1.0).