Skip to content
2 changes: 1 addition & 1 deletion Terminal.Gui/Drawing/Color/Color.ColorExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static ColorExtensions ()
{ new Color(255, 0, 255), ColorName16.Magenta },
{ new Color(255, 255, 0), ColorName16.Yellow },
{ new Color(128, 128, 128), ColorName16.Gray },
{ new Color(118, 118, 118), ColorName16.DarkGray },
{ new Color(169, 169, 169), ColorName16.DarkGray },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That correspond adding 20% of the opacity (118+255*0.20=118+51=169), which may be the opacity percentage used by the StandardColor? It's possible to comprove with a unit test the opacity percentage (20%) for all StandardColor?

{ new Color(59, 120, 255), ColorName16.BrightBlue },
{ new Color(22, 198, 12), ColorName16.BrightGreen },
{ new Color(97, 214, 214), ColorName16.BrightCyan },
Expand Down
16 changes: 11 additions & 5 deletions Terminal.Gui/Drawing/Color/Color.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@ namespace Terminal.Gui.Drawing;
/// <seealso cref="ColorName16"/>
[JsonConverter (typeof (ColorJsonConverter))]
[StructLayout (LayoutKind.Explicit)]
public readonly partial record struct Color : ISpanParsable<Color>, IUtf8SpanParsable<Color>, ISpanFormattable,
public readonly partial record struct Color : ISpanParsable<Color>, IUtf8SpanParsable<Color>, ISpanFormattable,
IUtf8SpanFormattable, IMinMaxValue<Color>
{
/// <summary>
/// Transparent color (0 for all elements). This is interpreted as default console color.
/// </summary>
public static readonly Color Transparent = new Color (0, 0, 0, 0);

/// <summary>The value of the alpha channel component</summary>
/// <remarks>
/// The alpha channel is not currently supported, so the value of the alpha channel bits will not affect
Expand Down Expand Up @@ -86,14 +91,15 @@ public Color (int red = 0, int green = 0, int blue = 0, int alpha = byte.MaxValu

/// <summary>
/// Initializes a new instance of the <see cref="Color"/> class with an encoded signed 32-bit color value in
/// ARGB32 format.
/// RGB32 format. Note that <see langword="int"/> is insufficient to represent alpha so assumed to be 255 unless
/// the value is <see cref="StandardColor.Transparent"/>
/// </summary>
/// <param name="rgba">The encoded 32-bit color value (see <see cref="Rgba"/>).</param>
/// <param name="rgb">The encoded 32-bit color value (see <see cref="Rgba"/>).</param>
/// <remarks>
/// The alpha channel is not currently supported, so the value of the alpha channel bits will not affect
/// rendering.
/// </remarks>
public Color (int rgba) { Rgba = rgba; }
public Color (int rgb) { Rgba = rgb; }

/// <summary>
/// Initializes a new instance of the <see cref="Color"/> class with an encoded unsigned 32-bit color value in
Expand All @@ -113,7 +119,7 @@ public Color (int red = 0, int green = 0, int blue = 0, int alpha = byte.MaxValu

/// <summary>Initializes a new instance of the <see cref="Color"/> color from a value in the <see cref="StandardColor"/> enum.</summary>
/// <param name="colorName">The 16-color value.</param>
public Color (in StandardColor colorName) : this ((int)colorName) { }
public Color (in StandardColor colorName) : this ((uint)colorName) { }

/// <summary>
/// Initializes a new instance of the <see cref="Color"/> color from string. See
Expand Down
Loading
Loading