DominantColorState

abstract class DominantColorState<T : Any>(defaultColor: Color, defaultOnColor: Color, cacheSize: Int = DEFAULT_CACHE_SIZE, coroutineContext: CoroutineContext = Dispatchers.Default, isSwatchValid: (Palette.Swatch) -> Boolean = { true }, builder: Palette.Builder.() -> Unit = {})

A class which stores and caches the result of any calculated dominant colors.

Access the current dominant color via color.

Parameters

T

The type of the input to calculate the dominant color from.

defaultColor

The default color, which will be used if calculateDominantColor fails to calculate a dominant color

cacheSize

The size of the LruCache used to store recent results. Pass 0 to disable the cache.

coroutineContext

The CoroutineContext used to launch the coroutine.

builder

A lambda which allows customization of the Palette.Builder used to generate the Palette from the input T

Constructors

Link copied to clipboard
constructor(defaultColor: Color, defaultOnColor: Color, cacheSize: Int = DEFAULT_CACHE_SIZE, coroutineContext: CoroutineContext = Dispatchers.Default, isSwatchValid: (Palette.Swatch) -> Boolean = { true }, builder: Palette.Builder.() -> Unit = {})

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The dominant color.

Link copied to clipboard

The color to use on color.

Link copied to clipboard

The result of the last Palette generation.

Functions

Link copied to clipboard
fun reset()

Reset the color values to defaultColor.

Link copied to clipboard
suspend fun updateFrom(input: T)

Update the dominant color from the given input.