Package-level declarations

Types

Link copied to clipboard

Define the threshold for a contrast ratio.

Properties

Link copied to clipboard

A MaterialKolors class that holds the generated colors based on the current state.

Link copied to clipboard

Returns the Material 3 color scheme based on the current dynamic color scheme.

Link copied to clipboard

Get the Color used to generate the DynamicScheme.

Functions

Link copied to clipboard
@Composable
fun Color.animate(animationSpec: AnimationSpec<Color> = defaultColorSpring, label: String = "ColorAnimation", finishedListener: (Color) -> Unit? = null): State<Color>

Animate the color over time, allowing for a smooth transition between different color states.

Link copied to clipboard
@Composable
fun animateColorScheme(colorScheme: ColorScheme, animationSpec: @Composable Transition.Segment<ColorScheme>.() -> FiniteAnimationSpec<Color> = { defaultColorSpring }, label: String = "ColorSchemeAnimation"): ColorScheme

Creates an animated version of a ColorScheme where all colors smoothly animate when changed.

Link copied to clipboard
fun Color.blend(to: Color, amount: Float = 0.5f): Color
fun Blend.blend(from: Color, to: Color, amount: Float): Color

Blend two colors together. The hue, chroma, and tone of the original color will change.

Link copied to clipboard
fun Color.blendHue(to: Color, amount: Float = 0.5f): Color

Blends this Color into another. The chroma and tone of the original color are maintained.

fun Blend.blendHue(from: Color, to: Color, amount: Float): Color

Blends hue from one Color into another. The chroma and tone of the original color are maintained.

Link copied to clipboard

Create content key tones from a color.

Link copied to clipboard
fun Color.contrastRatio(other: Color): Double

Contrast ratio is a measure of legibility, its used to compare the lightness of two colors. This method is used commonly in industry due to its use by WCAG.

Link copied to clipboard
@Stable
fun Color.darken(ratio: Float = 1.1f): Color

Darken the color by the given ratio.

Link copied to clipboard
fun DynamicScheme(seedColor: Color, isDark: Boolean, primary: Color? = null, secondary: Color? = null, tertiary: Color? = null, neutral: Color? = null, neutralVariant: Color? = null, error: Color? = null, style: PaletteStyle = TonalSpot, contrastLevel: Double = Contrast.Default.value, specVersion: ColorSpec.SpecVersion = ColorSpec.SpecVersion.Default, platform: DynamicScheme.Platform = DynamicScheme.Platform.Default): DynamicScheme

Create a DynamicScheme based on the provided colors.

Link copied to clipboard
@Stable
fun Color.fixIfDisliked(): Color

If color is disliked, lighten it to make it likable.

Link copied to clipboard
fun Hct.Companion.from(color: Color): Hct

Convert a Compose Color to Hct.

Create key tones from a color.

Generates a TonalPalette from the given color.

Generates a TonalPalette from the given Hct.

Generates a TonalPalette from the given argb color int.

Link copied to clipboard
fun DynamicColor.getColor(scheme: DynamicScheme): Color

Returns an Color that represents the color of this DynamicColor in the given scheme.

Link copied to clipboard
@Stable
fun Color.harmonize(other: Color, matchSaturation: Boolean = false): Color

Blend the color's HCT hue towards the other color's HCT hue, in a way that leaves the original color recognizable and recognizably shifted towards the key color.

@Stable
fun Blend.harmonize(fromColor: Color, toColor: Color, matchSaturation: Boolean = false): Color

Blend the design color's HCT hue towards the key color's HCT hue, in a way that leaves the original color recognizable and recognizably shifted towards the key color.

Link copied to clipboard
@Stable
fun ColorScheme.harmonizeWithPrimary(color: Color, matchSaturation: Boolean = false): Color

Returns the Color of the given color harmonized with the ColorScheme.primary.

Link copied to clipboard
fun Color.hasEnoughContrast(other: Color, threshold: ContrastThreshold = ContrastThreshold.WCAG_AA_NORMAL_TEXT): Boolean

Check if the contrast ratio between two colors is greater than or equal to a given threshold.

Link copied to clipboard
@Stable
fun Color.isCool(): Boolean

Determine a given color is cool.

Link copied to clipboard
@Stable
fun Color.isDisliked(): Boolean

Returns true if color is disliked.

Link copied to clipboard
@Stable
fun Color.isLight(): Boolean

