🌈 Create new beautiful Compose Gradients with our new wesite ->
Class

VectorizedKeyframesSpec

VectorizedKeyframesSpec class manages the animation based on the values defined at different timestamps in the duration of the animation (i.e.

Source set: Common
public class VectorizedKeyframesSpec<V : AnimationVector> internal constructor(
    // List of all timestamps. Must include start (time = 0), end (time = durationMillis) and all
    // other timestamps found in [keyframes].
    private val timestamps: IntList,
    private val keyframes: IntObjectMap<VectorizedKeyframeSpecElementInfo<V>>,
    override val durationMillis: Int,
    override val delayMillis: Int,
    // Easing used for any segment of time not covered by [keyframes].
    private val defaultEasing: Easing,
    // The [ArcMode] used from time `0` until the first keyframe. So, it applies
    // for the entire duration if [keyframes] is empty.
    private val initialArcMode: ArcMode,
) : VectorizedDurationBasedAnimationSpec<V>

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 keyframes parameter. VectorizedKeyframesSpec allows very specific animation definitions with a precision to millisecond.

Here's an example of creating a VectorizedKeyframesSpec animation: (keyframes and KeyframesSpec.KeyframesSpecConfig could make defining key frames much more readable.)

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 VectorizedKeyframeSpecElementInfo.arcMode on each keyframe. If no keyframe information is provided, initialArcMode is used.

Functions

getValueFromNanos

Source set: Common
override fun getValueFromNanos(
        playTimeNanos: Long,
        initialValue: V,
        targetValue: V,
        initialVelocity: V,
    ): V

getVelocityFromNanos

Source set: Common
override fun getVelocityFromNanos(
        playTimeNanos: Long,
        initialValue: V,
        targetValue: V,
        initialVelocity: V,
    ): V