Skip to content

Commit f36703e

Browse files
Update to latest Clipper
1 parent 795dd02 commit f36703e

File tree

23 files changed

+53
-66
lines changed

23 files changed

+53
-66
lines changed

src/ImageSharp.Drawing/Shapes/PolygonClipper/PolygonOffsetter.cs

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -426,19 +426,7 @@ private void OffsetPoint(Group group, PathF path, int j, ref int k)
426426
sinA = -1F;
427427
}
428428

429-
// almost straight - less than 8 degrees
430-
if (cosA > .99F)
431-
{
432-
group.OutPath.Add(this.GetPerpendic(path[j], this.normals[k]));
433-
434-
// greater than 1 degree (#424)
435-
if (cosA < .9998F)
436-
{
437-
// (#418)
438-
group.OutPath.Add(this.GetPerpendic(path[j], this.normals[j]));
439-
}
440-
}
441-
else if (cosA > -.99F && (sinA * this.groupDelta < 0))
429+
if (cosA > -0.99F && (sinA * this.groupDelta < 0F))
442430
{
443431
// is concave
444432
group.OutPath.Add(this.GetPerpendic(path[j], this.normals[k]));
@@ -448,10 +436,6 @@ private void OffsetPoint(Group group, PathF path, int j, ref int k)
448436
group.OutPath.Add(path[j]); // (#405)
449437
group.OutPath.Add(this.GetPerpendic(path[j], this.normals[j]));
450438
}
451-
else if (this.joinType == JointStyle.Round)
452-
{
453-
this.DoRound(group, path, j, k, MathF.Atan2(sinA, cosA));
454-
}
455439
else if (this.joinType == JointStyle.Miter)
456440
{
457441
// miter unless the angle is so acute the miter would exceeds ML
@@ -464,17 +448,20 @@ private void OffsetPoint(Group group, PathF path, int j, ref int k)
464448
this.DoSquare(group, path, j, k);
465449
}
466450
}
467-
468-
// don't bother squaring angles that deviate < ~20 degrees because
469-
// squaring will be indistinguishable from mitering and just be a lot slower
470-
else if (cosA > .9F)
451+
else if (cosA > 0.9998F)
471452
{
453+
// almost straight - less than 1 degree (#424)
472454
this.DoMiter(group, path, j, k, cosA);
473455
}
474-
else
456+
else if (cosA > 0.99F || this.joinType == JointStyle.Square)
475457
{
458+
// angle less than 8 degrees or a squared join
476459
this.DoSquare(group, path, j, k);
477460
}
461+
else
462+
{
463+
this.DoRound(group, path, j, k, MathF.Atan2(sinA, cosA));
464+
}
478465

479466
k = j;
480467
}
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading

0 commit comments

Comments
 (0)