animateColorAsState

@Composable
fun animateColorAsState(targetValue: Color, animationSpec: AnimationSpec<Color> = colorDefaultSpring, label: String = "ColorAnimation", finishedListener: (Color) -> Unit? = null): State<Color>

Animates towards targetValue whenever it changes. A running animation continues from its current value towards the new target instead of restarting.

The color travels through Oklab, the space ColorToVector describes.

The animation runs for as long as this call stays in the composition and cannot be stopped from outside it; use Animatable for an animation the caller can cancel.

Return

a state holding the color of the current frame.

Parameters

targetValue

the color to animate towards.

animationSpec

how the value moves through time; a spring by default.

label

names this animation in a tool that inspects a composition.

finishedListener

called with the target color once the animation arrives; null by default.