FileDocCategorySizeDatePackage
RectEvaluator.javaAPI DocAndroid 5.1 API3407Thu Mar 12 22:22:08 GMT 2015android.animation

RectEvaluator

public class RectEvaluator extends Object implements TypeEvaluator
This evaluator can be used to perform type interpolation between Rect values.

Fields Summary
private android.graphics.Rect
mRect
When null, a new Rect is returned on every evaluate call. When non-null, mRect will be modified and returned on every evaluate.
Constructors Summary
public RectEvaluator()
Construct a RectEvaluator that returns a new Rect on every evaluate call. To avoid creating an object for each evaluate call, {@link RectEvaluator#RectEvaluator(android.graphics.Rect)} should be used whenever possible.

    
public RectEvaluator(android.graphics.Rect reuseRect)
Constructs a RectEvaluator that modifies and returns reuseRect in {@link #evaluate(float, android.graphics.Rect, android.graphics.Rect)} calls. The value returned from {@link #evaluate(float, android.graphics.Rect, android.graphics.Rect)} should not be cached because it will change over time as the object is reused on each call.

param
reuseRect A Rect to be modified and returned by evaluate.

        mRect = reuseRect;
    
Methods Summary
public android.graphics.Rectevaluate(float fraction, android.graphics.Rect startValue, android.graphics.Rect endValue)
This function returns the result of linearly interpolating the start and end Rect values, with fraction representing the proportion between the start and end values. The calculation is a simple parametric calculation on each of the separate components in the Rect objects (left, top, right, and bottom).

If {@link #RectEvaluator(android.graphics.Rect)} was used to construct this RectEvaluator, the object returned will be the reuseRect passed into the constructor.

param
fraction The fraction from the starting to the ending values
param
startValue The start Rect
param
endValue The end Rect
return
A linear interpolation between the start and end values, given the fraction parameter.

        int left = startValue.left + (int) ((endValue.left - startValue.left) * fraction);
        int top = startValue.top + (int) ((endValue.top - startValue.top) * fraction);
        int right = startValue.right + (int) ((endValue.right - startValue.right) * fraction);
        int bottom = startValue.bottom + (int) ((endValue.bottom - startValue.bottom) * fraction);
        if (mRect == null) {
            return new Rect(left, top, right, bottom);
        } else {
            mRect.set(left, top, right, bottom);
            return mRect;
        }