AngleSharp / AngleSharp.Css

:angel: Library to enable support for cascading stylesheets in AngleSharp.

Home Page:https://anglesharp.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Output hex color value for transparent values if `UseHex` is true

mganss opened this issue · comments

Currently, when UseHex is true, color values are output as hex only if alpha is 1.0.

/// <summary>
/// Gets or sets if hex codes should be used for serialization.
/// This will not be applied in case of transparent colors, i.e.,
/// when alpha is not 1.
/// </summary>
public static Boolean UseHex { get; set; }

else if (_alpha == 255 && UseHex)
{
return $"#{_red.ToString("X2", CultureInfo.InvariantCulture)}{_green.ToString("X2", CultureInfo.InvariantCulture)}{_blue.ToString("X2", CultureInfo.InvariantCulture)}";
}

Perhaps this could be changed to include colors with alpha < 1.0, too.