Thread
#compose
    adjpd

    adjpd

    11 months ago
    A transparent to white
    Brush.verticalGradient
    in a white
    Box
    renders gray with
    drawWithCache
    . A bug? Code in 🧵
    Box(
      Modifier
        .size(50.dp, 50.dp)
        .background(Color.White)
        .drawWithCache {
          onDrawWithContent {
            drawContent()
            drawRect(
              Brush.verticalGradient(
                .5f to Color.Transparent,
                1F to Color.White
              )
            )
          }
        }
    )
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    11 months ago
    I'm not at a computer atm but i think transparent might set the other color channels to zero, and so it ends up interpolating between transparent black and opaque white which gives you the gray?
    You could try doing
    Color.White.copy(alpha=0f)
    instead of
    Transparent
    adjpd

    adjpd

    11 months ago
    That's fantastic, Zach. Thank you. Should I report that as a bug? The gray gradient seems rather strange seeing as
    Color.Transparent
    was set.
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    11 months ago
    I don't think it's worth filing a bug, I think you just have to be careful when lerping colors that if you only want to lerp the alpha channel, you make sure that's the only channel that's different.