e41019364de3314c7395a49ce6859d3818a811b6
2 * Copyright (C) 2010 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com
.actionbarsherlock
.internal
.nineoldandroids
.animation
;
20 * This evaluator can be used to perform type interpolation between <code>float</code> values.
22 public class FloatEvaluator
implements TypeEvaluator
<Number
> {
25 * This function returns the result of linearly interpolating the start and end values, with
26 * <code>fraction</code> representing the proportion between the start and end values. The
27 * calculation is a simple parametric calculation: <code>result = x0 + t * (v1 - v0)</code>,
28 * where <code>x0</code> is <code>startValue</code>, <code>x1</code> is <code>endValue</code>,
29 * and <code>t</code> is <code>fraction</code>.
31 * @param fraction The fraction from the starting to the ending values
32 * @param startValue The start value; should be of type <code>float</code> or
34 * @param endValue The end value; should be of type <code>float</code> or <code>Float</code>
35 * @return A linear interpolation between the start and end values, given the
36 * <code>fraction</code> parameter.
38 public Float
evaluate(float fraction
, Number startValue
, Number endValue
) {
39 float startFloat
= startValue
.floatValue();
40 return startFloat
+ fraction
* (endValue
.floatValue() - startFloat
);