Skip to content

Commit

Permalink
Fix svg-net#437 'Doesn't render stroke of rect, if fill opacity is 0'…
Browse files Browse the repository at this point in the history
… issue.
  • Loading branch information
H1Gdev committed Apr 22, 2019
1 parent 6ca4100 commit 1415c54
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Source/SvgElementFactory.cs
Expand Up @@ -269,11 +269,12 @@ internal static bool SetPropertyValue(SvgElement element, string attributeName,
attributeValue = "1";
}
var value = descriptor.Converter.ConvertFrom(document, CultureInfo.InvariantCulture, attributeValue);
if (value is SvgColourServer && ((SvgColourServer)value).Colour.A < 255)
if ((attributeName == "fill" || attributeName == "stroke") &&
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",
SetPropertyValue(element, attributeName + "-opacity",
opacity.ToString("F2", CultureInfo.InvariantCulture), document, isStyle);
}
descriptor.SetValue(element, value);
Expand Down

0 comments on commit 1415c54

Please sign in to comment.