Browse Source

Merge remote-tracking branch 'upstream/master'

pull/495/head
Jason Nelson 8 years ago
parent
commit
242ad80a37
  1. 24
      src/ImageSharp.Drawing/Processing/Drawing/DrawBezierExtensions.cs
  2. 16
      src/ImageSharp.Drawing/Processing/Drawing/DrawImageExtensions.cs
  3. 26
      src/ImageSharp.Drawing/Processing/Drawing/DrawLineExtensions.cs
  4. 20
      src/ImageSharp.Drawing/Processing/Drawing/DrawPathCollectionExtensions.cs
  5. 22
      src/ImageSharp.Drawing/Processing/Drawing/DrawPathExtensions.cs
  6. 26
      src/ImageSharp.Drawing/Processing/Drawing/DrawPolygonExtensions.cs
  7. 20
      src/ImageSharp.Drawing/Processing/Drawing/DrawRectangleExtensions.cs
  8. 14
      src/ImageSharp.Drawing/Processing/Drawing/FillPathBuilderExtensions.cs
  9. 14
      src/ImageSharp.Drawing/Processing/Drawing/FillPathCollectionExtensions.cs
  10. 14
      src/ImageSharp.Drawing/Processing/Drawing/FillPathExtensions.cs
  11. 16
      src/ImageSharp.Drawing/Processing/Drawing/FillPolygonExtensions.cs
  12. 12
      src/ImageSharp.Drawing/Processing/Drawing/FillRectangleExtensions.cs
  13. 18
      src/ImageSharp.Drawing/Processing/Drawing/FillRegionExtensions.cs
  14. 34
      src/ImageSharp.Drawing/Processing/Text/DrawTextExtensions.Path.cs
  15. 34
      src/ImageSharp.Drawing/Processing/Text/DrawTextExtensions.cs
  16. 2
      src/ImageSharp/PixelFormats/PixelBlenderMode.cs
  17. 8
      src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs
  18. 2
      src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt
  19. 130
      src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs
  20. 19
      src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt
  21. 24
      src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs
  22. 2
      src/ImageSharp/PixelFormats/PixelOperations{TPixel}.PixelBenders.cs
  23. 12
      src/ImageSharp/Processing/Overlays/BackgroundColorExtensions.cs
  24. 44
      src/ImageSharp/Processing/Overlays/GlowExtensions.cs
  25. 38
      src/ImageSharp/Processing/Overlays/VignetteExtensions.cs
  26. 31
      tests/ImageSharp.Tests/Drawing/BlendedShapes.cs
  27. 2
      tests/ImageSharp.Tests/Drawing/DrawImageTest.cs
  28. 16
      tests/ImageSharp.Tests/Drawing/LineTests.cs
  29. 4
      tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs
  30. 6
      tests/ImageSharp.Tests/Drawing/Paths/FillPathCollection.cs
  31. 4
      tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs
  32. 4
      tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs
  33. 6
      tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs
  34. 22
      tests/ImageSharp.Tests/Drawing/Text/DrawText.Path.cs
  35. 22
      tests/ImageSharp.Tests/Drawing/Text/DrawText.cs
  36. 8
      tests/ImageSharp.Tests/Issues/Issue412.cs
  37. 48
      tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffCompositorTests.cs
  38. 2
      tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs
  39. 6
      tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests_TPixel.cs
  40. 88
      tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.Blender.cs
  41. 4
      tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs
  42. 2
      tests/ImageSharp.Tests/TestImages.cs
  43. 2
      tests/Images/External
  44. BIN
      tests/Images/Input/Png/pd-dest.png
  45. BIN
      tests/Images/Input/Png/pd-source.png

24
src/ImageSharp.Drawing/Processing/Drawing/DrawBezierExtensions.cs

@ -19,14 +19,14 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="brush">The brush.</param>
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> DrawBeziers<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points, GraphicsOptions options)
public static IImageProcessingContext<TPixel> DrawBeziers<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, IBrush<TPixel> brush, float thickness, params PointF[] points)
where TPixel : struct, IPixel<TPixel>
=> source.Draw(new Pen<TPixel>(brush, thickness), new Path(new CubicBezierLineSegment(points)), options);
=> source.Draw(options, new Pen<TPixel>(brush, thickness), new Path(new CubicBezierLineSegment(points)));
/// <summary>
/// Draws the provided points as an open Bezier path at the provided thickness with the supplied brush
@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> DrawBeziers<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points)
public static IImageProcessingContext<TPixel> DrawBeziers<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, float thickness, params PointF[] points)
where TPixel : struct, IPixel<TPixel>
=> source.Draw(new Pen<TPixel>(brush, thickness), new Path(new CubicBezierLineSegment(points)));
@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> DrawBeziers<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, float thickness, PointF[] points)
public static IImageProcessingContext<TPixel> DrawBeziers<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, float thickness, params PointF[] points)
where TPixel : struct, IPixel<TPixel>
=> source.DrawBeziers(new SolidBrush<TPixel>(color), thickness, points);
@ -59,27 +59,27 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="color">The color.</param>
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> DrawBeziers<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, float thickness, PointF[] points, GraphicsOptions options)
public static IImageProcessingContext<TPixel> DrawBeziers<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, TPixel color, float thickness, params PointF[] points)
where TPixel : struct, IPixel<TPixel>
=> source.DrawBeziers(new SolidBrush<TPixel>(color), thickness, points, options);
=> source.DrawBeziers(options, new SolidBrush<TPixel>(color), thickness, points);
/// <summary>
/// Draws the provided points as an open Bezier path with the supplied pen
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="pen">The pen.</param>
/// <param name="points">The points.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> DrawBeziers<TPixel>(this IImageProcessingContext<TPixel> source, IPen<TPixel> pen, PointF[] points, GraphicsOptions options)
public static IImageProcessingContext<TPixel> DrawBeziers<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, IPen<TPixel> pen, params PointF[] points)
where TPixel : struct, IPixel<TPixel>
=> source.Draw(pen, new Path(new CubicBezierLineSegment(points)), options);
=> source.Draw(options, pen, new Path(new CubicBezierLineSegment(points)));
/// <summary>
/// Draws the provided points as an open Bezier path with the supplied pen
@ -89,7 +89,7 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// <param name="pen">The pen.</param>
/// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> DrawBeziers<TPixel>(this IImageProcessingContext<TPixel> source, IPen<TPixel> pen, PointF[] points)
public static IImageProcessingContext<TPixel> DrawBeziers<TPixel>(this IImageProcessingContext<TPixel> source, IPen<TPixel> pen, params PointF[] points)
where TPixel : struct, IPixel<TPixel>
=> source.Draw(pen, new Path(new CubicBezierLineSegment(points)));
}

16
src/ImageSharp.Drawing/Processing/Drawing/DrawImageExtensions.cs

@ -20,7 +20,7 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// <param name="image">The image to blend with the currently processing image.</param>
/// <param name="opacity">The opacity of the image to blend. Must be between 0 and 1.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Blend<TPixel>(this IImageProcessingContext<TPixel> source, Image<TPixel> image, float opacity)
public static IImageProcessingContext<TPixel> DrawImage<TPixel>(this IImageProcessingContext<TPixel> source, Image<TPixel> image, float opacity)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new DrawImageProcessor<TPixel>(image, opacity));
@ -33,7 +33,7 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// <param name="blender">The blending mode.</param>
/// <param name="opacity">The opacity of the image to blend. Must be between 0 and 1.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Blend<TPixel>(this IImageProcessingContext<TPixel> source, Image<TPixel> image, PixelBlenderMode blender, float opacity)
public static IImageProcessingContext<TPixel> DrawImage<TPixel>(this IImageProcessingContext<TPixel> source, Image<TPixel> image, PixelBlenderMode blender, float opacity)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new DrawImageProcessor<TPixel>(image, opacity, blender));
@ -42,14 +42,12 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="image">The image to blend with the currently processing image.</param>
/// <param name="options">The options, including the blending type and blending amount.</param>
/// <param name="image">The image to blend with the currently processing image.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Blend<TPixel>(this IImageProcessingContext<TPixel> source, Image<TPixel> image, GraphicsOptions options)
public static IImageProcessingContext<TPixel> DrawImage<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, Image<TPixel> image)
where TPixel : struct, IPixel<TPixel>
{
return source.ApplyProcessor(new DrawImageProcessor<TPixel>(image, options));
}
=> source.ApplyProcessor(new DrawImageProcessor<TPixel>(image, options));
/// <summary>
/// Draws the given image together with the current one by blending their pixels.
@ -82,12 +80,12 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// Draws the given image together with the current one by blending their pixels.
/// </summary>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options containing the blend mode and opacity.</param>
/// <param name="image">The image to blend with the currently processing image.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="location">The location to draw the blended image.</param>
/// <param name="options">The options containing the blend mode and opacity.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> DrawImage<TPixel>(this IImageProcessingContext<TPixel> source, Image<TPixel> image, Point location, GraphicsOptions options)
public static IImageProcessingContext<TPixel> DrawImage<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, Image<TPixel> image, Point location)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new DrawImageProcessor<TPixel>(image, location, options));
}

26
src/ImageSharp.Drawing/Processing/Drawing/DrawLineExtensions.cs

@ -19,14 +19,14 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="brush">The brush.</param>
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> DrawLines<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points, GraphicsOptions options)
public static IImageProcessingContext<TPixel> DrawLines<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, IBrush<TPixel> brush, float thickness, params PointF[] points)
where TPixel : struct, IPixel<TPixel>
=> source.Draw(new Pen<TPixel>(brush, thickness), new Path(new LinearLineSegment(points)), options);
=> source.Draw(options, new Pen<TPixel>(brush, thickness), new Path(new LinearLineSegment(points)));
/// <summary>
/// Draws the provided Points as an open Linear path at the provided thickness with the supplied brush
@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> DrawLines<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points)
public static IImageProcessingContext<TPixel> DrawLines<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, float thickness, params PointF[] points)
where TPixel : struct, IPixel<TPixel>
=> source.Draw(new Pen<TPixel>(brush, thickness), new Path(new LinearLineSegment(points)));
@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> DrawLines<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, float thickness, PointF[] points)
public static IImageProcessingContext<TPixel> DrawLines<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, float thickness, params PointF[] points)
where TPixel : struct, IPixel<TPixel>
=> source.DrawLines(new SolidBrush<TPixel>(color), thickness, points);
@ -59,27 +59,27 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="color">The color.</param>
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>>
public static IImageProcessingContext<TPixel> DrawLines<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, float thickness, PointF[] points, GraphicsOptions options)
public static IImageProcessingContext<TPixel> DrawLines<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, TPixel color, float thickness, params PointF[] points)
where TPixel : struct, IPixel<TPixel>
=> source.DrawLines(new SolidBrush<TPixel>(color), thickness, points, options);
=> source.DrawLines(options, new SolidBrush<TPixel>(color), thickness, points);
/// <summary>
/// Draws the provided Points as an open Linear path with the supplied pen
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="pen">The pen.</param>
/// <param name="points">The points.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> DrawLines<TPixel>(this IImageProcessingContext<TPixel> source, IPen<TPixel> pen, PointF[] points, GraphicsOptions options)
public static IImageProcessingContext<TPixel> DrawLines<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, IPen<TPixel> pen, params PointF[] points)
where TPixel : struct, IPixel<TPixel>
=> source.Draw(pen, new Path(new LinearLineSegment(points)), options);
=> source.Draw(options, pen, new Path(new LinearLineSegment(points)));
/// <summary>
/// Draws the provided Points as an open Linear path with the supplied pen
@ -89,8 +89,8 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// <param name="pen">The pen.</param>
/// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> DrawLines<TPixel>(this IImageProcessingContext<TPixel> source, IPen<TPixel> pen, PointF[] points)
public static IImageProcessingContext<TPixel> DrawLines<TPixel>(this IImageProcessingContext<TPixel> source, IPen<TPixel> pen, params PointF[] points)
where TPixel : struct, IPixel<TPixel>
=> source.Draw(pen, new Path(new LinearLineSegment(points)));
}
}
}

20
src/ImageSharp.Drawing/Processing/Drawing/DrawPathCollectionExtensions.cs

