Claw  1.7.3
single_tweener.hpp
Go to the documentation of this file.
1 /*
2  CLAW - a C++ Library Absolutely Wonderful
3 
4  CLAW is a free library without any particular aim but being useful to
5  anyone.
6 
7  Copyright (C) 2005-2011 Julien Jorge
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU Lesser General Public
11  License as published by the Free Software Foundation; either
12  version 2.1 of the License, or (at your option) any later version.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22  contact: julien.jorge@gamned.org
23 */
30 #ifndef __CLAW_TWEEN_SINGLE_TWEENER_HPP__
31 #define __CLAW_TWEEN_SINGLE_TWEENER_HPP__
32 
35 
36 #include <boost/function.hpp>
37 
38 namespace claw
39 {
40  namespace tween
41  {
49  public base_tweener
50  {
51  public:
54  typedef boost::function<void (double&)> update_function;
55 
57  typedef boost::function<double (double)> easing_function;
58 
59  public:
62  ( double init, double end, double duration, update_function callback,
63  easing_function e );
65  ( double& val, double end, double duration, easing_function e );
66 
67  double get_init() const;
68  void set_init( double v );
69 
70  double get_end() const;
71  void set_end( double v );
72 
73  double get_duration() const;
74  void set_duration( double v );
75 
76  void set_callback( update_function f );
77  void set_easing( easing_function f );
78 
79  double get_value() const;
80 
81  private:
82  single_tweener* do_clone() const;
83  bool do_is_finished() const;
84  double do_update( double dt );
85 
86  private:
88  double m_init;
89 
91  double m_end;
92 
94  double m_date;
95 
97  double m_duration;
98 
100  update_function m_callback;
101 
103  easing_function m_easing;
104 
105  }; // class single_tweener
106 
107  } // namespace tween
108 } // namespace claw
109 
110 #endif // __CLAW_TWEEN_SINGLE_TWEENER_HPP__
void set_init(double v)
Sets the initial value.
Common interface for all tweeners.
boost::function< double(double)> easing_function
The type of the function used to compute the new value.
double get_value() const
Gets the current value of the tweener.
A single_tweener makes a value to evolve through time from a initial value to an end value according ...
void set_duration(double v)
Sets the total duration.
Common interface for all tweeners.
void set_callback(update_function f)
The function called when the single_tweener is updated.
double get_duration() const
Gets the total duration.
double get_init() const
Gets the initial value.
void set_end(double v)
Sets the final value.
single_tweener()
Default constructor.
This is the main namespace.
Definition: algorithm.hpp:33
void set_easing(easing_function f)
The function used to compute the new value.
double get_end() const
Gets the final value.
Easing functions for the tweener. Those functions do nothing.
boost::function< void(double &)> update_function
The type of the function called when the single_tweener is updated.