# VectorizedAnimationSpec

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

  ```
  interface VectorizedAnimationSpec<V : AnimationVector>
  ```
Known direct subclasses [VectorizedFiniteAnimationSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedFiniteAnimationSpec), [VectorizedInfiniteRepeatableSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedInfiniteRepeatableSpec)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedFiniteAnimationSpec` | All the finite `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec`s implement this interface, including: `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedKeyframesSpec`, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedTweenSpec`, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedRepeatableSpec`, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedSnapSpec`, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedSpringSpec`, etc. |
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedInfiniteRepeatableSpec` | This animation takes another `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedDurationBasedAnimationSpec` and plays it **infinite** times. |

Known indirect subclasses [VectorizedDurationBasedAnimationSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedDurationBasedAnimationSpec), [VectorizedFloatAnimationSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedFloatAnimationSpec), [VectorizedKeyframesSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedKeyframesSpec), [VectorizedRepeatableSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedRepeatableSpec), [VectorizedSnapSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedSnapSpec), [VectorizedSpringSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedSpringSpec), [VectorizedTweenSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedTweenSpec)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedDurationBasedAnimationSpec` | Base class for `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec`s that are based on a fixed `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedDurationBasedAnimationSpec#durationMillis()`. |
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedFloatAnimationSpec` | A convenient implementation of `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedFloatAnimationSpec` that turns a `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FloatAnimationSpec` into a multi-dimensional `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedFloatAnimationSpec`, by using the same `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/FloatAnimationSpec` on each dimension of the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector` that is being animated. |
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedKeyframesSpec` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedKeyframesSpec` class manages the animation based on the values defined at different timestamps in the duration of the animation (i.e. different keyframes). |
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedRepeatableSpec` | This animation takes another `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedDurationBasedAnimationSpec` and plays it `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedRepeatableSpec#(kotlin.Int,androidx.compose.animation.core.VectorizedDurationBasedAnimationSpec,androidx.compose.animation.core.RepeatMode,androidx.compose.animation.core.StartOffset)` times. |
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedSnapSpec` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedSnapSpec` immediately snaps the animating value to the end value. |
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedSpringSpec` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedSpringSpec` uses spring animations to animate (each dimension of) `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector`s. |
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedTweenSpec` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedTweenSpec` animates a `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector` value by interpolating the start and end value, in the given `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedTweenSpec#(kotlin.Int,kotlin.Int,androidx.compose.animation.core.Easing)` using the given `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedTweenSpec#(kotlin.Int,kotlin.Int,androidx.compose.animation.core.Easing)` curve. |

*** ** * ** ***

`https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec`s are stateless vector based animation specifications. They do not assume any starting/ending conditions. Nor do they manage a lifecycle. All it stores is the configuration that is particular to the type of the animation. easing and duration for `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedTweenSpec`s, or spring constants for `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedSpringSpec`s. Its stateless nature allows the same `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec` to be reused by a few different running animations with different starting and ending values. More importantly, it allows the system to reuse the same animation spec when the animation target changes in-flight.

Since `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec`s are stateless, it requires starting value/velocity and ending value to be passed in, along with playtime, to calculate the value or velocity at that time. Play time here is the progress of the animation in terms of milliseconds, where 0 means the start of the animation and `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec#getDurationNanos(androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector)` returns the play time for the end of the animation.

**Note** : For use cases where the starting values/velocity and ending values aren't expected to change, it is recommended to use `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/Animation` that caches these static values and hence does not require them to be supplied in the value/velocity calculation.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/Animation` |   |

## Summary

| ### Public functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec#getDurationNanos(androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector)(initialValue: V, targetValue: V, initialVelocity: V)` Calculates the duration of an animation. | Cmn |
| `open V` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec#getEndVelocity(androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector)(initialValue: V, targetValue: V, initialVelocity: V)` Calculates the end velocity of the animation with the provided start/end values, and start velocity. | Cmn |
| `V` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec#getValueFromNanos(kotlin.Long,androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector)( playTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, initialValue: V, targetValue: V, initialVelocity: V )` Calculates the value of the animation at given the playtime, with the provided start/end values, and start velocity. | Cmn |
| `V` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec#getVelocityFromNanos(kotlin.Long,androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector)( playTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, initialValue: V, targetValue: V, initialVelocity: V )` Calculates the velocity of the animation at given the playtime, with the provided start/end values, and start velocity. | Cmn |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec#isInfinite()` Whether or not the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec` specifies an infinite animation. | Cmn |

## Public functions

### getDurationNanos

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

```
fun getDurationNanos(initialValue: V, targetValue: V, initialVelocity: V): Long
```

Calculates the duration of an animation. For duration-based animations, this will return the pre-defined duration. For physics-based animations, the duration will be estimated based on the physics configuration (such as spring stiffness, damping ratio, visibility threshold) as well as the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec#getDurationNanos(androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector)`, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec#getDurationNanos(androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector)` values, and `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec#getDurationNanos(androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector,androidx.compose.animation.core.AnimationVector)`.

| Parameters |
|---|---|
| `initialValue: V` | start value of the animation |
| `targetValue: V` | end value of the animation |
| `initialVelocity: V` | start velocity of the animation |

### getEndVelocity

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

```
open fun getEndVelocity(initialValue: V, targetValue: V, initialVelocity: V): V
```

Calculates the end velocity of the animation with the provided start/end values, and start velocity. For duration-based animations, end velocity will be the velocity of the animation at the duration time. This is also the default assumption. However, for physics-based animations, end velocity is an `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector` of 0s.

| Parameters |
|---|---|
| `initialValue: V` | start value of the animation |
| `targetValue: V` | end value of the animation |
| `initialVelocity: V` | start velocity of the animation |

### getValueFromNanos

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

```
fun getValueFromNanos(
    playTimeNanos: Long,
    initialValue: V,
    targetValue: V,
    initialVelocity: V
): V
```

Calculates the value of the animation at given the playtime, with the provided start/end values, and start velocity.

| Parameters |
|---|---|
| `playTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | time since the start of the animation |
| `initialValue: V` | start value of the animation |
| `targetValue: V` | end value of the animation |
| `initialVelocity: V` | start velocity of the animation |

### getVelocityFromNanos

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

```
fun getVelocityFromNanos(
    playTimeNanos: Long,
    initialValue: V,
    targetValue: V,
    initialVelocity: V
): V
```

Calculates the velocity of the animation at given the playtime, with the provided start/end values, and start velocity.

| Parameters |
|---|---|
| `playTimeNanos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | time since the start of the animation |
| `initialValue: V` | start value of the animation |
| `targetValue: V` | end value of the animation |
| `initialVelocity: V` | start velocity of the animation |

## Public properties

### isInfinite

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

```
val isInfinite: Boolean
```

Whether or not the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec` specifies an infinite animation. That is, one that will not finish by itself, one that needs an external action to stop. For examples, an indeterminate progress bar, which will only stop when it is removed from the composition.