# Palette.Swatch

Artifact: [androidx.palette:palette](https://developer.android.com/jetpack/androidx/releases/palette) [View Source](https://cs.android.com/search?q=file:androidx/palette/graphics/Palette.java+class:androidx.palette.graphics.Palette.Swatch) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/palette#1.0.0)

*** ** * ** ***

<br />

```
class Palette.Swatch
```

<br />

*** ** * ** ***

Represents a color swatch generated from an image's palette. The RGB color can be retrieved by calling `https://developer.android.com/reference/kotlin/androidx/palette/graphics/Palette.Swatch#getRgb()`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/palette/graphics/Palette.Swatch#Swatch(int,int)(color: @https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, population: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/palette/graphics/Palette.Swatch#equals(java.lang.Object)(o: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` |
| `@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/palette/graphics/Palette.Swatch#getBodyTextColor()()` Returns an appropriate color to use for any 'body' text which is displayed over this `https://developer.android.com/reference/kotlin/androidx/palette/graphics/Palette.Swatch`'s color. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>` | `https://developer.android.com/reference/kotlin/androidx/palette/graphics/Palette.Swatch#getHsl()()` Return this swatch's HSL values. hsv\[0\] is Hue \[0 .. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/palette/graphics/Palette.Swatch#getPopulation()()` |
| `@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/palette/graphics/Palette.Swatch#getRgb()()` |
| `@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/palette/graphics/Palette.Swatch#getTitleTextColor()()` Returns an appropriate color to use for any 'title' text which is displayed over this `https://developer.android.com/reference/kotlin/androidx/palette/graphics/Palette.Swatch`'s color. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/palette/graphics/Palette.Swatch#hashCode()()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/palette/graphics/Palette.Swatch#toString()()` |

## Public constructors

### Swatch

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/palette#1.0.0)

```
Swatch(color: @ColorInt Int, population: Int)
```

## Public functions

### equals

```
fun equals(o: Any?): Boolean
```

### getBodyTextColor

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/palette#1.0.0)

```
fun getBodyTextColor(): @ColorInt Int
```

Returns an appropriate color to use for any 'body' text which is displayed over this `https://developer.android.com/reference/kotlin/androidx/palette/graphics/Palette.Swatch`'s color. This color is guaranteed to have sufficient contrast.

### getHsl

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/palette#1.0.0)

```
fun getHsl(): Array<Float>
```

Return this swatch's HSL values. hsv\[0\] is Hue \[0 .. 360) hsv\[1\] is Saturation \[0...1\] hsv\[2\] is Lightness \[0...1\]

### getPopulation

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/palette#1.0.0)

```
fun getPopulation(): Int
```

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the number of pixels represented by this swatch |

### getRgb

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/palette#1.0.0)

```
fun getRgb(): @ColorInt Int
```

| Returns |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | this swatch's RGB color value |

### getTitleTextColor

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/palette#1.0.0)

```
fun getTitleTextColor(): @ColorInt Int
```

Returns an appropriate color to use for any 'title' text which is displayed over this `https://developer.android.com/reference/kotlin/androidx/palette/graphics/Palette.Swatch`'s color. This color is guaranteed to have sufficient contrast.

### hashCode

```
fun hashCode(): Int
```

### toString

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