// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Drawing;
using SixLabors.ImageSharp.Drawing.Brushes;
using SixLabors.ImageSharp.Drawing.Pens;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp
{
///
/// 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 IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, RectangleF shape, GraphicsOptions options)
where TPixel : struct, IPixel
{
return source.Draw(pen, new SixLabors.Shapes.RectangularePolygon(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 IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, RectangleF 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 IImageProcessingContext Draw(this IImageProcessingContext source, IBrush brush, float thickness, RectangleF 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 IImageProcessingContext Draw(this IImageProcessingContext source, IBrush brush, float thickness, RectangleF 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 IImageProcessingContext Draw(this IImageProcessingContext source, TPixel color, float thickness, RectangleF 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 IImageProcessingContext Draw(this IImageProcessingContext source, TPixel color, float thickness, RectangleF shape)
where TPixel : struct, IPixel
{
return source.Draw(new SolidBrush(color), thickness, shape);
}
}
}