Commit bb69f2be authored by Tebjan Halm's avatar Tebjan Halm Committed by GitHub
Browse files

Merge pull request #297 from LightningDragon/master

Found better solution to SvgClosePathSegment tested with Tiger.
parents 35d0e857 6a20095e
......@@ -8,24 +8,22 @@ namespace Svg.Pathing
{
public override void AddToPath(System.Drawing.Drawing2D.GraphicsPath graphicsPath)
{
if (graphicsPath.PointCount == 0)
var pathData = graphicsPath.PathData;
if (pathData.Points.Length > 0)
{
return;
}
// Important for custom line caps. Force the path the close with an explicit line, not just an implicit close of the figure.
// Important for custom line caps. Force the path the close with an explicit line, not just an implicit close of the figure.
var pathPoints = graphicsPath.PathPoints;
if (!pathData.Points[0].Equals(pathData.Points[pathData.Points.Length - 1]))
{
int i = pathData.Points.Length - 1;
while (i >= 0 && pathData.Types[i] > 0) i--;
if (i < 0) i = 0;
graphicsPath.AddLine(pathData.Points[pathData.Points.Length - 1], pathData.Points[i]);
}
if (!pathPoints[0].Equals(pathPoints[pathPoints.Length - 1]))
{
var pathTypes = graphicsPath.PathTypes;
int i = pathPoints.Length - 1;
while (i >= 0 && pathTypes[i] > 0) i--;
if (i < 0) i = 0;
graphicsPath.AddLine(pathPoints[pathPoints.Length - 1], pathPoints[i]);
graphicsPath.CloseFigure();
}
graphicsPath.CloseFigure();
}
public override string ToString()
......
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