• 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 Bounce extends TweenEquation {
11 	public static final Bounce IN = new Bounce() {
12 		@Override
13 		public final float compute(float t) {
14 			return 1 - OUT.compute(1-t);
15 		}
16 
17 		@Override
18 		public String toString() {
19 			return "Bounce.IN";
20 		}
21 	};
22 
23 	public static final Bounce OUT = new Bounce() {
24 		@Override
25 		public final float compute(float t) {
26 			if (t < (1/2.75)) {
27 				return 7.5625f*t*t;
28 			} else if (t < (2/2.75)) {
29 				return 7.5625f*(t-=(1.5f/2.75f))*t + .75f;
30 			} else if (t < (2.5/2.75)) {
31 				return 7.5625f*(t-=(2.25f/2.75f))*t + .9375f;
32 			} else {
33 				return 7.5625f*(t-=(2.625f/2.75f))*t + .984375f;
34 			}
35 		}
36 
37 		@Override
38 		public String toString() {
39 			return "Bounce.OUT";
40 		}
41 	};
42 
43 	public static final Bounce INOUT = new Bounce() {
44 		@Override
45 		public final float compute(float t) {
46 			if (t < 0.5f) return IN.compute(t*2) * .5f;
47 			else return OUT.compute(t*2-1) * .5f + 0.5f;
48 		}
49 
50 		@Override
51 		public String toString() {
52 			return "Bounce.INOUT";
53 		}
54 	};
55 }