• 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 Quad extends TweenEquation {
11 	public static final Quad IN = new Quad() {
12 		@Override
13 		public final float compute(float t) {
14 			return t*t;
15 		}
16 
17 		@Override
18 		public String toString() {
19 			return "Quad.IN";
20 		}
21 	};
22 
23 	public static final Quad OUT = new Quad() {
24 		@Override
25 		public final float compute(float t) {
26 			return -t*(t-2);
27 		}
28 
29 		@Override
30 		public String toString() {
31 			return "Quad.OUT";
32 		}
33 	};
34 
35 	public static final Quad INOUT = new Quad() {
36 		@Override
37 		public final float compute(float t) {
38 			if ((t*=2) < 1) return 0.5f*t*t;
39 			return -0.5f * ((--t)*(t-2) - 1);
40 		}
41 
42 		@Override
43 		public String toString() {
44 			return "Quad.INOUT";
45 		}
46 	};
47 }