diff options
-rw-r--r-- | .idea/misc.xml | 2 | ||||
-rw-r--r-- | library/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/.idea/misc.xml b/.idea/misc.xml index 7319f02..085136f 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -53,7 +53,7 @@ <ConfirmationsSetting value="0" id="Add" /> <ConfirmationsSetting value="0" id="Remove" /> </component> - <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <output url="file://$PROJECT_DIR$/build/classes" /> </component> <component name="ProjectType"> 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) } |