Created
March 29, 2022 11:16
-
-
Save cp-hardik-p/0f84c90480d7addb67a7ae271fe973c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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