# 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)

*** ** * ** ***


```
class RectEvaluator : TypeEvaluator<Rect!>
```

<br />

*** ** * ** ***

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

## Summary

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

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/android/graphics/Rect.html` | `https://developer.android.com/reference/kotlin/androidx/core/animation/RectEvaluator#evaluate(float,android.graphics.Rect,android.graphics.Rect)(fraction: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, startValue: https://developer.android.com/reference/android/graphics/Rect.html, endValue: https://developer.android.com/reference/android/graphics/Rect.html)` 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)

```
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/kotlin/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)

```
RectEvaluator(reuseRect: Rect)
```

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

## Public functions

### evaluate

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

```
fun evaluate(fraction: Float, startValue: Rect, endValue: Rect): Rect
```

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/kotlin/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 |
|---|---|
| `fraction: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The fraction from the starting to the ending values |
| `startValue: https://developer.android.com/reference/android/graphics/Rect.html` | The start Rect |
| `endValue: https://developer.android.com/reference/android/graphics/Rect.html` | The end Rect |

| Returns |
|---|---|
| `https://developer.android.com/reference/android/graphics/Rect.html` | A linear interpolation between the start and end values, given the `fraction` parameter. |