|
|
|
If you
are using animation to move some object around, you may want it to follow a
more complex path than a straightforward move from one point to another. You
could achieve this by stringing together a sequence of animations one after
the other. However, the Key Frame Animation types provide a way of specifying
a series of points at various offsets into the animation. The value will be
interpolated between these.
|
|
|
|
This
approach is named after a common technique in conventional animation. An
animated scene will typically have the most important frames drawn first –
these ‘key frames’ will define the basic flow and character of the animation.
Once these are defined, the remaining frames are drawn by interpolating
between key frames. In WPF, you can define these key frames and let the
animation system perform the interpolation for you. Note that this is
somewhat different from conventional animation key frames – you do not get to
provide two complete drawings, and have the system interpolate between these
– you are still just modifying property values on a single scene. WPF has no
built-in way of ‘morphing’ from one shape to another automatically.
|
|
|
|
Key
frame animations can use either linear or spline interpolation. Linear
interpolation just moves values at constant speed between any two key frames.
This results in rather stilted and jagged motion. Using splines lets you
smooth things out a little. Splines are a little tricky to get used to – you
are not simply defining a curve for an object to follow – splines are used at
the level of individual properties, so you might specify a spline defining
how just the X coordinate behaves! The curve defined by the spline is
actually a curve in the graph representing space vs time. This allows you to
control the acceleration and deceleration. (By controlling acceleration and
deceleration of X and Y coordinates independently, it is possible to
introduce curved motion.)
|