Skip to main content

AsyncPicPalette

A data class returned via onPaletteLoaded containing extracted color swatches from the loaded image.

data class AsyncPicPalette(
val vibrant: Color?,
val dominant: Color?,
val muted: Color?,
val lightVibrant: Color?,
val darkVibrant: Color?
)

All fields are nullable — complex images may not produce every swatch.


Fields​

FieldDescriptionBest used for
vibrantMost vivid, saturated colorButtons, highlights, accents
dominantMost frequently occurring colorBackgrounds, containers
mutedDesaturated version of vibrantSubtle backgrounds
lightVibrantLight, saturated swatchText on dark backgrounds
darkVibrantDark, saturated swatchText color, dark containers

Usage​

AsyncPic(
source = ImageSource.Url("https://example.com/photo.jpg"),
modifier = Modifier.size(200.dp),
onPaletteLoaded = { palette ->
// Safely unwrap — any swatch may be null
val accent = palette.vibrant ?: palette.dominant ?: Color.Gray
val bg = palette.darkVibrant ?: Color(0xFF1E293B)
}
)

Internal Use​

AsyncPic uses AsyncPicPalette internally to drive the Adaptive Shimmer Morph feature. Before calling onPaletteLoaded, it updates the shimmer's activeShimmerColor with this priority:

  1. vibrantSwatch
  2. lightVibrantSwatch
  3. dominantSwatch

This means even if you don't pass onPaletteLoaded, you still get the color morphing effect automatically.