Google is committed to advancing racial equity for Black communities. See how.

VectorizedFloatAnimationSpec

class VectorizedFloatAnimationSpec<V : AnimationVector> : VectorizedAnimationSpec<V>
kotlin.Any
   ↳ androidx.compose.animation.core.VectorizedFloatAnimationSpec

A convenient implementation of VectorizedFloatAnimationSpec that turns a FloatAnimationSpec into a multi-dimensional VectorizedFloatAnimationSpec, by using the same FloatAnimationSpec on each dimension of the AnimationVector that is being animated.

Summary

Public constructors

Creates a VectorizedAnimationSpec from a FloatAnimationSpec.

Public methods
Long
getDurationMillis(start: V, end: V, startVelocity: V)

Calculates the duration of an animation.

V
getEndVelocity(start: V, end: V, startVelocity: V)

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

V
getValue(playTime: Long, start: V, end: V, startVelocity: V)

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

V
getVelocity(playTime: Long, start: V, end: V, startVelocity: V)

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

Public constructors

<init>

VectorizedFloatAnimationSpec(anim: FloatAnimationSpec)

Creates a VectorizedAnimationSpec from a FloatAnimationSpec. The given FloatAnimationSpec will be used to animate every dimension of the AnimationVector.

Parameters
anim: FloatAnimationSpec the animation spec for animating each dimension of the AnimationVector

Public methods

getDurationMillis

fun getDurationMillis(
    start: V,
    end: V,
    startVelocity: 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 start, end values, and startVelocity.

Parameters
start: V start value of the animation
end: V end value of the animation
startVelocity: V start velocity of the animation

getEndVelocity

fun getEndVelocity(
    start: V,
    end: V,
    startVelocity: 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 AnimationVector of 0s.

Parameters
start: V start value of the animation
end: V end value of the animation
startVelocity: V start velocity of the animation

getValue

fun getValue(
    playTime: Long,
    start: V,
    end: V,
    startVelocity: V
): V

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

Parameters
playTime: Long time since the start of the animation
start: V start value of the animation
end: V end value of the animation
startVelocity: V start velocity of the animation

getVelocity

fun getVelocity(
    playTime: Long,
    start: V,
    end: V,
    startVelocity: V
): V

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

Parameters
playTime: Long time since the start of the animation
start: V start value of the animation
end: V end value of the animation
startVelocity: V start velocity of the animation