# TwoWayConverter

Artifact: [androidx.compose.animation:animation-core](https://developer.android.com/jetpack/androidx/releases/compose-animation) [View Source](https://cs.android.com/search?q=file:androidx/compose/animation/core/VectorConverters.kt+class:androidx.compose.animation.core.TwoWayConverter) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0) Common/All
- Cmn

  ```
  interface TwoWayConverter<T : Any?, V : AnimationVector>
  ```

*** ** * ** ***

`https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter` class contains the definition on how to convert from an arbitrary type `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter` to a `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector`, and convert the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector` back to the type `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter`. This allows animations to run on any type of objects, e.g. position, rectangle, color, etc.

## Summary

| ### Public properties |
|---|---|---|
| `(V) -> T` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter#convertFromVector()` Defines how to convert a Vector type (i.e. `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector1D`, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector2D`, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector3D` or `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector4D`, depends on the dimensions of type T) back to type `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter`. | Cmn |
| `(T) -> V` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter#convertToVector()` Defines how a type `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter` should be converted to a Vector type (i.e. `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector1D`, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector2D`, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector3D` or `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector4D`, depends on the dimensions of type T). | Cmn |

| ### Extension functions |
|---|---|---|
| `V` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?, V : https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector> https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter<T, V>.https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter#(androidx.compose.animation.core.TwoWayConverter).createZeroVectorFrom(kotlin.Any)( value: T )` Creates an AnimationVector with all the values set to 0 using the provided `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter` and the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.TwoWayConverter).createZeroVectorFrom(kotlin.Any)`. | Cmn |

## Public properties

### convertFromVector

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0)

```
val convertFromVector: (V) -> T
```

Defines how to convert a Vector type (i.e. `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector1D`, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector2D`, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector3D` or `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector4D`, depends on the dimensions of type T) back to type `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter`.

### convertToVector

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0)

```
val convertToVector: (T) -> V
```

Defines how a type `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter` should be converted to a Vector type (i.e. `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector1D`, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector2D`, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector3D` or `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector4D`, depends on the dimensions of type T).

## Extension functions

### TwoWayConverter.createZeroVectorFrom

Cmn Artifact: [androidx.compose.animation:animation-core](https://developer.android.com/jetpack/androidx/releases/compose-animation) [View Source](https://cs.android.com/search?q=file:androidx/compose/animation/core/AnimationState.kt+function:createZeroVectorFrom)

```
fun <T : Any?, V : AnimationVector> TwoWayConverter<T, V>.createZeroVectorFrom(
    value: T
): V
```

Creates an AnimationVector with all the values set to 0 using the provided `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter` and the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.TwoWayConverter).createZeroVectorFrom(kotlin.Any)`.

| Returns |
|---|---|
| `V` | a new AnimationVector instance of type `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.animation.core.TwoWayConverter).createZeroVectorFrom(kotlin.Any)`. |