StelFader.hpp   StelFader.hpp 
skipping to change at line 23 skipping to change at line 23
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#ifndef _STELFADER_HPP_ #ifndef _STELFADER_HPP_
#define _STELFADER_HPP_ #define _STELFADER_HPP_
#include <cstdio>
#include <cfloat>
//! @class StelFader //! @class StelFader
//! Manages a (usually smooth) transition between two states (typically ON/ OFF) in function of a counter //! Manages a (usually smooth) transition between two states (typically ON/ OFF) in function of a counter
//! It used for various purpose like smooth transitions between //! It used for various purpose like smooth transitions between
class StelFader class StelFader
{ {
public: public:
// Create and initialise // Create and initialise
StelFader(bool initialState, float minimumValue=0.f, float maximumVa lue=1.f) : state(initialState), minValue(minimumValue), maxValue(maximumVal ue) {;} StelFader(bool initialState, float minimumValue=0.f, float maximumVa lue=1.f) : state(initialState), minValue(minimumValue), maxValue(maximumVal ue) {;}
virtual ~StelFader() {;} virtual ~StelFader() {;}
// Increments the internal counter of deltaTime ticks // Increments the internal counter of deltaTime ticks
skipping to change at line 238 skipping to change at line 235
void setDuration(int _duration) {duration = _duration;} void setDuration(int _duration) {duration = _duration;}
virtual float getDuration(void) {return duration;} virtual float getDuration(void) {return duration;}
protected: protected:
bool isTransiting; bool isTransiting;
int duration; int duration;
float startValue, targetValue; float startValue, targetValue;
int counter; int counter;
float interstate; float interstate;
}; };
/* better idea but not working...
class ParabolicFader : public LinearFader
{
public:
ParabolicFader(int _duration=1000, float minimumValue=0.f, float max
imumValue=1.f, bool initialState=false)
: LinearFader(_duration, minimumValue, maximumValue, initial
State)
{
}
// Increments the internal counter of deltaTime ticks
void update(int deltaTicks)
{
printf("Counter %d interstate %f\n", counter, interstate);
if (!isTransiting) return; // We are not in transition
counter+=deltaTicks;
if (counter>=duration)
{
// Transition is over
isTransiting = false;
interstate = targetValue;
}
else
{
interstate = startValue + (targetValue - startValue)
* counter/duration;
interstate *= interstate;
}
printf("Counter %d interstate %f\n", counter, interstate);
}
};
*/
#endif // _STELFADER_HPP_ #endif // _STELFADER_HPP_
 End of changes. 2 change blocks. 
39 lines changed or deleted 0 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/