# PathInterpolator

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/PathInterpolator.java+class:androidx.core.animation.PathInterpolator) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

*** ** * ** ***


```
public class PathInterpolator implements Interpolator
```

<br />

*** ** * ** ***

An interpolator that can traverse a Path that extends from `Point``(0, 0)` to `(1, 1)`. The x coordinate along the `Path` is the input value and the output is the y coordinate of the line at that point. This means that the Path must conform to a function `y = f(x)`.

The `Path` must not have gaps in the x direction and must not loop back on itself such that there can be two points sharing the same x coordinate. It is alright to have a disjoint line in the vertical direction:
>
> ```
>     Path path = new Path();
>     path.lineTo(0.25f, 0.25f);
>     path.moveTo(0.25f, 0.5f);
>     path.lineTo(1f, 1f);
> ```

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/core/animation/PathInterpolator#PathInterpolator(android.graphics.Path)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Path.html path)` Create an interpolator for an arbitrary `Path`. |
| `https://developer.android.com/reference/androidx/core/animation/PathInterpolator#PathInterpolator(float,float)(float controlX, float controlY)` Create an interpolator for a quadratic Bezier curve. |
| `https://developer.android.com/reference/androidx/core/animation/PathInterpolator#PathInterpolator(android.content.Context,android.util.AttributeSet,org.xmlpull.v1.XmlPullParser)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/util/AttributeSet.html attrs, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/org/xmlpull/v1/XmlPullParser.html parser )` Create an interpolator from XML. |
| `https://developer.android.com/reference/androidx/core/animation/PathInterpolator#PathInterpolator(float,float,float,float)( float controlX1, float controlY1, float controlX2, float controlY2 )` Create an interpolator for a cubic Bezier curve. |
| `https://developer.android.com/reference/androidx/core/animation/PathInterpolator#PathInterpolator(android.content.res.Resources,android.content.res.Resources.Theme,android.util.AttributeSet,org.xmlpull.v1.XmlPullParser)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/res/Resources.html res, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/content/res/Resources.Theme.html theme, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/util/AttributeSet.html attrs, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/org/xmlpull/v1/XmlPullParser.html parser )` Create an interpolator from XML. |

| ### Public methods |
|---|---|
| `float` | `https://developer.android.com/reference/androidx/core/animation/PathInterpolator#getInterpolation(float)(@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, to = 1) float input)` Using the line in the Path in this interpolator that can be described as `y = f(x)`, finds the y coordinate of the line given `t` as the x coordinate. |

## Public constructors

### PathInterpolator

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

```
public PathInterpolator(@NonNull Path path)
```

Create an interpolator for an arbitrary `Path`. The `Path` must begin at `(0, 0)` and end at `(1, 1)`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Path.html path` | The `Path` to use to make the line representing the interpolator. |

### PathInterpolator

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

```
public PathInterpolator(float controlX, float controlY)
```

Create an interpolator for a quadratic Bezier curve. The end points `(0, 0)` and `(1, 1)` are assumed.

| Parameters |
|---|---|
| `float controlX` | The x coordinate of the quadratic Bezier control point. |
| `float controlY` | The y coordinate of the quadratic Bezier control point. |

### PathInterpolator

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

```
public PathInterpolator(
    @NonNull Context context,
    @Nullable AttributeSet attrs,
    @NonNull XmlPullParser parser
)
```

Create an interpolator from XML.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context` | The context. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/util/AttributeSet.html attrs` | The AttributeSet for pathInterpolator. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/org/xmlpull/v1/XmlPullParser.html parser` | The XmlPullParser that was used to create the AttributeSet with `https://developer.android.com/reference/android/util/Xml.html#asAttributeSet(org.xmlpull.v1.XmlPullParser)`. |

### PathInterpolator

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

```
public PathInterpolator(
    float controlX1,
    float controlY1,
    float controlX2,
    float controlY2
)
```

Create an interpolator for a cubic Bezier curve. The end points `(0, 0)` and `(1, 1)` are assumed.

| Parameters |
|---|---|
| `float controlX1` | The x coordinate of the first control point of the cubic Bezier. |
| `float controlY1` | The y coordinate of the first control point of the cubic Bezier. |
| `float controlX2` | The x coordinate of the second control point of the cubic Bezier. |
| `float controlY2` | The y coordinate of the second control point of the cubic Bezier. |

### PathInterpolator

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

```
public PathInterpolator(
    @NonNull Resources res,
    @Nullable Resources.Theme theme,
    @Nullable AttributeSet attrs,
    @NonNull XmlPullParser parser
)
```

Create an interpolator from XML.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/res/Resources.html res` | The resources. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/content/res/Resources.Theme.html theme` | The theme. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/util/AttributeSet.html attrs` | The AttributeSet for pathInterpolator. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/org/xmlpull/v1/XmlPullParser.html parser` | The XmlPullParser that was used to create the AttributeSet with `https://developer.android.com/reference/android/util/Xml.html#asAttributeSet(org.xmlpull.v1.XmlPullParser)`. |

## Public methods

### getInterpolation

```
public float getInterpolation(@FloatRange(from = 0, to = 1) float input)
```

Using the line in the Path in this interpolator that can be described as `y = f(x)`, finds the y coordinate of the line given `t` as the x coordinate. Values less than 0 will always return 0 and values greater than 1 will always return 1.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, to = 1) float input` | Treated as the x coordinate along the line. |

| Returns |
|---|---|
| `float` | The y coordinate of the Path along the line where x = `t`. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/animation/Interpolator#getInterpolation(float)` |   |