# AnimationSpec

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/AnimationSpec.kt+class:androidx.compose.animation.core.AnimationSpec) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-animation#1.0.0) Common/All
- Cmn

  ```
  interface AnimationSpec<T : Any?>
  ```
Known direct subclasses [FiniteAnimationSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FiniteAnimationSpec), [FloatAnimationSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FloatAnimationSpec), [InfiniteRepeatableSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/InfiniteRepeatableSpec)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FiniteAnimationSpec` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FiniteAnimationSpec` is the interface that all non-infinite `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec`s implement, including: `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TweenSpec`, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/SpringSpec`, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/KeyframesSpec`, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/RepeatableSpec`, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/SnapSpec`, etc. |
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FloatAnimationSpec` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FloatAnimationSpec` interface is similar to `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec`, except it deals exclusively with floats. |
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/InfiniteRepeatableSpec` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/InfiniteRepeatableSpec` repeats the provided `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/InfiniteRepeatableSpec#(androidx.compose.animation.core.DurationBasedAnimationSpec,androidx.compose.animation.core.RepeatMode,androidx.compose.animation.core.StartOffset)` infinite amount of times. |

Known indirect subclasses [ArcAnimationSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/ArcAnimationSpec), [DurationBasedAnimationSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DurationBasedAnimationSpec), [FloatSpringSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FloatSpringSpec), [FloatTweenSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FloatTweenSpec), [KeyframesSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/KeyframesSpec), [KeyframesWithSplineSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/KeyframesWithSplineSpec), [RepeatableSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/RepeatableSpec), [SnapSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/SnapSpec), [SpringSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/SpringSpec), [TweenSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TweenSpec)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/ArcAnimationSpec` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DurationBasedAnimationSpec` that interpolates 2-dimensional values using arcs of quarter of an Ellipse. |
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DurationBasedAnimationSpec` | This describes `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec`s that are based on a fixed duration, such as `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/KeyframesSpec`, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TweenSpec`, and `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/SnapSpec`. |
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FloatSpringSpec` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FloatSpringSpec` animation uses a spring animation to animate a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` value. |
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FloatTweenSpec` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FloatTweenSpec` animates a Float value from any start value to any end value using a provided `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FloatTweenSpec#(kotlin.Int,kotlin.Int,androidx.compose.animation.core.Easing)` function. |
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/KeyframesSpec` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/KeyframesSpec` creates a `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedKeyframesSpec` animation. |
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/KeyframesWithSplineSpec` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/KeyframesWithSplineSpec` creates a keyframe based `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DurationBasedAnimationSpec` using the Monotone cubic Hermite spline to interpolate between the values in `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/KeyframesWithSplineSpec#config()`. |
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/RepeatableSpec` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/RepeatableSpec` takes another `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/DurationBasedAnimationSpec` and plays it `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/RepeatableSpec#(kotlin.Int,androidx.compose.animation.core.DurationBasedAnimationSpec,androidx.compose.animation.core.RepeatMode,androidx.compose.animation.core.StartOffset)` times. |
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/SnapSpec` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/SnapSpec` describes a jump-cut type of animation. |
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/SpringSpec` | Creates a `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/SpringSpec` that uses the given spring constants (i.e. `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/SpringSpec#(kotlin.Float,kotlin.Float,kotlin.Any)` and `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/SpringSpec#(kotlin.Float,kotlin.Float,kotlin.Any)`. |
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TweenSpec` | Creates a TweenSpec configured with the given duration, delay, and easing curve. |

*** ** * ** ***

`https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec` stores the specification of an animation, including 1) the data type to be animated, and 2) the animation configuration (i.e. `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec`) that will be used once the data (of type `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec`) has been converted to `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector`.

Any type `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec` can be animated by the system as long as a `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter` is supplied to convert the data type `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec` from and to an `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector`. There are a number of converters available out of the box. For example, to animate `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntOffset` the system uses `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary#(androidx.compose.ui.unit.IntOffset.Companion).VectorConverter()` to convert the object to `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector2D`, so that both x and y dimensions are animated independently with separate velocity tracking. This enables multidimensional objects to be animated in a true multi-dimensional way. It is particularly useful for smoothly handling animation interruptions (such as when the target changes during the animation).

## Summary

| ### Public functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec<V>` | `<V : https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector> https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec#vectorize(androidx.compose.animation.core.TwoWayConverter)(converter: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter<T, V>)` Creates a `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec` with the given `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter`. | Cmn |

## Public functions

### vectorize

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

```
fun <V : AnimationVector> vectorize(converter: TwoWayConverter<T, V>): VectorizedAnimationSpec<V>
```

Creates a `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec` with the given `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter`.

The underlying animation system operates on `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector`s. `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec` will be converted to `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector` to animate. `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec` describes how the converted `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector` should be animated. E.g. The animation could simply interpolate between the start and end values (i.e.`https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TweenSpec`), or apply spring physics to produce the motion (i.e. `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/SpringSpec`), etc)

| Parameters |
|---|---|
| `converter: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/TwoWayConverter<T, V>` | converts the type `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec` from and to `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector` type |