animateColor

@Composable
fun <S> Transition<S>.animateColor(transitionSpec: @Composable Transition.Segment<S>.() -> FiniteAnimationSpec<Color> = { spring() }, label: String = "ColorAnimation", targetValueByState: @Composable (state: S) -> Color): State<Color>

Animates a color as part of this Transition, which owns the animation's lifetime.

targetValueByState is composable, so it may read state or a composition local. A new color it returns for a state the transition has already reached is also animated to.

Return

a state holding the color of the current frame.

Parameters

transitionSpec

how the value moves through time between a given pair of states; a spring for every pair by default.

label

names this animation among the others of the same transition.

targetValueByState

the color each state of the transition stands for.


@Composable
fun InfiniteTransition.animateColor(initialValue: Color, targetValue: Color, animationSpec: InfiniteRepeatableSpec<Color>, label: String = "ColorAnimation"): State<Color>

Animates a color from initialValue to targetValue and repeats for as long as this InfiniteTransition stays in the composition, restarting or reversing on each iteration according to the RepeatMode of animationSpec.

Changing initialValue or targetValue restarts the animation at the new endpoints.

Return

a state holding the color of the current frame.

Parameters

initialValue

the color each iteration starts from.

targetValue

the color each iteration runs to.

animationSpec

how the value moves through time, and how each iteration follows the last.

label

names this animation among the others of the same transition.