diff --git a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj
index 915915f6cc..f9181b45da 100644
--- a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj
+++ b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj
@@ -39,9 +39,9 @@
+
-
diff --git a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj.DotSettings b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj.DotSettings
new file mode 100644
index 0000000000..a728b54979
--- /dev/null
+++ b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj.DotSettings
@@ -0,0 +1,2 @@
+
+ True
\ No newline at end of file
diff --git a/src/ImageSharp.Drawing/Processing/BrushApplicator.cs b/src/ImageSharp.Drawing/Processing/BrushApplicator.cs
index 0c6e0d3b40..7e75d7effc 100644
--- a/src/ImageSharp.Drawing/Processing/BrushApplicator.cs
+++ b/src/ImageSharp.Drawing/Processing/BrushApplicator.cs
@@ -44,7 +44,7 @@ internal BrushApplicator(ImageFrame target, GraphicsOptions options)
///
/// Gets the blend percentage
///
- protected GraphicsOptions Options { get; private set; }
+ protected GraphicsOptions Options { get; }
///
/// Gets the color for a single pixel.
diff --git a/src/ImageSharp.Drawing/Processing/Brushes.cs b/src/ImageSharp.Drawing/Processing/Brushes.cs
index c5e7a3e9ff..bd73e1f1b6 100644
--- a/src/ImageSharp.Drawing/Processing/Brushes.cs
+++ b/src/ImageSharp.Drawing/Processing/Brushes.cs
@@ -8,7 +8,7 @@ namespace SixLabors.ImageSharp.Processing
///
/// A collection of methods for creating generic brushes.
///
- /// A New
+ /// A New
public static class Brushes
{
///
@@ -94,163 +94,131 @@ public static class Brushes
/// Create as brush that will paint a solid color
///
/// The color.
- /// The pixel format.
- /// A New
- public static SolidBrush Solid(TPixel color)
- where TPixel : struct, IPixel
- => new SolidBrush(color);
+ /// A New
+ public static SolidBrush Solid(Color color) => new SolidBrush(color);
///
/// Create as brush that will paint a Percent10 Hatch Pattern with the specified colors
///
/// Color of the foreground.
- /// The pixel format.
- /// A New
- public static PatternBrush Percent10(TPixel foreColor)
- where TPixel : struct, IPixel
- => new PatternBrush(foreColor, NamedColors.Transparent, Percent10Pattern);
+ /// A New
+ public static PatternBrush Percent10(Color foreColor) =>
+ new PatternBrush(foreColor, Color.Transparent, Percent10Pattern);
///
/// Create as brush that will paint a Percent10 Hatch Pattern with the specified colors
///
/// Color of the foreground.
/// Color of the background.
- /// The pixel format.
- /// A New
- public static PatternBrush Percent10(TPixel foreColor, TPixel backColor)
- where TPixel : struct, IPixel
- => new PatternBrush(foreColor, backColor, Percent10Pattern);
+ /// A New
+ public static PatternBrush Percent10(Color foreColor, Color backColor) =>
+ new PatternBrush(foreColor, backColor, Percent10Pattern);
///
/// Create as brush that will paint a Percent20 Hatch Pattern with the specified foreground color and a
/// transparent background.
///
/// Color of the foreground.
- /// The pixel format.
- /// A New
- public static PatternBrush Percent20(TPixel foreColor)
- where TPixel : struct, IPixel
- => new PatternBrush(foreColor, NamedColors.Transparent, Percent20Pattern);
+ /// A New
+ public static PatternBrush Percent20(Color foreColor) =>
+ new PatternBrush(foreColor, Color.Transparent, Percent20Pattern);
///
/// Create as brush that will paint a Percent20 Hatch Pattern with the specified colors
///
/// Color of the foreground.
/// Color of the background.
- /// The pixel format.
- /// A New
- public static PatternBrush Percent20(TPixel foreColor, TPixel backColor)
- where TPixel : struct, IPixel
- => new PatternBrush(foreColor, backColor, Percent20Pattern);
+ /// A New
+ public static PatternBrush Percent20(Color foreColor, Color backColor) =>
+ new PatternBrush(foreColor, backColor, Percent20Pattern);
///
/// Create as brush that will paint a Horizontal Hatch Pattern with the specified foreground color and a
/// transparent background.
///
/// Color of the foreground.
- /// The pixel format.
- /// A New
- public static PatternBrush Horizontal(TPixel foreColor)
- where TPixel : struct, IPixel
- => new PatternBrush(foreColor, NamedColors.Transparent, HorizontalPattern);
+ /// A New
+ public static PatternBrush Horizontal(Color foreColor) =>
+ new PatternBrush(foreColor, Color.Transparent, HorizontalPattern);
///
/// Create as brush that will paint a Horizontal Hatch Pattern with the specified colors
///
/// Color of the foreground.
/// Color of the background.
- /// The pixel format.
- /// A New
- public static PatternBrush Horizontal(TPixel foreColor, TPixel backColor)
- where TPixel : struct, IPixel
- => new PatternBrush(foreColor, backColor, HorizontalPattern);
+ /// A New
+ public static PatternBrush Horizontal(Color foreColor, Color backColor) =>
+ new PatternBrush(foreColor, backColor, HorizontalPattern);
///
/// Create as brush that will paint a Min Hatch Pattern with the specified foreground color and a
/// transparent background.
///
/// Color of the foreground.
- /// The pixel format.
- /// A New
- public static PatternBrush Min(TPixel foreColor)
- where TPixel : struct, IPixel
- => new PatternBrush(foreColor, NamedColors.Transparent, MinPattern);
+ /// A New
+ public static PatternBrush Min(Color foreColor) => new PatternBrush(foreColor, Color.Transparent, MinPattern);
///
/// Create as brush that will paint a Min Hatch Pattern with the specified colors
///
/// Color of the foreground.
/// Color of the background.
- /// The pixel format.
- /// A New
- public static PatternBrush Min(TPixel foreColor, TPixel backColor)
- where TPixel : struct, IPixel
- => new PatternBrush(foreColor, backColor, MinPattern);
+ /// A New
+ public static PatternBrush Min(Color foreColor, Color backColor) =>
+ new PatternBrush(foreColor, backColor, MinPattern);
///
/// Create as brush that will paint a Vertical Hatch Pattern with the specified foreground color and a
/// transparent background.
///
/// Color of the foreground.
- /// The pixel format.
- /// A New
- public static PatternBrush Vertical(TPixel foreColor)
- where TPixel : struct, IPixel
- => new PatternBrush(foreColor, NamedColors.Transparent, VerticalPattern);
+ /// A New
+ public static PatternBrush Vertical(Color foreColor) =>
+ new PatternBrush(foreColor, Color.Transparent, VerticalPattern);
///
/// Create as brush that will paint a Vertical Hatch Pattern with the specified colors
///
/// Color of the foreground.
/// Color of the background.
- /// The pixel format.
- /// A New
- public static PatternBrush Vertical(TPixel foreColor, TPixel backColor)
- where TPixel : struct, IPixel
- => new PatternBrush(foreColor, backColor, VerticalPattern);
+ /// A New
+ public static PatternBrush Vertical(Color foreColor, Color backColor) =>
+ new PatternBrush(foreColor, backColor, VerticalPattern);
///
/// Create as brush that will paint a Forward Diagonal Hatch Pattern with the specified foreground color and a
/// transparent background.
///
/// Color of the foreground.
- /// The pixel format.
- /// A New
- public static PatternBrush ForwardDiagonal(TPixel foreColor)
- where TPixel : struct, IPixel
- => new PatternBrush(foreColor, NamedColors.Transparent, ForwardDiagonalPattern);
+ /// A New
+ public static PatternBrush ForwardDiagonal(Color foreColor) =>
+ new PatternBrush(foreColor, Color.Transparent, ForwardDiagonalPattern);
///
/// Create as brush that will paint a Forward Diagonal Hatch Pattern with the specified colors
///
/// Color of the foreground.
/// Color of the background.
- /// The pixel format.
- /// A New
- public static PatternBrush ForwardDiagonal(TPixel foreColor, TPixel backColor)
- where TPixel : struct, IPixel
- => new PatternBrush(foreColor, backColor, ForwardDiagonalPattern);
+ /// A New
+ public static PatternBrush ForwardDiagonal(Color foreColor, Color backColor) =>
+ new PatternBrush(foreColor, backColor, ForwardDiagonalPattern);
///
/// Create as brush that will paint a Backward Diagonal Hatch Pattern with the specified foreground color and a
/// transparent background.
///
/// Color of the foreground.
- /// The pixel format.
- /// A New
- public static PatternBrush BackwardDiagonal(TPixel foreColor)
- where TPixel : struct, IPixel
- => new PatternBrush(foreColor, NamedColors.Transparent, BackwardDiagonalPattern);
+ /// A New
+ public static PatternBrush BackwardDiagonal(Color foreColor) =>
+ new PatternBrush(foreColor, Color.Transparent, BackwardDiagonalPattern);
///
/// Create as brush that will paint a Backward Diagonal Hatch Pattern with the specified colors
///
/// Color of the foreground.
/// Color of the background.
- /// The pixel format.
- /// A New
- public static PatternBrush BackwardDiagonal(TPixel foreColor, TPixel backColor)
- where TPixel : struct, IPixel
- => new PatternBrush(foreColor, backColor, BackwardDiagonalPattern);
+ /// A New
+ public static PatternBrush BackwardDiagonal(Color foreColor, Color backColor) =>
+ new PatternBrush(foreColor, backColor, BackwardDiagonalPattern);
}
}
\ No newline at end of file
diff --git a/src/ImageSharp.Drawing/Processing/ColorStop{TPixel}.cs b/src/ImageSharp.Drawing/Processing/ColorStop.cs
similarity index 79%
rename from src/ImageSharp.Drawing/Processing/ColorStop{TPixel}.cs
rename to src/ImageSharp.Drawing/Processing/ColorStop.cs
index 7fd0ba7cd3..aee559469f 100644
--- a/src/ImageSharp.Drawing/Processing/ColorStop{TPixel}.cs
+++ b/src/ImageSharp.Drawing/Processing/ColorStop.cs
@@ -10,17 +10,15 @@ namespace SixLabors.ImageSharp.Processing
///
/// A struct that defines a single color stop.
///
- /// The pixel format.
[DebuggerDisplay("ColorStop({Ratio} -> {Color}")]
- public struct ColorStop
- where TPixel : struct, IPixel
+ public readonly struct ColorStop
{
///
- /// Initializes a new instance of the struct.
+ /// Initializes a new instance of the struct.
///
/// Where should it be? 0 is at the start, 1 at the end of the Gradient.
/// What color should be used at that point?
- public ColorStop(float ratio, TPixel color)
+ public ColorStop(float ratio, in Color color)
{
this.Ratio = ratio;
this.Color = color;
@@ -34,6 +32,6 @@ public ColorStop(float ratio, TPixel color)
///
/// Gets the color to be used.
///
- public TPixel Color { get; }
+ public Color Color { get; }
}
}
\ No newline at end of file
diff --git a/src/ImageSharp.Drawing/Processing/DrawImageExtensions.cs b/src/ImageSharp.Drawing/Processing/DrawImageExtensions.cs
deleted file mode 100644
index a8ee4d90bc..0000000000
--- a/src/ImageSharp.Drawing/Processing/DrawImageExtensions.cs
+++ /dev/null
@@ -1,137 +0,0 @@
-// Copyright (c) Six Labors and contributors.
-// Licensed under the Apache License, Version 2.0.
-
-using SixLabors.ImageSharp.PixelFormats;
-using SixLabors.ImageSharp.Processing.Processors.Drawing;
-using SixLabors.Primitives;
-
-namespace SixLabors.ImageSharp.Processing
-{
- ///
- /// Adds extensions that allow the drawing of images to the type.
- ///
- public static class DrawImageExtensions
- {
- ///
- /// Draws the given image together with the current one by blending their pixels.
- ///
- /// The pixel format of the destination image.
- /// The pixel format of the source image.
- /// The image this method extends.
- /// The image to blend with the currently processing image.
- /// The opacity of the image to blend. Must be between 0 and 1.
- /// The .
- public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, float opacity)
- where TPixelDst : struct, IPixel
- where TPixelSrc : struct, IPixel
- => source.ApplyProcessor(new DrawImageProcessor(image, Point.Empty, GraphicsOptions.Default.ColorBlendingMode, GraphicsOptions.Default.AlphaCompositionMode, opacity));
-
- ///
- /// Draws the given image together with the current one by blending their pixels.
- ///
- /// The pixel format of the destination image.
- /// The pixel format of the source image.
- /// The image this method extends.
- /// The image to blend with the currently processing image.
- /// The blending mode.
- /// The opacity of the image to blend. Must be between 0 and 1.
- /// The .
- public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, PixelColorBlendingMode colorBlending, float opacity)
- where TPixelDst : struct, IPixel
- where TPixelSrc : struct, IPixel
- => source.ApplyProcessor(new DrawImageProcessor(image, Point.Empty, colorBlending, GraphicsOptions.Default.AlphaCompositionMode, opacity));
-
- ///
- /// Draws the given image together with the current one by blending their pixels.
- ///
- /// The pixel format of the destination image.
- /// The pixel format of the source image.
- /// The image this method extends.
- /// The image to blend with the currently processing image.
- /// The color blending mode.
- /// The alpha composition mode.
- /// The opacity of the image to blend. Must be between 0 and 1.
- /// The .
- public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity)
- where TPixelDst : struct, IPixel
- where TPixelSrc : struct, IPixel
- => source.ApplyProcessor(new DrawImageProcessor(image, Point.Empty, colorBlending, alphaComposition, opacity));
-
- ///
- /// Draws the given image together with the current one by blending their pixels.
- ///
- /// The pixel format of the destination image.
- /// The pixel format of the source image.
- /// The image this method extends.
- /// The image to blend with the currently processing image.
- /// The options, including the blending type and blending amount.
- /// The .
- public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, GraphicsOptions options)
- where TPixelDst : struct, IPixel
- where TPixelSrc : struct, IPixel
- => source.ApplyProcessor(new DrawImageProcessor(image, Point.Empty, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage));
-
- ///
- /// Draws the given image together with the current one by blending their pixels.
- ///
- /// The pixel format of the destination image.
- /// The pixel format of the source image.
- /// The image this method extends.
- /// The image to blend with the currently processing image.
- /// The location to draw the blended image.
- /// The opacity of the image to blend. Must be between 0 and 1.
- /// The .
- public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, Point location, float opacity)
- where TPixelDst : struct, IPixel
- where TPixelSrc : struct, IPixel
- => source.ApplyProcessor(new DrawImageProcessor(image, location, GraphicsOptions.Default.ColorBlendingMode, GraphicsOptions.Default.AlphaCompositionMode, opacity));
-
- ///
- /// Draws the given image together with the current one by blending their pixels.
- ///
- /// The pixel format of the destination image.
- /// The pixel format of the source image.
- /// The image this method extends.
- /// The image to blend with the currently processing image.
- /// The location to draw the blended image.
- /// The color blending to apply.
- /// The opacity of the image to blend. Must be between 0 and 1.
- /// The .
- public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, Point location, PixelColorBlendingMode colorBlending, float opacity)
- where TPixelDst : struct, IPixel
- where TPixelSrc : struct, IPixel
- => source.ApplyProcessor(new DrawImageProcessor(image, location, colorBlending, GraphicsOptions.Default.AlphaCompositionMode, opacity));
-
- ///
- /// Draws the given image together with the current one by blending their pixels.
- ///
- /// The pixel format of the destination image.
- /// The pixel format of the source image.
- /// The image this method extends.
- /// The image to blend with the currently processing image.
- /// The location to draw the blended image.
- /// The color blending to apply.
- /// The alpha composition mode.
- /// The opacity of the image to blend. Must be between 0 and 1.
- /// The .
- public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, Point location, PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity)
- where TPixelDst : struct, IPixel
- where TPixelSrc : struct, IPixel
- => source.ApplyProcessor(new DrawImageProcessor(image, location, colorBlending, alphaComposition, opacity));
-
- ///
- /// Draws the given image together with the current one by blending their pixels.
- ///
- /// The pixel format of the destination image.
- /// The pixel format of the source image.
- /// The image this method extends.
- /// The image to blend with the currently processing image.
- /// The location to draw the blended image.
- /// The options containing the blend mode and opacity.
- /// The .
- public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, Point location, GraphicsOptions options)
- where TPixelDst : struct, IPixel
- where TPixelSrc : struct, IPixel
- => source.ApplyProcessor(new DrawImageProcessor(image, location, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage));
- }
-}
\ No newline at end of file
diff --git a/src/ImageSharp.Drawing/Processing/DrawingHelpers.cs b/src/ImageSharp.Drawing/Processing/DrawingHelpers.cs
new file mode 100644
index 0000000000..b4ce0c5cba
--- /dev/null
+++ b/src/ImageSharp.Drawing/Processing/DrawingHelpers.cs
@@ -0,0 +1,22 @@
+// Copyright (c) Six Labors and contributors.
+// Licensed under the Apache License, Version 2.0.
+
+using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Primitives;
+
+namespace SixLabors.ImageSharp.Processing
+{
+ internal static class DrawingHelpers
+ {
+ ///
+ /// Convert a to a of the given pixel type.
+ ///
+ public static DenseMatrix ToPixelMatrix(this DenseMatrix colorMatrix, Configuration configuration)
+ where TPixel : struct, IPixel
+ {
+ DenseMatrix result = new DenseMatrix(colorMatrix.Columns, colorMatrix.Rows);
+ Color.ToPixel(configuration, colorMatrix.Span, result.Span);
+ return result;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/ImageSharp.Drawing/Processing/EllipticGradientBrush{TPixel}.cs b/src/ImageSharp.Drawing/Processing/EllipticGradientBrush.cs
similarity index 91%
rename from src/ImageSharp.Drawing/Processing/EllipticGradientBrush{TPixel}.cs
rename to src/ImageSharp.Drawing/Processing/EllipticGradientBrush.cs
index 64901c8e80..4a8ce44dbb 100644
--- a/src/ImageSharp.Drawing/Processing/EllipticGradientBrush{TPixel}.cs
+++ b/src/ImageSharp.Drawing/Processing/EllipticGradientBrush.cs
@@ -14,9 +14,7 @@ namespace SixLabors.ImageSharp.Processing
/// a point on the longest extension of the ellipse and
/// the ratio between longest and shortest extension.
///
- /// The Pixel format that is used.
- public sealed class EllipticGradientBrush : GradientBrushBase
- where TPixel : struct, IPixel
+ public sealed class EllipticGradientBrush : GradientBrushBase
{
private readonly PointF center;
@@ -24,7 +22,7 @@ public sealed class EllipticGradientBrush : GradientBrushBase
private readonly float axisRatio;
- ///
+ ///
/// The center of the elliptical gradient and 0 for the color stops.
/// The end point of the reference axis of the ellipse.
///
@@ -39,7 +37,7 @@ public EllipticGradientBrush(
PointF referenceAxisEnd,
float axisRatio,
GradientRepetitionMode repetitionMode,
- params ColorStop[] colorStops)
+ params ColorStop[] colorStops)
: base(repetitionMode, colorStops)
{
this.center = center;
@@ -47,12 +45,12 @@ public EllipticGradientBrush(
this.axisRatio = axisRatio;
}
- ///
- public override BrushApplicator CreateApplicator(
+ ///
+ public override BrushApplicator CreateApplicator(
ImageFrame source,
RectangleF region,
GraphicsOptions options) =>
- new RadialGradientBrushApplicator(
+ new RadialGradientBrushApplicator(
source,
options,
this.center,
@@ -62,7 +60,8 @@ public override BrushApplicator CreateApplicator(
this.RepetitionMode);
///
- private sealed class RadialGradientBrushApplicator : GradientBrushApplicatorBase
+ private sealed class RadialGradientBrushApplicator : GradientBrushApplicatorBase
+ where TPixel : struct, IPixel
{
private readonly PointF center;
@@ -85,7 +84,7 @@ private sealed class RadialGradientBrushApplicator : GradientBrushApplicatorBase
private readonly float referenceRadiusSquared;
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// The target image
/// The options
@@ -102,7 +101,7 @@ public RadialGradientBrushApplicator(
PointF center,
PointF referenceAxisEnd,
float axisRatio,
- ColorStop[] colorStops,
+ ColorStop[] colorStops,
GradientRepetitionMode repetitionMode)
: base(target, options, colorStops, repetitionMode)
{
diff --git a/src/ImageSharp.Drawing/Processing/DrawBezierExtensions.cs b/src/ImageSharp.Drawing/Processing/Extensions/DrawBezierExtensions.cs
similarity index 56%
rename from src/ImageSharp.Drawing/Processing/DrawBezierExtensions.cs
rename to src/ImageSharp.Drawing/Processing/Extensions/DrawBezierExtensions.cs
index 782f5d4d73..85addd5f2c 100644
--- a/src/ImageSharp.Drawing/Processing/DrawBezierExtensions.cs
+++ b/src/ImageSharp.Drawing/Processing/Extensions/DrawBezierExtensions.cs
@@ -15,80 +15,93 @@ public static class DrawBezierExtensions
///
/// Draws the provided points as an open Bezier path at the provided thickness with the supplied brush
///
- /// The type of the color.
/// The image this method extends.
/// The options.
/// The brush.
/// The thickness.
/// The points.
/// The .
- public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, GraphicsOptions options, IBrush brush, float thickness, params PointF[] points)
- where TPixel : struct, IPixel
- => source.Draw(options, new Pen(brush, thickness), new Path(new CubicBezierLineSegment(points)));
+ public static IImageProcessingContext DrawBeziers(
+ this IImageProcessingContext source,
+ GraphicsOptions options,
+ IBrush brush,
+ float thickness,
+ params PointF[] points) =>
+ source.Draw(options, new Pen(brush, thickness), new Path(new CubicBezierLineSegment(points)));
///
/// Draws the provided points as an open Bezier path at the provided thickness with the supplied brush
///
- /// The type of the color.
/// The image this method extends.
/// The brush.
/// The thickness.
/// The points.
/// The .
- public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, IBrush brush, float thickness, params PointF[] points)
- where TPixel : struct, IPixel
- => source.Draw(new Pen(brush, thickness), new Path(new CubicBezierLineSegment(points)));
+ public static IImageProcessingContext DrawBeziers(
+ this IImageProcessingContext source,
+ IBrush brush,
+ float thickness,
+ params PointF[] points) =>
+ source.Draw(new Pen(brush, thickness), new Path(new CubicBezierLineSegment(points)));
///
/// Draws the provided points as an open Bezier path at the provided thickness with the supplied brush
///
- /// The type of the color.
/// The image this method extends.
/// The color.
/// The thickness.
/// The points.
/// The .
- public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, TPixel color, float thickness, params PointF[] points)
- where TPixel : struct, IPixel
- => source.DrawBeziers(new SolidBrush(color), thickness, points);
+ public static IImageProcessingContext DrawBeziers(
+ this IImageProcessingContext source,
+ Color color,
+ float thickness,
+ params PointF[] points) =>
+ source.DrawBeziers(new SolidBrush(color), thickness, points);
///
/// Draws the provided points as an open Bezier path at the provided thickness with the supplied brush
///
- /// The type of the color.
/// The image this method extends.
/// The options.
/// The color.
/// The thickness.
/// The points.
/// The .
- public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, GraphicsOptions options, TPixel color, float thickness, params PointF[] points)
- where TPixel : struct, IPixel
- => source.DrawBeziers(options, new SolidBrush(color), thickness, points);
+ public static IImageProcessingContext DrawBeziers(
+ this IImageProcessingContext source,
+ GraphicsOptions options,
+ Color color,
+ float thickness,
+ params PointF[] points) =>
+ source.DrawBeziers(options, new SolidBrush(color), thickness, points);
///
/// Draws the provided points as an open Bezier path with the supplied pen
///
- /// The type of the color.
/// The image this method extends.
/// The options.
/// The pen.
/// The points.
/// The .
- public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, GraphicsOptions options, IPen pen, params PointF[] points)
- where TPixel : struct, IPixel
- => source.Draw(options, pen, new Path(new CubicBezierLineSegment(points)));
+ public static IImageProcessingContext DrawBeziers(
+ this IImageProcessingContext source,
+ GraphicsOptions options,
+ IPen pen,
+ params PointF[] points) =>
+ source.Draw(options, pen, new Path(new CubicBezierLineSegment(points)));
///
/// Draws the provided points as an open Bezier path with the supplied pen
///
- /// The type of the color.
/// The image this method extends.
/// The pen.
/// The points.
/// The .
- public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, IPen pen, params PointF[] points)
- where TPixel : struct, IPixel
- => source.Draw(pen, new Path(new CubicBezierLineSegment(points)));
+ public static IImageProcessingContext DrawBeziers(
+ this IImageProcessingContext source,
+ IPen pen,
+ params PointF[] points) =>
+ source.Draw(pen, new Path(new CubicBezierLineSegment(points)));
}
}
diff --git a/src/ImageSharp.Drawing/Processing/Extensions/DrawImageExtensions.cs b/src/ImageSharp.Drawing/Processing/Extensions/DrawImageExtensions.cs
new file mode 100644
index 0000000000..981cf1bef4
--- /dev/null
+++ b/src/ImageSharp.Drawing/Processing/Extensions/DrawImageExtensions.cs
@@ -0,0 +1,175 @@
+// Copyright (c) Six Labors and contributors.
+// Licensed under the Apache License, Version 2.0.
+
+using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing.Processors.Drawing;
+using SixLabors.Primitives;
+
+namespace SixLabors.ImageSharp.Processing
+{
+ ///
+ /// Adds extensions that allow the drawing of images to the type.
+ ///
+ public static class DrawImageExtensions
+ {
+ ///
+ /// Draws the given image together with the current one by blending their pixels.
+ ///
+ /// The image this method extends.
+ /// The image to blend with the currently processing image.
+ /// The opacity of the image to blend. Must be between 0 and 1.
+ /// The .
+ public static IImageProcessingContext DrawImage(
+ this IImageProcessingContext source,
+ Image image,
+ float opacity) =>
+ source.ApplyProcessor(
+ new DrawImageProcessor(
+ image,
+ Point.Empty,
+ GraphicsOptions.Default.ColorBlendingMode,
+ GraphicsOptions.Default.AlphaCompositionMode,
+ opacity));
+
+ ///
+ /// Draws the given image together with the current one by blending their pixels.
+ ///
+ /// The image this method extends.
+ /// The image to blend with the currently processing image.
+ /// The blending mode.
+ /// The opacity of the image to blend. Must be between 0 and 1.
+ /// The .
+ public static IImageProcessingContext DrawImage(
+ this IImageProcessingContext source,
+ Image image,
+ PixelColorBlendingMode colorBlending,
+ float opacity) =>
+ source.ApplyProcessor(
+ new DrawImageProcessor(
+ image,
+ Point.Empty,
+ colorBlending,
+ GraphicsOptions.Default.AlphaCompositionMode,
+ opacity));
+
+ ///
+ /// Draws the given image together with the current one by blending their pixels.
+ ///
+ /// The image this method extends.
+ /// The image to blend with the currently processing image.
+ /// The color blending mode.
+ /// The alpha composition mode.
+ /// The opacity of the image to blend. Must be between 0 and 1.
+ /// The .
+ public static IImageProcessingContext DrawImage(
+ this IImageProcessingContext source,
+ Image image,
+ PixelColorBlendingMode colorBlending,
+ PixelAlphaCompositionMode alphaComposition,
+ float opacity) =>
+ source.ApplyProcessor(new DrawImageProcessor(image, Point.Empty, colorBlending, alphaComposition, opacity));
+
+ ///
+ /// Draws the given image together with the current one by blending their pixels.
+ ///
+ /// The image this method extends.
+ /// The image to blend with the currently processing image.
+ /// The options, including the blending type and blending amount.
+ /// The .
+ public static IImageProcessingContext DrawImage(
+ this IImageProcessingContext source,
+ Image image,
+ GraphicsOptions options) =>
+ source.ApplyProcessor(
+ new DrawImageProcessor(
+ image,
+ Point.Empty,
+ options.ColorBlendingMode,
+ options.AlphaCompositionMode,
+ options.BlendPercentage));
+
+ ///
+ /// Draws the given image together with the current one by blending their pixels.
+ ///
+ /// The image this method extends.
+ /// The image to blend with the currently processing image.
+ /// The location to draw the blended image.
+ /// The opacity of the image to blend. Must be between 0 and 1.
+ /// The .
+ public static IImageProcessingContext DrawImage(
+ this IImageProcessingContext source,
+ Image image,
+ Point location,
+ float opacity) =>
+ source.ApplyProcessor(
+ new DrawImageProcessor(
+ image,
+ location,
+ GraphicsOptions.Default.ColorBlendingMode,
+ GraphicsOptions.Default.AlphaCompositionMode,
+ opacity));
+
+ ///
+ /// Draws the given image together with the current one by blending their pixels.
+ ///
+ /// The image this method extends.
+ /// The image to blend with the currently processing image.
+ /// The location to draw the blended image.
+ /// The color blending to apply.
+ /// The opacity of the image to blend. Must be between 0 and 1.
+ /// The .
+ public static IImageProcessingContext DrawImage(
+ this IImageProcessingContext source,
+ Image image,
+ Point location,
+ PixelColorBlendingMode colorBlending,
+ float opacity) =>
+ source.ApplyProcessor(
+ new DrawImageProcessor(
+ image,
+ location,
+ colorBlending,
+ GraphicsOptions.Default.AlphaCompositionMode,
+ opacity));
+
+ ///
+ /// Draws the given image together with the current one by blending their pixels.
+ ///
+ /// The image this method extends.
+ /// The image to blend with the currently processing image.
+ /// The location to draw the blended image.
+ /// The color blending to apply.
+ /// The alpha composition mode.
+ /// The opacity of the image to blend. Must be between 0 and 1.
+ /// The .
+ public static IImageProcessingContext DrawImage(
+ this IImageProcessingContext source,
+ Image image,
+ Point location,
+ PixelColorBlendingMode colorBlending,
+ PixelAlphaCompositionMode alphaComposition,
+ float opacity) =>
+ source.ApplyProcessor(new DrawImageProcessor(image, location, colorBlending, alphaComposition, opacity));
+
+ ///
+ /// Draws the given image together with the current one by blending their pixels.
+ ///
+ /// The image this method extends.
+ /// The image to blend with the currently processing image.
+ /// The location to draw the blended image.
+ /// The options containing the blend mode and opacity.
+ /// The .
+ public static IImageProcessingContext DrawImage(
+ this IImageProcessingContext source,
+ Image image,
+ Point location,
+ GraphicsOptions options) =>
+ source.ApplyProcessor(
+ new DrawImageProcessor(
+ image,
+ location,
+ options.ColorBlendingMode,
+ options.AlphaCompositionMode,
+ options.BlendPercentage));
+ }
+}
\ No newline at end of file
diff --git a/src/ImageSharp.Drawing/Processing/DrawLineExtensions.cs b/src/ImageSharp.Drawing/Processing/Extensions/DrawLineExtensions.cs
similarity index 56%
rename from src/ImageSharp.Drawing/Processing/DrawLineExtensions.cs
rename to src/ImageSharp.Drawing/Processing/Extensions/DrawLineExtensions.cs
index 9084b30efe..b7b419be61 100644
--- a/src/ImageSharp.Drawing/Processing/DrawLineExtensions.cs
+++ b/src/ImageSharp.Drawing/Processing/Extensions/DrawLineExtensions.cs
@@ -15,80 +15,93 @@ public static class DrawLineExtensions
///
/// Draws the provided Points as an open Linear path at the provided thickness with the supplied brush
///
- /// The type of the color.
/// The image this method extends.
/// The options.
/// The brush.
/// The thickness.
/// The points.
/// The .
- public static IImageProcessingContext DrawLines(this IImageProcessingContext source, GraphicsOptions options, IBrush brush, float thickness, params PointF[] points)
- where TPixel : struct, IPixel
- => source.Draw(options, new Pen(brush, thickness), new Path(new LinearLineSegment(points)));
+ public static IImageProcessingContext DrawLines(
+ this IImageProcessingContext source,
+ GraphicsOptions options,
+ IBrush brush,
+ float thickness,
+ params PointF[] points) =>
+ source.Draw(options, new Pen(brush, thickness), new Path(new LinearLineSegment(points)));
///
/// Draws the provided Points as an open Linear path at the provided thickness with the supplied brush
///
- /// The type of the color.
/// The image this method extends.
/// The brush.
/// The thickness.
/// The points.
/// The .
- public static IImageProcessingContext DrawLines(this IImageProcessingContext source, IBrush brush, float thickness, params PointF[] points)
- where TPixel : struct, IPixel
- => source.Draw(new Pen(brush, thickness), new Path(new LinearLineSegment(points)));
+ public static IImageProcessingContext DrawLines(
+ this IImageProcessingContext source,
+ IBrush brush,
+ float thickness,
+ params PointF[] points) =>
+ source.Draw(new Pen(brush, thickness), new Path(new LinearLineSegment(points)));
///
/// Draws the provided Points as an open Linear path at the provided thickness with the supplied brush
///
- /// The type of the color.
/// The image this method extends.
/// The color.
/// The thickness.
/// The points.
/// The .
- public static IImageProcessingContext DrawLines(this IImageProcessingContext source, TPixel color, float thickness, params PointF[] points)
- where TPixel : struct, IPixel
- => source.DrawLines(new SolidBrush(color), thickness, points);
+ public static IImageProcessingContext DrawLines(
+ this IImageProcessingContext source,
+ Color color,
+ float thickness,
+ params PointF[] points) =>
+ source.DrawLines(new SolidBrush(color), thickness, points);
///
/// Draws the provided Points as an open Linear path at the provided thickness with the supplied brush
///
- /// The type of the color.
/// The image this method extends.
/// The options.
/// The color.
/// The thickness.
/// The points.
/// The .>
- public static IImageProcessingContext DrawLines(this IImageProcessingContext source, GraphicsOptions options, TPixel color, float thickness, params PointF[] points)
- where TPixel : struct, IPixel
- => source.DrawLines(options, new SolidBrush(color), thickness, points);
+ public static IImageProcessingContext DrawLines(
+ this IImageProcessingContext source,
+ GraphicsOptions options,
+ Color color,
+ float thickness,
+ params PointF[] points) =>
+ source.DrawLines(options, new SolidBrush(color), thickness, points);
///
/// Draws the provided Points as an open Linear path with the supplied pen
///
- /// The type of the color.
/// The image this method extends.
/// The options.
/// The pen.
/// The points.
/// The .
- public static IImageProcessingContext DrawLines(this IImageProcessingContext source, GraphicsOptions options, IPen pen, params PointF[] points)
- where TPixel : struct, IPixel
- => source.Draw(options, pen, new Path(new LinearLineSegment(points)));
+ public static IImageProcessingContext DrawLines(
+ this IImageProcessingContext source,
+ GraphicsOptions options,
+ IPen pen,
+ params PointF[] points) =>
+ source.Draw(options, pen, new Path(new LinearLineSegment(points)));
///
/// Draws the provided Points as an open Linear path with the supplied pen
///
- /// The type of the color.
/// The image this method extends.
/// The pen.
/// The points.
/// The .
- public static IImageProcessingContext DrawLines(this IImageProcessingContext source, IPen pen, params PointF[] points)
- where TPixel : struct, IPixel
- => source.Draw(pen, new Path(new LinearLineSegment(points)));
+ public static IImageProcessingContext DrawLines(
+ this IImageProcessingContext source,
+ IPen pen,
+ params PointF[] points) =>
+ source.Draw(pen, new Path(new LinearLineSegment(points)));
}
}
\ No newline at end of file
diff --git a/src/ImageSharp.Drawing/Processing/DrawPathCollectionExtensions.cs b/src/ImageSharp.Drawing/Processing/Extensions/DrawPathCollectionExtensions.cs
similarity index 59%
rename from src/ImageSharp.Drawing/Processing/DrawPathCollectionExtensions.cs
rename to src/ImageSharp.Drawing/Processing/Extensions/DrawPathCollectionExtensions.cs
index 0d3abf297e..79b4fd0a80 100644
--- a/src/ImageSharp.Drawing/Processing/DrawPathCollectionExtensions.cs
+++ b/src/ImageSharp.Drawing/Processing/Extensions/DrawPathCollectionExtensions.cs
@@ -14,14 +14,16 @@ public static class DrawPathCollectionExtensions
///
/// Draws the outline of the polygon with the provided pen.
///
- /// The type of the color.
/// The image this method extends.
/// The options.
/// The pen.
/// The paths.
/// The .
- public static IImageProcessingContext Draw(this IImageProcessingContext source, GraphicsOptions options, IPen pen, IPathCollection paths)
- where TPixel : struct, IPixel
+ public static IImageProcessingContext Draw(
+ this IImageProcessingContext source,
+ GraphicsOptions options,
+ IPen pen,
+ IPathCollection paths)
{
foreach (IPath path in paths)
{
@@ -34,67 +36,76 @@ public static IImageProcessingContext Draw(this IImageProcessing
///
/// Draws the outline of the polygon with the provided pen.
///
- /// The type of the color.
/// The image this method extends.
/// The pen.
/// The paths.
/// The .
- public static IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, IPathCollection paths)
- where TPixel : struct, IPixel
- => source.Draw(GraphicsOptions.Default, pen, paths);
+ public static IImageProcessingContext
+ Draw(this IImageProcessingContext source, IPen pen, IPathCollection paths) =>
+ source.Draw(GraphicsOptions.Default, pen, paths);
///
/// Draws the outline of the polygon with the provided brush at the provided thickness.
///
- /// The type of the color.
/// The image this method extends.
/// The options.
/// The brush.
/// The thickness.
/// The shapes.
/// The .
- public static IImageProcessingContext Draw(this IImageProcessingContext source, GraphicsOptions options, IBrush brush, float thickness, IPathCollection paths)
- where TPixel : struct, IPixel
- => source.Draw(options, new Pen(brush, thickness), paths);
+ public static IImageProcessingContext Draw(
+ this IImageProcessingContext source,
+ GraphicsOptions options,
+ IBrush brush,
+ float thickness,
+ IPathCollection paths) =>
+ source.Draw(options, new Pen(brush, thickness), paths);
///
/// Draws the outline of the polygon with the provided brush at the provided thickness.
///
- /// The type of the color.
/// The image this method extends.
/// The brush.
/// The thickness.
/// The paths.
/// The .
- public static IImageProcessingContext Draw(this IImageProcessingContext source, IBrush brush, float thickness, IPathCollection paths)
- where TPixel : struct, IPixel
- => source.Draw(new Pen(brush, thickness), paths);
+ public static IImageProcessingContext Draw(
+ this IImageProcessingContext source,
+ IBrush brush,
+ float thickness,
+ IPathCollection paths) =>
+ source.Draw(new Pen(brush, thickness), paths);
///
/// Draws the outline of the polygon with the provided brush at the provided thickness.
///
- /// The type of the color.
/// The image this method extends.
/// The options.
/// The color.
/// The thickness.
/// The paths.
/// The .
- public static IImageProcessingContext Draw(this IImageProcessingContext source, GraphicsOptions options, TPixel color, float thickness, IPathCollection paths)
- where TPixel : struct, IPixel
- => source.Draw(options, new SolidBrush(color), thickness, paths);
+ public static IImageProcessingContext Draw(
+ this IImageProcessingContext source,
+ GraphicsOptions options,
+ Color color,
+ float thickness,
+ IPathCollection paths) =>
+ source.Draw(options, new SolidBrush(color), thickness, paths);
///
/// Draws the outline of the polygon with the provided brush at the provided thickness.
///
- /// The type of the color.
/// The image this method extends.
/// The color.
/// The thickness.
/// The paths.
/// The .
- public static IImageProcessingContext Draw(this IImageProcessingContext source, TPixel color, float thickness, IPathCollection paths)
- where TPixel : struct, IPixel
- => source.Draw(new SolidBrush(color), thickness, paths);
+ public static IImageProcessingContext Draw(
+ this IImageProcessingContext source,
+ Color color,
+ float thickness,
+ IPathCollection paths) =>
+ source.Draw(new SolidBrush(color), thickness, paths);
}
}
\ No newline at end of file
diff --git a/src/ImageSharp.Drawing/Processing/DrawPathExtensions.cs b/src/ImageSharp.Drawing/Processing/Extensions/DrawPathExtensions.cs
similarity index 58%
rename from src/ImageSharp.Drawing/Processing/DrawPathExtensions.cs
rename to src/ImageSharp.Drawing/Processing/Extensions/DrawPathExtensions.cs
index 4dbe942f2b..efafdde5ab 100644
--- a/src/ImageSharp.Drawing/Processing/DrawPathExtensions.cs
+++ b/src/ImageSharp.Drawing/Processing/Extensions/DrawPathExtensions.cs
@@ -15,80 +15,90 @@ public static class DrawPathExtensions
///
/// Draws the outline of the polygon with the provided pen.
///
- /// The type of the color.
/// The image this method extends.
/// The options.
/// The pen.
/// The path.
/// The .
- public static IImageProcessingContext Draw(this IImageProcessingContext source, GraphicsOptions options, IPen pen, IPath path)
- where TPixel : struct, IPixel
- => source.Fill(options, pen.StrokeFill, new ShapePath(path, pen));
+ public static IImageProcessingContext Draw(
+ this IImageProcessingContext source,
+ GraphicsOptions options,
+ IPen pen,
+ IPath path) =>
+ source.Fill(options, pen.StrokeFill, new ShapePath(path, pen));
///
/// Draws the outline of the polygon with the provided pen.
///
- /// The type of the color.
/// The image this method extends.
/// The pen.
/// The path.
/// The .
- public static IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, IPath path)
- where TPixel : struct, IPixel
- => source.Draw(GraphicsOptions.Default, pen, path);
+ public static IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, IPath path) =>
+ source.Draw(GraphicsOptions.Default, pen, path);
///
/// Draws the outline of the polygon with the provided brush at the provided thickness.
///
- /// The type of the color.
/// The image this method extends.
/// The options.
/// The brush.
/// The thickness.
/// The shape.
/// The .
- public static IImageProcessingContext Draw(this IImageProcessingContext source, GraphicsOptions options, IBrush brush, float thickness, IPath path)
- where TPixel : struct, IPixel
- => source.Draw(options, new Pen(brush, thickness), path);
+ public static IImageProcessingContext Draw(
+ this IImageProcessingContext source,
+ GraphicsOptions options,
+ IBrush brush,
+ float thickness,
+ IPath path) =>
+ source.Draw(options, new Pen(brush, thickness), path);
///
/// Draws the outline of the polygon with the provided brush at the provided thickness.
///
- /// The type of the color.
/// The image this method extends.
/// The brush.
/// The thickness.
/// The path.
/// The .
- public static IImageProcessingContext Draw(this IImageProcessingContext source, IBrush brush, float thickness, IPath path)
- where TPixel : struct, IPixel
- => source.Draw(new Pen(brush, thickness), path);
+ public static IImageProcessingContext Draw(
+ this IImageProcessingContext source,
+ IBrush brush,
+ float thickness,
+ IPath path) =>
+ source.Draw(new Pen(brush, thickness), path);
///
/// Draws the outline of the polygon with the provided brush at the provided thickness.
///
- /// The type of the color.
/// The image this method extends.
/// The options.
/// The color.
/// The thickness.
/// The path.
/// The .
- public static IImageProcessingContext Draw(this IImageProcessingContext source, GraphicsOptions options, TPixel color, float thickness, IPath path)
- where TPixel : struct, IPixel
- => source.Draw(options, new SolidBrush(color), thickness, path);
+ public static IImageProcessingContext Draw(
+ this IImageProcessingContext source,
+ GraphicsOptions options,
+ Color color,
+ float thickness,
+ IPath path) =>
+ source.Draw(options, new SolidBrush(color), thickness, path);
///
/// Draws the outline of the polygon with the provided brush at the provided thickness.
///
- /// The type of the color.
/// The image this method extends.
/// The color.
/// The thickness.
/// The path.
/// The .
- public static IImageProcessingContext Draw(this IImageProcessingContext source, TPixel color, float thickness, IPath path)
- where TPixel : struct, IPixel
- => source.Draw(new SolidBrush(color), thickness, path);
+ public static IImageProcessingContext Draw(
+ this IImageProcessingContext source,
+ Color color,
+ float thickness,
+ IPath path) =>
+ source.Draw(new SolidBrush(color), thickness, path);
}
}
\ No newline at end of file
diff --git a/src/ImageSharp.Drawing/Processing/DrawPolygonExtensions.cs b/src/ImageSharp.Drawing/Processing/Extensions/DrawPolygonExtensions.cs
similarity index 56%
rename from src/ImageSharp.Drawing/Processing/DrawPolygonExtensions.cs
rename to src/ImageSharp.Drawing/Processing/Extensions/DrawPolygonExtensions.cs
index 4dcfe00aa3..324e05e87b 100644
--- a/src/ImageSharp.Drawing/Processing/DrawPolygonExtensions.cs
+++ b/src/ImageSharp.Drawing/Processing/Extensions/DrawPolygonExtensions.cs
@@ -15,80 +15,93 @@ public static class DrawPolygonExtensions
///
/// Draws the provided Points as a closed Linear Polygon with the provided brush at the provided thickness.
///
- /// The type of the color.
/// The image this method extends.
/// The options.
/// The brush.
/// The thickness.
/// The points.
/// The .
- public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, GraphicsOptions options, IBrush brush, float thickness, params PointF[] points)
- where TPixel : struct, IPixel
- => source.Draw(options, new Pen(brush, thickness), new Polygon(new LinearLineSegment(points)));
+ public static IImageProcessingContext DrawPolygon(
+ this IImageProcessingContext source,
+ GraphicsOptions options,
+ IBrush brush,
+ float thickness,
+ params PointF[] points) =>
+ source.Draw(options, new Pen(brush, thickness), new Polygon(new LinearLineSegment(points)));
///
/// Draws the provided Points as a closed Linear Polygon with the provided brush at the provided thickness.
///
- /// The type of the color.
/// The image this method extends.
/// The brush.
/// The thickness.
/// The points.
/// The .
- public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, IBrush brush, float thickness, params PointF[] points)
- where TPixel : struct, IPixel
- => source.Draw(new Pen(brush, thickness), new Polygon(new LinearLineSegment(points)));
+ public static IImageProcessingContext DrawPolygon(
+ this IImageProcessingContext source,
+ IBrush brush,
+ float thickness,
+ params PointF[] points) =>
+ source.Draw(new Pen(brush, thickness), new Polygon(new LinearLineSegment(points)));
///
/// Draws the provided Points as a closed Linear Polygon with the provided brush at the provided thickness.
///
- /// The type of the color.
/// The image this method extends.
/// The color.
/// The thickness.
/// The points.
/// The .
- public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, TPixel color, float thickness, params PointF[] points)
- where TPixel : struct, IPixel
- => source.DrawPolygon(new SolidBrush(color), thickness, points);
+ public static IImageProcessingContext DrawPolygon(
+ this IImageProcessingContext source,
+ Color color,
+ float thickness,
+ params PointF[] points) =>
+ source.DrawPolygon(new SolidBrush(color), thickness, points);
///
/// Draws the provided Points as a closed Linear Polygon with the provided brush at the provided thickness.
///
- /// The type of the color.
/// The image this method extends.
/// The options.
/// The color.
/// The thickness.
/// The points.
/// The .
- public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, GraphicsOptions options, TPixel color, float thickness, params PointF[] points)
- where TPixel : struct, IPixel
- => source.DrawPolygon(options, new SolidBrush(color), thickness, points);
+ public static IImageProcessingContext DrawPolygon(
+ this IImageProcessingContext source,
+ GraphicsOptions options,
+ Color color,
+ float thickness,
+ params PointF[] points) =>
+ source.DrawPolygon(options, new SolidBrush(color), thickness, points);
///
/// Draws the provided Points as a closed Linear Polygon with the provided Pen.
///
- /// The type of the color.
/// The image this method extends.
/// The pen.
/// The points.
/// The .
- public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, IPen pen, params PointF[] points)
- where TPixel : struct, IPixel
- => source.Draw(GraphicsOptions.Default, pen, new Polygon(new LinearLineSegment(points)));
+ public static IImageProcessingContext DrawPolygon(
+ this IImageProcessingContext source,
+ IPen pen,
+ params PointF[] points) =>
+ source.Draw(GraphicsOptions.Default, pen, new Polygon(new LinearLineSegment(points)));
///
/// Draws the provided Points as a closed Linear Polygon with the provided Pen.
///
- /// The type of the color.
/// The image this method extends.
/// The options.
/// The pen.
/// The points.
/// The .
- public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, GraphicsOptions options, IPen pen, params PointF[] points)
- where TPixel : struct, IPixel
- => source.Draw(options, pen, new Polygon(new LinearLineSegment(points)));
+ public static IImageProcessingContext DrawPolygon(
+ this IImageProcessingContext source,
+ GraphicsOptions options,
+ IPen pen,
+ params PointF[] points) =>
+ source.Draw(options, pen, new Polygon(new LinearLineSegment(points)));
}
}
\ No newline at end of file
diff --git a/src/ImageSharp.Drawing/Processing/DrawRectangleExtensions.cs b/src/ImageSharp.Drawing/Processing/Extensions/DrawRectangleExtensions.cs
similarity index 57%
rename from src/ImageSharp.Drawing/Processing/DrawRectangleExtensions.cs
rename to src/ImageSharp.Drawing/Processing/Extensions/DrawRectangleExtensions.cs
index 918fb1e738..d0a6c8ccd2 100644
--- a/src/ImageSharp.Drawing/Processing/DrawRectangleExtensions.cs
+++ b/src/ImageSharp.Drawing/Processing/Extensions/DrawRectangleExtensions.cs
@@ -15,80 +15,90 @@ public static class DrawRectangleExtensions
///
/// Draws the outline of the rectangle with the provided pen.
///
- /// The type of the color.
/// The image this method extends.
/// The options.
/// The pen.
/// The shape.
/// The .
- public static IImageProcessingContext Draw(this IImageProcessingContext source, GraphicsOptions options, IPen pen, RectangleF shape)
- where TPixel : struct, IPixel
- => source.Draw(options, pen, new RectangularPolygon(shape.X, shape.Y, shape.Width, shape.Height));
+ public static IImageProcessingContext Draw(
+ this IImageProcessingContext source,
+ GraphicsOptions options,
+ IPen pen,
+ RectangleF shape) =>
+ source.Draw(options, pen, new RectangularPolygon(shape.X, shape.Y, shape.Width, shape.Height));
///
/// Draws the outline of the rectangle with the provided pen.
///
- /// The type of the color.
/// The image this method extends.
/// The pen.
/// The shape.
/// The .
- public static IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, RectangleF shape)
- where TPixel : struct, IPixel
- => source.Draw(GraphicsOptions.Default, pen, shape);
+ public static IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, RectangleF shape) =>
+ source.Draw(GraphicsOptions.Default, pen, shape);
///
/// Draws the outline of the rectangle with the provided brush at the provided thickness.
///
- /// The type of the color.
/// The image this method extends.
/// The options.
/// The brush.
/// The thickness.
/// The shape.
/// The .
- public static IImageProcessingContext Draw(this IImageProcessingContext source, GraphicsOptions options, IBrush brush, float thickness, RectangleF shape)
- where TPixel : struct, IPixel
- => source.Draw(options, new Pen(brush, thickness), shape);
+ public static IImageProcessingContext Draw(
+ this IImageProcessingContext source,
+ GraphicsOptions options,
+ IBrush brush,
+ float thickness,
+ RectangleF shape) =>
+ source.Draw(options, new Pen(brush, thickness), shape);
///
/// Draws the outline of the rectangle with the provided brush at the provided thickness.
///
- /// The type of the color.
/// The image this method extends.
/// The brush.
/// The thickness.
/// The shape.
/// The .
- public static IImageProcessingContext Draw(this IImageProcessingContext source, IBrush brush, float thickness, RectangleF shape)
- where TPixel : struct, IPixel
- => source.Draw(new Pen(brush, thickness), shape);
+ public static IImageProcessingContext Draw(
+ this IImageProcessingContext source,
+ IBrush brush,
+ float thickness,
+ RectangleF shape) =>
+ source.Draw(new Pen(brush, thickness), shape);
///
/// Draws the outline of the rectangle with the provided brush at the provided thickness.
///
- /// The type of the color.
/// The image this method extends.
/// The options.
/// The color.
/// The thickness.
/// The shape.
/// The .
- public static IImageProcessingContext Draw(this IImageProcessingContext source, GraphicsOptions options, TPixel color, float thickness, RectangleF shape)
- where TPixel : struct, IPixel
- => source.Draw(options, new SolidBrush(color), thickness, shape);
+ public static IImageProcessingContext Draw(
+ this IImageProcessingContext source,
+ GraphicsOptions options,
+ Color color,
+ float thickness,
+ RectangleF shape) =>
+ source.Draw(options, new SolidBrush(color), thickness, shape);
///
/// Draws the outline of the rectangle with the provided brush at the provided thickness.
///
- /// The type of the color.
/// The image this method extends.
/// The color.
/// The thickness.
/// The shape.
/// The .
- public static IImageProcessingContext Draw(this IImageProcessingContext source, TPixel color, float thickness, RectangleF shape)
- where TPixel : struct, IPixel
- => source.Draw(new SolidBrush(color), thickness, shape);
+ public static IImageProcessingContext Draw(
+ this IImageProcessingContext source,
+ Color color,
+ float thickness,
+ RectangleF shape) =>
+ source.Draw(new SolidBrush(color), thickness, shape);
}
}
\ No newline at end of file
diff --git a/src/ImageSharp.Drawing/Processing/DrawTextExtensions.cs b/src/ImageSharp.Drawing/Processing/Extensions/DrawTextExtensions.cs
similarity index 59%
rename from src/ImageSharp.Drawing/Processing/DrawTextExtensions.cs
rename to src/ImageSharp.Drawing/Processing/Extensions/DrawTextExtensions.cs
index 46061ce9bc..163a676bbe 100644
--- a/src/ImageSharp.Drawing/Processing/DrawTextExtensions.cs
+++ b/src/ImageSharp.Drawing/Processing/Extensions/DrawTextExtensions.cs
@@ -16,7 +16,6 @@ public static class DrawTextExtensions
///
/// Draws the text onto the the image filled via the brush.
///
- /// The type of the color.
/// The image this method extends.
/// The text.
/// The font.
@@ -25,14 +24,17 @@ public static class DrawTextExtensions
///
/// The .
///
- public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, TPixel color, PointF location)
- where TPixel : struct, IPixel
- => source.DrawText(TextGraphicsOptions.Default, text, font, color, location);
+ public static IImageProcessingContext DrawText(
+ this IImageProcessingContext source,
+ string text,
+ Font font,
+ Color color,
+ PointF location) =>
+ source.DrawText(TextGraphicsOptions.Default, text, font, color, location);
///
/// Draws the text onto the the image filled via the brush.
///
- /// The type of the color.
/// The image this method extends.
/// The options.
/// The text.
@@ -42,14 +44,18 @@ public static IImageProcessingContext DrawText(this IImageProces
///
/// The .
///
- public static IImageProcessingContext DrawText(this IImageProcessingContext source, TextGraphicsOptions options, string text, Font font, TPixel color, PointF location)
- where TPixel : struct, IPixel
- => source.DrawText(options, text, font, Brushes.Solid(color), null, location);
+ public static IImageProcessingContext DrawText(
+ this IImageProcessingContext source,
+ TextGraphicsOptions options,
+ string text,
+ Font font,
+ Color color,
+ PointF location) =>
+ source.DrawText(options, text, font, Brushes.Solid(color), null, location);
///
/// Draws the text onto the the image filled via the brush.
///
- /// The type of the color.
/// The image this method extends.
/// The text.
/// The font.
@@ -58,14 +64,17 @@ public static IImageProcessingContext DrawText(this IImageProces
///
/// The .
///
- public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, IBrush brush, PointF location)
- where TPixel : struct, IPixel
- => source.DrawText(TextGraphicsOptions.Default, text, font, brush, location);
+ public static IImageProcessingContext DrawText(
+ this IImageProcessingContext source,
+ string text,
+ Font font,
+ IBrush brush,
+ PointF location) =>
+ source.DrawText(TextGraphicsOptions.Default, text, font, brush, location);
///
/// Draws the text onto the the image filled via the brush.
///
- /// The type of the color.
/// The image this method extends.
/// The options.
/// The text.
@@ -75,14 +84,18 @@ public static IImageProcessingContext DrawText(this IImageProces
///
/// The .
///
- public static IImageProcessingContext DrawText(this IImageProcessingContext source, TextGraphicsOptions options, string text, Font font, IBrush brush, PointF location)
- where TPixel : struct, IPixel
- => source.DrawText(options, text, font, brush, null, location);
+ public static IImageProcessingContext DrawText(
+ this IImageProcessingContext source,
+ TextGraphicsOptions options,
+ string text,
+ Font font,
+ IBrush brush,
+ PointF location) =>
+ source.DrawText(options, text, font, brush, null, location);
///
/// Draws the text onto the the image outlined via the pen.
///
- /// The type of the color.
/// The image this method extends.
/// The text.
/// The font.
@@ -91,14 +104,17 @@ public static IImageProcessingContext DrawText(this IImageProces
///
/// The .
///
- public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, IPen pen, PointF location)
- where TPixel : struct, IPixel
- => source.DrawText(TextGraphicsOptions.Default, text, font, pen, location);
+ public static IImageProcessingContext DrawText(
+ this IImageProcessingContext source,
+ string text,
+ Font font,
+ IPen pen,
+ PointF location) =>
+ source.DrawText(TextGraphicsOptions.Default, text, font, pen, location);
///
/// Draws the text onto the the image outlined via the pen.
///
- /// The type of the color.
/// The image this method extends.
/// The options.
/// The text.
@@ -108,14 +124,18 @@ public static IImageProcessingContext DrawText(this IImageProces
///
/// The .
///
- public static IImageProcessingContext DrawText(this IImageProcessingContext source, TextGraphicsOptions options, string text, Font font, IPen pen, PointF location)
- where TPixel : struct, IPixel
- => source.DrawText(options, text, font, null, pen, location);
+ public static IImageProcessingContext DrawText(
+ this IImageProcessingContext source,
+ TextGraphicsOptions options,
+ string text,
+ Font font,
+ IPen pen,
+ PointF location) =>
+ source.DrawText(options, text, font, null, pen, location);
///
/// Draws the text onto the the image filled via the brush then outlined via the pen.
///
- /// The type of the color.
/// The image this method extends.
/// The text.
/// The font.
@@ -125,14 +145,18 @@ public static IImageProcessingContext DrawText(this IImageProces
///
/// The .
///
- public static IImageProcessingContext DrawText(this IImageProcessingContext