Package-level declarations

Types

Link copied to clipboard
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.

Link copied to clipboard
interface PaletteResult

Wrapper result class for the generation of a Palette.

Link copied to clipboard
abstract class PaletteState<T : Any>(cacheSize: Int = DEFAULT_CACHE_SIZE, coroutineContext: CoroutineContext = Dispatchers.Default, builder: Palette.Builder.() -> Unit = {})

A state object that generates a Palette from an ImageBitmap using loader.

Link copied to clipboard
interface SwatchTarget

A class which allows custom selection of colors in a Palette's generation. Instances can be created via the Builder class.

Properties

Link copied to clipboard

Returns a color value in the RGB color space which represents the color of this Swatch

Link copied to clipboard

Returns an appropriate color to use for any 'title' text which is displayed over this Swatch's color. This color is guaranteed to have sufficient contrast.

Functions

Link copied to clipboard

Returns an appropriate color to use for any 'body' text which is displayed over this Swatch's color. This color is guaranteed to have sufficient contrast.

Link copied to clipboard
suspend fun ImageBitmap.generatePalette(coroutineContext: CoroutineContext = Dispatchers.Default, block: Palette.Builder.() -> Unit = {}): Palette

Generates a Palette from this ImageBitmap.

Link copied to clipboard
operator fun Palette.get(target: SwatchTarget): Palette.Swatch?
operator fun Palette.get(target: Target): Palette.Swatch?

Returns the selected swatch for the given target from the palette, or null if one could not be found.

Link copied to clipboard

Returns the selected swatch for the given target from the palette, or null if one could not be found.

Link copied to clipboard
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>
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.

Link copied to clipboard
fun rememberGeneratePalette(loader: suspend () -> ImageBitmap, coroutineContext: CoroutineContext = Dispatchers.Default, block: Palette.Builder.() -> Unit = {}): PaletteResult

Generates a Palette from this ImageBitmap and remembers the result.

Link copied to clipboard
fun ImageBitmap.rememberGeneratePalette(coroutineContext: CoroutineContext = Dispatchers.Default, block: Palette.Builder.() -> Unit = {}): PaletteResult

Generates a Palette from this ImageBitmap and remembers the result.

Link copied to clipboard
fun rememberPainterDominantColorState(defaultColor: Color = MaterialTheme.colorScheme.primary, defaultOnColor: Color = MaterialTheme.colorScheme.onPrimary, density: Density = LocalDensity.current, layoutDirection: LayoutDirection = LocalLayoutDirection.current, cacheSize: Int = 0, coroutineContext: CoroutineContext = Dispatchers.Default, isSwatchValid: (Palette.Swatch) -> Boolean = { true }, builder: Palette.Builder.() -> Unit = {}): DominantColorState<Painter>

Wrapper around rememberDominantColorState that uses PainterLoader to load the image.

Link copied to clipboard
fun rememberPainterPaletteState(density: Density = LocalDensity.current, layoutDirection: LayoutDirection = LocalLayoutDirection.current, cacheSize: Int = DominantColorState.DEFAULT_CACHE_SIZE, coroutineContext: CoroutineContext = Dispatchers.Default, builder: Palette.Builder.() -> Unit = {}): PaletteState<Painter>

Wrapper around rememberPaletteState that uses PainterLoader to load the image.

Link copied to clipboard
fun rememberPaletteState(cacheSize: Int = DominantColorState.DEFAULT_CACHE_SIZE, coroutineContext: CoroutineContext = Dispatchers.Default, builder: Palette.Builder.() -> Unit = {}): PaletteState<ImageBitmap>

Creates a PaletteState that will be remembered across compilation and can be used to generate a Palette from an ImageBitmap.

fun <T : Any> rememberPaletteState(loader: ImageBitmapLoader<T>, cacheSize: Int = DominantColorState.DEFAULT_CACHE_SIZE, coroutineContext: CoroutineContext = Dispatchers.Default, builder: Palette.Builder.() -> Unit = {}): PaletteState<T>

Creates a PaletteState that will be remembered across compilation and can be used to generate a Palette from an ImageBitmap using loader.

Link copied to clipboard

Returns an appropriate color to use for any 'title' text which is displayed over this Swatch's color. This color is guaranteed to have sufficient contrast.