Browse Source

everything builds

pull/910/head
Anton Firszov 7 years ago
parent
commit
8271ef18c9
  1. 2
      tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs
  2. 2
      tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs
  3. 2
      tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs
  4. 4
      tests/ImageSharp.Benchmarks/Drawing/DrawText.cs
  5. 23
      tests/ImageSharp.Benchmarks/Drawing/DrawTextOutline.cs
  6. 2
      tests/ImageSharp.Tests/Drawing/DrawBezierTests.cs
  7. 2
      tests/ImageSharp.Tests/Drawing/DrawComplexPolygonTests.cs
  8. 12
      tests/ImageSharp.Tests/Drawing/DrawLinesTests.cs
  9. 4
      tests/ImageSharp.Tests/Drawing/DrawPathTests.cs
  10. 2
      tests/ImageSharp.Tests/Drawing/DrawPolygonTests.cs
  11. 2
      tests/ImageSharp.Tests/Drawing/FillComplexPolygonTests.cs
  12. 36
      tests/ImageSharp.Tests/Drawing/FillEllipticGradientBrushTest.cs
  13. 104
      tests/ImageSharp.Tests/Drawing/FillLinearGradientBrushTests.cs
  14. 2
      tests/ImageSharp.Tests/Drawing/FillPatternBrushTests.cs
  15. 12
      tests/ImageSharp.Tests/Drawing/FillPolygonTests.cs
  16. 14
      tests/ImageSharp.Tests/Drawing/FillRadialGradientBrushTests.cs
  17. 11
      tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs
  18. 22
      tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs
  19. 16
      tests/ImageSharp.Tests/Drawing/Paths/DrawPathCollection.cs
  20. 16
      tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs
  21. 16
      tests/ImageSharp.Tests/Drawing/Paths/FillPathCollection.cs
  22. 16
      tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs
  23. 16
      tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs
  24. 4
      tests/ImageSharp.Tests/Drawing/RecolorImageTests.cs
  25. 2
      tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs
  26. 26
      tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs
  27. 70
      tests/ImageSharp.Tests/Drawing/Text/DrawText.cs
  28. 12
      tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs
  29. 6
      tests/ImageSharp.Tests/Issues/Issue412.cs
  30. 3
      tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs
  31. 14
      tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs

2
tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs

