Commit dcafe786 authored by joye-ramone's avatar joye-ramone
Browse files

Fixed issue with translate(x,y) transformation parsing in SvgTransformConverter

According to https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform
translate transformation can be specified without second parameter
parent 6a17e694
...@@ -60,14 +60,21 @@ namespace Svg.Transforms ...@@ -60,14 +60,21 @@ namespace Svg.Transforms
case "translate": case "translate":
string[] coords = contents.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); string[] coords = contents.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (coords.Length != 2) if (coords.Length == 0 || coords.Length > 2)
{ {
throw new FormatException("Translate transforms must be in the format 'translate(x, y)'"); throw new FormatException("Translate transforms must be in the format 'translate(x [,y])'");
} }
float x = float.Parse(coords[0].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture); float x = float.Parse(coords[0].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture);
if (coords.Length > 1)
{
float y = float.Parse(coords[1].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture); float y = float.Parse(coords[1].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture);
transformList.Add(new SvgTranslate(x, y)); transformList.Add(new SvgTranslate(x, y));
}
else
{
transformList.Add(new SvgTranslate(x));
}
break; break;
case "rotate": case "rotate":
string[] args = contents.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); string[] args = contents.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
......
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