⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 easing.as

📁 用于flash/flex的 as3的 2D图形图像图表的动态生成
💻 AS
📖 第 1 页 / 共 2 页
字号:
			return 0.5 * 1.0005 * (-Math.pow(2, -10 * (2*t-1)) + 2);
		}
	
		/**
		 * Easing equation function for an exponential (2^t) easing out/in: deceleration until halfway, then acceleration.
 		 *
		 * @param t		Current time (an animation fraction between 0 and 1).
		 * @return		The correct value.
		 */
		public static function easeOutInExpo (t:Number):Number {
			if (t < 0.5) return 0.5 * easeOutExpo(2*t);
			return 0.5 * (1 + easeInExpo(2*t-1));
		}
	
		/**
		 * Easing equation function for a circular (sqrt(1-t^2)) easing in: accelerating from zero velocity.
 		 *
		 * @param t		Current time (an animation fraction between 0 and 1).
		 * @return		The correct value.
		 */
		public static function easeInCirc(t:Number):Number {
			return -(Math.sqrt(1-t*t) - 1);
		}
	
		/**
		 * Easing equation function for a circular (sqrt(1-t^2)) easing out: decelerating from zero velocity.
 		 *
		 * @param t		Current time (an animation fraction between 0 and 1).
		 * @return		The correct value.
		 */
		public static function easeOutCirc(t:Number):Number {
			return Math.sqrt(1 - (t=t-1)*t);
		}
	
		/**
		 * Easing equation function for a circular (sqrt(1-t^2)) easing in/out: acceleration until halfway, then deceleration.
 		 *
		 * @param t		Current time (an animation fraction between 0 and 1).
		 * @return		The correct value.
		 */
		public static function easeInOutCirc(t:Number):Number {
			if (t < 0.5) return -0.5 * (Math.sqrt(1 - 4*t*t) - 1);
			return 0.5 * (Math.sqrt(1 - (t=2*t-2)*t) + 1);
		}
	
		/**
		 * Easing equation function for a circular (sqrt(1-t^2)) easing out/in: deceleration until halfway, then acceleration.
		 *
		 * @param t		Current time (an animation fraction between 0 and 1).
		 * @return		The correct value.
		 */
		public static function easeOutInCirc(t:Number):Number {
			if (t < 0.5) return easeOutCirc(2*t);
			return 0.5 * (1 + easeInCirc(2*t-1));
		}
	
		/**
		 * Easing equation function for an elastic (exponentially decaying sine wave) easing in: accelerating from zero velocity.
		 *
		 * @param t		Current time (an animation fraction between 0 and 1).
		 * @param a		Amplitude.
		 * @param p		Period.
		 * @return		The correct value.
		 */
		public static function easeInElastic (t:Number, a:Number = Number.NaN, p:Number = Number.NaN):Number {
			if (t<=0 || t>=1) return t;  if (!p) p=0.45;
			var s:Number;
			if (!a || a < Math.abs(1)) { a=1; s=p/4; }
			else s = p/(2*Math.PI) * Math.asin (1/a);
			return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t-s)*(2*Math.PI)/p ));
		}
		
		/**
		 * Easing equation function for an elastic (exponentially decaying sine wave) easing out: decelerating from zero velocity.
		 *
		 * @param t		Current time (an animation fraction between 0 and 1).
		 * @param a		Amplitude.
		 * @param p		Period.
		 * @return		The correct value.
		 */
		public static function easeOutElastic (t:Number, a:Number = Number.NaN, p:Number = Number.NaN):Number {
			return 1 - easeInElastic(1-t, a, p);
		}
	
		/**
		 * Easing equation function for an elastic (exponentially decaying sine wave) easing in/out: acceleration until halfway, then deceleration.
		 *
		 * @param t		Current time (an animation fraction between 0 and 1).
		 * @param a		Amplitude.
		 * @param p		Period.
		 * @return		The correct value.
		 */
		public static function easeInOutElastic (t:Number, a:Number = Number.NaN, p:Number = Number.NaN):Number {
			if (t < 0.5) return 0.5 * easeInElastic(2*t, a, p);
			return 0.5 * (1 + easeOutElastic(2*t-1, a, p));
		}
	
		/**
		 * Easing equation function for an elastic (exponentially decaying sine wave) easing out/in: deceleration until halfway, then acceleration.
		 *
		 * @param t		Current time (an animation fraction between 0 and 1).
		 * @param a		Amplitude.
		 * @param p		Period.
		 * @return		The correct value.
		 */
		public static function easeOutInElastic (t:Number, a:Number = Number.NaN, p:Number = Number.NaN):Number {
			if (t < 0.5) return 0.5 * easeOutElastic(2*t, a, p);
			return 0.5 * (1 + easeInElastic(2*t-1, a, p));
		}

		/**
		 * Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity.
		 *
		 * @param t		Current time (an animation fraction between 0 and 1).
		 * @param s		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).
		 * @return		The correct value.
		 */
		public static function easeInBack (t:Number, s:Number = Number.NaN):Number {
			if (!s) s = 1.70158;
			return t*t*((s+1)*t - s);
		}
	
		/**
		 * Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out: decelerating from zero velocity.
		 *
		 * @param t		Current time (an animation fraction between 0 and 1).
		 * @param s		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).
		 * @return		The correct value.
		 */
		public static function easeOutBack (t:Number, s:Number = Number.NaN):Number {
			if (!s) s = 1.70158;
			return 1 - (t=1-t)*t*((s+1)*t - s);
		}
	
		/**
		 * Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration.
		 *
		 * @param t		Current time (an animation fraction between 0 and 1).
		 * @param s		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).
		 * @return		The correct value.
		 */
		public static function easeInOutBack (t:Number, s:Number = Number.NaN):Number {
			if (!s) s = 1.70158 * 1.525;
			if (t < 0.5) return 0.5 * easeInBack(2*t, s);
			return 0.5 * (1 + easeOutBack(2*t-1, s));
		}
	
		/**
		 * Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration.
		 *
		 * @param t		Current time (an animation fraction between 0 and 1).
		 * @param s		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).
		 * @return		The correct value.
		 */
		public static function easeOutInBack (t:Number, s:Number = Number.NaN):Number {
			if (!s) s = 1.70158 * 1.525;
			if (t < 0.5) return 0.5 * easeOutBack(2*t, s);
			return 0.5 * (1 + easeInBack(2*t-1, s));
		}
	
		/**
		 * Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in: accelerating from zero velocity.
		 *
		 * @param t		Current time (an animation fraction between 0 and 1).
		 * @return		The correct value.
		 */
		public static function easeInBounce(t:Number):Number {
			return 1 - easeOutBounce(1-t);
		}
	
		/**
		 * Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out: decelerating from zero velocity.
		 *
		 * @param t		Current time (an animation fraction between 0 and 1).
		 * @return		The correct value.
		 */
		public static function easeOutBounce (t:Number):Number {
			if (t < (1/2.75)) {
				return 7.5625*t*t;
			} else if (t < (2/2.75)) {
				return (7.5625*(t-=(1.5/2.75))*t + .75);
			} else if (t < (2.5/2.75)) {
				return (7.5625*(t-=(2.25/2.75))*t + .9375);
			} else {
				return (7.5625*(t-=(2.625/2.75))*t + .984375);
			}
		}
	
		/**
		 * Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in/out: acceleration until halfway, then deceleration.
		 *
		 * @param t		Current time (an animation fraction between 0 and 1).
		 * @return		The correct value.
		 */
		public static function easeInOutBounce (t:Number):Number {
			if (t < 0.5) return 0.5 * easeInBounce(2*t);
			return 0.5 * (1 + easeOutBounce(2*t-1));
		}
	
		/**
		 * Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out/in: deceleration until halfway, then acceleration.
		 *
		 * @param t		Current time (an animation fraction between 0 and 1).
		 * @return		The correct value.
		 */
		public static function easeOutInBounce (t:Number):Number {
			if (t < 0.5) return 0.5 * easeOutBounce(2*t);
			return 0.5 * (1 + easeInBounce(2*t-1));
		}
		
	} // end of class Easing
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -