RectEvaluatorpublic class RectEvaluator extends Object implements TypeEvaluatorThis evaluator can be used to perform type interpolation between Rect values. |
Fields Summary |
---|
private android.graphics.Rect | mRectWhen 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.
mRect = reuseRect;
|
Methods Summary |
---|
public android.graphics.Rect | evaluate(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.
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;
}
|
|