Add surfaceColorAtElevation extension
This commit is contained in:
parent
6fb60c8dc4
commit
a1ceb9a489
16
app/src/main/java/me/ash/reader/ui/extension/ColorScheme.kt
Normal file
16
app/src/main/java/me/ash/reader/ui/extension/ColorScheme.kt
Normal file
|
@ -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)
|
||||
}
|
Loading…
Reference in New Issue
Block a user