Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix for DrawPath implementation #11

Merged
merged 8 commits into from
Aug 29, 2017
7 changes: 6 additions & 1 deletion SvgGdiTest/SvgGdiTestForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,12 @@ private void Render(IGraphics ig)
LinearGradientBrush gbr2 = new LinearGradientBrush(new Point(0, 0), new Point(10, 20), Color.WhiteSmoke, Color.CornflowerBlue);
gbr2.WrapMode = WrapMode.TileFlipXY;
ig.FillPath(gbr2, myPath);

GraphicsPath myPath2 = new GraphicsPath();
myPath2.AddLine(100, 100, 130, 120);
myPath2.AddEllipse(120, 120, 120, 140);
myPath2.AddBezier(130, 160, 170, 160, 150, 130, 200, 110);
ig.DrawPath(new Pen(Color.Blue), myPath2);
}
else if (s == "Path 2 (Slow)")
{
Expand All @@ -522,7 +528,6 @@ private void Render(IGraphics ig)
myGraphicsPath.AddString("a string in a path filled", myFontFamily,
0, 24, myPointF, myStringFormat);
myGraphicsPath.AddPie(230, 10, 40, 40, 40, 110);

ig.FillPath(mySolidBrush, myGraphicsPath);
ig.DrawPath(new Pen(Color.Green), myGraphicsPath);
}
Expand Down
9 changes: 5 additions & 4 deletions SvgNet/SVGGraphics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1972,7 +1972,7 @@ public void DrawLines(Pen pen, Point[] points)
/// <remarks>
/// Mainly based on the libgdi+ implementation: https://github.com/mono/libgdiplus/blob/master/src/graphics-cairo.c
/// and this SO question reply: https://stackoverflow.com/questions/1790862/how-to-determine-endpoints-of-arcs-in-graphicspath-pathpoints-and-pathtypes-arra
/// from SiiliconMind.
/// from SiliconMind.
/// </remarks>
public void DrawPath(Pen pen, GraphicsPath path)
{
Expand Down Expand Up @@ -2011,10 +2011,11 @@ public void DrawPath(Pen pen, GraphicsPath path)
start = subpath.PathPoints[i];
bezierCurvePoints[0] = subpath.PathPoints[i];
bezierCurvePointsIndex = 1;
pen.DashStyle = originalPenDashStyle; //Reset pen dash mode to original when starting subpath
continue;
case PathPointType.Line:
DrawLine(pen, start, subpath.PathPoints[i]); //Draw a line segment ftom start point
start = subpath.PathPoints[i]; //Move start point here
start = subpath.PathPoints[i]; //Move start point to line end
bezierCurvePoints[0] = subpath.PathPoints[i]; //A line point can also be the start of a Bezier curve
bezierCurvePointsIndex = 1;
continue;
Expand All @@ -2026,10 +2027,10 @@ public void DrawPath(Pen pen, GraphicsPath path)
bezierCurvePoints = new PointF[4];
bezierCurvePoints[0] = subpath.PathPoints[i];
bezierCurvePointsIndex = 1;
start = subpath.PathPoints[i]; //Move start point to curve end
}
continue;
default:

switch ((PathPointType)subpath.PathTypes[i])
{
case PathPointType.DashMode:
Expand Down Expand Up @@ -2353,7 +2354,7 @@ public void FillPath(Brush brush, GraphicsPath path)
}
if (!isClosed)
{
subpath.CloseAllFigures();
//subpath.CloseAllFigures();
}
PathPointType lastType = (PathPointType)subpath.PathTypes[subpath.PathPoints.Length - 1];
if (subpath.PathTypes.Any(pt => ((PathPointType) pt & PathPointType.PathTypeMask) == PathPointType.Line))
Expand Down
2 changes: 1 addition & 1 deletion SvgNet/svgnetdoc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.