Skip to content

Instantly share code, notes, and snippets.

@cp-hardik-p
Created March 29, 2022 11:16
Show Gist options
  • Save cp-hardik-p/0f84c90480d7addb67a7ae271fe973c9 to your computer and use it in GitHub Desktop.
Save cp-hardik-p/0f84c90480d7addb67a7ae271fe973c9 to your computer and use it in GitHub Desktop.
@Composable
fun PacmanAnimation(infiniteTransition: InfiniteTransition) {
val mouthAnimation by infiniteTransition.animateFloat(
initialValue = 360F,
targetValue = 280F,
animationSpec = infiniteRepeatable(
animation = tween(800, easing = FastOutSlowInEasing),
repeatMode = RepeatMode.Restart
)
)
val antiMouthAnimation by infiniteTransition.animateFloat(
initialValue = 0F,
targetValue = 40F,
animationSpec = infiniteRepeatable(
animation = tween(800, easing = FastOutSlowInEasing),
repeatMode = RepeatMode.Restart
)
)
Canvas(
modifier = Modifier
.padding(top = 16.dp)
.size(100.dp)
) {
drawArc(
color = Color(0xFFFFd301),
startAngle = antiMouthAnimation,
sweepAngle = mouthAnimation,
useCenter = true,
)
drawCircle(
color = Black,
radius = 15f,
center = Offset(x = this.center.x + 15f, y = this.center.y - 85f)
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment