ColorKt

public final class ColorKt


Summary

Public fields

final int

Return the alpha component of a color int.

final float

Return the alpha component of a color long.

final int

Return the blue component of a color int.

final float

Return the blue component of a color long.

final @NonNull ColorSpace

Returns the color space encoded in the specified color long.

final int

Return the green component of a color int.

final float

Return the green component of a color long.

final boolean

Indicates whether the color is in the sRGB color space.

final boolean

Indicates whether the color is in a wide-gamut color space.

final float

Returns the relative luminance of a color int, assuming sRGB encoding.

final float

Returns the relative luminance of a color.

final int

Return the red component of a color int.

final float

Return the red component of a color long.

Public methods

static final @RequiresApi(value = "26") float

Returns the first component of the color.

static final int
ColorKt.component1(@ColorInt int receiver)

Return the alpha component of a color int.

static final @RequiresApi(value = "26") float
ColorKt.component1(@ColorLong long receiver)

Returns the first component of the color.

static final @RequiresApi(value = "26") float

Returns the second component of the color.

static final int
ColorKt.component2(@ColorInt int receiver)

Return the red component of a color int.

static final @RequiresApi(value = "26") float
ColorKt.component2(@ColorLong long receiver)

Returns the second component of the color.

static final @RequiresApi(value = "26") float

Returns the third component of the color.

static final int
ColorKt.component3(@ColorInt int receiver)

Return the green component of a color int.

static final @RequiresApi(value = "26") float
ColorKt.component3(@ColorLong long receiver)

Returns the third component of the color.

static final @RequiresApi(value = "26") float

Returns the fourth component of the color.

static final int
ColorKt.component4(@ColorInt int receiver)

Return the blue component of a color int.

static final @RequiresApi(value = "26") float
ColorKt.component4(@ColorLong long receiver)

Returns the fourth component of the color.

static final @RequiresApi(value = "26") @ColorLong long
ColorKt.convertTo(
    @ColorInt int receiver,
    @NonNull ColorSpace.Named colorSpace
)

Converts the color int receiver to a color long in the specified color space.

static final @RequiresApi(value = "26") @ColorLong long
ColorKt.convertTo(@ColorInt int receiver, @NonNull ColorSpace colorSpace)

Converts the color int receiver to a color long in the specified color space.

static final @RequiresApi(value = "26") @ColorLong long
ColorKt.convertTo(
    @ColorLong long receiver,
    @NonNull ColorSpace.Named colorSpace
)

Converts the color long receiver to a color long in the specified color space.

static final @RequiresApi(value = "26") @ColorLong long
ColorKt.convertTo(
    @ColorLong long receiver,
    @NonNull ColorSpace colorSpace
)

Converts the color long receiver to a color long in the specified color space.

static final @RequiresApi(value = "26") @NonNull Color
ColorKt.convertTo(
    @NonNull Color receiver,
    @NonNull ColorSpace.Named colorSpace
)

Converts the color receiver to a color in the specified color space.

static final @RequiresApi(value = "26") @NonNull Color
ColorKt.convertTo(@NonNull Color receiver, @NonNull ColorSpace colorSpace)

Converts the color receiver to a color in the specified color space.

static final @RequiresApi(value = "26") @NonNull Color

Composites two translucent colors together.

static final @RequiresApi(value = "26") @NonNull Color
ColorKt.toColor(@ColorInt int receiver)

Creates a new Color instance from a color int.

static final @RequiresApi(value = "26") @NonNull Color
ColorKt.toColor(@ColorLong long receiver)

Creates a new Color instance from a color long.

static final @RequiresApi(value = "26") @ColorInt int
ColorKt.toColorInt(@ColorLong long receiver)

Converts the specified color long to an ARGB color int.

static final @ColorInt int

Return a corresponding Int color of this String.

static final @RequiresApi(value = "26") @ColorLong long
ColorKt.toColorLong(@ColorInt int receiver)

Converts the specified ARGB color int to an RGBA color long in the sRGB color space.

Public fields

alpha

@NonNull
public final int alpha

Return the alpha component of a color int. This is equivalent to calling:

