language: C++ 4.7.2 (gcc-4.7.2)
date: 80 days 7 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include "Easer.h"
 
//Sets 'position' to 'newPosition'.
void Easer::SetPosition(float position)
{
    this->Position = position;
}
 
//Resets 'position' to 0.0f. This is the same as calling SetPosition(0.0f);
void Easer::Reset()
{
    this->Position = 0.0f;
}
 
//Returns true if 'position' is at or beyond 1.0f.
bool Easer::AtEnd() const
{
    return (this->Position >= 1.0f);
}
 
//Returns the value at the current position.
//(Note: Unless constrained, the actual result may actually drop below 0.0f or above 1.0f depending
//on the easing function. This is intentional, and desirable for some effects)
float Easer::Get() const
{
    return this->plot(this->Position);
}
 
//Returns the value at the current position, scaled to the range of 'min' to 'max' instead of around (0.0f - 1.0f)-ish
float Easer::GetInRange(const FloatRange &range) const
{
    float value = this->plot(this->Position);
    return range.GetAt(value);
}
 
//Returns the value at 'pos'.
float Easer::GetAt(float pos) const
{
    return this->plot(pos);
}
 
//Returns the value at 'pos', scaled to the range of 'min' to 'max' instead of around (0.0f - 1.0f)-ish
float Easer::GetInRangeAt(float pos, const FloatRange &range) const
{
    float value = this->plot(pos);
    return range.Constrained(value);
}
    
//Moves the position of the ease by 'amount'.
void Easer::Step(float amount)
{
    this->Position += amount;
}
 
//Same as Step().
void Easer::operator+=(float amount)
{
    this->Step(amount);
}
 
//Same as Step() with a negative amount.
void Easer::operator-=(float amount)
{
    this->Step(-amount);
}
 
//Same as SetPosition().
void Easer::operator=(float position)
{
    this->SetPosition(position);
}
 
//Same as Get()
float Easer::operator()() const
{
    return this->Get();
}
 
//Same as GetAt()
float Easer::operator()(float value) const
{
    return this->GetAt(value);
}
 
//Calls the virtual function 'plot' and processes the result depending on the EaseStyle.
float Easer::plot(float position) const
{
    //Binds 'position' from 0.0 to 1.0.
    //if(position > 1.0f) position = 1.0f;
    //if(position < 0.0f) position = 0.0f;
    
    float result;
    
    if(this->Style == EaseIn)
    {
        //Plots the position.
        result = this->EaseFunc(position);
    }
    else if(this->Style == EaseOut)
    {
        //Plots the position.
        result = DoEaseOut(this->EaseFunc, position);
    }
    else if(this->Style == EaseInOut)
    {
        //Plots the position.
        result = DoEaseInOut(this->EaseFunc, position);
    }
    else if(this->Style == EaseOutIn)
    {
        //Plots the position.
        result = DoEaseOutIn(this->EaseFunc, position);
    }
    
    //Constrains the result and returns.
    return this->Constaints.Constrained(result);
}
Easer.cpp