language: C++ 4.7.2 (gcc-4.7.2)
date: 84 days 4 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//These functions assume 'position' is of the _scale_ (0.0 to 1.0), though they can be outside that _range_.
 
//For consistency, this 'Coverts' an EaseIn function to... an EaseIn function. It doesn't actually do anything.
inline float DoEaseIn(EaseFunction easeFunction, float position) { return easeFunction(position); }
 
//Converts a EaseIn function to an EaseOut function.
float DoEaseOut(EaseFunction easeFunction, float position)
{
    float result = easeFunction(1.0f - position);
    return (1.0f - result);
}
 
//Converts a EaseIn function to an EaseInOut function.
float DoEaseInOut(EaseFunction easeFunction, float position)
{
    //If less than halfway, Ease-In.
    if(position < 0.5f)
    {
        //Doubles the positon to scales it from (0.0 - 0.5) to (0.0 - 1.0)
        float result = easeFunction(position * 2.0f); 
        
        //Scale to (0.0 - 0.5), by halfing the result.
        return (result * 0.5f);
    }
    //If more than halfway, Ease-Out.
    else
    {
        //Scales the position from (0.5 - 1.0) to (0.0 - 1.0)
        float result = DoEaseOut(easeFunction, (position * 2.0f) - 1.0f);
        
        //Scale to (0.5 - 1.0), by halfing the result and then adding half.
        return (result * 0.5f) + 0.5f;
    }
}
 
//Converts an EaseIn function to an EaseOutIn function. 
float DoEaseOutIn(EaseFunction easeFunction, float position)
{
    //If less than halfway, Ease-Out.
    if(position < 0.5f)
    {
        //Doubles the positon to scales it from (0.0 - 0.5) to (0.0 - 1.0)
        float result = DoEaseOut(easeFunction, position * 2.0f);
        
        //Scale to (0.0 - 0.5), by halfing the result.
        return (result * 0.5f);
    }
    //If more than halfway, Ease-In.
    else
    {
        //Scales the position from (0.5 - 1.0) to (0.0 - 1.0)
        float result = easeFunction((position * 2.0f) - 1.0f);
        
        //Scale to (0.5 - 1.0), by halfing the result and then adding half.
        return (result * 0.5f) + 0.5f;
    }
}