13012eefc84559507168982a7fc53dff667582b00Chiao Cheng/* 23012eefc84559507168982a7fc53dff667582b00Chiao Cheng * Copyright (C) 2011 The Android Open Source Project 33012eefc84559507168982a7fc53dff667582b00Chiao Cheng * 43012eefc84559507168982a7fc53dff667582b00Chiao Cheng * Licensed under the Apache License, Version 2.0 (the "License"); 53012eefc84559507168982a7fc53dff667582b00Chiao Cheng * you may not use this file except in compliance with the License. 63012eefc84559507168982a7fc53dff667582b00Chiao Cheng * You may obtain a copy of the License at 73012eefc84559507168982a7fc53dff667582b00Chiao Cheng * 83012eefc84559507168982a7fc53dff667582b00Chiao Cheng * http://www.apache.org/licenses/LICENSE-2.0 93012eefc84559507168982a7fc53dff667582b00Chiao Cheng * 103012eefc84559507168982a7fc53dff667582b00Chiao Cheng * Unless required by applicable law or agreed to in writing, software 113012eefc84559507168982a7fc53dff667582b00Chiao Cheng * distributed under the License is distributed on an "AS IS" BASIS, 123012eefc84559507168982a7fc53dff667582b00Chiao Cheng * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 133012eefc84559507168982a7fc53dff667582b00Chiao Cheng * See the License for the specific language governing permissions and 143012eefc84559507168982a7fc53dff667582b00Chiao Cheng * limitations under the License. 153012eefc84559507168982a7fc53dff667582b00Chiao Cheng */ 163012eefc84559507168982a7fc53dff667582b00Chiao Cheng 173012eefc84559507168982a7fc53dff667582b00Chiao Chengpackage com.android.deskclock.widget.multiwaveview; 183012eefc84559507168982a7fc53dff667582b00Chiao Cheng 193012eefc84559507168982a7fc53dff667582b00Chiao Chengimport android.animation.TimeInterpolator; 203012eefc84559507168982a7fc53dff667582b00Chiao Cheng 213012eefc84559507168982a7fc53dff667582b00Chiao Chengclass Ease { 223012eefc84559507168982a7fc53dff667582b00Chiao Cheng private static final float DOMAIN = 1.0f; 233012eefc84559507168982a7fc53dff667582b00Chiao Cheng private static final float DURATION = 1.0f; 243012eefc84559507168982a7fc53dff667582b00Chiao Cheng private static final float START = 0.0f; 253012eefc84559507168982a7fc53dff667582b00Chiao Cheng 263012eefc84559507168982a7fc53dff667582b00Chiao Cheng static class Linear { 273012eefc84559507168982a7fc53dff667582b00Chiao Cheng public static final TimeInterpolator easeNone = new TimeInterpolator() { 283012eefc84559507168982a7fc53dff667582b00Chiao Cheng public float getInterpolation(float input) { 293012eefc84559507168982a7fc53dff667582b00Chiao Cheng return input; 303012eefc84559507168982a7fc53dff667582b00Chiao Cheng } 313012eefc84559507168982a7fc53dff667582b00Chiao Cheng }; 323012eefc84559507168982a7fc53dff667582b00Chiao Cheng } 333012eefc84559507168982a7fc53dff667582b00Chiao Cheng 343012eefc84559507168982a7fc53dff667582b00Chiao Cheng static class Cubic { 353012eefc84559507168982a7fc53dff667582b00Chiao Cheng public static final TimeInterpolator easeIn = new TimeInterpolator() { 363012eefc84559507168982a7fc53dff667582b00Chiao Cheng public float getInterpolation(float input) { 373012eefc84559507168982a7fc53dff667582b00Chiao Cheng return DOMAIN*(input/=DURATION)*input*input + START; 383012eefc84559507168982a7fc53dff667582b00Chiao Cheng } 393012eefc84559507168982a7fc53dff667582b00Chiao Cheng }; 403012eefc84559507168982a7fc53dff667582b00Chiao Cheng public static final TimeInterpolator easeOut = new TimeInterpolator() { 413012eefc84559507168982a7fc53dff667582b00Chiao Cheng public float getInterpolation(float input) { 423012eefc84559507168982a7fc53dff667582b00Chiao Cheng return DOMAIN*((input=input/DURATION-1)*input*input + 1) + START; 433012eefc84559507168982a7fc53dff667582b00Chiao Cheng } 443012eefc84559507168982a7fc53dff667582b00Chiao Cheng }; 453012eefc84559507168982a7fc53dff667582b00Chiao Cheng public static final TimeInterpolator easeInOut = new TimeInterpolator() { 463012eefc84559507168982a7fc53dff667582b00Chiao Cheng public float getInterpolation(float input) { 473012eefc84559507168982a7fc53dff667582b00Chiao Cheng return ((input/=DURATION/2) < 1.0f) ? 483012eefc84559507168982a7fc53dff667582b00Chiao Cheng (DOMAIN/2*input*input*input + START) 493012eefc84559507168982a7fc53dff667582b00Chiao Cheng : (DOMAIN/2*((input-=2)*input*input + 2) + START); 503012eefc84559507168982a7fc53dff667582b00Chiao Cheng } 513012eefc84559507168982a7fc53dff667582b00Chiao Cheng }; 523012eefc84559507168982a7fc53dff667582b00Chiao Cheng } 533012eefc84559507168982a7fc53dff667582b00Chiao Cheng 543012eefc84559507168982a7fc53dff667582b00Chiao Cheng static class Quad { 553012eefc84559507168982a7fc53dff667582b00Chiao Cheng public static final TimeInterpolator easeIn = new TimeInterpolator() { 563012eefc84559507168982a7fc53dff667582b00Chiao Cheng public float getInterpolation (float input) { 573012eefc84559507168982a7fc53dff667582b00Chiao Cheng return DOMAIN*(input/=DURATION)*input + START; 583012eefc84559507168982a7fc53dff667582b00Chiao Cheng } 593012eefc84559507168982a7fc53dff667582b00Chiao Cheng }; 603012eefc84559507168982a7fc53dff667582b00Chiao Cheng public static final TimeInterpolator easeOut = new TimeInterpolator() { 613012eefc84559507168982a7fc53dff667582b00Chiao Cheng public float getInterpolation(float input) { 623012eefc84559507168982a7fc53dff667582b00Chiao Cheng return -DOMAIN *(input/=DURATION)*(input-2) + START; 633012eefc84559507168982a7fc53dff667582b00Chiao Cheng } 643012eefc84559507168982a7fc53dff667582b00Chiao Cheng }; 653012eefc84559507168982a7fc53dff667582b00Chiao Cheng public static final TimeInterpolator easeInOut = new TimeInterpolator() { 663012eefc84559507168982a7fc53dff667582b00Chiao Cheng public float getInterpolation(float input) { 673012eefc84559507168982a7fc53dff667582b00Chiao Cheng return ((input/=DURATION/2) < 1) ? 683012eefc84559507168982a7fc53dff667582b00Chiao Cheng (DOMAIN/2*input*input + START) 693012eefc84559507168982a7fc53dff667582b00Chiao Cheng : (-DOMAIN/2 * ((--input)*(input-2) - 1) + START); 703012eefc84559507168982a7fc53dff667582b00Chiao Cheng } 713012eefc84559507168982a7fc53dff667582b00Chiao Cheng }; 723012eefc84559507168982a7fc53dff667582b00Chiao Cheng } 733012eefc84559507168982a7fc53dff667582b00Chiao Cheng 743012eefc84559507168982a7fc53dff667582b00Chiao Cheng static class Quart { 753012eefc84559507168982a7fc53dff667582b00Chiao Cheng public static final TimeInterpolator easeIn = new TimeInterpolator() { 763012eefc84559507168982a7fc53dff667582b00Chiao Cheng public float getInterpolation(float input) { 773012eefc84559507168982a7fc53dff667582b00Chiao Cheng return DOMAIN*(input/=DURATION)*input*input*input + START; 783012eefc84559507168982a7fc53dff667582b00Chiao Cheng } 793012eefc84559507168982a7fc53dff667582b00Chiao Cheng }; 803012eefc84559507168982a7fc53dff667582b00Chiao Cheng public static final TimeInterpolator easeOut = new TimeInterpolator() { 813012eefc84559507168982a7fc53dff667582b00Chiao Cheng public float getInterpolation(float input) { 823012eefc84559507168982a7fc53dff667582b00Chiao Cheng return -DOMAIN * ((input=input/DURATION-1)*input*input*input - 1) + START; 833012eefc84559507168982a7fc53dff667582b00Chiao Cheng } 843012eefc84559507168982a7fc53dff667582b00Chiao Cheng }; 853012eefc84559507168982a7fc53dff667582b00Chiao Cheng public static final TimeInterpolator easeInOut = new TimeInterpolator() { 863012eefc84559507168982a7fc53dff667582b00Chiao Cheng public float getInterpolation(float input) { 873012eefc84559507168982a7fc53dff667582b00Chiao Cheng return ((input/=DURATION/2) < 1) ? 883012eefc84559507168982a7fc53dff667582b00Chiao Cheng (DOMAIN/2*input*input*input*input + START) 893012eefc84559507168982a7fc53dff667582b00Chiao Cheng : (-DOMAIN/2 * ((input-=2)*input*input*input - 2) + START); 903012eefc84559507168982a7fc53dff667582b00Chiao Cheng } 913012eefc84559507168982a7fc53dff667582b00Chiao Cheng }; 923012eefc84559507168982a7fc53dff667582b00Chiao Cheng } 933012eefc84559507168982a7fc53dff667582b00Chiao Cheng 943012eefc84559507168982a7fc53dff667582b00Chiao Cheng static class Quint { 953012eefc84559507168982a7fc53dff667582b00Chiao Cheng public static final TimeInterpolator easeIn = new TimeInterpolator() { 963012eefc84559507168982a7fc53dff667582b00Chiao Cheng public float getInterpolation(float input) { 973012eefc84559507168982a7fc53dff667582b00Chiao Cheng return DOMAIN*(input/=DURATION)*input*input*input*input + START; 983012eefc84559507168982a7fc53dff667582b00Chiao Cheng } 993012eefc84559507168982a7fc53dff667582b00Chiao Cheng }; 1003012eefc84559507168982a7fc53dff667582b00Chiao Cheng public static final TimeInterpolator easeOut = new TimeInterpolator() { 1013012eefc84559507168982a7fc53dff667582b00Chiao Cheng public float getInterpolation(float input) { 1023012eefc84559507168982a7fc53dff667582b00Chiao Cheng return DOMAIN*((input=input/DURATION-1)*input*input*input*input + 1) + START; 1033012eefc84559507168982a7fc53dff667582b00Chiao Cheng } 1043012eefc84559507168982a7fc53dff667582b00Chiao Cheng }; 1053012eefc84559507168982a7fc53dff667582b00Chiao Cheng public static final TimeInterpolator easeInOut = new TimeInterpolator() { 1063012eefc84559507168982a7fc53dff667582b00Chiao Cheng public float getInterpolation(float input) { 1073012eefc84559507168982a7fc53dff667582b00Chiao Cheng return ((input/=DURATION/2) < 1) ? 1083012eefc84559507168982a7fc53dff667582b00Chiao Cheng (DOMAIN/2*input*input*input*input*input + START) 1093012eefc84559507168982a7fc53dff667582b00Chiao Cheng : (DOMAIN/2*((input-=2)*input*input*input*input + 2) + START); 1103012eefc84559507168982a7fc53dff667582b00Chiao Cheng } 1113012eefc84559507168982a7fc53dff667582b00Chiao Cheng }; 1123012eefc84559507168982a7fc53dff667582b00Chiao Cheng } 1133012eefc84559507168982a7fc53dff667582b00Chiao Cheng 1143012eefc84559507168982a7fc53dff667582b00Chiao Cheng static class Sine { 1153012eefc84559507168982a7fc53dff667582b00Chiao Cheng public static final TimeInterpolator easeIn = new TimeInterpolator() { 1163012eefc84559507168982a7fc53dff667582b00Chiao Cheng public float getInterpolation(float input) { 1173012eefc84559507168982a7fc53dff667582b00Chiao Cheng return -DOMAIN * (float) Math.cos(input/DURATION * (Math.PI/2)) + DOMAIN + START; 1183012eefc84559507168982a7fc53dff667582b00Chiao Cheng } 1193012eefc84559507168982a7fc53dff667582b00Chiao Cheng }; 1203012eefc84559507168982a7fc53dff667582b00Chiao Cheng public static final TimeInterpolator easeOut = new TimeInterpolator() { 1213012eefc84559507168982a7fc53dff667582b00Chiao Cheng public float getInterpolation(float input) { 1223012eefc84559507168982a7fc53dff667582b00Chiao Cheng return DOMAIN * (float) Math.sin(input/DURATION * (Math.PI/2)) + START; 1233012eefc84559507168982a7fc53dff667582b00Chiao Cheng } 1243012eefc84559507168982a7fc53dff667582b00Chiao Cheng }; 1253012eefc84559507168982a7fc53dff667582b00Chiao Cheng public static final TimeInterpolator easeInOut = new TimeInterpolator() { 1263012eefc84559507168982a7fc53dff667582b00Chiao Cheng public float getInterpolation(float input) { 1273012eefc84559507168982a7fc53dff667582b00Chiao Cheng return -DOMAIN/2 * ((float)Math.cos(Math.PI*input/DURATION) - 1.0f) + START; 1283012eefc84559507168982a7fc53dff667582b00Chiao Cheng } 1293012eefc84559507168982a7fc53dff667582b00Chiao Cheng }; 1303012eefc84559507168982a7fc53dff667582b00Chiao Cheng } 1313012eefc84559507168982a7fc53dff667582b00Chiao Cheng 1323012eefc84559507168982a7fc53dff667582b00Chiao Cheng} 133