mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-11 23:39:15 +01:00
lift warm tonal surfaces to the bright gradient tone
This commit is contained in:
@@ -34,7 +34,6 @@ private const val DARKEN_END_SCREENS = 1.5f
|
||||
private const val DARKEN_KNEE = 0.2f
|
||||
private const val PLAYER_SURFACE_SATURATION_FACTOR = 1.6f
|
||||
private const val LIBRARY_SURFACE_LIGHTNESS = 0.10f
|
||||
private const val WARM_SURFACE_SATURATION_DAMPING = 0.2f
|
||||
|
||||
@Immutable
|
||||
data class ArtworkColors(
|
||||
@@ -210,14 +209,14 @@ fun ArtworkTheme(
|
||||
|
||||
fun playerSurfaceColor(artwork: ArtworkColors): Color {
|
||||
val (hue, saturation, lightness) = artwork.scheme.surfaceContainerHigh.toHsl()
|
||||
val damping = if (isWarmHue(hue)) WARM_SURFACE_SATURATION_DAMPING else 1f
|
||||
return Color.hsl(hue, (saturation * PLAYER_SURFACE_SATURATION_FACTOR * damping).coerceIn(0f, 1f), lightness)
|
||||
if (isWarmHue(hue)) return artwork.gradientHigh
|
||||
return Color.hsl(hue, (saturation * PLAYER_SURFACE_SATURATION_FACTOR).coerceIn(0f, 1f), lightness)
|
||||
}
|
||||
|
||||
fun librarySurfaceColor(artwork: ArtworkColors): Color {
|
||||
val (hue, saturation, _) = artwork.scheme.surfaceContainerHigh.toHsl()
|
||||
val damping = if (isWarmHue(hue)) WARM_SURFACE_SATURATION_DAMPING else 1f
|
||||
return Color.hsl(hue, (saturation * damping).coerceIn(0f, 1f), LIBRARY_SURFACE_LIGHTNESS)
|
||||
if (isWarmHue(hue)) return lerp(artwork.gradientHigh, artwork.scheme.surfaceContainerHigh, 0.5f)
|
||||
return Color.hsl(hue, saturation, LIBRARY_SURFACE_LIGHTNESS)
|
||||
}
|
||||
|
||||
private fun isWarmHue(hue: Float): Boolean = hue in 0f..120f
|
||||
|
||||
@@ -59,6 +59,14 @@ class ArtworkColorsTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun warmArtworkLiftsPlayerSurfaceToTheBrightGradientTone() {
|
||||
val warm = artworkColorsFromSeed(0xFFE6C822.toInt())
|
||||
val cool = artworkColorsFromSeed(0xFF3A7BD5.toInt())
|
||||
assertEquals(warm.gradientHigh, playerSurfaceColor(warm))
|
||||
assertTrue(playerSurfaceColor(cool) != cool.gradientHigh)
|
||||
}
|
||||
|
||||
private fun contrast(
|
||||
a: Color,
|
||||
b: Color,
|
||||
|
||||
Reference in New Issue
Block a user