# Color

Artifact: [androidx.compose.ui:ui-graphics](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/graphics/Color.kt+class:androidx.compose.ui.graphics.Color) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Common/AllAndroid/JVM
- Cmn

  ```
  value class Color
  ```

*** ** * ** ***

The `Color` class contains color information to be used while painting in `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas`. `Color` supports `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpace`s with 3 `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpace#componentCount()`, plus one for `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#alpha()`.

### Creating

`Color` can be created with one of these methods:

```kotlin
// from 4 separate [Float] components. Alpha and ColorSpace are optional
val rgbaWhiteFloat = Color(red = 1f, green = 1f, blue = 1f, alpha = 1f,
    ColorSpace.get(ColorSpaces.Srgb))
// from a 32-bit SRGB color integer
val fromIntWhite = Color(android.graphics.Color.WHITE)
val fromLongBlue = Color(0xFF0000FF)
// from SRGB integer component values. Alpha is optional
val rgbaWhiteInt = Color(red = 0xFF, green = 0xFF, blue = 0xFF, alpha = 0xFF)
```

### Representation

A `Color` always defines a color using 4 components packed in a single 64 bit long value. One of these components is always alpha while the other three components depend on the color space's `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorModel`. The most common color model is the `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorModel#Rgb()` model in which the components represent red, green, and blue values.

**Component ranges:** the ranges defined in the tables below indicate the ranges that can be encoded in a color long. They do not represent the actual ranges as they may differ per color space. For instance, the RGB components of a color in the `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpaces#DisplayP3()` color space use the `[0..1]` range. Please refer to the documentation of the various `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpaces` to find their respective ranges.

**Alpha range:** while alpha is encoded in a color long using a 10 bit integer (thus using a range of `[0..1023]`), it is converted to and from `[0..1]` float values when decoding and encoding color longs.

**sRGB color space:** for compatibility reasons and ease of use, `Color` encoded `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpaces#Srgb()` colors do not use the same encoding as other color longs.

```kotlin
| Component | Name        | Size    | Range                 |
|---|---|---|---|
| [RGB][ColorSpace.Model.Rgb] color model                   |
| R         | Red         | 16 bits | `[-65504.0, 65504.0]` |
| G         | Green       | 16 bits | `[-65504.0, 65504.0]` |
| B         | Blue        | 16 bits | `[-65504.0, 65504.0]` |
| A         | Alpha       | 10 bits | `[0..1023]`           |
|           | Color space | 6 bits  | `[0..63]`             |
| [SRGB][ColorSpaces.Srgb] color space                      |
| A         | Alpha       | 8 bits  | `[0..255]`            |
| R         | Red         | 8 bits  | `[0..255]`            |
| G         | Green       | 8 bits  | `[0..255]`            |
| B         | Blue        | 8 bits  | `[0..255]`            |
| X         | Unused      | 32 bits | `[0]`                 |
| [XYZ][ColorSpace.Model.Xyz] color model                   |
| X         | X           | 16 bits | `[-65504.0, 65504.0]` |
| Y         | Y           | 16 bits | `[-65504.0, 65504.0]` |
| Z         | Z           | 16 bits | `[-65504.0, 65504.0]` |
| A         | Alpha       | 10 bits | `[0..1023]`           |
|           | Color space | 6 bits  | `[0..63]`             |
| [Lab][ColorSpace.Model.Lab] color model                   |
| L         | L           | 16 bits | `[-65504.0, 65504.0]` |
| a         | a           | 16 bits | `[-65504.0, 65504.0]` |
| b         | b           | 16 bits | `[-65504.0, 65504.0]` |
| A         | Alpha       | 10 bits | `[0..1023]`           |
|           | Color space | 6 bits  | `[0..63]`             |
```

