1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.incallui.widget.multiwaveview; 18 19 import android.animation.TimeInterpolator; 20 21 class Ease { 22 private static final float DOMAIN = 1.0f; 23 private static final float DURATION = 1.0f; 24 private static final float START = 0.0f; 25 26 static class Linear { 27 public static final TimeInterpolator easeNone = new TimeInterpolator() { 28 public float getInterpolation(float input) { 29 return input; 30 } 31 }; 32 } 33 34 static class Cubic { 35 public static final TimeInterpolator easeIn = new TimeInterpolator() { 36 public float getInterpolation(float input) { 37 return DOMAIN*(input/=DURATION)*input*input + START; 38 } 39 }; 40 public static final TimeInterpolator easeOut = new TimeInterpolator() { 41 public float getInterpolation(float input) { 42 return DOMAIN*((input=input/DURATION-1)*input*input + 1) + START; 43 } 44 }; 45 public static final TimeInterpolator easeInOut = new TimeInterpolator() { 46 public float getInterpolation(float input) { 47 return ((input/=DURATION/2) < 1.0f) ? 48 (DOMAIN/2*input*input*input + START) 49 : (DOMAIN/2*((input-=2)*input*input + 2) + START); 50 } 51 }; 52 } 53 54 static class Quad { 55 public static final TimeInterpolator easeIn = new TimeInterpolator() { 56 public float getInterpolation (float input) { 57 return DOMAIN*(input/=DURATION)*input + START; 58 } 59 }; 60 public static final TimeInterpolator easeOut = new TimeInterpolator() { 61 public float getInterpolation(float input) { 62 return -DOMAIN *(input/=DURATION)*(input-2) + START; 63 } 64 }; 65 public static final TimeInterpolator easeInOut = new TimeInterpolator() { 66 public float getInterpolation(float input) { 67 return ((input/=DURATION/2) < 1) ? 68 (DOMAIN/2*input*input + START) 69 : (-DOMAIN/2 * ((--input)*(input-2) - 1) + START); 70 } 71 }; 72 } 73 74 static class Quart { 75 public static final TimeInterpolator easeIn = new TimeInterpolator() { 76 public float getInterpolation(float input) { 77 return DOMAIN*(input/=DURATION)*input*input*input + START; 78 } 79 }; 80 public static final TimeInterpolator easeOut = new TimeInterpolator() { 81 public float getInterpolation(float input) { 82 return -DOMAIN * ((input=input/DURATION-1)*input*input*input - 1) + START; 83 } 84 }; 85 public static final TimeInterpolator easeInOut = new TimeInterpolator() { 86 public float getInterpolation(float input) { 87 return ((input/=DURATION/2) < 1) ? 88 (DOMAIN/2*input*input*input*input + START) 89 : (-DOMAIN/2 * ((input-=2)*input*input*input - 2) + START); 90 } 91 }; 92 } 93 94 static class Quint { 95 public static final TimeInterpolator easeIn = new TimeInterpolator() { 96 public float getInterpolation(float input) { 97 return DOMAIN*(input/=DURATION)*input*input*input*input + START; 98 } 99 }; 100 public static final TimeInterpolator easeOut = new TimeInterpolator() { 101 public float getInterpolation(float input) { 102 return DOMAIN*((input=input/DURATION-1)*input*input*input*input + 1) + START; 103 } 104 }; 105 public static final TimeInterpolator easeInOut = new TimeInterpolator() { 106 public float getInterpolation(float input) { 107 return ((input/=DURATION/2) < 1) ? 108 (DOMAIN/2*input*input*input*input*input + START) 109 : (DOMAIN/2*((input-=2)*input*input*input*input + 2) + START); 110 } 111 }; 112 } 113 114 static class Sine { 115 public static final TimeInterpolator easeIn = new TimeInterpolator() { 116 public float getInterpolation(float input) { 117 return -DOMAIN * (float) Math.cos(input/DURATION * (Math.PI/2)) + DOMAIN + START; 118 } 119 }; 120 public static final TimeInterpolator easeOut = new TimeInterpolator() { 121 public float getInterpolation(float input) { 122 return DOMAIN * (float) Math.sin(input/DURATION * (Math.PI/2)) + START; 123 } 124 }; 125 public static final TimeInterpolator easeInOut = new TimeInterpolator() { 126 public float getInterpolation(float input) { 127 return -DOMAIN/2 * ((float)Math.cos(Math.PI*input/DURATION) - 1.0f) + START; 128 } 129 }; 130 } 131 132 } 133