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.
81 lines
3.7 KiB
81 lines
3.7 KiB
// <copyright file="FillPaths.cs" company="James Jackson-South">
|
|
// Copyright (c) James Jackson-South and contributors.
|
|
// Licensed under the Apache License, Version 2.0.
|
|
// </copyright>
|
|
|
|
namespace ImageSharp
|
|
{
|
|
using Drawing;
|
|
using Drawing.Brushes;
|
|
using ImageSharp.PixelFormats;
|
|
using SixLabors.Shapes;
|
|
|
|
/// <summary>
|
|
/// Extension methods for the <see cref="Image{TPixel}"/> type.
|
|
/// </summary>
|
|
public static partial class ImageExtensions
|
|
{
|
|
/// <summary>
|
|
/// Flood fills the image in the shape of the provided polygon with the specified brush..
|
|
/// </summary>
|
|
/// <typeparam name="TPixel">The type of the color.</typeparam>
|
|
/// <param name="source">The image this method extends.</param>
|
|
/// <param name="brush">The brush.</param>
|
|
/// <param name="paths">The shapes.</param>
|
|
/// <param name="options">The graphics options.</param>
|
|
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
|
|
public static IImageProcessorApplicator<TPixel> Fill<TPixel>(this IImageProcessorApplicator<TPixel> source, IBrush<TPixel> brush, IPathCollection paths, GraphicsOptions options)
|
|
where TPixel : struct, IPixel<TPixel>
|
|
{
|
|
foreach (IPath s in paths)
|
|
{
|
|
source.Fill(brush, s, options);
|
|
}
|
|
|
|
return source;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Flood fills the image in the shape of the provided polygon with the specified brush.
|
|
/// </summary>
|
|
/// <typeparam name="TPixel">The type of the color.</typeparam>
|
|
/// <param name="source">The image this method extends.</param>
|
|
/// <param name="brush">The brush.</param>
|
|
/// <param name="paths">The paths.</param>
|
|
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
|
|
public static IImageProcessorApplicator<TPixel> Fill<TPixel>(this IImageProcessorApplicator<TPixel> source, IBrush<TPixel> brush, IPathCollection paths)
|
|
where TPixel : struct, IPixel<TPixel>
|
|
{
|
|
return source.Fill(brush, paths, GraphicsOptions.Default);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Flood fills the image in the shape of the provided polygon with the specified brush..
|
|
/// </summary>
|
|
/// <typeparam name="TPixel">The type of the color.</typeparam>
|
|
/// <param name="source">The image this method extends.</param>
|
|
/// <param name="color">The color.</param>
|
|
/// <param name="paths">The paths.</param>
|
|
/// <param name="options">The options.</param>
|
|
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
|
|
public static IImageProcessorApplicator<TPixel> Fill<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, IPathCollection paths, GraphicsOptions options)
|
|
where TPixel : struct, IPixel<TPixel>
|
|
{
|
|
return source.Fill(new SolidBrush<TPixel>(color), paths, options);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Flood fills the image in the shape of the provided polygon with the specified brush..
|
|
/// </summary>
|
|
/// <typeparam name="TPixel">The type of the color.</typeparam>
|
|
/// <param name="source">The image this method extends.</param>
|
|
/// <param name="color">The color.</param>
|
|
/// <param name="paths">The paths.</param>
|
|
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
|
|
public static IImageProcessorApplicator<TPixel> Fill<TPixel>(this IImageProcessorApplicator<TPixel> source, TPixel color, IPathCollection paths)
|
|
where TPixel : struct, IPixel<TPixel>
|
|
{
|
|
return source.Fill(new SolidBrush<TPixel>(color), paths);
|
|
}
|
|
}
|
|
}
|
|
|