Skip to content
This repository has been archived by the owner on Jan 18, 2020. It is now read-only.

Commit

Permalink
offset per path causing drift
Browse files Browse the repository at this point in the history
  • Loading branch information
tocsoft committed Sep 12, 2017
1 parent a8ad968 commit 27f4867
Show file tree
Hide file tree
Showing 4 changed files with 349 additions and 3 deletions.
317 changes: 317 additions & 0 deletions icons/shapes-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions src/SixLabors.Shapes/ComplexPolygon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ public int FindIntersections(PointF start, PointF end, PointF[] buffer, int offs
int totalAdded = 0;
for (int i = 0; i < this.paths.Length; i++)
{
offset += totalAdded;
int added = this.paths[i].FindIntersections(start, end, buffer, offset);
int added = this.paths[i].FindIntersections(start, end, buffer, totalAdded + offset);
totalAdded += added;
}

Expand Down
2 changes: 1 addition & 1 deletion src/SixLabors.Shapes/Outliner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public static IPath GenerateOutline(this IPath path, float width)
EndType type = p.IsClosed ? EndType.etClosedLine : EndType.etOpenButt;


offset.AddPath(points, JoinType.jtMiter, type);
offset.AddPath(points, JoinType.jtSquare, type);
}

return ExecuteOutliner(width, offset);
Expand Down
30 changes: 30 additions & 0 deletions tests/SixLabors.Shapes.Tests/Issues/Issue_ClippedPaths.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using SixLabors.Primitives;
using System;
using System.Collections.Generic;
using System.Text;
using Xunit;

namespace SixLabors.Shapes.Tests.Issues
{
public class Issue_ClippedPaths
{
[Fact]
public void ClippedTriangle()
{
Polygon simplePath = new Polygon(new LinearLineSegment(
new PointF(10, 10),
new PointF(200, 150),
new PointF(50, 300)));

Polygon hole1 = new Polygon(new LinearLineSegment(
new PointF(37, 85),
new PointF(93, 85),
new PointF(65, 137)));

var clippedPath = simplePath.Clip(hole1);
var outline = clippedPath.GenerateOutline(5, new[] { 1f });

Assert.False(outline.Contains(new PointF(74, 97)));
}
}
}

0 comments on commit 27f4867

Please sign in to comment.