Method GetBrighterColor
GetBrighterColor(double, bool?)
Returns a "highlighted" version of this color — visually more prominent against the given background context.
public Color GetBrighterColor(double brightenAmount = 0.2, bool? isDarkBackground = null)
Parameters
brightenAmountdoubleThe percent amount to adjust the lightness by. The default is
20%.isDarkBackgroundbool?If true, brightens (increases lightness) for visibility on dark backgrounds. If false, darkens (decreases lightness) for visibility on light backgrounds. If null, auto-detects based on this color's own lightness (default/backward-compatible behavior).
Returns
Remarks
The algorithm works in HSL color space and adjusts the lightness channel. When
isDarkBackground is provided, the direction is explicit. When null,
direction is auto-detected from this color's own lightness:
- Dark backgrounds (or dark colors when auto-detecting): lightness is increased.
- Light backgrounds (or light colors when auto-detecting): lightness is decreased.
- If the adjustment resulted in a color too close to the original, a larger adjustment is made.