The components in this table are listed in encoding order, which is why color longs in the RGB model are called RGBA colors (even if this doesn't quite hold for the special case of sRGB colors).

The color encoding relies on half-precision float values (fp16). If you wish to know more about the limitations of half-precision float values, please refer to the documentation of the `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Float16` class.

The values returned by these methods depend on the color space encoded in the color long. The values are however typically in the `[0..1]` range for RGB colors. Please refer to the documentation of the various `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpaces` for the exact ranges.

## Summary

| ### Nested types |
|---|
| `object https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color.Companion` |

| ### Public companion functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#hsl(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,androidx.compose.ui.graphics.colorspace.Rgb)( hue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, saturation: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, lightness: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, alpha: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, colorSpace: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/Rgb )` Return a `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` from `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color.Companion#hsl(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,androidx.compose.ui.graphics.colorspace.Rgb)`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color.Companion#hsl(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,androidx.compose.ui.graphics.colorspace.Rgb)`, and `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color.Companion#hsl(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,androidx.compose.ui.graphics.colorspace.Rgb)` (HSL representation). | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#hsv(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,androidx.compose.ui.graphics.colorspace.Rgb)(hue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, saturation: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, alpha: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, colorSpace: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/Rgb)` Return a `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` from `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color.Companion#hsv(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,androidx.compose.ui.graphics.colorspace.Rgb)`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color.Companion#hsv(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,androidx.compose.ui.graphics.colorspace.Rgb)`, and `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color.Companion#hsv(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,androidx.compose.ui.graphics.colorspace.Rgb)` (HSV representation). | Cmn |

| ### Public companion properties |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#Black()` | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#Blue()` | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#Cyan()` | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#DarkGray()` | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#Gray()` | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#Green()` | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#LightGray()` | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#Magenta()` | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#Red()` | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#Transparent()` | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#Unspecified()` Because Color is an inline class, this represents an unset value without having to box the Color. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#White()` | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#Yellow()` | Cmn |

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#Color(kotlin.ULong)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-u-long/index.html)` | Cmn |

| ### Public functions |
|---|---|---|
| `inline operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#component1()()` | Cmn |
| `inline operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#component2()()` | Cmn |
| `inline operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#component3()()` | Cmn |
| `inline operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#component4()()` | Cmn |
| `inline operator https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpace` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#component5()()` | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#convert(androidx.compose.ui.graphics.colorspace.ColorSpace)(colorSpace: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpace)` Converts this color from its color space to the specified color space. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#copy(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float)(alpha: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, red: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, green: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, blue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Copies the existing color, changing only the provided values. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#toString()()` Returns a string representation of the object. | Cmn |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#alpha()` Returns the value of the alpha component in the range `[0..1]`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#blue()` Returns the value of the blue component in the range defined by this color's color space (see `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpace#getMinValue(kotlin.Int)` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpace#getMaxValue(kotlin.Int)`). | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpace` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#colorSpace()` Returns this color's color space. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#green()` Returns the value of the green component in the range defined by this color's color space (see `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpace#getMinValue(kotlin.Int)` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpace#getMaxValue(kotlin.Int)`). | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#red()` Returns the value of the red component in the range defined by this color's color space (see `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpace#getMinValue(kotlin.Int)` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpace#getMaxValue(kotlin.Int)`). | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-u-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#value()` | Cmn |

| ### Extension functions |
|---|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/ColorLong https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color.https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#(androidx.compose.ui.graphics.Color).toColorLong()()` Converts the `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` to a 64-bit `https://developer.android.com/reference/kotlin/androidx/annotation/ColorLong` value that can be used by Android's framework. | android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color.https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#(androidx.compose.ui.graphics.Color).compositeOver(androidx.compose.ui.graphics.Color)(background: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color)` Composites `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` color on top of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/package-summary#(androidx.compose.ui.graphics.Color).compositeOver(androidx.compose.ui.graphics.Color)` using the Porter-Duff 'source over' mode. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color.https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#(androidx.compose.ui.graphics.Color).luminance()()` Returns the relative luminance of this color. | Cmn |
| `inline https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color.https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#(androidx.compose.ui.graphics.Color).takeOrElse(kotlin.Function0)(block: () -> https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color)` If this color `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/package-summary#(androidx.compose.ui.graphics.Color).isSpecified()` then this is returned, otherwise `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/package-summary#(androidx.compose.ui.graphics.Color).takeOrElse(kotlin.Function0)` is executed and its result is returned. | Cmn |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color.https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#(androidx.compose.ui.graphics.Color).toArgb()()` Converts this color to an ARGB color int. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/remote/creation/compose/state/RemoteColor` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color.https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#(androidx.compose.ui.graphics.Color).asRemoteColor()()` Extension function to convert a `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` to a `https://developer.android.com/reference/kotlin/androidx/compose/remote/creation/compose/state/RemoteColor`. | android |

| ### Extension properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color.https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#(androidx.compose.ui.graphics.Color).isSpecified()` `false` when this is `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#Unspecified()`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color.https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#(androidx.compose.ui.graphics.Color).isUnspecified()` `true` when this is `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#Unspecified()`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/remote/creation/compose/state/RemoteColor` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color.https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#(androidx.compose.ui.graphics.Color).rc()` Extension property to convert a `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` to a `https://developer.android.com/reference/kotlin/androidx/compose/remote/creation/compose/state/RemoteColor`. | android |

## Public companion functions

### hsl

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun hsl(
    hue: Float,
    saturation: Float,
    lightness: Float,
    alpha: Float = 1.0f,
    colorSpace: Rgb = ColorSpaces.Srgb
): Color
```

Return a `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` from `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color.Companion#hsl(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,androidx.compose.ui.graphics.colorspace.Rgb)`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color.Companion#hsl(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,androidx.compose.ui.graphics.colorspace.Rgb)`, and `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color.Companion#hsl(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,androidx.compose.ui.graphics.colorspace.Rgb)` (HSL representation).

| Parameters |
|---|---|
| `hue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The color value in the range (0..360), where 0 is red, 120 is green, and 240 is blue |
| `saturation: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The amount of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color.Companion#hsl(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,androidx.compose.ui.graphics.colorspace.Rgb)` represented in the color in the range (0..1), where 0 has no color and 1 is fully saturated. |
| `lightness: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | A range of (0..1) where 0 is black, 0.5 is fully colored, and 1 is white. |
| `alpha: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = 1.0f` | Alpha channel to apply to the computed color |
| `colorSpace: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/Rgb = ColorSpaces.Srgb` | The RGB color space used to calculate the Color from the HSL values. |

### hsv

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun hsv(
    hue: Float,
    saturation: Float,
    value: Float,
    alpha: Float = 1.0f,
    colorSpace: Rgb = ColorSpaces.Srgb
): Color
```

Return a `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` from `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color.Companion#hsv(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,androidx.compose.ui.graphics.colorspace.Rgb)`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color.Companion#hsv(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,androidx.compose.ui.graphics.colorspace.Rgb)`, and `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color.Companion#hsv(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,androidx.compose.ui.graphics.colorspace.Rgb)` (HSV representation).

| Parameters |
|---|---|
| `hue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The color value in the range (0..360), where 0 is red, 120 is green, and 240 is blue |
| `saturation: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The amount of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color.Companion#hsv(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,androidx.compose.ui.graphics.colorspace.Rgb)` represented in the color in the range (0..1), where 0 has no color and 1 is fully saturated. |
| `value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The strength of the color, where 0 is black. |
| `alpha: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = 1.0f` | Alpha channel to apply to the computed color |
| `colorSpace: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/Rgb = ColorSpaces.Srgb` | The RGB color space used to calculate the Color from the HSV values. |

## Public companion properties

### Black

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val Black: Color
```

### Blue

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val Blue: Color
```

### Cyan

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val Cyan: Color
```

### DarkGray

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val DarkGray: Color
```

### Gray

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val Gray: Color
```

### Green

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val Green: Color
```

### LightGray

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val LightGray: Color
```

### Magenta

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val Magenta: Color
```

### Red

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val Red: Color
```

### Transparent

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val Transparent: Color
```

### Unspecified

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val Unspecified: Color
```

Because Color is an inline class, this represents an unset value without having to box the Color. It will be treated as `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#Transparent()` when drawn. A Color can compare with `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#Unspecified()` for equality or use `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/package-summary#(androidx.compose.ui.graphics.Color).isUnspecified()` to check for the unset value or `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/package-summary#(androidx.compose.ui.graphics.Color).isSpecified()` for any color that isn't `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#Unspecified()`.

### White

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val White: Color
```

### Yellow

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val Yellow: Color
```

## Public constructors

### Color

Cmn Added in [1.9.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.9.0)

```
Color(value: ULong)
```

## Public functions

### component1

Cmn Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.1.0)

