呼吸灯

fun PreviewCustom() {
//    val deltaXAnim = rememberInfiniteTransition()
//    val dx by deltaXAnim.animateFloat(
//        initialValue = 0.8f,
//        targetValue = 1f,
//        animationSpec = infiniteRepeatable(
//            animation = tween(6000, easing = LinearEasing),
//            repeatMode = RepeatMode.Reverse
//        )
//    )

    var colorState by remember { mutableStateOf(1) }
    val colorAnim by animateColorAsState(
        when {
            colorState % 7 == 1 -> Color(0xff0055ff)
            colorState % 7 == 2 -> Color(0xff00ff55)
            colorState % 7 == 3 -> Color(0xffff0055)
            colorState % 7 == 4 -> Color(0xffffff00)
            colorState % 7 == 5 -> Color(0xff33cccc)
            colorState % 7 == 6 -> Color(0xffff00bf)
            colorState % 7 == 0 -> Color(0xff9900ff)
            else -> Color.DarkGray
        },
        TweenSpec(durationMillis = 3000, easing = FastOutSlowInEasing),
        finishedListener = {
            colorState++
        }
    )
    LaunchedEffect(1){
        delay(3000)
        colorState++
    }
    
    Box(
        Modifier
            .size(100.dp)
            .graphicsLayer {
//                alpha = dx
                shape = CircleShape
                clip = true
            }
            .background(colorAnim)
    )
    Image(
        painter = painterResource(id = R.drawable.ic_kid),
        contentDescription = "Awesome Image",
        modifier = Modifier
            .size(100.dp)
            .padding(10.dp)
            .clip(CircleShape)
   
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值