rememberDominantColorState

fun rememberDominantColorState(defaultColor: Color = MaterialTheme.colorScheme.primary, defaultOnColor: Color = MaterialTheme.colorScheme.onPrimary, cacheSize: Int = 0, coroutineContext: CoroutineContext = Dispatchers.Default, isSwatchValid: (Palette.Swatch) -> Boolean = { true }, builder: Palette.Builder.() -> Unit = {}): DominantColorState<ImageBitmap>

Create a DominantColorState which will be remembered across compositions. Then can be used to generate a dominant color from an ImageBitmap.

Return

A DominantColorState which can be used to generate a dominant color from a ImageBitmap.

Parameters

defaultColor

The default color, which will be used if Palette.generate fails.

defaultOnColor

The default color to use on defaultColor.

cacheSize

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

coroutineContext

The CoroutineContext used to launch the coroutine.

isSwatchValid

A lambda which allows filtering of the calculated Palette.Swatch.

builder

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


fun <T : Any> rememberDominantColorState(loader: ImageBitmapLoader<T>, defaultColor: Color = MaterialTheme.colorScheme.primary, defaultOnColor: Color = MaterialTheme.colorScheme.onPrimary, cacheSize: Int = DominantColorState.DEFAULT_CACHE_SIZE, coroutineContext: CoroutineContext = Dispatchers.Default, isSwatchValid: (Palette.Swatch) -> Boolean = { true }, builder: Palette.Builder.() -> Unit = {}): DominantColorState<T>

Create a DominantColorState which will be remembered across compositions. Then can be used to generate a dominant color from an ImageBitmap.

Return

A DominantColorState which can be used to generate a dominant color from a ImageBitmap.

Parameters

loader

The ImageBitmapLoader to use to load the ImageBitmap.

defaultColor

The default color, which will be used if Palette.generate fails.

defaultOnColor

The default color to use on defaultColor.

cacheSize

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

coroutineContext

The CoroutineContext used to launch the coroutine.

isSwatchValid

A lambda which allows filtering of the calculated Palette.Swatch.

builder

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