// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Drawing.Brushes; using SixLabors.ImageSharp.Processing.Drawing.Pens; using SixLabors.Shapes; namespace SixLabors.ImageSharp.Processing.Drawing { /// /// Adds extensions that allow the drawing of collections of polygon outlines to the type. /// 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 { foreach (IPath path in paths) { source.Draw(options, pen, path); } 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 IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, IPathCollection paths) where TPixel : struct, IPixel => 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); /// /// 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); /// /// 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); /// /// 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); } }