Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- val scope = rememberCoroutineScope()
- val red = Color(0xFFFF7F4D)
- val gray = Color(0xFF34343C).copy(alpha = 0.12f)
- var start by remember {
- mutableStateOf(-1)
- }
- LaunchedEffect(key1 = Unit) {
- while (scope.isActive) {
- delay(150)
- start = if (start == -1) 0 else -1
- }
- }
- Box(modifier = Modifier
- .padding(top = 100.dp)
- .border(1.dp, Color.Black)
- .padding(10.dp)
- .size(56.dp)
- .clip(CircleShape)
- .background(red)
- .drawBehind {
- val step = 10.dp // line width
- val angleDegrees = 45f // todo adjust depending on roundedCornerShape
- val stepPx = step.toPx()
- val stepsCount = (size.width / stepPx).roundToInt()
- val actualStep = size.width / stepsCount
- val dotSize = Size(width = actualStep, height = size.height * 2)
- for (i in start..stepsCount step 2) {
- val rect = Rect(
- offset = Offset(
- x = i * actualStep,
- y = (size.height - dotSize.height) / 2
- ),
- size = dotSize,
- )
- rotate(angleDegrees, pivot = Offset(0f,0f)) {
- drawRect(
- gray,
- topLeft = rect.topLeft,
- size = rect.size,
- )
- }
- }
- },
- ) {
- Text(text = "button")
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement