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 = {})
Properties
Functions
Link copied to clipboard
Reset the color values to defaultColor.
Link copied to clipboard
Update the dominant color from the given input.