KutintColor

sealed class KutintColor<T : ColorSpace> : CSSColorValue

Base class for all color types supported by Kutint. See RGB and HSL for specific implementations.

Includes a variety of functions for working with colors in Kobweb and Compose HTML.

Inheritors

Properties

Link copied to clipboard
abstract val alpha: Float

Alpha channel 0-1

Link copied to clipboard
abstract val hsl: HSL

An HSL representation of the current color.

Link copied to clipboard
abstract 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
abstract infix fun withAlpha(newAlpha: Float): KutintColor<T>

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.