@ -18,16 +18,16 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="pen">The pen.</param>
/// <param name="paths">The paths.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, IPen<TPixel> pen, IPathCollection paths, GraphicsOptions options)
public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, IPen<TPixel> pen, IPathCollection paths)
where TPixel : struct, IPixel<TPixel>
{
foreach (IPath path in paths)
{
source.Draw(pen, path, options);
source.Draw(options, pen, path);
}
return source;
@ -43,21 +43,21 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, IPen<TPixel> pen, IPathCollection paths)
where TPixel : struct, IPixel<TPixel>
=> source.Draw(pen, paths, GraphicsOptions.Default);
=> source.Draw(GraphicsOptions.Default, pen, paths);
/// <summary>
/// Draws the outline of the polygon with the provided brush at the provided thickness.
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="brush">The brush.</param>
/// <param name="thickness">The thickness.</param>
/// <param name="paths">The shapes.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, float thickness, IPathCollection paths, GraphicsOptions options)
public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, IBrush<TPixel> brush, float thickness, IPathCollection paths)
where TPixel : struct, IPixel<TPixel>
=> source.Draw(new Pen<TPixel>(brush, thickness), paths, options);
=> source.Draw(options, new Pen<TPixel>(brush, thickness), paths);
/// <summary>
/// Draws the outline of the polygon with the provided brush at the provided thickness.
@ -77,14 +77,14 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="color">The color.</param>
/// <param name="thickness">The thickness.</param>
/// <param name="paths">The paths.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, float thickness, IPathCollection paths, GraphicsOptions options)
public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, TPixel color, float thickness, IPathCollection paths)
where TPixel : struct, IPixel<TPixel>
=> source.Draw(new SolidBrush<TPixel>(color), thickness, paths, options);
=> source.Draw(options, new SolidBrush<TPixel>(color), thickness, paths);
/// <summary>
/// Draws the outline of the polygon with the provided brush at the provided thickness.

22
src/ImageSharp.Drawing/Processing/Drawing/DrawPathExtensions.cs

@ -19,13 +19,13 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="pen">The pen.</param>
/// <param name="path">The path.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, IPen<TPixel> pen, IPath path, GraphicsOptions options)
public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, IPen<TPixel> pen, IPath path)
where TPixel : struct, IPixel<TPixel>
=> source.Fill(pen.StrokeFill, new ShapePath(path, pen), options);
=> source.Fill(options, pen.StrokeFill, new ShapePath(path, pen));
/// <summary>
/// Draws the outline of the polygon with the provided pen.
@ -37,21 +37,21 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, IPen<TPixel> pen, IPath path)
where TPixel : struct, IPixel<TPixel>
=> source.Draw(pen, path, GraphicsOptions.Default);
=> source.Draw(GraphicsOptions.Default, pen, path);
/// <summary>
/// Draws the outline of the polygon with the provided brush at the provided thickness.
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="brush">The brush.</param>
/// <param name="thickness">The thickness.</param>
/// <param name="path">The shape.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, float thickness, IPath path, GraphicsOptions options)
public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, IBrush<TPixel> brush, float thickness, IPath path)
where TPixel : struct, IPixel<TPixel>
=> source.Draw(new Pen<TPixel>(brush, thickness), path, options);
=> source.Draw(options, new Pen<TPixel>(brush, thickness), path);
/// <summary>
/// Draws the outline of the polygon with the provided brush at the provided thickness.
@ -71,14 +71,14 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="color">The color.</param>
/// <param name="thickness">The thickness.</param>
/// <param name="path">The path.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, float thickness, IPath path, GraphicsOptions options)
public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, TPixel color, float thickness, IPath path)
where TPixel : struct, IPixel<TPixel>
=> source.Draw(new SolidBrush<TPixel>(color), thickness, path, options);
=> source.Draw(options, new SolidBrush<TPixel>(color), thickness, path);
/// <summary>
/// Draws the outline of the polygon with the provided brush at the provided thickness.
@ -93,4 +93,4 @@ namespace SixLabors.ImageSharp.Processing.Drawing
where TPixel : struct, IPixel<TPixel>
=> source.Draw(new SolidBrush<TPixel>(color), thickness, path);
}
}
}

26
src/ImageSharp.Drawing/Processing/Drawing/DrawPolygonExtensions.cs

@ -19,14 +19,14 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="brush">The brush.</param>
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> DrawPolygon<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points, GraphicsOptions options)
public static IImageProcessingContext<TPixel> DrawPolygon<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, IBrush<TPixel> brush, float thickness, params PointF[] points)
where TPixel : struct, IPixel<TPixel>
=> source.Draw(new Pen<TPixel>(brush, thickness), new Polygon(new LinearLineSegment(points)), options);
=> source.Draw(options, new Pen<TPixel>(brush, thickness), new Polygon(new LinearLineSegment(points)));
/// <summary>
/// Draws the provided Points as a closed Linear Polygon with the provided brush at the provided thickness.
@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> DrawPolygon<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points)
public static IImageProcessingContext<TPixel> DrawPolygon<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, float thickness, params PointF[] points)
where TPixel : struct, IPixel<TPixel>
=> source.Draw(new Pen<TPixel>(brush, thickness), new Polygon(new LinearLineSegment(points)));
@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> DrawPolygon<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, float thickness, PointF[] points)
public static IImageProcessingContext<TPixel> DrawPolygon<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, float thickness, params PointF[] points)
where TPixel : struct, IPixel<TPixel>
=> source.DrawPolygon(new SolidBrush<TPixel>(color), thickness, points);
@ -59,14 +59,14 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="color">The color.</param>
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> DrawPolygon<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, float thickness, PointF[] points, GraphicsOptions options)
public static IImageProcessingContext<TPixel> DrawPolygon<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, TPixel color, float thickness, params PointF[] points)
where TPixel : struct, IPixel<TPixel>
=> source.DrawPolygon(new SolidBrush<TPixel>(color), thickness, points, options);
=> source.DrawPolygon(options, new SolidBrush<TPixel>(color), thickness, points);
/// <summary>
/// Draws the provided Points as a closed Linear Polygon with the provided Pen.
@ -76,21 +76,21 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// <param name="pen">The pen.</param>
/// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> DrawPolygon<TPixel>(this IImageProcessingContext<TPixel> source, IPen<TPixel> pen, PointF[] points)
public static IImageProcessingContext<TPixel> DrawPolygon<TPixel>(this IImageProcessingContext<TPixel> source, IPen<TPixel> pen, params PointF[] points)
where TPixel : struct, IPixel<TPixel>
=> source.Draw(pen, new Polygon(new LinearLineSegment(points)), GraphicsOptions.Default);
=> source.Draw(GraphicsOptions.Default, pen, new Polygon(new LinearLineSegment(points)));
/// <summary>
/// Draws the provided Points as a closed Linear Polygon with the provided Pen.
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="pen">The pen.</param>
/// <param name="points">The points.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> DrawPolygon<TPixel>(this IImageProcessingContext<TPixel> source, IPen<TPixel> pen, PointF[] points, GraphicsOptions options)
public static IImageProcessingContext<TPixel> DrawPolygon<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, IPen<TPixel> pen, params PointF[] points)
where TPixel : struct, IPixel<TPixel>
=> source.Draw(pen, new Polygon(new LinearLineSegment(points)), options);
=> source.Draw(options, pen, new Polygon(new LinearLineSegment(points)));
}
}

20
src/ImageSharp.Drawing/Processing/Drawing/DrawRectangleExtensions.cs

@ -19,13 +19,13 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="pen">The pen.</param>
/// <param name="shape">The shape.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, IPen<TPixel> pen, RectangleF shape, GraphicsOptions options)
public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, IPen<TPixel> pen, RectangleF shape)
where TPixel : struct, IPixel<TPixel>
=> source.Draw(pen, new RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height), options);
=> source.Draw(options, pen, new RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height));
/// <summary>
/// Draws the outline of the rectangle with the provided pen.
@ -37,21 +37,21 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, IPen<TPixel> pen, RectangleF shape)
where TPixel : struct, IPixel<TPixel>
=> source.Draw(pen, shape, GraphicsOptions.Default);
=> source.Draw(GraphicsOptions.Default, pen, shape);
/// <summary>
/// Draws the outline of the rectangle with the provided brush at the provided thickness.
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="brush">The brush.</param>
/// <param name="thickness">The thickness.</param>
/// <param name="shape">The shape.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, float thickness, RectangleF shape, GraphicsOptions options)
public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, IBrush<TPixel> brush, float thickness, RectangleF shape)
where TPixel : struct, IPixel<TPixel>
=> source.Draw(new Pen<TPixel>(brush, thickness), shape, options);
=> source.Draw(options, new Pen<TPixel>(brush, thickness), shape);
/// <summary>
/// Draws the outline of the rectangle with the provided brush at the provided thickness.
@ -71,14 +71,14 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="color">The color.</param>
/// <param name="thickness">The thickness.</param>
/// <param name="shape">The shape.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, float thickness, RectangleF shape, GraphicsOptions options)
public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, TPixel color, float thickness, RectangleF shape)
where TPixel : struct, IPixel<TPixel>
=> source.Draw(new SolidBrush<TPixel>(color), thickness, shape, options);
=> source.Draw(options, new SolidBrush<TPixel>(color), thickness, shape);
/// <summary>
/// Draws the outline of the rectangle with the provided brush at the provided thickness.

14
src/ImageSharp.Drawing/Processing/Drawing/FillPathBuilderExtensions.cs

@ -18,17 +18,17 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The graphics options.</param>
/// <param name="brush">The brush.</param>
/// <param name="path">The shape.</param>
/// <param name="options">The graphics options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, Action<PathBuilder> path, GraphicsOptions options)
public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, IBrush<TPixel> brush, Action<PathBuilder> path)
where TPixel : struct, IPixel<TPixel>
{
var pb = new PathBuilder();
path(pb);
return source.Fill(brush, pb.Build(), options);
return source.Fill(options, brush, pb.Build());
}
/// <summary>
@ -41,20 +41,20 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, Action<PathBuilder> path)
where TPixel : struct, IPixel<TPixel>
=> source.Fill(brush, path, GraphicsOptions.Default);
=> source.Fill(GraphicsOptions.Default, brush, path);
/// <summary>
/// Flood fills the image in the shape of the provided polygon with the specified brush.
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="color">The color.</param>
/// <param name="path">The path.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, Action<PathBuilder> path, GraphicsOptions options)
public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, TPixel color, Action<PathBuilder> path)
where TPixel : struct, IPixel<TPixel>
=> source.Fill(new SolidBrush<TPixel>(color), path, options);
=> source.Fill(options, new SolidBrush<TPixel>(color), path);
/// <summary>
/// Flood fills the image in the shape of the provided polygon with the specified brush.

14
src/ImageSharp.Drawing/Processing/Drawing/FillPathCollectionExtensions.cs

@ -17,16 +17,16 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The graphics options.</param>
/// <param name="brush">The brush.</param>
/// <param name="paths">The shapes.</param>
/// <param name="options">The graphics options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, IPathCollection paths, GraphicsOptions options)
public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, IBrush<TPixel> brush, IPathCollection paths)
where TPixel : struct, IPixel<TPixel>
{
foreach (IPath s in paths)
{
source.Fill(brush, s, options);
source.Fill(options, brush, s);
}
return source;
@ -42,20 +42,20 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, IPathCollection paths)
where TPixel : struct, IPixel<TPixel>
=> source.Fill(brush, paths, GraphicsOptions.Default);
=> source.Fill(GraphicsOptions.Default, brush, paths);
/// <summary>
/// Flood fills the image in the shape of the provided polygon with the specified brush.
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="color">The color.</param>
/// <param name="paths">The paths.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, IPathCollection paths, GraphicsOptions options)
public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, TPixel color, IPathCollection paths)
where TPixel : struct, IPixel<TPixel>
=> source.Fill(new SolidBrush<TPixel>(color), paths, options);
=> source.Fill(options, new SolidBrush<TPixel>(color), paths);
/// <summary>
/// Flood fills the image in the shape of the provided polygon with the specified brush.

14
src/ImageSharp.Drawing/Processing/Drawing/FillPathExtensions.cs

