Skip to content

Commit c84ca9b

Browse files
committed
Fixes transparency issue
- This resolves the issue #289
1 parent 79da795 commit c84ca9b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Source/SharpVectorCss/Css/CssPrimitiveColorValue.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@ public sealed class CssPrimitiveColorValue : CssPrimitiveValue
77
public CssPrimitiveColorValue(int color, bool readOnly)
88
: base(color.ToString(CssNumber.Format), readOnly)
99
{
10-
if (color < 0)
10+
if (color <= 0)
1111
{
1212
SetFloatValue(0);
1313
}
14+
else if (color > 0 && color <= 1)
15+
{
16+
color = (int)(255 * color);
17+
SetFloatValue(color);
18+
}
1419
else if (color > 255)
1520
{
1621
SetFloatValue(255);
@@ -49,10 +54,14 @@ protected override void OnSetCssText(string cssText)
4954

5055
}
5156
var color = double.Parse(cssText, CssNumber.Format);
52-
if (color < 0)
57+
if (color <= 0)
5358
{
5459
color = 0;
5560
}
61+
else if (color > 0 && color <= 1)
62+
{
63+
color = (int)(255 * color);
64+
}
5665
else if (color > 255)
5766
{
5867
color = 255;

0 commit comments

Comments
 (0)