Color.alpha(myInt)

alpha

@NonNull
public final float alpha

Return the alpha component of a color long. This is equivalent to calling:

Color.alpha(myLong)

blue

@NonNull
public final int blue

Return the blue component of a color int. This is equivalent to calling:

Color.blue(myInt)

blue

@NonNull
public final float blue

Return the blue component of a color long. This is equivalent to calling:

Color.blue(myLong)

colorSpace

@NonNull
public final @NonNull ColorSpace colorSpace

Returns the color space encoded in the specified color long.

green

@NonNull
public final int green

Return the green component of a color int. This is equivalent to calling:

Color.green(myInt)

green

@NonNull
public final float green

Return the green component of a color long. This is equivalent to calling:

Color.green(myLong)

isSrgb

@NonNull
public final boolean isSrgb

Indicates whether the color is in the sRGB color space.

isWideGamut

@NonNull
public final boolean isWideGamut

Indicates whether the color is in a wide-gamut color space.

luminance

@NonNull
public final float luminance

Returns the relative luminance of a color int, assuming sRGB encoding. Based on the formula for relative luminance defined in WCAG 2.0, W3C Recommendation 11 December 2008.

luminance

@NonNull
public final float luminance

Returns the relative luminance of a color. Based on the formula for relative luminance defined in WCAG 2.0, W3C Recommendation 11 December 2008.

red

@NonNull
public final int red

Return the red component of a color int. This is equivalent to calling:

Color.red(myInt)

red

@NonNull
public final float red

Return the red component of a color long. This is equivalent to calling:

Color.red(myLong)

Public methods

ColorKt.component1

@RequiresApi(value = "26")
@NonNull
public static final @RequiresApi(value = "26") float ColorKt.component1(@NonNull Color receiver)

Returns the first component of the color. For instance, when the color model of the color is android.graphics.ColorSpace.Model.RGB, the first component is "red".

This method allows to use destructuring declarations when working with colors, for example:

val (red, green, blue) = myColor

ColorKt.component1

@NonNull
public static final int ColorKt.component1(@ColorInt int receiver)

Return the alpha component of a color int. This is equivalent to calling:

Color.alpha(myInt)

This method allows to use destructuring declarations when working with colors, for example:

val (alpha, red, green, blue) = myColor

ColorKt.component1

@RequiresApi(value = "26")
@NonNull
public static final @RequiresApi(value = "26") float ColorKt.component1(@ColorLong long receiver)

Returns the first component of the color. For instance, when the color model of the color is android.graphics.ColorSpace.Model.RGB, the first component is "red".

This method allows to use destructuring declarations when working with colors, for example:

val (red, green, blue, alpha) = myColorLong

ColorKt.component2

@RequiresApi(value = "26")
@NonNull
public static final @RequiresApi(value = "26") float ColorKt.component2(@NonNull Color receiver)

Returns the second component of the color. For instance, when the color model of the color is android.graphics.ColorSpace.Model.RGB, the second component is "green".

This method allows to use destructuring declarations when working with colors, for example:

val (red, green, blue) = myColor

ColorKt.component2

@NonNull
public static final int ColorKt.component2(@ColorInt int receiver)

Return the red component of a color int. This is equivalent to calling:

Color.red(myInt)

This method allows to use destructuring declarations when working with colors, for example:

val (alpha, red, green, blue) = myColor

ColorKt.component2

@RequiresApi(value = "26")
@NonNull
public static final @RequiresApi(value = "26") float ColorKt.component2(@ColorLong long receiver)

Returns the second component of the color. For instance, when the color model of the color is android.graphics.ColorSpace.Model.RGB, the second component is "green".

This method allows to use destructuring declarations when working with colors, for example:

val (red, green, blue, alpha) = myColorLong

ColorKt.component3

@RequiresApi(value = "26")
@NonNull
public static final @RequiresApi(value = "26") float ColorKt.component3(@NonNull Color receiver)

Returns the third component of the color. For instance, when the color model of the color is android.graphics.ColorSpace.Model.RGB, the third component is "blue". = * This method allows to use destructuring declarations when working with colors, for example:

