Skip to content

Commit

Permalink
Support getter for integer representation in RGBA class.
Browse files Browse the repository at this point in the history
  • Loading branch information
slaviboy committed Apr 18, 2020
1 parent 1c59619 commit 2d6ce1d
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.slaviboy.colorpicker.models

import android.graphics.Color

// Copyright (C) 2020 Stanislav Georgiev
// https://github.com/slaviboy
//
Expand Down Expand Up @@ -98,6 +100,13 @@ class RGBA(var r: Int = 0, var g: Int = 0, var b: Int = 0, var a: Int = 100) {
return intArrayOf(r, g, b, a)
}

/**
* Get integer representation of the color
*/
fun getInt(): Int {
return Color.argb((a * (255 / 100f)).toInt(), r, g, b)
}

override fun toString(): String {
return getString()
}
Expand Down

0 comments on commit 2d6ce1d

Please sign in to comment.