Skip to content

Commit

Permalink
Fixes transparency issue
Browse files Browse the repository at this point in the history
-  This resolves the issue #289
  • Loading branch information
paulushub committed Jun 24, 2024
1 parent 79da795 commit c84ca9b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Source/SharpVectorCss/Css/CssPrimitiveColorValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ public sealed class CssPrimitiveColorValue : CssPrimitiveValue
public CssPrimitiveColorValue(int color, bool readOnly)
: base(color.ToString(CssNumber.Format), readOnly)
{
if (color < 0)
if (color <= 0)
{
SetFloatValue(0);
}
else if (color > 0 && color <= 1)
{
color = (int)(255 * color);
SetFloatValue(color);
}
else if (color > 255)
{
SetFloatValue(255);
Expand Down Expand Up @@ -49,10 +54,14 @@ protected override void OnSetCssText(string cssText)

}
var color = double.Parse(cssText, CssNumber.Format);
if (color < 0)
if (color <= 0)
{
color = 0;
}
else if (color > 0 && color <= 1)
{
color = (int)(255 * color);
}
else if (color > 255)
{
color = 255;
Expand Down

0 comments on commit c84ca9b

Please sign in to comment.