// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.Primitives;
using SixLabors.Shapes;
namespace SixLabors.ImageSharp.Processing
{
///
/// Adds extensions that allow the drawing of closed linear polygons to the type.
///
public static class DrawPolygonExtensions
{
///
/// Draws the provided Points as a closed Linear Polygon with the provided brush at the provided thickness.
///
/// The image this method extends.
/// The options.
/// The brush.
/// The thickness.
/// The points.
/// The .
public static IImageProcessingContext DrawPolygon(
this IImageProcessingContext source,
GraphicsOptions options,
IBrush brush,
float thickness,
params PointF[] points) =>
source.Draw(options, 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 image this method extends.
/// The brush.
/// The thickness.
/// The points.
/// The .
public static IImageProcessingContext DrawPolygon(
this IImageProcessingContext source,
IBrush brush,
float thickness,
params PointF[] points) =>
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 image this method extends.
/// The color.
/// The thickness.
/// The points.
/// The .
public static IImageProcessingContext DrawPolygon(
this IImageProcessingContext source,
Color color,
float thickness,
params PointF[] points) =>
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 image this method extends.
/// The options.
/// The color.
/// The thickness.
/// The points.
/// The .
public static IImageProcessingContext DrawPolygon(
this IImageProcessingContext source,
GraphicsOptions options,
Color color,
float thickness,
params PointF[] points) =>
source.DrawPolygon(options, new SolidBrush(color), thickness, points);
///
/// Draws the provided Points as a closed Linear Polygon with the provided Pen.
///
/// The image this method extends.
/// The pen.
/// The points.
/// The .
public static IImageProcessingContext DrawPolygon(
this IImageProcessingContext source,
IPen pen,
params PointF[] points) =>
source.Draw(GraphicsOptions.Default, pen, new Polygon(new LinearLineSegment(points)));
///
/// Draws the provided Points as a closed Linear Polygon with the provided Pen.
///
/// The image this method extends.
/// The options.
/// The pen.
/// The points.
/// The .
public static IImageProcessingContext DrawPolygon(
this IImageProcessingContext source,
GraphicsOptions options,
IPen pen,
params PointF[] points) =>
source.Draw(options, pen, new Polygon(new LinearLineSegment(points)));
}
}