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

Found better solution to SvgClosePathSegment tested with Tiger. #297

Merged
merged 1 commit into from Mar 13, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 12 additions & 14 deletions Source/Paths/SvgClosePathSegment.cs
Expand Up @@ -8,24 +8,22 @@ public sealed class SvgClosePathSegment : SvgPathSegment
{
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()
Expand Down