RGB

data class RGB(val r: Float, val g: Float, val b: Float, val alpha: Float = 1.0f) : KutintColor<RGBColorSpace>

Represents a color in the RGB color space.

Constructors

Link copied to clipboard
constructor(r: Float, g: Float, b: Float, alpha: Float = 1.0f)

Properties

Link copied to clipboard
open override val alpha: Float

Alpha channel 0-1

Link copied to clipboard
val b: Float

Blue channel 0-255

Link copied to clipboard
val g: Float

Green channel 0-255

Link copied to clipboard
open override val hsl: HSL

An HSL representation of the current color.

Link copied to clipboard
val r: Float

Red channel 0-255

Link copied to clipboard
open override val rgb: RGB

An RGB representation of the current color.

Functions

Link copied to clipboard
fun blend(other: KutintColor<*>, amount: Float = 0.5f): RGB

Blends two colors together using a linear interpolation between them in the RGB color space.

Link copied to clipboard

Gets the complementary color in the HSL color space.

Link copied to clipboard
infix fun darken(amount: Float = 0.2f): HSL

Darkens the color, through the HSL color space, by a given amount.

Link copied to clipboard
infix fun desaturate(amount: Float = 0.2f): HSL

Desaturates the color, through the HSL color space, by a given amount.

Link copied to clipboard
fun grayscale(): RGB

Converts the color to grayscale using the W3C formula for relative luminance through the RGB color space.

Link copied to clipboard
infix fun hueRotate(degrees: Int = 30): HSL

Rotates the hue in the HSL color space by a given number of degrees.

Link copied to clipboard
fun invert(): RGB

Inverts the color by subtracting each channel from 255 in the RGB color space.

Link copied to clipboard
infix fun lighten(amount: Float = 0.2f): HSL

Lightens the color, through the HSL color space, by a given amount.

Link copied to clipboard

Calculates the luminance of the color in the RGB color space.

Link copied to clipboard
infix fun saturate(amount: Float = 0.2f): HSL

Saturates the color, through the HSL color space, by a given amount.

Link copied to clipboard
infix fun shade(amount: Float = 0.2f): RGB

Shades the color, using a linear interpolation between the original color and black in the RGB color space, by a given amount.

Link copied to clipboard
infix fun tint(amount: Float = 0.2f): RGB

Tints the color, using a linear interpolation between the original color and white in the RGB color space, by a given amount.

Link copied to clipboard
fun toHex(includeAlpha: Boolean = alpha < 1f): String

Converts the color to a hex string.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
open infix override fun withAlpha(newAlpha: Float): RGB

Creates a new color with the given alpha value.

Link copied to clipboard
inline fun <T> withHSL(func: (h: Float, s: Float, l: Float) -> T): T

Utility function for switching the HSL color space and performing an operation on the channels.

Link copied to clipboard
inline fun <T> withRGB(func: (r: Float, g: Float, b: Float) -> T): T

Utility function for switching to the RGB color space and performing an operation on the channels.