mirror of https://github.com/SixLabors/ImageSharp
2 changed files with 152 additions and 152 deletions
@ -1,158 +1,158 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
using System; |
using System; |
||||
using System.Collections.Generic; |
using System.Collections.Generic; |
||||
using System.Linq; |
using System.Linq; |
||||
using SixLabors.ImageSharp.PixelFormats; |
using SixLabors.ImageSharp.PixelFormats; |
||||
using SixLabors.ImageSharp.Processing; |
using SixLabors.ImageSharp.Processing; |
||||
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; |
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; |
||||
using SixLabors.Primitives; |
using SixLabors.Primitives; |
||||
using Xunit; |
using Xunit; |
||||
|
|
||||
// ReSharper disable InconsistentNaming
|
// ReSharper disable InconsistentNaming
|
||||
namespace SixLabors.ImageSharp.Tests.Drawing |
namespace SixLabors.ImageSharp.Tests.Drawing |
||||
{ |
{ |
||||
[GroupOutput("Drawing")] |
[GroupOutput("Drawing")] |
||||
public class SolidFillBlendedShapesTests |
public class SolidFillBlendedShapesTests |
||||
{ |
{ |
||||
public static IEnumerable<object[]> modes = |
public static IEnumerable<object[]> modes = |
||||
((PixelBlenderMode[])Enum.GetValues(typeof(PixelBlenderMode))).Select(x => new object[] { x }); |
((PixelBlenderMode[])Enum.GetValues(typeof(PixelBlenderMode))).Select(x => new object[] { x }); |
||||
|
|
||||
[Theory] |
[Theory] |
||||
[WithBlankImages(nameof(modes), 250, 250, PixelTypes.Rgba32)] |
[WithBlankImages(nameof(modes), 250, 250, PixelTypes.Rgba32)] |
||||
public void _1DarkBlueRect_2BlendHotPinkRect<TPixel>( |
public void _1DarkBlueRect_2BlendHotPinkRect<TPixel>( |
||||
TestImageProvider<TPixel> provider, |
TestImageProvider<TPixel> provider, |
||||
PixelBlenderMode mode) |
PixelBlenderMode mode) |
||||
where TPixel : struct, IPixel<TPixel> |
where TPixel : struct, IPixel<TPixel> |
||||
{ |
{ |
||||
using (Image<TPixel> img = provider.GetImage()) |
using (Image<TPixel> img = provider.GetImage()) |
||||
{ |
{ |
||||
int scaleX = img.Width / 100; |
int scaleX = img.Width / 100; |
||||
int scaleY = img.Height / 100; |
int scaleY = img.Height / 100; |
||||
img.Mutate( |
img.Mutate( |
||||
x => x.Fill( |
x => x.Fill( |
||||
NamedColors<TPixel>.DarkBlue, |
NamedColors<TPixel>.DarkBlue, |
||||
new Rectangle(0 * scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY) |
new Rectangle(0 * scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY) |
||||
) |
) |
||||
.Fill(new GraphicsOptions(true) { BlenderMode = mode }, |
.Fill(new GraphicsOptions(true) { BlenderMode = mode }, |
||||
NamedColors<TPixel>.HotPink, |
NamedColors<TPixel>.HotPink, |
||||
new Rectangle(20 * scaleX, 0 * scaleY, 30 * scaleX, 100 * scaleY)) |
new Rectangle(20 * scaleX, 0 * scaleY, 30 * scaleX, 100 * scaleY)) |
||||
); |
); |
||||
|
|
||||
VerifyImage(provider, mode, img); |
VerifyImage(provider, mode, img); |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
[Theory] |
[Theory] |
||||
[WithBlankImages(nameof(modes), 250, 250, PixelTypes.Rgba32)] |
[WithBlankImages(nameof(modes), 250, 250, PixelTypes.Rgba32)] |
||||
public void _1DarkBlueRect_2BlendHotPinkRect_3BlendTransparentEllipse<TPixel>( |
public void _1DarkBlueRect_2BlendHotPinkRect_3BlendTransparentEllipse<TPixel>( |
||||
TestImageProvider<TPixel> provider, |
TestImageProvider<TPixel> provider, |
||||
PixelBlenderMode mode) |
PixelBlenderMode mode) |
||||
where TPixel : struct, IPixel<TPixel> |
where TPixel : struct, IPixel<TPixel> |
||||
{ |
{ |
||||
using (Image<TPixel> img = provider.GetImage()) |
using (Image<TPixel> img = provider.GetImage()) |
||||
{ |
{ |
||||
int scaleX = img.Width / 100; |
int scaleX = img.Width / 100; |
||||
int scaleY = img.Height / 100; |
int scaleY = img.Height / 100; |
||||
img.Mutate( |
img.Mutate( |
||||
x => x.Fill( |
x => x.Fill( |
||||
NamedColors<TPixel>.DarkBlue, |
NamedColors<TPixel>.DarkBlue, |
||||
new Rectangle(0 * scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY))); |
new Rectangle(0 * scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY))); |
||||
img.Mutate( |
img.Mutate( |
||||
x => x.Fill( |
x => x.Fill( |
||||
new GraphicsOptions(true) { BlenderMode = mode }, |
new GraphicsOptions(true) { BlenderMode = mode }, |
||||
NamedColors<TPixel>.HotPink, |
NamedColors<TPixel>.HotPink, |
||||
new Rectangle(20 * scaleX, 0 * scaleY, 30 * scaleX, 100 * scaleY))); |
new Rectangle(20 * scaleX, 0 * scaleY, 30 * scaleX, 100 * scaleY))); |
||||
img.Mutate( |
img.Mutate( |
||||
x => x.Fill( |
x => x.Fill( |
||||
new GraphicsOptions(true) { BlenderMode = mode }, |
new GraphicsOptions(true) { BlenderMode = mode }, |
||||
NamedColors<TPixel>.Transparent, |
NamedColors<TPixel>.Transparent, |
||||
new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY)) |
new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY)) |
||||
); |
); |
||||
|
|
||||
VerifyImage(provider, mode, img); |
VerifyImage(provider, mode, img); |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
[Theory] |
[Theory] |
||||
[WithBlankImages(nameof(modes), 250, 250, PixelTypes.Rgba32)] |
[WithBlankImages(nameof(modes), 250, 250, PixelTypes.Rgba32)] |
||||
public void _1DarkBlueRect_2BlendHotPinkRect_3BlendSemiTransparentRedEllipse<TPixel>( |
public void _1DarkBlueRect_2BlendHotPinkRect_3BlendSemiTransparentRedEllipse<TPixel>( |
||||
TestImageProvider<TPixel> provider, |
TestImageProvider<TPixel> provider, |
||||
PixelBlenderMode mode) |
PixelBlenderMode mode) |
||||
where TPixel : struct, IPixel<TPixel> |
where TPixel : struct, IPixel<TPixel> |
||||
{ |
{ |
||||
using (Image<TPixel> img = provider.GetImage()) |
using (Image<TPixel> img = provider.GetImage()) |
||||
{ |
{ |
||||
int scaleX = (img.Width / 100); |
int scaleX = (img.Width / 100); |
||||
int scaleY = (img.Height / 100); |
int scaleY = (img.Height / 100); |
||||
img.Mutate( |
img.Mutate( |
||||
x => x.Fill( |
x => x.Fill( |
||||
NamedColors<TPixel>.DarkBlue, |
NamedColors<TPixel>.DarkBlue, |
||||
new Rectangle(0 * scaleX, 40, 100 * scaleX, 20 * scaleY))); |
new Rectangle(0 * scaleX, 40, 100 * scaleX, 20 * scaleY))); |
||||
img.Mutate( |
img.Mutate( |
||||
x => x.Fill( |
x => x.Fill( |
||||
new GraphicsOptions(true) { BlenderMode = mode }, |
new GraphicsOptions(true) { BlenderMode = mode }, |
||||
NamedColors<TPixel>.HotPink, |
NamedColors<TPixel>.HotPink, |
||||
new Rectangle(20 * scaleX, 0, 30 * scaleX, 100 * scaleY))); |
new Rectangle(20 * scaleX, 0, 30 * scaleX, 100 * scaleY))); |
||||
var c = NamedColors<TPixel>.Red.ToVector4(); |
var c = NamedColors<TPixel>.Red.ToVector4(); |
||||
c.W *= 0.5f; |
c.W *= 0.5f; |
||||
var pixel = default(TPixel); |
var pixel = default(TPixel); |
||||
pixel.PackFromVector4(c); |
pixel.PackFromVector4(c); |
||||
|
|
||||
img.Mutate( |
img.Mutate( |
||||
x => x.Fill( |
x => x.Fill( |
||||
new GraphicsOptions(true) { BlenderMode = mode }, |
new GraphicsOptions(true) { BlenderMode = mode }, |
||||
pixel, |
pixel, |
||||
new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY)) |
new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY)) |
||||
); |
); |
||||
|
|
||||
VerifyImage(provider, mode, img); ; |
VerifyImage(provider, mode, img); ; |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
[Theory] |
[Theory] |
||||
[WithBlankImages(nameof(modes), 250, 250, PixelTypes.Rgba32)] |
[WithBlankImages(nameof(modes), 250, 250, PixelTypes.Rgba32)] |
||||
public void _1DarkBlueRect_2BlendBlackEllipse<TPixel>(TestImageProvider<TPixel> provider, PixelBlenderMode mode) |
public void _1DarkBlueRect_2BlendBlackEllipse<TPixel>(TestImageProvider<TPixel> provider, PixelBlenderMode mode) |
||||
where TPixel : struct, IPixel<TPixel> |
where TPixel : struct, IPixel<TPixel> |
||||
{ |
{ |
||||
using(Image<TPixel> dstImg = provider.GetImage(), srcImg = provider.GetImage()) |
using(Image<TPixel> dstImg = provider.GetImage(), srcImg = provider.GetImage()) |
||||
{ |
{ |
||||
int scaleX = (dstImg.Width / 100); |
int scaleX = (dstImg.Width / 100); |
||||
int scaleY = (dstImg.Height / 100); |
int scaleY = (dstImg.Height / 100); |
||||
|
|
||||
dstImg.Mutate( |
dstImg.Mutate( |
||||
x => x.Fill( |
x => x.Fill( |
||||
NamedColors<TPixel>.DarkBlue, |
NamedColors<TPixel>.DarkBlue, |
||||
new Rectangle(0 * scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY))); |
new Rectangle(0 * scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY))); |
||||
|
|
||||
srcImg.Mutate( |
srcImg.Mutate( |
||||
x => x.Fill( |
x => x.Fill( |
||||
NamedColors<TPixel>.Black, |
NamedColors<TPixel>.Black, |
||||
new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY))); |
new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY))); |
||||
|
|
||||
dstImg.Mutate( |
dstImg.Mutate( |
||||
x => x.DrawImage(new GraphicsOptions(true) { BlenderMode = mode }, srcImg) |
x => x.DrawImage(new GraphicsOptions(true) { BlenderMode = mode }, srcImg) |
||||
); |
); |
||||
|
|
||||
VerifyImage(provider, mode, dstImg); |
VerifyImage(provider, mode, dstImg); |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
private static void VerifyImage<TPixel>(TestImageProvider<TPixel> provider, PixelBlenderMode mode, Image<TPixel> img) |
private static void VerifyImage<TPixel>(TestImageProvider<TPixel> provider, PixelBlenderMode mode, Image<TPixel> img) |
||||
where TPixel : struct, IPixel<TPixel> |
where TPixel : struct, IPixel<TPixel> |
||||
{ |
{ |
||||
img.DebugSave( |
img.DebugSave( |
||||
provider, |
provider, |
||||
new { mode }, |
new { mode }, |
||||
appendPixelTypeToFileName: false, |
appendPixelTypeToFileName: false, |
||||
appendSourceFileOrDescription: false); |
appendSourceFileOrDescription: false); |
||||
|
|
||||
var comparer = ImageComparer.TolerantPercentage(0.01f, 3); |
var comparer = ImageComparer.TolerantPercentage(0.01f, 3); |
||||
img.CompareFirstFrameToReferenceOutput(comparer, |
img.CompareFirstFrameToReferenceOutput(comparer, |
||||
provider, |
provider, |
||||
new { mode }, |
new { mode }, |
||||
appendPixelTypeToFileName: false, |
appendPixelTypeToFileName: false, |
||||
appendSourceFileOrDescription: false); |
appendSourceFileOrDescription: false); |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
@ -1 +1 @@ |
|||||
Subproject commit 98fb7e2e4d5935b1c733bd2b206b6145b71ef378 |
Subproject commit 825220cdc4e9d1b4b3b474c63139e18e1cdb800e |
||||
Loading…
Reference in new issue