rememberThemeColors

fun <T : Any> rememberThemeColors(loader: ImageBitmapLoader<T>, input: T, fallback: Color, desired: Int = DEFAULT_DESIRED_COLORS, filter: Boolean = true, cacheSize: Int = DEFAULT_CACHE_SIZE, coroutineContext: CoroutineContext = Dispatchers.Default, builder: Palette.Builder.() -> Unit = {}): List<Color>

Create and remember the colors of the image loader loads for input, ranked by how well they would seed a UI theme.

The image is loaded and quantized off the main thread, so the first composition sees only fallback and later ones see the scored colors. Results are cached by input, which means going back to an image you already used costs nothing.

Return

Colors sorted by suitability for a UI theme, or a list holding only fallback until there are any.

Parameters

loader

The ImageBitmapLoader that turns input into an image.

input

The input to load, and the cache key of its result.

fallback

color to be returned if no other options available.

desired

The number of colors to return.

filter

whether to filter out undesirable combinations.

cacheSize

The maximum number of palettes to cache. If 0, no caching will be done.

coroutineContext

The CoroutineContext to generate the palette on.

builder

A lambda applied to the Palette.Builder to customize the generation.

Type Parameters

T

The type of the input to load with loader.