Method GetDimmerColor
GetDimmerColor(double, bool?)
Returns a "dimmed" version of this color appropriate for the given background context. On dark backgrounds, dims by reducing lightness (darker). On light backgrounds, dims by increasing lightness (lighter/washed out), moving the color toward the background.
public Color GetDimmerColor(double dimAmount = 0.2, bool? isDarkBackground = null)
Parameters
dimAmountdoubleThe percent amount to dim the color by. The default is
20%.isDarkBackgroundbool?If true, dims by reducing lightness (darker, toward the dark background). If false, dims by increasing lightness (washed out, toward the light background). If null, always reduces lightness (default/backward-compatible behavior).
Returns
Remarks
The algorithm works in HSL color space and adjusts the lightness channel:
- If the color is already at the extreme for the given direction, returns a context-appropriate gray (DarkGray for dark backgrounds, Gray for light backgrounds).
- Otherwise, adjusts lightness by the specified amount in the appropriate direction.
- If the adjustment resulted in a color too close to the original, a larger adjustment is made.