//
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
//
namespace ImageSharp
{
using System.Numerics;
using Drawing;
using Drawing.Brushes;
using Drawing.Pens;
using ImageSharp.PixelFormats;
using SixLabors.Primitives;
using SixLabors.Shapes;
///
/// Extension methods for the type.
///
public static partial class ImageExtensions
{
///
/// Draws the provided Points as a closed Linear Polygon with the provided brush at the provided thickness.
///
/// The type of the color.
/// The image this method extends.
/// The brush.
/// The thickness.
/// The points.
/// The options.
/// The .
public static IImageProcessorApplicator DrawPolygon(this IImageProcessorApplicator source, IBrush brush, float thickness, PointF[] points, GraphicsOptions options)
where TPixel : struct, IPixel
{
return source.Draw(new Pen(brush, thickness), new Polygon(new LinearLineSegment(points)), options);
}
///
/// Draws the provided Points as a closed Linear Polygon with the provided brush at the provided thickness.
///
/// The type of the color.
/// The image this method extends.
/// The brush.
/// The thickness.
/// The points.
/// The .
public static IImageProcessorApplicator DrawPolygon(this IImageProcessorApplicator source, IBrush brush, float thickness, PointF[] points)
where TPixel : struct, IPixel
{
return 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 type of the color.
/// The image this method extends.
/// The color.
/// The thickness.
/// The points.
/// The .
public static IImageProcessorApplicator DrawPolygon(this IImageProcessorApplicator source, TPixel color, float thickness, PointF[] points)
where TPixel : struct, IPixel
{
return 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 type of the color.
/// The image this method extends.
/// The color.
/// The thickness.
/// The points.
/// The options.
/// The .
public static IImageProcessorApplicator DrawPolygon(this IImageProcessorApplicator source, TPixel color, float thickness, PointF[] points, GraphicsOptions options)
where TPixel : struct, IPixel
{
return source.DrawPolygon(new SolidBrush(color), thickness, points, options);
}
///
/// Draws the provided Points as a closed Linear Polygon with the provided Pen.
///
/// The type of the color.
/// The image this method extends.
/// The pen.
/// The points.
/// The .
public static IImageProcessorApplicator DrawPolygon(this IImageProcessorApplicator source, IPen pen, PointF[] points)
where TPixel : struct, IPixel
{
return source.Draw(pen, new Polygon(new LinearLineSegment(points)), GraphicsOptions.Default);
}
///
/// Draws the provided Points as a closed Linear Polygon with the provided Pen.
///
/// The type of the color.
/// The image this method extends.
/// The pen.
/// The points.
/// The options.
/// The .
public static IImageProcessorApplicator DrawPolygon(this IImageProcessorApplicator source, IPen pen, PointF[] points, GraphicsOptions options)
where TPixel : struct, IPixel
{
return source.Draw(pen, new Polygon(new LinearLineSegment(points)), options);
}
}
}