117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase/*
217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * Copyright (C) 2010 The Android Open Source Project
317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase *
417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * Licensed under the Apache License, Version 2.0 (the "License");
517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * you may not use this file except in compliance with the License.
617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * You may obtain a copy of the License at
717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase *
817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase *      http://www.apache.org/licenses/LICENSE-2.0
917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase *
1017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * Unless required by applicable law or agreed to in writing, software
1117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * distributed under the License is distributed on an "AS IS" BASIS,
1217fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * See the License for the specific language governing permissions and
1417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * limitations under the License.
1517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */
1617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
1717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haasepackage android.animation;
1817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
1917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase/**
20a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * Interface for use with the {@link ValueAnimator#setEvaluator(TypeEvaluator)} function. Evaluators
2117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * allow developers to create animations on arbitrary property types, by allowing them to supply
22bac752632c7f2cea9ae5bb1e21408b4095e71afaSascha Haeberling * custom evaluators for types that are not automatically understood and used by the animation
2317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase * system.
2417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase *
25a18a86b43e40e3c15dcca0ae0148d641be9b25feChet Haase * @see ValueAnimator#setEvaluator(TypeEvaluator)
2617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase */
27b39f051631250c49936a475d0e64584afb7f1b93Chet Haasepublic interface TypeEvaluator<T> {
2817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
2917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase    /**
3017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * This function returns the result of linearly interpolating the start and end values, with
3117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * <code>fraction</code> representing the proportion between the start and end values. The
325f9ea81c99306b2741db3109fb68b52c652f39f2Chet Haase     * calculation is a simple parametric calculation: <code>result = x0 + t * (x1 - x0)</code>,
3317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * where <code>x0</code> is <code>startValue</code>, <code>x1</code> is <code>endValue</code>,
3417fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * and <code>t</code> is <code>fraction</code>.
3517fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *
3617fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * @param fraction   The fraction from the starting to the ending values
3717fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * @param startValue The start value.
3817fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * @param endValue   The end value.
3917fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     * @return A linear interpolation between the start and end values, given the
4017fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     *         <code>fraction</code> parameter.
4117fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase     */
42b39f051631250c49936a475d0e64584afb7f1b93Chet Haase    public T evaluate(float fraction, T startValue, T endValue);
4317fb4b0d1cfbad1f026fec704c86640f070b4c2fChet Haase
44bac752632c7f2cea9ae5bb1e21408b4095e71afaSascha Haeberling}
45