|
|
|
@ -13,6 +13,7 @@ namespace ImageSharp.Tests.Drawing |
|
|
|
using System.Numerics; |
|
|
|
using Xunit; |
|
|
|
using ImageSharp.Drawing.Brushes; |
|
|
|
using SixLabors.Shapes; |
|
|
|
|
|
|
|
public class SolidPolygonTests : FileTestBase |
|
|
|
{ |
|
|
|
@ -151,7 +152,7 @@ namespace ImageSharp.Tests.Drawing |
|
|
|
{ |
|
|
|
image |
|
|
|
.BackgroundColor(Color.Blue) |
|
|
|
.Fill(Color.HotPink, new SixLabors.Shapes.Rectangle(10,10, 190, 140)) |
|
|
|
.Fill(Color.HotPink, new SixLabors.Shapes.Rectangle(10, 10, 190, 140)) |
|
|
|
.Save(output); |
|
|
|
} |
|
|
|
|
|
|
|
@ -169,5 +170,78 @@ namespace ImageSharp.Tests.Drawing |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void ImageShouldBeOverlayedByFilledTriangle() |
|
|
|
{ |
|
|
|
string path = this.CreateOutputDirectory("Drawing", "FilledPolygons"); |
|
|
|
|
|
|
|
using (Image image = new Image(100, 100)) |
|
|
|
{ |
|
|
|
using (FileStream output = File.OpenWrite($"{path}/Triangle.png")) |
|
|
|
{ |
|
|
|
image |
|
|
|
.BackgroundColor(Color.Blue) |
|
|
|
.Fill(Color.HotPink, new RegularPolygon(50, 50, 3, 30)) |
|
|
|
.Save(output); |
|
|
|
} |
|
|
|
|
|
|
|
using (PixelAccessor<Color> sourcePixels = image.Lock()) |
|
|
|
{ |
|
|
|
Assert.Equal(Color.HotPink, sourcePixels[25, 35]); |
|
|
|
|
|
|
|
Assert.Equal(Color.HotPink, sourcePixels[50, 79]); |
|
|
|
|
|
|
|
Assert.Equal(Color.HotPink, sourcePixels[75, 35]); |
|
|
|
|
|
|
|
Assert.Equal(Color.HotPink, sourcePixels[50, 50]); |
|
|
|
|
|
|
|
Assert.Equal(Color.Blue, sourcePixels[2, 2]); |
|
|
|
|
|
|
|
Assert.Equal(Color.Blue, sourcePixels[28, 60]); |
|
|
|
|
|
|
|
Assert.Equal(Color.Blue, sourcePixels[67, 67]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void ImageShouldBeOverlayedByFilledSeptagon() |
|
|
|
{ |
|
|
|
string path = this.CreateOutputDirectory("Drawing", "FilledPolygons"); |
|
|
|
|
|
|
|
var config = Configuration.CreateDefaultInstance(); |
|
|
|
config.ParallelOptions.MaxDegreeOfParallelism = 1; |
|
|
|
using (Image image = new Image(100, 100, config)) |
|
|
|
{ |
|
|
|
using (FileStream output = File.OpenWrite($"{path}/Septagon.png")) |
|
|
|
{ |
|
|
|
image |
|
|
|
.BackgroundColor(Color.Blue) |
|
|
|
.Fill(Color.HotPink, new RegularPolygon(50, 50, 7, 30, -(float)Math.PI)) |
|
|
|
.Save(output); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void ImageShouldBeOverlayedByFilledEllipse() |
|
|
|
{ |
|
|
|
string path = this.CreateOutputDirectory("Drawing", "FilledPolygons"); |
|
|
|
|
|
|
|
var config = Configuration.CreateDefaultInstance(); |
|
|
|
config.ParallelOptions.MaxDegreeOfParallelism = 1; |
|
|
|
using (Image image = new Image(100, 100, config)) |
|
|
|
{ |
|
|
|
using (FileStream output = File.OpenWrite($"{path}/ellipse.png")) |
|
|
|
{ |
|
|
|
image |
|
|
|
.BackgroundColor(Color.Blue) |
|
|
|
.Fill(Color.HotPink, new Ellipse(50, 50, 30, 50) |
|
|
|
.Rotate((float)(Math.PI / 3))) |
|
|
|
.Save(output); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|