{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

Color.Companion

public static class Color.Companion


Summary

Public methods

static final @NonNull Color
static final @NonNull Color
static final @NonNull Color
static final @NonNull Color
static final @NonNull Color
static final @NonNull Color
static final @NonNull Color
static final @NonNull Color
static final @NonNull Color
static final @NonNull Color
static final @NonNull Color

Because Color is an inline class, this represents an unset value without having to box the Color.

static final @NonNull Color
static final @NonNull Color
static final @NonNull Color
hsl(
    float hue,
    float saturation,
    float lightness,
    float alpha,
    @NonNull Rgb colorSpace
)

Return a Color from hue, saturation, and lightness (HSL representation).

static final @NonNull Color
hsv(
    float hue,
    float saturation,
    float value,
    float alpha,
    @NonNull Rgb colorSpace
)

Return a Color from hue, saturation, and value (HSV representation).

Extension functions

static final @NonNull Function1<@NonNull ColorSpace, @NonNull TwoWayConverter<@NonNull Color, @NonNull AnimationVector4D>>

A lambda that takes a ColorSpace and returns a converter that can both convert a Color to a AnimationVector4D, and convert a AnimationVector4D) back to a Color in the given ColorSpace.

Public methods

getBlack

public static final @NonNull Color getBlack()

getBlue

public static final @NonNull Color getBlue()

getCyan

public static final @NonNull Color getCyan()

getDarkGray

public static final @NonNull Color getDarkGray()

getGray

public static final @NonNull Color getGray()

getGreen

public static final @NonNull Color getGreen()

getLightGray

public static final @NonNull Color getLightGray()

getMagenta

public static final @NonNull Color getMagenta()

getRed

public static final @NonNull Color getRed()

getTransparent

public static final @NonNull Color getTransparent()

getUnspecified

public static final @NonNull Color getUnspecified()

Because Color is an inline class, this represents an unset value without having to box the Color. It will be treated as Transparent when drawn. A Color can compare with Unspecified for equality or use isUnspecified to check for the unset value or isSpecified for any color that isn't Unspecified.

getWhite

public static final @NonNull Color getWhite()

getYellow

public static final @NonNull Color getYellow()

hsl

public static final @NonNull Color hsl(
    float hue,
    float saturation,
    float lightness,
    float alpha,
    @NonNull Rgb colorSpace
)

Return a Color from hue, saturation, and lightness (HSL representation).

Parameters
float hue

The color value in the range (0..360), where 0 is red, 120 is green, and 240 is blue

float saturation

The amount of hue represented in the color in the range (0..1), where 0 has no color and 1 is fully saturated.

float lightness

A range of (0..1) where 0 is black, 0.5 is fully colored, and 1 is white.

@NonNull Rgb colorSpace

The RGB color space used to calculate the Color from the HSL values.

hsv

public static final @NonNull Color hsv(
    float hue,
    float saturation,
    float value,
    float alpha,
    @NonNull Rgb colorSpace
)

Return a Color from hue, saturation, and value (HSV representation).

Parameters
float hue

The color value in the range (0..360), where 0 is red, 120 is green, and 240 is blue

float saturation

The amount of hue represented in the color in the range (0..1), where 0 has no color and 1 is fully saturated.

float value

The strength of the color, where 0 is black.

@NonNull Rgb colorSpace

The RGB color space used to calculate the Color from the HSV values.

Extension functions

ColorVectorConverterKt.getVectorConverter

public static final @NonNull Function1<@NonNull ColorSpace, @NonNull TwoWayConverter<@NonNull Color, @NonNull AnimationVector4D>> ColorVectorConverterKt.getVectorConverter(
    @NonNull Color.Companion receiver
)

A lambda that takes a ColorSpace and returns a converter that can both convert a Color to a AnimationVector4D, and convert a AnimationVector4D) back to a Color in the given ColorSpace.