added in version 1.0.0
belongs to Maven artifact androidx.palette:palette:1.0.0-beta01

Palette.Swatch

public static final class Palette.Swatch
extends Object

java.lang.Object
   ↳ 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

Palette.Swatch(int color, int population)

Public methods

boolean equals(Object o)
int getBodyTextColor()

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

float[] getHsl()

Return this swatch's HSL values.

int getPopulation()
int getRgb()
int getTitleTextColor()

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

int hashCode()
String toString()

Inherited methods

Public constructors

Palette.Swatch

added in version 1.0.0
public Palette.Swatch (int color, 
                int population)

Parameters
color int

population int

Public methods

equals

public boolean equals (Object o)

Parameters
o Object

Returns
boolean

getBodyTextColor

added in version 1.0.0
public int getBodyTextColor ()

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

Returns
int

getHsl

added in version 1.0.0
public float[] getHsl ()

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

Returns
float[]

getPopulation

added in version 1.0.0
public int getPopulation ()

Returns
int the number of pixels represented by this swatch

getRgb

added in version 1.0.0
public int getRgb ()

Returns
int this swatch's RGB color value

getTitleTextColor

added in version 1.0.0
public int getTitleTextColor ()

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

Returns
int

hashCode

public int hashCode ()

Returns
int

toString

public String toString ()

Returns
String