@ -18,13 +18,13 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The graphics options.</param>
/// <param name="brush">The brush.</param>
/// <param name="path">The shape.</param>
/// <param name="options">The graphics options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, IPath path, GraphicsOptions options)
public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, IBrush<TPixel> brush, IPath path)
where TPixel : struct, IPixel<TPixel>
=> source.Fill(brush, new ShapeRegion(path), options);
=> source.Fill(options, brush, new ShapeRegion(path));
/// <summary>
/// Flood fills the image in the shape of the provided polygon with the specified brush.
@ -36,20 +36,20 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, IPath path)
where TPixel : struct, IPixel<TPixel>
=> source.Fill(brush, new ShapeRegion(path), GraphicsOptions.Default);
=> source.Fill(GraphicsOptions.Default, brush, new ShapeRegion(path));
/// <summary>
/// Flood fills the image in the shape of the provided polygon with the specified brush..
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="color">The color.</param>
/// <param name="path">The path.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, IPath path, GraphicsOptions options)
public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, TPixel color, IPath path)
where TPixel : struct, IPixel<TPixel>
=> source.Fill(new SolidBrush<TPixel>(color), path, options);
=> source.Fill(options, new SolidBrush<TPixel>(color), path);
/// <summary>
/// Flood fills the image in the shape of the provided polygon with the specified brush..

16
src/ImageSharp.Drawing/Processing/Drawing/FillPolygonExtensions.cs

@ -18,13 +18,13 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="brush">The brush.</param>
/// <param name="points">The points.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> FillPolygon<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, PointF[] points, GraphicsOptions options)
public static IImageProcessingContext<TPixel> FillPolygon<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, IBrush<TPixel> brush, params PointF[] points)
where TPixel : struct, IPixel<TPixel>
=> source.Fill(brush, new Polygon(new LinearLineSegment(points)), options);
=> source.Fill(options, brush, new Polygon(new LinearLineSegment(points)));
/// <summary>
/// Flood fills the image in the shape of a Linear polygon described by the points
@ -34,7 +34,7 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// <param name="brush">The brush.</param>
/// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> FillPolygon<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, PointF[] points)
public static IImageProcessingContext<TPixel> FillPolygon<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, params PointF[] points)
where TPixel : struct, IPixel<TPixel>
=> source.Fill(brush, new Polygon(new LinearLineSegment(points)));
@ -43,13 +43,13 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="color">The color.</param>
/// <param name="points">The points.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> FillPolygon<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, PointF[] points, GraphicsOptions options)
public static IImageProcessingContext<TPixel> FillPolygon<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, TPixel color, params PointF[] points)
where TPixel : struct, IPixel<TPixel>
=> source.Fill(new SolidBrush<TPixel>(color), new Polygon(new LinearLineSegment(points)), options);
=> source.Fill(options, new SolidBrush<TPixel>(color), new Polygon(new LinearLineSegment(points)));
/// <summary>
/// Flood fills the image in the shape of a Linear polygon described by the points
@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// <param name="color">The color.</param>
/// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> FillPolygon<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, PointF[] points)
public static IImageProcessingContext<TPixel> FillPolygon<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, params PointF[] points)
where TPixel : struct, IPixel<TPixel>
=> source.Fill(new SolidBrush<TPixel>(color), new Polygon(new LinearLineSegment(points)));
}

12
src/ImageSharp.Drawing/Processing/Drawing/FillRectangleExtensions.cs

@ -18,13 +18,13 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="brush">The brush.</param>
/// <param name="shape">The shape.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, RectangleF shape, GraphicsOptions options)
public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, IBrush<TPixel> brush, RectangleF shape)
where TPixel : struct, IPixel<TPixel>
=> source.Fill(brush, new RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height), options);
=> source.Fill(options, brush, new RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height));
/// <summary>
/// Flood fills the image in the shape of the provided rectangle with the specified brush.
@ -43,13 +43,13 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="color">The color.</param>
/// <param name="shape">The shape.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, RectangleF shape, GraphicsOptions options)
public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, TPixel color, RectangleF shape)
where TPixel : struct, IPixel<TPixel>
=> source.Fill(new SolidBrush<TPixel>(color), shape, options);
=> source.Fill(options, new SolidBrush<TPixel>(color), shape);
/// <summary>
/// Flood fills the image in the shape of the provided rectangle with the specified brush.

18
src/ImageSharp.Drawing/Processing/Drawing/FillRegionExtensions.cs

@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush)
where TPixel : struct, IPixel<TPixel>
=> source.Fill(brush, GraphicsOptions.Default);
=> source.Fill(GraphicsOptions.Default, brush);
/// <summary>
/// Flood fills the image with the specified color.
@ -45,20 +45,20 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, Region region)
where TPixel : struct, IPixel<TPixel>
=> source.Fill(brush, region, GraphicsOptions.Default);
=> source.Fill(GraphicsOptions.Default, brush, region);
/// <summary>
/// Flood fills the image with in the region with the specified color.
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="color">The color.</param>
/// <param name="region">The region.</param>
/// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, Region region, GraphicsOptions options)
public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, TPixel color, Region region)
where TPixel : struct, IPixel<TPixel>
=> source.Fill(new SolidBrush<TPixel>(color), region, options);
=> source.Fill(options, new SolidBrush<TPixel>(color), region);
/// <summary>
/// Flood fills the image with in the region with the specified color.
@ -77,11 +77,11 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The graphics options.</param>
/// <param name="brush">The brush.</param>
/// <param name="region">The region.</param>
/// <param name="options">The graphics options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, Region region, GraphicsOptions options)
public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, IBrush<TPixel> brush, Region region)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new FillRegionProcessor<TPixel>(brush, region, options));
@ -90,10 +90,10 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="brush">The details how to fill the region of interest.</param>
/// <param name="options">The graphics options.</param>
/// <param name="brush">The details how to fill the region of interest.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, GraphicsOptions options)
public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, IBrush<TPixel> brush)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new FillProcessor<TPixel>(brush, options));
}

34
src/ImageSharp.Drawing/Processing/Text/DrawTextExtensions.Path.cs

