• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package aurelienribon.tweenengine.equations;
2 
3 import aurelienribon.tweenengine.TweenEquation;
4 
5 /**
6  * Easing equation based on Robert Penner's work:
7  * http://robertpenner.com/easing/
8  * @author Aurelien Ribon | http://www.aurelienribon.com/
9  */
10 public abstract class Back extends TweenEquation {
11 	public static final Back IN = new Back() {
12 		@Override
13 		public final float compute(float t) {
14 			float s = param_s;
15 			return t*t*((s+1)*t - s);
16 		}
17 
18 		@Override
19 		public String toString() {
20 			return "Back.IN";
21 		}
22 	};
23 
24 	public static final Back OUT = new Back() {
25 		@Override
26 		public final float compute(float t) {
27 			float s = param_s;
28 			return (t-=1)*t*((s+1)*t + s) + 1;
29 		}
30 
31 		@Override
32 		public String toString() {
33 			return "Back.OUT";
34 		}
35 	};
36 
37 	public static final Back INOUT = new Back() {
38 		@Override
39 		public final float compute(float t) {
40 			float s = param_s;
41 			if ((t*=2) < 1) return 0.5f*(t*t*(((s*=(1.525f))+1)*t - s));
42 			return 0.5f*((t-=2)*t*(((s*=(1.525f))+1)*t + s) + 2);
43 		}
44 
45 		@Override
46 		public String toString() {
47 			return "Back.INOUT";
48 		}
49 	};
50 
51 	// -------------------------------------------------------------------------
52 
53 	protected float param_s = 1.70158f;
54 
s(float s)55 	public Back s(float s) {
56 		param_s = s;
57 		return this;
58 	}
59 }