aboutsummaryrefslogtreecommitdiff
path: root/library/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt
diff options
context:
space:
mode:
Diffstat (limited to 'library/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt')
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt2
1 files changed, 2 insertions, 0 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 8ae23d1..3499647 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt
+++ b/library/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt
@@ -28,6 +28,8 @@ fun Int.toHexString(withAlpha: Boolean = false, withHexPrefix: Boolean = true):
return if (withHexPrefix) hex else hex.substring(1)
}
+fun Int.toRgbaString() :String = "rgba(${Color.red(this)}, ${Color.green(this)}, ${Color.blue(this)}, ${(Color.alpha(this)/255f).round(3)})"
+
fun Int.toHSV(): FloatArray {
val hsv = FloatArray(3)
Color.colorToHSV(this, hsv)