# VectorizedKeyframesSpec

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

  ```
  class VectorizedKeyframesSpec<V : AnimationVector> : VectorizedDurationBasedAnimationSpec<V>
  ```

*** ** * ** ***

`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). Each keyframe can be provided via `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedKeyframesSpec#keyframes()` parameter. `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedKeyframesSpec` allows very specific animation definitions with a precision to millisecond.

Here's an example of creating a `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedKeyframesSpec` animation: (`https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedKeyframesSpec#keyframes()` and `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/KeyframesSpec.KeyframesSpecConfig` could make defining key frames much more readable.)

```kotlin
val delay = 120
val startValue = AnimationVector3D(100f, 200f, 300f)
val endValue = AnimationVector3D(200f, 100f, 0f)
val keyframes = VectorizedKeyframesSpec(
     keyframes = mutableMapOf (
          0 to (startValue to LinearEasing),
          100 to (startValue to FastOutLinearInEasing)
     ),
     durationMillis = 200,
     delayMillis = delay
)
```

The interpolation between each value is dictated by `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedKeyframeSpecElementInfo#arcMode()` on each keyframe. If no keyframe information is provided, `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedKeyframesSpec#initialArcMode()` is used.

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

## Summary

| ### Public constructors |
|---|---|
| `<V : https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationVector> https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedKeyframesSpec#VectorizedKeyframesSpec(kotlin.collections.Map,kotlin.Int,kotlin.Int)( keyframes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-pair/index.html<V, https://developer.android.com/reference/kotlin/androidx/compose/animation/core/Easing>>, durationMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, delayMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` | Cmn |

| ### Public functions |
|---|---|---|
| `open V` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedKeyframesSpec#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 )` | Cmn |
| `open V` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedKeyframesSpec#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 |
|---|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedKeyframesSpec#delayMillis()` delay defines the amount of time that animation can be delayed. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedKeyframesSpec#durationMillis()` duration is the amount of time while animation is not yet finished. | Cmn |

### Inherited functions

From [androidx.compose.animation.core.VectorizedAnimationSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec) `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 From [androidx.compose.animation.core.VectorizedDurationBasedAnimationSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedDurationBasedAnimationSpec) `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedDurationBasedAnimationSpec#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

### Inherited properties

From [androidx.compose.animation.core.VectorizedFiniteAnimationSpec](https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedFiniteAnimationSpec) `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedFiniteAnimationSpec#isInfinite()`

Whether or not the `https://developer.android.com/reference/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec` specifies an infinite animation.
Cmn

## Public constructors

### VectorizedKeyframesSpec

Cmn

```
<V : AnimationVector> VectorizedKeyframesSpec(
    keyframes: Map<Int, Pair<V, Easing>>,
    durationMillis: Int,
    delayMillis: Int = 0
)
```

| Parameters |
|---|---|
| `keyframes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-pair/index.html<V, https://developer.android.com/reference/kotlin/androidx/compose/animation/core/Easing>>` | a map from time to a value/easing function pair. The value in each entry defines the animation value at that time, and the easing curve is used in the interval starting from that time. |
| `durationMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | total duration of the animation |
| `delayMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = 0` | the amount of the time the animation should wait before it starts. Defaults to 0. |

## Public functions

### getValueFromNanos

Cmn

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

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | When the initial or final value to animate within a keyframe is missing. |

### getVelocityFromNanos

Cmn

```
open 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

### delayMillis

Cmn

```
open val delayMillis: Int
```

delay defines the amount of time that animation can be delayed.

### durationMillis

Cmn

```
open val durationMillis: Int
```

duration is the amount of time while animation is not yet finished.