Skip to content

KColor

@Serializable



data class KColor(
    val red: Int = 0, 
    val green: Int = 0, 
    val blue: Int = 0, 
    val alpha: Int = 255
)

A serializable, immutable ARGB colour value for use in GUI composables.

KColor is a pure-Kotlin alternative to java.awt.Color that works with Minecraft's integer-packed colour conventions. All component values are in the range 0–255.

Creating colours

val red    = KColor.RED
val custom = KColor.ofRgb(0xFF8C00)          // opaque dark orange
val semi   = KColor.ofArgb(0x80FF0000L)       // 50 % transparent red
val hsv    = KColor.ofHsv(0.33f, 1f, 0.8f)   // dark green via HSV

Constructors

KColor

constructor(
    red: Int = 0, 
    green: Int = 0, 
    blue: Int = 0, 
    alpha: Int = 255
)

Types

Companion

object Companion

Properties

alpha

val alpha: Int

argb

val argb: Int

The packed ARGB integer representation (in the form 0xAARRGGBB).

blue

val blue: Int

green

val green: Int

red

val red: Int

rgb

val rgb: Int

The packed RGB integer representation (no alpha channel, in the form 0xRRGGBB).