```
inline operator fun component1(): Float
```

### component2

Cmn Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.1.0)

```
inline operator fun component2(): Float
```

### component3

Cmn Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.1.0)

```
inline operator fun component3(): Float
```

### component4

Cmn Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.1.0)

```
inline operator fun component4(): Float
```

### component5

Cmn Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.1.0)

```
inline operator fun component5(): ColorSpace
```

### convert

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0)

```
fun convert(colorSpace: ColorSpace): Color
```

Converts this color from its color space to the specified color space. The conversion is done using the default rendering intent as specified by `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/package-summary#(androidx.compose.ui.graphics.colorspace.ColorSpace).connect(androidx.compose.ui.graphics.colorspace.ColorSpace,androidx.compose.ui.graphics.colorspace.RenderIntent)`.

| Parameters |
|---|---|
| `colorSpace: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpace` | The destination color space, cannot be null |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` | A non-null color instance in the specified color space |

### copy

Cmn Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.1.0)

```
fun copy(
    alpha: Float = this.alpha,
    red: Float = this.red,
    green: Float = this.green,
    blue: Float = this.blue
): Color
```

Copies the existing color, changing only the provided values. The `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#colorSpace()` of the returned `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` is the same as this `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#colorSpace()`.

### toString

Cmn

```
open fun toString(): String
```

