Advertisement
Kostiggig

Untitled

Aug 14th, 2024
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. val scope = rememberCoroutineScope()
  2. val red = Color(0xFFFF7F4D)
  3. val gray = Color(0xFF34343C).copy(alpha = 0.12f)
  4. var start by remember {
  5. mutableStateOf(-1)
  6. }
  7. LaunchedEffect(key1 = Unit) {
  8. while (scope.isActive) {
  9. delay(150)
  10. start = if (start == -1) 0 else -1
  11. }
  12. }
  13. Box(modifier = Modifier
  14. .padding(top = 100.dp)
  15. .border(1.dp, Color.Black)
  16. .padding(10.dp)
  17. .size(56.dp)
  18. .clip(CircleShape)
  19. .background(red)
  20. .drawBehind {
  21. val step = 10.dp // line width
  22. val angleDegrees = 45f // todo adjust depending on roundedCornerShape
  23. val stepPx = step.toPx()
  24. val stepsCount = (size.width / stepPx).roundToInt()
  25. val actualStep = size.width / stepsCount
  26. val dotSize = Size(width = actualStep, height = size.height * 2)
  27. for (i in start..stepsCount step 2) {
  28. val rect = Rect(
  29. offset = Offset(
  30. x = i * actualStep,
  31. y = (size.height - dotSize.height) / 2
  32. ),
  33. size = dotSize,
  34. )
  35. rotate(angleDegrees, pivot = Offset(0f,0f)) {
  36. drawRect(
  37. gray,
  38. topLeft = rect.topLeft,
  39. size = rect.size,
  40. )
  41. }
  42. }
  43. },
  44. ) {
  45. Text(text = "button")
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement