Skip to content

Commit 517a35d

Browse files
Default should be mitre
1 parent e84e9bb commit 517a35d

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/PolygonClipper/PolygonStroker.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ public sealed class PolygonStroker
3636
private const double Pi = Math.PI;
3737
private const double PiMul2 = Math.PI * 2D;
3838

39+
// The inner miter limit used to clamp joins on acute interior angles.
40+
private const double InnerMiterLimit = 1.01D;
41+
3942
// Keep at most 2 warm instances per option-set (one active shape and one spare)
4043
// to reduce churn without retaining many rarely reused configurations.
4144
private const int MaxPooledStrokersPerOptions = 2;
@@ -1100,8 +1103,13 @@ private void CalcJoin(ref StrokeVertexDistance v0, ref StrokeVertexDistance v1,
11001103
double cp = Vertex.Cross(segNext, segForward);
11011104
if (Math.Abs(cp) > double.Epsilon && (cp > 0D) == (strokeWidth > 0D))
11021105
{
1103-
this.AddPoint(v1.X + dx1, v1.Y - dy1);
1104-
this.AddPoint(v1.X + dx2, v1.Y - dy2);
1106+
double limit = Math.Min(len1, len2) / widthAbs;
1107+
if (limit < InnerMiterLimit)
1108+
{
1109+
limit = InnerMiterLimit;
1110+
}
1111+
1112+
this.CalcMiter(ref v0, ref v1, ref v2, dx1, dy1, dx2, dy2, LineJoin.MiterRevert, limit, 0D);
11051113
}
11061114
else
11071115
{

tests/PolygonClipper.Tests/PolygonStrokerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public void ProcessPolygonAndClip_FigureNinePath_ProducesValidStroke()
137137
AssertStrokeCoversInputCenterline(input, actual, samplesPerSegment: 3);
138138
}
139139

140-
[Theory (Skip = "For profiling only.")]
140+
[Theory(Skip = "For profiling only.")]
141141
[InlineData(101)]
142142
[InlineData(301)]
143143
[InlineData(1001)]

0 commit comments

Comments
 (0)