//
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
//
namespace ImageSharp
{
using System;
using System.Numerics;
using Drawing;
using Drawing.Brushes;
using Drawing.Paths;
using Drawing.Pens;
using Drawing.Processing;
using Drawing.Shapes;
///
/// 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 source.
/// The pen.
/// The shape.
/// The options.
///
/// The Image
///
public static Image DrawPolygon(this Image source, IPen pen, IShape shape, GraphicsOptions options)
where TColor : struct, IPackedPixel, IEquatable
{
return source.Apply(new DrawPathProcessor(pen, shape, options));
}
///
/// Draws the outline of the polygon with the provided pen.
///
/// The type of the color.
/// The source.
/// The pen.
/// The shape.
/// The Image
public static Image DrawPolygon(this Image source, IPen pen, IShape shape)
where TColor : struct, IPackedPixel, IEquatable
{
return source.DrawPolygon(pen, shape, GraphicsOptions.Default);
}
///
/// Draws the outline of the polygon with the provided brush at the provided thickness.
///
/// The type of the color.
/// The source.
/// The brush.
/// The thickness.
/// The shape.
/// The options.
///
/// The Image
///
public static Image DrawPolygon(this Image source, IBrush brush, float thickness, IShape shape, GraphicsOptions options)
where TColor : struct, IPackedPixel, IEquatable
{
return source.DrawPolygon(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 source.
/// The brush.
/// The thickness.
/// The shape.
/// The Image
public static Image DrawPolygon(this Image source, IBrush brush, float thickness, IShape shape)
where TColor : struct, IPackedPixel, IEquatable
{
return source.DrawPolygon(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 source.
/// The color.
/// The thickness.
/// The shape.
/// The options.
///
/// The Image
///
public static Image DrawPolygon(this Image source, TColor color, float thickness, IShape shape, GraphicsOptions options)
where TColor : struct, IPackedPixel, IEquatable
{
return source.DrawPolygon(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 source.
/// The color.
/// The thickness.
/// The shape.
/// The Image
public static Image DrawPolygon(this Image source, TColor color, float thickness, IShape shape)
where TColor : struct, IPackedPixel, IEquatable
{
return source.DrawPolygon(new SolidBrush(color), thickness, shape);
}
///
/// Draws the provided Points as a closed Linear Polygon with the provided brush at the provided thickness.
///
/// The type of the color.
/// The source.
/// The brush.
/// The thickness.
/// The points.
/// The options.
///
/// The Image
///
public static Image DrawPolygon(this Image source, IBrush brush, float thickness, Vector2[] points, GraphicsOptions options)
where TColor : struct, IPackedPixel, IEquatable
{
return source.DrawPolygon(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 source.
/// The brush.
/// The thickness.
/// The points.
/// The Image
public static Image DrawPolygon(this Image source, IBrush brush, float thickness, Vector2[] points)
where TColor : struct, IPackedPixel, IEquatable
{
return source.DrawPolygon(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 source.
/// The color.
/// The thickness.
/// The points.
/// The Image
public static Image DrawPolygon(this Image source, TColor color, float thickness, Vector2[] points)
where TColor : struct, IPackedPixel, IEquatable
{
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 source.
/// The color.
/// The thickness.
/// The points.
/// The options.
///
/// The Image
///
public static Image DrawPolygon(this Image source, TColor color, float thickness, Vector2[] points, GraphicsOptions options)
where TColor : struct, IPackedPixel, IEquatable
{
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 source.
/// The pen.
/// The points.
/// The options.
///
/// The Image
///
public static Image DrawPolygon(this Image source, IPen pen, Vector2[] points, GraphicsOptions options)
where TColor : struct, IPackedPixel, IEquatable
{
return source.DrawPolygon(pen, new Polygon(new LinearLineSegment(points)), options);
}
///
/// Draws the provided Points as a closed Linear Polygon with the provided Pen.
///
/// The type of the color.
/// The source.
/// The pen.
/// The points.
/// The Image
public static Image DrawPolygon(this Image source, IPen pen, Vector2[] points)
where TColor : struct, IPackedPixel, IEquatable
{
return source.DrawPolygon(pen, new Polygon(new LinearLineSegment(points)));
}
///
/// Draws the path with the provided pen.
///
/// The type of the color.
/// The source.
/// The pen.
/// The path.
/// The options.
///
/// The Image
///
public static Image DrawPath(this Image source, IPen pen, IPath path, GraphicsOptions options)
where TColor : struct, IPackedPixel, IEquatable
{
return source.Apply(new DrawPathProcessor(pen, path, options));
}
///
/// Draws the path with the provided pen.
///
/// The type of the color.
/// The source.
/// The pen.
/// The path.
/// The Image
public static Image DrawPath(this Image source, IPen pen, IPath path)
where TColor : struct, IPackedPixel, IEquatable
{
return source.Apply(new DrawPathProcessor(pen, path, GraphicsOptions.Default));
}
///
/// Draws the path with the bursh at the privdied thickness.
///
/// The type of the color.
/// The source.
/// The brush.
/// The thickness.
/// The path.
/// The options.
///
/// The Image
///
public static Image DrawPath(this Image source, IBrush brush, float thickness, IPath path, GraphicsOptions options)
where TColor : struct, IPackedPixel, IEquatable
{
return source.DrawPath(new Pen(brush, thickness), path, options);
}
///
/// Draws the path with the bursh at the privdied thickness.
///
/// The type of the color.
/// The source.
/// The brush.
/// The thickness.
/// The path.
/// The Image
public static Image DrawPath(this Image source, IBrush brush, float thickness, IPath path)
where TColor : struct, IPackedPixel, IEquatable
{
return source.DrawPath(new Pen(brush, thickness), path);
}
///
/// Draws the path with the bursh at the privdied thickness.
///
/// The type of the color.
/// The source.
/// The color.
/// The thickness.
/// The path.
/// The options.
///
/// The Image
///
public static Image DrawPath(this Image source, TColor color, float thickness, IPath path, GraphicsOptions options)
where TColor : struct, IPackedPixel, IEquatable
{
return source.DrawPath(new SolidBrush(color), thickness, path, options);
}
///
/// Draws the path with the bursh at the privdied thickness.
///
/// The type of the color.
/// The source.
/// The color.
/// The thickness.
/// The path.
/// The Image
public static Image DrawPath(this Image source, TColor color, float thickness, IPath path)
where TColor : struct, IPackedPixel, IEquatable
{
return source.DrawPath(new SolidBrush(color), thickness, path);
}
///
/// Draws the provided Points as an open Linear path at the provided thickness with the supplied brush
///
/// The type of the color.
/// The source.
/// The brush.
/// The thickness.
/// The points.
/// The options.
///
/// The Image
///
public static Image DrawLines(this Image source, IBrush brush, float thickness, Vector2[] points, GraphicsOptions options)
where TColor : struct, IPackedPixel, IEquatable
{
return source.DrawPath(new Pen(brush, thickness), new Path(new LinearLineSegment(points)), options);
}
///
/// Draws the provided Points as an open Linear path at the provided thickness with the supplied brush
///
/// The type of the color.
/// The source.
/// The brush.
/// The thickness.
/// The points.
/// The Image
public static Image DrawLines(this Image source, IBrush brush, float thickness, Vector2[] points)
where TColor : struct, IPackedPixel, IEquatable
{
return source.DrawPath(new Pen(brush, thickness), new Path(new LinearLineSegment(points)));
}
///
/// Draws the provided Points as an open Linear path at the provided thickness with the supplied brush
///
/// The type of the color.
/// The source.
/// The color.
/// The thickness.
/// The points.
/// The Image
public static Image DrawLines(this Image source, TColor color, float thickness, Vector2[] points)
where TColor : struct, IPackedPixel, IEquatable
{
return source.DrawLines(new SolidBrush(color), thickness, points);
}
///
/// Draws the provided Points as an open Linear path at the provided thickness with the supplied brush
///
/// The type of the color.
/// The source.
/// The color.
/// The thickness.
/// The points.
/// The options.
///
/// The Image
///
public static Image DrawLines(this Image source, TColor color, float thickness, Vector2[] points, GraphicsOptions options)
where TColor : struct, IPackedPixel, IEquatable
{
return source.DrawLines(new SolidBrush(color), thickness, points, options);
}
///
/// Draws the provided Points as an open Linear path with the supplied pen
///
/// The type of the color.
/// The source.
/// The pen.
/// The points.
/// The options.
///
/// The Image
///
public static Image DrawLines(this Image source, IPen pen, Vector2[] points, GraphicsOptions options)
where TColor : struct, IPackedPixel, IEquatable
{
return source.DrawPath(pen, new Path(new LinearLineSegment(points)), options);
}
///
/// Draws the provided Points as an open Linear path with the supplied pen
///
/// The type of the color.
/// The source.
/// The pen.
/// The points.
/// The Image
public static Image DrawLines(this Image source, IPen pen, Vector2[] points)
where TColor : struct, IPackedPixel, IEquatable
{
return source.DrawPath(pen, new Path(new LinearLineSegment(points)));
}
///
/// Draws the provided Points as an open Bezier path at the provided thickness with the supplied brush
///
/// The type of the color.
/// The source.
/// The brush.
/// The thickness.
/// The points.
/// The options.
///
/// The Image
///
public static Image DrawBeziers(this Image source, IBrush brush, float thickness, Vector2[] points, GraphicsOptions options)
where TColor : struct, IPackedPixel, IEquatable
{
return source.DrawPath(new Pen(brush, thickness), new Path(new BezierLineSegment(points)), options);
}
///
/// Draws the provided Points as an open Bezier path at the provided thickness with the supplied brush
///
/// The type of the color.
/// The source.
/// The brush.
/// The thickness.
/// The points.
/// The Image
public static Image DrawBeziers(this Image source, IBrush brush, float thickness, Vector2[] points)
where TColor : struct, IPackedPixel, IEquatable
{
return source.DrawPath(new Pen(brush, thickness), new Path(new BezierLineSegment(points)));
}
///
/// Draws the provided Points as an open Bezier path at the provided thickness with the supplied brush
///
/// The type of the color.
/// The source.
/// The color.
/// The thickness.
/// The points.
/// The Image
public static Image DrawBeziers(this Image source, TColor color, float thickness, Vector2[] points)
where TColor : struct, IPackedPixel, IEquatable
{
return source.DrawBeziers(new SolidBrush(color), thickness, points);
}
///
/// Draws the provided Points as an open Bezier path at the provided thickness with the supplied brush
///
/// The type of the color.
/// The source.
/// The color.
/// The thickness.
/// The points.
/// The options.
///
/// The Image
///
public static Image DrawBeziers(this Image source, TColor color, float thickness, Vector2[] points, GraphicsOptions options)
where TColor : struct, IPackedPixel, IEquatable
{
return source.DrawBeziers(new SolidBrush(color), thickness, points, options);
}
///
/// Draws the provided Points as an open Bezier path with the supplied pen
///
/// The type of the color.
/// The source.
/// The pen.
/// The points.
/// The options.
///
/// The Image
///
public static Image DrawBeziers(this Image source, IPen pen, Vector2[] points, GraphicsOptions options)
where TColor : struct, IPackedPixel, IEquatable
{
return source.DrawPath(pen, new Path(new BezierLineSegment(points)), options);
}
///
/// Draws the provided Points as an open Bezier path with the supplied pen
///
/// The type of the color.
/// The source.
/// The pen.
/// The points.
/// The Image
public static Image DrawBeziers(this Image source, IPen pen, Vector2[] points)
where TColor : struct, IPackedPixel, IEquatable
{
return source.DrawPath(pen, new Path(new BezierLineSegment(points)));
}
}
}