Table of Contents

Method GetDimmerColor

Namespace
Terminal.Gui.Drawing
Assembly
Terminal.Gui.dll

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

dimAmount double

The percent amount to dim the color by. The default is 20%.

isDarkBackground bool?

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

Color

Remarks

The algorithm works in HSL color space and adjusts the lightness channel:

<ul><li>
            If the color is already at the extreme for the given direction, returns a context-appropriate
            gray (<xref href="Terminal.Gui.Drawing.ColorName16.DarkGray" data-throw-if-not-resolved="false"></xref> for dark backgrounds,
            <xref href="Terminal.Gui.Drawing.ColorName16.Gray" data-throw-if-not-resolved="false"></xref> for light backgrounds).
        </li><li>Otherwise, adjusts lightness by the specified amount in the appropriate direction.</li><li>
            If the adjustment resulted in a color too close to the original, a larger adjustment is
            made.
        </li></ul>