Commit 4aef1a55 authored by davescriven's avatar davescriven
Browse files

- Fixed "#7845 - Arc Path Renders incorrectly" as described in the work item -...

- Fixed "#7845 - Arc Path Renders incorrectly" as described in the work item - W3C example now renders   correctly.
- Ensured that a divide by zero exception could not occur during rendering of stroke dash arrays.
parent 7f03fa6b
...@@ -110,7 +110,7 @@ namespace Svg ...@@ -110,7 +110,7 @@ namespace Svg
pen.DashPattern = this.StrokeDashArray.ConvertAll<float>(delegate(SvgUnit unit) pen.DashPattern = this.StrokeDashArray.ConvertAll<float>(delegate(SvgUnit unit)
{ {
// divide by stroke width - GDI behaviour that I don't quite understand yet. // divide by stroke width - GDI behaviour that I don't quite understand yet.
return unit.Value / strokeWidth; return unit.Value / ((strokeWidth <= 0) ? 1 : strokeWidth);
}).ToArray(); }).ToArray();
} }
......
...@@ -99,7 +99,7 @@ namespace Svg.Pathing ...@@ -99,7 +99,7 @@ namespace Svg.Pathing
} }
else else
{ {
root = (this.Size == SvgArcSize.Large && this.Sweep == SvgArcSweep.Positive ? -1.0 : 1.0) * Math.Sqrt(numerator / (this.RadiusX * this.RadiusX * y1dash * y1dash + this.RadiusY * this.RadiusY * x1dash * x1dash)); root = ((this.Size == SvgArcSize.Large && this.Sweep == SvgArcSweep.Positive) || (this.Size == SvgArcSize.Small && this.Sweep == SvgArcSweep.Negative) ? -1.0 : 1.0) * Math.Sqrt(numerator / (this.RadiusX * this.RadiusX * y1dash * y1dash + this.RadiusY * this.RadiusY * x1dash * x1dash));
} }
double cxdash = root * rx * y1dash / ry; double cxdash = root * rx * y1dash / ry;
......
...@@ -57,8 +57,8 @@ namespace Svg ...@@ -57,8 +57,8 @@ namespace Svg
for (var i = 0; i < coords.Count; i += 7) for (var i = 0; i < coords.Count; i += 7)
{ {
size = (coords[i + 3] == 1.0f) ? SvgArcSize.Large : SvgArcSize.Small; size = (coords[i + 3] != 0.0f) ? SvgArcSize.Large : SvgArcSize.Small;
sweep = (coords[i + 4] == 1.0f) ? SvgArcSweep.Positive : SvgArcSweep.Negative; sweep = (coords[i + 4] != 0.0f) ? SvgArcSweep.Positive : SvgArcSweep.Negative;
// A|a rx ry x-axis-rotation large-arc-flag sweep-flag x y // A|a rx ry x-axis-rotation large-arc-flag sweep-flag x y
segments.Add(new SvgArcSegment(segments.Last.End, coords[i], coords[i + 1], coords[i + 2], segments.Add(new SvgArcSegment(segments.Last.End, coords[i], coords[i + 1], coords[i + 2],
...@@ -235,7 +235,7 @@ namespace Svg ...@@ -235,7 +235,7 @@ namespace Svg
private static IEnumerable<float> ParseCoordinates(string coords) private static IEnumerable<float> ParseCoordinates(string coords)
{ {
// TODO: Handle "1-1" (new PointF(1, -1); // TODO: Handle "1-1" (new PointF(1, -1);
var parts = coords.Remove(0, 1).Replace("-", " -").Split(new[] { ',', ' '}, var parts = coords.Remove(0, 1).Replace("-", " -").Split(new[] { ',', ' ' },
StringSplitOptions.RemoveEmptyEntries); StringSplitOptions.RemoveEmptyEntries);
for (var i = 0; i < parts.Length; i++) for (var i = 0; i < parts.Length; i++)
......
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