@ -29,24 +29,24 @@ namespace SixLabors.ImageSharp.Processing.Text
/// </returns>
public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, TPixel color, IPath path)
where TPixel : struct, IPixel<TPixel>
=> source.DrawText(text, font, color, path, TextGraphicsOptions.Default);
=> source.DrawText(TextGraphicsOptions.Default, text, font, color, path);
/// <summary>
/// Draws the text onto the the image filled via the brush.
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="text">The text.</param>
/// <param name="font">The font.</param>
/// <param name="color">The color.</param>
/// <param name="path">The path.</param>
/// <param name="options">The options.</param>
/// <returns>
/// The <see cref="Image{TPixel}" />.
/// </returns>
public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, TPixel color, IPath path, TextGraphicsOptions options)
public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, TextGraphicsOptions options, string text, Font font, TPixel color, IPath path)
where TPixel : struct, IPixel<TPixel>
=> source.DrawText(text, font, Brushes.Solid(color), null, path, options);
=> source.DrawText(options, text, font, Brushes.Solid(color), null, path);
/// <summary>
/// Draws the text onto the the image filled via the brush.
@ -62,24 +62,24 @@ namespace SixLabors.ImageSharp.Processing.Text
/// </returns>
public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPath path)
where TPixel : struct, IPixel<TPixel>
=> source.DrawText(text, font, brush, path, TextGraphicsOptions.Default);
=> source.DrawText(TextGraphicsOptions.Default, text, font, brush, path);
/// <summary>
/// Draws the text onto the the image filled via the brush.
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="text">The text.</param>
/// <param name="font">The font.</param>
/// <param name="brush">The brush.</param>
/// <param name="path">The path.</param>
/// <param name="options">The options.</param>
/// <returns>
/// The <see cref="Image{TPixel}" />.
/// </returns>
public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPath path, TextGraphicsOptions options)
public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, TextGraphicsOptions options, string text, Font font, IBrush<TPixel> brush, IPath path)
where TPixel : struct, IPixel<TPixel>
=> source.DrawText(text, font, brush, null, path, options);
=> source.DrawText(options, text, font, brush, null, path);
/// <summary>
/// Draws the text onto the the image outlined via the pen.
@ -95,24 +95,24 @@ namespace SixLabors.ImageSharp.Processing.Text
/// </returns>
public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, IPen<TPixel> pen, IPath path)
where TPixel : struct, IPixel<TPixel>
=> source.DrawText(text, font, pen, path, TextGraphicsOptions.Default);
=> source.DrawText(TextGraphicsOptions.Default, text, font, pen, path);
/// <summary>
/// Draws the text onto the the image outlined via the pen.
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="text">The text.</param>
/// <param name="font">The font.</param>
/// <param name="pen">The pen.</param>
/// <param name="path">The path.</param>
/// <param name="options">The options.</param>
/// <returns>
/// The <see cref="Image{TPixel}" />.
/// </returns>
public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, IPen<TPixel> pen, IPath path, TextGraphicsOptions options)
public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, TextGraphicsOptions options, string text, Font font, IPen<TPixel> pen, IPath path)
where TPixel : struct, IPixel<TPixel>
=> source.DrawText(text, font, null, pen, path, options);
=> source.DrawText(options, text, font, null, pen, path);
/// <summary>
/// Draws the text onto the the image filled via the brush then outlined via the pen.
@ -129,23 +129,23 @@ namespace SixLabors.ImageSharp.Processing.Text
/// </returns>
public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPen<TPixel> pen, IPath path)
where TPixel : struct, IPixel<TPixel>
=> source.DrawText(text, font, brush, pen, path, TextGraphicsOptions.Default);
=> source.DrawText(TextGraphicsOptions.Default, text, font, brush, pen, path);
/// <summary>
/// Draws the text onto the the image filled via the brush then outlined via the pen.
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="text">The text.</param>
/// <param name="font">The font.</param>
/// <param name="brush">The brush.</param>
/// <param name="pen">The pen.</param>
/// <param name="path">The path.</param>
/// <param name="options">The options.</param>
/// <returns>
/// The <see cref="Image{TPixel}" />.
/// </returns>
public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPen<TPixel> pen, IPath path, TextGraphicsOptions options)
public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, TextGraphicsOptions options, string text, Font font, IBrush<TPixel> brush, IPen<TPixel> pen, IPath path)
where TPixel : struct, IPixel<TPixel>
{
float dpiX = DefaultTextDpi;
@ -165,12 +165,12 @@ namespace SixLabors.ImageSharp.Processing.Text
var pathOptions = (GraphicsOptions)options;
if (brush != null)
{
source.Fill(brush, glyphs, pathOptions);
source.Fill(pathOptions, brush, glyphs);
}
if (pen != null)
{
source.Draw(pen, glyphs, pathOptions);
source.Draw(pathOptions, pen, glyphs);
}
return source;

34
src/ImageSharp.Drawing/Processing/Text/DrawTextExtensions.cs

@ -32,24 +32,24 @@ namespace SixLabors.ImageSharp.Processing.Text
/// </returns>
public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, TPixel color, PointF location)
where TPixel : struct, IPixel<TPixel>
=> source.DrawText(text, font, color, location, TextGraphicsOptions.Default);
=> source.DrawText(TextGraphicsOptions.Default, text, font, color, location);
/// <summary>
/// Draws the text onto the the image filled via the brush.
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="text">The text.</param>
/// <param name="font">The font.</param>
/// <param name="color">The color.</param>
/// <param name="location">The location.</param>
/// <param name="options">The options.</param>
/// <returns>
/// The <see cref="Image{TPixel}" />.
/// </returns>
public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, TPixel color, PointF location, TextGraphicsOptions options)
public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, TextGraphicsOptions options, string text, Font font, TPixel color, PointF location)
where TPixel : struct, IPixel<TPixel>
=> source.DrawText(text, font, Brushes.Solid(color), null, location, options);
=> source.DrawText(options, text, font, Brushes.Solid(color), null, location);
/// <summary>
/// Draws the text onto the the image filled via the brush.
@ -65,24 +65,24 @@ namespace SixLabors.ImageSharp.Processing.Text
/// </returns>
public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, IBrush<TPixel> brush, PointF location)
where TPixel : struct, IPixel<TPixel>
=> source.DrawText(text, font, brush, location, TextGraphicsOptions.Default);
=> source.DrawText(TextGraphicsOptions.Default, text, font, brush, location);
/// <summary>
/// Draws the text onto the the image filled via the brush.
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="text">The text.</param>
/// <param name="font">The font.</param>
/// <param name="brush">The brush.</param>
/// <param name="location">The location.</param>
/// <param name="options">The options.</param>
/// <returns>
/// The <see cref="Image{TPixel}" />.
/// </returns>
public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, IBrush<TPixel> brush, PointF location, TextGraphicsOptions options)
public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, TextGraphicsOptions options, string text, Font font, IBrush<TPixel> brush, PointF location)
where TPixel : struct, IPixel<TPixel>
=> source.DrawText(text, font, brush, null, location, options);
=> source.DrawText(options, text, font, brush, null, location);
/// <summary>
/// Draws the text onto the the image outlined via the pen.
@ -98,24 +98,24 @@ namespace SixLabors.ImageSharp.Processing.Text
/// </returns>
public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, IPen<TPixel> pen, PointF location)
where TPixel : struct, IPixel<TPixel>
=> source.DrawText(text, font, pen, location, TextGraphicsOptions.Default);
=> source.DrawText(TextGraphicsOptions.Default, text, font, pen, location);
/// <summary>
/// Draws the text onto the the image outlined via the pen.
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="text">The text.</param>
/// <param name="font">The font.</param>
/// <param name="pen">The pen.</param>
/// <param name="location">The location.</param>
/// <param name="options">The options.</param>
/// <returns>
/// The <see cref="Image{TPixel}" />.
/// </returns>
public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, IPen<TPixel> pen, PointF location, TextGraphicsOptions options)
public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, TextGraphicsOptions options, string text, Font font, IPen<TPixel> pen, PointF location)
where TPixel : struct, IPixel<TPixel>
=> source.DrawText(text, font, null, pen, location, options);
=> source.DrawText(options, text, font, null, pen, location);
/// <summary>
/// Draws the text onto the the image filled via the brush then outlined via the pen.
@ -132,23 +132,23 @@ namespace SixLabors.ImageSharp.Processing.Text
/// </returns>
public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPen<TPixel> pen, PointF location)
where TPixel : struct, IPixel<TPixel>
=> source.DrawText(text, font, brush, pen, location, TextGraphicsOptions.Default);
=> source.DrawText(TextGraphicsOptions.Default, text, font, brush, pen, location);
/// <summary>
/// Draws the text using the default resolution of <value>72dpi</value> onto the the image filled via the brush then outlined via the pen.
/// </summary>
/// <typeparam name="TPixel">The type of the color.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options.</param>
/// <param name="text">The text.</param>
/// <param name="font">The font.</param>
/// <param name="brush">The brush.</param>
/// <param name="pen">The pen.</param>
/// <param name="location">The location.</param>
/// <param name="options">The options.</param>
/// <returns>
/// The <see cref="Image{TPixel}" />.
/// </returns>
public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPen<TPixel> pen, PointF location, TextGraphicsOptions options)
public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, TextGraphicsOptions options, string text, Font font, IBrush<TPixel> brush, IPen<TPixel> pen, PointF location)
where TPixel : struct, IPixel<TPixel>
{
float dpiX = DefaultTextDpi;
@ -168,12 +168,12 @@ namespace SixLabors.ImageSharp.Processing.Text
var pathOptions = (GraphicsOptions)options;
if (brush != null)
{
source.Fill(brush, glyphs, pathOptions);
source.Fill(pathOptions, brush, glyphs);
}
if (pen != null)
{
source.Draw(pen, glyphs, pathOptions);
source.Draw(pathOptions, pen, glyphs);
}
return source;

2
src/ImageSharp/PixelFormats/PixelBlenderMode.cs

@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <summary>
/// Blends the 2 values by subtraction.
/// </summary>
Substract,
Subtract,
/// <summary>
/// Multiplies the complements of the backdrop and source values, then complements the result.

8
src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs

@ -141,17 +141,17 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
}
}
internal class Substract : PixelBlender<TPixel>
internal class Subtract : PixelBlender<TPixel>
{
/// <summary>
/// Gets the static instance of this blender.
/// </summary>
public static Substract Instance { get; } = new Substract();
public static Subtract Instance { get; } = new Subtract();
/// <inheritdoc />
public override TPixel Blend(TPixel background, TPixel source, float amount)
{
return PorterDuffFunctions.Substract(background, source, amount);
return PorterDuffFunctions.Subtract(background, source, amount);
}
/// <inheritdoc />
@ -172,7 +172,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
for (int i = 0; i < destination.Length; i++)
{
destinationSpan[i] = PorterDuffFunctions.Substract(backgroundSpan[i], sourceSpan[i], amount[i]);
destinationSpan[i] = PorterDuffFunctions.Subtract(backgroundSpan[i], sourceSpan[i], amount[i]);
}
PixelOperations<TPixel>.Instance.PackFromVector4(destinationSpan, destination, destination.Length);

2
src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt

@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
"Normal",
"Multiply",
"Add",
"Substract",
"Subtract",
"Screen",
"Darken",
"Lighten",

130
src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.cs

@ -15,19 +15,19 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
public static Vector4 Src(Vector4 backdrop, Vector4 source, float opacity)
{
opacity = opacity.Clamp(0, 1);
source.W *= opacity;
Vector4 xform = source;
source.W *= opacity;
// calculate weights
float xw = Vector4.Zero.W * source.W;
float bw = Vector4.Zero.W - xw;
float xw = backdrop.W * source.W;
float bw = backdrop.W - xw;
float sw = source.W - xw;
// calculate final alpha
float a = xw + bw + sw;
float fw = (sw * 1) + (bw * 0) + (xw * 1);
// calculate final value
xform = ((xform * xw) + (Vector4.Zero * bw) + (source * sw)) / MathF.Max(a, Constants.Epsilon);
Vector4 xform = ((source * xw) + (Vector4.Zero * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon);
xform.W = fw;
return Vector4.Lerp(backdrop, xform, opacity);
}
@ -36,18 +36,18 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
public static Vector4 Atop(Vector4 backdrop, Vector4 source, float opacity)
{
opacity = opacity.Clamp(0, 1);
Vector4 xform = source;
// calculate weights
float xw = backdrop.W * Vector4.Zero.W;
float xw = backdrop.W * source.W;
float bw = backdrop.W - xw;
float sw = Vector4.Zero.W - xw;
float sw = source.W - xw;
// calculate final alpha
float a = xw + bw + sw;
float fw = (sw * 0) + (bw * 1) + (xw * 1);
// calculate final value
xform = ((xform * xw) + (backdrop * bw) + (Vector4.Zero * sw)) / MathF.Max(a, Constants.Epsilon);
Vector4 xform = ((source * xw) + (backdrop * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon);
xform.W = fw;
return Vector4.Lerp(backdrop, xform, opacity);
}
@ -56,8 +56,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
public static Vector4 Over(Vector4 backdrop, Vector4 source, float opacity)
{
opacity = opacity.Clamp(0, 1);
source.W *= opacity;
Vector4 xform = source;
source.W *= opacity;
// calculate weights
float xw = backdrop.W * source.W;
@ -65,10 +64,11 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
float sw = source.W - xw;
// calculate final alpha
float a = xw + bw + sw;
float fw = (sw * 1) + (bw * 1) + (xw * 1);
// calculate final value
xform = ((xform * xw) + (backdrop * bw) + (source * sw)) / MathF.Max(a, Constants.Epsilon);
Vector4 xform = ((source * xw) + (backdrop * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon);
xform.W = fw;
return Vector4.Lerp(backdrop, xform, opacity);
}
@ -77,18 +77,18 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
public static Vector4 In(Vector4 backdrop, Vector4 source, float opacity)
{
opacity = opacity.Clamp(0, 1);
Vector4 xform = source;
// calculate weights
float xw = Vector4.Zero.W * Vector4.Zero.W;
float bw = Vector4.Zero.W - xw;
float sw = Vector4.Zero.W - xw;
float xw = backdrop.W * source.W;
float bw = backdrop.W - xw;
float sw = source.W - xw;
// calculate final alpha
float a = xw + bw + sw;
float fw = (sw * 0) + (bw * 0) + (xw * 1);
// calculate final value
xform = ((xform * xw) + (Vector4.Zero * bw) + (Vector4.Zero * sw)) / MathF.Max(a, Constants.Epsilon);
Vector4 xform = ((source * xw) + (Vector4.Zero * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon);
xform.W = fw;
return Vector4.Lerp(backdrop, xform, opacity);
}
@ -97,19 +97,19 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
public static Vector4 Out(Vector4 backdrop, Vector4 source, float opacity)
{
opacity = opacity.Clamp(0, 1);
source.W *= opacity;
Vector4 xform = Vector4.Zero;
source.W *= opacity;
// calculate weights
float xw = Vector4.Zero.W * source.W;
float bw = Vector4.Zero.W - xw;
float xw = backdrop.W * source.W;
float bw = backdrop.W - xw;
float sw = source.W - xw;
// calculate final alpha
float a = xw + bw + sw;
float fw = (sw * 1) + (bw * 0) + (xw * 0);
// calculate final value
xform = ((xform * xw) + (Vector4.Zero * bw) + (source * sw)) / MathF.Max(a, Constants.Epsilon);
Vector4 xform = ((Vector4.Zero * xw) + (Vector4.Zero * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon);
xform.W = fw;
return Vector4.Lerp(backdrop, xform, opacity);
}
@ -118,18 +118,18 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
public static Vector4 Dest(Vector4 backdrop, Vector4 source, float opacity)
{
opacity = opacity.Clamp(0, 1);
Vector4 xform = backdrop;
// calculate weights
float xw = backdrop.W * Vector4.Zero.W;
float xw = backdrop.W * source.W;
float bw = backdrop.W - xw;
float sw = Vector4.Zero.W - xw;
float sw = source.W - xw;
// calculate final alpha
float a = xw + bw + sw;
float fw = (sw * 0) + (bw * 1) + (xw * 1);
// calculate final value
xform = ((xform * xw) + (backdrop * bw) + (Vector4.Zero * sw)) / MathF.Max(a, Constants.Epsilon);
Vector4 xform = ((backdrop * xw) + (backdrop * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon);
xform.W = fw;
return Vector4.Lerp(backdrop, xform, opacity);
}
@ -138,19 +138,19 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
public static Vector4 DestAtop(Vector4 backdrop, Vector4 source, float opacity)
{
opacity = opacity.Clamp(0, 1);
source.W *= opacity;
Vector4 xform = backdrop;
source.W *= opacity;
// calculate weights
float xw = Vector4.Zero.W * source.W;
float bw = Vector4.Zero.W - xw;
float xw = backdrop.W * source.W;
float bw = backdrop.W - xw;
float sw = source.W - xw;
// calculate final alpha
float a = xw + bw + sw;
float fw = (sw * 1) + (bw * 0) + (xw * 1);
// calculate final value
xform = ((xform * xw) + (Vector4.Zero * bw) + (source * sw)) / MathF.Max(a, Constants.Epsilon);
Vector4 xform = ((backdrop * xw) + (Vector4.Zero * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon);
xform.W = fw;
return Vector4.Lerp(backdrop, xform, opacity);
}
@ -159,8 +159,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
public static Vector4 DestOver(Vector4 backdrop, Vector4 source, float opacity)
{
opacity = opacity.Clamp(0, 1);
source.W *= opacity;
Vector4 xform = backdrop;
source.W *= opacity;
// calculate weights
float xw = backdrop.W * source.W;
@ -168,10 +167,11 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
float sw = source.W - xw;
// calculate final alpha
float a = xw + bw + sw;
float fw = (sw * 1) + (bw * 1) + (xw * 1);
// calculate final value
xform = ((xform * xw) + (backdrop * bw) + (source * sw)) / MathF.Max(a, Constants.Epsilon);
Vector4 xform = ((backdrop * xw) + (backdrop * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon);
xform.W = fw;
return Vector4.Lerp(backdrop, xform, opacity);
}
@ -180,18 +180,18 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
public static Vector4 DestIn(Vector4 backdrop, Vector4 source, float opacity)
{
opacity = opacity.Clamp(0, 1);
Vector4 xform = backdrop;
// calculate weights
float xw = Vector4.Zero.W * Vector4.Zero.W;
float bw = Vector4.Zero.W - xw;
float sw = Vector4.Zero.W - xw;
float xw = backdrop.W * source.W;
float bw = backdrop.W - xw;
float sw = source.W - xw;
// calculate final alpha
float a = xw + bw + sw;
float fw = (sw * 0) + (bw * 0) + (xw * 1);
// calculate final value
xform = ((xform * xw) + (Vector4.Zero * bw) + (Vector4.Zero * sw)) / MathF.Max(a, Constants.Epsilon);
Vector4 xform = ((backdrop * xw) + (Vector4.Zero * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon);
xform.W = fw;
return Vector4.Lerp(backdrop, xform, opacity);
}
@ -200,18 +200,18 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
public static Vector4 DestOut(Vector4 backdrop, Vector4 source, float opacity)
{
opacity = opacity.Clamp(0, 1);
Vector4 xform = Vector4.Zero;
// calculate weights
float xw = backdrop.W * Vector4.Zero.W;
float xw = backdrop.W * source.W;
float bw = backdrop.W - xw;
float sw = Vector4.Zero.W - xw;
float sw = source.W - xw;
// calculate final alpha
float a = xw + bw + sw;
float fw = (sw * 0) + (bw * 1) + (xw * 0);
// calculate final value
xform = ((xform * xw) + (backdrop * bw) + (Vector4.Zero * sw)) / MathF.Max(a, Constants.Epsilon);
Vector4 xform = ((Vector4.Zero * xw) + (backdrop * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon);
xform.W = fw;
return Vector4.Lerp(backdrop, xform, opacity);
}
@ -220,18 +220,18 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
public static Vector4 Clear(Vector4 backdrop, Vector4 source, float opacity)
{
opacity = opacity.Clamp(0, 1);
Vector4 xform = Vector4.Zero;
// calculate weights
float xw = Vector4.Zero.W * Vector4.Zero.W;
float bw = Vector4.Zero.W - xw;
float sw = Vector4.Zero.W - xw;
float xw = backdrop.W * source.W;
float bw = backdrop.W - xw;
float sw = source.W - xw;
// calculate final alpha
float a = xw + bw + sw;
float fw = (sw * 0) + (bw * 0) + (xw * 0);
// calculate final value
xform = ((xform * xw) + (Vector4.Zero * bw) + (Vector4.Zero * sw)) / MathF.Max(a, Constants.Epsilon);
Vector4 xform = ((Vector4.Zero * xw) + (Vector4.Zero * bw) + (Vector4.Zero * sw)) / MathF.Max(fw, Constants.Epsilon);
xform.W = fw;
return Vector4.Lerp(backdrop, xform, opacity);
}
@ -240,8 +240,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
public static Vector4 Xor(Vector4 backdrop, Vector4 source, float opacity)
{
opacity = opacity.Clamp(0, 1);
source.W *= opacity;
Vector4 xform = Vector4.Zero;
source.W *= opacity;
// calculate weights
float xw = backdrop.W * source.W;
@ -249,10 +248,11 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
float sw = source.W - xw;
// calculate final alpha
float a = xw + bw + sw;
float fw = (sw * 1) + (bw * 1) + (xw * 0);
// calculate final value
xform = ((xform * xw) + (backdrop * bw) + (source * sw)) / MathF.Max(a, Constants.Epsilon);
Vector4 xform = ((Vector4.Zero * xw) + (backdrop * bw) + (source * sw)) / MathF.Max(fw, Constants.Epsilon);
xform.W = fw;
return Vector4.Lerp(backdrop, xform, opacity);
}
@ -285,11 +285,11 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPixel Substract<TPixel>(TPixel backdrop, TPixel source, float amount)
public static TPixel Subtract<TPixel>(TPixel backdrop, TPixel source, float amount)
where TPixel : struct, IPixel<TPixel>
{
TPixel dest = default(TPixel);
dest.PackFromVector4(Substract(backdrop.ToVector4(), source.ToVector4(), amount));
dest.PackFromVector4(Subtract(backdrop.ToVector4(), source.ToVector4(), amount));
return dest;
}

19
src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.Generated.tt

@ -40,26 +40,29 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
void GenerateVectorCompositor(string name, string sourceVar, string destVar, string blendVar)
{
int a_s = sourceVar == "Vector4.Zero" ? 0 : 1;
int a_b = destVar == "Vector4.Zero" ? 0 : 1;
int a_x = blendVar == "Vector4.Zero" ? 0 : 1;
#>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 <#=name#>(Vector4 backdrop, Vector4 source, float opacity)
{
opacity = opacity.Clamp(0, 1);
<# if(sourceVar != "Vector4.Zero" ) { #>
source.W *= opacity;
source.W *= opacity;
<# } #>
Vector4 xform = <#=blendVar#>;
// calculate weights
float xw = <#=destVar#>.W * <#=sourceVar#>.W;
float bw = <#=destVar#>.W - xw;
float sw = <#=sourceVar#>.W - xw;
float xw = backdrop.W * source.W;
float bw = backdrop.W - xw;
float sw = source.W - xw;
// calculate final alpha
float a = xw + bw + sw;
float fw = (sw * <#=a_s#>) + (bw * <#=a_b#>) + (xw * <#=a_x#>);
// calculate final value
xform = ((xform * xw) + (<#=destVar#> * bw) + (<#=sourceVar#> * sw)) / MathF.Max(a, Constants.Epsilon);
Vector4 xform = ((<#=blendVar#> * xw) + (<#=destVar#> * bw) + (<#=sourceVar#> * sw)) / MathF.Max(fw, Constants.Epsilon);
xform.W = fw;
return Vector4.Lerp(backdrop, xform, opacity);
}
@ -83,7 +86,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
GeneratePixelBlender("Normal");
GeneratePixelBlender("Multiply");
GeneratePixelBlender("Add");
GeneratePixelBlender("Substract");
GeneratePixelBlender("Subtract");
GeneratePixelBlender("Screen");
GeneratePixelBlender("Darken");
GeneratePixelBlender("Lighten");

24
src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs

@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <summary>
/// Source over backdrop
/// </summary>
/// <param name="backdrop">Backgrop color</param>
/// <param name="backdrop">Backdrop color</param>
/// <param name="source">Source color</param>
/// <param name="opacity">Opacity applied to Source Alpha</param>
/// <returns>Output color</returns>
@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <summary>
/// Source multiplied by backdrop
/// </summary>
/// <param name="backdrop">Backgrop color</param>
/// <param name="backdrop">Backdrop color</param>
/// <param name="source">Source color</param>
/// <param name="opacity">Opacity applied to Source Alpha</param>
/// <returns>Output color</returns>
@ -51,7 +51,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <summary>
/// Source added to backdrop
/// </summary>
/// <param name="backdrop">Backgrop color</param>
/// <param name="backdrop">Backdrop color</param>
/// <param name="source">Source color</param>
/// <param name="opacity">Opacity applied to Source Alpha</param>
/// <returns>Output color</returns>
@ -63,14 +63,14 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
}
/// <summary>
/// Source substracted from backdrop
/// Source subtracted from backdrop
/// </summary>
/// <param name="backdrop">Backgrop color</param>
/// <param name="backdrop">Backdrop color</param>
/// <param name="source">Source color</param>
/// <param name="opacity">Opacity applied to Source Alpha</param>
/// <returns>Output color</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 Substract(Vector4 backdrop, Vector4 source, float opacity)
public static Vector4 Subtract(Vector4 backdrop, Vector4 source, float opacity)
{
source.W *= opacity;
return Compose(backdrop, source, Vector4.Max(Vector4.Zero, backdrop - source));
@ -79,7 +79,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <summary>
/// Complement of source multiplied by the complement of backdrop
/// </summary>
/// <param name="backdrop">Backgrop color</param>
/// <param name="backdrop">Backdrop color</param>
/// <param name="source">Source color</param>
/// <param name="opacity">Opacity applied to Source Alpha</param>
/// <returns>Output color</returns>
@ -93,7 +93,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <summary>
/// Per element, chooses the smallest value of source and backdrop
/// </summary>
/// <param name="backdrop">Backgrop color</param>
/// <param name="backdrop">Backdrop color</param>
/// <param name="source">Source color</param>
/// <param name="opacity">Opacity applied to Source Alpha</param>
/// <returns>Output color</returns>
@ -107,7 +107,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <summary>
/// Per element, chooses the largest value of source and backdrop
/// </summary>
/// <param name="backdrop">Backgrop color</param>
/// <param name="backdrop">Backdrop color</param>
/// <param name="source">Source color</param>
/// <param name="opacity">Opacity applied to Source Alpha</param>
/// <returns>Output color</returns>
@ -121,7 +121,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <summary>
/// Overlays source over backdrop
/// </summary>
/// <param name="backdrop">Backgrop color</param>
/// <param name="backdrop">Backdrop color</param>
/// <param name="source">Source color</param>
/// <param name="opacity">Opacity applied to Source Alpha</param>
/// <returns>Output color</returns>
@ -139,7 +139,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <summary>
/// Hard light effect
/// </summary>
/// <param name="backdrop">Backgrop color</param>
/// <param name="backdrop">Backdrop color</param>
/// <param name="source">Source color</param>
/// <param name="opacity">Opacity applied to Source Alpha</param>
/// <returns>Output color</returns>
@ -169,7 +169,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
/// <summary>
/// General composition function for all modes, with a general solution for alpha channel
/// </summary>
/// <param name="backdrop">Original backgrop color</param>
/// <param name="backdrop">Original Backdrop color</param>
/// <param name="source">Original source color</param>
/// <param name="xform">Desired transformed color, without taking Alpha channel in account</param>
/// <returns>The final color</returns>

2
src/ImageSharp/PixelFormats/PixelOperations{TPixel}.PixelBenders.cs

@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.PixelFormats
{
case PixelBlenderMode.Multiply: return DefaultPixelBlenders<TPixel>.Multiply.Instance;
case PixelBlenderMode.Add: return DefaultPixelBlenders<TPixel>.Add.Instance;
case PixelBlenderMode.Substract: return DefaultPixelBlenders<TPixel>.Substract.Instance;
case PixelBlenderMode.Subtract: return DefaultPixelBlenders<TPixel>.Subtract.Instance;
case PixelBlenderMode.Screen: return DefaultPixelBlenders<TPixel>.Screen.Instance;
case PixelBlenderMode.Darken: return DefaultPixelBlenders<TPixel>.Darken.Instance;
case PixelBlenderMode.Lighten: return DefaultPixelBlenders<TPixel>.Lighten.Instance;

12
src/ImageSharp/Processing/Overlays/BackgroundColorExtensions.cs

@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Processing.Overlays
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> BackgroundColor<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color)
where TPixel : struct, IPixel<TPixel>
=> BackgroundColor(source, color, GraphicsOptions.Default);
=> BackgroundColor(source, GraphicsOptions.Default, color);
/// <summary>
/// Replaces the background color of image with the given one.
@ -35,17 +35,17 @@ namespace SixLabors.ImageSharp.Processing.Overlays
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> BackgroundColor<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
=> BackgroundColor(source, color, rectangle, GraphicsOptions.Default);
=> BackgroundColor(source, GraphicsOptions.Default, color, rectangle);
/// <summary>
/// Replaces the background color of image with the given one.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="color">The color to set as the background.</param>
/// <param name="options">The options effecting pixel blending.</param>
/// <param name="color">The color to set as the background.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> BackgroundColor<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, GraphicsOptions options)
public static IImageProcessingContext<TPixel> BackgroundColor<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, TPixel color)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new BackgroundColorProcessor<TPixel>(color, options));
@ -54,13 +54,13 @@ namespace SixLabors.ImageSharp.Processing.Overlays
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options effecting pixel blending.</param>
/// <param name="color">The color to set as the background.</param>
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="options">The options effecting pixel blending.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> BackgroundColor<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, Rectangle rectangle, GraphicsOptions options)
public static IImageProcessingContext<TPixel> BackgroundColor<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, TPixel color, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new BackgroundColorProcessor<TPixel>(color, options), rectangle);
}

44
src/ImageSharp/Processing/Overlays/GlowExtensions.cs

@ -33,7 +33,7 @@ namespace SixLabors.ImageSharp.Processing.Overlays
public static IImageProcessingContext<TPixel> Glow<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color)
where TPixel : struct, IPixel<TPixel>
{
return Glow(source, color, GraphicsOptions.Default);
return Glow(source, GraphicsOptions.Default, color);
}
/// <summary>
@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.Processing.Overlays
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Glow<TPixel>(this IImageProcessingContext<TPixel> source, float radius)
where TPixel : struct, IPixel<TPixel>
=> Glow(source, radius, GraphicsOptions.Default);
=> Glow(source, GraphicsOptions.Default, radius);
/// <summary>
/// Applies a radial glow effect to an image.
@ -58,7 +58,7 @@ namespace SixLabors.ImageSharp.Processing.Overlays
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Glow<TPixel>(this IImageProcessingContext<TPixel> source, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
=> source.Glow(rectangle, GraphicsOptions.Default);
=> source.Glow(GraphicsOptions.Default, rectangle);
/// <summary>
/// Applies a radial glow effect to an image.
@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.Processing.Overlays
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Glow<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, float radius, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
=> source.Glow(color, ValueSize.Absolute(radius), rectangle, GraphicsOptions.Default);
=> source.Glow(GraphicsOptions.Default, color, ValueSize.Absolute(radius), rectangle);
/// <summary>
/// Applies a radial glow effect to an image.
@ -84,75 +84,75 @@ namespace SixLabors.ImageSharp.Processing.Overlays
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Glow<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
=> source.Glow(NamedColors<TPixel>.Black, ValueSize.PercentageOfWidth(0.5f), options);
=> source.Glow(options, NamedColors<TPixel>.Black, ValueSize.PercentageOfWidth(0.5f));
/// <summary>
/// Applies a radial glow effect to an image.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="color">The color to set as the glow.</param>
/// <param name="options">The options effecting things like blending.</param>
/// <param name="color">The color to set as the glow.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Glow<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, GraphicsOptions options)
public static IImageProcessingContext<TPixel> Glow<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, TPixel color)
where TPixel : struct, IPixel<TPixel>
=> source.Glow(color, ValueSize.PercentageOfWidth(0.5f), options);
=> source.Glow(options, color, ValueSize.PercentageOfWidth(0.5f));
/// <summary>
/// Applies a radial glow effect to an image.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="radius">The the radius.</param>
/// <param name="options">The options effecting things like blending.</param>
/// <param name="radius">The the radius.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Glow<TPixel>(this IImageProcessingContext<TPixel> source, float radius, GraphicsOptions options)
public static IImageProcessingContext<TPixel> Glow<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, float radius)
where TPixel : struct, IPixel<TPixel>
=> source.Glow(NamedColors<TPixel>.Black, ValueSize.Absolute(radius), options);
=> source.Glow(options, NamedColors<TPixel>.Black, ValueSize.Absolute(radius));
/// <summary>
/// Applies a radial glow effect to an image.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options effecting things like blending.</param>
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="options">The options effecting things like blending.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Glow<TPixel>(this IImageProcessingContext<TPixel> source, Rectangle rectangle, GraphicsOptions options)
public static IImageProcessingContext<TPixel> Glow<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
=> source.Glow(NamedColors<TPixel>.Black, ValueSize.PercentageOfWidth(0.5f), rectangle, options);
=> source.Glow(options, NamedColors<TPixel>.Black, ValueSize.PercentageOfWidth(0.5f), rectangle);
/// <summary>
/// Applies a radial glow effect to an image.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options effecting things like blending.</param>
/// <param name="color">The color to set as the glow.</param>
/// <param name="radius">The the radius.</param>
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="options">The options effecting things like blending.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Glow<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, float radius, Rectangle rectangle, GraphicsOptions options)
public static IImageProcessingContext<TPixel> Glow<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, TPixel color, float radius, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
=> source.Glow(color, ValueSize.Absolute(radius), rectangle, options);
=> source.Glow(options, color, ValueSize.Absolute(radius), rectangle);
/// <summary>
/// Applies a radial glow effect to an image.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options effecting things like blending.</param>
/// <param name="color">The color to set as the glow.</param>
/// <param name="radius">The the radius.</param>
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="options">The options effecting things like blending.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
private static IImageProcessingContext<TPixel> Glow<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, ValueSize radius, Rectangle rectangle, GraphicsOptions options)
private static IImageProcessingContext<TPixel> Glow<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, TPixel color, ValueSize radius, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new GlowProcessor<TPixel>(color, radius, options), rectangle);
@ -161,12 +161,12 @@ namespace SixLabors.ImageSharp.Processing.Overlays
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options effecting things like blending.</param>
/// <param name="color">The color to set as the glow.</param>
/// <param name="radius">The the radius.</param>
/// <param name="options">The options effecting things like blending.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
private static IImageProcessingContext<TPixel> Glow<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, ValueSize radius, GraphicsOptions options)
private static IImageProcessingContext<TPixel> Glow<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, TPixel color, ValueSize radius)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new GlowProcessor<TPixel>(color, radius, options));
}
}
}

38
src/ImageSharp/Processing/Overlays/VignetteExtensions.cs

@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp.Processing.Overlays
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Vignette<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color)
where TPixel : struct, IPixel<TPixel>
=> Vignette(source, color, GraphicsOptions.Default);
=> Vignette(source, GraphicsOptions.Default, color);
/// <summary>
/// Applies a radial vignette effect to an image.
@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.Processing.Overlays
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Vignette<TPixel>(this IImageProcessingContext<TPixel> source, float radiusX, float radiusY)
where TPixel : struct, IPixel<TPixel>
=> Vignette(source, radiusX, radiusY, GraphicsOptions.Default);
=> Vignette(source, GraphicsOptions.Default, radiusX, radiusY);
/// <summary>
/// Applies a radial vignette effect to an image.
@ -57,7 +57,7 @@ namespace SixLabors.ImageSharp.Processing.Overlays
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Vignette<TPixel>(this IImageProcessingContext<TPixel> source, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
=> Vignette(source, rectangle, GraphicsOptions.Default);
=> Vignette(source, GraphicsOptions.Default, rectangle);
/// <summary>
/// Applies a radial vignette effect to an image.
@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.Processing.Overlays
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Vignette<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, float radiusX, float radiusY, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
=> source.Vignette(color, radiusX, radiusY, rectangle, GraphicsOptions.Default);
=> source.Vignette(GraphicsOptions.Default, color, radiusX, radiusY, rectangle);
/// <summary>
/// Applies a radial vignette effect to an image.
@ -84,69 +84,69 @@ namespace SixLabors.ImageSharp.Processing.Overlays
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Vignette<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
=> source.VignetteInternal(NamedColors<TPixel>.Black, ValueSize.PercentageOfWidth(.5f), ValueSize.PercentageOfHeight(.5f), options);
=> source.VignetteInternal(options, NamedColors<TPixel>.Black, ValueSize.PercentageOfWidth(.5f), ValueSize.PercentageOfHeight(.5f));
/// <summary>
/// Applies a radial vignette effect to an image.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="color">The color to set as the vignette.</param>
/// <param name="options">The options effecting pixel blending.</param>
/// <param name="color">The color to set as the vignette.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Vignette<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, GraphicsOptions options)
public static IImageProcessingContext<TPixel> Vignette<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, TPixel color)
where TPixel : struct, IPixel<TPixel>
=> source.VignetteInternal(color, ValueSize.PercentageOfWidth(.5f), ValueSize.PercentageOfHeight(.5f), options);
=> source.VignetteInternal(options, color, ValueSize.PercentageOfWidth(.5f), ValueSize.PercentageOfHeight(.5f));
/// <summary>
/// Applies a radial vignette effect to an image.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options effecting pixel blending.</param>
/// <param name="radiusX">The the x-radius.</param>
/// <param name="radiusY">The the y-radius.</param>
/// <param name="options">The options effecting pixel blending.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Vignette<TPixel>(this IImageProcessingContext<TPixel> source, float radiusX, float radiusY, GraphicsOptions options)
public static IImageProcessingContext<TPixel> Vignette<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, float radiusX, float radiusY)
where TPixel : struct, IPixel<TPixel>
=> source.VignetteInternal(NamedColors<TPixel>.Black, radiusX, radiusY, options);
=> source.VignetteInternal(options, NamedColors<TPixel>.Black, radiusX, radiusY);
/// <summary>
/// Applies a radial vignette effect to an image.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options effecting pixel blending.</param>
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="options">The options effecting pixel blending.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Vignette<TPixel>(this IImageProcessingContext<TPixel> source, Rectangle rectangle, GraphicsOptions options)
public static IImageProcessingContext<TPixel> Vignette<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
=> source.VignetteInternal(NamedColors<TPixel>.Black, ValueSize.PercentageOfWidth(.5f), ValueSize.PercentageOfHeight(.5f), rectangle, options);
=> source.VignetteInternal(options, NamedColors<TPixel>.Black, ValueSize.PercentageOfWidth(.5f), ValueSize.PercentageOfHeight(.5f), rectangle);
/// <summary>
/// Applies a radial vignette effect to an image.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="options">The options effecting pixel blending.</param>
/// <param name="color">The color to set as the vignette.</param>
/// <param name="radiusX">The the x-radius.</param>
/// <param name="radiusY">The the y-radius.</param>
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="options">The options effecting pixel blending.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Vignette<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, float radiusX, float radiusY, Rectangle rectangle, GraphicsOptions options)
public static IImageProcessingContext<TPixel> Vignette<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, TPixel color, float radiusX, float radiusY, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
=> source.VignetteInternal(color, radiusX, radiusY, rectangle, options);
=> source.VignetteInternal(options, color, radiusX, radiusY, rectangle);
private static IImageProcessingContext<TPixel> VignetteInternal<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, ValueSize radiusX, ValueSize radiusY, Rectangle rectangle, GraphicsOptions options)
private static IImageProcessingContext<TPixel> VignetteInternal<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, TPixel color, ValueSize radiusX, ValueSize radiusY, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new VignetteProcessor<TPixel>(color, radiusX, radiusY, options), rectangle);
private static IImageProcessingContext<TPixel> VignetteInternal<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, ValueSize radiusX, ValueSize radiusY, GraphicsOptions options)
private static IImageProcessingContext<TPixel> VignetteInternal<TPixel>(this IImageProcessingContext<TPixel> source, GraphicsOptions options, TPixel color, ValueSize radiusX, ValueSize radiusY)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new VignetteProcessor<TPixel>(color, radiusX, radiusY, options));
}

