// // 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.Pens; /// /// 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 shape. /// The options. /// The . public static Image Draw(this Image source, IPen pen, Rectangle shape, GraphicsOptions options) where TPixel : struct, IPixel { return source.Draw(pen, new SixLabors.Shapes.Rectangle(shape.X, shape.Y, shape.Width, shape.Height), options); } /// /// Draws the outline of the polygon with the provided pen. /// /// The type of the color. /// The image this method extends. /// The pen. /// The shape. /// The . public static Image Draw(this Image source, IPen pen, Rectangle shape) where TPixel : struct, IPixel { return source.Draw(pen, shape, 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 Image Draw(this Image source, IBrush brush, float thickness, Rectangle shape, GraphicsOptions options) where TPixel : struct, IPixel { return source.Draw(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 image this method extends. /// The brush. /// The thickness. /// The shape. /// The . public static Image Draw(this Image source, IBrush brush, float thickness, Rectangle shape) where TPixel : struct, IPixel { return source.Draw(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 image this method extends. /// The color. /// The thickness. /// The shape. /// The options. /// The . public static Image Draw(this Image source, TPixel color, float thickness, Rectangle shape, GraphicsOptions options) where TPixel : struct, IPixel { return source.Draw(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 image this method extends. /// The color. /// The thickness. /// The shape. /// The . public static Image Draw(this Image source, TPixel color, float thickness, Rectangle shape) where TPixel : struct, IPixel { return source.Draw(new SolidBrush(color), thickness, shape); } } }