Returns a string representation of the object. This method returns a string equal to the value of:

```kotlin
"Color($r, $g, $b, $a, ${colorSpace.name})"
```

For instance, the string representation of opaque black in the sRGB color space is equal to the following value:

```kotlin
Color(0.0, 0.0, 0.0, 1.0, sRGB IEC61966-2.1)
```

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | A non-null string representation of the object |

## Public properties

### alpha

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0)

```
val alpha: Float
```

Returns the value of the alpha component in the range `[0..1]`.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#red()` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#green()` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#blue()` |   |

### blue

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0)

```
val blue: Float
```

Returns the value of the blue component in the range defined by this color's color space (see `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpace#getMinValue(kotlin.Int)` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpace#getMaxValue(kotlin.Int)`).

If this color's color model is not `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorModel#Rgb()`, calling this is the third component of the ColorSpace.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#alpha()` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#red()` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#green()` |   |

### colorSpace

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0)

```
val colorSpace: ColorSpace
```

Returns this color's color space.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpace` | A non-null instance of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpace` |

### green

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0)

```
val green: Float
```

Returns the value of the green component in the range defined by this color's color space (see `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpace#getMinValue(kotlin.Int)` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpace#getMaxValue(kotlin.Int)`).

If this color's color model is not `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorModel#Rgb()`, calling this is the second component of the ColorSpace.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#alpha()` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#red()` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#blue()` |   |

### red

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0)

```
val red: Float
```

Returns the value of the red component in the range defined by this color's color space (see `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpace#getMinValue(kotlin.Int)` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpace#getMaxValue(kotlin.Int)`).

If this color's color model is not `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorModel#Rgb()`, calling this is the first component of the ColorSpace.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#alpha()` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#blue()` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#green()` |   |

### value

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val value: ULong
```

## Extension functions

### Color.toColorLong

android Artifact: [androidx.compose.ui:ui-graphics](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/graphics/AndroidColor.android.kt+function:toColorLong)

```
fun Color.toColorLong(): @ColorLong Long
```

Converts the `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` to a 64-bit `https://developer.android.com/reference/kotlin/androidx/annotation/ColorLong` value that can be used by Android's framework. `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#value()` isn't fully compatible with Android's 64-bit `https://developer.android.com/reference/kotlin/androidx/annotation/ColorLong` values as some color spaces differ, so this method handles the conversion. Color spaces that are not supported by the current Android API level will safely fallback to the `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpaces#Srgb()` color space.

