1 var Equations = Equations || {};
  2 
  3 
  4 /**
  5  * Disclaimer for Robert Penner's Easing Equations license:
  6  *
  7  * TERMS OF USE - EASING EQUATIONS
  8  *
  9  * Open source under the BSD License.
 10  *
 11  * Copyright © 2001 Robert Penner
 12  * All rights reserved.
 13  *
 14  * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
 15  *
 16  *     * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
 17  *     * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
 18  *     * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.
 19  *
 20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 21  *
 22  * @class
 23  */
 24 Equations = (function () {
 25 
 26 	/**
 27 	 * Easing equation function for a simple linear tweening, with no easing.
 28 	 *
 29 	 * @param t	{Number} Current time (in frames or seconds).
 30 	 * @param b	{Number} Starting value.
 31 	 * @param c	{Number} Change needed in value.
 32 	 * @param d	{Number} Expected easing duration (in frames or seconds).
 33 	 * @param [p_params] {Object}
 34 	 * @return	{Number} The correct value.
 35 	 */
 36 	function easeNone (t, b, c, d, p_params) {
 37 		return c*t/d + b;
 38 	}
 39 
 40 	/**
 41 	 * Easing equation function for a quadratic (t^2) easing in: accelerating from zero velocity.
 42 	 *
 43 	 * @param t	{Number} Current time (in frames or seconds).
 44 	 * @param b	{Number} Starting value.
 45 	 * @param c	{Number} Change needed in value.
 46 	 * @param d	{Number} Expected easing duration (in frames or seconds).
 47 	 * @param [p_params] {Object}
 48 	 * @return	{Number} The correct value.
 49 	 */
 50 	function easeInQuad (t, b, c, d, p_params) {
 51 		return c*(t/=d)*t + b;
 52 	}
 53 
 54 	/**
 55 	 * Easing equation function for a quadratic (t^2) easing out: decelerating to zero velocity.
 56 	 *
 57 	 * @param t	{Number} Current time (in frames or seconds).
 58 	 * @param b	{Number} Starting value.
 59 	 * @param c	{Number} Change needed in value.
 60 	 * @param d	{Number} Expected easing duration (in frames or seconds).
 61 	 * @param [p_params] {Object}
 62 	 * @return	{Number} The correct value.
 63 	 */
 64 	function easeOutQuad (t, b, c, d, p_params) {
 65 		return -c *(t/=d)*(t-2) + b;
 66 	}
 67 
 68 	/**
 69 	 * Easing equation function for a quadratic (t^2) easing in/out: acceleration until halfway, then deceleration.
 70 	 *
 71 	 * @param t	{Number} Current time (in frames or seconds).
 72 	 * @param b	{Number} Starting value.
 73 	 * @param c	{Number} Change needed in value.
 74 	 * @param d	{Number} Expected easing duration (in frames or seconds).
 75 	 * @param [p_params] {Object}
 76 	 * @return	{Number} The correct value.
 77 	 */
 78 	function easeInOutQuad (t, b, c, d, p_params) {
 79 		if ((t/=d/2) < 1) return c/2*t*t + b;
 80 		return -c/2 * ((--t)*(t-2) - 1) + b;
 81 	}
 82 
 83 	/**
 84 	 * Easing equation function for a quadratic (t^2) easing out/in: deceleration until halfway, then acceleration.
 85 	 *
 86 	 * @param t	{Number} Current time (in frames or seconds).
 87 	 * @param b	{Number} Starting value.
 88 	 * @param c	{Number} Change needed in value.
 89 	 * @param d	{Number} Expected easing duration (in frames or seconds).
 90 	 * @param [p_params] {Object}
 91 	 * @return	{Number} The correct value.
 92 	 */
 93 	function easeOutInQuad (t, b, c, d, p_params) {
 94 		if (t < d/2) return easeOutQuad (t*2, b, c/2, d, p_params);
 95 		return easeInQuad((t*2)-d, b+c/2, c/2, d, p_params);
 96 	}
 97 
 98 
 99 	/**
100 	 * Easing equation function for a cubic (t^3) easing in: accelerating from zero velocity.
101 	 *
102 	 * @param t	{Number} Current time (in frames or seconds).
103 	 * @param b	{Number} Starting value.
104 	 * @param c	{Number} Change needed in value.
105 	 * @param d	{Number} Expected easing duration (in frames or seconds).
106 	 * @param [p_params] {Object}
107 	 * @return	{Number} The correct value.
108 	 */
109 	function easeInCubic (t, b, c, d, p_params) {
110 		return c*(t/=d)*t*t + b;
111 	}
112 
113 	/**
114 	 * Easing equation function for a cubic (t^3) easing out: decelerating from zero velocity.
115 	 *
116 	 * @param t	{Number} Current time (in frames or seconds).
117 	 * @param b	{Number} Starting value.
118 	 * @param c	{Number} Change needed in value.
119 	 * @param d	{Number} Expected easing duration (in frames or seconds).
120 	 * @param [p_params] {Object}
121 	 * @return	{Number} The correct value.
122 	 */
123 	function easeOutCubic (t, b, c, d, p_params) {
124 		return c*((t=t/d-1)*t*t + 1) + b;
125 	}
126 
127 	/**
128 	 * Easing equation function for a cubic (t^3) easing in/out: acceleration until halfway, then deceleration.
129 	 *
130 	 * @param t	{Number} Current time (in frames or seconds).
131 	 * @param b	{Number} Starting value.
132 	 * @param c	{Number} Change needed in value.
133 	 * @param d	{Number} Expected easing duration (in frames or seconds).
134 	 * @param [p_params] {Object}
135 	 * @return	{Number} The correct value.
136 	 */
137 	function easeInOutCubic (t, b, c, d, p_params) {
138 		if ((t/=d/2) < 1) return c/2*t*t*t + b;
139 		return c/2*((t-=2)*t*t + 2) + b;
140 	}
141 
142 	/**
143 	 * Easing equation function for a cubic (t^3) easing out/in: deceleration until halfway, then acceleration.
144 	 *
145 	 * @param t	{Number} Current time (in frames or seconds).
146 	 * @param b	{Number} Starting value.
147 	 * @param c	{Number} Change needed in value.
148 	 * @param d	{Number} Expected easing duration (in frames or seconds).
149 	 * @param [p_params] {Object}
150 	 * @return	{Number} The correct value.
151 	 */
152 	function easeOutInCubic (t, b, c, d, p_params) {
153 		if (t < d/2) return easeOutCubic (t*2, b, c/2, d, p_params);
154 		return easeInCubic((t*2)-d, b+c/2, c/2, d, p_params);
155 	}
156 
157 	/**
158 	 * Easing equation function for a quartic (t^4) easing in: accelerating from zero velocity.
159 	 *
160 	 * @param t	{Number} Current time (in frames or seconds).
161 	 * @param b	{Number} Starting value.
162 	 * @param c	{Number} Change needed in value.
163 	 * @param d	{Number} Expected easing duration (in frames or seconds).
164 	 * @param [p_params] {Object}
165 	 * @return	{Number} The correct value.
166 	 */
167 	function easeInQuart (t, b, c, d, p_params) {
168 		return c*(t/=d)*t*t*t + b;
169 	}
170 
171 	/**
172 	 * Easing equation function for a quartic (t^4) easing out: decelerating from zero velocity.
173 	 *
174 	 * @param t	{Number} Current time (in frames or seconds).
175 	 * @param b	{Number} Starting value.
176 	 * @param c	{Number} Change needed in value.
177 	 * @param d	{Number} Expected easing duration (in frames or seconds).
178 	 * @param [p_params] {Object}
179 	 * @return	{Number} The correct value.
180 	 */
181 	function easeOutQuart (t, b, c, d, p_params) {
182 		return -c * ((t=t/d-1)*t*t*t - 1) + b;
183 	}
184 
185 	/**
186 	 * Easing equation function for a quartic (t^4) easing in/out: acceleration until halfway, then deceleration.
187 	 *
188 	 * @param t	{Number} Current time (in frames or seconds).
189 	 * @param b	{Number} Starting value.
190 	 * @param c	{Number} Change needed in value.
191 	 * @param d	{Number} Expected easing duration (in frames or seconds).
192 	 * @param [p_params] {Object}
193 	 * @return	{Number} The correct value.
194 	 */
195 	function easeInOutQuart (t, b, c, d, p_params) {
196 		if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
197 		return -c/2 * ((t-=2)*t*t*t - 2) + b;
198 	}
199 
200 	/**
201 	 * Easing equation function for a quartic (t^4) easing out/in: deceleration until halfway, then acceleration.
202 	 *
203 	 * @param t	{Number} Current time (in frames or seconds).
204 	 * @param b	{Number} Starting value.
205 	 * @param c	{Number} Change needed in value.
206 	 * @param d	{Number} Expected easing duration (in frames or seconds).
207 	 * @param [p_params] {Object}
208 	 * @return	{Number} The correct value.
209 	 */
210 	function easeOutInQuart (t, b, c, d, p_params) {
211 		if (t < d/2) return easeOutQuart (t*2, b, c/2, d, p_params);
212 		return easeInQuart((t*2)-d, b+c/2, c/2, d, p_params);
213 	}
214 
215 	/**
216 	 * Easing equation function for a quintic (t^5) easing in: accelerating from zero velocity.
217 	 *
218 	 * @param t	{Number} Current time (in frames or seconds).
219 	 * @param b	{Number} Starting value.
220 	 * @param c	{Number} Change needed in value.
221 	 * @param d	{Number} Expected easing duration (in frames or seconds).
222 	 * @param [p_params] {Object}
223 	 * @return	{Number} The correct value.
224 	 */
225 	function easeInQuint (t, b, c, d, p_params) {
226 		return c*(t/=d)*t*t*t*t + b;
227 	}
228 
229 	/**
230 	 * Easing equation function for a quintic (t^5) easing out: decelerating from zero velocity.
231 	 *
232 	 * @param t	{Number} Current time (in frames or seconds).
233 	 * @param b	{Number} Starting value.
234 	 * @param c	{Number} Change needed in value.
235 	 * @param d	{Number} Expected easing duration (in frames or seconds).
236 	 * @param [p_params] {Object}
237 	 * @return	{Number} The correct value.
238 	 */
239 	function easeOutQuint (t, b, c, d, p_params) {
240 		return c*((t=t/d-1)*t*t*t*t + 1) + b;
241 	}
242 
243 	/**
244 	 * Easing equation function for a quintic (t^5) easing in/out: acceleration until halfway, then deceleration.
245 	 *
246 	 * @param t	{Number} Current time (in frames or seconds).
247 	 * @param b	{Number} Starting value.
248 	 * @param c	{Number} Change needed in value.
249 	 * @param d	{Number} Expected easing duration (in frames or seconds).
250 	 * @param [p_params] {Object}
251 	 * @return	{Number} The correct value.
252 	 */
253 	function easeInOutQuint (t, b, c, d, p_params) {
254 		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
255 		return c/2*((t-=2)*t*t*t*t + 2) + b;
256 	}
257 
258 	/**
259 	 * Easing equation function for a quintic (t^5) easing out/in: deceleration until halfway, then acceleration.
260 	 *
261 	 * @param t	{Number} Current time (in frames or seconds).
262 	 * @param b	{Number} Starting value.
263 	 * @param c	{Number} Change needed in value.
264 	 * @param d	{Number} Expected easing duration (in frames or seconds).
265 	 * @param [p_params] {Object}
266 	 * @return	{Number} The correct value.
267 	 */
268 	function easeOutInQuint (t, b, c, d, p_params) {
269 		if (t < d/2) return easeOutQuint (t*2, b, c/2, d, p_params);
270 		return easeInQuint((t*2)-d, b+c/2, c/2, d, p_params);
271 	}
272 
273 	/**
274 	 * Easing equation function for a sinusoidal (sin(t)) easing in: accelerating from zero velocity.
275 	 *
276 	 * @param t	{Number} Current time (in frames or seconds).
277 	 * @param b	{Number} Starting value.
278 	 * @param c	{Number} Change needed in value.
279 	 * @param d	{Number} Expected easing duration (in frames or seconds).
280 	 * @param [p_params] {Object}
281 	 * @return	{Number} The correct value.
282 	 */
283 	function easeInSine (t, b, c, d, p_params) {
284 		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
285 	}
286 
287 	/**
288 	 * Easing equation function for a sinusoidal (sin(t)) easing out: decelerating from zero velocity.
289 	 *
290 	 * @param t	{Number} Current time (in frames or seconds).
291 	 * @param b	{Number} Starting value.
292 	 * @param c	{Number} Change needed in value.
293 	 * @param d	{Number} Expected easing duration (in frames or seconds).
294 	 * @param [p_params] {Object}
295 	 * @return	{Number} The correct value.
296 	 */
297 	function easeOutSine (t, b, c, d, p_params) {
298 		return c * Math.sin(t/d * (Math.PI/2)) + b;
299 	}
300 
301 	/**
302 	 * Easing equation function for a sinusoidal (sin(t)) easing in/out: acceleration until halfway, then deceleration.
303 	 *
304 	 * @param t	{Number} Current time (in frames or seconds).
305 	 * @param b	{Number} Starting value.
306 	 * @param c	{Number} Change needed in value.
307 	 * @param d	{Number} Expected easing duration (in frames or seconds).
308 	 * @param [p_params] {Object}
309 	 * @return	{Number} The correct value.
310 	 */
311 	function easeInOutSine (t, b, c, d, p_params) {
312 		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
313 	}
314 
315 	/**
316 	 * Easing equation function for a sinusoidal (sin(t)) easing out/in: deceleration until halfway, then acceleration.
317 	 *
318 	 * @param t	{Number} Current time (in frames or seconds).
319 	 * @param b	{Number} Starting value.
320 	 * @param c	{Number} Change needed in value.
321 	 * @param d	{Number} Expected easing duration (in frames or seconds).
322 	 * @param [p_params] {Object}
323 	 * @return	{Number} The correct value.
324 	 */
325 	function easeOutInSine (t, b, c, d, p_params) {
326 		if (t < d/2) return easeOutSine (t*2, b, c/2, d, p_params);
327 		return easeInSine((t*2)-d, b+c/2, c/2, d, p_params);
328 	}
329 
330 	/**
331 	 * Easing equation function for an exponential (2^t) easing in: accelerating from zero velocity.
332 	 *
333 	 * @param t	{Number} Current time (in frames or seconds).
334 	 * @param b	{Number} Starting value.
335 	 * @param c	{Number} Change needed in value.
336 	 * @param d	{Number} Expected easing duration (in frames or seconds).
337 	 * @param [p_params] {Object}
338 	 * @return	{Number} The correct value.
339 	 */
340 	function easeInExpo (t, b, c, d, p_params) {
341 		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b - c * 0.001;
342 	}
343 
344 	/**
345 	 * Easing equation function for an exponential (2^t) easing out: decelerating from zero velocity.
346 	 *
347 	 * @param t	{Number} Current time (in frames or seconds).
348 	 * @param b	{Number} Starting value.
349 	 * @param c	{Number} Change needed in value.
350 	 * @param d	{Number} Expected easing duration (in frames or seconds).
351 	 * @param [p_params] {Object}
352 	 * @return	{Number} The correct value.
353 	 */
354 	function easeOutExpo (t, b, c, d, p_params) {
355 		return (t==d) ? b+c : c * 1.001 * (-Math.pow(2, -10 * t/d) + 1) + b;
356 	}
357 
358 	/**
359 	 * Easing equation function for an exponential (2^t) easing in/out: acceleration until halfway, then deceleration.
360 	 *
361 	 * @param t	{Number} Current time (in frames or seconds).
362 	 * @param b	{Number} Starting value.
363 	 * @param c	{Number} Change needed in value.
364 	 * @param d	{Number} Expected easing duration (in frames or seconds).
365 	 * @param [p_params] {Object}
366 	 * @return	{Number} The correct value.
367 	 */
368 	function easeInOutExpo (t, b, c, d, p_params) {
369 		if (t==0) return b;
370 		if (t==d) return b+c;
371 		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b - c * 0.0005;
372 		return c/2 * 1.0005 * (-Math.pow(2, -10 * --t) + 2) + b;
373 	}
374 
375 	/**
376 	 * Easing equation function for an exponential (2^t) easing out/in: deceleration until halfway, then acceleration.
377 	 *
378 	 * @param t	{Number} Current time (in frames or seconds).
379 	 * @param b	{Number} Starting value.
380 	 * @param c	{Number} Change needed in value.
381 	 * @param d	{Number} Expected easing duration (in frames or seconds).
382 	 * @param [p_params] {Object}
383 	 * @return	{Number} The correct value.
384 	 */
385 	function easeOutInExpo (t, b, c, d, p_params) {
386 		if (t < d/2) return easeOutExpo (t*2, b, c/2, d, p_params);
387 		return easeInExpo((t*2)-d, b+c/2, c/2, d, p_params);
388 	}
389 
390 	/**
391 	 * Easing equation function for a circular (sqrt(1-t^2)) easing in: accelerating from zero velocity.
392 	 *
393 	 * @param t	{Number} Current time (in frames or seconds).
394 	 * @param b	{Number} Starting value.
395 	 * @param c	{Number} Change needed in value.
396 	 * @param d	{Number} Expected easing duration (in frames or seconds).
397 	 * @param [p_params] {Object}
398 	 * @return	{Number} The correct value.
399 	 */
400 	function easeInCirc (t, b, c, d, p_params) {
401 		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
402 	}
403 
404 	/**
405 	 * Easing equation function for a circular (sqrt(1-t^2)) easing out: decelerating from zero velocity.
406 	 *
407 	 * @param t	{Number} Current time (in frames or seconds).
408 	 * @param b	{Number} Starting value.
409 	 * @param c	{Number} Change needed in value.
410 	 * @param d	{Number} Expected easing duration (in frames or seconds).
411 	 * @param [p_params] {Object}
412 	 * @return	{Number} The correct value.
413 	 */
414 	function easeOutCirc (t, b, c, d, p_params) {
415 		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
416 	}
417 
418 	/**
419 	 * Easing equation function for a circular (sqrt(1-t^2)) easing in/out: acceleration until halfway, then deceleration.
420 	 *
421 	 * @param t	{Number} Current time (in frames or seconds).
422 	 * @param b	{Number} Starting value.
423 	 * @param c	{Number} Change needed in value.
424 	 * @param d	{Number} Expected easing duration (in frames or seconds).
425 	 * @param [p_params] {Object}
426 	 * @return	{Number} The correct value.
427 	 */
428 	function easeInOutCirc (t, b, c, d, p_params) {
429 		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
430 		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
431 	}
432 
433 	/**
434 	 * Easing equation function for a circular (sqrt(1-t^2)) easing out/in: deceleration until halfway, then acceleration.
435 	 *
436 	 * @param t	{Number} Current time (in frames or seconds).
437 	 * @param b	{Number} Starting value.
438 	 * @param c	{Number} Change needed in value.
439 	 * @param d	{Number} Expected easing duration (in frames or seconds).
440 	 * @param [p_params] {Object}
441 	 * @return	{Number} The correct value.
442 	 */
443 	function easeOutInCirc (t, b, c, d, p_params) {
444 		if (t < d/2) return easeOutCirc (t*2, b, c/2, d, p_params);
445 		return easeInCirc((t*2)-d, b+c/2, c/2, d, p_params);
446 	}
447 
448 	/**
449 	 * Easing equation function for an elastic (exponentially decaying sine wave) easing in: accelerating from zero velocity.
450 	 *
451 	 * @param t	{Number} Current time (in frames or seconds).
452 	 * @param b	{Number} Starting value.
453 	 * @param c	{Number} Change needed in value.
454 	 * @param d	{Number} Expected easing duration (in frames or seconds).
455 	 * @param [p_params] {Object}
456 	 * @param [p_params.amplitude] {Number} Amplitude.
457 	 * @param [p_params.period] {Number} Period.
458 	 * @return	{Number} The correct value.
459 	 */
460 	function easeInElastic (t, b, c, d, p_params) {
461 		if (t==0) return b;
462 		if ((t/=d)==1) return b+c;
463 		var p = !Boolean(p_params) || isNaN(p_params.period) ? d*.3 : p_params.period;
464 		var s;
465 		var a = !Boolean(p_params) || isNaN(p_params.amplitude) ? 0 : p_params.amplitude;
466 		if (!Boolean(a) || a < Math.abs(c)) {
467 			a = c;
468 			s = p/4;
469 		} else {
470 			s = p/(2*Math.PI) * Math.asin (c/a);
471 		}
472 		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
473 	}
474 
475 	/**
476 	 * Easing equation function for an elastic (exponentially decaying sine wave) easing out: decelerating from zero velocity.
477 	 *
478 	 * @param t	{Number} Current time (in frames or seconds).
479 	 * @param b	{Number} Starting value.
480 	 * @param c	{Number} Change needed in value.
481 	 * @param d	{Number} Expected easing duration (in frames or seconds).
482 	 * @param [p_params] {Object}
483 	 * @param [p_params.amplitude] {Number} Amplitude.
484 	 * @param [p_params.period] {Number} Period.
485 	 * @return	{Number} The correct value.
486 	 */
487 	function easeOutElastic (t, b, c, d, p_params) {
488 		if (t==0) return b;
489 		if ((t/=d)==1) return b+c;
490 		var p = !Boolean(p_params) || isNaN(p_params.period) ? d*.3 : p_params.period;
491 		var s;
492 		var a = !Boolean(p_params) || isNaN(p_params.amplitude) ? 0 : p_params.amplitude;
493 		if (!Boolean(a) || a < Math.abs(c)) {
494 			a = c;
495 			s = p/4;
496 		} else {
497 			s = p/(2*Math.PI) * Math.asin (c/a);
498 		}
499 		return (a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b);
500 	}
501 
502 	/**
503 	 * Easing equation function for an elastic (exponentially decaying sine wave) easing in/out: acceleration until halfway, then deceleration.
504 	 *
505 	 * @param t	{Number} Current time (in frames or seconds).
506 	 * @param b	{Number} Starting value.
507 	 * @param c	{Number} Change needed in value.
508 	 * @param d	{Number} Expected easing duration (in frames or seconds).
509 	 * @param [p_params] {Object}
510 	 * @param [p_params.amplitude] {Number} Amplitude.
511 	 * @param [p_params.period] {Number} Period.
512 	 * @return	{Number} The correct value.
513 	 */
514 	function easeInOutElastic (t, b, c, d, p_params) {
515 		if (t==0) return b;
516 		if ((t/=d/2)==2) return b+c;
517 		var p = !Boolean(p_params) || isNaN(p_params.period) ? d*(.3*1.5) : p_params.period;
518 		var s;
519 		var a = !Boolean(p_params) || isNaN(p_params.amplitude) ? 0 : p_params.amplitude;
520 		if (!Boolean(a) || a < Math.abs(c)) {
521 			a = c;
522 			s = p/4;
523 		} else {
524 			s = p/(2*Math.PI) * Math.asin (c/a);
525 		}
526 		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
527 		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
528 	}
529 
530 	/**
531 	 * Easing equation function for an elastic (exponentially decaying sine wave) easing out/in: deceleration until halfway, then acceleration.
532 	 *
533 	 * @param t	{Number} Current time (in frames or seconds).
534 	 * @param b	{Number} Starting value.
535 	 * @param c	{Number} Change needed in value.
536 	 * @param d	{Number} Expected easing duration (in frames or seconds).
537 	 * @param [p_params] {Object}
538 	 * @param [p_params.amplitude] {Number} Amplitude.
539 	 * @param [p_params.period] {Number} Period.
540 	 * @return	{Number} The correct value.
541 	 */
542 	function easeOutInElastic (t, b, c, d, p_params) {
543 		if (t < d/2) return easeOutElastic (t*2, b, c/2, d, p_params);
544 		return easeInElastic((t*2)-d, b+c/2, c/2, d, p_params);
545 	}
546 
547 	/**
548 	 * Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity.
549 	 *
550 	 * @param t	{Number} Current time (in frames or seconds).
551 	 * @param b	{Number} Starting value.
552 	 * @param c	{Number} Change needed in value.
553 	 * @param d	{Number} Expected easing duration (in frames or seconds).
554 	 * @param [p_params] {Object}
555 	 * @param [p_params.overshoot] {Number} Overshoot ammount: higher s means greater overshoot (0 produces cubic easing with no overshoot, and the default value of 1.70158 produces an overshoot of 10 percent).
556 	 * @return	{Number} The correct value.
557 	 */
558 	function easeInBack (t, b, c, d, p_params) {
559 		var s = !Boolean(p_params) || isNaN(p_params.overshoot) ? 1.70158 : p_params.overshoot;
560 		return c*(t/=d)*t*((s+1)*t - s) + b;
561 	}
562 
563 	/**
564 	 * Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out: decelerating from zero velocity.
565 	 *
566 	 * @param t	{Number} Current time (in frames or seconds).
567 	 * @param b	{Number} Starting value.
568 	 * @param c	{Number} Change needed in value.
569 	 * @param d	{Number} Expected easing duration (in frames or seconds).
570 	 * @param [p_params] {Object}
571 	 * @param [p_params.overshoot] {Number} Overshoot ammount: higher s means greater overshoot (0 produces cubic easing with no overshoot, and the default value of 1.70158 produces an overshoot of 10 percent).
572 	 * @return	{Number} The correct value.
573 	 */
574 	function easeOutBack (t, b, c, d, p_params) {
575 		var s = !Boolean(p_params) || isNaN(p_params.overshoot) ? 1.70158 : p_params.overshoot;
576 		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
577 	}
578 
579 	/**
580 	 * Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration.
581 	 *
582 	 * @param t	{Number} Current time (in frames or seconds).
583 	 * @param b	{Number} Starting value.
584 	 * @param c	{Number} Change needed in value.
585 	 * @param d	{Number} Expected easing duration (in frames or seconds).
586 	 * @param [p_params] {Object}
587 	 * @param [p_params.overshoot] {Number} Overshoot ammount: higher s means greater overshoot (0 produces cubic easing with no overshoot, and the default value of 1.70158 produces an overshoot of 10 percent).
588 	 * @return	{Number} The correct value.
589 	 */
590 	function easeInOutBack (t, b, c, d, p_params) {
591 		var s = !Boolean(p_params) || isNaN(p_params.overshoot) ? 1.70158 : p_params.overshoot;
592 		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
593 		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
594 	}
595 
596 	/**
597 	 * Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration.
598 	 *
599 	 * @param t	{Number} Current time (in frames or seconds).
600 	 * @param b	{Number} Starting value.
601 	 * @param c	{Number} Change needed in value.
602 	 * @param d	{Number} Expected easing duration (in frames or seconds).
603 	 * @param [p_params] {Object}
604 	 * @param [p_params.overshoot] {Number} Overshoot ammount: higher s means greater overshoot (0 produces cubic easing with no overshoot, and the default value of 1.70158 produces an overshoot of 10 percent).
605 	 * @return	{Number} The correct value.
606 	 */
607 	function easeOutInBack (t, b, c, d, p_params) {
608 		if (t < d/2) return easeOutBack (t*2, b, c/2, d, p_params);
609 		return easeInBack((t*2)-d, b+c/2, c/2, d, p_params);
610 	}
611 
612 	/**
613 	 * Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in: accelerating from zero velocity.
614 	 *
615 	 * @param t	{Number} Current time (in frames or seconds).
616 	 * @param b	{Number} Starting value.
617 	 * @param c	{Number} Change needed in value.
618 	 * @param d	{Number} Expected easing duration (in frames or seconds).
619 	 * @param [p_params] {Object}
620 	 * @return	{Number} The correct value.
621 	 */
622 	function easeInBounce (t, b, c, d, p_params) {
623 		return c - easeOutBounce (d-t, 0, c, d) + b;
624 	}
625 
626 	/**
627 	 * Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out: decelerating from zero velocity.
628 	 *
629 	 * @param t	{Number} Current time (in frames or seconds).
630 	 * @param b	{Number} Starting value.
631 	 * @param c	{Number} Change needed in value.
632 	 * @param d	{Number} Expected easing duration (in frames or seconds).
633 	 * @param [p_params] {Object}
634 	 * @return	{Number} The correct value.
635 	 */
636 	function easeOutBounce (t, b, c, d, p_params) {
637 		if ((t/=d) < (1/2.75)) {
638 			return c*(7.5625*t*t) + b;
639 		} else if (t < (2/2.75)) {
640 			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
641 		} else if (t < (2.5/2.75)) {
642 			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
643 		} else {
644 			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
645 		}
646 	}
647 
648 	/**
649 	 * Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in/out: acceleration until halfway, then deceleration.
650 	 *
651 	 * @param t	{Number} Current time (in frames or seconds).
652 	 * @param b	{Number} Starting value.
653 	 * @param c	{Number} Change needed in value.
654 	 * @param d	{Number} Expected easing duration (in frames or seconds).
655 	 * @param [p_params] {Object}
656 	 * @return	{Number} The correct value.
657 	 */
658 	function easeInOutBounce (t, b, c, d, p_params) {
659 		if (t < d/2) return easeInBounce (t*2, 0, c, d) * .5 + b;
660 		else return easeOutBounce (t*2-d, 0, c, d) * .5 + c*.5 + b;
661 	}
662 
663 	/**
664 	 * Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out/in: deceleration until halfway, then acceleration.
665 	 *
666 	 * @param t	{Number} Current time (in frames or seconds).
667 	 * @param b	{Number} Starting value.
668 	 * @param c	{Number} Change needed in value.
669 	 * @param d	{Number} Expected easing duration (in frames or seconds).
670 	 * @param [p_params] {Object}
671 	 * @return	{Number} The correct value.
672 	 */
673 	function easeOutInBounce (t, b, c, d, p_params) {
674 		if (t < d/2) return easeOutBounce (t*2, b, c/2, d, p_params);
675 		return easeInBounce((t*2)-d, b+c/2, c/2, d, p_params);
676 	}
677 
678 	//public
679 	return {
680 		easeNone: 			easeNone,
681 		easeInQuad: 		easeInQuad,
682 		easeOutQuad: 		easeOutQuad,
683 		easeInOutQuad: 		easeInOutQuad,
684 		easeOutInQuad: 		easeOutInQuad,
685 		easeInCubic: 		easeInCubic,
686 		easeOutCubic: 		easeOutCubic,
687 		easeInOutCubic: 	easeInOutCubic,
688 		easeOutInCubic: 	easeOutInCubic,
689 		easeInQuart: 		easeInQuart,
690 		easeOutQuart: 		easeOutQuart,
691 		easeInOutQuart: 	easeInQuad,
692 		easeOutInQuart: 	easeOutInQuart,
693 		easeInQuint: 		easeInQuint,
694 		easeOutQuint: 		easeOutQuint,
695 		easeInOutQuint: 	easeInOutQuint,
696 		easeOutInQuint: 	easeOutInQuint,
697 		easeInSine: 		easeInSine,
698 		easeOutSine: 		easeOutSine,
699 		easeInOutSine: 		easeInOutSine,
700 		easeOutInSine: 		easeOutInSine,
701 		easeInCirc: 		easeInCirc,
702 		easeOutCirc: 		easeOutCirc,
703 		easeInOutCirc: 		easeInOutCirc,
704 		easeOutInCirc: 		easeOutInCirc,
705 		easeInExpo: 		easeInExpo,
706 		easeOutExpo: 		easeOutExpo,
707 		easeInOutExpo: 		easeInOutExpo,
708 		easeOutInExpo: 		easeOutInExpo,
709 		easeInElastic: 		easeInElastic,
710 		easeOutElastic: 	easeOutElastic,
711 		easeInOutElastic: 	easeInOutElastic,
712 		easeOutInElastic: 	easeOutInElastic,
713 		easeInBack: 		easeInBack,
714 		easeOutBack: 		easeOutBack,
715 		easeInOutBack: 		easeInOutBack,
716 		easeOutInBack: 		easeOutInBack,
717 		easeInBounce: 		easeInBounce,
718 		easeOutBounce: 		easeOutBounce,
719 		easeInOutBounce:	easeInOutBounce,
720 		easeOutInBounce:	easeOutInBounce
721 	}
722 }());
723 
724 
725 
726 
727