# Connector

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/colorspace/Connector.kt+class:androidx.compose.ui.graphics.colorspace.Connector) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Common/All
- Cmn

  ```
  open class Connector
  ```

*** ** * ** ***

A connector transforms colors from a source color space to a destination color space.

A source color space is connected to a destination color space using the color transform `C` computed from their respective transforms noted `Tsrc` and `Tdst` in the following equation:

[See equation](https://developer.android.com/reference/android/graphics/ColorSpace.Connector)

The transform `C` shown above is only valid when the source and destination color spaces have the same profile connection space (PCS). We know that instances of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpace` always use CIE XYZ as their PCS but their white points might differ. When they do, we must perform a chromatic adaptation of the color spaces' transforms. To do so, we use the von Kries method described in the documentation of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/Adaptation`, using the CIE standard illuminant `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/Illuminant#D50()` as the target white point.

Example of conversion from `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpaces#Srgb()` to `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpaces#DciP3()`:

```kotlin
val connector = ColorSpaces.Srgb.connect(ColorSpaces.DciP3);
val p3 = connector.transform(1.0f, 0.0f, 0.0f);
// p3 contains { 0.9473, 0.2740, 0.2076 }
```

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/Adaptation` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/package-summary#(androidx.compose.ui.graphics.colorspace.ColorSpace).adapt(androidx.compose.ui.graphics.colorspace.WhitePoint,androidx.compose.ui.graphics.colorspace.Adaptation)` |   |
| `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)` |   |

## Summary

| ### Public functions |
|---|---|---|
| `open @https://developer.android.com/reference/kotlin/androidx/annotation/Size(min = 3) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float-array/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/Connector#transform(kotlin.FloatArray)(v: @https://developer.android.com/reference/kotlin/androidx/annotation/Size(min = 3) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float-array/index.html)` Transforms the specified color from the source color space to a color in the destination color space. | Cmn |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Size(value = 3) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float-array/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/Connector#transform(kotlin.Float,kotlin.Float,kotlin.Float)(r: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, g: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, b: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Transforms the specified color from the source color space to a color in the destination color space. | Cmn |

| ### Public properties |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpace` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/Connector#destination()` Returns the destination color space this connector will convert to. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/RenderIntent` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/Connector#renderIntent()` Returns the render intent this connector will use when mapping the source color space to the destination color space. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorSpace` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/Connector#source()` Returns the source color space this connector will convert from. | Cmn |

## Public functions

### transform

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

```
open fun transform(v: @Size(min = 3) FloatArray): @Size(min = 3) FloatArray
```

Transforms the specified color from the source color space to a color in the destination color space.

| Parameters |
|---|---|
| `v: @https://developer.android.com/reference/kotlin/androidx/annotation/Size(min = 3) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float-array/index.html` | A non-null array of 3 floats containing the value to transform and that will hold the result of the transform |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Size(min = 3) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float-array/index.html` | The `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/Connector#transform(kotlin.FloatArray)` array passed as a parameter, containing the specified color transformed from the source space to the destination space |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/Connector#transform(kotlin.FloatArray)` |   |

### transform

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

```
fun transform(r: Float, g: Float, b: Float): @Size(value = 3) FloatArray
```

Transforms the specified color from the source color space to a color in the destination color space. This convenience method assumes a source color model with 3 components (typically RGB). To transform from color models with more than 3 components, such as `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/ColorModel#Cmyk()`, use `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/Connector#transform(kotlin.Float,kotlin.Float,kotlin.Float)` instead.

| Parameters |
|---|---|
| `r: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The red component of the color to transform |
| `g: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The green component of the color to transform |
| `b: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The blue component of the color to transform |

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/Size(value = 3) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float-array/index.html` | A new array of 3 floats containing the specified color transformed from the source space to the destination space |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/Connector#transform(kotlin.Float,kotlin.Float,kotlin.Float)` |   |

## Public properties

### destination

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

```
val destination: ColorSpace
```

Returns the destination color space this connector will convert to.

| 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` |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/Connector#(androidx.compose.ui.graphics.colorspace.ColorSpace,androidx.compose.ui.graphics.colorspace.ColorSpace,androidx.compose.ui.graphics.colorspace.ColorSpace,androidx.compose.ui.graphics.colorspace.ColorSpace,androidx.compose.ui.graphics.colorspace.RenderIntent,kotlin.FloatArray)` |   |

### renderIntent

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

```
val renderIntent: RenderIntent
```

Returns the render intent this connector will use when mapping the source color space to the destination color space.

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

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/RenderIntent` |   |

### source

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

```
val source: ColorSpace
```

Returns the source color space this connector will convert from.

| 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` |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/colorspace/Connector#(androidx.compose.ui.graphics.colorspace.ColorSpace,androidx.compose.ui.graphics.colorspace.ColorSpace,androidx.compose.ui.graphics.colorspace.ColorSpace,androidx.compose.ui.graphics.colorspace.ColorSpace,androidx.compose.ui.graphics.colorspace.RenderIntent,kotlin.FloatArray)` |   |