diff --git a/Source/SharpVectorCss/Css/CssPrimitiveColorValue.cs b/Source/SharpVectorCss/Css/CssPrimitiveColorValue.cs index 8d3f1446a..1900afbb6 100644 --- a/Source/SharpVectorCss/Css/CssPrimitiveColorValue.cs +++ b/Source/SharpVectorCss/Css/CssPrimitiveColorValue.cs @@ -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); @@ -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;