1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
4 * Moonlight List (moonlight-list@lists.ximian.com)
6 * Copyright 2007 Novell, Inc. (http://www.novell.com)
8 * See the LICENSE file included with the distribution for details.
23 #include <timemanager.h>
24 #include <timesource.h>
30 EasingFunctionBase::EasingFunctionBase ()
32 SetObjectType (Type::EASINGFUNCTIONBASE
);
33 easing_function_callback
= NULL
;
36 EasingFunctionBase::~EasingFunctionBase ()
42 EasingFunctionBase::Ease (double normalizedTime
)
44 if (easing_function_callback
)
45 return easing_function_callback (normalizedTime
);
47 switch (GetEasingMode()) {
49 return EaseInCore (normalizedTime
);
51 return 1.0 - EaseInCore (1 - normalizedTime
);
53 return (normalizedTime
<= 0.5
54 ? EaseInCore (normalizedTime
* 2) * 0.5
55 : 1.0 - EaseInCore ((1 - normalizedTime
) * 2) * 0.5);
63 EasingFunctionBase::SetEasingFunction (EasingFunction easing_function
)
65 easing_function_callback
= easing_function
;
72 SetObjectType (Type::BACKEASE
);
75 BackEase::~BackEase ()
80 BackEase::EaseInCore (double normalizedTime
)
82 double t_cubed
= normalizedTime
* normalizedTime
* normalizedTime
;
84 return t_cubed
- normalizedTime
* GetAmplitude () * sin (normalizedTime
* M_PI
);
89 BounceEase::BounceEase ()
91 SetObjectType (Type::BOUNCEEASE
);
94 BounceEase::~BounceEase ()
99 BounceEase::EaseInCore (double normalizedTime
)
101 g_warning ("BounceEase::EaseInCore not implemented");
102 return EasingFunctionBase::EaseInCore (normalizedTime
);
107 CircleEase::CircleEase ()
109 SetObjectType (Type::CIRCLEEASE
);
112 CircleEase::~CircleEase ()
117 CircleEase::EaseInCore (double normalizedTime
)
119 return 1 - sqrt (1 - normalizedTime
* normalizedTime
);
124 CubicEase::CubicEase ()
126 SetObjectType (Type::CUBICEASE
);
129 CubicEase::~CubicEase ()
134 CubicEase::EaseInCore (double normalizedTime
)
136 return normalizedTime
* normalizedTime
* normalizedTime
;
141 ElasticEase::ElasticEase ()
143 SetObjectType (Type::ELASTICEASE
);
146 ElasticEase::~ElasticEase ()
151 ElasticEase::EaseInCore (double normalizedTime
)
153 g_warning ("ElasticEase::EaseInCore not implemented");
154 return EasingFunctionBase::EaseInCore (normalizedTime
);
159 ExponentialEase::ExponentialEase ()
161 SetObjectType (Type::EXPONENTIALEASE
);
164 ExponentialEase::~ExponentialEase ()
169 ExponentialEase::EaseInCore (double normalizedTime
)
171 return (exp (GetExponent () * normalizedTime
) - 1) / (exp (GetExponent ()) - 1);
176 PowerEase::PowerEase ()
178 SetObjectType (Type::POWEREASE
);
181 PowerEase::~PowerEase ()
186 PowerEase::EaseInCore (double normalizedTime
)
188 return pow (normalizedTime
, GetPower ());
193 QuadraticEase::QuadraticEase ()
195 SetObjectType (Type::QUADRATICEASE
);
198 QuadraticEase::~QuadraticEase ()
203 QuadraticEase::EaseInCore (double normalizedTime
)
205 return normalizedTime
* normalizedTime
;
211 QuarticEase::QuarticEase ()
213 SetObjectType (Type::QUARTICEASE
);
216 QuarticEase::~QuarticEase ()
221 QuarticEase::EaseInCore (double normalizedTime
)
223 return normalizedTime
* normalizedTime
* normalizedTime
* normalizedTime
;
229 QuinticEase::QuinticEase ()
231 SetObjectType (Type::QUINTICEASE
);
234 QuinticEase::~QuinticEase ()
239 QuinticEase::EaseInCore (double normalizedTime
)
241 return normalizedTime
* normalizedTime
* normalizedTime
* normalizedTime
* normalizedTime
;
247 SineEase::SineEase ()
249 SetObjectType (Type::SINEEASE
);
252 SineEase::~SineEase ()
257 SineEase::EaseInCore (double normalizedTime
)
259 return 1.0 - sin ((1.0 - normalizedTime
) * M_PI_2
);