topical media & game development

talk show tell print

actionscript-video-com-mosesSupposes-fuse-PennerEasing.ax

actionscript-video-com-mosesSupposes-fuse-PennerEasing.ax [swf] flex


  
* The Fuse Kit [beta1.1z3] * http://www.robertpenner.com/easing_terms_of_use.html * * TERMS OF USE - EASING EQUATIONS * * Open source under the BSD License. * * Copyright © 2001 Robert Penner * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. * 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. * 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. * * @ignore * * Robert Penner's original set of easing equations are used in The Fuse Kit by permission. See class file for license terms.<br> * <br> * @usage * This is an optional set of easing equations that enables you to use string shortcuts with the engine. You may also choose not to register this class if you wish to use default easing, the <code>mx.transitions.easing</code> package, or other easing equations that follow the same format.<br><br> * To use as string shortcuts you must register this class with the engine, either with {gray com.mosesSupposes.fuse.ZigoEngine#register} or {gray com.mosesSupposes.fuse.ZigoEngine#simpleSetup}.<br><br> * You may then use the method names in this class as shortcut-strings for the easing parameter of tween calls, such as <code>"easeOutQuad"</code>. * * @author Robert Penner

  
class com.mosesSupposes.fuse.@ax-actionscript-video-com-mosesSupposes-fuse-PennerEasing 
{
        
* @exclude * Unique identifier used by ZigoEngine.register

   
        static var registryKey:String = 'pennerEasing';
        
        
* Generates linear tween with constant velocity and no acceleration. *
parameter: t time * @param b beginning position * @param c total change in position * @param d duration of the tween * @return final position */ static function linear(t:Number, b:Number, c:Number, d:Number):Number { return c*t/d+b; } /** * Generates quadratic, or "normal" easing in tween where equation for motion is based on a squared variable. * @param t time * @param b beginning position * @param c total change in position * @param d duration of the tween * @return final position */ static function easeInQuad(t:Number, b:Number, c:Number, d:Number):Number { return c*(t /= d)*t+b; } /** * Generates quadratic, or "normal" easing out tween where equation for motion is based on a squared variable. * @param t time * @param b beginning position * @param c total change in position * @param d duration of the tween * @return final position */ static function easeOutQuad(t:Number, b:Number, c:Number, d:Number):Number { return -c*(t /= d)*(t-2)+b; } /** * Generates quadratic, or "normal" easing in-out tween (two half tweens fused together) where equation for motion is based on a squared variable. * @param t time * @param b beginning position * @param c total change in position * @param d duration of the tween * @return final position */ static function easeInOutQuad(t:Number, b:Number, c:Number, d:Number):Number { if ((t /= d/2)<1) { return c/2*t*t+b; } return -c/2*((--t)*(t-2)-1)+b; } /** * Generates exponential (sharp curve) easing in tween where equation for motion is based on the number 2 raised to a multiple of 10. * @param t time * @param b beginning position * @param c total change in position * @param d duration of the tween * @return final position */ static function easeInExpo(t:Number, b:Number, c:Number, d:Number):Number { return (t == 0) ? b : c*Math.pow(2, 10*(t/d-1))+b; } /** * Generates exponential (sharp curve) easing out tween where equation for motion is based on the number 2 raised to a multiple of 10. * @param t time * @param b beginning position * @param c total change in position * @param d duration of the tween * @return final position */ static function easeOutExpo(t:Number, b:Number, c:Number, d:Number):Number { return (t == d) ? b+c : c*(-Math.pow(2, -10*t/d)+1)+b; } /** * Generates exponential (sharp curve) easing in-out tween where equation for motion is based on the number 2 raised to a multiple of 10. * @param t time * @param b beginning position * @param c total change in position * @param d duration of the tween * @return final position */ static function easeInOutExpo(t:Number, b:Number, c:Number, d:Number):Number { if (t == 0) { return b; } if (t == d) { return b+c; } if ((t /= d/2)<1) { return c/2*Math.pow(2, 10*(t-1))+b; } return c/2*(-Math.pow(2, -10*--t)+2)+b; } /** * Generates exponential (sharp curve) easing out-in tween where equation for motion is based on the number 2 raised to a multiple of 10. * @param t time * @param b beginning position * @param c total change in position * @param d duration of the tween * @return final position */ static function easeOutInExpo(t:Number, b:Number, c:Number, d:Number):Number { if (t == 0) { return b; } if (t == d) { return b+c; } if ((t /= d/2)<1) { return c/2*(-Math.pow(2, -10*t)+1)+b; } return c/2*(Math.pow(2, 10*(t-2))+1)+b; } /** * Generates elastic easing in tween where equation for motion is based on Hooke's Law of F = -kd. * @param t time * @param b beginning position * @param c total change in position * @param d duration of the tween * @param a (optional) amplitude, or magnitude of wave's oscillation * @param p (optional) period * @return final position */ static function easeInElastic(t:Number, b:Number, c:Number, d:Number, a:Number, p:Number):Number { var s:Number; if (t == 0) { return b; } if ((t /= d) == 1) { return b+c; } if (!p) { p = d*.3; } if (!a || aF = -kd. * @param t time * @param b beginning position * @param c total change in position * @param d duration of the tween * @param a (optional) amplitude, or magnitude of wave's oscillation * @param p (optional) period * @return final position */ static function easeOutElastic(t:Number, b:Number, c:Number, d:Number, a:Number, p:Number):Number { var s:Number; if (t == 0) { return b; } if ((t /= d) == 1) { return b+c; } if (!p) { p = d*.3; } if (!a || aF = -kd. * @param t time * @param b beginning position * @param c total change in position * @param d duration of the tween * @param a (optional) amplitude, or magnitude of wave's oscillation * @param p (optional) period * @return final position */ static function easeInOutElastic(t:Number, b:Number, c:Number, d:Number, a:Number, p:Number):Number { var s:Number; if (t == 0) { return b; } if ((t /= d/2) == 2) { return b+c; } if (!p) { p = d*(.3*1.5); } if (!a || aF = -kd. * @param t time * @param b beginning position * @param c total change in position * @param d duration of the tween * @param a (optional) amplitude, or magnitude of wave's oscillation * @param p (optional) period * @return final position */ static function easeOutInElastic(t:Number, b:Number, c:Number, d:Number, a:Number, p:Number):Number { var s:Number; if (t == 0) { return b; } if ((t /= d/2) == 2) { return b+c; } if (!p) { p = d*(.3*1.5); } if (!a || a

(C) Æliens 27/08/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> </script> <script type="text/javascript"> _uacct = "UA-2780434-1"; urchinTracker(); </script>