lift warm tonal surfaces to the bright gradient tone

This commit is contained in:
austinried
2026-10-04 00:29:56 +00:00
parent 043c6201ba
commit 5e00bf86a8
2 changed files with 12 additions and 5 deletions
@@ -34,7 +34,6 @@ private const val DARKEN_END_SCREENS = 1.5f
private const val DARKEN_KNEE = 0.2f private const val DARKEN_KNEE = 0.2f
private const val PLAYER_SURFACE_SATURATION_FACTOR = 1.6f private const val PLAYER_SURFACE_SATURATION_FACTOR = 1.6f
private const val LIBRARY_SURFACE_LIGHTNESS = 0.10f private const val LIBRARY_SURFACE_LIGHTNESS = 0.10f
private const val WARM_SURFACE_SATURATION_DAMPING = 0.2f
@Immutable @Immutable
data class ArtworkColors( data class ArtworkColors(
@@ -210,14 +209,14 @@ fun ArtworkTheme(
fun playerSurfaceColor(artwork: ArtworkColors): Color { fun playerSurfaceColor(artwork: ArtworkColors): Color {
val (hue, saturation, lightness) = artwork.scheme.surfaceContainerHigh.toHsl() val (hue, saturation, lightness) = artwork.scheme.surfaceContainerHigh.toHsl()
val damping = if (isWarmHue(hue)) WARM_SURFACE_SATURATION_DAMPING else 1f if (isWarmHue(hue)) return artwork.gradientHigh
return Color.hsl(hue, (saturation * PLAYER_SURFACE_SATURATION_FACTOR * damping).coerceIn(0f, 1f), lightness) return Color.hsl(hue, (saturation * PLAYER_SURFACE_SATURATION_FACTOR).coerceIn(0f, 1f), lightness)
} }
fun librarySurfaceColor(artwork: ArtworkColors): Color { fun librarySurfaceColor(artwork: ArtworkColors): Color {
val (hue, saturation, _) = artwork.scheme.surfaceContainerHigh.toHsl() val (hue, saturation, _) = artwork.scheme.surfaceContainerHigh.toHsl()
val damping = if (isWarmHue(hue)) WARM_SURFACE_SATURATION_DAMPING else 1f if (isWarmHue(hue)) return lerp(artwork.gradientHigh, artwork.scheme.surfaceContainerHigh, 0.5f)
return Color.hsl(hue, (saturation * damping).coerceIn(0f, 1f), LIBRARY_SURFACE_LIGHTNESS) return Color.hsl(hue, saturation, LIBRARY_SURFACE_LIGHTNESS)
} }
private fun isWarmHue(hue: Float): Boolean = hue in 0f..120f 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( private fun contrast(
a: Color, a: Color,
b: Color, b: Color,