// 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 image this method extends.
/// The options.
/// The pen.
/// The shape.
/// The .
public static IImageProcessingContext Draw(
this IImageProcessingContext source,
GraphicsOptions options,
IPen pen,
RectangleF shape) =>
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 image this method extends.
/// The pen.
/// The shape.
/// The .
public static IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, RectangleF shape) =>
source.Draw(GraphicsOptions.Default, pen, shape);
///
/// Draws the outline of the rectangle with the provided brush at the provided thickness.
///
/// 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) =>
source.Draw(options, new Pen(brush, thickness), shape);
///
/// Draws the outline of the rectangle with the provided brush at the provided thickness.
///
/// 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) =>
source.Draw(new Pen(brush, thickness), shape);
///
/// Draws the outline of the rectangle with the provided brush at the provided thickness.
///
/// The image this method extends.
/// The options.
/// The color.
/// The thickness.
/// The shape.
/// The .
public static IImageProcessingContext Draw(
this IImageProcessingContext source,
GraphicsOptions options,
Color color,
float thickness,
RectangleF shape) =>
source.Draw(options, new SolidBrush(color), thickness, shape);
///
/// Draws the outline of the rectangle with the provided brush at the provided thickness.
///
/// The image this method extends.
/// The color.
/// The thickness.
/// The shape.
/// The .
public static IImageProcessingContext Draw(
this IImageProcessingContext source,
Color color,
float thickness,
RectangleF shape) =>
source.Draw(new SolidBrush(color), thickness, shape);
}
}