### Color.compositeOver

Cmn Artifact: [androidx.compose.ui:ui-graphics](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/graphics/Color.kt+function:compositeOver)

```
fun Color.compositeOver(background: Color): Color
```

Composites `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` color on top of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/package-summary#(androidx.compose.ui.graphics.Color).compositeOver(androidx.compose.ui.graphics.Color)` using the Porter-Duff 'source over' mode.

Both `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/package-summary#(androidx.compose.ui.graphics.Color).compositeOver(androidx.compose.ui.graphics.Color)` must not be pre-multiplied, and the resulting color will also not be pre-multiplied.

The `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpace` of the result is always the `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#colorSpace()` of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/package-summary#(androidx.compose.ui.graphics.Color).compositeOver(androidx.compose.ui.graphics.Color)`.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` | the `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` representing `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` composited on top of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/package-summary#(androidx.compose.ui.graphics.Color).compositeOver(androidx.compose.ui.graphics.Color)`, converted to the color space of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/package-summary#(androidx.compose.ui.graphics.Color).compositeOver(androidx.compose.ui.graphics.Color)`. |

### Color.luminance

Cmn Artifact: [androidx.compose.ui:ui-graphics](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/graphics/Color.kt+function:luminance)

```
fun Color.luminance(): Float
```

Returns the relative luminance of this color.

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

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | A value between 0 (darkest black) and 1 (lightest white) |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | If the this color's color space does not use the `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorModel#Rgb()` color model |

### Color.takeOrElse

Cmn Artifact: [androidx.compose.ui:ui-graphics](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/graphics/Color.kt+function:takeOrElse)

```
inline fun Color.takeOrElse(block: () -> Color): Color
```

If this color `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/package-summary#(androidx.compose.ui.graphics.Color).isSpecified()` then this is returned, otherwise `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/package-summary#(androidx.compose.ui.graphics.Color).takeOrElse(kotlin.Function0)` is executed and its result is returned.

### Color.toArgb

Cmn Artifact: [androidx.compose.ui:ui-graphics](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/graphics/Color.kt+function:toArgb)

```
fun Color.toArgb(): @ColorInt Int
```

Converts this color to an ARGB color int. A color int is always in the `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpaces#Srgb()` color space. This implies a color space conversion is applied if needed.

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | An ARGB color in the sRGB color space |

### Color.asRemoteColor

android Artifact: [androidx.compose.remote:remote-creation-compose](https://developer.android.com/jetpack/androidx/releases/compose-remote) [View Source](https://cs.android.com/search?q=file:androidx/compose/remote/creation/compose/state/RemoteColorCompose.kt+function:asRemoteColor)

```
fun Color.asRemoteColor(): RemoteColor
```

Extension function to convert a `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` to a `https://developer.android.com/reference/kotlin/androidx/compose/remote/creation/compose/state/RemoteColor`.

## Extension properties

### Color.isSpecified

Cmn Artifact: [androidx.compose.ui:ui-graphics](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/graphics/Color.kt+symbol:isSpecified)

```
val Color.isSpecified: Boolean
```

`false` when this is `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#Unspecified()`.

### Color.isUnspecified

Cmn Artifact: [androidx.compose.ui:ui-graphics](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/graphics/Color.kt+symbol:isUnspecified)

```
val Color.isUnspecified: Boolean
```

`true` when this is `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color#Unspecified()`.

### Color.rc

android Artifact: [androidx.compose.remote:remote-creation-compose](https://developer.android.com/jetpack/androidx/releases/compose-remote) [View Source](https://cs.android.com/search?q=file:androidx/compose/remote/creation/compose/state/RemoteColorCompose.kt+symbol:rc)

```
val Color.rc: RemoteColor
```

Extension property to convert a `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` to a `https://developer.android.com/reference/kotlin/androidx/compose/remote/creation/compose/state/RemoteColor`.