31
tests/ImageSharp.Tests/Drawing/BlendedShapes.cs

@ -29,10 +29,8 @@ namespace SixLabors.ImageSharp.Tests.Drawing
var scaleY = (img.Height / 100);
img.Mutate(x => x
.Fill(NamedColors<TPixel>.DarkBlue, new Rectangle(0 * scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY))
.Fill(NamedColors<TPixel>.HotPink, new Rectangle(20 * scaleX, 0 * scaleY, 30 * scaleX, 100 * scaleY), new ImageSharp.GraphicsOptions(true)
{
BlenderMode = mode
}));
.Fill(new GraphicsOptions(true) { BlenderMode = mode }, NamedColors<TPixel>.HotPink, new Rectangle(20 * scaleX, 0 * scaleY, 30 * scaleX, 100 * scaleY)
));
img.DebugSave(provider, new { mode });
}
}
@ -47,14 +45,8 @@ namespace SixLabors.ImageSharp.Tests.Drawing
var scaleX = (img.Width / 100);
var scaleY = (img.Height / 100);
img.Mutate(x => x.Fill(NamedColors<TPixel>.DarkBlue, new Rectangle(0 * scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY)));
img.Mutate(x => x.Fill(NamedColors<TPixel>.HotPink, new Rectangle(20 * scaleX, 0 * scaleY, 30 * scaleX, 100 * scaleY), new ImageSharp.GraphicsOptions(true)
{
BlenderMode = mode
}));
img.Mutate(x => x.Fill(NamedColors<TPixel>.Transparent, new SixLabors.Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY), new ImageSharp.GraphicsOptions(true)
{
BlenderMode = mode
}));
img.Mutate(x => x.Fill(new GraphicsOptions(true) { BlenderMode = mode }, NamedColors<TPixel>.HotPink, new Rectangle(20 * scaleX, 0 * scaleY, 30 * scaleX, 100 * scaleY)));
img.Mutate(x => x.Fill(new GraphicsOptions(true) { BlenderMode = mode }, NamedColors<TPixel>.Transparent, new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY)));
img.DebugSave(provider, new { mode });
}
}
@ -69,19 +61,13 @@ namespace SixLabors.ImageSharp.Tests.Drawing
var scaleX = (img.Width / 100);
var scaleY = (img.Height / 100);
img.Mutate(x => x.Fill(NamedColors<TPixel>.DarkBlue, new Rectangle(0 * scaleX, 40, 100 * scaleX, 20 * scaleY)));
img.Mutate(x => x.Fill(NamedColors<TPixel>.HotPink, new Rectangle(20 * scaleX, 0, 30 * scaleX, 100 * scaleY), new ImageSharp.GraphicsOptions(true)
{
BlenderMode = mode
}));
img.Mutate(x => x.Fill(new GraphicsOptions(true) { BlenderMode = mode }, NamedColors<TPixel>.HotPink, new Rectangle(20 * scaleX, 0, 30 * scaleX, 100 * scaleY)));
var c = NamedColors<TPixel>.Red.ToVector4();
c.W *= 0.5f;
TPixel pixel = default(TPixel);
pixel.PackFromVector4(c);
img.Mutate(x => x.Fill(pixel, new SixLabors.Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY), new ImageSharp.GraphicsOptions(true)
{
BlenderMode = mode
}));
img.Mutate(x => x.Fill(new GraphicsOptions(true) { BlenderMode = mode }, pixel, new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY)));
img.DebugSave(provider, new { mode });
}
}
@ -98,10 +84,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
var scaleX = (img.Width / 100);
var scaleY = (img.Height / 100);
img.Mutate(x => x.Fill(NamedColors<TPixel>.DarkBlue, new Rectangle(0 * scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY)));
img.Mutate(x => x.Fill(NamedColors<TPixel>.Black, new SixLabors.Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY), new ImageSharp.GraphicsOptions(true)
{
BlenderMode = mode
}));
img.Mutate(x => x.Fill(new GraphicsOptions(true) { BlenderMode = mode }, NamedColors<TPixel>.Black, new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY)));
img.DebugSave(provider, new { mode });
}
}

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

