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