diff --git a/ImageSharp.sln b/ImageSharp.sln
index f1e9fb1045..503a5b8601 100644
--- a/ImageSharp.sln
+++ b/ImageSharp.sln
@@ -60,11 +60,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageSharp.Sandbox46", "tes
{2AA31A1F-142C-43F4-8687-09ABCA4B3A26} = {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}
{27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F} = {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}
{7213767C-0003-41CA-AB18-0223CFA7CE4B} = {7213767C-0003-41CA-AB18-0223CFA7CE4B}
+ {E5BD4F96-28A8-410C-8B63-1C5731948549} = {E5BD4F96-28A8-410C-8B63-1C5731948549}
{C77661B9-F793-422E-8E27-AC60ECC5F215} = {C77661B9-F793-422E-8E27-AC60ECC5F215}
{556ABDCF-ED93-4327-BE98-F6815F78B9B8} = {556ABDCF-ED93-4327-BE98-F6815F78B9B8}
{A623CFE9-9D2B-4528-AD1F-2E834B061134} = {A623CFE9-9D2B-4528-AD1F-2E834B061134}
EndProjectSection
EndProject
+Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ImageSharp.Drawing.Paths", "src\ImageSharp.Drawing.Paths\ImageSharp.Drawing.Paths.xproj", "{E5BD4F96-28A8-410C-8B63-1C5731948549}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -115,6 +118,10 @@ Global
{96188137-5FA6-4924-AB6E-4EFF79C6E0BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{96188137-5FA6-4924-AB6E-4EFF79C6E0BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{96188137-5FA6-4924-AB6E-4EFF79C6E0BB}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E5BD4F96-28A8-410C-8B63-1C5731948549}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E5BD4F96-28A8-410C-8B63-1C5731948549}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E5BD4F96-28A8-410C-8B63-1C5731948549}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E5BD4F96-28A8-410C-8B63-1C5731948549}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -132,5 +139,6 @@ Global
{A623CFE9-9D2B-4528-AD1F-2E834B061134} = {815C0625-CD3D-440F-9F80-2D83856AB7AE}
{9E574A07-F879-4811-9C41-5CBDC6BAFDB7} = {815C0625-CD3D-440F-9F80-2D83856AB7AE}
{96188137-5FA6-4924-AB6E-4EFF79C6E0BB} = {56801022-D71A-4FBE-BC5B-CBA08E2284EC}
+ {E5BD4F96-28A8-410C-8B63-1C5731948549} = {815C0625-CD3D-440F-9F80-2D83856AB7AE}
EndGlobalSection
EndGlobal
diff --git a/README.md b/README.md
index 9d947f227e..79f8994629 100644
--- a/README.md
+++ b/README.md
@@ -45,7 +45,9 @@ Packages include:
Contains methods like Resize, Crop, Skew, Rotate - Anything that alters the dimensions of the image.
Contains methods like Gaussian Blur, Pixelate, Edge Detection - Anything that maintains the original image dimensions.
- **ImageSharp.Drawing**
- Brushes and various drawing algorithms.
+ Brushes and various drawing algorithms, including drawing Images
+ - **ImageSharp.Drawing.Paths**
+ Various vector drawing methods for drawing paths, polygons etc.
### Manual build
diff --git a/src/ImageSharp.Drawing.Paths/DrawBeziers.cs b/src/ImageSharp.Drawing.Paths/DrawBeziers.cs
new file mode 100644
index 0000000000..1a511d84d7
--- /dev/null
+++ b/src/ImageSharp.Drawing.Paths/DrawBeziers.cs
@@ -0,0 +1,114 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp
+{
+ using System;
+ using System.Numerics;
+ using Drawing;
+ using Drawing.Brushes;
+ using Drawing.Pens;
+ using Drawing.Processors;
+ using SixLabors.Shapes;
+
+ using Path = SixLabors.Shapes.Path;
+
+ ///
+ /// Extension methods for the type.
+ ///
+ public static partial class ImageExtensions
+ {
+ ///
+ /// 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 options.
+ /// The .
+ public static Image DrawBeziers(this Image source, IBrush brush, float thickness, Vector2[] points, GraphicsOptions options)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.Draw(new Pen(brush, thickness), new Path(new BezierLineSegment(points)), options);
+ }
+
+ ///
+ /// 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 Image DrawBeziers(this Image source, IBrush brush, float thickness, Vector2[] points)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.Draw(new Pen(brush, thickness), new Path(new BezierLineSegment(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 Image DrawBeziers(this Image source, TColor color, float thickness, Vector2[] points)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return 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 color.
+ /// The thickness.
+ /// The points.
+ /// The options.
+ /// The .
+ public static Image DrawBeziers(this Image source, TColor color, float thickness, Vector2[] points, GraphicsOptions options)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.DrawBeziers(new SolidBrush(color), thickness, points, options);
+ }
+
+ ///
+ /// 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 options.
+ /// The .
+ public static Image DrawBeziers(this Image source, IPen pen, Vector2[] points, GraphicsOptions options)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.Draw(pen, new Path(new BezierLineSegment(points)), options);
+ }
+
+ ///
+ /// 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 Image DrawBeziers(this Image source, IPen pen, Vector2[] points)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.Draw(pen, new Path(new BezierLineSegment(points)));
+ }
+ }
+}
diff --git a/src/ImageSharp.Drawing.Paths/DrawLines.cs b/src/ImageSharp.Drawing.Paths/DrawLines.cs
new file mode 100644
index 0000000000..f6f8d8f6c9
--- /dev/null
+++ b/src/ImageSharp.Drawing.Paths/DrawLines.cs
@@ -0,0 +1,112 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp
+{
+ using System;
+ using System.Numerics;
+ using Drawing;
+ using Drawing.Brushes;
+ using Drawing.Pens;
+ using Drawing.Processors;
+ using SixLabors.Shapes;
+
+ ///
+ /// Extension methods for the type.
+ ///
+ public static partial class ImageExtensions
+ {
+ ///
+ /// 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 options.
+ /// The .
+ public static Image DrawLines(this Image source, IBrush brush, float thickness, Vector2[] points, GraphicsOptions options)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.Draw(new Pen(brush, thickness), new Path(new LinearLineSegment(points)), options);
+ }
+
+ ///
+ /// 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 Image DrawLines(this Image source, IBrush brush, float thickness, Vector2[] points)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return 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 Image DrawLines(this Image source, TColor color, float thickness, Vector2[] points)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return 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 color.
+ /// The thickness.
+ /// The points.
+ /// The options.
+ /// The .>
+ public static Image DrawLines(this Image source, TColor color, float thickness, Vector2[] points, GraphicsOptions options)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.DrawLines(new SolidBrush(color), thickness, points, options);
+ }
+
+ ///
+ /// 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 options.
+ /// The .
+ public static Image DrawLines(this Image source, IPen pen, Vector2[] points, GraphicsOptions options)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.Draw(pen, new Path(new LinearLineSegment(points)), options);
+ }
+
+ ///
+ /// 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 Image DrawLines(this Image source, IPen pen, Vector2[] points)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.Draw(pen, new Path(new LinearLineSegment(points)));
+ }
+ }
+}
diff --git a/src/ImageSharp.Drawing.Paths/DrawPath.cs b/src/ImageSharp.Drawing.Paths/DrawPath.cs
new file mode 100644
index 0000000000..4e4275df6e
--- /dev/null
+++ b/src/ImageSharp.Drawing.Paths/DrawPath.cs
@@ -0,0 +1,112 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp
+{
+ using System;
+ using System.Numerics;
+ using Drawing;
+ using Drawing.Brushes;
+ using Drawing.Pens;
+ using Drawing.Processors;
+ using SixLabors.Shapes;
+
+ ///
+ /// Extension methods for the type.
+ ///
+ public static partial class ImageExtensions
+ {
+ ///
+ /// 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 options.
+ /// The .
+ public static Image Draw(this Image source, IPen pen, IPath path, GraphicsOptions options)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.Draw(pen, new ShapePath(path), options);
+ }
+
+ ///
+ /// 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 Image Draw(this Image source, IPen pen, IPath path)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.Draw(pen, path, GraphicsOptions.Default);
+ }
+
+ ///
+ /// 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 shape.
+ /// The options.
+ /// The .
+ public static Image Draw(this Image source, IBrush brush, float thickness, IPath path, GraphicsOptions options)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.Draw(new Pen(brush, thickness), path, options);
+ }
+
+ ///
+ /// 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 Image Draw(this Image source, IBrush brush, float thickness, IPath path)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return 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 color.
+ /// The thickness.
+ /// The path.
+ /// The options.
+ /// The .
+ public static Image Draw(this Image source, TColor color, float thickness, IPath path, GraphicsOptions options)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.Draw(new SolidBrush(color), thickness, path, options);
+ }
+
+ ///
+ /// 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 Image Draw(this Image source, TColor color, float thickness, IPath path)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.Draw(new SolidBrush(color), thickness, path);
+ }
+ }
+}
diff --git a/src/ImageSharp.Drawing.Paths/DrawPolygon.cs b/src/ImageSharp.Drawing.Paths/DrawPolygon.cs
new file mode 100644
index 0000000000..28785e5cbf
--- /dev/null
+++ b/src/ImageSharp.Drawing.Paths/DrawPolygon.cs
@@ -0,0 +1,112 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp
+{
+ using System;
+ using System.Numerics;
+ using Drawing;
+ using Drawing.Brushes;
+ using Drawing.Pens;
+ using Drawing.Processors;
+ using SixLabors.Shapes;
+
+ ///
+ /// Extension methods for the type.
+ ///
+ public static partial class ImageExtensions
+ {
+ ///
+ /// 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 options.
+ /// The .
+ public static Image DrawPolygon(this Image source, IBrush brush, float thickness, Vector2[] points, GraphicsOptions options)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.Draw(new Pen(brush, thickness), new Polygon(new LinearLineSegment(points)), options);
+ }
+
+ ///
+ /// 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 Image DrawPolygon(this Image source, IBrush brush, float thickness, Vector2[] points)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return 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 Image DrawPolygon(this Image source, TColor color, float thickness, Vector2[] points)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return 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 color.
+ /// The thickness.
+ /// The points.
+ /// The options.
+ /// The .
+ public static Image DrawPolygon(this Image source, TColor color, float thickness, Vector2[] points, GraphicsOptions options)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.DrawPolygon(new SolidBrush(color), thickness, points, options);
+ }
+
+ ///
+ /// 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 Image DrawPolygon(this Image source, IPen pen, Vector2[] points)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.Draw(pen, new Polygon(new LinearLineSegment(points)), GraphicsOptions.Default);
+ }
+
+ ///
+ /// 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 options.
+ /// The .
+ public static Image DrawPolygon(this Image source, IPen pen, Vector2[] points, GraphicsOptions options)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.Draw(pen, new Polygon(new LinearLineSegment(points)), options);
+ }
+ }
+}
diff --git a/src/ImageSharp.Drawing/DrawRectangle.cs b/src/ImageSharp.Drawing.Paths/DrawRectangle.cs
similarity index 60%
rename from src/ImageSharp.Drawing/DrawRectangle.cs
rename to src/ImageSharp.Drawing.Paths/DrawRectangle.cs
index 38ed578b65..4e8ec7135b 100644
--- a/src/ImageSharp.Drawing/DrawRectangle.cs
+++ b/src/ImageSharp.Drawing.Paths/DrawRectangle.cs
@@ -9,10 +9,10 @@ namespace ImageSharp
using Drawing;
using Drawing.Brushes;
- using Drawing.Paths;
using Drawing.Pens;
using Drawing.Processors;
- using Drawing.Shapes;
+
+ using SixLabors.Shapes;
///
/// Extension methods for the type.
@@ -23,97 +23,91 @@ namespace ImageSharp
/// Draws the outline of the polygon with the provided pen.
///
/// The type of the color.
- /// The source.
+ /// The image this method extends.
/// The pen.
/// The shape.
/// The options.
- ///
- /// The Image
- ///
- public static Image DrawPolygon(this Image source, IPen pen, RectangleF shape, GraphicsOptions options)
+ /// The .
+ public static Image Draw(this Image source, IPen pen, Rectangle shape, GraphicsOptions options)
where TColor : struct, IPackedPixel, IEquatable
{
- return source.Apply(new DrawPathProcessor(pen, (IPath)new RectangularPolygon(shape), options));
+ return source.Draw(pen, new SixLabors.Shapes.Rectangle(shape.X, shape.Y, shape.Width, shape.Height), options);
}
///
/// Draws the outline of the polygon with the provided pen.
///
/// The type of the color.
- /// The source.
+ /// The image this method extends.
/// The pen.
/// The shape.
- /// The Image
- public static Image DrawPolygon(this Image source, IPen pen, RectangleF shape)
+ /// The .
+ public static Image Draw(this Image source, IPen pen, Rectangle shape)
where TColor : struct, IPackedPixel, IEquatable
{
- return source.DrawPolygon(pen, shape, GraphicsOptions.Default);
+ return source.Draw(pen, shape, GraphicsOptions.Default);
}
///
/// Draws the outline of the polygon with the provided brush at the provided thickness.
///
/// The type of the color.
- /// The source.
+ /// The image this method extends.
/// The brush.
/// The thickness.
/// The shape.
/// The options.
- ///
- /// The Image
- ///
- public static Image DrawPolygon(this Image source, IBrush brush, float thickness, RectangleF shape, GraphicsOptions options)
+ /// The .
+ public static Image Draw(this Image source, IBrush brush, float thickness, Rectangle shape, GraphicsOptions options)
where TColor : struct, IPackedPixel, IEquatable
{
- return source.DrawPolygon(new Pen(brush, thickness), shape, options);
+ return source.Draw(new Pen(brush, thickness), shape, options);
}
///
/// Draws the outline of the polygon with the provided brush at the provided thickness.
///
/// The type of the color.
- /// The source.
+ /// The image this method extends.
/// The brush.
/// The thickness.
/// The shape.
- /// The Image
- public static Image DrawPolygon(this Image source, IBrush brush, float thickness, RectangleF shape)
+ /// The .
+ public static Image Draw(this Image source, IBrush brush, float thickness, Rectangle shape)
where TColor : struct, IPackedPixel, IEquatable
{
- return source.DrawPolygon(new Pen(brush, thickness), shape);
+ return source.Draw(new Pen(brush, thickness), shape);
}
///
/// Draws the outline of the polygon with the provided brush at the provided thickness.
///
/// The type of the color.
- /// The source.
+ /// The image this method extends.
/// The color.
/// The thickness.
/// The shape.
/// The options.
- ///
- /// The Image
- ///
- public static Image DrawPolygon(this Image source, TColor color, float thickness, RectangleF shape, GraphicsOptions options)
+ /// The .
+ public static Image Draw(this Image source, TColor color, float thickness, Rectangle shape, GraphicsOptions options)
where TColor : struct, IPackedPixel, IEquatable
{
- return source.DrawPolygon(new SolidBrush(color), thickness, shape, options);
+ return source.Draw(new SolidBrush(color), thickness, shape, options);
}
///
/// Draws the outline of the polygon with the provided brush at the provided thickness.
///
/// The type of the color.
- /// The source.
+ /// The image this method extends.
/// The color.
/// The thickness.
/// The shape.
- /// The Image
- public static Image DrawPolygon(this Image source, TColor color, float thickness, RectangleF shape)
+ /// The .
+ public static Image Draw(this Image source, TColor color, float thickness, Rectangle shape)
where TColor : struct, IPackedPixel, IEquatable
{
- return source.DrawPolygon(new SolidBrush(color), thickness, shape);
+ return source.Draw(new SolidBrush(color), thickness, shape);
}
}
}
diff --git a/src/ImageSharp.Drawing.Paths/DrawShape.cs b/src/ImageSharp.Drawing.Paths/DrawShape.cs
new file mode 100644
index 0000000000..6ddce65b98
--- /dev/null
+++ b/src/ImageSharp.Drawing.Paths/DrawShape.cs
@@ -0,0 +1,112 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp
+{
+ using System;
+ using System.Numerics;
+ using Drawing;
+ using Drawing.Brushes;
+ using Drawing.Pens;
+ using Drawing.Processors;
+ using SixLabors.Shapes;
+
+ ///
+ /// Extension methods for the type.
+ ///
+ public static partial class ImageExtensions
+ {
+ ///
+ /// Draws the outline of the polygon with the provided pen.
+ ///
+ /// The type of the color.
+ /// The image this method extends.
+ /// The pen.
+ /// The shape.
+ /// The options.
+ /// The .
+ public static Image Draw(this Image source, IPen pen, IShape shape, GraphicsOptions options)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.Draw(pen, new ShapePath(shape), options);
+ }
+
+ ///
+ /// Draws the outline of the polygon with the provided pen.
+ ///
+ /// The type of the color.
+ /// The image this method extends.
+ /// The pen.
+ /// The shape.
+ /// The .
+ public static Image Draw(this Image source, IPen pen, IShape shape)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.Draw(pen, shape, GraphicsOptions.Default);
+ }
+
+ ///
+ /// 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 shape.
+ /// The options.
+ /// The .
+ public static Image Draw(this Image source, IBrush brush, float thickness, IShape shape, GraphicsOptions options)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.Draw(new Pen(brush, thickness), shape, options);
+ }
+
+ ///
+ /// 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 shape.
+ /// The .
+ public static Image Draw(this Image source, IBrush brush, float thickness, IShape shape)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.Draw(new Pen(brush, thickness), shape);
+ }
+
+ ///
+ /// 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 shape.
+ /// The options.
+ /// The .
+ public static Image Draw(this Image source, TColor color, float thickness, IShape shape, GraphicsOptions options)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.Draw(new SolidBrush(color), thickness, shape, options);
+ }
+
+ ///
+ /// 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 shape.
+ /// The .
+ public static Image Draw(this Image source, TColor color, float thickness, IShape shape)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.Draw(new SolidBrush(color), thickness, shape);
+ }
+ }
+}
diff --git a/src/ImageSharp.Drawing.Paths/FillPaths.cs b/src/ImageSharp.Drawing.Paths/FillPaths.cs
new file mode 100644
index 0000000000..09a799794c
--- /dev/null
+++ b/src/ImageSharp.Drawing.Paths/FillPaths.cs
@@ -0,0 +1,79 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp
+{
+ using System;
+ using System.Numerics;
+ using Drawing;
+ using Drawing.Brushes;
+ using Drawing.Processors;
+
+ using SixLabors.Shapes;
+
+ ///
+ /// Extension methods for the type.
+ ///
+ public static partial class ImageExtensions
+ {
+ ///
+ /// Flood fills the image in the shape of the provided polygon with the specified brush..
+ ///
+ /// The type of the color.
+ /// The image this method extends.
+ /// The brush.
+ /// The shape.
+ /// The graphics options.
+ /// The .
+ public static Image Fill(this Image source, IBrush brush, IPath path, GraphicsOptions options)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.Fill(brush, new ShapeRegion(path), options);
+ }
+
+ ///
+ /// Flood fills the image in the shape of the provided polygon with the specified brush.
+ ///
+ /// The type of the color.
+ /// The image this method extends.
+ /// The brush.
+ /// The path.
+ /// The .
+ public static Image Fill(this Image source, IBrush brush, IPath path)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.Fill(brush, new ShapeRegion(path), GraphicsOptions.Default);
+ }
+
+ ///
+ /// Flood fills the image in the shape of the provided polygon with the specified brush..
+ ///
+ /// The type of the color.
+ /// The image this method extends.
+ /// The color.
+ /// The path.
+ /// The options.
+ /// The .
+ public static Image Fill(this Image source, TColor color, IPath path, GraphicsOptions options)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.Fill(new SolidBrush(color), path, options);
+ }
+
+ ///
+ /// Flood fills the image in the shape of the provided polygon with the specified brush..
+ ///
+ /// The type of the color.
+ /// The image this method extends.
+ /// The color.
+ /// The path.
+ /// The .
+ public static Image Fill(this Image source, TColor color, IPath path)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.Fill(new SolidBrush(color), path);
+ }
+ }
+}
diff --git a/src/ImageSharp.Drawing.Paths/FillPolygon.cs b/src/ImageSharp.Drawing.Paths/FillPolygon.cs
new file mode 100644
index 0000000000..a609ceed24
--- /dev/null
+++ b/src/ImageSharp.Drawing.Paths/FillPolygon.cs
@@ -0,0 +1,79 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp
+{
+ using System;
+ using System.Numerics;
+ using Drawing;
+ using Drawing.Brushes;
+ using Drawing.Processors;
+
+ using SixLabors.Shapes;
+
+ ///
+ /// Extension methods for the type.
+ ///
+ public static partial class ImageExtensions
+ {
+ ///
+ /// Flood fills the image in the shape of a Linear polygon described by the points
+ ///
+ /// The type of the color.
+ /// The image this method extends.
+ /// The brush.
+ /// The points.
+ /// The options.
+ /// The .
+ public static Image FillPolygon(this Image source, IBrush brush, Vector2[] points, GraphicsOptions options)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.Fill(brush, new Polygon(new LinearLineSegment(points)), options);
+ }
+
+ ///
+ /// Flood fills the image in the shape of a Linear polygon described by the points
+ ///
+ /// The type of the color.
+ /// The image this method extends.
+ /// The brush.
+ /// The points.
+ /// The .
+ public static Image FillPolygon(this Image source, IBrush brush, Vector2[] points)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.Fill(brush, new Polygon(new LinearLineSegment(points)));
+ }
+
+ ///
+ /// Flood fills the image in the shape of a Linear polygon described by the points
+ ///
+ /// The type of the color.
+ /// The image this method extends.
+ /// The color.
+ /// The points.
+ /// The options.
+ /// The .
+ public static Image FillPolygon(this Image source, TColor color, Vector2[] points, GraphicsOptions options)
+ where TColor : struct, IPackedPixel, IEquatable
+ {
+ return source.Fill(new SolidBrush(color), new Polygon(new LinearLineSegment(points)), options);
+ }
+
+ ///