diff --git a/app/src/main/java/me/ash/reader/ui/extension/ColorScheme.kt b/app/src/main/java/me/ash/reader/ui/extension/ColorScheme.kt new file mode 100644 index 0000000..6ff4f0c --- /dev/null +++ b/app/src/main/java/me/ash/reader/ui/extension/ColorScheme.kt @@ -0,0 +1,16 @@ +package me.ash.reader.ui.extension + +import androidx.compose.material3.ColorScheme +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.compositeOver +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp +import kotlin.math.ln + +fun ColorScheme.surfaceColorAtElevation( + elevation: Dp, +): Color { + if (elevation == 0.dp) return surface + val alpha = ((4.5f * ln(elevation.value + 1)) + 2f) / 100f + return primary.copy(alpha = alpha).compositeOver(surface) +} \ No newline at end of file