Skip to content

Commit

Permalink
Force alpha values to be in range [0,100].
Browse files Browse the repository at this point in the history
  • Loading branch information
slaviboy committed Apr 18, 2020
1 parent 94ee253 commit 75d2604
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,21 @@ class ColorConverter {
* @param color integer representation of a color
*/
constructor(color: Int) {
val r = Color.red(color)
val g = Color.green(color)
val b = Color.blue(color)
val a = Color.alpha(color)

val r = Color.red(color) // red [0-255]
val g = Color.green(color) // green [0-255]
val b = Color.blue(color) // blue [0-255]
val a = (Color.alpha(color) * (100 / 255f)).toInt() // alpha [0-100]

init()
setRGBA(r, g, b, a)
}

/**
* Constructor that sets r, g and b values for current selected color
* @param r red
* @param g green
* @param b blue
* @param r red [0-255]
* @param g green [0-255]
* @param b blue [0-255]
*/
constructor(r: Int = 0, g: Int = 0, b: Int = 0) {
init()
Expand All @@ -78,10 +79,10 @@ class ColorConverter {

/**
* Constructor that sets r, g, b and a values for current selected color
* @param r red
* @param g green
* @param b blue
* @param a alpha
* @param r red [0-255]
* @param g green [0-255]
* @param b blue [0-255]
* @param a alpha [0-100]
*/
constructor(r: Int, g: Int, b: Int, a: Int) {
init()
Expand Down

0 comments on commit 75d2604

Please sign in to comment.