---
title: "PathEasing"
description: "An easing function for an arbitrary [Path].

The [Path] must begin at `(0, 0)` and end at `(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 be continuous along the x axis. The [Path] should also be monotonically
increasing along the x axis. If the [Path] is not monotonic and there are multiple y values for a
given x, the chosen y value is implementation dependent and may vary.

The [Path] must not contain any [Path.close] command as it would force the path to restart from
the beginning.

This is equivalent to the Android `PathInterpolator`.

[CubicBezierEasing] should be used if a single bezier curve is required as it performs fewer
allocations. [PathEasing] should be used when creating an arbitrary path.

Note: a [PathEasing] instance can be used from any thread, but not concurrently."
type: "class"
---

<div class='type'>Class</div>


<a id='references'></a>

<div class='sourceset sourceset-common'>Common</div>


```kotlin
public class PathEasing(private val path: Path) : Easing
```


An easing function for an arbitrary `Path`.

The `Path` must begin at `(0, 0)` and end at `(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 be continuous along the x axis. The `Path` should also be monotonically
increasing along the x axis. If the `Path` is not monotonic and there are multiple y values for a
given x, the chosen y value is implementation dependent and may vary.

The `Path` must not contain any `Path.close` command as it would force the path to restart from
the beginning.

This is equivalent to the Android `PathInterpolator`.

`CubicBezierEasing` should be used if a single bezier curve is required as it performs fewer
allocations. `PathEasing` should be used when creating an arbitrary path.

Note: a `PathEasing` instance can be used from any thread, but not concurrently.

#### Parameters

| | |
| --- | --- |
| path | The `Path` to use to make the curve representing the easing curve. |




## Code Examples

### PathEasingSample
```kotlin
@Composable
fun PathEasingSample() {
    // Creates a custom PathEasing curve and applies it to an animation
    var toggled by remember { mutableStateOf(true) }
    val pathForAnimation = remember {
        Path().apply {
            moveTo(0f, 0f)
            cubicTo(0.05f, 0f, 0.133333f, 0.06f, 0.166666f, 0.4f)
            cubicTo(0.208333f, 0.82f, 0.25f, 1f, 1f, 1f)
        }
    }
    val offset by
        animateIntOffsetAsState(
            targetValue = if (toggled) IntOffset.Zero else IntOffset(300, 300),
            label = "offset",
            animationSpec = tween(durationMillis = 1000, easing = PathEasing(pathForAnimation)),
        )
    Box(modifier = Modifier.fillMaxSize().clickable { toggled = !toggled }) {
        Box(modifier = Modifier.offset { offset }.size(100.dp).background(Color.Blue))
    }
}
```

