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  void set_init( double v );
68  void set_end( double v );
69  void set_duration( double v );
70  void set_callback( update_function f );
71  void set_easing( easing_function f );
72 
73  private:
74  single_tweener* do_clone() const;
75  bool do_is_finished() const;
76  double do_update( double dt );
77 
78  private:
80  double m_init;
81 
83  double m_end;
84 
86  double m_date;
87 
89  double m_duration;
90 
92  update_function m_callback;
93 
95  easing_function m_easing;
96 
97  }; // class single_tweener
98 
99  } // namespace tween
100 } // namespace claw
101 
102 #endif // __CLAW_TWEEN_SINGLE_TWEENER_HPP__