Graphics Reference
In-Depth Information
10
In life, as in art, the beautiful moves in curves.
Edward G. Bulwer-Lytton
In Chapter 9, “Layer Time,” we discussed animation timing and the
CAMediaTiming
protocol. We now look at another time-related mechanism—a system known as
easing.
Core Animation uses easing to make animations move smoothly and naturally instead of
seeming robotic and artificial, and in this chapter we explore how to control and customize
the easing curves for your animations.
Animation is the change of a value over time, and that implies that the change must happen
at a particular rate or
velocity.
The velocity of an animation is related to its duration by the
following equation:
velocity = change / time
The
change
would be (for example) the distance that a moving object travels, and the
time
is the duration of the animation. This is easier to visualize for an animation that involves
movement (such as animation of the
position
or
bounds
property), but it applies equally
to any animatable property (such as
color
or
opacity
).
The equation above assumes that the velocity is constant throughout the animation (which
was the case for the animations we created in Chapter 8, “Explicit Animations”). Using a
constant velocity for an animation is known as
linear pacing
, and it's the simplest way to
implement animation, from a technical standpoint. It's also
completely unrealistic.
Consider a car driving a short distance. It would not start at 60 mph, drive to the destination
and then immediately drop to 0 mph. For one thing, that would require infinite accelerating