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

◆ stepped

detail::steppedEasing stepped {}
inlineconstexpr

Stepped easing that holds the start value until the keyframe completes.

The stepped easing function returns the starting value throughout the entire duration of the keyframe segment, only jumping to the target value when moving to the next keyframe. This creates instant transitions between keyframes without any interpolation within each segment.

Characteristics:

  • No interpolation within keyframe segments
  • Holds start value until keyframe ends
  • Instant jumps between keyframes
  • Creates discrete, stair-step motion

This easing is ideal for:

  • Discrete state transitions: Values that shouldn't interpolate smoothly
  • Keyframe-based animations: Step through distinct poses or states
  • Frame-by-frame effects: Hold each frame without blending
  • Boolean-like values: Properties that need instant changes
  • Sprite switching: Change sprites at keyframe boundaries
  • Cut transitions: Instant changes without fading

Stepped is fundamentally different from other easings because it eliminates interpolation entirely within each keyframe segment, creating hard cuts between animation states.

// Hold value at each keyframe, jump instantly between them
auto value = tweeny::from(0)
.to(10).via(easing::stepped).during(100U)
.to(20).via(easing::stepped).during(100U)
.to(30).via(easing::stepped).during(100U)
.build();
// During frames 0-99: returns 0
// During frames 100-199: returns 10
// During frames 200-299: returns 20
// At frame 300: returns 30
// Useful for sprite animation indices
auto spriteIndex = tweeny::from(0)
.to(1).via(easing::stepped).during(10U)
.to(2).via(easing::stepped).during(10U)
.to(3).via(easing::stepped).during(10U)
.build();
// Holds each sprite index for 10 frames, then instantly switches
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::steppedEasing stepped
Stepped easing that holds the start value until the keyframe completes.
Definition easing.h:1465
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
See also
linear For smooth constant-velocity interpolation