Skip to content

Commit 5b5c2d8

Browse files
Add fixes from Clipper Discussion 490
1 parent f36703e commit 5b5c2d8

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3112,9 +3112,14 @@ private void CheckJoinLeft(Active e, Vector2 pt, bool checkCurrX = false)
31123112
|| IsOpen(e)
31133113
|| IsOpen(prev)
31143114
|| !IsHotEdge(e)
3115-
|| !IsHotEdge(prev)
3116-
|| pt.Y < e.Top.Y + 2
3117-
|| pt.Y < prev.Top.Y + 2)
3115+
|| !IsHotEdge(prev))
3116+
{
3117+
return;
3118+
}
3119+
3120+
// Avoid trivial joins
3121+
if ((pt.Y < e.Top.Y + 2 || pt.Y < prev.Top.Y + 2)
3122+
&& ((e.Bot.Y > pt.Y) || (prev.Bot.Y > pt.Y)))
31183123
{
31193124
return;
31203125
}
@@ -3162,10 +3167,14 @@ private void CheckJoinRight(Active e, Vector2 pt, bool checkCurrX = false)
31623167
|| IsJoined(e)
31633168
|| next == null
31643169
|| IsOpen(next)
3165-
|| !IsHotEdge(next)
3170+
|| !IsHotEdge(next))
3171+
{
3172+
return;
3173+
}
31663174

3167-
// avoids trivial joins
3168-
|| pt.Y < e.Top.Y + 2 || pt.Y < next.Top.Y + 2)
3175+
// Avoid trivial joins
3176+
if ((pt.Y < e.Top.Y + 2 || pt.Y < next.Top.Y + 2)
3177+
&& ((e.Bot.Y > pt.Y) || (next.Bot.Y > pt.Y)))
31693178
{
31703179
return;
31713180
}

0 commit comments

Comments
 (0)