Check if the color is light.

Link copied to clipboard
@Stable
fun Color.isWarm(): Boolean

Determine a given color is warm.

Link copied to clipboard
@Stable
fun Color.lighten(ratio: Float = 1.0f): Color

Lighten the color by the given ratio.

Link copied to clipboard

Create key tones from a color.

Link copied to clipboard
fun QuantizerCelebi.quantize(image: ImageBitmap, maxColors: Int): Map<Int, Int>

Quantize the colors in a ImageBitmap to a maximum of maxColors colors.

Link copied to clipboard
@Composable
fun rememberDynamicScheme(seedColor: Color, isDark: Boolean, primary: Color? = null, secondary: Color? = null, tertiary: Color? = null, neutral: Color? = null, neutralVariant: Color? = null, error: Color? = null, style: PaletteStyle = TonalSpot, contrastLevel: Double = Contrast.Default.value, specVersion: ColorSpec.SpecVersion = ColorSpec.SpecVersion.Default, platform: DynamicScheme.Platform = DynamicScheme.Platform.Default): DynamicScheme

Create and remember a DynamicScheme based on the provided colors.

Link copied to clipboard
@Stable
@Composable
fun rememberThemeColor(image: ImageBitmap, fallback: Color = MaterialTheme.colorScheme.primary, filter: Boolean = true, maxColors: Int = DEFAULT_QUANTIZE_MAX_COLORS): Color

Determine the most suitable color in a ImageBitmap for a UI theme.

Link copied to clipboard
@Stable
@Composable
fun rememberThemeColors(image: ImageBitmap, fallback: Color = MaterialTheme.colorScheme.primary, maxColors: Int = DEFAULT_QUANTIZE_MAX_COLORS, filter: Boolean = true, desired: Int = DEFAULT_DESIRED_COLORS): List<Color>

Determine the most suitable color in a ImageBitmap for a UI theme.

Link copied to clipboard

Value representing cool-warm factor of a color.

Link copied to clipboard

Design utilities using color temperature theory.

Link copied to clipboard
@Stable
fun ImageBitmap.themeColor(fallback: Color, filter: Boolean = true, maxColors: Int = DEFAULT_QUANTIZE_MAX_COLORS): Color

Determine the most suitable color in a ImageBitmap for a UI theme.

Link copied to clipboard
@Stable
fun ImageBitmap.themeColorOrNull(filter: Boolean = true, maxColors: Int = DEFAULT_QUANTIZE_MAX_COLORS): Color?

Determine the most suitable color in a ImageBitmap for a UI theme or null

Link copied to clipboard
@Stable
fun ImageBitmap.themeColors(maxColors: Int = DEFAULT_QUANTIZE_MAX_COLORS, fallback: Color = Color(-0xbd7a0c), filter: Boolean = true, desired: Int = DEFAULT_DESIRED_COLORS): List<Color>

Rank the colors in a ImageBitmap by their suitability for being used for a UI theme.

Link copied to clipboard
@Stable
fun Hct.toColor(): Color

Convert HCT to a Compose Color.

Link copied to clipboard
@Stable
fun List<Hct>.toColors(): List<Color>

Convert a list of HCT to a list of Compose Color.

Link copied to clipboard
fun Color.toDynamicScheme(isDark: Boolean, style: PaletteStyle, contrastLevel: Double = Contrast.Default.value, specVersion: ColorSpec.SpecVersion = ColorSpec.SpecVersion.Default, platform: DynamicScheme.Platform = DynamicScheme.Platform.Default): DynamicScheme

Generate a DynamicScheme based on the given Color.

Link copied to clipboard
fun Color.toHct(): Hct

Convert a Compose Color to Hct.

Link copied to clipboard
fun List<Color>.toHcts(): List<Hct>

Convert a list of Compose Color to a list of HCT.

Link copied to clipboard
fun Color.toHex(includePrefix: Boolean = true, prefix: String = "#", alwaysIncludeAlpha: Boolean = false): String

Convert the color to a hex string.

Link copied to clipboard
fun Color.tonalContrastRatio(other: Color): Double

Contrast ratio of two tones. T in HCT, L* in Lab*. Also known as luminance or perpetual luminance.

Link copied to clipboard
fun TonalPalette.toneColor(tone: Int): Color

Get a tonal Color from the TonalPalette with the given tone.