Skip to content

Commit

Permalink
Merge pull request #1431 from winterdouglas/optional-gradient-offset
Browse files Browse the repository at this point in the history
Adds support of implicit gradient offsets for SVGs
  • Loading branch information
daniel-luberda committed Jun 30, 2020
2 parents 0801368 + fc8ed84 commit 7012d6c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions source/FFImageLoading.Svg.Shared/SkSvg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1735,16 +1735,20 @@ private static string ReadHrefString(XElement e)
private SortedDictionary<float, SKColor> ReadStops(XElement e)
{
var stops = new SortedDictionary<float, SKColor>();

var ns = e.Name.Namespace;
foreach (var se in e.Elements(ns + "stop"))
{
var style = ReadStyle(se);

var offset = ReadNumber(style["offset"]);
float offset = 0;
var color = SKColors.Black;
byte alpha = 255;

if (style.TryGetValue("offset", out string offsetValue))
{
offset = ReadNumber(offsetValue);
}

if (style.TryGetValue("stop-color", out string stopColor))
{
ColorHelper.TryParse(stopColor, out color);
Expand Down

0 comments on commit 7012d6c

Please sign in to comment.