Skip to content

saeedmfarahani/easing-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Easing Functions (ease.h)

A single-header C++17 library providing a comprehensive collection of easing functions for animations, interpolation, and smooth transitions.

Easing functions map a normalized time parameter (t in [0.0, 1.0]) into a transformed value, controlling acceleration, deceleration, bounce, and overshoot effects. They are widely used in UI animations, games, and motion design.


✨ Features

  • Header-only (ease.h) – just drop it into your project.
  • Wide variety of easing functions:
    • Linear
    • Quadratic, Cubic, Quartic, Quintic
    • Sine, Exponential, Circular
    • Elastic, Back, Bounce
  • In, Out, InOut variants for each type.
  • Customizable parameters for Elastic and Back easing.
  • constexpr support for compile-time evaluation where possible.
  • No dependencies beyond the C++ standard library.

πŸ“₯ Installation

Clone or copy ease.h into your project:

git clone https://github.com/yourusername/ease.h.git

Include it in your code:

#include "ease.h"

No build system integration required.


πŸš€ Usage Example

#include <iostream>
#include "ease.h"

int main() {
    double t = 0.3; // normalized time

    double v1 = Ease::inQuad(t);    // ease-in quadratic
    double v2 = Ease::outBounce(t); // ease-out bounce

    std::cout << "inQuad(0.3)   = " << v1 << "\n";
    std::cout << "outBounce(0.3)= " << v2 << "\n";
}

Output:

inQuad(0.3)   = 0.09
outBounce(0.3)= 0.680625

πŸ“š Reference

Each function accepts a normalized time value t ∈ [0.0, 1.0].

  • Linear linear(t) – straight interpolation.

  • Quadratic / Cubic / Quartic / Quintic inQuad(t), outQuad(t), inOutQuad(t) … up to inOutQuint(t).

  • Sine inSine(t), outSine(t), inOutSine(t).

  • Exponential inExpo(t), outExpo(t), inOutExpo(t).

  • Circular inCirc(t), outCirc(t), inOutCirc(t).

  • Elastic (with amplitude a and period p) inElastic(t, a, p), outElastic(t, a, p), inOutElastic(t, a, p).

  • Back (with overshoot parameter s) inBack(t, s), outBack(t, s), inOutBack(t, s).

  • Bounce inBounce(t), outBounce(t), inOutBounce(t).


πŸ›  Requirements

  • C++17 or newer
  • A standard-compliant compiler (GCC, Clang, MSVC, etc.)

πŸ“„ License

This project is licensed under the MIT License – see LICENSE for details.

About

easing class for cpp

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages