mirror of https://github.com/SixLabors/ImageSharp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
3.5 KiB
83 lines
3.5 KiB
// <copyright file="FillPolygon.cs" company="James Jackson-South">
|
|
// Copyright (c) James Jackson-South and contributors.
|
|
// Licensed under the Apache License, Version 2.0.
|
|
// </copyright>
|
|
|
|
namespace ImageSharp
|
|
{
|
|
using System;
|
|
using System.Numerics;
|
|
using Drawing;
|
|
using Drawing.Brushes;
|
|
using Drawing.Processors;
|
|
|
|
using SixLabors.Shapes;
|
|
|
|
/// <summary>
|
|
/// Extension methods for the <see cref="Image{TColor}"/> type.
|
|
/// </summary>
|
|
public static partial class ImageExtensions
|
|
{
|
|
/// <summary>
|
|
/// Flood fills the image in the shape of a Linear polygon described by the points
|
|
/// </summary>
|
|
/// <typeparam name="TColor">The type of the color.</typeparam>
|
|
/// <param name="source">The source.</param>
|
|
/// <param name="brush">The brush.</param>
|
|
/// <param name="points">The points.</param>
|
|
/// <param name="options">The options.</param>
|
|
/// <returns>
|
|
/// The Image
|
|
/// </returns>
|
|
public static Image<TColor> FillPolygon<TColor>(this Image<TColor> source, IBrush<TColor> brush, Vector2[] points, GraphicsOptions options)
|
|
where TColor : struct, IPackedPixel, IEquatable<TColor>
|
|
{
|
|
return source.Fill(brush, new Polygon(new LinearLineSegment(points)), options);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Flood fills the image in the shape of a Linear polygon described by the points
|
|
/// </summary>
|
|
/// <typeparam name="TColor">The type of the color.</typeparam>
|
|
/// <param name="source">The source.</param>
|
|
/// <param name="brush">The brush.</param>
|
|
/// <param name="points">The points.</param>
|
|
/// <returns>The Image</returns>
|
|
public static Image<TColor> FillPolygon<TColor>(this Image<TColor> source, IBrush<TColor> brush, Vector2[] points)
|
|
where TColor : struct, IPackedPixel, IEquatable<TColor>
|
|
{
|
|
return source.Fill(brush, new Polygon(new LinearLineSegment(points)));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Flood fills the image in the shape of a Linear polygon described by the points
|
|
/// </summary>
|
|
/// <typeparam name="TColor">The type of the color.</typeparam>
|
|
/// <param name="source">The source.</param>
|
|
/// <param name="color">The color.</param>
|
|
/// <param name="points">The points.</param>
|
|
/// <param name="options">The options.</param>
|
|
/// <returns>
|
|
/// The Image
|
|
/// </returns>
|
|
public static Image<TColor> FillPolygon<TColor>(this Image<TColor> source, TColor color, Vector2[] points, GraphicsOptions options)
|
|
where TColor : struct, IPackedPixel, IEquatable<TColor>
|
|
{
|
|
return source.Fill(new SolidBrush<TColor>(color), new Polygon(new LinearLineSegment(points)), options);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Flood fills the image in the shape of a Linear polygon described by the points
|
|
/// </summary>
|
|
/// <typeparam name="TColor">The type of the color.</typeparam>
|
|
/// <param name="source">The source.</param>
|
|
/// <param name="color">The color.</param>
|
|
/// <param name="points">The points.</param>
|
|
/// <returns>The Image</returns>
|
|
public static Image<TColor> FillPolygon<TColor>(this Image<TColor> source, TColor color, Vector2[] points)
|
|
where TColor : struct, IPackedPixel, IEquatable<TColor>
|
|
{
|
|
return source.Fill(new SolidBrush<TColor>(color), new Polygon(new LinearLineSegment(points)));
|
|
}
|
|
}
|
|
}
|
|
|