CoreComponents 3.0.0
A Modern C++ Toolkit
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages Modules
Easing Class Reference

Easing curves More...

#include <cc/Easing>

Classes

class  Bezier
 Cubic Bezier curve. More...
 

Public Member Functions

template<class T >
 Easing (Property< T > &property, const EasingCurve &curve, double duration, Function< bool()> &&direct=nullptr)
 Setup easing behavior for a property.
 

Static Public Member Functions

static double Linear (double t)
 $f(t)=t$
 
static double InQuad (double t)
 $f(t)=t^2$
 
static double OutQuad (double t)
 $f(t)=-t^2+2t$
 
static double InOutQuad (double t)
 $f(t) = \begin{cases}
t<=0.5 & 2t^2\\
t>0.5  & -2t^2+4t-1
\end{cases}$
 
static double InCubic (double t)
 $f(t)=t^3$
 
static double OutCubic (double t)
 $f(t)=t^3-3t^2+3t$
 
static double InOutCubic (double t)
 $f(t) = \begin{cases}
t<=0.5 & 4t^3\\
t>0.5  & 4t^3-12t^2+12t-3
\end{cases}$
 
static double InQuart (double t)
 $f(t)=t^4$
 
static double OutQuart (double t)
 $f(t)=t^4+4t^3-6t^2+4t$
 
static double InOutQuart (double t)
 $f(t) = \begin{cases}
t<=0.5 & 8t^3\\
t>0.5  & -8t^4+32t^3-48t^2+32t-7
\end{cases}$
 
static double InQuint (double t)
 $f(t)=t^5$
 
static double OutQuint (double t)
 $f(t)=t^5-4t^4+10t^3-10t^2+5t$
 
static double InOutQuint (double t)
 $f(t) = \begin{cases}
t<=0.5 & 16t^5\\
t>0.5  & 16t^5-80t^4+160t^3-160t^2+80t-15
\end{cases}$
 
static double InSine (double t)
 $f(t)=\sin(2\pi(t-1))+1$
 
static double OutSine (double t)
 $f(t)=\sin(2\pi t)$
 
static double InOutSine (double t)
 $f(t)=\frac{1}{2}(1-\cos(\pi t))$
 
static double InCirc (double t)
 $f(t)=1-\sqrt{1-t^2}$
 
static double OutCirc (double t)
 $f(t)=\sqrt{2t-t^2}$
 
static double InOutCirc (double t)
 $f(t)=\frac{1}{2}-\frac{1}{2}\sqrt{1-4t^2}$
 
static double InExpo (double t)
 $f(t) = \begin{cases}
t\neq 0 & 2^{10t-10}\\
t=0 & 0
\end{cases}$
 
static double OutExpo (double t)
 $f(t) = \begin{cases}
t\neq 1 & 1-2^{-10t}\\
t=1 & 1
\end{cases}$
 
static double InOutExpo (double t)
 $f(t) = \begin{cases}
t=0\vee t=1 & t\\
t<=0.5 & \frac{1}{2}2^{20t-10}\\
t>0.5 & 1-\frac{1}{2}2^{-20t+10}
\end{cases}$
 
static double InElastic (double t)
 $f(t)=\sin(26\pi t)2^{10t-10}$
 
static double OutElastic (double t)
 $f(t)=\sin(-26\pi (t + 1))2^{-10t} + 1$
 
static double InOutElastic (double t)
 $f(t) = \begin{cases}
t<=0.5 & \frac{1}{2}\sin(52\pi t)2^{20t-10}\\
t>0.5  & \frac{1}{2}\sin(-52\pi t)2^{-20t+10}+1
\end{cases}$
 
static double InBack (double t)
 $f(t)=t^3-t\sin(\pi t)$
 
static double OutBack (double t)
 $f(t)=t^3-2t^2+3t-(1-t)\sin(\pi(1-t))$
 
static double InOutBack (double t)
 $f(t) = \begin{cases}
t<=0.5 & 4t^3-2t\sin(2\pi t)\\
t>0.5  & (t^3-3t^2+t-2)\sin(-2\pi(t-1))
\end{cases}$
 
static double InBounce (double t)
 $f(t)=1-OutBounce(1-t)$
 
static double OutBounce (double t)
 $f(t) = \begin{cases}
0<=t<=\frac{4}{11}           & \frac{121}{16}t^2 \\
\frac{4}{11}<t<=\frac{8}{11} & \frac{363}{40}t^2 - \frac{99}{10}t + \frac{17}{5}\\
\frac{8}{11}<t<=\frac{9}{10} & \frac{4356}{361}t^2 - \frac{35442}{1805}t + \frac{16061}{1805}\\
\frac{9}{10}<t               & \frac{54}{5}t^2 - \frac{513}{25}t + \frac{268}{25}\\
\end{cases}$
 
static double InOutBounce (double t)
 $f(t) = \begin{cases}
t<=0.5 & \frac{1}{2}InBounce(2t)\\
t>0.5  & \frac{1}{2}OutBounce(2t-1)+\frac{1}{2}\\
\end{cases}$
 

Detailed Description

Easing curves

Todo
Visualize and tune the easing functions

Constructor & Destructor Documentation

◆ Easing()

template<class T >
Easing ( Property< T > & property,
const EasingCurve & curve,
double duration,
Function< bool()> && direct = nullptr )

Setup easing behavior for a property.

