From: Richard K. <ric...@us...> - 2005-07-09 14:56:20
|
Update of /cvsroot/actionstep/actionstep/src/org/actionstep In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv907 Modified Files: ASDraw.as Log Message: added easing functions Index: ASDraw.as =================================================================== RCS file: /cvsroot/actionstep/actionstep/src/org/actionstep/ASDraw.as,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ASDraw.as 29 Jun 2005 06:58:26 -0000 1.13 --- ASDraw.as 9 Jul 2005 14:56:11 -0000 1.14 *************** *** 41,50 **** public static var TRACE_FLAG:Boolean = false; ! public static function setTrace(value:Boolean) { TRACE_FLAG = value; } ! //draws a horizontal line with thickness=1. public static function drawHLine(mc:MovieClip, lineColor:Number, x1:Number, x2:Number, y1:Number) { --- 41,50 ---- public static var TRACE_FLAG:Boolean = false; ! public static function setTrace(value:Boolean) { TRACE_FLAG = value; } ! //draws a horizontal line with thickness=1. public static function drawHLine(mc:MovieClip, lineColor:Number, x1:Number, x2:Number, y1:Number) { *************** *** 1234,1237 **** --- 1234,1414 ---- + // EASING FUNCTIONS USEFUL FOR ANIMATIONS + // Robert Penner - Sept. 2001 - robertpenner.com + + public static function linearTween(t, b, c, d) { + return c*t/d + b; + }; + + + // quadratic easing in - accelerating from zero velocity + public static function easeInQuad(t, b, c, d) { + t /= d; + return c*t*t + b; + }; + + + // quadratic easing out - decelerating to zero velocity + public static function easeOutQuad(t, b, c, d) { + t /= d; + return -c * t*(t-2) + b; + }; + + + + // quadratic easing in/out - acceleration until halfway, then deceleration + public static function easeInOutQuad(t, b, c, d) { + t /= d/2; + if (t < 1) return c/2*t*t + b; + t--; + return -c/2 * (t*(t-2) - 1) + b; + }; + + // cubic easing in - accelerating from zero velocity + public static function easeInCubic(t, b, c, d) { + t /= d; + return c*t*t*t + b; + }; + + + + // cubic easing out - decelerating to zero velocity + public static function easeOutCubic(t, b, c, d) { + t /= d; + t--; + return c*(t*t*t + 1) + b; + }; + + + + // cubic easing in/out - acceleration until halfway, then deceleration + public static function easeInOutCubic(t, b, c, d) { + t /= d/2; + if (t < 1) return c/2*t*t*t + b; + t -= 2; + return c/2*(t*t*t + 2) + b; + }; + + + // quartic easing in - accelerating from zero velocity + public static function easeInQuart(t, b, c, d) { + t /= d; + return c*t*t*t*t + b; + }; + + + + // quartic easing out - decelerating to zero velocity + public static function easeOutQuart(t, b, c, d) { + t /= d; + t--; + return -c * (t*t*t*t - 1) + b; + }; + + + + // quartic easing in/out - acceleration until halfway, then deceleration + public static function easeInOutQuart(t, b, c, d) { + t /= d/2; + if (t < 1) return c/2*t*t*t*t + b; + t -= 2; + return -c/2 * (t*t*t*t - 2) + b; + }; + + + // quintic easing in - accelerating from zero velocity + public static function easeInQuint(t, b, c, d) { + t /= d; + return c*t*t*t*t*t + b; + }; + + + + // quintic easing out - decelerating to zero velocity + public static function easeOutQuint(t, b, c, d) { + t /= d; + t--; + return c*(t*t*t*t*t + 1) + b; + }; + + + + // quintic easing in/out - acceleration until halfway, then deceleration + public static function easeInOutQuint(t, b, c, d) { + t /= d/2; + if (t < 1) return c/2*t*t*t*t*t + b; + t -= 2; + return c/2*(t*t*t*t*t + 2) + b; + }; + + + // sinusoidal easing in - accelerating from zero velocity + public static function easeInSine(t, b, c, d) { + return -c * Math.cos(t/d * (Math.PI/2)) + c + b; + }; + + + + // sinusoidal easing out - decelerating to zero velocity + public static function easeOutSine(t, b, c, d) { + return c * Math.sin(t/d * (Math.PI/2)) + b; + }; + + + + // sinusoidal easing in/out - accelerating until halfway, then decelerating + public static function easeInOutSine(t, b, c, d) { + return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b; + }; + + + + // exponential easing in - accelerating from zero velocity + public static function easeInExpo(t, b, c, d) { + return c * Math.pow( 2, 10 * (t/d - 1) ) + b; + }; + + + + // exponential easing out - decelerating to zero velocity + public static function easeOutExpo(t, b, c, d) { + return c * ( -Math.pow( 2, -10 * t/d ) + 1 ) + b; + }; + + + + // exponential easing in/out - accelerating until halfway, then decelerating + public static function easeInOutExpo(t, b, c, d) { + t /= d/2; + if (t < 1) return c/2 * Math.pow( 2, 10 * (t - 1) ) + b; + t--; + return c/2 * ( -Math.pow( 2, -10 * t) + 2 ) + b; + }; + + + // circular easing in - accelerating from zero velocity + public static function easeInCirc(t, b, c, d) { + t /= d; + return -c * (Math.sqrt(1 - t*t) - 1) + b; + }; + + + + // circular easing out - decelerating to zero velocity + public static function easeOutCirc(t, b, c, d) { + t /= d; + t--; + return c * Math.sqrt(1 - t*t) + b; + }; + + + + // circular easing in/out - acceleration until halfway, then deceleration + public static function easeInOutCirc(t, b, c, d) { + t /= d/2; + if (t < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b; + t -= 2; + return c/2 * (Math.sqrt(1 - t*t) + 1) + b; + }; } \ No newline at end of file |