@ -28,7 +28,7 @@ namespace SixLabors.ImageSharp.Tests
[WithFileCollection(nameof(TestFiles), PixelTypes, PixelBlenderMode.Normal)]
[WithFileCollection(nameof(TestFiles), PixelTypes, PixelBlenderMode.Multiply)]
[WithFileCollection(nameof(TestFiles), PixelTypes, PixelBlenderMode.Add)]
[WithFileCollection(nameof(TestFiles), PixelTypes, PixelBlenderMode.Substract)]
[WithFileCollection(nameof(TestFiles), PixelTypes, PixelBlenderMode.Subtract)]
[WithFileCollection(nameof(TestFiles), PixelTypes, PixelBlenderMode.Screen)]
[WithFileCollection(nameof(TestFiles), PixelTypes, PixelBlenderMode.Darken)]
[WithFileCollection(nameof(TestFiles), PixelTypes, PixelBlenderMode.Lighten)]

16
tests/ImageSharp.Tests/Drawing/LineTests.cs

@ -50,13 +50,15 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{
image.Mutate(x => x
.BackgroundColor(Rgba32.Blue)
.DrawLines(Rgba32.HotPink, 5,
new SixLabors.Primitives.PointF[] {
new Vector2(10, 10),
new Vector2(200, 150),
new Vector2(50, 300)
},
new GraphicsOptions(false)));
.DrawLines(
new GraphicsOptions(false),
Rgba32.HotPink,
5,
new SixLabors.Primitives.PointF[] {
new Vector2(10, 10),
new Vector2(200, 150),
new Vector2(50, 300)
}));
image.Save($"{path}/Simple_noantialias.png");
using (PixelAccessor<Rgba32> sourcePixels = image.Lock())

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

