BrushedLayout.kt 771 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Copyright (c) Milan Jurkulák 2024.
  3. * Contact:
  4. * e: mimoccc@gmail.com
  5. * e: mj@mjdev.org
  6. * w: https://mjdev.org
  7. */
  8. package eu.mjdev.desktop.components.custom
  9. import androidx.compose.foundation.Canvas
  10. import androidx.compose.runtime.Composable
  11. import androidx.compose.ui.Modifier
  12. import androidx.compose.ui.graphics.Brush
  13. import androidx.compose.ui.graphics.Color
  14. @Composable
  15. fun BrushedLayout(
  16. modifier: Modifier = Modifier,
  17. alpha: Float = 1f,
  18. colorStart: Color = Color.Black.copy(alpha = if (alpha.isNaN()) 1f else alpha),
  19. colorEnd: Color = Color.Transparent,
  20. ) {
  21. val brush = Brush.radialGradient(listOf(colorStart, colorEnd))
  22. Canvas(
  23. modifier = modifier,
  24. onDraw = {
  25. drawRect(brush)
  26. }
  27. )
  28. }