From 99c14cb91f264e1f20db51df2e6b425636a66593 Mon Sep 17 00:00:00 2001 From: Fynn Godau Date: Wed, 2 Aug 2023 15:02:22 +0200 Subject: [PATCH] Preserve alpha component when applying custom styles --- .../main/kotlin/org/microg/gms/maps/mapbox/Styles.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/Styles.kt b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/Styles.kt index 7dcd84698..43bb5602c 100644 --- a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/Styles.kt +++ b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/Styles.kt @@ -301,7 +301,7 @@ fun Styler.applyColorChanges(color: Int): Int { // Apply hue to layer color ColorUtils.colorToHSL(color, hslResult) hslResult[0] = hueDegree - return ColorUtils.HSLToColor(hslResult) + return ColorUtils.setAlphaComponent(ColorUtils.HSLToColor(hslResult), Color.alpha(color)) } lightness?.let { lightness -> @@ -315,7 +315,7 @@ fun Styler.applyColorChanges(color: Int): Int { // Increase brightness. Percentage amount = relative reduction of difference between is-lightness and 1.0. hsl[2] + (lightness / 100) * (1 - hsl[2]) } - return ColorUtils.HSLToColor(hsl) + return ColorUtils.setAlphaComponent(ColorUtils.HSLToColor(hsl), Color.alpha(color)) } saturation?.let { saturation -> @@ -330,7 +330,7 @@ fun Styler.applyColorChanges(color: Int): Int { hsl[1] + (saturation / 100) * (1 - hsl[1]) } - return ColorUtils.HSLToColor(hsl) + return ColorUtils.setAlphaComponent(ColorUtils.HSLToColor(hsl), Color.alpha(color)) } gamma?.let { gamma -> @@ -339,7 +339,7 @@ fun Styler.applyColorChanges(color: Int): Int { ColorUtils.colorToHSL(color, hsl) hsl[2] = hsl[2].toDouble().pow(gamma.toDouble()).toFloat() - return ColorUtils.HSLToColor(hsl) + return ColorUtils.setAlphaComponent(ColorUtils.HSLToColor(hsl), Color.alpha(color)) } if (invertLightness == true) { @@ -348,7 +348,7 @@ fun Styler.applyColorChanges(color: Int): Int { ColorUtils.colorToHSL(color, hsl) hsl[2] = 1 - hsl[2] - return ColorUtils.HSLToColor(hsl) + return ColorUtils.setAlphaComponent(ColorUtils.HSLToColor(hsl), Color.alpha(color)) } this.color?.let { -- GitLab