ColorRGBa

@Serializable
data class ColorRGBa(val r: Double, val g: Double, val b: Double, val alpha: Double = 1.0, val linearity: Linearity = Linearity.LINEAR) : ColorModel<ColorRGBa> , ShadableColor<ColorRGBa> , AlgebraicColor<ColorRGBa> (source)

Represents a color in the RGBA color space. Each component, including red, green, blue, and alpha (opacity), is represented as a Double in the range [0.0, 1.0]. The color can be defined in either linear or sRGB space, determined by the linearity property.

This class provides a wide variety of utility functions for manipulating and converting colors, such as shading, opacity adjustment, and format transformations. It also includes methods for parsing colors from hexadecimal notation or vectors.

Constructors

Link copied to clipboard
constructor(r: Double, g: Double, b: Double, alpha: Double = 1.0, linearity: Linearity = Linearity.LINEAR)

Types

Link copied to clipboard
object Companion
Link copied to clipboard

Properties

Link copied to clipboard
open override val alpha: Double

Alpha (opacity) component of the color as a value between 0.0 and 1.0. Defaults to 1.0.

Link copied to clipboard

Returns a new instance of ColorRGBa where the red, green, and blue components are multiplied by the alpha value of the original color. The alpha value and linearity remain unchanged.

Link copied to clipboard
val b: Double

Blue component of the color as a value between 0.0 and 1.0.

Link copied to clipboard
val g: Double

Green component of the color as a value between 0.0 and 1.0.

Link copied to clipboard

Indicates whether the color is defined in linear or sRGB space. Defaults to Linearity.LINEAR.

Link copied to clipboard

calculate luminance value luminance value is according to https://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef

Link copied to clipboard

The maximum value over r, g, b

Link copied to clipboard

The minimum value over r, g, b

Link copied to clipboard
val r: Double

Red component of the color as a value between 0.0 and 1.0.

Functions

Link copied to clipboard

Copy of the color with all of its fields clamped to [0, 1]

Link copied to clipboard
open operator override fun div(scale: Double): ColorRGBa
Link copied to clipboard
operator fun get(index: Int): Double

Retrieves the color's RGBA component value based on the specified index: index should be 0 for red, 1 for green, 2 for blue, 3 for alpha. Other index values throw an IndexOutOfBoundsException.

Link copied to clipboard

calculate the contrast value between this color and the given color contrast value is accordingo to // see http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open operator override fun minus(right: ColorRGBa): ColorRGBa
Link copied to clipboard
open override fun mix(other: ColorRGBa, factor: Double): ColorRGBa
Link copied to clipboard
open override fun opacify(factor: Double): ColorRGBa

Creates a copy of color with adjusted opacity

Link copied to clipboard
open operator override fun plus(right: ColorRGBa): ColorRGBa
Link copied to clipboard
open override fun shade(factor: Double): ColorRGBa

Creates a copy of color with adjusted color

Link copied to clipboard
open operator override fun times(scale: Double): ColorRGBa
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun toLABa(ref: ColorXYZa = ColorXYZa.NEUTRAL): ColorLABa
Link copied to clipboard
fun toLCHABa(ref: ColorXYZa = ColorXYZa.NEUTRAL): ColorLCHABa
Link copied to clipboard
fun toLCHUVa(ref: ColorXYZa = ColorXYZa.NEUTRAL): ColorLCHUVa
Link copied to clipboard
Link copied to clipboard

Converts this color to the specified linearity.

Link copied to clipboard
fun toLUVa(ref: ColorXYZa = ColorXYZa.NEUTRAL): ColorLUVa
Link copied to clipboard
open override fun toRGBa(): ColorRGBa

Convert into ColorRGBa.

Link copied to clipboard

Convert to SRGB

Link copied to clipboard
open override fun toVector4(): Vector4
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard