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

◆ elasticIn

detail::elasticInEasing elasticIn {}
inlineconstexpr

Elastic easing with oscillating spring-like motion at the start.

The elasticIn easing function creates a spring or elastic band effect that oscillates with increasing amplitude before reaching the starting point of the animation. The motion resembles pulling back an elastic band that vibrates as tension builds.

The oscillation characteristics:

  • Multiple back-and-forth swings before the main motion begins
  • Amplitude increases as the animation progresses
  • Creates a "winding up" or "charging" effect
  • More pronounced than backIn's single overshoot

This easing is particularly effective for:

  • Magical or fantasy effects: Spell charging, energy gathering
  • Exaggerated cartoon animations: Extreme anticipation and wind-up
  • Attention-grabbing entrances: Elements that need dramatic introduction
  • Game power-ups: Visual feedback for charging actions
  • Playful UI elements: Whimsical, high-energy interactions

The elastic effect is more dramatic than back easing, making it suitable for contexts where strong visual emphasis or entertainment value is desired. It's less appropriate for subtle or professional interfaces.

Mathematically, this uses a decaying sine wave with exponential amplitude growth.

Warning
This easing creates significant overshoot in both directions. Values will oscillate well beyond the start value in both positive and negative directions. Ensure your rendering system can handle these extreme values gracefully.
// Magical charging effect before an action
auto glow = tweeny::from(0.0f)
.to(1.0f)
.during(45U)
.build();
// The glow will oscillate negative before reaching 1.0f
// producing a "charging" visual effect
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::elasticInEasing elasticIn
Elastic easing with oscillating spring-like motion at the start.
Definition easing.h:618
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
elasticOut For spring-like oscillation at the end
elasticInOut For oscillation at both start and end
backIn For a simpler single-overshoot alternative
Visualize at https://easings.net/#easeInElastic