Parameters
propertyProperty for which to ease value changes
curveEasing curve to apply
durationDuration of the transition in seconds
directPass a function to decide when to omit easing and go for direct property transition
Template Parameters
TProperty value type

Member Function Documentation

◆ Linear()

double Linear ( double t)
static

$f(t)=t$

◆ InQuad()

double InQuad ( double t)
static

$f(t)=t^2$

◆ OutQuad()

double OutQuad ( double t)
static

$f(t)=-t^2+2t$

◆ InOutQuad()

double InOutQuad ( double t)
static

$f(t) = \begin{cases}
t<=0.5 & 2t^2\\
t>0.5  & -2t^2+4t-1
\end{cases}$

◆ InCubic()

double InCubic ( double t)
static

$f(t)=t^3$

◆ OutCubic()

double OutCubic ( double t)
static

$f(t)=t^3-3t^2+3t$

◆ InOutCubic()

double InOutCubic ( double t)
static

$f(t) = \begin{cases}
t<=0.5 & 4t^3\\
t>0.5  & 4t^3-12t^2+12t-3
\end{cases}$

◆ InQuart()

double InQuart ( double t)
static

$f(t)=t^4$

◆ OutQuart()

double OutQuart ( double t)
static

$f(t)=t^4+4t^3-6t^2+4t$

◆ InOutQuart()

double InOutQuart ( double t)
static

$f(t) = \begin{cases}
t<=0.5 & 8t^3\\
t>0.5  & -8t^4+32t^3-48t^2+32t-7
\end{cases}$

◆ InQuint()

double InQuint ( double t)
static

$f(t)=t^5$

◆ OutQuint()

double OutQuint ( double t)
static

$f(t)=t^5-4t^4+10t^3-10t^2+5t$

◆ InOutQuint()

double InOutQuint ( double t)
static

$f(t) = \begin{cases}
t<=0.5 & 16t^5\\
t>0.5  & 16t^5-80t^4+160t^3-160t^2+80t-15
\end{cases}$

◆ InSine()

double InSine ( double t)
static

$f(t)=\sin(2\pi(t-1))+1$

◆ OutSine()

double OutSine ( double t)
static

$f(t)=\sin(2\pi t)$

◆ InOutSine()

double InOutSine ( double t)
static

$f(t)=\frac{1}{2}(1-\cos(\pi t))$

◆ InCirc()

double InCirc ( double t)
static

$f(t)=1-\sqrt{1-t^2}$

◆ OutCirc()

double OutCirc ( double t)
static

$f(t)=\sqrt{2t-t^2}$

◆ InOutCirc()

double InOutCirc ( double t)
static

$f(t)=\frac{1}{2}-\frac{1}{2}\sqrt{1-4t^2}$

◆ InExpo()

double InExpo ( double t)
static

$f(t) = \begin{cases}
t\neq 0 & 2^{10t-10}\\
t=0 & 0
\end{cases}$

◆ OutExpo()

double OutExpo ( double t)
static

$f(t) = \begin{cases}
t\neq 1 & 1-2^{-10t}\\
t=1 & 1
\end{cases}$

◆ InOutExpo()

double InOutExpo ( double t)
static

$f(t) = \begin{cases}
t=0\vee t=1 & t\\
t<=0.5 & \frac{1}{2}2^{20t-10}\\
t>0.5 & 1-\frac{1}{2}2^{-20t+10}
\end{cases}$

◆ InElastic()

double InElastic ( double t)
static

$f(t)=\sin(26\pi t)2^{10t-10}$

◆ OutElastic()

double OutElastic ( double t)
static

$f(t)=\sin(-26\pi (t + 1))2^{-10t} + 1$

◆ InOutElastic()

double InOutElastic ( double t)
static

$f(t) = \begin{cases}
t<=0.5 & \frac{1}{2}\sin(52\pi t)2^{20t-10}\\
t>0.5  & \frac{1}{2}\sin(-52\pi t)2^{-20t+10}+1
\end{cases}$

◆ InBack()

double InBack ( double t)
static

$f(t)=t^3-t\sin(\pi t)$

◆ OutBack()

double OutBack ( double t)
static

$f(t)=t^3-2t^2+3t-(1-t)\sin(\pi(1-t))$

◆ InOutBack()

double InOutBack ( double t)
static

$f(t) = \begin{cases}
t<=0.5 & 4t^3-2t\sin(2\pi t)\\
t>0.5  & (t^3-3t^2+t-2)\sin(-2\pi(t-1))
\end{cases}$

◆ InBounce()

double InBounce ( double t)
static

$f(t)=1-OutBounce(1-t)$

◆ OutBounce()

double OutBounce ( double t)
static

$f(t) = \begin{cases}
0<=t<=\frac{4}{11}           & \frac{121}{16}t^2 \\
\frac{4}{11}<t<=\frac{8}{11} & \frac{363}{40}t^2 - \frac{99}{10}t + \frac{17}{5}\\
\frac{8}{11}<t<=\frac{9}{10} & \frac{4356}{361}t^2 - \frac{35442}{1805}t + \frac{16061}{1805}\\
\frac{9}{10}<t               & \frac{54}{5}t^2 - \frac{513}{25}t + \frac{268}{25}\\
\end{cases}$

◆ InOutBounce()

double InOutBounce ( double t)
static

$f(t) = \begin{cases}
t<=0.5 & \frac{1}{2}InBounce(2t)\\
t>0.5  & \frac{1}{2}OutBounce(2t-1)+\frac{1}{2}\\
\end{cases}$