---
title: "ColorModel"
description: "A color model is required by a [ColorSpace] to describe the way colors can be represented as
tuples of numbers. A common color model is the [RGB][Rgb] color model which defines a color as
represented by a tuple of 3 numbers (red, green and blue)."
type: "class"
---

<div class='type'>Class</div>


<a id='references'></a>

<div class='sourceset sourceset-common'>Common</div>


```kotlin
value class ColorModel
internal constructor(
    /**
     * pack both the number of components and an ordinal value to distinguish between different
     * ColorModel types that have the same number of components
     */
    internal val packedValue: Long
)
```


A color model is required by a `ColorSpace` to describe the way colors can be represented as
tuples of numbers. A common color model is the `RGB` color model which defines a color as
represented by a tuple of 3 numbers (red, green and blue).


## Properties

<div class='sourceset sourceset-common'>Common</div>


```kotlin
@get:IntRange(from = 1, to = 4)

val componentCount: Int
```


Returns the number of components for this color model.

#### Returns

| | |
| --- | --- |
|  | An integer between 1 and 4 |




## Companion Object

#### Properties

<div class='sourceset sourceset-common'>Common</div>


```kotlin
val Rgb = ColorModel(packInts(3, 0))
```


The RGB model is a color model with 3 components that refer to the three additive
primiaries: red, green and blue.



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val Xyz = ColorModel(packInts(3, 1))
```


The XYZ model is a color model with 3 components that are used to model human color
vision on a basic sensory level.



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val Lab = ColorModel(packInts(3, 2))
```


The Lab model is a color model with 3 components used to describe a color space that is
more perceptually uniform than XYZ.



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val Cmyk = ColorModel(packInts(4, 3))
```


The CMYK model is a color model with 4 components that refer to four inks used in color
printing: cyan, magenta, yellow and black (or key). CMYK is a subtractive color model.