@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.Benchmarks
graphics.InterpolationMode = InterpolationMode.Default; graphics.InterpolationMode = InterpolationMode.Default;
graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.SmoothingMode = SmoothingMode.AntiAlias;
using (var pen = new Pen(System.Drawing.Color.HotPink, 10)) using (var pen = new System.Drawing.Pen(System.Drawing.Color.HotPink, 10))
{ {
graphics.DrawBeziers(pen, new[] { graphics.DrawBeziers(pen, new[] {
new PointF(10, 500), new PointF(10, 500),

2
tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs

@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Benchmarks
graphics.InterpolationMode = InterpolationMode.Default; graphics.InterpolationMode = InterpolationMode.Default;
graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.SmoothingMode = SmoothingMode.AntiAlias;
using (var pen = new Pen(System.Drawing.Color.HotPink, 10)) using (var pen = new System.Drawing.Pen(System.Drawing.Color.HotPink, 10))
{ {
graphics.DrawLines(pen, new[] { graphics.DrawLines(pen, new[] {
new PointF(10, 10), new PointF(10, 10),

2
tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs

@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Benchmarks
{ {
graphics.InterpolationMode = InterpolationMode.Default; graphics.InterpolationMode = InterpolationMode.Default;
graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.SmoothingMode = SmoothingMode.AntiAlias;
using (var pen = new Pen(System.Drawing.Color.HotPink, 10)) using (var pen = new System.Drawing.Pen(System.Drawing.Color.HotPink, 10))
{ {
graphics.DrawPolygon(pen, new[] { graphics.DrawPolygon(pen, new[] {
new PointF(10, 10), new PointF(10, 10),

4
tests/ImageSharp.Benchmarks/Drawing/DrawText.cs

@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp.Benchmarks
using (var image = new Image<Rgba32>(800, 800)) using (var image = new Image<Rgba32>(800, 800))
{ {
var font = SixLabors.Fonts.SystemFonts.CreateFont("Arial", 12); var font = SixLabors.Fonts.SystemFonts.CreateFont("Arial", 12);
image.Mutate(x => x.ApplyProcessor(new DrawTextProcessor<Rgba32>(new TextGraphicsOptions(true) { WrapTextWidth = 780 }, TextToRender, font, Processing.Brushes.Solid(Rgba32.HotPink), null, new SixLabors.Primitives.PointF(10, 10)))); image.Mutate(x => x.ApplyProcessor(new DrawTextProcessor(new TextGraphicsOptions(true) { WrapTextWidth = 780 }, TextToRender, font, Processing.Brushes.Solid(Rgba32.HotPink), null, new SixLabors.Primitives.PointF(10, 10))));
} }
} }
@ -55,7 +55,7 @@ namespace SixLabors.ImageSharp.Benchmarks
image.Mutate(x => DrawTextOldVersion(x, new TextGraphicsOptions(true) { WrapTextWidth = 780 }, TextToRender, font, Processing.Brushes.Solid(Rgba32.HotPink), null, new SixLabors.Primitives.PointF(10, 10))); image.Mutate(x => DrawTextOldVersion(x, new TextGraphicsOptions(true) { WrapTextWidth = 780 }, TextToRender, font, Processing.Brushes.Solid(Rgba32.HotPink), null, new SixLabors.Primitives.PointF(10, 10)));
} }
IImageProcessingContext<TPixel> DrawTextOldVersion<TPixel>(IImageProcessingContext<TPixel> source, TextGraphicsOptions options, string text, SixLabors.Fonts.Font font, IBrush<TPixel> brush, IPen<TPixel> pen, SixLabors.Primitives.PointF location) IImageProcessingContext<TPixel> DrawTextOldVersion<TPixel>(IImageProcessingContext<TPixel> source, TextGraphicsOptions options, string text, SixLabors.Fonts.Font font, IBrush brush, IPen pen, SixLabors.Primitives.PointF location)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
float dpiX = 72; float dpiX = 72;

23
tests/ImageSharp.Benchmarks/Drawing/DrawTextOutline.cs

@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.Benchmarks
{ {
graphics.InterpolationMode = InterpolationMode.Default; graphics.InterpolationMode = InterpolationMode.Default;
graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.SmoothingMode = SmoothingMode.AntiAlias;
using (var pen = new Pen(System.Drawing.Color.HotPink, 10)) using (var pen = new System.Drawing.Pen(System.Drawing.Color.HotPink, 10))
using (var font = new Font("Arial", 12, GraphicsUnit.Point)) using (var font = new Font("Arial", 12, GraphicsUnit.Point))
using (var gp = new GraphicsPath()) using (var gp = new GraphicsPath())
{ {
@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Benchmarks
using (var image = new Image<Rgba32>(800, 800)) using (var image = new Image<Rgba32>(800, 800))
{ {
var font = SixLabors.Fonts.SystemFonts.CreateFont("Arial", 12); var font = SixLabors.Fonts.SystemFonts.CreateFont("Arial", 12);
image.Mutate(x => x.ApplyProcessor(new DrawTextProcessor<Rgba32>(new TextGraphicsOptions(true) { WrapTextWidth = 780 }, TextToRender, font, null, Processing.Pens.Solid(Rgba32.HotPink, 10), new SixLabors.Primitives.PointF(10, 10)))); image.Mutate(x => x.ApplyProcessor(new DrawTextProcessor(new TextGraphicsOptions(true) { WrapTextWidth = 780 }, TextToRender, font, null, Processing.Pens.Solid(Rgba32.HotPink, 10), new SixLabors.Primitives.PointF(10, 10))));
} }
} }
@ -53,10 +53,25 @@ namespace SixLabors.ImageSharp.Benchmarks
using (var image = new Image<Rgba32>(800, 800)) using (var image = new Image<Rgba32>(800, 800))
{ {
var font = SixLabors.Fonts.SystemFonts.CreateFont("Arial", 12); var font = SixLabors.Fonts.SystemFonts.CreateFont("Arial", 12);
image.Mutate(x => DrawTextOldVersion(x, new TextGraphicsOptions(true) { WrapTextWidth = 780 }, TextToRender, font, null, Processing.Pens.Solid(Rgba32.HotPink, 10), new SixLabors.Primitives.PointF(10, 10))); image.Mutate(
x => DrawTextOldVersion(
x,
new TextGraphicsOptions(true) { WrapTextWidth = 780 },
TextToRender,
font,
null,
Processing.Pens.Solid(Rgba32.HotPink, 10),
new SixLabors.Primitives.PointF(10, 10)));
} }
IImageProcessingContext<TPixel> DrawTextOldVersion<TPixel>(IImageProcessingContext<TPixel> source, TextGraphicsOptions options, string text, SixLabors.Fonts.Font font, IBrush<TPixel> brush, IPen<TPixel> pen, SixLabors.Primitives.PointF location) IImageProcessingContext<TPixel> DrawTextOldVersion<TPixel>(
IImageProcessingContext<TPixel> source,
TextGraphicsOptions options,
string text,
SixLabors.Fonts.Font font,
IBrush brush,
IPen pen,
SixLabors.Primitives.PointF location)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
var style = new SixLabors.Fonts.RendererOptions(font, options.DpiX, options.DpiY, location) var style = new SixLabors.Fonts.RendererOptions(font, options.DpiX, options.DpiY, location)

2
tests/ImageSharp.Tests/Drawing/DrawBezierTests.cs

@ -39,7 +39,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
FormattableString testDetails = $"{colorName}_A{alpha}_T{thickness}"; FormattableString testDetails = $"{colorName}_A{alpha}_T{thickness}";
provider.RunValidatingProcessorTest( x => x.DrawBeziers(color.ToPixel<TPixel>(), 5f, points), provider.RunValidatingProcessorTest( x => x.DrawBeziers(color, 5f, points),
testDetails, testDetails,
appendSourceFileOrDescription: false, appendSourceFileOrDescription: false,
appendPixelTypeToFileName: false); appendPixelTypeToFileName: false);

2
tests/ImageSharp.Tests/Drawing/DrawComplexPolygonTests.cs

@ -58,7 +58,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
testDetails += "_Dashed"; testDetails += "_Dashed";
} }
Pen<TPixel> pen = dashed ? Pens.Dash(color.ToPixel<TPixel>(), 5f) : Pens.Solid(color.ToPixel<TPixel>(), 5f); Pen pen = dashed ? Pens.Dash(color, 5f) : Pens.Solid(color, 5f);
provider.RunValidatingProcessorTest( provider.RunValidatingProcessorTest(
x => x.Draw(pen, clipped), x => x.Draw(pen, clipped),

12
tests/ImageSharp.Tests/Drawing/DrawLinesTests.cs

@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
Color color = TestUtils.GetColorByName(colorName).WithAlpha(alpha); Color color = TestUtils.GetColorByName(colorName).WithAlpha(alpha);
Pen<TPixel> pen = new Pen<TPixel>(color.ToPixel<TPixel>(), thickness); Pen pen = new Pen(color, thickness);
DrawLinesImpl(provider, colorName, alpha, thickness, antialias, pen); DrawLinesImpl(provider, colorName, alpha, thickness, antialias, pen);
} }
@ -35,7 +35,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
Color color = TestUtils.GetColorByName(colorName).WithAlpha(alpha); Color color = TestUtils.GetColorByName(colorName).WithAlpha(alpha);
Pen<TPixel> pen = Pens.Dash(color.ToPixel<TPixel>(), thickness); Pen pen = Pens.Dash(color, thickness);
DrawLinesImpl(provider, colorName, alpha, thickness, antialias, pen); DrawLinesImpl(provider, colorName, alpha, thickness, antialias, pen);
} }
@ -46,7 +46,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
Color color = TestUtils.GetColorByName(colorName).WithAlpha(alpha); Color color = TestUtils.GetColorByName(colorName).WithAlpha(alpha);
Pen<TPixel> pen = Pens.Dot(color.ToPixel<TPixel>(), thickness); Pen pen = Pens.Dot(color, thickness);
DrawLinesImpl(provider, colorName, alpha, thickness, antialias, pen); DrawLinesImpl(provider, colorName, alpha, thickness, antialias, pen);
} }
@ -57,7 +57,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
Color color = TestUtils.GetColorByName(colorName).WithAlpha(alpha); Color color = TestUtils.GetColorByName(colorName).WithAlpha(alpha);
Pen<TPixel> pen = Pens.DashDot(color.ToPixel<TPixel>(), thickness); Pen pen = Pens.DashDot(color, thickness);
DrawLinesImpl(provider, colorName, alpha, thickness, antialias, pen); DrawLinesImpl(provider, colorName, alpha, thickness, antialias, pen);
} }
@ -68,7 +68,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
Color color = TestUtils.GetColorByName(colorName).WithAlpha(alpha); Color color = TestUtils.GetColorByName(colorName).WithAlpha(alpha);
Pen<TPixel> pen = Pens.DashDotDot(color.ToPixel<TPixel>(), thickness); Pen pen = Pens.DashDotDot(color, thickness);
DrawLinesImpl(provider, colorName, alpha, thickness, antialias, pen); DrawLinesImpl(provider, colorName, alpha, thickness, antialias, pen);
} }
@ -80,7 +80,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
float alpha, float alpha,
float thickness, float thickness,
bool antialias, bool antialias,
Pen<TPixel> pen) Pen pen)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
SixLabors.Primitives.PointF[] simplePath = { new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) }; SixLabors.Primitives.PointF[] simplePath = { new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) };

4
tests/ImageSharp.Tests/Drawing/DrawPathTests.cs

@ -49,7 +49,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
FormattableString testDetails = $"{colorName}_A{alpha}_T{thickness}"; FormattableString testDetails = $"{colorName}_A{alpha}_T{thickness}";
provider.RunValidatingProcessorTest( provider.RunValidatingProcessorTest(
x => x.Draw(color.ToPixel<TPixel>(), thickness, path), x => x.Draw(color, thickness, path),
testDetails, testDetails,
appendPixelTypeToFileName: false, appendPixelTypeToFileName: false,
appendSourceFileOrDescription: false); appendSourceFileOrDescription: false);
@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
Color color = Color.White; Color color = Color.White;
Pen<TPixel> pen = Pens.Solid(color.ToPixel<TPixel>(), 5f); Pen pen = Pens.Solid(color, 5f);
provider.RunValidatingProcessorTest( provider.RunValidatingProcessorTest(
x => x =>

2
tests/ImageSharp.Tests/Drawing/DrawPolygonTests.cs

@ -35,7 +35,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
FormattableString outputDetails = $"{colorName}_A({alpha})_T({thickness}){aa}"; FormattableString outputDetails = $"{colorName}_A({alpha})_T({thickness}){aa}";
provider.RunValidatingProcessorTest( provider.RunValidatingProcessorTest(
c => c.DrawPolygon(options, color.ToPixel<TPixel>(), thickness, simplePath), c => c.DrawPolygon(options, color, thickness, simplePath),
outputDetails, outputDetails,
appendSourceFileOrDescription: false); appendSourceFileOrDescription: false);
} }

2
tests/ImageSharp.Tests/Drawing/FillComplexPolygonTests.cs

@ -53,7 +53,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
} }
provider.RunValidatingProcessorTest( provider.RunValidatingProcessorTest(
x => x.Fill(color.ToPixel<TPixel>(), clipped), x => x.Fill(color, clipped),
testDetails, testDetails,
appendPixelTypeToFileName: false, appendPixelTypeToFileName: false,
appendSourceFileOrDescription: false); appendSourceFileOrDescription: false);

36
tests/ImageSharp.Tests/Drawing/FillEllipticGradientBrushTest.cs

@ -23,18 +23,18 @@ namespace SixLabors.ImageSharp.Tests.Drawing
TestImageProvider<TPixel> provider) TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
TPixel red = NamedColors<TPixel>.Red; Color red = Color.Red;
using (Image<TPixel> image = provider.GetImage()) using (Image<TPixel> image = provider.GetImage())
{ {
var unicolorLinearGradientBrush = var unicolorLinearGradientBrush =
new EllipticGradientBrush<TPixel>( new EllipticGradientBrush(
new SixLabors.Primitives.Point(0, 0), new SixLabors.Primitives.Point(0, 0),
new SixLabors.Primitives.Point(10, 0), new SixLabors.Primitives.Point(10, 0),
1.0f, 1.0f,
GradientRepetitionMode.None, GradientRepetitionMode.None,
new ColorStop<TPixel>(0, red), new ColorStop(0, red),
new ColorStop<TPixel>(1, red)); new ColorStop(1, red));
image.Mutate(x => x.Fill(unicolorLinearGradientBrush)); image.Mutate(x => x.Fill(unicolorLinearGradientBrush));
@ -58,22 +58,22 @@ namespace SixLabors.ImageSharp.Tests.Drawing
float ratio) float ratio)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
TPixel yellow = NamedColors<TPixel>.Yellow; Color yellow = Color.Yellow;
TPixel red = NamedColors<TPixel>.Red; Color red = Color.Red;
TPixel black = NamedColors<TPixel>.Black; Color black = Color.Black;
provider.VerifyOperation( provider.VerifyOperation(
TolerantComparer, TolerantComparer,
image => image =>
{ {
var unicolorLinearGradientBrush = new EllipticGradientBrush<TPixel>( var unicolorLinearGradientBrush = new EllipticGradientBrush(
new SixLabors.Primitives.Point(image.Width / 2, image.Height / 2), new SixLabors.Primitives.Point(image.Width / 2, image.Height / 2),
new SixLabors.Primitives.Point(image.Width / 2, (image.Width * 2) / 3), new SixLabors.Primitives.Point(image.Width / 2, (image.Width * 2) / 3),
ratio, ratio,
GradientRepetitionMode.None, GradientRepetitionMode.None,
new ColorStop<TPixel>(0, yellow), new ColorStop(0, yellow),
new ColorStop<TPixel>(1, red), new ColorStop(1, red),
new ColorStop<TPixel>(1, black)); new ColorStop(1, black));
image.Mutate(x => x.Fill(unicolorLinearGradientBrush)); image.Mutate(x => x.Fill(unicolorLinearGradientBrush));
}, },
@ -114,9 +114,9 @@ namespace SixLabors.ImageSharp.Tests.Drawing
TolerantComparer, TolerantComparer,
image => image =>
{ {
TPixel yellow = NamedColors<TPixel>.Yellow; Color yellow = Color.Yellow;
TPixel red = NamedColors<TPixel>.Red; Color red = Color.Red;
TPixel black = NamedColors<TPixel>.Black; Color black = Color.Black;
var center = new SixLabors.Primitives.Point(image.Width / 2, image.Height / 2); var center = new SixLabors.Primitives.Point(image.Width / 2, image.Height / 2);
@ -128,14 +128,14 @@ namespace SixLabors.ImageSharp.Tests.Drawing
int axisX = center.X + (int)-(offsetY * sin); int axisX = center.X + (int)-(offsetY * sin);
int axisY = center.Y + (int)(offsetY * cos); int axisY = center.Y + (int)(offsetY * cos);
var unicolorLinearGradientBrush = new EllipticGradientBrush<TPixel>( var unicolorLinearGradientBrush = new EllipticGradientBrush(
center, center,
new SixLabors.Primitives.Point(axisX, axisY), new SixLabors.Primitives.Point(axisX, axisY),
ratio, ratio,
GradientRepetitionMode.None, GradientRepetitionMode.None,
new ColorStop<TPixel>(0, yellow), new ColorStop(0, yellow),
new ColorStop<TPixel>(1, red), new ColorStop(1, red),
new ColorStop<TPixel>(1, black)); new ColorStop(1, black));
image.Mutate(x => x.Fill(unicolorLinearGradientBrush)); image.Mutate(x => x.Fill(unicolorLinearGradientBrush));
}, },

104
tests/ImageSharp.Tests/Drawing/FillLinearGradientBrushTests.cs

@ -29,14 +29,14 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{ {
using (Image<TPixel> image = provider.GetImage()) using (Image<TPixel> image = provider.GetImage())
{ {
TPixel red = NamedColors<TPixel>.Red; Color red = Color.Red;
var unicolorLinearGradientBrush = new LinearGradientBrush<TPixel>( var unicolorLinearGradientBrush = new LinearGradientBrush(
new SixLabors.Primitives.Point(0, 0), new SixLabors.Primitives.Point(0, 0),
new SixLabors.Primitives.Point(10, 0), new SixLabors.Primitives.Point(10, 0),
GradientRepetitionMode.None, GradientRepetitionMode.None,
new ColorStop<TPixel>(0, red), new ColorStop(0, red),
new ColorStop<TPixel>(1, red)); new ColorStop(1, red));
image.Mutate(x => x.Fill(unicolorLinearGradientBrush)); image.Mutate(x => x.Fill(unicolorLinearGradientBrush));
@ -58,12 +58,12 @@ namespace SixLabors.ImageSharp.Tests.Drawing
TolerantComparer, TolerantComparer,
image => image =>
{ {
var unicolorLinearGradientBrush = new LinearGradientBrush<TPixel>( var unicolorLinearGradientBrush = new LinearGradientBrush(
new SixLabors.Primitives.Point(0, 0), new SixLabors.Primitives.Point(0, 0),
new SixLabors.Primitives.Point(image.Width, 0), new SixLabors.Primitives.Point(image.Width, 0),
GradientRepetitionMode.None, GradientRepetitionMode.None,
new ColorStop<TPixel>(0, NamedColors<TPixel>.Blue), new ColorStop(0, Color.Blue),
new ColorStop<TPixel>(1, NamedColors<TPixel>.Yellow)); new ColorStop(1, Color.Yellow));
image.Mutate(x => x.Fill(unicolorLinearGradientBrush)); image.Mutate(x => x.Fill(unicolorLinearGradientBrush));
}, },
@ -79,15 +79,15 @@ namespace SixLabors.ImageSharp.Tests.Drawing
TolerantComparer, TolerantComparer,
image => image =>
{ {
TPixel red = NamedColors<TPixel>.Red; Color red = Color.Red;
TPixel yellow = NamedColors<TPixel>.Yellow; Color yellow = Color.Yellow;
var unicolorLinearGradientBrush = new LinearGradientBrush<TPixel>( var unicolorLinearGradientBrush = new LinearGradientBrush(
new SixLabors.Primitives.Point(0, 0), new SixLabors.Primitives.Point(0, 0),
new SixLabors.Primitives.Point(image.Width, 0), new SixLabors.Primitives.Point(image.Width, 0),
GradientRepetitionMode.None, GradientRepetitionMode.None,
new ColorStop<TPixel>(0, red), new ColorStop(0, red),
new ColorStop<TPixel>(1, yellow)); new ColorStop(1, yellow));
image.Mutate(x => x.Fill(unicolorLinearGradientBrush)); image.Mutate(x => x.Fill(unicolorLinearGradientBrush));
}, },
@ -109,15 +109,15 @@ namespace SixLabors.ImageSharp.Tests.Drawing
TolerantComparer, TolerantComparer,
image => image =>
{ {
TPixel red = NamedColors<TPixel>.Red; Color red = Color.Red;
TPixel yellow = NamedColors<TPixel>.Yellow; Color yellow = Color.Yellow;
var unicolorLinearGradientBrush = new LinearGradientBrush<TPixel>( var unicolorLinearGradientBrush = new LinearGradientBrush(
new SixLabors.Primitives.Point(0, 0), new SixLabors.Primitives.Point(0, 0),
new SixLabors.Primitives.Point(image.Width / 10, 0), new SixLabors.Primitives.Point(image.Width / 10, 0),
repetitionMode, repetitionMode,
new ColorStop<TPixel>(0, red), new ColorStop(0, red),
new ColorStop<TPixel>(1, yellow)); new ColorStop(1, yellow));
image.Mutate(x => x.Fill(unicolorLinearGradientBrush)); image.Mutate(x => x.Fill(unicolorLinearGradientBrush));
}, },
@ -140,26 +140,26 @@ namespace SixLabors.ImageSharp.Tests.Drawing
// ensure the input data is valid // ensure the input data is valid
Assert.True(pattern.Length > 0); Assert.True(pattern.Length > 0);
TPixel black = NamedColors<TPixel>.Black; Color black = Color.Black;
TPixel white = NamedColors<TPixel>.White; Color white = Color.White;
// create the input pattern: 0, followed by each of the arguments twice, followed by 1.0 - toggling black and white. // create the input pattern: 0, followed by each of the arguments twice, followed by 1.0 - toggling black and white.
ColorStop<TPixel>[] colorStops = ColorStop[] colorStops =
Enumerable.Repeat(new ColorStop<TPixel>(0, black), 1) Enumerable.Repeat(new ColorStop(0, black), 1)
.Concat( .Concat(
pattern pattern
.SelectMany((f, index) => new[] .SelectMany((f, index) => new[]
{ {
new ColorStop<TPixel>(f, index % 2 == 0 ? black : white), new ColorStop(f, index % 2 == 0 ? black : white),
new ColorStop<TPixel>(f, index % 2 == 0 ? white : black) new ColorStop(f, index % 2 == 0 ? white : black)
})) }))
.Concat(Enumerable.Repeat(new ColorStop<TPixel>(1, pattern.Length % 2 == 0 ? black : white), 1)) .Concat(Enumerable.Repeat(new ColorStop(1, pattern.Length % 2 == 0 ? black : white), 1))
.ToArray(); .ToArray();
using (Image<TPixel> image = provider.GetImage()) using (Image<TPixel> image = provider.GetImage())
{ {
var unicolorLinearGradientBrush = var unicolorLinearGradientBrush =
new LinearGradientBrush<TPixel>( new LinearGradientBrush(
new SixLabors.Primitives.Point(0, 0), new SixLabors.Primitives.Point(0, 0),
new SixLabors.Primitives.Point(image.Width, 0), new SixLabors.Primitives.Point(image.Width, 0),
GradientRepetitionMode.None, GradientRepetitionMode.None,
@ -196,15 +196,15 @@ namespace SixLabors.ImageSharp.Tests.Drawing
provider.VerifyOperation( provider.VerifyOperation(
image => image =>
{ {
TPixel red = NamedColors<TPixel>.Red; Color red = Color.Red;
TPixel yellow = NamedColors<TPixel>.Yellow; Color yellow = Color.Yellow;
var unicolorLinearGradientBrush = new LinearGradientBrush<TPixel>( var unicolorLinearGradientBrush = new LinearGradientBrush(
new SixLabors.Primitives.Point(0, 0), new SixLabors.Primitives.Point(0, 0),
new SixLabors.Primitives.Point(0, image.Height), new SixLabors.Primitives.Point(0, image.Height),
GradientRepetitionMode.None, GradientRepetitionMode.None,
new ColorStop<TPixel>(0, red), new ColorStop(0, red),
new ColorStop<TPixel>(1, yellow)); new ColorStop(1, yellow));
image.Mutate(x => x.Fill(unicolorLinearGradientBrush)); image.Mutate(x => x.Fill(unicolorLinearGradientBrush));
@ -254,16 +254,16 @@ namespace SixLabors.ImageSharp.Tests.Drawing
int endX = image.Height - startX - 1; int endX = image.Height - startX - 1;
int endY = image.Width - startY - 1; int endY = image.Width - startY - 1;
TPixel red = NamedColors<TPixel>.Red; Color red = Color.Red;
TPixel yellow = NamedColors<TPixel>.Yellow; Color yellow = Color.Yellow;
var unicolorLinearGradientBrush = var unicolorLinearGradientBrush =
new LinearGradientBrush<TPixel>( new LinearGradientBrush(
new SixLabors.Primitives.Point(startX, startY), new SixLabors.Primitives.Point(startX, startY),
new SixLabors.Primitives.Point(endX, endY), new SixLabors.Primitives.Point(endX, endY),
GradientRepetitionMode.None, GradientRepetitionMode.None,
new ColorStop<TPixel>(0, red), new ColorStop(0, red),
new ColorStop<TPixel>(1, yellow)); new ColorStop(1, yellow));
image.Mutate(x => x.Fill(unicolorLinearGradientBrush)); image.Mutate(x => x.Fill(unicolorLinearGradientBrush));
image.DebugSave( image.DebugSave(
@ -310,22 +310,21 @@ namespace SixLabors.ImageSharp.Tests.Drawing
int[] stopColorCodes) int[] stopColorCodes)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
TPixel[] colors = Color[] colors =
{ {
NamedColors<TPixel>.Navy, NamedColors<TPixel>.LightGreen, NamedColors<TPixel>.Yellow, Color.Navy, Color.LightGreen, Color.Yellow,
NamedColors<TPixel>.Red Color.Red
}; };
var coloringVariant = new StringBuilder(); var coloringVariant = new StringBuilder();
var colorStops = new ColorStop<TPixel>[stopPositions.Length]; var colorStops = new ColorStop[stopPositions.Length];
for (int i = 0; i < stopPositions.Length; i++) for (int i = 0; i < stopPositions.Length; i++)
{ {
TPixel color = colors[stopColorCodes[i % colors.Length]]; Color color = colors[stopColorCodes[i % colors.Length]];
float position = stopPositions[i]; float position = stopPositions[i];
colorStops[i] = new ColorStop<TPixel>(position, color); colorStops[i] = new ColorStop(position, color);
Rgba32 rgba = default; Rgba32 rgba = color;
color.ToRgba32(ref rgba);
coloringVariant.AppendFormat(CultureInfo.InvariantCulture, "{0}@{1};", rgba.ToHex(), position); coloringVariant.AppendFormat(CultureInfo.InvariantCulture, "{0}@{1};", rgba.ToHex(), position);
} }
@ -334,7 +333,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
provider.VerifyOperation( provider.VerifyOperation(
image => image =>
{ {
var unicolorLinearGradientBrush = new LinearGradientBrush<TPixel>( var unicolorLinearGradientBrush = new LinearGradientBrush(
new SixLabors.Primitives.Point(startX, startY), new SixLabors.Primitives.Point(startX, startY),
new SixLabors.Primitives.Point(endX, endY), new SixLabors.Primitives.Point(endX, endY),
GradientRepetitionMode.None, GradientRepetitionMode.None,
@ -357,22 +356,21 @@ namespace SixLabors.ImageSharp.Tests.Drawing
int[] stopColorCodes) int[] stopColorCodes)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
TPixel[] colors = Color[] colors =
{ {
NamedColors<TPixel>.Black, NamedColors<TPixel>.Blue, NamedColors<TPixel>.Red, Color.Black, Color.Blue, Color.Red,
NamedColors<TPixel>.White, NamedColors<TPixel>.Lime Color.White, Color.Lime
}; };
var coloringVariant = new StringBuilder(); var coloringVariant = new StringBuilder();
var colorStops = new ColorStop<TPixel>[stopPositions.Length]; var colorStops = new ColorStop[stopPositions.Length];
for (int i = 0; i < stopPositions.Length; i++) for (int i = 0; i < stopPositions.Length; i++)
{ {
TPixel color = colors[stopColorCodes[i % colors.Length]]; Color color = colors[stopColorCodes[i % colors.Length]];
float position = stopPositions[i]; float position = stopPositions[i];
colorStops[i] = new ColorStop<TPixel>(position, color); colorStops[i] = new ColorStop(position, color);
Rgba32 rgba = default; Rgba32 rgba = color;
color.ToRgba32(ref rgba);
coloringVariant.AppendFormat(CultureInfo.InvariantCulture, "{0}@{1};", rgba.ToHex(), position); coloringVariant.AppendFormat(CultureInfo.InvariantCulture, "{0}@{1};", rgba.ToHex(), position);
} }
@ -381,7 +379,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
provider.VerifyOperation( provider.VerifyOperation(
image => image =>
{ {
var unicolorLinearGradientBrush = new LinearGradientBrush<TPixel>( var unicolorLinearGradientBrush = new LinearGradientBrush(
new SixLabors.Primitives.Point(startX, startY), new SixLabors.Primitives.Point(startX, startY),
new SixLabors.Primitives.Point(endX, endY), new SixLabors.Primitives.Point(endX, endY),
GradientRepetitionMode.None, GradientRepetitionMode.None,

2
tests/ImageSharp.Tests/Drawing/FillPatternBrushTests.cs

@ -14,7 +14,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{ {
public class FillPatternBrushTests public class FillPatternBrushTests
{ {
private void Test(string name, Rgba32 background, IBrush<Rgba32> brush, Rgba32[,] expectedPattern) private void Test(string name, Rgba32 background, IBrush brush, Rgba32[,] expectedPattern)
{ {
string path = TestEnvironment.CreateOutputDirectory("Drawing", "FillPatternBrushTests"); string path = TestEnvironment.CreateOutputDirectory("Drawing", "FillPatternBrushTests");
using (var image = new Image<Rgba32>(20, 20)) using (var image = new Image<Rgba32>(20, 20))

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

@ -36,7 +36,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
FormattableString outputDetails = $"{colorName}_A{alpha}{aa}"; FormattableString outputDetails = $"{colorName}_A{alpha}{aa}";
provider.RunValidatingProcessorTest( provider.RunValidatingProcessorTest(
c => c.FillPolygon(options, color.ToPixel<TPixel>(), simplePath), c => c.FillPolygon(options, color, simplePath),
outputDetails, outputDetails,
appendSourceFileOrDescription: false); appendSourceFileOrDescription: false);
} }
@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
Color color = Color.LightGreen; Color color = Color.LightGreen;
provider.RunValidatingProcessorTest( provider.RunValidatingProcessorTest(
c => c.FillPolygon(color.ToPixel<TPixel>(), points), c => c.FillPolygon(color, points),
appendSourceFileOrDescription: false, appendSourceFileOrDescription: false,
appendPixelTypeToFileName: false); appendPixelTypeToFileName: false);
} }
@ -75,7 +75,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
}; };
Color color = Color.Yellow; Color color = Color.Yellow;
var brush = Brushes.Horizontal(color.ToPixel<TPixel>()); var brush = Brushes.Horizontal(color);
provider.RunValidatingProcessorTest( provider.RunValidatingProcessorTest(
c => c.FillPolygon(brush, simplePath), c => c.FillPolygon(brush, simplePath),
@ -113,7 +113,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
Color color = Color.White; Color color = Color.White;
provider.RunValidatingProcessorTest( provider.RunValidatingProcessorTest(
c => c.Fill(color.ToPixel<TPixel>(), polygon), c => c.Fill(color, polygon),
appendSourceFileOrDescription: false); appendSourceFileOrDescription: false);
} }
@ -132,7 +132,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
FormattableString testOutput = $"V({vertices})_R({radius})_Ang({angleDeg})"; FormattableString testOutput = $"V({vertices})_R({radius})_Ang({angleDeg})";
provider.RunValidatingProcessorTest( provider.RunValidatingProcessorTest(
c => c.Fill(color.ToPixel<TPixel>(), polygon), c => c.Fill(color, polygon),
testOutput, testOutput,
appendSourceFileOrDescription: false, appendSourceFileOrDescription: false,
appendPixelTypeToFileName: false); appendPixelTypeToFileName: false);
@ -147,7 +147,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
Color color = Color.Azure; Color color = Color.Azure;
provider.RunValidatingProcessorTest( provider.RunValidatingProcessorTest(
c => c.Fill(color.ToPixel<TPixel>(), polygon), c => c.Fill(color, polygon),
appendSourceFileOrDescription: false, appendSourceFileOrDescription: false,
appendPixelTypeToFileName: false); appendPixelTypeToFileName: false);
} }

14
tests/ImageSharp.Tests/Drawing/FillRadialGradientBrushTests.cs

@ -21,15 +21,15 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{ {
using (Image<TPixel> image = provider.GetImage()) using (Image<TPixel> image = provider.GetImage())
{ {
TPixel red = NamedColors<TPixel>.Red; Color red = Color.Red;
var unicolorRadialGradientBrush = var unicolorRadialGradientBrush =
new RadialGradientBrush<TPixel>( new RadialGradientBrush(
new SixLabors.Primitives.Point(0, 0), new SixLabors.Primitives.Point(0, 0),
100, 100,
GradientRepetitionMode.None, GradientRepetitionMode.None,
new ColorStop<TPixel>(0, red), new ColorStop(0, red),
new ColorStop<TPixel>(1, red)); new ColorStop(1, red));
image.Mutate(x => x.Fill(unicolorRadialGradientBrush)); image.Mutate(x => x.Fill(unicolorRadialGradientBrush));
@ -56,12 +56,12 @@ namespace SixLabors.ImageSharp.Tests.Drawing
TolerantComparer, TolerantComparer,
image => image =>
{ {
var brush = new RadialGradientBrush<TPixel>( var brush = new RadialGradientBrush(
new SixLabors.Primitives.Point(centerX, centerY), new SixLabors.Primitives.Point(centerX, centerY),
image.Width / 2f, image.Width / 2f,
GradientRepetitionMode.None, GradientRepetitionMode.None,
new ColorStop<TPixel>(0, NamedColors<TPixel>.Red), new ColorStop(0, Color.Red),
new ColorStop<TPixel>(1, NamedColors<TPixel>.Yellow)); new ColorStop(1, Color.Yellow));
image.Mutate(x => x.Fill(brush)); image.Mutate(x => x.Fill(brush));
}, },

11
tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs

@ -8,6 +8,7 @@ using System;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Primitives; using SixLabors.ImageSharp.Primitives;
using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.Primitives; using SixLabors.Primitives;
using Xunit; using Xunit;
using SixLabors.ImageSharp.Processing.Processors.Drawing; using SixLabors.ImageSharp.Processing.Processors.Drawing;
@ -30,14 +31,14 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{ {
var bounds = new Rectangle(0, 0, 1, 1); var bounds = new Rectangle(0, 0, 1, 1);
var brush = new Mock<IBrush<Rgba32>>(); var brush = new Mock<IBrush>();
var region = new MockRegion2(bounds); var region = new MockRegion2(bounds);
var options = new GraphicsOptions(antialias) var options = new GraphicsOptions(antialias)
{ {
AntialiasSubpixelDepth = 1 AntialiasSubpixelDepth = 1
}; };
var processor = new FillRegionProcessor<Rgba32>(brush.Object, region, options); var processor = new FillRegionProcessor(brush.Object, region, options);
var img = new Image<Rgba32>(1, 1); var img = new Image<Rgba32>(1, 1);
processor.Apply(img, bounds); processor.Apply(img, bounds);
@ -48,9 +49,9 @@ namespace SixLabors.ImageSharp.Tests.Drawing
public void FillOffCanvas() public void FillOffCanvas()
{ {
var bounds = new Rectangle(-100, -10, 10, 10); var bounds = new Rectangle(-100, -10, 10, 10);
var brush = new Mock<IBrush<Rgba32>>(); var brush = new Mock<IBrush>();
var options = new GraphicsOptions(true); var options = new GraphicsOptions(true);
var processor = new FillRegionProcessor<Rgba32>(brush.Object, new MockRegion1(), options); var processor = new FillRegionProcessor(brush.Object, new MockRegion1(), options);
var img = new Image<Rgba32>(10, 10); var img = new Image<Rgba32>(10, 10);
processor.Apply(img, bounds); processor.Apply(img, bounds);
} }
@ -61,7 +62,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
using (var img = new Image<Rgba32>(10, 10)) using (var img = new Image<Rgba32>(10, 10))
{ {
img.Mutate(x => x.DrawLines(new Pen<Rgba32>(Rgba32.Black, 10), new SixLabors.Primitives.PointF[] { img.Mutate(x => x.DrawLines(new Pen(Rgba32.Black, 10), new SixLabors.Primitives.PointF[] {
new Vector2(-10, 5), new Vector2(-10, 5),
new Vector2(20, 5), new Vector2(20, 5),
})); }));

22
tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs

@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{ {
using (Image<TPixel> image = provider.GetImage()) using (Image<TPixel> image = provider.GetImage())
{ {
TPixel color = NamedColors<TPixel>.HotPink; Color color = Color.HotPink;
image.Mutate(c => c.Fill(color)); image.Mutate(c => c.Fill(color));
image.DebugSave(provider, appendPixelTypeToFileName: false); image.DebugSave(provider, appendPixelTypeToFileName: false);
@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{ {
using (Image<TPixel> image = provider.GetImage()) using (Image<TPixel> image = provider.GetImage())
{ {
TPixel color = NamedColors<TPixel>.HotPink; Color color = Color.HotPink;
image.Mutate(c => c.Fill(color)); image.Mutate(c => c.Fill(color));
image.DebugSave(provider, appendSourceFileOrDescription: false); image.DebugSave(provider, appendSourceFileOrDescription: false);
@ -63,7 +63,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{ {
using (Image<TPixel> image = provider.GetImage()) using (Image<TPixel> image = provider.GetImage())
{ {
TPixel color = TestUtils.GetPixelOfNamedColor<TPixel>(newColorName); Color color = TestUtils.GetColorByName(newColorName);
image.Mutate(c => c.Fill(color)); image.Mutate(c => c.Fill(color));
image.DebugSave( image.DebugSave(
@ -83,7 +83,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{ {
FormattableString testDetails = $"(x{x0},y{y0},w{w},h{h})"; FormattableString testDetails = $"(x{x0},y{y0},w{w},h{h})";
var region = new RectangleF(x0, y0, w, h); var region = new RectangleF(x0, y0, w, h);
TPixel color = TestUtils.GetPixelOfNamedColor<TPixel>("Blue"); Color color = TestUtils.GetColorByName("Blue");
provider.RunValidatingProcessorTest(c => c.Fill(color, region), testDetails, ImageComparer.Exact); provider.RunValidatingProcessorTest(c => c.Fill(color, region), testDetails, ImageComparer.Exact);
} }
@ -101,7 +101,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{ {
FormattableString testDetails = $"(x{x0},y{y0},w{w},h{h})"; FormattableString testDetails = $"(x{x0},y{y0},w{w},h{h})";
var region = new RectangleF(x0, y0, w, h); var region = new RectangleF(x0, y0, w, h);
TPixel color = TestUtils.GetPixelOfNamedColor<TPixel>("Blue"); Color color = TestUtils.GetColorByName("Blue");
provider.RunValidatingProcessorTestOnWrappedMemoryImage( provider.RunValidatingProcessorTestOnWrappedMemoryImage(
c => c.Fill(color, region), c => c.Fill(color, region),
@ -150,11 +150,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
float blendPercentage) float blendPercentage)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
var vec = TestUtils.GetPixelOfNamedColor<RgbaVector>(newColorName).ToVector4(); Color fillColor = TestUtils.GetColorByName(newColorName).WithAlpha(alpha);
vec.W = alpha;
TPixel fillColor = default;
fillColor.FromVector4(vec);
using (Image<TPixel> image = provider.GetImage()) using (Image<TPixel> image = provider.GetImage())
{ {
@ -169,11 +165,11 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{ {
var region = new ShapeRegion(new RectangularPolygon(0, 0, 16, 16)); var region = new ShapeRegion(new RectangularPolygon(0, 0, 16, 16));
image.Mutate(c => c.Fill(options, new SolidBrush<TPixel>(fillColor), region)); image.Mutate(c => c.Fill(options, new SolidBrush(fillColor), region));
} }
else else
{ {
image.Mutate(c => c.Fill(options, new SolidBrush<TPixel>(fillColor))); image.Mutate(c => c.Fill(options, new SolidBrush(fillColor)));
} }
var testOutputDetails = new var testOutputDetails = new
@ -194,7 +190,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
PixelBlender<TPixel> blender = PixelOperations<TPixel>.Instance.GetPixelBlender( PixelBlender<TPixel> blender = PixelOperations<TPixel>.Instance.GetPixelBlender(
blenderMode, blenderMode,
PixelAlphaCompositionMode.SrcOver); PixelAlphaCompositionMode.SrcOver);
TPixel expectedPixel = blender.Blend(bgColor, fillColor, blendPercentage); TPixel expectedPixel = blender.Blend(bgColor, fillColor.ToPixel<TPixel>(), blendPercentage);
image.ComparePixelBufferTo(expectedPixel); image.ComparePixelBufferTo(expectedPixel);
} }

16
tests/ImageSharp.Tests/Drawing/Paths/DrawPathCollection.cs

@ -14,8 +14,8 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
public class DrawPathCollection : BaseImageOperationsExtensionTest public class DrawPathCollection : BaseImageOperationsExtensionTest
{ {
GraphicsOptions noneDefault = new GraphicsOptions(); GraphicsOptions noneDefault = new GraphicsOptions();
Rgba32 color = Rgba32.HotPink; Color color = Color.HotPink;
Pen<Rgba32> pen = Pens.Solid(Rgba32.HotPink, 1); Pen pen = Pens.Solid(Rgba32.HotPink, 1);
IPath path1 = new Path(new LinearLineSegment(new SixLabors.Primitives.PointF[] { IPath path1 = new Path(new LinearLineSegment(new SixLabors.Primitives.PointF[] {
new Vector2(10,10), new Vector2(10,10),
new Vector2(20,10), new Vector2(20,10),
@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
FillRegionProcessor<Rgba32> processor = this.Verify<FillRegionProcessor<Rgba32>>(i); FillRegionProcessor processor = this.Verify<FillRegionProcessor>(i);
Assert.Equal(GraphicsOptions.Default, processor.Options); Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -63,7 +63,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
FillRegionProcessor<Rgba32> processor = this.Verify<FillRegionProcessor<Rgba32>>(i); FillRegionProcessor processor = this.Verify<FillRegionProcessor>(i);
Assert.Equal(this.noneDefault, processor.Options); Assert.Equal(this.noneDefault, processor.Options);
@ -81,14 +81,14 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
FillRegionProcessor<Rgba32> processor = this.Verify<FillRegionProcessor<Rgba32>>(i); FillRegionProcessor processor = this.Verify<FillRegionProcessor>(i);
Assert.Equal(GraphicsOptions.Default, processor.Options); Assert.Equal(GraphicsOptions.Default, processor.Options);
ShapePath region = Assert.IsType<ShapePath>(processor.Region); ShapePath region = Assert.IsType<ShapePath>(processor.Region);
ComplexPolygon polygon = Assert.IsType<ComplexPolygon>(region.Shape); ComplexPolygon polygon = Assert.IsType<ComplexPolygon>(region.Shape);
SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(processor.Brush); SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
Assert.Equal(this.color, brush.Color); Assert.Equal(this.color, brush.Color);
} }
} }
@ -100,14 +100,14 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
FillRegionProcessor<Rgba32> processor = this.Verify<FillRegionProcessor<Rgba32>>(i); FillRegionProcessor processor = this.Verify<FillRegionProcessor>(i);
Assert.Equal(this.noneDefault, processor.Options); Assert.Equal(this.noneDefault, processor.Options);
ShapePath region = Assert.IsType<ShapePath>(processor.Region); ShapePath region = Assert.IsType<ShapePath>(processor.Region);
ComplexPolygon polygon = Assert.IsType<ComplexPolygon>(region.Shape); ComplexPolygon polygon = Assert.IsType<ComplexPolygon>(region.Shape);
SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(processor.Brush); SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
Assert.Equal(this.color, brush.Color); Assert.Equal(this.color, brush.Color);
} }
} }

16
tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs

@ -14,8 +14,8 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
public class FillPath : BaseImageOperationsExtensionTest public class FillPath : BaseImageOperationsExtensionTest
{ {
GraphicsOptions noneDefault = new GraphicsOptions(); GraphicsOptions noneDefault = new GraphicsOptions();
Rgba32 color = Rgba32.HotPink; Color color = Color.HotPink;
SolidBrush<Rgba32> brush = Brushes.Solid(Rgba32.HotPink); SolidBrush brush = Brushes.Solid(Rgba32.HotPink);
IPath path = new Path(new LinearLineSegment(new SixLabors.Primitives.PointF[] { IPath path = new Path(new LinearLineSegment(new SixLabors.Primitives.PointF[] {
new Vector2(10,10), new Vector2(10,10),
new Vector2(20,10), new Vector2(20,10),
@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
public void CorrectlySetsBrushAndPath() public void CorrectlySetsBrushAndPath()
{ {
this.operations.Fill(this.brush, this.path); this.operations.Fill(this.brush, this.path);
var processor = this.Verify<FillRegionProcessor<Rgba32>>(); var processor = this.Verify<FillRegionProcessor>();
Assert.Equal(GraphicsOptions.Default, processor.Options); Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
public void CorrectlySetsBrushPathOptions() public void CorrectlySetsBrushPathOptions()
{ {
this.operations.Fill(this.noneDefault, this.brush, this.path); this.operations.Fill(this.noneDefault, this.brush, this.path);
var processor = this.Verify<FillRegionProcessor<Rgba32>>(); var processor = this.Verify<FillRegionProcessor>();
Assert.Equal(this.noneDefault, processor.Options); Assert.Equal(this.noneDefault, processor.Options);
@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
public void CorrectlySetsColorAndPath() public void CorrectlySetsColorAndPath()
{ {
this.operations.Fill(this.color, this.path); this.operations.Fill(this.color, this.path);
var processor = this.Verify<FillRegionProcessor<Rgba32>>(); var processor = this.Verify<FillRegionProcessor>();
Assert.Equal(GraphicsOptions.Default, processor.Options); Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
Polygon polygon = Assert.IsType<Polygon>(region.Shape); Polygon polygon = Assert.IsType<Polygon>(region.Shape);
LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]); LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(processor.Brush); SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
Assert.Equal(this.color, brush.Color); Assert.Equal(this.color, brush.Color);
} }
@ -75,7 +75,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
public void CorrectlySetsColorPathAndOptions() public void CorrectlySetsColorPathAndOptions()
{ {
this.operations.Fill(this.noneDefault, this.color, this.path); this.operations.Fill(this.noneDefault, this.color, this.path);
var processor = this.Verify<FillRegionProcessor<Rgba32>>(); var processor = this.Verify<FillRegionProcessor>();
Assert.Equal(this.noneDefault, processor.Options); Assert.Equal(this.noneDefault, processor.Options);
@ -83,7 +83,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
Polygon polygon = Assert.IsType<Polygon>(region.Shape); Polygon polygon = Assert.IsType<Polygon>(region.Shape);
LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]); LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(processor.Brush); SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
Assert.Equal(this.color, brush.Color); Assert.Equal(this.color, brush.Color);
} }
} }

16
tests/ImageSharp.Tests/Drawing/Paths/FillPathCollection.cs

@ -14,8 +14,8 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
public class FillPathCollection : BaseImageOperationsExtensionTest public class FillPathCollection : BaseImageOperationsExtensionTest
{ {
GraphicsOptions noneDefault = new GraphicsOptions(); GraphicsOptions noneDefault = new GraphicsOptions();
Rgba32 color = Rgba32.HotPink; Color color = Color.HotPink;
SolidBrush<Rgba32> brush = Brushes.Solid(Rgba32.HotPink); SolidBrush brush = Brushes.Solid(Rgba32.HotPink);
IPath path1 = new Path(new LinearLineSegment(new SixLabors.Primitives.PointF[] { IPath path1 = new Path(new LinearLineSegment(new SixLabors.Primitives.PointF[] {
new Vector2(10,10), new Vector2(10,10),
new Vector2(20,10), new Vector2(20,10),
@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
FillRegionProcessor<Rgba32> processor = this.Verify<FillRegionProcessor<Rgba32>>(i); FillRegionProcessor processor = this.Verify<FillRegionProcessor>(i);
Assert.Equal(GraphicsOptions.Default, processor.Options); Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -64,7 +64,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
FillRegionProcessor<Rgba32> processor = this.Verify<FillRegionProcessor<Rgba32>>(i); FillRegionProcessor processor = this.Verify<FillRegionProcessor>(i);
Assert.Equal(this.noneDefault, processor.Options); Assert.Equal(this.noneDefault, processor.Options);
@ -83,7 +83,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
FillRegionProcessor<Rgba32> processor = this.Verify<FillRegionProcessor<Rgba32>>(i); FillRegionProcessor processor = this.Verify<FillRegionProcessor>(i);
Assert.Equal(GraphicsOptions.Default, processor.Options); Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -91,7 +91,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
Polygon polygon = Assert.IsType<Polygon>(region.Shape); Polygon polygon = Assert.IsType<Polygon>(region.Shape);
LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]); LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(processor.Brush); SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
Assert.Equal(this.color, brush.Color); Assert.Equal(this.color, brush.Color);
} }
} }
@ -103,7 +103,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
FillRegionProcessor<Rgba32> processor = this.Verify<FillRegionProcessor<Rgba32>>(i); FillRegionProcessor processor = this.Verify<FillRegionProcessor>(i);
Assert.Equal(this.noneDefault, processor.Options); Assert.Equal(this.noneDefault, processor.Options);
@ -111,7 +111,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
Polygon polygon = Assert.IsType<Polygon>(region.Shape); Polygon polygon = Assert.IsType<Polygon>(region.Shape);
LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]); LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(processor.Brush); SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
Assert.Equal(this.color, brush.Color); Assert.Equal(this.color, brush.Color);
} }
} }

16
tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs

@ -14,8 +14,8 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
public class FillPolygon : BaseImageOperationsExtensionTest public class FillPolygon : BaseImageOperationsExtensionTest
{ {
GraphicsOptions noneDefault = new GraphicsOptions(); GraphicsOptions noneDefault = new GraphicsOptions();
Rgba32 color = Rgba32.HotPink; Color color = Color.HotPink;
SolidBrush<Rgba32> brush = Brushes.Solid(Rgba32.HotPink); SolidBrush brush = Brushes.Solid(Rgba32.HotPink);
SixLabors.Primitives.PointF[] path = { SixLabors.Primitives.PointF[] path = {
new Vector2(10,10), new Vector2(10,10),
new Vector2(20,10), new Vector2(20,10),
@ -29,7 +29,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
{ {
this.operations.FillPolygon(this.brush, this.path); this.operations.FillPolygon(this.brush, this.path);
FillRegionProcessor<Rgba32> processor = this.Verify<FillRegionProcessor<Rgba32>>(); FillRegionProcessor processor = this.Verify<FillRegionProcessor>();
Assert.Equal(GraphicsOptions.Default, processor.Options); Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
public void CorrectlySetsBrushPathAndOptions() public void CorrectlySetsBrushPathAndOptions()
{ {
this.operations.FillPolygon(this.noneDefault, this.brush, this.path); this.operations.FillPolygon(this.noneDefault, this.brush, this.path);
FillRegionProcessor<Rgba32> processor = this.Verify<FillRegionProcessor<Rgba32>>(); FillRegionProcessor processor = this.Verify<FillRegionProcessor>();
Assert.Equal(this.noneDefault, processor.Options); Assert.Equal(this.noneDefault, processor.Options);
@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
public void CorrectlySetsColorAndPath() public void CorrectlySetsColorAndPath()
{ {
this.operations.FillPolygon(this.color, this.path); this.operations.FillPolygon(this.color, this.path);
FillRegionProcessor<Rgba32> processor = this.Verify<FillRegionProcessor<Rgba32>>(); FillRegionProcessor processor = this.Verify<FillRegionProcessor>();
Assert.Equal(GraphicsOptions.Default, processor.Options); Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -68,7 +68,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
Polygon polygon = Assert.IsType<Polygon>(region.Shape); Polygon polygon = Assert.IsType<Polygon>(region.Shape);
LinearLineSegment segemnt = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]); LinearLineSegment segemnt = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(processor.Brush); SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
Assert.Equal(this.color, brush.Color); Assert.Equal(this.color, brush.Color);
} }
@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
public void CorrectlySetsColorPathAndOptions() public void CorrectlySetsColorPathAndOptions()
{ {
this.operations.FillPolygon(this.noneDefault, this.color, this.path); this.operations.FillPolygon(this.noneDefault, this.color, this.path);
FillRegionProcessor<Rgba32> processor = this.Verify<FillRegionProcessor<Rgba32>>(); FillRegionProcessor processor = this.Verify<FillRegionProcessor>();
Assert.Equal(this.noneDefault, processor.Options); Assert.Equal(this.noneDefault, processor.Options);
@ -84,7 +84,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
Polygon polygon = Assert.IsType<Polygon>(region.Shape); Polygon polygon = Assert.IsType<Polygon>(region.Shape);
LinearLineSegment segemnt = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]); LinearLineSegment segemnt = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(processor.Brush); SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
Assert.Equal(this.color, brush.Color); Assert.Equal(this.color, brush.Color);
} }
} }

16
tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs

@ -12,15 +12,15 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
public class FillRectangle : BaseImageOperationsExtensionTest public class FillRectangle : BaseImageOperationsExtensionTest
{ {
GraphicsOptions noneDefault = new GraphicsOptions(); GraphicsOptions noneDefault = new GraphicsOptions();
Rgba32 color = Rgba32.HotPink; Color color = Color.HotPink;
SolidBrush<Rgba32> brush = Brushes.Solid(Rgba32.HotPink); SolidBrush brush = Brushes.Solid(Rgba32.HotPink);
SixLabors.Primitives.Rectangle rectangle = new SixLabors.Primitives.Rectangle(10, 10, 77, 76); SixLabors.Primitives.Rectangle rectangle = new SixLabors.Primitives.Rectangle(10, 10, 77, 76);
[Fact] [Fact]
public void CorrectlySetsBrushAndRectangle() public void CorrectlySetsBrushAndRectangle()
{ {
this.operations.Fill(this.brush, this.rectangle); this.operations.Fill(this.brush, this.rectangle);
FillRegionProcessor<Rgba32> processor = this.Verify<FillRegionProcessor<Rgba32>>(); FillRegionProcessor processor = this.Verify<FillRegionProcessor>();
Assert.Equal(GraphicsOptions.Default, processor.Options); Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -38,7 +38,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
public void CorrectlySetsBrushRectangleAndOptions() public void CorrectlySetsBrushRectangleAndOptions()
{ {
this.operations.Fill(this.noneDefault, this.brush, this.rectangle); this.operations.Fill(this.noneDefault, this.brush, this.rectangle);
FillRegionProcessor<Rgba32> processor = this.Verify<FillRegionProcessor<Rgba32>>(); FillRegionProcessor processor = this.Verify<FillRegionProcessor>();
Assert.Equal(this.noneDefault, processor.Options); Assert.Equal(this.noneDefault, processor.Options);
@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
public void CorrectlySetsColorAndRectangle() public void CorrectlySetsColorAndRectangle()
{ {
this.operations.Fill(this.color, this.rectangle); this.operations.Fill(this.color, this.rectangle);
FillRegionProcessor<Rgba32> processor = this.Verify<FillRegionProcessor<Rgba32>>(); FillRegionProcessor processor = this.Verify<FillRegionProcessor>();
Assert.Equal(GraphicsOptions.Default, processor.Options); Assert.Equal(GraphicsOptions.Default, processor.Options);
@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
Assert.Equal(rect.Size.Width, this.rectangle.Width); Assert.Equal(rect.Size.Width, this.rectangle.Width);
Assert.Equal(rect.Size.Height, this.rectangle.Height); Assert.Equal(rect.Size.Height, this.rectangle.Height);
SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(processor.Brush); SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
Assert.Equal(this.color, brush.Color); Assert.Equal(this.color, brush.Color);
} }
@ -75,7 +75,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
public void CorrectlySetsColorRectangleAndOptions() public void CorrectlySetsColorRectangleAndOptions()
{ {
this.operations.Fill(this.noneDefault, this.color, this.rectangle); this.operations.Fill(this.noneDefault, this.color, this.rectangle);
FillRegionProcessor<Rgba32> processor = this.Verify<FillRegionProcessor<Rgba32>>(); FillRegionProcessor processor = this.Verify<FillRegionProcessor>();
Assert.Equal(this.noneDefault, processor.Options); Assert.Equal(this.noneDefault, processor.Options);
@ -86,7 +86,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
Assert.Equal(rect.Size.Width, this.rectangle.Width); Assert.Equal(rect.Size.Width, this.rectangle.Width);
Assert.Equal(rect.Size.Height, this.rectangle.Height); Assert.Equal(rect.Size.Height, this.rectangle.Height);
SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(processor.Brush); SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
Assert.Equal(this.color, brush.Color); Assert.Equal(this.color, brush.Color);
} }
} }

4
tests/ImageSharp.Tests/Drawing/RecolorImageTests.cs

@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{ {
Color sourceColor = TestUtils.GetColorByName(sourceColorName); Color sourceColor = TestUtils.GetColorByName(sourceColorName);
Color targetColor = TestUtils.GetColorByName(targetColorName); Color targetColor = TestUtils.GetColorByName(targetColorName);
var brush = new RecolorBrush<TPixel>(sourceColor.ToPixel<TPixel>(), targetColor.ToPixel<TPixel>(), threshold); var brush = new RecolorBrush(sourceColor, targetColor, threshold);
FormattableString testInfo = $"{sourceColorName}-{targetColorName}-{threshold}"; FormattableString testInfo = $"{sourceColorName}-{targetColorName}-{threshold}";
provider.RunValidatingProcessorTest(x => x.Fill(brush), testInfo); provider.RunValidatingProcessorTest(x => x.Fill(brush), testInfo);
@ -38,7 +38,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{ {
Color sourceColor = TestUtils.GetColorByName(sourceColorName); Color sourceColor = TestUtils.GetColorByName(sourceColorName);
Color targetColor = TestUtils.GetColorByName(targetColorName); Color targetColor = TestUtils.GetColorByName(targetColorName);
var brush = new RecolorBrush<TPixel>(sourceColor.ToPixel<TPixel>(), targetColor.ToPixel<TPixel>(), threshold); var brush = new RecolorBrush(sourceColor, targetColor, threshold);
FormattableString testInfo = $"{sourceColorName}-{targetColorName}-{threshold}"; FormattableString testInfo = $"{sourceColorName}-{targetColorName}-{threshold}";
provider.RunValidatingProcessorTest(x => provider.RunValidatingProcessorTest(x =>

2
tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs

@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
using (Image<TPixel> image = provider.GetImage()) using (Image<TPixel> image = provider.GetImage())
{ {
image.Mutate(x => x.BackgroundColor(blue)); image.Mutate(x => x.BackgroundColor(blue));
image.Mutate(x => x.Fill(hotPink.ToPixel<TPixel>(), new Polygon(new CubicBezierLineSegment(simplePath)))); image.Mutate(x => x.Fill(hotPink, new Polygon(new CubicBezierLineSegment(simplePath))));
image.DebugSave(provider); image.DebugSave(provider);
image.CompareToReferenceOutput(provider); image.CompareToReferenceOutput(provider);
} }

26
tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs

@ -43,11 +43,11 @@ namespace SixLabors.ImageSharp.Tests.Drawing
int scaleY = img.Height / 100; int scaleY = img.Height / 100;
img.Mutate( img.Mutate(
x => x.Fill( x => x.Fill(
NamedColors<TPixel>.DarkBlue, Color.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) { ColorBlendingMode = blending, AlphaCompositionMode=composition }, .Fill(new GraphicsOptions(true) { ColorBlendingMode = blending, AlphaCompositionMode=composition },
NamedColors<TPixel>.HotPink, Color.HotPink,
new Rectangle(20 * scaleX, 0 * scaleY, 30 * scaleX, 100 * scaleY)) new Rectangle(20 * scaleX, 0 * scaleY, 30 * scaleX, 100 * scaleY))
); );
@ -69,17 +69,17 @@ namespace SixLabors.ImageSharp.Tests.Drawing
int scaleY = img.Height / 100; int scaleY = img.Height / 100;
img.Mutate( img.Mutate(
x => x.Fill( x => x.Fill(
NamedColors<TPixel>.DarkBlue, Color.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) { ColorBlendingMode = blending, AlphaCompositionMode = composition }, new GraphicsOptions(true) { ColorBlendingMode = blending, AlphaCompositionMode = composition },
NamedColors<TPixel>.HotPink, Color.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) { ColorBlendingMode = blending, AlphaCompositionMode = composition }, new GraphicsOptions(true) { ColorBlendingMode = blending, AlphaCompositionMode = composition },
NamedColors<TPixel>.Transparent, Color.Transparent,
new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY)) new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY))
); );
@ -101,22 +101,20 @@ namespace SixLabors.ImageSharp.Tests.Drawing
int scaleY = (img.Height / 100); int scaleY = (img.Height / 100);
img.Mutate( img.Mutate(
x => x.Fill( x => x.Fill(
NamedColors<TPixel>.DarkBlue, Color.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) { ColorBlendingMode = blending, AlphaCompositionMode = composition }, new GraphicsOptions(true) { ColorBlendingMode = blending, AlphaCompositionMode = composition },
NamedColors<TPixel>.HotPink, Color.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();
c.W *= 0.5f; var transparentRed = Color.Red.WithAlpha(0.5f);
var pixel = default(TPixel);
pixel.FromVector4(c);
img.Mutate( img.Mutate(
x => x.Fill( x => x.Fill(
new GraphicsOptions(true) { ColorBlendingMode = blending, AlphaCompositionMode = composition }, new GraphicsOptions(true) { ColorBlendingMode = blending, AlphaCompositionMode = composition },
pixel, transparentRed,
new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY)) new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY))
); );
@ -139,12 +137,12 @@ namespace SixLabors.ImageSharp.Tests.Drawing
dstImg.Mutate( dstImg.Mutate(
x => x.Fill( x => x.Fill(
NamedColors<TPixel>.DarkBlue, Color.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, Color.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(

70
tests/ImageSharp.Tests/Drawing/Text/DrawText.cs

@ -14,9 +14,9 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
{ {
public class DrawText : BaseImageOperationsExtensionTest public class DrawText : BaseImageOperationsExtensionTest
{ {
Rgba32 color = Rgba32.HotPink; Rgba32 color = Color.HotPink;
SolidBrush<Rgba32> brush = Brushes.Solid(Rgba32.HotPink); SolidBrush brush = Brushes.Solid(Color.HotPink);
IPath path = new SixLabors.Shapes.Path( IPath path = new SixLabors.Shapes.Path(
new LinearLineSegment( new LinearLineSegment(
@ -39,57 +39,57 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
new TextGraphicsOptions(true), new TextGraphicsOptions(true),
"123", "123",
this.Font, this.Font,
Brushes.Solid(Rgba32.Red), Brushes.Solid(Color.Red),
null, null,
Vector2.Zero); Vector2.Zero);
this.Verify<DrawTextProcessor<Rgba32>>(0); this.Verify<DrawTextProcessor>(0);
} }
[Fact] [Fact]
public void FillsForEachACharachterWhenBrushSetAndNotPenDefaultOptions() public void FillsForEachACharachterWhenBrushSetAndNotPenDefaultOptions()
{ {
this.operations.DrawText("123", this.Font, Brushes.Solid(Rgba32.Red), null, Vector2.Zero); this.operations.DrawText("123", this.Font, Brushes.Solid(Color.Red), null, Vector2.Zero);
this.Verify<DrawTextProcessor<Rgba32>>(0); this.Verify<DrawTextProcessor>(0);
} }
[Fact] [Fact]
public void FillsForEachACharachterWhenBrushSet() public void FillsForEachACharachterWhenBrushSet()
{ {
this.operations.DrawText(new TextGraphicsOptions(true), "123", this.Font, Brushes.Solid(Rgba32.Red), Vector2.Zero); this.operations.DrawText(new TextGraphicsOptions(true), "123", this.Font, Brushes.Solid(Color.Red), Vector2.Zero);
this.Verify<DrawTextProcessor<Rgba32>>(0); this.Verify<DrawTextProcessor>(0);
} }
[Fact] [Fact]
public void FillsForEachACharachterWhenBrushSetDefaultOptions() public void FillsForEachACharachterWhenBrushSetDefaultOptions()
{ {
this.operations.DrawText("123", this.Font, Brushes.Solid(Rgba32.Red), Vector2.Zero); this.operations.DrawText("123", this.Font, Brushes.Solid(Color.Red), Vector2.Zero);
this.Verify<DrawTextProcessor<Rgba32>>(0); this.Verify<DrawTextProcessor>(0);
} }
[Fact] [Fact]
public void FillsForEachACharachterWhenColorSet() public void FillsForEachACharachterWhenColorSet()
{ {
this.operations.DrawText(new TextGraphicsOptions(true), "123", this.Font, Rgba32.Red, Vector2.Zero); this.operations.DrawText(new TextGraphicsOptions(true), "123", this.Font, Color.Red, Vector2.Zero);
var processor = this.Verify<DrawTextProcessor<Rgba32>>(0); var processor = this.Verify<DrawTextProcessor>(0);
SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(processor.Brush); SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
Assert.Equal(Rgba32.Red, brush.Color); Assert.Equal(Color.Red, brush.Color);
} }
[Fact] [Fact]
public void FillsForEachACharachterWhenColorSetDefaultOptions() public void FillsForEachACharachterWhenColorSetDefaultOptions()
{ {
this.operations.DrawText("123", this.Font, Rgba32.Red, Vector2.Zero); this.operations.DrawText("123", this.Font, Color.Red, Vector2.Zero);
var processor = this.Verify<DrawTextProcessor<Rgba32>>(0); var processor = this.Verify<DrawTextProcessor>(0);
SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(processor.Brush); SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
Assert.Equal(Rgba32.Red, brush.Color); Assert.Equal(Color.Red, brush.Color);
} }
[Fact] [Fact]
@ -100,39 +100,39 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
"123", "123",
this.Font, this.Font,
null, null,
Pens.Dash(Rgba32.Red, 1), Pens.Dash(Color.Red, 1),
Vector2.Zero); Vector2.Zero);
var processor = this.Verify<DrawTextProcessor<Rgba32>>(0); var processor = this.Verify<DrawTextProcessor>(0);
} }
[Fact] [Fact]
public void DrawForEachACharachterWhenPenSetAndNotBrushDefaultOptions() public void DrawForEachACharachterWhenPenSetAndNotBrushDefaultOptions()
{ {
this.operations.DrawText("123", this.Font, null, Pens.Dash(Rgba32.Red, 1), Vector2.Zero); this.operations.DrawText("123", this.Font, null, Pens.Dash(Color.Red, 1), Vector2.Zero);
var processor = this.Verify<DrawTextProcessor<Rgba32>>(0); var processor = this.Verify<DrawTextProcessor>(0);
} }
[Fact] [Fact]
public void DrawForEachACharachterWhenPenSet() public void DrawForEachACharachterWhenPenSet()
{ {
this.operations.DrawText(new TextGraphicsOptions(true), "123", this.Font, Pens.Dash(Rgba32.Red, 1), Vector2.Zero); this.operations.DrawText(new TextGraphicsOptions(true), "123", this.Font, Pens.Dash(Color.Red, 1), Vector2.Zero);
var processor = this.Verify<DrawTextProcessor<Rgba32>>(0); var processor = this.Verify<DrawTextProcessor>(0);
} }
[Fact] [Fact]
public void DrawForEachACharachterWhenPenSetDefaultOptions() public void DrawForEachACharachterWhenPenSetDefaultOptions()
{ {
this.operations.DrawText("123", this.Font, Pens.Dash(Rgba32.Red, 1), Vector2.Zero); this.operations.DrawText("123", this.Font, Pens.Dash(Color.Red, 1), Vector2.Zero);
var processor = this.Verify<DrawTextProcessor<Rgba32>>(0); var processor = this.Verify<DrawTextProcessor>(0);
Assert.Equal("123", processor.Text); Assert.Equal("123", processor.Text);
Assert.Equal(this.Font, processor.Font); Assert.Equal(this.Font, processor.Font);
var penBrush = Assert.IsType<SolidBrush<Rgba32>>(processor.Pen.StrokeFill); var penBrush = Assert.IsType<SolidBrush>(processor.Pen.StrokeFill);
Assert.Equal(Rgba32.Red, penBrush.Color); Assert.Equal(Color.Red, penBrush.Color);
Assert.Equal(1, processor.Pen.StrokeWidth); Assert.Equal(1, processor.Pen.StrokeWidth);
Assert.Equal(PointF.Empty, processor.Location); Assert.Equal(PointF.Empty, processor.Location);
} }
@ -144,19 +144,19 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
new TextGraphicsOptions(true), new TextGraphicsOptions(true),
"123", "123",
this.Font, this.Font,
Brushes.Solid(Rgba32.Red), Brushes.Solid(Color.Red),
Pens.Dash(Rgba32.Red, 1), Pens.Dash(Color.Red, 1),
Vector2.Zero); Vector2.Zero);
var processor = this.Verify<DrawTextProcessor<Rgba32>>(0); var processor = this.Verify<DrawTextProcessor>(0);
Assert.Equal("123", processor.Text); Assert.Equal("123", processor.Text);
Assert.Equal(this.Font, processor.Font); Assert.Equal(this.Font, processor.Font);
var brush = Assert.IsType<SolidBrush<Rgba32>>(processor.Brush); var brush = Assert.IsType<SolidBrush>(processor.Brush);
Assert.Equal(Rgba32.Red, brush.Color); Assert.Equal(Color.Red, brush.Color);
Assert.Equal(PointF.Empty, processor.Location); Assert.Equal(PointF.Empty, processor.Location);
var penBrush = Assert.IsType<SolidBrush<Rgba32>>(processor.Pen.StrokeFill); var penBrush = Assert.IsType<SolidBrush>(processor.Pen.StrokeFill);
Assert.Equal(Rgba32.Red, penBrush.Color); Assert.Equal(Color.Red, penBrush.Color);
Assert.Equal(1, processor.Pen.StrokeWidth); Assert.Equal(1, processor.Pen.StrokeWidth);
} }
} }

12
tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs

@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
Font font = CreateFont("OpenSans-Regular.ttf", 36); Font font = CreateFont("OpenSans-Regular.ttf", 36);
TPixel color = NamedColors<TPixel>.Black; Color color = Color.Black;
float padding = 5; float padding = 5;
var text = "A short piece of text"; var text = "A short piece of text";
@ -84,7 +84,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
Font font = CreateFont(fontName, fontSize); Font font = CreateFont(fontName, fontSize);
TPixel color = NamedColors<TPixel>.Black; Color color = Color.Black;
provider.VerifyOperation( provider.VerifyOperation(
TextDrawingComparer, TextDrawingComparer,
@ -129,7 +129,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
HorizontalAlignment = HorizontalAlignment.Left, HorizontalAlignment = HorizontalAlignment.Left,
}; };
TPixel color = NamedColors<TPixel>.Black; Color color = Color.Black;
// Based on the reported 0.0270% difference with AccuracyMultiple = 8 // Based on the reported 0.0270% difference with AccuracyMultiple = 8
// We should avoid quality regressions leading to higher difference! // We should avoid quality regressions leading to higher difference!
@ -159,7 +159,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
Font font = CreateFont(fontName, fontSize); Font font = CreateFont(fontName, fontSize);
TPixel color = NamedColors<TPixel>.Black; Color color = Color.Black;
provider.VerifyOperation( provider.VerifyOperation(
OutlinedTextDrawingComparer, OutlinedTextDrawingComparer,
@ -186,7 +186,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
Font font = CreateFont(fontName, fontSize); Font font = CreateFont(fontName, fontSize);
TPixel color = NamedColors<TPixel>.Black; Color color = Color.Black;
provider.VerifyOperation( provider.VerifyOperation(
OutlinedTextDrawingComparer, OutlinedTextDrawingComparer,
@ -217,7 +217,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
var comparer = ImageComparer.TolerantPercentage(0.2f); var comparer = ImageComparer.TolerantPercentage(0.2f);
provider.RunValidatingProcessorTest( provider.RunValidatingProcessorTest(
x => x.DrawText(textOptions, text, font, NamedColors<TPixel>.Black, new PointF(10, 50)), x => x.DrawText(textOptions, text, font, Color.Black, new PointF(10, 50)),
details, details,
comparer, comparer,
appendPixelTypeToFileName: false, appendPixelTypeToFileName: false,

6
tests/ImageSharp.Tests/Issues/Issue412.cs

@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Tests.Issues
{ {
context.DrawLines( context.DrawLines(
new GraphicsOptions(false), new GraphicsOptions(false),
NamedColors<TPixel>.Black, Color.Black,
1, 1,
new[] new[]
{ {
@ -31,7 +31,7 @@ namespace SixLabors.ImageSharp.Tests.Issues
context.DrawLines( context.DrawLines(
new GraphicsOptions(false), new GraphicsOptions(false),
NamedColors<TPixel>.Red, Color.Red,
1, 1,
new[] new[]
{ {
@ -47,7 +47,7 @@ namespace SixLabors.ImageSharp.Tests.Issues
for (var x = 0; x < 40; x++) for (var x = 0; x < 40; x++)
{ {
Assert.True(NamedColors<TPixel>.Red.Equals(image[x, y]), $"expected {NamedColors<TPixel>.Red} but found {image[x, y]} at [{x}, {y}]"); Assert.True(Color.Red.Equals(image[x, y]), $"expected {Color.Red} but found {image[x, y]} at [{x}, {y}]");
} }
} }
} }

3
tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs

@ -53,8 +53,7 @@ namespace SixLabors.ImageSharp.Tests
public override Image<TPixel> GetImage() public override Image<TPixel> GetImage()
{ {
Image<TPixel> image = base.GetImage(); Image<TPixel> image = base.GetImage();
TPixel color = default(TPixel); Color color = new Rgba32(this.r, this.g, this.b, this.a);
color.FromRgba32(new Rgba32(this.r, this.g, this.b, this.a));
image.Mutate(x => x.Fill(color)); image.Mutate(x => x.Fill(color));
return image; return image;

14
tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs

@ -484,6 +484,20 @@ namespace SixLabors.ImageSharp.Tests
return image; return image;
} }
/// <summary>
/// All pixels in all frames should be exactly equal to 'expectedPixelColor.ToPixel()'.
/// </summary>
public static Image<TPixel> ComparePixelBufferTo<TPixel>(this Image<TPixel> image, Color expectedPixelColor)
where TPixel : struct, IPixel<TPixel>
{
foreach (ImageFrame<TPixel> imageFrame in image.Frames)
{
imageFrame.ComparePixelBufferTo(expectedPixelColor.ToPixel<TPixel>());
}
return image;
}
/// <summary> /// <summary>
/// All pixels in the frame should be exactly equal to 'expectedPixel'. /// All pixels in the frame should be exactly equal to 'expectedPixel'.

Loading…
Cancel
Save