@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
[Fact]
public void CorrectlySetsBrushPathOptions()
{
this.operations.Fill(this.brush, this.path, this.noneDefault);
this.operations.Fill(this.noneDefault, this.brush, this.path);
var processor = this.Verify<FillRegionProcessor<Rgba32>>();
Assert.Equal(this.noneDefault, processor.Options);
@ -75,7 +75,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
[Fact]
public void CorrectlySetsColorPathAndOptions()
{
this.operations.Fill(this.color, this.path, this.noneDefault);
this.operations.Fill(this.noneDefault, this.color, this.path);
var processor = this.Verify<FillRegionProcessor<Rgba32>>();
Assert.Equal(this.noneDefault, processor.Options);

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

@ -31,7 +31,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
}));
IPathCollection pathCollection;
public FillPathCollection()
{
this.pathCollection = new PathCollection(this.path1, this.path2);
@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
[Fact]
public void CorrectlySetsBrushPathOptions()
{
this.operations.Fill(this.brush, this.pathCollection, this.noneDefault);
this.operations.Fill(this.noneDefault, this.brush, this.pathCollection);
for (int i = 0; i < 2; i++)
{
@ -100,7 +100,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
[Fact]
public void CorrectlySetsColorPathAndOptions()
{
this.operations.Fill(this.color, this.pathCollection, this.noneDefault);
this.operations.Fill(this.noneDefault, this.color, this.pathCollection);
for (int i = 0; i < 2; i++)
{

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

@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
[Fact]
public void CorrectlySetsBrushPathAndOptions()
{
this.operations.FillPolygon(this.brush, this.path, this.noneDefault);
this.operations.FillPolygon(this.noneDefault, this.brush, this.path);
FillRegionProcessor<Rgba32> processor = this.Verify<FillRegionProcessor<Rgba32>>();
Assert.Equal(this.noneDefault, processor.Options);
@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
[Fact]
public void CorrectlySetsColorPathAndOptions()
{
this.operations.FillPolygon(this.color, this.path, this.noneDefault);
this.operations.FillPolygon(this.noneDefault, this.color, this.path);
FillRegionProcessor<Rgba32> processor = this.Verify<FillRegionProcessor<Rgba32>>();

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

@ -38,7 +38,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
[Fact]
public void CorrectlySetsBrushRectangleAndOptions()
{
this.operations.Fill(this.brush, this.rectangle, this.noneDefault);
this.operations.Fill(this.noneDefault, this.brush, this.rectangle);
FillRegionProcessor<Rgba32> processor = this.Verify<FillRegionProcessor<Rgba32>>();
Assert.Equal(this.noneDefault, processor.Options);
@ -75,7 +75,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
[Fact]
public void CorrectlySetsColorRectangleAndOptions()
{
this.operations.Fill(this.color, this.rectangle, this.noneDefault);
this.operations.Fill(this.noneDefault, this.color, this.rectangle);
FillRegionProcessor<Rgba32> processor = this.Verify<FillRegionProcessor<Rgba32>>();
Assert.Equal(this.noneDefault, processor.Options);

6
tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs

@ -29,7 +29,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
using (var image = new Image<Rgba32>(500, 500))
{
image.Mutate(x => x
.FillPolygon(Rgba32.HotPink, simplePath, new GraphicsOptions(true)));
.FillPolygon(new GraphicsOptions(true), Rgba32.HotPink, simplePath));
image.Save($"{path}/Simple.png");
using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
@ -52,7 +52,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
using (var image = new Image<Rgba32>(500, 500))
{
image.Mutate(x => x
.FillPolygon(Brushes.Horizontal(Rgba32.HotPink), simplePath, new GraphicsOptions(true)));
.FillPolygon(new GraphicsOptions(true), Brushes.Horizontal(Rgba32.HotPink), simplePath));
image.Save($"{path}/Pattern.png");
using (PixelAccessor<Rgba32> sourcePixels = image.Lock())
@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{
image.Mutate(x => x
.BackgroundColor(Rgba32.Blue)
.FillPolygon(Rgba32.HotPink, simplePath, new GraphicsOptions(false)));
.FillPolygon(new GraphicsOptions(false), Rgba32.HotPink, simplePath));
image.Save($"{path}/Simple_NoAntialias.png");
using (PixelAccessor<Rgba32> sourcePixels = image.Lock())

22
tests/ImageSharp.Tests/Drawing/Text/DrawText.Path.cs

@ -37,12 +37,12 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
public void FillsForEachACharachterWhenBrushSetAndNotPen()
{
this.operations.DrawText(
new TextGraphicsOptions(true),
"123",
this.Font,
Brushes.Solid(Rgba32.Red),
null,
this.path,
new TextGraphicsOptions(true));
this.path);
this.Verify<FillRegionProcessor<Rgba32>>(0);
this.Verify<FillRegionProcessor<Rgba32>>(1);
@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
[Fact]
public void FillsForEachACharachterWhenBrushSet()
{
this.operations.DrawText("123", this.Font, Brushes.Solid(Rgba32.Red), this.path, new TextGraphicsOptions(true));
this.operations.DrawText(new TextGraphicsOptions(true), "123", this.Font, Brushes.Solid(Rgba32.Red), this.path);
this.Verify<FillRegionProcessor<Rgba32>>(0);
this.Verify<FillRegionProcessor<Rgba32>>(1);
@ -82,7 +82,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
[Fact]
public void FillsForEachACharachterWhenColorSet()
{
this.operations.DrawText("123", this.Font, Rgba32.Red, this.path, new TextGraphicsOptions(true));
this.operations.DrawText(new TextGraphicsOptions(true), "123", this.Font, Rgba32.Red, this.path);
var processor = this.Verify<FillRegionProcessor<Rgba32>>(0);
this.Verify<FillRegionProcessor<Rgba32>>(1);
@ -109,12 +109,12 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
public void DrawForEachACharachterWhenPenSetAndNotBrush()
{
this.operations.DrawText(
new TextGraphicsOptions(true),
"123",
this.Font,
null,
Pens.Dash(Rgba32.Red, 1),
this.path,
new TextGraphicsOptions(true));
this.path);
var processor = this.Verify<FillRegionProcessor<Rgba32>>(0);
this.Verify<FillRegionProcessor<Rgba32>>(1);
@ -134,7 +134,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
[Fact]
public void DrawForEachACharachterWhenPenSet()
{
this.operations.DrawText("123", this.Font, Pens.Dash(Rgba32.Red, 1), this.path, new TextGraphicsOptions(true));
this.operations.DrawText(new TextGraphicsOptions(true), "123", this.Font, Pens.Dash(Rgba32.Red, 1), this.path);
var processor = this.Verify<FillRegionProcessor<Rgba32>>(0);
this.Verify<FillRegionProcessor<Rgba32>>(1);
@ -155,12 +155,12 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
public void DrawForEachACharachterWhenPenSetAndFillFroEachWhenBrushSet()
{
this.operations.DrawText(
new TextGraphicsOptions(true),
"123",
this.Font,
Brushes.Solid(Rgba32.Red),
Pens.Dash(Rgba32.Red, 1),
this.path,
new TextGraphicsOptions(true));
this.path);
var processor = this.Verify<FillRegionProcessor<Rgba32>>(0);
this.Verify<FillRegionProcessor<Rgba32>>(1);
@ -187,12 +187,12 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
public void BrushAppliesBeforPen()
{
this.operations.DrawText(
new TextGraphicsOptions(true),
"1",
this.Font,
Brushes.Solid(Rgba32.Red),
Pens.Dash(Rgba32.Red, 1),
this.path,
new TextGraphicsOptions(true));
this.path);
var processor = this.Verify<FillRegionProcessor<Rgba32>>(0);
this.Verify<FillRegionProcessor<Rgba32>>(1);

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

@ -37,12 +37,12 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
public void FillsForEachACharachterWhenBrushSetAndNotPen()
{
this.operations.DrawText(
new TextGraphicsOptions(true),
"123",
this.Font,
Brushes.Solid(Rgba32.Red),
null,
Vector2.Zero,
new TextGraphicsOptions(true));
Vector2.Zero);
this.Verify<FillRegionProcessor<Rgba32>>(0);
this.Verify<FillRegionProcessor<Rgba32>>(1);
@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
[Fact]
public void FillsForEachACharachterWhenBrushSet()
{
this.operations.DrawText("123", this.Font, Brushes.Solid(Rgba32.Red), Vector2.Zero, new TextGraphicsOptions(true));
this.operations.DrawText(new TextGraphicsOptions(true), "123", this.Font, Brushes.Solid(Rgba32.Red), Vector2.Zero);
this.Verify<FillRegionProcessor<Rgba32>>(0);
this.Verify<FillRegionProcessor<Rgba32>>(1);
@ -82,7 +82,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
[Fact]
public void FillsForEachACharachterWhenColorSet()
{
this.operations.DrawText("123", this.Font, Rgba32.Red, Vector2.Zero, new TextGraphicsOptions(true));
this.operations.DrawText(new TextGraphicsOptions(true), "123", this.Font, Rgba32.Red, Vector2.Zero);
var processor = this.Verify<FillRegionProcessor<Rgba32>>(0);
this.Verify<FillRegionProcessor<Rgba32>>(1);
@ -109,12 +109,12 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
public void DrawForEachACharachterWhenPenSetAndNotBrush()
{
this.operations.DrawText(
new TextGraphicsOptions(true),
"123",
this.Font,
null,
Pens.Dash(Rgba32.Red, 1),
Vector2.Zero,
new TextGraphicsOptions(true));
Vector2.Zero);
var processor = this.Verify<FillRegionProcessor<Rgba32>>(0);
this.Verify<FillRegionProcessor<Rgba32>>(1);
@ -134,7 +134,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
[Fact]
public void DrawForEachACharachterWhenPenSet()
{
this.operations.DrawText("123", this.Font, Pens.Dash(Rgba32.Red, 1), Vector2.Zero, new TextGraphicsOptions(true));
this.operations.DrawText(new TextGraphicsOptions(true), "123", this.Font, Pens.Dash(Rgba32.Red, 1), Vector2.Zero);
var processor = this.Verify<FillRegionProcessor<Rgba32>>(0);
this.Verify<FillRegionProcessor<Rgba32>>(1);
@ -155,12 +155,12 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
public void DrawForEachACharachterWhenPenSetAndFillFroEachWhenBrushSet()
{
this.operations.DrawText(
new TextGraphicsOptions(true),
"123",
this.Font,
Brushes.Solid(Rgba32.Red),
Pens.Dash(Rgba32.Red, 1),
Vector2.Zero,
new TextGraphicsOptions(true));
Vector2.Zero);
var processor = this.Verify<FillRegionProcessor<Rgba32>>(0);
this.Verify<FillRegionProcessor<Rgba32>>(1);
@ -188,12 +188,12 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
public void BrushAppliesBeforePen()
{
this.operations.DrawText(
new TextGraphicsOptions(true),
"1",
this.Font,
Brushes.Solid(Rgba32.Red),
Pens.Dash(Rgba32.Red, 1),
Vector2.Zero,
new TextGraphicsOptions(true));
Vector2.Zero);
var processor = this.Verify<FillRegionProcessor<Rgba32>>(0);
this.Verify<FillRegionProcessor<Rgba32>>(1);

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

@ -22,24 +22,24 @@ namespace SixLabors.ImageSharp.Tests.Issues
for (var i = 0; i < 40; ++i)
{
context.DrawLines(
new GraphicsOptions(false),
NamedColors<TPixel>.Black,
1,
new[]
{
new PointF(i, 0.1066f),
new PointF(i, 10.1066f)
},
new GraphicsOptions(true));
});
context.DrawLines(
new GraphicsOptions(false),
NamedColors<TPixel>.Red,
1,
new[]
{
new PointF(i, 15.1066f),
new PointF(i, 25.1066f)
},
new GraphicsOptions(false));
});
}
});

48
tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffCompositorTests.cs

@ -0,0 +1,48 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders
{
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Drawing;
using Xunit;
public class PorterDuffCompositorTests
{
// TODO: Add other modes to compare.
public static readonly TheoryData<PixelBlenderMode> CompositingOperators =
new TheoryData<PixelBlenderMode>
{
PixelBlenderMode.Src,
PixelBlenderMode.Atop,
PixelBlenderMode.Over,
PixelBlenderMode.In,
PixelBlenderMode.Out,
PixelBlenderMode.Dest,
PixelBlenderMode.DestAtop,
PixelBlenderMode.DestOver,
PixelBlenderMode.DestIn,
PixelBlenderMode.DestOut,
PixelBlenderMode.Clear,
PixelBlenderMode.Xor
};
[Theory]
[WithFile(TestImages.Png.PDDest, nameof(CompositingOperators), PixelTypes.Rgba32)]
public void PorterDuffOutputIsCorrect(TestImageProvider<Rgba32> provider, PixelBlenderMode mode)
{
var srcFile = TestFile.Create(TestImages.Png.PDSrc);
using (Image<Rgba32> src = srcFile.CreateImage())
using (Image<Rgba32> dest = provider.GetImage())
{
using (Image<Rgba32> res = dest.Clone(x => x.DrawImage(new GraphicsOptions { BlenderMode = mode }, src)))
{
res.DebugSave(provider, mode.ToString());
res.CompareToReferenceOutput(provider, mode.ToString());
}
}
}
}
}

2
tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs

@ -79,7 +79,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders
[MemberData(nameof(SubstractFunctionData))]
public void SubstractFunction(TestVector4 back, TestVector4 source, float amount, TestVector4 expected)
{
Vector4 actual = PorterDuffFunctions.Substract((Vector4)back, source, amount);
Vector4 actual = PorterDuffFunctions.Subtract((Vector4)back, source, amount);
VectorAssert.Equal(expected, actual, 5);
}

6
tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests_TPixel.cs

@ -151,7 +151,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders
public void SubstractFunction<TPixel>(TestPixel<TPixel> back, TestPixel<TPixel> source, float amount, TestPixel<TPixel> expected)
where TPixel : struct, IPixel<TPixel>
{
TPixel actual = PorterDuffFunctions.Substract((TPixel)back, source, amount);
TPixel actual = PorterDuffFunctions.Subtract((TPixel)back, source, amount);
VectorAssert.Equal(expected, actual, 2);
}
@ -160,7 +160,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders
public void SubstractFunction_Blender<TPixel>(TestPixel<TPixel> back, TestPixel<TPixel> source, float amount, TestPixel<TPixel> expected)
where TPixel : struct, IPixel<TPixel>
{
TPixel actual = new DefaultPixelBlenders<TPixel>.Substract().Blend(back, source, amount);
TPixel actual = new DefaultPixelBlenders<TPixel>.Subtract().Blend(back, source, amount);
VectorAssert.Equal(expected, actual, 2);
}
@ -170,7 +170,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders
where TPixel : struct, IPixel<TPixel>
{
Span<TPixel> dest = new Span<TPixel>(new TPixel[1]);
new DefaultPixelBlenders<TPixel>.Substract().Blend(this.MemoryManager, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount));
new DefaultPixelBlenders<TPixel>.Subtract().Blend(this.MemoryManager, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount));
VectorAssert.Equal(expected, dest[0], 2);
}

88
tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.Blender.cs

@ -16,53 +16,53 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
public static TheoryData<object, Type, PixelBlenderMode> BlenderMappings = new TheoryData<object, Type, PixelBlenderMode>()
{
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Normal), PixelBlenderMode.Normal },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Screen), PixelBlenderMode.Screen },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.HardLight), PixelBlenderMode.HardLight },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Overlay), PixelBlenderMode.Overlay },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Darken), PixelBlenderMode.Darken },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Lighten), PixelBlenderMode.Lighten },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Add), PixelBlenderMode.Add },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Substract), PixelBlenderMode.Substract },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Multiply), PixelBlenderMode.Multiply },
{
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Normal), PixelBlenderMode.Normal },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Screen), PixelBlenderMode.Screen },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.HardLight), PixelBlenderMode.HardLight },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Overlay), PixelBlenderMode.Overlay },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Darken), PixelBlenderMode.Darken },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Lighten), PixelBlenderMode.Lighten },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Add), PixelBlenderMode.Add },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Subtract), PixelBlenderMode.Subtract },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Multiply), PixelBlenderMode.Multiply },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Src), PixelBlenderMode.Src },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Atop), PixelBlenderMode.Atop },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Over), PixelBlenderMode.Over },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.In), PixelBlenderMode.In },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Out), PixelBlenderMode.Out },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Dest), PixelBlenderMode.Dest },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.DestAtop), PixelBlenderMode.DestAtop },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.DestOver), PixelBlenderMode.DestOver },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.DestIn), PixelBlenderMode.DestIn },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.DestOut), PixelBlenderMode.DestOut },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Clear), PixelBlenderMode.Clear },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Xor), PixelBlenderMode.Xor },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Src), PixelBlenderMode.Src },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Atop), PixelBlenderMode.Atop },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Over), PixelBlenderMode.Over },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.In), PixelBlenderMode.In },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Out), PixelBlenderMode.Out },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Dest), PixelBlenderMode.Dest },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.DestAtop), PixelBlenderMode.DestAtop },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.DestOver), PixelBlenderMode.DestOver },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.DestIn), PixelBlenderMode.DestIn },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.DestOut), PixelBlenderMode.DestOut },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Clear), PixelBlenderMode.Clear },
{ new TestPixel<Rgba32>(), typeof(DefaultPixelBlenders<Rgba32>.Xor), PixelBlenderMode.Xor },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Normal), PixelBlenderMode.Normal },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Screen), PixelBlenderMode.Screen },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.HardLight), PixelBlenderMode.HardLight },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Overlay), PixelBlenderMode.Overlay },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Darken), PixelBlenderMode.Darken },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Lighten), PixelBlenderMode.Lighten },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Add), PixelBlenderMode.Add },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Substract), PixelBlenderMode.Substract },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Multiply), PixelBlenderMode.Multiply },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Src), PixelBlenderMode.Src },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Atop), PixelBlenderMode.Atop },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Over), PixelBlenderMode.Over },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.In), PixelBlenderMode.In },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Out), PixelBlenderMode.Out },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Dest), PixelBlenderMode.Dest },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.DestAtop), PixelBlenderMode.DestAtop },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.DestOver), PixelBlenderMode.DestOver },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.DestIn), PixelBlenderMode.DestIn },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.DestOut), PixelBlenderMode.DestOut },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Clear), PixelBlenderMode.Clear },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Xor), PixelBlenderMode.Xor },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Normal), PixelBlenderMode.Normal },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Screen), PixelBlenderMode.Screen },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.HardLight), PixelBlenderMode.HardLight },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Overlay), PixelBlenderMode.Overlay },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Darken), PixelBlenderMode.Darken },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Lighten), PixelBlenderMode.Lighten },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Add), PixelBlenderMode.Add },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Subtract), PixelBlenderMode.Subtract },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Multiply), PixelBlenderMode.Multiply },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Src), PixelBlenderMode.Src },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Atop), PixelBlenderMode.Atop },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Over), PixelBlenderMode.Over },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.In), PixelBlenderMode.In },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Out), PixelBlenderMode.Out },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Dest), PixelBlenderMode.Dest },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.DestAtop), PixelBlenderMode.DestAtop },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.DestOver), PixelBlenderMode.DestOver },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.DestIn), PixelBlenderMode.DestIn },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.DestOut), PixelBlenderMode.DestOut },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Clear), PixelBlenderMode.Clear },
{ new TestPixel<RgbaVector>(), typeof(DefaultPixelBlenders<RgbaVector>.Xor), PixelBlenderMode.Xor },
};
};
[Theory]
[MemberData(nameof(BlenderMappings))]

