Keyframes specify poses at selected times; interpolation determines the motion between them. Inspect poses, timing curves and clip boundaries together.
1. Normalize time first
Let t1 > t0, with current time t. Compute normalised progress:
u = clamp((t - t0) / (t1 - t0), 0, 1)
Position, rotation, or scale can then use:
x(t) = x0 + (x1 - x0) f(u)
f(u) controls timing. It must at least satisfy f(0)=0 and f(1)=1. Zero endpoint velocity, overshoot, or elasticity depend on the intended motion.
2. Why linear interpolation feels mechanical
Linear timing has f(u)=u and segment velocity (x1-x0)/(t1-t0). Connecting it to a held pose causes a velocity jump; neighbouring linear segments with matching velocities can join continuously. Select the curve for the required motion.
3. Proving the endpoint behavior of smoothstep
A common ease-in-out function is:
f(u) = 3u^2 - 2u^3
f'(u) = 6u - 6u^2 = 6u(1-u)
Because f'(0)=0 and f'(1)=0, the motion comes to rest at both ends. At u=0.5, normalized velocity reaches 1.5. Ease-in-out is therefore not slower everywhere: it spends time accelerating and braking, so it must move faster through the middle.
4. Cubic Bezier curves and control handles
Animation curve editors commonly use a cubic Bezier:
B(u) = (1-u)^3 P0
+ 3(1-u)^2 u P1
+ 3(1-u)u^2 P2
+ u^3 P3
For a 2D Bezier curve B(q)=(X(q),Y(q)), solve X(q)=u for the time progress, then evaluate f(u)=Y(q). In general, q is not u. Endpoint timing slopes use dY/dX. CSS restricts control-point x coordinates to [0,1]; y coordinates can produce overshoot.
Time · Curves
Keyframes, Interpolation, and Easing
Compare linear, ease-in-out, and cubic Bezier curves through velocity and timing.
5. Frame-rate-independent playback
Accumulate elapsed time from a monotonic clock. The pseudocode requires consistent time units, duration > 0 and progress clamped to [0,1] before easing. Browser timestamps are generally in milliseconds:
elapsed += currentTime - previousTime
u = elapsed / duration
value = lerp(start, end, easing(u))
A deterministic time curve gives the same value at a specified timestamp regardless of render rate. Displays show values only on their refresh frames. Physics still requires an integration-step policy and a policy for catching up after a pause.
6. Coordinating multiple channels
Position, rotation, scale, and opacity do not need the same curve. During a jump, the body can accelerate while the arms anticipate earlier and the shadow scale lags behind. Natural motion often comes from phase offsets rather than every channel moving from 0 to 1 together.
Parent and child bones must still sample one timeline. Compute each local channel first, run forward kinematics through the hierarchy, and then deform the mesh with skinning weights.
7. Animation review checklist
- Do important poses land on intentional frame times rather than approximate curve handles?
- Does velocity approach zero where the character should visibly settle?
- Does overshoot express material and weight instead of appearing on every channel?
- Does the action finish at the same time under a low frame rate?
- Do bones, masks, and attachments share the same time base?
8. Inspect the curve with fixed samples
Sampling an easing function at fixed progress values exposes wrong endpoints, non-monotonic segments, and accidental overshoot. Linear timing and smoothstep compare as follows:
| u | Linear f(u) | Smoothstep f(u) | Smoothstep f'(u) | Meaning |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | Starts at rest |
| 0.25 | 0.25 | 0.15625 | 1.125 | Position lags while speed rises |
| 0.5 | 0.5 | 0.5 | 1.5 | Maximum speed at the midpoint |
| 0.75 | 0.75 | 0.84375 | 1.125 | Position leads while speed falls |
| 1 | 1 | 1 | 0 | Stops at the destination |
For a custom Bezier or bounce function, check f(0), f(1), monotonicity, and the allowed minimum and maximum. Position channels usually should not move to negative progress. When scale or joint angles allow overshoot, bound it explicitly so one curve handle cannot flip or intersect the character.
Velocity and acceleration at clip boundaries
We showed that smoothstep’s first derivative vanishes at both ends, so motion settles naturally. But if two clips play back to back — a character raises an arm and immediately waves — a vanishing first derivative is not enough.
Look at the second derivative:
f(u) = 3u^2 - 2u^3
f'(u) = 6u - 6u^2
f''(u) = 6 - 12u
f''(0) = 6 f''(1) = -6
The normalised second derivative is +6 at the start and −6 at the end. Actual acceleration also includes displacement and duration: the first clip ends at -6*Δx1/T1², and the next starts at 6*Δx2/T2². These can match or differ.
For a visible hitch, compare world-space position, velocity and acceleration at the join, then inspect playback. Smoothstep reaches zero endpoint velocity; appearance depends on displacement, duration and the following clip.
When second-order continuity matters, use the quintic version, usually called smootherstep:
g(u) = 6u^5 - 15u^4 + 10u^3
g'(u) = 30u^4 - 60u^3 + 30u^2 = 30u^2(1-u)^2
g''(u) = 120u^3 - 180u^2 + 60u
g'(0) = g'(1) = 0 g''(0) = g''(1) = 0
Both first and second derivatives vanish at the ends, so acceleration is continuous across the seam. The cost is that midpoint speed rises from 1.5 to 1.875 — in the same duration, the middle has to travel faster to repay the time given to starting and stopping. So smootherstep is not simply “smoother and therefore better”; it reallocates more of the time budget to the ends, and the middle of the motion reads faster.
Smootherstep supports a rest-to-rest join with zero acceleration when endpoint positions agree. To pass through at nonzero velocity, match velocity and acceleration across segments, for example with a Hermite construction that enforces those conditions.
Drive held drawings from elapsed time
Real time can also drive held drawings: compute playback time, then select a drawing or pose using its hold interval.
Traditional animation frequently works “on twos” — at 24 fps each drawing is held for two frames, so there are only 12 distinct images per second. This cadence is also a stylistic choice. The step between drawings is itself part of what makes the action feel crisp, and plenty of stylised 2D work preserves it deliberately.
Continuous curve sampling produces continuous poses at render times. Preserve a held-drawing cadence by storing hold intervals or quantising sample time explicitly.
The remedy is to quantise time rather than values:
STEP = 1.0 / 12.0 # intended drawing rate
t_quantized = floor(elapsed / STEP) * STEP
u = t_quantized / duration
value = lerp(start, end, easing(u))
At a 12 Hz pose rate, the logical pose changes at most every 1/12 second. A 60 or 144 Hz renderer displays it on its next frame; dropped frames can skip poses. Clamp u and explicitly set the endpoint when elapsed >= duration, especially if duration is not a multiple of the step.
The essential part is that this quantisation must be switchable per channel. The character body goes on twos while camera moves and fades usually need to stay continuous; quantise the whole scene together and the camera looks like it is stuttering. Which is why cadence belongs as a property of a channel rather than a global setting on the player.
Spline overshoot and shape-preserving interpolation
Everything above concerned two keyframes. With three or more the situation changes: the usual approach is not independent easing per segment but a spline fitted through every keyframe so the whole curve is smooth. That introduces a new problem.
Catmull–Rom estimates tangents from neighbouring keys. A nonzero tangent at a local extremum can produce overshoot; symmetric neighbours or other configurations need not do so.
Concretely: the animator set the contact frame’s y to exactly floor height, and on playback the foot sinks a few pixels into the floor before springing back. Inspecting the keyframes shows correct values throughout, because what is wrong is the curve between them.
Interpolation passes through its nodes; values between them depend on tangent rules. Shape-preserving splines can additionally constrain overshoot.
Use a monotonicity-preserving cubic Hermite method when needed. The retained snippet illustrates an interior-tangent limiter and requires strictly increasing x. A complete method also handles endpoint derivatives and checks each interval. See PCHIP, whose derivative rules differ from this simplified code.
# secant slopes of the two adjacent segments
d0 = (y[i] - y[i-1]) / (x[i] - x[i-1])
d1 = (y[i+1] - y[i]) / (x[i+1] - x[i])
if d0 * d1 <= 0:
m[i] = 0.0 # local extremum, zero the tangent
else:
m[i] = min(abs(m[i]), 3 * abs(d0), 3 * abs(d1)) * sign(d0)
Shape-preserving cubic interpolation can be C1 while second derivatives jump at nodes. For floor contact or bounded opacity, evaluate the required range against acceleration continuity.
Apply shape-preserving limits where a channel must stay within bounds. Joint angles may also have anatomical or rig constraints. For recoil, specify the allowed overshoot range per channel.
9. Angle interpolation and frame-rate tests
For shortest-path rotation, wrap the difference into [-180°,180°). From 350° to 10°, the shortest difference is +20°. Full turns require unwrapped angles, and a 180° tie needs a direction convention:
delta = ((target - start + 180) mod 360) - 180
angle = start + delta * f(u)
Call the sampler directly at synthetic timestamps 0, 200, 400, 600 and 800 ms under simulated 60 Hz, 120 Hz and skipped frames. Actual display frames need not land on those timestamps, so record function-value checks separately from visual playback.
10. Connect the four principles into one pipeline
The complete order is: layered assets define parts and pivots, bone matrices propagate pose, IK solves angles from targets, skinning closes joint gaps, and keyframe curves control time. Return to the 2D Animation Principles hub to review every interactive demo in order.