package studio.junk.jam.coloritum.ui.animation;

public interface InterpolationFunction {
	public static class Sin implements InterpolationFunction {
		@Override
		public double f(double x) {
			return -0.5 * Math.cos(Math.PI * x) + 0.5;
		}
	}

	public static class EndlessSin implements InterpolationFunction {
		@Override
		public double f(double x) {
			return -0.5 * Math.cos(2 * Math.PI * x) + 0.5;
		}
	}

	public static class Linear implements InterpolationFunction {
		@Override
		public double f(double x) {
			return x;
		}
	}

	public static class EndlessLinear implements InterpolationFunction {
		@Override
		public double f(double x) {
			if (x <= 0.5) {
				return 2 * x;
			} else {
				return 2 - 2 * x;
			}
		}
	}

	/**
	 * Should return a value between 0.0 and 1.0
	 * 
	 * @param x
	 *            the x value for this function
	 * @return
	 */
	public double f(double x);
}
