# RectEvaluator

Artifact: [androidx.core:core-animation](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/animation/RectEvaluator.java+class:androidx.core.animation.RectEvaluator) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

*** ** * ** ***


```
public class RectEvaluator implements TypeEvaluator<Rect>
```

<br />

*** ** * ** ***

This evaluator can be used to perform type interpolation between `Rect` values.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/core/animation/RectEvaluator#RectEvaluator()()` Construct a RectEvaluator that returns a new Rect on every evaluate call. |
| `https://developer.android.com/reference/androidx/core/animation/RectEvaluator#RectEvaluator(android.graphics.Rect)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Rect.html reuseRect)` Constructs a RectEvaluator that modifies and returns `reuseRect` in `https://developer.android.com/reference/androidx/core/animation/RectEvaluator#evaluate(float,android.graphics.Rect,android.graphics.Rect)` calls. |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Rect.html` | `https://developer.android.com/reference/androidx/core/animation/RectEvaluator#evaluate(float,android.graphics.Rect,android.graphics.Rect)(float fraction, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Rect.html startValue, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Rect.html 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. |

## Public constructors

### RectEvaluator

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public RectEvaluator()
```

Construct a RectEvaluator that returns a new Rect on every evaluate call. To avoid creating an object for each evaluate call, `https://developer.android.com/reference/androidx/core/animation/RectEvaluator#RectEvaluator(android.graphics.Rect)` should be used whenever possible.

### RectEvaluator

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public RectEvaluator(@NonNull Rect reuseRect)
```

Constructs a RectEvaluator that modifies and returns `reuseRect` in `https://developer.android.com/reference/androidx/core/animation/RectEvaluator#evaluate(float,android.graphics.Rect,android.graphics.Rect)` calls. The value returned from `https://developer.android.com/reference/androidx/core/animation/RectEvaluator#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.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Rect.html reuseRect` | A Rect to be modified and returned by evaluate. |

## Public methods

### evaluate

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public @NonNull Rect evaluate(float fraction, @NonNull Rect startValue, @NonNull 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 `https://developer.android.com/reference/androidx/core/animation/RectEvaluator#RectEvaluator(android.graphics.Rect)` was used to construct this RectEvaluator, the object returned will be the `reuseRect` passed into the constructor.

| Parameters |
|---|---|
| `float fraction` | The fraction from the starting to the ending values |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Rect.html startValue` | The start Rect |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Rect.html endValue` | The end Rect |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Rect.html` | A linear interpolation between the start and end values, given the `fraction` parameter. |