Introduction
anim is a modern C++20 library for creating, managing, and evaluating animation curves built from keyframes and cubic Bézier interpolation.
Core concepts
AnimationA named container that owns a set of
anim::Channelcurves and is the only way to create them. It also carries an overall time range used for sampling.ChannelA named, time-ordered sequence of keyframes that can be evaluated as a curve. Each channel has a unique, immutable
anim::Idthat survives copies. Channels keep their keyframes sorted by time and apply the appropriate handle constraints automatically.KeyframeA value at a point in time, plus the data needed to interpolate towards its neighbours: an interpolation
anim::Function, aanim::HandleMode, and two Bézier handles.PointThe fundamental
(time, value)coordinate type. It doubles as a 2D vector via theanim::Vectoralias.
Interpolation and handles
Each keyframe chooses how the segment leaving it is interpolated via
anim::Function:
Constant— hold the value until the next keyframe (step)Linear— straight-line interpolationBezier— cubic Bézier interpolation driven by the handles
For Bézier segments, anim::HandleMode controls how the handles are
computed and constrained — from fully automatic (Smooth) through aligned
variants (Aligned, AlignStrict, AlignFlex, AlignAdjustable) to
fully manual (Free).
Extending beyond the range
Times outside a channel’s keyframe range are resolved per
anim::Extend, set independently for the start and end:
Hold— clamp to the nearest end valueRepeat— loop the range periodicallyMirror— ping-pong the range