Commit a234a72b authored by mrbean-bremen's avatar mrbean-bremen Committed by mrbean-bremen
Browse files

Handle writing colors with alpha value

- if the alpha value is less than 1, write additionally the opacity
- fixes #129 (issue 4)
parent 793997f0
...@@ -264,14 +264,19 @@ namespace Svg ...@@ -264,14 +264,19 @@ namespace Svg
try try
{ {
if (attributeName == "opacity" && attributeValue == "undefined") if (attributeName == "opacity" && attributeValue == "undefined")
{ {
attributeValue = "1"; attributeValue = "1";
} }
var value = descriptor.Converter.ConvertFrom(document, CultureInfo.InvariantCulture, attributeValue);
descriptor.SetValue(element, descriptor.Converter.ConvertFrom(document, CultureInfo.InvariantCulture, attributeValue)); if (value is SvgColourServer && ((SvgColourServer)value).Colour.A < 255)
{
// handle alpha values less than 1 by adding an opacity property
var opacity = ((SvgColourServer)value).Colour.A / 255.0;
SetPropertyValue(element, "opacity",
opacity.ToString("F2", CultureInfo.InvariantCulture), document, isStyle);
}
descriptor.SetValue(element, value);
} }
catch catch
{ {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment