// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // namespace ImageSharp { using Drawing; using Drawing.Brushes; using Drawing.Pens; using ImageSharp.PixelFormats; 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 paths. /// The options. /// The . public static Image Draw(this Image source, IPen pen, IPathCollection paths, GraphicsOptions options) where TPixel : struct, IPixel { foreach (IPath path in paths) { source.Draw(pen, path, options); } return source; } /// /// 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 Image Draw(this Image source, IPen pen, IPathCollection paths) where TPixel : struct, IPixel { return source.Draw(pen, paths, 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 shapes. /// The options. /// The . public static Image Draw(this Image source, IBrush brush, float thickness, IPathCollection paths, GraphicsOptions options) where TPixel : struct, IPixel { return source.Draw(new Pen(brush, thickness), paths, 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 paths. /// The . public static Image Draw(this Image source, IBrush brush, float thickness, IPathCollection paths) where TPixel : struct, IPixel { return 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 color. /// The thickness. /// The paths. /// The options. /// The . public static Image Draw(this Image source, TPixel color, float thickness, IPathCollection paths, GraphicsOptions options) where TPixel : struct, IPixel { return source.Draw(new SolidBrush(color), thickness, paths, 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 paths. /// The . public static Image Draw(this Image source, TPixel color, float thickness, IPathCollection paths) where TPixel : struct, IPixel { return source.Draw(new SolidBrush(color), thickness, paths); } } }