Tweeny 4.1.0
A Tweening library for modern C++
Loading...
Searching...
No Matches

◆ linear

detail::linearEasing linear {}
inlineconstexpr

Linear easing function with constant velocity throughout the animation.

The linear easing function produces uniform motion with no acceleration or deceleration. The interpolation progresses at a constant rate from start to finish, creating mechanical, predictable movement.

Linear easing is characterized by:

  • Constant velocity: the rate of change never varies
  • No ease-in or ease-out: motion starts and stops abruptly
  • Simple mathematical relationship: output = start + (end - start) * progress
  • Predictable timing: halfway through time means halfway through distance

This easing is appropriate for:

  • Mechanical objects: Conveyor belts, pistons, automated systems
  • Progress indicators: Loading bars, timers, countdowns
  • Continuous loops: Rotating objects, scrolling backgrounds
  • Data visualization: Graph animations where consistency is important
  • Debug and testing: Predictable behavior for verification

Linear easing is generally not recommended for most UI animations because:

  • Lacks the natural feel of acceleration/deceleration
  • Abrupt starts and stops can feel jarring
  • Missing visual polish that easing provides
  • Human perception expects objects to ease into and out of motion

However, it serves as the foundation for all other easing functions and is essential when mechanical precision is more important than natural motion feel.

Mathematically, this implements: f(t) = t where t is normalized progress [0, 1].

// Constant velocity scrolling background
auto scroll = tweeny::from(0.0f)
.to(1000.0f)
.during(600U)
.build();
// Progress indicator that matches time exactly
auto progress = tweeny::from(0)
.to(100)
.during(100U)
.build();
// At frame 50, progress will be exactly 50
tweeny_builder< true, FirstValue, RemainingValues... > to(const FirstValue &firstComponent, const RemainingValues &... remainingComponents) &
Adds a target keyframe to the tween.
Definition tweeny.h:109
tweeny_builder & via(EasingFunctionTypes... easing_functions)
Specifies per-component easing functions for the last keyframe segment.
Definition tweeny.h:198
constexpr detail::linearEasing linear
Linear easing function with constant velocity throughout the animation.
Definition easing.h:956
tweeny_builder< false, FirstValue, RemainingValues... > from(FirstValue firstComponent, RemainingValues... remainingComponents)
Creates a new tween builder starting from the specified value(s).
Definition tweeny.h:347
Note
Linear is the default easing when no via() is specified, though using def is more explicit in code.
See also
def Alias for linear easing
quadraticInOut For a gentle alternative with ease-in and ease-out
sinusoidalInOut For smooth, natural-feeling motion