Save the date! Android Dev Summit is coming to Sunnyvale, CA on Oct 23-24, 2019.

Swatch

class Swatch
kotlin.Any
   ↳ androidx.palette.graphics.Palette.Swatch

Represents a color swatch generated from an image's palette. The RGB color can be retrieved by calling getRgb().

Summary

Public constructors
<init>(color: Int, population: Int)

Public methods
Int

Returns an appropriate color to use for any 'title' text which is displayed over this Swatch's color.

Int

FloatArray

Return this swatch's HSL values.

Boolean
equals(other: Any?)

String

Int

Returns an appropriate color to use for any 'body' text which is displayed over this Swatch's color.

Int

Int

Public constructors

<init>

Swatch(color: Int, population: Int)

Public methods

getTitleTextColor

fun getTitleTextColor(): Int

Returns an appropriate color to use for any 'title' text which is displayed over this Swatch's color. This color is guaranteed to have sufficient contrast.

hashCode

fun hashCode(): Int

getHsl

@NonNull fun getHsl(): FloatArray

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

equals

fun equals(other: Any?): Boolean

toString

fun toString(): String

getBodyTextColor

fun getBodyTextColor(): Int

Returns an appropriate color to use for any 'body' text which is displayed over this Swatch's color. This color is guaranteed to have sufficient contrast.

getPopulation

fun getPopulation(): Int
Return
Int: the number of pixels represented by this swatch

getRgb

fun getRgb(): Int
Return
Int: this swatch's RGB color value