// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // namespace ImageSharp { using System; using Drawing; using Drawing.Brushes; using Drawing.Paths; using Drawing.Pens; using Drawing.Processors; using Drawing.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 source. /// The pen. /// The shape. /// The options. /// /// The Image /// public static Image DrawPolygon(this Image source, IPen pen, RectangleF shape, GraphicsOptions options) where TColor : struct, IPackedPixel, IEquatable { return source.Process(new DrawPathProcessor(pen, (IPath)new RectangularPolygon(shape), options)); } /// /// Draws the outline of the polygon with the provided pen. /// /// The type of the color. /// The source. /// The pen. /// The shape. /// The Image public static Image DrawPolygon(this Image source, IPen pen, RectangleF shape) where TColor : struct, IPackedPixel, IEquatable { return source.DrawPolygon(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 brush. /// The thickness. /// The shape. /// The options. /// /// The Image /// public static Image DrawPolygon(this Image source, IBrush brush, float thickness, RectangleF shape, GraphicsOptions options) where TColor : struct, IPackedPixel, IEquatable { return source.DrawPolygon(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 brush. /// The thickness. /// The shape. /// The Image public static Image DrawPolygon(this Image source, IBrush brush, float thickness, RectangleF shape) where TColor : struct, IPackedPixel, IEquatable { return source.DrawPolygon(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 color. /// The thickness. /// The shape. /// The options. /// /// The Image /// public static Image DrawPolygon(this Image source, TColor color, float thickness, RectangleF shape, GraphicsOptions options) where TColor : struct, IPackedPixel, IEquatable { return source.DrawPolygon(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 color. /// The thickness. /// The shape. /// The Image public static Image DrawPolygon(this Image source, TColor color, float thickness, RectangleF shape) where TColor : struct, IPackedPixel, IEquatable { return source.DrawPolygon(new SolidBrush(color), thickness, shape); } } }