Archived
1
0
Fork 0

Add own RGBColor class

This commit is contained in:
Moritz Ruth 2021-01-08 21:58:26 +01:00
parent 83b9124670
commit 4fafdcbbc5
No known key found for this signature in database
GPG key ID: AFD57E23E753841B

View file

@ -20,6 +20,8 @@ class RGBColor(rgb: Int) {
val green: UByte by lazy { ((rgb and 0x00FF00) shr 8).toUByte() } val green: UByte by lazy { ((rgb and 0x00FF00) shr 8).toUByte() }
val blue: UByte by lazy { (rgb and 0x0000FF).toUByte() } val blue: UByte by lazy { (rgb and 0x0000FF).toUByte() }
fun copy(red: UByte = this.red, green: UByte = this.green, blue: UByte = this.blue) = RGBColor(red, green, blue)
override fun toString() = "0x${rgb.toString(16).toUpperCase().padStart(6, '0')}" override fun toString() = "0x${rgb.toString(16).toUpperCase().padStart(6, '0')}"
override fun equals(other: Any?): Boolean = (other == this) || (other is RGBColor && other.rgb == this.rgb) override fun equals(other: Any?): Boolean = (other == this) || (other is RGBColor && other.rgb == this.rgb)