# PathInterpolator

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

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/animation/PathInterpolator "View this page in Java")

<br />

```
class PathInterpolator : 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:
>
> ```kotlin
>     Path path = new Path();
>     path.lineTo(0.25f, 0.25f);
>     path.moveTo(0.25f, 0.5f);
>     path.lineTo(1f, 1f);
> ```

## Summary

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

|                              ### Public functions                               |
|---------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | [getInterpolation](https://developer.android.com/reference/kotlin/androidx/core/animation/PathInterpolator#getInterpolation(float))`(input: @`[FloatRange](https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange)`(from = 0, to = 1) `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` 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

```
PathInterpolator(path: Path)
```

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

|                                     Parameters                                     |
|------------------------------------------------------------------------------------|-----------------------------------------------------------------|
| `path: `[Path](https://developer.android.com/reference/android/graphics/Path.html) | The`Path`to use to make the line representing the interpolator. |

### PathInterpolator

```
PathInterpolator(controlX: Float, controlY: Float)
```

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

|                                         Parameters                                          |
|---------------------------------------------------------------------------------------------|---------------------------------------------------------|
| `controlX: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | The x coordinate of the quadratic Bezier control point. |
| `controlY: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | The y coordinate of the quadratic Bezier control point. |

### PathInterpolator

```
PathInterpolator(
    context: Context,
    attrs: AttributeSet?,
    parser: XmlPullParser
)
```

Create an interpolator from XML.  

|                                              Parameters                                              |
|------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html)           | The context.                                                                                                                                                                                 |
| `attrs: `[AttributeSet](https://developer.android.com/reference/android/util/AttributeSet.html)`?`   | The AttributeSet for pathInterpolator.                                                                                                                                                       |
| `parser: `[XmlPullParser](https://developer.android.com/reference/org/xmlpull/v1/XmlPullParser.html) | The XmlPullParser that was used to create the AttributeSet with[asAttributeSet](https://developer.android.com/reference/android/util/Xml.html#asAttributeSet(org.xmlpull.v1.XmlPullParser)). |

### PathInterpolator

```
PathInterpolator(
    controlX1: Float,
    controlY1: Float,
    controlX2: Float,
    controlY2: Float
)
```

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

|                                          Parameters                                          |
|----------------------------------------------------------------------------------------------|-------------------------------------------------------------------|
| `controlX1: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | The x coordinate of the first control point of the cubic Bezier.  |
| `controlY1: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | The y coordinate of the first control point of the cubic Bezier.  |
| `controlX2: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | The x coordinate of the second control point of the cubic Bezier. |
| `controlY2: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | The y coordinate of the second control point of the cubic Bezier. |

### PathInterpolator

```
PathInterpolator(
    res: Resources,
    theme: Resources.Theme?,
    attrs: AttributeSet?,
    parser: XmlPullParser
)
```

Create an interpolator from XML.  

|                                                   Parameters                                                    |
|-----------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `res: `[Resources](https://developer.android.com/reference/android/content/res/Resources.html)                  | The resources.                                                                                                                                                                               |
| `theme: `[Resources.Theme](https://developer.android.com/reference/android/content/res/Resources.Theme.html)`?` | The theme.                                                                                                                                                                                   |
| `attrs: `[AttributeSet](https://developer.android.com/reference/android/util/AttributeSet.html)`?`              | The AttributeSet for pathInterpolator.                                                                                                                                                       |
| `parser: `[XmlPullParser](https://developer.android.com/reference/org/xmlpull/v1/XmlPullParser.html)            | The XmlPullParser that was used to create the AttributeSet with[asAttributeSet](https://developer.android.com/reference/android/util/Xml.html#asAttributeSet(org.xmlpull.v1.XmlPullParser)). |

## Public functions

### getInterpolation

```
fun getInterpolation(input: @FloatRange(from = 0, to = 1) Float): Float
```

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                                                                                                 |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------|
| `input: @`[FloatRange](https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange)`(from = 0, to = 1) `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | Treated as the x coordinate along the line. |

|                                     Returns                                     |
|---------------------------------------------------------------------------------|-----------------------------------------------------------|
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | The y coordinate of the Path along the line where x =`t`. |

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