val (red, green, blue) = myColor

ColorKt.component3

@NonNull
public static final int ColorKt.component3(@ColorInt int receiver)

Return the green component of a color int. This is equivalent to calling:

Color.green(myInt)

This method allows to use destructuring declarations when working with colors, for example:

val (alpha, red, green, blue) = myColor

ColorKt.component3

@RequiresApi(value = "26")
@NonNull
public static final @RequiresApi(value = "26") float ColorKt.component3(@ColorLong long receiver)

Returns the third component of the color. For instance, when the color model of the color is android.graphics.ColorSpace.Model.RGB, the third component is "blue".

This method allows to use destructuring declarations when working with colors, for example:

val (red, green, blue, alpha) = myColorLong

ColorKt.component4

@RequiresApi(value = "26")
@NonNull
public static final @RequiresApi(value = "26") float ColorKt.component4(@NonNull Color receiver)

Returns the fourth component of the color. For instance, when the color model of the color is android.graphics.ColorSpace.Model.RGB, the fourth component is "alpha".

This method allows to use destructuring declarations when working with colors, for example:

val (red, green, blue, alpha) = myColor

ColorKt.component4

@NonNull
public static final int ColorKt.component4(@ColorInt int receiver)

Return the blue component of a color int. This is equivalent to calling:

Color.blue(myInt)

This method allows to use destructuring declarations when working with colors, for example:

val (alpha, red, green, blue) = myColor

ColorKt.component4

@RequiresApi(value = "26")
@NonNull
public static final @RequiresApi(value = "26") float ColorKt.component4(@ColorLong long receiver)

Returns the fourth component of the color. For instance, when the color model of the color is android.graphics.ColorSpace.Model.RGB, the fourth component is "alpha".

This method allows to use destructuring declarations when working with colors, for example:

val (red, green, blue, alpha) = myColorLong

ColorKt.convertTo

@RequiresApi(value = "26")
@ColorLong
@NonNull
public static final @RequiresApi(value = "26") @ColorLong long ColorKt.convertTo(
    @ColorInt int receiver,
    @NonNull ColorSpace.Named colorSpace
)

Converts the color int receiver to a color long in the specified color space. This is equivalent to calling:

Color.convert(myColorInt, ColorSpace.get(colorSpace))

ColorKt.convertTo

@RequiresApi(value = "26")
@ColorLong
@NonNull
public static final @RequiresApi(value = "26") @ColorLong long ColorKt.convertTo(@ColorInt int receiver, @NonNull ColorSpace colorSpace)

Converts the color int receiver to a color long in the specified color space. This is equivalent to calling:

Color.convert(myColorInt, colorSpace)

ColorKt.convertTo

@RequiresApi(value = "26")
@ColorLong
@NonNull
public static final @RequiresApi(value = "26") @ColorLong long ColorKt.convertTo(
    @ColorLong long receiver,
    @NonNull ColorSpace.Named colorSpace
)

Converts the color long receiver to a color long in the specified color space. This is equivalent to calling:

Color.convert(myColorLong, ColorSpace.get(colorSpace))

ColorKt.convertTo

@RequiresApi(value = "26")
@ColorLong
@NonNull
public static final @RequiresApi(value = "26") @ColorLong long ColorKt.convertTo(
    @ColorLong long receiver,
    @NonNull ColorSpace colorSpace
)

Converts the color long receiver to a color long in the specified color space. This is equivalent to calling:

Color.convert(myColorLong, colorSpace)

ColorKt.convertTo

@RequiresApi(value = "26")
@NonNull
public static final @RequiresApi(value = "26") Color ColorKt.convertTo(
    @NonNull Color receiver,
    @NonNull ColorSpace.Named colorSpace
)

Converts the color receiver to a color in the specified color space. This is equivalent to calling:

myColor.convert(ColorSpace.get(colorSpace))

ColorKt.convertTo

@RequiresApi(value = "26")
@NonNull
public static final @RequiresApi(value = "26") Color ColorKt.convertTo(@NonNull Color receiver, @NonNull ColorSpace colorSpace)

Converts the color receiver to a