Last active
February 24, 2024 12:46
-
-
Save AndreVero/f4b3bdb518d8797cd708a500492f599b to your computer and use it in GitHub Desktop.
Draw secondary items in glovolike animation
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
// Draw secondary items | |
items.forEachIndexed { i, item -> | |
// Firstly count the angle on which we | |
// should position secondary item in degrees | |
// -90 will help to position degrees in | |
// the right appropriately (you can play around with that) | |
val angleInDegrees = (i * distance - 90) | |
// Convert angle to radians | |
val angleInRad = angleInDegrees * (PI / 180).toFloat() | |
// In essence, this function helps | |
// find the coordinates of a point on a circle based | |
// on its radius (mainCircleRadius), | |
// center (circleCenter), and the angle (angleInRad) | |
// at which you want to find the point. | |
val currentOffset = Offset( | |
x = mainCircleRadius.toPx() * cos(angleInRad) + circleCenter.x, | |
y = mainCircleRadius.toPx() * sin(angleInRad) + circleCenter.y | |
) | |
drawCircle( | |
color = Color.White, | |
radius = innerCircleRadius.toPx(), | |
center = currentOffset | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment