aboutsummaryrefslogtreecommitdiff
path: root/library/src/main/kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'library/src/main/kotlin')
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt4
1 files changed, 2 insertions, 2 deletions
diff --git a/library/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt b/library/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt
index eaa6d91..2c5a395 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt
+++ b/library/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt
@@ -71,14 +71,14 @@ fun Int.withMinAlpha(@IntRange(from = 0L, to = 255L) alpha: Int): Int
@ColorInt
fun Int.lighten(@FloatRange(from = 0.0, to = 1.0) factor: Float = 0.2f): Int {
val (red, green, blue) = intArrayOf(Color.red(this), Color.green(this), Color.blue(this))
- .map { Math.min(it * (1 + factor), 255.0f).toInt() }
+ .map { Math.min(255f * factor + it, 255f).toInt() }
return Color.argb(Color.alpha(this), red, green, blue)
}
@ColorInt
fun Int.darken(@FloatRange(from = 0.0, to = 1.0) factor: Float = 0.2f): Int {
val (red, green, blue) = intArrayOf(Color.red(this), Color.green(this), Color.blue(this))
- .map { Math.max(it * (1 - factor), 0f).toInt() }
+ .map { Math.max(it - 255f * factor, 0f).toInt() }
return Color.argb(Color.alpha(this), red, green, blue)
}