4
tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs

@ -35,7 +35,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Effects
[Fact]
public void BackgroundColor_amount_options_BackgroundColorProcessorDefaultsSet()
{
this.operations.BackgroundColor(Rgba32.BlanchedAlmond, this.options);
this.operations.BackgroundColor(this.options, Rgba32.BlanchedAlmond);
var processor = this.Verify<BackgroundColorProcessor<Rgba32>>();
Assert.Equal(this.options, processor.GraphicsOptions);
@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Effects
[Fact]
public void BackgroundColor_amount_rect_options_BackgroundColorProcessorDefaultsSet()
{
this.operations.BackgroundColor(Rgba32.BlanchedAlmond, this.rect, this.options);
this.operations.BackgroundColor(this.options, Rgba32.BlanchedAlmond, this.rect);
var processor = this.Verify<BackgroundColorProcessor<Rgba32>>(this.rect);
Assert.Equal(this.options, processor.GraphicsOptions);

2
tests/ImageSharp.Tests/TestImages.cs

@ -36,6 +36,8 @@ namespace SixLabors.ImageSharp.Tests
public const string SnakeGame = "Png/SnakeGame.png";
public const string Icon = "Png/icon.png";
public const string Kaboom = "Png/kaboom.png";
public const string PDSrc = "Png/pd-source.png";
public const string PDDest = "Png/pd-dest.png";
// Filtered test images from http://www.schaik.com/pngsuite/pngsuite_fil_png.html
public const string Filter0 = "Png/filter0.png";

2
tests/Images/External

@ -1 +1 @@
Subproject commit e9f33352b77a5176508d2d5dcafbd1bd33805530
Subproject commit 5a66c9c6da02bf27345f90adc05d415c0d0450ea

BIN
tests/Images/Input/Png/pd-dest.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
tests/Images/Input/Png/pd-source.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Loading…
Cancel
Save