toFluentShades

fun TonalPalette.toFluentShades(): Shades

Turns a tonal ramp into the seven shades Fluent themes from.

Fluent ships one accent, Windows blue, and generateShades is a lookup with a single entry, so any other accent silently comes back as that blue. This is the way round it. Give Fluent a ramp that was generated rather than looked up.

The tones below are anchored to the lightness of Microsoft's own Windows blue family, rounded to the nearest five.

ShadeWindows blueits tonetone used here
Shades.dark3#00196813.815
Shades.dark2#003D9227.930
Shades.dark1#005EB740.340
Shades.base#0078D449.750
Shades.light1#0093F959.660
Shades.light2#60CCFE77.880
Shades.light3#98ECFE88.890

Microsoft's ramp shifts hue as it goes, 64 degrees from the darkest shade to the lightest, and a tonal palette holds hue steady. So this matches the lightness of that ramp and not its hue. The result is a ramp of one color rather than a reproduction of the Windows one, which is what you want from a generated accent anyway.

A seed with little chroma gives a Fluent theme with little chroma. A grey seed produces seven greys, which is the ramp doing its job rather than a fault.

// Fluent themed off the scheme's secondary ramp rather than its primary.
val shades = scheme.secondaryPalette.toFluentShades()
FluentTheme(colors = Colors(shades, darkMode = scheme.isDark)) {
Text("Themed from the secondary ramp")
}

Receiver

The ramp to read the seven tones from, usually a scheme's primary palette.

Return

Shades for Colors, or for anything else taking Fluent's shades.