Skip to content

Easing functions implemented in C for embedded MCU applications

Notifications You must be signed in to change notification settings

mnemocron/easing-functions

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Easing functions C++

30 easing functions implemented in C++.
More info how functions look like and their behaviour on easings.net.

How to use

Include h-file.

#include "easing.h"

After that there are two ways:

  1. Just call one of the 30 implemented functions:

     easeInSine( 0.5 );
    
  2. Or to make functions calls more unified, you can use the help-function (getEasingFunction) to get the pointer to the needed function and call it:

     auto easingFunction = getEasingFunction( EaseInExpo );
     double progress = easingFunction( 0.5 );	// 0.058
    
     easingFunction = getEasingFunction( EaseOutQuint );
     progress = easingFunction( 0.5 );	//0.968
    

Function that returns needed pointer has the following definition:

typedef double(*easingFunction)(double);
easingFunction getEasingFunction( easing_functions function );

And accept one the enums:

enum easing_functions
{
  EaseInSine,
	EaseOutSine,
	EaseInOutSine,
	EaseInQuad,
	EaseOutQuad,
	EaseInOutQuad,
	EaseInCubic,
	EaseOutCubic,
	EaseInOutCubic,
	EaseInQuart,
	EaseOutQuart,
	EaseInOutQuart,
	EaseInQuint,
	EaseOutQuint,
	EaseInOutQuint,
	EaseInExpo,
	EaseOutExpo,
	EaseInOutExpo,
	EaseInCirc,
	EaseOutCirc,
	EaseInOutCirc,
	EaseInBack,
	EaseOutBack,
	EaseInOutBack,
	EaseInElastic,
	EaseOutElastic,
	EaseInOutElastic,
	EaseInBounce,
	EaseOutBounce,
	EaseInOutBounce
};

About

Easing functions implemented in C for embedded MCU applications

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Languages

  • C 100.0%