// // 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 source. /// The brush. /// The thickness. /// The points. /// The options. /// /// The Image /// 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 source. /// The brush. /// The thickness. /// The points. /// The Image 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 source. /// The color. /// The thickness. /// The points. /// The Image 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 source. /// The color. /// The thickness. /// The points. /// The options. /// /// The Image /// 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 source. /// The pen. /// The points. /// The options. /// /// The Image /// 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); } } }