Home | History | Annotate | Download | only in tweenengine
      1 package aurelienribon.tweenengine;
      2 
      3 import aurelienribon.tweenengine.equations.Back;
      4 import aurelienribon.tweenengine.equations.Bounce;
      5 import aurelienribon.tweenengine.equations.Circ;
      6 import aurelienribon.tweenengine.equations.Cubic;
      7 import aurelienribon.tweenengine.equations.Elastic;
      8 import aurelienribon.tweenengine.equations.Expo;
      9 import aurelienribon.tweenengine.equations.Linear;
     10 import aurelienribon.tweenengine.equations.Quad;
     11 import aurelienribon.tweenengine.equations.Quart;
     12 import aurelienribon.tweenengine.equations.Quint;
     13 import aurelienribon.tweenengine.equations.Sine;
     14 
     15 /**
     16  * Collection of miscellaneous utilities.
     17  *
     18  * @author Aurelien Ribon | http://www.aurelienribon.com/
     19  */
     20 public class TweenUtils {
     21 	private static TweenEquation[] easings;
     22 
     23 	/**
     24 	 * Takes an easing name and gives you the corresponding TweenEquation.
     25 	 * You probably won't need this, but tools will love that.
     26 	 *
     27 	 * @param easingName The name of an easing, like "Quad.INOUT".
     28 	 * @return The parsed equation, or null if there is no match.
     29 	 */
     30 	public static TweenEquation parseEasing(String easingName) {
     31 		if (easings == null) {
     32 			easings = new TweenEquation[] {Linear.INOUT,
     33 				Quad.IN, Quad.OUT, Quad.INOUT,
     34 				Cubic.IN, Cubic.OUT, Cubic.INOUT,
     35 				Quart.IN, Quart.OUT, Quart.INOUT,
     36 				Quint.IN, Quint.OUT, Quint.INOUT,
     37 				Circ.IN, Circ.OUT, Circ.INOUT,
     38 				Sine.IN, Sine.OUT, Sine.INOUT,
     39 				Expo.IN, Expo.OUT, Expo.INOUT,
     40 				Back.IN, Back.OUT, Back.INOUT,
     41 				Bounce.IN, Bounce.OUT, Bounce.INOUT,
     42 				Elastic.IN, Elastic.OUT, Elastic.INOUT
     43 			};
     44 		}
     45 
     46 		for (int i=0; i<easings.length; i++) {
     47 			if (easingName.equals(easings[i].toString()))
     48 				return easings[i];
     49 		}
     50 
     51 		return null;
     52 	}
     53 }
     54