From 4aef1a55c419bd8843e2e15fbc3f6aa546ab2a82 Mon Sep 17 00:00:00 2001 From: davescriven Date: Sat, 18 Oct 2008 23:28:25 +0000 Subject: [PATCH] - 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. --- Basic Shapes/SvgGraphicsElement.cs | 2 +- Paths/SvgArcSegment.cs | 2 +- Paths/SvgPathBuilder.cs | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Basic Shapes/SvgGraphicsElement.cs b/Basic Shapes/SvgGraphicsElement.cs index 5ff4d43..4e48869 100644 --- a/Basic Shapes/SvgGraphicsElement.cs +++ b/Basic Shapes/SvgGraphicsElement.cs @@ -110,7 +110,7 @@ namespace Svg pen.DashPattern = this.StrokeDashArray.ConvertAll(delegate(SvgUnit unit) { // 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(); } diff --git a/Paths/SvgArcSegment.cs b/Paths/SvgArcSegment.cs index f94cddb..011d3e7 100644 --- a/Paths/SvgArcSegment.cs +++ b/Paths/SvgArcSegment.cs @@ -99,7 +99,7 @@ namespace Svg.Pathing } 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; diff --git a/Paths/SvgPathBuilder.cs b/Paths/SvgPathBuilder.cs index 1273222..387d125 100644 --- a/Paths/SvgPathBuilder.cs +++ b/Paths/SvgPathBuilder.cs @@ -57,8 +57,8 @@ namespace Svg for (var i = 0; i < coords.Count; i += 7) { - size = (coords[i + 3] == 1.0f) ? SvgArcSize.Large : SvgArcSize.Small; - sweep = (coords[i + 4] == 1.0f) ? SvgArcSweep.Positive : SvgArcSweep.Negative; + size = (coords[i + 3] != 0.0f) ? SvgArcSize.Large : SvgArcSize.Small; + sweep = (coords[i + 4] != 0.0f) ? SvgArcSweep.Positive : SvgArcSweep.Negative; // 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], @@ -235,7 +235,7 @@ namespace Svg private static IEnumerable ParseCoordinates(string coords) { // 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); for (var i = 0; i < parts.Length; i++) -- GitLab