Skip to content

Commit b0f3858

Browse files
Add ClippingOperation tests
1 parent 0d1ad3d commit b0f3858

6 files changed

Lines changed: 36 additions & 0 deletions

tests/ImageSharp.Drawing.Tests/Drawing/FillPolygonTests.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.Numerics;
66
using SixLabors.ImageSharp.Drawing.Processing;
7+
using SixLabors.ImageSharp.Drawing.Shapes.PolygonClipper;
78
using SixLabors.ImageSharp.Drawing.Tests.TestUtilities.ImageComparison;
89
using SixLabors.ImageSharp.PixelFormats;
910
using SixLabors.ImageSharp.Processing;
@@ -184,6 +185,26 @@ public void FillPolygon_StarCircle(TestImageProvider<Rgba32> provider)
184185
appendPixelTypeToFileName: false);
185186
}
186187

188+
[Theory]
189+
[WithSolidFilledImages(128, 128, "Black", PixelTypes.Rgba32)]
190+
public void FillPolygon_StarCircle_AllOperations(TestImageProvider<Rgba32> provider)
191+
{
192+
IPath circle = new EllipsePolygon(36, 36, 36).Translate(28, 28);
193+
var star = new Star(64, 64, 5, 24, 64);
194+
195+
foreach (ClippingOperation operation in (ClippingOperation[])Enum.GetValues(typeof(ClippingOperation)))
196+
{
197+
IPath shape = star.Clip(operation, IntersectionRule.EvenOdd, circle);
198+
199+
provider.RunValidatingProcessorTest(
200+
c => c.Fill(Color.DeepPink, circle).Fill(Color.LightGray, star).Fill(Color.ForestGreen, shape),
201+
comparer: ImageComparer.TolerantPercentage(0.01f),
202+
testOutputDetails: operation.ToString(),
203+
appendSourceFileOrDescription: false,
204+
appendPixelTypeToFileName: false);
205+
}
206+
}
207+
187208
[Theory]
188209
[WithBasicTestPatternImages(250, 350, PixelTypes.Rgba32)]
189210
public void FillPolygon_Pattern<TPixel>(TestImageProvider<TPixel> provider)
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)