fromPalette

A convenience constructor for DynamicColor.

Strongly prefer using one of the convenience constructors. This class is arguably too flexible to ensure it can support any scenario. Functional arguments allow overriding without risks that come with subclasses.

For example, the default behavior of adjust tone at max contrast to be at a 7.0 ratio with its background is principled and matches accessibility guidance. That does not mean it's the desired approach for every design system, and every color pairing, always, in every case.

For opaque colors (colors with alpha = 100%).

For colors that are not backgrounds, and do not have backgrounds.

Parameters

name

The name of the dynamic color.

palette

Function that provides a TonalPalette given DynamicScheme. A TonalPalette is defined by a hue and chroma, so this replaces the need to specify hue/chroma. By providing a tonal palette, when contrast adjustments are made, intended chroma can be preserved.

tone

Function that provides a tone, given a DynamicScheme.


fun fromPalette(name: String, palette: (DynamicScheme) -> TonalPalette, tone: (DynamicScheme) -> Double, isBackground: Boolean): DynamicColor

A convenience constructor for DynamicColor.

Strongly prefer using one of the convenience constructors. This class is arguably too flexible to ensure it can support any scenario. Functional arguments allow overriding without risks that come with subclasses.

For example, the default behavior of adjust tone at max contrast to be at a 7.0 ratio with its background is principled and matches accessibility guidance. That does not mean it's the desired approach for every design system, and every color pairing, always, in every case.

For opaque colors (colors with alpha = 100%).

For colors that do not have backgrounds.

Parameters

name

The name of the dynamic color.

palette

Function that provides a TonalPalette given DynamicScheme. A TonalPalette is defined by a hue and chroma, so this replaces the need to specify hue/chroma. By providing a tonal palette, when contrast adjustments are made, intended chroma can be preserved.

tone

Function that provides a tone, given a DynamicScheme.

isBackground

Whether this dynamic color is a background, with some other color as the foreground.