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
......@@ -268,10 +268,15 @@ namespace Svg
{
attributeValue = "1";
}
descriptor.SetValue(element, descriptor.Converter.ConvertFrom(document, CultureInfo.InvariantCulture, attributeValue));
var value = 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
{
......
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