Struct Keyframe

Struct Documentation

struct Keyframe

A single control point on an animation curve.

A keyframe is a value at a point in time together with the data needed to interpolate towards its neighbours: the interpolation Function, the HandleMode, and the two Bézier handles. The handles are only used when the function is Function::Bezier.

Keyframes are value types: they can be constructed, copied and compared freely. To place a keyframe in a channel (which keeps them time-sorted and applies handle constraints) use Channel::create_keyframe.

Public Functions

inline Keyframe(const Point &position, Function function = Function::Bezier, HandleMode handle_mode = HandleMode::Smooth, const Point &in_handle = Point(), const Point &out_handle = Point())

Constructs a keyframe from a position point.

Parameters:
  • position – The (time, value) position.

  • function – Interpolation function (default Function::Bezier).

  • handle_mode – Handle mode (default HandleMode::Smooth).

  • in_handle – Incoming handle (defaults to the origin).

  • out_handle – Outgoing handle (defaults to the origin).

inline Keyframe(double time, double value, Function function = Function::Bezier, HandleMode handle_mode = HandleMode::Smooth, const Point &in_handle = Point(), const Point &out_handle = Point())

Constructs a keyframe from a time and value.

Parameters:
  • time – Time component of the position.

  • value – Value component of the position.

  • function – Interpolation function (default Function::Bezier).

  • handle_mode – Handle mode (default HandleMode::Smooth).

  • in_handle – Incoming handle (defaults to the origin).

  • out_handle – Outgoing handle (defaults to the origin).

inline Keyframe()

Constructs a default keyframe at the origin (Bézier / Smooth).

inline Keyframe(const Keyframe &other) = default
inline Keyframe(Keyframe &&other) noexcept = default
inline Keyframe &operator=(const Keyframe &other) = default
inline Keyframe &operator=(Keyframe &&other) noexcept = default
inline bool operator==(const Keyframe &other) const

Equality across position, both handles, function and handle mode.

inline bool operator!=(const Keyframe &other) const

Negation of operator==.

inline double time() const

Convenience accessor for the position’s time component.

inline double value() const

Convenience accessor for the position’s value component.

Public Members

Point position

The keyframe’s (time, value) position.

Point in_handle

Incoming Bézier handle (controls the curve arriving from the previous keyframe).

Point out_handle

Outgoing Bézier handle (controls the curve leaving towards the next keyframe).

Function function

Interpolation function for the segment starting at this keyframe.

HandleMode handle_mode

How the handles are computed and constrained.