// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
using SixLabors.Shapes;
namespace SixLabors.ImageSharp.Processing
{
///
/// Adds extensions that allow the drawing of rectangles to the type.
///
public static class DrawRectangleExtensions
{
///
/// Draws the outline of the rectangle with the provided pen.
///
/// The type of the color.
/// The image this method extends.
/// The options.
/// The pen.
/// The shape.
/// The .
public static IImageProcessingContext Draw(this IImageProcessingContext source, GraphicsOptions options, IPen pen, RectangleF shape)
where TPixel : struct, IPixel
=> source.Draw(options, pen, new RectangularPolygon(shape.X, shape.Y, shape.Width, shape.Height));
///
/// Draws the outline of the rectangle with the provided pen.
///
/// The type of the color.
/// The image this method extends.
/// The pen.
/// The shape.
/// The .
public static IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, RectangleF shape)
where TPixel : struct, IPixel
=> source.Draw(GraphicsOptions.Default, pen, shape);
///
/// Draws the outline of the rectangle 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 shape.
/// The .
public static IImageProcessingContext Draw(this IImageProcessingContext source, GraphicsOptions options, IBrush brush, float thickness, RectangleF shape)
where TPixel : struct, IPixel
=> source.Draw(options, new Pen(brush, thickness), shape);
///
/// Draws the outline of the rectangle 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 IImageProcessingContext Draw(this IImageProcessingContext source, IBrush brush, float thickness, RectangleF shape)
where TPixel : struct, IPixel
=> source.Draw(new Pen(brush, thickness), shape);
///
/// Draws the outline of the rectangle 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 shape.
/// The .
public static IImageProcessingContext Draw(this IImageProcessingContext source, GraphicsOptions options, TPixel color, float thickness, RectangleF shape)
where TPixel : struct, IPixel
=> source.Draw(options, new SolidBrush(color), thickness, shape);
///
/// Draws the outline of the rectangle 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 IImageProcessingContext Draw(this IImageProcessingContext source, TPixel color, float thickness, RectangleF shape)
where TPixel : struct, IPixel
=> source.Draw(new SolidBrush(color), thickness, shape);
}
}