// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; using SixLabors.Shapes; namespace SixLabors.ImageSharp.Processing.Overlays { /// /// Adds extensions that allow the drawing of polygon outlines to the type. /// 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 pen. /// The path. /// The options. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, IPath path, GraphicsOptions options) where TPixel : struct, IPixel => source.Fill(pen.StrokeFill, new ShapePath(path, pen), 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 IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, IPath path) where TPixel : struct, IPixel => 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 IImageProcessingContext Draw(this IImageProcessingContext source, IBrush brush, float thickness, IPath path, GraphicsOptions options) where TPixel : struct, IPixel => 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 IImageProcessingContext Draw(this IImageProcessingContext source, IBrush brush, float thickness, IPath path) where TPixel : struct, IPixel => 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 IImageProcessingContext Draw(this IImageProcessingContext source, TPixel color, float thickness, IPath path, GraphicsOptions options) where TPixel : struct, IPixel => 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 IImageProcessingContext Draw(this IImageProcessingContext source, TPixel color, float thickness, IPath path) where TPixel : struct, IPixel => source.Draw(new SolidBrush(color), thickness, path); } }