Palette.Swatch


public final class Palette.Swatch


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

Summary

Public constructors

Swatch(@ColorInt int color, int population)

Public methods

boolean
@ColorInt int

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

@NonNull float[]

Return this swatch's HSL values. hsv[0] is Hue [0 ..

int
@ColorInt int
@ColorInt int

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

int
String

Public constructors

Swatch

Added in 1.0.0
public Swatch(@ColorInt int color, int population)

Public methods

equals

public boolean equals(Object o)

getBodyTextColor

Added in 1.0.0
public @ColorInt int getBodyTextColor()

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.

getHsl

Added in 1.0.0
public @NonNull 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]

getPopulation

Added in 1.0.0
public int getPopulation()
Returns
int

the number of pixels represented by this swatch

getRgb

Added in 1.0.0
public @ColorInt int getRgb()
Returns
@ColorInt int

this swatch's RGB color value

getTitleTextColor

Added in 1.0.0
public @ColorInt int getTitleTextColor()

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

public int hashCode()

toString

public String toString()