Palette

class Palette

A helper class to extract prominent colors from an image.

A number of colors with different profiles are extracted from the image:

  • Vibrant

  • Vibrant Dark

  • Vibrant Light

  • Muted

  • Muted Dark

  • Muted Light

These can be retrieved from the appropriate getter method.

Instances are created with a Builder which supports several options to tweak the generated Palette. See that class' documentation for more information.

Generation should always be completed on a background thread, ideally the one in which you load your image on. Builder supports both synchronous and asynchronous generation:

Palette p = Palette.from(pixels, width, height).generate();

Types

Link copied to clipboard
class Builder
Link copied to clipboard
object Companion
Link copied to clipboard
fun interface Filter
Link copied to clipboard
class Swatch(val rgb: Int, val population: Int)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun getColorForTarget(target: Target, @ColorInt defaultColor: Int): Int
Link copied to clipboard
fun getDarkMutedColor(@ColorInt defaultColor: Int): Int
Link copied to clipboard
Link copied to clipboard
fun getDominantColor(@ColorInt defaultColor: Int): Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun getMutedColor(@ColorInt defaultColor: Int): Int
Link copied to clipboard
Link copied to clipboard
fun getVibrantColor(@ColorInt defaultColor: Int): Int